@cimulate/copilot-widget 1.30.8 → 1.32.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,14 @@
2
2
 
3
3
  `@cimulate/copilot-widget` follows [Semantic Versioning](https://semver.org/). Each entry is a released `package.json` version (deployed on merge to `master`), newest first.
4
4
 
5
+ ## 1.32.0 — 2026-08-28
6
+
7
+ - Added `getAuthLinkKey()` for retrieving a single-use auth link key for the current conversation, so hosts can bridge a guest shopper's session (e.g. a SLAS/commerce session) into the conversation and let the agent inherit the shopper's identity and cart. Exposed both to React hosts via `useMessaging().getAuthLinkKey()` and to script-tag/CDN hosts via `window.CimulateMessaging.getAuthLinkKey()`. The key is single-use: each call mints a fresh key the server invalidates on redemption, so callers must request a new one rather than caching or retrying with a consumed key. The CDN export is async and rejects (rather than throwing synchronously) when called before the widget is ready. Requires `@cimulate/agentforce-sdk` 1.3.0, which adds the underlying auth-link-key v2 retrieval.
8
+
9
+ ## 1.31.0 — 2026-08-27
10
+
11
+ - Messaging mode now defers SCRT2 connection and conversation creation until the shopper opens the widget or sends the first message. Concurrent engagement signals share one initialization, and persisted conversations still resume before a new conversation is created.
12
+
5
13
  ## 1.30.8 — 2026-08-27
6
14
 
7
15
  - In Agentforce messaging mode, an agent reply that double-encodes itself — a valid `{ response: [...] }` message whose markdown block's `content` is another `{ response: [...] }` JSON string — no longer renders as raw JSON in the chat. The nested payload is now unwrapped and its inner blocks (prose, suggestions, products) render normally, so the message reads exactly as the agent intended instead of dumping the serialized envelope.
@@ -7352,8 +7352,8 @@ const gt = new ek(), tk = (e) => {
7352
7352
  e != null ? e : Xe.entryTypeProxy.entryType
7353
7353
  ), [u, c] = B.useState(Xe.modeProxy.mode), [f, d] = B.useState({
7354
7354
  type: n || Xe.statusProxy.type,
7355
- isOpen: Xe.statusProxy.isOpen,
7356
- isMinimized: Xe.statusProxy.isMinimized
7355
+ isOpen: t && "isOpen" in t ? !!t.isOpen : Xe.statusProxy.isOpen,
7356
+ isMinimized: t && "isMinimized" in t ? !!t.isMinimized : Xe.statusProxy.isMinimized
7357
7357
  }), [p, m] = B.useState(Xe.dialogProxy.position), [b, y] = B.useState(Xe.dialogProxy.isFullHeight), [_, C] = B.useState(Xe.dialogProxy.width), [N, A] = B.useState(Xe.modalProxy.isFullscreen), P = CP(f.type);
7358
7358
  B.useEffect(() => {
7359
7359
  const U = (Y) => {
@@ -7,7 +7,7 @@
7
7
  `);return u===-1?"":s.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=ts(this.defaults,n);const{transitional:r,paramsSerializer:s,headers:a}=n;r!==void 0&&ul.assertOptions(r,{silentJSONParsing:pn.transitional(pn.boolean),forcedJSONParsing:pn.transitional(pn.boolean),clarifyTimeoutError:pn.transitional(pn.boolean),legacyInterceptorReqResOrdering:pn.transitional(pn.boolean),advertiseZstdAcceptEncoding:pn.transitional(pn.boolean),validateStatusUndefinedResolves:pn.transitional(pn.boolean)},!1),s!=null&&($.isFunction(s)?n.paramsSerializer={serialize:s}:ul.assertOptions(s,{encode:pn.function,serialize:pn.function},!0)),n.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?n.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:n.allowAbsoluteUrls=!0),ul.assertOptions(n,{baseUrl:pn.spelling("baseURL"),withXsrfToken:pn.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=hn.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 v=n.transitional||lf;v&&v.legacyInterceptorReqResOrdering?c.unshift(A.fulfilled,A.rejected):c.push(A.fulfilled,A.rejected)});const f=[];this.interceptors.response.forEach(function(A){f.push(A.fulfilled,A.rejected)});let p,m=0,b;if(!d){const _=[Og.bind(this),void 0];for(_.unshift(...c),_.push(...f),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(v){A.call(this,v);break}}try{p=Og.call(this,y)}catch(_){return Promise.reject(_)}for(m=0,b=f.length;m<b;)p=p.then(f[m++],f[m++]);return p}getUri(t){t=ts(this.defaults,t);const n=_g(t.baseURL,t.url,t.allowAbsoluteUrls,t);return dg(n,t.params,t.paramsSerializer)}};$.forEach(["delete","get","head","options"],function(t){ns.prototype[t]=function(n,r){return this.request(ts(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(ts(c||{},{method:t,headers:r?{"Content-Type":"multipart/form-data"}:{},url:a,data:u}))}}ns.prototype[t]=n(),t!=="query"&&(ns.prototype[t+"Form"]=n(!0))});let ZC=class I2{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(s=>{if(!r._listeners)return;let a=r._listeners.length;for(;a-- >0;)r._listeners[a](s);r._listeners=null}),this.promise.then=s=>{let a;const u=new Promise(c=>{r.subscribe(c),a=c}).then(s);return u.cancel=function(){r.unsubscribe(a)},u},t(function(a,u,c){r.reason||(r.reason=new da(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 I2(function(s){t=s}),cancel:t}}};function ev(e){return function(n){return e.apply(null,n)}}function tv(e){return $.isObject(e)&&e.isAxiosError===!0}const gf={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(gf).forEach(([e,t])=>{gf[t]=e});function Rg(e){const t=new ns(e),n=W0(ns.prototype.request,t);return $.extend(n,ns.prototype,t,{allOwnKeys:!0}),$.extend(n,t,null,{allOwnKeys:!0}),n.create=function(s){return Rg(ts(e,s))},n}const Ot=Rg(ca);Ot.Axios=ns,Ot.CanceledError=da,Ot.CancelToken=ZC,Ot.isCancel=gg,Ot.VERSION=hf,Ot.toFormData=rl,Ot.AxiosError=be,Ot.Cancel=Ot.CanceledError,Ot.all=function(t){return Promise.all(t)},Ot.spread=ev,Ot.isAxiosError=tv,Ot.mergeConfig=ts,Ot.AxiosHeaders=hn,Ot.formToJSON=e=>mg($.isHTMLForm(e)?new FormData(e):e),Ot.getAdapter=Pg.getAdapter,Ot.HttpStatusCode=gf,Ot.default=Ot;const{Axios:O7,AxiosError:I7,CanceledError:R7,isCancel:L7,CancelToken:D7,VERSION:M7,all:F7,Cancel:B7,isAxiosError:U7,spread:H7,toFormData:z7,AxiosHeaders:j7,HttpStatusCode:$7,formToJSON:V7,getAdapter:q7,mergeConfig:Y7,create:G7}=Ot;class nv{constructor(t,n,r,s=!1,a,u){Se(this,"CIMULATE_API_HEADER","x-cimulate-api-key");Se(this,"CIMULATE_SEARCH_API_HOST","search.cimulate");Se(this,"CIMULATE_SEARCH_API_PATH","api/v1");Se(this,"baseApiUrl");Se(this,"headers",{});Se(this,"fetchConfig",()=>Ke(this,null,function*(){try{const t=yield Ot.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}}));Se(this,"_mapCopilotUrlToSearchUrl",(t="",n=!1)=>{if(t.endsWith("io")){const s=new URL(t);return s.hostname=s.hostname.replace(/^copilot\./,"api."),s.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,s)}get apiUrl(){return`${this.baseApiUrl}/${this.CIMULATE_SEARCH_API_PATH}`}}class rv{constructor(t,n,r,s=!1,a,u){Se(this,"apiService");Se(this,"config",null);Se(this,"getConfig",()=>Ke(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}}));Se(this,"getPid",t=>this.getProductFieldValue(t,"pidCol"));Se(this,"getName",t=>this.getProductFieldValue(t,"nameCol"));Se(this,"getDescription",t=>this.getProductFieldValue(t,"description"));Se(this,"getBrand",t=>this.getProductFieldValue(t,"productBrandCol"));Se(this,"getPrice",t=>this.getProductFieldValue(t,"priceCol"));Se(this,"getRelativePdp",t=>this.getProductFieldValue(t,"relativePdpCol"));Se(this,"getPdp",t=>this.getProductFieldValue(t,"pdpCol"));Se(this,"getImage",t=>this.getProductFieldValue(t,"imageCol"));Se(this,"getProductHiddenFields",()=>{const t=this.getProductField("productHiddenFields");return Array.isArray(t)?t:[]});Se(this,"getProductField",t=>this.config?this.config[t]:"");Se(this,"getProductFieldValue",(t,n)=>{const r=this.getProductField(n);return r&&t[r]||""});this.apiService=new nv(t,n,r,s,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 Ys=(e,t,n,...r)=>{if(!e)return;const s=["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]",s,n,...r)};class iv{constructor(t=!1){Se(this,"isDevelopment");Se(this,"_log",(t,n,...r)=>{Ys(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 sv={copilot:"Your Search Assistant",messaging:"Commerce Client"},Lg=B.createContext(null),ov=({mode:e,logoUrl:t,headerText:n,headerConfig:r,globalClassName:s="",entryMessage:a,openLinksInNewTab:u=!1,disclaimerText:c,disclaimerMarkdown:d,clientContext:f,baseCatalogParams:p,searchPlaceholder:m,searchButtonLabel:b,searchConfig:y,suggestionButtonConfig:_,progressStepsLimit:A=3,messageAlignment:v="start",autoScroll:w=!0,showProductDescription:N=!1,componentConfig:C,conversationHistory:U,resetConversationMessage:Y="",apiKey:R,apiToken:q,baseUrl:ne,customerId:me,tenantId:V,theme:se,isDevelopment:he,__features:ve,routingAttributes:re,enableDownloadTranscript:oe=!0,enableEscalationToAgent:xe=!1,showProductCaptions:ae=!1,children:Q})=>{const ie=e==="messaging",k=B.useMemo(()=>{const Le=re==null?void 0:re.isCartMgmtSupported;return Le===!0||Le==="true"},[re]),D=B.useMemo(()=>ie?{config:null}:new rv(ne,R,q,he,me,V),[ie,ne,R,q,he,me,V]),ee=B.useMemo(()=>new iv(he),[he]);B.useEffect(()=>{ie||!D||D.config||D.getConfig()},[D,ie]);const I=B.useMemo(()=>lA(se),[se]),_e=B.useMemo(()=>{const Le=(y==null?void 0:y.placeholder)||m,Ue=(y==null?void 0:y.buttonLabel)||b;let Ye="icon";return y!=null&&y.buttonType?Ye=y.buttonType:b&&(Ye="text"),de(F({},y||{}),{placeholder:Le,buttonLabel:Ue,buttonType:Ye})},[y,m,b]),Be=B.useMemo(()=>de(F({},r||{}),{logoUrl:t||(r==null?void 0:r.logoUrl),headerText:(r==null?void 0:r.headerText)||n||sv[e!=null?e:"copilot"]}),[r,t,n,e]),ye=B.useMemo(()=>({configModule:D,mode:e!=null?e:"copilot",headerConfig:Be,entryMessage:a,globalClassName:s,openLinksInNewTab:u,disclaimerText:c,disclaimerMarkdown:d,clientContext:f,baseCatalogParams:p,themeVariables:I,logger:ee,searchConfig:_e,suggestionButtonConfig:_,progressStepsLimit:A,messageAlignment:v,autoScroll:w,showProductDescription:!!N,enableMinimize:!!(C!=null&&C.enableMinimize),enableDownloadTranscript:oe,enableEscalationToAgent:xe,showProductCaptions:!!ae,resetConversationMessage:Y,conversationHistory:{sinceHours:typeof(U==null?void 0:U.sinceHours)=="number"?U.sinceHours:1,limit:U==null?void 0:U.limit},features:ve,isCartMgmtSupported:k}),[D,e,Be,a,s,f,p,c,d,u,_e,_,v,w,N,C,oe,xe,ae,Y,ee,I,U,ve,k]);return S.jsx(Lg.Provider,{value:ye,children:Q})},tt=()=>{const e=B.useContext(Lg);if(!e)throw new Error("useConfig must be used within a ConfigProvider");return e};class av{constructor(){Se(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}});Se(this,"connectedProxy");Se(this,"modeProxy");Se(this,"entryTypeProxy");Se(this,"statusProxy");Se(this,"dialogProxy");Se(this,"modalProxy",{isFullscreen:!1});Se(this,"_fullGet",(t,n)=>Reflect.get(t,n));Se(this,"_fullSet",(t,n,r)=>{if(!(n in t))throw new Error(`Property ${n} does not exist on UIState`);return cv(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 Je=new av,rs=()=>Je.connected,fa=()=>Je.isOpen,uv=e=>{window.addEventListener(Jd,e)},lv=e=>{window.removeEventListener(Jd,e)},cv=(e,t)=>{const n=new CustomEvent(Jd,{detail:{property:e,value:t}});window.dispatchEvent(n)},dv=e=>{Je.connectedProxy.connected=e},ha=e=>{if(!iA(e)){const t=V0.map(r=>`'${r}'`),n=`${t.slice(0,-1).join(", ")}, or ${t[t.length-1]}`;throw new Error(`Invalid entryType: "${e}". Must be ${n}.`)}Je.entryTypeProxy.entryType=e},ei=e=>{const t=Je.statusProxy.isOpen,n=typeof e=="boolean"?e:!t;Je.statusProxy.isOpen=n,n&&(Je.statusProxy.isMinimized=!1)},ll=e=>{const t=Je.statusProxy.isMinimized,n=typeof e=="boolean"?e:!t;Je.statusProxy.isMinimized=n,n&&(Je.statusProxy.isOpen=!1)},Ef=e=>{Je.modalProxy.isFullscreen=e},cl=e=>{if(!["chat","dialog","modal"].includes(e))throw new Error(`Invalid type: ${e}. Must be 'chat', 'dialog', or 'modal'.`);Je.statusProxy.type=e,e==="dialog"||e==="chat"?Je.modeProxy.mode="embedded":Je.modeProxy.mode="standalone"},yf=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(", ")}.`);Je.dialogProxy.position=e},fv=e=>{const t=Je.dialogProxy.isFullHeight,n=typeof e=="boolean"?e:!t;Je.dialogProxy.isFullHeight=n},hv=({onCopilotEvent:e,children:t,dispatch:n})=>{const{logger:r}=tt(),s=B.useCallback(C=>{n({type:mt.SET_COPILOT,payload:C})},[n]),a=B.useCallback(C=>{dv(C),n({type:mt.SET_CONNECTED,payload:C})},[n]),u=B.useCallback(()=>{n({type:mt.RESET_COPILOT,payload:{}})},[n]),c=B.useCallback(()=>{n({type:mt.RESET_STATE,payload:{}})},[n]),d=B.useCallback(C=>{r==null||r.log(`${C.name} event received`,C),n({type:mt.ADD_MESSAGE,payload:C}),C.bypassHandlers||e==null||e(C)},[e,r,n]),f=B.useCallback(C=>{n({type:mt.ADD_LOADING_MESSAGE,payload:C})},[n]),p=B.useCallback(C=>{n({type:mt.REMOVE_LOADING_MESSAGE,payload:C})},[n]),m=B.useCallback(C=>{d(C),f(C.id)},[d,f]),b=B.useCallback(C=>{n({type:mt.SET_ACTIVE_CONVERSATION_ID,payload:C})},[n]),y=B.useCallback(C=>{n({type:mt.ADD_CONVERSATION_ID,payload:C})},[n]),_=B.useCallback(C=>{n({type:mt.SET_CONVERSATION_IDS,payload:C})},[n]),A=B.useCallback(C=>{n({type:mt.SET_IMAGE_FILE,payload:C})},[n]),v=B.useCallback(C=>{n({type:mt.SET_ASK_CIM_PROMPTS,payload:C})},[n]),w=B.useCallback(C=>{n({type:mt.SET_CONVERSATION_HISTORY_LOADED,payload:C})},[n]),N=B.useMemo(()=>({setCopilot:s,setConnected:a,resetCopilot:u,resetCopilotState:c,addCopilotEvent:d,addLoadingMessage:f,removeLoadingMessage:p,handleCopilotRequestAck:m,setActiveConversationId:b,addConversationId:y,setConversationIds:_,setImageFile:A,setAskCimPrompts:v,setConversationHistoryLoaded:w}),[s,a,u,c,d,f,p,m,b,y,_,A,v,w]);return S.jsx(G0.Provider,{value:N,children:t})};tA();const pv=(e,t)=>{const{type:n,payload:r}=t;if(n===mt.ADD_MESSAGE){const s=r;if(e.messages.push(s),s.eventSourceId){const a=e.groupedMessages.findIndex(u=>u.eventSourceId===s.eventSourceId);if(a!==-1){let u=e.groupedMessages[a].messages;u||(u=[]);const c=u.findIndex(d=>d.id===s.id);if(c!==-1){u[c]=s;return}u.push(s);return}else{e.groupedMessages.push({type:"group",eventSourceId:s.eventSourceId,messages:[s],createdAt:new Date(s.createdAt)});return}}e.groupedMessages.push({type:"individual",message:s,createdAt:new Date(s.createdAt)});return}switch(n){case mt.RESET_STATE:e.messages=Ji.messages,e.groupedMessages=Ji.groupedMessages,e.loadingMessages=Ji.loadingMessages,e.imageFile=Ji.imageFile,e.askCimPrompts=Ji.askCimPrompts,e.conversationHistoryLoaded=Ji.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 s=r;e.conversationIds.includes(s)||e.conversationIds.push(s)}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}},mv=({onCopilotEvent:e,children:t})=>{const[n,r]=j0(pv,Ji);return S.jsx(Y0.Provider,{value:n,children:S.jsx(hv,{onCopilotEvent:e,dispatch:r,children:t})})};function gv(){var e=B.useRef(!0);return e.current?(e.current=!1,!0):e.current}function Ev(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];e&&e.addEventListener&&e.addEventListener.apply(e,t)}function yv(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];e&&e.removeEventListener&&e.removeEventListener.apply(e,t)}var Tf=typeof window!="undefined",pa=function(e){B.useEffect(e,[])},Tv=function(e){var t=B.useRef(e);t.current=e,pa(function(){return function(){return t.current()}})},bv=function(e){var t=B.useRef(0),n=B.useState(e),r=n[0],s=n[1],a=B.useCallback(function(u){cancelAnimationFrame(t.current),t.current=requestAnimationFrame(function(){s(u)})},[]);return Tv(function(){cancelAnimationFrame(t.current)}),[r,a]},_v=function(e,t){return e===t};function Sv(e,t){t===void 0&&(t=_v);var n=B.useRef(),r=B.useRef(e),s=gv();return!s&&!t(r.current,e)&&(n.current=r.current,r.current=e),n.current}var xv=function(e){var t={},n=t.initialWidth,r=n===void 0?1/0:n,s=t.initialHeight,a=s===void 0?1/0:s,u=t.onChange,c=bv({width:Tf?window.innerWidth:r,height:Tf?window.innerHeight:a}),d=c[0],f=c[1];return B.useEffect(function(){if(Tf){var p=function(){var m=window.innerWidth,b=window.innerHeight;f({width:m,height:b}),u&&u(m,b)};return Ev(window,"resize",p),function(){yv(window,"resize",p)}}},[]),d};class wv{constructor(){Se(this,"items",[]);Se(this,"add",t=>{const n=this.first();n&&n.context===t.context&&this.remove(),this.items.push(t)});Se(this,"remove",()=>this.items.shift());Se(this,"first",()=>this.items.length>0?this.items[0]:null);Se(this,"clear",()=>{this.items.length=0});Se(this,"processQueue",t=>{new Array(mn.size).fill(1).forEach(()=>{const r=mn.first();r&&(t(r),mn.remove())})})}get size(){return this.items.length}}const mn=new wv,Dg=e=>{window.addEventListener(Qd,e)},Mg=e=>{window.removeEventListener(Qd,e)},Av=(e,t,n)=>{const r=new CustomEvent(Qd,{detail:{event:e,property:t,value:n}});window.dispatchEvent(r)},Fg=e=>{window.addEventListener(Kd,e)},Bg=e=>{window.removeEventListener(Kd,e)},Cv=(e,t,n)=>{const r=new CustomEvent(Kd,{detail:{event:e,property:t,value:n}});window.dispatchEvent(r)},Ug=e=>{window.addEventListener(Xd,e)},Hg=e=>{window.removeEventListener(Xd,e)},zg=(e,t,n)=>{const r=new CustomEvent(Xd,{detail:{property:e,value:t,event:n}});window.dispatchEvent(r)},vv=e=>{window.addEventListener(ef,e)},kv=e=>{window.removeEventListener(ef,e)},dl=(e,t,n)=>{const r=new CustomEvent(ef,{detail:{property:e,value:t,event:n}});window.dispatchEvent(r)};class Nv{constructor(){Se(this,"initialParams",{categoryId:"",categoryName:"",page:null,pageSize:null,includeFacets:!0,facetFilters:{},rangeFilters:[],catalogSegment:null,pricebooks:null});Se(this,"categoryIdProxy");Se(this,"facetFiltersProxy");Se(this,"rangeFiltersProxy");Se(this,"catalogSegmentProxy");Se(this,"pricebooksProxy");Se(this,"_fullGet",(t,n)=>Reflect.get(t,n));Se(this,"_fullSet",(t,n,r)=>{const s=aA[n];return Cv(s,n,r),Reflect.set(t,n,r)});Se(this,"updateFacetFiltersProxy",t=>new Proxy({facetFilters:t},{get:this._fullGet,set:this._fullSet}));Se(this,"updateRangeFiltersProxy",t=>new Proxy({rangeFilters:t},{get:this._fullGet,set:this._fullSet}));Se(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 ut=new Nv,jg=(e,t)=>{const n=t.updateFacetFiltersProxy(e);t.facetFiltersProxy.facetFilters=n.facetFilters},$g=(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},Vg=(e,t)=>{const n=t.updateRangeFiltersProxy(e);t.rangeFiltersProxy.rangeFilters=n.rangeFilters},qg=({field:e,value:t},n)=>{const[r,s]=Array.isArray(t)?t:[];if(typeof r=="undefined"||typeof s=="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:s},n.rangeFiltersProxy.rangeFilters=a;return}a.push({field:e,min:r,max:s});const c=n.updateRangeFiltersProxy(a);n.rangeFiltersProxy.rangeFilters=c.rangeFilters},Yg=(e,t)=>{t.catalogSegmentProxy.catalogSegment=e},Gg=(e,t)=>{const n=t.updatePricebooksProxy(e);t.pricebooksProxy.pricebooks=n.pricebooks},Pv=e=>{if(!rs()||!fa()){rs()&&mn.clear(),mn.add({context:"browse",payload:de(F({},ut.state),{categoryId:e})});return}ut.categoryIdProxy.categoryId=e},Wg=e=>{jg(e,ut)},Ov=(e,t)=>{$g(e,t,ut)},Xg=e=>{Vg(e,ut)},Iv=({field:e,value:t})=>{qg({field:e,value:t},ut)},Rv=e=>{Yg(e,ut)},Kg=e=>{Gg(e,ut)},Qg=e=>{if(!e||!("categoryId"in e))throw new Error("Browse context must include a categoryId");const t=rs(),n=fa();if(!t||!n){t&&mn.clear(),mn.add({context:"browse",payload:F({},e)});return}"facetFilters"in e&&Wg(e.facetFilters||{}),"rangeFilters"in e&&Xg(e.rangeFilters||[]),"catalogSegment"in e&&(ut.catalogSegmentProxy.catalogSegment=e.catalogSegment||null),"pricebooks"in e&&Kg(e.pricebooks||[]),"categoryName"in e&&(ut.categoryIdProxy.categoryName=e.categoryName||""),ut.categoryIdProxy.categoryId=e.categoryId},Lv=Object.freeze(Object.defineProperty({__proto__:null,setBrowseContext:Qg,updateBrowseCategoryId:Pv,updateCatalogSegment:Rv,updateFacetFilter:Ov,updateFacetFilters:Wg,updatePricebooks:Kg,updateRangeFilter:Iv,updateRangeFilters:Xg},Symbol.toStringTag,{value:"Module"}));class Dv{constructor(){Se(this,"initialParams",{productId:"",productName:"",pdpLink:""});Se(this,"proxy");Se(this,"_fullGet",(t,n)=>Reflect.get(t,n));Se(this,"_fullSet",(t,n,r)=>(zg(n,r),Reflect.set(t,n,r)));Se(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 hr=new Dv,Jg=e=>{if(!e||!e.productId)throw new Error("PDP context must include a productId");const t=rs(),n=fa();if(!t||!n){t&&mn.clear(),mn.add({context:"pdp",payload:F({},e)});return}hr.updateProxy(e),zg("pdp-context",e)},Mv=e=>{hr.proxy.productId=e,rs()||mn.add({context:"pdp",payload:F({},hr.state)})},Fv=e=>{hr.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"},Zg={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",staticQuestions:[],staticQuestionsStrategy:"append",disableAskElseButton:!1};class Bv{constructor(){Se(this,"initialState",Zg);Se(this,"promptsStateProxy");Se(this,"promptsParamsProxy");Se(this,"_fullGet",(t,n)=>Reflect.get(t,n));Se(this,"_fullSet",(t,n,r)=>{if(!(n in t))throw new Error(`Property ${n} does not exist on PromptsExtensionState`);return ma(n,r),Reflect.set(t,n,r)});Se(this,"_paramsFullGet",(t,n)=>Reflect.get(t,n));Se(this,"_paramsFullSet",(t,n,r)=>Reflect.set(t,n,r));Se(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 Ft=new Bv,Uv=e=>{window.addEventListener(Zd,e)},Hv=e=>{window.removeEventListener(Zd,e)},ma=(e,t)=>{const n=new CustomEvent(Zd,{detail:{property:e,value:t}});window.dispatchEvent(n)},e1=e=>{const t=Ft.isOpen,n=typeof e=="boolean"?e:!t;Ft.promptsStateProxy.isOpen=n},t1=e=>{const t=Ft.isInline,n=typeof e=="boolean"?e:!t;Ft.promptsStateProxy.isInline=n},zv=e=>{Ft.promptsParamsProxy=Ft.updatePromptsParamsProxy(e),ma("params",e),Ft.promptsStateProxy.entryType="ask_cim"},jv=e=>{Ft.promptsParamsProxy=Ft.updatePromptsParamsProxy(e),ma("params",e),Ft.promptsStateProxy.entryType="search"},$v=e=>{Ft.promptsParamsProxy=Ft.updatePromptsParamsProxy(e),ma("params",e),Ft.promptsStateProxy.entryType="browse"},Vv=e=>{Ft.promptsParamsProxy=Ft.updatePromptsParamsProxy(e),ma("params",e),Ft.promptsStateProxy.entryType="pdp"},qv=({elementId:e,entryType:t,params:n,isInline:r})=>{Ft.promptsStateProxy.elementId=e,t&&(Ft.promptsStateProxy.entryType=t),typeof r=="boolean"&&t1(r),n&&Ft.updatePromptsParamsProxy(n),Ft.isOpen||e1(!0)},Yv=Object.freeze(Object.defineProperty({__proto__:null,getConversationMessages:({payload:e,callback:t})=>{dl("getConversationMessages",{payload:e,callback:t},Ti.GET_CONVERSATION_MESSAGES)},getSessionInformation:e=>{dl("getSessionInformation",{callback:e},Ti.GET_SESSION_INFORMATION)},loadConversation:e=>{dl("loadConversation",e,Ti.LOAD_CONVERSATION)},resetConversation:()=>{dl("resetConversation",!0,Ti.RESET_CONVERSATION)}},Symbol.toStringTag,{value:"Module"}));class Gv{constructor(){Se(this,"initialParams",{query:"",page:null,pageSize:null,includeFacets:!0,facetFilters:{},rangeFilters:[],catalogSegment:null,pricebooks:null});Se(this,"queryProxy");Se(this,"facetFiltersProxy");Se(this,"rangeFiltersProxy");Se(this,"catalogSegmentProxy");Se(this,"pricebooksProxy");Se(this,"_fullGet",(t,n)=>Reflect.get(t,n));Se(this,"_fullSet",(t,n,r)=>{const s=uA[n];return Av(s,n,r),Reflect.set(t,n,r)});Se(this,"updateFacetFiltersProxy",t=>new Proxy({facetFilters:t},{get:this._fullGet,set:this._fullSet}));Se(this,"updateRangeFiltersProxy",t=>new Proxy({rangeFilters:t},{get:this._fullGet,set:this._fullSet}));Se(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 yt=new Gv,Wv=e=>{const t=fa(),n=rs();if(!n||!t){n&&mn.clear(),mn.add({context:"search",payload:de(F({},yt.state),{query:e})});return}yt.queryProxy.query=e},n1=e=>{jg(e,yt)},Xv=(e,t)=>{$g(e,t,yt)},r1=e=>{Vg(e,yt)},Kv=({field:e,value:t})=>{qg({field:e,value:t},yt)},Qv=e=>{Yg(e,yt)},i1=e=>{Gg(e,yt)},s1=e=>{if(!e||!e.query)throw new Error("Search context must include a query");const t=fa(),n=rs();if(!n||!t){n&&mn.clear(),mn.add({context:"search",payload:F({},e)});return}"facetFilters"in e&&n1(e.facetFilters||{}),"rangeFilters"in e&&r1(e.rangeFilters||[]),"catalogSegment"in e&&(yt.catalogSegmentProxy.catalogSegment=e.catalogSegment||null),"pricebooks"in e&&i1(e.pricebooks||[]),yt.queryProxy.query=e.query},Jv=Object.freeze(Object.defineProperty({__proto__:null,setSearchContext:s1,updateCatalogSegment:Qv,updateFacetFilter:Xv,updateFacetFilters:n1,updatePricebooks:i1,updateRangeFilter:Kv,updateRangeFilters:r1,updateSearchQuery:Wv},Symbol.toStringTag,{value:"Module"})),Zv={categoryId:ut.categoryId,categoryName:ut.categoryIdProxy.categoryName||"",facetFilters:ut.facetFilters,rangeFilters:ut.rangeFilters,catalogSegment:ut.catalogSegment,pricebooks:ut.pricebooks},o1=B.createContext(Zv),ek=({children:e})=>{const[t,n]=B.useState(ut.categoryId),[r,s]=B.useState(ut.categoryIdProxy.categoryName||""),[a,u]=B.useState(ut.facetFilters||{}),[c,d]=B.useState(ut.rangeFilters||[]),[f,p]=B.useState(ut.catalogSegment||null),[m,b]=B.useState(ut.pricebooks||null);B.useEffect(()=>{const _=({detail:A})=>{(A==null?void 0:A.property)==="categoryId"&&n(A.value),(A==null?void 0:A.property)==="categoryName"&&s(A.value),(A==null?void 0:A.property)==="facetFilters"&&u(A.value),(A==null?void 0:A.property)==="rangeFilters"&&d(A.value),(A==null?void 0:A.property)==="catalogSegment"&&p(A.value),(A==null?void 0:A.property)==="pricebooks"&&b(A.value)};return Fg(_),()=>{Bg(_)}},[]);const y=B.useMemo(()=>({categoryId:t,categoryName:r,facetFilters:a,rangeFilters:c,catalogSegment:f,pricebooks:m}),[t,r,a,c,f,m]);return S.jsx(o1.Provider,{value:y,children:e})},tk=()=>{const e=B.useContext(o1);if(!e)throw new Error("useBrowse must be used within a BrowseProvider");return e},nk={searchQuery:yt.query,facetFilters:yt.facetFilters,rangeFilters:yt.rangeFilters,catalogSegment:yt.catalogSegment,pricebooks:yt.pricebooks},a1=B.createContext(nk),rk=({children:e})=>{const[t,n]=B.useState(yt.query),[r,s]=B.useState(yt.facetFilters),[a,u]=B.useState(yt.rangeFilters),[c,d]=B.useState(yt.catalogSegment),[f,p]=B.useState(yt.pricebooks);B.useEffect(()=>{const b=({detail:y})=>{(y==null?void 0:y.property)==="query"&&n(y.value),(y==null?void 0:y.property)==="facetFilters"&&s(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 Dg(b),()=>{Mg(b)}},[]);const m=B.useMemo(()=>({searchQuery:t,facetFilters:r,rangeFilters:a,catalogSegment:c,pricebooks:f}),[t,r,a,c,f]);return S.jsx(a1.Provider,{value:m,children:e})},ik=()=>{const e=B.useContext(a1);if(!e)throw new Error("useSearch must be used within a SearchProvider");return e},sk={productId:hr.productId,pdpLink:hr.pdpLink},u1=B.createContext(sk),ok=({children:e})=>{const[t,n]=B.useState(hr.productId),[r,s]=B.useState(hr.pdpLink);B.useEffect(()=>{const u=({detail:c})=>{if((c==null?void 0:c.property)==="pdp-context"){const d=c.value;n(d.productId),s(d.pdpLink);return}(c==null?void 0:c.property)==="productId"&&n(c.value),(c==null?void 0:c.property)==="pdpLink"&&s(c.value)};return Ug(u),()=>{Hg(u)}},[]);const a=B.useMemo(()=>({productId:t,pdpLink:r}),[t,r]);return S.jsx(u1.Provider,{value:a,children:e})},ak=()=>{const e=B.useContext(u1);if(!e)throw new Error("usePdp must be used within a PdpProvider");return e},l1=B.createContext({mode:Je.modeProxy.mode,entryType:Je.entryType,status:Je.statusProxy,dialogPosition:Je.dialogProxy.position,isDialogFullHeight:Je.dialogProxy.isFullHeight,dialogWidth:Je.dialogProxy.width,isModalFullscreen:Je.modalProxy.isFullscreen,previousComponentType:Je.statusProxy.type}),uk=({entryType:e,componentConfig:t,componentType:n,children:r})=>{const[s,a]=B.useState(e!=null?e:Je.entryTypeProxy.entryType),[u,c]=B.useState(Je.modeProxy.mode),[d,f]=B.useState({type:n||Je.statusProxy.type,isOpen:Je.statusProxy.isOpen,isMinimized:Je.statusProxy.isMinimized}),[p,m]=B.useState(Je.dialogProxy.position),[b,y]=B.useState(Je.dialogProxy.isFullHeight),[_,A]=B.useState(Je.dialogProxy.width),[v,w]=B.useState(Je.modalProxy.isFullscreen),N=Sv(d.type);B.useEffect(()=>{const U=Y=>{const{property:R,value:q}=Y.detail||{};if(!(!R||q===void 0)){if(R==="mode"){c(q);return}if(R==="entryType"){a(q);return}if(R==="isMinimized"){f(ne=>de(F({},ne),{isMinimized:q}));return}if(R==="isOpen"){f(ne=>de(F({},ne),{isOpen:q}));return}if(R==="type"){f(ne=>de(F({},ne),{type:q}));return}if(R==="position"){m(q);return}if(R==="isFullHeight"){y(q);return}if(R==="width"){A(q);return}if(R==="isFullscreen"){w(q);return}}};return uv(U),()=>{lv(U)}},[]),pa(()=>{e&&ha(e)}),pa(()=>{const U=n||(t==null?void 0:t.type);U&&cl(U),t&&"isOpen"in t&&ei(!!t.isOpen),t&&"isMinimized"in t&&ll(!!t.isMinimized)}),pa(()=>{if(!(t!=null&&t.options))return;const{dialogPosition:U}=t.options;U&&yf(U),"dialogFullHeight"in t.options&&fv(!!t.options.dialogFullHeight),"dialogWidth"in t.options&&t.options.dialogWidth&&A(t.options.dialogWidth),"isModalFullscreen"in t.options&&Ef(!!t.options.isModalFullscreen)});const C=B.useMemo(()=>({mode:u,entryType:s,status:d,previousComponentType:N||"dialog",dialogPosition:p,isDialogFullHeight:b,dialogWidth:_,isModalFullscreen:v}),[u,s,d,N,p,b,_,v]);return S.jsx(l1.Provider,{value:C,children:r})},Zn=()=>{const e=B.useContext(l1);if(!e)throw new Error("useUIState must be used within a UIStateProvider");return e},c1=B.createContext(null),d1=B.createContext(null),bf=()=>{const e=B.useContext(d1);if(!e)throw new Error("usePromptsExtensionDispatch must be used within a PromptsExtensionProvider");return e||{}},ti=()=>{const e=B.useContext(c1);if(!e)throw new Error("usePromptsExtensionState must be used within a PromptsExtensionProvider");return e||{}},Gs=()=>{const e=B.useContext(G0);if(!e)throw new Error("useCopilotDispatch must be used within a CopilotProvider");return e},er=()=>{const e=B.useContext(Y0);if(!e)throw new Error("useCopilotState must be used within a CopilotProvider");return e},lk=({copilot:e})=>{const{logger:t,conversationHistory:n}=tt(),{isInline:r}=ti(),{addCopilotEvent:s,setConversationHistoryLoaded:a}=Gs(),{activeConversationId:u}=er(),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,b=>{const y=[];[...b.reverse()||[]].forEach(A=>{var w;const v=b.find(N=>N.id===A.eventSourceId);(w=v==null?void 0:v.name)!=null&&w.endsWith("_suggestions")||(A.bypassHandlers=!0,y.unshift(A))}),y.forEach(A=>{s(A)}),a(!0)})},[t,r,u,d,s,a,n]),{getSessionInformation:c,getConversationMessages:d}},f1=B.createContext({copilot:null,messages:[],groupedMessages:[],isLoading:!1,isResponseLoading:()=>!1,handleAskCim:()=>{},handleSearch:()=>{},handleBrowse:()=>{},handlePdp:()=>{},handleSuggestion:()=>{},handleUserInput:()=>{},handleCancel:()=>{},resetConversation:()=>{},getSessionInformation:()=>{},getConversationMessages:()=>{}}),ck=({apiKey:e,apiToken:t,baseUrl:n,customerId:r,tenantId:s,isDevelopment:a,onConnect:u,onRefinedSearch:c,onRefinedBrowse:d,children:f})=>{const{logger:p,clientContext:m,baseCatalogParams:b}=tt(),sn=ik(),{searchQuery:y}=sn,_=cn(sn,["searchQuery"]),Mn=tk(),{categoryId:A}=Mn,v=cn(Mn,["categoryId"]),{productId:w,pdpLink:N}=ak(),{setCopilot:C,setConnected:U,resetCopilot:Y,resetCopilotState:R,addCopilotEvent:q,removeLoadingMessage:ne,handleCopilotRequestAck:me,setActiveConversationId:V,setConversationIds:se,setAskCimPrompts:he}=Gs(),{connected:ve,copilot:re,messages:oe,groupedMessages:xe,loadingMessages:ae,askCimPrompts:Q}=er(),{status:ie,entryType:k}=Zn(),{isInline:D}=ti(),{getConversationMessages:ee,getSessionInformation:I}=lk({copilot:re}),_e=B.useMemo(()=>ae.size>0,[ae]),Be=B.useCallback(we=>ae.has(we),[ae]),ye=B.useCallback(({query:we,facetFilters:Pe,rangeFilters:Me,catalogSegment:rt,pricebooks:ht,userPrompt:J,imageFile:ge})=>{if(!re){p==null||p.error("Copilot is not initialized");return}if(!we)return;const Ce={searchParams:{query:we}};J&&(Ce.userPrompt=J),ge&&(Ce.attachments={image:ge}),Pe&&Object.keys(Pe).length>0&&(Ce.searchParams.facetFilters=Pe),Me&&Me.length>0&&(Ce.searchParams.rangeFilters=Me),rt&&(Ce.searchParams.catalogSegment=rt),ht&&(Ce.searchParams.pricebooks=ht),m&&(Ce.clientContext=m),ha("search"),re.search(Ce,Ve=>{const Ie=F({},Ve);me(Ie)})},[p,me,re,m]),Le=B.useCallback(({categoryId:we,categoryName:Pe,facetFilters:Me,rangeFilters:rt,catalogSegment:ht,pricebooks:J,userPrompt:ge,imageFile:Ce})=>{if(!re){p==null||p.error("Copilot is not initialized");return}const Ve=Me&&Object.keys(Me).length>0;if(we===""&&!Ve){p==null||p.error("Browse event must include facetFilters when categoryId is empty");return}const Ie={browseParams:{categoryId:we||""}};ge&&(Ie.userPrompt=ge),Ce&&(Ie.attachments={image:Ce}),Ve&&(Ie.browseParams.facetFilters=Me),rt&&rt.length>0&&(Ie.browseParams.rangeFilters=rt),ht&&(Ie.browseParams.catalogSegment=ht),Array.isArray(J)&&J.length>0&&(Ie.browseParams.pricebooks=J),(m||Pe)&&(Ie.clientContext={},m&&(Ie.clientContext=F({},m)),Pe&&(Ie.clientContext.cimLabel=Pe)),ha("browse"),re.browse(Ie,lt=>{var $r;const $t=F({},lt),Ut=(($r=$t.request)==null?void 0:$r.clientContext)||{},on=(Ut==null?void 0:Ut.cimLabel)||Pe;on&&$t.request&&($t.request.label=on),me($t)})},[p,me,re,m]),Ue=B.useCallback(({productId:we,productName:Pe,pdpLink:Me,userPrompt:rt,imageFile:ht})=>{if(!re){p==null||p.error("Copilot is not initialized");return}if(!we)return;const J={productId:we};rt&&(J.userPrompt=rt),Me&&(J.pdpLink=Me),ht&&(J.attachments={image:ht}),(m||Pe)&&(J.clientContext={},m&&(J.clientContext=F({},m)),Pe&&(J.clientContext.cimLabel=Pe)),b&&(J.baseCatalogParams=b),ha("pdp"),re.productView(J,ge=>{var lt;const Ce=F({},ge),Ve=((lt=Ce.request)==null?void 0:lt.clientContext)||{},Ie=(Ve==null?void 0:Ve.cimLabel)||Pe;Ie&&Ce.request&&(Ce.request.label=Ie),me(Ce)})},[p,re,me,m,b]),Ye=B.useCallback(({userPrompt:we,imageFile:Pe})=>{if(!re){p==null||p.error("Copilot is not initialized");return}if(!we)return;const Me={userPrompt:we};Pe&&(Me.attachments={image:Pe}),m&&(Me.clientContext=m),b&&(Me.baseCatalogParams=b),re.askCim(Me,rt=>{const ht=F({},rt);me(ht)})},[p,re,me,m,b]),Tt=B.useCallback(we=>{q(we),c==null||c(we)},[q,c]),Cn=B.useCallback(we=>{q(we),d==null||d(we)},[q,d]),rn=B.useCallback(we=>{u==null||u(we),U(!0)},[u,U]);B.useEffect(()=>{!re||!ve||!ie.isOpen||mn.size>0&&mn.processQueue(we=>{if(we.context==="search"){const Pe=F({},we.payload);s1(Pe)}if(we.context==="browse"){const Pe=F({},we.payload);Qg(Pe)}if(we.context==="pdp"){const Pe=F({},we.payload);Jg(Pe)}})},[ie.isOpen,re,ve]);const Tr=B.useCallback(we=>{const Pe=Me=>{const rt=de(F({},Me),{id:Me.inquiryLinkId||Me.id});q(rt)};we.on("connect_ack",rn),we.on("partial_inquiry",Pe),we.on("display_products",q),we.on("progress",q),we.on("refined_search",Tt),we.on("refined_browse",Cn),we.on("done",Me=>{ne(Me.eventSourceId)}),we.on("error",Me=>{q(Me),ne(Me.eventSourceId)}),we.onDisconnect(Me=>{const rt=["io server disconnect","transport error","server shutting down"];if(p==null||p.log("Connection disconnected with reason: ",Me),!rt.includes(Me)){U(!1);return}p==null||p.log("De-registering event listeners");const ht=new Date().toISOString();q({name:"error",message:"Connection was lost. Please try again.",createdAt:ht,id:`error-${ht}`,sessionId:"session"}),we.off()})},[p,U,ne,Tt,Cn,q,rn]);B.useEffect(()=>{if(!re)return;const we=Pe=>{if(!D){if(!Pe.message&&Pe.eventSourceId&&Pe.eventSourceId===Q.requestId){he({requestId:Pe.eventSourceId,message:Pe});return}q(Pe)}};return re.on("follow_up",we),()=>{re.off("follow_up",we)}},[re,oe,Q.requestId,D,q,he]),B.useEffect(()=>{if(!re)return;const we=Pe=>{if(D)return;const Me=de(F({},Pe),{id:Pe.inquiryLinkId||Pe.id});q(Me)};return re.on("inquiry",we),()=>{re.off("inquiry",we)}},[re,D,q]),pa(()=>{let we;n?we=n:we=a?"https://staging.copilot.search.cimulate.ai":"https://prod.copilot.search.cimulate.ai";const Pe={baseUrl:we};e?Pe.apiKey=e:t&&(Pe.apiToken=t),r&&(Pe.customerId=r),s&&(Pe.tenantId=s);const Me=new qw(Pe);return C(Me),Tr(Me),Me.connect(),Me.requestSessionInformation(rt=>{p==null||p.log("Session Information: ",rt);const{activeConversationId:ht,conversationIds:J}=rt.data||{};ht&&V(ht),J!=null&&J.length&&se(J)}),()=>{Me.disconnect(),Me.off(),Y()}});const ir=B.useCallback(we=>{if(!re)return;const Pe={eventId:we,reason:"User cancelled the request"};re.cancelRequest(Pe,Me=>{q(Me),ne(we)})},[q,ne,re]),Qt=B.useCallback(()=>{re&&re.conversationReset({},we=>{R(),q(we),re.requestSessionInformation(Pe=>{p==null||p.log("Session Information: ",Pe);const{activeConversationId:Me,conversationIds:rt}=Pe.data||{};Me&&V(Me),rt!=null&&rt.length&&se(rt)})})},[re,p,q,R,V,se]),$e=B.useCallback((we,Pe)=>{if(!we)return;const Me={userPrompt:we};switch(Pe&&(Me.imageFile=Pe),k){case"ask_cim":Ye(Me);return;case"search":y?ye(F(F({query:y},_),Me)):Ye(Me);return;case"browse":Le(F(F({categoryId:A},v),Me));return;case"pdp":w?Ue(F({productId:w,pdpLink:N||""},Me)):Ye(Me);return}},[k,y,_,ye,Ye,A,v,Le,Ue,w,N]),vt=B.useCallback((we,Pe)=>{var ge,Ce,Ve;const rt=we.params.userPrompt||"";if(!rt)return;const ht=oe.find(Ie=>Ie.id===Pe);if(!ht)return;const J=ht.name.replace("_suggestions","");if(J==="ask_cim"){Ye({userPrompt:rt});return}if(J==="copilot_search"){const Ie=((ge=ht.request)==null?void 0:ge.searchParams)||{},$t=Ie.query===y;ye(de(F({query:Ie.query||y},$t?_:{}),{userPrompt:rt}));return}if(J==="copilot_browse"){const Ie=ht.request,lt=Ie.browseParams||{},Ut=lt.categoryId===A,on=((Ce=Ie.clientContext)==null?void 0:Ce.cimLabel)||"";Le(de(F({categoryId:lt.categoryId||A||""},Ut?v:{}),{categoryName:on,userPrompt:rt}));return}if(J==="product_view"){const Ie=ht.request||{},lt=Ie.productId,$t=lt===w,Ut=((Ve=Ie.clientContext)==null?void 0:Ve.cimLabel)||"";let on="";$t?on=N||"":on=Ie.pdpLink||"",Ue({productId:lt||w,pdpLink:on,productName:Ut,userPrompt:rt})}},[oe,y,_,ye,Ye,A,v,Le,Ue,w,N]),vn=B.useMemo(()=>({copilot:re,messages:oe,groupedMessages:xe,isLoading:_e,isResponseLoading:Be,handleAskCim:Ye,handleSearch:ye,handleBrowse:Le,handlePdp:Ue,handleUserInput:$e,handleSuggestion:vt,handleCancel:ir,resetConversation:Qt,getSessionInformation:I,getConversationMessages:ee}),[re,oe,xe,_e,Be,Ye,ye,Le,Ue,$e,vt,ir,Qt,I,ee]);return S.jsx(f1.Provider,{value:vn,children:f})},h1=()=>{const{copilot:e}=er(),{addCopilotEvent:t}=Gs();return{getCopilotSuggestions:B.useCallback((r,s,a)=>{if(!e||!s||!r)return;const u=c=>{t(c),a(c)};switch(s){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])}},Or=()=>{const e=B.useContext(f1);if(!e)throw new Error("useCopilot must be used within a CopilotProvider");return e},dk=()=>{const{copilot:e,activeConversationId:t,askCimPrompts:n,conversationHistoryLoaded:r}=er(),{entryType:s}=Zn(),{resetCopilotState:a,addCopilotEvent:u,setAskCimPrompts:c}=Gs(),{handleSearch:d,handleBrowse:f,handlePdp:p,resetConversation:m,getSessionInformation:b,getConversationMessages:y}=Or(),{getCopilotSuggestions:_}=h1();B.useEffect(()=>{!e||!s||!t||!r||n.requestId||s==="ask_cim"&&_({},s,N=>{c({requestId:N.id,message:null})})},[e,t,n.requestId,s,r,_,c]);const A=B.useCallback(({query:N})=>{if(!e||!N)return;const{facetFilters:C}=yt.facetFiltersProxy,{rangeFilters:U}=yt.rangeFiltersProxy,{catalogSegment:Y}=yt.catalogSegmentProxy,{pricebooks:R}=yt.pricebooksProxy,q={query:N};q.facetFilters=C||{},q.rangeFilters=U||[],q.catalogSegment=Y||"",q.pricebooks=R||[],d(F({},q))},[e,d]),v=B.useCallback(({categoryId:N})=>{if(!e)return;const C=ut.categoryIdProxy.categoryName,{facetFilters:U}=ut.facetFiltersProxy,{rangeFilters:Y}=ut.rangeFiltersProxy,{catalogSegment:R}=ut.catalogSegmentProxy,{pricebooks:q}=ut.pricebooksProxy,ne={categoryId:N};ne.categoryName=C||"",ne.facetFilters=U||{},ne.rangeFilters=Y||[],ne.catalogSegment=R||"",ne.pricebooks=q||[],f(F({},ne))},[e,f]),w=B.useCallback(({productId:N})=>{if(!e||!N)return;const C={productId:N,pdpLink:hr.pdpLink,productName:hr.proxy.productName||""};p(C)},[e,p]);return B.useEffect(()=>{const N=({detail:C})=>{(C==null?void 0:C.property)==="query"&&A({query:C.value})};return Dg(N),()=>{Mg(N)}},[A]),B.useEffect(()=>{const N=({detail:C})=>{if((C==null?void 0:C.property)==="pdp-context"){const U=C.value;w({productId:U.productId});return}(C==null?void 0:C.property)==="productId"&&w({productId:C.value})};return Ug(N),()=>{Hg(N)}},[w]),B.useEffect(()=>{const N=({detail:C})=>{(C==null?void 0:C.property)==="categoryId"&&v({categoryId:C.value})};return Fg(N),()=>{Bg(N)}},[v]),B.useEffect(()=>{const N=({detail:C})=>{if((C==null?void 0:C.event)==Ti.RESET_CONVERSATION&&m(),(C==null?void 0:C.event)==Ti.GET_SESSION_INFORMATION){const U=C.value.callback;b(U)}if((C==null?void 0:C.event)==Ti.GET_CONVERSATION_MESSAGES){const{payload:U,callback:Y}=C.value;if(!U.conversationId||typeof Y!="function")return;y(U,Y)}if((C==null?void 0:C.event)==Ti.LOAD_CONVERSATION){const U=C.value;if(!U.conversationId)return;y(U,R=>{a(),R.forEach(q=>{u(q)})})}};return vv(N),()=>{kv(N)}},[m,b,y,a,u]),null},fk=({apiKey:e,apiToken:t,baseUrl:n,customerId:r,tenantId:s,isDevelopment:a,onConnect:u,onRefinedSearch:c,onRefinedBrowse:d,children:f})=>S.jsxs(ck,{apiKey:e,apiToken:t,baseUrl:n,customerId:r,tenantId:s,isDevelopment:a,onConnect:u,onRefinedSearch:c,onRefinedBrowse:d,children:[S.jsx(dk,{}),f]}),hk=e=>Array.from(new Set((e!=null?e:[]).map(t=>t.trim()).filter(Boolean))),pk=({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]),s=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]),b=B.useCallback(_=>{t({type:gt.SET_PROMPTS_EXTENSION_RESPONSE_LOADING,payload:_})},[t]),y=B.useMemo(()=>({setIsInitialized:n,setIsOpen:r,setIsInline:s,setElementId:a,setEntryType:u,setActivePromptsId:c,setUserPrompt:d,setParams:f,setPromptsMessage:p,setResponseMessage:m,setIsResponseLoading:b}),[n,r,s,a,u,c,d,f,p,m,b]);return S.jsx(d1.Provider,{value:y,children:e})},mk=(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}},gk=({promptsConfig:e,children:t})=>{const[n,r]=j0(mk,de(F(F({},Zg),e||{}),{staticQuestions:hk((e==null?void 0:e.staticQuestions)||[])}));return S.jsx(c1.Provider,{value:n,children:S.jsx(pk,{dispatch:r,children:t})})},p1=({mode:e,apiKey:t,apiToken:n,baseUrl:r,customerId:s,tenantId:a,logoUrl:u,headerText:c,headerConfig:d,theme:f,openLinksInNewTab:p,globalClassName:m,isDevelopment:b=!1,componentType:y,componentConfig:_,entryType:A,entryMessage:v,disclaimerText:w,disclaimerMarkdown:N,clientContext:C,baseCatalogParams:U,searchPlaceholder:Y,searchButtonLabel:R,searchConfig:q,suggestionButtonConfig:ne,messageAlignment:me,autoScroll:V,promptsConfig:se,resetConversationMessage:he,conversationHistory:ve,onConnect:re,onCopilotEvent:oe,onRefinedSearch:xe,onRefinedBrowse:ae,__features:Q,children:ie})=>S.jsx(ov,{mode:e,baseUrl:r,apiKey:t,apiToken:n,customerId:s,tenantId:a,logoUrl:u,headerText:c,headerConfig:d,entryMessage:v,theme:f,globalClassName:m,openLinksInNewTab:p,searchPlaceholder:Y,searchButtonLabel:R,searchConfig:q,suggestionButtonConfig:ne,messageAlignment:me,autoScroll:V,componentConfig:_,clientContext:C,baseCatalogParams:U,disclaimerMarkdown:N,disclaimerText:w,resetConversationMessage:he,conversationHistory:ve,isDevelopment:b,__features:Q,children:S.jsx(uk,{entryType:A,componentConfig:_,componentType:y,children:S.jsx(mv,{onCopilotEvent:oe,children:S.jsx(ok,{children:S.jsx(ek,{children:S.jsx(rk,{children:S.jsx(gk,{promptsConfig:se,children:S.jsx(fk,{apiKey:t,apiToken:n,baseUrl:r,customerId:s,tenantId:a,isDevelopment:b,entryType:A,onConnect:re,onRefinedSearch:xe,onRefinedBrowse:ae,onCopilotEvent:oe,children:ie})})})})})})})});var _f={exports:{}},On={},Sf={exports:{}},xf={};var m1;function Ek(){return m1||(m1=1,(function(e){function t(Q,ie){var k=Q.length;Q.push(ie);e:for(;0<k;){var D=k-1>>>1,ee=Q[D];if(0<s(ee,ie))Q[D]=ie,Q[k]=ee,k=D;else break e}}function n(Q){return Q.length===0?null:Q[0]}function r(Q){if(Q.length===0)return null;var ie=Q[0],k=Q.pop();if(k!==ie){Q[0]=k;e:for(var D=0,ee=Q.length,I=ee>>>1;D<I;){var _e=2*(D+1)-1,Be=Q[_e],ye=_e+1,Le=Q[ye];if(0>s(Be,k))ye<ee&&0>s(Le,Be)?(Q[D]=Le,Q[ye]=k,D=ye):(Q[D]=Be,Q[_e]=k,D=_e);else if(ye<ee&&0>s(Le,k))Q[D]=Le,Q[ye]=k,D=ye;else break e}}return ie}function s(Q,ie){var k=Q.sortIndex-ie.sortIndex;return k!==0?k:Q.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,b=3,y=!1,_=!1,A=!1,v=typeof setTimeout=="function"?setTimeout:null,w=typeof clearTimeout=="function"?clearTimeout:null,N=typeof setImmediate!="undefined"?setImmediate:null;typeof navigator!="undefined"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function C(Q){for(var ie=n(f);ie!==null;){if(ie.callback===null)r(f);else if(ie.startTime<=Q)r(f),ie.sortIndex=ie.expirationTime,t(d,ie);else break;ie=n(f)}}function U(Q){if(A=!1,C(Q),!_)if(n(d)!==null)_=!0,xe(Y);else{var ie=n(f);ie!==null&&ae(U,ie.startTime-Q)}}function Y(Q,ie){_=!1,A&&(A=!1,w(ne),ne=-1),y=!0;var k=b;try{for(C(ie),m=n(d);m!==null&&(!(m.expirationTime>ie)||Q&&!se());){var D=m.callback;if(typeof D=="function"){m.callback=null,b=m.priorityLevel;var ee=D(m.expirationTime<=ie);ie=e.unstable_now(),typeof ee=="function"?m.callback=ee:m===n(d)&&r(d),C(ie)}else r(d);m=n(d)}if(m!==null)var I=!0;else{var _e=n(f);_e!==null&&ae(U,_e.startTime-ie),I=!1}return I}finally{m=null,b=k,y=!1}}var R=!1,q=null,ne=-1,me=5,V=-1;function se(){return!(e.unstable_now()-V<me)}function he(){if(q!==null){var Q=e.unstable_now();V=Q;var ie=!0;try{ie=q(!0,Q)}finally{ie?ve():(R=!1,q=null)}}else R=!1}var ve;if(typeof N=="function")ve=function(){N(he)};else if(typeof MessageChannel!="undefined"){var re=new MessageChannel,oe=re.port2;re.port1.onmessage=he,ve=function(){oe.postMessage(null)}}else ve=function(){v(he,0)};function xe(Q){q=Q,R||(R=!0,ve())}function ae(Q,ie){ne=v(function(){Q(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(Q){Q.callback=null},e.unstable_continueExecution=function(){_||y||(_=!0,xe(Y))},e.unstable_forceFrameRate=function(Q){0>Q||125<Q?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):me=0<Q?Math.floor(1e3/Q):5},e.unstable_getCurrentPriorityLevel=function(){return b},e.unstable_getFirstCallbackNode=function(){return n(d)},e.unstable_next=function(Q){switch(b){case 1:case 2:case 3:var ie=3;break;default:ie=b}var k=b;b=ie;try{return Q()}finally{b=k}},e.unstable_pauseExecution=function(){},e.unstable_requestPaint=function(){},e.unstable_runWithPriority=function(Q,ie){switch(Q){case 1:case 2:case 3:case 4:case 5:break;default:Q=3}var k=b;b=Q;try{return ie()}finally{b=k}},e.unstable_scheduleCallback=function(Q,ie,k){var D=e.unstable_now();switch(typeof k=="object"&&k!==null?(k=k.delay,k=typeof k=="number"&&0<k?D+k:D):k=D,Q){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,Q={id:p++,callback:ie,priorityLevel:Q,startTime:k,expirationTime:ee,sortIndex:-1},k>D?(Q.sortIndex=k,t(f,Q),n(d)===null&&Q===n(f)&&(A?(w(ne),ne=-1):A=!0,ae(U,k-D))):(Q.sortIndex=ee,t(d,Q),_||y||(_=!0,xe(Y))),Q},e.unstable_shouldYield=se,e.unstable_wrapCallback=function(Q){var ie=b;return function(){var k=b;b=ie;try{return Q.apply(this,arguments)}finally{b=k}}}})(xf)),xf}var g1;function yk(){return g1||(g1=1,Sf.exports=Ek()),Sf.exports}var E1;function Tk(){if(E1)return On;E1=1;var e=fn(),t=yk();function n(i){for(var o="https://reactjs.org/docs/error-decoder.html?invariant="+i,l=1;l<arguments.length;l++)o+="&args[]="+encodeURIComponent(arguments[l]);return"Minified React error #"+i+"; visit "+o+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}var r=new Set,s={};function a(i,o){u(i,o),u(i+"Capture",o)}function u(i,o){for(s[i]=o,i=0;i<o.length;i++)r.add(o[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 b(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,o,l,h){if(l!==null&&l.type===0)return!1;switch(typeof o){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,o,l,h){if(o===null||typeof o=="undefined"||y(i,o,l,h))return!0;if(h)return!1;if(l!==null)switch(l.type){case 3:return!o;case 4:return o===!1;case 5:return isNaN(o);case 6:return isNaN(o)||1>o}return!1}function A(i,o,l,h,E,T,x){this.acceptsBooleans=o===2||o===3||o===4,this.attributeName=h,this.attributeNamespace=E,this.mustUseProperty=l,this.propertyName=i,this.type=o,this.sanitizeURL=T,this.removeEmptyString=x}var v={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(i){v[i]=new A(i,0,!1,i,null,!1,!1)}),[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(i){var o=i[0];v[o]=new A(o,1,!1,i[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(i){v[i]=new A(i,2,!1,i.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(i){v[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){v[i]=new A(i,3,!1,i.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(i){v[i]=new A(i,3,!0,i,null,!1,!1)}),["capture","download"].forEach(function(i){v[i]=new A(i,4,!1,i,null,!1,!1)}),["cols","rows","size","span"].forEach(function(i){v[i]=new A(i,6,!1,i,null,!1,!1)}),["rowSpan","start"].forEach(function(i){v[i]=new A(i,5,!1,i.toLowerCase(),null,!1,!1)});var w=/[\-:]([a-z])/g;function N(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 o=i.replace(w,N);v[o]=new A(o,1,!1,i,null,!1,!1)}),"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(i){var o=i.replace(w,N);v[o]=new A(o,1,!1,i,"http://www.w3.org/1999/xlink",!1,!1)}),["xml:base","xml:lang","xml:space"].forEach(function(i){var o=i.replace(w,N);v[o]=new A(o,1,!1,i,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(function(i){v[i]=new A(i,1,!1,i.toLowerCase(),null,!1,!1)}),v.xlinkHref=new A("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach(function(i){v[i]=new A(i,1,!1,i.toLowerCase(),null,!0,!0)});function C(i,o,l,h){var E=v.hasOwnProperty(o)?v[o]:null;(E!==null?E.type!==0:h||!(2<o.length)||o[0]!=="o"&&o[0]!=="O"||o[1]!=="n"&&o[1]!=="N")&&(_(o,l,E,h)&&(l=null),h||E===null?b(o)&&(l===null?i.removeAttribute(o):i.setAttribute(o,""+l)):E.mustUseProperty?i[E.propertyName]=l===null?E.type===3?!1:"":l:(o=E.attributeName,h=E.attributeNamespace,l===null?i.removeAttribute(o):(E=E.type,l=E===3||E===4&&l===!0?"":""+l,h?i.setAttributeNS(h,o,l):i.setAttribute(o,l))))}var U=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,Y=Symbol.for("react.element"),R=Symbol.for("react.portal"),q=Symbol.for("react.fragment"),ne=Symbol.for("react.strict_mode"),me=Symbol.for("react.profiler"),V=Symbol.for("react.provider"),se=Symbol.for("react.context"),he=Symbol.for("react.forward_ref"),ve=Symbol.for("react.suspense"),re=Symbol.for("react.suspense_list"),oe=Symbol.for("react.memo"),xe=Symbol.for("react.lazy"),ae=Symbol.for("react.offscreen"),Q=Symbol.iterator;function ie(i){return i===null||typeof i!="object"?null:(i=Q&&i[Q]||i["@@iterator"],typeof i=="function"?i:null)}var k=Object.assign,D;function ee(i){if(D===void 0)try{throw Error()}catch(l){var o=l.stack.trim().match(/\n( *(at )?)/);D=o&&o[1]||""}return`
10
+ `+a)}}catch(u){}}throw r}})}_request(t,n){typeof t=="string"?(n=n||{},n.url=t):n=t||{},n=ts(this.defaults,n);const{transitional:r,paramsSerializer:s,headers:a}=n;r!==void 0&&ul.assertOptions(r,{silentJSONParsing:pn.transitional(pn.boolean),forcedJSONParsing:pn.transitional(pn.boolean),clarifyTimeoutError:pn.transitional(pn.boolean),legacyInterceptorReqResOrdering:pn.transitional(pn.boolean),advertiseZstdAcceptEncoding:pn.transitional(pn.boolean),validateStatusUndefinedResolves:pn.transitional(pn.boolean)},!1),s!=null&&($.isFunction(s)?n.paramsSerializer={serialize:s}:ul.assertOptions(s,{encode:pn.function,serialize:pn.function},!0)),n.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?n.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:n.allowAbsoluteUrls=!0),ul.assertOptions(n,{baseUrl:pn.spelling("baseURL"),withXsrfToken:pn.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=hn.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 v=n.transitional||lf;v&&v.legacyInterceptorReqResOrdering?c.unshift(A.fulfilled,A.rejected):c.push(A.fulfilled,A.rejected)});const f=[];this.interceptors.response.forEach(function(A){f.push(A.fulfilled,A.rejected)});let p,m=0,b;if(!d){const _=[Og.bind(this),void 0];for(_.unshift(...c),_.push(...f),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(v){A.call(this,v);break}}try{p=Og.call(this,y)}catch(_){return Promise.reject(_)}for(m=0,b=f.length;m<b;)p=p.then(f[m++],f[m++]);return p}getUri(t){t=ts(this.defaults,t);const n=_g(t.baseURL,t.url,t.allowAbsoluteUrls,t);return dg(n,t.params,t.paramsSerializer)}};$.forEach(["delete","get","head","options"],function(t){ns.prototype[t]=function(n,r){return this.request(ts(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(ts(c||{},{method:t,headers:r?{"Content-Type":"multipart/form-data"}:{},url:a,data:u}))}}ns.prototype[t]=n(),t!=="query"&&(ns.prototype[t+"Form"]=n(!0))});let ZC=class I2{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(s=>{if(!r._listeners)return;let a=r._listeners.length;for(;a-- >0;)r._listeners[a](s);r._listeners=null}),this.promise.then=s=>{let a;const u=new Promise(c=>{r.subscribe(c),a=c}).then(s);return u.cancel=function(){r.unsubscribe(a)},u},t(function(a,u,c){r.reason||(r.reason=new da(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 I2(function(s){t=s}),cancel:t}}};function ev(e){return function(n){return e.apply(null,n)}}function tv(e){return $.isObject(e)&&e.isAxiosError===!0}const gf={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(gf).forEach(([e,t])=>{gf[t]=e});function Rg(e){const t=new ns(e),n=W0(ns.prototype.request,t);return $.extend(n,ns.prototype,t,{allOwnKeys:!0}),$.extend(n,t,null,{allOwnKeys:!0}),n.create=function(s){return Rg(ts(e,s))},n}const Ot=Rg(ca);Ot.Axios=ns,Ot.CanceledError=da,Ot.CancelToken=ZC,Ot.isCancel=gg,Ot.VERSION=hf,Ot.toFormData=rl,Ot.AxiosError=be,Ot.Cancel=Ot.CanceledError,Ot.all=function(t){return Promise.all(t)},Ot.spread=ev,Ot.isAxiosError=tv,Ot.mergeConfig=ts,Ot.AxiosHeaders=hn,Ot.formToJSON=e=>mg($.isHTMLForm(e)?new FormData(e):e),Ot.getAdapter=Pg.getAdapter,Ot.HttpStatusCode=gf,Ot.default=Ot;const{Axios:O7,AxiosError:I7,CanceledError:R7,isCancel:L7,CancelToken:D7,VERSION:M7,all:F7,Cancel:B7,isAxiosError:U7,spread:H7,toFormData:z7,AxiosHeaders:j7,HttpStatusCode:$7,formToJSON:V7,getAdapter:q7,mergeConfig:Y7,create:G7}=Ot;class nv{constructor(t,n,r,s=!1,a,u){Se(this,"CIMULATE_API_HEADER","x-cimulate-api-key");Se(this,"CIMULATE_SEARCH_API_HOST","search.cimulate");Se(this,"CIMULATE_SEARCH_API_PATH","api/v1");Se(this,"baseApiUrl");Se(this,"headers",{});Se(this,"fetchConfig",()=>Ke(this,null,function*(){try{const t=yield Ot.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}}));Se(this,"_mapCopilotUrlToSearchUrl",(t="",n=!1)=>{if(t.endsWith("io")){const s=new URL(t);return s.hostname=s.hostname.replace(/^copilot\./,"api."),s.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,s)}get apiUrl(){return`${this.baseApiUrl}/${this.CIMULATE_SEARCH_API_PATH}`}}class rv{constructor(t,n,r,s=!1,a,u){Se(this,"apiService");Se(this,"config",null);Se(this,"getConfig",()=>Ke(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}}));Se(this,"getPid",t=>this.getProductFieldValue(t,"pidCol"));Se(this,"getName",t=>this.getProductFieldValue(t,"nameCol"));Se(this,"getDescription",t=>this.getProductFieldValue(t,"description"));Se(this,"getBrand",t=>this.getProductFieldValue(t,"productBrandCol"));Se(this,"getPrice",t=>this.getProductFieldValue(t,"priceCol"));Se(this,"getRelativePdp",t=>this.getProductFieldValue(t,"relativePdpCol"));Se(this,"getPdp",t=>this.getProductFieldValue(t,"pdpCol"));Se(this,"getImage",t=>this.getProductFieldValue(t,"imageCol"));Se(this,"getProductHiddenFields",()=>{const t=this.getProductField("productHiddenFields");return Array.isArray(t)?t:[]});Se(this,"getProductField",t=>this.config?this.config[t]:"");Se(this,"getProductFieldValue",(t,n)=>{const r=this.getProductField(n);return r&&t[r]||""});this.apiService=new nv(t,n,r,s,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 Ys=(e,t,n,...r)=>{if(!e)return;const s=["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]",s,n,...r)};class iv{constructor(t=!1){Se(this,"isDevelopment");Se(this,"_log",(t,n,...r)=>{Ys(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 sv={copilot:"Your Search Assistant",messaging:"Commerce Client"},Lg=B.createContext(null),ov=({mode:e,logoUrl:t,headerText:n,headerConfig:r,globalClassName:s="",entryMessage:a,openLinksInNewTab:u=!1,disclaimerText:c,disclaimerMarkdown:d,clientContext:f,baseCatalogParams:p,searchPlaceholder:m,searchButtonLabel:b,searchConfig:y,suggestionButtonConfig:_,progressStepsLimit:A=3,messageAlignment:v="start",autoScroll:w=!0,showProductDescription:N=!1,componentConfig:C,conversationHistory:U,resetConversationMessage:Y="",apiKey:R,apiToken:q,baseUrl:ne,customerId:me,tenantId:V,theme:se,isDevelopment:he,__features:ve,routingAttributes:re,enableDownloadTranscript:oe=!0,enableEscalationToAgent:xe=!1,showProductCaptions:ae=!1,children:Q})=>{const ie=e==="messaging",k=B.useMemo(()=>{const Le=re==null?void 0:re.isCartMgmtSupported;return Le===!0||Le==="true"},[re]),D=B.useMemo(()=>ie?{config:null}:new rv(ne,R,q,he,me,V),[ie,ne,R,q,he,me,V]),ee=B.useMemo(()=>new iv(he),[he]);B.useEffect(()=>{ie||!D||D.config||D.getConfig()},[D,ie]);const I=B.useMemo(()=>lA(se),[se]),_e=B.useMemo(()=>{const Le=(y==null?void 0:y.placeholder)||m,Ue=(y==null?void 0:y.buttonLabel)||b;let Ye="icon";return y!=null&&y.buttonType?Ye=y.buttonType:b&&(Ye="text"),de(F({},y||{}),{placeholder:Le,buttonLabel:Ue,buttonType:Ye})},[y,m,b]),Be=B.useMemo(()=>de(F({},r||{}),{logoUrl:t||(r==null?void 0:r.logoUrl),headerText:(r==null?void 0:r.headerText)||n||sv[e!=null?e:"copilot"]}),[r,t,n,e]),ye=B.useMemo(()=>({configModule:D,mode:e!=null?e:"copilot",headerConfig:Be,entryMessage:a,globalClassName:s,openLinksInNewTab:u,disclaimerText:c,disclaimerMarkdown:d,clientContext:f,baseCatalogParams:p,themeVariables:I,logger:ee,searchConfig:_e,suggestionButtonConfig:_,progressStepsLimit:A,messageAlignment:v,autoScroll:w,showProductDescription:!!N,enableMinimize:!!(C!=null&&C.enableMinimize),enableDownloadTranscript:oe,enableEscalationToAgent:xe,showProductCaptions:!!ae,resetConversationMessage:Y,conversationHistory:{sinceHours:typeof(U==null?void 0:U.sinceHours)=="number"?U.sinceHours:1,limit:U==null?void 0:U.limit},features:ve,isCartMgmtSupported:k}),[D,e,Be,a,s,f,p,c,d,u,_e,_,v,w,N,C,oe,xe,ae,Y,ee,I,U,ve,k]);return S.jsx(Lg.Provider,{value:ye,children:Q})},tt=()=>{const e=B.useContext(Lg);if(!e)throw new Error("useConfig must be used within a ConfigProvider");return e};class av{constructor(){Se(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}});Se(this,"connectedProxy");Se(this,"modeProxy");Se(this,"entryTypeProxy");Se(this,"statusProxy");Se(this,"dialogProxy");Se(this,"modalProxy",{isFullscreen:!1});Se(this,"_fullGet",(t,n)=>Reflect.get(t,n));Se(this,"_fullSet",(t,n,r)=>{if(!(n in t))throw new Error(`Property ${n} does not exist on UIState`);return cv(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 Je=new av,rs=()=>Je.connected,fa=()=>Je.isOpen,uv=e=>{window.addEventListener(Jd,e)},lv=e=>{window.removeEventListener(Jd,e)},cv=(e,t)=>{const n=new CustomEvent(Jd,{detail:{property:e,value:t}});window.dispatchEvent(n)},dv=e=>{Je.connectedProxy.connected=e},ha=e=>{if(!iA(e)){const t=V0.map(r=>`'${r}'`),n=`${t.slice(0,-1).join(", ")}, or ${t[t.length-1]}`;throw new Error(`Invalid entryType: "${e}". Must be ${n}.`)}Je.entryTypeProxy.entryType=e},ei=e=>{const t=Je.statusProxy.isOpen,n=typeof e=="boolean"?e:!t;Je.statusProxy.isOpen=n,n&&(Je.statusProxy.isMinimized=!1)},ll=e=>{const t=Je.statusProxy.isMinimized,n=typeof e=="boolean"?e:!t;Je.statusProxy.isMinimized=n,n&&(Je.statusProxy.isOpen=!1)},Ef=e=>{Je.modalProxy.isFullscreen=e},cl=e=>{if(!["chat","dialog","modal"].includes(e))throw new Error(`Invalid type: ${e}. Must be 'chat', 'dialog', or 'modal'.`);Je.statusProxy.type=e,e==="dialog"||e==="chat"?Je.modeProxy.mode="embedded":Je.modeProxy.mode="standalone"},yf=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(", ")}.`);Je.dialogProxy.position=e},fv=e=>{const t=Je.dialogProxy.isFullHeight,n=typeof e=="boolean"?e:!t;Je.dialogProxy.isFullHeight=n},hv=({onCopilotEvent:e,children:t,dispatch:n})=>{const{logger:r}=tt(),s=B.useCallback(C=>{n({type:mt.SET_COPILOT,payload:C})},[n]),a=B.useCallback(C=>{dv(C),n({type:mt.SET_CONNECTED,payload:C})},[n]),u=B.useCallback(()=>{n({type:mt.RESET_COPILOT,payload:{}})},[n]),c=B.useCallback(()=>{n({type:mt.RESET_STATE,payload:{}})},[n]),d=B.useCallback(C=>{r==null||r.log(`${C.name} event received`,C),n({type:mt.ADD_MESSAGE,payload:C}),C.bypassHandlers||e==null||e(C)},[e,r,n]),f=B.useCallback(C=>{n({type:mt.ADD_LOADING_MESSAGE,payload:C})},[n]),p=B.useCallback(C=>{n({type:mt.REMOVE_LOADING_MESSAGE,payload:C})},[n]),m=B.useCallback(C=>{d(C),f(C.id)},[d,f]),b=B.useCallback(C=>{n({type:mt.SET_ACTIVE_CONVERSATION_ID,payload:C})},[n]),y=B.useCallback(C=>{n({type:mt.ADD_CONVERSATION_ID,payload:C})},[n]),_=B.useCallback(C=>{n({type:mt.SET_CONVERSATION_IDS,payload:C})},[n]),A=B.useCallback(C=>{n({type:mt.SET_IMAGE_FILE,payload:C})},[n]),v=B.useCallback(C=>{n({type:mt.SET_ASK_CIM_PROMPTS,payload:C})},[n]),w=B.useCallback(C=>{n({type:mt.SET_CONVERSATION_HISTORY_LOADED,payload:C})},[n]),N=B.useMemo(()=>({setCopilot:s,setConnected:a,resetCopilot:u,resetCopilotState:c,addCopilotEvent:d,addLoadingMessage:f,removeLoadingMessage:p,handleCopilotRequestAck:m,setActiveConversationId:b,addConversationId:y,setConversationIds:_,setImageFile:A,setAskCimPrompts:v,setConversationHistoryLoaded:w}),[s,a,u,c,d,f,p,m,b,y,_,A,v,w]);return S.jsx(G0.Provider,{value:N,children:t})};tA();const pv=(e,t)=>{const{type:n,payload:r}=t;if(n===mt.ADD_MESSAGE){const s=r;if(e.messages.push(s),s.eventSourceId){const a=e.groupedMessages.findIndex(u=>u.eventSourceId===s.eventSourceId);if(a!==-1){let u=e.groupedMessages[a].messages;u||(u=[]);const c=u.findIndex(d=>d.id===s.id);if(c!==-1){u[c]=s;return}u.push(s);return}else{e.groupedMessages.push({type:"group",eventSourceId:s.eventSourceId,messages:[s],createdAt:new Date(s.createdAt)});return}}e.groupedMessages.push({type:"individual",message:s,createdAt:new Date(s.createdAt)});return}switch(n){case mt.RESET_STATE:e.messages=Ji.messages,e.groupedMessages=Ji.groupedMessages,e.loadingMessages=Ji.loadingMessages,e.imageFile=Ji.imageFile,e.askCimPrompts=Ji.askCimPrompts,e.conversationHistoryLoaded=Ji.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 s=r;e.conversationIds.includes(s)||e.conversationIds.push(s)}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}},mv=({onCopilotEvent:e,children:t})=>{const[n,r]=j0(pv,Ji);return S.jsx(Y0.Provider,{value:n,children:S.jsx(hv,{onCopilotEvent:e,dispatch:r,children:t})})};function gv(){var e=B.useRef(!0);return e.current?(e.current=!1,!0):e.current}function Ev(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];e&&e.addEventListener&&e.addEventListener.apply(e,t)}function yv(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];e&&e.removeEventListener&&e.removeEventListener.apply(e,t)}var Tf=typeof window!="undefined",pa=function(e){B.useEffect(e,[])},Tv=function(e){var t=B.useRef(e);t.current=e,pa(function(){return function(){return t.current()}})},bv=function(e){var t=B.useRef(0),n=B.useState(e),r=n[0],s=n[1],a=B.useCallback(function(u){cancelAnimationFrame(t.current),t.current=requestAnimationFrame(function(){s(u)})},[]);return Tv(function(){cancelAnimationFrame(t.current)}),[r,a]},_v=function(e,t){return e===t};function Sv(e,t){t===void 0&&(t=_v);var n=B.useRef(),r=B.useRef(e),s=gv();return!s&&!t(r.current,e)&&(n.current=r.current,r.current=e),n.current}var xv=function(e){var t={},n=t.initialWidth,r=n===void 0?1/0:n,s=t.initialHeight,a=s===void 0?1/0:s,u=t.onChange,c=bv({width:Tf?window.innerWidth:r,height:Tf?window.innerHeight:a}),d=c[0],f=c[1];return B.useEffect(function(){if(Tf){var p=function(){var m=window.innerWidth,b=window.innerHeight;f({width:m,height:b}),u&&u(m,b)};return Ev(window,"resize",p),function(){yv(window,"resize",p)}}},[]),d};class wv{constructor(){Se(this,"items",[]);Se(this,"add",t=>{const n=this.first();n&&n.context===t.context&&this.remove(),this.items.push(t)});Se(this,"remove",()=>this.items.shift());Se(this,"first",()=>this.items.length>0?this.items[0]:null);Se(this,"clear",()=>{this.items.length=0});Se(this,"processQueue",t=>{new Array(mn.size).fill(1).forEach(()=>{const r=mn.first();r&&(t(r),mn.remove())})})}get size(){return this.items.length}}const mn=new wv,Dg=e=>{window.addEventListener(Qd,e)},Mg=e=>{window.removeEventListener(Qd,e)},Av=(e,t,n)=>{const r=new CustomEvent(Qd,{detail:{event:e,property:t,value:n}});window.dispatchEvent(r)},Fg=e=>{window.addEventListener(Kd,e)},Bg=e=>{window.removeEventListener(Kd,e)},Cv=(e,t,n)=>{const r=new CustomEvent(Kd,{detail:{event:e,property:t,value:n}});window.dispatchEvent(r)},Ug=e=>{window.addEventListener(Xd,e)},Hg=e=>{window.removeEventListener(Xd,e)},zg=(e,t,n)=>{const r=new CustomEvent(Xd,{detail:{property:e,value:t,event:n}});window.dispatchEvent(r)},vv=e=>{window.addEventListener(ef,e)},kv=e=>{window.removeEventListener(ef,e)},dl=(e,t,n)=>{const r=new CustomEvent(ef,{detail:{property:e,value:t,event:n}});window.dispatchEvent(r)};class Nv{constructor(){Se(this,"initialParams",{categoryId:"",categoryName:"",page:null,pageSize:null,includeFacets:!0,facetFilters:{},rangeFilters:[],catalogSegment:null,pricebooks:null});Se(this,"categoryIdProxy");Se(this,"facetFiltersProxy");Se(this,"rangeFiltersProxy");Se(this,"catalogSegmentProxy");Se(this,"pricebooksProxy");Se(this,"_fullGet",(t,n)=>Reflect.get(t,n));Se(this,"_fullSet",(t,n,r)=>{const s=aA[n];return Cv(s,n,r),Reflect.set(t,n,r)});Se(this,"updateFacetFiltersProxy",t=>new Proxy({facetFilters:t},{get:this._fullGet,set:this._fullSet}));Se(this,"updateRangeFiltersProxy",t=>new Proxy({rangeFilters:t},{get:this._fullGet,set:this._fullSet}));Se(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 ut=new Nv,jg=(e,t)=>{const n=t.updateFacetFiltersProxy(e);t.facetFiltersProxy.facetFilters=n.facetFilters},$g=(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},Vg=(e,t)=>{const n=t.updateRangeFiltersProxy(e);t.rangeFiltersProxy.rangeFilters=n.rangeFilters},qg=({field:e,value:t},n)=>{const[r,s]=Array.isArray(t)?t:[];if(typeof r=="undefined"||typeof s=="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:s},n.rangeFiltersProxy.rangeFilters=a;return}a.push({field:e,min:r,max:s});const c=n.updateRangeFiltersProxy(a);n.rangeFiltersProxy.rangeFilters=c.rangeFilters},Yg=(e,t)=>{t.catalogSegmentProxy.catalogSegment=e},Gg=(e,t)=>{const n=t.updatePricebooksProxy(e);t.pricebooksProxy.pricebooks=n.pricebooks},Pv=e=>{if(!rs()||!fa()){rs()&&mn.clear(),mn.add({context:"browse",payload:de(F({},ut.state),{categoryId:e})});return}ut.categoryIdProxy.categoryId=e},Wg=e=>{jg(e,ut)},Ov=(e,t)=>{$g(e,t,ut)},Xg=e=>{Vg(e,ut)},Iv=({field:e,value:t})=>{qg({field:e,value:t},ut)},Rv=e=>{Yg(e,ut)},Kg=e=>{Gg(e,ut)},Qg=e=>{if(!e||!("categoryId"in e))throw new Error("Browse context must include a categoryId");const t=rs(),n=fa();if(!t||!n){t&&mn.clear(),mn.add({context:"browse",payload:F({},e)});return}"facetFilters"in e&&Wg(e.facetFilters||{}),"rangeFilters"in e&&Xg(e.rangeFilters||[]),"catalogSegment"in e&&(ut.catalogSegmentProxy.catalogSegment=e.catalogSegment||null),"pricebooks"in e&&Kg(e.pricebooks||[]),"categoryName"in e&&(ut.categoryIdProxy.categoryName=e.categoryName||""),ut.categoryIdProxy.categoryId=e.categoryId},Lv=Object.freeze(Object.defineProperty({__proto__:null,setBrowseContext:Qg,updateBrowseCategoryId:Pv,updateCatalogSegment:Rv,updateFacetFilter:Ov,updateFacetFilters:Wg,updatePricebooks:Kg,updateRangeFilter:Iv,updateRangeFilters:Xg},Symbol.toStringTag,{value:"Module"}));class Dv{constructor(){Se(this,"initialParams",{productId:"",productName:"",pdpLink:""});Se(this,"proxy");Se(this,"_fullGet",(t,n)=>Reflect.get(t,n));Se(this,"_fullSet",(t,n,r)=>(zg(n,r),Reflect.set(t,n,r)));Se(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 hr=new Dv,Jg=e=>{if(!e||!e.productId)throw new Error("PDP context must include a productId");const t=rs(),n=fa();if(!t||!n){t&&mn.clear(),mn.add({context:"pdp",payload:F({},e)});return}hr.updateProxy(e),zg("pdp-context",e)},Mv=e=>{hr.proxy.productId=e,rs()||mn.add({context:"pdp",payload:F({},hr.state)})},Fv=e=>{hr.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"},Zg={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",staticQuestions:[],staticQuestionsStrategy:"append",disableAskElseButton:!1};class Bv{constructor(){Se(this,"initialState",Zg);Se(this,"promptsStateProxy");Se(this,"promptsParamsProxy");Se(this,"_fullGet",(t,n)=>Reflect.get(t,n));Se(this,"_fullSet",(t,n,r)=>{if(!(n in t))throw new Error(`Property ${n} does not exist on PromptsExtensionState`);return ma(n,r),Reflect.set(t,n,r)});Se(this,"_paramsFullGet",(t,n)=>Reflect.get(t,n));Se(this,"_paramsFullSet",(t,n,r)=>Reflect.set(t,n,r));Se(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 Ft=new Bv,Uv=e=>{window.addEventListener(Zd,e)},Hv=e=>{window.removeEventListener(Zd,e)},ma=(e,t)=>{const n=new CustomEvent(Zd,{detail:{property:e,value:t}});window.dispatchEvent(n)},e1=e=>{const t=Ft.isOpen,n=typeof e=="boolean"?e:!t;Ft.promptsStateProxy.isOpen=n},t1=e=>{const t=Ft.isInline,n=typeof e=="boolean"?e:!t;Ft.promptsStateProxy.isInline=n},zv=e=>{Ft.promptsParamsProxy=Ft.updatePromptsParamsProxy(e),ma("params",e),Ft.promptsStateProxy.entryType="ask_cim"},jv=e=>{Ft.promptsParamsProxy=Ft.updatePromptsParamsProxy(e),ma("params",e),Ft.promptsStateProxy.entryType="search"},$v=e=>{Ft.promptsParamsProxy=Ft.updatePromptsParamsProxy(e),ma("params",e),Ft.promptsStateProxy.entryType="browse"},Vv=e=>{Ft.promptsParamsProxy=Ft.updatePromptsParamsProxy(e),ma("params",e),Ft.promptsStateProxy.entryType="pdp"},qv=({elementId:e,entryType:t,params:n,isInline:r})=>{Ft.promptsStateProxy.elementId=e,t&&(Ft.promptsStateProxy.entryType=t),typeof r=="boolean"&&t1(r),n&&Ft.updatePromptsParamsProxy(n),Ft.isOpen||e1(!0)},Yv=Object.freeze(Object.defineProperty({__proto__:null,getConversationMessages:({payload:e,callback:t})=>{dl("getConversationMessages",{payload:e,callback:t},Ti.GET_CONVERSATION_MESSAGES)},getSessionInformation:e=>{dl("getSessionInformation",{callback:e},Ti.GET_SESSION_INFORMATION)},loadConversation:e=>{dl("loadConversation",e,Ti.LOAD_CONVERSATION)},resetConversation:()=>{dl("resetConversation",!0,Ti.RESET_CONVERSATION)}},Symbol.toStringTag,{value:"Module"}));class Gv{constructor(){Se(this,"initialParams",{query:"",page:null,pageSize:null,includeFacets:!0,facetFilters:{},rangeFilters:[],catalogSegment:null,pricebooks:null});Se(this,"queryProxy");Se(this,"facetFiltersProxy");Se(this,"rangeFiltersProxy");Se(this,"catalogSegmentProxy");Se(this,"pricebooksProxy");Se(this,"_fullGet",(t,n)=>Reflect.get(t,n));Se(this,"_fullSet",(t,n,r)=>{const s=uA[n];return Av(s,n,r),Reflect.set(t,n,r)});Se(this,"updateFacetFiltersProxy",t=>new Proxy({facetFilters:t},{get:this._fullGet,set:this._fullSet}));Se(this,"updateRangeFiltersProxy",t=>new Proxy({rangeFilters:t},{get:this._fullGet,set:this._fullSet}));Se(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 yt=new Gv,Wv=e=>{const t=fa(),n=rs();if(!n||!t){n&&mn.clear(),mn.add({context:"search",payload:de(F({},yt.state),{query:e})});return}yt.queryProxy.query=e},n1=e=>{jg(e,yt)},Xv=(e,t)=>{$g(e,t,yt)},r1=e=>{Vg(e,yt)},Kv=({field:e,value:t})=>{qg({field:e,value:t},yt)},Qv=e=>{Yg(e,yt)},i1=e=>{Gg(e,yt)},s1=e=>{if(!e||!e.query)throw new Error("Search context must include a query");const t=fa(),n=rs();if(!n||!t){n&&mn.clear(),mn.add({context:"search",payload:F({},e)});return}"facetFilters"in e&&n1(e.facetFilters||{}),"rangeFilters"in e&&r1(e.rangeFilters||[]),"catalogSegment"in e&&(yt.catalogSegmentProxy.catalogSegment=e.catalogSegment||null),"pricebooks"in e&&i1(e.pricebooks||[]),yt.queryProxy.query=e.query},Jv=Object.freeze(Object.defineProperty({__proto__:null,setSearchContext:s1,updateCatalogSegment:Qv,updateFacetFilter:Xv,updateFacetFilters:n1,updatePricebooks:i1,updateRangeFilter:Kv,updateRangeFilters:r1,updateSearchQuery:Wv},Symbol.toStringTag,{value:"Module"})),Zv={categoryId:ut.categoryId,categoryName:ut.categoryIdProxy.categoryName||"",facetFilters:ut.facetFilters,rangeFilters:ut.rangeFilters,catalogSegment:ut.catalogSegment,pricebooks:ut.pricebooks},o1=B.createContext(Zv),ek=({children:e})=>{const[t,n]=B.useState(ut.categoryId),[r,s]=B.useState(ut.categoryIdProxy.categoryName||""),[a,u]=B.useState(ut.facetFilters||{}),[c,d]=B.useState(ut.rangeFilters||[]),[f,p]=B.useState(ut.catalogSegment||null),[m,b]=B.useState(ut.pricebooks||null);B.useEffect(()=>{const _=({detail:A})=>{(A==null?void 0:A.property)==="categoryId"&&n(A.value),(A==null?void 0:A.property)==="categoryName"&&s(A.value),(A==null?void 0:A.property)==="facetFilters"&&u(A.value),(A==null?void 0:A.property)==="rangeFilters"&&d(A.value),(A==null?void 0:A.property)==="catalogSegment"&&p(A.value),(A==null?void 0:A.property)==="pricebooks"&&b(A.value)};return Fg(_),()=>{Bg(_)}},[]);const y=B.useMemo(()=>({categoryId:t,categoryName:r,facetFilters:a,rangeFilters:c,catalogSegment:f,pricebooks:m}),[t,r,a,c,f,m]);return S.jsx(o1.Provider,{value:y,children:e})},tk=()=>{const e=B.useContext(o1);if(!e)throw new Error("useBrowse must be used within a BrowseProvider");return e},nk={searchQuery:yt.query,facetFilters:yt.facetFilters,rangeFilters:yt.rangeFilters,catalogSegment:yt.catalogSegment,pricebooks:yt.pricebooks},a1=B.createContext(nk),rk=({children:e})=>{const[t,n]=B.useState(yt.query),[r,s]=B.useState(yt.facetFilters),[a,u]=B.useState(yt.rangeFilters),[c,d]=B.useState(yt.catalogSegment),[f,p]=B.useState(yt.pricebooks);B.useEffect(()=>{const b=({detail:y})=>{(y==null?void 0:y.property)==="query"&&n(y.value),(y==null?void 0:y.property)==="facetFilters"&&s(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 Dg(b),()=>{Mg(b)}},[]);const m=B.useMemo(()=>({searchQuery:t,facetFilters:r,rangeFilters:a,catalogSegment:c,pricebooks:f}),[t,r,a,c,f]);return S.jsx(a1.Provider,{value:m,children:e})},ik=()=>{const e=B.useContext(a1);if(!e)throw new Error("useSearch must be used within a SearchProvider");return e},sk={productId:hr.productId,pdpLink:hr.pdpLink},u1=B.createContext(sk),ok=({children:e})=>{const[t,n]=B.useState(hr.productId),[r,s]=B.useState(hr.pdpLink);B.useEffect(()=>{const u=({detail:c})=>{if((c==null?void 0:c.property)==="pdp-context"){const d=c.value;n(d.productId),s(d.pdpLink);return}(c==null?void 0:c.property)==="productId"&&n(c.value),(c==null?void 0:c.property)==="pdpLink"&&s(c.value)};return Ug(u),()=>{Hg(u)}},[]);const a=B.useMemo(()=>({productId:t,pdpLink:r}),[t,r]);return S.jsx(u1.Provider,{value:a,children:e})},ak=()=>{const e=B.useContext(u1);if(!e)throw new Error("usePdp must be used within a PdpProvider");return e},l1=B.createContext({mode:Je.modeProxy.mode,entryType:Je.entryType,status:Je.statusProxy,dialogPosition:Je.dialogProxy.position,isDialogFullHeight:Je.dialogProxy.isFullHeight,dialogWidth:Je.dialogProxy.width,isModalFullscreen:Je.modalProxy.isFullscreen,previousComponentType:Je.statusProxy.type}),uk=({entryType:e,componentConfig:t,componentType:n,children:r})=>{const[s,a]=B.useState(e!=null?e:Je.entryTypeProxy.entryType),[u,c]=B.useState(Je.modeProxy.mode),[d,f]=B.useState({type:n||Je.statusProxy.type,isOpen:t&&"isOpen"in t?!!t.isOpen:Je.statusProxy.isOpen,isMinimized:t&&"isMinimized"in t?!!t.isMinimized:Je.statusProxy.isMinimized}),[p,m]=B.useState(Je.dialogProxy.position),[b,y]=B.useState(Je.dialogProxy.isFullHeight),[_,A]=B.useState(Je.dialogProxy.width),[v,w]=B.useState(Je.modalProxy.isFullscreen),N=Sv(d.type);B.useEffect(()=>{const U=Y=>{const{property:R,value:q}=Y.detail||{};if(!(!R||q===void 0)){if(R==="mode"){c(q);return}if(R==="entryType"){a(q);return}if(R==="isMinimized"){f(ne=>de(F({},ne),{isMinimized:q}));return}if(R==="isOpen"){f(ne=>de(F({},ne),{isOpen:q}));return}if(R==="type"){f(ne=>de(F({},ne),{type:q}));return}if(R==="position"){m(q);return}if(R==="isFullHeight"){y(q);return}if(R==="width"){A(q);return}if(R==="isFullscreen"){w(q);return}}};return uv(U),()=>{lv(U)}},[]),pa(()=>{e&&ha(e)}),pa(()=>{const U=n||(t==null?void 0:t.type);U&&cl(U),t&&"isOpen"in t&&ei(!!t.isOpen),t&&"isMinimized"in t&&ll(!!t.isMinimized)}),pa(()=>{if(!(t!=null&&t.options))return;const{dialogPosition:U}=t.options;U&&yf(U),"dialogFullHeight"in t.options&&fv(!!t.options.dialogFullHeight),"dialogWidth"in t.options&&t.options.dialogWidth&&A(t.options.dialogWidth),"isModalFullscreen"in t.options&&Ef(!!t.options.isModalFullscreen)});const C=B.useMemo(()=>({mode:u,entryType:s,status:d,previousComponentType:N||"dialog",dialogPosition:p,isDialogFullHeight:b,dialogWidth:_,isModalFullscreen:v}),[u,s,d,N,p,b,_,v]);return S.jsx(l1.Provider,{value:C,children:r})},Zn=()=>{const e=B.useContext(l1);if(!e)throw new Error("useUIState must be used within a UIStateProvider");return e},c1=B.createContext(null),d1=B.createContext(null),bf=()=>{const e=B.useContext(d1);if(!e)throw new Error("usePromptsExtensionDispatch must be used within a PromptsExtensionProvider");return e||{}},ti=()=>{const e=B.useContext(c1);if(!e)throw new Error("usePromptsExtensionState must be used within a PromptsExtensionProvider");return e||{}},Gs=()=>{const e=B.useContext(G0);if(!e)throw new Error("useCopilotDispatch must be used within a CopilotProvider");return e},er=()=>{const e=B.useContext(Y0);if(!e)throw new Error("useCopilotState must be used within a CopilotProvider");return e},lk=({copilot:e})=>{const{logger:t,conversationHistory:n}=tt(),{isInline:r}=ti(),{addCopilotEvent:s,setConversationHistoryLoaded:a}=Gs(),{activeConversationId:u}=er(),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,b=>{const y=[];[...b.reverse()||[]].forEach(A=>{var w;const v=b.find(N=>N.id===A.eventSourceId);(w=v==null?void 0:v.name)!=null&&w.endsWith("_suggestions")||(A.bypassHandlers=!0,y.unshift(A))}),y.forEach(A=>{s(A)}),a(!0)})},[t,r,u,d,s,a,n]),{getSessionInformation:c,getConversationMessages:d}},f1=B.createContext({copilot:null,messages:[],groupedMessages:[],isLoading:!1,isResponseLoading:()=>!1,handleAskCim:()=>{},handleSearch:()=>{},handleBrowse:()=>{},handlePdp:()=>{},handleSuggestion:()=>{},handleUserInput:()=>{},handleCancel:()=>{},resetConversation:()=>{},getSessionInformation:()=>{},getConversationMessages:()=>{}}),ck=({apiKey:e,apiToken:t,baseUrl:n,customerId:r,tenantId:s,isDevelopment:a,onConnect:u,onRefinedSearch:c,onRefinedBrowse:d,children:f})=>{const{logger:p,clientContext:m,baseCatalogParams:b}=tt(),sn=ik(),{searchQuery:y}=sn,_=cn(sn,["searchQuery"]),Mn=tk(),{categoryId:A}=Mn,v=cn(Mn,["categoryId"]),{productId:w,pdpLink:N}=ak(),{setCopilot:C,setConnected:U,resetCopilot:Y,resetCopilotState:R,addCopilotEvent:q,removeLoadingMessage:ne,handleCopilotRequestAck:me,setActiveConversationId:V,setConversationIds:se,setAskCimPrompts:he}=Gs(),{connected:ve,copilot:re,messages:oe,groupedMessages:xe,loadingMessages:ae,askCimPrompts:Q}=er(),{status:ie,entryType:k}=Zn(),{isInline:D}=ti(),{getConversationMessages:ee,getSessionInformation:I}=lk({copilot:re}),_e=B.useMemo(()=>ae.size>0,[ae]),Be=B.useCallback(we=>ae.has(we),[ae]),ye=B.useCallback(({query:we,facetFilters:Pe,rangeFilters:Me,catalogSegment:rt,pricebooks:ht,userPrompt:J,imageFile:ge})=>{if(!re){p==null||p.error("Copilot is not initialized");return}if(!we)return;const Ce={searchParams:{query:we}};J&&(Ce.userPrompt=J),ge&&(Ce.attachments={image:ge}),Pe&&Object.keys(Pe).length>0&&(Ce.searchParams.facetFilters=Pe),Me&&Me.length>0&&(Ce.searchParams.rangeFilters=Me),rt&&(Ce.searchParams.catalogSegment=rt),ht&&(Ce.searchParams.pricebooks=ht),m&&(Ce.clientContext=m),ha("search"),re.search(Ce,Ve=>{const Ie=F({},Ve);me(Ie)})},[p,me,re,m]),Le=B.useCallback(({categoryId:we,categoryName:Pe,facetFilters:Me,rangeFilters:rt,catalogSegment:ht,pricebooks:J,userPrompt:ge,imageFile:Ce})=>{if(!re){p==null||p.error("Copilot is not initialized");return}const Ve=Me&&Object.keys(Me).length>0;if(we===""&&!Ve){p==null||p.error("Browse event must include facetFilters when categoryId is empty");return}const Ie={browseParams:{categoryId:we||""}};ge&&(Ie.userPrompt=ge),Ce&&(Ie.attachments={image:Ce}),Ve&&(Ie.browseParams.facetFilters=Me),rt&&rt.length>0&&(Ie.browseParams.rangeFilters=rt),ht&&(Ie.browseParams.catalogSegment=ht),Array.isArray(J)&&J.length>0&&(Ie.browseParams.pricebooks=J),(m||Pe)&&(Ie.clientContext={},m&&(Ie.clientContext=F({},m)),Pe&&(Ie.clientContext.cimLabel=Pe)),ha("browse"),re.browse(Ie,lt=>{var $r;const $t=F({},lt),Ut=(($r=$t.request)==null?void 0:$r.clientContext)||{},on=(Ut==null?void 0:Ut.cimLabel)||Pe;on&&$t.request&&($t.request.label=on),me($t)})},[p,me,re,m]),Ue=B.useCallback(({productId:we,productName:Pe,pdpLink:Me,userPrompt:rt,imageFile:ht})=>{if(!re){p==null||p.error("Copilot is not initialized");return}if(!we)return;const J={productId:we};rt&&(J.userPrompt=rt),Me&&(J.pdpLink=Me),ht&&(J.attachments={image:ht}),(m||Pe)&&(J.clientContext={},m&&(J.clientContext=F({},m)),Pe&&(J.clientContext.cimLabel=Pe)),b&&(J.baseCatalogParams=b),ha("pdp"),re.productView(J,ge=>{var lt;const Ce=F({},ge),Ve=((lt=Ce.request)==null?void 0:lt.clientContext)||{},Ie=(Ve==null?void 0:Ve.cimLabel)||Pe;Ie&&Ce.request&&(Ce.request.label=Ie),me(Ce)})},[p,re,me,m,b]),Ye=B.useCallback(({userPrompt:we,imageFile:Pe})=>{if(!re){p==null||p.error("Copilot is not initialized");return}if(!we)return;const Me={userPrompt:we};Pe&&(Me.attachments={image:Pe}),m&&(Me.clientContext=m),b&&(Me.baseCatalogParams=b),re.askCim(Me,rt=>{const ht=F({},rt);me(ht)})},[p,re,me,m,b]),Tt=B.useCallback(we=>{q(we),c==null||c(we)},[q,c]),Cn=B.useCallback(we=>{q(we),d==null||d(we)},[q,d]),rn=B.useCallback(we=>{u==null||u(we),U(!0)},[u,U]);B.useEffect(()=>{!re||!ve||!ie.isOpen||mn.size>0&&mn.processQueue(we=>{if(we.context==="search"){const Pe=F({},we.payload);s1(Pe)}if(we.context==="browse"){const Pe=F({},we.payload);Qg(Pe)}if(we.context==="pdp"){const Pe=F({},we.payload);Jg(Pe)}})},[ie.isOpen,re,ve]);const Tr=B.useCallback(we=>{const Pe=Me=>{const rt=de(F({},Me),{id:Me.inquiryLinkId||Me.id});q(rt)};we.on("connect_ack",rn),we.on("partial_inquiry",Pe),we.on("display_products",q),we.on("progress",q),we.on("refined_search",Tt),we.on("refined_browse",Cn),we.on("done",Me=>{ne(Me.eventSourceId)}),we.on("error",Me=>{q(Me),ne(Me.eventSourceId)}),we.onDisconnect(Me=>{const rt=["io server disconnect","transport error","server shutting down"];if(p==null||p.log("Connection disconnected with reason: ",Me),!rt.includes(Me)){U(!1);return}p==null||p.log("De-registering event listeners");const ht=new Date().toISOString();q({name:"error",message:"Connection was lost. Please try again.",createdAt:ht,id:`error-${ht}`,sessionId:"session"}),we.off()})},[p,U,ne,Tt,Cn,q,rn]);B.useEffect(()=>{if(!re)return;const we=Pe=>{if(!D){if(!Pe.message&&Pe.eventSourceId&&Pe.eventSourceId===Q.requestId){he({requestId:Pe.eventSourceId,message:Pe});return}q(Pe)}};return re.on("follow_up",we),()=>{re.off("follow_up",we)}},[re,oe,Q.requestId,D,q,he]),B.useEffect(()=>{if(!re)return;const we=Pe=>{if(D)return;const Me=de(F({},Pe),{id:Pe.inquiryLinkId||Pe.id});q(Me)};return re.on("inquiry",we),()=>{re.off("inquiry",we)}},[re,D,q]),pa(()=>{let we;n?we=n:we=a?"https://staging.copilot.search.cimulate.ai":"https://prod.copilot.search.cimulate.ai";const Pe={baseUrl:we};e?Pe.apiKey=e:t&&(Pe.apiToken=t),r&&(Pe.customerId=r),s&&(Pe.tenantId=s);const Me=new qw(Pe);return C(Me),Tr(Me),Me.connect(),Me.requestSessionInformation(rt=>{p==null||p.log("Session Information: ",rt);const{activeConversationId:ht,conversationIds:J}=rt.data||{};ht&&V(ht),J!=null&&J.length&&se(J)}),()=>{Me.disconnect(),Me.off(),Y()}});const ir=B.useCallback(we=>{if(!re)return;const Pe={eventId:we,reason:"User cancelled the request"};re.cancelRequest(Pe,Me=>{q(Me),ne(we)})},[q,ne,re]),Qt=B.useCallback(()=>{re&&re.conversationReset({},we=>{R(),q(we),re.requestSessionInformation(Pe=>{p==null||p.log("Session Information: ",Pe);const{activeConversationId:Me,conversationIds:rt}=Pe.data||{};Me&&V(Me),rt!=null&&rt.length&&se(rt)})})},[re,p,q,R,V,se]),$e=B.useCallback((we,Pe)=>{if(!we)return;const Me={userPrompt:we};switch(Pe&&(Me.imageFile=Pe),k){case"ask_cim":Ye(Me);return;case"search":y?ye(F(F({query:y},_),Me)):Ye(Me);return;case"browse":Le(F(F({categoryId:A},v),Me));return;case"pdp":w?Ue(F({productId:w,pdpLink:N||""},Me)):Ye(Me);return}},[k,y,_,ye,Ye,A,v,Le,Ue,w,N]),vt=B.useCallback((we,Pe)=>{var ge,Ce,Ve;const rt=we.params.userPrompt||"";if(!rt)return;const ht=oe.find(Ie=>Ie.id===Pe);if(!ht)return;const J=ht.name.replace("_suggestions","");if(J==="ask_cim"){Ye({userPrompt:rt});return}if(J==="copilot_search"){const Ie=((ge=ht.request)==null?void 0:ge.searchParams)||{},$t=Ie.query===y;ye(de(F({query:Ie.query||y},$t?_:{}),{userPrompt:rt}));return}if(J==="copilot_browse"){const Ie=ht.request,lt=Ie.browseParams||{},Ut=lt.categoryId===A,on=((Ce=Ie.clientContext)==null?void 0:Ce.cimLabel)||"";Le(de(F({categoryId:lt.categoryId||A||""},Ut?v:{}),{categoryName:on,userPrompt:rt}));return}if(J==="product_view"){const Ie=ht.request||{},lt=Ie.productId,$t=lt===w,Ut=((Ve=Ie.clientContext)==null?void 0:Ve.cimLabel)||"";let on="";$t?on=N||"":on=Ie.pdpLink||"",Ue({productId:lt||w,pdpLink:on,productName:Ut,userPrompt:rt})}},[oe,y,_,ye,Ye,A,v,Le,Ue,w,N]),vn=B.useMemo(()=>({copilot:re,messages:oe,groupedMessages:xe,isLoading:_e,isResponseLoading:Be,handleAskCim:Ye,handleSearch:ye,handleBrowse:Le,handlePdp:Ue,handleUserInput:$e,handleSuggestion:vt,handleCancel:ir,resetConversation:Qt,getSessionInformation:I,getConversationMessages:ee}),[re,oe,xe,_e,Be,Ye,ye,Le,Ue,$e,vt,ir,Qt,I,ee]);return S.jsx(f1.Provider,{value:vn,children:f})},h1=()=>{const{copilot:e}=er(),{addCopilotEvent:t}=Gs();return{getCopilotSuggestions:B.useCallback((r,s,a)=>{if(!e||!s||!r)return;const u=c=>{t(c),a(c)};switch(s){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])}},Or=()=>{const e=B.useContext(f1);if(!e)throw new Error("useCopilot must be used within a CopilotProvider");return e},dk=()=>{const{copilot:e,activeConversationId:t,askCimPrompts:n,conversationHistoryLoaded:r}=er(),{entryType:s}=Zn(),{resetCopilotState:a,addCopilotEvent:u,setAskCimPrompts:c}=Gs(),{handleSearch:d,handleBrowse:f,handlePdp:p,resetConversation:m,getSessionInformation:b,getConversationMessages:y}=Or(),{getCopilotSuggestions:_}=h1();B.useEffect(()=>{!e||!s||!t||!r||n.requestId||s==="ask_cim"&&_({},s,N=>{c({requestId:N.id,message:null})})},[e,t,n.requestId,s,r,_,c]);const A=B.useCallback(({query:N})=>{if(!e||!N)return;const{facetFilters:C}=yt.facetFiltersProxy,{rangeFilters:U}=yt.rangeFiltersProxy,{catalogSegment:Y}=yt.catalogSegmentProxy,{pricebooks:R}=yt.pricebooksProxy,q={query:N};q.facetFilters=C||{},q.rangeFilters=U||[],q.catalogSegment=Y||"",q.pricebooks=R||[],d(F({},q))},[e,d]),v=B.useCallback(({categoryId:N})=>{if(!e)return;const C=ut.categoryIdProxy.categoryName,{facetFilters:U}=ut.facetFiltersProxy,{rangeFilters:Y}=ut.rangeFiltersProxy,{catalogSegment:R}=ut.catalogSegmentProxy,{pricebooks:q}=ut.pricebooksProxy,ne={categoryId:N};ne.categoryName=C||"",ne.facetFilters=U||{},ne.rangeFilters=Y||[],ne.catalogSegment=R||"",ne.pricebooks=q||[],f(F({},ne))},[e,f]),w=B.useCallback(({productId:N})=>{if(!e||!N)return;const C={productId:N,pdpLink:hr.pdpLink,productName:hr.proxy.productName||""};p(C)},[e,p]);return B.useEffect(()=>{const N=({detail:C})=>{(C==null?void 0:C.property)==="query"&&A({query:C.value})};return Dg(N),()=>{Mg(N)}},[A]),B.useEffect(()=>{const N=({detail:C})=>{if((C==null?void 0:C.property)==="pdp-context"){const U=C.value;w({productId:U.productId});return}(C==null?void 0:C.property)==="productId"&&w({productId:C.value})};return Ug(N),()=>{Hg(N)}},[w]),B.useEffect(()=>{const N=({detail:C})=>{(C==null?void 0:C.property)==="categoryId"&&v({categoryId:C.value})};return Fg(N),()=>{Bg(N)}},[v]),B.useEffect(()=>{const N=({detail:C})=>{if((C==null?void 0:C.event)==Ti.RESET_CONVERSATION&&m(),(C==null?void 0:C.event)==Ti.GET_SESSION_INFORMATION){const U=C.value.callback;b(U)}if((C==null?void 0:C.event)==Ti.GET_CONVERSATION_MESSAGES){const{payload:U,callback:Y}=C.value;if(!U.conversationId||typeof Y!="function")return;y(U,Y)}if((C==null?void 0:C.event)==Ti.LOAD_CONVERSATION){const U=C.value;if(!U.conversationId)return;y(U,R=>{a(),R.forEach(q=>{u(q)})})}};return vv(N),()=>{kv(N)}},[m,b,y,a,u]),null},fk=({apiKey:e,apiToken:t,baseUrl:n,customerId:r,tenantId:s,isDevelopment:a,onConnect:u,onRefinedSearch:c,onRefinedBrowse:d,children:f})=>S.jsxs(ck,{apiKey:e,apiToken:t,baseUrl:n,customerId:r,tenantId:s,isDevelopment:a,onConnect:u,onRefinedSearch:c,onRefinedBrowse:d,children:[S.jsx(dk,{}),f]}),hk=e=>Array.from(new Set((e!=null?e:[]).map(t=>t.trim()).filter(Boolean))),pk=({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]),s=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]),b=B.useCallback(_=>{t({type:gt.SET_PROMPTS_EXTENSION_RESPONSE_LOADING,payload:_})},[t]),y=B.useMemo(()=>({setIsInitialized:n,setIsOpen:r,setIsInline:s,setElementId:a,setEntryType:u,setActivePromptsId:c,setUserPrompt:d,setParams:f,setPromptsMessage:p,setResponseMessage:m,setIsResponseLoading:b}),[n,r,s,a,u,c,d,f,p,m,b]);return S.jsx(d1.Provider,{value:y,children:e})},mk=(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}},gk=({promptsConfig:e,children:t})=>{const[n,r]=j0(mk,de(F(F({},Zg),e||{}),{staticQuestions:hk((e==null?void 0:e.staticQuestions)||[])}));return S.jsx(c1.Provider,{value:n,children:S.jsx(pk,{dispatch:r,children:t})})},p1=({mode:e,apiKey:t,apiToken:n,baseUrl:r,customerId:s,tenantId:a,logoUrl:u,headerText:c,headerConfig:d,theme:f,openLinksInNewTab:p,globalClassName:m,isDevelopment:b=!1,componentType:y,componentConfig:_,entryType:A,entryMessage:v,disclaimerText:w,disclaimerMarkdown:N,clientContext:C,baseCatalogParams:U,searchPlaceholder:Y,searchButtonLabel:R,searchConfig:q,suggestionButtonConfig:ne,messageAlignment:me,autoScroll:V,promptsConfig:se,resetConversationMessage:he,conversationHistory:ve,onConnect:re,onCopilotEvent:oe,onRefinedSearch:xe,onRefinedBrowse:ae,__features:Q,children:ie})=>S.jsx(ov,{mode:e,baseUrl:r,apiKey:t,apiToken:n,customerId:s,tenantId:a,logoUrl:u,headerText:c,headerConfig:d,entryMessage:v,theme:f,globalClassName:m,openLinksInNewTab:p,searchPlaceholder:Y,searchButtonLabel:R,searchConfig:q,suggestionButtonConfig:ne,messageAlignment:me,autoScroll:V,componentConfig:_,clientContext:C,baseCatalogParams:U,disclaimerMarkdown:N,disclaimerText:w,resetConversationMessage:he,conversationHistory:ve,isDevelopment:b,__features:Q,children:S.jsx(uk,{entryType:A,componentConfig:_,componentType:y,children:S.jsx(mv,{onCopilotEvent:oe,children:S.jsx(ok,{children:S.jsx(ek,{children:S.jsx(rk,{children:S.jsx(gk,{promptsConfig:se,children:S.jsx(fk,{apiKey:t,apiToken:n,baseUrl:r,customerId:s,tenantId:a,isDevelopment:b,entryType:A,onConnect:re,onRefinedSearch:xe,onRefinedBrowse:ae,onCopilotEvent:oe,children:ie})})})})})})})});var _f={exports:{}},On={},Sf={exports:{}},xf={};var m1;function Ek(){return m1||(m1=1,(function(e){function t(Q,ie){var k=Q.length;Q.push(ie);e:for(;0<k;){var D=k-1>>>1,ee=Q[D];if(0<s(ee,ie))Q[D]=ie,Q[k]=ee,k=D;else break e}}function n(Q){return Q.length===0?null:Q[0]}function r(Q){if(Q.length===0)return null;var ie=Q[0],k=Q.pop();if(k!==ie){Q[0]=k;e:for(var D=0,ee=Q.length,I=ee>>>1;D<I;){var _e=2*(D+1)-1,Be=Q[_e],ye=_e+1,Le=Q[ye];if(0>s(Be,k))ye<ee&&0>s(Le,Be)?(Q[D]=Le,Q[ye]=k,D=ye):(Q[D]=Be,Q[_e]=k,D=_e);else if(ye<ee&&0>s(Le,k))Q[D]=Le,Q[ye]=k,D=ye;else break e}}return ie}function s(Q,ie){var k=Q.sortIndex-ie.sortIndex;return k!==0?k:Q.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,b=3,y=!1,_=!1,A=!1,v=typeof setTimeout=="function"?setTimeout:null,w=typeof clearTimeout=="function"?clearTimeout:null,N=typeof setImmediate!="undefined"?setImmediate:null;typeof navigator!="undefined"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function C(Q){for(var ie=n(f);ie!==null;){if(ie.callback===null)r(f);else if(ie.startTime<=Q)r(f),ie.sortIndex=ie.expirationTime,t(d,ie);else break;ie=n(f)}}function U(Q){if(A=!1,C(Q),!_)if(n(d)!==null)_=!0,xe(Y);else{var ie=n(f);ie!==null&&ae(U,ie.startTime-Q)}}function Y(Q,ie){_=!1,A&&(A=!1,w(ne),ne=-1),y=!0;var k=b;try{for(C(ie),m=n(d);m!==null&&(!(m.expirationTime>ie)||Q&&!se());){var D=m.callback;if(typeof D=="function"){m.callback=null,b=m.priorityLevel;var ee=D(m.expirationTime<=ie);ie=e.unstable_now(),typeof ee=="function"?m.callback=ee:m===n(d)&&r(d),C(ie)}else r(d);m=n(d)}if(m!==null)var I=!0;else{var _e=n(f);_e!==null&&ae(U,_e.startTime-ie),I=!1}return I}finally{m=null,b=k,y=!1}}var R=!1,q=null,ne=-1,me=5,V=-1;function se(){return!(e.unstable_now()-V<me)}function he(){if(q!==null){var Q=e.unstable_now();V=Q;var ie=!0;try{ie=q(!0,Q)}finally{ie?ve():(R=!1,q=null)}}else R=!1}var ve;if(typeof N=="function")ve=function(){N(he)};else if(typeof MessageChannel!="undefined"){var re=new MessageChannel,oe=re.port2;re.port1.onmessage=he,ve=function(){oe.postMessage(null)}}else ve=function(){v(he,0)};function xe(Q){q=Q,R||(R=!0,ve())}function ae(Q,ie){ne=v(function(){Q(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(Q){Q.callback=null},e.unstable_continueExecution=function(){_||y||(_=!0,xe(Y))},e.unstable_forceFrameRate=function(Q){0>Q||125<Q?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):me=0<Q?Math.floor(1e3/Q):5},e.unstable_getCurrentPriorityLevel=function(){return b},e.unstable_getFirstCallbackNode=function(){return n(d)},e.unstable_next=function(Q){switch(b){case 1:case 2:case 3:var ie=3;break;default:ie=b}var k=b;b=ie;try{return Q()}finally{b=k}},e.unstable_pauseExecution=function(){},e.unstable_requestPaint=function(){},e.unstable_runWithPriority=function(Q,ie){switch(Q){case 1:case 2:case 3:case 4:case 5:break;default:Q=3}var k=b;b=Q;try{return ie()}finally{b=k}},e.unstable_scheduleCallback=function(Q,ie,k){var D=e.unstable_now();switch(typeof k=="object"&&k!==null?(k=k.delay,k=typeof k=="number"&&0<k?D+k:D):k=D,Q){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,Q={id:p++,callback:ie,priorityLevel:Q,startTime:k,expirationTime:ee,sortIndex:-1},k>D?(Q.sortIndex=k,t(f,Q),n(d)===null&&Q===n(f)&&(A?(w(ne),ne=-1):A=!0,ae(U,k-D))):(Q.sortIndex=ee,t(d,Q),_||y||(_=!0,xe(Y))),Q},e.unstable_shouldYield=se,e.unstable_wrapCallback=function(Q){var ie=b;return function(){var k=b;b=ie;try{return Q.apply(this,arguments)}finally{b=k}}}})(xf)),xf}var g1;function yk(){return g1||(g1=1,Sf.exports=Ek()),Sf.exports}var E1;function Tk(){if(E1)return On;E1=1;var e=fn(),t=yk();function n(i){for(var o="https://reactjs.org/docs/error-decoder.html?invariant="+i,l=1;l<arguments.length;l++)o+="&args[]="+encodeURIComponent(arguments[l]);return"Minified React error #"+i+"; visit "+o+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}var r=new Set,s={};function a(i,o){u(i,o),u(i+"Capture",o)}function u(i,o){for(s[i]=o,i=0;i<o.length;i++)r.add(o[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 b(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,o,l,h){if(l!==null&&l.type===0)return!1;switch(typeof o){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,o,l,h){if(o===null||typeof o=="undefined"||y(i,o,l,h))return!0;if(h)return!1;if(l!==null)switch(l.type){case 3:return!o;case 4:return o===!1;case 5:return isNaN(o);case 6:return isNaN(o)||1>o}return!1}function A(i,o,l,h,E,T,x){this.acceptsBooleans=o===2||o===3||o===4,this.attributeName=h,this.attributeNamespace=E,this.mustUseProperty=l,this.propertyName=i,this.type=o,this.sanitizeURL=T,this.removeEmptyString=x}var v={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(i){v[i]=new A(i,0,!1,i,null,!1,!1)}),[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(i){var o=i[0];v[o]=new A(o,1,!1,i[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(i){v[i]=new A(i,2,!1,i.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(i){v[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){v[i]=new A(i,3,!1,i.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(i){v[i]=new A(i,3,!0,i,null,!1,!1)}),["capture","download"].forEach(function(i){v[i]=new A(i,4,!1,i,null,!1,!1)}),["cols","rows","size","span"].forEach(function(i){v[i]=new A(i,6,!1,i,null,!1,!1)}),["rowSpan","start"].forEach(function(i){v[i]=new A(i,5,!1,i.toLowerCase(),null,!1,!1)});var w=/[\-:]([a-z])/g;function N(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 o=i.replace(w,N);v[o]=new A(o,1,!1,i,null,!1,!1)}),"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(i){var o=i.replace(w,N);v[o]=new A(o,1,!1,i,"http://www.w3.org/1999/xlink",!1,!1)}),["xml:base","xml:lang","xml:space"].forEach(function(i){var o=i.replace(w,N);v[o]=new A(o,1,!1,i,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(function(i){v[i]=new A(i,1,!1,i.toLowerCase(),null,!1,!1)}),v.xlinkHref=new A("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach(function(i){v[i]=new A(i,1,!1,i.toLowerCase(),null,!0,!0)});function C(i,o,l,h){var E=v.hasOwnProperty(o)?v[o]:null;(E!==null?E.type!==0:h||!(2<o.length)||o[0]!=="o"&&o[0]!=="O"||o[1]!=="n"&&o[1]!=="N")&&(_(o,l,E,h)&&(l=null),h||E===null?b(o)&&(l===null?i.removeAttribute(o):i.setAttribute(o,""+l)):E.mustUseProperty?i[E.propertyName]=l===null?E.type===3?!1:"":l:(o=E.attributeName,h=E.attributeNamespace,l===null?i.removeAttribute(o):(E=E.type,l=E===3||E===4&&l===!0?"":""+l,h?i.setAttributeNS(h,o,l):i.setAttribute(o,l))))}var U=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,Y=Symbol.for("react.element"),R=Symbol.for("react.portal"),q=Symbol.for("react.fragment"),ne=Symbol.for("react.strict_mode"),me=Symbol.for("react.profiler"),V=Symbol.for("react.provider"),se=Symbol.for("react.context"),he=Symbol.for("react.forward_ref"),ve=Symbol.for("react.suspense"),re=Symbol.for("react.suspense_list"),oe=Symbol.for("react.memo"),xe=Symbol.for("react.lazy"),ae=Symbol.for("react.offscreen"),Q=Symbol.iterator;function ie(i){return i===null||typeof i!="object"?null:(i=Q&&i[Q]||i["@@iterator"],typeof i=="function"?i:null)}var k=Object.assign,D;function ee(i){if(D===void 0)try{throw Error()}catch(l){var o=l.stack.trim().match(/\n( *(at )?)/);D=o&&o[1]||""}return`
11
11
  `+D+i}var I=!1;function _e(i,o){if(!i||I)return"";I=!0;var l=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{if(o)if(o=function(){throw Error()},Object.defineProperty(o.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(o,[])}catch(Z){var h=Z}Reflect.construct(i,[],o)}else{try{o.call()}catch(Z){h=Z}i.call(o.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
  `),T=h.stack.split(`
13
13
  `),x=E.length-1,L=T.length-1;1<=x&&0<=L&&E[x]!==T[L];)L--;for(;1<=x&&0<=L;x--,L--)if(E[x]!==T[L]){if(x!==1||L!==1)do if(x--,L--,0>L||E[x]!==T[L]){var H=`
@@ -7352,8 +7352,8 @@ const gt = new KP(), QP = (e) => {
7352
7352
  e != null ? e : Xe.entryTypeProxy.entryType
7353
7353
  ), [u, c] = B.useState(Xe.modeProxy.mode), [f, d] = B.useState({
7354
7354
  type: n || Xe.statusProxy.type,
7355
- isOpen: Xe.statusProxy.isOpen,
7356
- isMinimized: Xe.statusProxy.isMinimized
7355
+ isOpen: t && "isOpen" in t ? !!t.isOpen : Xe.statusProxy.isOpen,
7356
+ isMinimized: t && "isMinimized" in t ? !!t.isMinimized : Xe.statusProxy.isMinimized
7357
7357
  }), [p, m] = B.useState(Xe.dialogProxy.position), [b, y] = B.useState(Xe.dialogProxy.isFullHeight), [_, C] = B.useState(Xe.dialogProxy.width), [N, A] = B.useState(Xe.modalProxy.isFullscreen), P = _P(f.type);
7358
7358
  B.useEffect(() => {
7359
7359
  const U = (Y) => {