@searchstax-inc/searchstudio-ux-react 0.0.1 → 0.0.2

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.
@@ -0,0 +1,11 @@
1
+ import type { ISearchstaxSearchProps, ISearchstaxSuggestProps, ISearchstaxParsedResult, ISearchstaxSuggestResponse } from "@searchstax-inc/searchstudio-ux-js";
2
+ declare function SearchstaxInputWidget(props: {
3
+ beforeSearch: (props: ISearchstaxSearchProps) => ISearchstaxSearchProps | null;
4
+ afterSearch: (results: ISearchstaxParsedResult[]) => ISearchstaxParsedResult[];
5
+ afterAutosuggest: (result: ISearchstaxSuggestResponse) => ISearchstaxSuggestResponse;
6
+ beforeAutosuggest: (props: ISearchstaxSuggestProps) => ISearchstaxSuggestProps | null;
7
+ searchInputId?: string;
8
+ suggestAfterMinChars?: number;
9
+ inputTemplate?: () => React.ReactElement;
10
+ }): JSX.Element;
11
+ export default SearchstaxInputWidget;
@@ -0,0 +1,7 @@
1
+ import type { ISearchstaxParsedResult } from '@searchstax-inc/searchstudio-ux-js';
2
+ declare function SearchstaxResultWidget(props: {
3
+ afterLinkClick: (results: ISearchstaxParsedResult[]) => ISearchstaxParsedResult[];
4
+ noResultTemplate?: (searchTerm: string, searchSuggestion: string) => React.ReactElement;
5
+ resultsTemplate?: (results: ISearchstaxParsedResult[], resultClicked: (result: ISearchstaxParsedResult, event: any) => any) => React.ReactElement;
6
+ }): JSX.Element;
7
+ export default SearchstaxResultWidget;
@@ -0,0 +1,12 @@
1
+ import Searchstax from '@searchstax-inc/searchstudio-ux-js';
2
+ declare function SearchstaxWrapper(props: {
3
+ language?: string;
4
+ searchURL: string;
5
+ suggesterURL: string;
6
+ trackApiKey: string;
7
+ searchAuth: string;
8
+ authType?: "basic" | "token";
9
+ children: any;
10
+ initialized: (searchstax: Searchstax) => void;
11
+ }): JSX.Element;
12
+ export default SearchstaxWrapper;
@@ -1,5 +1,4 @@
1
- import SearchstaxInputWidget from "./components/SearchstaxInputWidget";
1
+ import SearchstaxInputWidget from "./components/SearchstaxInputWidget";
2
2
  import SearchstaxWrapper from "./components/SearchstaxWrapper";
3
3
  import SearchstaxResultWidget from "./components/SearchstaxResultWidget";
4
-
5
4
  export { SearchstaxWrapper, SearchstaxResultWidget, SearchstaxInputWidget };
@@ -0,0 +1,95 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const D=require("react");var d={},xt={get exports(){return d},set exports(r){d=r}},X={};/**
2
+ * @license React
3
+ * react-jsx-runtime.production.min.js
4
+ *
5
+ * Copyright (c) Facebook, Inc. and its affiliates.
6
+ *
7
+ * This source code is licensed under the MIT license found in the
8
+ * LICENSE file in the root directory of this source tree.
9
+ */var Ne;function Ct(){if(Ne)return X;Ne=1;var r=D,e=Symbol.for("react.element"),s=Symbol.for("react.fragment"),n=Object.prototype.hasOwnProperty,a=r.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,i={key:!0,ref:!0,__self:!0,__source:!0};function u(l,h,p){var C,I={},L=null,B=null;p!==void 0&&(L=""+p),h.key!==void 0&&(L=""+h.key),h.ref!==void 0&&(B=h.ref);for(C in h)n.call(h,C)&&!i.hasOwnProperty(C)&&(I[C]=h[C]);if(l&&l.defaultProps)for(C in h=l.defaultProps,h)I[C]===void 0&&(I[C]=h[C]);return{$$typeof:e,type:l,key:L,ref:B,props:I,_owner:a.current}}return X.Fragment=s,X.jsx=u,X.jsxs=u,X}var Q={};/**
10
+ * @license React
11
+ * react-jsx-runtime.development.js
12
+ *
13
+ * Copyright (c) Facebook, Inc. and its affiliates.
14
+ *
15
+ * This source code is licensed under the MIT license found in the
16
+ * LICENSE file in the root directory of this source tree.
17
+ */var qe;function Rt(){return qe||(qe=1,process.env.NODE_ENV!=="production"&&function(){var r=D,e=Symbol.for("react.element"),s=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),a=Symbol.for("react.strict_mode"),i=Symbol.for("react.profiler"),u=Symbol.for("react.provider"),l=Symbol.for("react.context"),h=Symbol.for("react.forward_ref"),p=Symbol.for("react.suspense"),C=Symbol.for("react.suspense_list"),I=Symbol.for("react.memo"),L=Symbol.for("react.lazy"),B=Symbol.for("react.offscreen"),Y=Symbol.iterator,E="@@iterator";function O(t){if(t===null||typeof t!="object")return null;var o=Y&&t[Y]||t[E];return typeof o=="function"?o:null}var R=r.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function y(t){{for(var o=arguments.length,c=new Array(o>1?o-1:0),f=1;f<o;f++)c[f-1]=arguments[f];U("error",t,c)}}function U(t,o,c){{var f=R.ReactDebugCurrentFrame,b=f.getStackAddendum();b!==""&&(o+="%s",c=c.concat([b]));var x=c.map(function(m){return String(m)});x.unshift("Warning: "+o),Function.prototype.apply.call(console[t],console,x)}}var W=!1,P=!1,z=!1,oe=!1,_=!1,ye;ye=Symbol.for("react.module.reference");function Ye(t){return!!(typeof t=="string"||typeof t=="function"||t===n||t===i||_||t===a||t===p||t===C||oe||t===B||W||P||z||typeof t=="object"&&t!==null&&(t.$$typeof===L||t.$$typeof===I||t.$$typeof===u||t.$$typeof===l||t.$$typeof===h||t.$$typeof===ye||t.getModuleId!==void 0))}function ze(t,o,c){var f=t.displayName;if(f)return f;var b=o.displayName||o.name||"";return b!==""?c+"("+b+")":c}function xe(t){return t.displayName||"Context"}function V(t){if(t==null)return null;if(typeof t.tag=="number"&&y("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),typeof t=="function")return t.displayName||t.name||null;if(typeof t=="string")return t;switch(t){case n:return"Fragment";case s:return"Portal";case i:return"Profiler";case a:return"StrictMode";case p:return"Suspense";case C:return"SuspenseList"}if(typeof t=="object")switch(t.$$typeof){case l:var o=t;return xe(o)+".Consumer";case u:var c=t;return xe(c._context)+".Provider";case h:return ze(t,t.render,"ForwardRef");case I:var f=t.displayName||null;return f!==null?f:V(t.type)||"Memo";case L:{var b=t,x=b._payload,m=b._init;try{return V(m(x))}catch{return null}}}return null}var H=Object.assign,G=0,Ce,Re,Se,Ee,ke,Te,Ie;function Ae(){}Ae.__reactDisabledLog=!0;function Ge(){{if(G===0){Ce=console.log,Re=console.info,Se=console.warn,Ee=console.error,ke=console.group,Te=console.groupCollapsed,Ie=console.groupEnd;var t={configurable:!0,enumerable:!0,value:Ae,writable:!0};Object.defineProperties(console,{info:t,log:t,warn:t,error:t,group:t,groupCollapsed:t,groupEnd:t})}G++}}function Je(){{if(G--,G===0){var t={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:H({},t,{value:Ce}),info:H({},t,{value:Re}),warn:H({},t,{value:Se}),error:H({},t,{value:Ee}),group:H({},t,{value:ke}),groupCollapsed:H({},t,{value:Te}),groupEnd:H({},t,{value:Ie})})}G<0&&y("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var ue=R.ReactCurrentDispatcher,ce;function se(t,o,c){{if(ce===void 0)try{throw Error()}catch(b){var f=b.stack.trim().match(/\n( *(at )?)/);ce=f&&f[1]||""}return`
18
+ `+ce+t}}var le=!1,re;{var Xe=typeof WeakMap=="function"?WeakMap:Map;re=new Xe}function we(t,o){if(!t||le)return"";{var c=re.get(t);if(c!==void 0)return c}var f;le=!0;var b=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var x;x=ue.current,ue.current=null,Ge();try{if(o){var m=function(){throw Error()};if(Object.defineProperty(m.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(m,[])}catch(M){f=M}Reflect.construct(t,[],m)}else{try{m.call()}catch(M){f=M}t.call(m.prototype)}}else{try{throw Error()}catch(M){f=M}t()}}catch(M){if(M&&f&&typeof M.stack=="string"){for(var v=M.stack.split(`
19
+ `),A=f.stack.split(`
20
+ `),S=v.length-1,k=A.length-1;S>=1&&k>=0&&v[S]!==A[k];)k--;for(;S>=1&&k>=0;S--,k--)if(v[S]!==A[k]){if(S!==1||k!==1)do if(S--,k--,k<0||v[S]!==A[k]){var j=`
21
+ `+v[S].replace(" at new "," at ");return t.displayName&&j.includes("<anonymous>")&&(j=j.replace("<anonymous>",t.displayName)),typeof t=="function"&&re.set(t,j),j}while(S>=1&&k>=0);break}}}finally{le=!1,ue.current=x,Je(),Error.prepareStackTrace=b}var q=t?t.displayName||t.name:"",We=q?se(q):"";return typeof t=="function"&&re.set(t,We),We}function Qe(t,o,c){return we(t,!1)}function Ze(t){var o=t.prototype;return!!(o&&o.isReactComponent)}function ae(t,o,c){if(t==null)return"";if(typeof t=="function")return we(t,Ze(t));if(typeof t=="string")return se(t);switch(t){case p:return se("Suspense");case C:return se("SuspenseList")}if(typeof t=="object")switch(t.$$typeof){case h:return Qe(t.render);case I:return ae(t.type,o,c);case L:{var f=t,b=f._payload,x=f._init;try{return ae(x(b),o,c)}catch{}}}return""}var ne=Object.prototype.hasOwnProperty,Le={},je=R.ReactDebugCurrentFrame;function ie(t){if(t){var o=t._owner,c=ae(t.type,t._source,o?o.type:null);je.setExtraStackFrame(c)}else je.setExtraStackFrame(null)}function et(t,o,c,f,b){{var x=Function.call.bind(ne);for(var m in t)if(x(t,m)){var v=void 0;try{if(typeof t[m]!="function"){var A=Error((f||"React class")+": "+c+" type `"+m+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof t[m]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw A.name="Invariant Violation",A}v=t[m](o,m,f,c,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(S){v=S}v&&!(v instanceof Error)&&(ie(b),y("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",f||"React class",c,m,typeof v),ie(null)),v instanceof Error&&!(v.message in Le)&&(Le[v.message]=!0,ie(b),y("Failed %s type: %s",c,v.message),ie(null))}}}var tt=Array.isArray;function he(t){return tt(t)}function st(t){{var o=typeof Symbol=="function"&&Symbol.toStringTag,c=o&&t[Symbol.toStringTag]||t.constructor.name||"Object";return c}}function rt(t){try{return _e(t),!1}catch{return!0}}function _e(t){return""+t}function Oe(t){if(rt(t))return y("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",st(t)),_e(t)}var J=R.ReactCurrentOwner,at={key:!0,ref:!0,__self:!0,__source:!0},Pe,Ve,ge;ge={};function nt(t){if(ne.call(t,"ref")){var o=Object.getOwnPropertyDescriptor(t,"ref").get;if(o&&o.isReactWarning)return!1}return t.ref!==void 0}function it(t){if(ne.call(t,"key")){var o=Object.getOwnPropertyDescriptor(t,"key").get;if(o&&o.isReactWarning)return!1}return t.key!==void 0}function ot(t,o){if(typeof t.ref=="string"&&J.current&&o&&J.current.stateNode!==o){var c=V(J.current.type);ge[c]||(y('Component "%s" contains the string ref "%s". Support for string refs will be removed in a future major release. This case cannot be automatically converted to an arrow function. We ask you to manually fix this case by using useRef() or createRef() instead. Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref',V(J.current.type),t.ref),ge[c]=!0)}}function ut(t,o){{var c=function(){Pe||(Pe=!0,y("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",o))};c.isReactWarning=!0,Object.defineProperty(t,"key",{get:c,configurable:!0})}}function ct(t,o){{var c=function(){Ve||(Ve=!0,y("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",o))};c.isReactWarning=!0,Object.defineProperty(t,"ref",{get:c,configurable:!0})}}var lt=function(t,o,c,f,b,x,m){var v={$$typeof:e,type:t,key:o,ref:c,props:m,_owner:x};return v._store={},Object.defineProperty(v._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(v,"_self",{configurable:!1,enumerable:!1,writable:!1,value:f}),Object.defineProperty(v,"_source",{configurable:!1,enumerable:!1,writable:!1,value:b}),Object.freeze&&(Object.freeze(v.props),Object.freeze(v)),v};function ht(t,o,c,f,b){{var x,m={},v=null,A=null;c!==void 0&&(Oe(c),v=""+c),it(o)&&(Oe(o.key),v=""+o.key),nt(o)&&(A=o.ref,ot(o,b));for(x in o)ne.call(o,x)&&!at.hasOwnProperty(x)&&(m[x]=o[x]);if(t&&t.defaultProps){var S=t.defaultProps;for(x in S)m[x]===void 0&&(m[x]=S[x])}if(v||A){var k=typeof t=="function"?t.displayName||t.name||"Unknown":t;v&&ut(m,k),A&&ct(m,k)}return lt(t,v,A,b,f,J.current,m)}}var de=R.ReactCurrentOwner,Me=R.ReactDebugCurrentFrame;function N(t){if(t){var o=t._owner,c=ae(t.type,t._source,o?o.type:null);Me.setExtraStackFrame(c)}else Me.setExtraStackFrame(null)}var fe;fe=!1;function pe(t){return typeof t=="object"&&t!==null&&t.$$typeof===e}function Fe(){{if(de.current){var t=V(de.current.type);if(t)return`
22
+
23
+ Check the render method of \``+t+"`."}return""}}function gt(t){{if(t!==void 0){var o=t.fileName.replace(/^.*[\\\/]/,""),c=t.lineNumber;return`
24
+
25
+ Check your code at `+o+":"+c+"."}return""}}var De={};function dt(t){{var o=Fe();if(!o){var c=typeof t=="string"?t:t.displayName||t.name;c&&(o=`
26
+
27
+ Check the top-level render call using <`+c+">.")}return o}}function Be(t,o){{if(!t._store||t._store.validated||t.key!=null)return;t._store.validated=!0;var c=dt(o);if(De[c])return;De[c]=!0;var f="";t&&t._owner&&t._owner!==de.current&&(f=" It was passed a child from "+V(t._owner.type)+"."),N(t),y('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',c,f),N(null)}}function Ue(t,o){{if(typeof t!="object")return;if(he(t))for(var c=0;c<t.length;c++){var f=t[c];pe(f)&&Be(f,o)}else if(pe(t))t._store&&(t._store.validated=!0);else if(t){var b=O(t);if(typeof b=="function"&&b!==t.entries)for(var x=b.call(t),m;!(m=x.next()).done;)pe(m.value)&&Be(m.value,o)}}}function ft(t){{var o=t.type;if(o==null||typeof o=="string")return;var c;if(typeof o=="function")c=o.propTypes;else if(typeof o=="object"&&(o.$$typeof===h||o.$$typeof===I))c=o.propTypes;else return;if(c){var f=V(o);et(c,t.props,"prop",f,t)}else if(o.PropTypes!==void 0&&!fe){fe=!0;var b=V(o);y("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",b||"Unknown")}typeof o.getDefaultProps=="function"&&!o.getDefaultProps.isReactClassApproved&&y("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function pt(t){{for(var o=Object.keys(t.props),c=0;c<o.length;c++){var f=o[c];if(f!=="children"&&f!=="key"){N(t),y("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",f),N(null);break}}t.ref!==null&&(N(t),y("Invalid attribute `ref` supplied to `React.Fragment`."),N(null))}}function He(t,o,c,f,b,x){{var m=Ye(t);if(!m){var v="";(t===void 0||typeof t=="object"&&t!==null&&Object.keys(t).length===0)&&(v+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");var A=gt(b);A?v+=A:v+=Fe();var S;t===null?S="null":he(t)?S="array":t!==void 0&&t.$$typeof===e?(S="<"+(V(t.type)||"Unknown")+" />",v=" Did you accidentally export a JSX literal instead of a component?"):S=typeof t,y("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",S,v)}var k=ht(t,o,c,b,x);if(k==null)return k;if(m){var j=o.children;if(j!==void 0)if(f)if(he(j)){for(var q=0;q<j.length;q++)Ue(j[q],t);Object.freeze&&Object.freeze(j)}else y("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else Ue(j,t)}return t===n?pt(k):ft(k),k}}function vt(t,o,c){return He(t,o,c,!0)}function mt(t,o,c){return He(t,o,c,!1)}var bt=mt,yt=vt;Q.Fragment=n,Q.jsx=bt,Q.jsxs=yt}()),Q}(function(r){process.env.NODE_ENV==="production"?r.exports=Ct():r.exports=Rt()})(xt);var St=Object.defineProperty,Et=(r,e,s)=>e in r?St(r,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):r[e]=s,g=(r,e,s)=>(Et(r,typeof e!="symbol"?e+"":e,s),s);class Z{constructor(e){g(this,"value"),g(this,"observers",[]),this.value=e,this.observers=[]}subscribe(e){this.observers.push(e),e(this.value)}unsubscribe(e){const s=this.observers.indexOf(e);s!==-1&&this.observers.splice(s,1)}setValue(e){this.value=e,this.notify()}getValue(){return this.value}notify(){this.observers.forEach(e=>e(this.value))}}class kt{constructor(){g(this,"searchTermChangeObservable",new Z("")),g(this,"loadingChangeObservable",new Z(!1)),g(this,"searchResultsObservable",new Z(null)),g(this,"searchResultsMetadataObservable",new Z(null)),g(this,"searchAutosuggestObservable",new Z(null)),g(this,"currentPage",1),g(this,"renderingEngine","mustache")}setSearchTerm(e){this.searchTermChangeObservable.setValue(e)}setRenderingEngine(e){this.renderingEngine=e}setCurrentPage(e){this.currentPage=e}setLoading(e){this.loadingChangeObservable.setValue(e)}setSearchResults(e){this.searchResultsObservable.setValue(e)}setSearchResultsMetadata(e){this.searchResultsMetadataObservable.setValue(e)}setSearchAutosuggest(e){this.searchAutosuggestObservable.setValue(e)}get searchResultsValue(){return this.searchResultsObservable.getValue()}get searchTermValue(){return this.searchTermChangeObservable.getValue()}get loadingValue(){return this.loadingChangeObservable.getValue()}get searchAutosuggestValue(){return this.searchAutosuggestObservable.getValue()}get searchResultsMetadataValue(){return this.searchResultsMetadataObservable.getValue()}get currentPageValue(){return this.currentPage}get renderingEngineValue(){return this.renderingEngine}}class ve{static combineResultsWithMetadata(e){const s=[],n=parseInt(e.response.start+"");return e.response.docs.forEach((a,i)=>{const u={custom:null,uniqueId:this.getValueByKey(e.responseHeader.params.uniqueId,a,e)??"",position:n+i+1,ribbon:this.doesMapExist("ribbon",e)?this.getValueByKey("ribbon",a,e):null,paths:this.doesMapExist("paths",e)?this.getValueByKey("paths",a,e):null,url:this.doesMapExist("url",e)?this.getValueByKey("url",a,e):null,title:this.doesMapExist("title",e)?this.getValueByKey("title",a,e):null,promoted:a["[elevated]"]?a["[elevated]"]:!1,thumbnail:this.doesMapExist("thumbnail",e)?this.getValueByKey("thumbnail",a,e):null,date:this.doesMapExist("date",e)?this.getValueByKey("date",a,e):null,snippet:this.doesMapExist("snippet",e)?this.getValueByKey("snippet",a,e):null,description:this.doesMapExist("description",e)?this.getValueByKey("description",a,e):null,unmappedFields:this.getUnmappedFields(a,e),allFields:this.getAllFields(a,e)};s.push(u)}),s}static extractSearchResultsMetadata(e){var s,n,a,i;let u="";return u=((i=(a=(n=(s=e==null?void 0:e.spellcheck)==null?void 0:s.suggestions)==null?void 0:n[0])==null?void 0:a.suggestion)==null?void 0:i[0])??"",typeof u!="string"&&(u=(u==null?void 0:u.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:u}}static findResultByUniqueId(e,s){return s.find(n=>n.uniqueId===e)??null}static getUnmappedFields(e,s){const n=s.metadata.results.filter(i=>i.result_card==="").map(i=>i.name),a=[];for(const i of Object.keys(e))if(n.indexOf(i)!==-1){const u=Array.isArray(e[i])?e[i].join(", "):e[i];a.push({key:i,value:u,isImage:this.checkIfImage(e[i])})}return a}static checkIfImage(e){return e===void 0||typeof e!="string"?!1:/\.(gif|jpe?g|tiff?|png|webp|bmp)$/i.test(e)}static getAllFields(e,s){const n=s.metadata.results.map(i=>i.name),a=[];for(const i of Object.keys(e))n.indexOf(i)!==-1&&a.push({key:i,value:e[i],isImage:this.checkIfImage(e[i])});return a}static doesMapExist(e,s){return s.metadata.results.find(n=>n.result_card===e)!==void 0}static getValueByKey(e,s,n){const a=n.metadata.results.find(u=>u.result_card===e);if(a===void 0)return null;const i=s[a.name];return i===void 0?null:typeof i=="string"?i:Array.isArray(i)?i.join(", "):null}}class Tt{constructor(e,s){g(this,"url",""),g(this,"relatedSearches",""),g(this,"suggester",""),g(this,"authHeader"),g(this,"authHeaderRelated"),g(this,"language","en"),g(this,"trackApiKey",""),g(this,"session",""),g(this,"searchAuthType"),g(this,"controllerSearch"),g(this,"signalSearch"),g(this,"controllerSuggest"),g(this,"signalSuggest"),g(this,"dataLayer"),this.dataLayer=s,this.url=e.searchURL,this.language=e.language,this.suggester=e.suggesterURL,this.trackApiKey=e.trackApiKey,this.session=e.sessionId,this.searchAuthType=e.authType,this.authHeader=new Headers,this.authHeader.append("Accept","application/json");const n=this.searchAuthType==="token"?`Token ${e.searchAuth}`:`Basic ${e.searchAuth}`;this.authHeader.append("Authorization",n),this.authHeaderRelated=new Headers,this.authHeaderRelated.append("Accept","application/json"),this.authHeaderRelated.append("Authorization",e.searchAuth)}search(e,s,n){this.dataLayer.setSearchTerm(e),this.dataLayer.setLoading(!0),this.controllerSearch&&this.controllerSearch.abort(),this.controllerSearch=new AbortController,this.signalSearch=this.controllerSearch.signal;const a=new Proxy(new URLSearchParams(window.location.search),{get:(l,h)=>l.get(h)??""}),i=a.languageVariant?"&fq=_language:"+a.languageVariant:"",u=this.url+"?q="+encodeURIComponent(e.trim())+this.toQueryString(n)+"&language="+this.language+i;fetch(u,{method:"GET",headers:this.authHeader,credentials:"same-origin",signal:this.signalSearch}).then(l=>l.json()).then(l=>{this.dataLayer.setLoading(!1),s(l)}).catch(l=>{this.dataLayer.setLoading(!1),console.log(l)})}suggest(e,s,n){this.controllerSuggest&&this.controllerSuggest.abort(),this.controllerSuggest=new AbortController,this.signalSuggest=this.controllerSuggest.signal;const a=this.suggester+"?q="+e.trim()+this.toQueryString(n)+"&language="+this.language;fetch(a,{method:"GET",headers:this.authHeader,credentials:"same-origin",signal:this.signalSuggest}).then(i=>i.json()).then(i=>{s(i)}).catch(i=>console.log(i))}fields(){return this.fields}toQueryString(e){return"&"+e.join("&")}}class It{static getOrSetCookie(e){let s=this.getCookie(e);return s==null&&(s=this.makeid(25),this.setCookie(e,s,{secure:!0,"max-age":3600})),s}static makeid(e){let s="";const n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",a=n.length;for(let i=0;i<e;i++)s+=n.charAt(Math.floor(Math.random()*a));return s}static getCookie(e){const s=document.cookie.match(new RegExp("(?:^|; )"+e.replace(/([.$?*|{}()[\]\\/+^])/g,"\\$1")+"=([^;]*)"));return s?decodeURIComponent(s[1]):void 0}static setCookie(e,s,n){const a={path:"/",...n};n.expires instanceof Date&&(a.expires=n.expires.toUTCString());let i=encodeURIComponent(e)+"="+encodeURIComponent(s);for(const u in a){i+="; "+u;const l=a[u];l!==!0&&(i+="="+l)}document.cookie=i}}class At{static trackClick(e){const s={key:e.trackApiKey,query:e.searchTermValue,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};_msq.push(["trackClick",s])}}/*!
28
+ * mustache.js - Logic-less {{mustache}} templates with JavaScript
29
+ * http://github.com/janl/mustache.js
30
+ */var wt=Object.prototype.toString,K=Array.isArray||function(r){return wt.call(r)==="[object Array]"};function be(r){return typeof r=="function"}function Lt(r){return K(r)?"array":typeof r}function me(r){return r.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g,"\\$&")}function $e(r,e){return r!=null&&typeof r=="object"&&e in r}function jt(r,e){return r!=null&&typeof r!="object"&&r.hasOwnProperty&&r.hasOwnProperty(e)}var _t=RegExp.prototype.test;function Ot(r,e){return _t.call(r,e)}var Pt=/\S/;function Vt(r){return!Ot(Pt,r)}var Mt={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;","/":"&#x2F;","`":"&#x60;","=":"&#x3D;"};function Ft(r){return String(r).replace(/[&<>"'`=\/]/g,function(e){return Mt[e]})}var Dt=/\s*/,Bt=/\s+/,Ke=/\s*=/,Ut=/\s*\}/,Ht=/#|\^|\/|>|\{|&|=|!/;function Wt(r,e){if(!r)return[];var s=!1,n=[],a=[],i=[],u=!1,l=!1,h="",p=0;function C(){if(u&&!l)for(;i.length;)delete a[i.pop()];else i=[];u=!1,l=!1}var I,L,B;function Y(_){if(typeof _=="string"&&(_=_.split(Bt,2)),!K(_)||_.length!==2)throw new Error("Invalid tags: "+_);I=new RegExp(me(_[0])+"\\s*"),L=new RegExp("\\s*"+me(_[1])),B=new RegExp("\\s*"+me("}"+_[1]))}Y(e||T.tags);for(var E=new te(r),O,R,y,U,W,P;!E.eos();){if(O=E.pos,y=E.scanUntil(I),y)for(var z=0,oe=y.length;z<oe;++z)U=y.charAt(z),Vt(U)?(i.push(a.length),h+=U):(l=!0,s=!0,h+=" "),a.push(["text",U,O,O+1]),O+=1,U===`
31
+ `&&(C(),h="",p=0,s=!1);if(!E.scan(I))break;if(u=!0,R=E.scan(Ht)||"name",E.scan(Dt),R==="="?(y=E.scanUntil(Ke),E.scan(Ke),E.scanUntil(L)):R==="{"?(y=E.scanUntil(B),E.scan(Ut),E.scanUntil(L),R="&"):y=E.scanUntil(L),!E.scan(L))throw new Error("Unclosed tag at "+E.pos);if(R==">"?W=[R,y,O,E.pos,h,p,s]:W=[R,y,O,E.pos],p++,a.push(W),R==="#"||R==="^")n.push(W);else if(R==="/"){if(P=n.pop(),!P)throw new Error('Unopened section "'+y+'" at '+O);if(P[1]!==y)throw new Error('Unclosed section "'+P[1]+'" at '+O)}else R==="name"||R==="{"||R==="&"?l=!0:R==="="&&Y(y)}if(C(),P=n.pop(),P)throw new Error('Unclosed section "'+P[1]+'" at '+E.pos);return qt(Nt(a))}function Nt(r){for(var e=[],s,n,a=0,i=r.length;a<i;++a)s=r[a],s&&(s[0]==="text"&&n&&n[0]==="text"?(n[1]+=s[1],n[3]=s[3]):(e.push(s),n=s));return e}function qt(r){for(var e=[],s=e,n=[],a,i,u=0,l=r.length;u<l;++u)switch(a=r[u],a[0]){case"#":case"^":s.push(a),n.push(a),s=a[4]=[];break;case"/":i=n.pop(),i[5]=a[2],s=n.length>0?n[n.length-1][4]:e;break;default:s.push(a)}return e}function te(r){this.string=r,this.tail=r,this.pos=0}te.prototype.eos=function(){return this.tail===""};te.prototype.scan=function(r){var e=this.tail.match(r);if(!e||e.index!==0)return"";var s=e[0];return this.tail=this.tail.substring(s.length),this.pos+=s.length,s};te.prototype.scanUntil=function(r){var e=this.tail.search(r),s;switch(e){case-1:s=this.tail,this.tail="";break;case 0:s="";break;default:s=this.tail.substring(0,e),this.tail=this.tail.substring(e)}return this.pos+=s.length,s};function $(r,e){this.view=r,this.cache={".":this.view},this.parent=e}$.prototype.push=function(r){return new $(r,this)};$.prototype.lookup=function(r){var e=this.cache,s;if(e.hasOwnProperty(r))s=e[r];else{for(var n=this,a,i,u,l=!1;n;){if(r.indexOf(".")>0)for(a=n.view,i=r.split("."),u=0;a!=null&&u<i.length;)u===i.length-1&&(l=$e(a,i[u])||jt(a,i[u])),a=a[i[u++]];else a=n.view[r],l=$e(n.view,r);if(l){s=a;break}n=n.parent}e[r]=s}return be(s)&&(s=s.call(this.view)),s};function w(){this.templateCache={_cache:{},set:function(r,e){this._cache[r]=e},get:function(r){return this._cache[r]},clear:function(){this._cache={}}}}w.prototype.clearCache=function(){typeof this.templateCache<"u"&&this.templateCache.clear()};w.prototype.parse=function(r,e){var s=this.templateCache,n=r+":"+(e||T.tags).join(":"),a=typeof s<"u",i=a?s.get(n):void 0;return i==null&&(i=Wt(r,e),a&&s.set(n,i)),i};w.prototype.render=function(r,e,s,n){var a=this.getConfigTags(n),i=this.parse(r,a),u=e instanceof $?e:new $(e,void 0);return this.renderTokens(i,u,s,r,n)};w.prototype.renderTokens=function(r,e,s,n,a){for(var i="",u,l,h,p=0,C=r.length;p<C;++p)h=void 0,u=r[p],l=u[0],l==="#"?h=this.renderSection(u,e,s,n,a):l==="^"?h=this.renderInverted(u,e,s,n,a):l===">"?h=this.renderPartial(u,e,s,a):l==="&"?h=this.unescapedValue(u,e):l==="name"?h=this.escapedValue(u,e,a):l==="text"&&(h=this.rawValue(u)),h!==void 0&&(i+=h);return i};w.prototype.renderSection=function(r,e,s,n,a){var i=this,u="",l=e.lookup(r[1]);function h(I){return i.render(I,e,s,a)}if(l){if(K(l))for(var p=0,C=l.length;p<C;++p)u+=this.renderTokens(r[4],e.push(l[p]),s,n,a);else if(typeof l=="object"||typeof l=="string"||typeof l=="number")u+=this.renderTokens(r[4],e.push(l),s,n,a);else if(be(l)){if(typeof n!="string")throw new Error("Cannot use higher-order sections without the original template");l=l.call(e.view,n.slice(r[3],r[5]),h),l!=null&&(u+=l)}else u+=this.renderTokens(r[4],e,s,n,a);return u}};w.prototype.renderInverted=function(r,e,s,n,a){var i=e.lookup(r[1]);if(!i||K(i)&&i.length===0)return this.renderTokens(r[4],e,s,n,a)};w.prototype.indentPartial=function(r,e,s){for(var n=e.replace(/[^ \t]/g,""),a=r.split(`
32
+ `),i=0;i<a.length;i++)a[i].length&&(i>0||!s)&&(a[i]=n+a[i]);return a.join(`
33
+ `)};w.prototype.renderPartial=function(r,e,s,n){if(s){var a=this.getConfigTags(n),i=be(s)?s(r[1]):s[r[1]];if(i!=null){var u=r[6],l=r[5],h=r[4],p=i;l==0&&h&&(p=this.indentPartial(i,h,u));var C=this.parse(p,a);return this.renderTokens(C,e,s,p,n)}}};w.prototype.unescapedValue=function(r,e){var s=e.lookup(r[1]);if(s!=null)return s};w.prototype.escapedValue=function(r,e,s){var n=this.getConfigEscape(s)||T.escape,a=e.lookup(r[1]);if(a!=null)return typeof a=="number"&&n===T.escape?String(a):n(a)};w.prototype.rawValue=function(r){return r[1]};w.prototype.getConfigTags=function(r){return K(r)?r:r&&typeof r=="object"?r.tags:void 0};w.prototype.getConfigEscape=function(r){if(r&&typeof r=="object"&&!K(r))return r.escape};var T={name:"mustache.js",version:"4.2.0",tags:["{{","}}"],clearCache:void 0,escape:void 0,parse:void 0,render:void 0,Scanner:void 0,Context:void 0,Writer:void 0,set templateCache(r){ee.templateCache=r},get templateCache(){return ee.templateCache}},ee=new w;T.clearCache=function(){return ee.clearCache()};T.parse=function(r,e){return ee.parse(r,e)};T.render=function(r,e,s,n){if(typeof r!="string")throw new TypeError('Invalid template! Template should be a "string" but "'+Lt(r)+'" was given as the first argument for mustache#render(template, view, partials)');return ee.render(r,e,s,n)};T.escape=Ft;T.Scanner=te;T.Context=$;T.Writer=w;class $t{constructor(e){g(this,"dataLayer"),g(this,"config"),g(this,"suggestAfterMinChars"),g(this,"containerId"),g(this,"currentInputValue",""),g(this,"autosuggestResults"),g(this,"searchInput"),g(this,"actionButton"),g(this,"autosuggestContainer"),g(this,"buttonState","search"),g(this,"selectedAutosuggestItem",-1),g(this,"suggestTrigger"),g(this,"searchTrigger"),this.dataLayer=e.dataLayer,this.config=e.config,this.searchTrigger=e.searchTrigger,this.suggestTrigger=e.suggestTrigger,this.containerId=e.containerId,this.suggestAfterMinChars=e.config.suggestAfterMinChars,this.renderMainTemplate(),this.actionButtonInit(),this.updateActionButtonState("search"),this.searchInput&&(this.createAutosuggestContainer(),this.attachSubscriptions())}renderMainTemplate(){var e,s;const n=document.getElementById(this.containerId);if(!n)throw new Error("Search input container not found");const a=((e=this.config.templates)==null?void 0:e.mainTemplate)||`
34
+ <div class="searchstax-search-input-container">
35
+ <div class="searchstax-search-input-wrapper">
36
+ <input type="text" id="searchstax-search-input" class="searchstax-search-input" placeholder="SEARCH FOR..." />
37
+ <button class="searchstax-spinner-icon" id="searchstax-search-input-action-button"></button>
38
+ </div>
39
+ </div>
40
+ `;if(console.log("this.dataLayer.renderingEngineValue",this.dataLayer.renderingEngineValue),this.dataLayer.renderingEngineValue==="mustache"){const l=T.render(a,{});n.innerHTML=l}const i=((s=this.config.templates)==null?void 0:s.searchInputId)||"searchstax-search-input",u=document.querySelector(`#${i}`);if(u)this.searchInput=u,u.addEventListener("keyup",this.inputKeyupEvent.bind(this)),u.addEventListener("blur",this.hideAutosuggest.bind(this)),u.addEventListener("paste",this.inputPasteEvent.bind(this));else throw new Error("Input not found")}createAutosuggestContainer(){var e;this.autosuggestContainer=document.createElement("div"),this.autosuggestContainer.classList.add("searchstax-autosuggest-container"),this.autosuggestContainer.addEventListener("mouseleave",()=>{this.resetAutosuggestSelection(),this.markActiveAutosuggestItem()}),(e=this.searchInput)==null||e.after(this.autosuggestContainer)}actionButtonInit(){this.actionButton=document.getElementById("searchstax-search-input-action-button"),this.actionButton&&this.actionButton.addEventListener("click",()=>{var e;this.buttonState==="search"?this.executeSearch(((e=this.searchInput)==null?void 0:e.value)??""):this.buttonState==="close"&&this.searchInput&&(this.searchInput.value="",this.executeSearch(""))})}attachSubscriptions(){this.dataLayer.searchTermChangeObservable.subscribe(()=>{this.handleSearchTermChange()}),this.dataLayer.loadingChangeObservable.subscribe(()=>{this.handleLoadingChange()}),this.dataLayer.searchAutosuggestObservable.subscribe(e=>{e&&this.appendSuggestions(e)})}handleLoadingChange(){this.dataLayer.loadingValue?this.updateActionButtonState("loading"):this.handleSearchTermChange()}handleSearchTermChange(){var e;this.dataLayer.searchTermValue===((e=this.searchInput)==null?void 0:e.value)&&this.searchInput.value!==""?this.updateActionButtonState("close"):this.updateActionButtonState("search")}updateActionButtonState(e){if(this.buttonState=e,this.actionButton)switch(this.actionButton.classList.remove("searchstax-spinner-icon"),this.actionButton.classList.remove("searchstax-search-close"),this.actionButton.classList.remove("searchstax-search-icon"),e){case"loading":this.actionButton.classList.add("searchstax-spinner-icon");break;case"search":this.actionButton.classList.add("searchstax-search-icon");break;case"close":this.actionButton.classList.add("searchstax-search-close");break}}selectPreviousAutosuggestItem(){this.selectedAutosuggestItem>0?this.selectedAutosuggestItem--:this.selectedAutosuggestItem=this.autosuggestResults.suggestions.length-1,this.markActiveAutosuggestItem()}selectNextAutosuggestItem(){this.selectedAutosuggestItem<this.autosuggestResults.suggestions.length-1?this.selectedAutosuggestItem++:this.selectedAutosuggestItem=0,this.markActiveAutosuggestItem()}resetAutosuggestSelection(){this.selectedAutosuggestItem=-1,this.markActiveAutosuggestItem()}markActiveAutosuggestItem(){const e=document.getElementsByClassName("searchstax-autosuggest-item");for(let s=0;s<e.length;s++){const n=e[s];s===this.selectedAutosuggestItem?n.classList.add("active"):n.classList.remove("active")}}inputKeyupEvent(e){const s=e.key;this.currentInputValue=e.target.value,s==="Enter"?this.suggestionChosen():s==="Escape"?this.hideAutosuggest():s==="ArrowUp"?this.selectPreviousAutosuggestItem():s==="ArrowDown"?this.selectNextAutosuggestItem():this.autosuggestHandling(e),this.handleSearchTermChange()}autosuggestHandling(e){e.target&&e.target.value.length>=this.suggestAfterMinChars?this.executeSuggest(e.target.value):this.hideAutosuggest()}inputPasteEvent(e){setTimeout(()=>{this.autosuggestHandling(e),this.handleSearchTermChange()},0)}executeSuggest(e){this.suggestTrigger(e)}executeSearch(e){this.hideAutosuggest(),this.searchTrigger(e===""?"*":e)}suggestionChosen(){this.selectedAutosuggestItem>-1?this.autosuggestItemClicked(this.autosuggestResults.suggestions[this.selectedAutosuggestItem]):this.executeSearch(this.currentInputValue)}hideAutosuggest(){this.autosuggestContainer&&(this.autosuggestContainer.innerHTML="",this.autosuggestContainer.classList.add("hidden")),this.resetAutosuggestSelection()}cleanSuggestionTerm(e){return e.replace(/(<([^>]+)>)/gi,"").trim()}autosuggestItemClicked(e){this.searchInput.value=this.cleanSuggestionTerm(e.term),this.executeSearch(this.cleanSuggestionTerm(e.term))}createAutosuggestItem(e){var s;const n=document.createElement("div");n.classList.add("searchstax-autosuggest-item"),n.addEventListener("click",()=>{this.autosuggestItemClicked(e)}),n.addEventListener("mouseenter",()=>{var i;this.selectedAutosuggestItem=((i=this.autosuggestResults)==null?void 0:i.suggestions.indexOf(e))||0,this.markActiveAutosuggestItem()});const a=((s=this.config.templates)==null?void 0:s.autosuggestItemTemplate)||'<div class="searchstax-autosuggest-item-term-container">{{{term}}}</div>';return n.innerHTML=T.render(a,e),n}appendSuggestions(e){if(this.autosuggestContainer){this.autosuggestContainer.innerHTML="",this.autosuggestContainer.classList.remove("hidden");for(const s in e.suggest)if(Object.prototype.hasOwnProperty.call(e.suggest,s)){const n=e.suggest[s];for(const a in n)if(Object.prototype.hasOwnProperty.call(n,a)){const i=n[a];this.autosuggestResults=i,i.numFound>0?i.suggestions.forEach(u=>{this.autosuggestContainer.appendChild(this.createAutosuggestItem(u))}):this.autosuggestContainer.classList.add("hidden")}}}}}class Kt{constructor(e){g(this,"dataLayer"),g(this,"config"),g(this,"linkClickCallback"),g(this,"searchCallback"),g(this,"containerId"),g(this,"searchResultsMainContainer"),g(this,"searchResultsContainer"),g(this,"searchResultLinks",[]),this.linkClickCallback=e.linkClickCallback,this.searchCallback=e.searchTrigger,this.dataLayer=e.dataLayer,this.config=e.config,this.containerId=e.containerId;const s=document.getElementById(this.containerId);if(console.log("resultsContainer",s),s)this.searchResultsMainContainer=s;else throw new Error(`Search Results Main Container with id ${this.containerId} not found`);this.initializeSubscriptions(),this.renderMainTemplate()}initializeSubscriptions(){this.dataLayer.searchResultsObservable.subscribe(e=>{e&&this.searchResultsContainer&&this.renderResults(e)})}renderNoResultsTemplate(){var e,s,n;const a=((s=(e=this.config)==null?void 0:e.templates)==null?void 0:s.noSearchResultTemplate)||`
41
+ <div class="searchstax-no-results">
42
+ Showing <strong>no results</strong> for <strong>"{{ searchTerm }}"</strong>
43
+ <br>
44
+ {{#spellingSuggestion}}
45
+ <span>&nbsp;Did you mean <a href="#"
46
+ class="searchstax-suggestion-term">{{ spellingSuggestion }}</a>?</span>
47
+ {{/spellingSuggestion}}
48
+ </div>
49
+ <div>
50
+ <p>Try searching for search related terms or topics. We offer a wide variety of content to help you get the information you need.</p>
51
+ <p>Lost? Click on the ‘X” in the Search Box to reset your search.</p>
52
+ </div>
53
+ `,i=((n=this.dataLayer.searchResultsMetadataValue)==null?void 0:n.spellingSuggestion)??"";if(this.dataLayer.renderingEngineValue==="mustache"&&this.searchResultsContainer&&(this.searchResultsContainer.innerHTML=T.render(a,{spellingSuggestion:i,searchTerm:this.dataLayer.searchTermValue})),i&&this.searchResultsContainer){const u=this.searchResultsContainer.querySelector("a");u&&u.addEventListener("click",l=>{l.preventDefault(),l.stopPropagation(),this.searchCallback(i)})}}renderResults(e){var s,n;if(this.dataLayer.renderingEngineValue==="mustache"&&this.searchResultsContainer)if(this.removeLinkClickEvents(),e.length===0)this.renderNoResultsTemplate();else{const a=((n=(s=this.config)==null?void 0:s.templates)==null?void 0:n.searchResultTemplate)||`
54
+ <div class="searchstax-search-result">
55
+ {{#url}}
56
+ <a href="{{url}}" data-searchstax-unique-result-id="{{uniqueId}}" class="searchstax-result-item-link"></a>
57
+ {{/url}}
58
+ {{#ribbon}}
59
+ <div class="searchstax-search-result-ribbon">
60
+ {{ribbon}}
61
+ </div>
62
+ {{/ribbon}}
63
+ {{#thumbnail}}
64
+ <img :src="thumbnail" class="searchstax-thumbnail">
65
+ {{/thumbnail}}
66
+ <div class="searchstax-search-result-title-container">
67
+ <span class="searchstax-search-result-title">{{title}}</span>
68
+ </div>
69
+ {{#paths}}
70
+ <p class="searchstax-search-result-common">
71
+ {{paths}}
72
+ </p>
73
+ {{/paths}}
74
+ {{#description}}
75
+ <p class="searchstax-search-result-description searchstax-search-result-common">
76
+ {{description}}
77
+ </p>
78
+ {{/description}}
79
+ {{#unmappedFields}}
80
+ {{#isImage}}
81
+ <div class="searchstax-search-result-image-container">
82
+ <img :src="result[value]" class="searchstax-result-image">
83
+ </div>
84
+ {{/isImage}}
85
+ {{^isImage}}
86
+ <p class="searchstax-search-result-common">
87
+ {{value}}
88
+ </p>
89
+ {{/isImage}}
90
+ {{/unmappedFields}}
91
+ </div>`,i=e.map(u=>T.render(a,u));this.searchResultsContainer.innerHTML=i.join(""),this.searchResultLinks=Array.from(this.searchResultsContainer.querySelectorAll(`[${this.uniqueIdAttribute}]`)),this.attachLinkClickEvents()}}removeLinkClickEvents(){this.searchResultLinks.forEach(e=>{e.removeEventListener("click",()=>{})})}get uniqueIdAttribute(){return this.config.searchResultUniqueIdAttribute||"data-searchstax-unique-result-id"}attachLinkClickEvents(){this.searchResultLinks.forEach(e=>{e.addEventListener("click",s=>{s.preventDefault(),s.stopPropagation();const n=e.getAttribute(this.uniqueIdAttribute)??"";n&&this.linkClickCallback(n)})})}renderMainTemplate(){var e,s;const n=((s=(e=this.config)==null?void 0:e.templates)==null?void 0:s.mainTemplate)||`
92
+ <div class="searchstax-search-results-container">
93
+ <div class="searchstax-search-results"></div>
94
+ </div>
95
+ `;this.dataLayer.renderingEngineValue==="mustache"&&(this.searchResultsMainContainer.innerHTML=T.render(n,{})),setTimeout(()=>{var a,i;const u=(a=this.config)!=null&&a.searchResultsContainerId?(i=this.config)==null?void 0:i.searchResultsContainerId:"searchstax-search-results",l=document.getElementById(u);if(l)this.searchResultsContainer=l;else throw new Error(`Search Results Container with id ${u} not found`)},0)}}class Yt{constructor(e="mustache"){g(this,"sessionId"),g(this,"searchstaxConfig"),g(this,"searchHelper"),g(this,"searchInputConfig"),g(this,"searchResultsConfig"),g(this,"searchInputWidget"),g(this,"searchResultsWidget"),g(this,"dataLayer",new kt),e&&this.dataLayer.setRenderingEngine(e),this.sessionId=It.getOrSetCookie("searchstax_session_id"),this.handleHooks()}setRenderingEngine(e="mustache"){this.dataLayer.setRenderingEngine(e)}handleHooks(){var e,s;(s=(e=this.searchInputConfig)==null?void 0:e.hooks)!=null&&s.afterSearch&&this.dataLayer.searchResultsObservable.subscribe(n=>{this.searchInputConfig.hooks.afterSearch(n)})}initialize(e){this.searchstaxConfig||(this.searchstaxConfig=e,this.searchHelper=new Tt({...e,sessionId:this.sessionId},this.dataLayer))}search(e,s){this.searchHelper&&this.searchHelper.search(e,this.parseSearchResultsResponse.bind(this),s)}parseSearchResultsResponse(e){var s,n;let a=ve.combineResultsWithMetadata(e);(n=(s=this.searchInputConfig)==null?void 0:s.hooks)!=null&&n.afterSearch&&(a=this.searchInputConfig.hooks.afterSearch(a)),this.dataLayer.setSearchResults(a),this.dataLayer.setSearchResultsMetadata(ve.extractSearchResultsMetadata(e))}parseSuggestSuggestResponse(e){var s,n;let a=e;(n=(s=this.searchInputConfig)==null?void 0:s.hooks)!=null&&n.afterAutosuggest&&(a=this.searchInputConfig.hooks.afterAutosuggest(e)),this.dataLayer.setSearchAutosuggest(a)}suggest(e,s){this.searchHelper&&this.searchHelper.suggest(e,this.parseSuggestSuggestResponse.bind(this),s)}changeLanguage(e){this.searchHelper&&(this.searchHelper.language=e)}addSearchInputWidget(e,s){this.searchInputConfig||(this.searchInputConfig=s,this.searchInputWidget=new $t({containerId:e,config:s,searchTrigger:this.executeSearch.bind(this),suggestTrigger:this.executeSuggest.bind(this),dataLayer:this.dataLayer}))}addSearchResultsWidget(e,s){this.searchResultsConfig||(this.searchResultsConfig=s,this.searchResultsWidget=new Kt({containerId:e,linkClickCallback:this.executeLinkClick.bind(this),searchTrigger:this.executeSearch.bind(this),config:s,dataLayer:this.dataLayer}))}executeSearch(e){var s,n;let a={term:e,queryParams:[]};(n=(s=this.searchInputConfig)==null?void 0:s.hooks)!=null&&n.beforeSearch&&(a=this.searchInputConfig.hooks.beforeSearch(a)),a&&a.term!==void 0&&a.queryParams!==void 0&&this.search(a.term,a.queryParams)}executeSuggest(e){var s,n;let a={term:e,queryParams:[]};(n=(s=this.searchInputConfig)==null?void 0:s.hooks)!=null&&n.beforeAutosuggest&&(a=this.searchInputConfig.hooks.beforeAutosuggest(a)),a&&a.term!==void 0&&a.queryParams!==void 0&&this.suggest(a.term,a.queryParams)}executeLinkClick(e){var s,n,a,i;let u=ve.findResultByUniqueId(e,this.dataLayer.searchResultsValue??[]);u&&((n=(s=this.searchResultsConfig)==null?void 0:s.hooks)!=null&&n.afterLinkClick&&(u=this.searchResultsConfig.hooks.afterLinkClick(u)),u&&(console.log("foundResult",u),this.dataLayer.searchResultsMetadataValue&&At.trackClick({result:u,searchTermValue:this.dataLayer.searchTermValue,trackApiKey:((a=this.searchstaxConfig)==null?void 0:a.trackApiKey)??"",session:this.sessionId,language:((i=this.searchHelper)==null?void 0:i.language)??"",recordsPerPage:this.dataLayer.searchResultsMetadataValue.recordsPerPageValue,totalResults:this.dataLayer.searchResultsMetadataValue.totalResultsValue,currentPage:this.dataLayer.currentPageValue,latencyVal:this.dataLayer.searchResultsMetadataValue.latency})))}}const F={searchstax:new Yt("react")};function zt(r){return D.useEffect(()=>{if(F.searchstax){const e={};r.beforeSearch&&(e.beforeSearch=r.beforeSearch),r.afterSearch&&(e.afterSearch=r.afterSearch),r.afterAutosuggest&&(e.afterAutosuggest=r.afterAutosuggest),r.beforeAutosuggest&&(e.beforeAutosuggest=r.beforeAutosuggest),F.searchstax.addSearchInputWidget("searchstax-input-container",{suggestAfterMinChars:r.suggestAfterMinChars??3,hooks:e,templates:{searchInputId:r.searchInputId??"searchstax-search-input"}})}else throw Error("Searchstax instance needs to be passed via props")},[]),d.jsx(d.Fragment,{children:d.jsx("div",{id:"searchstax-input-container",children:d.jsxs("div",{className:"searchstax-search-input-container",children:[!r.inputTemplate&&d.jsxs("div",{className:"searchstax-search-input-wrapper",children:[d.jsx("input",{type:"text",id:"searchstax-search-input",className:"searchstax-search-input",placeholder:"SEARCH FOR..."}),d.jsx("button",{className:"searchstax-spinner-icon",id:"searchstax-search-input-action-button"})]}),r.inputTemplate&&d.jsx(d.Fragment,{children:r.inputTemplate()})]})})})}function Gt(r){return D.useEffect(()=>{F.searchstax.initialize({language:r.language??"en",searchURL:r.searchURL,suggesterURL:r.suggesterURL,trackApiKey:r.trackApiKey,searchAuth:r.searchAuth,authType:r.authType??"basic"}),r.initialized(F.searchstax)},[r.initialized]),d.jsx(d.Fragment,{children:r.children})}function Jt(r){const[e,s]=D.useState(null),[n,a]=D.useState(""),[i,u]=D.useState(""),l=(h,p)=>{p.preventDefault(),p.stopPropagation(),F.searchstax.executeLinkClick(h.uniqueId)};return D.useEffect(()=>{const h={};r.afterLinkClick&&(h.afterLinkClick=r.afterLinkClick),F.searchstax.dataLayer.searchResultsObservable.subscribe(p=>{s(p)}),F.searchstax.dataLayer.searchResultsMetadataObservable.subscribe(p=>{u((p==null?void 0:p.spellingSuggestion)??"")}),F.searchstax.dataLayer.searchTermChangeObservable.subscribe(p=>{a(p)}),F.searchstax.addSearchResultsWidget("searchstax-results-container",{searchResultsContainerId:"searchstax-result-container",templates:{},hooks:h})},[]),d.jsx(d.Fragment,{children:d.jsx("div",{id:"searchstax-results-container",children:d.jsx("div",{className:"searchstax-search-results-container",children:d.jsxs("div",{id:"searchstax-result-container",children:[e&&e.length===0&&!r.noResultTemplate&&d.jsxs("div",{children:[d.jsxs("div",{className:"searchstax-no-results",children:["Showing ",d.jsx("strong",{children:"no results"})," for",d.jsxs("strong",{children:['"',n,'"']}),d.jsx("br",{}),i&&d.jsxs("span",{children:[" Did you mean",d.jsx("a",{href:"#",className:"searchstax-suggestion-term",children:i}),"?"]})]}),d.jsxs("div",{children:[d.jsx("p",{children:"Try searching for search related terms or topics. We offer a wide variety of content to help you get the information you need."}),d.jsx("p",{children:"Lost? Click on the ‘X” in the Search Box to reset your search."})]})]}),e&&e.length===0&&r.noResultTemplate&&d.jsx(d.Fragment,{children:r.noResultTemplate(n,i)}),e&&e.length&&!r.resultsTemplate&&d.jsxs("div",{className:"searchstax-search-results",children:[e!==null&&e.map(function(h){return d.jsxs("div",{className:"searchstax-search-result",children:[h.url&&d.jsx("a",{href:h.url,"data-searchstax-unique-result-id":h.uniqueId,onClick:p=>{l(h,p)},className:"searchstax-result-item-link"}),h.ribbon&&d.jsx("div",{className:"searchstax-search-result-ribbon",children:h.ribbon}),h.thumbnail&&d.jsx("img",{src:h.thumbnail,className:"searchstax-thumbnail"}),d.jsx("div",{className:"searchstax-search-result-title-container",children:d.jsx("span",{className:"searchstax-search-result-title",children:h.title})}),h.paths&&d.jsx("p",{className:"searchstax-search-result-common",children:h.paths}),h.description&&d.jsx("p",{className:"searchstax-search-result-description searchstax-search-result-common",children:h.description}),h.unmappedFields.map(function(p){return d.jsxs("div",{children:[p.isImage&&d.jsx("div",{className:"searchstax-search-result-image-container",children:d.jsx("img",{src:p.value,className:"searchstax-result-image"})}),!p.isImage&&d.jsx("div",{children:d.jsx("p",{className:"searchstax-search-result-common",children:p.value})})]},p.value)})]},h.uniqueId)}),e!==null&&e.length&&d.jsx("div",{"v-if":"searchResults && searchResults.length && hasResultSlot"})]}),e&&e.length&&r.resultsTemplate&&d.jsx(d.Fragment,{children:r.resultsTemplate(e,l)})]})})})})}exports.SearchstaxInputWidget=zt;exports.SearchstaxResultWidget=Jt;exports.SearchstaxWrapper=Gt;