var __extends,Bnet,ForumSidebar;(function(n){var t;(function(t){var i=function(){function t(){this.createContainerSelector=".container_create";this.resultsContainerSelectorCreate=".ais-Hits";this.createInputSelector="#topicSubject";this.autocompInputSelector="#aa-search-input";this.autocompSuggestionsSelector="#topics-datalist";this.articleUrlBase="https://www.bungie.net/en/Help/Article/";this.delay=300;this.initialize()}return t.prototype.initialize=function(){var t=this;if(n.Site.getPageDataOrDefault("createTopicDeflectionElastic",!1))$(document).on("click",".btn_openCreateNewTopic",function(i){(i.preventDefault(),SignIn.notSignedIn())||(n.Site.getPageDataOrDefault("forumWithCategoryIndex",!1)?t.showCreatePostModal():t.setupCreatePostForDeflections())});n.Site.getPageDataOrDefault("searchForumWithElastic",!1)&&$(this.autocompInputSelector).length&&(this.addListenersForSearchBarSearch(),this.setupSuggestionsPanel())},t.prototype.addListenersForCreateSearch=function(){var n=this,t=$(this.createContainerSelector),i=t.find(this.createInputSelector);i.on("focus keyup",function(t){clearTimeout(n.createTopicDelay);n.createTopicDelay=setTimeout(function(){n.respondToCreateTopicKeyEvent(i,t)},n.delay);var i=$(t.currentTarget).val()})},t.prototype.addListenersForSearchBarSearch=function(){var n=this;$(document).on("keyup",this.autocompInputSelector,function(t){clearTimeout(n.searchBarDelay);var i=$(t.currentTarget).val();n.searchBarDelay=setTimeout(function(){n.respondToSearchBarKeyEvent(i,t)},n.delay)});$(document).on("click","#view-results",function(){var t=$(n.autocompInputSelector).val();n.doSearchForSearchBar(t,!0)});$(document).on("focus",this.autocompInputSelector,function(t){var i=$(t.currentTarget).val();i!=""&&n.doSearchForSearchBar(i,t.which===13)});$(document).on("blur",this.autocompInputSelector,function(){setTimeout(function(){$(n.autocompSuggestionsSelector).html("")},400)})},t.prototype.respondToSearchBarKeyEvent=function(n,t){clearTimeout(this.searchBarDelay);n!=""&&this.doSearchForSearchBar(n,t.which===13);$(this.autocompInputSelector).val()==""&&$(this.autocompSuggestionsSelector).html("")},t.prototype.respondToCreateTopicKeyEvent=function(n){var t=$(this.createContainerSelector),i=t.find(this.resultsContainerSelectorCreate);clearTimeout(this.createTopicDelay);n.length>0?this.doSearchForCreate(n):i.hide()},t.prototype.showSearchResultsFromSearch=function(n,t,i){i?this.showResultsModal(n,t):t.hits.total>0&&this.populateSuggestions(n,t)},t.prototype.populateSuggestions=function(n,t){var r=this,i;t.length>0&&($(this.autocompSuggestionsSelector).html(""),$(this.autocompSuggestionsSelector).length&&(i=t.map(function(n,t){if(t<4)return'<li class="aa-suggestion">\n\t\t\t\t\t\t\t\t\t<a href="'+r.articleUrlBase+n.contentId.toString().replace("'","")+'"><h4 class="subject">'+(typeof n.properties.title!="undefined"?n.properties.title:"")+'<\/h4><span class="body">'+(typeof n.properties.shortAnswer!="undefined"?n.properties.shortAnswer:"")+"<\/span><\/a>\n\t\t\t\t\t\t\t\t<\/li>"}).join(""),i=this.appendTheViewResultsLink(i,t.length),$(this.autocompSuggestionsSelector).html(i)))},t.prototype.appendTheViewResultsLink=function(n,t){return n+('<li id="view-results" class="aa-suggestion results"><span>'+t+' Search Results<\/span><i class="material-icons">keyboard_arrow_right<\/i><\/li>')},t.prototype.showSearchResultsFromCreate=function(n,t){var u=this,r,i;t.length>0&&(r=$(this.createContainerSelector),i=r.find(this.resultsContainerSelectorCreate),i.html(""),i.append(t.map(function(n,t){if(t<5)return'<div class="aa-suggestion">\n\t\t\t\t\t\t\t<a href="'+u.articleUrlBase+n.contentId.toString().replace("'","")+'">'+(typeof n.properties.Title!="undefined"&&n.properties.Title!==""?n.properties.Title:n.properties.ShortAnswer)+"<\/a>\n\t\t\t\t\t\t<\/div>"}).join("")),i.show())},t.prototype.doSearchForSearchBar=function(n,t){var r=this,i=5;t&&(i=20);bungieNetPlatform.contentService.SearchHelpArticles(n,i.toString(),function(i){r.showSearchResultsFromSearch(n,i,t)},function(n){console.log(n)})},t.prototype.doSearchForCreate=function(n){var t=this;bungieNetPlatform.contentService.SearchHelpArticles(n,"5",function(i){t.showSearchResultsFromCreate(n,i)},function(n){console.log(n)})},t.prototype.showCreatePostModal=function(){var i=this,r=$("#forum-create").html(),t=new n.Modal("forum-create",r);t.afterOpenCallback=function(){var n=$(".container_create");n.addClass("open");$("#modal-forum-create").insertAfter(".creationBox");$(".container_actions").detach().appendTo(".modal-after-content");i.setupCreatePostForDeflections()};t.open()},t.prototype.setupCreatePostForDeflections=function(){var n=this;this.matchCreateDeflectionSuggestionsWidth();$(window).on("resize",function(){n.matchCreateDeflectionSuggestionsWidth()});this.addListenersForCreateSearch()},t.prototype.matchCreateDeflectionSuggestionsWidth=function(){$("#hits").width($("#hits").prev(".text_subject").width())},t.prototype.showResultsModal=function(t,i){var u=this,f=$("#forum-search").html(),r=new n.Modal("forum-search",f);r.overflowType=n.ModalOverflowTypes.scrolloutsidemodal;r.afterOpenCallback=function(){var n,f,e;i.length>0&&(n=r.modalContentElement.find(".results"),n.html(i.map(function(n){return'<a class="result" href="'+u.articleUrlBase+n.contentId.toString().replace("'","")+'"><span class="subject">'+n.properties.Title+'<\/span><span class="body">'+(typeof n.properties.ShortAnswer!="undefined"?n.properties.ShortAnswer:"")+"<span><\/a>"}).join("")),f=r.modalContentElement.find(".result-count"),f.html(i.length+" Results for <span>"+t+"<\/span>"),e=r.modalContentElement.find("#textbox_searchForClans"),e.val(t))};r.open()},t.prototype.setupSuggestionsPanel=function(){var n="#aa-input-container",t="#topics-datalist",r=$(n).width(),i;$(t).width(r);i=$(n).offset().top+$(n).outerHeight(!0);$(t).css({top:i});$(window).on("resize",function(){var r=$(n).width(),i;$(t).width(r);i=$(n).offset().top+$(n).outerHeight(!0);$(t).css({top:i})})},t}();t.Elastic=i})(t=n.ExternalSearch||(n.ExternalSearch={}))})(Bnet||(Bnet={}));Bnet.Site.getPageDataOrDefault("elasticSearch",!1)&&$(document).ready(function(){var n=new Bnet.ExternalSearch.Elastic});__extends=this&&this.__extends||function(){var n=function(t,i){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,t){n.__proto__=t}||function(n,t){for(var i in t)t.hasOwnProperty(i)&&(n[i]=t[i])},n(t,i)};return function(t,i){function r(){this.constructor=t}n(t,i);t.prototype=i===null?Object.create(i):(r.prototype=i.prototype,new r)}}(),function(n){var t;(function(t){var i=function(n){function i(){return n.call(this,"Forums")||this}return __extends(i,n),i.prototype.addPages=function(n){n.add(".Forum.PublicForum",function(){return new t.RecruitmentNavPage});n.add(".Forum.Topics",function(){return new t.TopicsInit});n.add(".Forum.Post",function(){return new t.PostsInit})},i.Instance=new i,i}(n.Site.Area);t.ForumsArea=i;n.Site.setCurrentArea(i.Instance)})(t=n.Forums||(n.Forums={}))}(Bnet||(Bnet={}));__extends=this&&this.__extends||function(){var n=function(t,i){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,t){n.__proto__=t}||function(n,t){for(var i in t)t.hasOwnProperty(i)&&(n[i]=t[i])},n(t,i)};return function(t,i){function r(){this.constructor=t}n(t,i);t.prototype=i===null?Object.create(i):(r.prototype=i.prototype,new r)}}(),function(n){var t;(function(t){var i=function(t){function i(){return t!==null&&t.apply(this,arguments)||this}return __extends(i,t),i.prototype.initialize=function(){this.posts=new Posts(n.Site.getPageData("postId"),{forumType:Globals.ForumTypeEnum.Public,isLargeThread:n.Site.getPageData("isLargeThread"),sort:n.Site.getPageData("sort"),page:n.Site.getPageData("page"),path:n.Site.getPageData("path"),hasMore:n.Site.getPageData("hasMore"),showBanned:n.Site.getPageData("showBanned"),groupId:n.Site.getPageData("groupId")})},i.prototype.addListeners=function(){},i}(n.Site.PageInitializer);t.PostsInit=i})(t=n.Forums||(n.Forums={}))}(Bnet||(Bnet={}));__extends=this&&this.__extends||function(){var n=function(t,i){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,t){n.__proto__=t}||function(n,t){for(var i in t)t.hasOwnProperty(i)&&(n[i]=t[i])},n(t,i)};return function(t,i){function r(){this.constructor=t}n(t,i);t.prototype=i===null?Object.create(i):(r.prototype=i.prototype,new r)}}(),function(n){var t;(function(t){var i=function(t){function i(){return t!==null&&t.apply(this,arguments)||this}return __extends(i,t),i.prototype.initialize=function(){n.Site.PageController.Instance.ajaxSectionRegex=/\/Forums\/Topics/i;this.topics=new Topics({pageNumber:n.Site.getPageData("page"),forumType:n.Site.getPageData("forumType"),category:n.Site.getPageData("category"),sort:n.Site.getPageData("sort"),createdDate:n.Site.getPageData("dateFilter"),groupId:n.Site.getPageData("groupId"),tags:n.Site.getPageData("searchedTags"),activityOnPage:n.Site.getPageData("activityOnPage"),languages:n.Site.getPageData("languages")})},i.prototype.addListeners=function(){},i}(n.Site.PageInitializer);t.TopicsInit=i})(t=n.Forums||(n.Forums={}))}(Bnet||(Bnet={}));__extends=this&&this.__extends||function(){var n=function(t,i){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,t){n.__proto__=t}||function(n,t){for(var i in t)t.hasOwnProperty(i)&&(n[i]=t[i])},n(t,i)};return function(t,i){function r(){this.constructor=t}n(t,i);t.prototype=i===null?Object.create(i):(r.prototype=i.prototype,new r)}}(),function(n){var t;(function(t){var r=function(n){function t(){return n!==null&&n.apply(this,arguments)||this}return __extends(t,n),t.prototype.initialize=function(){if($(".recruitmentSideNav").length)var n=new i(this.eventBinder)},t.prototype.addListeners=function(){},t.prototype.destroy=function(){},t}(n.Site.PageInitializer),i;t.RecruitmentNavPage=r;i=function(){function t(n){this.eventBinder=n;this.initialize()}return t.prototype.initialize=function(){this.getRecruitmentConfig();this.$containerEl=$(".recruitmentSideNav");this.$platformSwitcher=this.$containerEl.find(".platformSwitcher");this.$navItems=this.$containerEl.find(".navItem");this.addListeners();var n=this.getPlatformTag();this.markPlatformSwitcherOnState(n);this.showOnlyPlatformItems(n)},t.prototype.addListeners=function(){var t=this;this.$platformSwitcher.find("a").addClass("exempt");this.eventBinder.for(this.$platformSwitcher.find("a")).on("click",function(i){var u,f,r,e;i.preventDefault();u=$(i.currentTarget);u.hasClass("on")||(f=t.getIndexOfOriginalElement(),r=u.attr("data-platform"),t.markPlatformSwitcherOnState(r),e=t.getCorrespondingActivityUrl(f,r),t.showOnlyPlatformItems(r),n.Site.PageController.Instance.redirect(e))})},t.prototype.getIndexOfOriginalElement=function(){return this.$navItems.filter(".show").index(this.$navItems.filter(".on"))},t.prototype.getCorrespondingActivityUrl=function(n,t){return this.$navItems.filter("."+t).find("a").eq(n).attr("href")},t.prototype.showOnlyPlatformItems=function(n){this.$navItems.filter("."+n).addClass("show").siblings(":not(li."+n+")").removeClass("show")},t.prototype.getRecruitmentConfig=function(){this.recruitmentConfig=n.Site.getPageDataOrDefault("recruitmentConfig",{})},t.prototype.markPlatformSwitcherOnState=function(n){this.$platformSwitcher.find("[data-platform="+n+"]").addClass("on").siblings(".on").removeClass("on")},t.prototype.getPlatformTag=function(){var n="";for(var t in this.recruitmentConfig.PlatformTags)window.location.href.indexOf(t)>-1?n=t:$("#content_topics[data-platform]").length&&$("#content_topics[data-platform]").attr("data-platform").toLowerCase()===t.toLowerCase()&&(n=t);return n===""&&(n=this.recruitmentConfig.DefaultPlatformTag),n},t}();t.RecruitmentNav=i})(t=n.Forums||(n.Forums={}))}(Bnet||(Bnet={}));ForumSidebar=function(){this.taggleFollowedList;this.addEventListeners()};ForumSidebar.prototype.addEventListeners=function(){$("#Nav_Forum").on("click",".trigger .expandIcon",function(n,t){n.stopImmediatePropagation();n.preventDefault();var i=$(this);i.closest(".navItem").hasClass("opened")?i.closest(".navItem").removeClass("opened"):(i.closest(".navItem").addClass("opened"),i.closest(".container_followedTagsList").length&&(typeof this.taggleFollowedList=="undefined"&&(this.taggleFollowedList=new Taggle("followedTagsList",{placeholder:Localizer.Forums.entertags,tags:followedTags,onTagAdd:function(n,t){t=Utility.GetValidTags(t);bungieNetPlatform.activityService.FollowTag(t,function(){var n={"0":t,"2":PageUrls.profilePage+"/254/"+myID_cookie+"#context=membership&tab=tags"},i=Localizer.fnStringReplace(Localizer.Community.followingtagconfirmationmessage,n);Utility.alertSuccess(i,Globals.SuccessMessages.Following);$("#alert").addClass("follow")},function(n){Utility.alert(n.errorMessage)})},onTagRemove:function(n,t){bungieNetPlatform.activityService.UnfollowTag(t,function(){viewModels.myFollowedTagsModel.remove(function(n){return n.detail.displayName.toLowerCase()==t.toLowerCase()})},function(n){Utility.alert(n.errorMessage)})}}),$("#followedTagsList .taggle_input").focus()),typeof t!="undefined"&&typeof t.tag!="undefined"&&this.taggleFollowedList.add(t.tag.replace("#",""))))});$("#Nav_Forum").on("click.tagnav",".taggle",function(n){n.preventDefault();Bnet.Site.PageController.Instance.stateChange(PageUrls.defaultTopicsPage+"/0/Default/None/"+$(this).find(".taggle_text").text().replace("#",""),!0)})}