@searchstax-inc/searchstudio-ux-js 1.0.4 → 1.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- "use strict";var G=Object.defineProperty;var Y=(o,e,t)=>e in o?G(o,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):o[e]=t;var n=(o,e,t)=>(Y(o,typeof e!="symbol"?e+"":e,t),t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});var T=(o=>(o[o.mustache=0]="mustache",o[o.vue=1]="vue",o[o.react=2]="react",o[o.angular=3]="angular",o))(T||{});class Z{constructor(e){n(this,"dataLayer");this.dataLayer=e}get currentPage(){var e;return(e=this.dataLayer.searchObject)==null?void 0:e.page}get totalResults(){var e;return((e=this.dataLayer.searchResultsMetadata)==null?void 0:e.totalResultsValue)||0}get resultsPerPage(){return this.dataLayer.itemsPerPage||0}get sortOptions(){var e;return((e=this.dataLayer.searchResultsMetadata)==null?void 0:e.sorting.options)||[]}get selectedSortOption(){var e;return((e=this.dataLayer.searchResultsMetadata)==null?void 0:e.sorting.selectedSortOption)||""}get startResultIndex(){var e;return(((e=this.dataLayer.searchObject)==null?void 0:e.page)-1)*this.resultsPerPage+1}get endResultIndex(){var t;const e=(((t=this.dataLayer.searchObject)==null?void 0:t.page)-1)*this.resultsPerPage+(this.resultsPerPage??0);return e>this.totalResults?this.totalResults:e}get isFirstPage(){var e;return((e=this.dataLayer.searchObject)==null?void 0:e.page)===1}get isLastPage(){var e;return((e=this.dataLayer.searchObject)==null?void 0:e.page)>=Math.ceil(this.totalResults/this.resultsPerPage)}get percentageOfResultsLoaded(){return this.endResultIndex/this.totalResults*100}get results(){return this.dataLayer.searchResults??[]}get autoCorrectedQuery(){var e;return((e=this.dataLayer.searchResultsMetadata)==null?void 0:e.autoCorrectedQuery)||""}get originalQuery(){var e;return((e=this.dataLayer.searchObject)==null?void 0:e.query)||""}get getAnswerData(){return this.dataLayer.getAnswerData||""}get shouldShowAnswer(){return this.isFirstPage&&this.dataLayer.getAnswerData!==""&&this.dataLayer.searchObject.query!=="*"&&this.dataLayer.searchObject.facets.length===0}get searchTerm(){var e,t;return((e=this.dataLayer.searchResultsMetadata)==null?void 0:e.autoCorrectedQuery)||((t=this.dataLayer.searchObject)==null?void 0:t.query)||""}get searchingEverything(){return this.searchTerm==="*"}get firstSearchHappened(){return this.dataLayer.firstSearchHappened}get isInfiniteScroll(){return this.dataLayer.isInfiniteScroll??!1}get searchExecuted(){var e,t,a;return((e=this.dataLayer.searchObject)==null?void 0:e.query)!==void 0&&((t=this.dataLayer.searchObject)==null?void 0:t.query)!=="undefined"&&((a=this.dataLayer.searchObject)==null?void 0:a.query)!==""}get selectedFacets(){var t;const e=this.dataLayer.searchFacetsCached??this.dataLayer.searchFacets;return e?(((t=this.dataLayer.searchObject)==null?void 0:t.facets)??[]).map(r=>{const i=r.name,c=r.value,l=e.find(h=>h.name===i);if(l){const h=l.values.find(u=>u.type==="range"?!1:u.type==="checkbox"?'"'+u.value+'"'===c:!1);if(h)return h}return null}).filter(r=>r!==null):[]}get relatedSearches(){const e=this.dataLayer.searchRelatedSearches??[];return e[e.length-1]&&(e[e.length-1].last=!0),e}get externalPromotions(){return this.dataLayer.searchExternalPromotions??[]}get data(){return{currentPage:this.currentPage,totalResults:this.totalResults,resultsPerPage:this.resultsPerPage,startResultIndex:this.startResultIndex,endResultIndex:this.endResultIndex,isFirstPage:this.isFirstPage,isLastPage:this.isLastPage,results:this.results,searchTerm:this.searchTerm!=="undefined"?this.searchTerm:"",autoCorrectedQuery:this.autoCorrectedQuery,originalQuery:this.originalQuery,selectedFacets:this.selectedFacets,searchExecuted:this.searchExecuted,searchingEverything:this.searchingEverything,relatedSearches:this.relatedSearches,hasRelatedSearches:this.relatedSearches.length>0,externalPromotions:this.externalPromotions,hasExternalPromotions:this.externalPromotions.length>0,hasResults:this.results.length>0,hasResultsOrExternalPromotions:this.results.length>0||this.externalPromotions.length>0,answer:this.getAnswerData,shouldShowAnswer:this.shouldShowAnswer,isInfiniteScroll:this.isInfiniteScroll,percentageOfResultsLoaded:this.percentageOfResultsLoaded,firstSearchHappened:this.firstSearchHappened,sortOptions:this.sortOptions,selectedSortOption:this.selectedSortOption}}get trackingData(){var e,t,a,s;return{searchTerm:this.dataLayer.searchTerm!=="undefined"?this.dataLayer.searchTerm:"",trackApiKey:((e=this.dataLayer.searchstaxConfig)==null?void 0:e.trackApiKey)??"",session:this.dataLayer.sessionIdValue,language:this.dataLayer.language,recordsPerPage:((t=this.dataLayer.searchResultsMetadata)==null?void 0:t.recordsPerPageValue)??0,totalResults:((a=this.dataLayer.searchResultsMetadata)==null?void 0:a.totalResultsValue)??0,currentPage:this.dataLayer.currentPage,latencyVal:((s=this.dataLayer.searchResultsMetadata)==null?void 0:s.latency)??0}}}class P{static deepEqual(e,t){const a=Object.keys(e),s=Object.keys(t);if(a.length!==s.length)return!1;for(const r of a){const i=e[r],c=t[r],l=this.isObject(i)&&this.isObject(c);if(l&&!this.deepEqual(i,c)||!l&&i!==c)return!1}return!0}static isObject(e){return e!=null&&typeof e=="object"}}class b{constructor(e){n(this,"value");n(this,"observers",[]);this.value=e,this.observers=[]}subscribe(e){this.observers.push(e),e(this.value)}unsubscribe(e){const t=this.observers.indexOf(e);t!==-1&&this.observers.splice(t,1)}setValue(e){this.value=e,this.notify()}getValue(){return this.value}notify(){this.observers.forEach(e=>e(this.value))}}class Q{static getOrSetCookie(e,t){let a=this.getCookie(e);return a==null&&(a=t??this.makeid(25),this.setCookie(e,a,{secure:!0,"max-age":3600})),a}static deleteCookie(e){this.getCookie(e)&&this.setCookie(e,"",{secure:!0,"max-age":-1})}static makeid(e){let t="";const a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",s=a.length;for(let r=0;r<e;r++)t+=a.charAt(Math.floor(Math.random()*s));return t}static getCookie(e){const t=typeof document<"u"?document.cookie.match(new RegExp("(?:^|; )"+e.replace(/([.$?*|{}()[\]\\/+^])/g,"\\$1")+"=([^;]*)")):null;return t?decodeURIComponent(t[1]):void 0}static setCookie(e,t,a){const s={path:"/",...a};a.expires instanceof Date&&(s.expires=a.expires.toUTCString());let r=encodeURIComponent(e)+"="+encodeURIComponent(t);for(const i in s){r+="; "+i;const c=s[i];c!==!0&&(r+="="+c)}typeof document<"u"&&(document.cookie=r)}}class F{static removeXSSRiskyTags(e){var t="script|style|iframe|object|embed|form|input|button",a=new RegExp("</?("+t+")(\\s[^>]*)?>","gi");return e?e.replace(a,""):""}}class ee{constructor(e,t){n(this,"$searchTermChange",new b(""));n(this,"$loadingChange",new b(!1));n(this,"$searchResults",new b(null));n(this,"$searchResultsMetadata",new b(null));n(this,"$searchAutosuggest",new b(null));n(this,"$searchFacets",new b(null));n(this,"$searchFacetsCached",new b(null));n(this,"$searchstaxConfig",new b(null));n(this,"$autosuggestResults",new b(null));n(this,"$itemsPerPage",new b(void 0));n(this,"$searchObject",new b({query:"",itemsPerPage:null,page:99999999,order:"",facets:[],additionalProps:[]}));n(this,"$searchRelatedSearches",new b(null));n(this,"$searchInputConfig",new b(null));n(this,"$searchExternalPromotions",new b(null));n(this,"$facetsTemplateData",new b(null));n(this,"$selectedFacetsTemplateData",new b(null));n(this,"$paginationData",new b(null));n(this,"$searchFeedbackData",new b(null));n(this,"$searchSortingData",new b(null));n(this,"$searchRelatedSearchesData",new b(null));n(this,"$searchExternalPromotionsData",new b(null));n(this,"$cookiesDisabled",new b(null));n(this,"$answer",new b(""));n(this,"$language",new b("en"));n(this,"currentPageValue",1);n(this,"isAnswerWidgetCreatedValue",!1);n(this,"renderingEngineValue",T.mustache);n(this,"parsedData",new Z(this));n(this,"sessionId");n(this,"sessionIdValue",null);n(this,"autoCorrect",!0);n(this,"forceNotCorrect",!1);n(this,"lastSearchValue","");n(this,"turnAIAnswerGenerationOn",!1);n(this,"isInfiniteScroll",!1);n(this,"firstSearchHappened",!1);n(this,"facetsWereSet",!1);this.sessionId=e,t&&(this.sessionIdValue=t),this.cookieHandlingCallback(t),this.$cookiesDisabled.subscribe(()=>{this.cookieHandlingCallback(t)})}cookieHandlingCallback(e){this.cookiesDisabled?(this.sessionIdValue=null,Q.deleteCookie(this.sessionId),Q.deleteCookie("ms_visitorid")):this.sessionIdValue=Q.getOrSetCookie(this.sessionId,e)}setIsInfiniteScroll(e){this.isInfiniteScroll=e}setSearchTerm(e){this.$searchTermChange.setValue(F.removeXSSRiskyTags(e))}setRenderingEngine(e){this.renderingEngineValue=e}setCurrentPage(e){this.currentPageValue=e}setIsAnswerWidgetCreated(e){this.isAnswerWidgetCreatedValue=e}setLoading(e){this.$loadingChange.setValue(e)}setSearchResults(e){this.firstSearchHappened=!0,(!P.deepEqual(e,this.searchResults??[""])||this.facetsWereSet)&&(this.facetsWereSet=!1,this.$searchResults.setValue(e))}setSearchResultsMetadata(e){P.deepEqual(e,this.searchResultsMetadata??{})||this.$searchResultsMetadata.setValue(e)}setSearchAutosuggest(e){this.$searchAutosuggest.setValue(e)}setSearchObject(e){var a,s;let t=e;t={...t,itemsPerPage:this.itemsPerPage},(s=(a=this.searchstaxConfig)==null?void 0:a.hooks)!=null&&s.beforeSearch&&t&&(t=this.searchstaxConfig.hooks.beforeSearch(t)),t&&(!P.deepEqual(t,this.searchObject??{})||this.forceNotCorrect)&&this.$searchObject.setValue(t)}setSearchFacets(e){this.facetsWereSet=!0,P.deepEqual(e,this.searchFacets??[])||this.$searchFacets.setValue(e)}setSearchFacetsCached(e){P.deepEqual(e,this.searchFacetsCached??[])||this.$searchFacetsCached.setValue(e)}setSearchRelatedSearches(e){P.deepEqual(e,this.searchRelatedSearches??[])||this.$searchRelatedSearches.setValue(e)}setSearchExternalPromotions(e){P.deepEqual(e,this.searchExternalPromotions??[])||this.$searchExternalPromotions.setValue(e)}setLanguage(e){this.$language.setValue(e)}setSearchstaxConfig(e){this.$searchstaxConfig.setValue(e)}setSearchInputConfig(e){this.$searchInputConfig.setValue(e)}setAutosuggestResults(e){this.$autosuggestResults.setValue(e)}setFacetsTemplateData(e){this.$facetsTemplateData.setValue(e)}setSelectedFacetsTemplateData(e){this.$selectedFacetsTemplateData.setValue(e)}setPaginationData(e){this.$paginationData.setValue(e)}setSearchFeedbackData(e){this.$searchFeedbackData.setValue(e)}setSearchSortingData(e){this.$searchSortingData.setValue(e)}setRelatedSearchesData(e){this.$searchRelatedSearchesData.setValue(e)}setExternalPromotionsData(e){this.$searchExternalPromotionsData.setValue(e)}setCookiesDisabled(e){this.$cookiesDisabled.setValue(e)}setAnswerData(e){this.$answer.setValue(e)}setItemsPerPage(e){this.$itemsPerPage.setValue(e)}get getAnswerData(){return this.$answer.getValue()}get searchstaxConfig(){return this.$searchstaxConfig.getValue()}get searchFacets(){return this.$searchFacets.getValue()?JSON.parse(JSON.stringify(this.$searchFacets.getValue())):null}get searchFacetsCached(){return this.$searchFacetsCached.getValue()?JSON.parse(JSON.stringify(this.$searchFacetsCached.getValue())):null}get searchResults(){return this.$searchResults.getValue()?JSON.parse(JSON.stringify(this.$searchResults.getValue())):null}get searchTerm(){return this.$searchTermChange.getValue()}get loading(){return this.$loadingChange.getValue()}get searchAutosuggest(){return this.$searchAutosuggest.getValue()}get searchResultsMetadata(){return this.$searchResultsMetadata.getValue()?JSON.parse(JSON.stringify(this.$searchResultsMetadata.getValue())):null}get currentPage(){return this.$searchObject.getValue().page??this.currentPageValue}get isAnswerWidgetCreated(){return this.isAnswerWidgetCreatedValue}get renderingEngine(){return this.renderingEngineValue}get searchObject(){return JSON.parse(JSON.stringify(this.$searchObject.getValue()))}get searchRelatedSearches(){return this.$searchRelatedSearches.getValue()?JSON.parse(JSON.stringify(this.$searchRelatedSearches.getValue())):null}get searchExternalPromotions(){return this.$searchExternalPromotions.getValue()?JSON.parse(JSON.stringify(this.$searchExternalPromotions.getValue())):null}get language(){return this.$language.getValue()}get searchInputConfig(){return this.$searchInputConfig.getValue()}get answerConfig(){return this.$answer.getValue()}get autosuggestResults(){return this.$autosuggestResults.getValue()}get facetsTemplateData(){return this.$facetsTemplateData.getValue()}get selectedFacetsTemplateData(){return this.$selectedFacetsTemplateData.getValue()}get paginationData(){return this.$paginationData.getValue()}get searchFeedbackData(){return this.$searchFeedbackData.getValue()}get searchSortingData(){return this.$searchSortingData.getValue()}get searchRelatedSearchesData(){return this.$searchRelatedSearchesData.getValue()}get searchExternalPromotionsData(){return this.$searchExternalPromotionsData.getValue()}get cookiesDisabled(){return(this.$cookiesDisabled.getValue()??!1)||!navigator.cookieEnabled}get itemsPerPage(){return this.$itemsPerPage.getValue()}}class B{static combineResultsWithMetadata(e){const t=[],a=parseInt(e.response.start+"");return e.response.docs.forEach((s,r)=>{const i=s[e.responseHeader.params.uniqueId]??"",c={custom:null,uniqueId:i,position:a+1+r,ribbon:this.doesMapExist("ribbon",e)?this.getValueByKey("ribbon",s,e,i):null,paths:this.doesMapExist("paths",e)?this.getValueByKey("paths",s,e,i):null,url:this.doesMapExist("url",e)?this.getValueByKey("url",s,e,i):null,title:this.doesMapExist("title",e)?this.getValueByKey("title",s,e,i):null,titleTracking:this.doesMapExist("title",e)?this.getValueByKey("title",s,e,i,!0):null,promoted:s["[elevated]"]?s["[elevated]"]:!1,thumbnail:this.doesMapExist("thumbnail",e)?this.getValueByKey("thumbnail",s,e,i):null,date:this.doesMapExist("date",e)?this.getValueByKey("date",s,e,i):null,snippet:this.doesMapExist("snippet",e)?this.getValueByKey("snippet",s,e,i):null,description:this.doesMapExist("description",e)?this.getValueByKey("description",s,e,i):null,unmappedFields:this.getUnmappedFields(s,e,i),allFields:this.getAllFields(s,e)};t.push(c)}),t}static extractFacets(e){const t=[];if(e.metadata.facets)for(const a of e.metadata.facets){let s={values:[]};if(s.name=a.name,s.label=a.label,a.name in e.facet_counts.facet_fields){const r=e.facet_counts.facet_fields[a.name];for(let i=0;i<r.length;i+=2){const c={};c.value=r[i],c.parentName=s.name,c.count=r[i+1],c.type="checkbox",s.values.push(c)}}s.values.length>0&&t.push(s)}return t}static extractSearchResultsMetadata(e){var r,i,c,l,h,u;let t="",a={selectedSortOption:"",options:[]},s=(r=e.metadata.results.find(p=>p.result_card==="date"))==null?void 0:r.name;if(a.options=[{key:"",value:"Relevance"},{key:s+" desc",value:"Most Recent"}],(i=e.metadata.sorts)!=null&&i.length){const p=e.metadata.sorts.map(d=>({value:d.label,key:d.name+" "+d.order}));a.options=[{key:"",value:"Relevance"},...p]}return t=((u=(h=(l=(c=e==null?void 0:e.spellcheck)==null?void 0:c.suggestions)==null?void 0:l[1])==null?void 0:h.suggestion)==null?void 0:u[0])??"",typeof t!="string"&&(t=(t==null?void 0:t.word)??""),{recordsPerPageValue:parseInt(e.responseHeader.params.rows),startDocVal:parseInt(e.response.start+""),totalResultsValue:parseInt(e.response.numFound+""),latency:parseInt(e.responseHeader.QTime+""),endDocValue:parseInt(e.responseHeader.params.rows)+parseInt(e.response.start+""),spellingSuggestion:t,autoCorrectedQuery:e.responseHeader.params.autoCorrectedQ??"",impressions:this.getImpressions(e),sorting:a}}static getImpressions(e){const t=[],a=this.combineResultsWithMetadata(e);for(const s in a){const r=a[s],i={};i.cDocId=this.getDataForAnalytics(r.uniqueId),r.title&&(i.cDocTitle=this.getDataForAnalytics(r.title)),i.position=r.position,t.push(i)}return t}static getDataForAnalytics(e){return e!==null?typeof e>"u"?"":typeof e=="string"?e:typeof e.join<"u"?e[0]:e:""}static findResultByUniqueId(e,t){return t.find(a=>a.uniqueId===e)??null}static getUnmappedFields(e,t,a){const s=t.metadata.results.filter(i=>i.result_card==="").map(i=>i.name),r=[];for(const i of Object.keys(e))if(s.indexOf(i)!==-1){const c=Array.isArray(e[i])?this.getHighlightedResults(i,e[i].join(", "),a,t):this.getHighlightedResults(i,e[i]+"",a,t);r.push({key:i,value:c,isImage:this.checkIfImage(e[i])})}return r}static checkIfImage(e){return e===void 0?!1:typeof e!="string"?Array.isArray(e)&&e[0]?/\.(gif|jpe?g|tiff?|png|webp|bmp)$/i.test(e[0]):!1:/\.(gif|jpe?g|tiff?|png|webp|bmp)$/i.test(e)}static getAllFields(e,t){const a=t.metadata.results.map(r=>r.name),s=[];for(const r of Object.keys(e))a.indexOf(r)!==-1&&s.push({key:r,value:e[r],isImage:this.checkIfImage(e[r])});return s}static doesMapExist(e,t){return t.metadata.results.find(a=>a.result_card===e)!==void 0}static getValueByKey(e,t,a,s,r=!1){const i=a.metadata.results.find(l=>l.result_card===e);if(i===void 0)return null;const c=t[i.name];return c===void 0?null:typeof c=="string"?r?c:this.getHighlightedResults(i.name,c,s,a):Array.isArray(c)?r?c.join(", "):this.getHighlightedResults(i.name,c.join(", "),s,a):null}static getHighlightedResults(e,t,a,s){if(s.highlighting&&a in s.highlighting){let r=s.highlighting[a];if(r&&e in r){let i=r[e];const c=this.cleanValue(i);if(c!=="")return c}}return t}static cleanValue(e){return e===null?"":typeof e=="string"?e:Array.isArray(e)?e.join(" "):""}}class z{constructor(e){n(this,"routeName","searchstax");n(this,"ignoredKeys",[]);n(this,"queryStringHelper");n(this,"titleParser");e.routeName&&(this.routeName=e.routeName),e.ignoredKeys&&(this.ignoredKeys=e.ignoredKeys),e.title&&(this.titleParser=e.title),this.queryStringHelper=new te(this.routeName)}updateUrl(e){const t=this.searchObjectToUrl(e);let a=typeof document<"u"?document==null?void 0:document.title:"";this.titleParser&&(a=this.titleParser(e)),typeof document<"u"&&(document.title=a),(window==null?void 0:window.location.href)!==t&&(window==null||window.history.pushState({},a,t))}searchObjectToUrl(e){return this.queryStringHelper.urlHasQueryParams((window==null?void 0:window.location.href)??"")?(window==null?void 0:window.location.href.split("?")[0])+"?"+this.queryStringHelper.stringify(this.searchObjectToParams(e),{ignoredKeys:this.ignoredKeys}):(window==null?void 0:window.location.href)+"?"+this.queryStringHelper.stringify(this.searchObjectToParams(e),{ignoredKeys:this.ignoredKeys})}searchObjectToParams(e){const t={},a=e.page||1;if(e.query&&(t[this.routeName+"[query]"]=encodeURIComponent(e.query)),e.page&&(t[this.routeName+"[page]"]=a+""),e.order&&(t[this.routeName+"[order]"]=e.order),e.facets)for(const s in e.facets){const r=e.facets[s].type+":"+encodeURIComponent(e.facets[s].name)+":"+encodeURIComponent(e.facets[s].value);t[this.routeName+`[facets][${s}]`]=r}if(this.queryStringHelper.urlHasQueryParams((window==null?void 0:window.location.href)??"")){const s=this.queryStringHelper.urlToParams((window==null?void 0:window.location.href)??"");for(const r in s)r.startsWith(this.routeName)&&delete s[r];return{...s,...t}}else return t}extractParamsThatDoNotStartWithRouteName(e){const t={};for(const a in e)a.startsWith(this.routeName)||(t[a]=e[a]);return t}extractArrayOfFacetsFromQueryParameters(e){var a,s,r;const t=[];for(const i in e)if(i.startsWith(this.routeName+"[facets]")){const c=F.removeXSSRiskyTags((a=e[i].split(":"))==null?void 0:a[0]),l=F.removeXSSRiskyTags(decodeURIComponent((s=e[i].split(":"))==null?void 0:s[1])),h=F.removeXSSRiskyTags(decodeURIComponent((r=e[i].split(":"))==null?void 0:r[2]));t.push({type:c,name:l,value:h})}return t}urlToSearchObject(e,t){const a=this.queryStringHelper.urlToParams(e),s=F.removeXSSRiskyTags(decodeURIComponent(a[this.routeName+"[page]"])),r=parseInt(s),i=isNaN(r)?1:r;return{query:F.removeXSSRiskyTags(decodeURIComponent(a[this.routeName+"[query]"]))||"",page:i,itemsPerPage:t,order:F.removeXSSRiskyTags(a[this.routeName+"[order]"])||"",facets:this.extractArrayOfFacetsFromQueryParameters(a)||[]}}}class te{constructor(e){n(this,"routeName","");n(this,"stringify",(e,t)=>{const a=this.filterOutIgnoredKeys(e,t.ignoredKeys);return Object.keys(a).map(s=>{const r=a[s];return Array.isArray(r)?r.map(i=>`${s}=${i}`).join("&"):`${s}=${r}`}).join("&")});this.routeName=e}filterOutIgnoredKeys(e,t){const a=t||[],s={};return Object.keys(e).forEach(r=>{a.includes(r)||e[r]!==""&&(s[r]=e[r])}),s}urlToParams(e){const t={},a=e.split("?")[1];return a&&a.split("&").forEach(s=>{const[r,i]=s.split("=");t[r]=i}),t}doesParamContainRouteName(e){return e.indexOf(this.routeName)!==-1}urlHasQueryParams(e){return e.indexOf("?")!==-1}}const D={questionURL:"http://smartsearch-dev.searchstax.co/completion/?q=",question:"I_AM_A_QUESTION",notQuestion:"I_AM_NOT_A_QUESTION",close:"CLOSE"};class ae{constructor(e,t){n(this,"cachedQuery","");n(this,"url","");n(this,"relatedSearches","");n(this,"suggester","");n(this,"authHeader");n(this,"authHeaderRelated");n(this,"trackApiKey","");n(this,"session","");n(this,"searchAuthType");n(this,"searchAuth","");n(this,"controllerSearch");n(this,"signalSearch");n(this,"controllerSuggest");n(this,"signalSuggest");n(this,"dataLayer");this.dataLayer=t,this.url=e.searchURL,this.dataLayer.setLanguage(e.language),this.suggester=e.suggesterURL,this.trackApiKey=e.trackApiKey,this.session=e.sessionId,this.searchAuthType=e.authType,this.searchAuth=e.searchAuth,this.authHeader=new Headers,this.authHeader.append("Accept","application/json");const a=this.searchAuthType==="token"?`Token ${e.searchAuth}`:`Basic ${e.searchAuth}`;this.authHeader.append("Authorization",a),this.authHeaderRelated=new Headers,this.authHeaderRelated.append("Accept","application/json"),this.authHeaderRelated.append("Authorization",e.searchAuth)}generateFacetQuery(e,t){let a=[];if(!t)e.forEach(function(s){const r=s.name+':"'+s.value+'"';a=a.concat("fq="+decodeURIComponent(r).replace(" "," "))});else{const s={};e.forEach(function(r){const i=r.name+":"+r.value,c=decodeURIComponent(i).replace(" "," ").split(":");s[c[0]]?s[c[0]].push(c[1]):s[c[0]]=[c[1]]});for(const r in s)if(Object.prototype.hasOwnProperty.call(s,r)){const i=s[r],c=r;let l="";for(const h of i)l+=` ${c}:"${h}"`;a=a.concat("fq="+l.trim())}}return a.length?"&"+a.join("&"):""}getRelatedSearches(e,t,a,s){const r=new Headers;r.append("Accept","application/json"),r.append("Authorization",a),fetch(t+"?search="+encodeURIComponent(e.query)+"&language="+this.dataLayer.language,{method:"GET",headers:r,credentials:"same-origin"}).then(i=>i.json()).then(i=>{s(i)})}cacheFacets(){this.dataLayer.searchObject.query!==this.cachedQuery&&(this.cachedQuery=this.dataLayer.searchObject.query,this.search({query:this.dataLayer.searchObject.query??"*",itemsPerPage:void 0,page:1,order:"",facets:[],additionalProps:this.dataLayer.searchObject.additionalProps},this.cacheFacetsCallback.bind(this),!0))}cacheFacetsCallback(e){let t=B.extractFacets(e);this.dataLayer.setSearchFacetsCached(t)}search(e,t,a=!1,s=!1){if(e.query&&e.query!=="undefined"){this.dataLayer.setSearchTerm(e.query),this.dataLayer.setLoading(!0),this.controllerSearch&&this.controllerSearch.abort(),this.controllerSearch=new AbortController,this.signalSearch=this.controllerSearch.signal;const r=new Proxy(new URLSearchParams((window==null?void 0:window.location.search)??""),{get:(d,f)=>d.get(f)??""}),i=r.languageVariant?"&fq=_language:"+r.languageVariant:"";let c=e.itemsPerPage,l=(e.itemsPerPage?e.itemsPerPage:0)*(e.page-1),h=e.order?`&sort=${e.order}`:"";const u=this.url+"?q="+encodeURIComponent(e.query.trim())+"&start="+l+this.toQueryString(e.additionalProps??[])+this.generateFacetQuery(e.facets.filter(d=>d.type==="or"||d.type==="showUnavailable"),!0)+this.generateFacetQuery(e.facets.filter(d=>d.type==="and"||d.type==="tabs"),!1)+h+`&spellcheck.correct=${this.dataLayer.autoCorrect&&!s}`+(c?`&rows=${c}`:"")+"&language="+this.dataLayer.language+i,p={method:"GET",headers:this.authHeader,credentials:"same-origin",signal:this.signalSearch};a&&delete p.signal,fetch(u,p).then(d=>d.json()).then(d=>{this.dataLayer.setLoading(!1),t(d)}).catch(()=>{this.dataLayer.setLoading(!1)})}}startSSE(e,t){if(!this.dataLayer.turnAIAnswerGenerationOn||e==="*"||this.dataLayer.lastSearchValue===e||this.dataLayer.searchObject.facets.length>0||this.dataLayer.searchObject.page!==1)return;const a=new EventSource(D.questionURL+e),s=this.dataLayer;a.onmessage=function(r){if(r.data===D.question||r.data===D.notQuestion){s.setAnswerData("");return}if(r.data===D.close){a.close();return}t(r.data)},a.onerror=function(){a.close()}}suggest(e,t,a){this.controllerSuggest&&this.controllerSuggest.abort(),this.controllerSuggest=new AbortController,this.signalSuggest=this.controllerSuggest.signal;const s=this.suggester+"?q="+e.trim()+this.toQueryString(a)+"&language="+this.dataLayer.language;fetch(s,{method:"GET",headers:this.authHeader,credentials:"same-origin",signal:this.signalSuggest}).then(r=>r.json()).then(r=>{t(r)}).catch(()=>()=>{})}fields(){return this.fields}toQueryString(e){if(e.length===0)return"";const t=[];for(const a of e)t.push(encodeURIComponent(a.key)+"="+encodeURIComponent(a.value));return"&"+t.join("&")}}class O{static trackClick(e){const t={key:e.trackApiKey,query:e.searchTerm,shownHits:e.recordsPerPage,totalHits:e.totalResults,pageNo:e.currentPage,latency:e.latencyVal,session:e.session,cDocId:e.result.uniqueId,cDocTitle:e.result.titleTracking,position:e.result.position,language:e.language};return new Promise((a,s)=>{const r=["trackClick",t];t.key&&this.msq().push(r,(function(i,c){JSON.stringify(i)===JSON.stringify(t)&&c?a():s()}).bind(this))})}static trackSearch(e){const t={key:e.trackApiKey,query:e.searchTerm,shownHits:e.recordsPerPage,totalHits:e.totalResults,pageNo:e.currentPage,latency:e.latencyVal,session:e.session,language:e.language,impressions:e.impressions};setTimeout(()=>{t.key&&this.msq().push(["track",t])},0)}static trackRelatedSearchClick(e){const t={session:e.session,key:e.trackApiKey,query:e.relatedSearch.search_term,position:e.relatedSearch.position,relatedSearch:e.relatedSearch.related_search,pageNo:e.currentPage,shownHits:e.recordsPerPage,totalHits:e.totalResults,language:e.language};setTimeout(()=>{t.key&&this.msq().push(["trackRelatedSearchClick",t])},0)}static trackRelatedSearches(e){const t={session:e.session,key:e.trackApiKey,query:e.searchTerm,shownHits:e.recordsPerPage,latency:e.latencyVal,language:e.language,impressions:e.impressions};setTimeout(()=>{t.key&&this.msq().push(["trackRelatedSearch",t])},0)}}n(O,"subscribedToClickEvent",!1),n(O,"msq",()=>typeof window<"u"&&(window!=null&&window._msq)?window==null?void 0:window._msq:[]);/*!
1
+ "use strict";var G=Object.defineProperty;var Y=(o,e,t)=>e in o?G(o,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):o[e]=t;var n=(o,e,t)=>(Y(o,typeof e!="symbol"?e+"":e,t),t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});var T=(o=>(o[o.mustache=0]="mustache",o[o.vue=1]="vue",o[o.react=2]="react",o[o.angular=3]="angular",o))(T||{});class Z{constructor(e){n(this,"dataLayer");this.dataLayer=e}get currentPage(){var e;return(e=this.dataLayer.searchObject)==null?void 0:e.page}get totalResults(){var e;return((e=this.dataLayer.searchResultsMetadata)==null?void 0:e.totalResultsValue)||0}get resultsPerPage(){return this.dataLayer.itemsPerPage||0}get sortOptions(){var e;return((e=this.dataLayer.searchResultsMetadata)==null?void 0:e.sorting.options)||[]}get selectedSortOption(){var e;return((e=this.dataLayer.searchResultsMetadata)==null?void 0:e.sorting.selectedSortOption)||""}get startResultIndex(){var e;return(((e=this.dataLayer.searchObject)==null?void 0:e.page)-1)*this.resultsPerPage+1}get endResultIndex(){var t;const e=(((t=this.dataLayer.searchObject)==null?void 0:t.page)-1)*this.resultsPerPage+(this.resultsPerPage??0);return e>this.totalResults?this.totalResults:e}get isFirstPage(){var e;return((e=this.dataLayer.searchObject)==null?void 0:e.page)===1}get isLastPage(){var e;return((e=this.dataLayer.searchObject)==null?void 0:e.page)>=Math.ceil(this.totalResults/this.resultsPerPage)}get percentageOfResultsLoaded(){return this.endResultIndex/this.totalResults*100}get results(){return this.dataLayer.searchResults??[]}get autoCorrectedQuery(){var e;return((e=this.dataLayer.searchResultsMetadata)==null?void 0:e.autoCorrectedQuery)||""}get originalQuery(){var e;return((e=this.dataLayer.searchObject)==null?void 0:e.query)||""}get getAnswerData(){return this.dataLayer.getAnswerData||""}get shouldShowAnswer(){return this.isFirstPage&&this.dataLayer.getAnswerData!==""&&this.dataLayer.searchObject.query!=="*"&&this.dataLayer.searchObject.facets.length===0}get searchTerm(){var e,t;return((e=this.dataLayer.searchResultsMetadata)==null?void 0:e.autoCorrectedQuery)||((t=this.dataLayer.searchObject)==null?void 0:t.query)||""}get searchingEverything(){return this.searchTerm==="*"}get firstSearchHappened(){return this.dataLayer.firstSearchHappened}get isInfiniteScroll(){return this.dataLayer.isInfiniteScroll??!1}get searchExecuted(){var e,t,a;return((e=this.dataLayer.searchObject)==null?void 0:e.query)!==void 0&&((t=this.dataLayer.searchObject)==null?void 0:t.query)!=="undefined"&&((a=this.dataLayer.searchObject)==null?void 0:a.query)!==""}get selectedFacets(){var t;const e=this.dataLayer.searchFacetsCached??this.dataLayer.searchFacets;return e?(((t=this.dataLayer.searchObject)==null?void 0:t.facets)??[]).map(r=>{const i=r.name,c=r.value,l=e.find(h=>h.name===i);if(l){const h=l.values.find(u=>u.type==="range"?!1:u.type==="checkbox"?'"'+u.value+'"'===c:!1);if(h)return h}return null}).filter(r=>r!==null):[]}get relatedSearches(){const e=this.dataLayer.searchRelatedSearches??[];return e[e.length-1]&&(e[e.length-1].last=!0),e}get externalPromotions(){return this.dataLayer.searchExternalPromotions??[]}get data(){return{currentPage:this.currentPage,totalResults:this.totalResults,resultsPerPage:this.resultsPerPage,startResultIndex:this.startResultIndex,endResultIndex:this.endResultIndex,isFirstPage:this.isFirstPage,isLastPage:this.isLastPage,results:this.results,searchTerm:this.searchTerm!=="undefined"?this.searchTerm:"",autoCorrectedQuery:this.autoCorrectedQuery,originalQuery:this.originalQuery,selectedFacets:this.selectedFacets,searchExecuted:this.searchExecuted,searchingEverything:this.searchingEverything,relatedSearches:this.relatedSearches,hasRelatedSearches:this.relatedSearches.length>0,externalPromotions:this.externalPromotions,hasExternalPromotions:this.externalPromotions.length>0,hasResults:this.results.length>0,hasResultsOrExternalPromotions:this.results.length>0||this.externalPromotions.length>0,answer:this.getAnswerData,shouldShowAnswer:this.shouldShowAnswer,isInfiniteScroll:this.isInfiniteScroll,percentageOfResultsLoaded:this.percentageOfResultsLoaded,firstSearchHappened:this.firstSearchHappened,sortOptions:this.sortOptions,selectedSortOption:this.selectedSortOption}}get trackingData(){var e,t,a,s;return{searchTerm:this.dataLayer.searchTerm!=="undefined"?this.dataLayer.searchTerm:"",trackApiKey:((e=this.dataLayer.searchstaxConfig)==null?void 0:e.trackApiKey)??"",session:this.dataLayer.sessionIdValue,language:this.dataLayer.language,recordsPerPage:((t=this.dataLayer.searchResultsMetadata)==null?void 0:t.recordsPerPageValue)??0,totalResults:((a=this.dataLayer.searchResultsMetadata)==null?void 0:a.totalResultsValue)??0,currentPage:this.dataLayer.currentPage,latencyVal:((s=this.dataLayer.searchResultsMetadata)==null?void 0:s.latency)??0}}}class P{static deepEqual(e,t){const a=Object.keys(e),s=Object.keys(t);if(a.length!==s.length)return!1;for(const r of a){const i=e[r],c=t[r],l=this.isObject(i)&&this.isObject(c);if(l&&!this.deepEqual(i,c)||!l&&i!==c)return!1}return!0}static isObject(e){return e!=null&&typeof e=="object"}}class b{constructor(e){n(this,"value");n(this,"observers",[]);this.value=e,this.observers=[]}subscribe(e){this.observers.push(e),e(this.value)}unsubscribe(e){const t=this.observers.indexOf(e);t!==-1&&this.observers.splice(t,1)}setValue(e){this.value=e,this.notify()}getValue(){return this.value}notify(){this.observers.forEach(e=>e(this.value))}}class Q{static getOrSetCookie(e,t){let a=this.getCookie(e);return a==null&&(a=t??this.makeid(25),this.setCookie(e,a,{secure:!0,"max-age":3600})),a}static deleteCookie(e){this.getCookie(e)&&this.setCookie(e,"",{secure:!0,"max-age":-1})}static makeid(e){let t="";const a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",s=a.length;for(let r=0;r<e;r++)t+=a.charAt(Math.floor(Math.random()*s));return t}static getCookie(e){const t=typeof document<"u"?document.cookie.match(new RegExp("(?:^|; )"+e.replace(/([.$?*|{}()[\]\\/+^])/g,"\\$1")+"=([^;]*)")):null;return t?decodeURIComponent(t[1]):void 0}static setCookie(e,t,a){const s={path:"/",...a};a.expires instanceof Date&&(s.expires=a.expires.toUTCString());let r=encodeURIComponent(e)+"="+encodeURIComponent(t);for(const i in s){r+="; "+i;const c=s[i];c!==!0&&(r+="="+c)}typeof document<"u"&&(document.cookie=r)}}class F{static removeXSSRiskyTags(e){var t="script|style|iframe|object|embed|form|input|button",a=new RegExp("</?("+t+")(\\s[^>]*)?>","gi");return e?e.replace(a,""):""}}class ee{constructor(e,t){n(this,"$searchTermChange",new b(""));n(this,"$loadingChange",new b(!1));n(this,"$searchResults",new b(null));n(this,"$searchResultsMetadata",new b(null));n(this,"$searchAutosuggest",new b(null));n(this,"$searchFacets",new b(null));n(this,"$searchFacetsCached",new b(null));n(this,"$searchstaxConfig",new b(null));n(this,"$autosuggestResults",new b(null));n(this,"$itemsPerPage",new b(void 0));n(this,"$searchObject",new b({query:"",itemsPerPage:null,page:99999999,order:"",facets:[],additionalProps:[]}));n(this,"$searchRelatedSearches",new b(null));n(this,"$searchInputConfig",new b(null));n(this,"$searchExternalPromotions",new b(null));n(this,"$facetsTemplateData",new b(null));n(this,"$selectedFacetsTemplateData",new b(null));n(this,"$paginationData",new b(null));n(this,"$searchFeedbackData",new b(null));n(this,"$searchSortingData",new b(null));n(this,"$searchRelatedSearchesData",new b(null));n(this,"$searchExternalPromotionsData",new b(null));n(this,"$cookiesDisabled",new b(null));n(this,"$answer",new b(""));n(this,"$language",new b("en"));n(this,"currentPageValue",1);n(this,"isAnswerWidgetCreatedValue",!1);n(this,"renderingEngineValue",T.mustache);n(this,"parsedData",new Z(this));n(this,"sessionId");n(this,"sessionIdValue",null);n(this,"autoCorrect",!0);n(this,"forceNotCorrect",!1);n(this,"lastSearchValue","");n(this,"turnAIAnswerGenerationOn",!1);n(this,"isInfiniteScroll",!1);n(this,"firstSearchHappened",!1);n(this,"facetsWereSet",!1);this.sessionId=e,t&&(this.sessionIdValue=t),this.cookieHandlingCallback(t),this.$cookiesDisabled.subscribe(()=>{this.cookieHandlingCallback(t)})}cookieHandlingCallback(e){this.cookiesDisabled?(this.sessionIdValue=null,Q.deleteCookie(this.sessionId),Q.deleteCookie("ms_visitorid")):this.sessionIdValue=Q.getOrSetCookie(this.sessionId,e)}setIsInfiniteScroll(e){this.isInfiniteScroll=e}setSearchTerm(e){this.$searchTermChange.setValue(F.removeXSSRiskyTags(e))}setRenderingEngine(e){this.renderingEngineValue=e}setCurrentPage(e){this.currentPageValue=e}setIsAnswerWidgetCreated(e){this.isAnswerWidgetCreatedValue=e}setLoading(e){this.$loadingChange.setValue(e)}setSearchResults(e){this.firstSearchHappened=!0,(!P.deepEqual(e,this.searchResults??[""])||this.facetsWereSet)&&(this.facetsWereSet=!1,this.$searchResults.setValue(e))}setSearchResultsMetadata(e){P.deepEqual(e,this.searchResultsMetadata??{})||this.$searchResultsMetadata.setValue(e)}setSearchAutosuggest(e){this.$searchAutosuggest.setValue(e)}setSearchObject(e){var a,s;let t=e;t={...t,itemsPerPage:this.itemsPerPage},(s=(a=this.searchstaxConfig)==null?void 0:a.hooks)!=null&&s.beforeSearch&&t&&(t=this.searchstaxConfig.hooks.beforeSearch(t)),t&&(!P.deepEqual(t,this.searchObject??{})||this.forceNotCorrect)&&this.$searchObject.setValue(t)}setSearchFacets(e){this.facetsWereSet=!0,P.deepEqual(e,this.searchFacets??[])||this.$searchFacets.setValue(e)}setSearchFacetsCached(e){P.deepEqual(e,this.searchFacetsCached??[])||this.$searchFacetsCached.setValue(e)}setSearchRelatedSearches(e){P.deepEqual(e,this.searchRelatedSearches??[])||this.$searchRelatedSearches.setValue(e)}setSearchExternalPromotions(e){P.deepEqual(e,this.searchExternalPromotions??[])||this.$searchExternalPromotions.setValue(e)}setLanguage(e){this.$language.setValue(e)}setSearchstaxConfig(e){this.$searchstaxConfig.setValue(e)}setSearchInputConfig(e){this.$searchInputConfig.setValue(e)}setAutosuggestResults(e){this.$autosuggestResults.setValue(e)}setFacetsTemplateData(e){this.$facetsTemplateData.setValue(e)}setSelectedFacetsTemplateData(e){this.$selectedFacetsTemplateData.setValue(e)}setPaginationData(e){this.$paginationData.setValue(e)}setSearchFeedbackData(e){this.$searchFeedbackData.setValue(e)}setSearchSortingData(e){this.$searchSortingData.setValue(e)}setRelatedSearchesData(e){this.$searchRelatedSearchesData.setValue(e)}setExternalPromotionsData(e){this.$searchExternalPromotionsData.setValue(e)}setCookiesDisabled(e){this.$cookiesDisabled.setValue(e)}setAnswerData(e){this.$answer.setValue(e)}setItemsPerPage(e){this.$itemsPerPage.setValue(e)}get getAnswerData(){return this.$answer.getValue()}get searchstaxConfig(){return this.$searchstaxConfig.getValue()}get searchFacets(){return this.$searchFacets.getValue()?JSON.parse(JSON.stringify(this.$searchFacets.getValue())):null}get searchFacetsCached(){return this.$searchFacetsCached.getValue()?JSON.parse(JSON.stringify(this.$searchFacetsCached.getValue())):null}get searchResults(){return this.$searchResults.getValue()?JSON.parse(JSON.stringify(this.$searchResults.getValue())):null}get searchTerm(){return this.$searchTermChange.getValue()}get loading(){return this.$loadingChange.getValue()}get searchAutosuggest(){return this.$searchAutosuggest.getValue()}get searchResultsMetadata(){return this.$searchResultsMetadata.getValue()?JSON.parse(JSON.stringify(this.$searchResultsMetadata.getValue())):null}get currentPage(){return this.$searchObject.getValue().page??this.currentPageValue}get isAnswerWidgetCreated(){return this.isAnswerWidgetCreatedValue}get renderingEngine(){return this.renderingEngineValue}get searchObject(){return JSON.parse(JSON.stringify(this.$searchObject.getValue()))}get searchRelatedSearches(){return this.$searchRelatedSearches.getValue()?JSON.parse(JSON.stringify(this.$searchRelatedSearches.getValue())):null}get searchExternalPromotions(){return this.$searchExternalPromotions.getValue()?JSON.parse(JSON.stringify(this.$searchExternalPromotions.getValue())):null}get language(){return this.$language.getValue()}get searchInputConfig(){return this.$searchInputConfig.getValue()}get answerConfig(){return this.$answer.getValue()}get autosuggestResults(){return this.$autosuggestResults.getValue()}get facetsTemplateData(){return this.$facetsTemplateData.getValue()}get selectedFacetsTemplateData(){return this.$selectedFacetsTemplateData.getValue()}get paginationData(){return this.$paginationData.getValue()}get searchFeedbackData(){return this.$searchFeedbackData.getValue()}get searchSortingData(){return this.$searchSortingData.getValue()}get searchRelatedSearchesData(){return this.$searchRelatedSearchesData.getValue()}get searchExternalPromotionsData(){return this.$searchExternalPromotionsData.getValue()}get cookiesDisabled(){return(this.$cookiesDisabled.getValue()??!1)||!navigator.cookieEnabled}get itemsPerPage(){return this.$itemsPerPage.getValue()}}class B{static combineResultsWithMetadata(e){const t=[],a=parseInt(e.response.start+"");return e.response.docs.forEach((s,r)=>{const i=s[e.responseHeader.params.uniqueId]??"",c={custom:null,uniqueId:i,position:a+1+r,ribbon:this.doesMapExist("ribbon",e)?this.getValueByKey("ribbon",s,e,i):null,paths:this.doesMapExist("paths",e)?this.getValueByKey("paths",s,e,i):null,url:this.doesMapExist("url",e)?this.getValueByKey("url",s,e,i):null,title:this.doesMapExist("title",e)?this.getValueByKey("title",s,e,i):null,titleTracking:this.doesMapExist("title",e)?this.getValueByKey("title",s,e,i,!0):null,promoted:s["[elevated]"]?s["[elevated]"]:!1,thumbnail:this.doesMapExist("thumbnail",e)?this.getValueByKey("thumbnail",s,e,i):null,date:this.doesMapExist("date",e)?this.getValueByKey("date",s,e,i):null,snippet:this.doesMapExist("snippet",e)?this.getValueByKey("snippet",s,e,i):null,description:this.doesMapExist("description",e)?this.getValueByKey("description",s,e,i):null,unmappedFields:this.getUnmappedFields(s,e,i),allFields:this.getAllFields(s,e)};t.push(c)}),t}static extractFacets(e){const t=[];if(e.metadata.facets)for(const a of e.metadata.facets){let s={values:[]};if(s.name=a.name,s.label=a.label,a.name in e.facet_counts.facet_fields){const r=e.facet_counts.facet_fields[a.name];for(let i=0;i<r.length;i+=2){const c={};c.value=r[i],c.parentName=s.name,c.count=r[i+1],c.type="checkbox",s.values.push(c)}}s.values.length>0&&t.push(s)}return t}static extractSearchResultsMetadata(e){var r,i,c,l,h,u;let t="",a={selectedSortOption:"",options:[]},s=(r=e.metadata.results.find(p=>p.result_card==="date"))==null?void 0:r.name;if(a.options=[{key:"",value:"Relevance"},{key:s+" desc",value:"Most Recent"}],(i=e.metadata.sorts)!=null&&i.length){const p=e.metadata.sorts.map(d=>({value:d.label,key:d.name+" "+d.order}));a.options=[{key:"",value:"Relevance"},...p]}return t=((u=(h=(l=(c=e==null?void 0:e.spellcheck)==null?void 0:c.suggestions)==null?void 0:l[1])==null?void 0:h.suggestion)==null?void 0:u[0])??"",typeof t!="string"&&(t=(t==null?void 0:t.word)??""),{recordsPerPageValue:parseInt(e.responseHeader.params.rows),startDocVal:parseInt(e.response.start+""),totalResultsValue:parseInt(e.response.numFound+""),latency:parseInt(e.responseHeader.QTime+""),endDocValue:parseInt(e.responseHeader.params.rows)+parseInt(e.response.start+""),spellingSuggestion:t,autoCorrectedQuery:e.responseHeader.params.autoCorrectedQ??"",impressions:this.getImpressions(e),sorting:a}}static getImpressions(e){const t=[],a=this.combineResultsWithMetadata(e);for(const s in a){const r=a[s],i={};i.cDocId=this.getDataForAnalytics(r.uniqueId),r.title&&(i.cDocTitle=this.getDataForAnalytics(r.title)),i.position=r.position,t.push(i)}return t}static getDataForAnalytics(e){return e!==null?typeof e>"u"?"":typeof e=="string"?e:typeof e.join<"u"?e[0]:e:""}static findResultByUniqueId(e,t){return t.find(a=>a.uniqueId===e)??null}static getUnmappedFields(e,t,a){const s=t.metadata.results.filter(i=>i.result_card==="").map(i=>i.name),r=[];for(const i of Object.keys(e))if(s.indexOf(i)!==-1){const c=Array.isArray(e[i])?this.getHighlightedResults(i,e[i].join(", "),a,t):this.getHighlightedResults(i,e[i]+"",a,t);r.push({key:i,value:c,isImage:this.checkIfImage(e[i])})}return r}static checkIfImage(e){return e===void 0?!1:typeof e!="string"?Array.isArray(e)&&e[0]?/\.(gif|jpe?g|tiff?|png|webp|bmp)$/i.test(e[0]):!1:/\.(gif|jpe?g|tiff?|png|webp|bmp)$/i.test(e)}static getAllFields(e,t){const a=t.metadata.results.map(r=>r.name),s=[];for(const r of Object.keys(e))a.indexOf(r)!==-1&&s.push({key:r,value:e[r],isImage:this.checkIfImage(e[r])});return s}static doesMapExist(e,t){return t.metadata.results.find(a=>a.result_card===e)!==void 0}static getValueByKey(e,t,a,s,r=!1){const i=a.metadata.results.find(l=>l.result_card===e);if(i===void 0)return null;const c=t[i.name];return c===void 0?null:typeof c=="string"?r?c:this.getHighlightedResults(i.name,c,s,a):Array.isArray(c)?r?c.join(", "):this.getHighlightedResults(i.name,c.join(", "),s,a):null}static getHighlightedResults(e,t,a,s){if(s.highlighting&&a in s.highlighting){let r=s.highlighting[a];if(r&&e in r){let i=r[e];const c=this.cleanValue(i);if(c!=="")return c}}return t}static cleanValue(e){return e===null?"":typeof e=="string"?e:Array.isArray(e)?e.join(" "):""}}class z{constructor(e){n(this,"routeName","searchstax");n(this,"ignoredKeys",[]);n(this,"queryStringHelper");n(this,"titleParser");e.routeName&&(this.routeName=e.routeName),e.ignoredKeys&&(this.ignoredKeys=e.ignoredKeys),e.title&&(this.titleParser=e.title),this.queryStringHelper=new te(this.routeName)}updateUrl(e){const t=this.searchObjectToUrl(e);let a=typeof document<"u"?document==null?void 0:document.title:"";this.titleParser&&(a=this.titleParser(e)),typeof document<"u"&&(document.title=a),(window==null?void 0:window.location.href)!==t&&(window==null||window.history.replaceState(window.history.state,a,t))}searchObjectToUrl(e){return this.queryStringHelper.urlHasQueryParams((window==null?void 0:window.location.href)??"")?(window==null?void 0:window.location.href.split("?")[0])+"?"+this.queryStringHelper.stringify(this.searchObjectToParams(e),{ignoredKeys:this.ignoredKeys}):(window==null?void 0:window.location.href)+"?"+this.queryStringHelper.stringify(this.searchObjectToParams(e),{ignoredKeys:this.ignoredKeys})}searchObjectToParams(e){const t={},a=e.page||1;if(e.query&&(t[this.routeName+"[query]"]=encodeURIComponent(e.query)),e.page&&(t[this.routeName+"[page]"]=a+""),e.order&&(t[this.routeName+"[order]"]=e.order),e.facets)for(const s in e.facets){const r=e.facets[s].type+":"+encodeURIComponent(e.facets[s].name)+":"+encodeURIComponent(e.facets[s].value);t[this.routeName+`[facets][${s}]`]=r}if(this.queryStringHelper.urlHasQueryParams((window==null?void 0:window.location.href)??"")){const s=this.queryStringHelper.urlToParams((window==null?void 0:window.location.href)??"");for(const r in s)r.startsWith(this.routeName)&&delete s[r];return{...s,...t}}else return t}extractParamsThatDoNotStartWithRouteName(e){const t={};for(const a in e)a.startsWith(this.routeName)||(t[a]=e[a]);return t}extractArrayOfFacetsFromQueryParameters(e){var a,s,r;const t=[];for(const i in e)if(i.startsWith(this.routeName+"[facets]")){const c=F.removeXSSRiskyTags((a=e[i].split(":"))==null?void 0:a[0]),l=F.removeXSSRiskyTags(decodeURIComponent((s=e[i].split(":"))==null?void 0:s[1])),h=F.removeXSSRiskyTags(decodeURIComponent((r=e[i].split(":"))==null?void 0:r[2]));t.push({type:c,name:l,value:h})}return t}urlToSearchObject(e,t){const a=this.queryStringHelper.urlToParams(e),s=F.removeXSSRiskyTags(decodeURIComponent(a[this.routeName+"[page]"])),r=parseInt(s),i=isNaN(r)?1:r;return{query:F.removeXSSRiskyTags(decodeURIComponent(a[this.routeName+"[query]"]))||"",page:i,itemsPerPage:t,order:F.removeXSSRiskyTags(a[this.routeName+"[order]"])||"",facets:this.extractArrayOfFacetsFromQueryParameters(a)||[]}}}class te{constructor(e){n(this,"routeName","");n(this,"stringify",(e,t)=>{const a=this.filterOutIgnoredKeys(e,t.ignoredKeys);return Object.keys(a).map(s=>{const r=a[s];return Array.isArray(r)?r.map(i=>`${s}=${i}`).join("&"):`${s}=${r}`}).join("&")});this.routeName=e}filterOutIgnoredKeys(e,t){const a=t||[],s={};return Object.keys(e).forEach(r=>{a.includes(r)||e[r]!==""&&(s[r]=e[r])}),s}urlToParams(e){const t={},a=e.split("?")[1];return a&&a.split("&").forEach(s=>{const[r,i]=s.split("=");t[r]=i}),t}doesParamContainRouteName(e){return e.indexOf(this.routeName)!==-1}urlHasQueryParams(e){return e.indexOf("?")!==-1}}const D={questionURL:"http://smartsearch-dev.searchstax.co/completion/?q=",question:"I_AM_A_QUESTION",notQuestion:"I_AM_NOT_A_QUESTION",close:"CLOSE"};class ae{constructor(e,t){n(this,"cachedQuery","");n(this,"url","");n(this,"relatedSearches","");n(this,"suggester","");n(this,"authHeader");n(this,"authHeaderRelated");n(this,"trackApiKey","");n(this,"session","");n(this,"searchAuthType");n(this,"searchAuth","");n(this,"controllerSearch");n(this,"signalSearch");n(this,"controllerSuggest");n(this,"signalSuggest");n(this,"dataLayer");this.dataLayer=t,this.url=e.searchURL,this.dataLayer.setLanguage(e.language),this.suggester=e.suggesterURL,this.trackApiKey=e.trackApiKey,this.session=e.sessionId,this.searchAuthType=e.authType,this.searchAuth=e.searchAuth,this.authHeader=new Headers,this.authHeader.append("Accept","application/json");const a=this.searchAuthType==="token"?`Token ${e.searchAuth}`:`Basic ${e.searchAuth}`;this.authHeader.append("Authorization",a),this.authHeaderRelated=new Headers,this.authHeaderRelated.append("Accept","application/json"),this.authHeaderRelated.append("Authorization",e.searchAuth)}generateFacetQuery(e,t){let a=[];if(!t)e.forEach(function(s){const r=s.name+':"'+s.value+'"';a=a.concat("fq="+decodeURIComponent(r).replace(" "," "))});else{const s={};e.forEach(function(r){const i=r.name+":"+r.value,c=decodeURIComponent(i).replace(" "," ").split(":");s[c[0]]?s[c[0]].push(c[1]):s[c[0]]=[c[1]]});for(const r in s)if(Object.prototype.hasOwnProperty.call(s,r)){const i=s[r],c=r;let l="";for(const h of i)l+=` ${c}:"${h}"`;a=a.concat("fq="+l.trim())}}return a.length?"&"+a.join("&"):""}getRelatedSearches(e,t,a,s){const r=new Headers;r.append("Accept","application/json"),r.append("Authorization",a),fetch(t+"?search="+encodeURIComponent(e.query)+"&language="+this.dataLayer.language,{method:"GET",headers:r,credentials:"same-origin"}).then(i=>i.json()).then(i=>{s(i)})}cacheFacets(){this.dataLayer.searchObject.query!==this.cachedQuery&&(this.cachedQuery=this.dataLayer.searchObject.query,this.search({query:this.dataLayer.searchObject.query??"*",itemsPerPage:void 0,page:1,order:"",facets:[],additionalProps:this.dataLayer.searchObject.additionalProps},this.cacheFacetsCallback.bind(this),!0))}cacheFacetsCallback(e){let t=B.extractFacets(e);this.dataLayer.setSearchFacetsCached(t)}search(e,t,a=!1,s=!1){if(e.query&&e.query!=="undefined"){this.dataLayer.setSearchTerm(e.query),this.dataLayer.setLoading(!0),this.controllerSearch&&this.controllerSearch.abort(),this.controllerSearch=new AbortController,this.signalSearch=this.controllerSearch.signal;const r=new Proxy(new URLSearchParams((window==null?void 0:window.location.search)??""),{get:(d,f)=>d.get(f)??""}),i=r.languageVariant?"&fq=_language:"+r.languageVariant:"";let c=e.itemsPerPage,l=(e.itemsPerPage?e.itemsPerPage:0)*(e.page-1),h=e.order?`&sort=${e.order}`:"";const u=this.url+"?q="+encodeURIComponent(e.query.trim())+"&start="+l+this.toQueryString(e.additionalProps??[])+this.generateFacetQuery(e.facets.filter(d=>d.type==="or"||d.type==="showUnavailable"),!0)+this.generateFacetQuery(e.facets.filter(d=>d.type==="and"||d.type==="tabs"),!1)+h+`&spellcheck.correct=${this.dataLayer.autoCorrect&&!s}`+(c?`&rows=${c}`:"")+"&language="+this.dataLayer.language+i,p={method:"GET",headers:this.authHeader,credentials:"same-origin",signal:this.signalSearch};a&&delete p.signal,fetch(u,p).then(d=>d.json()).then(d=>{this.dataLayer.setLoading(!1),t(d)}).catch(()=>{this.dataLayer.setLoading(!1)})}}startSSE(e,t){if(!this.dataLayer.turnAIAnswerGenerationOn||e==="*"||this.dataLayer.lastSearchValue===e||this.dataLayer.searchObject.facets.length>0||this.dataLayer.searchObject.page!==1)return;const a=new EventSource(D.questionURL+e),s=this.dataLayer;a.onmessage=function(r){if(r.data===D.question||r.data===D.notQuestion){s.setAnswerData("");return}if(r.data===D.close){a.close();return}t(r.data)},a.onerror=function(){a.close()}}suggest(e,t,a){this.controllerSuggest&&this.controllerSuggest.abort(),this.controllerSuggest=new AbortController,this.signalSuggest=this.controllerSuggest.signal;const s=this.suggester+"?q="+e.trim()+this.toQueryString(a)+"&language="+this.dataLayer.language;fetch(s,{method:"GET",headers:this.authHeader,credentials:"same-origin",signal:this.signalSuggest}).then(r=>r.json()).then(r=>{t(r)}).catch(()=>()=>{})}fields(){return this.fields}toQueryString(e){if(e.length===0)return"";const t=[];for(const a of e)t.push(encodeURIComponent(a.key)+"="+encodeURIComponent(a.value));return"&"+t.join("&")}}class O{static trackClick(e){const t={key:e.trackApiKey,query:e.searchTerm,shownHits:e.recordsPerPage,totalHits:e.totalResults,pageNo:e.currentPage,latency:e.latencyVal,session:e.session,cDocId:e.result.uniqueId,cDocTitle:e.result.titleTracking,position:e.result.position,language:e.language};return new Promise((a,s)=>{const r=["trackClick",t];t.key&&this.msq().push(r,(function(i,c){JSON.stringify(i)===JSON.stringify(t)&&c?a():s()}).bind(this))})}static trackSearch(e){const t={key:e.trackApiKey,query:e.searchTerm,shownHits:e.recordsPerPage,totalHits:e.totalResults,pageNo:e.currentPage,latency:e.latencyVal,session:e.session,language:e.language,impressions:e.impressions};setTimeout(()=>{t.key&&this.msq().push(["track",t])},0)}static trackRelatedSearchClick(e){const t={session:e.session,key:e.trackApiKey,query:e.relatedSearch.search_term,position:e.relatedSearch.position,relatedSearch:e.relatedSearch.related_search,pageNo:e.currentPage,shownHits:e.recordsPerPage,totalHits:e.totalResults,language:e.language};setTimeout(()=>{t.key&&this.msq().push(["trackRelatedSearchClick",t])},0)}static trackRelatedSearches(e){const t={session:e.session,key:e.trackApiKey,query:e.searchTerm,shownHits:e.recordsPerPage,latency:e.latencyVal,language:e.language,impressions:e.impressions};setTimeout(()=>{t.key&&this.msq().push(["trackRelatedSearch",t])},0)}}n(O,"subscribedToClickEvent",!1),n(O,"msq",()=>typeof window<"u"&&(window!=null&&window._msq)?window==null?void 0:window._msq:[]);/*!
2
2
  * mustache.js - Logic-less {{mustache}} templates with JavaScript
3
3
  * http://github.com/janl/mustache.js
4
4
  */var se=Object.prototype.toString,$=Array.isArray||function(e){return se.call(e)==="[object Array]"};function _(o){return typeof o=="function"}function re(o){return $(o)?"array":typeof o}function K(o){return o.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g,"\\$&")}function J(o,e){return o!=null&&typeof o=="object"&&e in o}function ie(o,e){return o!=null&&typeof o!="object"&&o.hasOwnProperty&&o.hasOwnProperty(e)}var ne=RegExp.prototype.test;function ce(o,e){return ne.call(o,e)}var le=/\S/;function oe(o){return!ce(le,o)}var he={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;","/":"&#x2F;","`":"&#x60;","=":"&#x3D;"};function ue(o){return String(o).replace(/[&<>"'`=\/]/g,function(t){return he[t]})}var de=/\s*/,ge=/\s+/,X=/\s*=/,pe=/\s*\}/,fe=/#|\^|\/|>|\{|&|=|!/;function me(o,e){if(!o)return[];var t=!1,a=[],s=[],r=[],i=!1,c=!1,l="",h=0;function u(){if(i&&!c)for(;r.length;)delete s[r.pop()];else r=[];i=!1,c=!1}var p,d,f;function S(w){if(typeof w=="string"&&(w=w.split(ge,2)),!$(w)||w.length!==2)throw new Error("Invalid tags: "+w);p=new RegExp(K(w[0])+"\\s*"),d=new RegExp("\\s*"+K(w[1])),f=new RegExp("\\s*"+K("}"+w[1]))}S(e||y.tags);for(var C=new N(o),m,L,v,k,I,x;!C.eos();){if(m=C.pos,v=C.scanUntil(p),v)for(var A=0,U=v.length;A<U;++A)k=v.charAt(A),oe(k)?(r.push(s.length),l+=k):(c=!0,t=!0,l+=" "),s.push(["text",k,m,m+1]),m+=1,k===`
@@ -1,4 +1,4 @@
1
- var $e=Object.defineProperty;var He=(A,S,M)=>S in A?$e(A,S,{enumerable:!0,configurable:!0,writable:!0,value:M}):A[S]=M;var n=(A,S,M)=>(He(A,typeof S!="symbol"?S+"":S,M),M);(function(A){"use strict";var S=(o=>(o[o.mustache=0]="mustache",o[o.vue=1]="vue",o[o.react=2]="react",o[o.angular=3]="angular",o))(S||{});class M{constructor(e){n(this,"dataLayer");this.dataLayer=e}get currentPage(){var e;return(e=this.dataLayer.searchObject)==null?void 0:e.page}get totalResults(){var e;return((e=this.dataLayer.searchResultsMetadata)==null?void 0:e.totalResultsValue)||0}get resultsPerPage(){return this.dataLayer.itemsPerPage||0}get sortOptions(){var e;return((e=this.dataLayer.searchResultsMetadata)==null?void 0:e.sorting.options)||[]}get selectedSortOption(){var e;return((e=this.dataLayer.searchResultsMetadata)==null?void 0:e.sorting.selectedSortOption)||""}get startResultIndex(){var e;return(((e=this.dataLayer.searchObject)==null?void 0:e.page)-1)*this.resultsPerPage+1}get endResultIndex(){var t;const e=(((t=this.dataLayer.searchObject)==null?void 0:t.page)-1)*this.resultsPerPage+(this.resultsPerPage??0);return e>this.totalResults?this.totalResults:e}get isFirstPage(){var e;return((e=this.dataLayer.searchObject)==null?void 0:e.page)===1}get isLastPage(){var e;return((e=this.dataLayer.searchObject)==null?void 0:e.page)>=Math.ceil(this.totalResults/this.resultsPerPage)}get percentageOfResultsLoaded(){return this.endResultIndex/this.totalResults*100}get results(){return this.dataLayer.searchResults??[]}get autoCorrectedQuery(){var e;return((e=this.dataLayer.searchResultsMetadata)==null?void 0:e.autoCorrectedQuery)||""}get originalQuery(){var e;return((e=this.dataLayer.searchObject)==null?void 0:e.query)||""}get getAnswerData(){return this.dataLayer.getAnswerData||""}get shouldShowAnswer(){return this.isFirstPage&&this.dataLayer.getAnswerData!==""&&this.dataLayer.searchObject.query!=="*"&&this.dataLayer.searchObject.facets.length===0}get searchTerm(){var e,t;return((e=this.dataLayer.searchResultsMetadata)==null?void 0:e.autoCorrectedQuery)||((t=this.dataLayer.searchObject)==null?void 0:t.query)||""}get searchingEverything(){return this.searchTerm==="*"}get firstSearchHappened(){return this.dataLayer.firstSearchHappened}get isInfiniteScroll(){return this.dataLayer.isInfiniteScroll??!1}get searchExecuted(){var e,t,a;return((e=this.dataLayer.searchObject)==null?void 0:e.query)!==void 0&&((t=this.dataLayer.searchObject)==null?void 0:t.query)!=="undefined"&&((a=this.dataLayer.searchObject)==null?void 0:a.query)!==""}get selectedFacets(){var t;const e=this.dataLayer.searchFacetsCached??this.dataLayer.searchFacets;return e?(((t=this.dataLayer.searchObject)==null?void 0:t.facets)??[]).map(r=>{const i=r.name,c=r.value,l=e.find(h=>h.name===i);if(l){const h=l.values.find(u=>u.type==="range"?!1:u.type==="checkbox"?'"'+u.value+'"'===c:!1);if(h)return h}return null}).filter(r=>r!==null):[]}get relatedSearches(){const e=this.dataLayer.searchRelatedSearches??[];return e[e.length-1]&&(e[e.length-1].last=!0),e}get externalPromotions(){return this.dataLayer.searchExternalPromotions??[]}get data(){return{currentPage:this.currentPage,totalResults:this.totalResults,resultsPerPage:this.resultsPerPage,startResultIndex:this.startResultIndex,endResultIndex:this.endResultIndex,isFirstPage:this.isFirstPage,isLastPage:this.isLastPage,results:this.results,searchTerm:this.searchTerm!=="undefined"?this.searchTerm:"",autoCorrectedQuery:this.autoCorrectedQuery,originalQuery:this.originalQuery,selectedFacets:this.selectedFacets,searchExecuted:this.searchExecuted,searchingEverything:this.searchingEverything,relatedSearches:this.relatedSearches,hasRelatedSearches:this.relatedSearches.length>0,externalPromotions:this.externalPromotions,hasExternalPromotions:this.externalPromotions.length>0,hasResults:this.results.length>0,hasResultsOrExternalPromotions:this.results.length>0||this.externalPromotions.length>0,answer:this.getAnswerData,shouldShowAnswer:this.shouldShowAnswer,isInfiniteScroll:this.isInfiniteScroll,percentageOfResultsLoaded:this.percentageOfResultsLoaded,firstSearchHappened:this.firstSearchHappened,sortOptions:this.sortOptions,selectedSortOption:this.selectedSortOption}}get trackingData(){var e,t,a,s;return{searchTerm:this.dataLayer.searchTerm!=="undefined"?this.dataLayer.searchTerm:"",trackApiKey:((e=this.dataLayer.searchstaxConfig)==null?void 0:e.trackApiKey)??"",session:this.dataLayer.sessionIdValue,language:this.dataLayer.language,recordsPerPage:((t=this.dataLayer.searchResultsMetadata)==null?void 0:t.recordsPerPageValue)??0,totalResults:((a=this.dataLayer.searchResultsMetadata)==null?void 0:a.totalResultsValue)??0,currentPage:this.dataLayer.currentPage,latencyVal:((s=this.dataLayer.searchResultsMetadata)==null?void 0:s.latency)??0}}}class P{static deepEqual(e,t){const a=Object.keys(e),s=Object.keys(t);if(a.length!==s.length)return!1;for(const r of a){const i=e[r],c=t[r],l=this.isObject(i)&&this.isObject(c);if(l&&!this.deepEqual(i,c)||!l&&i!==c)return!1}return!0}static isObject(e){return e!=null&&typeof e=="object"}}class L{constructor(e){n(this,"value");n(this,"observers",[]);this.value=e,this.observers=[]}subscribe(e){this.observers.push(e),e(this.value)}unsubscribe(e){const t=this.observers.indexOf(e);t!==-1&&this.observers.splice(t,1)}setValue(e){this.value=e,this.notify()}getValue(){return this.value}notify(){this.observers.forEach(e=>e(this.value))}}class K{static getOrSetCookie(e,t){let a=this.getCookie(e);return a==null&&(a=t??this.makeid(25),this.setCookie(e,a,{secure:!0,"max-age":3600})),a}static deleteCookie(e){this.getCookie(e)&&this.setCookie(e,"",{secure:!0,"max-age":-1})}static makeid(e){let t="";const a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",s=a.length;for(let r=0;r<e;r++)t+=a.charAt(Math.floor(Math.random()*s));return t}static getCookie(e){const t=typeof document<"u"?document.cookie.match(new RegExp("(?:^|; )"+e.replace(/([.$?*|{}()[\]\\/+^])/g,"\\$1")+"=([^;]*)")):null;return t?decodeURIComponent(t[1]):void 0}static setCookie(e,t,a){const s={path:"/",...a};a.expires instanceof Date&&(s.expires=a.expires.toUTCString());let r=encodeURIComponent(e)+"="+encodeURIComponent(t);for(const i in s){r+="; "+i;const c=s[i];c!==!0&&(r+="="+c)}typeof document<"u"&&(document.cookie=r)}}class F{static removeXSSRiskyTags(e){var t="script|style|iframe|object|embed|form|input|button",a=new RegExp("</?("+t+")(\\s[^>]*)?>","gi");return e?e.replace(a,""):""}}class Z{constructor(e,t){n(this,"$searchTermChange",new L(""));n(this,"$loadingChange",new L(!1));n(this,"$searchResults",new L(null));n(this,"$searchResultsMetadata",new L(null));n(this,"$searchAutosuggest",new L(null));n(this,"$searchFacets",new L(null));n(this,"$searchFacetsCached",new L(null));n(this,"$searchstaxConfig",new L(null));n(this,"$autosuggestResults",new L(null));n(this,"$itemsPerPage",new L(void 0));n(this,"$searchObject",new L({query:"",itemsPerPage:null,page:99999999,order:"",facets:[],additionalProps:[]}));n(this,"$searchRelatedSearches",new L(null));n(this,"$searchInputConfig",new L(null));n(this,"$searchExternalPromotions",new L(null));n(this,"$facetsTemplateData",new L(null));n(this,"$selectedFacetsTemplateData",new L(null));n(this,"$paginationData",new L(null));n(this,"$searchFeedbackData",new L(null));n(this,"$searchSortingData",new L(null));n(this,"$searchRelatedSearchesData",new L(null));n(this,"$searchExternalPromotionsData",new L(null));n(this,"$cookiesDisabled",new L(null));n(this,"$answer",new L(""));n(this,"$language",new L("en"));n(this,"currentPageValue",1);n(this,"isAnswerWidgetCreatedValue",!1);n(this,"renderingEngineValue",S.mustache);n(this,"parsedData",new M(this));n(this,"sessionId");n(this,"sessionIdValue",null);n(this,"autoCorrect",!0);n(this,"forceNotCorrect",!1);n(this,"lastSearchValue","");n(this,"turnAIAnswerGenerationOn",!1);n(this,"isInfiniteScroll",!1);n(this,"firstSearchHappened",!1);n(this,"facetsWereSet",!1);this.sessionId=e,t&&(this.sessionIdValue=t),this.cookieHandlingCallback(t),this.$cookiesDisabled.subscribe(()=>{this.cookieHandlingCallback(t)})}cookieHandlingCallback(e){this.cookiesDisabled?(this.sessionIdValue=null,K.deleteCookie(this.sessionId),K.deleteCookie("ms_visitorid")):this.sessionIdValue=K.getOrSetCookie(this.sessionId,e)}setIsInfiniteScroll(e){this.isInfiniteScroll=e}setSearchTerm(e){this.$searchTermChange.setValue(F.removeXSSRiskyTags(e))}setRenderingEngine(e){this.renderingEngineValue=e}setCurrentPage(e){this.currentPageValue=e}setIsAnswerWidgetCreated(e){this.isAnswerWidgetCreatedValue=e}setLoading(e){this.$loadingChange.setValue(e)}setSearchResults(e){this.firstSearchHappened=!0,(!P.deepEqual(e,this.searchResults??[""])||this.facetsWereSet)&&(this.facetsWereSet=!1,this.$searchResults.setValue(e))}setSearchResultsMetadata(e){P.deepEqual(e,this.searchResultsMetadata??{})||this.$searchResultsMetadata.setValue(e)}setSearchAutosuggest(e){this.$searchAutosuggest.setValue(e)}setSearchObject(e){var a,s;let t=e;t={...t,itemsPerPage:this.itemsPerPage},(s=(a=this.searchstaxConfig)==null?void 0:a.hooks)!=null&&s.beforeSearch&&t&&(t=this.searchstaxConfig.hooks.beforeSearch(t)),t&&(!P.deepEqual(t,this.searchObject??{})||this.forceNotCorrect)&&this.$searchObject.setValue(t)}setSearchFacets(e){this.facetsWereSet=!0,P.deepEqual(e,this.searchFacets??[])||this.$searchFacets.setValue(e)}setSearchFacetsCached(e){P.deepEqual(e,this.searchFacetsCached??[])||this.$searchFacetsCached.setValue(e)}setSearchRelatedSearches(e){P.deepEqual(e,this.searchRelatedSearches??[])||this.$searchRelatedSearches.setValue(e)}setSearchExternalPromotions(e){P.deepEqual(e,this.searchExternalPromotions??[])||this.$searchExternalPromotions.setValue(e)}setLanguage(e){this.$language.setValue(e)}setSearchstaxConfig(e){this.$searchstaxConfig.setValue(e)}setSearchInputConfig(e){this.$searchInputConfig.setValue(e)}setAutosuggestResults(e){this.$autosuggestResults.setValue(e)}setFacetsTemplateData(e){this.$facetsTemplateData.setValue(e)}setSelectedFacetsTemplateData(e){this.$selectedFacetsTemplateData.setValue(e)}setPaginationData(e){this.$paginationData.setValue(e)}setSearchFeedbackData(e){this.$searchFeedbackData.setValue(e)}setSearchSortingData(e){this.$searchSortingData.setValue(e)}setRelatedSearchesData(e){this.$searchRelatedSearchesData.setValue(e)}setExternalPromotionsData(e){this.$searchExternalPromotionsData.setValue(e)}setCookiesDisabled(e){this.$cookiesDisabled.setValue(e)}setAnswerData(e){this.$answer.setValue(e)}setItemsPerPage(e){this.$itemsPerPage.setValue(e)}get getAnswerData(){return this.$answer.getValue()}get searchstaxConfig(){return this.$searchstaxConfig.getValue()}get searchFacets(){return this.$searchFacets.getValue()?JSON.parse(JSON.stringify(this.$searchFacets.getValue())):null}get searchFacetsCached(){return this.$searchFacetsCached.getValue()?JSON.parse(JSON.stringify(this.$searchFacetsCached.getValue())):null}get searchResults(){return this.$searchResults.getValue()?JSON.parse(JSON.stringify(this.$searchResults.getValue())):null}get searchTerm(){return this.$searchTermChange.getValue()}get loading(){return this.$loadingChange.getValue()}get searchAutosuggest(){return this.$searchAutosuggest.getValue()}get searchResultsMetadata(){return this.$searchResultsMetadata.getValue()?JSON.parse(JSON.stringify(this.$searchResultsMetadata.getValue())):null}get currentPage(){return this.$searchObject.getValue().page??this.currentPageValue}get isAnswerWidgetCreated(){return this.isAnswerWidgetCreatedValue}get renderingEngine(){return this.renderingEngineValue}get searchObject(){return JSON.parse(JSON.stringify(this.$searchObject.getValue()))}get searchRelatedSearches(){return this.$searchRelatedSearches.getValue()?JSON.parse(JSON.stringify(this.$searchRelatedSearches.getValue())):null}get searchExternalPromotions(){return this.$searchExternalPromotions.getValue()?JSON.parse(JSON.stringify(this.$searchExternalPromotions.getValue())):null}get language(){return this.$language.getValue()}get searchInputConfig(){return this.$searchInputConfig.getValue()}get answerConfig(){return this.$answer.getValue()}get autosuggestResults(){return this.$autosuggestResults.getValue()}get facetsTemplateData(){return this.$facetsTemplateData.getValue()}get selectedFacetsTemplateData(){return this.$selectedFacetsTemplateData.getValue()}get paginationData(){return this.$paginationData.getValue()}get searchFeedbackData(){return this.$searchFeedbackData.getValue()}get searchSortingData(){return this.$searchSortingData.getValue()}get searchRelatedSearchesData(){return this.$searchRelatedSearchesData.getValue()}get searchExternalPromotionsData(){return this.$searchExternalPromotionsData.getValue()}get cookiesDisabled(){return(this.$cookiesDisabled.getValue()??!1)||!navigator.cookieEnabled}get itemsPerPage(){return this.$itemsPerPage.getValue()}}class B{static combineResultsWithMetadata(e){const t=[],a=parseInt(e.response.start+"");return e.response.docs.forEach((s,r)=>{const i=s[e.responseHeader.params.uniqueId]??"",c={custom:null,uniqueId:i,position:a+1+r,ribbon:this.doesMapExist("ribbon",e)?this.getValueByKey("ribbon",s,e,i):null,paths:this.doesMapExist("paths",e)?this.getValueByKey("paths",s,e,i):null,url:this.doesMapExist("url",e)?this.getValueByKey("url",s,e,i):null,title:this.doesMapExist("title",e)?this.getValueByKey("title",s,e,i):null,titleTracking:this.doesMapExist("title",e)?this.getValueByKey("title",s,e,i,!0):null,promoted:s["[elevated]"]?s["[elevated]"]:!1,thumbnail:this.doesMapExist("thumbnail",e)?this.getValueByKey("thumbnail",s,e,i):null,date:this.doesMapExist("date",e)?this.getValueByKey("date",s,e,i):null,snippet:this.doesMapExist("snippet",e)?this.getValueByKey("snippet",s,e,i):null,description:this.doesMapExist("description",e)?this.getValueByKey("description",s,e,i):null,unmappedFields:this.getUnmappedFields(s,e,i),allFields:this.getAllFields(s,e)};t.push(c)}),t}static extractFacets(e){const t=[];if(e.metadata.facets)for(const a of e.metadata.facets){let s={values:[]};if(s.name=a.name,s.label=a.label,a.name in e.facet_counts.facet_fields){const r=e.facet_counts.facet_fields[a.name];for(let i=0;i<r.length;i+=2){const c={};c.value=r[i],c.parentName=s.name,c.count=r[i+1],c.type="checkbox",s.values.push(c)}}s.values.length>0&&t.push(s)}return t}static extractSearchResultsMetadata(e){var r,i,c,l,h,u;let t="",a={selectedSortOption:"",options:[]},s=(r=e.metadata.results.find(p=>p.result_card==="date"))==null?void 0:r.name;if(a.options=[{key:"",value:"Relevance"},{key:s+" desc",value:"Most Recent"}],(i=e.metadata.sorts)!=null&&i.length){const p=e.metadata.sorts.map(d=>({value:d.label,key:d.name+" "+d.order}));a.options=[{key:"",value:"Relevance"},...p]}return t=((u=(h=(l=(c=e==null?void 0:e.spellcheck)==null?void 0:c.suggestions)==null?void 0:l[1])==null?void 0:h.suggestion)==null?void 0:u[0])??"",typeof t!="string"&&(t=(t==null?void 0:t.word)??""),{recordsPerPageValue:parseInt(e.responseHeader.params.rows),startDocVal:parseInt(e.response.start+""),totalResultsValue:parseInt(e.response.numFound+""),latency:parseInt(e.responseHeader.QTime+""),endDocValue:parseInt(e.responseHeader.params.rows)+parseInt(e.response.start+""),spellingSuggestion:t,autoCorrectedQuery:e.responseHeader.params.autoCorrectedQ??"",impressions:this.getImpressions(e),sorting:a}}static getImpressions(e){const t=[],a=this.combineResultsWithMetadata(e);for(const s in a){const r=a[s],i={};i.cDocId=this.getDataForAnalytics(r.uniqueId),r.title&&(i.cDocTitle=this.getDataForAnalytics(r.title)),i.position=r.position,t.push(i)}return t}static getDataForAnalytics(e){return e!==null?typeof e>"u"?"":typeof e=="string"?e:typeof e.join<"u"?e[0]:e:""}static findResultByUniqueId(e,t){return t.find(a=>a.uniqueId===e)??null}static getUnmappedFields(e,t,a){const s=t.metadata.results.filter(i=>i.result_card==="").map(i=>i.name),r=[];for(const i of Object.keys(e))if(s.indexOf(i)!==-1){const c=Array.isArray(e[i])?this.getHighlightedResults(i,e[i].join(", "),a,t):this.getHighlightedResults(i,e[i]+"",a,t);r.push({key:i,value:c,isImage:this.checkIfImage(e[i])})}return r}static checkIfImage(e){return e===void 0?!1:typeof e!="string"?Array.isArray(e)&&e[0]?/\.(gif|jpe?g|tiff?|png|webp|bmp)$/i.test(e[0]):!1:/\.(gif|jpe?g|tiff?|png|webp|bmp)$/i.test(e)}static getAllFields(e,t){const a=t.metadata.results.map(r=>r.name),s=[];for(const r of Object.keys(e))a.indexOf(r)!==-1&&s.push({key:r,value:e[r],isImage:this.checkIfImage(e[r])});return s}static doesMapExist(e,t){return t.metadata.results.find(a=>a.result_card===e)!==void 0}static getValueByKey(e,t,a,s,r=!1){const i=a.metadata.results.find(l=>l.result_card===e);if(i===void 0)return null;const c=t[i.name];return c===void 0?null:typeof c=="string"?r?c:this.getHighlightedResults(i.name,c,s,a):Array.isArray(c)?r?c.join(", "):this.getHighlightedResults(i.name,c.join(", "),s,a):null}static getHighlightedResults(e,t,a,s){if(s.highlighting&&a in s.highlighting){let r=s.highlighting[a];if(r&&e in r){let i=r[e];const c=this.cleanValue(i);if(c!=="")return c}}return t}static cleanValue(e){return e===null?"":typeof e=="string"?e:Array.isArray(e)?e.join(" "):""}}class X{constructor(e){n(this,"routeName","searchstax");n(this,"ignoredKeys",[]);n(this,"queryStringHelper");n(this,"titleParser");e.routeName&&(this.routeName=e.routeName),e.ignoredKeys&&(this.ignoredKeys=e.ignoredKeys),e.title&&(this.titleParser=e.title),this.queryStringHelper=new ee(this.routeName)}updateUrl(e){const t=this.searchObjectToUrl(e);let a=typeof document<"u"?document==null?void 0:document.title:"";this.titleParser&&(a=this.titleParser(e)),typeof document<"u"&&(document.title=a),(window==null?void 0:window.location.href)!==t&&(window==null||window.history.pushState({},a,t))}searchObjectToUrl(e){return this.queryStringHelper.urlHasQueryParams((window==null?void 0:window.location.href)??"")?(window==null?void 0:window.location.href.split("?")[0])+"?"+this.queryStringHelper.stringify(this.searchObjectToParams(e),{ignoredKeys:this.ignoredKeys}):(window==null?void 0:window.location.href)+"?"+this.queryStringHelper.stringify(this.searchObjectToParams(e),{ignoredKeys:this.ignoredKeys})}searchObjectToParams(e){const t={},a=e.page||1;if(e.query&&(t[this.routeName+"[query]"]=encodeURIComponent(e.query)),e.page&&(t[this.routeName+"[page]"]=a+""),e.order&&(t[this.routeName+"[order]"]=e.order),e.facets)for(const s in e.facets){const r=e.facets[s].type+":"+encodeURIComponent(e.facets[s].name)+":"+encodeURIComponent(e.facets[s].value);t[this.routeName+`[facets][${s}]`]=r}if(this.queryStringHelper.urlHasQueryParams((window==null?void 0:window.location.href)??"")){const s=this.queryStringHelper.urlToParams((window==null?void 0:window.location.href)??"");for(const r in s)r.startsWith(this.routeName)&&delete s[r];return{...s,...t}}else return t}extractParamsThatDoNotStartWithRouteName(e){const t={};for(const a in e)a.startsWith(this.routeName)||(t[a]=e[a]);return t}extractArrayOfFacetsFromQueryParameters(e){var a,s,r;const t=[];for(const i in e)if(i.startsWith(this.routeName+"[facets]")){const c=F.removeXSSRiskyTags((a=e[i].split(":"))==null?void 0:a[0]),l=F.removeXSSRiskyTags(decodeURIComponent((s=e[i].split(":"))==null?void 0:s[1])),h=F.removeXSSRiskyTags(decodeURIComponent((r=e[i].split(":"))==null?void 0:r[2]));t.push({type:c,name:l,value:h})}return t}urlToSearchObject(e,t){const a=this.queryStringHelper.urlToParams(e),s=F.removeXSSRiskyTags(decodeURIComponent(a[this.routeName+"[page]"])),r=parseInt(s),i=isNaN(r)?1:r;return{query:F.removeXSSRiskyTags(decodeURIComponent(a[this.routeName+"[query]"]))||"",page:i,itemsPerPage:t,order:F.removeXSSRiskyTags(a[this.routeName+"[order]"])||"",facets:this.extractArrayOfFacetsFromQueryParameters(a)||[]}}}class ee{constructor(e){n(this,"routeName","");n(this,"stringify",(e,t)=>{const a=this.filterOutIgnoredKeys(e,t.ignoredKeys);return Object.keys(a).map(s=>{const r=a[s];return Array.isArray(r)?r.map(i=>`${s}=${i}`).join("&"):`${s}=${r}`}).join("&")});this.routeName=e}filterOutIgnoredKeys(e,t){const a=t||[],s={};return Object.keys(e).forEach(r=>{a.includes(r)||e[r]!==""&&(s[r]=e[r])}),s}urlToParams(e){const t={},a=e.split("?")[1];return a&&a.split("&").forEach(s=>{const[r,i]=s.split("=");t[r]=i}),t}doesParamContainRouteName(e){return e.indexOf(this.routeName)!==-1}urlHasQueryParams(e){return e.indexOf("?")!==-1}}const q={questionURL:"http://smartsearch-dev.searchstax.co/completion/?q=",question:"I_AM_A_QUESTION",notQuestion:"I_AM_NOT_A_QUESTION",close:"CLOSE"};class te{constructor(e,t){n(this,"cachedQuery","");n(this,"url","");n(this,"relatedSearches","");n(this,"suggester","");n(this,"authHeader");n(this,"authHeaderRelated");n(this,"trackApiKey","");n(this,"session","");n(this,"searchAuthType");n(this,"searchAuth","");n(this,"controllerSearch");n(this,"signalSearch");n(this,"controllerSuggest");n(this,"signalSuggest");n(this,"dataLayer");this.dataLayer=t,this.url=e.searchURL,this.dataLayer.setLanguage(e.language),this.suggester=e.suggesterURL,this.trackApiKey=e.trackApiKey,this.session=e.sessionId,this.searchAuthType=e.authType,this.searchAuth=e.searchAuth,this.authHeader=new Headers,this.authHeader.append("Accept","application/json");const a=this.searchAuthType==="token"?`Token ${e.searchAuth}`:`Basic ${e.searchAuth}`;this.authHeader.append("Authorization",a),this.authHeaderRelated=new Headers,this.authHeaderRelated.append("Accept","application/json"),this.authHeaderRelated.append("Authorization",e.searchAuth)}generateFacetQuery(e,t){let a=[];if(!t)e.forEach(function(s){const r=s.name+':"'+s.value+'"';a=a.concat("fq="+decodeURIComponent(r).replace(" "," "))});else{const s={};e.forEach(function(r){const i=r.name+":"+r.value,c=decodeURIComponent(i).replace(" "," ").split(":");s[c[0]]?s[c[0]].push(c[1]):s[c[0]]=[c[1]]});for(const r in s)if(Object.prototype.hasOwnProperty.call(s,r)){const i=s[r],c=r;let l="";for(const h of i)l+=` ${c}:"${h}"`;a=a.concat("fq="+l.trim())}}return a.length?"&"+a.join("&"):""}getRelatedSearches(e,t,a,s){const r=new Headers;r.append("Accept","application/json"),r.append("Authorization",a),fetch(t+"?search="+encodeURIComponent(e.query)+"&language="+this.dataLayer.language,{method:"GET",headers:r,credentials:"same-origin"}).then(i=>i.json()).then(i=>{s(i)})}cacheFacets(){this.dataLayer.searchObject.query!==this.cachedQuery&&(this.cachedQuery=this.dataLayer.searchObject.query,this.search({query:this.dataLayer.searchObject.query??"*",itemsPerPage:void 0,page:1,order:"",facets:[],additionalProps:this.dataLayer.searchObject.additionalProps},this.cacheFacetsCallback.bind(this),!0))}cacheFacetsCallback(e){let t=B.extractFacets(e);this.dataLayer.setSearchFacetsCached(t)}search(e,t,a=!1,s=!1){if(e.query&&e.query!=="undefined"){this.dataLayer.setSearchTerm(e.query),this.dataLayer.setLoading(!0),this.controllerSearch&&this.controllerSearch.abort(),this.controllerSearch=new AbortController,this.signalSearch=this.controllerSearch.signal;const r=new Proxy(new URLSearchParams((window==null?void 0:window.location.search)??""),{get:(d,f)=>d.get(f)??""}),i=r.languageVariant?"&fq=_language:"+r.languageVariant:"";let c=e.itemsPerPage,l=(e.itemsPerPage?e.itemsPerPage:0)*(e.page-1),h=e.order?`&sort=${e.order}`:"";const u=this.url+"?q="+encodeURIComponent(e.query.trim())+"&start="+l+this.toQueryString(e.additionalProps??[])+this.generateFacetQuery(e.facets.filter(d=>d.type==="or"||d.type==="showUnavailable"),!0)+this.generateFacetQuery(e.facets.filter(d=>d.type==="and"||d.type==="tabs"),!1)+h+`&spellcheck.correct=${this.dataLayer.autoCorrect&&!s}`+(c?`&rows=${c}`:"")+"&language="+this.dataLayer.language+i,p={method:"GET",headers:this.authHeader,credentials:"same-origin",signal:this.signalSearch};a&&delete p.signal,fetch(u,p).then(d=>d.json()).then(d=>{this.dataLayer.setLoading(!1),t(d)}).catch(()=>{this.dataLayer.setLoading(!1)})}}startSSE(e,t){if(!this.dataLayer.turnAIAnswerGenerationOn||e==="*"||this.dataLayer.lastSearchValue===e||this.dataLayer.searchObject.facets.length>0||this.dataLayer.searchObject.page!==1)return;const a=new EventSource(q.questionURL+e),s=this.dataLayer;a.onmessage=function(r){if(r.data===q.question||r.data===q.notQuestion){s.setAnswerData("");return}if(r.data===q.close){a.close();return}t(r.data)},a.onerror=function(){a.close()}}suggest(e,t,a){this.controllerSuggest&&this.controllerSuggest.abort(),this.controllerSuggest=new AbortController,this.signalSuggest=this.controllerSuggest.signal;const s=this.suggester+"?q="+e.trim()+this.toQueryString(a)+"&language="+this.dataLayer.language;fetch(s,{method:"GET",headers:this.authHeader,credentials:"same-origin",signal:this.signalSuggest}).then(r=>r.json()).then(r=>{t(r)}).catch(()=>()=>{})}fields(){return this.fields}toQueryString(e){if(e.length===0)return"";const t=[];for(const a of e)t.push(encodeURIComponent(a.key)+"="+encodeURIComponent(a.value));return"&"+t.join("&")}}class ${static trackClick(e){const t={key:e.trackApiKey,query:e.searchTerm,shownHits:e.recordsPerPage,totalHits:e.totalResults,pageNo:e.currentPage,latency:e.latencyVal,session:e.session,cDocId:e.result.uniqueId,cDocTitle:e.result.titleTracking,position:e.result.position,language:e.language};return new Promise((a,s)=>{const r=["trackClick",t];t.key&&this.msq().push(r,(function(i,c){JSON.stringify(i)===JSON.stringify(t)&&c?a():s()}).bind(this))})}static trackSearch(e){const t={key:e.trackApiKey,query:e.searchTerm,shownHits:e.recordsPerPage,totalHits:e.totalResults,pageNo:e.currentPage,latency:e.latencyVal,session:e.session,language:e.language,impressions:e.impressions};setTimeout(()=>{t.key&&this.msq().push(["track",t])},0)}static trackRelatedSearchClick(e){const t={session:e.session,key:e.trackApiKey,query:e.relatedSearch.search_term,position:e.relatedSearch.position,relatedSearch:e.relatedSearch.related_search,pageNo:e.currentPage,shownHits:e.recordsPerPage,totalHits:e.totalResults,language:e.language};setTimeout(()=>{t.key&&this.msq().push(["trackRelatedSearchClick",t])},0)}static trackRelatedSearches(e){const t={session:e.session,key:e.trackApiKey,query:e.searchTerm,shownHits:e.recordsPerPage,latency:e.latencyVal,language:e.language,impressions:e.impressions};setTimeout(()=>{t.key&&this.msq().push(["trackRelatedSearch",t])},0)}}n($,"subscribedToClickEvent",!1),n($,"msq",()=>typeof window<"u"&&(window!=null&&window._msq)?window==null?void 0:window._msq:[]);/*!
1
+ var $e=Object.defineProperty;var He=(A,S,M)=>S in A?$e(A,S,{enumerable:!0,configurable:!0,writable:!0,value:M}):A[S]=M;var n=(A,S,M)=>(He(A,typeof S!="symbol"?S+"":S,M),M);(function(A){"use strict";var S=(o=>(o[o.mustache=0]="mustache",o[o.vue=1]="vue",o[o.react=2]="react",o[o.angular=3]="angular",o))(S||{});class M{constructor(e){n(this,"dataLayer");this.dataLayer=e}get currentPage(){var e;return(e=this.dataLayer.searchObject)==null?void 0:e.page}get totalResults(){var e;return((e=this.dataLayer.searchResultsMetadata)==null?void 0:e.totalResultsValue)||0}get resultsPerPage(){return this.dataLayer.itemsPerPage||0}get sortOptions(){var e;return((e=this.dataLayer.searchResultsMetadata)==null?void 0:e.sorting.options)||[]}get selectedSortOption(){var e;return((e=this.dataLayer.searchResultsMetadata)==null?void 0:e.sorting.selectedSortOption)||""}get startResultIndex(){var e;return(((e=this.dataLayer.searchObject)==null?void 0:e.page)-1)*this.resultsPerPage+1}get endResultIndex(){var t;const e=(((t=this.dataLayer.searchObject)==null?void 0:t.page)-1)*this.resultsPerPage+(this.resultsPerPage??0);return e>this.totalResults?this.totalResults:e}get isFirstPage(){var e;return((e=this.dataLayer.searchObject)==null?void 0:e.page)===1}get isLastPage(){var e;return((e=this.dataLayer.searchObject)==null?void 0:e.page)>=Math.ceil(this.totalResults/this.resultsPerPage)}get percentageOfResultsLoaded(){return this.endResultIndex/this.totalResults*100}get results(){return this.dataLayer.searchResults??[]}get autoCorrectedQuery(){var e;return((e=this.dataLayer.searchResultsMetadata)==null?void 0:e.autoCorrectedQuery)||""}get originalQuery(){var e;return((e=this.dataLayer.searchObject)==null?void 0:e.query)||""}get getAnswerData(){return this.dataLayer.getAnswerData||""}get shouldShowAnswer(){return this.isFirstPage&&this.dataLayer.getAnswerData!==""&&this.dataLayer.searchObject.query!=="*"&&this.dataLayer.searchObject.facets.length===0}get searchTerm(){var e,t;return((e=this.dataLayer.searchResultsMetadata)==null?void 0:e.autoCorrectedQuery)||((t=this.dataLayer.searchObject)==null?void 0:t.query)||""}get searchingEverything(){return this.searchTerm==="*"}get firstSearchHappened(){return this.dataLayer.firstSearchHappened}get isInfiniteScroll(){return this.dataLayer.isInfiniteScroll??!1}get searchExecuted(){var e,t,a;return((e=this.dataLayer.searchObject)==null?void 0:e.query)!==void 0&&((t=this.dataLayer.searchObject)==null?void 0:t.query)!=="undefined"&&((a=this.dataLayer.searchObject)==null?void 0:a.query)!==""}get selectedFacets(){var t;const e=this.dataLayer.searchFacetsCached??this.dataLayer.searchFacets;return e?(((t=this.dataLayer.searchObject)==null?void 0:t.facets)??[]).map(r=>{const i=r.name,c=r.value,l=e.find(h=>h.name===i);if(l){const h=l.values.find(u=>u.type==="range"?!1:u.type==="checkbox"?'"'+u.value+'"'===c:!1);if(h)return h}return null}).filter(r=>r!==null):[]}get relatedSearches(){const e=this.dataLayer.searchRelatedSearches??[];return e[e.length-1]&&(e[e.length-1].last=!0),e}get externalPromotions(){return this.dataLayer.searchExternalPromotions??[]}get data(){return{currentPage:this.currentPage,totalResults:this.totalResults,resultsPerPage:this.resultsPerPage,startResultIndex:this.startResultIndex,endResultIndex:this.endResultIndex,isFirstPage:this.isFirstPage,isLastPage:this.isLastPage,results:this.results,searchTerm:this.searchTerm!=="undefined"?this.searchTerm:"",autoCorrectedQuery:this.autoCorrectedQuery,originalQuery:this.originalQuery,selectedFacets:this.selectedFacets,searchExecuted:this.searchExecuted,searchingEverything:this.searchingEverything,relatedSearches:this.relatedSearches,hasRelatedSearches:this.relatedSearches.length>0,externalPromotions:this.externalPromotions,hasExternalPromotions:this.externalPromotions.length>0,hasResults:this.results.length>0,hasResultsOrExternalPromotions:this.results.length>0||this.externalPromotions.length>0,answer:this.getAnswerData,shouldShowAnswer:this.shouldShowAnswer,isInfiniteScroll:this.isInfiniteScroll,percentageOfResultsLoaded:this.percentageOfResultsLoaded,firstSearchHappened:this.firstSearchHappened,sortOptions:this.sortOptions,selectedSortOption:this.selectedSortOption}}get trackingData(){var e,t,a,s;return{searchTerm:this.dataLayer.searchTerm!=="undefined"?this.dataLayer.searchTerm:"",trackApiKey:((e=this.dataLayer.searchstaxConfig)==null?void 0:e.trackApiKey)??"",session:this.dataLayer.sessionIdValue,language:this.dataLayer.language,recordsPerPage:((t=this.dataLayer.searchResultsMetadata)==null?void 0:t.recordsPerPageValue)??0,totalResults:((a=this.dataLayer.searchResultsMetadata)==null?void 0:a.totalResultsValue)??0,currentPage:this.dataLayer.currentPage,latencyVal:((s=this.dataLayer.searchResultsMetadata)==null?void 0:s.latency)??0}}}class P{static deepEqual(e,t){const a=Object.keys(e),s=Object.keys(t);if(a.length!==s.length)return!1;for(const r of a){const i=e[r],c=t[r],l=this.isObject(i)&&this.isObject(c);if(l&&!this.deepEqual(i,c)||!l&&i!==c)return!1}return!0}static isObject(e){return e!=null&&typeof e=="object"}}class L{constructor(e){n(this,"value");n(this,"observers",[]);this.value=e,this.observers=[]}subscribe(e){this.observers.push(e),e(this.value)}unsubscribe(e){const t=this.observers.indexOf(e);t!==-1&&this.observers.splice(t,1)}setValue(e){this.value=e,this.notify()}getValue(){return this.value}notify(){this.observers.forEach(e=>e(this.value))}}class K{static getOrSetCookie(e,t){let a=this.getCookie(e);return a==null&&(a=t??this.makeid(25),this.setCookie(e,a,{secure:!0,"max-age":3600})),a}static deleteCookie(e){this.getCookie(e)&&this.setCookie(e,"",{secure:!0,"max-age":-1})}static makeid(e){let t="";const a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",s=a.length;for(let r=0;r<e;r++)t+=a.charAt(Math.floor(Math.random()*s));return t}static getCookie(e){const t=typeof document<"u"?document.cookie.match(new RegExp("(?:^|; )"+e.replace(/([.$?*|{}()[\]\\/+^])/g,"\\$1")+"=([^;]*)")):null;return t?decodeURIComponent(t[1]):void 0}static setCookie(e,t,a){const s={path:"/",...a};a.expires instanceof Date&&(s.expires=a.expires.toUTCString());let r=encodeURIComponent(e)+"="+encodeURIComponent(t);for(const i in s){r+="; "+i;const c=s[i];c!==!0&&(r+="="+c)}typeof document<"u"&&(document.cookie=r)}}class F{static removeXSSRiskyTags(e){var t="script|style|iframe|object|embed|form|input|button",a=new RegExp("</?("+t+")(\\s[^>]*)?>","gi");return e?e.replace(a,""):""}}class Z{constructor(e,t){n(this,"$searchTermChange",new L(""));n(this,"$loadingChange",new L(!1));n(this,"$searchResults",new L(null));n(this,"$searchResultsMetadata",new L(null));n(this,"$searchAutosuggest",new L(null));n(this,"$searchFacets",new L(null));n(this,"$searchFacetsCached",new L(null));n(this,"$searchstaxConfig",new L(null));n(this,"$autosuggestResults",new L(null));n(this,"$itemsPerPage",new L(void 0));n(this,"$searchObject",new L({query:"",itemsPerPage:null,page:99999999,order:"",facets:[],additionalProps:[]}));n(this,"$searchRelatedSearches",new L(null));n(this,"$searchInputConfig",new L(null));n(this,"$searchExternalPromotions",new L(null));n(this,"$facetsTemplateData",new L(null));n(this,"$selectedFacetsTemplateData",new L(null));n(this,"$paginationData",new L(null));n(this,"$searchFeedbackData",new L(null));n(this,"$searchSortingData",new L(null));n(this,"$searchRelatedSearchesData",new L(null));n(this,"$searchExternalPromotionsData",new L(null));n(this,"$cookiesDisabled",new L(null));n(this,"$answer",new L(""));n(this,"$language",new L("en"));n(this,"currentPageValue",1);n(this,"isAnswerWidgetCreatedValue",!1);n(this,"renderingEngineValue",S.mustache);n(this,"parsedData",new M(this));n(this,"sessionId");n(this,"sessionIdValue",null);n(this,"autoCorrect",!0);n(this,"forceNotCorrect",!1);n(this,"lastSearchValue","");n(this,"turnAIAnswerGenerationOn",!1);n(this,"isInfiniteScroll",!1);n(this,"firstSearchHappened",!1);n(this,"facetsWereSet",!1);this.sessionId=e,t&&(this.sessionIdValue=t),this.cookieHandlingCallback(t),this.$cookiesDisabled.subscribe(()=>{this.cookieHandlingCallback(t)})}cookieHandlingCallback(e){this.cookiesDisabled?(this.sessionIdValue=null,K.deleteCookie(this.sessionId),K.deleteCookie("ms_visitorid")):this.sessionIdValue=K.getOrSetCookie(this.sessionId,e)}setIsInfiniteScroll(e){this.isInfiniteScroll=e}setSearchTerm(e){this.$searchTermChange.setValue(F.removeXSSRiskyTags(e))}setRenderingEngine(e){this.renderingEngineValue=e}setCurrentPage(e){this.currentPageValue=e}setIsAnswerWidgetCreated(e){this.isAnswerWidgetCreatedValue=e}setLoading(e){this.$loadingChange.setValue(e)}setSearchResults(e){this.firstSearchHappened=!0,(!P.deepEqual(e,this.searchResults??[""])||this.facetsWereSet)&&(this.facetsWereSet=!1,this.$searchResults.setValue(e))}setSearchResultsMetadata(e){P.deepEqual(e,this.searchResultsMetadata??{})||this.$searchResultsMetadata.setValue(e)}setSearchAutosuggest(e){this.$searchAutosuggest.setValue(e)}setSearchObject(e){var a,s;let t=e;t={...t,itemsPerPage:this.itemsPerPage},(s=(a=this.searchstaxConfig)==null?void 0:a.hooks)!=null&&s.beforeSearch&&t&&(t=this.searchstaxConfig.hooks.beforeSearch(t)),t&&(!P.deepEqual(t,this.searchObject??{})||this.forceNotCorrect)&&this.$searchObject.setValue(t)}setSearchFacets(e){this.facetsWereSet=!0,P.deepEqual(e,this.searchFacets??[])||this.$searchFacets.setValue(e)}setSearchFacetsCached(e){P.deepEqual(e,this.searchFacetsCached??[])||this.$searchFacetsCached.setValue(e)}setSearchRelatedSearches(e){P.deepEqual(e,this.searchRelatedSearches??[])||this.$searchRelatedSearches.setValue(e)}setSearchExternalPromotions(e){P.deepEqual(e,this.searchExternalPromotions??[])||this.$searchExternalPromotions.setValue(e)}setLanguage(e){this.$language.setValue(e)}setSearchstaxConfig(e){this.$searchstaxConfig.setValue(e)}setSearchInputConfig(e){this.$searchInputConfig.setValue(e)}setAutosuggestResults(e){this.$autosuggestResults.setValue(e)}setFacetsTemplateData(e){this.$facetsTemplateData.setValue(e)}setSelectedFacetsTemplateData(e){this.$selectedFacetsTemplateData.setValue(e)}setPaginationData(e){this.$paginationData.setValue(e)}setSearchFeedbackData(e){this.$searchFeedbackData.setValue(e)}setSearchSortingData(e){this.$searchSortingData.setValue(e)}setRelatedSearchesData(e){this.$searchRelatedSearchesData.setValue(e)}setExternalPromotionsData(e){this.$searchExternalPromotionsData.setValue(e)}setCookiesDisabled(e){this.$cookiesDisabled.setValue(e)}setAnswerData(e){this.$answer.setValue(e)}setItemsPerPage(e){this.$itemsPerPage.setValue(e)}get getAnswerData(){return this.$answer.getValue()}get searchstaxConfig(){return this.$searchstaxConfig.getValue()}get searchFacets(){return this.$searchFacets.getValue()?JSON.parse(JSON.stringify(this.$searchFacets.getValue())):null}get searchFacetsCached(){return this.$searchFacetsCached.getValue()?JSON.parse(JSON.stringify(this.$searchFacetsCached.getValue())):null}get searchResults(){return this.$searchResults.getValue()?JSON.parse(JSON.stringify(this.$searchResults.getValue())):null}get searchTerm(){return this.$searchTermChange.getValue()}get loading(){return this.$loadingChange.getValue()}get searchAutosuggest(){return this.$searchAutosuggest.getValue()}get searchResultsMetadata(){return this.$searchResultsMetadata.getValue()?JSON.parse(JSON.stringify(this.$searchResultsMetadata.getValue())):null}get currentPage(){return this.$searchObject.getValue().page??this.currentPageValue}get isAnswerWidgetCreated(){return this.isAnswerWidgetCreatedValue}get renderingEngine(){return this.renderingEngineValue}get searchObject(){return JSON.parse(JSON.stringify(this.$searchObject.getValue()))}get searchRelatedSearches(){return this.$searchRelatedSearches.getValue()?JSON.parse(JSON.stringify(this.$searchRelatedSearches.getValue())):null}get searchExternalPromotions(){return this.$searchExternalPromotions.getValue()?JSON.parse(JSON.stringify(this.$searchExternalPromotions.getValue())):null}get language(){return this.$language.getValue()}get searchInputConfig(){return this.$searchInputConfig.getValue()}get answerConfig(){return this.$answer.getValue()}get autosuggestResults(){return this.$autosuggestResults.getValue()}get facetsTemplateData(){return this.$facetsTemplateData.getValue()}get selectedFacetsTemplateData(){return this.$selectedFacetsTemplateData.getValue()}get paginationData(){return this.$paginationData.getValue()}get searchFeedbackData(){return this.$searchFeedbackData.getValue()}get searchSortingData(){return this.$searchSortingData.getValue()}get searchRelatedSearchesData(){return this.$searchRelatedSearchesData.getValue()}get searchExternalPromotionsData(){return this.$searchExternalPromotionsData.getValue()}get cookiesDisabled(){return(this.$cookiesDisabled.getValue()??!1)||!navigator.cookieEnabled}get itemsPerPage(){return this.$itemsPerPage.getValue()}}class B{static combineResultsWithMetadata(e){const t=[],a=parseInt(e.response.start+"");return e.response.docs.forEach((s,r)=>{const i=s[e.responseHeader.params.uniqueId]??"",c={custom:null,uniqueId:i,position:a+1+r,ribbon:this.doesMapExist("ribbon",e)?this.getValueByKey("ribbon",s,e,i):null,paths:this.doesMapExist("paths",e)?this.getValueByKey("paths",s,e,i):null,url:this.doesMapExist("url",e)?this.getValueByKey("url",s,e,i):null,title:this.doesMapExist("title",e)?this.getValueByKey("title",s,e,i):null,titleTracking:this.doesMapExist("title",e)?this.getValueByKey("title",s,e,i,!0):null,promoted:s["[elevated]"]?s["[elevated]"]:!1,thumbnail:this.doesMapExist("thumbnail",e)?this.getValueByKey("thumbnail",s,e,i):null,date:this.doesMapExist("date",e)?this.getValueByKey("date",s,e,i):null,snippet:this.doesMapExist("snippet",e)?this.getValueByKey("snippet",s,e,i):null,description:this.doesMapExist("description",e)?this.getValueByKey("description",s,e,i):null,unmappedFields:this.getUnmappedFields(s,e,i),allFields:this.getAllFields(s,e)};t.push(c)}),t}static extractFacets(e){const t=[];if(e.metadata.facets)for(const a of e.metadata.facets){let s={values:[]};if(s.name=a.name,s.label=a.label,a.name in e.facet_counts.facet_fields){const r=e.facet_counts.facet_fields[a.name];for(let i=0;i<r.length;i+=2){const c={};c.value=r[i],c.parentName=s.name,c.count=r[i+1],c.type="checkbox",s.values.push(c)}}s.values.length>0&&t.push(s)}return t}static extractSearchResultsMetadata(e){var r,i,c,l,h,u;let t="",a={selectedSortOption:"",options:[]},s=(r=e.metadata.results.find(p=>p.result_card==="date"))==null?void 0:r.name;if(a.options=[{key:"",value:"Relevance"},{key:s+" desc",value:"Most Recent"}],(i=e.metadata.sorts)!=null&&i.length){const p=e.metadata.sorts.map(d=>({value:d.label,key:d.name+" "+d.order}));a.options=[{key:"",value:"Relevance"},...p]}return t=((u=(h=(l=(c=e==null?void 0:e.spellcheck)==null?void 0:c.suggestions)==null?void 0:l[1])==null?void 0:h.suggestion)==null?void 0:u[0])??"",typeof t!="string"&&(t=(t==null?void 0:t.word)??""),{recordsPerPageValue:parseInt(e.responseHeader.params.rows),startDocVal:parseInt(e.response.start+""),totalResultsValue:parseInt(e.response.numFound+""),latency:parseInt(e.responseHeader.QTime+""),endDocValue:parseInt(e.responseHeader.params.rows)+parseInt(e.response.start+""),spellingSuggestion:t,autoCorrectedQuery:e.responseHeader.params.autoCorrectedQ??"",impressions:this.getImpressions(e),sorting:a}}static getImpressions(e){const t=[],a=this.combineResultsWithMetadata(e);for(const s in a){const r=a[s],i={};i.cDocId=this.getDataForAnalytics(r.uniqueId),r.title&&(i.cDocTitle=this.getDataForAnalytics(r.title)),i.position=r.position,t.push(i)}return t}static getDataForAnalytics(e){return e!==null?typeof e>"u"?"":typeof e=="string"?e:typeof e.join<"u"?e[0]:e:""}static findResultByUniqueId(e,t){return t.find(a=>a.uniqueId===e)??null}static getUnmappedFields(e,t,a){const s=t.metadata.results.filter(i=>i.result_card==="").map(i=>i.name),r=[];for(const i of Object.keys(e))if(s.indexOf(i)!==-1){const c=Array.isArray(e[i])?this.getHighlightedResults(i,e[i].join(", "),a,t):this.getHighlightedResults(i,e[i]+"",a,t);r.push({key:i,value:c,isImage:this.checkIfImage(e[i])})}return r}static checkIfImage(e){return e===void 0?!1:typeof e!="string"?Array.isArray(e)&&e[0]?/\.(gif|jpe?g|tiff?|png|webp|bmp)$/i.test(e[0]):!1:/\.(gif|jpe?g|tiff?|png|webp|bmp)$/i.test(e)}static getAllFields(e,t){const a=t.metadata.results.map(r=>r.name),s=[];for(const r of Object.keys(e))a.indexOf(r)!==-1&&s.push({key:r,value:e[r],isImage:this.checkIfImage(e[r])});return s}static doesMapExist(e,t){return t.metadata.results.find(a=>a.result_card===e)!==void 0}static getValueByKey(e,t,a,s,r=!1){const i=a.metadata.results.find(l=>l.result_card===e);if(i===void 0)return null;const c=t[i.name];return c===void 0?null:typeof c=="string"?r?c:this.getHighlightedResults(i.name,c,s,a):Array.isArray(c)?r?c.join(", "):this.getHighlightedResults(i.name,c.join(", "),s,a):null}static getHighlightedResults(e,t,a,s){if(s.highlighting&&a in s.highlighting){let r=s.highlighting[a];if(r&&e in r){let i=r[e];const c=this.cleanValue(i);if(c!=="")return c}}return t}static cleanValue(e){return e===null?"":typeof e=="string"?e:Array.isArray(e)?e.join(" "):""}}class X{constructor(e){n(this,"routeName","searchstax");n(this,"ignoredKeys",[]);n(this,"queryStringHelper");n(this,"titleParser");e.routeName&&(this.routeName=e.routeName),e.ignoredKeys&&(this.ignoredKeys=e.ignoredKeys),e.title&&(this.titleParser=e.title),this.queryStringHelper=new ee(this.routeName)}updateUrl(e){const t=this.searchObjectToUrl(e);let a=typeof document<"u"?document==null?void 0:document.title:"";this.titleParser&&(a=this.titleParser(e)),typeof document<"u"&&(document.title=a),(window==null?void 0:window.location.href)!==t&&(window==null||window.history.replaceState(window.history.state,a,t))}searchObjectToUrl(e){return this.queryStringHelper.urlHasQueryParams((window==null?void 0:window.location.href)??"")?(window==null?void 0:window.location.href.split("?")[0])+"?"+this.queryStringHelper.stringify(this.searchObjectToParams(e),{ignoredKeys:this.ignoredKeys}):(window==null?void 0:window.location.href)+"?"+this.queryStringHelper.stringify(this.searchObjectToParams(e),{ignoredKeys:this.ignoredKeys})}searchObjectToParams(e){const t={},a=e.page||1;if(e.query&&(t[this.routeName+"[query]"]=encodeURIComponent(e.query)),e.page&&(t[this.routeName+"[page]"]=a+""),e.order&&(t[this.routeName+"[order]"]=e.order),e.facets)for(const s in e.facets){const r=e.facets[s].type+":"+encodeURIComponent(e.facets[s].name)+":"+encodeURIComponent(e.facets[s].value);t[this.routeName+`[facets][${s}]`]=r}if(this.queryStringHelper.urlHasQueryParams((window==null?void 0:window.location.href)??"")){const s=this.queryStringHelper.urlToParams((window==null?void 0:window.location.href)??"");for(const r in s)r.startsWith(this.routeName)&&delete s[r];return{...s,...t}}else return t}extractParamsThatDoNotStartWithRouteName(e){const t={};for(const a in e)a.startsWith(this.routeName)||(t[a]=e[a]);return t}extractArrayOfFacetsFromQueryParameters(e){var a,s,r;const t=[];for(const i in e)if(i.startsWith(this.routeName+"[facets]")){const c=F.removeXSSRiskyTags((a=e[i].split(":"))==null?void 0:a[0]),l=F.removeXSSRiskyTags(decodeURIComponent((s=e[i].split(":"))==null?void 0:s[1])),h=F.removeXSSRiskyTags(decodeURIComponent((r=e[i].split(":"))==null?void 0:r[2]));t.push({type:c,name:l,value:h})}return t}urlToSearchObject(e,t){const a=this.queryStringHelper.urlToParams(e),s=F.removeXSSRiskyTags(decodeURIComponent(a[this.routeName+"[page]"])),r=parseInt(s),i=isNaN(r)?1:r;return{query:F.removeXSSRiskyTags(decodeURIComponent(a[this.routeName+"[query]"]))||"",page:i,itemsPerPage:t,order:F.removeXSSRiskyTags(a[this.routeName+"[order]"])||"",facets:this.extractArrayOfFacetsFromQueryParameters(a)||[]}}}class ee{constructor(e){n(this,"routeName","");n(this,"stringify",(e,t)=>{const a=this.filterOutIgnoredKeys(e,t.ignoredKeys);return Object.keys(a).map(s=>{const r=a[s];return Array.isArray(r)?r.map(i=>`${s}=${i}`).join("&"):`${s}=${r}`}).join("&")});this.routeName=e}filterOutIgnoredKeys(e,t){const a=t||[],s={};return Object.keys(e).forEach(r=>{a.includes(r)||e[r]!==""&&(s[r]=e[r])}),s}urlToParams(e){const t={},a=e.split("?")[1];return a&&a.split("&").forEach(s=>{const[r,i]=s.split("=");t[r]=i}),t}doesParamContainRouteName(e){return e.indexOf(this.routeName)!==-1}urlHasQueryParams(e){return e.indexOf("?")!==-1}}const q={questionURL:"http://smartsearch-dev.searchstax.co/completion/?q=",question:"I_AM_A_QUESTION",notQuestion:"I_AM_NOT_A_QUESTION",close:"CLOSE"};class te{constructor(e,t){n(this,"cachedQuery","");n(this,"url","");n(this,"relatedSearches","");n(this,"suggester","");n(this,"authHeader");n(this,"authHeaderRelated");n(this,"trackApiKey","");n(this,"session","");n(this,"searchAuthType");n(this,"searchAuth","");n(this,"controllerSearch");n(this,"signalSearch");n(this,"controllerSuggest");n(this,"signalSuggest");n(this,"dataLayer");this.dataLayer=t,this.url=e.searchURL,this.dataLayer.setLanguage(e.language),this.suggester=e.suggesterURL,this.trackApiKey=e.trackApiKey,this.session=e.sessionId,this.searchAuthType=e.authType,this.searchAuth=e.searchAuth,this.authHeader=new Headers,this.authHeader.append("Accept","application/json");const a=this.searchAuthType==="token"?`Token ${e.searchAuth}`:`Basic ${e.searchAuth}`;this.authHeader.append("Authorization",a),this.authHeaderRelated=new Headers,this.authHeaderRelated.append("Accept","application/json"),this.authHeaderRelated.append("Authorization",e.searchAuth)}generateFacetQuery(e,t){let a=[];if(!t)e.forEach(function(s){const r=s.name+':"'+s.value+'"';a=a.concat("fq="+decodeURIComponent(r).replace(" "," "))});else{const s={};e.forEach(function(r){const i=r.name+":"+r.value,c=decodeURIComponent(i).replace(" "," ").split(":");s[c[0]]?s[c[0]].push(c[1]):s[c[0]]=[c[1]]});for(const r in s)if(Object.prototype.hasOwnProperty.call(s,r)){const i=s[r],c=r;let l="";for(const h of i)l+=` ${c}:"${h}"`;a=a.concat("fq="+l.trim())}}return a.length?"&"+a.join("&"):""}getRelatedSearches(e,t,a,s){const r=new Headers;r.append("Accept","application/json"),r.append("Authorization",a),fetch(t+"?search="+encodeURIComponent(e.query)+"&language="+this.dataLayer.language,{method:"GET",headers:r,credentials:"same-origin"}).then(i=>i.json()).then(i=>{s(i)})}cacheFacets(){this.dataLayer.searchObject.query!==this.cachedQuery&&(this.cachedQuery=this.dataLayer.searchObject.query,this.search({query:this.dataLayer.searchObject.query??"*",itemsPerPage:void 0,page:1,order:"",facets:[],additionalProps:this.dataLayer.searchObject.additionalProps},this.cacheFacetsCallback.bind(this),!0))}cacheFacetsCallback(e){let t=B.extractFacets(e);this.dataLayer.setSearchFacetsCached(t)}search(e,t,a=!1,s=!1){if(e.query&&e.query!=="undefined"){this.dataLayer.setSearchTerm(e.query),this.dataLayer.setLoading(!0),this.controllerSearch&&this.controllerSearch.abort(),this.controllerSearch=new AbortController,this.signalSearch=this.controllerSearch.signal;const r=new Proxy(new URLSearchParams((window==null?void 0:window.location.search)??""),{get:(d,f)=>d.get(f)??""}),i=r.languageVariant?"&fq=_language:"+r.languageVariant:"";let c=e.itemsPerPage,l=(e.itemsPerPage?e.itemsPerPage:0)*(e.page-1),h=e.order?`&sort=${e.order}`:"";const u=this.url+"?q="+encodeURIComponent(e.query.trim())+"&start="+l+this.toQueryString(e.additionalProps??[])+this.generateFacetQuery(e.facets.filter(d=>d.type==="or"||d.type==="showUnavailable"),!0)+this.generateFacetQuery(e.facets.filter(d=>d.type==="and"||d.type==="tabs"),!1)+h+`&spellcheck.correct=${this.dataLayer.autoCorrect&&!s}`+(c?`&rows=${c}`:"")+"&language="+this.dataLayer.language+i,p={method:"GET",headers:this.authHeader,credentials:"same-origin",signal:this.signalSearch};a&&delete p.signal,fetch(u,p).then(d=>d.json()).then(d=>{this.dataLayer.setLoading(!1),t(d)}).catch(()=>{this.dataLayer.setLoading(!1)})}}startSSE(e,t){if(!this.dataLayer.turnAIAnswerGenerationOn||e==="*"||this.dataLayer.lastSearchValue===e||this.dataLayer.searchObject.facets.length>0||this.dataLayer.searchObject.page!==1)return;const a=new EventSource(q.questionURL+e),s=this.dataLayer;a.onmessage=function(r){if(r.data===q.question||r.data===q.notQuestion){s.setAnswerData("");return}if(r.data===q.close){a.close();return}t(r.data)},a.onerror=function(){a.close()}}suggest(e,t,a){this.controllerSuggest&&this.controllerSuggest.abort(),this.controllerSuggest=new AbortController,this.signalSuggest=this.controllerSuggest.signal;const s=this.suggester+"?q="+e.trim()+this.toQueryString(a)+"&language="+this.dataLayer.language;fetch(s,{method:"GET",headers:this.authHeader,credentials:"same-origin",signal:this.signalSuggest}).then(r=>r.json()).then(r=>{t(r)}).catch(()=>()=>{})}fields(){return this.fields}toQueryString(e){if(e.length===0)return"";const t=[];for(const a of e)t.push(encodeURIComponent(a.key)+"="+encodeURIComponent(a.value));return"&"+t.join("&")}}class ${static trackClick(e){const t={key:e.trackApiKey,query:e.searchTerm,shownHits:e.recordsPerPage,totalHits:e.totalResults,pageNo:e.currentPage,latency:e.latencyVal,session:e.session,cDocId:e.result.uniqueId,cDocTitle:e.result.titleTracking,position:e.result.position,language:e.language};return new Promise((a,s)=>{const r=["trackClick",t];t.key&&this.msq().push(r,(function(i,c){JSON.stringify(i)===JSON.stringify(t)&&c?a():s()}).bind(this))})}static trackSearch(e){const t={key:e.trackApiKey,query:e.searchTerm,shownHits:e.recordsPerPage,totalHits:e.totalResults,pageNo:e.currentPage,latency:e.latencyVal,session:e.session,language:e.language,impressions:e.impressions};setTimeout(()=>{t.key&&this.msq().push(["track",t])},0)}static trackRelatedSearchClick(e){const t={session:e.session,key:e.trackApiKey,query:e.relatedSearch.search_term,position:e.relatedSearch.position,relatedSearch:e.relatedSearch.related_search,pageNo:e.currentPage,shownHits:e.recordsPerPage,totalHits:e.totalResults,language:e.language};setTimeout(()=>{t.key&&this.msq().push(["trackRelatedSearchClick",t])},0)}static trackRelatedSearches(e){const t={session:e.session,key:e.trackApiKey,query:e.searchTerm,shownHits:e.recordsPerPage,latency:e.latencyVal,language:e.language,impressions:e.impressions};setTimeout(()=>{t.key&&this.msq().push(["trackRelatedSearch",t])},0)}}n($,"subscribedToClickEvent",!1),n($,"msq",()=>typeof window<"u"&&(window!=null&&window._msq)?window==null?void 0:window._msq:[]);/*!
2
2
  * mustache.js - Logic-less {{mustache}} templates with JavaScript
3
3
  * http://github.com/janl/mustache.js
4
4
  */var ae=Object.prototype.toString,H=Array.isArray||function(e){return ae.call(e)==="[object Array]"};function _(o){return typeof o=="function"}function se(o){return H(o)?"array":typeof o}function z(o){return o.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g,"\\$&")}function G(o,e){return o!=null&&typeof o=="object"&&e in o}function re(o,e){return o!=null&&typeof o!="object"&&o.hasOwnProperty&&o.hasOwnProperty(e)}var ie=RegExp.prototype.test;function ne(o,e){return ie.call(o,e)}var ce=/\S/;function le(o){return!ne(ce,o)}var oe={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;","/":"&#x2F;","`":"&#x60;","=":"&#x3D;"};function he(o){return String(o).replace(/[&<>"'`=\/]/g,function(t){return oe[t]})}var ue=/\s*/,de=/\s+/,Y=/\s*=/,ge=/\s*\}/,pe=/#|\^|\/|>|\{|&|=|!/;function fe(o,e){if(!o)return[];var t=!1,a=[],s=[],r=[],i=!1,c=!1,l="",h=0;function u(){if(i&&!c)for(;r.length;)delete s[r.pop()];else r=[];i=!1,c=!1}var p,d,f;function b(w){if(typeof w=="string"&&(w=w.split(de,2)),!H(w)||w.length!==2)throw new Error("Invalid tags: "+w);p=new RegExp(z(w[0])+"\\s*"),d=new RegExp("\\s*"+z(w[1])),f=new RegExp("\\s*"+z("}"+w[1]))}b(e||y.tags);for(var C=new j(o),m,v,x,k,I,T;!C.eos();){if(m=C.pos,x=C.scanUntil(p),x)for(var D=0,Q=x.length;D<Q;++D)k=x.charAt(D),le(k)?(r.push(s.length),l+=k):(c=!0,t=!0,l+=" "),s.push(["text",k,m,m+1]),m+=1,k===`
@@ -602,7 +602,7 @@ class z {
602
602
  updateUrl(e) {
603
603
  const t = this.searchObjectToUrl(e);
604
604
  let a = typeof document < "u" ? document == null ? void 0 : document.title : "";
605
- this.titleParser && (a = this.titleParser(e)), typeof document < "u" && (document.title = a), (window == null ? void 0 : window.location.href) !== t && (window == null || window.history.pushState({}, a, t));
605
+ this.titleParser && (a = this.titleParser(e)), typeof document < "u" && (document.title = a), (window == null ? void 0 : window.location.href) !== t && (window == null || window.history.replaceState(window.history.state, a, t));
606
606
  }
607
607
  searchObjectToUrl(e) {
608
608
  return this.queryStringHelper.urlHasQueryParams((window == null ? void 0 : window.location.href) ?? "") ? (window == null ? void 0 : window.location.href.split("?")[0]) + "?" + this.queryStringHelper.stringify(
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@searchstax-inc/searchstudio-ux-js",
3
3
  "private": false,
4
- "version": "1.0.4",
4
+ "version": "1.0.5",
5
5
  "files": [
6
6
  "dist"
7
7
  ],