var __extends,NotificationCountCacheDataSource,NotificationCountDistributor,NotificationCountEventDataSource,NotificationCountManager,NotificationCountPollingDataSource,NotificationCountViewModel,Bnet;(function(n){var i=function(){function n(n,t){this.modalId=n;this.$content=t;this.includeCloseButton=!0;this.preventBodyScroll=!0;this.escKeyClosesModal=!0;this.parentSelector="body";this.modalClass="";this.beforeOpenCallback=function(){};this.afterOpenCallback=function(){};this.beforeCloseCallback=function(){};this.afterCloseCallback=function(){};this.isInitialized=!1;this.transitionDuration=0;this.modalOpenHtmlClass="modal-open"}return Object.defineProperty(n.prototype,"modalElement",{get:function(){return this.$modal},enumerable:!0,configurable:!0}),n.prototype.initialize=function(){this.buildModal();this.populateContent(this.$content);this.onModalCreated();this.addListeners();this.isInitialized=!0},n.prototype.onModalCreated=function(){},n.prototype.addListeners=function(){var n=this;this.$modalContainer.on("click",function(t){var i=$(t.target);i.closest(".modal").length||n.close()});this.$modal.find(".button-close").on("click",function(){n.close()});this.$modal.find(".modal-content").on("touchmove",function(t){n.preventTouchOverscroll(t)});$(document).on("keydown",function(t){n.onKeyDown(t.which)})},n.prototype.open=function(){var n=this;this.isInitialized||this.initialize();t.calculateScrollbarWidth();this.beforeOpenCallback();$(this.parentSelector).append(this.$modalContainer);this.setHtmlClass(!0);this.preventBodyScroll&&this.stopBodyFromScrolling();setTimeout(function(){n.$modalContainer.addClass("open")},1e3/60);setTimeout(function(){n.afterOpenCallback()},this.transitionDuration)},n.prototype.close=function(){var n=this;if(this.$modalContainer.length===0)throw"Modal has not been initialized!";this.determineTransitionDuration();this.beforeCloseCallback();this.$modalContainer.removeClass("open");this.setHtmlClass(!1);setTimeout(function(){n.$modalContainer.remove();n.afterCloseCallback()},this.transitionDuration)},n.prototype.populateContent=function(n){var t,i;n instanceof jQuery?(i=n,i.is("script[type=text/html]")?(t=i.html(),this.$content=$(t)):this.$content=i):(t=$.trim(n),t.charAt(0)!=="<"&&(t="<div>"+t+"<\/div>"),this.$content=$(t));this.$modal&&this.$modal.find(".modal-content").html(this.$content)},n.prototype.addHtmlAfterContent=function(n){var t=this.$modalContainer.find(".modal-after-content");t.html(n)},n.prototype.buildModal=function(){var n=this.includeCloseButton?'<div class="button-close"><\/div>':"",t='\n\t\t\t\t<div class="modal-container flex '+this.modalClass+'" id="modal-'+this.modalId+'">\n\t\t\t\t\t<div class="modal">\n\t\t\t\t\t\t'+n+'\n\t\t\t\t\t\t<div class="modal-content"><\/div>\n\t\t\t\t\t\t<div class="modal-after-content"><\/div>\n\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t';this.$modalContainer=$(t);this.$modal=this.$modalContainer.find(".modal")},n.prototype.setHtmlClass=function(n){var t=this;n?$("html").addClass(this.modalOpenHtmlClass):setTimeout(function(){$("html").removeClass(t.modalOpenHtmlClass)},this.transitionDuration/2)},n.prototype.onKeyDown=function(n){n===27&&this.escKeyClosesModal&&this.close()},n.prototype.determineTransitionDuration=function(){var i=this.$modal.css("transition-duration"),t=i.match(/[0-9\.]+/g),n;t&&(n=0,t.map(function(t){var i=parseFloat(t);n=i>n?i:n}),this.transitionDuration=n*1e3)},n.prototype.stopBodyFromScrolling=function(){if(!$("#modal-open-scrollbar-offset").length){var n=t.calculateScrollbarWidth();Modernizr.mobile||$("head").append("\n\t\t\t\t\t<style id='modal-open-scrollbar-offset'>\n\t\t\t\t\t\thtml."+this.modalOpenHtmlClass+" body { overflow: hidden; }\n\t\t\t\t\t\thtml."+this.modalOpenHtmlClass+" header { padding-right: "+n+"; width: calc(100% - "+n+"); }\n\t\t\t\t\t\thtml."+this.modalOpenHtmlClass+" #content { padding-right: "+n+"; box-sizing: border-box; }\n\t\t\t\t\t<\/style>\n\t\t\t\t")}},n.prototype.preventTouchOverscroll=function(n){var t=n.currentTarget;t.scrollTop===0?t.scrollTop=1:t.scrollHeight===t.scrollTop+t.offsetHeight&&(t.scrollTop-=1);t.offsetHeight===t.scrollHeight&&n.preventDefault()},n}(),t;n.Modal=i,function(n){function t(){var n=$('<div class="modal-measure-scrollbar"/>').prependTo($("body")),t=$('<div class="inner"/>').appendTo(n);return n.width()-t.width()+"px"}n.calculateScrollbarWidth=t}(t||(t={}))})(Bnet||(Bnet={})),function(n){var t;(function(t){var i=function(){function t(){}return t.prototype.initialize=function(){this.addEventMuxSubscriptions();this.toastClient=new n.ToastMessages.Client},t.prototype.addEventMuxSubscriptions=function(){var t=this;n.EventMux.subscribe(Globals.RealTimeEventType.ConversationChanged,function(n){if(n.conversationType!==Globals.EventConversationType.Group){var i=$("#mail_conversation"),r=viewModels.loggedInUserModel().pmToastsEnabled(),u=$(".mail .dropTrigger").parent().hasClass("opened"),f=u&&!i.hasClass("hide"),e=i.attr("data-conversationId")===n.conversationId;!r||e&&f||t.getUserForToast(n)}})},t.prototype.showToast=function(t,i,r){var u='<a href= "#" data-messageid="'+t+'" class="btn_gotomessage">\n\t\t\t\t\t\t\t<span class="avatar" style="background-image:url('+i.profilePicturePath+')"><\/span>\n\t\t\t\t\t\t\t<strong>'+Localizer.Format(Localizer.Messages.displaynamesays,{displayName:i.displayName})+"<\/strong>\n\t\t\t\t\t\t\t<p>"+r+"<\/p>\n\t\t\t\t\t\t<\/a>";this.toastClient.show(n.ToastMessages.ToastMessageType.Info,u);this.toastClient.maxConcurrentMessages=2},t.prototype.getUserForToast=function(n){var t=this;n.senderMembershipId!==viewModels.loggedInUserModel().user.membershipId()&&bungieNetPlatform.userService.GetBungieNetUserById(n.senderMembershipId,function(i){t.showToast(n.conversationId,i,n.preview)},function(){})},t}();t.MessageUpdate=i})(t=n.Site||(n.Site={}))}(Bnet||(Bnet={})),function(n){var t;(function(t){var r=function(){function t(){this.navItemCountDefault=7;this.initTime=new Date;this.delayHoverOnPageLoad=1200;this.normalDelay=300;this.userMenuIsOpen=!1;this.mobileClickEventType="ontouchstart"in window?"touchend":"click"}return t.prototype.initialize=function(){this.search=new i;this.addListeners();this.checkAuthentication();n.Reactive.mobile.test()&&this.scrollHeader()},t.prototype.addListeners=function(){var n=this;$(".small-menu").on("click",function(){$(document).off(n.mobileClickEventType+".closeMenu");n.openMobileMenu()});$("#nav-items .nav-bucket .expandIcon").each(function(t,i){var r=$(i),u=r.parents(".nav-bucket");n.menuExpand(r,u)})},t.prototype.openMobileMenu=function(){var n=this,t=$("html").hasClass("nav-open");if(t)$("html").removeClass("nav-open");else{$("html").addClass("nav-open");$(document).on(this.mobileClickEventType+".closeMenu",function(t){var i=$(t.target);i.is(".small-menu")||i.closest("#nav-items").length!==0||($(document).off(n.mobileClickEventType+".closeMenu"),t.preventDefault(),t.stopImmediatePropagation(),$("#nav-items .nav-bucket").removeClass("open"),$("html").hasClass("nav-open")&&$("html").removeClass("nav-open"))})}},t.prototype.menuExpand=function(n,t){n.on(this.mobileClickEventType,function(n){n.stopImmediatePropagation();n.preventDefault();Modernizr.mq("all and (max-width: 0px)")||t.hasClass("open")?t.removeClass("open"):($("#nav-items .nav-bucket").removeClass("open"),t.addClass("open"))})},t.prototype.checkAuthentication=function(){Utility.IsAuthenticated()?($("#btn_signOut").attr("href","/"+Localizer.CurrentCultureName+"/User/SignOut?bru="+encodeURIComponent(window.location.pathname+window.location.search+window.location.hash)),$(".Nav_Top .signedIn").show(),$(".Nav_Top .signedOut").hide()):($(".Nav_Top .signedIn").hide(),$(".Nav_Top .signedOut").show())},t.prototype.scrollHeader=function(){var n=0;$(window).on("scroll",function(){var t=$(this).scrollTop(),i=t>n,r=i&&t>100;$("html").toggleClass("scroll-hidden",r);n=t})},t}(),i;t.Nav=r;i=function(){function n(){this.$searchWrapper=$(".nav_top_search");this.$input=$("#text_search");this.$searchButton=$(".nav_top_search .btn_search");this.addListeners()}return n.prototype.addListeners=function(){var n=this;$("#form_search .btn_search").on("click",function(t){t.preventDefault();var i=$(".nav_top_search").hasClass("active");n.activateSearch(i)});$("#btn_search").on("click",function(){var t=$("#text_search").val();n.doSearch(t)});this.$input.on({focus:function(t){t.preventDefault();n.openSearchBox()},keyup:function(t){n.onKeyUp(t.which)}})},n.prototype.openSearchBox=function(){this.$searchWrapper.addClass("open")},n.prototype.onKeyUp=function(n){var t,i,r;n===13&&(t=encodeURIComponent(this.$input.val()),i="?all="+t,location.href=PageUrls.searchPage+i);r=$(this).val()!=="";r?this.$searchButton.addClass("ready"):this.$searchButton.removeClass("ready")},n.prototype.activateSearch=function(n){$(".nav_top_search").toggleClass("active",!n);$(".nav_links").toggleClass("searchmove",!n);n?$("#text_search").blur():$("#text_search").focus()},n.prototype.doSearch=function(n){var t=encodeURIComponent(n),i="?all="+t;location.href=PageUrls.searchPage+i},n}()})(t=n.Site||(n.Site={}))}(Bnet||(Bnet={})),function(n){var t;(function(t){var r=function(){function r(n,t){t===void 0&&(t=function(){});this.ajaxSectionRegex=n;this.urlParsedCallback=t;this.preventAjaxMode=!1;this.allowSamePathname=!1;this.scrollToTopOnAjaxLoad=!0;this.loadContent=!0;this.loadOutsideContent=!0;this.loadSubNav=!0;this.loadMainNavItems=!0;this.loadNavTop=!0;this.loadSidebar=!0;this.useCache=!0;this.isLoadingPage=!1;this.appendCacheQuerystring="ajax=true";this.url=""+window.location.pathname+window.location.search;this.isSamePathname=!1;this.lastParsedUrl=window.location.pathname+window.location.search+window.location.hash;this.parseUrlTimer=null;this.forceRedirectUrlRegex=/\/Companion/gi;this.disableUiDuringLoad=!1;this.unbindAll();this.normalizeAjaxSectionRegex()}return r.prototype.initialize=function(){this.unbindAll();this.handleRedirects();this.addListeners()},r.prototype.unbindAll=function(){$("*").unbind(".pagecontrol");$(document).unbind(".pagecontrol");$(window).unbind(".pagecontrol")},r.prototype.addListeners=function(){var n=this;$(document).on("click.pagecontrol","a:not(.exempt)[href]",function(t){return n.handleLinkClicks(t)});$(".sign-in-triggers a").on("click",function(t){n.handleSigninLinks(t)});$(window).on({"popstate.pagecontrol statechange.pagecontrol":function(t){n.setHash();n.urlParserThrottle(t)},"hashchange.pagecontrol":function(t){n.setHash();n.urlParserThrottle(t)}})},r.prototype.stateChangeString=function(t,i,r){r===void 0&&(r=!0);var u=n.Utilities.HtmlElement.urlToAnchorElement(t);this.stateChange(u,i,r)},r.prototype.stateChange=function(t,i,r){var u,e,f;r===void 0&&(r=!0);try{if(t===undefined||t===null)throw"ERROR: No link specified. Cannot proceed with statechange";u=n.Utilities.HtmlElement.urlToAnchorElement(t);e=u.pathname;u.pathname.charAt(0)!=="/"&&(e="/"+e);f=""+e+u.search+u.hash;i?history.replaceState({url:f},null,f):history.pushState({url:f},null,f);r&&$(window).trigger("statechange.pagecontrol")}catch(o){n.log(o)}},r.prototype.processRedirect=function(t){if(Modernizr.localstorage&&window.history&&document.all){var i=n.Utilities.LocalStorage.getItem("history").toLowerCase()===t.toLowerCase();i?history.go(-1):window.location.href=t}else this.stateChangeString(t,!0)},r.prototype.setHash=function(){Hash=Utility.parseHash(window.location.hash);viewModels.hash(Hash)},r.prototype.normalizeAjaxSectionRegex=function(){if(!this.ajaxSectionRegex){this.ajaxSectionRegex=new RegExp("NO AJAX SECTION REGEX DEFINED");return}var n=this.ajaxSectionRegex.source,t=n.replace("{locale}",Localizer.CurrentCultureName);this.ajaxSectionRegex=new RegExp(t)},r.prototype.handleLinkClicks=function(n){var t,r,u;return Modernizr.history?(t=n.currentTarget,r=Utility.urlToLinkObject(t.href),this.isLoadingPage)?!0:(u=i.doesLinkQualifyForAjax(r,n,this.ajaxSectionRegex),!u)?!0:(n.which!==2&&(n.preventDefault(),this.isLoadingPage=!0,t.search.indexOf("?c=")!==-1||t.search.indexOf("&c=")!==-1?window.location.reload():this.stateChange(r,!1)),!1):!0},r.prototype.handleSigninLinks=function(n){var f,u,r;n.preventDefault();f=$(n.currentTarget);u="loginui";location.protocol==="https:"&&(u="ssl_loginui");var i=f.attr("href"),t=window.location.pathname,e=window.location.search;window.location.pathname.toLowerCase().indexOf("/forum/topics/")>-1&&(r=[],$("#content_topics .searchedTag").length&&$("#content_topics .searchedTag").each(function(n,t){var i=$(t).find("[data-tag]").attr("data-tag").replace("%23","").replace("#","");r.push(i)}),r.length&&(t=t.replace(/(forum\/topics)([\w\/%23# ])+/gi,"$1"),t=t.replace(/(forum\/topics)([\w\/%20])+/gi,"$1"),e="?tg="+r.join(" ")),i.match(/(\/user\/signin\/\w+\?bru=)([%\w]+)/gi)&&(i=i.replace(/(\/user\/signin\/\w+\?bru=)([%\w]+)/gi,"$1")+encodeURIComponent(t+e+window.location.hash)));window.open(i,u,"height=560, width=790, left=550, top=200, menubar=no, location=no, resizable=no, scrollbars=yes, status=no, toolbar=no",!1)},r.prototype.urlParserThrottle=function(t){var i=this;if(this.parseUrlTimer!==null){n.log("Attempted to run URL parse while one was already running");return}this.parseUrlTimer=setTimeout(function(){i.parseUrlTimer=null},100);viewModels.currentUrl(window.location);this.parseUrlAndLoad(t)},r.prototype.parseUrlAndLoad=function(n){var u=this.url,t,i,r;this.url=window.location.pathname+window.location.search;t=Utility.urlToLinkObject(u);i=Utility.urlToLinkObject(this.url);this.isSamePathname=t.pathname.toLowerCase()===i.pathname.toLowerCase();r=this.lastParsedUrl===window.location.pathname+window.location.search+window.location.hash;r?this.isLoadingPage=!1:window.location.search.match("_modal")||this.preventAjaxMode?this.isLoadingPage=!1:this.loadUrl(n);Hash=Utility.parseHash(window.location.hash);this.urlParsedCallback()},r.prototype.reloadPage=function(){this.isSamePathname=!1;this.url=this.lastParsedUrl;this.loadUrl()},r.prototype.loadUrl=function(n){var t=this,i,r;(!this.isSamePathname||this.allowSamePathname)&&(this.lastParsedUrl=window.location.pathname+window.location.search,setTimeout(function(){$("body").addClass("preload")},300),this.startLoading(),this.disableUiDuringLoad&&$("html").addClass("uiDisabled"),i=window.location.search.length?"&":"?",r=this.url+i+this.appendCacheQuerystring,$.ajax({url:r,cache:this.useCache,type:"GET",data:null,dataType:"html",success:function(i,r,u){t.processUrl(u);t.onOldPageDestroyed(n);t.replaceContent(i);t.setViewModels();t.onNewPageCreated()},error:function(){history.replaceState({},null,"#");location.replace("")},statusCode:{302:function(){alert("302")}}}))},r.prototype.processUrl=function(t){var r=t.getResponseHeader("X-SelfUrl"),e=t.getResponseHeader("X-Error-Code"),i;if(e&&r){window.location.href=r;return}n.trackPageview(r);var f=new RegExp("(\\?|\\&)"+this.appendCacheQuerystring,"gi"),o=this.url.replace(f,""),s=r.replace(f,""),u=Utility.urlToLinkObject(o),h=Utility.urlToLinkObject(s);if(r.match(this.forceRedirectUrlRegex)){window.location.href=r;return}r!==u.origin+u.pathname+u.search&&(i=h.href+u.hash,i.substr(0,4)!=="http"&&(i+=i.substr(0,1)==="/"?"":"/"),this.ajaxSectionRegex&&!i.match(this.ajaxSectionRegex)&&(window.location.href=i),history.replaceState({},"",i),this.url=i,this.lastParsedUrl=i);successRedirect=encodeURIComponent(this.lastParsedUrl)},r.prototype.replaceContent=function(n){var i=$(n),u=n.match(/<body.*class=['"](.*)['"].*>/),f,r,e;u&&(f=u[1],$("body").attr("class",f));r=n.match(/<title>(.*)<\/title>/);r&&(e=$("<div/>").html(r[1]).text(),$("title").text(e));this.loadContent&&this.replaceElementContent("#content",i);this.loadOutsideContent&&this.replaceElementContent("#outsideContent",i);this.loadSubNav&&this.replaceElementContent(".Sub_Nav",i);this.loadMainNavItems&&this.replaceElementContent("#nav-items",i);!Utility.IsAuthenticated()&&this.loadNavTop&&this.replaceElementContent(".Nav_Top",i,!0,function(){t.nav.initialize()});this.loadSidebar&&this.replaceElementContent("#sidebar",i,!1,function(n){$("body").toggleClass("NoSidebar",!n)});$("#content").removeClass("hide").css("visibility","visible").siblings(".page").addClass("hide")},r.prototype.replaceElementContent=function(n,t,i,r){var e;i===void 0&&(i=!0);r===void 0&&(r=function(){});var f=$(n),u=t.find(n).html(),o=t.find(n).attr("class");i?f.html(u?u:""):f.html(u);f.attr("class",o);e=u?!0:!1;r(e)},r.prototype.setViewModels=function(){var i=[$("#content"),$(".Sub_Nav")],r,u,n,t;for(this.loadSidebar&&i.push($("#sidebar")),r=ko.utils.domNodeDisposal.cleanExternalData,ko.utils.domNodeDisposal.cleanExternalData=function(){},u=i.length,n=0;n<u;n++)t=i[n],typeof t[0]!="undefined"&&(ko.cleanNode(t[0]),ko.applyBindings(viewModels,t[0]));ko.utils.domNodeDisposal.cleanExternalData=r},r.prototype.onNewPageCreated=function(){this.unbindAll();$(document).trigger("newPageCreated");$(window).trigger("load");setTimeout(function(){$("body").removeClass("preload")},200);$("#mainContent").destinyLoader("exists")||$("#mainContent").destinyLoader();this.initialize()},r.prototype.startLoading=function(){$("#mainContent").destinyLoader({destroyOnStop:!1,startOnInit:!0})},r.prototype.stopLoading=function(){$("#mainContent").destinyLoader("stop")},r.prototype.onOldPageDestroyed=function(n){$(document).trigger("oldPageDestroyed");this.stopLoading();this.isLoadingPage=!1;this.disableUiDuringLoad&&$("html").removeClass("uiDisabled");this.scrollToTopOnAjaxLoad&&(n&&n.type==="popstate"||$(window).scrollTop(0))},r.prototype.handleRedirects=function(){if(Modernizr.hashchange&&window.location.search.indexOf("nhc")===-1)if(window.location.hash.indexOf("?lc=")>-1){if(window.location.hash.indexOf("?lc=")>-1){var t=window.location.href.replace("?lc=","&lc=");n.Site.pageController.processRedirect(t)}}else{$(window).on("beforeunload",function(){try{localStorage.setItem("history",window.location.href)}catch(e){}});$(window).on("hashchange newPageCreated",function(){$("html").removeClass("uiDisabled");$("#btn_signOut").attr("href","/"+Localizer.CurrentCultureName+"/User/SignOut?bru="+encodeURIComponent(window.location.pathname+window.location.search+window.location.hash))})}},r}(),i;t.PageController=r,function(n){function t(n,t){if(n.href===window.location.href)return t.preventDefault(),!0}function i(n){return n.pathname===window.location.pathname&&(n.href.match("#")&&n.hash===window.location.hash||n.href.match("\\?")&&n.search===window.location.search)?!0:!1}function r(n){var t=n.host.match(":")?n.host.split(":")[0]:n.host,i=window.location.host.match(":")?window.location.host.split(":")[0]:window.location.host;return t!==i?!0:!1}function u(n){return n.pathname===window.location.pathname&&typeof n.hash!="undefined"&&n.hash!==""?!0:!1}function f(n,t){return typeof t=="undefined"||!n.href.match(t)?!1:!0}function e(n,e,o){return Modernizr.ie?!1:f(n,o)?t(n,e)?!1:i(n)?!1:r(n)?!1:u(n)?!1:!0:!1}n.doesLinkQualifyForAjax=e}(i||(i={}))})(t=n.Site||(n.Site={}))}(Bnet||(Bnet={})),function(n){var t;(function(t){var i=function(){function t(){this.eventName="recruitThreadUpdated"}return t.prototype.initialize=function(){this.addEventMuxSubscription();this.addEventListeners()},t.prototype.addEventMuxSubscription=function(){var t=this;n.EventMux.subscribe(Globals.RealTimeEventType.RecruitThreadUpdate,function(n){var i={recruitThreadUpdate:{conversationId:n.conversationId,topicId:n.topicId,isRemoved:n.isRemoved,membershipId:n.targetMembershipId}};$(document).trigger(t.eventName,i)})},t.prototype.addEventListeners=function(){$(document).on(this.eventName,function(t,i){var r=i.recruitThreadUpdate,u;typeof r.conversationId!="undefined"&&r.conversationId!==null&&r.conversationId!=="0"&&(u=new n.ToastMessages.Client,u.show(n.ToastMessages.ToastMessageType.Info,Localizer.Format(Localizer.Messages.yourfireteamisreadyadata,{conversationId:r.conversationId})))})},t}();t.RecruitThreadUpdate=i})(t=n.Site||(n.Site={}))}(Bnet||(Bnet={})),function(n){var t;(function(t){function r(){u();t.pageController=new t.PageController(window.ajaxSectionRegex);t.pageController.initialize();ServerVars.MobileWebView||(t.eventMux=new n.EventMux.Instance,t.eventMux.initialize());t.messageUpdate=new t.MessageUpdate;t.messageUpdate.initialize();t.recruitThreadUpdate=new t.RecruitThreadUpdate;t.recruitThreadUpdate.initialize();t.streamingAlerts=new t.StreamingAlerts;t.streamingAlerts.initialize();t.nav=new t.Nav;t.nav.initialize();t.localeSelector=new t.LocaleSelector(Localizer.CurrentCultureName,Localizer.CurrentBrowserCultureName);t.localeSelector.initialize();t.Forms.initialize();i();initializeTopNavMessaging()}function u(){$(window).on("load",function(){return f()})}function f(){$("body").addClass("loaded");Modernizr.generatedcontent||$(".bg_top").append("<span>You are using an unsupported browser, your experience may be less than optimal<\/span>")}function i(){$.easing.BnetEasing=function(n){return n<.5?4*n*n*n:(n-1)*(2*n-2)*(2*n-2)+1};n.Utilities.HtmlElement.placeholderLocFix()}t.initialize=r;t.customFixes=i;var e=function(){function n(){}return n.isWebViewMode=$("html").hasClass("WebViewMode"),n}();t.Flags=e;$(document).ready(function(){ko.applyBindings(viewModels);t.initialize()})})(t=n.Site||(n.Site={}))}(Bnet||(Bnet={}));__extends=this&&this.__extends||function(n,t){function r(){this.constructor=n}for(var i in t)t.hasOwnProperty(i)&&(n[i]=t[i]);n.prototype=t===null?Object.create(t):(r.prototype=t.prototype,new r)},function(n){var t;(function(t){var u=function(){function u(){this.isHomepage=$("body").hasClass("Homepage");this.isPubPage=location.href.indexOf(Localizer.CurrentCultureName+"/pub/")!==-1;this.modalSeenStorageKey="StreamingAlerts.HomepageModalSeenTime";this.dontShowModalTimeLimit=864e5;this.modalAutoOpenDelay=1.5*1e3}return Object.defineProperty(u.prototype,"isMobile",{get:function(){return Modernizr.mobile||n.Reactive.mobile.test()},enumerable:!0,configurable:!0}),u.prototype.initialize=function(){t.Flags.isWebViewMode||this.isPubPage||(this.addListeners(),this.getStreamingAlerts())},u.prototype.addListeners=function(){var n=this;$(document).on("click","#streaming-alerts",function(){i.trackUsabilityEvent("StreamingAlertOpened","Opened Via Click");n.isMobile?window.location.href=n.getChannelLink(!1):n.openTwitchModal({muted:!1,openedAutomatically:!1})})},u.prototype.getChannelLink=function(n){if(!this.streamingAlert)return"";var t=n?"&muted":"&!muted";return location.protocol+"//player.twitch.tv/?channel="+this.streamingAlert.StreamInfo.ChannelName+t+"&volume=0.33"},u.prototype.getStreamingAlerts=function(){var n=this;bungieNetPlatform.coreService.GetGlobalAlerts(!0,function(t){n.processAlerts(t)},function(){})},u.prototype.processAlerts=function(n){for(var i,t=0;t<n.length;t++)if(i=n[t],i.AlertType===Globals.GlobalAlertType.StreamingAlert){this.streamingAlert=i;this.onStreamingAlertExists();continue}},u.prototype.onStreamingAlertExists=function(){var t=this,n=this.checkOrSetHasSeenModal(),i=!this.isHomepage||!n;r.show(i);n&&this.isHomepage&&!this.isMobile&&setTimeout(function(){t.openTwitchModal({muted:!0,openedAutomatically:!0})},this.modalAutoOpenDelay)},u.prototype.openTwitchModal=function(n){this.streamingAlertModal=new f(this);this.streamingAlertModal.open(n)},u.prototype.checkOrSetHasSeenModal=function(){var t=!0,i=n.Utilities.LocalStorage.getItem(this.modalSeenStorageKey),r;return i&&(r=parseInt(i,10),u.timeLimitExceeded(this.dontShowModalTimeLimit,r)||(t=!1)),t&&n.Utilities.LocalStorage.setItem(this.modalSeenStorageKey,Date.now().toString()),t},u.timeLimitExceeded=function(n,t){var i=Date.now(),r=i-t;return r>n},u}(),f,r,i;t.StreamingAlerts=u;f=function(n){function t(t){n.call(this,"streaming-alert",null);this.streamingAlerts=t;this.maximumModalTrackingTimeout=3e5}return __extends(t,n),t.prototype.addListeners=function(){var t=this;n.prototype.addListeners.call(this);$(document).one("oldPageDestroyed",function(){clearTimeout(t.maximumModalTrackingTimer)});$(window).one("beforeUnload",function(){clearTimeout(t.maximumModalTrackingTimer)})},t.prototype.trackAutoModalTimer=function(n){var r=Date.now(),t=n.openedAutomatically?"auto-open":"manual-open";this.afterCloseCallback=function(){var n=(Date.now()-r)/1e3,u;u=n<5?"< 5 seconds":n>=5&&n<20?"5 - 20 seconds":n>=20&&n<60?"20 - 60 seconds":n>60&&n<300?"60 - 300 seconds":"> 300 seconds";i.trackUsabilityEvent("StreamingModalClosed","Modal ("+t+") open time: "+u)};this.maximumModalTrackingTimer=setTimeout(function(){i.trackUsabilityEvent("StreamingModalClosed","Modal ("+t+") open time: > 300 seconds")},this.maximumModalTrackingTimeout)},t.prototype.open=function(t){if(t){var r='\n\t\t\t\t<iframe src="'+this.streamingAlerts.getChannelLink(t.muted)+'" frameborder="0" scrolling="no" height="100%" width="100%" allowfullscreen><\/iframe>\n\t\t\t';this.populateContent(r);this.trackAutoModalTimer(t);i.trackUsabilityEvent("StreamingAlertOpened",t.openedAutomatically?"Opened automatically":"Opened manually");n.prototype.open.call(this)}},t}(n.Modal),function(t){function o(n){n===void 0&&(n=!0);var t=s(),u=h(n),i=u?"streaming-alerts-transition":"";$("html").addClass("streaming-alerts-active "+i);t.addClass(i);setTimeout(function(){t.addClass("on")},r);setTimeout(function(){t.addClass("done")},f)}function s(){var t=$("#streaming-alerts-template").html(),n=$(t);return $("header").append(n),n}function h(n){var t=!0;return n&&(t=c(),t||(r=f=0)),t&&n}function c(){var t=!0,r=n.Utilities.SessionStorage.getItem(i),f;return r&&(f=parseInt(r,10),u.timeLimitExceeded(e,f)||(t=!1)),t&&n.Utilities.SessionStorage.setItem(i,Date.now().toString()),t}var i="StreamingAlerts.LastAnimatedTime",e=18e5,r=500,f=2500;t.show=o}(r||(r={}));i=function(){function t(){}return t.trackUsabilityEvent=function(t,i,r){r=r||null;n.trackEvent("Usability",t+"_StreamingAlerts",i,r)},t}()})(t=n.Site||(n.Site={}))}(Bnet||(Bnet={})),function(n){var t;(function(t){t.logging=!0;t.instance=null;t.lastSeqStored=0;t.storageKeys={OverlordTabId:"eventMux.overlordTabId",OverlordTabProofPoll:"eventMux.overlordTabProofPoll",StoredResponse:"eventMux.storedResponse",LastSeqStored:"eventMux.lastStoredSeq",TabId:"eventMux.tabId",UnloadFlag:"eventMux.unloadFlag",IsActive:"eventMux.isActive"};t.storageValues={OverlordTabReplaced:0};var i=function(){function n(){return(this.isAuthed=!1,t.instance!=null)?(t.warn("Cannot instantiate - Another instance already exists"),t.instance):Modernizr.localstorage?(t.instance=this,this):(t.error("Cannot instantiate - localStorage is not available!"),null)}return n.prototype.initialize=function(){t.logging&&t.bindLogging();t.storage=new t.Storage;this.isAuthed=t.isAuthed();this.tabManager=new t.TabManager;this.subManager=new t.SubManager},n.prototype.addSubscription=function(n){this.subManager.addSubscription(n)},n.prototype.isActive=function(){return this.tabManager.isActive()},n.prototype.isCurrentTabOverlord=function(){return this.tabManager.isCurrentTabOverlord()},n}();t.Instance=i;t.bindLogging=function(){Function.prototype.bind&&(t.log=Function.prototype.bind.call(n.base_log,console,"EventMux: "),t.warn=Function.prototype.bind.call(n.base_warn,console,"EventMux: "),t.error=Function.prototype.bind.call(n.base_error,console,"EventMux: "))};t.subscribe=function(n,i){if(t.instance==null)throw"EventMux not instantiated - cannot subscribe";var r=new t.Subscription(n,i);return t.instance.addSubscription(r),r};t.isAuthed=function(){var n=Cookies.Get(ServerVars.WebMembershipCookieName);return n!=null&&parseInt(n)>0};t.isActive=function(){return t.instance!=null?t.instance.isActive():!1};t.isCurrentTabOverlord=function(){return t.instance.isCurrentTabOverlord()};t.log=function(){};t.warn=function(){};t.error=function(){};t.disableLogging=function(){t.log=function(){};t.warn=function(){};t.error=function(){}}})(t=n.EventMux||(n.EventMux={}))}(Bnet||(Bnet={})),function(n){var t;(function(t){var i=function(){function i(n,t){this.tabId=n;this.tabReplacedCallback=t;this.requestTimeout=ServerVars.RealTimeHeartBeat||90;this.ackNext=0;this.failures=0;this.getRequested=!1;this.isReplaced=!1;this.errorTimeoutLeeway=5;this.errorTimeoutReductionAmount=10;this.pendingGets=0;this.failureTimer=null;this.errorGetTimeout=null}return i.prototype.startGets=function(){this.getRequested||(this.getRequested=!0,this.performRealTimeGet())},i.prototype.isActive=function(){return t.storage.getItem(t.storageKeys.IsActive)==="true"},i.prototype.performRealTimeGet=function(){var n=this,i;if(!t.isCurrentTabOverlord()){t.error("[ChannelClient] Something tried to run a GET, but this tab isn't the overlord!");return}if(this.isReplaced){t.error("[ChannelClient] Something tried to run a GET, but this tab was replaced!");return}if(!Modernizr.localstorage){t.error("[ChannelClient] Cannot perform get - localStorage is not available! Disabling EventMux.");this.toggleActive(!1);return}clearTimeout(this.errorGetTimeout);bungieNetPlatform.notificationService.GetRealTimeEvents!==undefined&&t.isAuthed()?(t.log("[ChannelClient]["+(new Date).toString("HH:mm:ss")+"] Performing GET from Tab "+this.tabId),this.toggleActive(!0),this.setFailureTimer(),this.pendingGets++,i=bungieNetPlatform.notificationService.GetRealTimeEvents(this.ackNext,this.tabId,this.requestTimeout,function(i){if(n.pendingGets--,!t.isCurrentTabOverlord()){t.warn("[ChannelClient]["+(new Date).toString("HH:mm:ss")+"] Get succeeded, but this tab is no longer overlord! Throwing out results...");return}if(t.log("[ChannelClient]["+(new Date).toString("HH:mm:ss")+"] GET Succeeded"),t.log(i),i.replaced){t.warn("[ChannelClient] This channel was replaced! Refresh to establish a new channel.");n.onTabReplaced();return}n.onGetSuccess(i)},function(i,r,u){if(n.pendingGets--,n.clearFailureTimer(),!t.isCurrentTabOverlord()){t.warn("[ChannelClient]["+(new Date).toString("HH:mm:ss")+"] Get failed, but this tab is no longer overlord! Throwing out results...");return}n.onGetFailure(i,u)})):(this.toggleActive(!1),t.warn("[ChannelClient] Real time events are disabled or user is not authenticated!"))},i.prototype.onTabReplaced=function(){this.isReplaced=!0;this.tabReplacedCallback()},i.prototype.resetChannelClient=function(){t.log("[ChannelClient] Server sequence reset, resetting channel client...");this.ackNext=0;t.storage.setItem(t.storageKeys.StoredResponse,JSON.stringify({}));t.storage.setItem(t.storageKeys.LastSeqStored,String(0));t.lastSeqStored=0},i.prototype.onGetSuccess=function(n){var i,r,f,e,o;this.ackNext>n.seq&&this.resetChannelClient();this.ackNext=n.seq;this.tabId=n.tab||this.tabId;t.log("[ChannelClient] Storing GET results...");var s=t.storage.getItem(t.storageKeys.StoredResponse),u=s?JSON.parse(s):{},h=Object.keys(u),c=h.length;if(c>2){for(i=9007199254740991,r=0;r<c;r++)f=parseInt(h[r]),i=f<i?f:i;delete u[i]}e=u;o=n.seq;e[o]=n;t.storage.setItem(t.storageKeys.LastSeqStored,o.toString());t.storage.setItem(t.storageKeys.StoredResponse,JSON.stringify(e),!0);this.pendingGets===0&&this.performRealTimeGet()},i.prototype.onGetFailure=function(i,r){var o=this,u=!0,f,e;switch(i.errorCode){case 2:switch(r.status){case 0:u=!1;r.abort();t.error("[ChannelClient] Request failed, event request cancelled.");break;case 524:u=!0;this.reduceTimerDueToTimeout()}break;case 5:case 99:u=!1;t.error("[ChannelClient] Events suspended.");break;case 51:u=!1;t.log("[ChannelClient] Throttle Exceeded, Events suspended.");n.trackEvent("Warnings","ChannelClient_Stopped","Server Throttle Exceeded");break;default:t.error("[ChannelClient] GET failed, code "+i.errorCode+': "'+i.errorMessage+'"')}u?(f=Math.max(Math.pow(2,this.failures),10),e=f*1e3,t.log("[ChannelClient] GET will try again in "+f+" seconds."),this.errorGetTimeout=setTimeout(function(){o.performRealTimeGet()},e)):this.toggleActive(!1);this.failures++},i.prototype.toggleActive=function(n){var i=n.toString();this.isActive().toString()!==i&&t.log("[ChannelClient] Toggling active state to "+i);t.storage.setItem(t.storageKeys.IsActive,i)},i.prototype.setFailureTimer=function(){var n=this;this.clearFailureTimer();this.failureTimer=setTimeout(function(){n.reduceTimerDueToTimeout();n.performRealTimeGet()},(this.requestTimeout+this.errorTimeoutLeeway)*1e3)},i.prototype.clearFailureTimer=function(){clearTimeout(this.failureTimer)},i.prototype.reduceTimerDueToTimeout=function(){var n=Math.max(15,this.requestTimeout-this.errorTimeoutReductionAmount);this.requestTimeout=n},i}();t.ChannelClient=i})(t=n.EventMux||(n.EventMux={}))}(Bnet||(Bnet={})),function(n){var t;(function(t){var i=function(){function i(){this.failures=0;this.callbacks=[];this.setupListeners()}return i.prototype.setupListeners=function(){var n=this;$(window).on("storage customStorage",function(t,i){var r=t.type==="storage"?t.originalEvent.key:i;r.match(/eventmux/gi)&&n.callbacks.map(function(n){n()})})},i.prototype.addCallback=function(n){n===void 0&&(n=function(){});this.callbacks.push(n)},i.prototype.setItem=function(i,r,u){u===void 0&&(u=!1);u=u!=undefined?u:!1;try{var f=n.Utilities.LocalStorage.setItem(i,r);return u&&$(window).trigger("customStorage","eventMux"),f}catch(e){t.error("[Storage] setItem failed: "+e)}return null},i.prototype.sessionSetItem=function(i,r){try{return n.Utilities.SessionStorage.setItem(i,r)}catch(u){t.error("[Storage] sessionSetItem failed: "+u)}return null},i.prototype.getItem=function(i){try{return n.Utilities.LocalStorage.getItem(i)}catch(r){t.error("[Storage] getItem failed: "+r)}},i.prototype.sessionGetItem=function(i){try{return n.Utilities.SessionStorage.getItem(i)}catch(r){t.error("[Storage] sessionGetItem failed: "+r)}},i.prototype.removeItem=function(i,r){r===void 0&&(r=!1);r=r!=undefined?r:!1;try{var u=n.Utilities.LocalStorage.removeItem(i);return r&&$(window).trigger("customStorage"),u}catch(f){t.error("[Storage] removeItem failed: "+f)}},i}();t.Storage=i})(t=n.EventMux||(n.EventMux={}))}(Bnet||(Bnet={})),function(n){var t;(function(n){var t=function(){function t(t,i){var r=this;if(this.eventType=t,this.onUpdate=i,this.lastSeqParsed=0,!(t in Globals.RealTimeEventType)){n.error("Attempted to subscribe to an invalid event type");return}n.storage.addCallback(function(){r.checkForUpdate()});this.eventName=Globals.RealTimeEventType[t];n.log("[Subscription] Registered for: "+this.eventName)}return t.prototype.checkForUpdate=function(){var h=n.storage.getItem(n.storageKeys.StoredResponse),e=JSON.parse(h),i=n.lastSeqStored,t,r,o,u,f,s;if(this.lastSeqParsed!==i)for((this.lastSeqParsed===0||this.lastSeqParsed>i)&&(this.lastSeqParsed=i-1),t=this.lastSeqParsed+1;t<=i;t++){if(t in e&&(r=e[t],"events"in r))for(o=r.events.length,u=0;u<o;u++)if(f=r.events[u],f.eventType===this.eventType){s=f;n.log("[Subscription] Update found for ["+this.eventName+"] at seq "+t);this.onUpdate(s)}this.lastSeqParsed=t}},t.prototype.findMinimumSeq=function(n){for(var f=Object.keys(n),e=f.length,i=-1,u=!1,t,r=0;r<e;r++)t=parseInt(f[r]),!u&&t>this.lastSeqParsed?(i=t,u=!0):u&&t<i&&(i=t);return i},t}();n.Subscription=t})(t=n.EventMux||(n.EventMux={}))}(Bnet||(Bnet={})),function(n){var t;(function(n){var t=function(){function n(){this.subscriptions=[]}return n.prototype.addSubscription=function(n){this.subscriptions.push(n)},n}();n.SubManager=t})(t=n.EventMux||(n.EventMux={}))}(Bnet||(Bnet={})),function(n){var t;(function(t){var i=function(){function i(){var n=this;this.sessionStorageAvailable=Modernizr.sessionstorage;this.tabId=null;this.overlordTabId=null;this.overlordTabProofPollTimeout=null;this.overlordTabProofPollInterval=15e3;this.minionTabCheckTimeout=null;this.minionTabCheckInterval=3e4;t.storage.addCallback(function(){n.onStorageUpdate()});this.setupTabId(function(){n.onTabIdSetupComplete(!0)});this.setupListeners()}return i.prototype.setupListeners=function(){var n=this,t=!1,i;window.addEventListener("beforeunload",function(){t||(t=!0,n.setUnloadFlag(),n.retireSelfAsOverload())});window.addEventListener("unload",function(){t||(t=!0,n.setUnloadFlag(),n.retireSelfAsOverload())});i=Utility.visibility.getVisibilityEvent();document.addEventListener(i,function(){n.onDocumentVisibilityChange()})},i.prototype.isActive=function(){return this.channelClient.isActive()},i.prototype.setupTabId=function(n){n===void 0&&(n=function(){});t.log("[TabManager] Setting up Tab ID");this.getStoredTabId();this.tabId===null?this.setNewTabId(n):n()},i.prototype.getStoredTabId=function(){if(this.sessionStorageAvailable){var i=n.Utilities.SessionStorage.getItem(t.storageKeys.UnloadFlag)==="true";i?(this.unsetUnloadFlag(),this.tabId=n.Utilities.SessionStorage.getItem(t.storageKeys.TabId),this.tabId!==null&&(this.tabId==0?this.tabId=null:t.log("[TabManager] Tab ID acquired from sessionStorage"))):t.log("[TabManager] Tab was never unloaded, setting new tab instead")}},i.prototype.setUnloadFlag=function(){t.storage.sessionSetItem(t.storageKeys.UnloadFlag,(!0).toString())},i.prototype.unsetUnloadFlag=function(){t.storage.sessionSetItem(t.storageKeys.UnloadFlag,(!1).toString())},i.prototype.setNewTabId=function(i){i===void 0&&(i=function(){});this.tabId=this.generateId();this.sessionStorageAvailable&&n.Utilities.SessionStorage.setItem(t.storageKeys.TabId,String(this.tabId));t.log("[TabManager] New Tab ID generated!");i()},i.prototype.clearTabId=function(){this.tabId=null;this.sessionStorageAvailable&&(n.Utilities.SessionStorage.removeItem(t.storageKeys.TabId),t.log("[TabManager] Tab ID cleared from sessionStorage"))},i.prototype.onTabIdSetupComplete=function(){var n=this;this.channelClient=new t.ChannelClient(this.tabId,function(){n.setOverlordAsReplaced()});this.tryGetSetOverlordTabTimer(!0);t.log("[TabManager] Tab ID set to "+this.tabId)},i.prototype.tryGetSetOverlordTab=function(n){n=n||!1;clearTimeout(this.overlordTabProofPollTimeout);clearTimeout(this.minionTabCheckTimeout);var i=t.storage.getItem(t.storageKeys.OverlordTabId),r=n&&i===t.storageValues.OverlordTabReplaced;i===null||r?(n&&t.log("[TabManager] There was an overlord tab, but it was replaced. This tab will take over as overlord."),i=this.setCurrentTabToOverlord()):t.log("[TabManager] Overlord tab ID : "+i);this.overlordTabId=i;this.overlordTabId===this.tabId?this.onOverlordTabSet():(t.log("[TabManager] This tab is a minion "),this.minionTabCheckForOverlord())},i.prototype.tryGetSetOverlordTabTimer=function(n){var t=this;setTimeout(function(){t.tryGetSetOverlordTab(n)},Math.random()*2e3)},i.prototype.setCurrentTabToOverlord=function(){var n=this.tabId;return t.storage.setItem(t.storageKeys.OverlordTabId,String(n)),t.log("[TabManager] Set new overlord tab ID : "+n),n},i.prototype.onOverlordTabSet=function(){this.channelClient.startGets();this.overlordTabProofPoll()},i.prototype.overlordTabProofPoll=function(){var i=this,n;clearTimeout(this.overlordTabProofPollTimeout);n=Date.now();t.storage.setItem(t.storageKeys.OverlordTabProofPoll,n.toString());this.overlordTabProofPollTimeout=setTimeout(function(){i.overlordTabProofPoll()},this.overlordTabProofPollInterval)},i.prototype.minionTabCheckForOverlord=function(){var r=this,n,i;clearTimeout(this.minionTabCheckTimeout);n=!0;i=parseInt(t.storage.getItem(t.storageKeys.OverlordTabProofPoll));isNaN(i)?n=!1:Date.now()-i>this.minionTabCheckInterval&&(n=!1);n||(t.warn("[TabManager] Overlord tab no longer exists!"),t.storage.removeItem(t.storageKeys.OverlordTabId),this.tryGetSetOverlordTabTimer(!1));this.minionTabCheckTimeout=setTimeout(function(){r.minionTabCheckForOverlord()},this.minionTabCheckInterval)},i.prototype.onStorageUpdate=function(){var r=this,i,n;if(!t.isActive()){t.warn("[TabManager] EventMux is no longer active. Disabling storage updates and overlord proof time poll.");this.onStorageUpdate=function(){};clearTimeout(this.overlordTabProofPollTimeout);return}i=t.storage.getItem(t.storageKeys.LastSeqStored);t.lastSeqStored=parseInt(i);n=t.storage.getItem(t.storageKeys.OverlordTabId);n===null?this.tryGetSetOverlordTabTimer(!1):this.tabId===t.storageValues.OverlordTabReplaced&&n!==t.storageValues.OverlordTabReplaced&&(t.log("[TabManager] This tab used to be an overlord, but was replaced. Making it into a minion..."),this.setNewTabId(function(){r.onTabIdSetupComplete(!1)}))},i.prototype.retireSelfAsOverload=function(){var n=t.storage.getItem(t.storageKeys.OverlordTabId);n===this.tabId?(this.overlordTabId=null,t.storage.removeItem(t.storageKeys.OverlordTabId),t.log("[TabManager] Tab "+this.tabId+" has retired itself as overlord")):t.warn("[TabManager] Tab "+this.tabId+" cannot retire because it is not overlord! Overlord tab is currently: "+n)},i.prototype.setOverlordAsReplaced=function(){var n=t.storage.getItem(t.storageKeys.OverlordTabId);n===this.tabId?(t.warn("[TabManager] Overlord tab has been replaced!"),this.tabId=t.storageValues.OverlordTabReplaced,t.storage.setItem(t.storageKeys.OverlordTabId,String(t.storageValues.OverlordTabReplaced))):t.warn("[TabManager] Cannot set overlord as replaced, because this tab is not the overlord")},i.prototype.onDocumentVisibilityChange=function(){var n=Utility.visibility.getHiddenProperty(),t=!document[n];t},i.prototype.generateId=function(){var n,t,i,r;return"crypto"in window?(t=new Uint32Array(1),n=crypto.getRandomValues(t)[0]):(i=new Date,r=new Date((new Date).getFullYear().toString()),n=i.getTime()-r.getTime()),n=n&2147483647,n.toString()},i.prototype.isCurrentTabOverlord=function(){return this.tabId===this.overlordTabId},i}();t.TabManager=i})(t=n.EventMux||(n.EventMux={}))}(Bnet||(Bnet={})),function(n){var t;(function(n){var t=function(){function t(){}return t.initialize=function(){$(document).off(".companionforms");this.inputs=new n.CompanionTextType(".companion-text-input","input");this.inputs.initialize();this.textareas=new n.CompanionTextType(".companion-textarea","textarea");this.textareas.initialize();this.selects=new n.CompanionSelect;this.selects.initialize()},t}();n.Forms=t})(t=n.Site||(n.Site={}))}(Bnet||(Bnet={})),function(n){var t;(function(n){var t=function(){function n(){this.inputContainerSelector=".companion-select";this.inputTag="select"}return Object.defineProperty(n.prototype,"inputSelector",{get:function(){return this.inputContainerSelector+" "+this.inputTag},enumerable:!0,configurable:!0}),n.prototype.initialize=function(){this.setExistingInputs();this.addListeners()},n.prototype.addListeners=function(){var n=this;$(document).on("click touchend",".companion-select .select-box",function(t){n.onSelectBoxClick(t.currentTarget)});$(document).on("click touchend",".companion-select .select-box .current-option .select-option",function(t){n.onSelectBoxClick(t.currentTarget);return!1});$(document).on("click touchend",".companion-select .select-box .select-option",function(t){if($(t.currentTarget).closest(".current-option").length)return!1;var i=$(t.currentTarget).attr("data-value"),r=$(t.currentTarget).closest(".companion-select");n.onSelectOption(i,r);return!1});$(document).on("change",".companion-select select",function(t){if(t.isTrigger!==3)n.onChange(t.currentTarget)});$(document).on("click",function(t){$(t.currentTarget).closest(".companion-select").length===0&&n.closeDropdown()})},n.prototype.setExistingInputs=function(){var t=this,n=$(this.inputSelector);n.length&&n.each(function(n,i){var r=$(i),u=r.parents(t.inputContainerSelector),f=r.val();u.toggleClass("has-value",f!=="")})},n.prototype.onSelectBoxClick=function(n){this.toggleOpenClose(n)},n.prototype.onSelectOption=function(n,t){var i=t.find(".select-option[data-value='"+n+"']").first(),f=i.clone(),e=t.find(".select-box"),r=t.find(".current-option"),u=t.find("select");r.find(".select-option").remove();r.append(f);u.val(i.data("value"));u.trigger("change");this.closeDropdown(e)},n.prototype.onChange=function(n){var t=$(n).closest(".companion-select");this.onSelectOption(n.value,t)},n.prototype.closeDropdown=function(n){n===void 0&&(n=null);n?n.removeClass("open"):$(".companion-select .select-box").removeClass("open")},n.prototype.openDropdown=function(n){if(!n.hasClass("open")){setTimeout(function(){n.addClass("open")},Modernizr.mobile?250:0);return}},n.prototype.toggleOpenClose=function(n){var i=$(n),t=i.is(".select-box")?i:$(n).parents(".select-box");t.hasClass("open")?this.closeDropdown(t):this.openDropdown(t)},n}();n.CompanionSelect=t})(t=n.Site||(n.Site={}))}(Bnet||(Bnet={})),function(n){var t;(function(n){var t=function(){function n(n,t){this.inputContainerSelector=n;this.inputTag=t}return Object.defineProperty(n.prototype,"inputSelector",{get:function(){return this.inputContainerSelector+" "+this.inputTag},enumerable:!0,configurable:!0}),n.prototype.initialize=function(){this.setExistingInputs();this.addListeners()},n.prototype.addListeners=function(){var n=this;$(document).on("change.companionforms, keyup.companionforms",this.inputSelector,function(t){n.onChange(t.currentTarget)});$(document).on("focus.companionforms",this.inputSelector,function(t){n.onFocus(t.currentTarget)});$(document).on("blur.companionforms",this.inputSelector,function(t){n.onBlur(t.currentTarget)});$(document).on("click.companionforms",this.inputContainerSelector+" .fa",function(t){n.onClear(t.currentTarget)})},n.prototype.setExistingInputs=function(){var t=this,n=$(this.inputSelector);n.length&&n.each(function(n,i){var r=$(i),u=r.parents(t.inputContainerSelector),f=r.val();u.toggleClass("has-value",f.length>0);u.toggleClass("focused",r.is("[autofocus]"))})},n.prototype.onChange=function(n){var t=$(n).val();$(n).closest(this.inputContainerSelector).toggleClass("has-value",t.length>0)},n.prototype.onBlur=function(n){$(n).closest(this.inputContainerSelector).removeClass("focused")},n.prototype.onFocus=function(n){$(n).closest(this.inputContainerSelector).addClass("focused")},n.prototype.onClear=function(n){$(n).siblings(this.inputTag).val("").trigger("keyup").focus()},n}();n.CompanionTextType=t})(t=n.Site||(n.Site={}))}(Bnet||(Bnet={})),function(n){var t;(function(t){var i=function(){function n(){}return n.openPartnershipLink=function(n,t){t===void 0&&(t=function(){});var r="/"+Localizer.CurrentCultureName+"/User/InitiateExternalPartnerLink?partnerType="+Globals.PartnershipType[n],i=window.open(r,this.linkingWindowName,this.newWindowOptions),u=setInterval(function(){(!i||i.closed)&&(setTimeout(function(){t();window.location.href=PageUrls.settingsPage+"#tab=account"},500),clearInterval(u))},500)},n.newWindowOptions="height=560,width=790,left=550,top=200,menubar=no,location=no,resizable=no,scrollbars=yes,status=no,toolbar=no",n.linkingWindowName="accountlink",n}(),r;t.AccountLinking=i,function(t){function u(t){if(ServerVars.FeatureFlags.TwitchLink&&!r){var u='\n\t\t\t\t\t<div class="twitch-modal-content">\n\t\t\t\t\t\t<div class="title">\n\t\t\t\t\t\t\t<span class="twitch-logo"><\/span>\n\t\t\t\t\t\t\t'+Localizer.Community.twitchlinktitle+'\n\t\t\t\t\t\t<\/div>\n\t\t\t\t\t\t<div class="subtitle">'+Localizer.Community.twitchlinksubtitle+'<\/div>\n\t\t\t\t\t\t<div class="about">\n\t\t\t\t\t\t\t<p>'+Localizer.Community.twitchlinkemblemabout+'<\/p>\n\t\t\t\t\t\t<\/div>\n\t\t\t\t\t\t<div>\n\t\t\t\t\t\t\t<div class="button gold link-button">'+Localizer.Community.twitchlinkcalltoaction+'<\/div>\n\t\t\t\t\t\t<\/div>\n\t\t\t\t\t\t<a href="/'+Localizer.CurrentCultureName+'/r/Help/TwitchLinking">'+Localizer.Community.twitchlinkhelplink+"<\/a>\n\t\t\t\t\t<\/div>\n\n\t\t\t\t\t<style>\n\t\t\t\t\t\t.twitch-modal-content\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tcolor: #F5F5F5;\n\t\t\t\t\t\t\tfont-family: Roboto, sans-serif;\n\t\t\t\t\t\t\ttext-align: center;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t.twitch-modal-content .title\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tfont-size: 3.25rem;\n\t\t\t\t\t\t\tfont-weight: 100;\n\t\t\t\t\t\t\twhite-space: nowrap;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t.react-tiny .twitch-modal-content .title\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tfont-size: 2.5rem;\t\n\t\t\t\t\t\t\t}\n\t\t\n\t\t\t\t\t\t.twitch-modal-content .title span\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tfont-weight: bold;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t.twitch-modal-content .twitch-logo\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tdisplay: inline-block;\n\t\t\t\t\t\t\tvertical-align: -6px;\n\t\t\t\t\t\t\theight: 3rem;\n\t\t\t\t\t\t\twidth: 3rem;\n\t\t\t\t\t\t\tbackground: url(/img/theme/bungienet/bgs/bg_logo_twitch_white.png) 50% 50% no-repeat;\n\t\t\t\t\t\t\tbackground-size: contain;\n\t\t\t\t\t\t}\n\t\t\n\t\t\t\t\t\t.twitch-modal-content .subtitle\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tcolor: rgb(255, 206, 31);\n\t\t\t\t\t\t\tmargin: 1rem 0 2rem;\n\t\t\t\t\t\t}\n\t\t\n\t\t\t\t\t\t.twitch-modal-content .button\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tmargin-bottom: 2rem;\n\t\t\t\t\t\t}\n\t\t\n\t\t\t\t\t\t.twitch-modal-content .about\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tmax-width: 380px;\n\t\t\t\t\t\t\twidth: 100%;\n\t\t\t\t\t\t\tmargin: 0 auto 2rem;\n\t\t\t\n\t\t\t\t\t\t\tfont-size: 0.8rem;\n\t\t\t\t\t\t\tfont-weight: 200;\n\t\t\t\t\t\t}\n\t\t\n\t\t\t\t\t\t.twitch-modal-content a\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tcolor: rgb(255, 206, 31);\n\t\t\t\t\t\t}\n\t\t\t\t\t<\/style>\n\t\t\t\t";setTimeout(function(){r=!0;var f=new n.Modal("twitch-link",u);f.open();Utility.ackItem(t);f.afterOpenCallback=function(){var n=f.modalElement;n.find(".link-button").on("click",function(){i.openPartnershipLink(Globals.PartnershipType.Twitch)})};f.afterCloseCallback=function(){r=!1}},1e3)}}var r=!1;t.showIfNotSeen=u}(r=t.TwitchPopup||(t.TwitchPopup={}))})(t=n.Site||(n.Site={}))}(Bnet||(Bnet={})),function(n){var t;(function(n){var i=function(){function n(){this.registeredControls=[]}return n.prototype.add=function(n,i){var r=new t(n,i);this.registeredControls.push(r)},n.prototype.initializePages=function(){for(var u=!1,i,t,n=0,r=this.registeredControls.length;n<r;n++)i=this.registeredControls[n],$("body").is(i.requiredSelector)&&(t=i.pageInitializerClosure(),t.initialize(),t.addListeners(),this.currentPage=t,u=!0)},n}(),t;n.AreaInitializer=i;t=function(){function n(n,t){this.requiredSelector=n;this.pageInitializerClosure=t}return n}()})(t=n.Site||(n.Site={}))}(Bnet||(Bnet={})),function(n){n.log=function(){};n.logData=function(){};n.warn=function(){};n.error=function(){};n.base_log=function(){};n.base_log_data=function(){};n.base_warn=function(){};n.base_error=function(){}}(Bnet||(Bnet={})),function(n){var t;(function(t){function i(){Function.prototype.bind&&(Modernizr.ie?(n.base_log=Function.prototype.bind.call(console.debug,console),n.base_warn=Function.prototype.bind.call(console.warn,console),n.base_error=Function.prototype.bind.call(console.error,console),n.log=Function.prototype.bind.call(n.base_log,console),n.warn=Function.prototype.bind.call(n.base_warn,console),n.error=Function.prototype.bind.call(n.base_error,console)):(n.base_log=Function.prototype.bind.call(console.debug,console),n.base_warn=Function.prototype.bind.call(console.warn,console),n.base_error=Function.prototype.bind.call(console.error,console),n.log=Function.prototype.bind.call(n.base_log,console,""),n.warn=Function.prototype.bind.call(n.base_warn,console,""),n.error=Function.prototype.bind.call(n.base_error,console,"")))}function r(){n.log=function(){};n.warn=function(){};n.error=function(){}}t.enableLogging=i;t.disableLogging=r})(t=n.Debugging||(n.Debugging={}))}(Bnet||(Bnet={})),function(n){var t;(function(t){function e(){var e=jQuery.prototype.on,s=jQuery.prototype.off,n,r;i=!0;n=function(i,r,s,h,c){var a=this,l=u(a,i,r,s,h),v,y,w,p,b;if(i instanceof Object){for(v in i)i.hasOwnProperty(v)&&n.apply(a,[v,r,i[v]]);return a}for(y=0,w=t.existingBindings.length;y<w;y++)if(p=t.existingBindings[y],b=f(l,p),b){var k=l.element.selector||l.element.toString(),d=l.extraElements?"->"+l.extraElements:"",g={newBinding:l,existingBinding:p};o(g,k,d,i)}return t.existingBindings.push(l),e.apply(a,[i,r,s,h,c])};r=function(n,i,r){for(var h=this,e=u(h,n,i,function(){},null),c,l,a,v,o=t.existingBindings.length-1;o>=0;o--)c=t.existingBindings[o],l=f(e,c,!0),l&&(t.existingBindings.splice(o,1),a=e.element.selector||e.element[0].toString(),v=e.extraElements?"->"+e.extraElements:"");return s.apply(h,[n,i,r])};jQuery.prototype.on=n;jQuery.prototype.off=r}function u(n,t,i,r,u){var o=typeof t=="string"?t:null;!o&&t instanceof Object&&(o=Object.keys(t).join(" "));for(var s=typeof i=="string"?i:null,f=0,h=0,e=o.split(" "),c=s?s.split(","):[],f=0,h=e.length;f<h;f++)e[f]=e[f].split(".")[0];return{element:$(n),extraElements:$.map(c,$.trim),events:$.map(e,$.trim),handler:u||r||i}}function f(t,i,r){var u,f,e,o;return(r===void 0&&(r=!1),u=i.element.is(t.element),u&&(f=n.Utilities.Array.intersection(i.extraElements,t.extraElements),(f.length>0||t.extraElements.length===0||i.extraElements.length===0)&&(e=n.Utilities.Array.intersection(i.events,t.events),e.length>0&&(o=t.handler.toString()===i.handler.toString(),o||r))))?!0:!1}function o(t,u,f,e){if(i){if(r>100){n.error("Duplicate bindings have exceed 100. No more logging. Fix it!");i=!1;return}r++;n.warn("DUPLICATE BINDING DETECTED of "+u+f+".on("+e+")");n.warn(t)}}t.existingBindings=[];var i=!1,r=0;t.preventJQueryDoubleBind=e;ServerVars.VerboseConsoleLogs&&(t.enableLogging(),t.preventJQueryDoubleBind())})(t=n.Debugging||(n.Debugging={}))}(Bnet||(Bnet={})),function(n){var t;(function(n){var t;(function(n){function r(){return n.bungieNetMembershipId!==undefined&&n.bungieNetMembershipId!==null&&n.bungieNetMembershipId!=="0"}function t(){var r=window.ONPAGE_MEMBERSHIP_INFO!=undefined,u=r?jQuery.extend(i,window.ONPAGE_MEMBERSHIP_INFO):i,t=function(n){return(!r,n in u)?u[n]:null};n.destinyMembershipType=t("destinyMembershipType");n.destinyMembershipId=t("destinyMembershipId");n.bungieNetMembershipId=t("bungieNetMembershipId");n.characterId=t("characterId");n.displayName=t("displayName");n.uniqueName=t("uniqueName")}var i={destinyMembershipType:"0",destinyMembershipId:"0",bungieNetMembershipId:"0",characterId:"0",displayName:"",uniqueName:"",allowOverride:!1};n.hasOnPageBungieNetMembershipId=r;n.refresh=t;t();$(document).on("ready newPageCreated",function(){t()})})(t=n.OnPageMembership||(n.OnPageMembership={}))})(t=n.Site||(n.Site={}))}(Bnet||(Bnet={})),function(n){var t;(function(t){(function(n){n[n.none=0]="none";n[n.de=1]="de";n[n.en=2]="en";n[n.es=3]="es";n[n.fr=4]="fr";n[n.it=5]="it";n[n["pt-br"]=6]="pt-br";n[n.ja=7]="ja"})(t.Locales||(t.Locales={}));var i=t.Locales,r=function(){function t(i,r){return(this.currentUrlLocaleString=i,this.browserLocaleString=r,this.$languageSelector=$("#select_language"),t.instance)?(n.warn("Language selector already exists, returning existing one"),t.instance):(t.instance=this,this)}return t.prototype.initialize=function(){this.currentUrlLocale=t.stringToLocale(this.currentUrlLocaleString);this.browserLocale=t.stringToLocale(this.browserLocaleString);var n=Cookies.GetInMulti("bungleloc","lc");this.cookieLocale=t.stringToLocale(n);this.addListeners();Localizer.switchEnabled&&(this.evaluateLocale(),this.setLanguageSelector(this.currentUrlLocale))},t.prototype.addListeners=function(){var n=this;$("#select_language").on("change",function(i){var u=$(i.currentTarget).val(),r=t.stringToLocale(u);n.setLanguageSelector(r);n.setLocaleAndRedirect(r,!1,!0)})},t.stringToLocale=function(n){if(typeof n=="string")n=n.toLowerCase();else return n;return n&&n in i?i[n]:i.none},t.prototype.setLanguageSelector=function(n){if(Localizer.switchEnabled){var t=i[n];this.$languageSelector.find("option[value="+t+"]").prop("selected","selected")}},t.prototype.evaluateLocale=function(){bungieNetPlatform.platformSettings.mockContent||bungieNetPlatform.platformSettings.isFirehose||(this.cookieLocale!==i.none&&this.cookieLocale!==this.currentUrlLocale?this.redirectToLocale(this.cookieLocale):this.currentUrlLocale===i.none&&(this.currentUrlLocale=i.en,this.browserLocale!==this.currentUrlLocale&&this.redirectToLocale(this.browserLocale)))},t.prototype.redirectToLocale=function(n){var u;if(n!==i.none&&(u=this.isValidLocale(n),u)){var r=i[n],t=window.location.href,f=/(\/[A-Za-z]{2}\/|\/[A-Za-z]{2}-[A-Za-z]{2}\/)|(\/[A-Za-z]{2}$|\/[A-Za-z]{2}-[A-Za-z]{2}$)/,e=/(\/?$)/;location.href=t.match(f)?t.replace(f,"/"+r+"/"):t.match(e)?t.replace(e,"/"+r+"/"):t+"/"+r+"/"}},t.prototype.setLocaleAndRedirect=function(n,t,r){var f=i[n],u;(r||this.cookieLocale!==i.none)&&(u=new Date,u.setFullYear(u.getFullYear()+7),Cookies.SetMultiWithExpires("bungleloc",u,{lc:f,lcin:t}));this.redirectToLocale(n)},t.prototype.isValidLocale=function(n){var u=i[n],t,r;for(t in Localizer.availableLocales)if(Localizer.availableLocales.hasOwnProperty(t)&&(r=Localizer.availableLocales[t],r===u))return!0;return!1},t}();t.LocaleSelector=r})(t=n.Site||(n.Site={}))}(Bnet||(Bnet={}));__extends=this&&this.__extends||function(n,t){function r(){this.constructor=n}for(var i in t)t.hasOwnProperty(i)&&(n[i]=t[i]);n.prototype=t===null?Object.create(t):(r.prototype=t.prototype,new r)},function(n){(function(n){n[n.None=0]="None";n[n.Warning=1]="Warning";n[n.Information=2]="Information";n[n.Question=3]="Question"})(n.ConfirmationReason||(n.ConfirmationReason={}));var i=n.ConfirmationReason,t=function(n){function t(t,i,r,u,f){f===void 0&&(f=function(){});n.call(this,"confirmation-"+t,r);this.confirmLabel=Localizer.Actions.confirmdialogbutton;this.cancelLabel=Localizer.Actions.canceldialogbutton;this.includeCloseButton=!1;this.closeOnConfirm=!0;this.reason=i;this.confirmCallback=u;this.cancelCallback=f}return __extends(t,n),t.prototype.addListeners=function(){var t=this;n.prototype.addListeners.call(this);this.$modalContainer.find(".button.confirm").on("click",function(){return t.confirmSelected()});this.$modalContainer.find(".button.cancel").on("click",function(){return t.cancelSelected()})},t.prototype.confirmSelected=function(){this.closeOnConfirm&&this.close();this.confirmCallback!==undefined&&this.confirmCallback()},t.prototype.cancelSelected=function(){this.close();this.cancelCallback!==undefined&&this.cancelCallback()},t.prototype.populateAfterContent=function(){var n='<div class="button text cancel">'+this.cancelLabel+'<\/div>\n\t\t\t\t <div class="button text confirm gold">'+this.confirmLabel+"<\/div>";this.addHtmlAfterContent(n);this.$modal.addClass("confirmation")},t.prototype.populateContent=function(t){n.prototype.populateContent.call(this,t);this.populateAfterContent()},t}(n.Modal);n.ConfirmationModal=t}(Bnet||(Bnet={}));NotificationCountCacheDataSource=function(n,t){Modernizr.localstorage&&(this.config={localStorageKeyPrefix:"liveUpdateItems.",isCountCachedLocalStorageKey:"isCountCached",countExpireLocalStorageKey:"countExpire",updatedItems:["onlineFriendCount","notificationCount","messageCount","privateMessageCount","groupMessageCount","providersNeedingReauth","acks"]},t&&$.extend(this.config,t),this.notificationCountDistributor=n,this.cachedItems=this.findAllCachedItems(),this.addListeners())};NotificationCountCacheDataSource.prototype.findAllCachedItems=function(){for(var i={},t,u,n=0,r=this.config.updatedItems.length;n<r;n++)t=this.config.updatedItems[n],Bnet.Utilities.LocalStorage.getItem(this.config.localStorageKeyPrefix+t)!==null&&(u=JSON.parse(Bnet.Utilities.LocalStorage.getItem(this.config.localStorageKeyPrefix+t)),i[t]=u);return i};NotificationCountCacheDataSource.prototype.updateNotificationDistributor=function(){this.notificationCountDistributor.parseResponseAndBroadcast(this.cachedItems)};NotificationCountCacheDataSource.prototype.addListeners=function(){for(var t=this,r,n=0,i=this.config.updatedItems.length;n<i;n++)r=this.config.updatedItems[n],this.notificationCountDistributor.addListener(r,function(n,i){(typeof i=="undefined"||i===null)&&(i="");var r=n.type.replace(t.notificationCountDistributor.config.listenerSuffix,"");Bnet.Utilities.LocalStorage.setItem(t.config.localStorageKeyPrefix+r,JSON.stringify(i));t.setLocalStorageSettings()},"cached")};NotificationCountCacheDataSource.prototype.millisecondsUntilCacheExpires=function(){var t,n,i;return Modernizr.localstorage?(t=Bnet.Utilities.LocalStorage.getItem(this.config.localStorageKeyPrefix+this.config.isCountCachedLocalStorageKey)!==null?!0:!1,t&&(n=Bnet.Utilities.LocalStorage.getItem(this.config.localStorageKeyPrefix+this.config.countExpireLocalStorageKey),n!==null))?(i=(new Date).getTime(),n-i):0:ServerVars.GetCountsInterval};NotificationCountCacheDataSource.prototype.hasCacheExpired=function(){var t,n;try{return t=Bnet.Utilities.LocalStorage.getItem(this.config.localStorageKeyPrefix+this.config.isCountCachedLocalStorageKey)!==null,n=Bnet.Utilities.LocalStorage.getItem(this.config.localStorageKeyPrefix+this.config.countExpireLocalStorageKey),n!==null?!t||(new Date).getTime()>n:!0}catch(i){return!0}};NotificationCountCacheDataSource.prototype.setLocalStorageSettings=function(){var n=(new Date).getTime()+ServerVars.GetCountsInterval-2e3,t=this.config.localStorageKeyPrefix+this.config.isCountCachedLocalStorageKey,i=this.config.localStorageKeyPrefix+this.config.countExpireLocalStorageKey;Bnet.Utilities.LocalStorage.setItem(t,!0);Bnet.Utilities.LocalStorage.setItem(i,n)};NotificationCountDistributor=function(n){this.config={updatedItems:["onlineFriendCount","notificationCount","messageCount","privateMessageCount","groupMessageCount","providersNeedingReauth","acks"],listenerSuffix:"Updated"};this.listeners=[];n&&$.extend(this.config,n)};NotificationCountDistributor.prototype.parseResponseAndBroadcast=function(n){for(var t in n)this.config.updatedItems.indexOf(t)>-1&&typeof n[t]!="undefined"&&n[t]!==null&&$(document).trigger(t+this.config.listenerSuffix,n[t])};NotificationCountDistributor.prototype.registerListeners=function(n){var i,t,r;if(n.config.updatedItems)for(i=i=n.config.updatedItems.length,t=0;t<i;t++)r=n.config.updatedItems[t],this.config.updatedItems.indexOf(r)>-1&&this.addListener(r,function(t,i){var r=t.type.replace("Updated","");n[r](t,i)})};NotificationCountDistributor.prototype.listener=function(n,t,i){var r=this;$(document).on(n+"."+i,function(n,i){t(n,i)})};NotificationCountDistributor.prototype.addListener=function(n,t,i){if(this.config.updatedItems.indexOf(n)>-1){var r=new this.listener(n+this.config.listenerSuffix,t,i);typeof this.listeners=="undefined"?this.listeners=[{listenerName:{namespace:i}}]:this.listeners.push({listenerName:{namespace:i}})}else Bnet.warn("notificationCountDistributor does not raise events for "+n)};NotificationCountDistributor.prototype.removeListener=function(n,t){$(document).off(n+"."+t);this.listeners=this.listeners.filter(function(t){return typeof t[n]=="undefined"})};NotificationCountEventDataSource=function(n,t){t&&$.extend(this.config,t);this.notificationCountDistributor=n;this.addListeners();this.friendCounts={Xuid:0,Psnid:0}};NotificationCountEventDataSource.prototype.addListeners=function(){var n=this;Bnet.EventMux.subscribe(Globals.RealTimeEventType.NotificationsChanged,function(t){var i={notificationCount:t.notificationCount};n.notificationCountDistributor.parseResponseAndBroadcast(i)});Bnet.EventMux.subscribe(Globals.RealTimeEventType.MessageCounts,function(t){var i={messageCount:t.privateMessageCount,groupMessageCount:t.externalMessageCount};n.notificationCountDistributor.parseResponseAndBroadcast(i)});Bnet.EventMux.subscribe(Globals.RealTimeEventType.FriendCounts,function(t){t.friendCounts.Xuid!==undefined&&(n.friendCounts.Xuid=t.friendCounts.Xuid);t.friendCounts.Psnid!==undefined&&(n.friendCounts.Psnid=t.friendCounts.Psnid);var i=n.friendCounts.Xuid+n.friendCounts.Psnid,r={onlineFriendCount:i,providersNeedingReauth:t.needsReauth};n.notificationCountDistributor.parseResponseAndBroadcast(r)});Bnet.EventMux.subscribe(Globals.RealTimeEventType.Announcements,function(t){var i={acks:t.announcements};n.notificationCountDistributor.parseResponseAndBroadcast(i)})};Bnet=Bnet||{};Bnet.NotificationCountManager=null;NotificationCountManager=function(){this.initializePreDOMReady()};NotificationCountManager.prototype.initializePreDOMReady=function(){this.notificationCountDistributor=new NotificationCountDistributor;this.notificationCountCacheDataSource=new NotificationCountCacheDataSource(this.notificationCountDistributor);this.notificationCountPollingDataSource=new NotificationCountPollingDataSource(this.notificationCountDistributor,this);this.NotificationCountEventDataSource=new NotificationCountEventDataSource(this.notificationCountDistributor)};NotificationCountManager.prototype.initializePostDOMReady=function(){this.notificationCountCacheDataSource.updateNotificationDistributor();this.notificationCountCacheDataSource.hasCacheExpired()?this.notificationCountPollingDataSource.getCounts():this.notificationCountPollingDataSource.nextGetCounts()};NotificationCountManager.prototype.getPollingTimeoutInMilliseconds=function(){var n=this.notificationCountCacheDataSource.millisecondsUntilCacheExpires();return n<0&&(n=0),n+2e3};NotificationCountManager.prototype.forceGetCounts=function(){this.notificationCountPollingDataSource.getCounts()};NotificationCountManager.prototype.broadcastUpdates=function(n,t){(typeof t=="undefined"&&(t=!1),t&&Bnet.EventMux.isActive())||this.notificationCountDistributor.parseResponseAndBroadcast(n)};$(document).on("ready",function(){Bnet.NotificationCountManager=new NotificationCountManager;Bnet.NotificationCountManager.notificationCountDistributor.registerListeners(new NotificationCountViewModel);Bnet.NotificationCountManager.initializePostDOMReady()});NotificationCountPollingDataSource=function(n,t,i){this.config={updatedItems:["groupMessageCounts","onlineFriendCount","notificationCount","messageCount","providersNeedingReauth","acks"]};i&&$.extend(this.config,i);this.notificationCountDistributor=n;this.pollingTimeoutComputationProvider=t;this.enabled=!0;this.addListeners()};NotificationCountPollingDataSource.prototype.IsAuthenticated=function(){var t=0,i=Cookies.Get(window.ServerVars.WebMembershipCookieName),n;return i!=null&&(n=parseInt(i),t=isNaN(n)?0:n),t>0};NotificationCountPollingDataSource.prototype.getCounts=function(){var n=this;this.enabled&&!this.isPageHidden()&&this.IsAuthenticated()&&(this.stopPolling(),bungieNetPlatform.userService.GetCountsForCurrentUser(function(t){n.notificationCountDistributor.parseResponseAndBroadcast(t);n.nextGetCounts()},function(t){t.errorCode===99||t.errorCode===5?n.enabled=!1:n.nextGetCounts()}))};NotificationCountPollingDataSource.prototype.isPageHidden=function(){return $("html").hasClass("hidden")};NotificationCountPollingDataSource.prototype.addListeners=function(){var n=this;$(document).on("browserWindowIsRevealing",function(){n.nextGetCounts()});$(document).on("browserWindowIsHiding",function(){n.stopPolling()})};NotificationCountPollingDataSource.prototype.nextGetCounts=function(){var n,t;this.enabled&&(n=this,this.stopPolling(),t=this.pollingTimeoutComputationProvider.getPollingTimeoutInMilliseconds(),this.getCountsUpdateTimer=setTimeout(function(){n.getCounts()},t))};NotificationCountPollingDataSource.prototype.stopPolling=function(){clearTimeout(this.getCountsUpdateTimer)};viewModels.newNotifications=ko.observable(0);viewModels.unreadMessages=ko.observable(0);viewModels.unreadGroupMessages=ko.observable(0);viewModels.onlineFriendCount=ko.observable(0);viewModels.acks=ko.observable({});NotificationCountViewModel=function(n){this.config={updatedItems:["onlineFriendCount","notificationCount","messageCount","groupMessageCount","providersNeedingReauth","acks"],listenerSuffix:"Updated"};n&&$.extend(this.config,n)};NotificationCountViewModel.prototype.notificationCount=function(n,t){viewModels.newNotifications(t)};NotificationCountViewModel.prototype.messageCount=function(n,t){viewModels.unreadMessages(t)};NotificationCountViewModel.prototype.groupMessageCount=function(n,t){viewModels.unreadGroupMessages(t)};NotificationCountViewModel.prototype.onlineFriendCount=function(n,t){viewModels.onlineFriendCount(t)};NotificationCountViewModel.prototype.acks=function(n,t){typeof t!="undefined"&&viewModels.acks(t)};NotificationCountViewModel.prototype.providersNeedingReauth=function(n,t){if(typeof t!="undefined"&&t.length>0)for(var i=0;i<t.length;i++)t[i]==Globals.BungieCredentialType.Psnid?$(".reauthPSN.hide").length&&$(".reauthPSN.hide").removeClass("hide"):t[i]==Globals.BungieCredentialType.Xuid&&$(".reauthXbox.hide").length&&$(".reauthXbox.hide").removeClass("hide")},function(n){var t;(function(n){var t=function(){function t(){this.maxConcurrentMessages=6;this.messageQueue=[];this.ui=new n.UI(this)}return t.prototype.show=function(n,i,r,u){u===void 0&&(u=function(){});var f={messageType:n,text:i,timeout:r||t.messageTimeout,onMessageHideCallback:u,id:Date.now()};this.messageQueue.push(f);this.processQueue()},t.prototype.removeMessageFromQueue=function(n){for(var r=this.messageQueue.length,i,t=0;t<r;t++)if(i=this.messageQueue[t],i.id===n.id){this.messageQueue.splice(t,1);break}},t.prototype.processQueue=function(){for(var r=this,u=this.messageQueue.length,i=0,n,t=0;t<u;t++)(n=this.messageQueue[t],i+=n.active?1:0,n.active||i>=this.maxConcurrentMessages)||(n.active=!0,this.ui.showMessage(n,function(){r.processQueue()}))},t.messageTimeout=5e3,t}();n.Client=t})(t=n.ToastMessages||(n.ToastMessages={}))}(Bnet||(Bnet={})),function(n){var t;(function(n){(function(n){n[n.Info=0]="Info";n[n.Warning=1]="Warning";n[n.Error=2]="Error"})(n.ToastMessageType||(n.ToastMessageType={}));var t=n.ToastMessageType})(t=n.ToastMessages||(n.ToastMessages={}))}(Bnet||(Bnet={})),function(n){var t;(function(n){var t=function(){function t(n){this.client=n;this.$messageTemplate=$("#toast-message-template");this.$toastContainer=$("#toast-container");this.messageTemplateHtml=this.$messageTemplate.html()}return t.prototype.showMessage=function(n,t){var r=this,i,u,f;t===void 0&&(t=function(){});i=$(this.messageTemplateHtml);u=this.getMessageTypeClass(n.messageType)+"-message";i.addClass(u.toLowerCase());i.find(".text").html(n.text);this.$toastContainer.append(i);setTimeout(function(){i.addClass("on")},50);f=setTimeout(function(){r.hideMessage(n,i);n.onMessageHideCallback()},n.timeout);i.on("click",function(){r.onMessageClick(n,i)})},t.prototype.onMessageClick=function(n,t){this.hideMessage(n,t)},t.prototype.hideMessage=function(n,t){t.removeClass("on").addClass("off");setTimeout(function(){t.remove()},500);this.client.removeMessageFromQueue(n)},t.prototype.getMessageTypeClass=function(t){return n.ToastMessageType[t]},t}();n.UI=t})(t=n.ToastMessages||(n.ToastMessages={}))}(Bnet||(Bnet={}))