@tavus/widget 0.1.9 → 0.1.10

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.
@@ -160,10 +160,10 @@ Boolean requesting whether a visible border and background is provided by the ho
160
160
  - omitted: host decides border`)});var VN=Z({method:$(`ui/request-display-mode`),params:Z({mode:EN.describe(`The display mode being requested.`)})});Z({mode:EN.describe(`The display mode that was actually set. May differ from requested if not supported.`)}).passthrough();var HN=Q([$(`model`),$(`app`)]).describe(`Tool visibility scope - who can access the tool.`);Z({resourceUri:J().optional(),visibility:X(HN).optional().describe(`Who can access this tool. Default: ["model", "app"]
161
161
  - "model": Tool visible to and callable by the agent
162
162
  - "app": Tool callable by the app from this server only`),csp:dk().optional(),permissions:dk().optional()}),Z({mimeTypes:X(J()).optional().describe('Array of supported MIME types for UI resources.\nMust include `"text/html;profile=mcp-app"` for MCP Apps support.')});var UN=Z({method:$(`ui/download-file`),params:Z({contents:X(Q([_M,vM])).describe(`Resource contents to download — embedded (inline data) or linked (host fetches). Uses standard MCP resource types.`)})}),WN=Z({method:$(`ui/message`),params:Z({role:$(`user`).describe(`Message role, currently only "user" is supported.`),content:X(yM).describe(`Message content blocks (text, image, etc.).`)})});Z({method:$(`ui/notifications/sandbox-resource-ready`),params:Z({html:J().describe(`HTML content to load into the inner iframe.`),sandbox:J().optional().describe(`Optional override for the inner iframe's sandbox attribute.`),csp:AN.optional().describe(`CSP configuration from resource metadata.`),permissions:jN.optional().describe(`Sandbox permissions from resource metadata.`)})}),Z({method:$(`ui/notifications/tool-result`),params:OM.describe(`Standard MCP tool execution result.`)});var GN=Z({toolInfo:Z({id:JA.optional().describe(`JSON-RPC id of the tools/call request.`),tool:TM.describe(`Tool definition including name, inputSchema, etc.`)}).optional().describe(`Metadata of the tool call that instantiated this App.`),theme:TN.optional().describe(`Current color theme preference.`),styles:PN.optional().describe(`Style configuration for theming the app.`),displayMode:EN.optional().describe(`How the UI is currently displayed.`),availableDisplayModes:X(EN).optional().describe(`Display modes the host supports.`),containerDimensions:Q([Z({height:Y().describe(`Fixed container height in pixels.`)}),Z({maxHeight:Q([Y(),ck()]).optional().describe(`Maximum container height in pixels.`)})]).and(Q([Z({width:Y().describe(`Fixed container width in pixels.`)}),Z({maxWidth:Q([Y(),ck()]).optional().describe(`Maximum container width in pixels.`)})])).optional().describe(`Container dimensions. Represents the dimensions of the iframe or other
163
- container holding the app. Specify either width or maxWidth, and either height or maxHeight.`),locale:J().optional().describe(`User's language and region preference in BCP 47 format.`),timeZone:J().optional().describe(`User's timezone in IANA format.`),userAgent:J().optional().describe(`Host application identifier.`),platform:Q([$(`web`),$(`desktop`),$(`mobile`)]).optional().describe(`Platform type for responsive design decisions.`),deviceCapabilities:Z({touch:sk().optional().describe(`Whether the device supports touch input.`),hover:sk().optional().describe(`Whether the device supports hover interactions.`)}).optional().describe(`Device input capabilities.`),safeAreaInsets:Z({top:Y().describe(`Top safe area inset in pixels.`),right:Y().describe(`Right safe area inset in pixels.`),bottom:Y().describe(`Bottom safe area inset in pixels.`),left:Y().describe(`Left safe area inset in pixels.`)}).optional().describe(`Mobile safe area boundaries in pixels.`)}).passthrough();Z({method:$(`ui/notifications/host-context-changed`),params:GN.describe(`Partial context update containing only changed fields.`)});var KN=Z({method:$(`ui/update-model-context`),params:Z({content:X(yM).optional().describe(`Context content blocks (text, image, etc.).`),structuredContent:hk(J(),uk().describe(`Structured content for machine-readable context data.`)).optional().describe(`Structured content for machine-readable context data.`)})}),qN=Z({method:$(`ui/initialize`),params:Z({appInfo:lj.describe(`App identification (name and version).`),appCapabilities:zN.describe(`Features and capabilities this app provides.`),protocolVersion:J().describe(`Protocol version this app supports.`)})});Z({protocolVersion:J().describe(`Negotiated protocol version string (e.g., "2025-11-21").`),hostInfo:lj.describe(`Host application identification and version.`),hostCapabilities:RN.describe(`Features and capabilities provided by the host.`),hostContext:GN.describe(`Rich context about the host environment.`)}).passthrough();var JN=[wN],YN=class extends CN{_client;_hostInfo;_capabilities;_appCapabilities;_hostContext={};_appInfo;_initializedReceived=!1;_baseReplaceRequestHandler=this.replaceRequestHandler;replaceRequestHandler=(e,t)=>{this._baseReplaceRequestHandler(e,(e,n)=>(this._initializedReceived||console.warn(`[ext-apps] AppBridge received '${e.method}' before ui/notifications/initialized. The View is calling host methods before completing the handshake; it should await app.connect() first.`),t(e,n)))};eventSchemas={sizechange:MN,sandboxready:kN,initialized:BN,requestteardown:LN,loggingmessage:IM};constructor(e,t,n,r){super(r),this._client=e,this._hostInfo=t,this._capabilities=n,this.addEventListener(`initialized`,()=>{this._initializedReceived=!0}),this._hostContext=r?.hostContext||{},this.setRequestHandler(qN,e=>this._oninitialize(e)),this.setRequestHandler(yj,(e,t)=>(this.onping?.(e.params,t),{})),this.replaceRequestHandler(VN,e=>({mode:this._hostContext.displayMode??`inline`}))}getAppCapabilities(){return this._appCapabilities}getAppVersion(){return this._appInfo}onping;get onsizechange(){return this.getEventHandler(`sizechange`)}set onsizechange(e){this.setEventHandler(`sizechange`,e)}get onsandboxready(){return this.getEventHandler(`sandboxready`)}set onsandboxready(e){this.setEventHandler(`sandboxready`,e)}get oninitialized(){return this.getEventHandler(`initialized`)}set oninitialized(e){this.setEventHandler(`initialized`,e)}_onmessage;get onmessage(){return this._onmessage}set onmessage(e){this.warnIfRequestHandlerReplaced(`onmessage`,this._onmessage,e),this._onmessage=e,this.replaceRequestHandler(WN,async(e,t)=>{if(!this._onmessage)throw Error(`No onmessage handler set`);return this._onmessage(e.params,t)})}_onopenlink;get onopenlink(){return this._onopenlink}set onopenlink(e){this.warnIfRequestHandlerReplaced(`onopenlink`,this._onopenlink,e),this._onopenlink=e,this.replaceRequestHandler(ON,async(e,t)=>{if(!this._onopenlink)throw Error(`No onopenlink handler set`);return this._onopenlink(e.params,t)})}_ondownloadfile;get ondownloadfile(){return this._ondownloadfile}set ondownloadfile(e){this.warnIfRequestHandlerReplaced(`ondownloadfile`,this._ondownloadfile,e),this._ondownloadfile=e,this.replaceRequestHandler(UN,async(e,t)=>{if(!this._ondownloadfile)throw Error(`No ondownloadfile handler set`);return this._ondownloadfile(e.params,t)})}get onrequestteardown(){return this.getEventHandler(`requestteardown`)}set onrequestteardown(e){this.setEventHandler(`requestteardown`,e)}_onrequestdisplaymode;get onrequestdisplaymode(){return this._onrequestdisplaymode}set onrequestdisplaymode(e){this.warnIfRequestHandlerReplaced(`onrequestdisplaymode`,this._onrequestdisplaymode,e),this._onrequestdisplaymode=e,this.replaceRequestHandler(VN,async(e,t)=>{if(!this._onrequestdisplaymode)throw Error(`No onrequestdisplaymode handler set`);return this._onrequestdisplaymode(e.params,t)})}get onloggingmessage(){return this.getEventHandler(`loggingmessage`)}set onloggingmessage(e){this.setEventHandler(`loggingmessage`,e)}_onupdatemodelcontext;get onupdatemodelcontext(){return this._onupdatemodelcontext}set onupdatemodelcontext(e){this.warnIfRequestHandlerReplaced(`onupdatemodelcontext`,this._onupdatemodelcontext,e),this._onupdatemodelcontext=e,this.replaceRequestHandler(KN,async(e,t)=>{if(!this._onupdatemodelcontext)throw Error(`No onupdatemodelcontext handler set`);return this._onupdatemodelcontext(e.params,t)})}_oncalltool;get oncalltool(){return this._oncalltool}set oncalltool(e){this.warnIfRequestHandlerReplaced(`oncalltool`,this._oncalltool,e),this._oncalltool=e,this.replaceRequestHandler(AM,async(e,t)=>{if(!this._oncalltool)throw Error(`No oncalltool handler set`);return this._oncalltool(e.params,t)})}set oncreatesamplingmessage(e){this.setRequestHandler(WM,async(t,n)=>e(t.params,n))}sendToolListChanged(e={}){return this.notification({method:`notifications/tools/list_changed`,params:e})}_onlistresources;get onlistresources(){return this._onlistresources}set onlistresources(e){this.warnIfRequestHandlerReplaced(`onlistresources`,this._onlistresources,e),this._onlistresources=e,this.replaceRequestHandler(Kj,async(e,t)=>{if(!this._onlistresources)throw Error(`No onlistresources handler set`);return this._onlistresources(e.params,t)})}_onlistresourcetemplates;get onlistresourcetemplates(){return this._onlistresourcetemplates}set onlistresourcetemplates(e){this.warnIfRequestHandlerReplaced(`onlistresourcetemplates`,this._onlistresourcetemplates,e),this._onlistresourcetemplates=e,this.replaceRequestHandler(Jj,async(e,t)=>{if(!this._onlistresourcetemplates)throw Error(`No onlistresourcetemplates handler set`);return this._onlistresourcetemplates(e.params,t)})}_onreadresource;get onreadresource(){return this._onreadresource}set onreadresource(e){this.warnIfRequestHandlerReplaced(`onreadresource`,this._onreadresource,e),this._onreadresource=e,this.replaceRequestHandler(Qj,async(e,t)=>{if(!this._onreadresource)throw Error(`No onreadresource handler set`);return this._onreadresource(e.params,t)})}sendResourceListChanged(e={}){return this.notification({method:`notifications/resources/list_changed`,params:e})}_onlistprompts;get onlistprompts(){return this._onlistprompts}set onlistprompts(e){this.warnIfRequestHandlerReplaced(`onlistprompts`,this._onlistprompts,e),this._onlistprompts=e,this.replaceRequestHandler(lM,async(e,t)=>{if(!this._onlistprompts)throw Error(`No onlistprompts handler set`);return this._onlistprompts(e.params,t)})}sendPromptListChanged(e={}){return this.notification({method:`notifications/prompts/list_changed`,params:e})}assertCapabilityForMethod(e){}assertRequestHandlerCapability(e){}assertNotificationCapability(e){}assertTaskCapability(e){throw Error(`Tasks are not supported in MCP Apps`)}assertTaskHandlerCapability(e){throw Error(`Task handlers are not supported in MCP Apps`)}getCapabilities(){return this._capabilities}async _oninitialize(e){let t=e.params.protocolVersion;return this._appInfo!==void 0&&console.warn(`[ext-apps] AppBridge received a second ui/initialize. The View may be double-mounting (e.g. React StrictMode in dev) without closing the previous App instance. Responding normally; the latest appInfo/appCapabilities replace the previous values.`),this._appCapabilities=e.params.appCapabilities,this._appInfo=e.params.appInfo,{protocolVersion:JN.includes(t)?t:wN,hostCapabilities:this.getCapabilities(),hostInfo:this._hostInfo,hostContext:this._hostContext}}setHostContext(e){let t={},n=!1;for(let r of Object.keys(e)){let i=this._hostContext[r],a=e[r];XN(i,a)||(t[r]=a,n=!0)}n&&(this._hostContext=e,this.sendHostContextChange(t))}sendHostContextChange(e){return this.notification({method:`ui/notifications/host-context-changed`,params:e})}sendToolInput(e){return this.notification({method:`ui/notifications/tool-input`,params:e})}sendToolInputPartial(e){return this.notification({method:`ui/notifications/tool-input-partial`,params:e})}sendToolResult(e){return this.notification({method:`ui/notifications/tool-result`,params:e})}sendToolCancelled(e){return this.notification({method:`ui/notifications/tool-cancelled`,params:e})}sendSandboxResourceReady(e){return this.notification({method:`ui/notifications/sandbox-resource-ready`,params:e})}teardownResource(e,t){return this.request({method:`ui/resource-teardown`,params:e},FN,t)}sendResourceTeardown=this.teardownResource;callTool(e,t){return this.request({method:`tools/call`,params:e},OM,t)}listTools(e,t){return this.request({method:`tools/list`,params:e},DM,t)}async connect(e){if(this.transport)throw Error(`AppBridge is already connected. Call close() before connecting again.`);if(this._initializedReceived=!1,this._client){let e=this._client.getServerCapabilities();if(!e)throw Error(`Client server capabilities not available`);e.tools&&(this.oncalltool=async(e,t)=>this._client.request({method:`tools/call`,params:e},OM,{signal:t.signal}),e.tools.listChanged&&this._client.setNotificationHandler(jM,e=>this.sendToolListChanged(e.params))),e.resources&&(this.onlistresources=async(e,t)=>this._client.request({method:`resources/list`,params:e},qj,{signal:t.signal}),this.onlistresourcetemplates=async(e,t)=>this._client.request({method:`resources/templates/list`,params:e},Yj,{signal:t.signal}),this.onreadresource=async(e,t)=>this._client.request({method:`resources/read`,params:e},$j,{signal:t.signal}),e.resources.listChanged&&this._client.setNotificationHandler(eM,e=>this.sendResourceListChanged(e.params))),e.prompts&&(this.onlistprompts=async(e,t)=>this._client.request({method:`prompts/list`,params:e},uM,{signal:t.signal}),e.prompts.listChanged&&this._client.setNotificationHandler(SM,e=>this.sendPromptListChanged(e.params)))}return super.connect(e)}};function XN(e,t){return JSON.stringify(e)===JSON.stringify(t)}function ZN(){let e=mt(Cv);if(!e)throw Error(`useTheme must be used within ThemeProvider`);return e}function QN({state:e}){return e.enabled?k(`details`,{class:`pointer-events-auto w-full max-w-md rounded-lg border border-base-300 bg-base-100/95 p-2 text-xs shadow-lg backdrop-blur`,children:[k(`summary`,{class:`cursor-pointer font-medium`,children:`Magic Canvas debug`}),k(`dl`,{class:`mt-2 grid gap-2`,children:[k($N,{label:`iframe`,value:e.iframeLifecycleState}),k($N,{label:`post`,value:e.lastInteractionPostResult}),k($N,{label:`context`,value:e.lastModelContextUpdate}),k($N,{label:`error`,value:e.lastError}),k(eP,{label:`tool_call`,value:e.lastToolCall}),k(eP,{label:`canvas_config`,value:e.parsedCanvasConfig})]})]}):null}function $N({label:e,value:t}){return t?k(`div`,{children:[k(`dt`,{class:`font-semibold`,children:e}),k(`dd`,{class:`break-words text-base-content/70`,children:t})]}):null}function eP({label:e,value:t}){return t===void 0?null:k(`div`,{children:[k(`dt`,{class:`font-semibold`,children:e}),k(`dd`,{children:k(`pre`,{class:`max-h-40 overflow-auto rounded bg-base-200 p-2 text-[10px] leading-relaxed`,children:JSON.stringify(t,null,2)})})]})}var tP=1e3,nP=5e3,rP=1200,iP=48,aP=`allow-scripts`,oP={"canvas.scheduling_embed":`allow-scripts allow-same-origin allow-popups allow-forms`};function sP(e,t){if(!t.contentWindow||e.source!==t.contentWindow)return!1;let n=e.data;return!!n&&typeof n==`object`&&n?.jsonrpc===`2.0`}var cP=class{onmessage;onerror;onclose;#e;#t;constructor(e){this.#e=e}start(){let e=e=>{sP(e,this.#e)&&this.onmessage?.(e.data)};return this.#t=e,globalThis.addEventListener(`message`,e),Promise.resolve()}send(e){return this.#e.contentWindow?.postMessage(e,`*`),Promise.resolve()}close(){return this.#t&&globalThis.removeEventListener(`message`,this.#t),this.#t=void 0,this.onclose?.(),Promise.resolve()}};function lP(e){for(let t of jx)if(e.some(e=>wP(e)===t))return t;return null}function uP({onLayoutEffectChange:e,onRenderedSlotChange:t,debugEnabled:n=TP()}={}){let{client:r}=ev(),{dataTheme:i,cssVars:a}=ZN(),o=ph(),s=Bg(),[c,l]=w([]),[u,d]=yP(),[f,p]=w(()=>({enabled:n,iframeLifecycleState:`idle`})),m=O(e=>{p(t=>({...t,...e}))},[]),h=O((e,t=`*`)=>{if(s!==`joined-meeting`){m({lastError:`Dropped Magic Canvas app message because the Daily meeting is not joined.`});return}o?.sendAppMessage(e,t)},[o,s,m]),g=D(()=>({theme:i.value===`dark`?`dark`:`light`,cssVars:a.value}),[i.value,a.value]);T(()=>{p(e=>e.enabled===n?e:{...e,enabled:n})},[n]),Qg({onAppMessage:O(e=>{if(s!==`joined-meeting`){m({lastToolCall:e.data,iframeLifecycleState:`idle`,lastError:`Dropped Magic Canvas tool call because the Daily meeting is not joined.`});return}try{let t=wS(e.data);if(!t)return;l(e=>Ux(e,t)),m({lastToolCall:e.data,parsedCanvasConfig:t.kind===`show`?t.instance.canvas_config:void 0,iframeLifecycleState:t.kind===`clear`?`closed`:`received`,lastError:void 0})}catch(e){m({iframeLifecycleState:`error`,lastError:OP(e).message})}},[s,m])});let _=c.map(e=>({instance:e,layout:Xx(e,d)})),v=Zx(_.map(({layout:e})=>e),d),y=[..._].reverse().find(({layout:e})=>e.display_mode===`fullscreen`)?.instance.tool_call_id;T(()=>{e?.(v)},[e,v.active,v.side,v.video_shift_x,v.backdrop.type,v.safe_area?.x,v.safe_area?.y,v.safe_area?.width,v.safe_area?.height]);let b=lP(_.map(({layout:e})=>e));T(()=>{t?.(b)},[t,b]);let x=c.length>0||f.enabled;return k(`div`,{ref:u,"data-magic-canvas-root":!0,class:`pointer-events-none absolute inset-0 z-30`,children:[x&&y&&k(`div`,{class:`absolute inset-0 bg-black/45`}),x&&jx.map(e=>{let t=_.filter(({layout:t})=>wP(t)===e);return t.length===0?null:k(fP,{slot:e,safeAreaTop:v.safe_area?.y,frameWidth:d.width,children:e=>t.map(({instance:t,layout:n})=>k(pP,{availableHeight:e,client:r,hostTheme:g,instance:t,layout:n,dimmed:!!(y&&y!==t.tool_call_id),onDebug:m,onComplete:()=>{l(e=>e.filter(e=>e.id!==t.id))},onDisplayModeChange:e=>{l(n=>n.map(n=>n.tool_call_id===t.tool_call_id?{...n,layout:{...n.layout,display_mode:e}}:n))},sendAppMessage:h},t.id))},e)}),x&&k(`div`,{class:`absolute right-4 bottom-24 @max-mobile:right-3 @max-mobile:bottom-20`,children:k(QN,{state:f})})]})}var dP=16;function fP({slot:e,safeAreaTop:t,frameWidth:n,children:r}){let[i,a]=bP(),o=r(e===`full`?void 0:a);if(e===`safe-area-left`||e===`safe-area-right`){let r=t==null?`1rem`:`${t*100}%`,a=n!=null&&n>0?Math.max(0,n-dP*2):void 0;return k(`div`,{ref:i,class:CP(e),style:{top:r,bottom:`${SP}px`,maxWidth:a},"data-canvas-slot":e,children:k(`div`,{class:`my-auto flex w-full flex-col gap-2`,children:o})})}return k(`div`,{ref:i,class:CP(e),"data-canvas-slot":e,children:o})}function pP({availableHeight:e,client:t,hostTheme:n,instance:r,layout:i,dimmed:a,onDebug:o,onComplete:s,onDisplayModeChange:c,sendAppMessage:l}){let u=E(null),d=E(null),f=E(e),p=E(320),m=E(n),h=E(r),g=E(i),_=E(-1),v=E(s),y=E(c),b=E(l),[x,S]=w(320);T(()=>{h.current=r},[r]),T(()=>{p.current=x,d.current?.setHostContext(_P(h.current,m.current,g.current,f.current,x))},[x]),T(()=>{f.current=e;let t=gP(n,u.current);m.current=t,d.current?.setHostContext(_P(h.current,t,g.current,e,p.current))},[e,n]),T(()=>{g.current=i,d.current?.setHostContext(_P(h.current,m.current,i,e,p.current))},[e,i]),T(()=>{v.current=s,y.current=c,b.current=l},[s,c,l]),T(()=>{let e=u.current;if(!e)return;let n=!1,i=null,a=null,s=null,c=null,l=new URL(r.canvas_config.sandbox_url,globalThis.location.href).href,x=e=>{n||o({iframeLifecycleState:`error`,lastError:OP(e).message})},C=()=>{if(n||!a)return;let e=h.current,t=Jx(e,a);a=null,b.current({message_type:`conversation`,event_type:`conversation.append_llm_context`,conversation_id:e.conversation_id,properties:{context:t}}),o({lastModelContextUpdate:e.canvas_config.component,lastError:void 0})},ee=()=>{if(i)return;if(e.src!==l){e.src;return}if(n||!e.contentWindow)return;let u=new YN(null,{name:`tavus-deployment`,version:`0.0.0`},{logging:{},message:{text:{},structuredContent:{}},updateModelContext:{text:{},structuredContent:{}}},{hostContext:_P(r,gP(m.current,e),g.current,f.current,p.current)});i=u,d.current=u,u.oninitialized=()=>{n||(o({iframeLifecycleState:`ready`}),_.current=h.current.revision,u.sendToolInput({arguments:h.current.arguments}).catch(x))},u.onsizechange=({height:e})=>{!n&&typeof e==`number`&&Number.isFinite(e)&&S(Math.min(Math.max(e,iP),720))},u.onmessage=async e=>{let r=Wx(e),i=qx(e);if(!r){if(i){let e=`Magic Canvas message included text without interaction metadata; no interaction row was recorded.`;return o({lastInteractionPostResult:`error`,lastError:e}),{isError:!0,code:`missing_interaction_metadata`,message:e}}return{}}try{let e=h.current,a=Gx(e,r),s=TS(a),l=new AbortController,u=globalThis.setTimeout(()=>l.abort(),nP);try{await Dn(t,a.conversation_id,s.body,{signal:l.signal})}finally{globalThis.clearTimeout(u)}if(n)return{};i&&b.current({message_type:`conversation`,event_type:`conversation.respond`,conversation_id:e.conversation_id,properties:{text:i}}),o({lastInteractionPostResult:`success`,lastError:void 0}),Kx(a)&&(a.type===`submit`?(c&&clearTimeout(c),c=setTimeout(()=>{c=null,n||v.current()},rP)):v.current())}catch(e){let t=OP(e).message;return o({lastInteractionPostResult:`error`,lastError:t}),{isError:!0,code:`interaction_post_failed`,message:t}}return{}},u.onupdatemodelcontext=async e=>(a=e,s||=setTimeout(()=>{s=null,C()},tP),{}),u.onrequestdisplaymode=async({mode:e})=>{let t=e===`fullscreen`?`fullscreen`:`inline`;return y.current(t),g.current={...g.current,display_mode:t,viable_slot:t===`fullscreen`?`full`:g.current.viable_slot},u.setHostContext(_P(h.current,m.current,g.current,f.current,p.current)),{mode:t}},u.connect(new cP(e)).then(()=>void 0).catch(x)};o({iframeLifecycleState:`mounting`,lastInteractionPostResult:void 0}),r.canvas_config.sandbox_url,e.src=r.canvas_config.sandbox_url;let te=()=>{ee()};return e.addEventListener(`load`,te),ee(),()=>{s&&=(clearTimeout(s),null),c&&=(clearTimeout(c),null),C(),n=!0,e.removeEventListener(`load`,te),d.current=null,o({iframeLifecycleState:`closed`}),i&&kx(i)}},[t,r.id,r.canvas_config.sandbox_url,o]),T(()=>{r.revision!==0&&(r.revision<=_.current||(_.current=r.revision,d.current?.sendToolInput({arguments:r.arguments}).catch(e=>{o({iframeLifecycleState:`error`,lastError:OP(e).message})})))},[r.arguments,r.revision,o]);let C=i.viable_slot===`full`||i.display_mode===`fullscreen`,ee=C?null:vP(x,e),te=ee?.placeholderStyle,ne=ee?.cardStyle,re=C?{height:`100%`}:ee?.iframeStyle??{height:`${x}px`},ie=[`pointer-events-auto w-full overflow-hidden rounded-lg border border-base-300 bg-base-100 shadow-xl transition-[opacity,transform]`,C?`fixed inset-4 z-10 max-w-none`:`max-w-md`,a?`scale-[0.98] opacity-40`:``].filter(Boolean).join(` `),ae=oP[r.canvas_config.component]??aP,oe=k(`div`,{class:ie,style:ne,"data-canvas-card":i.viable_slot,children:k(`iframe`,{ref:u,title:`${r.canvas_config.component} ${r.canvas_config.component_version}`,class:C?`block h-full w-full border-0 bg-transparent`:`block border-0 bg-transparent`,sandbox:ae,style:re})});return C?oe:k(`div`,{class:`block w-full`,style:te,children:oe})}var mP=[`--color-base-100`,`--color-base-200`,`--color-base-300`,`--color-base-content`,`--color-primary`,`--color-error`];function hP(e){if(!e||typeof getComputedStyle!=`function`)return{};let t=getComputedStyle(e),n={};for(let e of mP){let r=t.getPropertyValue(e).trim();r&&(n[e]=r)}return n}function gP(e,t){let n=hP(t);return Object.keys(n).length===0?e:{...e,cssVars:{...e.cssVars,...n}}}function _P(e,t,n,r,i){let a=ES(t,n),o=n.viable_slot===`full`||n.display_mode===`fullscreen`,s=o?void 0:EP(r),c=o?1:vP(i??0,r)?.displayScale??1;return{...e.canvas_config.host_context,...a,containerDimensions:{...DP(a.containerDimensions)?a.containerDimensions:{},...s===void 0?{}:{maxHeight:s},displayScale:c}}}function vP(e,t){if(t===void 0||!Number.isFinite(t)||t<=0)return null;let n=Math.min(e,720);if(n<=t)return{displayScale:1,placeholderStyle:{maxHeight:`${t}px`},cardStyle:void 0,iframeStyle:{width:`100%`,height:`${n}px`}};let r=t/n;return r>=.85?{displayScale:r,placeholderStyle:{height:`${n*r}px`,maxHeight:`${t}px`,overflow:`hidden`},cardStyle:{height:`${n}px`,transform:`scale(${r})`,transformOrigin:`top center`},iframeStyle:{width:`100%`,height:`${n}px`}}:{displayScale:1,placeholderStyle:{maxHeight:`${t}px`},cardStyle:void 0,iframeStyle:{width:`100%`,height:`${t}px`}}}function yP(){let e=E(null),[t,n]=w(()=>xP(null));return T(()=>{let t=()=>n(t=>{let n=xP(e.current);return t.width===n.width&&t.height===n.height&&t.visualViewportHeight===n.visualViewportHeight?t:n});t(),globalThis.addEventListener(`resize`,t),globalThis.visualViewport?.addEventListener(`resize`,t);let r;return typeof ResizeObserver<`u`&&e.current&&(r=new ResizeObserver(t),r.observe(e.current)),()=>{globalThis.removeEventListener(`resize`,t),globalThis.visualViewport?.removeEventListener(`resize`,t),r?.disconnect()}},[]),[e,t]}function bP(){let e=E(null),[t,n]=w();return T(()=>{let t=e.current;if(!t)return;let r=e=>{let r=e??t.getBoundingClientRect().height;!Number.isFinite(r)||r<=0||n(Math.floor(r))},i=()=>r();if(i(),typeof ResizeObserver>`u`)return globalThis.addEventListener(`resize`,i),()=>globalThis.removeEventListener(`resize`,i);let a=new ResizeObserver(e=>{r(e[0]?.contentRect.height)});return a.observe(t),()=>a.disconnect()},[]),[e,t]}function xP(e){let t=globalThis.visualViewport?.height,n=e?.getBoundingClientRect();if(n&&n.width>0&&n.height>0){let e=t===void 0?void 0:Math.max(0,(globalThis.innerHeight||0)-t);return{width:n.width,height:n.height,visualViewportHeight:e===void 0?void 0:Math.max(0,n.height-e)}}return{width:globalThis.innerWidth||1024,height:globalThis.innerHeight||768,visualViewportHeight:t}}var SP=72;function CP(e){let t=`absolute flex gap-2`;switch(e){case`safe-area-left`:return`${t} left-4 w-[28rem] flex-col overflow-y-auto`;case`safe-area-right`:return`${t} right-4 w-[28rem] flex-col overflow-y-auto`;case`safe-area-bottom`:return`${t} right-4 bottom-24 left-4 flex-col items-center justify-end @max-mobile:right-3 @max-mobile:bottom-20 @max-mobile:left-3`;case`full`:return`${t} inset-4 flex-col items-stretch justify-stretch`}}function wP(e){return e.display_mode===`fullscreen`&&e.preferred_slot!==`full`?e.preferred_slot:e.viable_slot}function TP(){return!1}function EP(e){return e===void 0||!Number.isFinite(e)||e<=0?720:Math.min(Math.floor(e),720)}function DP(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function OP(e){return e instanceof Error?e:Error(String(e))}var kP=1e4;function AP({onTimeout:e,timeoutMs:t=kP,active:n=!0}){let r=mx().length>0,[i,a]=w(!1),o=E(e);return T(()=>{o.current=e},[e]),T(()=>{if(!n||r){a(!1);return}let e=setTimeout(()=>{a(!0),o.current()},t);return()=>clearTimeout(e)},[n,r,t]),{hasJoined:r,timedOut:i}}function jP(e){if(typeof e!=`object`||!e)return!1;let t=e;return t.message_type===`system`&&t.event_type===`system.shutdown`}function MP({onShutdown:e}){let t=E(e);T(()=>{t.current=e},[e]),Qg({onAppMessage:O(e=>{jP(e?.data)&&t.current()},[])})}function NP(){let e=ph();return{joinCall:O(({url:t,micOnly:n=!1})=>{e?.join(n?{url:t,videoSource:!1}:{url:t})},[e]),leaveCall:O(()=>{e?.leave()},[e])}}var PP=bn(`PiP`),FP=360,IP=280;function LP(){return globalThis.window!==void 0&&`documentPictureInPicture`in globalThis.window}function RP(e){let{enabled:t,active:n}=e,[r,i]=w(null),a=LP(),o=mt(Cv),s=O(()=>{i(e=>(e&&!e.closed&&e.close(),null))},[]),c=O(async()=>{if(a&&!(!t||!n)&&!(r&&!r.closed))try{let e=await globalThis.window.documentPictureInPicture.requestWindow({width:FP,height:IP}),t=Xe.replace(/:host(?=[\s,{])/g,`:host, :root`),n=e.document.createElement(`style`);n.textContent=t,e.document.head.appendChild(n),e.document.body.style.margin=`0`,e.document.body.style.width=`100%`,e.document.body.style.height=`100vh`,e.document.body.style.overflow=`hidden`,e.addEventListener(`pagehide`,()=>{i(t=>t===e?null:t)},{once:!0}),i(e)}catch(e){PP.warn(`Failed to open PiP window`,e)}},[a,t,n,r]);return T(()=>{if(!t||!a||!n)return;let e=()=>{document.visibilityState===`hidden`?c():document.visibilityState===`visible`&&s()};document.addEventListener(`visibilitychange`,e);let r=[],i=null,o=`none`,l=!1;if(typeof navigator<`u`&&`mediaSession`in navigator){let e=navigator.mediaSession;i=e.metadata,o=e.playbackState;try{e.metadata=new MediaMetadata({title:`Tavus conversation`}),e.playbackState=`playing`,l=!0}catch(e){PP.warn(`mediaSession metadata setup failed`,e)}let t=(t,n)=>{try{e.setActionHandler(t,n),r.push(t)}catch(e){PP.warn(`mediaSession.${t} not supported`,e)}};t(`enterpictureinpicture`,()=>{c()}),t(`play`,()=>{}),t(`pause`,()=>{})}return()=>{if(document.removeEventListener(`visibilitychange`,e),typeof navigator<`u`&&`mediaSession`in navigator){let e=navigator.mediaSession;for(let t of r)try{e.setActionHandler(t,null)}catch{}if(l)try{e.metadata=i,e.playbackState=o}catch{}}}},[t,a,n,c,s]),T(()=>{(!n||!t)&&r&&!r.closed&&s()},[n,t,r,s]),T(()=>()=>{r&&!r.closed&&r.close()},[r]),T(()=>{if(!r||r.closed||!o)return;let e=()=>{r.document.body.setAttribute(`data-theme`,o.dataTheme.value);let e=o.cssVars.value;for(let[t,n]of Object.entries(e))r.document.body.style.setProperty(t,n)};e();let t=o.dataTheme.subscribe(()=>e()),n=o.cssVars.subscribe(()=>e());return()=>{t(),n()}},[r,o]),{pipWindow:r,isSupported:a,requestPipWindow:c,closePipWindow:s}}var zP=Gt(null),BP={active:!1,video_shift_x:0,backdrop:{type:`snapshot_mirror`}},VP=ya(({id:e,showAudioWave:t=!0})=>{let n=d_(e).isOff;return k(`div`,{class:`relative aspect-square w-32 @max-mobile:w-24 rounded-box overflow-hidden bg-black/30 z-10 ${n?`hidden`:``}`,children:[k(dg,{automirror:!0,sessionId:e,type:`video`,fit:`cover`,className:`w-full h-full object-cover ${n?`hidden`:``}`}),t&&k(`div`,{class:`absolute bottom-2 right-2`,children:k(sx,{id:e})})]})}),HP=ya(()=>{let e=Zh(),{isScreenSharing:t}=hb(),n=mx()[0];return k(de,{children:[t&&n&&k(VP,{id:n}),e&&k(VP,{id:e,showAudioWave:!1})]})}),UP=ya(()=>k(`div`,{class:`absolute top-4 left-4 flex flex-col items-end gap-2 z-20`,children:k(HP,{})})),WP=ya(({isAudioOnly:e,canvasLayoutEffect:t,canvasRenderedSlot:n})=>{let r=Zh(),i=!l_(r??``).isOff,a=hx(e),o=l_(a.phase===`ready`?a.replicaId:``),s=!i&&(o.state===`playable`||o.state===`loading`),c=t.active&&!i&&(!e||s);return a.phase===`left`?k(ax,{}):a.phase===`connecting`?k(ix,{}):e&&!s?k(`div`,{class:`absolute inset-0 flex items-center justify-center`,children:[k(dx,{sessionId:a.replicaId}),k(lg,{sessionId:a.replicaId})]}):k(de,{children:[s?k(aC,{personaSessionId:a.replicaId,isAudioOnly:e,avatarOff:a.videoState.isOff,canvasLayoutEffect:t,smartSidecarActive:c}):k(GP,{personaSessionId:a.replicaId,localId:r,isScreenSharing:i,avatarOff:a.videoState.isOff,smartSidecarActive:c,canvasLayoutEffect:t,canvasRenderedSlot:n}),k(lg,{sessionId:a.replicaId})]})}),GP=ya(({personaSessionId:e,localId:t,isScreenSharing:n,avatarOff:r,smartSidecarActive:i,canvasLayoutEffect:a,canvasRenderedSlot:o})=>k(rC,{canvasLayoutEffect:a,smartSidecarActive:i,isScreenSharing:n,captureSnapshot:YP,personaMode:`auto`,renderedSlot:o,fill:i=>k(yx,{personaSessionId:e,localSessionId:t,isScreenSharing:n,avatarOff:r,videoRef:i})})),KP=ya(({items:e})=>{let[t,n]=w(!1),r=E(null);return T(()=>{if(!t)return;let e=e=>{r.current&&!e.composedPath().includes(r.current)&&n(!1)},i=e=>{e.key===`Escape`&&n(!1)};return document.addEventListener(`pointerdown`,e),document.addEventListener(`keydown`,i),()=>{document.removeEventListener(`pointerdown`,e),document.removeEventListener(`keydown`,i)}},[t]),k(`div`,{ref:r,class:`relative`,children:[k(`button`,{type:`button`,onClick:()=>n(e=>!e),"aria-pressed":t,"aria-expanded":t,"aria-haspopup":`true`,"aria-label":t?`Close more controls`:`More controls`,class:`btn btn-control ${t?`btn-primary`:`btn-neutral`}`,children:k(Vy,{name:`more`})}),t&&k(`div`,{role:`menu`,class:`absolute bottom-full mb-1 left-1/2 -translate-x-1/2 flex flex-row items-center gap-1 p-1 rounded-box bg-base-100 border border-base-300 shadow-lg z-30 whitespace-nowrap`,children:e})]})}),qP=ya(({items:e})=>e.length<=1?k(de,{children:e}):k(KP,{items:e})),JP=ya(({onLeave:e})=>{let{joinCall:t,leaveCall:n}=NP(),r=Bg(),{config:i}=ev(),{session:a,end:o}=Gb(),s=Zh(),c=E(null),l=mt(Nv)?.frameRef??c,[u,d]=w(!1),[f,p]=w(!1),[m,h]=w(BP),[g,_]=w(null),v=a.value?.conversationUrl,y=i.value.customization.conversation,b=y.modality===`audio`,x=y.enable_chat,S=y.enable_closed_captions,C=y.enable_picture_in_picture,{pipWindow:ee}=RP({enabled:C,active:r===`joined-meeting`});T(()=>(v&&t({url:v,micOnly:!s}),()=>{n()}),[]);let{camera:te,requestCamera:ne}=bb(),{isCamMuted:re}=pb(),ie=te.isGranted&&!re;T(()=>{!b&&r===`joined-meeting`&&(zP.value=ie)},[b,r,ie]);let ae=E(!b&&!s&&zP.value===!0);T(()=>{r===`joined-meeting`&&ae.current&&(ae.current=!1,ne())},[r,ne]),T(()=>{(r===`left-meeting`||r===`error`)&&e()},[r,e]),T(()=>{let e=()=>{let e=l.current,t=e?.getRootNode(),n=t instanceof Document||t instanceof ShadowRoot?t:null;d(!!e&&n?.fullscreenElement===e)};return document.addEventListener(`fullscreenchange`,e),()=>document.removeEventListener(`fullscreenchange`,e)},[]);let oe=O(()=>{let e=l.current;if(!e)return;let t=e.getRootNode();(t instanceof Document||t instanceof ShadowRoot?t:null)?.fullscreenElement===e?document.exitFullscreen?.():e.requestFullscreen?.()},[]);O(()=>{p(e=>!e)},[]);let se=O(()=>{o(),n()},[o]);if(AP({active:r===`joined-meeting`,onTimeout:se}),MP({onShutdown:se}),!v)return null;let ce=[k(Wb,{compact:!0},`screen-share`)];x&&ce.push(k(ex,{compact:!0},`chat`));let le=r===`left-meeting`;return k(qb,{children:k(Qb,{children:k(Db,{children:[k(`div`,{class:`cvi-call-surface absolute inset-0`,children:[k(`div`,{class:`relative w-full h-full z-[5]`,children:[k(WP,{isAudioOnly:b,canvasLayoutEffect:m,canvasRenderedSlot:g}),!b&&k(UP,{}),k(Xb,{}),k(uP,{debugEnabled:f,onLayoutEffectChange:h,onRenderedSlotChange:_}),k(`div`,{class:`cvi-autohide absolute top-4 right-4 z-20`,"data-hidden":le,children:k(ox,{active:u,onToggle:oe,compact:!0})})]}),k(nx,{}),k(`div`,{class:`cvi-autohide cvi-autohide-slide pointer-events-none absolute bottom-6 left-0 right-0 z-20`,"data-hidden":le,"aria-hidden":le,children:k(`div`,{class:`cvi-control-rail flex justify-center items-center gap-2 @max-mobile:gap-1`,"data-hidden":le,children:[k(zb,{level:!0}),!b&&k(Vb,{}),S&&k(Yb,{}),k(qP,{items:ce}),k(`button`,{type:`button`,class:`btn btn-control btn-error`,onClick:se,"aria-label":`Leave call`,children:k(Vy,{name:`leave`,"aria-label":`Leave Call`})})]})})]}),ee&&Ia(k(_x,{onLeave:se}),ee.document.body)]})})})});function YP(e){if(!e||e.readyState<2||!e.videoWidth||!e.videoHeight)return null;let t=document.createElement(`canvas`),n=Math.round(640*(e.videoHeight/e.videoWidth));t.width=640,t.height=n;let r=t.getContext(`2d`);if(!r)return null;r.drawImage(e,0,0,640,n);try{return t.toDataURL(`image/jpeg`,.82)}catch{return null}}function XP({loading:e=!1,disabled:t,class:n,children:r,...i}){return k(`button`,{type:`button`,class:`btn relative ${n?` ${n}`:``}`,disabled:t||e,"aria-busy":e||void 0,...i,children:[k(`span`,{children:r}),e&&k(`span`,{class:`absolute inset-0 flex items-center justify-center backdrop-blur-xs`,"aria-hidden":`true`,children:k(`span`,{class:`loading loading-spinner loading-sm`})})]})}function ZP(e,t,n){switch(t){case`granted`:return n?e?.cameraOptional??`Camera is optional — turn it on anytime.`:e?.ready??`You're all set — join whenever you're ready.`;case`blocked`:return e?.denied??`Microphone is blocked. Click the mic to see how to allow it.`;case`in-use`:return`Your microphone is in use by another app. Close it and try again.`;case`not-found`:return`No microphone found. Connect one to continue.`;case`unsupported`:return`This browser can't access your microphone.`;case`prompt`:return e?.prompt??`Allow microphone access to join.`;default:return e?.loading??`Getting your microphone ready...`}}function QP({message:e}){return k(`div`,{class:`relative max-w-[min(20rem,90%)]`,children:[k(`div`,{class:`px-4 py-2 rounded-box bg-neutral text-neutral-content text-sm font-medium shadow-lg text-center`,role:`status`,"aria-live":`polite`,children:e}),k(`svg`,{class:`absolute left-1/2 -translate-x-1/2 top-full text-neutral`,width:`16`,height:`8`,viewBox:`0 0 16 8`,"aria-hidden":`true`,children:k(`path`,{d:`M0 0 L8 8 L16 0 Z`,fill:`currentColor`})})]})}var $P=ya(({text:e,isJoining:t=!1,onJoin:n,onCancel:r})=>{let i=ph(),{config:a}=ev(),{localSessionId:o,isCamMuted:s}=pb(),{mic:c,camera:l,requestMic:u,requestCamera:d}=bb(),f=a.value.customization.conversation.modality===`video`;T(()=>{u()},[]);let p=c.isGranted,m=E(!1);T(()=>{!f||!p||m.current||l.isGranted||l.isBlocked||(m.current=!0,d())},[f,p,l.isGranted,l.isBlocked,d]);let h=f&&p&&!l.isGranted,g=ZP(e,c.status,h);return k(Db,{children:k(`div`,{class:`absolute inset-0 motion-safe:animate-[tavusFadeUp_280ms_ease-out]`,children:[l.isGranted&&!s?k(`div`,{class:`absolute inset-0 flex items-center justify-center bg-black overflow-hidden`,children:k(dg,{type:`video`,sessionId:o??``,mirror:!0,fit:`cover`,className:`w-full h-full object-cover!`})}):k(`div`,{class:`absolute inset-0 flex items-center justify-center text-base-content/40`,children:k(Vy,{name:`face-smile`,size:`7rem`,"aria-label":`Camera off`})}),k(`div`,{class:`absolute bottom-6 left-1/2 -translate-x-1/2 z-10 flex flex-col items-center gap-2 max-w-[90%]`,children:[g&&k(QP,{message:g}),k(`div`,{class:`flex flex-wrap items-center justify-center gap-1.5 @max-mobile:gap-1`,children:[k(`div`,{class:`flex items-center justify-center gap-1.5 shrink-0 @max-mobile:gap-1`,children:[k(zb,{level:!0}),f&&k(Vb,{})]}),k(XP,{class:`btn-accent `,loading:t,disabled:!p,onClick:n,children:e?.join??`Join Video Chat`}),c.isBlocked&&k(`button`,{type:`button`,class:`btn btn-error `,onClick:()=>{i&&i.leave(),r?.()},children:e?.cancel??`Cancel`})]})]})]})})}),eF=`Password required`,tF=`Enter the password to start this conversation.`,nF=`Password`,rF=`Continue`;function iF({onSubmit:e,text:t,isSubmitting:n=!1,errorMessage:r}){let[i,a]=w(``),o=gt();return k(`div`,{class:`absolute inset-0 z-30 flex items-center justify-center bg-black/50 backdrop-blur-sm p-4`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`${o}-title`,children:k(`form`,{onSubmit:t=>{t.preventDefault();let r=i.trim();!r||n||e(r)},class:`card bg-base-100 shadow-xl w-full max-w-sm`,children:k(`div`,{class:`card-body gap-3`,children:[k(`h3`,{id:`${o}-title`,class:`card-title text-base-content`,children:t?.title??eF}),k(`p`,{class:`text-sm text-base-content/70`,children:t?.description??tF}),k(`input`,{id:o,type:`password`,autocomplete:`current-password`,class:`input input-bordered w-full`,placeholder:t?.placeholder??nF,value:i,disabled:n,onInput:e=>a(e.target.value),autoFocus:!0}),r&&k(`p`,{class:`text-error text-xs`,role:`alert`,children:r}),k(XP,{class:`btn-primary`,type:`submit`,disabled:!i.trim(),loading:n,children:t?.submit??rF})]})})})}var aF=bn(`CaptchaChallenge`),oF=1;function sF(e){return typeof e==`object`&&!!e&&e.source===`tavus-captcha`&&typeof e.type==`string`}function cF(e,t,n,r,i){return`${e.replace(/\/+$/,``)}${t.startsWith(`/`)?t:`/${t}`}?deployment_uuid=${encodeURIComponent(n)}&action=${encodeURIComponent(r)}&parent_origin=${encodeURIComponent(i)}`}function lF({captcha:e,deploymentId:t,onToken:n,onFallback:r}){let i=(mt(Tt).baseUrl??`https://tavusapi.com`).replace(/\/+$/,``),a=new URL(i).origin,[o,s]=w(0),[c,l]=w(0),[u,d]=w(!1),[f,p]=w(!1),m=cF(i,e.challenge_path,t,e.action,window.location.origin),h=O(()=>{p(!1),s(e=>e+1)},[]);return T(()=>{function e(e){if(u||e.origin!==a)return;let i=e.data;if(sF(i)&&i.deployment_uuid===t){if(i.type===`interactive`){p(!0);return}if(i.type===`token`&&i.token){aF.info(`Captcha token received`),p(!1),n(i.token);return}if(i.type===`expired`){aF.info(`Captcha token expired, reloading iframe`),h();return}i.type===`error`&&(aF.warn(`Captcha error received`,i.code),c<oF?(l(e=>e+1),h()):(aF.warn(`Captcha error retries exhausted, falling back to no-token mode`),d(!0),r()))}}return window.addEventListener(`message`,e),()=>window.removeEventListener(`message`,e)},[a,t,c,u,n,r,h]),u?null:k(`div`,{class:f?`absolute inset-0 z-30 flex items-center justify-center p-4 bg-base-100/70 backdrop-blur-sm animate-[tavusFadeUp_180ms_ease-out]`:`absolute top-0 left-0 w-0 h-0 overflow-hidden opacity-0 pointer-events-none`,"aria-hidden":!f,children:k(`iframe`,{src:m,sandbox:`allow-scripts allow-same-origin allow-forms allow-popups`,title:`Security challenge`,style:{border:`none`,width:`300px`,height:`65px`},scrolling:`no`},o)})}function uF({text:e,onStart:t,isStarting:n}){let{config:r,deploymentId:i}=ev(),a=mt(G_),o=Ky(r.value),s=o.btn_title??e?.fallback_button??`Start the conversation`,c=r.value.customization.terms_content?.trim()??``,l=r.value.customization.terms_enabled===!0,u=c.length>0,d=u&&l,f=D(()=>d&&S_(i,c),[d,i,c]),p=d&&!f,m=r.value.has_password===!0,h=a?.password.value??null,g=m&&!h,_=r.value.captcha??null,{captchaReady:v,captchaEpoch:y,handleCaptchaToken:b,handleCaptchaFallback:x}=_v(_,a),S=gt(),[C,ee]=w(f),te=_!==null&&!v,ne=n||d&&!C||g||te;return k(tb,{title:o.title,description:o.description,overlay:k(de,{children:[te&&k(lF,{captcha:_,deploymentId:i,onToken:b,onFallback:x},y),g&&a?k(iF,{onSubmit:a.setPassword}):null]}),children:[k(XP,{class:`btn-neutral rounded-box`,onClick:()=>{d&&C&&!f&&T_(i,c),t()},disabled:ne,loading:n,children:s}),u&&k(`div`,{class:`max-w-xs`,children:p?k(`label`,{for:S,class:`flex items-center gap-2 text-xs text-left cursor-pointer`,children:[k(`input`,{id:S,type:`checkbox`,class:`checkbox checkbox-secondary checkbox-xs mt-0.5 shrink-0`,checked:C,onChange:e=>ee(e.target.checked)}),k(`span`,{class:`leading-snug`,children:c})]}):k(`p`,{class:`text-xs leading-snug text-base-content/60`,children:c})})]})}function dF({flow:e,welcomeText:t,onUnavailableCancel:n}){switch(e.state){case`idle`:return k(uF,{text:t,onStart:()=>{e.start()},isStarting:e.isStarting});case`haircheck`:return k($P,{onJoin:()=>{e.join()},onCancel:()=>e.cancel(),isJoining:e.isStarting});case`call`:return k(JP,{onLeave:()=>e.leave()});case`ended`:return k(fb,{onRestart:()=>e.restart()});case`unavailable`:return k(ob,{cause:e.unavailableCause??`busy`,canRetry:e.canRetry,onRetry:()=>{e.start()},onCancel:n});default:{let t=e.state;throw Error(`Unreachable flow state: ${String(t)}`)}}}var fF=Le(null);function pF({children:e}){let{config:t}=mt(xi),n=t.peek().customization?.widget,r=n?.expandable??`default`,i=fn(r===`start-expanded`||r===`always`),a=fn(n?.variant??`full`),o=fn(n?.position??`bottom-right`),s=fn(r),c=fn(n?.avatar?.type??`orb`),l=E(r);yn(()=>{let e=t.value.customization?.widget,n=e?.expandable??`default`;a.value=e?.variant??`full`,o.value=e?.position??`bottom-right`,s.value=n,c.value=e?.avatar?.type??`orb`,l.current!==n&&(i.value=n===`start-expanded`||n===`always`,l.current=n)});let u=O(()=>{s.peek()!==`always`&&(i.value=!i.peek())},[i,s]),d=O(()=>{i.value=!0},[i]),f=O(()=>{s.peek()!==`always`&&(i.value=!1)},[i,s]),p=D(()=>({expanded:i,variant:a,position:o,expandable:s,avatarType:c,toggle:u,expand:d,collapse:f}),[i,a,o,s,c,u,d,f]);return k(fF.Provider,{value:p,children:e})}function mF(){let{config:e}=ev(),t=e.value.customization.branding;return e.value.show_tavus_branding!==!1&&!t?.hide_tavus_badge?k(hF,{}):t?.logo||t?.text?k(gF,{logo:t.logo,text:t.text}):null}function hF(){let{isDark:e}=ZN(),t=e.value?`white`:`#140206`;return k(`a`,{href:`https://tavus.io`,target:`_blank`,rel:`noopener noreferrer`,class:`inline-flex items-center gap-1 text-xs text-base-content/50 hover:text-base-content/80 transition-colors`,children:[k(`svg`,{viewBox:`0 0 488 452`,class:`h-2.5 w-2.5 shrink-0`,fill:`none`,"aria-hidden":`true`,children:[k(`path`,{d:`M160 152V208H104V152H160Z`,fill:t}),k(`path`,{"fill-rule":`evenodd`,"clip-rule":`evenodd`,d:`M488 270.5L436 285L451 326L418.766 346L441 360L423 392L435 452H0V0H394.766L488 270.5ZM24 24V428H216.2L209 392L227 360L204.766 346L237 326L222 285L274 270.5L189.038 24H24ZM352 152C336.536 152 324 164.536 324 180C324 195.464 336.536 208 352 208C367.464 208 380 195.464 380 180C380 164.536 367.464 152 352 152Z`,fill:t})]}),k(`span`,{children:[`Powered by `,k(`span`,{class:`underline`,children:`Tavus`})]})]})}function gF({logo:e,text:t}){return k(`div`,{class:`inline-flex items-center gap-1 text-xs text-base-content/50`,children:[e?k(`img`,{src:e,alt:t||`Branding`,class:`h-2.5 shrink-0`}):null,t?k(`span`,{children:t}):null]})}var _F={title:`Hi! Want to chat?`,btn_title:`Start conversation`};function vF(){let{config:e}=ev(),t=e.value.customization.widget?.text;return D(()=>({title:t?.title||_F.title,btn_title:t?.btn_title||_F.btn_title}),[t])}function yF(){let e=mt(fF);if(!e)throw Error(`useWidgetUI must be used within WidgetUIProvider`);return e}var bF={xs:`w-6 h-6`,sm:`w-8 h-8`,md:`w-10 h-10`,lg:`w-16 h-16`},xF={xs:`w-3 h-3`,sm:`w-4 h-4`,md:`w-5 h-5`,lg:`w-8 h-8`};function SF({size:e=`md`,className:t=``}){let{avatarType:n}=yF(),{config:r}=ev(),i=Gy(r.value);return(Ky(r.value).background.type===`replica`||n.value===`image`)&&i?k(`div`,{class:`relative ${bF[e]} rounded-box overflow-hidden bg-base-300 ${t}`,children:k(Xy,{replica:i})}):k(`div`,{class:`relative ${bF[e]} rounded-box bg-primary/15 flex items-center justify-center ${t}`,children:k(`span`,{class:`${xF[e]} rounded-full bg-primary animate-pulse`})})}function CF({variant:e}){let{toggle:t}=yF(),n=vF();return e===`tiny`?k(`button`,{type:`button`,onClick:t,"aria-label":n.btn_title,class:`rounded-box overflow-hidden shadow-xl hover:shadow-2xl transition-shadow cursor-pointer`,children:k(SF,{size:`lg`})}):e===`compact`?k(`button`,{type:`button`,onClick:t,"aria-label":n.btn_title,class:`group flex items-center gap-2.5 py-2.5 pl-2.5 pr-8 rounded-box bg-base-100 text-base-content border border-base-300 shadow-lg hover:shadow-xl transition-shadow cursor-pointer text-left`,children:[k(SF,{size:`md`}),k(`span`,{class:`flex flex-col gap-0.5`,children:[k(`span`,{class:`text-base font-medium leading-tight`,children:n.title}),k(`span`,{class:`text-sm text-base-content/60 leading-tight`,children:n.btn_title})]})]}):k(`button`,{type:`button`,onClick:t,"aria-label":n.btn_title,class:`flex flex-col gap-3 p-3 w-64 rounded-box bg-base-100 text-base-content border border-base-300 shadow-xl hover:shadow-2xl transition-shadow cursor-pointer text-left`,children:[k(`div`,{class:`flex items-center gap-2.5`,children:[k(SF,{size:`md`}),k(`span`,{class:`text-sm font-medium leading-snug`,children:n.title})]}),k(`span`,{class:`btn btn-primary btn-sm w-full pointer-events-none gap-2 flex items-center`,children:[k(Vy,{name:`cam`,size:16}),k(`span`,{className:`leading-4`,children:n.btn_title})]})]})}var wF=`tavus:widget:greeting-dismissed`;function TF({anchor:e}){let t=vF(),{variant:n,expand:r}=yF(),[i,a]=w(!1);T(()=>{if(n.value===`tiny`){try{if(sessionStorage.getItem(wF)===`1`)return}catch{}a(!0)}},[n]);let o=O(e=>{e.stopPropagation();try{sessionStorage.setItem(wF,`1`)}catch{}a(!1)},[]);if(!i)return null;let s=e===`right`?`right-[-6px] border-r border-b`:`left-[-6px] border-l border-t`,c=e===`right`?`-right-2`:`-left-2`;return k(`button`,{type:`button`,onClick:r,class:`relative max-w-56 rounded-box bg-base-100 text-base-content shadow-lg border border-base-300 px-3 py-2 text-sm text-left cursor-pointer animate-[tavusFadeUp_240ms_ease-out] hover:bg-base-200 transition-colors`,children:[k(`p`,{class:`leading-snug pr-3`,children:t.title}),k(`span`,{role:`button`,tabIndex:0,onClick:o,onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&o(e)},class:`absolute -top-2 ${c} btn btn-ghost btn-circle btn-xs bg-base-100 border border-base-300 shadow-sm`,"aria-label":`Dismiss`,children:`×`}),k(`span`,{class:`absolute bottom-3 w-3 h-3 rotate-45 bg-base-100 border-base-300 ${s}`})]})}function EF(){let e=mt(bv);if(!e)throw Error(`useHostBridge must be used within HostBridgeProvider`);return e}var DF=`bg-base-100 text-base-content rounded-box border border-base-300 shadow-xl w-[22rem] flex flex-col animate-[tavusPopIn_180ms_ease-out]`,OF=`bg-base-100 text-base-content w-[100vw] h-[100dvh] flex flex-col animate-[tavusFadeUp_180ms_ease-out]`,kF=`p-1 flex-1 min-h-0`,AF=`p-1 flex-1 min-h-0`;function jF({variant:e,children:t,fullscreen:n}){let{collapse:r,expandable:i}=yF(),a=i.value!==`always`;return n?k(`div`,{class:OF,children:[k(`div`,{class:`flex items-center justify-end gap-2 px-2.5 py-1.5 border-b border-base-300`,children:a&&k(`button`,{type:`button`,class:`btn btn-ghost btn-circle btn-xs`,onClick:r,"aria-label":`Close`,children:k(Vy,{name:`close`,size:14})})}),k(`div`,{class:AF,children:t}),k(`div`,{class:`flex justify-end px-2.5`,children:k(mF,{})})]}):k(`div`,{class:`flex flex-col h-[min(34rem,calc(100dvh-3rem))]`,children:[k(`div`,{class:`${DF} flex-1 overflow-hidden`,children:[k(`div`,{class:`flex items-center justify-end gap-2 px-2.5 pt-1.5 shrink-0`,children:a&&k(`button`,{type:`button`,class:`btn btn-ghost btn-circle btn-xs`,onClick:r,"aria-label":`Close`,children:k(Vy,{name:`close`,size:14})})}),k(`div`,{class:kF,children:t})]}),k(`div`,{class:`flex justify-end pr-2 pt-1.5 shrink-0`,children:k(mF,{})})]})}var MF=bn(`Widget`),NF=`1rem`,PF=480;function FF(){return typeof window>`u`?!1:window.innerWidth<=PF}function IF(e){switch(e){case`bottom-right`:return{bottom:NF,right:NF};case`bottom-left`:return{bottom:NF,left:NF};case`top-right`:return{top:NF,right:NF};case`top-left`:return{top:NF,left:NF};case`top`:return{top:NF,left:`50%`,transform:`translateX(-50%)`};case`bottom`:return{bottom:NF,left:`50%`,transform:`translateX(-50%)`}}}var LF=[`top`,`bottom`,`left`,`right`,`transform`];function RF(e){return e===`bottom-left`||e===`top-left`?`left`:`right`}function zF(){let{config:e,initError:t}=ev(),n=vF(),{expanded:r,position:i,variant:a}=yF(),{shadowHost:o}=EF(),s=sb(),c=fn(FF());T(()=>{if(typeof window>`u`)return;c.value=FF();let e=()=>{c.value=FF()};return window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[c]);let l=D(()=>({fallback_button:n.btn_title}),[n.btn_title]);if(yn(()=>{let e=o.value,t=i.value,n=r.value,a=n&&c.value;if(e){if(a)e.style.top=`0`,e.style.right=`0`,e.style.bottom=`0`,e.style.left=`0`,e.style.transform=``;else{let n=IF(t);for(let t of LF)e.style[t]=n[t]??``}e.dataset.tavusWidgetPosition=t,e.dataset.tavusWidgetExpanded=n?`true`:`false`,e.dataset.tavusWidgetFullscreen=a?`true`:`false`,e.dataset.tavusWidgetSmall=c.value?`true`:`false`}}),t.value)return MF.error(`Widget cannot initialize (init request failed):`,t.value),null;if(e.value.is_available===!1&&e.value.unavailable_reason===`total_limit`)return MF.error(`Widget is unavailable (total_limit reached) — not rendering`),null;if(!r.value){let e=RF(i.value),t=e===`right`?`flex items-end gap-2 justify-end`:`flex items-end gap-2 flex-row-reverse justify-end`,n=e===`right`?`justify-end pr-2`:`justify-start pl-2`;return k(`div`,{class:`flex flex-col`,children:[k(`div`,{class:t,children:[k(TF,{anchor:e}),k(CF,{variant:a.value})]}),k(`div`,{class:`flex ${n} pt-1.5`,children:k(mF,{})})]})}return e.value.is_available===!1?k(jF,{variant:a.value,fullscreen:c.value,children:k(Pv,{children:k(ob,{cause:e.value.unavailable_reason??`daily_limit`,canRetry:!1,onRetry:()=>{}})})}):k(jF,{variant:a.value,fullscreen:c.value,children:k(Pv,{children:k(dF,{flow:s,welcomeText:l,onUnavailableCancel:()=>s.restart()})})})}var BF=`:host {
163
+ container holding the app. Specify either width or maxWidth, and either height or maxHeight.`),locale:J().optional().describe(`User's language and region preference in BCP 47 format.`),timeZone:J().optional().describe(`User's timezone in IANA format.`),userAgent:J().optional().describe(`Host application identifier.`),platform:Q([$(`web`),$(`desktop`),$(`mobile`)]).optional().describe(`Platform type for responsive design decisions.`),deviceCapabilities:Z({touch:sk().optional().describe(`Whether the device supports touch input.`),hover:sk().optional().describe(`Whether the device supports hover interactions.`)}).optional().describe(`Device input capabilities.`),safeAreaInsets:Z({top:Y().describe(`Top safe area inset in pixels.`),right:Y().describe(`Right safe area inset in pixels.`),bottom:Y().describe(`Bottom safe area inset in pixels.`),left:Y().describe(`Left safe area inset in pixels.`)}).optional().describe(`Mobile safe area boundaries in pixels.`)}).passthrough();Z({method:$(`ui/notifications/host-context-changed`),params:GN.describe(`Partial context update containing only changed fields.`)});var KN=Z({method:$(`ui/update-model-context`),params:Z({content:X(yM).optional().describe(`Context content blocks (text, image, etc.).`),structuredContent:hk(J(),uk().describe(`Structured content for machine-readable context data.`)).optional().describe(`Structured content for machine-readable context data.`)})}),qN=Z({method:$(`ui/initialize`),params:Z({appInfo:lj.describe(`App identification (name and version).`),appCapabilities:zN.describe(`Features and capabilities this app provides.`),protocolVersion:J().describe(`Protocol version this app supports.`)})});Z({protocolVersion:J().describe(`Negotiated protocol version string (e.g., "2025-11-21").`),hostInfo:lj.describe(`Host application identification and version.`),hostCapabilities:RN.describe(`Features and capabilities provided by the host.`),hostContext:GN.describe(`Rich context about the host environment.`)}).passthrough();var JN=[wN],YN=class extends CN{_client;_hostInfo;_capabilities;_appCapabilities;_hostContext={};_appInfo;_initializedReceived=!1;_baseReplaceRequestHandler=this.replaceRequestHandler;replaceRequestHandler=(e,t)=>{this._baseReplaceRequestHandler(e,(e,n)=>(this._initializedReceived||console.warn(`[ext-apps] AppBridge received '${e.method}' before ui/notifications/initialized. The View is calling host methods before completing the handshake; it should await app.connect() first.`),t(e,n)))};eventSchemas={sizechange:MN,sandboxready:kN,initialized:BN,requestteardown:LN,loggingmessage:IM};constructor(e,t,n,r){super(r),this._client=e,this._hostInfo=t,this._capabilities=n,this.addEventListener(`initialized`,()=>{this._initializedReceived=!0}),this._hostContext=r?.hostContext||{},this.setRequestHandler(qN,e=>this._oninitialize(e)),this.setRequestHandler(yj,(e,t)=>(this.onping?.(e.params,t),{})),this.replaceRequestHandler(VN,e=>({mode:this._hostContext.displayMode??`inline`}))}getAppCapabilities(){return this._appCapabilities}getAppVersion(){return this._appInfo}onping;get onsizechange(){return this.getEventHandler(`sizechange`)}set onsizechange(e){this.setEventHandler(`sizechange`,e)}get onsandboxready(){return this.getEventHandler(`sandboxready`)}set onsandboxready(e){this.setEventHandler(`sandboxready`,e)}get oninitialized(){return this.getEventHandler(`initialized`)}set oninitialized(e){this.setEventHandler(`initialized`,e)}_onmessage;get onmessage(){return this._onmessage}set onmessage(e){this.warnIfRequestHandlerReplaced(`onmessage`,this._onmessage,e),this._onmessage=e,this.replaceRequestHandler(WN,async(e,t)=>{if(!this._onmessage)throw Error(`No onmessage handler set`);return this._onmessage(e.params,t)})}_onopenlink;get onopenlink(){return this._onopenlink}set onopenlink(e){this.warnIfRequestHandlerReplaced(`onopenlink`,this._onopenlink,e),this._onopenlink=e,this.replaceRequestHandler(ON,async(e,t)=>{if(!this._onopenlink)throw Error(`No onopenlink handler set`);return this._onopenlink(e.params,t)})}_ondownloadfile;get ondownloadfile(){return this._ondownloadfile}set ondownloadfile(e){this.warnIfRequestHandlerReplaced(`ondownloadfile`,this._ondownloadfile,e),this._ondownloadfile=e,this.replaceRequestHandler(UN,async(e,t)=>{if(!this._ondownloadfile)throw Error(`No ondownloadfile handler set`);return this._ondownloadfile(e.params,t)})}get onrequestteardown(){return this.getEventHandler(`requestteardown`)}set onrequestteardown(e){this.setEventHandler(`requestteardown`,e)}_onrequestdisplaymode;get onrequestdisplaymode(){return this._onrequestdisplaymode}set onrequestdisplaymode(e){this.warnIfRequestHandlerReplaced(`onrequestdisplaymode`,this._onrequestdisplaymode,e),this._onrequestdisplaymode=e,this.replaceRequestHandler(VN,async(e,t)=>{if(!this._onrequestdisplaymode)throw Error(`No onrequestdisplaymode handler set`);return this._onrequestdisplaymode(e.params,t)})}get onloggingmessage(){return this.getEventHandler(`loggingmessage`)}set onloggingmessage(e){this.setEventHandler(`loggingmessage`,e)}_onupdatemodelcontext;get onupdatemodelcontext(){return this._onupdatemodelcontext}set onupdatemodelcontext(e){this.warnIfRequestHandlerReplaced(`onupdatemodelcontext`,this._onupdatemodelcontext,e),this._onupdatemodelcontext=e,this.replaceRequestHandler(KN,async(e,t)=>{if(!this._onupdatemodelcontext)throw Error(`No onupdatemodelcontext handler set`);return this._onupdatemodelcontext(e.params,t)})}_oncalltool;get oncalltool(){return this._oncalltool}set oncalltool(e){this.warnIfRequestHandlerReplaced(`oncalltool`,this._oncalltool,e),this._oncalltool=e,this.replaceRequestHandler(AM,async(e,t)=>{if(!this._oncalltool)throw Error(`No oncalltool handler set`);return this._oncalltool(e.params,t)})}set oncreatesamplingmessage(e){this.setRequestHandler(WM,async(t,n)=>e(t.params,n))}sendToolListChanged(e={}){return this.notification({method:`notifications/tools/list_changed`,params:e})}_onlistresources;get onlistresources(){return this._onlistresources}set onlistresources(e){this.warnIfRequestHandlerReplaced(`onlistresources`,this._onlistresources,e),this._onlistresources=e,this.replaceRequestHandler(Kj,async(e,t)=>{if(!this._onlistresources)throw Error(`No onlistresources handler set`);return this._onlistresources(e.params,t)})}_onlistresourcetemplates;get onlistresourcetemplates(){return this._onlistresourcetemplates}set onlistresourcetemplates(e){this.warnIfRequestHandlerReplaced(`onlistresourcetemplates`,this._onlistresourcetemplates,e),this._onlistresourcetemplates=e,this.replaceRequestHandler(Jj,async(e,t)=>{if(!this._onlistresourcetemplates)throw Error(`No onlistresourcetemplates handler set`);return this._onlistresourcetemplates(e.params,t)})}_onreadresource;get onreadresource(){return this._onreadresource}set onreadresource(e){this.warnIfRequestHandlerReplaced(`onreadresource`,this._onreadresource,e),this._onreadresource=e,this.replaceRequestHandler(Qj,async(e,t)=>{if(!this._onreadresource)throw Error(`No onreadresource handler set`);return this._onreadresource(e.params,t)})}sendResourceListChanged(e={}){return this.notification({method:`notifications/resources/list_changed`,params:e})}_onlistprompts;get onlistprompts(){return this._onlistprompts}set onlistprompts(e){this.warnIfRequestHandlerReplaced(`onlistprompts`,this._onlistprompts,e),this._onlistprompts=e,this.replaceRequestHandler(lM,async(e,t)=>{if(!this._onlistprompts)throw Error(`No onlistprompts handler set`);return this._onlistprompts(e.params,t)})}sendPromptListChanged(e={}){return this.notification({method:`notifications/prompts/list_changed`,params:e})}assertCapabilityForMethod(e){}assertRequestHandlerCapability(e){}assertNotificationCapability(e){}assertTaskCapability(e){throw Error(`Tasks are not supported in MCP Apps`)}assertTaskHandlerCapability(e){throw Error(`Task handlers are not supported in MCP Apps`)}getCapabilities(){return this._capabilities}async _oninitialize(e){let t=e.params.protocolVersion;return this._appInfo!==void 0&&console.warn(`[ext-apps] AppBridge received a second ui/initialize. The View may be double-mounting (e.g. React StrictMode in dev) without closing the previous App instance. Responding normally; the latest appInfo/appCapabilities replace the previous values.`),this._appCapabilities=e.params.appCapabilities,this._appInfo=e.params.appInfo,{protocolVersion:JN.includes(t)?t:wN,hostCapabilities:this.getCapabilities(),hostInfo:this._hostInfo,hostContext:this._hostContext}}setHostContext(e){let t={},n=!1;for(let r of Object.keys(e)){let i=this._hostContext[r],a=e[r];XN(i,a)||(t[r]=a,n=!0)}n&&(this._hostContext=e,this.sendHostContextChange(t))}sendHostContextChange(e){return this.notification({method:`ui/notifications/host-context-changed`,params:e})}sendToolInput(e){return this.notification({method:`ui/notifications/tool-input`,params:e})}sendToolInputPartial(e){return this.notification({method:`ui/notifications/tool-input-partial`,params:e})}sendToolResult(e){return this.notification({method:`ui/notifications/tool-result`,params:e})}sendToolCancelled(e){return this.notification({method:`ui/notifications/tool-cancelled`,params:e})}sendSandboxResourceReady(e){return this.notification({method:`ui/notifications/sandbox-resource-ready`,params:e})}teardownResource(e,t){return this.request({method:`ui/resource-teardown`,params:e},FN,t)}sendResourceTeardown=this.teardownResource;callTool(e,t){return this.request({method:`tools/call`,params:e},OM,t)}listTools(e,t){return this.request({method:`tools/list`,params:e},DM,t)}async connect(e){if(this.transport)throw Error(`AppBridge is already connected. Call close() before connecting again.`);if(this._initializedReceived=!1,this._client){let e=this._client.getServerCapabilities();if(!e)throw Error(`Client server capabilities not available`);e.tools&&(this.oncalltool=async(e,t)=>this._client.request({method:`tools/call`,params:e},OM,{signal:t.signal}),e.tools.listChanged&&this._client.setNotificationHandler(jM,e=>this.sendToolListChanged(e.params))),e.resources&&(this.onlistresources=async(e,t)=>this._client.request({method:`resources/list`,params:e},qj,{signal:t.signal}),this.onlistresourcetemplates=async(e,t)=>this._client.request({method:`resources/templates/list`,params:e},Yj,{signal:t.signal}),this.onreadresource=async(e,t)=>this._client.request({method:`resources/read`,params:e},$j,{signal:t.signal}),e.resources.listChanged&&this._client.setNotificationHandler(eM,e=>this.sendResourceListChanged(e.params))),e.prompts&&(this.onlistprompts=async(e,t)=>this._client.request({method:`prompts/list`,params:e},uM,{signal:t.signal}),e.prompts.listChanged&&this._client.setNotificationHandler(SM,e=>this.sendPromptListChanged(e.params)))}return super.connect(e)}};function XN(e,t){return JSON.stringify(e)===JSON.stringify(t)}function ZN(){let e=mt(Cv);if(!e)throw Error(`useTheme must be used within ThemeProvider`);return e}function QN({state:e}){return e.enabled?k(`details`,{class:`pointer-events-auto w-full max-w-md rounded-lg border border-base-300 bg-base-100/95 p-2 text-xs shadow-lg backdrop-blur`,children:[k(`summary`,{class:`cursor-pointer font-medium`,children:`Magic Canvas debug`}),k(`dl`,{class:`mt-2 grid gap-2`,children:[k($N,{label:`iframe`,value:e.iframeLifecycleState}),k($N,{label:`post`,value:e.lastInteractionPostResult}),k($N,{label:`context`,value:e.lastModelContextUpdate}),k($N,{label:`error`,value:e.lastError}),k(eP,{label:`tool_call`,value:e.lastToolCall}),k(eP,{label:`canvas_config`,value:e.parsedCanvasConfig})]})]}):null}function $N({label:e,value:t}){return t?k(`div`,{children:[k(`dt`,{class:`font-semibold`,children:e}),k(`dd`,{class:`break-words text-base-content/70`,children:t})]}):null}function eP({label:e,value:t}){return t===void 0?null:k(`div`,{children:[k(`dt`,{class:`font-semibold`,children:e}),k(`dd`,{children:k(`pre`,{class:`max-h-40 overflow-auto rounded bg-base-200 p-2 text-[10px] leading-relaxed`,children:JSON.stringify(t,null,2)})})]})}var tP=1e3,nP=5e3,rP=1200,iP=2e3;function aP(e){return e.correct_answer===void 0?rP:iP}var oP=48,sP=`allow-scripts`,cP={"canvas.scheduling_embed":`allow-scripts allow-same-origin allow-popups allow-forms`};function lP(e,t){if(!t.contentWindow||e.source!==t.contentWindow)return!1;let n=e.data;return!!n&&typeof n==`object`&&n?.jsonrpc===`2.0`}var uP=class{onmessage;onerror;onclose;#e;#t;constructor(e){this.#e=e}start(){let e=e=>{lP(e,this.#e)&&this.onmessage?.(e.data)};return this.#t=e,globalThis.addEventListener(`message`,e),Promise.resolve()}send(e){return this.#e.contentWindow?.postMessage(e,`*`),Promise.resolve()}close(){return this.#t&&globalThis.removeEventListener(`message`,this.#t),this.#t=void 0,this.onclose?.(),Promise.resolve()}};function dP(e){for(let t of jx)if(e.some(e=>EP(e)===t))return t;return null}function fP({onLayoutEffectChange:e,onRenderedSlotChange:t,debugEnabled:n=DP()}={}){let{client:r}=ev(),{dataTheme:i,cssVars:a}=ZN(),o=ph(),s=Bg(),[c,l]=w([]),[u,d]=xP(),[f,p]=w(()=>({enabled:n,iframeLifecycleState:`idle`})),m=O(e=>{p(t=>({...t,...e}))},[]),h=O((e,t=`*`)=>{if(s!==`joined-meeting`){m({lastError:`Dropped Magic Canvas app message because the Daily meeting is not joined.`});return}o?.sendAppMessage(e,t)},[o,s,m]),g=D(()=>({theme:i.value===`dark`?`dark`:`light`,cssVars:a.value}),[i.value,a.value]);T(()=>{p(e=>e.enabled===n?e:{...e,enabled:n})},[n]),Qg({onAppMessage:O(e=>{if(s!==`joined-meeting`){m({lastToolCall:e.data,iframeLifecycleState:`idle`,lastError:`Dropped Magic Canvas tool call because the Daily meeting is not joined.`});return}try{let t=wS(e.data);if(!t)return;l(e=>Ux(e,t)),m({lastToolCall:e.data,parsedCanvasConfig:t.kind===`show`?t.instance.canvas_config:void 0,iframeLifecycleState:t.kind===`clear`?`closed`:`received`,lastError:void 0})}catch(e){m({iframeLifecycleState:`error`,lastError:AP(e).message})}},[s,m])});let _=c.map(e=>({instance:e,layout:Xx(e,d)})),v=Zx(_.map(({layout:e})=>e),d),y=[..._].reverse().find(({layout:e})=>e.display_mode===`fullscreen`)?.instance.tool_call_id;T(()=>{e?.(v)},[e,v.active,v.side,v.video_shift_x,v.backdrop.type,v.safe_area?.x,v.safe_area?.y,v.safe_area?.width,v.safe_area?.height]);let b=dP(_.map(({layout:e})=>e));T(()=>{t?.(b)},[t,b]);let x=c.length>0||f.enabled;return k(`div`,{ref:u,"data-magic-canvas-root":!0,class:`pointer-events-none absolute inset-0 z-30`,children:[x&&y&&k(`div`,{class:`absolute inset-0 bg-black/45`}),x&&jx.map(e=>{let t=_.filter(({layout:t})=>EP(t)===e);return t.length===0?null:k(mP,{slot:e,safeAreaTop:v.safe_area?.y,frameWidth:d.width,children:e=>t.map(({instance:t,layout:n})=>k(hP,{availableHeight:e,client:r,hostTheme:g,instance:t,layout:n,dimmed:!!(y&&y!==t.tool_call_id),onDebug:m,onComplete:()=>{l(e=>e.filter(e=>e.id!==t.id))},onDisplayModeChange:e=>{l(n=>n.map(n=>n.tool_call_id===t.tool_call_id?{...n,layout:{...n.layout,display_mode:e}}:n))},sendAppMessage:h},t.id))},e)}),x&&k(`div`,{class:`absolute right-4 bottom-24 @max-mobile:right-3 @max-mobile:bottom-20`,children:k(QN,{state:f})})]})}var pP=16;function mP({slot:e,safeAreaTop:t,frameWidth:n,children:r}){let[i,a]=SP(),o=r(e===`full`?void 0:a);if(e===`safe-area-left`||e===`safe-area-right`){let r=t==null?`1rem`:`${t*100}%`,a=n!=null&&n>0?Math.max(0,n-pP*2):void 0;return k(`div`,{ref:i,class:TP(e),style:{top:r,bottom:`${wP}px`,maxWidth:a},"data-canvas-slot":e,children:k(`div`,{class:`my-auto flex w-full flex-col gap-2`,children:o})})}return k(`div`,{ref:i,class:TP(e),"data-canvas-slot":e,children:o})}function hP({availableHeight:e,client:t,hostTheme:n,instance:r,layout:i,dimmed:a,onDebug:o,onComplete:s,onDisplayModeChange:c,sendAppMessage:l}){let u=E(null),d=E(null),f=E(e),p=E(320),m=E(n),h=E(r),g=E(i),_=E(-1),v=E(s),y=E(c),b=E(l),[x,S]=w(320);T(()=>{h.current=r},[r]),T(()=>{p.current=x,d.current?.setHostContext(yP(h.current,m.current,g.current,f.current,x))},[x]),T(()=>{f.current=e;let t=vP(n,u.current);m.current=t,d.current?.setHostContext(yP(h.current,t,g.current,e,p.current))},[e,n]),T(()=>{g.current=i,d.current?.setHostContext(yP(h.current,m.current,i,e,p.current))},[e,i]),T(()=>{v.current=s,y.current=c,b.current=l},[s,c,l]),T(()=>{let e=u.current;if(!e)return;let n=!1,i=null,a=null,s=null,c=null,l=new URL(r.canvas_config.sandbox_url,globalThis.location.href).href,x=e=>{n||o({iframeLifecycleState:`error`,lastError:AP(e).message})},C=()=>{if(n||!a)return;let e=h.current,t=Jx(e,a);a=null,b.current({message_type:`conversation`,event_type:`conversation.append_llm_context`,conversation_id:e.conversation_id,properties:{context:t}}),o({lastModelContextUpdate:e.canvas_config.component,lastError:void 0})},ee=()=>{if(i)return;if(e.src!==l){e.src;return}if(n||!e.contentWindow)return;let u=new YN(null,{name:`tavus-deployment`,version:`0.0.0`},{logging:{},message:{text:{},structuredContent:{}},updateModelContext:{text:{},structuredContent:{}}},{hostContext:yP(r,vP(m.current,e),g.current,f.current,p.current)});i=u,d.current=u,u.oninitialized=()=>{n||(o({iframeLifecycleState:`ready`}),_.current=h.current.revision,u.sendToolInput({arguments:h.current.arguments}).catch(x))},u.onsizechange=({height:e})=>{!n&&typeof e==`number`&&Number.isFinite(e)&&S(Math.min(Math.max(e,oP),720))},u.onmessage=async e=>{let r=Wx(e),i=qx(e);if(!r){if(i){let e=`Magic Canvas message included text without interaction metadata; no interaction row was recorded.`;return o({lastInteractionPostResult:`error`,lastError:e}),{isError:!0,code:`missing_interaction_metadata`,message:e}}return{}}try{let e=h.current,a=Gx(e,r),s=TS(a),l=new AbortController,u=globalThis.setTimeout(()=>l.abort(),nP);try{await Dn(t,a.conversation_id,s.body,{signal:l.signal})}finally{globalThis.clearTimeout(u)}if(n)return{};i&&b.current({message_type:`conversation`,event_type:`conversation.respond`,conversation_id:e.conversation_id,properties:{text:i}}),o({lastInteractionPostResult:`success`,lastError:void 0}),Kx(a)&&(a.type===`submit`?(c&&clearTimeout(c),c=setTimeout(()=>{c=null,n||v.current()},aP(e.arguments))):v.current())}catch(e){let t=AP(e).message;return o({lastInteractionPostResult:`error`,lastError:t}),{isError:!0,code:`interaction_post_failed`,message:t}}return{}},u.onupdatemodelcontext=async e=>(a=e,s||=setTimeout(()=>{s=null,C()},tP),{}),u.onrequestdisplaymode=async({mode:e})=>{let t=e===`fullscreen`?`fullscreen`:`inline`;return y.current(t),g.current={...g.current,display_mode:t,viable_slot:t===`fullscreen`?`full`:g.current.viable_slot},u.setHostContext(yP(h.current,m.current,g.current,f.current,p.current)),{mode:t}},u.connect(new uP(e)).then(()=>void 0).catch(x)};o({iframeLifecycleState:`mounting`,lastInteractionPostResult:void 0}),r.canvas_config.sandbox_url,e.src=r.canvas_config.sandbox_url;let te=()=>{ee()};return e.addEventListener(`load`,te),ee(),()=>{s&&=(clearTimeout(s),null),c&&=(clearTimeout(c),null),C(),n=!0,e.removeEventListener(`load`,te),d.current=null,o({iframeLifecycleState:`closed`}),i&&kx(i)}},[t,r.id,r.canvas_config.sandbox_url,o]),T(()=>{r.revision!==0&&(r.revision<=_.current||(_.current=r.revision,d.current?.sendToolInput({arguments:r.arguments}).catch(e=>{o({iframeLifecycleState:`error`,lastError:AP(e).message})})))},[r.arguments,r.revision,o]);let C=i.viable_slot===`full`||i.display_mode===`fullscreen`,ee=C?null:bP(x,e),te=ee?.placeholderStyle,ne=ee?.cardStyle,re=C?{height:`100%`}:ee?.iframeStyle??{height:`${x}px`},ie=[`pointer-events-auto w-full overflow-hidden rounded-lg border border-base-300 bg-base-100 shadow-xl transition-[opacity,transform]`,C?`fixed inset-4 z-10 max-w-none`:`max-w-md`,a?`scale-[0.98] opacity-40`:``].filter(Boolean).join(` `),ae=cP[r.canvas_config.component]??sP,oe=k(`div`,{class:ie,style:ne,"data-canvas-card":i.viable_slot,children:k(`iframe`,{ref:u,title:`${r.canvas_config.component} ${r.canvas_config.component_version}`,class:C?`block h-full w-full border-0 bg-transparent`:`block border-0 bg-transparent`,sandbox:ae,style:re})});return C?oe:k(`div`,{class:`block w-full`,style:te,children:oe})}var gP=[`--color-base-100`,`--color-base-200`,`--color-base-300`,`--color-base-content`,`--color-primary`,`--color-error`];function _P(e){if(!e||typeof getComputedStyle!=`function`)return{};let t=getComputedStyle(e),n={};for(let e of gP){let r=t.getPropertyValue(e).trim();r&&(n[e]=r)}return n}function vP(e,t){let n=_P(t);return Object.keys(n).length===0?e:{...e,cssVars:{...e.cssVars,...n}}}function yP(e,t,n,r,i){let a=ES(t,n),o=n.viable_slot===`full`||n.display_mode===`fullscreen`,s=o?void 0:OP(r),c=o?1:bP(i??0,r)?.displayScale??1;return{...e.canvas_config.host_context,...a,containerDimensions:{...kP(a.containerDimensions)?a.containerDimensions:{},...s===void 0?{}:{maxHeight:s},displayScale:c}}}function bP(e,t){if(t===void 0||!Number.isFinite(t)||t<=0)return null;let n=Math.min(e,720);if(n<=t)return{displayScale:1,placeholderStyle:{maxHeight:`${t}px`},cardStyle:void 0,iframeStyle:{width:`100%`,height:`${n}px`}};let r=t/n;return r>=.85?{displayScale:r,placeholderStyle:{height:`${n*r}px`,maxHeight:`${t}px`,overflow:`hidden`},cardStyle:{height:`${n}px`,transform:`scale(${r})`,transformOrigin:`top center`},iframeStyle:{width:`100%`,height:`${n}px`}}:{displayScale:1,placeholderStyle:{maxHeight:`${t}px`},cardStyle:void 0,iframeStyle:{width:`100%`,height:`${t}px`}}}function xP(){let e=E(null),[t,n]=w(()=>CP(null));return T(()=>{let t=()=>n(t=>{let n=CP(e.current);return t.width===n.width&&t.height===n.height&&t.visualViewportHeight===n.visualViewportHeight?t:n});t(),globalThis.addEventListener(`resize`,t),globalThis.visualViewport?.addEventListener(`resize`,t);let r;return typeof ResizeObserver<`u`&&e.current&&(r=new ResizeObserver(t),r.observe(e.current)),()=>{globalThis.removeEventListener(`resize`,t),globalThis.visualViewport?.removeEventListener(`resize`,t),r?.disconnect()}},[]),[e,t]}function SP(){let e=E(null),[t,n]=w();return T(()=>{let t=e.current;if(!t)return;let r=e=>{let r=e??t.getBoundingClientRect().height;!Number.isFinite(r)||r<=0||n(Math.floor(r))},i=()=>r();if(i(),typeof ResizeObserver>`u`)return globalThis.addEventListener(`resize`,i),()=>globalThis.removeEventListener(`resize`,i);let a=new ResizeObserver(e=>{r(e[0]?.contentRect.height)});return a.observe(t),()=>a.disconnect()},[]),[e,t]}function CP(e){let t=globalThis.visualViewport?.height,n=e?.getBoundingClientRect();if(n&&n.width>0&&n.height>0){let e=t===void 0?void 0:Math.max(0,(globalThis.innerHeight||0)-t);return{width:n.width,height:n.height,visualViewportHeight:e===void 0?void 0:Math.max(0,n.height-e)}}return{width:globalThis.innerWidth||1024,height:globalThis.innerHeight||768,visualViewportHeight:t}}var wP=72;function TP(e){let t=`absolute flex gap-2`;switch(e){case`safe-area-left`:return`${t} left-4 w-[28rem] flex-col overflow-y-auto`;case`safe-area-right`:return`${t} right-4 w-[28rem] flex-col overflow-y-auto`;case`safe-area-bottom`:return`${t} right-4 bottom-24 left-4 flex-col items-center justify-end @max-mobile:right-3 @max-mobile:bottom-20 @max-mobile:left-3`;case`full`:return`${t} inset-4 flex-col items-stretch justify-stretch`}}function EP(e){return e.display_mode===`fullscreen`&&e.preferred_slot!==`full`?e.preferred_slot:e.viable_slot}function DP(){return!1}function OP(e){return e===void 0||!Number.isFinite(e)||e<=0?720:Math.min(Math.floor(e),720)}function kP(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function AP(e){return e instanceof Error?e:Error(String(e))}var jP=1e4;function MP({onTimeout:e,timeoutMs:t=jP,active:n=!0}){let r=mx().length>0,[i,a]=w(!1),o=E(e);return T(()=>{o.current=e},[e]),T(()=>{if(!n||r){a(!1);return}let e=setTimeout(()=>{a(!0),o.current()},t);return()=>clearTimeout(e)},[n,r,t]),{hasJoined:r,timedOut:i}}function NP(e){if(typeof e!=`object`||!e)return!1;let t=e;return t.message_type===`system`&&t.event_type===`system.shutdown`}function PP({onShutdown:e}){let t=E(e);T(()=>{t.current=e},[e]),Qg({onAppMessage:O(e=>{NP(e?.data)&&t.current()},[])})}function FP(){let e=ph();return{joinCall:O(({url:t,micOnly:n=!1})=>{e?.join(n?{url:t,videoSource:!1}:{url:t})},[e]),leaveCall:O(()=>{e?.leave()},[e])}}var IP=bn(`PiP`),LP=360,RP=280;function zP(){return globalThis.window!==void 0&&`documentPictureInPicture`in globalThis.window}function BP(e){let{enabled:t,active:n}=e,[r,i]=w(null),a=zP(),o=mt(Cv),s=O(()=>{i(e=>(e&&!e.closed&&e.close(),null))},[]),c=O(async()=>{if(a&&!(!t||!n)&&!(r&&!r.closed))try{let e=await globalThis.window.documentPictureInPicture.requestWindow({width:LP,height:RP}),t=Xe.replace(/:host(?=[\s,{])/g,`:host, :root`),n=e.document.createElement(`style`);n.textContent=t,e.document.head.appendChild(n),e.document.body.style.margin=`0`,e.document.body.style.width=`100%`,e.document.body.style.height=`100vh`,e.document.body.style.overflow=`hidden`,e.addEventListener(`pagehide`,()=>{i(t=>t===e?null:t)},{once:!0}),i(e)}catch(e){IP.warn(`Failed to open PiP window`,e)}},[a,t,n,r]);return T(()=>{if(!t||!a||!n)return;let e=()=>{document.visibilityState===`hidden`?c():document.visibilityState===`visible`&&s()};document.addEventListener(`visibilitychange`,e);let r=[],i=null,o=`none`,l=!1;if(typeof navigator<`u`&&`mediaSession`in navigator){let e=navigator.mediaSession;i=e.metadata,o=e.playbackState;try{e.metadata=new MediaMetadata({title:`Tavus conversation`}),e.playbackState=`playing`,l=!0}catch(e){IP.warn(`mediaSession metadata setup failed`,e)}let t=(t,n)=>{try{e.setActionHandler(t,n),r.push(t)}catch(e){IP.warn(`mediaSession.${t} not supported`,e)}};t(`enterpictureinpicture`,()=>{c()}),t(`play`,()=>{}),t(`pause`,()=>{})}return()=>{if(document.removeEventListener(`visibilitychange`,e),typeof navigator<`u`&&`mediaSession`in navigator){let e=navigator.mediaSession;for(let t of r)try{e.setActionHandler(t,null)}catch{}if(l)try{e.metadata=i,e.playbackState=o}catch{}}}},[t,a,n,c,s]),T(()=>{(!n||!t)&&r&&!r.closed&&s()},[n,t,r,s]),T(()=>()=>{r&&!r.closed&&r.close()},[r]),T(()=>{if(!r||r.closed||!o)return;let e=()=>{r.document.body.setAttribute(`data-theme`,o.dataTheme.value);let e=o.cssVars.value;for(let[t,n]of Object.entries(e))r.document.body.style.setProperty(t,n)};e();let t=o.dataTheme.subscribe(()=>e()),n=o.cssVars.subscribe(()=>e());return()=>{t(),n()}},[r,o]),{pipWindow:r,isSupported:a,requestPipWindow:c,closePipWindow:s}}var VP=Gt(null),HP={active:!1,video_shift_x:0,backdrop:{type:`snapshot_mirror`}},UP=ya(({id:e,showAudioWave:t=!0})=>{let n=d_(e).isOff;return k(`div`,{class:`relative aspect-square w-32 @max-mobile:w-24 rounded-box overflow-hidden bg-black/30 z-10 ${n?`hidden`:``}`,children:[k(dg,{automirror:!0,sessionId:e,type:`video`,fit:`cover`,className:`w-full h-full object-cover ${n?`hidden`:``}`}),t&&k(`div`,{class:`absolute bottom-2 right-2`,children:k(sx,{id:e})})]})}),WP=ya(()=>{let e=Zh(),{isScreenSharing:t}=hb(),n=mx()[0];return k(de,{children:[t&&n&&k(UP,{id:n}),e&&k(UP,{id:e,showAudioWave:!1})]})}),GP=ya(()=>k(`div`,{class:`absolute top-4 left-4 flex flex-col items-end gap-2 z-20`,children:k(WP,{})})),KP=ya(({isAudioOnly:e,canvasLayoutEffect:t,canvasRenderedSlot:n})=>{let r=Zh(),i=!l_(r??``).isOff,a=hx(e),o=l_(a.phase===`ready`?a.replicaId:``),s=!i&&(o.state===`playable`||o.state===`loading`),c=t.active&&!i&&(!e||s);return a.phase===`left`?k(ax,{}):a.phase===`connecting`?k(ix,{}):e&&!s?k(`div`,{class:`absolute inset-0 flex items-center justify-center`,children:[k(dx,{sessionId:a.replicaId}),k(lg,{sessionId:a.replicaId})]}):k(de,{children:[s?k(aC,{personaSessionId:a.replicaId,isAudioOnly:e,avatarOff:a.videoState.isOff,canvasLayoutEffect:t,smartSidecarActive:c}):k(qP,{personaSessionId:a.replicaId,localId:r,isScreenSharing:i,avatarOff:a.videoState.isOff,smartSidecarActive:c,canvasLayoutEffect:t,canvasRenderedSlot:n}),k(lg,{sessionId:a.replicaId})]})}),qP=ya(({personaSessionId:e,localId:t,isScreenSharing:n,avatarOff:r,smartSidecarActive:i,canvasLayoutEffect:a,canvasRenderedSlot:o})=>k(rC,{canvasLayoutEffect:a,smartSidecarActive:i,isScreenSharing:n,captureSnapshot:ZP,personaMode:`auto`,renderedSlot:o,fill:i=>k(yx,{personaSessionId:e,localSessionId:t,isScreenSharing:n,avatarOff:r,videoRef:i})})),JP=ya(({items:e})=>{let[t,n]=w(!1),r=E(null);return T(()=>{if(!t)return;let e=e=>{r.current&&!e.composedPath().includes(r.current)&&n(!1)},i=e=>{e.key===`Escape`&&n(!1)};return document.addEventListener(`pointerdown`,e),document.addEventListener(`keydown`,i),()=>{document.removeEventListener(`pointerdown`,e),document.removeEventListener(`keydown`,i)}},[t]),k(`div`,{ref:r,class:`relative`,children:[k(`button`,{type:`button`,onClick:()=>n(e=>!e),"aria-pressed":t,"aria-expanded":t,"aria-haspopup":`true`,"aria-label":t?`Close more controls`:`More controls`,class:`btn btn-control ${t?`btn-primary`:`btn-neutral`}`,children:k(Vy,{name:`more`})}),t&&k(`div`,{role:`menu`,class:`absolute bottom-full mb-1 left-1/2 -translate-x-1/2 flex flex-row items-center gap-1 p-1 rounded-box bg-base-100 border border-base-300 shadow-lg z-30 whitespace-nowrap`,children:e})]})}),YP=ya(({items:e})=>e.length<=1?k(de,{children:e}):k(JP,{items:e})),XP=ya(({onLeave:e})=>{let{joinCall:t,leaveCall:n}=FP(),r=Bg(),{config:i}=ev(),{session:a,end:o}=Gb(),s=Zh(),c=E(null),l=mt(Nv)?.frameRef??c,[u,d]=w(!1),[f,p]=w(!1),[m,h]=w(HP),[g,_]=w(null),v=a.value?.conversationUrl,y=i.value.customization.conversation,b=y.modality===`audio`,x=y.enable_chat,S=y.enable_closed_captions,C=y.enable_picture_in_picture,{pipWindow:ee}=BP({enabled:C,active:r===`joined-meeting`});T(()=>(v&&t({url:v,micOnly:!s}),()=>{n()}),[]);let{camera:te,requestCamera:ne}=bb(),{isCamMuted:re}=pb(),ie=te.isGranted&&!re;T(()=>{!b&&r===`joined-meeting`&&(VP.value=ie)},[b,r,ie]);let ae=E(!b&&!s&&VP.value===!0);T(()=>{r===`joined-meeting`&&ae.current&&(ae.current=!1,ne())},[r,ne]),T(()=>{(r===`left-meeting`||r===`error`)&&e()},[r,e]),T(()=>{let e=()=>{let e=l.current,t=e?.getRootNode(),n=t instanceof Document||t instanceof ShadowRoot?t:null;d(!!e&&n?.fullscreenElement===e)};return document.addEventListener(`fullscreenchange`,e),()=>document.removeEventListener(`fullscreenchange`,e)},[]);let oe=O(()=>{let e=l.current;if(!e)return;let t=e.getRootNode();(t instanceof Document||t instanceof ShadowRoot?t:null)?.fullscreenElement===e?document.exitFullscreen?.():e.requestFullscreen?.()},[]);O(()=>{p(e=>!e)},[]);let se=O(()=>{o(),n()},[o]);if(MP({active:r===`joined-meeting`,onTimeout:se}),PP({onShutdown:se}),!v)return null;let ce=[k(Wb,{compact:!0},`screen-share`)];x&&ce.push(k(ex,{compact:!0},`chat`));let le=r===`left-meeting`;return k(qb,{children:k(Qb,{children:k(Db,{children:[k(`div`,{class:`cvi-call-surface absolute inset-0`,children:[k(`div`,{class:`relative w-full h-full z-[5]`,children:[k(KP,{isAudioOnly:b,canvasLayoutEffect:m,canvasRenderedSlot:g}),!b&&k(GP,{}),k(Xb,{}),k(fP,{debugEnabled:f,onLayoutEffectChange:h,onRenderedSlotChange:_}),k(`div`,{class:`cvi-autohide absolute top-4 right-4 z-20`,"data-hidden":le,children:k(ox,{active:u,onToggle:oe,compact:!0})})]}),k(nx,{}),k(`div`,{class:`cvi-autohide cvi-autohide-slide pointer-events-none absolute bottom-6 left-0 right-0 z-20`,"data-hidden":le,"aria-hidden":le,children:k(`div`,{class:`cvi-control-rail flex justify-center items-center gap-2 @max-mobile:gap-1`,"data-hidden":le,children:[k(zb,{level:!0}),!b&&k(Vb,{}),S&&k(Yb,{}),k(YP,{items:ce}),k(`button`,{type:`button`,class:`btn btn-control btn-error`,onClick:se,"aria-label":`Leave call`,children:k(Vy,{name:`leave`,"aria-label":`Leave Call`})})]})})]}),ee&&Ia(k(_x,{onLeave:se}),ee.document.body)]})})})});function ZP(e){if(!e||e.readyState<2||!e.videoWidth||!e.videoHeight)return null;let t=document.createElement(`canvas`),n=Math.round(640*(e.videoHeight/e.videoWidth));t.width=640,t.height=n;let r=t.getContext(`2d`);if(!r)return null;r.drawImage(e,0,0,640,n);try{return t.toDataURL(`image/jpeg`,.82)}catch{return null}}function QP({loading:e=!1,disabled:t,class:n,children:r,...i}){return k(`button`,{type:`button`,class:`btn relative ${n?` ${n}`:``}`,disabled:t||e,"aria-busy":e||void 0,...i,children:[k(`span`,{children:r}),e&&k(`span`,{class:`absolute inset-0 flex items-center justify-center backdrop-blur-xs`,"aria-hidden":`true`,children:k(`span`,{class:`loading loading-spinner loading-sm`})})]})}function $P(e,t,n){switch(t){case`granted`:return n?e?.cameraOptional??`Camera is optional — turn it on anytime.`:e?.ready??`You're all set — join whenever you're ready.`;case`blocked`:return e?.denied??`Microphone is blocked. Click the mic to see how to allow it.`;case`in-use`:return`Your microphone is in use by another app. Close it and try again.`;case`not-found`:return`No microphone found. Connect one to continue.`;case`unsupported`:return`This browser can't access your microphone.`;case`prompt`:return e?.prompt??`Allow microphone access to join.`;default:return e?.loading??`Getting your microphone ready...`}}function eF({message:e}){return k(`div`,{class:`relative max-w-[min(20rem,90%)]`,children:[k(`div`,{class:`px-4 py-2 rounded-box bg-neutral text-neutral-content text-sm font-medium shadow-lg text-center`,role:`status`,"aria-live":`polite`,children:e}),k(`svg`,{class:`absolute left-1/2 -translate-x-1/2 top-full text-neutral`,width:`16`,height:`8`,viewBox:`0 0 16 8`,"aria-hidden":`true`,children:k(`path`,{d:`M0 0 L8 8 L16 0 Z`,fill:`currentColor`})})]})}var tF=ya(({text:e,isJoining:t=!1,onJoin:n,onCancel:r})=>{let i=ph(),{config:a}=ev(),{localSessionId:o,isCamMuted:s}=pb(),{mic:c,camera:l,requestMic:u,requestCamera:d}=bb(),f=a.value.customization.conversation.modality===`video`;T(()=>{u()},[]);let p=c.isGranted,m=E(!1);T(()=>{!f||!p||m.current||l.isGranted||l.isBlocked||(m.current=!0,d())},[f,p,l.isGranted,l.isBlocked,d]);let h=f&&p&&!l.isGranted,g=$P(e,c.status,h);return k(Db,{children:k(`div`,{class:`absolute inset-0 motion-safe:animate-[tavusFadeUp_280ms_ease-out]`,children:[l.isGranted&&!s?k(`div`,{class:`absolute inset-0 flex items-center justify-center bg-black overflow-hidden`,children:k(dg,{type:`video`,sessionId:o??``,mirror:!0,fit:`cover`,className:`w-full h-full object-cover!`})}):k(`div`,{class:`absolute inset-0 flex items-center justify-center text-base-content/40`,children:k(Vy,{name:`face-smile`,size:`7rem`,"aria-label":`Camera off`})}),k(`div`,{class:`absolute bottom-6 left-1/2 -translate-x-1/2 z-10 flex flex-col items-center gap-2 max-w-[90%]`,children:[g&&k(eF,{message:g}),k(`div`,{class:`flex flex-wrap items-center justify-center gap-1.5 @max-mobile:gap-1`,children:[k(`div`,{class:`flex items-center justify-center gap-1.5 shrink-0 @max-mobile:gap-1`,children:[k(zb,{level:!0}),f&&k(Vb,{})]}),k(QP,{class:`btn-accent `,loading:t,disabled:!p,onClick:n,children:e?.join??`Join Video Chat`}),c.isBlocked&&k(`button`,{type:`button`,class:`btn btn-error `,onClick:()=>{i&&i.leave(),r?.()},children:e?.cancel??`Cancel`})]})]})]})})}),nF=`Password required`,rF=`Enter the password to start this conversation.`,iF=`Password`,aF=`Continue`;function oF({onSubmit:e,text:t,isSubmitting:n=!1,errorMessage:r}){let[i,a]=w(``),o=gt();return k(`div`,{class:`absolute inset-0 z-30 flex items-center justify-center bg-black/50 backdrop-blur-sm p-4`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`${o}-title`,children:k(`form`,{onSubmit:t=>{t.preventDefault();let r=i.trim();!r||n||e(r)},class:`card bg-base-100 shadow-xl w-full max-w-sm`,children:k(`div`,{class:`card-body gap-3`,children:[k(`h3`,{id:`${o}-title`,class:`card-title text-base-content`,children:t?.title??nF}),k(`p`,{class:`text-sm text-base-content/70`,children:t?.description??rF}),k(`input`,{id:o,type:`password`,autocomplete:`current-password`,class:`input input-bordered w-full`,placeholder:t?.placeholder??iF,value:i,disabled:n,onInput:e=>a(e.target.value),autoFocus:!0}),r&&k(`p`,{class:`text-error text-xs`,role:`alert`,children:r}),k(QP,{class:`btn-primary`,type:`submit`,disabled:!i.trim(),loading:n,children:t?.submit??aF})]})})})}var sF=bn(`CaptchaChallenge`),cF=1;function lF(e){return typeof e==`object`&&!!e&&e.source===`tavus-captcha`&&typeof e.type==`string`}function uF(e,t,n,r,i){return`${e.replace(/\/+$/,``)}${t.startsWith(`/`)?t:`/${t}`}?deployment_uuid=${encodeURIComponent(n)}&action=${encodeURIComponent(r)}&parent_origin=${encodeURIComponent(i)}`}function dF({captcha:e,deploymentId:t,onToken:n,onFallback:r}){let i=(mt(Tt).baseUrl??`https://tavusapi.com`).replace(/\/+$/,``),a=new URL(i).origin,[o,s]=w(0),[c,l]=w(0),[u,d]=w(!1),[f,p]=w(!1),m=uF(i,e.challenge_path,t,e.action,window.location.origin),h=O(()=>{p(!1),s(e=>e+1)},[]);return T(()=>{function e(e){if(u||e.origin!==a)return;let i=e.data;if(lF(i)&&i.deployment_uuid===t){if(i.type===`interactive`){p(!0);return}if(i.type===`token`&&i.token){sF.info(`Captcha token received`),p(!1),n(i.token);return}if(i.type===`expired`){sF.info(`Captcha token expired, reloading iframe`),h();return}i.type===`error`&&(sF.warn(`Captcha error received`,i.code),c<cF?(l(e=>e+1),h()):(sF.warn(`Captcha error retries exhausted, falling back to no-token mode`),d(!0),r()))}}return window.addEventListener(`message`,e),()=>window.removeEventListener(`message`,e)},[a,t,c,u,n,r,h]),u?null:k(`div`,{class:f?`absolute inset-0 z-30 flex items-center justify-center p-4 bg-base-100/70 backdrop-blur-sm animate-[tavusFadeUp_180ms_ease-out]`:`absolute top-0 left-0 w-0 h-0 overflow-hidden opacity-0 pointer-events-none`,"aria-hidden":!f,children:k(`iframe`,{src:m,sandbox:`allow-scripts allow-same-origin allow-forms allow-popups`,title:`Security challenge`,style:{border:`none`,width:`300px`,height:`65px`},scrolling:`no`},o)})}function fF({text:e,onStart:t,isStarting:n}){let{config:r,deploymentId:i}=ev(),a=mt(G_),o=Ky(r.value),s=o.btn_title??e?.fallback_button??`Start the conversation`,c=r.value.customization.terms_content?.trim()??``,l=r.value.customization.terms_enabled===!0,u=c.length>0,d=u&&l,f=D(()=>d&&S_(i,c),[d,i,c]),p=d&&!f,m=r.value.has_password===!0,h=a?.password.value??null,g=m&&!h,_=r.value.captcha??null,{captchaReady:v,captchaEpoch:y,handleCaptchaToken:b,handleCaptchaFallback:x}=_v(_,a),S=gt(),[C,ee]=w(f),te=_!==null&&!v,ne=n||d&&!C||g||te;return k(tb,{title:o.title,description:o.description,overlay:k(de,{children:[te&&k(dF,{captcha:_,deploymentId:i,onToken:b,onFallback:x},y),g&&a?k(oF,{onSubmit:a.setPassword}):null]}),children:[k(QP,{class:`btn-neutral rounded-box`,onClick:()=>{d&&C&&!f&&T_(i,c),t()},disabled:ne,loading:n,children:s}),u&&k(`div`,{class:`max-w-xs`,children:p?k(`label`,{for:S,class:`flex items-center gap-2 text-xs text-left cursor-pointer`,children:[k(`input`,{id:S,type:`checkbox`,class:`checkbox checkbox-secondary checkbox-xs mt-0.5 shrink-0`,checked:C,onChange:e=>ee(e.target.checked)}),k(`span`,{class:`leading-snug`,children:c})]}):k(`p`,{class:`text-xs leading-snug text-base-content/60`,children:c})})]})}function pF({flow:e,welcomeText:t,onUnavailableCancel:n}){switch(e.state){case`idle`:return k(fF,{text:t,onStart:()=>{e.start()},isStarting:e.isStarting});case`haircheck`:return k(tF,{onJoin:()=>{e.join()},onCancel:()=>e.cancel(),isJoining:e.isStarting});case`call`:return k(XP,{onLeave:()=>e.leave()});case`ended`:return k(fb,{onRestart:()=>e.restart()});case`unavailable`:return k(ob,{cause:e.unavailableCause??`busy`,canRetry:e.canRetry,onRetry:()=>{e.start()},onCancel:n});default:{let t=e.state;throw Error(`Unreachable flow state: ${String(t)}`)}}}var mF=Le(null);function hF({children:e}){let{config:t}=mt(xi),n=t.peek().customization?.widget,r=n?.expandable??`default`,i=fn(r===`start-expanded`||r===`always`),a=fn(n?.variant??`full`),o=fn(n?.position??`bottom-right`),s=fn(r),c=fn(n?.avatar?.type??`orb`),l=E(r);yn(()=>{let e=t.value.customization?.widget,n=e?.expandable??`default`;a.value=e?.variant??`full`,o.value=e?.position??`bottom-right`,s.value=n,c.value=e?.avatar?.type??`orb`,l.current!==n&&(i.value=n===`start-expanded`||n===`always`,l.current=n)});let u=O(()=>{s.peek()!==`always`&&(i.value=!i.peek())},[i,s]),d=O(()=>{i.value=!0},[i]),f=O(()=>{s.peek()!==`always`&&(i.value=!1)},[i,s]),p=D(()=>({expanded:i,variant:a,position:o,expandable:s,avatarType:c,toggle:u,expand:d,collapse:f}),[i,a,o,s,c,u,d,f]);return k(mF.Provider,{value:p,children:e})}function gF(){let{config:e}=ev(),t=e.value.customization.branding;return e.value.show_tavus_branding!==!1&&!t?.hide_tavus_badge?k(_F,{}):t?.logo||t?.text?k(vF,{logo:t.logo,text:t.text}):null}function _F(){let{isDark:e}=ZN(),t=e.value?`white`:`#140206`;return k(`a`,{href:`https://tavus.io`,target:`_blank`,rel:`noopener noreferrer`,class:`inline-flex items-center gap-1 text-xs text-base-content/50 hover:text-base-content/80 transition-colors`,children:[k(`svg`,{viewBox:`0 0 488 452`,class:`h-2.5 w-2.5 shrink-0`,fill:`none`,"aria-hidden":`true`,children:[k(`path`,{d:`M160 152V208H104V152H160Z`,fill:t}),k(`path`,{"fill-rule":`evenodd`,"clip-rule":`evenodd`,d:`M488 270.5L436 285L451 326L418.766 346L441 360L423 392L435 452H0V0H394.766L488 270.5ZM24 24V428H216.2L209 392L227 360L204.766 346L237 326L222 285L274 270.5L189.038 24H24ZM352 152C336.536 152 324 164.536 324 180C324 195.464 336.536 208 352 208C367.464 208 380 195.464 380 180C380 164.536 367.464 152 352 152Z`,fill:t})]}),k(`span`,{children:[`Powered by `,k(`span`,{class:`underline`,children:`Tavus`})]})]})}function vF({logo:e,text:t}){return k(`div`,{class:`inline-flex items-center gap-1 text-xs text-base-content/50`,children:[e?k(`img`,{src:e,alt:t||`Branding`,class:`h-2.5 shrink-0`}):null,t?k(`span`,{children:t}):null]})}var yF={title:`Hi! Want to chat?`,btn_title:`Start conversation`};function bF(){let{config:e}=ev(),t=e.value.customization.widget?.text;return D(()=>({title:t?.title||yF.title,btn_title:t?.btn_title||yF.btn_title}),[t])}function xF(){let e=mt(mF);if(!e)throw Error(`useWidgetUI must be used within WidgetUIProvider`);return e}var SF={xs:`w-6 h-6`,sm:`w-8 h-8`,md:`w-10 h-10`,lg:`w-16 h-16`},CF={xs:`w-3 h-3`,sm:`w-4 h-4`,md:`w-5 h-5`,lg:`w-8 h-8`};function wF({size:e=`md`,className:t=``}){let{avatarType:n}=xF(),{config:r}=ev(),i=Gy(r.value);return(Ky(r.value).background.type===`replica`||n.value===`image`)&&i?k(`div`,{class:`relative ${SF[e]} rounded-box overflow-hidden bg-base-300 ${t}`,children:k(Xy,{replica:i})}):k(`div`,{class:`relative ${SF[e]} rounded-box bg-primary/15 flex items-center justify-center ${t}`,children:k(`span`,{class:`${CF[e]} rounded-full bg-primary animate-pulse`})})}function TF({variant:e}){let{toggle:t}=xF(),n=bF();return e===`tiny`?k(`button`,{type:`button`,onClick:t,"aria-label":n.btn_title,class:`rounded-box overflow-hidden shadow-xl hover:shadow-2xl transition-shadow cursor-pointer`,children:k(wF,{size:`lg`})}):e===`compact`?k(`button`,{type:`button`,onClick:t,"aria-label":n.btn_title,class:`group flex items-center gap-2.5 py-2.5 pl-2.5 pr-8 rounded-box bg-base-100 text-base-content border border-base-300 shadow-lg hover:shadow-xl transition-shadow cursor-pointer text-left`,children:[k(wF,{size:`md`}),k(`span`,{class:`flex flex-col gap-0.5`,children:[k(`span`,{class:`text-base font-medium leading-tight`,children:n.title}),k(`span`,{class:`text-sm text-base-content/60 leading-tight`,children:n.btn_title})]})]}):k(`button`,{type:`button`,onClick:t,"aria-label":n.btn_title,class:`flex flex-col gap-3 p-3 w-64 rounded-box bg-base-100 text-base-content border border-base-300 shadow-xl hover:shadow-2xl transition-shadow cursor-pointer text-left`,children:[k(`div`,{class:`flex items-center gap-2.5`,children:[k(wF,{size:`md`}),k(`span`,{class:`text-sm font-medium leading-snug`,children:n.title})]}),k(`span`,{class:`btn btn-primary btn-sm w-full pointer-events-none gap-2 flex items-center`,children:[k(Vy,{name:`cam`,size:16}),k(`span`,{className:`leading-4`,children:n.btn_title})]})]})}var EF=`tavus:widget:greeting-dismissed`;function DF({anchor:e}){let t=bF(),{variant:n,expand:r}=xF(),[i,a]=w(!1);T(()=>{if(n.value===`tiny`){try{if(sessionStorage.getItem(EF)===`1`)return}catch{}a(!0)}},[n]);let o=O(e=>{e.stopPropagation();try{sessionStorage.setItem(EF,`1`)}catch{}a(!1)},[]);if(!i)return null;let s=e===`right`?`right-[-6px] border-r border-b`:`left-[-6px] border-l border-t`,c=e===`right`?`-right-2`:`-left-2`;return k(`button`,{type:`button`,onClick:r,class:`relative max-w-56 rounded-box bg-base-100 text-base-content shadow-lg border border-base-300 px-3 py-2 text-sm text-left cursor-pointer animate-[tavusFadeUp_240ms_ease-out] hover:bg-base-200 transition-colors`,children:[k(`p`,{class:`leading-snug pr-3`,children:t.title}),k(`span`,{role:`button`,tabIndex:0,onClick:o,onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&o(e)},class:`absolute -top-2 ${c} btn btn-ghost btn-circle btn-xs bg-base-100 border border-base-300 shadow-sm`,"aria-label":`Dismiss`,children:`×`}),k(`span`,{class:`absolute bottom-3 w-3 h-3 rotate-45 bg-base-100 border-base-300 ${s}`})]})}function OF(){let e=mt(bv);if(!e)throw Error(`useHostBridge must be used within HostBridgeProvider`);return e}var kF=`bg-base-100 text-base-content rounded-box border border-base-300 shadow-xl w-[22rem] flex flex-col animate-[tavusPopIn_180ms_ease-out]`,AF=`bg-base-100 text-base-content w-[100vw] h-[100dvh] flex flex-col animate-[tavusFadeUp_180ms_ease-out]`,jF=`p-1 flex-1 min-h-0`,MF=`p-1 flex-1 min-h-0`;function NF({variant:e,children:t,fullscreen:n}){let{collapse:r,expandable:i}=xF(),a=i.value!==`always`;return n?k(`div`,{class:AF,children:[k(`div`,{class:`flex items-center justify-end gap-2 px-2.5 py-1.5 border-b border-base-300`,children:a&&k(`button`,{type:`button`,class:`btn btn-ghost btn-circle btn-xs`,onClick:r,"aria-label":`Close`,children:k(Vy,{name:`close`,size:14})})}),k(`div`,{class:MF,children:t}),k(`div`,{class:`flex justify-end px-2.5`,children:k(gF,{})})]}):k(`div`,{class:`flex flex-col h-[min(34rem,calc(100dvh-3rem))]`,children:[k(`div`,{class:`${kF} flex-1 overflow-hidden`,children:[k(`div`,{class:`flex items-center justify-end gap-2 px-2.5 pt-1.5 shrink-0`,children:a&&k(`button`,{type:`button`,class:`btn btn-ghost btn-circle btn-xs`,onClick:r,"aria-label":`Close`,children:k(Vy,{name:`close`,size:14})})}),k(`div`,{class:jF,children:t})]}),k(`div`,{class:`flex justify-end pr-2 pt-1.5 shrink-0`,children:k(gF,{})})]})}var PF=bn(`Widget`),FF=`1rem`,IF=480;function LF(){return typeof window>`u`?!1:window.innerWidth<=IF}function RF(e){switch(e){case`bottom-right`:return{bottom:FF,right:FF};case`bottom-left`:return{bottom:FF,left:FF};case`top-right`:return{top:FF,right:FF};case`top-left`:return{top:FF,left:FF};case`top`:return{top:FF,left:`50%`,transform:`translateX(-50%)`};case`bottom`:return{bottom:FF,left:`50%`,transform:`translateX(-50%)`}}}var zF=[`top`,`bottom`,`left`,`right`,`transform`];function BF(e){return e===`bottom-left`||e===`top-left`?`left`:`right`}function VF(){let{config:e,initError:t}=ev(),n=bF(),{expanded:r,position:i,variant:a}=xF(),{shadowHost:o}=OF(),s=sb(),c=fn(LF());T(()=>{if(typeof window>`u`)return;c.value=LF();let e=()=>{c.value=LF()};return window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[c]);let l=D(()=>({fallback_button:n.btn_title}),[n.btn_title]);if(yn(()=>{let e=o.value,t=i.value,n=r.value,a=n&&c.value;if(e){if(a)e.style.top=`0`,e.style.right=`0`,e.style.bottom=`0`,e.style.left=`0`,e.style.transform=``;else{let n=RF(t);for(let t of zF)e.style[t]=n[t]??``}e.dataset.tavusWidgetPosition=t,e.dataset.tavusWidgetExpanded=n?`true`:`false`,e.dataset.tavusWidgetFullscreen=a?`true`:`false`,e.dataset.tavusWidgetSmall=c.value?`true`:`false`}}),t.value)return PF.error(`Widget cannot initialize (init request failed):`,t.value),null;if(e.value.is_available===!1&&e.value.unavailable_reason===`total_limit`)return PF.error(`Widget is unavailable (total_limit reached) — not rendering`),null;if(!r.value){let e=BF(i.value),t=e===`right`?`flex items-end gap-2 justify-end`:`flex items-end gap-2 flex-row-reverse justify-end`,n=e===`right`?`justify-end pr-2`:`justify-start pl-2`;return k(`div`,{class:`flex flex-col`,children:[k(`div`,{class:t,children:[k(DF,{anchor:e}),k(TF,{variant:a.value})]}),k(`div`,{class:`flex ${n} pt-1.5`,children:k(gF,{})})]})}return e.value.is_available===!1?k(NF,{variant:a.value,fullscreen:c.value,children:k(Pv,{children:k(ob,{cause:e.value.unavailable_reason??`daily_limit`,canRetry:!1,onRetry:()=>{}})})}):k(NF,{variant:a.value,fullscreen:c.value,children:k(Pv,{children:k(pF,{flow:s,welcomeText:l,onUnavailableCancel:()=>s.restart()})})})}var HF=`:host {
164
164
  display: block;
165
165
  position: fixed;
166
166
  z-index: 50;
167
167
  background: transparent;
168
168
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
169
- }`;function VF(e){return k(de,{children:[k(`style`,{dangerouslySetInnerHTML:{__html:Xe}}),k(`style`,{dangerouslySetInnerHTML:{__html:BF}}),k(Dt,{"deployment-id":e[`deployment-id`],"override-config":e[`override-config`],"conversational-context":e[`conversational-context`],"custom-greeting":e[`custom-greeting`],"memory-stores":e[`memory-stores`],"base-url":e[`base-url`],token:e.token,children:k(Si,{children:k(wi,{children:k(K_,{children:k(vv,{children:k(Sv,{children:k(wv,{children:k(pF,{children:k(zF,{})})})})})})})})})]})}var HF;function UF(){HF||=He(VF,`tavus-widget`,[`deployment-id`,`override-config`,`conversational-context`,`custom-greeting`,`memory-stores`,`base-url`,`token`],{shadow:!0,mode:`open`})}var WF=[`tavus:chat-message`,`tavus:conversation-ended`,`tavus:conversation-started`,`tavus:error`,`tavus:message`,`tavus:mode-change`,`tavus:protocol-message`,`tavus:ready`,`tavus:state-change`,`tavus:tool-call`],GF=class{element=null;tagName;constructor(e=`tavus-widget`){this.tagName=e,this.element=document.querySelector(this.tagName)}getElement(){if(this.element||=document.querySelector(this.tagName),!this.element)throw Error(`Element <${this.tagName}> not found in the DOM`);return this.element}open(){this.getElement().open?.()}close(){this.getElement().close?.()}startConversation(){this.getElement().startConversation?.()}endConversation(){this.getElement().endConversation?.()}sendMessage(e){let t=this.getElement();if(typeof e==`string`){let n={event_type:`conversation.respond`,properties:{text:e}};t.tavus?.sendMessage?.(n)}else t.tavus?.sendMessage?.(e)}updateConfig(e){this.getElement().updateConfig?.(e)}destroy(){this.getElement().destroy?.(),this.element=null}on(e,t){this.getElement().addEventListener(e,t)}off(e,t){this.getElement().removeEventListener(e,t)}};return typeof window<`u`&&UF(),e.TAVUS_EVENT_NAMES=WF,e.TavusIntegration=GF,e})({});
169
+ }`;function UF(e){return k(de,{children:[k(`style`,{dangerouslySetInnerHTML:{__html:Xe}}),k(`style`,{dangerouslySetInnerHTML:{__html:HF}}),k(Dt,{"deployment-id":e[`deployment-id`],"override-config":e[`override-config`],"conversational-context":e[`conversational-context`],"custom-greeting":e[`custom-greeting`],"memory-stores":e[`memory-stores`],"base-url":e[`base-url`],token:e.token,children:k(Si,{children:k(wi,{children:k(K_,{children:k(vv,{children:k(Sv,{children:k(wv,{children:k(hF,{children:k(VF,{})})})})})})})})})]})}var WF;function GF(){WF||=He(UF,`tavus-widget`,[`deployment-id`,`override-config`,`conversational-context`,`custom-greeting`,`memory-stores`,`base-url`,`token`],{shadow:!0,mode:`open`})}var KF=[`tavus:chat-message`,`tavus:conversation-ended`,`tavus:conversation-started`,`tavus:error`,`tavus:message`,`tavus:mode-change`,`tavus:protocol-message`,`tavus:ready`,`tavus:state-change`,`tavus:tool-call`],qF=class{element=null;tagName;constructor(e=`tavus-widget`){this.tagName=e,this.element=document.querySelector(this.tagName)}getElement(){if(this.element||=document.querySelector(this.tagName),!this.element)throw Error(`Element <${this.tagName}> not found in the DOM`);return this.element}open(){this.getElement().open?.()}close(){this.getElement().close?.()}startConversation(){this.getElement().startConversation?.()}endConversation(){this.getElement().endConversation?.()}sendMessage(e){let t=this.getElement();if(typeof e==`string`){let n={event_type:`conversation.respond`,properties:{text:e}};t.tavus?.sendMessage?.(n)}else t.tavus?.sendMessage?.(e)}updateConfig(e){this.getElement().updateConfig?.(e)}destroy(){this.getElement().destroy?.(),this.element=null}on(e,t){this.getElement().addEventListener(e,t)}off(e,t){this.getElement().removeEventListener(e,t)}};return typeof window<`u`&&GF(),e.TAVUS_EVENT_NAMES=KF,e.TavusIntegration=qF,e})({});