@smarttalks.ai/widget 0.8.8 → 0.9.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/lib/index.js +17 -14
- package/lib/index.umd.cjs +1 -1
- package/package.json +1 -1
package/lib/index.js
CHANGED
|
@@ -10690,16 +10690,19 @@ class et {
|
|
|
10690
10690
|
static instance;
|
|
10691
10691
|
constructor() {
|
|
10692
10692
|
}
|
|
10693
|
-
static init() {
|
|
10693
|
+
static init(t) {
|
|
10694
10694
|
return et.instance || (et.instance = gn(ja, {
|
|
10695
10695
|
path: "/ws",
|
|
10696
|
-
withCredentials: !0
|
|
10696
|
+
withCredentials: !0,
|
|
10697
|
+
extraHeaders: {
|
|
10698
|
+
"widget-id": t
|
|
10699
|
+
}
|
|
10697
10700
|
}), et.instance.on("connect", () => {
|
|
10698
10701
|
console.info("SmartTalks.ai widget connected!");
|
|
10699
10702
|
})), et.instance;
|
|
10700
10703
|
}
|
|
10701
|
-
static on(t, n) {
|
|
10702
|
-
et.instance || this.init().on(t,
|
|
10704
|
+
static on(t, n, r) {
|
|
10705
|
+
et.instance || this.init(n).on(t, r);
|
|
10703
10706
|
}
|
|
10704
10707
|
}
|
|
10705
10708
|
const Hs = 1e3 * 60 * 60 * 24, [An, qs] = Gi(
|
|
@@ -10744,22 +10747,22 @@ const Hs = 1e3 * 60 * 60 * 24, [An, qs] = Gi(
|
|
|
10744
10747
|
}
|
|
10745
10748
|
si();
|
|
10746
10749
|
}, wh = (e, t) => {
|
|
10747
|
-
const { chatWidget: n } = ie(),
|
|
10750
|
+
const { chatWidget: n, widgetId: r } = ie(), o = Ys();
|
|
10748
10751
|
e.trim() && (Dr({
|
|
10749
10752
|
text: e,
|
|
10750
10753
|
type: "text",
|
|
10751
10754
|
origin: "user",
|
|
10752
10755
|
createdAt: (/* @__PURE__ */ new Date()).toString()
|
|
10753
|
-
}), ee("onInput", e), et.on("message", (
|
|
10754
|
-
(
|
|
10755
|
-
contactId:
|
|
10756
|
-
interactionId:
|
|
10756
|
+
}), ee("onInput", e), et.on("message", r(), (i) => {
|
|
10757
|
+
(i.contactId !== o.contactId || i.interactionId !== o.interactionId) && Xs({
|
|
10758
|
+
contactId: i.contactId,
|
|
10759
|
+
interactionId: i.interactionId
|
|
10757
10760
|
});
|
|
10758
|
-
for (const
|
|
10759
|
-
Dr(
|
|
10760
|
-
or(!1), bf(
|
|
10761
|
-
}), or(!0), vf(e, t, n()?._id).catch((
|
|
10762
|
-
console.error(
|
|
10761
|
+
for (const s of i.messages)
|
|
10762
|
+
Dr(s), ee("onAnswer", s);
|
|
10763
|
+
or(!1), bf(i.debug);
|
|
10764
|
+
}), or(!0), vf(e, t, n()?._id).catch((i) => {
|
|
10765
|
+
console.error(i), or(!1);
|
|
10763
10766
|
}));
|
|
10764
10767
|
}, xh = () => {
|
|
10765
10768
|
const { chatWidget: e } = ie(), t = Ys();
|
package/lib/index.umd.cjs
CHANGED
|
@@ -178,4 +178,4 @@
|
|
|
178
178
|
*
|
|
179
179
|
* Credits to the Radix UI team:
|
|
180
180
|
* https://github.com/radix-ui/primitives/blob/81b25f4b40c54f72aeb106ca0e64e1e09655153e/packages/react/menu/src/Menu.tsx
|
|
181
|
-
*/function Wd(e,t){return t?jc([e.clientX,e.clientY],t):!1}function Gd(e){const t=kt(),n=Fi(),r=hs(),o=Le({placement:"bottom-start"},e),[i,s]=j(o,["open","defaultOpen","onOpenChange"]);let a=0,l=null,c="right";const[d,u]=P(),[h,m]=P(),[f,g]=P(),[p,b]=P(),[v,w]=P(!0),[x,O]=P(s.placement),[k,E]=P([]),[$,_]=P([]),{DomCollectionProvider:R}=Vu({items:$,onItemsChange:_}),L=wi({open:()=>i.open,defaultOpen:()=>i.defaultOpen,onOpenChange:U=>i.onOpenChange?.(U)}),I=uu(()=>t.forceMount()||L.isOpen()),ne=Tu({selectionMode:"none",dataSource:$}),Y=U=>{w(U),L.open()},fe=(U=!1)=>{L.close(),U&&r&&r.close(!0)},F=U=>{w(U),L.toggle()},V=()=>{const U=p();U&&(de(U),ne.selectionManager().setFocused(!0),ne.selectionManager().setFocusedKey(void 0))},Q=U=>{E(ho=>[...ho,U]);const Un=r?.registerNestedMenu(U);return()=>{E(ho=>dr(ho,U)),Un?.()}},ie=U=>c===l?.side&&Wd(U,l?.area),At=U=>{ie(U)&&U.preventDefault()},Pe=U=>{ie(U)||V()},dm=U=>{ie(U)&&U.preventDefault()};au({isDisabled:()=>!(r==null&&L.isOpen()&&t.isModal()),targets:()=>[p(),...k()].filter(Boolean)}),D(()=>{const U=p();if(!U||!r)return;const Un=r.registerNestedMenu(U);K(()=>{Un()})});const fm={dataset:C(()=>({"data-expanded":L.isOpen()?"":void 0,"data-closed":L.isOpen()?void 0:""})),isOpen:L.isOpen,contentPresence:I,nestedMenus:k,currentPlacement:x,pointerGraceTimeoutId:()=>a,autoFocus:v,listState:()=>ne,parentMenuContext:()=>r,triggerRef:f,contentRef:p,triggerId:d,contentId:h,setTriggerRef:g,setContentRef:b,open:Y,close:fe,toggle:F,focusContent:V,onItemEnter:At,onItemLeave:Pe,onTriggerLeave:dm,setPointerDir:U=>c=U,setPointerGraceTimeoutId:U=>a=U,setPointerGraceIntent:U=>l=U,registerNestedMenu:Q,registerItemToParentDomCollection:n?.registerItem,registerTriggerId:yn(u),registerContentId:yn(m)};return y(R,{get children(){return y(fs.Provider,{value:fm,get children(){return y(qd,T({anchorRef:f,contentRef:p,onCurrentPlacementChange:O},s))}})}})}const Yd=ce();function Xd(e){let t;const n=kt(),r=Et(),o=Le({id:n.generateId(`item-${Ae()}`)},e),[i,s]=j(o,["ref","textValue","disabled","closeOnSelect","checked","indeterminate","onSelect","onPointerMove","onPointerLeave","onPointerDown","onPointerUp","onClick","onKeyDown","onMouseDown","onFocus"]),[a,l]=P(),[c,d]=P(),[u,h]=P(),m=()=>r.listState().selectionManager(),f=()=>s.id,g=()=>m().focusedKey()===f(),p=()=>{i.onSelect?.(),i.closeOnSelect&&r.close(!0)};Uu({getItem:()=>({ref:()=>t,type:"item",key:f(),textValue:i.textValue??u()?.textContent??t?.textContent??"",disabled:i.disabled??!1})});const b=Pu({key:f,selectionManager:m,shouldSelectOnPressUp:!0,allowsDifferentPressOrigin:!0,disabled:()=>i.disabled},()=>t),v=_=>{ge(_,i.onPointerMove),_.pointerType==="mouse"&&(i.disabled?r.onItemLeave(_):(r.onItemEnter(_),_.defaultPrevented||(de(_.currentTarget),r.listState().selectionManager().setFocused(!0),r.listState().selectionManager().setFocusedKey(f()))))},w=_=>{ge(_,i.onPointerLeave),_.pointerType==="mouse"&&r.onItemLeave(_)},x=_=>{ge(_,i.onPointerUp),!i.disabled&&_.button===0&&p()},O=_=>{if(ge(_,i.onKeyDown),!_.repeat&&!i.disabled)switch(_.key){case"Enter":case" ":p();break}},k=C(()=>{if(i.indeterminate)return"mixed";if(i.checked!=null)return i.checked}),E=C(()=>({"data-indeterminate":i.indeterminate?"":void 0,"data-checked":i.checked&&!i.indeterminate?"":void 0,"data-disabled":i.disabled?"":void 0,"data-highlighted":g()?"":void 0})),$={isChecked:()=>i.checked,dataset:E,setLabelRef:h,generateId:ci(()=>s.id),registerLabel:yn(l),registerDescription:yn(d)};return y(Yd.Provider,{value:$,get children(){return y(bn,T({as:"div",ref(_){var R=ot(L=>t=L,i.ref);typeof R=="function"&&R(_)},get tabIndex(){return b.tabIndex()},get"aria-checked"(){return k()},get"aria-disabled"(){return i.disabled},get"aria-labelledby"(){return a()},get"aria-describedby"(){return c()},get"data-key"(){return b.dataKey()},get onPointerDown(){return we([i.onPointerDown,b.onPointerDown])},get onPointerUp(){return we([x,b.onPointerUp])},get onClick(){return we([i.onClick,b.onClick])},get onKeyDown(){return we([O,b.onKeyDown])},get onMouseDown(){return we([i.onMouseDown,b.onMouseDown])},get onFocus(){return we([i.onFocus,b.onFocus])},onPointerMove:v,onPointerLeave:w},E,s))}})}const Jd=ce();function ps(){return he(Jd)}function Zd(e){let t;const n=kt(),r=Et(),o=ps(),i=Le({id:n.generateId(`content-${Ae()}`)},e),[s,a]=j(i,["ref","id","style","onOpenAutoFocus","onCloseAutoFocus","onEscapeKeyDown","onFocusOutside","onPointerEnter","onPointerMove","onKeyDown","onMouseDown","onFocusIn","onFocusOut"]);let l=0;const c=()=>r.parentMenuContext()==null&&o===void 0&&n.isModal(),d=Lu({selectionManager:r.listState().selectionManager,collection:r.listState().collection,autoFocus:r.autoFocus,deferAutoFocus:!0,shouldFocusWrap:!0,disallowTypeAhead:()=>!r.listState().selectionManager().isFocused()},()=>t);iu({trapFocus:()=>c()&&r.isOpen(),onMountAutoFocus:p=>{o===void 0&&s.onOpenAutoFocus?.(p)},onUnmountAutoFocus:s.onCloseAutoFocus},()=>t);const u=p=>{if(De(p.currentTarget,p.target)&&(p.key==="Tab"&&r.isOpen()&&p.preventDefault(),o!==void 0&&p.currentTarget.getAttribute("aria-haspopup")!=="true"))switch(p.key){case"ArrowRight":p.stopPropagation(),p.preventDefault(),r.close(!0),o.setAutoFocusMenu(!0),o.nextMenu();break;case"ArrowLeft":if(p.currentTarget.hasAttribute("data-closed"))break;p.stopPropagation(),p.preventDefault(),r.close(!0),o.setAutoFocusMenu(!0),o.previousMenu();break}},h=p=>{s.onEscapeKeyDown?.(p),o?.setAutoFocusMenu(!1),r.close(!0)},m=p=>{s.onFocusOutside?.(p),n.isModal()&&p.preventDefault()},f=p=>{ge(p,s.onPointerEnter),r.isOpen()&&(r.parentMenuContext()?.listState().selectionManager().setFocused(!1),r.parentMenuContext()?.listState().selectionManager().setFocusedKey(void 0))},g=p=>{if(ge(p,s.onPointerMove),p.pointerType!=="mouse")return;const b=p.target,v=l!==p.clientX;De(p.currentTarget,b)&&v&&(r.setPointerDir(p.clientX>l?"right":"left"),l=p.clientX)};return D(()=>K(r.registerContentId(s.id))),y(Z,{get when(){return r.contentPresence.isPresent()},get children(){return y(td,{get children(){return y(Qu,T({ref(p){var b=ot(v=>{r.setContentRef(v),r.contentPresence.setRef(v),t=v},s.ref);typeof b=="function"&&b(p)},role:"menu",get id(){return s.id},get tabIndex(){return d.tabIndex()},get disableOutsidePointerEvents(){return C(()=>!!c())()&&r.isOpen()},get excludedElements(){return[r.triggerRef]},bypassTopMostLayerCheck:!0,get style(){return{"--kb-menu-content-transform-origin":"var(--kb-popper-content-transform-origin)",position:"relative",...s.style}},get"aria-labelledby"(){return r.triggerId()},onEscapeKeyDown:h,onFocusOutside:m,get onDismiss(){return r.close},get onKeyDown(){return we([s.onKeyDown,d.onKeyDown,u])},get onMouseDown(){return we([s.onMouseDown,d.onMouseDown])},get onFocusIn(){return we([s.onFocusIn,d.onFocusIn])},get onFocusOut(){return we([s.onFocusOut,d.onFocusOut])},onPointerEnter:f,onPointerMove:g},()=>r.dataset(),a))}})}})}function Qd(e){let t;const n=kt(),r=Et(),[o,i]=j(e,["ref"]);return Hi({element:()=>t??null,enabled:()=>r.isOpen()&&n.preventScroll()}),y(Zd,T({ref(s){var a=ot(l=>{t=l},o.ref);typeof a=="function"&&a(s)}},i))}function ef(e){return y(Xd,T({role:"menuitem",closeOnSelect:!0},e))}function tf(e){const t=Et();return y(Z,{get when(){return t.contentPresence.isPresent()},get children(){return y(qo,e)}})}function nf(e){const t=`menu-${Ae()}`,n=Le({id:t,modal:!0},e),[r,o]=j(n,["id","modal","preventScroll","forceMount","open","defaultOpen","onOpenChange","value"]),i=wi({open:()=>r.open,defaultOpen:()=>r.defaultOpen,onOpenChange:a=>r.onOpenChange?.(a)}),s={isModal:()=>r.modal??!0,preventScroll:()=>r.preventScroll??s.isModal(),forceMount:()=>r.forceMount??!1,generateId:ci(()=>r.id),value:()=>r.value};return y(gs.Provider,{value:s,get children(){return y(Gd,T({get open(){return i.isOpen()},get onOpenChange(){return i.setIsOpen}},o))}})}function rf(e){const t=kt(),n=Et(),r=ps(),o=Le({id:t.generateId("trigger")},e),[i,s]=j(o,["ref","id","disabled","onPointerDown","onClick","onKeyDown","onMouseOver","onFocus"]);let a;r!==void 0&&(a=t.value()??i.id,D(()=>{r.registerMenu(a,[n.contentRef(),...n.nestedMenus()])}),D(()=>{r.value()===a?(n.triggerRef()?.focus(),r.autoFocusMenu()&&n.open(!0)):n.close(!0)}),D(()=>{n.isOpen()&&r.setValue(a)}),K(()=>{r.unregisterMenu(a)}),r.lastValue()===void 0&&r.setLastValue(a));const l=()=>{r?.setAutoFocusMenu(!0),r!==void 0?n.toggle(!1):n.toggle(!0),r!==void 0&&!n.isOpen()&&r.value()===a&&r.closeMenu()},c=f=>{ge(f,i.onPointerDown),f.currentTarget.dataset.pointerType=f.pointerType,!i.disabled&&f.pointerType!=="touch"&&f.button===0&&l()},d=f=>{ge(f,i.onClick),i.disabled||f.currentTarget.dataset.pointerType==="touch"&&l()},u=f=>{if(ge(f,i.onKeyDown),!i.disabled)switch(f.key){case"Enter":case" ":case"ArrowDown":f.stopPropagation(),f.preventDefault(),Hc(f.currentTarget),n.toggle("first");break;case"ArrowUp":f.stopPropagation(),f.preventDefault(),n.toggle("last");break;case"ArrowRight":if(r===void 0)break;f.stopPropagation(),f.preventDefault(),r.nextMenu();break;case"ArrowLeft":if(r===void 0)break;f.stopPropagation(),f.preventDefault(),r.previousMenu();break}},h=f=>{ge(f,i.onMouseOver),!i.disabled&&r!==void 0&&r.value()!==void 0&&r.setValue(a)},m=f=>{ge(f,i.onFocus),r!==void 0&&r.setValue(a)};return D(()=>K(n.registerTriggerId(i.id))),y(Ru,T({ref(f){var g=ot(n.setTriggerRef,i.ref);typeof g=="function"&&g(f)},get id(){return i.id},get disabled(){return i.disabled},"aria-haspopup":"true",get"aria-expanded"(){return n.isOpen()},get"aria-controls"(){return C(()=>!!n.isOpen())()?n.contentId():void 0},get"data-highlighted"(){return a!==void 0&&r?.value()===a?!0:void 0},get tabIndex(){return r!==void 0?r.value()===a||r.lastValue()===a?0:-1:void 0},onPointerDown:c,onMouseOver:h,onClick:d,onKeyDown:u,onFocus:m,role:r!==void 0?"menuitem":void 0},()=>n.dataset(),s))}function of(e){const t=kt(),n=Et(),[r,o]=j(e,["onCloseAutoFocus","onInteractOutside"]);let i=!1;return y(Qd,T({onCloseAutoFocus:l=>{r.onCloseAutoFocus?.(l),i||de(n.triggerRef()),i=!1,l.preventDefault()},onInteractOutside:l=>{r.onInteractOutside?.(l),(!t.isModal()||l.detail.isContextMenu)&&(i=!0)}},o))}function sf(e){const t=`dropdownmenu-${Ae()}`,n=Le({id:t},e);return y(nf,n)}function af(e){return ve({a:{xmlns:"http://www.w3.org/2000/svg",class:"icon icon-tabler icon-tabler-circle-check-filled",width:"24",height:"24",viewBox:"0 0 24 24","stroke-width":"2",stroke:"currentColor",fill:"none","stroke-linecap":"round","stroke-linejoin":"round"},c:'<path stroke="none" d="M0 0h24v24H0z" fill="none"/><path d="M17 3.34a10 10 0 1 1 -14.995 8.984l-.005 -.324l.005 -.324a10 10 0 0 1 14.995 -8.336zm-1.293 5.953a1 1 0 0 0 -1.32 -.083l-.094 .083l-3.293 3.292l-1.293 -1.292l-.094 -.083a1 1 0 0 0 -1.403 1.403l.083 .094l2 2l.094 .083a1 1 0 0 0 1.226 0l.094 -.083l4 -4l.083 -.094a1 1 0 0 0 -.083 -1.32z" stroke-width="0" fill="currentColor"/>'},e)}function lf(e){return ve({a:{xmlns:"http://www.w3.org/2000/svg",class:"icon icon-tabler icon-tabler-circle",width:"24",height:"24",viewBox:"0 0 24 24","stroke-width":"2",stroke:"currentColor",fill:"none","stroke-linecap":"round","stroke-linejoin":"round"},c:'<path stroke="none" d="M0 0h24v24H0z" fill="none"/><path d="M12 12m-9 0a9 9 0 1 0 18 0a9 9 0 1 0 -18 0"/>'},e)}function cf(e){return ve({a:{xmlns:"http://www.w3.org/2000/svg",class:"icon icon-tabler icon-tabler-file-download",width:"24",height:"24",viewBox:"0 0 24 24","stroke-width":"2",stroke:"currentColor",fill:"none","stroke-linecap":"round","stroke-linejoin":"round"},c:'<path stroke="none" d="M0 0h24v24H0z" fill="none"/><path d="M14 3v4a1 1 0 0 0 1 1h4"/><path d="M17 21h-10a2 2 0 0 1 -2 -2v-14a2 2 0 0 1 2 -2h7l5 5v11a2 2 0 0 1 -2 2z"/><path d="M12 17v-6"/><path d="M9.5 14.5l2.5 2.5l2.5 -2.5"/>'},e)}const uf=e=>y(sf,T({gutter:4},e)),df=rf,ff=e=>{const[,t]=j(e,["class"]);return y(tf,{get mount(){return Wn()},get children(){return y(of,T({get class(){return Ge("z-50 min-w-[8rem] origin-[var(--kb-menu-content-transform-origin)] animate-content-hide overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md data-[expanded]:animate-content-show",e.class)}},t))}})},hf=e=>{const[,t]=j(e,["class"]);return y(ef,T({get class(){return Ge("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e.class)}},t))};function gf(e){return e.type==="buttons"&&e.buttons.options.length>10?{list:{text:e.buttons.text,options:[{items:e.buttons.options}]},type:"list",origin:e.origin,createdAt:e.createdAt}:e}function pf(e){if(Array.isArray(e)){console.info("----------------------------------------------------------");for(const t of e)console.info("Executed:",t.type),console.info(t)}}async function mf(e,t,n){const r=`${Jt}/v1/messages`,o={credentials:"include",method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({channelId:n,postback:t,type:"text",text:e})};await fetch(r,o)}async function yf(e,t,n){if(!e||!t||!n)return;const r=`${Jt}/v1/widget/${e}/restart`,o={credentials:"include",method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({contactId:t,interactionId:n})};await fetch(r,o)}const $e=Object.create(null);$e.open="0",$e.close="1",$e.ping="2",$e.pong="3",$e.message="4",$e.upgrade="5",$e.noop="6";const _n=Object.create(null);Object.keys($e).forEach(e=>{_n[$e[e]]=e});const Fr={type:"error",data:"parser error"},ms=typeof Blob=="function"||typeof Blob<"u"&&Object.prototype.toString.call(Blob)==="[object BlobConstructor]",ys=typeof ArrayBuffer=="function",bs=e=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(e):e&&e.buffer instanceof ArrayBuffer,Nr=({type:e,data:t},n,r)=>ms&&t instanceof Blob?n?r(t):vs(t,r):ys&&(t instanceof ArrayBuffer||bs(t))?n?r(t):vs(new Blob([t]),r):r($e[e]+(t||"")),vs=(e,t)=>{const n=new FileReader;return n.onload=function(){const r=n.result.split(",")[1];t("b"+(r||""))},n.readAsDataURL(e)};function ws(e){return e instanceof Uint8Array?e:e instanceof ArrayBuffer?new Uint8Array(e):new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}let Kr;function bf(e,t){if(ms&&e.data instanceof Blob)return e.data.arrayBuffer().then(ws).then(t);if(ys&&(e.data instanceof ArrayBuffer||bs(e.data)))return t(ws(e.data));Nr(e,!1,n=>{Kr||(Kr=new TextEncoder),t(Kr.encode(n))})}const xs="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Wt=typeof Uint8Array>"u"?[]:new Uint8Array(256);for(let e=0;e<xs.length;e++)Wt[xs.charCodeAt(e)]=e;const vf=e=>{let t=e.length*.75,n=e.length,r,o=0,i,s,a,l;e[e.length-1]==="="&&(t--,e[e.length-2]==="="&&t--);const c=new ArrayBuffer(t),d=new Uint8Array(c);for(r=0;r<n;r+=4)i=Wt[e.charCodeAt(r)],s=Wt[e.charCodeAt(r+1)],a=Wt[e.charCodeAt(r+2)],l=Wt[e.charCodeAt(r+3)],d[o++]=i<<2|s>>4,d[o++]=(s&15)<<4|a>>2,d[o++]=(a&3)<<6|l&63;return c},wf=typeof ArrayBuffer=="function",Br=(e,t)=>{if(typeof e!="string")return{type:"message",data:Ss(e,t)};const n=e.charAt(0);return n==="b"?{type:"message",data:xf(e.substring(1),t)}:_n[n]?e.length>1?{type:_n[n],data:e.substring(1)}:{type:_n[n]}:Fr},xf=(e,t)=>{if(wf){const n=vf(e);return Ss(n,t)}else return{base64:!0,data:e}},Ss=(e,t)=>{switch(t){case"blob":return e instanceof Blob?e:new Blob([e]);case"arraybuffer":default:return e instanceof ArrayBuffer?e:e.buffer}},Es="",Sf=(e,t)=>{const n=e.length,r=new Array(n);let o=0;e.forEach((i,s)=>{Nr(i,!1,a=>{r[s]=a,++o===n&&t(r.join(Es))})})},Ef=(e,t)=>{const n=e.split(Es),r=[];for(let o=0;o<n.length;o++){const i=Br(n[o],t);if(r.push(i),i.type==="error")break}return r};function kf(){return new TransformStream({transform(e,t){bf(e,n=>{const r=n.length;let o;if(r<126)o=new Uint8Array(1),new DataView(o.buffer).setUint8(0,r);else if(r<65536){o=new Uint8Array(3);const i=new DataView(o.buffer);i.setUint8(0,126),i.setUint16(1,r)}else{o=new Uint8Array(9);const i=new DataView(o.buffer);i.setUint8(0,127),i.setBigUint64(1,BigInt(r))}e.data&&typeof e.data!="string"&&(o[0]|=128),t.enqueue(o),t.enqueue(n)})}})}let zr;function Pn(e){return e.reduce((t,n)=>t+n.length,0)}function An(e,t){if(e[0].length===t)return e.shift();const n=new Uint8Array(t);let r=0;for(let o=0;o<t;o++)n[o]=e[0][r++],r===e[0].length&&(e.shift(),r=0);return e.length&&r<e[0].length&&(e[0]=e[0].slice(r)),n}function Cf(e,t){zr||(zr=new TextDecoder);const n=[];let r=0,o=-1,i=!1;return new TransformStream({transform(s,a){for(n.push(s);;){if(r===0){if(Pn(n)<1)break;const l=An(n,1);i=(l[0]&128)===128,o=l[0]&127,o<126?r=3:o===126?r=1:r=2}else if(r===1){if(Pn(n)<2)break;const l=An(n,2);o=new DataView(l.buffer,l.byteOffset,l.length).getUint16(0),r=3}else if(r===2){if(Pn(n)<8)break;const l=An(n,8),c=new DataView(l.buffer,l.byteOffset,l.length),d=c.getUint32(0);if(d>Math.pow(2,21)-1){a.enqueue(Fr);break}o=d*Math.pow(2,32)+c.getUint32(4),r=3}else{if(Pn(n)<o)break;const l=An(n,o);a.enqueue(Br(i?l:zr.decode(l),t)),r=0}if(o===0||o>e){a.enqueue(Fr);break}}}})}const ks=4;function te(e){if(e)return Of(e)}function Of(e){for(var t in te.prototype)e[t]=te.prototype[t];return e}te.prototype.on=te.prototype.addEventListener=function(e,t){return this._callbacks=this._callbacks||{},(this._callbacks["$"+e]=this._callbacks["$"+e]||[]).push(t),this},te.prototype.once=function(e,t){function n(){this.off(e,n),t.apply(this,arguments)}return n.fn=t,this.on(e,n),this},te.prototype.off=te.prototype.removeListener=te.prototype.removeAllListeners=te.prototype.removeEventListener=function(e,t){if(this._callbacks=this._callbacks||{},arguments.length==0)return this._callbacks={},this;var n=this._callbacks["$"+e];if(!n)return this;if(arguments.length==1)return delete this._callbacks["$"+e],this;for(var r,o=0;o<n.length;o++)if(r=n[o],r===t||r.fn===t){n.splice(o,1);break}return n.length===0&&delete this._callbacks["$"+e],this},te.prototype.emit=function(e){this._callbacks=this._callbacks||{};for(var t=new Array(arguments.length-1),n=this._callbacks["$"+e],r=1;r<arguments.length;r++)t[r-1]=arguments[r];if(n){n=n.slice(0);for(var r=0,o=n.length;r<o;++r)n[r].apply(this,t)}return this},te.prototype.emitReserved=te.prototype.emit,te.prototype.listeners=function(e){return this._callbacks=this._callbacks||{},this._callbacks["$"+e]||[]},te.prototype.hasListeners=function(e){return!!this.listeners(e).length};const Tn=typeof Promise=="function"&&typeof Promise.resolve=="function"?t=>Promise.resolve().then(t):(t,n)=>n(t,0),Se=typeof self<"u"?self:typeof window<"u"?window:Function("return this")(),_f="arraybuffer";function mm(){}function Cs(e,...t){return t.reduce((n,r)=>(e.hasOwnProperty(r)&&(n[r]=e[r]),n),{})}const Pf=Se.setTimeout,Af=Se.clearTimeout;function Dn(e,t){t.useNativeTimers?(e.setTimeoutFn=Pf.bind(Se),e.clearTimeoutFn=Af.bind(Se)):(e.setTimeoutFn=Se.setTimeout.bind(Se),e.clearTimeoutFn=Se.clearTimeout.bind(Se))}const Tf=1.33;function Df(e){return typeof e=="string"?Lf(e):Math.ceil((e.byteLength||e.size)*Tf)}function Lf(e){let t=0,n=0;for(let r=0,o=e.length;r<o;r++)t=e.charCodeAt(r),t<128?n+=1:t<2048?n+=2:t<55296||t>=57344?n+=3:(r++,n+=4);return n}function Os(){return Date.now().toString(36).substring(3)+Math.random().toString(36).substring(2,5)}function Mf(e){let t="";for(let n in e)e.hasOwnProperty(n)&&(t.length&&(t+="&"),t+=encodeURIComponent(n)+"="+encodeURIComponent(e[n]));return t}function If(e){let t={},n=e.split("&");for(let r=0,o=n.length;r<o;r++){let i=n[r].split("=");t[decodeURIComponent(i[0])]=decodeURIComponent(i[1])}return t}class Rf extends Error{constructor(t,n,r){super(t),this.description=n,this.context=r,this.type="TransportError"}}class Vr extends te{constructor(t){super(),this.writable=!1,Dn(this,t),this.opts=t,this.query=t.query,this.socket=t.socket,this.supportsBinary=!t.forceBase64}onError(t,n,r){return super.emitReserved("error",new Rf(t,n,r)),this}open(){return this.readyState="opening",this.doOpen(),this}close(){return(this.readyState==="opening"||this.readyState==="open")&&(this.doClose(),this.onClose()),this}send(t){this.readyState==="open"&&this.write(t)}onOpen(){this.readyState="open",this.writable=!0,super.emitReserved("open")}onData(t){const n=Br(t,this.socket.binaryType);this.onPacket(n)}onPacket(t){super.emitReserved("packet",t)}onClose(t){this.readyState="closed",super.emitReserved("close",t)}pause(t){}createUri(t,n={}){return t+"://"+this._hostname()+this._port()+this.opts.path+this._query(n)}_hostname(){const t=this.opts.hostname;return t.indexOf(":")===-1?t:"["+t+"]"}_port(){return this.opts.port&&(this.opts.secure&&+(this.opts.port!==443)||!this.opts.secure&&Number(this.opts.port)!==80)?":"+this.opts.port:""}_query(t){const n=Mf(t);return n.length?"?"+n:""}}class $f extends Vr{constructor(){super(...arguments),this._polling=!1}get name(){return"polling"}doOpen(){this._poll()}pause(t){this.readyState="pausing";const n=()=>{this.readyState="paused",t()};if(this._polling||!this.writable){let r=0;this._polling&&(r++,this.once("pollComplete",function(){--r||n()})),this.writable||(r++,this.once("drain",function(){--r||n()}))}else n()}_poll(){this._polling=!0,this.doPoll(),this.emitReserved("poll")}onData(t){const n=r=>{if(this.readyState==="opening"&&r.type==="open"&&this.onOpen(),r.type==="close")return this.onClose({description:"transport closed by the server"}),!1;this.onPacket(r)};Ef(t,this.socket.binaryType).forEach(n),this.readyState!=="closed"&&(this._polling=!1,this.emitReserved("pollComplete"),this.readyState==="open"&&this._poll())}doClose(){const t=()=>{this.write([{type:"close"}])};this.readyState==="open"?t():this.once("open",t)}write(t){this.writable=!1,Sf(t,n=>{this.doWrite(n,()=>{this.writable=!0,this.emitReserved("drain")})})}uri(){const t=this.opts.secure?"https":"http",n=this.query||{};return this.opts.timestampRequests!==!1&&(n[this.opts.timestampParam]=Os()),!this.supportsBinary&&!n.sid&&(n.b64=1),this.createUri(t,n)}}let _s=!1;try{_s=typeof XMLHttpRequest<"u"&&"withCredentials"in new XMLHttpRequest}catch{}const Ff=_s;function Nf(){}class Kf extends $f{constructor(t){if(super(t),typeof location<"u"){const n=location.protocol==="https:";let r=location.port;r||(r=n?"443":"80"),this.xd=typeof location<"u"&&t.hostname!==location.hostname||r!==t.port}}doWrite(t,n){const r=this.request({method:"POST",data:t});r.on("success",n),r.on("error",(o,i)=>{this.onError("xhr post error",o,i)})}doPoll(){const t=this.request();t.on("data",this.onData.bind(this)),t.on("error",(n,r)=>{this.onError("xhr poll error",n,r)}),this.pollXhr=t}}class Fe extends te{constructor(t,n,r){super(),this.createRequest=t,Dn(this,r),this._opts=r,this._method=r.method||"GET",this._uri=n,this._data=r.data!==void 0?r.data:null,this._create()}_create(){var t;const n=Cs(this._opts,"agent","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","autoUnref");n.xdomain=!!this._opts.xd;const r=this._xhr=this.createRequest(n);try{r.open(this._method,this._uri,!0);try{if(this._opts.extraHeaders){r.setDisableHeaderCheck&&r.setDisableHeaderCheck(!0);for(let o in this._opts.extraHeaders)this._opts.extraHeaders.hasOwnProperty(o)&&r.setRequestHeader(o,this._opts.extraHeaders[o])}}catch{}if(this._method==="POST")try{r.setRequestHeader("Content-type","text/plain;charset=UTF-8")}catch{}try{r.setRequestHeader("Accept","*/*")}catch{}(t=this._opts.cookieJar)===null||t===void 0||t.addCookies(r),"withCredentials"in r&&(r.withCredentials=this._opts.withCredentials),this._opts.requestTimeout&&(r.timeout=this._opts.requestTimeout),r.onreadystatechange=()=>{var o;r.readyState===3&&((o=this._opts.cookieJar)===null||o===void 0||o.parseCookies(r.getResponseHeader("set-cookie"))),r.readyState===4&&(r.status===200||r.status===1223?this._onLoad():this.setTimeoutFn(()=>{this._onError(typeof r.status=="number"?r.status:0)},0))},r.send(this._data)}catch(o){this.setTimeoutFn(()=>{this._onError(o)},0);return}typeof document<"u"&&(this._index=Fe.requestsCount++,Fe.requests[this._index]=this)}_onError(t){this.emitReserved("error",t,this._xhr),this._cleanup(!0)}_cleanup(t){if(!(typeof this._xhr>"u"||this._xhr===null)){if(this._xhr.onreadystatechange=Nf,t)try{this._xhr.abort()}catch{}typeof document<"u"&&delete Fe.requests[this._index],this._xhr=null}}_onLoad(){const t=this._xhr.responseText;t!==null&&(this.emitReserved("data",t),this.emitReserved("success"),this._cleanup())}abort(){this._cleanup()}}if(Fe.requestsCount=0,Fe.requests={},typeof document<"u"){if(typeof attachEvent=="function")attachEvent("onunload",Ps);else if(typeof addEventListener=="function"){const e="onpagehide"in Se?"pagehide":"unload";addEventListener(e,Ps,!1)}}function Ps(){for(let e in Fe.requests)Fe.requests.hasOwnProperty(e)&&Fe.requests[e].abort()}const Bf=function(){const e=As({xdomain:!1});return e&&e.responseType!==null}();class zf extends Kf{constructor(t){super(t);const n=t&&t.forceBase64;this.supportsBinary=Bf&&!n}request(t={}){return Object.assign(t,{xd:this.xd},this.opts),new Fe(As,this.uri(),t)}}function As(e){const t=e.xdomain;try{if(typeof XMLHttpRequest<"u"&&(!t||Ff))return new XMLHttpRequest}catch{}if(!t)try{return new Se[["Active"].concat("Object").join("X")]("Microsoft.XMLHTTP")}catch{}}const Ts=typeof navigator<"u"&&typeof navigator.product=="string"&&navigator.product.toLowerCase()==="reactnative";class Vf extends Vr{get name(){return"websocket"}doOpen(){const t=this.uri(),n=this.opts.protocols,r=Ts?{}:Cs(this.opts,"agent","perMessageDeflate","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","localAddress","protocolVersion","origin","maxPayload","family","checkServerIdentity");this.opts.extraHeaders&&(r.headers=this.opts.extraHeaders);try{this.ws=this.createSocket(t,n,r)}catch(o){return this.emitReserved("error",o)}this.ws.binaryType=this.socket.binaryType,this.addEventListeners()}addEventListeners(){this.ws.onopen=()=>{this.opts.autoUnref&&this.ws._socket.unref(),this.onOpen()},this.ws.onclose=t=>this.onClose({description:"websocket connection closed",context:t}),this.ws.onmessage=t=>this.onData(t.data),this.ws.onerror=t=>this.onError("websocket error",t)}write(t){this.writable=!1;for(let n=0;n<t.length;n++){const r=t[n],o=n===t.length-1;Nr(r,this.supportsBinary,i=>{try{this.doWrite(r,i)}catch{}o&&Tn(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){typeof this.ws<"u"&&(this.ws.onerror=()=>{},this.ws.close(),this.ws=null)}uri(){const t=this.opts.secure?"wss":"ws",n=this.query||{};return this.opts.timestampRequests&&(n[this.opts.timestampParam]=Os()),this.supportsBinary||(n.b64=1),this.createUri(t,n)}}const Ur=Se.WebSocket||Se.MozWebSocket;class Uf extends Vf{createSocket(t,n,r){return Ts?new Ur(t,n,r):n?new Ur(t,n):new Ur(t)}doWrite(t,n){this.ws.send(n)}}class jf extends Vr{get name(){return"webtransport"}doOpen(){try{this._transport=new WebTransport(this.createUri("https"),this.opts.transportOptions[this.name])}catch(t){return this.emitReserved("error",t)}this._transport.closed.then(()=>{this.onClose()}).catch(t=>{this.onError("webtransport error",t)}),this._transport.ready.then(()=>{this._transport.createBidirectionalStream().then(t=>{const n=Cf(Number.MAX_SAFE_INTEGER,this.socket.binaryType),r=t.readable.pipeThrough(n).getReader(),o=kf();o.readable.pipeTo(t.writable),this._writer=o.writable.getWriter();const i=()=>{r.read().then(({done:a,value:l})=>{a||(this.onPacket(l),i())}).catch(a=>{})};i();const s={type:"open"};this.query.sid&&(s.data=`{"sid":"${this.query.sid}"}`),this._writer.write(s).then(()=>this.onOpen())})})}write(t){this.writable=!1;for(let n=0;n<t.length;n++){const r=t[n],o=n===t.length-1;this._writer.write(r).then(()=>{o&&Tn(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){var t;(t=this._transport)===null||t===void 0||t.close()}}const Hf={websocket:Uf,webtransport:jf,polling:zf},qf=/^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,Wf=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"];function jr(e){if(e.length>8e3)throw"URI too long";const t=e,n=e.indexOf("["),r=e.indexOf("]");n!=-1&&r!=-1&&(e=e.substring(0,n)+e.substring(n,r).replace(/:/g,";")+e.substring(r,e.length));let o=qf.exec(e||""),i={},s=14;for(;s--;)i[Wf[s]]=o[s]||"";return n!=-1&&r!=-1&&(i.source=t,i.host=i.host.substring(1,i.host.length-1).replace(/;/g,":"),i.authority=i.authority.replace("[","").replace("]","").replace(/;/g,":"),i.ipv6uri=!0),i.pathNames=Gf(i,i.path),i.queryKey=Yf(i,i.query),i}function Gf(e,t){const n=/\/{2,9}/g,r=t.replace(n,"/").split("/");return(t.slice(0,1)=="/"||t.length===0)&&r.splice(0,1),t.slice(-1)=="/"&&r.splice(r.length-1,1),r}function Yf(e,t){const n={};return t.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,function(r,o,i){o&&(n[o]=i)}),n}const Hr=typeof addEventListener=="function"&&typeof removeEventListener=="function",Ln=[];Hr&&addEventListener("offline",()=>{Ln.forEach(e=>e())},!1);class Ze extends te{constructor(t,n){if(super(),this.binaryType=_f,this.writeBuffer=[],this._prevBufferLen=0,this._pingInterval=-1,this._pingTimeout=-1,this._maxPayload=-1,this._pingTimeoutTime=1/0,t&&typeof t=="object"&&(n=t,t=null),t){const r=jr(t);n.hostname=r.host,n.secure=r.protocol==="https"||r.protocol==="wss",n.port=r.port,r.query&&(n.query=r.query)}else n.host&&(n.hostname=jr(n.host).host);Dn(this,n),this.secure=n.secure!=null?n.secure:typeof location<"u"&&location.protocol==="https:",n.hostname&&!n.port&&(n.port=this.secure?"443":"80"),this.hostname=n.hostname||(typeof location<"u"?location.hostname:"localhost"),this.port=n.port||(typeof location<"u"&&location.port?location.port:this.secure?"443":"80"),this.transports=[],this._transportsByName={},n.transports.forEach(r=>{const o=r.prototype.name;this.transports.push(o),this._transportsByName[o]=r}),this.opts=Object.assign({path:"/engine.io",agent:!1,withCredentials:!1,upgrade:!0,timestampParam:"t",rememberUpgrade:!1,addTrailingSlash:!0,rejectUnauthorized:!0,perMessageDeflate:{threshold:1024},transportOptions:{},closeOnBeforeunload:!1},n),this.opts.path=this.opts.path.replace(/\/$/,"")+(this.opts.addTrailingSlash?"/":""),typeof this.opts.query=="string"&&(this.opts.query=If(this.opts.query)),Hr&&(this.opts.closeOnBeforeunload&&(this._beforeunloadEventListener=()=>{this.transport&&(this.transport.removeAllListeners(),this.transport.close())},addEventListener("beforeunload",this._beforeunloadEventListener,!1)),this.hostname!=="localhost"&&(this._offlineEventListener=()=>{this._onClose("transport close",{description:"network connection lost"})},Ln.push(this._offlineEventListener))),this.opts.withCredentials&&(this._cookieJar=void 0),this._open()}createTransport(t){const n=Object.assign({},this.opts.query);n.EIO=ks,n.transport=t,this.id&&(n.sid=this.id);const r=Object.assign({},this.opts,{query:n,socket:this,hostname:this.hostname,secure:this.secure,port:this.port},this.opts.transportOptions[t]);return new this._transportsByName[t](r)}_open(){if(this.transports.length===0){this.setTimeoutFn(()=>{this.emitReserved("error","No transports available")},0);return}const t=this.opts.rememberUpgrade&&Ze.priorWebsocketSuccess&&this.transports.indexOf("websocket")!==-1?"websocket":this.transports[0];this.readyState="opening";const n=this.createTransport(t);n.open(),this.setTransport(n)}setTransport(t){this.transport&&this.transport.removeAllListeners(),this.transport=t,t.on("drain",this._onDrain.bind(this)).on("packet",this._onPacket.bind(this)).on("error",this._onError.bind(this)).on("close",n=>this._onClose("transport close",n))}onOpen(){this.readyState="open",Ze.priorWebsocketSuccess=this.transport.name==="websocket",this.emitReserved("open"),this.flush()}_onPacket(t){if(this.readyState==="opening"||this.readyState==="open"||this.readyState==="closing")switch(this.emitReserved("packet",t),this.emitReserved("heartbeat"),t.type){case"open":this.onHandshake(JSON.parse(t.data));break;case"ping":this._sendPacket("pong"),this.emitReserved("ping"),this.emitReserved("pong"),this._resetPingTimeout();break;case"error":const n=new Error("server error");n.code=t.data,this._onError(n);break;case"message":this.emitReserved("data",t.data),this.emitReserved("message",t.data);break}}onHandshake(t){this.emitReserved("handshake",t),this.id=t.sid,this.transport.query.sid=t.sid,this._pingInterval=t.pingInterval,this._pingTimeout=t.pingTimeout,this._maxPayload=t.maxPayload,this.onOpen(),this.readyState!=="closed"&&this._resetPingTimeout()}_resetPingTimeout(){this.clearTimeoutFn(this._pingTimeoutTimer);const t=this._pingInterval+this._pingTimeout;this._pingTimeoutTime=Date.now()+t,this._pingTimeoutTimer=this.setTimeoutFn(()=>{this._onClose("ping timeout")},t),this.opts.autoUnref&&this._pingTimeoutTimer.unref()}_onDrain(){this.writeBuffer.splice(0,this._prevBufferLen),this._prevBufferLen=0,this.writeBuffer.length===0?this.emitReserved("drain"):this.flush()}flush(){if(this.readyState!=="closed"&&this.transport.writable&&!this.upgrading&&this.writeBuffer.length){const t=this._getWritablePackets();this.transport.send(t),this._prevBufferLen=t.length,this.emitReserved("flush")}}_getWritablePackets(){if(!(this._maxPayload&&this.transport.name==="polling"&&this.writeBuffer.length>1))return this.writeBuffer;let n=1;for(let r=0;r<this.writeBuffer.length;r++){const o=this.writeBuffer[r].data;if(o&&(n+=Df(o)),r>0&&n>this._maxPayload)return this.writeBuffer.slice(0,r);n+=2}return this.writeBuffer}_hasPingExpired(){if(!this._pingTimeoutTime)return!0;const t=Date.now()>this._pingTimeoutTime;return t&&(this._pingTimeoutTime=0,Tn(()=>{this._onClose("ping timeout")},this.setTimeoutFn)),t}write(t,n,r){return this._sendPacket("message",t,n,r),this}send(t,n,r){return this._sendPacket("message",t,n,r),this}_sendPacket(t,n,r,o){if(typeof n=="function"&&(o=n,n=void 0),typeof r=="function"&&(o=r,r=null),this.readyState==="closing"||this.readyState==="closed")return;r=r||{},r.compress=r.compress!==!1;const i={type:t,data:n,options:r};this.emitReserved("packetCreate",i),this.writeBuffer.push(i),o&&this.once("flush",o),this.flush()}close(){const t=()=>{this._onClose("forced close"),this.transport.close()},n=()=>{this.off("upgrade",n),this.off("upgradeError",n),t()},r=()=>{this.once("upgrade",n),this.once("upgradeError",n)};return(this.readyState==="opening"||this.readyState==="open")&&(this.readyState="closing",this.writeBuffer.length?this.once("drain",()=>{this.upgrading?r():t()}):this.upgrading?r():t()),this}_onError(t){if(Ze.priorWebsocketSuccess=!1,this.opts.tryAllTransports&&this.transports.length>1&&this.readyState==="opening")return this.transports.shift(),this._open();this.emitReserved("error",t),this._onClose("transport error",t)}_onClose(t,n){if(this.readyState==="opening"||this.readyState==="open"||this.readyState==="closing"){if(this.clearTimeoutFn(this._pingTimeoutTimer),this.transport.removeAllListeners("close"),this.transport.close(),this.transport.removeAllListeners(),Hr&&(this._beforeunloadEventListener&&removeEventListener("beforeunload",this._beforeunloadEventListener,!1),this._offlineEventListener)){const r=Ln.indexOf(this._offlineEventListener);r!==-1&&Ln.splice(r,1)}this.readyState="closed",this.id=null,this.emitReserved("close",t,n),this.writeBuffer=[],this._prevBufferLen=0}}}Ze.protocol=ks;class Xf extends Ze{constructor(){super(...arguments),this._upgrades=[]}onOpen(){if(super.onOpen(),this.readyState==="open"&&this.opts.upgrade)for(let t=0;t<this._upgrades.length;t++)this._probe(this._upgrades[t])}_probe(t){let n=this.createTransport(t),r=!1;Ze.priorWebsocketSuccess=!1;const o=()=>{r||(n.send([{type:"ping",data:"probe"}]),n.once("packet",u=>{if(!r)if(u.type==="pong"&&u.data==="probe"){if(this.upgrading=!0,this.emitReserved("upgrading",n),!n)return;Ze.priorWebsocketSuccess=n.name==="websocket",this.transport.pause(()=>{r||this.readyState!=="closed"&&(d(),this.setTransport(n),n.send([{type:"upgrade"}]),this.emitReserved("upgrade",n),n=null,this.upgrading=!1,this.flush())})}else{const h=new Error("probe error");h.transport=n.name,this.emitReserved("upgradeError",h)}}))};function i(){r||(r=!0,d(),n.close(),n=null)}const s=u=>{const h=new Error("probe error: "+u);h.transport=n.name,i(),this.emitReserved("upgradeError",h)};function a(){s("transport closed")}function l(){s("socket closed")}function c(u){n&&u.name!==n.name&&i()}const d=()=>{n.removeListener("open",o),n.removeListener("error",s),n.removeListener("close",a),this.off("close",l),this.off("upgrading",c)};n.once("open",o),n.once("error",s),n.once("close",a),this.once("close",l),this.once("upgrading",c),this._upgrades.indexOf("webtransport")!==-1&&t!=="webtransport"?this.setTimeoutFn(()=>{r||n.open()},200):n.open()}onHandshake(t){this._upgrades=this._filterUpgrades(t.upgrades),super.onHandshake(t)}_filterUpgrades(t){const n=[];for(let r=0;r<t.length;r++)~this.transports.indexOf(t[r])&&n.push(t[r]);return n}}let Jf=class extends Xf{constructor(t,n={}){const r=typeof t=="object"?t:n;(!r.transports||r.transports&&typeof r.transports[0]=="string")&&(r.transports=(r.transports||["polling","websocket","webtransport"]).map(o=>Hf[o]).filter(o=>!!o)),super(t,r)}};function Zf(e,t="",n){let r=e;n=n||typeof location<"u"&&location,e==null&&(e=n.protocol+"//"+n.host),typeof e=="string"&&(e.charAt(0)==="/"&&(e.charAt(1)==="/"?e=n.protocol+e:e=n.host+e),/^(https?|wss?):\/\//.test(e)||(typeof n<"u"?e=n.protocol+"//"+e:e="https://"+e),r=jr(e)),r.port||(/^(http|ws)$/.test(r.protocol)?r.port="80":/^(http|ws)s$/.test(r.protocol)&&(r.port="443")),r.path=r.path||"/";const i=r.host.indexOf(":")!==-1?"["+r.host+"]":r.host;return r.id=r.protocol+"://"+i+":"+r.port+t,r.href=r.protocol+"://"+i+(n&&n.port===r.port?"":":"+r.port),r}const Qf=typeof ArrayBuffer=="function",eh=e=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(e):e.buffer instanceof ArrayBuffer,Ds=Object.prototype.toString,th=typeof Blob=="function"||typeof Blob<"u"&&Ds.call(Blob)==="[object BlobConstructor]",nh=typeof File=="function"||typeof File<"u"&&Ds.call(File)==="[object FileConstructor]";function qr(e){return Qf&&(e instanceof ArrayBuffer||eh(e))||th&&e instanceof Blob||nh&&e instanceof File}function Mn(e,t){if(!e||typeof e!="object")return!1;if(Array.isArray(e)){for(let n=0,r=e.length;n<r;n++)if(Mn(e[n]))return!0;return!1}if(qr(e))return!0;if(e.toJSON&&typeof e.toJSON=="function"&&arguments.length===1)return Mn(e.toJSON(),!0);for(const n in e)if(Object.prototype.hasOwnProperty.call(e,n)&&Mn(e[n]))return!0;return!1}function rh(e){const t=[],n=e.data,r=e;return r.data=Wr(n,t),r.attachments=t.length,{packet:r,buffers:t}}function Wr(e,t){if(!e)return e;if(qr(e)){const n={_placeholder:!0,num:t.length};return t.push(e),n}else if(Array.isArray(e)){const n=new Array(e.length);for(let r=0;r<e.length;r++)n[r]=Wr(e[r],t);return n}else if(typeof e=="object"&&!(e instanceof Date)){const n={};for(const r in e)Object.prototype.hasOwnProperty.call(e,r)&&(n[r]=Wr(e[r],t));return n}return e}function oh(e,t){return e.data=Gr(e.data,t),delete e.attachments,e}function Gr(e,t){if(!e)return e;if(e&&e._placeholder===!0){if(typeof e.num=="number"&&e.num>=0&&e.num<t.length)return t[e.num];throw new Error("illegal attachments")}else if(Array.isArray(e))for(let n=0;n<e.length;n++)e[n]=Gr(e[n],t);else if(typeof e=="object")for(const n in e)Object.prototype.hasOwnProperty.call(e,n)&&(e[n]=Gr(e[n],t));return e}const ih=["connect","connect_error","disconnect","disconnecting","newListener","removeListener"],sh=5;var z;(function(e){e[e.CONNECT=0]="CONNECT",e[e.DISCONNECT=1]="DISCONNECT",e[e.EVENT=2]="EVENT",e[e.ACK=3]="ACK",e[e.CONNECT_ERROR=4]="CONNECT_ERROR",e[e.BINARY_EVENT=5]="BINARY_EVENT",e[e.BINARY_ACK=6]="BINARY_ACK"})(z||(z={}));class ah{constructor(t){this.replacer=t}encode(t){return(t.type===z.EVENT||t.type===z.ACK)&&Mn(t)?this.encodeAsBinary({type:t.type===z.EVENT?z.BINARY_EVENT:z.BINARY_ACK,nsp:t.nsp,data:t.data,id:t.id}):[this.encodeAsString(t)]}encodeAsString(t){let n=""+t.type;return(t.type===z.BINARY_EVENT||t.type===z.BINARY_ACK)&&(n+=t.attachments+"-"),t.nsp&&t.nsp!=="/"&&(n+=t.nsp+","),t.id!=null&&(n+=t.id),t.data!=null&&(n+=JSON.stringify(t.data,this.replacer)),n}encodeAsBinary(t){const n=rh(t),r=this.encodeAsString(n.packet),o=n.buffers;return o.unshift(r),o}}function Ls(e){return Object.prototype.toString.call(e)==="[object Object]"}class Yr extends te{constructor(t){super(),this.reviver=t}add(t){let n;if(typeof t=="string"){if(this.reconstructor)throw new Error("got plaintext data when reconstructing a packet");n=this.decodeString(t);const r=n.type===z.BINARY_EVENT;r||n.type===z.BINARY_ACK?(n.type=r?z.EVENT:z.ACK,this.reconstructor=new lh(n),n.attachments===0&&super.emitReserved("decoded",n)):super.emitReserved("decoded",n)}else if(qr(t)||t.base64)if(this.reconstructor)n=this.reconstructor.takeBinaryData(t),n&&(this.reconstructor=null,super.emitReserved("decoded",n));else throw new Error("got binary data when not reconstructing a packet");else throw new Error("Unknown type: "+t)}decodeString(t){let n=0;const r={type:Number(t.charAt(0))};if(z[r.type]===void 0)throw new Error("unknown packet type "+r.type);if(r.type===z.BINARY_EVENT||r.type===z.BINARY_ACK){const i=n+1;for(;t.charAt(++n)!=="-"&&n!=t.length;);const s=t.substring(i,n);if(s!=Number(s)||t.charAt(n)!=="-")throw new Error("Illegal attachments");r.attachments=Number(s)}if(t.charAt(n+1)==="/"){const i=n+1;for(;++n&&!(t.charAt(n)===","||n===t.length););r.nsp=t.substring(i,n)}else r.nsp="/";const o=t.charAt(n+1);if(o!==""&&Number(o)==o){const i=n+1;for(;++n;){const s=t.charAt(n);if(s==null||Number(s)!=s){--n;break}if(n===t.length)break}r.id=Number(t.substring(i,n+1))}if(t.charAt(++n)){const i=this.tryParse(t.substr(n));if(Yr.isPayloadValid(r.type,i))r.data=i;else throw new Error("invalid payload")}return r}tryParse(t){try{return JSON.parse(t,this.reviver)}catch{return!1}}static isPayloadValid(t,n){switch(t){case z.CONNECT:return Ls(n);case z.DISCONNECT:return n===void 0;case z.CONNECT_ERROR:return typeof n=="string"||Ls(n);case z.EVENT:case z.BINARY_EVENT:return Array.isArray(n)&&(typeof n[0]=="number"||typeof n[0]=="string"&&ih.indexOf(n[0])===-1);case z.ACK:case z.BINARY_ACK:return Array.isArray(n)}}destroy(){this.reconstructor&&(this.reconstructor.finishedReconstruction(),this.reconstructor=null)}}class lh{constructor(t){this.packet=t,this.buffers=[],this.reconPack=t}takeBinaryData(t){if(this.buffers.push(t),this.buffers.length===this.reconPack.attachments){const n=oh(this.reconPack,this.buffers);return this.finishedReconstruction(),n}return null}finishedReconstruction(){this.reconPack=null,this.buffers=[]}}const ch=Object.freeze(Object.defineProperty({__proto__:null,Decoder:Yr,Encoder:ah,get PacketType(){return z},protocol:sh},Symbol.toStringTag,{value:"Module"}));function _e(e,t,n){return e.on(t,n),function(){e.off(t,n)}}const uh=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1});class Ms extends te{constructor(t,n,r){super(),this.connected=!1,this.recovered=!1,this.receiveBuffer=[],this.sendBuffer=[],this._queue=[],this._queueSeq=0,this.ids=0,this.acks={},this.flags={},this.io=t,this.nsp=n,r&&r.auth&&(this.auth=r.auth),this._opts=Object.assign({},r),this.io._autoConnect&&this.open()}get disconnected(){return!this.connected}subEvents(){if(this.subs)return;const t=this.io;this.subs=[_e(t,"open",this.onopen.bind(this)),_e(t,"packet",this.onpacket.bind(this)),_e(t,"error",this.onerror.bind(this)),_e(t,"close",this.onclose.bind(this))]}get active(){return!!this.subs}connect(){return this.connected?this:(this.subEvents(),this.io._reconnecting||this.io.open(),this.io._readyState==="open"&&this.onopen(),this)}open(){return this.connect()}send(...t){return t.unshift("message"),this.emit.apply(this,t),this}emit(t,...n){var r,o,i;if(uh.hasOwnProperty(t))throw new Error('"'+t.toString()+'" is a reserved event name');if(n.unshift(t),this._opts.retries&&!this.flags.fromQueue&&!this.flags.volatile)return this._addToQueue(n),this;const s={type:z.EVENT,data:n};if(s.options={},s.options.compress=this.flags.compress!==!1,typeof n[n.length-1]=="function"){const d=this.ids++,u=n.pop();this._registerAckCallback(d,u),s.id=d}const a=(o=(r=this.io.engine)===null||r===void 0?void 0:r.transport)===null||o===void 0?void 0:o.writable,l=this.connected&&!(!((i=this.io.engine)===null||i===void 0)&&i._hasPingExpired());return this.flags.volatile&&!a||(l?(this.notifyOutgoingListeners(s),this.packet(s)):this.sendBuffer.push(s)),this.flags={},this}_registerAckCallback(t,n){var r;const o=(r=this.flags.timeout)!==null&&r!==void 0?r:this._opts.ackTimeout;if(o===void 0){this.acks[t]=n;return}const i=this.io.setTimeoutFn(()=>{delete this.acks[t];for(let a=0;a<this.sendBuffer.length;a++)this.sendBuffer[a].id===t&&this.sendBuffer.splice(a,1);n.call(this,new Error("operation has timed out"))},o),s=(...a)=>{this.io.clearTimeoutFn(i),n.apply(this,a)};s.withError=!0,this.acks[t]=s}emitWithAck(t,...n){return new Promise((r,o)=>{const i=(s,a)=>s?o(s):r(a);i.withError=!0,n.push(i),this.emit(t,...n)})}_addToQueue(t){let n;typeof t[t.length-1]=="function"&&(n=t.pop());const r={id:this._queueSeq++,tryCount:0,pending:!1,args:t,flags:Object.assign({fromQueue:!0},this.flags)};t.push((o,...i)=>r!==this._queue[0]?void 0:(o!==null?r.tryCount>this._opts.retries&&(this._queue.shift(),n&&n(o)):(this._queue.shift(),n&&n(null,...i)),r.pending=!1,this._drainQueue())),this._queue.push(r),this._drainQueue()}_drainQueue(t=!1){if(!this.connected||this._queue.length===0)return;const n=this._queue[0];n.pending&&!t||(n.pending=!0,n.tryCount++,this.flags=n.flags,this.emit.apply(this,n.args))}packet(t){t.nsp=this.nsp,this.io._packet(t)}onopen(){typeof this.auth=="function"?this.auth(t=>{this._sendConnectPacket(t)}):this._sendConnectPacket(this.auth)}_sendConnectPacket(t){this.packet({type:z.CONNECT,data:this._pid?Object.assign({pid:this._pid,offset:this._lastOffset},t):t})}onerror(t){this.connected||this.emitReserved("connect_error",t)}onclose(t,n){this.connected=!1,delete this.id,this.emitReserved("disconnect",t,n),this._clearAcks()}_clearAcks(){Object.keys(this.acks).forEach(t=>{if(!this.sendBuffer.some(r=>String(r.id)===t)){const r=this.acks[t];delete this.acks[t],r.withError&&r.call(this,new Error("socket has been disconnected"))}})}onpacket(t){if(t.nsp===this.nsp)switch(t.type){case z.CONNECT:t.data&&t.data.sid?this.onconnect(t.data.sid,t.data.pid):this.emitReserved("connect_error",new Error("It seems you are trying to reach a Socket.IO server in v2.x with a v3.x client, but they are not compatible (more information here: https://socket.io/docs/v3/migrating-from-2-x-to-3-0/)"));break;case z.EVENT:case z.BINARY_EVENT:this.onevent(t);break;case z.ACK:case z.BINARY_ACK:this.onack(t);break;case z.DISCONNECT:this.ondisconnect();break;case z.CONNECT_ERROR:this.destroy();const r=new Error(t.data.message);r.data=t.data.data,this.emitReserved("connect_error",r);break}}onevent(t){const n=t.data||[];t.id!=null&&n.push(this.ack(t.id)),this.connected?this.emitEvent(n):this.receiveBuffer.push(Object.freeze(n))}emitEvent(t){if(this._anyListeners&&this._anyListeners.length){const n=this._anyListeners.slice();for(const r of n)r.apply(this,t)}super.emit.apply(this,t),this._pid&&t.length&&typeof t[t.length-1]=="string"&&(this._lastOffset=t[t.length-1])}ack(t){const n=this;let r=!1;return function(...o){r||(r=!0,n.packet({type:z.ACK,id:t,data:o}))}}onack(t){const n=this.acks[t.id];typeof n=="function"&&(delete this.acks[t.id],n.withError&&t.data.unshift(null),n.apply(this,t.data))}onconnect(t,n){this.id=t,this.recovered=n&&this._pid===n,this._pid=n,this.connected=!0,this.emitBuffered(),this.emitReserved("connect"),this._drainQueue(!0)}emitBuffered(){this.receiveBuffer.forEach(t=>this.emitEvent(t)),this.receiveBuffer=[],this.sendBuffer.forEach(t=>{this.notifyOutgoingListeners(t),this.packet(t)}),this.sendBuffer=[]}ondisconnect(){this.destroy(),this.onclose("io server disconnect")}destroy(){this.subs&&(this.subs.forEach(t=>t()),this.subs=void 0),this.io._destroy(this)}disconnect(){return this.connected&&this.packet({type:z.DISCONNECT}),this.destroy(),this.connected&&this.onclose("io client disconnect"),this}close(){return this.disconnect()}compress(t){return this.flags.compress=t,this}get volatile(){return this.flags.volatile=!0,this}timeout(t){return this.flags.timeout=t,this}onAny(t){return this._anyListeners=this._anyListeners||[],this._anyListeners.push(t),this}prependAny(t){return this._anyListeners=this._anyListeners||[],this._anyListeners.unshift(t),this}offAny(t){if(!this._anyListeners)return this;if(t){const n=this._anyListeners;for(let r=0;r<n.length;r++)if(t===n[r])return n.splice(r,1),this}else this._anyListeners=[];return this}listenersAny(){return this._anyListeners||[]}onAnyOutgoing(t){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.push(t),this}prependAnyOutgoing(t){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.unshift(t),this}offAnyOutgoing(t){if(!this._anyOutgoingListeners)return this;if(t){const n=this._anyOutgoingListeners;for(let r=0;r<n.length;r++)if(t===n[r])return n.splice(r,1),this}else this._anyOutgoingListeners=[];return this}listenersAnyOutgoing(){return this._anyOutgoingListeners||[]}notifyOutgoingListeners(t){if(this._anyOutgoingListeners&&this._anyOutgoingListeners.length){const n=this._anyOutgoingListeners.slice();for(const r of n)r.apply(this,t.data)}}}function Ct(e){e=e||{},this.ms=e.min||100,this.max=e.max||1e4,this.factor=e.factor||2,this.jitter=e.jitter>0&&e.jitter<=1?e.jitter:0,this.attempts=0}Ct.prototype.duration=function(){var e=this.ms*Math.pow(this.factor,this.attempts++);if(this.jitter){var t=Math.random(),n=Math.floor(t*this.jitter*e);e=Math.floor(t*10)&1?e+n:e-n}return Math.min(e,this.max)|0},Ct.prototype.reset=function(){this.attempts=0},Ct.prototype.setMin=function(e){this.ms=e},Ct.prototype.setMax=function(e){this.max=e},Ct.prototype.setJitter=function(e){this.jitter=e};class Xr extends te{constructor(t,n){var r;super(),this.nsps={},this.subs=[],t&&typeof t=="object"&&(n=t,t=void 0),n=n||{},n.path=n.path||"/socket.io",this.opts=n,Dn(this,n),this.reconnection(n.reconnection!==!1),this.reconnectionAttempts(n.reconnectionAttempts||1/0),this.reconnectionDelay(n.reconnectionDelay||1e3),this.reconnectionDelayMax(n.reconnectionDelayMax||5e3),this.randomizationFactor((r=n.randomizationFactor)!==null&&r!==void 0?r:.5),this.backoff=new Ct({min:this.reconnectionDelay(),max:this.reconnectionDelayMax(),jitter:this.randomizationFactor()}),this.timeout(n.timeout==null?2e4:n.timeout),this._readyState="closed",this.uri=t;const o=n.parser||ch;this.encoder=new o.Encoder,this.decoder=new o.Decoder,this._autoConnect=n.autoConnect!==!1,this._autoConnect&&this.open()}reconnection(t){return arguments.length?(this._reconnection=!!t,t||(this.skipReconnect=!0),this):this._reconnection}reconnectionAttempts(t){return t===void 0?this._reconnectionAttempts:(this._reconnectionAttempts=t,this)}reconnectionDelay(t){var n;return t===void 0?this._reconnectionDelay:(this._reconnectionDelay=t,(n=this.backoff)===null||n===void 0||n.setMin(t),this)}randomizationFactor(t){var n;return t===void 0?this._randomizationFactor:(this._randomizationFactor=t,(n=this.backoff)===null||n===void 0||n.setJitter(t),this)}reconnectionDelayMax(t){var n;return t===void 0?this._reconnectionDelayMax:(this._reconnectionDelayMax=t,(n=this.backoff)===null||n===void 0||n.setMax(t),this)}timeout(t){return arguments.length?(this._timeout=t,this):this._timeout}maybeReconnectOnOpen(){!this._reconnecting&&this._reconnection&&this.backoff.attempts===0&&this.reconnect()}open(t){if(~this._readyState.indexOf("open"))return this;this.engine=new Jf(this.uri,this.opts);const n=this.engine,r=this;this._readyState="opening",this.skipReconnect=!1;const o=_e(n,"open",function(){r.onopen(),t&&t()}),i=a=>{this.cleanup(),this._readyState="closed",this.emitReserved("error",a),t?t(a):this.maybeReconnectOnOpen()},s=_e(n,"error",i);if(this._timeout!==!1){const a=this._timeout,l=this.setTimeoutFn(()=>{o(),i(new Error("timeout")),n.close()},a);this.opts.autoUnref&&l.unref(),this.subs.push(()=>{this.clearTimeoutFn(l)})}return this.subs.push(o),this.subs.push(s),this}connect(t){return this.open(t)}onopen(){this.cleanup(),this._readyState="open",this.emitReserved("open");const t=this.engine;this.subs.push(_e(t,"ping",this.onping.bind(this)),_e(t,"data",this.ondata.bind(this)),_e(t,"error",this.onerror.bind(this)),_e(t,"close",this.onclose.bind(this)),_e(this.decoder,"decoded",this.ondecoded.bind(this)))}onping(){this.emitReserved("ping")}ondata(t){try{this.decoder.add(t)}catch(n){this.onclose("parse error",n)}}ondecoded(t){Tn(()=>{this.emitReserved("packet",t)},this.setTimeoutFn)}onerror(t){this.emitReserved("error",t)}socket(t,n){let r=this.nsps[t];return r?this._autoConnect&&!r.active&&r.connect():(r=new Ms(this,t,n),this.nsps[t]=r),r}_destroy(t){const n=Object.keys(this.nsps);for(const r of n)if(this.nsps[r].active)return;this._close()}_packet(t){const n=this.encoder.encode(t);for(let r=0;r<n.length;r++)this.engine.write(n[r],t.options)}cleanup(){this.subs.forEach(t=>t()),this.subs.length=0,this.decoder.destroy()}_close(){this.skipReconnect=!0,this._reconnecting=!1,this.onclose("forced close")}disconnect(){return this._close()}onclose(t,n){var r;this.cleanup(),(r=this.engine)===null||r===void 0||r.close(),this.backoff.reset(),this._readyState="closed",this.emitReserved("close",t,n),this._reconnection&&!this.skipReconnect&&this.reconnect()}reconnect(){if(this._reconnecting||this.skipReconnect)return this;const t=this;if(this.backoff.attempts>=this._reconnectionAttempts)this.backoff.reset(),this.emitReserved("reconnect_failed"),this._reconnecting=!1;else{const n=this.backoff.duration();this._reconnecting=!0;const r=this.setTimeoutFn(()=>{t.skipReconnect||(this.emitReserved("reconnect_attempt",t.backoff.attempts),!t.skipReconnect&&t.open(o=>{o?(t._reconnecting=!1,t.reconnect(),this.emitReserved("reconnect_error",o)):t.onreconnect()}))},n);this.opts.autoUnref&&r.unref(),this.subs.push(()=>{this.clearTimeoutFn(r)})}}onreconnect(){const t=this.backoff.attempts;this._reconnecting=!1,this.backoff.reset(),this.emitReserved("reconnect",t)}}const Gt={};function In(e,t){typeof e=="object"&&(t=e,e=void 0),t=t||{};const n=Zf(e,t.path||"/socket.io"),r=n.source,o=n.id,i=n.path,s=Gt[o]&&i in Gt[o].nsps,a=t.forceNew||t["force new connection"]||t.multiplex===!1||s;let l;return a?l=new Xr(r,t):(Gt[o]||(Gt[o]=new Xr(r,t)),l=Gt[o]),n.query&&!t.query&&(t.query=n.queryKey),l.socket(n.path,t)}Object.assign(In,{Manager:Xr,Socket:Ms,io:In,connect:In});class lt{static instance;constructor(){}static init(){return lt.instance||(lt.instance=In(za,{path:"/ws",withCredentials:!0}),lt.instance.on("connect",()=>{console.info("SmartTalks.ai widget connected!")})),lt.instance}static on(t,n){lt.instance||this.init().on(t,n)}}const Is=1e3*60*60*24,[Rn,Rs]=ti("smarttalks-widget-messages",{},Is),$s=()=>{const{widgetId:e}=oe();return Rn[e()]??[]},dh=e=>{const{widgetId:t}=oe();Rs({...Rn,[t()]:[...Rn[t()]??[],e]})},fh=()=>{const{widgetId:e}=oe();Rs({...Rn,[e()]:[]})},[Fs,hh]=ti("smarttalks-widget-conversationinfo",{},Is),Ns=()=>{const{widgetId:e}=oe();return Fs[e()]??{}},Ks=e=>{const{widgetId:t}=oe();hh({...Fs,[t()]:e})},[gh,Jr]=P(!1),[ph,Bs]=P(!1),zs=[],Vs=()=>{zs.forEach(e=>e())},mh=e=>zs.push(e),Zr=e=>{const t=gf(e);if(dh(t),t.type==="media"){setTimeout(Vs,200);return}Vs()},yh=(e,t)=>{const{chatWidget:n}=oe(),r=Ns();e.trim()&&(Zr({text:e,type:"text",origin:"user",createdAt:new Date().toString()}),ee("onInput",e),lt.on("message",o=>{(o.contactId!==r.contactId||o.interactionId!==r.interactionId)&&Ks({contactId:o.contactId,interactionId:o.interactionId});for(const i of o.messages)Zr(i),ee("onAnswer",i);Jr(!1),pf(o.debug)}),Jr(!0),mf(e,t,n()?._id).catch(o=>{console.error(o),Jr(!1)}))},bh=()=>{const{chatWidget:e}=oe(),t=Ns();Bs(!0),fh(),yf(e()?._id,t.contactId,t.interactionId).finally(()=>{Ks({}),Bs(!1),vh()}),ee("onReset")},vh=()=>{const{chatWidget:e}=oe();if($s().length===0&&e()?.balloonMessage){const n=e()?.balloonMessage;n&&Zr({text:n,type:"text",origin:"bot",createdAt:new Date().toString()})}},Qe=()=>({getMessages:$s,pushMessage:yh,clearMessages:bh,onMessage:mh,typing:gh,loading:ph});var wh=M("<span>");const xh=()=>{const{clearMessages:e}=Qe();P(!1);const[t,n]=P(!1);return y(uf,{get open(){return t()},onOpenChange:n,get children(){return[y(df,{get children(){return y(Te,{variant:"ghost",size:"icon",class:"hover:bg-accent/10 hover:text-primary-foreground",get children(){return y(fc,{size:20})}})}}),y(ff,{get children(){return y(hf,{class:"flex space-x-2 items-center cursor-pointer",onSelect:e,get children(){return[y(dc,{size:14}),(()=>{var r=wh();return A(r,()=>dt("restart")),r})()]}})}})]}})};function Sh(e){return ve({a:{fill:"currentColor",viewBox:"0 0 16 16"},c:'<path d="M5.5 0a.5.5 0 0 1 .5.5v4A1.5 1.5 0 0 1 4.5 6h-4a.5.5 0 0 1 0-1h4a.5.5 0 0 0 .5-.5v-4a.5.5 0 0 1 .5-.5zm5 0a.5.5 0 0 1 .5.5v4a.5.5 0 0 0 .5.5h4a.5.5 0 0 1 0 1h-4A1.5 1.5 0 0 1 10 4.5v-4a.5.5 0 0 1 .5-.5zM0 10.5a.5.5 0 0 1 .5-.5h4A1.5 1.5 0 0 1 6 11.5v4a.5.5 0 0 1-1 0v-4a.5.5 0 0 0-.5-.5h-4a.5.5 0 0 1-.5-.5zm10 1a1.5 1.5 0 0 1 1.5-1.5h4a.5.5 0 0 1 0 1h-4a.5.5 0 0 0-.5.5v4a.5.5 0 0 1-1 0v-4z"/>'},e)}function Eh(e){return ve({a:{fill:"currentColor",viewBox:"0 0 16 16"},c:'<path d="M1.5 1a.5.5 0 0 0-.5.5v4a.5.5 0 0 1-1 0v-4A1.5 1.5 0 0 1 1.5 0h4a.5.5 0 0 1 0 1h-4zM10 .5a.5.5 0 0 1 .5-.5h4A1.5 1.5 0 0 1 16 1.5v4a.5.5 0 0 1-1 0v-4a.5.5 0 0 0-.5-.5h-4a.5.5 0 0 1-.5-.5zM.5 10a.5.5 0 0 1 .5.5v4a.5.5 0 0 0 .5.5h4a.5.5 0 0 1 0 1h-4A1.5 1.5 0 0 1 0 14.5v-4a.5.5 0 0 1 .5-.5zm15 0a.5.5 0 0 1 .5.5v4a1.5 1.5 0 0 1-1.5 1.5h-4a.5.5 0 0 1 0-1h4a.5.5 0 0 0 .5-.5v-4a.5.5 0 0 1 .5-.5z"/>'},e)}function kh(e){return ve({a:{fill:"currentColor",viewBox:"0 0 16 16"},c:'<path d="M2.146 2.854a.5.5 0 1 1 .708-.708L8 7.293l5.146-5.147a.5.5 0 0 1 .708.708L8.707 8l5.147 5.146a.5.5 0 0 1-.708.708L8 8.707l-5.146 5.147a.5.5 0 0 1-.708-.708L7.293 8 2.146 2.854Z"/>'},e)}var Ch=M('<header class="flex-none bg-primary text-primary-foreground p-3 flex items-center justify-between space-x-4"><div class="flex items-center gap-0.5">');const Qr=()=>{const{chatWidget:e}=oe(),[t,n]=P(!1),r=()=>{try{const i=Wn();i&&(t()?document.exitFullscreen().then(()=>n(!1)):i.requestFullscreen().then(()=>n(!0)))}catch{console.error("SmartTalks.ai Widget unable to toggle fullscreen in the current state.")}};document.addEventListener("fullscreenchange",()=>{document.fullscreenElement||n(!1)});const o=()=>{e()?.mode==="popup"&&ee("close")};return se("toggleFullscreen",()=>{r()}),(()=>{var i=Ch(),s=i.firstChild;return A(i,y(cc,{}),s),A(s,y(Te,{size:"icon",variant:"ghost",class:"hover:bg-accent/10 hover:text-primary-foreground",onClick:r,get children(){return y(Z,{get when(){return t()},get fallback(){return y(Eh,{size:16})},get children(){return y(Sh,{size:16})}})}}),null),A(s,y(Z,{get when(){return e()?.showSettings},get children(){return y(xh,{})}}),null),A(s,y(Z,{get when(){return e()?.mode==="popup"},get children(){return y(Te,{size:"icon",variant:"ghost",class:"hover:bg-accent/10 hover:text-primary-foreground",onClick:o,get children(){return y(kh,{size:16})}})}}),null),i})()};var Oh=M("<span>");const Us=({createdAt:e,anchor:t="end"})=>(()=>{var n=Oh();return gt(n,`${t==="end"?"self-end":"self-start"} pt-1 text-[10px] italic font-light text-slate-600`),A(n,()=>new Date(e).toLocaleString([],{hour:"2-digit",minute:"2-digit"})),n})();var _h=M('<div class="place-self-start py-1 flex flex-col"><div class="bg-white shadow-md py-2 px-4 rounded-r-xl rounded-tl-xl">');const Ph=({children:e,createdAt:t})=>(()=>{var n=_h(),r=n.firstChild;return A(r,e),A(n,y(Us,{createdAt:t,anchor:"start"}),null),n})();var Ah=M("<span>");const Ot=e=>{const[,t]=j(e,["class","children"]);let n=e.children?.toString();return n&&(n=Na(Ka(n))),(()=>{var r=Ah();return r.innerHTML=n,tt(r,T({get class(){return Ge("whitespace-pre-line",e.class)}},t),!1,!1),r})()};var Th=M('<div class="flex flex-col space-y-2"><div><div class="flex p-1 flex-wrap items-center justify-center">');const Dh=({options:e,text:t})=>{let n;const{pushMessage:r}=Qe(),[o,i]=P(!1),s=(a,l)=>{i(!0),r(a,l)};return(()=>{var a=Th(),l=a.firstChild,c=l.firstChild;A(a,y(Ot,{get children(){return t?.trim()}}),l);var d=n;return typeof d=="function"?ir(d,c):n=c,A(c,y(ht,{each:e,children:u=>y(Te,{variant:"outline",get disabled(){return o()},class:"px-2 ml-1 mb-1 py-0 text-nowrap",onClick:()=>s(u.label,u.value),get children(){return u.label?.trim()}})})),re(()=>gt(l,`flex items-center justify-center max-w-80 mx-[-1rem] ${o()&&"opacity-50"}`)),a})()};var Lh=M('<div class="flex flex-col"><span>'),Mh=M("<a target=_blank><img><span></span><span>");const Ih=({options:e,text:t})=>(()=>{var n=Lh(),r=n.firstChild;return A(r,()=>t?.trim()),A(n,y(ht,{each:e,children:o=>(()=>{var i=Mh(),s=i.firstChild,a=s.nextSibling,l=a.nextSibling;return A(a,()=>o.title?.trim()),A(l,()=>o.description?.trim()),re(c=>{var d=o.url,u=o.image;return d!==c.e&&ue(i,"href",c.e=d),u!==c.t&&ue(s,"src",c.t=u),c},{e:void 0,t:void 0}),i})()}),null),n})();var Rh=M("<a target=_blank>");const $h=({url:e,text:t})=>(()=>{var n=Rh();return ue(n,"href",e),A(n,()=>t?.trim()),n})();var G=e=>typeof e=="function"?e():e,js=e=>requestAnimationFrame(()=>requestAnimationFrame(e)),Fh=e=>{const t=T({initialRegistered:!1},e),[n,r]=P(t.initialRegistered);return[C(()=>{if(n())return G(t.value)}),()=>{r(!0)},()=>{r(!1)}]},Hs=Fh,Yt=e=>typeof e=="function",Nh=["button","color","file","image","reset","submit"],Kh=(e,t)=>e==="button"?!0:e==="input"&&t?Nh.indexOf(t)!==-1:!1;function Bh(e){const[t,n]=P(e.initialValue),r=()=>e.value?.()!==void 0,o=()=>r()?e.value?.():t();return[o,s=>q(()=>{let a;return Yt(s)?a=s(o()):a=s,Object.is(a,o())||(r()||n(a),e.onChange?.(a)),a})]}var eo=Bh,$n=new Map,Fn=(e,t)=>{if($n.has(e))return $n.get(e);const n=ce(t);return $n.set(e,n),n},to=e=>{const t=$n.get(e);if(t)return he(t)},Nn=new Map,zh=e=>{D(()=>{const t=G(e.style)??{},n=G(e.properties)??[],r={};for(const i in t)r[i]=e.element.style[i];const o=Nn.get(e.key);o?o.activeCount++:Nn.set(e.key,{activeCount:1,originalStyles:r,properties:n.map(i=>i.key)}),Object.assign(e.element.style,e.style);for(const i of n)e.element.style.setProperty(i.key,i.value);K(()=>{const i=Nn.get(e.key);if(i){if(i.activeCount!==1){i.activeCount--;return}Nn.delete(e.key);for(const[s,a]of Object.entries(i.originalStyles))e.element.style[s]=a;for(const s of i.properties)e.element.style.removeProperty(s);e.element.style.length===0&&e.element.removeAttribute("style"),e.cleanup?.()}})})},Vh=zh,Uh=e=>{const t=T({enabled:!0},e);D(()=>{G(t.enabled)&&(document.addEventListener("keydown",n),K(()=>{document.removeEventListener("keydown",n)}))});const n=r=>{r.key==="Escape"&&t.onEscapeKeyDown(r)}},jh=Uh,Hh=e=>{const t=T({enabled:!0},e);D(()=>{const{body:n}=document;G(t.enabled)&&Vh({key:"no-pointer-events",element:n,style:{pointerEvents:"none"}})})},qh=Hh,Wh=e=>{const t=T({enabled:!0,strategy:"pointerup"},e);D(()=>{if(!G(t.enabled))return;const r=G(t.strategy);document.addEventListener(r,n),K(()=>{document.removeEventListener(r,n)})});const n=r=>{const o=G(t.element),i=G(t.ignore);o&&!o.contains(r.target)&&!(i&&i.contains(r.target))&&t.onPointer(r)}},Gh=Wh,Yh=e=>{const t=T({dismissOnEscapeKeyDown:!0,dismissOnOutsidePointer:!0,closeOnOutsidePointerStrategy:"pointerup",noOutsidePointerEvents:!0},e);jh({enabled:t.dismissOnEscapeKeyDown,onEscapeKeyDown:n=>{t.onEscapeKeyDown?.(n),n.defaultPrevented||t.onDismiss("escapeKey")}}),Gh({enabled:t.dismissOnOutsidePointer,strategy:t.closeOnOutsidePointerStrategy,ignore:t.dismissOnOutsidePointerIgnore,onPointer:n=>{if(t.onOutsidePointer?.(n),!n.defaultPrevented){const r=n.button===0&&n.ctrlKey===!0;if(n.button===2||r)return;t.onDismiss("pointerOutside")}},element:t.element}),qh({enabled:t.noOutsidePointerEvents})},Xh=Yh,no=ce(),Jh=e=>C(()=>{if(he(no))return y(qs,e);const r=Ae(),[o,i]=P([r]),s=l=>{i(c=>[...c,l])},a=l=>{i(c=>c.filter(d=>d!==l))};return y(no.Provider,{value:{layers:o,onLayerShow:s,onLayerDismiss:a},get children(){return y(qs,e)}})}),qs=e=>{const t=T({enabled:!0,dismissOnEscapeKeyDown:!0,dismissOnOutsidePointer:!0,dismissOnOutsidePointerStrategy:"pointerup",noOutsidePointerEvents:!0},e),[n,r]=j(t,["enabled","children","dismissOnEscapeKeyDown","dismissOnOutsidePointer","dismissOnOutsidePointerStrategy","dismissOnOutsidePointerIgnore","noOutsidePointerEvents","onDismiss"]),o=he(no),i=Ae();D(()=>{n.enabled?o.onLayerShow(i):o.onLayerDismiss(i)});const s=()=>o.layers()[o.layers().length-1]===i;Xh({dismissOnEscapeKeyDown:()=>G(n.dismissOnEscapeKeyDown)&&s()&&n.enabled,dismissOnOutsidePointer:()=>G(n.dismissOnOutsidePointer)&&s()&&n.enabled,dismissOnOutsidePointerStrategy:n.dismissOnOutsidePointerStrategy,dismissOnOutsidePointerIgnore:n.dismissOnOutsidePointerIgnore,noOutsidePointerEvents:()=>G(n.noOutsidePointerEvents)&&n.enabled,onDismiss:c=>{n.onDismiss(c)},...r});const a=C(()=>n.children),l=()=>{const c=a();return Yt(c)?c({get isLastLayer(){return s()}}):c};return q(()=>l())},Zh=Jh,Qh=()=>{const[e,t]=P(!1);return D(()=>t(!0)),e},eg=Qh,tg=(e,t)=>(e&&(Yt(e)?e(t):e[0](e[1],t)),t.defaultPrevented),ro=(...e)=>e.some(t=>!!t()),ng=e=>(...t)=>{for(const n of e)n&&n(...t)},Kn=(...e)=>ng(e),le=e=>e?"":void 0,rg="div",og=e=>{const[t,n]=j(e,["as"]),r=C(()=>t.as??rg);return C(()=>{const i=r();switch(typeof i){case"function":return q(()=>i(n));case"string":return y(ln,T({component:i},n))}})},oo=og,ig=e=>{let t,n=!1;return()=>n?t:(n=!0,t=C(e))},Ws=ig,sg=e=>C(()=>G(e.element)?.tagName.toLowerCase()||e.fallback),ag=sg,Gs="button",lg=e=>{const[t,n]=P(null),[r,o]=j(e,["as","ref","type"]),i=ag({element:t,fallback:Gs}),s=C(()=>Kh(i(),r.type));return y(oo,T({get as(){return r.as??Gs},ref(a){var l=Kn(n,r.ref);typeof l=="function"&&l(a)},get type(){return s()?"button":void 0},get role(){return s()?void 0:"button"}},o))},cg=lg,ug='a[href]:not([tabindex="-1"]), button:not([tabindex="-1"]), input:not([tabindex="-1"]), textarea:not([tabindex="-1"]), select:not([tabindex="-1"]), details:not([tabindex="-1"]), [tabindex]:not([tabindex="-1"])',io="focusTrap.initialFocus",so="focusTrap.finalFocus",Ys={bubbles:!1,cancelable:!0},dg=e=>{const t=T({enabled:!0,observeChanges:!0,restoreFocus:!0},e),[n,r]=P(null),o=C(()=>{const f=n();return f?f[0]??null:null}),i=C(()=>{const f=n();return f?f[f.length-1]??null:null});let s=null;const a=()=>{Cr(()=>{l(J(t.element)),(document.activeElement===null||document.activeElement===document.body)&&c(J(t.element))})};D(()=>{const f=J(t.element);if(f&&J(t.enabled)){s=document.activeElement,q(()=>{l(f),c(f)});const g=new MutationObserver(a);J(t.observeChanges)&&g.observe(f,{subtree:!0,childList:!0,attributes:!0,attributeFilter:["tabindex"]}),K(()=>{J(t.observeChanges)&&g.disconnect(),r(null),m(f)})}}),D(()=>{const f=n();f===null||f.length!==0||(document.addEventListener("keydown",h),K(()=>{document.removeEventListener("keydown",h)}))}),D(()=>{const f=o();f&&(f.addEventListener("keydown",d),K(()=>{f.removeEventListener("keydown",d)}))}),D(()=>{const f=i();f&&(f.addEventListener("keydown",u),K(()=>{f.removeEventListener("keydown",u)}))});const l=f=>{const g=Array.from(f.querySelectorAll(ug)).map((p,b)=>({element:p,domIndex:b,tabIndex:p.tabIndex})).sort((p,b)=>p.tabIndex===b.tabIndex?p.domIndex-b.domIndex:p.tabIndex-b.tabIndex);r(g.map(({element:p})=>p))},c=f=>{Cr(()=>{const g=J(t.initialFocusElement)??o()??f,p=t.onInitialFocus;let b;p&&(b=new CustomEvent(io,Ys),f.addEventListener(io,p),f.dispatchEvent(b),f.removeEventListener(io,p)),b?.defaultPrevented!==!0&&g.focus()})},d=f=>{f.key==="Tab"&&f.shiftKey&&(f.preventDefault(),i().focus())},u=f=>{f.key==="Tab"&&!f.shiftKey&&(f.preventDefault(),o().focus())},h=f=>{f.key==="Tab"&&f.preventDefault()},m=f=>{Cr(()=>{if(!J(t.restoreFocus))return;const p=J(t.finalFocusElement)??s;if(!p)return;let b;const v=t.onFinalFocus;v&&(b=new CustomEvent(so,Ys),f.addEventListener(so,v),f.dispatchEvent(b),f.removeEventListener(so,v)),b?.defaultPrevented!==!0&&p.focus()})}},fg=dg,hg=fg,gg=e=>{const t=C(()=>{const s=J(e.element);if(s)return getComputedStyle(s)}),n=()=>t()?.animationName??"none",[r,o]=P(J(e.show)?"present":"hidden");let i="none";return D(s=>{const a=J(e.show);return q(()=>{if(s===a)return a;const l=i,c=n();a?o("present"):c==="none"||t()?.display==="none"?o("hidden"):o(s===!0&&l!==c?"hiding":"hidden")}),a}),D(()=>{const s=J(e.element);if(!s)return;const a=c=>{c.target===s&&(i=n())},l=c=>{const u=n().includes(c.animationName);c.target===s&&u&&r()==="hiding"&&o("hidden")};s.addEventListener("animationstart",a),s.addEventListener("animationcancel",l),s.addEventListener("animationend",l),K(()=>{s.removeEventListener("animationstart",a),s.removeEventListener("animationcancel",l),s.removeEventListener("animationend",l)})}),{present:()=>r()==="present"||r()==="hiding",state:r,setState:o}},pg=gg,Xs=pg,mg=ce(),yg=e=>e?Fn(`dialog-${e}`):mg,Js=ce(),bg=e=>e?Fn(`dialog-internal-${e}`):Js,_t=e=>{if(!e){const n=he(Js);if(!n)throw new Error("[corvu]: Dialog context not found. Make sure to wrap Dialog components in <Dialog.Root>");return n}const t=to(`dialog-internal-${e}`);if(!t)throw new Error(`[corvu]: Dialog context with id "${e}" not found. Make sure to wrap Dialog components in <Dialog.Root contextId="${e}">`);return t},vg="div",wg=e=>{const[t,n]=j(e,["as","forceMount","contextId","children","ref","style","data-corvu-dialog-content"]),r=C(()=>_t(t.contextId)),o=()=>ro(r().open,()=>t.forceMount,r().contentPresent),i=C(s=>s||o(),!1);return y(Z,{get when(){return i()},get children(){return y(Zh,{get element(){return r().contentRef},get enabled(){return r().open()||r().contentPresent()},onDismiss:()=>r().setOpen(!1),get dismissOnEscapeKeyDown(){return r().closeOnEscapeKeyDown},get dismissOnOutsidePointer(){return r().closeOnOutsidePointer},get dismissOnOutsidePointerStrategy(){return r().closeOnOutsidePointerStrategy},get dismissOnOutsidePointerIgnore(){return r().triggerRef},get noOutsidePointerEvents(){return r().noOutsidePointerEvents},get onEscapeKeyDown(){return r().onEscapeKeyDown},get onOutsidePointer(){return r().onOutsidePointer},children:s=>{const a=C(()=>t.children);return y(Z,{get when(){return o()},get children(){return y(oo,T({ref(l){var c=Kn(r().setContentRef,t.ref);typeof c=="function"&&c(l)},get as(){return t.as??vg},get role(){return r().role()},get id(){return r().dialogId()},get"aria-labelledby"(){return r().labelId()},get"aria-describedby"(){return r().descriptionId()},get"aria-modal"(){return r().modal()?"true":"false"},get"data-open"(){return le(r().open())},get"data-closed"(){return le(!r().open())},get"data-corvu-dialog-content"(){return t.hasOwnProperty("data-corvu-dialog-content")?t["data-corvu-dialog-content"]:""},tabIndex:"-1",get style(){return{"pointer-events":s.isLastLayer?"auto":void 0,...t.style}}},n,{get children(){return a()}}))}})}})}})},xg=wg,Sg="div",Eg=e=>{const[t,n]=j(e,["as","forceMount","contextId","children","ref","style","data-corvu-dialog-overlay"]),r=C(()=>_t(t.contextId)),o=()=>ro(r().open,()=>t.forceMount,r().overlayPresent),i=C(s=>s||o(),!1);return y(Z,{get when(){return i()},get children(){return(()=>{const s=C(()=>t.children);return y(Z,{get when(){return o()},get children(){return y(oo,T({get as(){return t.as??Sg},ref(a){var l=Kn(r().setOverlayRef,t.ref);typeof l=="function"&&l(a)},"aria-hidden":"true",get"data-open"(){return le(r().open())},get"data-closed"(){return le(!r().open())},get"data-corvu-dialog-overlay"(){return t.hasOwnProperty("data-corvu-dialog-overlay")?t["data-corvu-dialog-overlay"]:""},tabIndex:"-1",get style(){return{"pointer-events":"auto",...t.style}}},n,{get children(){return s()}}))}})})()}})},kg=Eg,Cg=e=>{const[t,n]=j(e,["forceMount","contextId","children"]),r=C(()=>_t(t.contextId)),o=()=>ro(r().open,()=>t.forceMount,r().contentPresent,r().overlayPresent),i=eg(),s=C(a=>a||o()&&i(),!1);return y(Z,{get when(){return s()},get children(){return(()=>{const a=C(()=>t.children);return y(Z,{get when(){return o()},get children(){return y(qo,T(n,{get children(){return a()}}))}})})()}})},Og=Cg,ao=!0,_g=e=>{const t=T({role:"dialog",initialOpen:!1,modal:!0,closeOnEscapeKeyDown:!0,closeOnOutsidePointer:()=>!!(e.modal??ao),closeOnOutsidePointerStrategy:"pointerup",noOutsidePointerEvents:()=>!!(e.modal??ao),preventScroll:()=>!!(e.modal??ao),hideScrollbar:!0,preventScrollbarShift:!0,preventScrollbarShiftMode:"padding",allowPinchZoom:!0,trapFocus:!0,restoreFocus:!0,dialogId:Ae()},e),[n,r]=eo({value:()=>t.open,initialValue:t.initialOpen,onChange:t.onOpenChange}),[o,i,s]=Hs({value:()=>t.labelId??Ae()}),[a,l,c]=Hs({value:()=>t.descriptionId??Ae()}),[d,u]=P(null),[h,m]=P(null),[f,g]=P(null),{present:p}=Xs({show:n,element:h}),{present:b}=Xs({show:n,element:f});hg({element:h,enabled:()=>n()&&t.trapFocus,initialFocusElement:()=>t.initialFocusEl??null,restoreFocus:()=>t.restoreFocus,finalFocusElement:()=>t.finalFocusEl??null,onFinalFocus:t.onFinalFocus,onInitialFocus:t.onInitialFocus}),Hi({element:h,enabled:()=>p()&&G(t.preventScroll),hideScrollbar:()=>t.hideScrollbar,preventScrollbarShift:()=>t.preventScrollbarShift,preventScrollbarShiftMode:()=>t.preventScrollbarShiftMode,allowPinchZoom:()=>t.allowPinchZoom});const v={get role(){return t.role},get open(){return n()},setOpen:r,get modal(){return t.modal},get closeOnEscapeKeyDown(){return t.closeOnEscapeKeyDown},get closeOnOutsidePointer(){return G(t.closeOnOutsidePointer)},get closeOnOutsidePointerStrategy(){return t.closeOnOutsidePointerStrategy},get noOutsidePointerEvents(){return G(t.noOutsidePointerEvents)},get preventScroll(){return G(t.preventScroll)},get hideScrollbar(){return t.hideScrollbar},get preventScrollbarShift(){return G(t.preventScrollbarShift)},get preventScrollbarShiftMode(){return t.preventScrollbarShiftMode},get allowPinchZoom(){return t.allowPinchZoom},get trapFocus(){return t.trapFocus},get restoreFocus(){return t.restoreFocus},get initialFocusEl(){return t.initialFocusEl},get finalFocusEl(){return t.finalFocusEl},get contentPresent(){return p()},get contentRef(){return h()},get overlayPresent(){return b()},get overlayRef(){return f()},get dialogId(){return t.dialogId},get labelId(){return o()},get descriptionId(){return a()}},w=Ws(()=>t.children),x=()=>{const k=w()();return Yt(k)?k(v):k};return C(()=>{const k=yg(t.contextId),E=bg(t.contextId);return y(k.Provider,{value:{role:()=>t.role,open:n,setOpen:r,modal:()=>t.modal,closeOnEscapeKeyDown:()=>t.closeOnEscapeKeyDown,closeOnOutsidePointer:()=>G(t.closeOnOutsidePointer),closeOnOutsidePointerStrategy:()=>t.closeOnOutsidePointerStrategy,noOutsidePointerEvents:()=>G(t.noOutsidePointerEvents),preventScroll:()=>G(t.preventScroll),hideScrollbar:()=>t.hideScrollbar,preventScrollbarShift:()=>G(t.preventScrollbarShift),preventScrollbarShiftMode:()=>t.preventScrollbarShiftMode,allowPinchZoom:()=>t.allowPinchZoom,trapFocus:()=>t.trapFocus,restoreFocus:()=>t.restoreFocus,initialFocusEl:()=>t.initialFocusEl,finalFocusEl:()=>t.finalFocusEl,contentPresent:p,contentRef:h,overlayPresent:b,overlayRef:f,dialogId:()=>t.dialogId,labelId:o,descriptionId:a},get children(){return y(E.Provider,{get value(){return{role:()=>t.role,open:n,setOpen:r,modal:()=>t.modal,closeOnEscapeKeyDown:()=>t.closeOnEscapeKeyDown,onEscapeKeyDown:t.onEscapeKeyDown,closeOnOutsidePointer:()=>G(t.closeOnOutsidePointer),closeOnOutsidePointerStrategy:()=>t.closeOnOutsidePointerStrategy,onOutsidePointer:t.onOutsidePointer,noOutsidePointerEvents:()=>G(t.noOutsidePointerEvents),preventScroll:()=>G(t.preventScroll),hideScrollbar:()=>t.hideScrollbar,preventScrollbarShift:()=>G(t.preventScrollbarShift),preventScrollbarShiftMode:()=>t.preventScrollbarShiftMode,allowPinchZoom:()=>t.allowPinchZoom,trapFocus:()=>t.trapFocus,restoreFocus:()=>t.restoreFocus,initialFocusEl:()=>t.initialFocusEl,finalFocusEl:()=>t.finalFocusEl,contentPresent:p,contentRef:h,overlayPresent:b,overlayRef:f,dialogId:()=>t.dialogId,labelId:o,registerLabelId:i,unregisterLabelId:s,descriptionId:a,registerDescriptionId:l,unregisterDescriptionId:c,setContentRef:m,setOverlayRef:g,triggerRef:d,setTriggerRef:u}},get children(){return q(()=>x())}})}})})},Pg=_g,Ag="button",Tg=e=>{const[t,n]=j(e,["as","contextId","ref","onClick","data-corvu-dialog-trigger"]),r=C(()=>_t(t.contextId));return y(cg,T({ref(i){var s=Kn(r().setTriggerRef,t.ref);typeof s=="function"&&s(i)},get as(){return t.as??Ag},onClick:i=>{!tg(t.onClick,i)&&r().setOpen(s=>!s)},"aria-haspopup":"dialog",get"aria-expanded"(){return r().open()?"true":"false"},get"aria-controls"(){return r().dialogId()},get"data-open"(){return le(r().open())},get"data-closed"(){return le(!r().open())},get"data-corvu-dialog-trigger"(){return t.hasOwnProperty("data-corvu-dialog-trigger")?t["data-corvu-dialog-trigger"]:""}},n))},Dg=Tg,Bn=e=>typeof e=="function"?e():e,Zs=e=>requestAnimationFrame(()=>requestAnimationFrame(e));function Lg(e){const t=T({enabled:!0,dimension:"both"},e),[n,r]=P(!1),[o,i]=P(null);let s=null;D(()=>{const c=Bn(t.element),d=Bn(t.enabled);if(!c||!d)return;const u=new ResizeObserver(a);u.observe(c),c.addEventListener("transitionend",l),K(()=>{u.disconnect(),c.removeEventListener("transitionend",l),l()})});const a=([c])=>{if(n())return;const d=c.target,u=[d.offsetWidth,d.offsetHeight],h=Bn(t.dimension);h==="both"?s?s[0]!==u[0]&&s[1]!==u[1]&&(Ee(()=>{i(s),r(!0)}),Zs(()=>{i(u),parseFloat(getComputedStyle(c.target).transitionDuration)===0&&l()})):s=u:s?zn(h,s)!==zn(h,u)&&(Ee(()=>{i(zn(h,s)),r(!0)}),Zs(()=>{i(zn(h,u)),parseFloat(getComputedStyle(c.target).transitionDuration)===0&&l()})):s=u},l=()=>{if(!n())return;const c=Bn(t.element);c?s=[c.offsetWidth,c.offsetHeight]:s=null,Ee(()=>{r(!1),i(null)})};return{transitioning:n,transitionSize:o}}var zn=(e,t)=>{switch(e){case"width":return t[0];case"height":return t[1]}},Mg=Lg,Ig=Mg;const Rg=(e,t)=>e.length>0?()=>e(q(t)):e;function $g(e,t){let n=0;const r=e.map((o,i)=>C(()=>(n=i,o()),void 0,cr));return C(()=>r.map(o=>o())[n],void 0,t)}function Qs(e,t,n){let r=()=>t;const[o,i]=P(t,cr),s=C(Rg(e,()=>r()),t,cr);return[r=$g([o,s],n),a=>i(()=>typeof a=="function"?a(q(r)):a)]}var Fg=(e,t)=>{switch(t){case"x":return[e.clientWidth,e.scrollLeft,e.scrollWidth];case"y":return[e.clientHeight,e.scrollTop,e.scrollHeight]}},Ng=(e,t)=>{const n=getComputedStyle(e),r=t==="x"?n.overflowX:n.overflowY;return r==="auto"||r==="scroll"||e.tagName==="HTML"&&r==="visible"},Kg=(e,t,n)=>{const r=t==="x"&&window.getComputedStyle(e).direction==="rtl"?-1:1;let o=e,i=0,s=0,a=!1;do{const[l,c,d]=Fg(o,t),u=d-l-r*c;(c!==0||u!==0)&&Ng(o,t)&&(i+=u,s+=c),o===(n??document.documentElement)?a=!0:o=o._$host??o.parentElement}while(o&&!a);return[i,s]},Bg=e=>y(Dg,T({"data-corvu-dialog-trigger":void 0,"data-corvu-drawer-trigger":""},e)),ea=ce(),zg=e=>e?Fn(`drawer-${e}`):ea,Vg=e=>{if(!e){const n=he(ea);if(!n)throw new Error("[corvu]: Drawer context not found. Make sure to wrap Drawer components in <Drawer.Root>");return n}const t=to(`drawer-${e}`);if(!t)throw new Error(`[corvu]: Drawer context with id "${e}" not found. Make sure to wrap Drawer components in <Drawer.Root contextId="${e}">`);return t},ta=ce(),Ug=e=>e?Fn(`drawer-internal-${e}`):ta,na=e=>{if(!e){const n=he(ta);if(!n)throw new Error("[corvu]: Drawer context not found. Make sure to wrap Drawer components in <Drawer.Root>");return n}const t=to(`drawer-internal-${e}`);if(!t)throw new Error(`[corvu]: Drawer context with id "${e}" not found. Make sure to wrap Drawer components in <Drawer.Root contextId="${e}">`);return t},ra=(e,t,n,r)=>{if(n===void 0||r===void 0)return{value:e,offset:Vn(e,t)};const o=r[n-1]?Vn(r[n-1],t):void 0,i=r[n]?Vn(r[n],t):void 0;return{value:e,offset:Vn(e,t),lowerBreakPoint:i,upperBreakPoint:o}},Vn=(e,t)=>{if(typeof e=="number")return t-e*t;if(!e.endsWith("px"))throw new Error(`[corvu] Snap and break points must be a number or a string ending with 'px'. Got ${e}`);return t-parseInt(e,10)},jg=(e,t,n,r)=>{const o=oa("upper",e,r?n:t),i=oa("lower",e,r?n:t);return o?i?i.upperBreakPoint===void 0||o.lowerBreakPoint===void 0?Math.abs(i.offset-n)<Math.abs(o.offset-n)?i:o:n<o.lowerBreakPoint?i:o:o:i},oa=(e,t,n)=>t.reduce((r,o)=>e=="upper"&&o.offset>=n&&(!r||o.offset<r.offset)||e=="lower"&&o.offset<=n&&(!r||o.offset>r.offset)?o:r,void 0),Hg=(e,t)=>{let n=e,r=!1;do{if(n.hasAttribute("data-corvu-no-drag")||n.type==="range")return!1;n===(t??document.documentElement)?r=!0:n=n.parentElement}while(n&&!r);return!0},qg=void 0,Wg=e=>{const t=T({initialOpen:!1,snapPoints:[0,1],breakPoints:[qg],defaultSnapPoint:1,side:"bottom",dampFunction:F=>6*Math.log(F+1),velocityFunction:(F,V)=>{const Q=F/V;return Q<1&&Q>-1?1:Q},velocityCacheReset:200,allowSkippingSnapPoints:!0,handleScrollableElements:!0,transitionResize:!1,closeOnOutsidePointer:!0,allowPinchZoom:!1},e),[n,r]=j(t,["snapPoints","breakPoints","defaultSnapPoint","activeSnapPoint","onActiveSnapPointChange","side","dampFunction","velocityFunction","velocityCacheReset","allowSkippingSnapPoints","handleScrollableElements","transitionResize","open","initialOpen","onOpenChange","closeOnOutsidePointer","contextId","children"]),[o,i]=eo({value:()=>n.open,initialValue:n.initialOpen,onChange:n.onOpenChange}),[s,a]=eo({value:()=>n.activeSnapPoint,initialValue:0,onChange:n.onActiveSnapPointChange}),[l,c]=P(),{transitioning:d,transitionSize:u}=Ig({element:()=>l()?.contentRef()??null,enabled:()=>o()&&n.transitionResize,dimension:()=>{switch(n.side){case"top":case"bottom":return"height";case"left":case"right":return"width"}}}),[h,m]=P(!1),[f,g]=Qs(()=>d()?"resizing":null),p=C(()=>{const F=l()?.contentRef();if(F)return getComputedStyle(F)}),[b,v]=P(!1);D(()=>{const F=o();q(()=>{b()!==F&&(F?(v(!0),js(()=>{Ee(()=>{g("opening"),a(n.defaultSnapPoint)}),parseFloat(p().transitionDuration)===0&&g(null)})):(Ee(()=>{g("closing"),a(0)}),js(()=>{parseFloat(p().transitionDuration)===0&&w()})))})});const w=()=>{Ee(()=>{v(!1),g(null)})},[x,O]=P(0);D(()=>{const F=l()?.contentRef();if(!F)return;E(F);const V=new ResizeObserver(k);V.observe(F),K(()=>{V.disconnect()})});const k=F=>{for(const V of F)V.target===l()?.contentRef()&&E(V.target)},E=F=>{const V=q(()=>x());switch(n.side){case"top":case"bottom":if(V===F.offsetHeight)return;O(F.offsetHeight);break;case"left":case"right":if(V===F.offsetWidth)return;O(F.offsetWidth);break}},$=C(()=>ra(s(),x())),[_,R]=Qs(()=>$().offset),L=C(()=>x()?(x()-_())/x():0),I={get snapPoints(){return n.snapPoints},get breakPoints(){return n.breakPoints},get defaultSnapPoint(){return n.defaultSnapPoint},get activeSnapPoint(){return s()},setActiveSnapPoint:a,get side(){return n.side},get isDragging(){return h()},get isTransitioning(){return f()!==null},get transitionState(){return f()},get openPercentage(){return L()},get translate(){return _()},get velocityCacheReset(){return n.velocityCacheReset},get allowSkippingSnapPoints(){return n.allowSkippingSnapPoints},get handleScrollableElements(){return n.handleScrollableElements},get transitionResize(){return n.transitionResize}},ne=Ws(()=>n.children),Y=F=>{c(_t(n.contextId));const V=ne()();if(Yt(V)){const Q=T(F,I);return V(Q)}return V};return C(()=>{const F=zg(n.contextId),V=Ug(n.contextId);return q(()=>y(F.Provider,{value:{snapPoints:()=>n.snapPoints,breakPoints:()=>n.breakPoints,defaultSnapPoint:()=>n.defaultSnapPoint,activeSnapPoint:s,setActiveSnapPoint:a,side:()=>n.side,isDragging:h,isTransitioning:()=>f()!==null,transitionState:f,openPercentage:L,translate:_,velocityCacheReset:()=>n.velocityCacheReset,allowSkippingSnapPoints:()=>n.allowSkippingSnapPoints,handleScrollableElements:()=>n.handleScrollableElements,transitionResize:()=>n.transitionResize},get children(){return y(V.Provider,{get value(){return{snapPoints:()=>n.snapPoints,breakPoints:()=>n.breakPoints,defaultSnapPoint:()=>n.defaultSnapPoint,activeSnapPoint:s,setActiveSnapPoint:a,side:()=>n.side,isDragging:h,isTransitioning:()=>f()!==null,transitionState:f,openPercentage:L,translate:_,velocityCacheReset:()=>n.velocityCacheReset,allowSkippingSnapPoints:()=>n.allowSkippingSnapPoints,handleScrollableElements:()=>n.handleScrollableElements,transitionResize:()=>n.transitionResize,dampFunction:n.dampFunction,velocityFunction:n.velocityFunction,setIsDragging:m,setTranslate:R,drawerSize:x,resolvedActiveSnapPoint:$,drawerStyles:p,setTransitionState:g,transitionSize:u,closeDrawer:w}},get children(){return y(Pg,T({get open(){return b()},onOpenChange:i,get contextId(){return n.contextId},get closeOnOutsidePointer(){return!h()&&n.closeOnOutsidePointer}},r,{children:Q=>Y(Q)}))}})}}))})},Gg=Wg,Yg=e=>{const[t,n]=j(e,["contextId","style"]);let r=!1,o=null,i=[0,0],s,a=0;const l=C(()=>na(t.contextId)),c=C(()=>_t(t.contextId)),d=C(()=>l().snapPoints().map((w,x)=>ra(w,l().drawerSize(),x,l().breakPoints()))),u=C(()=>{switch(l().side()){case"top":return`translate3d(0, ${-l().translate()}px, 0)`;case"bottom":return`translate3d(0, ${l().translate()}px, 0)`;case"right":return`translate3d(${l().translate()}px, 0, 0)`;case"left":return`translate3d(${-l().translate()}px, 0, 0)`}}),h=C(()=>{const w=l().transitionSize();if(w)switch(l().side()){case"top":case"bottom":return`${w}px`}}),m=C(()=>{const w=l().transitionSize();if(w)switch(l().side()){case"left":case"right":return`${w}px`}});D(()=>{c().open()&&(document.addEventListener("pointermove",g),document.addEventListener("touchmove",p),document.addEventListener("pointerup",v),document.addEventListener("touchend",v),K(()=>{document.removeEventListener("pointermove",g),document.removeEventListener("touchmove",p),document.removeEventListener("pointerup",v),document.removeEventListener("touchend",v)}))});const f=w=>{Hg(w.target,c().contentRef())&&l().transitionState()!=="closing"&&(r=!0,l().handleScrollableElements()&&(i=[w.clientX,w.clientY]))},g=w=>{b(w.target,w.clientX,w.clientY)},p=w=>{w.touches[0]&&b(w.target,w.touches[0].clientX,w.touches[0].clientY)},b=(w,x,O)=>{if(!r)return;if(!l().isDragging()||o===null){const $=window.getSelection();if($&&$.toString().length>0){v();return}if(l().handleScrollableElements()){const _=[x,O].map((fe,F)=>i[F]-fe),R=Math.abs(_[0])>Math.abs(_[1])?"x":"y",L=R==="x"?_[0]:_[1];if(Math.abs(L)<.3)return;const I=c().contentRef(),[ne,Y]=Kg(w,R,I);if(L>0&&Math.abs(ne)>1||L<0&&Math.abs(Y)>0){v();return}}switch(l().side()){case"top":case"bottom":o=O;break;case"right":case"left":o=x}s=new Date,a=l().translate(),Ee(()=>{l().setIsDragging(!0),l().setTransitionState(null)})}let k;switch(l().side()){case"top":k=-(o-O);break;case"bottom":k=o-O;break;case"right":k=o-x;break;case"left":k=-(o-x);break}k-=l().resolvedActiveSnapPoint().offset,k>0&&(k=l().dampFunction(k));const E=new Date;E.getTime()-s.getTime()>l().velocityCacheReset()&&(s=E,a=l().translate()),l().setTranslate(-k)},v=()=>{if(r=!1,!l().isDragging())return;const w=new Date,x=l().velocityFunction(-(a-l().translate()),w.getTime()-s.getTime()||1),O=l().translate()*x,k=jg(d(),l().translate(),O,l().allowSkippingSnapPoints());Ee(()=>{l().setTransitionState("snapping"),l().setIsDragging(!1)}),Ee(()=>{l().setActiveSnapPoint(k.value),k.offset===l().drawerSize()?c().setOpen(!1):(l().setTranslate(k.offset),parseFloat(l().drawerStyles().transitionDuration)===0&&l().setTransitionState(null))})};return y(xg,T({get contextId(){return t.contextId},get style(){return{transform:u(),"transition-duration":l().isDragging()?"0ms":void 0,height:h(),width:m(),...t.style}},onPointerDown:f,onTransitionEnd:()=>{Ee(()=>{l().transitionState()==="closing"&&l().closeDrawer(),l().transitionState()!=="resizing"&&l().setTransitionState(null)})},get"data-transitioning"(){return le(l().isTransitioning())},get"data-opening"(){return le(l().transitionState()==="opening")},get"data-closing"(){return le(l().transitionState()==="closing")},get"data-snapping"(){return le(l().transitionState()==="snapping")},get"data-resizing"(){return le(l().transitionState()==="resizing")},"data-corvu-dialog-content":void 0,"data-corvu-drawer-content":""},n))},Xg=Yg,Jg=e=>{const[t,n]=j(e,["contextId"]),r=C(()=>na(t.contextId));return y(kg,T({get contextId(){return t.contextId},get"data-transitioning"(){return le(r().isTransitioning())},get"data-opening"(){return le(r().transitionState()==="opening")},get"data-closing"(){return le(r().transitionState()==="closing")},get"data-snapping"(){return le(r().transitionState()==="snapping")},get"data-resizing"(){return le(r().transitionState()==="resizing")},"data-corvu-dialog-overlay":void 0,"data-corvu-drawer-overlay":""},n))},Zg=Jg,Qg=M('<div class="mx-auto mt-4 h-2 w-[100px] rounded-full bg-muted">');const ep=Gg,tp=Bg,np=Og,rp=e=>{const[,t]=j(e,["class"]),n=Vg();return y(Zg,T({get class(){return Ge("absolute inset-0 z-50 data-[transitioning]:transition-colors data-[transitioning]:duration-300",e.class)},get style(){return{"background-color":`rgb(0 0 0 / ${.6*n.openPercentage()})`}}},t))},op=e=>{const[,t]=j(e,["class","children"]);return y(np,{get mount(){return Wn()},get children(){return[y(rp,{}),y(Xg,T({id:"smarttalks-list-content",get class(){return Ge("absolute inset-x-0 bottom-0 z-50 mt-24 flex h-auto max-h-[80%] flex-col rounded-t-[10px] border bg-background after:top-full after:h-[50%] after:bg-inherit md:select-none transition-transform duration-300",e.class)}},t,{get children(){return[Qg(),C(()=>e.children)]}}))]}})};var ip=M('<span class="font-semibold mt-2">'),sp=M('<div class="flex py-4 pl-3 pr-1 flex-col w-full space-y-4 overflow-y-auto">'),ap=M('<div class="flex flex-col space-y-2"><div>'),lp=M('<div class="flex flex-col w-full space-y-1"><span class="font-semibold text-slate-700">'),cp=M('<div class="flex flex-col items-start"><span class=text-slate-500>');const up=({options:e,text:t,title:n})=>{const{pushMessage:r}=Qe(),[o,i]=P(!1),[s,a]=P(!1),[l,c]=P(),d=(h,m)=>{a(!1),i(!0),r(h,m)},u=h=>{const m=h.composedPath();for(const f of m)if(f.id==="smarttalks-list-content"){h.preventDefault();return}};return(()=>{var h=ap(),m=h.firstChild;return A(h,y(Ot,{get children(){return t?.trim()}}),m),A(m,y(ep,{get open(){return s()},onOpenChange:a,onOutsidePointer:u,get children(){return[y(tp,{as:Te,variant:"outline",class:"w-full text-nowrap",get children(){return n?.trim()??dt("selectOption")}}),y(op,{class:"pb-2 px-2 flex flex-col items-center justify-center",get children(){return[(()=>{var f=ip();return A(f,()=>n?.trim()??dt("selectOption")),f})(),(()=>{var f=sp();return A(f,y(ht,{each:e,children:g=>(()=>{var p=lp(),b=p.firstChild;return A(b,()=>g.label?.trim()??""),A(p,y(ht,{get each(){return g.items},children:v=>y(Te,{variant:"outline",get disabled(){return o()},get class(){return`py-6 flex justify-between hover:bg-slate-200 ${l()===v?"bg-slate-200":""}`},onClick:()=>c(v),get children(){return[(()=>{var w=cp(),x=w.firstChild;return A(w,()=>v.label?.trim(),x),A(x,()=>v.description?.trim()),w})(),y(Z,{get when(){return l()===v},get fallback(){return y(lf,{class:"size-4 text-slate-500"})},get children(){return y(af,{class:"size-4 text-slate-500"})}})]}})}),null),p})()})),f})(),y(Te,{get disabled(){return o()||!l()},onClick:()=>d(l().label,l().value),class:"w-11/12 mt-4 hover:bg-primary shadow-sm hover:shadow-primary transition-shadow",get children(){return dt("send")}})]}})]}})),re(()=>gt(m,o()?"opacity-50":"")),h})()};var dp=M("<audio controls preload=auto class=h-8><source type=audio/mpeg><source type=audio/ogg>Your browser does not support the audio element.");const fp=e=>(()=>{var t=dp(),n=t.firstChild,r=n.nextSibling;return re(o=>{var i=e.link,s=e.link;return i!==o.e&&ue(n,"src",o.e=i),s!==o.t&&ue(r,"src",o.t=s),o},{e:void 0,t:void 0}),t})();var hp=M('<div class="flex flex-col space-y-2"><a class="self-center hover:brightness-75 transition-all duration-300 flex flex-col items-center justify-between bg-slate-200 rounded-md px-1 py-1 space-y-2 text-slate-700"target=_blank><span class="font-semibold text-sm">');const gp=e=>(()=>{var t=hp(),n=t.firstChild,r=n.firstChild;return A(n,y(cf,{class:"size-10"}),r),A(r,()=>e.filename?.trim()),A(t,y(Ot,{get children(){return e.text?.trim()}}),null),re(()=>ue(n,"href",e.link)),t})();var pp=M('<div class="flex flex-col space-y-2"><a class="object-contain hover:brightness-50 transition-all duration-300"target=_blank><img class="w-full h-auto rounded-md">');const mp=e=>(()=>{var t=pp(),n=t.firstChild,r=n.firstChild;return A(t,y(Ot,{get children(){return e.text?.trim()}}),null),re(o=>{var i=e.link,s=e.link,a=e.text?.trim();return i!==o.e&&ue(n,"href",o.e=i),s!==o.t&&ue(r,"src",o.t=s),a!==o.a&&ue(r,"alt",o.a=a),o},{e:void 0,t:void 0,a:void 0}),t})();var yp=M('<div class="flex flex-col space-y-2"><video controls preload=auto class="size-full rounded-md"><source type=video/mp4><source type=video/ogg>Your browser does not support the video element.');const bp=e=>(()=>{var t=yp(),n=t.firstChild,r=n.firstChild,o=r.nextSibling;return A(t,y(Ot,{get children(){return e.text?.trim()}}),null),re(i=>{var s=e.link,a=e.link;return s!==i.e&&ue(r,"src",i.e=s),a!==i.t&&ue(o,"src",i.t=a),i},{e:void 0,t:void 0}),t})();var vp=M("<div>Media type not supported");const ia=e=>e.type==="image"?y(mp,e):e.type==="audio"?y(fp,e):e.type==="document"?y(gp,e):e.type==="video"?y(bp,e):vp(),lo=({text:e})=>y(Ot,{get children(){return e?.trim()}});var wp=M("<div>Unknown bot message type");const xp=e=>y(Ph,{get createdAt(){return e.createdAt},get children(){return e.type==="text"?y(lo,{get text(){return e.text}}):e.type==="buttons"?y(Dh,T(()=>e.buttons)):e.type==="list"?y(up,T(()=>e.list)):e.type==="media"?y(ia,T(()=>e.media)):e.type==="link"?y($h,T(()=>e.link)):e.type==="cards"?y(Ih,T(()=>e.cards)):e.type==="date"?y(lo,{get text(){return e.text}}):wp()}});var Sp=M('<div class="place-self-center p-4"><span class="bg-slate-200/40 text-black font-semibold py-2 px-4 rounded-xl">');const Ep=e=>(()=>{var t=Sp(),n=t.firstChild;return A(n,()=>e.text?.trim()),t})();var kp=M('<div class="place-self-end py-1 flex flex-col"><div class="bg-primary shadow-primary/40 shadow-md py-2 px-4 rounded-l-xl rounded-tr-xl text-primary-foreground">');const Cp=({children:e,createdAt:t})=>(()=>{var n=kp(),r=n.firstChild;return A(r,e),A(n,y(Us,{createdAt:t,anchor:"end"}),null),n})();var Op=M("<div>Unknown user message type");const _p=e=>y(Cp,{get createdAt(){return e.createdAt},get children(){return e.type==="text"?y(lo,{get text(){return e.text}}):e.type==="media"?y(ia,T(()=>e.media)):Op()}});var Pp=M("<div>Unknown message origin");const Ap=e=>e.origin==="bot"?y(xp,e):e.origin==="user"?y(_p,e):e.origin==="service"?y(Ep,e):Pp();function Tp(e){return ve({a:{viewBox:"0 0 512 512"},c:'<path d="m289.94 256 95-95A24 24 0 0 0 351 127l-95 95-95-95a24 24 0 0 0-34 34l95 95-95 95a24 24 0 1 0 34 34l95-95 95 95a24 24 0 0 0 34-34Z"/>'},e)}function Pt(e){return ve({a:{viewBox:"0 0 512 512"},c:'<path d="M256 464c-114.69 0-208-93.31-208-208S141.31 48 256 48s208 93.31 208 208-93.31 208-208 208Z"/>'},e)}var Dp=M('<div class="place-self-start py-1"><div class="animate-pulse bg-white flex space-x-1 shadow-md py-2 px-4 rounded-r-xl rounded-tl-xl text-slate-400">');const Lp=()=>(()=>{var e=Dp(),t=e.firstChild;return A(t,y(Pt,{class:"size-2 animate-bounce"}),null),A(t,y(Pt,{class:"size-2 animate-bounce delay-150"}),null),A(t,y(Pt,{class:"size-2 animate-bounce delay-300"}),null),e})();var Mp=M('<main class="flex-grow p-4 overflow-y-auto flex flex-col items-center scroll-smooth relative">'),Ip=M("<div>");const co=()=>{let e;const{getMessages:t,onMessage:n,typing:r,clearMessages:o}=Qe(),{onOpen:i}=Xo(),s=(a=100)=>{setTimeout(()=>{e?.scrollTo(0,e.scrollHeight)},a)};return se("reset",()=>{o()}),tn(()=>{s(200)}),n(s),i(()=>s(200)),(()=>{var a=Mp(),l=e;return typeof l=="function"?ir(l,a):e=a,A(a,y(ht,{get each(){return t()},get fallback(){return(()=>{var c=Ip();return A(c,()=>dt("emptyMessages")),c})()},children:c=>y(Ap,c)}),null),A(a,y(Z,{get when(){return r()},get children(){return y(Lp,{})}}),null),a})()};var Rp=M("<textarea>");const $p=e=>{const[,t]=j(e,["class"]);return(()=>{var n=Rp();return tt(n,T({get class(){return Ge("flex w-full rounded-md border border-input bg-transparent px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",e.class)}},t),!1,!1),n})()};var Fp=M('<svg viewBox="0 0 72 72"fill=none xmlns=http://www.w3.org/2000/svg><path d="M50.3241 0H21.6759C9.69907 0 0 9.68892 0 21.6519V50.3481C0 62.3111 9.69907 72 21.6759 72H67.9815C70.2546 72 72 70.1845 72 67.9105V21.6519C72 9.68892 62.3009 0 50.3241 0Z"fill=#212431></path><path d="M28.9868 56.1046H24.7249C21.9596 56.1046 19.7217 53.8671 19.7217 51.1129V45.9126C19.7217 44.244 18.3676 42.8929 16.6952 42.8929H13.6924C11.8108 42.8929 10.2857 41.3712 10.2857 39.494V37.0622C10.2857 35.185 11.8108 33.6633 13.6924 33.6633H25.3758C27.3713 33.6633 28.9868 35.275 28.9868 37.2613V56.1046Z"fill=white></path><path d="M61.7142 26.3227C61.7142 28.1782 60.2059 29.6992 58.3661 29.6992H46.2955V56.1042H37.629C34.9627 56.1042 32.8054 53.9238 32.8054 51.2395V36.1839C32.8054 32.6002 29.9243 29.6992 26.3755 29.6992H20.1791C18.3393 29.6992 16.8311 28.1782 16.8311 26.3227V19.2729C16.8311 17.408 18.33 15.8964 20.1791 15.8964H58.3661C60.2153 15.8964 61.7142 17.408 61.7142 19.2729V26.3227Z"fill=white>');const Np=e=>(()=>{var t=Fp();return tt(t,e,!0,!0),t})();var Kp=M('<div class="absolute flex items-center justify-center left-1/2 transform -translate-x-1/2 bottom-0 pb-1"><span class="font-semibold text-xs text-gray-600 ml-1">SmartTalks.ai');const Bp=()=>(()=>{var e=Kp(),t=e.firstChild;return A(e,y(Np,{height:15}),t),e})();var zp=M('<footer class="relative flex-none p-4 bg-white min-h-16 flex space-x-1 pb-6">');const uo=()=>{const{pushMessage:e}=Qe(),[t,n]=P(""),r=()=>{e(t()),n("")},o=i=>{i.key==="Enter"&&!i.shiftKey&&r()};return se("setInput",i=>{i&&n(i)}),(()=>{var i=zp();return A(i,y($p,{get placeholder(){return dt("inputPlaceholder")},get value(){return t()},onInput:s=>n(s.currentTarget.value),onkeyup:o,class:"focus-visible:ring-primary h-10",style:"resize: none;",autofocus:!0}),null),A(i,y(Te,{variant:"outline",class:"p-2","aria-label":"Send",type:"button",onClick:r,get children(){return y(gc,{size:24})}}),null),A(i,y(Bp,{}),null),i})()};var Vp=M('<div id=smarttalks-widget class="rounded-md shadow-xl h-[85vh] w-[90vw] md:h-[min(100vh,500px)] md:w-[min(100vw,400px)] overflow-hidden bg-background text-foreground flex flex-col relative">'),Up=M("<span class=sr-only>Close"),jp=M("<div>"),Hp=M("<span class=sr-only>Open"),qp=M("<span>"),Wp=M('<div class="animate-pulse flex p-1">');const Gp=({children:e,openIcon:t})=>{const{bubble:n,toggle:r,show:o,hide:i}=Xo(),{chatWidget:s}=oe(),[a,l]=P(!0);setTimeout(()=>l(!1),2e3),s()?.openDelay&&setTimeout(()=>{o()},(s()?.openDelay||0)*1e3);const c=()=>(s()?.style.margin??5)/4,d=()=>s()?.style.position==="left"?{left:`${c()}rem`}:{right:`${c()}rem`};return se("open",()=>{o()}),se("close",()=>{i()}),se("toggle",()=>{r()}),(()=>{var u=jp();return A(u,y(Z,{get when(){return n()},get children(){var h=Vp();return A(h,e),h}}),null),A(u,y(Z,{get when(){return n()},get fallback(){return y(Te,{onclick:r,class:"rounded-full py-6 px-0 hover:shadow-primary shadow-md border border-primary transition-shadow duration-300","aria-label":"Open",type:"button",get children(){return[t,Hp(),y(Z,{get when(){return s()?.balloonMessage},get children(){var h=qp();return A(h,y(Z,{get when(){return!a()},get fallback(){return(()=>{var m=Wp();return A(m,y(Pt,{class:"size-2 animate-bounce"}),null),A(m,y(Pt,{class:"size-2 animate-bounce delay-150"}),null),A(m,y(Pt,{class:"size-2 animate-bounce delay-300"}),null),m})()},get children(){return s()?.balloonMessage}})),re(()=>gt(h,"absolute -top-2 bg-primary text-primary-foreground px-1 py-0.5 pointer-events-none rounded truncate"+(s()?.style.position==="left"?" left-9":" right-9"))),h}})]}})},get children(){return y(Te,{onclick:r,class:"rounded-full py-6 px-2 hover:bg-primary hover:shadow-primary shadow-md transition-shadow duration-300","aria-label":"Close",type:"button",get children(){return[y(Tp,{size:30}),Up()]}})}}),null),re(h=>{var m="max-h-full max-w-full md:max-h-[90%] md:max-w-[90%] fixed bottom-5 flex flex-col space-y-2"+(s()?.style.position==="left"?" items-start":" items-end"),f=d();return m!==h.e&>(u,h.e=m),h.t=an(u,f,h.t),h},{e:void 0,t:void 0}),u})()};var Yp=M('<div id=smarttalks-widget class="h-screen w-full overflow-hidden bg-background text-foreground flex flex-col rounded-md">');const Xp=({children:e})=>{const{chatWidget:t}=oe(),n={};return t()?.style.width&&(n.width=`min(100vw, ${t()?.style.width}px)`),t()?.style.height&&(n.height=`min(100vh, ${t()?.style.height}px)`),(()=>{var r=Yp();return an(r,n),A(r,e),r})()};var Jp=M('<div id=smarttalks-widget class="h-[85vh] w-[90vw] md:h-[min(100vh,500px)] md:w-[min(100vw,400px)] max-h-full max-w-full md:max-h-[90%] md:max-w-[90%] fixed bottom-5 rounded-md shadow-xl overflow-hidden bg-background text-foreground flex flex-col">');const Zp=({children:e})=>{const{chatWidget:t}=oe(),[n,r]=P(!1),o=()=>(t()?.style.margin??5)/4,i=()=>{const s={};return t()?.fullscreen?(s.height="100%",s["max-height"]="100%",s.width="100%",s["max-width"]="100%",s.bottom=0,s.left=0):t()?.style.position&&(s[t()?.style.position||"right"]=`${o()}rem`),s};return se("open",()=>{r(!0),ee("onOpen")}),se("close",()=>{r(!1),ee("onClose")}),se("toggle",()=>{r(!n()),ee("onToggle")}),setTimeout(()=>{r(!0),ee("onOpen")},(t()?.openDelay||0)*1e3),y(Z,{get when(){return n()},get children(){var s=Jp();return A(s,e),re(a=>an(s,i(),a)),s}})};var Qp=M('<div class="absolute bg-black/50 text-white font-bold h-full w-full grid place-content-center z-50">');const fo=()=>(()=>{var e=Qp();return A(e,y(hc,{size:45,class:"animate-spin"})),e})(),em=()=>{const{chatWidget:e}=oe(),{loading:t}=Qe();return y(Gp,{get openIcon(){return y(ii,{get src(){return e()?.avatar}})},get children(){return[y(Z,{get when(){return t()},get children(){return y(fo,{})}}),y(Qr,{}),y(co,{}),y(uo,{})]}})},tm=()=>{const{loading:e}=Qe();return y(Zp,{get children(){return[y(Z,{get when(){return e()},get children(){return y(fo,{})}}),y(Qr,{}),y(co,{}),y(uo,{})]}})},nm=()=>{const{loading:e}=Qe();return y(Xp,{get children(){return[y(Z,{get when(){return e()},get children(){return y(fo,{})}}),y(Qr,{}),y(co,{}),y(uo,{})]}})},rm=()=>{const{chatWidget:e}=oe();return y(Bo,{get children(){return[y(It,{get when(){return e()?.mode==="standard"},get children(){return y(em,{})}}),y(It,{get when(){return e()?.mode==="popup"},get children(){return y(tm,{})}}),y(It,{get when(){return e()?.mode==="static"},get children(){return y(nm,{})}})]}})};var om=M("<div><div>Form");const im=()=>{const{formWidget:e}=oe();return(()=>{var t=om();return t.firstChild,A(t,()=>e()?._id,null),t})()};function sm(){const{widget:e}=oe();return y(Bo,{get children(){return[y(It,{get when(){return e()?.type==="chat"},get children(){return y(rm,{})}}),y(It,{get when(){return e()?.type==="form"},get children(){return y(im,{})}})]}})}var am=M("<style>"),lm=M("<div>");const cm=({id:e,settings:t,side:n,margin:r,mode:o})=>{const{setWidgetId:i}=oe(),s=(e||"default")+"?"+(t?"&showSettings":"")+(n?`&${n}`:"")+(r?`&margin=${r}`:"")+(o?`&mode=${o}`:"");return i(s),[(()=>{var a=am();return A(a,zl),a})(),(()=>{var a=lm();return A(a,y(sm,{})),a})()]},um={id:"",settings:!1,side:void 0,margin:void 0,mode:void 0};(()=>{typeof window>"u"||Bl("smarttalks-widget",um,cm)})(),Va()});
|
|
181
|
+
*/function Wd(e,t){return t?jc([e.clientX,e.clientY],t):!1}function Gd(e){const t=kt(),n=Fi(),r=hs(),o=Le({placement:"bottom-start"},e),[i,s]=j(o,["open","defaultOpen","onOpenChange"]);let a=0,l=null,c="right";const[d,u]=P(),[h,m]=P(),[f,g]=P(),[p,b]=P(),[v,w]=P(!0),[x,O]=P(s.placement),[k,E]=P([]),[$,_]=P([]),{DomCollectionProvider:R}=Vu({items:$,onItemsChange:_}),L=wi({open:()=>i.open,defaultOpen:()=>i.defaultOpen,onOpenChange:U=>i.onOpenChange?.(U)}),I=uu(()=>t.forceMount()||L.isOpen()),ne=Tu({selectionMode:"none",dataSource:$}),Y=U=>{w(U),L.open()},fe=(U=!1)=>{L.close(),U&&r&&r.close(!0)},F=U=>{w(U),L.toggle()},V=()=>{const U=p();U&&(de(U),ne.selectionManager().setFocused(!0),ne.selectionManager().setFocusedKey(void 0))},Q=U=>{E(ho=>[...ho,U]);const Un=r?.registerNestedMenu(U);return()=>{E(ho=>dr(ho,U)),Un?.()}},ie=U=>c===l?.side&&Wd(U,l?.area),At=U=>{ie(U)&&U.preventDefault()},Pe=U=>{ie(U)||V()},dm=U=>{ie(U)&&U.preventDefault()};au({isDisabled:()=>!(r==null&&L.isOpen()&&t.isModal()),targets:()=>[p(),...k()].filter(Boolean)}),D(()=>{const U=p();if(!U||!r)return;const Un=r.registerNestedMenu(U);K(()=>{Un()})});const fm={dataset:C(()=>({"data-expanded":L.isOpen()?"":void 0,"data-closed":L.isOpen()?void 0:""})),isOpen:L.isOpen,contentPresence:I,nestedMenus:k,currentPlacement:x,pointerGraceTimeoutId:()=>a,autoFocus:v,listState:()=>ne,parentMenuContext:()=>r,triggerRef:f,contentRef:p,triggerId:d,contentId:h,setTriggerRef:g,setContentRef:b,open:Y,close:fe,toggle:F,focusContent:V,onItemEnter:At,onItemLeave:Pe,onTriggerLeave:dm,setPointerDir:U=>c=U,setPointerGraceTimeoutId:U=>a=U,setPointerGraceIntent:U=>l=U,registerNestedMenu:Q,registerItemToParentDomCollection:n?.registerItem,registerTriggerId:yn(u),registerContentId:yn(m)};return y(R,{get children(){return y(fs.Provider,{value:fm,get children(){return y(qd,T({anchorRef:f,contentRef:p,onCurrentPlacementChange:O},s))}})}})}const Yd=ce();function Xd(e){let t;const n=kt(),r=Et(),o=Le({id:n.generateId(`item-${Ae()}`)},e),[i,s]=j(o,["ref","textValue","disabled","closeOnSelect","checked","indeterminate","onSelect","onPointerMove","onPointerLeave","onPointerDown","onPointerUp","onClick","onKeyDown","onMouseDown","onFocus"]),[a,l]=P(),[c,d]=P(),[u,h]=P(),m=()=>r.listState().selectionManager(),f=()=>s.id,g=()=>m().focusedKey()===f(),p=()=>{i.onSelect?.(),i.closeOnSelect&&r.close(!0)};Uu({getItem:()=>({ref:()=>t,type:"item",key:f(),textValue:i.textValue??u()?.textContent??t?.textContent??"",disabled:i.disabled??!1})});const b=Pu({key:f,selectionManager:m,shouldSelectOnPressUp:!0,allowsDifferentPressOrigin:!0,disabled:()=>i.disabled},()=>t),v=_=>{ge(_,i.onPointerMove),_.pointerType==="mouse"&&(i.disabled?r.onItemLeave(_):(r.onItemEnter(_),_.defaultPrevented||(de(_.currentTarget),r.listState().selectionManager().setFocused(!0),r.listState().selectionManager().setFocusedKey(f()))))},w=_=>{ge(_,i.onPointerLeave),_.pointerType==="mouse"&&r.onItemLeave(_)},x=_=>{ge(_,i.onPointerUp),!i.disabled&&_.button===0&&p()},O=_=>{if(ge(_,i.onKeyDown),!_.repeat&&!i.disabled)switch(_.key){case"Enter":case" ":p();break}},k=C(()=>{if(i.indeterminate)return"mixed";if(i.checked!=null)return i.checked}),E=C(()=>({"data-indeterminate":i.indeterminate?"":void 0,"data-checked":i.checked&&!i.indeterminate?"":void 0,"data-disabled":i.disabled?"":void 0,"data-highlighted":g()?"":void 0})),$={isChecked:()=>i.checked,dataset:E,setLabelRef:h,generateId:ci(()=>s.id),registerLabel:yn(l),registerDescription:yn(d)};return y(Yd.Provider,{value:$,get children(){return y(bn,T({as:"div",ref(_){var R=ot(L=>t=L,i.ref);typeof R=="function"&&R(_)},get tabIndex(){return b.tabIndex()},get"aria-checked"(){return k()},get"aria-disabled"(){return i.disabled},get"aria-labelledby"(){return a()},get"aria-describedby"(){return c()},get"data-key"(){return b.dataKey()},get onPointerDown(){return we([i.onPointerDown,b.onPointerDown])},get onPointerUp(){return we([x,b.onPointerUp])},get onClick(){return we([i.onClick,b.onClick])},get onKeyDown(){return we([O,b.onKeyDown])},get onMouseDown(){return we([i.onMouseDown,b.onMouseDown])},get onFocus(){return we([i.onFocus,b.onFocus])},onPointerMove:v,onPointerLeave:w},E,s))}})}const Jd=ce();function ps(){return he(Jd)}function Zd(e){let t;const n=kt(),r=Et(),o=ps(),i=Le({id:n.generateId(`content-${Ae()}`)},e),[s,a]=j(i,["ref","id","style","onOpenAutoFocus","onCloseAutoFocus","onEscapeKeyDown","onFocusOutside","onPointerEnter","onPointerMove","onKeyDown","onMouseDown","onFocusIn","onFocusOut"]);let l=0;const c=()=>r.parentMenuContext()==null&&o===void 0&&n.isModal(),d=Lu({selectionManager:r.listState().selectionManager,collection:r.listState().collection,autoFocus:r.autoFocus,deferAutoFocus:!0,shouldFocusWrap:!0,disallowTypeAhead:()=>!r.listState().selectionManager().isFocused()},()=>t);iu({trapFocus:()=>c()&&r.isOpen(),onMountAutoFocus:p=>{o===void 0&&s.onOpenAutoFocus?.(p)},onUnmountAutoFocus:s.onCloseAutoFocus},()=>t);const u=p=>{if(De(p.currentTarget,p.target)&&(p.key==="Tab"&&r.isOpen()&&p.preventDefault(),o!==void 0&&p.currentTarget.getAttribute("aria-haspopup")!=="true"))switch(p.key){case"ArrowRight":p.stopPropagation(),p.preventDefault(),r.close(!0),o.setAutoFocusMenu(!0),o.nextMenu();break;case"ArrowLeft":if(p.currentTarget.hasAttribute("data-closed"))break;p.stopPropagation(),p.preventDefault(),r.close(!0),o.setAutoFocusMenu(!0),o.previousMenu();break}},h=p=>{s.onEscapeKeyDown?.(p),o?.setAutoFocusMenu(!1),r.close(!0)},m=p=>{s.onFocusOutside?.(p),n.isModal()&&p.preventDefault()},f=p=>{ge(p,s.onPointerEnter),r.isOpen()&&(r.parentMenuContext()?.listState().selectionManager().setFocused(!1),r.parentMenuContext()?.listState().selectionManager().setFocusedKey(void 0))},g=p=>{if(ge(p,s.onPointerMove),p.pointerType!=="mouse")return;const b=p.target,v=l!==p.clientX;De(p.currentTarget,b)&&v&&(r.setPointerDir(p.clientX>l?"right":"left"),l=p.clientX)};return D(()=>K(r.registerContentId(s.id))),y(Z,{get when(){return r.contentPresence.isPresent()},get children(){return y(td,{get children(){return y(Qu,T({ref(p){var b=ot(v=>{r.setContentRef(v),r.contentPresence.setRef(v),t=v},s.ref);typeof b=="function"&&b(p)},role:"menu",get id(){return s.id},get tabIndex(){return d.tabIndex()},get disableOutsidePointerEvents(){return C(()=>!!c())()&&r.isOpen()},get excludedElements(){return[r.triggerRef]},bypassTopMostLayerCheck:!0,get style(){return{"--kb-menu-content-transform-origin":"var(--kb-popper-content-transform-origin)",position:"relative",...s.style}},get"aria-labelledby"(){return r.triggerId()},onEscapeKeyDown:h,onFocusOutside:m,get onDismiss(){return r.close},get onKeyDown(){return we([s.onKeyDown,d.onKeyDown,u])},get onMouseDown(){return we([s.onMouseDown,d.onMouseDown])},get onFocusIn(){return we([s.onFocusIn,d.onFocusIn])},get onFocusOut(){return we([s.onFocusOut,d.onFocusOut])},onPointerEnter:f,onPointerMove:g},()=>r.dataset(),a))}})}})}function Qd(e){let t;const n=kt(),r=Et(),[o,i]=j(e,["ref"]);return Hi({element:()=>t??null,enabled:()=>r.isOpen()&&n.preventScroll()}),y(Zd,T({ref(s){var a=ot(l=>{t=l},o.ref);typeof a=="function"&&a(s)}},i))}function ef(e){return y(Xd,T({role:"menuitem",closeOnSelect:!0},e))}function tf(e){const t=Et();return y(Z,{get when(){return t.contentPresence.isPresent()},get children(){return y(qo,e)}})}function nf(e){const t=`menu-${Ae()}`,n=Le({id:t,modal:!0},e),[r,o]=j(n,["id","modal","preventScroll","forceMount","open","defaultOpen","onOpenChange","value"]),i=wi({open:()=>r.open,defaultOpen:()=>r.defaultOpen,onOpenChange:a=>r.onOpenChange?.(a)}),s={isModal:()=>r.modal??!0,preventScroll:()=>r.preventScroll??s.isModal(),forceMount:()=>r.forceMount??!1,generateId:ci(()=>r.id),value:()=>r.value};return y(gs.Provider,{value:s,get children(){return y(Gd,T({get open(){return i.isOpen()},get onOpenChange(){return i.setIsOpen}},o))}})}function rf(e){const t=kt(),n=Et(),r=ps(),o=Le({id:t.generateId("trigger")},e),[i,s]=j(o,["ref","id","disabled","onPointerDown","onClick","onKeyDown","onMouseOver","onFocus"]);let a;r!==void 0&&(a=t.value()??i.id,D(()=>{r.registerMenu(a,[n.contentRef(),...n.nestedMenus()])}),D(()=>{r.value()===a?(n.triggerRef()?.focus(),r.autoFocusMenu()&&n.open(!0)):n.close(!0)}),D(()=>{n.isOpen()&&r.setValue(a)}),K(()=>{r.unregisterMenu(a)}),r.lastValue()===void 0&&r.setLastValue(a));const l=()=>{r?.setAutoFocusMenu(!0),r!==void 0?n.toggle(!1):n.toggle(!0),r!==void 0&&!n.isOpen()&&r.value()===a&&r.closeMenu()},c=f=>{ge(f,i.onPointerDown),f.currentTarget.dataset.pointerType=f.pointerType,!i.disabled&&f.pointerType!=="touch"&&f.button===0&&l()},d=f=>{ge(f,i.onClick),i.disabled||f.currentTarget.dataset.pointerType==="touch"&&l()},u=f=>{if(ge(f,i.onKeyDown),!i.disabled)switch(f.key){case"Enter":case" ":case"ArrowDown":f.stopPropagation(),f.preventDefault(),Hc(f.currentTarget),n.toggle("first");break;case"ArrowUp":f.stopPropagation(),f.preventDefault(),n.toggle("last");break;case"ArrowRight":if(r===void 0)break;f.stopPropagation(),f.preventDefault(),r.nextMenu();break;case"ArrowLeft":if(r===void 0)break;f.stopPropagation(),f.preventDefault(),r.previousMenu();break}},h=f=>{ge(f,i.onMouseOver),!i.disabled&&r!==void 0&&r.value()!==void 0&&r.setValue(a)},m=f=>{ge(f,i.onFocus),r!==void 0&&r.setValue(a)};return D(()=>K(n.registerTriggerId(i.id))),y(Ru,T({ref(f){var g=ot(n.setTriggerRef,i.ref);typeof g=="function"&&g(f)},get id(){return i.id},get disabled(){return i.disabled},"aria-haspopup":"true",get"aria-expanded"(){return n.isOpen()},get"aria-controls"(){return C(()=>!!n.isOpen())()?n.contentId():void 0},get"data-highlighted"(){return a!==void 0&&r?.value()===a?!0:void 0},get tabIndex(){return r!==void 0?r.value()===a||r.lastValue()===a?0:-1:void 0},onPointerDown:c,onMouseOver:h,onClick:d,onKeyDown:u,onFocus:m,role:r!==void 0?"menuitem":void 0},()=>n.dataset(),s))}function of(e){const t=kt(),n=Et(),[r,o]=j(e,["onCloseAutoFocus","onInteractOutside"]);let i=!1;return y(Qd,T({onCloseAutoFocus:l=>{r.onCloseAutoFocus?.(l),i||de(n.triggerRef()),i=!1,l.preventDefault()},onInteractOutside:l=>{r.onInteractOutside?.(l),(!t.isModal()||l.detail.isContextMenu)&&(i=!0)}},o))}function sf(e){const t=`dropdownmenu-${Ae()}`,n=Le({id:t},e);return y(nf,n)}function af(e){return ve({a:{xmlns:"http://www.w3.org/2000/svg",class:"icon icon-tabler icon-tabler-circle-check-filled",width:"24",height:"24",viewBox:"0 0 24 24","stroke-width":"2",stroke:"currentColor",fill:"none","stroke-linecap":"round","stroke-linejoin":"round"},c:'<path stroke="none" d="M0 0h24v24H0z" fill="none"/><path d="M17 3.34a10 10 0 1 1 -14.995 8.984l-.005 -.324l.005 -.324a10 10 0 0 1 14.995 -8.336zm-1.293 5.953a1 1 0 0 0 -1.32 -.083l-.094 .083l-3.293 3.292l-1.293 -1.292l-.094 -.083a1 1 0 0 0 -1.403 1.403l.083 .094l2 2l.094 .083a1 1 0 0 0 1.226 0l.094 -.083l4 -4l.083 -.094a1 1 0 0 0 -.083 -1.32z" stroke-width="0" fill="currentColor"/>'},e)}function lf(e){return ve({a:{xmlns:"http://www.w3.org/2000/svg",class:"icon icon-tabler icon-tabler-circle",width:"24",height:"24",viewBox:"0 0 24 24","stroke-width":"2",stroke:"currentColor",fill:"none","stroke-linecap":"round","stroke-linejoin":"round"},c:'<path stroke="none" d="M0 0h24v24H0z" fill="none"/><path d="M12 12m-9 0a9 9 0 1 0 18 0a9 9 0 1 0 -18 0"/>'},e)}function cf(e){return ve({a:{xmlns:"http://www.w3.org/2000/svg",class:"icon icon-tabler icon-tabler-file-download",width:"24",height:"24",viewBox:"0 0 24 24","stroke-width":"2",stroke:"currentColor",fill:"none","stroke-linecap":"round","stroke-linejoin":"round"},c:'<path stroke="none" d="M0 0h24v24H0z" fill="none"/><path d="M14 3v4a1 1 0 0 0 1 1h4"/><path d="M17 21h-10a2 2 0 0 1 -2 -2v-14a2 2 0 0 1 2 -2h7l5 5v11a2 2 0 0 1 -2 2z"/><path d="M12 17v-6"/><path d="M9.5 14.5l2.5 2.5l2.5 -2.5"/>'},e)}const uf=e=>y(sf,T({gutter:4},e)),df=rf,ff=e=>{const[,t]=j(e,["class"]);return y(tf,{get mount(){return Wn()},get children(){return y(of,T({get class(){return Ge("z-50 min-w-[8rem] origin-[var(--kb-menu-content-transform-origin)] animate-content-hide overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md data-[expanded]:animate-content-show",e.class)}},t))}})},hf=e=>{const[,t]=j(e,["class"]);return y(ef,T({get class(){return Ge("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e.class)}},t))};function gf(e){return e.type==="buttons"&&e.buttons.options.length>10?{list:{text:e.buttons.text,options:[{items:e.buttons.options}]},type:"list",origin:e.origin,createdAt:e.createdAt}:e}function pf(e){if(Array.isArray(e)){console.info("----------------------------------------------------------");for(const t of e)console.info("Executed:",t.type),console.info(t)}}async function mf(e,t,n){const r=`${Jt}/v1/messages`,o={credentials:"include",method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({channelId:n,postback:t,type:"text",text:e})};await fetch(r,o)}async function yf(e,t,n){if(!e||!t||!n)return;const r=`${Jt}/v1/widget/${e}/restart`,o={credentials:"include",method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({contactId:t,interactionId:n})};await fetch(r,o)}const $e=Object.create(null);$e.open="0",$e.close="1",$e.ping="2",$e.pong="3",$e.message="4",$e.upgrade="5",$e.noop="6";const _n=Object.create(null);Object.keys($e).forEach(e=>{_n[$e[e]]=e});const Fr={type:"error",data:"parser error"},ms=typeof Blob=="function"||typeof Blob<"u"&&Object.prototype.toString.call(Blob)==="[object BlobConstructor]",ys=typeof ArrayBuffer=="function",bs=e=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(e):e&&e.buffer instanceof ArrayBuffer,Nr=({type:e,data:t},n,r)=>ms&&t instanceof Blob?n?r(t):vs(t,r):ys&&(t instanceof ArrayBuffer||bs(t))?n?r(t):vs(new Blob([t]),r):r($e[e]+(t||"")),vs=(e,t)=>{const n=new FileReader;return n.onload=function(){const r=n.result.split(",")[1];t("b"+(r||""))},n.readAsDataURL(e)};function ws(e){return e instanceof Uint8Array?e:e instanceof ArrayBuffer?new Uint8Array(e):new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}let Kr;function bf(e,t){if(ms&&e.data instanceof Blob)return e.data.arrayBuffer().then(ws).then(t);if(ys&&(e.data instanceof ArrayBuffer||bs(e.data)))return t(ws(e.data));Nr(e,!1,n=>{Kr||(Kr=new TextEncoder),t(Kr.encode(n))})}const xs="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Wt=typeof Uint8Array>"u"?[]:new Uint8Array(256);for(let e=0;e<xs.length;e++)Wt[xs.charCodeAt(e)]=e;const vf=e=>{let t=e.length*.75,n=e.length,r,o=0,i,s,a,l;e[e.length-1]==="="&&(t--,e[e.length-2]==="="&&t--);const c=new ArrayBuffer(t),d=new Uint8Array(c);for(r=0;r<n;r+=4)i=Wt[e.charCodeAt(r)],s=Wt[e.charCodeAt(r+1)],a=Wt[e.charCodeAt(r+2)],l=Wt[e.charCodeAt(r+3)],d[o++]=i<<2|s>>4,d[o++]=(s&15)<<4|a>>2,d[o++]=(a&3)<<6|l&63;return c},wf=typeof ArrayBuffer=="function",Br=(e,t)=>{if(typeof e!="string")return{type:"message",data:Ss(e,t)};const n=e.charAt(0);return n==="b"?{type:"message",data:xf(e.substring(1),t)}:_n[n]?e.length>1?{type:_n[n],data:e.substring(1)}:{type:_n[n]}:Fr},xf=(e,t)=>{if(wf){const n=vf(e);return Ss(n,t)}else return{base64:!0,data:e}},Ss=(e,t)=>{switch(t){case"blob":return e instanceof Blob?e:new Blob([e]);case"arraybuffer":default:return e instanceof ArrayBuffer?e:e.buffer}},Es="",Sf=(e,t)=>{const n=e.length,r=new Array(n);let o=0;e.forEach((i,s)=>{Nr(i,!1,a=>{r[s]=a,++o===n&&t(r.join(Es))})})},Ef=(e,t)=>{const n=e.split(Es),r=[];for(let o=0;o<n.length;o++){const i=Br(n[o],t);if(r.push(i),i.type==="error")break}return r};function kf(){return new TransformStream({transform(e,t){bf(e,n=>{const r=n.length;let o;if(r<126)o=new Uint8Array(1),new DataView(o.buffer).setUint8(0,r);else if(r<65536){o=new Uint8Array(3);const i=new DataView(o.buffer);i.setUint8(0,126),i.setUint16(1,r)}else{o=new Uint8Array(9);const i=new DataView(o.buffer);i.setUint8(0,127),i.setBigUint64(1,BigInt(r))}e.data&&typeof e.data!="string"&&(o[0]|=128),t.enqueue(o),t.enqueue(n)})}})}let zr;function Pn(e){return e.reduce((t,n)=>t+n.length,0)}function An(e,t){if(e[0].length===t)return e.shift();const n=new Uint8Array(t);let r=0;for(let o=0;o<t;o++)n[o]=e[0][r++],r===e[0].length&&(e.shift(),r=0);return e.length&&r<e[0].length&&(e[0]=e[0].slice(r)),n}function Cf(e,t){zr||(zr=new TextDecoder);const n=[];let r=0,o=-1,i=!1;return new TransformStream({transform(s,a){for(n.push(s);;){if(r===0){if(Pn(n)<1)break;const l=An(n,1);i=(l[0]&128)===128,o=l[0]&127,o<126?r=3:o===126?r=1:r=2}else if(r===1){if(Pn(n)<2)break;const l=An(n,2);o=new DataView(l.buffer,l.byteOffset,l.length).getUint16(0),r=3}else if(r===2){if(Pn(n)<8)break;const l=An(n,8),c=new DataView(l.buffer,l.byteOffset,l.length),d=c.getUint32(0);if(d>Math.pow(2,21)-1){a.enqueue(Fr);break}o=d*Math.pow(2,32)+c.getUint32(4),r=3}else{if(Pn(n)<o)break;const l=An(n,o);a.enqueue(Br(i?l:zr.decode(l),t)),r=0}if(o===0||o>e){a.enqueue(Fr);break}}}})}const ks=4;function te(e){if(e)return Of(e)}function Of(e){for(var t in te.prototype)e[t]=te.prototype[t];return e}te.prototype.on=te.prototype.addEventListener=function(e,t){return this._callbacks=this._callbacks||{},(this._callbacks["$"+e]=this._callbacks["$"+e]||[]).push(t),this},te.prototype.once=function(e,t){function n(){this.off(e,n),t.apply(this,arguments)}return n.fn=t,this.on(e,n),this},te.prototype.off=te.prototype.removeListener=te.prototype.removeAllListeners=te.prototype.removeEventListener=function(e,t){if(this._callbacks=this._callbacks||{},arguments.length==0)return this._callbacks={},this;var n=this._callbacks["$"+e];if(!n)return this;if(arguments.length==1)return delete this._callbacks["$"+e],this;for(var r,o=0;o<n.length;o++)if(r=n[o],r===t||r.fn===t){n.splice(o,1);break}return n.length===0&&delete this._callbacks["$"+e],this},te.prototype.emit=function(e){this._callbacks=this._callbacks||{};for(var t=new Array(arguments.length-1),n=this._callbacks["$"+e],r=1;r<arguments.length;r++)t[r-1]=arguments[r];if(n){n=n.slice(0);for(var r=0,o=n.length;r<o;++r)n[r].apply(this,t)}return this},te.prototype.emitReserved=te.prototype.emit,te.prototype.listeners=function(e){return this._callbacks=this._callbacks||{},this._callbacks["$"+e]||[]},te.prototype.hasListeners=function(e){return!!this.listeners(e).length};const Tn=typeof Promise=="function"&&typeof Promise.resolve=="function"?t=>Promise.resolve().then(t):(t,n)=>n(t,0),Se=typeof self<"u"?self:typeof window<"u"?window:Function("return this")(),_f="arraybuffer";function mm(){}function Cs(e,...t){return t.reduce((n,r)=>(e.hasOwnProperty(r)&&(n[r]=e[r]),n),{})}const Pf=Se.setTimeout,Af=Se.clearTimeout;function Dn(e,t){t.useNativeTimers?(e.setTimeoutFn=Pf.bind(Se),e.clearTimeoutFn=Af.bind(Se)):(e.setTimeoutFn=Se.setTimeout.bind(Se),e.clearTimeoutFn=Se.clearTimeout.bind(Se))}const Tf=1.33;function Df(e){return typeof e=="string"?Lf(e):Math.ceil((e.byteLength||e.size)*Tf)}function Lf(e){let t=0,n=0;for(let r=0,o=e.length;r<o;r++)t=e.charCodeAt(r),t<128?n+=1:t<2048?n+=2:t<55296||t>=57344?n+=3:(r++,n+=4);return n}function Os(){return Date.now().toString(36).substring(3)+Math.random().toString(36).substring(2,5)}function Mf(e){let t="";for(let n in e)e.hasOwnProperty(n)&&(t.length&&(t+="&"),t+=encodeURIComponent(n)+"="+encodeURIComponent(e[n]));return t}function If(e){let t={},n=e.split("&");for(let r=0,o=n.length;r<o;r++){let i=n[r].split("=");t[decodeURIComponent(i[0])]=decodeURIComponent(i[1])}return t}class Rf extends Error{constructor(t,n,r){super(t),this.description=n,this.context=r,this.type="TransportError"}}class Vr extends te{constructor(t){super(),this.writable=!1,Dn(this,t),this.opts=t,this.query=t.query,this.socket=t.socket,this.supportsBinary=!t.forceBase64}onError(t,n,r){return super.emitReserved("error",new Rf(t,n,r)),this}open(){return this.readyState="opening",this.doOpen(),this}close(){return(this.readyState==="opening"||this.readyState==="open")&&(this.doClose(),this.onClose()),this}send(t){this.readyState==="open"&&this.write(t)}onOpen(){this.readyState="open",this.writable=!0,super.emitReserved("open")}onData(t){const n=Br(t,this.socket.binaryType);this.onPacket(n)}onPacket(t){super.emitReserved("packet",t)}onClose(t){this.readyState="closed",super.emitReserved("close",t)}pause(t){}createUri(t,n={}){return t+"://"+this._hostname()+this._port()+this.opts.path+this._query(n)}_hostname(){const t=this.opts.hostname;return t.indexOf(":")===-1?t:"["+t+"]"}_port(){return this.opts.port&&(this.opts.secure&&+(this.opts.port!==443)||!this.opts.secure&&Number(this.opts.port)!==80)?":"+this.opts.port:""}_query(t){const n=Mf(t);return n.length?"?"+n:""}}class $f extends Vr{constructor(){super(...arguments),this._polling=!1}get name(){return"polling"}doOpen(){this._poll()}pause(t){this.readyState="pausing";const n=()=>{this.readyState="paused",t()};if(this._polling||!this.writable){let r=0;this._polling&&(r++,this.once("pollComplete",function(){--r||n()})),this.writable||(r++,this.once("drain",function(){--r||n()}))}else n()}_poll(){this._polling=!0,this.doPoll(),this.emitReserved("poll")}onData(t){const n=r=>{if(this.readyState==="opening"&&r.type==="open"&&this.onOpen(),r.type==="close")return this.onClose({description:"transport closed by the server"}),!1;this.onPacket(r)};Ef(t,this.socket.binaryType).forEach(n),this.readyState!=="closed"&&(this._polling=!1,this.emitReserved("pollComplete"),this.readyState==="open"&&this._poll())}doClose(){const t=()=>{this.write([{type:"close"}])};this.readyState==="open"?t():this.once("open",t)}write(t){this.writable=!1,Sf(t,n=>{this.doWrite(n,()=>{this.writable=!0,this.emitReserved("drain")})})}uri(){const t=this.opts.secure?"https":"http",n=this.query||{};return this.opts.timestampRequests!==!1&&(n[this.opts.timestampParam]=Os()),!this.supportsBinary&&!n.sid&&(n.b64=1),this.createUri(t,n)}}let _s=!1;try{_s=typeof XMLHttpRequest<"u"&&"withCredentials"in new XMLHttpRequest}catch{}const Ff=_s;function Nf(){}class Kf extends $f{constructor(t){if(super(t),typeof location<"u"){const n=location.protocol==="https:";let r=location.port;r||(r=n?"443":"80"),this.xd=typeof location<"u"&&t.hostname!==location.hostname||r!==t.port}}doWrite(t,n){const r=this.request({method:"POST",data:t});r.on("success",n),r.on("error",(o,i)=>{this.onError("xhr post error",o,i)})}doPoll(){const t=this.request();t.on("data",this.onData.bind(this)),t.on("error",(n,r)=>{this.onError("xhr poll error",n,r)}),this.pollXhr=t}}class Fe extends te{constructor(t,n,r){super(),this.createRequest=t,Dn(this,r),this._opts=r,this._method=r.method||"GET",this._uri=n,this._data=r.data!==void 0?r.data:null,this._create()}_create(){var t;const n=Cs(this._opts,"agent","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","autoUnref");n.xdomain=!!this._opts.xd;const r=this._xhr=this.createRequest(n);try{r.open(this._method,this._uri,!0);try{if(this._opts.extraHeaders){r.setDisableHeaderCheck&&r.setDisableHeaderCheck(!0);for(let o in this._opts.extraHeaders)this._opts.extraHeaders.hasOwnProperty(o)&&r.setRequestHeader(o,this._opts.extraHeaders[o])}}catch{}if(this._method==="POST")try{r.setRequestHeader("Content-type","text/plain;charset=UTF-8")}catch{}try{r.setRequestHeader("Accept","*/*")}catch{}(t=this._opts.cookieJar)===null||t===void 0||t.addCookies(r),"withCredentials"in r&&(r.withCredentials=this._opts.withCredentials),this._opts.requestTimeout&&(r.timeout=this._opts.requestTimeout),r.onreadystatechange=()=>{var o;r.readyState===3&&((o=this._opts.cookieJar)===null||o===void 0||o.parseCookies(r.getResponseHeader("set-cookie"))),r.readyState===4&&(r.status===200||r.status===1223?this._onLoad():this.setTimeoutFn(()=>{this._onError(typeof r.status=="number"?r.status:0)},0))},r.send(this._data)}catch(o){this.setTimeoutFn(()=>{this._onError(o)},0);return}typeof document<"u"&&(this._index=Fe.requestsCount++,Fe.requests[this._index]=this)}_onError(t){this.emitReserved("error",t,this._xhr),this._cleanup(!0)}_cleanup(t){if(!(typeof this._xhr>"u"||this._xhr===null)){if(this._xhr.onreadystatechange=Nf,t)try{this._xhr.abort()}catch{}typeof document<"u"&&delete Fe.requests[this._index],this._xhr=null}}_onLoad(){const t=this._xhr.responseText;t!==null&&(this.emitReserved("data",t),this.emitReserved("success"),this._cleanup())}abort(){this._cleanup()}}if(Fe.requestsCount=0,Fe.requests={},typeof document<"u"){if(typeof attachEvent=="function")attachEvent("onunload",Ps);else if(typeof addEventListener=="function"){const e="onpagehide"in Se?"pagehide":"unload";addEventListener(e,Ps,!1)}}function Ps(){for(let e in Fe.requests)Fe.requests.hasOwnProperty(e)&&Fe.requests[e].abort()}const Bf=function(){const e=As({xdomain:!1});return e&&e.responseType!==null}();class zf extends Kf{constructor(t){super(t);const n=t&&t.forceBase64;this.supportsBinary=Bf&&!n}request(t={}){return Object.assign(t,{xd:this.xd},this.opts),new Fe(As,this.uri(),t)}}function As(e){const t=e.xdomain;try{if(typeof XMLHttpRequest<"u"&&(!t||Ff))return new XMLHttpRequest}catch{}if(!t)try{return new Se[["Active"].concat("Object").join("X")]("Microsoft.XMLHTTP")}catch{}}const Ts=typeof navigator<"u"&&typeof navigator.product=="string"&&navigator.product.toLowerCase()==="reactnative";class Vf extends Vr{get name(){return"websocket"}doOpen(){const t=this.uri(),n=this.opts.protocols,r=Ts?{}:Cs(this.opts,"agent","perMessageDeflate","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","localAddress","protocolVersion","origin","maxPayload","family","checkServerIdentity");this.opts.extraHeaders&&(r.headers=this.opts.extraHeaders);try{this.ws=this.createSocket(t,n,r)}catch(o){return this.emitReserved("error",o)}this.ws.binaryType=this.socket.binaryType,this.addEventListeners()}addEventListeners(){this.ws.onopen=()=>{this.opts.autoUnref&&this.ws._socket.unref(),this.onOpen()},this.ws.onclose=t=>this.onClose({description:"websocket connection closed",context:t}),this.ws.onmessage=t=>this.onData(t.data),this.ws.onerror=t=>this.onError("websocket error",t)}write(t){this.writable=!1;for(let n=0;n<t.length;n++){const r=t[n],o=n===t.length-1;Nr(r,this.supportsBinary,i=>{try{this.doWrite(r,i)}catch{}o&&Tn(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){typeof this.ws<"u"&&(this.ws.onerror=()=>{},this.ws.close(),this.ws=null)}uri(){const t=this.opts.secure?"wss":"ws",n=this.query||{};return this.opts.timestampRequests&&(n[this.opts.timestampParam]=Os()),this.supportsBinary||(n.b64=1),this.createUri(t,n)}}const Ur=Se.WebSocket||Se.MozWebSocket;class Uf extends Vf{createSocket(t,n,r){return Ts?new Ur(t,n,r):n?new Ur(t,n):new Ur(t)}doWrite(t,n){this.ws.send(n)}}class jf extends Vr{get name(){return"webtransport"}doOpen(){try{this._transport=new WebTransport(this.createUri("https"),this.opts.transportOptions[this.name])}catch(t){return this.emitReserved("error",t)}this._transport.closed.then(()=>{this.onClose()}).catch(t=>{this.onError("webtransport error",t)}),this._transport.ready.then(()=>{this._transport.createBidirectionalStream().then(t=>{const n=Cf(Number.MAX_SAFE_INTEGER,this.socket.binaryType),r=t.readable.pipeThrough(n).getReader(),o=kf();o.readable.pipeTo(t.writable),this._writer=o.writable.getWriter();const i=()=>{r.read().then(({done:a,value:l})=>{a||(this.onPacket(l),i())}).catch(a=>{})};i();const s={type:"open"};this.query.sid&&(s.data=`{"sid":"${this.query.sid}"}`),this._writer.write(s).then(()=>this.onOpen())})})}write(t){this.writable=!1;for(let n=0;n<t.length;n++){const r=t[n],o=n===t.length-1;this._writer.write(r).then(()=>{o&&Tn(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){var t;(t=this._transport)===null||t===void 0||t.close()}}const Hf={websocket:Uf,webtransport:jf,polling:zf},qf=/^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,Wf=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"];function jr(e){if(e.length>8e3)throw"URI too long";const t=e,n=e.indexOf("["),r=e.indexOf("]");n!=-1&&r!=-1&&(e=e.substring(0,n)+e.substring(n,r).replace(/:/g,";")+e.substring(r,e.length));let o=qf.exec(e||""),i={},s=14;for(;s--;)i[Wf[s]]=o[s]||"";return n!=-1&&r!=-1&&(i.source=t,i.host=i.host.substring(1,i.host.length-1).replace(/;/g,":"),i.authority=i.authority.replace("[","").replace("]","").replace(/;/g,":"),i.ipv6uri=!0),i.pathNames=Gf(i,i.path),i.queryKey=Yf(i,i.query),i}function Gf(e,t){const n=/\/{2,9}/g,r=t.replace(n,"/").split("/");return(t.slice(0,1)=="/"||t.length===0)&&r.splice(0,1),t.slice(-1)=="/"&&r.splice(r.length-1,1),r}function Yf(e,t){const n={};return t.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,function(r,o,i){o&&(n[o]=i)}),n}const Hr=typeof addEventListener=="function"&&typeof removeEventListener=="function",Ln=[];Hr&&addEventListener("offline",()=>{Ln.forEach(e=>e())},!1);class Ze extends te{constructor(t,n){if(super(),this.binaryType=_f,this.writeBuffer=[],this._prevBufferLen=0,this._pingInterval=-1,this._pingTimeout=-1,this._maxPayload=-1,this._pingTimeoutTime=1/0,t&&typeof t=="object"&&(n=t,t=null),t){const r=jr(t);n.hostname=r.host,n.secure=r.protocol==="https"||r.protocol==="wss",n.port=r.port,r.query&&(n.query=r.query)}else n.host&&(n.hostname=jr(n.host).host);Dn(this,n),this.secure=n.secure!=null?n.secure:typeof location<"u"&&location.protocol==="https:",n.hostname&&!n.port&&(n.port=this.secure?"443":"80"),this.hostname=n.hostname||(typeof location<"u"?location.hostname:"localhost"),this.port=n.port||(typeof location<"u"&&location.port?location.port:this.secure?"443":"80"),this.transports=[],this._transportsByName={},n.transports.forEach(r=>{const o=r.prototype.name;this.transports.push(o),this._transportsByName[o]=r}),this.opts=Object.assign({path:"/engine.io",agent:!1,withCredentials:!1,upgrade:!0,timestampParam:"t",rememberUpgrade:!1,addTrailingSlash:!0,rejectUnauthorized:!0,perMessageDeflate:{threshold:1024},transportOptions:{},closeOnBeforeunload:!1},n),this.opts.path=this.opts.path.replace(/\/$/,"")+(this.opts.addTrailingSlash?"/":""),typeof this.opts.query=="string"&&(this.opts.query=If(this.opts.query)),Hr&&(this.opts.closeOnBeforeunload&&(this._beforeunloadEventListener=()=>{this.transport&&(this.transport.removeAllListeners(),this.transport.close())},addEventListener("beforeunload",this._beforeunloadEventListener,!1)),this.hostname!=="localhost"&&(this._offlineEventListener=()=>{this._onClose("transport close",{description:"network connection lost"})},Ln.push(this._offlineEventListener))),this.opts.withCredentials&&(this._cookieJar=void 0),this._open()}createTransport(t){const n=Object.assign({},this.opts.query);n.EIO=ks,n.transport=t,this.id&&(n.sid=this.id);const r=Object.assign({},this.opts,{query:n,socket:this,hostname:this.hostname,secure:this.secure,port:this.port},this.opts.transportOptions[t]);return new this._transportsByName[t](r)}_open(){if(this.transports.length===0){this.setTimeoutFn(()=>{this.emitReserved("error","No transports available")},0);return}const t=this.opts.rememberUpgrade&&Ze.priorWebsocketSuccess&&this.transports.indexOf("websocket")!==-1?"websocket":this.transports[0];this.readyState="opening";const n=this.createTransport(t);n.open(),this.setTransport(n)}setTransport(t){this.transport&&this.transport.removeAllListeners(),this.transport=t,t.on("drain",this._onDrain.bind(this)).on("packet",this._onPacket.bind(this)).on("error",this._onError.bind(this)).on("close",n=>this._onClose("transport close",n))}onOpen(){this.readyState="open",Ze.priorWebsocketSuccess=this.transport.name==="websocket",this.emitReserved("open"),this.flush()}_onPacket(t){if(this.readyState==="opening"||this.readyState==="open"||this.readyState==="closing")switch(this.emitReserved("packet",t),this.emitReserved("heartbeat"),t.type){case"open":this.onHandshake(JSON.parse(t.data));break;case"ping":this._sendPacket("pong"),this.emitReserved("ping"),this.emitReserved("pong"),this._resetPingTimeout();break;case"error":const n=new Error("server error");n.code=t.data,this._onError(n);break;case"message":this.emitReserved("data",t.data),this.emitReserved("message",t.data);break}}onHandshake(t){this.emitReserved("handshake",t),this.id=t.sid,this.transport.query.sid=t.sid,this._pingInterval=t.pingInterval,this._pingTimeout=t.pingTimeout,this._maxPayload=t.maxPayload,this.onOpen(),this.readyState!=="closed"&&this._resetPingTimeout()}_resetPingTimeout(){this.clearTimeoutFn(this._pingTimeoutTimer);const t=this._pingInterval+this._pingTimeout;this._pingTimeoutTime=Date.now()+t,this._pingTimeoutTimer=this.setTimeoutFn(()=>{this._onClose("ping timeout")},t),this.opts.autoUnref&&this._pingTimeoutTimer.unref()}_onDrain(){this.writeBuffer.splice(0,this._prevBufferLen),this._prevBufferLen=0,this.writeBuffer.length===0?this.emitReserved("drain"):this.flush()}flush(){if(this.readyState!=="closed"&&this.transport.writable&&!this.upgrading&&this.writeBuffer.length){const t=this._getWritablePackets();this.transport.send(t),this._prevBufferLen=t.length,this.emitReserved("flush")}}_getWritablePackets(){if(!(this._maxPayload&&this.transport.name==="polling"&&this.writeBuffer.length>1))return this.writeBuffer;let n=1;for(let r=0;r<this.writeBuffer.length;r++){const o=this.writeBuffer[r].data;if(o&&(n+=Df(o)),r>0&&n>this._maxPayload)return this.writeBuffer.slice(0,r);n+=2}return this.writeBuffer}_hasPingExpired(){if(!this._pingTimeoutTime)return!0;const t=Date.now()>this._pingTimeoutTime;return t&&(this._pingTimeoutTime=0,Tn(()=>{this._onClose("ping timeout")},this.setTimeoutFn)),t}write(t,n,r){return this._sendPacket("message",t,n,r),this}send(t,n,r){return this._sendPacket("message",t,n,r),this}_sendPacket(t,n,r,o){if(typeof n=="function"&&(o=n,n=void 0),typeof r=="function"&&(o=r,r=null),this.readyState==="closing"||this.readyState==="closed")return;r=r||{},r.compress=r.compress!==!1;const i={type:t,data:n,options:r};this.emitReserved("packetCreate",i),this.writeBuffer.push(i),o&&this.once("flush",o),this.flush()}close(){const t=()=>{this._onClose("forced close"),this.transport.close()},n=()=>{this.off("upgrade",n),this.off("upgradeError",n),t()},r=()=>{this.once("upgrade",n),this.once("upgradeError",n)};return(this.readyState==="opening"||this.readyState==="open")&&(this.readyState="closing",this.writeBuffer.length?this.once("drain",()=>{this.upgrading?r():t()}):this.upgrading?r():t()),this}_onError(t){if(Ze.priorWebsocketSuccess=!1,this.opts.tryAllTransports&&this.transports.length>1&&this.readyState==="opening")return this.transports.shift(),this._open();this.emitReserved("error",t),this._onClose("transport error",t)}_onClose(t,n){if(this.readyState==="opening"||this.readyState==="open"||this.readyState==="closing"){if(this.clearTimeoutFn(this._pingTimeoutTimer),this.transport.removeAllListeners("close"),this.transport.close(),this.transport.removeAllListeners(),Hr&&(this._beforeunloadEventListener&&removeEventListener("beforeunload",this._beforeunloadEventListener,!1),this._offlineEventListener)){const r=Ln.indexOf(this._offlineEventListener);r!==-1&&Ln.splice(r,1)}this.readyState="closed",this.id=null,this.emitReserved("close",t,n),this.writeBuffer=[],this._prevBufferLen=0}}}Ze.protocol=ks;class Xf extends Ze{constructor(){super(...arguments),this._upgrades=[]}onOpen(){if(super.onOpen(),this.readyState==="open"&&this.opts.upgrade)for(let t=0;t<this._upgrades.length;t++)this._probe(this._upgrades[t])}_probe(t){let n=this.createTransport(t),r=!1;Ze.priorWebsocketSuccess=!1;const o=()=>{r||(n.send([{type:"ping",data:"probe"}]),n.once("packet",u=>{if(!r)if(u.type==="pong"&&u.data==="probe"){if(this.upgrading=!0,this.emitReserved("upgrading",n),!n)return;Ze.priorWebsocketSuccess=n.name==="websocket",this.transport.pause(()=>{r||this.readyState!=="closed"&&(d(),this.setTransport(n),n.send([{type:"upgrade"}]),this.emitReserved("upgrade",n),n=null,this.upgrading=!1,this.flush())})}else{const h=new Error("probe error");h.transport=n.name,this.emitReserved("upgradeError",h)}}))};function i(){r||(r=!0,d(),n.close(),n=null)}const s=u=>{const h=new Error("probe error: "+u);h.transport=n.name,i(),this.emitReserved("upgradeError",h)};function a(){s("transport closed")}function l(){s("socket closed")}function c(u){n&&u.name!==n.name&&i()}const d=()=>{n.removeListener("open",o),n.removeListener("error",s),n.removeListener("close",a),this.off("close",l),this.off("upgrading",c)};n.once("open",o),n.once("error",s),n.once("close",a),this.once("close",l),this.once("upgrading",c),this._upgrades.indexOf("webtransport")!==-1&&t!=="webtransport"?this.setTimeoutFn(()=>{r||n.open()},200):n.open()}onHandshake(t){this._upgrades=this._filterUpgrades(t.upgrades),super.onHandshake(t)}_filterUpgrades(t){const n=[];for(let r=0;r<t.length;r++)~this.transports.indexOf(t[r])&&n.push(t[r]);return n}}let Jf=class extends Xf{constructor(t,n={}){const r=typeof t=="object"?t:n;(!r.transports||r.transports&&typeof r.transports[0]=="string")&&(r.transports=(r.transports||["polling","websocket","webtransport"]).map(o=>Hf[o]).filter(o=>!!o)),super(t,r)}};function Zf(e,t="",n){let r=e;n=n||typeof location<"u"&&location,e==null&&(e=n.protocol+"//"+n.host),typeof e=="string"&&(e.charAt(0)==="/"&&(e.charAt(1)==="/"?e=n.protocol+e:e=n.host+e),/^(https?|wss?):\/\//.test(e)||(typeof n<"u"?e=n.protocol+"//"+e:e="https://"+e),r=jr(e)),r.port||(/^(http|ws)$/.test(r.protocol)?r.port="80":/^(http|ws)s$/.test(r.protocol)&&(r.port="443")),r.path=r.path||"/";const i=r.host.indexOf(":")!==-1?"["+r.host+"]":r.host;return r.id=r.protocol+"://"+i+":"+r.port+t,r.href=r.protocol+"://"+i+(n&&n.port===r.port?"":":"+r.port),r}const Qf=typeof ArrayBuffer=="function",eh=e=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(e):e.buffer instanceof ArrayBuffer,Ds=Object.prototype.toString,th=typeof Blob=="function"||typeof Blob<"u"&&Ds.call(Blob)==="[object BlobConstructor]",nh=typeof File=="function"||typeof File<"u"&&Ds.call(File)==="[object FileConstructor]";function qr(e){return Qf&&(e instanceof ArrayBuffer||eh(e))||th&&e instanceof Blob||nh&&e instanceof File}function Mn(e,t){if(!e||typeof e!="object")return!1;if(Array.isArray(e)){for(let n=0,r=e.length;n<r;n++)if(Mn(e[n]))return!0;return!1}if(qr(e))return!0;if(e.toJSON&&typeof e.toJSON=="function"&&arguments.length===1)return Mn(e.toJSON(),!0);for(const n in e)if(Object.prototype.hasOwnProperty.call(e,n)&&Mn(e[n]))return!0;return!1}function rh(e){const t=[],n=e.data,r=e;return r.data=Wr(n,t),r.attachments=t.length,{packet:r,buffers:t}}function Wr(e,t){if(!e)return e;if(qr(e)){const n={_placeholder:!0,num:t.length};return t.push(e),n}else if(Array.isArray(e)){const n=new Array(e.length);for(let r=0;r<e.length;r++)n[r]=Wr(e[r],t);return n}else if(typeof e=="object"&&!(e instanceof Date)){const n={};for(const r in e)Object.prototype.hasOwnProperty.call(e,r)&&(n[r]=Wr(e[r],t));return n}return e}function oh(e,t){return e.data=Gr(e.data,t),delete e.attachments,e}function Gr(e,t){if(!e)return e;if(e&&e._placeholder===!0){if(typeof e.num=="number"&&e.num>=0&&e.num<t.length)return t[e.num];throw new Error("illegal attachments")}else if(Array.isArray(e))for(let n=0;n<e.length;n++)e[n]=Gr(e[n],t);else if(typeof e=="object")for(const n in e)Object.prototype.hasOwnProperty.call(e,n)&&(e[n]=Gr(e[n],t));return e}const ih=["connect","connect_error","disconnect","disconnecting","newListener","removeListener"],sh=5;var z;(function(e){e[e.CONNECT=0]="CONNECT",e[e.DISCONNECT=1]="DISCONNECT",e[e.EVENT=2]="EVENT",e[e.ACK=3]="ACK",e[e.CONNECT_ERROR=4]="CONNECT_ERROR",e[e.BINARY_EVENT=5]="BINARY_EVENT",e[e.BINARY_ACK=6]="BINARY_ACK"})(z||(z={}));class ah{constructor(t){this.replacer=t}encode(t){return(t.type===z.EVENT||t.type===z.ACK)&&Mn(t)?this.encodeAsBinary({type:t.type===z.EVENT?z.BINARY_EVENT:z.BINARY_ACK,nsp:t.nsp,data:t.data,id:t.id}):[this.encodeAsString(t)]}encodeAsString(t){let n=""+t.type;return(t.type===z.BINARY_EVENT||t.type===z.BINARY_ACK)&&(n+=t.attachments+"-"),t.nsp&&t.nsp!=="/"&&(n+=t.nsp+","),t.id!=null&&(n+=t.id),t.data!=null&&(n+=JSON.stringify(t.data,this.replacer)),n}encodeAsBinary(t){const n=rh(t),r=this.encodeAsString(n.packet),o=n.buffers;return o.unshift(r),o}}function Ls(e){return Object.prototype.toString.call(e)==="[object Object]"}class Yr extends te{constructor(t){super(),this.reviver=t}add(t){let n;if(typeof t=="string"){if(this.reconstructor)throw new Error("got plaintext data when reconstructing a packet");n=this.decodeString(t);const r=n.type===z.BINARY_EVENT;r||n.type===z.BINARY_ACK?(n.type=r?z.EVENT:z.ACK,this.reconstructor=new lh(n),n.attachments===0&&super.emitReserved("decoded",n)):super.emitReserved("decoded",n)}else if(qr(t)||t.base64)if(this.reconstructor)n=this.reconstructor.takeBinaryData(t),n&&(this.reconstructor=null,super.emitReserved("decoded",n));else throw new Error("got binary data when not reconstructing a packet");else throw new Error("Unknown type: "+t)}decodeString(t){let n=0;const r={type:Number(t.charAt(0))};if(z[r.type]===void 0)throw new Error("unknown packet type "+r.type);if(r.type===z.BINARY_EVENT||r.type===z.BINARY_ACK){const i=n+1;for(;t.charAt(++n)!=="-"&&n!=t.length;);const s=t.substring(i,n);if(s!=Number(s)||t.charAt(n)!=="-")throw new Error("Illegal attachments");r.attachments=Number(s)}if(t.charAt(n+1)==="/"){const i=n+1;for(;++n&&!(t.charAt(n)===","||n===t.length););r.nsp=t.substring(i,n)}else r.nsp="/";const o=t.charAt(n+1);if(o!==""&&Number(o)==o){const i=n+1;for(;++n;){const s=t.charAt(n);if(s==null||Number(s)!=s){--n;break}if(n===t.length)break}r.id=Number(t.substring(i,n+1))}if(t.charAt(++n)){const i=this.tryParse(t.substr(n));if(Yr.isPayloadValid(r.type,i))r.data=i;else throw new Error("invalid payload")}return r}tryParse(t){try{return JSON.parse(t,this.reviver)}catch{return!1}}static isPayloadValid(t,n){switch(t){case z.CONNECT:return Ls(n);case z.DISCONNECT:return n===void 0;case z.CONNECT_ERROR:return typeof n=="string"||Ls(n);case z.EVENT:case z.BINARY_EVENT:return Array.isArray(n)&&(typeof n[0]=="number"||typeof n[0]=="string"&&ih.indexOf(n[0])===-1);case z.ACK:case z.BINARY_ACK:return Array.isArray(n)}}destroy(){this.reconstructor&&(this.reconstructor.finishedReconstruction(),this.reconstructor=null)}}class lh{constructor(t){this.packet=t,this.buffers=[],this.reconPack=t}takeBinaryData(t){if(this.buffers.push(t),this.buffers.length===this.reconPack.attachments){const n=oh(this.reconPack,this.buffers);return this.finishedReconstruction(),n}return null}finishedReconstruction(){this.reconPack=null,this.buffers=[]}}const ch=Object.freeze(Object.defineProperty({__proto__:null,Decoder:Yr,Encoder:ah,get PacketType(){return z},protocol:sh},Symbol.toStringTag,{value:"Module"}));function _e(e,t,n){return e.on(t,n),function(){e.off(t,n)}}const uh=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1});class Ms extends te{constructor(t,n,r){super(),this.connected=!1,this.recovered=!1,this.receiveBuffer=[],this.sendBuffer=[],this._queue=[],this._queueSeq=0,this.ids=0,this.acks={},this.flags={},this.io=t,this.nsp=n,r&&r.auth&&(this.auth=r.auth),this._opts=Object.assign({},r),this.io._autoConnect&&this.open()}get disconnected(){return!this.connected}subEvents(){if(this.subs)return;const t=this.io;this.subs=[_e(t,"open",this.onopen.bind(this)),_e(t,"packet",this.onpacket.bind(this)),_e(t,"error",this.onerror.bind(this)),_e(t,"close",this.onclose.bind(this))]}get active(){return!!this.subs}connect(){return this.connected?this:(this.subEvents(),this.io._reconnecting||this.io.open(),this.io._readyState==="open"&&this.onopen(),this)}open(){return this.connect()}send(...t){return t.unshift("message"),this.emit.apply(this,t),this}emit(t,...n){var r,o,i;if(uh.hasOwnProperty(t))throw new Error('"'+t.toString()+'" is a reserved event name');if(n.unshift(t),this._opts.retries&&!this.flags.fromQueue&&!this.flags.volatile)return this._addToQueue(n),this;const s={type:z.EVENT,data:n};if(s.options={},s.options.compress=this.flags.compress!==!1,typeof n[n.length-1]=="function"){const d=this.ids++,u=n.pop();this._registerAckCallback(d,u),s.id=d}const a=(o=(r=this.io.engine)===null||r===void 0?void 0:r.transport)===null||o===void 0?void 0:o.writable,l=this.connected&&!(!((i=this.io.engine)===null||i===void 0)&&i._hasPingExpired());return this.flags.volatile&&!a||(l?(this.notifyOutgoingListeners(s),this.packet(s)):this.sendBuffer.push(s)),this.flags={},this}_registerAckCallback(t,n){var r;const o=(r=this.flags.timeout)!==null&&r!==void 0?r:this._opts.ackTimeout;if(o===void 0){this.acks[t]=n;return}const i=this.io.setTimeoutFn(()=>{delete this.acks[t];for(let a=0;a<this.sendBuffer.length;a++)this.sendBuffer[a].id===t&&this.sendBuffer.splice(a,1);n.call(this,new Error("operation has timed out"))},o),s=(...a)=>{this.io.clearTimeoutFn(i),n.apply(this,a)};s.withError=!0,this.acks[t]=s}emitWithAck(t,...n){return new Promise((r,o)=>{const i=(s,a)=>s?o(s):r(a);i.withError=!0,n.push(i),this.emit(t,...n)})}_addToQueue(t){let n;typeof t[t.length-1]=="function"&&(n=t.pop());const r={id:this._queueSeq++,tryCount:0,pending:!1,args:t,flags:Object.assign({fromQueue:!0},this.flags)};t.push((o,...i)=>r!==this._queue[0]?void 0:(o!==null?r.tryCount>this._opts.retries&&(this._queue.shift(),n&&n(o)):(this._queue.shift(),n&&n(null,...i)),r.pending=!1,this._drainQueue())),this._queue.push(r),this._drainQueue()}_drainQueue(t=!1){if(!this.connected||this._queue.length===0)return;const n=this._queue[0];n.pending&&!t||(n.pending=!0,n.tryCount++,this.flags=n.flags,this.emit.apply(this,n.args))}packet(t){t.nsp=this.nsp,this.io._packet(t)}onopen(){typeof this.auth=="function"?this.auth(t=>{this._sendConnectPacket(t)}):this._sendConnectPacket(this.auth)}_sendConnectPacket(t){this.packet({type:z.CONNECT,data:this._pid?Object.assign({pid:this._pid,offset:this._lastOffset},t):t})}onerror(t){this.connected||this.emitReserved("connect_error",t)}onclose(t,n){this.connected=!1,delete this.id,this.emitReserved("disconnect",t,n),this._clearAcks()}_clearAcks(){Object.keys(this.acks).forEach(t=>{if(!this.sendBuffer.some(r=>String(r.id)===t)){const r=this.acks[t];delete this.acks[t],r.withError&&r.call(this,new Error("socket has been disconnected"))}})}onpacket(t){if(t.nsp===this.nsp)switch(t.type){case z.CONNECT:t.data&&t.data.sid?this.onconnect(t.data.sid,t.data.pid):this.emitReserved("connect_error",new Error("It seems you are trying to reach a Socket.IO server in v2.x with a v3.x client, but they are not compatible (more information here: https://socket.io/docs/v3/migrating-from-2-x-to-3-0/)"));break;case z.EVENT:case z.BINARY_EVENT:this.onevent(t);break;case z.ACK:case z.BINARY_ACK:this.onack(t);break;case z.DISCONNECT:this.ondisconnect();break;case z.CONNECT_ERROR:this.destroy();const r=new Error(t.data.message);r.data=t.data.data,this.emitReserved("connect_error",r);break}}onevent(t){const n=t.data||[];t.id!=null&&n.push(this.ack(t.id)),this.connected?this.emitEvent(n):this.receiveBuffer.push(Object.freeze(n))}emitEvent(t){if(this._anyListeners&&this._anyListeners.length){const n=this._anyListeners.slice();for(const r of n)r.apply(this,t)}super.emit.apply(this,t),this._pid&&t.length&&typeof t[t.length-1]=="string"&&(this._lastOffset=t[t.length-1])}ack(t){const n=this;let r=!1;return function(...o){r||(r=!0,n.packet({type:z.ACK,id:t,data:o}))}}onack(t){const n=this.acks[t.id];typeof n=="function"&&(delete this.acks[t.id],n.withError&&t.data.unshift(null),n.apply(this,t.data))}onconnect(t,n){this.id=t,this.recovered=n&&this._pid===n,this._pid=n,this.connected=!0,this.emitBuffered(),this.emitReserved("connect"),this._drainQueue(!0)}emitBuffered(){this.receiveBuffer.forEach(t=>this.emitEvent(t)),this.receiveBuffer=[],this.sendBuffer.forEach(t=>{this.notifyOutgoingListeners(t),this.packet(t)}),this.sendBuffer=[]}ondisconnect(){this.destroy(),this.onclose("io server disconnect")}destroy(){this.subs&&(this.subs.forEach(t=>t()),this.subs=void 0),this.io._destroy(this)}disconnect(){return this.connected&&this.packet({type:z.DISCONNECT}),this.destroy(),this.connected&&this.onclose("io client disconnect"),this}close(){return this.disconnect()}compress(t){return this.flags.compress=t,this}get volatile(){return this.flags.volatile=!0,this}timeout(t){return this.flags.timeout=t,this}onAny(t){return this._anyListeners=this._anyListeners||[],this._anyListeners.push(t),this}prependAny(t){return this._anyListeners=this._anyListeners||[],this._anyListeners.unshift(t),this}offAny(t){if(!this._anyListeners)return this;if(t){const n=this._anyListeners;for(let r=0;r<n.length;r++)if(t===n[r])return n.splice(r,1),this}else this._anyListeners=[];return this}listenersAny(){return this._anyListeners||[]}onAnyOutgoing(t){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.push(t),this}prependAnyOutgoing(t){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.unshift(t),this}offAnyOutgoing(t){if(!this._anyOutgoingListeners)return this;if(t){const n=this._anyOutgoingListeners;for(let r=0;r<n.length;r++)if(t===n[r])return n.splice(r,1),this}else this._anyOutgoingListeners=[];return this}listenersAnyOutgoing(){return this._anyOutgoingListeners||[]}notifyOutgoingListeners(t){if(this._anyOutgoingListeners&&this._anyOutgoingListeners.length){const n=this._anyOutgoingListeners.slice();for(const r of n)r.apply(this,t.data)}}}function Ct(e){e=e||{},this.ms=e.min||100,this.max=e.max||1e4,this.factor=e.factor||2,this.jitter=e.jitter>0&&e.jitter<=1?e.jitter:0,this.attempts=0}Ct.prototype.duration=function(){var e=this.ms*Math.pow(this.factor,this.attempts++);if(this.jitter){var t=Math.random(),n=Math.floor(t*this.jitter*e);e=Math.floor(t*10)&1?e+n:e-n}return Math.min(e,this.max)|0},Ct.prototype.reset=function(){this.attempts=0},Ct.prototype.setMin=function(e){this.ms=e},Ct.prototype.setMax=function(e){this.max=e},Ct.prototype.setJitter=function(e){this.jitter=e};class Xr extends te{constructor(t,n){var r;super(),this.nsps={},this.subs=[],t&&typeof t=="object"&&(n=t,t=void 0),n=n||{},n.path=n.path||"/socket.io",this.opts=n,Dn(this,n),this.reconnection(n.reconnection!==!1),this.reconnectionAttempts(n.reconnectionAttempts||1/0),this.reconnectionDelay(n.reconnectionDelay||1e3),this.reconnectionDelayMax(n.reconnectionDelayMax||5e3),this.randomizationFactor((r=n.randomizationFactor)!==null&&r!==void 0?r:.5),this.backoff=new Ct({min:this.reconnectionDelay(),max:this.reconnectionDelayMax(),jitter:this.randomizationFactor()}),this.timeout(n.timeout==null?2e4:n.timeout),this._readyState="closed",this.uri=t;const o=n.parser||ch;this.encoder=new o.Encoder,this.decoder=new o.Decoder,this._autoConnect=n.autoConnect!==!1,this._autoConnect&&this.open()}reconnection(t){return arguments.length?(this._reconnection=!!t,t||(this.skipReconnect=!0),this):this._reconnection}reconnectionAttempts(t){return t===void 0?this._reconnectionAttempts:(this._reconnectionAttempts=t,this)}reconnectionDelay(t){var n;return t===void 0?this._reconnectionDelay:(this._reconnectionDelay=t,(n=this.backoff)===null||n===void 0||n.setMin(t),this)}randomizationFactor(t){var n;return t===void 0?this._randomizationFactor:(this._randomizationFactor=t,(n=this.backoff)===null||n===void 0||n.setJitter(t),this)}reconnectionDelayMax(t){var n;return t===void 0?this._reconnectionDelayMax:(this._reconnectionDelayMax=t,(n=this.backoff)===null||n===void 0||n.setMax(t),this)}timeout(t){return arguments.length?(this._timeout=t,this):this._timeout}maybeReconnectOnOpen(){!this._reconnecting&&this._reconnection&&this.backoff.attempts===0&&this.reconnect()}open(t){if(~this._readyState.indexOf("open"))return this;this.engine=new Jf(this.uri,this.opts);const n=this.engine,r=this;this._readyState="opening",this.skipReconnect=!1;const o=_e(n,"open",function(){r.onopen(),t&&t()}),i=a=>{this.cleanup(),this._readyState="closed",this.emitReserved("error",a),t?t(a):this.maybeReconnectOnOpen()},s=_e(n,"error",i);if(this._timeout!==!1){const a=this._timeout,l=this.setTimeoutFn(()=>{o(),i(new Error("timeout")),n.close()},a);this.opts.autoUnref&&l.unref(),this.subs.push(()=>{this.clearTimeoutFn(l)})}return this.subs.push(o),this.subs.push(s),this}connect(t){return this.open(t)}onopen(){this.cleanup(),this._readyState="open",this.emitReserved("open");const t=this.engine;this.subs.push(_e(t,"ping",this.onping.bind(this)),_e(t,"data",this.ondata.bind(this)),_e(t,"error",this.onerror.bind(this)),_e(t,"close",this.onclose.bind(this)),_e(this.decoder,"decoded",this.ondecoded.bind(this)))}onping(){this.emitReserved("ping")}ondata(t){try{this.decoder.add(t)}catch(n){this.onclose("parse error",n)}}ondecoded(t){Tn(()=>{this.emitReserved("packet",t)},this.setTimeoutFn)}onerror(t){this.emitReserved("error",t)}socket(t,n){let r=this.nsps[t];return r?this._autoConnect&&!r.active&&r.connect():(r=new Ms(this,t,n),this.nsps[t]=r),r}_destroy(t){const n=Object.keys(this.nsps);for(const r of n)if(this.nsps[r].active)return;this._close()}_packet(t){const n=this.encoder.encode(t);for(let r=0;r<n.length;r++)this.engine.write(n[r],t.options)}cleanup(){this.subs.forEach(t=>t()),this.subs.length=0,this.decoder.destroy()}_close(){this.skipReconnect=!0,this._reconnecting=!1,this.onclose("forced close")}disconnect(){return this._close()}onclose(t,n){var r;this.cleanup(),(r=this.engine)===null||r===void 0||r.close(),this.backoff.reset(),this._readyState="closed",this.emitReserved("close",t,n),this._reconnection&&!this.skipReconnect&&this.reconnect()}reconnect(){if(this._reconnecting||this.skipReconnect)return this;const t=this;if(this.backoff.attempts>=this._reconnectionAttempts)this.backoff.reset(),this.emitReserved("reconnect_failed"),this._reconnecting=!1;else{const n=this.backoff.duration();this._reconnecting=!0;const r=this.setTimeoutFn(()=>{t.skipReconnect||(this.emitReserved("reconnect_attempt",t.backoff.attempts),!t.skipReconnect&&t.open(o=>{o?(t._reconnecting=!1,t.reconnect(),this.emitReserved("reconnect_error",o)):t.onreconnect()}))},n);this.opts.autoUnref&&r.unref(),this.subs.push(()=>{this.clearTimeoutFn(r)})}}onreconnect(){const t=this.backoff.attempts;this._reconnecting=!1,this.backoff.reset(),this.emitReserved("reconnect",t)}}const Gt={};function In(e,t){typeof e=="object"&&(t=e,e=void 0),t=t||{};const n=Zf(e,t.path||"/socket.io"),r=n.source,o=n.id,i=n.path,s=Gt[o]&&i in Gt[o].nsps,a=t.forceNew||t["force new connection"]||t.multiplex===!1||s;let l;return a?l=new Xr(r,t):(Gt[o]||(Gt[o]=new Xr(r,t)),l=Gt[o]),n.query&&!t.query&&(t.query=n.queryKey),l.socket(n.path,t)}Object.assign(In,{Manager:Xr,Socket:Ms,io:In,connect:In});class lt{static instance;constructor(){}static init(t){return lt.instance||(lt.instance=In(za,{path:"/ws",withCredentials:!0,extraHeaders:{"widget-id":t}}),lt.instance.on("connect",()=>{console.info("SmartTalks.ai widget connected!")})),lt.instance}static on(t,n,r){lt.instance||this.init(n).on(t,r)}}const Is=1e3*60*60*24,[Rn,Rs]=ti("smarttalks-widget-messages",{},Is),$s=()=>{const{widgetId:e}=oe();return Rn[e()]??[]},dh=e=>{const{widgetId:t}=oe();Rs({...Rn,[t()]:[...Rn[t()]??[],e]})},fh=()=>{const{widgetId:e}=oe();Rs({...Rn,[e()]:[]})},[Fs,hh]=ti("smarttalks-widget-conversationinfo",{},Is),Ns=()=>{const{widgetId:e}=oe();return Fs[e()]??{}},Ks=e=>{const{widgetId:t}=oe();hh({...Fs,[t()]:e})},[gh,Jr]=P(!1),[ph,Bs]=P(!1),zs=[],Vs=()=>{zs.forEach(e=>e())},mh=e=>zs.push(e),Zr=e=>{const t=gf(e);if(dh(t),t.type==="media"){setTimeout(Vs,200);return}Vs()},yh=(e,t)=>{const{chatWidget:n,widgetId:r}=oe(),o=Ns();e.trim()&&(Zr({text:e,type:"text",origin:"user",createdAt:new Date().toString()}),ee("onInput",e),lt.on("message",r(),i=>{(i.contactId!==o.contactId||i.interactionId!==o.interactionId)&&Ks({contactId:i.contactId,interactionId:i.interactionId});for(const s of i.messages)Zr(s),ee("onAnswer",s);Jr(!1),pf(i.debug)}),Jr(!0),mf(e,t,n()?._id).catch(i=>{console.error(i),Jr(!1)}))},bh=()=>{const{chatWidget:e}=oe(),t=Ns();Bs(!0),fh(),yf(e()?._id,t.contactId,t.interactionId).finally(()=>{Ks({}),Bs(!1),vh()}),ee("onReset")},vh=()=>{const{chatWidget:e}=oe();if($s().length===0&&e()?.balloonMessage){const n=e()?.balloonMessage;n&&Zr({text:n,type:"text",origin:"bot",createdAt:new Date().toString()})}},Qe=()=>({getMessages:$s,pushMessage:yh,clearMessages:bh,onMessage:mh,typing:gh,loading:ph});var wh=M("<span>");const xh=()=>{const{clearMessages:e}=Qe();P(!1);const[t,n]=P(!1);return y(uf,{get open(){return t()},onOpenChange:n,get children(){return[y(df,{get children(){return y(Te,{variant:"ghost",size:"icon",class:"hover:bg-accent/10 hover:text-primary-foreground",get children(){return y(fc,{size:20})}})}}),y(ff,{get children(){return y(hf,{class:"flex space-x-2 items-center cursor-pointer",onSelect:e,get children(){return[y(dc,{size:14}),(()=>{var r=wh();return A(r,()=>dt("restart")),r})()]}})}})]}})};function Sh(e){return ve({a:{fill:"currentColor",viewBox:"0 0 16 16"},c:'<path d="M5.5 0a.5.5 0 0 1 .5.5v4A1.5 1.5 0 0 1 4.5 6h-4a.5.5 0 0 1 0-1h4a.5.5 0 0 0 .5-.5v-4a.5.5 0 0 1 .5-.5zm5 0a.5.5 0 0 1 .5.5v4a.5.5 0 0 0 .5.5h4a.5.5 0 0 1 0 1h-4A1.5 1.5 0 0 1 10 4.5v-4a.5.5 0 0 1 .5-.5zM0 10.5a.5.5 0 0 1 .5-.5h4A1.5 1.5 0 0 1 6 11.5v4a.5.5 0 0 1-1 0v-4a.5.5 0 0 0-.5-.5h-4a.5.5 0 0 1-.5-.5zm10 1a1.5 1.5 0 0 1 1.5-1.5h4a.5.5 0 0 1 0 1h-4a.5.5 0 0 0-.5.5v4a.5.5 0 0 1-1 0v-4z"/>'},e)}function Eh(e){return ve({a:{fill:"currentColor",viewBox:"0 0 16 16"},c:'<path d="M1.5 1a.5.5 0 0 0-.5.5v4a.5.5 0 0 1-1 0v-4A1.5 1.5 0 0 1 1.5 0h4a.5.5 0 0 1 0 1h-4zM10 .5a.5.5 0 0 1 .5-.5h4A1.5 1.5 0 0 1 16 1.5v4a.5.5 0 0 1-1 0v-4a.5.5 0 0 0-.5-.5h-4a.5.5 0 0 1-.5-.5zM.5 10a.5.5 0 0 1 .5.5v4a.5.5 0 0 0 .5.5h4a.5.5 0 0 1 0 1h-4A1.5 1.5 0 0 1 0 14.5v-4a.5.5 0 0 1 .5-.5zm15 0a.5.5 0 0 1 .5.5v4a1.5 1.5 0 0 1-1.5 1.5h-4a.5.5 0 0 1 0-1h4a.5.5 0 0 0 .5-.5v-4a.5.5 0 0 1 .5-.5z"/>'},e)}function kh(e){return ve({a:{fill:"currentColor",viewBox:"0 0 16 16"},c:'<path d="M2.146 2.854a.5.5 0 1 1 .708-.708L8 7.293l5.146-5.147a.5.5 0 0 1 .708.708L8.707 8l5.147 5.146a.5.5 0 0 1-.708.708L8 8.707l-5.146 5.147a.5.5 0 0 1-.708-.708L7.293 8 2.146 2.854Z"/>'},e)}var Ch=M('<header class="flex-none bg-primary text-primary-foreground p-3 flex items-center justify-between space-x-4"><div class="flex items-center gap-0.5">');const Qr=()=>{const{chatWidget:e}=oe(),[t,n]=P(!1),r=()=>{try{const i=Wn();i&&(t()?document.exitFullscreen().then(()=>n(!1)):i.requestFullscreen().then(()=>n(!0)))}catch{console.error("SmartTalks.ai Widget unable to toggle fullscreen in the current state.")}};document.addEventListener("fullscreenchange",()=>{document.fullscreenElement||n(!1)});const o=()=>{e()?.mode==="popup"&&ee("close")};return se("toggleFullscreen",()=>{r()}),(()=>{var i=Ch(),s=i.firstChild;return A(i,y(cc,{}),s),A(s,y(Te,{size:"icon",variant:"ghost",class:"hover:bg-accent/10 hover:text-primary-foreground",onClick:r,get children(){return y(Z,{get when(){return t()},get fallback(){return y(Eh,{size:16})},get children(){return y(Sh,{size:16})}})}}),null),A(s,y(Z,{get when(){return e()?.showSettings},get children(){return y(xh,{})}}),null),A(s,y(Z,{get when(){return e()?.mode==="popup"},get children(){return y(Te,{size:"icon",variant:"ghost",class:"hover:bg-accent/10 hover:text-primary-foreground",onClick:o,get children(){return y(kh,{size:16})}})}}),null),i})()};var Oh=M("<span>");const Us=({createdAt:e,anchor:t="end"})=>(()=>{var n=Oh();return gt(n,`${t==="end"?"self-end":"self-start"} pt-1 text-[10px] italic font-light text-slate-600`),A(n,()=>new Date(e).toLocaleString([],{hour:"2-digit",minute:"2-digit"})),n})();var _h=M('<div class="place-self-start py-1 flex flex-col"><div class="bg-white shadow-md py-2 px-4 rounded-r-xl rounded-tl-xl">');const Ph=({children:e,createdAt:t})=>(()=>{var n=_h(),r=n.firstChild;return A(r,e),A(n,y(Us,{createdAt:t,anchor:"start"}),null),n})();var Ah=M("<span>");const Ot=e=>{const[,t]=j(e,["class","children"]);let n=e.children?.toString();return n&&(n=Na(Ka(n))),(()=>{var r=Ah();return r.innerHTML=n,tt(r,T({get class(){return Ge("whitespace-pre-line",e.class)}},t),!1,!1),r})()};var Th=M('<div class="flex flex-col space-y-2"><div><div class="flex p-1 flex-wrap items-center justify-center">');const Dh=({options:e,text:t})=>{let n;const{pushMessage:r}=Qe(),[o,i]=P(!1),s=(a,l)=>{i(!0),r(a,l)};return(()=>{var a=Th(),l=a.firstChild,c=l.firstChild;A(a,y(Ot,{get children(){return t?.trim()}}),l);var d=n;return typeof d=="function"?ir(d,c):n=c,A(c,y(ht,{each:e,children:u=>y(Te,{variant:"outline",get disabled(){return o()},class:"px-2 ml-1 mb-1 py-0 text-nowrap",onClick:()=>s(u.label,u.value),get children(){return u.label?.trim()}})})),re(()=>gt(l,`flex items-center justify-center max-w-80 mx-[-1rem] ${o()&&"opacity-50"}`)),a})()};var Lh=M('<div class="flex flex-col"><span>'),Mh=M("<a target=_blank><img><span></span><span>");const Ih=({options:e,text:t})=>(()=>{var n=Lh(),r=n.firstChild;return A(r,()=>t?.trim()),A(n,y(ht,{each:e,children:o=>(()=>{var i=Mh(),s=i.firstChild,a=s.nextSibling,l=a.nextSibling;return A(a,()=>o.title?.trim()),A(l,()=>o.description?.trim()),re(c=>{var d=o.url,u=o.image;return d!==c.e&&ue(i,"href",c.e=d),u!==c.t&&ue(s,"src",c.t=u),c},{e:void 0,t:void 0}),i})()}),null),n})();var Rh=M("<a target=_blank>");const $h=({url:e,text:t})=>(()=>{var n=Rh();return ue(n,"href",e),A(n,()=>t?.trim()),n})();var G=e=>typeof e=="function"?e():e,js=e=>requestAnimationFrame(()=>requestAnimationFrame(e)),Fh=e=>{const t=T({initialRegistered:!1},e),[n,r]=P(t.initialRegistered);return[C(()=>{if(n())return G(t.value)}),()=>{r(!0)},()=>{r(!1)}]},Hs=Fh,Yt=e=>typeof e=="function",Nh=["button","color","file","image","reset","submit"],Kh=(e,t)=>e==="button"?!0:e==="input"&&t?Nh.indexOf(t)!==-1:!1;function Bh(e){const[t,n]=P(e.initialValue),r=()=>e.value?.()!==void 0,o=()=>r()?e.value?.():t();return[o,s=>q(()=>{let a;return Yt(s)?a=s(o()):a=s,Object.is(a,o())||(r()||n(a),e.onChange?.(a)),a})]}var eo=Bh,$n=new Map,Fn=(e,t)=>{if($n.has(e))return $n.get(e);const n=ce(t);return $n.set(e,n),n},to=e=>{const t=$n.get(e);if(t)return he(t)},Nn=new Map,zh=e=>{D(()=>{const t=G(e.style)??{},n=G(e.properties)??[],r={};for(const i in t)r[i]=e.element.style[i];const o=Nn.get(e.key);o?o.activeCount++:Nn.set(e.key,{activeCount:1,originalStyles:r,properties:n.map(i=>i.key)}),Object.assign(e.element.style,e.style);for(const i of n)e.element.style.setProperty(i.key,i.value);K(()=>{const i=Nn.get(e.key);if(i){if(i.activeCount!==1){i.activeCount--;return}Nn.delete(e.key);for(const[s,a]of Object.entries(i.originalStyles))e.element.style[s]=a;for(const s of i.properties)e.element.style.removeProperty(s);e.element.style.length===0&&e.element.removeAttribute("style"),e.cleanup?.()}})})},Vh=zh,Uh=e=>{const t=T({enabled:!0},e);D(()=>{G(t.enabled)&&(document.addEventListener("keydown",n),K(()=>{document.removeEventListener("keydown",n)}))});const n=r=>{r.key==="Escape"&&t.onEscapeKeyDown(r)}},jh=Uh,Hh=e=>{const t=T({enabled:!0},e);D(()=>{const{body:n}=document;G(t.enabled)&&Vh({key:"no-pointer-events",element:n,style:{pointerEvents:"none"}})})},qh=Hh,Wh=e=>{const t=T({enabled:!0,strategy:"pointerup"},e);D(()=>{if(!G(t.enabled))return;const r=G(t.strategy);document.addEventListener(r,n),K(()=>{document.removeEventListener(r,n)})});const n=r=>{const o=G(t.element),i=G(t.ignore);o&&!o.contains(r.target)&&!(i&&i.contains(r.target))&&t.onPointer(r)}},Gh=Wh,Yh=e=>{const t=T({dismissOnEscapeKeyDown:!0,dismissOnOutsidePointer:!0,closeOnOutsidePointerStrategy:"pointerup",noOutsidePointerEvents:!0},e);jh({enabled:t.dismissOnEscapeKeyDown,onEscapeKeyDown:n=>{t.onEscapeKeyDown?.(n),n.defaultPrevented||t.onDismiss("escapeKey")}}),Gh({enabled:t.dismissOnOutsidePointer,strategy:t.closeOnOutsidePointerStrategy,ignore:t.dismissOnOutsidePointerIgnore,onPointer:n=>{if(t.onOutsidePointer?.(n),!n.defaultPrevented){const r=n.button===0&&n.ctrlKey===!0;if(n.button===2||r)return;t.onDismiss("pointerOutside")}},element:t.element}),qh({enabled:t.noOutsidePointerEvents})},Xh=Yh,no=ce(),Jh=e=>C(()=>{if(he(no))return y(qs,e);const r=Ae(),[o,i]=P([r]),s=l=>{i(c=>[...c,l])},a=l=>{i(c=>c.filter(d=>d!==l))};return y(no.Provider,{value:{layers:o,onLayerShow:s,onLayerDismiss:a},get children(){return y(qs,e)}})}),qs=e=>{const t=T({enabled:!0,dismissOnEscapeKeyDown:!0,dismissOnOutsidePointer:!0,dismissOnOutsidePointerStrategy:"pointerup",noOutsidePointerEvents:!0},e),[n,r]=j(t,["enabled","children","dismissOnEscapeKeyDown","dismissOnOutsidePointer","dismissOnOutsidePointerStrategy","dismissOnOutsidePointerIgnore","noOutsidePointerEvents","onDismiss"]),o=he(no),i=Ae();D(()=>{n.enabled?o.onLayerShow(i):o.onLayerDismiss(i)});const s=()=>o.layers()[o.layers().length-1]===i;Xh({dismissOnEscapeKeyDown:()=>G(n.dismissOnEscapeKeyDown)&&s()&&n.enabled,dismissOnOutsidePointer:()=>G(n.dismissOnOutsidePointer)&&s()&&n.enabled,dismissOnOutsidePointerStrategy:n.dismissOnOutsidePointerStrategy,dismissOnOutsidePointerIgnore:n.dismissOnOutsidePointerIgnore,noOutsidePointerEvents:()=>G(n.noOutsidePointerEvents)&&n.enabled,onDismiss:c=>{n.onDismiss(c)},...r});const a=C(()=>n.children),l=()=>{const c=a();return Yt(c)?c({get isLastLayer(){return s()}}):c};return q(()=>l())},Zh=Jh,Qh=()=>{const[e,t]=P(!1);return D(()=>t(!0)),e},eg=Qh,tg=(e,t)=>(e&&(Yt(e)?e(t):e[0](e[1],t)),t.defaultPrevented),ro=(...e)=>e.some(t=>!!t()),ng=e=>(...t)=>{for(const n of e)n&&n(...t)},Kn=(...e)=>ng(e),le=e=>e?"":void 0,rg="div",og=e=>{const[t,n]=j(e,["as"]),r=C(()=>t.as??rg);return C(()=>{const i=r();switch(typeof i){case"function":return q(()=>i(n));case"string":return y(ln,T({component:i},n))}})},oo=og,ig=e=>{let t,n=!1;return()=>n?t:(n=!0,t=C(e))},Ws=ig,sg=e=>C(()=>G(e.element)?.tagName.toLowerCase()||e.fallback),ag=sg,Gs="button",lg=e=>{const[t,n]=P(null),[r,o]=j(e,["as","ref","type"]),i=ag({element:t,fallback:Gs}),s=C(()=>Kh(i(),r.type));return y(oo,T({get as(){return r.as??Gs},ref(a){var l=Kn(n,r.ref);typeof l=="function"&&l(a)},get type(){return s()?"button":void 0},get role(){return s()?void 0:"button"}},o))},cg=lg,ug='a[href]:not([tabindex="-1"]), button:not([tabindex="-1"]), input:not([tabindex="-1"]), textarea:not([tabindex="-1"]), select:not([tabindex="-1"]), details:not([tabindex="-1"]), [tabindex]:not([tabindex="-1"])',io="focusTrap.initialFocus",so="focusTrap.finalFocus",Ys={bubbles:!1,cancelable:!0},dg=e=>{const t=T({enabled:!0,observeChanges:!0,restoreFocus:!0},e),[n,r]=P(null),o=C(()=>{const f=n();return f?f[0]??null:null}),i=C(()=>{const f=n();return f?f[f.length-1]??null:null});let s=null;const a=()=>{Cr(()=>{l(J(t.element)),(document.activeElement===null||document.activeElement===document.body)&&c(J(t.element))})};D(()=>{const f=J(t.element);if(f&&J(t.enabled)){s=document.activeElement,q(()=>{l(f),c(f)});const g=new MutationObserver(a);J(t.observeChanges)&&g.observe(f,{subtree:!0,childList:!0,attributes:!0,attributeFilter:["tabindex"]}),K(()=>{J(t.observeChanges)&&g.disconnect(),r(null),m(f)})}}),D(()=>{const f=n();f===null||f.length!==0||(document.addEventListener("keydown",h),K(()=>{document.removeEventListener("keydown",h)}))}),D(()=>{const f=o();f&&(f.addEventListener("keydown",d),K(()=>{f.removeEventListener("keydown",d)}))}),D(()=>{const f=i();f&&(f.addEventListener("keydown",u),K(()=>{f.removeEventListener("keydown",u)}))});const l=f=>{const g=Array.from(f.querySelectorAll(ug)).map((p,b)=>({element:p,domIndex:b,tabIndex:p.tabIndex})).sort((p,b)=>p.tabIndex===b.tabIndex?p.domIndex-b.domIndex:p.tabIndex-b.tabIndex);r(g.map(({element:p})=>p))},c=f=>{Cr(()=>{const g=J(t.initialFocusElement)??o()??f,p=t.onInitialFocus;let b;p&&(b=new CustomEvent(io,Ys),f.addEventListener(io,p),f.dispatchEvent(b),f.removeEventListener(io,p)),b?.defaultPrevented!==!0&&g.focus()})},d=f=>{f.key==="Tab"&&f.shiftKey&&(f.preventDefault(),i().focus())},u=f=>{f.key==="Tab"&&!f.shiftKey&&(f.preventDefault(),o().focus())},h=f=>{f.key==="Tab"&&f.preventDefault()},m=f=>{Cr(()=>{if(!J(t.restoreFocus))return;const p=J(t.finalFocusElement)??s;if(!p)return;let b;const v=t.onFinalFocus;v&&(b=new CustomEvent(so,Ys),f.addEventListener(so,v),f.dispatchEvent(b),f.removeEventListener(so,v)),b?.defaultPrevented!==!0&&p.focus()})}},fg=dg,hg=fg,gg=e=>{const t=C(()=>{const s=J(e.element);if(s)return getComputedStyle(s)}),n=()=>t()?.animationName??"none",[r,o]=P(J(e.show)?"present":"hidden");let i="none";return D(s=>{const a=J(e.show);return q(()=>{if(s===a)return a;const l=i,c=n();a?o("present"):c==="none"||t()?.display==="none"?o("hidden"):o(s===!0&&l!==c?"hiding":"hidden")}),a}),D(()=>{const s=J(e.element);if(!s)return;const a=c=>{c.target===s&&(i=n())},l=c=>{const u=n().includes(c.animationName);c.target===s&&u&&r()==="hiding"&&o("hidden")};s.addEventListener("animationstart",a),s.addEventListener("animationcancel",l),s.addEventListener("animationend",l),K(()=>{s.removeEventListener("animationstart",a),s.removeEventListener("animationcancel",l),s.removeEventListener("animationend",l)})}),{present:()=>r()==="present"||r()==="hiding",state:r,setState:o}},pg=gg,Xs=pg,mg=ce(),yg=e=>e?Fn(`dialog-${e}`):mg,Js=ce(),bg=e=>e?Fn(`dialog-internal-${e}`):Js,_t=e=>{if(!e){const n=he(Js);if(!n)throw new Error("[corvu]: Dialog context not found. Make sure to wrap Dialog components in <Dialog.Root>");return n}const t=to(`dialog-internal-${e}`);if(!t)throw new Error(`[corvu]: Dialog context with id "${e}" not found. Make sure to wrap Dialog components in <Dialog.Root contextId="${e}">`);return t},vg="div",wg=e=>{const[t,n]=j(e,["as","forceMount","contextId","children","ref","style","data-corvu-dialog-content"]),r=C(()=>_t(t.contextId)),o=()=>ro(r().open,()=>t.forceMount,r().contentPresent),i=C(s=>s||o(),!1);return y(Z,{get when(){return i()},get children(){return y(Zh,{get element(){return r().contentRef},get enabled(){return r().open()||r().contentPresent()},onDismiss:()=>r().setOpen(!1),get dismissOnEscapeKeyDown(){return r().closeOnEscapeKeyDown},get dismissOnOutsidePointer(){return r().closeOnOutsidePointer},get dismissOnOutsidePointerStrategy(){return r().closeOnOutsidePointerStrategy},get dismissOnOutsidePointerIgnore(){return r().triggerRef},get noOutsidePointerEvents(){return r().noOutsidePointerEvents},get onEscapeKeyDown(){return r().onEscapeKeyDown},get onOutsidePointer(){return r().onOutsidePointer},children:s=>{const a=C(()=>t.children);return y(Z,{get when(){return o()},get children(){return y(oo,T({ref(l){var c=Kn(r().setContentRef,t.ref);typeof c=="function"&&c(l)},get as(){return t.as??vg},get role(){return r().role()},get id(){return r().dialogId()},get"aria-labelledby"(){return r().labelId()},get"aria-describedby"(){return r().descriptionId()},get"aria-modal"(){return r().modal()?"true":"false"},get"data-open"(){return le(r().open())},get"data-closed"(){return le(!r().open())},get"data-corvu-dialog-content"(){return t.hasOwnProperty("data-corvu-dialog-content")?t["data-corvu-dialog-content"]:""},tabIndex:"-1",get style(){return{"pointer-events":s.isLastLayer?"auto":void 0,...t.style}}},n,{get children(){return a()}}))}})}})}})},xg=wg,Sg="div",Eg=e=>{const[t,n]=j(e,["as","forceMount","contextId","children","ref","style","data-corvu-dialog-overlay"]),r=C(()=>_t(t.contextId)),o=()=>ro(r().open,()=>t.forceMount,r().overlayPresent),i=C(s=>s||o(),!1);return y(Z,{get when(){return i()},get children(){return(()=>{const s=C(()=>t.children);return y(Z,{get when(){return o()},get children(){return y(oo,T({get as(){return t.as??Sg},ref(a){var l=Kn(r().setOverlayRef,t.ref);typeof l=="function"&&l(a)},"aria-hidden":"true",get"data-open"(){return le(r().open())},get"data-closed"(){return le(!r().open())},get"data-corvu-dialog-overlay"(){return t.hasOwnProperty("data-corvu-dialog-overlay")?t["data-corvu-dialog-overlay"]:""},tabIndex:"-1",get style(){return{"pointer-events":"auto",...t.style}}},n,{get children(){return s()}}))}})})()}})},kg=Eg,Cg=e=>{const[t,n]=j(e,["forceMount","contextId","children"]),r=C(()=>_t(t.contextId)),o=()=>ro(r().open,()=>t.forceMount,r().contentPresent,r().overlayPresent),i=eg(),s=C(a=>a||o()&&i(),!1);return y(Z,{get when(){return s()},get children(){return(()=>{const a=C(()=>t.children);return y(Z,{get when(){return o()},get children(){return y(qo,T(n,{get children(){return a()}}))}})})()}})},Og=Cg,ao=!0,_g=e=>{const t=T({role:"dialog",initialOpen:!1,modal:!0,closeOnEscapeKeyDown:!0,closeOnOutsidePointer:()=>!!(e.modal??ao),closeOnOutsidePointerStrategy:"pointerup",noOutsidePointerEvents:()=>!!(e.modal??ao),preventScroll:()=>!!(e.modal??ao),hideScrollbar:!0,preventScrollbarShift:!0,preventScrollbarShiftMode:"padding",allowPinchZoom:!0,trapFocus:!0,restoreFocus:!0,dialogId:Ae()},e),[n,r]=eo({value:()=>t.open,initialValue:t.initialOpen,onChange:t.onOpenChange}),[o,i,s]=Hs({value:()=>t.labelId??Ae()}),[a,l,c]=Hs({value:()=>t.descriptionId??Ae()}),[d,u]=P(null),[h,m]=P(null),[f,g]=P(null),{present:p}=Xs({show:n,element:h}),{present:b}=Xs({show:n,element:f});hg({element:h,enabled:()=>n()&&t.trapFocus,initialFocusElement:()=>t.initialFocusEl??null,restoreFocus:()=>t.restoreFocus,finalFocusElement:()=>t.finalFocusEl??null,onFinalFocus:t.onFinalFocus,onInitialFocus:t.onInitialFocus}),Hi({element:h,enabled:()=>p()&&G(t.preventScroll),hideScrollbar:()=>t.hideScrollbar,preventScrollbarShift:()=>t.preventScrollbarShift,preventScrollbarShiftMode:()=>t.preventScrollbarShiftMode,allowPinchZoom:()=>t.allowPinchZoom});const v={get role(){return t.role},get open(){return n()},setOpen:r,get modal(){return t.modal},get closeOnEscapeKeyDown(){return t.closeOnEscapeKeyDown},get closeOnOutsidePointer(){return G(t.closeOnOutsidePointer)},get closeOnOutsidePointerStrategy(){return t.closeOnOutsidePointerStrategy},get noOutsidePointerEvents(){return G(t.noOutsidePointerEvents)},get preventScroll(){return G(t.preventScroll)},get hideScrollbar(){return t.hideScrollbar},get preventScrollbarShift(){return G(t.preventScrollbarShift)},get preventScrollbarShiftMode(){return t.preventScrollbarShiftMode},get allowPinchZoom(){return t.allowPinchZoom},get trapFocus(){return t.trapFocus},get restoreFocus(){return t.restoreFocus},get initialFocusEl(){return t.initialFocusEl},get finalFocusEl(){return t.finalFocusEl},get contentPresent(){return p()},get contentRef(){return h()},get overlayPresent(){return b()},get overlayRef(){return f()},get dialogId(){return t.dialogId},get labelId(){return o()},get descriptionId(){return a()}},w=Ws(()=>t.children),x=()=>{const k=w()();return Yt(k)?k(v):k};return C(()=>{const k=yg(t.contextId),E=bg(t.contextId);return y(k.Provider,{value:{role:()=>t.role,open:n,setOpen:r,modal:()=>t.modal,closeOnEscapeKeyDown:()=>t.closeOnEscapeKeyDown,closeOnOutsidePointer:()=>G(t.closeOnOutsidePointer),closeOnOutsidePointerStrategy:()=>t.closeOnOutsidePointerStrategy,noOutsidePointerEvents:()=>G(t.noOutsidePointerEvents),preventScroll:()=>G(t.preventScroll),hideScrollbar:()=>t.hideScrollbar,preventScrollbarShift:()=>G(t.preventScrollbarShift),preventScrollbarShiftMode:()=>t.preventScrollbarShiftMode,allowPinchZoom:()=>t.allowPinchZoom,trapFocus:()=>t.trapFocus,restoreFocus:()=>t.restoreFocus,initialFocusEl:()=>t.initialFocusEl,finalFocusEl:()=>t.finalFocusEl,contentPresent:p,contentRef:h,overlayPresent:b,overlayRef:f,dialogId:()=>t.dialogId,labelId:o,descriptionId:a},get children(){return y(E.Provider,{get value(){return{role:()=>t.role,open:n,setOpen:r,modal:()=>t.modal,closeOnEscapeKeyDown:()=>t.closeOnEscapeKeyDown,onEscapeKeyDown:t.onEscapeKeyDown,closeOnOutsidePointer:()=>G(t.closeOnOutsidePointer),closeOnOutsidePointerStrategy:()=>t.closeOnOutsidePointerStrategy,onOutsidePointer:t.onOutsidePointer,noOutsidePointerEvents:()=>G(t.noOutsidePointerEvents),preventScroll:()=>G(t.preventScroll),hideScrollbar:()=>t.hideScrollbar,preventScrollbarShift:()=>G(t.preventScrollbarShift),preventScrollbarShiftMode:()=>t.preventScrollbarShiftMode,allowPinchZoom:()=>t.allowPinchZoom,trapFocus:()=>t.trapFocus,restoreFocus:()=>t.restoreFocus,initialFocusEl:()=>t.initialFocusEl,finalFocusEl:()=>t.finalFocusEl,contentPresent:p,contentRef:h,overlayPresent:b,overlayRef:f,dialogId:()=>t.dialogId,labelId:o,registerLabelId:i,unregisterLabelId:s,descriptionId:a,registerDescriptionId:l,unregisterDescriptionId:c,setContentRef:m,setOverlayRef:g,triggerRef:d,setTriggerRef:u}},get children(){return q(()=>x())}})}})})},Pg=_g,Ag="button",Tg=e=>{const[t,n]=j(e,["as","contextId","ref","onClick","data-corvu-dialog-trigger"]),r=C(()=>_t(t.contextId));return y(cg,T({ref(i){var s=Kn(r().setTriggerRef,t.ref);typeof s=="function"&&s(i)},get as(){return t.as??Ag},onClick:i=>{!tg(t.onClick,i)&&r().setOpen(s=>!s)},"aria-haspopup":"dialog",get"aria-expanded"(){return r().open()?"true":"false"},get"aria-controls"(){return r().dialogId()},get"data-open"(){return le(r().open())},get"data-closed"(){return le(!r().open())},get"data-corvu-dialog-trigger"(){return t.hasOwnProperty("data-corvu-dialog-trigger")?t["data-corvu-dialog-trigger"]:""}},n))},Dg=Tg,Bn=e=>typeof e=="function"?e():e,Zs=e=>requestAnimationFrame(()=>requestAnimationFrame(e));function Lg(e){const t=T({enabled:!0,dimension:"both"},e),[n,r]=P(!1),[o,i]=P(null);let s=null;D(()=>{const c=Bn(t.element),d=Bn(t.enabled);if(!c||!d)return;const u=new ResizeObserver(a);u.observe(c),c.addEventListener("transitionend",l),K(()=>{u.disconnect(),c.removeEventListener("transitionend",l),l()})});const a=([c])=>{if(n())return;const d=c.target,u=[d.offsetWidth,d.offsetHeight],h=Bn(t.dimension);h==="both"?s?s[0]!==u[0]&&s[1]!==u[1]&&(Ee(()=>{i(s),r(!0)}),Zs(()=>{i(u),parseFloat(getComputedStyle(c.target).transitionDuration)===0&&l()})):s=u:s?zn(h,s)!==zn(h,u)&&(Ee(()=>{i(zn(h,s)),r(!0)}),Zs(()=>{i(zn(h,u)),parseFloat(getComputedStyle(c.target).transitionDuration)===0&&l()})):s=u},l=()=>{if(!n())return;const c=Bn(t.element);c?s=[c.offsetWidth,c.offsetHeight]:s=null,Ee(()=>{r(!1),i(null)})};return{transitioning:n,transitionSize:o}}var zn=(e,t)=>{switch(e){case"width":return t[0];case"height":return t[1]}},Mg=Lg,Ig=Mg;const Rg=(e,t)=>e.length>0?()=>e(q(t)):e;function $g(e,t){let n=0;const r=e.map((o,i)=>C(()=>(n=i,o()),void 0,cr));return C(()=>r.map(o=>o())[n],void 0,t)}function Qs(e,t,n){let r=()=>t;const[o,i]=P(t,cr),s=C(Rg(e,()=>r()),t,cr);return[r=$g([o,s],n),a=>i(()=>typeof a=="function"?a(q(r)):a)]}var Fg=(e,t)=>{switch(t){case"x":return[e.clientWidth,e.scrollLeft,e.scrollWidth];case"y":return[e.clientHeight,e.scrollTop,e.scrollHeight]}},Ng=(e,t)=>{const n=getComputedStyle(e),r=t==="x"?n.overflowX:n.overflowY;return r==="auto"||r==="scroll"||e.tagName==="HTML"&&r==="visible"},Kg=(e,t,n)=>{const r=t==="x"&&window.getComputedStyle(e).direction==="rtl"?-1:1;let o=e,i=0,s=0,a=!1;do{const[l,c,d]=Fg(o,t),u=d-l-r*c;(c!==0||u!==0)&&Ng(o,t)&&(i+=u,s+=c),o===(n??document.documentElement)?a=!0:o=o._$host??o.parentElement}while(o&&!a);return[i,s]},Bg=e=>y(Dg,T({"data-corvu-dialog-trigger":void 0,"data-corvu-drawer-trigger":""},e)),ea=ce(),zg=e=>e?Fn(`drawer-${e}`):ea,Vg=e=>{if(!e){const n=he(ea);if(!n)throw new Error("[corvu]: Drawer context not found. Make sure to wrap Drawer components in <Drawer.Root>");return n}const t=to(`drawer-${e}`);if(!t)throw new Error(`[corvu]: Drawer context with id "${e}" not found. Make sure to wrap Drawer components in <Drawer.Root contextId="${e}">`);return t},ta=ce(),Ug=e=>e?Fn(`drawer-internal-${e}`):ta,na=e=>{if(!e){const n=he(ta);if(!n)throw new Error("[corvu]: Drawer context not found. Make sure to wrap Drawer components in <Drawer.Root>");return n}const t=to(`drawer-internal-${e}`);if(!t)throw new Error(`[corvu]: Drawer context with id "${e}" not found. Make sure to wrap Drawer components in <Drawer.Root contextId="${e}">`);return t},ra=(e,t,n,r)=>{if(n===void 0||r===void 0)return{value:e,offset:Vn(e,t)};const o=r[n-1]?Vn(r[n-1],t):void 0,i=r[n]?Vn(r[n],t):void 0;return{value:e,offset:Vn(e,t),lowerBreakPoint:i,upperBreakPoint:o}},Vn=(e,t)=>{if(typeof e=="number")return t-e*t;if(!e.endsWith("px"))throw new Error(`[corvu] Snap and break points must be a number or a string ending with 'px'. Got ${e}`);return t-parseInt(e,10)},jg=(e,t,n,r)=>{const o=oa("upper",e,r?n:t),i=oa("lower",e,r?n:t);return o?i?i.upperBreakPoint===void 0||o.lowerBreakPoint===void 0?Math.abs(i.offset-n)<Math.abs(o.offset-n)?i:o:n<o.lowerBreakPoint?i:o:o:i},oa=(e,t,n)=>t.reduce((r,o)=>e=="upper"&&o.offset>=n&&(!r||o.offset<r.offset)||e=="lower"&&o.offset<=n&&(!r||o.offset>r.offset)?o:r,void 0),Hg=(e,t)=>{let n=e,r=!1;do{if(n.hasAttribute("data-corvu-no-drag")||n.type==="range")return!1;n===(t??document.documentElement)?r=!0:n=n.parentElement}while(n&&!r);return!0},qg=void 0,Wg=e=>{const t=T({initialOpen:!1,snapPoints:[0,1],breakPoints:[qg],defaultSnapPoint:1,side:"bottom",dampFunction:F=>6*Math.log(F+1),velocityFunction:(F,V)=>{const Q=F/V;return Q<1&&Q>-1?1:Q},velocityCacheReset:200,allowSkippingSnapPoints:!0,handleScrollableElements:!0,transitionResize:!1,closeOnOutsidePointer:!0,allowPinchZoom:!1},e),[n,r]=j(t,["snapPoints","breakPoints","defaultSnapPoint","activeSnapPoint","onActiveSnapPointChange","side","dampFunction","velocityFunction","velocityCacheReset","allowSkippingSnapPoints","handleScrollableElements","transitionResize","open","initialOpen","onOpenChange","closeOnOutsidePointer","contextId","children"]),[o,i]=eo({value:()=>n.open,initialValue:n.initialOpen,onChange:n.onOpenChange}),[s,a]=eo({value:()=>n.activeSnapPoint,initialValue:0,onChange:n.onActiveSnapPointChange}),[l,c]=P(),{transitioning:d,transitionSize:u}=Ig({element:()=>l()?.contentRef()??null,enabled:()=>o()&&n.transitionResize,dimension:()=>{switch(n.side){case"top":case"bottom":return"height";case"left":case"right":return"width"}}}),[h,m]=P(!1),[f,g]=Qs(()=>d()?"resizing":null),p=C(()=>{const F=l()?.contentRef();if(F)return getComputedStyle(F)}),[b,v]=P(!1);D(()=>{const F=o();q(()=>{b()!==F&&(F?(v(!0),js(()=>{Ee(()=>{g("opening"),a(n.defaultSnapPoint)}),parseFloat(p().transitionDuration)===0&&g(null)})):(Ee(()=>{g("closing"),a(0)}),js(()=>{parseFloat(p().transitionDuration)===0&&w()})))})});const w=()=>{Ee(()=>{v(!1),g(null)})},[x,O]=P(0);D(()=>{const F=l()?.contentRef();if(!F)return;E(F);const V=new ResizeObserver(k);V.observe(F),K(()=>{V.disconnect()})});const k=F=>{for(const V of F)V.target===l()?.contentRef()&&E(V.target)},E=F=>{const V=q(()=>x());switch(n.side){case"top":case"bottom":if(V===F.offsetHeight)return;O(F.offsetHeight);break;case"left":case"right":if(V===F.offsetWidth)return;O(F.offsetWidth);break}},$=C(()=>ra(s(),x())),[_,R]=Qs(()=>$().offset),L=C(()=>x()?(x()-_())/x():0),I={get snapPoints(){return n.snapPoints},get breakPoints(){return n.breakPoints},get defaultSnapPoint(){return n.defaultSnapPoint},get activeSnapPoint(){return s()},setActiveSnapPoint:a,get side(){return n.side},get isDragging(){return h()},get isTransitioning(){return f()!==null},get transitionState(){return f()},get openPercentage(){return L()},get translate(){return _()},get velocityCacheReset(){return n.velocityCacheReset},get allowSkippingSnapPoints(){return n.allowSkippingSnapPoints},get handleScrollableElements(){return n.handleScrollableElements},get transitionResize(){return n.transitionResize}},ne=Ws(()=>n.children),Y=F=>{c(_t(n.contextId));const V=ne()();if(Yt(V)){const Q=T(F,I);return V(Q)}return V};return C(()=>{const F=zg(n.contextId),V=Ug(n.contextId);return q(()=>y(F.Provider,{value:{snapPoints:()=>n.snapPoints,breakPoints:()=>n.breakPoints,defaultSnapPoint:()=>n.defaultSnapPoint,activeSnapPoint:s,setActiveSnapPoint:a,side:()=>n.side,isDragging:h,isTransitioning:()=>f()!==null,transitionState:f,openPercentage:L,translate:_,velocityCacheReset:()=>n.velocityCacheReset,allowSkippingSnapPoints:()=>n.allowSkippingSnapPoints,handleScrollableElements:()=>n.handleScrollableElements,transitionResize:()=>n.transitionResize},get children(){return y(V.Provider,{get value(){return{snapPoints:()=>n.snapPoints,breakPoints:()=>n.breakPoints,defaultSnapPoint:()=>n.defaultSnapPoint,activeSnapPoint:s,setActiveSnapPoint:a,side:()=>n.side,isDragging:h,isTransitioning:()=>f()!==null,transitionState:f,openPercentage:L,translate:_,velocityCacheReset:()=>n.velocityCacheReset,allowSkippingSnapPoints:()=>n.allowSkippingSnapPoints,handleScrollableElements:()=>n.handleScrollableElements,transitionResize:()=>n.transitionResize,dampFunction:n.dampFunction,velocityFunction:n.velocityFunction,setIsDragging:m,setTranslate:R,drawerSize:x,resolvedActiveSnapPoint:$,drawerStyles:p,setTransitionState:g,transitionSize:u,closeDrawer:w}},get children(){return y(Pg,T({get open(){return b()},onOpenChange:i,get contextId(){return n.contextId},get closeOnOutsidePointer(){return!h()&&n.closeOnOutsidePointer}},r,{children:Q=>Y(Q)}))}})}}))})},Gg=Wg,Yg=e=>{const[t,n]=j(e,["contextId","style"]);let r=!1,o=null,i=[0,0],s,a=0;const l=C(()=>na(t.contextId)),c=C(()=>_t(t.contextId)),d=C(()=>l().snapPoints().map((w,x)=>ra(w,l().drawerSize(),x,l().breakPoints()))),u=C(()=>{switch(l().side()){case"top":return`translate3d(0, ${-l().translate()}px, 0)`;case"bottom":return`translate3d(0, ${l().translate()}px, 0)`;case"right":return`translate3d(${l().translate()}px, 0, 0)`;case"left":return`translate3d(${-l().translate()}px, 0, 0)`}}),h=C(()=>{const w=l().transitionSize();if(w)switch(l().side()){case"top":case"bottom":return`${w}px`}}),m=C(()=>{const w=l().transitionSize();if(w)switch(l().side()){case"left":case"right":return`${w}px`}});D(()=>{c().open()&&(document.addEventListener("pointermove",g),document.addEventListener("touchmove",p),document.addEventListener("pointerup",v),document.addEventListener("touchend",v),K(()=>{document.removeEventListener("pointermove",g),document.removeEventListener("touchmove",p),document.removeEventListener("pointerup",v),document.removeEventListener("touchend",v)}))});const f=w=>{Hg(w.target,c().contentRef())&&l().transitionState()!=="closing"&&(r=!0,l().handleScrollableElements()&&(i=[w.clientX,w.clientY]))},g=w=>{b(w.target,w.clientX,w.clientY)},p=w=>{w.touches[0]&&b(w.target,w.touches[0].clientX,w.touches[0].clientY)},b=(w,x,O)=>{if(!r)return;if(!l().isDragging()||o===null){const $=window.getSelection();if($&&$.toString().length>0){v();return}if(l().handleScrollableElements()){const _=[x,O].map((fe,F)=>i[F]-fe),R=Math.abs(_[0])>Math.abs(_[1])?"x":"y",L=R==="x"?_[0]:_[1];if(Math.abs(L)<.3)return;const I=c().contentRef(),[ne,Y]=Kg(w,R,I);if(L>0&&Math.abs(ne)>1||L<0&&Math.abs(Y)>0){v();return}}switch(l().side()){case"top":case"bottom":o=O;break;case"right":case"left":o=x}s=new Date,a=l().translate(),Ee(()=>{l().setIsDragging(!0),l().setTransitionState(null)})}let k;switch(l().side()){case"top":k=-(o-O);break;case"bottom":k=o-O;break;case"right":k=o-x;break;case"left":k=-(o-x);break}k-=l().resolvedActiveSnapPoint().offset,k>0&&(k=l().dampFunction(k));const E=new Date;E.getTime()-s.getTime()>l().velocityCacheReset()&&(s=E,a=l().translate()),l().setTranslate(-k)},v=()=>{if(r=!1,!l().isDragging())return;const w=new Date,x=l().velocityFunction(-(a-l().translate()),w.getTime()-s.getTime()||1),O=l().translate()*x,k=jg(d(),l().translate(),O,l().allowSkippingSnapPoints());Ee(()=>{l().setTransitionState("snapping"),l().setIsDragging(!1)}),Ee(()=>{l().setActiveSnapPoint(k.value),k.offset===l().drawerSize()?c().setOpen(!1):(l().setTranslate(k.offset),parseFloat(l().drawerStyles().transitionDuration)===0&&l().setTransitionState(null))})};return y(xg,T({get contextId(){return t.contextId},get style(){return{transform:u(),"transition-duration":l().isDragging()?"0ms":void 0,height:h(),width:m(),...t.style}},onPointerDown:f,onTransitionEnd:()=>{Ee(()=>{l().transitionState()==="closing"&&l().closeDrawer(),l().transitionState()!=="resizing"&&l().setTransitionState(null)})},get"data-transitioning"(){return le(l().isTransitioning())},get"data-opening"(){return le(l().transitionState()==="opening")},get"data-closing"(){return le(l().transitionState()==="closing")},get"data-snapping"(){return le(l().transitionState()==="snapping")},get"data-resizing"(){return le(l().transitionState()==="resizing")},"data-corvu-dialog-content":void 0,"data-corvu-drawer-content":""},n))},Xg=Yg,Jg=e=>{const[t,n]=j(e,["contextId"]),r=C(()=>na(t.contextId));return y(kg,T({get contextId(){return t.contextId},get"data-transitioning"(){return le(r().isTransitioning())},get"data-opening"(){return le(r().transitionState()==="opening")},get"data-closing"(){return le(r().transitionState()==="closing")},get"data-snapping"(){return le(r().transitionState()==="snapping")},get"data-resizing"(){return le(r().transitionState()==="resizing")},"data-corvu-dialog-overlay":void 0,"data-corvu-drawer-overlay":""},n))},Zg=Jg,Qg=M('<div class="mx-auto mt-4 h-2 w-[100px] rounded-full bg-muted">');const ep=Gg,tp=Bg,np=Og,rp=e=>{const[,t]=j(e,["class"]),n=Vg();return y(Zg,T({get class(){return Ge("absolute inset-0 z-50 data-[transitioning]:transition-colors data-[transitioning]:duration-300",e.class)},get style(){return{"background-color":`rgb(0 0 0 / ${.6*n.openPercentage()})`}}},t))},op=e=>{const[,t]=j(e,["class","children"]);return y(np,{get mount(){return Wn()},get children(){return[y(rp,{}),y(Xg,T({id:"smarttalks-list-content",get class(){return Ge("absolute inset-x-0 bottom-0 z-50 mt-24 flex h-auto max-h-[80%] flex-col rounded-t-[10px] border bg-background after:top-full after:h-[50%] after:bg-inherit md:select-none transition-transform duration-300",e.class)}},t,{get children(){return[Qg(),C(()=>e.children)]}}))]}})};var ip=M('<span class="font-semibold mt-2">'),sp=M('<div class="flex py-4 pl-3 pr-1 flex-col w-full space-y-4 overflow-y-auto">'),ap=M('<div class="flex flex-col space-y-2"><div>'),lp=M('<div class="flex flex-col w-full space-y-1"><span class="font-semibold text-slate-700">'),cp=M('<div class="flex flex-col items-start"><span class=text-slate-500>');const up=({options:e,text:t,title:n})=>{const{pushMessage:r}=Qe(),[o,i]=P(!1),[s,a]=P(!1),[l,c]=P(),d=(h,m)=>{a(!1),i(!0),r(h,m)},u=h=>{const m=h.composedPath();for(const f of m)if(f.id==="smarttalks-list-content"){h.preventDefault();return}};return(()=>{var h=ap(),m=h.firstChild;return A(h,y(Ot,{get children(){return t?.trim()}}),m),A(m,y(ep,{get open(){return s()},onOpenChange:a,onOutsidePointer:u,get children(){return[y(tp,{as:Te,variant:"outline",class:"w-full text-nowrap",get children(){return n?.trim()??dt("selectOption")}}),y(op,{class:"pb-2 px-2 flex flex-col items-center justify-center",get children(){return[(()=>{var f=ip();return A(f,()=>n?.trim()??dt("selectOption")),f})(),(()=>{var f=sp();return A(f,y(ht,{each:e,children:g=>(()=>{var p=lp(),b=p.firstChild;return A(b,()=>g.label?.trim()??""),A(p,y(ht,{get each(){return g.items},children:v=>y(Te,{variant:"outline",get disabled(){return o()},get class(){return`py-6 flex justify-between hover:bg-slate-200 ${l()===v?"bg-slate-200":""}`},onClick:()=>c(v),get children(){return[(()=>{var w=cp(),x=w.firstChild;return A(w,()=>v.label?.trim(),x),A(x,()=>v.description?.trim()),w})(),y(Z,{get when(){return l()===v},get fallback(){return y(lf,{class:"size-4 text-slate-500"})},get children(){return y(af,{class:"size-4 text-slate-500"})}})]}})}),null),p})()})),f})(),y(Te,{get disabled(){return o()||!l()},onClick:()=>d(l().label,l().value),class:"w-11/12 mt-4 hover:bg-primary shadow-sm hover:shadow-primary transition-shadow",get children(){return dt("send")}})]}})]}})),re(()=>gt(m,o()?"opacity-50":"")),h})()};var dp=M("<audio controls preload=auto class=h-8><source type=audio/mpeg><source type=audio/ogg>Your browser does not support the audio element.");const fp=e=>(()=>{var t=dp(),n=t.firstChild,r=n.nextSibling;return re(o=>{var i=e.link,s=e.link;return i!==o.e&&ue(n,"src",o.e=i),s!==o.t&&ue(r,"src",o.t=s),o},{e:void 0,t:void 0}),t})();var hp=M('<div class="flex flex-col space-y-2"><a class="self-center hover:brightness-75 transition-all duration-300 flex flex-col items-center justify-between bg-slate-200 rounded-md px-1 py-1 space-y-2 text-slate-700"target=_blank><span class="font-semibold text-sm">');const gp=e=>(()=>{var t=hp(),n=t.firstChild,r=n.firstChild;return A(n,y(cf,{class:"size-10"}),r),A(r,()=>e.filename?.trim()),A(t,y(Ot,{get children(){return e.text?.trim()}}),null),re(()=>ue(n,"href",e.link)),t})();var pp=M('<div class="flex flex-col space-y-2"><a class="object-contain hover:brightness-50 transition-all duration-300"target=_blank><img class="w-full h-auto rounded-md">');const mp=e=>(()=>{var t=pp(),n=t.firstChild,r=n.firstChild;return A(t,y(Ot,{get children(){return e.text?.trim()}}),null),re(o=>{var i=e.link,s=e.link,a=e.text?.trim();return i!==o.e&&ue(n,"href",o.e=i),s!==o.t&&ue(r,"src",o.t=s),a!==o.a&&ue(r,"alt",o.a=a),o},{e:void 0,t:void 0,a:void 0}),t})();var yp=M('<div class="flex flex-col space-y-2"><video controls preload=auto class="size-full rounded-md"><source type=video/mp4><source type=video/ogg>Your browser does not support the video element.');const bp=e=>(()=>{var t=yp(),n=t.firstChild,r=n.firstChild,o=r.nextSibling;return A(t,y(Ot,{get children(){return e.text?.trim()}}),null),re(i=>{var s=e.link,a=e.link;return s!==i.e&&ue(r,"src",i.e=s),a!==i.t&&ue(o,"src",i.t=a),i},{e:void 0,t:void 0}),t})();var vp=M("<div>Media type not supported");const ia=e=>e.type==="image"?y(mp,e):e.type==="audio"?y(fp,e):e.type==="document"?y(gp,e):e.type==="video"?y(bp,e):vp(),lo=({text:e})=>y(Ot,{get children(){return e?.trim()}});var wp=M("<div>Unknown bot message type");const xp=e=>y(Ph,{get createdAt(){return e.createdAt},get children(){return e.type==="text"?y(lo,{get text(){return e.text}}):e.type==="buttons"?y(Dh,T(()=>e.buttons)):e.type==="list"?y(up,T(()=>e.list)):e.type==="media"?y(ia,T(()=>e.media)):e.type==="link"?y($h,T(()=>e.link)):e.type==="cards"?y(Ih,T(()=>e.cards)):e.type==="date"?y(lo,{get text(){return e.text}}):wp()}});var Sp=M('<div class="place-self-center p-4"><span class="bg-slate-200/40 text-black font-semibold py-2 px-4 rounded-xl">');const Ep=e=>(()=>{var t=Sp(),n=t.firstChild;return A(n,()=>e.text?.trim()),t})();var kp=M('<div class="place-self-end py-1 flex flex-col"><div class="bg-primary shadow-primary/40 shadow-md py-2 px-4 rounded-l-xl rounded-tr-xl text-primary-foreground">');const Cp=({children:e,createdAt:t})=>(()=>{var n=kp(),r=n.firstChild;return A(r,e),A(n,y(Us,{createdAt:t,anchor:"end"}),null),n})();var Op=M("<div>Unknown user message type");const _p=e=>y(Cp,{get createdAt(){return e.createdAt},get children(){return e.type==="text"?y(lo,{get text(){return e.text}}):e.type==="media"?y(ia,T(()=>e.media)):Op()}});var Pp=M("<div>Unknown message origin");const Ap=e=>e.origin==="bot"?y(xp,e):e.origin==="user"?y(_p,e):e.origin==="service"?y(Ep,e):Pp();function Tp(e){return ve({a:{viewBox:"0 0 512 512"},c:'<path d="m289.94 256 95-95A24 24 0 0 0 351 127l-95 95-95-95a24 24 0 0 0-34 34l95 95-95 95a24 24 0 1 0 34 34l95-95 95 95a24 24 0 0 0 34-34Z"/>'},e)}function Pt(e){return ve({a:{viewBox:"0 0 512 512"},c:'<path d="M256 464c-114.69 0-208-93.31-208-208S141.31 48 256 48s208 93.31 208 208-93.31 208-208 208Z"/>'},e)}var Dp=M('<div class="place-self-start py-1"><div class="animate-pulse bg-white flex space-x-1 shadow-md py-2 px-4 rounded-r-xl rounded-tl-xl text-slate-400">');const Lp=()=>(()=>{var e=Dp(),t=e.firstChild;return A(t,y(Pt,{class:"size-2 animate-bounce"}),null),A(t,y(Pt,{class:"size-2 animate-bounce delay-150"}),null),A(t,y(Pt,{class:"size-2 animate-bounce delay-300"}),null),e})();var Mp=M('<main class="flex-grow p-4 overflow-y-auto flex flex-col items-center scroll-smooth relative">'),Ip=M("<div>");const co=()=>{let e;const{getMessages:t,onMessage:n,typing:r,clearMessages:o}=Qe(),{onOpen:i}=Xo(),s=(a=100)=>{setTimeout(()=>{e?.scrollTo(0,e.scrollHeight)},a)};return se("reset",()=>{o()}),tn(()=>{s(200)}),n(s),i(()=>s(200)),(()=>{var a=Mp(),l=e;return typeof l=="function"?ir(l,a):e=a,A(a,y(ht,{get each(){return t()},get fallback(){return(()=>{var c=Ip();return A(c,()=>dt("emptyMessages")),c})()},children:c=>y(Ap,c)}),null),A(a,y(Z,{get when(){return r()},get children(){return y(Lp,{})}}),null),a})()};var Rp=M("<textarea>");const $p=e=>{const[,t]=j(e,["class"]);return(()=>{var n=Rp();return tt(n,T({get class(){return Ge("flex w-full rounded-md border border-input bg-transparent px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",e.class)}},t),!1,!1),n})()};var Fp=M('<svg viewBox="0 0 72 72"fill=none xmlns=http://www.w3.org/2000/svg><path d="M50.3241 0H21.6759C9.69907 0 0 9.68892 0 21.6519V50.3481C0 62.3111 9.69907 72 21.6759 72H67.9815C70.2546 72 72 70.1845 72 67.9105V21.6519C72 9.68892 62.3009 0 50.3241 0Z"fill=#212431></path><path d="M28.9868 56.1046H24.7249C21.9596 56.1046 19.7217 53.8671 19.7217 51.1129V45.9126C19.7217 44.244 18.3676 42.8929 16.6952 42.8929H13.6924C11.8108 42.8929 10.2857 41.3712 10.2857 39.494V37.0622C10.2857 35.185 11.8108 33.6633 13.6924 33.6633H25.3758C27.3713 33.6633 28.9868 35.275 28.9868 37.2613V56.1046Z"fill=white></path><path d="M61.7142 26.3227C61.7142 28.1782 60.2059 29.6992 58.3661 29.6992H46.2955V56.1042H37.629C34.9627 56.1042 32.8054 53.9238 32.8054 51.2395V36.1839C32.8054 32.6002 29.9243 29.6992 26.3755 29.6992H20.1791C18.3393 29.6992 16.8311 28.1782 16.8311 26.3227V19.2729C16.8311 17.408 18.33 15.8964 20.1791 15.8964H58.3661C60.2153 15.8964 61.7142 17.408 61.7142 19.2729V26.3227Z"fill=white>');const Np=e=>(()=>{var t=Fp();return tt(t,e,!0,!0),t})();var Kp=M('<div class="absolute flex items-center justify-center left-1/2 transform -translate-x-1/2 bottom-0 pb-1"><span class="font-semibold text-xs text-gray-600 ml-1">SmartTalks.ai');const Bp=()=>(()=>{var e=Kp(),t=e.firstChild;return A(e,y(Np,{height:15}),t),e})();var zp=M('<footer class="relative flex-none p-4 bg-white min-h-16 flex space-x-1 pb-6">');const uo=()=>{const{pushMessage:e}=Qe(),[t,n]=P(""),r=()=>{e(t()),n("")},o=i=>{i.key==="Enter"&&!i.shiftKey&&r()};return se("setInput",i=>{i&&n(i)}),(()=>{var i=zp();return A(i,y($p,{get placeholder(){return dt("inputPlaceholder")},get value(){return t()},onInput:s=>n(s.currentTarget.value),onkeyup:o,class:"focus-visible:ring-primary h-10",style:"resize: none;",autofocus:!0}),null),A(i,y(Te,{variant:"outline",class:"p-2","aria-label":"Send",type:"button",onClick:r,get children(){return y(gc,{size:24})}}),null),A(i,y(Bp,{}),null),i})()};var Vp=M('<div id=smarttalks-widget class="rounded-md shadow-xl h-[85vh] w-[90vw] md:h-[min(100vh,500px)] md:w-[min(100vw,400px)] overflow-hidden bg-background text-foreground flex flex-col relative">'),Up=M("<span class=sr-only>Close"),jp=M("<div>"),Hp=M("<span class=sr-only>Open"),qp=M("<span>"),Wp=M('<div class="animate-pulse flex p-1">');const Gp=({children:e,openIcon:t})=>{const{bubble:n,toggle:r,show:o,hide:i}=Xo(),{chatWidget:s}=oe(),[a,l]=P(!0);setTimeout(()=>l(!1),2e3),s()?.openDelay&&setTimeout(()=>{o()},(s()?.openDelay||0)*1e3);const c=()=>(s()?.style.margin??5)/4,d=()=>s()?.style.position==="left"?{left:`${c()}rem`}:{right:`${c()}rem`};return se("open",()=>{o()}),se("close",()=>{i()}),se("toggle",()=>{r()}),(()=>{var u=jp();return A(u,y(Z,{get when(){return n()},get children(){var h=Vp();return A(h,e),h}}),null),A(u,y(Z,{get when(){return n()},get fallback(){return y(Te,{onclick:r,class:"rounded-full py-6 px-0 hover:shadow-primary shadow-md border border-primary transition-shadow duration-300","aria-label":"Open",type:"button",get children(){return[t,Hp(),y(Z,{get when(){return s()?.balloonMessage},get children(){var h=qp();return A(h,y(Z,{get when(){return!a()},get fallback(){return(()=>{var m=Wp();return A(m,y(Pt,{class:"size-2 animate-bounce"}),null),A(m,y(Pt,{class:"size-2 animate-bounce delay-150"}),null),A(m,y(Pt,{class:"size-2 animate-bounce delay-300"}),null),m})()},get children(){return s()?.balloonMessage}})),re(()=>gt(h,"absolute -top-2 bg-primary text-primary-foreground px-1 py-0.5 pointer-events-none rounded truncate"+(s()?.style.position==="left"?" left-9":" right-9"))),h}})]}})},get children(){return y(Te,{onclick:r,class:"rounded-full py-6 px-2 hover:bg-primary hover:shadow-primary shadow-md transition-shadow duration-300","aria-label":"Close",type:"button",get children(){return[y(Tp,{size:30}),Up()]}})}}),null),re(h=>{var m="max-h-full max-w-full md:max-h-[90%] md:max-w-[90%] fixed bottom-5 flex flex-col space-y-2"+(s()?.style.position==="left"?" items-start":" items-end"),f=d();return m!==h.e&>(u,h.e=m),h.t=an(u,f,h.t),h},{e:void 0,t:void 0}),u})()};var Yp=M('<div id=smarttalks-widget class="h-screen w-full overflow-hidden bg-background text-foreground flex flex-col rounded-md">');const Xp=({children:e})=>{const{chatWidget:t}=oe(),n={};return t()?.style.width&&(n.width=`min(100vw, ${t()?.style.width}px)`),t()?.style.height&&(n.height=`min(100vh, ${t()?.style.height}px)`),(()=>{var r=Yp();return an(r,n),A(r,e),r})()};var Jp=M('<div id=smarttalks-widget class="h-[85vh] w-[90vw] md:h-[min(100vh,500px)] md:w-[min(100vw,400px)] max-h-full max-w-full md:max-h-[90%] md:max-w-[90%] fixed bottom-5 rounded-md shadow-xl overflow-hidden bg-background text-foreground flex flex-col">');const Zp=({children:e})=>{const{chatWidget:t}=oe(),[n,r]=P(!1),o=()=>(t()?.style.margin??5)/4,i=()=>{const s={};return t()?.fullscreen?(s.height="100%",s["max-height"]="100%",s.width="100%",s["max-width"]="100%",s.bottom=0,s.left=0):t()?.style.position&&(s[t()?.style.position||"right"]=`${o()}rem`),s};return se("open",()=>{r(!0),ee("onOpen")}),se("close",()=>{r(!1),ee("onClose")}),se("toggle",()=>{r(!n()),ee("onToggle")}),setTimeout(()=>{r(!0),ee("onOpen")},(t()?.openDelay||0)*1e3),y(Z,{get when(){return n()},get children(){var s=Jp();return A(s,e),re(a=>an(s,i(),a)),s}})};var Qp=M('<div class="absolute bg-black/50 text-white font-bold h-full w-full grid place-content-center z-50">');const fo=()=>(()=>{var e=Qp();return A(e,y(hc,{size:45,class:"animate-spin"})),e})(),em=()=>{const{chatWidget:e}=oe(),{loading:t}=Qe();return y(Gp,{get openIcon(){return y(ii,{get src(){return e()?.avatar}})},get children(){return[y(Z,{get when(){return t()},get children(){return y(fo,{})}}),y(Qr,{}),y(co,{}),y(uo,{})]}})},tm=()=>{const{loading:e}=Qe();return y(Zp,{get children(){return[y(Z,{get when(){return e()},get children(){return y(fo,{})}}),y(Qr,{}),y(co,{}),y(uo,{})]}})},nm=()=>{const{loading:e}=Qe();return y(Xp,{get children(){return[y(Z,{get when(){return e()},get children(){return y(fo,{})}}),y(Qr,{}),y(co,{}),y(uo,{})]}})},rm=()=>{const{chatWidget:e}=oe();return y(Bo,{get children(){return[y(It,{get when(){return e()?.mode==="standard"},get children(){return y(em,{})}}),y(It,{get when(){return e()?.mode==="popup"},get children(){return y(tm,{})}}),y(It,{get when(){return e()?.mode==="static"},get children(){return y(nm,{})}})]}})};var om=M("<div><div>Form");const im=()=>{const{formWidget:e}=oe();return(()=>{var t=om();return t.firstChild,A(t,()=>e()?._id,null),t})()};function sm(){const{widget:e}=oe();return y(Bo,{get children(){return[y(It,{get when(){return e()?.type==="chat"},get children(){return y(rm,{})}}),y(It,{get when(){return e()?.type==="form"},get children(){return y(im,{})}})]}})}var am=M("<style>"),lm=M("<div>");const cm=({id:e,settings:t,side:n,margin:r,mode:o})=>{const{setWidgetId:i}=oe(),s=(e||"default")+"?"+(t?"&showSettings":"")+(n?`&${n}`:"")+(r?`&margin=${r}`:"")+(o?`&mode=${o}`:"");return i(s),[(()=>{var a=am();return A(a,zl),a})(),(()=>{var a=lm();return A(a,y(sm,{})),a})()]},um={id:"",settings:!1,side:void 0,margin:void 0,mode:void 0};(()=>{typeof window>"u"||Bl("smarttalks-widget",um,cm)})(),Va()});
|