@searchstax-inc/searchstudio-ux-js 0.5.8 → 0.5.9

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.
package/dist/.DS_Store ADDED
Binary file
@@ -1,4 +1,4 @@
1
- "use strict";var z=Object.defineProperty;var J=(o,e,t)=>e in o?z(o,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):o[e]=t;var n=(o,e,t)=>(J(o,typeof e!="symbol"?e+"":e,t),t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});var x=(o=>(o[o.mustache=0]="mustache",o[o.vue=1]="vue",o[o.react=2]="react",o[o.angular=3]="angular",o))(x||{});class X{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 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)!==""}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,l=e.find(h=>h.name===i);if(l){const h=l.values.find(u=>u.type==="range"?!1:u.type==="checkbox"?'"'+u.value+'"'===c:!1);if(h)return h}return null}).filter(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}}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 F{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],l=this.isObject(i)&&this.isObject(c);if(l&&!this.deepEqual(i,c)||!l&&i!==c)return!1}return!0}static isObject(e){return e!=null&&typeof e=="object"}}class 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 N{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 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,"$language",new v("en"));n(this,"currentPageValue",1);n(this,"renderingEngineValue",x.mustache);n(this,"parsedData",new X(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?(N.deleteCookie(this.sessionId),N.deleteCookie("ms_visitorid")):N.getOrSetCookie(this.sessionId)}setSearchTerm(e){this.$searchTermChange.setValue(E.removeXSSRiskyTags(e))}setRenderingEngine(e){this.renderingEngineValue=e}setCurrentPage(e){this.currentPageValue=e}setLoading(e){this.$loadingChange.setValue(e)}setSearchResults(e){F.deepEqual(e,this.searchResults??[""])||this.$searchResults.setValue(e)}setSearchResultsMetadata(e){F.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&&(!F.deepEqual(t,this.searchObject??{})||this.forceNotCorrect)&&this.$searchObject.setValue(t)}setSearchFacets(e){F.deepEqual(e,this.searchFacets??[])||this.$searchFacets.setValue(e)}setSearchFacetsCached(e){F.deepEqual(e,this.searchFacetsCached??[])||this.$searchFacetsCached.setValue(e)}setSearchRelatedSearches(e){F.deepEqual(e,this.searchRelatedSearches??[])||this.$searchRelatedSearches.setValue(e)}setSearchExternalPromotions(e){F.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)}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 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 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 O{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 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]),l=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:l,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}}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 l="";for(const h of i)l+=` ${c}:"${h}"`;a=a.concat("fq="+l.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=O.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}`:"",l=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(l,h).then(u=>u.json()).then(u=>{this.dataLayer.setLoading(!1),t(u)}).catch(()=>{this.dataLayer.setLoading(!1)})}}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(()=>{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(()=>{this.msq.push(["track",t])},0)}static trackRelatedSearchClick(e){const t={session:e.session,key:e.trackApiKey,query:e.relatedSearch.search_term,position:e.relatedSearch.position,relatedSearch:e.relatedSearch.related_search,pageNo:e.currentPage,shownHits:e.recordsPerPage,totalHits:e.totalResults,language:e.language};setTimeout(()=>{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(()=>{this.msq.push(["trackRelatedSearch",t])},0)}}n(H,"msq",window._msq||[]);/*!
1
+ "use strict";var z=Object.defineProperty;var J=(o,e,t)=>e in o?z(o,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):o[e]=t;var n=(o,e,t)=>(J(o,typeof e!="symbol"?e+"":e,t),t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});var x=(o=>(o[o.mustache=0]="mustache",o[o.vue=1]="vue",o[o.react=2]="react",o[o.angular=3]="angular",o))(x||{});class X{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 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)!==""}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,l=e.find(h=>h.name===i);if(l){const h=l.values.find(u=>u.type==="range"?!1:u.type==="checkbox"?'"'+u.value+'"'===c:!1);if(h)return h}return null}).filter(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}}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 F{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],l=this.isObject(i)&&this.isObject(c);if(l&&!this.deepEqual(i,c)||!l&&i!==c)return!1}return!0}static isObject(e){return e!=null&&typeof e=="object"}}class 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 N{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 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,"$language",new v("en"));n(this,"currentPageValue",1);n(this,"renderingEngineValue",x.mustache);n(this,"parsedData",new X(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?(N.deleteCookie(this.sessionId),N.deleteCookie("ms_visitorid")):N.getOrSetCookie(this.sessionId)}setSearchTerm(e){this.$searchTermChange.setValue(E.removeXSSRiskyTags(e))}setRenderingEngine(e){this.renderingEngineValue=e}setCurrentPage(e){this.currentPageValue=e}setLoading(e){this.$loadingChange.setValue(e)}setSearchResults(e){F.deepEqual(e,this.searchResults??[""])||this.$searchResults.setValue(e)}setSearchResultsMetadata(e){F.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&&(!F.deepEqual(t,this.searchObject??{})||this.forceNotCorrect)&&this.$searchObject.setValue(t)}setSearchFacets(e){F.deepEqual(e,this.searchFacets??[])||this.$searchFacets.setValue(e)}setSearchFacetsCached(e){F.deepEqual(e,this.searchFacetsCached??[])||this.$searchFacetsCached.setValue(e)}setSearchRelatedSearches(e){F.deepEqual(e,this.searchRelatedSearches??[])||this.$searchRelatedSearches.setValue(e)}setSearchExternalPromotions(e){F.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)}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 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 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 O{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 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]),l=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:l,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}}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 l="";for(const h of i)l+=` ${c}:"${h}"`;a=a.concat("fq="+l.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=O.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}`:"",l=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(l,h).then(u=>u.json()).then(u=>{this.dataLayer.setLoading(!1),t(u)}).catch(()=>{this.dataLayer.setLoading(!1)})}}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,D=Array.isArray||function(e){return ee.call(e)==="[object Array]"};function W(o){return typeof o=="function"}function te(o){return D(o)?"array":typeof o}function U(o){return o.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g,"\\$&")}function Q(o,e){return o!=null&&typeof o=="object"&&e in o}function ae(o,e){return o!=null&&typeof o!="object"&&o.hasOwnProperty&&o.hasOwnProperty(e)}var se=RegExp.prototype.test;function re(o,e){return se.call(o,e)}var ie=/\S/;function ne(o){return!re(ie,o)}var ce={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;","/":"&#x2F;","`":"&#x60;","=":"&#x3D;"};function le(o){return String(o).replace(/[&<>"'`=\/]/g,function(t){return ce[t]})}var oe=/\s*/,he=/\s+/,_=/\s*=/,ue=/\s*\}/,de=/#|\^|\/|>|\{|&|=|!/;function ge(o,e){if(!o)return[];var t=!1,a=[],r=[],s=[],i=!1,c=!1,l="",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 L(P){if(typeof P=="string"&&(P=P.split(he,2)),!D(P)||P.length!==2)throw new Error("Invalid tags: "+P);g=new RegExp(U(P[0])+"\\s*"),p=new RegExp("\\s*"+U(P[1])),y=new RegExp("\\s*"+U("}"+P[1]))}L(e||m.tags);for(var f=new V(o),C,S,b,R,I,T;!f.eos();){if(C=f.pos,b=f.scanUntil(g),b)for(var w=0,j=b.length;w<j;++w)R=b.charAt(w),ne(R)?(s.push(r.length),l+=R):(c=!0,t=!0,l+=" "),r.push(["text",R,C,C+1]),C+=1,R===`
@@ -1,4 +1,4 @@
1
- var Me=Object.defineProperty;var De=(w,C,M)=>C in w?Me(w,C,{enumerable:!0,configurable:!0,writable:!0,value:M}):w[C]=M;var n=(w,C,M)=>(De(w,typeof C!="symbol"?C+"":C,M),M);(function(w){"use strict";var C=(o=>(o[o.mustache=0]="mustache",o[o.vue=1]="vue",o[o.react=2]="react",o[o.angular=3]="angular",o))(C||{});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 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)!==""}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,l=e.find(h=>h.name===i);if(l){const h=l.values.find(u=>u.type==="range"?!1:u.type==="checkbox"?'"'+u.value+'"'===c:!1);if(h)return h}return null}).filter(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}}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 F{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],l=this.isObject(i)&&this.isObject(c);if(l&&!this.deepEqual(i,c)||!l&&i!==c)return!1}return!0}static isObject(e){return e!=null&&typeof e=="object"}}class b{constructor(e){n(this,"value");n(this,"observers",[]);this.value=e,this.observers=[]}subscribe(e){this.observers.push(e),e(this.value)}unsubscribe(e){const t=this.observers.indexOf(e);t!==-1&&this.observers.splice(t,1)}setValue(e){this.value=e,this.notify()}getValue(){return this.value}notify(){this.observers.forEach(e=>e(this.value))}}class U{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 X{constructor(e){n(this,"$searchTermChange",new b(""));n(this,"$loadingChange",new b(!1));n(this,"$searchResults",new b(null));n(this,"$searchResultsMetadata",new b(null));n(this,"$searchAutosuggest",new b(null));n(this,"$searchFacets",new b(null));n(this,"$searchFacetsCached",new b(null));n(this,"$searchstaxConfig",new b(null));n(this,"$autosuggestResults",new b(null));n(this,"$searchObject",new b({query:"",page:99999999,order:"",facets:[],additionalProps:[]}));n(this,"$searchRelatedSearches",new b(null));n(this,"$searchInputConfig",new b(null));n(this,"$searchExternalPromotions",new b(null));n(this,"$facetsTemplateData",new b(null));n(this,"$selectedFacetsTemplateData",new b(null));n(this,"$paginationData",new b(null));n(this,"$searchFeedbackData",new b(null));n(this,"$searchSortingData",new b(null));n(this,"$searchRelatedSearchesData",new b(null));n(this,"$searchExternalPromotionsData",new b(null));n(this,"$cookiesDisabled",new b(null));n(this,"$language",new b("en"));n(this,"currentPageValue",1);n(this,"renderingEngineValue",C.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?(U.deleteCookie(this.sessionId),U.deleteCookie("ms_visitorid")):U.getOrSetCookie(this.sessionId)}setSearchTerm(e){this.$searchTermChange.setValue(E.removeXSSRiskyTags(e))}setRenderingEngine(e){this.renderingEngineValue=e}setCurrentPage(e){this.currentPageValue=e}setLoading(e){this.$loadingChange.setValue(e)}setSearchResults(e){F.deepEqual(e,this.searchResults??[""])||this.$searchResults.setValue(e)}setSearchResultsMetadata(e){F.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&&(!F.deepEqual(t,this.searchObject??{})||this.forceNotCorrect)&&this.$searchObject.setValue(t)}setSearchFacets(e){F.deepEqual(e,this.searchFacets??[])||this.$searchFacets.setValue(e)}setSearchFacetsCached(e){F.deepEqual(e,this.searchFacetsCached??[])||this.$searchFacetsCached.setValue(e)}setSearchRelatedSearches(e){F.deepEqual(e,this.searchRelatedSearches??[])||this.$searchRelatedSearches.setValue(e)}setSearchExternalPromotions(e){F.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)}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 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 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 O{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 _{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 G(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]),l=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:l,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 G{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}}class Y{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 l="";for(const h of i)l+=` ${c}:"${h}"`;a=a.concat("fq="+l.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=O.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}`:"",l=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(l,h).then(u=>u.json()).then(u=>{this.dataLayer.setLoading(!1),t(u)}).catch(()=>{this.dataLayer.setLoading(!1)})}}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(()=>{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(()=>{this.msq.push(["track",t])},0)}static trackRelatedSearchClick(e){const t={session:e.session,key:e.trackApiKey,query:e.relatedSearch.search_term,position:e.relatedSearch.position,relatedSearch:e.relatedSearch.related_search,pageNo:e.currentPage,shownHits:e.recordsPerPage,totalHits:e.totalResults,language:e.language};setTimeout(()=>{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(()=>{this.msq.push(["trackRelatedSearch",t])},0)}}n(H,"msq",window._msq||[]);/*!
1
+ var Me=Object.defineProperty;var De=(w,C,M)=>C in w?Me(w,C,{enumerable:!0,configurable:!0,writable:!0,value:M}):w[C]=M;var n=(w,C,M)=>(De(w,typeof C!="symbol"?C+"":C,M),M);(function(w){"use strict";var C=(o=>(o[o.mustache=0]="mustache",o[o.vue=1]="vue",o[o.react=2]="react",o[o.angular=3]="angular",o))(C||{});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 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)!==""}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,l=e.find(h=>h.name===i);if(l){const h=l.values.find(u=>u.type==="range"?!1:u.type==="checkbox"?'"'+u.value+'"'===c:!1);if(h)return h}return null}).filter(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}}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 F{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],l=this.isObject(i)&&this.isObject(c);if(l&&!this.deepEqual(i,c)||!l&&i!==c)return!1}return!0}static isObject(e){return e!=null&&typeof e=="object"}}class b{constructor(e){n(this,"value");n(this,"observers",[]);this.value=e,this.observers=[]}subscribe(e){this.observers.push(e),e(this.value)}unsubscribe(e){const t=this.observers.indexOf(e);t!==-1&&this.observers.splice(t,1)}setValue(e){this.value=e,this.notify()}getValue(){return this.value}notify(){this.observers.forEach(e=>e(this.value))}}class U{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 X{constructor(e){n(this,"$searchTermChange",new b(""));n(this,"$loadingChange",new b(!1));n(this,"$searchResults",new b(null));n(this,"$searchResultsMetadata",new b(null));n(this,"$searchAutosuggest",new b(null));n(this,"$searchFacets",new b(null));n(this,"$searchFacetsCached",new b(null));n(this,"$searchstaxConfig",new b(null));n(this,"$autosuggestResults",new b(null));n(this,"$searchObject",new b({query:"",page:99999999,order:"",facets:[],additionalProps:[]}));n(this,"$searchRelatedSearches",new b(null));n(this,"$searchInputConfig",new b(null));n(this,"$searchExternalPromotions",new b(null));n(this,"$facetsTemplateData",new b(null));n(this,"$selectedFacetsTemplateData",new b(null));n(this,"$paginationData",new b(null));n(this,"$searchFeedbackData",new b(null));n(this,"$searchSortingData",new b(null));n(this,"$searchRelatedSearchesData",new b(null));n(this,"$searchExternalPromotionsData",new b(null));n(this,"$cookiesDisabled",new b(null));n(this,"$language",new b("en"));n(this,"currentPageValue",1);n(this,"renderingEngineValue",C.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?(U.deleteCookie(this.sessionId),U.deleteCookie("ms_visitorid")):U.getOrSetCookie(this.sessionId)}setSearchTerm(e){this.$searchTermChange.setValue(E.removeXSSRiskyTags(e))}setRenderingEngine(e){this.renderingEngineValue=e}setCurrentPage(e){this.currentPageValue=e}setLoading(e){this.$loadingChange.setValue(e)}setSearchResults(e){F.deepEqual(e,this.searchResults??[""])||this.$searchResults.setValue(e)}setSearchResultsMetadata(e){F.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&&(!F.deepEqual(t,this.searchObject??{})||this.forceNotCorrect)&&this.$searchObject.setValue(t)}setSearchFacets(e){F.deepEqual(e,this.searchFacets??[])||this.$searchFacets.setValue(e)}setSearchFacetsCached(e){F.deepEqual(e,this.searchFacetsCached??[])||this.$searchFacetsCached.setValue(e)}setSearchRelatedSearches(e){F.deepEqual(e,this.searchRelatedSearches??[])||this.$searchRelatedSearches.setValue(e)}setSearchExternalPromotions(e){F.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)}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 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 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 O{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 _{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 G(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]),l=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:l,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 G{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}}class Y{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 l="";for(const h of i)l+=` ${c}:"${h}"`;a=a.concat("fq="+l.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=O.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}`:"",l=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(l,h).then(u=>u.json()).then(u=>{this.dataLayer.setLoading(!1),t(u)}).catch(()=>{this.dataLayer.setLoading(!1)})}}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 Z=Object.prototype.toString,A=Array.isArray||function(e){return Z.call(e)==="[object Array]"};function W(o){return typeof o=="function"}function ee(o){return A(o)?"array":typeof o}function K(o){return o.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g,"\\$&")}function z(o,e){return o!=null&&typeof o=="object"&&e in o}function te(o,e){return o!=null&&typeof o!="object"&&o.hasOwnProperty&&o.hasOwnProperty(e)}var ae=RegExp.prototype.test;function se(o,e){return ae.call(o,e)}var re=/\S/;function ie(o){return!se(re,o)}var ne={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;","/":"&#x2F;","`":"&#x60;","=":"&#x3D;"};function ce(o){return String(o).replace(/[&<>"'`=\/]/g,function(t){return ne[t]})}var le=/\s*/,oe=/\s+/,J=/\s*=/,he=/\s*\}/,ue=/#|\^|\/|>|\{|&|=|!/;function de(o,e){if(!o)return[];var t=!1,a=[],r=[],s=[],i=!1,c=!1,l="",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 T(P){if(typeof P=="string"&&(P=P.split(oe,2)),!A(P)||P.length!==2)throw new Error("Invalid tags: "+P);g=new RegExp(K(P[0])+"\\s*"),p=new RegExp("\\s*"+K(P[1])),y=new RegExp("\\s*"+K("}"+P[1]))}T(e||f.tags);for(var m=new $(o),S,v,L,R,I,x;!m.eos();){if(S=m.pos,L=m.scanUntil(g),L)for(var D=0,N=L.length;D<N;++D)R=L.charAt(D),ie(R)?(s.push(r.length),l+=R):(c=!0,t=!0,l+=" "),r.push(["text",R,S,S+1]),S+=1,R===`
@@ -729,7 +729,7 @@ class H {
729
729
  language: e.language
730
730
  };
731
731
  setTimeout(() => {
732
- this.msq.push(["trackClick", t]);
732
+ t.key && this.msq.push(["trackClick", t]);
733
733
  }, 0);
734
734
  }
735
735
  static trackSearch(e) {
@@ -745,7 +745,7 @@ class H {
745
745
  impressions: e.impressions
746
746
  };
747
747
  setTimeout(() => {
748
- this.msq.push(["track", t]);
748
+ t.key && this.msq.push(["trackSearch", t]);
749
749
  }, 0);
750
750
  }
751
751
  static trackRelatedSearchClick(e) {
@@ -761,7 +761,7 @@ class H {
761
761
  language: e.language
762
762
  };
763
763
  setTimeout(() => {
764
- this.msq.push(["trackRelatedSearchClick", t]);
764
+ t.key && this.msq.push(["trackRelatedSearchClick", t]);
765
765
  }, 0);
766
766
  }
767
767
  static trackRelatedSearches(e) {
@@ -775,7 +775,7 @@ class H {
775
775
  impressions: e.impressions
776
776
  };
777
777
  setTimeout(() => {
778
- this.msq.push(["trackRelatedSearch", t]);
778
+ t.key && this.msq.push(["trackRelatedSearch", t]);
779
779
  }, 0);
780
780
  }
781
781
  }
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.8",
4
+ "version": "0.5.9",
5
5
  "files": [
6
6
  "dist"
7
7
  ],