@coveo/quantic 3.37.0 → 3.37.1

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.
@@ -24,7 +24,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
24
24
 
25
25
  ${t}
26
26
  `;return new ko(r)}var ko=class extends Error{constructor(e){super(e),this.name="SchemaValidationError"}},Fe=class{constructor(e){this.definition=e}validate(e={},t=""){let r={...this.default,...e},n=[];for(let o in this.definition){let i=this.definition[o].validate(r[o]);i&&n.push(`${o}: ${i}`)}if(n.length)throw gk(n,t);return r}get default(){let e={};for(let t in this.definition){let r=this.definition[t].default;r!==void 0&&(e[t]=r)}return e}},Ge=class{constructor(e={}){this.baseConfig=e}validate(e){return this.baseConfig.required&&ee(e)?"value is required.":null}get default(){return this.baseConfig.default instanceof Function?this.baseConfig.default():this.baseConfig.default}get required(){return this.baseConfig.required===!0}};function Li(e){return e===void 0}function hk(e){return e===null}function ee(e){return Li(e)||hk(e)}var de=class{constructor(e={}){De(this,"value");this.value=new Ge(e)}validate(e){let t=this.value.validate(e);return t||(yk(e)?null:"value is not a boolean.")}get default(){return this.value.default}get required(){return this.value.required}};function yk(e){return Li(e)||Fu(e)}function Fu(e){return typeof e=="boolean"}var oe=class{constructor(e={}){De(this,"value");this.config=e,this.value=new Ge(e)}validate(e){let t=this.value.validate(e);return t||(Sk(e)?e<this.config.min?`minimum value of ${this.config.min} not respected.`:e>this.config.max?`maximum value of ${this.config.max} not respected.`:null:"value is not a number.")}get default(){return this.value.default}get required(){return this.value.required}};function Sk(e){return Li(e)||Ov(e)}function Ov(e){return typeof e=="number"&&!Number.isNaN(e)}var vk=/^\d{4}(-\d\d(-\d\d(T\d\d:\d\d(:\d\d)?(\.\d+)?(([+-]\d\d:\d\d)|Z)?)?)?)?$/i,$=class{constructor(e={}){De(this,"value");De(this,"config");this.config={emptyAllowed:!0,url:!1,...e},this.value=new Ge(this.config)}validate(e){let{emptyAllowed:t,url:r,regex:n,constrainTo:o,ISODate:i}=this.config,a=this.value.validate(e);if(a)return a;if(Li(e))return null;if(!Ui(e))return"value is not a string.";if(!t&&!e.length)return"value is an empty string.";if(r)try{new URL(e)}catch{return"value is not a valid URL."}return n&&!n.test(e)?`value did not match provided regex ${n}`:o&&!o.includes(e)?`value should be one of: ${o.join(", ")}.`:i&&!(vk.test(e)&&new Date(e).toString()!=="Invalid Date")?"value is not a valid ISO8601 date string":null}get default(){return this.value.default}get required(){return this.value.required}};function Ui(e){return Object.prototype.toString.call(e)==="[object String]"}var Y=class{constructor(e={}){De(this,"config");this.config={options:{required:!1},values:{},...e}}validate(e){if(Li(e))return this.config.options.required?"value is required and is currently undefined":null;if(!_v(e))return"value is not an object";for(let[r,n]of Object.entries(this.config.values))if(n.required&&ee(e[r]))return`value does not contain ${r}`;let t="";for(let[r,n]of Object.entries(this.config.values)){let o=e[r],i=n.validate(o);i!==null&&(t+=` ${i}`)}return t===""?null:t}get default(){}get required(){return!!this.config.options.required}};function _v(e){return e!==void 0&&typeof e=="object"}var ne=class{constructor(e={}){De(this,"value");this.config=e,this.value=new Ge(this.config)}validate(e){if(!ee(e)&&!Array.isArray(e))return"value is not an array";let t=this.value.validate(e);if(t!==null)return t;if(ee(e))return null;if(this.config.max!==void 0&&e.length>this.config.max)return`value contains more than ${this.config.max}`;if(this.config.min!==void 0&&e.length<this.config.min)return`value contains less than ${this.config.min}`;if(this.config.each!==void 0){let r="";return e.forEach(n=>{this.config.each.required&&ee(n)&&(r=`value is null or undefined: ${e.join(",")}`);let o=this.validatePrimitiveValue(n,this.config.each);o!==null&&(r+=` ${o}`)}),r===""?null:r}return null}validatePrimitiveValue(e,t){return Fu(e)||Ui(e)||Ov(e)||_v(e)?t.validate(e):"value is not a primitive value"}get default(){}get required(){return this.value.required}};function Qi(e){return Array.isArray(e)}var Hs=class{constructor(e){De(this,"value");this.config=e,this.value=new Ge(e)}validate(e){let t=this.value.validate(e);return t!==null?t:Li(e)||Object.values(this.config.enum).find(n=>n===e)?null:"value is not in enum."}get default(){return this.value.default}get required(){return this.value.required}};d();c();l();u();var Tu=(e,t=5)=>e+Math.random().toString(36).substring(2,2+t);function Pu(e){return Array.isArray(e)}function ku(e){return e.trim()===""}function Nv(e,t){return[...e.reduce((r,n)=>{let o=t(n);return r.has(o)||r.set(o,n),r},new Map).values()]}function Ak(e){return btoa(encodeURI(e))}function Ou(e,t){let{[e]:r,...n}=t;return n}function Bi(e){return Ak(JSON.stringify(e))}var Ck=new Set(["1",1,"yes",!0]);function Dv(){if(typeof navigator>"u"||typeof window>"u")return!1;let e=navigator,t=window;return[e.globalPrivacyControl,e.doNotTrack,e.msDoNotTrack,t.doNotTrack].some(r=>Ck.has(r))}function qv(e){let t={};for(let[r,n]of e)t[r]=n;return t}function Mv(e,t,r){return clearTimeout(t),setTimeout(e,r)}function zs(e){if(typeof e!="object"||!e)return e;try{return JSON.parse(JSON.stringify(e))}catch{return e}}function _u(e,t,r={}){let n;return(...o)=>{let i=r.isImmediate&&!n;if(clearTimeout(n),n=setTimeout(()=>{n=void 0,r.isImmediate||e.apply(void 0,o)},t),i)return e.apply(void 0,o)}}function bk(e){if(ku(e.openingDelimiter)||ku(e.closingDelimiter))throw Error("delimiters should be a non-empty string");if(ee(e.content)||ku(e.content))return e.content;if(e.highlights.length===0)return Gi(e.content);let t=e.content.length,r="",n=0;for(let o=0;o<e.highlights.length;o++){let i=e.highlights[o],a=i.offset,p=a+i.length;if(p>t)break;r+=Gi(e.content.slice(n,a)),r+=e.openingDelimiter,r+=Gi(e.content.slice(a,p)),r+=e.closingDelimiter,n=p}return n!==t&&(r+=Gi(e.content.slice(n))),r}function xg(e,t){return e=Gi(e),e.replace(/\[(.*?)\]|\{(.*?)\}|\((.*?)\)/g,(r,n,o,i)=>n?bg(n,t.notMatchDelimiters):o?bg(o,t.exactMatchDelimiters):i?bg(i,t.correctionDelimiters):r)}function bg(e,t){return t?t.open+e+t.close:e}function Gi(e){let t={"&":"&amp;","<":"&lt;",">":"&gt;","\"":"&quot;","'":"&#x27;","`":"&#x60;"},r=`(?:${Object.keys(t).join("|")})`,n=RegExp(r),o=RegExp(r,"g");return n.test(e)?e.replace(o,i=>t[i]):e}d();c();l();u();var Yv=Er($v(),1);d();c();l();u();var ie=new Error("Failed to load reducers."),$i=class extends Error{constructor(){super(),this.name="UnauthorizedTokenError",this.message="The token being used to perform the request is unauthorized. It may be expired or invalid."}},_o=class extends Error{constructor(r,n){super();De(this,"statusCode");this.name="Disconnected",this.message=`Client could not connect to the following URL: ${r}`,this.statusCode=n??0}};d();c();l();u();function Hv(e){let t=[];for(let r in e){let n=encodeURIComponent(r),o=encodeURIComponent(e[r]);t.push(`${n}=${o}`)}return t.join("&")}function zv(e){return typeof e!="object"||!e?!1:Object.values(e).every(Wk)}function Wk(e){return typeof e=="string"||typeof e=="number"||typeof e=="boolean"}function Wv(e){return e===429}var Vr=class e{static call(t){return _asyncToGenerator(function*(){let r=Yk(t),{logger:n}=t,o=yield e.preprocessRequest(r,t);n.info(o,"Platform request");let{url:i,...a}=o,p=/*#__PURE__*/function(){var _ref=_asyncToGenerator(function*(){let f=yield v(i,a);if(Wv(f.status))throw f;return f});return function p(){return _ref.apply(this,arguments)}}();try{let f=yield(0,Yv.backOff)(p,{startingDelay:100,timeMultiple:2,maxDelay:800,numOfAttempts:4,jitter:"full",retry:function(){var _ref2=_asyncToGenerator(function*(m){let h=m&&Wv(m.status);return h&&(n.info("Platform retrying request"),yield new Promise(C=>setTimeout(C,1e3))),h});return function retry(_x2){return _ref2.apply(this,arguments)}}()});switch(f.status){case 419:case 401:throw n.info("Platform renewing token"),new $i;case 404:throw new _o(i,f.status);default:return n.info({response:f,requestInfo:o},"Platform response"),f}}catch(f){return f.message==="Failed to fetch"?new _o(i):f}})()}static preprocessRequest(t,r){return _asyncToGenerator(function*(){let{origin:n,preprocessRequest:o,logger:i,requestMetadata:a}=r,{signal:p,...f}=t,m=zs(f);try{let h=yield o(t,n,a);return{...t,...h}}catch(h){i.error(h,"Platform request preprocessing failed. Returning default request options.")}return m})()}};function Ye(e,t="prod",r="platform"){let n=t==="prod"?"":t,o=r==="platform"?"":`.${r}`;return`https://${e}${o}.org${n}.coveo.com`}function Kt(e,t="prod"){return`${Ye(e,t)}/rest/search/v2`}function Du(e,t="prod"){return`${Ye(e,t,"analytics")}/rest/organizations/${e}/events/v1`}function Yk(e){let{url:t,method:r,requestParams:n,contentType:o,accessToken:i,signal:a}=e,p=e.method==="POST"||e.method==="PUT",f=Kk(n,o);return{url:t,method:r,headers:{"Content-Type":o,Authorization:`Bearer ${i}`,...e.headers},...(p&&{body:f}),signal:a}}function Kk(e,t){return t==="application/x-www-form-urlencoded"?zv(e)?Hv(e):"":JSON.stringify(e)}d();c();l();u();var Ks=Er(qu(),1),tA=Er(Kv(),1);d();c();l();u();var Mu=Er(qu(),1),Jv=Er(Xv(),1);Mu.default.extend(Jv.default);var Zv="YYYY/MM/DD@HH:mm:ss",Xk="1401-01-01";function Hi(e,t){let r=(0,Mu.default)(e,t);return!r.isValid()&&!t?(0,Mu.default)(e,Zv):r}function Vu(e){return e.format(Zv)}function eA(e,t){let r=Hi(e,t);if(!r.isValid()){let n=". Please provide a date format string in the configuration options. See https://day.js.org/docs/en/parse/string-format for more information.",o=` with the format "${t}"`;throw new Error(`Could not parse the provided date "${e}"${t?o:n}`)}jg(r)}function jg(e){if(e.isBefore(Xk))throw new Error(`Date is before year 1401, which is unsupported by the API: ${e}`)}Ks.default.extend(tA.default);var rA=["past","now","next"],nA=["minute","hour","day","week","month","quarter","year"],Jk=e=>{let t=e==="now";return{amount:new oe({required:!t,min:1}),unit:new $({required:!t,constrainTo:nA}),period:new $({required:!0,constrainTo:rA})}};function ju(e){if(typeof e=="string"&&!Un(e))throw new Error(`The value "${e}" is not respecting the relative date format "period-amount-unit"`);let t=typeof e=="string"?Lg(e):e;new Fe(Jk(t.period)).validate(t);let r=iA(t),n=JSON.stringify(t);if(!r.isValid())throw new Error(`Date is invalid: ${n}`);jg(r)}function oA(e){let{period:t,amount:r,unit:n}=e;switch(t){case"past":case"next":return`${t}-${r}-${n}`;case"now":return t}}function iA(e){let{period:t,amount:r,unit:n}=e;switch(t){case"past":return(0,Ks.default)().subtract(r,n);case"next":return(0,Ks.default)().add(r,n);case"now":return(0,Ks.default)()}}function Xs(e){return Vu(iA(Lg(e)))}function aA(e){return e.toLocaleLowerCase().split("-")}function Un(e){let[t,r,n]=aA(e);if(t==="now")return!0;if(!rA.includes(t)||!nA.includes(n))return!1;let o=parseInt(r,10);return!(Number.isNaN(o)||o<=0)}function sA(e){return!!e&&typeof e=="object"&&"period"in e}function Lg(e){let[t,r,n]=aA(e);return t==="now"?{period:"now"}:{period:t,amount:r?parseInt(r,10):void 0,unit:n||void 0}}function cA(e){return ju(e),Lg(e)}d();c();l();u();d();c();l();u();d();c();l();u();d();c();l();u();function lA(_x3,_x4){return _lA.apply(this,arguments)}function _lA(){_lA=_asyncToGenerator(function*(e,t){let r=e.getReader(),n;for(;!(n=yield r.read()).done;)t(n.value)});return _lA.apply(this,arguments)}function dA(e){let t,r,n,o=!1;return function(a){t===void 0?(t=a,r=0,n=-1):t=eO(t,a);let p=t.length,f=0;for(;r<p;){o&&(t[r]===10&&(f=++r),o=!1);let m=-1;for(;r<p&&m===-1;++r)switch(t[r]){case 58:n===-1&&(n=r-f);break;case 13:o=!0,m=r;break;case 10:m=r;break}if(m===-1)break;e(t.subarray(f,m),n),f=r,n=-1}f===p?t=void 0:f!==0&&(t=t.subarray(f),r-=f)}}function pA(e,t,r){let n=uA(),o=new TextDecoder;return function(a,p){if(a.length===0)r?.(n),n=uA();else if(p>0){let f=o.decode(a.subarray(0,p)),m=p+(a[p+1]===32?2:1),h=o.decode(a.subarray(m));switch(f){case"data":n.data=n.data?`${n.data}
27
- ${h}`:h;break;case"event":n.event=h;break;case"id":e(n.id=h);break;case"retry":Zk(h,n,t);break}}}}function Zk(e,t,r){let n=parseInt(e,10);Number.isNaN(n)||r(t.retry=n)}function eO(e,t){let r=new Uint8Array(e.length+t.length);return r.set(e),r.set(t,e.length),r}function uA(){return{data:"",event:"",id:"",retry:void 0}}var Ug="text/event-stream",tO=1e3,fA="last-event-id";function mA(){return typeof window<"u"}function Lu(e,{signal:t,headers:r,onopen:n,onmessage:o,onclose:i,onerror:a,openWhenHidden:p,fetch:f,...m}){return new Promise((h,C)=>{let b={...r};b.accept||(b.accept=Ug);let g;function S(){g?.abort(),document.hidden||_()}!p&&mA()&&document.addEventListener("visibilitychange",S);let x=tO,w;function R(){mA()&&document.removeEventListener("visibilitychange",S),clearTimeout(w),g?.abort()}t?.addEventListener("abort",()=>{R(),h()});let P=f??v,E=n??rO;function _(){return _2.apply(this,arguments)}function _2(){_2=_asyncToGenerator(function*(){g=s.AbortController?new s.AbortController:null;try{let F=yield P(e,{...m,headers:b,signal:g?.signal});yield E(F),yield lA(F.body,dA(pA(q=>{q?b[fA]=q:delete b[fA]},q=>{x=q},o))),i?.(),R(),h()}catch(F){if(!g?.signal?.aborted)try{let q=a?.(F)??x;clearTimeout(w),w=setTimeout(_,q)}catch(q){R(),C(q)}}});return _2.apply(this,arguments)}_()})}function rO(e){let t=e.headers.get("content-type");if(!t?.startsWith(Ug))throw new Error(`Expected content-type to be ${Ug}, Actual: ${t}`)}d();c();l();u();var Qn=class{constructor(t){De(this,"_basePath");De(this,"_params",{});this._basePath=t}addParam(t,r){this._params={...this.params,[t]:r}}get basePath(){return this._basePath}get params(){return this._params}get hasParams(){return Object.entries(this._params).length}get href(){return this.hasParams?`${this.basePath}?${Object.entries(this.params).map(([t,r])=>`${t}=${encodeURIComponent(r)}`).join("&")}`:this.basePath}};var nO=(e,t,r)=>new Qn(`${e}/rest/organizations/${t}/machinelearning/streaming/${r}`).href,gA=3,oO=5e3,iO="text/event-stream",Gg=1,Qg=class extends Error{},Js=class extends Error{constructor(r){super(r.message);this.payload=r}},Bg=class{constructor(){De(this,"timeouts",new Set)}add(t){this.timeouts.add(t)}remove(t){clearTimeout(t),this.timeouts.delete(t)}isActive(t){return this.timeouts.has(t)}},Uu=class{constructor(t){De(this,"logger");this.logger=t.logger}streamGeneratedAnswer(t,r){let{url:n,organizationId:o,streamId:i,accessToken:a}=t,{write:p,abort:f,close:m,resetAnswer:h}=r,C=new Bg;if(!i){this.logger.error("No stream ID found");return}let b=0,g,S=()=>{g&&!C.isActive(g)&&(w?.abort(),h(),R())},x=()=>{C.remove(g),g=Mv(S,g,oO),C.add(g)},w=new s.AbortController,R=()=>Lu(nO(n,o,i),{method:"GET",fetch:v,headers:{Authorization:`Bearer ${a}`,accept:"*/*"},openWhenHidden:!0,signal:w?.signal,onopen(P){return _asyncToGenerator(function*(){if(P.ok&&P.headers.get("content-type")===iO)return;throw P.status>=400&&P.status<500&&P.status!==429?new Js({message:"Error opening stream",code:P.status}):new Qg})()},onmessage:P=>{if(w?.signal.aborted)return;let E=JSON.parse(P.data);if(E.finishReason==="ERROR"){C.remove(g),w?.abort(),f({message:E.errorMessage,code:E.statusCode});return}p(E),b=0,E.finishReason==="COMPLETED"?(C.remove(g),m()):x()},onerror:P=>{if(!w?.signal.aborted){if(C.remove(g),P instanceof Js)throw w?.abort(),f(P),P;if(++b>gA){this.logger.info("Maximum retry exceeded.");let E={message:"Failed to complete stream.",code:Gg};throw w?.abort(),f(E),new Js(E)}this.logger.info(`Retrying...(${b}/${gA})`),h()}}});return R(),w}};d();c();l();u();var Qu=e=>e;d();c();l();u();d();c();l();u();d();c();l();u();function Zs(e){let{url:t,accessToken:r,organizationId:n,authentication:o,...i}=e;return i}var $g=e=>{let{response:t}=e;return t.body?aO(e):sO(t)},aO=e=>uO(e)?lO(e):cO(e)?e.body:{message:"unknown",statusCode:0,type:"unknown"},sO=e=>{let t=JSON.parse(JSON.stringify(e,Object.getOwnPropertyNames(e)));return{...t,message:`Client side error: ${t.message||""}`,statusCode:400,type:"ClientError"}};function cO(e){return e.body.statusCode!==void 0}function uO(e){return e.body.exception!==void 0}var lO=e=>({message:e.body.exception.code,statusCode:e.response.status,type:e.body.exception.code});d();c();l();u();function hA(e){return((e.headers.get("content-type")||"").split(";").find(n=>n.indexOf("charset=")!==-1)||"").split("=")[1]||"UTF-8"}d();c();l();u();var Hg=(e,t,r,n)=>{let o=new Qn(`${e.url}${n}`);return o.addParam("organizationId",e.organizationId),e.authentication&&o.addParam("authentication",e.authentication),{accessToken:e.accessToken,method:t,contentType:r,url:o.href,origin:"searchApiFetch"}};var yA=(e,t)=>{let r=new Qn(`${e.url}${t}`);return r.addParam("access_token",e.accessToken),r.addParam("organizationId",e.organizationId),r.addParam("uniqueId",e.uniqueId),e.authentication&&r.addParam("authentication",e.authentication),e.q!==void 0&&r.addParam("q",e.q),e.enableNavigation!==void 0&&r.addParam("enableNavigation",`${e.enableNavigation}`),e.requestedOutputSize!==void 0&&r.addParam("requestedOutputSize",`${e.requestedOutputSize}`),r.href},zg=/*#__PURE__*/function(){var _ref3=_asyncToGenerator(function*(e,t){let r=yield Vr.call({...Hg(e,"POST","application/x-www-form-urlencoded","/html"),requestParams:Zs(e),requestMetadata:{method:"html"},...t});if(r instanceof Error)throw r;let n=hA(r),o=yield r.arrayBuffer(),a=new TextDecoder(n).decode(o);return dO(a)?{success:a}:{error:$g({response:r,body:a})}});return function zg(_x5,_x6){return _ref3.apply(this,arguments)}}();function dO(e){return typeof e=="string"}d();c();l();u();d();c();l();u();function zi(){return{answerSnippet:"",documentId:{contentIdKey:"",contentIdValue:""},question:"",relatedQuestions:[],score:0}}function At(){return{response:{results:[],searchUid:"",totalCountFiltered:0,facets:[],generateAutomaticFacets:{facets:[]},queryCorrections:[],triggers:[],questionAnswer:zi(),pipeline:"",splitTestRun:"",termsToHighlight:{},phrasesToHighlight:{},extendedResults:{}},duration:0,queryExecuted:"",error:null,automaticallyCorrected:!1,isLoading:!1,results:[],searchResponseId:"",requestId:"",questionAnswer:zi(),extendedResults:{},searchAction:void 0}}d();c();l();u();d();c();l();u();function pO(e){return{statusCode:e.statusCode,type:e.name,message:e.message}}function fO(e){return{statusCode:e.code,type:e.name,message:e.message,ignored:!0}}function Wi(e,t){if(t&&e.name==="AbortError")return{error:fO(e)};if(e instanceof _o)return{error:pO(e)};throw e}var Bn=e=>e.success!==void 0,$e=e=>e.error!==void 0;function SA(e){return e.results!==void 0}function vA(e){let t=zi();return ee(e.questionAnswer)?(e.questionAnswer=t,e):(e.questionAnswer={...t,...e.questionAnswer},e)}d();c();l();u();d();c();l();u();var Wg=(e,t)=>`${e.url}/rest/organizations/${e.organizationId}/insight/v1/configs/${e.insightId}${t??""}`,mO=e=>`${e.url}/rest/organizations/${e.organizationId}/machinelearning/user/actions`,ec=(e,t,r,n)=>{gO(e);let o=Wg(e,n);return{accessToken:e.accessToken,method:t,contentType:r,url:o,origin:"insightApiFetch"}},AA=(e,t,r)=>{hO(e);let n=mO(e);return{accessToken:e.accessToken,method:t,contentType:r,url:n,origin:"insightApiFetch"}},Yg=e=>{let{insightId:t,...r}=Zs(e);return r},CA=e=>{if(!e.url)throw new Error("The 'url' attribute must contain a valid platform URL.");if(!e.organizationId)throw new Error("The 'organizationId' attribute must contain a valid organization ID.");if(!e.accessToken)throw new Error("The 'accessToken' attribute must contain a valid platform access token.")},gO=e=>{if(CA(e),!e.insightId)throw new Error("The 'insightId' attribute must contain a valid Insight Panel configuration ID.")},hO=e=>{if(CA(e),!e.userId)throw new Error("The 'userId' attribute must contain a valid user ID.")};var bA=e=>({...ec(e,"GET","application/json","/interface"),requestParams:{}});d();c();l();u();var xA=e=>({...ec(e,"POST","application/json","/search"),requestParams:Yg(e)}),wA=e=>({...ec(e,"POST","application/json","/querysuggest"),requestParams:Yg(e)});d();c();l();u();var RA=e=>({...AA(e,"POST","application/json"),requestParams:{objectId:e.userId}});var Bu=class{constructor(t){this.options=t}getInterface(t){var _this=this;return _asyncToGenerator(function*(){let r=yield Vr.call({...bA(t),..._this.options});if(r instanceof Error)return Wi(r);let n=yield r.json();return r.ok?{success:n}:{error:n}})()}query(t,r){var _this2=this;return _asyncToGenerator(function*(){let n=yield Vr.call({...xA(t),requestMetadata:{method:"search",origin:r?.origin},..._this2.options});if(n instanceof Error)return Wi(n);let o=yield n.json();return SA(o)&&(o=vA(o)),n.ok?{success:o}:{error:o}})()}querySuggest(t){var _this3=this;return _asyncToGenerator(function*(){let r=yield Vr.call({...wA(t),..._this3.options});if(r instanceof Error)return Wi(r);let n=yield r.json();return n.completions?{success:n}:{error:n}})()}userActions(t){var _this4=this;return _asyncToGenerator(function*(){let r=yield Vr.call({...RA(t),..._this4.options});if(r instanceof Error)return Wi(r);let n=yield r.json();return r.ok?{success:n}:{error:n}})()}html(t){var _this5=this;return _asyncToGenerator(function*(){return zg(t,{..._this5.options})})()}};d();c();l();u();d();c();l();u();var z=new $({required:!0,emptyAllowed:!1}),ze=new $({required:!1,emptyAllowed:!1}),Ke=new $({required:!0,emptyAllowed:!0}),P3=new $({required:!1,emptyAllowed:!0}),Gu=new ne({each:z,required:!0}),IA=new $({required:!1,emptyAllowed:!1,regex:/^\d+\.\d+\.\d+$/}),EA=new $({required:!1,emptyAllowed:!1,regex:/^[a-zA-Z0-9_\-.]{1,100}$/}),k3=new $({required:!0,emptyAllowed:!1,regex:/^[a-zA-Z0-9_\-.]{1,100}$/}),Fr=({message:e,name:t,stack:r})=>({message:e,name:t,stack:r}),fr=(e,t)=>{if("required"in t)return{payload:new Fe({value:t}).validate({value:e}).value};let o=new Y({options:{required:!0},values:t}).validate(e);if(o)throw new ko(o);return{payload:e}},O=(e,t)=>{try{return fr(e,t)}catch(r){return{payload:e,error:Fr(r)}}},mr=(e,t,r,n)=>{let o=`Check the initialState of ${n}`;return FA(e,t,r,o,"Controller initialization error")},ht=(e,t,r,n)=>{let o=`Check the options of ${n}`;return FA(e,t,r,o,"Controller initialization error")},FA=(e,t,r,n,o)=>{try{return t.validate(r,n)}catch(i){throw e.logger.error(i,o),i}};d();c();l();u();d();c();l();u();d();c();l();u();function Et(e){return`Minified Redux error #${e}; visit https://redux.js.org/Errors?code=${e} for the full message or use the non-minified dev environment for full errors. `}var yO=typeof Symbol=="function"&&Symbol.observable||"@@observable",TA=yO,Kg=()=>Math.random().toString(36).substring(7).split("").join("."),SO={INIT:`@@redux/INIT${Kg()}`,REPLACE:`@@redux/REPLACE${Kg()}`,PROBE_UNKNOWN_ACTION:()=>`@@redux/PROBE_UNKNOWN_ACTION${Kg()}`},$u=SO;function jr(e){if(typeof e!="object"||e===null)return!1;let t=e;for(;Object.getPrototypeOf(t)!==null;)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t||Object.getPrototypeOf(e)===null}function Xg(e,t,r){if(typeof e!="function")throw new Error(Et(2));if(typeof t=="function"&&typeof r=="function"||typeof r=="function"&&typeof arguments[3]=="function")throw new Error(Et(0));if(typeof t=="function"&&typeof r>"u"&&(r=t,t=void 0),typeof r<"u"){if(typeof r!="function")throw new Error(Et(1));return r(Xg)(e,t)}let n=e,o=t,i=new Map,a=i,p=0,f=!1;function m(){a===i&&(a=new Map,i.forEach((w,R)=>{a.set(R,w)}))}function h(){if(f)throw new Error(Et(3));return o}function C(w){if(typeof w!="function")throw new Error(Et(4));if(f)throw new Error(Et(5));let R=!0;m();let P=p++;return a.set(P,w),function(){if(R){if(f)throw new Error(Et(6));R=!1,m(),a.delete(P),i=null}}}function b(w){if(!jr(w))throw new Error(Et(7));if(typeof w.type>"u")throw new Error(Et(8));if(typeof w.type!="string")throw new Error(Et(17));if(f)throw new Error(Et(9));try{f=!0,o=n(o,w)}finally{f=!1}return(i=a).forEach(P=>{P()}),w}function g(w){if(typeof w!="function")throw new Error(Et(10));n=w,b({type:$u.REPLACE})}function S(){let w=C;return{subscribe(R){if(typeof R!="object"||R===null)throw new Error(Et(11));function P(){let _=R;_.next&&_.next(h())}return P(),{unsubscribe:w(P)}},[TA](){return this}}}return b({type:$u.INIT}),{dispatch:b,subscribe:C,getState:h,replaceReducer:g,[TA]:S}}function vO(e){Object.keys(e).forEach(t=>{let r=e[t];if(typeof r(void 0,{type:$u.INIT})>"u")throw new Error(Et(12));if(typeof r(void 0,{type:$u.PROBE_UNKNOWN_ACTION()})>"u")throw new Error(Et(13))})}function Yi(e){let t=Object.keys(e),r={};for(let a=0;a<t.length;a++){let p=t[a];typeof e[p]=="function"&&(r[p]=e[p])}let n=Object.keys(r),o,i;try{vO(r)}catch(a){i=a}return function(p={},f){if(i)throw i;let m=!1,h={};for(let C=0;C<n.length;C++){let b=n[C],g=r[b],S=p[b],x=g(S,f);if(typeof x>"u"){let w=f&&f.type;throw new Error(Et(14))}h[b]=x,m=m||x!==S}return m=m||n.length!==Object.keys(p).length,m?h:p}}function tc(...e){return e.length===0?t=>t:e.length===1?e[0]:e.reduce((t,r)=>(...n)=>t(r(...n)))}function PA(...e){return t=>(r,n)=>{let o=t(r,n),i=()=>{throw new Error(Et(15))},a={getState:o.getState,dispatch:(f,...m)=>i(f,...m)},p=e.map(f=>f(a));return i=tc(...p)(o.dispatch),{...o,dispatch:i}}}function rc(e){return jr(e)&&"type"in e&&typeof e.type=="string"}d();c();l();u();var ah=Symbol.for("immer-nothing"),nc=Symbol.for("immer-draftable"),Ct=Symbol.for("immer-state");function Ft(e,...t){throw new Error(`[Immer] minified error nr: ${e}. Full error at: https://bit.ly/3cXEKWf`)}var sr=Object,Do=sr.getPrototypeOf,ic="constructor",lc="prototype",eh="configurable",Yu="enumerable",zu="writable",ac="value",Gt=e=>!!e&&!!e[Ct];function $t(e){return e?VA(e)||pc(e)||!!e[nc]||!!e[ic]?.[nc]||fc(e)||mc(e):!1}var AO=sr[lc][ic].toString(),kA=new WeakMap;function VA(e){if(!e||!Ki(e))return!1;let t=Do(e);if(t===null||t===sr[lc])return!0;let r=sr.hasOwnProperty.call(t,ic)&&t[ic];if(r===Object)return!0;if(!No(r))return!1;let n=kA.get(r);return n===void 0&&(n=Function.toString.call(r),kA.set(r,n)),n===AO}function jA(e){return Gt(e)||Ft(15,e),e[Ct].base_}function dc(e,t,r=!0){qo(e)===0?(r?Reflect.ownKeys(e):sr.keys(e)).forEach(o=>{t(o,e[o],e)}):e.forEach((n,o)=>t(o,n,e))}function qo(e){let t=e[Ct];return t?t.type_:pc(e)?1:fc(e)?2:mc(e)?3:0}var oc=(e,t,r=qo(e))=>r===2?e.has(t):sr[lc].hasOwnProperty.call(e,t),wn=(e,t,r=qo(e))=>r===2?e.get(t):e[t],Ku=(e,t,r,n=qo(e))=>{n===2?e.set(t,r):n===3?e.add(r):e[t]=r};function CO(e,t){return e===t?e!==0||1/e===1/t:e!==e&&t!==t}var pc=Array.isArray,fc=e=>e instanceof Map,mc=e=>e instanceof Set,Ki=e=>typeof e=="object",No=e=>typeof e=="function",Jg=e=>typeof e=="boolean";function bO(e){let t=+e;return Number.isInteger(t)&&String(t)===e}var xO=e=>Ki(e)?e?.[Ct]:null,Rn=e=>e.copy_||e.base_;var sh=e=>e.modified_?e.copy_:e.base_;function th(e,t){if(fc(e))return new Map(e);if(mc(e))return new Set(e);if(pc(e))return Array[lc].slice.call(e);let r=VA(e);if(t===!0||t==="class_only"&&!r){let n=sr.getOwnPropertyDescriptors(e);delete n[Ct];let o=Reflect.ownKeys(n);for(let i=0;i<o.length;i++){let a=o[i],p=n[a];p[zu]===!1&&(p[zu]=!0,p[eh]=!0),(p.get||p.set)&&(n[a]={[eh]:!0,[zu]:!0,[Yu]:p[Yu],[ac]:e[a]})}return sr.create(Do(e),n)}else{let n=Do(e);if(n!==null&&r)return{...e};let o=sr.create(n);return sr.assign(o,e)}}function ch(e,t=!1){return rl(e)||Gt(e)||!$t(e)||(qo(e)>1&&sr.defineProperties(e,{set:Hu,add:Hu,clear:Hu,delete:Hu}),sr.freeze(e),t&&dc(e,(r,n)=>{ch(n,!0)},!1)),e}function wO(){Ft(2)}var Hu={[ac]:wO};function rl(e){return e===null||!Ki(e)?!0:sr.isFrozen(e)}var Xu="MapSet",Ju="Patches",OA="ArrayMethods",Zu={};function Mo(e){let t=Zu[e];return t||Ft(0,e),t}var _A=e=>!!Zu[e];function RO(e,t){Zu[e]||(Zu[e]=t)}var sc,LA=()=>sc,IO=(e,t)=>({drafts_:[],parent_:e,immer_:t,canAutoFreeze_:!0,unfinalizedDrafts_:0,handledSet_:new Set,processedForPatches_:new Set,mapSetPlugin_:_A(Xu)?Mo(Xu):void 0,arrayMethodsPlugin_:_A(OA)?Mo(OA):void 0});function NA(e,t){t&&(e.patchPlugin_=Mo(Ju),e.patches_=[],e.inversePatches_=[],e.patchListener_=t)}function rh(e){nh(e),e.drafts_.forEach(EO),e.drafts_=null}function nh(e){e===sc&&(sc=e.parent_)}var DA=e=>sc=IO(sc,e);function EO(e){let t=e[Ct];t.type_===0||t.type_===1?t.revoke_():t.revoked_=!0}function qA(e,t){t.unfinalizedDrafts_=t.drafts_.length;let r=t.drafts_[0];if(e!==void 0&&e!==r){r[Ct].modified_&&(rh(t),Ft(4)),$t(e)&&(e=MA(t,e));let{patchPlugin_:o}=t;o&&o.generateReplacementPatches_(r[Ct].base_,e,t)}else e=MA(t,r);return FO(t,e,!0),rh(t),t.patches_&&t.patchListener_(t.patches_,t.inversePatches_),e!==ah?e:void 0}function MA(e,t){if(rl(t))return t;let r=t[Ct];if(!r)return el(t,e.handledSet_,e);if(!nl(r,e))return t;if(!r.modified_)return r.base_;if(!r.finalized_){let{callbacks_:n}=r;if(n)for(;n.length>0;)n.pop()(e);BA(r,e)}return r.copy_}function FO(e,t,r=!1){!e.parent_&&e.immer_.autoFreeze_&&e.canAutoFreeze_&&ch(t,r)}function UA(e){e.finalized_=!0,e.scope_.unfinalizedDrafts_--}var nl=(e,t)=>e.scope_===t,TO=[];function QA(e,t,r,n){let o=Rn(e),i=e.type_;if(n!==void 0&&wn(o,n,i)===t){Ku(o,n,r,i);return}if(!e.draftLocations_){let p=e.draftLocations_=new Map;dc(o,(f,m)=>{if(Gt(m)){let h=p.get(m)||[];h.push(f),p.set(m,h)}})}let a=e.draftLocations_.get(t)??TO;for(let p of a)Ku(o,p,r,i)}function PO(e,t,r){e.callbacks_.push(function(o){let i=t;if(!i||!nl(i,o))return;o.mapSetPlugin_?.fixSetContents(i);let a=sh(i);QA(e,i.draft_??i,a,r),BA(i,o)})}function BA(e,t){if(e.modified_&&!e.finalized_&&(e.type_===3||e.type_===1&&e.allIndicesReassigned_||(e.assigned_?.size??0)>0)){let{patchPlugin_:n}=t;if(n){let o=n.getPath(e);o&&n.generatePatches_(e,o,t)}UA(e)}}function kO(e,t,r){let{scope_:n}=e;if(Gt(r)){let o=r[Ct];nl(o,n)&&o.callbacks_.push(function(){Wu(e);let a=sh(o);QA(e,r,a,t)})}else $t(r)&&e.callbacks_.push(function(){let i=Rn(e);e.type_===3?i.has(r)&&el(r,n.handledSet_,n):wn(i,t,e.type_)===r&&n.drafts_.length>1&&(e.assigned_.get(t)??!1)===!0&&e.copy_&&el(wn(e.copy_,t,e.type_),n.handledSet_,n)})}function el(e,t,r){return!r.immer_.autoFreeze_&&r.unfinalizedDrafts_<1||Gt(e)||t.has(e)||!$t(e)||rl(e)||(t.add(e),dc(e,(n,o)=>{if(Gt(o)){let i=o[Ct];if(nl(i,r)){let a=sh(i);Ku(e,n,a,e.type_),UA(i)}}else $t(o)&&el(o,t,r)})),e}function OO(e,t){let r=pc(e),n={type_:r?1:0,scope_:t?t.scope_:LA(),modified_:!1,finalized_:!1,assigned_:void 0,parent_:t,base_:e,draft_:null,copy_:null,revoke_:null,isManual_:!1,callbacks_:void 0},o=n,i=tl;r&&(o=[n],i=cc);let{revoke:a,proxy:p}=Proxy.revocable(o,i);return n.draft_=p,n.revoke_=a,[p,n]}var tl={get(e,t){if(t===Ct)return e;let r=e.scope_.arrayMethodsPlugin_,n=e.type_===1&&typeof t=="string";if(n&&r?.isArrayOperationMethod(t))return r.createMethodInterceptor(e,t);let o=Rn(e);if(!oc(o,t,e.type_))return _O(e,o,t);let i=o[t];if(e.finalized_||!$t(i)||n&&e.operationMethod&&r?.isMutatingArrayMethod(e.operationMethod)&&bO(t))return i;if(i===Zg(e.base_,t)){Wu(e);let a=e.type_===1?+t:t,p=ih(e.scope_,i,e,a);return e.copy_[a]=p}return i},has(e,t){return t in Rn(e)},ownKeys(e){return Reflect.ownKeys(Rn(e))},set(e,t,r){let n=GA(Rn(e),t);if(n?.set)return n.set.call(e.draft_,r),!0;if(!e.modified_){let o=Zg(Rn(e),t),i=o?.[Ct];if(i&&i.base_===r)return e.copy_[t]=r,e.assigned_.set(t,!1),!0;if(CO(r,o)&&(r!==void 0||oc(e.base_,t,e.type_)))return!0;Wu(e),oh(e)}return e.copy_[t]===r&&(r!==void 0||t in e.copy_)||Number.isNaN(r)&&Number.isNaN(e.copy_[t])||(e.copy_[t]=r,e.assigned_.set(t,!0),kO(e,t,r)),!0},deleteProperty(e,t){return Wu(e),Zg(e.base_,t)!==void 0||t in e.base_?(e.assigned_.set(t,!1),oh(e)):e.assigned_.delete(t),e.copy_&&delete e.copy_[t],!0},getOwnPropertyDescriptor(e,t){let r=Rn(e),n=Reflect.getOwnPropertyDescriptor(r,t);return n&&{[zu]:!0,[eh]:e.type_!==1||t!=="length",[Yu]:n[Yu],[ac]:r[t]}},defineProperty(){Ft(11)},getPrototypeOf(e){return Do(e.base_)},setPrototypeOf(){Ft(12)}},cc={};for(let e in tl){let t=tl[e];cc[e]=function(){let r=arguments;return r[0]=r[0][0],t.apply(this,r)}}cc.deleteProperty=function(e,t){return cc.set.call(this,e,t,void 0)};cc.set=function(e,t,r){return tl.set.call(this,e[0],t,r,e[0])};function Zg(e,t){let r=e[Ct];return(r?Rn(r):e)[t]}function _O(e,t,r){let n=GA(t,r);return n?ac in n?n[ac]:n.get?.call(e.draft_):void 0}function GA(e,t){if(!(t in e))return;let r=Do(e);for(;r;){let n=Object.getOwnPropertyDescriptor(r,t);if(n)return n;r=Do(r)}}function oh(e){e.modified_||(e.modified_=!0,e.parent_&&oh(e.parent_))}function Wu(e){e.copy_||(e.assigned_=new Map,e.copy_=th(e.base_,e.scope_.immer_.useStrictShallowCopy_))}var NO=class{constructor(e){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.useStrictIteration_=!1,this.produce=(t,r,n)=>{if(No(t)&&!No(r)){let i=r;r=t;let a=this;return function(f=i,...m){return a.produce(f,h=>r.call(this,h,...m))}}No(r)||Ft(6),n!==void 0&&!No(n)&&Ft(7);let o;if($t(t)){let i=DA(this),a=ih(i,t,void 0),p=!0;try{o=r(a),p=!1}finally{p?rh(i):nh(i)}return NA(i,n),qA(o,i)}else if(!t||!Ki(t)){if(o=r(t),o===void 0&&(o=t),o===ah&&(o=void 0),this.autoFreeze_&&ch(o,!0),n){let i=[],a=[];Mo(Ju).generateReplacementPatches_(t,o,{patches_:i,inversePatches_:a}),n(i,a)}return o}else Ft(1,t)},this.produceWithPatches=(t,r)=>{if(No(t))return(a,...p)=>this.produceWithPatches(a,f=>t(f,...p));let n,o;return[this.produce(t,r,(a,p)=>{n=a,o=p}),n,o]},Jg(e?.autoFreeze)&&this.setAutoFreeze(e.autoFreeze),Jg(e?.useStrictShallowCopy)&&this.setUseStrictShallowCopy(e.useStrictShallowCopy),Jg(e?.useStrictIteration)&&this.setUseStrictIteration(e.useStrictIteration)}createDraft(e){$t(e)||Ft(8),Gt(e)&&(e=ol(e));let t=DA(this),r=ih(t,e,void 0);return r[Ct].isManual_=!0,nh(t),r}finishDraft(e,t){let r=e&&e[Ct];(!r||!r.isManual_)&&Ft(9);let{scope_:n}=r;return NA(n,t),qA(void 0,n)}setAutoFreeze(e){this.autoFreeze_=e}setUseStrictShallowCopy(e){this.useStrictShallowCopy_=e}setUseStrictIteration(e){this.useStrictIteration_=e}shouldUseStrictIteration(){return this.useStrictIteration_}applyPatches(e,t){let r;for(r=t.length-1;r>=0;r--){let o=t[r];if(o.path.length===0&&o.op==="replace"){e=o.value;break}}r>-1&&(t=t.slice(r+1));let n=Mo(Ju).applyPatches_;return Gt(e)?n(e,t):this.produce(e,o=>n(o,t))}};function ih(e,t,r,n){let[o,i]=fc(t)?Mo(Xu).proxyMap_(t,r):mc(t)?Mo(Xu).proxySet_(t,r):OO(t,r);return(r?.scope_??LA()).drafts_.push(o),i.callbacks_=r?.callbacks_??[],i.key_=n,r&&n!==void 0?PO(r,i,n):i.callbacks_.push(function(f){f.mapSetPlugin_?.fixSetContents(i);let{patchPlugin_:m}=f;i.modified_&&m&&m.generatePatches_(i,[],f)}),o}function ol(e){return Gt(e)||Ft(10,e),$A(e)}function $A(e){if(!$t(e)||rl(e))return e;let t=e[Ct],r,n=!0;if(t){if(!t.modified_)return t.base_;t.finalized_=!0,r=th(e,t.scope_.immer_.useStrictShallowCopy_),n=t.scope_.immer_.shouldUseStrictIteration()}else r=th(e,!0);return dc(r,(o,i)=>{Ku(r,o,$A(i))},n),t&&(t.finalized_=!1),r}function HA(){function t(S,x=[]){if(S.key_!==void 0){let w=S.parent_.copy_??S.parent_.base_,R=xO(wn(w,S.key_)),P=wn(w,S.key_);if(P===void 0||P!==S.draft_&&P!==S.base_&&P!==S.copy_||R!=null&&R.base_!==S.base_)return null;let E=S.parent_.type_===3,_;if(E){let F=S.parent_;_=Array.from(F.drafts_.keys()).indexOf(S.key_)}else _=S.key_;if(!(E&&w.size>_||oc(w,_)))return null;x.push(_)}if(S.parent_)return t(S.parent_,x);x.reverse();try{r(S.copy_,x)}catch{return null}return x}function r(S,x){let w=S;for(let R=0;R<x.length-1;R++){let P=x[R];if(w=wn(w,P),!Ki(w)||w===null)throw new Error(`Cannot resolve path at '${x.join("/")}'`)}return w}let n="replace",o="add",i="remove";function a(S,x,w){if(S.scope_.processedForPatches_.has(S))return;S.scope_.processedForPatches_.add(S);let{patches_:R,inversePatches_:P}=w;switch(S.type_){case 0:case 2:return f(S,x,R,P);case 1:return p(S,x,R,P);case 3:return m(S,x,R,P)}}function p(S,x,w,R){let{base_:P,assigned_:E}=S,_=S.copy_;_.length<P.length&&([P,_]=[_,P],[w,R]=[R,w]);let F=S.allIndicesReassigned_===!0;for(let q=0;q<P.length;q++){let G=_[q],Q=P[q];if((F||E?.get(q.toString()))&&G!==Q){let B=G?.[Ct];if(B&&B.modified_)continue;let L=x.concat([q]);w.push({op:n,path:L,value:g(G)}),R.push({op:n,path:L,value:g(Q)})}}for(let q=P.length;q<_.length;q++){let G=x.concat([q]);w.push({op:o,path:G,value:g(_[q])})}for(let q=_.length-1;P.length<=q;--q){let G=x.concat([q]);R.push({op:i,path:G})}}function f(S,x,w,R){let{base_:P,copy_:E,type_:_}=S;dc(S.assigned_,(F,q)=>{let G=wn(P,F,_),Q=wn(E,F,_),j=q?oc(P,F)?n:o:i;if(G===Q&&j===n)return;let B=x.concat(F);w.push(j===i?{op:j,path:B}:{op:j,path:B,value:g(Q)}),R.push(j===o?{op:i,path:B}:j===i?{op:o,path:B,value:g(G)}:{op:n,path:B,value:g(G)})})}function m(S,x,w,R){let{base_:P,copy_:E}=S,_=0;P.forEach(F=>{if(!E.has(F)){let q=x.concat([_]);w.push({op:i,path:q,value:F}),R.unshift({op:o,path:q,value:F})}_++}),_=0,E.forEach(F=>{if(!P.has(F)){let q=x.concat([_]);w.push({op:o,path:q,value:F}),R.unshift({op:i,path:q,value:F})}_++})}function h(S,x,w){let{patches_:R,inversePatches_:P}=w;R.push({op:n,path:[],value:x===ah?void 0:x}),P.push({op:n,path:[],value:S})}function C(S,x){return x.forEach(w=>{let{path:R,op:P}=w,E=S;for(let G=0;G<R.length-1;G++){let Q=qo(E),j=R[G];typeof j!="string"&&typeof j!="number"&&(j=""+j),(Q===0||Q===1)&&(j==="__proto__"||j===ic)&&Ft(19),No(E)&&j===lc&&Ft(19),E=wn(E,j),Ki(E)||Ft(18,R.join("/"))}let _=qo(E),F=b(w.value),q=R[R.length-1];switch(P){case n:switch(_){case 2:return E.set(q,F);case 3:Ft(16);default:return E[q]=F}case o:switch(_){case 1:return q==="-"?E.push(F):E.splice(q,0,F);case 2:return E.set(q,F);case 3:return E.add(F);default:return E[q]=F}case i:switch(_){case 1:return E.splice(q,1);case 2:return E.delete(q);case 3:return E.delete(w.value);default:return delete E[q]}default:Ft(17,P)}}),S}function b(S){if(!$t(S))return S;if(pc(S))return S.map(b);if(fc(S))return new Map(Array.from(S.entries()).map(([w,R])=>[w,b(R)]));if(mc(S))return new Set(Array.from(S).map(b));let x=Object.create(Do(S));for(let w in S)x[w]=b(S[w]);return oc(S,nc)&&(x[nc]=S[nc]),x}function g(S){return Gt(S)?b(S):S}RO(Ju,{applyPatches_:C,generatePatches_:a,generateReplacementPatches_:h,getPath:t})}var uc=new NO,Vo=uc.produce,uh=uc.produceWithPatches.bind(uc);var lh=uc.applyPatches.bind(uc);d();c();l();u();function DO(e,t=`expected a function, instead received ${typeof e}`){if(typeof e!="function")throw new TypeError(t)}function qO(e,t=`expected an object, instead received ${typeof e}`){if(typeof e!="object")throw new TypeError(t)}function MO(e,t="expected all items to be functions, instead received the following types: "){if(!e.every(r=>typeof r=="function")){let r=e.map(n=>typeof n=="function"?`function ${n.name||"unnamed"}()`:typeof n).join(", ");throw new TypeError(`${t}[${r}]`)}}var zA=e=>Array.isArray(e)?e:[e];function VO(e){let t=Array.isArray(e[0])?e[0]:e;return MO(t,"createSelector expects all input-selectors to be functions, but received the following types: "),t}function jO(e,t){let r=[],{length:n}=e;for(let o=0;o<n;o++)r.push(e[o].apply(null,t));return r}var W3=Object.getPrototypeOf({});var LO=class{constructor(e){this.value=e}deref(){return this.value}},UO=typeof WeakRef<"u"?WeakRef:LO,QO=0,WA=1;function il(){return{s:QO,v:void 0,o:null,p:null}}function gc(e,t={}){let r=il(),{resultEqualityCheck:n}=t,o,i=0;function a(){let p=r,{length:f}=arguments;for(let C=0,b=f;C<b;C++){let g=arguments[C];if(typeof g=="function"||typeof g=="object"&&g!==null){let S=p.o;S===null&&(p.o=S=new WeakMap);let x=S.get(g);x===void 0?(p=il(),S.set(g,p)):p=x}else{let S=p.p;S===null&&(p.p=S=new Map);let x=S.get(g);x===void 0?(p=il(),S.set(g,p)):p=x}}let m=p,h;if(p.s===WA)h=p.v;else if(h=e.apply(null,arguments),i++,n){let C=o?.deref?.()??o;C!=null&&n(C,h)&&(h=C,i!==0&&i--),o=typeof h=="object"&&h!==null||typeof h=="function"?new UO(h):h}return m.s=WA,m.v=h,h}return a.clearCache=()=>{r=il(),a.resetResultsCount()},a.resultsCount=()=>i,a.resetResultsCount=()=>{i=0},a}function BO(e,...t){let r=typeof e=="function"?{memoize:e,memoizeOptions:t}:e,n=(...o)=>{let i=0,a=0,p,f={},m=o.pop();typeof m=="object"&&(f=m,m=o.pop()),DO(m,`createSelector expects an output function after the inputs, but received: [${typeof m}]`);let h={...r,...f},{memoize:C,memoizeOptions:b=[],argsMemoize:g=gc,argsMemoizeOptions:S=[],devModeChecks:x={}}=h,w=zA(b),R=zA(S),P=VO(o),E=C(function(){return i++,m.apply(null,arguments)},...w),_=!0,F=g(function(){a++;let G=jO(P,arguments);return p=E.apply(null,G),p},...R);return Object.assign(F,{resultFunc:m,memoizedResultFunc:E,dependencies:P,dependencyRecomputations:()=>a,resetDependencyRecomputations:()=>{a=0},lastResult:()=>p,recomputations:()=>i,resetRecomputations:()=>{i=0},memoize:C,argsMemoize:g})};return Object.assign(n,{withTypes:()=>n}),n}var ct=BO(gc),GO=Object.assign((e,t=ct)=>{qO(e,`createStructuredSelector expects first argument to be an object where each property is a selector, instead received a ${typeof e}`);let r=Object.keys(e),n=r.map(i=>e[i]);return t(n,(...i)=>i.reduce((a,p,f)=>(a[r[f]]=p,a),{}))},{withTypes:()=>GO});d();c();l();u();function YA(e){return({dispatch:r,getState:n})=>o=>i=>typeof i=="function"?i(r,n,e):o(i)}var KA=YA(),XA=YA;var $O=typeof window<"u"&&window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__?window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__:function(){if(arguments.length!==0)return typeof arguments[0]=="object"?tc:tc.apply(null,arguments)},pz=typeof window<"u"&&window.__REDUX_DEVTOOLS_EXTENSION__?window.__REDUX_DEVTOOLS_EXTENSION__:function(){return function(e){return e}},HO=e=>e&&typeof e.match=="function";function T(e,t){function r(...n){if(t){let o=t(...n);if(!o)throw new Error(Ht(0));return{type:e,payload:o.payload,...("meta"in o&&{meta:o.meta}),...("error"in o&&{error:o.error})}}return{type:e,payload:n[0]}}return r.toString=()=>`${e}`,r.type=e,r.match=n=>rc(n)&&n.type===e,r}var iC=class hc extends Array{constructor(...t){super(...t),Object.setPrototypeOf(this,hc.prototype)}static get[Symbol.species](){return hc}concat(...t){return super.concat.apply(this,t)}prepend(...t){return t.length===1&&Array.isArray(t[0])?new hc(...t[0].concat(this)):new hc(...t.concat(this))}};function JA(e){return $t(e)?Vo(e,()=>{}):e}function al(e,t,r){return e.has(t)?e.get(t):e.set(t,r(t)).get(t)}function zO(e){return typeof e=="boolean"}var WO=()=>function(t){let{thunk:r=!0,immutableCheck:n=!0,serializableCheck:o=!0,actionCreatorCheck:i=!0}=t??{},a=new iC;return r&&(zO(r)?a.push(KA):a.push(XA(r.extraArgument))),a},yc="RTK_autoBatch",Zi=()=>e=>({payload:e,meta:{[yc]:!0}}),ZA=e=>t=>{setTimeout(t,e)},YO=(e={type:"raf"})=>t=>(...r)=>{let n=t(...r),o=!0,i=!1,a=!1,p=new Set,f=e.type==="tick"?queueMicrotask:e.type==="raf"?typeof window<"u"&&window.requestAnimationFrame?window.requestAnimationFrame:ZA(10):e.type==="callback"?e.queueNotification:ZA(e.timeout),m=()=>{a=!1,i&&(i=!1,p.forEach(h=>h()))};return Object.assign({},n,{subscribe(h){let C=()=>o&&h(),b=n.subscribe(C);return p.add(h),()=>{b(),p.delete(h)}},dispatch(h){try{return o=!h?.meta?.[yc],i=!o,i&&(a||(a=!0,f(m))),n.dispatch(h)}finally{o=!0}}})},KO=e=>function(r){let{autoBatch:n=!0}=r??{},o=new iC(e);return n&&o.push(YO(typeof n=="object"?n:void 0)),o};function aC(e){let t=WO(),{reducer:r=void 0,middleware:n,devTools:o=!0,duplicateMiddlewareCheck:i=!0,preloadedState:a=void 0,enhancers:p=void 0}=e||{},f;if(typeof r=="function")f=r;else if(jr(r))f=Yi(r);else throw new Error(Ht(1));let m;typeof n=="function"?m=n(t):m=t();let h=tc;o&&(h=$O({trace:!1,...(typeof o=="object"&&o)}));let C=PA(...m),b=KO(C),g=typeof p=="function"?p(b):b(),S=h(...g);return Xg(f,a,S)}function sC(e){let t={},r=[],n,o={addCase(i,a){let p=typeof i=="string"?i:i.type;if(!p)throw new Error(Ht(28));if(p in t)throw new Error(Ht(29));return t[p]=a,o},addAsyncThunk(i,a){return a.pending&&(t[i.pending.type]=a.pending),a.rejected&&(t[i.rejected.type]=a.rejected),a.fulfilled&&(t[i.fulfilled.type]=a.fulfilled),a.settled&&r.push({matcher:i.settled,reducer:a.settled}),o},addMatcher(i,a){return r.push({matcher:i,reducer:a}),o},addDefaultCase(i){return n=i,o}};return e(o),[t,r,n]}function XO(e){return typeof e=="function"}function le(e,t){let[r,n,o]=sC(t),i;if(XO(e))i=()=>JA(e());else{let p=JA(e);i=()=>p}function a(p=i(),f){let m=[r[f.type],...n.filter(({matcher:h})=>h(f)).map(({reducer:h})=>h)];return m.filter(h=>!!h).length===0&&(m=[o]),m.reduce((h,C)=>{if(C)if(Gt(h)){let g=C(h,f);return g===void 0?h:g}else{if($t(h))return Vo(h,b=>C(b,f));{let b=C(h,f);if(b===void 0){if(h===null)return h;throw Error("A case reducer on a non-draftable value must not return undefined")}return b}}return h},p)}return a.getInitialState=i,a}var cC=(e,t)=>HO(e)?e.match(t):e(t);function Lr(...e){return t=>e.some(r=>cC(r,t))}function Ji(...e){return t=>e.every(r=>cC(r,t))}function ll(e,t){if(!e||!e.meta)return!1;let r=typeof e.meta.requestId=="string",n=t.indexOf(e.meta.requestStatus)>-1;return r&&n}function Sc(e){return typeof e[0]=="function"&&"pending"in e[0]&&"fulfilled"in e[0]&&"rejected"in e[0]}function dl(...e){return e.length===0?t=>ll(t,["pending"]):Sc(e)?Lr(...e.map(t=>t.pending)):dl()(e[0])}function Lo(...e){return e.length===0?t=>ll(t,["rejected"]):Sc(e)?Lr(...e.map(t=>t.rejected)):Lo()(e[0])}function vc(...e){let t=r=>r&&r.meta&&r.meta.rejectedWithValue;return e.length===0?Ji(Lo(...e),t):Sc(e)?Ji(Lo(...e),t):vc()(e[0])}function In(...e){return e.length===0?t=>ll(t,["fulfilled"]):Sc(e)?Lr(...e.map(t=>t.fulfilled)):In()(e[0])}function pl(...e){return e.length===0?t=>ll(t,["pending","fulfilled","rejected"]):Sc(e)?Lr(...e.flatMap(t=>[t.pending,t.rejected,t.fulfilled])):pl()(e[0])}var JO="ModuleSymbhasOwnPr-0123456789ABCDEFGHNRVfgctiUvz_KqYTJkLxpZXIjQW",Ac=(e=21)=>{let t="",r=e;for(;r--;)t+=JO[Math.random()*64|0];return t},ZO=["name","message","stack","code"],dh=class{constructor(e,t){De(this,"_type");this.payload=e,this.meta=t}},eC=class{constructor(e,t){De(this,"_type");this.payload=e,this.meta=t}},e_=e=>{if(typeof e=="object"&&e!==null){let t={};for(let r of ZO)typeof e[r]=="string"&&(t[r]=e[r]);return t}return{message:String(e)}},tC="External signal was aborted",pe=(()=>{function e(t,r,n){let o=T(t+"/fulfilled",(f,m,h,C)=>({payload:f,meta:{...(C||{}),arg:h,requestId:m,requestStatus:"fulfilled"}})),i=T(t+"/pending",(f,m,h)=>({payload:void 0,meta:{...(h||{}),arg:m,requestId:f,requestStatus:"pending"}})),a=T(t+"/rejected",(f,m,h,C,b)=>({payload:C,error:(n&&n.serializeError||e_)(f||"Rejected"),meta:{...(b||{}),arg:h,requestId:m,rejectedWithValue:!!C,requestStatus:"rejected",aborted:f?.name==="AbortError",condition:f?.name==="ConditionError"}}));function p(f,{signal:m}={}){return(h,C,b)=>{let g=n?.idGenerator?n.idGenerator(f):Ac(),S=new s.AbortController,x,w;function R(E){w=E,S.abort()}m&&(m.aborted?R(tC):m.addEventListener("abort",()=>R(tC),{once:!0}));let P=_asyncToGenerator(function*(){let E;try{let F=n?.condition?.(f,{getState:C,extra:b});if(r_(F)&&(F=yield F),F===!1||S.signal.aborted)throw{name:"ConditionError",message:"Aborted due to condition callback returning false."};let q=new Promise((G,Q)=>{x=()=>{Q({name:"AbortError",message:w||"Aborted"})},S.signal.addEventListener("abort",x,{once:!0})});h(i(g,f,n?.getPendingMeta?.({requestId:g,arg:f},{getState:C,extra:b}))),E=yield Promise.race([q,Promise.resolve(r(f,{dispatch:h,getState:C,extra:b,requestId:g,signal:S.signal,abort:R,rejectWithValue:(G,Q)=>new dh(G,Q),fulfillWithValue:(G,Q)=>new eC(G,Q)})).then(G=>{if(G instanceof dh)throw G;return G instanceof eC?o(G.payload,g,f,G.meta):o(G,g,f)})])}catch(F){E=F instanceof dh?a(null,g,f,F.payload,F.meta):a(F,g,f)}finally{x&&S.signal.removeEventListener("abort",x)}return n&&!n.dispatchConditionRejection&&a.match(E)&&E.meta.condition||h(E),E})();return Object.assign(P,{abort:R,requestId:g,arg:f,unwrap(){return P.then(t_)}})}}return Object.assign(p,{pending:i,rejected:a,fulfilled:o,settled:Lr(a,o),typePrefix:t})}return e.withTypes=()=>e,e})();function t_(e){if(e.meta&&e.meta.rejectedWithValue)throw e.payload;if(e.error)throw e.error;return e.payload}function r_(e){return e!==null&&typeof e=="object"&&typeof e.then=="function"}var uC=Symbol.for("rtk-slice-createasyncthunk"),mz={[uC]:pe};function n_(e,t){return`${e}/${t}`}function o_({creators:e}={}){let t=e?.asyncThunk?.[uC];return function(n){let{name:o,reducerPath:i=o}=n;if(!o)throw new Error(Ht(11));typeof process<"u";let a=(typeof n.reducers=="function"?n.reducers(a_()):n.reducers)||{},p=Object.keys(a),f={sliceCaseReducersByName:{},sliceCaseReducersByType:{},actionCreators:{},sliceMatchers:[]},m={addCase(E,_){let F=typeof E=="string"?E:E.type;if(!F)throw new Error(Ht(12));if(F in f.sliceCaseReducersByType)throw new Error(Ht(13));return f.sliceCaseReducersByType[F]=_,m},addMatcher(E,_){return f.sliceMatchers.push({matcher:E,reducer:_}),m},exposeAction(E,_){return f.actionCreators[E]=_,m},exposeCaseReducer(E,_){return f.sliceCaseReducersByName[E]=_,m}};p.forEach(E=>{let _=a[E],F={reducerName:E,type:n_(o,E),createNotation:typeof n.reducers=="function"};c_(_)?l_(F,_,m,t):s_(F,_,m)});function h(){let[E={},_=[],F=void 0]=typeof n.extraReducers=="function"?sC(n.extraReducers):[n.extraReducers],q={...E,...f.sliceCaseReducersByType};return le(n.initialState,G=>{for(let Q in q)G.addCase(Q,q[Q]);for(let Q of f.sliceMatchers)G.addMatcher(Q.matcher,Q.reducer);for(let Q of _)G.addMatcher(Q.matcher,Q.reducer);F&&G.addDefaultCase(F)})}let C=E=>E,b=new Map,g=new WeakMap,S;function x(E,_){return S||(S=h()),S(E,_)}function w(){return S||(S=h()),S.getInitialState()}function R(E,_=!1){function F(G){let Q=G[E];return typeof Q>"u"&&_&&(Q=al(g,F,w)),Q}function q(G=C){let Q=al(b,_,()=>new WeakMap);return al(Q,G,()=>{let j={};for(let[B,L]of Object.entries(n.selectors??{}))j[B]=i_(L,G,()=>al(g,G,w),_);return j})}return{reducerPath:E,getSelectors:q,get selectors(){return q(F)},selectSlice:F}}let P={name:o,reducer:x,actions:f.actionCreators,caseReducers:f.sliceCaseReducersByName,getInitialState:w,...R(i),injectInto(E,{reducerPath:_,...F}={}){let q=_??i;return E.inject({reducerPath:q,reducer:x},F),{...P,...R(q,!0)}}};return P}}function i_(e,t,r,n){function o(i,...a){let p=t(i);return typeof p>"u"&&n&&(p=r()),e(p,...a)}return o.unwrapped=e,o}var Uo=o_();function a_(){function e(t,r){return{_reducerDefinitionType:"asyncThunk",payloadCreator:t,...r}}return e.withTypes=()=>e,{reducer(t){return Object.assign({[t.name](...r){return t(...r)}}[t.name],{_reducerDefinitionType:"reducer"})},preparedReducer(t,r){return{_reducerDefinitionType:"reducerWithPrepare",prepare:t,reducer:r}},asyncThunk:e}}function s_({type:e,reducerName:t,createNotation:r},n,o){let i,a;if("reducer"in n){if(r&&!u_(n))throw new Error(Ht(17));i=n.reducer,a=n.prepare}else i=n;o.addCase(e,i).exposeCaseReducer(t,i).exposeAction(t,a?T(e,a):T(e))}function c_(e){return e._reducerDefinitionType==="asyncThunk"}function u_(e){return e._reducerDefinitionType==="reducerWithPrepare"}function l_({type:e,reducerName:t},r,n,o){if(!o)throw new Error(Ht(18));let{payloadCreator:i,fulfilled:a,pending:p,rejected:f,settled:m,options:h}=r,C=o(e,i,h);n.exposeAction(t,C),a&&n.addCase(C.fulfilled,a),p&&n.addCase(C.pending,p),f&&n.addCase(C.rejected,f),m&&n.addMatcher(C.settled,m),n.exposeCaseReducer(t,{fulfilled:a||sl,pending:p||sl,rejected:f||sl,settled:m||sl})}function sl(){}var d_="task",lC="listener",dC="completed",mh="cancelled",p_=`task-${mh}`,f_=`task-${dC}`,ph=`${lC}-${mh}`,m_=`${lC}-${dC}`,fl=class{constructor(e){De(this,"name","TaskAbortError");De(this,"message");this.code=e,this.message=`${d_} ${mh} (reason: ${e})`}},gh=(e,t)=>{if(typeof e!="function")throw new TypeError(Ht(32))},cl=()=>{},pC=(e,t=cl)=>(e.catch(t),e),fC=(e,t)=>(e.addEventListener("abort",t,{once:!0}),()=>e.removeEventListener("abort",t)),jo=e=>{if(e.aborted)throw new fl(e.reason)};function mC(e,t){let r=cl;return new Promise((n,o)=>{let i=()=>o(new fl(e.reason));if(e.aborted){i();return}r=fC(e,i),t.finally(()=>r()).then(n,o)}).finally(()=>{r=cl})}var g_=/*#__PURE__*/function(){var _ref5=_asyncToGenerator(function*(e,t){try{return yield Promise.resolve(),{status:"ok",value:yield e()}}catch(r){return{status:r instanceof fl?"cancelled":"rejected",error:r}}finally{t?.()}});return function g_(_x7,_x8){return _ref5.apply(this,arguments)}}(),ul=e=>t=>pC(mC(e,t).then(r=>(jo(e),r))),gC=e=>{let t=ul(e);return r=>t(new Promise(n=>setTimeout(n,r)))},{assign:Xi}=Object,rC={},ml="listenerMiddleware",h_=(e,t)=>{let r=n=>fC(e,()=>n.abort(e.reason));return(n,o)=>{gh(n,"taskExecutor");let i=new s.AbortController;r(i);let a=g_(/*#__PURE__*/_asyncToGenerator(function*(){jo(e),jo(i.signal);let p=yield n({pause:ul(i.signal),delay:gC(i.signal),signal:i.signal});return jo(i.signal),p}),()=>i.abort(f_));return o?.autoJoin&&t.push(a.catch(cl)),{result:ul(e)(a),cancel(){i.abort(p_)}}}},y_=(e,t)=>{let r=/*#__PURE__*/function(){var _ref7=_asyncToGenerator(function*(n,o){jo(t);let i=()=>{},p=[new Promise((f,m)=>{let h=e({predicate:n,effect:(C,b)=>{b.unsubscribe(),f([C,b.getState(),b.getOriginalState()])}});i=()=>{h(),m()}})];o!=null&&p.push(new Promise(f=>setTimeout(f,o,null)));try{let f=yield mC(t,Promise.race(p));return jo(t),f}finally{i()}});return function r(_x9,_x0){return _ref7.apply(this,arguments)}}();return(n,o)=>pC(r(n,o))},hC=e=>{let{type:t,actionCreator:r,matcher:n,predicate:o,effect:i}=e;if(t)o=T(t).match;else if(r)t=r.type,o=r.match;else if(n)o=n;else if(!o)throw new Error(Ht(21));return gh(i,"options.listener"),{predicate:o,type:t,effect:i}},yC=Xi(e=>{let{type:t,predicate:r,effect:n}=hC(e);return{id:Ac(),effect:n,type:t,predicate:r,pending:new Set,unsubscribe:()=>{throw new Error(Ht(22))}}},{withTypes:()=>yC}),nC=(e,t)=>{let{type:r,effect:n,predicate:o}=hC(t);return Array.from(e.values()).find(i=>(typeof r=="string"?i.type===r:i.predicate===o)&&i.effect===n)},fh=e=>{e.pending.forEach(t=>{t.abort(ph)})},S_=(e,t)=>()=>{for(let r of t.keys())fh(r);e.clear()},oC=(e,t,r)=>{try{e(t,r)}catch(n){setTimeout(()=>{throw n},0)}},SC=Xi(T(`${ml}/add`),{withTypes:()=>SC}),v_=T(`${ml}/removeAll`),vC=Xi(T(`${ml}/remove`),{withTypes:()=>vC}),A_=(...e)=>{console.error(`${ml}/error`,...e)},AC=(e={})=>{let t=new Map,r=new Map,n=g=>{let S=r.get(g)??0;r.set(g,S+1)},o=g=>{let S=r.get(g)??1;S===1?r.delete(g):r.set(g,S-1)},{extra:i,onError:a=A_}=e;gh(a,"onError");let p=g=>(g.unsubscribe=()=>t.delete(g.id),t.set(g.id,g),S=>{g.unsubscribe(),S?.cancelActive&&fh(g)}),f=g=>{let S=nC(t,g)??yC(g);return p(S)};Xi(f,{withTypes:()=>f});let m=g=>{let S=nC(t,g);return S&&(S.unsubscribe(),g.cancelActive&&fh(S)),!!S};Xi(m,{withTypes:()=>m});let h=/*#__PURE__*/function(){var _ref8=_asyncToGenerator(function*(g,S,x,w){let R=new s.AbortController,P=y_(f,R.signal),E=[];try{g.pending.add(R),n(g),yield Promise.resolve(g.effect(S,Xi({},x,{getOriginalState:w,condition:(_,F)=>P(_,F).then(Boolean),take:P,delay:gC(R.signal),pause:ul(R.signal),extra:i,signal:R.signal,fork:h_(R.signal,E),unsubscribe:g.unsubscribe,subscribe:()=>{t.set(g.id,g)},cancelActiveListeners:()=>{g.pending.forEach((_,F,q)=>{_!==R&&(_.abort(ph),q.delete(_))})},cancel:()=>{R.abort(ph),g.pending.delete(R)},throwIfCancelled:()=>{jo(R.signal)}})))}catch(_){_ instanceof fl||oC(a,_,{raisedBy:"effect"})}finally{yield Promise.all(E),R.abort(m_),o(g),g.pending.delete(R)}});return function h(_x1,_x10,_x11,_x12){return _ref8.apply(this,arguments)}}(),C=S_(t,r);return{middleware:g=>S=>x=>{if(!rc(x))return S(x);if(SC.match(x))return f(x.payload);if(v_.match(x)){C();return}if(vC.match(x))return m(x.payload);let w=g.getState(),R=()=>{if(w===rC)throw new Error(Ht(23));return w},P;try{if(P=S(x),t.size>0){let E=g.getState(),_=Array.from(t.values());for(let F of _){let q=!1;try{q=F.predicate(x,E,w)}catch(G){q=!1,oC(a,G,{raisedBy:"predicate"})}q&&h(F,x,g,R)}}}finally{w=rC}return P},startListening:f,stopListening:m,clearListeners:C}};function Ht(e){return`Minified Redux Toolkit error #${e}; visit https://redux-toolkit.js.org/Errors?code=${e} for the full message or use the non-minified dev environment for full errors. `}d();c();l();u();d();c();l();u();d();c();l();u();function CC(){let e=typeof window<"u";return{sendMessage(t){e&&window.postMessage(t,"*")}}}d();c();l();u();d();c();l();u();d();c();l();u();var bC=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/i;function C_(e){return typeof e=="string"&&bC.test(e)}var hh=C_;d();c();l();u();var Tt=[];for(let e=0;e<256;++e)Tt.push((e+256).toString(16).slice(1));function xC(e,t=0){return(Tt[e[t+0]]+Tt[e[t+1]]+Tt[e[t+2]]+Tt[e[t+3]]+"-"+Tt[e[t+4]]+Tt[e[t+5]]+"-"+Tt[e[t+6]]+Tt[e[t+7]]+"-"+Tt[e[t+8]]+Tt[e[t+9]]+"-"+Tt[e[t+10]]+Tt[e[t+11]]+Tt[e[t+12]]+Tt[e[t+13]]+Tt[e[t+14]]+Tt[e[t+15]]).toLowerCase()}d();c();l();u();var yh,b_=new Uint8Array(16);function Sh(){if(!yh){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");yh=crypto.getRandomValues.bind(crypto)}return yh(b_)}d();c();l();u();d();c();l();u();var x_=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),vh={randomUUID:x_};function w_(e,t,r){e=e||{};let n=e.random??e.rng?.()??Sh();if(n.length<16)throw new Error("Random bytes length must be >= 16");if(n[6]=n[6]&15|64,n[8]=n[8]&63|128,t){if(r=r||0,r<0||r+16>t.length)throw new RangeError(`UUID byte range ${r}:${r+15} is out of buffer bounds`);for(let o=0;o<16;++o)t[r+o]=n[o];return t}return xC(n)}function R_(e,t,r){return vh.randomUUID&&!t&&!e?vh.randomUUID():w_(e,t,r)}var Ah=R_;function I_(_x13){return _I_.apply(this,arguments)}function _I_(){_I_=_asyncToGenerator(function*({config:e,environment:t,event:r,listenerManager:n}){let{url:o,token:i,mode:a}=e;if(a!=="disabled")return n.call(r),t.send(o,i,r)});return _I_.apply(this,arguments)}var TC="2.0.4",Ch=128,PC=192,wC=224,RC=240,E_=248;function F_(e){return(e&E_)===RC?4:(e&RC)===wC?3:(e&wC)===PC?2:1}function T_(e,t){if(t<0||e.length<=t)return e;let r=e.indexOf("%",t-2);for(r<0||r>t?r=t:t=r;r>2&&e.charAt(r-3)=="%";){let n=Number.parseInt(e.substring(r-2,r),16);if((n&Ch)!=Ch)break;if(r-=3,(n&PC)!=Ch){t-r>=F_(n)*3&&(r=t);break}}return e.substring(0,r)}function P_(e){let{trackingId:t}=e;return{trackingId:t}}function k_(e){return(e.source||[]).concat([`relay@${TC}`])}function kC(e,t,r){let{getReferrer:n,getLocation:o,getUserAgent:i}=r,a=P_(t),p=r.getClientId();return Object.freeze({type:e,config:a,ts:Date.now(),source:k_(t),clientId:p,userAgent:i(),referrer:IC(n()),location:IC(o())})}function IC(e){return e!==null?T_(e,1024):null}function O_(e,t,r,n){return{...t,meta:kC(e,r,n)}}var __="*";function N_(){let e=[];function t({type:f,callback:m}){return e.findIndex(h=>h.type===f&&h.callback===m)}function r(f,m){return f.type==="*"||m===f.type}function n(f){return t(f)<0&&e.push(f),()=>p(f.type,f.callback)}function o(f){e.forEach(m=>{if(r(m,f.meta.type))try{m.callback(f)}catch(h){console.error(h)}})}function i(f){if(f===__)e.length=0;else for(let m=e.length-1;m>=0;m--)e[m].type===f&&e.splice(m,1)}function a(f){let m=t(f);m>=0&&e.splice(m,1)}function p(f,m){m?a({type:f,callback:m}):i(f)}return{add:n,call:o,remove:p}}function EC({url:e,token:t,trackingId:r,...n}){return Object.freeze({url:e,token:t,trackingId:r,...(!!n.mode&&{mode:n.mode}),...(!!n.source&&{source:n.source}),...(!!n.environment&&{environment:n.environment})})}function D_(e){let t=EC(e);return{get:()=>t,update:r=>{t=EC({...t,...r})}}}var bh=q_();function q_(){let e="coveo_",t=r=>{let n=r.split(".").slice(-2);return n.length==2?n.join("."):""};return{getItem(r){let n=`${e}${r}=`,o=document.cookie.split(";");for(let i of o){let a=i.replace(/^\s+/,"");if(a.lastIndexOf(n,0)===0)return a.substring(n.length,a.length)}return null},setItem(r,n,o){let i=t(window.location.hostname),a=`;expires=${new Date(new Date().getTime()+o).toUTCString()}`,p=i?`;domain=${i}`:"";document.cookie=`${e}${r}=${n}${a}${p};path=/;SameSite=Lax`},removeItem(r){this.setItem(r,"",-1)}}}function M_(){return{getItem(e){return bh.getItem(e)||localStorage.getItem(e)},removeItem(e){bh.removeItem(e),localStorage.removeItem(e)},setItem(e,t){localStorage.setItem(e,t),bh.setItem(e,t,31556952e3)}}}var FC="visitorId";function V_(){let e=document.referrer;return e===""?null:e}function xh(){let e=M_();return{runtime:"browser",send:function(){var _ref9=_asyncToGenerator(function*(t,r,n){let o=v(t,{method:"POST",body:JSON.stringify([n]),keepalive:!0,headers:{"Content-Type":"application/json",Authorization:`Bearer ${r}`}});CC().sendMessage({kind:"EVENT_PROTOCOL",event:n,url:t,token:r});let a=yield o;if(a?.ok){let p;try{p=yield a.json()}catch{return}for(let f of p.events)if(!f.accepted)throw new Error(`Received event was rejected for processing: ${f.errorMessage}`)}else throw new Error(`Error ${a.status}: Failed to send the event(s).`)});return function send(_x14,_x15,_x16){return _ref9.apply(this,arguments)}}(),getReferrer:()=>V_(),getLocation:()=>window.location.href,getUserAgent:()=>navigator.userAgent,getClientId:()=>{let t=e.getItem(FC);if(t&&hh(t))return t;let r=Ah();return e.setItem(FC,r),r}}}function j_(){try{let e="__storage_test__";return localStorage.setItem(e,e),localStorage.removeItem(e),!0}catch(e){return e instanceof DOMException&&e.name==="QuotaExceededError"&&localStorage&&localStorage.length!==0}}function L_(){return{runtime:"null",send:()=>Promise.resolve(void 0),getReferrer:()=>null,getLocation:()=>null,getUserAgent:()=>null,getClientId:()=>""}}function U_(e){let t=e.get().mode!=="disabled",r=e.get().environment,n=L_();return t&&r?{...r,runtime:"custom"}:t&&Q_()&&j_()?xh():n}function Q_(){try{return typeof window=="object"}catch{return!1}}function B_(e){return{get:()=>Object.freeze(U_(e))}}function OC(e){let t=D_(e),r=N_(),n=B_(t);return{emit:function(){var _ref0=_asyncToGenerator(function*(o,i){let a=t.get(),p=n.get(),f=O_(o,i,a,p);return I_({config:a,environment:p,event:f,listenerManager:r})});return function emit(_x17,_x18){return _ref0.apply(this,arguments)}}(),getMeta:o=>kC(o,t.get(),n.get()),on:(o,i)=>r.add({type:o,callback:i}),off:(o,i)=>r.remove(o,i),updateConfig:o=>t.update(o),version:TC}}d();c();l();u();function _C(){return typeof window<"u"&&typeof document<"u"}d();c();l();u();d();c();l();u();var Gn="3.48.0",NC=["@coveo/atomic","@coveo/quantic"];var ea=ct(e=>e.source,e=>Object.entries(e).map(([t,r])=>`${t}@${r}`).concat(`@coveo/headless@${Gn}`));var Cc=ct(e=>e.configuration.organizationId,e=>e.configuration.environment,e=>e.configuration.accessToken,e=>e.configuration.analytics,e=>ea(e.configuration.analytics),(e,t)=>t,(e,t,r,{trackingId:n,apiBaseUrl:o,enabled:i},a,p)=>{let f=$_(p);return OC({mode:i?"emit":"disabled",url:o??Du(e,t),token:r,trackingId:n??null,source:a,environment:f})}),G_={getClientId:()=>"",getLocation:()=>null,getReferrer:()=>null,getUserAgent:()=>null,send:function(){var _ref1=_asyncToGenerator(function*(){});return function send(){return _ref1.apply(this,arguments)}}()},$_=e=>{if(!e)return;let t=e();return{...(_C()?xh():G_),getClientId:()=>t.clientId,getLocation:()=>t.location,getReferrer:()=>t.referrer,getUserAgent:()=>t.userAgent}};d();c();l();u();d();c();l();u();function Ur(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var o=0,n=Object.getOwnPropertySymbols(e);o<n.length;o++)t.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(e,n[o])&&(r[n[o]]=e[n[o]]);return r}function U(e,t,r,n){function o(i){return i instanceof r?i:new r(function(a){a(i)})}return new(r||(r=Promise))(function(i,a){function p(h){try{m(n.next(h))}catch(C){a(C)}}function f(h){try{m(n.throw(h))}catch(C){a(C)}}function m(h){h.done?i(h.value):o(h.value).then(p,f)}m((n=n.apply(e,t||[])).next())})}var Oe;(function(e){e.search="search",e.click="click",e.custom="custom",e.view="view",e.collect="collect"})(Oe||(Oe={}));function Ih(){return typeof window<"u"}function Lh(){return typeof navigator<"u"}function ta(){return typeof document<"u"}function Eh(){try{return typeof localStorage<"u"}catch{return!1}}function H_(){try{return typeof sessionStorage<"u"}catch{return!1}}function zC(){return Lh()&&navigator.cookieEnabled}var z_=[Oe.click,Oe.custom,Oe.search,Oe.view],W_=(e,t)=>z_.indexOf(e)!==-1?Object.assign({language:ta()?document.documentElement.lang:"unknown",userAgent:Lh()?navigator.userAgent:"unknown"},t):t,xc=class e{static set(t,r,n){var o,i,a,p;n&&(i=new Date,i.setTime(i.getTime()+n)),p=window.location.hostname,p.indexOf(".")===-1?DC(t,r,i):(a=p.split("."),o=a[a.length-2]+"."+a[a.length-1],DC(t,r,i,o))}static get(t){for(var r=t+"=",n=document.cookie.split(";"),o=0;o<n.length;o++){var i=n[o];if(i=i.replace(/^\s+/,""),i.lastIndexOf(r,0)===0)return i.substring(r.length,i.length)}return null}static erase(t){e.set(t,"",-1)}};function DC(e,t,r,n){document.cookie=`${e}=${t}`+(r?`;expires=${r.toUTCString()}`:"")+(n?`;domain=${n}`:"")+";path=/;SameSite=Lax"}function Y_(){return Eh()?localStorage:zC()?new wc:H_()?sessionStorage:new na}var wc=class e{getItem(t){return xc.get(`${e.prefix}${t}`)}removeItem(t){xc.erase(`${e.prefix}${t}`)}setItem(t,r,n){xc.set(`${e.prefix}${t}`,r,n)}};wc.prefix="coveo_";var Fh=class{constructor(){this.cookieStorage=new wc}getItem(t){return localStorage.getItem(t)||this.cookieStorage.getItem(t)}removeItem(t){this.cookieStorage.removeItem(t),localStorage.removeItem(t)}setItem(t,r){localStorage.setItem(t,r),this.cookieStorage.setItem(t,r,31556926e3)}},na=class{getItem(t){return null}removeItem(t){}setItem(t,r){}},gl="__coveo.analytics.history",K_=20,X_=1e3*60,J_=75,Sl=class{constructor(t){this.store=t||Y_()}addElement(t){t.internalTime=new Date().getTime(),t=this.cropQueryElement(this.stripEmptyQuery(t));let r=this.getHistoryWithInternalTime();r!=null?this.isValidEntry(t)&&this.setHistory([t].concat(r)):this.setHistory([t])}addElementAsync(t){return U(this,void 0,void 0,function*(){t.internalTime=new Date().getTime(),t=this.cropQueryElement(this.stripEmptyQuery(t));let r=yield this.getHistoryWithInternalTimeAsync();r!=null?this.isValidEntry(t)&&this.setHistory([t].concat(r)):this.setHistory([t])})}getHistory(){let t=this.getHistoryWithInternalTime();return this.stripEmptyQueries(this.stripInternalTime(t))}getHistoryAsync(){return U(this,void 0,void 0,function*(){let t=yield this.getHistoryWithInternalTimeAsync();return this.stripEmptyQueries(this.stripInternalTime(t))})}getHistoryWithInternalTime(){try{let t=this.store.getItem(gl);return t&&typeof t=="string"?JSON.parse(t):[]}catch{return[]}}getHistoryWithInternalTimeAsync(){return U(this,void 0,void 0,function*(){try{let t=yield this.store.getItem(gl);return t?JSON.parse(t):[]}catch{return[]}})}setHistory(t){try{this.store.setItem(gl,JSON.stringify(t.slice(0,K_)))}catch{}}clear(){try{this.store.removeItem(gl)}catch{}}getMostRecentElement(){let t=this.getHistoryWithInternalTime();return Array.isArray(t)?t.sort((n,o)=>(o.internalTime||0)-(n.internalTime||0))[0]:null}cropQueryElement(t){return t.name&&t.value&&t.name.toLowerCase()==="query"&&(t.value=t.value.slice(0,J_)),t}isValidEntry(t){let r=this.getMostRecentElement();return r&&r.value==t.value?(t.internalTime||0)-(r.internalTime||0)>X_:!0}stripInternalTime(t){return Array.isArray(t)?t.map(r=>{let{name:n,time:o,value:i}=r;return{name:n,time:o,value:i}}):[]}stripEmptyQuery(t){let{name:r,time:n,value:o}=t;return r&&typeof o=="string"&&r.toLowerCase()==="query"&&o.trim()===""?{name:r,time:n}:t}stripEmptyQueries(t){return t.map(r=>this.stripEmptyQuery(r))}};var Z_=(e,t)=>U(void 0,void 0,void 0,function*(){return e===Oe.view?(yield eN(t.contentIdValue),Object.assign({location:window.location.toString(),referrer:document.referrer,title:document.title},t)):t}),eN=e=>U(void 0,void 0,void 0,function*(){let t=new Sl,r={name:"PageView",value:e,time:new Date().toISOString()};yield t.addElementAsync(r)}),hl,tN=new Uint8Array(16);function rN(){if(!hl&&(hl=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!hl))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return hl(tN)}var nN=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;function vl(e){return typeof e=="string"&&nN.test(e)}var Pt=[];for(let e=0;e<256;++e)Pt.push((e+256).toString(16).slice(1));function WC(e,t=0){return Pt[e[t+0]]+Pt[e[t+1]]+Pt[e[t+2]]+Pt[e[t+3]]+"-"+Pt[e[t+4]]+Pt[e[t+5]]+"-"+Pt[e[t+6]]+Pt[e[t+7]]+"-"+Pt[e[t+8]]+Pt[e[t+9]]+"-"+Pt[e[t+10]]+Pt[e[t+11]]+Pt[e[t+12]]+Pt[e[t+13]]+Pt[e[t+14]]+Pt[e[t+15]]}function oN(e){if(!vl(e))throw TypeError("Invalid UUID");let t,r=new Uint8Array(16);return r[0]=(t=parseInt(e.slice(0,8),16))>>>24,r[1]=t>>>16&255,r[2]=t>>>8&255,r[3]=t&255,r[4]=(t=parseInt(e.slice(9,13),16))>>>8,r[5]=t&255,r[6]=(t=parseInt(e.slice(14,18),16))>>>8,r[7]=t&255,r[8]=(t=parseInt(e.slice(19,23),16))>>>8,r[9]=t&255,r[10]=(t=parseInt(e.slice(24,36),16))/1099511627776&255,r[11]=t/4294967296&255,r[12]=t>>>24&255,r[13]=t>>>16&255,r[14]=t>>>8&255,r[15]=t&255,r}function iN(e){e=unescape(encodeURIComponent(e));let t=[];for(let r=0;r<e.length;++r)t.push(e.charCodeAt(r));return t}var aN="6ba7b810-9dad-11d1-80b4-00c04fd430c8",sN="6ba7b811-9dad-11d1-80b4-00c04fd430c8";function cN(e,t,r){function n(o,i,a,p){var f;if(typeof o=="string"&&(o=iN(o)),typeof i=="string"&&(i=oN(i)),((f=i)===null||f===void 0?void 0:f.length)!==16)throw TypeError("Namespace must be array-like (16 iterable integer values, 0-255)");let m=new Uint8Array(16+o.length);if(m.set(i),m.set(o,i.length),m=r(m),m[6]=m[6]&15|t,m[8]=m[8]&63|128,a){p=p||0;for(let h=0;h<16;++h)a[p+h]=m[h];return a}return WC(m)}try{n.name=e}catch{}return n.DNS=aN,n.URL=sN,n}var uN=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),qC={randomUUID:uN};function Qo(e,t,r){if(qC.randomUUID&&!t&&!e)return qC.randomUUID();e=e||{};let n=e.random||(e.rng||rN)();if(n[6]=n[6]&15|64,n[8]=n[8]&63|128,t){r=r||0;for(let o=0;o<16;++o)t[r+o]=n[o];return t}return WC(n)}function lN(e,t,r,n){switch(e){case 0:return t&r^~t&n;case 1:return t^r^n;case 2:return t&r^t&n^r&n;case 3:return t^r^n}}function wh(e,t){return e<<t|e>>>32-t}function dN(e){let t=[1518500249,1859775393,2400959708,3395469782],r=[1732584193,4023233417,2562383102,271733878,3285377520];if(typeof e=="string"){let a=unescape(encodeURIComponent(e));e=[];for(let p=0;p<a.length;++p)e.push(a.charCodeAt(p))}else Array.isArray(e)||(e=Array.prototype.slice.call(e));e.push(128);let n=e.length/4+2,o=Math.ceil(n/16),i=new Array(o);for(let a=0;a<o;++a){let p=new Uint32Array(16);for(let f=0;f<16;++f)p[f]=e[a*64+f*4]<<24|e[a*64+f*4+1]<<16|e[a*64+f*4+2]<<8|e[a*64+f*4+3];i[a]=p}i[o-1][14]=(e.length-1)*8/Math.pow(2,32),i[o-1][14]=Math.floor(i[o-1][14]),i[o-1][15]=(e.length-1)*8&4294967295;for(let a=0;a<o;++a){let p=new Uint32Array(80);for(let g=0;g<16;++g)p[g]=i[a][g];for(let g=16;g<80;++g)p[g]=wh(p[g-3]^p[g-8]^p[g-14]^p[g-16],1);let f=r[0],m=r[1],h=r[2],C=r[3],b=r[4];for(let g=0;g<80;++g){let S=Math.floor(g/20),x=wh(f,5)+lN(S,m,h,C)+b+t[S]+p[g]>>>0;b=C,C=h,h=wh(m,30)>>>0,m=f,f=x}r[0]=r[0]+f>>>0,r[1]=r[1]+m>>>0,r[2]=r[2]+h>>>0,r[3]=r[3]+C>>>0,r[4]=r[4]+b>>>0}return[r[0]>>24&255,r[0]>>16&255,r[0]>>8&255,r[0]&255,r[1]>>24&255,r[1]>>16&255,r[1]>>8&255,r[1]&255,r[2]>>24&255,r[2]>>16&255,r[2]>>8&255,r[2]&255,r[3]>>24&255,r[3]>>16&255,r[3]>>8&255,r[3]&255,r[4]>>24&255,r[4]>>16&255,r[4]>>8&255,r[4]&255]}var pN=cN("v5",80,dN),MC=pN,YC="2.30.54",VC=e=>`${e.protocol}//${e.hostname}${e.pathname.indexOf("/")===0?e.pathname:`/${e.pathname}`}${e.search}`,bc={pageview:"pageview",event:"event"},Al=class{constructor({client:t,uuidGenerator:r=Qo}){this.client=t,this.uuidGenerator=r}},Th=class extends Al{constructor({client:t,uuidGenerator:r=Qo}){super({client:t,uuidGenerator:r}),this.actionData={},this.pageViewId=r(),this.nextPageViewId=this.pageViewId,this.currentLocation=VC(window.location),this.lastReferrer=ta()?document.referrer:"",this.addHooks()}getApi(t){return t==="setAction"?this.setAction:null}setAction(t,r){this.action=t,this.actionData=r}clearData(){this.clearPluginData(),this.action=void 0,this.actionData={}}getLocationInformation(t,r){return Object.assign({hitType:t},this.getNextValues(t,r))}updateLocationInformation(t,r){this.updateLocationForNextPageView(t,r)}getDefaultContextInformation(t){let r={title:ta()?document.title:"",encoding:ta()?document.characterSet:"UTF-8"},n={screenResolution:`${screen.width}x${screen.height}`,screenColor:`${screen.colorDepth}-bit`},o={language:navigator.language,userAgent:navigator.userAgent},i={time:Date.now(),eventId:this.uuidGenerator()};return Object.assign(Object.assign(Object.assign(Object.assign({},i),n),o),r)}updateLocationForNextPageView(t,r){let{pageViewId:n,referrer:o,location:i}=this.getNextValues(t,r);this.lastReferrer=o,this.pageViewId=n,this.currentLocation=i,t===bc.pageview&&(this.nextPageViewId=this.uuidGenerator(),this.hasSentFirstPageView=!0)}getNextValues(t,r){return{pageViewId:t===bc.pageview?this.nextPageViewId:this.pageViewId,referrer:t===bc.pageview&&this.hasSentFirstPageView?this.currentLocation:this.lastReferrer,location:t===bc.pageview?this.getCurrentLocationFromPayload(r):this.currentLocation}}getCurrentLocationFromPayload(t){if(t.page){let r=o=>o.replace(/^\/?(.*)$/,"/$1");return`${(o=>o.split("/").slice(0,3).join("/"))(this.currentLocation)}${r(t.page)}`}else return VC(window.location)}},$n=class e{constructor(t,r){if(!vl(t))throw Error("Not a valid uuid");this.clientId=t,this.creationDate=Math.floor(r/1e3)}toString(){return this.clientId.replace(/-/g,"")+"."+this.creationDate.toString()}get expired(){let t=Math.floor(Date.now()/1e3)-this.creationDate;return t<0||t>e.expirationTime}validate(t,r){return!this.expired&&this.matchReferrer(t,r)}matchReferrer(t,r){try{let n=new URL(t);return r.some(o=>new RegExp(o.replace(/\\/g,"\\\\").replace(/\./g,"\\.").replace(/\*/g,".*")+"$").test(n.host))}catch{return!1}}static fromString(t){let r=t.split(".");if(r.length!==2)return null;let[n,o]=r;if(n.length!==32||isNaN(parseInt(o)))return null;let i=n.substring(0,8)+"-"+n.substring(8,12)+"-"+n.substring(12,16)+"-"+n.substring(16,20)+"-"+n.substring(20,32);return vl(i)?new e(i,Number.parseInt(o)*1e3):null}};$n.cvo_cid="cvo_cid";$n.expirationTime=120;var Ph=class extends Al{constructor({client:t,uuidGenerator:r=Qo}){super({client:t,uuidGenerator:r})}getApi(t){switch(t){case"decorate":return this.decorate;case"acceptFrom":return this.acceptFrom;default:return null}}decorate(t){return U(this,void 0,void 0,function*(){if(!this.client.getCurrentVisitorId)throw new Error("Could not retrieve current clientId");try{let r=new URL(t),n=yield this.client.getCurrentVisitorId();return r.searchParams.set($n.cvo_cid,new $n(n,Date.now()).toString()),r.toString()}catch{throw new Error("Invalid URL provided")}})}acceptFrom(t){this.client.setAcceptedLinkReferrers(t)}};Ph.Id="link";var hr=Object.keys;function yl(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}var Rh=128,KC=192,jC=224,LC=240;function fN(e){return(e&248)===LC?4:(e&LC)===jC?3:(e&jC)===KC?2:1}function mN(e,t){if(t<0||e.length<=t)return e;let r=e.indexOf("%",t-2);for(r<0||r>t?r=t:t=r;r>2&&e.charAt(r-3)=="%";){let n=Number.parseInt(e.substring(r-2,r),16);if((n&Rh)!=Rh)break;if(r-=3,(n&KC)!=Rh){t-r>=fN(n)*3&&(r=t);break}}return e.substring(0,r)}var kh={id:"svc_ticket_id",subject:"svc_ticket_subject",description:"svc_ticket_description",category:"svc_ticket_category",productId:"svc_ticket_product_id",custom:"svc_ticket_custom"},gN=hr(kh).map(e=>kh[e]),hN=[...gN].join("|"),yN=new RegExp(`^(${hN}$)`),SN={svcAction:"svc_action",svcActionData:"svc_action_data"},vN=e=>hr(e).filter(t=>e[t]!==void 0).reduce((t,r)=>{let n=kh[r]||r;return Object.assign(Object.assign({},t),{[n]:e[r]})},{}),AN=e=>yN.test(e),CN=[AN],UC={id:"id",name:"nm",brand:"br",category:"ca",variant:"va",price:"pr",quantity:"qt",coupon:"cc",position:"ps",group:"group"},QC={id:"id",name:"nm",brand:"br",category:"ca",variant:"va",position:"ps",price:"pr",group:"group"},Mt={action:"pa",list:"pal",listSource:"pls"},Cl={id:"ti",revenue:"tr",tax:"tt",shipping:"ts",coupon:"tcc",affiliation:"ta",step:"cos",option:"col"},bN=["loyaltyCardId","loyaltyTier","thirdPartyPersona","companyName","favoriteStore","storeName","userIndustry","userRole","userDepartment","businessUnit"],Oh={id:"quoteId",affiliation:"quoteAffiliation"},_h={id:"reviewId",rating:"reviewRating",comment:"reviewComment"},xN={add:Mt,bookmark_add:Mt,bookmark_remove:Mt,click:Mt,checkout:Mt,checkout_option:Mt,detail:Mt,impression:Mt,remove:Mt,refund:Object.assign(Object.assign({},Mt),Cl),purchase:Object.assign(Object.assign({},Mt),Cl),quickview:Mt,quote:Object.assign(Object.assign({},Mt),Oh),review:Object.assign(Object.assign({},Mt),_h)},wN=hr(UC).map(e=>UC[e]),RN=hr(QC).map(e=>QC[e]),IN=hr(Mt).map(e=>Mt[e]),EN=hr(Cl).map(e=>Cl[e]),FN=hr(_h).map(e=>_h[e]),TN=hr(Oh).map(e=>Oh[e]),PN=[...wN,"custom"].join("|"),kN=[...RN,"custom"].join("|"),XC="(pr[0-9]+)",JC="(il[0-9]+pi[0-9]+)",ON=new RegExp(`^${XC}(${PN})$`),_N=new RegExp(`^(${JC}(${kN}))|(il[0-9]+nm)$`),NN=new RegExp(`^(${IN.join("|")})$`),DN=new RegExp(`^(${EN.join("|")})$`),qN=new RegExp(`^${XC}custom$`),MN=new RegExp(`^${JC}custom$`),VN=new RegExp(`^(${[...bN,...FN,...TN].join("|")})$`),jN=e=>ON.test(e),LN=e=>_N.test(e),UN=e=>NN.test(e),QN=e=>DN.test(e),BN=e=>VN.test(e),GN=[LN,jN,UN,QN,BN],$N=[qN,MN],HN={anonymizeIp:"aip"},zN={eventCategory:"ec",eventAction:"ea",eventLabel:"el",eventValue:"ev",page:"dp",visitorId:"cid",clientId:"cid",userId:"uid",currencyCode:"cu"},WN={hitType:"t",pageViewId:"pid",encoding:"de",location:"dl",referrer:"dr",screenColor:"sd",screenResolution:"sr",title:"dt",userAgent:"ua",language:"ul",eventId:"z",time:"tm"},YN=["contentId","contentIdKey","contentType","searchHub","tab","searchUid","permanentId","contentLocale","trackingId"],KN=Object.assign(Object.assign(Object.assign(Object.assign({},HN),zN),WN),YN.reduce((e,t)=>Object.assign(Object.assign({},e),{[t]:t}),{})),Nh=Object.assign(Object.assign({},KN),SN),XN=e=>{let t=!!e.action&&xN[e.action]||{};return hr(e).reduce((r,n)=>{let o=t[n]||Nh[n]||n;return Object.assign(Object.assign({},r),{[o]:e[n]})},{})},JN=hr(Nh).map(e=>Nh[e]),ZN=e=>JN.indexOf(e)!==-1,e0=e=>e==="custom",t0=e=>[...GN,...CN,ZN,e0].some(t=>t(e)),r0=e=>hr(e).reduce((t,r)=>{let n=n0(r);return n?Object.assign(Object.assign({},t),o0(n,e[r])):Object.assign(Object.assign({},t),{[r]:e[r]})},{}),n0=e=>{let t;return[...$N].every(r=>{var n;return t=(n=r.exec(e))===null||n===void 0?void 0:n[1],!t}),t},o0=(e,t)=>hr(t).reduce((r,n)=>Object.assign(Object.assign({},r),{[`${e}${n}`]:t[n]}),{}),Dh=class{constructor(t){this.opts=t}sendEvent(t,r){return U(this,void 0,void 0,function*(){if(!this.isAvailable())throw new Error("navigator.sendBeacon is not supported in this browser. Consider adding a polyfill like \"sendbeacon-polyfill\".");let{baseUrl:n,preprocessRequest:o}=this.opts,i=yield this.getQueryParamsForEventType(t),{url:a,payload:p}=yield this.preProcessRequestAsPotentialJSONString(`${n}/analytics/${t}?${i}`,r,o),f=this.encodeForEventType(t,p),m=new Blob([f],{type:"application/x-www-form-urlencoded"});navigator.sendBeacon(a,m)})}isAvailable(){return"sendBeacon"in navigator}deleteHttpCookieVisitorId(){return Promise.resolve()}preProcessRequestAsPotentialJSONString(t,r,n){return U(this,void 0,void 0,function*(){let o=t,i=r;if(n){let a=yield n({url:t,body:JSON.stringify(r)},"analyticsBeacon"),{url:p,body:f}=a;o=p||t;try{i=JSON.parse(f)}catch(m){console.error("Unable to process the request body as a JSON string",m)}}return{payload:i,url:o}})}encodeForEventType(t,r){return this.isEventTypeLegacy(t)?this.encodeEventToJson(t,r):this.encodeEventToJson(t,r,this.opts.token)}getQueryParamsForEventType(t){return U(this,void 0,void 0,function*(){let{token:r,visitorIdProvider:n}=this.opts,o=yield n.getCurrentVisitorId();return[r&&this.isEventTypeLegacy(t)?`access_token=${r}`:"",o?`visitorId=${o}`:"","discardVisitInfo=true"].filter(i=>!!i).join("&")})}isEventTypeLegacy(t){return[Oe.click,Oe.custom,Oe.search,Oe.view].indexOf(t)!==-1}encodeEventToJson(t,r,n){let o=`${t}Event=${encodeURIComponent(JSON.stringify(r))}`;return n&&(o=`access_token=${encodeURIComponent(n)}&${o}`),o}},qh=class{sendEvent(t,r){return U(this,void 0,void 0,function*(){return Promise.resolve()})}deleteHttpCookieVisitorId(){return U(this,void 0,void 0,function*(){return Promise.resolve()})}},BC=y.fetch,bl=class{constructor(t){this.opts=t}sendEvent(t,r){return U(this,void 0,void 0,function*(){let{baseUrl:n,visitorIdProvider:o,preprocessRequest:i}=this.opts,a=this.shouldAppendVisitorId(t)?yield this.getVisitorIdParam():"",p={url:`${n}/analytics/${t}${a}`,credentials:"include",mode:"cors",headers:this.getHeaders(),method:"POST",body:JSON.stringify(r)},f=Object.assign(Object.assign({},p),i?yield i(p,"analyticsFetch"):{}),{url:m}=f,h=Ur(f,["url"]),C;try{C=yield BC(m,h)}catch(b){console.error("An error has occured when sending the event.",b);return}if(C.ok){let b=yield C.json();return b.visitorId&&o.setCurrentVisitorId(b.visitorId),b}else{try{C.json()}catch{}throw console.error(`An error has occured when sending the "${t}" event.`,C,r),new Error(`An error has occurred when sending the "${t}" event. Check the console logs for more details.`)}})}deleteHttpCookieVisitorId(){return U(this,void 0,void 0,function*(){let{baseUrl:t}=this.opts,r=`${t}/analytics/visit`;yield BC(r,{headers:this.getHeaders(),method:"DELETE"})})}shouldAppendVisitorId(t){return[Oe.click,Oe.custom,Oe.search,Oe.view].indexOf(t)!==-1}getVisitorIdParam(){return U(this,void 0,void 0,function*(){let{visitorIdProvider:t}=this.opts,r=yield t.getCurrentVisitorId();return r?`?visitor=${r}`:""})}getHeaders(){let{token:t}=this.opts;return Object.assign(Object.assign({},t?{Authorization:`Bearer ${t}`}:{}),{"Content-Type":"application/json"})}},Mh=class{constructor(t,r){Eh()&&zC()?this.storage=new Fh:Eh()?this.storage=localStorage:(console.warn("BrowserRuntime detected no valid storage available.",this),this.storage=new na),this.client=new bl(t),this.beaconClient=new Dh(t),window.addEventListener("beforeunload",()=>{let n=r();for(let{eventType:o,payload:i}of n)this.beaconClient.sendEvent(o,i)})}getClientDependingOnEventType(t){return t==="click"&&this.beaconClient.isAvailable()?this.beaconClient:this.client}},Vh=class{constructor(t,r){this.storage=r||new na,this.client=new bl(t)}getClientDependingOnEventType(t){return this.client}},xl=class{constructor(){this.storage=new na,this.client=new qh}getClientDependingOnEventType(t){return this.client}},i0="xx",a0=e=>e?.startsWith(i0)||!1,s0=`
27
+ ${h}`:h;break;case"event":n.event=h;break;case"id":e(n.id=h);break;case"retry":Zk(h,n,t);break}}}}function Zk(e,t,r){let n=parseInt(e,10);Number.isNaN(n)||r(t.retry=n)}function eO(e,t){let r=new Uint8Array(e.length+t.length);return r.set(e),r.set(t,e.length),r}function uA(){return{data:"",event:"",id:"",retry:void 0}}var Ug="text/event-stream",tO=1e3,fA="last-event-id";function mA(){return typeof window<"u"}function Lu(e,{signal:t,headers:r,onopen:n,onmessage:o,onclose:i,onerror:a,openWhenHidden:p,fetch:f,...m}){return new Promise((h,C)=>{let b={...r};b.accept||(b.accept=Ug);let g;function S(){g?.abort(),document.hidden||_()}!p&&mA()&&document.addEventListener("visibilitychange",S);let x=tO,w;function R(){mA()&&document.removeEventListener("visibilitychange",S),clearTimeout(w),g?.abort()}t?.addEventListener("abort",()=>{R(),h()});let P=f??v,E=n??rO;function _(){return _2.apply(this,arguments)}function _2(){_2=_asyncToGenerator(function*(){g=s.AbortController?new s.AbortController:null;try{let F=yield P(e,{...m,headers:b,signal:g?.signal});yield E(F),yield lA(F.body,dA(pA(q=>{q?b[fA]=q:delete b[fA]},q=>{x=q},o))),i?.(),R(),h()}catch(F){if(!g?.signal?.aborted)try{let q=a?.(F)??x;clearTimeout(w),w=setTimeout(_,q)}catch(q){R(),C(q)}}});return _2.apply(this,arguments)}_()})}function rO(e){let t=e.headers.get("content-type");if(!t?.startsWith(Ug))throw new Error(`Expected content-type to be ${Ug}, Actual: ${t}`)}d();c();l();u();var Qn=class{constructor(t){De(this,"_basePath");De(this,"_params",{});this._basePath=t}addParam(t,r){this._params={...this.params,[t]:r}}get basePath(){return this._basePath}get params(){return this._params}get hasParams(){return Object.entries(this._params).length}get href(){return this.hasParams?`${this.basePath}?${Object.entries(this.params).map(([t,r])=>`${t}=${encodeURIComponent(r)}`).join("&")}`:this.basePath}};var nO=(e,t,r)=>new Qn(`${e}/rest/organizations/${t}/machinelearning/streaming/${r}`).href,gA=3,oO=5e3,iO="text/event-stream",Gg=1,Qg=class extends Error{},Js=class extends Error{constructor(r){super(r.message);this.payload=r}},Bg=class{constructor(){De(this,"timeouts",new Set)}add(t){this.timeouts.add(t)}remove(t){clearTimeout(t),this.timeouts.delete(t)}isActive(t){return this.timeouts.has(t)}},Uu=class{constructor(t){De(this,"logger");this.logger=t.logger}streamGeneratedAnswer(t,r){let{url:n,organizationId:o,streamId:i,accessToken:a}=t,{write:p,abort:f,close:m,resetAnswer:h}=r,C=new Bg;if(!i){this.logger.error("No stream ID found");return}let b=0,g,S=()=>{g&&!C.isActive(g)&&(w?.abort(),h(),R())},x=()=>{C.remove(g),g=Mv(S,g,oO),C.add(g)},w=new s.AbortController,R=()=>Lu(nO(n,o,i),{method:"GET",fetch:v,headers:{Authorization:`Bearer ${a}`,accept:"*/*"},openWhenHidden:!0,signal:w?.signal,onopen(P){return _asyncToGenerator(function*(){if(P.ok&&P.headers.get("content-type")===iO)return;throw P.status>=400&&P.status<500&&P.status!==429?new Js({message:"Error opening stream",code:P.status}):new Qg})()},onmessage:P=>{if(w?.signal.aborted)return;let E=JSON.parse(P.data);if(E.finishReason==="ERROR"){C.remove(g),w?.abort(),f({message:E.errorMessage,code:E.statusCode});return}p(E),b=0,E.finishReason==="COMPLETED"?(C.remove(g),m()):x()},onerror:P=>{if(!w?.signal.aborted){if(C.remove(g),P instanceof Js)throw w?.abort(),f(P),P;if(++b>gA){this.logger.info("Maximum retry exceeded.");let E={message:"Failed to complete stream.",code:Gg};throw w?.abort(),f(E),new Js(E)}this.logger.info(`Retrying...(${b}/${gA})`),h()}}});return R(),w}};d();c();l();u();var Qu=e=>e;d();c();l();u();d();c();l();u();d();c();l();u();function Zs(e){let{url:t,accessToken:r,organizationId:n,authentication:o,...i}=e;return i}var $g=e=>{let{response:t}=e;return t.body?aO(e):sO(t)},aO=e=>uO(e)?lO(e):cO(e)?e.body:{message:"unknown",statusCode:0,type:"unknown"},sO=e=>{let t=JSON.parse(JSON.stringify(e,Object.getOwnPropertyNames(e)));return{...t,message:`Client side error: ${t.message||""}`,statusCode:400,type:"ClientError"}};function cO(e){return e.body.statusCode!==void 0}function uO(e){return e.body.exception!==void 0}var lO=e=>({message:e.body.exception.code,statusCode:e.response.status,type:e.body.exception.code});d();c();l();u();function hA(e){return((e.headers.get("content-type")||"").split(";").find(n=>n.indexOf("charset=")!==-1)||"").split("=")[1]||"UTF-8"}d();c();l();u();var Hg=(e,t,r,n)=>{let o=new Qn(`${e.url}${n}`);return o.addParam("organizationId",e.organizationId),e.authentication&&o.addParam("authentication",e.authentication),{accessToken:e.accessToken,method:t,contentType:r,url:o.href,origin:"searchApiFetch"}};var yA=(e,t)=>{let r=new Qn(`${e.url}${t}`);return r.addParam("access_token",e.accessToken),r.addParam("organizationId",e.organizationId),r.addParam("uniqueId",e.uniqueId),e.authentication&&r.addParam("authentication",e.authentication),e.q!==void 0&&r.addParam("q",e.q),e.enableNavigation!==void 0&&r.addParam("enableNavigation",`${e.enableNavigation}`),e.requestedOutputSize!==void 0&&r.addParam("requestedOutputSize",`${e.requestedOutputSize}`),r.href},zg=/*#__PURE__*/function(){var _ref3=_asyncToGenerator(function*(e,t){let r=yield Vr.call({...Hg(e,"POST","application/x-www-form-urlencoded","/html"),requestParams:Zs(e),requestMetadata:{method:"html"},...t});if(r instanceof Error)throw r;let n=hA(r),o=yield r.arrayBuffer(),a=new TextDecoder(n).decode(o);return dO(a)?{success:a}:{error:$g({response:r,body:a})}});return function zg(_x5,_x6){return _ref3.apply(this,arguments)}}();function dO(e){return typeof e=="string"}d();c();l();u();d();c();l();u();function zi(){return{answerSnippet:"",documentId:{contentIdKey:"",contentIdValue:""},question:"",relatedQuestions:[],score:0}}function At(){return{response:{results:[],searchUid:"",totalCountFiltered:0,facets:[],generateAutomaticFacets:{facets:[]},queryCorrections:[],triggers:[],questionAnswer:zi(),pipeline:"",splitTestRun:"",termsToHighlight:{},phrasesToHighlight:{},extendedResults:{}},duration:0,queryExecuted:"",error:null,automaticallyCorrected:!1,isLoading:!1,results:[],searchResponseId:"",requestId:"",questionAnswer:zi(),extendedResults:{},searchAction:void 0}}d();c();l();u();d();c();l();u();function pO(e){return{statusCode:e.statusCode,type:e.name,message:e.message}}function fO(e){return{statusCode:e.code,type:e.name,message:e.message,ignored:!0}}function Wi(e,t){if(t&&e.name==="AbortError")return{error:fO(e)};if(e instanceof _o)return{error:pO(e)};throw e}var Bn=e=>e.success!==void 0,$e=e=>e.error!==void 0;function SA(e){return e.results!==void 0}function vA(e){let t=zi();return ee(e.questionAnswer)?(e.questionAnswer=t,e):(e.questionAnswer={...t,...e.questionAnswer},e)}d();c();l();u();d();c();l();u();var Wg=(e,t)=>`${e.url}/rest/organizations/${e.organizationId}/insight/v1/configs/${e.insightId}${t??""}`,mO=e=>`${e.url}/rest/organizations/${e.organizationId}/machinelearning/user/actions`,ec=(e,t,r,n)=>{gO(e);let o=Wg(e,n);return{accessToken:e.accessToken,method:t,contentType:r,url:o,origin:"insightApiFetch"}},AA=(e,t,r)=>{hO(e);let n=mO(e);return{accessToken:e.accessToken,method:t,contentType:r,url:n,origin:"insightApiFetch"}},Yg=e=>{let{insightId:t,...r}=Zs(e);return r},CA=e=>{if(!e.url)throw new Error("The 'url' attribute must contain a valid platform URL.");if(!e.organizationId)throw new Error("The 'organizationId' attribute must contain a valid organization ID.");if(!e.accessToken)throw new Error("The 'accessToken' attribute must contain a valid platform access token.")},gO=e=>{if(CA(e),!e.insightId)throw new Error("The 'insightId' attribute must contain a valid Insight Panel configuration ID.")},hO=e=>{if(CA(e),!e.userId)throw new Error("The 'userId' attribute must contain a valid user ID.")};var bA=e=>({...ec(e,"GET","application/json","/interface"),requestParams:{}});d();c();l();u();var xA=e=>({...ec(e,"POST","application/json","/search"),requestParams:Yg(e)}),wA=e=>({...ec(e,"POST","application/json","/querysuggest"),requestParams:Yg(e)});d();c();l();u();var RA=e=>({...AA(e,"POST","application/json"),requestParams:{objectId:e.userId}});var Bu=class{constructor(t){this.options=t}getInterface(t){var _this=this;return _asyncToGenerator(function*(){let r=yield Vr.call({...bA(t),..._this.options});if(r instanceof Error)return Wi(r);let n=yield r.json();return r.ok?{success:n}:{error:n}})()}query(t,r){var _this2=this;return _asyncToGenerator(function*(){let n=yield Vr.call({...xA(t),requestMetadata:{method:"search",origin:r?.origin},..._this2.options});if(n instanceof Error)return Wi(n);let o=yield n.json();return SA(o)&&(o=vA(o)),n.ok?{success:o}:{error:o}})()}querySuggest(t){var _this3=this;return _asyncToGenerator(function*(){let r=yield Vr.call({...wA(t),..._this3.options});if(r instanceof Error)return Wi(r);let n=yield r.json();return n.completions?{success:n}:{error:n}})()}userActions(t){var _this4=this;return _asyncToGenerator(function*(){let r=yield Vr.call({...RA(t),..._this4.options});if(r instanceof Error)return Wi(r);let n=yield r.json();return r.ok?{success:n}:{error:n}})()}html(t){var _this5=this;return _asyncToGenerator(function*(){return zg(t,{..._this5.options})})()}};d();c();l();u();d();c();l();u();var z=new $({required:!0,emptyAllowed:!1}),ze=new $({required:!1,emptyAllowed:!1}),Ke=new $({required:!0,emptyAllowed:!0}),P3=new $({required:!1,emptyAllowed:!0}),Gu=new ne({each:z,required:!0}),IA=new $({required:!1,emptyAllowed:!1,regex:/^\d+\.\d+\.\d+$/}),EA=new $({required:!1,emptyAllowed:!1,regex:/^[a-zA-Z0-9_\-.]{1,100}$/}),k3=new $({required:!0,emptyAllowed:!1,regex:/^[a-zA-Z0-9_\-.]{1,100}$/}),Fr=({message:e,name:t,stack:r})=>({message:e,name:t,stack:r}),fr=(e,t)=>{if("required"in t)return{payload:new Fe({value:t}).validate({value:e}).value};let o=new Y({options:{required:!0},values:t}).validate(e);if(o)throw new ko(o);return{payload:e}},O=(e,t)=>{try{return fr(e,t)}catch(r){return{payload:e,error:Fr(r)}}},mr=(e,t,r,n)=>{let o=`Check the initialState of ${n}`;return FA(e,t,r,o,"Controller initialization error")},ht=(e,t,r,n)=>{let o=`Check the options of ${n}`;return FA(e,t,r,o,"Controller initialization error")},FA=(e,t,r,n,o)=>{try{return t.validate(r,n)}catch(i){throw e.logger.error(i,o),i}};d();c();l();u();d();c();l();u();d();c();l();u();function Et(e){return`Minified Redux error #${e}; visit https://redux.js.org/Errors?code=${e} for the full message or use the non-minified dev environment for full errors. `}var yO=typeof Symbol=="function"&&Symbol.observable||"@@observable",TA=yO,Kg=()=>Math.random().toString(36).substring(7).split("").join("."),SO={INIT:`@@redux/INIT${Kg()}`,REPLACE:`@@redux/REPLACE${Kg()}`,PROBE_UNKNOWN_ACTION:()=>`@@redux/PROBE_UNKNOWN_ACTION${Kg()}`},$u=SO;function jr(e){if(typeof e!="object"||e===null)return!1;let t=e;for(;Object.getPrototypeOf(t)!==null;)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t||Object.getPrototypeOf(e)===null}function Xg(e,t,r){if(typeof e!="function")throw new Error(Et(2));if(typeof t=="function"&&typeof r=="function"||typeof r=="function"&&typeof arguments[3]=="function")throw new Error(Et(0));if(typeof t=="function"&&typeof r>"u"&&(r=t,t=void 0),typeof r<"u"){if(typeof r!="function")throw new Error(Et(1));return r(Xg)(e,t)}let n=e,o=t,i=new Map,a=i,p=0,f=!1;function m(){a===i&&(a=new Map,i.forEach((w,R)=>{a.set(R,w)}))}function h(){if(f)throw new Error(Et(3));return o}function C(w){if(typeof w!="function")throw new Error(Et(4));if(f)throw new Error(Et(5));let R=!0;m();let P=p++;return a.set(P,w),function(){if(R){if(f)throw new Error(Et(6));R=!1,m(),a.delete(P),i=null}}}function b(w){if(!jr(w))throw new Error(Et(7));if(typeof w.type>"u")throw new Error(Et(8));if(typeof w.type!="string")throw new Error(Et(17));if(f)throw new Error(Et(9));try{f=!0,o=n(o,w)}finally{f=!1}return(i=a).forEach(P=>{P()}),w}function g(w){if(typeof w!="function")throw new Error(Et(10));n=w,b({type:$u.REPLACE})}function S(){let w=C;return{subscribe(R){if(typeof R!="object"||R===null)throw new Error(Et(11));function P(){let _=R;_.next&&_.next(h())}return P(),{unsubscribe:w(P)}},[TA](){return this}}}return b({type:$u.INIT}),{dispatch:b,subscribe:C,getState:h,replaceReducer:g,[TA]:S}}function vO(e){Object.keys(e).forEach(t=>{let r=e[t];if(typeof r(void 0,{type:$u.INIT})>"u")throw new Error(Et(12));if(typeof r(void 0,{type:$u.PROBE_UNKNOWN_ACTION()})>"u")throw new Error(Et(13))})}function Yi(e){let t=Object.keys(e),r={};for(let a=0;a<t.length;a++){let p=t[a];typeof e[p]=="function"&&(r[p]=e[p])}let n=Object.keys(r),o,i;try{vO(r)}catch(a){i=a}return function(p={},f){if(i)throw i;let m=!1,h={};for(let C=0;C<n.length;C++){let b=n[C],g=r[b],S=p[b],x=g(S,f);if(typeof x>"u"){let w=f&&f.type;throw new Error(Et(14))}h[b]=x,m=m||x!==S}return m=m||n.length!==Object.keys(p).length,m?h:p}}function tc(...e){return e.length===0?t=>t:e.length===1?e[0]:e.reduce((t,r)=>(...n)=>t(r(...n)))}function PA(...e){return t=>(r,n)=>{let o=t(r,n),i=()=>{throw new Error(Et(15))},a={getState:o.getState,dispatch:(f,...m)=>i(f,...m)},p=e.map(f=>f(a));return i=tc(...p)(o.dispatch),{...o,dispatch:i}}}function rc(e){return jr(e)&&"type"in e&&typeof e.type=="string"}d();c();l();u();var ah=Symbol.for("immer-nothing"),nc=Symbol.for("immer-draftable"),Ct=Symbol.for("immer-state");function Ft(e,...t){throw new Error(`[Immer] minified error nr: ${e}. Full error at: https://bit.ly/3cXEKWf`)}var sr=Object,Do=sr.getPrototypeOf,ic="constructor",lc="prototype",eh="configurable",Yu="enumerable",zu="writable",ac="value",Gt=e=>!!e&&!!e[Ct];function $t(e){return e?VA(e)||pc(e)||!!e[nc]||!!e[ic]?.[nc]||fc(e)||mc(e):!1}var AO=sr[lc][ic].toString(),kA=new WeakMap;function VA(e){if(!e||!Ki(e))return!1;let t=Do(e);if(t===null||t===sr[lc])return!0;let r=sr.hasOwnProperty.call(t,ic)&&t[ic];if(r===Object)return!0;if(!No(r))return!1;let n=kA.get(r);return n===void 0&&(n=Function.toString.call(r),kA.set(r,n)),n===AO}function jA(e){return Gt(e)||Ft(15,e),e[Ct].base_}function dc(e,t,r=!0){qo(e)===0?(r?Reflect.ownKeys(e):sr.keys(e)).forEach(o=>{t(o,e[o],e)}):e.forEach((n,o)=>t(o,n,e))}function qo(e){let t=e[Ct];return t?t.type_:pc(e)?1:fc(e)?2:mc(e)?3:0}var oc=(e,t,r=qo(e))=>r===2?e.has(t):sr[lc].hasOwnProperty.call(e,t),wn=(e,t,r=qo(e))=>r===2?e.get(t):e[t],Ku=(e,t,r,n=qo(e))=>{n===2?e.set(t,r):n===3?e.add(r):e[t]=r};function CO(e,t){return e===t?e!==0||1/e===1/t:e!==e&&t!==t}var pc=Array.isArray,fc=e=>e instanceof Map,mc=e=>e instanceof Set,Ki=e=>typeof e=="object",No=e=>typeof e=="function",Jg=e=>typeof e=="boolean";function bO(e){let t=+e;return Number.isInteger(t)&&String(t)===e}var xO=e=>Ki(e)?e?.[Ct]:null,Rn=e=>e.copy_||e.base_;var sh=e=>e.modified_?e.copy_:e.base_;function th(e,t){if(fc(e))return new Map(e);if(mc(e))return new Set(e);if(pc(e))return Array[lc].slice.call(e);let r=VA(e);if(t===!0||t==="class_only"&&!r){let n=sr.getOwnPropertyDescriptors(e);delete n[Ct];let o=Reflect.ownKeys(n);for(let i=0;i<o.length;i++){let a=o[i],p=n[a];p[zu]===!1&&(p[zu]=!0,p[eh]=!0),(p.get||p.set)&&(n[a]={[eh]:!0,[zu]:!0,[Yu]:p[Yu],[ac]:e[a]})}return sr.create(Do(e),n)}else{let n=Do(e);if(n!==null&&r)return{...e};let o=sr.create(n);return sr.assign(o,e)}}function ch(e,t=!1){return rl(e)||Gt(e)||!$t(e)||(qo(e)>1&&sr.defineProperties(e,{set:Hu,add:Hu,clear:Hu,delete:Hu}),sr.freeze(e),t&&dc(e,(r,n)=>{ch(n,!0)},!1)),e}function wO(){Ft(2)}var Hu={[ac]:wO};function rl(e){return e===null||!Ki(e)?!0:sr.isFrozen(e)}var Xu="MapSet",Ju="Patches",OA="ArrayMethods",Zu={};function Mo(e){let t=Zu[e];return t||Ft(0,e),t}var _A=e=>!!Zu[e];function RO(e,t){Zu[e]||(Zu[e]=t)}var sc,LA=()=>sc,IO=(e,t)=>({drafts_:[],parent_:e,immer_:t,canAutoFreeze_:!0,unfinalizedDrafts_:0,handledSet_:new Set,processedForPatches_:new Set,mapSetPlugin_:_A(Xu)?Mo(Xu):void 0,arrayMethodsPlugin_:_A(OA)?Mo(OA):void 0});function NA(e,t){t&&(e.patchPlugin_=Mo(Ju),e.patches_=[],e.inversePatches_=[],e.patchListener_=t)}function rh(e){nh(e),e.drafts_.forEach(EO),e.drafts_=null}function nh(e){e===sc&&(sc=e.parent_)}var DA=e=>sc=IO(sc,e);function EO(e){let t=e[Ct];t.type_===0||t.type_===1?t.revoke_():t.revoked_=!0}function qA(e,t){t.unfinalizedDrafts_=t.drafts_.length;let r=t.drafts_[0];if(e!==void 0&&e!==r){r[Ct].modified_&&(rh(t),Ft(4)),$t(e)&&(e=MA(t,e));let{patchPlugin_:o}=t;o&&o.generateReplacementPatches_(r[Ct].base_,e,t)}else e=MA(t,r);return FO(t,e,!0),rh(t),t.patches_&&t.patchListener_(t.patches_,t.inversePatches_),e!==ah?e:void 0}function MA(e,t){if(rl(t))return t;let r=t[Ct];if(!r)return el(t,e.handledSet_,e);if(!nl(r,e))return t;if(!r.modified_)return r.base_;if(!r.finalized_){let{callbacks_:n}=r;if(n)for(;n.length>0;)n.pop()(e);BA(r,e)}return r.copy_}function FO(e,t,r=!1){!e.parent_&&e.immer_.autoFreeze_&&e.canAutoFreeze_&&ch(t,r)}function UA(e){e.finalized_=!0,e.scope_.unfinalizedDrafts_--}var nl=(e,t)=>e.scope_===t,TO=[];function QA(e,t,r,n){let o=Rn(e),i=e.type_;if(n!==void 0&&wn(o,n,i)===t){Ku(o,n,r,i);return}if(!e.draftLocations_){let p=e.draftLocations_=new Map;dc(o,(f,m)=>{if(Gt(m)){let h=p.get(m)||[];h.push(f),p.set(m,h)}})}let a=e.draftLocations_.get(t)??TO;for(let p of a)Ku(o,p,r,i)}function PO(e,t,r){e.callbacks_.push(function(o){let i=t;if(!i||!nl(i,o))return;o.mapSetPlugin_?.fixSetContents(i);let a=sh(i);QA(e,i.draft_??i,a,r),BA(i,o)})}function BA(e,t){if(e.modified_&&!e.finalized_&&(e.type_===3||e.type_===1&&e.allIndicesReassigned_||(e.assigned_?.size??0)>0)){let{patchPlugin_:n}=t;if(n){let o=n.getPath(e);o&&n.generatePatches_(e,o,t)}UA(e)}}function kO(e,t,r){let{scope_:n}=e;if(Gt(r)){let o=r[Ct];nl(o,n)&&o.callbacks_.push(function(){Wu(e);let a=sh(o);QA(e,r,a,t)})}else $t(r)&&e.callbacks_.push(function(){let i=Rn(e);e.type_===3?i.has(r)&&el(r,n.handledSet_,n):wn(i,t,e.type_)===r&&n.drafts_.length>1&&(e.assigned_.get(t)??!1)===!0&&e.copy_&&el(wn(e.copy_,t,e.type_),n.handledSet_,n)})}function el(e,t,r){return!r.immer_.autoFreeze_&&r.unfinalizedDrafts_<1||Gt(e)||t.has(e)||!$t(e)||rl(e)||(t.add(e),dc(e,(n,o)=>{if(Gt(o)){let i=o[Ct];if(nl(i,r)){let a=sh(i);Ku(e,n,a,e.type_),UA(i)}}else $t(o)&&el(o,t,r)})),e}function OO(e,t){let r=pc(e),n={type_:r?1:0,scope_:t?t.scope_:LA(),modified_:!1,finalized_:!1,assigned_:void 0,parent_:t,base_:e,draft_:null,copy_:null,revoke_:null,isManual_:!1,callbacks_:void 0},o=n,i=tl;r&&(o=[n],i=cc);let{revoke:a,proxy:p}=Proxy.revocable(o,i);return n.draft_=p,n.revoke_=a,[p,n]}var tl={get(e,t){if(t===Ct)return e;let r=e.scope_.arrayMethodsPlugin_,n=e.type_===1&&typeof t=="string";if(n&&r?.isArrayOperationMethod(t))return r.createMethodInterceptor(e,t);let o=Rn(e);if(!oc(o,t,e.type_))return _O(e,o,t);let i=o[t];if(e.finalized_||!$t(i)||n&&e.operationMethod&&r?.isMutatingArrayMethod(e.operationMethod)&&bO(t))return i;if(i===Zg(e.base_,t)){Wu(e);let a=e.type_===1?+t:t,p=ih(e.scope_,i,e,a);return e.copy_[a]=p}return i},has(e,t){return t in Rn(e)},ownKeys(e){return Reflect.ownKeys(Rn(e))},set(e,t,r){let n=GA(Rn(e),t);if(n?.set)return n.set.call(e.draft_,r),!0;if(!e.modified_){let o=Zg(Rn(e),t),i=o?.[Ct];if(i&&i.base_===r)return e.copy_[t]=r,e.assigned_.set(t,!1),!0;if(CO(r,o)&&(r!==void 0||oc(e.base_,t,e.type_)))return!0;Wu(e),oh(e)}return e.copy_[t]===r&&(r!==void 0||t in e.copy_)||Number.isNaN(r)&&Number.isNaN(e.copy_[t])||(e.copy_[t]=r,e.assigned_.set(t,!0),kO(e,t,r)),!0},deleteProperty(e,t){return Wu(e),Zg(e.base_,t)!==void 0||t in e.base_?(e.assigned_.set(t,!1),oh(e)):e.assigned_.delete(t),e.copy_&&delete e.copy_[t],!0},getOwnPropertyDescriptor(e,t){let r=Rn(e),n=Reflect.getOwnPropertyDescriptor(r,t);return n&&{[zu]:!0,[eh]:e.type_!==1||t!=="length",[Yu]:n[Yu],[ac]:r[t]}},defineProperty(){Ft(11)},getPrototypeOf(e){return Do(e.base_)},setPrototypeOf(){Ft(12)}},cc={};for(let e in tl){let t=tl[e];cc[e]=function(){let r=arguments;return r[0]=r[0][0],t.apply(this,r)}}cc.deleteProperty=function(e,t){return cc.set.call(this,e,t,void 0)};cc.set=function(e,t,r){return tl.set.call(this,e[0],t,r,e[0])};function Zg(e,t){let r=e[Ct];return(r?Rn(r):e)[t]}function _O(e,t,r){let n=GA(t,r);return n?ac in n?n[ac]:n.get?.call(e.draft_):void 0}function GA(e,t){if(!(t in e))return;let r=Do(e);for(;r;){let n=Object.getOwnPropertyDescriptor(r,t);if(n)return n;r=Do(r)}}function oh(e){e.modified_||(e.modified_=!0,e.parent_&&oh(e.parent_))}function Wu(e){e.copy_||(e.assigned_=new Map,e.copy_=th(e.base_,e.scope_.immer_.useStrictShallowCopy_))}var NO=class{constructor(e){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.useStrictIteration_=!1,this.produce=(t,r,n)=>{if(No(t)&&!No(r)){let i=r;r=t;let a=this;return function(f=i,...m){return a.produce(f,h=>r.call(this,h,...m))}}No(r)||Ft(6),n!==void 0&&!No(n)&&Ft(7);let o;if($t(t)){let i=DA(this),a=ih(i,t,void 0),p=!0;try{o=r(a),p=!1}finally{p?rh(i):nh(i)}return NA(i,n),qA(o,i)}else if(!t||!Ki(t)){if(o=r(t),o===void 0&&(o=t),o===ah&&(o=void 0),this.autoFreeze_&&ch(o,!0),n){let i=[],a=[];Mo(Ju).generateReplacementPatches_(t,o,{patches_:i,inversePatches_:a}),n(i,a)}return o}else Ft(1,t)},this.produceWithPatches=(t,r)=>{if(No(t))return(a,...p)=>this.produceWithPatches(a,f=>t(f,...p));let n,o;return[this.produce(t,r,(a,p)=>{n=a,o=p}),n,o]},Jg(e?.autoFreeze)&&this.setAutoFreeze(e.autoFreeze),Jg(e?.useStrictShallowCopy)&&this.setUseStrictShallowCopy(e.useStrictShallowCopy),Jg(e?.useStrictIteration)&&this.setUseStrictIteration(e.useStrictIteration)}createDraft(e){$t(e)||Ft(8),Gt(e)&&(e=ol(e));let t=DA(this),r=ih(t,e,void 0);return r[Ct].isManual_=!0,nh(t),r}finishDraft(e,t){let r=e&&e[Ct];(!r||!r.isManual_)&&Ft(9);let{scope_:n}=r;return NA(n,t),qA(void 0,n)}setAutoFreeze(e){this.autoFreeze_=e}setUseStrictShallowCopy(e){this.useStrictShallowCopy_=e}setUseStrictIteration(e){this.useStrictIteration_=e}shouldUseStrictIteration(){return this.useStrictIteration_}applyPatches(e,t){let r;for(r=t.length-1;r>=0;r--){let o=t[r];if(o.path.length===0&&o.op==="replace"){e=o.value;break}}r>-1&&(t=t.slice(r+1));let n=Mo(Ju).applyPatches_;return Gt(e)?n(e,t):this.produce(e,o=>n(o,t))}};function ih(e,t,r,n){let[o,i]=fc(t)?Mo(Xu).proxyMap_(t,r):mc(t)?Mo(Xu).proxySet_(t,r):OO(t,r);return(r?.scope_??LA()).drafts_.push(o),i.callbacks_=r?.callbacks_??[],i.key_=n,r&&n!==void 0?PO(r,i,n):i.callbacks_.push(function(f){f.mapSetPlugin_?.fixSetContents(i);let{patchPlugin_:m}=f;i.modified_&&m&&m.generatePatches_(i,[],f)}),o}function ol(e){return Gt(e)||Ft(10,e),$A(e)}function $A(e){if(!$t(e)||rl(e))return e;let t=e[Ct],r,n=!0;if(t){if(!t.modified_)return t.base_;t.finalized_=!0,r=th(e,t.scope_.immer_.useStrictShallowCopy_),n=t.scope_.immer_.shouldUseStrictIteration()}else r=th(e,!0);return dc(r,(o,i)=>{Ku(r,o,$A(i))},n),t&&(t.finalized_=!1),r}function HA(){function t(S,x=[]){if(S.key_!==void 0){let w=S.parent_.copy_??S.parent_.base_,R=xO(wn(w,S.key_)),P=wn(w,S.key_);if(P===void 0||P!==S.draft_&&P!==S.base_&&P!==S.copy_||R!=null&&R.base_!==S.base_)return null;let E=S.parent_.type_===3,_;if(E){let F=S.parent_;_=Array.from(F.drafts_.keys()).indexOf(S.key_)}else _=S.key_;if(!(E&&w.size>_||oc(w,_)))return null;x.push(_)}if(S.parent_)return t(S.parent_,x);x.reverse();try{r(S.copy_,x)}catch{return null}return x}function r(S,x){let w=S;for(let R=0;R<x.length-1;R++){let P=x[R];if(w=wn(w,P),!Ki(w)||w===null)throw new Error(`Cannot resolve path at '${x.join("/")}'`)}return w}let n="replace",o="add",i="remove";function a(S,x,w){if(S.scope_.processedForPatches_.has(S))return;S.scope_.processedForPatches_.add(S);let{patches_:R,inversePatches_:P}=w;switch(S.type_){case 0:case 2:return f(S,x,R,P);case 1:return p(S,x,R,P);case 3:return m(S,x,R,P)}}function p(S,x,w,R){let{base_:P,assigned_:E}=S,_=S.copy_;_.length<P.length&&([P,_]=[_,P],[w,R]=[R,w]);let F=S.allIndicesReassigned_===!0;for(let q=0;q<P.length;q++){let G=_[q],Q=P[q];if((F||E?.get(q.toString()))&&G!==Q){let B=G?.[Ct];if(B&&B.modified_)continue;let L=x.concat([q]);w.push({op:n,path:L,value:g(G)}),R.push({op:n,path:L,value:g(Q)})}}for(let q=P.length;q<_.length;q++){let G=x.concat([q]);w.push({op:o,path:G,value:g(_[q])})}for(let q=_.length-1;P.length<=q;--q){let G=x.concat([q]);R.push({op:i,path:G})}}function f(S,x,w,R){let{base_:P,copy_:E,type_:_}=S;dc(S.assigned_,(F,q)=>{let G=wn(P,F,_),Q=wn(E,F,_),j=q?oc(P,F)?n:o:i;if(G===Q&&j===n)return;let B=x.concat(F);w.push(j===i?{op:j,path:B}:{op:j,path:B,value:g(Q)}),R.push(j===o?{op:i,path:B}:j===i?{op:o,path:B,value:g(G)}:{op:n,path:B,value:g(G)})})}function m(S,x,w,R){let{base_:P,copy_:E}=S,_=0;P.forEach(F=>{if(!E.has(F)){let q=x.concat([_]);w.push({op:i,path:q,value:F}),R.unshift({op:o,path:q,value:F})}_++}),_=0,E.forEach(F=>{if(!P.has(F)){let q=x.concat([_]);w.push({op:o,path:q,value:F}),R.unshift({op:i,path:q,value:F})}_++})}function h(S,x,w){let{patches_:R,inversePatches_:P}=w;R.push({op:n,path:[],value:x===ah?void 0:x}),P.push({op:n,path:[],value:S})}function C(S,x){return x.forEach(w=>{let{path:R,op:P}=w,E=S;for(let G=0;G<R.length-1;G++){let Q=qo(E),j=R[G];typeof j!="string"&&typeof j!="number"&&(j=""+j),(Q===0||Q===1)&&(j==="__proto__"||j===ic)&&Ft(19),No(E)&&j===lc&&Ft(19),E=wn(E,j),Ki(E)||Ft(18,R.join("/"))}let _=qo(E),F=b(w.value),q=R[R.length-1];switch(P){case n:switch(_){case 2:return E.set(q,F);case 3:Ft(16);default:return E[q]=F}case o:switch(_){case 1:return q==="-"?E.push(F):E.splice(q,0,F);case 2:return E.set(q,F);case 3:return E.add(F);default:return E[q]=F}case i:switch(_){case 1:return E.splice(q,1);case 2:return E.delete(q);case 3:return E.delete(w.value);default:return delete E[q]}default:Ft(17,P)}}),S}function b(S){if(!$t(S))return S;if(pc(S))return S.map(b);if(fc(S))return new Map(Array.from(S.entries()).map(([w,R])=>[w,b(R)]));if(mc(S))return new Set(Array.from(S).map(b));let x=Object.create(Do(S));for(let w in S)x[w]=b(S[w]);return oc(S,nc)&&(x[nc]=S[nc]),x}function g(S){return Gt(S)?b(S):S}RO(Ju,{applyPatches_:C,generatePatches_:a,generateReplacementPatches_:h,getPath:t})}var uc=new NO,Vo=uc.produce,uh=uc.produceWithPatches.bind(uc);var lh=uc.applyPatches.bind(uc);d();c();l();u();function DO(e,t=`expected a function, instead received ${typeof e}`){if(typeof e!="function")throw new TypeError(t)}function qO(e,t=`expected an object, instead received ${typeof e}`){if(typeof e!="object")throw new TypeError(t)}function MO(e,t="expected all items to be functions, instead received the following types: "){if(!e.every(r=>typeof r=="function")){let r=e.map(n=>typeof n=="function"?`function ${n.name||"unnamed"}()`:typeof n).join(", ");throw new TypeError(`${t}[${r}]`)}}var zA=e=>Array.isArray(e)?e:[e];function VO(e){let t=Array.isArray(e[0])?e[0]:e;return MO(t,"createSelector expects all input-selectors to be functions, but received the following types: "),t}function jO(e,t){let r=[],{length:n}=e;for(let o=0;o<n;o++)r.push(e[o].apply(null,t));return r}var W3=Object.getPrototypeOf({});var LO=class{constructor(e){this.value=e}deref(){return this.value}},UO=typeof WeakRef<"u"?WeakRef:LO,QO=0,WA=1;function il(){return{s:QO,v:void 0,o:null,p:null}}function gc(e,t={}){let r=il(),{resultEqualityCheck:n}=t,o,i=0;function a(){let p=r,{length:f}=arguments;for(let C=0,b=f;C<b;C++){let g=arguments[C];if(typeof g=="function"||typeof g=="object"&&g!==null){let S=p.o;S===null&&(p.o=S=new WeakMap);let x=S.get(g);x===void 0?(p=il(),S.set(g,p)):p=x}else{let S=p.p;S===null&&(p.p=S=new Map);let x=S.get(g);x===void 0?(p=il(),S.set(g,p)):p=x}}let m=p,h;if(p.s===WA)h=p.v;else if(h=e.apply(null,arguments),i++,n){let C=o?.deref?.()??o;C!=null&&n(C,h)&&(h=C,i!==0&&i--),o=typeof h=="object"&&h!==null||typeof h=="function"?new UO(h):h}return m.s=WA,m.v=h,h}return a.clearCache=()=>{r=il(),a.resetResultsCount()},a.resultsCount=()=>i,a.resetResultsCount=()=>{i=0},a}function BO(e,...t){let r=typeof e=="function"?{memoize:e,memoizeOptions:t}:e,n=(...o)=>{let i=0,a=0,p,f={},m=o.pop();typeof m=="object"&&(f=m,m=o.pop()),DO(m,`createSelector expects an output function after the inputs, but received: [${typeof m}]`);let h={...r,...f},{memoize:C,memoizeOptions:b=[],argsMemoize:g=gc,argsMemoizeOptions:S=[],devModeChecks:x={}}=h,w=zA(b),R=zA(S),P=VO(o),E=C(function(){return i++,m.apply(null,arguments)},...w),_=!0,F=g(function(){a++;let G=jO(P,arguments);return p=E.apply(null,G),p},...R);return Object.assign(F,{resultFunc:m,memoizedResultFunc:E,dependencies:P,dependencyRecomputations:()=>a,resetDependencyRecomputations:()=>{a=0},lastResult:()=>p,recomputations:()=>i,resetRecomputations:()=>{i=0},memoize:C,argsMemoize:g})};return Object.assign(n,{withTypes:()=>n}),n}var ct=BO(gc),GO=Object.assign((e,t=ct)=>{qO(e,`createStructuredSelector expects first argument to be an object where each property is a selector, instead received a ${typeof e}`);let r=Object.keys(e),n=r.map(i=>e[i]);return t(n,(...i)=>i.reduce((a,p,f)=>(a[r[f]]=p,a),{}))},{withTypes:()=>GO});d();c();l();u();function YA(e){return({dispatch:r,getState:n})=>o=>i=>typeof i=="function"?i(r,n,e):o(i)}var KA=YA(),XA=YA;var $O=typeof window<"u"&&window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__?window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__:function(){if(arguments.length!==0)return typeof arguments[0]=="object"?tc:tc.apply(null,arguments)},pz=typeof window<"u"&&window.__REDUX_DEVTOOLS_EXTENSION__?window.__REDUX_DEVTOOLS_EXTENSION__:function(){return function(e){return e}},HO=e=>e&&typeof e.match=="function";function T(e,t){function r(...n){if(t){let o=t(...n);if(!o)throw new Error(Ht(0));return{type:e,payload:o.payload,...("meta"in o&&{meta:o.meta}),...("error"in o&&{error:o.error})}}return{type:e,payload:n[0]}}return r.toString=()=>`${e}`,r.type=e,r.match=n=>rc(n)&&n.type===e,r}var iC=class hc extends Array{constructor(...t){super(...t),Object.setPrototypeOf(this,hc.prototype)}static get[Symbol.species](){return hc}concat(...t){return super.concat.apply(this,t)}prepend(...t){return t.length===1&&Array.isArray(t[0])?new hc(...t[0].concat(this)):new hc(...t.concat(this))}};function JA(e){return $t(e)?Vo(e,()=>{}):e}function al(e,t,r){return e.has(t)?e.get(t):e.set(t,r(t)).get(t)}function zO(e){return typeof e=="boolean"}var WO=()=>function(t){let{thunk:r=!0,immutableCheck:n=!0,serializableCheck:o=!0,actionCreatorCheck:i=!0}=t??{},a=new iC;return r&&(zO(r)?a.push(KA):a.push(XA(r.extraArgument))),a},yc="RTK_autoBatch",Zi=()=>e=>({payload:e,meta:{[yc]:!0}}),ZA=e=>t=>{setTimeout(t,e)},YO=(e={type:"raf"})=>t=>(...r)=>{let n=t(...r),o=!0,i=!1,a=!1,p=new Set,f=e.type==="tick"?queueMicrotask:e.type==="raf"?typeof window<"u"&&window.requestAnimationFrame?window.requestAnimationFrame:ZA(10):e.type==="callback"?e.queueNotification:ZA(e.timeout),m=()=>{a=!1,i&&(i=!1,p.forEach(h=>h()))};return Object.assign({},n,{subscribe(h){let C=()=>o&&h(),b=n.subscribe(C);return p.add(h),()=>{b(),p.delete(h)}},dispatch(h){try{return o=!h?.meta?.[yc],i=!o,i&&(a||(a=!0,f(m))),n.dispatch(h)}finally{o=!0}}})},KO=e=>function(r){let{autoBatch:n=!0}=r??{},o=new iC(e);return n&&o.push(YO(typeof n=="object"?n:void 0)),o};function aC(e){let t=WO(),{reducer:r=void 0,middleware:n,devTools:o=!0,duplicateMiddlewareCheck:i=!0,preloadedState:a=void 0,enhancers:p=void 0}=e||{},f;if(typeof r=="function")f=r;else if(jr(r))f=Yi(r);else throw new Error(Ht(1));let m;typeof n=="function"?m=n(t):m=t();let h=tc;o&&(h=$O({trace:!1,...(typeof o=="object"&&o)}));let C=PA(...m),b=KO(C),g=typeof p=="function"?p(b):b(),S=h(...g);return Xg(f,a,S)}function sC(e){let t={},r=[],n,o={addCase(i,a){let p=typeof i=="string"?i:i.type;if(!p)throw new Error(Ht(28));if(p in t)throw new Error(Ht(29));return t[p]=a,o},addAsyncThunk(i,a){return a.pending&&(t[i.pending.type]=a.pending),a.rejected&&(t[i.rejected.type]=a.rejected),a.fulfilled&&(t[i.fulfilled.type]=a.fulfilled),a.settled&&r.push({matcher:i.settled,reducer:a.settled}),o},addMatcher(i,a){return r.push({matcher:i,reducer:a}),o},addDefaultCase(i){return n=i,o}};return e(o),[t,r,n]}function XO(e){return typeof e=="function"}function le(e,t){let[r,n,o]=sC(t),i;if(XO(e))i=()=>JA(e());else{let p=JA(e);i=()=>p}function a(p=i(),f){let m=[r[f.type],...n.filter(({matcher:h})=>h(f)).map(({reducer:h})=>h)];return m.filter(h=>!!h).length===0&&(m=[o]),m.reduce((h,C)=>{if(C)if(Gt(h)){let g=C(h,f);return g===void 0?h:g}else{if($t(h))return Vo(h,b=>C(b,f));{let b=C(h,f);if(b===void 0){if(h===null)return h;throw Error("A case reducer on a non-draftable value must not return undefined")}return b}}return h},p)}return a.getInitialState=i,a}var cC=(e,t)=>HO(e)?e.match(t):e(t);function Lr(...e){return t=>e.some(r=>cC(r,t))}function Ji(...e){return t=>e.every(r=>cC(r,t))}function ll(e,t){if(!e||!e.meta)return!1;let r=typeof e.meta.requestId=="string",n=t.indexOf(e.meta.requestStatus)>-1;return r&&n}function Sc(e){return typeof e[0]=="function"&&"pending"in e[0]&&"fulfilled"in e[0]&&"rejected"in e[0]}function dl(...e){return e.length===0?t=>ll(t,["pending"]):Sc(e)?Lr(...e.map(t=>t.pending)):dl()(e[0])}function Lo(...e){return e.length===0?t=>ll(t,["rejected"]):Sc(e)?Lr(...e.map(t=>t.rejected)):Lo()(e[0])}function vc(...e){let t=r=>r&&r.meta&&r.meta.rejectedWithValue;return e.length===0?Ji(Lo(...e),t):Sc(e)?Ji(Lo(...e),t):vc()(e[0])}function In(...e){return e.length===0?t=>ll(t,["fulfilled"]):Sc(e)?Lr(...e.map(t=>t.fulfilled)):In()(e[0])}function pl(...e){return e.length===0?t=>ll(t,["pending","fulfilled","rejected"]):Sc(e)?Lr(...e.flatMap(t=>[t.pending,t.rejected,t.fulfilled])):pl()(e[0])}var JO="ModuleSymbhasOwnPr-0123456789ABCDEFGHNRVfgctiUvz_KqYTJkLxpZXIjQW",Ac=(e=21)=>{let t="",r=e;for(;r--;)t+=JO[Math.random()*64|0];return t},ZO=["name","message","stack","code"],dh=class{constructor(e,t){De(this,"_type");this.payload=e,this.meta=t}},eC=class{constructor(e,t){De(this,"_type");this.payload=e,this.meta=t}},e_=e=>{if(typeof e=="object"&&e!==null){let t={};for(let r of ZO)typeof e[r]=="string"&&(t[r]=e[r]);return t}return{message:String(e)}},tC="External signal was aborted",pe=(()=>{function e(t,r,n){let o=T(t+"/fulfilled",(f,m,h,C)=>({payload:f,meta:{...(C||{}),arg:h,requestId:m,requestStatus:"fulfilled"}})),i=T(t+"/pending",(f,m,h)=>({payload:void 0,meta:{...(h||{}),arg:m,requestId:f,requestStatus:"pending"}})),a=T(t+"/rejected",(f,m,h,C,b)=>({payload:C,error:(n&&n.serializeError||e_)(f||"Rejected"),meta:{...(b||{}),arg:h,requestId:m,rejectedWithValue:!!C,requestStatus:"rejected",aborted:f?.name==="AbortError",condition:f?.name==="ConditionError"}}));function p(f,{signal:m}={}){return(h,C,b)=>{let g=n?.idGenerator?n.idGenerator(f):Ac(),S=new s.AbortController,x,w;function R(E){w=E,S.abort()}m&&(m.aborted?R(tC):m.addEventListener("abort",()=>R(tC),{once:!0}));let P=_asyncToGenerator(function*(){let E;try{let F=n?.condition?.(f,{getState:C,extra:b});if(r_(F)&&(F=yield F),F===!1||S.signal.aborted)throw{name:"ConditionError",message:"Aborted due to condition callback returning false."};let q=new Promise((G,Q)=>{x=()=>{Q({name:"AbortError",message:w||"Aborted"})},S.signal.addEventListener("abort",x,{once:!0})});h(i(g,f,n?.getPendingMeta?.({requestId:g,arg:f},{getState:C,extra:b}))),E=yield Promise.race([q,Promise.resolve(r(f,{dispatch:h,getState:C,extra:b,requestId:g,signal:S.signal,abort:R,rejectWithValue:(G,Q)=>new dh(G,Q),fulfillWithValue:(G,Q)=>new eC(G,Q)})).then(G=>{if(G instanceof dh)throw G;return G instanceof eC?o(G.payload,g,f,G.meta):o(G,g,f)})])}catch(F){E=F instanceof dh?a(null,g,f,F.payload,F.meta):a(F,g,f)}finally{x&&S.signal.removeEventListener("abort",x)}return n&&!n.dispatchConditionRejection&&a.match(E)&&E.meta.condition||h(E),E})();return Object.assign(P,{abort:R,requestId:g,arg:f,unwrap(){return P.then(t_)}})}}return Object.assign(p,{pending:i,rejected:a,fulfilled:o,settled:Lr(a,o),typePrefix:t})}return e.withTypes=()=>e,e})();function t_(e){if(e.meta&&e.meta.rejectedWithValue)throw e.payload;if(e.error)throw e.error;return e.payload}function r_(e){return e!==null&&typeof e=="object"&&typeof e.then=="function"}var uC=Symbol.for("rtk-slice-createasyncthunk"),mz={[uC]:pe};function n_(e,t){return`${e}/${t}`}function o_({creators:e}={}){let t=e?.asyncThunk?.[uC];return function(n){let{name:o,reducerPath:i=o}=n;if(!o)throw new Error(Ht(11));typeof process<"u";let a=(typeof n.reducers=="function"?n.reducers(a_()):n.reducers)||{},p=Object.keys(a),f={sliceCaseReducersByName:{},sliceCaseReducersByType:{},actionCreators:{},sliceMatchers:[]},m={addCase(E,_){let F=typeof E=="string"?E:E.type;if(!F)throw new Error(Ht(12));if(F in f.sliceCaseReducersByType)throw new Error(Ht(13));return f.sliceCaseReducersByType[F]=_,m},addMatcher(E,_){return f.sliceMatchers.push({matcher:E,reducer:_}),m},exposeAction(E,_){return f.actionCreators[E]=_,m},exposeCaseReducer(E,_){return f.sliceCaseReducersByName[E]=_,m}};p.forEach(E=>{let _=a[E],F={reducerName:E,type:n_(o,E),createNotation:typeof n.reducers=="function"};c_(_)?l_(F,_,m,t):s_(F,_,m)});function h(){let[E={},_=[],F=void 0]=typeof n.extraReducers=="function"?sC(n.extraReducers):[n.extraReducers],q={...E,...f.sliceCaseReducersByType};return le(n.initialState,G=>{for(let Q in q)G.addCase(Q,q[Q]);for(let Q of f.sliceMatchers)G.addMatcher(Q.matcher,Q.reducer);for(let Q of _)G.addMatcher(Q.matcher,Q.reducer);F&&G.addDefaultCase(F)})}let C=E=>E,b=new Map,g=new WeakMap,S;function x(E,_){return S||(S=h()),S(E,_)}function w(){return S||(S=h()),S.getInitialState()}function R(E,_=!1){function F(G){let Q=G[E];return typeof Q>"u"&&_&&(Q=al(g,F,w)),Q}function q(G=C){let Q=al(b,_,()=>new WeakMap);return al(Q,G,()=>{let j={};for(let[B,L]of Object.entries(n.selectors??{}))j[B]=i_(L,G,()=>al(g,G,w),_);return j})}return{reducerPath:E,getSelectors:q,get selectors(){return q(F)},selectSlice:F}}let P={name:o,reducer:x,actions:f.actionCreators,caseReducers:f.sliceCaseReducersByName,getInitialState:w,...R(i),injectInto(E,{reducerPath:_,...F}={}){let q=_??i;return E.inject({reducerPath:q,reducer:x},F),{...P,...R(q,!0)}}};return P}}function i_(e,t,r,n){function o(i,...a){let p=t(i);return typeof p>"u"&&n&&(p=r()),e(p,...a)}return o.unwrapped=e,o}var Uo=o_();function a_(){function e(t,r){return{_reducerDefinitionType:"asyncThunk",payloadCreator:t,...r}}return e.withTypes=()=>e,{reducer(t){return Object.assign({[t.name](...r){return t(...r)}}[t.name],{_reducerDefinitionType:"reducer"})},preparedReducer(t,r){return{_reducerDefinitionType:"reducerWithPrepare",prepare:t,reducer:r}},asyncThunk:e}}function s_({type:e,reducerName:t,createNotation:r},n,o){let i,a;if("reducer"in n){if(r&&!u_(n))throw new Error(Ht(17));i=n.reducer,a=n.prepare}else i=n;o.addCase(e,i).exposeCaseReducer(t,i).exposeAction(t,a?T(e,a):T(e))}function c_(e){return e._reducerDefinitionType==="asyncThunk"}function u_(e){return e._reducerDefinitionType==="reducerWithPrepare"}function l_({type:e,reducerName:t},r,n,o){if(!o)throw new Error(Ht(18));let{payloadCreator:i,fulfilled:a,pending:p,rejected:f,settled:m,options:h}=r,C=o(e,i,h);n.exposeAction(t,C),a&&n.addCase(C.fulfilled,a),p&&n.addCase(C.pending,p),f&&n.addCase(C.rejected,f),m&&n.addMatcher(C.settled,m),n.exposeCaseReducer(t,{fulfilled:a||sl,pending:p||sl,rejected:f||sl,settled:m||sl})}function sl(){}var d_="task",lC="listener",dC="completed",mh="cancelled",p_=`task-${mh}`,f_=`task-${dC}`,ph=`${lC}-${mh}`,m_=`${lC}-${dC}`,fl=class{constructor(e){De(this,"name","TaskAbortError");De(this,"message");this.code=e,this.message=`${d_} ${mh} (reason: ${e})`}},gh=(e,t)=>{if(typeof e!="function")throw new TypeError(Ht(32))},cl=()=>{},pC=(e,t=cl)=>(e.catch(t),e),fC=(e,t)=>(e.addEventListener("abort",t,{once:!0}),()=>e.removeEventListener("abort",t)),jo=e=>{if(e.aborted)throw new fl(e.reason)};function mC(e,t){let r=cl;return new Promise((n,o)=>{let i=()=>o(new fl(e.reason));if(e.aborted){i();return}r=fC(e,i),t.finally(()=>r()).then(n,o)}).finally(()=>{r=cl})}var g_=/*#__PURE__*/function(){var _ref5=_asyncToGenerator(function*(e,t){try{return yield Promise.resolve(),{status:"ok",value:yield e()}}catch(r){return{status:r instanceof fl?"cancelled":"rejected",error:r}}finally{t?.()}});return function g_(_x7,_x8){return _ref5.apply(this,arguments)}}(),ul=e=>t=>pC(mC(e,t).then(r=>(jo(e),r))),gC=e=>{let t=ul(e);return r=>t(new Promise(n=>setTimeout(n,r)))},{assign:Xi}=Object,rC={},ml="listenerMiddleware",h_=(e,t)=>{let r=n=>fC(e,()=>n.abort(e.reason));return(n,o)=>{gh(n,"taskExecutor");let i=new s.AbortController;r(i);let a=g_(/*#__PURE__*/_asyncToGenerator(function*(){jo(e),jo(i.signal);let p=yield n({pause:ul(i.signal),delay:gC(i.signal),signal:i.signal});return jo(i.signal),p}),()=>i.abort(f_));return o?.autoJoin&&t.push(a.catch(cl)),{result:ul(e)(a),cancel(){i.abort(p_)}}}},y_=(e,t)=>{let r=/*#__PURE__*/function(){var _ref7=_asyncToGenerator(function*(n,o){jo(t);let i=()=>{},p=[new Promise((f,m)=>{let h=e({predicate:n,effect:(C,b)=>{b.unsubscribe(),f([C,b.getState(),b.getOriginalState()])}});i=()=>{h(),m()}})];o!=null&&p.push(new Promise(f=>setTimeout(f,o,null)));try{let f=yield mC(t,Promise.race(p));return jo(t),f}finally{i()}});return function r(_x9,_x0){return _ref7.apply(this,arguments)}}();return(n,o)=>pC(r(n,o))},hC=e=>{let{type:t,actionCreator:r,matcher:n,predicate:o,effect:i}=e;if(t)o=T(t).match;else if(r)t=r.type,o=r.match;else if(n)o=n;else if(!o)throw new Error(Ht(21));return gh(i,"options.listener"),{predicate:o,type:t,effect:i}},yC=Xi(e=>{let{type:t,predicate:r,effect:n}=hC(e);return{id:Ac(),effect:n,type:t,predicate:r,pending:new Set,unsubscribe:()=>{throw new Error(Ht(22))}}},{withTypes:()=>yC}),nC=(e,t)=>{let{type:r,effect:n,predicate:o}=hC(t);return Array.from(e.values()).find(i=>(typeof r=="string"?i.type===r:i.predicate===o)&&i.effect===n)},fh=e=>{e.pending.forEach(t=>{t.abort(ph)})},S_=(e,t)=>()=>{for(let r of t.keys())fh(r);e.clear()},oC=(e,t,r)=>{try{e(t,r)}catch(n){setTimeout(()=>{throw n},0)}},SC=Xi(T(`${ml}/add`),{withTypes:()=>SC}),v_=T(`${ml}/removeAll`),vC=Xi(T(`${ml}/remove`),{withTypes:()=>vC}),A_=(...e)=>{console.error(`${ml}/error`,...e)},AC=(e={})=>{let t=new Map,r=new Map,n=g=>{let S=r.get(g)??0;r.set(g,S+1)},o=g=>{let S=r.get(g)??1;S===1?r.delete(g):r.set(g,S-1)},{extra:i,onError:a=A_}=e;gh(a,"onError");let p=g=>(g.unsubscribe=()=>t.delete(g.id),t.set(g.id,g),S=>{g.unsubscribe(),S?.cancelActive&&fh(g)}),f=g=>{let S=nC(t,g)??yC(g);return p(S)};Xi(f,{withTypes:()=>f});let m=g=>{let S=nC(t,g);return S&&(S.unsubscribe(),g.cancelActive&&fh(S)),!!S};Xi(m,{withTypes:()=>m});let h=/*#__PURE__*/function(){var _ref8=_asyncToGenerator(function*(g,S,x,w){let R=new s.AbortController,P=y_(f,R.signal),E=[];try{g.pending.add(R),n(g),yield Promise.resolve(g.effect(S,Xi({},x,{getOriginalState:w,condition:(_,F)=>P(_,F).then(Boolean),take:P,delay:gC(R.signal),pause:ul(R.signal),extra:i,signal:R.signal,fork:h_(R.signal,E),unsubscribe:g.unsubscribe,subscribe:()=>{t.set(g.id,g)},cancelActiveListeners:()=>{g.pending.forEach((_,F,q)=>{_!==R&&(_.abort(ph),q.delete(_))})},cancel:()=>{R.abort(ph),g.pending.delete(R)},throwIfCancelled:()=>{jo(R.signal)}})))}catch(_){_ instanceof fl||oC(a,_,{raisedBy:"effect"})}finally{yield Promise.all(E),R.abort(m_),o(g),g.pending.delete(R)}});return function h(_x1,_x10,_x11,_x12){return _ref8.apply(this,arguments)}}(),C=S_(t,r);return{middleware:g=>S=>x=>{if(!rc(x))return S(x);if(SC.match(x))return f(x.payload);if(v_.match(x)){C();return}if(vC.match(x))return m(x.payload);let w=g.getState(),R=()=>{if(w===rC)throw new Error(Ht(23));return w},P;try{if(P=S(x),t.size>0){let E=g.getState(),_=Array.from(t.values());for(let F of _){let q=!1;try{q=F.predicate(x,E,w)}catch(G){q=!1,oC(a,G,{raisedBy:"predicate"})}q&&h(F,x,g,R)}}}finally{w=rC}return P},startListening:f,stopListening:m,clearListeners:C}};function Ht(e){return`Minified Redux Toolkit error #${e}; visit https://redux-toolkit.js.org/Errors?code=${e} for the full message or use the non-minified dev environment for full errors. `}d();c();l();u();d();c();l();u();d();c();l();u();function CC(){let e=typeof window<"u";return{sendMessage(t){e&&window.postMessage(t,"*")}}}d();c();l();u();d();c();l();u();d();c();l();u();var bC=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/i;function C_(e){return typeof e=="string"&&bC.test(e)}var hh=C_;d();c();l();u();var Tt=[];for(let e=0;e<256;++e)Tt.push((e+256).toString(16).slice(1));function xC(e,t=0){return(Tt[e[t+0]]+Tt[e[t+1]]+Tt[e[t+2]]+Tt[e[t+3]]+"-"+Tt[e[t+4]]+Tt[e[t+5]]+"-"+Tt[e[t+6]]+Tt[e[t+7]]+"-"+Tt[e[t+8]]+Tt[e[t+9]]+"-"+Tt[e[t+10]]+Tt[e[t+11]]+Tt[e[t+12]]+Tt[e[t+13]]+Tt[e[t+14]]+Tt[e[t+15]]).toLowerCase()}d();c();l();u();var yh,b_=new Uint8Array(16);function Sh(){if(!yh){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");yh=crypto.getRandomValues.bind(crypto)}return yh(b_)}d();c();l();u();d();c();l();u();var x_=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),vh={randomUUID:x_};function w_(e,t,r){e=e||{};let n=e.random??e.rng?.()??Sh();if(n.length<16)throw new Error("Random bytes length must be >= 16");if(n[6]=n[6]&15|64,n[8]=n[8]&63|128,t){if(r=r||0,r<0||r+16>t.length)throw new RangeError(`UUID byte range ${r}:${r+15} is out of buffer bounds`);for(let o=0;o<16;++o)t[r+o]=n[o];return t}return xC(n)}function R_(e,t,r){return vh.randomUUID&&!t&&!e?vh.randomUUID():w_(e,t,r)}var Ah=R_;function I_(_x13){return _I_.apply(this,arguments)}function _I_(){_I_=_asyncToGenerator(function*({config:e,environment:t,event:r,listenerManager:n}){let{url:o,token:i,mode:a}=e;if(a!=="disabled")return n.call(r),t.send(o,i,r)});return _I_.apply(this,arguments)}var TC="2.1.1",Ch=128,PC=192,wC=224,RC=240,E_=248;function F_(e){return(e&E_)===RC?4:(e&RC)===wC?3:(e&wC)===PC?2:1}function T_(e,t){if(t<0||e.length<=t)return e;let r=e.indexOf("%",t-2);for(r<0||r>t?r=t:t=r;r>2&&e.charAt(r-3)=="%";){let n=Number.parseInt(e.substring(r-2,r),16);if((n&Ch)!=Ch)break;if(r-=3,(n&PC)!=Ch){t-r>=F_(n)*3&&(r=t);break}}return e.substring(0,r)}function P_(e){let{trackingId:t}=e;return{trackingId:t}}function k_(e){return(e.source||[]).concat([`relay@${TC}`])}function kC(e,t,r){let{getReferrer:n,getLocation:o,getUserAgent:i}=r,a=P_(t),p=r.getClientId();return Object.freeze({type:e,config:a,ts:Date.now(),source:k_(t),clientId:p,userAgent:i(),referrer:IC(n()),location:IC(o())})}function IC(e){return e!==null?T_(e,1024):null}function O_(e,t,r,n){return{...t,meta:kC(e,r,n)}}var __="*";function N_(){let e=[];function t({type:f,callback:m}){return e.findIndex(h=>h.type===f&&h.callback===m)}function r(f,m){return f.type==="*"||m===f.type}function n(f){return t(f)<0&&e.push(f),()=>p(f.type,f.callback)}function o(f){e.forEach(m=>{if(r(m,f.meta.type))try{m.callback(f)}catch(h){console.error(h)}})}function i(f){if(f===__)e.length=0;else for(let m=e.length-1;m>=0;m--)e[m].type===f&&e.splice(m,1)}function a(f){let m=t(f);m>=0&&e.splice(m,1)}function p(f,m){m?a({type:f,callback:m}):i(f)}return{add:n,call:o,remove:p}}function EC({url:e,token:t,trackingId:r,...n}){return Object.freeze({url:e,token:t,trackingId:r,...(!!n.mode&&{mode:n.mode}),...(!!n.source&&{source:n.source}),...(!!n.environment&&{environment:n.environment})})}function D_(e){let t=EC(e);return{get:()=>t,update:r=>{t=EC({...t,...r})}}}var bh=q_();function q_(){let e="coveo_",t=r=>{let n=r.split(".").slice(-2);return n.length==2?n.join("."):""};return{getItem(r){let n=`${e}${r}=`,o=document.cookie.split(";");for(let i of o){let a=i.replace(/^\s+/,"");if(a.lastIndexOf(n,0)===0)return a.substring(n.length,a.length)}return null},setItem(r,n,o){let i=t(window.location.hostname),a=`;expires=${new Date(new Date().getTime()+o).toUTCString()}`,p=i?`;domain=${i}`:"";document.cookie=`${e}${r}=${n}${a}${p};path=/;SameSite=Lax`},removeItem(r){this.setItem(r,"",-1)}}}function M_(){return{getItem(e){return bh.getItem(e)||localStorage.getItem(e)},removeItem(e){bh.removeItem(e),localStorage.removeItem(e)},setItem(e,t){localStorage.setItem(e,t),bh.setItem(e,t,31556952e3)}}}var FC="visitorId";function V_(){let e=document.referrer;return e===""?null:e}function xh(){let e=M_();return{runtime:"browser",send:function(){var _ref9=_asyncToGenerator(function*(t,r,n){let o=v(t,{method:"POST",body:JSON.stringify([n]),keepalive:!0,headers:{"Content-Type":"application/json",Authorization:`Bearer ${r}`}});CC().sendMessage({kind:"EVENT_PROTOCOL",event:n,url:t,token:r});let a=yield o;if(a?.ok){let p;try{p=yield a.json()}catch{return}for(let f of p.events)if(!f.accepted)throw new Error(`Received event was rejected for processing: ${f.errorMessage}`)}else throw new Error(`Error ${a.status}: Failed to send the event(s).`)});return function send(_x14,_x15,_x16){return _ref9.apply(this,arguments)}}(),getReferrer:()=>V_(),getLocation:()=>window.location.href,getUserAgent:()=>navigator.userAgent,getClientId:()=>{let t=e.getItem(FC);if(t&&hh(t))return t;let r=Ah();return e.setItem(FC,r),r}}}function j_(){try{let e="__storage_test__";return localStorage.setItem(e,e),localStorage.removeItem(e),!0}catch(e){return e instanceof DOMException&&e.name==="QuotaExceededError"&&localStorage&&localStorage.length!==0}}function L_(){return{runtime:"null",send:()=>Promise.resolve(void 0),getReferrer:()=>null,getLocation:()=>null,getUserAgent:()=>null,getClientId:()=>""}}function U_(e){let t=e.get().mode!=="disabled",r=e.get().environment,n=L_();return t&&r?{...r,runtime:"custom"}:t&&Q_()&&j_()?xh():n}function Q_(){try{return typeof window=="object"}catch{return!1}}function B_(e){return{get:()=>Object.freeze(U_(e))}}function OC(e){let t=D_(e),r=N_(),n=B_(t);return{emit:function(){var _ref0=_asyncToGenerator(function*(o,i){let a=t.get(),p=n.get(),f=O_(o,i,a,p);return I_({config:a,environment:p,event:f,listenerManager:r})});return function emit(_x17,_x18){return _ref0.apply(this,arguments)}}(),getMeta:o=>kC(o,t.get(),n.get()),on:(o,i)=>r.add({type:o,callback:i}),off:(o,i)=>r.remove(o,i),updateConfig:o=>t.update(o),version:TC}}d();c();l();u();function _C(){return typeof window<"u"&&typeof document<"u"}d();c();l();u();d();c();l();u();var Gn="3.48.1",NC=["@coveo/atomic","@coveo/quantic"];var ea=ct(e=>e.source,e=>Object.entries(e).map(([t,r])=>`${t}@${r}`).concat(`@coveo/headless@${Gn}`));var Cc=ct(e=>e.configuration.organizationId,e=>e.configuration.environment,e=>e.configuration.accessToken,e=>e.configuration.analytics,e=>ea(e.configuration.analytics),(e,t)=>t,(e,t,r,{trackingId:n,apiBaseUrl:o,enabled:i},a,p)=>{let f=$_(p);return OC({mode:i?"emit":"disabled",url:o??Du(e,t),token:r,trackingId:n??null,source:a,environment:f})}),G_={getClientId:()=>"",getLocation:()=>null,getReferrer:()=>null,getUserAgent:()=>null,send:function(){var _ref1=_asyncToGenerator(function*(){});return function send(){return _ref1.apply(this,arguments)}}()},$_=e=>{if(!e)return;let t=e();return{...(_C()?xh():G_),getClientId:()=>t.clientId,getLocation:()=>t.location,getReferrer:()=>t.referrer,getUserAgent:()=>t.userAgent}};d();c();l();u();d();c();l();u();function Ur(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var o=0,n=Object.getOwnPropertySymbols(e);o<n.length;o++)t.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(e,n[o])&&(r[n[o]]=e[n[o]]);return r}function U(e,t,r,n){function o(i){return i instanceof r?i:new r(function(a){a(i)})}return new(r||(r=Promise))(function(i,a){function p(h){try{m(n.next(h))}catch(C){a(C)}}function f(h){try{m(n.throw(h))}catch(C){a(C)}}function m(h){h.done?i(h.value):o(h.value).then(p,f)}m((n=n.apply(e,t||[])).next())})}var Oe;(function(e){e.search="search",e.click="click",e.custom="custom",e.view="view",e.collect="collect"})(Oe||(Oe={}));function Ih(){return typeof window<"u"}function Lh(){return typeof navigator<"u"}function ta(){return typeof document<"u"}function Eh(){try{return typeof localStorage<"u"}catch{return!1}}function H_(){try{return typeof sessionStorage<"u"}catch{return!1}}function zC(){return Lh()&&navigator.cookieEnabled}var z_=[Oe.click,Oe.custom,Oe.search,Oe.view],W_=(e,t)=>z_.indexOf(e)!==-1?Object.assign({language:ta()?document.documentElement.lang:"unknown",userAgent:Lh()?navigator.userAgent:"unknown"},t):t,xc=class e{static set(t,r,n){var o,i,a,p;n&&(i=new Date,i.setTime(i.getTime()+n)),p=window.location.hostname,p.indexOf(".")===-1?DC(t,r,i):(a=p.split("."),o=a[a.length-2]+"."+a[a.length-1],DC(t,r,i,o))}static get(t){for(var r=t+"=",n=document.cookie.split(";"),o=0;o<n.length;o++){var i=n[o];if(i=i.replace(/^\s+/,""),i.lastIndexOf(r,0)===0)return i.substring(r.length,i.length)}return null}static erase(t){e.set(t,"",-1)}};function DC(e,t,r,n){document.cookie=`${e}=${t}`+(r?`;expires=${r.toUTCString()}`:"")+(n?`;domain=${n}`:"")+";path=/;SameSite=Lax"}function Y_(){return Eh()?localStorage:zC()?new wc:H_()?sessionStorage:new na}var wc=class e{getItem(t){return xc.get(`${e.prefix}${t}`)}removeItem(t){xc.erase(`${e.prefix}${t}`)}setItem(t,r,n){xc.set(`${e.prefix}${t}`,r,n)}};wc.prefix="coveo_";var Fh=class{constructor(){this.cookieStorage=new wc}getItem(t){return localStorage.getItem(t)||this.cookieStorage.getItem(t)}removeItem(t){this.cookieStorage.removeItem(t),localStorage.removeItem(t)}setItem(t,r){localStorage.setItem(t,r),this.cookieStorage.setItem(t,r,31556926e3)}},na=class{getItem(t){return null}removeItem(t){}setItem(t,r){}},gl="__coveo.analytics.history",K_=20,X_=1e3*60,J_=75,Sl=class{constructor(t){this.store=t||Y_()}addElement(t){t.internalTime=new Date().getTime(),t=this.cropQueryElement(this.stripEmptyQuery(t));let r=this.getHistoryWithInternalTime();r!=null?this.isValidEntry(t)&&this.setHistory([t].concat(r)):this.setHistory([t])}addElementAsync(t){return U(this,void 0,void 0,function*(){t.internalTime=new Date().getTime(),t=this.cropQueryElement(this.stripEmptyQuery(t));let r=yield this.getHistoryWithInternalTimeAsync();r!=null?this.isValidEntry(t)&&this.setHistory([t].concat(r)):this.setHistory([t])})}getHistory(){let t=this.getHistoryWithInternalTime();return this.stripEmptyQueries(this.stripInternalTime(t))}getHistoryAsync(){return U(this,void 0,void 0,function*(){let t=yield this.getHistoryWithInternalTimeAsync();return this.stripEmptyQueries(this.stripInternalTime(t))})}getHistoryWithInternalTime(){try{let t=this.store.getItem(gl);return t&&typeof t=="string"?JSON.parse(t):[]}catch{return[]}}getHistoryWithInternalTimeAsync(){return U(this,void 0,void 0,function*(){try{let t=yield this.store.getItem(gl);return t?JSON.parse(t):[]}catch{return[]}})}setHistory(t){try{this.store.setItem(gl,JSON.stringify(t.slice(0,K_)))}catch{}}clear(){try{this.store.removeItem(gl)}catch{}}getMostRecentElement(){let t=this.getHistoryWithInternalTime();return Array.isArray(t)?t.sort((n,o)=>(o.internalTime||0)-(n.internalTime||0))[0]:null}cropQueryElement(t){return t.name&&t.value&&t.name.toLowerCase()==="query"&&(t.value=t.value.slice(0,J_)),t}isValidEntry(t){let r=this.getMostRecentElement();return r&&r.value==t.value?(t.internalTime||0)-(r.internalTime||0)>X_:!0}stripInternalTime(t){return Array.isArray(t)?t.map(r=>{let{name:n,time:o,value:i}=r;return{name:n,time:o,value:i}}):[]}stripEmptyQuery(t){let{name:r,time:n,value:o}=t;return r&&typeof o=="string"&&r.toLowerCase()==="query"&&o.trim()===""?{name:r,time:n}:t}stripEmptyQueries(t){return t.map(r=>this.stripEmptyQuery(r))}};var Z_=(e,t)=>U(void 0,void 0,void 0,function*(){return e===Oe.view?(yield eN(t.contentIdValue),Object.assign({location:window.location.toString(),referrer:document.referrer,title:document.title},t)):t}),eN=e=>U(void 0,void 0,void 0,function*(){let t=new Sl,r={name:"PageView",value:e,time:new Date().toISOString()};yield t.addElementAsync(r)}),hl,tN=new Uint8Array(16);function rN(){if(!hl&&(hl=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!hl))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return hl(tN)}var nN=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;function vl(e){return typeof e=="string"&&nN.test(e)}var Pt=[];for(let e=0;e<256;++e)Pt.push((e+256).toString(16).slice(1));function WC(e,t=0){return Pt[e[t+0]]+Pt[e[t+1]]+Pt[e[t+2]]+Pt[e[t+3]]+"-"+Pt[e[t+4]]+Pt[e[t+5]]+"-"+Pt[e[t+6]]+Pt[e[t+7]]+"-"+Pt[e[t+8]]+Pt[e[t+9]]+"-"+Pt[e[t+10]]+Pt[e[t+11]]+Pt[e[t+12]]+Pt[e[t+13]]+Pt[e[t+14]]+Pt[e[t+15]]}function oN(e){if(!vl(e))throw TypeError("Invalid UUID");let t,r=new Uint8Array(16);return r[0]=(t=parseInt(e.slice(0,8),16))>>>24,r[1]=t>>>16&255,r[2]=t>>>8&255,r[3]=t&255,r[4]=(t=parseInt(e.slice(9,13),16))>>>8,r[5]=t&255,r[6]=(t=parseInt(e.slice(14,18),16))>>>8,r[7]=t&255,r[8]=(t=parseInt(e.slice(19,23),16))>>>8,r[9]=t&255,r[10]=(t=parseInt(e.slice(24,36),16))/1099511627776&255,r[11]=t/4294967296&255,r[12]=t>>>24&255,r[13]=t>>>16&255,r[14]=t>>>8&255,r[15]=t&255,r}function iN(e){e=unescape(encodeURIComponent(e));let t=[];for(let r=0;r<e.length;++r)t.push(e.charCodeAt(r));return t}var aN="6ba7b810-9dad-11d1-80b4-00c04fd430c8",sN="6ba7b811-9dad-11d1-80b4-00c04fd430c8";function cN(e,t,r){function n(o,i,a,p){var f;if(typeof o=="string"&&(o=iN(o)),typeof i=="string"&&(i=oN(i)),((f=i)===null||f===void 0?void 0:f.length)!==16)throw TypeError("Namespace must be array-like (16 iterable integer values, 0-255)");let m=new Uint8Array(16+o.length);if(m.set(i),m.set(o,i.length),m=r(m),m[6]=m[6]&15|t,m[8]=m[8]&63|128,a){p=p||0;for(let h=0;h<16;++h)a[p+h]=m[h];return a}return WC(m)}try{n.name=e}catch{}return n.DNS=aN,n.URL=sN,n}var uN=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),qC={randomUUID:uN};function Qo(e,t,r){if(qC.randomUUID&&!t&&!e)return qC.randomUUID();e=e||{};let n=e.random||(e.rng||rN)();if(n[6]=n[6]&15|64,n[8]=n[8]&63|128,t){r=r||0;for(let o=0;o<16;++o)t[r+o]=n[o];return t}return WC(n)}function lN(e,t,r,n){switch(e){case 0:return t&r^~t&n;case 1:return t^r^n;case 2:return t&r^t&n^r&n;case 3:return t^r^n}}function wh(e,t){return e<<t|e>>>32-t}function dN(e){let t=[1518500249,1859775393,2400959708,3395469782],r=[1732584193,4023233417,2562383102,271733878,3285377520];if(typeof e=="string"){let a=unescape(encodeURIComponent(e));e=[];for(let p=0;p<a.length;++p)e.push(a.charCodeAt(p))}else Array.isArray(e)||(e=Array.prototype.slice.call(e));e.push(128);let n=e.length/4+2,o=Math.ceil(n/16),i=new Array(o);for(let a=0;a<o;++a){let p=new Uint32Array(16);for(let f=0;f<16;++f)p[f]=e[a*64+f*4]<<24|e[a*64+f*4+1]<<16|e[a*64+f*4+2]<<8|e[a*64+f*4+3];i[a]=p}i[o-1][14]=(e.length-1)*8/Math.pow(2,32),i[o-1][14]=Math.floor(i[o-1][14]),i[o-1][15]=(e.length-1)*8&4294967295;for(let a=0;a<o;++a){let p=new Uint32Array(80);for(let g=0;g<16;++g)p[g]=i[a][g];for(let g=16;g<80;++g)p[g]=wh(p[g-3]^p[g-8]^p[g-14]^p[g-16],1);let f=r[0],m=r[1],h=r[2],C=r[3],b=r[4];for(let g=0;g<80;++g){let S=Math.floor(g/20),x=wh(f,5)+lN(S,m,h,C)+b+t[S]+p[g]>>>0;b=C,C=h,h=wh(m,30)>>>0,m=f,f=x}r[0]=r[0]+f>>>0,r[1]=r[1]+m>>>0,r[2]=r[2]+h>>>0,r[3]=r[3]+C>>>0,r[4]=r[4]+b>>>0}return[r[0]>>24&255,r[0]>>16&255,r[0]>>8&255,r[0]&255,r[1]>>24&255,r[1]>>16&255,r[1]>>8&255,r[1]&255,r[2]>>24&255,r[2]>>16&255,r[2]>>8&255,r[2]&255,r[3]>>24&255,r[3]>>16&255,r[3]>>8&255,r[3]&255,r[4]>>24&255,r[4]>>16&255,r[4]>>8&255,r[4]&255]}var pN=cN("v5",80,dN),MC=pN,YC="2.30.54",VC=e=>`${e.protocol}//${e.hostname}${e.pathname.indexOf("/")===0?e.pathname:`/${e.pathname}`}${e.search}`,bc={pageview:"pageview",event:"event"},Al=class{constructor({client:t,uuidGenerator:r=Qo}){this.client=t,this.uuidGenerator=r}},Th=class extends Al{constructor({client:t,uuidGenerator:r=Qo}){super({client:t,uuidGenerator:r}),this.actionData={},this.pageViewId=r(),this.nextPageViewId=this.pageViewId,this.currentLocation=VC(window.location),this.lastReferrer=ta()?document.referrer:"",this.addHooks()}getApi(t){return t==="setAction"?this.setAction:null}setAction(t,r){this.action=t,this.actionData=r}clearData(){this.clearPluginData(),this.action=void 0,this.actionData={}}getLocationInformation(t,r){return Object.assign({hitType:t},this.getNextValues(t,r))}updateLocationInformation(t,r){this.updateLocationForNextPageView(t,r)}getDefaultContextInformation(t){let r={title:ta()?document.title:"",encoding:ta()?document.characterSet:"UTF-8"},n={screenResolution:`${screen.width}x${screen.height}`,screenColor:`${screen.colorDepth}-bit`},o={language:navigator.language,userAgent:navigator.userAgent},i={time:Date.now(),eventId:this.uuidGenerator()};return Object.assign(Object.assign(Object.assign(Object.assign({},i),n),o),r)}updateLocationForNextPageView(t,r){let{pageViewId:n,referrer:o,location:i}=this.getNextValues(t,r);this.lastReferrer=o,this.pageViewId=n,this.currentLocation=i,t===bc.pageview&&(this.nextPageViewId=this.uuidGenerator(),this.hasSentFirstPageView=!0)}getNextValues(t,r){return{pageViewId:t===bc.pageview?this.nextPageViewId:this.pageViewId,referrer:t===bc.pageview&&this.hasSentFirstPageView?this.currentLocation:this.lastReferrer,location:t===bc.pageview?this.getCurrentLocationFromPayload(r):this.currentLocation}}getCurrentLocationFromPayload(t){if(t.page){let r=o=>o.replace(/^\/?(.*)$/,"/$1");return`${(o=>o.split("/").slice(0,3).join("/"))(this.currentLocation)}${r(t.page)}`}else return VC(window.location)}},$n=class e{constructor(t,r){if(!vl(t))throw Error("Not a valid uuid");this.clientId=t,this.creationDate=Math.floor(r/1e3)}toString(){return this.clientId.replace(/-/g,"")+"."+this.creationDate.toString()}get expired(){let t=Math.floor(Date.now()/1e3)-this.creationDate;return t<0||t>e.expirationTime}validate(t,r){return!this.expired&&this.matchReferrer(t,r)}matchReferrer(t,r){try{let n=new URL(t);return r.some(o=>new RegExp(o.replace(/\\/g,"\\\\").replace(/\./g,"\\.").replace(/\*/g,".*")+"$").test(n.host))}catch{return!1}}static fromString(t){let r=t.split(".");if(r.length!==2)return null;let[n,o]=r;if(n.length!==32||isNaN(parseInt(o)))return null;let i=n.substring(0,8)+"-"+n.substring(8,12)+"-"+n.substring(12,16)+"-"+n.substring(16,20)+"-"+n.substring(20,32);return vl(i)?new e(i,Number.parseInt(o)*1e3):null}};$n.cvo_cid="cvo_cid";$n.expirationTime=120;var Ph=class extends Al{constructor({client:t,uuidGenerator:r=Qo}){super({client:t,uuidGenerator:r})}getApi(t){switch(t){case"decorate":return this.decorate;case"acceptFrom":return this.acceptFrom;default:return null}}decorate(t){return U(this,void 0,void 0,function*(){if(!this.client.getCurrentVisitorId)throw new Error("Could not retrieve current clientId");try{let r=new URL(t),n=yield this.client.getCurrentVisitorId();return r.searchParams.set($n.cvo_cid,new $n(n,Date.now()).toString()),r.toString()}catch{throw new Error("Invalid URL provided")}})}acceptFrom(t){this.client.setAcceptedLinkReferrers(t)}};Ph.Id="link";var hr=Object.keys;function yl(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}var Rh=128,KC=192,jC=224,LC=240;function fN(e){return(e&248)===LC?4:(e&LC)===jC?3:(e&jC)===KC?2:1}function mN(e,t){if(t<0||e.length<=t)return e;let r=e.indexOf("%",t-2);for(r<0||r>t?r=t:t=r;r>2&&e.charAt(r-3)=="%";){let n=Number.parseInt(e.substring(r-2,r),16);if((n&Rh)!=Rh)break;if(r-=3,(n&KC)!=Rh){t-r>=fN(n)*3&&(r=t);break}}return e.substring(0,r)}var kh={id:"svc_ticket_id",subject:"svc_ticket_subject",description:"svc_ticket_description",category:"svc_ticket_category",productId:"svc_ticket_product_id",custom:"svc_ticket_custom"},gN=hr(kh).map(e=>kh[e]),hN=[...gN].join("|"),yN=new RegExp(`^(${hN}$)`),SN={svcAction:"svc_action",svcActionData:"svc_action_data"},vN=e=>hr(e).filter(t=>e[t]!==void 0).reduce((t,r)=>{let n=kh[r]||r;return Object.assign(Object.assign({},t),{[n]:e[r]})},{}),AN=e=>yN.test(e),CN=[AN],UC={id:"id",name:"nm",brand:"br",category:"ca",variant:"va",price:"pr",quantity:"qt",coupon:"cc",position:"ps",group:"group"},QC={id:"id",name:"nm",brand:"br",category:"ca",variant:"va",position:"ps",price:"pr",group:"group"},Mt={action:"pa",list:"pal",listSource:"pls"},Cl={id:"ti",revenue:"tr",tax:"tt",shipping:"ts",coupon:"tcc",affiliation:"ta",step:"cos",option:"col"},bN=["loyaltyCardId","loyaltyTier","thirdPartyPersona","companyName","favoriteStore","storeName","userIndustry","userRole","userDepartment","businessUnit"],Oh={id:"quoteId",affiliation:"quoteAffiliation"},_h={id:"reviewId",rating:"reviewRating",comment:"reviewComment"},xN={add:Mt,bookmark_add:Mt,bookmark_remove:Mt,click:Mt,checkout:Mt,checkout_option:Mt,detail:Mt,impression:Mt,remove:Mt,refund:Object.assign(Object.assign({},Mt),Cl),purchase:Object.assign(Object.assign({},Mt),Cl),quickview:Mt,quote:Object.assign(Object.assign({},Mt),Oh),review:Object.assign(Object.assign({},Mt),_h)},wN=hr(UC).map(e=>UC[e]),RN=hr(QC).map(e=>QC[e]),IN=hr(Mt).map(e=>Mt[e]),EN=hr(Cl).map(e=>Cl[e]),FN=hr(_h).map(e=>_h[e]),TN=hr(Oh).map(e=>Oh[e]),PN=[...wN,"custom"].join("|"),kN=[...RN,"custom"].join("|"),XC="(pr[0-9]+)",JC="(il[0-9]+pi[0-9]+)",ON=new RegExp(`^${XC}(${PN})$`),_N=new RegExp(`^(${JC}(${kN}))|(il[0-9]+nm)$`),NN=new RegExp(`^(${IN.join("|")})$`),DN=new RegExp(`^(${EN.join("|")})$`),qN=new RegExp(`^${XC}custom$`),MN=new RegExp(`^${JC}custom$`),VN=new RegExp(`^(${[...bN,...FN,...TN].join("|")})$`),jN=e=>ON.test(e),LN=e=>_N.test(e),UN=e=>NN.test(e),QN=e=>DN.test(e),BN=e=>VN.test(e),GN=[LN,jN,UN,QN,BN],$N=[qN,MN],HN={anonymizeIp:"aip"},zN={eventCategory:"ec",eventAction:"ea",eventLabel:"el",eventValue:"ev",page:"dp",visitorId:"cid",clientId:"cid",userId:"uid",currencyCode:"cu"},WN={hitType:"t",pageViewId:"pid",encoding:"de",location:"dl",referrer:"dr",screenColor:"sd",screenResolution:"sr",title:"dt",userAgent:"ua",language:"ul",eventId:"z",time:"tm"},YN=["contentId","contentIdKey","contentType","searchHub","tab","searchUid","permanentId","contentLocale","trackingId"],KN=Object.assign(Object.assign(Object.assign(Object.assign({},HN),zN),WN),YN.reduce((e,t)=>Object.assign(Object.assign({},e),{[t]:t}),{})),Nh=Object.assign(Object.assign({},KN),SN),XN=e=>{let t=!!e.action&&xN[e.action]||{};return hr(e).reduce((r,n)=>{let o=t[n]||Nh[n]||n;return Object.assign(Object.assign({},r),{[o]:e[n]})},{})},JN=hr(Nh).map(e=>Nh[e]),ZN=e=>JN.indexOf(e)!==-1,e0=e=>e==="custom",t0=e=>[...GN,...CN,ZN,e0].some(t=>t(e)),r0=e=>hr(e).reduce((t,r)=>{let n=n0(r);return n?Object.assign(Object.assign({},t),o0(n,e[r])):Object.assign(Object.assign({},t),{[r]:e[r]})},{}),n0=e=>{let t;return[...$N].every(r=>{var n;return t=(n=r.exec(e))===null||n===void 0?void 0:n[1],!t}),t},o0=(e,t)=>hr(t).reduce((r,n)=>Object.assign(Object.assign({},r),{[`${e}${n}`]:t[n]}),{}),Dh=class{constructor(t){this.opts=t}sendEvent(t,r){return U(this,void 0,void 0,function*(){if(!this.isAvailable())throw new Error("navigator.sendBeacon is not supported in this browser. Consider adding a polyfill like \"sendbeacon-polyfill\".");let{baseUrl:n,preprocessRequest:o}=this.opts,i=yield this.getQueryParamsForEventType(t),{url:a,payload:p}=yield this.preProcessRequestAsPotentialJSONString(`${n}/analytics/${t}?${i}`,r,o),f=this.encodeForEventType(t,p),m=new Blob([f],{type:"application/x-www-form-urlencoded"});navigator.sendBeacon(a,m)})}isAvailable(){return"sendBeacon"in navigator}deleteHttpCookieVisitorId(){return Promise.resolve()}preProcessRequestAsPotentialJSONString(t,r,n){return U(this,void 0,void 0,function*(){let o=t,i=r;if(n){let a=yield n({url:t,body:JSON.stringify(r)},"analyticsBeacon"),{url:p,body:f}=a;o=p||t;try{i=JSON.parse(f)}catch(m){console.error("Unable to process the request body as a JSON string",m)}}return{payload:i,url:o}})}encodeForEventType(t,r){return this.isEventTypeLegacy(t)?this.encodeEventToJson(t,r):this.encodeEventToJson(t,r,this.opts.token)}getQueryParamsForEventType(t){return U(this,void 0,void 0,function*(){let{token:r,visitorIdProvider:n}=this.opts,o=yield n.getCurrentVisitorId();return[r&&this.isEventTypeLegacy(t)?`access_token=${r}`:"",o?`visitorId=${o}`:"","discardVisitInfo=true"].filter(i=>!!i).join("&")})}isEventTypeLegacy(t){return[Oe.click,Oe.custom,Oe.search,Oe.view].indexOf(t)!==-1}encodeEventToJson(t,r,n){let o=`${t}Event=${encodeURIComponent(JSON.stringify(r))}`;return n&&(o=`access_token=${encodeURIComponent(n)}&${o}`),o}},qh=class{sendEvent(t,r){return U(this,void 0,void 0,function*(){return Promise.resolve()})}deleteHttpCookieVisitorId(){return U(this,void 0,void 0,function*(){return Promise.resolve()})}},BC=y.fetch,bl=class{constructor(t){this.opts=t}sendEvent(t,r){return U(this,void 0,void 0,function*(){let{baseUrl:n,visitorIdProvider:o,preprocessRequest:i}=this.opts,a=this.shouldAppendVisitorId(t)?yield this.getVisitorIdParam():"",p={url:`${n}/analytics/${t}${a}`,credentials:"include",mode:"cors",headers:this.getHeaders(),method:"POST",body:JSON.stringify(r)},f=Object.assign(Object.assign({},p),i?yield i(p,"analyticsFetch"):{}),{url:m}=f,h=Ur(f,["url"]),C;try{C=yield BC(m,h)}catch(b){console.error("An error has occured when sending the event.",b);return}if(C.ok){let b=yield C.json();return b.visitorId&&o.setCurrentVisitorId(b.visitorId),b}else{try{C.json()}catch{}throw console.error(`An error has occured when sending the "${t}" event.`,C,r),new Error(`An error has occurred when sending the "${t}" event. Check the console logs for more details.`)}})}deleteHttpCookieVisitorId(){return U(this,void 0,void 0,function*(){let{baseUrl:t}=this.opts,r=`${t}/analytics/visit`;yield BC(r,{headers:this.getHeaders(),method:"DELETE"})})}shouldAppendVisitorId(t){return[Oe.click,Oe.custom,Oe.search,Oe.view].indexOf(t)!==-1}getVisitorIdParam(){return U(this,void 0,void 0,function*(){let{visitorIdProvider:t}=this.opts,r=yield t.getCurrentVisitorId();return r?`?visitor=${r}`:""})}getHeaders(){let{token:t}=this.opts;return Object.assign(Object.assign({},t?{Authorization:`Bearer ${t}`}:{}),{"Content-Type":"application/json"})}},Mh=class{constructor(t,r){Eh()&&zC()?this.storage=new Fh:Eh()?this.storage=localStorage:(console.warn("BrowserRuntime detected no valid storage available.",this),this.storage=new na),this.client=new bl(t),this.beaconClient=new Dh(t),window.addEventListener("beforeunload",()=>{let n=r();for(let{eventType:o,payload:i}of n)this.beaconClient.sendEvent(o,i)})}getClientDependingOnEventType(t){return t==="click"&&this.beaconClient.isAvailable()?this.beaconClient:this.client}},Vh=class{constructor(t,r){this.storage=r||new na,this.client=new bl(t)}getClientDependingOnEventType(t){return this.client}},xl=class{constructor(){this.storage=new na,this.client=new qh}getClientDependingOnEventType(t){return this.client}},i0="xx",a0=e=>e?.startsWith(i0)||!1,s0=`
28
28
  We've detected you're using React Native but have not provided the corresponding runtime,
29
29
  for an optimal experience please use the "coveo.analytics/react-native" subpackage.
30
30
  Follow the Readme on how to set it up: https://github.com/coveo/coveo.analytics.js#using-react-native
@@ -38,7 +38,7 @@ Patch operations: ${JSON.stringify(b,null,2)}
38
38
  Error: ${S}`)}}return f()}case V.MESSAGES_SNAPSHOT:{let C=yield We(n,o,i,(b,g,S)=>b.onMessagesSnapshotEvent?.({event:m,messages:g,state:S,agent:r,input:e}));if(p(C),C.stopPropagation!==!0){let{messages:b}=m;o=b,p({messages:o})}return f()}case V.ACTIVITY_SNAPSHOT:{let C=m,b=o.findIndex(R=>R.id===C.messageId),g=b>=0?o[b]:void 0,S=g?.role==="activity"?g:void 0,x=C.replace??!0,w=yield We(n,o,i,(R,P,E)=>R.onActivitySnapshotEvent?.({event:C,messages:P,state:E,agent:r,input:e,activityMessage:S,existingMessage:g}));if(p(w),w.stopPropagation!==!0){let R={id:C.messageId,role:"activity",activityType:C.activityType,content:Ze(C.content)},P;b===-1?(o.push(R),P=R):S?x&&(o[b]={...S,activityType:C.activityType,content:Ze(C.content)}):x&&(o[b]=R,P=R),p({messages:o}),P&&(yield Promise.all(n.map(E=>E.onNewMessage?.({message:P,messages:o,state:i,agent:r,input:e}))))}return f()}case V.ACTIVITY_DELTA:{let C=m,b=o.findIndex(w=>w.id===C.messageId);if(b===-1)return console.warn(`ACTIVITY_DELTA: No message found with ID '${C.messageId}' to apply patch`),f();let g=o[b];if(g.role!=="activity")return console.warn(`ACTIVITY_DELTA: Message '${C.messageId}' is not an activity message`),f();let S=g,x=yield We(n,o,i,(w,R,P)=>w.onActivityDeltaEvent?.({event:C,messages:R,state:P,agent:r,input:e,activityMessage:S}));if(p(x),x.stopPropagation!==!0)try{let w=Ze(S.content??{}),R=po(w,C.patch??[],!0,!1).newDocument;o[b]={...S,content:Ze(R),activityType:C.activityType},p({messages:o})}catch(w){let R=w instanceof Error?w.message:String(w);console.warn(`Failed to apply activity patch for '${C.messageId}': ${R}`)}return f()}case V.RAW:return p(yield We(n,o,i,(C,b,g)=>C.onRawEvent?.({event:m,messages:b,state:g,agent:r,input:e}))),f();case V.CUSTOM:return p(yield We(n,o,i,(C,b,g)=>C.onCustomEvent?.({event:m,messages:b,state:g,agent:r,input:e}))),f();case V.RUN_STARTED:{let C=yield We(n,o,i,(b,g,S)=>b.onRunStartedEvent?.({event:m,messages:g,state:S,agent:r,input:e}));if(p(C),C.stopPropagation!==!0){let b=m;if(b.input?.messages){for(let g of b.input.messages)o.find(S=>S.id===g.id)||o.push(g);p({messages:o})}}return f()}case V.RUN_FINISHED:return p(yield We(n,o,i,(C,b,g)=>C.onRunFinishedEvent?.({event:m,messages:b,state:g,agent:r,input:e,result:m.result}))),f();case V.RUN_ERROR:return p(yield We(n,o,i,(C,b,g)=>C.onRunErrorEvent?.({event:m,messages:b,state:g,agent:r,input:e}))),f();case V.STEP_STARTED:return p(yield We(n,o,i,(C,b,g)=>C.onStepStartedEvent?.({event:m,messages:b,state:g,agent:r,input:e}))),f();case V.STEP_FINISHED:return p(yield We(n,o,i,(C,b,g)=>C.onStepFinishedEvent?.({event:m,messages:b,state:g,agent:r,input:e}))),f();case V.TEXT_MESSAGE_CHUNK:throw Error("TEXT_MESSAGE_CHUNK must be tranformed before being applied");case V.TOOL_CALL_CHUNK:throw Error("TOOL_CALL_CHUNK must be tranformed before being applied");case V.THINKING_START:return f();case V.THINKING_END:return f();case V.THINKING_TEXT_MESSAGE_START:return f();case V.THINKING_TEXT_MESSAGE_CONTENT:return f();case V.THINKING_TEXT_MESSAGE_END:return f();case V.REASONING_START:return p(yield We(n,o,i,(C,b,g)=>C.onReasoningStartEvent?.({event:m,messages:b,state:g,agent:r,input:e}))),f();case V.REASONING_MESSAGE_START:{let C=yield We(n,o,i,(b,g,S)=>b.onReasoningMessageStartEvent?.({event:m,messages:g,state:S,agent:r,input:e}));if(p(C),C.stopPropagation!==!0){let{messageId:b}=m;if(!o.find(g=>g.id===b)){let g={id:b,role:"reasoning",content:""};o.push(g),p({messages:o})}}return f()}case V.REASONING_MESSAGE_CONTENT:{let{messageId:C,delta:b}=m,g=o.find(x=>x.id===C);if(!g)return console.warn(`REASONING_MESSAGE_CONTENT: No message found with ID '${C}'`),f();let S=yield We(n,o,i,(x,w,R)=>x.onReasoningMessageContentEvent?.({event:m,messages:w,state:R,agent:r,input:e,reasoningMessageBuffer:typeof g.content=="string"?g.content:""}));return p(S),S.stopPropagation!==!0&&(g.content=`${typeof g.content=="string"?g.content:""}${b}`,p({messages:o})),f()}case V.REASONING_MESSAGE_END:{let{messageId:C}=m,b=o.find(g=>g.id===C);return b?(p(yield We(n,o,i,(g,S,x)=>g.onReasoningMessageEndEvent?.({event:m,messages:S,state:x,agent:r,input:e,reasoningMessageBuffer:typeof b.content=="string"?b.content:""}))),yield Promise.all(n.map(g=>{g.onNewMessage?.({message:b,messages:o,state:i,agent:r,input:e})})),f()):(console.warn(`REASONING_MESSAGE_END: No message found with ID '${C}'`),f())}case V.REASONING_MESSAGE_CHUNK:throw Error("REASONING_MESSAGE_CHUNK must be transformed before being applied");case V.REASONING_END:return p(yield We(n,o,i,(C,b,g)=>C.onReasoningEndEvent?.({event:m,messages:b,state:g,agent:r,input:e}))),f();case V.REASONING_ENCRYPTED_VALUE:{let{subtype:C,entityId:b,encryptedValue:g}=m,S=yield We(n,o,i,(x,w,R)=>x.onReasoningEncryptedValueEvent?.({event:m,messages:w,state:R,agent:r,input:e}));if(p(S),S.stopPropagation!==!0){let x=!1;if(C==="tool-call"){for(let w of o)if(w.role==="assistant"&&w.toolCalls){let R=w.toolCalls.find(P=>P.id===b);if(R){R.encryptedValue=g,x=!0;break}}}else{let w=o.find(R=>R.id===b);w?.role!=="activity"&&w&&(w.encryptedValue=g,x=!0)}x&&(a.messages=o)}return f()}}return m.type,f()});return function(_x201){return _ref76.apply(this,arguments)}}()),gS(),n.length>0?yS({}):m=>m)},_S=e=>t=>{let r=new Map,n=new Map,o=!1,i=!1,a=!1,p=new Map,f=!1,m=!1,h=!1,C=()=>{r.clear(),n.clear(),p.clear(),f=!1,m=!1,o=!1,i=!1,h=!0};return t.pipe(rr(b=>{let g=b.type;if(e&&console.debug("[VERIFY]:",JSON.stringify(b)),i)return st(()=>new lt(`Cannot send event type '${g}': The run has already errored with 'RUN_ERROR'. No further events can be sent.`));if(o&&g!==V.RUN_ERROR&&g!==V.RUN_STARTED)return st(()=>new lt(`Cannot send event type '${g}': The run has already finished with 'RUN_FINISHED'. Start a new run with 'RUN_STARTED'.`));if(a){if(g===V.RUN_STARTED){if(h&&!o)return st(()=>new lt("Cannot send 'RUN_STARTED' while a run is still active. The previous run must be finished with 'RUN_FINISHED' before starting a new run."));o&&C()}}else if(a=!0,g!==V.RUN_STARTED&&g!==V.RUN_ERROR)return st(()=>new lt("First event must be 'RUN_STARTED'"));switch(g){case V.TEXT_MESSAGE_START:{let S=b.messageId;return r.has(S)?st(()=>new lt(`Cannot send 'TEXT_MESSAGE_START' event: A text message with ID '${S}' is already in progress. Complete it with 'TEXT_MESSAGE_END' first.`)):(r.set(S,!0),dt(b))}case V.TEXT_MESSAGE_CONTENT:{let S=b.messageId;return r.has(S)?dt(b):st(()=>new lt(`Cannot send 'TEXT_MESSAGE_CONTENT' event: No active text message found with ID '${S}'. Start a text message with 'TEXT_MESSAGE_START' first.`))}case V.TEXT_MESSAGE_END:{let S=b.messageId;return r.has(S)?(r.delete(S),dt(b)):st(()=>new lt(`Cannot send 'TEXT_MESSAGE_END' event: No active text message found with ID '${S}'. A 'TEXT_MESSAGE_START' event must be sent first.`))}case V.TOOL_CALL_START:{let S=b.toolCallId;return n.has(S)?st(()=>new lt(`Cannot send 'TOOL_CALL_START' event: A tool call with ID '${S}' is already in progress. Complete it with 'TOOL_CALL_END' first.`)):(n.set(S,!0),dt(b))}case V.TOOL_CALL_ARGS:{let S=b.toolCallId;return n.has(S)?dt(b):st(()=>new lt(`Cannot send 'TOOL_CALL_ARGS' event: No active tool call found with ID '${S}'. Start a tool call with 'TOOL_CALL_START' first.`))}case V.TOOL_CALL_END:{let S=b.toolCallId;return n.has(S)?(n.delete(S),dt(b)):st(()=>new lt(`Cannot send 'TOOL_CALL_END' event: No active tool call found with ID '${S}'. A 'TOOL_CALL_START' event must be sent first.`))}case V.STEP_STARTED:{let S=b.stepName;return p.has(S)?st(()=>new lt(`Step "${S}" is already active for 'STEP_STARTED'`)):(p.set(S,!0),dt(b))}case V.STEP_FINISHED:{let S=b.stepName;return p.has(S)?(p.delete(S),dt(b)):st(()=>new lt(`Cannot send 'STEP_FINISHED' for step "${S}" that was not started`))}case V.RUN_STARTED:return h=!0,dt(b);case V.RUN_FINISHED:if(p.size>0){let S=Array.from(p.keys()).join(", ");return st(()=>new lt(`Cannot send 'RUN_FINISHED' while steps are still active: ${S}`))}if(r.size>0){let S=Array.from(r.keys()).join(", ");return st(()=>new lt(`Cannot send 'RUN_FINISHED' while text messages are still active: ${S}`))}if(n.size>0){let S=Array.from(n.keys()).join(", ");return st(()=>new lt(`Cannot send 'RUN_FINISHED' while tool calls are still active: ${S}`))}return o=!0,dt(b);case V.RUN_ERROR:return i=!0,dt(b);case V.CUSTOM:return dt(b);case V.THINKING_TEXT_MESSAGE_START:return f?m?st(()=>new lt("Cannot send 'THINKING_TEXT_MESSAGE_START' event: A thinking message is already in progress. Complete it with 'THINKING_TEXT_MESSAGE_END' first.")):(m=!0,dt(b)):st(()=>new lt("Cannot send 'THINKING_TEXT_MESSAGE_START' event: A thinking step is not in progress. Create one with 'THINKING_START' first."));case V.THINKING_TEXT_MESSAGE_CONTENT:return m?dt(b):st(()=>new lt("Cannot send 'THINKING_TEXT_MESSAGE_CONTENT' event: No active thinking message found. Start a message with 'THINKING_TEXT_MESSAGE_START' first."));case V.THINKING_TEXT_MESSAGE_END:return m?(m=!1,dt(b)):st(()=>new lt("Cannot send 'THINKING_TEXT_MESSAGE_END' event: No active thinking message found. A 'THINKING_TEXT_MESSAGE_START' event must be sent first."));case V.THINKING_START:return f?st(()=>new lt("Cannot send 'THINKING_START' event: A thinking step is already in progress. End it with 'THINKING_END' first.")):(f=!0,dt(b));case V.THINKING_END:return f?(f=!1,dt(b)):st(()=>new lt("Cannot send 'THINKING_END' event: No active thinking step found. A 'THINKING_START' event must be sent first."));default:return dt(b)}}))},Ei=function(e){return e.HEADERS="headers",e.DATA="data",e}({}),Tj=(e,t)=>hS(()=>wi(v(e,t))).pipe(SS(r=>{if(!r.ok){let i=r.headers.get("content-type")||"";return wi(r.text()).pipe(rr(a=>{let p=a;if(i.includes("application/json"))try{p=JSON.parse(a)}catch{}let f=Error(`HTTP ${r.status}: ${typeof p=="string"?p:JSON.stringify(p)}`);return f.status=r.status,f.payload=p,st(()=>f)}))}let n={type:Ei.HEADERS,status:r.status,headers:r.headers},o=r.body?.getReader();return o?new at(i=>(i.next(n),_asyncToGenerator(function*(){try{for(;;){let{done:a,value:p}=yield o.read();if(a)break;let f={type:Ei.DATA,data:p};i.next(f)}i.complete()}catch(a){i.error(a)}})(),()=>{o.cancel().catch(a=>{if(a?.name!=="AbortError")throw a})})):st(()=>Error("Failed to getReader() from response"))})),Pj=e=>{let t=new on,r=new TextDecoder("utf-8",{fatal:!1}),n="";e.subscribe({next:i=>{if(i.type!==Ei.HEADERS&&i.type===Ei.DATA&&i.data){let a=r.decode(i.data,{stream:!0});n+=a;let p=n.split(/\n\n/);n=p.pop()||"";for(let f of p)o(f)}},error:i=>t.error(i),complete:()=>{n&&(n+=r.decode(),o(n)),t.complete()}});function o(i){let a=i.split(`
39
39
  `),p=[];for(let f of a)f.startsWith("data:")&&p.push(f.slice(5).replace(/^ /,""));if(p.length>0)try{let f=p.join(`
40
40
  `),m=JSON.parse(f);t.next(m)}catch(f){t.error(f)}}return t.asObservable()},kj=e=>{let t=new on,r=new Uint8Array;e.subscribe({next:o=>{if(o.type!==Ei.HEADERS&&o.type===Ei.DATA&&o.data){let i=new Uint8Array(r.length+o.data.length);i.set(r,0),i.set(o.data,r.length),r=i,n()}},error:o=>t.error(o),complete:()=>{if(r.length>0)try{n()}catch{console.warn("Incomplete or invalid protocol buffer data at stream end")}t.complete()}});function n(){for(;r.length>=4;){let o=4+new DataView(r.buffer,r.byteOffset,4).getUint32(0,!1);if(r.length<o)break;try{let i=r.slice(4,o),a=nI(i);t.next(a),r=r.slice(o)}catch(i){let a=i instanceof Error?i.message:String(i);t.error(Error(`Failed to decode protocol buffer message: ${a}`));return}}}return t.asObservable()},Oj=e=>{let t=new on,r=new Ap,n=!1;return e.subscribe({next:o=>{r.next(o),o.type===Ei.HEADERS&&!n?(n=!0,o.headers.get("content-type")===oI?kj(r).subscribe({next:i=>t.next(i),error:i=>t.error(i),complete:()=>t.complete()}):Pj(r).subscribe({next:i=>{try{let a=ap.parse(i);t.next(a)}catch(a){t.error(a)}},error:i=>{if(i?.name==="AbortError"){t.next({type:V.RUN_ERROR,message:i.message||"Request aborted",code:"abort",rawEvent:i}),t.complete();return}return t.error(i)},complete:()=>t.complete()})):n||t.error(Error("No headers event received before data events"))},error:o=>{r.error(o),t.error(o)},complete:()=>{r.complete()}}),t.asObservable()},nt=I.enum(["TextMessageStart","TextMessageContent","TextMessageEnd","ActionExecutionStart","ActionExecutionArgs","ActionExecutionEnd","ActionExecutionResult","AgentStateMessage","MetaEvent","RunStarted","RunFinished","RunError","NodeStarted","NodeFinished"]),_j=I.enum(["LangGraphInterruptEvent","PredictState","Exit"]),Nj=I.object({type:I.literal(nt.enum.TextMessageStart),messageId:I.string(),parentMessageId:I.string().optional(),role:I.string().optional()}),Dj=I.object({type:I.literal(nt.enum.TextMessageContent),messageId:I.string(),content:I.string()}),qj=I.object({type:I.literal(nt.enum.TextMessageEnd),messageId:I.string()}),Mj=I.object({type:I.literal(nt.enum.ActionExecutionStart),actionExecutionId:I.string(),actionName:I.string(),parentMessageId:I.string().optional()}),Vj=I.object({type:I.literal(nt.enum.ActionExecutionArgs),actionExecutionId:I.string(),args:I.string()}),jj=I.object({type:I.literal(nt.enum.ActionExecutionEnd),actionExecutionId:I.string()}),Lj=I.object({type:I.literal(nt.enum.ActionExecutionResult),actionName:I.string(),actionExecutionId:I.string(),result:I.string()}),Uj=I.object({type:I.literal(nt.enum.AgentStateMessage),threadId:I.string(),agentName:I.string(),nodeName:I.string(),runId:I.string(),active:I.boolean(),role:I.string(),state:I.string(),running:I.boolean()}),Qj=I.object({type:I.literal(nt.enum.MetaEvent),name:_j,value:I.any()}),Bj=I.object({type:I.literal(nt.enum.RunError),message:I.string(),code:I.string().optional()});I.discriminatedUnion("type",[Nj,Dj,qj,Mj,Vj,jj,Lj,Uj,Qj,Bj]),I.object({id:I.string(),role:I.string(),content:I.string(),parentMessageId:I.string().optional()}),I.object({id:I.string(),name:I.string(),arguments:I.any(),parentMessageId:I.string().optional()}),I.object({id:I.string(),result:I.any(),actionExecutionId:I.string(),actionName:I.string()});var Gj=e=>{if(typeof e=="string")return e;if(!Array.isArray(e))return;let t=e.filter(r=>r.type==="text").map(r=>r.text).filter(r=>r.length>0);if(t.length!==0)return t.join(`
41
- `)},$j=(e,t,r)=>n=>{let o={},i=!0,a=!0,p="",f=null,m=null,h=[],C={},b=g=>{typeof g=="object"&&g&&("messages"in g&&delete g.messages,o=g)};return n.pipe(rr(g=>{switch(g.type){case V.TEXT_MESSAGE_START:{let S=g;return[{type:nt.enum.TextMessageStart,messageId:S.messageId,role:S.role}]}case V.TEXT_MESSAGE_CONTENT:{let S=g;return[{type:nt.enum.TextMessageContent,messageId:S.messageId,content:S.delta}]}case V.TEXT_MESSAGE_END:{let S=g;return[{type:nt.enum.TextMessageEnd,messageId:S.messageId}]}case V.TOOL_CALL_START:{let S=g;return h.push({id:S.toolCallId,type:"function",function:{name:S.toolCallName,arguments:""}}),a=!0,C[S.toolCallId]=S.toolCallName,[{type:nt.enum.ActionExecutionStart,actionExecutionId:S.toolCallId,actionName:S.toolCallName,parentMessageId:S.parentMessageId}]}case V.TOOL_CALL_ARGS:{let S=g,x=h.find(R=>R.id===S.toolCallId);if(!x)return console.warn(`TOOL_CALL_ARGS: No tool call found with ID '${S.toolCallId}'`),[];x.function.arguments+=S.delta;let w=!1;if(m){let R=m.find(P=>P.tool==x.function.name);if(R)try{let P=JSON.parse(Mp(x.function.arguments));R.tool_argument&&R.tool_argument in P?(b({...o,[R.state_key]:P[R.tool_argument]}),w=!0):R.tool_argument||(b({...o,[R.state_key]:P}),w=!0)}catch{}}return[{type:nt.enum.ActionExecutionArgs,actionExecutionId:S.toolCallId,args:S.delta},...(w?[{type:nt.enum.AgentStateMessage,threadId:e,agentName:r,nodeName:p,runId:t,running:i,role:"assistant",state:JSON.stringify(o),active:a}]:[])]}case V.TOOL_CALL_END:{let S=g;return[{type:nt.enum.ActionExecutionEnd,actionExecutionId:S.toolCallId}]}case V.TOOL_CALL_RESULT:{let S=g;return[{type:nt.enum.ActionExecutionResult,actionExecutionId:S.toolCallId,result:S.content,actionName:C[S.toolCallId]||"unknown"}]}case V.RAW:return[];case V.CUSTOM:{let S=g;switch(S.name){case"Exit":i=!1;break;case"PredictState":m=S.value;break}return[{type:nt.enum.MetaEvent,name:S.name,value:S.value}]}case V.STATE_SNAPSHOT:return b(g.snapshot),[{type:nt.enum.AgentStateMessage,threadId:e,agentName:r,nodeName:p,runId:t,running:i,role:"assistant",state:JSON.stringify(o),active:a}];case V.STATE_DELTA:{let S=g,x=po(o,S.delta,!0,!1);return x?(b(x.newDocument),[{type:nt.enum.AgentStateMessage,threadId:e,agentName:r,nodeName:p,runId:t,running:i,role:"assistant",state:JSON.stringify(o),active:a}]):[]}case V.MESSAGES_SNAPSHOT:return f=g.messages,[{type:nt.enum.AgentStateMessage,threadId:e,agentName:r,nodeName:p,runId:t,running:i,role:"assistant",state:JSON.stringify({...o,...(f?{messages:f}:{})}),active:!0}];case V.RUN_STARTED:return[];case V.RUN_FINISHED:return f&&(o.messages=f),Object.keys(o).length===0?[]:[{type:nt.enum.AgentStateMessage,threadId:e,agentName:r,nodeName:p,runId:t,running:i,role:"assistant",state:JSON.stringify({...o,...(f?{messages:Hj(f)}:{})}),active:!1}];case V.RUN_ERROR:{let S=g;return[{type:nt.enum.RunError,message:S.message,code:S.code}]}case V.STEP_STARTED:return p=g.stepName,h=[],m=null,[{type:nt.enum.AgentStateMessage,threadId:e,agentName:r,nodeName:p,runId:t,running:i,role:"assistant",state:JSON.stringify(o),active:!0}];case V.STEP_FINISHED:return h=[],m=null,[{type:nt.enum.AgentStateMessage,threadId:e,agentName:r,nodeName:p,runId:t,running:i,role:"assistant",state:JSON.stringify(o),active:!1}];default:return[]}}))};function Hj(e){let t=[];for(let r of e)if(r.role==="assistant"||r.role==="user"||r.role==="system"){let n=Gj(r.content);if(n){let o={id:r.id,role:r.role,content:n};t.push(o)}if(r.role==="assistant"&&r.toolCalls&&r.toolCalls.length>0)for(let o of r.toolCalls){let i={id:o.id,name:o.function.name,arguments:JSON.parse(o.function.arguments),parentMessageId:r.id};t.push(i)}}else if(r.role==="tool"){let n="unknown";for(let i of e)if(i.role==="assistant"&&i.toolCalls?.length){for(let a of i.toolCalls)if(a.id===r.toolCallId){n=a.function.name;break}}let o={id:r.id,result:r.content,actionExecutionId:r.toolCallId,actionName:n};t.push(o)}return t}var lf=e=>t=>{let r,n,o,i,a=()=>{if(!r||i!=="text")throw Error("No text message to close");let h={type:V.TEXT_MESSAGE_END,messageId:r.messageId};return i=void 0,r=void 0,e&&console.debug("[TRANSFORM]: TEXT_MESSAGE_END",JSON.stringify(h)),h},p=()=>{if(!n||i!=="tool")throw Error("No tool call to close");let h={type:V.TOOL_CALL_END,toolCallId:n.toolCallId};return i=void 0,n=void 0,e&&console.debug("[TRANSFORM]: TOOL_CALL_END",JSON.stringify(h)),h},f=()=>{if(!o||i!=="reasoning")throw Error("No reasoning message to close");let h={type:V.REASONING_MESSAGE_END,messageId:o.messageId};return i=void 0,o=void 0,e&&console.debug("[TRANSFORM]: REASONING_MESSAGE_END",JSON.stringify(h)),h},m=()=>i==="text"?[a()]:i==="tool"?[p()]:i==="reasoning"?[f()]:[];return t.pipe(rr(h=>{switch(h.type){case V.TEXT_MESSAGE_START:case V.TEXT_MESSAGE_CONTENT:case V.TEXT_MESSAGE_END:case V.TOOL_CALL_START:case V.TOOL_CALL_ARGS:case V.TOOL_CALL_END:case V.TOOL_CALL_RESULT:case V.STATE_SNAPSHOT:case V.STATE_DELTA:case V.MESSAGES_SNAPSHOT:case V.CUSTOM:case V.RUN_STARTED:case V.RUN_FINISHED:case V.RUN_ERROR:case V.STEP_STARTED:case V.STEP_FINISHED:case V.THINKING_START:case V.THINKING_END:case V.THINKING_TEXT_MESSAGE_START:case V.THINKING_TEXT_MESSAGE_CONTENT:case V.THINKING_TEXT_MESSAGE_END:case V.REASONING_START:case V.REASONING_MESSAGE_START:case V.REASONING_MESSAGE_CONTENT:case V.REASONING_MESSAGE_END:case V.REASONING_END:return[...m(),h];case V.RAW:case V.ACTIVITY_SNAPSHOT:case V.ACTIVITY_DELTA:case V.REASONING_ENCRYPTED_VALUE:return[h];case V.TEXT_MESSAGE_CHUNK:let C=h,b=[];if((i!=="text"||C.messageId!==void 0&&C.messageId!==r?.messageId)&&b.push(...m()),i!=="text"){if(C.messageId===void 0)throw Error("First TEXT_MESSAGE_CHUNK must have a messageId");r={messageId:C.messageId},i="text";let R={type:V.TEXT_MESSAGE_START,messageId:C.messageId,role:C.role||"assistant"};b.push(R),e&&console.debug("[TRANSFORM]: TEXT_MESSAGE_START",JSON.stringify(R))}if(C.delta!==void 0){let R={type:V.TEXT_MESSAGE_CONTENT,messageId:r.messageId,delta:C.delta};b.push(R),e&&console.debug("[TRANSFORM]: TEXT_MESSAGE_CONTENT",JSON.stringify(R))}return b;case V.TOOL_CALL_CHUNK:let g=h,S=[];if((i!=="tool"||g.toolCallId!==void 0&&g.toolCallId!==n?.toolCallId)&&S.push(...m()),i!=="tool"){if(g.toolCallId===void 0)throw Error("First TOOL_CALL_CHUNK must have a toolCallId");if(g.toolCallName===void 0)throw Error("First TOOL_CALL_CHUNK must have a toolCallName");n={toolCallId:g.toolCallId,toolCallName:g.toolCallName,parentMessageId:g.parentMessageId},i="tool";let R={type:V.TOOL_CALL_START,toolCallId:g.toolCallId,toolCallName:g.toolCallName,parentMessageId:g.parentMessageId};S.push(R),e&&console.debug("[TRANSFORM]: TOOL_CALL_START",JSON.stringify(R))}if(g.delta!==void 0){let R={type:V.TOOL_CALL_ARGS,toolCallId:n.toolCallId,delta:g.delta};S.push(R),e&&console.debug("[TRANSFORM]: TOOL_CALL_ARGS",JSON.stringify(R))}return S;case V.REASONING_MESSAGE_CHUNK:let x=h,w=[];if((i!=="reasoning"||x.messageId&&x.messageId!==o?.messageId)&&w.push(...m()),i!=="reasoning"){if(x.messageId===void 0)throw Error("First REASONING_MESSAGE_CHUNK must have a messageId");o={messageId:x.messageId},i="reasoning";let R={type:V.REASONING_MESSAGE_START,messageId:x.messageId};w.push(R),e&&console.debug("[TRANSFORM]: REASONING_MESSAGE_START",JSON.stringify(R))}if(x.delta!==void 0){let R={type:V.REASONING_MESSAGE_CONTENT,messageId:o.messageId,delta:x.delta};w.push(R),e&&console.debug("[TRANSFORM]: REASONING_MESSAGE_CONTENT",JSON.stringify(R))}return w}return h.type,[]}),Ii(()=>{m()}))},NS=class{runNext(e,t){return t.run(e).pipe(lf(!1))}runNextWithState(e,t){let r=Ze(e.messages||[]),n=Ze(e.state||{}),o=new Ap;return pI(e,o,t,[]).subscribe(i=>{i.messages!==void 0&&(r=i.messages),i.state!==void 0&&(n=i.state)}),this.runNext(e,t).pipe(Dp(/*#__PURE__*/function(){var _ref78=_asyncToGenerator(function*(i){return o.next(i),yield new Promise(a=>setTimeout(a,0)),{event:i,messages:Ze(r),state:Ze(n)}});return function(_x202){return _ref78.apply(this,arguments)}}()))}},zj=class extends NS{constructor(e){super(),this.fn=e}run(e,t){return this.fn(e,t)}};function Wj(e){let t=e.content;if(Array.isArray(t)){let r=t.filter(n=>typeof n=="object"&&!!n&&"type"in n&&n.type==="text"&&typeof n.text=="string").map(n=>n.text).join("");return{...e,content:r}}return typeof t=="string"?e:{...e,content:""}}var Yj=class extends NS{run(e,t){let{parentRunId:r,...n}=e,o={...n,messages:n.messages.map(Wj)};return this.runNext(o,t)}},sI="THINKING_START",cI="THINKING_END",uI="THINKING_TEXT_MESSAGE_START",lI="THINKING_TEXT_MESSAGE_CONTENT",dI="THINKING_TEXT_MESSAGE_END",Kj=class extends NS{constructor(...e){super(...e),this.currentReasoningId=null,this.currentMessageId=null}warnAboutTransformation(e,t){process.env.SUPPRESS_TRANSFORMATION_WARNINGS||console.warn(`AG-UI is converting ${e} to ${t}. To remove this warning, upgrade your AG-UI integration package (e.g. @ag-ui/langgraph). To surpress it, set SUPPRESS_TRANSFORMATION_WARNINGS=true in your .env file.`)}run(e,t){return this.currentReasoningId=null,this.currentMessageId=null,this.runNext(e,t).pipe(Ri(r=>this.transformEvent(r)))}transformEvent(e){switch(e.type){case sI:{this.currentReasoningId=ru();let{title:t,...r}=e;return this.warnAboutTransformation(sI,V.REASONING_START),{...r,type:V.REASONING_START,messageId:this.currentReasoningId}}case uI:return this.currentMessageId=ru(),this.warnAboutTransformation(uI,V.REASONING_MESSAGE_START),{...e,type:V.REASONING_MESSAGE_START,messageId:this.currentMessageId,role:"assistant"};case lI:{let{delta:t,...r}=e;return this.warnAboutTransformation(lI,V.REASONING_MESSAGE_CONTENT),{...r,type:V.REASONING_MESSAGE_CONTENT,messageId:this.currentMessageId??ru(),delta:t}}case dI:{let t=this.currentMessageId??ru();return this.warnAboutTransformation(dI,V.REASONING_MESSAGE_END),{...e,type:V.REASONING_MESSAGE_END,messageId:t}}case cI:{let t=this.currentReasoningId??ru();return this.warnAboutTransformation(cI,V.REASONING_END),{...e,type:V.REASONING_END,messageId:t}}default:return e}}},Xj="0.0.45",Jj=class{get maxVersion(){return Xj}constructor({agentId:e,description:t,threadId:r,initialMessages:n,initialState:o,debug:i}={}){this.debug=!1,this.subscribers=[],this.isRunning=!1,this.middlewares=[],this.agentId=e,this.description=t??"",this.threadId=r??ao(),this.messages=Ze(n??[]),this.state=Ze(o??{}),this.debug=i??!1,uf(this.maxVersion,"0.0.39")<=0&&this.middlewares.unshift(new Yj),uf(this.maxVersion,"0.0.45")<=0&&this.middlewares.unshift(new Kj)}subscribe(e){return this.subscribers.push(e),{unsubscribe:()=>{this.subscribers=this.subscribers.filter(t=>t!==e)}}}use(...e){let t=e.map(r=>typeof r=="function"?new zj(r):r);return this.middlewares.push(...t),this}runAgent(e,t){var _this35=this;return _asyncToGenerator(function*(){try{_this35.isRunning=!0,_this35.agentId=_this35.agentId??ao();let r=_this35.prepareRunAgentInput(e),n,o=new Set(_this35.messages.map(f=>f.id)),i=[{onRunFinishedEvent:f=>{n=f.result}},..._this35.subscribers,t??{}];yield _this35.onInitialize(r,i),_this35.activeRunDetach$=new on;let a;_this35.activeRunCompletionPromise=new Promise(f=>{a=f}),yield Np(vp(()=>_this35.middlewares.length===0?_this35.run(r):_this35.middlewares.reduceRight((f,m)=>({run:h=>m.run(h,f)}),_this35).run(r),lf(_this35.debug),_S(_this35.debug),f=>f.pipe(qp(_this35.activeRunDetach$)),f=>_this35.apply(r,f,i),f=>_this35.processApplyEvents(r,f,i),Zc(f=>(_this35.isRunning=!1,_this35.onError(r,f,i))),Ii(()=>{_this35.isRunning=!1,_this35.onFinalize(r,i),a?.(),a=void 0,_this35.activeRunCompletionPromise=void 0,_this35.activeRunDetach$=void 0}))(dt(null)));let p=Ze(_this35.messages).filter(f=>!o.has(f.id));return{result:n,newMessages:p}}finally{_this35.isRunning=!1}})()}connect(e){throw new rS}connectAgent(e,t){var _this36=this;return _asyncToGenerator(function*(){try{_this36.isRunning=!0,_this36.agentId=_this36.agentId??ao();let r=_this36.prepareRunAgentInput(e),n,o=new Set(_this36.messages.map(f=>f.id)),i=[{onRunFinishedEvent:f=>{n=f.result}},..._this36.subscribers,t??{}];yield _this36.onInitialize(r,i),_this36.activeRunDetach$=new on;let a;_this36.activeRunCompletionPromise=new Promise(f=>{a=f}),yield Np(vp(()=>_this36.connect(r),lf(_this36.debug),_S(_this36.debug),f=>f.pipe(qp(_this36.activeRunDetach$)),f=>_this36.apply(r,f,i),f=>_this36.processApplyEvents(r,f,i),Zc(f=>(_this36.isRunning=!1,f instanceof rS?Cp:_this36.onError(r,f,i))),Ii(()=>{_this36.isRunning=!1,_this36.onFinalize(r,i),a?.(),a=void 0,_this36.activeRunCompletionPromise=void 0,_this36.activeRunDetach$=void 0}))(dt(null)));let p=Ze(_this36.messages).filter(f=>!o.has(f.id));return{result:n,newMessages:p}}finally{_this36.isRunning=!1}})()}abortRun(){}detachActiveRun(){var _this37=this;return _asyncToGenerator(function*(){if(!_this37.activeRunDetach$)return;let e=_this37.activeRunCompletionPromise??Promise.resolve();_this37.activeRunDetach$.next(),_this37.activeRunDetach$?.complete(),yield e})()}apply(e,t,r){return pI(e,t,this,r)}processApplyEvents(e,t,r){return t.pipe(vS(n=>{n.messages&&(this.messages=n.messages,r.forEach(o=>{o.onMessagesChanged?.({messages:this.messages,state:this.state,agent:this,input:e})})),n.state&&(this.state=n.state,r.forEach(o=>{o.onStateChanged?.({state:this.state,messages:this.messages,agent:this,input:e})}))}))}prepareRunAgentInput(e){let t=Ze(this.messages).filter(r=>r.role!=="activity");return{threadId:this.threadId,runId:e?.runId||ao(),tools:Ze(e?.tools??[]),context:Ze(e?.context??[]),forwardedProps:Ze(e?.forwardedProps??{}),state:Ze(this.state),messages:t}}onInitialize(e,t){var _this38=this;return _asyncToGenerator(function*(){let r=yield We(t,_this38.messages,_this38.state,(n,o,i)=>n.onRunInitialized?.({messages:o,state:i,agent:_this38,input:e}));(r.messages!==void 0||r.state!==void 0)&&(r.messages&&(_this38.messages=r.messages,e.messages=r.messages,t.forEach(n=>{n.onMessagesChanged?.({messages:_this38.messages,state:_this38.state,agent:_this38,input:e})})),r.state&&(_this38.state=r.state,e.state=r.state,t.forEach(n=>{n.onStateChanged?.({state:_this38.state,messages:_this38.messages,agent:_this38,input:e})})))})()}onError(e,t,r){return wi(We(r,this.messages,this.state,(n,o,i)=>n.onRunFailed?.({error:t,messages:o,state:i,agent:this,input:e}))).pipe(Ri(n=>{let o=n;if((o.messages!==void 0||o.state!==void 0)&&(o.messages!==void 0&&(this.messages=o.messages,r.forEach(i=>{i.onMessagesChanged?.({messages:this.messages,state:this.state,agent:this,input:e})})),o.state!==void 0&&(this.state=o.state,r.forEach(i=>{i.onStateChanged?.({state:this.state,messages:this.messages,agent:this,input:e})}))),o.stopPropagation!==!0)throw console.error("Agent execution failed:",t),t;return{}}))}onFinalize(e,t){var _this39=this;return _asyncToGenerator(function*(){let r=yield We(t,_this39.messages,_this39.state,(n,o,i)=>n.onRunFinalized?.({messages:o,state:i,agent:_this39,input:e}));(r.messages!==void 0||r.state!==void 0)&&(r.messages!==void 0&&(_this39.messages=r.messages,t.forEach(n=>{n.onMessagesChanged?.({messages:_this39.messages,state:_this39.state,agent:_this39,input:e})})),r.state!==void 0&&(_this39.state=r.state,t.forEach(n=>{n.onStateChanged?.({state:_this39.state,messages:_this39.messages,agent:_this39,input:e})})))})()}clone(){let e=Object.create(Object.getPrototypeOf(this));return e.agentId=this.agentId,e.description=this.description,e.threadId=this.threadId,e.messages=Ze(this.messages),e.state=Ze(this.state),e.debug=this.debug,e.isRunning=this.isRunning,e.subscribers=[...this.subscribers],e.middlewares=[...this.middlewares],e}addMessage(e){var _this40=this;this.messages.push(e),_asyncToGenerator(function*(){for(let t of _this40.subscribers)yield t.onNewMessage?.({message:e,messages:_this40.messages,state:_this40.state,agent:_this40});if(e.role==="assistant"&&e.toolCalls)for(let t of e.toolCalls)for(let r of _this40.subscribers)yield r.onNewToolCall?.({toolCall:t,messages:_this40.messages,state:_this40.state,agent:_this40});for(let t of _this40.subscribers)yield t.onMessagesChanged?.({messages:_this40.messages,state:_this40.state,agent:_this40})})()}addMessages(e){var _this41=this;this.messages.push(...e),_asyncToGenerator(function*(){for(let t of e){for(let r of _this41.subscribers)yield r.onNewMessage?.({message:t,messages:_this41.messages,state:_this41.state,agent:_this41});if(t.role==="assistant"&&t.toolCalls)for(let r of t.toolCalls)for(let n of _this41.subscribers)yield n.onNewToolCall?.({toolCall:r,messages:_this41.messages,state:_this41.state,agent:_this41})}for(let t of _this41.subscribers)yield t.onMessagesChanged?.({messages:_this41.messages,state:_this41.state,agent:_this41})})()}setMessages(e){var _this42=this;this.messages=Ze(e),_asyncToGenerator(function*(){for(let t of _this42.subscribers)yield t.onMessagesChanged?.({messages:_this42.messages,state:_this42.state,agent:_this42})})()}setState(e){var _this43=this;this.state=Ze(e),_asyncToGenerator(function*(){for(let t of _this43.subscribers)yield t.onStateChanged?.({messages:_this43.messages,state:_this43.state,agent:_this43})})()}legacy_to_be_removed_runAgentBridged(e){this.agentId=this.agentId??ao();let t=this.prepareRunAgentInput(e);return(this.middlewares.length===0?this.run(t):this.middlewares.reduceRight((r,n)=>({run:o=>n.run(o,r)}),this).run(t)).pipe(lf(this.debug),_S(this.debug),$j(this.threadId,t.runId,this.agentId),r=>r.pipe(Ri(n=>(this.debug&&console.debug("[LEGACY]:",JSON.stringify(n)),n))))}},fI=class extends Jj{requestInit(e){return{method:"POST",headers:{...this.headers,"Content-Type":"application/json",Accept:"text/event-stream"},body:JSON.stringify(e),signal:this.abortController.signal}}runAgent(e,t){return this.abortController=e?.abortController??new s.AbortController,super.runAgent(e,t)}abortRun(){this.abortController.abort(),super.abortRun()}constructor(e){super(e),this.abortController=new s.AbortController,this.url=e.url,this.headers=Ze(e.headers??{})}run(e){return Oj(Tj(this.url,this.requestInit(e)))}clone(){let e=super.clone();e.url=this.url,e.headers=Ze(this.headers??{});let t=new s.AbortController,r=this.abortController.signal;return r.aborted&&t.abort(r.reason),e.abortController=t,e}};d();c();l();u();var mI=(e,t,r)=>{let n=Ye(t,r),o=e?.trim();if(!n||!t||!o)throw new Error("Missing required parameters for answer endpoint");let i=`/api/preview/organizations/${t}/agents`;return`${n}${i}/${o}`};var DS=class extends fI{requestInit(t){let{params:r,accessToken:n,recordDebugSession:o}=t.forwardedProps||{},i={...r,...(o&&{recordDebugSession:!0})};return{method:"POST",headers:{...this.headers,Authorization:`Bearer ${n}`,"Content-Type":"application/json",Accept:"text/event-stream, application/json"},body:JSON.stringify(i),signal:this.abortController.signal}}},gI=(e,t,r)=>new DS({url:`${mI(e,t,r)}/answer`});d();c();l();u();d();c();l();u();var Zj=new $({required:!0}),hI=new $({required:!0,constrainTo:Pd}),yI=e=>({...e,name:kd(e.name)}),SI=T("followUpAnswers/setIsEnabled",e=>O(e,new de({required:!0}))),vI=T("followUpAnswers/setFollowUpAnswersConversationId",e=>O(e,z)),AI=T("followUpAnswers/setFollowUpAnswersConversationToken",e=>O(e,z)),CI=T("followUpAnswers/clearFollowUpAnswersConversationToken"),VAe=T("followUpAnswers/createFollowUpAnswer",e=>O(e,{question:z})),jAe=T("followUpAnswers/setActiveFollowUpAnswerId",e=>O(e,z)),LAe=T("followUpAnswers/setFollowUpAnswerContentFormat",e=>O(e,{contentFormat:Od,answerId:z})),UAe=T("followUpAnswers/setFollowUpIsLoading",e=>O(e,{isLoading:new de({required:!0}),answerId:z})),QAe=T("followUpAnswers/setFollowUpIsStreaming",e=>O(e,{isStreaming:new de({required:!0}),answerId:z})),BAe=T("followUpAnswers/followUpMessageChunkReceived",e=>O(e,{textDelta:Zj,answerId:z})),GAe=T("followUpAnswers/followUpCitationsReceived",e=>O(e,{citations:new ne({required:!0,each:new Y({values:By})}),answerId:z})),$Ae=T("followUpAnswers/followUpCompleted",e=>O(e,{answerId:z,cannotAnswer:new de({required:!1})})),HAe=T("followUpAnswers/followUpFailed",e=>O(e,{message:new $,code:new oe({min:0}),answerId:z})),zAe=T("followUpAnswers/activeFollowUpStartFailed",e=>O(e,{message:new $})),WAe=T("followUpAnswers/likeFollowUp",e=>O(e,{answerId:z})),YAe=T("followUpAnswers/dislikeFollowUp",e=>O(e,{answerId:z})),KAe=T("followUpAnswers/submitFollowUpFeedback",e=>O(e,{answerId:z})),bI=T("followUpAnswers/resetFollowUpAnswers"),XAe=T("followUpAnswers/stepStarted",e=>O(yI(e),{answerId:z,name:hI,startedAt:new oe({min:0,required:!0})})),JAe=T("followUpAnswers/stepFinished",e=>O(yI(e),{answerId:z,name:hI,finishedAt:new oe({min:0,required:!0})}));d();c();l();u();var eL={"KNOWLEDGE:SSE_MAX_DURATION_EXCEEDED":1e3,"KNOWLEDGE:SSE_FOLLOW_UP_NOT_SUPPORTED":1001,"KNOWLEDGE:NOT_FOUND":1002,"KNOWLEDGE:SSE_MODELS_NOT_AVAILABLE":1003,"KNOWLEDGE:SSE_INTERNAL_ERROR":1004,"KNOWLEDGE:TURN_LIMIT_REACHED":1005};function xI(e){return e?eL[e]??1004:1004}function tL(e){let t=r=>e.code===r;return Object.defineProperties(e,{isMaxDurationExceededError:{value:()=>t(1e3),enumerable:!1},isFollowupNotSupportedError:{value:()=>t(1001),enumerable:!1},isConversationNotFoundError:{value:()=>t(1002),enumerable:!1},isSseModelNotAvailableError:{value:()=>t(1003),enumerable:!1},isSseInternalError:{value:()=>t(1004),enumerable:!1},isSseTurnLimitReachedError:{value:()=>t(1005),enumerable:!1}}),e}function df(e){if(e)return tL({...e})}var wI=e=>{let t="",r=!1;return{onRunStartedEvent:({event:n})=>{t=n.runId,r=!1,e(Da(n.runId)),e(Jr(!1)),e(Jo(!0)),e(vI(n.threadId)),e(CI())},onStepStartedEvent:({event:n})=>{e(Bd({name:n.stepName,startedAt:n.timestamp??Date.now()}))},onStepFinishedEvent:({event:n})=>{e(Gd({name:n.stepName,finishedAt:n.timestamp??Date.now()}))},onTextMessageContentEvent:({event:n})=>{n.delta.length>0&&(r=!0),e(Zo({textDelta:n.delta}))},onCustomEvent:({event:n})=>{let{name:o,value:i}=n;switch(o){case"header":{i?.contentFormat&&e(ri(i.contentFormat)),typeof i?.followUpEnabled=="boolean"&&e(SI(i.followUpEnabled)),i?.conversationToken&&e(AI(i.conversationToken));return}case"citations":{e(ei({citations:i.citations}));return}}},onRunErrorEvent:({event:n})=>{let o=xI(n.code);e(ti({message:n.message,code:o}))},onRunFinishedEvent:({event:n})=>{let o=n.result?.completionReason==="ANSWERED",i=o?!r:void 0;e(Bc(o)),e(ni(!o)),e(Jo(!1)),e(Pa(o,t,i,n.threadId)),e(ka())}}};var RI=()=>{let e,t=()=>{e?.abortRun(),e=void 0};return{run:function(){var _ref83=_asyncToGenerator(function*(n,o,i){t();let a=Ol(n),p=Sb(n),f=vb(n),m=yb(n),h=Ab(n),C=gI(a,p,f);e=C;let b=wI(o),g=Sw(n,i());try{o(Jr(!0)),yield C.runAgent({forwardedProps:{params:g,accessToken:m,recordDebugSession:h}},b)}catch(S){o(Jr(!1)),o(ti({message:"An error occurred while starting the answer generation."})),console.error("Error running the answer agent:",S)}});return function run(_x203,_x204,_x205){return _ref83.apply(this,arguments)}}(),abortRun:t}};var II=e=>{let t=AC({extra:e}),r=RI();return t.startListening({actionCreator:Te.pending,effect:function(){var _ref84=_asyncToGenerator(function*(n,o){let i=o.getState();if(!Yh(i))return;r.abortRun(),o.dispatch(lr()),o.dispatch(bI());let a=Xo(i)?.q;!a||a.trim()===""||r.run(i,o.dispatch,e.getNavigatorContext)});return function effect(_x206,_x207){return _ref84.apply(this,arguments)}}()}),t};d();c();l();u();var EI=e=>()=>t=>r=>{let n=r;if(!n.error)return t(r);let o=n.error;if(n.payload?.ignored||e.error({error:o,action:r},`Action dispatch error ${n.type}`),n.error.name!=="SchemaValidationError")return t(r)},FI=e=>t=>r=>n=>(e.debug({action:n,nextState:t.getState()},`Action dispatched: ${n.type}`),r(n));d();c();l();u();var qS=(e,t)=>{let{referrer:r,userAgent:n,location:o,clientId:i}=e.getMeta("");return{...(t?t():{}),referrer:r,userAgent:n,location:o,clientId:i}};d();c();l();u();function TI(e,t){let r={...e},n,o=i=>(a,p)=>{let f=i(a,p);return n?n(f,p):f};return{get combinedReducer(){let i=qv(Object.entries(t).filter(([a])=>!(a in r)).map(([a,p])=>[a,()=>p]));return o(Yi({...i,...r}))},containsAll(i){return Object.keys(i).every(p=>p in r)},add(i){Object.keys(i).filter(a=>!(a in r)).forEach(a=>{r[a]=i[a]})},addCrossReducer(i){n=i}}}d();c();l();u();d();c();l();u();function rL(e){if(!e||!nL(e))return null;try{let r=e.split(".")[1].replace(/-/g,"+").replace(/_/g,"/"),n=atob(r),o=decodeURIComponent(n.split("").map(i=>`%${`00${i.charCodeAt(0).toString(16)}`.slice(-2)}`).join(""));return JSON.parse(o)}catch{return null}}function PI(e,t=60){if(!e)return!1;let r=rL(e);if(!r||typeof r.exp!="number")return!1;let n=Math.floor(Date.now()/1e3);return r.exp<=n+t}function nL(e){return e?/^[A-Za-z0-9_-]{2,}(?:\.[A-Za-z0-9_-]{2,}){2}$/.test(e):!1}function OI(e,t){let r=0,n=null,o=_u(()=>{r=0},500),i=/*#__PURE__*/function(){var _ref85=_asyncToGenerator(function*(f,m=!1){let h=!n;h&&t&&(n=_asyncToGenerator(function*(){try{return yield t()}catch(b){if(!m)throw b;return null}})().finally(()=>{n=null}));let C=yield n;return h&&C&&f.dispatch(ha({accessToken:C})),C});return function i(_x208){return _ref85.apply(this,arguments)}}(),a=/*#__PURE__*/function(){var _ref87=_asyncToGenerator(function*(f){let m=f.getState(),h=iL(m);if(!(!h||!PI(h))){e.debug("Access token is expired or about to expire, attempting renewal.");try{(yield i(f))?e.debug("Access token was renewed."):e.warn("Access token renewal returned an empty token. Please check the #renewAccessToken function.")}catch(C){e.warn(C,"Access token renewal failed. A retry will occur if necessary.")}}});return function a(_x209){return _ref87.apply(this,arguments)}}(),p=/*#__PURE__*/function(){var _ref88=_asyncToGenerator(function*(f,m,h){if(r>=5)return e.warn("Attempted to renew the token but was not successful. Please check the #renewAccessToken function."),kI(f,m.error),m;r++,o(),yield i(f,!0),f.dispatch(h)});return function p(_x210,_x211,_x212){return _ref88.apply(this,arguments)}}();return f=>m=>(/*#__PURE__*/function(){var _ref89=_asyncToGenerator(function*(h){let C=typeof h=="function",b=typeof t=="function";if(!C)return m(h);b&&(yield a(f));let g=yield m(h);return oL(g)?b?yield p(f,g,h):(e.warn("Unable to renew the expired token because a renew function was not provided. Please specify the #renewAccessToken option when initializing the engine."),kI(f,g.error),g):g});return function(_x213){return _ref89.apply(this,arguments)}}())}function oL(e){return typeof e=="object"&&e!==null&&"error"in e&&e.error?.name===new $i().name}function kI(e,t){e.dispatch(Ea({status:401,statusCode:401,message:t.message,type:t.name}))}function iL(e){return e.configuration.accessToken}d();c();l();u();function _I({reducer:e,preloadedState:t,middlewares:r=[],thunkExtraArguments:n,name:o}){return aC({reducer:e,preloadedState:t,devTools:{stateSanitizer:i=>i.history?{...i,history:"<<OMIT>>"}:i,name:o,shouldHotReload:!1},middleware:i=>i({thunk:{extraArgument:n}}).prepend(...r).concat(FI(n.logger))})}function aL(e,t){let{analytics:r}=e,{analyticsClientMiddleware:n,...o}=r??{},i={...o,...(r?.proxyBaseUrl&&{apiBaseUrl:r.proxyBaseUrl,nexApiBaseUrl:r.proxyBaseUrl})};return i.analyticsMode!=="next"&&Dv()?(t.info("Analytics disabled since doNotTrack is active."),{...i,enabled:!1}):i}function NI(e,t){let r={...e.reducers,configuration:Ce,version:Rw},n=sL({...e,reducers:r},t,Ce),{accessToken:o,environment:i,organizationId:a}=e.configuration;n.dispatch(ha({accessToken:o,environment:i,organizationId:a}));let p=aL(e.configuration,n.logger);return p&&n.dispatch(Ul(p)),n}function sL(e,t,r){let{reducers:n,navigatorContextProvider:o}=e,i=TI({...n,configurationReducer:r},e.preloadedState??{});e.crossReducer&&i.addCrossReducer(e.crossReducer);let a=t.logger,p={...t,get relay(){return Cc(m.state,o)},get navigatorContext(){return qS(this.relay,o)}},f=cL(e,p,i),m={addReducers(h){i.containsAll(h)||(i.add(h),f.replaceReducer(i.combinedReducer))},dispatch:f.dispatch,subscribe:f.subscribe,enableAnalytics(){f.dispatch(Bl())},disableAnalytics(){f.dispatch(Ql())},get state(){return f.getState()},get relay(){return Cc(this.state,o)},get navigatorContext(){return qS(this.relay,o)},logger:a,store:f};return m}function cL(e,t,r){let{preloadedState:n,configuration:o}=e,i=o.name||"coveo-headless",a=uL(e,t.logger,()=>t.navigatorContext);return _I({preloadedState:n,reducer:r.combinedReducer,middlewares:a,thunkExtraArguments:t,name:i})}function uL(e,t,r){let{renewAccessToken:n}=e.configuration,o=OI(t,n),i=II({getNavigatorContext:r});return[Nw,o,EI(t),Ew].concat(oi.middleware,i.middleware,e.middlewares||[])}var lL=`[Warning] A component from the Coveo Headless library has been instantiated with the Analytics Mode: "Next".
41
+ `)},$j=(e,t,r)=>n=>{let o={},i=!0,a=!0,p="",f=null,m=null,h=[],C={},b=g=>{typeof g=="object"&&g&&("messages"in g&&delete g.messages,o=g)};return n.pipe(rr(g=>{switch(g.type){case V.TEXT_MESSAGE_START:{let S=g;return[{type:nt.enum.TextMessageStart,messageId:S.messageId,role:S.role}]}case V.TEXT_MESSAGE_CONTENT:{let S=g;return[{type:nt.enum.TextMessageContent,messageId:S.messageId,content:S.delta}]}case V.TEXT_MESSAGE_END:{let S=g;return[{type:nt.enum.TextMessageEnd,messageId:S.messageId}]}case V.TOOL_CALL_START:{let S=g;return h.push({id:S.toolCallId,type:"function",function:{name:S.toolCallName,arguments:""}}),a=!0,C[S.toolCallId]=S.toolCallName,[{type:nt.enum.ActionExecutionStart,actionExecutionId:S.toolCallId,actionName:S.toolCallName,parentMessageId:S.parentMessageId}]}case V.TOOL_CALL_ARGS:{let S=g,x=h.find(R=>R.id===S.toolCallId);if(!x)return console.warn(`TOOL_CALL_ARGS: No tool call found with ID '${S.toolCallId}'`),[];x.function.arguments+=S.delta;let w=!1;if(m){let R=m.find(P=>P.tool==x.function.name);if(R)try{let P=JSON.parse(Mp(x.function.arguments));R.tool_argument&&R.tool_argument in P?(b({...o,[R.state_key]:P[R.tool_argument]}),w=!0):R.tool_argument||(b({...o,[R.state_key]:P}),w=!0)}catch{}}return[{type:nt.enum.ActionExecutionArgs,actionExecutionId:S.toolCallId,args:S.delta},...(w?[{type:nt.enum.AgentStateMessage,threadId:e,agentName:r,nodeName:p,runId:t,running:i,role:"assistant",state:JSON.stringify(o),active:a}]:[])]}case V.TOOL_CALL_END:{let S=g;return[{type:nt.enum.ActionExecutionEnd,actionExecutionId:S.toolCallId}]}case V.TOOL_CALL_RESULT:{let S=g;return[{type:nt.enum.ActionExecutionResult,actionExecutionId:S.toolCallId,result:S.content,actionName:C[S.toolCallId]||"unknown"}]}case V.RAW:return[];case V.CUSTOM:{let S=g;switch(S.name){case"Exit":i=!1;break;case"PredictState":m=S.value;break}return[{type:nt.enum.MetaEvent,name:S.name,value:S.value}]}case V.STATE_SNAPSHOT:return b(g.snapshot),[{type:nt.enum.AgentStateMessage,threadId:e,agentName:r,nodeName:p,runId:t,running:i,role:"assistant",state:JSON.stringify(o),active:a}];case V.STATE_DELTA:{let S=g,x=po(o,S.delta,!0,!1);return x?(b(x.newDocument),[{type:nt.enum.AgentStateMessage,threadId:e,agentName:r,nodeName:p,runId:t,running:i,role:"assistant",state:JSON.stringify(o),active:a}]):[]}case V.MESSAGES_SNAPSHOT:return f=g.messages,[{type:nt.enum.AgentStateMessage,threadId:e,agentName:r,nodeName:p,runId:t,running:i,role:"assistant",state:JSON.stringify({...o,...(f?{messages:f}:{})}),active:!0}];case V.RUN_STARTED:return[];case V.RUN_FINISHED:return f&&(o.messages=f),Object.keys(o).length===0?[]:[{type:nt.enum.AgentStateMessage,threadId:e,agentName:r,nodeName:p,runId:t,running:i,role:"assistant",state:JSON.stringify({...o,...(f?{messages:Hj(f)}:{})}),active:!1}];case V.RUN_ERROR:{let S=g;return[{type:nt.enum.RunError,message:S.message,code:S.code}]}case V.STEP_STARTED:return p=g.stepName,h=[],m=null,[{type:nt.enum.AgentStateMessage,threadId:e,agentName:r,nodeName:p,runId:t,running:i,role:"assistant",state:JSON.stringify(o),active:!0}];case V.STEP_FINISHED:return h=[],m=null,[{type:nt.enum.AgentStateMessage,threadId:e,agentName:r,nodeName:p,runId:t,running:i,role:"assistant",state:JSON.stringify(o),active:!1}];default:return[]}}))};function Hj(e){let t=[];for(let r of e)if(r.role==="assistant"||r.role==="user"||r.role==="system"){let n=Gj(r.content);if(n){let o={id:r.id,role:r.role,content:n};t.push(o)}if(r.role==="assistant"&&r.toolCalls&&r.toolCalls.length>0)for(let o of r.toolCalls){let i={id:o.id,name:o.function.name,arguments:JSON.parse(o.function.arguments),parentMessageId:r.id};t.push(i)}}else if(r.role==="tool"){let n="unknown";for(let i of e)if(i.role==="assistant"&&i.toolCalls?.length){for(let a of i.toolCalls)if(a.id===r.toolCallId){n=a.function.name;break}}let o={id:r.id,result:r.content,actionExecutionId:r.toolCallId,actionName:n};t.push(o)}return t}var lf=e=>t=>{let r,n,o,i,a=()=>{if(!r||i!=="text")throw Error("No text message to close");let h={type:V.TEXT_MESSAGE_END,messageId:r.messageId};return i=void 0,r=void 0,e&&console.debug("[TRANSFORM]: TEXT_MESSAGE_END",JSON.stringify(h)),h},p=()=>{if(!n||i!=="tool")throw Error("No tool call to close");let h={type:V.TOOL_CALL_END,toolCallId:n.toolCallId};return i=void 0,n=void 0,e&&console.debug("[TRANSFORM]: TOOL_CALL_END",JSON.stringify(h)),h},f=()=>{if(!o||i!=="reasoning")throw Error("No reasoning message to close");let h={type:V.REASONING_MESSAGE_END,messageId:o.messageId};return i=void 0,o=void 0,e&&console.debug("[TRANSFORM]: REASONING_MESSAGE_END",JSON.stringify(h)),h},m=()=>i==="text"?[a()]:i==="tool"?[p()]:i==="reasoning"?[f()]:[];return t.pipe(rr(h=>{switch(h.type){case V.TEXT_MESSAGE_START:case V.TEXT_MESSAGE_CONTENT:case V.TEXT_MESSAGE_END:case V.TOOL_CALL_START:case V.TOOL_CALL_ARGS:case V.TOOL_CALL_END:case V.TOOL_CALL_RESULT:case V.STATE_SNAPSHOT:case V.STATE_DELTA:case V.MESSAGES_SNAPSHOT:case V.CUSTOM:case V.RUN_STARTED:case V.RUN_FINISHED:case V.RUN_ERROR:case V.STEP_STARTED:case V.STEP_FINISHED:case V.THINKING_START:case V.THINKING_END:case V.THINKING_TEXT_MESSAGE_START:case V.THINKING_TEXT_MESSAGE_CONTENT:case V.THINKING_TEXT_MESSAGE_END:case V.REASONING_START:case V.REASONING_MESSAGE_START:case V.REASONING_MESSAGE_CONTENT:case V.REASONING_MESSAGE_END:case V.REASONING_END:return[...m(),h];case V.RAW:case V.ACTIVITY_SNAPSHOT:case V.ACTIVITY_DELTA:case V.REASONING_ENCRYPTED_VALUE:return[h];case V.TEXT_MESSAGE_CHUNK:let C=h,b=[];if((i!=="text"||C.messageId!==void 0&&C.messageId!==r?.messageId)&&b.push(...m()),i!=="text"){if(C.messageId===void 0)throw Error("First TEXT_MESSAGE_CHUNK must have a messageId");r={messageId:C.messageId},i="text";let R={type:V.TEXT_MESSAGE_START,messageId:C.messageId,role:C.role||"assistant"};b.push(R),e&&console.debug("[TRANSFORM]: TEXT_MESSAGE_START",JSON.stringify(R))}if(C.delta!==void 0){let R={type:V.TEXT_MESSAGE_CONTENT,messageId:r.messageId,delta:C.delta};b.push(R),e&&console.debug("[TRANSFORM]: TEXT_MESSAGE_CONTENT",JSON.stringify(R))}return b;case V.TOOL_CALL_CHUNK:let g=h,S=[];if((i!=="tool"||g.toolCallId!==void 0&&g.toolCallId!==n?.toolCallId)&&S.push(...m()),i!=="tool"){if(g.toolCallId===void 0)throw Error("First TOOL_CALL_CHUNK must have a toolCallId");if(g.toolCallName===void 0)throw Error("First TOOL_CALL_CHUNK must have a toolCallName");n={toolCallId:g.toolCallId,toolCallName:g.toolCallName,parentMessageId:g.parentMessageId},i="tool";let R={type:V.TOOL_CALL_START,toolCallId:g.toolCallId,toolCallName:g.toolCallName,parentMessageId:g.parentMessageId};S.push(R),e&&console.debug("[TRANSFORM]: TOOL_CALL_START",JSON.stringify(R))}if(g.delta!==void 0){let R={type:V.TOOL_CALL_ARGS,toolCallId:n.toolCallId,delta:g.delta};S.push(R),e&&console.debug("[TRANSFORM]: TOOL_CALL_ARGS",JSON.stringify(R))}return S;case V.REASONING_MESSAGE_CHUNK:let x=h,w=[];if((i!=="reasoning"||x.messageId&&x.messageId!==o?.messageId)&&w.push(...m()),i!=="reasoning"){if(x.messageId===void 0)throw Error("First REASONING_MESSAGE_CHUNK must have a messageId");o={messageId:x.messageId},i="reasoning";let R={type:V.REASONING_MESSAGE_START,messageId:x.messageId};w.push(R),e&&console.debug("[TRANSFORM]: REASONING_MESSAGE_START",JSON.stringify(R))}if(x.delta!==void 0){let R={type:V.REASONING_MESSAGE_CONTENT,messageId:o.messageId,delta:x.delta};w.push(R),e&&console.debug("[TRANSFORM]: REASONING_MESSAGE_CONTENT",JSON.stringify(R))}return w}return h.type,[]}),Ii(()=>{m()}))},NS=class{runNext(e,t){return t.run(e).pipe(lf(!1))}runNextWithState(e,t){let r=Ze(e.messages||[]),n=Ze(e.state||{}),o=new Ap;return pI(e,o,t,[]).subscribe(i=>{i.messages!==void 0&&(r=i.messages),i.state!==void 0&&(n=i.state)}),this.runNext(e,t).pipe(Dp(/*#__PURE__*/function(){var _ref78=_asyncToGenerator(function*(i){return o.next(i),yield new Promise(a=>setTimeout(a,0)),{event:i,messages:Ze(r),state:Ze(n)}});return function(_x202){return _ref78.apply(this,arguments)}}()))}},zj=class extends NS{constructor(e){super(),this.fn=e}run(e,t){return this.fn(e,t)}};function Wj(e){let t=e.content;if(Array.isArray(t)){let r=t.filter(n=>typeof n=="object"&&!!n&&"type"in n&&n.type==="text"&&typeof n.text=="string").map(n=>n.text).join("");return{...e,content:r}}return typeof t=="string"?e:{...e,content:""}}var Yj=class extends NS{run(e,t){let{parentRunId:r,...n}=e,o={...n,messages:n.messages.map(Wj)};return this.runNext(o,t)}},sI="THINKING_START",cI="THINKING_END",uI="THINKING_TEXT_MESSAGE_START",lI="THINKING_TEXT_MESSAGE_CONTENT",dI="THINKING_TEXT_MESSAGE_END",Kj=class extends NS{constructor(...e){super(...e),this.currentReasoningId=null,this.currentMessageId=null}warnAboutTransformation(e,t){process.env.SUPPRESS_TRANSFORMATION_WARNINGS||console.warn(`AG-UI is converting ${e} to ${t}. To remove this warning, upgrade your AG-UI integration package (e.g. @ag-ui/langgraph). To surpress it, set SUPPRESS_TRANSFORMATION_WARNINGS=true in your .env file.`)}run(e,t){return this.currentReasoningId=null,this.currentMessageId=null,this.runNext(e,t).pipe(Ri(r=>this.transformEvent(r)))}transformEvent(e){switch(e.type){case sI:{this.currentReasoningId=ru();let{title:t,...r}=e;return this.warnAboutTransformation(sI,V.REASONING_START),{...r,type:V.REASONING_START,messageId:this.currentReasoningId}}case uI:return this.currentMessageId=ru(),this.warnAboutTransformation(uI,V.REASONING_MESSAGE_START),{...e,type:V.REASONING_MESSAGE_START,messageId:this.currentMessageId,role:"assistant"};case lI:{let{delta:t,...r}=e;return this.warnAboutTransformation(lI,V.REASONING_MESSAGE_CONTENT),{...r,type:V.REASONING_MESSAGE_CONTENT,messageId:this.currentMessageId??ru(),delta:t}}case dI:{let t=this.currentMessageId??ru();return this.warnAboutTransformation(dI,V.REASONING_MESSAGE_END),{...e,type:V.REASONING_MESSAGE_END,messageId:t}}case cI:{let t=this.currentReasoningId??ru();return this.warnAboutTransformation(cI,V.REASONING_END),{...e,type:V.REASONING_END,messageId:t}}default:return e}}},Xj="0.0.45",Jj=class{get maxVersion(){return Xj}constructor({agentId:e,description:t,threadId:r,initialMessages:n,initialState:o,debug:i}={}){this.debug=!1,this.subscribers=[],this.isRunning=!1,this.middlewares=[],this.agentId=e,this.description=t??"",this.threadId=r??ao(),this.messages=Ze(n??[]),this.state=Ze(o??{}),this.debug=i??!1,uf(this.maxVersion,"0.0.39")<=0&&this.middlewares.unshift(new Yj),uf(this.maxVersion,"0.0.45")<=0&&this.middlewares.unshift(new Kj)}subscribe(e){return this.subscribers.push(e),{unsubscribe:()=>{this.subscribers=this.subscribers.filter(t=>t!==e)}}}use(...e){let t=e.map(r=>typeof r=="function"?new zj(r):r);return this.middlewares.push(...t),this}runAgent(e,t){var _this35=this;return _asyncToGenerator(function*(){try{_this35.isRunning=!0,_this35.agentId=_this35.agentId??ao();let r=_this35.prepareRunAgentInput(e),n,o=new Set(_this35.messages.map(f=>f.id)),i=[{onRunFinishedEvent:f=>{n=f.result}},..._this35.subscribers,t??{}];yield _this35.onInitialize(r,i),_this35.activeRunDetach$=new on;let a;_this35.activeRunCompletionPromise=new Promise(f=>{a=f}),yield Np(vp(()=>_this35.middlewares.length===0?_this35.run(r):_this35.middlewares.reduceRight((f,m)=>({run:h=>m.run(h,f)}),_this35).run(r),lf(_this35.debug),_S(_this35.debug),f=>f.pipe(qp(_this35.activeRunDetach$)),f=>_this35.apply(r,f,i),f=>_this35.processApplyEvents(r,f,i),Zc(f=>(_this35.isRunning=!1,_this35.onError(r,f,i))),Ii(()=>{_this35.isRunning=!1,_this35.onFinalize(r,i),a?.(),a=void 0,_this35.activeRunCompletionPromise=void 0,_this35.activeRunDetach$=void 0}))(dt(null)));let p=Ze(_this35.messages).filter(f=>!o.has(f.id));return{result:n,newMessages:p}}finally{_this35.isRunning=!1}})()}connect(e){throw new rS}connectAgent(e,t){var _this36=this;return _asyncToGenerator(function*(){try{_this36.isRunning=!0,_this36.agentId=_this36.agentId??ao();let r=_this36.prepareRunAgentInput(e),n,o=new Set(_this36.messages.map(f=>f.id)),i=[{onRunFinishedEvent:f=>{n=f.result}},..._this36.subscribers,t??{}];yield _this36.onInitialize(r,i),_this36.activeRunDetach$=new on;let a;_this36.activeRunCompletionPromise=new Promise(f=>{a=f}),yield Np(vp(()=>_this36.connect(r),lf(_this36.debug),_S(_this36.debug),f=>f.pipe(qp(_this36.activeRunDetach$)),f=>_this36.apply(r,f,i),f=>_this36.processApplyEvents(r,f,i),Zc(f=>(_this36.isRunning=!1,f instanceof rS?Cp:_this36.onError(r,f,i))),Ii(()=>{_this36.isRunning=!1,_this36.onFinalize(r,i),a?.(),a=void 0,_this36.activeRunCompletionPromise=void 0,_this36.activeRunDetach$=void 0}))(dt(null)));let p=Ze(_this36.messages).filter(f=>!o.has(f.id));return{result:n,newMessages:p}}finally{_this36.isRunning=!1}})()}abortRun(){}detachActiveRun(){var _this37=this;return _asyncToGenerator(function*(){if(!_this37.activeRunDetach$)return;let e=_this37.activeRunCompletionPromise??Promise.resolve();_this37.activeRunDetach$.next(),_this37.activeRunDetach$?.complete(),yield e})()}apply(e,t,r){return pI(e,t,this,r)}processApplyEvents(e,t,r){return t.pipe(vS(n=>{n.messages&&(this.messages=n.messages,r.forEach(o=>{o.onMessagesChanged?.({messages:this.messages,state:this.state,agent:this,input:e})})),n.state&&(this.state=n.state,r.forEach(o=>{o.onStateChanged?.({state:this.state,messages:this.messages,agent:this,input:e})}))}))}prepareRunAgentInput(e){let t=Ze(this.messages).filter(r=>r.role!=="activity");return{threadId:this.threadId,runId:e?.runId||ao(),tools:Ze(e?.tools??[]),context:Ze(e?.context??[]),forwardedProps:Ze(e?.forwardedProps??{}),state:Ze(this.state),messages:t}}onInitialize(e,t){var _this38=this;return _asyncToGenerator(function*(){let r=yield We(t,_this38.messages,_this38.state,(n,o,i)=>n.onRunInitialized?.({messages:o,state:i,agent:_this38,input:e}));(r.messages!==void 0||r.state!==void 0)&&(r.messages&&(_this38.messages=r.messages,e.messages=r.messages,t.forEach(n=>{n.onMessagesChanged?.({messages:_this38.messages,state:_this38.state,agent:_this38,input:e})})),r.state&&(_this38.state=r.state,e.state=r.state,t.forEach(n=>{n.onStateChanged?.({state:_this38.state,messages:_this38.messages,agent:_this38,input:e})})))})()}onError(e,t,r){return wi(We(r,this.messages,this.state,(n,o,i)=>n.onRunFailed?.({error:t,messages:o,state:i,agent:this,input:e}))).pipe(Ri(n=>{let o=n;if((o.messages!==void 0||o.state!==void 0)&&(o.messages!==void 0&&(this.messages=o.messages,r.forEach(i=>{i.onMessagesChanged?.({messages:this.messages,state:this.state,agent:this,input:e})})),o.state!==void 0&&(this.state=o.state,r.forEach(i=>{i.onStateChanged?.({state:this.state,messages:this.messages,agent:this,input:e})}))),o.stopPropagation!==!0)throw console.error("Agent execution failed:",t),t;return{}}))}onFinalize(e,t){var _this39=this;return _asyncToGenerator(function*(){let r=yield We(t,_this39.messages,_this39.state,(n,o,i)=>n.onRunFinalized?.({messages:o,state:i,agent:_this39,input:e}));(r.messages!==void 0||r.state!==void 0)&&(r.messages!==void 0&&(_this39.messages=r.messages,t.forEach(n=>{n.onMessagesChanged?.({messages:_this39.messages,state:_this39.state,agent:_this39,input:e})})),r.state!==void 0&&(_this39.state=r.state,t.forEach(n=>{n.onStateChanged?.({state:_this39.state,messages:_this39.messages,agent:_this39,input:e})})))})()}clone(){let e=Object.create(Object.getPrototypeOf(this));return e.agentId=this.agentId,e.description=this.description,e.threadId=this.threadId,e.messages=Ze(this.messages),e.state=Ze(this.state),e.debug=this.debug,e.isRunning=this.isRunning,e.subscribers=[...this.subscribers],e.middlewares=[...this.middlewares],e}addMessage(e){var _this40=this;this.messages.push(e),_asyncToGenerator(function*(){for(let t of _this40.subscribers)yield t.onNewMessage?.({message:e,messages:_this40.messages,state:_this40.state,agent:_this40});if(e.role==="assistant"&&e.toolCalls)for(let t of e.toolCalls)for(let r of _this40.subscribers)yield r.onNewToolCall?.({toolCall:t,messages:_this40.messages,state:_this40.state,agent:_this40});for(let t of _this40.subscribers)yield t.onMessagesChanged?.({messages:_this40.messages,state:_this40.state,agent:_this40})})()}addMessages(e){var _this41=this;this.messages.push(...e),_asyncToGenerator(function*(){for(let t of e){for(let r of _this41.subscribers)yield r.onNewMessage?.({message:t,messages:_this41.messages,state:_this41.state,agent:_this41});if(t.role==="assistant"&&t.toolCalls)for(let r of t.toolCalls)for(let n of _this41.subscribers)yield n.onNewToolCall?.({toolCall:r,messages:_this41.messages,state:_this41.state,agent:_this41})}for(let t of _this41.subscribers)yield t.onMessagesChanged?.({messages:_this41.messages,state:_this41.state,agent:_this41})})()}setMessages(e){var _this42=this;this.messages=Ze(e),_asyncToGenerator(function*(){for(let t of _this42.subscribers)yield t.onMessagesChanged?.({messages:_this42.messages,state:_this42.state,agent:_this42})})()}setState(e){var _this43=this;this.state=Ze(e),_asyncToGenerator(function*(){for(let t of _this43.subscribers)yield t.onStateChanged?.({messages:_this43.messages,state:_this43.state,agent:_this43})})()}legacy_to_be_removed_runAgentBridged(e){this.agentId=this.agentId??ao();let t=this.prepareRunAgentInput(e);return(this.middlewares.length===0?this.run(t):this.middlewares.reduceRight((r,n)=>({run:o=>n.run(o,r)}),this).run(t)).pipe(lf(this.debug),_S(this.debug),$j(this.threadId,t.runId,this.agentId),r=>r.pipe(Ri(n=>(this.debug&&console.debug("[LEGACY]:",JSON.stringify(n)),n))))}},fI=class extends Jj{requestInit(e){return{method:"POST",headers:{...this.headers,"Content-Type":"application/json",Accept:"text/event-stream"},body:JSON.stringify(e),signal:this.abortController.signal}}runAgent(e,t){return this.abortController=e?.abortController??new s.AbortController,super.runAgent(e,t)}abortRun(){this.abortController.abort(),super.abortRun()}constructor(e){super(e),this.abortController=new s.AbortController,this.url=e.url,this.headers=Ze(e.headers??{})}run(e){return Oj(Tj(this.url,this.requestInit(e)))}clone(){let e=super.clone();e.url=this.url,e.headers=Ze(this.headers??{});let t=new s.AbortController,r=this.abortController.signal;return r.aborted&&t.abort(r.reason),e.abortController=t,e}};d();c();l();u();var mI=(e,t,r)=>{let n=Ye(t,r),o=e?.trim();if(!n||!t||!o)throw new Error("Missing required parameters for answer endpoint");let i=`/api/preview/organizations/${t}/agents`;return`${n}${i}/${o}`};var DS=class extends fI{requestInit(t){let{params:r,accessToken:n,recordDebugSession:o}=t.forwardedProps||{},i={...r,...(o&&{recordDebugSession:!0})};return{method:"POST",headers:{...this.headers,Authorization:`Bearer ${n}`,"Content-Type":"application/json",Accept:"text/event-stream, application/json"},body:JSON.stringify(i),signal:this.abortController.signal}}},gI=(e,t,r)=>new DS({url:`${mI(e,t,r)}/answer`});d();c();l();u();d();c();l();u();var Zj=new $({required:!0}),hI=new $({required:!0,constrainTo:Pd}),yI=e=>({...e,name:kd(e.name)}),SI=T("followUpAnswers/setIsEnabled",e=>O(e,new de({required:!0}))),vI=T("followUpAnswers/setFollowUpAnswersConversationId",e=>O(e,z)),AI=T("followUpAnswers/setFollowUpAnswersConversationToken",e=>O(e,z)),CI=T("followUpAnswers/clearFollowUpAnswersConversationToken"),VAe=T("followUpAnswers/createFollowUpAnswer",e=>O(e,{question:z})),jAe=T("followUpAnswers/setActiveFollowUpAnswerId",e=>O(e,z)),LAe=T("followUpAnswers/setFollowUpAnswerContentFormat",e=>O(e,{contentFormat:Od,answerId:z})),UAe=T("followUpAnswers/setFollowUpIsLoading",e=>O(e,{isLoading:new de({required:!0}),answerId:z})),QAe=T("followUpAnswers/setFollowUpIsStreaming",e=>O(e,{isStreaming:new de({required:!0}),answerId:z})),BAe=T("followUpAnswers/followUpMessageChunkReceived",e=>O(e,{textDelta:Zj,answerId:z})),GAe=T("followUpAnswers/followUpCitationsReceived",e=>O(e,{citations:new ne({required:!0,each:new Y({values:By})}),answerId:z})),$Ae=T("followUpAnswers/followUpCompleted",e=>O(e,{answerId:z,cannotAnswer:new de({required:!1})})),HAe=T("followUpAnswers/followUpFailed",e=>O(e,{message:new $,code:new oe({min:0}),answerId:z})),zAe=T("followUpAnswers/activeFollowUpStartFailed",e=>O(e,{message:new $})),WAe=T("followUpAnswers/likeFollowUp",e=>O(e,{answerId:z})),YAe=T("followUpAnswers/dislikeFollowUp",e=>O(e,{answerId:z})),KAe=T("followUpAnswers/submitFollowUpFeedback",e=>O(e,{answerId:z})),bI=T("followUpAnswers/resetFollowUpAnswers"),XAe=T("followUpAnswers/stepStarted",e=>O(yI(e),{answerId:z,name:hI,startedAt:new oe({min:0,required:!0})})),JAe=T("followUpAnswers/stepFinished",e=>O(yI(e),{answerId:z,name:hI,finishedAt:new oe({min:0,required:!0})}));d();c();l();u();var eL={"KNOWLEDGE:SSE_MAX_DURATION_EXCEEDED":1e3,"KNOWLEDGE:SSE_FOLLOW_UP_NOT_SUPPORTED":1001,"KNOWLEDGE:NOT_FOUND":1002,"KNOWLEDGE:SSE_MODELS_NOT_AVAILABLE":1003,"KNOWLEDGE:SSE_INTERNAL_ERROR":1004,"KNOWLEDGE:TURN_LIMIT_REACHED":1005};function xI(e){return e?eL[e]??1004:1004}function tL(e){let t=r=>e.code===r;return Object.defineProperties(e,{isMaxDurationExceededError:{value:()=>t(1e3),enumerable:!1},isFollowupNotSupportedError:{value:()=>t(1001),enumerable:!1},isConversationNotFoundError:{value:()=>t(1002),enumerable:!1},isSseModelNotAvailableError:{value:()=>t(1003),enumerable:!1},isSseInternalError:{value:()=>t(1004),enumerable:!1},isSseTurnLimitReachedError:{value:()=>t(1005),enumerable:!1}}),e}function df(e){if(e)return tL({...e})}var wI=e=>{let t="",r=!1;return{onRunStartedEvent:({event:n})=>{t=n.runId,r=!1,e(Da(n.runId)),e(Jr(!1)),e(Jo(!0)),e(vI(n.threadId)),e(CI())},onStepStartedEvent:({event:n})=>{e(Bd({name:n.stepName,startedAt:n.timestamp??Date.now()}))},onStepFinishedEvent:({event:n})=>{e(Gd({name:n.stepName,finishedAt:n.timestamp??Date.now()}))},onTextMessageContentEvent:({event:n})=>{n.delta.length>0&&(r=!0),e(Zo({textDelta:n.delta}))},onCustomEvent:({event:n})=>{let{name:o,value:i}=n;switch(o){case"header":{i?.contentFormat&&e(ri(i.contentFormat)),typeof i?.followUpEnabled=="boolean"&&e(SI(i.followUpEnabled)),i?.conversationToken&&e(AI(i.conversationToken));return}case"citations":{e(ei({citations:i.citations}));return}}},onRunErrorEvent:({event:n})=>{let o=xI(n.code);e(ti({message:n.message,code:o}))},onRunFinishedEvent:({event:n})=>{let o=n.result?.completionReason==="ANSWERED",i=o?!r:void 0;e(Bc(o)),e(ni(!o)),e(Jo(!1)),e(Pa(o,t,i,n.threadId)),e(ka())}}};var RI=()=>{let e,t=()=>{e?.abortRun(),e=void 0};return{run:function(){var _ref83=_asyncToGenerator(function*(n,o,i){t();let a=Ol(n),p=Sb(n),f=vb(n),m=yb(n),h=Ab(n),C=gI(a,p,f);e=C;let b=wI(o),g=Sw(n,i());try{o(Jr(!0)),yield C.runAgent({forwardedProps:{params:g,accessToken:m,recordDebugSession:h}},b)}catch(S){o(Jr(!1)),o(ti({message:"An error occurred while starting the answer generation."})),console.error("Error running the answer agent:",S)}});return function run(_x203,_x204,_x205){return _ref83.apply(this,arguments)}}(),abortRun:t}};var II=e=>{let t=AC({extra:e}),r=RI();return t.startListening({actionCreator:Te.pending,effect:function(){var _ref84=_asyncToGenerator(function*(n,o){let i=o.getState();if(!Yh(i))return;r.abortRun(),o.dispatch(lr()),o.dispatch(bI());let a=Xo(i)?.q;!a||a.trim()===""||r.run(i,o.dispatch,e.getNavigatorContext)});return function effect(_x206,_x207){return _ref84.apply(this,arguments)}}()}),t};d();c();l();u();var EI=e=>()=>t=>r=>{let n=r;if(!n.error)return t(r);let o=n.error;if(n.payload?.ignored||e.error({error:o,action:r},`Action dispatch error ${n.type}`),n.error.name!=="SchemaValidationError")return t(r)},FI=e=>t=>r=>n=>(e.debug({action:n,nextState:t.getState()},`Action dispatched: ${n.type}`),r(n));d();c();l();u();var qS=(e,t)=>{let{referrer:r,userAgent:n,location:o,clientId:i}=e.getMeta("");return{...(t?t():{}),referrer:r,userAgent:n,location:o,clientId:i}};d();c();l();u();function TI(e,t){let r={...e},n,o=i=>(a,p)=>{let f=i(a,p);return n?n(f,p):f};return{get combinedReducer(){let i=qv(Object.entries(t).filter(([a])=>!(a in r)).map(([a,p])=>[a,()=>p]));return o(Yi({...i,...r}))},containsAll(i){return Object.keys(i).every(p=>p in r)},add(i){Object.keys(i).filter(a=>!(a in r)).forEach(a=>{r[a]=i[a]})},addCrossReducer(i){n=i}}}d();c();l();u();d();c();l();u();function rL(e){if(!e||!nL(e))return null;try{let r=e.split(".")[1].replace(/-/g,"+").replace(/_/g,"/"),n=atob(r),o=decodeURIComponent(n.split("").map(i=>`%${`00${i.charCodeAt(0).toString(16)}`.slice(-2)}`).join(""));return JSON.parse(o)}catch{return null}}function PI(e,t=60){if(!e)return!1;let r=rL(e);if(!r||typeof r.exp!="number")return!1;let n=Math.floor(Date.now()/1e3);return r.exp<=n+t}function nL(e){return e?/^[A-Za-z0-9_-]{2,}(?:\.[A-Za-z0-9_-]{2,}){2}$/.test(e):!1}function OI(e,t){let r=0,n=null,o=_u(()=>{r=0},500),i=/*#__PURE__*/function(){var _ref85=_asyncToGenerator(function*(f,m=!1){let h=!n;h&&t&&(n=_asyncToGenerator(function*(){try{return yield t()}catch(b){if(!m)throw b;return null}})().finally(()=>{n=null}));let C=yield n;return h&&C&&f.dispatch(ha({accessToken:C})),C});return function i(_x208){return _ref85.apply(this,arguments)}}(),a=/*#__PURE__*/function(){var _ref87=_asyncToGenerator(function*(f){let m=f.getState(),h=iL(m);if(!(!h||!PI(h))){e.debug("Access token is expired or about to expire, attempting renewal.");try{(yield i(f))?e.debug("Access token was renewed."):e.warn("Access token renewal returned an empty token. Please check the #renewAccessToken function.")}catch(C){e.warn(C,"Access token renewal failed. A retry will occur if necessary.")}}});return function a(_x209){return _ref87.apply(this,arguments)}}(),p=/*#__PURE__*/function(){var _ref88=_asyncToGenerator(function*(f,m,h){if(r>=5)return e.warn("Attempted to renew the token but was not successful. Please check the #renewAccessToken function."),kI(f,m.error),m;!n&&(r++,o());try{yield i(f,!0)}catch(b){e.debug(b,"Token renewal failed in reactive path (piggybacked on a proactive renewal). The action will be re-dispatched.")}f.dispatch(h)});return function p(_x210,_x211,_x212){return _ref88.apply(this,arguments)}}();return f=>m=>(/*#__PURE__*/function(){var _ref89=_asyncToGenerator(function*(h){let C=typeof h=="function",b=typeof t=="function";if(!C)return m(h);b&&(yield a(f));let g=yield m(h);return oL(g)?b?yield p(f,g,h):(e.warn("Unable to renew the expired token because a renew function was not provided. Please specify the #renewAccessToken option when initializing the engine."),kI(f,g.error),g):g});return function(_x213){return _ref89.apply(this,arguments)}}())}function oL(e){return typeof e=="object"&&e!==null&&"error"in e&&e.error?.name===new $i().name}function kI(e,t){e.dispatch(Ea({status:401,statusCode:401,message:t.message,type:t.name}))}function iL(e){return e.configuration.accessToken}d();c();l();u();function _I({reducer:e,preloadedState:t,middlewares:r=[],thunkExtraArguments:n,name:o}){return aC({reducer:e,preloadedState:t,devTools:{stateSanitizer:i=>i.history?{...i,history:"<<OMIT>>"}:i,name:o,shouldHotReload:!1},middleware:i=>i({thunk:{extraArgument:n}}).prepend(...r).concat(FI(n.logger))})}function aL(e,t){let{analytics:r}=e,{analyticsClientMiddleware:n,...o}=r??{},i={...o,...(r?.proxyBaseUrl&&{apiBaseUrl:r.proxyBaseUrl,nexApiBaseUrl:r.proxyBaseUrl})};return i.analyticsMode!=="next"&&Dv()?(t.info("Analytics disabled since doNotTrack is active."),{...i,enabled:!1}):i}function NI(e,t){let r={...e.reducers,configuration:Ce,version:Rw},n=sL({...e,reducers:r},t,Ce),{accessToken:o,environment:i,organizationId:a}=e.configuration;n.dispatch(ha({accessToken:o,environment:i,organizationId:a}));let p=aL(e.configuration,n.logger);return p&&n.dispatch(Ul(p)),n}function sL(e,t,r){let{reducers:n,navigatorContextProvider:o}=e,i=TI({...n,configurationReducer:r},e.preloadedState??{});e.crossReducer&&i.addCrossReducer(e.crossReducer);let a=t.logger,p={...t,get relay(){return Cc(m.state,o)},get navigatorContext(){return qS(this.relay,o)}},f=cL(e,p,i),m={addReducers(h){i.containsAll(h)||(i.add(h),f.replaceReducer(i.combinedReducer))},dispatch:f.dispatch,subscribe:f.subscribe,enableAnalytics(){f.dispatch(Bl())},disableAnalytics(){f.dispatch(Ql())},get state(){return f.getState()},get relay(){return Cc(this.state,o)},get navigatorContext(){return qS(this.relay,o)},logger:a,store:f};return m}function cL(e,t,r){let{preloadedState:n,configuration:o}=e,i=o.name||"coveo-headless",a=uL(e,t.logger,()=>t.navigatorContext);return _I({preloadedState:n,reducer:r.combinedReducer,middlewares:a,thunkExtraArguments:t,name:i})}function uL(e,t,r){let{renewAccessToken:n}=e.configuration,o=OI(t,n),i=II({getNavigatorContext:r});return[Nw,o,EI(t),Ew].concat(oi.middleware,i.middleware,e.middlewares||[])}var lL=`[Warning] A component from the Coveo Headless library has been instantiated with the Analytics Mode: "Next".
42
42
  However, this mode is not available for Coveo for Service features, and this configuration may not work as expected.
43
43
  Please switch back to the "legacy" analytics mode to ensure proper functionality.
44
44
  For more information, refer to the documentation: https://docs.coveo.com/en/o3r90189/build-a-search-ui/event-protocol`;function pf(e){e==="next"&&console.warn(lL)}d();c();l();u();var BI=Er(QI(),1);function GI(e){return(0,BI.pino)({name:"@coveo/headless",level:e?.level||"warn",formatters:{log:e?.logFormatter}})}d();c();l();u();function $I(e,t){let r=FL(e),n=fr,o=TL(e);return{analyticsClientMiddleware:r,validatePayload:n,preprocessRequest:o,logger:t}}function FL(e){let{analytics:t}=e,r=(n,o)=>o;return t?.analyticsClientMiddleware||r}function TL(e){return e.preprocessRequest||Qu}d();c();l();u();d();c();l();u();var HI={organizationId:z,accessToken:z,name:new $({required:!1,emptyAllowed:!1}),analytics:new Y({options:{required:!1},values:{enabled:new de({required:!1}),originContext:new $({required:!1}),originLevel2:new $({required:!1}),originLevel3:new $({required:!1}),analyticsMode:new $({constrainTo:["legacy","next"],required:!1,default:"next"}),proxyBaseUrl:new $({required:!1,url:!0}),trackingId:new $({required:!1,emptyAllowed:!1,regex:/^[a-zA-Z0-9_\-.]{1,100}$/})}}),environment:new $({required:!1,default:"prod",constrainTo:["prod","hipaa","stg","dev"]})};function zI(){return{organizationId:"searchuisamples",accessToken:"xx564559b1-0045-48e1-953c-3addd1ee4457"}}var WI=new Fe({...HI,insightId:z,search:new Y({options:{required:!1},values:{locale:ze}})}),PL="2729db39-d7fd-4504-a06e-668c64968c95";function QS(){return{...zI(),insightId:PL}}var kL={insightConfiguration:$l,search:we,insightInterface:Yn,searchHub:Cd,resultPreview:Ia};function YI(e){let t=GI(e.loggerOptions);OL(e.configuration,t);let r=_L(e.configuration,t),n=NL(t),o={...$I(e.configuration,t),apiClient:r,streamingClient:n},i={...e,reducers:kL},a=NI(i,o);pf(a.state.configuration.analytics.analyticsMode);let{insightId:p,search:f}=e.configuration;return a.dispatch(Gl({insightId:p})),a.dispatch($r()),f&&a.dispatch(ya(f)),{...a,get state(){return a.state},executeFirstSearch(m=ed()){Ad(a.state)||a.dispatch(Ae({legacy:m,next:Vb()}))}}}function OL(e,t){try{WI.validate(e)}catch(r){throw t.error(r,"Insight engine configuration error"),r}}function _L(e,t){return new Bu({logger:t,preprocessRequest:e.preprocessRequest||Qu})}function NL(e){return new Uu({logger:e})}d();c();l();u();function me(e){let t,r=new Map,n=()=>r.size===0,o=i=>{try{let a=JSON.stringify(i),p=t!==a;return t=a,p}catch(a){return console.warn("Could not detect if state has changed, check the controller \"get state method\"",a),!0}};return{subscribe(i){i();let a=Symbol(),p;return n()&&(t=JSON.stringify(this.state),p=e.subscribe(()=>{o(this.state)&&r.forEach(f=>f())})),r.set(a,i),()=>{r.delete(a),n()&&p?.()}},get state(){return{}}}}d();c();l();u();d();c();l();u();var KI={articleLanguage:ze,articlePublishStatus:ze,articleVersionNumber:ze,caseId:z,knowledgeArticleId:ze,name:ze,permanentId:ze,resultUrl:ze,source:ze,title:z,uriHash:ze,isAttachedFromCitation:new de({required:!1,default:!1})},DL=new Y({options:{required:!0},values:KI}),gf=T("insight/attachToCase/setAttachedResults",e=>O(e,{results:new ne({each:DL}),loading:new de({required:!1,default:!1})})),go=T("insight/attachToCase/attach",e=>XI(e)),ho=T("insight/attachToCase/detach",e=>XI(e)),XI=e=>ee(e.permanentId)&&ee(e.uriHash)?{payload:e,error:Fr(new ko("Either permanentId or uriHash is required"))}:O(e,KI);d();c();l();u();d();c();l();u();var Nr=e=>{let t=Z(e.insightCaseContext);return{targetId:t.caseId||"",targetType:"Case",caseNumber:t.caseNumber}};var ts=e=>te("caseAttach")({prefix:"insight/caseAttach",__legacy__getBuilder:(t,r)=>{Ot(e);let n=Z(r.insightCaseContext);return t.logCaseAttach(Xe(e,r),Je(e),n)},analyticsType:"InsightPanel.ItemAction",analyticsPayloadBuilder:t=>{let r=Xe(e,t);return{itemMetadata:Tr(e,t),position:r.documentPosition,responseId:t.search?.response.searchUid||"",action:"attach",context:Nr(t)}}}),rs=e=>te("caseDetach")({prefix:"insight/caseDetach",__legacy__getBuilder:(t,r)=>t.logCaseDetach(e.raw.urihash,Z(r.insightCaseContext)),analyticsType:"InsightPanel.DetachItem",analyticsPayloadBuilder:t=>({itemMetadata:Tr(e,t),context:Nr(t)})});d();c();l();u();d();c();l();u();function JI(){return{results:[],loading:!1}}var yo=le(JI(),e=>{e.addCase(gf,(t,r)=>{let{results:n,loading:o}=r.payload;"results"in t&&t.results?.length>0||(t.results=n,o&&(t.loading=o))}).addCase(go,(t,r)=>{(!ee(r.payload.permanentId)||!ee(r.payload.uriHash))&&(t.results=[...t.results,r.payload])}).addCase(ho,(t,r)=>{t.results=t.results.filter(n=>qL(n,r.payload))})}),qL=(e,t)=>{let r=!ee(e.permanentId)&&e?.permanentId===t?.permanentId,n=!ee(e.uriHash)&&e?.uriHash===t?.uriHash;return!(e.caseId===t.caseId)||!r&&!n};d();c();l();u();var hf=(e,t)=>Ui(e.raw[t])?String(e.raw[t]):void 0,ns=(e,t)=>({articleLanguage:hf(e,"sflanguage"),articleVersionNumber:hf(e,"sflanguage"),articlePublishStatus:hf(e,"articlePublishStatus"),caseId:t,knowledgeArticleId:hf(e,"knowledgeArticleId"),permanentId:e.raw?.permanentid,uriHash:e.raw?.urihash,resultUrl:e.clickUri,source:e.raw.source,title:e.title});function ZI(e,t){if(!ML(e))throw ie;let{dispatch:r}=e,n=()=>e.state.attachedResults,o=me(e),{result:i,caseId:a}=t.options,p=()=>ee(a)||ee(i.raw.permanentid)&&ee(i.raw.urihash)?!1:e.state.attachedResults.results.some(f=>{let m=a===f.caseId,h=!ee(f.permanentId)&&f.permanentId===i.raw.permanentid,C=!ee(f.uriHash)&&f.uriHash===i.raw.urihash;return m&&(h||C)});return{...o,get state(){return n()},isAttached(){return p()},attach(){r(go(ns(i,a))),r(ts(i))},detach(){r(ho(ns(i,a))),r(rs(i))}}}function ML(e){return e.addReducers({configuration:Ce,attachedResults:yo}),!0}d();c();l();u();function eE(e,t){if(!VL(e))throw ie;let{dispatch:r}=e,n=me(e),{caseId:o}=t.options,i=p=>ee(o)||ee(p.raw.permanentid)&&ee(p.raw.urihash)?!1:e.state.attachedResults.results.some(f=>{let m=o===f.caseId,h=!ee(f.permanentId)&&f.permanentId===p.raw.permanentid,C=!ee(f.uriHash)&&f.uriHash===p.raw.urihash;return m&&(h||C)}),a=()=>e.state.attachedResults.results.filter(p=>p.caseId===o);return{...n,get state(){return{results:a(),loading:e.state.attachedResults.loading}},isAttached(p){return i(p)},attach(p){r(go(ns(p,o))),r(ts(p))},detach(p){r(ho(ns(p,o))),r(rs(p))}}}function VL(e){return e.addReducers({configuration:Ce,attachedResults:yo}),!0}d();c();l();u();d();c();l();u();d();c();l();u();var he=z;d();c();l();u();var jL={state:new Ge({required:!0}),numberOfResults:new oe({required:!0,min:0}),value:new $({required:!0,emptyAllowed:!0}),path:new ne({required:!0,each:z}),moreValuesAvailable:new de({required:!1})};function BS(e){e.children.forEach(t=>{BS(t)}),fr({state:e.state,numberOfResults:e.numberOfResults,value:e.value,path:e.path,moreValuesAvailable:e.moreValuesAvailable},jL)}var os={facetId:he,field:z,tabs:new Y({options:{required:!1},values:{included:new ne({each:new $}),excluded:new ne({each:new $})}}),activeTab:new $({required:!1}),delimitingCharacter:new $({required:!1,emptyAllowed:!0}),filterFacetCount:new de({required:!1}),injectionDepth:new oe({required:!1,min:0}),numberOfValues:new oe({required:!1,min:1}),sortCriteria:new Ge({required:!1}),basePath:new ne({required:!1,each:z}),filterByBasePath:new de({required:!1})};var is=T("categoryFacet/register",e=>O(e,os)),as=T("categoryFacet/toggleSelectValue",e=>{try{return fr(e.facetId,z),BS(e.selection),{payload:e,error:null}}catch(t){return{payload:e,error:Fr(t)}}}),So=T("categoryFacet/deselectAll",e=>O(e,os.facetId)),ou=T("categoryFacet/updateNumberOfValues",e=>O(e,{facetId:os.facetId,numberOfValues:os.numberOfValues})),yf=T("categoryFacet/updateSortCriterion",e=>O(e,{facetId:os.facetId,criterion:new Ge})),tE=T("categoryFacet/updateBasePath",e=>O(e,{facetId:os.facetId,basePath:new ne({each:z})}));d();c();l();u();var zRe={categoryFacetId:he,categoryFacetPath:new ne({required:!0,each:z})};var rE=()=>({actionCause:"breadcrumbFacet"});d();c();l();u();var LL={categoryFacetId:he,categoryFacetPath:new ne({required:!0,each:z})},UL=(e,{categoryFacetId:t,categoryFacetPath:r})=>{let o=e.categoryFacetSet[t]?.request.field,i=`${o}_${t}`;return{categoryFacetId:t,categoryFacetPath:r,categoryFacetField:o,categoryFacetTitle:i}},Sf=e=>te("breadcrumbFacet")("analytics/categoryFacet/breadcrumb",(t,r)=>{O(e,LL);let n={...UL(r,e),...Z(r.insightCaseContext)};return t.logBreadcrumbFacet(n)});d();c();l();u();d();c();l();u();var Qe=T("facetOptions/update",(e={freezeFacetOrder:!0})=>O(e,{freezeFacetOrder:new de({required:!1})})),nr=T("facetOptions/facet/enable",e=>O(e,he)),ft=T("facetOptions/facet/disable",e=>O(e,he));d();c();l();u();var or=(e,t)=>typeof e=="object"&&Object.keys({...e}).length===0||!t||!e?!0:e.excluded?.includes(t)?!1:!!(e.included&&(e.included.length===0||e.included.includes(t))||e.excluded&&!e.included);d();c();l();u();d();c();l();u();var iu={facetId:he,captions:new Y({options:{required:!1}}),numberOfValues:new oe({required:!1,min:1}),query:new $({required:!1,emptyAllowed:!0})};var QL={path:new ne({required:!0,each:z}),displayValue:Ke,rawValue:Ke,count:new oe({required:!0,min:0})},vf=T("categoryFacet/selectSearchResult",e=>O(e,{facetId:he,value:new Y({values:QL})})),nE=T("categoryFacetSearch/register",e=>O(e,iu));d();c();l();u();function ss(e,t){let{facetId:r,criterion:n}=t,o=e[r]?.request;o&&(o.sortCriteria=n)}function cs(e){e&&(e.currentValues=e.currentValues.map(t=>({...t,previousState:t.state!=="idle"?t.state:void 0,state:"idle"})),e.preventAutoSelect=!0)}function Af(e,t){e&&(e.numberOfValues=t)}d();c();l();u();function au(e,t){let r=e[t];r&&(r.request.numberOfValues=r.initialNumberOfValues,r.request.currentValues=[],r.request.preventAutoSelect=!0)}function Cf(e,t,r){e.currentValues=BL(t,r),e.numberOfValues=t.length?1:r,e.preventAutoSelect=!0}function BL(e,t){if(!e.length)return[];let r=oE(e[0],t),n=r;for(let o of e.splice(1)){let i=oE(o,t);n.children.push(i),n=i}return n.state="selected",n.retrieveChildren=!0,[r]}function oE(e,t){return{value:e,retrieveCount:t,children:[],state:"idle",retrieveChildren:!1}}var bf=le(sa(),e=>{e.addCase(is,(t,r)=>{let n=r.payload,{facetId:o,tabs:i}=n;if(o in t)return;let a=$L(n),p=a.numberOfValues;t[o]={request:a,initialNumberOfValues:p,tabs:i}}).addCase(rt.fulfilled,(t,r)=>r.payload?.categoryFacetSet??t).addCase(it,(t,r)=>{let n=r.payload.cf||{},o=r.payload.tab;Object.keys(t).forEach(i=>{let a=t[i],p=a.request;if((a.tabs?.included?.length||a.tabs?.excluded?.length)&&!or(a.tabs,o)){p.currentValues.length&&Cf(p,[],a.initialNumberOfValues);return}let m=n[i]||[];(m.length||p.currentValues.length)&&Cf(p,m,a.initialNumberOfValues)})}).addCase(yf,(t,r)=>{let{facetId:n,criterion:o}=r.payload,i=t[n]?.request;i&&(i.sortCriteria=o)}).addCase(tE,(t,r)=>{let{facetId:n,basePath:o}=r.payload,i=t[n]?.request;i&&(i.basePath=[...o])}).addCase(as,(t,r)=>{let{facetId:n,selection:o,retrieveCount:i}=r.payload,a=t[n]?.request;if(!a)return;let{path:p}=o,f=p.slice(0,p.length-1),m=GL(a,f,i);if(m.length){let C=m[0];C.retrieveChildren=!0,C.state="selected",C.previousState="idle",C.children=[];return}let h=aE(o.value,i);h.state="selected",h.previousState="idle",m.push(h),a.numberOfValues=1}).addCase(So,(t,r)=>{let n=r.payload;au(t,n)}).addCase(Zt,t=>{Object.keys(t).forEach(r=>au(t,r))}).addCase(Aa,(t,r)=>Object.keys(t).forEach(n=>{t[n].request.preventAutoSelect=!r.payload.allow})).addCase(ou,(t,r)=>{let{facetId:n,numberOfValues:o}=r.payload,i=t[n]?.request;if(i){if(!i.currentValues.length)return Af(i,o);HL(t,r.payload)}}).addCase(vf,(t,r)=>{let{facetId:n,value:o}=r.payload,i=t[n];if(!i)return;let a=[...o.path,o.rawValue];Cf(i.request,a,i.initialNumberOfValues)}).addCase(Ra.fulfilled,(t,r)=>{iE(t,r.payload.response.facets)}).addCase(Te.fulfilled,(t,r)=>{iE(t,r.payload.response.facets)}).addCase(ft,(t,r)=>{au(t,r.payload)}).addCase(_t,(t,r)=>{let n=r.payload;Object.keys(t).forEach(o=>{let i=t[o];(i.tabs?.included?.length||i.tabs?.excluded?.length)&&!or(i.tabs,n)&&au(t,o)})})}),GS={delimitingCharacter:";",filterFacetCount:!0,injectionDepth:1e3,numberOfValues:5,sortCriteria:"occurrences",basePath:[],filterByBasePath:!0,resultsMustMatch:"atLeastOneValue"};function GL(e,t,r){let n=e.currentValues;for(let o of t){let i=n[0];(!i||o!==i.value)&&(i=aE(o,r),n.length=0,n.push(i)),i.retrieveChildren=!1,i.previousState=void 0,i.state="idle",n=i.children}return n}function $L(e){return{...GS,currentValues:[],preventAutoSelect:!1,type:"hierarchical",...e}}function aE(e,t){return{value:e,state:"idle",children:[],retrieveChildren:!0,retrieveCount:t}}function iE(e,t){t.forEach(r=>{if(!zL(e,r))return;let n=r.facetId,o=e[n]?.request;if(!o)return;let i=WL(o,r);o.currentValues=i?[]:o.currentValues,o.preventAutoSelect=!1})}function HL(e,t){let{facetId:r,numberOfValues:n}=t,o=e[r]?.request.currentValues[0];if(o){for(;o.children.length&&o?.state!=="selected";)o=o.children[0];o.retrieveCount=n}}function zL(e,t){return t.facetId in e}function WL(e,t){let r=Br(e.currentValues),n=Br(t.values);return r.length!==n.length}d();c();l();u();d();c();l();u();var an=new $({regex:/^[a-zA-Z0-9-_]+$/}),sn=new $({required:!0}),sE=new ne({each:new $}),cE=new $,uE=new de,cn=new de,un=new oe({min:0}),Dr=new oe({min:1}),xf=new de({required:!0}),YL=new Y,KL=new $,XL={captions:YL,numberOfValues:Dr,query:KL},us=new Y({values:XL}),wf=new Y({options:{required:!1},values:{type:new $({constrainTo:["simple"],emptyAllowed:!1,required:!0}),values:new ne({required:!0,max:25,each:new $({emptyAllowed:!1,required:!0})})}}),SEe=new de,Rf=new ne({min:1,max:25,required:!1,each:new $({emptyAllowed:!1,required:!0})});d();c();l();u();var Ti={value:z,numberOfResults:new oe({min:0}),state:z};var JL={facetId:he,field:new $({required:!0,emptyAllowed:!0}),tabs:new Y({options:{required:!1},values:{included:new ne({each:new $}),excluded:new ne({each:new $})}}),activeTab:new $({required:!1}),filterFacetCount:new de({required:!1}),injectionDepth:new oe({required:!1,min:0}),numberOfValues:new oe({required:!1,min:1}),sortCriteria:new Ge({required:!1}),resultsMustMatch:new Ge({required:!1}),allowedValues:wf,customSort:Rf},ls=T("facet/register",e=>O(e,JL)),vo=T("facet/toggleSelectValue",e=>O(e,{facetId:he,selection:new Y({values:Ti})})),Ao=T("facet/toggleExcludeValue",e=>O(e,{facetId:he,selection:new Y({values:Ti})})),St=T("facet/deselectAll",e=>O(e,he)),If=T("facet/updateSortCriterion",e=>O(e,{facetId:he,criterion:new Ge({required:!0})})),su=T("facet/updateNumberOfValues",e=>O(e,{facetId:he,numberOfValues:new oe({required:!0,min:1})})),cu=T("facet/updateIsFieldExpanded",e=>O(e,{facetId:he,isFieldExpanded:new de({required:!0})})),Pi=T("facet/updateFreezeCurrentValues",e=>O(e,{facetId:he,freezeCurrentValues:new de({required:!0})}));d();c();l();u();var ds=e=>He("analytics/facet/unexclude",(t,r)=>{O(e,{facetId:he,facetValue:z});let n=Xt(r),o=da(e,n);return t.makeFacetUnexclude(o)});var ir=()=>({actionCause:"facetClearAll"}),dr=()=>({actionCause:"facetSelect"}),Ef=()=>({actionCause:"facetExclude"}),Mn=()=>({actionCause:"facetDeselect"});var $S=()=>({actionCause:"breadcrumbFacet"});d();c();l();u();var ps=e=>te("showMoreFacetResults")("analytics/facet/showMore",(t,r)=>{O(e,he);let n={...Bo(e,Xt(r)),...Z(r.insightCaseContext)};return t.logFacetShowMore(n)}),fs=e=>te("showLessFacetResults")("analytics/facet/showLess",(t,r)=>{O(e,he);let n={...Bo(e,Xt(r)),...Z(r.insightCaseContext)};return t.logFacetShowLess(n)}),ln=e=>te("facetUpdateSort")("analytics/facet/sortChange",(t,r)=>{O(e,{facetId:he,sortCriterion:new Ge({required:!0})});let{facetId:n,sortCriterion:o}=e,i=Xt(r),p={...Bo(n,i),criteria:o,...Z(r.insightCaseContext)};return t.logFacetUpdateSort(p)}),Lt=e=>te("facetClearAll")("analytics/facet/reset",(t,r)=>{O(e,he);let n=Xt(r),o={...Bo(e,n),...Z(r.insightCaseContext)};return t.logFacetClearAll(o)}),Yt=e=>te("facetSelect")("analytics/facet/select",(t,r)=>{O(e,{facetId:he,facetValue:z});let n=Xt(r),o={...da(e,n),...Z(r.insightCaseContext)};return t.logFacetSelect(o)}),qr=e=>te("facetDeselect")("analytics/facet/deselect",(t,r)=>{O(e,{facetId:he,facetValue:z});let n=Xt(r),o={...da(e,n),...Z(r.insightCaseContext)};return t.logFacetDeselect(o)}),uu=e=>te("breadcrumbFacet")("analytics/facet/breadcrumb",(t,r)=>{O(e,{facetId:he,facetValue:z});let n={...da(e,Xt(r)),...Z(r.insightCaseContext)};return t.logBreadcrumbFacet(n)});d();c();l();u();d();c();l();u();var lE={facetId:he,value:new Y({values:{displayValue:Ke,rawValue:Ke,count:new oe({required:!0,min:0})}})},dE=T("facetSearch/register",e=>O(e,iu)),Ff=T("facetSearch/update",e=>O(e,iu)),Tf=T("facetSearch/toggleSelectValue",e=>O(e,lE)),Pf=T("facetSearch/toggleExcludeValue",e=>O(e,lE));var ms=le(la(),e=>{e.addCase(ls,(t,r)=>{let{facetId:n,tabs:o}=r.payload;n in t||(t[n]=lb(ZL(r.payload),o))}).addCase(rt.fulfilled,(t,r)=>{if(r.payload&&Object.keys(r.payload.facetSet).length!==0)return r.payload.facetSet}).addCase(it,(t,r)=>{let n=r.payload.f||{},o=r.payload.fExcluded||{};Object.keys(t).forEach(a=>{let{request:p}=t[a],f=n[a]||[],m=o[a]||[],h=f.length+m.length,C=p.currentValues.filter(b=>!f.includes(b.value)&&!m.includes(b.value));p.currentValues=[...f.map(fE),...m.map(mE),...C.map(tU)],p.preventAutoSelect=h>0,p.numberOfValues=Math.max(h,p.numberOfValues)})}).addCase(vo,(t,r)=>{let{facetId:n,selection:o}=r.payload,i=t[n]?.request;if(!i)return;i.preventAutoSelect=!0;let a=i.currentValues.find(f=>f.value===o.value);if(!a){kf(i,o);return}let p=a.state==="selected";a.previousState=a.state,a.state=p?"idle":"selected",i.freezeCurrentValues=!0}).addCase(Ao,(t,r)=>{let{facetId:n,selection:o}=r.payload,i=t[n]?.request;if(!i)return;i.preventAutoSelect=!0;let a=i.currentValues.find(f=>f.value===o.value);if(!a){kf(i,o);return}let p=a.state==="excluded";a.previousState=a.state,a.state=p?"idle":"excluded",i.freezeCurrentValues=!0}).addCase(Pi,(t,r)=>{let{facetId:n,freezeCurrentValues:o}=r.payload,i=t[n]?.request;i&&(i.freezeCurrentValues=o)}).addCase(St,(t,r)=>{cs(t[r.payload]?.request)}).addCase(Zt,t=>{Object.values(t).filter(r=>r.hasBreadcrumbs).forEach(({request:r})=>cs(r))}).addCase(ad,t=>{Object.values(t).filter(r=>!r.hasBreadcrumbs).forEach(({request:r})=>cs(r))}).addCase(Aa,(t,r)=>Object.values(t).forEach(n=>{n.request.preventAutoSelect=!r.payload.allow})).addCase(If,(t,r)=>{ss(t,r.payload)}).addCase(su,(t,r)=>{let{facetId:n,numberOfValues:o}=r.payload;Af(t[n]?.request,o)}).addCase(cu,(t,r)=>{let{facetId:n,isFieldExpanded:o}=r.payload,i=t[n]?.request;i&&(i.isFieldExpanded=o)}).addCase(Te.fulfilled,(t,r)=>{r.payload.response.facets.forEach(o=>pE(t[o.facetId]?.request,o))}).addCase(Ra.fulfilled,(t,r)=>{r.payload.response.facets.forEach(o=>pE(t[o.facetId]?.request,o))}).addCase(Tf,(t,r)=>{let{facetId:n,value:o}=r.payload,i=t[n]?.request;if(!i)return;let{rawValue:a}=o,{currentValues:p}=i,f=p.find(h=>h.value===a);if(f){f.state="selected";return}let m=fE(a);kf(i,m),i.freezeCurrentValues=!0,i.preventAutoSelect=!0}).addCase(Pf,(t,r)=>{let{facetId:n,value:o}=r.payload,i=t[n]?.request;if(!i)return;let{rawValue:a}=o,{currentValues:p}=i,f=p.find(h=>h.value===a);if(f){f.state="excluded";return}let m=mE(a);kf(i,m),i.freezeCurrentValues=!0,i.preventAutoSelect=!0}).addCase(ft,(t,r)=>{if(!(r.payload in t))return;let{request:n}=t[r.payload];cs(n)}).addCase(_t,(t,r)=>{let n=r.payload;Object.keys(t).forEach(o=>{let i=t[o];(i.tabs?.included?.length||i.tabs?.excluded?.length)&&!or(i.tabs,n)&&cs(i.request)})})});function kf(e,t){let{currentValues:r}=e,n=r.findIndex(i=>i.state==="idle"),o=n===-1?r.length:n;e.currentValues.splice(o,0,t),n>-1&&e.currentValues.pop(),e.numberOfValues=e.currentValues.length}function pE(e,t){e&&(e.currentValues=t.values.map(eU),e.freezeCurrentValues=!1,e.preventAutoSelect=!1)}var HS={filterFacetCount:!0,injectionDepth:1e3,numberOfValues:8,sortCriteria:"automatic",resultsMustMatch:"atLeastOneValue"};function ZL(e){return{...HS,type:"specific",currentValues:[],freezeCurrentValues:!1,isFieldExpanded:!1,preventAutoSelect:!1,...e}}function eU(e){let{value:t,state:r}=e;return{value:t,state:r}}function fE(e){return{value:e,state:"selected"}}function mE(e){return{value:e,state:"excluded"}}function tU(e){return{...e,state:"idle"}}d();c();l();u();var Of=()=>te("breadcrumbResetAll")("analytics/facet/deselectAllBreadcrumbs",(e,t)=>e.logBreadcrumbResetAll(Z(t.insightCaseContext)));d();c();l();u();d();c();l();u();function gs(e){let t=gE(e.start,e),r=gE(e.end,e),n=e.endInclusive??!1,o=e.state??"idle";return{start:t,end:r,endInclusive:n,state:o}}function gE(e,t){let{dateFormat:r}=t;return sA(e)?(ju(e),oA(e)):typeof e=="string"&&Un(e)?(ju(e),e):(eA(e,r),Vu(Hi(e,r)))}d();c();l();u();var hs=T("rangeFacet/updateSortCriterion",e=>O(e,{facetId:he,criterion:new Ge({required:!0})}));d();c();l();u();var ki={state:z,start:new oe({required:!0}),end:new oe({required:!0}),endInclusive:new de({required:!0}),numberOfResults:new oe({required:!0,min:0})},Oi={start:z,end:z,endInclusive:new de({required:!0}),state:z,numberOfResults:new oe({required:!0,min:0})},Vn=e=>({facetId:he,selection:typeof e.start=="string"?new Y({values:Oi}):new Y({values:ki})});var rU={start:z,end:z,endInclusive:new de({required:!0}),state:z},nU={facetId:he,field:z,tabs:new Y({options:{required:!1},values:{included:new ne({each:new $}),excluded:new ne({each:new $})}}),activeTab:new $({required:!1}),currentValues:new ne({required:!1,each:new Y({values:rU})}),generateAutomaticRanges:new de({required:!0}),filterFacetCount:new de({required:!1}),injectionDepth:new oe({required:!1,min:0}),numberOfValues:new oe({required:!1,min:1}),sortCriteria:new Ge({required:!1}),rangeAlgorithm:new Ge({required:!1})};function hE(e){return Un(e)?Xs(e):e}function _f(e){e.currentValues&&e.currentValues.forEach(t=>{let{start:r,end:n}=gs(t);if(Hi(hE(r)).isAfter(Hi(hE(n))))throw new Error(`The start value is greater than the end value for the date range ${t.start} to ${t.end}`)})}var dn=T("dateFacet/register",e=>{try{return fr(e,nU),_f(e),{payload:e,error:null}}catch(t){return{payload:e,error:Fr(t)}}}),pn=T("dateFacet/toggleSelectValue",e=>O(e,{facetId:he,selection:new Y({values:Oi})})),fn=T("dateFacet/toggleExcludeValue",e=>O(e,{facetId:he,selection:new Y({values:Oi})})),jn=T("dateFacet/updateFacetValues",e=>{try{return fr(e,{facetId:he,values:new ne({each:new Y({values:Oi})})}),_f({currentValues:e.values}),{payload:e,error:null}}catch(t){return{payload:e,error:Fr(t)}}}),Nf=hs,Df=St;d();c();l();u();d();c();l();u();var qf=(e,{facetId:t,selection:r})=>{let o=(e.dateFacetSet[t]||e.numericFacetSet[t]).request.field,i=`${o}_${t}`;return{facetId:t,facetField:o,facetTitle:i,facetRangeEndInclusive:r.endInclusive,facetRangeEnd:`${r.end}`,facetRangeStart:`${r.start}`}},Mf=()=>({actionCause:"breadcrumbFacet"});var zS=Mf;d();c();l();u();var lu=e=>te("breadcrumbFacet")("analytics/dateFacet/breadcrumb",(t,r)=>{O(e,Vn(e.selection));let n={...qf(r,e),...Z(r.insightCaseContext)};return t.logBreadcrumbFacet(n)});d();c();l();u();function oU(e,t){return!!t&&t.facetId in e.dateFacetSet}var yE=(e,t)=>{let r=En(e,t);if(oU(e,r))return r},SE=(e,t)=>(yE(e,t)||{values:[]}).values.filter(n=>n.state==="selected"),vE=(e,t)=>(yE(e,t)||{values:[]}).values.filter(n=>n.state!=="idle");d();c();l();u();d();c();l();u();var jf={filterFacetCount:!0,injectionDepth:1e3,numberOfValues:8,sortCriteria:"ascending",rangeAlgorithm:"even",resultsMustMatch:"atLeastOneValue"};function Lf(e,t){let{request:r}=t,{facetId:n}=r;if(n in e)return;let o=AE(r);r.numberOfValues=o,e[n]=t}function Uf(e,t,r){let n=e[t]?.request;n&&(n.currentValues=r,n.numberOfValues=AE(n))}function Qf(e,t,r){let n=e[t]?.request;if(!n)return;let o=Vf(n.currentValues,r);if(!o)return;let i=o.state==="selected";o.previousState=o.state,o.state=i?"idle":"selected",n.preventAutoSelect=!0}function Bf(e,t,r){let n=e[t]?.request;if(!n)return;let o=Vf(n.currentValues,r);if(!o)return;let i=o.state==="excluded";o.previousState=o.state,o.state=i?"idle":"excluded",n.preventAutoSelect=!0}function mn(e,t){let r=e[t]?.request;r&&r.currentValues.forEach(n=>{n.state!=="idle"&&(n.previousState=n.state),n.state="idle"})}function Gf(e,t){Object.entries(e).forEach(([r,{request:n}])=>{let o=t[r]||[];n.currentValues.forEach(p=>(Vf(o,p)&&(p.state="selected"),p));let i=o.filter(p=>!Vf(n.currentValues,p)),a=n.currentValues;a.push(...i),n.numberOfValues=Math.max(n.numberOfValues,a.length)})}function $f(e,t,r){t.forEach(n=>{let o=n.facetId,i=e[o]?.request;if(!i)return;let a=r(n.values);i.currentValues=a,i.preventAutoSelect=!1})}function Vf(e,t){let{start:r,end:n}=t;return e.find(o=>o.start===r&&o.end===n)}function AE(e){let{generateAutomaticRanges:t,currentValues:r,numberOfValues:n}=e;return t?Math.max(n,r.length):r.length}var gn=le(ca(),e=>{e.addCase(dn,(t,r)=>{let{payload:n}=r,{tabs:o}=n,i=iU(n);Lf(t,cb(i,o))}).addCase(rt.fulfilled,(t,r)=>r.payload?.dateFacetSet??t).addCase(it,(t,r)=>{let n=r.payload.df||{};Gf(t,n)}).addCase(pn,(t,r)=>{let{facetId:n,selection:o}=r.payload;Qf(t,n,o)}).addCase(fn,(t,r)=>{let{facetId:n,selection:o}=r.payload;Bf(t,n,o)}).addCase(jn,(t,r)=>{let{facetId:n,values:o}=r.payload;Uf(t,n,o)}).addCase(Df,(t,r)=>{mn(t,r.payload)}).addCase(Zt,t=>{Object.keys(t).forEach(r=>{mn(t,r)})}).addCase(Nf,(t,r)=>{ss(t,r.payload)}).addCase(Te.fulfilled,(t,r)=>{let n=r.payload.response.facets;$f(t,n,aU)}).addCase(ft,(t,r)=>{mn(t,r.payload)}).addCase(_t,(t,r)=>{let n=r.payload;Object.keys(t).forEach(o=>{let i=t[o];(i.tabs?.included?.length||i.tabs?.excluded?.length)&&!or(i.tabs,n)&&mn(t,o)})})});function iU(e){return{...jf,currentValues:[],preventAutoSelect:!1,type:"dateRange",...e}}function aU(e){return e.map(t=>{let{numberOfResults:r,...n}=t;return n})}d();c();l();u();var sU={state:z,start:new oe({required:!0}),end:new oe({required:!0}),endInclusive:new de({required:!0})},cU={facetId:he,field:z,tabs:new Y({options:{required:!1},values:{included:new ne({each:new $}),excluded:new ne({each:new $})}}),activeTab:new $({required:!1}),currentValues:new ne({required:!1,each:new Y({values:sU})}),generateAutomaticRanges:new de({required:!0}),filterFacetCount:new de({required:!1}),injectionDepth:new oe({required:!1,min:0}),numberOfValues:new oe({required:!1,min:1}),sortCriteria:new Ge({required:!1}),rangeAlgorithm:new Ge({required:!1})};function Hf(e){e.currentValues&&e.currentValues.forEach(({start:t,end:r})=>{if(t>r)throw new Error(`The start value is greater than the end value for the numeric range ${t} to ${r}`)})}var hn=T("numericFacet/register",e=>{try{return O(e,cU),Hf(e),{payload:e,error:null}}catch(t){return{payload:e,error:Fr(t)}}}),yn=T("numericFacet/toggleSelectValue",e=>O(e,{facetId:he,selection:new Y({values:ki})})),Sn=T("numericFacet/toggleExcludeValue",e=>O(e,{facetId:he,selection:new Y({values:ki})})),Ln=T("numericFacet/updateFacetValues",e=>{try{return fr(e,{facetId:he,values:new ne({each:new Y({values:ki})})}),Hf({currentValues:e.values}),{payload:e,error:null}}catch(t){return{payload:e,error:Fr(t)}}}),zf=hs,Wf=St;d();c();l();u();var WS=Mf;d();c();l();u();d();c();l();u();var CE=(e,{facetId:t,selection:r})=>{let o=(e.dateFacetSet[t]||e.numericFacetSet[t]).request.field,i=`${o}_${t}`;return{facetId:t,facetField:o,facetTitle:i,facetRangeEndInclusive:r.endInclusive,facetRangeEnd:`${r.end}`,facetRangeStart:`${r.start}`}};var du=e=>te("breadcrumbFacet")("analytics/numericFacet/breadcrumb",(t,r)=>{O(e,Vn(e.selection));let n={...CE(r,e),...Z(r.insightCaseContext)};return t.logBreadcrumbFacet(n)});d();c();l();u();function uU(e,t){return!!t&&t.facetId in e.numericFacetSet}var bE=(e,t)=>{let r=En(e,t);if(uU(e,r))return r},xE=(e,t)=>(bE(e,t)||{values:[]}).values.filter(n=>n.state!=="idle"),wE=(e,t)=>(bE(e,t)||{values:[]}).values.filter(n=>n.state==="selected");d();c();l();u();var Co=le(ua(),e=>{e.addCase(hn,(t,r)=>{let{payload:n}=r,{tabs:o}=n,i=lU(n);Lf(t,ub(i,o))}).addCase(rt.fulfilled,(t,r)=>r.payload?.numericFacetSet??t).addCase(it,(t,r)=>{let n=r.payload.nf||{};Gf(t,n)}).addCase(yn,(t,r)=>{let{facetId:n,selection:o}=r.payload;Qf(t,n,o)}).addCase(Sn,(t,r)=>{let{facetId:n,selection:o}=r.payload;Bf(t,n,o)}).addCase(Ln,(t,r)=>{let{facetId:n,values:o}=r.payload;Uf(t,n,o)}).addCase(Wf,(t,r)=>{mn(t,r.payload)}).addCase(Zt,t=>{Object.keys(t).forEach(r=>{mn(t,r)})}).addCase(zf,(t,r)=>{ss(t,r.payload)}).addCase(Te.fulfilled,(t,r)=>{let n=r.payload.response.facets;$f(t,n,dU)}).addCase(ft,(t,r)=>{mn(t,r.payload)}).addCase(_t,(t,r)=>{let n=r.payload;Object.keys(t).forEach(o=>{let i=t[o];(i.tabs?.included?.length||i.tabs?.excluded?.length)&&!or(i.tabs,n)&&mn(t,o)})})});function lU(e){return{...jf,currentValues:[],preventAutoSelect:!1,type:"numericalRange",...e}}function dU(e){return e.map(t=>{let{numberOfResults:r,...n}=t;return n})}d();c();l();u();d();c();l();u();var pu=z,Yf=new Y({options:{required:!0},values:{caption:Ke,expression:Ke,state:new $({constrainTo:["idle","selected","excluded"]})}}),RE=new ne({required:!0,each:Yf});var Yke=T("staticFilter/register",e=>O(e,{id:pu,values:RE})),IE=T("staticFilter/toggleSelect",e=>O(e,{id:pu,value:Yf})),EE=T("staticFilter/toggleExclude",e=>O(e,{id:pu,value:Yf})),Kke=T("staticFilter/deselectAllFilterValues",e=>O(e,pu));d();c();l();u();var Kf=e=>te("staticFilterDeselect")("analytics/staticFilter/deselect",(t,r)=>t.logStaticFilterDeselect({...e,...Z(r.insightCaseContext)}));d();c();l();u();var Xf=e=>Object.keys(e.facetSet).map(t=>{let r=e.facetValuesSelector(e.engine.state,t).map(n=>({value:n,deselect:()=>{n.state==="selected"?e.executeToggleSelect({facetId:t,selection:n}):n.state==="excluded"&&e.executeToggleExclude({facetId:t,selection:n})}}));return{facetId:t,field:e.facetSet[t].request.field,values:r}}).filter(t=>t.values.length);function FE(e){let t=me(e),{dispatch:r}=e;return{...t,get state(){return{facetBreadcrumbs:[],categoryFacetBreadcrumbs:[],numericFacetBreadcrumbs:[],dateFacetBreadcrumbs:[],staticFilterBreadcrumbs:[],hasBreadcrumbs:!1}},deselectAll:()=>{r(Zt())},deselectBreadcrumb(n){n.deselect()}}}function TE(e){if(!pU(e))throw ie;let t=FE(e),{dispatch:r}=e,n=()=>e.state,o=()=>{let g={engine:e,facetSet:n().facetSet,executeToggleSelect:({facetId:S,selection:x})=>{let w=uu({facetId:S,facetValue:x.value});r(vo({facetId:S,selection:x})),r(Pi({facetId:S,freezeCurrentValues:!1})),r(Ae({legacy:w,next:$S()}))},executeToggleExclude:({facetId:S,selection:x})=>{let w=uu({facetId:S,facetValue:x.value});r(Ao({facetId:S,selection:x})),r(Pi({facetId:S,freezeCurrentValues:!1})),r(Ae({legacy:w,next:$S()}))},facetValuesSelector:ib};return Xf(g)},i=()=>{let g={engine:e,facetSet:n().numericFacetSet,executeToggleSelect:S=>{r(yn(S)),r(Ae({legacy:du(S),next:WS()}))},executeToggleExclude:S=>{r(Sn(S)),r(Ae({legacy:du(S),next:WS()}))},facetValuesSelector:xE};return Xf(g)},a=()=>{let g={engine:e,facetSet:n().dateFacetSet,executeToggleSelect:S=>{r(pn(S)),r(Ae({legacy:lu(S),next:zS()}))},executeToggleExclude:S=>{r(fn(S)),r(Ae({legacy:lu(S),next:zS()}))},facetValuesSelector:vE};return Xf(g)},p=g=>{let S=sb(n(),g);return{facetId:g,field:n().categoryFacetSet[g].request.field,path:S,deselect:()=>{r(So(g)),r(Ae({legacy:Sf({categoryFacetPath:S.map(x=>x.value),categoryFacetId:g}),next:rE()}))}}},f=()=>Object.keys(n().categoryFacetSet).map(p).filter(g=>g.path.length),m=()=>{let g=n().staticFilterSet||{};return Object.values(g).map(h)},h=g=>{let{id:S,values:x}=g,w=x.filter(R=>R.state!=="idle").map(R=>C(S,R));return{id:S,values:w}},C=(g,S)=>({value:S,deselect:()=>{let{caption:x,expression:w}=S,R=Kf({staticFilterId:g,staticFilterValue:{caption:x,expression:w}});S.state==="selected"?r(IE({id:g,value:S})):S.state==="excluded"&&r(EE({id:g,value:S})),r(Ae({legacy:R}))}});function b(){return!![...o(),...i(),...a(),...f(),...m()].length}return{...t,get state(){return{facetBreadcrumbs:o(),categoryFacetBreadcrumbs:f(),numericFacetBreadcrumbs:i(),dateFacetBreadcrumbs:a(),staticFilterBreadcrumbs:m(),hasBreadcrumbs:b()}},deselectAll:()=>{t.deselectAll(),r(Ae({legacy:Of(),next:{actionCause:"breadcrumbResetAll"}}))}}}function pU(e){return e.addReducers({configuration:Ce,search:we,facetSet:ms,numericFacetSet:Co,dateFacetSet:gn,categoryFacetSet:bf}),!0}d();c();l();u();d();c();l();u();d();c();l();u();var PE=e=>e.queryCorrection.correctedQuery!==""||e.wasCorrectedTo!=="";d();c();l();u();d();c();l();u();d();c();l();u();var Jf=()=>({correctedQuery:"",wordCorrections:[],originalQuery:""}),kE=()=>({correctedQuery:"",corrections:[],originalQuery:""});function OE(){return{enableDidYouMean:!1,wasCorrectedTo:"",wasAutomaticallyCorrected:!1,queryCorrection:Jf(),originalQuery:"",automaticallyCorrectQuery:!0,queryCorrectionMode:"legacy"}}var _E=(e,t)=>{let r={...kE(),...t,correctedQuery:t?.correctedQuery||t?.corrections[0]?.correctedQuery||""};e.queryCorrection=r,e.wasCorrectedTo=r.correctedQuery};var NE=le(OE(),e=>{e.addCase(zl,t=>{t.enableDidYouMean=!0}).addCase(Yb,t=>{t.enableDidYouMean=!1}).addCase(Kb,t=>{t.automaticallyCorrectQuery=!0}).addCase(Wl,t=>{t.automaticallyCorrectQuery=!1}).addCase(Te.pending,t=>{t.queryCorrection=Jf(),t.wasAutomaticallyCorrected=!1,t.wasCorrectedTo=""}).addCase(Te.fulfilled,(t,r)=>{let{queryCorrection:n,queryCorrections:o}=r.payload.response;if(t.queryCorrectionMode==="legacy"){let i=o?.[0]?o[0]:Jf();t.queryCorrection=i}t.queryCorrectionMode==="next"&&_E(t,n),t.wasAutomaticallyCorrected=r.payload.automaticallyCorrected,t.originalQuery=r.payload.originalQuery}).addCase(Jt,(t,r)=>{t.wasCorrectedTo=r.payload}).addCase(Pc,(t,r)=>{t.queryCorrectionMode=r.payload})});function DE(e,t={}){if(!fU(e))throw ie;let r=me(e),{dispatch:n}=e;n(zl()),t.options?.automaticallyCorrectQuery===!1&&n(Wl()),n(Pc(t.options?.queryCorrectionMode||"next"));let o=()=>e.state,i=()=>PE(o().didYouMean);return{...r,get state(){let a=o();return{originalQuery:a.didYouMean.originalQuery,wasCorrectedTo:a.didYouMean.wasCorrectedTo,wasAutomaticallyCorrected:a.didYouMean.wasAutomaticallyCorrected,queryCorrection:a.didYouMean.queryCorrection,hasQueryCorrection:i()}},applyCorrection(){n(Jt(this.state.queryCorrection.correctedQuery))},updateQueryCorrectionMode(a){n(Pc(a))}}}function fU(e){return e.addReducers({configuration:Ce,didYouMean:NE}),!0}var qE={automaticallyCorrectQuery:!0,queryCorrectionMode:"legacy"};function ME(e,t={options:qE}){let r={...qE,...t.options},n=DE(e,{options:r}),{dispatch:o}=e;return{...n,get state(){return n.state},applyCorrection(){n.applyCorrection(),o(Ae({legacy:ox(),next:px()}))}}}d();c();l();u();d();c();l();u();d();c();l();u();var Ut=le(Xl(),e=>{e.addCase(Qe,(t,r)=>({...t,...r.payload})).addCase(Te.fulfilled,t=>{t.freezeFacetOrder=!1}).addCase(Te.rejected,t=>{t.freezeFacetOrder=!1}).addCase(rt.fulfilled,(t,r)=>r.payload?.facetOptions??t).addCase(is,(t,r)=>{let{facetId:n,tabs:o}=r.payload;Zf(o,t,n)}).addCase(ls,(t,r)=>{let{facetId:n,tabs:o}=r.payload;Zf(o,t,n)}).addCase(dn,(t,r)=>{let{facetId:n,tabs:o}=r.payload;Zf(o,t,n)}).addCase(hn,(t,r)=>{let{facetId:n,tabs:o}=r.payload;Zf(o,t,n)}).addCase(nr,(t,r)=>{t.facets[r.payload].enabled=!0}).addCase(ft,(t,r)=>{t.facets[r.payload].enabled=!1}).addCase(it,(t,r)=>{[...Object.keys(r.payload.f??{}),...Object.keys(r.payload.fExcluded??{}),...Object.keys(r.payload.cf??{}),...Object.keys(r.payload.nf??{}),...Object.keys(r.payload.df??{})].forEach(n=>{n in t||(t.facets[n]=sy()),t.facets[n].enabled=!0})})});function Zf(e,t,r){let n={...sy(),tabs:e??{}};t.facets[r]=n}d();c();l();u();d();c();l();u();var em=le(Zl(),e=>{e.addCase(Kd,(t,r)=>{let n=r.payload,{id:o}=n;o in t||(t[o]={...n,isActive:!1})}).addCase(_t,(t,r)=>{let n=r.payload;VE(t,n)}).addCase(Yd,(t,r)=>{let n=r.payload;VE(t,n)}).addCase(rt.fulfilled,(t,r)=>r.payload?.tabSet??t).addCase(it,(t,r)=>{let n=r.payload.tab;ee(n)||Object.keys(t).forEach(o=>{t[o].isActive=o===n})})});function VE(e,t){t in e&&Object.keys(e).forEach(n=>{e[n].isActive=n===t})}function jE(e){if(!mU(e))throw ie;let t=me(e),r=ct(n=>n.tabSet,n=>Object.values(n).find(i=>i.isActive)?.id??"");return{...t,get state(){return{activeTab:r(e.state)}}}}function mU(e){return e.addReducers({tabSet:em}),!0}function LE(e,t){if(!gU(e))throw ie;let r=jE(e),n=S=>e.state.facetOptions.facets[S]?.enabled??!1,o=S=>e.state.facetSet?.[S]?.request?.currentValues??e.state.categoryFacetSet?.[S]?.request?.currentValues??e.state.numericFacetSet?.[S]?.request?.currentValues??e.state.dateFacetSet?.[S]?.request?.currentValues??null,i=S=>S in e.state.facetOptions.facets,a=S=>e.state.facetOptions.facets[S]?.tabs,p=()=>Bi({isFacetRegistered:i(t.facetId),parentFacets:t.conditions.map(({parentFacetId:S})=>i(S)?{enabled:n(S),values:o(S)}:null),isTabEnabled:or(a(t.facetId),r.state.activeTab)}),f=()=>{let S=p();return S===b?!1:(b=S,!0)},m=()=>t.conditions.length>0?t.conditions.some(S=>{if(!n(S.parentFacetId))return!1;let x=o(S.parentFacetId);return x===null?!1:S.condition(x)}):!0,h=()=>{e.state.facetSet&&Object.entries(e.state.facetSet).forEach(([S,x])=>x.request.freezeCurrentValues&&e.dispatch(Pi({facetId:S,freezeCurrentValues:!1})))},C=()=>{if(!i(t.facetId))return;let S=n(t.facetId),x=m(),w=or(a(t.facetId),r.state.activeTab),R=x&&w;S!==R&&(e.dispatch(R?nr(t.facetId):ft(t.facetId)),h())},b=p(),g=e.subscribe(()=>{f()&&C()});return C(),{stopWatching(){g()}}}function gU(e){return e.addReducers({facetOptions:Ut}),!0}function UE(e,t){return LE(e,t)}d();c();l();u();d();c();l();u();function QE(e){if(!hU(e))throw ie;let t=me(e),r=()=>e.state;return{...t,sort(n){return Oc(n,this.state.facetIds)},get state(){return{facetIds:r().search.response.facets.map(i=>i.facetId)}}}}function hU(e){return e.addReducers({search:we,facetOptions:Ut}),!0}function BE(e){return QE(e)}d();c();l();u();d();c();l();u();d();c();l();u();d();c();l();u();function tm(e,t,r){let{facetId:n}=t;if(e[n])return;let o=!1,i={...ys,...t},a=r();e[n]={options:i,isLoading:o,response:a,initialNumberOfValues:i.numberOfValues,requestId:""}}function rm(e,t){let{facetId:r,...n}=t,o=e[r];o&&(o.options={...o.options,...n})}function nm(e,t,r){let n=e[t];n&&(n.requestId=r,n.isLoading=!0)}function om(e,t){let r=e[t];r&&(r.isLoading=!1)}function im(e,t,r){let{facetId:n,response:o}=t,i=e[n];i&&i.requestId===r&&(i.isLoading=!1,i.response=o)}function fu(e,t,r){let{facetId:n}=t,o=e[n];o&&(o.requestId="",o.isLoading=!1,o.response=r(),o.options.numberOfValues=o.initialNumberOfValues,o.options.query=ys.query)}function am(e,t){Object.keys(e).forEach(r=>fu(e,{facetId:r},t))}var ys={captions:{},numberOfValues:10,query:""};d();c();l();u();d();c();l();u();var GE=/*#__PURE__*/function(){var _ref90=_asyncToGenerator(function*(e,t,r,n){let o=t.categoryFacetSearchSet[e].options,i=t.categoryFacetSet[e].request,{captions:a,query:p,numberOfValues:f}=o,{field:m,delimitingCharacter:h,basePath:C,filterFacetCount:b}=i,g=yU(i),S=g.length?[g]:[],x=`*${p}*`;return{url:t.configuration.search.apiBaseUrl??Kt(t.configuration.organizationId,t.configuration.environment),accessToken:t.configuration.accessToken,organizationId:t.configuration.organizationId,...(t.configuration.search.authenticationProviders.length&&{authentication:t.configuration.search.authenticationProviders.join(",")}),basePath:C,captions:a,numberOfValues:f,query:x,field:m,delimitingCharacter:h,ignorePaths:S,filterFacetCount:b,type:"hierarchical",...(n?{}:{searchContext:(yield Sr(t,r)).request})}});return function GE(_x214,_x215,_x216,_x217){return _ref90.apply(this,arguments)}}(),yU=e=>{let t=[],r=e.currentValues[0];for(;r;)t.push(r.value),r=r.children[0];return t};d();c();l();u();var $E=/*#__PURE__*/function(){var _ref91=_asyncToGenerator(function*(e,t,r,n){let{captions:o,query:i,numberOfValues:a}=t.facetSearchSet[e].options,{field:p,currentValues:f,filterFacetCount:m}=t.facetSet[e].request,h=f.filter(b=>b.state!=="idle").map(b=>b.value),C=`*${i}*`;return{url:t.configuration.search.apiBaseUrl??Kt(t.configuration.organizationId,t.configuration.environment),accessToken:t.configuration.accessToken,organizationId:t.configuration.organizationId,...(t.configuration.search.authenticationProviders&&{authentication:t.configuration.search.authenticationProviders.join(",")}),captions:o,numberOfValues:a,query:C,field:p,ignoreValues:h,filterFacetCount:m,type:"specific",...(n?{}:{searchContext:(yield Sr(t,r)).request})}});return function $E(_x218,_x219,_x220,_x221){return _ref91.apply(this,arguments)}}();var HE=e=>(/*#__PURE__*/function(){var _ref92=_asyncToGenerator(function*(t,{getState:r,extra:{apiClient:n,validatePayload:o,navigatorContext:i}}){let a=r(),p;o(t,z),SU(a,t)?p=yield $E(t,a,i,e):p=yield GE(t,a,i,e);let f=yield n.facetSearch(p);return{facetId:t,response:f}});return function(_x222,_x223){return _ref92.apply(this,arguments)}}()),bo=pe("facetSearch/executeSearch",HE(!1)),F0e=pe("facetSearch/executeSearch",HE(!0)),sm=T("facetSearch/clearResults",e=>O(e,{facetId:he})),SU=(e,t)=>e.facetSearchSet!==void 0&&e.facetSet!==void 0&&e.facetSet[t]!==void 0;d();c();l();u();function zE(){return{}}var WE=le(zE(),e=>{e.addCase(nE,(t,r)=>{let n=r.payload;tm(t,n,YS)}).addCase(Ff,(t,r)=>{rm(t,r.payload)}).addCase(bo.pending,(t,r)=>{let n=r.meta.arg;nm(t,n,r.meta.requestId)}).addCase(bo.rejected,(t,r)=>{let n=r.meta.arg;om(t,n)}).addCase(bo.fulfilled,(t,r)=>{im(t,r.payload,r.meta.requestId)}).addCase(sm,(t,{payload:{facetId:r}})=>{fu(t,{facetId:r},YS)}).addCase(Te.fulfilled,t=>{am(t,YS)})});function YS(){return{moreValuesAvailable:!1,values:[]}}d();c();l();u();d();c();l();u();function YE(e,t){let{field:r,state:n}=e;if(!vU(e))return r;let o=`${r}_`,i=AU(o,n);return bU(r,t),`${o}${i}`}function vU(e){let{field:t,state:r}=e;return KE(r).some(o=>o&&t in o)}function AU(e,t){let n=KE(t).map(o=>Object.keys(o||{})).reduce((o,i)=>o.concat(i),[]);return CU(n,e)+1}function KE(e){let{facetSet:t,numericFacetSet:r,dateFacetSet:n,categoryFacetSet:o}=e;return[t,r,n,o]}function CU(e,t){return e.map(i=>{let a=i.split(t)[1],p=parseInt(a,10);return Number.isNaN(p)?0:p}).sort().pop()??0}function bU(e,t){let r=`A facet with field "${e}" already exists.
@@ -75,4 +75,4 @@ fast-json-patch/module/duplex.mjs:
75
75
  *)
76
76
  */if(__exports!=exports)module.exports=exports;return module.exports});
77
77
 
78
- window.coveoQuanticVersion = '3.37.0';
78
+ window.coveoQuanticVersion = '3.37.1';