function _objectWithoutProperties(a,b){var c={};for(var d in a)b.indexOf(d)>=0||Object.prototype.hasOwnProperty.call(a,d)&&(c[d]=a[d]);return c}define("core/utils/getEmbeddedData",[],function(){"use strict";return function(a){var b=window.document.getElementById("disqus-"+a);try{return b&&JSON.parse(b.textContent||b.innerHTML)}catch(c){return null}}}),define("core/utils/cookies",[],function(){"use strict";var a={_doc:window.document,create:function(b,c,d){d||(d={});var e=b+"="+c+"; path="+(d.path||"/"),f=d.domain,g=d.expiresIn;if(f&&(e+="; domain=."+f),"[object Number]"===Object.prototype.toString.call(g)){var h=new Date((new Date).getTime()+g);e+="; expires="+h.toGMTString()}"https:"===a._doc.location.protocol&&(e+="; secure"),e+="; SameSite=None",a._doc.cookie=e},read:function(b){for(var c,d=b+"=",e=a._doc.cookie.split(";"),f=0;f2048&&this.has("page_referrer")){var f=window.document.createElement("a");f.href=this.get("page_referrer");var g=f.hostname;g&&(c.page_referrer_domain=g),delete c.page_referrer}return c},emit:function(c){return a.ajax({url:b.result(this,"url"),data:this.decoratePayload(c),dataType:"script",cache:!0})}}),g=function(b){var c=new window.Image;return c.src=e.jester+"/stat.gif?"+a.param({event:b}),c},h=function(c,d){if(!b.any(d,function(a){return a<0})){b.each(d,function(a,b){d[b]=Math.round(a)});var f=new window.Image;return f.src=e.jester+"/telemetry/"+c+".gif?"+a.param(d),f}},i=new f;return i.setHostReferrer(window.document.referrer),{ActivityClient:f,client:i,logStat:g,telemetry:h}}),define("core/utils/urls",[],function(){"use strict";var a={},b=window.document.createElement("a");return a.getOrigin=function(a){b.href=a;var c=b.href.split("/");return c[0]+"//"+c[2]},a.getHostName=function(a){return b.href=a,b.hostname},a.getDomainPart=function(b,c){"undefined"==typeof c&&(c=0);var d=a.getHostName(b),e=d.split(".").reverse();return e[c]},a.getQuery=function(a){return b.href=a,b.search},a.getPathname=function(a){return b.href=a,b.pathname},a}),define("core/frameBus",["jquery","underscore","backbone","core/utils/urls"],function(a,b,c,d){"use strict";var e=window.opener||window.parent,f=window.name,g=window.document.referrer,h={};h.client=d.getOrigin(window.document.location.href),h.secureClient=h.client.replace(/^\w+:\/\//,"https://"),h.host=g?d.getOrigin(g):h.client;var i={origins:h,messageHandler:function(a){a=a.originalEvent;var b;try{b=JSON.parse(a.data)}catch(c){return}b.name&&"!"===b.name[0]&&a.origin!==h.client&&a.origin!==h.secureClient||"client"===b.scope&&i.trigger(b.name,b.data)},postMessage:function(a){a=JSON.stringify(a),e.postMessage(a,"*")},sendHostMessage:function(a,b){b=b||[],i.postMessage({scope:"host",sender:f,name:a,data:b})}};return b.extend(i,c.Events),a(window).on("message",i.messageHandler),a(window).on("unload",function(){i.sendHostMessage("die")}),window.DISQUS=window.DISQUS||{},window.DISQUS.Bus=i,i}),define("core/bus",["backbone","underscore","core/frameBus"],function(a,b,c){"use strict";var d=b.extend({},a.Events);return d.frame=c,d}),define("core/utils/storage",[],function(){"use strict";var a=function(a){var b="_dsqstorage_";try{return a.localStorage.setItem(b,b),a.localStorage.getItem(b),a.localStorage.removeItem(b),!0}catch(c){return!1}}(window),b=function(){var a={};return{getItem:function(b){return a.hasOwnProperty(b)?a[b]:null},setItem:function(b,c){a[b]=String(c)},removeItem:function(b){delete a[b]},clear:function(){a={}}}}();return{get:function(a){var b=null;try{return b=this.backend.getItem(a),JSON.parse(b)}catch(c){return b}},set:function(a,b){try{this.backend.setItem(a,JSON.stringify(b))}catch(c){}},remove:function(a){try{this.backend.removeItem(a)}catch(b){}},clear:function(){try{this.backend.clear()}catch(a){}},backend:a?window.localStorage:b,isPersistent:a}}),define("core/utils/auth",["core/utils/cookies"],function(a){"use strict";var b={},c="disqusauth";return b.getFromCookie=function(){var b=(a.read(c)||"").replace(/"/g,"").split("|");!b||b[1]&&b[6]||(b=[],a.erase(c,{}));var d=parseInt(b[6]||"0",10);return{avatarUrl:b[7]?decodeURIComponent(b[7]):void 0,datetimeFormatting:parseInt(b[4],10)?"absolute":"relative",id:d,isModerator:parseInt(b[8],10)>0,staff:Boolean(parseInt(b[2],10)),tzOffset:b[5],username:b[1],isAuthenticated:Boolean(d&&"0"!==d)}},b}),define("core/switches",["underscore","remote/config","core/analytics/identity","core/utils/storage","core/utils/auth"],function(a,b,c,d,e){"use strict";var f="switch:",g={},h={};return h._getKey=function(a){return f+a},h.disableFeature=function(a){g[a]=!1},h.resetFeature=function(a){g[a]=null},h.forceFeature=function(a){g[a]=!0},h.getSwitchContext=function(a){var c=d.get(this._getKey(a));if(null!==c)return c;var e=g[a];return null!=e?e:(b.lounge&&b.lounge.switches||{})[a]},h.isFeatureActive=function(b,d){var f=h.getSwitchContext(b);if(a.isBoolean(f))return f;if(!f)return!1;var g=e.getFromCookie(),i={percent:c.clientPercent(),user_id:g.id,username:g.username,is_staff:g.staff,is_moderator:g.isModerator},j=a.defaults(d||{},i);return a.any(f,function(b,d){var e=j[d];return/percent$/.test(d)&&a.isNumber(b)?a.isNumber(e)?b>e:!!a.isString(e)&&b>c.getPercentBucketForString(e):a.isArray(b)?a.contains(b,e):b===e})},h}),define("core/utils/isAdBlockEnabled",[],function(){"use strict";var a="adsbox",b=100,c=window.document;return function(d){if(d){var e=c.createElement("div");e.innerHTML=" ",e.className=a,c.body.appendChild(e),setTimeout(function(){d(0===e.offsetHeight),c.body.removeChild(e)},b)}}}),define("core/utils/html/toRGBColorString",[],function(){"use strict";var a="Color components should be numbers.";return function(b){var c=Number(b.red),d=Number(b.green),e=Number(b.blue);if(isNaN(c)||isNaN(d)||isNaN(e))throw new Error(a);var f="rgb",g=[c,d,e],h=b.alpha;if(h){if(h=Number(h),isNaN(h))throw new Error(a);f+="a",g.push(h)}return f+"("+g+")"}}),define("common/utils",["jquery","underscore","loglevel","common/main","common/urls","core/utils/cookies"],function(a,b,c,d,e,f){"use strict";var g=window.document,h={};h.globalUniqueId=function(a){return b.uniqueId(a)+"_"+Number(new Date)},h.addStylesheetRules=function(a){function c(){var e=b.find(g.styleSheets,function(a){var b=a.ownerNode||a.owningElement;return b.id===d});if(!e)return void setTimeout(c,50);for(var f=0,h=a.length;f=200&&c<300?a():b&&(c<200||c>=300)&&b()},XHR2:function(a,b,c,d){var e=i.handler,f=new window.XMLHttpRequest;return f.open(a,b,!0),f.onreadystatechange=function(){f.readyState===window.XMLHttpRequest.DONE&&e(c,d,f.status)},f}};i.request=function(){return"withCredentials"in new window.XMLHttpRequest?i.XHR2:function(){return null}}(),h.isWindowClosed=function(a){if(!a)return!0;try{return a.closed||void 0===a.closed}catch(b){return!0}},h.truncate=function(a,b,c){return c=c||"...",a.length>b?a.slice(0,b)+c:a},h.extractDomainForCookies=function(a){return a.split("/")[2].replace(/:[0-9]+/,"")},h.cookies={domain:h.extractDomainForCookies(e.root),create:function(a,b){var c=31536e6;f.create(a,b,{domain:h.cookies.domain,expiresIn:c})},read:f.read,erase:function(a){f.erase(a,{domain:h.cookies.domain})}},h.updateURL=function(a,c){var d,e=g.createElement("a");return c=c||{},e.href=a,c.hostname&&c.hostname.match(/\.$/)&&(c.hostname+=e.hostname),d=b.extend({protocol:e.protocol,hostname:e.hostname,pathname:e.pathname,search:e.search},c),d.pathname.match(/^\//)||(d.pathname="/"+d.pathname),d.protocol+"//"+d.hostname+d.pathname+d.search},h.injectBaseElement=function(a,b){b=b||g;var c=b.getElementsByTagName("base")[0]||b.createElement("base");c.target="_parent",a?c.href=a:c.removeAttribute("href"),c.parentNode||(b.head||b.getElementsByTagName("head")[0]).appendChild(c)},h.syntaxHighlighter=function(){var c=1,e=2,f=null,g=null,h=[],i={highlight:function(a){null===g&&i._load(),h.push(a),g===e&&i.scheduleHighlight()},_highlight:function(b){var c=a(b).html();a(b).html(c.replace(/^
/,"")),f.highlightBlock(b),i.scheduleHighlight()},scheduleHighlight:function(){var a=h.shift();a&&window.requestAnimationFrame(b.bind(i._highlight,i,a))},_load:function(){g=c,d.loadCss("https://c.disquscdn.com/next/embed/styles/highlight.3128dd90ecaebd8542ac3442033f3f00.css"),require(["common/vendor_extensions/highlight"],function(a){g=e,f=a,i.scheduleHighlight()})}};return i}();var j=a("html");h.getPageHeight=function(){var b=a("#tos__message"),c=b.outerHeight();return c&&(c+=b.offset().top),Math.max(c,j.height())},h.calculatePositionFullscreen=function(){return{pageOffset:a(window).scrollTop(),height:g.documentElement.clientHeight,frameOffset:{left:0,top:0}}},h.triggerClick=function(a,b){var c,d,e=a[0],f={altKey:!1,button:0,ctrlKey:!1,metaKey:!1,shiftKey:!1};if(g.createEvent){if(c=g.createEvent("MouseEvents"),b)for(d in f)f.hasOwnProperty(d)&&b.hasOwnProperty(d)&&(f[d]=b[d]);c.initMouseEvent("click",!0,!0,window,0,0,0,0,0,f.ctrlKey,f.altKey,f.shiftKey,f.metaKey,0,null),e.dispatchEvent&&e.dispatchEvent(c)}else if(g.createEventObject){if(c=g.createEventObject(),c.eventType="click",b)for(d in f)f.hasOwnProperty(d)&&b.hasOwnProperty(d)&&(c[d]=b[d]);e.fireEvent("onclick",c)}},h.delayLinkClick=function(a,c){a.preventDefault(),b.delay(b.bind(h.triggerClick,this,c,a.originalEvent),100)},h.mixin=function(a,c,d){var e=a.prototype,f=b.extend({},c,d);if(b.defaults(e,f),b.defaults(e.events,f.events),void 0!==e.initialize&&void 0!==f.initialize){var g=e.initialize;e.initialize=function(){var a=g.apply(this,arguments);return f.initialize.apply(this,arguments),a}}return a},h.extractService=function(b,c){var d="[data-action^="+c+"]",e=a(b);e=e.is(d)&&e||e.closest(d);var f=e.attr("data-action")||":",g=f.split(":")[1];return g},h.getConfigFromHash=function(a){var d,e=a.location.hash;try{d=JSON.parse(decodeURIComponent(String(e).substr(1)))}catch(f){c.debug("Failed to parse config from URL hash",f)}return b.isObject(d)?d:{}};var k=/[<>]|:\/\//;return h.isPlainText=function(a){return!a.match(k)},h.isDNTEnabled=function(a){return a||(a=window),"1"===a.navigator.doNotTrack||"yes"===a.navigator.doNotTrack||"1"===a.navigator.msDoNotTrack},h.shouldSample=function(a){var b=parseInt(a,10);return!!b&&(!(b>100)&&Math.random()").hide().attr("src",g))}catch(h){c.captureException(h)}u=!0}})}var s={},t=!1,u=!1,v=!1;return s.init=function(a){r(window,a)},s.getEventTrackingArea=function(b){return a(b.currentTarget).closest("[data-tracking-area]").attr("data-tracking-area")},s.load3rdParties=function(d,e){if(n.glitter&&!t){var f=m.lounge.tracking||{},g=f.iframe_limit||0,h={postCount:d.get("posts")||0,likeCount:d.get("likes")||0,postVoteCount:b.reduce(d.posts.pluck("likes"),function(a,b){return a+b},0)};a.ajax({dataType:"jsonp",cache:!0,url:n.glitter,data:{forum_shortname:d.forum.id,thread_id:d.id,referer:e.config.hostReferrer},jsonpCallback:"dsqGlitterResponseHandler",success:function(d){var e=a("body");b.each(d,function(d){if(!("img"!==d.type&&"iframe"!==d.type||"iframe"===d.type&&(g-=1,g<0))){var f;try{f=d.url.replace(/\{\{(.+?)\}\}/g,function(a,c){var d=c.trim();if(!h.hasOwnProperty(d))throw new Error("Unknown template variable in tracker URL: "+d);return b.escape(h[d])}),e.append(a("<"+d.type+">").hide().attr("src",f))}catch(i){c.captureException(i)}}})}}),t=!0}},s.shouldTrack=function(a,b){return!(a&&a.get("settings").disable3rdPartyTrackers||b&&b.get("disable3rdPartyTrackers")||"1"===o.cookies.read("disqus_tracking_optout")||o.isDNTEnabled()||s.isPrivate(b))},s.isPrivate=function(a){return q.getLounge().config.isPrivate&&(!a||!a.get("hasAcceptedGdprTerms"))&&!v},s.reset=function(){t=!1,u=!1,v=!1},s}),define("common/jsxUtils",["underscore"],function(a){"use strict";return{append:function(b,c){var d=function e(c){if(null!==c)return a.isArray(c)?void c.forEach(e):a.isElement(c)||c&&c.nodeType===window.Node.DOCUMENT_FRAGMENT_NODE?void b.appendChild(c):void b.appendChild(window.document.createTextNode(c))};d(c)}}});var _extends=Object.assign||function(a){for(var b=1;b2?g-2:0),i=2;i0&&(f=_extends({children:1===h.length?h[0]:h},f));var j=e(f);if(b.isArray(j)){var k=d.createDocumentFragment();return c.append(k,j),k}return j}if("string"!=typeof e)throw new Error("Unknown type");var l=d.createElement(e),m=!1;return f&&Object.keys(f).forEach(function(b){var c=f[b];if(/^(?:data-|aria-|role$)/.test(b))null!==c&&l.setAttribute(b,c);else if("dangerouslySetInnerHTML"===b)m=!0,l.innerHTML=c&&c.__html||"";else if("style"===b)Object.keys(c).forEach(function(a){l.style[a]=c[a]});else if(/^on[A-Z]/.test(b))c&&a(l).on(b.slice(2).toLowerCase(),c);else if("key"===b);else try{l[b]=c}catch(d){}}),m||c.append(l,h),l}}}),define("react-dom",["common/jsxUtils"],function(a){"use strict";return{render:function(b,c,d){return c.innerHTML="",a.append(c,b),d&&d(),null}}}),define("core/api",["jquery","underscore","backbone","core/config","core/utils"],function(a,b,c,d,e){"use strict";function f(a){return l.href=a,l.origin||l.protocol+"//"+l.hostname+(l.port?":"+l.port:"")}function g(a){return a.replace(/^(http:)?\/\//,"https://")}function h(c){c=b.defaults(c,m),c.traditional=!0,f(window.location.href)!==f(c.url)&&(c.xhrFields={withCredentials:!0}),c.omitDisqusApiKey||(c.data=c.data||{},window.FormData&&c.data instanceof window.FormData?c.url=e.serialize(c.url,{api_key:d.keys.api}):c.data.api_key=d.keys.api);var g=c.error;return c.error=function(a){n.trigger("error",a),b.isFunction(g)&&g(a)},a.ajax(c)}function i(a,c){return c=c||{},c.url=j(a),c.omitDisqusApiKey||(c.data=b.extend(c.data||{},{api_key:d.keys.api})),n.trigger("call",c),h(c).always(b.bind(this.trigger,this,"complete",c))}function j(a){return/(https?:)?\/\//.test(a)?g(a):d.urls.api+a}var k=window.document,l=k.createElement("a"),m={},n={ERROR_CODES:{OBJ_NOT_FOUND:8,MAX_ITEMS_REACHED:24},ajax:h,call:i,getURL:j,defaults:function(a){Object.keys(a).forEach(function(c){var d=a[c],e=m[c];b.isObject(d)&&b.isObject(e)?b.extend(e,d):m[c]=d})},headers:function(a){var c=b.extend({},m.headers,a);return m.headers=b.pick(c,Boolean),m.headers},makeHttps:g};return b.extend(n,c.Events),n}),define("core/mediaConfig",["underscore","backbone"],function(a,b){"use strict";function c(){var b=window.document.body.offsetWidth,c=d,e=c.length;return a.find(c,function(a,d){return d+1===e||Math.abs(c[d+1]-b)>Math.abs(c[d]-b)})}var d=[320,480,600,800],e=new b.Model({collapsed:!1,defaultIframeHeight:300,mediaPersistedWidths:d,loadedThumbnailWidth:c()});return e.findClosestThumbnailSize=c,e}),define("core/templates/handlebars.partials",["handlebars"],function(a){a.registerPartial("cardGuestUser",a.template({1:function(a,b,c,d,e){var f,g=null!=b?b:{},h=a.lambda,i=a.escapeExpression;return'
  • \n\n'+i(c.gettext.call(g,\n\n\n'+i(h(null!=b?b.guestText:b,b))+"\n\n
  • \n"},2:function(a,b,c,d,e){return"highlight"},compiler:[7,">= 4.0.0"],main:function(a,b,c,d,e){var f;return null!=(f=c["if"].call(null!=b?b:{},null!=b?b.guestCount:b,{name:"if",hash:{},fn:a.program(1,e,0),inverse:a.noop,data:e}))?f:""},useData:!0})),a.registerPartial("cardGuestVoterText",a.template({1:function(a,b,c,d,e){return" "+a.escapeExpression(c.gettext.call(null!=b?b:{},"%(guestCount)s Guest Votes",{name:"gettext",hash:{guestCount:null!=b?b.guestCount:b},data:e}))+" "},3:function(a,b,c,d,e){return" "+a.escapeExpression(c.gettext.call(null!=b?b:{},"1 Guest Vote",{name:"gettext",hash:{},data:e}))+" "},compiler:[7,">= 4.0.0"],main:function(a,b,c,d,e){var f,g=null!=b?b:{};return(null!=(f=c["if"].call(g,c.gt.call(g,null!=b?b.guestCount:b,1,{name:"gt",hash:{},data:e}),{name:"if",hash:{},fn:a.program(1,e,0),inverse:a.program(3,e,0),data:e}))?f:"")+"\n"},useData:!0})),a.registerPartial("cardOtherUserText",a.template({1:function(a,b,c,d,e){return" "+a.escapeExpression(c.gettext.call(null!=b?b:{},"%(guestCount)s Others",{name:"gettext",hash:{guestCount:null!=b?b.guestCount:b},data:e}))+" "},3:function(a,b,c,d,e){return" "+a.escapeExpression(c.gettext.call(null!=b?b:{},"1 Other",{name:"gettext",hash:{},data:e}))+" "},compiler:[7,">= 4.0.0"],main:function(a,b,c,d,e){var f,g=null!=b?b:{};return(null!=(f=c["if"].call(g,c.gt.call(g,null!=b?b.guestCount:b,1,{name:"gt",hash:{},data:e}),{name:"if",hash:{},fn:a.program(1,e,0),inverse:a.program(3,e,0),data:e}))?f:"")+"\n"},useData:!0})),a.registerPartial("cardUser",a.template({1:function(a,b,c,d,e){return"highlight"},3:function(a,b,c,d,e){return'data-action="profile"'},5:function(a,b,c,d,e){var f,g=a.lambda,h=a.escapeExpression;return'\n'+h(c.gettext.call(null!=b?b:{},\n\n\n'+h(g(null!=b?b.name:b,b))+"\n\n"},7:function(a,b,c,d,e){var f,g=a.lambda,h=a.escapeExpression;return'\n'+h(c.gettext.call(null!=b?b:{},\n\n\n'+h(g(null!=b?b.name:b,b))+"\n\n"; },compiler:[7,">= 4.0.0"],main:function(a,b,c,d,e){var f,g=null!=b?b:{};return'
  • \n'+(null!=(f=c.if_all.call(g,c["switch"].call(g,"sso_less_branding",{name:"switch",hash:{forum:null!=b?b.forumId:b},data:e}),c.ne.call(g,null!=b?b.isSSOProfileUrl:b,!0,{name:"ne",hash:{},data:e}),{name:"if_all",hash:{},fn:a.program(5,e,0),inverse:a.program(7,e,0),data:e}))?f:"")+"
  • \n"},useData:!0})),a.registerPartial("carouselArrowLeft",a.template({compiler:[7,">= 4.0.0"],main:function(a,b,c,d,e){return'\n'},useData:!0})),a.registerPartial("carouselArrowRight",a.template({compiler:[7,">= 4.0.0"],main:function(a,b,c,d,e){return'\n'},useData:!0})),a.registerPartial("channelsHeader",a.template({compiler:[7,">= 4.0.0"],main:function(a,b,c,d,e){var f=null!=b?b:{},g=a.escapeExpression;return'
    \n
    \n\n
    \n
    \n

    '+g(c.gettext.call(f,"Channels",{name:"gettext",hash:{},data:e}))+'

    \n
    \n
    \n

    '+g(c.gettext.call(f,"Places to start your own discussions.",{name:"gettext",hash:{},data:e}))+"

    \n"},useData:!0})),a.registerPartial("genericFollowButton",a.template({1:function(a,b,c,d,e){return" active"},compiler:[7,">= 4.0.0"],main:function(a,b,c,d,e){var f,g=null!=b?b:{},h=a.escapeExpression;return'\n"},useData:!0}))}),define("core/extensions/helpers/eq",[],function(){"use strict";return function(a,b){return a===b}}),define("core/extensions/helpers/ne",[],function(){"use strict";return function(a,b){return a!==b}}),define("core/extensions/helpers/gt",[],function(){"use strict";return function(a,b){return a>b}}),define("core/extensions/helpers/lt",[],function(){"use strict";return function(a,b){return a=b}}),define("core/extensions/helpers/le",[],function(){"use strict";return function(a,b){return a<=b}}),define("core/extensions/helpers/typeof",[],function(){"use strict";return function(a,b){return typeof a===b}}),define("core/extensions/helpers/notNull",[],function(){"use strict";return function(a){return null!==a}}),define("core/extensions/helpers/any",[],function(){"use strict";return function(){for(var a=arguments.length,b=0;b"+a.escapeExpression(e)+""),new a.SafeString(d.join(""))}}),define("core/extensions/helpers/now",["moment"],function(a){"use strict";return function(b){return a().format(b)}}),define("core/extensions/handlebars.helpers",["require","handlebars","./helpers/eq","./helpers/ne","./helpers/gt","./helpers/lt","./helpers/ge","./helpers/le","./helpers/typeof","./helpers/notNull","./helpers/any","./helpers/if_any","./helpers/if_all","./helpers/switch","./helpers/partial","./helpers/getPartial","./helpers/gettext","./helpers/urlfor","./helpers/html","./helpers/with","./helpers/each","./helpers/log","./helpers/debug","./helpers/geturl","./helpers/tag","./helpers/now"],function(a){"use strict";var b=a("handlebars");return b.registerHelper("eq",a("./helpers/eq")),b.registerHelper("ne",a("./helpers/ne")),b.registerHelper("gt",a("./helpers/gt")),b.registerHelper("lt",a("./helpers/lt")),b.registerHelper("ge",a("./helpers/ge")),b.registerHelper("le",a("./helpers/le")),b.registerHelper("typeof",a("./helpers/typeof")),b.registerHelper("notNull",a("./helpers/notNull")),b.registerHelper("any",a("./helpers/any")),b.registerHelper("if_any",a("./helpers/if_any")),b.registerHelper("if_all",a("./helpers/if_all")),b.registerHelper("switch",a("./helpers/switch")),b.registerHelper("partial",a("./helpers/partial")),b.registerHelper("getPartial",a("./helpers/getPartial")),b.registerHelper("gettext",a("./helpers/gettext")),b.registerHelper("urlfor",a("./helpers/urlfor")),b.registerHelper("html",a("./helpers/html")),b.registerHelper("with",a("./helpers/with")),b.registerHelper("each",a("./helpers/each")),b.registerHelper("log",a("./helpers/log")),b.registerHelper("debug",a("./helpers/debug")),b.registerHelper("geturl",a("./helpers/geturl")),b.registerHelper("tag",a("./helpers/tag")),b.registerHelper("now",a("./helpers/now")),b}),define("core/templates/alert",["handlebars","core/templates/handlebars.partials","core/extensions/handlebars.helpers"],function(a){return a.template({1:function(a,b,c,d,e){return'\n'},3:function(a,b,c,d,e){var f;return(null!=(f=a.lambda(null!=b?b.message:b,b))?f:"")+"\n"},5:function(a,b,c,d,e){return a.escapeExpression(a.lambda(null!=b?b.message:b,b))+"\n"},compiler:[7,">= 4.0.0"],main:function(a,b,c,d,e){var f,g=null!=b?b:{};return'×\n\n'+(null!=(f=c["if"].call(g,null!=b?b.icon:b,{name:"if",hash:{},fn:a.program(1,e,0),inverse:a.noop,data:e}))?f:"")+(null!=(f=c["if"].call(g,null!=b?b.safe:b,{name:"if",hash:{},fn:a.program(3,e,0),inverse:a.program(5,e,0),data:e}))?f:"")+"\n"},useData:!0})}),define("core/views/AlertView",["backbone","core/templates/alert"],function(a,b){"use strict";var c=a.View.extend({defaultClassName:"alert",events:{"click [data-action=dismiss]":"dismiss"},initialize:function(a){this.options=a,this.message=a.message,this.safe=a.safe,this.type=a.type,this.className=a.className||this.defaultClassName},render:function(){var a=this.$el;return a.html(b({message:this.message,safe:this.safe,icon:Boolean(this.type),iconType:"error"===this.type||"warn"===this.type?"warning":this.type})),a.attr("class",this.className),this.type&&a.addClass(this.type),this},dismiss:function(a){a&&a.preventDefault&&a.preventDefault(),this.remove(),this.trigger("dismiss")}});return c}),define("core/mixins/withAlert",["underscore","core/views/AlertView"],function(a,b){"use strict";var c={alert:function(c,d){a.isObject(d)||(d={});var e=d.target||this._alertSelector;this.dismissAlert();var f=this._alert=new b(a.extend({message:c},d));if(this.listenToOnce(this._alert,"dismiss",function(){this._alert=null}),f.render(),e){var g=this.$el.find(e);g.length?g.prepend(f.el):this.listenToOnce(this,"threadView:render",function(){return this.alert(c,d)})}else this.el.parentNode&&this.el.parentNode.insertBefore(f.el,this.el);return f},dismissAlert:function(a){this._alert&&(a&&!a(this._alert)||(this.stopListening(this._alert),this._alert.dismiss(),this._alert=null))},getAlert:function(){return this._alert||null},setAlertSelector:function(a){this._alertSelector=a}},d=function(){return a.extend(this,c)};return d}),define("core/models/ThreadVote",["backbone"],function(a){"use strict";var b=a.Model.extend({defaults:{score:0}});return b}),define("core/models/Vote",["backbone"],function(a){"use strict";var b=a.Model.extend({defaults:{score:0}});return b}),define("core/constants/ratingsConstants",["exports"],function(a){"use strict";a.DEFAULT_RATINGS={average:0,breakdown:{1:0,2:0,3:0,4:0,5:0},count:0}}),define("core/time",[],function(){"use strict";function a(a){return a.indexOf("+")>=0?a:a+"+00:00"}var b="YYYY-MM-DDTHH:mm:ssZ";return{ISO_8601:b,assureTzOffset:a}}),define("core/models/BaseUser",["backbone","core/config"],function(a,b){"use strict";var c=a.Model.extend({defaults:{about:null,avatar:{cache:b.urls.avatar.generic,permalink:b.urls.avatar.generic},connections:{},email:null,isAnonymous:!0,isFollowedBy:null,isFollowing:null,joinedAt:null,name:null,profileUrl:null,url:null,username:null,numPosts:null,numFollowing:null,numForumsFollowing:null,numFollowers:null,numLikesReceived:null,isFlagged:null},hasValidAvatar:function(a){var b=a?a.avatar:this.get("avatar");return b&&b.cache},isAnonymous:function(){return!this.get("id")},isRegistered:function(){return!this.isAnonymous()},validate:function(a){if(!this.hasValidAvatar(a))return"None of the avatar related properties can be null, undefined or empty on User models."},toJSON:function(){var b=a.Model.prototype.toJSON.apply(this,arguments);return b.thread={},this.hasValidAvatar()||(b.avatar=this.defaults.avatar),b.isRegistered=this.isRegistered(),b}});return c}),define("core/models/User",["jquery","underscore","moment","core/config","core/time","core/utils","core/strings","core/api","core/models/BaseUser"],function(a,b,c,d,e,f,g,h,i){"use strict";function j(a,b,c){a[b]=a[b]||[],a[b].push(c)}var k=g.get,l=i.extend({url:h.getURL("users/details"),validate:function(c){var d={};if(c.display_name&&(c.display_name=a.trim(c.display_name)),c.display_name||j(d,"display_name",k("Please enter your name.")),c.email||j(d,"email",k("Please enter your email address.")),f.validateEmail(c.email)||j(d,"email",k("Invalid email address.")),this.isNew()&&(c.password?c.password.lengthl.MAX_NAME_LEN&&j(d,"name",g.interpolate(k("Name must have less than %(maxLength)s characters."),{maxLength:l.MAX_NAME_LEN}))),c.location&&c.location.length>l.MAX_LOCATION_LEN&&j(d,"location",g.interpolate(k("Location must have less than %(maxLength)s characters."),{maxLength:l.MAX_LOCATION_LEN})),c.url&&(c.url.length>l.MAX_URL_LEN&&j(d,"url",g.interpolate(k("Site must have less than %(maxLength)s characters."),{maxLength:l.MAX_URL_LEN})),f.isUrl(c.url)||j(d,"url",k("Please enter a valid site."))),!b.isEmpty(d))return d},prepareFetchOptions:function(a){a=a?b.clone(a):{};var c={};return this.get("id")?c.user=this.get("id"):this.get("username")&&(c.user="username:"+this.get("username")),b.extend(c,a.data),a.data=c,a},fetch:function(a){return a=this.prepareFetchOptions(a),i.prototype.fetch.call(this,a)},parse:function(a){return a.response||a},register:function(a){var c=this;return a=a||{},h.call("internal/users/register.json",{data:b.extend(this.toRegisterJSON(),{gRecaptchaResponse:a.gRecaptchaResponse}),method:"POST",success:function(d){h.call("users/acceptTerms",{method:"POST"}),c.set(b.extend({},d.response,{hasAcceptedGdprTerms:!0})),a.success&&a.success(d)},error:a.error})},saveAvatar:function(a){var b=new window.FormData;return b.append("avatar_file",a),b.append("api_key",d.keys.api),h.call("internal/users/updateAvatar.json",{method:"post",data:b,cache:!1,contentType:!1,processData:!1})},saveProfile:function(){return h.call("users/updateProfile.json",{method:"POST",data:{name:this.get("name"),about:this.get("about"),location:this.get("location"),url:this.get("url")}})},toRegisterJSON:function(){return b.pick(this.toJSON(),"display_name","email","password")},isSession:function(a){return a.user.id&&a.user.id===this.id},isEditable:function(a){return this.isSession(a)&&!this.get("remote")},toJSON:function(a){a=a||{};var b=i.prototype.toJSON.call(this),c=this.collection&&this.collection.thread;return b.thread.canModerate=Boolean(c&&c.isModerator(this)),a.session&&(b.isSession=this.isSession(a.session),b.isEditable=this.isEditable(a.session)),b},_changeFollowState:function(a){this.set({isFollowing:a,numFollowers:Math.max(0,this.get("numFollowers")+(a?1:-1))});var b="users/"+(a?"follow":"unfollow"),c=this;return h.call(b+".json",{data:{target:this.get("id")},method:"POST",success:function(a){c.trigger("sync",c,a,{})}})},follow:function(){return this._changeFollowState(!0)},unfollow:function(){return this._changeFollowState(!1)},_changeBlockState:function(a){var b="users/block/"+(a?"create":"delete"),c=this;return h.call(b+".json",{data:{user:this.get("id")},method:"POST",success:function(a){c.set(a.response)}})},block:function(){return this._changeBlockState(!0)},unblock:function(){return this._changeBlockState(!1)},report:function(a){var b=this;return h.call("users/report.json",{data:{reason:a,user:this.get("id")},method:"POST",success:function(){b.set("isFlagged",!0)}})},toggleFollowState:function(){return this._changeFollowState(!this.get("isFollowing"))},registeredLessThan:function(a,b){var d=e.assureTzOffset(this.get("joinedAt")),f=c().subtract(a,b);return c(d).isAfter(f)},registeredToday:function(){return this.registeredLessThan(1,"day")},registeredThisWeek:function(){return this.registeredLessThan(1,"week")},shouldHomeOnboard:function(){return!this.get("homeOnboardingComplete")},setHomeOnboardComplete:function(a){this.updateFlags({homeOnboardingComplete:a}),a&&this.listenTo(this,"change:homeOnboardingComplete",b.bind(this.set,this,"homeOnboardingComplete",a,{silent:!0}))},updateFlags:function(a){return this.set(a),h.call("internal/users/updateFlags.json",{data:b.mapObject(a,function(a){return a?1:0}),method:"POST"})}},{MIN_PASSWORD_LEN:6,MIN_NAME_LEN:2,MAX_NAME_LEN:30,MAX_LOCATION_LEN:255,MAX_URL_LEN:200});return l}),define("core/utils/html",[],function(){"use strict";var a="...",b=a.length,c=function(a){var b;try{b=(new window.DOMParser).parseFromString(" ","text/html")}catch(c){}return b||(b=window.document.implementation.createHTMLDocument("")),b.body.innerHTML=a,b};return{stripTags:function(a){var b=c(a).body;return(b.textContent||b.innerText).replace(/\r?\n/g," ")},replaceAnchors:function(a,d){var e=c(a);return[].forEach.call(e.querySelectorAll("a"),function(a){var c=a.getAttribute("href")||"",e=a.innerHTML,f=d(a);0===c.indexOf(e.slice(0,-b))?e=f:c.length&&e.indexOf(c)!==-1?e=e.replace(c,f):e+=" "+f,a.insertAdjacentHTML("afterend",e),a.parentNode.removeChild(a)}),e.body.innerHTML.trim()}}}),define("core/advice",["underscore"],function(a){"use strict";function b(){a.each(["before","after","around"],function(a){this[a]=function(b,d){return"function"==typeof this[b]?this[b]=c[a](this[b],d):this[b]=d,this[b]}},this)}var c={around:function(b,c){return function(){var d=a.toArray(arguments);return c.apply(this,[a.bind(b,this)].concat(d))}},before:function(b,d){return c.around(b,function(){var b=a.toArray(arguments),c=b.shift();return d.apply(this,b),c.apply(this,b)})},after:function(b,d){return c.around(b,function(){var b=a.toArray(arguments),c=b.shift(),e=c.apply(this,b);return d.apply(this,b),e})}};return{withAdvice:b}}),define("core/models/mixins",["underscore","moment","core/time"],function(a,b,c){"use strict";function d(){b.locale("en",{relativeTime:{future:"%s from now",past:"%s ago",s:"a few seconds",ss:"%d seconds",m:"a minute",mm:"%d minutes",h:"an hour",hh:"%d hours",d:"a day",dd:"%d days",M:"a month",MM:"%d months",y:"a year",yy:"%d years"}}),this._getCreatedMoment=a.memoize(function(a){var d=this.get(a||"createdAt");if(d)return b(c.assureTzOffset(d),c.ISO_8601)},function(a){return this.get(a||"createdAt")}),this.getRelativeCreatedAt=function(a){var b=this._getCreatedMoment(a);return b&&b.from(Number(new Date))},this.getFormattedCreatedAt=a.memoize(function(a){var b=this._getCreatedMoment(a);return b&&b.format("LLLL")},function(a){return this.get(a||"createdAt")})}return{withCreatedAt:d}}),define("core/collections/UserCollection",["jquery","backbone","core/models/User"],function(a,b,c){"use strict";var d=b.Collection.extend({model:c,initialize:function(a,c){b.Collection.prototype.initialize.apply(this,arguments),this.thread=c&&c.thread},fetch:function(){return a.when(!0)}});return d}),define("core/collections/VotersUserCollection",["underscore","backbone","core/api","core/collections/UserCollection"],function(a,b,c,d){"use strict";var e=d.extend({LIMIT:50,url:function(){return c.getURL("posts/listUsersVotedPost")},initialize:function(a,b){this.postId=b.postId,this.threadId=b.threadId},fetch:function(c){return b.Collection.prototype.fetch.call(this,a.extend({data:{post:this.postId,thread:this.threadId,vote:c.vote,limit:this.LIMIT}},c))}});return e}),define("core/collections/VoteCollection",["backbone","core/models/Vote"],function(a,b){"use strict";var c=a.Collection.extend({model:b});return c}),define("core/models/Post",["jquery","underscore","backbone","moment","core/config/urls","core/api","core/strings","core/time","core/utils","core/utils/html","core/advice","remote/config","core/models/mixins","core/collections/VotersUserCollection","core/collections/VoteCollection"],function(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o){"use strict";var p=1e3,q=0,r=function(){var b=a.now();return!(b-q0?(e.likes+=a,e.dislikes+=b):a<0?(e.dislikes-=a,e.likes-=b):b>0?e.likes-=b:e.dislikes+=b,e.points+=d,c&&(1===a?(this.getUpvotersUserCollection().add(c),this.getDownvotersUserCollection().remove(c)):(this.getDownvotersUserCollection().add(c),this.getUpvotersUserCollection().remove(c))),this.set(e),d)},vote:function(a){if(!r())return 0;var b=this,c=b._vote(a,b.get("userScore"));0!==c&&(b.set("userScore",a),f.call("posts/vote.json",{data:{post:b.id,vote:a},method:"POST",success:function(c){b.votes.add({id:c.response.id,score:a},{merge:!0})}}))},_delete:function(){return this.set({isApproved:!1,isDeleted:!0}),f.call("posts/remove.json",{data:{post:this.id},method:"POST"})},spam:function(){this.set({isApproved:!1,isDeleted:!0,isSpam:!0}),this.trigger("spam"),f.call("posts/spam.json",{data:{post:this.id},method:"POST"})},_create:function(a,b){var c=this,d=a.attributes,e={thread:d.thread,message:d.raw_message,rating:d.rating};return d.parent&&(e.parent=d.parent),d.author_name&&(e.author_name=d.author_name,e.author_email=d.author_email),f.call("posts/create.json",{data:e,method:"POST",success:function(a){c.set(a.response),b.success&&b.success()},error:b.error})},_update:function(a,b){var c=this,d=a.attributes,e={post:d.id,message:d.raw_message,rating:d.rating};return f.call("posts/update.json",{data:e,method:"POST",success:function(a){c.set(a.response),b.success&&b.success()},error:b.error})},_read:function(a,b){var c=this;return b=b||{},f.call("posts/details.json",{data:{post:c.id},method:"GET",success:function(a){c.set(a.response),b.success&&b.success()},error:b.error})},sync:function(a,b,c){c=c||{};var d=c.error;switch(d&&(c.error=function(a){var b={};try{b=JSON.parse(a.responseText)}catch(c){}d(b)}),a){case"create":return this._create(b,c);case"update":return this._update(b,c);case"delete":return this._delete();case"read":return this._read(b,c)}},storageKey:function(){if(this.isNew()&&this.getThreadId())return["drafts","thread",this.getThreadId(),"parent",this.get("parent")||0].join(":")}},{formatMessage:function(){var a=/(?:\r\n|\r|\n){2,}/,c=/\r\n|\r|\n/;return function(d){var e=b.chain(d.split(a)).compact().value(),f=b.map(e,function(a){return b.chain(a.split(c)).compact().map(b.escape).join("
    ").value()}).join("

    ");return"

    "+f+"

    "}}()});return m.withCreatedAt.call(t.prototype),k.withAdvice.call(t.prototype),t.withAuthor=function(a){this.around("set",function(c,d,e,f){var g;if(null==d)return this;"object"==typeof d?(g=d,f=e):(g={},g[d]=e);var h=g.author;if(h){if(b.isString(h)||b.isNumber(h)){var i=h;h={},h[a.prototype.idAttribute||"id"]=i}this.author=new a(h),this.trigger("changeRelated:author"),delete g.author}return c.call(this,g,f)}),this.around("toJSON",function(a){var c=a.apply(this,b.rest(arguments));return this.author&&(c.author=this.author.toJSON()),c})},t.withMediaCollection=function(a){this.after("set",function(c){c&&"string"!=typeof c&&(b.isUndefined(c.media)||(this.media?this.media.reset(c.media):this.media=new a(c.media),delete c.media))}),this.around("toJSON",function(a){var c=a.apply(this,b.rest(arguments));return this.media&&(c.media=this.media.toJSON()),c})},t}),define("core/utils/threadRatingsHelpers",["core/utils/object/get"],function(a){"use strict";var b={};return b.isThreadRatingsEnabled=function(b,c){return!!(b&&b.forum&&c&&c.id===b.forum)&&Boolean(a(b,["ratingsEnabled"])&&a(c,["settings","threadRatingsEnabled"])&&a(c,["features","threadRatings"]))},b.isThreadModelRatingsEnabled=function(a){if(!a||!a.forum)return!1;var b=a.forum.get("settings"),c=a.forum.get("features");return Boolean(a.get("ratingsEnabled")&&b&&b.threadRatingsEnabled&&c&&c.threadRatings)},b.isForumRatingsEnabled=function(b){return!!b&&Boolean(a(b,["settings","threadRatingsEnabled"])&&a(b,["features","threadRatings"]))},b.isForumModelRatingsEnabled=function(a){if(!a)return!1;var b=a.get("settings"),c=a.get("features");return Boolean(b&&b.threadRatingsEnabled&&c&&c.threadRatings)},b}),define("core/models/Thread",["underscore","backbone","loglevel","core/config/urls","core/utils","core/api","core/config","core/advice","core/UniqueModel","core/utils/threadRatingsHelpers","core/models/User"],function(a,b,c,d,e,f,g,h,i,j,k){"use strict";var l=b.Model,m=l.prototype,n=l.extend({defaults:{author:null,category:null,createdAt:null,forum:null,identifiers:[],ipAddress:null,isClosed:!1,isDeleted:!1,hasStreaming:!1,link:null,message:null,slug:null,title:null,userSubscription:!1,posts:0,likes:0,dislikes:0,userScore:0},initialize:function(a,b){b=b||{},this.moderators=b.moderators,this.forum=b.forum,this.on("change:userScore",function(){var a=this.get("userScore");a>0&&0===this.get("likes")&&this.set("likes",a)},this)},_vote:function(a,b){var c=a-b;return 0===c?c:(this.set("likes",this.get("likes")+c),c)},vote:function(a){var b=this,c=b._vote(a,b.get("userScore"));0!==c&&(this.set("userScore",a),f.call("threads/vote.json",{data:{thread:this.id,vote:a},method:"POST",success:function(a){a.response.id&&b.trigger("vote:success",a)}}))},fetch:function(a){var b,d=this,e=d.attributes;a=a||{},b=e.identifier?"ident:"+e.identifier:"link:"+e.url,f.call("threads/details.json",{data:{thread:b,forum:e.forum},success:function(b){d.set(b.response),a.success&&a.success()},error:function(){g.debug?d.save({},{success:a.success}):c.info("Couldn't find thread; not creating in production.")}})},_toggleState:function(a,b){b||(b={});var c=a?"open.json":"close.json";return this.set("isClosed",!a),f.call("threads/"+c,{method:"POST",data:{thread:this.id},success:b.success,error:b.error})},open:function(a){return this._toggleState(!0,a)},close:function(a){return this._toggleState(!1,a)},premoderate:function(b,c){return this.set("validateAllPosts",b),f.call("threads/update",a.extend({},c,{method:"POST",data:a.extend({thread:this.id,validateAllPosts:b?1:0},c&&c.data)}))},sync:function(){var a=this,b=a.attributes;f.call("threads/create.json",{data:{title:b.title,forum:b.forum,identifier:b.identifier,url:b.url},method:"POST",success:function(b){a.set(b.response)}})},fetchRatings:function(){var a=this,b={thread:a.id};return f.call("threads/ratingsSummary.json",{data:b,method:"GET",success:function(b){a.set("ratings",b.response)}})},toggleRatingsEnabled:function(){var a=this;if(j.isForumModelRatingsEnabled(a.forum)){var b=a.get("ratingsEnabled"),c={thread:a.id,ratingsEnabled:b?0:1};return a.set("ratingsEnabled",!b),f.call("threads/update.json",{data:c,method:"POST"})}},incrementPostCount:function(a){var b=this.get("posts")+a;this.set("posts",b>0?b:0)},isModerator:function(b){var c;if(this.moderators)return c=b instanceof k||a.isObject(b)?b.id:b,c=parseInt(c,10),a(this.moderators).contains(c)},subscribe:function(a){a=a!==!1;var b=this.get("userSubscription");if(b!==a){this.set("userSubscription",a);var c=a?"subscribe.json":"unsubscribe.json",d={thread:this.id};return f.call("threads/"+c,{data:d,method:"POST"})}},twitterText:function(a){var b=140-(a.length+1),c=this.get("clean_title");return c=e.niceTruncate(c,b)},permalink:function(){return this.get("url")||this.get("link")||this.currentUrl; },shortLink:function(){return d.shortener+"/t/"+Number(this.id).toString(36)},toJSON:function(){var a=m.toJSON.call(this);return a.permalink=this.permalink(),a.shortLink=this.shortLink(),a},getDiscussionRoute:function(a){var b=["","home","discussion",this.forum.id,this.get("slug"),""];return a=a||this.forum.channel,a&&(a=a.attributes||a,b.splice(2,0,"channel",a.slug)),b.join("/")}});return h.withAdvice.call(n.prototype),n.withThreadVoteCollection=function(a){this.after("initialize",function(){this.votes=new a,this.on("vote:success",function(a){this.votes.get(a.response.id)||this.votes.add({id:a.response.id,score:a.response.vote,currentUser:!0})},this)})},n.withPostCollection=function(b){this.after("initialize",function(c){c=c||{},this.posts=new b(c.posts,{thread:this,cursor:c.postCursor,order:c.order,perPage:this.postsPerPage}),this.listenTo(this.posts,"add reset",function(b){b=b.models?b.models:[b],this.users&&a.each(b,function(a){this.users.get(a.author.id)||this.users.add(a.author)}),this.recalculatePostCount()}),this.listenTo(this.posts,"change:isDeleted change:isFlagged",function(a,b){b&&this.incrementPostCount(-1)})}),this.recalculatePostCount=function(){var a=this.get("posts");a>50||(a=this.posts.reduce(function(a,b){return b.isPublic()?a+1:a},0),this.set("posts",a))}},i.addType("Thread",n),n}),define("core/models/Forum",["backbone","core/UniqueModel","core/api"],function(a,b,c){"use strict";var d=a.Model.extend({defaults:{settings:{},followUrl:"forums/follow",unfollowUrl:"forums/unfollow",isFollowing:!1},initialize:function(a,b){b&&b.channel&&(this.channel=b.channel),this.getFeatures(),this.on("change:id",this.getFeatures)},_changeFollowingState:function(a){return c.call(a,{method:"POST",data:{target:this.get("id")}})},follow:function(){return this.set("isFollowing",!0),this._changeFollowingState(this.get("followUrl"))},unfollow:function(){return this.set("isFollowing",!1),this._changeFollowingState(this.get("unfollowUrl"))},toggleFollowed:function(){if(this.channel&&this.channel.get("options").isCurationOnlyChannel)return this.channel.toggleFollowed();var a=this.get("isFollowing")?this.unfollow():this.follow();return this.trigger("toggled:isFollowing"),a},getFeatures:function(){var a=this;a.id&&!a.get("features")&&c.call("forums/details",{data:{forum:this.id,attach:"forumFeatures"},success:function(b){b&&b.response&&a.set("features",b.response.features)}})}});return b.addType("Forum",d),d}),define("core/models/Media",["underscore","backbone","core/api","core/UniqueModel"],function(a,b,c,d){"use strict";var e=b.Model.extend({idAttribute:"url",defaults:{mediaType:null,html:"",htmlWidth:null,htmlHeight:null,thumbnailUrl:"",thumbnailWidth:null,thumbnailHeight:null,url:"",urlRedirect:"",resolvedUrl:"",resolvedUrlRedirect:"",title:"",description:"",providerName:""},parse:function(a){return a.response},sync:function(b,d,e){if("read"!==b)throw new Error('Media models do not support methods other than "read".');return c.call("media/details.json",a.extend({method:"POST",data:{url:this.get("url"),forum:e.forum}},e))}},{MEDIA_TYPES:{IMAGE:"1",IMAGE_UPLOAD:"2",YOUTUBE_VIDEO:"3",WEBPAGE:"4",TWITTER_STATUS:"5",FACEBOOK_PAGE:"6",FACEBOOK_POST:"7",FACEBOOK_PHOTO:"8",FACEBOOK_VIDEO:"9",SOUNDCLOUD_SOUND:"10",GOOGLE_MAP:"11",VIMEO_VIDEO:"12",VINE_VIDEO:"14",GIF_VIDEO:"15"},WEBPAGE_TYPES:["4","6","7"]});return d.addType("Media",e),e}),define("core/collections/MediaCollection",["backbone","core/models/Media"],function(a,b){"use strict";var c=a.Collection.extend({model:b});return c}),define("common/models",["require","jquery","underscore","backbone","modernizr","core/api","core/UniqueModel","core/models/User","core/models/Post","core/models/Thread","core/models/Forum","core/collections/MediaCollection","core/utils/object/get","core/utils/url/serialize","core/utils/guid","common/utils","core/utils","common/urls","shared/urls","backbone.uniquemodel"],function(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s){"use strict";var t=k.extend({defaults:{settings:{}},toJSON:function(){return c.extend(d.Model.prototype.toJSON.apply(this,arguments),{homeUrl:s.apps.home+"home/forums/"+this.id+"/"})}}),u=j.extend({initialize:function(b,d){j.prototype.initialize.apply(this,arguments),d=d||{};var e=this,f=a("common/collections");e.users=new f.UserCollection(d.users,{thread:e}),e.forum&&(e.moderatorList=new f.ModeratorCollection(null,{forum:e.forum.get("id")})),e.posts=new f.SubpaginatedPostCollection(d.posts,{thread:e,cursor:d.postCursor,order:d.order,perPage:q.isMobileUserAgent()?20:50}),e.votes=new f.ThreadVoteCollection,e.posts.on("add reset",function(a){a=a.models?a.models:[a],c.each(a,function(a){e.users.get(a.author.id)||e.users.add(a.author)}),e.recalculatePostCount()}),e.listenTo(e.posts,"change:isDeleted change:isFlagged",function(a,b){b&&e.incrementPostCount(-1)}),e.queue=new f.QueuedPostCollection(null,{thread:e})},recalculatePostCount:function(){var a=this.get("posts");a>50||(a=this.posts.buffer.reduce(function(a,b){var c=b.isPublic()&&(!b.get("sb")||b.isAuthorSessionUser());return c?a+1:a},0),this.set("posts",a))},toJSON:function(){var a=this.get("forum"),b=c.isObject(a)?a.id:a;return c.extend(j.prototype.toJSON.apply(this,arguments),{homeUrl:s.apps.home+"home/discussions/"+b+"/"+this.get("slug")+"/"})}});j.withThreadVoteCollection.call(u.prototype,d.Collection);var v=i.extend({initialize:function(){i.prototype.initialize.apply(this,arguments);var b=a("common/collections");this.usersTyping=new b.TypingUserCollection},isAuthorSessionUser:function(b){var c=a("common/Session"),d=m(b,["user","id"])||c.fromCookie().id;return!!(d&&this.author&&this.author.id)&&this.author.id.toString()===d.toString()},canBeEdited:function(a,b){var c=this.get("editableUntil"),d=(new Date).toISOString();return!b.get("isClosed")&&!this.get("isDeleted")&&a.isLoggedIn()&&this.isAuthorSessionUser(a)&&this.get("raw_message")&&!this.get("isHighlighted")&&!this.get("isSponsored")&&dthis.constructor.MAX_NAME_LENGTH&&c.push({attrName:"name",message:f.interpolate(g("Name must have less than %(maxLength)s characters."),{maxLength:this.constructor.MAX_NAME_LENGTH})});var e=b.description.trim();if(e.lengththis.constructor.MAX_DESCRIPTION_LENGTH&&c.push({attrName:"description",message:f.interpolate(g("Description must have less than %(maxLength)s characters."),{maxLength:this.constructor.MAX_DESCRIPTION_LENGTH})}),this.constructor.BANNER_COLORS[b.bannerColor]||c.push({attrName:"bannerColor",message:f.interpolate(g("Banner color must be one of "+a.invoke(a.values(this.constructor.BANNER_COLORS),"toLowerCase").join(", "))+".")}),!a.isEmpty(c))return c},_changeFollowingState:function(b,c){return c=c||{},c.type="POST",c.data=a.extend({target:this.get("slug")},c.data),d.call(b,c)},follow:function(a){return this.primaryForum.set("isFollowing",!0),this._changeFollowingState(this.get("followUrl"),a)},unfollow:function(a){return this.primaryForum.set("isFollowing",!1),this._changeFollowingState(this.get("unfollowUrl"),a)},toggleFollowed:function(){if(this.get("options").isCurationOnlyChannel&&this.primaryForum){var a=this.primaryForum.get("isFollowing")?this.unfollow():this.follow();return this.primaryForum.trigger("toggled:isFollowing"),a}},toJSON:function(){var c=b.Model.prototype.toJSON.call(this);return a.defaults({primaryCategory:this.primaryCategory?this.primaryCategory.toJSON():{}},c)}},{URLS:{read:"channels/details",create:"channels/create",update:"channels/update"},BANNER_COLORS:{gray:g("Gray"),blue:g("Blue"),green:g("Green"),yellow:g("Yellow"),orange:g("Orange"),red:g("Red"),purple:g("Purple")},MIN_NAME_LENGTH:3,MAX_NAME_LENGTH:100,MIN_DESCRIPTION_LENGTH:5,MAX_DESCRIPTION_LENGTH:200});return c.addType("Channel",h),h}),define("core/utils/objectExpander",["underscore","core/UniqueModel","core/models/Channel","core/models/Thread"],function(a,b,c,d){"use strict";return{Channel:c,Thread:d,parseObject:function(b,c){return a.isString(c)?b[c]:c},buildThread:function(c,d){if(d instanceof this.Thread)return d;if(d=this.parseObject(c,d),a.isString(d.author)){var e=d.author.replace("auth.User?id=","");d.author=c["auth.User?id="+e]||e}return new b(this.Thread,d,{forum:this.parseObject(c,d.forum),author:d.author})},buildChannel:function(a,c){return c instanceof this.Channel?c:(c=this.parseObject(a,c),new b(this.Channel,c))}}}),define("core/collections/PaginatedCollection",["underscore","backbone"],function(a,b){"use strict";var c=b.Collection.extend({PER_PAGE:30,initialize:function(b,c){this.cid=a.uniqueId("collection"),c=c||{},this.cursor=c.cursor||{}},ensureFetched:a.memoize(function(){return this.fetch()},function(){return this.cid}),fetch:function(c){return c=c||{},c.data=a.defaults(c.data||{},{cursor:c.cursor||"",limit:c.limit||this.PER_PAGE}),b.Collection.prototype.fetch.call(this,c)},hasPrev:function(){return this.cursor.hasPrev},hasNext:function(){return this.cursor.hasNext},next:function(b){return this.cursor.hasNext?this.fetch(a.extend({},b,{add:!0,remove:!0,cursor:this.cursor.next})):void this.trigger("nodata")},prev:function(b){return this.cursor.hasPrev?this.fetch(a.extend({},b,{add:!0,remove:!0,cursor:this.cursor.prev})):void this.trigger("nodata")},more:function(b){function c(a){f.push(a)}var d=this;if(b=b||{},b.post?!b.post.attributes.hasMore:!this.cursor.hasNext)return void d.trigger("nodata");var e,f=[];if(b.post){var g=this.postCursors[b.post.id];e=g&&g.cursor?g.cursor.next:""}else e=this.cursor.next;return this.on("add",c),this.fetch(a.extend({},b,{add:!0,remove:!1,cursor:e,limit:this.PER_PAGE||this.perPage,success:function(){d.trigger("add:many",f,d,b),d.off("add",c),b.success&&b.success.apply(this,arguments)}}))},parse:function(c){return Array.isArray(c)&&a.every(c,function(a){return a instanceof b.Model})?c:(this.cursor=c.cursor||{hasNext:!1},c.response)},getLength:function(){return this.length}});return c}),define("core/collections/ChannelCollection",["underscore","core/collections/PaginatedCollection","core/UniqueModel","core/api","core/models/Channel","core/utils/objectExpander"],function(a,b,c,d,e,f){"use strict";var g=b.extend({url:d.getURL("channels/list"),model:c.boundModel(e),initialize:function(a,c){b.prototype.initialize.call(this,a,c),c=c||{},this.listName=c.listName},fetch:function(c){return c=c||{},this.listName&&(c.data=a.extend({listName:this.listName},c.data)),b.prototype.fetch.call(this,c)},parse:function(c){return Boolean(c)&&Boolean(c.response)&&a.isArray(c.response)&&(c=a.defaults({response:a.filter(c.response,function(a){return!a||!a.primaryForum||!a.primaryForum.id||"channel-discussdisqus"===a.primaryForum.id})},c)),c=b.prototype.parse.call(this,c),c.items?a.map(c.items,function(a){return f.buildChannel(c.objects,a.reference)}):c}});return g}),define("common/cached-storage",["underscore","core/utils/storage"],function(a,b){"use strict";var c=function(a,b){this.namespace=a,this.ttl=b||300,this.cache=this.getFromStorage()};return a.extend(c.prototype,{getItem:function(a){var b=this.cache[a];if(b){if(!this.isExpired(b))return b.value;delete this.cache[a]}},getCurrentTime:function(){return Math.floor((new Date).getTime()/1e3)},persist:function(){b.set(this.namespace,this.cache)},getFromStorage:function(){var c=b.get(this.namespace);return a.isObject(c)?c:{}},isExpired:function(a){return this.getCurrentTime()>a.expiry},setItem:function(a,b){this.cache[a]={value:b,expiry:this.getCurrentTime()+this.ttl},this.persist()},removeItem:function(a){delete this.cache[a],this.persist()},getAll:function(){var b=a.chain(this.cache).map(function(a,b){return this.getItem(b)},this).compact().value();return this.persist(),b}}),c}),define("common/collections",["underscore","backbone","moment","core/api","core/utils/objectExpander","core/utils/storage","core/collections/UserCollection","core/collections/PaginatedCollection","core/collections/ChannelCollection","core/models/ThreadVote","core/UniqueModel","common/models","common/cached-storage","lounge/common"],function(a,b,c,d,e,f,g,h,i,j,k,l,m,n){"use strict";var o=b.Collection.extend({model:j}),p=h.extend({PER_PAGE:50,model:k.wrap(l.Post),url:d.getURL("threads/listPostsThreaded"),initialize:function(a,b){h.prototype.initialize.apply(this,arguments),b=b||{},this.thread=b.thread,this.setOrder(b.order)},fetch:function(b){return b=b||{},a.extend(b,{data:{limit:this.PER_PAGE,thread:this.thread.id,forum:this.thread.get("forum"),order:this.getOrder()}}),h.prototype.fetch.call(this,b)},getOrder:function(){return this.order},setOrder:function(a){this.order=a}}),q=b.Collection.extend({collection:b.Collection,initialize:function(a,b){this.lounge=n.getLounge(),this.thread=b.thread,this.perPage=b.perPage||20,this.buffer=new this.collection(a,b),this.resetPage(),this.listenTo(this.buffer,"reset",this.resetPage)},resetPage:function(c,d){d=d||{};var e=a.isUndefined(d.customThreadLength)?this.perPage:Math.min(d.customThreadLength,this.perPage),f=this.buffer.slice(0,e);return this.postCursors={},this.fetchedReplies=0,this.trigger("set:done",f),b.Collection.prototype.reset.call(this,f,d)},currentPage:function(){var a=Math.floor((this.length-this.fetchedReplies)/this.perPage);return(this.length-this.fetchedReplies)%this.perPage&&(a+=1),a},setPageFor:function(a,b){var c=this.buffer.get(a),d=this.perPage;c&&(d=this.perPage*Math.floor(this.buffer.indexOf(c)/this.perPage+1)),this.add(this.buffer.slice(0,d),b)},hasNext:function(){return this.buffer.length>this.length||this.buffer.hasNext()},more:function(a){a=a||{};var b=this,c=b.length+b.perPage,d=a.success;a.success=function(){a.post||b.add(b.buffer.slice(0,c)),b.trigger("set:done",b.models),d&&d()};var e=a.post?b.get(a.post.id):null;e&&e.attributes.hasMore?b.collection.prototype.more.call(b,a):!e&&b.buffer.length-1))return this.buffer.parse(a,b);this.postCursors[b.data.post]||(this.postCursors[b.data.post]={}),this.postCursors[b.data.post].cursor=a.cursor,b.post.set("hasMore",a.cursor.hasNext),this.fetchedReplies+=a.response.length;var c=this.buffer.indexOf(b.post),d=this.getDescendantsFromBuffer(b.post);return d&&this.add(d,{at:c}),this.buffer.add(a.response,{at:c+d.length}),a.response},getDescendantsFromBuffer:function(b){var c={};c[b.id]=b;var d=this.buffer.slice(this.buffer.indexOf(b)+1);return a.some(d,function(a){var b=a.get("parent");return!b||!c[b]||(c[a.id]=a,!1)}),a.values(c)}}),s=b.Collection.extend({model:l.QueuedPost,initialize:function(a,b){var c=this;c.thread=b.thread,c.counters={comments:0,replies:{}},c.on("add",function(a){var b=a.getVisibleParent(c.thread),d=c.counters.replies;b?(d[b.id]=(d[b.id]||0)+1,b.id===a.get("parentId")&&a.set("immedReply",!0)):c.counters.comments+=1})},comparator:function(a){return parseInt(a.id,10)},isDescendant:function(b,c){var d=b.get("parentId"),e=d?this.get(d):null,f={};for(a.each(c,function(a){f[a]=!0});e;){if(f[e.get("id")]===!0)return!0;d=e.get("parentId"),e=d?this.get(d):null}return!1},drain:function B(b){function c(a){var b=[];e.each(function(a){null===a.get("parentId")&&b.push(a.get("id"))}),e.reset(e.filter(function(c){return null===c.get("parentId")||e.isDescendant(c,b)?void a(c):c})),e.counters.comments=0}function d(c){var d,f=[];d=e.filter(function(a){var c=a.getVisibleParent(e.thread);return c&&c.get("id")===b?void f.push(a):a}),f=a.sortBy(f,function(a){return parseInt(a.get("id"),10)}),a.each(f,function(a){c(a)}),e.reset(d),e.counters.replies[b]=0}var e=this,B=b?d:c;return B(function(a){e.thread.posts.add(a.toPost(e.thread))})}}),t=b.Collection.extend({models:l.TypingUser,initialize:function(){var b=this;b.gc=null,b.on("add remove reset",function(){var c=b.count();return c>0&&null===b.gc?void(b.gc=setInterval(a.bind(b.cleanup,b),6e4)):void(c<=0&&null!==b.gc&&(clearInterval(b.gc),b.gc=null))},b)},count:function(a){var b=this.filter(function(b){return!(a&&b.id===a)&&b.get("typing")});return b.length},cleanup:function(){var a=c();this.reset(this.filter(function(b){return a.diff(b.lastModified,"minutes")<5}))}}),u=h.extend({model:k.wrap(l.Post),url:d.getURL("users/listPostActivity")}),v=h.extend({model:l.Thread,url:d.getURL("timelines/ranked"),initialize:function(a,b){b=b||{},this.type=b.type,this.target=b.target},fetch:function(b){return b=b||{},b.data=a.extend({type:this.type,target:this.target},b.data),h.prototype.fetch.call(this,b)},parse:function(b){return b=h.prototype.parse.call(this,b),a.map(b.activities,function(a){return e.buildThread(b.objects,a.items[0].object)})}}),w=b.Collection.extend({model:l.SyncedTopUser,url:d.getURL("forums/listMostActiveUsers"),initialize:function(a,b){this.forum=b.forum,this.limit=b.limit},fetch:function(c){return b.Collection.prototype.fetch.call(this,a.extend({data:{forum:this.forum,limit:this.limit}},c))},parse:function(b){return a.filter(b.response,function(a){if(parseFloat(a.rep)>.7)return a})}});g.prototype.model=k.wrap(l.User);var x=b.Collection.extend({model:l.SyncedUser,url:d.getURL("forums/listModerators"),initialize:function(a,b){this.forum=b.forum},fetch:function(c){return b.Collection.prototype.fetch.call(this,a.extend({data:{forum:this.forum}},c))},parse:function(b){return a.map(b.response,function(a){return a.user})}}),y="reaction-vote",z=b.Collection.extend({url:d.getURL("threadReactions/loadReactions"),initialize:function(a,b){this.thread=b.thread,this.enabled=Boolean(a.length),this.eligible=Boolean(b.eligible),this.userIsAnonymous=b.userIsAnonymous,this.renderId=b.renderId},fetch:function(c){return b.Collection.prototype.fetch.call(this,a.extend({data:{thread:this.thread.id}},c))},parse:function(a,b){var c=a.response;b=b||{};var d=c.reactions;return this.enabled=Boolean(d.length),this.eligible=c.eligible,this.prompt=c.prompt,this.renderId=c.renderId,this.setSelectedReaction(d,c.selected),b.isManual&&this.set(d),d},setSelectedReaction:function(a,b){var c=b&&b.id;if(!c&&this.userIsAnonymous){var d=f.get(y);c=d&&d[this.thread.get("id")]}c&&(a.forEach(function(a){a.id===c?(a.set?a.set("isSelected",!0):a.isSelected=!0,a.get&&!a.get("votes")?a.set("votes",1):a.get||a.votes||(a.votes=1)):a.set?a.set("isSelected",!1):a.isSelected=!1}),this.trigger("change:selectedReaction"))},toggleEnabled:function(){var a=this;d.call("threadReactions/disableForThread",{method:"POST",data:{thread:this.thread.get("id"),enable:this.enabled?0:1},success:function(){a.enabled=!a.enabled,a.trigger("change:enabled"),a.enabled&&!a.length&&a.fetch()}})},vote:function(b,c){var e=this.at(b);if(e&&!e.get("isSelected")){c=c||{},this.trigger("vote:start");var g=this;d.call("threadReactions/vote",a.extend({},c,{method:"POST",data:{thread:this.thread.get("id"),reaction:e.get("id")},success:function(){if(g.forEach(function(a,c){var d=c===b,e=a.get("votes");d&&(e+=1),a.get("isSelected")&&(e=Math.max(0,e-1)),a.set({isSelected:d,votes:e})},g),g.trigger("vote:end"),g.userIsAnonymous){var a=f.get(y)||{};a[g.thread.get("id")]=e.get("id"),f.set(y,a)}c.success&&c.success()},error:function(){g.trigger("vote:end"),c.error&&c.error()}}))}}}),A=b.Collection.extend({url:d.getURL("gifs/search"),model:l.GifObject,query:null,page:null,fetch:function(c){return c.query===this.query?this.page+=1:this.page=1,b.Collection.prototype.fetch.call(this,a.extend({data:{forum:c.forum,query:c.query,page:this.page}},c))},parse:function(a,b){var c=a.response,d=this.toJSON();return b.query===this.query?d.concat(c):(this.query=b.query,c)},reset:function(){return this.query=null,this.page=null,b.Collection.prototype.reset.call(this)}});return{PaginatedCollection:h,UserCollection:g,ChannelCollection:i,PostCollection:p,SubpaginatedPostCollection:r,TypingUserCollection:t,TopUserCollection:w,RankedThreadCollection:v,ThreadVoteCollection:o,PostActivityCollection:u,QueuedPostCollection:s,ModeratorCollection:x,ReactionsCollection:z,GifObjectsCollection:A}}),define("core/models/Session",["jquery","underscore","backbone","moment","core/api","core/bus","core/config","core/time","core/utils","core/utils/cookies","core/utils/guid","core/utils/auth","core/models/BaseUser","core/models/User"],function(a,b,c,d,e,f,g,h,i,j,k,l,m,n){"use strict";var o=function(){return l.getFromCookie()},p=c.Model.extend({initialize:function(){this.constructor.fromCookie=b.once(o),this.user=this.getAnonUserInstance()},setUser:function(a){this.user&&this.stopListening(this.user),this.user=a,this.setIfNewUser(),this.listenTo(a,"all",this.trigger),this.trigger("change:id",a)},isLoggedOut:function(){return!this.isLoggedIn()},isLoggedIn:function(){return Boolean(this.user.get("id"))},fetch:function(a){var c=a||{};return e.call("users/details.json",{data:c.data,success:b.bind(function(a){a=a.response,a.id&&this.setUser(this.getUserInstance(a)),c.success&&c.success(a),c.complete&&c.complete(a)},this),error:function(a){c.error&&c.error(a),c.complete&&c.complete(a)}})},getAnonUserInstance:function(a){return new m(a)},getUserInstance:function(a){return new n(a)},getCsrfToken:function(){var a=j.read("csrftoken");return a||(a=k.generate().replace(/\W/g,""),j.create("csrftoken",a,{domain:window.location.hostname,expiresIn:31536e6})),a},authenticate:function(c){var d=this.authServices[c];if(d){if(b.isFunction(d))return d.call(this);f.trigger("uiAction:openLogin",c);var e=this.getAuthWindowArgs(d),g=d.url;g+=(g.indexOf("?")>-1?"&":"?")+a.param(e),this.openAuthWindow(g,d.width,d.height)}},authServices:{disqus:{url:g.urls.login,width:460,height:355,attachExperiment:!0},twitter:{url:g.urls.oauth.twitter,width:650,height:680,csrf:!0,attachExperiment:!0},facebook:{url:g.urls.oauth.facebook,width:550,height:300,csrf:!0,attachExperiment:!0},google:{url:g.urls.oauth.google,width:445,height:635,csrf:!0,attachExperiment:!0}},getAuthWindowArgs:function(a){var c={};return a.csrf&&(c.ctkn=this.getCsrfToken()),b.extend(c,a.params),c},openAuthWindow:function(a,b,c){return i.openWindow(a,"_blank",{width:b,height:c})},setIfNewUser:function(){var a=this.user.get("joinedAt");if(this.user.get("isAnonymous")||!a)return void this.user.set("joinedRecently",!1);var b=h.assureTzOffset(a);this.user.set("joinedRecently",d().subtract(10,"seconds").isBefore(b))}});return p.fromCookie=o,p.isKnownToBeLoggedOut=function(){return!p.fromCookie().id},p}),define("core/WindowBus",["jquery","underscore","backbone","modernizr"],function(a,b,c,d){"use strict";var e=c.Model.extend({initialize:function(){d.localstorage&&a(window).on("storage",b.bind(this.onStorageEvent,this))},broadcast:function(a,b){if(d.localstorage){var c=JSON.stringify({name:a,data:b,time:(new Date).getTime()});try{window.localStorage.setItem(this.constructor.STORAGE_KEY,c)}catch(e){}}},onStorageEvent:function(a){var b=a.originalEvent.key,c=a.originalEvent.newValue;if(c&&b===this.constructor.STORAGE_KEY)try{c=JSON.parse(c),this.trigger(c.name,c.data)}catch(d){}}},{STORAGE_KEY:"disqus.bus"});return e}),define("templates/lounge/threadVotes",["react","core/config/urls","core/strings","core/utils/object/get"],function(a,b,c,d){"use strict";var e=c.gettext,f=function(c){return a.createElement("div",null,a.createElement("a",{href:"#","data-action":"recommend",title:e("Recommend this discussion"),className:"dropdown-toggle "+(d(c.thread,["userScore"])?"upvoted":"")},a.createElement("span",{className:"label label-default"},a.createElement("span",{className:"recommend-icon icon-heart-empty"})," ",e("Recommend")),a.createElement("span",{className:"label label-recommended"},a.createElement("span",{className:"recommend-icon icon-heart"})," ",e("Recommended"))," ",d(c.thread,["likes"])?a.createElement("span",{className:"label label-count"},d(c.thread,["likes"],null)):null),a.createElement("ul",{className:"dropdown-menu dropdown-menu--coachmark"},a.createElement("li",null,c.loggedIn?a.createElement("div",null,a.createElement("h2",{className:"coachmark__heading"},e("Your 1st recommended discussion!")),a.createElement("p",{className:"coachmark__description"},e("Recommending means this is a discussion worth sharing. It gets shared to your followers' %(Disqus)s feeds if you log in, and gives the creator kudos!",{Disqus:"Disqus"}))):a.createElement("div",null,a.createElement("h2",{className:"coachmark__heading"},e("Discussion Recommended!")),a.createElement("p",{className:"coachmark__description"},e("Recommending means this is a discussion worth sharing. It gets shared to your followers' %(Disqus)s feeds, and gives the creator kudos!",{Disqus:"Disqus"})))," ",a.createElement("a",{href:(b.root||"")+"/home/?utm_source=disqus_embed&utm_content=recommend_btn",className:"btn btn-primary coachmark__button",target:"_blank"},e(c.loggedIn?"See Your Feed":"Find More Discussions"))))); };return f}),define("lounge/views/recommend-button",["backbone","core/utils/storage","templates/lounge/threadVotes"],function(a,b,c){"use strict";var d=a.View.extend({className:"thread-likes",events:{"click [data-action=recommend]":"recommendHandler"},initialize:function(a){this.session=a.session,this.thread=a.thread,this.loggedOutRecommendFlag=this.session.getLoggedOutUserFlags().get(d.ONBOARDING_KEY),this.listenTo(this.thread,"change:userScore",this.render),this.listenTo(this.thread,"change:likes",this.render),this.listenTo(this.session,"change:id",this.startRecommendOnboarding),this.setTooltipEnabled()},setTooltipEnabled:function(){this.tooltipEnabled=this.session.isLoggedIn()?b.get(d.ONBOARDING_KEY):!this.loggedOutRecommendFlag.isRead()},render:function(){return this.$el.html(c({thread:this.thread.toJSON(),user:this.session.toJSON(),loggedIn:this.session.isLoggedIn()})),this},startRecommendOnboarding:function(){this.session.user.get("joinedRecently")&&b.set(d.ONBOARDING_KEY,"true"),this.setTooltipEnabled()},recommendHandler:function(a){a.stopPropagation(),a.preventDefault();var b=0===this.thread.get("userScore");this.trigger(b?"vote:like":"vote:unlike"),this.thread.vote(b?1:0),this.toggleTooltip(b),this.tooltipEnabled&&b&&this.markAsSeen()},markAsSeen:function(){this.session.isLoggedIn()?b.remove(d.ONBOARDING_KEY):this.loggedOutRecommendFlag.markRead()},toggleTooltip:function(a){this.tooltipEnabled&&(a?this.$el.parent().addClass("open"):this.$el.parent().removeClass("open"))}},{ONBOARDING_KEY:"showRecommendOnboarding"});return d}),define("common/collections/LoggedOutCache",["backbone","common/cached-storage","lounge/views/recommend-button"],function(a,b,c){"use strict";var d=[{id:"welcome",title:"",body:""}],e=[{id:c.ONBOARDING_KEY}],f=new b("notes",7776e3),g=a.Model.extend({markRead:function(){f.setItem(this.id,!0)},isRead:function(){return Boolean(f.getItem(this.id))}}),h=a.Collection.extend({initialize:function(a,b){this.session=b.session},model:g,markAllRead:function(){return this.each(function(a){a.markRead()}),this.session.set("notificationCount",0),this},getUnread:function(){return this.filter(function(a){return!a.isRead()})}});return{storage:f,Collection:h,Model:g,LOGGED_OUT_NOTES:d,LOGGED_OUT_FLAGS:e}}),define("common/Session",["jquery","underscore","core/analytics/jester","core/api","core/bus","core/config","core/models/Session","core/switches","core/UniqueModel","core/utils/cookies","core/utils/url/serialize","core/WindowBus","common/collections/LoggedOutCache","common/keys","common/models","common/urls","common/utils","lounge/common","lounge/tracking"],function(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s){"use strict";var t,u=3500,v={type:"notifications",routingVersion:f.feedApiVersion},w={},x=new l,y=g.extend({_defaults:{canReply:!0,canModerate:!1,audienceSyncVerified:!1,sso:null},socialLoginProviders:{facebook:function(){var b=a.Deferred();return require(["fb"],b.resolve.bind(b),b.reject.bind(b)),b.promise().then(function(){window.FB.init({appId:n.facebook,xfbml:!1,status:!0,version:"v2.8"});var b=a.Deferred();return window.FB.getLoginStatus(function(a){"connected"===a.status?b.resolve(a):b.reject()}),b.promise()}).then(function(a){c.logStat("lounge.auto_login.fb");var b=a.authResponse;return{grant_type:"urn:disqus:params:oauth:grant-type:facebook-login",client_id:n.embedAPI,expires:b.expiresIn,fb_access_token:b.accessToken}})},google:function(){var b=a.Deferred();return require(["gapi"],function(a){setTimeout(b.reject.bind(b),u),a.load("auth2",b.resolve.bind(b,a))},b.reject.bind(b)),b.promise().then(function(b){var c=b.auth2.init({client_id:n.google,fetch_basic_profile:!1,scope:"profile email"}),d=a.Deferred();return c.then(function(){c.isSignedIn.get()?d.resolve(c.currentUser.get()):d.reject()}),d.promise()}).then(function(a){c.logStat("lounge.auto_login.google");var b=a.getAuthResponse();return{grant_type:"urn:disqus:params:oauth:grant-type:google-login",client_id:n.embedAPI,expires:b.expires_in,google_access_token:JSON.stringify(b)}})}},defaults:function(){var a=new m.Collection(m.LOGGED_OUT_NOTES,{session:this});return b.extend(this._defaults,{notificationCount:a.getUnread().length})},start:function(b){var c=b||{};if(this.set(c),this.listenTo(x,"auth:success",this.fetch),this.listenTo(e.frame,{"!auth:success":function(a){a&&(a.sessionId&&d.headers({"X-Sessionid":a.sessionId}),a.message&&this.trigger("alert",a.message,{type:"info"}),a.logEvent&&e.trigger("uiAction:"+a.logEvent)),x.broadcast("auth:success"),this.fetch()}}),this.bindAudienceSyncHandlers(),this.shouldFetchSession())this.fetch({isStart:!0});else if(j.read("no_auto_login")||s.isPrivate())this.loginAsAnon();else{var f=this.socialLoginProviders,g=!1,h=0,i=a.Deferred(),k=Object.keys(f).map(function(a){return f[a].call(this)},this),l=function(a){g||(g=!0,i.resolve(a))},m=function(a){h+=1,h===k.length&&i.reject(a)};k.forEach(function(a){a.then(l).fail(m)}),i.promise().then(function(b){return a.post("https://disqus.com/api/oauth/2.0/access_token/",b)}).then(function(a){this.fetch({data:{access_token:a.access_token}})}.bind(this)).fail(this.loginAsAnon.bind(this))}},stop:function(){this.stopListening(),this.off()},loginAsAnon:function(){this.setUser(this.getAnonUserInstance())},shouldFetchSession:function(){return Boolean(this.get("remoteAuthS3")||w.fromCookie().id)},getUserInstance:function(a){return new i(o.User,a)},toJSON:function(){var a=this.user.toJSON.apply(this.user,arguments);return a.thread.canReply=this.get("canReply"),a.thread.canModerate||(a.thread.canModerate=this.get("canModerate")),a},fetch:function(a){var b=this,c=a||{};b.has("thread")&&(c.thread=b.get("thread"));var d=c.thread?b.fetchThreadDetails(c):g.prototype.fetch.call(b,c);return d&&!h.isFeatureActive("experiment:lightapi:consolidated")&&d.done(function(){b.set("notificationCount",0)}),d},fetchNotificationCount:function(){var b=this;return b.isLoggedIn()?d.call("timelines/getUnreadCount.json",{data:v}).done(function(a){b.set("notificationCount",a.response)}):a.Deferred().resolve()},fetchThreadDetails:function(a){var c=this,e=a.thread;c._request&&(c._request.abort(),c._request=null);var f={thread:e.id,post:e.posts.pluck("id")};return h.isFeatureActive("experiment:lightapi:consolidated")&&(b.extend(f,v),e&&e.get("reactionsRenderId")&&(f.renderId=e.get("reactionsRenderId"))),c._request=d.call("embed/threadDetails.json",{data:f,success:function(a){var d=a.response,f={};d.user&&b.extend(f,d.user,{votes:d.votes,selectedReaction:d.selected}),c.set(d.session),f.id?(c.setUser(new i(o.User,f)),e.users.add(c.user),d.thread&&(e.set("userScore",d.thread.userScore),e.set("userSubscription",d.thread.userSubscription),e.set("userRating",d.thread.userRating))):c.loginAsAnon(),d.blockedUsers&&b.each(d.blockedUsers,function(a){new i(o.User,{id:a}).set({isBlocked:!0})}),h.isFeatureActive("experiment:lightapi:consolidated")&&c.set("notificationCount",d.notificationCount),c.trigger("fetchThreadDetails:success")},complete:function(){c._request=null}}),c._request},logout:function(){var a=this.get("sso");this.isSSO()&&a&&a.logout?e.frame.sendHostMessage("navigate",a.logout):this.locationReplace(k(p.logout,{redirect:window.location.href}))},locationReplace:function(a){window.location.replace(a)},isSSO:function(){return this.user&&"sso"===this.user.get("user_type")},getAuthWindowArgs:function(a){var c=g.prototype.getAuthWindowArgs.call(this,a),d=r.getLounge().config;if(a.attachExperiment&&d&&d.experiment){var e=d.experiment;c.evs=window.btoa([e.experiment,e.variant,e.service].join(":"))}return b.defaults({forum:this.get("thread")&&this.get("thread").forum.id},c)},openAuthWindow:function(a,b,c){try{var d=this.get("thread"),e=d&&d.currentUrl;window.sessionStorage&&e&&window.sessionStorage.setItem("discussionUrl",e)}catch(f){}return g.prototype.openAuthWindow.call(this,a,b,c)},authServices:b.defaults({disqusDotcom:{url:p.dotcomLogin,width:478,height:590,params:{next:p.login},attachExperiment:!0},sso:function z(){var z=this.get("sso"),a=parseInt(z.width||"800",10),c=parseInt(z.height||"500",10),d=this.openAuthWindow(z.url,a,c);!function f(){q.isWindowClosed(d)?e.frame.sendHostMessage("reload"):b.delay(f,500)}()}},g.prototype.authServices),bindAudienceSyncHandlers:function(){this.listenTo(this,"change:id change:audienceSyncVerified",function(){this.get("audienceSyncVerified")&&e.frame.sendHostMessage("session.identify",this.user.id)}),this.listenTo(e.frame,{"!audiencesync:grant":function(){this.set("audienceSyncVerified",!0)}})},getAudienceSyncUrl:function(){var a={client_id:this.get("apiKey"),response_type:"audiencesync",forum_id:this.get("thread").forum.id};return"https:"===window.location.protocol&&(a.ssl=1),k(p.authorize,a)},audienceSync:function(){this.openAuthWindow(this.getAudienceSyncUrl(),460,355)},needsAudienceSyncAuth:function(a){return a.get("settings").audienceSyncEnabled&&this.isLoggedIn()&&!this.get("audienceSyncVerified")},getLoggedOutUserFlags:function(){return this._loggedOutUserFlags?this._loggedOutUserFlags:(this._loggedOutUserFlags=new m.Collection(m.LOGGED_OUT_FLAGS,{session:this}),this._loggedOutUserFlags)}});return b.extend(w,b.chain(y).keys().map(function(a){return[a,y[a]]}).object().value(),{get:function(){return t=t||new y},setDefaults:function(a){if(t)throw new Error("Session defaults cannot be changed after a session instance is created!");return y._defaults=b.extend(y.prototype._defaults,a),y._defaults},forget:function(){t&&(t.stop(),t=null)}}),w}),define("common/views/mixins",["jquery","underscore","core/bus","common/Session"],function(a,b,c,d){"use strict";function e(){this._getStyleProperty=function(a){var b=this.forum.get(a);return this.config.forceAutoStyles||"auto"===b?this.config[a]:b},this.getTypeface=function(){return this._getStyleProperty("typeface")},this.getColorScheme=function(){return this._getStyleProperty("colorScheme")},this.applyPublisherClasses=function(){var b=a("body");"serif"===this.getTypeface()&&b.addClass("serif"),"dark"===this.getColorScheme()&&b.addClass("dark")}}var f={proxyViewEvents:function(a){this.listenTo(a,"all",function(a){0===a.indexOf("uiAction:")&&this.trigger.apply(this,arguments)},this)}},g={updateUserAvatarHelper:function(b,c){a("img[data-user="+b+'][data-role="user-avatar"]').attr("src",c)},updateUserNameHelper:function(c,d){var e='[data-username="'+c+'"][data-role=username]';a("a"+e+", span"+e).html(b.escape(d))},bindProfileUIListeners:function(a){this.listenTo(a,{"change:avatar":function(){this.updateUserAvatarHelper(a.user.id,a.user.get("avatar").cache)},"change:name":function(){this.updateUserNameHelper(a.user.get("username"),a.user.get("name"))}})}},h={toggleFollow:function(b){b.preventDefault(),b.stopPropagation();var c=b&&a(b.target).closest("a[data-user]").attr("data-user"),e=this.collection&&c?this.collection.get(c):this.user,f=d.get();return f.isLoggedOut()?(this.trigger("authenticating"),this.listenToOnce(f,"change:id",function(){f.isLoggedIn()&&this.follow(e)}),f.get("sso")&&f.get("sso").url?void f.authenticate("sso"):void f.authenticate("disqusDotcom")):void(e.get("isFollowing")?this.unfollow(e):this.follow(e))},unfollow:function(a){a.unfollow(),c.trigger("uiAction:unfollowUser",a)},follow:function(a){a.follow(),c.trigger("uiAction:followUser",a)}};return{FollowButtonMixin:h,UiActionEventProxy:f,appliesPublisherClasses:e,ProfileHtmlHelpers:g}}),define("core/utils/isIframed",[],function(){"use strict";return function(a){try{return a.self!==a.top}catch(b){return!0}}}),define("core/viglink",["remote/config"],function(a){"use strict";var b={},c=null;return b.resetVersion=function(){c=null},b.forceVersion=function(a){c=a},b.getVersion=function(){return c?c:a.lounge&&a.lounge.viglink&&a.lounge.viglink.version||"none"},b.getExperimentVersion=function(){return a.lounge&&a.lounge.viglink&&a.lounge.viglink.experiment_version||"none"},b}),define("common/outboundlinkhandler",["jquery","underscore","core/utils","common/utils"],function(a,b,c,d){"use strict";function e(){this.handlers=[],this.locked={},this.timeout=1e3}return b.extend(e.prototype,{handleClick:function(d){var e=a(d.currentTarget),f=this.getLinkTrackingId(e);if(this.shouldHandleClick(d,e,f)){var g=b.chain(this.handlers).map(function(a){return a[0].call(a[1],d,e)}).compact().value();c.willOpenNewWindow(d,e)||(d.preventDefault(),this.setLatestClick(f),this.delayNavigation(d,e,g))}},delayNavigation:function(c,e,f){this.lockLink(this.getLinkTrackingId(e));var g=b.bind(function(){this.isLatestClick(this.getLinkTrackingId(e))&&d.triggerClick(e,c.originalEvent)},this);b.delay(g,this.timeout),a.when.apply(a,f).always(g)},registerBeforeNavigationHandler:function(a,b){this.handlers.push([a,b])},getLinkTrackingId:function(a){var c=a.attr("data-tid");return c||(c=b.uniqueId(),a.attr("data-tid",c)),c},shouldHandleClick:function(a,b){if(!this.isLinkLocked(this.getLinkTrackingId(b))){if(a.isDefaultPrevented())return!1;if(!b.is("a"))return!1;var c=/#.*/,d=(b.attr("href")||"").replace(c,"");return!!d}},setLatestClick:function(a){this.latestLinkId=a},isLatestClick:function(a){return this.latestLinkId===a},lockLink:function(a){this.locked[a]=!0},isLinkLocked:function(a){return this.locked[a]}}),e}),define("core/mixins/withEmailVerifyLink",["jquery","underscore","core/config","core/utils"],function(a,b,c,d){"use strict";var e=d.preventDefaultHandler,f={events:{"click [data-action=verify-email]":"showVerifyEmailPopup"},showVerifyEmailPopup:e(function(b){var e=a(b.target).attr("data-forum"),f=c.urls.verifyEmail;return e&&(f=f+"?f="+e),d.openWindow(f,"_blank",{width:460,height:355})})};return function(){this.events=b.defaults({},this.events,f.events),b.extend(this,b.pick(f,"showVerifyEmailPopup"))}}),define("core/constants/behindClickConstants",["exports","core/strings"],function(a,b){"use strict";var c=b.get;a.DEFAULT_BUTTON_TEXT=b.interpolate(c("Show Comments (%(count)s)"),{count:"{postCount}"})}),define("core/templates/react/BehindClickTemplate",["react","core/constants/behindClickConstants"],function(a,b){"use strict";function c(a){if(!a||a.indexOf(":")===-1)return{};var b={},c=a.split(";");return c.forEach(function(a){var c=a.split(":").map(function(a){return a.trim()});if(c[0].indexOf("-")>0){var d=c[0].split("-");c[0]=d[0]+d[1].charAt(0).toUpperCase()+d[1].slice(1)}b[c.splice(0,1)[0]]=c.join(":")}),b}function d(a,b){return a?a.replace("{postCount}",b.toLocaleString()):a}var e=function(e){var f=e.postCount,g=e.buttonText,h=e.buttonCSS,i=e.titleEnabled,j=e.titleText,k=e.titleCSS;return a.createElement("div",{id:"behind-click__container"},i?a.createElement("h3",{id:"behind-click__title",style:c(k)},d(j,f)):null,a.createElement("button",{id:"thread-visibility__button",className:"btn alert","data-action":"toggle-thread-visibility",style:c(h)},g?d(g,f):d(b.DEFAULT_BUTTON_TEXT,f)))};return e}),define("core/constants/reactionConstants",["exports","core/strings"],function(a,b){"use strict";var c=b.get,d="//c.disquscdn.com/next/current/publisher-admin/assets/img/emoji/";a.DEFAULT_REACTIONS=[{text:"Upvote",imageUrl:d+"upvote-512x512.png"},{text:"Funny",imageUrl:d+"funny-512x512.png"},{text:"Love",imageUrl:d+"love-512x512.png"},{text:"Surprised",imageUrl:d+"surprised-512x512.png"},{text:"Angry",imageUrl:d+"angry-512x512.png"},{text:"Sad",imageUrl:d+"sad-512x512.png"}],a.DEFAULT_PROMPT=c("What do you think?"),a.DEFAULT_DESCRIPTIONS=["Upvote","Funny","Love","Surprised","Angry","Sad"],a.UPLOAD_IMAGE_ERROR_MESSAGES={"invalid-image-file":"Unfortunately your image upload failed. Please verify that the file is valid and in a supported format (JPEG, PNG, or GIF).","invalid-content-type":"Unfortunately your image upload failed. Please verify that the file is in a supported format (JPEG, PNG, or GIF).","file-too-large":"Unfortunately your image upload failed. Please verify that your image is under 5MB.","not-authenticated":"You must be logged in to upload an image.","default":"Unfortunately your image upload failed. Please verify that your image is in a supported format (JPEG, PNG, or GIF) and under 5MB. If you continue seeing this error, please try again later."}});var _extends=Object.assign||function(a){for(var b=1;b=f.length)){a=f.slice(this.marker).split("\n");for(var h=a.length,i=0;i0&&(this.marker+=g-1)}}},open:function(){this.close();var a=this.connection=f.CORS.request("GET",this.getUrl(),this._boundOnLoad,this._boundOnError);if(!a)return void c.debug("RT: Cannot use any cross-domain request tool with StreamPipe. Bailing out.");a.onprogress=this._boundOnProgress,this.connection=a,this.marker=0;try{a.send()}catch(b){this.connection=null,c.debug("RT: Attempt to send a CORS request failed.")}},close:function(){var a=s.prototype.close.apply(this);return a&&a.abort()}}),a.extend(i.prototype,s.prototype,{baseUrl:"wss:"+g.realertime+"/ws/2/",onOpen:function(){c.debug("RT: [Socket] Connection established."),this.handshakeSuccess=!0},onError:function(){if(!this.handshakeSuccess){if(this.handshakeFails>=n)return c.debug("RT: [Socket] Error before open, bailing out."),void this.trigger("fail");this.handshakeFails+=1}this.connection&&(this.connection=null,this.trigger("error"),this.interval<=l&&(this.interval*=k),c.error("RT: Connection error, backing off %s secs",this.interval),a.delay(this._boundOpen,1e3*this.interval))},onClose:function(a){if(this.connection){if(!a.wasClean)return this.onError();this.connection=null,c.debug("RT: [Socket] Connection closed. Restarting..."),this.trigger("close"),this.open()}},open:function(){this.close();try{this.connection=new window.WebSocket(this.getUrl())}catch(a){return this.onError()}var b=this.connection;b.onopen=this._boundOnOpen,b.onerror=this._boundError,b.onmessage=this._boundMessage,b.onclose=this._boundClose},close:function(){var a=s.prototype.close.apply(this);return a&&a.close()}});var t={_wsSupported:o,initialize:function(b,c,d){this.close(),this._initArgs=[b,c,d];var e=this._wsSupported,f=e&&i||p&&h;if(f){var g=this.pipe=new f(b);a.chain(c).pairs().each(function(a){g.on(a[0],a[1],d)}),e&&g.on("fail",function(){this._wsSupported=!1,g.off(),this.initialize.apply(this,this._initArgs)},this),g.open()}},pause:function(a){this.pipe&&this.pipe.pause(a)},resume:function(){this.pipe&&this.pipe.resume()},close:function(){this.pipe&&(this.pipe.close(),this.pipe=null)}};return window.addEventListener("unload",a.bind(t.close,t)),{Pipe:s,StreamPipe:h,SocketPipe:i,Manager:t,MAX_HANDSHAKE_FAILS:n}}),define("host/common/apps/BaseApp",["require","core/Events","core/utils/object/extend","core/utils/object/has","core/utils/uniqueId"],function(a){"use strict";var b=a("core/Events"),c=a("core/utils/object/extend"),d=a("core/utils/object/has"),e=a("core/utils/uniqueId"),f=function(a){this.uid=e("dsq-app"),this.settings=a||{};var b=[],c=this.constructor.prototype;do b.unshift(c),c=c.constructor.__super__;while(c);for(var f=0,g=b.length;f255)throw new Error("Color components should be numbers less than 256");return a=a.toString(16),1===a.length?"0"+a:String(a)}return function(b){return"#"+a(b.red)+a(b.green)+a(b.blue)}}),define("core/utils/sandbox",[],function(){"use strict";var a=["allow-forms","allow-pointer-lock","allow-popups","allow-same-origin","allow-scripts","allow-top-navigation"],b=function(b){return b?a.reduce(function(a,c){return b[c]&&(a+=c+" "),a},"").trim():""};return{getAttribute:b}}),define("core/utils/url/parseQueryString",["core/utils/collection/each"],function(a){"use strict";return function(b){"undefined"==typeof b&&(b=window.location.search);var c={};return a(b.substr(1).split("&"),function(a){var b=a.split("=").map(function(a){return decodeURIComponent(a.replace(/\+/g,"%20"))});b[0]&&(c[b[0]]=b[1])}),c}}),define("common/analytics/reporting",["require","core/utils/collection/each","core/utils/url/serialize"],function(a){"use strict";function b(a){var b=a.split("."),c=b.length>2?b[b.length-2]:"";return c.match(/^[0-9a-f]{32}$/i)&&c}function c(a){(new window.Image).src=g(h+"/stat.gif",{event:a})}function d(a){(new window.Image).src=g(h+"/event.gif",a)}function e(a){var b=new window.URLSearchParams;f(a,function(a,c){void 0!==a&&b.append(c,a)});var c=new window.XMLHttpRequest;c.open("POST",h+"/event.json",!0),c.withCredentials=!0,c.send(b)}var f=a("core/utils/collection/each"),g=a("core/utils/url/serialize"),h="https://referrer.disqus.com/juggler";return{getLoaderVersionFromUrl:b,logStat:c,reportJester:d,reportJesterPOST:e}}),define("lounge/ads/ads",["require","common/main","host/common/apps/WindowedApp","host/common/json","stance/main","stance/utils","core/utils/OnceTimer","core/utils/html/toHexColorString","core/utils/object/extend","core/utils/sandbox","core/utils/url/parseQueryString","core/utils/url/serialize","core/utils/urls","core/utils/urls","common/analytics/reporting","common/kernel/WindowBase"],function(a){"use strict";var b=a("common/main"),c=a("host/common/apps/WindowedApp"),d=a("host/common/json"),e=a("stance/main"),f=a("stance/utils"),g=a("core/utils/OnceTimer"),h=a("core/utils/html/toHexColorString"),i=a("core/utils/object/extend"),j=a("core/utils/sandbox"),k=a("core/utils/url/parseQueryString"),l=a("core/utils/url/serialize"),m=a("core/utils/urls").getOrigin,n=a("core/utils/urls").getQuery,o=a("common/analytics/reporting"),p=a("common/kernel/WindowBase"),q=c.extend({name:"ads",origin:void 0,onceEvents:{"view:enter":function(){this._reportLegacy({verb:"view",adverb:"0ms-no50perc"})},"view:iab":function(){this._reportLegacy({verb:"view",adverb:"iab-scroll"})}},events:{"frame:ready":function(a){this.forumId=a.forumId,this._reportOnce({verb:"load",extra_data:a.extraData,advertisement_id:a.advertisement_id},"load"),this.bindViewEvents()},"frame:resize":function(a){this.frame.setInlineStyle("height",a.height+"px")},"frame:click":function(){this._reportOnce({verb:"click"},"click")},"frame:hover":function(){this._reportOnce({verb:"hover"},"hover")},"frame:error-provider-not-ready":function(){this._reportLegacy({verb:"fail",object_type:"provider",object_id:this.getProvider(),adverb:"provider_not_ready"})},"frame:error-no-height":function(){this._reportLegacy({verb:"fail",object_type:"provider",object_id:this.getProvider(),adverb:"no_height"})},"frame:clearSandbox":function(){this.frame.elem.hasAttribute("sandbox")&&this.frame.elem.removeAttribute("sandbox")},"frame:logAd":function(a){this._report(a,{usePOST:!0})}},constructor:function(){c.apply(this,arguments),this.origin=m(this.settings.adUrl),this._reportOnceHistory={}},init:function(){if(!this.settings.isHostIframed&&(this.settings.forum=k(n(this.settings.adUrl)).shortname,this.settings.forum)){var a=this.settings.discovery,b=a&&(a.disable_all||a.disable_promoted);!this.settings.isInHome&&b&&this.settings.canDisableAds||(this._reportOnce({verb:"call",object_type:"provider",object_id:this.getProvider(),adjective:1},"call"),this.settings.sandboxAds&&(this.sandbox=j.getAttribute({"allow-scripts":!0,"allow-same-origin":!0,"allow-forms":!0,"allow-popups":!0})),c.prototype.init.call(this))}},getProvider:function(){if(this._provider)return this._provider;var a=this.settings.adUrl.match(/provider=(\w+)/);return a&&(this._provider=a[1]),this._provider},getUrl:function(){var a=this.settings;return l(a.adUrl,{anchorColor:h(a.anchorColor),colorScheme:a.colorScheme,sourceUrl:a.referrer,typeface:a.typeface,canonicalUrl:a.canonicalUrl,disqus_version:a.version})},bindViewEvents:function(){if(!this._viewEventsBound){this._viewEventsBound=!0;var a=this,b=function(b,c){a.postMessageDirect({event:b,percentViewable:c})},c=1e3,d=new g(function(){a.trigger("view:iab"),b("view:iab")},c),h=!1;this.listenTo(e({el:this.frame.elem}),{enter:function(){a.trigger("view:enter"),b("view:enter")},exit:function(){b("view:exit"),h&&(h=!1,b("view:50out"),d.clear())},visible:function(a,c){var e=f.visiblePercent(c,a.offset());e>=50&&!h?(h=!0,b("view:50in"),d.start()):e<50&&h&&(h=!1,b("view:50out"),d.clear()),b("view",e)}})}},postMessageDirect:function(a){this.frame.requiresWindow(function(a){var b=d.stringify(i({},a,{space:"disqus"}));p.postMessage(this.window,b,this.origin),p.postMessage(this.window,"disqus."+a.event,this.origin)})(a)},_report:function(a){var c=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},d=this.settings,e=this.getProvider();a.forum_id=d.forumId||this.forumId;var f=c.usePOST?"reportJesterPOST":"reportJester";o[f](i({imp:d.impressionId,experiment:d.experiment.experiment,variant:d.experiment.variant,service:d.experiment.service,area:d.placement,product:"embed",forum:d.forum,zone:"thread",version:b.version,page_url:d.referrer,page_referrer:d.hostReferrer,object_type:"advertisement",provider:e,event:"activity"},a))},_reportLegacy:function(a){var b=this.settings;this._report(i({ad_product_name:"iab_display",ad_product_layout:"iab_display",bin:"embed:promoted_discovery:"+b.experiment.service+":"+b.experiment.experiment+":"+b.experiment.variant,object_id:a.advertisement_id?"["+a.advertisement_id+"]":"",section:"default"},a))},_reportOnce:function(a,b){this._reportOnceHistory[b]||(this._reportLegacy(a),this._reportOnceHistory[b]=!0)},getFrameSettings:function(){var a=c.prototype.getFrameSettings.call(this);return a.insertBeforeEl=this.settings.insertBeforeEl,a.insertAfterEl=this.settings.insertAfterEl,a}}),r=function(a){return new q(a)};return{Ads:r}}),define("core/templates/react/aet/EmailSignupComplete",["react"],function(a){"use strict";var b=function(b){var c=b.forum,d=b.isVerified,e=b.onDismiss;return a.createElement("div",{className:"newsletter-box spacing-bottom-large text-center"},a.createElement("div",{className:"text-medium spacing-bottom-small"},a.createElement("strong",null,"Thanks for subscribing!")),d?a.createElement("div",{className:"spacing-bottom-small"},(c.aetBannerConfirmation||"").split("\n").map(function(b,c){return a.createElement("div",{key:c},b)})):a.createElement("div",{className:"spacing-bottom-small"},"To begin receiving email updates from ",c.name,", please click the link in the confirmation email we've sent to your inbox."),a.createElement("a",{className:"newsletter-box__hide",href:"#",onClick:function(a){a.preventDefault(),e()}},"Dismiss this message"))};return b}),define("core/templates/react/aet/EmailSignupForm",["react","core/strings"],function(a,b){"use strict";var c=b.gettext,d=function(b){var d=b.forum,e=b.isLoading,f=b.isLoggedIn,g=b.onDismiss,h=b.onSubscribe,i=b.allowEmpty;return a.createElement("div",{className:"newsletter-box spacing-bottom-large"},a.createElement("div",{className:"text-medium spacing-bottom-small"},a.createElement("strong",null,d.aetBannerTitle)),f?a.createElement("button",{className:"button button-fill--brand button-padding-wider pull-right",disabled:e,onClick:function(){h&&h()}},"Subscribe"):null,a.createElement("div",{className:"spacing-bottom"},(d.aetBannerDescription||"").split("\n").map(function(b,c){return a.createElement("div",{key:c},b)})),a.createElement("div",{className:"align align--wrap"},f?null:a.createElement("form",{className:"align__item--grow",onSubmit:function(a){a.preventDefault();var b=a.target.elements.email.value.trim();(b||i)&&h&&h(b)}},a.createElement("div",{className:"newsletter-box__input-group"},a.createElement("span",{className:"icon icon-mail text-large newsletter-box__input-group__icon"}),a.createElement("input",{type:"email",name:"email",placeholder:c("Enter email address")})),a.createElement("input",{type:"submit",className:"button button-fill--brand button-padding-wider",disabled:e,value:c("Subscribe")})),a.createElement("a",{href:"#",className:"newsletter-box__hide publisher-anchor-color",onClick:function(a){a.preventDefault(),g&&g()}},c("Hide this message"))))};return d}),define("lounge/views/email-signup",["backbone","react","react-dom","stance","core/api","core/bus","core/templates/react/aet/EmailSignupComplete","core/templates/react/aet/EmailSignupForm","common/cached-storage"],function(a,b,c,d,e,f,g,h,i){"use strict";var j=0,k=2,l=new i("aet-dismiss");l.getAll();var m=a.View.extend({initialize:function(b){var c=b.forum,d=b.session;this.forum=c,this.session=d,this.model=new a.Model({dismissed:Boolean(l.getItem(this.forum.id)),loading:!1,signupComplete:!1}),this._isFirstRender=!0,this.handleCompleteDismiss=this.handleCompleteDismiss.bind(this),this.handleDismiss=this.handleDismiss.bind(this),this.handleSubscribe=this.handleSubscribe.bind(this),this.listenTo(this.model,"change",this.render),this.listenTo(this.session,"change",this.render)},getTrackingCopy:function(){return{title:this.forum.get("aetBannerTitle"),description_copy:this.forum.get("aetBannerDescription"),confirmation_copy:this.forum.get("aetBannerConfirmation")}},isLoggedIn:function(){return Boolean(this.session.user&&this.session.user.id)},handleDismiss:function(){return this.model.set("dismissed",!0),f.trigger("uiAction:clickEmailSubscriptionPromptDismiss",this.getTrackingCopy()),this.isLoggedIn()?Promise.resolve(e.call("aet/dismiss",{data:{forum:this.forum.id},method:"POST"})):(l.setItem(this.forum.id,!0),Promise.resolve())},handleCompleteDismiss:function(){this.model.set("dismissed",!0)},handleSubscribe:function(){var a=this,b=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;if(!this.model.get("loading"))return f.trigger("uiAction:clickEmailSubscriptionPromptSubscribe",this.getTrackingCopy()),this.model.set("loading",!0),Promise.resolve(b?e.call("aet/anonymousSubscribe",{data:{email:b,forum:this.forum.id},method:"POST"}):e.call("aet/subscribe",{data:{forum:this.forum.id},method:"POST"})).then(function(b){return a.model.set({loading:!1,signupComplete:!0}),b})["catch"](function(){a.model.set("loading",!1)})},reportView:function(){f.trigger("uiAction:viewEmailSubscriptionPrompt",this.getTrackingCopy())},render:function(){if(!this.forum.get("aetEnabled")||this.model.get("dismissed"))return this.$el.empty(),this;var a=this.session.shouldFetchSession()?this.session.get("aetBannerStatus"):j;switch(a){case j:case k:if(this.model.get("signupComplete")||a===k?c.render(b.createElement(g,{forum:this.forum.toJSON(),isVerified:Boolean(this.session.user&&this.session.user.get("isVerified")),onDismiss:this.handleCompleteDismiss}),this.el):c.render(b.createElement(h,{forum:this.forum.toJSON(),isLoading:this.model.get("loading"),isLoggedIn:this.isLoggedIn(),onDismiss:this.handleDismiss,onSubscribe:this.handleSubscribe}),this.el),this._isFirstRender){this._isFirstRender=!1,f.trigger("uiAction:loadEmailSubscriptionPrompt",this.getTrackingCopy());var e=d(this);e.isVisible()?this.reportView():this.listenToOnce(e,"enter",this.reportView)}break;default:this.$el.empty()}return this}});return m}),define("react-dom/server",["underscore"],function(a){"use strict";var b=function c(b){if(null===b)return"";if(a.isArray(b))return b.map(c).join("");if(a.isElement(b))return b.outerHTML;if(b&&b.nodeType===window.Node.DOCUMENT_FRAGMENT_NODE){var d=window.document.createElement("div");return d.appendChild(b),d.innerHTML}return a.escape(String(b))};return{renderToString:b,renderToStaticMarkup:b}}),define("core/utils/media/upload",["underscore","exports","core/api","core/models/Media","core/UniqueModel"],function(a,b,c,d,e){"use strict";b.uploadSupported=Boolean(window.FormData),b._extractFirstImageFile=function(b){return a.find(b,function(a){return a.type.match(/^image\//)})},b._uploadViaApi=function(a,b,d){return Promise.resolve(c.call(a,{data:b,contentType:!1,processData:!1,method:"POST",xhr:function(){var a=new window.XMLHttpRequest,b=d&&d.onProgress;return b&&a.upload.addEventListener("progress",function(a){a.total&&b(100*a.loaded/a.total)}),a}}))},b.UPLOAD_URL="https://uploads.services.disqus.com/api/3.0/media/create.json",b.uploadMediaUrl=function(c,f){var g,h=new window.FormData,i=b._extractFirstImageFile(c);return i?(h.append("upload",i),h.append("permanent",1),b._uploadViaApi(b.UPLOAD_URL,h,f).then(function(b){var c=b.response,f=a.first(a.values(c));if(!f||!f.ok)throw g=new Error("Upload failed"),g.code=f&&f["error-code"],g;return new e(d,{mediaType:d.MEDIA_TYPES.IMAGE_UPLOAD,url:f.url,thumbnailUrl:f.url})},function(a){if(a.responseJSON&&4===a.responseJSON.code)throw g=new Error("Upload failed"),g.code="not-authenticated",g;throw a})):(g=new Error("No image file to upload"),g.code="invalid-content-type",Promise.reject(g))}}),define("core/views/media/DragDropUploadView",["underscore","backbone","core/utils"],function(a,b,c){"use strict";var d=c.stopEventHandler,e=b.View.extend({events:{dragover:"_dragOn",dragenter:"_dragOn",dragleave:"_dragOff",dragexit:"_dragOff",drop:"_drop"},_dragOn:d(function(){this.trigger("uploader:dragEnter"),this._toggleDragPlaceholder(!0)}),_dragOff:d(function(){this._toggleDragPlaceholder(!1)}),_drop:d(function(a){this._toggleDragPlaceholder(!1);var b=a.originalEvent.dataTransfer.files;return b.length?void this.trigger("uploader:attachMedia",b):void this.trigger("uploader:dropError","No files")}),_toggleDragPlaceholder:a.throttle(function(a){a?this.trigger("uploader:showPlaceholder"):this.trigger("uploader:hidePlaceholder")},50)});return e}),define("core/templates/postMediaUploadButton",["handlebars","core/templates/handlebars.partials","core/extensions/handlebars.helpers"],function(a){return a.template({compiler:[7,">= 4.0.0"],main:function(a,b,c,d,e){return'\n
    \n\n\n'},useData:!0})}),define("core/views/media/UploadButtonView",["jquery","underscore","backbone","core/templates/postMediaUploadButton","core/utils"],function(a,b,c,d,e){"use strict";var f=e.stopEventHandler,g="input[type=file][data-role=media-upload]",h=c.View.extend({events:function(){var a={"click [data-action=attach]":"_attachMedia"};return a["change "+g]="_selectorChange",a}(),initialize:function(a){this.template=a&&a.template||this.generateImageUploadButton},generateImageUploadButton:function(){return d({imageUrl:"https://c.disquscdn.com/next/embed/assets/img/attach.03c320b14aa9c071da30c904d0a0827f.svg"})},render:function(){return this.$el.html(this.template()),this},_attachMedia:f(b.throttle(function(){this.$(g).click()},1e3,{trailing:!1})),_selectorChange:function(b){var c=b.target,d=c.files;d.length&&(this.trigger("uploader:attachMedia",d),a(c).replaceWith(c.cloneNode()))}});return h}),define("core/templates/postMediaUploadProgress",["handlebars","core/templates/handlebars.partials","core/extensions/handlebars.helpers"],function(a){return a.template({1:function(a,b,c,d,e){return'
  • \n
    \n
    \n
    \n
    \n
    \n
  • \n'; },compiler:[7,">= 4.0.0"],main:function(a,b,c,d,e){var f;return null!=(f=c.each.call(null!=b?b:{},null!=b?b.collection:b,{name:"each",hash:{},fn:a.program(1,e,0),inverse:a.noop,data:e}))?f:""},useData:!0})}),define("core/views/media/UploadsProgressSubView",["backbone","core/templates/postMediaUploadProgress"],function(a,b){"use strict";var c=a.View.extend({initialize:function(){this.collection=new a.Collection,this.listenTo(this.collection,"add remove change",this.render)},hasVisible:function(){return Boolean(this.collection.length)},render:function(){return this.$el.html(b({collection:this.collection.toJSON()})),this}});return c}),define("core/templates/postMediaUploadRich",["handlebars","core/templates/handlebars.partials","core/extensions/handlebars.helpers"],function(a){return a.template({1:function(a,b,c,d,e){var f;return a.escapeExpression(a.lambda(null!=(f=null!=b?b.media:b)?f.title:f,b))},3:function(a,b,c,d,e){return a.escapeExpression(c.gettext.call(null!=b?b:{},"Media attachment",{name:"gettext",hash:{},data:e}))},compiler:[7,">= 4.0.0"],main:function(a,b,c,d,e){var f,g=a.lambda,h=a.escapeExpression;return'
  • \n
    \n
    \n
    \n\n'+(null!=(f=c[\n\n
    \n
    \n
    \n
  • \n'},useData:!0})}),define("core/views/media/UploadsRichSubView",["underscore","backbone","core/models/Media","core/UniqueModel","core/utils","core/templates/postMediaUploadRich"],function(a,b,c,d,e,f){"use strict";var g=b.View.extend({initialize:function(){this._hasVisible=!1,this.collection=new b.Collection([],{model:c,comparator:"index"}),this.listenTo(this.collection,"add remove reset sort change:thumbnailUrl change:mediaType change:editsFinished",this.render),this.listenTo(this.collection,"change:index",a.bind(this.collection.sort,this.collection))},render:function(){return this.$el.empty(),this._hasVisible=!1,this.collection.each(function(b){b.get("thumbnailUrl")&&(a.contains(c.WEBPAGE_TYPES,b.get("mediaType"))||b.get("editsFinished")&&(this.$el.append(f({media:b.toJSON()})),this._hasVisible=!0))},this),this},hasVisible:function(){return this._hasVisible},addMedia:function(a,b){var e=d.get(c,a.url);if(e)e.set(a);else{if(!a.editsFinished)return;e=new d(c,a),e.fetch(b)}return this.collection.add(e),e},updateFromText:function(b,c,d){if(!b)return void this.collection.reset();var f=e.bleachFindUrls(b);f=a.uniq(f,!1,function(a){return a.url});var g={};a.each(f,function(e){g[e.url]=!0;var f=a.pick(e,"index","url"),h=e.index= 4.0.0"],main:function(a,b,c,d,e){return'
      \n
        \n
        \n'+a.escapeExpression(c.gettext.call(null!=b?b:{},\n
        \n'},useData:!0})}),define("core/views/media/UploadsView",["backbone","core/views/media/UploadsProgressSubView","core/views/media/UploadsRichSubView","core/templates/postMediaUploads"],function(a,b,c,d){"use strict";var e=a.View.extend({initialize:function(){this.richView=new c,this.rich=this.richView.collection,this.uploadProgressView=new b,this.uploadProgress=this.uploadProgressView.collection,this.listenTo(this.rich,"all",this._updateEmpty),this.listenTo(this.uploadProgress,"all",this._updateEmpty)},render:function(){return this.richView.$el.detach(),this.uploadProgressView.$el.detach(),this.$el.html(d()),this._updateEmpty(),this.richView.setElement(this.$("[data-role=media-rich-list]")[0]),this.uploadProgressView.setElement(this.$("[data-role=media-progress-list]")[0]),this},clear:function(){this.rich.reset(),this.uploadProgress.reset()},_updateEmpty:function(){this.richView.hasVisible()||this.uploadProgressView.hasVisible()?this.$el.removeClass("empty"):this.$el.addClass("empty")}});return e}),define("core/mixins/withUploadForm",["underscore","backbone","core/strings","core/utils","core/utils/media/upload","core/utils/storage","core/views/media/DragDropUploadView","core/views/media/UploadButtonView","core/views/media/UploadsView"],function(a,b,c,d,e,f,g,h,i){"use strict";var j=c.get,k=function(){a.defaults(this,k.bothProto,k.uploadsProto,k.previewsProto)},l={"invalid-image-file":j("Unfortunately your image upload failed. Please verify that the file is valid and in a supported format (JPEG, PNG, or GIF)."),"invalid-content-type":j("Unfortunately your image upload failed. Please verify that the file is in a supported format (JPEG, PNG, or GIF)."),"file-too-large":j("Unfortunately your image upload failed. Please verify that your image is under 5MB."),"not-authenticated":j("You must be logged in to upload an image.")},m=j("Unfortunately your image upload failed. Please verify that your image is in a supported format (JPEG, PNG, or GIF) and under 5MB. If you continue seeing this error, please try again later.");return k.previewsProto={initMediaPreviews:function(b,c){this.mediaUploadsView=new i({el:b[0]}),this.mediaUploadsView.render(),this.updateLiveMediaDebounced=a.partial(a.debounce(this.updateLiveMedia,500),c,!1),this.stopListening(c,"keychange"),this.stopListening(c,"paste"),this.listenTo(c,{keychange:this.updateLiveMediaDebounced,paste:function(b,d){d&&d.fake||a.defer(a.bind(this.updateLiveMedia,this,c,!0))}}),this.updateLiveMedia(c,!0)},clearMediaPreviews:function(){this.mediaUploadsView&&this.mediaUploadsView.clear()},updateLiveMedia:function(a,b){if(this.mediaUploadsView){var c=a.get(),d=a.offset();this.mediaUploadsView.richView.updateFromText(c,d,{isPasteEvent:b,forum:this.thread.forum.id})}}},k.uploadsProto={initMediaUploads:function(a,b,c){this.mediaDragDropView&&this.stopListening(this.mediaDragDropView),this.mediaDragDropView=new g({el:b[0]}),this.listenTo(this.mediaDragDropView,{"uploader:attachMedia":function(){f.set("usedDragDrop",1),this.handleAttachMedia.apply(this,arguments)},"uploader:dragEnter":function(){this.$el.addClass("expanded")},"uploader:showPlaceholder":function(){a.show()},"uploader:hidePlaceholder":function(){a.hide()},"uploader:dropError":function(){var a=j("Sorry we didn't catch that. Try again?");this.alert(a,{type:"error",isUploadError:!0})}}),this.mediaUploadButtonView&&this.stopListening(this.mediaUploadButtonView),this.mediaUploadButtonView=new h({el:c[0]}),this.listenTo(this.mediaUploadButtonView,{"uploader:attachMedia":this.handleUploadViaButton}),this.mediaUploadButtonView.render()},handleUploadViaButton:function(a){if(a&&f.isPersistent&&!f.get("usedDragDrop")&&!d.isMobileUserAgent()){var b=this.alert(j("Did you know you can drag and drop images too? Try it now!"));this.listenToOnce(b,"dismiss",function(){f.set("usedDragDrop",1)})}this.handleAttachMedia.apply(this,arguments)},handleAttachMedia:function(c,d){var f=this,g=new b.Model({remainingPerc:100});f.mediaUploadsView.uploadProgress.add(g),d=a.extend(d||{},{onProgress:function(a){g.set("remainingPerc",100-a)}});var h=function(){f.mediaUploadsView.uploadProgress.remove(g)};e.uploadMediaUrl(c,d).then(function(a){a.fetch({forum:f.thread.forum.id}),f.textarea.insertAtCursor(a.get("url")),f.updateLiveMedia(f.textarea,!0),f.dismissUploadError()})["catch"](function(a){var b;a&&a.code&&(b=l[a.code]),b||(b=m),f.alert(b,{type:"error",isUploadError:!0})}).then(h,h)},dismissUploadError:function(){this.dismissAlert(function(a){return a.options&&a.options.isUploadError})},uploadSupported:e.uploadSupported,isUploadInProgress:function(){return this.mediaUploadsView&&this.mediaUploadsView.uploadProgress.length}},k.bothProto={initMediaViews:function(a){(a.mediaembedEnabled||a.gifPickerEnabled)&&this.initMediaPreviews(this.$("[data-role=media-preview]"),a.textarea),a.allowUploads&&this.initMediaUploads(this.$("[data-role=drag-drop-placeholder]"),this.$("[data-role=textarea]"),this.$("[data-role=media-uploader]"))}},k}),define("core/editable",[],function(){"use strict";function a(a){return a.replace(e," ")}function b(c,d,e){var f,h,i,j,k="",l=[];for("string"!=typeof e&&(e="\n\n"),j=0;j-1)i=g,n=n.replace(j,"");else if(j.indexOf(n)>-1)return g;return i}},selectedTextNodeOffset:function(b){var e,f,g;if(window.getSelection){var h=window.getSelection();h&&h.anchorOffset&&(g=h.anchorOffset)}else if(b&&c.selection.createRange){var i=a(b.nodeValue);e=c.selection.createRange();var j=e.duplicate(),k=j.parentElement();for(f=0;0!==e.moveStart(d,-1)&&(0!==i.indexOf(a(e.text))&&k===e.parentElement());f++)j=e.duplicate(),k=j.parentElement();g=f}return isNaN(g)?0:g},offset:function(){function b(d,e){function f(a){i+=a[0];for(var b=1;b0&&h.moveStart(d,l+2),h.collapse()}for(;h.moveStart(d,-1)===-1&&0!==j.indexOf(a(h.text));)continue;for(;1===h.moveEnd(d,1)&&j!==a(h.text);)continue;return h.moveStart(d,e),h.moveEnd(d,-1*(f-e-h.text.length)),h.select(),h}}},i.normalizeSpace=a,i}),define("core/utils/html/nodeTypes",[],function(){"use strict";var a=function(a){return"p"===a.nodeName.toLowerCase()},b=function(a){return"div"===a.nodeName.toLowerCase()},c=function(a){return"#text"===a.nodeName.toLowerCase()},d=function(a){return"br"===a.nodeName.toLowerCase()},e=function(a){return"button"===a.nodeName.toLowerCase()},f=function(a){return"br"===a.nodeName.toLowerCase()||"#text"===a.nodeName.toLowerCase()&&"\n"===a.nodeValue},g=function(a){return"p"===a.nodeName.toLowerCase()||"div"===a.nodeName.toLowerCase()};return{isP:a,isDiv:b,isText:c,isBr:d,isButton:e,isNewline:f,isPorDiv:g}}),define("core/CappedStorage",["core/utils/storage"],function(a){"use strict";var b=function(a,b){this.max=a||10,this.queueKey=b||"__queue",this.getQueue()||this.setQueue([])};return b.prototype.set=function(b,c){var d=this.getQueue()||this.setQueue([]);d.length===this.max&&a.remove(d.shift()),a.set(b,c),d.push(b),this.setQueue(d)},b.prototype.get=function(b){return a.get(b)},b.prototype.remove=function(b){a.remove(b);for(var c=this.getQueue()||[],d=0;d":"\n",g=c.height(),h=function(){var d={};b.each(d,function(a,b){d[b]=c.css(b)});var e=a(c[0].cloneNode(!0));return e.removeAttr("id").removeAttr("name").css({visibility:"hidden",position:"absolute",top:"-9999px",left:"-9999px",contentEditable:!1}).css(d).attr("tabIndex","-1"),e.insertAfter(c[0]),e}(),i=null,j=function(){h[0].style.height=0,h[e](c[e]()+f),h.scrollTop(h[0].scrollHeight);var a=Math.max(h[0].scrollHeight,g)+parseInt(d.extraSpace,10);d.maxHeight&&(a>=d.maxHeight?(c.css("overflow",""),a=d.maxHeight):c.css("overflow","hidden")),i!==a&&(i=a,c.height(a),c.trigger&&c.trigger("resize"))},k=b.throttle(j,500),l=function(a){13===a.keyCode?j():k()};c.bind("keyup",l).bind("paste",j).css("overflow","hidden"),j()})},a}),define("core/views/TextareaView",["underscore","jquery","backbone","core/utils","core/utils/html/nodeTypes","core/CappedStorage","core/extensions/jquery.autoresize"],function(a,b,c,d,e,f){"use strict";var g=c.View.extend({events:{"keydown [data-role=editable]":"handleKeyDown","keyup [data-role=editable]":"handleKeyUp","paste [data-role=editable]":"handlePaste","focusin [data-role=editable]":"handleFocusIn","blur [data-role=editable]":"handleBlur"},initialize:function(b){b=b||{},this.storageKey=b.storageKey,this.value=b.value||this.getDraft()[0],this.history=[this.value],this.historyPosition=0,this.placeholder=b.placeholder,this.selectionIndices={start:0,end:0,endElemInd:0,endElemSelectionInd:0,startElemInd:0,startElemSelectionInd:0},this.inputFixed=!1,this.listenTo(this,"keychange",a.debounce(this.saveDraft,this.constructor.SAVE_DRAFT_INTERVAL))},render:function(){return this.$input=this.createInput(),this.set(this.value),this.$el.append(this.$input),this.$input.autoresize({maxHeight:this.constructor.MAX_TEXTAREA_HEIGHT}),this},createInput:function(){return b("