@searchstax-inc/searchstudio-ux-js 0.5.10 → 0.5.11

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 J=Object.defineProperty;var X=(l,e,t)=>e in l?J(l,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):l[e]=t;var n=(l,e,t)=>(X(l,typeof e!="symbol"?e+"":e,t),t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});var x=(l=>(l[l.mustache=0]="mustache",l[l.vue=1]="vue",l[l.react=2]="react",l[l.angular=3]="angular",l))(x||{});class G{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(){var e;return((e=this.dataLayer.searchResultsMetadata)==null?void 0:e.recordsPerPageValue)||0}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 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 searchTerm(){var e,t;return((e=this.dataLayer.searchResultsMetadata)==null?void 0:e.autoCorrectedQuery)||((t=this.dataLayer.searchObject)==null?void 0:t.query)||""}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)!==""&&this.dataLayer.getAnswerData===""}get selectedFacets(){var t;const e=this.dataLayer.searchFacetsCached??this.dataLayer.searchFacets;return e?(((t=this.dataLayer.searchObject)==null?void 0:t.facets)??[]).map(s=>{const i=s.name,c=s.value,o=e.find(h=>h.name===i);if(o){const h=o.values.find(u=>u.type==="range"?!1:u.type==="checkbox"?'"'+u.value+'"'===c:!1);if(h)return h}return null}).filter(s=>s!==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,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}}get trackingData(){var e,t,a,r;return{searchTerm:this.dataLayer.searchTerm!=="undefined"?this.dataLayer.searchTerm:"",trackApiKey:((e=this.dataLayer.searchstaxConfig)==null?void 0:e.trackApiKey)??"",session:this.dataLayer.sessionId,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:((r=this.dataLayer.searchResultsMetadata)==null?void 0:r.latency)??0}}}class P{static deepEqual(e,t){const a=Object.keys(e),r=Object.keys(t);if(a.length!==r.length)return!1;for(const s of a){const i=e[s],c=t[s],o=this.isObject(i)&&this.isObject(c);if(o&&!this.deepEqual(i,c)||!o&&i!==c)return!1}return!0}static isObject(e){return e!=null&&typeof e=="object"}}class v{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 W{static getOrSetCookie(e){let t=this.getCookie(e);return t==null&&(t=this.makeid(25),this.setCookie(e,t,{secure:!0,"max-age":3600})),t}static deleteCookie(e){this.getCookie(e)&&this.setCookie(e,"",{secure:!0,"max-age":-1})}static makeid(e){let t="";const a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",r=a.length;for(let s=0;s<e;s++)t+=a.charAt(Math.floor(Math.random()*r));return t}static getCookie(e){const t=document.cookie.match(new RegExp("(?:^|; )"+e.replace(/([.$?*|{}()[\]\\/+^])/g,"\\$1")+"=([^;]*)"));return t?decodeURIComponent(t[1]):void 0}static setCookie(e,t,a){const r={path:"/",...a};a.expires instanceof Date&&(r.expires=a.expires.toUTCString());let s=encodeURIComponent(e)+"="+encodeURIComponent(t);for(const i in r){s+="; "+i;const c=r[i];c!==!0&&(s+="="+c)}document.cookie=s}}class E{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 Y{constructor(e){n(this,"$searchTermChange",new v(""));n(this,"$loadingChange",new v(!1));n(this,"$searchResults",new v(null));n(this,"$searchResultsMetadata",new v(null));n(this,"$searchAutosuggest",new v(null));n(this,"$searchFacets",new v(null));n(this,"$searchFacetsCached",new v(null));n(this,"$searchstaxConfig",new v(null));n(this,"$autosuggestResults",new v(null));n(this,"$searchObject",new v({query:"",page:99999999,order:"",facets:[],additionalProps:[]}));n(this,"$searchRelatedSearches",new v(null));n(this,"$searchInputConfig",new v(null));n(this,"$searchExternalPromotions",new v(null));n(this,"$facetsTemplateData",new v(null));n(this,"$selectedFacetsTemplateData",new v(null));n(this,"$paginationData",new v(null));n(this,"$searchFeedbackData",new v(null));n(this,"$searchSortingData",new v(null));n(this,"$searchRelatedSearchesData",new v(null));n(this,"$searchExternalPromotionsData",new v(null));n(this,"$cookiesDisabled",new v(null));n(this,"$answer",new v(""));n(this,"$language",new v("en"));n(this,"currentPageValue",1);n(this,"isAnswerWidgetCreatedValue",!1);n(this,"renderingEngineValue",x.mustache);n(this,"parsedData",new G(this));n(this,"sessionId");n(this,"autoCorrect",!0);n(this,"forceNotCorrect",!1);this.sessionId=e,this.cookieHandlingCallback(),this.$cookiesDisabled.subscribe(()=>{this.cookieHandlingCallback()})}cookieHandlingCallback(){this.cookiesDisabled?(W.deleteCookie(this.sessionId),W.deleteCookie("ms_visitorid")):W.getOrSetCookie(this.sessionId)}setSearchTerm(e){this.$searchTermChange.setValue(E.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){P.deepEqual(e,this.searchResults??[""])||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,r;let t=e;(r=(a=this.searchstaxConfig)==null?void 0:a.hooks)!=null&&r.beforeSearch&&t&&(t=this.searchstaxConfig.hooks.beforeSearch(t)),t&&(!P.deepEqual(t,this.searchObject??{})||this.forceNotCorrect)&&this.$searchObject.setValue(t)}setSearchFacets(e){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)}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.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}}class ${static combineResultsWithMetadata(e){const t=[],a=parseInt(e.response.start+"")-1,r=parseInt(e.responseHeader.params.rows);return e.response.docs.forEach((s,i)=>{const c={custom:null,uniqueId:this.getValueByKey(e.responseHeader.params.uniqueId,s,e)??"",position:a*r+1+i,ribbon:this.doesMapExist("ribbon",e)?this.getValueByKey("ribbon",s,e):null,paths:this.doesMapExist("paths",e)?this.getValueByKey("paths",s,e):null,url:this.doesMapExist("url",e)?this.getValueByKey("url",s,e):null,title:this.doesMapExist("title",e)?this.getValueByKey("title",s,e):null,promoted:s["[elevated]"]?s["[elevated]"]:!1,thumbnail:this.doesMapExist("thumbnail",e)?this.getValueByKey("thumbnail",s,e):null,date:this.doesMapExist("date",e)?this.getValueByKey("date",s,e):null,snippet:this.doesMapExist("snippet",e)?this.getValueByKey("snippet",s,e):null,description:this.doesMapExist("description",e)?this.getValueByKey("description",s,e):null,unmappedFields:this.getUnmappedFields(s,e),allFields:this.getAllFields(s,e)};t.push(c)}),t}static extractFacets(e){const t=[];for(const a of e.metadata.facets){let r={values:[]};if(r.name=a.name,r.label=a.label,a.name in e.facet_counts.facet_fields){const s=e.facet_counts.facet_fields[a.name];for(let i=0;i<s.length;i+=2){const c={};c.value=s[i],c.parentName=r.name,c.count=s[i+1],c.type="checkbox",r.values.push(c)}}r.values.length>0&&t.push(r)}return t}static extractSearchResultsMetadata(e){var a,r,s,i;let t="";return t=((i=(s=(r=(a=e==null?void 0:e.spellcheck)==null?void 0:a.suggestions)==null?void 0:r[0])==null?void 0:s.suggestion)==null?void 0:i[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)}}static getImpressions(e){const t=[],a=this.combineResultsWithMetadata(e);for(const r in a){const s=a[r],i={};i.cDocId=this.getDataForAnalytics(s.uniqueId),s.title&&(i.cDocTitle=this.getDataForAnalytics(s.title)),i.position=s.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){const a=t.metadata.results.filter(s=>s.result_card==="").map(s=>s.name),r=[];for(const s of Object.keys(e))if(a.indexOf(s)!==-1){const i=Array.isArray(e[s])?e[s].join(", "):e[s];r.push({key:s,value:i,isImage:this.checkIfImage(e[s])})}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(s=>s.name),r=[];for(const s of Object.keys(e))a.indexOf(s)!==-1&&r.push({key:s,value:e[s],isImage:this.checkIfImage(e[s])});return r}static doesMapExist(e,t){return t.metadata.results.find(a=>a.result_card===e)!==void 0}static getValueByKey(e,t,a){const r=a.metadata.results.find(i=>i.result_card===e);if(r===void 0)return null;const s=t[r.name];return s===void 0?null:typeof s=="string"?s:Array.isArray(s)?s.join(", "):null}}class K{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 Z(this.routeName)}updateUrl(e){const t=this.searchObjectToUrl(e);let a=document.title;this.titleParser&&(a=this.titleParser(e)),document.title=a,window.location.href!==t&&window.history.pushState({},a,t)}searchObjectToUrl(e){return this.queryStringHelper.urlHasQueryParams(window.location.href)?window.location.href.split("?")[0]+"?"+this.queryStringHelper.stringify(this.searchObjectToParams(e),{ignoredKeys:this.ignoredKeys}):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)),t[this.routeName+"[page]"]=a+"",e.order&&(t[this.routeName+"[order]"]=e.order),e.facets)for(const r in e.facets){const s=e.facets[r].type+":"+encodeURIComponent(e.facets[r].name)+":"+encodeURIComponent(e.facets[r].value);t[this.routeName+`[facets][${r}]`]=s}if(this.queryStringHelper.urlHasQueryParams(window.location.href)){const r=this.queryStringHelper.urlToParams(window.location.href);for(const s in r)s.startsWith(this.routeName)&&delete r[s];return{...r,...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,r,s;const t=[];for(const i in e)if(i.startsWith(this.routeName+"[facets]")){const c=E.removeXSSRiskyTags((a=e[i].split(":"))==null?void 0:a[0]),o=E.removeXSSRiskyTags(decodeURIComponent((r=e[i].split(":"))==null?void 0:r[1])),h=E.removeXSSRiskyTags(decodeURIComponent((s=e[i].split(":"))==null?void 0:s[2]));t.push({type:c,name:o,value:h})}return t}urlToSearchObject(e){const t=this.queryStringHelper.urlToParams(e),a=E.removeXSSRiskyTags(decodeURIComponent(t[this.routeName+"[page]"])),r=parseInt(a),s=isNaN(r)?1:r;return{query:E.removeXSSRiskyTags(decodeURIComponent(t[this.routeName+"[query]"]))||"",page:s,order:E.removeXSSRiskyTags(t[this.routeName+"[order]"])||"",facets:this.extractArrayOfFacetsFromQueryParameters(t)||[]}}}class Z{constructor(e){n(this,"routeName","");n(this,"stringify",(e,t)=>{const a=this.filterOutIgnoredKeys(e,t.ignoredKeys);return Object.keys(a).map(r=>{const s=a[r];return Array.isArray(s)?s.map(i=>`${r}=${i}`).join("&"):`${r}=${s}`}).join("&")});this.routeName=e}filterOutIgnoredKeys(e,t){const a=t||[],r={};return Object.keys(e).forEach(s=>{a.includes(s)||e[s]!==""&&(r[s]=e[s])}),r}urlToParams(e){const t={},a=e.split("?")[1];return a&&a.split("&").forEach(r=>{const[s,i]=r.split("=");t[s]=i}),t}doesParamContainRouteName(e){return e.indexOf(this.routeName)!==-1}urlHasQueryParams(e){return e.indexOf("?")!==-1}}const M={questionURL:"http://smartsearch-dev.searchstax.co/completion/?q=",question:"I_AM_A_QUESTION",notQuestion:"I_AM_NOT_A_QUESTION",close:"CLOSE"};class ee{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(r){const s=r.name+':"'+r.value+'"';a=a.concat("fq="+decodeURIComponent(s).replace(" "," "))});else{const r={};e.forEach(function(s){const i=s.name+":"+s.value,c=decodeURIComponent(i).replace(" "," ").split(":");r[c[0]]?r[c[0]].push(c[1]):r[c[0]]=[c[1]]});for(const s in r)if(Object.prototype.hasOwnProperty.call(r,s)){const i=r[s],c=s;let o="";for(const h of i)o+=` ${c}:"${h}"`;a=a.concat("fq="+o.trim())}}return a.length?"&"+a.join("&"):""}getRelatedSearches(e,t,a,r){const s=new Headers;s.append("Accept","application/json"),s.append("Authorization",a),fetch(t+"?search="+encodeURIComponent(e.query)+"&language="+this.dataLayer.language,{method:"GET",headers:s,credentials:"same-origin"}).then(i=>i.json()).then(i=>{r(i)})}cacheFacets(){this.dataLayer.searchObject.query!==this.cachedQuery&&(this.cachedQuery=this.dataLayer.searchObject.query,this.search({query:this.dataLayer.searchObject.query??"*",page:1,order:"",facets:[],additionalProps:this.dataLayer.searchObject.additionalProps},this.cacheFacetsCallback.bind(this)))}cacheFacetsCallback(e){let t=$.extractFacets(e);this.dataLayer.setSearchFacetsCached(t)}search(e,t,a=!1,r=!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 s=new Proxy(new URLSearchParams(window.location.search),{get:(u,g)=>u.get(g)??""}),i=s.languageVariant?"&fq=_language:"+s.languageVariant:"",c=e.order?`&sort=${e.order}`:"",o=this.url+"?q="+encodeURIComponent(e.query.trim())+"&start="+(e.page-1)+this.toQueryString(e.additionalProps??[])+this.generateFacetQuery(e.facets.filter(u=>u.type==="or"||u.type==="showUnavailable"),!0)+this.generateFacetQuery(e.facets.filter(u=>u.type==="and"||u.type==="tabs"),!1)+c+`&spellcheck.correct=${this.dataLayer.autoCorrect&&!r}&language=`+this.dataLayer.language+i,h={method:"GET",headers:this.authHeader,credentials:"same-origin",signal:this.signalSearch};a&&delete h.signal,fetch(o,h).then(u=>u.json()).then(u=>{this.dataLayer.setLoading(!1),t(u)}).catch(()=>{this.dataLayer.setLoading(!1)})}}startSSE(e,t){const a=new EventSource(M.questionURL+e),r=this.dataLayer;a.onmessage=function(s){if(s.data===M.question||s.data===M.notQuestion){r.setAnswerData("");return}if(s.data===M.close){a.close();return}t(s.data)},a.onerror=function(s){console.log(s),a.close()}}suggest(e,t,a){this.controllerSuggest&&this.controllerSuggest.abort(),this.controllerSuggest=new AbortController,this.signalSuggest=this.controllerSuggest.signal;const r=this.suggester+"?q="+e.trim()+this.toQueryString(a)+"&language="+this.dataLayer.language;fetch(r,{method:"GET",headers:this.authHeader,credentials:"same-origin",signal:this.signalSuggest}).then(s=>s.json()).then(s=>{t(s)}).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 H{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.title,position:e.result.position,language:e.language};setTimeout(()=>{t.key&&this.msq.push(["trackClick",t])},0)}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(["trackSearch",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(H,"msq",window._msq||[]);/*!
1
+ "use strict";var J=Object.defineProperty;var X=(l,e,t)=>e in l?J(l,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):l[e]=t;var n=(l,e,t)=>(X(l,typeof e!="symbol"?e+"":e,t),t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});var x=(l=>(l[l.mustache=0]="mustache",l[l.vue=1]="vue",l[l.react=2]="react",l[l.angular=3]="angular",l))(x||{});class G{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(){var e;return((e=this.dataLayer.searchResultsMetadata)==null?void 0:e.recordsPerPageValue)||0}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 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 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 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(s=>{const i=s.name,c=s.value,o=e.find(h=>h.name===i);if(o){const h=o.values.find(u=>u.type==="range"?!1:u.type==="checkbox"?'"'+u.value+'"'===c:!1);if(h)return h}return null}).filter(s=>s!==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}}get trackingData(){var e,t,a,r;return{searchTerm:this.dataLayer.searchTerm!=="undefined"?this.dataLayer.searchTerm:"",trackApiKey:((e=this.dataLayer.searchstaxConfig)==null?void 0:e.trackApiKey)??"",session:this.dataLayer.sessionId,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:((r=this.dataLayer.searchResultsMetadata)==null?void 0:r.latency)??0}}}class P{static deepEqual(e,t){const a=Object.keys(e),r=Object.keys(t);if(a.length!==r.length)return!1;for(const s of a){const i=e[s],c=t[s],o=this.isObject(i)&&this.isObject(c);if(o&&!this.deepEqual(i,c)||!o&&i!==c)return!1}return!0}static isObject(e){return e!=null&&typeof e=="object"}}class v{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 W{static getOrSetCookie(e){let t=this.getCookie(e);return t==null&&(t=this.makeid(25),this.setCookie(e,t,{secure:!0,"max-age":3600})),t}static deleteCookie(e){this.getCookie(e)&&this.setCookie(e,"",{secure:!0,"max-age":-1})}static makeid(e){let t="";const a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",r=a.length;for(let s=0;s<e;s++)t+=a.charAt(Math.floor(Math.random()*r));return t}static getCookie(e){const t=document.cookie.match(new RegExp("(?:^|; )"+e.replace(/([.$?*|{}()[\]\\/+^])/g,"\\$1")+"=([^;]*)"));return t?decodeURIComponent(t[1]):void 0}static setCookie(e,t,a){const r={path:"/",...a};a.expires instanceof Date&&(r.expires=a.expires.toUTCString());let s=encodeURIComponent(e)+"="+encodeURIComponent(t);for(const i in r){s+="; "+i;const c=r[i];c!==!0&&(s+="="+c)}document.cookie=s}}class E{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 Y{constructor(e){n(this,"$searchTermChange",new v(""));n(this,"$loadingChange",new v(!1));n(this,"$searchResults",new v(null));n(this,"$searchResultsMetadata",new v(null));n(this,"$searchAutosuggest",new v(null));n(this,"$searchFacets",new v(null));n(this,"$searchFacetsCached",new v(null));n(this,"$searchstaxConfig",new v(null));n(this,"$autosuggestResults",new v(null));n(this,"$searchObject",new v({query:"",page:99999999,order:"",facets:[],additionalProps:[]}));n(this,"$searchRelatedSearches",new v(null));n(this,"$searchInputConfig",new v(null));n(this,"$searchExternalPromotions",new v(null));n(this,"$facetsTemplateData",new v(null));n(this,"$selectedFacetsTemplateData",new v(null));n(this,"$paginationData",new v(null));n(this,"$searchFeedbackData",new v(null));n(this,"$searchSortingData",new v(null));n(this,"$searchRelatedSearchesData",new v(null));n(this,"$searchExternalPromotionsData",new v(null));n(this,"$cookiesDisabled",new v(null));n(this,"$answer",new v(""));n(this,"$language",new v("en"));n(this,"currentPageValue",1);n(this,"isAnswerWidgetCreatedValue",!1);n(this,"renderingEngineValue",x.mustache);n(this,"parsedData",new G(this));n(this,"sessionId");n(this,"autoCorrect",!0);n(this,"forceNotCorrect",!1);this.sessionId=e,this.cookieHandlingCallback(),this.$cookiesDisabled.subscribe(()=>{this.cookieHandlingCallback()})}cookieHandlingCallback(){this.cookiesDisabled?(W.deleteCookie(this.sessionId),W.deleteCookie("ms_visitorid")):W.getOrSetCookie(this.sessionId)}setSearchTerm(e){this.$searchTermChange.setValue(E.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){P.deepEqual(e,this.searchResults??[""])||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,r;let t=e;(r=(a=this.searchstaxConfig)==null?void 0:a.hooks)!=null&&r.beforeSearch&&t&&(t=this.searchstaxConfig.hooks.beforeSearch(t)),t&&(!P.deepEqual(t,this.searchObject??{})||this.forceNotCorrect)&&this.$searchObject.setValue(t)}setSearchFacets(e){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)}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.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}}class ${static combineResultsWithMetadata(e){const t=[],a=parseInt(e.response.start+"")-1,r=parseInt(e.responseHeader.params.rows);return e.response.docs.forEach((s,i)=>{const c={custom:null,uniqueId:this.getValueByKey(e.responseHeader.params.uniqueId,s,e)??"",position:a*r+1+i,ribbon:this.doesMapExist("ribbon",e)?this.getValueByKey("ribbon",s,e):null,paths:this.doesMapExist("paths",e)?this.getValueByKey("paths",s,e):null,url:this.doesMapExist("url",e)?this.getValueByKey("url",s,e):null,title:this.doesMapExist("title",e)?this.getValueByKey("title",s,e):null,promoted:s["[elevated]"]?s["[elevated]"]:!1,thumbnail:this.doesMapExist("thumbnail",e)?this.getValueByKey("thumbnail",s,e):null,date:this.doesMapExist("date",e)?this.getValueByKey("date",s,e):null,snippet:this.doesMapExist("snippet",e)?this.getValueByKey("snippet",s,e):null,description:this.doesMapExist("description",e)?this.getValueByKey("description",s,e):null,unmappedFields:this.getUnmappedFields(s,e),allFields:this.getAllFields(s,e)};t.push(c)}),t}static extractFacets(e){const t=[];for(const a of e.metadata.facets){let r={values:[]};if(r.name=a.name,r.label=a.label,a.name in e.facet_counts.facet_fields){const s=e.facet_counts.facet_fields[a.name];for(let i=0;i<s.length;i+=2){const c={};c.value=s[i],c.parentName=r.name,c.count=s[i+1],c.type="checkbox",r.values.push(c)}}r.values.length>0&&t.push(r)}return t}static extractSearchResultsMetadata(e){var a,r,s,i;let t="";return t=((i=(s=(r=(a=e==null?void 0:e.spellcheck)==null?void 0:a.suggestions)==null?void 0:r[0])==null?void 0:s.suggestion)==null?void 0:i[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)}}static getImpressions(e){const t=[],a=this.combineResultsWithMetadata(e);for(const r in a){const s=a[r],i={};i.cDocId=this.getDataForAnalytics(s.uniqueId),s.title&&(i.cDocTitle=this.getDataForAnalytics(s.title)),i.position=s.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){const a=t.metadata.results.filter(s=>s.result_card==="").map(s=>s.name),r=[];for(const s of Object.keys(e))if(a.indexOf(s)!==-1){const i=Array.isArray(e[s])?e[s].join(", "):e[s];r.push({key:s,value:i,isImage:this.checkIfImage(e[s])})}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(s=>s.name),r=[];for(const s of Object.keys(e))a.indexOf(s)!==-1&&r.push({key:s,value:e[s],isImage:this.checkIfImage(e[s])});return r}static doesMapExist(e,t){return t.metadata.results.find(a=>a.result_card===e)!==void 0}static getValueByKey(e,t,a){const r=a.metadata.results.find(i=>i.result_card===e);if(r===void 0)return null;const s=t[r.name];return s===void 0?null:typeof s=="string"?s:Array.isArray(s)?s.join(", "):null}}class K{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 Z(this.routeName)}updateUrl(e){const t=this.searchObjectToUrl(e);let a=document.title;this.titleParser&&(a=this.titleParser(e)),document.title=a,window.location.href!==t&&window.history.pushState({},a,t)}searchObjectToUrl(e){return this.queryStringHelper.urlHasQueryParams(window.location.href)?window.location.href.split("?")[0]+"?"+this.queryStringHelper.stringify(this.searchObjectToParams(e),{ignoredKeys:this.ignoredKeys}):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)),t[this.routeName+"[page]"]=a+"",e.order&&(t[this.routeName+"[order]"]=e.order),e.facets)for(const r in e.facets){const s=e.facets[r].type+":"+encodeURIComponent(e.facets[r].name)+":"+encodeURIComponent(e.facets[r].value);t[this.routeName+`[facets][${r}]`]=s}if(this.queryStringHelper.urlHasQueryParams(window.location.href)){const r=this.queryStringHelper.urlToParams(window.location.href);for(const s in r)s.startsWith(this.routeName)&&delete r[s];return{...r,...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,r,s;const t=[];for(const i in e)if(i.startsWith(this.routeName+"[facets]")){const c=E.removeXSSRiskyTags((a=e[i].split(":"))==null?void 0:a[0]),o=E.removeXSSRiskyTags(decodeURIComponent((r=e[i].split(":"))==null?void 0:r[1])),h=E.removeXSSRiskyTags(decodeURIComponent((s=e[i].split(":"))==null?void 0:s[2]));t.push({type:c,name:o,value:h})}return t}urlToSearchObject(e){const t=this.queryStringHelper.urlToParams(e),a=E.removeXSSRiskyTags(decodeURIComponent(t[this.routeName+"[page]"])),r=parseInt(a),s=isNaN(r)?1:r;return{query:E.removeXSSRiskyTags(decodeURIComponent(t[this.routeName+"[query]"]))||"",page:s,order:E.removeXSSRiskyTags(t[this.routeName+"[order]"])||"",facets:this.extractArrayOfFacetsFromQueryParameters(t)||[]}}}class Z{constructor(e){n(this,"routeName","");n(this,"stringify",(e,t)=>{const a=this.filterOutIgnoredKeys(e,t.ignoredKeys);return Object.keys(a).map(r=>{const s=a[r];return Array.isArray(s)?s.map(i=>`${r}=${i}`).join("&"):`${r}=${s}`}).join("&")});this.routeName=e}filterOutIgnoredKeys(e,t){const a=t||[],r={};return Object.keys(e).forEach(s=>{a.includes(s)||e[s]!==""&&(r[s]=e[s])}),r}urlToParams(e){const t={},a=e.split("?")[1];return a&&a.split("&").forEach(r=>{const[s,i]=r.split("=");t[s]=i}),t}doesParamContainRouteName(e){return e.indexOf(this.routeName)!==-1}urlHasQueryParams(e){return e.indexOf("?")!==-1}}const M={questionURL:"http://smartsearch-dev.searchstax.co/completion/?q=",question:"I_AM_A_QUESTION",notQuestion:"I_AM_NOT_A_QUESTION",close:"CLOSE"};class ee{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(r){const s=r.name+':"'+r.value+'"';a=a.concat("fq="+decodeURIComponent(s).replace(" "," "))});else{const r={};e.forEach(function(s){const i=s.name+":"+s.value,c=decodeURIComponent(i).replace(" "," ").split(":");r[c[0]]?r[c[0]].push(c[1]):r[c[0]]=[c[1]]});for(const s in r)if(Object.prototype.hasOwnProperty.call(r,s)){const i=r[s],c=s;let o="";for(const h of i)o+=` ${c}:"${h}"`;a=a.concat("fq="+o.trim())}}return a.length?"&"+a.join("&"):""}getRelatedSearches(e,t,a,r){const s=new Headers;s.append("Accept","application/json"),s.append("Authorization",a),fetch(t+"?search="+encodeURIComponent(e.query)+"&language="+this.dataLayer.language,{method:"GET",headers:s,credentials:"same-origin"}).then(i=>i.json()).then(i=>{r(i)})}cacheFacets(){this.dataLayer.searchObject.query!==this.cachedQuery&&(this.cachedQuery=this.dataLayer.searchObject.query,this.search({query:this.dataLayer.searchObject.query??"*",page:1,order:"",facets:[],additionalProps:this.dataLayer.searchObject.additionalProps},this.cacheFacetsCallback.bind(this)))}cacheFacetsCallback(e){let t=$.extractFacets(e);this.dataLayer.setSearchFacetsCached(t)}search(e,t,a=!1,r=!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 s=new Proxy(new URLSearchParams(window.location.search),{get:(u,g)=>u.get(g)??""}),i=s.languageVariant?"&fq=_language:"+s.languageVariant:"",c=e.order?`&sort=${e.order}`:"",o=this.url+"?q="+encodeURIComponent(e.query.trim())+"&start="+(e.page-1)+this.toQueryString(e.additionalProps??[])+this.generateFacetQuery(e.facets.filter(u=>u.type==="or"||u.type==="showUnavailable"),!0)+this.generateFacetQuery(e.facets.filter(u=>u.type==="and"||u.type==="tabs"),!1)+c+`&spellcheck.correct=${this.dataLayer.autoCorrect&&!r}&language=`+this.dataLayer.language+i,h={method:"GET",headers:this.authHeader,credentials:"same-origin",signal:this.signalSearch};a&&delete h.signal,fetch(o,h).then(u=>u.json()).then(u=>{this.dataLayer.setLoading(!1),t(u)}).catch(()=>{this.dataLayer.setLoading(!1)})}}startSSE(e,t){const a=new EventSource(M.questionURL+e),r=this.dataLayer;a.onmessage=function(s){if(s.data===M.question||s.data===M.notQuestion){r.setAnswerData("");return}if(s.data===M.close){a.close();return}t(s.data)},a.onerror=function(s){console.log(s),a.close()}}suggest(e,t,a){this.controllerSuggest&&this.controllerSuggest.abort(),this.controllerSuggest=new AbortController,this.signalSuggest=this.controllerSuggest.signal;const r=this.suggester+"?q="+e.trim()+this.toQueryString(a)+"&language="+this.dataLayer.language;fetch(r,{method:"GET",headers:this.authHeader,credentials:"same-origin",signal:this.signalSuggest}).then(s=>s.json()).then(s=>{t(s)}).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 H{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.title,position:e.result.position,language:e.language};setTimeout(()=>{t.key&&this.msq.push(["trackClick",t])},0)}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(["trackSearch",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(H,"msq",window._msq||[]);/*!
2
2
  * mustache.js - Logic-less {{mustache}} templates with JavaScript
3
3
  * http://github.com/janl/mustache.js
4
4
  */var te=Object.prototype.toString,A=Array.isArray||function(e){return te.call(e)==="[object Array]"};function Q(l){return typeof l=="function"}function ae(l){return A(l)?"array":typeof l}function U(l){return l.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g,"\\$&")}function _(l,e){return l!=null&&typeof l=="object"&&e in l}function se(l,e){return l!=null&&typeof l!="object"&&l.hasOwnProperty&&l.hasOwnProperty(e)}var re=RegExp.prototype.test;function ie(l,e){return re.call(l,e)}var ne=/\S/;function ce(l){return!ie(ne,l)}var oe={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;","/":"&#x2F;","`":"&#x60;","=":"&#x3D;"};function le(l){return String(l).replace(/[&<>"'`=\/]/g,function(t){return oe[t]})}var he=/\s*/,ue=/\s+/,z=/\s*=/,de=/\s*\}/,ge=/#|\^|\/|>|\{|&|=|!/;function pe(l,e){if(!l)return[];var t=!1,a=[],r=[],s=[],i=!1,c=!1,o="",h=0;function u(){if(i&&!c)for(;s.length;)delete r[s.pop()];else s=[];i=!1,c=!1}var g,p,y;function b(w){if(typeof w=="string"&&(w=w.split(ue,2)),!A(w)||w.length!==2)throw new Error("Invalid tags: "+w);g=new RegExp(U(w[0])+"\\s*"),p=new RegExp("\\s*"+U(w[1])),y=new RegExp("\\s*"+U("}"+w[1]))}b(e||f.tags);for(var m=new j(l),C,S,L,R,I,T;!m.eos();){if(C=m.pos,L=m.scanUntil(g),L)for(var F=0,B=L.length;F<B;++F)R=L.charAt(F),ce(R)?(s.push(r.length),o+=R):(c=!0,t=!0,o+=" "),r.push(["text",R,C,C+1]),C+=1,R===`
@@ -91,6 +91,7 @@ export interface ISearchstaxParsedData {
91
91
  hasResults: boolean;
92
92
  hasResultsOrExternalPromotions: boolean;
93
93
  searchExecuted: boolean;
94
+ searchingEverything: boolean;
94
95
  hasRelatedSearches: boolean;
95
96
  hasExternalPromotions: boolean;
96
97
  startResultIndex: number;
@@ -226,6 +227,7 @@ declare class DataCalculations {
226
227
  get originalQuery(): string;
227
228
  get getAnswerData(): string;
228
229
  get searchTerm(): string;
230
+ get searchingEverything(): boolean;
229
231
  get searchExecuted(): boolean;
230
232
  get selectedFacets(): (IFacetValue | IFacetValueRange)[];
231
233
  get relatedSearches(): ISearchstaxRelatedSearchResult[];
@@ -91,6 +91,7 @@ export interface ISearchstaxParsedData {
91
91
  hasResults: boolean;
92
92
  hasResultsOrExternalPromotions: boolean;
93
93
  searchExecuted: boolean;
94
+ searchingEverything: boolean;
94
95
  hasRelatedSearches: boolean;
95
96
  hasExternalPromotions: boolean;
96
97
  startResultIndex: number;
@@ -226,6 +227,7 @@ declare class DataCalculations {
226
227
  get originalQuery(): string;
227
228
  get getAnswerData(): string;
228
229
  get searchTerm(): string;
230
+ get searchingEverything(): boolean;
229
231
  get searchExecuted(): boolean;
230
232
  get selectedFacets(): (IFacetValue | IFacetValueRange)[];
231
233
  get relatedSearches(): ISearchstaxRelatedSearchResult[];
@@ -1,4 +1,4 @@
1
- var qe=Object.defineProperty;var Oe=(F,y,M)=>y in F?qe(F,y,{enumerable:!0,configurable:!0,writable:!0,value:M}):F[y]=M;var n=(F,y,M)=>(Oe(F,typeof y!="symbol"?y+"":y,M),M);(function(F){"use strict";var y=(l=>(l[l.mustache=0]="mustache",l[l.vue=1]="vue",l[l.react=2]="react",l[l.angular=3]="angular",l))(y||{});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(){var e;return((e=this.dataLayer.searchResultsMetadata)==null?void 0:e.recordsPerPageValue)||0}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 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 searchTerm(){var e,t;return((e=this.dataLayer.searchResultsMetadata)==null?void 0:e.autoCorrectedQuery)||((t=this.dataLayer.searchObject)==null?void 0:t.query)||""}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)!==""&&this.dataLayer.getAnswerData===""}get selectedFacets(){var t;const e=this.dataLayer.searchFacetsCached??this.dataLayer.searchFacets;return e?(((t=this.dataLayer.searchObject)==null?void 0:t.facets)??[]).map(s=>{const i=s.name,c=s.value,o=e.find(h=>h.name===i);if(o){const h=o.values.find(u=>u.type==="range"?!1:u.type==="checkbox"?'"'+u.value+'"'===c:!1);if(h)return h}return null}).filter(s=>s!==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,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}}get trackingData(){var e,t,a,r;return{searchTerm:this.dataLayer.searchTerm!=="undefined"?this.dataLayer.searchTerm:"",trackApiKey:((e=this.dataLayer.searchstaxConfig)==null?void 0:e.trackApiKey)??"",session:this.dataLayer.sessionId,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:((r=this.dataLayer.searchResultsMetadata)==null?void 0:r.latency)??0}}}class P{static deepEqual(e,t){const a=Object.keys(e),r=Object.keys(t);if(a.length!==r.length)return!1;for(const s of a){const i=e[s],c=t[s],o=this.isObject(i)&&this.isObject(c);if(o&&!this.deepEqual(i,c)||!o&&i!==c)return!1}return!0}static isObject(e){return e!=null&&typeof e=="object"}}class S{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 W{static getOrSetCookie(e){let t=this.getCookie(e);return t==null&&(t=this.makeid(25),this.setCookie(e,t,{secure:!0,"max-age":3600})),t}static deleteCookie(e){this.getCookie(e)&&this.setCookie(e,"",{secure:!0,"max-age":-1})}static makeid(e){let t="";const a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",r=a.length;for(let s=0;s<e;s++)t+=a.charAt(Math.floor(Math.random()*r));return t}static getCookie(e){const t=document.cookie.match(new RegExp("(?:^|; )"+e.replace(/([.$?*|{}()[\]\\/+^])/g,"\\$1")+"=([^;]*)"));return t?decodeURIComponent(t[1]):void 0}static setCookie(e,t,a){const r={path:"/",...a};a.expires instanceof Date&&(r.expires=a.expires.toUTCString());let s=encodeURIComponent(e)+"="+encodeURIComponent(t);for(const i in r){s+="; "+i;const c=r[i];c!==!0&&(s+="="+c)}document.cookie=s}}class E{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 G{constructor(e){n(this,"$searchTermChange",new S(""));n(this,"$loadingChange",new S(!1));n(this,"$searchResults",new S(null));n(this,"$searchResultsMetadata",new S(null));n(this,"$searchAutosuggest",new S(null));n(this,"$searchFacets",new S(null));n(this,"$searchFacetsCached",new S(null));n(this,"$searchstaxConfig",new S(null));n(this,"$autosuggestResults",new S(null));n(this,"$searchObject",new S({query:"",page:99999999,order:"",facets:[],additionalProps:[]}));n(this,"$searchRelatedSearches",new S(null));n(this,"$searchInputConfig",new S(null));n(this,"$searchExternalPromotions",new S(null));n(this,"$facetsTemplateData",new S(null));n(this,"$selectedFacetsTemplateData",new S(null));n(this,"$paginationData",new S(null));n(this,"$searchFeedbackData",new S(null));n(this,"$searchSortingData",new S(null));n(this,"$searchRelatedSearchesData",new S(null));n(this,"$searchExternalPromotionsData",new S(null));n(this,"$cookiesDisabled",new S(null));n(this,"$answer",new S(""));n(this,"$language",new S("en"));n(this,"currentPageValue",1);n(this,"isAnswerWidgetCreatedValue",!1);n(this,"renderingEngineValue",y.mustache);n(this,"parsedData",new M(this));n(this,"sessionId");n(this,"autoCorrect",!0);n(this,"forceNotCorrect",!1);this.sessionId=e,this.cookieHandlingCallback(),this.$cookiesDisabled.subscribe(()=>{this.cookieHandlingCallback()})}cookieHandlingCallback(){this.cookiesDisabled?(W.deleteCookie(this.sessionId),W.deleteCookie("ms_visitorid")):W.getOrSetCookie(this.sessionId)}setSearchTerm(e){this.$searchTermChange.setValue(E.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){P.deepEqual(e,this.searchResults??[""])||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,r;let t=e;(r=(a=this.searchstaxConfig)==null?void 0:a.hooks)!=null&&r.beforeSearch&&t&&(t=this.searchstaxConfig.hooks.beforeSearch(t)),t&&(!P.deepEqual(t,this.searchObject??{})||this.forceNotCorrect)&&this.$searchObject.setValue(t)}setSearchFacets(e){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)}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.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}}class ${static combineResultsWithMetadata(e){const t=[],a=parseInt(e.response.start+"")-1,r=parseInt(e.responseHeader.params.rows);return e.response.docs.forEach((s,i)=>{const c={custom:null,uniqueId:this.getValueByKey(e.responseHeader.params.uniqueId,s,e)??"",position:a*r+1+i,ribbon:this.doesMapExist("ribbon",e)?this.getValueByKey("ribbon",s,e):null,paths:this.doesMapExist("paths",e)?this.getValueByKey("paths",s,e):null,url:this.doesMapExist("url",e)?this.getValueByKey("url",s,e):null,title:this.doesMapExist("title",e)?this.getValueByKey("title",s,e):null,promoted:s["[elevated]"]?s["[elevated]"]:!1,thumbnail:this.doesMapExist("thumbnail",e)?this.getValueByKey("thumbnail",s,e):null,date:this.doesMapExist("date",e)?this.getValueByKey("date",s,e):null,snippet:this.doesMapExist("snippet",e)?this.getValueByKey("snippet",s,e):null,description:this.doesMapExist("description",e)?this.getValueByKey("description",s,e):null,unmappedFields:this.getUnmappedFields(s,e),allFields:this.getAllFields(s,e)};t.push(c)}),t}static extractFacets(e){const t=[];for(const a of e.metadata.facets){let r={values:[]};if(r.name=a.name,r.label=a.label,a.name in e.facet_counts.facet_fields){const s=e.facet_counts.facet_fields[a.name];for(let i=0;i<s.length;i+=2){const c={};c.value=s[i],c.parentName=r.name,c.count=s[i+1],c.type="checkbox",r.values.push(c)}}r.values.length>0&&t.push(r)}return t}static extractSearchResultsMetadata(e){var a,r,s,i;let t="";return t=((i=(s=(r=(a=e==null?void 0:e.spellcheck)==null?void 0:a.suggestions)==null?void 0:r[0])==null?void 0:s.suggestion)==null?void 0:i[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)}}static getImpressions(e){const t=[],a=this.combineResultsWithMetadata(e);for(const r in a){const s=a[r],i={};i.cDocId=this.getDataForAnalytics(s.uniqueId),s.title&&(i.cDocTitle=this.getDataForAnalytics(s.title)),i.position=s.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){const a=t.metadata.results.filter(s=>s.result_card==="").map(s=>s.name),r=[];for(const s of Object.keys(e))if(a.indexOf(s)!==-1){const i=Array.isArray(e[s])?e[s].join(", "):e[s];r.push({key:s,value:i,isImage:this.checkIfImage(e[s])})}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(s=>s.name),r=[];for(const s of Object.keys(e))a.indexOf(s)!==-1&&r.push({key:s,value:e[s],isImage:this.checkIfImage(e[s])});return r}static doesMapExist(e,t){return t.metadata.results.find(a=>a.result_card===e)!==void 0}static getValueByKey(e,t,a){const r=a.metadata.results.find(i=>i.result_card===e);if(r===void 0)return null;const s=t[r.name];return s===void 0?null:typeof s=="string"?s:Array.isArray(s)?s.join(", "):null}}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 Y(this.routeName)}updateUrl(e){const t=this.searchObjectToUrl(e);let a=document.title;this.titleParser&&(a=this.titleParser(e)),document.title=a,window.location.href!==t&&window.history.pushState({},a,t)}searchObjectToUrl(e){return this.queryStringHelper.urlHasQueryParams(window.location.href)?window.location.href.split("?")[0]+"?"+this.queryStringHelper.stringify(this.searchObjectToParams(e),{ignoredKeys:this.ignoredKeys}):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)),t[this.routeName+"[page]"]=a+"",e.order&&(t[this.routeName+"[order]"]=e.order),e.facets)for(const r in e.facets){const s=e.facets[r].type+":"+encodeURIComponent(e.facets[r].name)+":"+encodeURIComponent(e.facets[r].value);t[this.routeName+`[facets][${r}]`]=s}if(this.queryStringHelper.urlHasQueryParams(window.location.href)){const r=this.queryStringHelper.urlToParams(window.location.href);for(const s in r)s.startsWith(this.routeName)&&delete r[s];return{...r,...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,r,s;const t=[];for(const i in e)if(i.startsWith(this.routeName+"[facets]")){const c=E.removeXSSRiskyTags((a=e[i].split(":"))==null?void 0:a[0]),o=E.removeXSSRiskyTags(decodeURIComponent((r=e[i].split(":"))==null?void 0:r[1])),h=E.removeXSSRiskyTags(decodeURIComponent((s=e[i].split(":"))==null?void 0:s[2]));t.push({type:c,name:o,value:h})}return t}urlToSearchObject(e){const t=this.queryStringHelper.urlToParams(e),a=E.removeXSSRiskyTags(decodeURIComponent(t[this.routeName+"[page]"])),r=parseInt(a),s=isNaN(r)?1:r;return{query:E.removeXSSRiskyTags(decodeURIComponent(t[this.routeName+"[query]"]))||"",page:s,order:E.removeXSSRiskyTags(t[this.routeName+"[order]"])||"",facets:this.extractArrayOfFacetsFromQueryParameters(t)||[]}}}class Y{constructor(e){n(this,"routeName","");n(this,"stringify",(e,t)=>{const a=this.filterOutIgnoredKeys(e,t.ignoredKeys);return Object.keys(a).map(r=>{const s=a[r];return Array.isArray(s)?s.map(i=>`${r}=${i}`).join("&"):`${r}=${s}`}).join("&")});this.routeName=e}filterOutIgnoredKeys(e,t){const a=t||[],r={};return Object.keys(e).forEach(s=>{a.includes(s)||e[s]!==""&&(r[s]=e[s])}),r}urlToParams(e){const t={},a=e.split("?")[1];return a&&a.split("&").forEach(r=>{const[s,i]=r.split("=");t[s]=i}),t}doesParamContainRouteName(e){return e.indexOf(this.routeName)!==-1}urlHasQueryParams(e){return e.indexOf("?")!==-1}}const A={questionURL:"http://smartsearch-dev.searchstax.co/completion/?q=",question:"I_AM_A_QUESTION",notQuestion:"I_AM_NOT_A_QUESTION",close:"CLOSE"};class Z{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(r){const s=r.name+':"'+r.value+'"';a=a.concat("fq="+decodeURIComponent(s).replace(" "," "))});else{const r={};e.forEach(function(s){const i=s.name+":"+s.value,c=decodeURIComponent(i).replace(" "," ").split(":");r[c[0]]?r[c[0]].push(c[1]):r[c[0]]=[c[1]]});for(const s in r)if(Object.prototype.hasOwnProperty.call(r,s)){const i=r[s],c=s;let o="";for(const h of i)o+=` ${c}:"${h}"`;a=a.concat("fq="+o.trim())}}return a.length?"&"+a.join("&"):""}getRelatedSearches(e,t,a,r){const s=new Headers;s.append("Accept","application/json"),s.append("Authorization",a),fetch(t+"?search="+encodeURIComponent(e.query)+"&language="+this.dataLayer.language,{method:"GET",headers:s,credentials:"same-origin"}).then(i=>i.json()).then(i=>{r(i)})}cacheFacets(){this.dataLayer.searchObject.query!==this.cachedQuery&&(this.cachedQuery=this.dataLayer.searchObject.query,this.search({query:this.dataLayer.searchObject.query??"*",page:1,order:"",facets:[],additionalProps:this.dataLayer.searchObject.additionalProps},this.cacheFacetsCallback.bind(this)))}cacheFacetsCallback(e){let t=$.extractFacets(e);this.dataLayer.setSearchFacetsCached(t)}search(e,t,a=!1,r=!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 s=new Proxy(new URLSearchParams(window.location.search),{get:(u,g)=>u.get(g)??""}),i=s.languageVariant?"&fq=_language:"+s.languageVariant:"",c=e.order?`&sort=${e.order}`:"",o=this.url+"?q="+encodeURIComponent(e.query.trim())+"&start="+(e.page-1)+this.toQueryString(e.additionalProps??[])+this.generateFacetQuery(e.facets.filter(u=>u.type==="or"||u.type==="showUnavailable"),!0)+this.generateFacetQuery(e.facets.filter(u=>u.type==="and"||u.type==="tabs"),!1)+c+`&spellcheck.correct=${this.dataLayer.autoCorrect&&!r}&language=`+this.dataLayer.language+i,h={method:"GET",headers:this.authHeader,credentials:"same-origin",signal:this.signalSearch};a&&delete h.signal,fetch(o,h).then(u=>u.json()).then(u=>{this.dataLayer.setLoading(!1),t(u)}).catch(()=>{this.dataLayer.setLoading(!1)})}}startSSE(e,t){const a=new EventSource(A.questionURL+e),r=this.dataLayer;a.onmessage=function(s){if(s.data===A.question||s.data===A.notQuestion){r.setAnswerData("");return}if(s.data===A.close){a.close();return}t(s.data)},a.onerror=function(s){console.log(s),a.close()}}suggest(e,t,a){this.controllerSuggest&&this.controllerSuggest.abort(),this.controllerSuggest=new AbortController,this.signalSuggest=this.controllerSuggest.signal;const r=this.suggester+"?q="+e.trim()+this.toQueryString(a)+"&language="+this.dataLayer.language;fetch(r,{method:"GET",headers:this.authHeader,credentials:"same-origin",signal:this.signalSuggest}).then(s=>s.json()).then(s=>{t(s)}).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 H{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.title,position:e.result.position,language:e.language};setTimeout(()=>{t.key&&this.msq.push(["trackClick",t])},0)}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(["trackSearch",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(H,"msq",window._msq||[]);/*!
1
+ var qe=Object.defineProperty;var Oe=(F,y,M)=>y in F?qe(F,y,{enumerable:!0,configurable:!0,writable:!0,value:M}):F[y]=M;var n=(F,y,M)=>(Oe(F,typeof y!="symbol"?y+"":y,M),M);(function(F){"use strict";var y=(l=>(l[l.mustache=0]="mustache",l[l.vue=1]="vue",l[l.react=2]="react",l[l.angular=3]="angular",l))(y||{});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(){var e;return((e=this.dataLayer.searchResultsMetadata)==null?void 0:e.recordsPerPageValue)||0}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 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 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 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(s=>{const i=s.name,c=s.value,o=e.find(h=>h.name===i);if(o){const h=o.values.find(u=>u.type==="range"?!1:u.type==="checkbox"?'"'+u.value+'"'===c:!1);if(h)return h}return null}).filter(s=>s!==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}}get trackingData(){var e,t,a,r;return{searchTerm:this.dataLayer.searchTerm!=="undefined"?this.dataLayer.searchTerm:"",trackApiKey:((e=this.dataLayer.searchstaxConfig)==null?void 0:e.trackApiKey)??"",session:this.dataLayer.sessionId,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:((r=this.dataLayer.searchResultsMetadata)==null?void 0:r.latency)??0}}}class P{static deepEqual(e,t){const a=Object.keys(e),r=Object.keys(t);if(a.length!==r.length)return!1;for(const s of a){const i=e[s],c=t[s],o=this.isObject(i)&&this.isObject(c);if(o&&!this.deepEqual(i,c)||!o&&i!==c)return!1}return!0}static isObject(e){return e!=null&&typeof e=="object"}}class S{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 W{static getOrSetCookie(e){let t=this.getCookie(e);return t==null&&(t=this.makeid(25),this.setCookie(e,t,{secure:!0,"max-age":3600})),t}static deleteCookie(e){this.getCookie(e)&&this.setCookie(e,"",{secure:!0,"max-age":-1})}static makeid(e){let t="";const a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",r=a.length;for(let s=0;s<e;s++)t+=a.charAt(Math.floor(Math.random()*r));return t}static getCookie(e){const t=document.cookie.match(new RegExp("(?:^|; )"+e.replace(/([.$?*|{}()[\]\\/+^])/g,"\\$1")+"=([^;]*)"));return t?decodeURIComponent(t[1]):void 0}static setCookie(e,t,a){const r={path:"/",...a};a.expires instanceof Date&&(r.expires=a.expires.toUTCString());let s=encodeURIComponent(e)+"="+encodeURIComponent(t);for(const i in r){s+="; "+i;const c=r[i];c!==!0&&(s+="="+c)}document.cookie=s}}class E{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 G{constructor(e){n(this,"$searchTermChange",new S(""));n(this,"$loadingChange",new S(!1));n(this,"$searchResults",new S(null));n(this,"$searchResultsMetadata",new S(null));n(this,"$searchAutosuggest",new S(null));n(this,"$searchFacets",new S(null));n(this,"$searchFacetsCached",new S(null));n(this,"$searchstaxConfig",new S(null));n(this,"$autosuggestResults",new S(null));n(this,"$searchObject",new S({query:"",page:99999999,order:"",facets:[],additionalProps:[]}));n(this,"$searchRelatedSearches",new S(null));n(this,"$searchInputConfig",new S(null));n(this,"$searchExternalPromotions",new S(null));n(this,"$facetsTemplateData",new S(null));n(this,"$selectedFacetsTemplateData",new S(null));n(this,"$paginationData",new S(null));n(this,"$searchFeedbackData",new S(null));n(this,"$searchSortingData",new S(null));n(this,"$searchRelatedSearchesData",new S(null));n(this,"$searchExternalPromotionsData",new S(null));n(this,"$cookiesDisabled",new S(null));n(this,"$answer",new S(""));n(this,"$language",new S("en"));n(this,"currentPageValue",1);n(this,"isAnswerWidgetCreatedValue",!1);n(this,"renderingEngineValue",y.mustache);n(this,"parsedData",new M(this));n(this,"sessionId");n(this,"autoCorrect",!0);n(this,"forceNotCorrect",!1);this.sessionId=e,this.cookieHandlingCallback(),this.$cookiesDisabled.subscribe(()=>{this.cookieHandlingCallback()})}cookieHandlingCallback(){this.cookiesDisabled?(W.deleteCookie(this.sessionId),W.deleteCookie("ms_visitorid")):W.getOrSetCookie(this.sessionId)}setSearchTerm(e){this.$searchTermChange.setValue(E.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){P.deepEqual(e,this.searchResults??[""])||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,r;let t=e;(r=(a=this.searchstaxConfig)==null?void 0:a.hooks)!=null&&r.beforeSearch&&t&&(t=this.searchstaxConfig.hooks.beforeSearch(t)),t&&(!P.deepEqual(t,this.searchObject??{})||this.forceNotCorrect)&&this.$searchObject.setValue(t)}setSearchFacets(e){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)}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.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}}class ${static combineResultsWithMetadata(e){const t=[],a=parseInt(e.response.start+"")-1,r=parseInt(e.responseHeader.params.rows);return e.response.docs.forEach((s,i)=>{const c={custom:null,uniqueId:this.getValueByKey(e.responseHeader.params.uniqueId,s,e)??"",position:a*r+1+i,ribbon:this.doesMapExist("ribbon",e)?this.getValueByKey("ribbon",s,e):null,paths:this.doesMapExist("paths",e)?this.getValueByKey("paths",s,e):null,url:this.doesMapExist("url",e)?this.getValueByKey("url",s,e):null,title:this.doesMapExist("title",e)?this.getValueByKey("title",s,e):null,promoted:s["[elevated]"]?s["[elevated]"]:!1,thumbnail:this.doesMapExist("thumbnail",e)?this.getValueByKey("thumbnail",s,e):null,date:this.doesMapExist("date",e)?this.getValueByKey("date",s,e):null,snippet:this.doesMapExist("snippet",e)?this.getValueByKey("snippet",s,e):null,description:this.doesMapExist("description",e)?this.getValueByKey("description",s,e):null,unmappedFields:this.getUnmappedFields(s,e),allFields:this.getAllFields(s,e)};t.push(c)}),t}static extractFacets(e){const t=[];for(const a of e.metadata.facets){let r={values:[]};if(r.name=a.name,r.label=a.label,a.name in e.facet_counts.facet_fields){const s=e.facet_counts.facet_fields[a.name];for(let i=0;i<s.length;i+=2){const c={};c.value=s[i],c.parentName=r.name,c.count=s[i+1],c.type="checkbox",r.values.push(c)}}r.values.length>0&&t.push(r)}return t}static extractSearchResultsMetadata(e){var a,r,s,i;let t="";return t=((i=(s=(r=(a=e==null?void 0:e.spellcheck)==null?void 0:a.suggestions)==null?void 0:r[0])==null?void 0:s.suggestion)==null?void 0:i[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)}}static getImpressions(e){const t=[],a=this.combineResultsWithMetadata(e);for(const r in a){const s=a[r],i={};i.cDocId=this.getDataForAnalytics(s.uniqueId),s.title&&(i.cDocTitle=this.getDataForAnalytics(s.title)),i.position=s.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){const a=t.metadata.results.filter(s=>s.result_card==="").map(s=>s.name),r=[];for(const s of Object.keys(e))if(a.indexOf(s)!==-1){const i=Array.isArray(e[s])?e[s].join(", "):e[s];r.push({key:s,value:i,isImage:this.checkIfImage(e[s])})}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(s=>s.name),r=[];for(const s of Object.keys(e))a.indexOf(s)!==-1&&r.push({key:s,value:e[s],isImage:this.checkIfImage(e[s])});return r}static doesMapExist(e,t){return t.metadata.results.find(a=>a.result_card===e)!==void 0}static getValueByKey(e,t,a){const r=a.metadata.results.find(i=>i.result_card===e);if(r===void 0)return null;const s=t[r.name];return s===void 0?null:typeof s=="string"?s:Array.isArray(s)?s.join(", "):null}}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 Y(this.routeName)}updateUrl(e){const t=this.searchObjectToUrl(e);let a=document.title;this.titleParser&&(a=this.titleParser(e)),document.title=a,window.location.href!==t&&window.history.pushState({},a,t)}searchObjectToUrl(e){return this.queryStringHelper.urlHasQueryParams(window.location.href)?window.location.href.split("?")[0]+"?"+this.queryStringHelper.stringify(this.searchObjectToParams(e),{ignoredKeys:this.ignoredKeys}):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)),t[this.routeName+"[page]"]=a+"",e.order&&(t[this.routeName+"[order]"]=e.order),e.facets)for(const r in e.facets){const s=e.facets[r].type+":"+encodeURIComponent(e.facets[r].name)+":"+encodeURIComponent(e.facets[r].value);t[this.routeName+`[facets][${r}]`]=s}if(this.queryStringHelper.urlHasQueryParams(window.location.href)){const r=this.queryStringHelper.urlToParams(window.location.href);for(const s in r)s.startsWith(this.routeName)&&delete r[s];return{...r,...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,r,s;const t=[];for(const i in e)if(i.startsWith(this.routeName+"[facets]")){const c=E.removeXSSRiskyTags((a=e[i].split(":"))==null?void 0:a[0]),o=E.removeXSSRiskyTags(decodeURIComponent((r=e[i].split(":"))==null?void 0:r[1])),h=E.removeXSSRiskyTags(decodeURIComponent((s=e[i].split(":"))==null?void 0:s[2]));t.push({type:c,name:o,value:h})}return t}urlToSearchObject(e){const t=this.queryStringHelper.urlToParams(e),a=E.removeXSSRiskyTags(decodeURIComponent(t[this.routeName+"[page]"])),r=parseInt(a),s=isNaN(r)?1:r;return{query:E.removeXSSRiskyTags(decodeURIComponent(t[this.routeName+"[query]"]))||"",page:s,order:E.removeXSSRiskyTags(t[this.routeName+"[order]"])||"",facets:this.extractArrayOfFacetsFromQueryParameters(t)||[]}}}class Y{constructor(e){n(this,"routeName","");n(this,"stringify",(e,t)=>{const a=this.filterOutIgnoredKeys(e,t.ignoredKeys);return Object.keys(a).map(r=>{const s=a[r];return Array.isArray(s)?s.map(i=>`${r}=${i}`).join("&"):`${r}=${s}`}).join("&")});this.routeName=e}filterOutIgnoredKeys(e,t){const a=t||[],r={};return Object.keys(e).forEach(s=>{a.includes(s)||e[s]!==""&&(r[s]=e[s])}),r}urlToParams(e){const t={},a=e.split("?")[1];return a&&a.split("&").forEach(r=>{const[s,i]=r.split("=");t[s]=i}),t}doesParamContainRouteName(e){return e.indexOf(this.routeName)!==-1}urlHasQueryParams(e){return e.indexOf("?")!==-1}}const A={questionURL:"http://smartsearch-dev.searchstax.co/completion/?q=",question:"I_AM_A_QUESTION",notQuestion:"I_AM_NOT_A_QUESTION",close:"CLOSE"};class Z{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(r){const s=r.name+':"'+r.value+'"';a=a.concat("fq="+decodeURIComponent(s).replace(" "," "))});else{const r={};e.forEach(function(s){const i=s.name+":"+s.value,c=decodeURIComponent(i).replace(" "," ").split(":");r[c[0]]?r[c[0]].push(c[1]):r[c[0]]=[c[1]]});for(const s in r)if(Object.prototype.hasOwnProperty.call(r,s)){const i=r[s],c=s;let o="";for(const h of i)o+=` ${c}:"${h}"`;a=a.concat("fq="+o.trim())}}return a.length?"&"+a.join("&"):""}getRelatedSearches(e,t,a,r){const s=new Headers;s.append("Accept","application/json"),s.append("Authorization",a),fetch(t+"?search="+encodeURIComponent(e.query)+"&language="+this.dataLayer.language,{method:"GET",headers:s,credentials:"same-origin"}).then(i=>i.json()).then(i=>{r(i)})}cacheFacets(){this.dataLayer.searchObject.query!==this.cachedQuery&&(this.cachedQuery=this.dataLayer.searchObject.query,this.search({query:this.dataLayer.searchObject.query??"*",page:1,order:"",facets:[],additionalProps:this.dataLayer.searchObject.additionalProps},this.cacheFacetsCallback.bind(this)))}cacheFacetsCallback(e){let t=$.extractFacets(e);this.dataLayer.setSearchFacetsCached(t)}search(e,t,a=!1,r=!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 s=new Proxy(new URLSearchParams(window.location.search),{get:(u,g)=>u.get(g)??""}),i=s.languageVariant?"&fq=_language:"+s.languageVariant:"",c=e.order?`&sort=${e.order}`:"",o=this.url+"?q="+encodeURIComponent(e.query.trim())+"&start="+(e.page-1)+this.toQueryString(e.additionalProps??[])+this.generateFacetQuery(e.facets.filter(u=>u.type==="or"||u.type==="showUnavailable"),!0)+this.generateFacetQuery(e.facets.filter(u=>u.type==="and"||u.type==="tabs"),!1)+c+`&spellcheck.correct=${this.dataLayer.autoCorrect&&!r}&language=`+this.dataLayer.language+i,h={method:"GET",headers:this.authHeader,credentials:"same-origin",signal:this.signalSearch};a&&delete h.signal,fetch(o,h).then(u=>u.json()).then(u=>{this.dataLayer.setLoading(!1),t(u)}).catch(()=>{this.dataLayer.setLoading(!1)})}}startSSE(e,t){const a=new EventSource(A.questionURL+e),r=this.dataLayer;a.onmessage=function(s){if(s.data===A.question||s.data===A.notQuestion){r.setAnswerData("");return}if(s.data===A.close){a.close();return}t(s.data)},a.onerror=function(s){console.log(s),a.close()}}suggest(e,t,a){this.controllerSuggest&&this.controllerSuggest.abort(),this.controllerSuggest=new AbortController,this.signalSuggest=this.controllerSuggest.signal;const r=this.suggester+"?q="+e.trim()+this.toQueryString(a)+"&language="+this.dataLayer.language;fetch(r,{method:"GET",headers:this.authHeader,credentials:"same-origin",signal:this.signalSuggest}).then(s=>s.json()).then(s=>{t(s)}).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 H{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.title,position:e.result.position,language:e.language};setTimeout(()=>{t.key&&this.msq.push(["trackClick",t])},0)}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(["trackSearch",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(H,"msq",window._msq||[]);/*!
2
2
  * mustache.js - Logic-less {{mustache}} templates with JavaScript
3
3
  * http://github.com/janl/mustache.js
4
4
  */var ee=Object.prototype.toString,q=Array.isArray||function(e){return ee.call(e)==="[object Array]"};function Q(l){return typeof l=="function"}function te(l){return q(l)?"array":typeof l}function K(l){return l.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g,"\\$&")}function J(l,e){return l!=null&&typeof l=="object"&&e in l}function ae(l,e){return l!=null&&typeof l!="object"&&l.hasOwnProperty&&l.hasOwnProperty(e)}var se=RegExp.prototype.test;function re(l,e){return se.call(l,e)}var ie=/\S/;function ne(l){return!re(ie,l)}var ce={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;","/":"&#x2F;","`":"&#x60;","=":"&#x3D;"};function oe(l){return String(l).replace(/[&<>"'`=\/]/g,function(t){return ce[t]})}var le=/\s*/,he=/\s+/,X=/\s*=/,ue=/\s*\}/,de=/#|\^|\/|>|\{|&|=|!/;function ge(l,e){if(!l)return[];var t=!1,a=[],r=[],s=[],i=!1,c=!1,o="",h=0;function u(){if(i&&!c)for(;s.length;)delete r[s.pop()];else s=[];i=!1,c=!1}var g,p,C;function T(w){if(typeof w=="string"&&(w=w.split(he,2)),!q(w)||w.length!==2)throw new Error("Invalid tags: "+w);g=new RegExp(K(w[0])+"\\s*"),p=new RegExp("\\s*"+K(w[1])),C=new RegExp("\\s*"+K("}"+w[1]))}T(e||f.tags);for(var m=new V(l),v,L,b,R,I,x;!m.eos();){if(v=m.pos,b=m.scanUntil(g),b)for(var D=0,U=b.length;D<U;++D)R=b.charAt(D),ne(R)?(s.push(r.length),o+=R):(c=!0,t=!0,o+=" "),r.push(["text",R,v,v+1]),v+=1,R===`
@@ -54,9 +54,12 @@ class G {
54
54
  var e, t;
55
55
  return ((e = this.dataLayer.searchResultsMetadata) == null ? void 0 : e.autoCorrectedQuery) || ((t = this.dataLayer.searchObject) == null ? void 0 : t.query) || "";
56
56
  }
57
+ get searchingEverything() {
58
+ return this.searchTerm === "*";
59
+ }
57
60
  get searchExecuted() {
58
61
  var e, t, a;
59
- 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) !== "" && this.dataLayer.getAnswerData === "";
62
+ 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) !== "";
60
63
  }
61
64
  get selectedFacets() {
62
65
  var t;
@@ -93,6 +96,7 @@ class G {
93
96
  originalQuery: this.originalQuery,
94
97
  selectedFacets: this.selectedFacets,
95
98
  searchExecuted: this.searchExecuted,
99
+ searchingEverything: this.searchingEverything,
96
100
  relatedSearches: this.relatedSearches,
97
101
  hasRelatedSearches: this.relatedSearches.length > 0,
98
102
  externalPromotions: this.externalPromotions,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@searchstax-inc/searchstudio-ux-js",
3
3
  "private": false,
4
- "version": "0.5.10",
4
+ "version": "0.5.11",
5
5
  "files": [
6
6
  "dist"
7
7
  ],