@cimulate/copilot-widget 1.22.0 → 1.22.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.
@@ -347,7 +347,7 @@ declare interface MessagingModeConfig {
347
347
  /**
348
348
  * Shows a "Connect to a human agent" button in the messaging search bar that
349
349
  * asks the Agentforce agent to escalate the conversation to a human. Defaults
350
- * to true; set to false to hide it. Requires the org's Agentforce agent to be
350
+ * to false; set to true to show it. Requires the org's Agentforce agent to be
351
351
  * configured with an escalation path/topic, otherwise the button is a no-op.
352
352
  */
353
353
  enableEscalationToAgent?: boolean;
@@ -6217,7 +6217,7 @@ const vk = {
6217
6217
  __features: se,
6218
6218
  routingAttributes: ce,
6219
6219
  enableDownloadTranscript: fe = !0,
6220
- enableEscalationToAgent: ne = !0,
6220
+ enableEscalationToAgent: ne = !1,
6221
6221
  children: be
6222
6222
  }) => {
6223
6223
  const ke = e === "messaging", oe = B.useMemo(() => {
@@ -7,7 +7,7 @@
7
7
  `);return u===-1?"":o.stack.slice(u+1)})();try{if(!r.stack)r.stack=a;else if(a){const u=a.indexOf(`
8
8
  `),c=u===-1?-1:a.indexOf(`
9
9
  `,u+1),d=c===-1?"":a.slice(c+1);String(r.stack).endsWith(d)||(r.stack+=`
10
- `+a)}}catch(u){}}throw r}})}_request(t,n){typeof t=="string"?(n=n||{},n.url=t):n=t||{},n=so(this.defaults,n);const{transitional:r,paramsSerializer:o,headers:a}=n;r!==void 0&&gl.assertOptions(r,{silentJSONParsing:En.transitional(En.boolean),forcedJSONParsing:En.transitional(En.boolean),clarifyTimeoutError:En.transitional(En.boolean),legacyInterceptorReqResOrdering:En.transitional(En.boolean),advertiseZstdAcceptEncoding:En.transitional(En.boolean),validateStatusUndefinedResolves:En.transitional(En.boolean)},!1),o!=null&&($.isFunction(o)?n.paramsSerializer={serialize:o}:gl.assertOptions(o,{encode:En.function,serialize:En.function},!0)),n.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?n.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:n.allowAbsoluteUrls=!0),gl.assertOptions(n,{baseUrl:En.spelling("baseURL"),withXsrfToken:En.spelling("withXSRFToken")},!0),n.method=(n.method||this.defaults.method||"get").toLowerCase();let u=a&&$.merge(a.common,a[n.method]);a&&$.forEach(["delete","get","head","post","put","patch","query","common"],_=>{delete a[_]}),n.headers=gn.concat(u,a);const c=[];let d=!0;this.interceptors.request.forEach(function(w){if(typeof w.runWhen=="function"&&w.runWhen(n)===!1)return;d=d&&w.synchronous;const C=n.transitional||yf;C&&C.legacyInterceptorReqResOrdering?c.unshift(w.fulfilled,w.rejected):c.push(w.fulfilled,w.rejected)});const f=[];this.interceptors.response.forEach(function(w){f.push(w.fulfilled,w.rejected)});let p,m=0,T;if(!d){const _=[$g.bind(this),void 0];for(_.unshift(...c),_.push(...f),T=_.length,p=Promise.resolve(n);m<T;)p=p.then(_[m++],_[m++]);return p}T=c.length;let y=n;for(;m<T;){const _=c[m++],w=c[m++];try{y=_(y)}catch(C){w.call(this,C);break}}try{p=$g.call(this,y)}catch(_){return Promise.reject(_)}for(m=0,T=f.length;m<T;)p=p.then(f[m++],f[m++]);return p}getUri(t){t=so(this.defaults,t);const n=Rg(t.baseURL,t.url,t.allowAbsoluteUrls,t);return xg(n,t.params,t.paramsSerializer)}};$.forEach(["delete","get","head","options"],function(t){ao.prototype[t]=function(n,r){return this.request(so(r||{},{method:t,url:n,data:r&&$.hasOwnProp(r,"data")?r.data:void 0}))}}),$.forEach(["post","put","patch","query"],function(t){function n(r){return function(a,u,c){return this.request(so(c||{},{method:t,headers:r?{"Content-Type":"multipart/form-data"}:{},url:a,data:u}))}}ao.prototype[t]=n(),t!=="query"&&(ao.prototype[t+"Form"]=n(!0))});let yC=class Zw{constructor(t){if(typeof t!="function")throw new TypeError("executor must be a function.");let n;this.promise=new Promise(function(a){n=a});const r=this;this.promise.then(o=>{if(!r._listeners)return;let a=r._listeners.length;for(;a-- >0;)r._listeners[a](o);r._listeners=null}),this.promise.then=o=>{let a;const u=new Promise(c=>{r.subscribe(c),a=c}).then(o);return u.cancel=function(){r.unsubscribe(a)},u},t(function(a,u,c){r.reason||(r.reason=new ya(a,u,c),n(r.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(t){if(this.reason){t(this.reason);return}this._listeners?this._listeners.push(t):this._listeners=[t]}unsubscribe(t){if(!this._listeners)return;const n=this._listeners.indexOf(t);n!==-1&&this._listeners.splice(n,1)}toAbortSignal(){const t=new AbortController,n=r=>{t.abort(r)};return this.subscribe(n),t.signal.unsubscribe=()=>this.unsubscribe(n),t.signal}static source(){let t;return{token:new Zw(function(o){t=o}),cancel:t}}};function bC(e){return function(n){return e.apply(null,n)}}function TC(e){return $.isObject(e)&&e.isAxiosError===!0}const Af={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511,WebServerIsDown:521,ConnectionTimedOut:522,OriginIsUnreachable:523,TimeoutOccurred:524,SslHandshakeFailed:525,InvalidSslCertificate:526};Object.entries(Af).forEach(([e,t])=>{Af[t]=e});function qg(e){const t=new ao(e),n=sg(ao.prototype.request,t);return $.extend(n,ao.prototype,t,{allOwnKeys:!0}),$.extend(n,t,null,{allOwnKeys:!0}),n.create=function(o){return qg(so(e,o))},n}const Lt=qg(Ea);Lt.Axios=ao,Lt.CanceledError=ya,Lt.CancelToken=yC,Lt.isCancel=kg,Lt.VERSION=Sf,Lt.toFormData=dl,Lt.AxiosError=xe,Lt.Cancel=Lt.CanceledError,Lt.all=function(t){return Promise.all(t)},Lt.spread=bC,Lt.isAxiosError=TC,Lt.mergeConfig=so,Lt.AxiosHeaders=gn,Lt.formToJSON=e=>Cg($.isHTMLForm(e)?new FormData(e):e),Lt.getAdapter=jg.getAdapter,Lt.HttpStatusCode=Af,Lt.default=Lt;const{Axios:cU,AxiosError:dU,CanceledError:fU,isCancel:hU,CancelToken:pU,VERSION:mU,all:gU,Cancel:EU,isAxiosError:yU,spread:bU,toFormData:TU,AxiosHeaders:_U,HttpStatusCode:SU,formToJSON:xU,getAdapter:wU,mergeConfig:AU,create:vU}=Lt;class _C{constructor(t,n,r,o=!1,a,u){we(this,"CIMULATE_API_HEADER","x-cimulate-api-key");we(this,"CIMULATE_SEARCH_API_HOST","search.cimulate");we(this,"CIMULATE_SEARCH_API_PATH","api/v1");we(this,"baseApiUrl");we(this,"headers",{});we(this,"fetchConfig",()=>Je(this,null,function*(){try{const t=yield Lt.get(`${this.apiUrl}/configs/copilot`,{headers:this.headers}),{customer_config:n}=t.data,r=atob(n);return JSON.parse(r)}catch(t){throw console.error("Error fetching customer config:",t),t}}));we(this,"_mapCopilotUrlToSearchUrl",(t="",n=!1)=>{if(t.endsWith("io")){const o=new URL(t);return o.hostname=o.hostname.replace(/^copilot\./,"api."),o.origin}return n?`https://staging.${this.CIMULATE_SEARCH_API_HOST}.ai`:`https://prod.${this.CIMULATE_SEARCH_API_HOST}.ai`});if(n&&r||!n&&!r)throw new Error("Provide exactly one authentication method: either 'apiKey' or 'apiToken', but not both.");n?this.headers[this.CIMULATE_API_HEADER]=n:r&&(this.headers.Authorization=`Bearer ${r}`),a&&(this.headers["x-cimulate-customer-id"]=a),u&&(this.headers["Tenant-ID"]=u),this.baseApiUrl=this._mapCopilotUrlToSearchUrl(t,o)}get apiUrl(){return`${this.baseApiUrl}/${this.CIMULATE_SEARCH_API_PATH}`}}class SC{constructor(t,n,r,o=!1,a,u){we(this,"apiService");we(this,"config",null);we(this,"getConfig",()=>Je(this,null,function*(){if(this.config)return this.config;try{const t=yield this.apiService.fetchConfig();return this.config=t,this.config}catch(t){throw console.error("Failed to fetch customer config:",t),t}}));we(this,"getPid",t=>this.getProductFieldValue(t,"pidCol"));we(this,"getName",t=>this.getProductFieldValue(t,"nameCol"));we(this,"getDescription",t=>this.getProductFieldValue(t,"description"));we(this,"getBrand",t=>this.getProductFieldValue(t,"productBrandCol"));we(this,"getPrice",t=>this.getProductFieldValue(t,"priceCol"));we(this,"getRelativePdp",t=>this.getProductFieldValue(t,"relativePdpCol"));we(this,"getPdp",t=>this.getProductFieldValue(t,"pdpCol"));we(this,"getImage",t=>this.getProductFieldValue(t,"imageCol"));we(this,"getProductHiddenFields",()=>{const t=this.getProductField("productHiddenFields");return Array.isArray(t)?t:[]});we(this,"getProductField",t=>this.config?this.config[t]:"");we(this,"getProductFieldValue",(t,n)=>{const r=this.getProductField(n);return r&&t[r]||""});this.apiService=new _C(t,n,r,o,a,u)}getPriceDisplay(t){const n=this.getPrice(t);return n?typeof n=="string"?n.includes("$")?n:`$${n}`:typeof n=="number"?new Intl.NumberFormat("en-US",{style:"currency",currency:"USD"}).format(n):n:""}}const Xo=(e,t,n,...r)=>{if(!e)return;const o=["background: linear-gradient(90deg,rgba(253, 99, 99, 1) 0%, rgba(245, 139, 35, 1) 65%)","font-weight: bold","color: transparent","background-clip: text","text-fill-color: transparent"].join(";");console[t]("%c[cimulate-widget]",o,n,...r)};class xC{constructor(t=!1){we(this,"isDevelopment");we(this,"_log",(t,n,...r)=>{Xo(this.isDevelopment,t,n,...r)});this.isDevelopment=t}log(t,...n){this._log("log",t,...n)}warn(t,...n){this._log("warn",t,...n)}error(t,...n){this._log("error",t,...n)}info(t,...n){this._log("info",t,...n)}debug(t,...n){this._log("debug",t,...n)}}const wC={copilot:"Your Search Assistant",messaging:"Commerce Client"},Yg=B.createContext(null),AC=({mode:e,logoUrl:t,headerText:n,headerConfig:r,globalClassName:o="",entryMessage:a,openLinksInNewTab:u=!1,disclaimerText:c,disclaimerMarkdown:d,clientContext:f,baseCatalogParams:p,searchPlaceholder:m,searchButtonLabel:T,searchConfig:y,suggestionButtonConfig:_,messageAlignment:w="start",autoScroll:C=!0,componentConfig:A,conversationHistory:P,resetConversationMessage:v="",apiKey:H,apiToken:Y,baseUrl:D,customerId:q,tenantId:re,theme:me,isDevelopment:V,__features:oe,routingAttributes:ce,enableDownloadTranscript:de=!0,enableEscalationToAgent:ne=!0,children:Te})=>{const Pe=e==="messaging",se=B.useMemo(()=>{const Se=ce==null?void 0:ce.isCartMgmtSupported;return Se===!0||Se==="true"},[ce]),K=B.useMemo(()=>Pe?{config:null}:new SC(D,H,Y,V,q,re),[Pe,D,H,Y,V,q,re]),ie=B.useMemo(()=>new xC(V),[V]);B.useEffect(()=>{Pe||!K||K.config||K.getConfig()},[K,Pe]);const k=B.useMemo(()=>kA(me),[me]),L=B.useMemo(()=>{const Se=(y==null?void 0:y.placeholder)||m,je=(y==null?void 0:y.buttonLabel)||T;let Ee="icon";return y!=null&&y.buttonType?Ee=y.buttonType:T&&(Ee="text"),pe(F({},y||{}),{placeholder:Se,buttonLabel:je,buttonType:Ee})},[y,m,T]),ee=B.useMemo(()=>pe(F({},r||{}),{logoUrl:t||(r==null?void 0:r.logoUrl),headerText:(r==null?void 0:r.headerText)||n||wC[e!=null?e:"copilot"]}),[r,t,n,e]),I=B.useMemo(()=>({configModule:K,mode:e!=null?e:"copilot",headerConfig:ee,entryMessage:a,globalClassName:o,openLinksInNewTab:u,disclaimerText:c,disclaimerMarkdown:d,clientContext:f,baseCatalogParams:p,themeVariables:k,logger:ie,searchConfig:L,suggestionButtonConfig:_,messageAlignment:w,autoScroll:C,enableMinimize:!!(A!=null&&A.enableMinimize),enableDownloadTranscript:de,enableEscalationToAgent:ne,resetConversationMessage:v,conversationHistory:{sinceHours:typeof(P==null?void 0:P.sinceHours)=="number"?P.sinceHours:1,limit:P==null?void 0:P.limit},features:oe,isCartMgmtSupported:se}),[K,e,ee,a,o,f,p,c,d,u,L,_,w,C,A,de,ne,v,ie,k,P,oe,se]);return x.jsx(Yg.Provider,{value:I,children:Te})},rt=()=>{const e=B.useContext(Yg);if(!e)throw new Error("useConfig must be used within a ConfigProvider");return e};class vC{constructor(){we(this,"initialState",{connected:!1,mode:"embedded",entryType:"search",status:{type:"dialog",isOpen:!1,isMinimized:!1},dialog:{position:"bottom-left",isFullHeight:!1,width:""},modal:{isFullscreen:!1}});we(this,"connectedProxy");we(this,"modeProxy");we(this,"entryTypeProxy");we(this,"statusProxy");we(this,"dialogProxy");we(this,"modalProxy",{isFullscreen:!1});we(this,"_fullGet",(t,n)=>Reflect.get(t,n));we(this,"_fullSet",(t,n,r)=>{if(!(n in t))throw new Error(`Property ${n} does not exist on UIState`);return PC(n,r),Reflect.set(t,n,r)});this.connectedProxy=new Proxy({connected:this.initialState.connected},{get:this._fullGet,set:this._fullSet}),this.modeProxy=new Proxy({mode:this.initialState.mode},{get:this._fullGet,set:this._fullSet}),this.entryTypeProxy=new Proxy({entryType:this.initialState.entryType},{get:this._fullGet,set:this._fullSet}),this.statusProxy=new Proxy({type:this.initialState.status.type,isOpen:this.initialState.status.isOpen,isMinimized:this.initialState.status.isMinimized},{get:this._fullGet,set:this._fullSet}),this.dialogProxy=new Proxy({position:this.initialState.dialog.position,isFullHeight:this.initialState.dialog.isFullHeight,width:this.initialState.dialog.width},{get:this._fullGet,set:this._fullSet}),this.modalProxy=new Proxy({isFullscreen:this.initialState.modal.isFullscreen},{get:this._fullGet,set:this._fullSet})}get connected(){return this.connectedProxy.connected}get mode(){return this.modeProxy.mode}get isOpen(){return!!this.statusProxy.isOpen}get isMinimized(){return!!this.statusProxy.isMinimized}get type(){return this.statusProxy.type}get entryType(){return this.entryTypeProxy.entryType}get position(){return this.dialogProxy.position}get state(){return{connected:this.connected,mode:this.mode,entryType:this.entryType,status:{type:this.type,isOpen:this.isOpen,isMinimized:this.isMinimized},dialog:{position:this.position,isFullHeight:this.dialogProxy.isFullHeight,width:this.dialogProxy.width},modal:{isFullscreen:this.modalProxy.isFullscreen}}}}const et=new vC,uo=()=>et.connected,ba=()=>et.isOpen,CC=e=>{window.addEventListener(uf,e)},kC=e=>{window.removeEventListener(uf,e)},PC=(e,t)=>{const n=new CustomEvent(uf,{detail:{property:e,value:t}});window.dispatchEvent(n)},NC=e=>{et.connectedProxy.connected=e},Ta=e=>{if(!["ask_cim","search","browse","pdp"].includes(e))throw new Error(`Invalid entryType: "${e}". Must be 'ask_cim', 'search', 'browse', or 'pdp'.`);et.entryTypeProxy.entryType=e},ui=e=>{const t=et.statusProxy.isOpen,n=typeof e=="boolean"?e:!t;et.statusProxy.isOpen=n,n&&(et.statusProxy.isMinimized=!1)},El=e=>{const t=et.statusProxy.isMinimized,n=typeof e=="boolean"?e:!t;et.statusProxy.isMinimized=n,n&&(et.statusProxy.isOpen=!1)},vf=e=>{et.modalProxy.isFullscreen=e},yl=e=>{if(!["chat","dialog","modal"].includes(e))throw new Error(`Invalid type: ${e}. Must be 'chat', 'dialog', or 'modal'.`);et.statusProxy.type=e,e==="dialog"||e==="chat"?et.modeProxy.mode="embedded":et.modeProxy.mode="standalone"},Cf=e=>{const t=["top","top-left","top-right","bottom","bottom-left","bottom-right","left","right","center"];if(!t.includes(e))throw new Error(`Invalid position: ${e}. Must be one of ${t.join(", ")}.`);et.dialogProxy.position=e},OC=e=>{const t=et.dialogProxy.isFullHeight,n=typeof e=="boolean"?e:!t;et.dialogProxy.isFullHeight=n},IC=({onCopilotEvent:e,children:t,dispatch:n})=>{const{logger:r}=rt(),o=B.useCallback(v=>{n({type:mt.SET_COPILOT,payload:v})},[n]),a=B.useCallback(v=>{NC(v),n({type:mt.SET_CONNECTED,payload:v})},[n]),u=B.useCallback(()=>{n({type:mt.RESET_COPILOT,payload:{}})},[n]),c=B.useCallback(()=>{n({type:mt.RESET_STATE,payload:{}})},[n]),d=B.useCallback(v=>{r==null||r.log(`${v.name} event received`,v),n({type:mt.ADD_MESSAGE,payload:v}),v.bypassHandlers||e==null||e(v)},[e,r,n]),f=B.useCallback(v=>{n({type:mt.ADD_LOADING_MESSAGE,payload:v})},[n]),p=B.useCallback(v=>{n({type:mt.REMOVE_LOADING_MESSAGE,payload:v})},[n]),m=B.useCallback(v=>{d(v),f(v.id)},[d,f]),T=B.useCallback(v=>{n({type:mt.SET_ACTIVE_CONVERSATION_ID,payload:v})},[n]),y=B.useCallback(v=>{n({type:mt.ADD_CONVERSATION_ID,payload:v})},[n]),_=B.useCallback(v=>{n({type:mt.SET_CONVERSATION_IDS,payload:v})},[n]),w=B.useCallback(v=>{n({type:mt.SET_IMAGE_FILE,payload:v})},[n]),C=B.useCallback(v=>{n({type:mt.SET_ASK_CIM_PROMPTS,payload:v})},[n]),A=B.useCallback(v=>{n({type:mt.SET_CONVERSATION_HISTORY_LOADED,payload:v})},[n]),P=B.useMemo(()=>({setCopilot:o,setConnected:a,resetCopilot:u,resetCopilotState:c,addCopilotEvent:d,addLoadingMessage:f,removeLoadingMessage:p,handleCopilotRequestAck:m,setActiveConversationId:T,addConversationId:y,setConversationIds:_,setImageFile:w,setAskCimPrompts:C,setConversationHistoryLoaded:A}),[o,a,u,c,d,f,p,m,T,y,_,w,C,A]);return x.jsx(og.Provider,{value:P,children:t})};xA();const RC=(e,t)=>{const{type:n,payload:r}=t;if(n===mt.ADD_MESSAGE){const o=r;if(e.messages.push(o),o.eventSourceId){const a=e.groupedMessages.findIndex(u=>u.eventSourceId===o.eventSourceId);if(a!==-1){let u=e.groupedMessages[a].messages;u||(u=[]);const c=u.findIndex(d=>d.id===o.id);if(c!==-1){u[c]=o;return}u.push(o);return}else{e.groupedMessages.push({type:"group",eventSourceId:o.eventSourceId,messages:[o],createdAt:new Date(o.createdAt)});return}}e.groupedMessages.push({type:"individual",message:o,createdAt:new Date(o.createdAt)});return}switch(n){case mt.RESET_STATE:e.messages=ro.messages,e.groupedMessages=ro.groupedMessages,e.loadingMessages=ro.loadingMessages,e.imageFile=ro.imageFile,e.askCimPrompts=ro.askCimPrompts,e.conversationHistoryLoaded=ro.conversationHistoryLoaded;break;case mt.RESET_COPILOT:e.copilot=null;break;case mt.SET_COPILOT:e.copilot=r;break;case mt.SET_CONNECTED:e.connected=r;break;case mt.ADD_LOADING_MESSAGE:e.loadingMessages.add(r);break;case mt.REMOVE_LOADING_MESSAGE:e.loadingMessages.delete(r);break;case mt.SET_ACTIVE_CONVERSATION_ID:e.activeConversationId=r;break;case mt.ADD_CONVERSATION_ID:{const o=r;e.conversationIds.includes(o)||e.conversationIds.push(o)}break;case mt.SET_CONVERSATION_IDS:e.conversationIds=r;break;case mt.SET_IMAGE_FILE:e.imageFile=r;break;case mt.SET_ASK_CIM_PROMPTS:e.askCimPrompts.requestId=(r==null?void 0:r.requestId)||null,e.askCimPrompts.message=(r==null?void 0:r.message)||null;break;case mt.SET_CONVERSATION_HISTORY_LOADED:e.conversationHistoryLoaded=r;break}},LC=({onCopilotEvent:e,children:t})=>{const[n,r]=ng(RC,ro);return x.jsx(ig.Provider,{value:n,children:x.jsx(IC,{onCopilotEvent:e,dispatch:r,children:t})})};function DC(){var e=B.useRef(!0);return e.current?(e.current=!1,!0):e.current}function MC(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];e&&e.addEventListener&&e.addEventListener.apply(e,t)}function FC(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];e&&e.removeEventListener&&e.removeEventListener.apply(e,t)}var kf=typeof window!="undefined",_a=function(e){B.useEffect(e,[])},BC=function(e){var t=B.useRef(e);t.current=e,_a(function(){return function(){return t.current()}})},UC=function(e){var t=B.useRef(0),n=B.useState(e),r=n[0],o=n[1],a=B.useCallback(function(u){cancelAnimationFrame(t.current),t.current=requestAnimationFrame(function(){o(u)})},[]);return BC(function(){cancelAnimationFrame(t.current)}),[r,a]},HC=function(e,t){return e===t};function zC(e,t){t===void 0&&(t=HC);var n=B.useRef(),r=B.useRef(e),o=DC();return!o&&!t(r.current,e)&&(n.current=r.current,r.current=e),n.current}var jC=function(e){var t={},n=t.initialWidth,r=n===void 0?1/0:n,o=t.initialHeight,a=o===void 0?1/0:o,u=t.onChange,c=UC({width:kf?window.innerWidth:r,height:kf?window.innerHeight:a}),d=c[0],f=c[1];return B.useEffect(function(){if(kf){var p=function(){var m=window.innerWidth,T=window.innerHeight;f({width:m,height:T}),u&&u(m,T)};return MC(window,"resize",p),function(){FC(window,"resize",p)}}},[]),d};class $C{constructor(){we(this,"items",[]);we(this,"add",t=>{const n=this.first();n&&n.context===t.context&&this.remove(),this.items.push(t)});we(this,"remove",()=>this.items.shift());we(this,"first",()=>this.items.length>0?this.items[0]:null);we(this,"clear",()=>{this.items.length=0});we(this,"processQueue",t=>{new Array(yn.size).fill(1).forEach(()=>{const r=yn.first();r&&(t(r),yn.remove())})})}get size(){return this.items.length}}const yn=new $C,Wg=e=>{window.addEventListener(af,e)},Gg=e=>{window.removeEventListener(af,e)},VC=(e,t,n)=>{const r=new CustomEvent(af,{detail:{event:e,property:t,value:n}});window.dispatchEvent(r)},Xg=e=>{window.addEventListener(sf,e)},Kg=e=>{window.removeEventListener(sf,e)},qC=(e,t,n)=>{const r=new CustomEvent(sf,{detail:{event:e,property:t,value:n}});window.dispatchEvent(r)},Qg=e=>{window.addEventListener(of,e)},Jg=e=>{window.removeEventListener(of,e)},Zg=(e,t,n)=>{const r=new CustomEvent(of,{detail:{property:e,value:t,event:n}});window.dispatchEvent(r)},YC=e=>{window.addEventListener(cf,e)},WC=e=>{window.removeEventListener(cf,e)},bl=(e,t,n)=>{const r=new CustomEvent(cf,{detail:{property:e,value:t,event:n}});window.dispatchEvent(r)};class GC{constructor(){we(this,"initialParams",{categoryId:"",categoryName:"",page:null,pageSize:null,includeFacets:!0,facetFilters:{},rangeFilters:[],catalogSegment:null,pricebooks:null});we(this,"categoryIdProxy");we(this,"facetFiltersProxy");we(this,"rangeFiltersProxy");we(this,"catalogSegmentProxy");we(this,"pricebooksProxy");we(this,"_fullGet",(t,n)=>Reflect.get(t,n));we(this,"_fullSet",(t,n,r)=>{const o=vA[n];return qC(o,n,r),Reflect.set(t,n,r)});we(this,"updateFacetFiltersProxy",t=>new Proxy({facetFilters:t},{get:this._fullGet,set:this._fullSet}));we(this,"updateRangeFiltersProxy",t=>new Proxy({rangeFilters:t},{get:this._fullGet,set:this._fullSet}));we(this,"updatePricebooksProxy",t=>new Proxy({pricebooks:t},{get:this._fullGet,set:this._fullSet}));this.categoryIdProxy=new Proxy({categoryId:this.initialParams.categoryId,categoryName:this.initialParams.categoryName},{get:this._fullGet,set:this._fullSet}),this.facetFiltersProxy=this.updateFacetFiltersProxy(this.initialParams.facetFilters||{}),this.rangeFiltersProxy=this.updateRangeFiltersProxy(this.initialParams.rangeFilters||[]),this.catalogSegmentProxy=new Proxy({catalogSegment:this.initialParams.catalogSegment},{get:this._fullGet,set:this._fullSet}),this.pricebooksProxy=this.updatePricebooksProxy(this.initialParams.pricebooks||null)}get categoryId(){return this.categoryIdProxy.categoryId||""}get facetFilters(){return this.facetFiltersProxy.facetFilters||{}}get rangeFilters(){return this.rangeFiltersProxy.rangeFilters||[]}get catalogSegment(){return this.catalogSegmentProxy.catalogSegment||null}get pricebooks(){return this.pricebooksProxy.pricebooks||null}get state(){return{categoryId:this.categoryId,categoryName:this.categoryIdProxy.categoryName,facetFilters:this.facetFilters,rangeFilters:this.rangeFilters,catalogSegment:this.catalogSegment,pricebooks:this.pricebooks,page:this.initialParams.page,pageSize:this.initialParams.pageSize,includeFacets:this.initialParams.includeFacets}}}const ct=new GC,e1=(e,t)=>{const n=t.updateFacetFiltersProxy(e);t.facetFiltersProxy.facetFilters=n.facetFilters},t1=(e,t,n)=>{var u,c;const r=F({},((u=n.facetFiltersProxy)==null?void 0:u.facetFilters)||{});if(!!((c=r[e])!=null&&c.includes(t))){const d=r[e].filter(f=>f!==t);d.length>0?r[e]=d:delete r[e]}else r[e]=r[e]?[...r[e],t]:[t];const a=n.updateFacetFiltersProxy(r);n.facetFiltersProxy.facetFilters=a.facetFilters},n1=(e,t)=>{const n=t.updateRangeFiltersProxy(e);t.rangeFiltersProxy.rangeFilters=n.rangeFilters},r1=({field:e,value:t},n)=>{const[r,o]=Array.isArray(t)?t:[];if(typeof r=="undefined"||typeof o=="undefined")throw new Error("Range values must be an array with two numbers for min and max");const a=[...n.rangeFiltersProxy.rangeFilters||[]],u=a.findIndex(d=>d.field===e);if(u!==-1){a[u]={field:e,min:r,max:o},n.rangeFiltersProxy.rangeFilters=a;return}a.push({field:e,min:r,max:o});const c=n.updateRangeFiltersProxy(a);n.rangeFiltersProxy.rangeFilters=c.rangeFilters},i1=(e,t)=>{t.catalogSegmentProxy.catalogSegment=e},o1=(e,t)=>{const n=t.updatePricebooksProxy(e);t.pricebooksProxy.pricebooks=n.pricebooks},XC=e=>{if(!uo()||!ba()){uo()&&yn.clear(),yn.add({context:"browse",payload:pe(F({},ct.state),{categoryId:e})});return}ct.categoryIdProxy.categoryId=e},s1=e=>{e1(e,ct)},KC=(e,t)=>{t1(e,t,ct)},a1=e=>{n1(e,ct)},QC=({field:e,value:t})=>{r1({field:e,value:t},ct)},JC=e=>{i1(e,ct)},u1=e=>{o1(e,ct)},l1=e=>{if(!e||!("categoryId"in e))throw new Error("Browse context must include a categoryId");const t=uo(),n=ba();if(!t||!n){t&&yn.clear(),yn.add({context:"browse",payload:F({},e)});return}"facetFilters"in e&&s1(e.facetFilters||{}),"rangeFilters"in e&&a1(e.rangeFilters||[]),"catalogSegment"in e&&(ct.catalogSegmentProxy.catalogSegment=e.catalogSegment||null),"pricebooks"in e&&u1(e.pricebooks||[]),"categoryName"in e&&(ct.categoryIdProxy.categoryName=e.categoryName||""),ct.categoryIdProxy.categoryId=e.categoryId},ZC=Object.freeze(Object.defineProperty({__proto__:null,setBrowseContext:l1,updateBrowseCategoryId:XC,updateCatalogSegment:JC,updateFacetFilter:KC,updateFacetFilters:s1,updatePricebooks:u1,updateRangeFilter:QC,updateRangeFilters:a1},Symbol.toStringTag,{value:"Module"}));class ek{constructor(){we(this,"initialParams",{productId:"",productName:"",pdpLink:""});we(this,"proxy");we(this,"_fullGet",(t,n)=>Reflect.get(t,n));we(this,"_fullSet",(t,n,r)=>(Zg(n,r),Reflect.set(t,n,r)));we(this,"updateProxy",t=>{t.productId&&(this.proxy=new Proxy({productId:t.productId,productName:t.productName||"",pdpLink:t.pdpLink||""},{get:this._fullGet,set:this._fullSet}))});this.proxy=new Proxy({productId:this.initialParams.productId,productName:this.initialParams.productName,pdpLink:this.initialParams.pdpLink},{get:this._fullGet,set:this._fullSet})}get productId(){return this.proxy.productId}get pdpLink(){return this.proxy.pdpLink}get state(){return{productId:this.productId,productName:this.proxy.productName,pdpLink:this.pdpLink}}}const _r=new ek,c1=e=>{if(!e||!e.productId)throw new Error("PDP context must include a productId");const t=uo(),n=ba();if(!t||!n){t&&yn.clear(),yn.add({context:"pdp",payload:F({},e)});return}_r.updateProxy(e),Zg("pdp-context",e)},tk=e=>{_r.proxy.productId=e,uo()||yn.add({context:"pdp",payload:F({},_r.state)})},nk=e=>{_r.proxy.pdpLink=e},gt={SET_PROMPTS_EXTENSION_INITIALIZED:"SET_PROMPTS_EXTENSION_INITIALIZED",SET_PROMPTS_EXTENSION_OPEN:"SET_PROMPTS_EXTENSION_OPEN",SET_PROMPTS_EXTENSION_INLINE:"SET_PROMPTS_EXTENSION_INLINE",SET_PROMPTS_EXTENSION_ELEMENT_ID:"SET_PROMPTS_EXTENSION_ELEMENT_ID",SET_PROMPTS_EXTENSION_ENTRY_TYPE:"SET_PROMPTS_EXTENSION_ENTRY_TYPE",SET_PROMPTS_EXTENSION_PARAMS:"SET_PROMPTS_EXTENSION_PARAMS",RESET_PROMPTS_EXTENSION_PARAMS:"RESET_PROMPTS_EXTENSION_PARAMS",SET_PROMPTS_EXTENSION_ACTIVE_PROMPTS_ID:"SET_PROMPTS_EXTENSION_ACTIVE_PROMPTS_ID",RESET_PROMPTS_EXTENSION_ACTIVE_PROMPTS_ID:"RESET_PROMPTS_EXTENSION_ACTIVE_PROMPTS_ID",SET_PROMPTS_EXTENSION_USER_PROMPT:"SET_PROMPTS_EXTENSION_USER_PROMPT",SET_PROMPTS_EXTENSION_PROMPTS_MESSAGE:"SET_PROMPTS_EXTENSION_PROMPTS_MESSAGE",RESET_PROMPTS_EXTENSION_PROMPTS_MESSAGE:"RESET_PROMPTS_EXTENSION_PROMPTS_MESSAGE",SET_PROMPTS_EXTENSION_RESPONSE_MESSAGE:"SET_PROMPTS_EXTENSION_RESPONSE_MESSAGE",RESET_PROMPTS_EXTENSION_RESPONSE_MESSAGE:"RESET_PROMPTS_EXTENSION_RESPONSE_MESSAGE",SET_PROMPTS_EXTENSION_RESPONSE_LOADING:"SET_PROMPTS_EXTENSION_RESPONSE_LOADING"},d1={isInitialized:!1,isOpen:!1,isInline:!1,elementId:null,placeholder:null,askElseButtonLabel:null,entryType:null,params:null,activePromptsId:null,userPrompt:null,promptsMessage:null,isResponseLoading:!1,responseMessage:null,promptsDisplay:"both",disableAskElseButton:!1};class rk{constructor(){we(this,"initialState",d1);we(this,"promptsStateProxy");we(this,"promptsParamsProxy");we(this,"_fullGet",(t,n)=>Reflect.get(t,n));we(this,"_fullSet",(t,n,r)=>{if(!(n in t))throw new Error(`Property ${n} does not exist on PromptsExtensionState`);return Sa(n,r),Reflect.set(t,n,r)});we(this,"_paramsFullGet",(t,n)=>Reflect.get(t,n));we(this,"_paramsFullSet",(t,n,r)=>Reflect.set(t,n,r));we(this,"updatePromptsParamsProxy",t=>new Proxy(F({},t),{get:this._paramsFullGet,set:this._paramsFullSet}));this.promptsStateProxy=new Proxy({isOpen:this.initialState.isOpen,isInline:this.initialState.isInline,elementId:this.initialState.elementId,entryType:this.initialState.entryType},{get:this._fullGet,set:this._fullSet}),this.promptsParamsProxy=this.updatePromptsParamsProxy({})}get isOpen(){return this.promptsStateProxy.isOpen}get isInline(){return this.promptsStateProxy.isInline}get state(){return{isOpen:this.isOpen,isInline:this.isInline}}get params(){return this.promptsParamsProxy}}const Ht=new rk,ik=e=>{window.addEventListener(lf,e)},ok=e=>{window.removeEventListener(lf,e)},Sa=(e,t)=>{const n=new CustomEvent(lf,{detail:{property:e,value:t}});window.dispatchEvent(n)},f1=e=>{const t=Ht.isOpen,n=typeof e=="boolean"?e:!t;Ht.promptsStateProxy.isOpen=n},h1=e=>{const t=Ht.isInline,n=typeof e=="boolean"?e:!t;Ht.promptsStateProxy.isInline=n},sk=e=>{Ht.promptsParamsProxy=Ht.updatePromptsParamsProxy(e),Sa("params",e),Ht.promptsStateProxy.entryType="ask_cim"},ak=e=>{Ht.promptsParamsProxy=Ht.updatePromptsParamsProxy(e),Sa("params",e),Ht.promptsStateProxy.entryType="search"},uk=e=>{Ht.promptsParamsProxy=Ht.updatePromptsParamsProxy(e),Sa("params",e),Ht.promptsStateProxy.entryType="browse"},lk=e=>{Ht.promptsParamsProxy=Ht.updatePromptsParamsProxy(e),Sa("params",e),Ht.promptsStateProxy.entryType="pdp"},ck=({elementId:e,entryType:t,params:n,isInline:r})=>{Ht.promptsStateProxy.elementId=e,t&&(Ht.promptsStateProxy.entryType=t),typeof r=="boolean"&&h1(r),n&&Ht.updatePromptsParamsProxy(n),Ht.isOpen||f1(!0)},dk=Object.freeze(Object.defineProperty({__proto__:null,getConversationMessages:({payload:e,callback:t})=>{bl("getConversationMessages",{payload:e,callback:t},Ci.GET_CONVERSATION_MESSAGES)},getSessionInformation:e=>{bl("getSessionInformation",{callback:e},Ci.GET_SESSION_INFORMATION)},loadConversation:e=>{bl("loadConversation",e,Ci.LOAD_CONVERSATION)},resetConversation:()=>{bl("resetConversation",!0,Ci.RESET_CONVERSATION)}},Symbol.toStringTag,{value:"Module"}));class fk{constructor(){we(this,"initialParams",{query:"",page:null,pageSize:null,includeFacets:!0,facetFilters:{},rangeFilters:[],catalogSegment:null,pricebooks:null});we(this,"queryProxy");we(this,"facetFiltersProxy");we(this,"rangeFiltersProxy");we(this,"catalogSegmentProxy");we(this,"pricebooksProxy");we(this,"_fullGet",(t,n)=>Reflect.get(t,n));we(this,"_fullSet",(t,n,r)=>{const o=CA[n];return VC(o,n,r),Reflect.set(t,n,r)});we(this,"updateFacetFiltersProxy",t=>new Proxy({facetFilters:t},{get:this._fullGet,set:this._fullSet}));we(this,"updateRangeFiltersProxy",t=>new Proxy({rangeFilters:t},{get:this._fullGet,set:this._fullSet}));we(this,"updatePricebooksProxy",t=>new Proxy({pricebooks:t},{get:this._fullGet,set:this._fullSet}));this.queryProxy=new Proxy({query:this.initialParams.query},{get:this._fullGet,set:this._fullSet}),this.facetFiltersProxy=this.updateFacetFiltersProxy(this.initialParams.facetFilters||{}),this.rangeFiltersProxy=this.updateRangeFiltersProxy(this.initialParams.rangeFilters||[]),this.catalogSegmentProxy=new Proxy({catalogSegment:this.initialParams.catalogSegment},{get:this._fullGet,set:this._fullSet}),this.pricebooksProxy=this.updatePricebooksProxy(this.initialParams.pricebooks||null)}get query(){return this.queryProxy.query||""}get facetFilters(){return this.facetFiltersProxy.facetFilters||{}}get rangeFilters(){return this.rangeFiltersProxy.rangeFilters||[]}get catalogSegment(){return this.catalogSegmentProxy.catalogSegment||null}get pricebooks(){return this.pricebooksProxy.pricebooks||null}get state(){return{query:this.query,facetFilters:this.facetFilters,rangeFilters:this.rangeFilters,catalogSegment:this.catalogSegment,pricebooks:this.pricebooks,page:this.initialParams.page,pageSize:this.initialParams.pageSize,includeFacets:this.initialParams.includeFacets}}}const Tt=new fk,hk=e=>{const t=ba(),n=uo();if(!n||!t){n&&yn.clear(),yn.add({context:"search",payload:pe(F({},Tt.state),{query:e})});return}Tt.queryProxy.query=e},p1=e=>{e1(e,Tt)},pk=(e,t)=>{t1(e,t,Tt)},m1=e=>{n1(e,Tt)},mk=({field:e,value:t})=>{r1({field:e,value:t},Tt)},gk=e=>{i1(e,Tt)},g1=e=>{o1(e,Tt)},E1=e=>{if(!e||!e.query)throw new Error("Search context must include a query");const t=ba(),n=uo();if(!n||!t){n&&yn.clear(),yn.add({context:"search",payload:F({},e)});return}"facetFilters"in e&&p1(e.facetFilters||{}),"rangeFilters"in e&&m1(e.rangeFilters||[]),"catalogSegment"in e&&(Tt.catalogSegmentProxy.catalogSegment=e.catalogSegment||null),"pricebooks"in e&&g1(e.pricebooks||[]),Tt.queryProxy.query=e.query},Ek=Object.freeze(Object.defineProperty({__proto__:null,setSearchContext:E1,updateCatalogSegment:gk,updateFacetFilter:pk,updateFacetFilters:p1,updatePricebooks:g1,updateRangeFilter:mk,updateRangeFilters:m1,updateSearchQuery:hk},Symbol.toStringTag,{value:"Module"})),yk={categoryId:ct.categoryId,categoryName:ct.categoryIdProxy.categoryName||"",facetFilters:ct.facetFilters,rangeFilters:ct.rangeFilters,catalogSegment:ct.catalogSegment,pricebooks:ct.pricebooks},y1=B.createContext(yk),bk=({children:e})=>{const[t,n]=B.useState(ct.categoryId),[r,o]=B.useState(ct.categoryIdProxy.categoryName||""),[a,u]=B.useState(ct.facetFilters||{}),[c,d]=B.useState(ct.rangeFilters||[]),[f,p]=B.useState(ct.catalogSegment||null),[m,T]=B.useState(ct.pricebooks||null);B.useEffect(()=>{const _=({detail:w})=>{(w==null?void 0:w.property)==="categoryId"&&n(w.value),(w==null?void 0:w.property)==="categoryName"&&o(w.value),(w==null?void 0:w.property)==="facetFilters"&&u(w.value),(w==null?void 0:w.property)==="rangeFilters"&&d(w.value),(w==null?void 0:w.property)==="catalogSegment"&&p(w.value),(w==null?void 0:w.property)==="pricebooks"&&T(w.value)};return Xg(_),()=>{Kg(_)}},[]);const y=B.useMemo(()=>({categoryId:t,categoryName:r,facetFilters:a,rangeFilters:c,catalogSegment:f,pricebooks:m}),[t,r,a,c,f,m]);return x.jsx(y1.Provider,{value:y,children:e})},Tk=()=>{const e=B.useContext(y1);if(!e)throw new Error("useBrowse must be used within a BrowseProvider");return e},_k={searchQuery:Tt.query,facetFilters:Tt.facetFilters,rangeFilters:Tt.rangeFilters,catalogSegment:Tt.catalogSegment,pricebooks:Tt.pricebooks},b1=B.createContext(_k),Sk=({children:e})=>{const[t,n]=B.useState(Tt.query),[r,o]=B.useState(Tt.facetFilters),[a,u]=B.useState(Tt.rangeFilters),[c,d]=B.useState(Tt.catalogSegment),[f,p]=B.useState(Tt.pricebooks);B.useEffect(()=>{const T=({detail:y})=>{(y==null?void 0:y.property)==="query"&&n(y.value),(y==null?void 0:y.property)==="facetFilters"&&o(y.value),(y==null?void 0:y.property)==="rangeFilters"&&u(y.value),(y==null?void 0:y.property)==="catalogSegment"&&d(y.value),(y==null?void 0:y.property)==="pricebooks"&&p(y.value)};return Wg(T),()=>{Gg(T)}},[]);const m=B.useMemo(()=>({searchQuery:t,facetFilters:r,rangeFilters:a,catalogSegment:c,pricebooks:f}),[t,r,a,c,f]);return x.jsx(b1.Provider,{value:m,children:e})},xk=()=>{const e=B.useContext(b1);if(!e)throw new Error("useSearch must be used within a SearchProvider");return e},wk={productId:_r.productId,pdpLink:_r.pdpLink},T1=B.createContext(wk),Ak=({children:e})=>{const[t,n]=B.useState(_r.productId),[r,o]=B.useState(_r.pdpLink);B.useEffect(()=>{const u=({detail:c})=>{if((c==null?void 0:c.property)==="pdp-context"){const d=c.value;n(d.productId),o(d.pdpLink);return}(c==null?void 0:c.property)==="productId"&&n(c.value),(c==null?void 0:c.property)==="pdpLink"&&o(c.value)};return Qg(u),()=>{Jg(u)}},[]);const a=B.useMemo(()=>({productId:t,pdpLink:r}),[t,r]);return x.jsx(T1.Provider,{value:a,children:e})},vk=()=>{const e=B.useContext(T1);if(!e)throw new Error("usePdp must be used within a PdpProvider");return e},_1=B.createContext({mode:et.modeProxy.mode,entryType:et.entryType,status:et.statusProxy,dialogPosition:et.dialogProxy.position,isDialogFullHeight:et.dialogProxy.isFullHeight,dialogWidth:et.dialogProxy.width,isModalFullscreen:et.modalProxy.isFullscreen,previousComponentType:et.statusProxy.type}),Ck=({entryType:e,componentConfig:t,componentType:n,children:r})=>{const[o,a]=B.useState(e!=null?e:et.entryTypeProxy.entryType),[u,c]=B.useState(et.modeProxy.mode),[d,f]=B.useState({type:n||et.statusProxy.type,isOpen:et.statusProxy.isOpen,isMinimized:et.statusProxy.isMinimized}),[p,m]=B.useState(et.dialogProxy.position),[T,y]=B.useState(et.dialogProxy.isFullHeight),[_,w]=B.useState(et.dialogProxy.width),[C,A]=B.useState(et.modalProxy.isFullscreen),P=zC(d.type);B.useEffect(()=>{const H=Y=>{const{property:D,value:q}=Y.detail||{};if(!(!D||q===void 0)){if(D==="mode"){c(q);return}if(D==="entryType"){a(q);return}if(D==="isMinimized"){f(re=>pe(F({},re),{isMinimized:q}));return}if(D==="isOpen"){f(re=>pe(F({},re),{isOpen:q}));return}if(D==="type"){f(re=>pe(F({},re),{type:q}));return}if(D==="position"){m(q);return}if(D==="isFullHeight"){y(q);return}if(D==="width"){w(q);return}if(D==="isFullscreen"){A(q);return}}};return CC(H),()=>{kC(H)}},[]),_a(()=>{e&&Ta(e)}),_a(()=>{const H=n||(t==null?void 0:t.type);H&&yl(H),t&&"isOpen"in t&&ui(!!t.isOpen),t&&"isMinimized"in t&&El(!!t.isMinimized)}),_a(()=>{if(!(t!=null&&t.options))return;const{dialogPosition:H}=t.options;H&&Cf(H),"dialogFullHeight"in t.options&&OC(!!t.options.dialogFullHeight),"dialogWidth"in t.options&&t.options.dialogWidth&&w(t.options.dialogWidth),"isModalFullscreen"in t.options&&vf(!!t.options.isModalFullscreen)});const v=B.useMemo(()=>({mode:u,entryType:o,status:d,previousComponentType:P||"dialog",dialogPosition:p,isDialogFullHeight:T,dialogWidth:_,isModalFullscreen:C}),[u,o,d,P,p,T,_,C]);return x.jsx(_1.Provider,{value:v,children:r})},sr=()=>{const e=B.useContext(_1);if(!e)throw new Error("useUIState must be used within a UIStateProvider");return e},S1=B.createContext(null),x1=B.createContext(null),Pf=()=>{const e=B.useContext(x1);if(!e)throw new Error("usePromptsExtensionDispatch must be used within a PromptsExtensionProvider");return e||{}},li=()=>{const e=B.useContext(S1);if(!e)throw new Error("usePromptsExtensionState must be used within a PromptsExtensionProvider");return e||{}},Ko=()=>{const e=B.useContext(og);if(!e)throw new Error("useCopilotDispatch must be used within a CopilotProvider");return e},ar=()=>{const e=B.useContext(ig);if(!e)throw new Error("useCopilotState must be used within a CopilotProvider");return e},kk=({copilot:e})=>{const{logger:t,conversationHistory:n}=rt(),{isInline:r}=li(),{addCopilotEvent:o,setConversationHistoryLoaded:a}=Ko(),{activeConversationId:u}=ar(),c=B.useCallback(f=>{e&&e.requestSessionInformation(p=>{t==null||t.log("Retrieved session information: ",p),f==null||f(p)})},[e,t]),d=B.useCallback((f,p)=>{e&&f.conversationId&&e.getConversationEvents(f,m=>{t==null||t.log("Retrieved conversation messages: ",m),p==null||p(m)})},[e,t]);return B.useEffect(()=>{if(r||!u)return;if(n.sinceHours===0||(n==null?void 0:n.limit)===0){a(!0);return}const f=3600*1e3*n.sinceHours,p=new Date(Date.now()-f).toISOString(),m={conversationId:u,since:p,excludeEvents:["done","error","connection_error","refined_browse","refined_search","conversation_reset"]};typeof n.limit=="number"&&(m.limit=n.limit),d(m,T=>{const y=[];[...T.reverse()||[]].forEach(w=>{var A;const C=T.find(P=>P.id===w.eventSourceId);(A=C==null?void 0:C.name)!=null&&A.endsWith("_suggestions")||(w.bypassHandlers=!0,y.unshift(w))}),y.forEach(w=>{o(w)}),a(!0)})},[t,r,u,d,o,a,n]),{getSessionInformation:c,getConversationMessages:d}},w1=B.createContext({copilot:null,messages:[],groupedMessages:[],isLoading:!1,isResponseLoading:()=>!1,handleAskCim:()=>{},handleSearch:()=>{},handleBrowse:()=>{},handlePdp:()=>{},handleSuggestion:()=>{},handleUserInput:()=>{},handleCancel:()=>{},resetConversation:()=>{},getSessionInformation:()=>{},getConversationMessages:()=>{}}),Pk=({apiKey:e,apiToken:t,baseUrl:n,customerId:r,tenantId:o,isDevelopment:a,onConnect:u,onRefinedSearch:c,onRefinedBrowse:d,children:f})=>{const{logger:p,clientContext:m,baseCatalogParams:T}=rt(),cn=xk(),{searchQuery:y}=cn,_=mn(cn,["searchQuery"]),Hn=Tk(),{categoryId:w}=Hn,C=mn(Hn,["categoryId"]),{productId:A,pdpLink:P}=vk(),{setCopilot:v,setConnected:H,resetCopilot:Y,resetCopilotState:D,addCopilotEvent:q,removeLoadingMessage:re,handleCopilotRequestAck:me,setActiveConversationId:V,setConversationIds:oe,setAskCimPrompts:ce}=Ko(),{connected:de,copilot:ne,messages:Te,groupedMessages:Pe,loadingMessages:se,askCimPrompts:K}=ar(),{status:ie,entryType:k}=sr(),{isInline:L}=li(),{getConversationMessages:ee,getSessionInformation:I}=kk({copilot:ne}),Se=B.useMemo(()=>se.size>0,[se]),je=B.useCallback(Ae=>se.has(Ae),[se]),Ee=B.useCallback(({query:Ae,facetFilters:Oe,rangeFilters:Me,catalogSegment:ot,pricebooks:pt,userPrompt:J,imageFile:ge})=>{if(!ne){p==null||p.error("Copilot is not initialized");return}if(!Ae)return;const Ce={searchParams:{query:Ae}};J&&(Ce.userPrompt=J),ge&&(Ce.attachments={image:ge}),Oe&&Object.keys(Oe).length>0&&(Ce.searchParams.facetFilters=Oe),Me&&Me.length>0&&(Ce.searchParams.rangeFilters=Me),ot&&(Ce.searchParams.catalogSegment=ot),pt&&(Ce.searchParams.pricebooks=pt),m&&(Ce.clientContext=m),Ta("search"),ne.search(Ce,qe=>{const Re=F({},qe);me(Re)})},[p,me,ne,m]),Fe=B.useCallback(({categoryId:Ae,categoryName:Oe,facetFilters:Me,rangeFilters:ot,catalogSegment:pt,pricebooks:J,userPrompt:ge,imageFile:Ce})=>{if(!ne){p==null||p.error("Copilot is not initialized");return}const qe=Me&&Object.keys(Me).length>0;if(Ae===""&&!qe){p==null||p.error("Browse event must include facetFilters when categoryId is empty");return}const Re={browseParams:{categoryId:Ae||""}};ge&&(Re.userPrompt=ge),Ce&&(Re.attachments={image:Ce}),qe&&(Re.browseParams.facetFilters=Me),ot&&ot.length>0&&(Re.browseParams.rangeFilters=ot),pt&&(Re.browseParams.catalogSegment=pt),Array.isArray(J)&&J.length>0&&(Re.browseParams.pricebooks=J),(m||Oe)&&(Re.clientContext={},m&&(Re.clientContext=F({},m)),Oe&&(Re.clientContext.cimLabel=Oe)),Ta("browse"),ne.browse(Re,dt=>{var Qr;const Gt=F({},dt),$t=((Qr=Gt.request)==null?void 0:Qr.clientContext)||{},dn=($t==null?void 0:$t.cimLabel)||Oe;dn&&Gt.request&&(Gt.request.label=dn),me(Gt)})},[p,me,ne,m]),$e=B.useCallback(({productId:Ae,productName:Oe,pdpLink:Me,userPrompt:ot,imageFile:pt})=>{if(!ne){p==null||p.error("Copilot is not initialized");return}if(!Ae)return;const J={productId:Ae};ot&&(J.userPrompt=ot),Me&&(J.pdpLink=Me),pt&&(J.attachments={image:pt}),(m||Oe)&&(J.clientContext={},m&&(J.clientContext=F({},m)),Oe&&(J.clientContext.cimLabel=Oe)),T&&(J.baseCatalogParams=T),Ta("pdp"),ne.productView(J,ge=>{var dt;const Ce=F({},ge),qe=((dt=Ce.request)==null?void 0:dt.clientContext)||{},Re=(qe==null?void 0:qe.cimLabel)||Oe;Re&&Ce.request&&(Ce.request.label=Re),me(Ce)})},[p,ne,me,m,T]),Ge=B.useCallback(({userPrompt:Ae,imageFile:Oe})=>{if(!ne){p==null||p.error("Copilot is not initialized");return}if(!Ae)return;const Me={userPrompt:Ae};Oe&&(Me.attachments={image:Oe}),m&&(Me.clientContext=m),T&&(Me.baseCatalogParams=T),ne.askCim(Me,ot=>{const pt=F({},ot);me(pt)})},[p,ne,me,m,T]),_t=B.useCallback(Ae=>{q(Ae),c==null||c(Ae)},[q,c]),Nn=B.useCallback(Ae=>{q(Ae),d==null||d(Ae)},[q,d]),ln=B.useCallback(Ae=>{u==null||u(Ae),H(!0)},[u,H]);B.useEffect(()=>{!ne||!de||!ie.isOpen||yn.size>0&&yn.processQueue(Ae=>{if(Ae.context==="search"){const Oe=F({},Ae.payload);E1(Oe)}if(Ae.context==="browse"){const Oe=F({},Ae.payload);l1(Oe)}if(Ae.context==="pdp"){const Oe=F({},Ae.payload);c1(Oe)}})},[ie.isOpen,ne,de]);const Cr=B.useCallback(Ae=>{const Oe=Me=>{const ot=pe(F({},Me),{id:Me.inquiryLinkId||Me.id});q(ot)};Ae.on("connect_ack",ln),Ae.on("partial_inquiry",Oe),Ae.on("display_products",q),Ae.on("progress",q),Ae.on("refined_search",_t),Ae.on("refined_browse",Nn),Ae.on("done",Me=>{re(Me.eventSourceId)}),Ae.on("error",Me=>{q(Me),re(Me.eventSourceId)}),Ae.onDisconnect(Me=>{const ot=["io server disconnect","transport error","server shutting down"];if(p==null||p.log("Connection disconnected with reason: ",Me),!ot.includes(Me)){H(!1);return}p==null||p.log("De-registering event listeners");const pt=new Date().toISOString();q({name:"error",message:"Connection was lost. Please try again.",createdAt:pt,id:`error-${pt}`,sessionId:"session"}),Ae.off()})},[p,H,re,_t,Nn,q,ln]);B.useEffect(()=>{if(!ne)return;const Ae=Oe=>{if(!L){if(!Oe.message&&Oe.eventSourceId&&Oe.eventSourceId===K.requestId){ce({requestId:Oe.eventSourceId,message:Oe});return}q(Oe)}};return ne.on("follow_up",Ae),()=>{ne.off("follow_up",Ae)}},[ne,Te,K.requestId,L,q,ce]),B.useEffect(()=>{if(!ne)return;const Ae=Oe=>{if(L)return;const Me=pe(F({},Oe),{id:Oe.inquiryLinkId||Oe.id});q(Me)};return ne.on("inquiry",Ae),()=>{ne.off("inquiry",Ae)}},[ne,L,q]),_a(()=>{let Ae;n?Ae=n:Ae=a?"https://staging.copilot.search.cimulate.ai":"https://prod.copilot.search.cimulate.ai";const Oe={baseUrl:Ae};e?Oe.apiKey=e:t&&(Oe.apiToken=t),r&&(Oe.customerId=r),o&&(Oe.tenantId=o);const Me=new fA(Oe);return v(Me),Cr(Me),Me.connect(),Me.requestSessionInformation(ot=>{p==null||p.log("Session Information: ",ot);const{activeConversationId:pt,conversationIds:J}=ot.data||{};pt&&V(pt),J!=null&&J.length&&oe(J)}),()=>{Me.disconnect(),Me.off(),Y()}});const fr=B.useCallback(Ae=>{if(!ne)return;const Oe={eventId:Ae,reason:"User cancelled the request"};ne.cancelRequest(Oe,Me=>{q(Me),re(Ae)})},[q,re,ne]),nn=B.useCallback(()=>{ne&&ne.conversationReset({},Ae=>{D(),q(Ae),ne.requestSessionInformation(Oe=>{p==null||p.log("Session Information: ",Oe);const{activeConversationId:Me,conversationIds:ot}=Oe.data||{};Me&&V(Me),ot!=null&&ot.length&&oe(ot)})})},[ne,p,q,D,V,oe]),Ve=B.useCallback((Ae,Oe)=>{if(!Ae)return;const Me={userPrompt:Ae};switch(Oe&&(Me.imageFile=Oe),k){case"ask_cim":Ge(Me);return;case"search":y?Ee(F(F({query:y},_),Me)):Ge(Me);return;case"browse":Fe(F(F({categoryId:w},C),Me));return;case"pdp":A?$e(F({productId:A,pdpLink:P||""},Me)):Ge(Me);return}},[k,y,_,Ee,Ge,w,C,Fe,$e,A,P]),Pt=B.useCallback((Ae,Oe)=>{var ge,Ce,qe;const ot=Ae.params.userPrompt||"";if(!ot)return;const pt=Te.find(Re=>Re.id===Oe);if(!pt)return;const J=pt.name.replace("_suggestions","");if(J==="ask_cim"){Ge({userPrompt:ot});return}if(J==="copilot_search"){const Re=((ge=pt.request)==null?void 0:ge.searchParams)||{},Gt=Re.query===y;Ee(pe(F({query:Re.query||y},Gt?_:{}),{userPrompt:ot}));return}if(J==="copilot_browse"){const Re=pt.request,dt=Re.browseParams||{},$t=dt.categoryId===w,dn=((Ce=Re.clientContext)==null?void 0:Ce.cimLabel)||"";Fe(pe(F({categoryId:dt.categoryId||w||""},$t?C:{}),{categoryName:dn,userPrompt:ot}));return}if(J==="product_view"){const Re=pt.request||{},dt=Re.productId,Gt=dt===A,$t=((qe=Re.clientContext)==null?void 0:qe.cimLabel)||"";let dn="";Gt?dn=P||"":dn=Re.pdpLink||"",$e({productId:dt||A,pdpLink:dn,productName:$t,userPrompt:ot})}},[Te,y,_,Ee,Ge,w,C,Fe,$e,A,P]),On=B.useMemo(()=>({copilot:ne,messages:Te,groupedMessages:Pe,isLoading:Se,isResponseLoading:je,handleAskCim:Ge,handleSearch:Ee,handleBrowse:Fe,handlePdp:$e,handleUserInput:Ve,handleSuggestion:Pt,handleCancel:fr,resetConversation:nn,getSessionInformation:I,getConversationMessages:ee}),[ne,Te,Pe,Se,je,Ge,Ee,Fe,$e,Ve,Pt,fr,nn,I,ee]);return x.jsx(w1.Provider,{value:On,children:f})},A1=()=>{const{copilot:e}=ar(),{addCopilotEvent:t}=Ko();return{getCopilotSuggestions:B.useCallback((r,o,a)=>{if(!e||!o||!r)return;const u=c=>{t(c),a(c)};switch(o){case"ask_cim":e.askCimSuggestions(r,u);break;case"search":e.searchSuggestions({searchParams:r},u);break;case"browse":e.browseSuggestions({browseParams:r},u);break;case"pdp":e.productViewSuggestions({productId:r.productId},u);break}},[e,t])}},Ur=()=>{const e=B.useContext(w1);if(!e)throw new Error("useCopilot must be used within a CopilotProvider");return e},Nk=()=>{const{copilot:e,activeConversationId:t,askCimPrompts:n,conversationHistoryLoaded:r}=ar(),{entryType:o}=sr(),{resetCopilotState:a,addCopilotEvent:u,setAskCimPrompts:c}=Ko(),{handleSearch:d,handleBrowse:f,handlePdp:p,resetConversation:m,getSessionInformation:T,getConversationMessages:y}=Ur(),{getCopilotSuggestions:_}=A1();B.useEffect(()=>{!e||!o||!t||!r||n.requestId||o==="ask_cim"&&_({},o,P=>{c({requestId:P.id,message:null})})},[e,t,n.requestId,o,r,_,c]);const w=B.useCallback(({query:P})=>{if(!e||!P)return;const{facetFilters:v}=Tt.facetFiltersProxy,{rangeFilters:H}=Tt.rangeFiltersProxy,{catalogSegment:Y}=Tt.catalogSegmentProxy,{pricebooks:D}=Tt.pricebooksProxy,q={query:P};q.facetFilters=v||{},q.rangeFilters=H||[],q.catalogSegment=Y||"",q.pricebooks=D||[],d(F({},q))},[e,d]),C=B.useCallback(({categoryId:P})=>{if(!e)return;const v=ct.categoryIdProxy.categoryName,{facetFilters:H}=ct.facetFiltersProxy,{rangeFilters:Y}=ct.rangeFiltersProxy,{catalogSegment:D}=ct.catalogSegmentProxy,{pricebooks:q}=ct.pricebooksProxy,re={categoryId:P};re.categoryName=v||"",re.facetFilters=H||{},re.rangeFilters=Y||[],re.catalogSegment=D||"",re.pricebooks=q||[],f(F({},re))},[e,f]),A=B.useCallback(({productId:P})=>{if(!e||!P)return;const v={productId:P,pdpLink:_r.pdpLink,productName:_r.proxy.productName||""};p(v)},[e,p]);return B.useEffect(()=>{const P=({detail:v})=>{(v==null?void 0:v.property)==="query"&&w({query:v.value})};return Wg(P),()=>{Gg(P)}},[w]),B.useEffect(()=>{const P=({detail:v})=>{if((v==null?void 0:v.property)==="pdp-context"){const H=v.value;A({productId:H.productId});return}(v==null?void 0:v.property)==="productId"&&A({productId:v.value})};return Qg(P),()=>{Jg(P)}},[A]),B.useEffect(()=>{const P=({detail:v})=>{(v==null?void 0:v.property)==="categoryId"&&C({categoryId:v.value})};return Xg(P),()=>{Kg(P)}},[C]),B.useEffect(()=>{const P=({detail:v})=>{if((v==null?void 0:v.event)==Ci.RESET_CONVERSATION&&m(),(v==null?void 0:v.event)==Ci.GET_SESSION_INFORMATION){const H=v.value.callback;T(H)}if((v==null?void 0:v.event)==Ci.GET_CONVERSATION_MESSAGES){const{payload:H,callback:Y}=v.value;if(!H.conversationId||typeof Y!="function")return;y(H,Y)}if((v==null?void 0:v.event)==Ci.LOAD_CONVERSATION){const H=v.value;if(!H.conversationId)return;y(H,D=>{a(),D.forEach(q=>{u(q)})})}};return YC(P),()=>{WC(P)}},[m,T,y,a,u]),null},Ok=({apiKey:e,apiToken:t,baseUrl:n,customerId:r,tenantId:o,isDevelopment:a,onConnect:u,onRefinedSearch:c,onRefinedBrowse:d,children:f})=>x.jsxs(Pk,{apiKey:e,apiToken:t,baseUrl:n,customerId:r,tenantId:o,isDevelopment:a,onConnect:u,onRefinedSearch:c,onRefinedBrowse:d,children:[x.jsx(Nk,{}),f]}),Ik=({children:e,dispatch:t})=>{const n=B.useCallback(_=>{t({type:gt.SET_PROMPTS_EXTENSION_INITIALIZED,payload:_})},[t]),r=B.useCallback(_=>{t({type:gt.SET_PROMPTS_EXTENSION_OPEN,payload:_})},[t]),o=B.useCallback(_=>{t({type:gt.SET_PROMPTS_EXTENSION_INLINE,payload:_})},[t]),a=B.useCallback(_=>{t({type:gt.SET_PROMPTS_EXTENSION_ELEMENT_ID,payload:_})},[t]),u=B.useCallback(_=>{t({type:gt.SET_PROMPTS_EXTENSION_ENTRY_TYPE,payload:_})},[t]),c=B.useCallback(_=>{t({type:gt.SET_PROMPTS_EXTENSION_ACTIVE_PROMPTS_ID,payload:_})},[t]),d=B.useCallback(_=>{t({type:gt.SET_PROMPTS_EXTENSION_USER_PROMPT,payload:_})},[t]),f=B.useCallback(_=>{t({type:gt.SET_PROMPTS_EXTENSION_PARAMS,payload:_})},[t]),p=B.useCallback(_=>{t({type:gt.SET_PROMPTS_EXTENSION_PROMPTS_MESSAGE,payload:_})},[t]),m=B.useCallback(_=>{t({type:gt.SET_PROMPTS_EXTENSION_RESPONSE_MESSAGE,payload:_})},[t]),T=B.useCallback(_=>{t({type:gt.SET_PROMPTS_EXTENSION_RESPONSE_LOADING,payload:_})},[t]),y=B.useMemo(()=>({setIsInitialized:n,setIsOpen:r,setIsInline:o,setElementId:a,setEntryType:u,setActivePromptsId:c,setUserPrompt:d,setParams:f,setPromptsMessage:p,setResponseMessage:m,setIsResponseLoading:T}),[n,r,o,a,u,c,d,f,p,m,T]);return x.jsx(x1.Provider,{value:y,children:e})},Rk=(e,t)=>{const{type:n,payload:r}=t;switch(n){case gt.SET_PROMPTS_EXTENSION_INITIALIZED:e.isInitialized=r;break;case gt.SET_PROMPTS_EXTENSION_OPEN:e.isOpen=r;break;case gt.SET_PROMPTS_EXTENSION_INLINE:e.isInline=r;break;case gt.SET_PROMPTS_EXTENSION_ELEMENT_ID:e.elementId=r;break;case gt.SET_PROMPTS_EXTENSION_ENTRY_TYPE:e.entryType=r;break;case gt.SET_PROMPTS_EXTENSION_PARAMS:e.params=r;break;case gt.RESET_PROMPTS_EXTENSION_PARAMS:e.params=null;break;case gt.SET_PROMPTS_EXTENSION_USER_PROMPT:e.userPrompt=r;break;case gt.SET_PROMPTS_EXTENSION_ACTIVE_PROMPTS_ID:e.activePromptsId=r;break;case gt.RESET_PROMPTS_EXTENSION_ACTIVE_PROMPTS_ID:e.activePromptsId=null;break;case gt.SET_PROMPTS_EXTENSION_PROMPTS_MESSAGE:e.promptsMessage=r;break;case gt.RESET_PROMPTS_EXTENSION_PROMPTS_MESSAGE:e.promptsMessage=null;break;case gt.SET_PROMPTS_EXTENSION_RESPONSE_MESSAGE:e.responseMessage=r;break;case gt.RESET_PROMPTS_EXTENSION_RESPONSE_MESSAGE:e.responseMessage=null;break;case gt.SET_PROMPTS_EXTENSION_RESPONSE_LOADING:e.isResponseLoading=r;break}},Lk=({promptsConfig:e,children:t})=>{const[n,r]=ng(Rk,F(F({},d1),e||{}));return x.jsx(S1.Provider,{value:n,children:x.jsx(Ik,{dispatch:r,children:t})})},v1=({mode:e,apiKey:t,apiToken:n,baseUrl:r,customerId:o,tenantId:a,logoUrl:u,headerText:c,headerConfig:d,theme:f,openLinksInNewTab:p,globalClassName:m,isDevelopment:T=!1,componentType:y,componentConfig:_,entryType:w,entryMessage:C,disclaimerText:A,disclaimerMarkdown:P,clientContext:v,baseCatalogParams:H,searchPlaceholder:Y,searchButtonLabel:D,searchConfig:q,suggestionButtonConfig:re,messageAlignment:me,autoScroll:V,promptsConfig:oe,resetConversationMessage:ce,conversationHistory:de,onConnect:ne,onCopilotEvent:Te,onRefinedSearch:Pe,onRefinedBrowse:se,__features:K,children:ie})=>x.jsx(AC,{mode:e,baseUrl:r,apiKey:t,apiToken:n,customerId:o,tenantId:a,logoUrl:u,headerText:c,headerConfig:d,entryMessage:C,theme:f,globalClassName:m,openLinksInNewTab:p,searchPlaceholder:Y,searchButtonLabel:D,searchConfig:q,suggestionButtonConfig:re,messageAlignment:me,autoScroll:V,componentConfig:_,clientContext:v,baseCatalogParams:H,disclaimerMarkdown:P,disclaimerText:A,resetConversationMessage:ce,conversationHistory:de,isDevelopment:T,__features:K,children:x.jsx(Ck,{entryType:w,componentConfig:_,componentType:y,children:x.jsx(LC,{onCopilotEvent:Te,children:x.jsx(Ak,{children:x.jsx(bk,{children:x.jsx(Sk,{children:x.jsx(Lk,{promptsConfig:oe,children:x.jsx(Ok,{apiKey:t,apiToken:n,baseUrl:r,customerId:o,tenantId:a,isDevelopment:T,entryType:w,onConnect:ne,onRefinedSearch:Pe,onRefinedBrowse:se,onCopilotEvent:Te,children:ie})})})})})})})});var Nf={exports:{}},Dn={},Of={exports:{}},If={};var C1;function Dk(){return C1||(C1=1,(function(e){function t(K,ie){var k=K.length;K.push(ie);e:for(;0<k;){var L=k-1>>>1,ee=K[L];if(0<o(ee,ie))K[L]=ie,K[k]=ee,k=L;else break e}}function n(K){return K.length===0?null:K[0]}function r(K){if(K.length===0)return null;var ie=K[0],k=K.pop();if(k!==ie){K[0]=k;e:for(var L=0,ee=K.length,I=ee>>>1;L<I;){var Se=2*(L+1)-1,je=K[Se],Ee=Se+1,Fe=K[Ee];if(0>o(je,k))Ee<ee&&0>o(Fe,je)?(K[L]=Fe,K[Ee]=k,L=Ee):(K[L]=je,K[Se]=k,L=Se);else if(Ee<ee&&0>o(Fe,k))K[L]=Fe,K[Ee]=k,L=Ee;else break e}}return ie}function o(K,ie){var k=K.sortIndex-ie.sortIndex;return k!==0?k:K.id-ie.id}if(typeof performance=="object"&&typeof performance.now=="function"){var a=performance;e.unstable_now=function(){return a.now()}}else{var u=Date,c=u.now();e.unstable_now=function(){return u.now()-c}}var d=[],f=[],p=1,m=null,T=3,y=!1,_=!1,w=!1,C=typeof setTimeout=="function"?setTimeout:null,A=typeof clearTimeout=="function"?clearTimeout:null,P=typeof setImmediate!="undefined"?setImmediate:null;typeof navigator!="undefined"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function v(K){for(var ie=n(f);ie!==null;){if(ie.callback===null)r(f);else if(ie.startTime<=K)r(f),ie.sortIndex=ie.expirationTime,t(d,ie);else break;ie=n(f)}}function H(K){if(w=!1,v(K),!_)if(n(d)!==null)_=!0,Pe(Y);else{var ie=n(f);ie!==null&&se(H,ie.startTime-K)}}function Y(K,ie){_=!1,w&&(w=!1,A(re),re=-1),y=!0;var k=T;try{for(v(ie),m=n(d);m!==null&&(!(m.expirationTime>ie)||K&&!oe());){var L=m.callback;if(typeof L=="function"){m.callback=null,T=m.priorityLevel;var ee=L(m.expirationTime<=ie);ie=e.unstable_now(),typeof ee=="function"?m.callback=ee:m===n(d)&&r(d),v(ie)}else r(d);m=n(d)}if(m!==null)var I=!0;else{var Se=n(f);Se!==null&&se(H,Se.startTime-ie),I=!1}return I}finally{m=null,T=k,y=!1}}var D=!1,q=null,re=-1,me=5,V=-1;function oe(){return!(e.unstable_now()-V<me)}function ce(){if(q!==null){var K=e.unstable_now();V=K;var ie=!0;try{ie=q(!0,K)}finally{ie?de():(D=!1,q=null)}}else D=!1}var de;if(typeof P=="function")de=function(){P(ce)};else if(typeof MessageChannel!="undefined"){var ne=new MessageChannel,Te=ne.port2;ne.port1.onmessage=ce,de=function(){Te.postMessage(null)}}else de=function(){C(ce,0)};function Pe(K){q=K,D||(D=!0,de())}function se(K,ie){re=C(function(){K(e.unstable_now())},ie)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(K){K.callback=null},e.unstable_continueExecution=function(){_||y||(_=!0,Pe(Y))},e.unstable_forceFrameRate=function(K){0>K||125<K?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):me=0<K?Math.floor(1e3/K):5},e.unstable_getCurrentPriorityLevel=function(){return T},e.unstable_getFirstCallbackNode=function(){return n(d)},e.unstable_next=function(K){switch(T){case 1:case 2:case 3:var ie=3;break;default:ie=T}var k=T;T=ie;try{return K()}finally{T=k}},e.unstable_pauseExecution=function(){},e.unstable_requestPaint=function(){},e.unstable_runWithPriority=function(K,ie){switch(K){case 1:case 2:case 3:case 4:case 5:break;default:K=3}var k=T;T=K;try{return ie()}finally{T=k}},e.unstable_scheduleCallback=function(K,ie,k){var L=e.unstable_now();switch(typeof k=="object"&&k!==null?(k=k.delay,k=typeof k=="number"&&0<k?L+k:L):k=L,K){case 1:var ee=-1;break;case 2:ee=250;break;case 5:ee=1073741823;break;case 4:ee=1e4;break;default:ee=5e3}return ee=k+ee,K={id:p++,callback:ie,priorityLevel:K,startTime:k,expirationTime:ee,sortIndex:-1},k>L?(K.sortIndex=k,t(f,K),n(d)===null&&K===n(f)&&(w?(A(re),re=-1):w=!0,se(H,k-L))):(K.sortIndex=ee,t(d,K),_||y||(_=!0,Pe(Y))),K},e.unstable_shouldYield=oe,e.unstable_wrapCallback=function(K){var ie=T;return function(){var k=T;T=ie;try{return K.apply(this,arguments)}finally{T=k}}}})(If)),If}var k1;function Mk(){return k1||(k1=1,Of.exports=Dk()),Of.exports}var P1;function Fk(){if(P1)return Dn;P1=1;var e=Cn(),t=Mk();function n(i){for(var s="https://reactjs.org/docs/error-decoder.html?invariant="+i,l=1;l<arguments.length;l++)s+="&args[]="+encodeURIComponent(arguments[l]);return"Minified React error #"+i+"; visit "+s+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}var r=new Set,o={};function a(i,s){u(i,s),u(i+"Capture",s)}function u(i,s){for(o[i]=s,i=0;i<s.length;i++)r.add(s[i])}var c=!(typeof window=="undefined"||typeof window.document=="undefined"||typeof window.document.createElement=="undefined"),d=Object.prototype.hasOwnProperty,f=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,p={},m={};function T(i){return d.call(m,i)?!0:d.call(p,i)?!1:f.test(i)?m[i]=!0:(p[i]=!0,!1)}function y(i,s,l,h){if(l!==null&&l.type===0)return!1;switch(typeof s){case"function":case"symbol":return!0;case"boolean":return h?!1:l!==null?!l.acceptsBooleans:(i=i.toLowerCase().slice(0,5),i!=="data-"&&i!=="aria-");default:return!1}}function _(i,s,l,h){if(s===null||typeof s=="undefined"||y(i,s,l,h))return!0;if(h)return!1;if(l!==null)switch(l.type){case 3:return!s;case 4:return s===!1;case 5:return isNaN(s);case 6:return isNaN(s)||1>s}return!1}function w(i,s,l,h,E,b,S){this.acceptsBooleans=s===2||s===3||s===4,this.attributeName=h,this.attributeNamespace=E,this.mustUseProperty=l,this.propertyName=i,this.type=s,this.sanitizeURL=b,this.removeEmptyString=S}var C={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(i){C[i]=new w(i,0,!1,i,null,!1,!1)}),[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(i){var s=i[0];C[s]=new w(s,1,!1,i[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(i){C[i]=new w(i,2,!1,i.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(i){C[i]=new w(i,2,!1,i,null,!1,!1)}),"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(i){C[i]=new w(i,3,!1,i.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(i){C[i]=new w(i,3,!0,i,null,!1,!1)}),["capture","download"].forEach(function(i){C[i]=new w(i,4,!1,i,null,!1,!1)}),["cols","rows","size","span"].forEach(function(i){C[i]=new w(i,6,!1,i,null,!1,!1)}),["rowSpan","start"].forEach(function(i){C[i]=new w(i,5,!1,i.toLowerCase(),null,!1,!1)});var A=/[\-:]([a-z])/g;function P(i){return i[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(i){var s=i.replace(A,P);C[s]=new w(s,1,!1,i,null,!1,!1)}),"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(i){var s=i.replace(A,P);C[s]=new w(s,1,!1,i,"http://www.w3.org/1999/xlink",!1,!1)}),["xml:base","xml:lang","xml:space"].forEach(function(i){var s=i.replace(A,P);C[s]=new w(s,1,!1,i,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(function(i){C[i]=new w(i,1,!1,i.toLowerCase(),null,!1,!1)}),C.xlinkHref=new w("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach(function(i){C[i]=new w(i,1,!1,i.toLowerCase(),null,!0,!0)});function v(i,s,l,h){var E=C.hasOwnProperty(s)?C[s]:null;(E!==null?E.type!==0:h||!(2<s.length)||s[0]!=="o"&&s[0]!=="O"||s[1]!=="n"&&s[1]!=="N")&&(_(s,l,E,h)&&(l=null),h||E===null?T(s)&&(l===null?i.removeAttribute(s):i.setAttribute(s,""+l)):E.mustUseProperty?i[E.propertyName]=l===null?E.type===3?!1:"":l:(s=E.attributeName,h=E.attributeNamespace,l===null?i.removeAttribute(s):(E=E.type,l=E===3||E===4&&l===!0?"":""+l,h?i.setAttributeNS(h,s,l):i.setAttribute(s,l))))}var H=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,Y=Symbol.for("react.element"),D=Symbol.for("react.portal"),q=Symbol.for("react.fragment"),re=Symbol.for("react.strict_mode"),me=Symbol.for("react.profiler"),V=Symbol.for("react.provider"),oe=Symbol.for("react.context"),ce=Symbol.for("react.forward_ref"),de=Symbol.for("react.suspense"),ne=Symbol.for("react.suspense_list"),Te=Symbol.for("react.memo"),Pe=Symbol.for("react.lazy"),se=Symbol.for("react.offscreen"),K=Symbol.iterator;function ie(i){return i===null||typeof i!="object"?null:(i=K&&i[K]||i["@@iterator"],typeof i=="function"?i:null)}var k=Object.assign,L;function ee(i){if(L===void 0)try{throw Error()}catch(l){var s=l.stack.trim().match(/\n( *(at )?)/);L=s&&s[1]||""}return`
10
+ `+a)}}catch(u){}}throw r}})}_request(t,n){typeof t=="string"?(n=n||{},n.url=t):n=t||{},n=so(this.defaults,n);const{transitional:r,paramsSerializer:o,headers:a}=n;r!==void 0&&gl.assertOptions(r,{silentJSONParsing:En.transitional(En.boolean),forcedJSONParsing:En.transitional(En.boolean),clarifyTimeoutError:En.transitional(En.boolean),legacyInterceptorReqResOrdering:En.transitional(En.boolean),advertiseZstdAcceptEncoding:En.transitional(En.boolean),validateStatusUndefinedResolves:En.transitional(En.boolean)},!1),o!=null&&($.isFunction(o)?n.paramsSerializer={serialize:o}:gl.assertOptions(o,{encode:En.function,serialize:En.function},!0)),n.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?n.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:n.allowAbsoluteUrls=!0),gl.assertOptions(n,{baseUrl:En.spelling("baseURL"),withXsrfToken:En.spelling("withXSRFToken")},!0),n.method=(n.method||this.defaults.method||"get").toLowerCase();let u=a&&$.merge(a.common,a[n.method]);a&&$.forEach(["delete","get","head","post","put","patch","query","common"],_=>{delete a[_]}),n.headers=gn.concat(u,a);const c=[];let d=!0;this.interceptors.request.forEach(function(w){if(typeof w.runWhen=="function"&&w.runWhen(n)===!1)return;d=d&&w.synchronous;const C=n.transitional||yf;C&&C.legacyInterceptorReqResOrdering?c.unshift(w.fulfilled,w.rejected):c.push(w.fulfilled,w.rejected)});const f=[];this.interceptors.response.forEach(function(w){f.push(w.fulfilled,w.rejected)});let p,m=0,T;if(!d){const _=[$g.bind(this),void 0];for(_.unshift(...c),_.push(...f),T=_.length,p=Promise.resolve(n);m<T;)p=p.then(_[m++],_[m++]);return p}T=c.length;let y=n;for(;m<T;){const _=c[m++],w=c[m++];try{y=_(y)}catch(C){w.call(this,C);break}}try{p=$g.call(this,y)}catch(_){return Promise.reject(_)}for(m=0,T=f.length;m<T;)p=p.then(f[m++],f[m++]);return p}getUri(t){t=so(this.defaults,t);const n=Rg(t.baseURL,t.url,t.allowAbsoluteUrls,t);return xg(n,t.params,t.paramsSerializer)}};$.forEach(["delete","get","head","options"],function(t){ao.prototype[t]=function(n,r){return this.request(so(r||{},{method:t,url:n,data:r&&$.hasOwnProp(r,"data")?r.data:void 0}))}}),$.forEach(["post","put","patch","query"],function(t){function n(r){return function(a,u,c){return this.request(so(c||{},{method:t,headers:r?{"Content-Type":"multipart/form-data"}:{},url:a,data:u}))}}ao.prototype[t]=n(),t!=="query"&&(ao.prototype[t+"Form"]=n(!0))});let yC=class Zw{constructor(t){if(typeof t!="function")throw new TypeError("executor must be a function.");let n;this.promise=new Promise(function(a){n=a});const r=this;this.promise.then(o=>{if(!r._listeners)return;let a=r._listeners.length;for(;a-- >0;)r._listeners[a](o);r._listeners=null}),this.promise.then=o=>{let a;const u=new Promise(c=>{r.subscribe(c),a=c}).then(o);return u.cancel=function(){r.unsubscribe(a)},u},t(function(a,u,c){r.reason||(r.reason=new ya(a,u,c),n(r.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(t){if(this.reason){t(this.reason);return}this._listeners?this._listeners.push(t):this._listeners=[t]}unsubscribe(t){if(!this._listeners)return;const n=this._listeners.indexOf(t);n!==-1&&this._listeners.splice(n,1)}toAbortSignal(){const t=new AbortController,n=r=>{t.abort(r)};return this.subscribe(n),t.signal.unsubscribe=()=>this.unsubscribe(n),t.signal}static source(){let t;return{token:new Zw(function(o){t=o}),cancel:t}}};function bC(e){return function(n){return e.apply(null,n)}}function TC(e){return $.isObject(e)&&e.isAxiosError===!0}const Af={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511,WebServerIsDown:521,ConnectionTimedOut:522,OriginIsUnreachable:523,TimeoutOccurred:524,SslHandshakeFailed:525,InvalidSslCertificate:526};Object.entries(Af).forEach(([e,t])=>{Af[t]=e});function qg(e){const t=new ao(e),n=sg(ao.prototype.request,t);return $.extend(n,ao.prototype,t,{allOwnKeys:!0}),$.extend(n,t,null,{allOwnKeys:!0}),n.create=function(o){return qg(so(e,o))},n}const Lt=qg(Ea);Lt.Axios=ao,Lt.CanceledError=ya,Lt.CancelToken=yC,Lt.isCancel=kg,Lt.VERSION=Sf,Lt.toFormData=dl,Lt.AxiosError=xe,Lt.Cancel=Lt.CanceledError,Lt.all=function(t){return Promise.all(t)},Lt.spread=bC,Lt.isAxiosError=TC,Lt.mergeConfig=so,Lt.AxiosHeaders=gn,Lt.formToJSON=e=>Cg($.isHTMLForm(e)?new FormData(e):e),Lt.getAdapter=jg.getAdapter,Lt.HttpStatusCode=Af,Lt.default=Lt;const{Axios:cU,AxiosError:dU,CanceledError:fU,isCancel:hU,CancelToken:pU,VERSION:mU,all:gU,Cancel:EU,isAxiosError:yU,spread:bU,toFormData:TU,AxiosHeaders:_U,HttpStatusCode:SU,formToJSON:xU,getAdapter:wU,mergeConfig:AU,create:vU}=Lt;class _C{constructor(t,n,r,o=!1,a,u){we(this,"CIMULATE_API_HEADER","x-cimulate-api-key");we(this,"CIMULATE_SEARCH_API_HOST","search.cimulate");we(this,"CIMULATE_SEARCH_API_PATH","api/v1");we(this,"baseApiUrl");we(this,"headers",{});we(this,"fetchConfig",()=>Je(this,null,function*(){try{const t=yield Lt.get(`${this.apiUrl}/configs/copilot`,{headers:this.headers}),{customer_config:n}=t.data,r=atob(n);return JSON.parse(r)}catch(t){throw console.error("Error fetching customer config:",t),t}}));we(this,"_mapCopilotUrlToSearchUrl",(t="",n=!1)=>{if(t.endsWith("io")){const o=new URL(t);return o.hostname=o.hostname.replace(/^copilot\./,"api."),o.origin}return n?`https://staging.${this.CIMULATE_SEARCH_API_HOST}.ai`:`https://prod.${this.CIMULATE_SEARCH_API_HOST}.ai`});if(n&&r||!n&&!r)throw new Error("Provide exactly one authentication method: either 'apiKey' or 'apiToken', but not both.");n?this.headers[this.CIMULATE_API_HEADER]=n:r&&(this.headers.Authorization=`Bearer ${r}`),a&&(this.headers["x-cimulate-customer-id"]=a),u&&(this.headers["Tenant-ID"]=u),this.baseApiUrl=this._mapCopilotUrlToSearchUrl(t,o)}get apiUrl(){return`${this.baseApiUrl}/${this.CIMULATE_SEARCH_API_PATH}`}}class SC{constructor(t,n,r,o=!1,a,u){we(this,"apiService");we(this,"config",null);we(this,"getConfig",()=>Je(this,null,function*(){if(this.config)return this.config;try{const t=yield this.apiService.fetchConfig();return this.config=t,this.config}catch(t){throw console.error("Failed to fetch customer config:",t),t}}));we(this,"getPid",t=>this.getProductFieldValue(t,"pidCol"));we(this,"getName",t=>this.getProductFieldValue(t,"nameCol"));we(this,"getDescription",t=>this.getProductFieldValue(t,"description"));we(this,"getBrand",t=>this.getProductFieldValue(t,"productBrandCol"));we(this,"getPrice",t=>this.getProductFieldValue(t,"priceCol"));we(this,"getRelativePdp",t=>this.getProductFieldValue(t,"relativePdpCol"));we(this,"getPdp",t=>this.getProductFieldValue(t,"pdpCol"));we(this,"getImage",t=>this.getProductFieldValue(t,"imageCol"));we(this,"getProductHiddenFields",()=>{const t=this.getProductField("productHiddenFields");return Array.isArray(t)?t:[]});we(this,"getProductField",t=>this.config?this.config[t]:"");we(this,"getProductFieldValue",(t,n)=>{const r=this.getProductField(n);return r&&t[r]||""});this.apiService=new _C(t,n,r,o,a,u)}getPriceDisplay(t){const n=this.getPrice(t);return n?typeof n=="string"?n.includes("$")?n:`$${n}`:typeof n=="number"?new Intl.NumberFormat("en-US",{style:"currency",currency:"USD"}).format(n):n:""}}const Xo=(e,t,n,...r)=>{if(!e)return;const o=["background: linear-gradient(90deg,rgba(253, 99, 99, 1) 0%, rgba(245, 139, 35, 1) 65%)","font-weight: bold","color: transparent","background-clip: text","text-fill-color: transparent"].join(";");console[t]("%c[cimulate-widget]",o,n,...r)};class xC{constructor(t=!1){we(this,"isDevelopment");we(this,"_log",(t,n,...r)=>{Xo(this.isDevelopment,t,n,...r)});this.isDevelopment=t}log(t,...n){this._log("log",t,...n)}warn(t,...n){this._log("warn",t,...n)}error(t,...n){this._log("error",t,...n)}info(t,...n){this._log("info",t,...n)}debug(t,...n){this._log("debug",t,...n)}}const wC={copilot:"Your Search Assistant",messaging:"Commerce Client"},Yg=B.createContext(null),AC=({mode:e,logoUrl:t,headerText:n,headerConfig:r,globalClassName:o="",entryMessage:a,openLinksInNewTab:u=!1,disclaimerText:c,disclaimerMarkdown:d,clientContext:f,baseCatalogParams:p,searchPlaceholder:m,searchButtonLabel:T,searchConfig:y,suggestionButtonConfig:_,messageAlignment:w="start",autoScroll:C=!0,componentConfig:A,conversationHistory:P,resetConversationMessage:v="",apiKey:H,apiToken:Y,baseUrl:D,customerId:q,tenantId:re,theme:me,isDevelopment:V,__features:oe,routingAttributes:ce,enableDownloadTranscript:de=!0,enableEscalationToAgent:ne=!1,children:Te})=>{const Pe=e==="messaging",se=B.useMemo(()=>{const Se=ce==null?void 0:ce.isCartMgmtSupported;return Se===!0||Se==="true"},[ce]),K=B.useMemo(()=>Pe?{config:null}:new SC(D,H,Y,V,q,re),[Pe,D,H,Y,V,q,re]),ie=B.useMemo(()=>new xC(V),[V]);B.useEffect(()=>{Pe||!K||K.config||K.getConfig()},[K,Pe]);const k=B.useMemo(()=>kA(me),[me]),L=B.useMemo(()=>{const Se=(y==null?void 0:y.placeholder)||m,je=(y==null?void 0:y.buttonLabel)||T;let Ee="icon";return y!=null&&y.buttonType?Ee=y.buttonType:T&&(Ee="text"),pe(F({},y||{}),{placeholder:Se,buttonLabel:je,buttonType:Ee})},[y,m,T]),ee=B.useMemo(()=>pe(F({},r||{}),{logoUrl:t||(r==null?void 0:r.logoUrl),headerText:(r==null?void 0:r.headerText)||n||wC[e!=null?e:"copilot"]}),[r,t,n,e]),I=B.useMemo(()=>({configModule:K,mode:e!=null?e:"copilot",headerConfig:ee,entryMessage:a,globalClassName:o,openLinksInNewTab:u,disclaimerText:c,disclaimerMarkdown:d,clientContext:f,baseCatalogParams:p,themeVariables:k,logger:ie,searchConfig:L,suggestionButtonConfig:_,messageAlignment:w,autoScroll:C,enableMinimize:!!(A!=null&&A.enableMinimize),enableDownloadTranscript:de,enableEscalationToAgent:ne,resetConversationMessage:v,conversationHistory:{sinceHours:typeof(P==null?void 0:P.sinceHours)=="number"?P.sinceHours:1,limit:P==null?void 0:P.limit},features:oe,isCartMgmtSupported:se}),[K,e,ee,a,o,f,p,c,d,u,L,_,w,C,A,de,ne,v,ie,k,P,oe,se]);return x.jsx(Yg.Provider,{value:I,children:Te})},rt=()=>{const e=B.useContext(Yg);if(!e)throw new Error("useConfig must be used within a ConfigProvider");return e};class vC{constructor(){we(this,"initialState",{connected:!1,mode:"embedded",entryType:"search",status:{type:"dialog",isOpen:!1,isMinimized:!1},dialog:{position:"bottom-left",isFullHeight:!1,width:""},modal:{isFullscreen:!1}});we(this,"connectedProxy");we(this,"modeProxy");we(this,"entryTypeProxy");we(this,"statusProxy");we(this,"dialogProxy");we(this,"modalProxy",{isFullscreen:!1});we(this,"_fullGet",(t,n)=>Reflect.get(t,n));we(this,"_fullSet",(t,n,r)=>{if(!(n in t))throw new Error(`Property ${n} does not exist on UIState`);return PC(n,r),Reflect.set(t,n,r)});this.connectedProxy=new Proxy({connected:this.initialState.connected},{get:this._fullGet,set:this._fullSet}),this.modeProxy=new Proxy({mode:this.initialState.mode},{get:this._fullGet,set:this._fullSet}),this.entryTypeProxy=new Proxy({entryType:this.initialState.entryType},{get:this._fullGet,set:this._fullSet}),this.statusProxy=new Proxy({type:this.initialState.status.type,isOpen:this.initialState.status.isOpen,isMinimized:this.initialState.status.isMinimized},{get:this._fullGet,set:this._fullSet}),this.dialogProxy=new Proxy({position:this.initialState.dialog.position,isFullHeight:this.initialState.dialog.isFullHeight,width:this.initialState.dialog.width},{get:this._fullGet,set:this._fullSet}),this.modalProxy=new Proxy({isFullscreen:this.initialState.modal.isFullscreen},{get:this._fullGet,set:this._fullSet})}get connected(){return this.connectedProxy.connected}get mode(){return this.modeProxy.mode}get isOpen(){return!!this.statusProxy.isOpen}get isMinimized(){return!!this.statusProxy.isMinimized}get type(){return this.statusProxy.type}get entryType(){return this.entryTypeProxy.entryType}get position(){return this.dialogProxy.position}get state(){return{connected:this.connected,mode:this.mode,entryType:this.entryType,status:{type:this.type,isOpen:this.isOpen,isMinimized:this.isMinimized},dialog:{position:this.position,isFullHeight:this.dialogProxy.isFullHeight,width:this.dialogProxy.width},modal:{isFullscreen:this.modalProxy.isFullscreen}}}}const et=new vC,uo=()=>et.connected,ba=()=>et.isOpen,CC=e=>{window.addEventListener(uf,e)},kC=e=>{window.removeEventListener(uf,e)},PC=(e,t)=>{const n=new CustomEvent(uf,{detail:{property:e,value:t}});window.dispatchEvent(n)},NC=e=>{et.connectedProxy.connected=e},Ta=e=>{if(!["ask_cim","search","browse","pdp"].includes(e))throw new Error(`Invalid entryType: "${e}". Must be 'ask_cim', 'search', 'browse', or 'pdp'.`);et.entryTypeProxy.entryType=e},ui=e=>{const t=et.statusProxy.isOpen,n=typeof e=="boolean"?e:!t;et.statusProxy.isOpen=n,n&&(et.statusProxy.isMinimized=!1)},El=e=>{const t=et.statusProxy.isMinimized,n=typeof e=="boolean"?e:!t;et.statusProxy.isMinimized=n,n&&(et.statusProxy.isOpen=!1)},vf=e=>{et.modalProxy.isFullscreen=e},yl=e=>{if(!["chat","dialog","modal"].includes(e))throw new Error(`Invalid type: ${e}. Must be 'chat', 'dialog', or 'modal'.`);et.statusProxy.type=e,e==="dialog"||e==="chat"?et.modeProxy.mode="embedded":et.modeProxy.mode="standalone"},Cf=e=>{const t=["top","top-left","top-right","bottom","bottom-left","bottom-right","left","right","center"];if(!t.includes(e))throw new Error(`Invalid position: ${e}. Must be one of ${t.join(", ")}.`);et.dialogProxy.position=e},OC=e=>{const t=et.dialogProxy.isFullHeight,n=typeof e=="boolean"?e:!t;et.dialogProxy.isFullHeight=n},IC=({onCopilotEvent:e,children:t,dispatch:n})=>{const{logger:r}=rt(),o=B.useCallback(v=>{n({type:mt.SET_COPILOT,payload:v})},[n]),a=B.useCallback(v=>{NC(v),n({type:mt.SET_CONNECTED,payload:v})},[n]),u=B.useCallback(()=>{n({type:mt.RESET_COPILOT,payload:{}})},[n]),c=B.useCallback(()=>{n({type:mt.RESET_STATE,payload:{}})},[n]),d=B.useCallback(v=>{r==null||r.log(`${v.name} event received`,v),n({type:mt.ADD_MESSAGE,payload:v}),v.bypassHandlers||e==null||e(v)},[e,r,n]),f=B.useCallback(v=>{n({type:mt.ADD_LOADING_MESSAGE,payload:v})},[n]),p=B.useCallback(v=>{n({type:mt.REMOVE_LOADING_MESSAGE,payload:v})},[n]),m=B.useCallback(v=>{d(v),f(v.id)},[d,f]),T=B.useCallback(v=>{n({type:mt.SET_ACTIVE_CONVERSATION_ID,payload:v})},[n]),y=B.useCallback(v=>{n({type:mt.ADD_CONVERSATION_ID,payload:v})},[n]),_=B.useCallback(v=>{n({type:mt.SET_CONVERSATION_IDS,payload:v})},[n]),w=B.useCallback(v=>{n({type:mt.SET_IMAGE_FILE,payload:v})},[n]),C=B.useCallback(v=>{n({type:mt.SET_ASK_CIM_PROMPTS,payload:v})},[n]),A=B.useCallback(v=>{n({type:mt.SET_CONVERSATION_HISTORY_LOADED,payload:v})},[n]),P=B.useMemo(()=>({setCopilot:o,setConnected:a,resetCopilot:u,resetCopilotState:c,addCopilotEvent:d,addLoadingMessage:f,removeLoadingMessage:p,handleCopilotRequestAck:m,setActiveConversationId:T,addConversationId:y,setConversationIds:_,setImageFile:w,setAskCimPrompts:C,setConversationHistoryLoaded:A}),[o,a,u,c,d,f,p,m,T,y,_,w,C,A]);return x.jsx(og.Provider,{value:P,children:t})};xA();const RC=(e,t)=>{const{type:n,payload:r}=t;if(n===mt.ADD_MESSAGE){const o=r;if(e.messages.push(o),o.eventSourceId){const a=e.groupedMessages.findIndex(u=>u.eventSourceId===o.eventSourceId);if(a!==-1){let u=e.groupedMessages[a].messages;u||(u=[]);const c=u.findIndex(d=>d.id===o.id);if(c!==-1){u[c]=o;return}u.push(o);return}else{e.groupedMessages.push({type:"group",eventSourceId:o.eventSourceId,messages:[o],createdAt:new Date(o.createdAt)});return}}e.groupedMessages.push({type:"individual",message:o,createdAt:new Date(o.createdAt)});return}switch(n){case mt.RESET_STATE:e.messages=ro.messages,e.groupedMessages=ro.groupedMessages,e.loadingMessages=ro.loadingMessages,e.imageFile=ro.imageFile,e.askCimPrompts=ro.askCimPrompts,e.conversationHistoryLoaded=ro.conversationHistoryLoaded;break;case mt.RESET_COPILOT:e.copilot=null;break;case mt.SET_COPILOT:e.copilot=r;break;case mt.SET_CONNECTED:e.connected=r;break;case mt.ADD_LOADING_MESSAGE:e.loadingMessages.add(r);break;case mt.REMOVE_LOADING_MESSAGE:e.loadingMessages.delete(r);break;case mt.SET_ACTIVE_CONVERSATION_ID:e.activeConversationId=r;break;case mt.ADD_CONVERSATION_ID:{const o=r;e.conversationIds.includes(o)||e.conversationIds.push(o)}break;case mt.SET_CONVERSATION_IDS:e.conversationIds=r;break;case mt.SET_IMAGE_FILE:e.imageFile=r;break;case mt.SET_ASK_CIM_PROMPTS:e.askCimPrompts.requestId=(r==null?void 0:r.requestId)||null,e.askCimPrompts.message=(r==null?void 0:r.message)||null;break;case mt.SET_CONVERSATION_HISTORY_LOADED:e.conversationHistoryLoaded=r;break}},LC=({onCopilotEvent:e,children:t})=>{const[n,r]=ng(RC,ro);return x.jsx(ig.Provider,{value:n,children:x.jsx(IC,{onCopilotEvent:e,dispatch:r,children:t})})};function DC(){var e=B.useRef(!0);return e.current?(e.current=!1,!0):e.current}function MC(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];e&&e.addEventListener&&e.addEventListener.apply(e,t)}function FC(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];e&&e.removeEventListener&&e.removeEventListener.apply(e,t)}var kf=typeof window!="undefined",_a=function(e){B.useEffect(e,[])},BC=function(e){var t=B.useRef(e);t.current=e,_a(function(){return function(){return t.current()}})},UC=function(e){var t=B.useRef(0),n=B.useState(e),r=n[0],o=n[1],a=B.useCallback(function(u){cancelAnimationFrame(t.current),t.current=requestAnimationFrame(function(){o(u)})},[]);return BC(function(){cancelAnimationFrame(t.current)}),[r,a]},HC=function(e,t){return e===t};function zC(e,t){t===void 0&&(t=HC);var n=B.useRef(),r=B.useRef(e),o=DC();return!o&&!t(r.current,e)&&(n.current=r.current,r.current=e),n.current}var jC=function(e){var t={},n=t.initialWidth,r=n===void 0?1/0:n,o=t.initialHeight,a=o===void 0?1/0:o,u=t.onChange,c=UC({width:kf?window.innerWidth:r,height:kf?window.innerHeight:a}),d=c[0],f=c[1];return B.useEffect(function(){if(kf){var p=function(){var m=window.innerWidth,T=window.innerHeight;f({width:m,height:T}),u&&u(m,T)};return MC(window,"resize",p),function(){FC(window,"resize",p)}}},[]),d};class $C{constructor(){we(this,"items",[]);we(this,"add",t=>{const n=this.first();n&&n.context===t.context&&this.remove(),this.items.push(t)});we(this,"remove",()=>this.items.shift());we(this,"first",()=>this.items.length>0?this.items[0]:null);we(this,"clear",()=>{this.items.length=0});we(this,"processQueue",t=>{new Array(yn.size).fill(1).forEach(()=>{const r=yn.first();r&&(t(r),yn.remove())})})}get size(){return this.items.length}}const yn=new $C,Wg=e=>{window.addEventListener(af,e)},Gg=e=>{window.removeEventListener(af,e)},VC=(e,t,n)=>{const r=new CustomEvent(af,{detail:{event:e,property:t,value:n}});window.dispatchEvent(r)},Xg=e=>{window.addEventListener(sf,e)},Kg=e=>{window.removeEventListener(sf,e)},qC=(e,t,n)=>{const r=new CustomEvent(sf,{detail:{event:e,property:t,value:n}});window.dispatchEvent(r)},Qg=e=>{window.addEventListener(of,e)},Jg=e=>{window.removeEventListener(of,e)},Zg=(e,t,n)=>{const r=new CustomEvent(of,{detail:{property:e,value:t,event:n}});window.dispatchEvent(r)},YC=e=>{window.addEventListener(cf,e)},WC=e=>{window.removeEventListener(cf,e)},bl=(e,t,n)=>{const r=new CustomEvent(cf,{detail:{property:e,value:t,event:n}});window.dispatchEvent(r)};class GC{constructor(){we(this,"initialParams",{categoryId:"",categoryName:"",page:null,pageSize:null,includeFacets:!0,facetFilters:{},rangeFilters:[],catalogSegment:null,pricebooks:null});we(this,"categoryIdProxy");we(this,"facetFiltersProxy");we(this,"rangeFiltersProxy");we(this,"catalogSegmentProxy");we(this,"pricebooksProxy");we(this,"_fullGet",(t,n)=>Reflect.get(t,n));we(this,"_fullSet",(t,n,r)=>{const o=vA[n];return qC(o,n,r),Reflect.set(t,n,r)});we(this,"updateFacetFiltersProxy",t=>new Proxy({facetFilters:t},{get:this._fullGet,set:this._fullSet}));we(this,"updateRangeFiltersProxy",t=>new Proxy({rangeFilters:t},{get:this._fullGet,set:this._fullSet}));we(this,"updatePricebooksProxy",t=>new Proxy({pricebooks:t},{get:this._fullGet,set:this._fullSet}));this.categoryIdProxy=new Proxy({categoryId:this.initialParams.categoryId,categoryName:this.initialParams.categoryName},{get:this._fullGet,set:this._fullSet}),this.facetFiltersProxy=this.updateFacetFiltersProxy(this.initialParams.facetFilters||{}),this.rangeFiltersProxy=this.updateRangeFiltersProxy(this.initialParams.rangeFilters||[]),this.catalogSegmentProxy=new Proxy({catalogSegment:this.initialParams.catalogSegment},{get:this._fullGet,set:this._fullSet}),this.pricebooksProxy=this.updatePricebooksProxy(this.initialParams.pricebooks||null)}get categoryId(){return this.categoryIdProxy.categoryId||""}get facetFilters(){return this.facetFiltersProxy.facetFilters||{}}get rangeFilters(){return this.rangeFiltersProxy.rangeFilters||[]}get catalogSegment(){return this.catalogSegmentProxy.catalogSegment||null}get pricebooks(){return this.pricebooksProxy.pricebooks||null}get state(){return{categoryId:this.categoryId,categoryName:this.categoryIdProxy.categoryName,facetFilters:this.facetFilters,rangeFilters:this.rangeFilters,catalogSegment:this.catalogSegment,pricebooks:this.pricebooks,page:this.initialParams.page,pageSize:this.initialParams.pageSize,includeFacets:this.initialParams.includeFacets}}}const ct=new GC,e1=(e,t)=>{const n=t.updateFacetFiltersProxy(e);t.facetFiltersProxy.facetFilters=n.facetFilters},t1=(e,t,n)=>{var u,c;const r=F({},((u=n.facetFiltersProxy)==null?void 0:u.facetFilters)||{});if(!!((c=r[e])!=null&&c.includes(t))){const d=r[e].filter(f=>f!==t);d.length>0?r[e]=d:delete r[e]}else r[e]=r[e]?[...r[e],t]:[t];const a=n.updateFacetFiltersProxy(r);n.facetFiltersProxy.facetFilters=a.facetFilters},n1=(e,t)=>{const n=t.updateRangeFiltersProxy(e);t.rangeFiltersProxy.rangeFilters=n.rangeFilters},r1=({field:e,value:t},n)=>{const[r,o]=Array.isArray(t)?t:[];if(typeof r=="undefined"||typeof o=="undefined")throw new Error("Range values must be an array with two numbers for min and max");const a=[...n.rangeFiltersProxy.rangeFilters||[]],u=a.findIndex(d=>d.field===e);if(u!==-1){a[u]={field:e,min:r,max:o},n.rangeFiltersProxy.rangeFilters=a;return}a.push({field:e,min:r,max:o});const c=n.updateRangeFiltersProxy(a);n.rangeFiltersProxy.rangeFilters=c.rangeFilters},i1=(e,t)=>{t.catalogSegmentProxy.catalogSegment=e},o1=(e,t)=>{const n=t.updatePricebooksProxy(e);t.pricebooksProxy.pricebooks=n.pricebooks},XC=e=>{if(!uo()||!ba()){uo()&&yn.clear(),yn.add({context:"browse",payload:pe(F({},ct.state),{categoryId:e})});return}ct.categoryIdProxy.categoryId=e},s1=e=>{e1(e,ct)},KC=(e,t)=>{t1(e,t,ct)},a1=e=>{n1(e,ct)},QC=({field:e,value:t})=>{r1({field:e,value:t},ct)},JC=e=>{i1(e,ct)},u1=e=>{o1(e,ct)},l1=e=>{if(!e||!("categoryId"in e))throw new Error("Browse context must include a categoryId");const t=uo(),n=ba();if(!t||!n){t&&yn.clear(),yn.add({context:"browse",payload:F({},e)});return}"facetFilters"in e&&s1(e.facetFilters||{}),"rangeFilters"in e&&a1(e.rangeFilters||[]),"catalogSegment"in e&&(ct.catalogSegmentProxy.catalogSegment=e.catalogSegment||null),"pricebooks"in e&&u1(e.pricebooks||[]),"categoryName"in e&&(ct.categoryIdProxy.categoryName=e.categoryName||""),ct.categoryIdProxy.categoryId=e.categoryId},ZC=Object.freeze(Object.defineProperty({__proto__:null,setBrowseContext:l1,updateBrowseCategoryId:XC,updateCatalogSegment:JC,updateFacetFilter:KC,updateFacetFilters:s1,updatePricebooks:u1,updateRangeFilter:QC,updateRangeFilters:a1},Symbol.toStringTag,{value:"Module"}));class ek{constructor(){we(this,"initialParams",{productId:"",productName:"",pdpLink:""});we(this,"proxy");we(this,"_fullGet",(t,n)=>Reflect.get(t,n));we(this,"_fullSet",(t,n,r)=>(Zg(n,r),Reflect.set(t,n,r)));we(this,"updateProxy",t=>{t.productId&&(this.proxy=new Proxy({productId:t.productId,productName:t.productName||"",pdpLink:t.pdpLink||""},{get:this._fullGet,set:this._fullSet}))});this.proxy=new Proxy({productId:this.initialParams.productId,productName:this.initialParams.productName,pdpLink:this.initialParams.pdpLink},{get:this._fullGet,set:this._fullSet})}get productId(){return this.proxy.productId}get pdpLink(){return this.proxy.pdpLink}get state(){return{productId:this.productId,productName:this.proxy.productName,pdpLink:this.pdpLink}}}const _r=new ek,c1=e=>{if(!e||!e.productId)throw new Error("PDP context must include a productId");const t=uo(),n=ba();if(!t||!n){t&&yn.clear(),yn.add({context:"pdp",payload:F({},e)});return}_r.updateProxy(e),Zg("pdp-context",e)},tk=e=>{_r.proxy.productId=e,uo()||yn.add({context:"pdp",payload:F({},_r.state)})},nk=e=>{_r.proxy.pdpLink=e},gt={SET_PROMPTS_EXTENSION_INITIALIZED:"SET_PROMPTS_EXTENSION_INITIALIZED",SET_PROMPTS_EXTENSION_OPEN:"SET_PROMPTS_EXTENSION_OPEN",SET_PROMPTS_EXTENSION_INLINE:"SET_PROMPTS_EXTENSION_INLINE",SET_PROMPTS_EXTENSION_ELEMENT_ID:"SET_PROMPTS_EXTENSION_ELEMENT_ID",SET_PROMPTS_EXTENSION_ENTRY_TYPE:"SET_PROMPTS_EXTENSION_ENTRY_TYPE",SET_PROMPTS_EXTENSION_PARAMS:"SET_PROMPTS_EXTENSION_PARAMS",RESET_PROMPTS_EXTENSION_PARAMS:"RESET_PROMPTS_EXTENSION_PARAMS",SET_PROMPTS_EXTENSION_ACTIVE_PROMPTS_ID:"SET_PROMPTS_EXTENSION_ACTIVE_PROMPTS_ID",RESET_PROMPTS_EXTENSION_ACTIVE_PROMPTS_ID:"RESET_PROMPTS_EXTENSION_ACTIVE_PROMPTS_ID",SET_PROMPTS_EXTENSION_USER_PROMPT:"SET_PROMPTS_EXTENSION_USER_PROMPT",SET_PROMPTS_EXTENSION_PROMPTS_MESSAGE:"SET_PROMPTS_EXTENSION_PROMPTS_MESSAGE",RESET_PROMPTS_EXTENSION_PROMPTS_MESSAGE:"RESET_PROMPTS_EXTENSION_PROMPTS_MESSAGE",SET_PROMPTS_EXTENSION_RESPONSE_MESSAGE:"SET_PROMPTS_EXTENSION_RESPONSE_MESSAGE",RESET_PROMPTS_EXTENSION_RESPONSE_MESSAGE:"RESET_PROMPTS_EXTENSION_RESPONSE_MESSAGE",SET_PROMPTS_EXTENSION_RESPONSE_LOADING:"SET_PROMPTS_EXTENSION_RESPONSE_LOADING"},d1={isInitialized:!1,isOpen:!1,isInline:!1,elementId:null,placeholder:null,askElseButtonLabel:null,entryType:null,params:null,activePromptsId:null,userPrompt:null,promptsMessage:null,isResponseLoading:!1,responseMessage:null,promptsDisplay:"both",disableAskElseButton:!1};class rk{constructor(){we(this,"initialState",d1);we(this,"promptsStateProxy");we(this,"promptsParamsProxy");we(this,"_fullGet",(t,n)=>Reflect.get(t,n));we(this,"_fullSet",(t,n,r)=>{if(!(n in t))throw new Error(`Property ${n} does not exist on PromptsExtensionState`);return Sa(n,r),Reflect.set(t,n,r)});we(this,"_paramsFullGet",(t,n)=>Reflect.get(t,n));we(this,"_paramsFullSet",(t,n,r)=>Reflect.set(t,n,r));we(this,"updatePromptsParamsProxy",t=>new Proxy(F({},t),{get:this._paramsFullGet,set:this._paramsFullSet}));this.promptsStateProxy=new Proxy({isOpen:this.initialState.isOpen,isInline:this.initialState.isInline,elementId:this.initialState.elementId,entryType:this.initialState.entryType},{get:this._fullGet,set:this._fullSet}),this.promptsParamsProxy=this.updatePromptsParamsProxy({})}get isOpen(){return this.promptsStateProxy.isOpen}get isInline(){return this.promptsStateProxy.isInline}get state(){return{isOpen:this.isOpen,isInline:this.isInline}}get params(){return this.promptsParamsProxy}}const Ht=new rk,ik=e=>{window.addEventListener(lf,e)},ok=e=>{window.removeEventListener(lf,e)},Sa=(e,t)=>{const n=new CustomEvent(lf,{detail:{property:e,value:t}});window.dispatchEvent(n)},f1=e=>{const t=Ht.isOpen,n=typeof e=="boolean"?e:!t;Ht.promptsStateProxy.isOpen=n},h1=e=>{const t=Ht.isInline,n=typeof e=="boolean"?e:!t;Ht.promptsStateProxy.isInline=n},sk=e=>{Ht.promptsParamsProxy=Ht.updatePromptsParamsProxy(e),Sa("params",e),Ht.promptsStateProxy.entryType="ask_cim"},ak=e=>{Ht.promptsParamsProxy=Ht.updatePromptsParamsProxy(e),Sa("params",e),Ht.promptsStateProxy.entryType="search"},uk=e=>{Ht.promptsParamsProxy=Ht.updatePromptsParamsProxy(e),Sa("params",e),Ht.promptsStateProxy.entryType="browse"},lk=e=>{Ht.promptsParamsProxy=Ht.updatePromptsParamsProxy(e),Sa("params",e),Ht.promptsStateProxy.entryType="pdp"},ck=({elementId:e,entryType:t,params:n,isInline:r})=>{Ht.promptsStateProxy.elementId=e,t&&(Ht.promptsStateProxy.entryType=t),typeof r=="boolean"&&h1(r),n&&Ht.updatePromptsParamsProxy(n),Ht.isOpen||f1(!0)},dk=Object.freeze(Object.defineProperty({__proto__:null,getConversationMessages:({payload:e,callback:t})=>{bl("getConversationMessages",{payload:e,callback:t},Ci.GET_CONVERSATION_MESSAGES)},getSessionInformation:e=>{bl("getSessionInformation",{callback:e},Ci.GET_SESSION_INFORMATION)},loadConversation:e=>{bl("loadConversation",e,Ci.LOAD_CONVERSATION)},resetConversation:()=>{bl("resetConversation",!0,Ci.RESET_CONVERSATION)}},Symbol.toStringTag,{value:"Module"}));class fk{constructor(){we(this,"initialParams",{query:"",page:null,pageSize:null,includeFacets:!0,facetFilters:{},rangeFilters:[],catalogSegment:null,pricebooks:null});we(this,"queryProxy");we(this,"facetFiltersProxy");we(this,"rangeFiltersProxy");we(this,"catalogSegmentProxy");we(this,"pricebooksProxy");we(this,"_fullGet",(t,n)=>Reflect.get(t,n));we(this,"_fullSet",(t,n,r)=>{const o=CA[n];return VC(o,n,r),Reflect.set(t,n,r)});we(this,"updateFacetFiltersProxy",t=>new Proxy({facetFilters:t},{get:this._fullGet,set:this._fullSet}));we(this,"updateRangeFiltersProxy",t=>new Proxy({rangeFilters:t},{get:this._fullGet,set:this._fullSet}));we(this,"updatePricebooksProxy",t=>new Proxy({pricebooks:t},{get:this._fullGet,set:this._fullSet}));this.queryProxy=new Proxy({query:this.initialParams.query},{get:this._fullGet,set:this._fullSet}),this.facetFiltersProxy=this.updateFacetFiltersProxy(this.initialParams.facetFilters||{}),this.rangeFiltersProxy=this.updateRangeFiltersProxy(this.initialParams.rangeFilters||[]),this.catalogSegmentProxy=new Proxy({catalogSegment:this.initialParams.catalogSegment},{get:this._fullGet,set:this._fullSet}),this.pricebooksProxy=this.updatePricebooksProxy(this.initialParams.pricebooks||null)}get query(){return this.queryProxy.query||""}get facetFilters(){return this.facetFiltersProxy.facetFilters||{}}get rangeFilters(){return this.rangeFiltersProxy.rangeFilters||[]}get catalogSegment(){return this.catalogSegmentProxy.catalogSegment||null}get pricebooks(){return this.pricebooksProxy.pricebooks||null}get state(){return{query:this.query,facetFilters:this.facetFilters,rangeFilters:this.rangeFilters,catalogSegment:this.catalogSegment,pricebooks:this.pricebooks,page:this.initialParams.page,pageSize:this.initialParams.pageSize,includeFacets:this.initialParams.includeFacets}}}const Tt=new fk,hk=e=>{const t=ba(),n=uo();if(!n||!t){n&&yn.clear(),yn.add({context:"search",payload:pe(F({},Tt.state),{query:e})});return}Tt.queryProxy.query=e},p1=e=>{e1(e,Tt)},pk=(e,t)=>{t1(e,t,Tt)},m1=e=>{n1(e,Tt)},mk=({field:e,value:t})=>{r1({field:e,value:t},Tt)},gk=e=>{i1(e,Tt)},g1=e=>{o1(e,Tt)},E1=e=>{if(!e||!e.query)throw new Error("Search context must include a query");const t=ba(),n=uo();if(!n||!t){n&&yn.clear(),yn.add({context:"search",payload:F({},e)});return}"facetFilters"in e&&p1(e.facetFilters||{}),"rangeFilters"in e&&m1(e.rangeFilters||[]),"catalogSegment"in e&&(Tt.catalogSegmentProxy.catalogSegment=e.catalogSegment||null),"pricebooks"in e&&g1(e.pricebooks||[]),Tt.queryProxy.query=e.query},Ek=Object.freeze(Object.defineProperty({__proto__:null,setSearchContext:E1,updateCatalogSegment:gk,updateFacetFilter:pk,updateFacetFilters:p1,updatePricebooks:g1,updateRangeFilter:mk,updateRangeFilters:m1,updateSearchQuery:hk},Symbol.toStringTag,{value:"Module"})),yk={categoryId:ct.categoryId,categoryName:ct.categoryIdProxy.categoryName||"",facetFilters:ct.facetFilters,rangeFilters:ct.rangeFilters,catalogSegment:ct.catalogSegment,pricebooks:ct.pricebooks},y1=B.createContext(yk),bk=({children:e})=>{const[t,n]=B.useState(ct.categoryId),[r,o]=B.useState(ct.categoryIdProxy.categoryName||""),[a,u]=B.useState(ct.facetFilters||{}),[c,d]=B.useState(ct.rangeFilters||[]),[f,p]=B.useState(ct.catalogSegment||null),[m,T]=B.useState(ct.pricebooks||null);B.useEffect(()=>{const _=({detail:w})=>{(w==null?void 0:w.property)==="categoryId"&&n(w.value),(w==null?void 0:w.property)==="categoryName"&&o(w.value),(w==null?void 0:w.property)==="facetFilters"&&u(w.value),(w==null?void 0:w.property)==="rangeFilters"&&d(w.value),(w==null?void 0:w.property)==="catalogSegment"&&p(w.value),(w==null?void 0:w.property)==="pricebooks"&&T(w.value)};return Xg(_),()=>{Kg(_)}},[]);const y=B.useMemo(()=>({categoryId:t,categoryName:r,facetFilters:a,rangeFilters:c,catalogSegment:f,pricebooks:m}),[t,r,a,c,f,m]);return x.jsx(y1.Provider,{value:y,children:e})},Tk=()=>{const e=B.useContext(y1);if(!e)throw new Error("useBrowse must be used within a BrowseProvider");return e},_k={searchQuery:Tt.query,facetFilters:Tt.facetFilters,rangeFilters:Tt.rangeFilters,catalogSegment:Tt.catalogSegment,pricebooks:Tt.pricebooks},b1=B.createContext(_k),Sk=({children:e})=>{const[t,n]=B.useState(Tt.query),[r,o]=B.useState(Tt.facetFilters),[a,u]=B.useState(Tt.rangeFilters),[c,d]=B.useState(Tt.catalogSegment),[f,p]=B.useState(Tt.pricebooks);B.useEffect(()=>{const T=({detail:y})=>{(y==null?void 0:y.property)==="query"&&n(y.value),(y==null?void 0:y.property)==="facetFilters"&&o(y.value),(y==null?void 0:y.property)==="rangeFilters"&&u(y.value),(y==null?void 0:y.property)==="catalogSegment"&&d(y.value),(y==null?void 0:y.property)==="pricebooks"&&p(y.value)};return Wg(T),()=>{Gg(T)}},[]);const m=B.useMemo(()=>({searchQuery:t,facetFilters:r,rangeFilters:a,catalogSegment:c,pricebooks:f}),[t,r,a,c,f]);return x.jsx(b1.Provider,{value:m,children:e})},xk=()=>{const e=B.useContext(b1);if(!e)throw new Error("useSearch must be used within a SearchProvider");return e},wk={productId:_r.productId,pdpLink:_r.pdpLink},T1=B.createContext(wk),Ak=({children:e})=>{const[t,n]=B.useState(_r.productId),[r,o]=B.useState(_r.pdpLink);B.useEffect(()=>{const u=({detail:c})=>{if((c==null?void 0:c.property)==="pdp-context"){const d=c.value;n(d.productId),o(d.pdpLink);return}(c==null?void 0:c.property)==="productId"&&n(c.value),(c==null?void 0:c.property)==="pdpLink"&&o(c.value)};return Qg(u),()=>{Jg(u)}},[]);const a=B.useMemo(()=>({productId:t,pdpLink:r}),[t,r]);return x.jsx(T1.Provider,{value:a,children:e})},vk=()=>{const e=B.useContext(T1);if(!e)throw new Error("usePdp must be used within a PdpProvider");return e},_1=B.createContext({mode:et.modeProxy.mode,entryType:et.entryType,status:et.statusProxy,dialogPosition:et.dialogProxy.position,isDialogFullHeight:et.dialogProxy.isFullHeight,dialogWidth:et.dialogProxy.width,isModalFullscreen:et.modalProxy.isFullscreen,previousComponentType:et.statusProxy.type}),Ck=({entryType:e,componentConfig:t,componentType:n,children:r})=>{const[o,a]=B.useState(e!=null?e:et.entryTypeProxy.entryType),[u,c]=B.useState(et.modeProxy.mode),[d,f]=B.useState({type:n||et.statusProxy.type,isOpen:et.statusProxy.isOpen,isMinimized:et.statusProxy.isMinimized}),[p,m]=B.useState(et.dialogProxy.position),[T,y]=B.useState(et.dialogProxy.isFullHeight),[_,w]=B.useState(et.dialogProxy.width),[C,A]=B.useState(et.modalProxy.isFullscreen),P=zC(d.type);B.useEffect(()=>{const H=Y=>{const{property:D,value:q}=Y.detail||{};if(!(!D||q===void 0)){if(D==="mode"){c(q);return}if(D==="entryType"){a(q);return}if(D==="isMinimized"){f(re=>pe(F({},re),{isMinimized:q}));return}if(D==="isOpen"){f(re=>pe(F({},re),{isOpen:q}));return}if(D==="type"){f(re=>pe(F({},re),{type:q}));return}if(D==="position"){m(q);return}if(D==="isFullHeight"){y(q);return}if(D==="width"){w(q);return}if(D==="isFullscreen"){A(q);return}}};return CC(H),()=>{kC(H)}},[]),_a(()=>{e&&Ta(e)}),_a(()=>{const H=n||(t==null?void 0:t.type);H&&yl(H),t&&"isOpen"in t&&ui(!!t.isOpen),t&&"isMinimized"in t&&El(!!t.isMinimized)}),_a(()=>{if(!(t!=null&&t.options))return;const{dialogPosition:H}=t.options;H&&Cf(H),"dialogFullHeight"in t.options&&OC(!!t.options.dialogFullHeight),"dialogWidth"in t.options&&t.options.dialogWidth&&w(t.options.dialogWidth),"isModalFullscreen"in t.options&&vf(!!t.options.isModalFullscreen)});const v=B.useMemo(()=>({mode:u,entryType:o,status:d,previousComponentType:P||"dialog",dialogPosition:p,isDialogFullHeight:T,dialogWidth:_,isModalFullscreen:C}),[u,o,d,P,p,T,_,C]);return x.jsx(_1.Provider,{value:v,children:r})},sr=()=>{const e=B.useContext(_1);if(!e)throw new Error("useUIState must be used within a UIStateProvider");return e},S1=B.createContext(null),x1=B.createContext(null),Pf=()=>{const e=B.useContext(x1);if(!e)throw new Error("usePromptsExtensionDispatch must be used within a PromptsExtensionProvider");return e||{}},li=()=>{const e=B.useContext(S1);if(!e)throw new Error("usePromptsExtensionState must be used within a PromptsExtensionProvider");return e||{}},Ko=()=>{const e=B.useContext(og);if(!e)throw new Error("useCopilotDispatch must be used within a CopilotProvider");return e},ar=()=>{const e=B.useContext(ig);if(!e)throw new Error("useCopilotState must be used within a CopilotProvider");return e},kk=({copilot:e})=>{const{logger:t,conversationHistory:n}=rt(),{isInline:r}=li(),{addCopilotEvent:o,setConversationHistoryLoaded:a}=Ko(),{activeConversationId:u}=ar(),c=B.useCallback(f=>{e&&e.requestSessionInformation(p=>{t==null||t.log("Retrieved session information: ",p),f==null||f(p)})},[e,t]),d=B.useCallback((f,p)=>{e&&f.conversationId&&e.getConversationEvents(f,m=>{t==null||t.log("Retrieved conversation messages: ",m),p==null||p(m)})},[e,t]);return B.useEffect(()=>{if(r||!u)return;if(n.sinceHours===0||(n==null?void 0:n.limit)===0){a(!0);return}const f=3600*1e3*n.sinceHours,p=new Date(Date.now()-f).toISOString(),m={conversationId:u,since:p,excludeEvents:["done","error","connection_error","refined_browse","refined_search","conversation_reset"]};typeof n.limit=="number"&&(m.limit=n.limit),d(m,T=>{const y=[];[...T.reverse()||[]].forEach(w=>{var A;const C=T.find(P=>P.id===w.eventSourceId);(A=C==null?void 0:C.name)!=null&&A.endsWith("_suggestions")||(w.bypassHandlers=!0,y.unshift(w))}),y.forEach(w=>{o(w)}),a(!0)})},[t,r,u,d,o,a,n]),{getSessionInformation:c,getConversationMessages:d}},w1=B.createContext({copilot:null,messages:[],groupedMessages:[],isLoading:!1,isResponseLoading:()=>!1,handleAskCim:()=>{},handleSearch:()=>{},handleBrowse:()=>{},handlePdp:()=>{},handleSuggestion:()=>{},handleUserInput:()=>{},handleCancel:()=>{},resetConversation:()=>{},getSessionInformation:()=>{},getConversationMessages:()=>{}}),Pk=({apiKey:e,apiToken:t,baseUrl:n,customerId:r,tenantId:o,isDevelopment:a,onConnect:u,onRefinedSearch:c,onRefinedBrowse:d,children:f})=>{const{logger:p,clientContext:m,baseCatalogParams:T}=rt(),cn=xk(),{searchQuery:y}=cn,_=mn(cn,["searchQuery"]),Hn=Tk(),{categoryId:w}=Hn,C=mn(Hn,["categoryId"]),{productId:A,pdpLink:P}=vk(),{setCopilot:v,setConnected:H,resetCopilot:Y,resetCopilotState:D,addCopilotEvent:q,removeLoadingMessage:re,handleCopilotRequestAck:me,setActiveConversationId:V,setConversationIds:oe,setAskCimPrompts:ce}=Ko(),{connected:de,copilot:ne,messages:Te,groupedMessages:Pe,loadingMessages:se,askCimPrompts:K}=ar(),{status:ie,entryType:k}=sr(),{isInline:L}=li(),{getConversationMessages:ee,getSessionInformation:I}=kk({copilot:ne}),Se=B.useMemo(()=>se.size>0,[se]),je=B.useCallback(Ae=>se.has(Ae),[se]),Ee=B.useCallback(({query:Ae,facetFilters:Oe,rangeFilters:Me,catalogSegment:ot,pricebooks:pt,userPrompt:J,imageFile:ge})=>{if(!ne){p==null||p.error("Copilot is not initialized");return}if(!Ae)return;const Ce={searchParams:{query:Ae}};J&&(Ce.userPrompt=J),ge&&(Ce.attachments={image:ge}),Oe&&Object.keys(Oe).length>0&&(Ce.searchParams.facetFilters=Oe),Me&&Me.length>0&&(Ce.searchParams.rangeFilters=Me),ot&&(Ce.searchParams.catalogSegment=ot),pt&&(Ce.searchParams.pricebooks=pt),m&&(Ce.clientContext=m),Ta("search"),ne.search(Ce,qe=>{const Re=F({},qe);me(Re)})},[p,me,ne,m]),Fe=B.useCallback(({categoryId:Ae,categoryName:Oe,facetFilters:Me,rangeFilters:ot,catalogSegment:pt,pricebooks:J,userPrompt:ge,imageFile:Ce})=>{if(!ne){p==null||p.error("Copilot is not initialized");return}const qe=Me&&Object.keys(Me).length>0;if(Ae===""&&!qe){p==null||p.error("Browse event must include facetFilters when categoryId is empty");return}const Re={browseParams:{categoryId:Ae||""}};ge&&(Re.userPrompt=ge),Ce&&(Re.attachments={image:Ce}),qe&&(Re.browseParams.facetFilters=Me),ot&&ot.length>0&&(Re.browseParams.rangeFilters=ot),pt&&(Re.browseParams.catalogSegment=pt),Array.isArray(J)&&J.length>0&&(Re.browseParams.pricebooks=J),(m||Oe)&&(Re.clientContext={},m&&(Re.clientContext=F({},m)),Oe&&(Re.clientContext.cimLabel=Oe)),Ta("browse"),ne.browse(Re,dt=>{var Qr;const Gt=F({},dt),$t=((Qr=Gt.request)==null?void 0:Qr.clientContext)||{},dn=($t==null?void 0:$t.cimLabel)||Oe;dn&&Gt.request&&(Gt.request.label=dn),me(Gt)})},[p,me,ne,m]),$e=B.useCallback(({productId:Ae,productName:Oe,pdpLink:Me,userPrompt:ot,imageFile:pt})=>{if(!ne){p==null||p.error("Copilot is not initialized");return}if(!Ae)return;const J={productId:Ae};ot&&(J.userPrompt=ot),Me&&(J.pdpLink=Me),pt&&(J.attachments={image:pt}),(m||Oe)&&(J.clientContext={},m&&(J.clientContext=F({},m)),Oe&&(J.clientContext.cimLabel=Oe)),T&&(J.baseCatalogParams=T),Ta("pdp"),ne.productView(J,ge=>{var dt;const Ce=F({},ge),qe=((dt=Ce.request)==null?void 0:dt.clientContext)||{},Re=(qe==null?void 0:qe.cimLabel)||Oe;Re&&Ce.request&&(Ce.request.label=Re),me(Ce)})},[p,ne,me,m,T]),Ge=B.useCallback(({userPrompt:Ae,imageFile:Oe})=>{if(!ne){p==null||p.error("Copilot is not initialized");return}if(!Ae)return;const Me={userPrompt:Ae};Oe&&(Me.attachments={image:Oe}),m&&(Me.clientContext=m),T&&(Me.baseCatalogParams=T),ne.askCim(Me,ot=>{const pt=F({},ot);me(pt)})},[p,ne,me,m,T]),_t=B.useCallback(Ae=>{q(Ae),c==null||c(Ae)},[q,c]),Nn=B.useCallback(Ae=>{q(Ae),d==null||d(Ae)},[q,d]),ln=B.useCallback(Ae=>{u==null||u(Ae),H(!0)},[u,H]);B.useEffect(()=>{!ne||!de||!ie.isOpen||yn.size>0&&yn.processQueue(Ae=>{if(Ae.context==="search"){const Oe=F({},Ae.payload);E1(Oe)}if(Ae.context==="browse"){const Oe=F({},Ae.payload);l1(Oe)}if(Ae.context==="pdp"){const Oe=F({},Ae.payload);c1(Oe)}})},[ie.isOpen,ne,de]);const Cr=B.useCallback(Ae=>{const Oe=Me=>{const ot=pe(F({},Me),{id:Me.inquiryLinkId||Me.id});q(ot)};Ae.on("connect_ack",ln),Ae.on("partial_inquiry",Oe),Ae.on("display_products",q),Ae.on("progress",q),Ae.on("refined_search",_t),Ae.on("refined_browse",Nn),Ae.on("done",Me=>{re(Me.eventSourceId)}),Ae.on("error",Me=>{q(Me),re(Me.eventSourceId)}),Ae.onDisconnect(Me=>{const ot=["io server disconnect","transport error","server shutting down"];if(p==null||p.log("Connection disconnected with reason: ",Me),!ot.includes(Me)){H(!1);return}p==null||p.log("De-registering event listeners");const pt=new Date().toISOString();q({name:"error",message:"Connection was lost. Please try again.",createdAt:pt,id:`error-${pt}`,sessionId:"session"}),Ae.off()})},[p,H,re,_t,Nn,q,ln]);B.useEffect(()=>{if(!ne)return;const Ae=Oe=>{if(!L){if(!Oe.message&&Oe.eventSourceId&&Oe.eventSourceId===K.requestId){ce({requestId:Oe.eventSourceId,message:Oe});return}q(Oe)}};return ne.on("follow_up",Ae),()=>{ne.off("follow_up",Ae)}},[ne,Te,K.requestId,L,q,ce]),B.useEffect(()=>{if(!ne)return;const Ae=Oe=>{if(L)return;const Me=pe(F({},Oe),{id:Oe.inquiryLinkId||Oe.id});q(Me)};return ne.on("inquiry",Ae),()=>{ne.off("inquiry",Ae)}},[ne,L,q]),_a(()=>{let Ae;n?Ae=n:Ae=a?"https://staging.copilot.search.cimulate.ai":"https://prod.copilot.search.cimulate.ai";const Oe={baseUrl:Ae};e?Oe.apiKey=e:t&&(Oe.apiToken=t),r&&(Oe.customerId=r),o&&(Oe.tenantId=o);const Me=new fA(Oe);return v(Me),Cr(Me),Me.connect(),Me.requestSessionInformation(ot=>{p==null||p.log("Session Information: ",ot);const{activeConversationId:pt,conversationIds:J}=ot.data||{};pt&&V(pt),J!=null&&J.length&&oe(J)}),()=>{Me.disconnect(),Me.off(),Y()}});const fr=B.useCallback(Ae=>{if(!ne)return;const Oe={eventId:Ae,reason:"User cancelled the request"};ne.cancelRequest(Oe,Me=>{q(Me),re(Ae)})},[q,re,ne]),nn=B.useCallback(()=>{ne&&ne.conversationReset({},Ae=>{D(),q(Ae),ne.requestSessionInformation(Oe=>{p==null||p.log("Session Information: ",Oe);const{activeConversationId:Me,conversationIds:ot}=Oe.data||{};Me&&V(Me),ot!=null&&ot.length&&oe(ot)})})},[ne,p,q,D,V,oe]),Ve=B.useCallback((Ae,Oe)=>{if(!Ae)return;const Me={userPrompt:Ae};switch(Oe&&(Me.imageFile=Oe),k){case"ask_cim":Ge(Me);return;case"search":y?Ee(F(F({query:y},_),Me)):Ge(Me);return;case"browse":Fe(F(F({categoryId:w},C),Me));return;case"pdp":A?$e(F({productId:A,pdpLink:P||""},Me)):Ge(Me);return}},[k,y,_,Ee,Ge,w,C,Fe,$e,A,P]),Pt=B.useCallback((Ae,Oe)=>{var ge,Ce,qe;const ot=Ae.params.userPrompt||"";if(!ot)return;const pt=Te.find(Re=>Re.id===Oe);if(!pt)return;const J=pt.name.replace("_suggestions","");if(J==="ask_cim"){Ge({userPrompt:ot});return}if(J==="copilot_search"){const Re=((ge=pt.request)==null?void 0:ge.searchParams)||{},Gt=Re.query===y;Ee(pe(F({query:Re.query||y},Gt?_:{}),{userPrompt:ot}));return}if(J==="copilot_browse"){const Re=pt.request,dt=Re.browseParams||{},$t=dt.categoryId===w,dn=((Ce=Re.clientContext)==null?void 0:Ce.cimLabel)||"";Fe(pe(F({categoryId:dt.categoryId||w||""},$t?C:{}),{categoryName:dn,userPrompt:ot}));return}if(J==="product_view"){const Re=pt.request||{},dt=Re.productId,Gt=dt===A,$t=((qe=Re.clientContext)==null?void 0:qe.cimLabel)||"";let dn="";Gt?dn=P||"":dn=Re.pdpLink||"",$e({productId:dt||A,pdpLink:dn,productName:$t,userPrompt:ot})}},[Te,y,_,Ee,Ge,w,C,Fe,$e,A,P]),On=B.useMemo(()=>({copilot:ne,messages:Te,groupedMessages:Pe,isLoading:Se,isResponseLoading:je,handleAskCim:Ge,handleSearch:Ee,handleBrowse:Fe,handlePdp:$e,handleUserInput:Ve,handleSuggestion:Pt,handleCancel:fr,resetConversation:nn,getSessionInformation:I,getConversationMessages:ee}),[ne,Te,Pe,Se,je,Ge,Ee,Fe,$e,Ve,Pt,fr,nn,I,ee]);return x.jsx(w1.Provider,{value:On,children:f})},A1=()=>{const{copilot:e}=ar(),{addCopilotEvent:t}=Ko();return{getCopilotSuggestions:B.useCallback((r,o,a)=>{if(!e||!o||!r)return;const u=c=>{t(c),a(c)};switch(o){case"ask_cim":e.askCimSuggestions(r,u);break;case"search":e.searchSuggestions({searchParams:r},u);break;case"browse":e.browseSuggestions({browseParams:r},u);break;case"pdp":e.productViewSuggestions({productId:r.productId},u);break}},[e,t])}},Ur=()=>{const e=B.useContext(w1);if(!e)throw new Error("useCopilot must be used within a CopilotProvider");return e},Nk=()=>{const{copilot:e,activeConversationId:t,askCimPrompts:n,conversationHistoryLoaded:r}=ar(),{entryType:o}=sr(),{resetCopilotState:a,addCopilotEvent:u,setAskCimPrompts:c}=Ko(),{handleSearch:d,handleBrowse:f,handlePdp:p,resetConversation:m,getSessionInformation:T,getConversationMessages:y}=Ur(),{getCopilotSuggestions:_}=A1();B.useEffect(()=>{!e||!o||!t||!r||n.requestId||o==="ask_cim"&&_({},o,P=>{c({requestId:P.id,message:null})})},[e,t,n.requestId,o,r,_,c]);const w=B.useCallback(({query:P})=>{if(!e||!P)return;const{facetFilters:v}=Tt.facetFiltersProxy,{rangeFilters:H}=Tt.rangeFiltersProxy,{catalogSegment:Y}=Tt.catalogSegmentProxy,{pricebooks:D}=Tt.pricebooksProxy,q={query:P};q.facetFilters=v||{},q.rangeFilters=H||[],q.catalogSegment=Y||"",q.pricebooks=D||[],d(F({},q))},[e,d]),C=B.useCallback(({categoryId:P})=>{if(!e)return;const v=ct.categoryIdProxy.categoryName,{facetFilters:H}=ct.facetFiltersProxy,{rangeFilters:Y}=ct.rangeFiltersProxy,{catalogSegment:D}=ct.catalogSegmentProxy,{pricebooks:q}=ct.pricebooksProxy,re={categoryId:P};re.categoryName=v||"",re.facetFilters=H||{},re.rangeFilters=Y||[],re.catalogSegment=D||"",re.pricebooks=q||[],f(F({},re))},[e,f]),A=B.useCallback(({productId:P})=>{if(!e||!P)return;const v={productId:P,pdpLink:_r.pdpLink,productName:_r.proxy.productName||""};p(v)},[e,p]);return B.useEffect(()=>{const P=({detail:v})=>{(v==null?void 0:v.property)==="query"&&w({query:v.value})};return Wg(P),()=>{Gg(P)}},[w]),B.useEffect(()=>{const P=({detail:v})=>{if((v==null?void 0:v.property)==="pdp-context"){const H=v.value;A({productId:H.productId});return}(v==null?void 0:v.property)==="productId"&&A({productId:v.value})};return Qg(P),()=>{Jg(P)}},[A]),B.useEffect(()=>{const P=({detail:v})=>{(v==null?void 0:v.property)==="categoryId"&&C({categoryId:v.value})};return Xg(P),()=>{Kg(P)}},[C]),B.useEffect(()=>{const P=({detail:v})=>{if((v==null?void 0:v.event)==Ci.RESET_CONVERSATION&&m(),(v==null?void 0:v.event)==Ci.GET_SESSION_INFORMATION){const H=v.value.callback;T(H)}if((v==null?void 0:v.event)==Ci.GET_CONVERSATION_MESSAGES){const{payload:H,callback:Y}=v.value;if(!H.conversationId||typeof Y!="function")return;y(H,Y)}if((v==null?void 0:v.event)==Ci.LOAD_CONVERSATION){const H=v.value;if(!H.conversationId)return;y(H,D=>{a(),D.forEach(q=>{u(q)})})}};return YC(P),()=>{WC(P)}},[m,T,y,a,u]),null},Ok=({apiKey:e,apiToken:t,baseUrl:n,customerId:r,tenantId:o,isDevelopment:a,onConnect:u,onRefinedSearch:c,onRefinedBrowse:d,children:f})=>x.jsxs(Pk,{apiKey:e,apiToken:t,baseUrl:n,customerId:r,tenantId:o,isDevelopment:a,onConnect:u,onRefinedSearch:c,onRefinedBrowse:d,children:[x.jsx(Nk,{}),f]}),Ik=({children:e,dispatch:t})=>{const n=B.useCallback(_=>{t({type:gt.SET_PROMPTS_EXTENSION_INITIALIZED,payload:_})},[t]),r=B.useCallback(_=>{t({type:gt.SET_PROMPTS_EXTENSION_OPEN,payload:_})},[t]),o=B.useCallback(_=>{t({type:gt.SET_PROMPTS_EXTENSION_INLINE,payload:_})},[t]),a=B.useCallback(_=>{t({type:gt.SET_PROMPTS_EXTENSION_ELEMENT_ID,payload:_})},[t]),u=B.useCallback(_=>{t({type:gt.SET_PROMPTS_EXTENSION_ENTRY_TYPE,payload:_})},[t]),c=B.useCallback(_=>{t({type:gt.SET_PROMPTS_EXTENSION_ACTIVE_PROMPTS_ID,payload:_})},[t]),d=B.useCallback(_=>{t({type:gt.SET_PROMPTS_EXTENSION_USER_PROMPT,payload:_})},[t]),f=B.useCallback(_=>{t({type:gt.SET_PROMPTS_EXTENSION_PARAMS,payload:_})},[t]),p=B.useCallback(_=>{t({type:gt.SET_PROMPTS_EXTENSION_PROMPTS_MESSAGE,payload:_})},[t]),m=B.useCallback(_=>{t({type:gt.SET_PROMPTS_EXTENSION_RESPONSE_MESSAGE,payload:_})},[t]),T=B.useCallback(_=>{t({type:gt.SET_PROMPTS_EXTENSION_RESPONSE_LOADING,payload:_})},[t]),y=B.useMemo(()=>({setIsInitialized:n,setIsOpen:r,setIsInline:o,setElementId:a,setEntryType:u,setActivePromptsId:c,setUserPrompt:d,setParams:f,setPromptsMessage:p,setResponseMessage:m,setIsResponseLoading:T}),[n,r,o,a,u,c,d,f,p,m,T]);return x.jsx(x1.Provider,{value:y,children:e})},Rk=(e,t)=>{const{type:n,payload:r}=t;switch(n){case gt.SET_PROMPTS_EXTENSION_INITIALIZED:e.isInitialized=r;break;case gt.SET_PROMPTS_EXTENSION_OPEN:e.isOpen=r;break;case gt.SET_PROMPTS_EXTENSION_INLINE:e.isInline=r;break;case gt.SET_PROMPTS_EXTENSION_ELEMENT_ID:e.elementId=r;break;case gt.SET_PROMPTS_EXTENSION_ENTRY_TYPE:e.entryType=r;break;case gt.SET_PROMPTS_EXTENSION_PARAMS:e.params=r;break;case gt.RESET_PROMPTS_EXTENSION_PARAMS:e.params=null;break;case gt.SET_PROMPTS_EXTENSION_USER_PROMPT:e.userPrompt=r;break;case gt.SET_PROMPTS_EXTENSION_ACTIVE_PROMPTS_ID:e.activePromptsId=r;break;case gt.RESET_PROMPTS_EXTENSION_ACTIVE_PROMPTS_ID:e.activePromptsId=null;break;case gt.SET_PROMPTS_EXTENSION_PROMPTS_MESSAGE:e.promptsMessage=r;break;case gt.RESET_PROMPTS_EXTENSION_PROMPTS_MESSAGE:e.promptsMessage=null;break;case gt.SET_PROMPTS_EXTENSION_RESPONSE_MESSAGE:e.responseMessage=r;break;case gt.RESET_PROMPTS_EXTENSION_RESPONSE_MESSAGE:e.responseMessage=null;break;case gt.SET_PROMPTS_EXTENSION_RESPONSE_LOADING:e.isResponseLoading=r;break}},Lk=({promptsConfig:e,children:t})=>{const[n,r]=ng(Rk,F(F({},d1),e||{}));return x.jsx(S1.Provider,{value:n,children:x.jsx(Ik,{dispatch:r,children:t})})},v1=({mode:e,apiKey:t,apiToken:n,baseUrl:r,customerId:o,tenantId:a,logoUrl:u,headerText:c,headerConfig:d,theme:f,openLinksInNewTab:p,globalClassName:m,isDevelopment:T=!1,componentType:y,componentConfig:_,entryType:w,entryMessage:C,disclaimerText:A,disclaimerMarkdown:P,clientContext:v,baseCatalogParams:H,searchPlaceholder:Y,searchButtonLabel:D,searchConfig:q,suggestionButtonConfig:re,messageAlignment:me,autoScroll:V,promptsConfig:oe,resetConversationMessage:ce,conversationHistory:de,onConnect:ne,onCopilotEvent:Te,onRefinedSearch:Pe,onRefinedBrowse:se,__features:K,children:ie})=>x.jsx(AC,{mode:e,baseUrl:r,apiKey:t,apiToken:n,customerId:o,tenantId:a,logoUrl:u,headerText:c,headerConfig:d,entryMessage:C,theme:f,globalClassName:m,openLinksInNewTab:p,searchPlaceholder:Y,searchButtonLabel:D,searchConfig:q,suggestionButtonConfig:re,messageAlignment:me,autoScroll:V,componentConfig:_,clientContext:v,baseCatalogParams:H,disclaimerMarkdown:P,disclaimerText:A,resetConversationMessage:ce,conversationHistory:de,isDevelopment:T,__features:K,children:x.jsx(Ck,{entryType:w,componentConfig:_,componentType:y,children:x.jsx(LC,{onCopilotEvent:Te,children:x.jsx(Ak,{children:x.jsx(bk,{children:x.jsx(Sk,{children:x.jsx(Lk,{promptsConfig:oe,children:x.jsx(Ok,{apiKey:t,apiToken:n,baseUrl:r,customerId:o,tenantId:a,isDevelopment:T,entryType:w,onConnect:ne,onRefinedSearch:Pe,onRefinedBrowse:se,onCopilotEvent:Te,children:ie})})})})})})})});var Nf={exports:{}},Dn={},Of={exports:{}},If={};var C1;function Dk(){return C1||(C1=1,(function(e){function t(K,ie){var k=K.length;K.push(ie);e:for(;0<k;){var L=k-1>>>1,ee=K[L];if(0<o(ee,ie))K[L]=ie,K[k]=ee,k=L;else break e}}function n(K){return K.length===0?null:K[0]}function r(K){if(K.length===0)return null;var ie=K[0],k=K.pop();if(k!==ie){K[0]=k;e:for(var L=0,ee=K.length,I=ee>>>1;L<I;){var Se=2*(L+1)-1,je=K[Se],Ee=Se+1,Fe=K[Ee];if(0>o(je,k))Ee<ee&&0>o(Fe,je)?(K[L]=Fe,K[Ee]=k,L=Ee):(K[L]=je,K[Se]=k,L=Se);else if(Ee<ee&&0>o(Fe,k))K[L]=Fe,K[Ee]=k,L=Ee;else break e}}return ie}function o(K,ie){var k=K.sortIndex-ie.sortIndex;return k!==0?k:K.id-ie.id}if(typeof performance=="object"&&typeof performance.now=="function"){var a=performance;e.unstable_now=function(){return a.now()}}else{var u=Date,c=u.now();e.unstable_now=function(){return u.now()-c}}var d=[],f=[],p=1,m=null,T=3,y=!1,_=!1,w=!1,C=typeof setTimeout=="function"?setTimeout:null,A=typeof clearTimeout=="function"?clearTimeout:null,P=typeof setImmediate!="undefined"?setImmediate:null;typeof navigator!="undefined"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function v(K){for(var ie=n(f);ie!==null;){if(ie.callback===null)r(f);else if(ie.startTime<=K)r(f),ie.sortIndex=ie.expirationTime,t(d,ie);else break;ie=n(f)}}function H(K){if(w=!1,v(K),!_)if(n(d)!==null)_=!0,Pe(Y);else{var ie=n(f);ie!==null&&se(H,ie.startTime-K)}}function Y(K,ie){_=!1,w&&(w=!1,A(re),re=-1),y=!0;var k=T;try{for(v(ie),m=n(d);m!==null&&(!(m.expirationTime>ie)||K&&!oe());){var L=m.callback;if(typeof L=="function"){m.callback=null,T=m.priorityLevel;var ee=L(m.expirationTime<=ie);ie=e.unstable_now(),typeof ee=="function"?m.callback=ee:m===n(d)&&r(d),v(ie)}else r(d);m=n(d)}if(m!==null)var I=!0;else{var Se=n(f);Se!==null&&se(H,Se.startTime-ie),I=!1}return I}finally{m=null,T=k,y=!1}}var D=!1,q=null,re=-1,me=5,V=-1;function oe(){return!(e.unstable_now()-V<me)}function ce(){if(q!==null){var K=e.unstable_now();V=K;var ie=!0;try{ie=q(!0,K)}finally{ie?de():(D=!1,q=null)}}else D=!1}var de;if(typeof P=="function")de=function(){P(ce)};else if(typeof MessageChannel!="undefined"){var ne=new MessageChannel,Te=ne.port2;ne.port1.onmessage=ce,de=function(){Te.postMessage(null)}}else de=function(){C(ce,0)};function Pe(K){q=K,D||(D=!0,de())}function se(K,ie){re=C(function(){K(e.unstable_now())},ie)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(K){K.callback=null},e.unstable_continueExecution=function(){_||y||(_=!0,Pe(Y))},e.unstable_forceFrameRate=function(K){0>K||125<K?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):me=0<K?Math.floor(1e3/K):5},e.unstable_getCurrentPriorityLevel=function(){return T},e.unstable_getFirstCallbackNode=function(){return n(d)},e.unstable_next=function(K){switch(T){case 1:case 2:case 3:var ie=3;break;default:ie=T}var k=T;T=ie;try{return K()}finally{T=k}},e.unstable_pauseExecution=function(){},e.unstable_requestPaint=function(){},e.unstable_runWithPriority=function(K,ie){switch(K){case 1:case 2:case 3:case 4:case 5:break;default:K=3}var k=T;T=K;try{return ie()}finally{T=k}},e.unstable_scheduleCallback=function(K,ie,k){var L=e.unstable_now();switch(typeof k=="object"&&k!==null?(k=k.delay,k=typeof k=="number"&&0<k?L+k:L):k=L,K){case 1:var ee=-1;break;case 2:ee=250;break;case 5:ee=1073741823;break;case 4:ee=1e4;break;default:ee=5e3}return ee=k+ee,K={id:p++,callback:ie,priorityLevel:K,startTime:k,expirationTime:ee,sortIndex:-1},k>L?(K.sortIndex=k,t(f,K),n(d)===null&&K===n(f)&&(w?(A(re),re=-1):w=!0,se(H,k-L))):(K.sortIndex=ee,t(d,K),_||y||(_=!0,Pe(Y))),K},e.unstable_shouldYield=oe,e.unstable_wrapCallback=function(K){var ie=T;return function(){var k=T;T=ie;try{return K.apply(this,arguments)}finally{T=k}}}})(If)),If}var k1;function Mk(){return k1||(k1=1,Of.exports=Dk()),Of.exports}var P1;function Fk(){if(P1)return Dn;P1=1;var e=Cn(),t=Mk();function n(i){for(var s="https://reactjs.org/docs/error-decoder.html?invariant="+i,l=1;l<arguments.length;l++)s+="&args[]="+encodeURIComponent(arguments[l]);return"Minified React error #"+i+"; visit "+s+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}var r=new Set,o={};function a(i,s){u(i,s),u(i+"Capture",s)}function u(i,s){for(o[i]=s,i=0;i<s.length;i++)r.add(s[i])}var c=!(typeof window=="undefined"||typeof window.document=="undefined"||typeof window.document.createElement=="undefined"),d=Object.prototype.hasOwnProperty,f=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,p={},m={};function T(i){return d.call(m,i)?!0:d.call(p,i)?!1:f.test(i)?m[i]=!0:(p[i]=!0,!1)}function y(i,s,l,h){if(l!==null&&l.type===0)return!1;switch(typeof s){case"function":case"symbol":return!0;case"boolean":return h?!1:l!==null?!l.acceptsBooleans:(i=i.toLowerCase().slice(0,5),i!=="data-"&&i!=="aria-");default:return!1}}function _(i,s,l,h){if(s===null||typeof s=="undefined"||y(i,s,l,h))return!0;if(h)return!1;if(l!==null)switch(l.type){case 3:return!s;case 4:return s===!1;case 5:return isNaN(s);case 6:return isNaN(s)||1>s}return!1}function w(i,s,l,h,E,b,S){this.acceptsBooleans=s===2||s===3||s===4,this.attributeName=h,this.attributeNamespace=E,this.mustUseProperty=l,this.propertyName=i,this.type=s,this.sanitizeURL=b,this.removeEmptyString=S}var C={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(i){C[i]=new w(i,0,!1,i,null,!1,!1)}),[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(i){var s=i[0];C[s]=new w(s,1,!1,i[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(i){C[i]=new w(i,2,!1,i.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(i){C[i]=new w(i,2,!1,i,null,!1,!1)}),"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(i){C[i]=new w(i,3,!1,i.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(i){C[i]=new w(i,3,!0,i,null,!1,!1)}),["capture","download"].forEach(function(i){C[i]=new w(i,4,!1,i,null,!1,!1)}),["cols","rows","size","span"].forEach(function(i){C[i]=new w(i,6,!1,i,null,!1,!1)}),["rowSpan","start"].forEach(function(i){C[i]=new w(i,5,!1,i.toLowerCase(),null,!1,!1)});var A=/[\-:]([a-z])/g;function P(i){return i[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(i){var s=i.replace(A,P);C[s]=new w(s,1,!1,i,null,!1,!1)}),"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(i){var s=i.replace(A,P);C[s]=new w(s,1,!1,i,"http://www.w3.org/1999/xlink",!1,!1)}),["xml:base","xml:lang","xml:space"].forEach(function(i){var s=i.replace(A,P);C[s]=new w(s,1,!1,i,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(function(i){C[i]=new w(i,1,!1,i.toLowerCase(),null,!1,!1)}),C.xlinkHref=new w("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach(function(i){C[i]=new w(i,1,!1,i.toLowerCase(),null,!0,!0)});function v(i,s,l,h){var E=C.hasOwnProperty(s)?C[s]:null;(E!==null?E.type!==0:h||!(2<s.length)||s[0]!=="o"&&s[0]!=="O"||s[1]!=="n"&&s[1]!=="N")&&(_(s,l,E,h)&&(l=null),h||E===null?T(s)&&(l===null?i.removeAttribute(s):i.setAttribute(s,""+l)):E.mustUseProperty?i[E.propertyName]=l===null?E.type===3?!1:"":l:(s=E.attributeName,h=E.attributeNamespace,l===null?i.removeAttribute(s):(E=E.type,l=E===3||E===4&&l===!0?"":""+l,h?i.setAttributeNS(h,s,l):i.setAttribute(s,l))))}var H=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,Y=Symbol.for("react.element"),D=Symbol.for("react.portal"),q=Symbol.for("react.fragment"),re=Symbol.for("react.strict_mode"),me=Symbol.for("react.profiler"),V=Symbol.for("react.provider"),oe=Symbol.for("react.context"),ce=Symbol.for("react.forward_ref"),de=Symbol.for("react.suspense"),ne=Symbol.for("react.suspense_list"),Te=Symbol.for("react.memo"),Pe=Symbol.for("react.lazy"),se=Symbol.for("react.offscreen"),K=Symbol.iterator;function ie(i){return i===null||typeof i!="object"?null:(i=K&&i[K]||i["@@iterator"],typeof i=="function"?i:null)}var k=Object.assign,L;function ee(i){if(L===void 0)try{throw Error()}catch(l){var s=l.stack.trim().match(/\n( *(at )?)/);L=s&&s[1]||""}return`
11
11
  `+L+i}var I=!1;function Se(i,s){if(!i||I)return"";I=!0;var l=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{if(s)if(s=function(){throw Error()},Object.defineProperty(s.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(s,[])}catch(Z){var h=Z}Reflect.construct(i,[],s)}else{try{s.call()}catch(Z){h=Z}i.call(s.prototype)}else{try{throw Error()}catch(Z){h=Z}i()}}catch(Z){if(Z&&h&&typeof Z.stack=="string"){for(var E=Z.stack.split(`
12
12
  `),b=h.stack.split(`
13
13
  `),S=E.length-1,R=b.length-1;1<=S&&0<=R&&E[S]!==b[R];)R--;for(;1<=S&&0<=R;S--,R--)if(E[S]!==b[R]){if(S!==1||R!==1)do if(S--,R--,0>R||E[S]!==b[R]){var U=`
@@ -6217,7 +6217,7 @@ const xk = {
6217
6217
  __features: se,
6218
6218
  routingAttributes: ce,
6219
6219
  enableDownloadTranscript: fe = !0,
6220
- enableEscalationToAgent: ne = !0,
6220
+ enableEscalationToAgent: ne = !1,
6221
6221
  children: be
6222
6222
  }) => {
6223
6223
  const ke = e === "messaging", oe = B.useMemo(() => {
@@ -7,7 +7,7 @@
7
7
  `);return u===-1?"":o.stack.slice(u+1)})();try{if(!r.stack)r.stack=a;else if(a){const u=a.indexOf(`
8
8
  `),c=u===-1?-1:a.indexOf(`
9
9
  `,u+1),d=c===-1?"":a.slice(c+1);String(r.stack).endsWith(d)||(r.stack+=`
10
- `+a)}}catch(u){}}throw r}})}_request(t,n){typeof t=="string"?(n=n||{},n.url=t):n=t||{},n=so(this.defaults,n);const{transitional:r,paramsSerializer:o,headers:a}=n;r!==void 0&&ml.assertOptions(r,{silentJSONParsing:En.transitional(En.boolean),forcedJSONParsing:En.transitional(En.boolean),clarifyTimeoutError:En.transitional(En.boolean),legacyInterceptorReqResOrdering:En.transitional(En.boolean),advertiseZstdAcceptEncoding:En.transitional(En.boolean),validateStatusUndefinedResolves:En.transitional(En.boolean)},!1),o!=null&&($.isFunction(o)?n.paramsSerializer={serialize:o}:ml.assertOptions(o,{encode:En.function,serialize:En.function},!0)),n.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?n.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:n.allowAbsoluteUrls=!0),ml.assertOptions(n,{baseUrl:En.spelling("baseURL"),withXsrfToken:En.spelling("withXSRFToken")},!0),n.method=(n.method||this.defaults.method||"get").toLowerCase();let u=a&&$.merge(a.common,a[n.method]);a&&$.forEach(["delete","get","head","post","put","patch","query","common"],_=>{delete a[_]}),n.headers=gn.concat(u,a);const c=[];let d=!0;this.interceptors.request.forEach(function(w){if(typeof w.runWhen=="function"&&w.runWhen(n)===!1)return;d=d&&w.synchronous;const C=n.transitional||yf;C&&C.legacyInterceptorReqResOrdering?c.unshift(w.fulfilled,w.rejected):c.push(w.fulfilled,w.rejected)});const f=[];this.interceptors.response.forEach(function(w){f.push(w.fulfilled,w.rejected)});let p,m=0,T;if(!d){const _=[$g.bind(this),void 0];for(_.unshift(...c),_.push(...f),T=_.length,p=Promise.resolve(n);m<T;)p=p.then(_[m++],_[m++]);return p}T=c.length;let y=n;for(;m<T;){const _=c[m++],w=c[m++];try{y=_(y)}catch(C){w.call(this,C);break}}try{p=$g.call(this,y)}catch(_){return Promise.reject(_)}for(m=0,T=f.length;m<T;)p=p.then(f[m++],f[m++]);return p}getUri(t){t=so(this.defaults,t);const n=Rg(t.baseURL,t.url,t.allowAbsoluteUrls,t);return xg(n,t.params,t.paramsSerializer)}};$.forEach(["delete","get","head","options"],function(t){ao.prototype[t]=function(n,r){return this.request(so(r||{},{method:t,url:n,data:r&&$.hasOwnProp(r,"data")?r.data:void 0}))}}),$.forEach(["post","put","patch","query"],function(t){function n(r){return function(a,u,c){return this.request(so(c||{},{method:t,headers:r?{"Content-Type":"multipart/form-data"}:{},url:a,data:u}))}}ao.prototype[t]=n(),t!=="query"&&(ao.prototype[t+"Form"]=n(!0))});let bC=class Zw{constructor(t){if(typeof t!="function")throw new TypeError("executor must be a function.");let n;this.promise=new Promise(function(a){n=a});const r=this;this.promise.then(o=>{if(!r._listeners)return;let a=r._listeners.length;for(;a-- >0;)r._listeners[a](o);r._listeners=null}),this.promise.then=o=>{let a;const u=new Promise(c=>{r.subscribe(c),a=c}).then(o);return u.cancel=function(){r.unsubscribe(a)},u},t(function(a,u,c){r.reason||(r.reason=new ba(a,u,c),n(r.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(t){if(this.reason){t(this.reason);return}this._listeners?this._listeners.push(t):this._listeners=[t]}unsubscribe(t){if(!this._listeners)return;const n=this._listeners.indexOf(t);n!==-1&&this._listeners.splice(n,1)}toAbortSignal(){const t=new AbortController,n=r=>{t.abort(r)};return this.subscribe(n),t.signal.unsubscribe=()=>this.unsubscribe(n),t.signal}static source(){let t;return{token:new Zw(function(o){t=o}),cancel:t}}};function TC(e){return function(n){return e.apply(null,n)}}function _C(e){return $.isObject(e)&&e.isAxiosError===!0}const Af={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511,WebServerIsDown:521,ConnectionTimedOut:522,OriginIsUnreachable:523,TimeoutOccurred:524,SslHandshakeFailed:525,InvalidSslCertificate:526};Object.entries(Af).forEach(([e,t])=>{Af[t]=e});function qg(e){const t=new ao(e),n=sg(ao.prototype.request,t);return $.extend(n,ao.prototype,t,{allOwnKeys:!0}),$.extend(n,t,null,{allOwnKeys:!0}),n.create=function(o){return qg(so(e,o))},n}const Mt=qg(ya);Mt.Axios=ao,Mt.CanceledError=ba,Mt.CancelToken=bC,Mt.isCancel=kg,Mt.VERSION=Sf,Mt.toFormData=cl,Mt.AxiosError=xe,Mt.Cancel=Mt.CanceledError,Mt.all=function(t){return Promise.all(t)},Mt.spread=TC,Mt.isAxiosError=_C,Mt.mergeConfig=so,Mt.AxiosHeaders=gn,Mt.formToJSON=e=>Cg($.isHTMLForm(e)?new FormData(e):e),Mt.getAdapter=jg.getAdapter,Mt.HttpStatusCode=Af,Mt.default=Mt;const{Axios:pU,AxiosError:mU,CanceledError:gU,isCancel:EU,CancelToken:yU,VERSION:bU,all:TU,Cancel:_U,isAxiosError:SU,spread:xU,toFormData:wU,AxiosHeaders:AU,HttpStatusCode:vU,formToJSON:CU,getAdapter:kU,mergeConfig:PU,create:NU}=Mt;class SC{constructor(t,n,r,o=!1,a,u){we(this,"CIMULATE_API_HEADER","x-cimulate-api-key");we(this,"CIMULATE_SEARCH_API_HOST","search.cimulate");we(this,"CIMULATE_SEARCH_API_PATH","api/v1");we(this,"baseApiUrl");we(this,"headers",{});we(this,"fetchConfig",()=>Je(this,null,function*(){try{const t=yield Mt.get(`${this.apiUrl}/configs/copilot`,{headers:this.headers}),{customer_config:n}=t.data,r=atob(n);return JSON.parse(r)}catch(t){throw console.error("Error fetching customer config:",t),t}}));we(this,"_mapCopilotUrlToSearchUrl",(t="",n=!1)=>{if(t.endsWith("io")){const o=new URL(t);return o.hostname=o.hostname.replace(/^copilot\./,"api."),o.origin}return n?`https://staging.${this.CIMULATE_SEARCH_API_HOST}.ai`:`https://prod.${this.CIMULATE_SEARCH_API_HOST}.ai`});if(n&&r||!n&&!r)throw new Error("Provide exactly one authentication method: either 'apiKey' or 'apiToken', but not both.");n?this.headers[this.CIMULATE_API_HEADER]=n:r&&(this.headers.Authorization=`Bearer ${r}`),a&&(this.headers["x-cimulate-customer-id"]=a),u&&(this.headers["Tenant-ID"]=u),this.baseApiUrl=this._mapCopilotUrlToSearchUrl(t,o)}get apiUrl(){return`${this.baseApiUrl}/${this.CIMULATE_SEARCH_API_PATH}`}}class xC{constructor(t,n,r,o=!1,a,u){we(this,"apiService");we(this,"config",null);we(this,"getConfig",()=>Je(this,null,function*(){if(this.config)return this.config;try{const t=yield this.apiService.fetchConfig();return this.config=t,this.config}catch(t){throw console.error("Failed to fetch customer config:",t),t}}));we(this,"getPid",t=>this.getProductFieldValue(t,"pidCol"));we(this,"getName",t=>this.getProductFieldValue(t,"nameCol"));we(this,"getDescription",t=>this.getProductFieldValue(t,"description"));we(this,"getBrand",t=>this.getProductFieldValue(t,"productBrandCol"));we(this,"getPrice",t=>this.getProductFieldValue(t,"priceCol"));we(this,"getRelativePdp",t=>this.getProductFieldValue(t,"relativePdpCol"));we(this,"getPdp",t=>this.getProductFieldValue(t,"pdpCol"));we(this,"getImage",t=>this.getProductFieldValue(t,"imageCol"));we(this,"getProductHiddenFields",()=>{const t=this.getProductField("productHiddenFields");return Array.isArray(t)?t:[]});we(this,"getProductField",t=>this.config?this.config[t]:"");we(this,"getProductFieldValue",(t,n)=>{const r=this.getProductField(n);return r&&t[r]||""});this.apiService=new SC(t,n,r,o,a,u)}getPriceDisplay(t){const n=this.getPrice(t);return n?typeof n=="string"?n.includes("$")?n:`$${n}`:typeof n=="number"?new Intl.NumberFormat("en-US",{style:"currency",currency:"USD"}).format(n):n:""}}const Ko=(e,t,n,...r)=>{if(!e)return;const o=["background: linear-gradient(90deg,rgba(253, 99, 99, 1) 0%, rgba(245, 139, 35, 1) 65%)","font-weight: bold","color: transparent","background-clip: text","text-fill-color: transparent"].join(";");console[t]("%c[cimulate-widget]",o,n,...r)};class wC{constructor(t=!1){we(this,"isDevelopment");we(this,"_log",(t,n,...r)=>{Ko(this.isDevelopment,t,n,...r)});this.isDevelopment=t}log(t,...n){this._log("log",t,...n)}warn(t,...n){this._log("warn",t,...n)}error(t,...n){this._log("error",t,...n)}info(t,...n){this._log("info",t,...n)}debug(t,...n){this._log("debug",t,...n)}}const AC={copilot:"Your Search Assistant",messaging:"Commerce Client"},Yg=B.createContext(null),vC=({mode:e,logoUrl:t,headerText:n,headerConfig:r,globalClassName:o="",entryMessage:a,openLinksInNewTab:u=!1,disclaimerText:c,disclaimerMarkdown:d,clientContext:f,baseCatalogParams:p,searchPlaceholder:m,searchButtonLabel:T,searchConfig:y,suggestionButtonConfig:_,messageAlignment:w="start",autoScroll:C=!0,componentConfig:A,conversationHistory:P,resetConversationMessage:v="",apiKey:H,apiToken:Y,baseUrl:D,customerId:q,tenantId:re,theme:me,isDevelopment:V,__features:oe,routingAttributes:ce,enableDownloadTranscript:de=!0,enableEscalationToAgent:ne=!0,children:Te})=>{const Pe=e==="messaging",se=B.useMemo(()=>{const Se=ce==null?void 0:ce.isCartMgmtSupported;return Se===!0||Se==="true"},[ce]),K=B.useMemo(()=>Pe?{config:null}:new xC(D,H,Y,V,q,re),[Pe,D,H,Y,V,q,re]),ie=B.useMemo(()=>new wC(V),[V]);B.useEffect(()=>{Pe||!K||K.config||K.getConfig()},[K,Pe]);const k=B.useMemo(()=>PA(me),[me]),L=B.useMemo(()=>{const Se=(y==null?void 0:y.placeholder)||m,je=(y==null?void 0:y.buttonLabel)||T;let Ee="icon";return y!=null&&y.buttonType?Ee=y.buttonType:T&&(Ee="text"),pe(F({},y||{}),{placeholder:Se,buttonLabel:je,buttonType:Ee})},[y,m,T]),ee=B.useMemo(()=>pe(F({},r||{}),{logoUrl:t||(r==null?void 0:r.logoUrl),headerText:(r==null?void 0:r.headerText)||n||AC[e!=null?e:"copilot"]}),[r,t,n,e]),I=B.useMemo(()=>({configModule:K,mode:e!=null?e:"copilot",headerConfig:ee,entryMessage:a,globalClassName:o,openLinksInNewTab:u,disclaimerText:c,disclaimerMarkdown:d,clientContext:f,baseCatalogParams:p,themeVariables:k,logger:ie,searchConfig:L,suggestionButtonConfig:_,messageAlignment:w,autoScroll:C,enableMinimize:!!(A!=null&&A.enableMinimize),enableDownloadTranscript:de,enableEscalationToAgent:ne,resetConversationMessage:v,conversationHistory:{sinceHours:typeof(P==null?void 0:P.sinceHours)=="number"?P.sinceHours:1,limit:P==null?void 0:P.limit},features:oe,isCartMgmtSupported:se}),[K,e,ee,a,o,f,p,c,d,u,L,_,w,C,A,de,ne,v,ie,k,P,oe,se]);return x.jsx(Yg.Provider,{value:I,children:Te})},rt=()=>{const e=B.useContext(Yg);if(!e)throw new Error("useConfig must be used within a ConfigProvider");return e};class CC{constructor(){we(this,"initialState",{connected:!1,mode:"embedded",entryType:"search",status:{type:"dialog",isOpen:!1,isMinimized:!1},dialog:{position:"bottom-left",isFullHeight:!1,width:""},modal:{isFullscreen:!1}});we(this,"connectedProxy");we(this,"modeProxy");we(this,"entryTypeProxy");we(this,"statusProxy");we(this,"dialogProxy");we(this,"modalProxy",{isFullscreen:!1});we(this,"_fullGet",(t,n)=>Reflect.get(t,n));we(this,"_fullSet",(t,n,r)=>{if(!(n in t))throw new Error(`Property ${n} does not exist on UIState`);return NC(n,r),Reflect.set(t,n,r)});this.connectedProxy=new Proxy({connected:this.initialState.connected},{get:this._fullGet,set:this._fullSet}),this.modeProxy=new Proxy({mode:this.initialState.mode},{get:this._fullGet,set:this._fullSet}),this.entryTypeProxy=new Proxy({entryType:this.initialState.entryType},{get:this._fullGet,set:this._fullSet}),this.statusProxy=new Proxy({type:this.initialState.status.type,isOpen:this.initialState.status.isOpen,isMinimized:this.initialState.status.isMinimized},{get:this._fullGet,set:this._fullSet}),this.dialogProxy=new Proxy({position:this.initialState.dialog.position,isFullHeight:this.initialState.dialog.isFullHeight,width:this.initialState.dialog.width},{get:this._fullGet,set:this._fullSet}),this.modalProxy=new Proxy({isFullscreen:this.initialState.modal.isFullscreen},{get:this._fullGet,set:this._fullSet})}get connected(){return this.connectedProxy.connected}get mode(){return this.modeProxy.mode}get isOpen(){return!!this.statusProxy.isOpen}get isMinimized(){return!!this.statusProxy.isMinimized}get type(){return this.statusProxy.type}get entryType(){return this.entryTypeProxy.entryType}get position(){return this.dialogProxy.position}get state(){return{connected:this.connected,mode:this.mode,entryType:this.entryType,status:{type:this.type,isOpen:this.isOpen,isMinimized:this.isMinimized},dialog:{position:this.position,isFullHeight:this.dialogProxy.isFullHeight,width:this.dialogProxy.width},modal:{isFullscreen:this.modalProxy.isFullscreen}}}}const et=new CC,uo=()=>et.connected,Ta=()=>et.isOpen,kC=e=>{window.addEventListener(uf,e)},PC=e=>{window.removeEventListener(uf,e)},NC=(e,t)=>{const n=new CustomEvent(uf,{detail:{property:e,value:t}});window.dispatchEvent(n)},OC=e=>{et.connectedProxy.connected=e},_a=e=>{if(!["ask_cim","search","browse","pdp"].includes(e))throw new Error(`Invalid entryType: "${e}". Must be 'ask_cim', 'search', 'browse', or 'pdp'.`);et.entryTypeProxy.entryType=e},ui=e=>{const t=et.statusProxy.isOpen,n=typeof e=="boolean"?e:!t;et.statusProxy.isOpen=n,n&&(et.statusProxy.isMinimized=!1)},gl=e=>{const t=et.statusProxy.isMinimized,n=typeof e=="boolean"?e:!t;et.statusProxy.isMinimized=n,n&&(et.statusProxy.isOpen=!1)},vf=e=>{et.modalProxy.isFullscreen=e},El=e=>{if(!["chat","dialog","modal"].includes(e))throw new Error(`Invalid type: ${e}. Must be 'chat', 'dialog', or 'modal'.`);et.statusProxy.type=e,e==="dialog"||e==="chat"?et.modeProxy.mode="embedded":et.modeProxy.mode="standalone"},Cf=e=>{const t=["top","top-left","top-right","bottom","bottom-left","bottom-right","left","right","center"];if(!t.includes(e))throw new Error(`Invalid position: ${e}. Must be one of ${t.join(", ")}.`);et.dialogProxy.position=e},IC=e=>{const t=et.dialogProxy.isFullHeight,n=typeof e=="boolean"?e:!t;et.dialogProxy.isFullHeight=n},RC=({onCopilotEvent:e,children:t,dispatch:n})=>{const{logger:r}=rt(),o=B.useCallback(v=>{n({type:mt.SET_COPILOT,payload:v})},[n]),a=B.useCallback(v=>{OC(v),n({type:mt.SET_CONNECTED,payload:v})},[n]),u=B.useCallback(()=>{n({type:mt.RESET_COPILOT,payload:{}})},[n]),c=B.useCallback(()=>{n({type:mt.RESET_STATE,payload:{}})},[n]),d=B.useCallback(v=>{r==null||r.log(`${v.name} event received`,v),n({type:mt.ADD_MESSAGE,payload:v}),v.bypassHandlers||e==null||e(v)},[e,r,n]),f=B.useCallback(v=>{n({type:mt.ADD_LOADING_MESSAGE,payload:v})},[n]),p=B.useCallback(v=>{n({type:mt.REMOVE_LOADING_MESSAGE,payload:v})},[n]),m=B.useCallback(v=>{d(v),f(v.id)},[d,f]),T=B.useCallback(v=>{n({type:mt.SET_ACTIVE_CONVERSATION_ID,payload:v})},[n]),y=B.useCallback(v=>{n({type:mt.ADD_CONVERSATION_ID,payload:v})},[n]),_=B.useCallback(v=>{n({type:mt.SET_CONVERSATION_IDS,payload:v})},[n]),w=B.useCallback(v=>{n({type:mt.SET_IMAGE_FILE,payload:v})},[n]),C=B.useCallback(v=>{n({type:mt.SET_ASK_CIM_PROMPTS,payload:v})},[n]),A=B.useCallback(v=>{n({type:mt.SET_CONVERSATION_HISTORY_LOADED,payload:v})},[n]),P=B.useMemo(()=>({setCopilot:o,setConnected:a,resetCopilot:u,resetCopilotState:c,addCopilotEvent:d,addLoadingMessage:f,removeLoadingMessage:p,handleCopilotRequestAck:m,setActiveConversationId:T,addConversationId:y,setConversationIds:_,setImageFile:w,setAskCimPrompts:C,setConversationHistoryLoaded:A}),[o,a,u,c,d,f,p,m,T,y,_,w,C,A]);return x.jsx(og.Provider,{value:P,children:t})};wA();const LC=(e,t)=>{const{type:n,payload:r}=t;if(n===mt.ADD_MESSAGE){const o=r;if(e.messages.push(o),o.eventSourceId){const a=e.groupedMessages.findIndex(u=>u.eventSourceId===o.eventSourceId);if(a!==-1){let u=e.groupedMessages[a].messages;u||(u=[]);const c=u.findIndex(d=>d.id===o.id);if(c!==-1){u[c]=o;return}u.push(o);return}else{e.groupedMessages.push({type:"group",eventSourceId:o.eventSourceId,messages:[o],createdAt:new Date(o.createdAt)});return}}e.groupedMessages.push({type:"individual",message:o,createdAt:new Date(o.createdAt)});return}switch(n){case mt.RESET_STATE:e.messages=ro.messages,e.groupedMessages=ro.groupedMessages,e.loadingMessages=ro.loadingMessages,e.imageFile=ro.imageFile,e.askCimPrompts=ro.askCimPrompts,e.conversationHistoryLoaded=ro.conversationHistoryLoaded;break;case mt.RESET_COPILOT:e.copilot=null;break;case mt.SET_COPILOT:e.copilot=r;break;case mt.SET_CONNECTED:e.connected=r;break;case mt.ADD_LOADING_MESSAGE:e.loadingMessages.add(r);break;case mt.REMOVE_LOADING_MESSAGE:e.loadingMessages.delete(r);break;case mt.SET_ACTIVE_CONVERSATION_ID:e.activeConversationId=r;break;case mt.ADD_CONVERSATION_ID:{const o=r;e.conversationIds.includes(o)||e.conversationIds.push(o)}break;case mt.SET_CONVERSATION_IDS:e.conversationIds=r;break;case mt.SET_IMAGE_FILE:e.imageFile=r;break;case mt.SET_ASK_CIM_PROMPTS:e.askCimPrompts.requestId=(r==null?void 0:r.requestId)||null,e.askCimPrompts.message=(r==null?void 0:r.message)||null;break;case mt.SET_CONVERSATION_HISTORY_LOADED:e.conversationHistoryLoaded=r;break}},DC=({onCopilotEvent:e,children:t})=>{const[n,r]=ng(LC,ro);return x.jsx(ig.Provider,{value:n,children:x.jsx(RC,{onCopilotEvent:e,dispatch:r,children:t})})};function MC(){var e=B.useRef(!0);return e.current?(e.current=!1,!0):e.current}function FC(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];e&&e.addEventListener&&e.addEventListener.apply(e,t)}function BC(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];e&&e.removeEventListener&&e.removeEventListener.apply(e,t)}var kf=typeof window!="undefined",Sa=function(e){B.useEffect(e,[])},UC=function(e){var t=B.useRef(e);t.current=e,Sa(function(){return function(){return t.current()}})},HC=function(e){var t=B.useRef(0),n=B.useState(e),r=n[0],o=n[1],a=B.useCallback(function(u){cancelAnimationFrame(t.current),t.current=requestAnimationFrame(function(){o(u)})},[]);return UC(function(){cancelAnimationFrame(t.current)}),[r,a]},zC=function(e,t){return e===t};function jC(e,t){t===void 0&&(t=zC);var n=B.useRef(),r=B.useRef(e),o=MC();return!o&&!t(r.current,e)&&(n.current=r.current,r.current=e),n.current}var $C=function(e){var t={},n=t.initialWidth,r=n===void 0?1/0:n,o=t.initialHeight,a=o===void 0?1/0:o,u=t.onChange,c=HC({width:kf?window.innerWidth:r,height:kf?window.innerHeight:a}),d=c[0],f=c[1];return B.useEffect(function(){if(kf){var p=function(){var m=window.innerWidth,T=window.innerHeight;f({width:m,height:T}),u&&u(m,T)};return FC(window,"resize",p),function(){BC(window,"resize",p)}}},[]),d};class VC{constructor(){we(this,"items",[]);we(this,"add",t=>{const n=this.first();n&&n.context===t.context&&this.remove(),this.items.push(t)});we(this,"remove",()=>this.items.shift());we(this,"first",()=>this.items.length>0?this.items[0]:null);we(this,"clear",()=>{this.items.length=0});we(this,"processQueue",t=>{new Array(yn.size).fill(1).forEach(()=>{const r=yn.first();r&&(t(r),yn.remove())})})}get size(){return this.items.length}}const yn=new VC,Wg=e=>{window.addEventListener(af,e)},Gg=e=>{window.removeEventListener(af,e)},qC=(e,t,n)=>{const r=new CustomEvent(af,{detail:{event:e,property:t,value:n}});window.dispatchEvent(r)},Xg=e=>{window.addEventListener(sf,e)},Kg=e=>{window.removeEventListener(sf,e)},YC=(e,t,n)=>{const r=new CustomEvent(sf,{detail:{event:e,property:t,value:n}});window.dispatchEvent(r)},Qg=e=>{window.addEventListener(of,e)},Jg=e=>{window.removeEventListener(of,e)},Zg=(e,t,n)=>{const r=new CustomEvent(of,{detail:{property:e,value:t,event:n}});window.dispatchEvent(r)},WC=e=>{window.addEventListener(cf,e)},GC=e=>{window.removeEventListener(cf,e)},yl=(e,t,n)=>{const r=new CustomEvent(cf,{detail:{property:e,value:t,event:n}});window.dispatchEvent(r)};class XC{constructor(){we(this,"initialParams",{categoryId:"",categoryName:"",page:null,pageSize:null,includeFacets:!0,facetFilters:{},rangeFilters:[],catalogSegment:null,pricebooks:null});we(this,"categoryIdProxy");we(this,"facetFiltersProxy");we(this,"rangeFiltersProxy");we(this,"catalogSegmentProxy");we(this,"pricebooksProxy");we(this,"_fullGet",(t,n)=>Reflect.get(t,n));we(this,"_fullSet",(t,n,r)=>{const o=CA[n];return YC(o,n,r),Reflect.set(t,n,r)});we(this,"updateFacetFiltersProxy",t=>new Proxy({facetFilters:t},{get:this._fullGet,set:this._fullSet}));we(this,"updateRangeFiltersProxy",t=>new Proxy({rangeFilters:t},{get:this._fullGet,set:this._fullSet}));we(this,"updatePricebooksProxy",t=>new Proxy({pricebooks:t},{get:this._fullGet,set:this._fullSet}));this.categoryIdProxy=new Proxy({categoryId:this.initialParams.categoryId,categoryName:this.initialParams.categoryName},{get:this._fullGet,set:this._fullSet}),this.facetFiltersProxy=this.updateFacetFiltersProxy(this.initialParams.facetFilters||{}),this.rangeFiltersProxy=this.updateRangeFiltersProxy(this.initialParams.rangeFilters||[]),this.catalogSegmentProxy=new Proxy({catalogSegment:this.initialParams.catalogSegment},{get:this._fullGet,set:this._fullSet}),this.pricebooksProxy=this.updatePricebooksProxy(this.initialParams.pricebooks||null)}get categoryId(){return this.categoryIdProxy.categoryId||""}get facetFilters(){return this.facetFiltersProxy.facetFilters||{}}get rangeFilters(){return this.rangeFiltersProxy.rangeFilters||[]}get catalogSegment(){return this.catalogSegmentProxy.catalogSegment||null}get pricebooks(){return this.pricebooksProxy.pricebooks||null}get state(){return{categoryId:this.categoryId,categoryName:this.categoryIdProxy.categoryName,facetFilters:this.facetFilters,rangeFilters:this.rangeFilters,catalogSegment:this.catalogSegment,pricebooks:this.pricebooks,page:this.initialParams.page,pageSize:this.initialParams.pageSize,includeFacets:this.initialParams.includeFacets}}}const lt=new XC,e1=(e,t)=>{const n=t.updateFacetFiltersProxy(e);t.facetFiltersProxy.facetFilters=n.facetFilters},t1=(e,t,n)=>{var u,c;const r=F({},((u=n.facetFiltersProxy)==null?void 0:u.facetFilters)||{});if(!!((c=r[e])!=null&&c.includes(t))){const d=r[e].filter(f=>f!==t);d.length>0?r[e]=d:delete r[e]}else r[e]=r[e]?[...r[e],t]:[t];const a=n.updateFacetFiltersProxy(r);n.facetFiltersProxy.facetFilters=a.facetFilters},n1=(e,t)=>{const n=t.updateRangeFiltersProxy(e);t.rangeFiltersProxy.rangeFilters=n.rangeFilters},r1=({field:e,value:t},n)=>{const[r,o]=Array.isArray(t)?t:[];if(typeof r=="undefined"||typeof o=="undefined")throw new Error("Range values must be an array with two numbers for min and max");const a=[...n.rangeFiltersProxy.rangeFilters||[]],u=a.findIndex(d=>d.field===e);if(u!==-1){a[u]={field:e,min:r,max:o},n.rangeFiltersProxy.rangeFilters=a;return}a.push({field:e,min:r,max:o});const c=n.updateRangeFiltersProxy(a);n.rangeFiltersProxy.rangeFilters=c.rangeFilters},i1=(e,t)=>{t.catalogSegmentProxy.catalogSegment=e},o1=(e,t)=>{const n=t.updatePricebooksProxy(e);t.pricebooksProxy.pricebooks=n.pricebooks},KC=e=>{if(!uo()||!Ta()){uo()&&yn.clear(),yn.add({context:"browse",payload:pe(F({},lt.state),{categoryId:e})});return}lt.categoryIdProxy.categoryId=e},s1=e=>{e1(e,lt)},QC=(e,t)=>{t1(e,t,lt)},a1=e=>{n1(e,lt)},JC=({field:e,value:t})=>{r1({field:e,value:t},lt)},ZC=e=>{i1(e,lt)},u1=e=>{o1(e,lt)},l1=e=>{if(!e||!("categoryId"in e))throw new Error("Browse context must include a categoryId");const t=uo(),n=Ta();if(!t||!n){t&&yn.clear(),yn.add({context:"browse",payload:F({},e)});return}"facetFilters"in e&&s1(e.facetFilters||{}),"rangeFilters"in e&&a1(e.rangeFilters||[]),"catalogSegment"in e&&(lt.catalogSegmentProxy.catalogSegment=e.catalogSegment||null),"pricebooks"in e&&u1(e.pricebooks||[]),"categoryName"in e&&(lt.categoryIdProxy.categoryName=e.categoryName||""),lt.categoryIdProxy.categoryId=e.categoryId},ek=Object.freeze(Object.defineProperty({__proto__:null,setBrowseContext:l1,updateBrowseCategoryId:KC,updateCatalogSegment:ZC,updateFacetFilter:QC,updateFacetFilters:s1,updatePricebooks:u1,updateRangeFilter:JC,updateRangeFilters:a1},Symbol.toStringTag,{value:"Module"}));class tk{constructor(){we(this,"initialParams",{productId:"",productName:"",pdpLink:""});we(this,"proxy");we(this,"_fullGet",(t,n)=>Reflect.get(t,n));we(this,"_fullSet",(t,n,r)=>(Zg(n,r),Reflect.set(t,n,r)));we(this,"updateProxy",t=>{t.productId&&(this.proxy=new Proxy({productId:t.productId,productName:t.productName||"",pdpLink:t.pdpLink||""},{get:this._fullGet,set:this._fullSet}))});this.proxy=new Proxy({productId:this.initialParams.productId,productName:this.initialParams.productName,pdpLink:this.initialParams.pdpLink},{get:this._fullGet,set:this._fullSet})}get productId(){return this.proxy.productId}get pdpLink(){return this.proxy.pdpLink}get state(){return{productId:this.productId,productName:this.proxy.productName,pdpLink:this.pdpLink}}}const Sr=new tk,c1=e=>{if(!e||!e.productId)throw new Error("PDP context must include a productId");const t=uo(),n=Ta();if(!t||!n){t&&yn.clear(),yn.add({context:"pdp",payload:F({},e)});return}Sr.updateProxy(e),Zg("pdp-context",e)},nk=e=>{Sr.proxy.productId=e,uo()||yn.add({context:"pdp",payload:F({},Sr.state)})},rk=e=>{Sr.proxy.pdpLink=e},gt={SET_PROMPTS_EXTENSION_INITIALIZED:"SET_PROMPTS_EXTENSION_INITIALIZED",SET_PROMPTS_EXTENSION_OPEN:"SET_PROMPTS_EXTENSION_OPEN",SET_PROMPTS_EXTENSION_INLINE:"SET_PROMPTS_EXTENSION_INLINE",SET_PROMPTS_EXTENSION_ELEMENT_ID:"SET_PROMPTS_EXTENSION_ELEMENT_ID",SET_PROMPTS_EXTENSION_ENTRY_TYPE:"SET_PROMPTS_EXTENSION_ENTRY_TYPE",SET_PROMPTS_EXTENSION_PARAMS:"SET_PROMPTS_EXTENSION_PARAMS",RESET_PROMPTS_EXTENSION_PARAMS:"RESET_PROMPTS_EXTENSION_PARAMS",SET_PROMPTS_EXTENSION_ACTIVE_PROMPTS_ID:"SET_PROMPTS_EXTENSION_ACTIVE_PROMPTS_ID",RESET_PROMPTS_EXTENSION_ACTIVE_PROMPTS_ID:"RESET_PROMPTS_EXTENSION_ACTIVE_PROMPTS_ID",SET_PROMPTS_EXTENSION_USER_PROMPT:"SET_PROMPTS_EXTENSION_USER_PROMPT",SET_PROMPTS_EXTENSION_PROMPTS_MESSAGE:"SET_PROMPTS_EXTENSION_PROMPTS_MESSAGE",RESET_PROMPTS_EXTENSION_PROMPTS_MESSAGE:"RESET_PROMPTS_EXTENSION_PROMPTS_MESSAGE",SET_PROMPTS_EXTENSION_RESPONSE_MESSAGE:"SET_PROMPTS_EXTENSION_RESPONSE_MESSAGE",RESET_PROMPTS_EXTENSION_RESPONSE_MESSAGE:"RESET_PROMPTS_EXTENSION_RESPONSE_MESSAGE",SET_PROMPTS_EXTENSION_RESPONSE_LOADING:"SET_PROMPTS_EXTENSION_RESPONSE_LOADING"},d1={isInitialized:!1,isOpen:!1,isInline:!1,elementId:null,placeholder:null,askElseButtonLabel:null,entryType:null,params:null,activePromptsId:null,userPrompt:null,promptsMessage:null,isResponseLoading:!1,responseMessage:null,promptsDisplay:"both",disableAskElseButton:!1};class ik{constructor(){we(this,"initialState",d1);we(this,"promptsStateProxy");we(this,"promptsParamsProxy");we(this,"_fullGet",(t,n)=>Reflect.get(t,n));we(this,"_fullSet",(t,n,r)=>{if(!(n in t))throw new Error(`Property ${n} does not exist on PromptsExtensionState`);return xa(n,r),Reflect.set(t,n,r)});we(this,"_paramsFullGet",(t,n)=>Reflect.get(t,n));we(this,"_paramsFullSet",(t,n,r)=>Reflect.set(t,n,r));we(this,"updatePromptsParamsProxy",t=>new Proxy(F({},t),{get:this._paramsFullGet,set:this._paramsFullSet}));this.promptsStateProxy=new Proxy({isOpen:this.initialState.isOpen,isInline:this.initialState.isInline,elementId:this.initialState.elementId,entryType:this.initialState.entryType},{get:this._fullGet,set:this._fullSet}),this.promptsParamsProxy=this.updatePromptsParamsProxy({})}get isOpen(){return this.promptsStateProxy.isOpen}get isInline(){return this.promptsStateProxy.isInline}get state(){return{isOpen:this.isOpen,isInline:this.isInline}}get params(){return this.promptsParamsProxy}}const zt=new ik,ok=e=>{window.addEventListener(lf,e)},sk=e=>{window.removeEventListener(lf,e)},xa=(e,t)=>{const n=new CustomEvent(lf,{detail:{property:e,value:t}});window.dispatchEvent(n)},f1=e=>{const t=zt.isOpen,n=typeof e=="boolean"?e:!t;zt.promptsStateProxy.isOpen=n},h1=e=>{const t=zt.isInline,n=typeof e=="boolean"?e:!t;zt.promptsStateProxy.isInline=n},ak=e=>{zt.promptsParamsProxy=zt.updatePromptsParamsProxy(e),xa("params",e),zt.promptsStateProxy.entryType="ask_cim"},uk=e=>{zt.promptsParamsProxy=zt.updatePromptsParamsProxy(e),xa("params",e),zt.promptsStateProxy.entryType="search"},lk=e=>{zt.promptsParamsProxy=zt.updatePromptsParamsProxy(e),xa("params",e),zt.promptsStateProxy.entryType="browse"},ck=e=>{zt.promptsParamsProxy=zt.updatePromptsParamsProxy(e),xa("params",e),zt.promptsStateProxy.entryType="pdp"},dk=({elementId:e,entryType:t,params:n,isInline:r})=>{zt.promptsStateProxy.elementId=e,t&&(zt.promptsStateProxy.entryType=t),typeof r=="boolean"&&h1(r),n&&zt.updatePromptsParamsProxy(n),zt.isOpen||f1(!0)},fk=Object.freeze(Object.defineProperty({__proto__:null,getConversationMessages:({payload:e,callback:t})=>{yl("getConversationMessages",{payload:e,callback:t},Ci.GET_CONVERSATION_MESSAGES)},getSessionInformation:e=>{yl("getSessionInformation",{callback:e},Ci.GET_SESSION_INFORMATION)},loadConversation:e=>{yl("loadConversation",e,Ci.LOAD_CONVERSATION)},resetConversation:()=>{yl("resetConversation",!0,Ci.RESET_CONVERSATION)}},Symbol.toStringTag,{value:"Module"}));class hk{constructor(){we(this,"initialParams",{query:"",page:null,pageSize:null,includeFacets:!0,facetFilters:{},rangeFilters:[],catalogSegment:null,pricebooks:null});we(this,"queryProxy");we(this,"facetFiltersProxy");we(this,"rangeFiltersProxy");we(this,"catalogSegmentProxy");we(this,"pricebooksProxy");we(this,"_fullGet",(t,n)=>Reflect.get(t,n));we(this,"_fullSet",(t,n,r)=>{const o=kA[n];return qC(o,n,r),Reflect.set(t,n,r)});we(this,"updateFacetFiltersProxy",t=>new Proxy({facetFilters:t},{get:this._fullGet,set:this._fullSet}));we(this,"updateRangeFiltersProxy",t=>new Proxy({rangeFilters:t},{get:this._fullGet,set:this._fullSet}));we(this,"updatePricebooksProxy",t=>new Proxy({pricebooks:t},{get:this._fullGet,set:this._fullSet}));this.queryProxy=new Proxy({query:this.initialParams.query},{get:this._fullGet,set:this._fullSet}),this.facetFiltersProxy=this.updateFacetFiltersProxy(this.initialParams.facetFilters||{}),this.rangeFiltersProxy=this.updateRangeFiltersProxy(this.initialParams.rangeFilters||[]),this.catalogSegmentProxy=new Proxy({catalogSegment:this.initialParams.catalogSegment},{get:this._fullGet,set:this._fullSet}),this.pricebooksProxy=this.updatePricebooksProxy(this.initialParams.pricebooks||null)}get query(){return this.queryProxy.query||""}get facetFilters(){return this.facetFiltersProxy.facetFilters||{}}get rangeFilters(){return this.rangeFiltersProxy.rangeFilters||[]}get catalogSegment(){return this.catalogSegmentProxy.catalogSegment||null}get pricebooks(){return this.pricebooksProxy.pricebooks||null}get state(){return{query:this.query,facetFilters:this.facetFilters,rangeFilters:this.rangeFilters,catalogSegment:this.catalogSegment,pricebooks:this.pricebooks,page:this.initialParams.page,pageSize:this.initialParams.pageSize,includeFacets:this.initialParams.includeFacets}}}const Tt=new hk,pk=e=>{const t=Ta(),n=uo();if(!n||!t){n&&yn.clear(),yn.add({context:"search",payload:pe(F({},Tt.state),{query:e})});return}Tt.queryProxy.query=e},p1=e=>{e1(e,Tt)},mk=(e,t)=>{t1(e,t,Tt)},m1=e=>{n1(e,Tt)},gk=({field:e,value:t})=>{r1({field:e,value:t},Tt)},Ek=e=>{i1(e,Tt)},g1=e=>{o1(e,Tt)},E1=e=>{if(!e||!e.query)throw new Error("Search context must include a query");const t=Ta(),n=uo();if(!n||!t){n&&yn.clear(),yn.add({context:"search",payload:F({},e)});return}"facetFilters"in e&&p1(e.facetFilters||{}),"rangeFilters"in e&&m1(e.rangeFilters||[]),"catalogSegment"in e&&(Tt.catalogSegmentProxy.catalogSegment=e.catalogSegment||null),"pricebooks"in e&&g1(e.pricebooks||[]),Tt.queryProxy.query=e.query},yk=Object.freeze(Object.defineProperty({__proto__:null,setSearchContext:E1,updateCatalogSegment:Ek,updateFacetFilter:mk,updateFacetFilters:p1,updatePricebooks:g1,updateRangeFilter:gk,updateRangeFilters:m1,updateSearchQuery:pk},Symbol.toStringTag,{value:"Module"})),bk={categoryId:lt.categoryId,categoryName:lt.categoryIdProxy.categoryName||"",facetFilters:lt.facetFilters,rangeFilters:lt.rangeFilters,catalogSegment:lt.catalogSegment,pricebooks:lt.pricebooks},y1=B.createContext(bk),Tk=({children:e})=>{const[t,n]=B.useState(lt.categoryId),[r,o]=B.useState(lt.categoryIdProxy.categoryName||""),[a,u]=B.useState(lt.facetFilters||{}),[c,d]=B.useState(lt.rangeFilters||[]),[f,p]=B.useState(lt.catalogSegment||null),[m,T]=B.useState(lt.pricebooks||null);B.useEffect(()=>{const _=({detail:w})=>{(w==null?void 0:w.property)==="categoryId"&&n(w.value),(w==null?void 0:w.property)==="categoryName"&&o(w.value),(w==null?void 0:w.property)==="facetFilters"&&u(w.value),(w==null?void 0:w.property)==="rangeFilters"&&d(w.value),(w==null?void 0:w.property)==="catalogSegment"&&p(w.value),(w==null?void 0:w.property)==="pricebooks"&&T(w.value)};return Xg(_),()=>{Kg(_)}},[]);const y=B.useMemo(()=>({categoryId:t,categoryName:r,facetFilters:a,rangeFilters:c,catalogSegment:f,pricebooks:m}),[t,r,a,c,f,m]);return x.jsx(y1.Provider,{value:y,children:e})},_k=()=>{const e=B.useContext(y1);if(!e)throw new Error("useBrowse must be used within a BrowseProvider");return e},Sk={searchQuery:Tt.query,facetFilters:Tt.facetFilters,rangeFilters:Tt.rangeFilters,catalogSegment:Tt.catalogSegment,pricebooks:Tt.pricebooks},b1=B.createContext(Sk),xk=({children:e})=>{const[t,n]=B.useState(Tt.query),[r,o]=B.useState(Tt.facetFilters),[a,u]=B.useState(Tt.rangeFilters),[c,d]=B.useState(Tt.catalogSegment),[f,p]=B.useState(Tt.pricebooks);B.useEffect(()=>{const T=({detail:y})=>{(y==null?void 0:y.property)==="query"&&n(y.value),(y==null?void 0:y.property)==="facetFilters"&&o(y.value),(y==null?void 0:y.property)==="rangeFilters"&&u(y.value),(y==null?void 0:y.property)==="catalogSegment"&&d(y.value),(y==null?void 0:y.property)==="pricebooks"&&p(y.value)};return Wg(T),()=>{Gg(T)}},[]);const m=B.useMemo(()=>({searchQuery:t,facetFilters:r,rangeFilters:a,catalogSegment:c,pricebooks:f}),[t,r,a,c,f]);return x.jsx(b1.Provider,{value:m,children:e})},wk=()=>{const e=B.useContext(b1);if(!e)throw new Error("useSearch must be used within a SearchProvider");return e},Ak={productId:Sr.productId,pdpLink:Sr.pdpLink},T1=B.createContext(Ak),vk=({children:e})=>{const[t,n]=B.useState(Sr.productId),[r,o]=B.useState(Sr.pdpLink);B.useEffect(()=>{const u=({detail:c})=>{if((c==null?void 0:c.property)==="pdp-context"){const d=c.value;n(d.productId),o(d.pdpLink);return}(c==null?void 0:c.property)==="productId"&&n(c.value),(c==null?void 0:c.property)==="pdpLink"&&o(c.value)};return Qg(u),()=>{Jg(u)}},[]);const a=B.useMemo(()=>({productId:t,pdpLink:r}),[t,r]);return x.jsx(T1.Provider,{value:a,children:e})},Ck=()=>{const e=B.useContext(T1);if(!e)throw new Error("usePdp must be used within a PdpProvider");return e},_1=B.createContext({mode:et.modeProxy.mode,entryType:et.entryType,status:et.statusProxy,dialogPosition:et.dialogProxy.position,isDialogFullHeight:et.dialogProxy.isFullHeight,dialogWidth:et.dialogProxy.width,isModalFullscreen:et.modalProxy.isFullscreen,previousComponentType:et.statusProxy.type}),kk=({entryType:e,componentConfig:t,componentType:n,children:r})=>{const[o,a]=B.useState(e!=null?e:et.entryTypeProxy.entryType),[u,c]=B.useState(et.modeProxy.mode),[d,f]=B.useState({type:n||et.statusProxy.type,isOpen:et.statusProxy.isOpen,isMinimized:et.statusProxy.isMinimized}),[p,m]=B.useState(et.dialogProxy.position),[T,y]=B.useState(et.dialogProxy.isFullHeight),[_,w]=B.useState(et.dialogProxy.width),[C,A]=B.useState(et.modalProxy.isFullscreen),P=jC(d.type);B.useEffect(()=>{const H=Y=>{const{property:D,value:q}=Y.detail||{};if(!(!D||q===void 0)){if(D==="mode"){c(q);return}if(D==="entryType"){a(q);return}if(D==="isMinimized"){f(re=>pe(F({},re),{isMinimized:q}));return}if(D==="isOpen"){f(re=>pe(F({},re),{isOpen:q}));return}if(D==="type"){f(re=>pe(F({},re),{type:q}));return}if(D==="position"){m(q);return}if(D==="isFullHeight"){y(q);return}if(D==="width"){w(q);return}if(D==="isFullscreen"){A(q);return}}};return kC(H),()=>{PC(H)}},[]),Sa(()=>{e&&_a(e)}),Sa(()=>{const H=n||(t==null?void 0:t.type);H&&El(H),t&&"isOpen"in t&&ui(!!t.isOpen),t&&"isMinimized"in t&&gl(!!t.isMinimized)}),Sa(()=>{if(!(t!=null&&t.options))return;const{dialogPosition:H}=t.options;H&&Cf(H),"dialogFullHeight"in t.options&&IC(!!t.options.dialogFullHeight),"dialogWidth"in t.options&&t.options.dialogWidth&&w(t.options.dialogWidth),"isModalFullscreen"in t.options&&vf(!!t.options.isModalFullscreen)});const v=B.useMemo(()=>({mode:u,entryType:o,status:d,previousComponentType:P||"dialog",dialogPosition:p,isDialogFullHeight:T,dialogWidth:_,isModalFullscreen:C}),[u,o,d,P,p,T,_,C]);return x.jsx(_1.Provider,{value:v,children:r})},sr=()=>{const e=B.useContext(_1);if(!e)throw new Error("useUIState must be used within a UIStateProvider");return e},S1=B.createContext(null),x1=B.createContext(null),Pf=()=>{const e=B.useContext(x1);if(!e)throw new Error("usePromptsExtensionDispatch must be used within a PromptsExtensionProvider");return e||{}},li=()=>{const e=B.useContext(S1);if(!e)throw new Error("usePromptsExtensionState must be used within a PromptsExtensionProvider");return e||{}},Qo=()=>{const e=B.useContext(og);if(!e)throw new Error("useCopilotDispatch must be used within a CopilotProvider");return e},ar=()=>{const e=B.useContext(ig);if(!e)throw new Error("useCopilotState must be used within a CopilotProvider");return e},Pk=({copilot:e})=>{const{logger:t,conversationHistory:n}=rt(),{isInline:r}=li(),{addCopilotEvent:o,setConversationHistoryLoaded:a}=Qo(),{activeConversationId:u}=ar(),c=B.useCallback(f=>{e&&e.requestSessionInformation(p=>{t==null||t.log("Retrieved session information: ",p),f==null||f(p)})},[e,t]),d=B.useCallback((f,p)=>{e&&f.conversationId&&e.getConversationEvents(f,m=>{t==null||t.log("Retrieved conversation messages: ",m),p==null||p(m)})},[e,t]);return B.useEffect(()=>{if(r||!u)return;if(n.sinceHours===0||(n==null?void 0:n.limit)===0){a(!0);return}const f=3600*1e3*n.sinceHours,p=new Date(Date.now()-f).toISOString(),m={conversationId:u,since:p,excludeEvents:["done","error","connection_error","refined_browse","refined_search","conversation_reset"]};typeof n.limit=="number"&&(m.limit=n.limit),d(m,T=>{const y=[];[...T.reverse()||[]].forEach(w=>{var A;const C=T.find(P=>P.id===w.eventSourceId);(A=C==null?void 0:C.name)!=null&&A.endsWith("_suggestions")||(w.bypassHandlers=!0,y.unshift(w))}),y.forEach(w=>{o(w)}),a(!0)})},[t,r,u,d,o,a,n]),{getSessionInformation:c,getConversationMessages:d}},w1=B.createContext({copilot:null,messages:[],groupedMessages:[],isLoading:!1,isResponseLoading:()=>!1,handleAskCim:()=>{},handleSearch:()=>{},handleBrowse:()=>{},handlePdp:()=>{},handleSuggestion:()=>{},handleUserInput:()=>{},handleCancel:()=>{},resetConversation:()=>{},getSessionInformation:()=>{},getConversationMessages:()=>{}}),Nk=({apiKey:e,apiToken:t,baseUrl:n,customerId:r,tenantId:o,isDevelopment:a,onConnect:u,onRefinedSearch:c,onRefinedBrowse:d,children:f})=>{const{logger:p,clientContext:m,baseCatalogParams:T}=rt(),cn=wk(),{searchQuery:y}=cn,_=mn(cn,["searchQuery"]),Hn=_k(),{categoryId:w}=Hn,C=mn(Hn,["categoryId"]),{productId:A,pdpLink:P}=Ck(),{setCopilot:v,setConnected:H,resetCopilot:Y,resetCopilotState:D,addCopilotEvent:q,removeLoadingMessage:re,handleCopilotRequestAck:me,setActiveConversationId:V,setConversationIds:oe,setAskCimPrompts:ce}=Qo(),{connected:de,copilot:ne,messages:Te,groupedMessages:Pe,loadingMessages:se,askCimPrompts:K}=ar(),{status:ie,entryType:k}=sr(),{isInline:L}=li(),{getConversationMessages:ee,getSessionInformation:I}=Pk({copilot:ne}),Se=B.useMemo(()=>se.size>0,[se]),je=B.useCallback(Ae=>se.has(Ae),[se]),Ee=B.useCallback(({query:Ae,facetFilters:Oe,rangeFilters:Me,catalogSegment:ot,pricebooks:pt,userPrompt:J,imageFile:ge})=>{if(!ne){p==null||p.error("Copilot is not initialized");return}if(!Ae)return;const Ce={searchParams:{query:Ae}};J&&(Ce.userPrompt=J),ge&&(Ce.attachments={image:ge}),Oe&&Object.keys(Oe).length>0&&(Ce.searchParams.facetFilters=Oe),Me&&Me.length>0&&(Ce.searchParams.rangeFilters=Me),ot&&(Ce.searchParams.catalogSegment=ot),pt&&(Ce.searchParams.pricebooks=pt),m&&(Ce.clientContext=m),_a("search"),ne.search(Ce,Ye=>{const Re=F({},Ye);me(Re)})},[p,me,ne,m]),Be=B.useCallback(({categoryId:Ae,categoryName:Oe,facetFilters:Me,rangeFilters:ot,catalogSegment:pt,pricebooks:J,userPrompt:ge,imageFile:Ce})=>{if(!ne){p==null||p.error("Copilot is not initialized");return}const Ye=Me&&Object.keys(Me).length>0;if(Ae===""&&!Ye){p==null||p.error("Browse event must include facetFilters when categoryId is empty");return}const Re={browseParams:{categoryId:Ae||""}};ge&&(Re.userPrompt=ge),Ce&&(Re.attachments={image:Ce}),Ye&&(Re.browseParams.facetFilters=Me),ot&&ot.length>0&&(Re.browseParams.rangeFilters=ot),pt&&(Re.browseParams.catalogSegment=pt),Array.isArray(J)&&J.length>0&&(Re.browseParams.pricebooks=J),(m||Oe)&&(Re.clientContext={},m&&(Re.clientContext=F({},m)),Oe&&(Re.clientContext.cimLabel=Oe)),_a("browse"),ne.browse(Re,ct=>{var Qr;const Gt=F({},ct),Vt=((Qr=Gt.request)==null?void 0:Qr.clientContext)||{},dn=(Vt==null?void 0:Vt.cimLabel)||Oe;dn&&Gt.request&&(Gt.request.label=dn),me(Gt)})},[p,me,ne,m]),Ve=B.useCallback(({productId:Ae,productName:Oe,pdpLink:Me,userPrompt:ot,imageFile:pt})=>{if(!ne){p==null||p.error("Copilot is not initialized");return}if(!Ae)return;const J={productId:Ae};ot&&(J.userPrompt=ot),Me&&(J.pdpLink=Me),pt&&(J.attachments={image:pt}),(m||Oe)&&(J.clientContext={},m&&(J.clientContext=F({},m)),Oe&&(J.clientContext.cimLabel=Oe)),T&&(J.baseCatalogParams=T),_a("pdp"),ne.productView(J,ge=>{var ct;const Ce=F({},ge),Ye=((ct=Ce.request)==null?void 0:ct.clientContext)||{},Re=(Ye==null?void 0:Ye.cimLabel)||Oe;Re&&Ce.request&&(Ce.request.label=Re),me(Ce)})},[p,ne,me,m,T]),Ge=B.useCallback(({userPrompt:Ae,imageFile:Oe})=>{if(!ne){p==null||p.error("Copilot is not initialized");return}if(!Ae)return;const Me={userPrompt:Ae};Oe&&(Me.attachments={image:Oe}),m&&(Me.clientContext=m),T&&(Me.baseCatalogParams=T),ne.askCim(Me,ot=>{const pt=F({},ot);me(pt)})},[p,ne,me,m,T]),_t=B.useCallback(Ae=>{q(Ae),c==null||c(Ae)},[q,c]),Pn=B.useCallback(Ae=>{q(Ae),d==null||d(Ae)},[q,d]),ln=B.useCallback(Ae=>{u==null||u(Ae),H(!0)},[u,H]);B.useEffect(()=>{!ne||!de||!ie.isOpen||yn.size>0&&yn.processQueue(Ae=>{if(Ae.context==="search"){const Oe=F({},Ae.payload);E1(Oe)}if(Ae.context==="browse"){const Oe=F({},Ae.payload);l1(Oe)}if(Ae.context==="pdp"){const Oe=F({},Ae.payload);c1(Oe)}})},[ie.isOpen,ne,de]);const kr=B.useCallback(Ae=>{const Oe=Me=>{const ot=pe(F({},Me),{id:Me.inquiryLinkId||Me.id});q(ot)};Ae.on("connect_ack",ln),Ae.on("partial_inquiry",Oe),Ae.on("display_products",q),Ae.on("progress",q),Ae.on("refined_search",_t),Ae.on("refined_browse",Pn),Ae.on("done",Me=>{re(Me.eventSourceId)}),Ae.on("error",Me=>{q(Me),re(Me.eventSourceId)}),Ae.onDisconnect(Me=>{const ot=["io server disconnect","transport error","server shutting down"];if(p==null||p.log("Connection disconnected with reason: ",Me),!ot.includes(Me)){H(!1);return}p==null||p.log("De-registering event listeners");const pt=new Date().toISOString();q({name:"error",message:"Connection was lost. Please try again.",createdAt:pt,id:`error-${pt}`,sessionId:"session"}),Ae.off()})},[p,H,re,_t,Pn,q,ln]);B.useEffect(()=>{if(!ne)return;const Ae=Oe=>{if(!L){if(!Oe.message&&Oe.eventSourceId&&Oe.eventSourceId===K.requestId){ce({requestId:Oe.eventSourceId,message:Oe});return}q(Oe)}};return ne.on("follow_up",Ae),()=>{ne.off("follow_up",Ae)}},[ne,Te,K.requestId,L,q,ce]),B.useEffect(()=>{if(!ne)return;const Ae=Oe=>{if(L)return;const Me=pe(F({},Oe),{id:Oe.inquiryLinkId||Oe.id});q(Me)};return ne.on("inquiry",Ae),()=>{ne.off("inquiry",Ae)}},[ne,L,q]),Sa(()=>{let Ae;n?Ae=n:Ae=a?"https://staging.copilot.search.cimulate.ai":"https://prod.copilot.search.cimulate.ai";const Oe={baseUrl:Ae};e?Oe.apiKey=e:t&&(Oe.apiToken=t),r&&(Oe.customerId=r),o&&(Oe.tenantId=o);const Me=new hA(Oe);return v(Me),kr(Me),Me.connect(),Me.requestSessionInformation(ot=>{p==null||p.log("Session Information: ",ot);const{activeConversationId:pt,conversationIds:J}=ot.data||{};pt&&V(pt),J!=null&&J.length&&oe(J)}),()=>{Me.disconnect(),Me.off(),Y()}});const fr=B.useCallback(Ae=>{if(!ne)return;const Oe={eventId:Ae,reason:"User cancelled the request"};ne.cancelRequest(Oe,Me=>{q(Me),re(Ae)})},[q,re,ne]),rn=B.useCallback(()=>{ne&&ne.conversationReset({},Ae=>{D(),q(Ae),ne.requestSessionInformation(Oe=>{p==null||p.log("Session Information: ",Oe);const{activeConversationId:Me,conversationIds:ot}=Oe.data||{};Me&&V(Me),ot!=null&&ot.length&&oe(ot)})})},[ne,p,q,D,V,oe]),qe=B.useCallback((Ae,Oe)=>{if(!Ae)return;const Me={userPrompt:Ae};switch(Oe&&(Me.imageFile=Oe),k){case"ask_cim":Ge(Me);return;case"search":y?Ee(F(F({query:y},_),Me)):Ge(Me);return;case"browse":Be(F(F({categoryId:w},C),Me));return;case"pdp":A?Ve(F({productId:A,pdpLink:P||""},Me)):Ge(Me);return}},[k,y,_,Ee,Ge,w,C,Be,Ve,A,P]),Nt=B.useCallback((Ae,Oe)=>{var ge,Ce,Ye;const ot=Ae.params.userPrompt||"";if(!ot)return;const pt=Te.find(Re=>Re.id===Oe);if(!pt)return;const J=pt.name.replace("_suggestions","");if(J==="ask_cim"){Ge({userPrompt:ot});return}if(J==="copilot_search"){const Re=((ge=pt.request)==null?void 0:ge.searchParams)||{},Gt=Re.query===y;Ee(pe(F({query:Re.query||y},Gt?_:{}),{userPrompt:ot}));return}if(J==="copilot_browse"){const Re=pt.request,ct=Re.browseParams||{},Vt=ct.categoryId===w,dn=((Ce=Re.clientContext)==null?void 0:Ce.cimLabel)||"";Be(pe(F({categoryId:ct.categoryId||w||""},Vt?C:{}),{categoryName:dn,userPrompt:ot}));return}if(J==="product_view"){const Re=pt.request||{},ct=Re.productId,Gt=ct===A,Vt=((Ye=Re.clientContext)==null?void 0:Ye.cimLabel)||"";let dn="";Gt?dn=P||"":dn=Re.pdpLink||"",Ve({productId:ct||A,pdpLink:dn,productName:Vt,userPrompt:ot})}},[Te,y,_,Ee,Ge,w,C,Be,Ve,A,P]),Nn=B.useMemo(()=>({copilot:ne,messages:Te,groupedMessages:Pe,isLoading:Se,isResponseLoading:je,handleAskCim:Ge,handleSearch:Ee,handleBrowse:Be,handlePdp:Ve,handleUserInput:qe,handleSuggestion:Nt,handleCancel:fr,resetConversation:rn,getSessionInformation:I,getConversationMessages:ee}),[ne,Te,Pe,Se,je,Ge,Ee,Be,Ve,qe,Nt,fr,rn,I,ee]);return x.jsx(w1.Provider,{value:Nn,children:f})},A1=()=>{const{copilot:e}=ar(),{addCopilotEvent:t}=Qo();return{getCopilotSuggestions:B.useCallback((r,o,a)=>{if(!e||!o||!r)return;const u=c=>{t(c),a(c)};switch(o){case"ask_cim":e.askCimSuggestions(r,u);break;case"search":e.searchSuggestions({searchParams:r},u);break;case"browse":e.browseSuggestions({browseParams:r},u);break;case"pdp":e.productViewSuggestions({productId:r.productId},u);break}},[e,t])}},Ur=()=>{const e=B.useContext(w1);if(!e)throw new Error("useCopilot must be used within a CopilotProvider");return e},Ok=()=>{const{copilot:e,activeConversationId:t,askCimPrompts:n,conversationHistoryLoaded:r}=ar(),{entryType:o}=sr(),{resetCopilotState:a,addCopilotEvent:u,setAskCimPrompts:c}=Qo(),{handleSearch:d,handleBrowse:f,handlePdp:p,resetConversation:m,getSessionInformation:T,getConversationMessages:y}=Ur(),{getCopilotSuggestions:_}=A1();B.useEffect(()=>{!e||!o||!t||!r||n.requestId||o==="ask_cim"&&_({},o,P=>{c({requestId:P.id,message:null})})},[e,t,n.requestId,o,r,_,c]);const w=B.useCallback(({query:P})=>{if(!e||!P)return;const{facetFilters:v}=Tt.facetFiltersProxy,{rangeFilters:H}=Tt.rangeFiltersProxy,{catalogSegment:Y}=Tt.catalogSegmentProxy,{pricebooks:D}=Tt.pricebooksProxy,q={query:P};q.facetFilters=v||{},q.rangeFilters=H||[],q.catalogSegment=Y||"",q.pricebooks=D||[],d(F({},q))},[e,d]),C=B.useCallback(({categoryId:P})=>{if(!e)return;const v=lt.categoryIdProxy.categoryName,{facetFilters:H}=lt.facetFiltersProxy,{rangeFilters:Y}=lt.rangeFiltersProxy,{catalogSegment:D}=lt.catalogSegmentProxy,{pricebooks:q}=lt.pricebooksProxy,re={categoryId:P};re.categoryName=v||"",re.facetFilters=H||{},re.rangeFilters=Y||[],re.catalogSegment=D||"",re.pricebooks=q||[],f(F({},re))},[e,f]),A=B.useCallback(({productId:P})=>{if(!e||!P)return;const v={productId:P,pdpLink:Sr.pdpLink,productName:Sr.proxy.productName||""};p(v)},[e,p]);return B.useEffect(()=>{const P=({detail:v})=>{(v==null?void 0:v.property)==="query"&&w({query:v.value})};return Wg(P),()=>{Gg(P)}},[w]),B.useEffect(()=>{const P=({detail:v})=>{if((v==null?void 0:v.property)==="pdp-context"){const H=v.value;A({productId:H.productId});return}(v==null?void 0:v.property)==="productId"&&A({productId:v.value})};return Qg(P),()=>{Jg(P)}},[A]),B.useEffect(()=>{const P=({detail:v})=>{(v==null?void 0:v.property)==="categoryId"&&C({categoryId:v.value})};return Xg(P),()=>{Kg(P)}},[C]),B.useEffect(()=>{const P=({detail:v})=>{if((v==null?void 0:v.event)==Ci.RESET_CONVERSATION&&m(),(v==null?void 0:v.event)==Ci.GET_SESSION_INFORMATION){const H=v.value.callback;T(H)}if((v==null?void 0:v.event)==Ci.GET_CONVERSATION_MESSAGES){const{payload:H,callback:Y}=v.value;if(!H.conversationId||typeof Y!="function")return;y(H,Y)}if((v==null?void 0:v.event)==Ci.LOAD_CONVERSATION){const H=v.value;if(!H.conversationId)return;y(H,D=>{a(),D.forEach(q=>{u(q)})})}};return WC(P),()=>{GC(P)}},[m,T,y,a,u]),null},Ik=({apiKey:e,apiToken:t,baseUrl:n,customerId:r,tenantId:o,isDevelopment:a,onConnect:u,onRefinedSearch:c,onRefinedBrowse:d,children:f})=>x.jsxs(Nk,{apiKey:e,apiToken:t,baseUrl:n,customerId:r,tenantId:o,isDevelopment:a,onConnect:u,onRefinedSearch:c,onRefinedBrowse:d,children:[x.jsx(Ok,{}),f]}),Rk=({children:e,dispatch:t})=>{const n=B.useCallback(_=>{t({type:gt.SET_PROMPTS_EXTENSION_INITIALIZED,payload:_})},[t]),r=B.useCallback(_=>{t({type:gt.SET_PROMPTS_EXTENSION_OPEN,payload:_})},[t]),o=B.useCallback(_=>{t({type:gt.SET_PROMPTS_EXTENSION_INLINE,payload:_})},[t]),a=B.useCallback(_=>{t({type:gt.SET_PROMPTS_EXTENSION_ELEMENT_ID,payload:_})},[t]),u=B.useCallback(_=>{t({type:gt.SET_PROMPTS_EXTENSION_ENTRY_TYPE,payload:_})},[t]),c=B.useCallback(_=>{t({type:gt.SET_PROMPTS_EXTENSION_ACTIVE_PROMPTS_ID,payload:_})},[t]),d=B.useCallback(_=>{t({type:gt.SET_PROMPTS_EXTENSION_USER_PROMPT,payload:_})},[t]),f=B.useCallback(_=>{t({type:gt.SET_PROMPTS_EXTENSION_PARAMS,payload:_})},[t]),p=B.useCallback(_=>{t({type:gt.SET_PROMPTS_EXTENSION_PROMPTS_MESSAGE,payload:_})},[t]),m=B.useCallback(_=>{t({type:gt.SET_PROMPTS_EXTENSION_RESPONSE_MESSAGE,payload:_})},[t]),T=B.useCallback(_=>{t({type:gt.SET_PROMPTS_EXTENSION_RESPONSE_LOADING,payload:_})},[t]),y=B.useMemo(()=>({setIsInitialized:n,setIsOpen:r,setIsInline:o,setElementId:a,setEntryType:u,setActivePromptsId:c,setUserPrompt:d,setParams:f,setPromptsMessage:p,setResponseMessage:m,setIsResponseLoading:T}),[n,r,o,a,u,c,d,f,p,m,T]);return x.jsx(x1.Provider,{value:y,children:e})},Lk=(e,t)=>{const{type:n,payload:r}=t;switch(n){case gt.SET_PROMPTS_EXTENSION_INITIALIZED:e.isInitialized=r;break;case gt.SET_PROMPTS_EXTENSION_OPEN:e.isOpen=r;break;case gt.SET_PROMPTS_EXTENSION_INLINE:e.isInline=r;break;case gt.SET_PROMPTS_EXTENSION_ELEMENT_ID:e.elementId=r;break;case gt.SET_PROMPTS_EXTENSION_ENTRY_TYPE:e.entryType=r;break;case gt.SET_PROMPTS_EXTENSION_PARAMS:e.params=r;break;case gt.RESET_PROMPTS_EXTENSION_PARAMS:e.params=null;break;case gt.SET_PROMPTS_EXTENSION_USER_PROMPT:e.userPrompt=r;break;case gt.SET_PROMPTS_EXTENSION_ACTIVE_PROMPTS_ID:e.activePromptsId=r;break;case gt.RESET_PROMPTS_EXTENSION_ACTIVE_PROMPTS_ID:e.activePromptsId=null;break;case gt.SET_PROMPTS_EXTENSION_PROMPTS_MESSAGE:e.promptsMessage=r;break;case gt.RESET_PROMPTS_EXTENSION_PROMPTS_MESSAGE:e.promptsMessage=null;break;case gt.SET_PROMPTS_EXTENSION_RESPONSE_MESSAGE:e.responseMessage=r;break;case gt.RESET_PROMPTS_EXTENSION_RESPONSE_MESSAGE:e.responseMessage=null;break;case gt.SET_PROMPTS_EXTENSION_RESPONSE_LOADING:e.isResponseLoading=r;break}},Dk=({promptsConfig:e,children:t})=>{const[n,r]=ng(Lk,F(F({},d1),e||{}));return x.jsx(S1.Provider,{value:n,children:x.jsx(Rk,{dispatch:r,children:t})})},v1=({mode:e,apiKey:t,apiToken:n,baseUrl:r,customerId:o,tenantId:a,logoUrl:u,headerText:c,headerConfig:d,theme:f,openLinksInNewTab:p,globalClassName:m,isDevelopment:T=!1,componentType:y,componentConfig:_,entryType:w,entryMessage:C,disclaimerText:A,disclaimerMarkdown:P,clientContext:v,baseCatalogParams:H,searchPlaceholder:Y,searchButtonLabel:D,searchConfig:q,suggestionButtonConfig:re,messageAlignment:me,autoScroll:V,promptsConfig:oe,resetConversationMessage:ce,conversationHistory:de,onConnect:ne,onCopilotEvent:Te,onRefinedSearch:Pe,onRefinedBrowse:se,__features:K,children:ie})=>x.jsx(vC,{mode:e,baseUrl:r,apiKey:t,apiToken:n,customerId:o,tenantId:a,logoUrl:u,headerText:c,headerConfig:d,entryMessage:C,theme:f,globalClassName:m,openLinksInNewTab:p,searchPlaceholder:Y,searchButtonLabel:D,searchConfig:q,suggestionButtonConfig:re,messageAlignment:me,autoScroll:V,componentConfig:_,clientContext:v,baseCatalogParams:H,disclaimerMarkdown:P,disclaimerText:A,resetConversationMessage:ce,conversationHistory:de,isDevelopment:T,__features:K,children:x.jsx(kk,{entryType:w,componentConfig:_,componentType:y,children:x.jsx(DC,{onCopilotEvent:Te,children:x.jsx(vk,{children:x.jsx(Tk,{children:x.jsx(xk,{children:x.jsx(Dk,{promptsConfig:oe,children:x.jsx(Ik,{apiKey:t,apiToken:n,baseUrl:r,customerId:o,tenantId:a,isDevelopment:T,entryType:w,onConnect:ne,onRefinedSearch:Pe,onRefinedBrowse:se,onCopilotEvent:Te,children:ie})})})})})})})});var Nf={exports:{}},Dn={},Of={exports:{}},If={};var C1;function Mk(){return C1||(C1=1,(function(e){function t(K,ie){var k=K.length;K.push(ie);e:for(;0<k;){var L=k-1>>>1,ee=K[L];if(0<o(ee,ie))K[L]=ie,K[k]=ee,k=L;else break e}}function n(K){return K.length===0?null:K[0]}function r(K){if(K.length===0)return null;var ie=K[0],k=K.pop();if(k!==ie){K[0]=k;e:for(var L=0,ee=K.length,I=ee>>>1;L<I;){var Se=2*(L+1)-1,je=K[Se],Ee=Se+1,Be=K[Ee];if(0>o(je,k))Ee<ee&&0>o(Be,je)?(K[L]=Be,K[Ee]=k,L=Ee):(K[L]=je,K[Se]=k,L=Se);else if(Ee<ee&&0>o(Be,k))K[L]=Be,K[Ee]=k,L=Ee;else break e}}return ie}function o(K,ie){var k=K.sortIndex-ie.sortIndex;return k!==0?k:K.id-ie.id}if(typeof performance=="object"&&typeof performance.now=="function"){var a=performance;e.unstable_now=function(){return a.now()}}else{var u=Date,c=u.now();e.unstable_now=function(){return u.now()-c}}var d=[],f=[],p=1,m=null,T=3,y=!1,_=!1,w=!1,C=typeof setTimeout=="function"?setTimeout:null,A=typeof clearTimeout=="function"?clearTimeout:null,P=typeof setImmediate!="undefined"?setImmediate:null;typeof navigator!="undefined"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function v(K){for(var ie=n(f);ie!==null;){if(ie.callback===null)r(f);else if(ie.startTime<=K)r(f),ie.sortIndex=ie.expirationTime,t(d,ie);else break;ie=n(f)}}function H(K){if(w=!1,v(K),!_)if(n(d)!==null)_=!0,Pe(Y);else{var ie=n(f);ie!==null&&se(H,ie.startTime-K)}}function Y(K,ie){_=!1,w&&(w=!1,A(re),re=-1),y=!0;var k=T;try{for(v(ie),m=n(d);m!==null&&(!(m.expirationTime>ie)||K&&!oe());){var L=m.callback;if(typeof L=="function"){m.callback=null,T=m.priorityLevel;var ee=L(m.expirationTime<=ie);ie=e.unstable_now(),typeof ee=="function"?m.callback=ee:m===n(d)&&r(d),v(ie)}else r(d);m=n(d)}if(m!==null)var I=!0;else{var Se=n(f);Se!==null&&se(H,Se.startTime-ie),I=!1}return I}finally{m=null,T=k,y=!1}}var D=!1,q=null,re=-1,me=5,V=-1;function oe(){return!(e.unstable_now()-V<me)}function ce(){if(q!==null){var K=e.unstable_now();V=K;var ie=!0;try{ie=q(!0,K)}finally{ie?de():(D=!1,q=null)}}else D=!1}var de;if(typeof P=="function")de=function(){P(ce)};else if(typeof MessageChannel!="undefined"){var ne=new MessageChannel,Te=ne.port2;ne.port1.onmessage=ce,de=function(){Te.postMessage(null)}}else de=function(){C(ce,0)};function Pe(K){q=K,D||(D=!0,de())}function se(K,ie){re=C(function(){K(e.unstable_now())},ie)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(K){K.callback=null},e.unstable_continueExecution=function(){_||y||(_=!0,Pe(Y))},e.unstable_forceFrameRate=function(K){0>K||125<K?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):me=0<K?Math.floor(1e3/K):5},e.unstable_getCurrentPriorityLevel=function(){return T},e.unstable_getFirstCallbackNode=function(){return n(d)},e.unstable_next=function(K){switch(T){case 1:case 2:case 3:var ie=3;break;default:ie=T}var k=T;T=ie;try{return K()}finally{T=k}},e.unstable_pauseExecution=function(){},e.unstable_requestPaint=function(){},e.unstable_runWithPriority=function(K,ie){switch(K){case 1:case 2:case 3:case 4:case 5:break;default:K=3}var k=T;T=K;try{return ie()}finally{T=k}},e.unstable_scheduleCallback=function(K,ie,k){var L=e.unstable_now();switch(typeof k=="object"&&k!==null?(k=k.delay,k=typeof k=="number"&&0<k?L+k:L):k=L,K){case 1:var ee=-1;break;case 2:ee=250;break;case 5:ee=1073741823;break;case 4:ee=1e4;break;default:ee=5e3}return ee=k+ee,K={id:p++,callback:ie,priorityLevel:K,startTime:k,expirationTime:ee,sortIndex:-1},k>L?(K.sortIndex=k,t(f,K),n(d)===null&&K===n(f)&&(w?(A(re),re=-1):w=!0,se(H,k-L))):(K.sortIndex=ee,t(d,K),_||y||(_=!0,Pe(Y))),K},e.unstable_shouldYield=oe,e.unstable_wrapCallback=function(K){var ie=T;return function(){var k=T;T=ie;try{return K.apply(this,arguments)}finally{T=k}}}})(If)),If}var k1;function Fk(){return k1||(k1=1,Of.exports=Mk()),Of.exports}var P1;function Bk(){if(P1)return Dn;P1=1;var e=Uo(),t=Fk();function n(i){for(var s="https://reactjs.org/docs/error-decoder.html?invariant="+i,l=1;l<arguments.length;l++)s+="&args[]="+encodeURIComponent(arguments[l]);return"Minified React error #"+i+"; visit "+s+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}var r=new Set,o={};function a(i,s){u(i,s),u(i+"Capture",s)}function u(i,s){for(o[i]=s,i=0;i<s.length;i++)r.add(s[i])}var c=!(typeof window=="undefined"||typeof window.document=="undefined"||typeof window.document.createElement=="undefined"),d=Object.prototype.hasOwnProperty,f=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,p={},m={};function T(i){return d.call(m,i)?!0:d.call(p,i)?!1:f.test(i)?m[i]=!0:(p[i]=!0,!1)}function y(i,s,l,h){if(l!==null&&l.type===0)return!1;switch(typeof s){case"function":case"symbol":return!0;case"boolean":return h?!1:l!==null?!l.acceptsBooleans:(i=i.toLowerCase().slice(0,5),i!=="data-"&&i!=="aria-");default:return!1}}function _(i,s,l,h){if(s===null||typeof s=="undefined"||y(i,s,l,h))return!0;if(h)return!1;if(l!==null)switch(l.type){case 3:return!s;case 4:return s===!1;case 5:return isNaN(s);case 6:return isNaN(s)||1>s}return!1}function w(i,s,l,h,E,b,S){this.acceptsBooleans=s===2||s===3||s===4,this.attributeName=h,this.attributeNamespace=E,this.mustUseProperty=l,this.propertyName=i,this.type=s,this.sanitizeURL=b,this.removeEmptyString=S}var C={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(i){C[i]=new w(i,0,!1,i,null,!1,!1)}),[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(i){var s=i[0];C[s]=new w(s,1,!1,i[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(i){C[i]=new w(i,2,!1,i.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(i){C[i]=new w(i,2,!1,i,null,!1,!1)}),"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(i){C[i]=new w(i,3,!1,i.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(i){C[i]=new w(i,3,!0,i,null,!1,!1)}),["capture","download"].forEach(function(i){C[i]=new w(i,4,!1,i,null,!1,!1)}),["cols","rows","size","span"].forEach(function(i){C[i]=new w(i,6,!1,i,null,!1,!1)}),["rowSpan","start"].forEach(function(i){C[i]=new w(i,5,!1,i.toLowerCase(),null,!1,!1)});var A=/[\-:]([a-z])/g;function P(i){return i[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(i){var s=i.replace(A,P);C[s]=new w(s,1,!1,i,null,!1,!1)}),"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(i){var s=i.replace(A,P);C[s]=new w(s,1,!1,i,"http://www.w3.org/1999/xlink",!1,!1)}),["xml:base","xml:lang","xml:space"].forEach(function(i){var s=i.replace(A,P);C[s]=new w(s,1,!1,i,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(function(i){C[i]=new w(i,1,!1,i.toLowerCase(),null,!1,!1)}),C.xlinkHref=new w("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach(function(i){C[i]=new w(i,1,!1,i.toLowerCase(),null,!0,!0)});function v(i,s,l,h){var E=C.hasOwnProperty(s)?C[s]:null;(E!==null?E.type!==0:h||!(2<s.length)||s[0]!=="o"&&s[0]!=="O"||s[1]!=="n"&&s[1]!=="N")&&(_(s,l,E,h)&&(l=null),h||E===null?T(s)&&(l===null?i.removeAttribute(s):i.setAttribute(s,""+l)):E.mustUseProperty?i[E.propertyName]=l===null?E.type===3?!1:"":l:(s=E.attributeName,h=E.attributeNamespace,l===null?i.removeAttribute(s):(E=E.type,l=E===3||E===4&&l===!0?"":""+l,h?i.setAttributeNS(h,s,l):i.setAttribute(s,l))))}var H=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,Y=Symbol.for("react.element"),D=Symbol.for("react.portal"),q=Symbol.for("react.fragment"),re=Symbol.for("react.strict_mode"),me=Symbol.for("react.profiler"),V=Symbol.for("react.provider"),oe=Symbol.for("react.context"),ce=Symbol.for("react.forward_ref"),de=Symbol.for("react.suspense"),ne=Symbol.for("react.suspense_list"),Te=Symbol.for("react.memo"),Pe=Symbol.for("react.lazy"),se=Symbol.for("react.offscreen"),K=Symbol.iterator;function ie(i){return i===null||typeof i!="object"?null:(i=K&&i[K]||i["@@iterator"],typeof i=="function"?i:null)}var k=Object.assign,L;function ee(i){if(L===void 0)try{throw Error()}catch(l){var s=l.stack.trim().match(/\n( *(at )?)/);L=s&&s[1]||""}return`
10
+ `+a)}}catch(u){}}throw r}})}_request(t,n){typeof t=="string"?(n=n||{},n.url=t):n=t||{},n=so(this.defaults,n);const{transitional:r,paramsSerializer:o,headers:a}=n;r!==void 0&&ml.assertOptions(r,{silentJSONParsing:En.transitional(En.boolean),forcedJSONParsing:En.transitional(En.boolean),clarifyTimeoutError:En.transitional(En.boolean),legacyInterceptorReqResOrdering:En.transitional(En.boolean),advertiseZstdAcceptEncoding:En.transitional(En.boolean),validateStatusUndefinedResolves:En.transitional(En.boolean)},!1),o!=null&&($.isFunction(o)?n.paramsSerializer={serialize:o}:ml.assertOptions(o,{encode:En.function,serialize:En.function},!0)),n.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?n.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:n.allowAbsoluteUrls=!0),ml.assertOptions(n,{baseUrl:En.spelling("baseURL"),withXsrfToken:En.spelling("withXSRFToken")},!0),n.method=(n.method||this.defaults.method||"get").toLowerCase();let u=a&&$.merge(a.common,a[n.method]);a&&$.forEach(["delete","get","head","post","put","patch","query","common"],_=>{delete a[_]}),n.headers=gn.concat(u,a);const c=[];let d=!0;this.interceptors.request.forEach(function(w){if(typeof w.runWhen=="function"&&w.runWhen(n)===!1)return;d=d&&w.synchronous;const C=n.transitional||yf;C&&C.legacyInterceptorReqResOrdering?c.unshift(w.fulfilled,w.rejected):c.push(w.fulfilled,w.rejected)});const f=[];this.interceptors.response.forEach(function(w){f.push(w.fulfilled,w.rejected)});let p,m=0,T;if(!d){const _=[$g.bind(this),void 0];for(_.unshift(...c),_.push(...f),T=_.length,p=Promise.resolve(n);m<T;)p=p.then(_[m++],_[m++]);return p}T=c.length;let y=n;for(;m<T;){const _=c[m++],w=c[m++];try{y=_(y)}catch(C){w.call(this,C);break}}try{p=$g.call(this,y)}catch(_){return Promise.reject(_)}for(m=0,T=f.length;m<T;)p=p.then(f[m++],f[m++]);return p}getUri(t){t=so(this.defaults,t);const n=Rg(t.baseURL,t.url,t.allowAbsoluteUrls,t);return xg(n,t.params,t.paramsSerializer)}};$.forEach(["delete","get","head","options"],function(t){ao.prototype[t]=function(n,r){return this.request(so(r||{},{method:t,url:n,data:r&&$.hasOwnProp(r,"data")?r.data:void 0}))}}),$.forEach(["post","put","patch","query"],function(t){function n(r){return function(a,u,c){return this.request(so(c||{},{method:t,headers:r?{"Content-Type":"multipart/form-data"}:{},url:a,data:u}))}}ao.prototype[t]=n(),t!=="query"&&(ao.prototype[t+"Form"]=n(!0))});let bC=class Zw{constructor(t){if(typeof t!="function")throw new TypeError("executor must be a function.");let n;this.promise=new Promise(function(a){n=a});const r=this;this.promise.then(o=>{if(!r._listeners)return;let a=r._listeners.length;for(;a-- >0;)r._listeners[a](o);r._listeners=null}),this.promise.then=o=>{let a;const u=new Promise(c=>{r.subscribe(c),a=c}).then(o);return u.cancel=function(){r.unsubscribe(a)},u},t(function(a,u,c){r.reason||(r.reason=new ba(a,u,c),n(r.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(t){if(this.reason){t(this.reason);return}this._listeners?this._listeners.push(t):this._listeners=[t]}unsubscribe(t){if(!this._listeners)return;const n=this._listeners.indexOf(t);n!==-1&&this._listeners.splice(n,1)}toAbortSignal(){const t=new AbortController,n=r=>{t.abort(r)};return this.subscribe(n),t.signal.unsubscribe=()=>this.unsubscribe(n),t.signal}static source(){let t;return{token:new Zw(function(o){t=o}),cancel:t}}};function TC(e){return function(n){return e.apply(null,n)}}function _C(e){return $.isObject(e)&&e.isAxiosError===!0}const Af={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511,WebServerIsDown:521,ConnectionTimedOut:522,OriginIsUnreachable:523,TimeoutOccurred:524,SslHandshakeFailed:525,InvalidSslCertificate:526};Object.entries(Af).forEach(([e,t])=>{Af[t]=e});function qg(e){const t=new ao(e),n=sg(ao.prototype.request,t);return $.extend(n,ao.prototype,t,{allOwnKeys:!0}),$.extend(n,t,null,{allOwnKeys:!0}),n.create=function(o){return qg(so(e,o))},n}const Mt=qg(ya);Mt.Axios=ao,Mt.CanceledError=ba,Mt.CancelToken=bC,Mt.isCancel=kg,Mt.VERSION=Sf,Mt.toFormData=cl,Mt.AxiosError=xe,Mt.Cancel=Mt.CanceledError,Mt.all=function(t){return Promise.all(t)},Mt.spread=TC,Mt.isAxiosError=_C,Mt.mergeConfig=so,Mt.AxiosHeaders=gn,Mt.formToJSON=e=>Cg($.isHTMLForm(e)?new FormData(e):e),Mt.getAdapter=jg.getAdapter,Mt.HttpStatusCode=Af,Mt.default=Mt;const{Axios:pU,AxiosError:mU,CanceledError:gU,isCancel:EU,CancelToken:yU,VERSION:bU,all:TU,Cancel:_U,isAxiosError:SU,spread:xU,toFormData:wU,AxiosHeaders:AU,HttpStatusCode:vU,formToJSON:CU,getAdapter:kU,mergeConfig:PU,create:NU}=Mt;class SC{constructor(t,n,r,o=!1,a,u){we(this,"CIMULATE_API_HEADER","x-cimulate-api-key");we(this,"CIMULATE_SEARCH_API_HOST","search.cimulate");we(this,"CIMULATE_SEARCH_API_PATH","api/v1");we(this,"baseApiUrl");we(this,"headers",{});we(this,"fetchConfig",()=>Je(this,null,function*(){try{const t=yield Mt.get(`${this.apiUrl}/configs/copilot`,{headers:this.headers}),{customer_config:n}=t.data,r=atob(n);return JSON.parse(r)}catch(t){throw console.error("Error fetching customer config:",t),t}}));we(this,"_mapCopilotUrlToSearchUrl",(t="",n=!1)=>{if(t.endsWith("io")){const o=new URL(t);return o.hostname=o.hostname.replace(/^copilot\./,"api."),o.origin}return n?`https://staging.${this.CIMULATE_SEARCH_API_HOST}.ai`:`https://prod.${this.CIMULATE_SEARCH_API_HOST}.ai`});if(n&&r||!n&&!r)throw new Error("Provide exactly one authentication method: either 'apiKey' or 'apiToken', but not both.");n?this.headers[this.CIMULATE_API_HEADER]=n:r&&(this.headers.Authorization=`Bearer ${r}`),a&&(this.headers["x-cimulate-customer-id"]=a),u&&(this.headers["Tenant-ID"]=u),this.baseApiUrl=this._mapCopilotUrlToSearchUrl(t,o)}get apiUrl(){return`${this.baseApiUrl}/${this.CIMULATE_SEARCH_API_PATH}`}}class xC{constructor(t,n,r,o=!1,a,u){we(this,"apiService");we(this,"config",null);we(this,"getConfig",()=>Je(this,null,function*(){if(this.config)return this.config;try{const t=yield this.apiService.fetchConfig();return this.config=t,this.config}catch(t){throw console.error("Failed to fetch customer config:",t),t}}));we(this,"getPid",t=>this.getProductFieldValue(t,"pidCol"));we(this,"getName",t=>this.getProductFieldValue(t,"nameCol"));we(this,"getDescription",t=>this.getProductFieldValue(t,"description"));we(this,"getBrand",t=>this.getProductFieldValue(t,"productBrandCol"));we(this,"getPrice",t=>this.getProductFieldValue(t,"priceCol"));we(this,"getRelativePdp",t=>this.getProductFieldValue(t,"relativePdpCol"));we(this,"getPdp",t=>this.getProductFieldValue(t,"pdpCol"));we(this,"getImage",t=>this.getProductFieldValue(t,"imageCol"));we(this,"getProductHiddenFields",()=>{const t=this.getProductField("productHiddenFields");return Array.isArray(t)?t:[]});we(this,"getProductField",t=>this.config?this.config[t]:"");we(this,"getProductFieldValue",(t,n)=>{const r=this.getProductField(n);return r&&t[r]||""});this.apiService=new SC(t,n,r,o,a,u)}getPriceDisplay(t){const n=this.getPrice(t);return n?typeof n=="string"?n.includes("$")?n:`$${n}`:typeof n=="number"?new Intl.NumberFormat("en-US",{style:"currency",currency:"USD"}).format(n):n:""}}const Ko=(e,t,n,...r)=>{if(!e)return;const o=["background: linear-gradient(90deg,rgba(253, 99, 99, 1) 0%, rgba(245, 139, 35, 1) 65%)","font-weight: bold","color: transparent","background-clip: text","text-fill-color: transparent"].join(";");console[t]("%c[cimulate-widget]",o,n,...r)};class wC{constructor(t=!1){we(this,"isDevelopment");we(this,"_log",(t,n,...r)=>{Ko(this.isDevelopment,t,n,...r)});this.isDevelopment=t}log(t,...n){this._log("log",t,...n)}warn(t,...n){this._log("warn",t,...n)}error(t,...n){this._log("error",t,...n)}info(t,...n){this._log("info",t,...n)}debug(t,...n){this._log("debug",t,...n)}}const AC={copilot:"Your Search Assistant",messaging:"Commerce Client"},Yg=B.createContext(null),vC=({mode:e,logoUrl:t,headerText:n,headerConfig:r,globalClassName:o="",entryMessage:a,openLinksInNewTab:u=!1,disclaimerText:c,disclaimerMarkdown:d,clientContext:f,baseCatalogParams:p,searchPlaceholder:m,searchButtonLabel:T,searchConfig:y,suggestionButtonConfig:_,messageAlignment:w="start",autoScroll:C=!0,componentConfig:A,conversationHistory:P,resetConversationMessage:v="",apiKey:H,apiToken:Y,baseUrl:D,customerId:q,tenantId:re,theme:me,isDevelopment:V,__features:oe,routingAttributes:ce,enableDownloadTranscript:de=!0,enableEscalationToAgent:ne=!1,children:Te})=>{const Pe=e==="messaging",se=B.useMemo(()=>{const Se=ce==null?void 0:ce.isCartMgmtSupported;return Se===!0||Se==="true"},[ce]),K=B.useMemo(()=>Pe?{config:null}:new xC(D,H,Y,V,q,re),[Pe,D,H,Y,V,q,re]),ie=B.useMemo(()=>new wC(V),[V]);B.useEffect(()=>{Pe||!K||K.config||K.getConfig()},[K,Pe]);const k=B.useMemo(()=>PA(me),[me]),L=B.useMemo(()=>{const Se=(y==null?void 0:y.placeholder)||m,je=(y==null?void 0:y.buttonLabel)||T;let Ee="icon";return y!=null&&y.buttonType?Ee=y.buttonType:T&&(Ee="text"),pe(F({},y||{}),{placeholder:Se,buttonLabel:je,buttonType:Ee})},[y,m,T]),ee=B.useMemo(()=>pe(F({},r||{}),{logoUrl:t||(r==null?void 0:r.logoUrl),headerText:(r==null?void 0:r.headerText)||n||AC[e!=null?e:"copilot"]}),[r,t,n,e]),I=B.useMemo(()=>({configModule:K,mode:e!=null?e:"copilot",headerConfig:ee,entryMessage:a,globalClassName:o,openLinksInNewTab:u,disclaimerText:c,disclaimerMarkdown:d,clientContext:f,baseCatalogParams:p,themeVariables:k,logger:ie,searchConfig:L,suggestionButtonConfig:_,messageAlignment:w,autoScroll:C,enableMinimize:!!(A!=null&&A.enableMinimize),enableDownloadTranscript:de,enableEscalationToAgent:ne,resetConversationMessage:v,conversationHistory:{sinceHours:typeof(P==null?void 0:P.sinceHours)=="number"?P.sinceHours:1,limit:P==null?void 0:P.limit},features:oe,isCartMgmtSupported:se}),[K,e,ee,a,o,f,p,c,d,u,L,_,w,C,A,de,ne,v,ie,k,P,oe,se]);return x.jsx(Yg.Provider,{value:I,children:Te})},rt=()=>{const e=B.useContext(Yg);if(!e)throw new Error("useConfig must be used within a ConfigProvider");return e};class CC{constructor(){we(this,"initialState",{connected:!1,mode:"embedded",entryType:"search",status:{type:"dialog",isOpen:!1,isMinimized:!1},dialog:{position:"bottom-left",isFullHeight:!1,width:""},modal:{isFullscreen:!1}});we(this,"connectedProxy");we(this,"modeProxy");we(this,"entryTypeProxy");we(this,"statusProxy");we(this,"dialogProxy");we(this,"modalProxy",{isFullscreen:!1});we(this,"_fullGet",(t,n)=>Reflect.get(t,n));we(this,"_fullSet",(t,n,r)=>{if(!(n in t))throw new Error(`Property ${n} does not exist on UIState`);return NC(n,r),Reflect.set(t,n,r)});this.connectedProxy=new Proxy({connected:this.initialState.connected},{get:this._fullGet,set:this._fullSet}),this.modeProxy=new Proxy({mode:this.initialState.mode},{get:this._fullGet,set:this._fullSet}),this.entryTypeProxy=new Proxy({entryType:this.initialState.entryType},{get:this._fullGet,set:this._fullSet}),this.statusProxy=new Proxy({type:this.initialState.status.type,isOpen:this.initialState.status.isOpen,isMinimized:this.initialState.status.isMinimized},{get:this._fullGet,set:this._fullSet}),this.dialogProxy=new Proxy({position:this.initialState.dialog.position,isFullHeight:this.initialState.dialog.isFullHeight,width:this.initialState.dialog.width},{get:this._fullGet,set:this._fullSet}),this.modalProxy=new Proxy({isFullscreen:this.initialState.modal.isFullscreen},{get:this._fullGet,set:this._fullSet})}get connected(){return this.connectedProxy.connected}get mode(){return this.modeProxy.mode}get isOpen(){return!!this.statusProxy.isOpen}get isMinimized(){return!!this.statusProxy.isMinimized}get type(){return this.statusProxy.type}get entryType(){return this.entryTypeProxy.entryType}get position(){return this.dialogProxy.position}get state(){return{connected:this.connected,mode:this.mode,entryType:this.entryType,status:{type:this.type,isOpen:this.isOpen,isMinimized:this.isMinimized},dialog:{position:this.position,isFullHeight:this.dialogProxy.isFullHeight,width:this.dialogProxy.width},modal:{isFullscreen:this.modalProxy.isFullscreen}}}}const et=new CC,uo=()=>et.connected,Ta=()=>et.isOpen,kC=e=>{window.addEventListener(uf,e)},PC=e=>{window.removeEventListener(uf,e)},NC=(e,t)=>{const n=new CustomEvent(uf,{detail:{property:e,value:t}});window.dispatchEvent(n)},OC=e=>{et.connectedProxy.connected=e},_a=e=>{if(!["ask_cim","search","browse","pdp"].includes(e))throw new Error(`Invalid entryType: "${e}". Must be 'ask_cim', 'search', 'browse', or 'pdp'.`);et.entryTypeProxy.entryType=e},ui=e=>{const t=et.statusProxy.isOpen,n=typeof e=="boolean"?e:!t;et.statusProxy.isOpen=n,n&&(et.statusProxy.isMinimized=!1)},gl=e=>{const t=et.statusProxy.isMinimized,n=typeof e=="boolean"?e:!t;et.statusProxy.isMinimized=n,n&&(et.statusProxy.isOpen=!1)},vf=e=>{et.modalProxy.isFullscreen=e},El=e=>{if(!["chat","dialog","modal"].includes(e))throw new Error(`Invalid type: ${e}. Must be 'chat', 'dialog', or 'modal'.`);et.statusProxy.type=e,e==="dialog"||e==="chat"?et.modeProxy.mode="embedded":et.modeProxy.mode="standalone"},Cf=e=>{const t=["top","top-left","top-right","bottom","bottom-left","bottom-right","left","right","center"];if(!t.includes(e))throw new Error(`Invalid position: ${e}. Must be one of ${t.join(", ")}.`);et.dialogProxy.position=e},IC=e=>{const t=et.dialogProxy.isFullHeight,n=typeof e=="boolean"?e:!t;et.dialogProxy.isFullHeight=n},RC=({onCopilotEvent:e,children:t,dispatch:n})=>{const{logger:r}=rt(),o=B.useCallback(v=>{n({type:mt.SET_COPILOT,payload:v})},[n]),a=B.useCallback(v=>{OC(v),n({type:mt.SET_CONNECTED,payload:v})},[n]),u=B.useCallback(()=>{n({type:mt.RESET_COPILOT,payload:{}})},[n]),c=B.useCallback(()=>{n({type:mt.RESET_STATE,payload:{}})},[n]),d=B.useCallback(v=>{r==null||r.log(`${v.name} event received`,v),n({type:mt.ADD_MESSAGE,payload:v}),v.bypassHandlers||e==null||e(v)},[e,r,n]),f=B.useCallback(v=>{n({type:mt.ADD_LOADING_MESSAGE,payload:v})},[n]),p=B.useCallback(v=>{n({type:mt.REMOVE_LOADING_MESSAGE,payload:v})},[n]),m=B.useCallback(v=>{d(v),f(v.id)},[d,f]),T=B.useCallback(v=>{n({type:mt.SET_ACTIVE_CONVERSATION_ID,payload:v})},[n]),y=B.useCallback(v=>{n({type:mt.ADD_CONVERSATION_ID,payload:v})},[n]),_=B.useCallback(v=>{n({type:mt.SET_CONVERSATION_IDS,payload:v})},[n]),w=B.useCallback(v=>{n({type:mt.SET_IMAGE_FILE,payload:v})},[n]),C=B.useCallback(v=>{n({type:mt.SET_ASK_CIM_PROMPTS,payload:v})},[n]),A=B.useCallback(v=>{n({type:mt.SET_CONVERSATION_HISTORY_LOADED,payload:v})},[n]),P=B.useMemo(()=>({setCopilot:o,setConnected:a,resetCopilot:u,resetCopilotState:c,addCopilotEvent:d,addLoadingMessage:f,removeLoadingMessage:p,handleCopilotRequestAck:m,setActiveConversationId:T,addConversationId:y,setConversationIds:_,setImageFile:w,setAskCimPrompts:C,setConversationHistoryLoaded:A}),[o,a,u,c,d,f,p,m,T,y,_,w,C,A]);return x.jsx(og.Provider,{value:P,children:t})};wA();const LC=(e,t)=>{const{type:n,payload:r}=t;if(n===mt.ADD_MESSAGE){const o=r;if(e.messages.push(o),o.eventSourceId){const a=e.groupedMessages.findIndex(u=>u.eventSourceId===o.eventSourceId);if(a!==-1){let u=e.groupedMessages[a].messages;u||(u=[]);const c=u.findIndex(d=>d.id===o.id);if(c!==-1){u[c]=o;return}u.push(o);return}else{e.groupedMessages.push({type:"group",eventSourceId:o.eventSourceId,messages:[o],createdAt:new Date(o.createdAt)});return}}e.groupedMessages.push({type:"individual",message:o,createdAt:new Date(o.createdAt)});return}switch(n){case mt.RESET_STATE:e.messages=ro.messages,e.groupedMessages=ro.groupedMessages,e.loadingMessages=ro.loadingMessages,e.imageFile=ro.imageFile,e.askCimPrompts=ro.askCimPrompts,e.conversationHistoryLoaded=ro.conversationHistoryLoaded;break;case mt.RESET_COPILOT:e.copilot=null;break;case mt.SET_COPILOT:e.copilot=r;break;case mt.SET_CONNECTED:e.connected=r;break;case mt.ADD_LOADING_MESSAGE:e.loadingMessages.add(r);break;case mt.REMOVE_LOADING_MESSAGE:e.loadingMessages.delete(r);break;case mt.SET_ACTIVE_CONVERSATION_ID:e.activeConversationId=r;break;case mt.ADD_CONVERSATION_ID:{const o=r;e.conversationIds.includes(o)||e.conversationIds.push(o)}break;case mt.SET_CONVERSATION_IDS:e.conversationIds=r;break;case mt.SET_IMAGE_FILE:e.imageFile=r;break;case mt.SET_ASK_CIM_PROMPTS:e.askCimPrompts.requestId=(r==null?void 0:r.requestId)||null,e.askCimPrompts.message=(r==null?void 0:r.message)||null;break;case mt.SET_CONVERSATION_HISTORY_LOADED:e.conversationHistoryLoaded=r;break}},DC=({onCopilotEvent:e,children:t})=>{const[n,r]=ng(LC,ro);return x.jsx(ig.Provider,{value:n,children:x.jsx(RC,{onCopilotEvent:e,dispatch:r,children:t})})};function MC(){var e=B.useRef(!0);return e.current?(e.current=!1,!0):e.current}function FC(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];e&&e.addEventListener&&e.addEventListener.apply(e,t)}function BC(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];e&&e.removeEventListener&&e.removeEventListener.apply(e,t)}var kf=typeof window!="undefined",Sa=function(e){B.useEffect(e,[])},UC=function(e){var t=B.useRef(e);t.current=e,Sa(function(){return function(){return t.current()}})},HC=function(e){var t=B.useRef(0),n=B.useState(e),r=n[0],o=n[1],a=B.useCallback(function(u){cancelAnimationFrame(t.current),t.current=requestAnimationFrame(function(){o(u)})},[]);return UC(function(){cancelAnimationFrame(t.current)}),[r,a]},zC=function(e,t){return e===t};function jC(e,t){t===void 0&&(t=zC);var n=B.useRef(),r=B.useRef(e),o=MC();return!o&&!t(r.current,e)&&(n.current=r.current,r.current=e),n.current}var $C=function(e){var t={},n=t.initialWidth,r=n===void 0?1/0:n,o=t.initialHeight,a=o===void 0?1/0:o,u=t.onChange,c=HC({width:kf?window.innerWidth:r,height:kf?window.innerHeight:a}),d=c[0],f=c[1];return B.useEffect(function(){if(kf){var p=function(){var m=window.innerWidth,T=window.innerHeight;f({width:m,height:T}),u&&u(m,T)};return FC(window,"resize",p),function(){BC(window,"resize",p)}}},[]),d};class VC{constructor(){we(this,"items",[]);we(this,"add",t=>{const n=this.first();n&&n.context===t.context&&this.remove(),this.items.push(t)});we(this,"remove",()=>this.items.shift());we(this,"first",()=>this.items.length>0?this.items[0]:null);we(this,"clear",()=>{this.items.length=0});we(this,"processQueue",t=>{new Array(yn.size).fill(1).forEach(()=>{const r=yn.first();r&&(t(r),yn.remove())})})}get size(){return this.items.length}}const yn=new VC,Wg=e=>{window.addEventListener(af,e)},Gg=e=>{window.removeEventListener(af,e)},qC=(e,t,n)=>{const r=new CustomEvent(af,{detail:{event:e,property:t,value:n}});window.dispatchEvent(r)},Xg=e=>{window.addEventListener(sf,e)},Kg=e=>{window.removeEventListener(sf,e)},YC=(e,t,n)=>{const r=new CustomEvent(sf,{detail:{event:e,property:t,value:n}});window.dispatchEvent(r)},Qg=e=>{window.addEventListener(of,e)},Jg=e=>{window.removeEventListener(of,e)},Zg=(e,t,n)=>{const r=new CustomEvent(of,{detail:{property:e,value:t,event:n}});window.dispatchEvent(r)},WC=e=>{window.addEventListener(cf,e)},GC=e=>{window.removeEventListener(cf,e)},yl=(e,t,n)=>{const r=new CustomEvent(cf,{detail:{property:e,value:t,event:n}});window.dispatchEvent(r)};class XC{constructor(){we(this,"initialParams",{categoryId:"",categoryName:"",page:null,pageSize:null,includeFacets:!0,facetFilters:{},rangeFilters:[],catalogSegment:null,pricebooks:null});we(this,"categoryIdProxy");we(this,"facetFiltersProxy");we(this,"rangeFiltersProxy");we(this,"catalogSegmentProxy");we(this,"pricebooksProxy");we(this,"_fullGet",(t,n)=>Reflect.get(t,n));we(this,"_fullSet",(t,n,r)=>{const o=CA[n];return YC(o,n,r),Reflect.set(t,n,r)});we(this,"updateFacetFiltersProxy",t=>new Proxy({facetFilters:t},{get:this._fullGet,set:this._fullSet}));we(this,"updateRangeFiltersProxy",t=>new Proxy({rangeFilters:t},{get:this._fullGet,set:this._fullSet}));we(this,"updatePricebooksProxy",t=>new Proxy({pricebooks:t},{get:this._fullGet,set:this._fullSet}));this.categoryIdProxy=new Proxy({categoryId:this.initialParams.categoryId,categoryName:this.initialParams.categoryName},{get:this._fullGet,set:this._fullSet}),this.facetFiltersProxy=this.updateFacetFiltersProxy(this.initialParams.facetFilters||{}),this.rangeFiltersProxy=this.updateRangeFiltersProxy(this.initialParams.rangeFilters||[]),this.catalogSegmentProxy=new Proxy({catalogSegment:this.initialParams.catalogSegment},{get:this._fullGet,set:this._fullSet}),this.pricebooksProxy=this.updatePricebooksProxy(this.initialParams.pricebooks||null)}get categoryId(){return this.categoryIdProxy.categoryId||""}get facetFilters(){return this.facetFiltersProxy.facetFilters||{}}get rangeFilters(){return this.rangeFiltersProxy.rangeFilters||[]}get catalogSegment(){return this.catalogSegmentProxy.catalogSegment||null}get pricebooks(){return this.pricebooksProxy.pricebooks||null}get state(){return{categoryId:this.categoryId,categoryName:this.categoryIdProxy.categoryName,facetFilters:this.facetFilters,rangeFilters:this.rangeFilters,catalogSegment:this.catalogSegment,pricebooks:this.pricebooks,page:this.initialParams.page,pageSize:this.initialParams.pageSize,includeFacets:this.initialParams.includeFacets}}}const lt=new XC,e1=(e,t)=>{const n=t.updateFacetFiltersProxy(e);t.facetFiltersProxy.facetFilters=n.facetFilters},t1=(e,t,n)=>{var u,c;const r=F({},((u=n.facetFiltersProxy)==null?void 0:u.facetFilters)||{});if(!!((c=r[e])!=null&&c.includes(t))){const d=r[e].filter(f=>f!==t);d.length>0?r[e]=d:delete r[e]}else r[e]=r[e]?[...r[e],t]:[t];const a=n.updateFacetFiltersProxy(r);n.facetFiltersProxy.facetFilters=a.facetFilters},n1=(e,t)=>{const n=t.updateRangeFiltersProxy(e);t.rangeFiltersProxy.rangeFilters=n.rangeFilters},r1=({field:e,value:t},n)=>{const[r,o]=Array.isArray(t)?t:[];if(typeof r=="undefined"||typeof o=="undefined")throw new Error("Range values must be an array with two numbers for min and max");const a=[...n.rangeFiltersProxy.rangeFilters||[]],u=a.findIndex(d=>d.field===e);if(u!==-1){a[u]={field:e,min:r,max:o},n.rangeFiltersProxy.rangeFilters=a;return}a.push({field:e,min:r,max:o});const c=n.updateRangeFiltersProxy(a);n.rangeFiltersProxy.rangeFilters=c.rangeFilters},i1=(e,t)=>{t.catalogSegmentProxy.catalogSegment=e},o1=(e,t)=>{const n=t.updatePricebooksProxy(e);t.pricebooksProxy.pricebooks=n.pricebooks},KC=e=>{if(!uo()||!Ta()){uo()&&yn.clear(),yn.add({context:"browse",payload:pe(F({},lt.state),{categoryId:e})});return}lt.categoryIdProxy.categoryId=e},s1=e=>{e1(e,lt)},QC=(e,t)=>{t1(e,t,lt)},a1=e=>{n1(e,lt)},JC=({field:e,value:t})=>{r1({field:e,value:t},lt)},ZC=e=>{i1(e,lt)},u1=e=>{o1(e,lt)},l1=e=>{if(!e||!("categoryId"in e))throw new Error("Browse context must include a categoryId");const t=uo(),n=Ta();if(!t||!n){t&&yn.clear(),yn.add({context:"browse",payload:F({},e)});return}"facetFilters"in e&&s1(e.facetFilters||{}),"rangeFilters"in e&&a1(e.rangeFilters||[]),"catalogSegment"in e&&(lt.catalogSegmentProxy.catalogSegment=e.catalogSegment||null),"pricebooks"in e&&u1(e.pricebooks||[]),"categoryName"in e&&(lt.categoryIdProxy.categoryName=e.categoryName||""),lt.categoryIdProxy.categoryId=e.categoryId},ek=Object.freeze(Object.defineProperty({__proto__:null,setBrowseContext:l1,updateBrowseCategoryId:KC,updateCatalogSegment:ZC,updateFacetFilter:QC,updateFacetFilters:s1,updatePricebooks:u1,updateRangeFilter:JC,updateRangeFilters:a1},Symbol.toStringTag,{value:"Module"}));class tk{constructor(){we(this,"initialParams",{productId:"",productName:"",pdpLink:""});we(this,"proxy");we(this,"_fullGet",(t,n)=>Reflect.get(t,n));we(this,"_fullSet",(t,n,r)=>(Zg(n,r),Reflect.set(t,n,r)));we(this,"updateProxy",t=>{t.productId&&(this.proxy=new Proxy({productId:t.productId,productName:t.productName||"",pdpLink:t.pdpLink||""},{get:this._fullGet,set:this._fullSet}))});this.proxy=new Proxy({productId:this.initialParams.productId,productName:this.initialParams.productName,pdpLink:this.initialParams.pdpLink},{get:this._fullGet,set:this._fullSet})}get productId(){return this.proxy.productId}get pdpLink(){return this.proxy.pdpLink}get state(){return{productId:this.productId,productName:this.proxy.productName,pdpLink:this.pdpLink}}}const Sr=new tk,c1=e=>{if(!e||!e.productId)throw new Error("PDP context must include a productId");const t=uo(),n=Ta();if(!t||!n){t&&yn.clear(),yn.add({context:"pdp",payload:F({},e)});return}Sr.updateProxy(e),Zg("pdp-context",e)},nk=e=>{Sr.proxy.productId=e,uo()||yn.add({context:"pdp",payload:F({},Sr.state)})},rk=e=>{Sr.proxy.pdpLink=e},gt={SET_PROMPTS_EXTENSION_INITIALIZED:"SET_PROMPTS_EXTENSION_INITIALIZED",SET_PROMPTS_EXTENSION_OPEN:"SET_PROMPTS_EXTENSION_OPEN",SET_PROMPTS_EXTENSION_INLINE:"SET_PROMPTS_EXTENSION_INLINE",SET_PROMPTS_EXTENSION_ELEMENT_ID:"SET_PROMPTS_EXTENSION_ELEMENT_ID",SET_PROMPTS_EXTENSION_ENTRY_TYPE:"SET_PROMPTS_EXTENSION_ENTRY_TYPE",SET_PROMPTS_EXTENSION_PARAMS:"SET_PROMPTS_EXTENSION_PARAMS",RESET_PROMPTS_EXTENSION_PARAMS:"RESET_PROMPTS_EXTENSION_PARAMS",SET_PROMPTS_EXTENSION_ACTIVE_PROMPTS_ID:"SET_PROMPTS_EXTENSION_ACTIVE_PROMPTS_ID",RESET_PROMPTS_EXTENSION_ACTIVE_PROMPTS_ID:"RESET_PROMPTS_EXTENSION_ACTIVE_PROMPTS_ID",SET_PROMPTS_EXTENSION_USER_PROMPT:"SET_PROMPTS_EXTENSION_USER_PROMPT",SET_PROMPTS_EXTENSION_PROMPTS_MESSAGE:"SET_PROMPTS_EXTENSION_PROMPTS_MESSAGE",RESET_PROMPTS_EXTENSION_PROMPTS_MESSAGE:"RESET_PROMPTS_EXTENSION_PROMPTS_MESSAGE",SET_PROMPTS_EXTENSION_RESPONSE_MESSAGE:"SET_PROMPTS_EXTENSION_RESPONSE_MESSAGE",RESET_PROMPTS_EXTENSION_RESPONSE_MESSAGE:"RESET_PROMPTS_EXTENSION_RESPONSE_MESSAGE",SET_PROMPTS_EXTENSION_RESPONSE_LOADING:"SET_PROMPTS_EXTENSION_RESPONSE_LOADING"},d1={isInitialized:!1,isOpen:!1,isInline:!1,elementId:null,placeholder:null,askElseButtonLabel:null,entryType:null,params:null,activePromptsId:null,userPrompt:null,promptsMessage:null,isResponseLoading:!1,responseMessage:null,promptsDisplay:"both",disableAskElseButton:!1};class ik{constructor(){we(this,"initialState",d1);we(this,"promptsStateProxy");we(this,"promptsParamsProxy");we(this,"_fullGet",(t,n)=>Reflect.get(t,n));we(this,"_fullSet",(t,n,r)=>{if(!(n in t))throw new Error(`Property ${n} does not exist on PromptsExtensionState`);return xa(n,r),Reflect.set(t,n,r)});we(this,"_paramsFullGet",(t,n)=>Reflect.get(t,n));we(this,"_paramsFullSet",(t,n,r)=>Reflect.set(t,n,r));we(this,"updatePromptsParamsProxy",t=>new Proxy(F({},t),{get:this._paramsFullGet,set:this._paramsFullSet}));this.promptsStateProxy=new Proxy({isOpen:this.initialState.isOpen,isInline:this.initialState.isInline,elementId:this.initialState.elementId,entryType:this.initialState.entryType},{get:this._fullGet,set:this._fullSet}),this.promptsParamsProxy=this.updatePromptsParamsProxy({})}get isOpen(){return this.promptsStateProxy.isOpen}get isInline(){return this.promptsStateProxy.isInline}get state(){return{isOpen:this.isOpen,isInline:this.isInline}}get params(){return this.promptsParamsProxy}}const zt=new ik,ok=e=>{window.addEventListener(lf,e)},sk=e=>{window.removeEventListener(lf,e)},xa=(e,t)=>{const n=new CustomEvent(lf,{detail:{property:e,value:t}});window.dispatchEvent(n)},f1=e=>{const t=zt.isOpen,n=typeof e=="boolean"?e:!t;zt.promptsStateProxy.isOpen=n},h1=e=>{const t=zt.isInline,n=typeof e=="boolean"?e:!t;zt.promptsStateProxy.isInline=n},ak=e=>{zt.promptsParamsProxy=zt.updatePromptsParamsProxy(e),xa("params",e),zt.promptsStateProxy.entryType="ask_cim"},uk=e=>{zt.promptsParamsProxy=zt.updatePromptsParamsProxy(e),xa("params",e),zt.promptsStateProxy.entryType="search"},lk=e=>{zt.promptsParamsProxy=zt.updatePromptsParamsProxy(e),xa("params",e),zt.promptsStateProxy.entryType="browse"},ck=e=>{zt.promptsParamsProxy=zt.updatePromptsParamsProxy(e),xa("params",e),zt.promptsStateProxy.entryType="pdp"},dk=({elementId:e,entryType:t,params:n,isInline:r})=>{zt.promptsStateProxy.elementId=e,t&&(zt.promptsStateProxy.entryType=t),typeof r=="boolean"&&h1(r),n&&zt.updatePromptsParamsProxy(n),zt.isOpen||f1(!0)},fk=Object.freeze(Object.defineProperty({__proto__:null,getConversationMessages:({payload:e,callback:t})=>{yl("getConversationMessages",{payload:e,callback:t},Ci.GET_CONVERSATION_MESSAGES)},getSessionInformation:e=>{yl("getSessionInformation",{callback:e},Ci.GET_SESSION_INFORMATION)},loadConversation:e=>{yl("loadConversation",e,Ci.LOAD_CONVERSATION)},resetConversation:()=>{yl("resetConversation",!0,Ci.RESET_CONVERSATION)}},Symbol.toStringTag,{value:"Module"}));class hk{constructor(){we(this,"initialParams",{query:"",page:null,pageSize:null,includeFacets:!0,facetFilters:{},rangeFilters:[],catalogSegment:null,pricebooks:null});we(this,"queryProxy");we(this,"facetFiltersProxy");we(this,"rangeFiltersProxy");we(this,"catalogSegmentProxy");we(this,"pricebooksProxy");we(this,"_fullGet",(t,n)=>Reflect.get(t,n));we(this,"_fullSet",(t,n,r)=>{const o=kA[n];return qC(o,n,r),Reflect.set(t,n,r)});we(this,"updateFacetFiltersProxy",t=>new Proxy({facetFilters:t},{get:this._fullGet,set:this._fullSet}));we(this,"updateRangeFiltersProxy",t=>new Proxy({rangeFilters:t},{get:this._fullGet,set:this._fullSet}));we(this,"updatePricebooksProxy",t=>new Proxy({pricebooks:t},{get:this._fullGet,set:this._fullSet}));this.queryProxy=new Proxy({query:this.initialParams.query},{get:this._fullGet,set:this._fullSet}),this.facetFiltersProxy=this.updateFacetFiltersProxy(this.initialParams.facetFilters||{}),this.rangeFiltersProxy=this.updateRangeFiltersProxy(this.initialParams.rangeFilters||[]),this.catalogSegmentProxy=new Proxy({catalogSegment:this.initialParams.catalogSegment},{get:this._fullGet,set:this._fullSet}),this.pricebooksProxy=this.updatePricebooksProxy(this.initialParams.pricebooks||null)}get query(){return this.queryProxy.query||""}get facetFilters(){return this.facetFiltersProxy.facetFilters||{}}get rangeFilters(){return this.rangeFiltersProxy.rangeFilters||[]}get catalogSegment(){return this.catalogSegmentProxy.catalogSegment||null}get pricebooks(){return this.pricebooksProxy.pricebooks||null}get state(){return{query:this.query,facetFilters:this.facetFilters,rangeFilters:this.rangeFilters,catalogSegment:this.catalogSegment,pricebooks:this.pricebooks,page:this.initialParams.page,pageSize:this.initialParams.pageSize,includeFacets:this.initialParams.includeFacets}}}const Tt=new hk,pk=e=>{const t=Ta(),n=uo();if(!n||!t){n&&yn.clear(),yn.add({context:"search",payload:pe(F({},Tt.state),{query:e})});return}Tt.queryProxy.query=e},p1=e=>{e1(e,Tt)},mk=(e,t)=>{t1(e,t,Tt)},m1=e=>{n1(e,Tt)},gk=({field:e,value:t})=>{r1({field:e,value:t},Tt)},Ek=e=>{i1(e,Tt)},g1=e=>{o1(e,Tt)},E1=e=>{if(!e||!e.query)throw new Error("Search context must include a query");const t=Ta(),n=uo();if(!n||!t){n&&yn.clear(),yn.add({context:"search",payload:F({},e)});return}"facetFilters"in e&&p1(e.facetFilters||{}),"rangeFilters"in e&&m1(e.rangeFilters||[]),"catalogSegment"in e&&(Tt.catalogSegmentProxy.catalogSegment=e.catalogSegment||null),"pricebooks"in e&&g1(e.pricebooks||[]),Tt.queryProxy.query=e.query},yk=Object.freeze(Object.defineProperty({__proto__:null,setSearchContext:E1,updateCatalogSegment:Ek,updateFacetFilter:mk,updateFacetFilters:p1,updatePricebooks:g1,updateRangeFilter:gk,updateRangeFilters:m1,updateSearchQuery:pk},Symbol.toStringTag,{value:"Module"})),bk={categoryId:lt.categoryId,categoryName:lt.categoryIdProxy.categoryName||"",facetFilters:lt.facetFilters,rangeFilters:lt.rangeFilters,catalogSegment:lt.catalogSegment,pricebooks:lt.pricebooks},y1=B.createContext(bk),Tk=({children:e})=>{const[t,n]=B.useState(lt.categoryId),[r,o]=B.useState(lt.categoryIdProxy.categoryName||""),[a,u]=B.useState(lt.facetFilters||{}),[c,d]=B.useState(lt.rangeFilters||[]),[f,p]=B.useState(lt.catalogSegment||null),[m,T]=B.useState(lt.pricebooks||null);B.useEffect(()=>{const _=({detail:w})=>{(w==null?void 0:w.property)==="categoryId"&&n(w.value),(w==null?void 0:w.property)==="categoryName"&&o(w.value),(w==null?void 0:w.property)==="facetFilters"&&u(w.value),(w==null?void 0:w.property)==="rangeFilters"&&d(w.value),(w==null?void 0:w.property)==="catalogSegment"&&p(w.value),(w==null?void 0:w.property)==="pricebooks"&&T(w.value)};return Xg(_),()=>{Kg(_)}},[]);const y=B.useMemo(()=>({categoryId:t,categoryName:r,facetFilters:a,rangeFilters:c,catalogSegment:f,pricebooks:m}),[t,r,a,c,f,m]);return x.jsx(y1.Provider,{value:y,children:e})},_k=()=>{const e=B.useContext(y1);if(!e)throw new Error("useBrowse must be used within a BrowseProvider");return e},Sk={searchQuery:Tt.query,facetFilters:Tt.facetFilters,rangeFilters:Tt.rangeFilters,catalogSegment:Tt.catalogSegment,pricebooks:Tt.pricebooks},b1=B.createContext(Sk),xk=({children:e})=>{const[t,n]=B.useState(Tt.query),[r,o]=B.useState(Tt.facetFilters),[a,u]=B.useState(Tt.rangeFilters),[c,d]=B.useState(Tt.catalogSegment),[f,p]=B.useState(Tt.pricebooks);B.useEffect(()=>{const T=({detail:y})=>{(y==null?void 0:y.property)==="query"&&n(y.value),(y==null?void 0:y.property)==="facetFilters"&&o(y.value),(y==null?void 0:y.property)==="rangeFilters"&&u(y.value),(y==null?void 0:y.property)==="catalogSegment"&&d(y.value),(y==null?void 0:y.property)==="pricebooks"&&p(y.value)};return Wg(T),()=>{Gg(T)}},[]);const m=B.useMemo(()=>({searchQuery:t,facetFilters:r,rangeFilters:a,catalogSegment:c,pricebooks:f}),[t,r,a,c,f]);return x.jsx(b1.Provider,{value:m,children:e})},wk=()=>{const e=B.useContext(b1);if(!e)throw new Error("useSearch must be used within a SearchProvider");return e},Ak={productId:Sr.productId,pdpLink:Sr.pdpLink},T1=B.createContext(Ak),vk=({children:e})=>{const[t,n]=B.useState(Sr.productId),[r,o]=B.useState(Sr.pdpLink);B.useEffect(()=>{const u=({detail:c})=>{if((c==null?void 0:c.property)==="pdp-context"){const d=c.value;n(d.productId),o(d.pdpLink);return}(c==null?void 0:c.property)==="productId"&&n(c.value),(c==null?void 0:c.property)==="pdpLink"&&o(c.value)};return Qg(u),()=>{Jg(u)}},[]);const a=B.useMemo(()=>({productId:t,pdpLink:r}),[t,r]);return x.jsx(T1.Provider,{value:a,children:e})},Ck=()=>{const e=B.useContext(T1);if(!e)throw new Error("usePdp must be used within a PdpProvider");return e},_1=B.createContext({mode:et.modeProxy.mode,entryType:et.entryType,status:et.statusProxy,dialogPosition:et.dialogProxy.position,isDialogFullHeight:et.dialogProxy.isFullHeight,dialogWidth:et.dialogProxy.width,isModalFullscreen:et.modalProxy.isFullscreen,previousComponentType:et.statusProxy.type}),kk=({entryType:e,componentConfig:t,componentType:n,children:r})=>{const[o,a]=B.useState(e!=null?e:et.entryTypeProxy.entryType),[u,c]=B.useState(et.modeProxy.mode),[d,f]=B.useState({type:n||et.statusProxy.type,isOpen:et.statusProxy.isOpen,isMinimized:et.statusProxy.isMinimized}),[p,m]=B.useState(et.dialogProxy.position),[T,y]=B.useState(et.dialogProxy.isFullHeight),[_,w]=B.useState(et.dialogProxy.width),[C,A]=B.useState(et.modalProxy.isFullscreen),P=jC(d.type);B.useEffect(()=>{const H=Y=>{const{property:D,value:q}=Y.detail||{};if(!(!D||q===void 0)){if(D==="mode"){c(q);return}if(D==="entryType"){a(q);return}if(D==="isMinimized"){f(re=>pe(F({},re),{isMinimized:q}));return}if(D==="isOpen"){f(re=>pe(F({},re),{isOpen:q}));return}if(D==="type"){f(re=>pe(F({},re),{type:q}));return}if(D==="position"){m(q);return}if(D==="isFullHeight"){y(q);return}if(D==="width"){w(q);return}if(D==="isFullscreen"){A(q);return}}};return kC(H),()=>{PC(H)}},[]),Sa(()=>{e&&_a(e)}),Sa(()=>{const H=n||(t==null?void 0:t.type);H&&El(H),t&&"isOpen"in t&&ui(!!t.isOpen),t&&"isMinimized"in t&&gl(!!t.isMinimized)}),Sa(()=>{if(!(t!=null&&t.options))return;const{dialogPosition:H}=t.options;H&&Cf(H),"dialogFullHeight"in t.options&&IC(!!t.options.dialogFullHeight),"dialogWidth"in t.options&&t.options.dialogWidth&&w(t.options.dialogWidth),"isModalFullscreen"in t.options&&vf(!!t.options.isModalFullscreen)});const v=B.useMemo(()=>({mode:u,entryType:o,status:d,previousComponentType:P||"dialog",dialogPosition:p,isDialogFullHeight:T,dialogWidth:_,isModalFullscreen:C}),[u,o,d,P,p,T,_,C]);return x.jsx(_1.Provider,{value:v,children:r})},sr=()=>{const e=B.useContext(_1);if(!e)throw new Error("useUIState must be used within a UIStateProvider");return e},S1=B.createContext(null),x1=B.createContext(null),Pf=()=>{const e=B.useContext(x1);if(!e)throw new Error("usePromptsExtensionDispatch must be used within a PromptsExtensionProvider");return e||{}},li=()=>{const e=B.useContext(S1);if(!e)throw new Error("usePromptsExtensionState must be used within a PromptsExtensionProvider");return e||{}},Qo=()=>{const e=B.useContext(og);if(!e)throw new Error("useCopilotDispatch must be used within a CopilotProvider");return e},ar=()=>{const e=B.useContext(ig);if(!e)throw new Error("useCopilotState must be used within a CopilotProvider");return e},Pk=({copilot:e})=>{const{logger:t,conversationHistory:n}=rt(),{isInline:r}=li(),{addCopilotEvent:o,setConversationHistoryLoaded:a}=Qo(),{activeConversationId:u}=ar(),c=B.useCallback(f=>{e&&e.requestSessionInformation(p=>{t==null||t.log("Retrieved session information: ",p),f==null||f(p)})},[e,t]),d=B.useCallback((f,p)=>{e&&f.conversationId&&e.getConversationEvents(f,m=>{t==null||t.log("Retrieved conversation messages: ",m),p==null||p(m)})},[e,t]);return B.useEffect(()=>{if(r||!u)return;if(n.sinceHours===0||(n==null?void 0:n.limit)===0){a(!0);return}const f=3600*1e3*n.sinceHours,p=new Date(Date.now()-f).toISOString(),m={conversationId:u,since:p,excludeEvents:["done","error","connection_error","refined_browse","refined_search","conversation_reset"]};typeof n.limit=="number"&&(m.limit=n.limit),d(m,T=>{const y=[];[...T.reverse()||[]].forEach(w=>{var A;const C=T.find(P=>P.id===w.eventSourceId);(A=C==null?void 0:C.name)!=null&&A.endsWith("_suggestions")||(w.bypassHandlers=!0,y.unshift(w))}),y.forEach(w=>{o(w)}),a(!0)})},[t,r,u,d,o,a,n]),{getSessionInformation:c,getConversationMessages:d}},w1=B.createContext({copilot:null,messages:[],groupedMessages:[],isLoading:!1,isResponseLoading:()=>!1,handleAskCim:()=>{},handleSearch:()=>{},handleBrowse:()=>{},handlePdp:()=>{},handleSuggestion:()=>{},handleUserInput:()=>{},handleCancel:()=>{},resetConversation:()=>{},getSessionInformation:()=>{},getConversationMessages:()=>{}}),Nk=({apiKey:e,apiToken:t,baseUrl:n,customerId:r,tenantId:o,isDevelopment:a,onConnect:u,onRefinedSearch:c,onRefinedBrowse:d,children:f})=>{const{logger:p,clientContext:m,baseCatalogParams:T}=rt(),cn=wk(),{searchQuery:y}=cn,_=mn(cn,["searchQuery"]),Hn=_k(),{categoryId:w}=Hn,C=mn(Hn,["categoryId"]),{productId:A,pdpLink:P}=Ck(),{setCopilot:v,setConnected:H,resetCopilot:Y,resetCopilotState:D,addCopilotEvent:q,removeLoadingMessage:re,handleCopilotRequestAck:me,setActiveConversationId:V,setConversationIds:oe,setAskCimPrompts:ce}=Qo(),{connected:de,copilot:ne,messages:Te,groupedMessages:Pe,loadingMessages:se,askCimPrompts:K}=ar(),{status:ie,entryType:k}=sr(),{isInline:L}=li(),{getConversationMessages:ee,getSessionInformation:I}=Pk({copilot:ne}),Se=B.useMemo(()=>se.size>0,[se]),je=B.useCallback(Ae=>se.has(Ae),[se]),Ee=B.useCallback(({query:Ae,facetFilters:Oe,rangeFilters:Me,catalogSegment:ot,pricebooks:pt,userPrompt:J,imageFile:ge})=>{if(!ne){p==null||p.error("Copilot is not initialized");return}if(!Ae)return;const Ce={searchParams:{query:Ae}};J&&(Ce.userPrompt=J),ge&&(Ce.attachments={image:ge}),Oe&&Object.keys(Oe).length>0&&(Ce.searchParams.facetFilters=Oe),Me&&Me.length>0&&(Ce.searchParams.rangeFilters=Me),ot&&(Ce.searchParams.catalogSegment=ot),pt&&(Ce.searchParams.pricebooks=pt),m&&(Ce.clientContext=m),_a("search"),ne.search(Ce,Ye=>{const Re=F({},Ye);me(Re)})},[p,me,ne,m]),Be=B.useCallback(({categoryId:Ae,categoryName:Oe,facetFilters:Me,rangeFilters:ot,catalogSegment:pt,pricebooks:J,userPrompt:ge,imageFile:Ce})=>{if(!ne){p==null||p.error("Copilot is not initialized");return}const Ye=Me&&Object.keys(Me).length>0;if(Ae===""&&!Ye){p==null||p.error("Browse event must include facetFilters when categoryId is empty");return}const Re={browseParams:{categoryId:Ae||""}};ge&&(Re.userPrompt=ge),Ce&&(Re.attachments={image:Ce}),Ye&&(Re.browseParams.facetFilters=Me),ot&&ot.length>0&&(Re.browseParams.rangeFilters=ot),pt&&(Re.browseParams.catalogSegment=pt),Array.isArray(J)&&J.length>0&&(Re.browseParams.pricebooks=J),(m||Oe)&&(Re.clientContext={},m&&(Re.clientContext=F({},m)),Oe&&(Re.clientContext.cimLabel=Oe)),_a("browse"),ne.browse(Re,ct=>{var Qr;const Gt=F({},ct),Vt=((Qr=Gt.request)==null?void 0:Qr.clientContext)||{},dn=(Vt==null?void 0:Vt.cimLabel)||Oe;dn&&Gt.request&&(Gt.request.label=dn),me(Gt)})},[p,me,ne,m]),Ve=B.useCallback(({productId:Ae,productName:Oe,pdpLink:Me,userPrompt:ot,imageFile:pt})=>{if(!ne){p==null||p.error("Copilot is not initialized");return}if(!Ae)return;const J={productId:Ae};ot&&(J.userPrompt=ot),Me&&(J.pdpLink=Me),pt&&(J.attachments={image:pt}),(m||Oe)&&(J.clientContext={},m&&(J.clientContext=F({},m)),Oe&&(J.clientContext.cimLabel=Oe)),T&&(J.baseCatalogParams=T),_a("pdp"),ne.productView(J,ge=>{var ct;const Ce=F({},ge),Ye=((ct=Ce.request)==null?void 0:ct.clientContext)||{},Re=(Ye==null?void 0:Ye.cimLabel)||Oe;Re&&Ce.request&&(Ce.request.label=Re),me(Ce)})},[p,ne,me,m,T]),Ge=B.useCallback(({userPrompt:Ae,imageFile:Oe})=>{if(!ne){p==null||p.error("Copilot is not initialized");return}if(!Ae)return;const Me={userPrompt:Ae};Oe&&(Me.attachments={image:Oe}),m&&(Me.clientContext=m),T&&(Me.baseCatalogParams=T),ne.askCim(Me,ot=>{const pt=F({},ot);me(pt)})},[p,ne,me,m,T]),_t=B.useCallback(Ae=>{q(Ae),c==null||c(Ae)},[q,c]),Pn=B.useCallback(Ae=>{q(Ae),d==null||d(Ae)},[q,d]),ln=B.useCallback(Ae=>{u==null||u(Ae),H(!0)},[u,H]);B.useEffect(()=>{!ne||!de||!ie.isOpen||yn.size>0&&yn.processQueue(Ae=>{if(Ae.context==="search"){const Oe=F({},Ae.payload);E1(Oe)}if(Ae.context==="browse"){const Oe=F({},Ae.payload);l1(Oe)}if(Ae.context==="pdp"){const Oe=F({},Ae.payload);c1(Oe)}})},[ie.isOpen,ne,de]);const kr=B.useCallback(Ae=>{const Oe=Me=>{const ot=pe(F({},Me),{id:Me.inquiryLinkId||Me.id});q(ot)};Ae.on("connect_ack",ln),Ae.on("partial_inquiry",Oe),Ae.on("display_products",q),Ae.on("progress",q),Ae.on("refined_search",_t),Ae.on("refined_browse",Pn),Ae.on("done",Me=>{re(Me.eventSourceId)}),Ae.on("error",Me=>{q(Me),re(Me.eventSourceId)}),Ae.onDisconnect(Me=>{const ot=["io server disconnect","transport error","server shutting down"];if(p==null||p.log("Connection disconnected with reason: ",Me),!ot.includes(Me)){H(!1);return}p==null||p.log("De-registering event listeners");const pt=new Date().toISOString();q({name:"error",message:"Connection was lost. Please try again.",createdAt:pt,id:`error-${pt}`,sessionId:"session"}),Ae.off()})},[p,H,re,_t,Pn,q,ln]);B.useEffect(()=>{if(!ne)return;const Ae=Oe=>{if(!L){if(!Oe.message&&Oe.eventSourceId&&Oe.eventSourceId===K.requestId){ce({requestId:Oe.eventSourceId,message:Oe});return}q(Oe)}};return ne.on("follow_up",Ae),()=>{ne.off("follow_up",Ae)}},[ne,Te,K.requestId,L,q,ce]),B.useEffect(()=>{if(!ne)return;const Ae=Oe=>{if(L)return;const Me=pe(F({},Oe),{id:Oe.inquiryLinkId||Oe.id});q(Me)};return ne.on("inquiry",Ae),()=>{ne.off("inquiry",Ae)}},[ne,L,q]),Sa(()=>{let Ae;n?Ae=n:Ae=a?"https://staging.copilot.search.cimulate.ai":"https://prod.copilot.search.cimulate.ai";const Oe={baseUrl:Ae};e?Oe.apiKey=e:t&&(Oe.apiToken=t),r&&(Oe.customerId=r),o&&(Oe.tenantId=o);const Me=new hA(Oe);return v(Me),kr(Me),Me.connect(),Me.requestSessionInformation(ot=>{p==null||p.log("Session Information: ",ot);const{activeConversationId:pt,conversationIds:J}=ot.data||{};pt&&V(pt),J!=null&&J.length&&oe(J)}),()=>{Me.disconnect(),Me.off(),Y()}});const fr=B.useCallback(Ae=>{if(!ne)return;const Oe={eventId:Ae,reason:"User cancelled the request"};ne.cancelRequest(Oe,Me=>{q(Me),re(Ae)})},[q,re,ne]),rn=B.useCallback(()=>{ne&&ne.conversationReset({},Ae=>{D(),q(Ae),ne.requestSessionInformation(Oe=>{p==null||p.log("Session Information: ",Oe);const{activeConversationId:Me,conversationIds:ot}=Oe.data||{};Me&&V(Me),ot!=null&&ot.length&&oe(ot)})})},[ne,p,q,D,V,oe]),qe=B.useCallback((Ae,Oe)=>{if(!Ae)return;const Me={userPrompt:Ae};switch(Oe&&(Me.imageFile=Oe),k){case"ask_cim":Ge(Me);return;case"search":y?Ee(F(F({query:y},_),Me)):Ge(Me);return;case"browse":Be(F(F({categoryId:w},C),Me));return;case"pdp":A?Ve(F({productId:A,pdpLink:P||""},Me)):Ge(Me);return}},[k,y,_,Ee,Ge,w,C,Be,Ve,A,P]),Nt=B.useCallback((Ae,Oe)=>{var ge,Ce,Ye;const ot=Ae.params.userPrompt||"";if(!ot)return;const pt=Te.find(Re=>Re.id===Oe);if(!pt)return;const J=pt.name.replace("_suggestions","");if(J==="ask_cim"){Ge({userPrompt:ot});return}if(J==="copilot_search"){const Re=((ge=pt.request)==null?void 0:ge.searchParams)||{},Gt=Re.query===y;Ee(pe(F({query:Re.query||y},Gt?_:{}),{userPrompt:ot}));return}if(J==="copilot_browse"){const Re=pt.request,ct=Re.browseParams||{},Vt=ct.categoryId===w,dn=((Ce=Re.clientContext)==null?void 0:Ce.cimLabel)||"";Be(pe(F({categoryId:ct.categoryId||w||""},Vt?C:{}),{categoryName:dn,userPrompt:ot}));return}if(J==="product_view"){const Re=pt.request||{},ct=Re.productId,Gt=ct===A,Vt=((Ye=Re.clientContext)==null?void 0:Ye.cimLabel)||"";let dn="";Gt?dn=P||"":dn=Re.pdpLink||"",Ve({productId:ct||A,pdpLink:dn,productName:Vt,userPrompt:ot})}},[Te,y,_,Ee,Ge,w,C,Be,Ve,A,P]),Nn=B.useMemo(()=>({copilot:ne,messages:Te,groupedMessages:Pe,isLoading:Se,isResponseLoading:je,handleAskCim:Ge,handleSearch:Ee,handleBrowse:Be,handlePdp:Ve,handleUserInput:qe,handleSuggestion:Nt,handleCancel:fr,resetConversation:rn,getSessionInformation:I,getConversationMessages:ee}),[ne,Te,Pe,Se,je,Ge,Ee,Be,Ve,qe,Nt,fr,rn,I,ee]);return x.jsx(w1.Provider,{value:Nn,children:f})},A1=()=>{const{copilot:e}=ar(),{addCopilotEvent:t}=Qo();return{getCopilotSuggestions:B.useCallback((r,o,a)=>{if(!e||!o||!r)return;const u=c=>{t(c),a(c)};switch(o){case"ask_cim":e.askCimSuggestions(r,u);break;case"search":e.searchSuggestions({searchParams:r},u);break;case"browse":e.browseSuggestions({browseParams:r},u);break;case"pdp":e.productViewSuggestions({productId:r.productId},u);break}},[e,t])}},Ur=()=>{const e=B.useContext(w1);if(!e)throw new Error("useCopilot must be used within a CopilotProvider");return e},Ok=()=>{const{copilot:e,activeConversationId:t,askCimPrompts:n,conversationHistoryLoaded:r}=ar(),{entryType:o}=sr(),{resetCopilotState:a,addCopilotEvent:u,setAskCimPrompts:c}=Qo(),{handleSearch:d,handleBrowse:f,handlePdp:p,resetConversation:m,getSessionInformation:T,getConversationMessages:y}=Ur(),{getCopilotSuggestions:_}=A1();B.useEffect(()=>{!e||!o||!t||!r||n.requestId||o==="ask_cim"&&_({},o,P=>{c({requestId:P.id,message:null})})},[e,t,n.requestId,o,r,_,c]);const w=B.useCallback(({query:P})=>{if(!e||!P)return;const{facetFilters:v}=Tt.facetFiltersProxy,{rangeFilters:H}=Tt.rangeFiltersProxy,{catalogSegment:Y}=Tt.catalogSegmentProxy,{pricebooks:D}=Tt.pricebooksProxy,q={query:P};q.facetFilters=v||{},q.rangeFilters=H||[],q.catalogSegment=Y||"",q.pricebooks=D||[],d(F({},q))},[e,d]),C=B.useCallback(({categoryId:P})=>{if(!e)return;const v=lt.categoryIdProxy.categoryName,{facetFilters:H}=lt.facetFiltersProxy,{rangeFilters:Y}=lt.rangeFiltersProxy,{catalogSegment:D}=lt.catalogSegmentProxy,{pricebooks:q}=lt.pricebooksProxy,re={categoryId:P};re.categoryName=v||"",re.facetFilters=H||{},re.rangeFilters=Y||[],re.catalogSegment=D||"",re.pricebooks=q||[],f(F({},re))},[e,f]),A=B.useCallback(({productId:P})=>{if(!e||!P)return;const v={productId:P,pdpLink:Sr.pdpLink,productName:Sr.proxy.productName||""};p(v)},[e,p]);return B.useEffect(()=>{const P=({detail:v})=>{(v==null?void 0:v.property)==="query"&&w({query:v.value})};return Wg(P),()=>{Gg(P)}},[w]),B.useEffect(()=>{const P=({detail:v})=>{if((v==null?void 0:v.property)==="pdp-context"){const H=v.value;A({productId:H.productId});return}(v==null?void 0:v.property)==="productId"&&A({productId:v.value})};return Qg(P),()=>{Jg(P)}},[A]),B.useEffect(()=>{const P=({detail:v})=>{(v==null?void 0:v.property)==="categoryId"&&C({categoryId:v.value})};return Xg(P),()=>{Kg(P)}},[C]),B.useEffect(()=>{const P=({detail:v})=>{if((v==null?void 0:v.event)==Ci.RESET_CONVERSATION&&m(),(v==null?void 0:v.event)==Ci.GET_SESSION_INFORMATION){const H=v.value.callback;T(H)}if((v==null?void 0:v.event)==Ci.GET_CONVERSATION_MESSAGES){const{payload:H,callback:Y}=v.value;if(!H.conversationId||typeof Y!="function")return;y(H,Y)}if((v==null?void 0:v.event)==Ci.LOAD_CONVERSATION){const H=v.value;if(!H.conversationId)return;y(H,D=>{a(),D.forEach(q=>{u(q)})})}};return WC(P),()=>{GC(P)}},[m,T,y,a,u]),null},Ik=({apiKey:e,apiToken:t,baseUrl:n,customerId:r,tenantId:o,isDevelopment:a,onConnect:u,onRefinedSearch:c,onRefinedBrowse:d,children:f})=>x.jsxs(Nk,{apiKey:e,apiToken:t,baseUrl:n,customerId:r,tenantId:o,isDevelopment:a,onConnect:u,onRefinedSearch:c,onRefinedBrowse:d,children:[x.jsx(Ok,{}),f]}),Rk=({children:e,dispatch:t})=>{const n=B.useCallback(_=>{t({type:gt.SET_PROMPTS_EXTENSION_INITIALIZED,payload:_})},[t]),r=B.useCallback(_=>{t({type:gt.SET_PROMPTS_EXTENSION_OPEN,payload:_})},[t]),o=B.useCallback(_=>{t({type:gt.SET_PROMPTS_EXTENSION_INLINE,payload:_})},[t]),a=B.useCallback(_=>{t({type:gt.SET_PROMPTS_EXTENSION_ELEMENT_ID,payload:_})},[t]),u=B.useCallback(_=>{t({type:gt.SET_PROMPTS_EXTENSION_ENTRY_TYPE,payload:_})},[t]),c=B.useCallback(_=>{t({type:gt.SET_PROMPTS_EXTENSION_ACTIVE_PROMPTS_ID,payload:_})},[t]),d=B.useCallback(_=>{t({type:gt.SET_PROMPTS_EXTENSION_USER_PROMPT,payload:_})},[t]),f=B.useCallback(_=>{t({type:gt.SET_PROMPTS_EXTENSION_PARAMS,payload:_})},[t]),p=B.useCallback(_=>{t({type:gt.SET_PROMPTS_EXTENSION_PROMPTS_MESSAGE,payload:_})},[t]),m=B.useCallback(_=>{t({type:gt.SET_PROMPTS_EXTENSION_RESPONSE_MESSAGE,payload:_})},[t]),T=B.useCallback(_=>{t({type:gt.SET_PROMPTS_EXTENSION_RESPONSE_LOADING,payload:_})},[t]),y=B.useMemo(()=>({setIsInitialized:n,setIsOpen:r,setIsInline:o,setElementId:a,setEntryType:u,setActivePromptsId:c,setUserPrompt:d,setParams:f,setPromptsMessage:p,setResponseMessage:m,setIsResponseLoading:T}),[n,r,o,a,u,c,d,f,p,m,T]);return x.jsx(x1.Provider,{value:y,children:e})},Lk=(e,t)=>{const{type:n,payload:r}=t;switch(n){case gt.SET_PROMPTS_EXTENSION_INITIALIZED:e.isInitialized=r;break;case gt.SET_PROMPTS_EXTENSION_OPEN:e.isOpen=r;break;case gt.SET_PROMPTS_EXTENSION_INLINE:e.isInline=r;break;case gt.SET_PROMPTS_EXTENSION_ELEMENT_ID:e.elementId=r;break;case gt.SET_PROMPTS_EXTENSION_ENTRY_TYPE:e.entryType=r;break;case gt.SET_PROMPTS_EXTENSION_PARAMS:e.params=r;break;case gt.RESET_PROMPTS_EXTENSION_PARAMS:e.params=null;break;case gt.SET_PROMPTS_EXTENSION_USER_PROMPT:e.userPrompt=r;break;case gt.SET_PROMPTS_EXTENSION_ACTIVE_PROMPTS_ID:e.activePromptsId=r;break;case gt.RESET_PROMPTS_EXTENSION_ACTIVE_PROMPTS_ID:e.activePromptsId=null;break;case gt.SET_PROMPTS_EXTENSION_PROMPTS_MESSAGE:e.promptsMessage=r;break;case gt.RESET_PROMPTS_EXTENSION_PROMPTS_MESSAGE:e.promptsMessage=null;break;case gt.SET_PROMPTS_EXTENSION_RESPONSE_MESSAGE:e.responseMessage=r;break;case gt.RESET_PROMPTS_EXTENSION_RESPONSE_MESSAGE:e.responseMessage=null;break;case gt.SET_PROMPTS_EXTENSION_RESPONSE_LOADING:e.isResponseLoading=r;break}},Dk=({promptsConfig:e,children:t})=>{const[n,r]=ng(Lk,F(F({},d1),e||{}));return x.jsx(S1.Provider,{value:n,children:x.jsx(Rk,{dispatch:r,children:t})})},v1=({mode:e,apiKey:t,apiToken:n,baseUrl:r,customerId:o,tenantId:a,logoUrl:u,headerText:c,headerConfig:d,theme:f,openLinksInNewTab:p,globalClassName:m,isDevelopment:T=!1,componentType:y,componentConfig:_,entryType:w,entryMessage:C,disclaimerText:A,disclaimerMarkdown:P,clientContext:v,baseCatalogParams:H,searchPlaceholder:Y,searchButtonLabel:D,searchConfig:q,suggestionButtonConfig:re,messageAlignment:me,autoScroll:V,promptsConfig:oe,resetConversationMessage:ce,conversationHistory:de,onConnect:ne,onCopilotEvent:Te,onRefinedSearch:Pe,onRefinedBrowse:se,__features:K,children:ie})=>x.jsx(vC,{mode:e,baseUrl:r,apiKey:t,apiToken:n,customerId:o,tenantId:a,logoUrl:u,headerText:c,headerConfig:d,entryMessage:C,theme:f,globalClassName:m,openLinksInNewTab:p,searchPlaceholder:Y,searchButtonLabel:D,searchConfig:q,suggestionButtonConfig:re,messageAlignment:me,autoScroll:V,componentConfig:_,clientContext:v,baseCatalogParams:H,disclaimerMarkdown:P,disclaimerText:A,resetConversationMessage:ce,conversationHistory:de,isDevelopment:T,__features:K,children:x.jsx(kk,{entryType:w,componentConfig:_,componentType:y,children:x.jsx(DC,{onCopilotEvent:Te,children:x.jsx(vk,{children:x.jsx(Tk,{children:x.jsx(xk,{children:x.jsx(Dk,{promptsConfig:oe,children:x.jsx(Ik,{apiKey:t,apiToken:n,baseUrl:r,customerId:o,tenantId:a,isDevelopment:T,entryType:w,onConnect:ne,onRefinedSearch:Pe,onRefinedBrowse:se,onCopilotEvent:Te,children:ie})})})})})})})});var Nf={exports:{}},Dn={},Of={exports:{}},If={};var C1;function Mk(){return C1||(C1=1,(function(e){function t(K,ie){var k=K.length;K.push(ie);e:for(;0<k;){var L=k-1>>>1,ee=K[L];if(0<o(ee,ie))K[L]=ie,K[k]=ee,k=L;else break e}}function n(K){return K.length===0?null:K[0]}function r(K){if(K.length===0)return null;var ie=K[0],k=K.pop();if(k!==ie){K[0]=k;e:for(var L=0,ee=K.length,I=ee>>>1;L<I;){var Se=2*(L+1)-1,je=K[Se],Ee=Se+1,Be=K[Ee];if(0>o(je,k))Ee<ee&&0>o(Be,je)?(K[L]=Be,K[Ee]=k,L=Ee):(K[L]=je,K[Se]=k,L=Se);else if(Ee<ee&&0>o(Be,k))K[L]=Be,K[Ee]=k,L=Ee;else break e}}return ie}function o(K,ie){var k=K.sortIndex-ie.sortIndex;return k!==0?k:K.id-ie.id}if(typeof performance=="object"&&typeof performance.now=="function"){var a=performance;e.unstable_now=function(){return a.now()}}else{var u=Date,c=u.now();e.unstable_now=function(){return u.now()-c}}var d=[],f=[],p=1,m=null,T=3,y=!1,_=!1,w=!1,C=typeof setTimeout=="function"?setTimeout:null,A=typeof clearTimeout=="function"?clearTimeout:null,P=typeof setImmediate!="undefined"?setImmediate:null;typeof navigator!="undefined"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function v(K){for(var ie=n(f);ie!==null;){if(ie.callback===null)r(f);else if(ie.startTime<=K)r(f),ie.sortIndex=ie.expirationTime,t(d,ie);else break;ie=n(f)}}function H(K){if(w=!1,v(K),!_)if(n(d)!==null)_=!0,Pe(Y);else{var ie=n(f);ie!==null&&se(H,ie.startTime-K)}}function Y(K,ie){_=!1,w&&(w=!1,A(re),re=-1),y=!0;var k=T;try{for(v(ie),m=n(d);m!==null&&(!(m.expirationTime>ie)||K&&!oe());){var L=m.callback;if(typeof L=="function"){m.callback=null,T=m.priorityLevel;var ee=L(m.expirationTime<=ie);ie=e.unstable_now(),typeof ee=="function"?m.callback=ee:m===n(d)&&r(d),v(ie)}else r(d);m=n(d)}if(m!==null)var I=!0;else{var Se=n(f);Se!==null&&se(H,Se.startTime-ie),I=!1}return I}finally{m=null,T=k,y=!1}}var D=!1,q=null,re=-1,me=5,V=-1;function oe(){return!(e.unstable_now()-V<me)}function ce(){if(q!==null){var K=e.unstable_now();V=K;var ie=!0;try{ie=q(!0,K)}finally{ie?de():(D=!1,q=null)}}else D=!1}var de;if(typeof P=="function")de=function(){P(ce)};else if(typeof MessageChannel!="undefined"){var ne=new MessageChannel,Te=ne.port2;ne.port1.onmessage=ce,de=function(){Te.postMessage(null)}}else de=function(){C(ce,0)};function Pe(K){q=K,D||(D=!0,de())}function se(K,ie){re=C(function(){K(e.unstable_now())},ie)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(K){K.callback=null},e.unstable_continueExecution=function(){_||y||(_=!0,Pe(Y))},e.unstable_forceFrameRate=function(K){0>K||125<K?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):me=0<K?Math.floor(1e3/K):5},e.unstable_getCurrentPriorityLevel=function(){return T},e.unstable_getFirstCallbackNode=function(){return n(d)},e.unstable_next=function(K){switch(T){case 1:case 2:case 3:var ie=3;break;default:ie=T}var k=T;T=ie;try{return K()}finally{T=k}},e.unstable_pauseExecution=function(){},e.unstable_requestPaint=function(){},e.unstable_runWithPriority=function(K,ie){switch(K){case 1:case 2:case 3:case 4:case 5:break;default:K=3}var k=T;T=K;try{return ie()}finally{T=k}},e.unstable_scheduleCallback=function(K,ie,k){var L=e.unstable_now();switch(typeof k=="object"&&k!==null?(k=k.delay,k=typeof k=="number"&&0<k?L+k:L):k=L,K){case 1:var ee=-1;break;case 2:ee=250;break;case 5:ee=1073741823;break;case 4:ee=1e4;break;default:ee=5e3}return ee=k+ee,K={id:p++,callback:ie,priorityLevel:K,startTime:k,expirationTime:ee,sortIndex:-1},k>L?(K.sortIndex=k,t(f,K),n(d)===null&&K===n(f)&&(w?(A(re),re=-1):w=!0,se(H,k-L))):(K.sortIndex=ee,t(d,K),_||y||(_=!0,Pe(Y))),K},e.unstable_shouldYield=oe,e.unstable_wrapCallback=function(K){var ie=T;return function(){var k=T;T=ie;try{return K.apply(this,arguments)}finally{T=k}}}})(If)),If}var k1;function Fk(){return k1||(k1=1,Of.exports=Mk()),Of.exports}var P1;function Bk(){if(P1)return Dn;P1=1;var e=Uo(),t=Fk();function n(i){for(var s="https://reactjs.org/docs/error-decoder.html?invariant="+i,l=1;l<arguments.length;l++)s+="&args[]="+encodeURIComponent(arguments[l]);return"Minified React error #"+i+"; visit "+s+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}var r=new Set,o={};function a(i,s){u(i,s),u(i+"Capture",s)}function u(i,s){for(o[i]=s,i=0;i<s.length;i++)r.add(s[i])}var c=!(typeof window=="undefined"||typeof window.document=="undefined"||typeof window.document.createElement=="undefined"),d=Object.prototype.hasOwnProperty,f=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,p={},m={};function T(i){return d.call(m,i)?!0:d.call(p,i)?!1:f.test(i)?m[i]=!0:(p[i]=!0,!1)}function y(i,s,l,h){if(l!==null&&l.type===0)return!1;switch(typeof s){case"function":case"symbol":return!0;case"boolean":return h?!1:l!==null?!l.acceptsBooleans:(i=i.toLowerCase().slice(0,5),i!=="data-"&&i!=="aria-");default:return!1}}function _(i,s,l,h){if(s===null||typeof s=="undefined"||y(i,s,l,h))return!0;if(h)return!1;if(l!==null)switch(l.type){case 3:return!s;case 4:return s===!1;case 5:return isNaN(s);case 6:return isNaN(s)||1>s}return!1}function w(i,s,l,h,E,b,S){this.acceptsBooleans=s===2||s===3||s===4,this.attributeName=h,this.attributeNamespace=E,this.mustUseProperty=l,this.propertyName=i,this.type=s,this.sanitizeURL=b,this.removeEmptyString=S}var C={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(i){C[i]=new w(i,0,!1,i,null,!1,!1)}),[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(i){var s=i[0];C[s]=new w(s,1,!1,i[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(i){C[i]=new w(i,2,!1,i.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(i){C[i]=new w(i,2,!1,i,null,!1,!1)}),"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(i){C[i]=new w(i,3,!1,i.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(i){C[i]=new w(i,3,!0,i,null,!1,!1)}),["capture","download"].forEach(function(i){C[i]=new w(i,4,!1,i,null,!1,!1)}),["cols","rows","size","span"].forEach(function(i){C[i]=new w(i,6,!1,i,null,!1,!1)}),["rowSpan","start"].forEach(function(i){C[i]=new w(i,5,!1,i.toLowerCase(),null,!1,!1)});var A=/[\-:]([a-z])/g;function P(i){return i[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(i){var s=i.replace(A,P);C[s]=new w(s,1,!1,i,null,!1,!1)}),"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(i){var s=i.replace(A,P);C[s]=new w(s,1,!1,i,"http://www.w3.org/1999/xlink",!1,!1)}),["xml:base","xml:lang","xml:space"].forEach(function(i){var s=i.replace(A,P);C[s]=new w(s,1,!1,i,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(function(i){C[i]=new w(i,1,!1,i.toLowerCase(),null,!1,!1)}),C.xlinkHref=new w("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach(function(i){C[i]=new w(i,1,!1,i.toLowerCase(),null,!0,!0)});function v(i,s,l,h){var E=C.hasOwnProperty(s)?C[s]:null;(E!==null?E.type!==0:h||!(2<s.length)||s[0]!=="o"&&s[0]!=="O"||s[1]!=="n"&&s[1]!=="N")&&(_(s,l,E,h)&&(l=null),h||E===null?T(s)&&(l===null?i.removeAttribute(s):i.setAttribute(s,""+l)):E.mustUseProperty?i[E.propertyName]=l===null?E.type===3?!1:"":l:(s=E.attributeName,h=E.attributeNamespace,l===null?i.removeAttribute(s):(E=E.type,l=E===3||E===4&&l===!0?"":""+l,h?i.setAttributeNS(h,s,l):i.setAttribute(s,l))))}var H=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,Y=Symbol.for("react.element"),D=Symbol.for("react.portal"),q=Symbol.for("react.fragment"),re=Symbol.for("react.strict_mode"),me=Symbol.for("react.profiler"),V=Symbol.for("react.provider"),oe=Symbol.for("react.context"),ce=Symbol.for("react.forward_ref"),de=Symbol.for("react.suspense"),ne=Symbol.for("react.suspense_list"),Te=Symbol.for("react.memo"),Pe=Symbol.for("react.lazy"),se=Symbol.for("react.offscreen"),K=Symbol.iterator;function ie(i){return i===null||typeof i!="object"?null:(i=K&&i[K]||i["@@iterator"],typeof i=="function"?i:null)}var k=Object.assign,L;function ee(i){if(L===void 0)try{throw Error()}catch(l){var s=l.stack.trim().match(/\n( *(at )?)/);L=s&&s[1]||""}return`
11
11
  `+L+i}var I=!1;function Se(i,s){if(!i||I)return"";I=!0;var l=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{if(s)if(s=function(){throw Error()},Object.defineProperty(s.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(s,[])}catch(Z){var h=Z}Reflect.construct(i,[],s)}else{try{s.call()}catch(Z){h=Z}i.call(s.prototype)}else{try{throw Error()}catch(Z){h=Z}i()}}catch(Z){if(Z&&h&&typeof Z.stack=="string"){for(var E=Z.stack.split(`
12
12
  `),b=h.stack.split(`
13
13
  `),S=E.length-1,R=b.length-1;1<=S&&0<=R&&E[S]!==b[R];)R--;for(;1<=S&&0<=R;S--,R--)if(E[S]!==b[R]){if(S!==1||R!==1)do if(S--,R--,0>R||E[S]!==b[R]){var U=`
@@ -412,7 +412,7 @@ export declare interface MessagingModeConfig {
412
412
  /**
413
413
  * Shows a "Connect to a human agent" button in the messaging search bar that
414
414
  * asks the Agentforce agent to escalate the conversation to a human. Defaults
415
- * to true; set to false to hide it. Requires the org's Agentforce agent to be
415
+ * to false; set to true to show it. Requires the org's Agentforce agent to be
416
416
  * configured with an escalation path/topic, otherwise the button is a no-op.
417
417
  */
418
418
  enableEscalationToAgent?: boolean;
@@ -5533,7 +5533,7 @@ const oN = {
5533
5533
  __features: te,
5534
5534
  routingAttributes: re,
5535
5535
  enableDownloadTranscript: ce = !0,
5536
- enableEscalationToAgent: ae = !0,
5536
+ enableEscalationToAgent: ae = !1,
5537
5537
  children: ye
5538
5538
  }) => {
5539
5539
  const Ae = e === "messaging", oe = Y.useMemo(() => {
@@ -13,7 +13,7 @@
13
13
  `);return u===-1?"":o.stack.slice(u+1)})();try{if(!r.stack)r.stack=a;else if(a){const u=a.indexOf(`
14
14
  `),c=u===-1?-1:a.indexOf(`
15
15
  `,u+1),d=c===-1?"":a.slice(c+1);String(r.stack).endsWith(d)||(r.stack+=`
16
- `+a)}}catch(u){}}throw r}})}_request(t,n){typeof t=="string"?(n=n||{},n.url=t):n=t||{},n=Hi(this.defaults,n);const{transitional:r,paramsSerializer:o,headers:a}=n;r!==void 0&&Bu.assertOptions(r,{silentJSONParsing:Qt.transitional(Qt.boolean),forcedJSONParsing:Qt.transitional(Qt.boolean),clarifyTimeoutError:Qt.transitional(Qt.boolean),legacyInterceptorReqResOrdering:Qt.transitional(Qt.boolean),advertiseZstdAcceptEncoding:Qt.transitional(Qt.boolean),validateStatusUndefinedResolves:Qt.transitional(Qt.boolean)},!1),o!=null&&(W.isFunction(o)?n.paramsSerializer={serialize:o}:Bu.assertOptions(o,{encode:Qt.function,serialize:Qt.function},!0)),n.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?n.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:n.allowAbsoluteUrls=!0),Bu.assertOptions(n,{baseUrl:Qt.spelling("baseURL"),withXsrfToken:Qt.spelling("withXSRFToken")},!0),n.method=(n.method||this.defaults.method||"get").toLowerCase();let u=a&&W.merge(a.common,a[n.method]);a&&W.forEach(["delete","get","head","post","put","patch","query","common"],_=>{delete a[_]}),n.headers=Kt.concat(u,a);const c=[];let d=!0;this.interceptors.request.forEach(function(A){if(typeof A.runWhen=="function"&&A.runWhen(n)===!1)return;d=d&&A.synchronous;const C=n.transitional||Dd;C&&C.legacyInterceptorReqResOrdering?c.unshift(A.fulfilled,A.rejected):c.push(A.fulfilled,A.rejected)});const h=[];this.interceptors.response.forEach(function(A){h.push(A.fulfilled,A.rejected)});let p,m=0,b;if(!d){const _=[mg.bind(this),void 0];for(_.unshift(...c),_.push(...h),b=_.length,p=Promise.resolve(n);m<b;)p=p.then(_[m++],_[m++]);return p}b=c.length;let y=n;for(;m<b;){const _=c[m++],A=c[m++];try{y=_(y)}catch(C){A.call(this,C);break}}try{p=mg.call(this,y)}catch(_){return Promise.reject(_)}for(m=0,b=h.length;m<b;)p=p.then(h[m++],h[m++]);return p}getUri(t){t=Hi(this.defaults,t);const n=og(t.baseURL,t.url,t.allowAbsoluteUrls,t);return X0(n,t.params,t.paramsSerializer)}};W.forEach(["delete","get","head","options"],function(t){ji.prototype[t]=function(n,r){return this.request(Hi(r||{},{method:t,url:n,data:r&&W.hasOwnProp(r,"data")?r.data:void 0}))}}),W.forEach(["post","put","patch","query"],function(t){function n(r){return function(a,u,c){return this.request(Hi(c||{},{method:t,headers:r?{"Content-Type":"multipart/form-data"}:{},url:a,data:u}))}}ji.prototype[t]=n(),t!=="query"&&(ji.prototype[t+"Form"]=n(!0))});let iA=class h2{constructor(t){if(typeof t!="function")throw new TypeError("executor must be a function.");let n;this.promise=new Promise(function(a){n=a});const r=this;this.promise.then(o=>{if(!r._listeners)return;let a=r._listeners.length;for(;a-- >0;)r._listeners[a](o);r._listeners=null}),this.promise.then=o=>{let a;const u=new Promise(c=>{r.subscribe(c),a=c}).then(o);return u.cancel=function(){r.unsubscribe(a)},u},t(function(a,u,c){r.reason||(r.reason=new Ks(a,u,c),n(r.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(t){if(this.reason){t(this.reason);return}this._listeners?this._listeners.push(t):this._listeners=[t]}unsubscribe(t){if(!this._listeners)return;const n=this._listeners.indexOf(t);n!==-1&&this._listeners.splice(n,1)}toAbortSignal(){const t=new AbortController,n=r=>{t.abort(r)};return this.subscribe(n),t.signal.unsubscribe=()=>this.unsubscribe(n),t.signal}static source(){let t;return{token:new h2(function(o){t=o}),cancel:t}}};function oA(e){return function(n){return e.apply(null,n)}}function sA(e){return W.isObject(e)&&e.isAxiosError===!0}const zd={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511,WebServerIsDown:521,ConnectionTimedOut:522,OriginIsUnreachable:523,TimeoutOccurred:524,SslHandshakeFailed:525,InvalidSslCertificate:526};Object.entries(zd).forEach(([e,t])=>{zd[t]=e});function Eg(e){const t=new ji(e),n=I0(ji.prototype.request,t);return W.extend(n,ji.prototype,t,{allOwnKeys:!0}),W.extend(n,t,null,{allOwnKeys:!0}),n.create=function(o){return Eg(Hi(e,o))},n}const St=Eg(Xs);St.Axios=ji,St.CanceledError=Ks,St.CancelToken=iA,St.isCancel=eg,St.VERSION=Ud,St.toFormData=Ru,St.AxiosError=we,St.Cancel=St.CanceledError,St.all=function(t){return Promise.all(t)},St.spread=oA,St.isAxiosError=sA,St.mergeConfig=Hi,St.AxiosHeaders=Kt,St.formToJSON=e=>Z0(W.isHTMLForm(e)?new FormData(e):e),St.getAdapter=pg.getAdapter,St.HttpStatusCode=zd,St.default=St;const{Axios:f7,AxiosError:h7,CanceledError:p7,isCancel:m7,CancelToken:g7,VERSION:E7,all:y7,Cancel:T7,isAxiosError:b7,spread:x7,toFormData:_7,AxiosHeaders:w7,HttpStatusCode:S7,formToJSON:v7,getAdapter:A7,mergeConfig:k7,create:C7}=St;class aA{constructor(t,n,r,o=!1,a,u){qe(this,"CIMULATE_API_HEADER","x-cimulate-api-key");qe(this,"CIMULATE_SEARCH_API_HOST","search.cimulate");qe(this,"CIMULATE_SEARCH_API_PATH","api/v1");qe(this,"baseApiUrl");qe(this,"headers",{});qe(this,"fetchConfig",()=>je(this,null,function*(){try{const t=yield St.get(`${this.apiUrl}/configs/copilot`,{headers:this.headers}),{customer_config:n}=t.data,r=atob(n);return JSON.parse(r)}catch(t){throw console.error("Error fetching customer config:",t),t}}));qe(this,"_mapCopilotUrlToSearchUrl",(t="",n=!1)=>{if(t.endsWith("io")){const o=new URL(t);return o.hostname=o.hostname.replace(/^copilot\./,"api."),o.origin}return n?`https://staging.${this.CIMULATE_SEARCH_API_HOST}.ai`:`https://prod.${this.CIMULATE_SEARCH_API_HOST}.ai`});if(n&&r||!n&&!r)throw new Error("Provide exactly one authentication method: either 'apiKey' or 'apiToken', but not both.");n?this.headers[this.CIMULATE_API_HEADER]=n:r&&(this.headers.Authorization=`Bearer ${r}`),a&&(this.headers["x-cimulate-customer-id"]=a),u&&(this.headers["Tenant-ID"]=u),this.baseApiUrl=this._mapCopilotUrlToSearchUrl(t,o)}get apiUrl(){return`${this.baseApiUrl}/${this.CIMULATE_SEARCH_API_PATH}`}}class uA{constructor(t,n,r,o=!1,a,u){qe(this,"apiService");qe(this,"config",null);qe(this,"getConfig",()=>je(this,null,function*(){if(this.config)return this.config;try{const t=yield this.apiService.fetchConfig();return this.config=t,this.config}catch(t){throw console.error("Failed to fetch customer config:",t),t}}));qe(this,"getPid",t=>this.getProductFieldValue(t,"pidCol"));qe(this,"getName",t=>this.getProductFieldValue(t,"nameCol"));qe(this,"getDescription",t=>this.getProductFieldValue(t,"description"));qe(this,"getBrand",t=>this.getProductFieldValue(t,"productBrandCol"));qe(this,"getPrice",t=>this.getProductFieldValue(t,"priceCol"));qe(this,"getRelativePdp",t=>this.getProductFieldValue(t,"relativePdpCol"));qe(this,"getPdp",t=>this.getProductFieldValue(t,"pdpCol"));qe(this,"getImage",t=>this.getProductFieldValue(t,"imageCol"));qe(this,"getProductHiddenFields",()=>{const t=this.getProductField("productHiddenFields");return Array.isArray(t)?t:[]});qe(this,"getProductField",t=>this.config?this.config[t]:"");qe(this,"getProductFieldValue",(t,n)=>{const r=this.getProductField(n);return r&&t[r]||""});this.apiService=new aA(t,n,r,o,a,u)}getPriceDisplay(t){const n=this.getPrice(t);return n?typeof n=="string"?n.includes("$")?n:`$${n}`:typeof n=="number"?new Intl.NumberFormat("en-US",{style:"currency",currency:"USD"}).format(n):n:""}}const zi=(e,t,n,...r)=>{if(!e)return;const o=["background: linear-gradient(90deg,rgba(253, 99, 99, 1) 0%, rgba(245, 139, 35, 1) 65%)","font-weight: bold","color: transparent","background-clip: text","text-fill-color: transparent"].join(";");console[t]("%c[cimulate-widget]",o,n,...r)};class lA{constructor(t=!1){qe(this,"isDevelopment");qe(this,"_log",(t,n,...r)=>{zi(this.isDevelopment,t,n,...r)});this.isDevelopment=t}log(t,...n){this._log("log",t,...n)}warn(t,...n){this._log("warn",t,...n)}error(t,...n){this._log("error",t,...n)}info(t,...n){this._log("info",t,...n)}debug(t,...n){this._log("debug",t,...n)}}const cA={copilot:"Your Search Assistant",messaging:"Commerce Client"},yg=Y.createContext(null),dA=({mode:e,logoUrl:t,headerText:n,headerConfig:r,globalClassName:o="",entryMessage:a,openLinksInNewTab:u=!1,disclaimerText:c,disclaimerMarkdown:d,clientContext:h,baseCatalogParams:p,searchPlaceholder:m,searchButtonLabel:b,searchConfig:y,suggestionButtonConfig:_,messageAlignment:A="start",autoScroll:C=!0,componentConfig:v,conversationHistory:k,resetConversationMessage:R="",apiKey:j,apiToken:G,baseUrl:M,customerId:Z,tenantId:ue,theme:pe,isDevelopment:$,__features:te,routingAttributes:re,enableDownloadTranscript:de=!0,enableEscalationToAgent:ae=!0,children:ye})=>{const ve=e==="messaging",se=Y.useMemo(()=>{const Te=re==null?void 0:re.isCartMgmtSupported;return Te===!0||Te==="true"},[re]),z=Y.useMemo(()=>ve?{config:null}:new uA(M,j,G,$,Z,ue),[ve,M,j,G,$,Z,ue]),ee=Y.useMemo(()=>new lA($),[$]);Y.useEffect(()=>{ve||!z||z.config||z.getConfig()},[z,ve]);const w=Y.useMemo(()=>pS(pe),[pe]),N=Y.useMemo(()=>{const Te=(y==null?void 0:y.placeholder)||m,Ie=(y==null?void 0:y.buttonLabel)||b;let xe="icon";return y!=null&&y.buttonType?xe=y.buttonType:b&&(xe="text"),oe(U({},y||{}),{placeholder:Te,buttonLabel:Ie,buttonType:xe})},[y,m,b]),V=Y.useMemo(()=>oe(U({},r||{}),{logoUrl:t||(r==null?void 0:r.logoUrl),headerText:(r==null?void 0:r.headerText)||n||cA[e!=null?e:"copilot"]}),[r,t,n,e]),I=Y.useMemo(()=>({configModule:z,mode:e!=null?e:"copilot",headerConfig:V,entryMessage:a,globalClassName:o,openLinksInNewTab:u,disclaimerText:c,disclaimerMarkdown:d,clientContext:h,baseCatalogParams:p,themeVariables:w,logger:ee,searchConfig:N,suggestionButtonConfig:_,messageAlignment:A,autoScroll:C,enableMinimize:!!(v!=null&&v.enableMinimize),enableDownloadTranscript:de,enableEscalationToAgent:ae,resetConversationMessage:R,conversationHistory:{sinceHours:typeof(k==null?void 0:k.sinceHours)=="number"?k.sinceHours:1,limit:k==null?void 0:k.limit},features:te,isCartMgmtSupported:se}),[z,e,V,a,o,h,p,c,d,u,N,_,A,C,v,de,ae,R,ee,w,k,te,se]);return x.jsx(yg.Provider,{value:I,children:ye})},dt=()=>{const e=Y.useContext(yg);if(!e)throw new Error("useConfig must be used within a ConfigProvider");return e},fA=["markdown","product_carousel","product_tile","product_comparison","suggestions","cart","order_confirmation"],Uu=-1;function hA(e){if(!e||!e.trim())return null;try{const t=JSON.parse(e);if(t&&typeof t=="object"&&typeof t.type=="string"&&typeof t.index=="number")return fA.includes(t.type)?t:null}catch(t){}return{type:"markdown",index:Uu,data:{content:e}}}function pA(e,t){if(t.index===Uu){const o=e[e.length-1];if(o&&o.type==="markdown"&&o.index===Uu&&t.type==="markdown"){const a={type:"markdown",index:Uu,data:{content:o.data.content+t.data.content}};return[...e.slice(0,-1),a]}return[...e,t]}const n=e.findIndex(o=>o.index===t.index);return[...n>=0?e.map((o,a)=>a===n?t:o):[...e,t]].sort((o,a)=>o.index-a.index)}const Tg={connectionStatus:"disconnected",loading:!0,conversationId:null,messages:[],streamingBlocks:[],isAgentTyping:!1,progressMessage:"",progressSteps:[],routingResult:null,error:null,sendError:null,sessionExpired:!1};function mA(e,t){switch(t.type){case"SET_CONNECTION_STATUS":return U(oe(U({},e),{connectionStatus:t.status}),t.status==="connected"||t.status==="connecting"?{error:null}:{});case"SET_LOADING":return oe(U({},e),{loading:t.isLoading});case"SET_CONVERSATION_ID":return oe(U({},e),{conversationId:t.id});case"ADD_MESSAGE":return oe(U({},e),{messages:[...e.messages,oe(U({},t.message),{type:"ADD_MESSAGE"})]});case"APPEND_STREAMING_TOKEN":{const n=hA(t.token);return n?oe(U({},e),{streamingBlocks:pA(e.streamingBlocks,n)}):e}case"FLUSH_STREAMING":return oe(U({},e),{messages:[...e.messages,oe(U({},t.message),{type:"FLUSH_STREAMING"})],streamingBlocks:[],isAgentTyping:!1,loading:!1,progressMessage:"",progressSteps:[],sendError:null});case"SET_AGENT_TYPING":return oe(U({},e),{isAgentTyping:t.isTyping,loading:t.isTyping});case"SET_PROGRESS_MESSAGE":return U(oe(U({},e),{progressMessage:t.message}),t.message===""?{progressSteps:[]}:{});case"ADD_PROGRESS_STEP":return e.progressSteps[e.progressSteps.length-1]===t.message?e:oe(U({},e),{progressSteps:[...e.progressSteps,t.message],progressMessage:t.message});case"SET_ROUTING_RESULT":return oe(U({},e),{routingResult:t.result});case"SET_ERROR":return oe(U({},e),{error:t.error,loading:!1,progressMessage:"",progressSteps:[]});case"SET_SEND_ERROR":return oe(U({},e),{sendError:t.error,loading:!1,progressMessage:"",progressSteps:[]});case"CLEAR_SEND_ERROR":return oe(U({},e),{sendError:null});case"LOAD_HISTORY":return oe(U({},e),{messages:t.messages,loading:!1});case"SET_SESSION_EXPIRED":return oe(U({},e),{sessionExpired:t.expired});case"RESET":return oe(U({},Tg),{connectionStatus:e.connectionStatus,loading:!0});default:return e}}const bg=Y.createContext({connectionStatus:"disconnected",isConnected:!1,isAgentTyping:!1,conversationId:null,messages:[],streamingBlocks:[],progressMessage:"",progressSteps:[],loading:!0,error:null,sendError:null,sessionExpired:!1,sendMessage:()=>{},addToCart:()=>{},resetConversation:()=>{},retryLastMessage:()=>{},retryConnection:()=>{},downloadTranscript:()=>je(null,null,function*(){})});function $d(e,t){return`cim_af_conv_${e}_${t}`}function Vd(e,t){return Date.now()-e>t}function gA(e,t,n){try{const r=$d(e,t),o=sessionStorage.getItem(r);if(!o)return null;const a=JSON.parse(o);if(!a||typeof a!="object"||!("conversationId"in a)||!("storedAt"in a))return null;const u=a;return typeof u.conversationId!="string"||!u.conversationId?null:typeof u.storedAt!="number"||Vd(u.storedAt,n)?(sessionStorage.removeItem(r),null):u}catch(r){return null}}function Qs(e,t,n){try{const r=$d(e,t),o={conversationId:n,storedAt:Date.now()};sessionStorage.setItem(r,JSON.stringify(o))}catch(r){}}function Hu(e,t){try{const n=$d(e,t);sessionStorage.removeItem(n)}catch(n){}}function qd(e,t){return`cim_af_ct_${e}_${t}`}function xg(e,t,n){try{const r=qd(e,t),o=sessionStorage.getItem(r);if(!o)return null;const a=JSON.parse(o);if(!a||typeof a!="object"||!("accessToken"in a)||!("lastEventId"in a)||!("storedAt"in a))return null;const u=a;return typeof u.accessToken!="string"||!u.accessToken||typeof u.lastEventId!="string"||!u.lastEventId?null:typeof u.storedAt!="number"||Date.now()-u.storedAt>n?(sessionStorage.removeItem(r),null):u}catch(r){return null}}function EA(e,t,n,r){try{const o=qd(e,t),a={accessToken:n,lastEventId:r,storedAt:Date.now()};sessionStorage.setItem(o,JSON.stringify(a))}catch(o){}}function yA(e,t){try{const n=qd(e,t);sessionStorage.removeItem(n)}catch(n){}}function TA(e,t){return`cim_af_conv_${e}_${t}`}function bA(e,t){try{if(typeof BroadcastChannel=="undefined")return null;const n=TA(e,t);return new BroadcastChannel(n)}catch(n){return null}}function xA(e,t=500){return e?new Promise(n=>{let r=!1;const o=setTimeout(()=>{r||(r=!0,e.removeEventListener("message",a),n(null))},t);function a(u){var c;r||((c=u.data)==null?void 0:c.type)==="conversation_response"&&(r=!0,clearTimeout(o),e.removeEventListener("message",a),n({conversationId:u.data.conversationId,storedAt:u.data.storedAt,continuationToken:u.data.continuationToken,lastEventId:u.data.lastEventId}))}e.addEventListener("message",a);try{e.postMessage({type:"request_conversation"})}catch(u){r||(r=!0,clearTimeout(o),e.removeEventListener("message",a),n(null))}}):Promise.resolve(null)}function _A(e,t,n){if(!e)return()=>{};function r(o){var a;if((a=o.data)!=null&&a.type)switch(o.data.type){case"request_conversation":{const u=t();if(u!=null&&u.conversationId)try{e.postMessage({type:"conversation_response",conversationId:u.conversationId,storedAt:Date.now(),continuationToken:u.continuationToken,lastEventId:u.lastEventId})}catch(c){}break}case"conversation_cleared":{n==null||n();break}}}return e.addEventListener("message",r),()=>{e.removeEventListener("message",r)}}function wA(e){if(e)try{e.postMessage({type:"conversation_cleared"})}catch(t){}}function SA(e){if(e)try{e.close()}catch(t){}}function vA(e){switch(e){case"EndUser":case"Customer":return"user";case"Agent":case"Chatbot":return"agent";default:return"system"}}function AA(e){if(!e)return{};if(typeof e=="string")try{return JSON.parse(e)}catch(t){return{}}return e}function _g(e,...t){let n=e;for(const r of t){if(n==null||typeof n!="object")return"";n=n[r]}return typeof n=="string"?n:""}function kA(e){if(e.entryType!=="Message")return null;const n=AA(e.entryPayload).abstractMessage;if(!n)return null;const r=_g(n,"staticContent","text")||_g(n,"content","text")||"";if(!r)return null;const o=vA(e.sender.role);return{id:e.identifier,role:o,content:r,timestamp:new Date(e.transcriptedTimestamp).toISOString(),sender:{role:e.sender.role,name:e.senderDisplayName}}}function CA(e){const t=[];for(const n of e){const r=kA(n);r&&t.push(r)}return t}const wg="onCimulateWidgetReady",NA=5e3;function Js(e={}){const{routingAttributes:t,timeoutMs:n=NA}=e;if(typeof window=="undefined"||typeof window.dispatchEvent!="function")return Promise.resolve(t);const r=U({},t!=null?t:{});return new Promise(o=>{const a={settled:!1},u=()=>{if(a.settled)return;a.settled=!0,a.timer!==void 0&&clearTimeout(a.timer);const p=Object.keys(r).length>0;o(p?r:t)},c={routingAttributes:t,setHiddenPrechatFields:p=>{a.settled||!p||Object.assign(r,p)},done:u},d=new CustomEvent(wg,{detail:c,cancelable:!0});if(!!window.dispatchEvent(d)){u();return}a.timer=setTimeout(u,n)})}function OA(e){const{orgId:t,esDeveloperName:n,routingAttributes:r,conversationHistory:o}=e,a=Y.useRef(null),u=Y.useRef(null),c=Y.useRef(null),d=o.sinceHours*60*60*1e3,h=Y.useCallback(()=>(c.current||(c.current=xA(a.current)),c.current),[]);Y.useEffect(()=>{const C=bA(t,n);a.current=C,c.current=null;const v=_A(C,()=>{const k=u.current;if(!k)return null;const R=xg(t,n,d);return{conversationId:k,continuationToken:R==null?void 0:R.accessToken,lastEventId:R==null?void 0:R.lastEventId}},()=>{Hu(t,n),u.current=null});return()=>{v(),SA(C),a.current=null}},[t,n,d]);const p=Y.useCallback(C=>je(null,null,function*(){let v=gA(t,n,d);if(!v){const k=yield h();k&&!Vd(k.storedAt,d)&&(v=k)}if(!v){const k=yield C.createConversation(yield Js({routingAttributes:r}));return Qs(t,n,k),u.current=k,{conversationId:k,restoredMessages:[],resumed:!1}}try{const k=Date.now()-d,j=(yield C.listConversations({conversationId:v.conversationId,startTimestamp:k})).conversations.find(M=>M.conversationId===v.conversationId&&!M.isConversationClosed);if(!j){Hu(t,n);const M=yield C.createConversation(yield Js({routingAttributes:r}));return Qs(t,n,M),u.current=M,{conversationId:M,restoredMessages:[],resumed:!1}}C.resumeConversation(j.conversationId),u.current=j.conversationId,Qs(t,n,j.conversationId);let G=[];try{const M=yield C.listConversationEntries(j.conversationId,{limit:o.limit,startTimestamp:k,direction:"FromStart"});G=CA(M.conversationEntries)}catch(M){}return{conversationId:j.conversationId,restoredMessages:G,resumed:!0}}catch(k){Hu(t,n);const R=yield C.createConversation(yield Js({routingAttributes:r}));return Qs(t,n,R),u.current=R,{conversationId:R,restoredMessages:[],resumed:!1}}}),[t,n,r,o,d,h]),m=Y.useCallback(C=>{Qs(t,n,C),u.current=C},[t,n]),b=Y.useCallback(()=>{Hu(t,n),yA(t,n),wA(a.current),u.current=null},[t,n]),y=Y.useCallback(()=>{const C=xg(t,n,d);return C?{continuationToken:C.accessToken,lastEventId:C.lastEventId}:null},[t,n,d]),_=Y.useCallback(()=>je(null,null,function*(){const C=yield h();return!(C!=null&&C.continuationToken)||Vd(C.storedAt,d)?null:{continuationToken:C.continuationToken,lastEventId:C.lastEventId}}),[d,h]),A=Y.useCallback(C=>je(null,null,function*(){try{const{accessToken:v,lastEventId:k}=yield C.generateContinuationToken();EA(t,n,v,k)}catch(v){}}),[t,n]);return{initializeConversation:p,persistConversationId:m,clearPersistedConversation:b,getStoredConnectOptions:y,getPeerConnectOptions:_,persistContinuationToken:A}}const _r={default:"Something went wrong. Please try again.",server:"Something went wrong. Please try again.",rateLimit:"We are getting a lot of requests right now. Please try again in a moment.",network:"You are offline or we couldn't reach the assistant. Check connection and try again.",interrupted:"Something went wrong. Please try again.",connect:"You are offline or we couldn't reach the assistant. Check connection and try again.",lost:"You are offline or we couldn't reach the assistant. Check connection and try again.",routing:"Something went wrong. Please try again."};function PA(e){if(!e||typeof e!="object")return{};const t=e;return{type:typeof t.type=="string"?t.type:void 0,statusCode:typeof t.statusCode=="number"?t.statusCode:void 0}}function Ro(e){const{type:t,statusCode:n}=PA(e);if(t==="api"&&typeof n=="number")return n===429?_r.rateLimit:n>=500?_r.server:_r.default;switch(t){case"network":return _r.network;case"sse":return _r.interrupted;case"auth":return _r.connect;default:return _r.default}}function Sg(e){switch(e.code){case"MAX_RECONNECT":return _r.lost;case"ROUTING_FAILED":return _r.routing;default:return _r.connect}}const IA="Your session ended due to inactivity. Starting a new session…";function vg(e){if(!e||typeof e!="object")return!1;const t=e;return t.type==="auth"?!0:t.type==="api"&&(t.statusCode===401||t.statusCode===403)}function RA(e){var b;const t=e.productName||"this product",n=e.quantity&&e.quantity>1?e.quantity:void 0,r=((b=e.variants)!=null?b:[]).filter(y=>y.value),o=r.map(y=>`${y.label}: ${y.value}`).join(", "),a=r.map(y=>y.value).join(", "),u=o?` (${o})`:"",c=a?` (${a})`:"",d=n?`Add ${n} of`:"Add",h=e.sku?` [SKU: ${e.sku}]`:"",p=`${d} ${t} to my cart${u}${h}`,m=`Add ${n?`${n} × `:""}${t} to cart${c}`;return{prompt:p,display:m}}const Ag=({scrt2Url:e,orgId:t,esDeveloperName:n,routingAttributes:r,capabilitiesVersion:o,enableLogging:a=!1,onConnect:u,onMessage:c,onError:d,children:h})=>{const{logger:p,conversationHistory:m}=dt(),[b,y]=Y.useReducer(mA,Tg),_=Y.useRef(b);_.current=b;const A=OA({orgId:t,esDeveloperName:n,routingAttributes:r,conversationHistory:m}),C=Y.useRef(null),v=Y.useRef(c),k=Y.useRef(d),R=Y.useRef(u),j=Y.useRef(!1),G=Y.useRef(!1),M=Y.useRef(0),Z=Y.useRef(null);v.current=c,k.current=d,R.current=u,Y.useEffect(()=>{const z=new hS({baseURL:e,orgId:t,esDeveloperName:n,options:U({enableLogging:a},o?{capabilitiesVersion:o}:{})});C.current=z,z.on("connected",()=>{var w;y({type:"SET_CONNECTION_STATUS",status:"connected"}),(w=R.current)==null||w.call(R)}),z.on("disconnected",()=>{y({type:"SET_CONNECTION_STATUS",status:"disconnected"})}),z.on("reconnecting",()=>{y({type:"SET_CONNECTION_STATUS",status:"reconnecting"})}),z.on("message",w=>{var V;const N={id:w.messageId||crypto.randomUUID(),role:"agent",content:w.content,timestamp:w.timestamp,sender:w.sender,raw:w};p==null||p.log("🦜 MessagingProvider message received (FLUSH_STREAMING)",{messageId:N.id,tokensBeforeFlush:M.current,streamedFinalOnly:M.current===0}),M.current=0,y({type:"FLUSH_STREAMING",message:N}),(V=v.current)==null||V.call(v,N)}),z.on("streaming_token",w=>{M.current+=1,y({type:"APPEND_STREAMING_TOKEN",token:w.token})}),z.on("typing_started",()=>{y({type:"SET_AGENT_TYPING",isTyping:!0})}),z.on("typing_stopped",()=>{y({type:"SET_AGENT_TYPING",isTyping:!1})}),z.on("progress_indicator",w=>{y({type:"ADD_PROGRESS_STEP",message:w.message})}),z.on("routing_result",w=>{var N;if(y({type:"SET_ROUTING_RESULT",result:w}),!w.isSuccessful){const V=`Routing failed: ${w.failureType||"unknown"}`;y({type:"SET_ERROR",error:Sg({code:"ROUTING_FAILED"})}),y({type:"SET_CONNECTION_STATUS",status:"error"}),(N=k.current)==null||N.call(k,V)}}),z.on("participant_changed",w=>{if(w.participant.name==="Automated Process")return;const N={id:crypto.randomUUID(),role:"system",content:w.action==="add"?`${w.participant.name||"Agent"} joined the conversation`:`${w.participant.name||"Agent"} left the conversation`,timestamp:new Date().toISOString()};p==null||p.log("🦜 MessagingProvider participant_changed event received",{event:w}),y({type:"ADD_MESSAGE",message:N})}),z.on("conversation_closed",()=>{const w={id:crypto.randomUUID(),role:"system",content:"Conversation reset",timestamp:new Date().toISOString()};y({type:"ADD_MESSAGE",message:w}),y({type:"SET_CONVERSATION_ID",id:null}),A.clearPersistedConversation()}),z.on("error",w=>{var N;if(p==null||p.log("🦜 MessagingProvider ERROR event received",{event:w}),w.code==="SESSION_EXPIRED"){G.current=!0,y({type:"SET_SESSION_EXPIRED",expired:!0}),y({type:"SET_CONNECTION_STATUS",status:"disconnected"}),y({type:"SET_LOADING",isLoading:!1});return}y({type:"SET_ERROR",error:Sg(w)}),w.recoverable||y({type:"SET_CONNECTION_STATUS",status:"error"}),(N=k.current)==null||N.call(k,w.message)}),y({type:"SET_CONNECTION_STATUS",status:"connecting"});const ee=()=>je(null,null,function*(){let w=A.getStoredConnectOptions(),N=!1;w||(w=yield A.getPeerConnectOptions(),N=!!w);try{yield z.connect(w!=null?w:void 0)}catch(I){if(w)p==null||p.log("Continuation token failed, falling back to fresh connect"),N||A.clearPersistedConversation(),yield z.connect();else throw I}yield A.persistContinuationToken(z);const V=yield A.initializeConversation(z);y({type:"SET_CONVERSATION_ID",id:V.conversationId}),V.resumed&&V.restoredMessages.length>0&&y({type:"LOAD_HISTORY",messages:V.restoredMessages})});return Z.current=ee,ee().catch(w=>{var N;y({type:"SET_CONNECTION_STATUS",status:"error"}),y({type:"SET_ERROR",error:Ro(w)}),(N=k.current)==null||N.call(k,w.message)}),()=>{z.disconnect(),z.off(),C.current=null,Z.current=null}},[e,t,n,o]),Y.useEffect(()=>{const z=()=>{document.visibilityState==="visible"&&C.current&&!G.current&&C.current.reconnect()};return document.addEventListener("visibilitychange",z),()=>{document.removeEventListener("visibilitychange",z)}},[]);const ue=Y.useCallback(z=>je(null,null,function*(){var w;const ee=C.current;if(!(!ee||j.current)){j.current=!0,G.current=!1,y({type:"SET_SESSION_EXPIRED",expired:!1}),y({type:"ADD_MESSAGE",message:{id:crypto.randomUUID(),role:"system",content:IA,timestamp:new Date().toISOString()}}),A.clearPersistedConversation(),y({type:"SET_CONNECTION_STATUS",status:"connecting"});try{ee.disconnect(),yield ee.connect(),yield A.persistContinuationToken(ee);const N=yield ee.createConversation(yield Js({routingAttributes:r}));y({type:"SET_CONVERSATION_ID",id:N}),y({type:"SET_CONNECTION_STATUS",status:"connected"}),A.persistConversationId(N),z&&(y({type:"SET_LOADING",isLoading:!0}),y({type:"SET_PROGRESS_MESSAGE",message:""}),yield ee.sendMessage(z))}catch(N){const V=N instanceof Error?N.message:String(N);y({type:"SET_ERROR",error:Ro(N)}),y({type:"SET_CONNECTION_STATUS",status:"error"}),(w=k.current)==null||w.call(k,V)}finally{j.current=!1}}}),[r,A]),pe=Y.useRef(ue);pe.current=ue;const $=Y.useCallback((z,ee)=>{const w=C.current;if(!w)return;const N={id:crypto.randomUUID(),role:"user",content:ee!=null?ee:z,timestamp:new Date().toISOString()};if(y({type:"CLEAR_SEND_ERROR"}),y({type:"ADD_MESSAGE",message:N}),y({type:"SET_LOADING",isLoading:!0}),y({type:"SET_PROGRESS_MESSAGE",message:""}),G.current){pe.current(z);return}w.sendMessage(z).catch(V=>{var I;if(vg(V)){pe.current(z);return}y({type:"SET_SEND_ERROR",error:{text:z,displayContent:ee,message:Ro(V)}}),(I=k.current)==null||I.call(k,V.message)})},[]),te=Y.useCallback(z=>{z.trim()&&$(z)},[$]),re=Y.useCallback(z=>{if(!C.current)return;const{prompt:ee,display:w}=RA(z);$(ee,w)},[$]),de=Y.useCallback(()=>{const z=C.current,ee=_.current.sendError;if(!(!z||!ee)){if(y({type:"CLEAR_SEND_ERROR"}),y({type:"SET_LOADING",isLoading:!0}),y({type:"SET_PROGRESS_MESSAGE",message:""}),G.current){pe.current(ee.text);return}z.sendMessage(ee.text).catch(w=>{var N;if(vg(w)){pe.current(ee.text);return}y({type:"SET_SEND_ERROR",error:oe(U({},ee),{message:Ro(w)})}),(N=k.current)==null||N.call(k,w.message)})}},[]),ae=Y.useCallback(()=>{const z=C.current,ee=Z.current;!z||!ee||(G.current=!1,z.disconnect(),y({type:"SET_CONNECTION_STATUS",status:"connecting"}),ee().catch(w=>{var N;y({type:"SET_CONNECTION_STATUS",status:"error"}),y({type:"SET_ERROR",error:Ro(w)}),(N=k.current)==null||N.call(k,w.message)}))},[]),ye=Y.useCallback(()=>{const z=C.current;z&&(G.current=!1,A.clearPersistedConversation(),y({type:"RESET"}),y({type:"SET_CONNECTION_STATUS",status:"connecting"}),z.endConversation().then(()=>(z.disconnect(),z.connect())).then(()=>je(null,null,function*(){return yield A.persistContinuationToken(z),z.createConversation(yield Js({routingAttributes:r}))})).then(ee=>{y({type:"SET_CONVERSATION_ID",id:ee}),y({type:"SET_CONNECTION_STATUS",status:"connected"}),A.persistConversationId(ee)}).catch(ee=>{var w;y({type:"SET_ERROR",error:Ro(ee)}),y({type:"SET_CONNECTION_STATUS",status:"error"}),(w=k.current)==null||w.call(k,ee.message)}))},[r,A]),ve=Y.useCallback(()=>je(null,null,function*(){var N;const z=C.current;if(!z)return;const ee=yield z.retrieveConversationTranscript(),w=URL.createObjectURL(ee);try{const V=document.createElement("a");V.href=w,V.download=`transcript-${(N=z.conversationId)!=null?N:"conversation"}.pdf`,document.body.appendChild(V),V.click(),V.remove()}finally{URL.revokeObjectURL(w)}}),[]),se=Y.useMemo(()=>({connectionStatus:b.connectionStatus,isConnected:b.connectionStatus==="connected"&&b.conversationId!==null,isAgentTyping:b.isAgentTyping,conversationId:b.conversationId,messages:b.messages,streamingBlocks:b.streamingBlocks,progressMessage:b.progressMessage,progressSteps:b.progressSteps,error:b.error,sendError:b.sendError,loading:b.loading,sessionExpired:b.sessionExpired,sendMessage:te,addToCart:re,resetConversation:ye,retryLastMessage:de,retryConnection:ae,downloadTranscript:ve}),[b,te,re,ye,de,ae,ve]);return x.jsx(bg.Provider,{value:se,children:h})};var kg=Symbol.for("immer-nothing"),Cg=Symbol.for("immer-draftable"),Cn=Symbol.for("immer-state");function ir(e,...t){throw new Error(`[Immer] minified error nr: ${e}. Full error at: https://bit.ly/3cXEKWf`)}var Lo=Object.getPrototypeOf;function Do(e){return!!e&&!!e[Cn]}function $i(e){var t;return e?Ng(e)||Array.isArray(e)||!!e[Cg]||!!((t=e.constructor)!=null&&t[Cg])||$u(e)||Vu(e):!1}var LA=Object.prototype.constructor.toString();function Ng(e){if(!e||typeof e!="object")return!1;const t=Lo(e);if(t===null)return!0;const n=Object.hasOwnProperty.call(t,"constructor")&&t.constructor;return n===Object?!0:typeof n=="function"&&Function.toString.call(n)===LA}function ju(e,t){zu(e)===0?Reflect.ownKeys(e).forEach(n=>{t(n,e[n],e)}):e.forEach((n,r)=>t(r,n,e))}function zu(e){const t=e[Cn];return t?t.type_:Array.isArray(e)?1:$u(e)?2:Vu(e)?3:0}function Yd(e,t){return zu(e)===2?e.has(t):Object.prototype.hasOwnProperty.call(e,t)}function Og(e,t,n){const r=zu(e);r===2?e.set(t,n):r===3?e.add(n):e[t]=n}function DA(e,t){return e===t?e!==0||1/e===1/t:e!==e&&t!==t}function $u(e){return e instanceof Map}function Vu(e){return e instanceof Set}function Vi(e){return e.copy_||e.base_}function Wd(e,t){if($u(e))return new Map(e);if(Vu(e))return new Set(e);if(Array.isArray(e))return Array.prototype.slice.call(e);const n=Ng(e);if(t===!0||t==="class_only"&&!n){const r=Object.getOwnPropertyDescriptors(e);delete r[Cn];let o=Reflect.ownKeys(r);for(let a=0;a<o.length;a++){const u=o[a],c=r[u];c.writable===!1&&(c.writable=!0,c.configurable=!0),(c.get||c.set)&&(r[u]={configurable:!0,writable:!0,enumerable:c.enumerable,value:e[u]})}return Object.create(Lo(e),r)}else{const r=Lo(e);if(r!==null&&n)return U({},e);const o=Object.create(r);return Object.assign(o,e)}}function Gd(e,t=!1){return qu(e)||Do(e)||!$i(e)||(zu(e)>1&&(e.set=e.add=e.clear=e.delete=MA),Object.freeze(e),t&&Object.entries(e).forEach(([n,r])=>Gd(r,!0))),e}function MA(){ir(2)}function qu(e){return Object.isFrozen(e)}var FA={};function qi(e){const t=FA[e];return t||ir(0,e),t}var Zs;function Pg(){return Zs}function BA(e,t){return{drafts_:[],parent_:e,immer_:t,canAutoFreeze_:!0,unfinalizedDrafts_:0}}function Ig(e,t){t&&(qi("Patches"),e.patches_=[],e.inversePatches_=[],e.patchListener_=t)}function Xd(e){Kd(e),e.drafts_.forEach(UA),e.drafts_=null}function Kd(e){e===Zs&&(Zs=e.parent_)}function Rg(e){return Zs=BA(Zs,e)}function UA(e){const t=e[Cn];t.type_===0||t.type_===1?t.revoke_():t.revoked_=!0}function Lg(e,t){t.unfinalizedDrafts_=t.drafts_.length;const n=t.drafts_[0];return e!==void 0&&e!==n?(n[Cn].modified_&&(Xd(t),ir(4)),$i(e)&&(e=Yu(t,e),t.parent_||Wu(t,e)),t.patches_&&qi("Patches").generateReplacementPatches_(n[Cn].base_,e,t.patches_,t.inversePatches_)):e=Yu(t,n,[]),Xd(t),t.patches_&&t.patchListener_(t.patches_,t.inversePatches_),e!==kg?e:void 0}function Yu(e,t,n){if(qu(t))return t;const r=t[Cn];if(!r)return ju(t,(o,a)=>Dg(e,r,t,o,a,n)),t;if(r.scope_!==e)return t;if(!r.modified_)return Wu(e,r.base_,!0),r.base_;if(!r.finalized_){r.finalized_=!0,r.scope_.unfinalizedDrafts_--;const o=r.copy_;let a=o,u=!1;r.type_===3&&(a=new Set(o),o.clear(),u=!0),ju(a,(c,d)=>Dg(e,r,o,c,d,n,u)),Wu(e,o,!1),n&&e.patches_&&qi("Patches").generatePatches_(r,n,e.patches_,e.inversePatches_)}return r.copy_}function Dg(e,t,n,r,o,a,u){if(Do(o)){const c=a&&t&&t.type_!==3&&!Yd(t.assigned_,r)?a.concat(r):void 0,d=Yu(e,o,c);if(Og(n,r,d),Do(d))e.canAutoFreeze_=!1;else return}else u&&n.add(o);if($i(o)&&!qu(o)){if(!e.immer_.autoFreeze_&&e.unfinalizedDrafts_<1)return;Yu(e,o),(!t||!t.scope_.parent_)&&typeof r!="symbol"&&Object.prototype.propertyIsEnumerable.call(n,r)&&Wu(e,o)}}function Wu(e,t,n=!1){!e.parent_&&e.immer_.autoFreeze_&&e.canAutoFreeze_&&Gd(t,n)}function HA(e,t){const n=Array.isArray(e),r={type_:n?1:0,scope_:t?t.scope_:Pg(),modified_:!1,finalized_:!1,assigned_:{},parent_:t,base_:e,draft_:null,copy_:null,revoke_:null,isManual_:!1};let o=r,a=Qd;n&&(o=[r],a=ea);const{revoke:u,proxy:c}=Proxy.revocable(o,a);return r.draft_=c,r.revoke_=u,c}var Qd={get(e,t){if(t===Cn)return e;const n=Vi(e);if(!Yd(n,t))return jA(e,n,t);const r=n[t];return e.finalized_||!$i(r)?r:r===Jd(e.base_,t)?(ef(e),e.copy_[t]=tf(r,e)):r},has(e,t){return t in Vi(e)},ownKeys(e){return Reflect.ownKeys(Vi(e))},set(e,t,n){const r=Mg(Vi(e),t);if(r!=null&&r.set)return r.set.call(e.draft_,n),!0;if(!e.modified_){const o=Jd(Vi(e),t),a=o==null?void 0:o[Cn];if(a&&a.base_===n)return e.copy_[t]=n,e.assigned_[t]=!1,!0;if(DA(n,o)&&(n!==void 0||Yd(e.base_,t)))return!0;ef(e),Zd(e)}return e.copy_[t]===n&&(n!==void 0||t in e.copy_)||Number.isNaN(n)&&Number.isNaN(e.copy_[t])||(e.copy_[t]=n,e.assigned_[t]=!0),!0},deleteProperty(e,t){return Jd(e.base_,t)!==void 0||t in e.base_?(e.assigned_[t]=!1,ef(e),Zd(e)):delete e.assigned_[t],e.copy_&&delete e.copy_[t],!0},getOwnPropertyDescriptor(e,t){const n=Vi(e),r=Reflect.getOwnPropertyDescriptor(n,t);return r&&{writable:!0,configurable:e.type_!==1||t!=="length",enumerable:r.enumerable,value:n[t]}},defineProperty(){ir(11)},getPrototypeOf(e){return Lo(e.base_)},setPrototypeOf(){ir(12)}},ea={};ju(Qd,(e,t)=>{ea[e]=function(){return arguments[0]=arguments[0][0],t.apply(this,arguments)}}),ea.deleteProperty=function(e,t){return ea.set.call(this,e,t,void 0)},ea.set=function(e,t,n){return Qd.set.call(this,e[0],t,n,e[0])};function Jd(e,t){const n=e[Cn];return(n?Vi(n):e)[t]}function jA(e,t,n){var o;const r=Mg(t,n);return r?"value"in r?r.value:(o=r.get)==null?void 0:o.call(e.draft_):void 0}function Mg(e,t){if(!(t in e))return;let n=Lo(e);for(;n;){const r=Object.getOwnPropertyDescriptor(n,t);if(r)return r;n=Lo(n)}}function Zd(e){e.modified_||(e.modified_=!0,e.parent_&&Zd(e.parent_))}function ef(e){e.copy_||(e.copy_=Wd(e.base_,e.scope_.immer_.useStrictShallowCopy_))}var zA=class{constructor(e){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.produce=(t,n,r)=>{if(typeof t=="function"&&typeof n!="function"){const a=n;n=t;const u=this;return function(d=a,...h){return u.produce(d,p=>n.call(this,p,...h))}}typeof n!="function"&&ir(6),r!==void 0&&typeof r!="function"&&ir(7);let o;if($i(t)){const a=Rg(this),u=tf(t,void 0);let c=!0;try{o=n(u),c=!1}finally{c?Xd(a):Kd(a)}return Ig(a,r),Lg(o,a)}else if(!t||typeof t!="object"){if(o=n(t),o===void 0&&(o=t),o===kg&&(o=void 0),this.autoFreeze_&&Gd(o,!0),r){const a=[],u=[];qi("Patches").generateReplacementPatches_(t,o,a,u),r(a,u)}return o}else ir(1,t)},this.produceWithPatches=(t,n)=>{if(typeof t=="function")return(u,...c)=>this.produceWithPatches(u,d=>t(d,...c));let r,o;return[this.produce(t,n,(u,c)=>{r=u,o=c}),r,o]},typeof(e==null?void 0:e.autoFreeze)=="boolean"&&this.setAutoFreeze(e.autoFreeze),typeof(e==null?void 0:e.useStrictShallowCopy)=="boolean"&&this.setUseStrictShallowCopy(e.useStrictShallowCopy)}createDraft(e){$i(e)||ir(8),Do(e)&&(e=$A(e));const t=Rg(this),n=tf(e,void 0);return n[Cn].isManual_=!0,Kd(t),n}finishDraft(e,t){const n=e&&e[Cn];(!n||!n.isManual_)&&ir(9);const{scope_:r}=n;return Ig(r,t),Lg(void 0,r)}setAutoFreeze(e){this.autoFreeze_=e}setUseStrictShallowCopy(e){this.useStrictShallowCopy_=e}applyPatches(e,t){let n;for(n=t.length-1;n>=0;n--){const o=t[n];if(o.path.length===0&&o.op==="replace"){e=o.value;break}}n>-1&&(t=t.slice(n+1));const r=qi("Patches").applyPatches_;return Do(e)?r(e,t):this.produce(e,o=>r(o,t))}};function tf(e,t){const n=$u(e)?qi("MapSet").proxyMap_(e,t):Vu(e)?qi("MapSet").proxySet_(e,t):HA(e,t);return(t?t.scope_:Pg()).drafts_.push(n),n}function $A(e){return Do(e)||ir(10,e),Fg(e)}function Fg(e){if(!$i(e)||qu(e))return e;const t=e[Cn];let n;if(t){if(!t.modified_)return t.base_;t.finalized_=!0,n=Wd(e,t.scope_.immer_.useStrictShallowCopy_)}else n=Wd(e,!0);return ju(n,(r,o)=>{Og(n,r,Fg(o))}),t&&(t.finalized_=!1),n}var Nn=new zA,VA=Nn.produce;Nn.produceWithPatches.bind(Nn),Nn.setAutoFreeze.bind(Nn),Nn.setUseStrictShallowCopy.bind(Nn),Nn.applyPatches.bind(Nn),Nn.createDraft.bind(Nn),Nn.finishDraft.bind(Nn);function qA(e,t,n){var r=Y.useMemo(function(){return VA(e)},[e]);return Y.useReducer(r,t,n)}const at={SET_PROMPTS_EXTENSION_INITIALIZED:"SET_PROMPTS_EXTENSION_INITIALIZED",SET_PROMPTS_EXTENSION_OPEN:"SET_PROMPTS_EXTENSION_OPEN",SET_PROMPTS_EXTENSION_INLINE:"SET_PROMPTS_EXTENSION_INLINE",SET_PROMPTS_EXTENSION_ELEMENT_ID:"SET_PROMPTS_EXTENSION_ELEMENT_ID",SET_PROMPTS_EXTENSION_ENTRY_TYPE:"SET_PROMPTS_EXTENSION_ENTRY_TYPE",SET_PROMPTS_EXTENSION_PARAMS:"SET_PROMPTS_EXTENSION_PARAMS",RESET_PROMPTS_EXTENSION_PARAMS:"RESET_PROMPTS_EXTENSION_PARAMS",SET_PROMPTS_EXTENSION_ACTIVE_PROMPTS_ID:"SET_PROMPTS_EXTENSION_ACTIVE_PROMPTS_ID",RESET_PROMPTS_EXTENSION_ACTIVE_PROMPTS_ID:"RESET_PROMPTS_EXTENSION_ACTIVE_PROMPTS_ID",SET_PROMPTS_EXTENSION_USER_PROMPT:"SET_PROMPTS_EXTENSION_USER_PROMPT",SET_PROMPTS_EXTENSION_PROMPTS_MESSAGE:"SET_PROMPTS_EXTENSION_PROMPTS_MESSAGE",RESET_PROMPTS_EXTENSION_PROMPTS_MESSAGE:"RESET_PROMPTS_EXTENSION_PROMPTS_MESSAGE",SET_PROMPTS_EXTENSION_RESPONSE_MESSAGE:"SET_PROMPTS_EXTENSION_RESPONSE_MESSAGE",RESET_PROMPTS_EXTENSION_RESPONSE_MESSAGE:"RESET_PROMPTS_EXTENSION_RESPONSE_MESSAGE",SET_PROMPTS_EXTENSION_RESPONSE_LOADING:"SET_PROMPTS_EXTENSION_RESPONSE_LOADING"},Bg={isInitialized:!1,isOpen:!1,isInline:!1,elementId:null,placeholder:null,askElseButtonLabel:null,entryType:null,params:null,activePromptsId:null,userPrompt:null,promptsMessage:null,isResponseLoading:!1,responseMessage:null,promptsDisplay:"both",disableAskElseButton:!1},Ug=Y.createContext(null),Hg=Y.createContext(null),YA=({children:e,dispatch:t})=>{const n=Y.useCallback(_=>{t({type:at.SET_PROMPTS_EXTENSION_INITIALIZED,payload:_})},[t]),r=Y.useCallback(_=>{t({type:at.SET_PROMPTS_EXTENSION_OPEN,payload:_})},[t]),o=Y.useCallback(_=>{t({type:at.SET_PROMPTS_EXTENSION_INLINE,payload:_})},[t]),a=Y.useCallback(_=>{t({type:at.SET_PROMPTS_EXTENSION_ELEMENT_ID,payload:_})},[t]),u=Y.useCallback(_=>{t({type:at.SET_PROMPTS_EXTENSION_ENTRY_TYPE,payload:_})},[t]),c=Y.useCallback(_=>{t({type:at.SET_PROMPTS_EXTENSION_ACTIVE_PROMPTS_ID,payload:_})},[t]),d=Y.useCallback(_=>{t({type:at.SET_PROMPTS_EXTENSION_USER_PROMPT,payload:_})},[t]),h=Y.useCallback(_=>{t({type:at.SET_PROMPTS_EXTENSION_PARAMS,payload:_})},[t]),p=Y.useCallback(_=>{t({type:at.SET_PROMPTS_EXTENSION_PROMPTS_MESSAGE,payload:_})},[t]),m=Y.useCallback(_=>{t({type:at.SET_PROMPTS_EXTENSION_RESPONSE_MESSAGE,payload:_})},[t]),b=Y.useCallback(_=>{t({type:at.SET_PROMPTS_EXTENSION_RESPONSE_LOADING,payload:_})},[t]),y=Y.useMemo(()=>({setIsInitialized:n,setIsOpen:r,setIsInline:o,setElementId:a,setEntryType:u,setActivePromptsId:c,setUserPrompt:d,setParams:h,setPromptsMessage:p,setResponseMessage:m,setIsResponseLoading:b}),[n,r,o,a,u,c,d,h,p,m,b]);return x.jsx(Hg.Provider,{value:y,children:e})},WA=(e,t)=>{const{type:n,payload:r}=t;switch(n){case at.SET_PROMPTS_EXTENSION_INITIALIZED:e.isInitialized=r;break;case at.SET_PROMPTS_EXTENSION_OPEN:e.isOpen=r;break;case at.SET_PROMPTS_EXTENSION_INLINE:e.isInline=r;break;case at.SET_PROMPTS_EXTENSION_ELEMENT_ID:e.elementId=r;break;case at.SET_PROMPTS_EXTENSION_ENTRY_TYPE:e.entryType=r;break;case at.SET_PROMPTS_EXTENSION_PARAMS:e.params=r;break;case at.RESET_PROMPTS_EXTENSION_PARAMS:e.params=null;break;case at.SET_PROMPTS_EXTENSION_USER_PROMPT:e.userPrompt=r;break;case at.SET_PROMPTS_EXTENSION_ACTIVE_PROMPTS_ID:e.activePromptsId=r;break;case at.RESET_PROMPTS_EXTENSION_ACTIVE_PROMPTS_ID:e.activePromptsId=null;break;case at.SET_PROMPTS_EXTENSION_PROMPTS_MESSAGE:e.promptsMessage=r;break;case at.RESET_PROMPTS_EXTENSION_PROMPTS_MESSAGE:e.promptsMessage=null;break;case at.SET_PROMPTS_EXTENSION_RESPONSE_MESSAGE:e.responseMessage=r;break;case at.RESET_PROMPTS_EXTENSION_RESPONSE_MESSAGE:e.responseMessage=null;break;case at.SET_PROMPTS_EXTENSION_RESPONSE_LOADING:e.isResponseLoading=r;break}},GA=({promptsConfig:e,children:t})=>{const[n,r]=qA(WA,U(U({},Bg),e||{}));return x.jsx(Ug.Provider,{value:n,children:x.jsx(YA,{dispatch:r,children:t})})};function XA(){var e=Y.useRef(!0);return e.current?(e.current=!1,!0):e.current}function KA(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];e&&e.addEventListener&&e.addEventListener.apply(e,t)}function QA(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];e&&e.removeEventListener&&e.removeEventListener.apply(e,t)}var nf=typeof window!="undefined",Gu=function(e){Y.useEffect(e,[])},JA=function(e){var t=Y.useRef(e);t.current=e,Gu(function(){return function(){return t.current()}})},ZA=function(e){var t=Y.useRef(0),n=Y.useState(e),r=n[0],o=n[1],a=Y.useCallback(function(u){cancelAnimationFrame(t.current),t.current=requestAnimationFrame(function(){o(u)})},[]);return JA(function(){cancelAnimationFrame(t.current)}),[r,a]},ek=function(e,t){return e===t};function tk(e,t){t===void 0&&(t=ek);var n=Y.useRef(),r=Y.useRef(e),o=XA();return!o&&!t(r.current,e)&&(n.current=r.current,r.current=e),n.current}var nk=function(e){var t={},n=t.initialWidth,r=n===void 0?1/0:n,o=t.initialHeight,a=o===void 0?1/0:o,u=t.onChange,c=ZA({width:nf?window.innerWidth:r,height:nf?window.innerHeight:a}),d=c[0],h=c[1];return Y.useEffect(function(){if(nf){var p=function(){var m=window.innerWidth,b=window.innerHeight;h({width:m,height:b}),u&&u(m,b)};return KA(window,"resize",p),function(){QA(window,"resize",p)}}},[]),d};const jg="cimulate",rf=`${jg}:ui-state-update`,of=`${jg}:prompts-state-update`,rk=e=>{window.addEventListener(rf,e)},ik=e=>{window.removeEventListener(rf,e)},ok=(e,t)=>{const n=new CustomEvent(rf,{detail:{property:e,value:t}});window.dispatchEvent(n)},zg=e=>{if(!["ask_cim","search","browse","pdp"].includes(e))throw new Error(`Invalid entryType: "${e}". Must be 'ask_cim', 'search', 'browse', or 'pdp'.`);nt.entryTypeProxy.entryType=e},ai=e=>{const t=nt.statusProxy.isOpen,n=typeof e=="boolean"?e:!t;nt.statusProxy.isOpen=n,n&&(nt.statusProxy.isMinimized=!1)},Xu=e=>{const t=nt.statusProxy.isMinimized,n=typeof e=="boolean"?e:!t;nt.statusProxy.isMinimized=n,n&&(nt.statusProxy.isOpen=!1)},sf=e=>{nt.modalProxy.isFullscreen=e},Ku=e=>{if(!["chat","dialog","modal"].includes(e))throw new Error(`Invalid type: ${e}. Must be 'chat', 'dialog', or 'modal'.`);nt.statusProxy.type=e,e==="dialog"||e==="chat"?nt.modeProxy.mode="embedded":nt.modeProxy.mode="standalone"},af=e=>{const t=["top","top-left","top-right","bottom","bottom-left","bottom-right","left","right","center"];if(!t.includes(e))throw new Error(`Invalid position: ${e}. Must be one of ${t.join(", ")}.`);nt.dialogProxy.position=e},sk=e=>{const t=nt.dialogProxy.isFullHeight,n=typeof e=="boolean"?e:!t;nt.dialogProxy.isFullHeight=n};class ak{constructor(){qe(this,"initialState",{connected:!1,mode:"embedded",entryType:"search",status:{type:"dialog",isOpen:!1,isMinimized:!1},dialog:{position:"bottom-left",isFullHeight:!1,width:""},modal:{isFullscreen:!1}});qe(this,"connectedProxy");qe(this,"modeProxy");qe(this,"entryTypeProxy");qe(this,"statusProxy");qe(this,"dialogProxy");qe(this,"modalProxy",{isFullscreen:!1});qe(this,"_fullGet",(t,n)=>Reflect.get(t,n));qe(this,"_fullSet",(t,n,r)=>{if(!(n in t))throw new Error(`Property ${n} does not exist on UIState`);return ok(n,r),Reflect.set(t,n,r)});this.connectedProxy=new Proxy({connected:this.initialState.connected},{get:this._fullGet,set:this._fullSet}),this.modeProxy=new Proxy({mode:this.initialState.mode},{get:this._fullGet,set:this._fullSet}),this.entryTypeProxy=new Proxy({entryType:this.initialState.entryType},{get:this._fullGet,set:this._fullSet}),this.statusProxy=new Proxy({type:this.initialState.status.type,isOpen:this.initialState.status.isOpen,isMinimized:this.initialState.status.isMinimized},{get:this._fullGet,set:this._fullSet}),this.dialogProxy=new Proxy({position:this.initialState.dialog.position,isFullHeight:this.initialState.dialog.isFullHeight,width:this.initialState.dialog.width},{get:this._fullGet,set:this._fullSet}),this.modalProxy=new Proxy({isFullscreen:this.initialState.modal.isFullscreen},{get:this._fullGet,set:this._fullSet})}get connected(){return this.connectedProxy.connected}get mode(){return this.modeProxy.mode}get isOpen(){return!!this.statusProxy.isOpen}get isMinimized(){return!!this.statusProxy.isMinimized}get type(){return this.statusProxy.type}get entryType(){return this.entryTypeProxy.entryType}get position(){return this.dialogProxy.position}get state(){return{connected:this.connected,mode:this.mode,entryType:this.entryType,status:{type:this.type,isOpen:this.isOpen,isMinimized:this.isMinimized},dialog:{position:this.position,isFullHeight:this.dialogProxy.isFullHeight,width:this.dialogProxy.width},modal:{isFullscreen:this.modalProxy.isFullscreen}}}}const nt=new ak,$g=Y.createContext({mode:nt.modeProxy.mode,entryType:nt.entryType,status:nt.statusProxy,dialogPosition:nt.dialogProxy.position,isDialogFullHeight:nt.dialogProxy.isFullHeight,dialogWidth:nt.dialogProxy.width,isModalFullscreen:nt.modalProxy.isFullscreen,previousComponentType:nt.statusProxy.type}),uk=({entryType:e,componentConfig:t,componentType:n,children:r})=>{const[o,a]=Y.useState(e!=null?e:nt.entryTypeProxy.entryType),[u,c]=Y.useState(nt.modeProxy.mode),[d,h]=Y.useState({type:n||nt.statusProxy.type,isOpen:nt.statusProxy.isOpen,isMinimized:nt.statusProxy.isMinimized}),[p,m]=Y.useState(nt.dialogProxy.position),[b,y]=Y.useState(nt.dialogProxy.isFullHeight),[_,A]=Y.useState(nt.dialogProxy.width),[C,v]=Y.useState(nt.modalProxy.isFullscreen),k=tk(d.type);Y.useEffect(()=>{const j=G=>{const{property:M,value:Z}=G.detail||{};if(!(!M||Z===void 0)){if(M==="mode"){c(Z);return}if(M==="entryType"){a(Z);return}if(M==="isMinimized"){h(ue=>oe(U({},ue),{isMinimized:Z}));return}if(M==="isOpen"){h(ue=>oe(U({},ue),{isOpen:Z}));return}if(M==="type"){h(ue=>oe(U({},ue),{type:Z}));return}if(M==="position"){m(Z);return}if(M==="isFullHeight"){y(Z);return}if(M==="width"){A(Z);return}if(M==="isFullscreen"){v(Z);return}}};return rk(j),()=>{ik(j)}},[]),Gu(()=>{e&&zg(e)}),Gu(()=>{const j=n||(t==null?void 0:t.type);j&&Ku(j),t&&"isOpen"in t&&ai(!!t.isOpen),t&&"isMinimized"in t&&Xu(!!t.isMinimized)}),Gu(()=>{if(!(t!=null&&t.options))return;const{dialogPosition:j}=t.options;j&&af(j),"dialogFullHeight"in t.options&&sk(!!t.options.dialogFullHeight),"dialogWidth"in t.options&&t.options.dialogWidth&&A(t.options.dialogWidth),"isModalFullscreen"in t.options&&sf(!!t.options.isModalFullscreen)});const R=Y.useMemo(()=>({mode:u,entryType:o,status:d,previousComponentType:k||"dialog",dialogPosition:p,isDialogFullHeight:b,dialogWidth:_,isModalFullscreen:C}),[u,o,d,k,p,b,_,C]);return x.jsx($g.Provider,{value:R,children:r})},Vg=({mode:e,apiKey:t,apiToken:n,baseUrl:r,logoUrl:o,headerText:a,headerConfig:u,theme:c,openLinksInNewTab:d,globalClassName:h,isDevelopment:p=!1,componentType:m,componentConfig:b,entryType:y,entryMessage:_,disclaimerText:A,disclaimerMarkdown:C,clientContext:v,searchPlaceholder:k,searchButtonLabel:R,searchConfig:j,suggestionButtonConfig:G,messageAlignment:M,autoScroll:Z,promptsConfig:ue,resetConversationMessage:pe,conversationHistory:$,messagingConfig:te,__features:re,children:de})=>x.jsx(dA,{mode:e,baseUrl:r,apiKey:t,apiToken:n,logoUrl:o,headerText:a,headerConfig:u,entryMessage:_,theme:c,globalClassName:h,openLinksInNewTab:d,searchPlaceholder:k,searchButtonLabel:R,searchConfig:j,suggestionButtonConfig:G,messageAlignment:M,autoScroll:Z,componentConfig:b,clientContext:v,disclaimerMarkdown:C,disclaimerText:A,resetConversationMessage:pe,conversationHistory:$,isDevelopment:p,__features:re,routingAttributes:te==null?void 0:te.routingAttributes,enableDownloadTranscript:te==null?void 0:te.enableDownloadTranscript,enableEscalationToAgent:te==null?void 0:te.enableEscalationToAgent,children:x.jsx(uk,{entryType:y,componentConfig:b,componentType:m,children:x.jsx(GA,{promptsConfig:ue,children:x.jsx(Ag,{scrt2Url:(te==null?void 0:te.scrt2Url)||"",orgId:(te==null?void 0:te.orgId)||"",esDeveloperName:(te==null?void 0:te.esDeveloperName)||"",routingAttributes:(te==null?void 0:te.routingAttributes)||{},capabilitiesVersion:te==null?void 0:te.capabilitiesVersion,enableLogging:p,children:de})})})}),Yi=()=>{const e=Y.useContext($g);if(!e)throw new Error("useUIState must be used within a UIStateProvider");return e};var uf={exports:{}},pn={},lf={exports:{}},cf={};var qg;function lk(){return qg||(qg=1,(function(e){function t(z,ee){var w=z.length;z.push(ee);e:for(;0<w;){var N=w-1>>>1,V=z[N];if(0<o(V,ee))z[N]=ee,z[w]=V,w=N;else break e}}function n(z){return z.length===0?null:z[0]}function r(z){if(z.length===0)return null;var ee=z[0],w=z.pop();if(w!==ee){z[0]=w;e:for(var N=0,V=z.length,I=V>>>1;N<I;){var Te=2*(N+1)-1,Ie=z[Te],xe=Te+1,Fe=z[xe];if(0>o(Ie,w))xe<V&&0>o(Fe,Ie)?(z[N]=Fe,z[xe]=w,N=xe):(z[N]=Ie,z[Te]=w,N=Te);else if(xe<V&&0>o(Fe,w))z[N]=Fe,z[xe]=w,N=xe;else break e}}return ee}function o(z,ee){var w=z.sortIndex-ee.sortIndex;return w!==0?w:z.id-ee.id}if(typeof performance=="object"&&typeof performance.now=="function"){var a=performance;e.unstable_now=function(){return a.now()}}else{var u=Date,c=u.now();e.unstable_now=function(){return u.now()-c}}var d=[],h=[],p=1,m=null,b=3,y=!1,_=!1,A=!1,C=typeof setTimeout=="function"?setTimeout:null,v=typeof clearTimeout=="function"?clearTimeout:null,k=typeof setImmediate!="undefined"?setImmediate:null;typeof navigator!="undefined"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function R(z){for(var ee=n(h);ee!==null;){if(ee.callback===null)r(h);else if(ee.startTime<=z)r(h),ee.sortIndex=ee.expirationTime,t(d,ee);else break;ee=n(h)}}function j(z){if(A=!1,R(z),!_)if(n(d)!==null)_=!0,ve(G);else{var ee=n(h);ee!==null&&se(j,ee.startTime-z)}}function G(z,ee){_=!1,A&&(A=!1,v(ue),ue=-1),y=!0;var w=b;try{for(R(ee),m=n(d);m!==null&&(!(m.expirationTime>ee)||z&&!te());){var N=m.callback;if(typeof N=="function"){m.callback=null,b=m.priorityLevel;var V=N(m.expirationTime<=ee);ee=e.unstable_now(),typeof V=="function"?m.callback=V:m===n(d)&&r(d),R(ee)}else r(d);m=n(d)}if(m!==null)var I=!0;else{var Te=n(h);Te!==null&&se(j,Te.startTime-ee),I=!1}return I}finally{m=null,b=w,y=!1}}var M=!1,Z=null,ue=-1,pe=5,$=-1;function te(){return!(e.unstable_now()-$<pe)}function re(){if(Z!==null){var z=e.unstable_now();$=z;var ee=!0;try{ee=Z(!0,z)}finally{ee?de():(M=!1,Z=null)}}else M=!1}var de;if(typeof k=="function")de=function(){k(re)};else if(typeof MessageChannel!="undefined"){var ae=new MessageChannel,ye=ae.port2;ae.port1.onmessage=re,de=function(){ye.postMessage(null)}}else de=function(){C(re,0)};function ve(z){Z=z,M||(M=!0,de())}function se(z,ee){ue=C(function(){z(e.unstable_now())},ee)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(z){z.callback=null},e.unstable_continueExecution=function(){_||y||(_=!0,ve(G))},e.unstable_forceFrameRate=function(z){0>z||125<z?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):pe=0<z?Math.floor(1e3/z):5},e.unstable_getCurrentPriorityLevel=function(){return b},e.unstable_getFirstCallbackNode=function(){return n(d)},e.unstable_next=function(z){switch(b){case 1:case 2:case 3:var ee=3;break;default:ee=b}var w=b;b=ee;try{return z()}finally{b=w}},e.unstable_pauseExecution=function(){},e.unstable_requestPaint=function(){},e.unstable_runWithPriority=function(z,ee){switch(z){case 1:case 2:case 3:case 4:case 5:break;default:z=3}var w=b;b=z;try{return ee()}finally{b=w}},e.unstable_scheduleCallback=function(z,ee,w){var N=e.unstable_now();switch(typeof w=="object"&&w!==null?(w=w.delay,w=typeof w=="number"&&0<w?N+w:N):w=N,z){case 1:var V=-1;break;case 2:V=250;break;case 5:V=1073741823;break;case 4:V=1e4;break;default:V=5e3}return V=w+V,z={id:p++,callback:ee,priorityLevel:z,startTime:w,expirationTime:V,sortIndex:-1},w>N?(z.sortIndex=w,t(h,z),n(d)===null&&z===n(h)&&(A?(v(ue),ue=-1):A=!0,se(j,w-N))):(z.sortIndex=V,t(d,z),_||y||(_=!0,ve(G))),z},e.unstable_shouldYield=te,e.unstable_wrapCallback=function(z){var ee=b;return function(){var w=b;b=ee;try{return z.apply(this,arguments)}finally{b=w}}}})(cf)),cf}var Yg;function ck(){return Yg||(Yg=1,lf.exports=lk()),lf.exports}var Wg;function dk(){if(Wg)return pn;Wg=1;var e=Ao(),t=ck();function n(i){for(var s="https://reactjs.org/docs/error-decoder.html?invariant="+i,l=1;l<arguments.length;l++)s+="&args[]="+encodeURIComponent(arguments[l]);return"Minified React error #"+i+"; visit "+s+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}var r=new Set,o={};function a(i,s){u(i,s),u(i+"Capture",s)}function u(i,s){for(o[i]=s,i=0;i<s.length;i++)r.add(s[i])}var c=!(typeof window=="undefined"||typeof window.document=="undefined"||typeof window.document.createElement=="undefined"),d=Object.prototype.hasOwnProperty,h=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,p={},m={};function b(i){return d.call(m,i)?!0:d.call(p,i)?!1:h.test(i)?m[i]=!0:(p[i]=!0,!1)}function y(i,s,l,f){if(l!==null&&l.type===0)return!1;switch(typeof s){case"function":case"symbol":return!0;case"boolean":return f?!1:l!==null?!l.acceptsBooleans:(i=i.toLowerCase().slice(0,5),i!=="data-"&&i!=="aria-");default:return!1}}function _(i,s,l,f){if(s===null||typeof s=="undefined"||y(i,s,l,f))return!0;if(f)return!1;if(l!==null)switch(l.type){case 3:return!s;case 4:return s===!1;case 5:return isNaN(s);case 6:return isNaN(s)||1>s}return!1}function A(i,s,l,f,E,T,S){this.acceptsBooleans=s===2||s===3||s===4,this.attributeName=f,this.attributeNamespace=E,this.mustUseProperty=l,this.propertyName=i,this.type=s,this.sanitizeURL=T,this.removeEmptyString=S}var C={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(i){C[i]=new A(i,0,!1,i,null,!1,!1)}),[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(i){var s=i[0];C[s]=new A(s,1,!1,i[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(i){C[i]=new A(i,2,!1,i.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(i){C[i]=new A(i,2,!1,i,null,!1,!1)}),"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(i){C[i]=new A(i,3,!1,i.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(i){C[i]=new A(i,3,!0,i,null,!1,!1)}),["capture","download"].forEach(function(i){C[i]=new A(i,4,!1,i,null,!1,!1)}),["cols","rows","size","span"].forEach(function(i){C[i]=new A(i,6,!1,i,null,!1,!1)}),["rowSpan","start"].forEach(function(i){C[i]=new A(i,5,!1,i.toLowerCase(),null,!1,!1)});var v=/[\-:]([a-z])/g;function k(i){return i[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(i){var s=i.replace(v,k);C[s]=new A(s,1,!1,i,null,!1,!1)}),"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(i){var s=i.replace(v,k);C[s]=new A(s,1,!1,i,"http://www.w3.org/1999/xlink",!1,!1)}),["xml:base","xml:lang","xml:space"].forEach(function(i){var s=i.replace(v,k);C[s]=new A(s,1,!1,i,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(function(i){C[i]=new A(i,1,!1,i.toLowerCase(),null,!1,!1)}),C.xlinkHref=new A("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach(function(i){C[i]=new A(i,1,!1,i.toLowerCase(),null,!0,!0)});function R(i,s,l,f){var E=C.hasOwnProperty(s)?C[s]:null;(E!==null?E.type!==0:f||!(2<s.length)||s[0]!=="o"&&s[0]!=="O"||s[1]!=="n"&&s[1]!=="N")&&(_(s,l,E,f)&&(l=null),f||E===null?b(s)&&(l===null?i.removeAttribute(s):i.setAttribute(s,""+l)):E.mustUseProperty?i[E.propertyName]=l===null?E.type===3?!1:"":l:(s=E.attributeName,f=E.attributeNamespace,l===null?i.removeAttribute(s):(E=E.type,l=E===3||E===4&&l===!0?"":""+l,f?i.setAttributeNS(f,s,l):i.setAttribute(s,l))))}var j=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,G=Symbol.for("react.element"),M=Symbol.for("react.portal"),Z=Symbol.for("react.fragment"),ue=Symbol.for("react.strict_mode"),pe=Symbol.for("react.profiler"),$=Symbol.for("react.provider"),te=Symbol.for("react.context"),re=Symbol.for("react.forward_ref"),de=Symbol.for("react.suspense"),ae=Symbol.for("react.suspense_list"),ye=Symbol.for("react.memo"),ve=Symbol.for("react.lazy"),se=Symbol.for("react.offscreen"),z=Symbol.iterator;function ee(i){return i===null||typeof i!="object"?null:(i=z&&i[z]||i["@@iterator"],typeof i=="function"?i:null)}var w=Object.assign,N;function V(i){if(N===void 0)try{throw Error()}catch(l){var s=l.stack.trim().match(/\n( *(at )?)/);N=s&&s[1]||""}return`
16
+ `+a)}}catch(u){}}throw r}})}_request(t,n){typeof t=="string"?(n=n||{},n.url=t):n=t||{},n=Hi(this.defaults,n);const{transitional:r,paramsSerializer:o,headers:a}=n;r!==void 0&&Bu.assertOptions(r,{silentJSONParsing:Qt.transitional(Qt.boolean),forcedJSONParsing:Qt.transitional(Qt.boolean),clarifyTimeoutError:Qt.transitional(Qt.boolean),legacyInterceptorReqResOrdering:Qt.transitional(Qt.boolean),advertiseZstdAcceptEncoding:Qt.transitional(Qt.boolean),validateStatusUndefinedResolves:Qt.transitional(Qt.boolean)},!1),o!=null&&(W.isFunction(o)?n.paramsSerializer={serialize:o}:Bu.assertOptions(o,{encode:Qt.function,serialize:Qt.function},!0)),n.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?n.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:n.allowAbsoluteUrls=!0),Bu.assertOptions(n,{baseUrl:Qt.spelling("baseURL"),withXsrfToken:Qt.spelling("withXSRFToken")},!0),n.method=(n.method||this.defaults.method||"get").toLowerCase();let u=a&&W.merge(a.common,a[n.method]);a&&W.forEach(["delete","get","head","post","put","patch","query","common"],_=>{delete a[_]}),n.headers=Kt.concat(u,a);const c=[];let d=!0;this.interceptors.request.forEach(function(A){if(typeof A.runWhen=="function"&&A.runWhen(n)===!1)return;d=d&&A.synchronous;const C=n.transitional||Dd;C&&C.legacyInterceptorReqResOrdering?c.unshift(A.fulfilled,A.rejected):c.push(A.fulfilled,A.rejected)});const h=[];this.interceptors.response.forEach(function(A){h.push(A.fulfilled,A.rejected)});let p,m=0,b;if(!d){const _=[mg.bind(this),void 0];for(_.unshift(...c),_.push(...h),b=_.length,p=Promise.resolve(n);m<b;)p=p.then(_[m++],_[m++]);return p}b=c.length;let y=n;for(;m<b;){const _=c[m++],A=c[m++];try{y=_(y)}catch(C){A.call(this,C);break}}try{p=mg.call(this,y)}catch(_){return Promise.reject(_)}for(m=0,b=h.length;m<b;)p=p.then(h[m++],h[m++]);return p}getUri(t){t=Hi(this.defaults,t);const n=og(t.baseURL,t.url,t.allowAbsoluteUrls,t);return X0(n,t.params,t.paramsSerializer)}};W.forEach(["delete","get","head","options"],function(t){ji.prototype[t]=function(n,r){return this.request(Hi(r||{},{method:t,url:n,data:r&&W.hasOwnProp(r,"data")?r.data:void 0}))}}),W.forEach(["post","put","patch","query"],function(t){function n(r){return function(a,u,c){return this.request(Hi(c||{},{method:t,headers:r?{"Content-Type":"multipart/form-data"}:{},url:a,data:u}))}}ji.prototype[t]=n(),t!=="query"&&(ji.prototype[t+"Form"]=n(!0))});let iA=class h2{constructor(t){if(typeof t!="function")throw new TypeError("executor must be a function.");let n;this.promise=new Promise(function(a){n=a});const r=this;this.promise.then(o=>{if(!r._listeners)return;let a=r._listeners.length;for(;a-- >0;)r._listeners[a](o);r._listeners=null}),this.promise.then=o=>{let a;const u=new Promise(c=>{r.subscribe(c),a=c}).then(o);return u.cancel=function(){r.unsubscribe(a)},u},t(function(a,u,c){r.reason||(r.reason=new Ks(a,u,c),n(r.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(t){if(this.reason){t(this.reason);return}this._listeners?this._listeners.push(t):this._listeners=[t]}unsubscribe(t){if(!this._listeners)return;const n=this._listeners.indexOf(t);n!==-1&&this._listeners.splice(n,1)}toAbortSignal(){const t=new AbortController,n=r=>{t.abort(r)};return this.subscribe(n),t.signal.unsubscribe=()=>this.unsubscribe(n),t.signal}static source(){let t;return{token:new h2(function(o){t=o}),cancel:t}}};function oA(e){return function(n){return e.apply(null,n)}}function sA(e){return W.isObject(e)&&e.isAxiosError===!0}const zd={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511,WebServerIsDown:521,ConnectionTimedOut:522,OriginIsUnreachable:523,TimeoutOccurred:524,SslHandshakeFailed:525,InvalidSslCertificate:526};Object.entries(zd).forEach(([e,t])=>{zd[t]=e});function Eg(e){const t=new ji(e),n=I0(ji.prototype.request,t);return W.extend(n,ji.prototype,t,{allOwnKeys:!0}),W.extend(n,t,null,{allOwnKeys:!0}),n.create=function(o){return Eg(Hi(e,o))},n}const St=Eg(Xs);St.Axios=ji,St.CanceledError=Ks,St.CancelToken=iA,St.isCancel=eg,St.VERSION=Ud,St.toFormData=Ru,St.AxiosError=we,St.Cancel=St.CanceledError,St.all=function(t){return Promise.all(t)},St.spread=oA,St.isAxiosError=sA,St.mergeConfig=Hi,St.AxiosHeaders=Kt,St.formToJSON=e=>Z0(W.isHTMLForm(e)?new FormData(e):e),St.getAdapter=pg.getAdapter,St.HttpStatusCode=zd,St.default=St;const{Axios:f7,AxiosError:h7,CanceledError:p7,isCancel:m7,CancelToken:g7,VERSION:E7,all:y7,Cancel:T7,isAxiosError:b7,spread:x7,toFormData:_7,AxiosHeaders:w7,HttpStatusCode:S7,formToJSON:v7,getAdapter:A7,mergeConfig:k7,create:C7}=St;class aA{constructor(t,n,r,o=!1,a,u){qe(this,"CIMULATE_API_HEADER","x-cimulate-api-key");qe(this,"CIMULATE_SEARCH_API_HOST","search.cimulate");qe(this,"CIMULATE_SEARCH_API_PATH","api/v1");qe(this,"baseApiUrl");qe(this,"headers",{});qe(this,"fetchConfig",()=>je(this,null,function*(){try{const t=yield St.get(`${this.apiUrl}/configs/copilot`,{headers:this.headers}),{customer_config:n}=t.data,r=atob(n);return JSON.parse(r)}catch(t){throw console.error("Error fetching customer config:",t),t}}));qe(this,"_mapCopilotUrlToSearchUrl",(t="",n=!1)=>{if(t.endsWith("io")){const o=new URL(t);return o.hostname=o.hostname.replace(/^copilot\./,"api."),o.origin}return n?`https://staging.${this.CIMULATE_SEARCH_API_HOST}.ai`:`https://prod.${this.CIMULATE_SEARCH_API_HOST}.ai`});if(n&&r||!n&&!r)throw new Error("Provide exactly one authentication method: either 'apiKey' or 'apiToken', but not both.");n?this.headers[this.CIMULATE_API_HEADER]=n:r&&(this.headers.Authorization=`Bearer ${r}`),a&&(this.headers["x-cimulate-customer-id"]=a),u&&(this.headers["Tenant-ID"]=u),this.baseApiUrl=this._mapCopilotUrlToSearchUrl(t,o)}get apiUrl(){return`${this.baseApiUrl}/${this.CIMULATE_SEARCH_API_PATH}`}}class uA{constructor(t,n,r,o=!1,a,u){qe(this,"apiService");qe(this,"config",null);qe(this,"getConfig",()=>je(this,null,function*(){if(this.config)return this.config;try{const t=yield this.apiService.fetchConfig();return this.config=t,this.config}catch(t){throw console.error("Failed to fetch customer config:",t),t}}));qe(this,"getPid",t=>this.getProductFieldValue(t,"pidCol"));qe(this,"getName",t=>this.getProductFieldValue(t,"nameCol"));qe(this,"getDescription",t=>this.getProductFieldValue(t,"description"));qe(this,"getBrand",t=>this.getProductFieldValue(t,"productBrandCol"));qe(this,"getPrice",t=>this.getProductFieldValue(t,"priceCol"));qe(this,"getRelativePdp",t=>this.getProductFieldValue(t,"relativePdpCol"));qe(this,"getPdp",t=>this.getProductFieldValue(t,"pdpCol"));qe(this,"getImage",t=>this.getProductFieldValue(t,"imageCol"));qe(this,"getProductHiddenFields",()=>{const t=this.getProductField("productHiddenFields");return Array.isArray(t)?t:[]});qe(this,"getProductField",t=>this.config?this.config[t]:"");qe(this,"getProductFieldValue",(t,n)=>{const r=this.getProductField(n);return r&&t[r]||""});this.apiService=new aA(t,n,r,o,a,u)}getPriceDisplay(t){const n=this.getPrice(t);return n?typeof n=="string"?n.includes("$")?n:`$${n}`:typeof n=="number"?new Intl.NumberFormat("en-US",{style:"currency",currency:"USD"}).format(n):n:""}}const zi=(e,t,n,...r)=>{if(!e)return;const o=["background: linear-gradient(90deg,rgba(253, 99, 99, 1) 0%, rgba(245, 139, 35, 1) 65%)","font-weight: bold","color: transparent","background-clip: text","text-fill-color: transparent"].join(";");console[t]("%c[cimulate-widget]",o,n,...r)};class lA{constructor(t=!1){qe(this,"isDevelopment");qe(this,"_log",(t,n,...r)=>{zi(this.isDevelopment,t,n,...r)});this.isDevelopment=t}log(t,...n){this._log("log",t,...n)}warn(t,...n){this._log("warn",t,...n)}error(t,...n){this._log("error",t,...n)}info(t,...n){this._log("info",t,...n)}debug(t,...n){this._log("debug",t,...n)}}const cA={copilot:"Your Search Assistant",messaging:"Commerce Client"},yg=Y.createContext(null),dA=({mode:e,logoUrl:t,headerText:n,headerConfig:r,globalClassName:o="",entryMessage:a,openLinksInNewTab:u=!1,disclaimerText:c,disclaimerMarkdown:d,clientContext:h,baseCatalogParams:p,searchPlaceholder:m,searchButtonLabel:b,searchConfig:y,suggestionButtonConfig:_,messageAlignment:A="start",autoScroll:C=!0,componentConfig:v,conversationHistory:k,resetConversationMessage:R="",apiKey:j,apiToken:G,baseUrl:M,customerId:Z,tenantId:ue,theme:pe,isDevelopment:$,__features:te,routingAttributes:re,enableDownloadTranscript:de=!0,enableEscalationToAgent:ae=!1,children:ye})=>{const ve=e==="messaging",se=Y.useMemo(()=>{const Te=re==null?void 0:re.isCartMgmtSupported;return Te===!0||Te==="true"},[re]),z=Y.useMemo(()=>ve?{config:null}:new uA(M,j,G,$,Z,ue),[ve,M,j,G,$,Z,ue]),ee=Y.useMemo(()=>new lA($),[$]);Y.useEffect(()=>{ve||!z||z.config||z.getConfig()},[z,ve]);const w=Y.useMemo(()=>pS(pe),[pe]),N=Y.useMemo(()=>{const Te=(y==null?void 0:y.placeholder)||m,Ie=(y==null?void 0:y.buttonLabel)||b;let xe="icon";return y!=null&&y.buttonType?xe=y.buttonType:b&&(xe="text"),oe(U({},y||{}),{placeholder:Te,buttonLabel:Ie,buttonType:xe})},[y,m,b]),V=Y.useMemo(()=>oe(U({},r||{}),{logoUrl:t||(r==null?void 0:r.logoUrl),headerText:(r==null?void 0:r.headerText)||n||cA[e!=null?e:"copilot"]}),[r,t,n,e]),I=Y.useMemo(()=>({configModule:z,mode:e!=null?e:"copilot",headerConfig:V,entryMessage:a,globalClassName:o,openLinksInNewTab:u,disclaimerText:c,disclaimerMarkdown:d,clientContext:h,baseCatalogParams:p,themeVariables:w,logger:ee,searchConfig:N,suggestionButtonConfig:_,messageAlignment:A,autoScroll:C,enableMinimize:!!(v!=null&&v.enableMinimize),enableDownloadTranscript:de,enableEscalationToAgent:ae,resetConversationMessage:R,conversationHistory:{sinceHours:typeof(k==null?void 0:k.sinceHours)=="number"?k.sinceHours:1,limit:k==null?void 0:k.limit},features:te,isCartMgmtSupported:se}),[z,e,V,a,o,h,p,c,d,u,N,_,A,C,v,de,ae,R,ee,w,k,te,se]);return x.jsx(yg.Provider,{value:I,children:ye})},dt=()=>{const e=Y.useContext(yg);if(!e)throw new Error("useConfig must be used within a ConfigProvider");return e},fA=["markdown","product_carousel","product_tile","product_comparison","suggestions","cart","order_confirmation"],Uu=-1;function hA(e){if(!e||!e.trim())return null;try{const t=JSON.parse(e);if(t&&typeof t=="object"&&typeof t.type=="string"&&typeof t.index=="number")return fA.includes(t.type)?t:null}catch(t){}return{type:"markdown",index:Uu,data:{content:e}}}function pA(e,t){if(t.index===Uu){const o=e[e.length-1];if(o&&o.type==="markdown"&&o.index===Uu&&t.type==="markdown"){const a={type:"markdown",index:Uu,data:{content:o.data.content+t.data.content}};return[...e.slice(0,-1),a]}return[...e,t]}const n=e.findIndex(o=>o.index===t.index);return[...n>=0?e.map((o,a)=>a===n?t:o):[...e,t]].sort((o,a)=>o.index-a.index)}const Tg={connectionStatus:"disconnected",loading:!0,conversationId:null,messages:[],streamingBlocks:[],isAgentTyping:!1,progressMessage:"",progressSteps:[],routingResult:null,error:null,sendError:null,sessionExpired:!1};function mA(e,t){switch(t.type){case"SET_CONNECTION_STATUS":return U(oe(U({},e),{connectionStatus:t.status}),t.status==="connected"||t.status==="connecting"?{error:null}:{});case"SET_LOADING":return oe(U({},e),{loading:t.isLoading});case"SET_CONVERSATION_ID":return oe(U({},e),{conversationId:t.id});case"ADD_MESSAGE":return oe(U({},e),{messages:[...e.messages,oe(U({},t.message),{type:"ADD_MESSAGE"})]});case"APPEND_STREAMING_TOKEN":{const n=hA(t.token);return n?oe(U({},e),{streamingBlocks:pA(e.streamingBlocks,n)}):e}case"FLUSH_STREAMING":return oe(U({},e),{messages:[...e.messages,oe(U({},t.message),{type:"FLUSH_STREAMING"})],streamingBlocks:[],isAgentTyping:!1,loading:!1,progressMessage:"",progressSteps:[],sendError:null});case"SET_AGENT_TYPING":return oe(U({},e),{isAgentTyping:t.isTyping,loading:t.isTyping});case"SET_PROGRESS_MESSAGE":return U(oe(U({},e),{progressMessage:t.message}),t.message===""?{progressSteps:[]}:{});case"ADD_PROGRESS_STEP":return e.progressSteps[e.progressSteps.length-1]===t.message?e:oe(U({},e),{progressSteps:[...e.progressSteps,t.message],progressMessage:t.message});case"SET_ROUTING_RESULT":return oe(U({},e),{routingResult:t.result});case"SET_ERROR":return oe(U({},e),{error:t.error,loading:!1,progressMessage:"",progressSteps:[]});case"SET_SEND_ERROR":return oe(U({},e),{sendError:t.error,loading:!1,progressMessage:"",progressSteps:[]});case"CLEAR_SEND_ERROR":return oe(U({},e),{sendError:null});case"LOAD_HISTORY":return oe(U({},e),{messages:t.messages,loading:!1});case"SET_SESSION_EXPIRED":return oe(U({},e),{sessionExpired:t.expired});case"RESET":return oe(U({},Tg),{connectionStatus:e.connectionStatus,loading:!0});default:return e}}const bg=Y.createContext({connectionStatus:"disconnected",isConnected:!1,isAgentTyping:!1,conversationId:null,messages:[],streamingBlocks:[],progressMessage:"",progressSteps:[],loading:!0,error:null,sendError:null,sessionExpired:!1,sendMessage:()=>{},addToCart:()=>{},resetConversation:()=>{},retryLastMessage:()=>{},retryConnection:()=>{},downloadTranscript:()=>je(null,null,function*(){})});function $d(e,t){return`cim_af_conv_${e}_${t}`}function Vd(e,t){return Date.now()-e>t}function gA(e,t,n){try{const r=$d(e,t),o=sessionStorage.getItem(r);if(!o)return null;const a=JSON.parse(o);if(!a||typeof a!="object"||!("conversationId"in a)||!("storedAt"in a))return null;const u=a;return typeof u.conversationId!="string"||!u.conversationId?null:typeof u.storedAt!="number"||Vd(u.storedAt,n)?(sessionStorage.removeItem(r),null):u}catch(r){return null}}function Qs(e,t,n){try{const r=$d(e,t),o={conversationId:n,storedAt:Date.now()};sessionStorage.setItem(r,JSON.stringify(o))}catch(r){}}function Hu(e,t){try{const n=$d(e,t);sessionStorage.removeItem(n)}catch(n){}}function qd(e,t){return`cim_af_ct_${e}_${t}`}function xg(e,t,n){try{const r=qd(e,t),o=sessionStorage.getItem(r);if(!o)return null;const a=JSON.parse(o);if(!a||typeof a!="object"||!("accessToken"in a)||!("lastEventId"in a)||!("storedAt"in a))return null;const u=a;return typeof u.accessToken!="string"||!u.accessToken||typeof u.lastEventId!="string"||!u.lastEventId?null:typeof u.storedAt!="number"||Date.now()-u.storedAt>n?(sessionStorage.removeItem(r),null):u}catch(r){return null}}function EA(e,t,n,r){try{const o=qd(e,t),a={accessToken:n,lastEventId:r,storedAt:Date.now()};sessionStorage.setItem(o,JSON.stringify(a))}catch(o){}}function yA(e,t){try{const n=qd(e,t);sessionStorage.removeItem(n)}catch(n){}}function TA(e,t){return`cim_af_conv_${e}_${t}`}function bA(e,t){try{if(typeof BroadcastChannel=="undefined")return null;const n=TA(e,t);return new BroadcastChannel(n)}catch(n){return null}}function xA(e,t=500){return e?new Promise(n=>{let r=!1;const o=setTimeout(()=>{r||(r=!0,e.removeEventListener("message",a),n(null))},t);function a(u){var c;r||((c=u.data)==null?void 0:c.type)==="conversation_response"&&(r=!0,clearTimeout(o),e.removeEventListener("message",a),n({conversationId:u.data.conversationId,storedAt:u.data.storedAt,continuationToken:u.data.continuationToken,lastEventId:u.data.lastEventId}))}e.addEventListener("message",a);try{e.postMessage({type:"request_conversation"})}catch(u){r||(r=!0,clearTimeout(o),e.removeEventListener("message",a),n(null))}}):Promise.resolve(null)}function _A(e,t,n){if(!e)return()=>{};function r(o){var a;if((a=o.data)!=null&&a.type)switch(o.data.type){case"request_conversation":{const u=t();if(u!=null&&u.conversationId)try{e.postMessage({type:"conversation_response",conversationId:u.conversationId,storedAt:Date.now(),continuationToken:u.continuationToken,lastEventId:u.lastEventId})}catch(c){}break}case"conversation_cleared":{n==null||n();break}}}return e.addEventListener("message",r),()=>{e.removeEventListener("message",r)}}function wA(e){if(e)try{e.postMessage({type:"conversation_cleared"})}catch(t){}}function SA(e){if(e)try{e.close()}catch(t){}}function vA(e){switch(e){case"EndUser":case"Customer":return"user";case"Agent":case"Chatbot":return"agent";default:return"system"}}function AA(e){if(!e)return{};if(typeof e=="string")try{return JSON.parse(e)}catch(t){return{}}return e}function _g(e,...t){let n=e;for(const r of t){if(n==null||typeof n!="object")return"";n=n[r]}return typeof n=="string"?n:""}function kA(e){if(e.entryType!=="Message")return null;const n=AA(e.entryPayload).abstractMessage;if(!n)return null;const r=_g(n,"staticContent","text")||_g(n,"content","text")||"";if(!r)return null;const o=vA(e.sender.role);return{id:e.identifier,role:o,content:r,timestamp:new Date(e.transcriptedTimestamp).toISOString(),sender:{role:e.sender.role,name:e.senderDisplayName}}}function CA(e){const t=[];for(const n of e){const r=kA(n);r&&t.push(r)}return t}const wg="onCimulateWidgetReady",NA=5e3;function Js(e={}){const{routingAttributes:t,timeoutMs:n=NA}=e;if(typeof window=="undefined"||typeof window.dispatchEvent!="function")return Promise.resolve(t);const r=U({},t!=null?t:{});return new Promise(o=>{const a={settled:!1},u=()=>{if(a.settled)return;a.settled=!0,a.timer!==void 0&&clearTimeout(a.timer);const p=Object.keys(r).length>0;o(p?r:t)},c={routingAttributes:t,setHiddenPrechatFields:p=>{a.settled||!p||Object.assign(r,p)},done:u},d=new CustomEvent(wg,{detail:c,cancelable:!0});if(!!window.dispatchEvent(d)){u();return}a.timer=setTimeout(u,n)})}function OA(e){const{orgId:t,esDeveloperName:n,routingAttributes:r,conversationHistory:o}=e,a=Y.useRef(null),u=Y.useRef(null),c=Y.useRef(null),d=o.sinceHours*60*60*1e3,h=Y.useCallback(()=>(c.current||(c.current=xA(a.current)),c.current),[]);Y.useEffect(()=>{const C=bA(t,n);a.current=C,c.current=null;const v=_A(C,()=>{const k=u.current;if(!k)return null;const R=xg(t,n,d);return{conversationId:k,continuationToken:R==null?void 0:R.accessToken,lastEventId:R==null?void 0:R.lastEventId}},()=>{Hu(t,n),u.current=null});return()=>{v(),SA(C),a.current=null}},[t,n,d]);const p=Y.useCallback(C=>je(null,null,function*(){let v=gA(t,n,d);if(!v){const k=yield h();k&&!Vd(k.storedAt,d)&&(v=k)}if(!v){const k=yield C.createConversation(yield Js({routingAttributes:r}));return Qs(t,n,k),u.current=k,{conversationId:k,restoredMessages:[],resumed:!1}}try{const k=Date.now()-d,j=(yield C.listConversations({conversationId:v.conversationId,startTimestamp:k})).conversations.find(M=>M.conversationId===v.conversationId&&!M.isConversationClosed);if(!j){Hu(t,n);const M=yield C.createConversation(yield Js({routingAttributes:r}));return Qs(t,n,M),u.current=M,{conversationId:M,restoredMessages:[],resumed:!1}}C.resumeConversation(j.conversationId),u.current=j.conversationId,Qs(t,n,j.conversationId);let G=[];try{const M=yield C.listConversationEntries(j.conversationId,{limit:o.limit,startTimestamp:k,direction:"FromStart"});G=CA(M.conversationEntries)}catch(M){}return{conversationId:j.conversationId,restoredMessages:G,resumed:!0}}catch(k){Hu(t,n);const R=yield C.createConversation(yield Js({routingAttributes:r}));return Qs(t,n,R),u.current=R,{conversationId:R,restoredMessages:[],resumed:!1}}}),[t,n,r,o,d,h]),m=Y.useCallback(C=>{Qs(t,n,C),u.current=C},[t,n]),b=Y.useCallback(()=>{Hu(t,n),yA(t,n),wA(a.current),u.current=null},[t,n]),y=Y.useCallback(()=>{const C=xg(t,n,d);return C?{continuationToken:C.accessToken,lastEventId:C.lastEventId}:null},[t,n,d]),_=Y.useCallback(()=>je(null,null,function*(){const C=yield h();return!(C!=null&&C.continuationToken)||Vd(C.storedAt,d)?null:{continuationToken:C.continuationToken,lastEventId:C.lastEventId}}),[d,h]),A=Y.useCallback(C=>je(null,null,function*(){try{const{accessToken:v,lastEventId:k}=yield C.generateContinuationToken();EA(t,n,v,k)}catch(v){}}),[t,n]);return{initializeConversation:p,persistConversationId:m,clearPersistedConversation:b,getStoredConnectOptions:y,getPeerConnectOptions:_,persistContinuationToken:A}}const _r={default:"Something went wrong. Please try again.",server:"Something went wrong. Please try again.",rateLimit:"We are getting a lot of requests right now. Please try again in a moment.",network:"You are offline or we couldn't reach the assistant. Check connection and try again.",interrupted:"Something went wrong. Please try again.",connect:"You are offline or we couldn't reach the assistant. Check connection and try again.",lost:"You are offline or we couldn't reach the assistant. Check connection and try again.",routing:"Something went wrong. Please try again."};function PA(e){if(!e||typeof e!="object")return{};const t=e;return{type:typeof t.type=="string"?t.type:void 0,statusCode:typeof t.statusCode=="number"?t.statusCode:void 0}}function Ro(e){const{type:t,statusCode:n}=PA(e);if(t==="api"&&typeof n=="number")return n===429?_r.rateLimit:n>=500?_r.server:_r.default;switch(t){case"network":return _r.network;case"sse":return _r.interrupted;case"auth":return _r.connect;default:return _r.default}}function Sg(e){switch(e.code){case"MAX_RECONNECT":return _r.lost;case"ROUTING_FAILED":return _r.routing;default:return _r.connect}}const IA="Your session ended due to inactivity. Starting a new session…";function vg(e){if(!e||typeof e!="object")return!1;const t=e;return t.type==="auth"?!0:t.type==="api"&&(t.statusCode===401||t.statusCode===403)}function RA(e){var b;const t=e.productName||"this product",n=e.quantity&&e.quantity>1?e.quantity:void 0,r=((b=e.variants)!=null?b:[]).filter(y=>y.value),o=r.map(y=>`${y.label}: ${y.value}`).join(", "),a=r.map(y=>y.value).join(", "),u=o?` (${o})`:"",c=a?` (${a})`:"",d=n?`Add ${n} of`:"Add",h=e.sku?` [SKU: ${e.sku}]`:"",p=`${d} ${t} to my cart${u}${h}`,m=`Add ${n?`${n} × `:""}${t} to cart${c}`;return{prompt:p,display:m}}const Ag=({scrt2Url:e,orgId:t,esDeveloperName:n,routingAttributes:r,capabilitiesVersion:o,enableLogging:a=!1,onConnect:u,onMessage:c,onError:d,children:h})=>{const{logger:p,conversationHistory:m}=dt(),[b,y]=Y.useReducer(mA,Tg),_=Y.useRef(b);_.current=b;const A=OA({orgId:t,esDeveloperName:n,routingAttributes:r,conversationHistory:m}),C=Y.useRef(null),v=Y.useRef(c),k=Y.useRef(d),R=Y.useRef(u),j=Y.useRef(!1),G=Y.useRef(!1),M=Y.useRef(0),Z=Y.useRef(null);v.current=c,k.current=d,R.current=u,Y.useEffect(()=>{const z=new hS({baseURL:e,orgId:t,esDeveloperName:n,options:U({enableLogging:a},o?{capabilitiesVersion:o}:{})});C.current=z,z.on("connected",()=>{var w;y({type:"SET_CONNECTION_STATUS",status:"connected"}),(w=R.current)==null||w.call(R)}),z.on("disconnected",()=>{y({type:"SET_CONNECTION_STATUS",status:"disconnected"})}),z.on("reconnecting",()=>{y({type:"SET_CONNECTION_STATUS",status:"reconnecting"})}),z.on("message",w=>{var V;const N={id:w.messageId||crypto.randomUUID(),role:"agent",content:w.content,timestamp:w.timestamp,sender:w.sender,raw:w};p==null||p.log("🦜 MessagingProvider message received (FLUSH_STREAMING)",{messageId:N.id,tokensBeforeFlush:M.current,streamedFinalOnly:M.current===0}),M.current=0,y({type:"FLUSH_STREAMING",message:N}),(V=v.current)==null||V.call(v,N)}),z.on("streaming_token",w=>{M.current+=1,y({type:"APPEND_STREAMING_TOKEN",token:w.token})}),z.on("typing_started",()=>{y({type:"SET_AGENT_TYPING",isTyping:!0})}),z.on("typing_stopped",()=>{y({type:"SET_AGENT_TYPING",isTyping:!1})}),z.on("progress_indicator",w=>{y({type:"ADD_PROGRESS_STEP",message:w.message})}),z.on("routing_result",w=>{var N;if(y({type:"SET_ROUTING_RESULT",result:w}),!w.isSuccessful){const V=`Routing failed: ${w.failureType||"unknown"}`;y({type:"SET_ERROR",error:Sg({code:"ROUTING_FAILED"})}),y({type:"SET_CONNECTION_STATUS",status:"error"}),(N=k.current)==null||N.call(k,V)}}),z.on("participant_changed",w=>{if(w.participant.name==="Automated Process")return;const N={id:crypto.randomUUID(),role:"system",content:w.action==="add"?`${w.participant.name||"Agent"} joined the conversation`:`${w.participant.name||"Agent"} left the conversation`,timestamp:new Date().toISOString()};p==null||p.log("🦜 MessagingProvider participant_changed event received",{event:w}),y({type:"ADD_MESSAGE",message:N})}),z.on("conversation_closed",()=>{const w={id:crypto.randomUUID(),role:"system",content:"Conversation reset",timestamp:new Date().toISOString()};y({type:"ADD_MESSAGE",message:w}),y({type:"SET_CONVERSATION_ID",id:null}),A.clearPersistedConversation()}),z.on("error",w=>{var N;if(p==null||p.log("🦜 MessagingProvider ERROR event received",{event:w}),w.code==="SESSION_EXPIRED"){G.current=!0,y({type:"SET_SESSION_EXPIRED",expired:!0}),y({type:"SET_CONNECTION_STATUS",status:"disconnected"}),y({type:"SET_LOADING",isLoading:!1});return}y({type:"SET_ERROR",error:Sg(w)}),w.recoverable||y({type:"SET_CONNECTION_STATUS",status:"error"}),(N=k.current)==null||N.call(k,w.message)}),y({type:"SET_CONNECTION_STATUS",status:"connecting"});const ee=()=>je(null,null,function*(){let w=A.getStoredConnectOptions(),N=!1;w||(w=yield A.getPeerConnectOptions(),N=!!w);try{yield z.connect(w!=null?w:void 0)}catch(I){if(w)p==null||p.log("Continuation token failed, falling back to fresh connect"),N||A.clearPersistedConversation(),yield z.connect();else throw I}yield A.persistContinuationToken(z);const V=yield A.initializeConversation(z);y({type:"SET_CONVERSATION_ID",id:V.conversationId}),V.resumed&&V.restoredMessages.length>0&&y({type:"LOAD_HISTORY",messages:V.restoredMessages})});return Z.current=ee,ee().catch(w=>{var N;y({type:"SET_CONNECTION_STATUS",status:"error"}),y({type:"SET_ERROR",error:Ro(w)}),(N=k.current)==null||N.call(k,w.message)}),()=>{z.disconnect(),z.off(),C.current=null,Z.current=null}},[e,t,n,o]),Y.useEffect(()=>{const z=()=>{document.visibilityState==="visible"&&C.current&&!G.current&&C.current.reconnect()};return document.addEventListener("visibilitychange",z),()=>{document.removeEventListener("visibilitychange",z)}},[]);const ue=Y.useCallback(z=>je(null,null,function*(){var w;const ee=C.current;if(!(!ee||j.current)){j.current=!0,G.current=!1,y({type:"SET_SESSION_EXPIRED",expired:!1}),y({type:"ADD_MESSAGE",message:{id:crypto.randomUUID(),role:"system",content:IA,timestamp:new Date().toISOString()}}),A.clearPersistedConversation(),y({type:"SET_CONNECTION_STATUS",status:"connecting"});try{ee.disconnect(),yield ee.connect(),yield A.persistContinuationToken(ee);const N=yield ee.createConversation(yield Js({routingAttributes:r}));y({type:"SET_CONVERSATION_ID",id:N}),y({type:"SET_CONNECTION_STATUS",status:"connected"}),A.persistConversationId(N),z&&(y({type:"SET_LOADING",isLoading:!0}),y({type:"SET_PROGRESS_MESSAGE",message:""}),yield ee.sendMessage(z))}catch(N){const V=N instanceof Error?N.message:String(N);y({type:"SET_ERROR",error:Ro(N)}),y({type:"SET_CONNECTION_STATUS",status:"error"}),(w=k.current)==null||w.call(k,V)}finally{j.current=!1}}}),[r,A]),pe=Y.useRef(ue);pe.current=ue;const $=Y.useCallback((z,ee)=>{const w=C.current;if(!w)return;const N={id:crypto.randomUUID(),role:"user",content:ee!=null?ee:z,timestamp:new Date().toISOString()};if(y({type:"CLEAR_SEND_ERROR"}),y({type:"ADD_MESSAGE",message:N}),y({type:"SET_LOADING",isLoading:!0}),y({type:"SET_PROGRESS_MESSAGE",message:""}),G.current){pe.current(z);return}w.sendMessage(z).catch(V=>{var I;if(vg(V)){pe.current(z);return}y({type:"SET_SEND_ERROR",error:{text:z,displayContent:ee,message:Ro(V)}}),(I=k.current)==null||I.call(k,V.message)})},[]),te=Y.useCallback(z=>{z.trim()&&$(z)},[$]),re=Y.useCallback(z=>{if(!C.current)return;const{prompt:ee,display:w}=RA(z);$(ee,w)},[$]),de=Y.useCallback(()=>{const z=C.current,ee=_.current.sendError;if(!(!z||!ee)){if(y({type:"CLEAR_SEND_ERROR"}),y({type:"SET_LOADING",isLoading:!0}),y({type:"SET_PROGRESS_MESSAGE",message:""}),G.current){pe.current(ee.text);return}z.sendMessage(ee.text).catch(w=>{var N;if(vg(w)){pe.current(ee.text);return}y({type:"SET_SEND_ERROR",error:oe(U({},ee),{message:Ro(w)})}),(N=k.current)==null||N.call(k,w.message)})}},[]),ae=Y.useCallback(()=>{const z=C.current,ee=Z.current;!z||!ee||(G.current=!1,z.disconnect(),y({type:"SET_CONNECTION_STATUS",status:"connecting"}),ee().catch(w=>{var N;y({type:"SET_CONNECTION_STATUS",status:"error"}),y({type:"SET_ERROR",error:Ro(w)}),(N=k.current)==null||N.call(k,w.message)}))},[]),ye=Y.useCallback(()=>{const z=C.current;z&&(G.current=!1,A.clearPersistedConversation(),y({type:"RESET"}),y({type:"SET_CONNECTION_STATUS",status:"connecting"}),z.endConversation().then(()=>(z.disconnect(),z.connect())).then(()=>je(null,null,function*(){return yield A.persistContinuationToken(z),z.createConversation(yield Js({routingAttributes:r}))})).then(ee=>{y({type:"SET_CONVERSATION_ID",id:ee}),y({type:"SET_CONNECTION_STATUS",status:"connected"}),A.persistConversationId(ee)}).catch(ee=>{var w;y({type:"SET_ERROR",error:Ro(ee)}),y({type:"SET_CONNECTION_STATUS",status:"error"}),(w=k.current)==null||w.call(k,ee.message)}))},[r,A]),ve=Y.useCallback(()=>je(null,null,function*(){var N;const z=C.current;if(!z)return;const ee=yield z.retrieveConversationTranscript(),w=URL.createObjectURL(ee);try{const V=document.createElement("a");V.href=w,V.download=`transcript-${(N=z.conversationId)!=null?N:"conversation"}.pdf`,document.body.appendChild(V),V.click(),V.remove()}finally{URL.revokeObjectURL(w)}}),[]),se=Y.useMemo(()=>({connectionStatus:b.connectionStatus,isConnected:b.connectionStatus==="connected"&&b.conversationId!==null,isAgentTyping:b.isAgentTyping,conversationId:b.conversationId,messages:b.messages,streamingBlocks:b.streamingBlocks,progressMessage:b.progressMessage,progressSteps:b.progressSteps,error:b.error,sendError:b.sendError,loading:b.loading,sessionExpired:b.sessionExpired,sendMessage:te,addToCart:re,resetConversation:ye,retryLastMessage:de,retryConnection:ae,downloadTranscript:ve}),[b,te,re,ye,de,ae,ve]);return x.jsx(bg.Provider,{value:se,children:h})};var kg=Symbol.for("immer-nothing"),Cg=Symbol.for("immer-draftable"),Cn=Symbol.for("immer-state");function ir(e,...t){throw new Error(`[Immer] minified error nr: ${e}. Full error at: https://bit.ly/3cXEKWf`)}var Lo=Object.getPrototypeOf;function Do(e){return!!e&&!!e[Cn]}function $i(e){var t;return e?Ng(e)||Array.isArray(e)||!!e[Cg]||!!((t=e.constructor)!=null&&t[Cg])||$u(e)||Vu(e):!1}var LA=Object.prototype.constructor.toString();function Ng(e){if(!e||typeof e!="object")return!1;const t=Lo(e);if(t===null)return!0;const n=Object.hasOwnProperty.call(t,"constructor")&&t.constructor;return n===Object?!0:typeof n=="function"&&Function.toString.call(n)===LA}function ju(e,t){zu(e)===0?Reflect.ownKeys(e).forEach(n=>{t(n,e[n],e)}):e.forEach((n,r)=>t(r,n,e))}function zu(e){const t=e[Cn];return t?t.type_:Array.isArray(e)?1:$u(e)?2:Vu(e)?3:0}function Yd(e,t){return zu(e)===2?e.has(t):Object.prototype.hasOwnProperty.call(e,t)}function Og(e,t,n){const r=zu(e);r===2?e.set(t,n):r===3?e.add(n):e[t]=n}function DA(e,t){return e===t?e!==0||1/e===1/t:e!==e&&t!==t}function $u(e){return e instanceof Map}function Vu(e){return e instanceof Set}function Vi(e){return e.copy_||e.base_}function Wd(e,t){if($u(e))return new Map(e);if(Vu(e))return new Set(e);if(Array.isArray(e))return Array.prototype.slice.call(e);const n=Ng(e);if(t===!0||t==="class_only"&&!n){const r=Object.getOwnPropertyDescriptors(e);delete r[Cn];let o=Reflect.ownKeys(r);for(let a=0;a<o.length;a++){const u=o[a],c=r[u];c.writable===!1&&(c.writable=!0,c.configurable=!0),(c.get||c.set)&&(r[u]={configurable:!0,writable:!0,enumerable:c.enumerable,value:e[u]})}return Object.create(Lo(e),r)}else{const r=Lo(e);if(r!==null&&n)return U({},e);const o=Object.create(r);return Object.assign(o,e)}}function Gd(e,t=!1){return qu(e)||Do(e)||!$i(e)||(zu(e)>1&&(e.set=e.add=e.clear=e.delete=MA),Object.freeze(e),t&&Object.entries(e).forEach(([n,r])=>Gd(r,!0))),e}function MA(){ir(2)}function qu(e){return Object.isFrozen(e)}var FA={};function qi(e){const t=FA[e];return t||ir(0,e),t}var Zs;function Pg(){return Zs}function BA(e,t){return{drafts_:[],parent_:e,immer_:t,canAutoFreeze_:!0,unfinalizedDrafts_:0}}function Ig(e,t){t&&(qi("Patches"),e.patches_=[],e.inversePatches_=[],e.patchListener_=t)}function Xd(e){Kd(e),e.drafts_.forEach(UA),e.drafts_=null}function Kd(e){e===Zs&&(Zs=e.parent_)}function Rg(e){return Zs=BA(Zs,e)}function UA(e){const t=e[Cn];t.type_===0||t.type_===1?t.revoke_():t.revoked_=!0}function Lg(e,t){t.unfinalizedDrafts_=t.drafts_.length;const n=t.drafts_[0];return e!==void 0&&e!==n?(n[Cn].modified_&&(Xd(t),ir(4)),$i(e)&&(e=Yu(t,e),t.parent_||Wu(t,e)),t.patches_&&qi("Patches").generateReplacementPatches_(n[Cn].base_,e,t.patches_,t.inversePatches_)):e=Yu(t,n,[]),Xd(t),t.patches_&&t.patchListener_(t.patches_,t.inversePatches_),e!==kg?e:void 0}function Yu(e,t,n){if(qu(t))return t;const r=t[Cn];if(!r)return ju(t,(o,a)=>Dg(e,r,t,o,a,n)),t;if(r.scope_!==e)return t;if(!r.modified_)return Wu(e,r.base_,!0),r.base_;if(!r.finalized_){r.finalized_=!0,r.scope_.unfinalizedDrafts_--;const o=r.copy_;let a=o,u=!1;r.type_===3&&(a=new Set(o),o.clear(),u=!0),ju(a,(c,d)=>Dg(e,r,o,c,d,n,u)),Wu(e,o,!1),n&&e.patches_&&qi("Patches").generatePatches_(r,n,e.patches_,e.inversePatches_)}return r.copy_}function Dg(e,t,n,r,o,a,u){if(Do(o)){const c=a&&t&&t.type_!==3&&!Yd(t.assigned_,r)?a.concat(r):void 0,d=Yu(e,o,c);if(Og(n,r,d),Do(d))e.canAutoFreeze_=!1;else return}else u&&n.add(o);if($i(o)&&!qu(o)){if(!e.immer_.autoFreeze_&&e.unfinalizedDrafts_<1)return;Yu(e,o),(!t||!t.scope_.parent_)&&typeof r!="symbol"&&Object.prototype.propertyIsEnumerable.call(n,r)&&Wu(e,o)}}function Wu(e,t,n=!1){!e.parent_&&e.immer_.autoFreeze_&&e.canAutoFreeze_&&Gd(t,n)}function HA(e,t){const n=Array.isArray(e),r={type_:n?1:0,scope_:t?t.scope_:Pg(),modified_:!1,finalized_:!1,assigned_:{},parent_:t,base_:e,draft_:null,copy_:null,revoke_:null,isManual_:!1};let o=r,a=Qd;n&&(o=[r],a=ea);const{revoke:u,proxy:c}=Proxy.revocable(o,a);return r.draft_=c,r.revoke_=u,c}var Qd={get(e,t){if(t===Cn)return e;const n=Vi(e);if(!Yd(n,t))return jA(e,n,t);const r=n[t];return e.finalized_||!$i(r)?r:r===Jd(e.base_,t)?(ef(e),e.copy_[t]=tf(r,e)):r},has(e,t){return t in Vi(e)},ownKeys(e){return Reflect.ownKeys(Vi(e))},set(e,t,n){const r=Mg(Vi(e),t);if(r!=null&&r.set)return r.set.call(e.draft_,n),!0;if(!e.modified_){const o=Jd(Vi(e),t),a=o==null?void 0:o[Cn];if(a&&a.base_===n)return e.copy_[t]=n,e.assigned_[t]=!1,!0;if(DA(n,o)&&(n!==void 0||Yd(e.base_,t)))return!0;ef(e),Zd(e)}return e.copy_[t]===n&&(n!==void 0||t in e.copy_)||Number.isNaN(n)&&Number.isNaN(e.copy_[t])||(e.copy_[t]=n,e.assigned_[t]=!0),!0},deleteProperty(e,t){return Jd(e.base_,t)!==void 0||t in e.base_?(e.assigned_[t]=!1,ef(e),Zd(e)):delete e.assigned_[t],e.copy_&&delete e.copy_[t],!0},getOwnPropertyDescriptor(e,t){const n=Vi(e),r=Reflect.getOwnPropertyDescriptor(n,t);return r&&{writable:!0,configurable:e.type_!==1||t!=="length",enumerable:r.enumerable,value:n[t]}},defineProperty(){ir(11)},getPrototypeOf(e){return Lo(e.base_)},setPrototypeOf(){ir(12)}},ea={};ju(Qd,(e,t)=>{ea[e]=function(){return arguments[0]=arguments[0][0],t.apply(this,arguments)}}),ea.deleteProperty=function(e,t){return ea.set.call(this,e,t,void 0)},ea.set=function(e,t,n){return Qd.set.call(this,e[0],t,n,e[0])};function Jd(e,t){const n=e[Cn];return(n?Vi(n):e)[t]}function jA(e,t,n){var o;const r=Mg(t,n);return r?"value"in r?r.value:(o=r.get)==null?void 0:o.call(e.draft_):void 0}function Mg(e,t){if(!(t in e))return;let n=Lo(e);for(;n;){const r=Object.getOwnPropertyDescriptor(n,t);if(r)return r;n=Lo(n)}}function Zd(e){e.modified_||(e.modified_=!0,e.parent_&&Zd(e.parent_))}function ef(e){e.copy_||(e.copy_=Wd(e.base_,e.scope_.immer_.useStrictShallowCopy_))}var zA=class{constructor(e){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.produce=(t,n,r)=>{if(typeof t=="function"&&typeof n!="function"){const a=n;n=t;const u=this;return function(d=a,...h){return u.produce(d,p=>n.call(this,p,...h))}}typeof n!="function"&&ir(6),r!==void 0&&typeof r!="function"&&ir(7);let o;if($i(t)){const a=Rg(this),u=tf(t,void 0);let c=!0;try{o=n(u),c=!1}finally{c?Xd(a):Kd(a)}return Ig(a,r),Lg(o,a)}else if(!t||typeof t!="object"){if(o=n(t),o===void 0&&(o=t),o===kg&&(o=void 0),this.autoFreeze_&&Gd(o,!0),r){const a=[],u=[];qi("Patches").generateReplacementPatches_(t,o,a,u),r(a,u)}return o}else ir(1,t)},this.produceWithPatches=(t,n)=>{if(typeof t=="function")return(u,...c)=>this.produceWithPatches(u,d=>t(d,...c));let r,o;return[this.produce(t,n,(u,c)=>{r=u,o=c}),r,o]},typeof(e==null?void 0:e.autoFreeze)=="boolean"&&this.setAutoFreeze(e.autoFreeze),typeof(e==null?void 0:e.useStrictShallowCopy)=="boolean"&&this.setUseStrictShallowCopy(e.useStrictShallowCopy)}createDraft(e){$i(e)||ir(8),Do(e)&&(e=$A(e));const t=Rg(this),n=tf(e,void 0);return n[Cn].isManual_=!0,Kd(t),n}finishDraft(e,t){const n=e&&e[Cn];(!n||!n.isManual_)&&ir(9);const{scope_:r}=n;return Ig(r,t),Lg(void 0,r)}setAutoFreeze(e){this.autoFreeze_=e}setUseStrictShallowCopy(e){this.useStrictShallowCopy_=e}applyPatches(e,t){let n;for(n=t.length-1;n>=0;n--){const o=t[n];if(o.path.length===0&&o.op==="replace"){e=o.value;break}}n>-1&&(t=t.slice(n+1));const r=qi("Patches").applyPatches_;return Do(e)?r(e,t):this.produce(e,o=>r(o,t))}};function tf(e,t){const n=$u(e)?qi("MapSet").proxyMap_(e,t):Vu(e)?qi("MapSet").proxySet_(e,t):HA(e,t);return(t?t.scope_:Pg()).drafts_.push(n),n}function $A(e){return Do(e)||ir(10,e),Fg(e)}function Fg(e){if(!$i(e)||qu(e))return e;const t=e[Cn];let n;if(t){if(!t.modified_)return t.base_;t.finalized_=!0,n=Wd(e,t.scope_.immer_.useStrictShallowCopy_)}else n=Wd(e,!0);return ju(n,(r,o)=>{Og(n,r,Fg(o))}),t&&(t.finalized_=!1),n}var Nn=new zA,VA=Nn.produce;Nn.produceWithPatches.bind(Nn),Nn.setAutoFreeze.bind(Nn),Nn.setUseStrictShallowCopy.bind(Nn),Nn.applyPatches.bind(Nn),Nn.createDraft.bind(Nn),Nn.finishDraft.bind(Nn);function qA(e,t,n){var r=Y.useMemo(function(){return VA(e)},[e]);return Y.useReducer(r,t,n)}const at={SET_PROMPTS_EXTENSION_INITIALIZED:"SET_PROMPTS_EXTENSION_INITIALIZED",SET_PROMPTS_EXTENSION_OPEN:"SET_PROMPTS_EXTENSION_OPEN",SET_PROMPTS_EXTENSION_INLINE:"SET_PROMPTS_EXTENSION_INLINE",SET_PROMPTS_EXTENSION_ELEMENT_ID:"SET_PROMPTS_EXTENSION_ELEMENT_ID",SET_PROMPTS_EXTENSION_ENTRY_TYPE:"SET_PROMPTS_EXTENSION_ENTRY_TYPE",SET_PROMPTS_EXTENSION_PARAMS:"SET_PROMPTS_EXTENSION_PARAMS",RESET_PROMPTS_EXTENSION_PARAMS:"RESET_PROMPTS_EXTENSION_PARAMS",SET_PROMPTS_EXTENSION_ACTIVE_PROMPTS_ID:"SET_PROMPTS_EXTENSION_ACTIVE_PROMPTS_ID",RESET_PROMPTS_EXTENSION_ACTIVE_PROMPTS_ID:"RESET_PROMPTS_EXTENSION_ACTIVE_PROMPTS_ID",SET_PROMPTS_EXTENSION_USER_PROMPT:"SET_PROMPTS_EXTENSION_USER_PROMPT",SET_PROMPTS_EXTENSION_PROMPTS_MESSAGE:"SET_PROMPTS_EXTENSION_PROMPTS_MESSAGE",RESET_PROMPTS_EXTENSION_PROMPTS_MESSAGE:"RESET_PROMPTS_EXTENSION_PROMPTS_MESSAGE",SET_PROMPTS_EXTENSION_RESPONSE_MESSAGE:"SET_PROMPTS_EXTENSION_RESPONSE_MESSAGE",RESET_PROMPTS_EXTENSION_RESPONSE_MESSAGE:"RESET_PROMPTS_EXTENSION_RESPONSE_MESSAGE",SET_PROMPTS_EXTENSION_RESPONSE_LOADING:"SET_PROMPTS_EXTENSION_RESPONSE_LOADING"},Bg={isInitialized:!1,isOpen:!1,isInline:!1,elementId:null,placeholder:null,askElseButtonLabel:null,entryType:null,params:null,activePromptsId:null,userPrompt:null,promptsMessage:null,isResponseLoading:!1,responseMessage:null,promptsDisplay:"both",disableAskElseButton:!1},Ug=Y.createContext(null),Hg=Y.createContext(null),YA=({children:e,dispatch:t})=>{const n=Y.useCallback(_=>{t({type:at.SET_PROMPTS_EXTENSION_INITIALIZED,payload:_})},[t]),r=Y.useCallback(_=>{t({type:at.SET_PROMPTS_EXTENSION_OPEN,payload:_})},[t]),o=Y.useCallback(_=>{t({type:at.SET_PROMPTS_EXTENSION_INLINE,payload:_})},[t]),a=Y.useCallback(_=>{t({type:at.SET_PROMPTS_EXTENSION_ELEMENT_ID,payload:_})},[t]),u=Y.useCallback(_=>{t({type:at.SET_PROMPTS_EXTENSION_ENTRY_TYPE,payload:_})},[t]),c=Y.useCallback(_=>{t({type:at.SET_PROMPTS_EXTENSION_ACTIVE_PROMPTS_ID,payload:_})},[t]),d=Y.useCallback(_=>{t({type:at.SET_PROMPTS_EXTENSION_USER_PROMPT,payload:_})},[t]),h=Y.useCallback(_=>{t({type:at.SET_PROMPTS_EXTENSION_PARAMS,payload:_})},[t]),p=Y.useCallback(_=>{t({type:at.SET_PROMPTS_EXTENSION_PROMPTS_MESSAGE,payload:_})},[t]),m=Y.useCallback(_=>{t({type:at.SET_PROMPTS_EXTENSION_RESPONSE_MESSAGE,payload:_})},[t]),b=Y.useCallback(_=>{t({type:at.SET_PROMPTS_EXTENSION_RESPONSE_LOADING,payload:_})},[t]),y=Y.useMemo(()=>({setIsInitialized:n,setIsOpen:r,setIsInline:o,setElementId:a,setEntryType:u,setActivePromptsId:c,setUserPrompt:d,setParams:h,setPromptsMessage:p,setResponseMessage:m,setIsResponseLoading:b}),[n,r,o,a,u,c,d,h,p,m,b]);return x.jsx(Hg.Provider,{value:y,children:e})},WA=(e,t)=>{const{type:n,payload:r}=t;switch(n){case at.SET_PROMPTS_EXTENSION_INITIALIZED:e.isInitialized=r;break;case at.SET_PROMPTS_EXTENSION_OPEN:e.isOpen=r;break;case at.SET_PROMPTS_EXTENSION_INLINE:e.isInline=r;break;case at.SET_PROMPTS_EXTENSION_ELEMENT_ID:e.elementId=r;break;case at.SET_PROMPTS_EXTENSION_ENTRY_TYPE:e.entryType=r;break;case at.SET_PROMPTS_EXTENSION_PARAMS:e.params=r;break;case at.RESET_PROMPTS_EXTENSION_PARAMS:e.params=null;break;case at.SET_PROMPTS_EXTENSION_USER_PROMPT:e.userPrompt=r;break;case at.SET_PROMPTS_EXTENSION_ACTIVE_PROMPTS_ID:e.activePromptsId=r;break;case at.RESET_PROMPTS_EXTENSION_ACTIVE_PROMPTS_ID:e.activePromptsId=null;break;case at.SET_PROMPTS_EXTENSION_PROMPTS_MESSAGE:e.promptsMessage=r;break;case at.RESET_PROMPTS_EXTENSION_PROMPTS_MESSAGE:e.promptsMessage=null;break;case at.SET_PROMPTS_EXTENSION_RESPONSE_MESSAGE:e.responseMessage=r;break;case at.RESET_PROMPTS_EXTENSION_RESPONSE_MESSAGE:e.responseMessage=null;break;case at.SET_PROMPTS_EXTENSION_RESPONSE_LOADING:e.isResponseLoading=r;break}},GA=({promptsConfig:e,children:t})=>{const[n,r]=qA(WA,U(U({},Bg),e||{}));return x.jsx(Ug.Provider,{value:n,children:x.jsx(YA,{dispatch:r,children:t})})};function XA(){var e=Y.useRef(!0);return e.current?(e.current=!1,!0):e.current}function KA(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];e&&e.addEventListener&&e.addEventListener.apply(e,t)}function QA(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];e&&e.removeEventListener&&e.removeEventListener.apply(e,t)}var nf=typeof window!="undefined",Gu=function(e){Y.useEffect(e,[])},JA=function(e){var t=Y.useRef(e);t.current=e,Gu(function(){return function(){return t.current()}})},ZA=function(e){var t=Y.useRef(0),n=Y.useState(e),r=n[0],o=n[1],a=Y.useCallback(function(u){cancelAnimationFrame(t.current),t.current=requestAnimationFrame(function(){o(u)})},[]);return JA(function(){cancelAnimationFrame(t.current)}),[r,a]},ek=function(e,t){return e===t};function tk(e,t){t===void 0&&(t=ek);var n=Y.useRef(),r=Y.useRef(e),o=XA();return!o&&!t(r.current,e)&&(n.current=r.current,r.current=e),n.current}var nk=function(e){var t={},n=t.initialWidth,r=n===void 0?1/0:n,o=t.initialHeight,a=o===void 0?1/0:o,u=t.onChange,c=ZA({width:nf?window.innerWidth:r,height:nf?window.innerHeight:a}),d=c[0],h=c[1];return Y.useEffect(function(){if(nf){var p=function(){var m=window.innerWidth,b=window.innerHeight;h({width:m,height:b}),u&&u(m,b)};return KA(window,"resize",p),function(){QA(window,"resize",p)}}},[]),d};const jg="cimulate",rf=`${jg}:ui-state-update`,of=`${jg}:prompts-state-update`,rk=e=>{window.addEventListener(rf,e)},ik=e=>{window.removeEventListener(rf,e)},ok=(e,t)=>{const n=new CustomEvent(rf,{detail:{property:e,value:t}});window.dispatchEvent(n)},zg=e=>{if(!["ask_cim","search","browse","pdp"].includes(e))throw new Error(`Invalid entryType: "${e}". Must be 'ask_cim', 'search', 'browse', or 'pdp'.`);nt.entryTypeProxy.entryType=e},ai=e=>{const t=nt.statusProxy.isOpen,n=typeof e=="boolean"?e:!t;nt.statusProxy.isOpen=n,n&&(nt.statusProxy.isMinimized=!1)},Xu=e=>{const t=nt.statusProxy.isMinimized,n=typeof e=="boolean"?e:!t;nt.statusProxy.isMinimized=n,n&&(nt.statusProxy.isOpen=!1)},sf=e=>{nt.modalProxy.isFullscreen=e},Ku=e=>{if(!["chat","dialog","modal"].includes(e))throw new Error(`Invalid type: ${e}. Must be 'chat', 'dialog', or 'modal'.`);nt.statusProxy.type=e,e==="dialog"||e==="chat"?nt.modeProxy.mode="embedded":nt.modeProxy.mode="standalone"},af=e=>{const t=["top","top-left","top-right","bottom","bottom-left","bottom-right","left","right","center"];if(!t.includes(e))throw new Error(`Invalid position: ${e}. Must be one of ${t.join(", ")}.`);nt.dialogProxy.position=e},sk=e=>{const t=nt.dialogProxy.isFullHeight,n=typeof e=="boolean"?e:!t;nt.dialogProxy.isFullHeight=n};class ak{constructor(){qe(this,"initialState",{connected:!1,mode:"embedded",entryType:"search",status:{type:"dialog",isOpen:!1,isMinimized:!1},dialog:{position:"bottom-left",isFullHeight:!1,width:""},modal:{isFullscreen:!1}});qe(this,"connectedProxy");qe(this,"modeProxy");qe(this,"entryTypeProxy");qe(this,"statusProxy");qe(this,"dialogProxy");qe(this,"modalProxy",{isFullscreen:!1});qe(this,"_fullGet",(t,n)=>Reflect.get(t,n));qe(this,"_fullSet",(t,n,r)=>{if(!(n in t))throw new Error(`Property ${n} does not exist on UIState`);return ok(n,r),Reflect.set(t,n,r)});this.connectedProxy=new Proxy({connected:this.initialState.connected},{get:this._fullGet,set:this._fullSet}),this.modeProxy=new Proxy({mode:this.initialState.mode},{get:this._fullGet,set:this._fullSet}),this.entryTypeProxy=new Proxy({entryType:this.initialState.entryType},{get:this._fullGet,set:this._fullSet}),this.statusProxy=new Proxy({type:this.initialState.status.type,isOpen:this.initialState.status.isOpen,isMinimized:this.initialState.status.isMinimized},{get:this._fullGet,set:this._fullSet}),this.dialogProxy=new Proxy({position:this.initialState.dialog.position,isFullHeight:this.initialState.dialog.isFullHeight,width:this.initialState.dialog.width},{get:this._fullGet,set:this._fullSet}),this.modalProxy=new Proxy({isFullscreen:this.initialState.modal.isFullscreen},{get:this._fullGet,set:this._fullSet})}get connected(){return this.connectedProxy.connected}get mode(){return this.modeProxy.mode}get isOpen(){return!!this.statusProxy.isOpen}get isMinimized(){return!!this.statusProxy.isMinimized}get type(){return this.statusProxy.type}get entryType(){return this.entryTypeProxy.entryType}get position(){return this.dialogProxy.position}get state(){return{connected:this.connected,mode:this.mode,entryType:this.entryType,status:{type:this.type,isOpen:this.isOpen,isMinimized:this.isMinimized},dialog:{position:this.position,isFullHeight:this.dialogProxy.isFullHeight,width:this.dialogProxy.width},modal:{isFullscreen:this.modalProxy.isFullscreen}}}}const nt=new ak,$g=Y.createContext({mode:nt.modeProxy.mode,entryType:nt.entryType,status:nt.statusProxy,dialogPosition:nt.dialogProxy.position,isDialogFullHeight:nt.dialogProxy.isFullHeight,dialogWidth:nt.dialogProxy.width,isModalFullscreen:nt.modalProxy.isFullscreen,previousComponentType:nt.statusProxy.type}),uk=({entryType:e,componentConfig:t,componentType:n,children:r})=>{const[o,a]=Y.useState(e!=null?e:nt.entryTypeProxy.entryType),[u,c]=Y.useState(nt.modeProxy.mode),[d,h]=Y.useState({type:n||nt.statusProxy.type,isOpen:nt.statusProxy.isOpen,isMinimized:nt.statusProxy.isMinimized}),[p,m]=Y.useState(nt.dialogProxy.position),[b,y]=Y.useState(nt.dialogProxy.isFullHeight),[_,A]=Y.useState(nt.dialogProxy.width),[C,v]=Y.useState(nt.modalProxy.isFullscreen),k=tk(d.type);Y.useEffect(()=>{const j=G=>{const{property:M,value:Z}=G.detail||{};if(!(!M||Z===void 0)){if(M==="mode"){c(Z);return}if(M==="entryType"){a(Z);return}if(M==="isMinimized"){h(ue=>oe(U({},ue),{isMinimized:Z}));return}if(M==="isOpen"){h(ue=>oe(U({},ue),{isOpen:Z}));return}if(M==="type"){h(ue=>oe(U({},ue),{type:Z}));return}if(M==="position"){m(Z);return}if(M==="isFullHeight"){y(Z);return}if(M==="width"){A(Z);return}if(M==="isFullscreen"){v(Z);return}}};return rk(j),()=>{ik(j)}},[]),Gu(()=>{e&&zg(e)}),Gu(()=>{const j=n||(t==null?void 0:t.type);j&&Ku(j),t&&"isOpen"in t&&ai(!!t.isOpen),t&&"isMinimized"in t&&Xu(!!t.isMinimized)}),Gu(()=>{if(!(t!=null&&t.options))return;const{dialogPosition:j}=t.options;j&&af(j),"dialogFullHeight"in t.options&&sk(!!t.options.dialogFullHeight),"dialogWidth"in t.options&&t.options.dialogWidth&&A(t.options.dialogWidth),"isModalFullscreen"in t.options&&sf(!!t.options.isModalFullscreen)});const R=Y.useMemo(()=>({mode:u,entryType:o,status:d,previousComponentType:k||"dialog",dialogPosition:p,isDialogFullHeight:b,dialogWidth:_,isModalFullscreen:C}),[u,o,d,k,p,b,_,C]);return x.jsx($g.Provider,{value:R,children:r})},Vg=({mode:e,apiKey:t,apiToken:n,baseUrl:r,logoUrl:o,headerText:a,headerConfig:u,theme:c,openLinksInNewTab:d,globalClassName:h,isDevelopment:p=!1,componentType:m,componentConfig:b,entryType:y,entryMessage:_,disclaimerText:A,disclaimerMarkdown:C,clientContext:v,searchPlaceholder:k,searchButtonLabel:R,searchConfig:j,suggestionButtonConfig:G,messageAlignment:M,autoScroll:Z,promptsConfig:ue,resetConversationMessage:pe,conversationHistory:$,messagingConfig:te,__features:re,children:de})=>x.jsx(dA,{mode:e,baseUrl:r,apiKey:t,apiToken:n,logoUrl:o,headerText:a,headerConfig:u,entryMessage:_,theme:c,globalClassName:h,openLinksInNewTab:d,searchPlaceholder:k,searchButtonLabel:R,searchConfig:j,suggestionButtonConfig:G,messageAlignment:M,autoScroll:Z,componentConfig:b,clientContext:v,disclaimerMarkdown:C,disclaimerText:A,resetConversationMessage:pe,conversationHistory:$,isDevelopment:p,__features:re,routingAttributes:te==null?void 0:te.routingAttributes,enableDownloadTranscript:te==null?void 0:te.enableDownloadTranscript,enableEscalationToAgent:te==null?void 0:te.enableEscalationToAgent,children:x.jsx(uk,{entryType:y,componentConfig:b,componentType:m,children:x.jsx(GA,{promptsConfig:ue,children:x.jsx(Ag,{scrt2Url:(te==null?void 0:te.scrt2Url)||"",orgId:(te==null?void 0:te.orgId)||"",esDeveloperName:(te==null?void 0:te.esDeveloperName)||"",routingAttributes:(te==null?void 0:te.routingAttributes)||{},capabilitiesVersion:te==null?void 0:te.capabilitiesVersion,enableLogging:p,children:de})})})}),Yi=()=>{const e=Y.useContext($g);if(!e)throw new Error("useUIState must be used within a UIStateProvider");return e};var uf={exports:{}},pn={},lf={exports:{}},cf={};var qg;function lk(){return qg||(qg=1,(function(e){function t(z,ee){var w=z.length;z.push(ee);e:for(;0<w;){var N=w-1>>>1,V=z[N];if(0<o(V,ee))z[N]=ee,z[w]=V,w=N;else break e}}function n(z){return z.length===0?null:z[0]}function r(z){if(z.length===0)return null;var ee=z[0],w=z.pop();if(w!==ee){z[0]=w;e:for(var N=0,V=z.length,I=V>>>1;N<I;){var Te=2*(N+1)-1,Ie=z[Te],xe=Te+1,Fe=z[xe];if(0>o(Ie,w))xe<V&&0>o(Fe,Ie)?(z[N]=Fe,z[xe]=w,N=xe):(z[N]=Ie,z[Te]=w,N=Te);else if(xe<V&&0>o(Fe,w))z[N]=Fe,z[xe]=w,N=xe;else break e}}return ee}function o(z,ee){var w=z.sortIndex-ee.sortIndex;return w!==0?w:z.id-ee.id}if(typeof performance=="object"&&typeof performance.now=="function"){var a=performance;e.unstable_now=function(){return a.now()}}else{var u=Date,c=u.now();e.unstable_now=function(){return u.now()-c}}var d=[],h=[],p=1,m=null,b=3,y=!1,_=!1,A=!1,C=typeof setTimeout=="function"?setTimeout:null,v=typeof clearTimeout=="function"?clearTimeout:null,k=typeof setImmediate!="undefined"?setImmediate:null;typeof navigator!="undefined"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function R(z){for(var ee=n(h);ee!==null;){if(ee.callback===null)r(h);else if(ee.startTime<=z)r(h),ee.sortIndex=ee.expirationTime,t(d,ee);else break;ee=n(h)}}function j(z){if(A=!1,R(z),!_)if(n(d)!==null)_=!0,ve(G);else{var ee=n(h);ee!==null&&se(j,ee.startTime-z)}}function G(z,ee){_=!1,A&&(A=!1,v(ue),ue=-1),y=!0;var w=b;try{for(R(ee),m=n(d);m!==null&&(!(m.expirationTime>ee)||z&&!te());){var N=m.callback;if(typeof N=="function"){m.callback=null,b=m.priorityLevel;var V=N(m.expirationTime<=ee);ee=e.unstable_now(),typeof V=="function"?m.callback=V:m===n(d)&&r(d),R(ee)}else r(d);m=n(d)}if(m!==null)var I=!0;else{var Te=n(h);Te!==null&&se(j,Te.startTime-ee),I=!1}return I}finally{m=null,b=w,y=!1}}var M=!1,Z=null,ue=-1,pe=5,$=-1;function te(){return!(e.unstable_now()-$<pe)}function re(){if(Z!==null){var z=e.unstable_now();$=z;var ee=!0;try{ee=Z(!0,z)}finally{ee?de():(M=!1,Z=null)}}else M=!1}var de;if(typeof k=="function")de=function(){k(re)};else if(typeof MessageChannel!="undefined"){var ae=new MessageChannel,ye=ae.port2;ae.port1.onmessage=re,de=function(){ye.postMessage(null)}}else de=function(){C(re,0)};function ve(z){Z=z,M||(M=!0,de())}function se(z,ee){ue=C(function(){z(e.unstable_now())},ee)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(z){z.callback=null},e.unstable_continueExecution=function(){_||y||(_=!0,ve(G))},e.unstable_forceFrameRate=function(z){0>z||125<z?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):pe=0<z?Math.floor(1e3/z):5},e.unstable_getCurrentPriorityLevel=function(){return b},e.unstable_getFirstCallbackNode=function(){return n(d)},e.unstable_next=function(z){switch(b){case 1:case 2:case 3:var ee=3;break;default:ee=b}var w=b;b=ee;try{return z()}finally{b=w}},e.unstable_pauseExecution=function(){},e.unstable_requestPaint=function(){},e.unstable_runWithPriority=function(z,ee){switch(z){case 1:case 2:case 3:case 4:case 5:break;default:z=3}var w=b;b=z;try{return ee()}finally{b=w}},e.unstable_scheduleCallback=function(z,ee,w){var N=e.unstable_now();switch(typeof w=="object"&&w!==null?(w=w.delay,w=typeof w=="number"&&0<w?N+w:N):w=N,z){case 1:var V=-1;break;case 2:V=250;break;case 5:V=1073741823;break;case 4:V=1e4;break;default:V=5e3}return V=w+V,z={id:p++,callback:ee,priorityLevel:z,startTime:w,expirationTime:V,sortIndex:-1},w>N?(z.sortIndex=w,t(h,z),n(d)===null&&z===n(h)&&(A?(v(ue),ue=-1):A=!0,se(j,w-N))):(z.sortIndex=V,t(d,z),_||y||(_=!0,ve(G))),z},e.unstable_shouldYield=te,e.unstable_wrapCallback=function(z){var ee=b;return function(){var w=b;b=ee;try{return z.apply(this,arguments)}finally{b=w}}}})(cf)),cf}var Yg;function ck(){return Yg||(Yg=1,lf.exports=lk()),lf.exports}var Wg;function dk(){if(Wg)return pn;Wg=1;var e=Ao(),t=ck();function n(i){for(var s="https://reactjs.org/docs/error-decoder.html?invariant="+i,l=1;l<arguments.length;l++)s+="&args[]="+encodeURIComponent(arguments[l]);return"Minified React error #"+i+"; visit "+s+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}var r=new Set,o={};function a(i,s){u(i,s),u(i+"Capture",s)}function u(i,s){for(o[i]=s,i=0;i<s.length;i++)r.add(s[i])}var c=!(typeof window=="undefined"||typeof window.document=="undefined"||typeof window.document.createElement=="undefined"),d=Object.prototype.hasOwnProperty,h=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,p={},m={};function b(i){return d.call(m,i)?!0:d.call(p,i)?!1:h.test(i)?m[i]=!0:(p[i]=!0,!1)}function y(i,s,l,f){if(l!==null&&l.type===0)return!1;switch(typeof s){case"function":case"symbol":return!0;case"boolean":return f?!1:l!==null?!l.acceptsBooleans:(i=i.toLowerCase().slice(0,5),i!=="data-"&&i!=="aria-");default:return!1}}function _(i,s,l,f){if(s===null||typeof s=="undefined"||y(i,s,l,f))return!0;if(f)return!1;if(l!==null)switch(l.type){case 3:return!s;case 4:return s===!1;case 5:return isNaN(s);case 6:return isNaN(s)||1>s}return!1}function A(i,s,l,f,E,T,S){this.acceptsBooleans=s===2||s===3||s===4,this.attributeName=f,this.attributeNamespace=E,this.mustUseProperty=l,this.propertyName=i,this.type=s,this.sanitizeURL=T,this.removeEmptyString=S}var C={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(i){C[i]=new A(i,0,!1,i,null,!1,!1)}),[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(i){var s=i[0];C[s]=new A(s,1,!1,i[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(i){C[i]=new A(i,2,!1,i.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(i){C[i]=new A(i,2,!1,i,null,!1,!1)}),"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(i){C[i]=new A(i,3,!1,i.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(i){C[i]=new A(i,3,!0,i,null,!1,!1)}),["capture","download"].forEach(function(i){C[i]=new A(i,4,!1,i,null,!1,!1)}),["cols","rows","size","span"].forEach(function(i){C[i]=new A(i,6,!1,i,null,!1,!1)}),["rowSpan","start"].forEach(function(i){C[i]=new A(i,5,!1,i.toLowerCase(),null,!1,!1)});var v=/[\-:]([a-z])/g;function k(i){return i[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(i){var s=i.replace(v,k);C[s]=new A(s,1,!1,i,null,!1,!1)}),"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(i){var s=i.replace(v,k);C[s]=new A(s,1,!1,i,"http://www.w3.org/1999/xlink",!1,!1)}),["xml:base","xml:lang","xml:space"].forEach(function(i){var s=i.replace(v,k);C[s]=new A(s,1,!1,i,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(function(i){C[i]=new A(i,1,!1,i.toLowerCase(),null,!1,!1)}),C.xlinkHref=new A("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach(function(i){C[i]=new A(i,1,!1,i.toLowerCase(),null,!0,!0)});function R(i,s,l,f){var E=C.hasOwnProperty(s)?C[s]:null;(E!==null?E.type!==0:f||!(2<s.length)||s[0]!=="o"&&s[0]!=="O"||s[1]!=="n"&&s[1]!=="N")&&(_(s,l,E,f)&&(l=null),f||E===null?b(s)&&(l===null?i.removeAttribute(s):i.setAttribute(s,""+l)):E.mustUseProperty?i[E.propertyName]=l===null?E.type===3?!1:"":l:(s=E.attributeName,f=E.attributeNamespace,l===null?i.removeAttribute(s):(E=E.type,l=E===3||E===4&&l===!0?"":""+l,f?i.setAttributeNS(f,s,l):i.setAttribute(s,l))))}var j=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,G=Symbol.for("react.element"),M=Symbol.for("react.portal"),Z=Symbol.for("react.fragment"),ue=Symbol.for("react.strict_mode"),pe=Symbol.for("react.profiler"),$=Symbol.for("react.provider"),te=Symbol.for("react.context"),re=Symbol.for("react.forward_ref"),de=Symbol.for("react.suspense"),ae=Symbol.for("react.suspense_list"),ye=Symbol.for("react.memo"),ve=Symbol.for("react.lazy"),se=Symbol.for("react.offscreen"),z=Symbol.iterator;function ee(i){return i===null||typeof i!="object"?null:(i=z&&i[z]||i["@@iterator"],typeof i=="function"?i:null)}var w=Object.assign,N;function V(i){if(N===void 0)try{throw Error()}catch(l){var s=l.stack.trim().match(/\n( *(at )?)/);N=s&&s[1]||""}return`
17
17
  `+N+i}var I=!1;function Te(i,s){if(!i||I)return"";I=!0;var l=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{if(s)if(s=function(){throw Error()},Object.defineProperty(s.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(s,[])}catch(J){var f=J}Reflect.construct(i,[],s)}else{try{s.call()}catch(J){f=J}i.call(s.prototype)}else{try{throw Error()}catch(J){f=J}i()}}catch(J){if(J&&f&&typeof J.stack=="string"){for(var E=J.stack.split(`
18
18
  `),T=f.stack.split(`
19
19
  `),S=E.length-1,D=T.length-1;1<=S&&0<=D&&E[S]!==T[D];)D--;for(;1<=S&&0<=D;S--,D--)if(E[S]!==T[D]){if(S!==1||D!==1)do if(S--,D--,0>D||E[S]!==T[D]){var H=`
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@cimulate/copilot-widget",
3
3
  "description": "A frontend SDK for Cimulate Copilot",
4
- "version": "1.22.0",
4
+ "version": "1.22.1",
5
5
  "keywords": [
6
6
  "cimulate",
7
7
  "copilot",