@smarttalks.ai/widget 0.12.0 → 0.13.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 +5 -1
- package/lib/index.umd.cjs +1 -1
- package/package.json +1 -1
package/lib/index.js
CHANGED
|
@@ -8384,7 +8384,11 @@ async function xf(e, t, n) {
|
|
|
8384
8384
|
channelId: n,
|
|
8385
8385
|
postback: t,
|
|
8386
8386
|
type: "text",
|
|
8387
|
-
text: e
|
|
8387
|
+
text: e,
|
|
8388
|
+
metadata: {
|
|
8389
|
+
pageUrl: window.location.href,
|
|
8390
|
+
pageTitle: document.title
|
|
8391
|
+
}
|
|
8388
8392
|
})
|
|
8389
8393
|
};
|
|
8390
8394
|
await fetch(r, s);
|
package/lib/index.umd.cjs
CHANGED
|
@@ -178,7 +178,7 @@
|
|
|
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 Yd(e,t){return t?Hc([e.clientX,e.clientY],t):!1}function Xd(e){const t=Ct(),n=Ni(),r=gs(),o=Me({placement:"bottom-start"},e),[i,s]=j(o,["open","defaultOpen","onOpenChange"]);let a=0,l=null,c="right";const[d,u]=O(),[f,g]=O(),[h,p]=O(),[m,b]=O(),[w,v]=O(!0),[x,_]=O(s.placement),[E,k]=O([]),[F,P]=O([]),{DomCollectionProvider:R}=ju({items:F,onItemsChange:P}),M=xi({open:()=>i.open,defaultOpen:()=>i.defaultOpen,onOpenChange:U=>i.onOpenChange?.(U)}),I=fu(()=>t.forceMount()||M.isOpen()),re=Mu({selectionMode:"none",dataSource:F}),Y=U=>{v(U),M.open()},fe=(U=!1)=>{M.close(),U&&r&&r.close(!0)},$=U=>{v(U),M.toggle()},V=()=>{const U=m();U&&(de(U),re.selectionManager().setFocused(!0),re.selectionManager().setFocusedKey(void 0))},Q=U=>{k(go=>[...go,U]);const Un=r?.registerNestedMenu(U);return()=>{k(go=>dr(go,U)),Un?.()}},se=U=>c===l?.side&&Yd(U,l?.area),At=U=>{se(U)&&U.preventDefault()},Ae=U=>{se(U)||V()},dm=U=>{se(U)&&U.preventDefault()};cu({isDisabled:()=>!(r==null&&M.isOpen()&&t.isModal()),targets:()=>[m(),...E()].filter(Boolean)}),T(()=>{const U=m();if(!U||!r)return;const Un=r.registerNestedMenu(U);K(()=>{Un()})});const fm={dataset:C(()=>({"data-expanded":M.isOpen()?"":void 0,"data-closed":M.isOpen()?void 0:""})),isOpen:M.isOpen,contentPresence:I,nestedMenus:E,currentPlacement:x,pointerGraceTimeoutId:()=>a,autoFocus:w,listState:()=>re,parentMenuContext:()=>r,triggerRef:h,contentRef:m,triggerId:d,contentId:f,setTriggerRef:p,setContentRef:b,open:Y,close:fe,toggle:$,focusContent:V,onItemEnter:At,onItemLeave:Ae,onTriggerLeave:dm,setPointerDir:U=>c=U,setPointerGraceTimeoutId:U=>a=U,setPointerGraceIntent:U=>l=U,registerNestedMenu:Q,registerItemToParentDomCollection:n?.registerItem,registerTriggerId:yn(u),registerContentId:yn(g)};return y(R,{get children(){return y(hs.Provider,{value:fm,get children(){return y(Gd,L({anchorRef:h,contentRef:m,onCurrentPlacementChange:_},s))}})}})}const Jd=ce();function Zd(e){let t;const n=Ct(),r=Et(),o=Me({id:n.generateId(`item-${Te()}`)},e),[i,s]=j(o,["ref","textValue","disabled","closeOnSelect","checked","indeterminate","onSelect","onPointerMove","onPointerLeave","onPointerDown","onPointerUp","onClick","onKeyDown","onMouseDown","onFocus"]),[a,l]=O(),[c,d]=O(),[u,f]=O(),g=()=>r.listState().selectionManager(),h=()=>s.id,p=()=>g().focusedKey()===h(),m=()=>{i.onSelect?.(),i.closeOnSelect&&r.close(!0)};qu({getItem:()=>({ref:()=>t,type:"item",key:h(),textValue:i.textValue??u()?.textContent??t?.textContent??"",disabled:i.disabled??!1})});const b=Tu({key:h,selectionManager:g,shouldSelectOnPressUp:!0,allowsDifferentPressOrigin:!0,disabled:()=>i.disabled},()=>t),w=P=>{ge(P,i.onPointerMove),P.pointerType==="mouse"&&(i.disabled?r.onItemLeave(P):(r.onItemEnter(P),P.defaultPrevented||(de(P.currentTarget),r.listState().selectionManager().setFocused(!0),r.listState().selectionManager().setFocusedKey(h()))))},v=P=>{ge(P,i.onPointerLeave),P.pointerType==="mouse"&&r.onItemLeave(P)},x=P=>{ge(P,i.onPointerUp),!i.disabled&&P.button===0&&m()},_=P=>{if(ge(P,i.onKeyDown),!P.repeat&&!i.disabled)switch(P.key){case"Enter":case" ":m();break}},E=C(()=>{if(i.indeterminate)return"mixed";if(i.checked!=null)return i.checked}),k=C(()=>({"data-indeterminate":i.indeterminate?"":void 0,"data-checked":i.checked&&!i.indeterminate?"":void 0,"data-disabled":i.disabled?"":void 0,"data-highlighted":p()?"":void 0})),F={isChecked:()=>i.checked,dataset:k,setLabelRef:f,generateId:ui(()=>s.id),registerLabel:yn(l),registerDescription:yn(d)};return y(Jd.Provider,{value:F,get children(){return y(bn,L({as:"div",ref(P){var R=st(M=>t=M,i.ref);typeof R=="function"&&R(P)},get tabIndex(){return b.tabIndex()},get"aria-checked"(){return E()},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 ve([i.onPointerDown,b.onPointerDown])},get onPointerUp(){return ve([x,b.onPointerUp])},get onClick(){return ve([i.onClick,b.onClick])},get onKeyDown(){return ve([_,b.onKeyDown])},get onMouseDown(){return ve([i.onMouseDown,b.onMouseDown])},get onFocus(){return ve([i.onFocus,b.onFocus])},onPointerMove:w,onPointerLeave:v},k,s))}})}const Qd=ce();function ms(){return he(Qd)}function ef(e){let t;const n=Ct(),r=Et(),o=ms(),i=Me({id:n.generateId(`content-${Te()}`)},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=Iu({selectionManager:r.listState().selectionManager,collection:r.listState().collection,autoFocus:r.autoFocus,deferAutoFocus:!0,shouldFocusWrap:!0,disallowTypeAhead:()=>!r.listState().selectionManager().isFocused()},()=>t);au({trapFocus:()=>c()&&r.isOpen(),onMountAutoFocus:m=>{o===void 0&&s.onOpenAutoFocus?.(m)},onUnmountAutoFocus:s.onCloseAutoFocus},()=>t);const u=m=>{if(Le(m.currentTarget,m.target)&&(m.key==="Tab"&&r.isOpen()&&m.preventDefault(),o!==void 0&&m.currentTarget.getAttribute("aria-haspopup")!=="true"))switch(m.key){case"ArrowRight":m.stopPropagation(),m.preventDefault(),r.close(!0),o.setAutoFocusMenu(!0),o.nextMenu();break;case"ArrowLeft":if(m.currentTarget.hasAttribute("data-closed"))break;m.stopPropagation(),m.preventDefault(),r.close(!0),o.setAutoFocusMenu(!0),o.previousMenu();break}},f=m=>{s.onEscapeKeyDown?.(m),o?.setAutoFocusMenu(!1),r.close(!0)},g=m=>{s.onFocusOutside?.(m),n.isModal()&&m.preventDefault()},h=m=>{ge(m,s.onPointerEnter),r.isOpen()&&(r.parentMenuContext()?.listState().selectionManager().setFocused(!1),r.parentMenuContext()?.listState().selectionManager().setFocusedKey(void 0))},p=m=>{if(ge(m,s.onPointerMove),m.pointerType!=="mouse")return;const b=m.target,w=l!==m.clientX;Le(m.currentTarget,b)&&w&&(r.setPointerDir(m.clientX>l?"right":"left"),l=m.clientX)};return T(()=>K(r.registerContentId(s.id))),y(Z,{get when(){return r.contentPresence.isPresent()},get children(){return y(rd,{get children(){return y(td,L({ref(m){var b=st(w=>{r.setContentRef(w),r.contentPresence.setRef(w),t=w},s.ref);typeof b=="function"&&b(m)},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:f,onFocusOutside:g,get onDismiss(){return r.close},get onKeyDown(){return ve([s.onKeyDown,d.onKeyDown,u])},get onMouseDown(){return ve([s.onMouseDown,d.onMouseDown])},get onFocusIn(){return ve([s.onFocusIn,d.onFocusIn])},get onFocusOut(){return ve([s.onFocusOut,d.onFocusOut])},onPointerEnter:h,onPointerMove:p},()=>r.dataset(),a))}})}})}function tf(e){let t;const n=Ct(),r=Et(),[o,i]=j(e,["ref"]);return Hi({element:()=>t??null,enabled:()=>r.isOpen()&&n.preventScroll()}),y(ef,L({ref(s){var a=st(l=>{t=l},o.ref);typeof a=="function"&&a(s)}},i))}function nf(e){return y(Zd,L({role:"menuitem",closeOnSelect:!0},e))}function rf(e){const t=Et();return y(Z,{get when(){return t.contentPresence.isPresent()},get children(){return y(Wo,e)}})}function of(e){const t=`menu-${Te()}`,n=Me({id:t,modal:!0},e),[r,o]=j(n,["id","modal","preventScroll","forceMount","open","defaultOpen","onOpenChange","value"]),i=xi({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:ui(()=>r.id),value:()=>r.value};return y(ps.Provider,{value:s,get children(){return y(Xd,L({get open(){return i.isOpen()},get onOpenChange(){return i.setIsOpen}},o))}})}function sf(e){const t=Ct(),n=Et(),r=ms(),o=Me({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,T(()=>{r.registerMenu(a,[n.contentRef(),...n.nestedMenus()])}),T(()=>{r.value()===a?(n.triggerRef()?.focus(),r.autoFocusMenu()&&n.open(!0)):n.close(!0)}),T(()=>{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=h=>{ge(h,i.onPointerDown),h.currentTarget.dataset.pointerType=h.pointerType,!i.disabled&&h.pointerType!=="touch"&&h.button===0&&l()},d=h=>{ge(h,i.onClick),i.disabled||h.currentTarget.dataset.pointerType==="touch"&&l()},u=h=>{if(ge(h,i.onKeyDown),!i.disabled)switch(h.key){case"Enter":case" ":case"ArrowDown":h.stopPropagation(),h.preventDefault(),Wc(h.currentTarget),n.toggle("first");break;case"ArrowUp":h.stopPropagation(),h.preventDefault(),n.toggle("last");break;case"ArrowRight":if(r===void 0)break;h.stopPropagation(),h.preventDefault(),r.nextMenu();break;case"ArrowLeft":if(r===void 0)break;h.stopPropagation(),h.preventDefault(),r.previousMenu();break}},f=h=>{ge(h,i.onMouseOver),!i.disabled&&r!==void 0&&r.value()!==void 0&&r.setValue(a)},g=h=>{ge(h,i.onFocus),r!==void 0&&r.setValue(a)};return T(()=>K(n.registerTriggerId(i.id))),y($u,L({ref(h){var p=st(n.setTriggerRef,i.ref);typeof p=="function"&&p(h)},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:f,onClick:d,onKeyDown:u,onFocus:g,role:r!==void 0?"menuitem":void 0},()=>n.dataset(),s))}function af(e){const t=Ct(),n=Et(),[r,o]=j(e,["onCloseAutoFocus","onInteractOutside"]);let i=!1;return y(tf,L({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 lf(e){const t=`dropdownmenu-${Te()}`,n=Me({id:t},e);return y(of,n)}function cf(e){return we({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 uf(e){return we({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 df(e){return we({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 ff=e=>y(lf,L({gutter:4},e)),hf=sf,gf=e=>{const[,t]=j(e,["class"]);return y(rf,{get mount(){return Jt()},get children(){return y(af,L({get class(){return Ge("z-50 min-w-[128px] 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))}})},pf=e=>{const[,t]=j(e,["class"]);return y(nf,L({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 mf(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 yf(e){if(Array.isArray(e)){console.info("----------------------------------------------------------");for(const t of e)console.info("Executed:",t.type),console.info(t)}}async function bf(e,t,n){const r=`${Zt}/v1/messages`,o=lr(),i={"Content-Type":"application/json"};o&&(i["x-session-id"]=o);const s={credentials:"include",method:"POST",headers:i,body:JSON.stringify({channelId:n,postback:t,type:"text",text:e})};await fetch(r,s)}async function wf(e,t,n){if(!e||!t||!n)return;const r=`${Zt}/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 Fe=Object.create(null);Fe.open="0",Fe.close="1",Fe.ping="2",Fe.pong="3",Fe.message="4",Fe.upgrade="5",Fe.noop="6";const _n=Object.create(null);Object.keys(Fe).forEach(e=>{_n[Fe[e]]=e});const $r={type:"error",data:"parser error"},ys=typeof Blob=="function"||typeof Blob<"u"&&Object.prototype.toString.call(Blob)==="[object BlobConstructor]",bs=typeof ArrayBuffer=="function",ws=e=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(e):e&&e.buffer instanceof ArrayBuffer,Nr=({type:e,data:t},n,r)=>ys&&t instanceof Blob?n?r(t):vs(t,r):bs&&(t instanceof ArrayBuffer||ws(t))?n?r(t):vs(new Blob([t]),r):r(Fe[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 xs(e){return e instanceof Uint8Array?e:e instanceof ArrayBuffer?new Uint8Array(e):new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}let Kr;function vf(e,t){if(ys&&e.data instanceof Blob)return e.data.arrayBuffer().then(xs).then(t);if(bs&&(e.data instanceof ArrayBuffer||ws(e.data)))return t(xs(e.data));Nr(e,!1,n=>{Kr||(Kr=new TextEncoder),t(Kr.encode(n))})}const Ss="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Wt=typeof Uint8Array>"u"?[]:new Uint8Array(256);for(let e=0;e<Ss.length;e++)Wt[Ss.charCodeAt(e)]=e;const xf=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},Sf=typeof ArrayBuffer=="function",zr=(e,t)=>{if(typeof e!="string")return{type:"message",data:ks(e,t)};const n=e.charAt(0);return n==="b"?{type:"message",data:kf(e.substring(1),t)}:_n[n]?e.length>1?{type:_n[n],data:e.substring(1)}:{type:_n[n]}:$r},kf=(e,t)=>{if(Sf){const n=xf(e);return ks(n,t)}else return{base64:!0,data:e}},ks=(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="",Ef=(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))})})},Cf=(e,t)=>{const n=e.split(Es),r=[];for(let o=0;o<n.length;o++){const i=zr(n[o],t);if(r.push(i),i.type==="error")break}return r};function Of(){return new TransformStream({transform(e,t){vf(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 Br;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 _f(e,t){Br||(Br=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($r);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(zr(i?l:Br.decode(l),t)),r=0}if(o===0||o>e){a.enqueue($r);break}}}})}const Cs=4;function te(e){if(e)return Pf(e)}function Pf(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")(),Af="arraybuffer";function mm(){}function Os(e,...t){return t.reduce((n,r)=>(e.hasOwnProperty(r)&&(n[r]=e[r]),n),{})}const Tf=Se.setTimeout,Lf=Se.clearTimeout;function Ln(e,t){t.useNativeTimers?(e.setTimeoutFn=Tf.bind(Se),e.clearTimeoutFn=Lf.bind(Se)):(e.setTimeoutFn=Se.setTimeout.bind(Se),e.clearTimeoutFn=Se.clearTimeout.bind(Se))}const Mf=1.33;function Df(e){return typeof e=="string"?If(e):Math.ceil((e.byteLength||e.size)*Mf)}function If(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 _s(){return Date.now().toString(36).substring(3)+Math.random().toString(36).substring(2,5)}function Rf(e){let t="";for(let n in e)e.hasOwnProperty(n)&&(t.length&&(t+="&"),t+=encodeURIComponent(n)+"="+encodeURIComponent(e[n]));return t}function Ff(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 $f 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,Ln(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 $f(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=zr(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=Rf(t);return n.length?"?"+n:""}}class Nf 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)};Cf(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,Ef(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]=_s()),!this.supportsBinary&&!n.sid&&(n.b64=1),this.createUri(t,n)}}let Ps=!1;try{Ps=typeof XMLHttpRequest<"u"&&"withCredentials"in new XMLHttpRequest}catch{}const Kf=Ps;function zf(){}class Bf extends Nf{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 $e extends te{constructor(t,n,r){super(),this.createRequest=t,Ln(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=Os(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=$e.requestsCount++,$e.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=zf,t)try{this._xhr.abort()}catch{}typeof document<"u"&&delete $e.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($e.requestsCount=0,$e.requests={},typeof document<"u"){if(typeof attachEvent=="function")attachEvent("onunload",As);else if(typeof addEventListener=="function"){const e="onpagehide"in Se?"pagehide":"unload";addEventListener(e,As,!1)}}function As(){for(let e in $e.requests)$e.requests.hasOwnProperty(e)&&$e.requests[e].abort()}const Vf=function(){const e=Ts({xdomain:!1});return e&&e.responseType!==null}();class Uf extends Bf{constructor(t){super(t);const n=t&&t.forceBase64;this.supportsBinary=Vf&&!n}request(t={}){return Object.assign(t,{xd:this.xd},this.opts),new $e(Ts,this.uri(),t)}}function Ts(e){const t=e.xdomain;try{if(typeof XMLHttpRequest<"u"&&(!t||Kf))return new XMLHttpRequest}catch{}if(!t)try{return new Se[["Active"].concat("Object").join("X")]("Microsoft.XMLHTTP")}catch{}}const Ls=typeof navigator<"u"&&typeof navigator.product=="string"&&navigator.product.toLowerCase()==="reactnative";class jf extends Vr{get name(){return"websocket"}doOpen(){const t=this.uri(),n=this.opts.protocols,r=Ls?{}:Os(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]=_s()),this.supportsBinary||(n.b64=1),this.createUri(t,n)}}const Ur=Se.WebSocket||Se.MozWebSocket;class qf extends jf{createSocket(t,n,r){return Ls?new Ur(t,n,r):n?new Ur(t,n):new Ur(t)}doWrite(t,n){this.ws.send(n)}}class Hf 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=_f(Number.MAX_SAFE_INTEGER,this.socket.binaryType),r=t.readable.pipeThrough(n).getReader(),o=Of();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 Wf={websocket:qf,webtransport:Hf,polling:Uf},Gf=/^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,Yf=["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=Gf.exec(e||""),i={},s=14;for(;s--;)i[Yf[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=Xf(i,i.path),i.queryKey=Jf(i,i.query),i}function Xf(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 Jf(e,t){const n={};return t.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,function(r,o,i){o&&(n[o]=i)}),n}const qr=typeof addEventListener=="function"&&typeof removeEventListener=="function",Mn=[];qr&&addEventListener("offline",()=>{Mn.forEach(e=>e())},!1);class Ze extends te{constructor(t,n){if(super(),this.binaryType=Af,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);Ln(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=Ff(this.opts.query)),qr&&(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"})},Mn.push(this._offlineEventListener))),this.opts.withCredentials&&(this._cookieJar=void 0),this._open()}createTransport(t){const n=Object.assign({},this.opts.query);n.EIO=Cs,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(),qr&&(this._beforeunloadEventListener&&removeEventListener("beforeunload",this._beforeunloadEventListener,!1),this._offlineEventListener)){const r=Mn.indexOf(this._offlineEventListener);r!==-1&&Mn.splice(r,1)}this.readyState="closed",this.id=null,this.emitReserved("close",t,n),this.writeBuffer=[],this._prevBufferLen=0}}}Ze.protocol=Cs;class Zf 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 f=new Error("probe error");f.transport=n.name,this.emitReserved("upgradeError",f)}}))};function i(){r||(r=!0,d(),n.close(),n=null)}const s=u=>{const f=new Error("probe error: "+u);f.transport=n.name,i(),this.emitReserved("upgradeError",f)};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 Qf=class extends Zf{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=>Wf[o]).filter(o=>!!o)),super(t,r)}};function eh(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 th=typeof ArrayBuffer=="function",nh=e=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(e):e.buffer instanceof ArrayBuffer,Ms=Object.prototype.toString,rh=typeof Blob=="function"||typeof Blob<"u"&&Ms.call(Blob)==="[object BlobConstructor]",oh=typeof File=="function"||typeof File<"u"&&Ms.call(File)==="[object FileConstructor]";function Hr(e){return th&&(e instanceof ArrayBuffer||nh(e))||rh&&e instanceof Blob||oh&&e instanceof File}function Dn(e,t){if(!e||typeof e!="object")return!1;if(Array.isArray(e)){for(let n=0,r=e.length;n<r;n++)if(Dn(e[n]))return!0;return!1}if(Hr(e))return!0;if(e.toJSON&&typeof e.toJSON=="function"&&arguments.length===1)return Dn(e.toJSON(),!0);for(const n in e)if(Object.prototype.hasOwnProperty.call(e,n)&&Dn(e[n]))return!0;return!1}function ih(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(Hr(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 sh(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 ah=["connect","connect_error","disconnect","disconnecting","newListener","removeListener"],lh=5;var B;(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"})(B||(B={}));class ch{constructor(t){this.replacer=t}encode(t){return(t.type===B.EVENT||t.type===B.ACK)&&Dn(t)?this.encodeAsBinary({type:t.type===B.EVENT?B.BINARY_EVENT:B.BINARY_ACK,nsp:t.nsp,data:t.data,id:t.id}):[this.encodeAsString(t)]}encodeAsString(t){let n=""+t.type;return(t.type===B.BINARY_EVENT||t.type===B.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=ih(t),r=this.encodeAsString(n.packet),o=n.buffers;return o.unshift(r),o}}function Ds(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===B.BINARY_EVENT;r||n.type===B.BINARY_ACK?(n.type=r?B.EVENT:B.ACK,this.reconstructor=new uh(n),n.attachments===0&&super.emitReserved("decoded",n)):super.emitReserved("decoded",n)}else if(Hr(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(B[r.type]===void 0)throw new Error("unknown packet type "+r.type);if(r.type===B.BINARY_EVENT||r.type===B.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 B.CONNECT:return Ds(n);case B.DISCONNECT:return n===void 0;case B.CONNECT_ERROR:return typeof n=="string"||Ds(n);case B.EVENT:case B.BINARY_EVENT:return Array.isArray(n)&&(typeof n[0]=="number"||typeof n[0]=="string"&&ah.indexOf(n[0])===-1);case B.ACK:case B.BINARY_ACK:return Array.isArray(n)}}destroy(){this.reconstructor&&(this.reconstructor.finishedReconstruction(),this.reconstructor=null)}}class uh{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=sh(this.reconPack,this.buffers);return this.finishedReconstruction(),n}return null}finishedReconstruction(){this.reconPack=null,this.buffers=[]}}const dh=Object.freeze(Object.defineProperty({__proto__:null,Decoder:Yr,Encoder:ch,get PacketType(){return B},protocol:lh},Symbol.toStringTag,{value:"Module"}));function Pe(e,t,n){return e.on(t,n),function(){e.off(t,n)}}const fh=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1});class Is 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=[Pe(t,"open",this.onopen.bind(this)),Pe(t,"packet",this.onpacket.bind(this)),Pe(t,"error",this.onerror.bind(this)),Pe(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(fh.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:B.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:B.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 B.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 B.EVENT:case B.BINARY_EVENT:this.onevent(t);break;case B.ACK:case B.BINARY_ACK:this.onack(t);break;case B.DISCONNECT:this.ondisconnect();break;case B.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:B.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:B.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 Ot(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}Ot.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},Ot.prototype.reset=function(){this.attempts=0},Ot.prototype.setMin=function(e){this.ms=e},Ot.prototype.setMax=function(e){this.max=e},Ot.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,Ln(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 Ot({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||dh;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 Qf(this.uri,this.opts);const n=this.engine,r=this;this._readyState="opening",this.skipReconnect=!1;const o=Pe(n,"open",function(){r.onopen(),t&&t()}),i=a=>{this.cleanup(),this._readyState="closed",this.emitReserved("error",a),t?t(a):this.maybeReconnectOnOpen()},s=Pe(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(Pe(t,"ping",this.onping.bind(this)),Pe(t,"data",this.ondata.bind(this)),Pe(t,"error",this.onerror.bind(this)),Pe(t,"close",this.onclose.bind(this)),Pe(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 Is(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=eh(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:Is,io:In,connect:In});class Qe{static instance;constructor(){}static init(t){if(!Qe.instance){const n=lr();Qe.instance=In(Ua,{path:"/ws",withCredentials:!0,extraHeaders:{"widget-id":t},auth:{sessionId:n,widgetId:t},query:{sessionId:n||""}}),Qe.instance.on("connect",()=>{console.info("SmartTalks.ai widget connected!",Qe.instance.id)})}return Qe.instance}static on(t,n,r){const o=Qe.instance||this.init(n);o.off(t),o.on(t,r)}}const Rs=1e3*60*60*24,[Rn,Fs]=ni("smarttalks-widget-messages",{},Rs),$s=()=>{const{widgetId:e}=ie();return Rn[e()]??[]},hh=e=>{const{widgetId:t}=ie();Fs({...Rn,[t()]:[...Rn[t()]??[],e]})},gh=()=>{const{widgetId:e}=ie();Fs({...Rn,[e()]:[]})},[Ns,ph]=ni("smarttalks-widget-conversationinfo",{},Rs),Ks=()=>{const{widgetId:e}=ie();return Ns[e()]??{}},zs=e=>{const{widgetId:t}=ie();ph({...Ns,[t()]:e})},[mh,Jr]=O(!1),[yh,Bs]=O(!1),Vs=[],Us=()=>{Vs.forEach(e=>e())},bh=e=>Vs.push(e),Zr=e=>{const t=mf(e);if(hh(t),t.type==="media"){setTimeout(Us,200);return}Us()},wh=(e,t)=>{const{chatWidget:n,widgetId:r}=ie(),o=Ks();e.trim()&&(Zr({text:e,type:"text",origin:"user",createdAt:new Date().toString()}),ee("onInput",e),Qe.on("message",r(),i=>{(i.contactId!==o.contactId||i.interactionId!==o.interactionId)&&zs({contactId:i.contactId,interactionId:i.interactionId});for(const s of i.messages)Zr(s),ee("onAnswer",s);Jr(!1),yf(i.debug)}),Jr(!0),bf(e,t,n()?._id).catch(i=>{console.error(i),Jr(!1)}))},vh=()=>{const{chatWidget:e}=ie(),t=Ks();Bs(!0),gh(),wf(e()?._id,t.contactId,t.interactionId).finally(()=>{zs({}),Bs(!1),js()}),ee("onReset")},js=()=>{const{chatWidget:e}=ie();if($s().length===0&&e()?.balloonMessage){const n=e()?.balloonMessage;n&&Zr({text:n,type:"text",origin:"bot",createdAt:new Date().toString()})}},et=()=>({getMessages:$s,pushMessage:wh,clearMessages:vh,addBalloonMessage:js,onMessage:bh,typing:mh,loading:yh});var xh=D("<span>");const Sh=()=>{const{clearMessages:e}=et();O(!1);const[t,n]=O(!1);return y(ff,{get open(){return t()},onOpenChange:n,get children(){return[y(hf,{get children(){return y(Ee,{variant:"ghost",size:"icon",class:"hover:bg-accent/10 hover:text-primary-foreground",get children(){return y(gc,{size:20})}})}}),y(gf,{get children(){return y(pf,{class:"flex space-x-2 items-center cursor-pointer",onSelect:e,get children(){return[y(hc,{size:14}),(()=>{var r=xh();return A(r,()=>ft("restart")),r})()]}})}})]}})};function kh(e){return we({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 we({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 Ch(e){return we({a:{fill:"currentColor",viewBox:"0 0 16 16"},c:'<path d="M13.601 2.326A7.854 7.854 0 0 0 7.994 0C3.627 0 .068 3.558.064 7.926c0 1.399.366 2.76 1.057 3.965L0 16l4.204-1.102a7.933 7.933 0 0 0 3.79.965h.004c4.368 0 7.926-3.558 7.93-7.93A7.898 7.898 0 0 0 13.6 2.326zM7.994 14.521a6.573 6.573 0 0 1-3.356-.92l-.24-.144-2.494.654.666-2.433-.156-.251a6.56 6.56 0 0 1-1.007-3.505c0-3.626 2.957-6.584 6.591-6.584a6.56 6.56 0 0 1 4.66 1.931 6.557 6.557 0 0 1 1.928 4.66c-.004 3.639-2.961 6.592-6.592 6.592zm3.615-4.934c-.197-.099-1.17-.578-1.353-.646-.182-.065-.315-.099-.445.099-.133.197-.513.646-.627.775-.114.133-.232.148-.43.05-.197-.1-.836-.308-1.592-.985-.59-.525-.985-1.175-1.103-1.372-.114-.198-.011-.304.088-.403.087-.088.197-.232.296-.346.1-.114.133-.198.198-.33.065-.134.034-.248-.015-.347-.05-.099-.445-1.076-.612-1.47-.16-.389-.323-.335-.445-.34-.114-.007-.247-.007-.38-.007a.729.729 0 0 0-.529.247c-.182.198-.691.677-.691 1.654 0 .977.71 1.916.81 2.049.098.133 1.394 2.132 3.383 2.992.47.205.84.326 1.129.418.475.152.904.129 1.246.08.38-.058 1.171-.48 1.338-.943.164-.464.164-.86.114-.943-.049-.084-.182-.133-.38-.232z"/>'},e)}function Oh(e){return we({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 _h=D('<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}=ie(),[t,n]=O(!1);let r=null;ht(()=>{/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)&&c()});const o=f=>{const g=f;return!!(g.requestFullscreen||g.webkitRequestFullscreen||g.msRequestFullscreen)},i=async f=>{const g=f;try{if(g.requestFullscreen)return await g.requestFullscreen(),!0;if(g.webkitRequestFullscreen)return g.webkitRequestFullscreen(),!0;if(g.msRequestFullscreen)return g.msRequestFullscreen(),!0}catch{}return!1},s=async()=>{const f=document;try{if(document.exitFullscreen)return await document.exitFullscreen(),!0;if(f.webkitExitFullscreen)return f.webkitExitFullscreen(),!0;if(f.msExitFullscreen)return f.msExitFullscreen(),!0}catch{}return!1},a=f=>{r=document.body.style.overflow||null,document.body.style.overflow="hidden",f.classList.add("st-fullscreen"),n(!0)},l=f=>{f.classList.remove("st-fullscreen"),r!==null?(document.body.style.overflow=r,r=null):document.body.style.overflow="",n(!1)},c=async()=>{try{const f=Jt();if(!f)return;if(!t())o(f)&&await i(f)||a(f);else{const g=document;(document.fullscreenElement||g.webkitFullscreenElement||g.msFullscreenElement)&&await s()||l(f)}}catch{console.error("SmartTalks.ai Widget unable to toggle fullscreen in the current state.")}},d=()=>{const f=document,g=!!(document.fullscreenElement||f.webkitFullscreenElement||f.msFullscreenElement);if(n(g),!g)try{const h=Jt();h.classList.contains("st-fullscreen")&&l(h)}catch{}};document.addEventListener("fullscreenchange",d),document.addEventListener("webkitfullscreenchange",d);const u=()=>{e()?.mode==="popup"&&ee("close")};return ne("toggleFullscreen",()=>{c()}),(()=>{var f=_h(),g=f.firstChild;return A(f,y(dc,{}),g),A(g,y(Ee,{size:"icon",variant:"ghost",class:"hover:bg-accent/10 hover:text-primary-foreground",onClick:c,get children(){return y(Z,{get when(){return t()},get fallback(){return y(Eh,{size:16})},get children(){return y(kh,{size:16})}})}}),null),A(g,y(Z,{get when(){return e()?.showSettings},get children(){return y(Sh,{})}}),null),A(g,y(Z,{get when(){return e()?.mode==="popup"},get children(){return y(Ee,{size:"icon",variant:"ghost",class:"hover:bg-accent/10 hover:text-primary-foreground",onClick:u,get children(){return y(Oh,{size:16})}})}}),null),f})()};var Ph=D("<span>");const qs=({createdAt:e,anchor:t="end"})=>(()=>{var n=Ph();return nt(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 Ah=D('<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 Th=({children:e,createdAt:t})=>(()=>{var n=Ah(),r=n.firstChild;return A(r,e),A(n,y(qs,{createdAt:t,anchor:"start"}),null),n})();var Lh=D("<span>");const _t=e=>{const[,t]=j(e,["class","children"]);let n=e.children?.toString();return n&&(n=za(Ba(n))),(()=>{var r=Lh();return r.innerHTML=n,rt(r,L({get class(){return Ge("whitespace-pre-line",e.class)}},t),!1,!1),r})()};var Mh=D('<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}=et(),[o,i]=O(!1),s=(a,l)=>{i(!0),r(a,l)};return(()=>{var a=Mh(),l=a.firstChild,c=l.firstChild;A(a,y(_t,{get children(){return t?.trim()}}),l);var d=n;return typeof d=="function"?or(d,c):n=c,A(c,y(pt,{each:e,children:u=>y(Ee,{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()}})})),oe(()=>nt(l,`flex items-center justify-center max-w-80 mx-[-16px] ${o()&&"opacity-50"}`)),a})()};var Ih=D('<div class="flex flex-col"><span>'),Rh=D("<a target=_blank><img><span></span><span>");const Fh=({options:e,text:t})=>(()=>{var n=Ih(),r=n.firstChild;return A(r,()=>t?.trim()),A(n,y(pt,{each:e,children:o=>(()=>{var i=Rh(),s=i.firstChild,a=s.nextSibling,l=a.nextSibling;return A(a,()=>o.title?.trim()),A(l,()=>o.description?.trim()),oe(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 $h=D("<a target=_blank>");const Nh=({url:e,text:t})=>(()=>{var n=$h();return ue(n,"href",e),A(n,()=>t?.trim()),n})();var G=e=>typeof e=="function"?e():e,Hs=e=>requestAnimationFrame(()=>requestAnimationFrame(e)),Kh=e=>{const t=L({initialRegistered:!1},e),[n,r]=O(t.initialRegistered);return[C(()=>{if(n())return G(t.value)}),()=>{r(!0)},()=>{r(!1)}]},Ws=Kh,Yt=e=>typeof e=="function",zh=["button","color","file","image","reset","submit"],Bh=(e,t)=>e==="button"?!0:e==="input"&&t?zh.indexOf(t)!==-1:!1;function Vh(e){const[t,n]=O(e.initialValue),r=()=>e.value?.()!==void 0,o=()=>r()?e.value?.():t();return[o,s=>H(()=>{let a;return Yt(s)?a=s(o()):a=s,Object.is(a,o())||(r()||n(a),e.onChange?.(a)),a})]}var eo=Vh,Fn=new Map,$n=(e,t)=>{if(Fn.has(e))return Fn.get(e);const n=ce(t);return Fn.set(e,n),n},to=e=>{const t=Fn.get(e);if(t)return he(t)},Nn=new Map,Uh=e=>{T(()=>{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?.()}})})},jh=Uh,qh=e=>{const t=L({enabled:!0},e);T(()=>{G(t.enabled)&&(document.addEventListener("keydown",n),K(()=>{document.removeEventListener("keydown",n)}))});const n=r=>{r.key==="Escape"&&t.onEscapeKeyDown(r)}},Hh=qh,Wh=e=>{const t=L({enabled:!0},e);T(()=>{const{body:n}=document;G(t.enabled)&&jh({key:"no-pointer-events",element:n,style:{pointerEvents:"none"}})})},Gh=Wh,Yh=e=>{const t=L({enabled:!0,strategy:"pointerup"},e);T(()=>{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)}},Xh=Yh,Jh=e=>{const t=L({dismissOnEscapeKeyDown:!0,dismissOnOutsidePointer:!0,closeOnOutsidePointerStrategy:"pointerup",noOutsidePointerEvents:!0},e);Hh({enabled:t.dismissOnEscapeKeyDown,onEscapeKeyDown:n=>{t.onEscapeKeyDown?.(n),n.defaultPrevented||t.onDismiss("escapeKey")}}),Xh({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}),Gh({enabled:t.noOutsidePointerEvents})},Zh=Jh,no=ce(),Qh=e=>C(()=>{if(he(no))return y(Gs,e);const r=Te(),[o,i]=O([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(Gs,e)}})}),Gs=e=>{const t=L({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=Te();T(()=>{n.enabled?o.onLayerShow(i):o.onLayerDismiss(i)});const s=()=>o.layers()[o.layers().length-1]===i;Zh({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 H(()=>l())},eg=Qh,tg=()=>{const[e,t]=O(!1);return T(()=>t(!0)),e},ng=tg,rg=(e,t)=>(e&&(Yt(e)?e(t):e[0](e[1],t)),t.defaultPrevented),ro=(...e)=>e.some(t=>!!t()),og=e=>(...t)=>{for(const n of e)n&&n(...t)},Kn=(...e)=>og(e),le=e=>e?"":void 0,ig="div",sg=e=>{const[t,n]=j(e,["as"]),r=C(()=>t.as??ig);return C(()=>{const i=r();switch(typeof i){case"function":return H(()=>i(n));case"string":return y(ln,L({component:i},n))}})},oo=sg,ag=e=>{let t,n=!1;return()=>n?t:(n=!0,t=C(e))},Ys=ag,lg=e=>C(()=>G(e.element)?.tagName.toLowerCase()||e.fallback),cg=lg,Xs="button",ug=e=>{const[t,n]=O(null),[r,o]=j(e,["as","ref","type"]),i=cg({element:t,fallback:Xs}),s=C(()=>Bh(i(),r.type));return y(oo,L({get as(){return r.as??Xs},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))},dg=ug,fg='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",Js={bubbles:!1,cancelable:!0},hg=e=>{const t=L({enabled:!0,observeChanges:!0,restoreFocus:!0},e),[n,r]=O(null),o=C(()=>{const h=n();return h?h[0]??null:null}),i=C(()=>{const h=n();return h?h[h.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))})};T(()=>{const h=J(t.element);if(h&&J(t.enabled)){s=document.activeElement,H(()=>{l(h),c(h)});const p=new MutationObserver(a);J(t.observeChanges)&&p.observe(h,{subtree:!0,childList:!0,attributes:!0,attributeFilter:["tabindex"]}),K(()=>{J(t.observeChanges)&&p.disconnect(),r(null),g(h)})}}),T(()=>{const h=n();h===null||h.length!==0||(document.addEventListener("keydown",f),K(()=>{document.removeEventListener("keydown",f)}))}),T(()=>{const h=o();h&&(h.addEventListener("keydown",d),K(()=>{h.removeEventListener("keydown",d)}))}),T(()=>{const h=i();h&&(h.addEventListener("keydown",u),K(()=>{h.removeEventListener("keydown",u)}))});const l=h=>{const p=Array.from(h.querySelectorAll(fg)).map((m,b)=>({element:m,domIndex:b,tabIndex:m.tabIndex})).sort((m,b)=>m.tabIndex===b.tabIndex?m.domIndex-b.domIndex:m.tabIndex-b.tabIndex);r(p.map(({element:m})=>m))},c=h=>{Cr(()=>{const p=J(t.initialFocusElement)??o()??h,m=t.onInitialFocus;let b;m&&(b=new CustomEvent(io,Js),h.addEventListener(io,m),h.dispatchEvent(b),h.removeEventListener(io,m)),b?.defaultPrevented!==!0&&p.focus()})},d=h=>{h.key==="Tab"&&h.shiftKey&&(h.preventDefault(),i().focus())},u=h=>{h.key==="Tab"&&!h.shiftKey&&(h.preventDefault(),o().focus())},f=h=>{h.key==="Tab"&&h.preventDefault()},g=h=>{Cr(()=>{if(!J(t.restoreFocus))return;const m=J(t.finalFocusElement)??s;if(!m)return;let b;const w=t.onFinalFocus;w&&(b=new CustomEvent(so,Js),h.addEventListener(so,w),h.dispatchEvent(b),h.removeEventListener(so,w)),b?.defaultPrevented!==!0&&m.focus()})}},gg=hg,pg=gg,mg=e=>{const t=C(()=>{const s=J(e.element);if(s)return getComputedStyle(s)}),n=()=>t()?.animationName??"none",[r,o]=O(J(e.show)?"present":"hidden");let i="none";return T(s=>{const a=J(e.show);return H(()=>{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}),T(()=>{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}},yg=mg,Zs=yg,bg=ce(),wg=e=>e?$n(`dialog-${e}`):bg,Qs=ce(),vg=e=>e?$n(`dialog-internal-${e}`):Qs,Pt=e=>{if(!e){const n=he(Qs);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},xg="div",Sg=e=>{const[t,n]=j(e,["as","forceMount","contextId","children","ref","style","data-corvu-dialog-content"]),r=C(()=>Pt(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(eg,{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,L({ref(l){var c=Kn(r().setContentRef,t.ref);typeof c=="function"&&c(l)},get as(){return t.as??xg},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()}}))}})}})}})},kg=Sg,Eg="div",Cg=e=>{const[t,n]=j(e,["as","forceMount","contextId","children","ref","style","data-corvu-dialog-overlay"]),r=C(()=>Pt(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,L({get as(){return t.as??Eg},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()}}))}})})()}})},Og=Cg,_g=e=>{const[t,n]=j(e,["forceMount","contextId","children"]),r=C(()=>Pt(t.contextId)),o=()=>ro(r().open,()=>t.forceMount,r().contentPresent,r().overlayPresent),i=ng(),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(Wo,L(n,{get children(){return a()}}))}})})()}})},Pg=_g,ao=!0,Ag=e=>{const t=L({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:Te()},e),[n,r]=eo({value:()=>t.open,initialValue:t.initialOpen,onChange:t.onOpenChange}),[o,i,s]=Ws({value:()=>t.labelId??Te()}),[a,l,c]=Ws({value:()=>t.descriptionId??Te()}),[d,u]=O(null),[f,g]=O(null),[h,p]=O(null),{present:m}=Zs({show:n,element:f}),{present:b}=Zs({show:n,element:h});pg({element:f,enabled:()=>n()&&t.trapFocus,initialFocusElement:()=>t.initialFocusEl??null,restoreFocus:()=>t.restoreFocus,finalFocusElement:()=>t.finalFocusEl??null,onFinalFocus:t.onFinalFocus,onInitialFocus:t.onInitialFocus}),Hi({element:f,enabled:()=>m()&&G(t.preventScroll),hideScrollbar:()=>t.hideScrollbar,preventScrollbarShift:()=>t.preventScrollbarShift,preventScrollbarShiftMode:()=>t.preventScrollbarShiftMode,allowPinchZoom:()=>t.allowPinchZoom});const w={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 m()},get contentRef(){return f()},get overlayPresent(){return b()},get overlayRef(){return h()},get dialogId(){return t.dialogId},get labelId(){return o()},get descriptionId(){return a()}},v=Ys(()=>t.children),x=()=>{const E=v()();return Yt(E)?E(w):E};return C(()=>{const E=wg(t.contextId),k=vg(t.contextId);return y(E.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:m,contentRef:f,overlayPresent:b,overlayRef:h,dialogId:()=>t.dialogId,labelId:o,descriptionId:a},get children(){return y(k.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:m,contentRef:f,overlayPresent:b,overlayRef:h,dialogId:()=>t.dialogId,labelId:o,registerLabelId:i,unregisterLabelId:s,descriptionId:a,registerDescriptionId:l,unregisterDescriptionId:c,setContentRef:g,setOverlayRef:p,triggerRef:d,setTriggerRef:u}},get children(){return H(()=>x())}})}})})},Tg=Ag,Lg="button",Mg=e=>{const[t,n]=j(e,["as","contextId","ref","onClick","data-corvu-dialog-trigger"]),r=C(()=>Pt(t.contextId));return y(dg,L({ref(i){var s=Kn(r().setTriggerRef,t.ref);typeof s=="function"&&s(i)},get as(){return t.as??Lg},onClick:i=>{!rg(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=Mg,zn=e=>typeof e=="function"?e():e,ea=e=>requestAnimationFrame(()=>requestAnimationFrame(e));function Ig(e){const t=L({enabled:!0,dimension:"both"},e),[n,r]=O(!1),[o,i]=O(null);let s=null;T(()=>{const c=zn(t.element),d=zn(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],f=zn(t.dimension);f==="both"?s?s[0]!==u[0]&&s[1]!==u[1]&&(ke(()=>{i(s),r(!0)}),ea(()=>{i(u),parseFloat(getComputedStyle(c.target).transitionDuration)===0&&l()})):s=u:s?Bn(f,s)!==Bn(f,u)&&(ke(()=>{i(Bn(f,s)),r(!0)}),ea(()=>{i(Bn(f,u)),parseFloat(getComputedStyle(c.target).transitionDuration)===0&&l()})):s=u},l=()=>{if(!n())return;const c=zn(t.element);c?s=[c.offsetWidth,c.offsetHeight]:s=null,ke(()=>{r(!1),i(null)})};return{transitioning:n,transitionSize:o}}var Bn=(e,t)=>{switch(e){case"width":return t[0];case"height":return t[1]}},Rg=Ig,Fg=Rg;const $g=(e,t)=>e.length>0?()=>e(H(t)):e;function Ng(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 ta(e,t,n){let r=()=>t;const[o,i]=O(t,cr),s=C($g(e,()=>r()),t,cr);return[r=Ng([o,s],n),a=>i(()=>typeof a=="function"?a(H(r)):a)]}var Kg=(e,t)=>{switch(t){case"x":return[e.clientWidth,e.scrollLeft,e.scrollWidth];case"y":return[e.clientHeight,e.scrollTop,e.scrollHeight]}},zg=(e,t)=>{const n=getComputedStyle(e),r=t==="x"?n.overflowX:n.overflowY;return r==="auto"||r==="scroll"||e.tagName==="HTML"&&r==="visible"},Bg=(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]=Kg(o,t),u=d-l-r*c;(c!==0||u!==0)&&zg(o,t)&&(i+=u,s+=c),o===(n??document.documentElement)?a=!0:o=o._$host??o.parentElement}while(o&&!a);return[i,s]},Vg=e=>y(Dg,L({"data-corvu-dialog-trigger":void 0,"data-corvu-drawer-trigger":""},e)),na=ce(),Ug=e=>e?$n(`drawer-${e}`):na,jg=e=>{if(!e){const n=he(na);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},ra=ce(),qg=e=>e?$n(`drawer-internal-${e}`):ra,oa=e=>{if(!e){const n=he(ra);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},ia=(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)},Hg=(e,t,n,r)=>{const o=sa("upper",e,r?n:t),i=sa("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},sa=(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),Wg=(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},Gg=void 0,Yg=e=>{const t=L({initialOpen:!1,snapPoints:[0,1],breakPoints:[Gg],defaultSnapPoint:1,side:"bottom",dampFunction:$=>6*Math.log($+1),velocityFunction:($,V)=>{const Q=$/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]=O(),{transitioning:d,transitionSize:u}=Fg({element:()=>l()?.contentRef()??null,enabled:()=>o()&&n.transitionResize,dimension:()=>{switch(n.side){case"top":case"bottom":return"height";case"left":case"right":return"width"}}}),[f,g]=O(!1),[h,p]=ta(()=>d()?"resizing":null),m=C(()=>{const $=l()?.contentRef();if($)return getComputedStyle($)}),[b,w]=O(!1);T(()=>{const $=o();H(()=>{b()!==$&&($?(w(!0),Hs(()=>{ke(()=>{p("opening"),a(n.defaultSnapPoint)}),parseFloat(m().transitionDuration)===0&&p(null)})):(ke(()=>{p("closing"),a(0)}),Hs(()=>{parseFloat(m().transitionDuration)===0&&v()})))})});const v=()=>{ke(()=>{w(!1),p(null)})},[x,_]=O(0);T(()=>{const $=l()?.contentRef();if(!$)return;k($);const V=new ResizeObserver(E);V.observe($),K(()=>{V.disconnect()})});const E=$=>{for(const V of $)V.target===l()?.contentRef()&&k(V.target)},k=$=>{const V=H(()=>x());switch(n.side){case"top":case"bottom":if(V===$.offsetHeight)return;_($.offsetHeight);break;case"left":case"right":if(V===$.offsetWidth)return;_($.offsetWidth);break}},F=C(()=>ia(s(),x())),[P,R]=ta(()=>F().offset),M=C(()=>x()?(x()-P())/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 f()},get isTransitioning(){return h()!==null},get transitionState(){return h()},get openPercentage(){return M()},get translate(){return P()},get velocityCacheReset(){return n.velocityCacheReset},get allowSkippingSnapPoints(){return n.allowSkippingSnapPoints},get handleScrollableElements(){return n.handleScrollableElements},get transitionResize(){return n.transitionResize}},re=Ys(()=>n.children),Y=$=>{c(Pt(n.contextId));const V=re()();if(Yt(V)){const Q=L($,I);return V(Q)}return V};return C(()=>{const $=Ug(n.contextId),V=qg(n.contextId);return H(()=>y($.Provider,{value:{snapPoints:()=>n.snapPoints,breakPoints:()=>n.breakPoints,defaultSnapPoint:()=>n.defaultSnapPoint,activeSnapPoint:s,setActiveSnapPoint:a,side:()=>n.side,isDragging:f,isTransitioning:()=>h()!==null,transitionState:h,openPercentage:M,translate:P,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:f,isTransitioning:()=>h()!==null,transitionState:h,openPercentage:M,translate:P,velocityCacheReset:()=>n.velocityCacheReset,allowSkippingSnapPoints:()=>n.allowSkippingSnapPoints,handleScrollableElements:()=>n.handleScrollableElements,transitionResize:()=>n.transitionResize,dampFunction:n.dampFunction,velocityFunction:n.velocityFunction,setIsDragging:g,setTranslate:R,drawerSize:x,resolvedActiveSnapPoint:F,drawerStyles:m,setTransitionState:p,transitionSize:u,closeDrawer:v}},get children(){return y(Tg,L({get open(){return b()},onOpenChange:i,get contextId(){return n.contextId},get closeOnOutsidePointer(){return!f()&&n.closeOnOutsidePointer}},r,{children:Q=>Y(Q)}))}})}}))})},Xg=Yg,Jg=e=>{const[t,n]=j(e,["contextId","style"]);let r=!1,o=null,i=[0,0],s,a=0;const l=C(()=>oa(t.contextId)),c=C(()=>Pt(t.contextId)),d=C(()=>l().snapPoints().map((v,x)=>ia(v,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)`}}),f=C(()=>{const v=l().transitionSize();if(v)switch(l().side()){case"top":case"bottom":return`${v}px`}}),g=C(()=>{const v=l().transitionSize();if(v)switch(l().side()){case"left":case"right":return`${v}px`}});T(()=>{c().open()&&(document.addEventListener("pointermove",p),document.addEventListener("touchmove",m),document.addEventListener("pointerup",w),document.addEventListener("touchend",w),K(()=>{document.removeEventListener("pointermove",p),document.removeEventListener("touchmove",m),document.removeEventListener("pointerup",w),document.removeEventListener("touchend",w)}))});const h=v=>{Wg(v.target,c().contentRef())&&l().transitionState()!=="closing"&&(r=!0,l().handleScrollableElements()&&(i=[v.clientX,v.clientY]))},p=v=>{b(v.target,v.clientX,v.clientY)},m=v=>{v.touches[0]&&b(v.target,v.touches[0].clientX,v.touches[0].clientY)},b=(v,x,_)=>{if(!r)return;if(!l().isDragging()||o===null){const F=window.getSelection();if(F&&F.toString().length>0){w();return}if(l().handleScrollableElements()){const P=[x,_].map((fe,$)=>i[$]-fe),R=Math.abs(P[0])>Math.abs(P[1])?"x":"y",M=R==="x"?P[0]:P[1];if(Math.abs(M)<.3)return;const I=c().contentRef(),[re,Y]=Bg(v,R,I);if(M>0&&Math.abs(re)>1||M<0&&Math.abs(Y)>0){w();return}}switch(l().side()){case"top":case"bottom":o=_;break;case"right":case"left":o=x}s=new Date,a=l().translate(),ke(()=>{l().setIsDragging(!0),l().setTransitionState(null)})}let E;switch(l().side()){case"top":E=-(o-_);break;case"bottom":E=o-_;break;case"right":E=o-x;break;case"left":E=-(o-x);break}E-=l().resolvedActiveSnapPoint().offset,E>0&&(E=l().dampFunction(E));const k=new Date;k.getTime()-s.getTime()>l().velocityCacheReset()&&(s=k,a=l().translate()),l().setTranslate(-E)},w=()=>{if(r=!1,!l().isDragging())return;const v=new Date,x=l().velocityFunction(-(a-l().translate()),v.getTime()-s.getTime()||1),_=l().translate()*x,E=Hg(d(),l().translate(),_,l().allowSkippingSnapPoints());ke(()=>{l().setTransitionState("snapping"),l().setIsDragging(!1)}),ke(()=>{l().setActiveSnapPoint(E.value),E.offset===l().drawerSize()?c().setOpen(!1):(l().setTranslate(E.offset),parseFloat(l().drawerStyles().transitionDuration)===0&&l().setTransitionState(null))})};return y(kg,L({get contextId(){return t.contextId},get style(){return{transform:u(),"transition-duration":l().isDragging()?"0ms":void 0,height:f(),width:g(),...t.style}},onPointerDown:h,onTransitionEnd:()=>{ke(()=>{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))},Zg=Jg,Qg=e=>{const[t,n]=j(e,["contextId"]),r=C(()=>oa(t.contextId));return y(Og,L({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))},ep=Qg,tp=D('<div class="mx-auto mt-4 h-2 w-[100px] rounded-full bg-muted">');const np=Xg,rp=Vg,op=Pg,ip=e=>{const[,t]=j(e,["class"]),n=jg();return y(ep,L({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))},sp=e=>{const[,t]=j(e,["class","children"]);return y(op,{get mount(){return Jt()},get children(){return[y(ip,{}),y(Zg,L({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[tp(),C(()=>e.children)]}}))]}})};var ap=D('<span class="font-semibold mt-2">'),lp=D('<div class="flex py-4 pl-3 pr-1 flex-col w-full space-y-4 overflow-y-auto">'),cp=D('<div class="flex flex-col space-y-2"><div>'),up=D('<div class="flex flex-col w-full space-y-1"><span class="font-semibold text-slate-700">'),dp=D('<div class="flex flex-col items-start"><span class=text-slate-500>');const fp=({options:e,text:t,title:n})=>{const{pushMessage:r}=et(),[o,i]=O(!1),[s,a]=O(!1),[l,c]=O(),d=(f,g)=>{a(!1),i(!0),r(f,g)},u=f=>{const g=f.composedPath();for(const h of g)if(h.id==="smarttalks-list-content"){f.preventDefault();return}};return(()=>{var f=cp(),g=f.firstChild;return A(f,y(_t,{get children(){return t?.trim()}}),g),A(g,y(np,{get open(){return s()},onOpenChange:a,onOutsidePointer:u,get children(){return[y(rp,{as:Ee,variant:"outline",class:"w-full text-nowrap",get children(){return n?.trim()??ft("selectOption")}}),y(sp,{class:"pb-2 px-2 flex flex-col items-center justify-center",get children(){return[(()=>{var h=ap();return A(h,()=>n?.trim()??ft("selectOption")),h})(),(()=>{var h=lp();return A(h,y(pt,{each:e,children:p=>(()=>{var m=up(),b=m.firstChild;return A(b,()=>p.label?.trim()??""),A(m,y(pt,{get each(){return p.items},children:w=>y(Ee,{variant:"outline",get disabled(){return o()},get class(){return`py-6 flex justify-between hover:bg-slate-200 ${l()===w?"bg-slate-200":""}`},onClick:()=>c(w),get children(){return[(()=>{var v=dp(),x=v.firstChild;return A(v,()=>w.label?.trim(),x),A(x,()=>w.description?.trim()),v})(),y(Z,{get when(){return l()===w},get fallback(){return y(uf,{class:"size-4 text-slate-500"})},get children(){return y(cf,{class:"size-4 text-slate-500"})}})]}})}),null),m})()})),h})(),y(Ee,{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 ft("send")}})]}})]}})),oe(()=>nt(g,o()?"opacity-50":"")),f})()};var hp=D("<audio controls preload=auto class=h-8><source type=audio/mpeg><source type=audio/ogg>Your browser does not support the audio element.");const gp=e=>(()=>{var t=hp(),n=t.firstChild,r=n.nextSibling;return oe(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 pp=D('<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 mp=e=>(()=>{var t=pp(),n=t.firstChild,r=n.firstChild;return A(n,y(df,{class:"size-10"}),r),A(r,()=>e.filename?.trim()),A(t,y(_t,{get children(){return e.text?.trim()}}),null),oe(()=>ue(n,"href",e.link)),t})();var yp=D('<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 bp=e=>(()=>{var t=yp(),n=t.firstChild,r=n.firstChild;return A(t,y(_t,{get children(){return e.text?.trim()}}),null),oe(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 wp=D('<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 vp=e=>(()=>{var t=wp(),n=t.firstChild,r=n.firstChild,o=r.nextSibling;return A(t,y(_t,{get children(){return e.text?.trim()}}),null),oe(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 xp=D("<div>Media type not supported");const aa=e=>e.type==="image"?y(bp,e):e.type==="audio"?y(gp,e):e.type==="document"?y(mp,e):e.type==="video"?y(vp,e):xp(),lo=({text:e})=>y(_t,{get children(){return e?.trim()}});var Sp=D("<div>Unknown bot message type");const kp=e=>y(Th,{get createdAt(){return e.createdAt},get children(){return e.type==="text"?y(lo,{get text(){return e.text}}):e.type==="buttons"?y(Dh,L(()=>e.buttons)):e.type==="list"?y(fp,L(()=>e.list)):e.type==="media"?y(aa,L(()=>e.media)):e.type==="link"?y(Nh,L(()=>e.link)):e.type==="cards"?y(Fh,L(()=>e.cards)):e.type==="date"?y(lo,{get text(){return e.text}}):Sp()}});var Ep=D('<div class="place-self-center p-4"><span class="bg-slate-200/40 text-black font-semibold py-2 px-4 rounded-xl">');const Cp=e=>(()=>{var t=Ep(),n=t.firstChild;return A(n,()=>e.text?.trim()),t})();var Op=D('<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 _p=({children:e,createdAt:t})=>(()=>{var n=Op(),r=n.firstChild;return A(r,e),A(n,y(qs,{createdAt:t,anchor:"end"}),null),n})();var Pp=D("<div>Unknown user message type");const Ap=e=>y(_p,{get createdAt(){return e.createdAt},get children(){return e.type==="text"?y(lo,{get text(){return e.text}}):e.type==="media"?y(aa,L(()=>e.media)):Pp()}});var Tp=D("<div>Unknown message origin");const Lp=e=>e.origin==="bot"?y(kp,e):e.origin==="user"?y(Ap,e):e.origin==="service"?y(Cp,e):Tp();function co(e){return we({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 Mp=D('<main touch-action-pan-y class="flex-1 w-full p-4 overflow-y-auto flex flex-col items-center scroll-smooth relative min-h-0 overscroll-contain pb-2">'),Dp=D("<div>");const uo=()=>{let e;const{getMessages:t,onMessage:n,clearMessages:r,addBalloonMessage:o}=et(),{onOpen:i}=Jo(),s=(a=100)=>{setTimeout(()=>{e?.scrollTo(0,e.scrollHeight)},a)};return ne("reset",()=>{r()}),ht(()=>{o(),s(200)}),n(s),i(()=>s(200)),(()=>{var a=Mp(),l=e;return typeof l=="function"?or(l,a):e=a,A(a,y(pt,{get each(){return t()},get fallback(){return(()=>{var c=Dp();return A(c,()=>ft("emptyMessages")),c})()},children:c=>y(Lp,c)})),a})()};var Ip=D("<textarea>");const Rp=e=>{const[,t]=j(e,["class"]);return(()=>{var n=Ip();return rt(n,L({get class(){return Ge("flex w-full rounded-md border border-input bg-transparent px-3 py-2 text-base md: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=D('<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 $p=e=>(()=>{var t=Fp();return rt(t,e,!0,!0),t})();var Np=D('<div class="absolute flex items-center justify-center left-1/2 transform -translate-x-1/2 bottom-[-12px]"><span class="font-semibold text-xs text-gray-600 ml-1">SmartTalks.ai');const Kp=()=>(()=>{var e=Np(),t=e.firstChild;return A(e,y($p,{height:15}),t),e})();var zp=D('<footer class="relative flex-none bg-white border-t border-gray-100 z-20 w-full"><div class="flex flex-col p-3 gap-2 pb-[max(1rem,env(safe-area-inset-bottom))] w-full box-border"><div class="flex items-end gap-2 w-full"></div><div class="flex justify-center opacity-70 scale-95">');const fo=()=>{const{pushMessage:e}=et(),[t,n]=O(""),r=()=>{t().trim()&&(e(t()),n(""))},o=i=>{i.key==="Enter"&&!i.shiftKey&&(i.preventDefault(),r())};return ne("setInput",i=>{i&&n(i)}),(()=>{var i=zp(),s=i.firstChild,a=s.firstChild,l=a.nextSibling;return A(a,y(Rp,{id:"chat-input",get placeholder(){return ft("inputPlaceholder")},get value(){return t()},onInput:c=>n(c.currentTarget.value),onKeyDown:o,class:"focus-visible:ring-primary min-h-[44px] max-h-[120px] py-3 leading-tight resize-none"}),null),A(a,y(Ee,{variant:"outline",class:"h-[44px] w-[44px] p-0 shrink-0 flex items-center justify-center","aria-label":"Send",type:"button",onClick:r,get children(){return y(mc,{size:20})}}),null),A(l,y(Kp,{})),i})()};var Bp=D('<div id=smarttalks-widget class="rounded-md shadow-xl h-[85vh] w-[90vw] md:h-[min(100vh,500px)] md:w-[min(100vw,425px)] overflow-hidden bg-background text-foreground flex flex-col relative">'),Vp=D("<span class=sr-only>Close"),Up=D('<div><div class="flex justify-center gap-3 items-center">'),jp=D("<span class=sr-only>Open"),qp=D("<span class=font-bold>"),Hp=D("<span>"),Wp=D('<div class="animate-pulse flex p-1">');const Gp=({children:e,openIcon:t})=>{const{bubble:n,toggle:r,show:o,hide:i}=Jo(),{chatWidget:s}=ie(),[a,l]=O(!0),[c,d]=O("");setTimeout(()=>l(!1),2e3),s()?.openDelay&&setTimeout(()=>{o()},(s()?.openDelay||0)*1e3);const u=()=>(s()?.style.margin??5)/4,f=()=>s()?.style.position==="left"?{left:`${u()}rem`}:{right:`${u()}rem`};return ne("open",()=>{o()}),ne("close",()=>{i()}),ne("toggle",()=>{r()}),ne("onAnswer",g=>{g.text&&d(g.text),o()}),(()=>{var g=Up(),h=g.firstChild;return A(g,y(Z,{get when(){return n()},get children(){var p=Bp();return A(p,e),p}}),h),A(h,y(Z,{get when(){return s()?.whatsappBtn},get children(){return y(Ee,{onclick:()=>window.open(s()?.whatsappBtn,"_blank"),"aria-label":"Open",class:"bg-green-500 rounded-full size-14 shadow-md hover:bg-green-400 animate-scale",type:"button",get children(){return y(Ch,{class:"size-9",color:"white"})}})}}),null),A(h,y(Z,{get when(){return n()},get fallback(){return y(Ee,{onclick:r,class:"rounded-full px-0 animate-scale","aria-label":"Open",type:"button",get children(){return[t,jp(),y(Z,{get when(){return s()?.balloonMessage},get children(){var p=Hp();return A(p,y(Z,{get when(){return c()},get fallback(){return y(Z,{get when(){return!a()},get fallback(){return(()=>{var m=Wp();return A(m,y(co,{class:"size-2 animate-bounce"}),null),A(m,y(co,{class:"size-2 animate-bounce delay-150"}),null),A(m,y(co,{class:"size-2 animate-bounce delay-300"}),null),m})()},get children(){return C(()=>(s()?.balloonMessage?.length??0)>18)()?s()?.balloonMessage?.substring(0,15)+"...":s()?.balloonMessage}})},get children(){var m=qp();return A(m,(()=>{var b=C(()=>c().length>20);return()=>b()?c().substring(0,17)+"...":c()})()),m}})),oe(()=>nt(p,"absolute -top-12 bg-primary text-primary-foreground px-2.5 py-2 pointer-events-none rounded-full truncate hidden md:block"+(s()?.style.position==="left"?" left-0":" right-0"))),p}})]}})},get children(){return y(Ee,{onclick:r,class:"rounded-full px-0 hover:bg-primary hover:shadow-primary shadow-md transition-shadow duration-300","aria-label":"Close",type:"button",get children(){return[t,Vp()]}})}}),null),oe(p=>{var m="z-[9999] 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"),b=f();return m!==p.e&&nt(g,p.e=m),p.t=an(g,b,p.t),p},{e:void 0,t:void 0}),g})()};var Yp=D('<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}=ie(),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=D("<div id=smarttalks-widget>");const Zp=({children:e})=>{const{chatWidget:t}=ie(),[n,r]=O(!1),[o,i]=O(!1),[s,a]=O("100%"),l=()=>{typeof window<"u"&&i(window.innerWidth<768)},c=()=>{o()&&window.visualViewport&&(a(`${window.visualViewport.height}px`),window.scrollTo(0,0))};T(()=>{typeof document>"u"||(n()&&o()?(document.body.style.overflow="hidden",document.body.style.position="fixed",document.body.style.width="100%"):(document.body.style.overflow="",document.body.style.position="",document.body.style.width=""))}),ht(()=>{l(),window.addEventListener("resize",l),window.visualViewport&&(window.visualViewport.addEventListener("resize",c),window.visualViewport.addEventListener("scroll",c))}),K(()=>{window.removeEventListener("resize",l),window.visualViewport&&(window.visualViewport.removeEventListener("resize",c),window.visualViewport.removeEventListener("scroll",c)),document.body.style.overflow="",document.body.style.position=""});const d=()=>(t()?.style.margin??5)/4,u=()=>{if(o())return{height:s(),top:"0px"};const f={};return t()?.fullscreen?(f.height="100%",f["max-height"]="100%",f.width="100%",f["max-width"]="100%",f.bottom=0,f.left=0):t()?.style.position&&(f[t()?.style.position||"right"]=`${d()}rem`),f};return ne("open",()=>{r(!0),ee("onOpen"),o()&&window.visualViewport&&a(`${window.visualViewport.height}px`)}),ne("close",()=>{r(!1),ee("onClose")}),ne("toggle",()=>{r(!n()),ee("onToggle")}),ne("onAnswer",()=>{r(!0),ee("onOpen")}),setTimeout(()=>{r(!0),ee("onOpen")},(t()?.openDelay||0)*1e3),y(Z,{get when(){return n()},get children(){var f=Jp();return A(f,e),oe(g=>{var h=`
|
|
181
|
+
*/function Yd(e,t){return t?Hc([e.clientX,e.clientY],t):!1}function Xd(e){const t=Ct(),n=Ni(),r=gs(),o=Me({placement:"bottom-start"},e),[i,s]=j(o,["open","defaultOpen","onOpenChange"]);let a=0,l=null,c="right";const[d,u]=O(),[f,g]=O(),[h,p]=O(),[m,b]=O(),[w,v]=O(!0),[x,_]=O(s.placement),[E,k]=O([]),[F,P]=O([]),{DomCollectionProvider:R}=ju({items:F,onItemsChange:P}),M=xi({open:()=>i.open,defaultOpen:()=>i.defaultOpen,onOpenChange:U=>i.onOpenChange?.(U)}),I=fu(()=>t.forceMount()||M.isOpen()),re=Mu({selectionMode:"none",dataSource:F}),Y=U=>{v(U),M.open()},fe=(U=!1)=>{M.close(),U&&r&&r.close(!0)},$=U=>{v(U),M.toggle()},V=()=>{const U=m();U&&(de(U),re.selectionManager().setFocused(!0),re.selectionManager().setFocusedKey(void 0))},Q=U=>{k(go=>[...go,U]);const Un=r?.registerNestedMenu(U);return()=>{k(go=>dr(go,U)),Un?.()}},se=U=>c===l?.side&&Yd(U,l?.area),At=U=>{se(U)&&U.preventDefault()},Ae=U=>{se(U)||V()},dm=U=>{se(U)&&U.preventDefault()};cu({isDisabled:()=>!(r==null&&M.isOpen()&&t.isModal()),targets:()=>[m(),...E()].filter(Boolean)}),T(()=>{const U=m();if(!U||!r)return;const Un=r.registerNestedMenu(U);K(()=>{Un()})});const fm={dataset:C(()=>({"data-expanded":M.isOpen()?"":void 0,"data-closed":M.isOpen()?void 0:""})),isOpen:M.isOpen,contentPresence:I,nestedMenus:E,currentPlacement:x,pointerGraceTimeoutId:()=>a,autoFocus:w,listState:()=>re,parentMenuContext:()=>r,triggerRef:h,contentRef:m,triggerId:d,contentId:f,setTriggerRef:p,setContentRef:b,open:Y,close:fe,toggle:$,focusContent:V,onItemEnter:At,onItemLeave:Ae,onTriggerLeave:dm,setPointerDir:U=>c=U,setPointerGraceTimeoutId:U=>a=U,setPointerGraceIntent:U=>l=U,registerNestedMenu:Q,registerItemToParentDomCollection:n?.registerItem,registerTriggerId:yn(u),registerContentId:yn(g)};return y(R,{get children(){return y(hs.Provider,{value:fm,get children(){return y(Gd,L({anchorRef:h,contentRef:m,onCurrentPlacementChange:_},s))}})}})}const Jd=ce();function Zd(e){let t;const n=Ct(),r=Et(),o=Me({id:n.generateId(`item-${Te()}`)},e),[i,s]=j(o,["ref","textValue","disabled","closeOnSelect","checked","indeterminate","onSelect","onPointerMove","onPointerLeave","onPointerDown","onPointerUp","onClick","onKeyDown","onMouseDown","onFocus"]),[a,l]=O(),[c,d]=O(),[u,f]=O(),g=()=>r.listState().selectionManager(),h=()=>s.id,p=()=>g().focusedKey()===h(),m=()=>{i.onSelect?.(),i.closeOnSelect&&r.close(!0)};qu({getItem:()=>({ref:()=>t,type:"item",key:h(),textValue:i.textValue??u()?.textContent??t?.textContent??"",disabled:i.disabled??!1})});const b=Tu({key:h,selectionManager:g,shouldSelectOnPressUp:!0,allowsDifferentPressOrigin:!0,disabled:()=>i.disabled},()=>t),w=P=>{ge(P,i.onPointerMove),P.pointerType==="mouse"&&(i.disabled?r.onItemLeave(P):(r.onItemEnter(P),P.defaultPrevented||(de(P.currentTarget),r.listState().selectionManager().setFocused(!0),r.listState().selectionManager().setFocusedKey(h()))))},v=P=>{ge(P,i.onPointerLeave),P.pointerType==="mouse"&&r.onItemLeave(P)},x=P=>{ge(P,i.onPointerUp),!i.disabled&&P.button===0&&m()},_=P=>{if(ge(P,i.onKeyDown),!P.repeat&&!i.disabled)switch(P.key){case"Enter":case" ":m();break}},E=C(()=>{if(i.indeterminate)return"mixed";if(i.checked!=null)return i.checked}),k=C(()=>({"data-indeterminate":i.indeterminate?"":void 0,"data-checked":i.checked&&!i.indeterminate?"":void 0,"data-disabled":i.disabled?"":void 0,"data-highlighted":p()?"":void 0})),F={isChecked:()=>i.checked,dataset:k,setLabelRef:f,generateId:ui(()=>s.id),registerLabel:yn(l),registerDescription:yn(d)};return y(Jd.Provider,{value:F,get children(){return y(bn,L({as:"div",ref(P){var R=st(M=>t=M,i.ref);typeof R=="function"&&R(P)},get tabIndex(){return b.tabIndex()},get"aria-checked"(){return E()},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 ve([i.onPointerDown,b.onPointerDown])},get onPointerUp(){return ve([x,b.onPointerUp])},get onClick(){return ve([i.onClick,b.onClick])},get onKeyDown(){return ve([_,b.onKeyDown])},get onMouseDown(){return ve([i.onMouseDown,b.onMouseDown])},get onFocus(){return ve([i.onFocus,b.onFocus])},onPointerMove:w,onPointerLeave:v},k,s))}})}const Qd=ce();function ms(){return he(Qd)}function ef(e){let t;const n=Ct(),r=Et(),o=ms(),i=Me({id:n.generateId(`content-${Te()}`)},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=Iu({selectionManager:r.listState().selectionManager,collection:r.listState().collection,autoFocus:r.autoFocus,deferAutoFocus:!0,shouldFocusWrap:!0,disallowTypeAhead:()=>!r.listState().selectionManager().isFocused()},()=>t);au({trapFocus:()=>c()&&r.isOpen(),onMountAutoFocus:m=>{o===void 0&&s.onOpenAutoFocus?.(m)},onUnmountAutoFocus:s.onCloseAutoFocus},()=>t);const u=m=>{if(Le(m.currentTarget,m.target)&&(m.key==="Tab"&&r.isOpen()&&m.preventDefault(),o!==void 0&&m.currentTarget.getAttribute("aria-haspopup")!=="true"))switch(m.key){case"ArrowRight":m.stopPropagation(),m.preventDefault(),r.close(!0),o.setAutoFocusMenu(!0),o.nextMenu();break;case"ArrowLeft":if(m.currentTarget.hasAttribute("data-closed"))break;m.stopPropagation(),m.preventDefault(),r.close(!0),o.setAutoFocusMenu(!0),o.previousMenu();break}},f=m=>{s.onEscapeKeyDown?.(m),o?.setAutoFocusMenu(!1),r.close(!0)},g=m=>{s.onFocusOutside?.(m),n.isModal()&&m.preventDefault()},h=m=>{ge(m,s.onPointerEnter),r.isOpen()&&(r.parentMenuContext()?.listState().selectionManager().setFocused(!1),r.parentMenuContext()?.listState().selectionManager().setFocusedKey(void 0))},p=m=>{if(ge(m,s.onPointerMove),m.pointerType!=="mouse")return;const b=m.target,w=l!==m.clientX;Le(m.currentTarget,b)&&w&&(r.setPointerDir(m.clientX>l?"right":"left"),l=m.clientX)};return T(()=>K(r.registerContentId(s.id))),y(Z,{get when(){return r.contentPresence.isPresent()},get children(){return y(rd,{get children(){return y(td,L({ref(m){var b=st(w=>{r.setContentRef(w),r.contentPresence.setRef(w),t=w},s.ref);typeof b=="function"&&b(m)},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:f,onFocusOutside:g,get onDismiss(){return r.close},get onKeyDown(){return ve([s.onKeyDown,d.onKeyDown,u])},get onMouseDown(){return ve([s.onMouseDown,d.onMouseDown])},get onFocusIn(){return ve([s.onFocusIn,d.onFocusIn])},get onFocusOut(){return ve([s.onFocusOut,d.onFocusOut])},onPointerEnter:h,onPointerMove:p},()=>r.dataset(),a))}})}})}function tf(e){let t;const n=Ct(),r=Et(),[o,i]=j(e,["ref"]);return Hi({element:()=>t??null,enabled:()=>r.isOpen()&&n.preventScroll()}),y(ef,L({ref(s){var a=st(l=>{t=l},o.ref);typeof a=="function"&&a(s)}},i))}function nf(e){return y(Zd,L({role:"menuitem",closeOnSelect:!0},e))}function rf(e){const t=Et();return y(Z,{get when(){return t.contentPresence.isPresent()},get children(){return y(Wo,e)}})}function of(e){const t=`menu-${Te()}`,n=Me({id:t,modal:!0},e),[r,o]=j(n,["id","modal","preventScroll","forceMount","open","defaultOpen","onOpenChange","value"]),i=xi({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:ui(()=>r.id),value:()=>r.value};return y(ps.Provider,{value:s,get children(){return y(Xd,L({get open(){return i.isOpen()},get onOpenChange(){return i.setIsOpen}},o))}})}function sf(e){const t=Ct(),n=Et(),r=ms(),o=Me({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,T(()=>{r.registerMenu(a,[n.contentRef(),...n.nestedMenus()])}),T(()=>{r.value()===a?(n.triggerRef()?.focus(),r.autoFocusMenu()&&n.open(!0)):n.close(!0)}),T(()=>{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=h=>{ge(h,i.onPointerDown),h.currentTarget.dataset.pointerType=h.pointerType,!i.disabled&&h.pointerType!=="touch"&&h.button===0&&l()},d=h=>{ge(h,i.onClick),i.disabled||h.currentTarget.dataset.pointerType==="touch"&&l()},u=h=>{if(ge(h,i.onKeyDown),!i.disabled)switch(h.key){case"Enter":case" ":case"ArrowDown":h.stopPropagation(),h.preventDefault(),Wc(h.currentTarget),n.toggle("first");break;case"ArrowUp":h.stopPropagation(),h.preventDefault(),n.toggle("last");break;case"ArrowRight":if(r===void 0)break;h.stopPropagation(),h.preventDefault(),r.nextMenu();break;case"ArrowLeft":if(r===void 0)break;h.stopPropagation(),h.preventDefault(),r.previousMenu();break}},f=h=>{ge(h,i.onMouseOver),!i.disabled&&r!==void 0&&r.value()!==void 0&&r.setValue(a)},g=h=>{ge(h,i.onFocus),r!==void 0&&r.setValue(a)};return T(()=>K(n.registerTriggerId(i.id))),y($u,L({ref(h){var p=st(n.setTriggerRef,i.ref);typeof p=="function"&&p(h)},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:f,onClick:d,onKeyDown:u,onFocus:g,role:r!==void 0?"menuitem":void 0},()=>n.dataset(),s))}function af(e){const t=Ct(),n=Et(),[r,o]=j(e,["onCloseAutoFocus","onInteractOutside"]);let i=!1;return y(tf,L({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 lf(e){const t=`dropdownmenu-${Te()}`,n=Me({id:t},e);return y(of,n)}function cf(e){return we({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 uf(e){return we({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 df(e){return we({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 ff=e=>y(lf,L({gutter:4},e)),hf=sf,gf=e=>{const[,t]=j(e,["class"]);return y(rf,{get mount(){return Jt()},get children(){return y(af,L({get class(){return Ge("z-50 min-w-[128px] 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))}})},pf=e=>{const[,t]=j(e,["class"]);return y(nf,L({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 mf(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 yf(e){if(Array.isArray(e)){console.info("----------------------------------------------------------");for(const t of e)console.info("Executed:",t.type),console.info(t)}}async function bf(e,t,n){const r=`${Zt}/v1/messages`,o=lr(),i={"Content-Type":"application/json"};o&&(i["x-session-id"]=o);const s={credentials:"include",method:"POST",headers:i,body:JSON.stringify({channelId:n,postback:t,type:"text",text:e,metadata:{pageUrl:window.location.href,pageTitle:document.title}})};await fetch(r,s)}async function wf(e,t,n){if(!e||!t||!n)return;const r=`${Zt}/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 Fe=Object.create(null);Fe.open="0",Fe.close="1",Fe.ping="2",Fe.pong="3",Fe.message="4",Fe.upgrade="5",Fe.noop="6";const _n=Object.create(null);Object.keys(Fe).forEach(e=>{_n[Fe[e]]=e});const $r={type:"error",data:"parser error"},ys=typeof Blob=="function"||typeof Blob<"u"&&Object.prototype.toString.call(Blob)==="[object BlobConstructor]",bs=typeof ArrayBuffer=="function",ws=e=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(e):e&&e.buffer instanceof ArrayBuffer,Nr=({type:e,data:t},n,r)=>ys&&t instanceof Blob?n?r(t):vs(t,r):bs&&(t instanceof ArrayBuffer||ws(t))?n?r(t):vs(new Blob([t]),r):r(Fe[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 xs(e){return e instanceof Uint8Array?e:e instanceof ArrayBuffer?new Uint8Array(e):new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}let Kr;function vf(e,t){if(ys&&e.data instanceof Blob)return e.data.arrayBuffer().then(xs).then(t);if(bs&&(e.data instanceof ArrayBuffer||ws(e.data)))return t(xs(e.data));Nr(e,!1,n=>{Kr||(Kr=new TextEncoder),t(Kr.encode(n))})}const Ss="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Wt=typeof Uint8Array>"u"?[]:new Uint8Array(256);for(let e=0;e<Ss.length;e++)Wt[Ss.charCodeAt(e)]=e;const xf=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},Sf=typeof ArrayBuffer=="function",zr=(e,t)=>{if(typeof e!="string")return{type:"message",data:ks(e,t)};const n=e.charAt(0);return n==="b"?{type:"message",data:kf(e.substring(1),t)}:_n[n]?e.length>1?{type:_n[n],data:e.substring(1)}:{type:_n[n]}:$r},kf=(e,t)=>{if(Sf){const n=xf(e);return ks(n,t)}else return{base64:!0,data:e}},ks=(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="",Ef=(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))})})},Cf=(e,t)=>{const n=e.split(Es),r=[];for(let o=0;o<n.length;o++){const i=zr(n[o],t);if(r.push(i),i.type==="error")break}return r};function Of(){return new TransformStream({transform(e,t){vf(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 Br;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 _f(e,t){Br||(Br=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($r);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(zr(i?l:Br.decode(l),t)),r=0}if(o===0||o>e){a.enqueue($r);break}}}})}const Cs=4;function te(e){if(e)return Pf(e)}function Pf(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")(),Af="arraybuffer";function mm(){}function Os(e,...t){return t.reduce((n,r)=>(e.hasOwnProperty(r)&&(n[r]=e[r]),n),{})}const Tf=Se.setTimeout,Lf=Se.clearTimeout;function Ln(e,t){t.useNativeTimers?(e.setTimeoutFn=Tf.bind(Se),e.clearTimeoutFn=Lf.bind(Se)):(e.setTimeoutFn=Se.setTimeout.bind(Se),e.clearTimeoutFn=Se.clearTimeout.bind(Se))}const Mf=1.33;function Df(e){return typeof e=="string"?If(e):Math.ceil((e.byteLength||e.size)*Mf)}function If(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 _s(){return Date.now().toString(36).substring(3)+Math.random().toString(36).substring(2,5)}function Rf(e){let t="";for(let n in e)e.hasOwnProperty(n)&&(t.length&&(t+="&"),t+=encodeURIComponent(n)+"="+encodeURIComponent(e[n]));return t}function Ff(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 $f 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,Ln(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 $f(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=zr(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=Rf(t);return n.length?"?"+n:""}}class Nf 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)};Cf(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,Ef(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]=_s()),!this.supportsBinary&&!n.sid&&(n.b64=1),this.createUri(t,n)}}let Ps=!1;try{Ps=typeof XMLHttpRequest<"u"&&"withCredentials"in new XMLHttpRequest}catch{}const Kf=Ps;function zf(){}class Bf extends Nf{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 $e extends te{constructor(t,n,r){super(),this.createRequest=t,Ln(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=Os(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=$e.requestsCount++,$e.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=zf,t)try{this._xhr.abort()}catch{}typeof document<"u"&&delete $e.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($e.requestsCount=0,$e.requests={},typeof document<"u"){if(typeof attachEvent=="function")attachEvent("onunload",As);else if(typeof addEventListener=="function"){const e="onpagehide"in Se?"pagehide":"unload";addEventListener(e,As,!1)}}function As(){for(let e in $e.requests)$e.requests.hasOwnProperty(e)&&$e.requests[e].abort()}const Vf=function(){const e=Ts({xdomain:!1});return e&&e.responseType!==null}();class Uf extends Bf{constructor(t){super(t);const n=t&&t.forceBase64;this.supportsBinary=Vf&&!n}request(t={}){return Object.assign(t,{xd:this.xd},this.opts),new $e(Ts,this.uri(),t)}}function Ts(e){const t=e.xdomain;try{if(typeof XMLHttpRequest<"u"&&(!t||Kf))return new XMLHttpRequest}catch{}if(!t)try{return new Se[["Active"].concat("Object").join("X")]("Microsoft.XMLHTTP")}catch{}}const Ls=typeof navigator<"u"&&typeof navigator.product=="string"&&navigator.product.toLowerCase()==="reactnative";class jf extends Vr{get name(){return"websocket"}doOpen(){const t=this.uri(),n=this.opts.protocols,r=Ls?{}:Os(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]=_s()),this.supportsBinary||(n.b64=1),this.createUri(t,n)}}const Ur=Se.WebSocket||Se.MozWebSocket;class qf extends jf{createSocket(t,n,r){return Ls?new Ur(t,n,r):n?new Ur(t,n):new Ur(t)}doWrite(t,n){this.ws.send(n)}}class Hf 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=_f(Number.MAX_SAFE_INTEGER,this.socket.binaryType),r=t.readable.pipeThrough(n).getReader(),o=Of();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 Wf={websocket:qf,webtransport:Hf,polling:Uf},Gf=/^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,Yf=["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=Gf.exec(e||""),i={},s=14;for(;s--;)i[Yf[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=Xf(i,i.path),i.queryKey=Jf(i,i.query),i}function Xf(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 Jf(e,t){const n={};return t.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,function(r,o,i){o&&(n[o]=i)}),n}const qr=typeof addEventListener=="function"&&typeof removeEventListener=="function",Mn=[];qr&&addEventListener("offline",()=>{Mn.forEach(e=>e())},!1);class Ze extends te{constructor(t,n){if(super(),this.binaryType=Af,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);Ln(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=Ff(this.opts.query)),qr&&(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"})},Mn.push(this._offlineEventListener))),this.opts.withCredentials&&(this._cookieJar=void 0),this._open()}createTransport(t){const n=Object.assign({},this.opts.query);n.EIO=Cs,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(),qr&&(this._beforeunloadEventListener&&removeEventListener("beforeunload",this._beforeunloadEventListener,!1),this._offlineEventListener)){const r=Mn.indexOf(this._offlineEventListener);r!==-1&&Mn.splice(r,1)}this.readyState="closed",this.id=null,this.emitReserved("close",t,n),this.writeBuffer=[],this._prevBufferLen=0}}}Ze.protocol=Cs;class Zf 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 f=new Error("probe error");f.transport=n.name,this.emitReserved("upgradeError",f)}}))};function i(){r||(r=!0,d(),n.close(),n=null)}const s=u=>{const f=new Error("probe error: "+u);f.transport=n.name,i(),this.emitReserved("upgradeError",f)};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 Qf=class extends Zf{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=>Wf[o]).filter(o=>!!o)),super(t,r)}};function eh(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 th=typeof ArrayBuffer=="function",nh=e=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(e):e.buffer instanceof ArrayBuffer,Ms=Object.prototype.toString,rh=typeof Blob=="function"||typeof Blob<"u"&&Ms.call(Blob)==="[object BlobConstructor]",oh=typeof File=="function"||typeof File<"u"&&Ms.call(File)==="[object FileConstructor]";function Hr(e){return th&&(e instanceof ArrayBuffer||nh(e))||rh&&e instanceof Blob||oh&&e instanceof File}function Dn(e,t){if(!e||typeof e!="object")return!1;if(Array.isArray(e)){for(let n=0,r=e.length;n<r;n++)if(Dn(e[n]))return!0;return!1}if(Hr(e))return!0;if(e.toJSON&&typeof e.toJSON=="function"&&arguments.length===1)return Dn(e.toJSON(),!0);for(const n in e)if(Object.prototype.hasOwnProperty.call(e,n)&&Dn(e[n]))return!0;return!1}function ih(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(Hr(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 sh(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 ah=["connect","connect_error","disconnect","disconnecting","newListener","removeListener"],lh=5;var B;(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"})(B||(B={}));class ch{constructor(t){this.replacer=t}encode(t){return(t.type===B.EVENT||t.type===B.ACK)&&Dn(t)?this.encodeAsBinary({type:t.type===B.EVENT?B.BINARY_EVENT:B.BINARY_ACK,nsp:t.nsp,data:t.data,id:t.id}):[this.encodeAsString(t)]}encodeAsString(t){let n=""+t.type;return(t.type===B.BINARY_EVENT||t.type===B.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=ih(t),r=this.encodeAsString(n.packet),o=n.buffers;return o.unshift(r),o}}function Ds(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===B.BINARY_EVENT;r||n.type===B.BINARY_ACK?(n.type=r?B.EVENT:B.ACK,this.reconstructor=new uh(n),n.attachments===0&&super.emitReserved("decoded",n)):super.emitReserved("decoded",n)}else if(Hr(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(B[r.type]===void 0)throw new Error("unknown packet type "+r.type);if(r.type===B.BINARY_EVENT||r.type===B.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 B.CONNECT:return Ds(n);case B.DISCONNECT:return n===void 0;case B.CONNECT_ERROR:return typeof n=="string"||Ds(n);case B.EVENT:case B.BINARY_EVENT:return Array.isArray(n)&&(typeof n[0]=="number"||typeof n[0]=="string"&&ah.indexOf(n[0])===-1);case B.ACK:case B.BINARY_ACK:return Array.isArray(n)}}destroy(){this.reconstructor&&(this.reconstructor.finishedReconstruction(),this.reconstructor=null)}}class uh{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=sh(this.reconPack,this.buffers);return this.finishedReconstruction(),n}return null}finishedReconstruction(){this.reconPack=null,this.buffers=[]}}const dh=Object.freeze(Object.defineProperty({__proto__:null,Decoder:Yr,Encoder:ch,get PacketType(){return B},protocol:lh},Symbol.toStringTag,{value:"Module"}));function Pe(e,t,n){return e.on(t,n),function(){e.off(t,n)}}const fh=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1});class Is 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=[Pe(t,"open",this.onopen.bind(this)),Pe(t,"packet",this.onpacket.bind(this)),Pe(t,"error",this.onerror.bind(this)),Pe(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(fh.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:B.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:B.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 B.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 B.EVENT:case B.BINARY_EVENT:this.onevent(t);break;case B.ACK:case B.BINARY_ACK:this.onack(t);break;case B.DISCONNECT:this.ondisconnect();break;case B.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:B.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:B.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 Ot(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}Ot.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},Ot.prototype.reset=function(){this.attempts=0},Ot.prototype.setMin=function(e){this.ms=e},Ot.prototype.setMax=function(e){this.max=e},Ot.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,Ln(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 Ot({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||dh;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 Qf(this.uri,this.opts);const n=this.engine,r=this;this._readyState="opening",this.skipReconnect=!1;const o=Pe(n,"open",function(){r.onopen(),t&&t()}),i=a=>{this.cleanup(),this._readyState="closed",this.emitReserved("error",a),t?t(a):this.maybeReconnectOnOpen()},s=Pe(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(Pe(t,"ping",this.onping.bind(this)),Pe(t,"data",this.ondata.bind(this)),Pe(t,"error",this.onerror.bind(this)),Pe(t,"close",this.onclose.bind(this)),Pe(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 Is(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=eh(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:Is,io:In,connect:In});class Qe{static instance;constructor(){}static init(t){if(!Qe.instance){const n=lr();Qe.instance=In(Ua,{path:"/ws",withCredentials:!0,extraHeaders:{"widget-id":t},auth:{sessionId:n,widgetId:t},query:{sessionId:n||""}}),Qe.instance.on("connect",()=>{console.info("SmartTalks.ai widget connected!",Qe.instance.id)})}return Qe.instance}static on(t,n,r){const o=Qe.instance||this.init(n);o.off(t),o.on(t,r)}}const Rs=1e3*60*60*24,[Rn,Fs]=ni("smarttalks-widget-messages",{},Rs),$s=()=>{const{widgetId:e}=ie();return Rn[e()]??[]},hh=e=>{const{widgetId:t}=ie();Fs({...Rn,[t()]:[...Rn[t()]??[],e]})},gh=()=>{const{widgetId:e}=ie();Fs({...Rn,[e()]:[]})},[Ns,ph]=ni("smarttalks-widget-conversationinfo",{},Rs),Ks=()=>{const{widgetId:e}=ie();return Ns[e()]??{}},zs=e=>{const{widgetId:t}=ie();ph({...Ns,[t()]:e})},[mh,Jr]=O(!1),[yh,Bs]=O(!1),Vs=[],Us=()=>{Vs.forEach(e=>e())},bh=e=>Vs.push(e),Zr=e=>{const t=mf(e);if(hh(t),t.type==="media"){setTimeout(Us,200);return}Us()},wh=(e,t)=>{const{chatWidget:n,widgetId:r}=ie(),o=Ks();e.trim()&&(Zr({text:e,type:"text",origin:"user",createdAt:new Date().toString()}),ee("onInput",e),Qe.on("message",r(),i=>{(i.contactId!==o.contactId||i.interactionId!==o.interactionId)&&zs({contactId:i.contactId,interactionId:i.interactionId});for(const s of i.messages)Zr(s),ee("onAnswer",s);Jr(!1),yf(i.debug)}),Jr(!0),bf(e,t,n()?._id).catch(i=>{console.error(i),Jr(!1)}))},vh=()=>{const{chatWidget:e}=ie(),t=Ks();Bs(!0),gh(),wf(e()?._id,t.contactId,t.interactionId).finally(()=>{zs({}),Bs(!1),js()}),ee("onReset")},js=()=>{const{chatWidget:e}=ie();if($s().length===0&&e()?.balloonMessage){const n=e()?.balloonMessage;n&&Zr({text:n,type:"text",origin:"bot",createdAt:new Date().toString()})}},et=()=>({getMessages:$s,pushMessage:wh,clearMessages:vh,addBalloonMessage:js,onMessage:bh,typing:mh,loading:yh});var xh=D("<span>");const Sh=()=>{const{clearMessages:e}=et();O(!1);const[t,n]=O(!1);return y(ff,{get open(){return t()},onOpenChange:n,get children(){return[y(hf,{get children(){return y(Ee,{variant:"ghost",size:"icon",class:"hover:bg-accent/10 hover:text-primary-foreground",get children(){return y(gc,{size:20})}})}}),y(gf,{get children(){return y(pf,{class:"flex space-x-2 items-center cursor-pointer",onSelect:e,get children(){return[y(hc,{size:14}),(()=>{var r=xh();return A(r,()=>ft("restart")),r})()]}})}})]}})};function kh(e){return we({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 we({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 Ch(e){return we({a:{fill:"currentColor",viewBox:"0 0 16 16"},c:'<path d="M13.601 2.326A7.854 7.854 0 0 0 7.994 0C3.627 0 .068 3.558.064 7.926c0 1.399.366 2.76 1.057 3.965L0 16l4.204-1.102a7.933 7.933 0 0 0 3.79.965h.004c4.368 0 7.926-3.558 7.93-7.93A7.898 7.898 0 0 0 13.6 2.326zM7.994 14.521a6.573 6.573 0 0 1-3.356-.92l-.24-.144-2.494.654.666-2.433-.156-.251a6.56 6.56 0 0 1-1.007-3.505c0-3.626 2.957-6.584 6.591-6.584a6.56 6.56 0 0 1 4.66 1.931 6.557 6.557 0 0 1 1.928 4.66c-.004 3.639-2.961 6.592-6.592 6.592zm3.615-4.934c-.197-.099-1.17-.578-1.353-.646-.182-.065-.315-.099-.445.099-.133.197-.513.646-.627.775-.114.133-.232.148-.43.05-.197-.1-.836-.308-1.592-.985-.59-.525-.985-1.175-1.103-1.372-.114-.198-.011-.304.088-.403.087-.088.197-.232.296-.346.1-.114.133-.198.198-.33.065-.134.034-.248-.015-.347-.05-.099-.445-1.076-.612-1.47-.16-.389-.323-.335-.445-.34-.114-.007-.247-.007-.38-.007a.729.729 0 0 0-.529.247c-.182.198-.691.677-.691 1.654 0 .977.71 1.916.81 2.049.098.133 1.394 2.132 3.383 2.992.47.205.84.326 1.129.418.475.152.904.129 1.246.08.38-.058 1.171-.48 1.338-.943.164-.464.164-.86.114-.943-.049-.084-.182-.133-.38-.232z"/>'},e)}function Oh(e){return we({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 _h=D('<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}=ie(),[t,n]=O(!1);let r=null;ht(()=>{/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)&&c()});const o=f=>{const g=f;return!!(g.requestFullscreen||g.webkitRequestFullscreen||g.msRequestFullscreen)},i=async f=>{const g=f;try{if(g.requestFullscreen)return await g.requestFullscreen(),!0;if(g.webkitRequestFullscreen)return g.webkitRequestFullscreen(),!0;if(g.msRequestFullscreen)return g.msRequestFullscreen(),!0}catch{}return!1},s=async()=>{const f=document;try{if(document.exitFullscreen)return await document.exitFullscreen(),!0;if(f.webkitExitFullscreen)return f.webkitExitFullscreen(),!0;if(f.msExitFullscreen)return f.msExitFullscreen(),!0}catch{}return!1},a=f=>{r=document.body.style.overflow||null,document.body.style.overflow="hidden",f.classList.add("st-fullscreen"),n(!0)},l=f=>{f.classList.remove("st-fullscreen"),r!==null?(document.body.style.overflow=r,r=null):document.body.style.overflow="",n(!1)},c=async()=>{try{const f=Jt();if(!f)return;if(!t())o(f)&&await i(f)||a(f);else{const g=document;(document.fullscreenElement||g.webkitFullscreenElement||g.msFullscreenElement)&&await s()||l(f)}}catch{console.error("SmartTalks.ai Widget unable to toggle fullscreen in the current state.")}},d=()=>{const f=document,g=!!(document.fullscreenElement||f.webkitFullscreenElement||f.msFullscreenElement);if(n(g),!g)try{const h=Jt();h.classList.contains("st-fullscreen")&&l(h)}catch{}};document.addEventListener("fullscreenchange",d),document.addEventListener("webkitfullscreenchange",d);const u=()=>{e()?.mode==="popup"&&ee("close")};return ne("toggleFullscreen",()=>{c()}),(()=>{var f=_h(),g=f.firstChild;return A(f,y(dc,{}),g),A(g,y(Ee,{size:"icon",variant:"ghost",class:"hover:bg-accent/10 hover:text-primary-foreground",onClick:c,get children(){return y(Z,{get when(){return t()},get fallback(){return y(Eh,{size:16})},get children(){return y(kh,{size:16})}})}}),null),A(g,y(Z,{get when(){return e()?.showSettings},get children(){return y(Sh,{})}}),null),A(g,y(Z,{get when(){return e()?.mode==="popup"},get children(){return y(Ee,{size:"icon",variant:"ghost",class:"hover:bg-accent/10 hover:text-primary-foreground",onClick:u,get children(){return y(Oh,{size:16})}})}}),null),f})()};var Ph=D("<span>");const qs=({createdAt:e,anchor:t="end"})=>(()=>{var n=Ph();return nt(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 Ah=D('<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 Th=({children:e,createdAt:t})=>(()=>{var n=Ah(),r=n.firstChild;return A(r,e),A(n,y(qs,{createdAt:t,anchor:"start"}),null),n})();var Lh=D("<span>");const _t=e=>{const[,t]=j(e,["class","children"]);let n=e.children?.toString();return n&&(n=za(Ba(n))),(()=>{var r=Lh();return r.innerHTML=n,rt(r,L({get class(){return Ge("whitespace-pre-line",e.class)}},t),!1,!1),r})()};var Mh=D('<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}=et(),[o,i]=O(!1),s=(a,l)=>{i(!0),r(a,l)};return(()=>{var a=Mh(),l=a.firstChild,c=l.firstChild;A(a,y(_t,{get children(){return t?.trim()}}),l);var d=n;return typeof d=="function"?or(d,c):n=c,A(c,y(pt,{each:e,children:u=>y(Ee,{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()}})})),oe(()=>nt(l,`flex items-center justify-center max-w-80 mx-[-16px] ${o()&&"opacity-50"}`)),a})()};var Ih=D('<div class="flex flex-col"><span>'),Rh=D("<a target=_blank><img><span></span><span>");const Fh=({options:e,text:t})=>(()=>{var n=Ih(),r=n.firstChild;return A(r,()=>t?.trim()),A(n,y(pt,{each:e,children:o=>(()=>{var i=Rh(),s=i.firstChild,a=s.nextSibling,l=a.nextSibling;return A(a,()=>o.title?.trim()),A(l,()=>o.description?.trim()),oe(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 $h=D("<a target=_blank>");const Nh=({url:e,text:t})=>(()=>{var n=$h();return ue(n,"href",e),A(n,()=>t?.trim()),n})();var G=e=>typeof e=="function"?e():e,Hs=e=>requestAnimationFrame(()=>requestAnimationFrame(e)),Kh=e=>{const t=L({initialRegistered:!1},e),[n,r]=O(t.initialRegistered);return[C(()=>{if(n())return G(t.value)}),()=>{r(!0)},()=>{r(!1)}]},Ws=Kh,Yt=e=>typeof e=="function",zh=["button","color","file","image","reset","submit"],Bh=(e,t)=>e==="button"?!0:e==="input"&&t?zh.indexOf(t)!==-1:!1;function Vh(e){const[t,n]=O(e.initialValue),r=()=>e.value?.()!==void 0,o=()=>r()?e.value?.():t();return[o,s=>H(()=>{let a;return Yt(s)?a=s(o()):a=s,Object.is(a,o())||(r()||n(a),e.onChange?.(a)),a})]}var eo=Vh,Fn=new Map,$n=(e,t)=>{if(Fn.has(e))return Fn.get(e);const n=ce(t);return Fn.set(e,n),n},to=e=>{const t=Fn.get(e);if(t)return he(t)},Nn=new Map,Uh=e=>{T(()=>{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?.()}})})},jh=Uh,qh=e=>{const t=L({enabled:!0},e);T(()=>{G(t.enabled)&&(document.addEventListener("keydown",n),K(()=>{document.removeEventListener("keydown",n)}))});const n=r=>{r.key==="Escape"&&t.onEscapeKeyDown(r)}},Hh=qh,Wh=e=>{const t=L({enabled:!0},e);T(()=>{const{body:n}=document;G(t.enabled)&&jh({key:"no-pointer-events",element:n,style:{pointerEvents:"none"}})})},Gh=Wh,Yh=e=>{const t=L({enabled:!0,strategy:"pointerup"},e);T(()=>{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)}},Xh=Yh,Jh=e=>{const t=L({dismissOnEscapeKeyDown:!0,dismissOnOutsidePointer:!0,closeOnOutsidePointerStrategy:"pointerup",noOutsidePointerEvents:!0},e);Hh({enabled:t.dismissOnEscapeKeyDown,onEscapeKeyDown:n=>{t.onEscapeKeyDown?.(n),n.defaultPrevented||t.onDismiss("escapeKey")}}),Xh({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}),Gh({enabled:t.noOutsidePointerEvents})},Zh=Jh,no=ce(),Qh=e=>C(()=>{if(he(no))return y(Gs,e);const r=Te(),[o,i]=O([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(Gs,e)}})}),Gs=e=>{const t=L({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=Te();T(()=>{n.enabled?o.onLayerShow(i):o.onLayerDismiss(i)});const s=()=>o.layers()[o.layers().length-1]===i;Zh({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 H(()=>l())},eg=Qh,tg=()=>{const[e,t]=O(!1);return T(()=>t(!0)),e},ng=tg,rg=(e,t)=>(e&&(Yt(e)?e(t):e[0](e[1],t)),t.defaultPrevented),ro=(...e)=>e.some(t=>!!t()),og=e=>(...t)=>{for(const n of e)n&&n(...t)},Kn=(...e)=>og(e),le=e=>e?"":void 0,ig="div",sg=e=>{const[t,n]=j(e,["as"]),r=C(()=>t.as??ig);return C(()=>{const i=r();switch(typeof i){case"function":return H(()=>i(n));case"string":return y(ln,L({component:i},n))}})},oo=sg,ag=e=>{let t,n=!1;return()=>n?t:(n=!0,t=C(e))},Ys=ag,lg=e=>C(()=>G(e.element)?.tagName.toLowerCase()||e.fallback),cg=lg,Xs="button",ug=e=>{const[t,n]=O(null),[r,o]=j(e,["as","ref","type"]),i=cg({element:t,fallback:Xs}),s=C(()=>Bh(i(),r.type));return y(oo,L({get as(){return r.as??Xs},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))},dg=ug,fg='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",Js={bubbles:!1,cancelable:!0},hg=e=>{const t=L({enabled:!0,observeChanges:!0,restoreFocus:!0},e),[n,r]=O(null),o=C(()=>{const h=n();return h?h[0]??null:null}),i=C(()=>{const h=n();return h?h[h.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))})};T(()=>{const h=J(t.element);if(h&&J(t.enabled)){s=document.activeElement,H(()=>{l(h),c(h)});const p=new MutationObserver(a);J(t.observeChanges)&&p.observe(h,{subtree:!0,childList:!0,attributes:!0,attributeFilter:["tabindex"]}),K(()=>{J(t.observeChanges)&&p.disconnect(),r(null),g(h)})}}),T(()=>{const h=n();h===null||h.length!==0||(document.addEventListener("keydown",f),K(()=>{document.removeEventListener("keydown",f)}))}),T(()=>{const h=o();h&&(h.addEventListener("keydown",d),K(()=>{h.removeEventListener("keydown",d)}))}),T(()=>{const h=i();h&&(h.addEventListener("keydown",u),K(()=>{h.removeEventListener("keydown",u)}))});const l=h=>{const p=Array.from(h.querySelectorAll(fg)).map((m,b)=>({element:m,domIndex:b,tabIndex:m.tabIndex})).sort((m,b)=>m.tabIndex===b.tabIndex?m.domIndex-b.domIndex:m.tabIndex-b.tabIndex);r(p.map(({element:m})=>m))},c=h=>{Cr(()=>{const p=J(t.initialFocusElement)??o()??h,m=t.onInitialFocus;let b;m&&(b=new CustomEvent(io,Js),h.addEventListener(io,m),h.dispatchEvent(b),h.removeEventListener(io,m)),b?.defaultPrevented!==!0&&p.focus()})},d=h=>{h.key==="Tab"&&h.shiftKey&&(h.preventDefault(),i().focus())},u=h=>{h.key==="Tab"&&!h.shiftKey&&(h.preventDefault(),o().focus())},f=h=>{h.key==="Tab"&&h.preventDefault()},g=h=>{Cr(()=>{if(!J(t.restoreFocus))return;const m=J(t.finalFocusElement)??s;if(!m)return;let b;const w=t.onFinalFocus;w&&(b=new CustomEvent(so,Js),h.addEventListener(so,w),h.dispatchEvent(b),h.removeEventListener(so,w)),b?.defaultPrevented!==!0&&m.focus()})}},gg=hg,pg=gg,mg=e=>{const t=C(()=>{const s=J(e.element);if(s)return getComputedStyle(s)}),n=()=>t()?.animationName??"none",[r,o]=O(J(e.show)?"present":"hidden");let i="none";return T(s=>{const a=J(e.show);return H(()=>{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}),T(()=>{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}},yg=mg,Zs=yg,bg=ce(),wg=e=>e?$n(`dialog-${e}`):bg,Qs=ce(),vg=e=>e?$n(`dialog-internal-${e}`):Qs,Pt=e=>{if(!e){const n=he(Qs);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},xg="div",Sg=e=>{const[t,n]=j(e,["as","forceMount","contextId","children","ref","style","data-corvu-dialog-content"]),r=C(()=>Pt(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(eg,{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,L({ref(l){var c=Kn(r().setContentRef,t.ref);typeof c=="function"&&c(l)},get as(){return t.as??xg},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()}}))}})}})}})},kg=Sg,Eg="div",Cg=e=>{const[t,n]=j(e,["as","forceMount","contextId","children","ref","style","data-corvu-dialog-overlay"]),r=C(()=>Pt(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,L({get as(){return t.as??Eg},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()}}))}})})()}})},Og=Cg,_g=e=>{const[t,n]=j(e,["forceMount","contextId","children"]),r=C(()=>Pt(t.contextId)),o=()=>ro(r().open,()=>t.forceMount,r().contentPresent,r().overlayPresent),i=ng(),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(Wo,L(n,{get children(){return a()}}))}})})()}})},Pg=_g,ao=!0,Ag=e=>{const t=L({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:Te()},e),[n,r]=eo({value:()=>t.open,initialValue:t.initialOpen,onChange:t.onOpenChange}),[o,i,s]=Ws({value:()=>t.labelId??Te()}),[a,l,c]=Ws({value:()=>t.descriptionId??Te()}),[d,u]=O(null),[f,g]=O(null),[h,p]=O(null),{present:m}=Zs({show:n,element:f}),{present:b}=Zs({show:n,element:h});pg({element:f,enabled:()=>n()&&t.trapFocus,initialFocusElement:()=>t.initialFocusEl??null,restoreFocus:()=>t.restoreFocus,finalFocusElement:()=>t.finalFocusEl??null,onFinalFocus:t.onFinalFocus,onInitialFocus:t.onInitialFocus}),Hi({element:f,enabled:()=>m()&&G(t.preventScroll),hideScrollbar:()=>t.hideScrollbar,preventScrollbarShift:()=>t.preventScrollbarShift,preventScrollbarShiftMode:()=>t.preventScrollbarShiftMode,allowPinchZoom:()=>t.allowPinchZoom});const w={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 m()},get contentRef(){return f()},get overlayPresent(){return b()},get overlayRef(){return h()},get dialogId(){return t.dialogId},get labelId(){return o()},get descriptionId(){return a()}},v=Ys(()=>t.children),x=()=>{const E=v()();return Yt(E)?E(w):E};return C(()=>{const E=wg(t.contextId),k=vg(t.contextId);return y(E.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:m,contentRef:f,overlayPresent:b,overlayRef:h,dialogId:()=>t.dialogId,labelId:o,descriptionId:a},get children(){return y(k.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:m,contentRef:f,overlayPresent:b,overlayRef:h,dialogId:()=>t.dialogId,labelId:o,registerLabelId:i,unregisterLabelId:s,descriptionId:a,registerDescriptionId:l,unregisterDescriptionId:c,setContentRef:g,setOverlayRef:p,triggerRef:d,setTriggerRef:u}},get children(){return H(()=>x())}})}})})},Tg=Ag,Lg="button",Mg=e=>{const[t,n]=j(e,["as","contextId","ref","onClick","data-corvu-dialog-trigger"]),r=C(()=>Pt(t.contextId));return y(dg,L({ref(i){var s=Kn(r().setTriggerRef,t.ref);typeof s=="function"&&s(i)},get as(){return t.as??Lg},onClick:i=>{!rg(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=Mg,zn=e=>typeof e=="function"?e():e,ea=e=>requestAnimationFrame(()=>requestAnimationFrame(e));function Ig(e){const t=L({enabled:!0,dimension:"both"},e),[n,r]=O(!1),[o,i]=O(null);let s=null;T(()=>{const c=zn(t.element),d=zn(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],f=zn(t.dimension);f==="both"?s?s[0]!==u[0]&&s[1]!==u[1]&&(ke(()=>{i(s),r(!0)}),ea(()=>{i(u),parseFloat(getComputedStyle(c.target).transitionDuration)===0&&l()})):s=u:s?Bn(f,s)!==Bn(f,u)&&(ke(()=>{i(Bn(f,s)),r(!0)}),ea(()=>{i(Bn(f,u)),parseFloat(getComputedStyle(c.target).transitionDuration)===0&&l()})):s=u},l=()=>{if(!n())return;const c=zn(t.element);c?s=[c.offsetWidth,c.offsetHeight]:s=null,ke(()=>{r(!1),i(null)})};return{transitioning:n,transitionSize:o}}var Bn=(e,t)=>{switch(e){case"width":return t[0];case"height":return t[1]}},Rg=Ig,Fg=Rg;const $g=(e,t)=>e.length>0?()=>e(H(t)):e;function Ng(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 ta(e,t,n){let r=()=>t;const[o,i]=O(t,cr),s=C($g(e,()=>r()),t,cr);return[r=Ng([o,s],n),a=>i(()=>typeof a=="function"?a(H(r)):a)]}var Kg=(e,t)=>{switch(t){case"x":return[e.clientWidth,e.scrollLeft,e.scrollWidth];case"y":return[e.clientHeight,e.scrollTop,e.scrollHeight]}},zg=(e,t)=>{const n=getComputedStyle(e),r=t==="x"?n.overflowX:n.overflowY;return r==="auto"||r==="scroll"||e.tagName==="HTML"&&r==="visible"},Bg=(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]=Kg(o,t),u=d-l-r*c;(c!==0||u!==0)&&zg(o,t)&&(i+=u,s+=c),o===(n??document.documentElement)?a=!0:o=o._$host??o.parentElement}while(o&&!a);return[i,s]},Vg=e=>y(Dg,L({"data-corvu-dialog-trigger":void 0,"data-corvu-drawer-trigger":""},e)),na=ce(),Ug=e=>e?$n(`drawer-${e}`):na,jg=e=>{if(!e){const n=he(na);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},ra=ce(),qg=e=>e?$n(`drawer-internal-${e}`):ra,oa=e=>{if(!e){const n=he(ra);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},ia=(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)},Hg=(e,t,n,r)=>{const o=sa("upper",e,r?n:t),i=sa("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},sa=(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),Wg=(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},Gg=void 0,Yg=e=>{const t=L({initialOpen:!1,snapPoints:[0,1],breakPoints:[Gg],defaultSnapPoint:1,side:"bottom",dampFunction:$=>6*Math.log($+1),velocityFunction:($,V)=>{const Q=$/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]=O(),{transitioning:d,transitionSize:u}=Fg({element:()=>l()?.contentRef()??null,enabled:()=>o()&&n.transitionResize,dimension:()=>{switch(n.side){case"top":case"bottom":return"height";case"left":case"right":return"width"}}}),[f,g]=O(!1),[h,p]=ta(()=>d()?"resizing":null),m=C(()=>{const $=l()?.contentRef();if($)return getComputedStyle($)}),[b,w]=O(!1);T(()=>{const $=o();H(()=>{b()!==$&&($?(w(!0),Hs(()=>{ke(()=>{p("opening"),a(n.defaultSnapPoint)}),parseFloat(m().transitionDuration)===0&&p(null)})):(ke(()=>{p("closing"),a(0)}),Hs(()=>{parseFloat(m().transitionDuration)===0&&v()})))})});const v=()=>{ke(()=>{w(!1),p(null)})},[x,_]=O(0);T(()=>{const $=l()?.contentRef();if(!$)return;k($);const V=new ResizeObserver(E);V.observe($),K(()=>{V.disconnect()})});const E=$=>{for(const V of $)V.target===l()?.contentRef()&&k(V.target)},k=$=>{const V=H(()=>x());switch(n.side){case"top":case"bottom":if(V===$.offsetHeight)return;_($.offsetHeight);break;case"left":case"right":if(V===$.offsetWidth)return;_($.offsetWidth);break}},F=C(()=>ia(s(),x())),[P,R]=ta(()=>F().offset),M=C(()=>x()?(x()-P())/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 f()},get isTransitioning(){return h()!==null},get transitionState(){return h()},get openPercentage(){return M()},get translate(){return P()},get velocityCacheReset(){return n.velocityCacheReset},get allowSkippingSnapPoints(){return n.allowSkippingSnapPoints},get handleScrollableElements(){return n.handleScrollableElements},get transitionResize(){return n.transitionResize}},re=Ys(()=>n.children),Y=$=>{c(Pt(n.contextId));const V=re()();if(Yt(V)){const Q=L($,I);return V(Q)}return V};return C(()=>{const $=Ug(n.contextId),V=qg(n.contextId);return H(()=>y($.Provider,{value:{snapPoints:()=>n.snapPoints,breakPoints:()=>n.breakPoints,defaultSnapPoint:()=>n.defaultSnapPoint,activeSnapPoint:s,setActiveSnapPoint:a,side:()=>n.side,isDragging:f,isTransitioning:()=>h()!==null,transitionState:h,openPercentage:M,translate:P,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:f,isTransitioning:()=>h()!==null,transitionState:h,openPercentage:M,translate:P,velocityCacheReset:()=>n.velocityCacheReset,allowSkippingSnapPoints:()=>n.allowSkippingSnapPoints,handleScrollableElements:()=>n.handleScrollableElements,transitionResize:()=>n.transitionResize,dampFunction:n.dampFunction,velocityFunction:n.velocityFunction,setIsDragging:g,setTranslate:R,drawerSize:x,resolvedActiveSnapPoint:F,drawerStyles:m,setTransitionState:p,transitionSize:u,closeDrawer:v}},get children(){return y(Tg,L({get open(){return b()},onOpenChange:i,get contextId(){return n.contextId},get closeOnOutsidePointer(){return!f()&&n.closeOnOutsidePointer}},r,{children:Q=>Y(Q)}))}})}}))})},Xg=Yg,Jg=e=>{const[t,n]=j(e,["contextId","style"]);let r=!1,o=null,i=[0,0],s,a=0;const l=C(()=>oa(t.contextId)),c=C(()=>Pt(t.contextId)),d=C(()=>l().snapPoints().map((v,x)=>ia(v,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)`}}),f=C(()=>{const v=l().transitionSize();if(v)switch(l().side()){case"top":case"bottom":return`${v}px`}}),g=C(()=>{const v=l().transitionSize();if(v)switch(l().side()){case"left":case"right":return`${v}px`}});T(()=>{c().open()&&(document.addEventListener("pointermove",p),document.addEventListener("touchmove",m),document.addEventListener("pointerup",w),document.addEventListener("touchend",w),K(()=>{document.removeEventListener("pointermove",p),document.removeEventListener("touchmove",m),document.removeEventListener("pointerup",w),document.removeEventListener("touchend",w)}))});const h=v=>{Wg(v.target,c().contentRef())&&l().transitionState()!=="closing"&&(r=!0,l().handleScrollableElements()&&(i=[v.clientX,v.clientY]))},p=v=>{b(v.target,v.clientX,v.clientY)},m=v=>{v.touches[0]&&b(v.target,v.touches[0].clientX,v.touches[0].clientY)},b=(v,x,_)=>{if(!r)return;if(!l().isDragging()||o===null){const F=window.getSelection();if(F&&F.toString().length>0){w();return}if(l().handleScrollableElements()){const P=[x,_].map((fe,$)=>i[$]-fe),R=Math.abs(P[0])>Math.abs(P[1])?"x":"y",M=R==="x"?P[0]:P[1];if(Math.abs(M)<.3)return;const I=c().contentRef(),[re,Y]=Bg(v,R,I);if(M>0&&Math.abs(re)>1||M<0&&Math.abs(Y)>0){w();return}}switch(l().side()){case"top":case"bottom":o=_;break;case"right":case"left":o=x}s=new Date,a=l().translate(),ke(()=>{l().setIsDragging(!0),l().setTransitionState(null)})}let E;switch(l().side()){case"top":E=-(o-_);break;case"bottom":E=o-_;break;case"right":E=o-x;break;case"left":E=-(o-x);break}E-=l().resolvedActiveSnapPoint().offset,E>0&&(E=l().dampFunction(E));const k=new Date;k.getTime()-s.getTime()>l().velocityCacheReset()&&(s=k,a=l().translate()),l().setTranslate(-E)},w=()=>{if(r=!1,!l().isDragging())return;const v=new Date,x=l().velocityFunction(-(a-l().translate()),v.getTime()-s.getTime()||1),_=l().translate()*x,E=Hg(d(),l().translate(),_,l().allowSkippingSnapPoints());ke(()=>{l().setTransitionState("snapping"),l().setIsDragging(!1)}),ke(()=>{l().setActiveSnapPoint(E.value),E.offset===l().drawerSize()?c().setOpen(!1):(l().setTranslate(E.offset),parseFloat(l().drawerStyles().transitionDuration)===0&&l().setTransitionState(null))})};return y(kg,L({get contextId(){return t.contextId},get style(){return{transform:u(),"transition-duration":l().isDragging()?"0ms":void 0,height:f(),width:g(),...t.style}},onPointerDown:h,onTransitionEnd:()=>{ke(()=>{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))},Zg=Jg,Qg=e=>{const[t,n]=j(e,["contextId"]),r=C(()=>oa(t.contextId));return y(Og,L({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))},ep=Qg,tp=D('<div class="mx-auto mt-4 h-2 w-[100px] rounded-full bg-muted">');const np=Xg,rp=Vg,op=Pg,ip=e=>{const[,t]=j(e,["class"]),n=jg();return y(ep,L({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))},sp=e=>{const[,t]=j(e,["class","children"]);return y(op,{get mount(){return Jt()},get children(){return[y(ip,{}),y(Zg,L({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[tp(),C(()=>e.children)]}}))]}})};var ap=D('<span class="font-semibold mt-2">'),lp=D('<div class="flex py-4 pl-3 pr-1 flex-col w-full space-y-4 overflow-y-auto">'),cp=D('<div class="flex flex-col space-y-2"><div>'),up=D('<div class="flex flex-col w-full space-y-1"><span class="font-semibold text-slate-700">'),dp=D('<div class="flex flex-col items-start"><span class=text-slate-500>');const fp=({options:e,text:t,title:n})=>{const{pushMessage:r}=et(),[o,i]=O(!1),[s,a]=O(!1),[l,c]=O(),d=(f,g)=>{a(!1),i(!0),r(f,g)},u=f=>{const g=f.composedPath();for(const h of g)if(h.id==="smarttalks-list-content"){f.preventDefault();return}};return(()=>{var f=cp(),g=f.firstChild;return A(f,y(_t,{get children(){return t?.trim()}}),g),A(g,y(np,{get open(){return s()},onOpenChange:a,onOutsidePointer:u,get children(){return[y(rp,{as:Ee,variant:"outline",class:"w-full text-nowrap",get children(){return n?.trim()??ft("selectOption")}}),y(sp,{class:"pb-2 px-2 flex flex-col items-center justify-center",get children(){return[(()=>{var h=ap();return A(h,()=>n?.trim()??ft("selectOption")),h})(),(()=>{var h=lp();return A(h,y(pt,{each:e,children:p=>(()=>{var m=up(),b=m.firstChild;return A(b,()=>p.label?.trim()??""),A(m,y(pt,{get each(){return p.items},children:w=>y(Ee,{variant:"outline",get disabled(){return o()},get class(){return`py-6 flex justify-between hover:bg-slate-200 ${l()===w?"bg-slate-200":""}`},onClick:()=>c(w),get children(){return[(()=>{var v=dp(),x=v.firstChild;return A(v,()=>w.label?.trim(),x),A(x,()=>w.description?.trim()),v})(),y(Z,{get when(){return l()===w},get fallback(){return y(uf,{class:"size-4 text-slate-500"})},get children(){return y(cf,{class:"size-4 text-slate-500"})}})]}})}),null),m})()})),h})(),y(Ee,{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 ft("send")}})]}})]}})),oe(()=>nt(g,o()?"opacity-50":"")),f})()};var hp=D("<audio controls preload=auto class=h-8><source type=audio/mpeg><source type=audio/ogg>Your browser does not support the audio element.");const gp=e=>(()=>{var t=hp(),n=t.firstChild,r=n.nextSibling;return oe(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 pp=D('<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 mp=e=>(()=>{var t=pp(),n=t.firstChild,r=n.firstChild;return A(n,y(df,{class:"size-10"}),r),A(r,()=>e.filename?.trim()),A(t,y(_t,{get children(){return e.text?.trim()}}),null),oe(()=>ue(n,"href",e.link)),t})();var yp=D('<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 bp=e=>(()=>{var t=yp(),n=t.firstChild,r=n.firstChild;return A(t,y(_t,{get children(){return e.text?.trim()}}),null),oe(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 wp=D('<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 vp=e=>(()=>{var t=wp(),n=t.firstChild,r=n.firstChild,o=r.nextSibling;return A(t,y(_t,{get children(){return e.text?.trim()}}),null),oe(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 xp=D("<div>Media type not supported");const aa=e=>e.type==="image"?y(bp,e):e.type==="audio"?y(gp,e):e.type==="document"?y(mp,e):e.type==="video"?y(vp,e):xp(),lo=({text:e})=>y(_t,{get children(){return e?.trim()}});var Sp=D("<div>Unknown bot message type");const kp=e=>y(Th,{get createdAt(){return e.createdAt},get children(){return e.type==="text"?y(lo,{get text(){return e.text}}):e.type==="buttons"?y(Dh,L(()=>e.buttons)):e.type==="list"?y(fp,L(()=>e.list)):e.type==="media"?y(aa,L(()=>e.media)):e.type==="link"?y(Nh,L(()=>e.link)):e.type==="cards"?y(Fh,L(()=>e.cards)):e.type==="date"?y(lo,{get text(){return e.text}}):Sp()}});var Ep=D('<div class="place-self-center p-4"><span class="bg-slate-200/40 text-black font-semibold py-2 px-4 rounded-xl">');const Cp=e=>(()=>{var t=Ep(),n=t.firstChild;return A(n,()=>e.text?.trim()),t})();var Op=D('<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 _p=({children:e,createdAt:t})=>(()=>{var n=Op(),r=n.firstChild;return A(r,e),A(n,y(qs,{createdAt:t,anchor:"end"}),null),n})();var Pp=D("<div>Unknown user message type");const Ap=e=>y(_p,{get createdAt(){return e.createdAt},get children(){return e.type==="text"?y(lo,{get text(){return e.text}}):e.type==="media"?y(aa,L(()=>e.media)):Pp()}});var Tp=D("<div>Unknown message origin");const Lp=e=>e.origin==="bot"?y(kp,e):e.origin==="user"?y(Ap,e):e.origin==="service"?y(Cp,e):Tp();function co(e){return we({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 Mp=D('<main touch-action-pan-y class="flex-1 w-full p-4 overflow-y-auto flex flex-col items-center scroll-smooth relative min-h-0 overscroll-contain pb-2">'),Dp=D("<div>");const uo=()=>{let e;const{getMessages:t,onMessage:n,clearMessages:r,addBalloonMessage:o}=et(),{onOpen:i}=Jo(),s=(a=100)=>{setTimeout(()=>{e?.scrollTo(0,e.scrollHeight)},a)};return ne("reset",()=>{r()}),ht(()=>{o(),s(200)}),n(s),i(()=>s(200)),(()=>{var a=Mp(),l=e;return typeof l=="function"?or(l,a):e=a,A(a,y(pt,{get each(){return t()},get fallback(){return(()=>{var c=Dp();return A(c,()=>ft("emptyMessages")),c})()},children:c=>y(Lp,c)})),a})()};var Ip=D("<textarea>");const Rp=e=>{const[,t]=j(e,["class"]);return(()=>{var n=Ip();return rt(n,L({get class(){return Ge("flex w-full rounded-md border border-input bg-transparent px-3 py-2 text-base md: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=D('<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 $p=e=>(()=>{var t=Fp();return rt(t,e,!0,!0),t})();var Np=D('<div class="absolute flex items-center justify-center left-1/2 transform -translate-x-1/2 bottom-[-12px]"><span class="font-semibold text-xs text-gray-600 ml-1">SmartTalks.ai');const Kp=()=>(()=>{var e=Np(),t=e.firstChild;return A(e,y($p,{height:15}),t),e})();var zp=D('<footer class="relative flex-none bg-white border-t border-gray-100 z-20 w-full"><div class="flex flex-col p-3 gap-2 pb-[max(1rem,env(safe-area-inset-bottom))] w-full box-border"><div class="flex items-end gap-2 w-full"></div><div class="flex justify-center opacity-70 scale-95">');const fo=()=>{const{pushMessage:e}=et(),[t,n]=O(""),r=()=>{t().trim()&&(e(t()),n(""))},o=i=>{i.key==="Enter"&&!i.shiftKey&&(i.preventDefault(),r())};return ne("setInput",i=>{i&&n(i)}),(()=>{var i=zp(),s=i.firstChild,a=s.firstChild,l=a.nextSibling;return A(a,y(Rp,{id:"chat-input",get placeholder(){return ft("inputPlaceholder")},get value(){return t()},onInput:c=>n(c.currentTarget.value),onKeyDown:o,class:"focus-visible:ring-primary min-h-[44px] max-h-[120px] py-3 leading-tight resize-none"}),null),A(a,y(Ee,{variant:"outline",class:"h-[44px] w-[44px] p-0 shrink-0 flex items-center justify-center","aria-label":"Send",type:"button",onClick:r,get children(){return y(mc,{size:20})}}),null),A(l,y(Kp,{})),i})()};var Bp=D('<div id=smarttalks-widget class="rounded-md shadow-xl h-[85vh] w-[90vw] md:h-[min(100vh,500px)] md:w-[min(100vw,425px)] overflow-hidden bg-background text-foreground flex flex-col relative">'),Vp=D("<span class=sr-only>Close"),Up=D('<div><div class="flex justify-center gap-3 items-center">'),jp=D("<span class=sr-only>Open"),qp=D("<span class=font-bold>"),Hp=D("<span>"),Wp=D('<div class="animate-pulse flex p-1">');const Gp=({children:e,openIcon:t})=>{const{bubble:n,toggle:r,show:o,hide:i}=Jo(),{chatWidget:s}=ie(),[a,l]=O(!0),[c,d]=O("");setTimeout(()=>l(!1),2e3),s()?.openDelay&&setTimeout(()=>{o()},(s()?.openDelay||0)*1e3);const u=()=>(s()?.style.margin??5)/4,f=()=>s()?.style.position==="left"?{left:`${u()}rem`}:{right:`${u()}rem`};return ne("open",()=>{o()}),ne("close",()=>{i()}),ne("toggle",()=>{r()}),ne("onAnswer",g=>{g.text&&d(g.text),o()}),(()=>{var g=Up(),h=g.firstChild;return A(g,y(Z,{get when(){return n()},get children(){var p=Bp();return A(p,e),p}}),h),A(h,y(Z,{get when(){return s()?.whatsappBtn},get children(){return y(Ee,{onclick:()=>window.open(s()?.whatsappBtn,"_blank"),"aria-label":"Open",class:"bg-green-500 rounded-full size-14 shadow-md hover:bg-green-400 animate-scale",type:"button",get children(){return y(Ch,{class:"size-9",color:"white"})}})}}),null),A(h,y(Z,{get when(){return n()},get fallback(){return y(Ee,{onclick:r,class:"rounded-full px-0 animate-scale","aria-label":"Open",type:"button",get children(){return[t,jp(),y(Z,{get when(){return s()?.balloonMessage},get children(){var p=Hp();return A(p,y(Z,{get when(){return c()},get fallback(){return y(Z,{get when(){return!a()},get fallback(){return(()=>{var m=Wp();return A(m,y(co,{class:"size-2 animate-bounce"}),null),A(m,y(co,{class:"size-2 animate-bounce delay-150"}),null),A(m,y(co,{class:"size-2 animate-bounce delay-300"}),null),m})()},get children(){return C(()=>(s()?.balloonMessage?.length??0)>18)()?s()?.balloonMessage?.substring(0,15)+"...":s()?.balloonMessage}})},get children(){var m=qp();return A(m,(()=>{var b=C(()=>c().length>20);return()=>b()?c().substring(0,17)+"...":c()})()),m}})),oe(()=>nt(p,"absolute -top-12 bg-primary text-primary-foreground px-2.5 py-2 pointer-events-none rounded-full truncate hidden md:block"+(s()?.style.position==="left"?" left-0":" right-0"))),p}})]}})},get children(){return y(Ee,{onclick:r,class:"rounded-full px-0 hover:bg-primary hover:shadow-primary shadow-md transition-shadow duration-300","aria-label":"Close",type:"button",get children(){return[t,Vp()]}})}}),null),oe(p=>{var m="z-[9999] 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"),b=f();return m!==p.e&&nt(g,p.e=m),p.t=an(g,b,p.t),p},{e:void 0,t:void 0}),g})()};var Yp=D('<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}=ie(),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=D("<div id=smarttalks-widget>");const Zp=({children:e})=>{const{chatWidget:t}=ie(),[n,r]=O(!1),[o,i]=O(!1),[s,a]=O("100%"),l=()=>{typeof window<"u"&&i(window.innerWidth<768)},c=()=>{o()&&window.visualViewport&&(a(`${window.visualViewport.height}px`),window.scrollTo(0,0))};T(()=>{typeof document>"u"||(n()&&o()?(document.body.style.overflow="hidden",document.body.style.position="fixed",document.body.style.width="100%"):(document.body.style.overflow="",document.body.style.position="",document.body.style.width=""))}),ht(()=>{l(),window.addEventListener("resize",l),window.visualViewport&&(window.visualViewport.addEventListener("resize",c),window.visualViewport.addEventListener("scroll",c))}),K(()=>{window.removeEventListener("resize",l),window.visualViewport&&(window.visualViewport.removeEventListener("resize",c),window.visualViewport.removeEventListener("scroll",c)),document.body.style.overflow="",document.body.style.position=""});const d=()=>(t()?.style.margin??5)/4,u=()=>{if(o())return{height:s(),top:"0px"};const f={};return t()?.fullscreen?(f.height="100%",f["max-height"]="100%",f.width="100%",f["max-width"]="100%",f.bottom=0,f.left=0):t()?.style.position&&(f[t()?.style.position||"right"]=`${d()}rem`),f};return ne("open",()=>{r(!0),ee("onOpen"),o()&&window.visualViewport&&a(`${window.visualViewport.height}px`)}),ne("close",()=>{r(!1),ee("onClose")}),ne("toggle",()=>{r(!n()),ee("onToggle")}),ne("onAnswer",()=>{r(!0),ee("onOpen")}),setTimeout(()=>{r(!0),ee("onOpen")},(t()?.openDelay||0)*1e3),y(Z,{get when(){return n()},get children(){var f=Jp();return A(f,e),oe(g=>{var h=`
|
|
182
182
|
fixed flex flex-col bg-background text-foreground shadow-xl overflow-hidden z-[99999]
|
|
183
183
|
|
|
184
184
|
${o()?"inset-x-0 top-0 w-full rounded-none m-0":"transition-all duration-300 ease-in-out w-[400px] h-[min(85vh,700px)] md:w-[400px] md:max-h-[90%] md:rounded-xl md:bottom-5"}
|