/*=======================================================================*\
|| ###################################################################### ||
|| # vBulletin 5.5.2
|| # ------------------------------------------------------------------ # ||
|| # Copyright 2000-2019 MH Sub I, LLC dba vBulletin. All Rights Reserved.  # ||
|| # This file may not be redistributed in whole or significant part.   # ||
|| # ----------------- VBULLETIN IS NOT FREE SOFTWARE ----------------- # ||
|| # http://www.vbulletin.com | http://www.vbulletin.com/license.html   # ||
|| ###################################################################### ||
\*========================================================================*/
window.vBulletin=window.vBulletin||{};window.vBulletin.phrase=window.vBulletin.phrase||{};window.vBulletin.phrase.precache=window.vBulletin.phrase.precache||[];window.vBulletin.phrase.precache=$.merge(window.vBulletin.phrase.precache,["invalid_request","invalid_search_syntax","invalid_server_response_please_try_again","unknown_error"]);(function(A){vBulletin.conversation=vBulletin.conversation||{};vBulletin.conversation.filter=function(K){var N=this;var E=null;var F=0;var J=false;var C=false;var I="conversation_filter";var O={context:document,autoCheck:false,checkInterval:15000,scrollToTop:null,customFilter:null,onContentLoad:null,closeOverlayOnScroll:true,pagination:null,allowHistory:false,tabParamAsQueryString:true,hash:""};if(K&&typeof K=="object"){A.extend(O,K)}var B=new vBulletin.history.instance(O.allowHistory);function H(){A(".toolbar-filter-overlay input[type=radio]",O.context).off("change."+I).on("change."+I,function(X,W,b){var R,U,S=A(this),d=A(this.form);if(!B.isEnabled()&&O.allowHistory){R=vBulletin.makePaginatedUrl(location.href,1);location.href=vBulletin.makeFilterUrl(R,this.name,this.value,O.context,O.hash);return true}J=true;O.customFilter=null;if(!S.data("bypass-filter-display")){M(this)}U=S.closest(".conversation-toolbar-wrapper");if(A(".conversation-toolbar-wrapper",O.context).length>1){$toolbarWrappers.filter("."+(U.hasClass("top")?"bottom":"top")).find("input[name={0}][value={1}]".format(this.name,this.value)).prop("checked",true)}if(this.value=="conversations_on"){O.autoCheck=true;C=true;F=1}else{clearTimeout(F);C=(this.name=="filter_show")}A(".new-conversations-strip",O.context).hide();N.updatePageNumber(b||1);var T=A('.filtered-by .filter-text[data-filter-name="q"]',O.context);if(T.length){var Q=N.getSelectedFilters(d);Q.q=T.data("filter-value");N.setOption("customFilter",Q);N.forceApplyFilters()}else{N.applyFilters(false)}if(B.isEnabled()&&!W){var V=N.getSelectedFilters(d),c=this.name,P=this.value,a=A(".filtered-by",U),Z={from:"filter",page:1,tab:O.tabParamAsQueryString?"#"+U.closest(".ui-tabs-panel").attr("id"):vBulletin.getSelectedTabHashOrPath(U.closest(".ui-tabs"),false),filters:V,filtervalue:P,filtername:c};if(!a.data("reset")){R=vBulletin.makePaginatedUrl(location.href,1);R=vBulletin.makeFilterUrl(R,c,P,O.context)}else{R=location.pathname.replace(/\/page[0-9]+/,"");if(O.tabParamAsQueryString){var Y=vBulletin.parseQueryString(location.search);if(Y.tab){R+="?tab="+Y.tab}else{if(Y.view){R+="?view="+Y.view}}}}B.pushState(Z,document.title,R);a.data("reset",null)}});A(".new-conversations-strip",O.context).off("click."+I).on("click."+I,function(){A(this).hide();C=true;N.updatePageNumber(1);N.applyFilters(false,true)});A(".toolbar-filter",O.context).off("click."+I).on("click."+I,function(U,T,R){var S=A(this).closest(".conversation-toolbar-wrapper");var Q=(S.hasClass("bottom"))?"bottom":"top";if(typeof T=="undefined"){T="slow"}var V=A(".filter-wrapper",this).toggleClass("selected");A(".arrow .vb-icon",this).toggleClass("vb-icon-triangle-down-wide vb-icon-triangle-up-wide");A(".toolbar-filter-overlay",S).slideToggle(T,function(){var W=I+Q;if(A(this).is(":visible")){A("body").off("click."+W).on("click."+W,function(c){var a=".conversation-toolbar-wrapper."+Q;if(A(c.target).closest(".toolbar-filter-overlay").length==0&&A(c.target).closest(".toolbar-filter").length==0){A("body").off("click."+W);A(window).off("scroll."+W);var b=(A(c.target).closest(".toolbar-filter").length>0)?"fast":"slow";A(".conversation-toolbar-wrapper.{0} .conversation-toolbar .toolbar-filter".format(Q),O.context).triggerHandler("click."+I,[b])}});var Y=true;if(R!="scroll"){var X=A(".filtered-by",O.context);if(X.length==0||X.is(":hidden")){X=this}var Z={};Y=vBulletin.isScrolledIntoView(X,Z);if(!Y){A("html,body").animate({scrollTop:"+="+Math.abs(Z.bottom)},"fast",function(){setTimeout(function(){if(O.closeOverlayOnScroll){A(window).off("scroll."+W).on("scroll."+W,function(){A(".conversation-toolbar-wrapper.{0} .conversation-toolbar .toolbar-filter".format(Q),O.context).triggerHandler("click."+I,[0,"scroll"])})}},50)})}}if(Y){if(O.closeOverlayOnScroll){A(window).off("scroll."+W).on("scroll."+W,function(){A(".conversation-toolbar-wrapper.{0} .conversation-toolbar .toolbar-filter".format(Q),O.context).triggerHandler("click."+I,[0,"scroll"])})}}}else{A("body").off("click."+W);A(window).off("scroll."+W)}});if(S.hasClass("bottom")&&A(".arrow .vb-icon",this).hasClass("vb-icon-triangle-up-wide")){var P=A(".conversation-toolbar-wrapper.bottom .toolbar-filter-overlay",O.context);A("html, body").animate({scrollTop:P.offset().top+P.innerHeight()},500)}});A(".filtered-by",O.context).off("click."+I,".x").on("click."+I,".x",function(){var T=A(this),Q=T.closest(".filtered-by"),W=T.closest(".filter-text"),S=W.data("filter-name"),V=A(),R;Q.data("clicked",true);if(!B.isEnabled()&&O.allowHistory){var P;if(W.data("filter-type")=="text"&&W.data("filter-js-selector")){P=vBulletin.makePaginatedUrl(location.href,1);location.href=vBulletin.makeFilterUrl(P,"q","",O.context,O.hash,true)}else{P=vBulletin.makePaginatedUrl(location.href,1);location.href=vBulletin.makeFilterUrl(P,S,W.data("filter-value"),O.context,O.hash,true)}return false}V=A(".toolbar-filter-overlay .filter-options input[name={0}]".format(S),O.context).prop("checked",false).filter(".js-default-checked");N.updatePageNumber(1);if(W.data("filter-type")=="text"&&W.data("filter-js-selector")){A(W.data("filter-js-selector")).val("");R=N.getSelectedFilters(A("form.toolbar-filter-overlay",O.context));delete R[S];N.setOption("customFilter",R)}W.remove();var U=Q.find(".filter-text").length;if(U==0){Q.addClass("h-hide");Q.data("reset",true)}else{if(U==1){Q.find(".clear-all").addClass("h-hide")}}if(V.length==1){V.data("bypass-filter-display",true);V.trigger("click."+I);V.data("bypass-filter-display",null)}else{if(R){var P=vBulletin.makePaginatedUrl(location.href,1);P=vBulletin.makeFilterUrl(P,"q","",O.context);B.pushState({from:"filter",page:1,tab:O.tabParamAsQueryString?"#"+T.closest(".ui-tabs-panel").attr("id"):vBulletin.getSelectedTabHashOrPath(T.closest(".ui-tabs"),false),filters:R},document.title,P)}N.forceApplyFilters();if(R){N.setOption("customFilter",null)}}});A(".filtered-by",O.context).off("click."+I,".clear-all").on("click."+I,".clear-all",function(){var P=A(this).closest(".conversation-toolbar-wrapper");A(this).data("clicked",true);N.setOption("customFilter",null);N.resetFilters(false,false,P);return false});A(".conversation-toolbar .filter-wrapper",O.context).data("object-instance",N);A(".js-conversation-showmore-button",O.context).click(function(){var P=parseInt(A('form.toolbar-filter-overlay input[name="pagenum"]',O.context).val());C=false;N.updatePageNumber(P+1);N.applyFilters(false,true,true)});A(".conversation-toolbar .toolbar-search-form",O.context).off("submit.filtersearch").on("submit.filtersearch",function(){var P="q";$searchBox=A(this.elements[P]),searchKeyword=A.trim($searchBox.val()),$conversationToolbar=A(this).closest(".conversation-toolbar-wrapper"),Q;$searchBox.val(searchKeyword);if(!B.isEnabled()&&O.allowHistory){Q=vBulletin.makePaginatedUrl(location.href,1);location.href=vBulletin.makeFilterUrl(Q,P,searchKeyword,$conversationToolbar);return false}var T=O.tabParamAsQueryString?"#"+A(this).closest(".ui-tabs-panel").attr("id"):vBulletin.getSelectedTabHashOrPath(A(this).closest(".ui-tabs"),false);if(searchKeyword){var S=N.getSelectedFilters($conversationToolbar.find(".toolbar-filter-overlay")),U={};U[P]=searchKeyword;A.extend(S,U);N.setOption("customFilter",S);N.forceApplyFilters();N.displayCustomFilterText(this.elements[P]);if(B.isEnabled()){Q=vBulletin.makePaginatedUrl(location.href,1);Q=vBulletin.makeFilterUrl(Q,P,searchKeyword,$conversationToolbar);B.pushState({from:"filter",page:1,tab:T,filters:S},document.title,Q)}}else{var R=$conversationToolbar.find('.filter-text[data-filter-name="{0}"]'.format(P));if(R.length){var S=N.getSelectedFilters($conversationToolbar.find(".toolbar-filter-overlay"));N.setOption("customFilter",S);A(".x",R).trigger("click");if(B.isEnabled()){var Q=vBulletin.makePaginatedUrl(location.href,1);Q=vBulletin.makeFilterUrl(Q,P,searchKeyword,$conversationToolbar);B.pushState({from:"filter",page:1,tab:T,filters:S},document.title,Q)}}}return false})}function M(P,Q){vBulletin.conversation.displaySelectedFilterText(P,Q,O.context)}H();this.isFilterSelected=function(P){return A('.toolbar-filter-overlay input[value="'+P+'"]',O.context).is(":checked")};this.getSelectedFilters=function(P){return vBulletin.getSelectedFilters(P,false)};this.resetFilterForms=function(P){if(!P||(P instanceof A&&!P.length)){P=O.context}A(".toolbar-filter-overlay .js-default-checked",P).prop("checked",true);A(".toolbar-search-form .js-filter-search",P).val("").filter(".placeholder").focus().blur()};A(".toolbar-filter-overlay, .toolbar-search-form",O.context).trigger("reset");if(B.isEnabled()){var D=B.getState();if(!D||A.isEmptyObject(D.data)){var G=A(O.context).hasClass("ui-tabs-panel")?A(O.context).attr("id"):A(".conversation-toolbar-wrapper",O.context).closest(".ui-tabs-panel").attr("id"),L={from:"filter",page:Number(A(".pagenav-form .defaultpage",O.context).val())||1,tab:vBulletin.getSelectedTabHashOrPath(A(O.context).closest(".ui-tabs"),O.tabParamAsQueryString),filters:N.getSelectedFilters(A("form.toolbar-filter-overlay",O.context))};B.setDefaultState(L,document.title,location.href)}B.setStateChange(function(X,c,Y){var P=B.getState();if(P.data.from=="filter"||c=="pagination"||c=="tabs"){B.log(P.data,P.title,P.url);var S,Q;if(P.data.tab){S=O.tabParamAsQueryString?A(P.data.tab):A('.ui-tabs .ui-tabs-panel[data-url-path="'+P.data.tab+'"]')}Q=(S&&S.length&&S)||O.context;if(c=="pagination"){if(Y){var a=A(".filtered-by",Q),R=A(".toolbar-filter-overlay .filter-options-list",Q),b=false;A(".filter-text",a).filter('[data-filter-name!="q"]').remove();A(".clear-all",a).addClass("h-hide");R.find(".js-default-checked").prop("checked",true);A.each(Y,function(e,f){var d=A('input[name="{0}"][value="{1}"]'.format(e,f),R);if(d.length){d.prop("checked",true).trigger("change",[true,P.data.page]);b=true}});if(!b){R.first().data("bypass-filter-display",true).trigger("change",[true,P.data.page]).data("bypass-filter-display",null);a.addClass("h-hide")}}}else{var W=A(Q).closest(".ui-tabs"),T=O.tabParamAsQueryString?W.find('.ui-tabs-nav > li > a[href*="{0}"]'.format(P.data.tab)):W.find('.ui-tabs-nav > li > a[data-url-path="'+P.data.tab+'"]');if(!T.parent().hasClass("ui-tabs-active")){var V=T.parent().index();vBulletin.selectTabByIndex.call(W,V)}else{var U=N.getSelectedFilters(A(".toolbar-filter-overlay",Q)),Z=A(".conversation-toolbar .filter-wrapper",Q).data("object-instance")||N;if(!vBulletin.areJsonObjectsEqual(U,P.data.filters)){Z.setOption("context",Q);Z.updatePageNumber(P.data.page);Z.applyHistoryFilters(P.data)}}}}},"filter")}this.displayCustomFilterText=function(P,Q){M(P,(Q||A(P).val()))};this.isHistoryEnabled=function(){return B.isEnabled()};this.resetFilters=function(U,Q,T){if(!T||(T instanceof A&&!T.length)){T=O.context}var S=A(".filtered-by",T).addClass("h-hide"),R=location.pathname.replace(/\/page[0-9]+/,"");if(O.tabParamAsQueryString){var P=vBulletin.parseQueryString(location.search);if(P.tab){R+="?tab="+P.tab}else{if(P.view){R+="?view="+P.view}}}A(".clear-all",S).addClass("h-hide");A(".filter-text",S).remove();N.resetFilterForms(T);if(!U){if(B.isEnabled()){S.data("reset",true);N.updatePageNumber(1);var V=N.getSelectedFilters(A("form.toolbar-filter-overlay",T));if(Q){var W=A(".toolbar-search-form .js-filter-search",T).val("");delete V[W.attr("name")];N.setOption("customFilter",V)}N.forceApplyFilters();L={from:"filter",page:1,tab:O.tabParamAsQueryString?"#"+S.closest(".ui-tabs-panel").attr("id"):vBulletin.getSelectedTabHashOrPath(S.closest(".ui-tabs"),false),filters:V};B.pushState(L,document.title,R)}else{if(O.allowHistory){location.href=R}}}return N};this.applyHistoryFilters=function(R){if(R&&R.filters&&!A.isEmptyObject(R.filters)){var S=O.tabParamAsQueryString?A(R.tab):A('.ui-tabs .ui-tabs-panel[data-url-path="'+R.tab+'"]'),U=A(".toolbar-filter-overlay",S);if(typeof (N.lastFilters)!="undefined"){delete N.lastFilters}N.resetFilters(true,false,S);A.each(R.filters,function(V,X){var W=A('[name="'+V+'"]',U);if(W.attr("type")=="hidden"){W.val(X)}else{if(W.attr("type")=="radio"&&X!=R.filtervalue){W.filter('[value="'+X+'"]').prop("checked",true)}}});var Q=vBulletin.parseQueryString(location.href),T=true,P=function(){A(".toolbar-search-form .js-filter-search",S).val("").filter(".placeholder").focus().blur()};if(!A.isEmptyObject(Q)){A.each(Q,function(W,X){var V=A('.filter-options-list input[name="{0}"][value="{1}"]'.format(W,X),U);if(V.length){if(R.filtername==W&&R.filtervalue==X){T=false;V.prop("checked",true).trigger("change",[true])}else{M(V.get(0))}}else{V=A('.toolbar-search-form .js-toolbar-search-inner input[name="{0}"]'.format(W),S);if(V.length&&X){M(V.get(0),X);V.val(X)}else{P()}}})}else{P()}if(T){N.setOption("customFilter",R.filters);N.forceApplyFilters();N.setOption("customFilter",null)}}return N};this.forceApplyFilters=function(){if(typeof (N.lastFilters)!="undefined"){delete N.lastFilters}C=true;N.applyFilters(false,true);return N};this.applyFilters=function(U,X,P,V){var b=A(".toolbar-filter-overlay",O.context);if(X){clearTimeout(F)}var Q={filters:(!O.customFilter)?N.getSelectedFilters(b):O.customFilter,isAjaxTemplateRender:true,isAjaxTemplateRenderWithData:true};if(A.isEmptyObject(Q.filters)){return N}if(U){Q.filters["checkSince"]=E;Q.filters["pagenum"]=1}if(!V){var R=b.find('input[name="result-id"]').val(0);if(R.length){Q.filters["result-id"]=0}}else{C=true}if(typeof (this.lastFilters)!="undefined"&&vBulletin.areJsonObjectsEqual(this.lastFilters.filters,Q.filters)&&!U){return N}this.lastFilters=Q;var Y=A(".conversation-empty",O.context),T=A(".conversation-toolbar-wrapper",O.context);T.addClass("h-disabled");Y.addClass("h-invisible");if(U){window.vBulletin.loadingIndicator.suppressNextAjaxIndicator()}var a=vBulletin.normalizeAjaxUrl(b.attr("action"))||(vBulletin.getAjaxBaseurl()+"/activity/get");var Z=b.closest(".conversation-toolbar-wrapper").find('form.pagenav-form input[name="article_display_columns"]');if(Z.length==1){Q.article_display_columns=Z.val()}var W=A(".conversation-list",O.context);var S=function(c){W.addClass("h-hide");var d=vBulletin.phrase.get(c);Y.html((d||"").replace(/<br\s*\/*>/g," ")).removeClass("h-hide h-invisible")};vBulletin.AJAX({url:a,data:(Q),api_error:function(c){S(c[0])},emptyResponse:function(){S("invalid_server_response_please_try_again")},success:function(c){Y.addClass("h-hide");if(U){if(!J&&c.total>0&&!A("body").hasClass("edit-mode")){A(".new-conversations-strip span",O.context).html(c.total);A(".new-conversations-strip",O.context).fadeIn("slow")}if(A(".conversation-list li.list-item",O.context).length==0){Y.removeClass("h-hide")}}else{var f=A(".js-conversation-showmore",O.context);A(".new-conversations-strip",O.context).hide();if(((c.total_with_sticky>0)||(c.total>0))&&c.template){if(c.resultId){var e=A('input[name="result-id"]',b).val(c.resultId);if(e.length&&this.lastFilters){this.lastFilters.filters["result-id"]=c.resultId}if(O.pagination){O.pagination.updateResultId(c.resultId)}}if(P){W.append(c.template)}else{Y.addClass("h-hide");W.html(c.template).removeClass("h-hide")}if((Q.filters["maxpages"]&&Q.filters["pagenum"]>=Q.filters["maxpages"])||(c.pageinfo&&(Q.filters["pagenum"]>=c.pageinfo.totalpages||c.pageinfo.showseemore===false))){f.addClass("h-hide")}else{f.removeClass("h-hide")}}else{if(!P){Y.removeClass("h-hide");W.addClass("h-hide").empty()}}if(c.total_with_sticky==0){f.addClass("h-hide")}if(C&&O.scrollToTop){var d=(O.scrollToTop instanceof A)?O.scrollToTop:A(O.scrollToTop);if(d.length>0){A("body,html").animate({scrollTop:d.offset().top},"slow")}}E=c.lastDate;if(typeof O.onContentLoad=="function"){O.onContentLoad.apply(W.get(0),[c])}if(c.pageinfo){N.updatePageNumber(c.pageinfo.pagenumber||1);if(O.pagination&&typeof O.pagination.updatePageInfo=="function"){O.pagination.setOption("context",O.context);O.pagination.updatePageInfo(c.pageinfo,true)}}if(vBulletin.inlinemod&&typeof vBulletin.inlinemod.init=="function"&&A(".moderationmenu_container",O.context).length>0){vBulletin.inlinemod.init(O.context)}A(document).trigger("vb-filterposts",{parentOfInsertedHtml:W})}if(J){J=false}},error_phrase:"unable_to_contact_server_please_try_again",complete:function(){T.removeClass("h-disabled");Y.removeClass("h-invisible");if(!J&&O.autoCheck&&F){F=setTimeout(N.checkNewConversations,O.checkInterval)}}});return N};this.updatePageNumber=function(P){P=Number(P);if(P>0){A('form.toolbar-filter-overlay input[name="pagenum"]',O.context).val(P)}return N};this.checkNewConversations=function(){if(!A("body").hasClass("edit-mode")){console.log("Checking for new activity since "+E);N.applyFilters(true)}return N};this.toggleNewConversations=function(P){if(P){O.autoCheck=true;F=setTimeout(N.checkNewConversations,O.checkInterval)}else{O.autoCheck=false;clearTimeout(F)}return N};this.hideFilterOverlay=function(){A(".conversation-toolbar-wrapper .toolbar-filter-overlay",O.context).filter(":visible").each(function(){A(this).prev(".conversation-toolbar").find(".toolbar-filter").triggerHandler("click."+I,[0])});return N};this.getOption=function(P){return O[P]};this.setOption=function(P,Q){O[P]=Q;return N};if(O.autoCheck){E=pageData.current_server_datetime;F=setTimeout(N.checkNewConversations,O.checkInterval)}};vBulletin.conversation.displaySelectedFilterText=function(J,K,C){var L=A(J);if(L.data("bypass-filter-display")==1){return }C=C||L.closest(".conversation-toolbar-wrapper");var G=A(".filtered-by",C).removeClass("h-hide").find(".filter-text-wrapper").show(),B=A(".filter-text[data-filter-name={0}]".format(J.name),G),M='<div class="filter-text" data-filter-name="{0}" data-filter-value="{1}"><span title="{2}">{3}</span><span class="x b-icon b-icon__x-circle"></span></div>',E,F,I;if(J.type=="radio"){F=L.next("span").text();E=A(M.format(J.name,vBulletin.htmlEntities(J.value),L.closest(".filter-options").prev(".filter-header").html()+" - "+F,((J.name=="filter_new_topics"||J.name=="filter_depth"||(J.value.indexOf("_all")!=-1&&J.value!="time_all"))?(L.closest("li").find(".filter-header").html()||"")+" - ":"")+F))}else{if(J.type=="text"){K="&quot;"+JShtmlEncode(K)+"&quot;";E=A(M.format(J.name,vBulletin.htmlEntities(J.value),L.data("filter-name")+": "+K,K)).data("filter-type","text");I=L.attr("class").match(/js-.*/);if(I){E.data("filter-js-selector","."+I[0])}}}if(B.length>0){B.replaceWith(E)}else{var D=[],H=false;A(".toolbar-filter-overlay > ul > li",C).each(function(){D.push(A("input:first",this).attr("name"))});A(".filter-text",G).each(function(){var N=A(this);if(A.inArray(J.name,D)<A.inArray(N.attr("data-filter-name"),D)){N.before(E);H=true;return false}});if(!H){G.append(E)}if(A(".filter-text",G).length>1){G.next(".clear-all").removeClass("h-hide")}}}})(jQuery);