@tavus/embed 0.8.1 → 0.8.2

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.
@@ -48,13 +48,13 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
48
48
  pointer-events: none;
49
49
  `,document.body.appendChild(n),t.layout||=`custom-v1`,e.wrap(n,t)}},{key:`getCallInstance`,value:function(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:void 0;return e?Dm[e]:Object.values(Dm)[0]}}]);var t,n,r,i,a,o,s,c,l,u,d,f,p,m,h,g,_,v,y,b,x,S,C,w,T,E,D,ee,te,ne,re,O,ie,ae,k,A,oe,se}();function Um(e){if(e.extension){if(typeof e.extension!=`string`)throw Error(`Error starting dial out: extension must be a string`);if(e.extension.length>20)throw Error(`Error starting dial out: extension length must be less than or equal to 20`)}if(e.waitBeforeExtensionDialSec){if(typeof e.waitBeforeExtensionDialSec!=`number`)throw Error(`Error starting dial out: waitBeforeExtensionDialSec must be a number`);if(e.waitBeforeExtensionDialSec>60)throw Error(`Error starting dial out: waitBeforeExtensionDialSec must be less than or equal to 60`);if(!e.extension)throw Error(`Error starting dial out: waitBeforeExtensionDialSec requires a phoneNumber and extension`)}}function Wm(e,t){var n={};for(var r in e)if(e[r]instanceof MediaStreamTrack)console.warn(`MediaStreamTrack found in props or cache.`,r),n[r]=Vf;else if(r===`dailyConfig`){if(e[r].modifyLocalSdpHook){var i=window._daily.instances[t].customCallbacks||{};i.modifyLocalSdpHook=e[r].modifyLocalSdpHook,window._daily.instances[t].customCallbacks=i,delete e[r].modifyLocalSdpHook}if(e[r].modifyRemoteSdpHook){var a=window._daily.instances[t].customCallbacks||{};a.modifyRemoteSdpHook=e[r].modifyRemoteSdpHook,window._daily.instances[t].customCallbacks=a,delete e[r].modifyRemoteSdpHook}n[r]=e[r]}else n[r]=e[r];return n}function Gm(e){var t=arguments.length>2?arguments[2]:void 0;if(e!==`joined-meeting`){var n=`${arguments.length>1&&arguments[1]!==void 0?arguments[1]:`This daily-js method`} only supported after join.`;throw t&&(n+=` ${t}`),console.error(n),Error(n)}}function Km(e,t){return[`joining-meeting`,`joined-meeting`].includes(e)||t}function qm(e,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:`This daily-js method`,r=arguments.length>3?arguments[3]:void 0;if(Km(e,t)){var i=`${n} not supported after joining a meeting.`;throw r&&(i+=` ${r}`),console.error(i),Error(i)}}function Jm(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:`This daily-js method`,n=arguments.length>2?arguments[2]:void 0;if(!e){var r=`${t}${arguments.length>3&&arguments[3]!==void 0&&arguments[3]?` requires preAuth() or startCamera() to initialize call state.`:` requires preAuth(), startCamera(), or join() to initialize call state.`}`;throw n&&(r+=` ${n}`),console.error(r),Error(r)}}function Ym(e){if(e){var t=`A pre-call quality test is in progress. Please try ${arguments.length>1&&arguments[1]!==void 0?arguments[1]:`This daily-js method`} again once testing has completed. Use stopTestCallQuality() to end it early.`;throw console.error(t),Error(t)}}function Xm(e){if(!e){var t=`${arguments.length>1&&arguments[1]!==void 0?arguments[1]:`This daily-js method`} is only supported on custom callObject instances`;throw console.error(t),Error(t)}}function Zm(e){if(e){var t=`${arguments.length>1&&arguments[1]!==void 0?arguments[1]:`This daily-js method`} is only supported as part of Daily's Prebuilt`;throw console.error(t),Error(t)}}function Qm(){if(Qf())throw Error(`This daily-js method is not currently supported in React Native`)}function $m(){if(!Qf())throw Error(`This daily-js method is only supported in React Native`)}function eh(e){if(e===void 0)return!0;var t;if(typeof e==`string`)t=e;else try{t=JSON.stringify(e),Jo(JSON.parse(t),e)||console.warn(`The userData provided will be modified when serialized.`)}catch(e){throw Error(`userData must be serializable to JSON: ${e}`)}if(t.length>4096)throw Error(`userData is too large (${t.length} characters). Maximum size suppported is 4096.`);return!0}function th(e,t){for(var n=t.allowAllParticipantsKey,r=function(e){var t=[`local`];return n||t.push(`*`),e&&!t.includes(e)},i=function(e){return!!(e.layer===void 0||Number.isInteger(e.layer)&&e.layer>=0||e.layer===`inherit`)},a=function(e){return!!e&&!(e.video&&!i(e.video))&&!(e.screenVideo&&!i(e.screenVideo))},o=0,s=Object.entries(e);o<s.length;o++){var c=Bo(s[o],2),l=c[0],u=c[1];if(!r(l)||!a(u))return!1}return!0}function nh(e){if(Oo(e)!==`object`)return!1;for(var t=0,n=Object.entries(e);t<n.length;t++){var r=Bo(n[t],2),i=r[0],a=r[1];switch(i){case`video`:if(Oo(a)!==`object`)return!1;for(var o=0,s=Object.entries(a);o<s.length;o++){var c=Bo(s[o],2),l=c[0],u=c[1];switch(l){case`processor`:if(!ah(u))return!1;break;case`settings`:if(!oh(u))return!1;break;default:return!1}}break;case`audio`:if(Oo(a)!==`object`)return!1;for(var d=0,f=Object.entries(a);d<f.length;d++){var p=Bo(f[d],2),m=p[0],h=p[1];switch(m){case`processor`:if(!ih(h))return!1;break;case`settings`:if(!oh(h))return!1;break;default:return!1}}break;default:return!1}}return!0}function rh(e,t,n){var r,i=[];e.video&&e.video.processor&&(op((r=t?.useLegacyVideoProcessor)!=null&&r)||(e.video.settings?delete e.video.processor:delete e.video,i.push(`video`))),e.audio&&e.audio.processor&&(sp()||(e.audio.settings?delete e.audio.processor:delete e.audio,i.push(`audio`))),i.length>0&&console.error(`Ignoring settings for browser- or platform-unsupported input processor(s): ${i.join(`, `)}`),e.audio&&e.audio.settings&&(e.audio.settings.customTrack?(n.audioTrack=e.audio.settings.customTrack,e.audio.settings={customTrack:Vf}):delete n.audioTrack),e.video&&e.video.settings&&(e.video.settings.customTrack?(n.videoTrack=e.video.settings.customTrack,e.video.settings={customTrack:Vf}):delete n.videoTrack)}function ih(e){if(Qf())return console.warn(`Video processing is not yet supported in React Native`),!1;var t=[`type`];return!!e&&Oo(e)===`object`&&(Object.keys(e).filter(function(e){return!t.includes(e)}).forEach(function(t){console.warn(`invalid key inputSettings -> audio -> processor : ${t}`),delete e[t]}),!!function(e){return typeof e==`string`?Object.values(Uf).includes(e)?!0:(console.error(`inputSettings audio processor type invalid`),!1):!1}(e.type))}function ah(e){if(Qf())return console.warn(`Video processing is not yet supported in React Native`),!1;var t=[`type`,`config`];return!e||Oo(e)!==`object`||!function(e){return typeof e==`string`?Object.values(Hf).includes(e)?!0:(console.error(`inputSettings video processor type invalid`),!1):!1}(e.type)||e.config&&(Oo(e.config)!==`object`||!function(e,t){var n=Object.keys(t);if(n.length===0)return!0;var r=`invalid object in inputSettings -> video -> processor -> config`;switch(e){case Hf.BGBLUR:return n.length>1||n[0]!==`strength`?(console.error(r),!1):!(typeof t.strength!=`number`||t.strength<=0||t.strength>1||isNaN(t.strength))||(console.error(`${r}; expected: {0 < strength <= 1}, got: ${t.strength}`),!1);case Hf.BGIMAGE:return!(t.source!==void 0&&!function(e){if(e.source==="default")return e.type=`default`,!0;if(e.source instanceof ArrayBuffer)return!0;if(hs(e.source))return e.type=`url`,!!function(e){var t=new URL(e),n=t.pathname;if(t.protocol===`data:`)try{var r=n.substring(n.indexOf(`:`)+1,n.indexOf(`;`)).split(`/`)[1];return qf.includes(r)}catch(e){return console.error(`failed to deduce blob content type`,e),!1}var i=n.split(`.`).at(-1).toLowerCase().trim();return qf.includes(i)}(e.source)||(console.error(`invalid image type; supported types: [${qf.join(`, `)}]`),!1);return t=e.source,n=Number(t),isNaN(n)||!Number.isInteger(n)||n<=0||n>10?(console.error(`invalid image selection; must be an int, > 0, <= 10`),!1):(e.type=`daily-preselect`,!0);var t,n}(t));default:return!0}}(e.type,e.config))?!1:(Object.keys(e).filter(function(e){return!t.includes(e)}).forEach(function(t){console.warn(`invalid key inputSettings -> video -> processor : ${t}`),delete e[t]}),!0)}function oh(e){return Oo(e)===`object`&&(!e.customTrack||e.customTrack instanceof MediaStreamTrack)}function sh(){return`inputSettings must be of the form: { video?: { processor?: { type: [ ${Object.values(Hf).join(` | `)} ], config?: {} } }, audio?: { processor: {type: [ ${Object.values(Uf).join(` | `)} ] } } }`}function ch(e){return`receiveSettings must be of the form { [<remote participant id> | ${Fd}${e.allowAllParticipantsKey?` | "*"`:``}]: { [video: [{ layer: [<non-negative integer> | "inherit"] } | "inherit"]], [screenVideo: [{ layer: [<non-negative integer> | "inherit"] } | "inherit"]] }}}`}function lh(){return`customIntegrations should be an object of type ${JSON.stringify(Lm)}.`}function uh(e){if(e&&Oo(e)!==`object`||Array.isArray(e))return console.error(`customTrayButtons should be an Object of the type ${JSON.stringify(Im)}.`),!1;if(e)for(var t=0,n=Object.entries(e);t<n.length;t++)for(var r=Bo(n[t],1)[0],i=0,a=Object.entries(e[r]);i<a.length;i++){var o=Bo(a[i],2),s=o[0],c=o[1],l=Im.id[s];if(!l)return console.error(`customTrayButton does not support key ${s}`),!1;switch(s){case`iconPath`:case`iconPathDarkMode`:if(!hs(c))return console.error(`customTrayButton ${s} should be a url.`),!1;break;case`visualState`:if(![`default`,`sidebar-open`,`active`].includes(c))return console.error(`customTrayButton ${s} should be ${l}. Got: ${c}`),!1;break;default:if(Oo(c)!==l)return console.error(`customTrayButton ${s} should be a ${l}.`),!1}}return!0}function dh(e){if(!e||e&&Oo(e)!==`object`||Array.isArray(e))return console.error(lh()),!1;for(var t=function(e){return`${e} should be ${Lm.id[e]}`},n=function(e,t){return console.error(`customIntegration ${e}: ${t}`)},r=0,i=Object.entries(e);r<i.length;r++){var a=Bo(i[r],1)[0];if(!(`label`in e[a]))return n(a,`label is required`),!1;if(!(`location`in e[a]))return n(a,`location is required`),!1;if(!(`src`in e[a])&&!(`srcdoc`in e[a]))return n(a,`src or srcdoc is required`),!1;for(var o=0,s=Object.entries(e[a]);o<s.length;o++){var c=Bo(s[o],2),l=c[0],u=c[1];switch(l){case`allow`:case`csp`:case`name`:case`referrerPolicy`:case`sandbox`:if(typeof u!=`string`)return n(a,t(l)),!1;break;case`iconURL`:if(!hs(u))return n(a,`${l} should be a url`),!1;break;case`src`:if(`srcdoc`in e[a])return n(a,`cannot have both src and srcdoc`),!1;if(!hs(u))return n(a,`src "${u}" is not a valid URL`),!1;break;case`srcdoc`:if(`src`in e[a])return n(a,`cannot have both src and srcdoc`),!1;if(typeof u!=`string`)return n(a,t(l)),!1;break;case`location`:if(![`main`,`sidebar`].includes(u))return n(a,t(l)),!1;break;case`controlledBy`:if(u!==`*`&&u!==`owners`&&(!Array.isArray(u)||u.some(function(e){return typeof e!=`string`})))return n(a,t(l)),!1;break;case`shared`:if((!Array.isArray(u)||u.some(function(e){return typeof e!=`string`}))&&u!==`owners`&&typeof u!=`boolean`)return n(a,t(l)),!1;break;default:if(!Lm.id[l])return console.error(`customIntegration does not support key ${l}`),!1}}}return!0}function fh(e,t){if(t===void 0)return!1;switch(Oo(t)){case`string`:return Oo(e)===t;case`object`:if(Oo(e)!==`object`)return!1;for(var n in e)if(!fh(e[n],t[n]))return!1;return!0;default:return!1}}function ph(e,t){var n=e.sessionId,r=e.toEndPoint,i=e.callerId,a=e.useSipRefer;if(!n||!r)throw Error(`${t}() requires a sessionId and toEndPoint`);if(typeof n!=`string`||typeof r!=`string`)throw Error(`Invalid paramater: sessionId and toEndPoint must be of type string`);if(a&&!r.startsWith(`sip:`))throw Error(`"toEndPoint" must be a "sip" address`);if(!r.startsWith(`sip:`)&&!r.startsWith(`+`))throw Error(`toEndPoint: ${r} must starts with either "sip:" or "+"`);if(i&&typeof i!=`string`)throw Error(`callerId must be of type string`);if(i&&!r.startsWith(`+`))throw Error(`callerId is only valid when transferring to a PSTN number`)}function mh(e){if(Oo(e)!==`object`)throw Error(`RemoteMediaPlayerSettings: must be "object" type`);if(e.state&&!Object.values(Wf).includes(e.state))throw Error(`Invalid value for RemoteMediaPlayerSettings.state, valid values are: `+JSON.stringify(Wf));if(e.volume){if(typeof e.volume!=`number`)throw Error(`RemoteMediaPlayerSettings.volume: must be "number" type`);if(e.volume<0||e.volume>2)throw Error(`RemoteMediaPlayerSettings.volume: must be between 0.0 - 2.0`)}}function hh(e,t,n){return!(typeof e!=`number`||e<t||e>n)}function gh(e,t){return e&&!t&&delete e.data,e}function _h(e){"@babel/helpers - typeof";return _h=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},_h(e)}var W=function(){return W=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n],t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},W.apply(this,arguments)};function vh(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols==`function`)for(var i=0,r=Object.getOwnPropertySymbols(e);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(n[r[i]]=e[r[i]]);return n}function yh(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})}function bh(e,t){var n={label:0,sent:function(){if(a[0]&1)throw a[1];return a[1]},trys:[],ops:[]},r,i,a,o;return o={next:s(0),throw:s(1),return:s(2)},typeof Symbol==`function`&&(o[Symbol.iterator]=function(){return this}),o;function s(e){return function(t){return c([e,t])}}function c(s){if(r)throw TypeError(`Generator is already executing.`);for(;o&&(o=0,s[0]&&(n=0)),n;)try{if(r=1,i&&(a=s[0]&2?i.return:s[0]?i.throw||((a=i.return)&&a.call(i),0):i.next)&&!(a=a.call(i,s[1])).done)return a;switch(i=0,a&&(s=[s[0]&2,a.value]),s[0]){case 0:case 1:a=s;break;case 4:return n.label++,{value:s[1],done:!1};case 5:n.label++,i=s[1],s=[0];continue;case 7:s=n.ops.pop(),n.trys.pop();continue;default:if((a=n.trys,!(a=a.length>0&&a[a.length-1]))&&(s[0]===6||s[0]===2)){n=0;continue}if(s[0]===3&&(!a||s[1]>a[0]&&s[1]<a[3])){n.label=s[1];break}if(s[0]===6&&n.label<a[1]){n.label=a[1],a=s;break}if(a&&n.label<a[2]){n.label=a[2],n.ops.push(s);break}a[2]&&n.ops.pop(),n.trys.pop();continue}s=t.call(e,n)}catch(e){s=[6,e],i=0}finally{r=a=0}if(s[0]&5)throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}}function xh(e){var t=typeof Symbol==`function`&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&typeof e.length==`number`)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw TypeError(t?`Object is not iterable.`:`Symbol.iterator is not defined.`)}function Sh(e,t){var n=typeof Symbol==`function`&&e[Symbol.iterator];if(!n)return e;var r=n.call(e),i,a=[],o;try{for(;(t===void 0||t-->0)&&!(i=r.next()).done;)a.push(i.value)}catch(e){o={error:e}}finally{try{i&&!i.done&&(n=r.return)&&n.call(r)}finally{if(o)throw o.error}}return a}function Ch(e,t,n){if(n||arguments.length===2)for(var r=0,i=t.length,a;r<i;r++)(a||!(r in t))&&(a||=Array.prototype.slice.call(t,0,r),a[r]=t[r]);return e.concat(a||Array.prototype.slice.call(t))}var wh=Ae(null),Th=function(){var e=I(wh);return st(e),e},Eh=Ae({on:function(){},off:function(){}}),Dh=-1,Oh=function(){return Dh--},kh=1,Ah=function(){return kh++},G=function(e,t,n){n===void 0&&(n=!1);var r=I(Eh),i=r.off,a=r.on,o=Sh(j(!1),2),s=o[0],c=o[1],l=N(0),u=P(function(){return n?Oh():Ah()},[n]);M(function(){if(!(!e||s)){if(l.current>1e5){console.error(`useDailyEvent called with potentially non-memoized event callback or due to too many re-renders.
50
50
  Memoize using useCallback to avoid re-render loop or reduce the amount of state transitions the callback depends on.
51
- Passed callback for '${e}' event is NOT registered.`,t),c(!0);return}l.current++;var n=setTimeout(function(){l.current=0},50);return a(e,t,u),function(){clearTimeout(n),i(e,u)}}},[t,e,u,s,i,a]),st({event:e,eventId:u,isBlocked:s,callback:t})};function jh(e,t){var n,r;if(e===t)return!0;if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return!1;for(var i=0;i<e.length;i++)if(!jh(e[i],t[i]))return!1;return!0}if(MediaStream&&e instanceof MediaStream&&t instanceof MediaStream)return e.id===t.id&&e.active===t.active&&e.getTracks().length===t.getTracks().length&&e.getTracks().every(function(e,n){return jh(e,t.getTracks()[n])});if(MediaStreamTrack&&e instanceof MediaStreamTrack&&t instanceof MediaStreamTrack)return e.id===t.id&&e.kind===t.kind&&e.readyState===t.readyState;if(e instanceof Date&&t instanceof Date)return e.getTime()===t.getTime();if(e instanceof RegExp&&t instanceof RegExp)return e.source===t.source&&e.flags===t.flags;if(e instanceof Set&&t instanceof Set){if(e.size!==t.size)return!1;var a=Array.from(e).sort(),o=Array.from(t).sort();return a.every(function(e,t){return jh(e,o[t])})}if(e instanceof Map&&t instanceof Map){if(e.size!==t.size)return!1;try{for(var s=xh(e.entries()),c=s.next();!c.done;c=s.next()){var l=Sh(c.value,2),u=l[0],d=l[1];if(!t.has(u)||!jh(d,t.get(u)))return!1}}catch(e){n={error:e}}finally{try{c&&!c.done&&(r=s.return)&&r.call(s)}finally{if(n)throw n.error}}return!0}if(_h(e)!==`object`||e===null||_h(t)!==`object`||t===null)return!1;var f=Object.keys(e),p=Object.keys(t);if(f.length!==p.length)return!1;for(var i=0;i<f.length;i++){var u=f[i];if(!Object.prototype.hasOwnProperty.call(t,u)||!jh(e[u],t[u]))return!1}return!0}function Mh(e,t){if(e===t)return!0;if(e.length!==t.length)return!1;for(var n=0;n<e.length;n++){var r=e[n],i=t[n],a=r!==null&&_h(r)===`object`,o=i!==null&&_h(i)===`object`;if(a||o){if(!jh(r,i))return!1}else if(r!==i)return!1}return!0}function Nh(e){return`daily-react-`+e}function Ph(e){var t=new Map,n=new Map;return function(r){if(!t.has(r)){var i=ua(function(t){var i=e.get(r)(t),a=n.get(r);return a!=null&&e.equals(i,a)?a:(n.set(r,i),i)});t.set(r,i)}return t.get(r)}}var Fh=`::`,Ih=`;`,Lh=function(e,t){return e+Fh+t},Rh=function(e,t){return e+Fh+t.join(Ih)},zh=function(e,t){return Vh(Lh(e,t))},Bh=To(function(e){var t=ua([]);return t.debugLabel=Nh(`participant-property-paths-${e}`),t}),Vh=To(function(e){var t=ua(null);return t.debugLabel=Nh(`participant-property-${e}`),t}),Hh=Ph({equals:Mh,get:function(e){return function(t){var n=Sh(e.split(Fh),2),r=n[0];return n[1].split(Ih).map(function(e){return t(zh(r,e))})}}}),Uh=function(e,t){var n,r=So(Array.isArray(t)?Hh(Rh(e,t)):Vh(Lh(e,t)));return st(Array.isArray(t)?t.reduce(function(e,t,n){return e[t]=r[n],e},{}):(n={},n[t]=r,n)),r},Wh=typeof globalThis<`u`?globalThis:typeof window<`u`?window:typeof global<`u`?global:typeof self<`u`?self:{};function Gh(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,`default`)?e.default:e}var Kh,qh;function Jh(){if(qh)return Kh;qh=1;var e=`Expected a function`,t=NaN,n=`[object Symbol]`,r=/^\s+|\s+$/g,i=/^[-+]0x[0-9a-f]+$/i,a=/^0b[01]+$/i,o=/^0o[0-7]+$/i,s=parseInt,c=_h(Wh)==`object`&&Wh&&Wh.Object===Object&&Wh,l=(typeof self>`u`?`undefined`:_h(self))==`object`&&self&&self.Object===Object&&self,u=c||l||Function(`return this`)(),d=Object.prototype.toString,f=Math.max,p=Math.min,m=function(){return u.Date.now()};function h(t,n,r){var i,a,o,s,c,l,u=0,d=!1,h=!1,g=!0;if(typeof t!=`function`)throw TypeError(e);n=b(n)||0,_(r)&&(d=!!r.leading,h=`maxWait`in r,o=h?f(b(r.maxWait)||0,n):o,g=`trailing`in r?!!r.trailing:g);function v(e){var n=i,r=a;return i=a=void 0,u=e,s=t.apply(r,n),s}function y(e){return u=e,c=setTimeout(C,n),d?v(e):s}function x(e){var t=e-l,r=e-u,i=n-t;return h?p(i,o-r):i}function S(e){var t=e-l,r=e-u;return l===void 0||t>=n||t<0||h&&r>=o}function C(){var e=m();if(S(e))return w(e);c=setTimeout(C,x(e))}function w(e){return c=void 0,g&&i?v(e):(i=a=void 0,s)}function T(){c!==void 0&&clearTimeout(c),u=0,i=l=a=c=void 0}function E(){return c===void 0?s:w(m())}function D(){var e=m(),t=S(e);if(i=arguments,a=this,l=e,t){if(c===void 0)return y(l);if(h)return c=setTimeout(C,n),v(l)}return c===void 0&&(c=setTimeout(C,n)),s}return D.cancel=T,D.flush=E,D}function g(t,n,r){var i=!0,a=!0;if(typeof t!=`function`)throw TypeError(e);return _(r)&&(i=`leading`in r?!!r.leading:i,a=`trailing`in r?!!r.trailing:a),h(t,n,{leading:i,maxWait:n,trailing:a})}function _(e){var t=_h(e);return!!e&&(t==`object`||t==`function`)}function v(e){return!!e&&_h(e)==`object`}function y(e){return _h(e)==`symbol`||v(e)&&d.call(e)==n}function b(e){if(typeof e==`number`)return e;if(y(e))return t;if(_(e)){var n=typeof e.valueOf==`function`?e.valueOf():e;e=_(n)?n+``:n}if(typeof e!=`string`)return e===0?e:+e;e=e.replace(r,``);var c=a.test(e);return c||o.test(e)?s(e.slice(2),c?2:8):i.test(e)?t:+e}return Kh=g,Kh}var Yh=Gh(Jh()),Xh=function(e,t,n,r){n===void 0&&(n=500),r===void 0&&(r=!1);var i=I(Eh),a=i.off,o=i.on,s=P(function(){var t;return Array.isArray(e)?e.reduce(function(e,t){return e[t]=r?Oh():Ah(),e},{}):(t={},t[e]=r?Oh():Ah(),t)},[e,r]),c=N([]);G(`call-instance-destroyed`,F(function(){c.current.length=0},[]));var l=P(function(){return Yh(function(){c.current.length!==0&&(t(c.current),c.current.length=0)},n,{trailing:!0})},[t,n]);M(function(){if(e){var t=function(e){c.current.push(e),l()};return Array.isArray(e)?e.forEach(function(e){return o(e,t,s[e])}):o(e,t,s[e]),function(){Array.isArray(e)?e.forEach(function(e){return a(e,s[e])}):a(e,s[e])}}},[l,e,s,a,o]),st({event:e,eventId:s})},Zh=function(e,t,n){if(t===void 0&&(t=``),n===void 0&&(n=new Set),_h(e)!==`object`||e===null||n.has(e))return[t];n.add(e);var r=[];for(var i in e)if(Object.prototype.hasOwnProperty.call(e,i)){var a=t?`${t}.${i}`:i;r.push.apply(r,Ch([a],Sh(Zh(e[i],a,n)),!1))}return n.delete(e),r},Qh=function(e){return Zh(e)},$h=function(e,t){return String(t).split(`.`).filter(function(e){return e.length}).reduce(function(e,t){return e&&e[t]},e)},eg=function(e,t){return t.map(function(t){return $h(e,t)})},tg=ua(null);tg.debugLabel=Nh(`active-id`);var ng=ua(``);ng.debugLabel=Nh(`local-id`);var rg=ua(null);rg.debugLabel=Nh(`local-join-date`);var ig=ua([]);ig.debugLabel=Nh(`participant-ids`);var ag=To(function(e){var t=ua(null);return t.debugLabel=Nh(`participant-${e}`),t}),og=ua([]);og.debugLabel=Nh(`waiting-participants`);var sg=To(function(e){var t=ua({awaitingAccess:{level:`full`},id:e,name:``});return t.debugLabel=Nh(`waiting-participant-${e}`),t}),cg=function(e){var t=e.children,n=Th(),r=Sh(j(!1),2),i=r[0],a=r[1],o=wo(F(function(e,t,n){t(ng,n.local.session_id);var r=Object.values(n);t(ig,r.map(function(e){return e.session_id})),r.forEach(function(e){t(ag(e.session_id),e);var n=Qh(e);t(Bh(e.session_id),n),n.forEach(function(n){var r=Sh(eg(e,[n]),1)[0];t(zh(e.session_id,n),r)})}),a(!0)},[]));M(function(){if(!(!n||i)){var e=setInterval(function(){var t=n.participants();`local`in t&&(o(t),clearInterval(e))},100);return function(){clearInterval(e)}}},[n,i,o]);var s=F(function(){if(n){var e=n?.participants();e.local&&o(e)}},[n,o]);G(`started-camera`,s,!0),G(`access-state-updated`,s,!0),G(`joining-meeting`,wo(F(function(e,t){t(rg,new Date),s()},[s])),!0),G(`joined-meeting`,F(function(e){o(e.participants)},[o]),!0);var c=wo(F(function(e,t){t(ng,``),t(tg,null),e(ig).forEach(function(e){return ag.remove(e)}),t(ig,[])},[]));return G(`call-instance-destroyed`,c,!0),G(`left-meeting`,c,!0),Xh([`active-speaker-change`,`participant-joined`,`participant-updated`,`participant-left`],wo(F(function(e,t,n){n.length&&n.forEach(function(n){switch(n.action){case`active-speaker-change`:t(tg,n.activeSpeaker.peerId),t(ag(n.activeSpeaker.peerId),function(e){return e?W(W({},e),{last_active:new Date}):null});break;case`participant-joined`:t(ig,function(e){return e.includes(n.participant.session_id)?e:Ch(Ch([],Sh(e),!1),[n.participant.session_id],!1)}),t(ag(n.participant.session_id),n.participant);var r=Qh(n.participant);t(Bh(n.participant.session_id),r),r.forEach(function(e){var r=Sh(eg(n.participant,[e]),1)[0];t(zh(n.participant.session_id,e),r)});break;case`participant-updated`:t(ag(n.participant.session_id),n.participant),n.participant.local&&t(ng,n.participant.session_id);var r=Qh(n.participant),i=e(Bh(n.participant.session_id));(r.length!==i.length||r.some(function(e){return!i.includes(e)}))&&t(Bh(n.participant.session_id),r);var a=new Set(i),o=eg(n.participant,r);r.forEach(function(e,r){var i=o[r];a.delete(e),t(zh(n.participant.session_id,e),function(e){return jh(e,i)?e:i})}),a.forEach(function(e){t(zh(n.participant.session_id,e),null)});break;case`participant-left`:t(ig,function(e){return e.includes(n.participant.session_id)?e.filter(function(e){return e!==n.participant.session_id}):e}),ag.remove(n.participant.session_id),e(Bh(n.participant.session_id)).forEach(function(e){Vh.remove(Lh(n.participant.session_id,e))}),Bh.remove(n.participant.session_id);break}})},[])),100,!0),Xh([`waiting-participant-added`,`waiting-participant-updated`,`waiting-participant-removed`],wo(F(function(e,t,n){n.forEach(function(e){switch(e.action){case`waiting-participant-added`:t(og,function(t){return t.includes(e.participant.id)?t:Ch(Ch([],Sh(t),!1),[e.participant.id],!1)}),t(sg(e.participant.id),e.participant);break;case`waiting-participant-updated`:t(sg(e.participant.id),e.participant);break;case`waiting-participant-removed`:t(og,function(t){return t.filter(function(t){return t!==e.participant.id})}),sg.remove(e.participant.id);break}})},[])),100,!0),po.createElement(po.Fragment,null,t)},lg=function(){var e=So(ng);return st(e),e},ug=function(){return!0},dg=function(e){var t=e===void 0?{}:e,n=t.filter,r=n===void 0?ug:n,i=t.ignoreLocal,a=i===void 0?!1:i,o=lg(),s=So(tg),c=a&&s===o,l=!r?.(s),u=Sh(j(!c&&!l?s:null),2),d=u[0],f=u[1];return M(function(){c||l||f(s)},[l,c,s]),st(d),d},fg=function(e){return[`blocked`,`off`].includes(e)},pg=`;`,mg=function(e,t){return`${e}${pg}${t}`},hg=Ph({equals:jh,get:function(e){return function(t){var n=Sh(e.split(pg),2),r=n[0],i=n[1];return t(ig).filter(function(e){switch(r){case`local`:case`owner`:case`record`:return t(zh(e,r));case`remote`:return!t(zh(e,`local`));case`screen`:var n=t(zh(e,`tracks.screenAudio.state`)),i=t(zh(e,`tracks.screenVideo.state`));return!fg(n)||!fg(i);default:return!0}}).sort(function(e,n){switch(i){case`joined_at`:case`session_id`:case`user_id`:case`user_name`:var r=t(zh(e,i)),a=t(zh(n,i));if(r!==void 0||a!==void 0){if(r===void 0)return-1;if(a===void 0||r>a)return 1;if(r<a)return-1}return 0;default:return 0}})}}}),gg=function(e){var t=e===void 0?{}:e,n=t.filter,r=t.onActiveSpeakerChange,i=t.onParticipantJoined,a=t.onParticipantLeft,o=t.onParticipantUpdated,s=t.sort,c=So(hg(mg(typeof n==`string`?n:null,typeof s==`string`?s:null))),l=typeof n==`function`||typeof s==`function`,u=F(function(e){return typeof n!=`function`&&typeof s!=`function`?[]:c.map(function(t){return e(ag(t))}).filter(function(e){return!!e}).filter(typeof n==`function`?n:function(){return!0}).sort(typeof s==`function`?s:function(){return 0}).map(function(e){return e.session_id}).filter(Boolean)},[n,c,s]),d=Sh(j([]),2),f=d[0],p=d[1],m=wo(F(function(e){if(l){var t=u(e);jh(t,f)||p(t)}},[f,u,l]));M(function(){m()},[m]),Xh([`participant-joined`,`participant-updated`,`active-speaker-change`,`participant-left`],F(function(e){e.length&&(e.forEach(function(e){switch(e.action){case`participant-joined`:i?.(e);break;case`participant-updated`:o?.(e);break;case`active-speaker-change`:r?.(e);break;case`participant-left`:a?.(e);break}}),m())},[m,r,i,a,o]));var h=typeof n==`function`||typeof s==`function`?f:c;return st(h),h},_g=Ph({equals:Mh,get:function(){return function(e){return e(hg(mg(`screen`,null))).map(function(t){return{local:e(zh(t,`local`)),screenAudio:e(zh(t,`tracks.screenAudio`)),screenVideo:e(zh(t,`tracks.screenVideo`)),screenId:`${t}-screen`,session_id:t}})}}}),vg=function(e){var t=e===void 0?{}:e,n=t.onError,r=t.onLocalScreenShareStarted,i=t.onLocalScreenShareStopped,a=Th(),o=F(function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];a?.startScreenShare.apply(a,Ch([],Sh(e),!1))},[a]),s=F(function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];a?.stopScreenShare.apply(a,Ch([],Sh(e),!1))},[a]);G(`local-screen-share-started`,F(function(){return r?.()},[r])),G(`local-screen-share-stopped`,F(function(){return i?.()},[i])),G(`nonfatal-error`,F(function(e){e.type===`screen-share-error`&&n?.(e)},[n]));var c=So(_g(void 0)),l={isSharingScreen:c.some(function(e){return e.local}),screens:c,startScreenShare:o,stopScreenShare:s};return st(l),l},yg=function(e,t){t===void 0&&(t=`video`);var n=Uh(e,`tracks.${t}`),r=n?W(W({},n),{isOff:fg(n.state)}):{isOff:!0,persistentTrack:void 0,state:`off`,subscribed:!1};return st(r),r};function bg(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return F(function(t){for(var n=0;n<e.length;n++){var r=e[n];typeof r==`function`?r(t):r&&_h(r)===`object`&&(r.current=t)}},e)}var xg=Ea(ka(function(e,t){var n=e.onPlayFailed,r=e.sessionId,i=e.type,a=i===void 0?`audio`:i,o=vh(e,[`onPlayFailed`,`sessionId`,`type`]),s=N(null),c=yg(r,a),l=bg(s,t),u=c?.subscribed;return M(function(){var e=s.current;if(!(!e||!c?.persistentTrack)){if(!MediaStream){console.warn(`MediaStream API not available. Can't setup ${a} for ${r}`),n?.({sessionId:r,target:e,type:a,message:`MediaStream API not available`,name:`MediaStream API not available`});return}var t=function(){e.play().catch(function(t){n?.({sessionId:r,target:e,type:a,message:t.message,name:t.name})})};return e.addEventListener(`loadedmetadata`,t),e.srcObject=new MediaStream([c.persistentTrack]),e.load(),function(){e.removeEventListener(`loadedmetadata`,t)}}},[c?.persistentTrack,n,r,a]),G(`participant-left`,F(function(e){var t=s.current;e.participant.session_id!==r||!t||(t.srcObject=null)},[r])),G(`left-meeting`,F(function(){var e=s.current;e&&(e.pause(),e.srcObject=null)},[])),po.createElement(`audio`,W({autoPlay:!0,ref:l},o,{"data-session-id":r,"data-audio-type":a,"data-subscribed":u}))}));xg.displayName=`DailyAudioTrack`;var Sg=Ea(ka(function(e,t){var n=e.autoSubscribeActiveSpeaker,r=n===void 0?!1:n,i=e.maxSpeakers,a=i===void 0?5:i,o=e.onPlayFailed,s=e.playLocalScreenAudio,c=s===void 0?!1:s,l=Th(),u=Sh(j(Array(a).fill(``)),2),d=u[0],f=u[1],p=vg().screens,m=lg(),h=dg({ignoreLocal:!0}),g=N(null);ot(t,function(){return{getActiveSpeakerAudio:function(){return g.current?.querySelector(`audio[data-session-id="${h}"][data-audio-type="audio"]`)??null},getAllAudio:function(){return Array.from(g.current?.querySelectorAll(`audio`)??[])},getAudioBySessionId:function(e){return g.current?.querySelector(`audio[data-session-id="${e}"][data-audio-type="audio"]`)??null},getRmpAudio:function(){return Array.from(g.current?.querySelectorAll(`audio[data-audio-type="rmpAudio"]`)??[])},getScreenAudio:function(){return Array.from(g.current?.querySelectorAll(`audio[data-audio-type="screenAudio"]`)??[])},getRmpAudioBySessionId:function(e){return g.current?.querySelector(`audio[data-session-id="${e}"][data-audio-type="rmpAudio"]`)??null},getScreenAudioBySessionId:function(e){return g.current?.querySelector(`audio[data-session-id="${e}"][data-audio-type="screenAudio"]`)??null}}},[h]);var _=wo(F(function(e,t,n){return yh(void 0,void 0,void 0,function(){var t,i;return bh(this,function(a){if(t=Object.values(l?.participants()??{}).filter(function(e){return!e.local&&!!e.tracks.audio.subscribed}),i=function(e){return t.some(function(t){return t.session_id===e})},!i(n))if(l&&!l.isDestroyed()&&r&&!l.subscribeToTracksAutomatically())l.updateParticipant(n,{setSubscribedTracks:{audio:!0}});else return[2];return f(function(r){if(r.includes(n))return r;var a=function(e){return!e||!i(e)};if(r.some(a)){var o=r.findIndex(a);return r[o]=n,Ch([],Sh(r),!1)}var s=r.findIndex(function(e){return t.some(function(t){return t.session_id===e&&fg(t.tracks.audio.state)})});if(s>=0)return r[s]=n,Ch([],Sh(r),!1);var c=t.filter(function(e){return r.includes(e.session_id)&&e.session_id!==h}).sort(function(t,n){var r=e(zh(t.session_id,`last_active`))??new Date(`1970-01-01`),i=e(zh(n.session_id,`last_active`))??new Date(`1970-01-01`);return r>i?1:r<i?-1:0});if(!c.length){var l=r.findIndex(function(e){return e!==h});return r[l]=n,Ch([],Sh(r),!1)}var u=r.indexOf(c[0]?.session_id);return r[u]=n,Ch([],Sh(r),!1)}),[2]})})},[h,r,l])),v=F(function(e){f(function(t){if(!t.includes(e))return t;var n=Ch([],Sh(t),!1),r=n.indexOf(e);return n[r]=``,n})},[]);Xh([`active-speaker-change`,`track-started`,`participant-left`],F(function(e){e.forEach(function(e){switch(e.action){case`active-speaker-change`:if(e.activeSpeaker.peerId===m)return;_(e.activeSpeaker.peerId);break;case`track-started`:e.track.kind===`audio`&&e.participant&&!e.participant.local&&_(e.participant.session_id);break;case`participant-left`:v(e.participant.session_id);break}})},[_,m,v]),200);var y=gg({filter:F(function(e){return!!e?.tracks?.rmpAudio},[])});return po.createElement(`div`,{ref:g},d.map(function(e,t){return po.createElement(xg,{key:`speaker-slot-${t}`,onPlayFailed:o,sessionId:e,type:`audio`})}),p.filter(function(e){return c?!0:!e.local}).map(function(e){return po.createElement(xg,{key:e.screenId,onPlayFailed:o,sessionId:e.session_id,type:`screenAudio`})}),y.map(function(e){return po.createElement(xg,{key:`${e}-rmp`,onPlayFailed:o,sessionId:e,type:`rmpAudio`})}))}));Sg.displayName=`DailyAudio`;var Cg=ka(function(e,t){var n=e.automirror,r=e.fit,i=r===void 0?`contain`:r,a=e.mirror,o=e.onResize,s=e.playableStyle,c=s===void 0?{}:s,l=e.sessionId,u=e.style,d=u===void 0?{}:u,f=e.type,p=f===void 0?`video`:f,m=vh(e,[`automirror`,`fit`,`mirror`,`onResize`,`playableStyle`,`sessionId`,`style`,`type`]),h=lg()===l,g=p===`screenVideo`,_=h&&!g,v=N(null),y=bg(v,t),b=yg(l,p),x=b.persistentTrack,S=_||g||!b.isOff,C=Uh(l,`tracks.${p}`)?.subscribed,w=P(function(){if(typeof a==`boolean`)return a;if(!n)return!1;if(!x)return _;var e=x.getSettings();return`facingMode`in e?_&&e.facingMode===`user`:_},[n,_,a,x]);return M(function(){var e=v.current;if(e){var t=function(){var t=e.play();t!==void 0&&t.then(function(){e.controls=!1}).catch(function(t){e.controls=!0,console.warn(`Failed to play video`,t)})},n=function(){e.paused&&t()},r=function(){e.style.transform=`scale(1)`},i=function(){e.style.transform=``,setTimeout(function(){e.paused&&t()},100)},a=function(){document.visibilityState!==`hidden`&&e.paused&&t()};return e.addEventListener(`canplay`,n),e.addEventListener(`enterpictureinpicture`,r),e.addEventListener(`leavepictureinpicture`,i),document.addEventListener(`visibilitychange`,a),function(){e.removeEventListener(`canplay`,n),e.removeEventListener(`enterpictureinpicture`,r),e.removeEventListener(`leavepictureinpicture`,i),document.removeEventListener(`visibilitychange`,a)}}},[]),M(function(){var e=v.current;if(!(!e||!x)){if(!MediaStream){console.warn(`MediaStream API not available. Can't setup ${p} for ${l}`);return}return e.srcObject=new MediaStream([x]),e.load(),function(){e.srcObject=null,e.load()}}},[l,p,x,x?.id]),M(function(){var e=v.current;if(!o||!e)return;var t;function n(){t&&cancelAnimationFrame(t),t=requestAnimationFrame(function(){var e=v.current;if(!(!e||document.hidden)){var t=e.videoWidth,n=e.videoHeight;t&&n&&o?.({aspectRatio:t/n,height:n,width:t})}})}return n(),e.addEventListener(`loadedmetadata`,n),e.addEventListener(`resize`,n),function(){t&&cancelAnimationFrame(t),e.removeEventListener(`loadedmetadata`,n),e.removeEventListener(`resize`,n)}},[o]),po.createElement(`video`,W({autoPlay:!0,muted:!0,playsInline:!0,ref:y,"data-local":h,"data-mirrored":w||void 0,"data-playable":S||void 0,"data-session-id":l,"data-subscribed":C,"data-video-type":p,style:W(W({objectFit:i,transform:w?`scale(-1, 1)`:``},d),S?c:{})},m))});Cg.displayName=`DailyVideo`;var wg=Ae({refreshDevices:function(){return Promise.resolve()}}),Tg=ua(`idle`);Tg.debugLabel=Nh(`camera-state`);var Eg=ua(`idle`);Eg.debugLabel=Nh(`microphone-state`);var Dg=ua([]);Dg.debugLabel=Nh(`camera-devices`);var Og=ua([]);Og.debugLabel=Nh(`microphone-devices`);var kg=ua([]);kg.debugLabel=Nh(`speaker-devices`);var Ag=ua(null);Ag.debugLabel=Nh(`last-camera-error`);var jg=function(e){var t=e.children,n=Th(),r=wo(F(function(e,t){return yh(void 0,void 0,void 0,function(){var e,r,i,a,o,s,c,l,u,d;return bh(this,function(f){switch(f.label){case 0:if((navigator==null?void 0:navigator.mediaDevices)?.getUserMedia===void 0||(navigator==null?void 0:navigator.mediaDevices)?.enumerateDevices===void 0)return t(Tg,`not-supported`),t(Eg,`not-supported`),[2];if(!n)return[2];f.label=1;case 1:return f.trys.push([1,4,,5]),[4,n.enumerateDevices()];case 2:return e=f.sent().devices,r=e.filter(function(e){return e.kind===`videoinput`&&e.deviceId!==``}),i=e.filter(function(e){return e.kind===`audioinput`&&e.deviceId!==``}),a=e.filter(function(e){return e.kind===`audiooutput`&&e.deviceId!==``}),[4,n.getInputDevices()];case 3:return o=f.sent(),s=o.camera,c=o.mic,l=o.speaker,u=function(e,t,n){var r=n.find(function(e){return e.device.deviceId===t.deviceId}),i=`deviceId`in e&&t.deviceId===e.deviceId,a=!(`deviceId`in e)&&r?.selected;return{device:t,selected:i||!!a,state:r?.state??`granted`}},d=function(e,t){return e.device.deviceId==="default"?-1:t.device.deviceId==="default"?1:e.device.label<t.device.label?-1:+(e.device.label>t.device.label)},t(Dg,function(e){return r.filter(Boolean).map(function(t){return u(s,t,e)}).sort(d)}),t(Og,function(e){return i.filter(Boolean).map(function(t){return u(c,t,e)}).sort(d)}),t(kg,function(e){return a.filter(Boolean).map(function(t){return u(l,t,e)}).sort(d)}),[3,5];case 4:return f.sent(),t(Tg,`not-supported`),t(Eg,`not-supported`),[3,5];case 5:return[2]}})})},[n])),i=wo(F(function(e,t){return yh(void 0,void 0,void 0,function(){var i,a,o,s,c,l,u,d,f,p,m,h;return bh(this,function(g){switch(g.label){case 0:if(!n||(i=e(Tg),a=e(Eg),o=n.participants(),!o.local))return[2];if(s=o.local.tracks,c=`prompt`,l=`prompt`,!navigator.permissions)return[3,5];g.label=1;case 1:return g.trys.push([1,4,,5]),[4,navigator.permissions.query({name:`camera`})];case 2:return u=g.sent(),c=u.state,[4,navigator.permissions.query({name:`microphone`})];case 3:return d=g.sent(),l=d.state,[3,5];case 4:return g.sent(),[3,5];case 5:return f=c===`prompt`&&[`idle`,`pending`].includes(i)&&s.video.state===`interrupted`&&!s.video.persistentTrack,p=[`idle`,`pending`].includes(i)&&!s.video.persistentTrack&&!!s.video.off?.byUser,m=l===`prompt`&&[`idle`,`pending`].includes(a)&&s.audio.state===`interrupted`&&!s.audio.persistentTrack,h=[`idle`,`pending`].includes(a)&&!s.audio.persistentTrack&&!!s.audio.off?.byUser,s.audio?.blocked?.byDeviceInUse?(t(Eg,`in-use`),t(Og,function(e){return e.map(function(e){return e.selected?W(W({},e),{state:`in-use`}):e})})):s.audio?.blocked?.byDeviceMissing?t(Eg,`not-found`):s.audio?.blocked?.byPermissions||l===`denied`?t(Eg,`blocked`):m?t(Eg,`pending`):h?t(Eg,`idle`):(t(Eg,`granted`),t(Og,function(e){return e.map(function(e){return e.selected?W(W({},e),{state:`granted`}):e})})),s.video?.blocked?.byDeviceInUse?(t(Tg,`in-use`),t(Dg,function(e){return e.map(function(e){return e.selected?W(W({},e),{state:`in-use`}):e})})):s.video?.blocked?.byDeviceMissing?t(Tg,`not-found`):s.video?.blocked?.byPermissions||c===`denied`?t(Tg,`blocked`):f?t(Tg,`pending`):p?t(Tg,`idle`):(t(Tg,`granted`),t(Dg,function(e){return e.map(function(e){return e.selected?W(W({},e),{state:`granted`}):e})})),r(),[2]}})})},[n,r]));return G(`participant-updated`,F(function(e){e.participant.local&&i()},[i])),G(`available-devices-updated`,r),G(`selected-devices-updated`,r),G(`camera-error`,wo(F(function(e,t,n){switch(t(Ag,n.error),n.error?.type){case`cam-in-use`:t(Tg,`in-use`);break;case`mic-in-use`:t(Eg,`in-use`);break;case`cam-mic-in-use`:t(Tg,`in-use`),t(Eg,`in-use`);break;case`not-found`:n.error?.missingMedia.includes(`video`)&&t(Tg,`not-found`),n.error?.missingMedia.includes(`audio`)&&t(Eg,`not-found`);break;case`permissions`:n.error?.blockedMedia.includes(`video`)&&t(Tg,`blocked`),n.error?.blockedMedia.includes(`audio`)&&t(Eg,`blocked`);break;case`constraints`:n.error?.reason===`invalid`?(t(Tg,`constraints-invalid`),t(Eg,`constraints-invalid`)):n.error?.reason===`none-specified`&&(t(Tg,`constraints-none-specified`),t(Eg,`constraints-none-specified`));break;case`undefined-mediadevices`:t(Tg,`undefined-mediadevices`),t(Eg,`undefined-mediadevices`);break;default:t(Tg,`unknown`),t(Eg,`unknown`);break}},[]))),G(`started-camera`,wo(F(function(e,t){t(Tg,`granted`),t(Eg,`granted`),i()},[i]))),po.createElement(wg.Provider,{value:{refreshDevices:r}},t)};function Mg(e){return e.instanceId??`__default__`}var Ng=ua({});Ng.debugLabel=Nh(`live-streaming-instances`);var Pg=ua(function(e){var t=e(Ng),n=Object.values(t),r=n.filter(function(e){return e.isLiveStreaming}),i=r[0]??n[n.length-1];return{errorMsg:n.find(function(e){return e.errorMsg})?.errorMsg,isLiveStreaming:r.length>0,layout:i?.layout}});Pg.debugLabel=Nh(`live-streaming`);var Fg=function(e){var t=e.children;return G(`live-streaming-started`,wo(F(function(e,t,n){var r=Mg(n);t(Ng,function(e){var t;return W(W({},e),(t={},t[r]={instanceId:r,isLiveStreaming:!0,layout:n?.layout},t))})},[]))),G(`live-streaming-stopped`,wo(F(function(e,t,n){var r=Mg(n);t(Ng,function(e){var t;return e[r]?W(W({},e),(t={},t[r]=W(W({},e[r]),{isLiveStreaming:!1,layout:void 0}),t)):e})},[]))),G(`live-streaming-error`,wo(F(function(e,t,n){var r=Mg(n);t(Ng,function(e){var t;return W(W({},e),(t={},t[r]=W(W({},e[r]??{instanceId:r,isLiveStreaming:!1}),{errorMsg:n.errorMsg}),t))})},[]))),G(`left-meeting`,wo(F(function(e,t){t(Ng,{})},[]))),po.createElement(po.Fragment,null,t)},Ig=ua(`new`);Ig.debugLabel=Nh(`meeting-state`);var Lg=ua(null);Lg.debugLabel=Nh(`meeting-error`);var Rg=ua(null);Rg.debugLabel=Nh(`non-fatal-error`);var zg=ua({data:void 0,topology:`none`});zg.debugLabel=Nh(`meeting-session-data`);var Bg=function(e){var t=e.children,n=Th(),r=wo(F(function(e,t){if(n){var r=n.meetingState();return t(Ig,r),r}},[n]));return G(`loading`,r),G(`loaded`,r),G(`joining-meeting`,r),G(`joined-meeting`,r),G(`left-meeting`,r),G(`error`,wo(F(function(e,t,n){t(Lg,n),r()},[r]))),G(`nonfatal-error`,wo(F(function(e,t,n){t(Rg,n)},[]))),G(`joined-meeting`,wo(F(function(e,t){n&&t(zg,n.meetingSessionState())},[n]))),G(`meeting-session-state-updated`,wo(F(function(e,t,n){t(zg,n.meetingSessionState)},[]))),G(`left-meeting`,wo(F(function(e,t){t(zg,{data:void 0,topology:`none`})},[]))),G(`call-instance-destroyed`,wo(F(function(e,t){t(Ig,`new`),t(Lg,null),t(Rg,null),t(zg,{data:void 0,topology:`none`})},[]))),po.createElement(po.Fragment,null,t)},Vg=ua(`none`);Vg.debugLabel=Nh(`topology`);var Hg=ua(`unknown`),Ug=ua([]),Wg=ua(`interrupted`),Gg=ua(100);Gg.debugLabel=Nh(`network-quality`);var Kg=ua(`good`);Kg.debugLabel=Nh(`network-threshold`);var qg=function(e){var t=e.children,n=Th(),r=So(Vg),i=wo(F(function(e,t){return yh(void 0,void 0,void 0,function(){var e;return bh(this,function(r){switch(r.label){case 0:return n?[4,n.getNetworkTopology()]:[2];case 1:return e=r.sent(),!e||e?.topology===`none`||t(Vg,e.topology),[2]}})})},[n]));return G(`joined-meeting`,i),G(`network-connection`,wo(F(function(e,t,n){switch(t(Wg,n.event),n.event){case`connected`:n.type===`peer-to-peer`&&t(Vg,`peer`),n.type===`sfu`&&t(Vg,`sfu`);break}},[]))),G(`network-quality-change`,wo(F(function(e,t,n){t(Hg,function(e){return e===n.networkState?e:n.networkState}),t(Ug,function(e){var t=n.networkStateReasons??[];return Mh(e,t)?e:t}),t(Gg,function(e){return e===n.quality?e:n.quality}),t(Kg,function(e){return e===n.threshold?e:n.threshold})},[]))),G(`left-meeting`,wo(F(function(e,t){t(Vg,`none`),t(Hg,`unknown`),t(Ug,[]),t(Wg,`interrupted`),t(Gg,100),t(Kg,`good`)},[]))),M(function(){!n||r!==`none`||i()},[n,i,r]),po.createElement(po.Fragment,null,t)};function Jg(e){return e.instanceId?e.instanceId:e.type===`local`||e.local?`__local__`:`__default__`}var Yg=ua({});Yg.debugLabel=Nh(`recording-instances`);var Xg=ua(function(e){var t=e(Yg),n=Object.values(t),r=n.filter(function(e){return e.isRecording}),i=r[0]??n[n.length-1];return{error:n.some(function(e){return e.error}),isLocalParticipantRecorded:n.some(function(e){return e.isLocalParticipantRecorded}),isRecording:r.length>0,layout:i?.layout,local:i?.local,recordingId:i?.recordingId,recordingStartedDate:i?.recordingStartedDate,startedBy:i?.startedBy,type:i?.type}});Xg.debugLabel=Nh(`recording-state`);var Zg=function(e){var t=e.children,n=lg(),r=gg({filter:`record`}),i=wo(F(function(e,t,n,r){var i=e(Yg).__local__,a=W(W({},i),{instanceId:`__local__`,isLocalParticipantRecorded:n,isRecording:n,local:n?r:i?.local,type:n?`local`:i?.type});i&&jh(i,a)||!n&&!i||(n?t(Yg,function(e){return W(W({},e),{__local__:a})}):i&&t(Yg,function(e){return W(W({},e),{__local__:W(W({},i),{isLocalParticipantRecorded:!1,isRecording:!1})})}))},[]));return M(function(){i(r.length>0,r.includes(n||`local`))},[n,i,r]),G(`recording-started`,wo(F(function(e,t,r){var i=Jg(r),a=!0;switch(r.type){case`cloud-audio-only`:case`cloud-beta`:case`cloud`:n&&r.layout?.preset===`single-participant`&&r.layout.session_id!==n&&(a=!1);break}t(Yg,function(e){var t;return W(W({},e),(t={},t[i]={error:!1,instanceId:i,isLocalParticipantRecorded:a,isRecording:!0,layout:r?.layout,local:r?.local,recordingId:r?.recordingId,recordingStartedDate:new Date,startedBy:r?.startedBy,type:r?.type},t))})},[n]))),G(`recording-stopped`,wo(F(function(e,t,n){var r=Jg(n);t(Yg,function(e){var t;return e[r]?W(W({},e),(t={},t[r]=W(W({},e[r]),{isLocalParticipantRecorded:!1,isRecording:!1}),t)):e})},[]))),G(`recording-error`,wo(F(function(e,t,n){var r=Jg(n);t(Yg,function(e){var t,i=e[r];return W(W({},e),(t={},t[r]=W(W({},i??{instanceId:r}),{error:!0,errorMsg:n.errorMsg,isLocalParticipantRecorded:!1,isRecording:!1}),t))})},[]))),G(`left-meeting`,wo(F(function(e,t){t(Yg,{})},[]))),po.createElement(po.Fragment,null,t)},Qg=function(){var e=So(Ig);return st(e),e},$g=ua(null);$g.debugLabel=Nh(`room-state`);var e_=function(e){var t=e.children,n=Th(),r=Qg();return G(`access-state-updated`,wo(F(function(e,t){return yh(void 0,void 0,void 0,function(){var e;return bh(this,function(i){switch(i.label){case 0:return!n||r===`left-meeting`?[2]:[4,n.room()];case 1:return e=i.sent(),e&&`id`in e&&t($g,e),[2,e]}})})},[n,r]))),G(`left-meeting`,wo(F(function(e,t){return function(){t($g,null)}},[]))),po.createElement(po.Fragment,null,t)},t_=ua({isTranscribing:!1,model:`general`,language:`en`,transcriptions:[]});t_.debugLabel=Nh(`transcription-state`);var n_=function(e){var t=e.children;return G(`transcription-started`,wo(F(function(e,t,n){t(t_,{error:!1,transcriptionStartDate:new Date,isTranscribing:!0,transcriptions:[],endpointing:n.endpointing,extra:n.extra,includeRawResponse:n.includeRawResponse,instanceId:n.instanceId,language:n.language,model:n.model,profanity_filter:n.profanity_filter,punctuate:n.punctuate,redact:n.redact,startedBy:n.startedBy,tier:n.tier})},[]))),G(`transcription-stopped`,wo(F(function(e,t,n){t(t_,function(e){return W(W({},e),{updatedBy:n.updatedBy,isTranscribing:!1})})},[]))),G(`transcription-error`,wo(F(function(e,t){t(t_,function(e){return W(W({},e),{error:!0,isTranscribing:!1})})},[]))),G(`left-meeting`,wo(F(function(e,t){t(t_,function(e){return W(W({},e),{isTranscribing:!1})})},[]))),G(`app-message`,wo(F(function(e,t,n){n?.fromId===`transcription`&&t(t_,function(e){return W(W({},e),{isTranscribing:!0,transcriptions:Ch(Ch([],Sh(e.transcriptions),!1),[n.data],!1)})})},[]))),po.createElement(po.Fragment,null,t)},r_=`0.25.3`,i_={strictMode:!0},a_=function(){return!0},o_={options:i_,shouldCreateInstance:a_},s_=function(e,t){var n=t===void 0?o_:t,r=n.parentElRef,i=n.options,a=i===void 0?i_:i,o=n.shouldCreateInstance,s=o===void 0?a_:o,c=Sh(j(null),2),l=c[0],u=c[1],d=N();return M(function(){if(e===`callFrame`&&r?.current===null||!s())return;function t(e){return yh(this,void 0,void 0,function(){return bh(this,function(t){switch(t.label){case 0:return[4,e.destroy()];case 1:return t.sent(),[2]}})})}var n=function(){setTimeout(function(){return u(null)},0)},i=Hm.getCallInstance();if(!l&&i&&!i.isDestroyed()){i.once(`call-instance-destroyed`,n),u(i);return}if(l){jh(d.current,a)||t(l);return}if(!i||i.isDestroyed())try{var o=W(W({},a),{aboutClient:W(W({},a.aboutClient??{}),{"daily-react":r_})});switch(e){case`callFrame`:i=r?.current?Hm.createFrame(r.current,o):Hm.createFrame(o);break;case`callObject`:i=Hm.createCallObject(o);break}d.current=a,u(i),i.once(`call-instance-destroyed`,n)}catch(e){if(console.error(`Error creating call instance:`,e),a.strictMode)throw e}},[l,a,r,s,e]),l},c_=function(e){return s_(`callObject`,e)},l_=function(e){var t=e.children,n=e.jotaiStore,r=vh(e,[`children`,`jotaiStore`]),i=N({}),a=F(function(e){var t,n;if(`action`in e){var r=e.action,a=Array.from(i.current?.[r]??[]),o=a.filter(function(e){return Sh(e,1)[0]<0}),s=a.filter(function(e){return Sh(e,1)[0]>0}),c=Ch(Ch([],Sh(o),!1),Sh(s),!1);try{for(var l=xh(c),u=l.next();!u.done;u=l.next()){var d=Sh(u.value,2)[1];d(e)}}catch(e){t={error:e}}finally{try{u&&!u.done&&(n=l.return)&&n.call(l)}finally{if(t)throw t.error}}}},[]),o=F(function(e){e&&Object.keys(i.current).forEach(function(t){e.off(t,a),e.isDestroyed()||e.on(t,a)})},[a]),s=`callObject`in r?r.callObject:null,c=c_({options:P(function(){return`callObject`in r?{}:r},[r]),shouldCreateInstance:F(function(){return!(`callObject`in r)},[r])}),l=s??c;M(function(){l&&o(l)},[l,o]);var u=F(function(e,t,n){var r;i.current[e]||(i.current[e]=new Map,l&&(l.off(e,a),l.isDestroyed()||l.on(e,a))),i.current[e]?.has(n)||(r=i.current[e])==null||r.set(n,t)},[l,a]),d=F(function(e,t){var n;(n=i.current[e])==null||n.delete(t),i.current[e]?.size===0&&(l?.off(e,a),delete i.current[e])},[l,a]);return po.createElement(go,{store:n},po.createElement(wh.Provider,{value:l},po.createElement(Eh.Provider,{value:{on:u,off:d}},po.createElement(e_,null,po.createElement(Bg,null,po.createElement(qg,null,po.createElement(cg,null,po.createElement(Zg,null,po.createElement(Fg,null,po.createElement(n_,null,po.createElement(jg,null,t)))))))))))},u_=function(e){var t=(e===void 0?{}:e).onAppMessage,n=Th(),r=F(function(e,t){t===void 0&&(t=`*`),n&&n.sendAppMessage(e,t)},[n]);return G(`app-message`,F(function(e){t?.(e,r)},[t,r])),r},d_=function(e,t,n,r){var i=Th(),a=e===lg();G(`local-audio-level`,F(function(e){a&&t(e.audioLevel)},[t,a])),G(`remote-participants-audio-level`,F(function(n){a||t(n.participantsAudioLevel[e])},[t,e,a])),M(function(){if(!(!i||i.isDestroyed()||!a)&&!i.isLocalAudioLevelObserverRunning())try{i.startLocalAudioLevelObserver(r)}catch{n?.(`Local audio level observer not supported in this browser`)}},[i,n,r,a]),M(function(){!i||i.isDestroyed()||a||i.isRemoteParticipantsAudioLevelObserverRunning()||i.startRemoteParticipantsAudioLevelObserver(r)},[i,r,a])},f_=function(e){return yg(e,`audio`)},p_,m_;function h_(){return m_?p_:(m_=1,p_=function e(t,n){if(t===n)return!0;if(t&&n&&_h(t)==`object`&&_h(n)==`object`){if(t.constructor!==n.constructor)return!1;var r,i,a;if(Array.isArray(t)){if(r=t.length,r!=n.length)return!1;for(i=r;i--!==0;)if(!e(t[i],n[i]))return!1;return!0}if(t.constructor===RegExp)return t.source===n.source&&t.flags===n.flags;if(t.valueOf!==Object.prototype.valueOf)return t.valueOf()===n.valueOf();if(t.toString!==Object.prototype.toString)return t.toString()===n.toString();if(a=Object.keys(t),r=a.length,r!==Object.keys(n).length)return!1;for(i=r;i--!==0;)if(!Object.prototype.hasOwnProperty.call(n,a[i]))return!1;for(i=r;i--!==0;){var o=a[i];if(!e(t[o],n[o]))return!1}return!0}return t!==t&&n!==n},p_)}h_();var g_=ua({state:`low`,reason:`none`});g_.debugLabel=Nh(`cpu-load`);var __=function(){var e=Th(),t=So(Tg),n=So(Eg),r=So(Dg),i=So(Og),a=So(kg),o=So(Ag),s=I(wg).refreshDevices,c=F(function(t){return yh(void 0,void 0,void 0,function(){return bh(this,function(n){switch(n.label){case 0:return[4,e?.setInputDevicesAsync({audioDeviceId:null,videoDeviceId:t})];case 1:return n.sent(),[2]}})})},[e]),l=F(function(t){return yh(void 0,void 0,void 0,function(){return bh(this,function(n){switch(n.label){case 0:return[4,e?.setInputDevicesAsync({audioDeviceId:t,videoDeviceId:null})];case 1:return n.sent(),[2]}})})},[e]),u=F(function(t){return yh(void 0,void 0,void 0,function(){return bh(this,function(n){switch(n.label){case 0:return[4,e?.setOutputDeviceAsync({outputDeviceId:t})];case 1:return n.sent(),[2]}})})},[e]),d=[`blocked`,`in-use`,`not-found`,`constraints-invalid`,`constraints-none-specified`,`undefined-mediadevices`,`unknown`],f={cameraError:o,cameras:r,camState:t,currentCam:r.find(function(e){return e.selected}),currentMic:i.find(function(e){return e.selected}),currentSpeaker:a.find(function(e){return e.selected}),hasCamError:d.includes(t),hasMicError:d.includes(n),microphones:i,micState:n,refreshDevices:s,setCamera:c,setMicrophone:l,setSpeaker:u,speakers:a};return st(f),f},v_=ua(null);v_.debugLabel=Nh(`input-settings`);var y_=ua({hidden:0,present:0});y_.debugLabel=Nh(`participant-counts`);var b_=To(function(e){var t=ua({},function(t,n,r){n(b_(e),r)});return t.debugLabel=Nh(`participant-receive-settings-${e}`),t}),x_=function(e){return yg(e,`screenVideo`)},S_=ua(null);S_.debugLabel=Nh(`send-settings`);var C_=function(e){return yg(e,`video`)};function w_({children:e}){return L(l_,{children:e})}var T_=Ae(null),E_=`tavus:memory-user-id:`,D_=new Map;function O_(e){return`${E_}${e}`}function k_(){return typeof crypto<`u`&&typeof crypto.randomUUID==`function`?crypto.randomUUID():`${Date.now().toString(36)}-${Math.random().toString(36).slice(2,10)}`}function A_(e){if(!e)return``;let t=O_(e);try{let e=window.localStorage.getItem(t);if(e)return e;let n=k_();return window.localStorage.setItem(t,n),n}catch{}let n=D_.get(t);if(n)return n;let r=k_();return D_.set(t,r),r}var j_=`tavus:terms-accepted:`;function M_(e){let t=5381;for(let n=0;n<e.length;n++)t=(t*33^e.charCodeAt(n))>>>0;return t.toString(36)}function N_(e,t){return`${j_}${e}:${M_(t)}`}function P_(e,t){if(!e||!t)return!1;try{return globalThis.localStorage?.getItem(N_(e,t))===`1`}catch{return!1}}function F_(e,t){if(!(!e||!t))try{globalThis.localStorage?.setItem(N_(e,t),`1`)}catch{}}var I_=null;function L_(e,t){!e||!t||(I_={deploymentId:e,content:t})}function R_(){I_&&=(F_(I_.deploymentId,I_.content),null)}function z_(e){return e===`user`?`user`:e===`pal`?`replica`:null}function B_(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function V_(e){if(!B_(e)||e.message_type!==`conversation`||typeof e.event_type!=`string`||!B_(e.properties))return null;if(e.event_type===`conversation.utterance`){let t=e.properties;if(typeof t.speech!=`string`)return null;let n=z_(t.role);return n?{kind:`chat-message`,sender:n===`user`?`user`:`agent`,text:t.speech}:null}if(e.event_type===`conversation.utterance.streaming`){let t=e.properties;if(typeof t.speech!=`string`)return null;let n=z_(t.role);if(!n)return null;let r=t.final===!0||t.is_interrupted===!0;return{kind:`caption-update`,text:t.speech,final:r,role:n}}return null}function H_(e,t){return{message_type:`conversation`,event_type:`conversation.respond`,conversation_id:e,properties:{text:t}}}function U_(e,t){return typeof e[t]==`number`?{[t]:e[t]}:{}}function W_(e){let t=z_(e.role);return!t||typeof e.speech!=`string`?null:{kind:`utterance`,event_type:`conversation.utterance`,properties:{role:t,speech:e.speech,...U_(e,`seq`),...U_(e,`turn_idx`)}}}function G_(e){let t=z_(e.role);return!t||typeof e.speech!=`string`?null:{kind:`utterance.streaming`,event_type:`conversation.utterance.streaming`,properties:{role:t,speech:e.speech,...typeof e.final==`boolean`?{final:e.final}:{},...typeof e.is_interrupted==`boolean`?{is_interrupted:e.is_interrupted}:{},...U_(e,`seq`)}}}function K_(e){return typeof e.name!=`string`||typeof e.arguments!=`string`?null:{kind:`tool_call`,event_type:`conversation.tool_call`,properties:{name:e.name,arguments:e.arguments,...U_(e,`seq`),...U_(e,`turn_idx`)}}}function q_(e){if(typeof e==`string`)return e;try{let t=JSON.stringify(e??{});return typeof t==`string`?t:null}catch{return null}}function J_(e){if(typeof e.name!=`string`)return null;let t=e.modality===`vision`||e.modality===`audio`?e.modality:null;if(!t)return null;let n=q_(e.arguments);return n===null?null:{kind:`perception_tool_call`,event_type:`conversation.perception_tool_call`,properties:{name:e.name,arguments:n,modality:t}}}function Y_(e){return{kind:`perception_analysis`,event_type:`conversation.perception_analysis`,properties:e}}function X_(e,t){return{kind:`speaking`,event_type:t,properties:{...U_(e,`seq`),...U_(e,`turn_idx`)}}}var Z_={"conversation.utterance":W_,"conversation.utterance.streaming":G_,"conversation.tool_call":K_,"conversation.perception_tool_call":J_,"conversation.perception_analysis":Y_,"conversation.replica_started_speaking":X_,"conversation.replica_stopped_speaking":X_,"conversation.user_started_speaking":X_,"conversation.user_stopped_speaking":X_};function Q_(e){if(!B_(e)||e.message_type!==`conversation`||typeof e.event_type!=`string`||!B_(e.properties))return null;let t=Z_[e.event_type];return t?t(e.properties,e.event_type):{kind:`unknown`,event_type:e.event_type,properties:e.properties}}function $_(e,t){return{message_type:`conversation`,event_type:t.event_type,conversation_id:e,properties:t.properties??{}}}function ev(e,t){let n=V_(e);return n?n.kind===`chat-message`?(t.appendChatMessage(n.sender,n.text),!0):(t.setCaption(n.text,n.final,n.role),!0):!1}function tv(e=5e3){let t=[],n=n=>{for(;t.length>0&&n-t[0].ts>e;)t.shift()};return{markSent(e){t.push({text:e,ts:Date.now()})},consumeMatch(e){n(Date.now());let r=t.findIndex(t=>t.text===e);return r===-1?!1:(t.splice(r,1),!0)}}}var nv=wn(`Conversation`),rv=1500;function iv(e,t){if(!t)return e;let n=()=>t.reason??new DOMException(`The operation was aborted`,`AbortError`);return t.aborted?Promise.reject(n()):new Promise((r,i)=>{let a=()=>i(n());t.addEventListener(`abort`,a,{once:!0}),e.then(e=>{t.removeEventListener(`abort`,a),r(e)},e=>{t.removeEventListener(`abort`,a),i(e)})})}var av=Ae(null);function ov({children:e}){return L(w_,{children:L(hv,{children:e})})}function sv(e,t,n){let{role:r,speech:i}=e.properties;if(!(r===`user`&&n.consumeMatch(i)))for(let n of t)n.onUtterance?.({...e.properties})}function cv(e,t){for(let n of t)n.onToolCall?.({...e.properties})}function lv(e,t){for(let n of t)n.onPerception?.(e)}function uv(e,t){let n=e.event_type,r=n.startsWith(`conversation.replica`)?`replica`:`user`,i=n.endsWith(`started_speaking`)?`started`:`stopped`;for(let n of t)n.onSpeakingState?.({who:r,state:i,...e.properties})}function dv(e,t){for(let n of t)n.onMessage?.(e)}function fv(e,t,n){switch(e.kind){case`utterance`:case`utterance.streaming`:sv(e,t,n);return;case`tool_call`:cv(e,t);return;case`perception_tool_call`:case`perception_analysis`:lv(e,t);return;case`speaking`:uv(e,t);return;case`unknown`:dv(e,t);return}}function pv(e,t,n){let r=e;return t&&r?.conversational_context==null&&(r={...r,conversational_context:t}),n&&r?.custom_greeting==null&&(r={...r,custom_greeting:n}),r}function mv(e,t){return t?e instanceof Dn&&e.status===401:!1}function hv({children:e}){let{deploymentId:t,client:n,config:r}=I(Di),{memoryStores:i,conversationalContext:a,customGreeting:o}=I(kt),s=Th(),c=Qg(),l=I(T_),u=P(()=>Yt(`idle`),[]),d=P(()=>Yt(null),[]),f=P(()=>Yt([]),[]),p=P(()=>Yt(``),[]),m=P(()=>Yt(null),[]),h=P(()=>Yt(null),[]),g=P(()=>Yt(null),[]),_=P(()=>Yt(null),[]),v=N(null),y=N(null),b=P(()=>tv(),[]),x=P(()=>new Set,[]),S=P(()=>Yt(`idle`),[]),C=l?.flowSignal??S,w=F(e=>{g.value=e},[g]),T=F(e=>{_.value=e},[_]),[,E]=j(c);M(()=>{E(c),c===`joined-meeting`?(u.value=`connected`,nv.info(`Connected to meeting`)):c===`left-meeting`?(u.value=`ended`,R_(),nv.info(`Left meeting`)):c===`error`&&(h.value=`Meeting error`,u.value=`error`)},[c,u,h]),Cn(()=>{let e=u.value;if(e===`connected`)for(let e of x)e.onConnect?.();else if(e===`ended`||e===`disconnecting`)for(let e of x)e.onDisconnect?.();else if(e===`error`){let e=h.peek()??`Unknown error`;for(let t of x)t.onError?.({code:`CONVERSATION_ERROR`,message:e})}}),Cn(()=>{let e=C.value;for(let t of x)t.onModeChange?.(e)}),u_({onAppMessage:F(e=>{ev(e?.data,{appendChatMessage(e,t){e===`user`&&b.consumeMatch(t)||(f.value=[...f.peek(),{id:crypto.randomUUID(),sender:e,text:t,timestamp:Date.now()}])},setCaption(e,t,n){p.value=e,m.value=n,v.current!==null&&(clearTimeout(v.current),v.current=null),t&&(v.current=setTimeout(()=>{p.value=``,m.value=null,v.current=null},rv))}});let t=Q_(e?.data);t&&fv(t,x,b)},[f,p,m,b,x])}),M(()=>()=>{v.current!==null&&(clearTimeout(v.current),v.current=null)},[]);let D=F(()=>{y.current=null,d.value=null,f.value=[],p.value=``,m.value=null,v.current!==null&&(clearTimeout(v.current),v.current=null),(u.peek()===`ended`||u.peek()===`error`)&&(u.value=`idle`)},[d,u,f,p,m]),ee=F(()=>{let e=d.peek()?.conversationId??null,r=y.current;if(r?.conversationId===e)return r.promise;u.value=`disconnecting`;let i=!1,a=e?An(n,t,e,{keepalive:!0}).catch(e=>{i=!0,nv.error(`End conversation API failed`,e)}):Promise.resolve(),o;try{o=s?.leave()}catch(e){i=!0,nv.error(`Daily leave failed`,e)}let c=Promise.resolve(o).catch(e=>{i=!0,nv.error(`Daily leave failed`,e)}),l=Promise.all([a,c]).then(()=>{u.value=`ended`,i&&y.current?.promise===l&&(y.current=null)});return y.current={conversationId:e,promise:l},l},[n,t,s,d,u]),te=F(async(e,c)=>{let l=null;try{D(),u.value=`connecting`,h.value=null;let f=e,p=g.peek();p&&f?.password==null&&(f={...f,password:p});let m=r.value.customization.conversation.unique_memory_tag===!0;if(!f?.memory_stores){let e=i??(m?[A_(t)]:[]);e.length&&(f={...f,memory_stores:e})}f=pv(f,a,o);let v=_.peek();_.value=null,v&&f?.captcha_token==null&&(f={...f,captcha_token:v});let y=await kn(n,t,f,c);if(l=y.conversation_id,d.value={conversationId:y.conversation_id,conversationName:y.conversation_name,conversationUrl:y.conversation_url,callbackUrl:y.callback_url,createdAt:y.created_at,magicGrid:y.magic_grid===!0},console.info(`[Tavus:Conversation] Conversation created:`,y.conversation_id),c?.signal?.aborted)throw c.signal.reason??new DOMException(`The operation was aborted`,`AbortError`);let b=r.value.customization.conversation.modality===`chat`;await iv(Promise.resolve(s?.join({url:y.conversation_url,...b?{startAudioOff:!0,startVideoOff:!0}:{}})),c?.signal)}catch(e){throw await ee(),l&&(d.value=null),mv(e,r.value.has_password===!0)&&(g.value=null),nv.error(`Start failed`,e),h.value=String(e),u.value=`error`,e}},[n,t,s,u,h,d,g,_,r,i,a,o,D,ee]),ne=F(e=>{if(!s)return;let t=d.peek();if(!t){nv.warn(`sendChat called before session was established; dropping message`);return}b.markSent(e),s.sendAppMessage(H_(t.conversationId,e),`*`),f.value=[...f.peek(),{id:crypto.randomUUID(),sender:`user`,text:e,timestamp:Date.now()}]},[s,f,d,b]),re=F(e=>{if(!s){nv.warn(`sendMessage called before Daily was ready; dropping message`);return}let t=d.peek();if(!t){nv.warn(`sendMessage called before session was established; dropping message`);return}e.event_type===`conversation.respond`&&b.markSent(e.properties.text),s.sendAppMessage($_(t.conversationId,e),`*`)},[s,d,b]),O=F(e=>{x.add(e)},[x]),ie=F(e=>{x.delete(e)},[x]),ae=P(()=>({state:u,session:d,chatMessages:f,captionText:p,captionRole:m,error:h,password:g,setPassword:w,captchaToken:_,setCaptchaToken:T,mode:C,start:te,end:ee,sendChat:ne,sendMessage:re,conversation:{start:te,end:ee,sendMessage:re},__registerSubscriber:O,__unregisterSubscriber:ie,__beginAttempt:D}),[u,d,f,p,m,h,g,w,_,T,C,te,ee,ne,re,O,ie,D]);return L(av.Provider,{value:ae,children:e})}var gv=wn(`CaptchaChallenge`),_v=1;function vv(e){return typeof e==`object`&&!!e&&e.source===`tavus-captcha`&&typeof e.type==`string`}function yv(e,t,n,r,i){return`${e.replace(/\/+$/,``)}${t.startsWith(`/`)?t:`/${t}`}?deployment_uuid=${encodeURIComponent(n)}&action=${encodeURIComponent(r)}&parent_origin=${encodeURIComponent(i)}`}function bv({captcha:e,deploymentId:t,onToken:n,onFallback:r,onInteractive:i,presented:a=!0}){let o=(I(kt).baseUrl??`https://tavusapi.com`).replace(/\/+$/,``),s=new URL(o).origin,[c,l]=j(0),[u,d]=j(0),[f,p]=j(!1),[m,h]=j(!1),g=yv(o,e.challenge_path,t,e.action,window.location.origin),_=F(()=>{h(!1),l(e=>e+1)},[]);if(M(()=>{function e(e){if(f||e.origin!==s)return;let a=e.data;if(vv(a)&&a.deployment_uuid===t){if(a.type===`interactive`){h(!0),i?.(!0);return}if(a.type===`token`&&a.token){gv.info(`Captcha token received`),h(!1),i?.(!1),n(a.token);return}if(a.type===`expired`){gv.info(`Captcha token expired, reloading iframe`),_();return}a.type===`error`&&(gv.warn(`Captcha error received`,a.code),u<_v?(d(e=>e+1),_()):(gv.warn(`Captcha error retries exhausted, falling back to no-token mode`),p(!0),r()))}}return window.addEventListener(`message`,e),()=>window.removeEventListener(`message`,e)},[s,t,u,f,n,r,i,_]),f)return null;let v=m&&a;return L(`div`,{class:v?`absolute inset-0 z-50 flex items-center justify-center p-4 bg-black/50 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":!v,children:L(`iframe`,{src:g,sandbox:`allow-scripts allow-same-origin allow-forms allow-popups`,title:`Security challenge`,style:{border:`none`,width:`300px`,height:`65px`},scrolling:`no`},c)})}var xv=wn(`Captcha`),Sv=15e3,Cv=Ae(null);function wv({children:e}){let{config:t,deploymentId:n}=I(Di),r=I(av),i=gn(!0),a=gn(null),o=gn(!1),s=gn(0),c=gn(!1),l=gn(!1),u=N([]),d=t.value.captcha??null,f=r?.state.value??`idle`,p=f===`connecting`||f===`connected`,m=d!==null&&!c.value&&!p&&o.value,h=F(e=>{let t=u.current;u.current=[];for(let n of t)n(e)},[]),g=F(e=>{r?.setCaptchaToken(e),l.value=!1},[r,l]);Cn(()=>{(r?.captchaToken.value??null)!==null&&(o.value=!1)});let _=F(()=>{xv.warn(`Captcha challenge unavailable; not attempting /start without a token`),c.value=!0,o.value=!1,h({kind:`unavailable`})},[o,c,h]),v=F(e=>{l.value=e},[l]),y=F(async()=>(t.peek().captcha??null)===null?{kind:`not-required`}:(r?.captchaToken.peek()??null)===null?(c.peek()&&(c.value=!1,s.value=s.peek()+1),o.value=!0,new Promise(e=>{let t=!1,n,i=r=>{t||(t=!0,clearTimeout(a),n?.(),e(r))},a=setTimeout(()=>{l.peek()||(xv.warn(`Captcha mint timed out`),h({kind:`unavailable`}))},Sv);n=r?.captchaToken.subscribe(e=>{e!==null&&i({kind:`token`})}),u.current.push(i)})):{kind:`token`},[o,t,r,s,c,l,h]),b=P(()=>({ensureToken:y,hostVisible:i,promptSlot:a}),[y,i,a]),x=l.value&&i.value?a.value:null,S=m&&d?L(bv,{captcha:d,deploymentId:n,presented:i.value,onToken:g,onFallback:_,onInteractive:v},s.value):null;return L(Cv.Provider,{value:b,children:[e,x&&S?Ua(S,x):S]})}function Tv(){let e=I(Di);if(!e)throw Error(`useConfig must be used within ConfigProvider`);return e}var Ev=new Set([`network`,`server`,`unavailable`,`busy`,`rate_limited`]);function Dv(e){return e===401||e===403?`forbidden`:e===402?`limit_exceeded`:e===423?`busy`:e===429?`rate_limited`:e===409?`concurrency`:e===503?`unavailable`:e>=500?`server`:`unknown`}function Ov(e){if(!e)return;let t=e.get(`Retry-After`);if(!t)return;let n=Number.parseInt(t,10);if(!Number.isNaN(n)&&n>=0)return n;let r=Date.parse(t);if(!Number.isNaN(r)){let e=Math.floor((r-Date.now())/1e3);return e>0?e:0}}function kv(e){if(e instanceof Dn){let t=Dv(e.status);return{kind:t,status:e.status,raw:e.body,retryable:Ev.has(t),retryAfterSec:Ov(e.headers)}}return e instanceof TypeError?{kind:`network`,raw:String(e),retryable:!0}:{kind:`unknown`,raw:String(e),retryable:!1}}var Av=new Set([`Captcha token required`,`Captcha verification failed`]);function jv(e){if(!(e instanceof Dn)||e.status!==403)return null;try{let t=JSON.parse(e.body.trim()).error;return typeof t==`string`?t:null}catch{return null}}function Mv(e){let t=jv(e);return t!==null&&Av.has(t)}var Nv=`Origin not allowed`;function Pv(e){return jv(e)===Nv}function Fv(e){return e===`limit_exceeded`?`daily_limit`:e===`forbidden`||e===`concurrency`?null:`busy`}var Iv=`tavus_pudl_`,Lv=3600*48,Rv=new Map;function zv(){let e=new Date;return`${e.getUTCFullYear()}${String(e.getUTCMonth()+1).padStart(2,`0`)}${String(e.getUTCDate()).padStart(2,`0`)}`}function Bv(e){return`${Iv}${e}`}function Vv(e){try{let t=`${Bv(e)}=`,n=document.cookie.split(`; `).find(e=>e.startsWith(t));if(!n)return 0;let[r,i]=decodeURIComponent(n.slice(t.length)).split(`.`);if(r!==zv())return 0;let a=Number.parseInt(i,10);return Number.isFinite(a)&&a>0?a:0}catch{return 0}}function Hv(e,t){try{let n=encodeURIComponent(`${zv()}.${t}`);document.cookie=`${Bv(e)}=${n}; max-age=${Lv}; path=/; SameSite=Lax`}catch{return}}function Uv(e){let t=Rv.get(e);return t||(t=Yt(e?Vv(e):0),Rv.set(e,t)),t}function Wv(e){if(!e)return;Hv(e,Vv(e)+1);let t=Vv(e),n=Rv.get(e);n?n.value=t:Rv.set(e,Yt(t))}function Gv(e){switch(e){case`blocked`:return`blocked`;case`in-use`:return`in-use`;case`not-found`:return`not-found`;case`not-supported`:case`undefined-mediadevices`:return`unsupported`;default:return null}}function Kv(e,t,n,r){return e===`granted`&&r?`granted`:Gv(e)||(t===`denied`?`blocked`:t===`prompt`?e===`granted`&&n?`granted`:`prompt`:t===`granted`?n?`checking`:`prompt`:e===`granted`?`granted`:n?`checking`:`prompt`)}function qv(e,t){let n=e===`granted`,r=e===`blocked`||e===`in-use`||e===`not-found`||e===`unsupported`;return{status:e,isGranted:n,isBlocked:r,canRequest:e===`prompt`,needsAttention:r||e===`prompt`&&t!==`granted`}}function Jv(e){let[t,n]=j(null);return M(()=>{let t=!1,r=navigator.permissions;if(r?.query)return r.query({name:e}).then(e=>{t||(n(e.state),e.onchange=()=>{t||n(e.state)})}).catch(()=>{}),()=>{t=!0}},[e]),t}function Yv(){let e=Th(),t=Qg(),n=lg(),{micState:r,camState:i,currentMic:a,currentCam:o}=__(),s=Jv(`microphone`),c=Jv(`camera`),l=t===`joined-meeting`||!!n,[u,d]=j(!1),[f,p]=j(!1),m=F(()=>{e&&(d(!0),l?e.setLocalAudio(!0):Promise.resolve(e.startCamera({videoSource:!1})).catch(()=>{}))},[e,l]),h=F(async()=>{if(e){p(!0);try{await e.setInputDevicesAsync({videoSource:!0})}catch{}e.setLocalVideo(!0)}},[e]);return{mic:P(()=>qv(Kv(r,s,u,!!a),s),[r,s,u,a]),camera:P(()=>qv(Kv(i,c,f,!!o),c),[i,c,f,o]),requestMic:m,requestCamera:h}}var Xv=wn(`Flow`),Zv=[`idle`,`unavailable`,`ended`];function Qv({children:e}){let{config:t}=Tv(),{start:n,end:r,session:i,state:a,__beginAttempt:o}=I(av),s=t.value.deployment_id??``,c=Uv(s),l=F(()=>{let e=t.value,n=e.limits?.daily_call_limit_per_user;return n==null||e.channel!==`widget`&&e.channel!==`embed`?null:n},[t]),u=I(Cv),[d,f]=j(`idle`),[p,m]=j(!1),[h,g]=j(null),[_,v]=j(null),[y,b]=j(!1),{mic:x,camera:S,requestMic:C,requestCamera:w}=Yv(),T=P(()=>Yt(`idle`),[]);M(()=>{T.value=d},[d,T]),Cn(()=>{let e=t.value,n=e.limits?.daily_call_limit_per_user;n!=null&&(e.channel!==`widget`&&e.channel!==`embed`||T.value===`idle`&&c.value>=n&&(v(`daily_limit`),b(!1),f(`unavailable`)))});let E=t.value.customization.show_haircheck,D=t.value.customization.conversation.modality,ee=E&&D!==`chat`,te=!E&&D!==`chat`,ne=N(!1),re=N(!1),O=N(null),ie=N(null),ae=F(async(e=new AbortController)=>{ie.current=e;let{signal:r}=e;m(!0);try{let e=await u?.ensureToken()??{kind:`not-required`};if(r.aborted)return;if(e.kind===`unavailable`){v(`error`),b(!0),f(`unavailable`);return}if(await n(void 0,{signal:r}),r.aborted)return;ne.current=!1,l()!=null&&Wv(s),f(`call`)}catch(e){if(r.aborted)return;let n=kv(e);if(Mv(e)&&!ne.current){ne.current=!0,m(!1),f(`idle`);return}if(ne.current=!1,Pv(e)){Xv.error(`/start rejected: origin ${window.location.origin} is not on this deployment's allowed-origins list. Add it in the Tavus portal.`),v(`error`),b(!1),f(`unavailable`);return}if(n.status===401&&t.value.has_password===!0){f(`idle`);return}let i=Fv(n.kind)??`busy`;v(i),b(n.retryable),f(`unavailable`)}finally{ie.current===e&&(ie.current=null),m(!1)}},[n,t,l,s]),k=F(async()=>{let e=O.current;if(e){g(null);try{await ae(e.controller)}finally{O.current===e&&(O.current=null),e.resolve()}}},[ae]),A=F(()=>{let e=O.current;if(!(!e||e.proceeding)){if(e.proceeding=!0,D===`video`&&!S.isGranted&&!S.isBlocked){g({kind:`camera`,status:S.status}),w().finally(()=>{k()});return}k()}},[D,S,w,k]);M(()=>{if(!(!O.current||h?.kind!==`microphone`)){if(h.status!==x.status&&g({kind:`microphone`,status:x.status}),x.isGranted){A();return}if(x.isBlocked){let e=O.current;O.current=null,m(!1),e.resolve()}}},[h,x,A]);let oe=F(()=>{if(O.current)return O.current.promise;let e,t=new Promise(t=>{e=t});return O.current={promise:t,resolve:e,proceeding:!1,controller:new AbortController},m(!0),x.isGranted?A():x.isBlocked?(g({kind:`microphone`,status:x.status}),O.current=null,m(!1),e()):(g({kind:`microphone`,status:x.status}),C()),t},[x,C,A]),se=F(async()=>{if(!Zv.includes(d))return;let e=l();if(e!=null&&c.value>=e){v(`daily_limit`),b(!1),f(`unavailable`);return}if(v(null),b(!1),o(),ee&&!re.current){f(`haircheck`);return}return te?oe():ae()},[d,ee,te,oe,ae,l,c,o]),ce=F(async()=>{d===`haircheck`&&(re.current=!0,await ae())},[d,ae]),le=F(()=>{let e=O.current,t=e?.controller??ie.current;e&&(O.current=null,e.resolve(),g(null)),t?.abort(),t&&m(!1),d===`haircheck`&&f(`idle`)},[d]),ue=F(()=>{d===`call`&&f(`ended`)},[d]);M(()=>{let e=()=>{let e=O.current!==null||ie.current!==null,t=d===`haircheck`||d===`call`,n=i.peek()!==null,o=n&&a.peek()!==`ended`;!e&&!t&&!n||(le(),(d===`call`||o)&&f(`ended`),r())};return window.addEventListener(`pagehide`,e),()=>window.removeEventListener(`pagehide`,e)},[d,i,a,le,r]);let de=F(()=>{v(null),b(!1),f(`idle`)},[]),fe=P(()=>({flowSignal:T,setFlowState:f,isStarting:p,permissionRequest:h,unavailableCause:_,canRetry:y,start:se,join:ce,cancel:le,leave:ue,restart:de}),[T,p,h,_,y,se,ce,le,ue,de]);return L(T_.Provider,{value:fe,children:e})}var $v=wn(`HostBridge`),ey=Ae(null);function ty(e){if(!e)return null;let t=e.getRootNode();return t instanceof ShadowRoot&&t.host instanceof HTMLElement?t.host:e.parentElement}function ny({children:e}){let t=I(av),n=I(Di),r=I(T_),i=I(kt),a=gn(null),o=i?.overrideConfig,s=F(e=>{a.value=ty(e)},[a]),c=F((e,t)=>{let n=a.peek();n&&n.dispatchEvent(new CustomEvent(e,{detail:t,bubbles:!0,composed:!0})),$v.info(`Event:`,e,t)},[a]);M(()=>{let e=a.value;if(!e)return;let n={tavus:{start:t.start,end:t.end,sendChat:t.sendChat,sendMessage:t.sendMessage},startConversation:async()=>{try{r?await r.start():await t.start()}catch(e){$v.error(`startConversation failed`,e)}},endConversation:async()=>{try{let e=r?.flowSignal.peek();e===`call`?r?.leave():e===`haircheck`?r?.cancel():t.session.peek()&&await t.end()}catch(e){$v.error(`endConversation failed`,e)}},sendMessage:e=>{t.sendMessage(typeof e==`string`?{event_type:`conversation.respond`,properties:{text:e}}:e)},updateConfig:t=>{let n=Nn(o??{},t);e.setAttribute(`override-config`,JSON.stringify(n))},destroy:()=>{t.session.peek()&&t.end(),e.remove()}};return Object.assign(e,n),()=>{for(let t of Object.keys(n))delete e[t]}},[a.value,t,r,o]);let l=N(!1);M(()=>{l.current||!a.value||!n||(l.current=!0,c(`tavus:ready`,{deploymentId:n.deploymentId}))},[a.value,n,c]);let u=N(null);M(()=>t.state.subscribe(e=>{if(e!==u.current)switch(u.current=e,e){case`connected`:c(`tavus:conversation-started`,{conversationId:t.session.peek()?.conversationId??``}),c(`tavus:state-change`,{state:e});break;case`ended`:c(`tavus:conversation-ended`,{conversationId:t.session.peek()?.conversationId??``}),c(`tavus:state-change`,{state:e});break;case`error`:c(`tavus:error`,{code:`CONVERSATION_ERROR`,message:t.error.peek()??`Unknown error`}),c(`tavus:state-change`,{state:e});break;default:c(`tavus:state-change`,{state:e})}}),[t,c]),Cn(()=>{if(!r)return;let e=r.flowSignal.value;c(`tavus:mode-change`,{mode:e})}),M(()=>{let e={onUtterance(e){c(`tavus:protocol-message`,{kind:`utterance`,event_type:`conversation.utterance`,properties:e})},onToolCall(e){c(`tavus:tool-call`,e),c(`tavus:protocol-message`,{kind:`tool_call`,event_type:`conversation.tool_call`,properties:e})},onPerception(e){c(`tavus:protocol-message`,e)},onSpeakingState({who:e,state:t,seq:n,turn_idx:r}){let i={state:t,...n===void 0?{}:{seq:n},...r===void 0?{}:{turn_idx:r}};c(`tavus:protocol-message`,{kind:`speaking`,event_type:e===`replica`?t===`started`?`conversation.replica_started_speaking`:`conversation.replica_stopped_speaking`:t===`started`?`conversation.user_started_speaking`:`conversation.user_stopped_speaking`,properties:i})},onMessage(e){c(`tavus:protocol-message`,e)}};return t.__registerSubscriber(e),()=>t.__unregisterSubscriber(e)},[t,c]);let d=P(()=>({shadowHost:a,dispatchEvent:c}),[a,c]);return L(ey.Provider,{value:d,children:[L(`div`,{ref:s,style:`display:contents`}),e]})}var ry=Ae(null);function iy({children:e}){let{config:t}=I(Di),n=P(()=>en(()=>{let e=t.value.customization.style;return e.mode===`dark`||e.mode===`system`&&(globalThis.matchMedia?.(`(prefers-color-scheme: dark)`).matches??!1)}),[t]),r=P(()=>en(()=>{let e=t.value.customization.style;return e.style===`basic`?n.value?`white-black`:`black-white`:n.value?`${e.style}-dark`:e.style}),[t,n]),i=P(()=>en(()=>cy(t.value.customization.style)),[t]),a=P(()=>({dataTheme:r,isDark:n,cssVars:i}),[r,n,i]);return L(ry.Provider,{value:a,children:L(`div`,{"data-theme":r.value,style:ly(i.value),class:`contents`,children:e})})}var ay=[0,.125,.25,.5,.75],oy=[0,1,2,3,4],sy=[0,.2,.25,.3];function cy(e){return{"--radius-box":`${ay[e.boxes_radius]??.5}rem`,"--radius-field":`${ay[e.field_radius]??.25}rem`,"--radius-selector":`${ay[e.selectors_radius]??.5}rem`,"--border":`${oy[e.border_width]??1}px`,"--size-field":`${sy[e.fields_size]??.25}rem`,"--size-selector":`${sy[e.selectors_size]??.25}rem`,"--depth":e.depth_effect?`1`:`0`,"--noise":e.noise_effect?`1`:`0`}}function ly(e){return Object.entries(e).map(([e,t])=>`${e}: ${t}`).join(`; `)}var uy=.5,dy=.01;function fy(e,t){if(!hy(e)||!hy(t))return null;let n=e.left-t.left,r=e.top-t.top,i=e.width/t.width,a=e.height/t.height;return Math.abs(n)<uy&&Math.abs(r)<uy&&Math.abs(i-1)<dy&&Math.abs(a-1)<dy?null:`translate(${gy(n)}px, ${gy(r)}px) scale(${gy(i)}, ${gy(a)})`}function py(e){if(e==null)return null;let t=my(e.width),n=my(e.height);return t===null&&n===null?null:{width:t,height:n}}function my(e){return Number.isFinite(e)&&e>0?e:null}function hy(e){return Number.isFinite(e.left)&&Number.isFinite(e.top)&&Number.isFinite(e.width)&&Number.isFinite(e.height)&&e.width>0&&e.height>0}function gy(e){return Math.round(e*1e3)/1e3}function _y(e,t){M(()=>{let n=e.current;if(!n)return;let r=new ResizeObserver(e=>{let n=e[0];n&&t(n)});return r.observe(n),()=>r.disconnect()},[e,t])}var vy=new WeakMap;function yy(e){let t=vy.get(e);t?t.holders+=1:vy.set(e,{holders:1,restore:by(e)});let n=!1;return()=>{if(n)return;n=!0;let t=vy.get(e);t&&(--t.holders,!(t.holders>0)&&(vy.delete(e),t.restore()))}}function by(e){let{body:t,documentElement:n}=e,r=n.style.overflowX,i=n.style.overflowY,a=t.style.paddingRight,o=n.clientWidth;n.style.overflow=`hidden`;let s=n.clientWidth-o,c=s>0?`${xy(t)+s}px`:null;return c&&(t.style.paddingRight=c),()=>{n.style.overflow===`hidden`&&(n.style.overflow=``,n.style.overflowX=r,n.style.overflowY=i),c&&t.style.paddingRight===c&&(t.style.paddingRight=a)}}function xy(e){let t=e.ownerDocument.defaultView?.getComputedStyle(e).paddingRight,n=Number.parseFloat(t??``);return Number.isFinite(n)?n:0}var Sy=Ae(null),Cy=480,wy=768,Ty=`relative w-full h-full`,Ey=`m-0 p-0 border-0 bg-transparent text-inherit max-w-none max-h-none`,Dy=`${Ey} block static w-full h-full`,Oy=`${Ey} fixed inset-0 flex items-center justify-center w-screen h-dvh backdrop:bg-black/60 motion-safe:backdrop:animate-[tavusFadeIn_180ms_ease-out]`,ky=`relative outline-none aspect-[var(--tavus-expand-aspect)] [--tavus-expand-default-max-width:1280px] [--tavus-expand-default-max-height:900px] [@media(min-width:2560px)]:[--tavus-expand-default-max-width:1600px] [@media(min-width:2560px)]:[--tavus-expand-default-max-height:1200px] w-[var(--tavus-expand-width)] h-[var(--tavus-expand-height)] max-w-[var(--tavus-expand-max-width)] max-h-[var(--tavus-expand-max-height)] [@media(max-width:768px)]:w-screen [@media(max-width:768px)]:h-dvh [@media(max-width:768px)]:max-w-none [@media(max-width:768px)]:max-h-none`,Ay=280,jy=`cubic-bezier(0.22, 1, 0.36, 1)`,My={kind:`inline`};function Ny(e,t,{isStarting:n=!1,awaitingPermission:r=!1,startWasUnderway:i=!1}={}){return e?t===`haircheck`||t===`call`||n||r?!0:t===`unavailable`&&i:!1}function Py(e){return typeof e?.showModal==`function`&&typeof e.close==`function`}function Fy(e,t){let n=e.flowSignal.peek(),r=n===`call`,i=r||n===`haircheck`||e.isStarting;e.cancel(),r&&e.leave(),i&&t?.()}function Iy({children:e}){let t=N(null),n=N(null),r=P(()=>Yt(`full`),[]),[i,a]=j(My),o=I(kt),s=I(T_),c=I(ey),l=I(Cv),u=I(av),d=o?.expandOptions,f=c?.shadowHost.value??null,p=s?.flowSignal.value??`idle`,m=s?.isStarting??!1,h=s?.permissionRequest!=null,g=N(!1);M(()=>{m||p===`haircheck`||p===`call`?g.current=!0:(p===`idle`||p===`ended`)&&(g.current=!1)},[m,p]);let _=Ny(d?.enabled===!0,p,{isStarting:m,awaitingPermission:h,startWasUnderway:g.current}),v=i.kind!==`inline`;at(()=>{let e=t.current;if(e)if(i.kind===`inline`){if(!_||!Py(n.current))return;let t=e.getBoundingClientRect();a({kind:`expanding`,from:t,slot:py(f?.getBoundingClientRect())})}else!_&&i.kind!==`collapsing`?a({kind:`collapsing`,from:e.getBoundingClientRect(),slot:i.slot}):_&&i.kind===`collapsing`&&a({kind:`expanding`,from:e.getBoundingClientRect(),slot:i.slot})},[_,i,f]);let y=i.kind===`inline`?null:i.slot;at(()=>{if(!f||!y)return;let e=f.style.minWidth,t=f.style.minHeight;return y.width!==null&&(f.style.minWidth=`${y.width}px`),y.height!==null&&(f.style.minHeight=`${y.height}px`),()=>{f.style.minWidth=e,f.style.minHeight=t}},[f,y]);let b=F(()=>{s&&Fy(s,u?.end)},[s,u]),x=N(b);x.current=b,at(()=>{let e=n.current;if(!e||!v||!Py(e))return;let t=()=>{!e.isConnected||e.open||(e.showModal(),x.current())};return e.addEventListener(`close`,t),e.open||e.showModal(),()=>{e.removeEventListener(`close`,t),e.open&&e.close()}},[v]),at(()=>{if(!(!f||!v))return yy(f.ownerDocument)},[f,v]),at(()=>{let e=t.current;if(!e||i.kind!==`expanding`&&i.kind!==`collapsing`)return;let n=()=>a(i.kind===`expanding`?{kind:`expanded`,slot:i.slot}:My),r=e.getBoundingClientRect(),o=c?.shadowHost.peek()??null,s=i.kind===`expanding`?r:o?.getBoundingClientRect()??r,l=fy(i.from,r)??`none`,u=fy(s,r)??`none`,d=globalThis.matchMedia?.(`(prefers-reduced-motion: reduce)`).matches??!1;if(l===u||d||typeof e.animate!=`function`){n();return}let f=e.animate([{transform:l,transformOrigin:`top left`},{transform:u,transformOrigin:`top left`}],{duration:Ay,easing:jy,fill:`forwards`}),p=!1;return f.finished.then(()=>{p||n()},()=>{}),()=>{p=!0,f.cancel()}},[i,c]),at(()=>{let e=n.current;if(!e||!v)return;let t=e=>{e.preventDefault(),x.current()};return e.addEventListener(`cancel`,t),()=>e.removeEventListener(`cancel`,t)},[v]);let S=F(e=>{let t=e.contentRect.width;t<Cy?r.value=`compact`:t<wy?r.value=`medium`:r.value=`full`},[r]);M(()=>{if(l)return l.promptSlot.value=t.current,()=>{l.promptSlot.value=null}},[l,v]),_y(t,S);let C=P(()=>({layoutMode:r,containerRef:t}),[r,t]);return L(Sy.Provider,{value:C,children:L(`dialog`,{ref:n,class:v?Oy:Dy,"aria-label":v?`Conversation`:void 0,role:v?void 0:`none`,children:L(`div`,{ref:t,class:v?ky:Ty,style:v?Et(Tt(d).vars):void 0,tabIndex:v?-1:void 0,autofocus:v,children:e})})})}var Ly=`@container/conversation w-full h-full`,Ry=`motion-safe:animate-[tavusFadeUp_280ms_ease-out]`,zy=`relative w-full h-full max-h-screen aspect-video @max-mobile:aspect-9/16 overflow-hidden rounded-box`;function By({animate:e=!1,innerClassName:t,innerStyle:n,innerRef:r,role:i,"aria-live":a,"aria-label":o,children:s}){return L(`div`,{class:e?`${Ly} ${Ry}`:Ly,children:L(`div`,{ref:r,class:t?`${zy} ${t}`:zy,style:n,role:i,"aria-live":a,"aria-label":o,children:s})})}var Vy=41/2,Hy=23/2,Uy=Math.hypot(Vy,Hy),Wy=Array.from({length:1008},(e,t)=>{let n=t%42,r=Math.floor(t/42),i=Math.hypot(n-Vy,r-Hy)/Uy*.82,a=.34+(n*13+r*7)%34/100;return{delay:`${i.toFixed(3)}s`,opacity:a.toFixed(2)}});function Gy(){return L(By,{innerClassName:`embed-loading-screen`,role:`status`,"aria-live":`polite`,"aria-label":`Loading deployment`,children:L(`div`,{class:`embed-loading-dot-field`,"aria-hidden":`true`,style:{"--dot-columns":`42`,"--dot-rows":`24`},children:Wy.map((e,t)=>L(`span`,{class:`embed-loading-field-dot`,style:{"--dot-delay":e.delay,"--dot-opacity":e.opacity}},t))})})}var Ky=Ae(null);function qy({children:e}){let t=N(null);return L(Ky.Provider,{value:{frameRef:t},children:L(`div`,{class:`@container/conversation w-full h-full`,children:L(`div`,{ref:t,class:`relative w-full h-full max-h-screen aspect-video @max-mobile:aspect-9/16 overflow-hidden rounded-box bg-base-100 has-[.cvi-video-surface]:will-change-transform`,children:e})})})}var Jy=(...e)=>e.filter((e,t,n)=>!!e&&e.trim()!==``&&n.indexOf(e)===t).join(` `).trim(),Yy=e=>e.replace(/([a-z0-9])([A-Z])/g,`$1-$2`).toLowerCase(),Xy=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,t,n)=>n?n.toUpperCase():t.toLowerCase()),Zy=e=>{let t=Xy(e);return t.charAt(0).toUpperCase()+t.slice(1)},Qy={xmlns:`http://www.w3.org/2000/svg`,width:24,height:24,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,"stroke-width":`2`,"stroke-linecap":`round`,"stroke-linejoin":`round`},$y=Ae({size:24,color:`currentColor`,strokeWidth:2,absoluteStrokeWidth:!1,class:``}),eb=()=>I($y),tb=e=>{for(let t in e)if(t.startsWith(`aria-`)||t===`role`||t===`title`)return!0;return!1},nb=({color:e,size:t,strokeWidth:n,absoluteStrokeWidth:r,children:i,iconNode:a,class:o=``,...s})=>{let{size:c=24,strokeWidth:l=2,absoluteStrokeWidth:u=!1,color:d=`currentColor`,class:f=``}=eb()??{},p=r??u?Number(n??l)*24/Number(t??c):n??l;return O(`svg`,{...Qy,width:t??c??24,height:t??c??24,stroke:e??d,"stroke-width":p,class:Jy(`lucide`,f,o),...!i&&!tb(s)&&{"aria-hidden":`true`},...s},[...a.map(([e,t])=>O(e,t)),...me(i)])},rb=(e,t)=>{let n=({class:n=``,className:r=``,children:i,...a})=>O(nb,{...a,iconNode:t,class:Jy(`lucide-${Yy(Zy(e))}`,`lucide-${Yy(e)}`,n,r)},i);return n.displayName=Zy(e),n},ib=rb(`camera-off`,[[`path`,{d:`M14.564 14.558a3 3 0 1 1-4.122-4.121`,key:`1rnrzw`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}],[`path`,{d:`M20 20H4a2 2 0 0 1-2-2V9a2 2 0 0 1 2-2h1.997a2 2 0 0 0 .819-.175`,key:`1x3arw`}],[`path`,{d:`M9.695 4.024A2 2 0 0 1 10.004 4h3.993a2 2 0 0 1 1.76 1.05l.486.9A2 2 0 0 0 18.003 7H20a2 2 0 0 1 2 2v7.344`,key:`1i84u0`}]]),ab=rb(`camera`,[[`path`,{d:`M13.997 4a2 2 0 0 1 1.76 1.05l.486.9A2 2 0 0 0 18.003 7H20a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V9a2 2 0 0 1 2-2h1.997a2 2 0 0 0 1.759-1.048l.489-.904A2 2 0 0 1 10.004 4z`,key:`18u6gg`}],[`circle`,{cx:`12`,cy:`13`,r:`3`,key:`1vg3eu`}]]),ob=rb(`captions`,[[`rect`,{width:`18`,height:`14`,x:`3`,y:`5`,rx:`2`,ry:`2`,key:`12ruh7`}],[`path`,{d:`M7 15h4M15 15h2M7 11h2M13 11h4`,key:`1ueiar`}]]),sb=rb(`clock`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 6v6l4 2`,key:`mmk7yg`}]]),cb=rb(`ellipsis`,[[`circle`,{cx:`12`,cy:`12`,r:`1`,key:`41hilf`}],[`circle`,{cx:`19`,cy:`12`,r:`1`,key:`1wjl8i`}],[`circle`,{cx:`5`,cy:`12`,r:`1`,key:`1pcz8c`}]]),lb=rb(`expand`,[[`path`,{d:`m15 15 6 6`,key:`1s409w`}],[`path`,{d:`m15 9 6-6`,key:`ko1vev`}],[`path`,{d:`M21 16v5h-5`,key:`1ck2sf`}],[`path`,{d:`M21 8V3h-5`,key:`1qoq8a`}],[`path`,{d:`M3 16v5h5`,key:`1t08am`}],[`path`,{d:`m3 21 6-6`,key:`wwnumi`}],[`path`,{d:`M3 8V3h5`,key:`1ln10m`}],[`path`,{d:`M9 9 3 3`,key:`v551iv`}]]),ub=rb(`external-link`,[[`path`,{d:`M15 3h6v6`,key:`1q9fwt`}],[`path`,{d:`M10 14 21 3`,key:`gplh6r`}],[`path`,{d:`M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6`,key:`a6xqqp`}]]),db=rb(`maximize-2`,[[`path`,{d:`M15 3h6v6`,key:`1q9fwt`}],[`path`,{d:`m21 3-7 7`,key:`1l2asr`}],[`path`,{d:`m3 21 7-7`,key:`tjx5ai`}],[`path`,{d:`M9 21H3v-6`,key:`wtvkvv`}]]),fb=rb(`message-circle`,[[`path`,{d:`M2.992 16.342a2 2 0 0 1 .094 1.167l-1.065 3.29a1 1 0 0 0 1.236 1.168l3.413-.998a2 2 0 0 1 1.099.092 10 10 0 1 0-4.777-4.719`,key:`1sd12s`}]]),pb=rb(`mic-off`,[[`path`,{d:`M12 19v3`,key:`npa21l`}],[`path`,{d:`M15 9.34V5a3 3 0 0 0-5.68-1.33`,key:`1gzdoj`}],[`path`,{d:`M16.95 16.95A7 7 0 0 1 5 12v-2`,key:`cqa7eg`}],[`path`,{d:`M18.89 13.23A7 7 0 0 0 19 12v-2`,key:`16hl24`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}],[`path`,{d:`M9 9v3a3 3 0 0 0 5.12 2.12`,key:`r2i35w`}]]),mb=rb(`mic`,[[`path`,{d:`M12 19v3`,key:`npa21l`}],[`path`,{d:`M19 10v2a7 7 0 0 1-14 0v-2`,key:`1vc78b`}],[`rect`,{x:`9`,y:`2`,width:`6`,height:`13`,rx:`3`,key:`s6n7sd`}]]),hb=rb(`minimize-2`,[[`path`,{d:`m14 10 7-7`,key:`oa77jy`}],[`path`,{d:`M20 10h-6V4`,key:`mjg0md`}],[`path`,{d:`m3 21 7-7`,key:`tjx5ai`}],[`path`,{d:`M4 14h6v6`,key:`rmj7iw`}]]),gb=rb(`monitor-up`,[[`path`,{d:`m9 10 3-3 3 3`,key:`11gsxs`}],[`path`,{d:`M12 13V7`,key:`h0r20n`}],[`rect`,{width:`20`,height:`14`,x:`2`,y:`3`,rx:`2`,key:`48i651`}],[`path`,{d:`M12 17v4`,key:`1riwvh`}],[`path`,{d:`M8 21h8`,key:`1ev6f3`}]]),_b=rb(`moon`,[[`path`,{d:`M20.985 12.486a9 9 0 1 1-9.473-9.472c.405-.022.617.46.402.803a6 6 0 0 0 8.268 8.268c.344-.215.825-.004.803.401`,key:`kfwtm`}]]),vb=rb(`phone-off`,[[`path`,{d:`M10.1 13.9a14 14 0 0 0 3.732 2.668 1 1 0 0 0 1.213-.303l.355-.465A2 2 0 0 1 17 15h3a2 2 0 0 1 2 2v3a2 2 0 0 1-2 2 18 18 0 0 1-12.728-5.272`,key:`1wngk7`}],[`path`,{d:`M22 2 2 22`,key:`y4kqgn`}],[`path`,{d:`M4.76 13.582A18 18 0 0 1 2 4a2 2 0 0 1 2-2h3a2 2 0 0 1 2 2v3a2 2 0 0 1-.8 1.6l-.468.351a1 1 0 0 0-.292 1.233 14 14 0 0 0 .244.473`,key:`10hv5p`}]]),yb=rb(`picture-in-picture-2`,[[`path`,{d:`M21 9V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v10c0 1.1.9 2 2 2h4`,key:`daa4of`}],[`rect`,{width:`10`,height:`7`,x:`12`,y:`13`,rx:`2`,key:`1nb8gs`}]]),bb=rb(`send`,[[`path`,{d:`M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z`,key:`1ffxy3`}],[`path`,{d:`m21.854 2.147-10.94 10.939`,key:`12cjpa`}]]),xb=rb(`shrink`,[[`path`,{d:`m15 15 6 6m-6-6v4.8m0-4.8h4.8`,key:`17vawe`}],[`path`,{d:`M9 19.8V15m0 0H4.2M9 15l-6 6`,key:`chjx8e`}],[`path`,{d:`M15 4.2V9m0 0h4.8M15 9l6-6`,key:`lav6yq`}],[`path`,{d:`M9 4.2V9m0 0H4.2M9 9 3 3`,key:`1pxi2q`}]]),Sb=rb(`smile`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M8 14s1.5 2 4 2 4-2 4-2`,key:`1y1vjs`}],[`line`,{x1:`9`,x2:`9.01`,y1:`9`,y2:`9`,key:`yxxnd0`}],[`line`,{x1:`15`,x2:`15.01`,y1:`9`,y2:`9`,key:`1p4y9e`}]]),Cb=rb(`triangle-alert`,[[`path`,{d:`m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3`,key:`wmoenq`}],[`path`,{d:`M12 9v4`,key:`juzpu7`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]]),wb=rb(`user`,[[`path`,{d:`M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2`,key:`975kel`}],[`circle`,{cx:`12`,cy:`7`,r:`4`,key:`17ys0d`}]]),Tb=rb(`users`,[[`path`,{d:`M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2`,key:`1yyitq`}],[`path`,{d:`M16 3.128a4 4 0 0 1 0 7.744`,key:`16gr8j`}],[`path`,{d:`M22 21v-2a4 4 0 0 0-3-3.87`,key:`kshegd`}],[`circle`,{cx:`9`,cy:`7`,r:`4`,key:`nufk8`}]]),Eb=rb(`x`,[[`path`,{d:`M18 6 6 18`,key:`1bl5f8`}],[`path`,{d:`m6 6 12 12`,key:`d8bk6v`}]]);function Db(e,t){return({size:n=`var(--icon-size, 1.5rem)`,class:r,"aria-label":i,"aria-hidden":a})=>L(`span`,{class:r,role:a?void 0:`img`,"aria-hidden":a||void 0,"aria-label":a?void 0:i??t,children:L(e,{size:n})})}var Ob={close:Db(Eb,`Close`),cancel:Db(Eb,`Cancel`),leave:Db(vb,`Leave call`),more:Db(cb,`More`),error:Db(Cb,`Error`),mic:Db(mb,`Microphone`),"mic-off":Db(pb,`Microphone muted`),cam:Db(ab,`Camera`),"cam-off":Db(ib,`Camera off`),"screen-share":Db(gb,`Screen share`),pip:Db(yb,`Picture in picture`),user:Db(wb,`User`),"face-smile":Db(Sb,`Camera off`),captions:Db(ob,`Closed captions`),chat:Db(fb,`Chat`),fullscreen:Db(db,`Enter fullscreen`),"fullscreen-exit":Db(hb,`Exit fullscreen`),expand:Db(lb,`Expand`),collapse:Db(xb,`Collapse`),send:Db(bb,`Send`),"external-link":Db(ub,`External link`),clock:Db(sb,`Clock`),moon:Db(_b,`Unavailable`),users:Db(Tb,`Busy`)},kb=`<svg xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 24 24"><path d="M20 21h-2v-2h2v2Zm-6-2H4v-2h10v2Zm4 0h-2v-2h2v2Zm4 0h-2v-2h-2v-2h-2v-2h-2V7h2v2h2V7h2V5h2v14ZM4 17H2V7h2v10Zm12 0h-2v-2h2v2Zm-2-2h-2v-2h2v2Zm-2-2h-2v-2h2v2Zm-2-2H8V9h2v2ZM8 9H6V7h2v2ZM6 7H4V5h2v2Zm8 0h-4V5h4v2ZM4 5H2V3h2v2Z"/></svg>`,Ab=`<svg xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 24 24"><path d="M3 4h18v2H3zm0 14h18v2H3zM1 6h2v12H1zm20 0h2v12h-2zM5 10h2v4H5zm8 0h2v4h-2zM7 8h4v2H7zm0 6h4v2H7zm8 0h4v2h-4zm0-6h4v2h-4z"/></svg>`,jb=`<svg xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 24 24"><path d="M22 22h-2v-2h-2v-2h2v-8h2v12Zm-4-4h-8v-2h8v2ZM4 12h2v2H4v2H2V4h2v8Zm6 4H8v-6h2v6Zm10-6H10V8h10v2Zm-4-4h-2V4h2v2Zm-2-2H4V2h10v2Z"/></svg>`,Mb=`<svg xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 24 24"><path d="M18 22H6v-2h12v2ZM6 20H4v-2h2v2Zm14 0h-2v-2h2v2ZM4 18H2V6h2v12Zm18 0h-2V6h2v12Zm-5-1h-2v-2h2v2Zm-2-2h-2v-2h2v2Zm-2-2h-2V6h2v7ZM6 6H4V4h2v2Zm14 0h-2V4h2v2Zm-2-2H6V2h12v2Z"/></svg>`,Nb=`<svg xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 24 24"><path d="M18 22H6v-2h12v2ZM6 20H4v-2h2v2Zm14 0h-2v-2h2v2ZM4 18H2V6h2v12Zm4 0H6v-2h2v2Zm14 0h-2V6h2v12Zm-12-2H8v-2h2v2Zm2-2h-2v-2h2v2Zm2-2h-2v-2h2v2Zm2-2h-2V8h2v2Zm2-2h-2V6h2v2ZM6 6H4V4h2v2Zm14 0h-2V4h2v2Zm-2-2H6V2h12v2Z"/></svg>`,Pb=`<svg xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 24 24"><path d="M7 19H5v-2h2v2Zm12 0h-2v-2h2v2ZM9 15v2H7v-2h2Zm8 2h-2v-2h2v2Zm-6-2H9v-2h2v2Zm4 0h-2v-2h2v2Zm-2-2h-2v-2h2v2Zm-2-2H9V9h2v2Zm4 0h-2V9h2v2ZM9 9H7V7h2v2Zm8 0h-2V7h2v2ZM7 7H5V5h2v2Zm12 0h-2V5h2v2Z"/></svg>`,Fb=`<svg xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 24 24"><path d="M7 19h2v-2h2v-2h2v2h2v2h2v2H7v-2Zm13-6H4v-2h16v2Zm-3-8h-2v2h-2v2h-2V7H9V5H7V3h10v2Z"/></svg>`,Ib=`<svg xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 24 24"><path d="M20 22H4v-2h16v2ZM4 20H2V4h2v16Zm18 0h-2V4h2v16Zm-9-2h-2v-2h2v2Zm0-4h-2V6h2v8Zm7-10H4V2h16v2Z"/></svg>`,Lb=`<svg xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 24 24"><path d="M15 19h-2v2h-2v-2H9v-2H7v-2h10v2h-2v2Zm5-6H4v-2h16v2Zm-7-8h2v2h2v2H7V7h2V5h2V3h2v2Z"/></svg>`,Rb=`<svg xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 24 24"><path d="M8 22H4v-2h4v2Zm12 0h-4v-2h4v2ZM4 20H2v-4h2v4Zm18 0h-2v-4h2v4Zm-6-3H8v-2h8v2Zm-8-2H6V9h2v6Zm10 0h-2V9h2v6Zm-2-6H8V7h8v2ZM4 8H2V4h2v4Zm18 0h-2V4h2v4ZM8 4H4V2h4v2Zm12 0h-4V2h4v2Z"/></svg>`,zb=`<svg xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 24 24"><path d="M18 22H6v-2h12v2ZM6 20H4V4h2v16Zm14 0h-2v-3h2v3ZM16 9h2v2h2v2h-2v2h-2v2h-2v-4H8v-2h6V7h2v2Zm4-2h-2V4h2v3Zm-2-3H6V2h12v2Z"/></svg>`,Bb=`<svg xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 24 24"><path d="M13 22h-2v-2H8v-2h8v2h-3v2Zm-5-4H6v-2h2v2Zm10 0h-2v-2h2v2ZM6 16H4v-6h2v6Zm8 0h-4v-2h4v2Zm6 0h-2v-6h2v6Zm-10-2H8V4h2v10Zm6 0h-2V4h2v10ZM14 4h-4V2h4v2Z"/></svg>`,Vb=`<svg xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 24 24"><path d="M13 22h-2v-2H8v-2h8v2h-3v2Zm9 0h-2v-2h2v2Zm-2-2h-2v-2h2v2ZM8 18H6v-2h2v2Zm10 0h-2v-2h2v2ZM6 16H4v-6h2v6Zm8-2h2v2h-6v-2h2v-2h2v2Zm-4-4h2v2h-2v2H8V8h2v2Zm10 4h-2v-4h2v4Zm-4-4h-2V4h2v6ZM8 8H6V6h2v2ZM6 6H4V4h2v2ZM4 4H2V2h2v2Zm10 0h-4V2h4v2Z"/></svg>`,Hb=`<svg xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 24 24"><path d="M18 22H8v-2h10v2ZM8 20H6v-2h2v2Zm12 0h-2v-2h2v2ZM6 18H4v-2h2v2Zm16 0h-2v-4h-2v-2h2v-2h2v8ZM4 16H2V6h2v10Zm14 0h-6v-2h6v2Zm-6-2h-2v-2h2v2Zm-2-2H8V6h2v6ZM6 6H4V4h2v2Zm8-2h-2v2h-2V4H6V2h8v2Z"/></svg>`,Ub=`<svg xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 24 24"><path d="M5 15H3v-2h2v2Zm8 0h-2v-2h2v2Zm8 0h-2v-2h2v2ZM3 13H1v-2h2v2Zm4 0H5v-2h2v2Zm4 0H9v-2h2v2Zm4 0h-2v-2h2v2Zm4 0h-2v-2h2v2Zm4 0h-2v-2h2v2ZM5 11H3V9h2v2Zm8 0h-2V9h2v2Zm8 0h-2V9h2v2Z"/></svg>`,Wb=`<svg xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 24 24"><path d="M20 20H4v-2h16v2ZM4 18H2V6h2v12Zm18 0h-2V6h2v12ZM18 8v6h-8V8h8Zm2-2H4V4h16v2Zm-4 4h-4v2h4v-2Z"/></svg>`,Gb=`<svg xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 24 24"><path d="M20 18h-7v2h3v2H8v-2h3v-2H4v-2h16v2ZM4 16H2V4h2v12Zm18 0h-2v-6h2v6Zm-6-6h-2V8h2v2Zm2-2h-2V6h2v2Zm4-6v6h-2V6h-2V4h-2V2h6Zm-8 2H4V2h10v2Z"/></svg>`,Kb=`<svg xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 24 24"><path d="M4 19h4v2H2v-8h2v6Zm8 0H8v-2h4v2Zm4-2h-4v-2h4v2Zm4-2h-4v-2h4v2Zm-10-2H4v-2h6v2Zm12 0h-2v-2h2v2ZM8 5H4v6H2V3h6v2Zm12 6h-4V9h4v2Zm-4-2h-4V7h4v2Zm-4-2H8V5h4v2Z"/></svg>`,qb=`<svg xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 24 24"><path d="M6 22H4v-4h2v4Zm14 0h-2v-4h2v4ZM8 18H6v-2h2v2Zm10 0h-2v-2h2v2Zm-2-2H8v-2h8v2Zm-1-4H9v-2h6v2Zm-6-2H7V4h2v6Zm8 0h-2V4h2v6Zm-2-6H9V2h6v2Z"/></svg>`,Jb=`<svg xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 24 24"><path d="M2 22H0v-4h2v4Zm14 0h-2v-4h2v4Zm8 0h-2v-4h2v4ZM4 18H2v-2h2v2Zm10 0h-2v-2h2v2Zm8 0h-2v-2h2v2Zm-10-2H4v-2h8v2Zm8 0h-4v-2h4v2Zm-9-4H5v-2h6v2Zm8 0h-4v-2h4v2ZM5 10H3V4h2v6Zm8 0h-2V4h2v6Zm8 0h-2V4h2v6ZM11 4H5V2h6v2Zm8 0h-4V2h4v2Z"/></svg>`,Yb=`<svg xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 24 24"><path d="M20 22H4v-2h16v2ZM4 20H2v-6H0v-2h2V8h2v12Zm18-8h2v2h-2v6h-2V8h2v4Zm-8 6h-4v-2h4v2Zm-4-2H8v-2h2v2Zm6 0h-2v-2h2v2Zm-6-4H8v-2h2v2Zm6 0h-2v-2h2v2Zm-3-6h7v2H4V6h7V4h2v2Zm4-2h-4V2h4v2Z"/></svg>`,Xb=`<svg xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 24 24"><path d="M17 21H5v-2h12v2ZM5 19H3V7h2v12Zm14 0h-2v-6h2v6Zm-8-4H9v-2h2v2Zm2-2h-2v-2h2v2Zm2-2h-2V9h2v2Zm6 0h-2V7h-2V5h-4V3h8v8Zm-4-2h-2V7h2v2Zm-6-2H5V5h6v2Z"/></svg>`,Zb=`<svg xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 24 24"><path d="M16 9h2V7h2V5h2v14h-2v-2h-2v-2h-2v4H2V5h14v4ZM4 17h10V7H4v10Z"/></svg>
52
- `;function Qb(e){return e.replace(/\s(width|height)="\d+"/g,``)}function $b(e,t){let n=Qb(e);return({size:e=`var(--icon-size, 1.5rem)`,class:r,"aria-label":i,"aria-hidden":a})=>L(`span`,{class:r,role:a?void 0:`img`,"aria-hidden":a||void 0,"aria-label":a?void 0:i??t,style:{display:`inline-flex`,width:e,height:e},dangerouslySetInnerHTML:{__html:n.replace(`<svg`,`<svg width="100%" height="100%"`)}})}var ex={pixelarticons:{close:$b(Nb,`Close`),cancel:$b(Pb,`Cancel`),leave:$b(zb,`Leave call`),more:$b(Ub,`More`),error:$b(Ib,`Error`),mic:$b(Bb,`Microphone`),"mic-off":$b(Vb,`Microphone muted`),cam:$b(Zb,`Camera`),"cam-off":$b(kb,`Camera off`),"screen-share":$b(Gb,`Screen share`),pip:$b(Wb,`Picture in picture`),user:$b(qb,`User`),"face-smile":$b(Yb,`Camera off`),captions:$b(Ab,`Closed captions`),chat:$b(jb,`Chat`),fullscreen:$b(Rb,`Enter fullscreen`),"fullscreen-exit":$b(Fb,`Exit fullscreen`),expand:$b(Lb,`Expand`),collapse:$b(Fb,`Collapse`),send:$b(Kb,`Send`),"external-link":$b(Xb,`External link`),clock:$b(Mb,`Clock`),moon:$b(Hb,`Unavailable`),users:$b(Jb,`Busy`)},lucide:Ob};function tx({name:e,...t}){let{config:n}=Tv(),r=(ex[n.value.customization.style.icon_library]??ex.pixelarticons)[e];return L(r,{...t})}var nx=`Ready when you are`,rx=`Start the conversation`;function ix(e){return typeof e==`string`&&e.length>0?e:``}function ax(e){let t=ix(e.replica_thumbnail_image_url)||null,n=ix(e.replica_thumbnail_video_url)||null;return!t&&!n?null:{imageUrl:t,videoUrl:n}}function ox(e){let{preview:t}=e.customization,{background:n}=t,r=ax(e),i;i=n.type?n.type:r?`replica`:`background-gradient`;let a=ix(n.url);return{title:t.title||nx,description:t.description||``,btn_title:t.btn_title||rx,background:{type:i,url:a}}}var sx={backgroundImage:`linear-gradient(to bottom right, var(--color-primary), var(--color-base-300))`},cx=`#t=0.1`;function lx(e){return e.includes(`#`)?e:`${e}${cx}`}function ux({replica:e,fallback:t=null}){let[n,r]=j(()=>new Set),i=e=>r(t=>new Set(t).add(e)),a=`absolute inset-0 w-full h-full object-cover`,{imageUrl:o,videoUrl:s}=e;return o&&!n.has(o)?L(`img`,{class:a,src:o,loading:`lazy`,alt:``,onError:()=>i(o)}):s&&!n.has(s)?L(`video`,{class:a,src:lx(s),muted:!0,playsinline:!0,preload:`metadata`,controls:!1,onError:()=>i(s)}):L(k,{children:t})}function dx({variant:e,replica:t}){let[n,r]=j(!1);return M(()=>{r(!1)},[e.url]),e.type===`replica`&&t?L(ux,{replica:t,fallback:L(`div`,{class:`absolute inset-0`,style:sx})}):e.type===`custom-image`&&e.url&&!n?L(`img`,{class:`absolute inset-0 w-full h-full object-cover`,src:e.url,loading:`lazy`,alt:``,onError:()=>r(!0)}):L(`div`,{class:`absolute inset-0`,style:sx})}function fx({className:e=``}){let{config:t}=Tv(),n=ox(t.value),r=ax(t.value);return L(`div`,{class:`relative size-16 shrink-0 rounded-box overflow-hidden bg-base-300 ${e}`,children:L(dx,{variant:n.background,replica:r})})}var px=`absolute inset-0 bg-base-100 text-base-content flex flex-col items-center justify-center gap-6 px-6 py-8 text-center overflow-y-auto motion-safe:animate-[tavusFadeUp_280ms_ease-out]`;function mx({title:e,description:t,media:n,children:r,overlay:i}){return L(`div`,{class:px,children:[n===void 0?L(fx,{}):n,(e||t)&&L(`div`,{class:`flex flex-col items-center gap-3 max-w-sm`,children:[e&&L(`h2`,{class:`text-lg font-medium leading-snug`,children:e}),t&&L(`p`,{class:`text-base text-base-content/60 tracking-wide leading-snug`,children:t})]}),r&&L(`div`,{class:`flex flex-col items-center gap-3`,children:r}),i]})}var hx={daily_limit:{title:`PAL is at today's limit`,description:`This PAL can take more conversations tomorrow.`},total_limit:{title:`PAL is unavailable`,description:`This PAL isn't available right now. Please check back later.`},busy:{title:`PAL is in another conversation`,description:`Please try again in a moment.`},error:{title:`Couldn't load this PAL`,description:`This PAL couldn't be loaded. Please try again later.`}};function gx(e,t){let n=t?.[e];return{title:n?.title||hx[e].title,description:n?.description||hx[e].description}}var _x={daily_limit:`clock`,total_limit:`moon`,busy:`users`,error:`error`};function vx({cause:e}){return L(`div`,{class:`flex size-16 shrink-0 items-center justify-center rounded-box bg-base-200 text-base-content/70`,children:L(tx,{name:_x[e],size:`2rem`})})}function yx({cause:e,canRetry:t,onRetry:n,onCancel:r}){let{config:i}=Tv(),a=i.value.customization?.unavailable_screen,o=gx(e,a),s=a?.cta??[],c=e===`busy`||s.length>0||!!r;return L(mx,{media:L(vx,{cause:e}),title:o.title,description:o.description,children:c&&L(`div`,{class:`flex flex-wrap items-center justify-center gap-2`,children:[e===`busy`&&L(`button`,{type:`button`,class:`btn btn-neutral rounded-box`,disabled:!t,onClick:n,children:`Try again`}),s.map(e=>L(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,class:`btn btn-outline rounded-box`,children:e.title},e.url)),r&&L(`button`,{type:`button`,class:`btn btn-ghost`,onClick:r,children:`Close`})]})})}function bx(){let e=I(T_);return{state:e.flowSignal.value,isStarting:e.isStarting,permissionRequest:e.permissionRequest,unavailableCause:e.unavailableCause,canRetry:e.canRetry,start:e.start,join:e.join,cancel:e.cancel,leave:e.leave,restart:e.restart}}var xx={start_button:`Start the conversation`,ready_to_start:``};function Sx(){let{config:e}=Tv(),{preview:t}=e.value.customization;return P(()=>({start_button:t.btn_title??xx.start_button,ready_to_start:t.description??xx.ready_to_start}),[t])}function Cx(){return I(kt)?.layout??`inline`}var wx=`text-preview-title @max-mobile:text-preview-title-narrow`,Tx=`text-preview-title-full-screen`,Ex=`text-sm @max-mobile:text-xs`,Dx=`text-preview-description-full-screen`;function Ox({title:e,description:t,fullScreen:n}){return!e&&!t?null:L(`div`,{class:`flex flex-col gap-1 text-left ${n?`max-w-xl`:`max-w-sm`}`,children:[e&&L(`h2`,{class:`${n?Tx:wx} font-medium leading-tight`,children:e}),t&&L(`p`,{class:`${n?Dx:Ex} text-white/80 leading-snug`,children:t})]})}var kx=`absolute inset-0 overflow-hidden bg-base-100 motion-safe:animate-[tavusFadeUp_280ms_ease-out]`,Ax=`absolute inset-x-0 top-0 h-2/5 bg-linear-to-b from-black/60 to-transparent`,jx=`absolute inset-x-0 bottom-0 h-2/5 bg-linear-to-t from-black/70 to-transparent`,Mx=`absolute inset-0 bg-black/45`,Nx=`absolute inset-0 overflow-y-auto p-8 @max-mobile:p-5 text-white [text-shadow:0_1px_3px_rgb(0_0_0/0.45)]`;function Px({title:e,description:t,children:n,align:r=`low`,overlay:i,class:a,role:o,"aria-live":s}){let{config:c}=Tv(),l=ox(c.value),u=ax(c.value),d=Cx()===`full-screen`;return L(`div`,{class:a?`${kx} ${a}`:kx,role:o,"aria-live":s,children:[L(dx,{variant:l.background,replica:u}),r===`center`?L(k,{children:[L(`div`,{class:Mx}),L(`div`,{class:`${Nx} flex flex-col items-center justify-center gap-3`,children:n})]}):L(k,{children:[(e||t)&&(d?L(`div`,{class:Ax}):L(k,{children:[L(`div`,{class:`${Ax} hidden @max-mobile:block`}),L(`div`,{class:jx})]})),d?L(`div`,{class:Nx,children:[L(Ox,{title:e,description:t,fullScreen:!0}),L(`div`,{class:`absolute inset-x-8 @max-mobile:inset-x-5 bottom-[20%] flex flex-col items-center gap-3`,children:n})]}):L(`div`,{class:`${Nx} grid grid-cols-[1fr_auto] grid-rows-[1fr_auto] gap-x-6`,children:[L(`div`,{class:`col-start-1 row-start-2 self-center @max-mobile:col-span-2 @max-mobile:row-start-1 @max-mobile:self-start`,children:L(Ox,{title:e,description:t})}),L(`div`,{class:`col-start-2 row-start-2 self-end justify-self-end flex flex-col items-end gap-3`,children:n})]})]}),i]})}function Fx({loading:e=!1,disabled:t,class:n,children:r,...i}){return L(`button`,{type:`button`,class:`btn relative ${n?` ${n}`:``}`,disabled:t||e,"aria-busy":e||void 0,...i,children:[L(`span`,{children:r}),e&&L(`span`,{class:`absolute inset-0 flex items-center justify-center backdrop-blur-xs`,"aria-hidden":`true`,children:L(`span`,{class:`loading loading-spinner loading-sm`})})]})}var Ix={video:`cam`,audio:`mic`,chat:`chat`},Lx={"full-screen":`btn-lg px-16 @max-3xl:px-10 @max-md:btn-md @max-md:px-5`,inline:`px-8 @max-mobile:px-5`};function Rx({children:e,loading:t=!1,...n}){let{config:r}=Tv(),i=Cx(),a=Ix[r.value.customization.conversation.modality],o=a!==void 0&&i===`full-screen`;return L(Fx,{class:`btn-preview-action rounded-box ${Lx[i]}`,loading:t,...n,children:o?L(`span`,{class:`flex items-center justify-center gap-2`,children:[L(tx,{name:a,"aria-hidden":!0}),e]}):e})}var zx=`Thanks for joining`,Bx=`You can start a new conversation whenever you're ready.`,Vx=`Start a new conversation`;function Hx(e){try{let t=new URL(e);return t.protocol===`https:`||t.protocol===`http:`||t.protocol===`mailto:`}catch{return!1}}function Ux({text:e,onRestart:t,isStarting:n=!1}){let{config:r}=Tv(),i=Cx()===`full-screen`,a=r.value.customization.after_call,o=a.cta.filter(e=>Hx(e.url));return L(Px,{title:a.title||e?.title||zx,description:a.description||e?.description||Bx,children:[L(Rx,{onClick:t,loading:n,children:e?.restart||Vx}),o.length>0&&L(`div`,{class:`flex flex-wrap items-center gap-2 ${i?`justify-center`:`justify-end`}`,children:o.map(e=>L(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,class:`btn rounded-box border-white/50 bg-black/35 text-white backdrop-blur-xs hover:bg-black/50`,children:e.title},e.url))})]})}function Wx(){let e=Th(),t=lg(),{isOff:n}=C_(t),{camState:r}=__();return{isCamReady:P(()=>r===`granted`,[r]),isCamMuted:n,localSessionId:t,onToggleCamera:F(()=>{e?.setLocalVideo(n)},[e,n])}}function Gx(){let e=Th(),t=lg(),{isOff:n}=f_(t),{micState:r}=__();return{isMicReady:P(()=>r===`granted`,[r]),isMicMuted:n,localSessionId:t,onToggleMicrophone:F(()=>{e?.setLocalAudio(n)},[e,n])}}function Kx(){let e=Th(),t=lg(),{isOff:n}=x_(t),r=!n;return{isScreenSharing:r,localSessionId:t,onToggleScreenshare:F(()=>{r?e?.stopScreenShare():e?.startScreenShare({displayMediaOptions:{audio:!1,selfBrowserSurface:`exclude`,surfaceSwitching:`include`,video:{width:1920,height:1080}}})},[e,r])}}var qx={microphone:`microphone`,camera:`camera`};function Jx({class:e}){return L(`svg`,{class:e,viewBox:`0 0 24 24`,fill:`none`,"aria-hidden":`true`,children:[L(`circle`,{cx:`7`,cy:`8`,r:`2.2`,stroke:`currentColor`,"stroke-width":`1.6`}),L(`circle`,{cx:`16`,cy:`16`,r:`2.2`,stroke:`currentColor`,"stroke-width":`1.6`}),L(`path`,{d:`M2 8h2.5M9.5 8H22M2 16h11.5M18.5 16H22`,stroke:`currentColor`,"stroke-width":`1.6`,"stroke-linecap":`round`})]})}function Yx(){return L(`svg`,{viewBox:`0 0 240 180`,class:`w-full h-auto text-base-content/70`,fill:`none`,"aria-hidden":`true`,children:[L(`rect`,{x:`10`,y:`20`,width:`220`,height:`150`,rx:`10`,stroke:`currentColor`,"stroke-width":`2`}),L(`path`,{d:`M10 46h220`,stroke:`currentColor`,"stroke-width":`2`}),L(`circle`,{cx:`26`,cy:`33`,r:`3.5`,stroke:`currentColor`,"stroke-width":`1.6`}),L(`circle`,{cx:`40`,cy:`33`,r:`3.5`,stroke:`currentColor`,"stroke-width":`1.6`}),L(`circle`,{cx:`54`,cy:`33`,r:`3.5`,stroke:`currentColor`,"stroke-width":`1.6`}),L(`path`,{d:`M78 33h14M86 27l-6 6 6 6M104 27v12`,stroke:`currentColor`,"stroke-width":`1.8`,"stroke-linecap":`round`,"stroke-linejoin":`round`}),L(`rect`,{x:`118`,y:`25`,width:`96`,height:`16`,rx:`8`,stroke:`currentColor`,"stroke-width":`1.6`}),L(`circle`,{class:`text-info`,cx:`128`,cy:`33`,r:`11`,fill:`currentColor`,opacity:`0.18`}),L(`circle`,{class:`text-info`,cx:`128`,cy:`33`,r:`11`,stroke:`currentColor`,"stroke-width":`1.6`}),L(`g`,{class:`text-info`,transform:`translate(120 25) scale(0.66)`,children:L(Jx,{})}),L(`g`,{transform:`translate(34 78)`,children:[L(`rect`,{x:`0`,y:`8`,width:`34`,height:`26`,rx:`5`,stroke:`currentColor`,"stroke-width":`2`}),L(`path`,{d:`M34 16l14-8v26l-14-8`,stroke:`currentColor`,"stroke-width":`2`,"stroke-linejoin":`round`})]}),L(`g`,{transform:`translate(40 120)`,children:[L(`rect`,{x:`6`,y:`0`,width:`14`,height:`24`,rx:`7`,stroke:`currentColor`,"stroke-width":`2`}),L(`path`,{d:`M0 20a13 13 0 0 0 26 0M13 33v8`,stroke:`currentColor`,"stroke-width":`2`,"stroke-linecap":`round`})]}),L(`path`,{d:`M150 64l34 14-14 4-2 16-18-34Z`,fill:`currentColor`,stroke:`currentColor`,"stroke-width":`2`,"stroke-linejoin":`round`})]})}var Xx=Ea(({device:e,onClose:t})=>{let n=qx[e];return M(()=>{let e=e=>{e.key===`Escape`&&t()};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[t]),L(`div`,{class:`absolute inset-0 z-50 flex items-center justify-center p-4 bg-black/50 motion-safe:animate-[tavusFadeUp_180ms_ease-out]`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`tavus-blocked-title`,onClick:t,children:L(`div`,{class:`relative w-full max-w-md rounded-box bg-base-100 text-base-content shadow-xl overflow-hidden`,onClick:e=>e.stopPropagation(),children:[L(`button`,{type:`button`,class:`btn btn-sm btn-circle btn-ghost absolute top-2 right-2 z-10`,onClick:t,"aria-label":`Close`,children:L(tx,{name:`close`,size:`1.1rem`})}),L(`div`,{class:`grid @3xl:grid-cols-[1fr_1.2fr] gap-4 p-5 @max-md:p-4`,children:[L(`div`,{class:`flex items-center justify-center @max-md:hidden`,children:L(Yx,{})}),L(`div`,{class:`flex flex-col gap-4`,children:[L(`h2`,{id:`tavus-blocked-title`,class:`text-lg font-semibold leading-snug pr-6`,children:[`Access to your `,n,` is blocked`]}),L(`ol`,{class:`flex flex-col gap-3 text-sm`,children:[L(`li`,{class:`flex items-start gap-2`,children:[L(`span`,{class:`font-semibold tabular-nums`,children:`1.`}),L(`span`,{class:`leading-snug`,children:[`Click the `,L(Jx,{class:`inline-block align-text-bottom h-4 w-4 mx-0.5`}),` `,`settings icon in your browser's address bar`]})]}),L(`li`,{class:`flex items-start gap-2`,children:[L(`span`,{class:`font-semibold tabular-nums`,children:`2.`}),L(`span`,{class:`leading-snug`,children:[`Allow `,n,` access, then reload the page`]})]})]}),L(`button`,{type:`button`,class:`btn btn-neutral btn-sm self-start`,onClick:t,children:`Got it`})]})]})]})})}),Zx=Ae({open:()=>{},close:()=>{}});function Qx(){return I(Zx)}function $x({children:e}){let[t,n]=j(null),r=F(e=>n(e),[]),i=F(()=>n(null),[]),a=P(()=>({open:r,close:i}),[r,i]);return L(Zx.Provider,{value:a,children:[e,t&&L(Xx,{device:t,onClose:i})]})}var eS=Ea(()=>L(`span`,{"aria-hidden":`true`,class:`absolute -top-0.5 -right-0.5 z-20 flex h-4 w-4 items-center justify-center rounded-full bg-warning text-warning-content text-[0.6rem] font-bold leading-none ring-2 ring-base-100 pointer-events-none`,children:`!`})),tS=`select-control-pill relative inline-flex items-center bg-neutral text-neutral-content`,nS=`absolute inset-0 w-full h-full opacity-0 cursor-pointer appearance-none disabled:cursor-not-allowed`,rS=`absolute right-1.5 top-1/2 -translate-y-1/2 pointer-events-none flex items-center`,iS=`absolute left-0 top-0 h-full aspect-square flex items-center justify-center pointer-events-none`,aS=`absolute left-0 top-0 z-10 btn btn-control btn-neutral`;function oS(){return L(`svg`,{style:{width:`var(--chevron-size, 0.75rem)`,height:`var(--chevron-size, 0.75rem)`},viewBox:`0 0 16 16`,fill:`none`,"aria-hidden":`true`,children:L(`path`,{d:`M4 6L8 10L12 6`,stroke:`currentColor`,"stroke-width":`1.5`,"stroke-linecap":`round`,"stroke-linejoin":`round`})})}function sS(){let e=lg(),t=N(null),n=N(void 0);return d_(e??``,F(e=>{n.current&&cancelAnimationFrame(n.current),n.current=requestAnimationFrame(()=>{let n=Math.max(0,Math.min(1,e**.6));t.current?.style.setProperty(`--mic-level`,String(n))})},[])),L(`span`,{ref:t,"aria-hidden":`true`,class:`pointer-events-none absolute inset-x-0 bottom-0 z-0 bg-success/70`,style:{"--mic-level":`0`,height:`calc(var(--mic-level, 0) * 100%)`,transition:`height 100ms ease-out`}})}function cS({value:e,devices:t,disabled:n,onChange:r,label:i}){return L(k,{children:[L(`select`,{class:nS,value:e,onChange:e=>r(e.target.value),disabled:n,"aria-label":i,children:t.map(({device:e})=>L(`option`,{value:e.deviceId,children:e.label},e.deviceId))}),L(`span`,{class:rS,children:L(oS,{})})]})}function lS(e){return L(`div`,{class:tS,children:L(cS,{...e})})}function uS({iconName:e,...t}){return L(`div`,{class:tS,children:[L(`span`,{class:iS,"aria-hidden":`true`,children:L(tx,{name:e})}),L(cS,{...t})]})}var dS=Ea(({level:e=!1})=>{let{onToggleMicrophone:t,isMicReady:n,isMicMuted:r}=Gx(),{microphones:i,currentMic:a,setMicrophone:o}=__();if(!a||(i?.length??0)<=1)return L(mS,{level:e});let s=e&&n&&!r;return L(`div`,{class:`relative inline-flex items-center`,children:[L(lS,{value:a?.device?.deviceId,devices:i||[],disabled:!n,onChange:e=>o(e),label:`Select microphone`}),L(`button`,{type:`button`,onClick:t,disabled:!n,class:`${aS} overflow-hidden`,"aria-label":r?`Unmute microphone`:`Mute microphone`,"aria-pressed":r,children:[s&&L(sS,{}),L(`span`,{class:`relative z-10 inline-flex`,children:L(tx,{name:r||!n?`mic-off`:`mic`})})]})]})});function fS(){let{onToggleCamera:e,isCamMuted:t}=Wx(),{camera:n,requestCamera:r}=Yv(),{open:i}=Qx(),a=n.isGranted&&!t;return{isOn:a,onClick:()=>{if(n.isBlocked)return i(`camera`);if(a)return e();r()},label:a?`Turn camera off`:n.isGranted?`Turn camera on`:`Enable camera`,needsAttention:n.needsAttention}}var pS=Ea(()=>{let{isCamReady:e}=Wx(),{currentCam:t,cameras:n,setCamera:r}=__(),i=fS();return!t||(n?.length??0)<=1?L(hS,{}):L(`div`,{class:`relative inline-flex items-center`,children:[L(lS,{value:t?.device?.deviceId,devices:n||[],disabled:!e,onChange:e=>r(e),label:`Select camera`}),L(`button`,{type:`button`,onClick:i.onClick,class:aS,"aria-label":i.label,"aria-pressed":!i.isOn,children:L(tx,{name:i.isOn?`cam`:`cam-off`})})]})}),mS=Ea(({level:e=!1})=>{let{onToggleMicrophone:t,isMicMuted:n}=Gx(),{mic:r,requestMic:i}=Yv(),{open:a}=Qx(),o=()=>{if(r.isGranted)return t();if(r.isBlocked)return a(`microphone`);i()},s=r.isGranted?n?`Unmute microphone`:`Mute microphone`:`Allow microphone access`,c=e&&r.isGranted&&!n;return L(`span`,{class:`relative inline-flex`,children:[L(`button`,{type:`button`,onClick:o,class:`btn btn-control btn-neutral relative overflow-hidden`,"aria-label":s,"aria-pressed":r.isGranted?n:void 0,children:[c&&L(sS,{}),L(`span`,{class:`relative z-10 inline-flex`,children:L(tx,{name:n||!r.isGranted?`mic-off`:`mic`})})]}),r.needsAttention&&L(eS,{})]})}),hS=Ea(()=>{let{isOn:e,onClick:t,label:n,needsAttention:r}=fS();return L(`span`,{class:`relative inline-flex`,children:[L(`button`,{type:`button`,onClick:t,class:`btn btn-control btn-neutral`,"aria-label":n,"aria-pressed":!e,children:L(tx,{name:e?`cam`:`cam-off`})}),r&&L(eS,{})]})});Ea(({compact:e=!1}={})=>{let{isMicReady:t}=Gx(),{microphones:n,currentMic:r,setMicrophone:i}=__();return(n?.length??0)<=1?null:L(uS,{iconName:`mic`,value:r?.device?.deviceId,devices:n,disabled:!t,onChange:e=>i(e),label:`Select microphone`,compact:e})}),Ea(({compact:e=!1}={})=>{let{isCamReady:t}=Wx(),{currentCam:n,cameras:r,setCamera:i}=__();return(r?.length??0)<=1?null:L(uS,{iconName:`cam`,value:n?.device?.deviceId,devices:r,disabled:!t,onChange:e=>i(e),label:`Select camera`,compact:e})});var gS=Ea((e={})=>{let{onToggleScreenshare:t,isScreenSharing:n}=Kx();return L(`button`,{type:`button`,onClick:t,class:`btn btn-control ${n?`btn-primary`:`btn-neutral`}`,"aria-label":n?`Stop screen share`:`Start screen share`,"aria-pressed":n,children:L(tx,{name:`screen-share`})})});function _S(e){let t=I(av);if(!t)throw Error(`useConversation must be used within ConversationProvider`);return M(()=>{if(e)return t.__registerSubscriber(e),()=>t.__unregisterSubscriber(e)},[e]),t}var vS=Ae(null);function yS({children:e,defaultEnabled:t=!1}){let[n,r]=j(t),i=F(()=>r(e=>!e),[]),a=P(()=>({isEnabled:n,toggle:i}),[n,i]);return L(vS.Provider,{value:a,children:e})}function bS(){let e=I(vS);if(!e)throw Error(`ClosedCaptions components must be used within <ClosedCaptionsProvider>`);return e}var xS=Ea(()=>{let{isEnabled:e,toggle:t}=bS();return L(`button`,{type:`button`,onClick:t,"aria-pressed":e,class:`btn btn-control ${e?`btn-primary`:`btn-neutral`}`,"aria-label":e?`Hide captions`:`Show captions`,children:L(tx,{name:`captions`,"aria-label":e?`Closed Captions On`:`Closed Captions Off`})})}),SS=Ea(()=>{let{isEnabled:e}=bS(),{captionText:t,captionRole:n}=_S(),r=t.value,i=n.value;return!e||!r?null:L(`div`,{class:`pointer-events-none absolute bottom-24 left-1/2 -translate-x-1/2 max-w-[80%] px-4 py-2 rounded-box bg-black/60 text-white z-40`,role:`status`,"aria-live":`polite`,children:L(`div`,{class:`text-sm leading-5 max-h-15 overflow-hidden flex flex-col justify-end text-center`,children:L(`div`,{children:[L(`span`,{class:`text-xs ${i===`replica`?`text-secondary`:`text-primary`} mr-2`,children:i===`replica`?`PAL`:`You`}),r]})})})}),CS=Ae(null);function wS({children:e,defaultOpen:t=!1}){let[n,r]=j(t),i=F(()=>r(e=>!e),[]),a=F(()=>r(!1),[]),o=P(()=>({isOpen:n,toggle:i,close:a}),[n,i,a]);return L(CS.Provider,{value:o,children:e})}function TS(){let e=I(CS);if(!e)throw Error(`Chat components must be used within <ChatProvider>`);return e}var ES=Ea((e={})=>{let{isOpen:t,toggle:n}=TS();return L(`button`,{type:`button`,onClick:n,"aria-pressed":t,"aria-label":t?`Close chat`:`Open chat`,class:`btn btn-control ${t?`btn-primary`:`btn-neutral`}`,children:L(tx,{name:`chat`})})}),DS=Ea(({message:e})=>{let t=e.sender===`user`;return L(`li`,{class:`flex flex-col gap-1 ${t?`items-end`:`items-start`}`,children:[L(`span`,{class:`text-xs ${t?`text-primary`:`text-secondary`}`,children:t?`You`:`PAL`}),L(`span`,{class:`px-3 py-2 rounded-field text-sm max-w-[80%] ${t?`bg-primary text-primary-content`:`bg-base-200 text-base-content`}`,children:e.text})]})}),OS=Ea(({docked:e=!1,headerAction:t}={})=>{let{isOpen:n,close:r}=TS(),{chatMessages:i,sendChat:a,session:o}=_S(),s=o.value?.conversationId??null,c=i.value,[l,u]=j(``),d=N(null);M(()=>{let e=d.current;e&&(e.scrollTop=e.scrollHeight)},[c.length]);let f=F(()=>{let e=l.trim();!e||!s||(a(e),u(``))},[l,a,s]),p=F(e=>{e.key===`Enter`&&!e.shiftKey&&!e.isComposing&&(e.preventDefault(),f())},[f]),m=!!l.trim()&&!!s;return L(`aside`,{class:e?`absolute inset-0 w-full h-full bg-base-100 flex flex-col z-30`:`absolute top-0 right-0 w-80 h-full bg-base-100 border-l border-base-300 flex flex-col z-30 transition-transform ${n?`translate-x-0`:`translate-x-full`} @max-mobile:w-full`,"aria-hidden":e?!1:!n,inert:e?!1:!n,children:[L(`header`,{class:`flex items-center justify-between px-4 py-3 border-b border-base-300`,children:[L(`span`,{class:`font-medium text-base-content`,children:`Chat`}),e?t:L(`button`,{type:`button`,class:`btn btn-ghost btn-sm btn-circle`,onClick:r,"aria-label":`Close chat`,children:L(tx,{name:`close`,size:20})})]}),L(`ul`,{ref:d,class:`flex-1 overflow-y-auto p-4 flex flex-col gap-3`,role:`log`,"aria-live":`polite`,children:c.length===0?L(`li`,{class:`text-center text-sm opacity-70`,children:s?`Send a message to start the conversation.`:`Connecting…`}):c.map(e=>L(DS,{message:e},e.id))}),L(`form`,{class:`flex items-end gap-2 p-3 border-t border-base-300`,onSubmit:e=>{e.preventDefault(),f()},children:[L(`textarea`,{class:`textarea textarea-bordered textarea-sm flex-1 resize-none`,value:l,onChange:e=>u(e.target.value),onKeyDown:p,placeholder:s?`Type a message…`:`Connecting…`,disabled:!s,rows:1,"aria-label":`Message`}),L(`button`,{type:`submit`,class:`btn btn-primary btn-sm btn-circle`,disabled:!m,"aria-label":`Send message`,children:L(tx,{name:`send`,size:18})})]})]})});function kS({label:e}){return L(Px,{align:`center`,role:`status`,"aria-live":`polite`,class:`z-2`,children:L(`div`,{class:`flex items-center gap-2`,children:[L(`span`,{class:`loading loading-spinner loading-sm`}),L(`span`,{class:`text-base font-medium`,children:e})]})})}var AS=Ea(()=>L(kS,{label:`Connecting…`})),jS=Ea(()=>L(kS,{label:`Leaving…`}));function MS({active:e,onToggle:t,tooltip:n,nudge:r=!1}){return L(`div`,{class:`flex items-center gap-2`,children:[r&&L(`span`,{class:`rounded-field bg-base-100 px-2 py-1 text-xs font-medium whitespace-nowrap text-base-content shadow-md motion-safe:animate-[tavusFadeUp_180ms_ease-out]`,children:`Expand for a better view`}),L(`button`,{type:`button`,onClick:t,class:`btn btn-xs btn-control ${r?`btn-primary`:e?`btn-info`:`btn-neutral`}`,"aria-label":n??(e?`Exit fullscreen`:`Enter fullscreen`),title:n,children:L(tx,{name:e?`fullscreen-exit`:`fullscreen`,size:`calc(var(--size-field, 0.25rem) * 3.5)`})})]})}var NS=Ea(({id:e})=>{let t=dg()===e,n=N(null),r=N(null),i=N(null),a=N(void 0);d_(e,F(e=>{a.current&&cancelAnimationFrame(a.current),a.current=requestAnimationFrame(()=>{let t=Number(Math.max(.01,e).toFixed(2));n.current&&r.current&&i.current&&(n.current.style.height=`${20+t*40}%`,r.current.style.height=`${20+t*130}%`,i.current.style.height=`${20+t*40}%`)})},[]));let o=`w-[3px] rounded-full bg-base-100 transition-[opacity] ${t?`opacity-100`:`opacity-50`}`;return L(`div`,{class:`flex items-center justify-center w-6 h-6`,children:L(`div`,{class:`flex items-center justify-center gap-[2px] w-full h-full`,children:[L(`div`,{ref:n,class:o,style:{height:`20%`}}),L(`div`,{ref:r,class:o,style:{height:`20%`}}),L(`div`,{ref:i,class:o,style:{height:`20%`}})]})})}),PS=[0,1,2],FS=.05,IS=450;function LS({sessionId:e,className:t=``}){let{config:n}=Tv(),r=ox(n.value),i=ax(n.value),a=N(null),o=N(void 0),s=N(void 0),[c,l]=j(!1),u=N(!1);return d_(e??``,F(t=>{e&&(o.current&&cancelAnimationFrame(o.current),o.current=requestAnimationFrame(()=>{let e=Math.max(0,Math.min(1,t**.6));a.current?.style.setProperty(`--audio-level`,String(e)),e>FS?(s.current&&=(clearTimeout(s.current),void 0),u.current||(u.current=!0,l(!0))):u.current&&s.current===void 0&&(s.current=setTimeout(()=>{s.current=void 0,u.current=!1,l(!1)},IS))}))},[e])),M(()=>()=>{o.current&&cancelAnimationFrame(o.current),s.current&&clearTimeout(s.current)},[]),L(`div`,{ref:a,class:`relative aspect-square w-full max-w-[min(48cqi,16rem)] mx-auto pointer-events-none ${t}`,style:{"--audio-level":`0`},"aria-hidden":`true`,children:[PS.map(e=>L(`div`,{class:`absolute inset-[16%] rounded-full will-change-transform`,style:{border:`2px solid var(--color-primary)`,opacity:0,animation:c?`tavusAudioWave 2.4s ease-out ${e*.8}s infinite`:`none`,"--wave-peak":`calc(0.18 + var(--audio-level, 0) * 0.5)`}},e)),L(`div`,{class:`absolute inset-[16%] rounded-full`,style:{background:`radial-gradient(circle, color-mix(in oklab, var(--color-primary) 60%, transparent), transparent 70%)`,filter:`blur(20px)`,scale:`calc(1 + var(--audio-level, 0) * 0.25)`,opacity:`calc(0.35 + var(--audio-level, 0) * 0.5)`,transition:`scale 120ms ease-out, opacity 120ms ease-out`}}),L(`div`,{class:`absolute inset-[20%] rounded-full overflow-hidden bg-base-300 ring-2 ring-base-100/20 shadow-xl will-change-transform`,style:{scale:`calc(1 + var(--audio-level, 0) * 0.06)`,transition:`scale 100ms ease-out`},children:L(dx,{variant:r.background,replica:i})})]})}function RS({children:e,class:t,className:n,...r}){return L(`div`,{class:`tavus-mesh-bg ${t??n??``}`,...r,children:[L(`div`,{class:`tavus-mesh-blob tavus-mesh-blob-1`}),L(`div`,{class:`tavus-mesh-blob tavus-mesh-blob-2`}),L(`div`,{class:`tavus-mesh-blob tavus-mesh-blob-3`}),L(`div`,{class:`tavus-mesh-blob tavus-mesh-blob-4`}),L(`div`,{class:`tavus-mesh-blob tavus-mesh-blob-5`}),L(`div`,{class:`absolute inset-0 bg-linear-to-t from-black/30 via-black/10 to-transparent pointer-events-none backdrop-blur-xs`}),e]})}var zS=e=>!!e.user_id?.includes(`tavus-replica`);function BS(){return gg({filter:zS})}function VS(e){let t=BS()[0],n=C_(t??``),r=Qg(),[i,a]=j(!1);return M(()=>{t&&(n.state===`playable`||e)&&a(!0)},[t,n.state,e]),r===`left-meeting`||r===`error`?{phase:`left`}:!i||!t?{phase:`connecting`}:{phase:`ready`,replicaId:t,videoState:n}}var HS=Ea(({isAudioOnly:e})=>{let t=VS(e);return t.phase===`left`?L(jS,{}):t.phase===`connecting`?L(AS,{}):e?L(RS,{class:`flex items-center justify-center`,children:[L(LS,{sessionId:t.replicaId}),L(xg,{sessionId:t.replicaId})]}):L(`div`,{class:`relative w-full h-full`,children:[L(Cg,{automirror:!0,sessionId:t.replicaId,type:`video`,fit:`cover`,className:`absolute inset-0 w-full h-full object-cover ${t.videoState.isOff?`hidden`:``}`}),L(xg,{sessionId:t.replicaId})]})}),US=Ea(({onLeave:e})=>{let{config:t}=Tv(),n=t.value.customization.conversation.modality===`audio`;return L(`div`,{class:`@container/pip w-full h-full`,children:L(`div`,{class:`relative w-full h-full overflow-hidden bg-linear-to-br from-base-300 to-base-200 text-base-content`,children:[L(`div`,{class:`relative w-full h-full z-5`,children:L(HS,{isAudioOnly:n})}),L(`div`,{class:`absolute bottom-4 w-full inset-x-0 z-20 flex justify-center items-center gap-2 @max-mobile:gap-1`,children:[L(mS,{}),!n&&L(hS,{}),L(`button`,{type:`button`,class:`btn btn-control btn-error`,onClick:e,"aria-label":`Leave call`,children:L(tx,{name:`leave`,"aria-label":`Leave Call`})})]})]})})});function WS(e,t){return e<=0||t<=0?!1:e/t<.75}var GS=Ea(({personaSessionId:e,localSessionId:t,isScreenSharing:n,avatarOff:r,videoRef:i})=>{let a=N(null),o=i??a,[s,c]=j(0),[l,u]=j(0),d=F(({aspectRatio:e})=>c(e),[]);M(()=>{let e=o.current;if(!e||typeof ResizeObserver>`u`)return;let t=new ResizeObserver(e=>{let{width:t,height:n}=e[e.length-1].contentRect;u(n>0?t/n:0)});return t.observe(e),()=>t.disconnect()},[o]);let f=n?t??``:e,p=!n&&r,m=!n&&WS(s,l),h=n||m;return L(k,{children:[m&&L(Cg,{sessionId:e,type:`video`,fit:`cover`,"aria-hidden":`true`,className:`pointer-events-none absolute inset-0 w-full h-full object-cover scale-110 blur-xl brightness-[0.55] ${p?`hidden`:``}`}),L(Cg,{ref:o,automirror:!0,sessionId:f,type:n?`screenVideo`:`video`,fit:h?`contain`:`cover`,onResize:n?void 0:d,className:`absolute inset-0 w-full h-full transition-all ${h?`object-contain`:`object-cover`} ${p?`hidden`:``}`})]})}),KS=new Set([`mcp-ui.tavus.io`,`mcp-ui.tavus-preview.io`]),qS=[`.sandbox-tavus.io`],JS=new Set([`tavusapi.com`]);function YS(e){let t;try{t=new URL(e)}catch{return!1}return QS(t)?!0:t.protocol===`https:`?KS.has(t.hostname)?!0:qS.some(e=>t.hostname.endsWith(e)):!1}function XS(e){return YS(e)}function ZS(e){let t;try{t=new URL(e)}catch{return!1}return $S(t)?!0:t.protocol===`https:`&&JS.has(t.hostname)}function QS(e){return $S(e)}function $S(e){return!eC()||e.protocol!==`http:`&&e.protocol!==`https:`?!1:[`localhost`,`127.0.0.1`,`::1`,`[::1]`].includes(e.hostname)}function eC(){try{let e=globalThis.location?.hostname;return typeof e==`string`&&[`localhost`,`127.0.0.1`,`::1`,`[::1]`].includes(e)}catch{return!1}}async function tC(e){try{await e.teardownResource({},{timeout:1e3})}catch{}try{await e.close?.()}catch{}}var nC=`tavus.canvas.interaction`,rC=[`safe-area-right`,`safe-area-left`,`safe-area-bottom`,`full`],iC=`safe-area-right`,aC={x:275/1280,y:111/720,width:730/1280,height:609/720},oC={type:`snapshot_mirror`};function sC(e){return kC(e)?e.message_type===`conversation`&&e.event_type===`conversation.tool_call`&&typeof e.conversation_id==`string`&&kC(e.properties):!1}function cC(e){if(!kC(e))return null;let t=UC(e,`component`),n=UC(e,`component_version`),r=UC(e,`sandbox_url`),i=KC(e,`mcp_server_url`,XS),a=KC(e,`api_base_url`,ZS),o=KC(e,`interaction_url`,ZS),s=NC(e.layout),c=e.version;return c!==1||!t||!n||!r||!YS(r)||i===null||a===null||o===null||s===null?null:{version:c,component:t,component_version:n,resource_uri:UC(e,`resource_uri`),sandbox_url:r,mcp_server_url:i,mcp_tool_name:UC(e,`mcp_tool_name`),api_base_url:a,interaction_url:o,layout:s,host_context:kC(e.host_context)?e.host_context:void 0}}function lC(e){if(e===void 0)return{ok:!0,value:{}};if(kC(e))return{ok:!0,value:e};if(typeof e!=`string`)return{ok:!1,error:Error(`Magic Canvas tool arguments must be an object or JSON string.`)};try{let t=JSON.parse(e);return kC(t)?{ok:!0,value:t}:{ok:!1,error:Error(`Magic Canvas tool arguments must decode to an object.`)}}catch(e){return{ok:!1,error:AC(e)}}}function uC(e){let t=e.properties.name;if(t!==`canvas_clear`&&t!==`update_component`)return null;let n=lC(e.properties.arguments);if(!n.ok)throw n.error;if(t===`canvas_clear`){let t=n.value.tool_call_id,r=n.value.reason;if(t!==void 0&&typeof t!=`string`)throw Error(`Magic Canvas clear tool_call_id must be a string when provided.`);if(r!==void 0&&typeof r!=`string`)throw Error(`Magic Canvas clear reason must be a string when provided.`);return{kind:`clear`,conversation_id:e.conversation_id,tool_call_id:t,reason:r}}let r=n.value.tool_call_id,i=n.value.updates;if(typeof r!=`string`||r.length===0)throw Error(`Magic Canvas update_component requires a target tool_call_id.`);if(!kC(i))throw Error(`Magic Canvas update_component requires an object updates payload.`);return{kind:`update`,conversation_id:e.conversation_id,tool_call_id:r,updates:i}}var dC=[`safe-area-left`,`safe-area-right`];function fC(e){let t=dC.includes(e.preferred_slot)?e.preferred_slot:iC;return t===e.preferred_slot&&e.display_mode===`inline`?e:{...e,preferred_slot:t,display_mode:`inline`}}function pC(e){return e.display_mode===`fullscreen`?`full`:e.preferred_slot}function mC(e,t){return[t]}function hC(e,t){switch(t.kind){case`show`:{let n=e.find(e=>e.id===t.instance.id),r=n?{...t.instance,revision:n.revision+1}:t.instance;return mC(e.filter(e=>e.id!==t.instance.id),r)}case`update`:{let n=e=>e.conversation_id===t.conversation_id&&e.tool_call_id===t.tool_call_id,r=TC(t.updates),i,a=e.map(e=>{if(!n(e))return e;let t={...e,arguments:{...e.arguments,...r.componentArguments},layout:fC({preferred_slot:r.preferredSlot??e.layout.preferred_slot,display_mode:r.displayMode??e.layout.display_mode,avoid_safe_area:r.avoidSafeArea??e.layout.avoid_safe_area,safe_area:r.safeArea??e.layout.safe_area,backdrop:r.backdrop??e.layout.backdrop}),revision:e.revision+1};return i=t,t});if(i===void 0)return a;let o=e.find(n);return o&&pC(o.layout)===pC(i.layout)?a:mC(a.filter(e=>!n(e)),i)}case`clear`:return t.tool_call_id?e.filter(e=>!(e.conversation_id===t.conversation_id&&e.tool_call_id===t.tool_call_id)):e.filter(e=>e.conversation_id!==t.conversation_id)}}function gC(e){if(!kC(e)||!Array.isArray(e.content))return null;for(let t of e.content){if(!kC(t))continue;let e=(kC(t._meta)?t._meta:null)?.[nC];if(kC(e))return qC(e)}return null}function _C(e,t){let n=t.type,r=t.value;if(!n)throw Error(`Magic Canvas interaction is missing type.`);if(r===void 0)throw Error(`Magic Canvas interaction is missing value.`);return{interaction_id:t.interaction_id??OC(e.tool_call_id,n),conversation_id:e.conversation_id,tool_call_id:e.tool_call_id,component:t.component??e.canvas_config.component,component_version:t.component_version??e.canvas_config.component_version,type:n,value:r,metadata:kC(t.metadata)?t.metadata:{}}}function vC(e){return e.type===`dismiss`||e.type===`clear`?!0:e.type!==`submit`&&e.type!==`skip`?!1:e.component===`canvas.question`||e.component===`canvas.input`||e.component===`canvas.calendar`}function yC(e){return!kC(e)||!Array.isArray(e.content)?``:e.content.map(e=>kC(e)&&e.type===`text`&&typeof e.text==`string`?e.text:``).filter(Boolean).join(`
53
- `).trim()}function bC(e,t){let n=kC(t.structuredContent)?t.structuredContent:void 0,r=jC(t.content),i=typeof n?.state==`string`?n.state:`updated`,a=typeof n?.summary==`string`?n.summary:r,o=[`Magic Canvas state update for ${e.canvas_config.component} (${e.tool_call_id}).`,`State: ${i}.`];return a&&o.push(`Summary: ${a}`),n&&o.push(`Structured state: ${MC(n)}`),r&&r!==a&&o.push(r),o.join(`
54
- `)}function xC({conversationId:e,toolCallId:t,args:n,canvasConfig:r}){let i=TC(n);return{id:t,conversation_id:e,tool_call_id:t,arguments:i.componentArguments,canvas_config:r,layout:fC({preferred_slot:i.preferredSlot??r.layout?.preferred_slot??EC(r.component),display_mode:i.displayMode??`inline`,avoid_safe_area:i.avoidSafeArea??r.layout?.avoid_safe_area??!0,safe_area:i.safeArea??r.layout?.safe_area??aC,backdrop:i.backdrop??r.layout?.backdrop??oC}),revision:0}}function SC(e,t){let n=e.layout.display_mode;return{...e.layout,display_mode:n,viable_slot:n===`fullscreen`?`full`:wC(e.layout.preferred_slot,t)}}function CC(e,t){let n=e.filter(e=>!e.avoid_safe_area||e.display_mode===`fullscreen`?!1:e.viable_slot===`safe-area-left`||e.viable_slot===`safe-area-right`),r=n.some(e=>e.viable_slot===`safe-area-left`),i=n.some(e=>e.viable_slot===`safe-area-right`);if(r&&i)return{active:!1,video_shift_x:0,backdrop:oC};let a=[...n].reverse()[0];if(!a||t.width<900)return{active:!1,video_shift_x:0,backdrop:oC};let o=Math.min(448,Math.max(0,t.width-32)),s=a.safe_area,c=s.x*t.width,l=(s.x+s.width)*t.width,u=Math.min(360,t.width*.3),d=0;return d=a.viable_slot===`safe-area-left`?GC(16+o+24-c,0,u):-GC(l-(t.width-16-o-24),0,u),{active:!0,side:a.viable_slot===`safe-area-left`?`left`:`right`,video_shift_x:Math.round(d),safe_area:s,backdrop:a.backdrop}}function wC(e,t){return e===`full`||e===`safe-area-bottom`&&t.visualViewportHeight!==void 0&&t.visualViewportHeight<t.height*.75?`full`:(e===`safe-area-left`||e===`safe-area-right`)&&t.width<768&&t.height>=t.width?`safe-area-bottom`:e}function TC(e){let t={};for(let[n,r]of Object.entries(e))n===`layout`||n===`preferred_slot`||n===`preferredSlot`||n===`display_mode`||n===`displayMode`||n===`presentation`||n===`fullscreen`||n===`avoid_safe_area`||n===`avoidSafeArea`||n===`safe_area`||n===`safeArea`||n===`backdrop`||(t[n]=r);return{componentArguments:t,preferredSlot:PC(e.layout)??PC(e.preferred_slot)??PC(e.preferredSlot),displayMode:FC(e),avoidSafeArea:IC(e),safeArea:LC(e),backdrop:RC(e)}}function EC(e){switch(e){case`canvas.alert`:return`safe-area-bottom`;case`canvas.chart`:case`canvas.image`:case`canvas.video`:return`full`;default:return iC}}function DC(e,t){let n=t?.displayScale??1;if(e.display_mode===`fullscreen`||e.viable_slot===`full`)return{maxWidth:void 0,maxHeight:void 0,displayScale:n};let r=t?.maxHeight??720;return e.viable_slot===`safe-area-bottom`?{maxWidth:720,maxHeight:r,displayScale:n}:{width:384,maxHeight:r,displayScale:n}}function OC(e,t){return`ci_${e.replace(/[^a-zA-Z0-9_-]/g,`_`)}_${t}_${globalThis.crypto?.randomUUID?.()??Math.random().toString(36).slice(2,10)}`}function kC(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function AC(e){return e instanceof Error?e:Error(String(e))}function jC(e){return Array.isArray(e)?e.map(e=>kC(e)&&e.type===`text`&&typeof e.text==`string`?e.text:``).filter(Boolean).join(`
55
- `).trim():``}function MC(e){let t=JSON.stringify(e);return t?t.length<=2e3?t:`${t.slice(0,2e3)}...`:`{}`}function NC(e){if(e===void 0)return;if(!kC(e))return null;let t=PC(e),n=zC(e.safe_area??e.safeArea),r=BC(e.backdrop);return n===null||r===null?null:{...t?{preferred_slot:t}:{},...VC(e.avoid_safe_area??e.avoidSafeArea,`avoid_safe_area`),...n?{safe_area:n}:{},...r?{backdrop:r}:{}}}function PC(e){if(typeof e==`string`&&HC(e))return e;if(!kC(e))return;let t=e.preferred_slot??e.preferredSlot??e.slot;return typeof t==`string`&&HC(t)?t:void 0}function FC(e){if(e.presentation===!0||e.fullscreen===!0)return`fullscreen`;if(e.presentation===!1||e.fullscreen===!1)return`inline`;let t=e.display_mode??e.displayMode;return t===`fullscreen`||t===`inline`?t:void 0}function IC(e){let t=kC(e.layout)?e.layout:void 0,n=e.avoid_safe_area??e.avoidSafeArea??t?.avoid_safe_area??t?.avoidSafeArea;return typeof n==`boolean`?n:void 0}function LC(e){let t=kC(e.layout)?e.layout:void 0;return zC(e.safe_area??e.safeArea??t?.safe_area??t?.safeArea)??void 0}function RC(e){let t=kC(e.layout)?e.layout:void 0;return BC(e.backdrop??t?.backdrop)??void 0}function zC(e){if(e===void 0)return;if(!kC(e))return null;let t=WC(e,`x`),n=WC(e,`y`),r=WC(e,`width`),i=WC(e,`height`);return t===void 0||n===void 0||r===void 0||i===void 0||t<0||n<0||r<=0||i<=0||t+r>1.001||n+i>1.001?null:{x:GC(t,0,1),y:GC(n,0,1),width:GC(r,0,1),height:GC(i,0,1)}}function BC(e){if(e===void 0)return;if(e===`snapshot_mirror`||e===`none`)return{type:e};if(!kC(e))return null;let t=e.type;return t===`snapshot_mirror`||t===`none`?{type:t}:null}function VC(e,t){return typeof e==`boolean`?{[t]:e}:{}}function HC(e){return rC.includes(e)}function UC(e,t){let n=e[t];return typeof n==`string`&&n.length>0?n:void 0}function WC(e,t){let n=e[t];return typeof n==`number`&&Number.isFinite(n)?n:void 0}function GC(e,t,n){return Math.min(Math.max(e,t),n)}function KC(e,t,n){let r=UC(e,t);if(r)return n(r)?r:null}function qC(e){return e.interaction_id!==void 0&&typeof e.interaction_id!=`string`||e.component!==void 0&&typeof e.component!=`string`||e.component_version!==void 0&&typeof e.component_version!=`string`||e.type!==void 0&&typeof e.type!=`string`||e.metadata!==void 0&&!kC(e.metadata)?null:e}var JC=`tavus-deployment magic-canvas/0.0.0`;function YC(e){if(!sC(e)||e.canvas_config===void 0||e.canvas_config===null)return null;let t=cC(e.canvas_config),n=e.properties.tool_call_id;if(!t)return null;if(!n)throw Error(`Received Magic Canvas tool call without tool_call_id.`);let r=lC(e.properties.arguments);if(!r.ok)throw r.error;return xC({conversationId:e.conversation_id,toolCallId:n,args:r.value,canvasConfig:t})}function XC(e){if(!sC(e))return null;if(e.canvas_config!==void 0&&e.canvas_config!==null){let t=YC(e);return t?{kind:`show`,instance:t}:null}return uC(e)}function ZC(e){return{body:{interaction_id:e.interaction_id,tool_call_id:e.tool_call_id,component:e.component,component_version:e.component_version,type:e.type,value:e.value,metadata:e.metadata}}}function QC(e,t){return{theme:e.theme,displayMode:t?.display_mode??`inline`,availableDisplayModes:[`inline`,`fullscreen`],...t?{containerDimensions:DC(t),layout:{preferred_slot:t.preferred_slot,viable_slot:t.viable_slot,avoid_safe_area:t.avoid_safe_area,safe_area:t.safe_area,backdrop:t.backdrop}}:{},platform:`web`,userAgent:JC,styles:{variables:$C(e.cssVars)}}}function $C(e){return{"--border-radius-md":e[`--radius-box`]??e[`--tavus-boxes-radius`]??`0.5rem`,"--border-radius-sm":e[`--radius-field`]??e[`--tavus-field-radius`]??`0.375rem`,"--border-radius-xs":e[`--radius-selector`]??`0.25rem`,"--border-radius-lg":e[`--radius-box`]??e[`--tavus-boxes-radius`]??`0.75rem`,"--border-width-regular":e[`--border`]??e[`--tavus-border-width`]??`1px`,"--font-text-sm-size":`0.875rem`,"--font-text-md-size":`1rem`,...ew(e)}}function ew(e){let t=e[`--color-base-content`],n=e[`--color-base-100`],r=e[`--color-base-200`],i=e[`--color-base-300`],a=e[`--color-error`],o={},s=(e,t)=>{t&&(o[e]=t)},c=(e,t,n)=>e&&n?`color-mix(in oklch, ${e} ${t}%, ${n})`:void 0;return s(`--color-background-primary`,n),s(`--color-background-secondary`,r),s(`--color-border-secondary`,i),s(`--color-border-primary`,c(t,28,n)),s(`--color-text-primary`,t),s(`--color-text-secondary`,c(t,62,n)),s(`--color-text-danger`,a),s(`--color-border-danger`,a),o}var tw=24,nw=96;function rw(e=document){let t=Array.from(e.querySelectorAll(`[data-canvas-card]`)).map(e=>e.getBoundingClientRect());return t.length===0?null:{left:Math.min(...t.map(e=>e.left)),right:Math.max(...t.map(e=>e.right)),top:Math.min(...t.map(e=>e.top)),bottom:Math.max(...t.map(e=>e.bottom))}}function iw(e){let t=e?.getRootNode();return t instanceof ShadowRoot?t:document}function aw(e){if(!e)return null;let t=e.getBoundingClientRect();return t.width<=0||t.height<=0?null:{left:t.left,right:t.right,top:t.top,bottom:t.bottom}}function ow(e,t,n,r){if(!t)return!1;let i=r?r.left:0,a=r?r.top:0,o=r?r.right-r.left:globalThis.innerWidth,s=r?r.bottom-r.top:globalThis.innerHeight,c=e?.safe_area??aC,l=i+c.x*o+n,u=i+(c.x+c.width)*o+n,d=a+c.y*s,f=a+(c.y+c.height)*s;return l<t.right&&u>t.left&&d<t.bottom&&f>t.top}function sw(e,t,n){let[r,i]=j(()=>e?rw(iw(n?.current)):null);return at(()=>{if(!e){i(null);return}let t=iw(n?.current),r=()=>i(rw(t)),a=new ResizeObserver(r),o=()=>{for(let e of t.querySelectorAll(`[data-canvas-card]`))a.observe(e)};r(),o(),a.observe(document.documentElement);let s=globalThis.requestAnimationFrame(()=>{r(),o()});return globalThis.addEventListener(`resize`,r),()=>{a.disconnect(),globalThis.removeEventListener(`resize`,r),globalThis.cancelAnimationFrame(s)}},[e,t,n]),e?r:null}function cw(e,t,n){let[r,i]=j(()=>t?aw(e.current):null);return at(()=>{if(!t){i(null);return}let n=()=>i(aw(e.current)),r=new ResizeObserver(n);n(),e.current&&r.observe(e.current),r.observe(document.documentElement);let a=globalThis.requestAnimationFrame(n);return globalThis.addEventListener(`resize`,n),()=>{r.disconnect(),globalThis.removeEventListener(`resize`,n),globalThis.cancelAnimationFrame(a)}},[t,n,e]),t?r:null}function lw(e,t,n,r,i,a){let o=e?.side??(n===`safe-area-left`?`left`:n===`safe-area-right`?`right`:null);return{usePip:o!=null&&(t===`pip`||t===`auto`&&ow(e,r,i,a)),side:o}}function uw(e,t=document,n){let r=n?n.left:0,i=n?n.right:globalThis.innerWidth,a=n?n.top:0,o=n?n.bottom:globalThis.innerHeight,s=i-r,c=o-a,l=Array.from(t.querySelectorAll(`[data-canvas-card]`)).map(e=>e.getBoundingClientRect()),u,d,f,p;if(l.length>0){let t=Math.min(...l.map(e=>e.left)),n=Math.max(...l.map(e=>e.right));f=Math.min(...l.map(e=>e.top)),p=Math.max(...l.map(e=>e.bottom)),[u,d]=e===`right`?[r,t]:[n,i]}else{let t=Math.min(448,Math.max(0,s-32));[u,d]=e===`right`?[r,i-16-t]:[r+16+t,i],f=a,p=o}let m=d-u>=144&&p-f>=nw&&u>=r&&d<=i;if(l.length>0&&!m){let t=Math.min(448,Math.max(0,s-32));[u,d]=e===`right`?[r,i-16-t]:[r+16+t,i],f=a,p=o}let h=Math.max(0,d-u-tw*2),g=Math.max(nw,Math.min(h,c-tw*2));return{centerX:(u+d)/2-r,centerY:(f+p)/2-a,diameter:g}}var dw=`560ms linear(0, 0, .0001, .0002, .0003, .0005, .0007, .001, .0013, .0016, .002, .0024, .0029, .0033, .0039, .0044, .005, .0057, .0063, .007, .0079, .0086, .0094, .0103, .0112, .0121, .0132 1.84%, .0153, .0175, .0201, .0226, .0253, .0283, .0313, .0345, .038, .0416, .0454, .0493, .0535, .0576, .0621, .0667, .0714, .0764, .0816 5.04%, .0897, .098 5.62%, .1071, .1165, .1263 6.56%, .137, .1481 7.25%, .1601 7.62%, .1706 7.94%, .1819 8.28%, .194, .2068 9.02%, .2331 9.79%, .2898 11.44%, .3151 12.18%, .3412 12.95%, .3533, .365 13.66%, .3786, .3918, .4045, .4167, .4288, .4405, .452, .4631 16.72%, .4759, .4884, .5005, .5124, .5242, .5354, .5467, .5576, .5686, .5791, .5894, .5995, .6094, .6194, .6289, .6385, .6477, .6569, .6659 24.45%, .6702, .6747, .6789, .6833, .6877, .6919, .696, .7002, .7043, .7084, .7125, .7165, .7205, .7244, .7283, .7321, .7358, .7396, .7433, .7471, .7507, .7544, .7579, .7615, .7649, .7685, .7718, .7752, .7786, .782, .7853, .7885, .7918, .7951, .7982, .8013, .8043, .8075, .8104, .8135, .8165, .8195, .8224, .8253, .8281, .8309, .8336, .8365, .8391, .8419, .8446, .8472, .8499, .8524, .855, .8575, .8599, .8625 37.27%, .8651, .8678, .8703, .8729, .8754, .8779, .8803, .8827, .8851, .8875, .8898, .892, .8942, .8965, .8987, .9009, .903, .9051, .9071, .9092, .9112, .9132, .9151, .9171, .919, .9209, .9227, .9245, .9262, .928, .9297, .9314, .9331, .9347, .9364, .9379, .9395, .941, .9425, .944, .9454, .9469, .9483, .9497, .951, .9524, .9537, .955, .9562, .9574, .9586, .9599, .961, .9622, .9633, .9644, .9655, .9665, .9676, .9686, .9696, .9705, .9715, .9724, .9733, .9742, .975, .9758, .9766, .9774, .9782, .9789, .9796, .9804, .9811, .9817, .9824, .9831, .9837, .9843, .9849, .9855, .986, .9866, .9871, .9877, .9882, .9887, .9892, .9896 70.56%, .9905 71.67%, .9914 72.82%, .9922, .9929 75.2%, .9936 76.43%, .9942 77.71%, .9948 79.03%, .9954 80.39%, .9959 81.81%, .9963 83.28%, .9968 84.82%, .9972 86.41%, .9975 88.07%, .9979 89.81%, .9982 91.64%, .9984 93.56%, .9987 95.58%, .9989 97.72%, .9991)`;function fw(e,t){let n=Math.abs(t)/2;return e===`left`?`${n}px center`:`calc(100% - ${n}px) center`}function pw(e,t,n){let[r,i]=j(()=>e&&t?uw(t,iw(n?.current),aw(n?.current)):null);return at(()=>{if(!e||!t){i(null);return}let r=iw(n?.current),a=()=>i(uw(t,r,aw(n?.current))),o=new ResizeObserver(a),s=()=>{for(let e of r.querySelectorAll(`[data-canvas-card]`))o.observe(e)};a(),s(),n?.current&&o.observe(n.current),o.observe(document.documentElement);let c=globalThis.requestAnimationFrame(()=>{a(),s()});return globalThis.addEventListener(`resize`,a),()=>{o.disconnect(),globalThis.removeEventListener(`resize`,a),globalThis.cancelAnimationFrame(c)}},[e,t,n]),e&&t?r:null}function mw(e,t){let[n,r]=j(null);return at(()=>{if(!t){r(null);return}let n=e.current;if(!n)return;let i=()=>{let e=n.clientWidth,t=n.clientHeight;r(e&&t?{width:e,height:t}:null)},a=new ResizeObserver(i);return a.observe(n),i(),()=>a.disconnect()},[t,e]),t?n:null}var hw=1;function gw(e,t,n){return Math.min(Math.max(e,t),n)}function _w(e,t,n,r){let i=Math.min(e.diameter/t.height,1),a=r?.safe_area??aC,o=((a.x+a.width/2)*t.width+n)*i,s=(a.y+a.height/2)*t.height*i,c=e.diameter/2;return{scale:i,tx:gw(e.centerX-o,e.centerX+c-t.width*i,e.centerX-c),ty:gw(e.centerY-s,e.centerY+c-t.height*i,e.centerY-c)}}var vw=[`cx`,`cy`,`r`,`tx`,`ty`,`s`,`shift`];function yw(e,t,n,r,i){if(!n)return null;let{width:a,height:o}=n,s={x:a/2,y:o/2},c=null;if(e&&(c=_w(e,n,r,i),s={x:(e.centerX-c.tx)/c.scale,y:(e.centerY-c.ty)/c.scale}),t&&c&&e)return{cx:s.x,cy:s.y,r:e.diameter/2/c.scale,tx:c.tx,ty:c.ty,s:c.scale,shift:r};let l=Math.hypot(Math.max(s.x,a-s.x),Math.max(s.y,o-s.y));return{cx:s.x,cy:s.y,r:l*1.1,tx:0,ty:0,s:1,shift:r}}function bw(e,t,n){let r=N(null),i=N(e),a=N(n),o=N(0),s=N(0);i.current=e,a.current=n,M(()=>{let e=i.current;if(!e)return;if(!r.current||xw()){r.current={values:{...e},velocity:{cx:0,cy:0,r:0,tx:0,ty:0,s:0,shift:0}},a.current(e,!0);return}if(o.current)return;let n=Math.max(t,160)/4e3;s.current=performance.now();let c=e=>{o.current=0;let t=i.current,l=r.current;if(!t||!l)return;let u=Math.min((e-s.current)/1e3,1/30);s.current=e;let d=!0;for(let e of vw){let r=(t[e]-l.values[e])/(n*n)-2/n*l.velocity[e],i=l.velocity[e]+r*u,a=l.values[e]+i*u,o=e===`s`?.001:.25;Math.abs(t[e]-a)<o&&Math.abs(i)*n<o?(l.values[e]=t[e],l.velocity[e]=0):(l.values[e]=a,l.velocity[e]=i,d=!1)}a.current(l.values,d),d||(o.current=globalThis.requestAnimationFrame(c))};o.current=globalThis.requestAnimationFrame(c)},[e?vw.map(t=>Math.round(e[t]*100)).join():``,t]),M(()=>()=>{o.current&&globalThis.cancelAnimationFrame(o.current)},[])}function xw(){return globalThis.matchMedia?.(`(prefers-reduced-motion: reduce)`).matches??!1}function Sw({geom:e,visible:t}){return L(`div`,{"aria-hidden":`true`,"data-morph":`ring`,class:`pointer-events-none absolute z-10 rounded-full`,style:{top:`${e.centerY-e.diameter/2}px`,left:`${e.centerX-e.diameter/2}px`,width:`${e.diameter}px`,height:`${e.diameter}px`,boxShadow:`0 0 0 3px rgb(255 255 255 / 12%), 0 18px 50px rgb(0 0 0 / 55%)`,opacity:+!!t,transition:`opacity 240ms ease-out`}})}function Cw(e,t){let n=t>=0?`left`:`right`,r=N({side:n,shift:t});M(()=>{e&&(r.current={side:n,shift:t})},[e,n,t]);let i=e?n:r.current.side;return{side:i,transformOrigin:fw(i,e?t:r.current.shift),translateX:e?0:-r.current.shift}}function ww(e,t,n){return`${e.side??``}:${e.active}:${t}:${n??``}`}function Tw({snapshotUrl:e,transformOrigin:t}){return L(`div`,{class:`absolute inset-0 bg-cover bg-center`,style:{backgroundImage:`url("${e}")`,transform:`scaleX(-1)`,transformOrigin:t}})}function Ew({snapshotUrl:e,translateX:t,transition:n,transformOrigin:r}){return L(`div`,{"aria-hidden":`true`,"data-morph":`mirror`,class:`pointer-events-none absolute z-0 overflow-hidden`,style:{inset:`0 0`,transform:`translate3d(${t}px, 0, 0)`,transition:`transform ${n}`,willChange:`transform`},children:L(Tw,{snapshotUrl:e,transformOrigin:r})})}function Dw({ambient:e,usePip:t,transition:n}){return e===`none`?null:L(`div`,{"aria-hidden":`true`,"data-morph":`ambient`,class:`pointer-events-none absolute inset-0 z-0`,style:{opacity:+!!t,transition:`opacity ${n}`,background:e===`darker`?`rgb(0 0 0 / 40%)`:`rgb(0 0 0 / 15%)`}})}function Ow({morphCapable:e,snapshotUrl:t,mirrorSide:n,videoShiftX:r,transition:i,sceneRef:a,videoWrapRef:o,fill:s,videoRef:c}){return L(`div`,{ref:a,"data-morph":`scene`,class:`absolute inset-0`,style:e?{transformOrigin:`top left`}:void 0,children:L(`div`,{ref:o,class:`absolute inset-0`,style:e?void 0:{transform:`translate3d(${r}px, 0, 0)`,transition:`transform ${i}`},children:[s(c),e&&t!==null&&L(`div`,{"aria-hidden":`true`,"data-morph":`window-mirror`,class:`absolute top-0 bottom-0 w-full`,style:n===`right`?{left:`calc(100% - ${hw}px)`}:{right:`calc(100% - ${hw}px)`},children:L(Tw,{snapshotUrl:t,transformOrigin:`center`})})]})})}function kw({canvasLayoutEffect:e,smartSidecarActive:t,isScreenSharing:n,fill:r,captureSnapshot:i,transition:a=dw,transitionMs:o=560,personaMode:s=`shift`,renderedSlot:c=null,ambient:l=`default`,children:u}){let d=N(null),[f,p]=j(null),m=t&&e.backdrop.type===`snapshot_mirror`,h=t?e.video_shift_x:0,g=N(null),_=ww(e,h,c),{usePip:v,side:y}=lw(e,s,c,sw(s!==`shift`,_,g),h,cw(g,s!==`shift`,_)),b=pw(s!==`shift`,y,g),x=Cw(m,h);M(()=>{if(!m)return;let e=!1,t=0,n,r=0,a=()=>{if(e)return;let t=i(d.current);if(t){p(t);return}r+=1,r<8&&(n=globalThis.setTimeout(a,150))};return typeof globalThis.requestAnimationFrame==`function`?t=globalThis.requestAnimationFrame(a):n=globalThis.setTimeout(a,0),()=>{e=!0,t&&globalThis.cancelAnimationFrame?.(t),n&&globalThis.clearTimeout(n)}},[m,e.side,e.video_shift_x,i]),M(()=>{if(m||f===null)return;let e=globalThis.setTimeout(()=>{p(null)},o);return()=>globalThis.clearTimeout(e)},[m,f,o]);let S=v&&y!=null&&b!=null,C=s!==`shift`,w=mw(g,C),T=f!==null&&!C,E=C&&y!=null,D=N(null),ee=N(null),[te,ne]=j(!0),re=N(!0),O=F((e,t)=>{let n=D.current;n&&(n.style.clipPath=`circle(${e.r}px at ${e.cx}px ${e.cy}px)`,n.style.transform=`translate(${e.tx}px, ${e.ty}px) scale(${e.s})`);let r=ee.current;r&&(r.style.transform=`translate3d(${e.shift}px, 0, 0)`),re.current!==t&&(re.current=t,ne(t))},[]);return bw(C?yw(b,S,w,h,e):null,o,O),L(`div`,{ref:g,class:`relative w-full h-full overflow-hidden ${n?`flex items-center justify-center`:``}`,children:[T&&f!==null&&L(Ew,{snapshotUrl:f,translateX:x.translateX,transition:a,transformOrigin:x.transformOrigin}),E&&L(Dw,{ambient:l,usePip:v,transition:a}),L(`div`,{"data-morph":`fg`,class:`absolute inset-0 z-10`,children:L(Ow,{morphCapable:C,snapshotUrl:f,mirrorSide:x.side,videoShiftX:h,transition:a,sceneRef:D,videoWrapRef:ee,fill:r,videoRef:d})}),C&&b&&L(Sw,{geom:b,visible:S&&te}),u]})}var Aw=480,jw=Ea(({personaSessionId:e,isAudioOnly:t,avatarOff:n,canvasLayoutEffect:r,smartSidecarActive:i})=>{let a=t||n,o=i?r.video_shift_x:0;return L(`div`,{class:`absolute inset-0 overflow-hidden`,children:L(`div`,{class:`absolute top-0 bottom-0`,style:{left:o>0?`${Aw}px`:`0px`,right:o<0?`${Aw}px`:`0px`,transition:`left ${dw}, right ${dw}`},children:[L(Cg,{automirror:!0,sessionId:e,type:`screenVideo`,fit:`contain`,className:`absolute inset-0 w-full h-full object-contain`}),L(`div`,{class:`absolute bottom-4 right-4 aspect-square w-32 @max-mobile:w-24 rounded-box overflow-hidden bg-black/30 z-10`,children:a?L(`div`,{class:`flex w-full h-full items-center justify-center`,children:L(LS,{sessionId:e})}):L(Cg,{automirror:!0,sessionId:e,type:`video`,fit:`cover`,className:`w-full h-full object-cover`})})]})})});function K(e,t,n){function r(n,r){if(n._zod||Object.defineProperty(n,"_zod",{value:{def:r,constr:o,traits:new Set},enumerable:!1}),n._zod.traits.has(e))return;n._zod.traits.add(e),t(n,r);let i=o.prototype,a=Object.keys(i);for(let e=0;e<a.length;e++){let t=a[e];t in n||(n[t]=i[t].bind(n))}}let i=n?.Parent??Object;class a extends i{}Object.defineProperty(a,"name",{value:e});function o(e){var t;let i=n?.Parent?new a:this;r(i,e),(t=i._zod).deferred??(t.deferred=[]);for(let e of i._zod.deferred)e();return i}return Object.defineProperty(o,"init",{value:r}),Object.defineProperty(o,Symbol.hasInstance,{value:t=>n?.Parent&&t instanceof n.Parent?!0:t?._zod?.traits?.has(e)}),Object.defineProperty(o,"name",{value:e}),o}function Mw(e){return e&&Object.assign(Iw,e),Iw}var Nw,Pw,Fw,Iw,Lw=a((()=>{Pw=class extends Error{constructor(){super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`)}},Fw=class extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name=`ZodEncodeError`}},(Nw=globalThis).__zod_globalConfig??(Nw.__zod_globalConfig={}),Iw=globalThis.__zod_globalConfig}));function Rw(e){let t=Object.values(e).filter(e=>typeof e==`number`);return Object.entries(e).filter(([e,n])=>t.indexOf(+e)===-1).map(([e,t])=>t)}function zw(e,t=`|`){return e.map(e=>tT(e)).join(t)}function Bw(e,t){return typeof t==`bigint`?t.toString():t}function Vw(e){return{get value(){{let t=e();return Object.defineProperty(this,"value",{value:t}),t}throw Error(`cached value already set`)}}}function Hw(e){return e==null}function Uw(e){let t=+!!e.startsWith(`^`),n=e.endsWith(`$`)?e.length-1:e.length;return e.slice(t,n)}function Ww(e,t){let n=e/t,r=Math.round(n),i=2**-52*Math.max(Math.abs(n),1);return Math.abs(n-r)<i?0:n-r}function Gw(e,t,n){let r;Object.defineProperty(e,t,{get(){if(r!==vT)return r===void 0&&(r=vT,r=n()),r},set(n){Object.defineProperty(e,t,{value:n})},configurable:!0})}function Kw(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function qw(...e){let t={};for(let n of e){let e=Object.getOwnPropertyDescriptors(n);Object.assign(t,e)}return Object.defineProperties({},t)}function Jw(e){return JSON.stringify(e)}function Yw(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,``).replace(/[\s_-]+/g,`-`).replace(/^-+|-+$/g,``)}function Xw(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Zw(e){if(Xw(e)===!1)return!1;let t=e.constructor;if(t===void 0||typeof t!=`function`)return!0;let n=t.prototype;return!(Xw(n)===!1||Object.prototype.hasOwnProperty.call(n,`isPrototypeOf`)===!1)}function Qw(e){return Zw(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}function $w(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function eT(e,t,n){let r=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(r._zod.parent=e),r}function q(e){let t=e;if(!t)return{};if(typeof t==`string`)return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error==`string`?{...t,error:()=>t.error}:t}function tT(e){return typeof e==`bigint`?e.toString()+`n`:typeof e==`string`?`"${e}"`:`${e}`}function nT(e){return Object.keys(e).filter(t=>e[t]._zod.optin===`optional`&&e[t]._zod.optout===`optional`)}function rT(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw Error(`.pick() cannot be used on object schemas containing refinements`);return eT(e,qw(e._zod.def,{get shape(){let e={};for(let r in t){if(!(r in n.shape))throw Error(`Unrecognized key: "${r}"`);t[r]&&(e[r]=n.shape[r])}return Kw(this,`shape`,e),e},checks:[]}))}function iT(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw Error(`.omit() cannot be used on object schemas containing refinements`);return eT(e,qw(e._zod.def,{get shape(){let r={...e._zod.def.shape};for(let e in t){if(!(e in n.shape))throw Error(`Unrecognized key: "${e}"`);t[e]&&delete r[e]}return Kw(this,`shape`,r),r},checks:[]}))}function aT(e,t){if(!Zw(t))throw Error(`Invalid input to extend: expected a plain object`);let n=e._zod.def.checks;if(n&&n.length>0){let n=e._zod.def.shape;for(let e in t)if(Object.getOwnPropertyDescriptor(n,e)!==void 0)throw Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}return eT(e,qw(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t};return Kw(this,`shape`,n),n}}))}function oT(e,t){if(!Zw(t))throw Error(`Invalid input to safeExtend: expected a plain object`);return eT(e,qw(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t};return Kw(this,`shape`,n),n}}))}function sT(e,t){if(e._zod.def.checks?.length)throw Error(`.merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.`);return eT(e,qw(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t._zod.def.shape};return Kw(this,`shape`,n),n},get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]}))}function cT(e,t,n){let r=t._zod.def.checks;if(r&&r.length>0)throw Error(`.partial() cannot be used on object schemas containing refinements`);return eT(t,qw(t._zod.def,{get shape(){let r=t._zod.def.shape,i={...r};if(n)for(let t in n){if(!(t in r))throw Error(`Unrecognized key: "${t}"`);n[t]&&(i[t]=e?new e({type:`optional`,innerType:r[t]}):r[t])}else for(let t in r)i[t]=e?new e({type:`optional`,innerType:r[t]}):r[t];return Kw(this,`shape`,i),i},checks:[]}))}function lT(e,t,n){return eT(t,qw(t._zod.def,{get shape(){let r=t._zod.def.shape,i={...r};if(n)for(let t in n){if(!(t in i))throw Error(`Unrecognized key: "${t}"`);n[t]&&(i[t]=new e({type:`nonoptional`,innerType:r[t]}))}else for(let t in r)i[t]=new e({type:`nonoptional`,innerType:r[t]});return Kw(this,`shape`,i),i}}))}function uT(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue!==!0)return!0;return!1}function dT(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue===!1)return!0;return!1}function fT(e,t){return t.map(t=>{var n;return(n=t).path??(n.path=[]),t.path.unshift(e),t})}function pT(e){return typeof e==`string`?e:e?.message}function mT(e,t,n){let r=e.message?e.message:pT(e.inst?._zod.def?.error?.(e))??pT(t?.error?.(e))??pT(n.customError?.(e))??pT(n.localeError?.(e))??`Invalid input`,{inst:i,continue:a,input:o,...s}=e;return s.path??=[],s.message=r,t?.reportInput&&(s.input=o),s}function hT(e){return Array.isArray(e)?`array`:typeof e==`string`?`string`:`unknown`}function gT(e){let t=typeof e;switch(t){case`number`:return Number.isNaN(e)?`nan`:`number`;case`object`:{if(e===null)return`null`;if(Array.isArray(e))return`array`;let t=e;if(t&&Object.getPrototypeOf(t)!==Object.prototype&&`constructor`in t&&t.constructor)return t.constructor.name}}return t}function _T(...e){let[t,n,r]=e;return typeof t==`string`?{message:t,code:`custom`,input:n,inst:r}:{...t}}var vT,yT,bT,xT,ST,CT=a((()=>{Lw(),vT=Symbol(`evaluating`),yT=`captureStackTrace`in Error?Error.captureStackTrace:(...e)=>{},bT=Vw(()=>{if(Iw.jitless||typeof navigator<`u`&&navigator?.userAgent?.includes(`Cloudflare`))return!1;try{return Function(``),!0}catch{return!1}}),xT=new Set([`string`,`number`,`symbol`]),ST={safeint:[-(2**53-1),2**53-1],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]}}));function wT(e,t=e=>e.message){let n={},r=[];for(let i of e.issues)i.path.length>0?(n[i.path[0]]=n[i.path[0]]||[],n[i.path[0]].push(t(i))):r.push(t(i));return{formErrors:r,fieldErrors:n}}function TT(e,t=e=>e.message){let n={_errors:[]},r=(e,i=[])=>{for(let a of e.issues)if(a.code===`invalid_union`&&a.errors.length)a.errors.map(e=>r({issues:e},[...i,...a.path]));else if(a.code===`invalid_key`)r({issues:a.issues},[...i,...a.path]);else if(a.code===`invalid_element`)r({issues:a.issues},[...i,...a.path]);else{let e=[...i,...a.path];if(e.length===0)n._errors.push(t(a));else{let r=n,i=0;for(;i<e.length;){let n=e[i];i===e.length-1?(r[n]=r[n]||{_errors:[]},r[n]._errors.push(t(a))):r[n]=r[n]||{_errors:[]},r=r[n],i++}}}};return r(e),n}var ET,DT,OT,kT=a((()=>{Lw(),CT(),ET=(e,t)=>{e.name=`$ZodError`,Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:t,enumerable:!1}),e.message=JSON.stringify(t,Bw,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},DT=K(`$ZodError`,ET),OT=K(`$ZodError`,ET,{Parent:Error})})),AT,jT,MT,NT,PT,FT,IT,LT,RT,zT,BT,VT,HT,UT,WT=a((()=>{Lw(),kT(),CT(),AT=e=>(t,n,r,i)=>{let a=r?{...r,async:!1}:{async:!1},o=t._zod.run({value:n,issues:[]},a);if(o instanceof Promise)throw new Pw;if(o.issues.length){let t=new((i?.Err)??e)(o.issues.map(e=>mT(e,a,Mw())));throw yT(t,i?.callee),t}return o.value},jT=e=>async(t,n,r,i)=>{let a=r?{...r,async:!0}:{async:!0},o=t._zod.run({value:n,issues:[]},a);if(o instanceof Promise&&(o=await o),o.issues.length){let t=new((i?.Err)??e)(o.issues.map(e=>mT(e,a,Mw())));throw yT(t,i?.callee),t}return o.value},MT=e=>(t,n,r)=>{let i=r?{...r,async:!1}:{async:!1},a=t._zod.run({value:n,issues:[]},i);if(a instanceof Promise)throw new Pw;return a.issues.length?{success:!1,error:new(e??DT)(a.issues.map(e=>mT(e,i,Mw())))}:{success:!0,data:a.value}},NT=MT(OT),PT=e=>async(t,n,r)=>{let i=r?{...r,async:!0}:{async:!0},a=t._zod.run({value:n,issues:[]},i);return a instanceof Promise&&(a=await a),a.issues.length?{success:!1,error:new e(a.issues.map(e=>mT(e,i,Mw())))}:{success:!0,data:a.value}},FT=PT(OT),IT=e=>(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return AT(e)(t,n,i)},LT=e=>(t,n,r)=>AT(e)(t,n,r),RT=e=>async(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return jT(e)(t,n,i)},zT=e=>async(t,n,r)=>jT(e)(t,n,r),BT=e=>(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return MT(e)(t,n,i)},VT=e=>(t,n,r)=>MT(e)(t,n,r),HT=e=>async(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return PT(e)(t,n,i)},UT=e=>async(t,n,r)=>PT(e)(t,n,r)}));function GT(){return new RegExp(aE,`u`)}function KT(e){let t=`(?:[01]\\d|2[0-3]):[0-5]\\d`;return typeof e.precision==`number`?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function qT(e){return RegExp(`^${KT(e)}$`)}function JT(e){let t=KT({precision:e.precision}),n=[`Z`];e.local&&n.push(``),e.offset&&n.push(`([+-](?:[01]\\d|2[0-3]):[0-5]\\d)`);let r=`${t}(?:${n.join(`|`)})`;return RegExp(`^${mE}T(?:${r})$`)}var YT,XT,ZT,QT,$T,eE,tE,nE,rE,iE,aE,oE,sE,cE,lE,uE,dE,fE,pE,mE,hE,gE,_E,vE,yE,bE,xE,SE,CE,wE=a((()=>{YT=/^[cC][0-9a-z]{6,}$/,XT=/^[0-9a-z]+$/,ZT=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,QT=/^[0-9a-vA-V]{20}$/,$T=/^[A-Za-z0-9]{27}$/,eE=/^[a-zA-Z0-9_-]{21}$/,tE=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,nE=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,rE=e=>e?RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,iE=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,aE=`^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`,oE=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,sE=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/,cE=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,lE=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,uE=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,dE=/^[A-Za-z0-9_-]*$/,fE=/^https?$/,pE=/^\+[1-9]\d{6,14}$/,mE=`(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))`,hE=RegExp(`^${mE}$`),gE=e=>{let t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??``}}`:`[\\s\\S]*`;return RegExp(`^${t}$`)},_E=/^-?\d+$/,vE=/^-?\d+(?:\.\d+)?$/,yE=/^(?:true|false)$/i,bE=/^null$/i,xE=/^undefined$/i,SE=/^[^A-Z]*$/,CE=/^[^a-z]*$/})),TE,EE,DE,OE,kE,AE,jE,ME,NE,PE,FE,IE,LE,RE,zE,BE,VE,HE=a((()=>{Lw(),wE(),CT(),TE=K(`$ZodCheck`,(e,t)=>{var n;e._zod??={},e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),EE={number:`number`,bigint:`bigint`,object:`date`},DE=K(`$ZodCheckLessThan`,(e,t)=>{TE.init(e,t);let n=EE[typeof t.value];e._zod.onattach.push(e=>{let n=e._zod.bag,r=(t.inclusive?n.maximum:n.exclusiveMaximum)??1/0;t.value<r&&(t.inclusive?n.maximum=t.value:n.exclusiveMaximum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value<=t.value:r.value<t.value)||r.issues.push({origin:n,code:`too_big`,maximum:typeof t.value==`object`?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),OE=K(`$ZodCheckGreaterThan`,(e,t)=>{TE.init(e,t);let n=EE[typeof t.value];e._zod.onattach.push(e=>{let n=e._zod.bag,r=(t.inclusive?n.minimum:n.exclusiveMinimum)??-1/0;t.value>r&&(t.inclusive?n.minimum=t.value:n.exclusiveMinimum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value>=t.value:r.value>t.value)||r.issues.push({origin:n,code:`too_small`,minimum:typeof t.value==`object`?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),kE=K(`$ZodCheckMultipleOf`,(e,t)=>{TE.init(e,t),e._zod.onattach.push(e=>{var n;(n=e._zod.bag).multipleOf??(n.multipleOf=t.value)}),e._zod.check=n=>{if(typeof n.value!=typeof t.value)throw Error(`Cannot mix number and bigint in multiple_of check.`);(typeof n.value==`bigint`?n.value%t.value===BigInt(0):Ww(n.value,t.value)===0)||n.issues.push({origin:typeof n.value,code:`not_multiple_of`,divisor:t.value,input:n.value,inst:e,continue:!t.abort})}}),AE=K(`$ZodCheckNumberFormat`,(e,t)=>{TE.init(e,t),t.format=t.format||`float64`;let n=t.format?.includes(`int`),r=n?`int`:`number`,[i,a]=ST[t.format];e._zod.onattach.push(e=>{let r=e._zod.bag;r.format=t.format,r.minimum=i,r.maximum=a,n&&(r.pattern=_E)}),e._zod.check=o=>{let s=o.value;if(n){if(!Number.isInteger(s)){o.issues.push({expected:r,format:t.format,code:`invalid_type`,continue:!1,input:s,inst:e});return}if(!Number.isSafeInteger(s)){s>0?o.issues.push({input:s,code:`too_big`,maximum:2**53-1,note:`Integers must be within the safe integer range.`,inst:e,origin:r,inclusive:!0,continue:!t.abort}):o.issues.push({input:s,code:`too_small`,minimum:-(2**53-1),note:`Integers must be within the safe integer range.`,inst:e,origin:r,inclusive:!0,continue:!t.abort});return}}s<i&&o.issues.push({origin:`number`,input:s,code:`too_small`,minimum:i,inclusive:!0,inst:e,continue:!t.abort}),s>a&&o.issues.push({origin:`number`,input:s,code:`too_big`,maximum:a,inclusive:!0,inst:e,continue:!t.abort})}}),jE=K(`$ZodCheckMaxLength`,(e,t)=>{var n;TE.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!Hw(t)&&t.length!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag.maximum??1/0;t.maximum<n&&(e._zod.bag.maximum=t.maximum)}),e._zod.check=n=>{let r=n.value;if(r.length<=t.maximum)return;let i=hT(r);n.issues.push({origin:i,code:`too_big`,maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),ME=K(`$ZodCheckMinLength`,(e,t)=>{var n;TE.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!Hw(t)&&t.length!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag.minimum??-1/0;t.minimum>n&&(e._zod.bag.minimum=t.minimum)}),e._zod.check=n=>{let r=n.value;if(r.length>=t.minimum)return;let i=hT(r);n.issues.push({origin:i,code:`too_small`,minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),NE=K(`$ZodCheckLengthEquals`,(e,t)=>{var n;TE.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!Hw(t)&&t.length!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag;n.minimum=t.length,n.maximum=t.length,n.length=t.length}),e._zod.check=n=>{let r=n.value,i=r.length;if(i===t.length)return;let a=hT(r),o=i>t.length;n.issues.push({origin:a,...o?{code:`too_big`,maximum:t.length}:{code:`too_small`,minimum:t.length},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}}),PE=K(`$ZodCheckStringFormat`,(e,t)=>{var n,r;TE.init(e,t),e._zod.onattach.push(e=>{let n=e._zod.bag;n.format=t.format,t.pattern&&(n.patterns??=new Set,n.patterns.add(t.pattern))}),t.pattern?(n=e._zod).check??(n.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:`string`,code:`invalid_format`,format:t.format,input:n.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(r=e._zod).check??(r.check=()=>{})}),FE=K(`$ZodCheckRegex`,(e,t)=>{PE.init(e,t),e._zod.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:`string`,code:`invalid_format`,format:`regex`,input:n.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),IE=K(`$ZodCheckLowerCase`,(e,t)=>{t.pattern??=SE,PE.init(e,t)}),LE=K(`$ZodCheckUpperCase`,(e,t)=>{t.pattern??=CE,PE.init(e,t)}),RE=K(`$ZodCheckIncludes`,(e,t)=>{TE.init(e,t);let n=$w(t.includes),r=new RegExp(typeof t.position==`number`?`^.{${t.position}}${n}`:n);t.pattern=r,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=new Set,t.patterns.add(r)}),e._zod.check=n=>{n.value.includes(t.includes,t.position)||n.issues.push({origin:`string`,code:`invalid_format`,format:`includes`,includes:t.includes,input:n.value,inst:e,continue:!t.abort})}}),zE=K(`$ZodCheckStartsWith`,(e,t)=>{TE.init(e,t);let n=RegExp(`^${$w(t.prefix)}.*`);t.pattern??=n,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=new Set,t.patterns.add(n)}),e._zod.check=n=>{n.value.startsWith(t.prefix)||n.issues.push({origin:`string`,code:`invalid_format`,format:`starts_with`,prefix:t.prefix,input:n.value,inst:e,continue:!t.abort})}}),BE=K(`$ZodCheckEndsWith`,(e,t)=>{TE.init(e,t);let n=RegExp(`.*${$w(t.suffix)}$`);t.pattern??=n,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=new Set,t.patterns.add(n)}),e._zod.check=n=>{n.value.endsWith(t.suffix)||n.issues.push({origin:`string`,code:`invalid_format`,format:`ends_with`,suffix:t.suffix,input:n.value,inst:e,continue:!t.abort})}}),VE=K(`$ZodCheckOverwrite`,(e,t)=>{TE.init(e,t),e._zod.check=e=>{e.value=t.tx(e.value)}})})),UE,WE=a((()=>{UE=class{constructor(e=[]){this.content=[],this.indent=0,this&&(this.args=e)}indented(e){this.indent+=1,e(this),--this.indent}write(e){if(typeof e==`function`){e(this,{execution:`sync`}),e(this,{execution:`async`});return}let t=e.split(`
51
+ Passed callback for '${e}' event is NOT registered.`,t),c(!0);return}l.current++;var n=setTimeout(function(){l.current=0},50);return a(e,t,u),function(){clearTimeout(n),i(e,u)}}},[t,e,u,s,i,a]),st({event:e,eventId:u,isBlocked:s,callback:t})};function jh(e,t){var n,r;if(e===t)return!0;if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return!1;for(var i=0;i<e.length;i++)if(!jh(e[i],t[i]))return!1;return!0}if(MediaStream&&e instanceof MediaStream&&t instanceof MediaStream)return e.id===t.id&&e.active===t.active&&e.getTracks().length===t.getTracks().length&&e.getTracks().every(function(e,n){return jh(e,t.getTracks()[n])});if(MediaStreamTrack&&e instanceof MediaStreamTrack&&t instanceof MediaStreamTrack)return e.id===t.id&&e.kind===t.kind&&e.readyState===t.readyState;if(e instanceof Date&&t instanceof Date)return e.getTime()===t.getTime();if(e instanceof RegExp&&t instanceof RegExp)return e.source===t.source&&e.flags===t.flags;if(e instanceof Set&&t instanceof Set){if(e.size!==t.size)return!1;var a=Array.from(e).sort(),o=Array.from(t).sort();return a.every(function(e,t){return jh(e,o[t])})}if(e instanceof Map&&t instanceof Map){if(e.size!==t.size)return!1;try{for(var s=xh(e.entries()),c=s.next();!c.done;c=s.next()){var l=Sh(c.value,2),u=l[0],d=l[1];if(!t.has(u)||!jh(d,t.get(u)))return!1}}catch(e){n={error:e}}finally{try{c&&!c.done&&(r=s.return)&&r.call(s)}finally{if(n)throw n.error}}return!0}if(_h(e)!==`object`||e===null||_h(t)!==`object`||t===null)return!1;var f=Object.keys(e),p=Object.keys(t);if(f.length!==p.length)return!1;for(var i=0;i<f.length;i++){var u=f[i];if(!Object.prototype.hasOwnProperty.call(t,u)||!jh(e[u],t[u]))return!1}return!0}function Mh(e,t){if(e===t)return!0;if(e.length!==t.length)return!1;for(var n=0;n<e.length;n++){var r=e[n],i=t[n],a=r!==null&&_h(r)===`object`,o=i!==null&&_h(i)===`object`;if(a||o){if(!jh(r,i))return!1}else if(r!==i)return!1}return!0}function Nh(e){return`daily-react-`+e}function Ph(e){var t=new Map,n=new Map;return function(r){if(!t.has(r)){var i=ua(function(t){var i=e.get(r)(t),a=n.get(r);return a!=null&&e.equals(i,a)?a:(n.set(r,i),i)});t.set(r,i)}return t.get(r)}}var Fh=`::`,Ih=`;`,Lh=function(e,t){return e+Fh+t},Rh=function(e,t){return e+Fh+t.join(Ih)},zh=function(e,t){return Vh(Lh(e,t))},Bh=To(function(e){var t=ua([]);return t.debugLabel=Nh(`participant-property-paths-${e}`),t}),Vh=To(function(e){var t=ua(null);return t.debugLabel=Nh(`participant-property-${e}`),t}),Hh=Ph({equals:Mh,get:function(e){return function(t){var n=Sh(e.split(Fh),2),r=n[0];return n[1].split(Ih).map(function(e){return t(zh(r,e))})}}}),Uh=function(e,t){var n,r=So(Array.isArray(t)?Hh(Rh(e,t)):Vh(Lh(e,t)));return st(Array.isArray(t)?t.reduce(function(e,t,n){return e[t]=r[n],e},{}):(n={},n[t]=r,n)),r},Wh=typeof globalThis<`u`?globalThis:typeof window<`u`?window:typeof global<`u`?global:typeof self<`u`?self:{};function Gh(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,`default`)?e.default:e}var Kh,qh;function Jh(){if(qh)return Kh;qh=1;var e=`Expected a function`,t=NaN,n=`[object Symbol]`,r=/^\s+|\s+$/g,i=/^[-+]0x[0-9a-f]+$/i,a=/^0b[01]+$/i,o=/^0o[0-7]+$/i,s=parseInt,c=_h(Wh)==`object`&&Wh&&Wh.Object===Object&&Wh,l=(typeof self>`u`?`undefined`:_h(self))==`object`&&self&&self.Object===Object&&self,u=c||l||Function(`return this`)(),d=Object.prototype.toString,f=Math.max,p=Math.min,m=function(){return u.Date.now()};function h(t,n,r){var i,a,o,s,c,l,u=0,d=!1,h=!1,g=!0;if(typeof t!=`function`)throw TypeError(e);n=b(n)||0,_(r)&&(d=!!r.leading,h=`maxWait`in r,o=h?f(b(r.maxWait)||0,n):o,g=`trailing`in r?!!r.trailing:g);function v(e){var n=i,r=a;return i=a=void 0,u=e,s=t.apply(r,n),s}function y(e){return u=e,c=setTimeout(C,n),d?v(e):s}function x(e){var t=e-l,r=e-u,i=n-t;return h?p(i,o-r):i}function S(e){var t=e-l,r=e-u;return l===void 0||t>=n||t<0||h&&r>=o}function C(){var e=m();if(S(e))return w(e);c=setTimeout(C,x(e))}function w(e){return c=void 0,g&&i?v(e):(i=a=void 0,s)}function T(){c!==void 0&&clearTimeout(c),u=0,i=l=a=c=void 0}function E(){return c===void 0?s:w(m())}function D(){var e=m(),t=S(e);if(i=arguments,a=this,l=e,t){if(c===void 0)return y(l);if(h)return c=setTimeout(C,n),v(l)}return c===void 0&&(c=setTimeout(C,n)),s}return D.cancel=T,D.flush=E,D}function g(t,n,r){var i=!0,a=!0;if(typeof t!=`function`)throw TypeError(e);return _(r)&&(i=`leading`in r?!!r.leading:i,a=`trailing`in r?!!r.trailing:a),h(t,n,{leading:i,maxWait:n,trailing:a})}function _(e){var t=_h(e);return!!e&&(t==`object`||t==`function`)}function v(e){return!!e&&_h(e)==`object`}function y(e){return _h(e)==`symbol`||v(e)&&d.call(e)==n}function b(e){if(typeof e==`number`)return e;if(y(e))return t;if(_(e)){var n=typeof e.valueOf==`function`?e.valueOf():e;e=_(n)?n+``:n}if(typeof e!=`string`)return e===0?e:+e;e=e.replace(r,``);var c=a.test(e);return c||o.test(e)?s(e.slice(2),c?2:8):i.test(e)?t:+e}return Kh=g,Kh}var Yh=Gh(Jh()),Xh=function(e,t,n,r){n===void 0&&(n=500),r===void 0&&(r=!1);var i=I(Eh),a=i.off,o=i.on,s=P(function(){var t;return Array.isArray(e)?e.reduce(function(e,t){return e[t]=r?Oh():Ah(),e},{}):(t={},t[e]=r?Oh():Ah(),t)},[e,r]),c=N([]);G(`call-instance-destroyed`,F(function(){c.current.length=0},[]));var l=P(function(){return Yh(function(){c.current.length!==0&&(t(c.current),c.current.length=0)},n,{trailing:!0})},[t,n]);M(function(){if(e){var t=function(e){c.current.push(e),l()};return Array.isArray(e)?e.forEach(function(e){return o(e,t,s[e])}):o(e,t,s[e]),function(){Array.isArray(e)?e.forEach(function(e){return a(e,s[e])}):a(e,s[e])}}},[l,e,s,a,o]),st({event:e,eventId:s})},Zh=function(e,t,n){if(t===void 0&&(t=``),n===void 0&&(n=new Set),_h(e)!==`object`||e===null||n.has(e))return[t];n.add(e);var r=[];for(var i in e)if(Object.prototype.hasOwnProperty.call(e,i)){var a=t?`${t}.${i}`:i;r.push.apply(r,Ch([a],Sh(Zh(e[i],a,n)),!1))}return n.delete(e),r},Qh=function(e){return Zh(e)},$h=function(e,t){return String(t).split(`.`).filter(function(e){return e.length}).reduce(function(e,t){return e&&e[t]},e)},eg=function(e,t){return t.map(function(t){return $h(e,t)})},tg=ua(null);tg.debugLabel=Nh(`active-id`);var ng=ua(``);ng.debugLabel=Nh(`local-id`);var rg=ua(null);rg.debugLabel=Nh(`local-join-date`);var ig=ua([]);ig.debugLabel=Nh(`participant-ids`);var ag=To(function(e){var t=ua(null);return t.debugLabel=Nh(`participant-${e}`),t}),og=ua([]);og.debugLabel=Nh(`waiting-participants`);var sg=To(function(e){var t=ua({awaitingAccess:{level:`full`},id:e,name:``});return t.debugLabel=Nh(`waiting-participant-${e}`),t}),cg=function(e){var t=e.children,n=Th(),r=Sh(j(!1),2),i=r[0],a=r[1],o=wo(F(function(e,t,n){t(ng,n.local.session_id);var r=Object.values(n);t(ig,r.map(function(e){return e.session_id})),r.forEach(function(e){t(ag(e.session_id),e);var n=Qh(e);t(Bh(e.session_id),n),n.forEach(function(n){var r=Sh(eg(e,[n]),1)[0];t(zh(e.session_id,n),r)})}),a(!0)},[]));M(function(){if(!(!n||i)){var e=setInterval(function(){var t=n.participants();`local`in t&&(o(t),clearInterval(e))},100);return function(){clearInterval(e)}}},[n,i,o]);var s=F(function(){if(n){var e=n?.participants();e.local&&o(e)}},[n,o]);G(`started-camera`,s,!0),G(`access-state-updated`,s,!0),G(`joining-meeting`,wo(F(function(e,t){t(rg,new Date),s()},[s])),!0),G(`joined-meeting`,F(function(e){o(e.participants)},[o]),!0);var c=wo(F(function(e,t){t(ng,``),t(tg,null),e(ig).forEach(function(e){return ag.remove(e)}),t(ig,[])},[]));return G(`call-instance-destroyed`,c,!0),G(`left-meeting`,c,!0),Xh([`active-speaker-change`,`participant-joined`,`participant-updated`,`participant-left`],wo(F(function(e,t,n){n.length&&n.forEach(function(n){switch(n.action){case`active-speaker-change`:t(tg,n.activeSpeaker.peerId),t(ag(n.activeSpeaker.peerId),function(e){return e?W(W({},e),{last_active:new Date}):null});break;case`participant-joined`:t(ig,function(e){return e.includes(n.participant.session_id)?e:Ch(Ch([],Sh(e),!1),[n.participant.session_id],!1)}),t(ag(n.participant.session_id),n.participant);var r=Qh(n.participant);t(Bh(n.participant.session_id),r),r.forEach(function(e){var r=Sh(eg(n.participant,[e]),1)[0];t(zh(n.participant.session_id,e),r)});break;case`participant-updated`:t(ag(n.participant.session_id),n.participant),n.participant.local&&t(ng,n.participant.session_id);var r=Qh(n.participant),i=e(Bh(n.participant.session_id));(r.length!==i.length||r.some(function(e){return!i.includes(e)}))&&t(Bh(n.participant.session_id),r);var a=new Set(i),o=eg(n.participant,r);r.forEach(function(e,r){var i=o[r];a.delete(e),t(zh(n.participant.session_id,e),function(e){return jh(e,i)?e:i})}),a.forEach(function(e){t(zh(n.participant.session_id,e),null)});break;case`participant-left`:t(ig,function(e){return e.includes(n.participant.session_id)?e.filter(function(e){return e!==n.participant.session_id}):e}),ag.remove(n.participant.session_id),e(Bh(n.participant.session_id)).forEach(function(e){Vh.remove(Lh(n.participant.session_id,e))}),Bh.remove(n.participant.session_id);break}})},[])),100,!0),Xh([`waiting-participant-added`,`waiting-participant-updated`,`waiting-participant-removed`],wo(F(function(e,t,n){n.forEach(function(e){switch(e.action){case`waiting-participant-added`:t(og,function(t){return t.includes(e.participant.id)?t:Ch(Ch([],Sh(t),!1),[e.participant.id],!1)}),t(sg(e.participant.id),e.participant);break;case`waiting-participant-updated`:t(sg(e.participant.id),e.participant);break;case`waiting-participant-removed`:t(og,function(t){return t.filter(function(t){return t!==e.participant.id})}),sg.remove(e.participant.id);break}})},[])),100,!0),po.createElement(po.Fragment,null,t)},lg=function(){var e=So(ng);return st(e),e},ug=function(){return!0},dg=function(e){var t=e===void 0?{}:e,n=t.filter,r=n===void 0?ug:n,i=t.ignoreLocal,a=i===void 0?!1:i,o=lg(),s=So(tg),c=a&&s===o,l=!r?.(s),u=Sh(j(!c&&!l?s:null),2),d=u[0],f=u[1];return M(function(){c||l||f(s)},[l,c,s]),st(d),d},fg=function(e){return[`blocked`,`off`].includes(e)},pg=`;`,mg=function(e,t){return`${e}${pg}${t}`},hg=Ph({equals:jh,get:function(e){return function(t){var n=Sh(e.split(pg),2),r=n[0],i=n[1];return t(ig).filter(function(e){switch(r){case`local`:case`owner`:case`record`:return t(zh(e,r));case`remote`:return!t(zh(e,`local`));case`screen`:var n=t(zh(e,`tracks.screenAudio.state`)),i=t(zh(e,`tracks.screenVideo.state`));return!fg(n)||!fg(i);default:return!0}}).sort(function(e,n){switch(i){case`joined_at`:case`session_id`:case`user_id`:case`user_name`:var r=t(zh(e,i)),a=t(zh(n,i));if(r!==void 0||a!==void 0){if(r===void 0)return-1;if(a===void 0||r>a)return 1;if(r<a)return-1}return 0;default:return 0}})}}}),gg=function(e){var t=e===void 0?{}:e,n=t.filter,r=t.onActiveSpeakerChange,i=t.onParticipantJoined,a=t.onParticipantLeft,o=t.onParticipantUpdated,s=t.sort,c=So(hg(mg(typeof n==`string`?n:null,typeof s==`string`?s:null))),l=typeof n==`function`||typeof s==`function`,u=F(function(e){return typeof n!=`function`&&typeof s!=`function`?[]:c.map(function(t){return e(ag(t))}).filter(function(e){return!!e}).filter(typeof n==`function`?n:function(){return!0}).sort(typeof s==`function`?s:function(){return 0}).map(function(e){return e.session_id}).filter(Boolean)},[n,c,s]),d=Sh(j([]),2),f=d[0],p=d[1],m=wo(F(function(e){if(l){var t=u(e);jh(t,f)||p(t)}},[f,u,l]));M(function(){m()},[m]),Xh([`participant-joined`,`participant-updated`,`active-speaker-change`,`participant-left`],F(function(e){e.length&&(e.forEach(function(e){switch(e.action){case`participant-joined`:i?.(e);break;case`participant-updated`:o?.(e);break;case`active-speaker-change`:r?.(e);break;case`participant-left`:a?.(e);break}}),m())},[m,r,i,a,o]));var h=typeof n==`function`||typeof s==`function`?f:c;return st(h),h},_g=Ph({equals:Mh,get:function(){return function(e){return e(hg(mg(`screen`,null))).map(function(t){return{local:e(zh(t,`local`)),screenAudio:e(zh(t,`tracks.screenAudio`)),screenVideo:e(zh(t,`tracks.screenVideo`)),screenId:`${t}-screen`,session_id:t}})}}}),vg=function(e){var t=e===void 0?{}:e,n=t.onError,r=t.onLocalScreenShareStarted,i=t.onLocalScreenShareStopped,a=Th(),o=F(function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];a?.startScreenShare.apply(a,Ch([],Sh(e),!1))},[a]),s=F(function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];a?.stopScreenShare.apply(a,Ch([],Sh(e),!1))},[a]);G(`local-screen-share-started`,F(function(){return r?.()},[r])),G(`local-screen-share-stopped`,F(function(){return i?.()},[i])),G(`nonfatal-error`,F(function(e){e.type===`screen-share-error`&&n?.(e)},[n]));var c=So(_g(void 0)),l={isSharingScreen:c.some(function(e){return e.local}),screens:c,startScreenShare:o,stopScreenShare:s};return st(l),l},yg=function(e,t){t===void 0&&(t=`video`);var n=Uh(e,`tracks.${t}`),r=n?W(W({},n),{isOff:fg(n.state)}):{isOff:!0,persistentTrack:void 0,state:`off`,subscribed:!1};return st(r),r};function bg(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return F(function(t){for(var n=0;n<e.length;n++){var r=e[n];typeof r==`function`?r(t):r&&_h(r)===`object`&&(r.current=t)}},e)}var xg=Ea(ka(function(e,t){var n=e.onPlayFailed,r=e.sessionId,i=e.type,a=i===void 0?`audio`:i,o=vh(e,[`onPlayFailed`,`sessionId`,`type`]),s=N(null),c=yg(r,a),l=bg(s,t),u=c?.subscribed;return M(function(){var e=s.current;if(!(!e||!c?.persistentTrack)){if(!MediaStream){console.warn(`MediaStream API not available. Can't setup ${a} for ${r}`),n?.({sessionId:r,target:e,type:a,message:`MediaStream API not available`,name:`MediaStream API not available`});return}var t=function(){e.play().catch(function(t){n?.({sessionId:r,target:e,type:a,message:t.message,name:t.name})})};return e.addEventListener(`loadedmetadata`,t),e.srcObject=new MediaStream([c.persistentTrack]),e.load(),function(){e.removeEventListener(`loadedmetadata`,t)}}},[c?.persistentTrack,n,r,a]),G(`participant-left`,F(function(e){var t=s.current;e.participant.session_id!==r||!t||(t.srcObject=null)},[r])),G(`left-meeting`,F(function(){var e=s.current;e&&(e.pause(),e.srcObject=null)},[])),po.createElement(`audio`,W({autoPlay:!0,ref:l},o,{"data-session-id":r,"data-audio-type":a,"data-subscribed":u}))}));xg.displayName=`DailyAudioTrack`;var Sg=Ea(ka(function(e,t){var n=e.autoSubscribeActiveSpeaker,r=n===void 0?!1:n,i=e.maxSpeakers,a=i===void 0?5:i,o=e.onPlayFailed,s=e.playLocalScreenAudio,c=s===void 0?!1:s,l=Th(),u=Sh(j(Array(a).fill(``)),2),d=u[0],f=u[1],p=vg().screens,m=lg(),h=dg({ignoreLocal:!0}),g=N(null);ot(t,function(){return{getActiveSpeakerAudio:function(){return g.current?.querySelector(`audio[data-session-id="${h}"][data-audio-type="audio"]`)??null},getAllAudio:function(){return Array.from(g.current?.querySelectorAll(`audio`)??[])},getAudioBySessionId:function(e){return g.current?.querySelector(`audio[data-session-id="${e}"][data-audio-type="audio"]`)??null},getRmpAudio:function(){return Array.from(g.current?.querySelectorAll(`audio[data-audio-type="rmpAudio"]`)??[])},getScreenAudio:function(){return Array.from(g.current?.querySelectorAll(`audio[data-audio-type="screenAudio"]`)??[])},getRmpAudioBySessionId:function(e){return g.current?.querySelector(`audio[data-session-id="${e}"][data-audio-type="rmpAudio"]`)??null},getScreenAudioBySessionId:function(e){return g.current?.querySelector(`audio[data-session-id="${e}"][data-audio-type="screenAudio"]`)??null}}},[h]);var _=wo(F(function(e,t,n){return yh(void 0,void 0,void 0,function(){var t,i;return bh(this,function(a){if(t=Object.values(l?.participants()??{}).filter(function(e){return!e.local&&!!e.tracks.audio.subscribed}),i=function(e){return t.some(function(t){return t.session_id===e})},!i(n))if(l&&!l.isDestroyed()&&r&&!l.subscribeToTracksAutomatically())l.updateParticipant(n,{setSubscribedTracks:{audio:!0}});else return[2];return f(function(r){if(r.includes(n))return r;var a=function(e){return!e||!i(e)};if(r.some(a)){var o=r.findIndex(a);return r[o]=n,Ch([],Sh(r),!1)}var s=r.findIndex(function(e){return t.some(function(t){return t.session_id===e&&fg(t.tracks.audio.state)})});if(s>=0)return r[s]=n,Ch([],Sh(r),!1);var c=t.filter(function(e){return r.includes(e.session_id)&&e.session_id!==h}).sort(function(t,n){var r=e(zh(t.session_id,`last_active`))??new Date(`1970-01-01`),i=e(zh(n.session_id,`last_active`))??new Date(`1970-01-01`);return r>i?1:r<i?-1:0});if(!c.length){var l=r.findIndex(function(e){return e!==h});return r[l]=n,Ch([],Sh(r),!1)}var u=r.indexOf(c[0]?.session_id);return r[u]=n,Ch([],Sh(r),!1)}),[2]})})},[h,r,l])),v=F(function(e){f(function(t){if(!t.includes(e))return t;var n=Ch([],Sh(t),!1),r=n.indexOf(e);return n[r]=``,n})},[]);Xh([`active-speaker-change`,`track-started`,`participant-left`],F(function(e){e.forEach(function(e){switch(e.action){case`active-speaker-change`:if(e.activeSpeaker.peerId===m)return;_(e.activeSpeaker.peerId);break;case`track-started`:e.track.kind===`audio`&&e.participant&&!e.participant.local&&_(e.participant.session_id);break;case`participant-left`:v(e.participant.session_id);break}})},[_,m,v]),200);var y=gg({filter:F(function(e){return!!e?.tracks?.rmpAudio},[])});return po.createElement(`div`,{ref:g},d.map(function(e,t){return po.createElement(xg,{key:`speaker-slot-${t}`,onPlayFailed:o,sessionId:e,type:`audio`})}),p.filter(function(e){return c?!0:!e.local}).map(function(e){return po.createElement(xg,{key:e.screenId,onPlayFailed:o,sessionId:e.session_id,type:`screenAudio`})}),y.map(function(e){return po.createElement(xg,{key:`${e}-rmp`,onPlayFailed:o,sessionId:e,type:`rmpAudio`})}))}));Sg.displayName=`DailyAudio`;var Cg=ka(function(e,t){var n=e.automirror,r=e.fit,i=r===void 0?`contain`:r,a=e.mirror,o=e.onResize,s=e.playableStyle,c=s===void 0?{}:s,l=e.sessionId,u=e.style,d=u===void 0?{}:u,f=e.type,p=f===void 0?`video`:f,m=vh(e,[`automirror`,`fit`,`mirror`,`onResize`,`playableStyle`,`sessionId`,`style`,`type`]),h=lg()===l,g=p===`screenVideo`,_=h&&!g,v=N(null),y=bg(v,t),b=yg(l,p),x=b.persistentTrack,S=_||g||!b.isOff,C=Uh(l,`tracks.${p}`)?.subscribed,w=P(function(){if(typeof a==`boolean`)return a;if(!n)return!1;if(!x)return _;var e=x.getSettings();return`facingMode`in e?_&&e.facingMode===`user`:_},[n,_,a,x]);return M(function(){var e=v.current;if(e){var t=function(){var t=e.play();t!==void 0&&t.then(function(){e.controls=!1}).catch(function(t){e.controls=!0,console.warn(`Failed to play video`,t)})},n=function(){e.paused&&t()},r=function(){e.style.transform=`scale(1)`},i=function(){e.style.transform=``,setTimeout(function(){e.paused&&t()},100)},a=function(){document.visibilityState!==`hidden`&&e.paused&&t()};return e.addEventListener(`canplay`,n),e.addEventListener(`enterpictureinpicture`,r),e.addEventListener(`leavepictureinpicture`,i),document.addEventListener(`visibilitychange`,a),function(){e.removeEventListener(`canplay`,n),e.removeEventListener(`enterpictureinpicture`,r),e.removeEventListener(`leavepictureinpicture`,i),document.removeEventListener(`visibilitychange`,a)}}},[]),M(function(){var e=v.current;if(!(!e||!x)){if(!MediaStream){console.warn(`MediaStream API not available. Can't setup ${p} for ${l}`);return}return e.srcObject=new MediaStream([x]),e.load(),function(){e.srcObject=null,e.load()}}},[l,p,x,x?.id]),M(function(){var e=v.current;if(!o||!e)return;var t;function n(){t&&cancelAnimationFrame(t),t=requestAnimationFrame(function(){var e=v.current;if(!(!e||document.hidden)){var t=e.videoWidth,n=e.videoHeight;t&&n&&o?.({aspectRatio:t/n,height:n,width:t})}})}return n(),e.addEventListener(`loadedmetadata`,n),e.addEventListener(`resize`,n),function(){t&&cancelAnimationFrame(t),e.removeEventListener(`loadedmetadata`,n),e.removeEventListener(`resize`,n)}},[o]),po.createElement(`video`,W({autoPlay:!0,muted:!0,playsInline:!0,ref:y,"data-local":h,"data-mirrored":w||void 0,"data-playable":S||void 0,"data-session-id":l,"data-subscribed":C,"data-video-type":p,style:W(W({objectFit:i,transform:w?`scale(-1, 1)`:``},d),S?c:{})},m))});Cg.displayName=`DailyVideo`;var wg=Ae({refreshDevices:function(){return Promise.resolve()}}),Tg=ua(`idle`);Tg.debugLabel=Nh(`camera-state`);var Eg=ua(`idle`);Eg.debugLabel=Nh(`microphone-state`);var Dg=ua([]);Dg.debugLabel=Nh(`camera-devices`);var Og=ua([]);Og.debugLabel=Nh(`microphone-devices`);var kg=ua([]);kg.debugLabel=Nh(`speaker-devices`);var Ag=ua(null);Ag.debugLabel=Nh(`last-camera-error`);var jg=function(e){var t=e.children,n=Th(),r=wo(F(function(e,t){return yh(void 0,void 0,void 0,function(){var e,r,i,a,o,s,c,l,u,d;return bh(this,function(f){switch(f.label){case 0:if((navigator==null?void 0:navigator.mediaDevices)?.getUserMedia===void 0||(navigator==null?void 0:navigator.mediaDevices)?.enumerateDevices===void 0)return t(Tg,`not-supported`),t(Eg,`not-supported`),[2];if(!n)return[2];f.label=1;case 1:return f.trys.push([1,4,,5]),[4,n.enumerateDevices()];case 2:return e=f.sent().devices,r=e.filter(function(e){return e.kind===`videoinput`&&e.deviceId!==``}),i=e.filter(function(e){return e.kind===`audioinput`&&e.deviceId!==``}),a=e.filter(function(e){return e.kind===`audiooutput`&&e.deviceId!==``}),[4,n.getInputDevices()];case 3:return o=f.sent(),s=o.camera,c=o.mic,l=o.speaker,u=function(e,t,n){var r=n.find(function(e){return e.device.deviceId===t.deviceId}),i=`deviceId`in e&&t.deviceId===e.deviceId,a=!(`deviceId`in e)&&r?.selected;return{device:t,selected:i||!!a,state:r?.state??`granted`}},d=function(e,t){return e.device.deviceId==="default"?-1:t.device.deviceId==="default"?1:e.device.label<t.device.label?-1:+(e.device.label>t.device.label)},t(Dg,function(e){return r.filter(Boolean).map(function(t){return u(s,t,e)}).sort(d)}),t(Og,function(e){return i.filter(Boolean).map(function(t){return u(c,t,e)}).sort(d)}),t(kg,function(e){return a.filter(Boolean).map(function(t){return u(l,t,e)}).sort(d)}),[3,5];case 4:return f.sent(),t(Tg,`not-supported`),t(Eg,`not-supported`),[3,5];case 5:return[2]}})})},[n])),i=wo(F(function(e,t){return yh(void 0,void 0,void 0,function(){var i,a,o,s,c,l,u,d,f,p,m,h;return bh(this,function(g){switch(g.label){case 0:if(!n||(i=e(Tg),a=e(Eg),o=n.participants(),!o.local))return[2];if(s=o.local.tracks,c=`prompt`,l=`prompt`,!navigator.permissions)return[3,5];g.label=1;case 1:return g.trys.push([1,4,,5]),[4,navigator.permissions.query({name:`camera`})];case 2:return u=g.sent(),c=u.state,[4,navigator.permissions.query({name:`microphone`})];case 3:return d=g.sent(),l=d.state,[3,5];case 4:return g.sent(),[3,5];case 5:return f=c===`prompt`&&[`idle`,`pending`].includes(i)&&s.video.state===`interrupted`&&!s.video.persistentTrack,p=[`idle`,`pending`].includes(i)&&!s.video.persistentTrack&&!!s.video.off?.byUser,m=l===`prompt`&&[`idle`,`pending`].includes(a)&&s.audio.state===`interrupted`&&!s.audio.persistentTrack,h=[`idle`,`pending`].includes(a)&&!s.audio.persistentTrack&&!!s.audio.off?.byUser,s.audio?.blocked?.byDeviceInUse?(t(Eg,`in-use`),t(Og,function(e){return e.map(function(e){return e.selected?W(W({},e),{state:`in-use`}):e})})):s.audio?.blocked?.byDeviceMissing?t(Eg,`not-found`):s.audio?.blocked?.byPermissions||l===`denied`?t(Eg,`blocked`):m?t(Eg,`pending`):h?t(Eg,`idle`):(t(Eg,`granted`),t(Og,function(e){return e.map(function(e){return e.selected?W(W({},e),{state:`granted`}):e})})),s.video?.blocked?.byDeviceInUse?(t(Tg,`in-use`),t(Dg,function(e){return e.map(function(e){return e.selected?W(W({},e),{state:`in-use`}):e})})):s.video?.blocked?.byDeviceMissing?t(Tg,`not-found`):s.video?.blocked?.byPermissions||c===`denied`?t(Tg,`blocked`):f?t(Tg,`pending`):p?t(Tg,`idle`):(t(Tg,`granted`),t(Dg,function(e){return e.map(function(e){return e.selected?W(W({},e),{state:`granted`}):e})})),r(),[2]}})})},[n,r]));return G(`participant-updated`,F(function(e){e.participant.local&&i()},[i])),G(`available-devices-updated`,r),G(`selected-devices-updated`,r),G(`camera-error`,wo(F(function(e,t,n){switch(t(Ag,n.error),n.error?.type){case`cam-in-use`:t(Tg,`in-use`);break;case`mic-in-use`:t(Eg,`in-use`);break;case`cam-mic-in-use`:t(Tg,`in-use`),t(Eg,`in-use`);break;case`not-found`:n.error?.missingMedia.includes(`video`)&&t(Tg,`not-found`),n.error?.missingMedia.includes(`audio`)&&t(Eg,`not-found`);break;case`permissions`:n.error?.blockedMedia.includes(`video`)&&t(Tg,`blocked`),n.error?.blockedMedia.includes(`audio`)&&t(Eg,`blocked`);break;case`constraints`:n.error?.reason===`invalid`?(t(Tg,`constraints-invalid`),t(Eg,`constraints-invalid`)):n.error?.reason===`none-specified`&&(t(Tg,`constraints-none-specified`),t(Eg,`constraints-none-specified`));break;case`undefined-mediadevices`:t(Tg,`undefined-mediadevices`),t(Eg,`undefined-mediadevices`);break;default:t(Tg,`unknown`),t(Eg,`unknown`);break}},[]))),G(`started-camera`,wo(F(function(e,t){t(Tg,`granted`),t(Eg,`granted`),i()},[i]))),po.createElement(wg.Provider,{value:{refreshDevices:r}},t)};function Mg(e){return e.instanceId??`__default__`}var Ng=ua({});Ng.debugLabel=Nh(`live-streaming-instances`);var Pg=ua(function(e){var t=e(Ng),n=Object.values(t),r=n.filter(function(e){return e.isLiveStreaming}),i=r[0]??n[n.length-1];return{errorMsg:n.find(function(e){return e.errorMsg})?.errorMsg,isLiveStreaming:r.length>0,layout:i?.layout}});Pg.debugLabel=Nh(`live-streaming`);var Fg=function(e){var t=e.children;return G(`live-streaming-started`,wo(F(function(e,t,n){var r=Mg(n);t(Ng,function(e){var t;return W(W({},e),(t={},t[r]={instanceId:r,isLiveStreaming:!0,layout:n?.layout},t))})},[]))),G(`live-streaming-stopped`,wo(F(function(e,t,n){var r=Mg(n);t(Ng,function(e){var t;return e[r]?W(W({},e),(t={},t[r]=W(W({},e[r]),{isLiveStreaming:!1,layout:void 0}),t)):e})},[]))),G(`live-streaming-error`,wo(F(function(e,t,n){var r=Mg(n);t(Ng,function(e){var t;return W(W({},e),(t={},t[r]=W(W({},e[r]??{instanceId:r,isLiveStreaming:!1}),{errorMsg:n.errorMsg}),t))})},[]))),G(`left-meeting`,wo(F(function(e,t){t(Ng,{})},[]))),po.createElement(po.Fragment,null,t)},Ig=ua(`new`);Ig.debugLabel=Nh(`meeting-state`);var Lg=ua(null);Lg.debugLabel=Nh(`meeting-error`);var Rg=ua(null);Rg.debugLabel=Nh(`non-fatal-error`);var zg=ua({data:void 0,topology:`none`});zg.debugLabel=Nh(`meeting-session-data`);var Bg=function(e){var t=e.children,n=Th(),r=wo(F(function(e,t){if(n){var r=n.meetingState();return t(Ig,r),r}},[n]));return G(`loading`,r),G(`loaded`,r),G(`joining-meeting`,r),G(`joined-meeting`,r),G(`left-meeting`,r),G(`error`,wo(F(function(e,t,n){t(Lg,n),r()},[r]))),G(`nonfatal-error`,wo(F(function(e,t,n){t(Rg,n)},[]))),G(`joined-meeting`,wo(F(function(e,t){n&&t(zg,n.meetingSessionState())},[n]))),G(`meeting-session-state-updated`,wo(F(function(e,t,n){t(zg,n.meetingSessionState)},[]))),G(`left-meeting`,wo(F(function(e,t){t(zg,{data:void 0,topology:`none`})},[]))),G(`call-instance-destroyed`,wo(F(function(e,t){t(Ig,`new`),t(Lg,null),t(Rg,null),t(zg,{data:void 0,topology:`none`})},[]))),po.createElement(po.Fragment,null,t)},Vg=ua(`none`);Vg.debugLabel=Nh(`topology`);var Hg=ua(`unknown`),Ug=ua([]),Wg=ua(`interrupted`),Gg=ua(100);Gg.debugLabel=Nh(`network-quality`);var Kg=ua(`good`);Kg.debugLabel=Nh(`network-threshold`);var qg=function(e){var t=e.children,n=Th(),r=So(Vg),i=wo(F(function(e,t){return yh(void 0,void 0,void 0,function(){var e;return bh(this,function(r){switch(r.label){case 0:return n?[4,n.getNetworkTopology()]:[2];case 1:return e=r.sent(),!e||e?.topology===`none`||t(Vg,e.topology),[2]}})})},[n]));return G(`joined-meeting`,i),G(`network-connection`,wo(F(function(e,t,n){switch(t(Wg,n.event),n.event){case`connected`:n.type===`peer-to-peer`&&t(Vg,`peer`),n.type===`sfu`&&t(Vg,`sfu`);break}},[]))),G(`network-quality-change`,wo(F(function(e,t,n){t(Hg,function(e){return e===n.networkState?e:n.networkState}),t(Ug,function(e){var t=n.networkStateReasons??[];return Mh(e,t)?e:t}),t(Gg,function(e){return e===n.quality?e:n.quality}),t(Kg,function(e){return e===n.threshold?e:n.threshold})},[]))),G(`left-meeting`,wo(F(function(e,t){t(Vg,`none`),t(Hg,`unknown`),t(Ug,[]),t(Wg,`interrupted`),t(Gg,100),t(Kg,`good`)},[]))),M(function(){!n||r!==`none`||i()},[n,i,r]),po.createElement(po.Fragment,null,t)};function Jg(e){return e.instanceId?e.instanceId:e.type===`local`||e.local?`__local__`:`__default__`}var Yg=ua({});Yg.debugLabel=Nh(`recording-instances`);var Xg=ua(function(e){var t=e(Yg),n=Object.values(t),r=n.filter(function(e){return e.isRecording}),i=r[0]??n[n.length-1];return{error:n.some(function(e){return e.error}),isLocalParticipantRecorded:n.some(function(e){return e.isLocalParticipantRecorded}),isRecording:r.length>0,layout:i?.layout,local:i?.local,recordingId:i?.recordingId,recordingStartedDate:i?.recordingStartedDate,startedBy:i?.startedBy,type:i?.type}});Xg.debugLabel=Nh(`recording-state`);var Zg=function(e){var t=e.children,n=lg(),r=gg({filter:`record`}),i=wo(F(function(e,t,n,r){var i=e(Yg).__local__,a=W(W({},i),{instanceId:`__local__`,isLocalParticipantRecorded:n,isRecording:n,local:n?r:i?.local,type:n?`local`:i?.type});i&&jh(i,a)||!n&&!i||(n?t(Yg,function(e){return W(W({},e),{__local__:a})}):i&&t(Yg,function(e){return W(W({},e),{__local__:W(W({},i),{isLocalParticipantRecorded:!1,isRecording:!1})})}))},[]));return M(function(){i(r.length>0,r.includes(n||`local`))},[n,i,r]),G(`recording-started`,wo(F(function(e,t,r){var i=Jg(r),a=!0;switch(r.type){case`cloud-audio-only`:case`cloud-beta`:case`cloud`:n&&r.layout?.preset===`single-participant`&&r.layout.session_id!==n&&(a=!1);break}t(Yg,function(e){var t;return W(W({},e),(t={},t[i]={error:!1,instanceId:i,isLocalParticipantRecorded:a,isRecording:!0,layout:r?.layout,local:r?.local,recordingId:r?.recordingId,recordingStartedDate:new Date,startedBy:r?.startedBy,type:r?.type},t))})},[n]))),G(`recording-stopped`,wo(F(function(e,t,n){var r=Jg(n);t(Yg,function(e){var t;return e[r]?W(W({},e),(t={},t[r]=W(W({},e[r]),{isLocalParticipantRecorded:!1,isRecording:!1}),t)):e})},[]))),G(`recording-error`,wo(F(function(e,t,n){var r=Jg(n);t(Yg,function(e){var t,i=e[r];return W(W({},e),(t={},t[r]=W(W({},i??{instanceId:r}),{error:!0,errorMsg:n.errorMsg,isLocalParticipantRecorded:!1,isRecording:!1}),t))})},[]))),G(`left-meeting`,wo(F(function(e,t){t(Yg,{})},[]))),po.createElement(po.Fragment,null,t)},Qg=function(){var e=So(Ig);return st(e),e},$g=ua(null);$g.debugLabel=Nh(`room-state`);var e_=function(e){var t=e.children,n=Th(),r=Qg();return G(`access-state-updated`,wo(F(function(e,t){return yh(void 0,void 0,void 0,function(){var e;return bh(this,function(i){switch(i.label){case 0:return!n||r===`left-meeting`?[2]:[4,n.room()];case 1:return e=i.sent(),e&&`id`in e&&t($g,e),[2,e]}})})},[n,r]))),G(`left-meeting`,wo(F(function(e,t){return function(){t($g,null)}},[]))),po.createElement(po.Fragment,null,t)},t_=ua({isTranscribing:!1,model:`general`,language:`en`,transcriptions:[]});t_.debugLabel=Nh(`transcription-state`);var n_=function(e){var t=e.children;return G(`transcription-started`,wo(F(function(e,t,n){t(t_,{error:!1,transcriptionStartDate:new Date,isTranscribing:!0,transcriptions:[],endpointing:n.endpointing,extra:n.extra,includeRawResponse:n.includeRawResponse,instanceId:n.instanceId,language:n.language,model:n.model,profanity_filter:n.profanity_filter,punctuate:n.punctuate,redact:n.redact,startedBy:n.startedBy,tier:n.tier})},[]))),G(`transcription-stopped`,wo(F(function(e,t,n){t(t_,function(e){return W(W({},e),{updatedBy:n.updatedBy,isTranscribing:!1})})},[]))),G(`transcription-error`,wo(F(function(e,t){t(t_,function(e){return W(W({},e),{error:!0,isTranscribing:!1})})},[]))),G(`left-meeting`,wo(F(function(e,t){t(t_,function(e){return W(W({},e),{isTranscribing:!1})})},[]))),G(`app-message`,wo(F(function(e,t,n){n?.fromId===`transcription`&&t(t_,function(e){return W(W({},e),{isTranscribing:!0,transcriptions:Ch(Ch([],Sh(e.transcriptions),!1),[n.data],!1)})})},[]))),po.createElement(po.Fragment,null,t)},r_=`0.25.3`,i_={strictMode:!0},a_=function(){return!0},o_={options:i_,shouldCreateInstance:a_},s_=function(e,t){var n=t===void 0?o_:t,r=n.parentElRef,i=n.options,a=i===void 0?i_:i,o=n.shouldCreateInstance,s=o===void 0?a_:o,c=Sh(j(null),2),l=c[0],u=c[1],d=N();return M(function(){if(e===`callFrame`&&r?.current===null||!s())return;function t(e){return yh(this,void 0,void 0,function(){return bh(this,function(t){switch(t.label){case 0:return[4,e.destroy()];case 1:return t.sent(),[2]}})})}var n=function(){setTimeout(function(){return u(null)},0)},i=Hm.getCallInstance();if(!l&&i&&!i.isDestroyed()){i.once(`call-instance-destroyed`,n),u(i);return}if(l){jh(d.current,a)||t(l);return}if(!i||i.isDestroyed())try{var o=W(W({},a),{aboutClient:W(W({},a.aboutClient??{}),{"daily-react":r_})});switch(e){case`callFrame`:i=r?.current?Hm.createFrame(r.current,o):Hm.createFrame(o);break;case`callObject`:i=Hm.createCallObject(o);break}d.current=a,u(i),i.once(`call-instance-destroyed`,n)}catch(e){if(console.error(`Error creating call instance:`,e),a.strictMode)throw e}},[l,a,r,s,e]),l},c_=function(e){return s_(`callObject`,e)},l_=function(e){var t=e.children,n=e.jotaiStore,r=vh(e,[`children`,`jotaiStore`]),i=N({}),a=F(function(e){var t,n;if(`action`in e){var r=e.action,a=Array.from(i.current?.[r]??[]),o=a.filter(function(e){return Sh(e,1)[0]<0}),s=a.filter(function(e){return Sh(e,1)[0]>0}),c=Ch(Ch([],Sh(o),!1),Sh(s),!1);try{for(var l=xh(c),u=l.next();!u.done;u=l.next()){var d=Sh(u.value,2)[1];d(e)}}catch(e){t={error:e}}finally{try{u&&!u.done&&(n=l.return)&&n.call(l)}finally{if(t)throw t.error}}}},[]),o=F(function(e){e&&Object.keys(i.current).forEach(function(t){e.off(t,a),e.isDestroyed()||e.on(t,a)})},[a]),s=`callObject`in r?r.callObject:null,c=c_({options:P(function(){return`callObject`in r?{}:r},[r]),shouldCreateInstance:F(function(){return!(`callObject`in r)},[r])}),l=s??c;M(function(){l&&o(l)},[l,o]);var u=F(function(e,t,n){var r;i.current[e]||(i.current[e]=new Map,l&&(l.off(e,a),l.isDestroyed()||l.on(e,a))),i.current[e]?.has(n)||(r=i.current[e])==null||r.set(n,t)},[l,a]),d=F(function(e,t){var n;(n=i.current[e])==null||n.delete(t),i.current[e]?.size===0&&(l?.off(e,a),delete i.current[e])},[l,a]);return po.createElement(go,{store:n},po.createElement(wh.Provider,{value:l},po.createElement(Eh.Provider,{value:{on:u,off:d}},po.createElement(e_,null,po.createElement(Bg,null,po.createElement(qg,null,po.createElement(cg,null,po.createElement(Zg,null,po.createElement(Fg,null,po.createElement(n_,null,po.createElement(jg,null,t)))))))))))},u_=function(e){var t=(e===void 0?{}:e).onAppMessage,n=Th(),r=F(function(e,t){t===void 0&&(t=`*`),n&&n.sendAppMessage(e,t)},[n]);return G(`app-message`,F(function(e){t?.(e,r)},[t,r])),r},d_=function(e,t,n,r){var i=Th(),a=e===lg();G(`local-audio-level`,F(function(e){a&&t(e.audioLevel)},[t,a])),G(`remote-participants-audio-level`,F(function(n){a||t(n.participantsAudioLevel[e])},[t,e,a])),M(function(){if(!(!i||i.isDestroyed()||!a)&&!i.isLocalAudioLevelObserverRunning())try{i.startLocalAudioLevelObserver(r)}catch{n?.(`Local audio level observer not supported in this browser`)}},[i,n,r,a]),M(function(){!i||i.isDestroyed()||a||i.isRemoteParticipantsAudioLevelObserverRunning()||i.startRemoteParticipantsAudioLevelObserver(r)},[i,r,a])},f_=function(e){return yg(e,`audio`)},p_,m_;function h_(){return m_?p_:(m_=1,p_=function e(t,n){if(t===n)return!0;if(t&&n&&_h(t)==`object`&&_h(n)==`object`){if(t.constructor!==n.constructor)return!1;var r,i,a;if(Array.isArray(t)){if(r=t.length,r!=n.length)return!1;for(i=r;i--!==0;)if(!e(t[i],n[i]))return!1;return!0}if(t.constructor===RegExp)return t.source===n.source&&t.flags===n.flags;if(t.valueOf!==Object.prototype.valueOf)return t.valueOf()===n.valueOf();if(t.toString!==Object.prototype.toString)return t.toString()===n.toString();if(a=Object.keys(t),r=a.length,r!==Object.keys(n).length)return!1;for(i=r;i--!==0;)if(!Object.prototype.hasOwnProperty.call(n,a[i]))return!1;for(i=r;i--!==0;){var o=a[i];if(!e(t[o],n[o]))return!1}return!0}return t!==t&&n!==n},p_)}h_();var g_=ua({state:`low`,reason:`none`});g_.debugLabel=Nh(`cpu-load`);var __=function(){var e=Th(),t=So(Tg),n=So(Eg),r=So(Dg),i=So(Og),a=So(kg),o=So(Ag),s=I(wg).refreshDevices,c=F(function(t){return yh(void 0,void 0,void 0,function(){return bh(this,function(n){switch(n.label){case 0:return[4,e?.setInputDevicesAsync({audioDeviceId:null,videoDeviceId:t})];case 1:return n.sent(),[2]}})})},[e]),l=F(function(t){return yh(void 0,void 0,void 0,function(){return bh(this,function(n){switch(n.label){case 0:return[4,e?.setInputDevicesAsync({audioDeviceId:t,videoDeviceId:null})];case 1:return n.sent(),[2]}})})},[e]),u=F(function(t){return yh(void 0,void 0,void 0,function(){return bh(this,function(n){switch(n.label){case 0:return[4,e?.setOutputDeviceAsync({outputDeviceId:t})];case 1:return n.sent(),[2]}})})},[e]),d=[`blocked`,`in-use`,`not-found`,`constraints-invalid`,`constraints-none-specified`,`undefined-mediadevices`,`unknown`],f={cameraError:o,cameras:r,camState:t,currentCam:r.find(function(e){return e.selected}),currentMic:i.find(function(e){return e.selected}),currentSpeaker:a.find(function(e){return e.selected}),hasCamError:d.includes(t),hasMicError:d.includes(n),microphones:i,micState:n,refreshDevices:s,setCamera:c,setMicrophone:l,setSpeaker:u,speakers:a};return st(f),f},v_=ua(null);v_.debugLabel=Nh(`input-settings`);var y_=ua({hidden:0,present:0});y_.debugLabel=Nh(`participant-counts`);var b_=To(function(e){var t=ua({},function(t,n,r){n(b_(e),r)});return t.debugLabel=Nh(`participant-receive-settings-${e}`),t}),x_=function(e){return yg(e,`screenVideo`)},S_=ua(null);S_.debugLabel=Nh(`send-settings`);var C_=function(e){return yg(e,`video`)};function w_({children:e}){return L(l_,{children:e})}var T_=Ae(null),E_=`tavus:memory-user-id:`,D_=new Map;function O_(e){return`${E_}${e}`}function k_(){return typeof crypto<`u`&&typeof crypto.randomUUID==`function`?crypto.randomUUID():`${Date.now().toString(36)}-${Math.random().toString(36).slice(2,10)}`}function A_(e){if(!e)return``;let t=O_(e);try{let e=window.localStorage.getItem(t);if(e)return e;let n=k_();return window.localStorage.setItem(t,n),n}catch{}let n=D_.get(t);if(n)return n;let r=k_();return D_.set(t,r),r}var j_=`tavus:terms-accepted:`;function M_(e){let t=5381;for(let n=0;n<e.length;n++)t=(t*33^e.charCodeAt(n))>>>0;return t.toString(36)}function N_(e,t){return`${j_}${e}:${M_(t)}`}function P_(e,t){if(!e||!t)return!1;try{return globalThis.localStorage?.getItem(N_(e,t))===`1`}catch{return!1}}function F_(e,t){if(!(!e||!t))try{globalThis.localStorage?.setItem(N_(e,t),`1`)}catch{}}var I_=null;function L_(e,t){!e||!t||(I_={deploymentId:e,content:t})}function R_(){I_&&=(F_(I_.deploymentId,I_.content),null)}function z_(e){return e===`user`?`user`:e===`pal`?`replica`:null}function B_(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function V_(e){if(!B_(e)||e.message_type!==`conversation`||typeof e.event_type!=`string`||!B_(e.properties))return null;if(e.event_type===`conversation.utterance`){let t=e.properties;if(typeof t.speech!=`string`)return null;let n=z_(t.role);return n?{kind:`chat-message`,sender:n===`user`?`user`:`agent`,text:t.speech}:null}if(e.event_type===`conversation.utterance.streaming`){let t=e.properties;if(typeof t.speech!=`string`)return null;let n=z_(t.role);if(!n)return null;let r=t.final===!0||t.is_interrupted===!0;return{kind:`caption-update`,text:t.speech,final:r,role:n}}return null}function H_(e,t){return{message_type:`conversation`,event_type:`conversation.respond`,conversation_id:e,properties:{text:t}}}function U_(e,t){return typeof e[t]==`number`?{[t]:e[t]}:{}}function W_(e){let t=z_(e.role);return!t||typeof e.speech!=`string`?null:{kind:`utterance`,event_type:`conversation.utterance`,properties:{role:t,speech:e.speech,...U_(e,`seq`),...U_(e,`turn_idx`)}}}function G_(e){let t=z_(e.role);return!t||typeof e.speech!=`string`?null:{kind:`utterance.streaming`,event_type:`conversation.utterance.streaming`,properties:{role:t,speech:e.speech,...typeof e.final==`boolean`?{final:e.final}:{},...typeof e.is_interrupted==`boolean`?{is_interrupted:e.is_interrupted}:{},...U_(e,`seq`)}}}function K_(e){return typeof e.name!=`string`||typeof e.arguments!=`string`?null:{kind:`tool_call`,event_type:`conversation.tool_call`,properties:{name:e.name,arguments:e.arguments,...U_(e,`seq`),...U_(e,`turn_idx`)}}}function q_(e){if(typeof e==`string`)return e;try{let t=JSON.stringify(e??{});return typeof t==`string`?t:null}catch{return null}}function J_(e){if(typeof e.name!=`string`)return null;let t=e.modality===`vision`||e.modality===`audio`?e.modality:null;if(!t)return null;let n=q_(e.arguments);return n===null?null:{kind:`perception_tool_call`,event_type:`conversation.perception_tool_call`,properties:{name:e.name,arguments:n,modality:t}}}function Y_(e){return{kind:`perception_analysis`,event_type:`conversation.perception_analysis`,properties:e}}function X_(e,t){return{kind:`speaking`,event_type:t,properties:{...U_(e,`seq`),...U_(e,`turn_idx`)}}}var Z_={"conversation.utterance":W_,"conversation.utterance.streaming":G_,"conversation.tool_call":K_,"conversation.perception_tool_call":J_,"conversation.perception_analysis":Y_,"conversation.replica_started_speaking":X_,"conversation.replica_stopped_speaking":X_,"conversation.user_started_speaking":X_,"conversation.user_stopped_speaking":X_};function Q_(e){if(!B_(e)||e.message_type!==`conversation`||typeof e.event_type!=`string`||!B_(e.properties))return null;let t=Z_[e.event_type];return t?t(e.properties,e.event_type):{kind:`unknown`,event_type:e.event_type,properties:e.properties}}function $_(e,t){return{message_type:`conversation`,event_type:t.event_type,conversation_id:e,properties:t.properties??{}}}function ev(e,t){let n=V_(e);return n?n.kind===`chat-message`?(t.appendChatMessage(n.sender,n.text),!0):(t.setCaption(n.text,n.final,n.role),!0):!1}function tv(e=5e3){let t=[],n=n=>{for(;t.length>0&&n-t[0].ts>e;)t.shift()};return{markSent(e){t.push({text:e,ts:Date.now()})},consumeMatch(e){n(Date.now());let r=t.findIndex(t=>t.text===e);return r===-1?!1:(t.splice(r,1),!0)}}}var nv=wn(`Conversation`),rv=1500;function iv(e,t){if(!t)return e;let n=()=>t.reason??new DOMException(`The operation was aborted`,`AbortError`);return t.aborted?Promise.reject(n()):new Promise((r,i)=>{let a=()=>i(n());t.addEventListener(`abort`,a,{once:!0}),e.then(e=>{t.removeEventListener(`abort`,a),r(e)},e=>{t.removeEventListener(`abort`,a),i(e)})})}var av=Ae(null);function ov({children:e}){return L(w_,{children:L(hv,{children:e})})}function sv(e,t,n){let{role:r,speech:i}=e.properties;if(!(r===`user`&&n.consumeMatch(i)))for(let n of t)n.onUtterance?.({...e.properties})}function cv(e,t){for(let n of t)n.onToolCall?.({...e.properties})}function lv(e,t){for(let n of t)n.onPerception?.(e)}function uv(e,t){let n=e.event_type,r=n.startsWith(`conversation.replica`)?`replica`:`user`,i=n.endsWith(`started_speaking`)?`started`:`stopped`;for(let n of t)n.onSpeakingState?.({who:r,state:i,...e.properties})}function dv(e,t){for(let n of t)n.onMessage?.(e)}function fv(e,t,n){switch(e.kind){case`utterance`:case`utterance.streaming`:sv(e,t,n);return;case`tool_call`:cv(e,t);return;case`perception_tool_call`:case`perception_analysis`:lv(e,t);return;case`speaking`:uv(e,t);return;case`unknown`:dv(e,t);return}}function pv(e,t,n){let r=e;return t&&r?.conversational_context==null&&(r={...r,conversational_context:t}),n&&r?.custom_greeting==null&&(r={...r,custom_greeting:n}),r}function mv(e,t){return t?e instanceof Dn&&e.status===401:!1}function hv({children:e}){let{deploymentId:t,client:n,config:r}=I(Di),{memoryStores:i,conversationalContext:a,customGreeting:o}=I(kt),s=Th(),c=Qg(),l=I(T_),u=P(()=>Yt(`idle`),[]),d=P(()=>Yt(null),[]),f=P(()=>Yt([]),[]),p=P(()=>Yt(``),[]),m=P(()=>Yt(null),[]),h=P(()=>Yt(null),[]),g=P(()=>Yt(null),[]),_=P(()=>Yt(null),[]),v=N(null),y=N(null),b=P(()=>tv(),[]),x=P(()=>new Set,[]),S=P(()=>Yt(`idle`),[]),C=l?.flowSignal??S,w=F(e=>{g.value=e},[g]),T=F(e=>{_.value=e},[_]),[,E]=j(c);M(()=>{E(c),c===`joined-meeting`?(u.value=`connected`,nv.info(`Connected to meeting`)):c===`left-meeting`?(u.value=`ended`,R_(),nv.info(`Left meeting`)):c===`error`&&(h.value=`Meeting error`,u.value=`error`)},[c,u,h]),Cn(()=>{let e=u.value;if(e===`connected`)for(let e of x)e.onConnect?.();else if(e===`ended`||e===`disconnecting`)for(let e of x)e.onDisconnect?.();else if(e===`error`){let e=h.peek()??`Unknown error`;for(let t of x)t.onError?.({code:`CONVERSATION_ERROR`,message:e})}}),Cn(()=>{let e=C.value;for(let t of x)t.onModeChange?.(e)}),u_({onAppMessage:F(e=>{ev(e?.data,{appendChatMessage(e,t){e===`user`&&b.consumeMatch(t)||(f.value=[...f.peek(),{id:crypto.randomUUID(),sender:e,text:t,timestamp:Date.now()}])},setCaption(e,t,n){p.value=e,m.value=n,v.current!==null&&(clearTimeout(v.current),v.current=null),t&&(v.current=setTimeout(()=>{p.value=``,m.value=null,v.current=null},rv))}});let t=Q_(e?.data);t&&fv(t,x,b)},[f,p,m,b,x])}),M(()=>()=>{v.current!==null&&(clearTimeout(v.current),v.current=null)},[]);let D=F(()=>{y.current=null,d.value=null,f.value=[],p.value=``,m.value=null,v.current!==null&&(clearTimeout(v.current),v.current=null),(u.peek()===`ended`||u.peek()===`error`)&&(u.value=`idle`)},[d,u,f,p,m]),ee=F(()=>{let e=d.peek()?.conversationId??null,r=y.current;if(r?.conversationId===e)return r.promise;u.value=`disconnecting`;let i=!1,a=e?An(n,t,e,{keepalive:!0}).catch(e=>{i=!0,nv.error(`End conversation API failed`,e)}):Promise.resolve(),o;try{o=s?.leave()}catch(e){i=!0,nv.error(`Daily leave failed`,e)}let c=Promise.resolve(o).catch(e=>{i=!0,nv.error(`Daily leave failed`,e)}),l=Promise.all([a,c]).then(()=>{u.value=`ended`,i&&y.current?.promise===l&&(y.current=null)});return y.current={conversationId:e,promise:l},l},[n,t,s,d,u]),te=F(async(e,c)=>{let l=null;try{D(),u.value=`connecting`,h.value=null;let f=e,p=g.peek();p&&f?.password==null&&(f={...f,password:p});let m=r.value.customization.conversation.unique_memory_tag===!0;if(!f?.memory_stores){let e=i??(m?[A_(t)]:[]);e.length&&(f={...f,memory_stores:e})}f=pv(f,a,o);let v=_.peek();_.value=null,v&&f?.captcha_token==null&&(f={...f,captcha_token:v});let y=await kn(n,t,f,c);if(l=y.conversation_id,d.value={conversationId:y.conversation_id,conversationName:y.conversation_name,conversationUrl:y.conversation_url,callbackUrl:y.callback_url,createdAt:y.created_at,magicGrid:y.magic_grid===!0},console.info(`[Tavus:Conversation] Conversation created:`,y.conversation_id),c?.signal?.aborted)throw c.signal.reason??new DOMException(`The operation was aborted`,`AbortError`);let b=r.value.customization.conversation.modality===`chat`;await iv(Promise.resolve(s?.join({url:y.conversation_url,...b?{startAudioOff:!0,startVideoOff:!0}:{}})),c?.signal)}catch(e){throw await ee(),l&&(d.value=null),mv(e,r.value.has_password===!0)&&(g.value=null),nv.error(`Start failed`,e),h.value=String(e),u.value=`error`,e}},[n,t,s,u,h,d,g,_,r,i,a,o,D,ee]),ne=F(e=>{if(!s)return;let t=d.peek();if(!t){nv.warn(`sendChat called before session was established; dropping message`);return}b.markSent(e),s.sendAppMessage(H_(t.conversationId,e),`*`),f.value=[...f.peek(),{id:crypto.randomUUID(),sender:`user`,text:e,timestamp:Date.now()}]},[s,f,d,b]),re=F(e=>{if(!s){nv.warn(`sendMessage called before Daily was ready; dropping message`);return}let t=d.peek();if(!t){nv.warn(`sendMessage called before session was established; dropping message`);return}e.event_type===`conversation.respond`&&b.markSent(e.properties.text),s.sendAppMessage($_(t.conversationId,e),`*`)},[s,d,b]),O=F(e=>{x.add(e)},[x]),ie=F(e=>{x.delete(e)},[x]),ae=P(()=>({state:u,session:d,chatMessages:f,captionText:p,captionRole:m,error:h,password:g,setPassword:w,captchaToken:_,setCaptchaToken:T,mode:C,start:te,end:ee,sendChat:ne,sendMessage:re,conversation:{start:te,end:ee,sendMessage:re},__registerSubscriber:O,__unregisterSubscriber:ie,__beginAttempt:D}),[u,d,f,p,m,h,g,w,_,T,C,te,ee,ne,re,O,ie,D]);return L(av.Provider,{value:ae,children:e})}var gv=wn(`CaptchaChallenge`),_v=new Set([`110600`,`110620`,`200500`]);function vv(e){return e.startsWith(`3`)||e.startsWith(`6`)||_v.has(e)}function yv(e){return typeof e==`object`&&!!e&&e.source===`tavus-captcha`&&typeof e.type==`string`}function bv(e,t,n,r,i){return`${e.replace(/\/+$/,``)}${t.startsWith(`/`)?t:`/${t}`}?deployment_uuid=${encodeURIComponent(n)}&action=${encodeURIComponent(r)}&parent_origin=${encodeURIComponent(i)}`}function xv({captcha:e,deploymentId:t,onToken:n,onFallback:r,onInteractive:i,presented:a=!0}){let o=(I(kt).baseUrl??`https://tavusapi.com`).replace(/\/+$/,``),s=new URL(o).origin,[c,l]=j(0),[u,d]=j(!1),[f,p]=j(!1),m=bv(o,e.challenge_path,t,e.action,window.location.origin),h=F(()=>{p(!1),i?.(!1),l(e=>e+1)},[i]);if(M(()=>{function e(e){if(u||e.origin!==s)return;let a=e.data;if(yv(a)&&a.deployment_uuid===t){if(a.type===`interactive`){p(!0),i?.(!0);return}if(a.type===`token`&&a.token){gv.info(`Captcha token received`),p(!1),i?.(!1),n(a.token);return}if(a.type===`expired`){gv.info(`Captcha token expired, reloading iframe`),h();return}if(a.type===`error`){let e=String(a.code??``);if(gv.warn(`Captcha error received`,e),vv(e)){p(!1),i?.(!1);return}gv.warn(`Captcha error is not retryable, falling back to no-token mode`),d(!0),r()}}}return window.addEventListener(`message`,e),()=>window.removeEventListener(`message`,e)},[s,t,u,n,r,i,h]),u)return null;let g=f&&a;return L(`div`,{class:g?`absolute inset-0 z-50 flex items-center justify-center p-4 bg-black/50 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":!g,children:L(`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`},c)})}var Sv=wn(`Captcha`),Cv=15e3,wv=Ae(null);function Tv({children:e}){let{config:t,deploymentId:n}=I(Di),r=I(av),i=gn(!0),a=gn(null),o=gn(!1),s=gn(0),c=gn(!1),l=gn(!1),u=N([]),d=t.value.captcha??null,f=r?.state.value??`idle`,p=f===`connecting`||f===`connected`,m=d!==null&&!c.value&&!p&&o.value,h=F(e=>{let t=u.current;u.current=[];for(let n of t)n(e)},[]),g=F(()=>{o.value=!1,l.value=!1},[o,l]),_=F(e=>{Sv.warn(e),c.value=!0,g(),h({kind:`unavailable`})},[c,h,g]),v=F(e=>{r?.setCaptchaToken(e)},[r]);Cn(()=>{(r?.captchaToken.value??null)!==null&&g()});let y=F(()=>{_(`Captcha challenge unavailable; not attempting /start without a token`)},[_]),b=F(e=>{l.value=e},[l]),x=F(async e=>(t.peek().captcha??null)===null?{kind:`not-required`}:(r?.captchaToken.peek()??null)===null?(c.peek()&&(c.value=!1,s.value=s.peek()+1),o.value=!0,new Promise(t=>{let n=!1,i,a,o=l.subscribe(e=>{clearTimeout(i),!e&&(i=setTimeout(()=>_(`Captcha mint timed out`),Cv))}),s=r=>{if(n)return;n=!0,clearTimeout(i),o(),e?.removeEventListener(`abort`,c),a?.();let l=u.current.indexOf(s);l!==-1&&u.current.splice(l,1),t(r)},c=()=>{s({kind:`unavailable`}),u.current.length===0&&g()};a=r?.captchaToken.subscribe(e=>{e!==null&&s({kind:`token`})}),u.current.push(s),e?.aborted?c():e?.addEventListener(`abort`,c,{once:!0})})):{kind:`token`},[o,t,r,s,c,_,l,g]),S=P(()=>({ensureToken:x,hostVisible:i,promptSlot:a}),[x,i,a]),C=a.value,w=m&&d?L(xv,{captcha:d,deploymentId:n,presented:i.value,onToken:v,onFallback:y,onInteractive:b},s.value):null;return L(wv.Provider,{value:S,children:[e,C&&w?Ua(w,C):w]})}function Ev(){let e=I(Di);if(!e)throw Error(`useConfig must be used within ConfigProvider`);return e}var Dv=new Set([`network`,`server`,`unavailable`,`busy`,`rate_limited`]);function Ov(e){return e===401||e===403?`forbidden`:e===402?`limit_exceeded`:e===423?`busy`:e===429?`rate_limited`:e===409?`concurrency`:e===503?`unavailable`:e>=500?`server`:`unknown`}function kv(e){if(!e)return;let t=e.get(`Retry-After`);if(!t)return;let n=Number.parseInt(t,10);if(!Number.isNaN(n)&&n>=0)return n;let r=Date.parse(t);if(!Number.isNaN(r)){let e=Math.floor((r-Date.now())/1e3);return e>0?e:0}}function Av(e){if(e instanceof Dn){let t=Ov(e.status);return{kind:t,status:e.status,raw:e.body,retryable:Dv.has(t),retryAfterSec:kv(e.headers)}}return e instanceof TypeError?{kind:`network`,raw:String(e),retryable:!0}:{kind:`unknown`,raw:String(e),retryable:!1}}var jv=new Set([`Captcha token required`,`Captcha verification failed`]);function Mv(e){if(!(e instanceof Dn)||e.status!==403)return null;try{let t=JSON.parse(e.body.trim()).error;return typeof t==`string`?t:null}catch{return null}}function Nv(e){let t=Mv(e);return t!==null&&jv.has(t)}var Pv=`Origin not allowed`;function Fv(e){return Mv(e)===Pv}function Iv(e){return e===`limit_exceeded`?`daily_limit`:e===`forbidden`||e===`concurrency`?null:`busy`}var Lv=`tavus_pudl_`,Rv=3600*48,zv=new Map;function Bv(){let e=new Date;return`${e.getUTCFullYear()}${String(e.getUTCMonth()+1).padStart(2,`0`)}${String(e.getUTCDate()).padStart(2,`0`)}`}function Vv(e){return`${Lv}${e}`}function Hv(e){try{let t=`${Vv(e)}=`,n=document.cookie.split(`; `).find(e=>e.startsWith(t));if(!n)return 0;let[r,i]=decodeURIComponent(n.slice(t.length)).split(`.`);if(r!==Bv())return 0;let a=Number.parseInt(i,10);return Number.isFinite(a)&&a>0?a:0}catch{return 0}}function Uv(e,t){try{let n=encodeURIComponent(`${Bv()}.${t}`);document.cookie=`${Vv(e)}=${n}; max-age=${Rv}; path=/; SameSite=Lax`}catch{return}}function Wv(e){let t=zv.get(e);return t||(t=Yt(e?Hv(e):0),zv.set(e,t)),t}function Gv(e){if(!e)return;Uv(e,Hv(e)+1);let t=Hv(e),n=zv.get(e);n?n.value=t:zv.set(e,Yt(t))}function Kv(e){switch(e){case`blocked`:return`blocked`;case`in-use`:return`in-use`;case`not-found`:return`not-found`;case`not-supported`:case`undefined-mediadevices`:return`unsupported`;default:return null}}function qv(e,t,n,r){return e===`granted`&&r?`granted`:Kv(e)||(t===`denied`?`blocked`:t===`prompt`?e===`granted`&&n?`granted`:`prompt`:t===`granted`?n?`checking`:`prompt`:e===`granted`?`granted`:n?`checking`:`prompt`)}function Jv(e,t){let n=e===`granted`,r=e===`blocked`||e===`in-use`||e===`not-found`||e===`unsupported`;return{status:e,isGranted:n,isBlocked:r,canRequest:e===`prompt`,needsAttention:r||e===`prompt`&&t!==`granted`}}function Yv(e){let[t,n]=j(null);return M(()=>{let t=!1,r=navigator.permissions;if(r?.query)return r.query({name:e}).then(e=>{t||(n(e.state),e.onchange=()=>{t||n(e.state)})}).catch(()=>{}),()=>{t=!0}},[e]),t}function Xv(){let e=Th(),t=Qg(),n=lg(),{micState:r,camState:i,currentMic:a,currentCam:o}=__(),s=Yv(`microphone`),c=Yv(`camera`),l=t===`joined-meeting`||!!n,[u,d]=j(!1),[f,p]=j(!1),m=F(()=>{e&&(d(!0),l?e.setLocalAudio(!0):Promise.resolve(e.startCamera({videoSource:!1})).catch(()=>{}))},[e,l]),h=F(async()=>{if(e){p(!0);try{await e.setInputDevicesAsync({videoSource:!0})}catch{}e.setLocalVideo(!0)}},[e]);return{mic:P(()=>Jv(qv(r,s,u,!!a),s),[r,s,u,a]),camera:P(()=>Jv(qv(i,c,f,!!o),c),[i,c,f,o]),requestMic:m,requestCamera:h}}var Zv=wn(`Flow`),Qv=[`idle`,`unavailable`,`ended`];function $v({children:e}){let{config:t}=Ev(),{start:n,end:r,session:i,state:a,__beginAttempt:o}=I(av),s=t.value.deployment_id??``,c=Wv(s),l=F(()=>{let e=t.value,n=e.limits?.daily_call_limit_per_user;return n==null||e.channel!==`widget`&&e.channel!==`embed`?null:n},[t]),u=I(wv),[d,f]=j(`idle`),[p,m]=j(!1),[h,g]=j(null),[_,v]=j(null),[y,b]=j(!1),{mic:x,camera:S,requestMic:C,requestCamera:w}=Xv(),T=P(()=>Yt(`idle`),[]);M(()=>{T.value=d},[d,T]),Cn(()=>{let e=t.value,n=e.limits?.daily_call_limit_per_user;n!=null&&(e.channel!==`widget`&&e.channel!==`embed`||T.value===`idle`&&c.value>=n&&(v(`daily_limit`),b(!1),f(`unavailable`)))});let E=t.value.customization.show_haircheck,D=t.value.customization.conversation.modality,ee=E&&D!==`chat`,te=!E&&D!==`chat`,ne=N(!1),re=N(!1),O=N(null),ie=N(null),ae=F(async(e=new AbortController)=>{ie.current=e;let{signal:r}=e;m(!0);try{let e=await u?.ensureToken(r)??{kind:`not-required`};if(r.aborted)return;if(e.kind===`unavailable`){v(`error`),b(!0),f(`unavailable`);return}if(await n(void 0,{signal:r}),r.aborted)return;ne.current=!1,l()!=null&&Gv(s),f(`call`)}catch(e){if(r.aborted)return;let n=Av(e);if(Nv(e)&&!ne.current){ne.current=!0,m(!1),f(`idle`);return}if(ne.current=!1,Fv(e)){Zv.error(`/start rejected: origin ${window.location.origin} is not on this deployment's allowed-origins list. Add it in the Tavus portal.`),v(`error`),b(!1),f(`unavailable`);return}if(n.status===401&&t.value.has_password===!0){f(`idle`);return}let i=Iv(n.kind)??`busy`;v(i),b(n.retryable),f(`unavailable`)}finally{ie.current===e&&(ie.current=null),m(!1)}},[n,t,l,s,u]),k=F(async()=>{let e=O.current;if(e){g(null);try{await ae(e.controller)}finally{O.current===e&&(O.current=null),e.resolve()}}},[ae]),A=F(()=>{let e=O.current;if(!(!e||e.proceeding)){if(e.proceeding=!0,D===`video`&&!S.isGranted&&!S.isBlocked){g({kind:`camera`,status:S.status}),w().finally(()=>{k()});return}k()}},[D,S,w,k]);M(()=>{if(!(!O.current||h?.kind!==`microphone`)){if(h.status!==x.status&&g({kind:`microphone`,status:x.status}),x.isGranted){A();return}if(x.isBlocked){let e=O.current;O.current=null,m(!1),e.resolve()}}},[h,x,A]);let oe=F(()=>{if(O.current)return O.current.promise;let e,t=new Promise(t=>{e=t});return O.current={promise:t,resolve:e,proceeding:!1,controller:new AbortController},m(!0),x.isGranted?A():x.isBlocked?(g({kind:`microphone`,status:x.status}),O.current=null,m(!1),e()):(g({kind:`microphone`,status:x.status}),C()),t},[x,C,A]),se=F(async()=>{if(!Qv.includes(d))return;let e=l();if(e!=null&&c.value>=e){v(`daily_limit`),b(!1),f(`unavailable`);return}if(o(),ee&&!re.current){f(`haircheck`);return}return te?oe():ae()},[d,ee,te,oe,ae,l,c,o]),ce=F(async()=>{d===`haircheck`&&(re.current=!0,await ae())},[d,ae]),le=F(()=>{let e=O.current,t=e?.controller??ie.current;e&&(O.current=null,e.resolve(),g(null)),t?.abort(),t&&m(!1),d===`haircheck`&&f(`idle`)},[d]),ue=F(()=>{d===`call`&&f(`ended`)},[d]);M(()=>{let e=()=>{let e=O.current!==null||ie.current!==null,t=d===`haircheck`||d===`call`,n=i.peek()!==null,o=n&&a.peek()!==`ended`;!e&&!t&&!n||(le(),(d===`call`||o)&&f(`ended`),r())};return window.addEventListener(`pagehide`,e),()=>window.removeEventListener(`pagehide`,e)},[d,i,a,le,r]);let de=F(()=>{v(null),b(!1),f(`idle`)},[]),fe=P(()=>({flowSignal:T,setFlowState:f,isStarting:p,permissionRequest:h,unavailableCause:_,canRetry:y,start:se,join:ce,cancel:le,leave:ue,restart:de}),[T,p,h,_,y,se,ce,le,ue,de]);return L(T_.Provider,{value:fe,children:e})}var ey=wn(`HostBridge`),ty=Ae(null);function ny(e){if(!e)return null;let t=e.getRootNode();return t instanceof ShadowRoot&&t.host instanceof HTMLElement?t.host:e.parentElement}function ry({children:e}){let t=I(av),n=I(Di),r=I(T_),i=I(kt),a=gn(null),o=i?.overrideConfig,s=F(e=>{a.value=ny(e)},[a]),c=F((e,t)=>{let n=a.peek();n&&n.dispatchEvent(new CustomEvent(e,{detail:t,bubbles:!0,composed:!0})),ey.info(`Event:`,e,t)},[a]);M(()=>{let e=a.value;if(!e)return;let n={tavus:{start:t.start,end:t.end,sendChat:t.sendChat,sendMessage:t.sendMessage},startConversation:async()=>{try{r?await r.start():await t.start()}catch(e){ey.error(`startConversation failed`,e)}},endConversation:async()=>{try{let e=r?.flowSignal.peek();e===`call`?r?.leave():e===`haircheck`?r?.cancel():t.session.peek()&&await t.end()}catch(e){ey.error(`endConversation failed`,e)}},sendMessage:e=>{t.sendMessage(typeof e==`string`?{event_type:`conversation.respond`,properties:{text:e}}:e)},updateConfig:t=>{let n=Nn(o??{},t);e.setAttribute(`override-config`,JSON.stringify(n))},destroy:()=>{t.session.peek()&&t.end(),e.remove()}};return Object.assign(e,n),()=>{for(let t of Object.keys(n))delete e[t]}},[a.value,t,r,o]);let l=N(!1);M(()=>{l.current||!a.value||!n||(l.current=!0,c(`tavus:ready`,{deploymentId:n.deploymentId}))},[a.value,n,c]);let u=N(null);M(()=>t.state.subscribe(e=>{if(e!==u.current)switch(u.current=e,e){case`connected`:c(`tavus:conversation-started`,{conversationId:t.session.peek()?.conversationId??``}),c(`tavus:state-change`,{state:e});break;case`ended`:c(`tavus:conversation-ended`,{conversationId:t.session.peek()?.conversationId??``}),c(`tavus:state-change`,{state:e});break;case`error`:c(`tavus:error`,{code:`CONVERSATION_ERROR`,message:t.error.peek()??`Unknown error`}),c(`tavus:state-change`,{state:e});break;default:c(`tavus:state-change`,{state:e})}}),[t,c]),Cn(()=>{if(!r)return;let e=r.flowSignal.value;c(`tavus:mode-change`,{mode:e})}),M(()=>{let e={onUtterance(e){c(`tavus:protocol-message`,{kind:`utterance`,event_type:`conversation.utterance`,properties:e})},onToolCall(e){c(`tavus:tool-call`,e),c(`tavus:protocol-message`,{kind:`tool_call`,event_type:`conversation.tool_call`,properties:e})},onPerception(e){c(`tavus:protocol-message`,e)},onSpeakingState({who:e,state:t,seq:n,turn_idx:r}){let i={state:t,...n===void 0?{}:{seq:n},...r===void 0?{}:{turn_idx:r}};c(`tavus:protocol-message`,{kind:`speaking`,event_type:e===`replica`?t===`started`?`conversation.replica_started_speaking`:`conversation.replica_stopped_speaking`:t===`started`?`conversation.user_started_speaking`:`conversation.user_stopped_speaking`,properties:i})},onMessage(e){c(`tavus:protocol-message`,e)}};return t.__registerSubscriber(e),()=>t.__unregisterSubscriber(e)},[t,c]);let d=P(()=>({shadowHost:a,dispatchEvent:c}),[a,c]);return L(ty.Provider,{value:d,children:[L(`div`,{ref:s,style:`display:contents`}),e]})}var iy=Ae(null);function ay({children:e}){let{config:t}=I(Di),n=P(()=>en(()=>{let e=t.value.customization.style;return e.mode===`dark`||e.mode===`system`&&(globalThis.matchMedia?.(`(prefers-color-scheme: dark)`).matches??!1)}),[t]),r=P(()=>en(()=>{let e=t.value.customization.style;return e.style===`basic`?n.value?`white-black`:`black-white`:n.value?`${e.style}-dark`:e.style}),[t,n]),i=P(()=>en(()=>ly(t.value.customization.style)),[t]),a=P(()=>({dataTheme:r,isDark:n,cssVars:i}),[r,n,i]);return L(iy.Provider,{value:a,children:L(`div`,{"data-theme":r.value,style:uy(i.value),class:`contents`,children:e})})}var oy=[0,.125,.25,.5,.75],sy=[0,1,2,3,4],cy=[0,.2,.25,.3];function ly(e){return{"--radius-box":`${oy[e.boxes_radius]??.5}rem`,"--radius-field":`${oy[e.field_radius]??.25}rem`,"--radius-selector":`${oy[e.selectors_radius]??.5}rem`,"--border":`${sy[e.border_width]??1}px`,"--size-field":`${cy[e.fields_size]??.25}rem`,"--size-selector":`${cy[e.selectors_size]??.25}rem`,"--depth":e.depth_effect?`1`:`0`,"--noise":e.noise_effect?`1`:`0`}}function uy(e){return Object.entries(e).map(([e,t])=>`${e}: ${t}`).join(`; `)}var dy=.5,fy=.01;function py(e,t){if(!gy(e)||!gy(t))return null;let n=e.left-t.left,r=e.top-t.top,i=e.width/t.width,a=e.height/t.height;return Math.abs(n)<dy&&Math.abs(r)<dy&&Math.abs(i-1)<fy&&Math.abs(a-1)<fy?null:`translate(${_y(n)}px, ${_y(r)}px) scale(${_y(i)}, ${_y(a)})`}function my(e){if(e==null)return null;let t=hy(e.width),n=hy(e.height);return t===null&&n===null?null:{width:t,height:n}}function hy(e){return Number.isFinite(e)&&e>0?e:null}function gy(e){return Number.isFinite(e.left)&&Number.isFinite(e.top)&&Number.isFinite(e.width)&&Number.isFinite(e.height)&&e.width>0&&e.height>0}function _y(e){return Math.round(e*1e3)/1e3}function vy(e,t){M(()=>{let n=e.current;if(!n)return;let r=new ResizeObserver(e=>{let n=e[0];n&&t(n)});return r.observe(n),()=>r.disconnect()},[e,t])}var yy=new WeakMap;function by(e){let t=yy.get(e);t?t.holders+=1:yy.set(e,{holders:1,restore:xy(e)});let n=!1;return()=>{if(n)return;n=!0;let t=yy.get(e);t&&(--t.holders,!(t.holders>0)&&(yy.delete(e),t.restore()))}}function xy(e){let{body:t,documentElement:n}=e,r=n.style.overflowX,i=n.style.overflowY,a=t.style.paddingRight,o=n.clientWidth;n.style.overflow=`hidden`;let s=n.clientWidth-o,c=s>0?`${Sy(t)+s}px`:null;return c&&(t.style.paddingRight=c),()=>{n.style.overflow===`hidden`&&(n.style.overflow=``,n.style.overflowX=r,n.style.overflowY=i),c&&t.style.paddingRight===c&&(t.style.paddingRight=a)}}function Sy(e){let t=e.ownerDocument.defaultView?.getComputedStyle(e).paddingRight,n=Number.parseFloat(t??``);return Number.isFinite(n)?n:0}var Cy=Ae(null),wy=480,Ty=768,Ey=`relative w-full h-full`,Dy=`m-0 p-0 border-0 bg-transparent text-inherit max-w-none max-h-none`,Oy=`${Dy} block static w-full h-full`,ky=`${Dy} fixed inset-0 flex items-center justify-center w-screen h-dvh backdrop:bg-black/60 motion-safe:backdrop:animate-[tavusFadeIn_180ms_ease-out]`,Ay=`relative outline-none aspect-[var(--tavus-expand-aspect)] [--tavus-expand-default-max-width:1280px] [--tavus-expand-default-max-height:900px] [@media(min-width:2560px)]:[--tavus-expand-default-max-width:1600px] [@media(min-width:2560px)]:[--tavus-expand-default-max-height:1200px] w-[var(--tavus-expand-width)] h-[var(--tavus-expand-height)] max-w-[var(--tavus-expand-max-width)] max-h-[var(--tavus-expand-max-height)] [@media(max-width:768px)]:w-screen [@media(max-width:768px)]:h-dvh [@media(max-width:768px)]:max-w-none [@media(max-width:768px)]:max-h-none`,jy=280,My=`cubic-bezier(0.22, 1, 0.36, 1)`,Ny={kind:`inline`};function Py(e,t,{isStarting:n=!1,awaitingPermission:r=!1,startWasUnderway:i=!1}={}){return e?t===`haircheck`||t===`call`||n||r?!0:t===`unavailable`&&i:!1}function Fy(e){return typeof e?.showModal==`function`&&typeof e.close==`function`}function Iy(e,t){let n=e.flowSignal.peek(),r=n===`call`,i=r||n===`haircheck`||e.isStarting;e.cancel(),r&&e.leave(),i&&t?.()}function Ly({children:e}){let t=N(null),n=N(null),r=P(()=>Yt(`full`),[]),[i,a]=j(Ny),o=I(kt),s=I(T_),c=I(ty),l=I(wv),u=I(av),d=o?.expandOptions,f=c?.shadowHost.value??null,p=s?.flowSignal.value??`idle`,m=s?.isStarting??!1,h=s?.permissionRequest!=null,g=N(!1);M(()=>{m||p===`haircheck`||p===`call`?g.current=!0:(p===`idle`||p===`ended`)&&(g.current=!1)},[m,p]);let _=Py(d?.enabled===!0,p,{isStarting:m,awaitingPermission:h,startWasUnderway:g.current}),v=i.kind!==`inline`;at(()=>{let e=t.current;if(e)if(i.kind===`inline`){if(!_||!Fy(n.current))return;let t=e.getBoundingClientRect();a({kind:`expanding`,from:t,slot:my(f?.getBoundingClientRect())})}else!_&&i.kind!==`collapsing`?a({kind:`collapsing`,from:e.getBoundingClientRect(),slot:i.slot}):_&&i.kind===`collapsing`&&a({kind:`expanding`,from:e.getBoundingClientRect(),slot:i.slot})},[_,i,f]);let y=i.kind===`inline`?null:i.slot;at(()=>{if(!f||!y)return;let e=f.style.minWidth,t=f.style.minHeight;return y.width!==null&&(f.style.minWidth=`${y.width}px`),y.height!==null&&(f.style.minHeight=`${y.height}px`),()=>{f.style.minWidth=e,f.style.minHeight=t}},[f,y]);let b=F(()=>{s&&Iy(s,u?.end)},[s,u]),x=N(b);x.current=b,at(()=>{let e=n.current;if(!e||!v||!Fy(e))return;let t=()=>{!e.isConnected||e.open||(e.showModal(),x.current())};return e.addEventListener(`close`,t),e.open||e.showModal(),()=>{e.removeEventListener(`close`,t),e.open&&e.close()}},[v]),at(()=>{if(!(!f||!v))return by(f.ownerDocument)},[f,v]),at(()=>{let e=t.current;if(!e||i.kind!==`expanding`&&i.kind!==`collapsing`)return;let n=()=>a(i.kind===`expanding`?{kind:`expanded`,slot:i.slot}:Ny),r=e.getBoundingClientRect(),o=c?.shadowHost.peek()??null,s=i.kind===`expanding`?r:o?.getBoundingClientRect()??r,l=py(i.from,r)??`none`,u=py(s,r)??`none`,d=globalThis.matchMedia?.(`(prefers-reduced-motion: reduce)`).matches??!1;if(l===u||d||typeof e.animate!=`function`){n();return}let f=e.animate([{transform:l,transformOrigin:`top left`},{transform:u,transformOrigin:`top left`}],{duration:jy,easing:My,fill:`forwards`}),p=!1;return f.finished.then(()=>{p||n()},()=>{}),()=>{p=!0,f.cancel()}},[i,c]),at(()=>{let e=n.current;if(!e||!v)return;let t=e=>{e.preventDefault(),x.current()};return e.addEventListener(`cancel`,t),()=>e.removeEventListener(`cancel`,t)},[v]);let S=F(e=>{let t=e.contentRect.width;t<wy?r.value=`compact`:t<Ty?r.value=`medium`:r.value=`full`},[r]);M(()=>{if(l)return l.promptSlot.value=t.current,()=>{l.promptSlot.value=null}},[l,v]),vy(t,S);let C=P(()=>({layoutMode:r,containerRef:t}),[r,t]);return L(Cy.Provider,{value:C,children:L(`dialog`,{ref:n,class:v?ky:Oy,"aria-label":v?`Conversation`:void 0,role:v?void 0:`none`,children:L(`div`,{ref:t,class:v?Ay:Ey,style:v?Et(Tt(d).vars):void 0,tabIndex:v?-1:void 0,autofocus:v,children:e})})})}var Ry=`@container/conversation w-full h-full`,zy=`motion-safe:animate-[tavusFadeUp_280ms_ease-out]`,By=`relative w-full h-full max-h-screen aspect-video @max-mobile:aspect-9/16 overflow-hidden rounded-box`;function Vy({animate:e=!1,innerClassName:t,innerStyle:n,innerRef:r,role:i,"aria-live":a,"aria-label":o,children:s}){return L(`div`,{class:e?`${Ry} ${zy}`:Ry,children:L(`div`,{ref:r,class:t?`${By} ${t}`:By,style:n,role:i,"aria-live":a,"aria-label":o,children:s})})}var Hy=41/2,Uy=23/2,Wy=Math.hypot(Hy,Uy),Gy=Array.from({length:1008},(e,t)=>{let n=t%42,r=Math.floor(t/42),i=Math.hypot(n-Hy,r-Uy)/Wy*.82,a=.34+(n*13+r*7)%34/100;return{delay:`${i.toFixed(3)}s`,opacity:a.toFixed(2)}});function Ky(){return L(Vy,{innerClassName:`embed-loading-screen`,role:`status`,"aria-live":`polite`,"aria-label":`Loading deployment`,children:L(`div`,{class:`embed-loading-dot-field`,"aria-hidden":`true`,style:{"--dot-columns":`42`,"--dot-rows":`24`},children:Gy.map((e,t)=>L(`span`,{class:`embed-loading-field-dot`,style:{"--dot-delay":e.delay,"--dot-opacity":e.opacity}},t))})})}var qy=Ae(null);function Jy({children:e}){let t=N(null);return L(qy.Provider,{value:{frameRef:t},children:L(`div`,{class:`@container/conversation w-full h-full`,children:L(`div`,{ref:t,class:`relative w-full h-full max-h-screen aspect-video @max-mobile:aspect-9/16 overflow-hidden rounded-box bg-base-100 has-[.cvi-video-surface]:will-change-transform`,children:e})})})}var Yy=(...e)=>e.filter((e,t,n)=>!!e&&e.trim()!==``&&n.indexOf(e)===t).join(` `).trim(),Xy=e=>e.replace(/([a-z0-9])([A-Z])/g,`$1-$2`).toLowerCase(),Zy=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,t,n)=>n?n.toUpperCase():t.toLowerCase()),Qy=e=>{let t=Zy(e);return t.charAt(0).toUpperCase()+t.slice(1)},$y={xmlns:`http://www.w3.org/2000/svg`,width:24,height:24,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,"stroke-width":`2`,"stroke-linecap":`round`,"stroke-linejoin":`round`},eb=Ae({size:24,color:`currentColor`,strokeWidth:2,absoluteStrokeWidth:!1,class:``}),tb=()=>I(eb),nb=e=>{for(let t in e)if(t.startsWith(`aria-`)||t===`role`||t===`title`)return!0;return!1},rb=({color:e,size:t,strokeWidth:n,absoluteStrokeWidth:r,children:i,iconNode:a,class:o=``,...s})=>{let{size:c=24,strokeWidth:l=2,absoluteStrokeWidth:u=!1,color:d=`currentColor`,class:f=``}=tb()??{},p=r??u?Number(n??l)*24/Number(t??c):n??l;return O(`svg`,{...$y,width:t??c??24,height:t??c??24,stroke:e??d,"stroke-width":p,class:Yy(`lucide`,f,o),...!i&&!nb(s)&&{"aria-hidden":`true`},...s},[...a.map(([e,t])=>O(e,t)),...me(i)])},ib=(e,t)=>{let n=({class:n=``,className:r=``,children:i,...a})=>O(rb,{...a,iconNode:t,class:Yy(`lucide-${Xy(Qy(e))}`,`lucide-${Xy(e)}`,n,r)},i);return n.displayName=Qy(e),n},ab=ib(`camera-off`,[[`path`,{d:`M14.564 14.558a3 3 0 1 1-4.122-4.121`,key:`1rnrzw`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}],[`path`,{d:`M20 20H4a2 2 0 0 1-2-2V9a2 2 0 0 1 2-2h1.997a2 2 0 0 0 .819-.175`,key:`1x3arw`}],[`path`,{d:`M9.695 4.024A2 2 0 0 1 10.004 4h3.993a2 2 0 0 1 1.76 1.05l.486.9A2 2 0 0 0 18.003 7H20a2 2 0 0 1 2 2v7.344`,key:`1i84u0`}]]),ob=ib(`camera`,[[`path`,{d:`M13.997 4a2 2 0 0 1 1.76 1.05l.486.9A2 2 0 0 0 18.003 7H20a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V9a2 2 0 0 1 2-2h1.997a2 2 0 0 0 1.759-1.048l.489-.904A2 2 0 0 1 10.004 4z`,key:`18u6gg`}],[`circle`,{cx:`12`,cy:`13`,r:`3`,key:`1vg3eu`}]]),sb=ib(`captions`,[[`rect`,{width:`18`,height:`14`,x:`3`,y:`5`,rx:`2`,ry:`2`,key:`12ruh7`}],[`path`,{d:`M7 15h4M15 15h2M7 11h2M13 11h4`,key:`1ueiar`}]]),cb=ib(`clock`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 6v6l4 2`,key:`mmk7yg`}]]),lb=ib(`ellipsis`,[[`circle`,{cx:`12`,cy:`12`,r:`1`,key:`41hilf`}],[`circle`,{cx:`19`,cy:`12`,r:`1`,key:`1wjl8i`}],[`circle`,{cx:`5`,cy:`12`,r:`1`,key:`1pcz8c`}]]),ub=ib(`expand`,[[`path`,{d:`m15 15 6 6`,key:`1s409w`}],[`path`,{d:`m15 9 6-6`,key:`ko1vev`}],[`path`,{d:`M21 16v5h-5`,key:`1ck2sf`}],[`path`,{d:`M21 8V3h-5`,key:`1qoq8a`}],[`path`,{d:`M3 16v5h5`,key:`1t08am`}],[`path`,{d:`m3 21 6-6`,key:`wwnumi`}],[`path`,{d:`M3 8V3h5`,key:`1ln10m`}],[`path`,{d:`M9 9 3 3`,key:`v551iv`}]]),db=ib(`external-link`,[[`path`,{d:`M15 3h6v6`,key:`1q9fwt`}],[`path`,{d:`M10 14 21 3`,key:`gplh6r`}],[`path`,{d:`M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6`,key:`a6xqqp`}]]),fb=ib(`maximize-2`,[[`path`,{d:`M15 3h6v6`,key:`1q9fwt`}],[`path`,{d:`m21 3-7 7`,key:`1l2asr`}],[`path`,{d:`m3 21 7-7`,key:`tjx5ai`}],[`path`,{d:`M9 21H3v-6`,key:`wtvkvv`}]]),pb=ib(`message-circle`,[[`path`,{d:`M2.992 16.342a2 2 0 0 1 .094 1.167l-1.065 3.29a1 1 0 0 0 1.236 1.168l3.413-.998a2 2 0 0 1 1.099.092 10 10 0 1 0-4.777-4.719`,key:`1sd12s`}]]),mb=ib(`mic-off`,[[`path`,{d:`M12 19v3`,key:`npa21l`}],[`path`,{d:`M15 9.34V5a3 3 0 0 0-5.68-1.33`,key:`1gzdoj`}],[`path`,{d:`M16.95 16.95A7 7 0 0 1 5 12v-2`,key:`cqa7eg`}],[`path`,{d:`M18.89 13.23A7 7 0 0 0 19 12v-2`,key:`16hl24`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}],[`path`,{d:`M9 9v3a3 3 0 0 0 5.12 2.12`,key:`r2i35w`}]]),hb=ib(`mic`,[[`path`,{d:`M12 19v3`,key:`npa21l`}],[`path`,{d:`M19 10v2a7 7 0 0 1-14 0v-2`,key:`1vc78b`}],[`rect`,{x:`9`,y:`2`,width:`6`,height:`13`,rx:`3`,key:`s6n7sd`}]]),gb=ib(`minimize-2`,[[`path`,{d:`m14 10 7-7`,key:`oa77jy`}],[`path`,{d:`M20 10h-6V4`,key:`mjg0md`}],[`path`,{d:`m3 21 7-7`,key:`tjx5ai`}],[`path`,{d:`M4 14h6v6`,key:`rmj7iw`}]]),_b=ib(`monitor-up`,[[`path`,{d:`m9 10 3-3 3 3`,key:`11gsxs`}],[`path`,{d:`M12 13V7`,key:`h0r20n`}],[`rect`,{width:`20`,height:`14`,x:`2`,y:`3`,rx:`2`,key:`48i651`}],[`path`,{d:`M12 17v4`,key:`1riwvh`}],[`path`,{d:`M8 21h8`,key:`1ev6f3`}]]),vb=ib(`moon`,[[`path`,{d:`M20.985 12.486a9 9 0 1 1-9.473-9.472c.405-.022.617.46.402.803a6 6 0 0 0 8.268 8.268c.344-.215.825-.004.803.401`,key:`kfwtm`}]]),yb=ib(`phone-off`,[[`path`,{d:`M10.1 13.9a14 14 0 0 0 3.732 2.668 1 1 0 0 0 1.213-.303l.355-.465A2 2 0 0 1 17 15h3a2 2 0 0 1 2 2v3a2 2 0 0 1-2 2 18 18 0 0 1-12.728-5.272`,key:`1wngk7`}],[`path`,{d:`M22 2 2 22`,key:`y4kqgn`}],[`path`,{d:`M4.76 13.582A18 18 0 0 1 2 4a2 2 0 0 1 2-2h3a2 2 0 0 1 2 2v3a2 2 0 0 1-.8 1.6l-.468.351a1 1 0 0 0-.292 1.233 14 14 0 0 0 .244.473`,key:`10hv5p`}]]),bb=ib(`picture-in-picture-2`,[[`path`,{d:`M21 9V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v10c0 1.1.9 2 2 2h4`,key:`daa4of`}],[`rect`,{width:`10`,height:`7`,x:`12`,y:`13`,rx:`2`,key:`1nb8gs`}]]),xb=ib(`send`,[[`path`,{d:`M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z`,key:`1ffxy3`}],[`path`,{d:`m21.854 2.147-10.94 10.939`,key:`12cjpa`}]]),Sb=ib(`shrink`,[[`path`,{d:`m15 15 6 6m-6-6v4.8m0-4.8h4.8`,key:`17vawe`}],[`path`,{d:`M9 19.8V15m0 0H4.2M9 15l-6 6`,key:`chjx8e`}],[`path`,{d:`M15 4.2V9m0 0h4.8M15 9l6-6`,key:`lav6yq`}],[`path`,{d:`M9 4.2V9m0 0H4.2M9 9 3 3`,key:`1pxi2q`}]]),Cb=ib(`smile`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M8 14s1.5 2 4 2 4-2 4-2`,key:`1y1vjs`}],[`line`,{x1:`9`,x2:`9.01`,y1:`9`,y2:`9`,key:`yxxnd0`}],[`line`,{x1:`15`,x2:`15.01`,y1:`9`,y2:`9`,key:`1p4y9e`}]]),wb=ib(`triangle-alert`,[[`path`,{d:`m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3`,key:`wmoenq`}],[`path`,{d:`M12 9v4`,key:`juzpu7`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]]),Tb=ib(`user`,[[`path`,{d:`M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2`,key:`975kel`}],[`circle`,{cx:`12`,cy:`7`,r:`4`,key:`17ys0d`}]]),Eb=ib(`users`,[[`path`,{d:`M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2`,key:`1yyitq`}],[`path`,{d:`M16 3.128a4 4 0 0 1 0 7.744`,key:`16gr8j`}],[`path`,{d:`M22 21v-2a4 4 0 0 0-3-3.87`,key:`kshegd`}],[`circle`,{cx:`9`,cy:`7`,r:`4`,key:`nufk8`}]]),Db=ib(`x`,[[`path`,{d:`M18 6 6 18`,key:`1bl5f8`}],[`path`,{d:`m6 6 12 12`,key:`d8bk6v`}]]);function Ob(e,t){return({size:n=`var(--icon-size, 1.5rem)`,class:r,"aria-label":i,"aria-hidden":a})=>L(`span`,{class:r,role:a?void 0:`img`,"aria-hidden":a||void 0,"aria-label":a?void 0:i??t,children:L(e,{size:n})})}var kb={close:Ob(Db,`Close`),cancel:Ob(Db,`Cancel`),leave:Ob(yb,`Leave call`),more:Ob(lb,`More`),error:Ob(wb,`Error`),mic:Ob(hb,`Microphone`),"mic-off":Ob(mb,`Microphone muted`),cam:Ob(ob,`Camera`),"cam-off":Ob(ab,`Camera off`),"screen-share":Ob(_b,`Screen share`),pip:Ob(bb,`Picture in picture`),user:Ob(Tb,`User`),"face-smile":Ob(Cb,`Camera off`),captions:Ob(sb,`Closed captions`),chat:Ob(pb,`Chat`),fullscreen:Ob(fb,`Enter fullscreen`),"fullscreen-exit":Ob(gb,`Exit fullscreen`),expand:Ob(ub,`Expand`),collapse:Ob(Sb,`Collapse`),send:Ob(xb,`Send`),"external-link":Ob(db,`External link`),clock:Ob(cb,`Clock`),moon:Ob(vb,`Unavailable`),users:Ob(Eb,`Busy`)},Ab=`<svg xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 24 24"><path d="M20 21h-2v-2h2v2Zm-6-2H4v-2h10v2Zm4 0h-2v-2h2v2Zm4 0h-2v-2h-2v-2h-2v-2h-2V7h2v2h2V7h2V5h2v14ZM4 17H2V7h2v10Zm12 0h-2v-2h2v2Zm-2-2h-2v-2h2v2Zm-2-2h-2v-2h2v2Zm-2-2H8V9h2v2ZM8 9H6V7h2v2ZM6 7H4V5h2v2Zm8 0h-4V5h4v2ZM4 5H2V3h2v2Z"/></svg>`,jb=`<svg xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 24 24"><path d="M3 4h18v2H3zm0 14h18v2H3zM1 6h2v12H1zm20 0h2v12h-2zM5 10h2v4H5zm8 0h2v4h-2zM7 8h4v2H7zm0 6h4v2H7zm8 0h4v2h-4zm0-6h4v2h-4z"/></svg>`,Mb=`<svg xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 24 24"><path d="M22 22h-2v-2h-2v-2h2v-8h2v12Zm-4-4h-8v-2h8v2ZM4 12h2v2H4v2H2V4h2v8Zm6 4H8v-6h2v6Zm10-6H10V8h10v2Zm-4-4h-2V4h2v2Zm-2-2H4V2h10v2Z"/></svg>`,Nb=`<svg xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 24 24"><path d="M18 22H6v-2h12v2ZM6 20H4v-2h2v2Zm14 0h-2v-2h2v2ZM4 18H2V6h2v12Zm18 0h-2V6h2v12Zm-5-1h-2v-2h2v2Zm-2-2h-2v-2h2v2Zm-2-2h-2V6h2v7ZM6 6H4V4h2v2Zm14 0h-2V4h2v2Zm-2-2H6V2h12v2Z"/></svg>`,Pb=`<svg xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 24 24"><path d="M18 22H6v-2h12v2ZM6 20H4v-2h2v2Zm14 0h-2v-2h2v2ZM4 18H2V6h2v12Zm4 0H6v-2h2v2Zm14 0h-2V6h2v12Zm-12-2H8v-2h2v2Zm2-2h-2v-2h2v2Zm2-2h-2v-2h2v2Zm2-2h-2V8h2v2Zm2-2h-2V6h2v2ZM6 6H4V4h2v2Zm14 0h-2V4h2v2Zm-2-2H6V2h12v2Z"/></svg>`,Fb=`<svg xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 24 24"><path d="M7 19H5v-2h2v2Zm12 0h-2v-2h2v2ZM9 15v2H7v-2h2Zm8 2h-2v-2h2v2Zm-6-2H9v-2h2v2Zm4 0h-2v-2h2v2Zm-2-2h-2v-2h2v2Zm-2-2H9V9h2v2Zm4 0h-2V9h2v2ZM9 9H7V7h2v2Zm8 0h-2V7h2v2ZM7 7H5V5h2v2Zm12 0h-2V5h2v2Z"/></svg>`,Ib=`<svg xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 24 24"><path d="M7 19h2v-2h2v-2h2v2h2v2h2v2H7v-2Zm13-6H4v-2h16v2Zm-3-8h-2v2h-2v2h-2V7H9V5H7V3h10v2Z"/></svg>`,Lb=`<svg xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 24 24"><path d="M20 22H4v-2h16v2ZM4 20H2V4h2v16Zm18 0h-2V4h2v16Zm-9-2h-2v-2h2v2Zm0-4h-2V6h2v8Zm7-10H4V2h16v2Z"/></svg>`,Rb=`<svg xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 24 24"><path d="M15 19h-2v2h-2v-2H9v-2H7v-2h10v2h-2v2Zm5-6H4v-2h16v2Zm-7-8h2v2h2v2H7V7h2V5h2V3h2v2Z"/></svg>`,zb=`<svg xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 24 24"><path d="M8 22H4v-2h4v2Zm12 0h-4v-2h4v2ZM4 20H2v-4h2v4Zm18 0h-2v-4h2v4Zm-6-3H8v-2h8v2Zm-8-2H6V9h2v6Zm10 0h-2V9h2v6Zm-2-6H8V7h8v2ZM4 8H2V4h2v4Zm18 0h-2V4h2v4ZM8 4H4V2h4v2Zm12 0h-4V2h4v2Z"/></svg>`,Bb=`<svg xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 24 24"><path d="M18 22H6v-2h12v2ZM6 20H4V4h2v16Zm14 0h-2v-3h2v3ZM16 9h2v2h2v2h-2v2h-2v2h-2v-4H8v-2h6V7h2v2Zm4-2h-2V4h2v3Zm-2-3H6V2h12v2Z"/></svg>`,Vb=`<svg xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 24 24"><path d="M13 22h-2v-2H8v-2h8v2h-3v2Zm-5-4H6v-2h2v2Zm10 0h-2v-2h2v2ZM6 16H4v-6h2v6Zm8 0h-4v-2h4v2Zm6 0h-2v-6h2v6Zm-10-2H8V4h2v10Zm6 0h-2V4h2v10ZM14 4h-4V2h4v2Z"/></svg>`,Hb=`<svg xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 24 24"><path d="M13 22h-2v-2H8v-2h8v2h-3v2Zm9 0h-2v-2h2v2Zm-2-2h-2v-2h2v2ZM8 18H6v-2h2v2Zm10 0h-2v-2h2v2ZM6 16H4v-6h2v6Zm8-2h2v2h-6v-2h2v-2h2v2Zm-4-4h2v2h-2v2H8V8h2v2Zm10 4h-2v-4h2v4Zm-4-4h-2V4h2v6ZM8 8H6V6h2v2ZM6 6H4V4h2v2ZM4 4H2V2h2v2Zm10 0h-4V2h4v2Z"/></svg>`,Ub=`<svg xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 24 24"><path d="M18 22H8v-2h10v2ZM8 20H6v-2h2v2Zm12 0h-2v-2h2v2ZM6 18H4v-2h2v2Zm16 0h-2v-4h-2v-2h2v-2h2v8ZM4 16H2V6h2v10Zm14 0h-6v-2h6v2Zm-6-2h-2v-2h2v2Zm-2-2H8V6h2v6ZM6 6H4V4h2v2Zm8-2h-2v2h-2V4H6V2h8v2Z"/></svg>`,Wb=`<svg xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 24 24"><path d="M5 15H3v-2h2v2Zm8 0h-2v-2h2v2Zm8 0h-2v-2h2v2ZM3 13H1v-2h2v2Zm4 0H5v-2h2v2Zm4 0H9v-2h2v2Zm4 0h-2v-2h2v2Zm4 0h-2v-2h2v2Zm4 0h-2v-2h2v2ZM5 11H3V9h2v2Zm8 0h-2V9h2v2Zm8 0h-2V9h2v2Z"/></svg>`,Gb=`<svg xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 24 24"><path d="M20 20H4v-2h16v2ZM4 18H2V6h2v12Zm18 0h-2V6h2v12ZM18 8v6h-8V8h8Zm2-2H4V4h16v2Zm-4 4h-4v2h4v-2Z"/></svg>`,Kb=`<svg xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 24 24"><path d="M20 18h-7v2h3v2H8v-2h3v-2H4v-2h16v2ZM4 16H2V4h2v12Zm18 0h-2v-6h2v6Zm-6-6h-2V8h2v2Zm2-2h-2V6h2v2Zm4-6v6h-2V6h-2V4h-2V2h6Zm-8 2H4V2h10v2Z"/></svg>`,qb=`<svg xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 24 24"><path d="M4 19h4v2H2v-8h2v6Zm8 0H8v-2h4v2Zm4-2h-4v-2h4v2Zm4-2h-4v-2h4v2Zm-10-2H4v-2h6v2Zm12 0h-2v-2h2v2ZM8 5H4v6H2V3h6v2Zm12 6h-4V9h4v2Zm-4-2h-4V7h4v2Zm-4-2H8V5h4v2Z"/></svg>`,Jb=`<svg xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 24 24"><path d="M6 22H4v-4h2v4Zm14 0h-2v-4h2v4ZM8 18H6v-2h2v2Zm10 0h-2v-2h2v2Zm-2-2H8v-2h8v2Zm-1-4H9v-2h6v2Zm-6-2H7V4h2v6Zm8 0h-2V4h2v6Zm-2-6H9V2h6v2Z"/></svg>`,Yb=`<svg xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 24 24"><path d="M2 22H0v-4h2v4Zm14 0h-2v-4h2v4Zm8 0h-2v-4h2v4ZM4 18H2v-2h2v2Zm10 0h-2v-2h2v2Zm8 0h-2v-2h2v2Zm-10-2H4v-2h8v2Zm8 0h-4v-2h4v2Zm-9-4H5v-2h6v2Zm8 0h-4v-2h4v2ZM5 10H3V4h2v6Zm8 0h-2V4h2v6Zm8 0h-2V4h2v6ZM11 4H5V2h6v2Zm8 0h-4V2h4v2Z"/></svg>`,Xb=`<svg xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 24 24"><path d="M20 22H4v-2h16v2ZM4 20H2v-6H0v-2h2V8h2v12Zm18-8h2v2h-2v6h-2V8h2v4Zm-8 6h-4v-2h4v2Zm-4-2H8v-2h2v2Zm6 0h-2v-2h2v2Zm-6-4H8v-2h2v2Zm6 0h-2v-2h2v2Zm-3-6h7v2H4V6h7V4h2v2Zm4-2h-4V2h4v2Z"/></svg>`,Zb=`<svg xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 24 24"><path d="M17 21H5v-2h12v2ZM5 19H3V7h2v12Zm14 0h-2v-6h2v6Zm-8-4H9v-2h2v2Zm2-2h-2v-2h2v2Zm2-2h-2V9h2v2Zm6 0h-2V7h-2V5h-4V3h8v8Zm-4-2h-2V7h2v2Zm-6-2H5V5h6v2Z"/></svg>`,Qb=`<svg xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 24 24"><path d="M16 9h2V7h2V5h2v14h-2v-2h-2v-2h-2v4H2V5h14v4ZM4 17h10V7H4v10Z"/></svg>
52
+ `;function $b(e){return e.replace(/\s(width|height)="\d+"/g,``)}function ex(e,t){let n=$b(e);return({size:e=`var(--icon-size, 1.5rem)`,class:r,"aria-label":i,"aria-hidden":a})=>L(`span`,{class:r,role:a?void 0:`img`,"aria-hidden":a||void 0,"aria-label":a?void 0:i??t,style:{display:`inline-flex`,width:e,height:e},dangerouslySetInnerHTML:{__html:n.replace(`<svg`,`<svg width="100%" height="100%"`)}})}var tx={pixelarticons:{close:ex(Pb,`Close`),cancel:ex(Fb,`Cancel`),leave:ex(Bb,`Leave call`),more:ex(Wb,`More`),error:ex(Lb,`Error`),mic:ex(Vb,`Microphone`),"mic-off":ex(Hb,`Microphone muted`),cam:ex(Qb,`Camera`),"cam-off":ex(Ab,`Camera off`),"screen-share":ex(Kb,`Screen share`),pip:ex(Gb,`Picture in picture`),user:ex(Jb,`User`),"face-smile":ex(Xb,`Camera off`),captions:ex(jb,`Closed captions`),chat:ex(Mb,`Chat`),fullscreen:ex(zb,`Enter fullscreen`),"fullscreen-exit":ex(Ib,`Exit fullscreen`),expand:ex(Rb,`Expand`),collapse:ex(Ib,`Collapse`),send:ex(qb,`Send`),"external-link":ex(Zb,`External link`),clock:ex(Nb,`Clock`),moon:ex(Ub,`Unavailable`),users:ex(Yb,`Busy`)},lucide:kb};function nx({name:e,...t}){let{config:n}=Ev(),r=(tx[n.value.customization.style.icon_library]??tx.pixelarticons)[e];return L(r,{...t})}var rx=`Ready when you are`,ix=`Start the conversation`;function ax(e){return typeof e==`string`&&e.length>0?e:``}function ox(e){let t=ax(e.replica_thumbnail_image_url)||null,n=ax(e.replica_thumbnail_video_url)||null;return!t&&!n?null:{imageUrl:t,videoUrl:n}}function sx(e){let{preview:t}=e.customization,{background:n}=t,r=ox(e),i;i=n.type?n.type:r?`replica`:`background-gradient`;let a=ax(n.url);return{title:t.title||rx,description:t.description||``,btn_title:t.btn_title||ix,background:{type:i,url:a}}}var cx={backgroundImage:`linear-gradient(to bottom right, var(--color-primary), var(--color-base-300))`},lx=`#t=0.1`;function ux(e){return e.includes(`#`)?e:`${e}${lx}`}function dx({replica:e,fallback:t=null}){let[n,r]=j(()=>new Set),i=e=>r(t=>new Set(t).add(e)),a=`absolute inset-0 w-full h-full object-cover`,{imageUrl:o,videoUrl:s}=e;return o&&!n.has(o)?L(`img`,{class:a,src:o,loading:`lazy`,alt:``,onError:()=>i(o)}):s&&!n.has(s)?L(`video`,{class:a,src:ux(s),muted:!0,playsinline:!0,preload:`metadata`,controls:!1,onError:()=>i(s)}):L(k,{children:t})}function fx({variant:e,replica:t}){let[n,r]=j(!1);return M(()=>{r(!1)},[e.url]),e.type===`replica`&&t?L(dx,{replica:t,fallback:L(`div`,{class:`absolute inset-0`,style:cx})}):e.type===`custom-image`&&e.url&&!n?L(`img`,{class:`absolute inset-0 w-full h-full object-cover`,src:e.url,loading:`lazy`,alt:``,onError:()=>r(!0)}):L(`div`,{class:`absolute inset-0`,style:cx})}function px({className:e=``}){let{config:t}=Ev(),n=sx(t.value),r=ox(t.value);return L(`div`,{class:`relative size-16 shrink-0 rounded-box overflow-hidden bg-base-300 ${e}`,children:L(fx,{variant:n.background,replica:r})})}var mx=`absolute inset-0 bg-base-100 text-base-content flex flex-col items-center justify-center gap-6 px-6 py-8 text-center overflow-y-auto motion-safe:animate-[tavusFadeUp_280ms_ease-out]`;function hx({title:e,description:t,media:n,children:r,overlay:i}){return L(`div`,{class:mx,children:[n===void 0?L(px,{}):n,(e||t)&&L(`div`,{class:`flex flex-col items-center gap-3 max-w-sm`,children:[e&&L(`h2`,{class:`text-lg font-medium leading-snug`,children:e}),t&&L(`p`,{class:`text-base text-base-content/60 tracking-wide leading-snug`,children:t})]}),r&&L(`div`,{class:`flex flex-col items-center gap-3`,children:r}),i]})}function gx({loading:e=!1,disabled:t,class:n,children:r,...i}){return L(`button`,{type:`button`,class:`btn relative ${n?` ${n}`:``}`,disabled:t||e,"aria-busy":e||void 0,...i,children:[L(`span`,{children:r}),e&&L(`span`,{class:`absolute inset-0 flex items-center justify-center backdrop-blur-xs`,"aria-hidden":`true`,children:L(`span`,{class:`loading loading-spinner loading-sm`})})]})}var _x={daily_limit:{title:`PAL is at today's limit`,description:`This PAL can take more conversations tomorrow.`},total_limit:{title:`PAL is unavailable`,description:`This PAL isn't available right now. Please check back later.`},busy:{title:`PAL is in another conversation`,description:`Please try again in a moment.`},error:{title:`Couldn't load this PAL`,description:`This PAL couldn't be loaded. Please try again later.`}};function vx(e,t){let n=t?.[e];return{title:n?.title||_x[e].title,description:n?.description||_x[e].description}}var yx={daily_limit:`clock`,total_limit:`moon`,busy:`users`,error:`error`},bx={daily_limit:`never`,total_limit:`never`,busy:`always`,error:`when-retryable`};function xx({cause:e}){return L(`div`,{class:`flex size-16 shrink-0 items-center justify-center rounded-box bg-base-200 text-base-content/70`,children:L(nx,{name:yx[e],size:`2rem`})})}function Sx({cause:e,canRetry:t,onRetry:n,onCancel:r,isStarting:i=!1}){let{config:a}=Ev(),o=a.value.customization?.unavailable_screen,s=vx(e,o),c=o?.cta??[],l=bx[e],u=l===`always`||l===`when-retryable`&&t,d=u||c.length>0||!!r;return L(hx,{media:L(xx,{cause:e}),title:s.title,description:s.description,children:d&&L(`div`,{class:`flex flex-wrap items-center justify-center gap-2`,children:[u&&L(gx,{class:`btn-neutral rounded-box`,disabled:!t,loading:i,onClick:n,children:`Try again`}),c.map(e=>L(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,class:`btn btn-outline rounded-box`,children:e.title},e.url)),r&&L(`button`,{type:`button`,class:`btn btn-ghost`,onClick:r,children:`Close`})]})})}function Cx(){let e=I(T_);return{state:e.flowSignal.value,isStarting:e.isStarting,permissionRequest:e.permissionRequest,unavailableCause:e.unavailableCause,canRetry:e.canRetry,start:e.start,join:e.join,cancel:e.cancel,leave:e.leave,restart:e.restart}}var wx={start_button:`Start the conversation`,ready_to_start:``};function Tx(){let{config:e}=Ev(),{preview:t}=e.value.customization;return P(()=>({start_button:t.btn_title??wx.start_button,ready_to_start:t.description??wx.ready_to_start}),[t])}function Ex(){return I(kt)?.layout??`inline`}var Dx=`text-preview-title @max-mobile:text-preview-title-narrow`,Ox=`text-preview-title-full-screen`,kx=`text-sm @max-mobile:text-xs`,Ax=`text-preview-description-full-screen`;function jx({title:e,description:t,fullScreen:n}){return!e&&!t?null:L(`div`,{class:`flex flex-col gap-1 text-left ${n?`max-w-xl`:`max-w-sm`}`,children:[e&&L(`h2`,{class:`${n?Ox:Dx} font-medium leading-tight`,children:e}),t&&L(`p`,{class:`${n?Ax:kx} text-white/80 leading-snug`,children:t})]})}var Mx=`absolute inset-0 overflow-hidden bg-base-100 motion-safe:animate-[tavusFadeUp_280ms_ease-out]`,Nx=`absolute inset-x-0 top-0 h-2/5 bg-linear-to-b from-black/60 to-transparent`,Px=`absolute inset-x-0 bottom-0 h-2/5 bg-linear-to-t from-black/70 to-transparent`,Fx=`absolute inset-0 bg-black/45`,Ix=`absolute inset-0 overflow-y-auto p-8 @max-mobile:p-5 text-white [text-shadow:0_1px_3px_rgb(0_0_0/0.45)]`;function Lx({title:e,description:t,children:n,align:r=`low`,overlay:i,class:a,role:o,"aria-live":s}){let{config:c}=Ev(),l=sx(c.value),u=ox(c.value),d=Ex()===`full-screen`;return L(`div`,{class:a?`${Mx} ${a}`:Mx,role:o,"aria-live":s,children:[L(fx,{variant:l.background,replica:u}),r===`center`?L(k,{children:[L(`div`,{class:Fx}),L(`div`,{class:`${Ix} flex flex-col items-center justify-center gap-3`,children:n})]}):L(k,{children:[(e||t)&&(d?L(`div`,{class:Nx}):L(k,{children:[L(`div`,{class:`${Nx} hidden @max-mobile:block`}),L(`div`,{class:Px})]})),d?L(`div`,{class:Ix,children:[L(jx,{title:e,description:t,fullScreen:!0}),L(`div`,{class:`absolute inset-x-8 @max-mobile:inset-x-5 bottom-[20%] flex flex-col items-center gap-3`,children:n})]}):L(`div`,{class:`${Ix} grid grid-cols-[1fr_auto] grid-rows-[1fr_auto] gap-x-6`,children:[L(`div`,{class:`col-start-1 row-start-2 self-center @max-mobile:col-span-2 @max-mobile:row-start-1 @max-mobile:self-start`,children:L(jx,{title:e,description:t})}),L(`div`,{class:`col-start-2 row-start-2 self-end justify-self-end flex flex-col items-end gap-3`,children:n})]})]}),i]})}var Rx={video:`cam`,audio:`mic`,chat:`chat`},zx={"full-screen":`btn-lg px-16 @max-3xl:px-10 @max-md:btn-md @max-md:px-5`,inline:`px-8 @max-mobile:px-5`};function Bx({children:e,loading:t=!1,...n}){let{config:r}=Ev(),i=Ex(),a=Rx[r.value.customization.conversation.modality],o=a!==void 0&&i===`full-screen`;return L(gx,{class:`btn-preview-action rounded-box ${zx[i]}`,loading:t,...n,children:o?L(`span`,{class:`flex items-center justify-center gap-2`,children:[L(nx,{name:a,"aria-hidden":!0}),e]}):e})}var Vx=`Thanks for joining`,Hx=`You can start a new conversation whenever you're ready.`,Ux=`Start a new conversation`;function Wx(e){try{let t=new URL(e);return t.protocol===`https:`||t.protocol===`http:`||t.protocol===`mailto:`}catch{return!1}}function Gx({text:e,onRestart:t,isStarting:n=!1}){let{config:r}=Ev(),i=Ex()===`full-screen`,a=r.value.customization.after_call,o=a.cta.filter(e=>Wx(e.url));return L(Lx,{title:a.title||e?.title||Vx,description:a.description||e?.description||Hx,children:[L(Bx,{onClick:t,loading:n,children:e?.restart||Ux}),o.length>0&&L(`div`,{class:`flex flex-wrap items-center gap-2 ${i?`justify-center`:`justify-end`}`,children:o.map(e=>L(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,class:`btn rounded-box border-white/50 bg-black/35 text-white backdrop-blur-xs hover:bg-black/50`,children:e.title},e.url))})]})}function Kx(){let e=Th(),t=lg(),{isOff:n}=C_(t),{camState:r}=__();return{isCamReady:P(()=>r===`granted`,[r]),isCamMuted:n,localSessionId:t,onToggleCamera:F(()=>{e?.setLocalVideo(n)},[e,n])}}function qx(){let e=Th(),t=lg(),{isOff:n}=f_(t),{micState:r}=__();return{isMicReady:P(()=>r===`granted`,[r]),isMicMuted:n,localSessionId:t,onToggleMicrophone:F(()=>{e?.setLocalAudio(n)},[e,n])}}function Jx(){let e=Th(),t=lg(),{isOff:n}=x_(t),r=!n;return{isScreenSharing:r,localSessionId:t,onToggleScreenshare:F(()=>{r?e?.stopScreenShare():e?.startScreenShare({displayMediaOptions:{audio:!1,selfBrowserSurface:`exclude`,surfaceSwitching:`include`,video:{width:1920,height:1080}}})},[e,r])}}var Yx={microphone:`microphone`,camera:`camera`};function Xx({class:e}){return L(`svg`,{class:e,viewBox:`0 0 24 24`,fill:`none`,"aria-hidden":`true`,children:[L(`circle`,{cx:`7`,cy:`8`,r:`2.2`,stroke:`currentColor`,"stroke-width":`1.6`}),L(`circle`,{cx:`16`,cy:`16`,r:`2.2`,stroke:`currentColor`,"stroke-width":`1.6`}),L(`path`,{d:`M2 8h2.5M9.5 8H22M2 16h11.5M18.5 16H22`,stroke:`currentColor`,"stroke-width":`1.6`,"stroke-linecap":`round`})]})}function Zx(){return L(`svg`,{viewBox:`0 0 240 180`,class:`w-full h-auto text-base-content/70`,fill:`none`,"aria-hidden":`true`,children:[L(`rect`,{x:`10`,y:`20`,width:`220`,height:`150`,rx:`10`,stroke:`currentColor`,"stroke-width":`2`}),L(`path`,{d:`M10 46h220`,stroke:`currentColor`,"stroke-width":`2`}),L(`circle`,{cx:`26`,cy:`33`,r:`3.5`,stroke:`currentColor`,"stroke-width":`1.6`}),L(`circle`,{cx:`40`,cy:`33`,r:`3.5`,stroke:`currentColor`,"stroke-width":`1.6`}),L(`circle`,{cx:`54`,cy:`33`,r:`3.5`,stroke:`currentColor`,"stroke-width":`1.6`}),L(`path`,{d:`M78 33h14M86 27l-6 6 6 6M104 27v12`,stroke:`currentColor`,"stroke-width":`1.8`,"stroke-linecap":`round`,"stroke-linejoin":`round`}),L(`rect`,{x:`118`,y:`25`,width:`96`,height:`16`,rx:`8`,stroke:`currentColor`,"stroke-width":`1.6`}),L(`circle`,{class:`text-info`,cx:`128`,cy:`33`,r:`11`,fill:`currentColor`,opacity:`0.18`}),L(`circle`,{class:`text-info`,cx:`128`,cy:`33`,r:`11`,stroke:`currentColor`,"stroke-width":`1.6`}),L(`g`,{class:`text-info`,transform:`translate(120 25) scale(0.66)`,children:L(Xx,{})}),L(`g`,{transform:`translate(34 78)`,children:[L(`rect`,{x:`0`,y:`8`,width:`34`,height:`26`,rx:`5`,stroke:`currentColor`,"stroke-width":`2`}),L(`path`,{d:`M34 16l14-8v26l-14-8`,stroke:`currentColor`,"stroke-width":`2`,"stroke-linejoin":`round`})]}),L(`g`,{transform:`translate(40 120)`,children:[L(`rect`,{x:`6`,y:`0`,width:`14`,height:`24`,rx:`7`,stroke:`currentColor`,"stroke-width":`2`}),L(`path`,{d:`M0 20a13 13 0 0 0 26 0M13 33v8`,stroke:`currentColor`,"stroke-width":`2`,"stroke-linecap":`round`})]}),L(`path`,{d:`M150 64l34 14-14 4-2 16-18-34Z`,fill:`currentColor`,stroke:`currentColor`,"stroke-width":`2`,"stroke-linejoin":`round`})]})}var Qx=Ea(({device:e,onClose:t})=>{let n=Yx[e];return M(()=>{let e=e=>{e.key===`Escape`&&t()};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[t]),L(`div`,{class:`absolute inset-0 z-50 flex items-center justify-center p-4 bg-black/50 motion-safe:animate-[tavusFadeUp_180ms_ease-out]`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`tavus-blocked-title`,onClick:t,children:L(`div`,{class:`relative w-full max-w-md rounded-box bg-base-100 text-base-content shadow-xl overflow-hidden`,onClick:e=>e.stopPropagation(),children:[L(`button`,{type:`button`,class:`btn btn-sm btn-circle btn-ghost absolute top-2 right-2 z-10`,onClick:t,"aria-label":`Close`,children:L(nx,{name:`close`,size:`1.1rem`})}),L(`div`,{class:`grid @3xl:grid-cols-[1fr_1.2fr] gap-4 p-5 @max-md:p-4`,children:[L(`div`,{class:`flex items-center justify-center @max-md:hidden`,children:L(Zx,{})}),L(`div`,{class:`flex flex-col gap-4`,children:[L(`h2`,{id:`tavus-blocked-title`,class:`text-lg font-semibold leading-snug pr-6`,children:[`Access to your `,n,` is blocked`]}),L(`ol`,{class:`flex flex-col gap-3 text-sm`,children:[L(`li`,{class:`flex items-start gap-2`,children:[L(`span`,{class:`font-semibold tabular-nums`,children:`1.`}),L(`span`,{class:`leading-snug`,children:[`Click the `,L(Xx,{class:`inline-block align-text-bottom h-4 w-4 mx-0.5`}),` `,`settings icon in your browser's address bar`]})]}),L(`li`,{class:`flex items-start gap-2`,children:[L(`span`,{class:`font-semibold tabular-nums`,children:`2.`}),L(`span`,{class:`leading-snug`,children:[`Allow `,n,` access, then reload the page`]})]})]}),L(`button`,{type:`button`,class:`btn btn-neutral btn-sm self-start`,onClick:t,children:`Got it`})]})]})]})})}),$x=Ae({open:()=>{},close:()=>{}});function eS(){return I($x)}function tS({children:e}){let[t,n]=j(null),r=F(e=>n(e),[]),i=F(()=>n(null),[]),a=P(()=>({open:r,close:i}),[r,i]);return L($x.Provider,{value:a,children:[e,t&&L(Qx,{device:t,onClose:i})]})}var nS=Ea(()=>L(`span`,{"aria-hidden":`true`,class:`absolute -top-0.5 -right-0.5 z-20 flex h-4 w-4 items-center justify-center rounded-full bg-warning text-warning-content text-[0.6rem] font-bold leading-none ring-2 ring-base-100 pointer-events-none`,children:`!`})),rS=`select-control-pill relative inline-flex items-center bg-neutral text-neutral-content`,iS=`absolute inset-0 w-full h-full opacity-0 cursor-pointer appearance-none disabled:cursor-not-allowed`,aS=`absolute right-1.5 top-1/2 -translate-y-1/2 pointer-events-none flex items-center`,oS=`absolute left-0 top-0 h-full aspect-square flex items-center justify-center pointer-events-none`,sS=`absolute left-0 top-0 z-10 btn btn-control btn-neutral`;function cS(){return L(`svg`,{style:{width:`var(--chevron-size, 0.75rem)`,height:`var(--chevron-size, 0.75rem)`},viewBox:`0 0 16 16`,fill:`none`,"aria-hidden":`true`,children:L(`path`,{d:`M4 6L8 10L12 6`,stroke:`currentColor`,"stroke-width":`1.5`,"stroke-linecap":`round`,"stroke-linejoin":`round`})})}function lS(){let e=lg(),t=N(null),n=N(void 0);return d_(e??``,F(e=>{n.current&&cancelAnimationFrame(n.current),n.current=requestAnimationFrame(()=>{let n=Math.max(0,Math.min(1,e**.6));t.current?.style.setProperty(`--mic-level`,String(n))})},[])),L(`span`,{ref:t,"aria-hidden":`true`,class:`pointer-events-none absolute inset-x-0 bottom-0 z-0 bg-success/70`,style:{"--mic-level":`0`,height:`calc(var(--mic-level, 0) * 100%)`,transition:`height 100ms ease-out`}})}function uS({value:e,devices:t,disabled:n,onChange:r,label:i}){return L(k,{children:[L(`select`,{class:iS,value:e,onChange:e=>r(e.target.value),disabled:n,"aria-label":i,children:t.map(({device:e})=>L(`option`,{value:e.deviceId,children:e.label},e.deviceId))}),L(`span`,{class:aS,children:L(cS,{})})]})}function dS(e){return L(`div`,{class:rS,children:L(uS,{...e})})}function fS({iconName:e,...t}){return L(`div`,{class:rS,children:[L(`span`,{class:oS,"aria-hidden":`true`,children:L(nx,{name:e})}),L(uS,{...t})]})}var pS=Ea(({level:e=!1})=>{let{onToggleMicrophone:t,isMicReady:n,isMicMuted:r}=qx(),{microphones:i,currentMic:a,setMicrophone:o}=__();if(!a||(i?.length??0)<=1)return L(gS,{level:e});let s=e&&n&&!r;return L(`div`,{class:`relative inline-flex items-center`,children:[L(dS,{value:a?.device?.deviceId,devices:i||[],disabled:!n,onChange:e=>o(e),label:`Select microphone`}),L(`button`,{type:`button`,onClick:t,disabled:!n,class:`${sS} overflow-hidden`,"aria-label":r?`Unmute microphone`:`Mute microphone`,"aria-pressed":r,children:[s&&L(lS,{}),L(`span`,{class:`relative z-10 inline-flex`,children:L(nx,{name:r||!n?`mic-off`:`mic`})})]})]})});function mS(){let{onToggleCamera:e,isCamMuted:t}=Kx(),{camera:n,requestCamera:r}=Xv(),{open:i}=eS(),a=n.isGranted&&!t;return{isOn:a,onClick:()=>{if(n.isBlocked)return i(`camera`);if(a)return e();r()},label:a?`Turn camera off`:n.isGranted?`Turn camera on`:`Enable camera`,needsAttention:n.needsAttention}}var hS=Ea(()=>{let{isCamReady:e}=Kx(),{currentCam:t,cameras:n,setCamera:r}=__(),i=mS();return!t||(n?.length??0)<=1?L(_S,{}):L(`div`,{class:`relative inline-flex items-center`,children:[L(dS,{value:t?.device?.deviceId,devices:n||[],disabled:!e,onChange:e=>r(e),label:`Select camera`}),L(`button`,{type:`button`,onClick:i.onClick,class:sS,"aria-label":i.label,"aria-pressed":!i.isOn,children:L(nx,{name:i.isOn?`cam`:`cam-off`})})]})}),gS=Ea(({level:e=!1})=>{let{onToggleMicrophone:t,isMicMuted:n}=qx(),{mic:r,requestMic:i}=Xv(),{open:a}=eS(),o=()=>{if(r.isGranted)return t();if(r.isBlocked)return a(`microphone`);i()},s=r.isGranted?n?`Unmute microphone`:`Mute microphone`:`Allow microphone access`,c=e&&r.isGranted&&!n;return L(`span`,{class:`relative inline-flex`,children:[L(`button`,{type:`button`,onClick:o,class:`btn btn-control btn-neutral relative overflow-hidden`,"aria-label":s,"aria-pressed":r.isGranted?n:void 0,children:[c&&L(lS,{}),L(`span`,{class:`relative z-10 inline-flex`,children:L(nx,{name:n||!r.isGranted?`mic-off`:`mic`})})]}),r.needsAttention&&L(nS,{})]})}),_S=Ea(()=>{let{isOn:e,onClick:t,label:n,needsAttention:r}=mS();return L(`span`,{class:`relative inline-flex`,children:[L(`button`,{type:`button`,onClick:t,class:`btn btn-control btn-neutral`,"aria-label":n,"aria-pressed":!e,children:L(nx,{name:e?`cam`:`cam-off`})}),r&&L(nS,{})]})});Ea(({compact:e=!1}={})=>{let{isMicReady:t}=qx(),{microphones:n,currentMic:r,setMicrophone:i}=__();return(n?.length??0)<=1?null:L(fS,{iconName:`mic`,value:r?.device?.deviceId,devices:n,disabled:!t,onChange:e=>i(e),label:`Select microphone`,compact:e})}),Ea(({compact:e=!1}={})=>{let{isCamReady:t}=Kx(),{currentCam:n,cameras:r,setCamera:i}=__();return(r?.length??0)<=1?null:L(fS,{iconName:`cam`,value:n?.device?.deviceId,devices:r,disabled:!t,onChange:e=>i(e),label:`Select camera`,compact:e})});var vS=Ea((e={})=>{let{onToggleScreenshare:t,isScreenSharing:n}=Jx();return L(`button`,{type:`button`,onClick:t,class:`btn btn-control ${n?`btn-primary`:`btn-neutral`}`,"aria-label":n?`Stop screen share`:`Start screen share`,"aria-pressed":n,children:L(nx,{name:`screen-share`})})});function yS(e){let t=I(av);if(!t)throw Error(`useConversation must be used within ConversationProvider`);return M(()=>{if(e)return t.__registerSubscriber(e),()=>t.__unregisterSubscriber(e)},[e]),t}var bS=Ae(null);function xS({children:e,defaultEnabled:t=!1}){let[n,r]=j(t),i=F(()=>r(e=>!e),[]),a=P(()=>({isEnabled:n,toggle:i}),[n,i]);return L(bS.Provider,{value:a,children:e})}function SS(){let e=I(bS);if(!e)throw Error(`ClosedCaptions components must be used within <ClosedCaptionsProvider>`);return e}var CS=Ea(()=>{let{isEnabled:e,toggle:t}=SS();return L(`button`,{type:`button`,onClick:t,"aria-pressed":e,class:`btn btn-control ${e?`btn-primary`:`btn-neutral`}`,"aria-label":e?`Hide captions`:`Show captions`,children:L(nx,{name:`captions`,"aria-label":e?`Closed Captions On`:`Closed Captions Off`})})}),wS=Ea(()=>{let{isEnabled:e}=SS(),{captionText:t,captionRole:n}=yS(),r=t.value,i=n.value;return!e||!r?null:L(`div`,{class:`pointer-events-none absolute bottom-24 left-1/2 -translate-x-1/2 max-w-[80%] px-4 py-2 rounded-box bg-black/60 text-white z-40`,role:`status`,"aria-live":`polite`,children:L(`div`,{class:`text-sm leading-5 max-h-15 overflow-hidden flex flex-col justify-end text-center`,children:L(`div`,{children:[L(`span`,{class:`text-xs ${i===`replica`?`text-secondary`:`text-primary`} mr-2`,children:i===`replica`?`PAL`:`You`}),r]})})})}),TS=Ae(null);function ES({children:e,defaultOpen:t=!1}){let[n,r]=j(t),i=F(()=>r(e=>!e),[]),a=F(()=>r(!1),[]),o=P(()=>({isOpen:n,toggle:i,close:a}),[n,i,a]);return L(TS.Provider,{value:o,children:e})}function DS(){let e=I(TS);if(!e)throw Error(`Chat components must be used within <ChatProvider>`);return e}var OS=Ea((e={})=>{let{isOpen:t,toggle:n}=DS();return L(`button`,{type:`button`,onClick:n,"aria-pressed":t,"aria-label":t?`Close chat`:`Open chat`,class:`btn btn-control ${t?`btn-primary`:`btn-neutral`}`,children:L(nx,{name:`chat`})})}),kS=Ea(({message:e})=>{let t=e.sender===`user`;return L(`li`,{class:`flex flex-col gap-1 ${t?`items-end`:`items-start`}`,children:[L(`span`,{class:`text-xs ${t?`text-primary`:`text-secondary`}`,children:t?`You`:`PAL`}),L(`span`,{class:`px-3 py-2 rounded-field text-sm max-w-[80%] ${t?`bg-primary text-primary-content`:`bg-base-200 text-base-content`}`,children:e.text})]})}),AS=Ea(({docked:e=!1,headerAction:t}={})=>{let{isOpen:n,close:r}=DS(),{chatMessages:i,sendChat:a,session:o}=yS(),s=o.value?.conversationId??null,c=i.value,[l,u]=j(``),d=N(null);M(()=>{let e=d.current;e&&(e.scrollTop=e.scrollHeight)},[c.length]);let f=F(()=>{let e=l.trim();!e||!s||(a(e),u(``))},[l,a,s]),p=F(e=>{e.key===`Enter`&&!e.shiftKey&&!e.isComposing&&(e.preventDefault(),f())},[f]),m=!!l.trim()&&!!s;return L(`aside`,{class:e?`absolute inset-0 w-full h-full bg-base-100 flex flex-col z-30`:`absolute top-0 right-0 w-80 h-full bg-base-100 border-l border-base-300 flex flex-col z-30 transition-transform ${n?`translate-x-0`:`translate-x-full`} @max-mobile:w-full`,"aria-hidden":e?!1:!n,inert:e?!1:!n,children:[L(`header`,{class:`flex items-center justify-between px-4 py-3 border-b border-base-300`,children:[L(`span`,{class:`font-medium text-base-content`,children:`Chat`}),e?t:L(`button`,{type:`button`,class:`btn btn-ghost btn-sm btn-circle`,onClick:r,"aria-label":`Close chat`,children:L(nx,{name:`close`,size:20})})]}),L(`ul`,{ref:d,class:`flex-1 overflow-y-auto p-4 flex flex-col gap-3`,role:`log`,"aria-live":`polite`,children:c.length===0?L(`li`,{class:`text-center text-sm opacity-70`,children:s?`Send a message to start the conversation.`:`Connecting…`}):c.map(e=>L(kS,{message:e},e.id))}),L(`form`,{class:`flex items-end gap-2 p-3 border-t border-base-300`,onSubmit:e=>{e.preventDefault(),f()},children:[L(`textarea`,{class:`textarea textarea-bordered textarea-sm flex-1 resize-none`,value:l,onChange:e=>u(e.target.value),onKeyDown:p,placeholder:s?`Type a message…`:`Connecting…`,disabled:!s,rows:1,"aria-label":`Message`}),L(`button`,{type:`submit`,class:`btn btn-primary btn-sm btn-circle`,disabled:!m,"aria-label":`Send message`,children:L(nx,{name:`send`,size:18})})]})]})});function jS({label:e}){return L(Lx,{align:`center`,role:`status`,"aria-live":`polite`,class:`z-2`,children:L(`div`,{class:`flex items-center gap-2`,children:[L(`span`,{class:`loading loading-spinner loading-sm`}),L(`span`,{class:`text-base font-medium`,children:e})]})})}var MS=Ea(()=>L(jS,{label:`Connecting…`})),NS=Ea(()=>L(jS,{label:`Leaving…`}));function PS({active:e,onToggle:t,tooltip:n,nudge:r=!1}){return L(`div`,{class:`flex items-center gap-2`,children:[r&&L(`span`,{class:`rounded-field bg-base-100 px-2 py-1 text-xs font-medium whitespace-nowrap text-base-content shadow-md motion-safe:animate-[tavusFadeUp_180ms_ease-out]`,children:`Expand for a better view`}),L(`button`,{type:`button`,onClick:t,class:`btn btn-xs btn-control ${r?`btn-primary`:e?`btn-info`:`btn-neutral`}`,"aria-label":n??(e?`Exit fullscreen`:`Enter fullscreen`),title:n,children:L(nx,{name:e?`fullscreen-exit`:`fullscreen`,size:`calc(var(--size-field, 0.25rem) * 3.5)`})})]})}var FS=Ea(({id:e})=>{let t=dg()===e,n=N(null),r=N(null),i=N(null),a=N(void 0);d_(e,F(e=>{a.current&&cancelAnimationFrame(a.current),a.current=requestAnimationFrame(()=>{let t=Number(Math.max(.01,e).toFixed(2));n.current&&r.current&&i.current&&(n.current.style.height=`${20+t*40}%`,r.current.style.height=`${20+t*130}%`,i.current.style.height=`${20+t*40}%`)})},[]));let o=`w-[3px] rounded-full bg-base-100 transition-[opacity] ${t?`opacity-100`:`opacity-50`}`;return L(`div`,{class:`flex items-center justify-center w-6 h-6`,children:L(`div`,{class:`flex items-center justify-center gap-[2px] w-full h-full`,children:[L(`div`,{ref:n,class:o,style:{height:`20%`}}),L(`div`,{ref:r,class:o,style:{height:`20%`}}),L(`div`,{ref:i,class:o,style:{height:`20%`}})]})})}),IS=[0,1,2],LS=.05,RS=450;function zS({sessionId:e,className:t=``}){let{config:n}=Ev(),r=sx(n.value),i=ox(n.value),a=N(null),o=N(void 0),s=N(void 0),[c,l]=j(!1),u=N(!1);return d_(e??``,F(t=>{e&&(o.current&&cancelAnimationFrame(o.current),o.current=requestAnimationFrame(()=>{let e=Math.max(0,Math.min(1,t**.6));a.current?.style.setProperty(`--audio-level`,String(e)),e>LS?(s.current&&=(clearTimeout(s.current),void 0),u.current||(u.current=!0,l(!0))):u.current&&s.current===void 0&&(s.current=setTimeout(()=>{s.current=void 0,u.current=!1,l(!1)},RS))}))},[e])),M(()=>()=>{o.current&&cancelAnimationFrame(o.current),s.current&&clearTimeout(s.current)},[]),L(`div`,{ref:a,class:`relative aspect-square w-full max-w-[min(48cqi,16rem)] mx-auto pointer-events-none ${t}`,style:{"--audio-level":`0`},"aria-hidden":`true`,children:[IS.map(e=>L(`div`,{class:`absolute inset-[16%] rounded-full will-change-transform`,style:{border:`2px solid var(--color-primary)`,opacity:0,animation:c?`tavusAudioWave 2.4s ease-out ${e*.8}s infinite`:`none`,"--wave-peak":`calc(0.18 + var(--audio-level, 0) * 0.5)`}},e)),L(`div`,{class:`absolute inset-[16%] rounded-full`,style:{background:`radial-gradient(circle, color-mix(in oklab, var(--color-primary) 60%, transparent), transparent 70%)`,filter:`blur(20px)`,scale:`calc(1 + var(--audio-level, 0) * 0.25)`,opacity:`calc(0.35 + var(--audio-level, 0) * 0.5)`,transition:`scale 120ms ease-out, opacity 120ms ease-out`}}),L(`div`,{class:`absolute inset-[20%] rounded-full overflow-hidden bg-base-300 ring-2 ring-base-100/20 shadow-xl will-change-transform`,style:{scale:`calc(1 + var(--audio-level, 0) * 0.06)`,transition:`scale 100ms ease-out`},children:L(fx,{variant:r.background,replica:i})})]})}function BS({children:e,class:t,className:n,...r}){return L(`div`,{class:`tavus-mesh-bg ${t??n??``}`,...r,children:[L(`div`,{class:`tavus-mesh-blob tavus-mesh-blob-1`}),L(`div`,{class:`tavus-mesh-blob tavus-mesh-blob-2`}),L(`div`,{class:`tavus-mesh-blob tavus-mesh-blob-3`}),L(`div`,{class:`tavus-mesh-blob tavus-mesh-blob-4`}),L(`div`,{class:`tavus-mesh-blob tavus-mesh-blob-5`}),L(`div`,{class:`absolute inset-0 bg-linear-to-t from-black/30 via-black/10 to-transparent pointer-events-none backdrop-blur-xs`}),e]})}var VS=e=>!!e.user_id?.includes(`tavus-replica`);function HS(){return gg({filter:VS})}function US(e){let t=HS()[0],n=C_(t??``),r=Qg(),[i,a]=j(!1);return M(()=>{t&&(n.state===`playable`||e)&&a(!0)},[t,n.state,e]),r===`left-meeting`||r===`error`?{phase:`left`}:!i||!t?{phase:`connecting`}:{phase:`ready`,replicaId:t,videoState:n}}var WS=Ea(({isAudioOnly:e})=>{let t=US(e);return t.phase===`left`?L(NS,{}):t.phase===`connecting`?L(MS,{}):e?L(BS,{class:`flex items-center justify-center`,children:[L(zS,{sessionId:t.replicaId}),L(xg,{sessionId:t.replicaId})]}):L(`div`,{class:`relative w-full h-full`,children:[L(Cg,{automirror:!0,sessionId:t.replicaId,type:`video`,fit:`cover`,className:`absolute inset-0 w-full h-full object-cover ${t.videoState.isOff?`hidden`:``}`}),L(xg,{sessionId:t.replicaId})]})}),GS=Ea(({onLeave:e})=>{let{config:t}=Ev(),n=t.value.customization.conversation.modality===`audio`;return L(`div`,{class:`@container/pip w-full h-full`,children:L(`div`,{class:`relative w-full h-full overflow-hidden bg-linear-to-br from-base-300 to-base-200 text-base-content`,children:[L(`div`,{class:`relative w-full h-full z-5`,children:L(WS,{isAudioOnly:n})}),L(`div`,{class:`absolute bottom-4 w-full inset-x-0 z-20 flex justify-center items-center gap-2 @max-mobile:gap-1`,children:[L(gS,{}),!n&&L(_S,{}),L(`button`,{type:`button`,class:`btn btn-control btn-error`,onClick:e,"aria-label":`Leave call`,children:L(nx,{name:`leave`,"aria-label":`Leave Call`})})]})]})})});function KS(e,t){return e<=0||t<=0?!1:e/t<.75}var qS=Ea(({personaSessionId:e,localSessionId:t,isScreenSharing:n,avatarOff:r,videoRef:i})=>{let a=N(null),o=i??a,[s,c]=j(0),[l,u]=j(0),d=F(({aspectRatio:e})=>c(e),[]);M(()=>{let e=o.current;if(!e||typeof ResizeObserver>`u`)return;let t=new ResizeObserver(e=>{let{width:t,height:n}=e[e.length-1].contentRect;u(n>0?t/n:0)});return t.observe(e),()=>t.disconnect()},[o]);let f=n?t??``:e,p=!n&&r,m=!n&&KS(s,l),h=n||m;return L(k,{children:[m&&L(Cg,{sessionId:e,type:`video`,fit:`cover`,"aria-hidden":`true`,className:`pointer-events-none absolute inset-0 w-full h-full object-cover scale-110 blur-xl brightness-[0.55] ${p?`hidden`:``}`}),L(Cg,{ref:o,automirror:!0,sessionId:f,type:n?`screenVideo`:`video`,fit:h?`contain`:`cover`,onResize:n?void 0:d,className:`absolute inset-0 w-full h-full transition-all ${h?`object-contain`:`object-cover`} ${p?`hidden`:``}`})]})}),JS=new Set([`mcp-ui.tavus.io`,`mcp-ui.tavus-preview.io`]),YS=[`.sandbox-tavus.io`],XS=new Set([`tavusapi.com`]);function ZS(e){let t;try{t=new URL(e)}catch{return!1}return eC(t)?!0:t.protocol===`https:`?JS.has(t.hostname)?!0:YS.some(e=>t.hostname.endsWith(e)):!1}function QS(e){return ZS(e)}function $S(e){let t;try{t=new URL(e)}catch{return!1}return tC(t)?!0:t.protocol===`https:`&&XS.has(t.hostname)}function eC(e){return tC(e)}function tC(e){return!nC()||e.protocol!==`http:`&&e.protocol!==`https:`?!1:[`localhost`,`127.0.0.1`,`::1`,`[::1]`].includes(e.hostname)}function nC(){try{let e=globalThis.location?.hostname;return typeof e==`string`&&[`localhost`,`127.0.0.1`,`::1`,`[::1]`].includes(e)}catch{return!1}}async function rC(e){try{await e.teardownResource({},{timeout:1e3})}catch{}try{await e.close?.()}catch{}}var iC=`tavus.canvas.interaction`,aC=[`safe-area-right`,`safe-area-left`,`safe-area-bottom`,`full`],oC=`safe-area-right`,sC={x:275/1280,y:111/720,width:730/1280,height:609/720},cC={type:`snapshot_mirror`};function lC(e){return jC(e)?e.message_type===`conversation`&&e.event_type===`conversation.tool_call`&&typeof e.conversation_id==`string`&&jC(e.properties):!1}function uC(e){if(!jC(e))return null;let t=GC(e,`component`),n=GC(e,`component_version`),r=GC(e,`sandbox_url`),i=JC(e,`mcp_server_url`,QS),a=JC(e,`api_base_url`,$S),o=JC(e,`interaction_url`,$S),s=FC(e.layout),c=e.version;return c!==1||!t||!n||!r||!ZS(r)||i===null||a===null||o===null||s===null?null:{version:c,component:t,component_version:n,resource_uri:GC(e,`resource_uri`),sandbox_url:r,mcp_server_url:i,mcp_tool_name:GC(e,`mcp_tool_name`),api_base_url:a,interaction_url:o,layout:s,host_context:jC(e.host_context)?e.host_context:void 0}}function dC(e){if(e===void 0)return{ok:!0,value:{}};if(jC(e))return{ok:!0,value:e};if(typeof e!=`string`)return{ok:!1,error:Error(`Magic Canvas tool arguments must be an object or JSON string.`)};try{let t=JSON.parse(e);return jC(t)?{ok:!0,value:t}:{ok:!1,error:Error(`Magic Canvas tool arguments must decode to an object.`)}}catch(e){return{ok:!1,error:MC(e)}}}function fC(e){let t=e.properties.name;if(t!==`canvas_clear`&&t!==`update_component`)return null;let n=dC(e.properties.arguments);if(!n.ok)throw n.error;if(t===`canvas_clear`){let t=n.value.tool_call_id,r=n.value.reason;if(t!==void 0&&typeof t!=`string`)throw Error(`Magic Canvas clear tool_call_id must be a string when provided.`);if(r!==void 0&&typeof r!=`string`)throw Error(`Magic Canvas clear reason must be a string when provided.`);return{kind:`clear`,conversation_id:e.conversation_id,tool_call_id:t,reason:r}}let r=n.value.tool_call_id,i=n.value.updates;if(typeof r!=`string`||r.length===0)throw Error(`Magic Canvas update_component requires a target tool_call_id.`);if(!jC(i))throw Error(`Magic Canvas update_component requires an object updates payload.`);return{kind:`update`,conversation_id:e.conversation_id,tool_call_id:r,updates:i}}var pC=[`safe-area-left`,`safe-area-right`];function mC(e){let t=pC.includes(e.preferred_slot)?e.preferred_slot:oC;return t===e.preferred_slot&&e.display_mode===`inline`?e:{...e,preferred_slot:t,display_mode:`inline`}}function hC(e){return e.display_mode===`fullscreen`?`full`:e.preferred_slot}function gC(e,t){return[t]}function _C(e,t){switch(t.kind){case`show`:{let n=e.find(e=>e.id===t.instance.id),r=n?{...t.instance,revision:n.revision+1}:t.instance;return gC(e.filter(e=>e.id!==t.instance.id),r)}case`update`:{let n=e=>e.conversation_id===t.conversation_id&&e.tool_call_id===t.tool_call_id,r=DC(t.updates),i,a=e.map(e=>{if(!n(e))return e;let t={...e,arguments:{...e.arguments,...r.componentArguments},layout:mC({preferred_slot:r.preferredSlot??e.layout.preferred_slot,display_mode:r.displayMode??e.layout.display_mode,avoid_safe_area:r.avoidSafeArea??e.layout.avoid_safe_area,safe_area:r.safeArea??e.layout.safe_area,backdrop:r.backdrop??e.layout.backdrop}),revision:e.revision+1};return i=t,t});if(i===void 0)return a;let o=e.find(n);return o&&hC(o.layout)===hC(i.layout)?a:gC(a.filter(e=>!n(e)),i)}case`clear`:return t.tool_call_id?e.filter(e=>!(e.conversation_id===t.conversation_id&&e.tool_call_id===t.tool_call_id)):e.filter(e=>e.conversation_id!==t.conversation_id)}}function vC(e){if(!jC(e)||!Array.isArray(e.content))return null;for(let t of e.content){if(!jC(t))continue;let e=(jC(t._meta)?t._meta:null)?.[iC];if(jC(e))return YC(e)}return null}function yC(e,t){let n=t.type,r=t.value;if(!n)throw Error(`Magic Canvas interaction is missing type.`);if(r===void 0)throw Error(`Magic Canvas interaction is missing value.`);return{interaction_id:t.interaction_id??AC(e.tool_call_id,n),conversation_id:e.conversation_id,tool_call_id:e.tool_call_id,component:t.component??e.canvas_config.component,component_version:t.component_version??e.canvas_config.component_version,type:n,value:r,metadata:jC(t.metadata)?t.metadata:{}}}function bC(e){return e.type===`dismiss`||e.type===`clear`?!0:e.type!==`submit`&&e.type!==`skip`?!1:e.component===`canvas.question`||e.component===`canvas.input`||e.component===`canvas.calendar`}function xC(e){return!jC(e)||!Array.isArray(e.content)?``:e.content.map(e=>jC(e)&&e.type===`text`&&typeof e.text==`string`?e.text:``).filter(Boolean).join(`
53
+ `).trim()}function SC(e,t){let n=jC(t.structuredContent)?t.structuredContent:void 0,r=NC(t.content),i=typeof n?.state==`string`?n.state:`updated`,a=typeof n?.summary==`string`?n.summary:r,o=[`Magic Canvas state update for ${e.canvas_config.component} (${e.tool_call_id}).`,`State: ${i}.`];return a&&o.push(`Summary: ${a}`),n&&o.push(`Structured state: ${PC(n)}`),r&&r!==a&&o.push(r),o.join(`
54
+ `)}function CC({conversationId:e,toolCallId:t,args:n,canvasConfig:r}){let i=DC(n);return{id:t,conversation_id:e,tool_call_id:t,arguments:i.componentArguments,canvas_config:r,layout:mC({preferred_slot:i.preferredSlot??r.layout?.preferred_slot??OC(r.component),display_mode:i.displayMode??`inline`,avoid_safe_area:i.avoidSafeArea??r.layout?.avoid_safe_area??!0,safe_area:i.safeArea??r.layout?.safe_area??sC,backdrop:i.backdrop??r.layout?.backdrop??cC}),revision:0}}function wC(e,t){let n=e.layout.display_mode;return{...e.layout,display_mode:n,viable_slot:n===`fullscreen`?`full`:EC(e.layout.preferred_slot,t)}}function TC(e,t){let n=e.filter(e=>!e.avoid_safe_area||e.display_mode===`fullscreen`?!1:e.viable_slot===`safe-area-left`||e.viable_slot===`safe-area-right`),r=n.some(e=>e.viable_slot===`safe-area-left`),i=n.some(e=>e.viable_slot===`safe-area-right`);if(r&&i)return{active:!1,video_shift_x:0,backdrop:cC};let a=[...n].reverse()[0];if(!a||t.width<900)return{active:!1,video_shift_x:0,backdrop:cC};let o=Math.min(448,Math.max(0,t.width-32)),s=a.safe_area,c=s.x*t.width,l=(s.x+s.width)*t.width,u=Math.min(360,t.width*.3),d=0;return d=a.viable_slot===`safe-area-left`?qC(16+o+24-c,0,u):-qC(l-(t.width-16-o-24),0,u),{active:!0,side:a.viable_slot===`safe-area-left`?`left`:`right`,video_shift_x:Math.round(d),safe_area:s,backdrop:a.backdrop}}function EC(e,t){return e===`full`||e===`safe-area-bottom`&&t.visualViewportHeight!==void 0&&t.visualViewportHeight<t.height*.75?`full`:(e===`safe-area-left`||e===`safe-area-right`)&&t.width<768&&t.height>=t.width?`safe-area-bottom`:e}function DC(e){let t={};for(let[n,r]of Object.entries(e))n===`layout`||n===`preferred_slot`||n===`preferredSlot`||n===`display_mode`||n===`displayMode`||n===`presentation`||n===`fullscreen`||n===`avoid_safe_area`||n===`avoidSafeArea`||n===`safe_area`||n===`safeArea`||n===`backdrop`||(t[n]=r);return{componentArguments:t,preferredSlot:IC(e.layout)??IC(e.preferred_slot)??IC(e.preferredSlot),displayMode:LC(e),avoidSafeArea:RC(e),safeArea:zC(e),backdrop:BC(e)}}function OC(e){switch(e){case`canvas.alert`:return`safe-area-bottom`;case`canvas.chart`:case`canvas.image`:case`canvas.video`:return`full`;default:return oC}}function kC(e,t){let n=t?.displayScale??1;if(e.display_mode===`fullscreen`||e.viable_slot===`full`)return{maxWidth:void 0,maxHeight:void 0,displayScale:n};let r=t?.maxHeight??720;return e.viable_slot===`safe-area-bottom`?{maxWidth:720,maxHeight:r,displayScale:n}:{width:384,maxHeight:r,displayScale:n}}function AC(e,t){return`ci_${e.replace(/[^a-zA-Z0-9_-]/g,`_`)}_${t}_${globalThis.crypto?.randomUUID?.()??Math.random().toString(36).slice(2,10)}`}function jC(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function MC(e){return e instanceof Error?e:Error(String(e))}function NC(e){return Array.isArray(e)?e.map(e=>jC(e)&&e.type===`text`&&typeof e.text==`string`?e.text:``).filter(Boolean).join(`
55
+ `).trim():``}function PC(e){let t=JSON.stringify(e);return t?t.length<=2e3?t:`${t.slice(0,2e3)}...`:`{}`}function FC(e){if(e===void 0)return;if(!jC(e))return null;let t=IC(e),n=VC(e.safe_area??e.safeArea),r=HC(e.backdrop);return n===null||r===null?null:{...t?{preferred_slot:t}:{},...UC(e.avoid_safe_area??e.avoidSafeArea,`avoid_safe_area`),...n?{safe_area:n}:{},...r?{backdrop:r}:{}}}function IC(e){if(typeof e==`string`&&WC(e))return e;if(!jC(e))return;let t=e.preferred_slot??e.preferredSlot??e.slot;return typeof t==`string`&&WC(t)?t:void 0}function LC(e){if(e.presentation===!0||e.fullscreen===!0)return`fullscreen`;if(e.presentation===!1||e.fullscreen===!1)return`inline`;let t=e.display_mode??e.displayMode;return t===`fullscreen`||t===`inline`?t:void 0}function RC(e){let t=jC(e.layout)?e.layout:void 0,n=e.avoid_safe_area??e.avoidSafeArea??t?.avoid_safe_area??t?.avoidSafeArea;return typeof n==`boolean`?n:void 0}function zC(e){let t=jC(e.layout)?e.layout:void 0;return VC(e.safe_area??e.safeArea??t?.safe_area??t?.safeArea)??void 0}function BC(e){let t=jC(e.layout)?e.layout:void 0;return HC(e.backdrop??t?.backdrop)??void 0}function VC(e){if(e===void 0)return;if(!jC(e))return null;let t=KC(e,`x`),n=KC(e,`y`),r=KC(e,`width`),i=KC(e,`height`);return t===void 0||n===void 0||r===void 0||i===void 0||t<0||n<0||r<=0||i<=0||t+r>1.001||n+i>1.001?null:{x:qC(t,0,1),y:qC(n,0,1),width:qC(r,0,1),height:qC(i,0,1)}}function HC(e){if(e===void 0)return;if(e===`snapshot_mirror`||e===`none`)return{type:e};if(!jC(e))return null;let t=e.type;return t===`snapshot_mirror`||t===`none`?{type:t}:null}function UC(e,t){return typeof e==`boolean`?{[t]:e}:{}}function WC(e){return aC.includes(e)}function GC(e,t){let n=e[t];return typeof n==`string`&&n.length>0?n:void 0}function KC(e,t){let n=e[t];return typeof n==`number`&&Number.isFinite(n)?n:void 0}function qC(e,t,n){return Math.min(Math.max(e,t),n)}function JC(e,t,n){let r=GC(e,t);if(r)return n(r)?r:null}function YC(e){return e.interaction_id!==void 0&&typeof e.interaction_id!=`string`||e.component!==void 0&&typeof e.component!=`string`||e.component_version!==void 0&&typeof e.component_version!=`string`||e.type!==void 0&&typeof e.type!=`string`||e.metadata!==void 0&&!jC(e.metadata)?null:e}var XC=`tavus-deployment magic-canvas/0.0.0`;function ZC(e){if(!lC(e)||e.canvas_config===void 0||e.canvas_config===null)return null;let t=uC(e.canvas_config),n=e.properties.tool_call_id;if(!t)return null;if(!n)throw Error(`Received Magic Canvas tool call without tool_call_id.`);let r=dC(e.properties.arguments);if(!r.ok)throw r.error;return CC({conversationId:e.conversation_id,toolCallId:n,args:r.value,canvasConfig:t})}function QC(e){if(!lC(e))return null;if(e.canvas_config!==void 0&&e.canvas_config!==null){let t=ZC(e);return t?{kind:`show`,instance:t}:null}return fC(e)}function $C(e){return{body:{interaction_id:e.interaction_id,tool_call_id:e.tool_call_id,component:e.component,component_version:e.component_version,type:e.type,value:e.value,metadata:e.metadata}}}function ew(e,t){return{theme:e.theme,displayMode:t?.display_mode??`inline`,availableDisplayModes:[`inline`,`fullscreen`],...t?{containerDimensions:kC(t),layout:{preferred_slot:t.preferred_slot,viable_slot:t.viable_slot,avoid_safe_area:t.avoid_safe_area,safe_area:t.safe_area,backdrop:t.backdrop}}:{},platform:`web`,userAgent:XC,styles:{variables:tw(e.cssVars)}}}function tw(e){return{"--border-radius-md":e[`--radius-box`]??e[`--tavus-boxes-radius`]??`0.5rem`,"--border-radius-sm":e[`--radius-field`]??e[`--tavus-field-radius`]??`0.375rem`,"--border-radius-xs":e[`--radius-selector`]??`0.25rem`,"--border-radius-lg":e[`--radius-box`]??e[`--tavus-boxes-radius`]??`0.75rem`,"--border-width-regular":e[`--border`]??e[`--tavus-border-width`]??`1px`,"--font-text-sm-size":`0.875rem`,"--font-text-md-size":`1rem`,...nw(e)}}function nw(e){let t=e[`--color-base-content`],n=e[`--color-base-100`],r=e[`--color-base-200`],i=e[`--color-base-300`],a=e[`--color-error`],o={},s=(e,t)=>{t&&(o[e]=t)},c=(e,t,n)=>e&&n?`color-mix(in oklch, ${e} ${t}%, ${n})`:void 0;return s(`--color-background-primary`,n),s(`--color-background-secondary`,r),s(`--color-border-secondary`,i),s(`--color-border-primary`,c(t,28,n)),s(`--color-text-primary`,t),s(`--color-text-secondary`,c(t,62,n)),s(`--color-text-danger`,a),s(`--color-border-danger`,a),o}var rw=24,iw=96;function aw(e=document){let t=Array.from(e.querySelectorAll(`[data-canvas-card]`)).map(e=>e.getBoundingClientRect());return t.length===0?null:{left:Math.min(...t.map(e=>e.left)),right:Math.max(...t.map(e=>e.right)),top:Math.min(...t.map(e=>e.top)),bottom:Math.max(...t.map(e=>e.bottom))}}function ow(e){let t=e?.getRootNode();return t instanceof ShadowRoot?t:document}function sw(e){if(!e)return null;let t=e.getBoundingClientRect();return t.width<=0||t.height<=0?null:{left:t.left,right:t.right,top:t.top,bottom:t.bottom}}function cw(e,t,n,r){if(!t)return!1;let i=r?r.left:0,a=r?r.top:0,o=r?r.right-r.left:globalThis.innerWidth,s=r?r.bottom-r.top:globalThis.innerHeight,c=e?.safe_area??sC,l=i+c.x*o+n,u=i+(c.x+c.width)*o+n,d=a+c.y*s,f=a+(c.y+c.height)*s;return l<t.right&&u>t.left&&d<t.bottom&&f>t.top}function lw(e,t,n){let[r,i]=j(()=>e?aw(ow(n?.current)):null);return at(()=>{if(!e){i(null);return}let t=ow(n?.current),r=()=>i(aw(t)),a=new ResizeObserver(r),o=()=>{for(let e of t.querySelectorAll(`[data-canvas-card]`))a.observe(e)};r(),o(),a.observe(document.documentElement);let s=globalThis.requestAnimationFrame(()=>{r(),o()});return globalThis.addEventListener(`resize`,r),()=>{a.disconnect(),globalThis.removeEventListener(`resize`,r),globalThis.cancelAnimationFrame(s)}},[e,t,n]),e?r:null}function uw(e,t,n){let[r,i]=j(()=>t?sw(e.current):null);return at(()=>{if(!t){i(null);return}let n=()=>i(sw(e.current)),r=new ResizeObserver(n);n(),e.current&&r.observe(e.current),r.observe(document.documentElement);let a=globalThis.requestAnimationFrame(n);return globalThis.addEventListener(`resize`,n),()=>{r.disconnect(),globalThis.removeEventListener(`resize`,n),globalThis.cancelAnimationFrame(a)}},[t,n,e]),t?r:null}function dw(e,t,n,r,i,a){let o=e?.side??(n===`safe-area-left`?`left`:n===`safe-area-right`?`right`:null);return{usePip:o!=null&&(t===`pip`||t===`auto`&&cw(e,r,i,a)),side:o}}function fw(e,t=document,n){let r=n?n.left:0,i=n?n.right:globalThis.innerWidth,a=n?n.top:0,o=n?n.bottom:globalThis.innerHeight,s=i-r,c=o-a,l=Array.from(t.querySelectorAll(`[data-canvas-card]`)).map(e=>e.getBoundingClientRect()),u,d,f,p;if(l.length>0){let t=Math.min(...l.map(e=>e.left)),n=Math.max(...l.map(e=>e.right));f=Math.min(...l.map(e=>e.top)),p=Math.max(...l.map(e=>e.bottom)),[u,d]=e===`right`?[r,t]:[n,i]}else{let t=Math.min(448,Math.max(0,s-32));[u,d]=e===`right`?[r,i-16-t]:[r+16+t,i],f=a,p=o}let m=d-u>=144&&p-f>=iw&&u>=r&&d<=i;if(l.length>0&&!m){let t=Math.min(448,Math.max(0,s-32));[u,d]=e===`right`?[r,i-16-t]:[r+16+t,i],f=a,p=o}let h=Math.max(0,d-u-rw*2),g=Math.max(iw,Math.min(h,c-rw*2));return{centerX:(u+d)/2-r,centerY:(f+p)/2-a,diameter:g}}var pw=`560ms linear(0, 0, .0001, .0002, .0003, .0005, .0007, .001, .0013, .0016, .002, .0024, .0029, .0033, .0039, .0044, .005, .0057, .0063, .007, .0079, .0086, .0094, .0103, .0112, .0121, .0132 1.84%, .0153, .0175, .0201, .0226, .0253, .0283, .0313, .0345, .038, .0416, .0454, .0493, .0535, .0576, .0621, .0667, .0714, .0764, .0816 5.04%, .0897, .098 5.62%, .1071, .1165, .1263 6.56%, .137, .1481 7.25%, .1601 7.62%, .1706 7.94%, .1819 8.28%, .194, .2068 9.02%, .2331 9.79%, .2898 11.44%, .3151 12.18%, .3412 12.95%, .3533, .365 13.66%, .3786, .3918, .4045, .4167, .4288, .4405, .452, .4631 16.72%, .4759, .4884, .5005, .5124, .5242, .5354, .5467, .5576, .5686, .5791, .5894, .5995, .6094, .6194, .6289, .6385, .6477, .6569, .6659 24.45%, .6702, .6747, .6789, .6833, .6877, .6919, .696, .7002, .7043, .7084, .7125, .7165, .7205, .7244, .7283, .7321, .7358, .7396, .7433, .7471, .7507, .7544, .7579, .7615, .7649, .7685, .7718, .7752, .7786, .782, .7853, .7885, .7918, .7951, .7982, .8013, .8043, .8075, .8104, .8135, .8165, .8195, .8224, .8253, .8281, .8309, .8336, .8365, .8391, .8419, .8446, .8472, .8499, .8524, .855, .8575, .8599, .8625 37.27%, .8651, .8678, .8703, .8729, .8754, .8779, .8803, .8827, .8851, .8875, .8898, .892, .8942, .8965, .8987, .9009, .903, .9051, .9071, .9092, .9112, .9132, .9151, .9171, .919, .9209, .9227, .9245, .9262, .928, .9297, .9314, .9331, .9347, .9364, .9379, .9395, .941, .9425, .944, .9454, .9469, .9483, .9497, .951, .9524, .9537, .955, .9562, .9574, .9586, .9599, .961, .9622, .9633, .9644, .9655, .9665, .9676, .9686, .9696, .9705, .9715, .9724, .9733, .9742, .975, .9758, .9766, .9774, .9782, .9789, .9796, .9804, .9811, .9817, .9824, .9831, .9837, .9843, .9849, .9855, .986, .9866, .9871, .9877, .9882, .9887, .9892, .9896 70.56%, .9905 71.67%, .9914 72.82%, .9922, .9929 75.2%, .9936 76.43%, .9942 77.71%, .9948 79.03%, .9954 80.39%, .9959 81.81%, .9963 83.28%, .9968 84.82%, .9972 86.41%, .9975 88.07%, .9979 89.81%, .9982 91.64%, .9984 93.56%, .9987 95.58%, .9989 97.72%, .9991)`;function mw(e,t){let n=Math.abs(t)/2;return e===`left`?`${n}px center`:`calc(100% - ${n}px) center`}function hw(e,t,n){let[r,i]=j(()=>e&&t?fw(t,ow(n?.current),sw(n?.current)):null);return at(()=>{if(!e||!t){i(null);return}let r=ow(n?.current),a=()=>i(fw(t,r,sw(n?.current))),o=new ResizeObserver(a),s=()=>{for(let e of r.querySelectorAll(`[data-canvas-card]`))o.observe(e)};a(),s(),n?.current&&o.observe(n.current),o.observe(document.documentElement);let c=globalThis.requestAnimationFrame(()=>{a(),s()});return globalThis.addEventListener(`resize`,a),()=>{o.disconnect(),globalThis.removeEventListener(`resize`,a),globalThis.cancelAnimationFrame(c)}},[e,t,n]),e&&t?r:null}function gw(e,t){let[n,r]=j(null);return at(()=>{if(!t){r(null);return}let n=e.current;if(!n)return;let i=()=>{let e=n.clientWidth,t=n.clientHeight;r(e&&t?{width:e,height:t}:null)},a=new ResizeObserver(i);return a.observe(n),i(),()=>a.disconnect()},[t,e]),t?n:null}var _w=1;function vw(e,t,n){return Math.min(Math.max(e,t),n)}function yw(e,t,n,r){let i=Math.min(e.diameter/t.height,1),a=r?.safe_area??sC,o=((a.x+a.width/2)*t.width+n)*i,s=(a.y+a.height/2)*t.height*i,c=e.diameter/2;return{scale:i,tx:vw(e.centerX-o,e.centerX+c-t.width*i,e.centerX-c),ty:vw(e.centerY-s,e.centerY+c-t.height*i,e.centerY-c)}}var bw=[`cx`,`cy`,`r`,`tx`,`ty`,`s`,`shift`];function xw(e,t,n,r,i){if(!n)return null;let{width:a,height:o}=n,s={x:a/2,y:o/2},c=null;if(e&&(c=yw(e,n,r,i),s={x:(e.centerX-c.tx)/c.scale,y:(e.centerY-c.ty)/c.scale}),t&&c&&e)return{cx:s.x,cy:s.y,r:e.diameter/2/c.scale,tx:c.tx,ty:c.ty,s:c.scale,shift:r};let l=Math.hypot(Math.max(s.x,a-s.x),Math.max(s.y,o-s.y));return{cx:s.x,cy:s.y,r:l*1.1,tx:0,ty:0,s:1,shift:r}}function Sw(e,t,n){let r=N(null),i=N(e),a=N(n),o=N(0),s=N(0);i.current=e,a.current=n,M(()=>{let e=i.current;if(!e)return;if(!r.current||Cw()){r.current={values:{...e},velocity:{cx:0,cy:0,r:0,tx:0,ty:0,s:0,shift:0}},a.current(e,!0);return}if(o.current)return;let n=Math.max(t,160)/4e3;s.current=performance.now();let c=e=>{o.current=0;let t=i.current,l=r.current;if(!t||!l)return;let u=Math.min((e-s.current)/1e3,1/30);s.current=e;let d=!0;for(let e of bw){let r=(t[e]-l.values[e])/(n*n)-2/n*l.velocity[e],i=l.velocity[e]+r*u,a=l.values[e]+i*u,o=e===`s`?.001:.25;Math.abs(t[e]-a)<o&&Math.abs(i)*n<o?(l.values[e]=t[e],l.velocity[e]=0):(l.values[e]=a,l.velocity[e]=i,d=!1)}a.current(l.values,d),d||(o.current=globalThis.requestAnimationFrame(c))};o.current=globalThis.requestAnimationFrame(c)},[e?bw.map(t=>Math.round(e[t]*100)).join():``,t]),M(()=>()=>{o.current&&globalThis.cancelAnimationFrame(o.current)},[])}function Cw(){return globalThis.matchMedia?.(`(prefers-reduced-motion: reduce)`).matches??!1}function ww({geom:e,visible:t}){return L(`div`,{"aria-hidden":`true`,"data-morph":`ring`,class:`pointer-events-none absolute z-10 rounded-full`,style:{top:`${e.centerY-e.diameter/2}px`,left:`${e.centerX-e.diameter/2}px`,width:`${e.diameter}px`,height:`${e.diameter}px`,boxShadow:`0 0 0 3px rgb(255 255 255 / 12%), 0 18px 50px rgb(0 0 0 / 55%)`,opacity:+!!t,transition:`opacity 240ms ease-out`}})}function Tw(e,t){let n=t>=0?`left`:`right`,r=N({side:n,shift:t});M(()=>{e&&(r.current={side:n,shift:t})},[e,n,t]);let i=e?n:r.current.side;return{side:i,transformOrigin:mw(i,e?t:r.current.shift),translateX:e?0:-r.current.shift}}function Ew(e,t,n){return`${e.side??``}:${e.active}:${t}:${n??``}`}function Dw({snapshotUrl:e,transformOrigin:t}){return L(`div`,{class:`absolute inset-0 bg-cover bg-center`,style:{backgroundImage:`url("${e}")`,transform:`scaleX(-1)`,transformOrigin:t}})}function Ow({snapshotUrl:e,translateX:t,transition:n,transformOrigin:r}){return L(`div`,{"aria-hidden":`true`,"data-morph":`mirror`,class:`pointer-events-none absolute z-0 overflow-hidden`,style:{inset:`0 0`,transform:`translate3d(${t}px, 0, 0)`,transition:`transform ${n}`,willChange:`transform`},children:L(Dw,{snapshotUrl:e,transformOrigin:r})})}function kw({ambient:e,usePip:t,transition:n}){return e===`none`?null:L(`div`,{"aria-hidden":`true`,"data-morph":`ambient`,class:`pointer-events-none absolute inset-0 z-0`,style:{opacity:+!!t,transition:`opacity ${n}`,background:e===`darker`?`rgb(0 0 0 / 40%)`:`rgb(0 0 0 / 15%)`}})}function Aw({morphCapable:e,snapshotUrl:t,mirrorSide:n,videoShiftX:r,transition:i,sceneRef:a,videoWrapRef:o,fill:s,videoRef:c}){return L(`div`,{ref:a,"data-morph":`scene`,class:`absolute inset-0`,style:e?{transformOrigin:`top left`}:void 0,children:L(`div`,{ref:o,class:`absolute inset-0`,style:e?void 0:{transform:`translate3d(${r}px, 0, 0)`,transition:`transform ${i}`},children:[s(c),e&&t!==null&&L(`div`,{"aria-hidden":`true`,"data-morph":`window-mirror`,class:`absolute top-0 bottom-0 w-full`,style:n===`right`?{left:`calc(100% - ${_w}px)`}:{right:`calc(100% - ${_w}px)`},children:L(Dw,{snapshotUrl:t,transformOrigin:`center`})})]})})}function jw({canvasLayoutEffect:e,smartSidecarActive:t,isScreenSharing:n,fill:r,captureSnapshot:i,transition:a=pw,transitionMs:o=560,personaMode:s=`shift`,renderedSlot:c=null,ambient:l=`default`,children:u}){let d=N(null),[f,p]=j(null),m=t&&e.backdrop.type===`snapshot_mirror`,h=t?e.video_shift_x:0,g=N(null),_=Ew(e,h,c),{usePip:v,side:y}=dw(e,s,c,lw(s!==`shift`,_,g),h,uw(g,s!==`shift`,_)),b=hw(s!==`shift`,y,g),x=Tw(m,h);M(()=>{if(!m)return;let e=!1,t=0,n,r=0,a=()=>{if(e)return;let t=i(d.current);if(t){p(t);return}r+=1,r<8&&(n=globalThis.setTimeout(a,150))};return typeof globalThis.requestAnimationFrame==`function`?t=globalThis.requestAnimationFrame(a):n=globalThis.setTimeout(a,0),()=>{e=!0,t&&globalThis.cancelAnimationFrame?.(t),n&&globalThis.clearTimeout(n)}},[m,e.side,e.video_shift_x,i]),M(()=>{if(m||f===null)return;let e=globalThis.setTimeout(()=>{p(null)},o);return()=>globalThis.clearTimeout(e)},[m,f,o]);let S=v&&y!=null&&b!=null,C=s!==`shift`,w=gw(g,C),T=f!==null&&!C,E=C&&y!=null,D=N(null),ee=N(null),[te,ne]=j(!0),re=N(!0),O=F((e,t)=>{let n=D.current;n&&(n.style.clipPath=`circle(${e.r}px at ${e.cx}px ${e.cy}px)`,n.style.transform=`translate(${e.tx}px, ${e.ty}px) scale(${e.s})`);let r=ee.current;r&&(r.style.transform=`translate3d(${e.shift}px, 0, 0)`),re.current!==t&&(re.current=t,ne(t))},[]);return Sw(C?xw(b,S,w,h,e):null,o,O),L(`div`,{ref:g,class:`relative w-full h-full overflow-hidden ${n?`flex items-center justify-center`:``}`,children:[T&&f!==null&&L(Ow,{snapshotUrl:f,translateX:x.translateX,transition:a,transformOrigin:x.transformOrigin}),E&&L(kw,{ambient:l,usePip:v,transition:a}),L(`div`,{"data-morph":`fg`,class:`absolute inset-0 z-10`,children:L(Aw,{morphCapable:C,snapshotUrl:f,mirrorSide:x.side,videoShiftX:h,transition:a,sceneRef:D,videoWrapRef:ee,fill:r,videoRef:d})}),C&&b&&L(ww,{geom:b,visible:S&&te}),u]})}var Mw=480,Nw=Ea(({personaSessionId:e,isAudioOnly:t,avatarOff:n,canvasLayoutEffect:r,smartSidecarActive:i})=>{let a=t||n,o=i?r.video_shift_x:0;return L(`div`,{class:`absolute inset-0 overflow-hidden`,children:L(`div`,{class:`absolute top-0 bottom-0`,style:{left:o>0?`${Mw}px`:`0px`,right:o<0?`${Mw}px`:`0px`,transition:`left ${pw}, right ${pw}`},children:[L(Cg,{automirror:!0,sessionId:e,type:`screenVideo`,fit:`contain`,className:`absolute inset-0 w-full h-full object-contain`}),L(`div`,{class:`absolute bottom-4 right-4 aspect-square w-32 @max-mobile:w-24 rounded-box overflow-hidden bg-black/30 z-10`,children:a?L(`div`,{class:`flex w-full h-full items-center justify-center`,children:L(zS,{sessionId:e})}):L(Cg,{automirror:!0,sessionId:e,type:`video`,fit:`cover`,className:`w-full h-full object-cover`})})]})})});function K(e,t,n){function r(n,r){if(n._zod||Object.defineProperty(n,"_zod",{value:{def:r,constr:o,traits:new Set},enumerable:!1}),n._zod.traits.has(e))return;n._zod.traits.add(e),t(n,r);let i=o.prototype,a=Object.keys(i);for(let e=0;e<a.length;e++){let t=a[e];t in n||(n[t]=i[t].bind(n))}}let i=n?.Parent??Object;class a extends i{}Object.defineProperty(a,"name",{value:e});function o(e){var t;let i=n?.Parent?new a:this;r(i,e),(t=i._zod).deferred??(t.deferred=[]);for(let e of i._zod.deferred)e();return i}return Object.defineProperty(o,"init",{value:r}),Object.defineProperty(o,Symbol.hasInstance,{value:t=>n?.Parent&&t instanceof n.Parent?!0:t?._zod?.traits?.has(e)}),Object.defineProperty(o,"name",{value:e}),o}function Pw(e){return e&&Object.assign(Rw,e),Rw}var Fw,Iw,Lw,Rw,zw=a((()=>{Iw=class extends Error{constructor(){super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`)}},Lw=class extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name=`ZodEncodeError`}},(Fw=globalThis).__zod_globalConfig??(Fw.__zod_globalConfig={}),Rw=globalThis.__zod_globalConfig}));function Bw(e){let t=Object.values(e).filter(e=>typeof e==`number`);return Object.entries(e).filter(([e,n])=>t.indexOf(+e)===-1).map(([e,t])=>t)}function Vw(e,t=`|`){return e.map(e=>rT(e)).join(t)}function Hw(e,t){return typeof t==`bigint`?t.toString():t}function Uw(e){return{get value(){{let t=e();return Object.defineProperty(this,"value",{value:t}),t}throw Error(`cached value already set`)}}}function Ww(e){return e==null}function Gw(e){let t=+!!e.startsWith(`^`),n=e.endsWith(`$`)?e.length-1:e.length;return e.slice(t,n)}function Kw(e,t){let n=e/t,r=Math.round(n),i=2**-52*Math.max(Math.abs(n),1);return Math.abs(n-r)<i?0:n-r}function qw(e,t,n){let r;Object.defineProperty(e,t,{get(){if(r!==bT)return r===void 0&&(r=bT,r=n()),r},set(n){Object.defineProperty(e,t,{value:n})},configurable:!0})}function Jw(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function Yw(...e){let t={};for(let n of e){let e=Object.getOwnPropertyDescriptors(n);Object.assign(t,e)}return Object.defineProperties({},t)}function Xw(e){return JSON.stringify(e)}function Zw(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,``).replace(/[\s_-]+/g,`-`).replace(/^-+|-+$/g,``)}function Qw(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function $w(e){if(Qw(e)===!1)return!1;let t=e.constructor;if(t===void 0||typeof t!=`function`)return!0;let n=t.prototype;return!(Qw(n)===!1||Object.prototype.hasOwnProperty.call(n,`isPrototypeOf`)===!1)}function eT(e){return $w(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}function tT(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function nT(e,t,n){let r=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(r._zod.parent=e),r}function q(e){let t=e;if(!t)return{};if(typeof t==`string`)return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error==`string`?{...t,error:()=>t.error}:t}function rT(e){return typeof e==`bigint`?e.toString()+`n`:typeof e==`string`?`"${e}"`:`${e}`}function iT(e){return Object.keys(e).filter(t=>e[t]._zod.optin===`optional`&&e[t]._zod.optout===`optional`)}function aT(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw Error(`.pick() cannot be used on object schemas containing refinements`);return nT(e,Yw(e._zod.def,{get shape(){let e={};for(let r in t){if(!(r in n.shape))throw Error(`Unrecognized key: "${r}"`);t[r]&&(e[r]=n.shape[r])}return Jw(this,`shape`,e),e},checks:[]}))}function oT(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw Error(`.omit() cannot be used on object schemas containing refinements`);return nT(e,Yw(e._zod.def,{get shape(){let r={...e._zod.def.shape};for(let e in t){if(!(e in n.shape))throw Error(`Unrecognized key: "${e}"`);t[e]&&delete r[e]}return Jw(this,`shape`,r),r},checks:[]}))}function sT(e,t){if(!$w(t))throw Error(`Invalid input to extend: expected a plain object`);let n=e._zod.def.checks;if(n&&n.length>0){let n=e._zod.def.shape;for(let e in t)if(Object.getOwnPropertyDescriptor(n,e)!==void 0)throw Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}return nT(e,Yw(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t};return Jw(this,`shape`,n),n}}))}function cT(e,t){if(!$w(t))throw Error(`Invalid input to safeExtend: expected a plain object`);return nT(e,Yw(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t};return Jw(this,`shape`,n),n}}))}function lT(e,t){if(e._zod.def.checks?.length)throw Error(`.merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.`);return nT(e,Yw(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t._zod.def.shape};return Jw(this,`shape`,n),n},get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]}))}function uT(e,t,n){let r=t._zod.def.checks;if(r&&r.length>0)throw Error(`.partial() cannot be used on object schemas containing refinements`);return nT(t,Yw(t._zod.def,{get shape(){let r=t._zod.def.shape,i={...r};if(n)for(let t in n){if(!(t in r))throw Error(`Unrecognized key: "${t}"`);n[t]&&(i[t]=e?new e({type:`optional`,innerType:r[t]}):r[t])}else for(let t in r)i[t]=e?new e({type:`optional`,innerType:r[t]}):r[t];return Jw(this,`shape`,i),i},checks:[]}))}function dT(e,t,n){return nT(t,Yw(t._zod.def,{get shape(){let r=t._zod.def.shape,i={...r};if(n)for(let t in n){if(!(t in i))throw Error(`Unrecognized key: "${t}"`);n[t]&&(i[t]=new e({type:`nonoptional`,innerType:r[t]}))}else for(let t in r)i[t]=new e({type:`nonoptional`,innerType:r[t]});return Jw(this,`shape`,i),i}}))}function fT(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue!==!0)return!0;return!1}function pT(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue===!1)return!0;return!1}function mT(e,t){return t.map(t=>{var n;return(n=t).path??(n.path=[]),t.path.unshift(e),t})}function hT(e){return typeof e==`string`?e:e?.message}function gT(e,t,n){let r=e.message?e.message:hT(e.inst?._zod.def?.error?.(e))??hT(t?.error?.(e))??hT(n.customError?.(e))??hT(n.localeError?.(e))??`Invalid input`,{inst:i,continue:a,input:o,...s}=e;return s.path??=[],s.message=r,t?.reportInput&&(s.input=o),s}function _T(e){return Array.isArray(e)?`array`:typeof e==`string`?`string`:`unknown`}function vT(e){let t=typeof e;switch(t){case`number`:return Number.isNaN(e)?`nan`:`number`;case`object`:{if(e===null)return`null`;if(Array.isArray(e))return`array`;let t=e;if(t&&Object.getPrototypeOf(t)!==Object.prototype&&`constructor`in t&&t.constructor)return t.constructor.name}}return t}function yT(...e){let[t,n,r]=e;return typeof t==`string`?{message:t,code:`custom`,input:n,inst:r}:{...t}}var bT,xT,ST,CT,wT,TT=a((()=>{zw(),bT=Symbol(`evaluating`),xT=`captureStackTrace`in Error?Error.captureStackTrace:(...e)=>{},ST=Uw(()=>{if(Rw.jitless||typeof navigator<`u`&&navigator?.userAgent?.includes(`Cloudflare`))return!1;try{return Function(``),!0}catch{return!1}}),CT=new Set([`string`,`number`,`symbol`]),wT={safeint:[-(2**53-1),2**53-1],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]}}));function ET(e,t=e=>e.message){let n={},r=[];for(let i of e.issues)i.path.length>0?(n[i.path[0]]=n[i.path[0]]||[],n[i.path[0]].push(t(i))):r.push(t(i));return{formErrors:r,fieldErrors:n}}function DT(e,t=e=>e.message){let n={_errors:[]},r=(e,i=[])=>{for(let a of e.issues)if(a.code===`invalid_union`&&a.errors.length)a.errors.map(e=>r({issues:e},[...i,...a.path]));else if(a.code===`invalid_key`)r({issues:a.issues},[...i,...a.path]);else if(a.code===`invalid_element`)r({issues:a.issues},[...i,...a.path]);else{let e=[...i,...a.path];if(e.length===0)n._errors.push(t(a));else{let r=n,i=0;for(;i<e.length;){let n=e[i];i===e.length-1?(r[n]=r[n]||{_errors:[]},r[n]._errors.push(t(a))):r[n]=r[n]||{_errors:[]},r=r[n],i++}}}};return r(e),n}var OT,kT,AT,jT=a((()=>{zw(),TT(),OT=(e,t)=>{e.name=`$ZodError`,Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:t,enumerable:!1}),e.message=JSON.stringify(t,Hw,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},kT=K(`$ZodError`,OT),AT=K(`$ZodError`,OT,{Parent:Error})})),MT,NT,PT,FT,IT,LT,RT,zT,BT,VT,HT,UT,WT,GT,KT=a((()=>{zw(),jT(),TT(),MT=e=>(t,n,r,i)=>{let a=r?{...r,async:!1}:{async:!1},o=t._zod.run({value:n,issues:[]},a);if(o instanceof Promise)throw new Iw;if(o.issues.length){let t=new((i?.Err)??e)(o.issues.map(e=>gT(e,a,Pw())));throw xT(t,i?.callee),t}return o.value},NT=e=>async(t,n,r,i)=>{let a=r?{...r,async:!0}:{async:!0},o=t._zod.run({value:n,issues:[]},a);if(o instanceof Promise&&(o=await o),o.issues.length){let t=new((i?.Err)??e)(o.issues.map(e=>gT(e,a,Pw())));throw xT(t,i?.callee),t}return o.value},PT=e=>(t,n,r)=>{let i=r?{...r,async:!1}:{async:!1},a=t._zod.run({value:n,issues:[]},i);if(a instanceof Promise)throw new Iw;return a.issues.length?{success:!1,error:new(e??kT)(a.issues.map(e=>gT(e,i,Pw())))}:{success:!0,data:a.value}},FT=PT(AT),IT=e=>async(t,n,r)=>{let i=r?{...r,async:!0}:{async:!0},a=t._zod.run({value:n,issues:[]},i);return a instanceof Promise&&(a=await a),a.issues.length?{success:!1,error:new e(a.issues.map(e=>gT(e,i,Pw())))}:{success:!0,data:a.value}},LT=IT(AT),RT=e=>(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return MT(e)(t,n,i)},zT=e=>(t,n,r)=>MT(e)(t,n,r),BT=e=>async(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return NT(e)(t,n,i)},VT=e=>async(t,n,r)=>NT(e)(t,n,r),HT=e=>(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return PT(e)(t,n,i)},UT=e=>(t,n,r)=>PT(e)(t,n,r),WT=e=>async(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return IT(e)(t,n,i)},GT=e=>async(t,n,r)=>IT(e)(t,n,r)}));function qT(){return new RegExp(sE,`u`)}function JT(e){let t=`(?:[01]\\d|2[0-3]):[0-5]\\d`;return typeof e.precision==`number`?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function YT(e){return RegExp(`^${JT(e)}$`)}function XT(e){let t=JT({precision:e.precision}),n=[`Z`];e.local&&n.push(``),e.offset&&n.push(`([+-](?:[01]\\d|2[0-3]):[0-5]\\d)`);let r=`${t}(?:${n.join(`|`)})`;return RegExp(`^${gE}T(?:${r})$`)}var ZT,QT,$T,eE,tE,nE,rE,iE,aE,oE,sE,cE,lE,uE,dE,fE,pE,mE,hE,gE,_E,vE,yE,bE,xE,SE,CE,wE,TE,EE=a((()=>{ZT=/^[cC][0-9a-z]{6,}$/,QT=/^[0-9a-z]+$/,$T=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,eE=/^[0-9a-vA-V]{20}$/,tE=/^[A-Za-z0-9]{27}$/,nE=/^[a-zA-Z0-9_-]{21}$/,rE=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,iE=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,aE=e=>e?RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,oE=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,sE=`^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`,cE=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,lE=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/,uE=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,dE=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,fE=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,pE=/^[A-Za-z0-9_-]*$/,mE=/^https?$/,hE=/^\+[1-9]\d{6,14}$/,gE=`(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))`,_E=RegExp(`^${gE}$`),vE=e=>{let t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??``}}`:`[\\s\\S]*`;return RegExp(`^${t}$`)},yE=/^-?\d+$/,bE=/^-?\d+(?:\.\d+)?$/,xE=/^(?:true|false)$/i,SE=/^null$/i,CE=/^undefined$/i,wE=/^[^A-Z]*$/,TE=/^[^a-z]*$/})),DE,OE,kE,AE,jE,ME,NE,PE,FE,IE,LE,RE,zE,BE,VE,HE,UE,WE=a((()=>{zw(),EE(),TT(),DE=K(`$ZodCheck`,(e,t)=>{var n;e._zod??={},e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),OE={number:`number`,bigint:`bigint`,object:`date`},kE=K(`$ZodCheckLessThan`,(e,t)=>{DE.init(e,t);let n=OE[typeof t.value];e._zod.onattach.push(e=>{let n=e._zod.bag,r=(t.inclusive?n.maximum:n.exclusiveMaximum)??1/0;t.value<r&&(t.inclusive?n.maximum=t.value:n.exclusiveMaximum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value<=t.value:r.value<t.value)||r.issues.push({origin:n,code:`too_big`,maximum:typeof t.value==`object`?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),AE=K(`$ZodCheckGreaterThan`,(e,t)=>{DE.init(e,t);let n=OE[typeof t.value];e._zod.onattach.push(e=>{let n=e._zod.bag,r=(t.inclusive?n.minimum:n.exclusiveMinimum)??-1/0;t.value>r&&(t.inclusive?n.minimum=t.value:n.exclusiveMinimum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value>=t.value:r.value>t.value)||r.issues.push({origin:n,code:`too_small`,minimum:typeof t.value==`object`?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),jE=K(`$ZodCheckMultipleOf`,(e,t)=>{DE.init(e,t),e._zod.onattach.push(e=>{var n;(n=e._zod.bag).multipleOf??(n.multipleOf=t.value)}),e._zod.check=n=>{if(typeof n.value!=typeof t.value)throw Error(`Cannot mix number and bigint in multiple_of check.`);(typeof n.value==`bigint`?n.value%t.value===BigInt(0):Kw(n.value,t.value)===0)||n.issues.push({origin:typeof n.value,code:`not_multiple_of`,divisor:t.value,input:n.value,inst:e,continue:!t.abort})}}),ME=K(`$ZodCheckNumberFormat`,(e,t)=>{DE.init(e,t),t.format=t.format||`float64`;let n=t.format?.includes(`int`),r=n?`int`:`number`,[i,a]=wT[t.format];e._zod.onattach.push(e=>{let r=e._zod.bag;r.format=t.format,r.minimum=i,r.maximum=a,n&&(r.pattern=yE)}),e._zod.check=o=>{let s=o.value;if(n){if(!Number.isInteger(s)){o.issues.push({expected:r,format:t.format,code:`invalid_type`,continue:!1,input:s,inst:e});return}if(!Number.isSafeInteger(s)){s>0?o.issues.push({input:s,code:`too_big`,maximum:2**53-1,note:`Integers must be within the safe integer range.`,inst:e,origin:r,inclusive:!0,continue:!t.abort}):o.issues.push({input:s,code:`too_small`,minimum:-(2**53-1),note:`Integers must be within the safe integer range.`,inst:e,origin:r,inclusive:!0,continue:!t.abort});return}}s<i&&o.issues.push({origin:`number`,input:s,code:`too_small`,minimum:i,inclusive:!0,inst:e,continue:!t.abort}),s>a&&o.issues.push({origin:`number`,input:s,code:`too_big`,maximum:a,inclusive:!0,inst:e,continue:!t.abort})}}),NE=K(`$ZodCheckMaxLength`,(e,t)=>{var n;DE.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!Ww(t)&&t.length!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag.maximum??1/0;t.maximum<n&&(e._zod.bag.maximum=t.maximum)}),e._zod.check=n=>{let r=n.value;if(r.length<=t.maximum)return;let i=_T(r);n.issues.push({origin:i,code:`too_big`,maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),PE=K(`$ZodCheckMinLength`,(e,t)=>{var n;DE.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!Ww(t)&&t.length!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag.minimum??-1/0;t.minimum>n&&(e._zod.bag.minimum=t.minimum)}),e._zod.check=n=>{let r=n.value;if(r.length>=t.minimum)return;let i=_T(r);n.issues.push({origin:i,code:`too_small`,minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),FE=K(`$ZodCheckLengthEquals`,(e,t)=>{var n;DE.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!Ww(t)&&t.length!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag;n.minimum=t.length,n.maximum=t.length,n.length=t.length}),e._zod.check=n=>{let r=n.value,i=r.length;if(i===t.length)return;let a=_T(r),o=i>t.length;n.issues.push({origin:a,...o?{code:`too_big`,maximum:t.length}:{code:`too_small`,minimum:t.length},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}}),IE=K(`$ZodCheckStringFormat`,(e,t)=>{var n,r;DE.init(e,t),e._zod.onattach.push(e=>{let n=e._zod.bag;n.format=t.format,t.pattern&&(n.patterns??=new Set,n.patterns.add(t.pattern))}),t.pattern?(n=e._zod).check??(n.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:`string`,code:`invalid_format`,format:t.format,input:n.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(r=e._zod).check??(r.check=()=>{})}),LE=K(`$ZodCheckRegex`,(e,t)=>{IE.init(e,t),e._zod.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:`string`,code:`invalid_format`,format:`regex`,input:n.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),RE=K(`$ZodCheckLowerCase`,(e,t)=>{t.pattern??=wE,IE.init(e,t)}),zE=K(`$ZodCheckUpperCase`,(e,t)=>{t.pattern??=TE,IE.init(e,t)}),BE=K(`$ZodCheckIncludes`,(e,t)=>{DE.init(e,t);let n=tT(t.includes),r=new RegExp(typeof t.position==`number`?`^.{${t.position}}${n}`:n);t.pattern=r,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=new Set,t.patterns.add(r)}),e._zod.check=n=>{n.value.includes(t.includes,t.position)||n.issues.push({origin:`string`,code:`invalid_format`,format:`includes`,includes:t.includes,input:n.value,inst:e,continue:!t.abort})}}),VE=K(`$ZodCheckStartsWith`,(e,t)=>{DE.init(e,t);let n=RegExp(`^${tT(t.prefix)}.*`);t.pattern??=n,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=new Set,t.patterns.add(n)}),e._zod.check=n=>{n.value.startsWith(t.prefix)||n.issues.push({origin:`string`,code:`invalid_format`,format:`starts_with`,prefix:t.prefix,input:n.value,inst:e,continue:!t.abort})}}),HE=K(`$ZodCheckEndsWith`,(e,t)=>{DE.init(e,t);let n=RegExp(`.*${tT(t.suffix)}$`);t.pattern??=n,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=new Set,t.patterns.add(n)}),e._zod.check=n=>{n.value.endsWith(t.suffix)||n.issues.push({origin:`string`,code:`invalid_format`,format:`ends_with`,suffix:t.suffix,input:n.value,inst:e,continue:!t.abort})}}),UE=K(`$ZodCheckOverwrite`,(e,t)=>{DE.init(e,t),e._zod.check=e=>{e.value=t.tx(e.value)}})})),GE,KE=a((()=>{GE=class{constructor(e=[]){this.content=[],this.indent=0,this&&(this.args=e)}indented(e){this.indent+=1,e(this),--this.indent}write(e){if(typeof e==`function`){e(this,{execution:`sync`}),e(this,{execution:`async`});return}let t=e.split(`
56
56
  `).filter(e=>e),n=Math.min(...t.map(e=>e.length-e.trimStart().length)),r=t.map(e=>e.slice(n)).map(e=>` `.repeat(this.indent*2)+e);for(let e of r)this.content.push(e)}compile(){let e=Function,t=this?.args,n=[...(this?.content??[``]).map(e=>` ${e}`)];return new e(...t,n.join(`
57
- `))}}})),GE,KE=a((()=>{GE={major:4,minor:4,patch:3}}));function qE(e){if(e===``)return!0;if(/\s/.test(e)||e.length%4!=0)return!1;try{return atob(e),!0}catch{return!1}}function JE(e){if(!dE.test(e))return!1;let t=e.replace(/[-_]/g,e=>e===`-`?`+`:`/`);return qE(t.padEnd(Math.ceil(t.length/4)*4,`=`))}function YE(e,t=null){try{let n=e.split(`.`);if(n.length!==3)return!1;let[r]=n;if(!r)return!1;let i=JSON.parse(atob(r));return!(`typ`in i&&i?.typ!==`JWT`||!i.alg||t&&(!(`alg`in i)||i.alg!==t))}catch{return!1}}function XE(e,t,n){e.issues.length&&t.issues.push(...fT(n,e.issues)),t.value[n]=e.value}function ZE(e,t,n,r,i,a){let o=n in r;if(e.issues.length){if(i&&a&&!o)return;t.issues.push(...fT(n,e.issues))}if(!o&&!i){e.issues.length||t.issues.push({code:`invalid_type`,expected:`nonoptional`,input:void 0,path:[n]});return}e.value===void 0?o&&(t.value[n]=void 0):t.value[n]=e.value}function QE(e){let t=Object.keys(e.shape);for(let n of t)if(!e.shape?.[n]?._zod?.traits?.has(`$ZodType`))throw Error(`Invalid element at key "${n}": expected a Zod schema`);let n=nT(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(n)}}function $E(e,t,n,r,i,a){let o=[],s=i.keySet,c=i.catchall._zod,l=c.def.type,u=c.optin===`optional`,d=c.optout===`optional`;for(let i in t){if(i===`__proto__`||s.has(i))continue;if(l===`never`){o.push(i);continue}let a=c.run({value:t[i],issues:[]},r);a instanceof Promise?e.push(a.then(e=>ZE(e,n,i,t,u,d))):ZE(a,n,i,t,u,d)}return o.length&&n.issues.push({code:`unrecognized_keys`,keys:o,input:t,inst:a}),e.length?Promise.all(e).then(()=>n):n}function eD(e,t,n,r){for(let n of e)if(n.issues.length===0)return t.value=n.value,t;let i=e.filter(e=>!uT(e));return i.length===1?(t.value=i[0].value,i[0]):(t.issues.push({code:`invalid_union`,input:t.value,inst:n,errors:e.map(e=>e.issues.map(e=>mT(e,r,Mw())))}),t)}function tD(e,t){if(e===t||e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(Zw(e)&&Zw(t)){let n=Object.keys(t),r=Object.keys(e).filter(e=>n.indexOf(e)!==-1),i={...e,...t};for(let n of r){let r=tD(e[n],t[n]);if(!r.valid)return{valid:!1,mergeErrorPath:[n,...r.mergeErrorPath]};i[n]=r.data}return{valid:!0,data:i}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};let n=[];for(let r=0;r<e.length;r++){let i=e[r],a=t[r],o=tD(i,a);if(!o.valid)return{valid:!1,mergeErrorPath:[r,...o.mergeErrorPath]};n.push(o.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function nD(e,t,n){let r=new Map,i;for(let n of t.issues)if(n.code===`unrecognized_keys`){i??=n;for(let e of n.keys)r.has(e)||r.set(e,{}),r.get(e).l=!0}else e.issues.push(n);for(let t of n.issues)if(t.code===`unrecognized_keys`)for(let e of t.keys)r.has(e)||r.set(e,{}),r.get(e).r=!0;else e.issues.push(t);let a=[...r].filter(([,e])=>e.l&&e.r).map(([e])=>e);if(a.length&&i&&e.issues.push({...i,keys:a}),uT(e))return e;let o=tD(t.value,n.value);if(!o.valid)throw Error(`Unmergable intersection. Error path: ${JSON.stringify(o.mergeErrorPath)}`);return e.value=o.data,e}function rD(e,t){return t===void 0&&(e.issues.length||e.fallback)?{issues:[],value:void 0}:e}function iD(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}function aD(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:`invalid_type`,expected:`nonoptional`,input:e.value,inst:t}),e}function oD(e,t,n){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues,fallback:e.fallback},n)}function sD(e){return e.value=Object.freeze(e.value),e}function cD(e,t,n,r){if(!e){let e={code:`custom`,input:n,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(e.params=r._zod.def.params),t.issues.push(_T(e))}}var lD,uD,dD,fD,pD,mD,hD,gD,_D,vD,yD,bD,xD,SD,CD,wD,TD,ED,DD,OD,kD,AD,jD,MD,ND,PD,FD,ID,LD,RD,zD,BD,VD,HD,UD,WD,GD,KD,qD,JD,YD,XD,ZD,QD,$D,eO,tO,nO,rO,iO,aO,oO,sO,cO,lO=a((()=>{HE(),Lw(),WE(),WT(),wE(),CT(),KE(),lD=K(`$ZodType`,(e,t)=>{var n;e??={},e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=GE;let r=[...e._zod.def.checks??[]];e._zod.traits.has(`$ZodCheck`)&&r.unshift(e);for(let t of r)for(let n of t._zod.onattach)n(e);if(r.length===0)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let t=(e,t,n)=>{let r=uT(e),i;for(let a of t){if(a._zod.def.when){if(dT(e)||!a._zod.def.when(e))continue}else if(r)continue;let t=e.issues.length,o=a._zod.check(e);if(o instanceof Promise&&n?.async===!1)throw new Pw;if(i||o instanceof Promise)i=(i??Promise.resolve()).then(async()=>{await o,e.issues.length!==t&&(r||=uT(e,t))});else{if(e.issues.length===t)continue;r||=uT(e,t)}}return i?i.then(()=>e):e},n=(n,i,a)=>{if(uT(n))return n.aborted=!0,n;let o=t(i,r,a);if(o instanceof Promise){if(a.async===!1)throw new Pw;return o.then(t=>e._zod.parse(t,a))}return e._zod.parse(o,a)};e._zod.run=(i,a)=>{if(a.skipChecks)return e._zod.parse(i,a);if(a.direction===`backward`){let t=e._zod.parse({value:i.value,issues:[]},{...a,skipChecks:!0});return t instanceof Promise?t.then(e=>n(e,i,a)):n(t,i,a)}let o=e._zod.parse(i,a);if(o instanceof Promise){if(a.async===!1)throw new Pw;return o.then(e=>t(e,r,a))}return t(o,r,a)}}Gw(e,`~standard`,()=>({validate:t=>{try{let n=NT(e,t);return n.success?{value:n.data}:{issues:n.error?.issues}}catch{return FT(e,t).then(e=>e.success?{value:e.data}:{issues:e.error?.issues})}},vendor:`zod`,version:1}))}),uD=K(`$ZodString`,(e,t)=>{lD.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??gE(e._zod.bag),e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=String(n.value)}catch{}return typeof n.value==`string`||n.issues.push({expected:`string`,code:`invalid_type`,input:n.value,inst:e}),n}}),dD=K(`$ZodStringFormat`,(e,t)=>{PE.init(e,t),uD.init(e,t)}),fD=K(`$ZodGUID`,(e,t)=>{t.pattern??=nE,dD.init(e,t)}),pD=K(`$ZodUUID`,(e,t)=>{if(t.version){let e={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(e===void 0)throw Error(`Invalid UUID version: "${t.version}"`);t.pattern??=rE(e)}else t.pattern??=rE();dD.init(e,t)}),mD=K(`$ZodEmail`,(e,t)=>{t.pattern??=iE,dD.init(e,t)}),hD=K(`$ZodURL`,(e,t)=>{dD.init(e,t),e._zod.check=n=>{try{let r=n.value.trim();if(!t.normalize&&t.protocol?.source===fE.source&&!/^https?:\/\//i.test(r)){n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid URL format`,input:n.value,inst:e,continue:!t.abort});return}let i=new URL(r);t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(i.hostname)||n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid hostname`,pattern:t.hostname.source,input:n.value,inst:e,continue:!t.abort})),t.protocol&&(t.protocol.lastIndex=0,t.protocol.test(i.protocol.endsWith(`:`)?i.protocol.slice(0,-1):i.protocol)||n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid protocol`,pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort})),t.normalize?n.value=i.href:n.value=r;return}catch{n.issues.push({code:`invalid_format`,format:`url`,input:n.value,inst:e,continue:!t.abort})}}}),gD=K(`$ZodEmoji`,(e,t)=>{t.pattern??=GT(),dD.init(e,t)}),_D=K(`$ZodNanoID`,(e,t)=>{t.pattern??=eE,dD.init(e,t)}),vD=K(`$ZodCUID`,(e,t)=>{t.pattern??=YT,dD.init(e,t)}),yD=K(`$ZodCUID2`,(e,t)=>{t.pattern??=XT,dD.init(e,t)}),bD=K(`$ZodULID`,(e,t)=>{t.pattern??=ZT,dD.init(e,t)}),xD=K(`$ZodXID`,(e,t)=>{t.pattern??=QT,dD.init(e,t)}),SD=K(`$ZodKSUID`,(e,t)=>{t.pattern??=$T,dD.init(e,t)}),CD=K(`$ZodISODateTime`,(e,t)=>{t.pattern??=JT(t),dD.init(e,t)}),wD=K(`$ZodISODate`,(e,t)=>{t.pattern??=hE,dD.init(e,t)}),TD=K(`$ZodISOTime`,(e,t)=>{t.pattern??=qT(t),dD.init(e,t)}),ED=K(`$ZodISODuration`,(e,t)=>{t.pattern??=tE,dD.init(e,t)}),DD=K(`$ZodIPv4`,(e,t)=>{t.pattern??=oE,dD.init(e,t),e._zod.bag.format=`ipv4`}),OD=K(`$ZodIPv6`,(e,t)=>{t.pattern??=sE,dD.init(e,t),e._zod.bag.format=`ipv6`,e._zod.check=n=>{try{new URL(`http://[${n.value}]`)}catch{n.issues.push({code:`invalid_format`,format:`ipv6`,input:n.value,inst:e,continue:!t.abort})}}}),kD=K(`$ZodCIDRv4`,(e,t)=>{t.pattern??=cE,dD.init(e,t)}),AD=K(`$ZodCIDRv6`,(e,t)=>{t.pattern??=lE,dD.init(e,t),e._zod.check=n=>{let r=n.value.split(`/`);try{if(r.length!==2)throw Error();let[e,t]=r;if(!t)throw Error();let n=Number(t);if(`${n}`!==t||n<0||n>128)throw Error();new URL(`http://[${e}]`)}catch{n.issues.push({code:`invalid_format`,format:`cidrv6`,input:n.value,inst:e,continue:!t.abort})}}}),jD=K(`$ZodBase64`,(e,t)=>{t.pattern??=uE,dD.init(e,t),e._zod.bag.contentEncoding=`base64`,e._zod.check=n=>{qE(n.value)||n.issues.push({code:`invalid_format`,format:`base64`,input:n.value,inst:e,continue:!t.abort})}}),MD=K(`$ZodBase64URL`,(e,t)=>{t.pattern??=dE,dD.init(e,t),e._zod.bag.contentEncoding=`base64url`,e._zod.check=n=>{JE(n.value)||n.issues.push({code:`invalid_format`,format:`base64url`,input:n.value,inst:e,continue:!t.abort})}}),ND=K(`$ZodE164`,(e,t)=>{t.pattern??=pE,dD.init(e,t)}),PD=K(`$ZodJWT`,(e,t)=>{dD.init(e,t),e._zod.check=n=>{YE(n.value,t.alg)||n.issues.push({code:`invalid_format`,format:`jwt`,input:n.value,inst:e,continue:!t.abort})}}),FD=K(`$ZodNumber`,(e,t)=>{lD.init(e,t),e._zod.pattern=e._zod.bag.pattern??vE,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=Number(n.value)}catch{}let i=n.value;if(typeof i==`number`&&!Number.isNaN(i)&&Number.isFinite(i))return n;let a=typeof i==`number`?Number.isNaN(i)?`NaN`:Number.isFinite(i)?void 0:`Infinity`:void 0;return n.issues.push({expected:`number`,code:`invalid_type`,input:i,inst:e,...a?{received:a}:{}}),n}}),ID=K(`$ZodNumberFormat`,(e,t)=>{AE.init(e,t),FD.init(e,t)}),LD=K(`$ZodBoolean`,(e,t)=>{lD.init(e,t),e._zod.pattern=yE,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=!!n.value}catch{}let i=n.value;return typeof i==`boolean`||n.issues.push({expected:`boolean`,code:`invalid_type`,input:i,inst:e}),n}}),RD=K(`$ZodUndefined`,(e,t)=>{lD.init(e,t),e._zod.pattern=xE,e._zod.values=new Set([void 0]),e._zod.parse=(t,n)=>{let r=t.value;return r===void 0||t.issues.push({expected:`undefined`,code:`invalid_type`,input:r,inst:e}),t}}),zD=K(`$ZodNull`,(e,t)=>{lD.init(e,t),e._zod.pattern=bE,e._zod.values=new Set([null]),e._zod.parse=(t,n)=>{let r=t.value;return r===null||t.issues.push({expected:`null`,code:`invalid_type`,input:r,inst:e}),t}}),BD=K(`$ZodUnknown`,(e,t)=>{lD.init(e,t),e._zod.parse=e=>e}),VD=K(`$ZodNever`,(e,t)=>{lD.init(e,t),e._zod.parse=(t,n)=>(t.issues.push({expected:`never`,code:`invalid_type`,input:t.value,inst:e}),t)}),HD=K(`$ZodArray`,(e,t)=>{lD.init(e,t),e._zod.parse=(n,r)=>{let i=n.value;if(!Array.isArray(i))return n.issues.push({expected:`array`,code:`invalid_type`,input:i,inst:e}),n;n.value=Array(i.length);let a=[];for(let e=0;e<i.length;e++){let o=i[e],s=t.element._zod.run({value:o,issues:[]},r);s instanceof Promise?a.push(s.then(t=>XE(t,n,e))):XE(s,n,e)}return a.length?Promise.all(a).then(()=>n):n}}),UD=K(`$ZodObject`,(e,t)=>{if(lD.init(e,t),!Object.getOwnPropertyDescriptor(t,`shape`)?.get){let e=t.shape;Object.defineProperty(t,"shape",{get:()=>{let n={...e};return Object.defineProperty(t,"shape",{value:n}),n}})}let n=Vw(()=>QE(t));Gw(e._zod,`propValues`,()=>{let e=t.shape,n={};for(let t in e){let r=e[t]._zod;if(r.values){n[t]??(n[t]=new Set);for(let e of r.values)n[t].add(e)}}return n});let r=Xw,i=t.catchall,a;e._zod.parse=(t,o)=>{a??=n.value;let s=t.value;if(!r(s))return t.issues.push({expected:`object`,code:`invalid_type`,input:s,inst:e}),t;t.value={};let c=[],l=a.shape;for(let e of a.keys){let n=l[e],r=n._zod.optin===`optional`,i=n._zod.optout===`optional`,a=n._zod.run({value:s[e],issues:[]},o);a instanceof Promise?c.push(a.then(n=>ZE(n,t,e,s,r,i))):ZE(a,t,e,s,r,i)}return i?$E(c,s,t,o,n.value,e):c.length?Promise.all(c).then(()=>t):t}}),WD=K(`$ZodObjectJIT`,(e,t)=>{UD.init(e,t);let n=e._zod.parse,r=Vw(()=>QE(t)),i=e=>{let t=new UE([`shape`,`payload`,`ctx`]),n=r.value,i=e=>{let t=Jw(e);return`shape[${t}]._zod.run({ value: input[${t}], issues: [] }, ctx)`};t.write(`const input = payload.value;`);let a=Object.create(null),o=0;for(let e of n.keys)a[e]=`key_${o++}`;t.write(`const newResult = {};`);for(let r of n.keys){let n=a[r],o=Jw(r),s=e[r],c=s?._zod?.optin===`optional`,l=s?._zod?.optout===`optional`;t.write(`const ${n} = ${i(r)};`),c&&l?t.write(`
57
+ `))}}})),qE,JE=a((()=>{qE={major:4,minor:4,patch:3}}));function YE(e){if(e===``)return!0;if(/\s/.test(e)||e.length%4!=0)return!1;try{return atob(e),!0}catch{return!1}}function XE(e){if(!pE.test(e))return!1;let t=e.replace(/[-_]/g,e=>e===`-`?`+`:`/`);return YE(t.padEnd(Math.ceil(t.length/4)*4,`=`))}function ZE(e,t=null){try{let n=e.split(`.`);if(n.length!==3)return!1;let[r]=n;if(!r)return!1;let i=JSON.parse(atob(r));return!(`typ`in i&&i?.typ!==`JWT`||!i.alg||t&&(!(`alg`in i)||i.alg!==t))}catch{return!1}}function QE(e,t,n){e.issues.length&&t.issues.push(...mT(n,e.issues)),t.value[n]=e.value}function $E(e,t,n,r,i,a){let o=n in r;if(e.issues.length){if(i&&a&&!o)return;t.issues.push(...mT(n,e.issues))}if(!o&&!i){e.issues.length||t.issues.push({code:`invalid_type`,expected:`nonoptional`,input:void 0,path:[n]});return}e.value===void 0?o&&(t.value[n]=void 0):t.value[n]=e.value}function eD(e){let t=Object.keys(e.shape);for(let n of t)if(!e.shape?.[n]?._zod?.traits?.has(`$ZodType`))throw Error(`Invalid element at key "${n}": expected a Zod schema`);let n=iT(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(n)}}function tD(e,t,n,r,i,a){let o=[],s=i.keySet,c=i.catchall._zod,l=c.def.type,u=c.optin===`optional`,d=c.optout===`optional`;for(let i in t){if(i===`__proto__`||s.has(i))continue;if(l===`never`){o.push(i);continue}let a=c.run({value:t[i],issues:[]},r);a instanceof Promise?e.push(a.then(e=>$E(e,n,i,t,u,d))):$E(a,n,i,t,u,d)}return o.length&&n.issues.push({code:`unrecognized_keys`,keys:o,input:t,inst:a}),e.length?Promise.all(e).then(()=>n):n}function nD(e,t,n,r){for(let n of e)if(n.issues.length===0)return t.value=n.value,t;let i=e.filter(e=>!fT(e));return i.length===1?(t.value=i[0].value,i[0]):(t.issues.push({code:`invalid_union`,input:t.value,inst:n,errors:e.map(e=>e.issues.map(e=>gT(e,r,Pw())))}),t)}function rD(e,t){if(e===t||e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if($w(e)&&$w(t)){let n=Object.keys(t),r=Object.keys(e).filter(e=>n.indexOf(e)!==-1),i={...e,...t};for(let n of r){let r=rD(e[n],t[n]);if(!r.valid)return{valid:!1,mergeErrorPath:[n,...r.mergeErrorPath]};i[n]=r.data}return{valid:!0,data:i}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};let n=[];for(let r=0;r<e.length;r++){let i=e[r],a=t[r],o=rD(i,a);if(!o.valid)return{valid:!1,mergeErrorPath:[r,...o.mergeErrorPath]};n.push(o.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function iD(e,t,n){let r=new Map,i;for(let n of t.issues)if(n.code===`unrecognized_keys`){i??=n;for(let e of n.keys)r.has(e)||r.set(e,{}),r.get(e).l=!0}else e.issues.push(n);for(let t of n.issues)if(t.code===`unrecognized_keys`)for(let e of t.keys)r.has(e)||r.set(e,{}),r.get(e).r=!0;else e.issues.push(t);let a=[...r].filter(([,e])=>e.l&&e.r).map(([e])=>e);if(a.length&&i&&e.issues.push({...i,keys:a}),fT(e))return e;let o=rD(t.value,n.value);if(!o.valid)throw Error(`Unmergable intersection. Error path: ${JSON.stringify(o.mergeErrorPath)}`);return e.value=o.data,e}function aD(e,t){return t===void 0&&(e.issues.length||e.fallback)?{issues:[],value:void 0}:e}function oD(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}function sD(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:`invalid_type`,expected:`nonoptional`,input:e.value,inst:t}),e}function cD(e,t,n){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues,fallback:e.fallback},n)}function lD(e){return e.value=Object.freeze(e.value),e}function uD(e,t,n,r){if(!e){let e={code:`custom`,input:n,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(e.params=r._zod.def.params),t.issues.push(yT(e))}}var dD,fD,pD,mD,hD,gD,_D,vD,yD,bD,xD,SD,CD,wD,TD,ED,DD,OD,kD,AD,jD,MD,ND,PD,FD,ID,LD,RD,zD,BD,VD,HD,UD,WD,GD,KD,qD,JD,YD,XD,ZD,QD,$D,eO,tO,nO,rO,iO,aO,oO,sO,cO,lO,uO,dO=a((()=>{WE(),zw(),KE(),KT(),EE(),TT(),JE(),dD=K(`$ZodType`,(e,t)=>{var n;e??={},e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=qE;let r=[...e._zod.def.checks??[]];e._zod.traits.has(`$ZodCheck`)&&r.unshift(e);for(let t of r)for(let n of t._zod.onattach)n(e);if(r.length===0)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let t=(e,t,n)=>{let r=fT(e),i;for(let a of t){if(a._zod.def.when){if(pT(e)||!a._zod.def.when(e))continue}else if(r)continue;let t=e.issues.length,o=a._zod.check(e);if(o instanceof Promise&&n?.async===!1)throw new Iw;if(i||o instanceof Promise)i=(i??Promise.resolve()).then(async()=>{await o,e.issues.length!==t&&(r||=fT(e,t))});else{if(e.issues.length===t)continue;r||=fT(e,t)}}return i?i.then(()=>e):e},n=(n,i,a)=>{if(fT(n))return n.aborted=!0,n;let o=t(i,r,a);if(o instanceof Promise){if(a.async===!1)throw new Iw;return o.then(t=>e._zod.parse(t,a))}return e._zod.parse(o,a)};e._zod.run=(i,a)=>{if(a.skipChecks)return e._zod.parse(i,a);if(a.direction===`backward`){let t=e._zod.parse({value:i.value,issues:[]},{...a,skipChecks:!0});return t instanceof Promise?t.then(e=>n(e,i,a)):n(t,i,a)}let o=e._zod.parse(i,a);if(o instanceof Promise){if(a.async===!1)throw new Iw;return o.then(e=>t(e,r,a))}return t(o,r,a)}}qw(e,`~standard`,()=>({validate:t=>{try{let n=FT(e,t);return n.success?{value:n.data}:{issues:n.error?.issues}}catch{return LT(e,t).then(e=>e.success?{value:e.data}:{issues:e.error?.issues})}},vendor:`zod`,version:1}))}),fD=K(`$ZodString`,(e,t)=>{dD.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??vE(e._zod.bag),e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=String(n.value)}catch{}return typeof n.value==`string`||n.issues.push({expected:`string`,code:`invalid_type`,input:n.value,inst:e}),n}}),pD=K(`$ZodStringFormat`,(e,t)=>{IE.init(e,t),fD.init(e,t)}),mD=K(`$ZodGUID`,(e,t)=>{t.pattern??=iE,pD.init(e,t)}),hD=K(`$ZodUUID`,(e,t)=>{if(t.version){let e={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(e===void 0)throw Error(`Invalid UUID version: "${t.version}"`);t.pattern??=aE(e)}else t.pattern??=aE();pD.init(e,t)}),gD=K(`$ZodEmail`,(e,t)=>{t.pattern??=oE,pD.init(e,t)}),_D=K(`$ZodURL`,(e,t)=>{pD.init(e,t),e._zod.check=n=>{try{let r=n.value.trim();if(!t.normalize&&t.protocol?.source===mE.source&&!/^https?:\/\//i.test(r)){n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid URL format`,input:n.value,inst:e,continue:!t.abort});return}let i=new URL(r);t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(i.hostname)||n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid hostname`,pattern:t.hostname.source,input:n.value,inst:e,continue:!t.abort})),t.protocol&&(t.protocol.lastIndex=0,t.protocol.test(i.protocol.endsWith(`:`)?i.protocol.slice(0,-1):i.protocol)||n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid protocol`,pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort})),t.normalize?n.value=i.href:n.value=r;return}catch{n.issues.push({code:`invalid_format`,format:`url`,input:n.value,inst:e,continue:!t.abort})}}}),vD=K(`$ZodEmoji`,(e,t)=>{t.pattern??=qT(),pD.init(e,t)}),yD=K(`$ZodNanoID`,(e,t)=>{t.pattern??=nE,pD.init(e,t)}),bD=K(`$ZodCUID`,(e,t)=>{t.pattern??=ZT,pD.init(e,t)}),xD=K(`$ZodCUID2`,(e,t)=>{t.pattern??=QT,pD.init(e,t)}),SD=K(`$ZodULID`,(e,t)=>{t.pattern??=$T,pD.init(e,t)}),CD=K(`$ZodXID`,(e,t)=>{t.pattern??=eE,pD.init(e,t)}),wD=K(`$ZodKSUID`,(e,t)=>{t.pattern??=tE,pD.init(e,t)}),TD=K(`$ZodISODateTime`,(e,t)=>{t.pattern??=XT(t),pD.init(e,t)}),ED=K(`$ZodISODate`,(e,t)=>{t.pattern??=_E,pD.init(e,t)}),DD=K(`$ZodISOTime`,(e,t)=>{t.pattern??=YT(t),pD.init(e,t)}),OD=K(`$ZodISODuration`,(e,t)=>{t.pattern??=rE,pD.init(e,t)}),kD=K(`$ZodIPv4`,(e,t)=>{t.pattern??=cE,pD.init(e,t),e._zod.bag.format=`ipv4`}),AD=K(`$ZodIPv6`,(e,t)=>{t.pattern??=lE,pD.init(e,t),e._zod.bag.format=`ipv6`,e._zod.check=n=>{try{new URL(`http://[${n.value}]`)}catch{n.issues.push({code:`invalid_format`,format:`ipv6`,input:n.value,inst:e,continue:!t.abort})}}}),jD=K(`$ZodCIDRv4`,(e,t)=>{t.pattern??=uE,pD.init(e,t)}),MD=K(`$ZodCIDRv6`,(e,t)=>{t.pattern??=dE,pD.init(e,t),e._zod.check=n=>{let r=n.value.split(`/`);try{if(r.length!==2)throw Error();let[e,t]=r;if(!t)throw Error();let n=Number(t);if(`${n}`!==t||n<0||n>128)throw Error();new URL(`http://[${e}]`)}catch{n.issues.push({code:`invalid_format`,format:`cidrv6`,input:n.value,inst:e,continue:!t.abort})}}}),ND=K(`$ZodBase64`,(e,t)=>{t.pattern??=fE,pD.init(e,t),e._zod.bag.contentEncoding=`base64`,e._zod.check=n=>{YE(n.value)||n.issues.push({code:`invalid_format`,format:`base64`,input:n.value,inst:e,continue:!t.abort})}}),PD=K(`$ZodBase64URL`,(e,t)=>{t.pattern??=pE,pD.init(e,t),e._zod.bag.contentEncoding=`base64url`,e._zod.check=n=>{XE(n.value)||n.issues.push({code:`invalid_format`,format:`base64url`,input:n.value,inst:e,continue:!t.abort})}}),FD=K(`$ZodE164`,(e,t)=>{t.pattern??=hE,pD.init(e,t)}),ID=K(`$ZodJWT`,(e,t)=>{pD.init(e,t),e._zod.check=n=>{ZE(n.value,t.alg)||n.issues.push({code:`invalid_format`,format:`jwt`,input:n.value,inst:e,continue:!t.abort})}}),LD=K(`$ZodNumber`,(e,t)=>{dD.init(e,t),e._zod.pattern=e._zod.bag.pattern??bE,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=Number(n.value)}catch{}let i=n.value;if(typeof i==`number`&&!Number.isNaN(i)&&Number.isFinite(i))return n;let a=typeof i==`number`?Number.isNaN(i)?`NaN`:Number.isFinite(i)?void 0:`Infinity`:void 0;return n.issues.push({expected:`number`,code:`invalid_type`,input:i,inst:e,...a?{received:a}:{}}),n}}),RD=K(`$ZodNumberFormat`,(e,t)=>{ME.init(e,t),LD.init(e,t)}),zD=K(`$ZodBoolean`,(e,t)=>{dD.init(e,t),e._zod.pattern=xE,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=!!n.value}catch{}let i=n.value;return typeof i==`boolean`||n.issues.push({expected:`boolean`,code:`invalid_type`,input:i,inst:e}),n}}),BD=K(`$ZodUndefined`,(e,t)=>{dD.init(e,t),e._zod.pattern=CE,e._zod.values=new Set([void 0]),e._zod.parse=(t,n)=>{let r=t.value;return r===void 0||t.issues.push({expected:`undefined`,code:`invalid_type`,input:r,inst:e}),t}}),VD=K(`$ZodNull`,(e,t)=>{dD.init(e,t),e._zod.pattern=SE,e._zod.values=new Set([null]),e._zod.parse=(t,n)=>{let r=t.value;return r===null||t.issues.push({expected:`null`,code:`invalid_type`,input:r,inst:e}),t}}),HD=K(`$ZodUnknown`,(e,t)=>{dD.init(e,t),e._zod.parse=e=>e}),UD=K(`$ZodNever`,(e,t)=>{dD.init(e,t),e._zod.parse=(t,n)=>(t.issues.push({expected:`never`,code:`invalid_type`,input:t.value,inst:e}),t)}),WD=K(`$ZodArray`,(e,t)=>{dD.init(e,t),e._zod.parse=(n,r)=>{let i=n.value;if(!Array.isArray(i))return n.issues.push({expected:`array`,code:`invalid_type`,input:i,inst:e}),n;n.value=Array(i.length);let a=[];for(let e=0;e<i.length;e++){let o=i[e],s=t.element._zod.run({value:o,issues:[]},r);s instanceof Promise?a.push(s.then(t=>QE(t,n,e))):QE(s,n,e)}return a.length?Promise.all(a).then(()=>n):n}}),GD=K(`$ZodObject`,(e,t)=>{if(dD.init(e,t),!Object.getOwnPropertyDescriptor(t,`shape`)?.get){let e=t.shape;Object.defineProperty(t,"shape",{get:()=>{let n={...e};return Object.defineProperty(t,"shape",{value:n}),n}})}let n=Uw(()=>eD(t));qw(e._zod,`propValues`,()=>{let e=t.shape,n={};for(let t in e){let r=e[t]._zod;if(r.values){n[t]??(n[t]=new Set);for(let e of r.values)n[t].add(e)}}return n});let r=Qw,i=t.catchall,a;e._zod.parse=(t,o)=>{a??=n.value;let s=t.value;if(!r(s))return t.issues.push({expected:`object`,code:`invalid_type`,input:s,inst:e}),t;t.value={};let c=[],l=a.shape;for(let e of a.keys){let n=l[e],r=n._zod.optin===`optional`,i=n._zod.optout===`optional`,a=n._zod.run({value:s[e],issues:[]},o);a instanceof Promise?c.push(a.then(n=>$E(n,t,e,s,r,i))):$E(a,t,e,s,r,i)}return i?tD(c,s,t,o,n.value,e):c.length?Promise.all(c).then(()=>t):t}}),KD=K(`$ZodObjectJIT`,(e,t)=>{GD.init(e,t);let n=e._zod.parse,r=Uw(()=>eD(t)),i=e=>{let t=new GE([`shape`,`payload`,`ctx`]),n=r.value,i=e=>{let t=Xw(e);return`shape[${t}]._zod.run({ value: input[${t}], issues: [] }, ctx)`};t.write(`const input = payload.value;`);let a=Object.create(null),o=0;for(let e of n.keys)a[e]=`key_${o++}`;t.write(`const newResult = {};`);for(let r of n.keys){let n=a[r],o=Xw(r),s=e[r],c=s?._zod?.optin===`optional`,l=s?._zod?.optout===`optional`;t.write(`const ${n} = ${i(r)};`),c&&l?t.write(`
58
58
  if (${n}.issues.length) {
59
59
  if (${o} in input) {
60
60
  payload.issues = payload.issues.concat(${n}.issues.map(iss => ({
@@ -113,15 +113,15 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
113
113
  }
114
114
  }
115
115
 
116
- `)}t.write(`payload.value = newResult;`),t.write(`return payload;`);let s=t.compile();return(t,n)=>s(e,t,n)},a,o=Xw,s=!Iw.jitless,c=s&&bT.value,l=t.catchall,u;e._zod.parse=(d,f)=>{u??=r.value;let p=d.value;return o(p)?s&&c&&f?.async===!1&&f.jitless!==!0?(a||=i(t.shape),d=a(d,f),l?$E([],p,d,f,u,e):d):n(d,f):(d.issues.push({expected:`object`,code:`invalid_type`,input:p,inst:e}),d)}}),GD=K(`$ZodUnion`,(e,t)=>{lD.init(e,t),Gw(e._zod,`optin`,()=>t.options.some(e=>e._zod.optin===`optional`)?`optional`:void 0),Gw(e._zod,`optout`,()=>t.options.some(e=>e._zod.optout===`optional`)?`optional`:void 0),Gw(e._zod,`values`,()=>{if(t.options.every(e=>e._zod.values))return new Set(t.options.flatMap(e=>Array.from(e._zod.values)))}),Gw(e._zod,`pattern`,()=>{if(t.options.every(e=>e._zod.pattern)){let e=t.options.map(e=>e._zod.pattern);return RegExp(`^(${e.map(e=>Uw(e.source)).join(`|`)})$`)}});let n=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(r,i)=>{if(n)return n(r,i);let a=!1,o=[];for(let e of t.options){let t=e._zod.run({value:r.value,issues:[]},i);if(t instanceof Promise)o.push(t),a=!0;else{if(t.issues.length===0)return t;o.push(t)}}return a?Promise.all(o).then(t=>eD(t,r,e,i)):eD(o,r,e,i)}}),KD=K(`$ZodDiscriminatedUnion`,(e,t)=>{t.inclusive=!1,GD.init(e,t);let n=e._zod.parse;Gw(e._zod,`propValues`,()=>{let e={};for(let n of t.options){let r=n._zod.propValues;if(!r||Object.keys(r).length===0)throw Error(`Invalid discriminated union option at index "${t.options.indexOf(n)}"`);for(let[t,n]of Object.entries(r)){e[t]||(e[t]=new Set);for(let r of n)e[t].add(r)}}return e});let r=Vw(()=>{let e=t.options,n=new Map;for(let r of e){let e=r._zod.propValues?.[t.discriminator];if(!e||e.size===0)throw Error(`Invalid discriminated union option at index "${t.options.indexOf(r)}"`);for(let t of e){if(n.has(t))throw Error(`Duplicate discriminator value "${String(t)}"`);n.set(t,r)}}return n});e._zod.parse=(i,a)=>{let o=i.value;if(!Xw(o))return i.issues.push({code:`invalid_type`,expected:`object`,input:o,inst:e}),i;let s=r.value.get(o?.[t.discriminator]);return s?s._zod.run(i,a):t.unionFallback||a.direction===`backward`?n(i,a):(i.issues.push({code:`invalid_union`,errors:[],note:`No matching discriminator`,discriminator:t.discriminator,options:Array.from(r.value.keys()),input:o,path:[t.discriminator],inst:e}),i)}}),qD=K(`$ZodIntersection`,(e,t)=>{lD.init(e,t),e._zod.parse=(e,n)=>{let r=e.value,i=t.left._zod.run({value:r,issues:[]},n),a=t.right._zod.run({value:r,issues:[]},n);return i instanceof Promise||a instanceof Promise?Promise.all([i,a]).then(([t,n])=>nD(e,t,n)):nD(e,i,a)}}),JD=K(`$ZodRecord`,(e,t)=>{lD.init(e,t),e._zod.parse=(n,r)=>{let i=n.value;if(!Zw(i))return n.issues.push({expected:`record`,code:`invalid_type`,input:i,inst:e}),n;let a=[],o=t.keyType._zod.values;if(o){n.value={};let s=new Set;for(let c of o)if(typeof c==`string`||typeof c==`number`||typeof c==`symbol`){s.add(typeof c==`number`?c.toString():c);let o=t.keyType._zod.run({value:c,issues:[]},r);if(o instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);if(o.issues.length){n.issues.push({code:`invalid_key`,origin:`record`,issues:o.issues.map(e=>mT(e,r,Mw())),input:c,path:[c],inst:e});continue}let l=o.value,u=t.valueType._zod.run({value:i[c],issues:[]},r);u instanceof Promise?a.push(u.then(e=>{e.issues.length&&n.issues.push(...fT(c,e.issues)),n.value[l]=e.value})):(u.issues.length&&n.issues.push(...fT(c,u.issues)),n.value[l]=u.value)}let c;for(let e in i)s.has(e)||(c??=[],c.push(e));c&&c.length>0&&n.issues.push({code:`unrecognized_keys`,input:i,inst:e,keys:c})}else{n.value={};for(let o of Reflect.ownKeys(i)){if(o===`__proto__`||!Object.prototype.propertyIsEnumerable.call(i,o))continue;let s=t.keyType._zod.run({value:o,issues:[]},r);if(s instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);if(typeof o==`string`&&vE.test(o)&&s.issues.length){let e=t.keyType._zod.run({value:Number(o),issues:[]},r);if(e instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);e.issues.length===0&&(s=e)}if(s.issues.length){t.mode===`loose`?n.value[o]=i[o]:n.issues.push({code:`invalid_key`,origin:`record`,issues:s.issues.map(e=>mT(e,r,Mw())),input:o,path:[o],inst:e});continue}let c=t.valueType._zod.run({value:i[o],issues:[]},r);c instanceof Promise?a.push(c.then(e=>{e.issues.length&&n.issues.push(...fT(o,e.issues)),n.value[s.value]=e.value})):(c.issues.length&&n.issues.push(...fT(o,c.issues)),n.value[s.value]=c.value)}}return a.length?Promise.all(a).then(()=>n):n}}),YD=K(`$ZodEnum`,(e,t)=>{lD.init(e,t);let n=Rw(t.entries),r=new Set(n);e._zod.values=r,e._zod.pattern=RegExp(`^(${n.filter(e=>xT.has(typeof e)).map(e=>typeof e==`string`?$w(e):e.toString()).join(`|`)})$`),e._zod.parse=(t,i)=>{let a=t.value;return r.has(a)||t.issues.push({code:`invalid_value`,values:n,input:a,inst:e}),t}}),XD=K(`$ZodLiteral`,(e,t)=>{if(lD.init(e,t),t.values.length===0)throw Error(`Cannot create literal schema with no valid values`);let n=new Set(t.values);e._zod.values=n,e._zod.pattern=RegExp(`^(${t.values.map(e=>typeof e==`string`?$w(e):e?$w(e.toString()):String(e)).join(`|`)})$`),e._zod.parse=(r,i)=>{let a=r.value;return n.has(a)||r.issues.push({code:`invalid_value`,values:t.values,input:a,inst:e}),r}}),ZD=K(`$ZodTransform`,(e,t)=>{lD.init(e,t),e._zod.optin=`optional`,e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new Fw(e.constructor.name);let i=t.transform(n.value,n);if(r.async)return(i instanceof Promise?i:Promise.resolve(i)).then(e=>(n.value=e,n.fallback=!0,n));if(i instanceof Promise)throw new Pw;return n.value=i,n.fallback=!0,n}}),QD=K(`$ZodOptional`,(e,t)=>{lD.init(e,t),e._zod.optin=`optional`,e._zod.optout=`optional`,Gw(e._zod,`values`,()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),Gw(e._zod,`pattern`,()=>{let e=t.innerType._zod.pattern;return e?RegExp(`^(${Uw(e.source)})?$`):void 0}),e._zod.parse=(e,n)=>{if(t.innerType._zod.optin===`optional`){let r=e.value,i=t.innerType._zod.run(e,n);return i instanceof Promise?i.then(e=>rD(e,r)):rD(i,r)}return e.value===void 0?e:t.innerType._zod.run(e,n)}}),$D=K(`$ZodExactOptional`,(e,t)=>{QD.init(e,t),Gw(e._zod,`values`,()=>t.innerType._zod.values),Gw(e._zod,`pattern`,()=>t.innerType._zod.pattern),e._zod.parse=(e,n)=>t.innerType._zod.run(e,n)}),eO=K(`$ZodNullable`,(e,t)=>{lD.init(e,t),Gw(e._zod,`optin`,()=>t.innerType._zod.optin),Gw(e._zod,`optout`,()=>t.innerType._zod.optout),Gw(e._zod,`pattern`,()=>{let e=t.innerType._zod.pattern;return e?RegExp(`^(${Uw(e.source)}|null)$`):void 0}),Gw(e._zod,`values`,()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(e,n)=>e.value===null?e:t.innerType._zod.run(e,n)}),tO=K(`$ZodDefault`,(e,t)=>{lD.init(e,t),e._zod.optin=`optional`,Gw(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);if(e.value===void 0)return e.value=t.defaultValue,e;let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(e=>iD(e,t)):iD(r,t)}}),nO=K(`$ZodPrefault`,(e,t)=>{lD.init(e,t),e._zod.optin=`optional`,Gw(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>(n.direction===`backward`||e.value===void 0&&(e.value=t.defaultValue),t.innerType._zod.run(e,n))}),rO=K(`$ZodNonOptional`,(e,t)=>{lD.init(e,t),Gw(e._zod,`values`,()=>{let e=t.innerType._zod.values;return e?new Set([...e].filter(e=>e!==void 0)):void 0}),e._zod.parse=(n,r)=>{let i=t.innerType._zod.run(n,r);return i instanceof Promise?i.then(t=>aD(t,e)):aD(i,e)}}),iO=K(`$ZodCatch`,(e,t)=>{lD.init(e,t),e._zod.optin=`optional`,Gw(e._zod,`optout`,()=>t.innerType._zod.optout),Gw(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(r=>(e.value=r.value,r.issues.length&&(e.value=t.catchValue({...e,error:{issues:r.issues.map(e=>mT(e,n,Mw()))},input:e.value}),e.issues=[],e.fallback=!0),e)):(e.value=r.value,r.issues.length&&(e.value=t.catchValue({...e,error:{issues:r.issues.map(e=>mT(e,n,Mw()))},input:e.value}),e.issues=[],e.fallback=!0),e)}}),aO=K(`$ZodPipe`,(e,t)=>{lD.init(e,t),Gw(e._zod,`values`,()=>t.in._zod.values),Gw(e._zod,`optin`,()=>t.in._zod.optin),Gw(e._zod,`optout`,()=>t.out._zod.optout),Gw(e._zod,`propValues`,()=>t.in._zod.propValues),e._zod.parse=(e,n)=>{if(n.direction===`backward`){let r=t.out._zod.run(e,n);return r instanceof Promise?r.then(e=>oD(e,t.in,n)):oD(r,t.in,n)}let r=t.in._zod.run(e,n);return r instanceof Promise?r.then(e=>oD(e,t.out,n)):oD(r,t.out,n)}}),oO=K(`$ZodPreprocess`,(e,t)=>{aO.init(e,t)}),sO=K(`$ZodReadonly`,(e,t)=>{lD.init(e,t),Gw(e._zod,`propValues`,()=>t.innerType._zod.propValues),Gw(e._zod,`values`,()=>t.innerType._zod.values),Gw(e._zod,`optin`,()=>t.innerType?._zod?.optin),Gw(e._zod,`optout`,()=>t.innerType?._zod?.optout),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(sD):sD(r)}}),cO=K(`$ZodCustom`,(e,t)=>{TE.init(e,t),lD.init(e,t),e._zod.parse=(e,t)=>e,e._zod.check=n=>{let r=n.value,i=t.fn(r);if(i instanceof Promise)return i.then(t=>cD(t,n,r,e));cD(i,n,r,e)}})}));function uO(){return{localeError:dO()}}var dO,fO=a((()=>{CT(),dO=()=>{let e={string:{unit:`characters`,verb:`to have`},file:{unit:`bytes`,verb:`to have`},array:{unit:`items`,verb:`to have`},set:{unit:`items`,verb:`to have`},map:{unit:`entries`,verb:`to have`}};function t(t){return e[t]??null}let n={regex:`input`,email:`email address`,url:`URL`,emoji:`emoji`,uuid:`UUID`,uuidv4:`UUIDv4`,uuidv6:`UUIDv6`,nanoid:`nanoid`,guid:`GUID`,cuid:`cuid`,cuid2:`cuid2`,ulid:`ULID`,xid:`XID`,ksuid:`KSUID`,datetime:`ISO datetime`,date:`ISO date`,time:`ISO time`,duration:`ISO duration`,ipv4:`IPv4 address`,ipv6:`IPv6 address`,mac:`MAC address`,cidrv4:`IPv4 range`,cidrv6:`IPv6 range`,base64:`base64-encoded string`,base64url:`base64url-encoded string`,json_string:`JSON string`,e164:`E.164 number`,jwt:`JWT`,template_literal:`input`},r={nan:`NaN`};return e=>{switch(e.code){case`invalid_type`:{let t=r[e.expected]??e.expected,n=gT(e.input);return`Invalid input: expected ${t}, received ${r[n]??n}`}case`invalid_value`:return e.values.length===1?`Invalid input: expected ${tT(e.values[0])}`:`Invalid option: expected one of ${zw(e.values,`|`)}`;case`too_big`:{let n=e.inclusive?`<=`:`<`,r=t(e.origin);return r?`Too big: expected ${e.origin??`value`} to have ${n}${e.maximum.toString()} ${r.unit??`elements`}`:`Too big: expected ${e.origin??`value`} to be ${n}${e.maximum.toString()}`}case`too_small`:{let n=e.inclusive?`>=`:`>`,r=t(e.origin);return r?`Too small: expected ${e.origin} to have ${n}${e.minimum.toString()} ${r.unit}`:`Too small: expected ${e.origin} to be ${n}${e.minimum.toString()}`}case`invalid_format`:{let t=e;return t.format===`starts_with`?`Invalid string: must start with "${t.prefix}"`:t.format===`ends_with`?`Invalid string: must end with "${t.suffix}"`:t.format===`includes`?`Invalid string: must include "${t.includes}"`:t.format===`regex`?`Invalid string: must match pattern ${t.pattern}`:`Invalid ${n[t.format]??e.format}`}case`not_multiple_of`:return`Invalid number: must be a multiple of ${e.divisor}`;case`unrecognized_keys`:return`Unrecognized key${e.keys.length>1?`s`:``}: ${zw(e.keys,`, `)}`;case`invalid_key`:return`Invalid key in ${e.origin}`;case`invalid_union`:return e.options&&Array.isArray(e.options)&&e.options.length>0?`Invalid discriminator value. Expected ${e.options.map(e=>`'${e}'`).join(` | `)}`:`Invalid input`;case`invalid_element`:return`Invalid value in ${e.origin}`;default:return`Invalid input`}}}}));function pO(){return new hO}var mO,hO,gO,_O=a((()=>{hO=class{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...t){let n=t[0];return this._map.set(e,n),n&&typeof n==`object`&&`id`in n&&this._idmap.set(n.id,e),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(e){let t=this._map.get(e);return t&&typeof t==`object`&&`id`in t&&this._idmap.delete(t.id),this._map.delete(e),this}get(e){let t=e._zod.parent;if(t){let n={...this.get(t)??{}};delete n.id;let r={...n,...this._map.get(e)};return Object.keys(r).length?r:void 0}return this._map.get(e)}has(e){return this._map.has(e)}},(mO=globalThis).__zod_globalRegistry??(mO.__zod_globalRegistry=pO()),gO=globalThis.__zod_globalRegistry}));function vO(e,t){return new e({type:`string`,...q(t)})}function yO(e,t){return new e({type:`string`,format:`email`,check:`string_format`,abort:!1,...q(t)})}function bO(e,t){return new e({type:`string`,format:`guid`,check:`string_format`,abort:!1,...q(t)})}function xO(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,...q(t)})}function SO(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v4`,...q(t)})}function CO(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v6`,...q(t)})}function wO(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v7`,...q(t)})}function TO(e,t){return new e({type:`string`,format:`url`,check:`string_format`,abort:!1,...q(t)})}function EO(e,t){return new e({type:`string`,format:`emoji`,check:`string_format`,abort:!1,...q(t)})}function DO(e,t){return new e({type:`string`,format:`nanoid`,check:`string_format`,abort:!1,...q(t)})}function OO(e,t){return new e({type:`string`,format:`cuid`,check:`string_format`,abort:!1,...q(t)})}function kO(e,t){return new e({type:`string`,format:`cuid2`,check:`string_format`,abort:!1,...q(t)})}function AO(e,t){return new e({type:`string`,format:`ulid`,check:`string_format`,abort:!1,...q(t)})}function jO(e,t){return new e({type:`string`,format:`xid`,check:`string_format`,abort:!1,...q(t)})}function MO(e,t){return new e({type:`string`,format:`ksuid`,check:`string_format`,abort:!1,...q(t)})}function NO(e,t){return new e({type:`string`,format:`ipv4`,check:`string_format`,abort:!1,...q(t)})}function PO(e,t){return new e({type:`string`,format:`ipv6`,check:`string_format`,abort:!1,...q(t)})}function FO(e,t){return new e({type:`string`,format:`cidrv4`,check:`string_format`,abort:!1,...q(t)})}function IO(e,t){return new e({type:`string`,format:`cidrv6`,check:`string_format`,abort:!1,...q(t)})}function LO(e,t){return new e({type:`string`,format:`base64`,check:`string_format`,abort:!1,...q(t)})}function RO(e,t){return new e({type:`string`,format:`base64url`,check:`string_format`,abort:!1,...q(t)})}function zO(e,t){return new e({type:`string`,format:`e164`,check:`string_format`,abort:!1,...q(t)})}function BO(e,t){return new e({type:`string`,format:`jwt`,check:`string_format`,abort:!1,...q(t)})}function VO(e,t){return new e({type:`string`,format:`datetime`,check:`string_format`,offset:!1,local:!1,precision:null,...q(t)})}function HO(e,t){return new e({type:`string`,format:`date`,check:`string_format`,...q(t)})}function UO(e,t){return new e({type:`string`,format:`time`,check:`string_format`,precision:null,...q(t)})}function WO(e,t){return new e({type:`string`,format:`duration`,check:`string_format`,...q(t)})}function GO(e,t){return new e({type:`number`,checks:[],...q(t)})}function KO(e,t){return new e({type:`number`,check:`number_format`,abort:!1,format:`safeint`,...q(t)})}function qO(e,t){return new e({type:`boolean`,...q(t)})}function JO(e,t){return new e({type:`undefined`,...q(t)})}function YO(e,t){return new e({type:`null`,...q(t)})}function XO(e){return new e({type:`unknown`})}function ZO(e,t){return new e({type:`never`,...q(t)})}function QO(e,t){return new DE({check:`less_than`,...q(t),value:e,inclusive:!1})}function $O(e,t){return new DE({check:`less_than`,...q(t),value:e,inclusive:!0})}function ek(e,t){return new OE({check:`greater_than`,...q(t),value:e,inclusive:!1})}function tk(e,t){return new OE({check:`greater_than`,...q(t),value:e,inclusive:!0})}function nk(e,t){return new kE({check:`multiple_of`,...q(t),value:e})}function rk(e,t){return new jE({check:`max_length`,...q(t),maximum:e})}function ik(e,t){return new ME({check:`min_length`,...q(t),minimum:e})}function ak(e,t){return new NE({check:`length_equals`,...q(t),length:e})}function ok(e,t){return new FE({check:`string_format`,format:`regex`,...q(t),pattern:e})}function sk(e){return new IE({check:`string_format`,format:`lowercase`,...q(e)})}function ck(e){return new LE({check:`string_format`,format:`uppercase`,...q(e)})}function lk(e,t){return new RE({check:`string_format`,format:`includes`,...q(t),includes:e})}function uk(e,t){return new zE({check:`string_format`,format:`starts_with`,...q(t),prefix:e})}function dk(e,t){return new BE({check:`string_format`,format:`ends_with`,...q(t),suffix:e})}function fk(e){return new VE({check:`overwrite`,tx:e})}function pk(e){return fk(t=>t.normalize(e))}function mk(){return fk(e=>e.trim())}function hk(){return fk(e=>e.toLowerCase())}function gk(){return fk(e=>e.toUpperCase())}function _k(){return fk(e=>Yw(e))}function vk(e,t,n){return new e({type:`array`,element:t,...q(n)})}function yk(e,t,n){let r=q(n);return r.abort??=!0,new e({type:`custom`,check:`custom`,fn:t,...r})}function bk(e,t,n){return new e({type:`custom`,check:`custom`,fn:t,...q(n)})}function xk(e,t){let n=Sk(t=>(t.addIssue=e=>{if(typeof e==`string`)t.issues.push(_T(e,t.value,n._zod.def));else{let r=e;r.fatal&&(r.continue=!1),r.code??=`custom`,r.input??=t.value,r.inst??=n,r.continue??=!n._zod.def.abort,t.issues.push(_T(r))}},e(t.value,t)),t);return n}function Sk(e,t){let n=new TE({check:`custom`,...q(t)});return n._zod.check=e,n}var Ck=a((()=>{HE(),CT()}));function wk(e){let t=e?.target??`draft-2020-12`;return t===`draft-4`&&(t=`draft-04`),t===`draft-7`&&(t=`draft-07`),{processors:e.processors??{},metadataRegistry:e?.metadata??gO,target:t,unrepresentable:e?.unrepresentable??`throw`,override:e?.override??(()=>{}),io:e?.io??`output`,counter:0,seen:new Map,cycles:e?.cycles??`ref`,reused:e?.reused??`inline`,external:e?.external??void 0}}function Tk(e,t,n={path:[],schemaPath:[]}){var r;let i=e._zod.def,a=t.seen.get(e);if(a)return a.count++,n.schemaPath.includes(e)&&(a.cycle=n.path),a.schema;let o={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,o);let s=e._zod.toJSONSchema?.();if(s)o.schema=s;else{let r={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,o.schema,r);else{let n=o.schema,a=t.processors[i.type];if(!a)throw Error(`[toJSONSchema]: Non-representable type encountered: ${i.type}`);a(e,t,n,r)}let a=e._zod.parent;a&&(o.ref||=a,Tk(a,t,r),t.seen.get(a).isParent=!0)}let c=t.metadataRegistry.get(e);return c&&Object.assign(o.schema,c),t.io===`input`&&Ok(e)&&(delete o.schema.examples,delete o.schema.default),t.io===`input`&&`_prefault`in o.schema&&((r=o.schema).default??(r.default=o.schema._prefault)),delete o.schema._prefault,t.seen.get(e).schema}function Ek(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);let r=new Map;for(let t of e.seen.entries()){let n=e.metadataRegistry.get(t[0])?.id;if(n){let e=r.get(n);if(e&&e!==t[0])throw Error(`Duplicate schema id "${n}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);r.set(n,t[0])}}let i=t=>{let r=e.target===`draft-2020-12`?`$defs`:`definitions`;if(e.external){let n=e.external.registry.get(t[0])?.id,i=e.external.uri??(e=>e);if(n)return{ref:i(n)};let a=t[1].defId??t[1].schema.id??`schema${e.counter++}`;return t[1].defId=a,{defId:a,ref:`${i(`__shared`)}#/${r}/${a}`}}if(t[1]===n)return{ref:`#`};let i=`#/${r}/`,a=t[1].schema.id??`__schema${e.counter++}`;return{defId:a,ref:i+a}},a=e=>{if(e[1].schema.$ref)return;let t=e[1],{ref:n,defId:r}=i(e);t.def={...t.schema},r&&(t.defId=r);let a=t.schema;for(let e in a)delete a[e];a.$ref=n};if(e.cycles===`throw`)for(let t of e.seen.entries()){let e=t[1];if(e.cycle)throw Error(`Cycle detected: #/${e.cycle?.join(`/`)}/<root>
116
+ `)}t.write(`payload.value = newResult;`),t.write(`return payload;`);let s=t.compile();return(t,n)=>s(e,t,n)},a,o=Qw,s=!Rw.jitless,c=s&&ST.value,l=t.catchall,u;e._zod.parse=(d,f)=>{u??=r.value;let p=d.value;return o(p)?s&&c&&f?.async===!1&&f.jitless!==!0?(a||=i(t.shape),d=a(d,f),l?tD([],p,d,f,u,e):d):n(d,f):(d.issues.push({expected:`object`,code:`invalid_type`,input:p,inst:e}),d)}}),qD=K(`$ZodUnion`,(e,t)=>{dD.init(e,t),qw(e._zod,`optin`,()=>t.options.some(e=>e._zod.optin===`optional`)?`optional`:void 0),qw(e._zod,`optout`,()=>t.options.some(e=>e._zod.optout===`optional`)?`optional`:void 0),qw(e._zod,`values`,()=>{if(t.options.every(e=>e._zod.values))return new Set(t.options.flatMap(e=>Array.from(e._zod.values)))}),qw(e._zod,`pattern`,()=>{if(t.options.every(e=>e._zod.pattern)){let e=t.options.map(e=>e._zod.pattern);return RegExp(`^(${e.map(e=>Gw(e.source)).join(`|`)})$`)}});let n=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(r,i)=>{if(n)return n(r,i);let a=!1,o=[];for(let e of t.options){let t=e._zod.run({value:r.value,issues:[]},i);if(t instanceof Promise)o.push(t),a=!0;else{if(t.issues.length===0)return t;o.push(t)}}return a?Promise.all(o).then(t=>nD(t,r,e,i)):nD(o,r,e,i)}}),JD=K(`$ZodDiscriminatedUnion`,(e,t)=>{t.inclusive=!1,qD.init(e,t);let n=e._zod.parse;qw(e._zod,`propValues`,()=>{let e={};for(let n of t.options){let r=n._zod.propValues;if(!r||Object.keys(r).length===0)throw Error(`Invalid discriminated union option at index "${t.options.indexOf(n)}"`);for(let[t,n]of Object.entries(r)){e[t]||(e[t]=new Set);for(let r of n)e[t].add(r)}}return e});let r=Uw(()=>{let e=t.options,n=new Map;for(let r of e){let e=r._zod.propValues?.[t.discriminator];if(!e||e.size===0)throw Error(`Invalid discriminated union option at index "${t.options.indexOf(r)}"`);for(let t of e){if(n.has(t))throw Error(`Duplicate discriminator value "${String(t)}"`);n.set(t,r)}}return n});e._zod.parse=(i,a)=>{let o=i.value;if(!Qw(o))return i.issues.push({code:`invalid_type`,expected:`object`,input:o,inst:e}),i;let s=r.value.get(o?.[t.discriminator]);return s?s._zod.run(i,a):t.unionFallback||a.direction===`backward`?n(i,a):(i.issues.push({code:`invalid_union`,errors:[],note:`No matching discriminator`,discriminator:t.discriminator,options:Array.from(r.value.keys()),input:o,path:[t.discriminator],inst:e}),i)}}),YD=K(`$ZodIntersection`,(e,t)=>{dD.init(e,t),e._zod.parse=(e,n)=>{let r=e.value,i=t.left._zod.run({value:r,issues:[]},n),a=t.right._zod.run({value:r,issues:[]},n);return i instanceof Promise||a instanceof Promise?Promise.all([i,a]).then(([t,n])=>iD(e,t,n)):iD(e,i,a)}}),XD=K(`$ZodRecord`,(e,t)=>{dD.init(e,t),e._zod.parse=(n,r)=>{let i=n.value;if(!$w(i))return n.issues.push({expected:`record`,code:`invalid_type`,input:i,inst:e}),n;let a=[],o=t.keyType._zod.values;if(o){n.value={};let s=new Set;for(let c of o)if(typeof c==`string`||typeof c==`number`||typeof c==`symbol`){s.add(typeof c==`number`?c.toString():c);let o=t.keyType._zod.run({value:c,issues:[]},r);if(o instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);if(o.issues.length){n.issues.push({code:`invalid_key`,origin:`record`,issues:o.issues.map(e=>gT(e,r,Pw())),input:c,path:[c],inst:e});continue}let l=o.value,u=t.valueType._zod.run({value:i[c],issues:[]},r);u instanceof Promise?a.push(u.then(e=>{e.issues.length&&n.issues.push(...mT(c,e.issues)),n.value[l]=e.value})):(u.issues.length&&n.issues.push(...mT(c,u.issues)),n.value[l]=u.value)}let c;for(let e in i)s.has(e)||(c??=[],c.push(e));c&&c.length>0&&n.issues.push({code:`unrecognized_keys`,input:i,inst:e,keys:c})}else{n.value={};for(let o of Reflect.ownKeys(i)){if(o===`__proto__`||!Object.prototype.propertyIsEnumerable.call(i,o))continue;let s=t.keyType._zod.run({value:o,issues:[]},r);if(s instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);if(typeof o==`string`&&bE.test(o)&&s.issues.length){let e=t.keyType._zod.run({value:Number(o),issues:[]},r);if(e instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);e.issues.length===0&&(s=e)}if(s.issues.length){t.mode===`loose`?n.value[o]=i[o]:n.issues.push({code:`invalid_key`,origin:`record`,issues:s.issues.map(e=>gT(e,r,Pw())),input:o,path:[o],inst:e});continue}let c=t.valueType._zod.run({value:i[o],issues:[]},r);c instanceof Promise?a.push(c.then(e=>{e.issues.length&&n.issues.push(...mT(o,e.issues)),n.value[s.value]=e.value})):(c.issues.length&&n.issues.push(...mT(o,c.issues)),n.value[s.value]=c.value)}}return a.length?Promise.all(a).then(()=>n):n}}),ZD=K(`$ZodEnum`,(e,t)=>{dD.init(e,t);let n=Bw(t.entries),r=new Set(n);e._zod.values=r,e._zod.pattern=RegExp(`^(${n.filter(e=>CT.has(typeof e)).map(e=>typeof e==`string`?tT(e):e.toString()).join(`|`)})$`),e._zod.parse=(t,i)=>{let a=t.value;return r.has(a)||t.issues.push({code:`invalid_value`,values:n,input:a,inst:e}),t}}),QD=K(`$ZodLiteral`,(e,t)=>{if(dD.init(e,t),t.values.length===0)throw Error(`Cannot create literal schema with no valid values`);let n=new Set(t.values);e._zod.values=n,e._zod.pattern=RegExp(`^(${t.values.map(e=>typeof e==`string`?tT(e):e?tT(e.toString()):String(e)).join(`|`)})$`),e._zod.parse=(r,i)=>{let a=r.value;return n.has(a)||r.issues.push({code:`invalid_value`,values:t.values,input:a,inst:e}),r}}),$D=K(`$ZodTransform`,(e,t)=>{dD.init(e,t),e._zod.optin=`optional`,e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new Lw(e.constructor.name);let i=t.transform(n.value,n);if(r.async)return(i instanceof Promise?i:Promise.resolve(i)).then(e=>(n.value=e,n.fallback=!0,n));if(i instanceof Promise)throw new Iw;return n.value=i,n.fallback=!0,n}}),eO=K(`$ZodOptional`,(e,t)=>{dD.init(e,t),e._zod.optin=`optional`,e._zod.optout=`optional`,qw(e._zod,`values`,()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),qw(e._zod,`pattern`,()=>{let e=t.innerType._zod.pattern;return e?RegExp(`^(${Gw(e.source)})?$`):void 0}),e._zod.parse=(e,n)=>{if(t.innerType._zod.optin===`optional`){let r=e.value,i=t.innerType._zod.run(e,n);return i instanceof Promise?i.then(e=>aD(e,r)):aD(i,r)}return e.value===void 0?e:t.innerType._zod.run(e,n)}}),tO=K(`$ZodExactOptional`,(e,t)=>{eO.init(e,t),qw(e._zod,`values`,()=>t.innerType._zod.values),qw(e._zod,`pattern`,()=>t.innerType._zod.pattern),e._zod.parse=(e,n)=>t.innerType._zod.run(e,n)}),nO=K(`$ZodNullable`,(e,t)=>{dD.init(e,t),qw(e._zod,`optin`,()=>t.innerType._zod.optin),qw(e._zod,`optout`,()=>t.innerType._zod.optout),qw(e._zod,`pattern`,()=>{let e=t.innerType._zod.pattern;return e?RegExp(`^(${Gw(e.source)}|null)$`):void 0}),qw(e._zod,`values`,()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(e,n)=>e.value===null?e:t.innerType._zod.run(e,n)}),rO=K(`$ZodDefault`,(e,t)=>{dD.init(e,t),e._zod.optin=`optional`,qw(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);if(e.value===void 0)return e.value=t.defaultValue,e;let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(e=>oD(e,t)):oD(r,t)}}),iO=K(`$ZodPrefault`,(e,t)=>{dD.init(e,t),e._zod.optin=`optional`,qw(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>(n.direction===`backward`||e.value===void 0&&(e.value=t.defaultValue),t.innerType._zod.run(e,n))}),aO=K(`$ZodNonOptional`,(e,t)=>{dD.init(e,t),qw(e._zod,`values`,()=>{let e=t.innerType._zod.values;return e?new Set([...e].filter(e=>e!==void 0)):void 0}),e._zod.parse=(n,r)=>{let i=t.innerType._zod.run(n,r);return i instanceof Promise?i.then(t=>sD(t,e)):sD(i,e)}}),oO=K(`$ZodCatch`,(e,t)=>{dD.init(e,t),e._zod.optin=`optional`,qw(e._zod,`optout`,()=>t.innerType._zod.optout),qw(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(r=>(e.value=r.value,r.issues.length&&(e.value=t.catchValue({...e,error:{issues:r.issues.map(e=>gT(e,n,Pw()))},input:e.value}),e.issues=[],e.fallback=!0),e)):(e.value=r.value,r.issues.length&&(e.value=t.catchValue({...e,error:{issues:r.issues.map(e=>gT(e,n,Pw()))},input:e.value}),e.issues=[],e.fallback=!0),e)}}),sO=K(`$ZodPipe`,(e,t)=>{dD.init(e,t),qw(e._zod,`values`,()=>t.in._zod.values),qw(e._zod,`optin`,()=>t.in._zod.optin),qw(e._zod,`optout`,()=>t.out._zod.optout),qw(e._zod,`propValues`,()=>t.in._zod.propValues),e._zod.parse=(e,n)=>{if(n.direction===`backward`){let r=t.out._zod.run(e,n);return r instanceof Promise?r.then(e=>cD(e,t.in,n)):cD(r,t.in,n)}let r=t.in._zod.run(e,n);return r instanceof Promise?r.then(e=>cD(e,t.out,n)):cD(r,t.out,n)}}),cO=K(`$ZodPreprocess`,(e,t)=>{sO.init(e,t)}),lO=K(`$ZodReadonly`,(e,t)=>{dD.init(e,t),qw(e._zod,`propValues`,()=>t.innerType._zod.propValues),qw(e._zod,`values`,()=>t.innerType._zod.values),qw(e._zod,`optin`,()=>t.innerType?._zod?.optin),qw(e._zod,`optout`,()=>t.innerType?._zod?.optout),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(lD):lD(r)}}),uO=K(`$ZodCustom`,(e,t)=>{DE.init(e,t),dD.init(e,t),e._zod.parse=(e,t)=>e,e._zod.check=n=>{let r=n.value,i=t.fn(r);if(i instanceof Promise)return i.then(t=>uD(t,n,r,e));uD(i,n,r,e)}})}));function fO(){return{localeError:pO()}}var pO,mO=a((()=>{TT(),pO=()=>{let e={string:{unit:`characters`,verb:`to have`},file:{unit:`bytes`,verb:`to have`},array:{unit:`items`,verb:`to have`},set:{unit:`items`,verb:`to have`},map:{unit:`entries`,verb:`to have`}};function t(t){return e[t]??null}let n={regex:`input`,email:`email address`,url:`URL`,emoji:`emoji`,uuid:`UUID`,uuidv4:`UUIDv4`,uuidv6:`UUIDv6`,nanoid:`nanoid`,guid:`GUID`,cuid:`cuid`,cuid2:`cuid2`,ulid:`ULID`,xid:`XID`,ksuid:`KSUID`,datetime:`ISO datetime`,date:`ISO date`,time:`ISO time`,duration:`ISO duration`,ipv4:`IPv4 address`,ipv6:`IPv6 address`,mac:`MAC address`,cidrv4:`IPv4 range`,cidrv6:`IPv6 range`,base64:`base64-encoded string`,base64url:`base64url-encoded string`,json_string:`JSON string`,e164:`E.164 number`,jwt:`JWT`,template_literal:`input`},r={nan:`NaN`};return e=>{switch(e.code){case`invalid_type`:{let t=r[e.expected]??e.expected,n=vT(e.input);return`Invalid input: expected ${t}, received ${r[n]??n}`}case`invalid_value`:return e.values.length===1?`Invalid input: expected ${rT(e.values[0])}`:`Invalid option: expected one of ${Vw(e.values,`|`)}`;case`too_big`:{let n=e.inclusive?`<=`:`<`,r=t(e.origin);return r?`Too big: expected ${e.origin??`value`} to have ${n}${e.maximum.toString()} ${r.unit??`elements`}`:`Too big: expected ${e.origin??`value`} to be ${n}${e.maximum.toString()}`}case`too_small`:{let n=e.inclusive?`>=`:`>`,r=t(e.origin);return r?`Too small: expected ${e.origin} to have ${n}${e.minimum.toString()} ${r.unit}`:`Too small: expected ${e.origin} to be ${n}${e.minimum.toString()}`}case`invalid_format`:{let t=e;return t.format===`starts_with`?`Invalid string: must start with "${t.prefix}"`:t.format===`ends_with`?`Invalid string: must end with "${t.suffix}"`:t.format===`includes`?`Invalid string: must include "${t.includes}"`:t.format===`regex`?`Invalid string: must match pattern ${t.pattern}`:`Invalid ${n[t.format]??e.format}`}case`not_multiple_of`:return`Invalid number: must be a multiple of ${e.divisor}`;case`unrecognized_keys`:return`Unrecognized key${e.keys.length>1?`s`:``}: ${Vw(e.keys,`, `)}`;case`invalid_key`:return`Invalid key in ${e.origin}`;case`invalid_union`:return e.options&&Array.isArray(e.options)&&e.options.length>0?`Invalid discriminator value. Expected ${e.options.map(e=>`'${e}'`).join(` | `)}`:`Invalid input`;case`invalid_element`:return`Invalid value in ${e.origin}`;default:return`Invalid input`}}}}));function hO(){return new _O}var gO,_O,vO,yO=a((()=>{_O=class{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...t){let n=t[0];return this._map.set(e,n),n&&typeof n==`object`&&`id`in n&&this._idmap.set(n.id,e),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(e){let t=this._map.get(e);return t&&typeof t==`object`&&`id`in t&&this._idmap.delete(t.id),this._map.delete(e),this}get(e){let t=e._zod.parent;if(t){let n={...this.get(t)??{}};delete n.id;let r={...n,...this._map.get(e)};return Object.keys(r).length?r:void 0}return this._map.get(e)}has(e){return this._map.has(e)}},(gO=globalThis).__zod_globalRegistry??(gO.__zod_globalRegistry=hO()),vO=globalThis.__zod_globalRegistry}));function bO(e,t){return new e({type:`string`,...q(t)})}function xO(e,t){return new e({type:`string`,format:`email`,check:`string_format`,abort:!1,...q(t)})}function SO(e,t){return new e({type:`string`,format:`guid`,check:`string_format`,abort:!1,...q(t)})}function CO(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,...q(t)})}function wO(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v4`,...q(t)})}function TO(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v6`,...q(t)})}function EO(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v7`,...q(t)})}function DO(e,t){return new e({type:`string`,format:`url`,check:`string_format`,abort:!1,...q(t)})}function OO(e,t){return new e({type:`string`,format:`emoji`,check:`string_format`,abort:!1,...q(t)})}function kO(e,t){return new e({type:`string`,format:`nanoid`,check:`string_format`,abort:!1,...q(t)})}function AO(e,t){return new e({type:`string`,format:`cuid`,check:`string_format`,abort:!1,...q(t)})}function jO(e,t){return new e({type:`string`,format:`cuid2`,check:`string_format`,abort:!1,...q(t)})}function MO(e,t){return new e({type:`string`,format:`ulid`,check:`string_format`,abort:!1,...q(t)})}function NO(e,t){return new e({type:`string`,format:`xid`,check:`string_format`,abort:!1,...q(t)})}function PO(e,t){return new e({type:`string`,format:`ksuid`,check:`string_format`,abort:!1,...q(t)})}function FO(e,t){return new e({type:`string`,format:`ipv4`,check:`string_format`,abort:!1,...q(t)})}function IO(e,t){return new e({type:`string`,format:`ipv6`,check:`string_format`,abort:!1,...q(t)})}function LO(e,t){return new e({type:`string`,format:`cidrv4`,check:`string_format`,abort:!1,...q(t)})}function RO(e,t){return new e({type:`string`,format:`cidrv6`,check:`string_format`,abort:!1,...q(t)})}function zO(e,t){return new e({type:`string`,format:`base64`,check:`string_format`,abort:!1,...q(t)})}function BO(e,t){return new e({type:`string`,format:`base64url`,check:`string_format`,abort:!1,...q(t)})}function VO(e,t){return new e({type:`string`,format:`e164`,check:`string_format`,abort:!1,...q(t)})}function HO(e,t){return new e({type:`string`,format:`jwt`,check:`string_format`,abort:!1,...q(t)})}function UO(e,t){return new e({type:`string`,format:`datetime`,check:`string_format`,offset:!1,local:!1,precision:null,...q(t)})}function WO(e,t){return new e({type:`string`,format:`date`,check:`string_format`,...q(t)})}function GO(e,t){return new e({type:`string`,format:`time`,check:`string_format`,precision:null,...q(t)})}function KO(e,t){return new e({type:`string`,format:`duration`,check:`string_format`,...q(t)})}function qO(e,t){return new e({type:`number`,checks:[],...q(t)})}function JO(e,t){return new e({type:`number`,check:`number_format`,abort:!1,format:`safeint`,...q(t)})}function YO(e,t){return new e({type:`boolean`,...q(t)})}function XO(e,t){return new e({type:`undefined`,...q(t)})}function ZO(e,t){return new e({type:`null`,...q(t)})}function QO(e){return new e({type:`unknown`})}function $O(e,t){return new e({type:`never`,...q(t)})}function ek(e,t){return new kE({check:`less_than`,...q(t),value:e,inclusive:!1})}function tk(e,t){return new kE({check:`less_than`,...q(t),value:e,inclusive:!0})}function nk(e,t){return new AE({check:`greater_than`,...q(t),value:e,inclusive:!1})}function rk(e,t){return new AE({check:`greater_than`,...q(t),value:e,inclusive:!0})}function ik(e,t){return new jE({check:`multiple_of`,...q(t),value:e})}function ak(e,t){return new NE({check:`max_length`,...q(t),maximum:e})}function ok(e,t){return new PE({check:`min_length`,...q(t),minimum:e})}function sk(e,t){return new FE({check:`length_equals`,...q(t),length:e})}function ck(e,t){return new LE({check:`string_format`,format:`regex`,...q(t),pattern:e})}function lk(e){return new RE({check:`string_format`,format:`lowercase`,...q(e)})}function uk(e){return new zE({check:`string_format`,format:`uppercase`,...q(e)})}function dk(e,t){return new BE({check:`string_format`,format:`includes`,...q(t),includes:e})}function fk(e,t){return new VE({check:`string_format`,format:`starts_with`,...q(t),prefix:e})}function pk(e,t){return new HE({check:`string_format`,format:`ends_with`,...q(t),suffix:e})}function mk(e){return new UE({check:`overwrite`,tx:e})}function hk(e){return mk(t=>t.normalize(e))}function gk(){return mk(e=>e.trim())}function _k(){return mk(e=>e.toLowerCase())}function vk(){return mk(e=>e.toUpperCase())}function yk(){return mk(e=>Zw(e))}function bk(e,t,n){return new e({type:`array`,element:t,...q(n)})}function xk(e,t,n){let r=q(n);return r.abort??=!0,new e({type:`custom`,check:`custom`,fn:t,...r})}function Sk(e,t,n){return new e({type:`custom`,check:`custom`,fn:t,...q(n)})}function Ck(e,t){let n=wk(t=>(t.addIssue=e=>{if(typeof e==`string`)t.issues.push(yT(e,t.value,n._zod.def));else{let r=e;r.fatal&&(r.continue=!1),r.code??=`custom`,r.input??=t.value,r.inst??=n,r.continue??=!n._zod.def.abort,t.issues.push(yT(r))}},e(t.value,t)),t);return n}function wk(e,t){let n=new DE({check:`custom`,...q(t)});return n._zod.check=e,n}var Tk=a((()=>{WE(),TT()}));function Ek(e){let t=e?.target??`draft-2020-12`;return t===`draft-4`&&(t=`draft-04`),t===`draft-7`&&(t=`draft-07`),{processors:e.processors??{},metadataRegistry:e?.metadata??vO,target:t,unrepresentable:e?.unrepresentable??`throw`,override:e?.override??(()=>{}),io:e?.io??`output`,counter:0,seen:new Map,cycles:e?.cycles??`ref`,reused:e?.reused??`inline`,external:e?.external??void 0}}function Dk(e,t,n={path:[],schemaPath:[]}){var r;let i=e._zod.def,a=t.seen.get(e);if(a)return a.count++,n.schemaPath.includes(e)&&(a.cycle=n.path),a.schema;let o={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,o);let s=e._zod.toJSONSchema?.();if(s)o.schema=s;else{let r={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,o.schema,r);else{let n=o.schema,a=t.processors[i.type];if(!a)throw Error(`[toJSONSchema]: Non-representable type encountered: ${i.type}`);a(e,t,n,r)}let a=e._zod.parent;a&&(o.ref||=a,Dk(a,t,r),t.seen.get(a).isParent=!0)}let c=t.metadataRegistry.get(e);return c&&Object.assign(o.schema,c),t.io===`input`&&Ak(e)&&(delete o.schema.examples,delete o.schema.default),t.io===`input`&&`_prefault`in o.schema&&((r=o.schema).default??(r.default=o.schema._prefault)),delete o.schema._prefault,t.seen.get(e).schema}function Ok(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);let r=new Map;for(let t of e.seen.entries()){let n=e.metadataRegistry.get(t[0])?.id;if(n){let e=r.get(n);if(e&&e!==t[0])throw Error(`Duplicate schema id "${n}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);r.set(n,t[0])}}let i=t=>{let r=e.target===`draft-2020-12`?`$defs`:`definitions`;if(e.external){let n=e.external.registry.get(t[0])?.id,i=e.external.uri??(e=>e);if(n)return{ref:i(n)};let a=t[1].defId??t[1].schema.id??`schema${e.counter++}`;return t[1].defId=a,{defId:a,ref:`${i(`__shared`)}#/${r}/${a}`}}if(t[1]===n)return{ref:`#`};let i=`#/${r}/`,a=t[1].schema.id??`__schema${e.counter++}`;return{defId:a,ref:i+a}},a=e=>{if(e[1].schema.$ref)return;let t=e[1],{ref:n,defId:r}=i(e);t.def={...t.schema},r&&(t.defId=r);let a=t.schema;for(let e in a)delete a[e];a.$ref=n};if(e.cycles===`throw`)for(let t of e.seen.entries()){let e=t[1];if(e.cycle)throw Error(`Cycle detected: #/${e.cycle?.join(`/`)}/<root>
117
117
 
118
- Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let n of e.seen.entries()){let r=n[1];if(t===n[0]){a(n);continue}if(e.external){let r=e.external.registry.get(n[0])?.id;if(t!==n[0]&&r){a(n);continue}}if(e.metadataRegistry.get(n[0])?.id){a(n);continue}if(r.cycle){a(n);continue}if(r.count>1&&e.reused===`ref`){a(n);continue}}}function Dk(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);let r=t=>{let n=e.seen.get(t);if(n.ref===null)return;let i=n.def??n.schema,a={...i},o=n.ref;if(n.ref=null,o){r(o);let n=e.seen.get(o),s=n.schema;if(s.$ref&&(e.target===`draft-07`||e.target===`draft-04`||e.target===`openapi-3.0`)?(i.allOf=i.allOf??[],i.allOf.push(s)):Object.assign(i,s),Object.assign(i,a),t._zod.parent===o)for(let e in i)e===`$ref`||e===`allOf`||e in a||delete i[e];if(s.$ref&&n.def)for(let e in i)e===`$ref`||e===`allOf`||e in n.def&&JSON.stringify(i[e])===JSON.stringify(n.def[e])&&delete i[e]}let s=t._zod.parent;if(s&&s!==o){r(s);let t=e.seen.get(s);if(t?.schema.$ref&&(i.$ref=t.schema.$ref,t.def))for(let e in i)e===`$ref`||e===`allOf`||e in t.def&&JSON.stringify(i[e])===JSON.stringify(t.def[e])&&delete i[e]}e.override({zodSchema:t,jsonSchema:i,path:n.path??[]})};for(let t of[...e.seen.entries()].reverse())r(t[0]);let i={};if(e.target===`draft-2020-12`?i.$schema=`https://json-schema.org/draft/2020-12/schema`:e.target===`draft-07`?i.$schema=`http://json-schema.org/draft-07/schema#`:e.target===`draft-04`?i.$schema=`http://json-schema.org/draft-04/schema#`:e.target,e.external?.uri){let n=e.external.registry.get(t)?.id;if(!n)throw Error("Schema is missing an `id` property");i.$id=e.external.uri(n)}Object.assign(i,n.def??n.schema);let a=e.metadataRegistry.get(t)?.id;a!==void 0&&i.id===a&&delete i.id;let o=e.external?.defs??{};for(let t of e.seen.entries()){let e=t[1];e.def&&e.defId&&(e.def.id===e.defId&&delete e.def.id,o[e.defId]=e.def)}e.external||Object.keys(o).length>0&&(e.target===`draft-2020-12`?i.$defs=o:i.definitions=o);try{let n=JSON.parse(JSON.stringify(i));return Object.defineProperty(n,"~standard",{value:{...t[`~standard`],jsonSchema:{input:Ak(t,`input`,e.processors),output:Ak(t,`output`,e.processors)}},enumerable:!1,writable:!1}),n}catch{throw Error(`Error converting schema to JSON.`)}}function Ok(e,t){let n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);let r=e._zod.def;if(r.type===`transform`)return!0;if(r.type===`array`)return Ok(r.element,n);if(r.type===`set`)return Ok(r.valueType,n);if(r.type===`lazy`)return Ok(r.getter(),n);if(r.type===`promise`||r.type===`optional`||r.type===`nonoptional`||r.type===`nullable`||r.type===`readonly`||r.type==="default"||r.type===`prefault`)return Ok(r.innerType,n);if(r.type===`intersection`)return Ok(r.left,n)||Ok(r.right,n);if(r.type===`record`||r.type===`map`)return Ok(r.keyType,n)||Ok(r.valueType,n);if(r.type===`pipe`)return e._zod.traits.has(`$ZodCodec`)?!0:Ok(r.in,n)||Ok(r.out,n);if(r.type===`object`){for(let e in r.shape)if(Ok(r.shape[e],n))return!0;return!1}if(r.type===`union`){for(let e of r.options)if(Ok(e,n))return!0;return!1}if(r.type===`tuple`){for(let e of r.items)if(Ok(e,n))return!0;return!!(r.rest&&Ok(r.rest,n))}return!1}var kk,Ak,jk=a((()=>{_O(),kk=(e,t={})=>n=>{let r=wk({...n,processors:t});return Tk(e,r),Ek(r,e),Dk(r,e)},Ak=(e,t,n={})=>r=>{let{libraryOptions:i,target:a}=r??{},o=wk({...i??{},target:a,io:t,processors:n});return Tk(e,o),Ek(o,e),Dk(o,e)}})),Mk,Nk,Pk,Fk,Ik,Lk,Rk,zk,Bk,Vk,Hk,Uk,Wk,Gk,Kk,qk,Jk,Yk,Xk,Zk,Qk,$k,eA,tA,nA,rA=a((()=>{jk(),CT(),Mk={guid:`uuid`,url:`uri`,datetime:`date-time`,json_string:`json-string`,regex:``},Nk=(e,t,n,r)=>{let i=n;i.type=`string`;let{minimum:a,maximum:o,format:s,patterns:c,contentEncoding:l}=e._zod.bag;if(typeof a==`number`&&(i.minLength=a),typeof o==`number`&&(i.maxLength=o),s&&(i.format=Mk[s]??s,i.format===``&&delete i.format,s===`time`&&delete i.format),l&&(i.contentEncoding=l),c&&c.size>0){let e=[...c];e.length===1?i.pattern=e[0].source:e.length>1&&(i.allOf=[...e.map(e=>({...t.target===`draft-07`||t.target===`draft-04`||t.target===`openapi-3.0`?{type:`string`}:{},pattern:e.source}))])}},Pk=(e,t,n,r)=>{let i=n,{minimum:a,maximum:o,format:s,multipleOf:c,exclusiveMaximum:l,exclusiveMinimum:u}=e._zod.bag;typeof s==`string`&&s.includes(`int`)?i.type=`integer`:i.type=`number`;let d=typeof u==`number`&&u>=(a??-1/0),f=typeof l==`number`&&l<=(o??1/0),p=t.target===`draft-04`||t.target===`openapi-3.0`;d?p?(i.minimum=u,i.exclusiveMinimum=!0):i.exclusiveMinimum=u:typeof a==`number`&&(i.minimum=a),f?p?(i.maximum=l,i.exclusiveMaximum=!0):i.exclusiveMaximum=l:typeof o==`number`&&(i.maximum=o),typeof c==`number`&&(i.multipleOf=c)},Fk=(e,t,n,r)=>{n.type=`boolean`},Ik=(e,t,n,r)=>{t.target===`openapi-3.0`?(n.type=`string`,n.nullable=!0,n.enum=[null]):n.type=`null`},Lk=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Undefined cannot be represented in JSON Schema`)},Rk=(e,t,n,r)=>{n.not={}},zk=(e,t,n,r)=>{},Bk=(e,t,n,r)=>{let i=e._zod.def,a=Rw(i.entries);a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),n.enum=a},Vk=(e,t,n,r)=>{let i=e._zod.def,a=[];for(let e of i.values)if(e===void 0){if(t.unrepresentable===`throw`)throw Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof e==`bigint`){if(t.unrepresentable===`throw`)throw Error(`BigInt literals cannot be represented in JSON Schema`);a.push(Number(e))}else a.push(e);if(a.length!==0)if(a.length===1){let e=a[0];n.type=e===null?`null`:typeof e,t.target===`draft-04`||t.target===`openapi-3.0`?n.enum=[e]:n.const=e}else a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),a.every(e=>typeof e==`boolean`)&&(n.type=`boolean`),a.every(e=>e===null)&&(n.type=`null`),n.enum=a},Hk=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Custom types cannot be represented in JSON Schema`)},Uk=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Transforms cannot be represented in JSON Schema`)},Wk=(e,t,n,r)=>{let i=n,a=e._zod.def,{minimum:o,maximum:s}=e._zod.bag;typeof o==`number`&&(i.minItems=o),typeof s==`number`&&(i.maxItems=s),i.type=`array`,i.items=Tk(a.element,t,{...r,path:[...r.path,`items`]})},Gk=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`object`,i.properties={};let o=a.shape;for(let e in o)i.properties[e]=Tk(o[e],t,{...r,path:[...r.path,`properties`,e]});let s=new Set(Object.keys(o)),c=new Set([...s].filter(e=>{let n=a.shape[e]._zod;return t.io===`input`?n.optin===void 0:n.optout===void 0}));c.size>0&&(i.required=Array.from(c)),a.catchall?._zod.def.type===`never`?i.additionalProperties=!1:a.catchall?a.catchall&&(i.additionalProperties=Tk(a.catchall,t,{...r,path:[...r.path,`additionalProperties`]})):t.io===`output`&&(i.additionalProperties=!1)},Kk=(e,t,n,r)=>{let i=e._zod.def,a=i.inclusive===!1,o=i.options.map((e,n)=>Tk(e,t,{...r,path:[...r.path,a?`oneOf`:`anyOf`,n]}));a?n.oneOf=o:n.anyOf=o},qk=(e,t,n,r)=>{let i=e._zod.def,a=Tk(i.left,t,{...r,path:[...r.path,`allOf`,0]}),o=Tk(i.right,t,{...r,path:[...r.path,`allOf`,1]}),s=e=>`allOf`in e&&Object.keys(e).length===1;n.allOf=[...s(a)?a.allOf:[a],...s(o)?o.allOf:[o]]},Jk=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`object`;let o=a.keyType,s=o._zod.bag?.patterns;if(a.mode===`loose`&&s&&s.size>0){let e=Tk(a.valueType,t,{...r,path:[...r.path,`patternProperties`,`*`]});i.patternProperties={};for(let t of s)i.patternProperties[t.source]=e}else(t.target===`draft-07`||t.target===`draft-2020-12`)&&(i.propertyNames=Tk(a.keyType,t,{...r,path:[...r.path,`propertyNames`]})),i.additionalProperties=Tk(a.valueType,t,{...r,path:[...r.path,`additionalProperties`]});let c=o._zod.values;if(c){let e=[...c].filter(e=>typeof e==`string`||typeof e==`number`);e.length>0&&(i.required=e)}},Yk=(e,t,n,r)=>{let i=e._zod.def,a=Tk(i.innerType,t,r),o=t.seen.get(e);t.target===`openapi-3.0`?(o.ref=i.innerType,n.nullable=!0):n.anyOf=[a,{type:`null`}]},Xk=(e,t,n,r)=>{let i=e._zod.def;Tk(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},Zk=(e,t,n,r)=>{let i=e._zod.def;Tk(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.default=JSON.parse(JSON.stringify(i.defaultValue))},Qk=(e,t,n,r)=>{let i=e._zod.def;Tk(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,t.io===`input`&&(n._prefault=JSON.parse(JSON.stringify(i.defaultValue)))},$k=(e,t,n,r)=>{let i=e._zod.def;Tk(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o;try{o=i.catchValue(void 0)}catch{throw Error(`Dynamic catch values are not supported in JSON Schema`)}n.default=o},eA=(e,t,n,r)=>{let i=e._zod.def,a=i.in._zod.traits.has(`$ZodTransform`),o=t.io===`input`?a?i.out:i.in:i.out;Tk(o,t,r);let s=t.seen.get(e);s.ref=o},tA=(e,t,n,r)=>{let i=e._zod.def;Tk(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.readOnly=!0},nA=(e,t,n,r)=>{let i=e._zod.def;Tk(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType}})),iA=a((()=>{Lw(),WT(),kT(),lO(),HE(),KE(),CT(),wE(),fO(),_O(),WE(),Ck(),jk(),rA(),jk()})),aA=a((()=>{iA()}));function oA(e){return VO(uA,e)}function sA(e){return HO(dA,e)}function cA(e){return UO(fA,e)}function lA(e){return WO(pA,e)}var uA,dA,fA,pA,mA=a((()=>{iA(),nM(),uA=K(`ZodISODateTime`,(e,t)=>{CD.init(e,t),lj.init(e,t)}),dA=K(`ZodISODate`,(e,t)=>{wD.init(e,t),lj.init(e,t)}),fA=K(`ZodISOTime`,(e,t)=>{TD.init(e,t),lj.init(e,t)}),pA=K(`ZodISODuration`,(e,t)=>{ED.init(e,t),lj.init(e,t)})})),hA,gA,_A=a((()=>{iA(),CT(),hA=(e,t)=>{DT.init(e,t),e.name=`ZodError`,Object.defineProperties(e,{format:{value:t=>TT(e,t)},flatten:{value:t=>wT(e,t)},addIssue:{value:t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,Bw,2)}},addIssues:{value:t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,Bw,2)}},isEmpty:{get(){return e.issues.length===0}}})},gA=K(`ZodError`,hA,{Parent:Error})})),vA,yA,bA,xA,SA,CA,wA,TA,EA,DA,OA,kA,AA=a((()=>{iA(),_A(),vA=AT(gA),yA=jT(gA),bA=MT(gA),xA=PT(gA),SA=IT(gA),CA=LT(gA),wA=RT(gA),TA=zT(gA),EA=BT(gA),DA=VT(gA),OA=HT(gA),kA=UT(gA)}));function jA(e,t,n){let r=Object.getPrototypeOf(e),i=aj.get(r);if(i||(i=new Set,aj.set(r,i)),!i.has(t)){i.add(t);for(let e in n){let t=n[e];Object.defineProperty(r,e,{configurable:!0,enumerable:!1,get(){let n=t.bind(this);return Object.defineProperty(this,e,{configurable:!0,writable:!0,enumerable:!0,value:n}),n},set(t){Object.defineProperty(this,e,{configurable:!0,writable:!0,enumerable:!0,value:t})}})}}}function J(e){return vO(cj,e)}function MA(e){return GO(kj,e)}function NA(e){return KO(Aj,e)}function PA(e){return qO(jj,e)}function FA(e){return JO(Mj,e)}function IA(e){return YO(Nj,e)}function LA(){return XO(Pj)}function RA(e){return ZO(Fj,e)}function Y(e,t){return vk(Ij,e,t)}function X(e,t){let n={type:`object`,shape:e??{},...q(t)};return new Lj(n)}function zA(e,t){return new Lj({type:`object`,shape:e,catchall:LA(),...q(t)})}function BA(e,t){return new Rj({type:`union`,options:e,...q(t)})}function VA(e,t,n){return new zj({type:`union`,options:t,discriminator:e,...q(n)})}function HA(e,t){return new Bj({type:`intersection`,left:e,right:t})}function UA(e,t,n){return!t||!t._zod?new Vj({type:`record`,keyType:J(),valueType:e,...q(t)}):new Vj({type:`record`,keyType:e,valueType:t,...q(n)})}function WA(e,t){let n=Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e;return new Hj({type:`enum`,entries:n,...q(t)})}function Z(e,t){return new Uj({type:`literal`,values:Array.isArray(e)?e:[e],...q(t)})}function GA(e){return new Wj({type:`transform`,transform:e})}function KA(e){return new Gj({type:`optional`,innerType:e})}function qA(e){return new Kj({type:`optional`,innerType:e})}function JA(e){return new qj({type:`nullable`,innerType:e})}function YA(e,t){return new Jj({type:`default`,innerType:e,get defaultValue(){return typeof t==`function`?t():Qw(t)}})}function XA(e,t){return new Yj({type:`prefault`,innerType:e,get defaultValue(){return typeof t==`function`?t():Qw(t)}})}function ZA(e,t){return new Xj({type:`nonoptional`,innerType:e,...q(t)})}function QA(e,t){return new Zj({type:`catch`,innerType:e,catchValue:typeof t==`function`?t:()=>t})}function $A(e,t){return new Qj({type:`pipe`,in:e,out:t})}function ej(e){return new eM({type:`readonly`,innerType:e})}function tj(e,t){return yk(tM,e??(()=>!0),t)}function nj(e,t={}){return bk(tM,e,t)}function rj(e,t){return xk(e,t)}function ij(e,t){return new $j({type:`pipe`,in:GA(e),out:t})}var aj,oj,sj,cj,lj,uj,dj,fj,pj,mj,hj,gj,_j,vj,yj,bj,xj,Sj,Cj,wj,Tj,Ej,Dj,Oj,kj,Aj,jj,Mj,Nj,Pj,Fj,Ij,Lj,Rj,zj,Bj,Vj,Hj,Uj,Wj,Gj,Kj,qj,Jj,Yj,Xj,Zj,Qj,$j,eM,tM,nM=a((()=>{iA(),rA(),jk(),aA(),mA(),AA(),aj=new WeakMap,oj=K(`ZodType`,(e,t)=>(lD.init(e,t),Object.assign(e[`~standard`],{jsonSchema:{input:Ak(e,`input`),output:Ak(e,`output`)}}),e.toJSONSchema=kk(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.parse=(t,n)=>vA(e,t,n,{callee:e.parse}),e.safeParse=(t,n)=>bA(e,t,n),e.parseAsync=async(t,n)=>yA(e,t,n,{callee:e.parseAsync}),e.safeParseAsync=async(t,n)=>xA(e,t,n),e.spa=e.safeParseAsync,e.encode=(t,n)=>SA(e,t,n),e.decode=(t,n)=>CA(e,t,n),e.encodeAsync=async(t,n)=>wA(e,t,n),e.decodeAsync=async(t,n)=>TA(e,t,n),e.safeEncode=(t,n)=>EA(e,t,n),e.safeDecode=(t,n)=>DA(e,t,n),e.safeEncodeAsync=async(t,n)=>OA(e,t,n),e.safeDecodeAsync=async(t,n)=>kA(e,t,n),jA(e,`ZodType`,{check(...e){let t=this.def;return this.clone(qw(t,{checks:[...t.checks??[],...e.map(e=>typeof e==`function`?{_zod:{check:e,def:{check:`custom`},onattach:[]}}:e)]}),{parent:!0})},with(...e){return this.check(...e)},clone(e,t){return eT(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(nj(e,t))},superRefine(e,t){return this.check(rj(e,t))},overwrite(e){return this.check(fk(e))},optional(){return KA(this)},exactOptional(){return qA(this)},nullable(){return JA(this)},nullish(){return KA(JA(this))},nonoptional(e){return ZA(this,e)},array(){return Y(this)},or(e){return BA([this,e])},and(e){return HA(this,e)},transform(e){return $A(this,GA(e))},default(e){return YA(this,e)},prefault(e){return XA(this,e)},catch(e){return QA(this,e)},pipe(e){return $A(this,e)},readonly(){return ej(this)},describe(e){let t=this.clone();return gO.add(t,{description:e}),t},meta(...e){if(e.length===0)return gO.get(this);let t=this.clone();return gO.add(t,e[0]),t},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(e){return e(this)}}),Object.defineProperty(e,"description",{get(){return gO.get(e)?.description},configurable:!0}),e)),sj=K(`_ZodString`,(e,t)=>{uD.init(e,t),oj.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Nk(e,t,n,r);let n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,jA(e,`_ZodString`,{regex(...e){return this.check(ok(...e))},includes(...e){return this.check(lk(...e))},startsWith(...e){return this.check(uk(...e))},endsWith(...e){return this.check(dk(...e))},min(...e){return this.check(ik(...e))},max(...e){return this.check(rk(...e))},length(...e){return this.check(ak(...e))},nonempty(...e){return this.check(ik(1,...e))},lowercase(e){return this.check(sk(e))},uppercase(e){return this.check(ck(e))},trim(){return this.check(mk())},normalize(...e){return this.check(pk(...e))},toLowerCase(){return this.check(hk())},toUpperCase(){return this.check(gk())},slugify(){return this.check(_k())}})}),cj=K(`ZodString`,(e,t)=>{uD.init(e,t),sj.init(e,t),e.email=t=>e.check(yO(uj,t)),e.url=t=>e.check(TO(pj,t)),e.jwt=t=>e.check(BO(Oj,t)),e.emoji=t=>e.check(EO(mj,t)),e.guid=t=>e.check(bO(dj,t)),e.uuid=t=>e.check(xO(fj,t)),e.uuidv4=t=>e.check(SO(fj,t)),e.uuidv6=t=>e.check(CO(fj,t)),e.uuidv7=t=>e.check(wO(fj,t)),e.nanoid=t=>e.check(DO(hj,t)),e.guid=t=>e.check(bO(dj,t)),e.cuid=t=>e.check(OO(gj,t)),e.cuid2=t=>e.check(kO(_j,t)),e.ulid=t=>e.check(AO(vj,t)),e.base64=t=>e.check(LO(Tj,t)),e.base64url=t=>e.check(RO(Ej,t)),e.xid=t=>e.check(jO(yj,t)),e.ksuid=t=>e.check(MO(bj,t)),e.ipv4=t=>e.check(NO(xj,t)),e.ipv6=t=>e.check(PO(Sj,t)),e.cidrv4=t=>e.check(FO(Cj,t)),e.cidrv6=t=>e.check(IO(wj,t)),e.e164=t=>e.check(zO(Dj,t)),e.datetime=t=>e.check(oA(t)),e.date=t=>e.check(sA(t)),e.time=t=>e.check(cA(t)),e.duration=t=>e.check(lA(t))}),lj=K(`ZodStringFormat`,(e,t)=>{dD.init(e,t),sj.init(e,t)}),uj=K(`ZodEmail`,(e,t)=>{mD.init(e,t),lj.init(e,t)}),dj=K(`ZodGUID`,(e,t)=>{fD.init(e,t),lj.init(e,t)}),fj=K(`ZodUUID`,(e,t)=>{pD.init(e,t),lj.init(e,t)}),pj=K(`ZodURL`,(e,t)=>{hD.init(e,t),lj.init(e,t)}),mj=K(`ZodEmoji`,(e,t)=>{gD.init(e,t),lj.init(e,t)}),hj=K(`ZodNanoID`,(e,t)=>{_D.init(e,t),lj.init(e,t)}),gj=K(`ZodCUID`,(e,t)=>{vD.init(e,t),lj.init(e,t)}),_j=K(`ZodCUID2`,(e,t)=>{yD.init(e,t),lj.init(e,t)}),vj=K(`ZodULID`,(e,t)=>{bD.init(e,t),lj.init(e,t)}),yj=K(`ZodXID`,(e,t)=>{xD.init(e,t),lj.init(e,t)}),bj=K(`ZodKSUID`,(e,t)=>{SD.init(e,t),lj.init(e,t)}),xj=K(`ZodIPv4`,(e,t)=>{DD.init(e,t),lj.init(e,t)}),Sj=K(`ZodIPv6`,(e,t)=>{OD.init(e,t),lj.init(e,t)}),Cj=K(`ZodCIDRv4`,(e,t)=>{kD.init(e,t),lj.init(e,t)}),wj=K(`ZodCIDRv6`,(e,t)=>{AD.init(e,t),lj.init(e,t)}),Tj=K(`ZodBase64`,(e,t)=>{jD.init(e,t),lj.init(e,t)}),Ej=K(`ZodBase64URL`,(e,t)=>{MD.init(e,t),lj.init(e,t)}),Dj=K(`ZodE164`,(e,t)=>{ND.init(e,t),lj.init(e,t)}),Oj=K(`ZodJWT`,(e,t)=>{PD.init(e,t),lj.init(e,t)}),kj=K(`ZodNumber`,(e,t)=>{FD.init(e,t),oj.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Pk(e,t,n,r),jA(e,`ZodNumber`,{gt(e,t){return this.check(ek(e,t))},gte(e,t){return this.check(tk(e,t))},min(e,t){return this.check(tk(e,t))},lt(e,t){return this.check(QO(e,t))},lte(e,t){return this.check($O(e,t))},max(e,t){return this.check($O(e,t))},int(e){return this.check(NA(e))},safe(e){return this.check(NA(e))},positive(e){return this.check(ek(0,e))},nonnegative(e){return this.check(tk(0,e))},negative(e){return this.check(QO(0,e))},nonpositive(e){return this.check($O(0,e))},multipleOf(e,t){return this.check(nk(e,t))},step(e,t){return this.check(nk(e,t))},finite(){return this}});let n=e._zod.bag;e.minValue=Math.max(n.minimum??-1/0,n.exclusiveMinimum??-1/0)??null,e.maxValue=Math.min(n.maximum??1/0,n.exclusiveMaximum??1/0)??null,e.isInt=(n.format??``).includes(`int`)||Number.isSafeInteger(n.multipleOf??.5),e.isFinite=!0,e.format=n.format??null}),Aj=K(`ZodNumberFormat`,(e,t)=>{ID.init(e,t),kj.init(e,t)}),jj=K(`ZodBoolean`,(e,t)=>{LD.init(e,t),oj.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Fk(e,t,n,r)}),Mj=K(`ZodUndefined`,(e,t)=>{RD.init(e,t),oj.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Lk(e,t,n,r)}),Nj=K(`ZodNull`,(e,t)=>{zD.init(e,t),oj.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ik(e,t,n,r)}),Pj=K(`ZodUnknown`,(e,t)=>{BD.init(e,t),oj.init(e,t),e._zod.processJSONSchema=(t,n,r)=>zk(e,t,n,r)}),Fj=K(`ZodNever`,(e,t)=>{VD.init(e,t),oj.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Rk(e,t,n,r)}),Ij=K(`ZodArray`,(e,t)=>{HD.init(e,t),oj.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Wk(e,t,n,r),e.element=t.element,jA(e,`ZodArray`,{min(e,t){return this.check(ik(e,t))},nonempty(e){return this.check(ik(1,e))},max(e,t){return this.check(rk(e,t))},length(e,t){return this.check(ak(e,t))},unwrap(){return this.element}})}),Lj=K(`ZodObject`,(e,t)=>{WD.init(e,t),oj.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Gk(e,t,n,r),Gw(e,`shape`,()=>t.shape),jA(e,`ZodObject`,{keyof(){return WA(Object.keys(this._zod.def.shape))},catchall(e){return this.clone({...this._zod.def,catchall:e})},passthrough(){return this.clone({...this._zod.def,catchall:LA()})},loose(){return this.clone({...this._zod.def,catchall:LA()})},strict(){return this.clone({...this._zod.def,catchall:RA()})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(e){return aT(this,e)},safeExtend(e){return oT(this,e)},merge(e){return sT(this,e)},pick(e){return rT(this,e)},omit(e){return iT(this,e)},partial(...e){return cT(Gj,this,e[0])},required(...e){return lT(Xj,this,e[0])}})}),Rj=K(`ZodUnion`,(e,t)=>{GD.init(e,t),oj.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Kk(e,t,n,r),e.options=t.options}),zj=K(`ZodDiscriminatedUnion`,(e,t)=>{Rj.init(e,t),KD.init(e,t)}),Bj=K(`ZodIntersection`,(e,t)=>{qD.init(e,t),oj.init(e,t),e._zod.processJSONSchema=(t,n,r)=>qk(e,t,n,r)}),Vj=K(`ZodRecord`,(e,t)=>{JD.init(e,t),oj.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Jk(e,t,n,r),e.keyType=t.keyType,e.valueType=t.valueType}),Hj=K(`ZodEnum`,(e,t)=>{YD.init(e,t),oj.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Bk(e,t,n,r),e.enum=t.entries,e.options=Object.values(t.entries);let n=new Set(Object.keys(t.entries));e.extract=(e,r)=>{let i={};for(let r of e)if(n.has(r))i[r]=t.entries[r];else throw Error(`Key ${r} not found in enum`);return new Hj({...t,checks:[],...q(r),entries:i})},e.exclude=(e,r)=>{let i={...t.entries};for(let t of e)if(n.has(t))delete i[t];else throw Error(`Key ${t} not found in enum`);return new Hj({...t,checks:[],...q(r),entries:i})}}),Uj=K(`ZodLiteral`,(e,t)=>{XD.init(e,t),oj.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Vk(e,t,n,r),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})}),Wj=K(`ZodTransform`,(e,t)=>{ZD.init(e,t),oj.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Uk(e,t,n,r),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new Fw(e.constructor.name);n.addIssue=r=>{if(typeof r==`string`)n.issues.push(_T(r,n.value,t));else{let t=r;t.fatal&&(t.continue=!1),t.code??=`custom`,t.input??=n.value,t.inst??=e,n.issues.push(_T(t))}};let i=t.transform(n.value,n);return i instanceof Promise?i.then(e=>(n.value=e,n.fallback=!0,n)):(n.value=i,n.fallback=!0,n)}}),Gj=K(`ZodOptional`,(e,t)=>{QD.init(e,t),oj.init(e,t),e._zod.processJSONSchema=(t,n,r)=>nA(e,t,n,r),e.unwrap=()=>e._zod.def.innerType}),Kj=K(`ZodExactOptional`,(e,t)=>{$D.init(e,t),oj.init(e,t),e._zod.processJSONSchema=(t,n,r)=>nA(e,t,n,r),e.unwrap=()=>e._zod.def.innerType}),qj=K(`ZodNullable`,(e,t)=>{eO.init(e,t),oj.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Yk(e,t,n,r),e.unwrap=()=>e._zod.def.innerType}),Jj=K(`ZodDefault`,(e,t)=>{tO.init(e,t),oj.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Zk(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap}),Yj=K(`ZodPrefault`,(e,t)=>{nO.init(e,t),oj.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Qk(e,t,n,r),e.unwrap=()=>e._zod.def.innerType}),Xj=K(`ZodNonOptional`,(e,t)=>{rO.init(e,t),oj.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Xk(e,t,n,r),e.unwrap=()=>e._zod.def.innerType}),Zj=K(`ZodCatch`,(e,t)=>{iO.init(e,t),oj.init(e,t),e._zod.processJSONSchema=(t,n,r)=>$k(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap}),Qj=K(`ZodPipe`,(e,t)=>{aO.init(e,t),oj.init(e,t),e._zod.processJSONSchema=(t,n,r)=>eA(e,t,n,r),e.in=t.in,e.out=t.out}),$j=K(`ZodPreprocess`,(e,t)=>{Qj.init(e,t),oO.init(e,t)}),eM=K(`ZodReadonly`,(e,t)=>{sO.init(e,t),oj.init(e,t),e._zod.processJSONSchema=(t,n,r)=>tA(e,t,n,r),e.unwrap=()=>e._zod.def.innerType}),tM=K(`ZodCustom`,(e,t)=>{cO.init(e,t),oj.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Hk(e,t,n,r)})})),rM,iM=a((()=>{iA(),rM||={}})),aM=a((()=>{iA(),nM(),aA(),_A(),AA(),iM(),fO(),rA(),_O(),aA(),mA(),nM(),CT(),Mw(uO())})),oM=a((()=>{aM(),aM()})),sM=a((()=>{oM()}));sM();var cM=`io.modelcontextprotocol/related-task`,lM=tj(e=>e!==null&&(typeof e==`object`||typeof e==`function`)),uM=BA([J(),MA().int()]),dM=J();zA({ttl:MA().optional(),pollInterval:MA().optional()});var fM=X({ttl:MA().optional()}),pM=X({taskId:J()}),mM=zA({progressToken:uM.optional(),[cM]:pM.optional()}),hM=X({_meta:mM.optional()}),gM=hM.extend({task:fM.optional()}),_M=e=>gM.safeParse(e).success,vM=X({method:J(),params:hM.loose().optional()}),yM=X({_meta:mM.optional()}),bM=X({method:J(),params:yM.loose().optional()}),xM=zA({_meta:mM.optional()}),SM=BA([J(),MA().int()]),CM=X({jsonrpc:Z(`2.0`),id:SM,...vM.shape}).strict(),wM=e=>CM.safeParse(e).success,TM=X({jsonrpc:Z(`2.0`),...bM.shape}).strict(),EM=e=>TM.safeParse(e).success,DM=X({jsonrpc:Z(`2.0`),id:SM,result:xM}).strict(),OM=e=>DM.safeParse(e).success,kM;(function(e){e[e.ConnectionClosed=-32e3]=`ConnectionClosed`,e[e.RequestTimeout=-32001]=`RequestTimeout`,e[e.ParseError=-32700]=`ParseError`,e[e.InvalidRequest=-32600]=`InvalidRequest`,e[e.MethodNotFound=-32601]=`MethodNotFound`,e[e.InvalidParams=-32602]=`InvalidParams`,e[e.InternalError=-32603]=`InternalError`,e[e.UrlElicitationRequired=-32042]=`UrlElicitationRequired`})(kM||={});var AM=X({jsonrpc:Z(`2.0`),id:SM.optional(),error:X({code:MA().int(),message:J(),data:LA().optional()})}).strict(),jM=e=>AM.safeParse(e).success;BA([CM,TM,DM,AM]),BA([DM,AM]);var MM=xM.strict(),NM=yM.extend({requestId:SM.optional(),reason:J().optional()}),PM=bM.extend({method:Z(`notifications/cancelled`),params:NM}),FM=X({icons:Y(X({src:J(),mimeType:J().optional(),sizes:Y(J()).optional(),theme:WA([`light`,`dark`]).optional()})).optional()}),IM=X({name:J(),title:J().optional()}),LM=IM.extend({...IM.shape,...FM.shape,version:J(),websiteUrl:J().optional(),description:J().optional()}),RM=ij(e=>e&&typeof e==`object`&&!Array.isArray(e)&&Object.keys(e).length===0?{form:{}}:e,HA(X({form:HA(X({applyDefaults:PA().optional()}),UA(J(),LA())).optional(),url:lM.optional()}),UA(J(),LA()).optional())),zM=zA({list:lM.optional(),cancel:lM.optional(),requests:zA({sampling:zA({createMessage:lM.optional()}).optional(),elicitation:zA({create:lM.optional()}).optional()}).optional()}),BM=zA({list:lM.optional(),cancel:lM.optional(),requests:zA({tools:zA({call:lM.optional()}).optional()}).optional()}),VM=X({experimental:UA(J(),lM).optional(),sampling:X({context:lM.optional(),tools:lM.optional()}).optional(),elicitation:RM.optional(),roots:X({listChanged:PA().optional()}).optional(),tasks:zM.optional(),extensions:UA(J(),lM).optional()}),HM=hM.extend({protocolVersion:J(),capabilities:VM,clientInfo:LM}),UM=vM.extend({method:Z(`initialize`),params:HM}),WM=X({experimental:UA(J(),lM).optional(),logging:lM.optional(),completions:lM.optional(),prompts:X({listChanged:PA().optional()}).optional(),resources:X({subscribe:PA().optional(),listChanged:PA().optional()}).optional(),tools:X({listChanged:PA().optional()}).optional(),tasks:BM.optional(),extensions:UA(J(),lM).optional()}),GM=xM.extend({protocolVersion:J(),capabilities:WM,serverInfo:LM,instructions:J().optional()}),KM=bM.extend({method:Z(`notifications/initialized`),params:yM.optional()}),qM=vM.extend({method:Z(`ping`),params:hM.optional()}),JM=X({progress:MA(),total:KA(MA()),message:KA(J())}),YM=X({...yM.shape,...JM.shape,progressToken:uM}),XM=bM.extend({method:Z(`notifications/progress`),params:YM}),ZM=hM.extend({cursor:dM.optional()}),QM=vM.extend({params:ZM.optional()}),$M=xM.extend({nextCursor:dM.optional()}),eN=WA([`working`,`input_required`,`completed`,`failed`,`cancelled`]),tN=X({taskId:J(),status:eN,ttl:BA([MA(),IA()]),createdAt:J(),lastUpdatedAt:J(),pollInterval:KA(MA()),statusMessage:KA(J())}),nN=xM.extend({task:tN}),rN=yM.merge(tN),iN=bM.extend({method:Z(`notifications/tasks/status`),params:rN}),aN=vM.extend({method:Z(`tasks/get`),params:hM.extend({taskId:J()})}),oN=xM.merge(tN),sN=vM.extend({method:Z(`tasks/result`),params:hM.extend({taskId:J()})});xM.loose();var cN=QM.extend({method:Z(`tasks/list`)}),lN=$M.extend({tasks:Y(tN)}),uN=vM.extend({method:Z(`tasks/cancel`),params:hM.extend({taskId:J()})}),dN=xM.merge(tN),fN=X({uri:J(),mimeType:KA(J()),_meta:UA(J(),LA()).optional()}),pN=fN.extend({text:J()}),mN=J().refine(e=>{try{return atob(e),!0}catch{return!1}},{message:`Invalid Base64 string`}),hN=fN.extend({blob:mN}),gN=WA([`user`,`assistant`]),_N=X({audience:Y(gN).optional(),priority:MA().min(0).max(1).optional(),lastModified:oA({offset:!0}).optional()}),vN=X({...IM.shape,...FM.shape,uri:J(),description:KA(J()),mimeType:KA(J()),size:KA(MA()),annotations:_N.optional(),_meta:KA(zA({}))}),yN=X({...IM.shape,...FM.shape,uriTemplate:J(),description:KA(J()),mimeType:KA(J()),annotations:_N.optional(),_meta:KA(zA({}))}),bN=QM.extend({method:Z(`resources/list`)}),xN=$M.extend({resources:Y(vN)}),SN=QM.extend({method:Z(`resources/templates/list`)}),CN=$M.extend({resourceTemplates:Y(yN)}),wN=hM.extend({uri:J()}),TN=wN,EN=vM.extend({method:Z(`resources/read`),params:TN}),DN=xM.extend({contents:Y(BA([pN,hN]))}),ON=bM.extend({method:Z(`notifications/resources/list_changed`),params:yM.optional()}),kN=wN,AN=vM.extend({method:Z(`resources/subscribe`),params:kN}),jN=wN,MN=vM.extend({method:Z(`resources/unsubscribe`),params:jN}),NN=yM.extend({uri:J()}),PN=bM.extend({method:Z(`notifications/resources/updated`),params:NN}),FN=X({name:J(),description:KA(J()),required:KA(PA())}),IN=X({...IM.shape,...FM.shape,description:KA(J()),arguments:KA(Y(FN)),_meta:KA(zA({}))}),LN=QM.extend({method:Z(`prompts/list`)}),RN=$M.extend({prompts:Y(IN)}),zN=hM.extend({name:J(),arguments:UA(J(),J()).optional()}),BN=vM.extend({method:Z(`prompts/get`),params:zN}),VN=X({type:Z(`text`),text:J(),annotations:_N.optional(),_meta:UA(J(),LA()).optional()}),HN=X({type:Z(`image`),data:mN,mimeType:J(),annotations:_N.optional(),_meta:UA(J(),LA()).optional()}),UN=X({type:Z(`audio`),data:mN,mimeType:J(),annotations:_N.optional(),_meta:UA(J(),LA()).optional()}),WN=X({type:Z(`tool_use`),name:J(),id:J(),input:UA(J(),LA()),_meta:UA(J(),LA()).optional()}),GN=X({type:Z(`resource`),resource:BA([pN,hN]),annotations:_N.optional(),_meta:UA(J(),LA()).optional()}),KN=vN.extend({type:Z(`resource_link`)}),qN=BA([VN,HN,UN,KN,GN]),JN=X({role:gN,content:qN}),YN=xM.extend({description:J().optional(),messages:Y(JN)}),XN=bM.extend({method:Z(`notifications/prompts/list_changed`),params:yM.optional()}),ZN=X({title:J().optional(),readOnlyHint:PA().optional(),destructiveHint:PA().optional(),idempotentHint:PA().optional(),openWorldHint:PA().optional()}),QN=X({taskSupport:WA([`required`,`optional`,`forbidden`]).optional()}),$N=X({...IM.shape,...FM.shape,description:J().optional(),inputSchema:X({type:Z(`object`),properties:UA(J(),lM).optional(),required:Y(J()).optional()}).catchall(LA()),outputSchema:X({type:Z(`object`),properties:UA(J(),lM).optional(),required:Y(J()).optional()}).catchall(LA()).optional(),annotations:ZN.optional(),execution:QN.optional(),_meta:UA(J(),LA()).optional()}),eP=QM.extend({method:Z(`tools/list`)}),tP=$M.extend({tools:Y($N)}),nP=xM.extend({content:Y(qN).default([]),structuredContent:UA(J(),LA()).optional(),isError:PA().optional()});nP.or(xM.extend({toolResult:LA()}));var rP=gM.extend({name:J(),arguments:UA(J(),LA()).optional()}),iP=vM.extend({method:Z(`tools/call`),params:rP}),aP=bM.extend({method:Z(`notifications/tools/list_changed`),params:yM.optional()});X({autoRefresh:PA().default(!0),debounceMs:MA().int().nonnegative().default(300)});var oP=WA([`debug`,`info`,`notice`,`warning`,`error`,`critical`,`alert`,`emergency`]),sP=hM.extend({level:oP}),cP=vM.extend({method:Z(`logging/setLevel`),params:sP}),lP=yM.extend({level:oP,logger:J().optional(),data:LA()}),uP=bM.extend({method:Z(`notifications/message`),params:lP}),dP=X({hints:Y(X({name:J().optional()})).optional(),costPriority:MA().min(0).max(1).optional(),speedPriority:MA().min(0).max(1).optional(),intelligencePriority:MA().min(0).max(1).optional()}),fP=X({mode:WA([`auto`,`required`,`none`]).optional()}),pP=X({type:Z(`tool_result`),toolUseId:J().describe(`The unique identifier for the corresponding tool call.`),content:Y(qN).default([]),structuredContent:X({}).loose().optional(),isError:PA().optional(),_meta:UA(J(),LA()).optional()}),mP=VA(`type`,[VN,HN,UN]),hP=VA(`type`,[VN,HN,UN,WN,pP]),gP=X({role:gN,content:BA([hP,Y(hP)]),_meta:UA(J(),LA()).optional()}),_P=gM.extend({messages:Y(gP),modelPreferences:dP.optional(),systemPrompt:J().optional(),includeContext:WA([`none`,`thisServer`,`allServers`]).optional(),temperature:MA().optional(),maxTokens:MA().int(),stopSequences:Y(J()).optional(),metadata:lM.optional(),tools:Y($N).optional(),toolChoice:fP.optional()}),vP=vM.extend({method:Z(`sampling/createMessage`),params:_P}),yP=xM.extend({model:J(),stopReason:KA(WA([`endTurn`,`stopSequence`,`maxTokens`]).or(J())),role:gN,content:mP}),bP=xM.extend({model:J(),stopReason:KA(WA([`endTurn`,`stopSequence`,`maxTokens`,`toolUse`]).or(J())),role:gN,content:BA([hP,Y(hP)])}),xP=X({type:Z(`boolean`),title:J().optional(),description:J().optional(),default:PA().optional()}),SP=X({type:Z(`string`),title:J().optional(),description:J().optional(),minLength:MA().optional(),maxLength:MA().optional(),format:WA([`email`,`uri`,`date`,`date-time`]).optional(),default:J().optional()}),CP=X({type:WA([`number`,`integer`]),title:J().optional(),description:J().optional(),minimum:MA().optional(),maximum:MA().optional(),default:MA().optional()}),wP=X({type:Z(`string`),title:J().optional(),description:J().optional(),enum:Y(J()),default:J().optional()}),TP=X({type:Z(`string`),title:J().optional(),description:J().optional(),oneOf:Y(X({const:J(),title:J()})),default:J().optional()}),EP=BA([BA([X({type:Z(`string`),title:J().optional(),description:J().optional(),enum:Y(J()),enumNames:Y(J()).optional(),default:J().optional()}),BA([wP,TP]),BA([X({type:Z(`array`),title:J().optional(),description:J().optional(),minItems:MA().optional(),maxItems:MA().optional(),items:X({type:Z(`string`),enum:Y(J())}),default:Y(J()).optional()}),X({type:Z(`array`),title:J().optional(),description:J().optional(),minItems:MA().optional(),maxItems:MA().optional(),items:X({anyOf:Y(X({const:J(),title:J()}))}),default:Y(J()).optional()})])]),xP,SP,CP]),DP=BA([gM.extend({mode:Z(`form`).optional(),message:J(),requestedSchema:X({type:Z(`object`),properties:UA(J(),EP),required:Y(J()).optional()})}),gM.extend({mode:Z(`url`),message:J(),elicitationId:J(),url:J().url()})]),OP=vM.extend({method:Z(`elicitation/create`),params:DP}),kP=yM.extend({elicitationId:J()}),AP=bM.extend({method:Z(`notifications/elicitation/complete`),params:kP}),jP=xM.extend({action:WA([`accept`,`decline`,`cancel`]),content:ij(e=>e===null?void 0:e,UA(J(),BA([J(),MA(),PA(),Y(J())])).optional())}),MP=X({type:Z(`ref/resource`),uri:J()}),NP=X({type:Z(`ref/prompt`),name:J()}),PP=hM.extend({ref:BA([NP,MP]),argument:X({name:J(),value:J()}),context:X({arguments:UA(J(),J()).optional()}).optional()}),FP=vM.extend({method:Z(`completion/complete`),params:PP}),IP=xM.extend({completion:zA({values:Y(J()).max(100),total:KA(MA().int()),hasMore:KA(PA())})}),LP=X({uri:J().startsWith(`file://`),name:J().optional(),_meta:UA(J(),LA()).optional()}),RP=vM.extend({method:Z(`roots/list`),params:hM.optional()}),zP=xM.extend({roots:Y(LP)}),BP=bM.extend({method:Z(`notifications/roots/list_changed`),params:yM.optional()});BA([qM,UM,FP,cP,BN,LN,bN,SN,EN,AN,MN,iP,eP,aN,sN,cN,uN]),BA([PM,XM,KM,BP,iN]),BA([MM,yP,bP,jP,zP,oN,lN,nN]),BA([qM,vP,OP,RP,aN,sN,cN,uN]),BA([PM,XM,uP,PN,ON,aP,XN,iN,AP]),BA([MM,GM,IP,YN,RN,xN,CN,DN,nP,tP,oN,lN,nN]);var VP=class e extends Error{constructor(e,t,n){super(`MCP error ${e}: ${t}`),this.code=e,this.data=n,this.name=`McpError`}static fromError(t,n,r){if(t===kM.UrlElicitationRequired&&r){let e=r;if(e.elicitations)return new HP(e.elicitations,n)}return new e(t,n,r)}},HP=class extends VP{constructor(e,t=`URL elicitation${e.length>1?`s`:``} required`){super(kM.UrlElicitationRequired,t,{elicitations:e})}get elicitations(){return this.data?.elicitations??[]}};Ck(),CT(),wE(),Lw(),WT(),rA(),kT(),iA(),_O();function UP(e){return!!e._zod}function WP(e,t){return UP(e)?NT(e,t):e.safeParse(t)}function GP(e){if(!e)return;let t;if(t=UP(e)?e._zod?.def?.shape:e.shape,t){if(typeof t==`function`)try{return t()}catch{return}return t}}function KP(e){if(UP(e)){let t=e._zod?.def;if(t){if(t.value!==void 0)return t.value;if(Array.isArray(t.values)&&t.values.length>0)return t.values[0]}}let t=e._def;if(t){if(t.value!==void 0)return t.value;if(Array.isArray(t.values)&&t.values.length>0)return t.values[0]}let n=e.value;if(n!==void 0)return n}function qP(e){return e===`completed`||e===`failed`||e===`cancelled`}function JP(e){let t=GP(e)?.method;if(!t)throw Error(`Schema is missing a method literal`);let n=KP(t);if(typeof n!=`string`)throw Error(`Schema method literal must be a string`);return n}function YP(e,t){let n=WP(e,t);if(!n.success)throw n.error;return n.data}var XP=class{constructor(e){this._options=e,this._requestMessageId=0,this._requestHandlers=new Map,this._requestHandlerAbortControllers=new Map,this._notificationHandlers=new Map,this._responseHandlers=new Map,this._progressHandlers=new Map,this._timeoutInfo=new Map,this._pendingDebouncedNotifications=new Set,this._taskProgressTokens=new Map,this._requestResolvers=new Map,this.setNotificationHandler(PM,e=>{this._oncancel(e)}),this.setNotificationHandler(XM,e=>{this._onprogress(e)}),this.setRequestHandler(qM,e=>({})),this._taskStore=e?.taskStore,this._taskMessageQueue=e?.taskMessageQueue,this._taskStore&&(this.setRequestHandler(aN,async(e,t)=>{let n=await this._taskStore.getTask(e.params.taskId,t.sessionId);if(!n)throw new VP(kM.InvalidParams,`Failed to retrieve task: Task not found`);return{...n}}),this.setRequestHandler(sN,async(e,t)=>{let n=async()=>{let r=e.params.taskId;if(this._taskMessageQueue){let e;for(;e=await this._taskMessageQueue.dequeue(r,t.sessionId);){if(e.type===`response`||e.type===`error`){let t=e.message,n=t.id,r=this._requestResolvers.get(n);if(r)if(this._requestResolvers.delete(n),e.type===`response`)r(t);else{let e=t;r(new VP(e.error.code,e.error.message,e.error.data))}else{let t=e.type===`response`?`Response`:`Error`;this._onerror(Error(`${t} handler missing for request ${n}`))}continue}await this._transport?.send(e.message,{relatedRequestId:t.requestId})}}let i=await this._taskStore.getTask(r,t.sessionId);if(!i)throw new VP(kM.InvalidParams,`Task not found: ${r}`);if(!qP(i.status))return await this._waitForTaskUpdate(r,t.signal),await n();if(qP(i.status)){let e=await this._taskStore.getTaskResult(r,t.sessionId);return this._clearTaskQueue(r),{...e,_meta:{...e._meta,[cM]:{taskId:r}}}}return await n()};return await n()}),this.setRequestHandler(cN,async(e,t)=>{try{let{tasks:n,nextCursor:r}=await this._taskStore.listTasks(e.params?.cursor,t.sessionId);return{tasks:n,nextCursor:r,_meta:{}}}catch(e){throw new VP(kM.InvalidParams,`Failed to list tasks: ${e instanceof Error?e.message:String(e)}`)}}),this.setRequestHandler(uN,async(e,t)=>{try{let n=await this._taskStore.getTask(e.params.taskId,t.sessionId);if(!n)throw new VP(kM.InvalidParams,`Task not found: ${e.params.taskId}`);if(qP(n.status))throw new VP(kM.InvalidParams,`Cannot cancel task in terminal status: ${n.status}`);await this._taskStore.updateTaskStatus(e.params.taskId,`cancelled`,`Client cancelled task execution.`,t.sessionId),this._clearTaskQueue(e.params.taskId);let r=await this._taskStore.getTask(e.params.taskId,t.sessionId);if(!r)throw new VP(kM.InvalidParams,`Task not found after cancellation: ${e.params.taskId}`);return{_meta:{},...r}}catch(e){throw e instanceof VP?e:new VP(kM.InvalidRequest,`Failed to cancel task: ${e instanceof Error?e.message:String(e)}`)}}))}async _oncancel(e){e.params.requestId&&this._requestHandlerAbortControllers.get(e.params.requestId)?.abort(e.params.reason)}_setupTimeout(e,t,n,r,i=!1){this._timeoutInfo.set(e,{timeoutId:setTimeout(r,t),startTime:Date.now(),timeout:t,maxTotalTimeout:n,resetTimeoutOnProgress:i,onTimeout:r})}_resetTimeout(e){let t=this._timeoutInfo.get(e);if(!t)return!1;let n=Date.now()-t.startTime;if(t.maxTotalTimeout&&n>=t.maxTotalTimeout)throw this._timeoutInfo.delete(e),VP.fromError(kM.RequestTimeout,`Maximum total timeout exceeded`,{maxTotalTimeout:t.maxTotalTimeout,totalElapsed:n});return clearTimeout(t.timeoutId),t.timeoutId=setTimeout(t.onTimeout,t.timeout),!0}_cleanupTimeout(e){let t=this._timeoutInfo.get(e);t&&(clearTimeout(t.timeoutId),this._timeoutInfo.delete(e))}async connect(e){if(this._transport)throw Error(`Already connected to a transport. Call close() before connecting to a new transport, or use a separate Protocol instance per connection.`);this._transport=e;let t=this.transport?.onclose;this._transport.onclose=()=>{t?.(),this._onclose()};let n=this.transport?.onerror;this._transport.onerror=e=>{n?.(e),this._onerror(e)};let r=this._transport?.onmessage;this._transport.onmessage=(e,t)=>{r?.(e,t),OM(e)||jM(e)?this._onresponse(e):wM(e)?this._onrequest(e,t):EM(e)?this._onnotification(e):this._onerror(Error(`Unknown message type: ${JSON.stringify(e)}`))},await this._transport.start()}_onclose(){let e=this._responseHandlers;this._responseHandlers=new Map,this._progressHandlers.clear(),this._taskProgressTokens.clear(),this._pendingDebouncedNotifications.clear();for(let e of this._timeoutInfo.values())clearTimeout(e.timeoutId);this._timeoutInfo.clear();for(let e of this._requestHandlerAbortControllers.values())e.abort();this._requestHandlerAbortControllers.clear();let t=VP.fromError(kM.ConnectionClosed,`Connection closed`);this._transport=void 0,this.onclose?.();for(let n of e.values())n(t)}_onerror(e){this.onerror?.(e)}_onnotification(e){let t=this._notificationHandlers.get(e.method)??this.fallbackNotificationHandler;t!==void 0&&Promise.resolve().then(()=>t(e)).catch(e=>this._onerror(Error(`Uncaught error in notification handler: ${e}`)))}_onrequest(e,t){let n=this._requestHandlers.get(e.method)??this.fallbackRequestHandler,r=this._transport,i=e.params?._meta?.[cM]?.taskId;if(n===void 0){let t={jsonrpc:`2.0`,id:e.id,error:{code:kM.MethodNotFound,message:`Method not found`}};i&&this._taskMessageQueue?this._enqueueTaskMessage(i,{type:`error`,message:t,timestamp:Date.now()},r?.sessionId).catch(e=>this._onerror(Error(`Failed to enqueue error response: ${e}`))):r?.send(t).catch(e=>this._onerror(Error(`Failed to send an error response: ${e}`)));return}let a=new AbortController;this._requestHandlerAbortControllers.set(e.id,a);let o=_M(e.params)?e.params.task:void 0,s=this._taskStore?this.requestTaskStore(e,r?.sessionId):void 0,c={signal:a.signal,sessionId:r?.sessionId,_meta:e.params?._meta,sendNotification:async t=>{if(a.signal.aborted)return;let n={relatedRequestId:e.id};i&&(n.relatedTask={taskId:i}),await this.notification(t,n)},sendRequest:async(t,n,r)=>{if(a.signal.aborted)throw new VP(kM.ConnectionClosed,`Request was cancelled`);let o={...r,relatedRequestId:e.id};i&&!o.relatedTask&&(o.relatedTask={taskId:i});let c=o.relatedTask?.taskId??i;return c&&s&&await s.updateTaskStatus(c,`input_required`),await this.request(t,n,o)},authInfo:t?.authInfo,requestId:e.id,requestInfo:t?.requestInfo,taskId:i,taskStore:s,taskRequestedTtl:o?.ttl,closeSSEStream:t?.closeSSEStream,closeStandaloneSSEStream:t?.closeStandaloneSSEStream};Promise.resolve().then(()=>{o&&this.assertTaskHandlerCapability(e.method)}).then(()=>n(e,c)).then(async t=>{if(a.signal.aborted)return;let n={result:t,jsonrpc:`2.0`,id:e.id};i&&this._taskMessageQueue?await this._enqueueTaskMessage(i,{type:`response`,message:n,timestamp:Date.now()},r?.sessionId):await r?.send(n)},async t=>{if(a.signal.aborted)return;let n={jsonrpc:`2.0`,id:e.id,error:{code:Number.isSafeInteger(t.code)?t.code:kM.InternalError,message:t.message??`Internal error`,...t.data!==void 0&&{data:t.data}}};i&&this._taskMessageQueue?await this._enqueueTaskMessage(i,{type:`error`,message:n,timestamp:Date.now()},r?.sessionId):await r?.send(n)}).catch(e=>this._onerror(Error(`Failed to send response: ${e}`))).finally(()=>{this._requestHandlerAbortControllers.get(e.id)===a&&this._requestHandlerAbortControllers.delete(e.id)})}_onprogress(e){let{progressToken:t,...n}=e.params,r=Number(t),i=this._progressHandlers.get(r);if(!i){this._onerror(Error(`Received a progress notification for an unknown token: ${JSON.stringify(e)}`));return}let a=this._responseHandlers.get(r),o=this._timeoutInfo.get(r);if(o&&a&&o.resetTimeoutOnProgress)try{this._resetTimeout(r)}catch(e){this._responseHandlers.delete(r),this._progressHandlers.delete(r),this._cleanupTimeout(r),a(e);return}i(n)}_onresponse(e){let t=Number(e.id),n=this._requestResolvers.get(t);if(n){this._requestResolvers.delete(t),OM(e)?n(e):n(new VP(e.error.code,e.error.message,e.error.data));return}let r=this._responseHandlers.get(t);if(r===void 0){this._onerror(Error(`Received a response for an unknown message ID: ${JSON.stringify(e)}`));return}this._responseHandlers.delete(t),this._cleanupTimeout(t);let i=!1;if(OM(e)&&e.result&&typeof e.result==`object`){let n=e.result;if(n.task&&typeof n.task==`object`){let e=n.task;typeof e.taskId==`string`&&(i=!0,this._taskProgressTokens.set(e.taskId,t))}}i||this._progressHandlers.delete(t),OM(e)?r(e):r(VP.fromError(e.error.code,e.error.message,e.error.data))}get transport(){return this._transport}async close(){await this._transport?.close()}async*requestStream(e,t,n){let{task:r}=n??{};if(!r){try{yield{type:`result`,result:await this.request(e,t,n)}}catch(e){yield{type:`error`,error:e instanceof VP?e:new VP(kM.InternalError,String(e))}}return}let i;try{let r=await this.request(e,nN,n);if(r.task)i=r.task.taskId,yield{type:`taskCreated`,task:r.task};else throw new VP(kM.InternalError,`Task creation did not return a task`);for(;;){let e=await this.getTask({taskId:i},n);if(yield{type:`taskStatus`,task:e},qP(e.status)){e.status===`completed`?yield{type:`result`,result:await this.getTaskResult({taskId:i},t,n)}:e.status===`failed`?yield{type:`error`,error:new VP(kM.InternalError,`Task ${i} failed`)}:e.status===`cancelled`&&(yield{type:`error`,error:new VP(kM.InternalError,`Task ${i} was cancelled`)});return}if(e.status===`input_required`){yield{type:`result`,result:await this.getTaskResult({taskId:i},t,n)};return}let r=e.pollInterval??this._options?.defaultTaskPollInterval??1e3;await new Promise(e=>setTimeout(e,r)),n?.signal?.throwIfAborted()}}catch(e){yield{type:`error`,error:e instanceof VP?e:new VP(kM.InternalError,String(e))}}}request(e,t,n){let{relatedRequestId:r,resumptionToken:i,onresumptiontoken:a,task:o,relatedTask:s}=n??{};return new Promise((c,l)=>{let u=e=>{l(e)};if(!this._transport){u(Error(`Not connected`));return}if(this._options?.enforceStrictCapabilities===!0)try{this.assertCapabilityForMethod(e.method),o&&this.assertTaskCapability(e.method)}catch(e){u(e);return}n?.signal?.throwIfAborted();let d=this._requestMessageId++,f={...e,jsonrpc:`2.0`,id:d};n?.onprogress&&(this._progressHandlers.set(d,n.onprogress),f.params={...e.params,_meta:{...e.params?._meta||{},progressToken:d}}),o&&(f.params={...f.params,task:o}),s&&(f.params={...f.params,_meta:{...f.params?._meta||{},[cM]:s}});let p=e=>{this._responseHandlers.delete(d),this._progressHandlers.delete(d),this._cleanupTimeout(d),this._transport?.send({jsonrpc:`2.0`,method:`notifications/cancelled`,params:{requestId:d,reason:String(e)}},{relatedRequestId:r,resumptionToken:i,onresumptiontoken:a}).catch(e=>this._onerror(Error(`Failed to send cancellation: ${e}`))),l(e instanceof VP?e:new VP(kM.RequestTimeout,String(e)))};this._responseHandlers.set(d,e=>{if(!n?.signal?.aborted){if(e instanceof Error)return l(e);try{let n=WP(t,e.result);n.success?c(n.data):l(n.error)}catch(e){l(e)}}}),n?.signal?.addEventListener(`abort`,()=>{p(n?.signal?.reason)});let m=n?.timeout??6e4;this._setupTimeout(d,m,n?.maxTotalTimeout,()=>p(VP.fromError(kM.RequestTimeout,`Request timed out`,{timeout:m})),n?.resetTimeoutOnProgress??!1);let h=s?.taskId;h?(this._requestResolvers.set(d,e=>{let t=this._responseHandlers.get(d);t?t(e):this._onerror(Error(`Response handler missing for side-channeled request ${d}`))}),this._enqueueTaskMessage(h,{type:`request`,message:f,timestamp:Date.now()}).catch(e=>{this._cleanupTimeout(d),l(e)})):this._transport.send(f,{relatedRequestId:r,resumptionToken:i,onresumptiontoken:a}).catch(e=>{this._cleanupTimeout(d),l(e)})})}async getTask(e,t){return this.request({method:`tasks/get`,params:e},oN,t)}async getTaskResult(e,t,n){return this.request({method:`tasks/result`,params:e},t,n)}async listTasks(e,t){return this.request({method:`tasks/list`,params:e},lN,t)}async cancelTask(e,t){return this.request({method:`tasks/cancel`,params:e},dN,t)}async notification(e,t){if(!this._transport)throw Error(`Not connected`);this.assertNotificationCapability(e.method);let n=t?.relatedTask?.taskId;if(n){let r={...e,jsonrpc:`2.0`,params:{...e.params,_meta:{...e.params?._meta||{},[cM]:t.relatedTask}}};await this._enqueueTaskMessage(n,{type:`notification`,message:r,timestamp:Date.now()});return}if((this._options?.debouncedNotificationMethods??[]).includes(e.method)&&!e.params&&!t?.relatedRequestId&&!t?.relatedTask){if(this._pendingDebouncedNotifications.has(e.method))return;this._pendingDebouncedNotifications.add(e.method),Promise.resolve().then(()=>{if(this._pendingDebouncedNotifications.delete(e.method),!this._transport)return;let n={...e,jsonrpc:`2.0`};t?.relatedTask&&(n={...n,params:{...n.params,_meta:{...n.params?._meta||{},[cM]:t.relatedTask}}}),this._transport?.send(n,t).catch(e=>this._onerror(e))});return}let r={...e,jsonrpc:`2.0`};t?.relatedTask&&(r={...r,params:{...r.params,_meta:{...r.params?._meta||{},[cM]:t.relatedTask}}}),await this._transport.send(r,t)}setRequestHandler(e,t){let n=JP(e);this.assertRequestHandlerCapability(n),this._requestHandlers.set(n,(n,r)=>{let i=YP(e,n);return Promise.resolve(t(i,r))})}removeRequestHandler(e){this._requestHandlers.delete(e)}assertCanSetRequestHandler(e){if(this._requestHandlers.has(e))throw Error(`A request handler for ${e} already exists, which would be overridden`)}setNotificationHandler(e,t){let n=JP(e);this._notificationHandlers.set(n,n=>{let r=YP(e,n);return Promise.resolve(t(r))})}removeNotificationHandler(e){this._notificationHandlers.delete(e)}_cleanupTaskProgressHandler(e){let t=this._taskProgressTokens.get(e);t!==void 0&&(this._progressHandlers.delete(t),this._taskProgressTokens.delete(e))}async _enqueueTaskMessage(e,t,n){if(!this._taskStore||!this._taskMessageQueue)throw Error(`Cannot enqueue task message: taskStore and taskMessageQueue are not configured`);let r=this._options?.maxTaskQueueSize;await this._taskMessageQueue.enqueue(e,t,n,r)}async _clearTaskQueue(e,t){if(this._taskMessageQueue){let n=await this._taskMessageQueue.dequeueAll(e,t);for(let t of n)if(t.type===`request`&&wM(t.message)){let n=t.message.id,r=this._requestResolvers.get(n);r?(r(new VP(kM.InternalError,`Task cancelled or completed`)),this._requestResolvers.delete(n)):this._onerror(Error(`Resolver missing for request ${n} during task ${e} cleanup`))}}}async _waitForTaskUpdate(e,t){let n=this._options?.defaultTaskPollInterval??1e3;try{let t=await this._taskStore?.getTask(e);t?.pollInterval&&(n=t.pollInterval)}catch{}return new Promise((e,r)=>{if(t.aborted){r(new VP(kM.InvalidRequest,`Request cancelled`));return}let i=setTimeout(e,n);t.addEventListener(`abort`,()=>{clearTimeout(i),r(new VP(kM.InvalidRequest,`Request cancelled`))},{once:!0})})}requestTaskStore(e,t){let n=this._taskStore;if(!n)throw Error(`No task store configured`);return{createTask:async r=>{if(!e)throw Error(`No request provided`);return await n.createTask(r,e.id,{method:e.method,params:e.params},t)},getTask:async e=>{let r=await n.getTask(e,t);if(!r)throw new VP(kM.InvalidParams,`Failed to retrieve task: Task not found`);return r},storeTaskResult:async(e,r,i)=>{await n.storeTaskResult(e,r,i,t);let a=await n.getTask(e,t);if(a){let t=iN.parse({method:`notifications/tasks/status`,params:a});await this.notification(t),qP(a.status)&&this._cleanupTaskProgressHandler(e)}},getTaskResult:e=>n.getTaskResult(e,t),updateTaskStatus:async(e,r,i)=>{let a=await n.getTask(e,t);if(!a)throw new VP(kM.InvalidParams,`Task "${e}" not found - it may have been cleaned up`);if(qP(a.status))throw new VP(kM.InvalidParams,`Cannot update task "${e}" from terminal status "${a.status}" to "${r}". Terminal states (completed, failed, cancelled) cannot transition to other states.`);await n.updateTaskStatus(e,r,i,t);let o=await n.getTask(e,t);if(o){let t=iN.parse({method:`notifications/tasks/status`,params:o});await this.notification(t),qP(o.status)&&this._cleanupTaskProgressHandler(e)}},listTasks:e=>n.listTasks(e,t)}}};sM(),(e=>typeof require<`u`?require:typeof Proxy<`u`?new Proxy(e,{get:(e,t)=>(typeof require<`u`?require:e)[t]}):e)(function(e){if(typeof require<`u`)return require.apply(this,arguments);throw Error(`Dynamic require of "`+e+`" is not supported`)});var ZP=class extends XP{_registeredMethods=new Set;_eventSlots=new Map;onEventDispatch(e,t){}_ensureEventSlot(e){let t=this._eventSlots.get(e);if(!t){let n=this.eventSchemas[e];if(!n)throw Error(`Unknown event: ${String(e)}`);t={listeners:[]},this._eventSlots.set(e,t);let r=n.shape.method.value;this._registeredMethods.add(r);let i=t;super.setNotificationHandler(n,t=>{let n=t.params;this.onEventDispatch(e,n),i.onHandler?.(n);for(let e of[...i.listeners])e(n)})}return t}setEventHandler(e,t){let n=this._ensureEventSlot(e);n.onHandler&&t&&console.warn(`[MCP Apps] on${String(e)} handler replaced. Use addEventListener("${String(e)}", …) to add multiple listeners without replacing.`),n.onHandler=t}getEventHandler(e){return this._eventSlots.get(e)?.onHandler}addEventListener(e,t){this._ensureEventSlot(e).listeners.push(t)}removeEventListener(e,t){let n=this._eventSlots.get(e);if(!n)return;let r=n.listeners.indexOf(t);r!==-1&&n.listeners.splice(r,1)}setRequestHandler=(e,t)=>{this._assertMethodNotRegistered(e,`setRequestHandler`),super.setRequestHandler(e,t)};setNotificationHandler=(e,t)=>{this._assertMethodNotRegistered(e,`setNotificationHandler`),super.setNotificationHandler(e,t)};warnIfRequestHandlerReplaced(e,t,n){t&&n&&console.warn(`[MCP Apps] ${e} handler replaced. Previous handler will no longer be called.`)}replaceRequestHandler=(e,t)=>{let n=e.shape.method.value;this._registeredMethods.add(n),super.setRequestHandler(e,t)};_assertMethodNotRegistered(e,t){let n=e.shape.method.value;if(this._registeredMethods.has(n))throw Error(`Handler for "${n}" already registered (via ${t}). Use addEventListener() to attach multiple listeners, or the on* setter for replace semantics.`);this._registeredMethods.add(n)}},QP=`2026-01-26`,$P=BA([Z(`light`),Z(`dark`)]).describe(`Color theme preference for the host environment.`),eF=BA([Z(`inline`),Z(`fullscreen`),Z(`pip`)]).describe(`Display mode for UI presentation.`),tF=UA(BA([Z(`--color-background-primary`),Z(`--color-background-secondary`),Z(`--color-background-tertiary`),Z(`--color-background-inverse`),Z(`--color-background-ghost`),Z(`--color-background-info`),Z(`--color-background-danger`),Z(`--color-background-success`),Z(`--color-background-warning`),Z(`--color-background-disabled`),Z(`--color-text-primary`),Z(`--color-text-secondary`),Z(`--color-text-tertiary`),Z(`--color-text-inverse`),Z(`--color-text-ghost`),Z(`--color-text-info`),Z(`--color-text-danger`),Z(`--color-text-success`),Z(`--color-text-warning`),Z(`--color-text-disabled`),Z(`--color-border-primary`),Z(`--color-border-secondary`),Z(`--color-border-tertiary`),Z(`--color-border-inverse`),Z(`--color-border-ghost`),Z(`--color-border-info`),Z(`--color-border-danger`),Z(`--color-border-success`),Z(`--color-border-warning`),Z(`--color-border-disabled`),Z(`--color-ring-primary`),Z(`--color-ring-secondary`),Z(`--color-ring-inverse`),Z(`--color-ring-info`),Z(`--color-ring-danger`),Z(`--color-ring-success`),Z(`--color-ring-warning`),Z(`--font-sans`),Z(`--font-mono`),Z(`--font-weight-normal`),Z(`--font-weight-medium`),Z(`--font-weight-semibold`),Z(`--font-weight-bold`),Z(`--font-text-xs-size`),Z(`--font-text-sm-size`),Z(`--font-text-md-size`),Z(`--font-text-lg-size`),Z(`--font-heading-xs-size`),Z(`--font-heading-sm-size`),Z(`--font-heading-md-size`),Z(`--font-heading-lg-size`),Z(`--font-heading-xl-size`),Z(`--font-heading-2xl-size`),Z(`--font-heading-3xl-size`),Z(`--font-text-xs-line-height`),Z(`--font-text-sm-line-height`),Z(`--font-text-md-line-height`),Z(`--font-text-lg-line-height`),Z(`--font-heading-xs-line-height`),Z(`--font-heading-sm-line-height`),Z(`--font-heading-md-line-height`),Z(`--font-heading-lg-line-height`),Z(`--font-heading-xl-line-height`),Z(`--font-heading-2xl-line-height`),Z(`--font-heading-3xl-line-height`),Z(`--border-radius-xs`),Z(`--border-radius-sm`),Z(`--border-radius-md`),Z(`--border-radius-lg`),Z(`--border-radius-xl`),Z(`--border-radius-full`),Z(`--border-width-regular`),Z(`--shadow-hairline`),Z(`--shadow-sm`),Z(`--shadow-md`),Z(`--shadow-lg`)]).describe(`CSS variable keys available to MCP apps for theming.`).describe(`Style variables for theming MCP apps.
118
+ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let n of e.seen.entries()){let r=n[1];if(t===n[0]){a(n);continue}if(e.external){let r=e.external.registry.get(n[0])?.id;if(t!==n[0]&&r){a(n);continue}}if(e.metadataRegistry.get(n[0])?.id){a(n);continue}if(r.cycle){a(n);continue}if(r.count>1&&e.reused===`ref`){a(n);continue}}}function kk(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);let r=t=>{let n=e.seen.get(t);if(n.ref===null)return;let i=n.def??n.schema,a={...i},o=n.ref;if(n.ref=null,o){r(o);let n=e.seen.get(o),s=n.schema;if(s.$ref&&(e.target===`draft-07`||e.target===`draft-04`||e.target===`openapi-3.0`)?(i.allOf=i.allOf??[],i.allOf.push(s)):Object.assign(i,s),Object.assign(i,a),t._zod.parent===o)for(let e in i)e===`$ref`||e===`allOf`||e in a||delete i[e];if(s.$ref&&n.def)for(let e in i)e===`$ref`||e===`allOf`||e in n.def&&JSON.stringify(i[e])===JSON.stringify(n.def[e])&&delete i[e]}let s=t._zod.parent;if(s&&s!==o){r(s);let t=e.seen.get(s);if(t?.schema.$ref&&(i.$ref=t.schema.$ref,t.def))for(let e in i)e===`$ref`||e===`allOf`||e in t.def&&JSON.stringify(i[e])===JSON.stringify(t.def[e])&&delete i[e]}e.override({zodSchema:t,jsonSchema:i,path:n.path??[]})};for(let t of[...e.seen.entries()].reverse())r(t[0]);let i={};if(e.target===`draft-2020-12`?i.$schema=`https://json-schema.org/draft/2020-12/schema`:e.target===`draft-07`?i.$schema=`http://json-schema.org/draft-07/schema#`:e.target===`draft-04`?i.$schema=`http://json-schema.org/draft-04/schema#`:e.target,e.external?.uri){let n=e.external.registry.get(t)?.id;if(!n)throw Error("Schema is missing an `id` property");i.$id=e.external.uri(n)}Object.assign(i,n.def??n.schema);let a=e.metadataRegistry.get(t)?.id;a!==void 0&&i.id===a&&delete i.id;let o=e.external?.defs??{};for(let t of e.seen.entries()){let e=t[1];e.def&&e.defId&&(e.def.id===e.defId&&delete e.def.id,o[e.defId]=e.def)}e.external||Object.keys(o).length>0&&(e.target===`draft-2020-12`?i.$defs=o:i.definitions=o);try{let n=JSON.parse(JSON.stringify(i));return Object.defineProperty(n,"~standard",{value:{...t[`~standard`],jsonSchema:{input:Mk(t,`input`,e.processors),output:Mk(t,`output`,e.processors)}},enumerable:!1,writable:!1}),n}catch{throw Error(`Error converting schema to JSON.`)}}function Ak(e,t){let n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);let r=e._zod.def;if(r.type===`transform`)return!0;if(r.type===`array`)return Ak(r.element,n);if(r.type===`set`)return Ak(r.valueType,n);if(r.type===`lazy`)return Ak(r.getter(),n);if(r.type===`promise`||r.type===`optional`||r.type===`nonoptional`||r.type===`nullable`||r.type===`readonly`||r.type==="default"||r.type===`prefault`)return Ak(r.innerType,n);if(r.type===`intersection`)return Ak(r.left,n)||Ak(r.right,n);if(r.type===`record`||r.type===`map`)return Ak(r.keyType,n)||Ak(r.valueType,n);if(r.type===`pipe`)return e._zod.traits.has(`$ZodCodec`)?!0:Ak(r.in,n)||Ak(r.out,n);if(r.type===`object`){for(let e in r.shape)if(Ak(r.shape[e],n))return!0;return!1}if(r.type===`union`){for(let e of r.options)if(Ak(e,n))return!0;return!1}if(r.type===`tuple`){for(let e of r.items)if(Ak(e,n))return!0;return!!(r.rest&&Ak(r.rest,n))}return!1}var jk,Mk,Nk=a((()=>{yO(),jk=(e,t={})=>n=>{let r=Ek({...n,processors:t});return Dk(e,r),Ok(r,e),kk(r,e)},Mk=(e,t,n={})=>r=>{let{libraryOptions:i,target:a}=r??{},o=Ek({...i??{},target:a,io:t,processors:n});return Dk(e,o),Ok(o,e),kk(o,e)}})),Pk,Fk,Ik,Lk,Rk,zk,Bk,Vk,Hk,Uk,Wk,Gk,Kk,qk,Jk,Yk,Xk,Zk,Qk,$k,eA,tA,nA,rA,iA,aA=a((()=>{Nk(),TT(),Pk={guid:`uuid`,url:`uri`,datetime:`date-time`,json_string:`json-string`,regex:``},Fk=(e,t,n,r)=>{let i=n;i.type=`string`;let{minimum:a,maximum:o,format:s,patterns:c,contentEncoding:l}=e._zod.bag;if(typeof a==`number`&&(i.minLength=a),typeof o==`number`&&(i.maxLength=o),s&&(i.format=Pk[s]??s,i.format===``&&delete i.format,s===`time`&&delete i.format),l&&(i.contentEncoding=l),c&&c.size>0){let e=[...c];e.length===1?i.pattern=e[0].source:e.length>1&&(i.allOf=[...e.map(e=>({...t.target===`draft-07`||t.target===`draft-04`||t.target===`openapi-3.0`?{type:`string`}:{},pattern:e.source}))])}},Ik=(e,t,n,r)=>{let i=n,{minimum:a,maximum:o,format:s,multipleOf:c,exclusiveMaximum:l,exclusiveMinimum:u}=e._zod.bag;typeof s==`string`&&s.includes(`int`)?i.type=`integer`:i.type=`number`;let d=typeof u==`number`&&u>=(a??-1/0),f=typeof l==`number`&&l<=(o??1/0),p=t.target===`draft-04`||t.target===`openapi-3.0`;d?p?(i.minimum=u,i.exclusiveMinimum=!0):i.exclusiveMinimum=u:typeof a==`number`&&(i.minimum=a),f?p?(i.maximum=l,i.exclusiveMaximum=!0):i.exclusiveMaximum=l:typeof o==`number`&&(i.maximum=o),typeof c==`number`&&(i.multipleOf=c)},Lk=(e,t,n,r)=>{n.type=`boolean`},Rk=(e,t,n,r)=>{t.target===`openapi-3.0`?(n.type=`string`,n.nullable=!0,n.enum=[null]):n.type=`null`},zk=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Undefined cannot be represented in JSON Schema`)},Bk=(e,t,n,r)=>{n.not={}},Vk=(e,t,n,r)=>{},Hk=(e,t,n,r)=>{let i=e._zod.def,a=Bw(i.entries);a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),n.enum=a},Uk=(e,t,n,r)=>{let i=e._zod.def,a=[];for(let e of i.values)if(e===void 0){if(t.unrepresentable===`throw`)throw Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof e==`bigint`){if(t.unrepresentable===`throw`)throw Error(`BigInt literals cannot be represented in JSON Schema`);a.push(Number(e))}else a.push(e);if(a.length!==0)if(a.length===1){let e=a[0];n.type=e===null?`null`:typeof e,t.target===`draft-04`||t.target===`openapi-3.0`?n.enum=[e]:n.const=e}else a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),a.every(e=>typeof e==`boolean`)&&(n.type=`boolean`),a.every(e=>e===null)&&(n.type=`null`),n.enum=a},Wk=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Custom types cannot be represented in JSON Schema`)},Gk=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Transforms cannot be represented in JSON Schema`)},Kk=(e,t,n,r)=>{let i=n,a=e._zod.def,{minimum:o,maximum:s}=e._zod.bag;typeof o==`number`&&(i.minItems=o),typeof s==`number`&&(i.maxItems=s),i.type=`array`,i.items=Dk(a.element,t,{...r,path:[...r.path,`items`]})},qk=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`object`,i.properties={};let o=a.shape;for(let e in o)i.properties[e]=Dk(o[e],t,{...r,path:[...r.path,`properties`,e]});let s=new Set(Object.keys(o)),c=new Set([...s].filter(e=>{let n=a.shape[e]._zod;return t.io===`input`?n.optin===void 0:n.optout===void 0}));c.size>0&&(i.required=Array.from(c)),a.catchall?._zod.def.type===`never`?i.additionalProperties=!1:a.catchall?a.catchall&&(i.additionalProperties=Dk(a.catchall,t,{...r,path:[...r.path,`additionalProperties`]})):t.io===`output`&&(i.additionalProperties=!1)},Jk=(e,t,n,r)=>{let i=e._zod.def,a=i.inclusive===!1,o=i.options.map((e,n)=>Dk(e,t,{...r,path:[...r.path,a?`oneOf`:`anyOf`,n]}));a?n.oneOf=o:n.anyOf=o},Yk=(e,t,n,r)=>{let i=e._zod.def,a=Dk(i.left,t,{...r,path:[...r.path,`allOf`,0]}),o=Dk(i.right,t,{...r,path:[...r.path,`allOf`,1]}),s=e=>`allOf`in e&&Object.keys(e).length===1;n.allOf=[...s(a)?a.allOf:[a],...s(o)?o.allOf:[o]]},Xk=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`object`;let o=a.keyType,s=o._zod.bag?.patterns;if(a.mode===`loose`&&s&&s.size>0){let e=Dk(a.valueType,t,{...r,path:[...r.path,`patternProperties`,`*`]});i.patternProperties={};for(let t of s)i.patternProperties[t.source]=e}else(t.target===`draft-07`||t.target===`draft-2020-12`)&&(i.propertyNames=Dk(a.keyType,t,{...r,path:[...r.path,`propertyNames`]})),i.additionalProperties=Dk(a.valueType,t,{...r,path:[...r.path,`additionalProperties`]});let c=o._zod.values;if(c){let e=[...c].filter(e=>typeof e==`string`||typeof e==`number`);e.length>0&&(i.required=e)}},Zk=(e,t,n,r)=>{let i=e._zod.def,a=Dk(i.innerType,t,r),o=t.seen.get(e);t.target===`openapi-3.0`?(o.ref=i.innerType,n.nullable=!0):n.anyOf=[a,{type:`null`}]},Qk=(e,t,n,r)=>{let i=e._zod.def;Dk(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},$k=(e,t,n,r)=>{let i=e._zod.def;Dk(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.default=JSON.parse(JSON.stringify(i.defaultValue))},eA=(e,t,n,r)=>{let i=e._zod.def;Dk(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,t.io===`input`&&(n._prefault=JSON.parse(JSON.stringify(i.defaultValue)))},tA=(e,t,n,r)=>{let i=e._zod.def;Dk(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o;try{o=i.catchValue(void 0)}catch{throw Error(`Dynamic catch values are not supported in JSON Schema`)}n.default=o},nA=(e,t,n,r)=>{let i=e._zod.def,a=i.in._zod.traits.has(`$ZodTransform`),o=t.io===`input`?a?i.out:i.in:i.out;Dk(o,t,r);let s=t.seen.get(e);s.ref=o},rA=(e,t,n,r)=>{let i=e._zod.def;Dk(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.readOnly=!0},iA=(e,t,n,r)=>{let i=e._zod.def;Dk(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType}})),oA=a((()=>{zw(),KT(),jT(),dO(),WE(),JE(),TT(),EE(),mO(),yO(),KE(),Tk(),Nk(),aA(),Nk()})),sA=a((()=>{oA()}));function cA(e){return UO(fA,e)}function lA(e){return WO(pA,e)}function uA(e){return GO(mA,e)}function dA(e){return KO(hA,e)}var fA,pA,mA,hA,gA=a((()=>{oA(),iM(),fA=K(`ZodISODateTime`,(e,t)=>{TD.init(e,t),dj.init(e,t)}),pA=K(`ZodISODate`,(e,t)=>{ED.init(e,t),dj.init(e,t)}),mA=K(`ZodISOTime`,(e,t)=>{DD.init(e,t),dj.init(e,t)}),hA=K(`ZodISODuration`,(e,t)=>{OD.init(e,t),dj.init(e,t)})})),_A,vA,yA=a((()=>{oA(),TT(),_A=(e,t)=>{kT.init(e,t),e.name=`ZodError`,Object.defineProperties(e,{format:{value:t=>DT(e,t)},flatten:{value:t=>ET(e,t)},addIssue:{value:t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,Hw,2)}},addIssues:{value:t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,Hw,2)}},isEmpty:{get(){return e.issues.length===0}}})},vA=K(`ZodError`,_A,{Parent:Error})})),bA,xA,SA,CA,wA,TA,EA,DA,OA,kA,AA,jA,MA=a((()=>{oA(),yA(),bA=MT(vA),xA=NT(vA),SA=PT(vA),CA=IT(vA),wA=RT(vA),TA=zT(vA),EA=BT(vA),DA=VT(vA),OA=HT(vA),kA=UT(vA),AA=WT(vA),jA=GT(vA)}));function NA(e,t,n){let r=Object.getPrototypeOf(e),i=sj.get(r);if(i||(i=new Set,sj.set(r,i)),!i.has(t)){i.add(t);for(let e in n){let t=n[e];Object.defineProperty(r,e,{configurable:!0,enumerable:!1,get(){let n=t.bind(this);return Object.defineProperty(this,e,{configurable:!0,writable:!0,enumerable:!0,value:n}),n},set(t){Object.defineProperty(this,e,{configurable:!0,writable:!0,enumerable:!0,value:t})}})}}}function J(e){return bO(uj,e)}function PA(e){return qO(jj,e)}function FA(e){return JO(Mj,e)}function IA(e){return YO(Nj,e)}function LA(e){return XO(Pj,e)}function RA(e){return ZO(Fj,e)}function zA(){return QO(Ij)}function BA(e){return $O(Lj,e)}function Y(e,t){return bk(Rj,e,t)}function X(e,t){let n={type:`object`,shape:e??{},...q(t)};return new zj(n)}function VA(e,t){return new zj({type:`object`,shape:e,catchall:zA(),...q(t)})}function HA(e,t){return new Bj({type:`union`,options:e,...q(t)})}function UA(e,t,n){return new Vj({type:`union`,options:t,discriminator:e,...q(n)})}function WA(e,t){return new Hj({type:`intersection`,left:e,right:t})}function GA(e,t,n){return!t||!t._zod?new Uj({type:`record`,keyType:J(),valueType:e,...q(t)}):new Uj({type:`record`,keyType:e,valueType:t,...q(n)})}function KA(e,t){let n=Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e;return new Wj({type:`enum`,entries:n,...q(t)})}function Z(e,t){return new Gj({type:`literal`,values:Array.isArray(e)?e:[e],...q(t)})}function qA(e){return new Kj({type:`transform`,transform:e})}function JA(e){return new qj({type:`optional`,innerType:e})}function YA(e){return new Jj({type:`optional`,innerType:e})}function XA(e){return new Yj({type:`nullable`,innerType:e})}function ZA(e,t){return new Xj({type:`default`,innerType:e,get defaultValue(){return typeof t==`function`?t():eT(t)}})}function QA(e,t){return new Zj({type:`prefault`,innerType:e,get defaultValue(){return typeof t==`function`?t():eT(t)}})}function $A(e,t){return new Qj({type:`nonoptional`,innerType:e,...q(t)})}function ej(e,t){return new $j({type:`catch`,innerType:e,catchValue:typeof t==`function`?t:()=>t})}function tj(e,t){return new eM({type:`pipe`,in:e,out:t})}function nj(e){return new nM({type:`readonly`,innerType:e})}function rj(e,t){return xk(rM,e??(()=>!0),t)}function ij(e,t={}){return Sk(rM,e,t)}function aj(e,t){return Ck(e,t)}function oj(e,t){return new tM({type:`pipe`,in:qA(e),out:t})}var sj,cj,lj,uj,dj,fj,pj,mj,hj,gj,_j,vj,yj,bj,xj,Sj,Cj,wj,Tj,Ej,Dj,Oj,kj,Aj,jj,Mj,Nj,Pj,Fj,Ij,Lj,Rj,zj,Bj,Vj,Hj,Uj,Wj,Gj,Kj,qj,Jj,Yj,Xj,Zj,Qj,$j,eM,tM,nM,rM,iM=a((()=>{oA(),aA(),Nk(),sA(),gA(),MA(),sj=new WeakMap,cj=K(`ZodType`,(e,t)=>(dD.init(e,t),Object.assign(e[`~standard`],{jsonSchema:{input:Mk(e,`input`),output:Mk(e,`output`)}}),e.toJSONSchema=jk(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.parse=(t,n)=>bA(e,t,n,{callee:e.parse}),e.safeParse=(t,n)=>SA(e,t,n),e.parseAsync=async(t,n)=>xA(e,t,n,{callee:e.parseAsync}),e.safeParseAsync=async(t,n)=>CA(e,t,n),e.spa=e.safeParseAsync,e.encode=(t,n)=>wA(e,t,n),e.decode=(t,n)=>TA(e,t,n),e.encodeAsync=async(t,n)=>EA(e,t,n),e.decodeAsync=async(t,n)=>DA(e,t,n),e.safeEncode=(t,n)=>OA(e,t,n),e.safeDecode=(t,n)=>kA(e,t,n),e.safeEncodeAsync=async(t,n)=>AA(e,t,n),e.safeDecodeAsync=async(t,n)=>jA(e,t,n),NA(e,`ZodType`,{check(...e){let t=this.def;return this.clone(Yw(t,{checks:[...t.checks??[],...e.map(e=>typeof e==`function`?{_zod:{check:e,def:{check:`custom`},onattach:[]}}:e)]}),{parent:!0})},with(...e){return this.check(...e)},clone(e,t){return nT(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(ij(e,t))},superRefine(e,t){return this.check(aj(e,t))},overwrite(e){return this.check(mk(e))},optional(){return JA(this)},exactOptional(){return YA(this)},nullable(){return XA(this)},nullish(){return JA(XA(this))},nonoptional(e){return $A(this,e)},array(){return Y(this)},or(e){return HA([this,e])},and(e){return WA(this,e)},transform(e){return tj(this,qA(e))},default(e){return ZA(this,e)},prefault(e){return QA(this,e)},catch(e){return ej(this,e)},pipe(e){return tj(this,e)},readonly(){return nj(this)},describe(e){let t=this.clone();return vO.add(t,{description:e}),t},meta(...e){if(e.length===0)return vO.get(this);let t=this.clone();return vO.add(t,e[0]),t},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(e){return e(this)}}),Object.defineProperty(e,"description",{get(){return vO.get(e)?.description},configurable:!0}),e)),lj=K(`_ZodString`,(e,t)=>{fD.init(e,t),cj.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Fk(e,t,n,r);let n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,NA(e,`_ZodString`,{regex(...e){return this.check(ck(...e))},includes(...e){return this.check(dk(...e))},startsWith(...e){return this.check(fk(...e))},endsWith(...e){return this.check(pk(...e))},min(...e){return this.check(ok(...e))},max(...e){return this.check(ak(...e))},length(...e){return this.check(sk(...e))},nonempty(...e){return this.check(ok(1,...e))},lowercase(e){return this.check(lk(e))},uppercase(e){return this.check(uk(e))},trim(){return this.check(gk())},normalize(...e){return this.check(hk(...e))},toLowerCase(){return this.check(_k())},toUpperCase(){return this.check(vk())},slugify(){return this.check(yk())}})}),uj=K(`ZodString`,(e,t)=>{fD.init(e,t),lj.init(e,t),e.email=t=>e.check(xO(fj,t)),e.url=t=>e.check(DO(hj,t)),e.jwt=t=>e.check(HO(Aj,t)),e.emoji=t=>e.check(OO(gj,t)),e.guid=t=>e.check(SO(pj,t)),e.uuid=t=>e.check(CO(mj,t)),e.uuidv4=t=>e.check(wO(mj,t)),e.uuidv6=t=>e.check(TO(mj,t)),e.uuidv7=t=>e.check(EO(mj,t)),e.nanoid=t=>e.check(kO(_j,t)),e.guid=t=>e.check(SO(pj,t)),e.cuid=t=>e.check(AO(vj,t)),e.cuid2=t=>e.check(jO(yj,t)),e.ulid=t=>e.check(MO(bj,t)),e.base64=t=>e.check(zO(Dj,t)),e.base64url=t=>e.check(BO(Oj,t)),e.xid=t=>e.check(NO(xj,t)),e.ksuid=t=>e.check(PO(Sj,t)),e.ipv4=t=>e.check(FO(Cj,t)),e.ipv6=t=>e.check(IO(wj,t)),e.cidrv4=t=>e.check(LO(Tj,t)),e.cidrv6=t=>e.check(RO(Ej,t)),e.e164=t=>e.check(VO(kj,t)),e.datetime=t=>e.check(cA(t)),e.date=t=>e.check(lA(t)),e.time=t=>e.check(uA(t)),e.duration=t=>e.check(dA(t))}),dj=K(`ZodStringFormat`,(e,t)=>{pD.init(e,t),lj.init(e,t)}),fj=K(`ZodEmail`,(e,t)=>{gD.init(e,t),dj.init(e,t)}),pj=K(`ZodGUID`,(e,t)=>{mD.init(e,t),dj.init(e,t)}),mj=K(`ZodUUID`,(e,t)=>{hD.init(e,t),dj.init(e,t)}),hj=K(`ZodURL`,(e,t)=>{_D.init(e,t),dj.init(e,t)}),gj=K(`ZodEmoji`,(e,t)=>{vD.init(e,t),dj.init(e,t)}),_j=K(`ZodNanoID`,(e,t)=>{yD.init(e,t),dj.init(e,t)}),vj=K(`ZodCUID`,(e,t)=>{bD.init(e,t),dj.init(e,t)}),yj=K(`ZodCUID2`,(e,t)=>{xD.init(e,t),dj.init(e,t)}),bj=K(`ZodULID`,(e,t)=>{SD.init(e,t),dj.init(e,t)}),xj=K(`ZodXID`,(e,t)=>{CD.init(e,t),dj.init(e,t)}),Sj=K(`ZodKSUID`,(e,t)=>{wD.init(e,t),dj.init(e,t)}),Cj=K(`ZodIPv4`,(e,t)=>{kD.init(e,t),dj.init(e,t)}),wj=K(`ZodIPv6`,(e,t)=>{AD.init(e,t),dj.init(e,t)}),Tj=K(`ZodCIDRv4`,(e,t)=>{jD.init(e,t),dj.init(e,t)}),Ej=K(`ZodCIDRv6`,(e,t)=>{MD.init(e,t),dj.init(e,t)}),Dj=K(`ZodBase64`,(e,t)=>{ND.init(e,t),dj.init(e,t)}),Oj=K(`ZodBase64URL`,(e,t)=>{PD.init(e,t),dj.init(e,t)}),kj=K(`ZodE164`,(e,t)=>{FD.init(e,t),dj.init(e,t)}),Aj=K(`ZodJWT`,(e,t)=>{ID.init(e,t),dj.init(e,t)}),jj=K(`ZodNumber`,(e,t)=>{LD.init(e,t),cj.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ik(e,t,n,r),NA(e,`ZodNumber`,{gt(e,t){return this.check(nk(e,t))},gte(e,t){return this.check(rk(e,t))},min(e,t){return this.check(rk(e,t))},lt(e,t){return this.check(ek(e,t))},lte(e,t){return this.check(tk(e,t))},max(e,t){return this.check(tk(e,t))},int(e){return this.check(FA(e))},safe(e){return this.check(FA(e))},positive(e){return this.check(nk(0,e))},nonnegative(e){return this.check(rk(0,e))},negative(e){return this.check(ek(0,e))},nonpositive(e){return this.check(tk(0,e))},multipleOf(e,t){return this.check(ik(e,t))},step(e,t){return this.check(ik(e,t))},finite(){return this}});let n=e._zod.bag;e.minValue=Math.max(n.minimum??-1/0,n.exclusiveMinimum??-1/0)??null,e.maxValue=Math.min(n.maximum??1/0,n.exclusiveMaximum??1/0)??null,e.isInt=(n.format??``).includes(`int`)||Number.isSafeInteger(n.multipleOf??.5),e.isFinite=!0,e.format=n.format??null}),Mj=K(`ZodNumberFormat`,(e,t)=>{RD.init(e,t),jj.init(e,t)}),Nj=K(`ZodBoolean`,(e,t)=>{zD.init(e,t),cj.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Lk(e,t,n,r)}),Pj=K(`ZodUndefined`,(e,t)=>{BD.init(e,t),cj.init(e,t),e._zod.processJSONSchema=(t,n,r)=>zk(e,t,n,r)}),Fj=K(`ZodNull`,(e,t)=>{VD.init(e,t),cj.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Rk(e,t,n,r)}),Ij=K(`ZodUnknown`,(e,t)=>{HD.init(e,t),cj.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Vk(e,t,n,r)}),Lj=K(`ZodNever`,(e,t)=>{UD.init(e,t),cj.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Bk(e,t,n,r)}),Rj=K(`ZodArray`,(e,t)=>{WD.init(e,t),cj.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Kk(e,t,n,r),e.element=t.element,NA(e,`ZodArray`,{min(e,t){return this.check(ok(e,t))},nonempty(e){return this.check(ok(1,e))},max(e,t){return this.check(ak(e,t))},length(e,t){return this.check(sk(e,t))},unwrap(){return this.element}})}),zj=K(`ZodObject`,(e,t)=>{KD.init(e,t),cj.init(e,t),e._zod.processJSONSchema=(t,n,r)=>qk(e,t,n,r),qw(e,`shape`,()=>t.shape),NA(e,`ZodObject`,{keyof(){return KA(Object.keys(this._zod.def.shape))},catchall(e){return this.clone({...this._zod.def,catchall:e})},passthrough(){return this.clone({...this._zod.def,catchall:zA()})},loose(){return this.clone({...this._zod.def,catchall:zA()})},strict(){return this.clone({...this._zod.def,catchall:BA()})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(e){return sT(this,e)},safeExtend(e){return cT(this,e)},merge(e){return lT(this,e)},pick(e){return aT(this,e)},omit(e){return oT(this,e)},partial(...e){return uT(qj,this,e[0])},required(...e){return dT(Qj,this,e[0])}})}),Bj=K(`ZodUnion`,(e,t)=>{qD.init(e,t),cj.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Jk(e,t,n,r),e.options=t.options}),Vj=K(`ZodDiscriminatedUnion`,(e,t)=>{Bj.init(e,t),JD.init(e,t)}),Hj=K(`ZodIntersection`,(e,t)=>{YD.init(e,t),cj.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Yk(e,t,n,r)}),Uj=K(`ZodRecord`,(e,t)=>{XD.init(e,t),cj.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Xk(e,t,n,r),e.keyType=t.keyType,e.valueType=t.valueType}),Wj=K(`ZodEnum`,(e,t)=>{ZD.init(e,t),cj.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Hk(e,t,n,r),e.enum=t.entries,e.options=Object.values(t.entries);let n=new Set(Object.keys(t.entries));e.extract=(e,r)=>{let i={};for(let r of e)if(n.has(r))i[r]=t.entries[r];else throw Error(`Key ${r} not found in enum`);return new Wj({...t,checks:[],...q(r),entries:i})},e.exclude=(e,r)=>{let i={...t.entries};for(let t of e)if(n.has(t))delete i[t];else throw Error(`Key ${t} not found in enum`);return new Wj({...t,checks:[],...q(r),entries:i})}}),Gj=K(`ZodLiteral`,(e,t)=>{QD.init(e,t),cj.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Uk(e,t,n,r),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})}),Kj=K(`ZodTransform`,(e,t)=>{$D.init(e,t),cj.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Gk(e,t,n,r),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new Lw(e.constructor.name);n.addIssue=r=>{if(typeof r==`string`)n.issues.push(yT(r,n.value,t));else{let t=r;t.fatal&&(t.continue=!1),t.code??=`custom`,t.input??=n.value,t.inst??=e,n.issues.push(yT(t))}};let i=t.transform(n.value,n);return i instanceof Promise?i.then(e=>(n.value=e,n.fallback=!0,n)):(n.value=i,n.fallback=!0,n)}}),qj=K(`ZodOptional`,(e,t)=>{eO.init(e,t),cj.init(e,t),e._zod.processJSONSchema=(t,n,r)=>iA(e,t,n,r),e.unwrap=()=>e._zod.def.innerType}),Jj=K(`ZodExactOptional`,(e,t)=>{tO.init(e,t),cj.init(e,t),e._zod.processJSONSchema=(t,n,r)=>iA(e,t,n,r),e.unwrap=()=>e._zod.def.innerType}),Yj=K(`ZodNullable`,(e,t)=>{nO.init(e,t),cj.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Zk(e,t,n,r),e.unwrap=()=>e._zod.def.innerType}),Xj=K(`ZodDefault`,(e,t)=>{rO.init(e,t),cj.init(e,t),e._zod.processJSONSchema=(t,n,r)=>$k(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap}),Zj=K(`ZodPrefault`,(e,t)=>{iO.init(e,t),cj.init(e,t),e._zod.processJSONSchema=(t,n,r)=>eA(e,t,n,r),e.unwrap=()=>e._zod.def.innerType}),Qj=K(`ZodNonOptional`,(e,t)=>{aO.init(e,t),cj.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Qk(e,t,n,r),e.unwrap=()=>e._zod.def.innerType}),$j=K(`ZodCatch`,(e,t)=>{oO.init(e,t),cj.init(e,t),e._zod.processJSONSchema=(t,n,r)=>tA(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap}),eM=K(`ZodPipe`,(e,t)=>{sO.init(e,t),cj.init(e,t),e._zod.processJSONSchema=(t,n,r)=>nA(e,t,n,r),e.in=t.in,e.out=t.out}),tM=K(`ZodPreprocess`,(e,t)=>{eM.init(e,t),cO.init(e,t)}),nM=K(`ZodReadonly`,(e,t)=>{lO.init(e,t),cj.init(e,t),e._zod.processJSONSchema=(t,n,r)=>rA(e,t,n,r),e.unwrap=()=>e._zod.def.innerType}),rM=K(`ZodCustom`,(e,t)=>{uO.init(e,t),cj.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Wk(e,t,n,r)})})),aM,oM=a((()=>{oA(),aM||={}})),sM=a((()=>{oA(),iM(),sA(),yA(),MA(),oM(),mO(),aA(),yO(),sA(),gA(),iM(),TT(),Pw(fO())})),cM=a((()=>{sM(),sM()})),lM=a((()=>{cM()}));lM();var uM=`io.modelcontextprotocol/related-task`,dM=rj(e=>e!==null&&(typeof e==`object`||typeof e==`function`)),fM=HA([J(),PA().int()]),pM=J();VA({ttl:PA().optional(),pollInterval:PA().optional()});var mM=X({ttl:PA().optional()}),hM=X({taskId:J()}),gM=VA({progressToken:fM.optional(),[uM]:hM.optional()}),_M=X({_meta:gM.optional()}),vM=_M.extend({task:mM.optional()}),yM=e=>vM.safeParse(e).success,bM=X({method:J(),params:_M.loose().optional()}),xM=X({_meta:gM.optional()}),SM=X({method:J(),params:xM.loose().optional()}),CM=VA({_meta:gM.optional()}),wM=HA([J(),PA().int()]),TM=X({jsonrpc:Z(`2.0`),id:wM,...bM.shape}).strict(),EM=e=>TM.safeParse(e).success,DM=X({jsonrpc:Z(`2.0`),...SM.shape}).strict(),OM=e=>DM.safeParse(e).success,kM=X({jsonrpc:Z(`2.0`),id:wM,result:CM}).strict(),AM=e=>kM.safeParse(e).success,jM;(function(e){e[e.ConnectionClosed=-32e3]=`ConnectionClosed`,e[e.RequestTimeout=-32001]=`RequestTimeout`,e[e.ParseError=-32700]=`ParseError`,e[e.InvalidRequest=-32600]=`InvalidRequest`,e[e.MethodNotFound=-32601]=`MethodNotFound`,e[e.InvalidParams=-32602]=`InvalidParams`,e[e.InternalError=-32603]=`InternalError`,e[e.UrlElicitationRequired=-32042]=`UrlElicitationRequired`})(jM||={});var MM=X({jsonrpc:Z(`2.0`),id:wM.optional(),error:X({code:PA().int(),message:J(),data:zA().optional()})}).strict(),NM=e=>MM.safeParse(e).success;HA([TM,DM,kM,MM]),HA([kM,MM]);var PM=CM.strict(),FM=xM.extend({requestId:wM.optional(),reason:J().optional()}),IM=SM.extend({method:Z(`notifications/cancelled`),params:FM}),LM=X({icons:Y(X({src:J(),mimeType:J().optional(),sizes:Y(J()).optional(),theme:KA([`light`,`dark`]).optional()})).optional()}),RM=X({name:J(),title:J().optional()}),zM=RM.extend({...RM.shape,...LM.shape,version:J(),websiteUrl:J().optional(),description:J().optional()}),BM=oj(e=>e&&typeof e==`object`&&!Array.isArray(e)&&Object.keys(e).length===0?{form:{}}:e,WA(X({form:WA(X({applyDefaults:IA().optional()}),GA(J(),zA())).optional(),url:dM.optional()}),GA(J(),zA()).optional())),VM=VA({list:dM.optional(),cancel:dM.optional(),requests:VA({sampling:VA({createMessage:dM.optional()}).optional(),elicitation:VA({create:dM.optional()}).optional()}).optional()}),HM=VA({list:dM.optional(),cancel:dM.optional(),requests:VA({tools:VA({call:dM.optional()}).optional()}).optional()}),UM=X({experimental:GA(J(),dM).optional(),sampling:X({context:dM.optional(),tools:dM.optional()}).optional(),elicitation:BM.optional(),roots:X({listChanged:IA().optional()}).optional(),tasks:VM.optional(),extensions:GA(J(),dM).optional()}),WM=_M.extend({protocolVersion:J(),capabilities:UM,clientInfo:zM}),GM=bM.extend({method:Z(`initialize`),params:WM}),KM=X({experimental:GA(J(),dM).optional(),logging:dM.optional(),completions:dM.optional(),prompts:X({listChanged:IA().optional()}).optional(),resources:X({subscribe:IA().optional(),listChanged:IA().optional()}).optional(),tools:X({listChanged:IA().optional()}).optional(),tasks:HM.optional(),extensions:GA(J(),dM).optional()}),qM=CM.extend({protocolVersion:J(),capabilities:KM,serverInfo:zM,instructions:J().optional()}),JM=SM.extend({method:Z(`notifications/initialized`),params:xM.optional()}),YM=bM.extend({method:Z(`ping`),params:_M.optional()}),XM=X({progress:PA(),total:JA(PA()),message:JA(J())}),ZM=X({...xM.shape,...XM.shape,progressToken:fM}),QM=SM.extend({method:Z(`notifications/progress`),params:ZM}),$M=_M.extend({cursor:pM.optional()}),eN=bM.extend({params:$M.optional()}),tN=CM.extend({nextCursor:pM.optional()}),nN=KA([`working`,`input_required`,`completed`,`failed`,`cancelled`]),rN=X({taskId:J(),status:nN,ttl:HA([PA(),RA()]),createdAt:J(),lastUpdatedAt:J(),pollInterval:JA(PA()),statusMessage:JA(J())}),iN=CM.extend({task:rN}),aN=xM.merge(rN),oN=SM.extend({method:Z(`notifications/tasks/status`),params:aN}),sN=bM.extend({method:Z(`tasks/get`),params:_M.extend({taskId:J()})}),cN=CM.merge(rN),lN=bM.extend({method:Z(`tasks/result`),params:_M.extend({taskId:J()})});CM.loose();var uN=eN.extend({method:Z(`tasks/list`)}),dN=tN.extend({tasks:Y(rN)}),fN=bM.extend({method:Z(`tasks/cancel`),params:_M.extend({taskId:J()})}),pN=CM.merge(rN),mN=X({uri:J(),mimeType:JA(J()),_meta:GA(J(),zA()).optional()}),hN=mN.extend({text:J()}),gN=J().refine(e=>{try{return atob(e),!0}catch{return!1}},{message:`Invalid Base64 string`}),_N=mN.extend({blob:gN}),vN=KA([`user`,`assistant`]),yN=X({audience:Y(vN).optional(),priority:PA().min(0).max(1).optional(),lastModified:cA({offset:!0}).optional()}),bN=X({...RM.shape,...LM.shape,uri:J(),description:JA(J()),mimeType:JA(J()),size:JA(PA()),annotations:yN.optional(),_meta:JA(VA({}))}),xN=X({...RM.shape,...LM.shape,uriTemplate:J(),description:JA(J()),mimeType:JA(J()),annotations:yN.optional(),_meta:JA(VA({}))}),SN=eN.extend({method:Z(`resources/list`)}),CN=tN.extend({resources:Y(bN)}),wN=eN.extend({method:Z(`resources/templates/list`)}),TN=tN.extend({resourceTemplates:Y(xN)}),EN=_M.extend({uri:J()}),DN=EN,ON=bM.extend({method:Z(`resources/read`),params:DN}),kN=CM.extend({contents:Y(HA([hN,_N]))}),AN=SM.extend({method:Z(`notifications/resources/list_changed`),params:xM.optional()}),jN=EN,MN=bM.extend({method:Z(`resources/subscribe`),params:jN}),NN=EN,PN=bM.extend({method:Z(`resources/unsubscribe`),params:NN}),FN=xM.extend({uri:J()}),IN=SM.extend({method:Z(`notifications/resources/updated`),params:FN}),LN=X({name:J(),description:JA(J()),required:JA(IA())}),RN=X({...RM.shape,...LM.shape,description:JA(J()),arguments:JA(Y(LN)),_meta:JA(VA({}))}),zN=eN.extend({method:Z(`prompts/list`)}),BN=tN.extend({prompts:Y(RN)}),VN=_M.extend({name:J(),arguments:GA(J(),J()).optional()}),HN=bM.extend({method:Z(`prompts/get`),params:VN}),UN=X({type:Z(`text`),text:J(),annotations:yN.optional(),_meta:GA(J(),zA()).optional()}),WN=X({type:Z(`image`),data:gN,mimeType:J(),annotations:yN.optional(),_meta:GA(J(),zA()).optional()}),GN=X({type:Z(`audio`),data:gN,mimeType:J(),annotations:yN.optional(),_meta:GA(J(),zA()).optional()}),KN=X({type:Z(`tool_use`),name:J(),id:J(),input:GA(J(),zA()),_meta:GA(J(),zA()).optional()}),qN=X({type:Z(`resource`),resource:HA([hN,_N]),annotations:yN.optional(),_meta:GA(J(),zA()).optional()}),JN=bN.extend({type:Z(`resource_link`)}),YN=HA([UN,WN,GN,JN,qN]),XN=X({role:vN,content:YN}),ZN=CM.extend({description:J().optional(),messages:Y(XN)}),QN=SM.extend({method:Z(`notifications/prompts/list_changed`),params:xM.optional()}),$N=X({title:J().optional(),readOnlyHint:IA().optional(),destructiveHint:IA().optional(),idempotentHint:IA().optional(),openWorldHint:IA().optional()}),eP=X({taskSupport:KA([`required`,`optional`,`forbidden`]).optional()}),tP=X({...RM.shape,...LM.shape,description:J().optional(),inputSchema:X({type:Z(`object`),properties:GA(J(),dM).optional(),required:Y(J()).optional()}).catchall(zA()),outputSchema:X({type:Z(`object`),properties:GA(J(),dM).optional(),required:Y(J()).optional()}).catchall(zA()).optional(),annotations:$N.optional(),execution:eP.optional(),_meta:GA(J(),zA()).optional()}),nP=eN.extend({method:Z(`tools/list`)}),rP=tN.extend({tools:Y(tP)}),iP=CM.extend({content:Y(YN).default([]),structuredContent:GA(J(),zA()).optional(),isError:IA().optional()});iP.or(CM.extend({toolResult:zA()}));var aP=vM.extend({name:J(),arguments:GA(J(),zA()).optional()}),oP=bM.extend({method:Z(`tools/call`),params:aP}),sP=SM.extend({method:Z(`notifications/tools/list_changed`),params:xM.optional()});X({autoRefresh:IA().default(!0),debounceMs:PA().int().nonnegative().default(300)});var cP=KA([`debug`,`info`,`notice`,`warning`,`error`,`critical`,`alert`,`emergency`]),lP=_M.extend({level:cP}),uP=bM.extend({method:Z(`logging/setLevel`),params:lP}),dP=xM.extend({level:cP,logger:J().optional(),data:zA()}),fP=SM.extend({method:Z(`notifications/message`),params:dP}),pP=X({hints:Y(X({name:J().optional()})).optional(),costPriority:PA().min(0).max(1).optional(),speedPriority:PA().min(0).max(1).optional(),intelligencePriority:PA().min(0).max(1).optional()}),mP=X({mode:KA([`auto`,`required`,`none`]).optional()}),hP=X({type:Z(`tool_result`),toolUseId:J().describe(`The unique identifier for the corresponding tool call.`),content:Y(YN).default([]),structuredContent:X({}).loose().optional(),isError:IA().optional(),_meta:GA(J(),zA()).optional()}),gP=UA(`type`,[UN,WN,GN]),_P=UA(`type`,[UN,WN,GN,KN,hP]),vP=X({role:vN,content:HA([_P,Y(_P)]),_meta:GA(J(),zA()).optional()}),yP=vM.extend({messages:Y(vP),modelPreferences:pP.optional(),systemPrompt:J().optional(),includeContext:KA([`none`,`thisServer`,`allServers`]).optional(),temperature:PA().optional(),maxTokens:PA().int(),stopSequences:Y(J()).optional(),metadata:dM.optional(),tools:Y(tP).optional(),toolChoice:mP.optional()}),bP=bM.extend({method:Z(`sampling/createMessage`),params:yP}),xP=CM.extend({model:J(),stopReason:JA(KA([`endTurn`,`stopSequence`,`maxTokens`]).or(J())),role:vN,content:gP}),SP=CM.extend({model:J(),stopReason:JA(KA([`endTurn`,`stopSequence`,`maxTokens`,`toolUse`]).or(J())),role:vN,content:HA([_P,Y(_P)])}),CP=X({type:Z(`boolean`),title:J().optional(),description:J().optional(),default:IA().optional()}),wP=X({type:Z(`string`),title:J().optional(),description:J().optional(),minLength:PA().optional(),maxLength:PA().optional(),format:KA([`email`,`uri`,`date`,`date-time`]).optional(),default:J().optional()}),TP=X({type:KA([`number`,`integer`]),title:J().optional(),description:J().optional(),minimum:PA().optional(),maximum:PA().optional(),default:PA().optional()}),EP=X({type:Z(`string`),title:J().optional(),description:J().optional(),enum:Y(J()),default:J().optional()}),DP=X({type:Z(`string`),title:J().optional(),description:J().optional(),oneOf:Y(X({const:J(),title:J()})),default:J().optional()}),OP=HA([HA([X({type:Z(`string`),title:J().optional(),description:J().optional(),enum:Y(J()),enumNames:Y(J()).optional(),default:J().optional()}),HA([EP,DP]),HA([X({type:Z(`array`),title:J().optional(),description:J().optional(),minItems:PA().optional(),maxItems:PA().optional(),items:X({type:Z(`string`),enum:Y(J())}),default:Y(J()).optional()}),X({type:Z(`array`),title:J().optional(),description:J().optional(),minItems:PA().optional(),maxItems:PA().optional(),items:X({anyOf:Y(X({const:J(),title:J()}))}),default:Y(J()).optional()})])]),CP,wP,TP]),kP=HA([vM.extend({mode:Z(`form`).optional(),message:J(),requestedSchema:X({type:Z(`object`),properties:GA(J(),OP),required:Y(J()).optional()})}),vM.extend({mode:Z(`url`),message:J(),elicitationId:J(),url:J().url()})]),AP=bM.extend({method:Z(`elicitation/create`),params:kP}),jP=xM.extend({elicitationId:J()}),MP=SM.extend({method:Z(`notifications/elicitation/complete`),params:jP}),NP=CM.extend({action:KA([`accept`,`decline`,`cancel`]),content:oj(e=>e===null?void 0:e,GA(J(),HA([J(),PA(),IA(),Y(J())])).optional())}),PP=X({type:Z(`ref/resource`),uri:J()}),FP=X({type:Z(`ref/prompt`),name:J()}),IP=_M.extend({ref:HA([FP,PP]),argument:X({name:J(),value:J()}),context:X({arguments:GA(J(),J()).optional()}).optional()}),LP=bM.extend({method:Z(`completion/complete`),params:IP}),RP=CM.extend({completion:VA({values:Y(J()).max(100),total:JA(PA().int()),hasMore:JA(IA())})}),zP=X({uri:J().startsWith(`file://`),name:J().optional(),_meta:GA(J(),zA()).optional()}),BP=bM.extend({method:Z(`roots/list`),params:_M.optional()}),VP=CM.extend({roots:Y(zP)}),HP=SM.extend({method:Z(`notifications/roots/list_changed`),params:xM.optional()});HA([YM,GM,LP,uP,HN,zN,SN,wN,ON,MN,PN,oP,nP,sN,lN,uN,fN]),HA([IM,QM,JM,HP,oN]),HA([PM,xP,SP,NP,VP,cN,dN,iN]),HA([YM,bP,AP,BP,sN,lN,uN,fN]),HA([IM,QM,fP,IN,AN,sP,QN,oN,MP]),HA([PM,qM,RP,ZN,BN,CN,TN,kN,iP,rP,cN,dN,iN]);var UP=class e extends Error{constructor(e,t,n){super(`MCP error ${e}: ${t}`),this.code=e,this.data=n,this.name=`McpError`}static fromError(t,n,r){if(t===jM.UrlElicitationRequired&&r){let e=r;if(e.elicitations)return new WP(e.elicitations,n)}return new e(t,n,r)}},WP=class extends UP{constructor(e,t=`URL elicitation${e.length>1?`s`:``} required`){super(jM.UrlElicitationRequired,t,{elicitations:e})}get elicitations(){return this.data?.elicitations??[]}};Tk(),TT(),EE(),zw(),KT(),aA(),jT(),oA(),yO();function GP(e){return!!e._zod}function KP(e,t){return GP(e)?FT(e,t):e.safeParse(t)}function qP(e){if(!e)return;let t;if(t=GP(e)?e._zod?.def?.shape:e.shape,t){if(typeof t==`function`)try{return t()}catch{return}return t}}function JP(e){if(GP(e)){let t=e._zod?.def;if(t){if(t.value!==void 0)return t.value;if(Array.isArray(t.values)&&t.values.length>0)return t.values[0]}}let t=e._def;if(t){if(t.value!==void 0)return t.value;if(Array.isArray(t.values)&&t.values.length>0)return t.values[0]}let n=e.value;if(n!==void 0)return n}function YP(e){return e===`completed`||e===`failed`||e===`cancelled`}function XP(e){let t=qP(e)?.method;if(!t)throw Error(`Schema is missing a method literal`);let n=JP(t);if(typeof n!=`string`)throw Error(`Schema method literal must be a string`);return n}function ZP(e,t){let n=KP(e,t);if(!n.success)throw n.error;return n.data}var QP=class{constructor(e){this._options=e,this._requestMessageId=0,this._requestHandlers=new Map,this._requestHandlerAbortControllers=new Map,this._notificationHandlers=new Map,this._responseHandlers=new Map,this._progressHandlers=new Map,this._timeoutInfo=new Map,this._pendingDebouncedNotifications=new Set,this._taskProgressTokens=new Map,this._requestResolvers=new Map,this.setNotificationHandler(IM,e=>{this._oncancel(e)}),this.setNotificationHandler(QM,e=>{this._onprogress(e)}),this.setRequestHandler(YM,e=>({})),this._taskStore=e?.taskStore,this._taskMessageQueue=e?.taskMessageQueue,this._taskStore&&(this.setRequestHandler(sN,async(e,t)=>{let n=await this._taskStore.getTask(e.params.taskId,t.sessionId);if(!n)throw new UP(jM.InvalidParams,`Failed to retrieve task: Task not found`);return{...n}}),this.setRequestHandler(lN,async(e,t)=>{let n=async()=>{let r=e.params.taskId;if(this._taskMessageQueue){let e;for(;e=await this._taskMessageQueue.dequeue(r,t.sessionId);){if(e.type===`response`||e.type===`error`){let t=e.message,n=t.id,r=this._requestResolvers.get(n);if(r)if(this._requestResolvers.delete(n),e.type===`response`)r(t);else{let e=t;r(new UP(e.error.code,e.error.message,e.error.data))}else{let t=e.type===`response`?`Response`:`Error`;this._onerror(Error(`${t} handler missing for request ${n}`))}continue}await this._transport?.send(e.message,{relatedRequestId:t.requestId})}}let i=await this._taskStore.getTask(r,t.sessionId);if(!i)throw new UP(jM.InvalidParams,`Task not found: ${r}`);if(!YP(i.status))return await this._waitForTaskUpdate(r,t.signal),await n();if(YP(i.status)){let e=await this._taskStore.getTaskResult(r,t.sessionId);return this._clearTaskQueue(r),{...e,_meta:{...e._meta,[uM]:{taskId:r}}}}return await n()};return await n()}),this.setRequestHandler(uN,async(e,t)=>{try{let{tasks:n,nextCursor:r}=await this._taskStore.listTasks(e.params?.cursor,t.sessionId);return{tasks:n,nextCursor:r,_meta:{}}}catch(e){throw new UP(jM.InvalidParams,`Failed to list tasks: ${e instanceof Error?e.message:String(e)}`)}}),this.setRequestHandler(fN,async(e,t)=>{try{let n=await this._taskStore.getTask(e.params.taskId,t.sessionId);if(!n)throw new UP(jM.InvalidParams,`Task not found: ${e.params.taskId}`);if(YP(n.status))throw new UP(jM.InvalidParams,`Cannot cancel task in terminal status: ${n.status}`);await this._taskStore.updateTaskStatus(e.params.taskId,`cancelled`,`Client cancelled task execution.`,t.sessionId),this._clearTaskQueue(e.params.taskId);let r=await this._taskStore.getTask(e.params.taskId,t.sessionId);if(!r)throw new UP(jM.InvalidParams,`Task not found after cancellation: ${e.params.taskId}`);return{_meta:{},...r}}catch(e){throw e instanceof UP?e:new UP(jM.InvalidRequest,`Failed to cancel task: ${e instanceof Error?e.message:String(e)}`)}}))}async _oncancel(e){e.params.requestId&&this._requestHandlerAbortControllers.get(e.params.requestId)?.abort(e.params.reason)}_setupTimeout(e,t,n,r,i=!1){this._timeoutInfo.set(e,{timeoutId:setTimeout(r,t),startTime:Date.now(),timeout:t,maxTotalTimeout:n,resetTimeoutOnProgress:i,onTimeout:r})}_resetTimeout(e){let t=this._timeoutInfo.get(e);if(!t)return!1;let n=Date.now()-t.startTime;if(t.maxTotalTimeout&&n>=t.maxTotalTimeout)throw this._timeoutInfo.delete(e),UP.fromError(jM.RequestTimeout,`Maximum total timeout exceeded`,{maxTotalTimeout:t.maxTotalTimeout,totalElapsed:n});return clearTimeout(t.timeoutId),t.timeoutId=setTimeout(t.onTimeout,t.timeout),!0}_cleanupTimeout(e){let t=this._timeoutInfo.get(e);t&&(clearTimeout(t.timeoutId),this._timeoutInfo.delete(e))}async connect(e){if(this._transport)throw Error(`Already connected to a transport. Call close() before connecting to a new transport, or use a separate Protocol instance per connection.`);this._transport=e;let t=this.transport?.onclose;this._transport.onclose=()=>{t?.(),this._onclose()};let n=this.transport?.onerror;this._transport.onerror=e=>{n?.(e),this._onerror(e)};let r=this._transport?.onmessage;this._transport.onmessage=(e,t)=>{r?.(e,t),AM(e)||NM(e)?this._onresponse(e):EM(e)?this._onrequest(e,t):OM(e)?this._onnotification(e):this._onerror(Error(`Unknown message type: ${JSON.stringify(e)}`))},await this._transport.start()}_onclose(){let e=this._responseHandlers;this._responseHandlers=new Map,this._progressHandlers.clear(),this._taskProgressTokens.clear(),this._pendingDebouncedNotifications.clear();for(let e of this._timeoutInfo.values())clearTimeout(e.timeoutId);this._timeoutInfo.clear();for(let e of this._requestHandlerAbortControllers.values())e.abort();this._requestHandlerAbortControllers.clear();let t=UP.fromError(jM.ConnectionClosed,`Connection closed`);this._transport=void 0,this.onclose?.();for(let n of e.values())n(t)}_onerror(e){this.onerror?.(e)}_onnotification(e){let t=this._notificationHandlers.get(e.method)??this.fallbackNotificationHandler;t!==void 0&&Promise.resolve().then(()=>t(e)).catch(e=>this._onerror(Error(`Uncaught error in notification handler: ${e}`)))}_onrequest(e,t){let n=this._requestHandlers.get(e.method)??this.fallbackRequestHandler,r=this._transport,i=e.params?._meta?.[uM]?.taskId;if(n===void 0){let t={jsonrpc:`2.0`,id:e.id,error:{code:jM.MethodNotFound,message:`Method not found`}};i&&this._taskMessageQueue?this._enqueueTaskMessage(i,{type:`error`,message:t,timestamp:Date.now()},r?.sessionId).catch(e=>this._onerror(Error(`Failed to enqueue error response: ${e}`))):r?.send(t).catch(e=>this._onerror(Error(`Failed to send an error response: ${e}`)));return}let a=new AbortController;this._requestHandlerAbortControllers.set(e.id,a);let o=yM(e.params)?e.params.task:void 0,s=this._taskStore?this.requestTaskStore(e,r?.sessionId):void 0,c={signal:a.signal,sessionId:r?.sessionId,_meta:e.params?._meta,sendNotification:async t=>{if(a.signal.aborted)return;let n={relatedRequestId:e.id};i&&(n.relatedTask={taskId:i}),await this.notification(t,n)},sendRequest:async(t,n,r)=>{if(a.signal.aborted)throw new UP(jM.ConnectionClosed,`Request was cancelled`);let o={...r,relatedRequestId:e.id};i&&!o.relatedTask&&(o.relatedTask={taskId:i});let c=o.relatedTask?.taskId??i;return c&&s&&await s.updateTaskStatus(c,`input_required`),await this.request(t,n,o)},authInfo:t?.authInfo,requestId:e.id,requestInfo:t?.requestInfo,taskId:i,taskStore:s,taskRequestedTtl:o?.ttl,closeSSEStream:t?.closeSSEStream,closeStandaloneSSEStream:t?.closeStandaloneSSEStream};Promise.resolve().then(()=>{o&&this.assertTaskHandlerCapability(e.method)}).then(()=>n(e,c)).then(async t=>{if(a.signal.aborted)return;let n={result:t,jsonrpc:`2.0`,id:e.id};i&&this._taskMessageQueue?await this._enqueueTaskMessage(i,{type:`response`,message:n,timestamp:Date.now()},r?.sessionId):await r?.send(n)},async t=>{if(a.signal.aborted)return;let n={jsonrpc:`2.0`,id:e.id,error:{code:Number.isSafeInteger(t.code)?t.code:jM.InternalError,message:t.message??`Internal error`,...t.data!==void 0&&{data:t.data}}};i&&this._taskMessageQueue?await this._enqueueTaskMessage(i,{type:`error`,message:n,timestamp:Date.now()},r?.sessionId):await r?.send(n)}).catch(e=>this._onerror(Error(`Failed to send response: ${e}`))).finally(()=>{this._requestHandlerAbortControllers.get(e.id)===a&&this._requestHandlerAbortControllers.delete(e.id)})}_onprogress(e){let{progressToken:t,...n}=e.params,r=Number(t),i=this._progressHandlers.get(r);if(!i){this._onerror(Error(`Received a progress notification for an unknown token: ${JSON.stringify(e)}`));return}let a=this._responseHandlers.get(r),o=this._timeoutInfo.get(r);if(o&&a&&o.resetTimeoutOnProgress)try{this._resetTimeout(r)}catch(e){this._responseHandlers.delete(r),this._progressHandlers.delete(r),this._cleanupTimeout(r),a(e);return}i(n)}_onresponse(e){let t=Number(e.id),n=this._requestResolvers.get(t);if(n){this._requestResolvers.delete(t),AM(e)?n(e):n(new UP(e.error.code,e.error.message,e.error.data));return}let r=this._responseHandlers.get(t);if(r===void 0){this._onerror(Error(`Received a response for an unknown message ID: ${JSON.stringify(e)}`));return}this._responseHandlers.delete(t),this._cleanupTimeout(t);let i=!1;if(AM(e)&&e.result&&typeof e.result==`object`){let n=e.result;if(n.task&&typeof n.task==`object`){let e=n.task;typeof e.taskId==`string`&&(i=!0,this._taskProgressTokens.set(e.taskId,t))}}i||this._progressHandlers.delete(t),AM(e)?r(e):r(UP.fromError(e.error.code,e.error.message,e.error.data))}get transport(){return this._transport}async close(){await this._transport?.close()}async*requestStream(e,t,n){let{task:r}=n??{};if(!r){try{yield{type:`result`,result:await this.request(e,t,n)}}catch(e){yield{type:`error`,error:e instanceof UP?e:new UP(jM.InternalError,String(e))}}return}let i;try{let r=await this.request(e,iN,n);if(r.task)i=r.task.taskId,yield{type:`taskCreated`,task:r.task};else throw new UP(jM.InternalError,`Task creation did not return a task`);for(;;){let e=await this.getTask({taskId:i},n);if(yield{type:`taskStatus`,task:e},YP(e.status)){e.status===`completed`?yield{type:`result`,result:await this.getTaskResult({taskId:i},t,n)}:e.status===`failed`?yield{type:`error`,error:new UP(jM.InternalError,`Task ${i} failed`)}:e.status===`cancelled`&&(yield{type:`error`,error:new UP(jM.InternalError,`Task ${i} was cancelled`)});return}if(e.status===`input_required`){yield{type:`result`,result:await this.getTaskResult({taskId:i},t,n)};return}let r=e.pollInterval??this._options?.defaultTaskPollInterval??1e3;await new Promise(e=>setTimeout(e,r)),n?.signal?.throwIfAborted()}}catch(e){yield{type:`error`,error:e instanceof UP?e:new UP(jM.InternalError,String(e))}}}request(e,t,n){let{relatedRequestId:r,resumptionToken:i,onresumptiontoken:a,task:o,relatedTask:s}=n??{};return new Promise((c,l)=>{let u=e=>{l(e)};if(!this._transport){u(Error(`Not connected`));return}if(this._options?.enforceStrictCapabilities===!0)try{this.assertCapabilityForMethod(e.method),o&&this.assertTaskCapability(e.method)}catch(e){u(e);return}n?.signal?.throwIfAborted();let d=this._requestMessageId++,f={...e,jsonrpc:`2.0`,id:d};n?.onprogress&&(this._progressHandlers.set(d,n.onprogress),f.params={...e.params,_meta:{...e.params?._meta||{},progressToken:d}}),o&&(f.params={...f.params,task:o}),s&&(f.params={...f.params,_meta:{...f.params?._meta||{},[uM]:s}});let p=e=>{this._responseHandlers.delete(d),this._progressHandlers.delete(d),this._cleanupTimeout(d),this._transport?.send({jsonrpc:`2.0`,method:`notifications/cancelled`,params:{requestId:d,reason:String(e)}},{relatedRequestId:r,resumptionToken:i,onresumptiontoken:a}).catch(e=>this._onerror(Error(`Failed to send cancellation: ${e}`))),l(e instanceof UP?e:new UP(jM.RequestTimeout,String(e)))};this._responseHandlers.set(d,e=>{if(!n?.signal?.aborted){if(e instanceof Error)return l(e);try{let n=KP(t,e.result);n.success?c(n.data):l(n.error)}catch(e){l(e)}}}),n?.signal?.addEventListener(`abort`,()=>{p(n?.signal?.reason)});let m=n?.timeout??6e4;this._setupTimeout(d,m,n?.maxTotalTimeout,()=>p(UP.fromError(jM.RequestTimeout,`Request timed out`,{timeout:m})),n?.resetTimeoutOnProgress??!1);let h=s?.taskId;h?(this._requestResolvers.set(d,e=>{let t=this._responseHandlers.get(d);t?t(e):this._onerror(Error(`Response handler missing for side-channeled request ${d}`))}),this._enqueueTaskMessage(h,{type:`request`,message:f,timestamp:Date.now()}).catch(e=>{this._cleanupTimeout(d),l(e)})):this._transport.send(f,{relatedRequestId:r,resumptionToken:i,onresumptiontoken:a}).catch(e=>{this._cleanupTimeout(d),l(e)})})}async getTask(e,t){return this.request({method:`tasks/get`,params:e},cN,t)}async getTaskResult(e,t,n){return this.request({method:`tasks/result`,params:e},t,n)}async listTasks(e,t){return this.request({method:`tasks/list`,params:e},dN,t)}async cancelTask(e,t){return this.request({method:`tasks/cancel`,params:e},pN,t)}async notification(e,t){if(!this._transport)throw Error(`Not connected`);this.assertNotificationCapability(e.method);let n=t?.relatedTask?.taskId;if(n){let r={...e,jsonrpc:`2.0`,params:{...e.params,_meta:{...e.params?._meta||{},[uM]:t.relatedTask}}};await this._enqueueTaskMessage(n,{type:`notification`,message:r,timestamp:Date.now()});return}if((this._options?.debouncedNotificationMethods??[]).includes(e.method)&&!e.params&&!t?.relatedRequestId&&!t?.relatedTask){if(this._pendingDebouncedNotifications.has(e.method))return;this._pendingDebouncedNotifications.add(e.method),Promise.resolve().then(()=>{if(this._pendingDebouncedNotifications.delete(e.method),!this._transport)return;let n={...e,jsonrpc:`2.0`};t?.relatedTask&&(n={...n,params:{...n.params,_meta:{...n.params?._meta||{},[uM]:t.relatedTask}}}),this._transport?.send(n,t).catch(e=>this._onerror(e))});return}let r={...e,jsonrpc:`2.0`};t?.relatedTask&&(r={...r,params:{...r.params,_meta:{...r.params?._meta||{},[uM]:t.relatedTask}}}),await this._transport.send(r,t)}setRequestHandler(e,t){let n=XP(e);this.assertRequestHandlerCapability(n),this._requestHandlers.set(n,(n,r)=>{let i=ZP(e,n);return Promise.resolve(t(i,r))})}removeRequestHandler(e){this._requestHandlers.delete(e)}assertCanSetRequestHandler(e){if(this._requestHandlers.has(e))throw Error(`A request handler for ${e} already exists, which would be overridden`)}setNotificationHandler(e,t){let n=XP(e);this._notificationHandlers.set(n,n=>{let r=ZP(e,n);return Promise.resolve(t(r))})}removeNotificationHandler(e){this._notificationHandlers.delete(e)}_cleanupTaskProgressHandler(e){let t=this._taskProgressTokens.get(e);t!==void 0&&(this._progressHandlers.delete(t),this._taskProgressTokens.delete(e))}async _enqueueTaskMessage(e,t,n){if(!this._taskStore||!this._taskMessageQueue)throw Error(`Cannot enqueue task message: taskStore and taskMessageQueue are not configured`);let r=this._options?.maxTaskQueueSize;await this._taskMessageQueue.enqueue(e,t,n,r)}async _clearTaskQueue(e,t){if(this._taskMessageQueue){let n=await this._taskMessageQueue.dequeueAll(e,t);for(let t of n)if(t.type===`request`&&EM(t.message)){let n=t.message.id,r=this._requestResolvers.get(n);r?(r(new UP(jM.InternalError,`Task cancelled or completed`)),this._requestResolvers.delete(n)):this._onerror(Error(`Resolver missing for request ${n} during task ${e} cleanup`))}}}async _waitForTaskUpdate(e,t){let n=this._options?.defaultTaskPollInterval??1e3;try{let t=await this._taskStore?.getTask(e);t?.pollInterval&&(n=t.pollInterval)}catch{}return new Promise((e,r)=>{if(t.aborted){r(new UP(jM.InvalidRequest,`Request cancelled`));return}let i=setTimeout(e,n);t.addEventListener(`abort`,()=>{clearTimeout(i),r(new UP(jM.InvalidRequest,`Request cancelled`))},{once:!0})})}requestTaskStore(e,t){let n=this._taskStore;if(!n)throw Error(`No task store configured`);return{createTask:async r=>{if(!e)throw Error(`No request provided`);return await n.createTask(r,e.id,{method:e.method,params:e.params},t)},getTask:async e=>{let r=await n.getTask(e,t);if(!r)throw new UP(jM.InvalidParams,`Failed to retrieve task: Task not found`);return r},storeTaskResult:async(e,r,i)=>{await n.storeTaskResult(e,r,i,t);let a=await n.getTask(e,t);if(a){let t=oN.parse({method:`notifications/tasks/status`,params:a});await this.notification(t),YP(a.status)&&this._cleanupTaskProgressHandler(e)}},getTaskResult:e=>n.getTaskResult(e,t),updateTaskStatus:async(e,r,i)=>{let a=await n.getTask(e,t);if(!a)throw new UP(jM.InvalidParams,`Task "${e}" not found - it may have been cleaned up`);if(YP(a.status))throw new UP(jM.InvalidParams,`Cannot update task "${e}" from terminal status "${a.status}" to "${r}". Terminal states (completed, failed, cancelled) cannot transition to other states.`);await n.updateTaskStatus(e,r,i,t);let o=await n.getTask(e,t);if(o){let t=oN.parse({method:`notifications/tasks/status`,params:o});await this.notification(t),YP(o.status)&&this._cleanupTaskProgressHandler(e)}},listTasks:e=>n.listTasks(e,t)}}};lM(),(e=>typeof require<`u`?require:typeof Proxy<`u`?new Proxy(e,{get:(e,t)=>(typeof require<`u`?require:e)[t]}):e)(function(e){if(typeof require<`u`)return require.apply(this,arguments);throw Error(`Dynamic require of "`+e+`" is not supported`)});var $P=class extends QP{_registeredMethods=new Set;_eventSlots=new Map;onEventDispatch(e,t){}_ensureEventSlot(e){let t=this._eventSlots.get(e);if(!t){let n=this.eventSchemas[e];if(!n)throw Error(`Unknown event: ${String(e)}`);t={listeners:[]},this._eventSlots.set(e,t);let r=n.shape.method.value;this._registeredMethods.add(r);let i=t;super.setNotificationHandler(n,t=>{let n=t.params;this.onEventDispatch(e,n),i.onHandler?.(n);for(let e of[...i.listeners])e(n)})}return t}setEventHandler(e,t){let n=this._ensureEventSlot(e);n.onHandler&&t&&console.warn(`[MCP Apps] on${String(e)} handler replaced. Use addEventListener("${String(e)}", …) to add multiple listeners without replacing.`),n.onHandler=t}getEventHandler(e){return this._eventSlots.get(e)?.onHandler}addEventListener(e,t){this._ensureEventSlot(e).listeners.push(t)}removeEventListener(e,t){let n=this._eventSlots.get(e);if(!n)return;let r=n.listeners.indexOf(t);r!==-1&&n.listeners.splice(r,1)}setRequestHandler=(e,t)=>{this._assertMethodNotRegistered(e,`setRequestHandler`),super.setRequestHandler(e,t)};setNotificationHandler=(e,t)=>{this._assertMethodNotRegistered(e,`setNotificationHandler`),super.setNotificationHandler(e,t)};warnIfRequestHandlerReplaced(e,t,n){t&&n&&console.warn(`[MCP Apps] ${e} handler replaced. Previous handler will no longer be called.`)}replaceRequestHandler=(e,t)=>{let n=e.shape.method.value;this._registeredMethods.add(n),super.setRequestHandler(e,t)};_assertMethodNotRegistered(e,t){let n=e.shape.method.value;if(this._registeredMethods.has(n))throw Error(`Handler for "${n}" already registered (via ${t}). Use addEventListener() to attach multiple listeners, or the on* setter for replace semantics.`);this._registeredMethods.add(n)}},eF=`2026-01-26`,tF=HA([Z(`light`),Z(`dark`)]).describe(`Color theme preference for the host environment.`),nF=HA([Z(`inline`),Z(`fullscreen`),Z(`pip`)]).describe(`Display mode for UI presentation.`),rF=GA(HA([Z(`--color-background-primary`),Z(`--color-background-secondary`),Z(`--color-background-tertiary`),Z(`--color-background-inverse`),Z(`--color-background-ghost`),Z(`--color-background-info`),Z(`--color-background-danger`),Z(`--color-background-success`),Z(`--color-background-warning`),Z(`--color-background-disabled`),Z(`--color-text-primary`),Z(`--color-text-secondary`),Z(`--color-text-tertiary`),Z(`--color-text-inverse`),Z(`--color-text-ghost`),Z(`--color-text-info`),Z(`--color-text-danger`),Z(`--color-text-success`),Z(`--color-text-warning`),Z(`--color-text-disabled`),Z(`--color-border-primary`),Z(`--color-border-secondary`),Z(`--color-border-tertiary`),Z(`--color-border-inverse`),Z(`--color-border-ghost`),Z(`--color-border-info`),Z(`--color-border-danger`),Z(`--color-border-success`),Z(`--color-border-warning`),Z(`--color-border-disabled`),Z(`--color-ring-primary`),Z(`--color-ring-secondary`),Z(`--color-ring-inverse`),Z(`--color-ring-info`),Z(`--color-ring-danger`),Z(`--color-ring-success`),Z(`--color-ring-warning`),Z(`--font-sans`),Z(`--font-mono`),Z(`--font-weight-normal`),Z(`--font-weight-medium`),Z(`--font-weight-semibold`),Z(`--font-weight-bold`),Z(`--font-text-xs-size`),Z(`--font-text-sm-size`),Z(`--font-text-md-size`),Z(`--font-text-lg-size`),Z(`--font-heading-xs-size`),Z(`--font-heading-sm-size`),Z(`--font-heading-md-size`),Z(`--font-heading-lg-size`),Z(`--font-heading-xl-size`),Z(`--font-heading-2xl-size`),Z(`--font-heading-3xl-size`),Z(`--font-text-xs-line-height`),Z(`--font-text-sm-line-height`),Z(`--font-text-md-line-height`),Z(`--font-text-lg-line-height`),Z(`--font-heading-xs-line-height`),Z(`--font-heading-sm-line-height`),Z(`--font-heading-md-line-height`),Z(`--font-heading-lg-line-height`),Z(`--font-heading-xl-line-height`),Z(`--font-heading-2xl-line-height`),Z(`--font-heading-3xl-line-height`),Z(`--border-radius-xs`),Z(`--border-radius-sm`),Z(`--border-radius-md`),Z(`--border-radius-lg`),Z(`--border-radius-xl`),Z(`--border-radius-full`),Z(`--border-width-regular`),Z(`--shadow-hairline`),Z(`--shadow-sm`),Z(`--shadow-md`),Z(`--shadow-lg`)]).describe(`CSS variable keys available to MCP apps for theming.`).describe(`Style variables for theming MCP apps.
119
119
 
120
120
  Individual style keys are optional - hosts may provide any subset of these values.
121
121
  Values are strings containing CSS values (colors, sizes, font stacks, etc.).
122
122
 
123
123
  Note: This type uses \`Record<K, string | undefined>\` rather than \`Partial<Record<K, string>>\`
124
- for compatibility with Zod schema generation. Both are functionally equivalent for validation.`),BA([J(),FA()]).describe(`Style variables for theming MCP apps.
124
+ for compatibility with Zod schema generation. Both are functionally equivalent for validation.`),HA([J(),LA()]).describe(`Style variables for theming MCP apps.
125
125
 
126
126
  Individual style keys are optional - hosts may provide any subset of these values.
127
127
  Values are strings containing CSS values (colors, sizes, font stacks, etc.).
@@ -133,10 +133,10 @@ Individual style keys are optional - hosts may provide any subset of these value
133
133
  Values are strings containing CSS values (colors, sizes, font stacks, etc.).
134
134
 
135
135
  Note: This type uses \`Record<K, string | undefined>\` rather than \`Partial<Record<K, string>>\`
136
- for compatibility with Zod schema generation. Both are functionally equivalent for validation.`),nF=X({method:Z(`ui/open-link`),params:X({url:J().describe(`URL to open in the host's browser`)})});X({isError:PA().optional().describe(`True if the host failed to open the URL (e.g., due to security policy).`)}).passthrough(),X({isError:PA().optional().describe(`True if the download failed (e.g., user cancelled or host denied).`)}).passthrough(),X({isError:PA().optional().describe(`True if the host rejected or failed to deliver the message.`)}).passthrough();var rF=X({method:Z(`ui/notifications/sandbox-proxy-ready`),params:X({})}),iF=X({connectDomains:Y(J()).optional().describe(`Origins for network requests (fetch/XHR/WebSocket).
136
+ for compatibility with Zod schema generation. Both are functionally equivalent for validation.`),iF=X({method:Z(`ui/open-link`),params:X({url:J().describe(`URL to open in the host's browser`)})});X({isError:IA().optional().describe(`True if the host failed to open the URL (e.g., due to security policy).`)}).passthrough(),X({isError:IA().optional().describe(`True if the download failed (e.g., user cancelled or host denied).`)}).passthrough(),X({isError:IA().optional().describe(`True if the host rejected or failed to deliver the message.`)}).passthrough();var aF=X({method:Z(`ui/notifications/sandbox-proxy-ready`),params:X({})}),oF=X({connectDomains:Y(J()).optional().describe(`Origins for network requests (fetch/XHR/WebSocket).
137
137
 
138
138
  - Maps to CSP \`connect-src\` directive
139
- - Empty or omitted → no network connections (secure default)`),resourceDomains:Y(J()).optional().describe("Origins for static resources (images, scripts, stylesheets, fonts, media).\n\n- Maps to CSP `img-src`, `script-src`, `style-src`, `font-src`, `media-src` directives\n- Wildcard subdomains supported: `https://*.example.com`\n- Empty or omitted → no network resources (secure default)"),frameDomains:Y(J()).optional().describe("Origins for nested iframes.\n\n- Maps to CSP `frame-src` directive\n- Empty or omitted → no nested iframes allowed (`frame-src 'none'`)"),baseUriDomains:Y(J()).optional().describe("Allowed base URIs for the document.\n\n- Maps to CSP `base-uri` directive\n- Empty or omitted → only same origin allowed (`base-uri 'self'`)")}),aF=X({camera:X({}).optional().describe(`Request camera access.
139
+ - Empty or omitted → no network connections (secure default)`),resourceDomains:Y(J()).optional().describe("Origins for static resources (images, scripts, stylesheets, fonts, media).\n\n- Maps to CSP `img-src`, `script-src`, `style-src`, `font-src`, `media-src` directives\n- Wildcard subdomains supported: `https://*.example.com`\n- Empty or omitted → no network resources (secure default)"),frameDomains:Y(J()).optional().describe("Origins for nested iframes.\n\n- Maps to CSP `frame-src` directive\n- Empty or omitted → no nested iframes allowed (`frame-src 'none'`)"),baseUriDomains:Y(J()).optional().describe("Allowed base URIs for the document.\n\n- Maps to CSP `base-uri` directive\n- Empty or omitted → only same origin allowed (`base-uri 'self'`)")}),sF=X({camera:X({}).optional().describe(`Request camera access.
140
140
 
141
141
  Maps to Permission Policy \`camera\` feature.`),microphone:X({}).optional().describe(`Request microphone access.
142
142
 
@@ -144,7 +144,7 @@ Maps to Permission Policy \`microphone\` feature.`),geolocation:X({}).optional()
144
144
 
145
145
  Maps to Permission Policy \`geolocation\` feature.`),clipboardWrite:X({}).optional().describe(`Request clipboard write access.
146
146
 
147
- Maps to Permission Policy \`clipboard-write\` feature.`)}),oF=X({method:Z(`ui/notifications/size-changed`),params:X({width:MA().optional().describe(`New width in pixels.`),height:MA().optional().describe(`New height in pixels.`)})});X({method:Z(`ui/notifications/tool-input`),params:X({arguments:UA(J(),LA().describe(`Complete tool call arguments as key-value pairs.`)).optional().describe(`Complete tool call arguments as key-value pairs.`)})}),X({method:Z(`ui/notifications/tool-input-partial`),params:X({arguments:UA(J(),LA().describe(`Partial tool call arguments (incomplete, may change).`)).optional().describe(`Partial tool call arguments (incomplete, may change).`)})}),X({method:Z(`ui/notifications/tool-cancelled`),params:X({reason:J().optional().describe(`Optional reason for the cancellation (e.g., "user action", "timeout").`)})});var sF=X({fonts:J().optional()}),cF=X({variables:tF.optional().describe(`CSS variables for theming the app.`),css:sF.optional().describe(`CSS blocks that apps can inject.`)});X({method:Z(`ui/resource-teardown`),params:X({})});var lF=UA(J(),LA()),uF=X({text:X({}).optional().describe(`Host supports text content blocks.`),image:X({}).optional().describe(`Host supports image content blocks.`),audio:X({}).optional().describe(`Host supports audio content blocks.`),resource:X({}).optional().describe(`Host supports resource content blocks.`),resourceLink:X({}).optional().describe(`Host supports resource link content blocks.`),structuredContent:X({}).optional().describe(`Host supports structured content.`)}),dF=X({method:Z(`ui/notifications/request-teardown`),params:X({}).optional()}),fF=X({experimental:X({}).optional().describe(`Experimental features (structure TBD).`),openLinks:X({}).optional().describe(`Host supports opening external URLs.`),downloadFile:X({}).optional().describe(`Host supports file downloads via ui/download-file.`),serverTools:X({listChanged:PA().optional().describe(`Host supports tools/list_changed notifications.`)}).optional().describe(`Host can proxy tool calls to the MCP server.`),serverResources:X({listChanged:PA().optional().describe(`Host supports resources/list_changed notifications.`)}).optional().describe(`Host can proxy resource reads to the MCP server.`),logging:X({}).optional().describe(`Host accepts log messages.`),sandbox:X({permissions:aF.optional().describe(`Permissions granted by the host (camera, microphone, geolocation).`),csp:iF.optional().describe(`CSP domains approved by the host.`)}).optional().describe(`Sandbox configuration applied by the host.`),updateModelContext:uF.optional().describe(`Host accepts context updates (ui/update-model-context) to be included in the model's context for future turns.`),message:uF.optional().describe(`Host supports receiving content messages (ui/message) from the view.`),sampling:X({tools:X({}).optional().describe("Host supports tool use via `tools` and `toolChoice` parameters.")}).optional().describe("Host supports LLM sampling (sampling/createMessage) from the view.\nMirrors the MCP `ClientCapabilities.sampling` shape so hosts can pass it through.")}),pF=X({experimental:X({}).optional().describe(`Experimental features (structure TBD).`),tools:X({listChanged:PA().optional().describe(`App supports tools/list_changed notifications.`)}).optional().describe(`App exposes MCP-style tools that the host can call.`),availableDisplayModes:Y(eF).optional().describe(`Display modes the app supports.`)}),mF=X({method:Z(`ui/notifications/initialized`),params:X({}).optional()});X({csp:iF.optional().describe(`Content Security Policy configuration for UI resources.`),permissions:aF.optional().describe(`Sandbox permissions requested by the UI resource.`),domain:J().optional().describe(`Dedicated origin for view sandbox.
147
+ Maps to Permission Policy \`clipboard-write\` feature.`)}),cF=X({method:Z(`ui/notifications/size-changed`),params:X({width:PA().optional().describe(`New width in pixels.`),height:PA().optional().describe(`New height in pixels.`)})});X({method:Z(`ui/notifications/tool-input`),params:X({arguments:GA(J(),zA().describe(`Complete tool call arguments as key-value pairs.`)).optional().describe(`Complete tool call arguments as key-value pairs.`)})}),X({method:Z(`ui/notifications/tool-input-partial`),params:X({arguments:GA(J(),zA().describe(`Partial tool call arguments (incomplete, may change).`)).optional().describe(`Partial tool call arguments (incomplete, may change).`)})}),X({method:Z(`ui/notifications/tool-cancelled`),params:X({reason:J().optional().describe(`Optional reason for the cancellation (e.g., "user action", "timeout").`)})});var lF=X({fonts:J().optional()}),uF=X({variables:rF.optional().describe(`CSS variables for theming the app.`),css:lF.optional().describe(`CSS blocks that apps can inject.`)});X({method:Z(`ui/resource-teardown`),params:X({})});var dF=GA(J(),zA()),fF=X({text:X({}).optional().describe(`Host supports text content blocks.`),image:X({}).optional().describe(`Host supports image content blocks.`),audio:X({}).optional().describe(`Host supports audio content blocks.`),resource:X({}).optional().describe(`Host supports resource content blocks.`),resourceLink:X({}).optional().describe(`Host supports resource link content blocks.`),structuredContent:X({}).optional().describe(`Host supports structured content.`)}),pF=X({method:Z(`ui/notifications/request-teardown`),params:X({}).optional()}),mF=X({experimental:X({}).optional().describe(`Experimental features (structure TBD).`),openLinks:X({}).optional().describe(`Host supports opening external URLs.`),downloadFile:X({}).optional().describe(`Host supports file downloads via ui/download-file.`),serverTools:X({listChanged:IA().optional().describe(`Host supports tools/list_changed notifications.`)}).optional().describe(`Host can proxy tool calls to the MCP server.`),serverResources:X({listChanged:IA().optional().describe(`Host supports resources/list_changed notifications.`)}).optional().describe(`Host can proxy resource reads to the MCP server.`),logging:X({}).optional().describe(`Host accepts log messages.`),sandbox:X({permissions:sF.optional().describe(`Permissions granted by the host (camera, microphone, geolocation).`),csp:oF.optional().describe(`CSP domains approved by the host.`)}).optional().describe(`Sandbox configuration applied by the host.`),updateModelContext:fF.optional().describe(`Host accepts context updates (ui/update-model-context) to be included in the model's context for future turns.`),message:fF.optional().describe(`Host supports receiving content messages (ui/message) from the view.`),sampling:X({tools:X({}).optional().describe("Host supports tool use via `tools` and `toolChoice` parameters.")}).optional().describe("Host supports LLM sampling (sampling/createMessage) from the view.\nMirrors the MCP `ClientCapabilities.sampling` shape so hosts can pass it through.")}),hF=X({experimental:X({}).optional().describe(`Experimental features (structure TBD).`),tools:X({listChanged:IA().optional().describe(`App supports tools/list_changed notifications.`)}).optional().describe(`App exposes MCP-style tools that the host can call.`),availableDisplayModes:Y(nF).optional().describe(`Display modes the app supports.`)}),gF=X({method:Z(`ui/notifications/initialized`),params:X({}).optional()});X({csp:oF.optional().describe(`Content Security Policy configuration for UI resources.`),permissions:sF.optional().describe(`Sandbox permissions requested by the UI resource.`),domain:J().optional().describe(`Dedicated origin for view sandbox.
148
148
 
149
149
  Useful when views need stable, dedicated origins for OAuth callbacks, CORS policies, or API key allowlists.
150
150
 
@@ -152,16 +152,16 @@ Useful when views need stable, dedicated origins for OAuth callbacks, CORS polic
152
152
  - Hash-based subdomains (e.g., \`{hash}.claudemcpcontent.com\`)
153
153
  - URL-derived subdomains (e.g., \`www-example-com.oaiusercontent.com\`)
154
154
 
155
- If omitted, host uses default sandbox origin (typically per-conversation).`),prefersBorder:PA().optional().describe(`Visual boundary preference - true if view prefers a visible border.
155
+ If omitted, host uses default sandbox origin (typically per-conversation).`),prefersBorder:IA().optional().describe(`Visual boundary preference - true if view prefers a visible border.
156
156
 
157
157
  Boolean requesting whether a visible border and background is provided by the host. Specifying an explicit value for this is recommended because hosts' defaults may vary.
158
158
 
159
159
  - \`true\`: request visible border + background
160
160
  - \`false\`: request no visible border + background
161
- - omitted: host decides border`)});var hF=X({method:Z(`ui/request-display-mode`),params:X({mode:eF.describe(`The display mode being requested.`)})});X({mode:eF.describe(`The display mode that was actually set. May differ from requested if not supported.`)}).passthrough();var gF=BA([Z(`model`),Z(`app`)]).describe(`Tool visibility scope - who can access the tool.`);X({resourceUri:J().optional(),visibility:Y(gF).optional().describe(`Who can access this tool. Default: ["model", "app"]
161
+ - omitted: host decides border`)});var _F=X({method:Z(`ui/request-display-mode`),params:X({mode:nF.describe(`The display mode being requested.`)})});X({mode:nF.describe(`The display mode that was actually set. May differ from requested if not supported.`)}).passthrough();var vF=HA([Z(`model`),Z(`app`)]).describe(`Tool visibility scope - who can access the tool.`);X({resourceUri:J().optional(),visibility:Y(vF).optional().describe(`Who can access this tool. Default: ["model", "app"]
162
162
  - "model": Tool visible to and callable by the agent
163
- - "app": Tool callable by the app from this server only`),csp:RA().optional(),permissions:RA().optional()}),X({mimeTypes:Y(J()).optional().describe('Array of supported MIME types for UI resources.\nMust include `"text/html;profile=mcp-app"` for MCP Apps support.')});var _F=X({method:Z(`ui/download-file`),params:X({contents:Y(BA([GN,KN])).describe(`Resource contents to download — embedded (inline data) or linked (host fetches). Uses standard MCP resource types.`)})}),vF=X({method:Z(`ui/message`),params:X({role:Z(`user`).describe(`Message role, currently only "user" is supported.`),content:Y(qN).describe(`Message content blocks (text, image, etc.).`)})});X({method:Z(`ui/notifications/sandbox-resource-ready`),params:X({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:iF.optional().describe(`CSP configuration from resource metadata.`),permissions:aF.optional().describe(`Sandbox permissions from resource metadata.`)})}),X({method:Z(`ui/notifications/tool-result`),params:nP.describe(`Standard MCP tool execution result.`)});var yF=X({toolInfo:X({id:SM.optional().describe(`JSON-RPC id of the tools/call request.`),tool:$N.describe(`Tool definition including name, inputSchema, etc.`)}).optional().describe(`Metadata of the tool call that instantiated this App.`),theme:$P.optional().describe(`Current color theme preference.`),styles:cF.optional().describe(`Style configuration for theming the app.`),displayMode:eF.optional().describe(`How the UI is currently displayed.`),availableDisplayModes:Y(eF).optional().describe(`Display modes the host supports.`),containerDimensions:BA([X({height:MA().describe(`Fixed container height in pixels.`)}),X({maxHeight:BA([MA(),FA()]).optional().describe(`Maximum container height in pixels.`)})]).and(BA([X({width:MA().describe(`Fixed container width in pixels.`)}),X({maxWidth:BA([MA(),FA()]).optional().describe(`Maximum container width in pixels.`)})])).optional().describe(`Container dimensions. Represents the dimensions of the iframe or other
164
- 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:BA([Z(`web`),Z(`desktop`),Z(`mobile`)]).optional().describe(`Platform type for responsive design decisions.`),deviceCapabilities:X({touch:PA().optional().describe(`Whether the device supports touch input.`),hover:PA().optional().describe(`Whether the device supports hover interactions.`)}).optional().describe(`Device input capabilities.`),safeAreaInsets:X({top:MA().describe(`Top safe area inset in pixels.`),right:MA().describe(`Right safe area inset in pixels.`),bottom:MA().describe(`Bottom safe area inset in pixels.`),left:MA().describe(`Left safe area inset in pixels.`)}).optional().describe(`Mobile safe area boundaries in pixels.`)}).passthrough();X({method:Z(`ui/notifications/host-context-changed`),params:yF.describe(`Partial context update containing only changed fields.`)});var bF=X({method:Z(`ui/update-model-context`),params:X({content:Y(qN).optional().describe(`Context content blocks (text, image, etc.).`),structuredContent:UA(J(),LA().describe(`Structured content for machine-readable context data.`)).optional().describe(`Structured content for machine-readable context data.`)})}),xF=X({method:Z(`ui/initialize`),params:X({appInfo:LM.describe(`App identification (name and version).`),appCapabilities:pF.describe(`Features and capabilities this app provides.`),protocolVersion:J().describe(`Protocol version this app supports.`)})});X({protocolVersion:J().describe(`Negotiated protocol version string (e.g., "2025-11-21").`),hostInfo:LM.describe(`Host application identification and version.`),hostCapabilities:fF.describe(`Features and capabilities provided by the host.`),hostContext:yF.describe(`Rich context about the host environment.`)}).passthrough();var SF=[QP],CF=class extends ZP{_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:oF,sandboxready:rF,initialized:mF,requestteardown:dF,loggingmessage:uP};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(xF,e=>this._oninitialize(e)),this.setRequestHandler(qM,(e,t)=>(this.onping?.(e.params,t),{})),this.replaceRequestHandler(hF,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(vF,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(nF,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(_F,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(hF,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(bF,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(iP,async(e,t)=>{if(!this._oncalltool)throw Error(`No oncalltool handler set`);return this._oncalltool(e.params,t)})}set oncreatesamplingmessage(e){this.setRequestHandler(vP,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(bN,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(SN,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(EN,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(LN,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:SF.includes(t)?t:QP,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];wF(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},lF,t)}sendResourceTeardown=this.teardownResource;callTool(e,t){return this.request({method:`tools/call`,params:e},nP,t)}listTools(e,t){return this.request({method:`tools/list`,params:e},tP,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},nP,{signal:t.signal}),e.tools.listChanged&&this._client.setNotificationHandler(aP,e=>this.sendToolListChanged(e.params))),e.resources&&(this.onlistresources=async(e,t)=>this._client.request({method:`resources/list`,params:e},xN,{signal:t.signal}),this.onlistresourcetemplates=async(e,t)=>this._client.request({method:`resources/templates/list`,params:e},CN,{signal:t.signal}),this.onreadresource=async(e,t)=>this._client.request({method:`resources/read`,params:e},DN,{signal:t.signal}),e.resources.listChanged&&this._client.setNotificationHandler(ON,e=>this.sendResourceListChanged(e.params))),e.prompts&&(this.onlistprompts=async(e,t)=>this._client.request({method:`prompts/list`,params:e},RN,{signal:t.signal}),e.prompts.listChanged&&this._client.setNotificationHandler(XN,e=>this.sendPromptListChanged(e.params)))}return super.connect(e)}};function wF(e,t){return JSON.stringify(e)===JSON.stringify(t)}function TF(){let e=I(ry);if(!e)throw Error(`useTheme must be used within ThemeProvider`);return e}var EF={committedClass:null,pendingClass:null,pendingSinceMs:null,lastResolution:null},DF={classes:{widthCompactMaxPx:767,widthMediumMaxPx:1023,heightShortMaxPx:479},hysteresis:{windowMs:250,decisiveJumpPxDelta:200},rail:{widthPx:448,insetPx:16,gutterPx:24},sidecar:{minViewportWidthPx:900,maxVideoShiftPx:360,maxVideoShiftFraction:.3},card:{maxHeightPx:720,reportedHeightFloorPx:48,coldDefaultHeightPx:320,minDisplayScale:.85,layoutDefaultMinHeightPx:240,stackBandMaxFraction:.6,stackMaxWidthPx:600,componentOverrides:{}},content:{stackedAspect:16/9},pip:{gapPaddingPx:24,minWidthPx:128,maxAreaRatio:.35},motion:{layoutTransitionMs:560},insets:{callControlsBottomPx:72,participantsPadPx:16,cardsPadPx:16,surfacePadPx:16,compactCardsPadPx:8,compactSurfacePadPx:8},eviction:{policy:`evict-oldest`,maxVisibleCards:2,compactTakeoverMaxCards:1},degradationLadder:[`evict-cards`,`drop-self-view`,`collapse-replica`]};function OF(e,t){let n=Math.round(e.widthPx),r=Math.round(e.heightPx);return{width:n<=t.classes.widthCompactMaxPx?`compact`:n<=t.classes.widthMediumMaxPx?`medium`:`expanded`,height:r<=t.classes.heightShortMaxPx?`short`:`regular`}}var kF={idle:{id:`idle`,regions:[]},"conversation-full":{id:`conversation-full`,regions:[{name:`stage`,x:{fraction:0},y:{fraction:0},width:{fraction:1},height:{fraction:1},accepts:[`replica`],zBase:0},{name:`pip`,x:{fraction:.72},y:{fraction:.72},width:{fraction:.24},height:{fraction:.24},accepts:[`selfView`],zBase:100}]},"canvas-rail":{id:`canvas-rail`,soloVariant:`canvas-solo`,regions:[{name:`stage`,x:{px:0},y:{px:0},width:{fraction:.62},height:{fraction:1},accepts:[`replica`],zBase:0},{name:`rail`,x:{px:-448},y:{px:0},width:{px:448},height:{fraction:1},accepts:[`card`],zBase:0},{name:`pip`,x:{fraction:.38},y:{fraction:.72},width:{fraction:.2},height:{fraction:.24},accepts:[`selfView`],zBase:100}]},"canvas-stack":{id:`canvas-stack`,soloVariant:`canvas-solo`,regions:[{name:`canvasBand`,x:{fraction:0},y:{fraction:0},width:{fraction:1},height:{fraction:.38},accepts:[`card`],zBase:0},{name:`stage`,x:{fraction:0},y:{fraction:.38},width:{fraction:1},height:{fraction:.62},accepts:[`replica`],zBase:0},{name:`pip`,x:{fraction:.72},y:{fraction:.76},width:{fraction:.24},height:{fraction:.2},accepts:[`selfView`],zBase:100}]},"canvas-sheet":{id:`canvas-sheet`,soloVariant:`canvas-solo`,regions:[{name:`stage`,x:{fraction:0},y:{fraction:0},width:{fraction:1},height:{fraction:.55},accepts:[`replica`],zBase:0},{name:`canvasSheet`,x:{fraction:0},y:{fraction:.55},width:{fraction:1},height:{fraction:.45},accepts:[`card`],zBase:10},{name:`pip`,x:{fraction:.66},y:{fraction:.33},width:{fraction:.3},height:{fraction:.18},accepts:[`selfView`],zBase:100}]},"content-columns":{id:`content-columns`,soloVariant:`content-solo`,regions:[{name:`replicaColumn`,x:{fraction:0},y:{fraction:0},width:{fraction:.25},height:{fraction:1},accepts:[`replica`,`selfView`],zBase:0},{name:`contentStage`,x:{fraction:.25},y:{fraction:0},width:{fraction:.75},height:{fraction:1},accepts:[`content`],zBase:0},{name:`pip`,x:{fraction:.02},y:{fraction:.76},width:{fraction:.2},height:{fraction:.2},accepts:[`selfView`],zBase:100}]},"content-stack":{id:`content-stack`,soloVariant:`content-solo`,regions:[{name:`contentStage`,x:{fraction:0},y:{fraction:0},width:{fraction:1},height:{fraction:.62},accepts:[`content`],zBase:0},{name:`replicaBand`,x:{fraction:0},y:{fraction:.62},width:{fraction:1},height:{fraction:.38},accepts:[`replica`],zBase:0},{name:`pip`,x:{fraction:.72},y:{fraction:.74},width:{fraction:.24},height:{fraction:.22},accepts:[`selfView`],zBase:100}]},"content-stack-compact":{id:`content-stack-compact`,soloVariant:`content-solo`,regions:[{name:`contentStage`,x:{fraction:0},y:{fraction:0},width:{fraction:1},height:{fraction:.58},accepts:[`content`],zBase:0},{name:`replicaStrip`,x:{fraction:0},y:{fraction:.58},width:{fraction:1},height:{fraction:.42},accepts:[`replica`],zBase:0},{name:`pip`,x:{fraction:.66},y:{fraction:.78},width:{fraction:.3},height:{fraction:.18},accepts:[`selfView`],zBase:100}]},"content-sheet-compact":{id:`content-sheet-compact`,soloVariant:`content-sheet-solo`,regions:[{name:`contentStage`,x:{fraction:0},y:{fraction:0},width:{fraction:1},height:{fraction:.58},accepts:[`content`],zBase:0},{name:`replicaStrip`,x:{fraction:0},y:{fraction:.58},width:{fraction:1},height:{fraction:.42},accepts:[`replica`],zBase:0},{name:`cardSheet`,x:{fraction:0},y:{fraction:0},width:{fraction:1},height:{fraction:1},accepts:[`card`],zBase:100},{name:`pip`,x:{fraction:.66},y:{fraction:.78},width:{fraction:.3},height:{fraction:.18},accepts:[`selfView`],zBase:110}]},"content-rail":{id:`content-rail`,soloVariant:`content-rail-solo`,regions:[{name:`replicaColumn`,x:{fraction:0},y:{fraction:0},width:{fraction:.22},height:{fraction:1},accepts:[`replica`,`selfView`],zBase:0},{name:`contentStage`,x:{fraction:.22},y:{fraction:0},width:{fraction:.48},height:{fraction:1},accepts:[`content`],zBase:0},{name:`rail`,x:{px:-448},y:{px:0},width:{px:448},height:{fraction:1},accepts:[`card`],zBase:0},{name:`pip`,x:{fraction:.02},y:{fraction:.78},width:{fraction:.18},height:{fraction:.18},accepts:[`selfView`],zBase:100}]},"content-stack-canvas":{id:`content-stack-canvas`,soloVariant:`content-sheet-solo`,regions:[{name:`contentStage`,x:{fraction:0},y:{fraction:0},width:{fraction:1},height:{fraction:.5},accepts:[`content`],zBase:0},{name:`replicaBand`,x:{fraction:0},y:{fraction:.5},width:{fraction:1},height:{fraction:.22},accepts:[`replica`],zBase:0},{name:`canvasBand`,x:{fraction:0},y:{fraction:.72},width:{fraction:1},height:{fraction:.28},accepts:[`card`],zBase:0},{name:`pip`,x:{fraction:.72},y:{fraction:.52},width:{fraction:.24},height:{fraction:.18},accepts:[`selfView`],zBase:100}]},"canvas-takeover-columns":{id:`canvas-takeover-columns`,soloVariant:`canvas-solo`,regions:[{name:`replicaColumn`,x:{fraction:0},y:{fraction:0},width:{fraction:.24},height:{fraction:1},accepts:[`replica`,`selfView`],zBase:0},{name:`canvasStage`,x:{fraction:.24},y:{fraction:0},width:{fraction:.76},height:{fraction:1},accepts:[`card`],zBase:0},{name:`pip`,x:{fraction:.02},y:{fraction:.78},width:{fraction:.18},height:{fraction:.18},accepts:[`selfView`],zBase:100}]},"canvas-takeover-strip":{id:`canvas-takeover-strip`,soloVariant:`canvas-solo`,regions:[{name:`canvasStage`,x:{fraction:0},y:{fraction:0},width:{fraction:1},height:{fraction:.78},accepts:[`card`],zBase:0},{name:`replicaStrip`,x:{fraction:0},y:{fraction:.78},width:{fraction:1},height:{fraction:.22},accepts:[`replica`],zBase:0},{name:`pip`,x:{fraction:.66},y:{fraction:.8},width:{fraction:.3},height:{fraction:.16},accepts:[`selfView`],zBase:100}]},"canvas-solo":{id:`canvas-solo`,regions:[{name:`canvasStage`,x:{fraction:0},y:{fraction:0},width:{fraction:1},height:{fraction:1},accepts:[`card`],zBase:0}]},"content-solo":{id:`content-solo`,regions:[{name:`contentStage`,x:{fraction:0},y:{fraction:0},width:{fraction:1},height:{fraction:1},accepts:[`content`],zBase:0}]},"content-rail-solo":{id:`content-rail-solo`,regions:[{name:`contentStage`,x:{px:0},y:{px:0},width:{fraction:1},height:{fraction:1},accepts:[`content`],zBase:0},{name:`rail`,x:{px:-448},y:{px:0},width:{px:448},height:{fraction:1},accepts:[`card`],zBase:0}]},"content-sheet-solo":{id:`content-sheet-solo`,regions:[{name:`contentStage`,x:{fraction:0},y:{fraction:0},width:{fraction:1},height:{fraction:.62},accepts:[`content`],zBase:0},{name:`canvasBand`,x:{fraction:0},y:{fraction:.62},width:{fraction:1},height:{fraction:.38},accepts:[`card`],zBase:10}]}},AF={idle:{compact:{short:`idle`,regular:`idle`},medium:{short:`idle`,regular:`idle`},expanded:{short:`idle`,regular:`idle`}},conversation:{compact:{short:`conversation-full`,regular:`conversation-full`},medium:{short:`conversation-full`,regular:`conversation-full`},expanded:{short:`conversation-full`,regular:`conversation-full`}},"conversation-canvas":{compact:{short:`canvas-sheet`,regular:`canvas-sheet`},medium:{short:`canvas-rail`,regular:`canvas-stack`},expanded:{short:`canvas-rail`,regular:`canvas-rail`}},"content-focus":{compact:{short:`content-stack-compact`,regular:`content-stack-compact`},medium:{short:`content-columns`,regular:`content-stack`},expanded:{short:`content-columns`,regular:`content-columns`}},"content-plus-canvas":{compact:{short:`content-sheet-compact`,regular:`content-sheet-compact`},medium:{short:`content-rail`,regular:`content-stack-canvas`},expanded:{short:`content-rail`,regular:`content-rail`}},"canvas-dominant":{compact:{short:`canvas-takeover-strip`,regular:`canvas-takeover-strip`},medium:{short:`canvas-takeover-columns`,regular:`canvas-takeover-columns`},expanded:{short:`canvas-takeover-columns`,regular:`canvas-takeover-columns`}}};function jF(e,t,n=kF,r=AF,i=!0){let a=r[e][t.width][t.height],o=n[a];if(!o)throw Error(`Template matrix references missing template id: ${a}`);if(!i&&o.soloVariant!==void 0){let e=n[o.soloVariant];if(!e)throw Error(`soloVariant references missing template id: ${o.soloVariant}`);return e}return o}function MF(e,t,n){let r=[],{prefs:i}=e,a=e.userShare?`userShare`:e.presentation?`presentation`:null,o=e.cards.length>0,s=t.width===`compact`;return i.pipCorner!==void 0&&s&&r.push(`pipCorner`),a===null?(i.expandCanvas&&!o&&r.push(`expandCanvas`),o&&(i.expandCanvas||s)?{state:`canvas-dominant`,suppressedPrefs:r,contentKind:null}:o?{state:`conversation-canvas`,suppressedPrefs:r,contentKind:null}:e.replica||e.selfView?{state:`conversation`,suppressedPrefs:r,contentKind:null}:{state:`idle`,suppressedPrefs:r,contentKind:null}):(i.expandCanvas&&r.push(`expandCanvas`),{state:o?`content-plus-canvas`:`content-focus`,suppressedPrefs:r,contentKind:a})}var NF={alert:{minWidthPx:220,sizeClass:()=>`S`,estimateHeightPx:e=>e.charCount===void 0?120:Math.min(400,Math.round(90+e.charCount*.26))},input:{minWidthPx:220,sizeClass:()=>`S`,estimateHeightPx:()=>182},question:{minWidthPx:240,sizeClass:e=>{let t=e.optionCount??4;return t<=2?`S`:t>=10?`L`:`M`},estimateHeightPx:e=>{let t=e.optionCount??4;return 72+t*48+(t-1)*8+64}},text:{minWidthPx:220,sizeClass:e=>(e.charCount??400)>1500?`L`:`M`,estimateHeightPx:e=>{let t=e.charCount??400,n=Math.max(1,e.widthPx/8);return Math.max(100,Math.round(t/n*22+40))}},chart:{minWidthPx:260,sizeClass:()=>`M`,estimateHeightPx:e=>Math.round(e.widthPx*(260/480))+90},calendar:{minWidthPx:320,sizeClass:e=>e.slotCount===void 0?`M`:`L`,estimateHeightPx:e=>e.slotCount===void 0?470:64+e.slotCount*48},image:{minWidthPx:240,sizeClass:()=>`M`,estimateHeightPx:e=>Math.round((Math.min(e.widthPx,520)-36)*(9/16))+95+((e.imageCount??1)>1?44:0)},scheduling_embed:{minWidthPx:320,hardMinHeightPx:640,sizeClass:()=>`L`,estimateHeightPx:()=>640}},PF={minWidthPx:240,sizeClass:()=>`M`,estimateHeightPx:e=>e.coldDefaultHeightPx??320},FF=`canvas.`;function IF(e){return e.startsWith(FF)?e.slice(7):e}function LF(e,t){let n=IF(e),r=NF[n]??PF,i=t?.[n]??t?.[e];return i===void 0?r:{...r,minWidthPx:i.minWidthPx??r.minWidthPx,...i.hardMinHeightPx===void 0?r.hardMinHeightPx===void 0?{}:{hardMinHeightPx:r.hardMinHeightPx}:{hardMinHeightPx:i.hardMinHeightPx}}}Object.keys(NF);function RF(e,t,n){let r=LF(e,n),i=(t.naturalHeightPx!==void 0&&Number.isFinite(t.naturalHeightPx)?t.naturalHeightPx:void 0)??r.estimateHeightPx(t),a=r.hardMinHeightPx===void 0?i:Math.max(r.hardMinHeightPx,i);return{sizeClass:r.sizeClass(t),minWidthPx:r.minWidthPx,naturalHeightPx:Math.round(a),hardMinHeightPx:r.hardMinHeightPx}}function zF(e,t){let n=IF(e);return NF[n]===void 0?(t?.[n]??t?.[e])?.hardMinHeightPx:LF(e,t).hardMinHeightPx}function BF(e,t){return LF(e,t).minWidthPx}function VF(e,t){let n=Number.isFinite(e)?e:t.card.coldDefaultHeightPx;return Math.min(t.card.maxHeightPx,Math.max(t.card.reportedHeightFloorPx,Math.round(n)))}function HF(e,t,n){if(t>=e)return{kind:`natural`};if(t<=0||e<=0)return{kind:`scroll`};let r=t/e;return r>=n.card.minDisplayScale?{kind:`scaled`,factor:r}:{kind:`scroll`}}function UF(e,t){return e.width>0&&e.height>0&&t.width>0&&t.height>0&&e.x<t.x+t.width&&t.x<e.x+e.width&&e.y<t.y+t.height&&t.y<e.y+e.height}function WF(e,t){return t.x>=e.x&&t.y>=e.y&&t.x+t.width<=e.x+e.width&&t.y+t.height<=e.y+e.height}function GF(e,t,n){let r=[],i=e.find(e=>e.kind===`replica`),a=e=>e.kind===`selfView`&&e.layer===`overlay`&&i!==void 0&&WF(i.rect,e.rect),o=e=>e.kind===`card`&&e.layer===`overlay`&&e.sheet===!0;for(let a of e){let e=a.rect;if(Number.isInteger(e.x)&&Number.isInteger(e.y)&&Number.isInteger(e.width)&&Number.isInteger(e.height)||r.push({kind:`bounds`,tileId:a.id,message:`${a.id} has non-integer coordinates`}),(e.x<0||e.y<0||e.width<0||e.height<0||e.x+e.width>t.width||e.y+e.height>t.height)&&r.push({kind:`bounds`,tileId:a.id,message:`${a.id} rect exceeds the container`}),a.layer===`overlay`&&a.kind!==`selfView`&&!o(a)&&r.push({kind:`overlay-legality`,tileId:a.id,message:`only selfView or a sheet card may ride the overlay layer, got ${a.kind}`}),a.kind===`selfView`&&a.layer===`overlay`&&i!==void 0&&!WF(i.rect,a.rect)&&r.push({kind:`overlay-legality`,tileId:a.id,message:`selfView escapes the replica rect`}),(a.kind===`content`||a.kind===`replica`)&&(e.width<48||e.height<48)&&r.push({kind:`degenerate-surface`,tileId:a.id,message:`${a.kind} tile ${a.id} is ${e.width}x${e.height}px, below the 48px visible floor`}),a.kind===`card`){a.fit.kind===`scaled`&&(a.fit.factor<n.card.minDisplayScale||a.fit.factor>1)&&r.push({kind:`min-content`,tileId:a.id,message:`card ${a.id} scaled to ${a.fit.factor}, outside [${n.card.minDisplayScale}, 1]`}),e.height<n.card.reportedHeightFloorPx&&r.push({kind:`min-content`,tileId:a.id,message:`card ${a.id} box ${e.height}px is below the ${n.card.reportedHeightFloorPx}px report floor`});let t=a.component===void 0?void 0:zF(a.component,n.card.componentOverrides);t!==void 0&&e.height<t&&a.fit.kind!==`scroll`&&r.push({kind:`min-content`,tileId:a.id,message:`card ${a.id} box ${e.height}px is below its ${t}px hard min without scroll`});let i=a.component===void 0?void 0:BF(a.component,n.card.componentOverrides);i!==void 0&&e.width<i&&r.push({kind:`min-content`,tileId:a.id,message:`card ${a.id} box ${e.width}px is below its ${i}px min width`})}}for(let t of e)if(!(t.kind!==`content`&&t.kind!==`card`))for(let n of e)n.id!==t.id&&UF(t.rect,n.rect)&&(a(n)&&!o(t)||o(n)&&!o(t)||o(t)&&n.layer===`grid`||r.push({kind:`never-covered`,tileId:t.id,otherTileId:n.id,message:`${n.id} covers ${t.kind} tile ${t.id}`}));return r}var KF=(e,t,n)=>Math.min(n,Math.max(t,e));function qF(e,t){let n=t===`compact`;return{surfacePad:Math.round(n?e.insets.compactSurfacePadPx:e.insets.surfacePadPx),cardsPad:Math.round(n?e.insets.compactCardsPadPx:e.insets.cardsPadPx)}}function JF(e,t,n){return e===`canvas-dominant`&&t.width===`compact`?n.eviction.compactTakeoverMaxCards:n.eviction.maxVisibleCards}function YF(e,t,n){let r=[...e].sort((e,t)=>e.dispatchSeq-t.dispatchSeq),i=Math.floor(t);return r.length<=i?r:n===`evict-newest`?r.slice(0,i):r.slice(r.length-i)}function XF(e,t,n,r,i,a){let o=i??qF(n,r).cardsPad,s=Math.round(a??n.rail.widthPx),c=Math.max(1,Math.min(t-2*o,s-2*o));return{innerW:c,entries:e.map(e=>{let t=RF(e.component,{...e.contentOpts,naturalHeightPx:e.naturalHeightPx,widthPx:c,coldDefaultHeightPx:n.card.coldDefaultHeightPx},n.card.componentOverrides);return{card:e,constraints:t,clampedHeightPx:VF(t.naturalHeightPx,n)}})}}function ZF(e,t){return`fraction`in e?e.fraction*t:e.px>=0?e.px:t+e.px}function QF(e,t,n,r){return e.name!==`rail`||`fraction`in t?t:r===`width`?{px:n.rail.widthPx}:{px:t.px<0?-n.rail.widthPx:t.px}}function $F(e,t,n,r,i,a){let o=n===`x`?t.width:t.height,s=[...e].sort((e,t)=>ZF(n===`x`?e.x:e.y,o)-ZF(n===`x`?t.x:t.y,o)),c=s.map(e=>n===`x`?QF(e,e.width,r,`width`):e.height),l=0,u=0;for(let e of c)`px`in e?l+=e.px:u+=e.fraction;let d=Math.max(0,o-l),f=c.map(e=>`px`in e?e.px:u>0?e.fraction/u*d:0);if(n===`y`&&i!==void 0){let e=s.findIndex((e,t)=>e.accepts.includes(`card`)&&`fraction`in(c[t]??e.height));if(e!==-1){let t=f[e]??0,n=i.shrinkToContent?Math.min(i.neededPx,Math.max(t,i.capPx)):KF(i.neededPx,t,Math.max(t,i.capPx)),r=0,a=0;c.forEach((t,n)=>{n!==e&&(`px`in t?r+=t.px:a+=f[n]??0)});let s=Math.max(0,o-r-n);f=f.map((t,r)=>{if(r===e)return n;let i=c[r];return i!==void 0&&`px`in i?t:a>0?t/a*s:0})}}if(n===`y`&&a!==void 0){let e=s.findIndex((e,t)=>e.accepts.includes(`content`)&&`fraction`in(c[t]??e.height)),t=s.findIndex((e,t)=>e.accepts.includes(`replica`)&&`fraction`in(c[t]??e.height));if(e!==-1&&t!==-1){let n=(f[e]??0)-a.maxPx;n>0&&(f[e]=a.maxPx,f[t]=(f[t]??0)+n)}}let p=s.map(e=>e.accepts.includes(`content`)||e.accepts.includes(`replica`)?48:0),m=p.reduce((e,t)=>e+t,0),h=m>o?o/m:1,g=f.map((e,t)=>Math.max(e,(p[t]??0)*h));if(g.reduce((e,t)=>e+t,0)>o){let e=g.map((e,t)=>e-(p[t]??0)*h),t=e.reduce((e,t)=>e+t,0),n=Math.max(0,o-m*h),r=t>0?n/t:0;f=g.map((t,n)=>(p[n]??0)*h+(e[n]??0)*r)}else f=g;let _=[0],v=0;for(let e of f)v+=e,_.push(KF(Math.round(v),0,o));return s.map((e,r)=>{let i=_[r]??0,a=_[r+1]??i;return{region:e,rect:n===`x`?{x:i,y:0,width:a-i,height:t.height}:{x:0,y:i,width:t.width,height:a-i}}})}function eI(e,t,n){let r=t.width,i=t.height,a=QF(e,e.width,n,`width`),o=QF(e,e.x,n,`x`),s=KF(Math.round(ZF(o,r)),0,r),c=KF(Math.round(ZF(e.y,i)),0,i);return{x:s,y:c,width:KF(Math.round(`fraction`in a?a.fraction*r:a.px),0,r-s),height:KF(Math.round(`fraction`in e.height?e.height.fraction*i:e.height.px),0,i-c)}}function tI(e,t,n,r,i){let a=e.regions.filter(e=>e.zBase<100),o=e=>`fraction`in e&&e.fraction===1;return a.length>1&&a.every(e=>o(e.height))?$F(a,t,`x`,n):a.length>1&&a.every(e=>o(e.width))?$F(a,t,`y`,n,r,i):a.map(e=>({region:e,rect:eI(e,t,n)}))}function nI(e,t,n,r,i,a,o,s,c,l,u){if(n!==null)return;let d=e.regions.filter(e=>e.zBase<100);if(!(d.length>1&&d.every(e=>`fraction`in e.width&&e.width.fraction===1)))return;let f=d.find(e=>e.accepts.includes(`card`)&&`fraction`in e.height);if(f===void 0||r.cards.length===0)return;let{innerW:p,entries:m}=XF(YF(r.cards,u,c.eviction.policy),i.width,c,l,void 0,c.card.stackMaxWidthPx),h=m.reduce((e,t)=>t.constraints.minWidthPx>p?e:Math.max(e,t.clampedHeightPx),0),{cardsPad:g}=qF(c,l),_=ZF(f.y,i.height),v=d.every(e=>ZF(e.y,i.height)<=_),y=v?Math.max(0,o-s):0,b=!v&&h>0;return{neededPx:h+2*g+(b?0:y),capPx:Math.round(c.card.stackBandMaxFraction*a.height),...b&&{shrinkToContent:b}}}function rI(e,t,n,r){if(t===null)return;let i=e.regions.filter(e=>e.zBase<100);if(!(i.length>1&&i.every(e=>`fraction`in e.width&&e.width.fraction===1)))return;let a=i.some(e=>e.accepts.includes(`content`)&&`fraction`in e.height),o=i.some(e=>e.accepts.includes(`replica`)&&`fraction`in e.height);if(!a||!o)return;let s=r.content.stackedAspect;if(!(!Number.isFinite(s)||s<=0))return{maxPx:Math.round(n.width/s)}}var iI=`bottom-left`;function aI(e,t,n,r,i){let a=t.endsWith(`right`)?e.x+e.width-n-r:e.x+n,o=t.startsWith(`bottom`)?e.y+e.height-n-i:e.y+n;return{x:Math.round(a),y:Math.round(o),width:r,height:i}}function oI(e,t,n,r){let i=Math.max(n.pip.minWidthPx,Math.round(e.width*.25)),a=r?e.height-t:Math.round((e.height-t)*16/9),o=Math.min(i,e.width-t,a),s=r?o:Math.round(o*9/16);return o<n.pip.minWidthPx||o<=0||s<=0?null:{w:o,h:s}}function sI(e,t,n){return t===null||!UF(e,t)?e:{...e,y:Math.round(t.y)-n-e.height}}function cI(e){if(typeof e!=`object`||!e)return!1;let t=e;return[`x`,`y`,`width`,`height`].every(e=>typeof t[e]==`number`&&Number.isFinite(t[e]))}function lI(e,t,n){let r=e;for(let e of t.filter(cI).sort((e,t)=>t.y-e.y))r=sI(r,e,n);return r}function uI(e,t,n){if(t<=0)return e;let r=Math.min(t,e.length);return n===`evict-newest`?e.slice(0,e.length-r):e.slice(r)}function dI(e,t,n,r,i,a){let o=n.callControls===!0?Math.round(a.insets.callControlsBottomPx):0,s=i.height-o,c=n.selfView&&n.prefs.hideSelfView!==!0,l=(n.replica||c?1:0)+(t.contentKind===null?0:1)+ +(n.cards.length>0)>=2?qF(a,r.width).surfacePad:0,u={width:Math.max(0,i.width-2*l),height:Math.max(0,i.height-2*l)},d=n.callControlsRect??(o>0?{x:0,y:s,width:i.width,height:o}:null);return{regions:tI(e,u,a,nI(e,t.state,t.contentKind,n,u,i,o,l,a,r.width,JF(t.state,r,a)),rI(e,t.contentKind,u,a)).map(e=>({...e,rect:{...e.rect,x:e.rect.x+l,y:e.rect.y+l}})).map(e=>d===null||!e.region.accepts.includes(`card`)||!(e.rect.x<d.x+d.width&&e.rect.x+e.rect.width>d.x)?e:{...e,rect:{...e.rect,height:Math.max(0,Math.min(e.rect.height,s-e.rect.y))}}),surfacePad:l,controlsInset:o,bandTopY:s}}function fI(e,t,n,r,i,a){let o=n.selfView&&n.prefs.hideSelfView!==!0,{regions:s,surfacePad:c,controlsInset:l,bandTopY:u}=dI(t,e,n,r,i,a),d=s.find(e=>e.region.accepts.includes(`replica`)),f=s.find(e=>e.region.accepts.includes(`content`)),p=s.find(e=>e.region.accepts.includes(`card`)),m=t.regions.find(e=>e.zBase>=100&&e.accepts.includes(`selfView`)),h=t.regions.find(e=>e.zBase>=100&&e.accepts.includes(`card`)),g=Math.round(a.rail.gutterPx),_=Math.round(a.pip.gapPaddingPx),v=[...n.cards].sort((e,t)=>e.dispatchSeq-t.dispatchSeq),y=JF(e.state,r,a),b=p?YF(n.cards,y,a.eviction.policy):h===void 0?[]:YF(n.cards,1,a.eviction.policy),x=s=>{let y={evictedCardIds:[],selfViewDropped:!1,replicaCollapsed:!1},x=[],S=null,C=!1,w=d!==void 0&&d.region.accepts.includes(`selfView`);if(d&&w&&(n.replica||o)){let e=d.rect,t=o&&!s.selfViewDropped;o&&s.selfViewDropped&&(y.selfViewDropped=!0);let r=+!!n.replica+ +!!t,i=Math.round(a.insets.participantsPadPx),c=Math.max(1,e.width-2*i),l=Math.round(c*9/16),u=e=>r*e+(r-1)*i;u(l)>e.height&&(l=Math.max(1,Math.floor((e.height-(r-1)*i)/r)),c=Math.min(Math.max(1,e.width-2*i),Math.round(l*16/9))),l=Math.max(l,Math.min(48,e.height)),c=Math.max(c,Math.min(48,e.width));let f=e.x+Math.round((e.width-c)/2),p=e.y+Math.round((e.height-u(l))/2);if(n.replica){let e={x:f,y:p,width:c,height:l};if(s.replicaCollapsed){let t=Math.min(l,Math.max(64,Math.round(l*.25)));e={...e,height:t},y.replicaCollapsed=!0}S={id:`replica`,kind:`replica`,rect:e,layer:`grid`,order:d.region.zBase,fit:{kind:`natural`},region:d.region.name},x.push(S),p+=l+i}t&&(x.push({id:`selfView`,kind:`selfView`,rect:{x:f,y:p,width:c,height:l},layer:`grid`,order:d.region.zBase,fit:{kind:`natural`},region:d.region.name}),C=!0)}else if(d&&(n.replica||o)){let e=!n.replica,t=d.rect;if(!e&&s.replicaCollapsed){let e=Math.min(t.height,Math.max(64,Math.round(t.height*.25)));t={...t,height:e},y.replicaCollapsed=!0}let r={id:e?`selfView`:`replica`,kind:e?`selfView`:`replica`,rect:t,layer:`grid`,order:d.region.zBase,fit:{kind:`natural`},region:d.region.name};x.push(r),e?C=!0:S=r}e.contentKind!==null&&f&&x.push({id:`content`,kind:`content`,rect:f.rect,layer:`grid`,order:f.region.zBase,fit:{kind:`natural`},region:f.region.name});let T=uI(b,s.extraEvictions,a.eviction.policy),E=new Set(T.map(e=>e.id));if(y.evictedCardIds=v.filter(e=>!E.has(e.id)).map(e=>e.id),p&&T.length>0){let e=p.rect,n=t.regions.filter(e=>e.zBase<100),i=n.length>1&&n.every(e=>`fraction`in e.width&&e.width.fraction===1),{innerW:o,entries:s}=XF(T,e.width,a,r.width,void 0,i?a.card.stackMaxWidthPx:void 0),c=e.x+Math.round((e.width-o)/2),l=e.height-g*(s.length-1),u=s.reduce((e,t)=>e+t.clampedHeightPx,0),d;if(u<=l)d=s.map(e=>e.clampedHeightPx);else{let e=l>0?l/u:0;d=s.map(t=>Math.max(a.card.reportedHeightFloorPx,Math.floor(t.clampedHeightPx*e)));let t=d.reduce((e,t)=>e+t,0)-Math.max(0,l);for(;t>0;){let e=-1;for(let t=0;t<d.length;t++){let n=d[t]??0;n>a.card.reportedHeightFloorPx&&(e===-1||n>(d[e]??0))&&(e=t)}if(e===-1)break;d[e]=(d[e]??0)-1,--t}}let f=d.reduce((e,t)=>e+t,0)+g*(s.length-1),m=e.y+Math.max(0,Math.round((e.height-f)/2));s.forEach((t,n)=>{let r=Math.min(m,e.y+e.height),i=Math.max(0,Math.min(d[n]??0,e.y+e.height-r)),s=HF(t.clampedHeightPx,i,a),l=t.constraints.hardMinHeightPx;l!==void 0&&i<l&&s.kind!==`scroll`&&(s={kind:`scroll`}),x.push({id:t.card.id,kind:`card`,component:t.card.component,cardSizeClass:t.constraints.sizeClass,rect:{x:c,y:r,width:o,height:i},layer:`grid`,order:p.region.zBase+n,fit:s,region:p.region.name}),m=r+i+g})}let D=null;if(p===void 0&&h!==void 0&&T.length>0){let e={width:Math.max(0,i.width-2*c),height:Math.max(0,i.height-2*c)},t=eI(h,e,a),n={x:t.x+c,y:t.y+c,width:t.width,height:Math.max(0,Math.min(t.height,u-(t.y+c)))},{innerW:o,entries:s}=XF(T,n.width,a,r.width,0,a.card.stackMaxWidthPx),l=s[0];if(l!==void 0){let e=n.x+Math.round((n.width-o)/2),t=Math.max(0,Math.min(l.clampedHeightPx,n.height)),r=HF(l.clampedHeightPx,t,a),i=l.constraints.hardMinHeightPx;i!==void 0&&t<i&&r.kind!==`scroll`&&(r={kind:`scroll`}),D={id:l.card.id,kind:`card`,component:l.card.component,cardSizeClass:l.constraints.sizeClass,rect:{x:e,y:n.y,width:o,height:t},layer:`overlay`,order:h.zBase,fit:r,region:h.name,sheet:!0},x.push(D)}}if(!C){if(o&&s.selfViewDropped)y.selfViewDropped=!0;else if(o){let t=e.suppressedPrefs.includes(`pipCorner`)?iI:n.prefs.pipCorner??`bottom-left`,o=n.callControlsVisible===!1?null:n.callControlsRect??(l>0?{x:0,y:u,width:i.width,height:l}:null),s=[...o===null?[]:[o],...D===null?[]:[D.rect],...n.chromeObstacles??[]];if(S){let e=S.rect,n=oI(e,_,a,r.width===`compact`),i=n===null?null:aI(e,t,_,n.w,n.h),o=i===null?null:lI(i,s,_),c=n!==null&&o!==null&&o.y>=e.y&&n.w+_<=e.width&&n.h+_<=e.height,l=n!==null&&e.width>0&&e.height>0?n.w*n.h/(e.width*e.height):1/0;o!==null&&c&&l<=a.pip.maxAreaRatio?x.push({id:`selfView`,kind:`selfView`,rect:o,layer:`overlay`,order:m?.zBase??100,fit:{kind:`natural`},region:m?.name??`pip`}):y.selfViewDropped=!0}else{let e=a.pip.minWidthPx,n=r.width===`compact`?e:Math.round(e*9/16),o={x:0,y:0,width:i.width,height:i.height},c=lI(aI(o,t,_,e,n),s,_),l=c.y>=0&&e+_<=o.width&&n+_<=o.height,u=x.some(e=>(e.kind===`content`||e.kind===`card`)&&UF(e.rect,c));l&&!u?x.push({id:`selfView`,kind:`selfView`,rect:c,layer:`overlay`,order:m?.zBase??100,fit:{kind:`natural`},region:m?.name??`pip`}):y.selfViewDropped=!0}}}return{tiles:x,degradations:y}},S={extraEvictions:0,selfViewDropped:!1,replicaCollapsed:!1},C=x(S),w=GF(C.tiles,i,a);for(let e of a.degradationLadder){if(w.length===0)break;if(e===`evict-cards`)for(;w.length>0&&S.extraEvictions<b.length;)S={...S,extraEvictions:S.extraEvictions+1},C=x(S),w=GF(C.tiles,i,a);else e===`drop-self-view`?C.tiles.some(e=>e.kind===`selfView`)&&(S={...S,selfViewDropped:!0},C=x(S),w=GF(C.tiles,i,a)):e===`collapse-replica`&&!S.replicaCollapsed&&C.tiles.some(e=>e.kind===`replica`)&&(S={...S,replicaCollapsed:!0},C=x(S),w=GF(C.tiles,i,a))}return C}function pI(e){if(!(e===void 0||e.length===0))return{...kF,...Object.fromEntries(e.map(e=>[e.id,e]))}}function mI(e,t,n,r){let i={width:Math.max(0,Math.round(e.container.widthPx)),height:Math.max(0,Math.round(e.container.heightPx))},a=MF(e,t,n),o=e.replica||e.selfView&&e.prefs.hideSelfView!==!0,s=jF(a.state,t,pI(r?.templates),void 0,o),{tiles:c,degradations:l}=fI(a,s,e,t,i,n);return{state:a.state,sizeClass:t,containerPx:i,templateId:s.id,tiles:c,degradations:l,suppressedPrefs:[...a.suppressedPrefs]}}var hI={compact:0,medium:1,expanded:2};function gI(e,t){return e.width===t.width&&e.height===t.height}function _I(e,t,n,r,i){let a=e.committedClass;if(a===null)return{committedClass:t,pendingClass:null,pendingSinceMs:null};if(gI(t,a))return{committedClass:a,pendingClass:null,pendingSinceMs:null};let o=Math.abs(hI[t.width]-hI[a.width]),s=e.lastResolution?.containerPx.width??null;return o>1||s===null||Math.abs(Math.round(n)-s)>=i.hysteresis.decisiveJumpPxDelta?{committedClass:t,pendingClass:null,pendingSinceMs:null}:e.pendingClass!==null&&e.pendingSinceMs!==null&&gI(e.pendingClass,t)?r-e.pendingSinceMs>=i.hysteresis.windowMs?{committedClass:t,pendingClass:null,pendingSinceMs:null}:{committedClass:a,pendingClass:e.pendingClass,pendingSinceMs:e.pendingSinceMs}:{committedClass:a,pendingClass:t,pendingSinceMs:r}}var vI=(e,t)=>e<t?-1:+(e>t);function yI(e,t){let n=new Map((e?.tiles??[]).map(e=>[e.id,e])),r=new Map(t.tiles.map(e=>[e.id,e])),i=[];for(let e of[...n.keys()].sort(vI))r.has(e)||i.push({type:`exit`,tileId:e});let a=[],o=[],s=[];for(let e of[...r.keys()].sort(vI)){let t=n.get(e);if(t===void 0){a.push({type:`enter`,tileId:e});continue}let i=r.get(e);if(t.layer!==i.layer){o.push(i.layer===`overlay`?{type:`promote`,tileId:e,toLayer:i.layer}:{type:`demote`,tileId:e,toLayer:i.layer});continue}let c=t.rect.x!==i.rect.x||t.rect.y!==i.rect.y,l=t.rect.width!==i.rect.width||t.rect.height!==i.rect.height;c?s.push({type:`move`,tileId:e,from:t.rect,to:i.rect}):l&&s.push({type:`resize`,tileId:e,from:t.rect,to:i.rect})}return[...i,...a,...o,...s]}function bI(e,t,n,r,i){let a=_I(e,OF(t.container,r),t.container.widthPx,n,r),o=mI(t,a.committedClass,r,i);return{resolution:o,transitions:yI(e.lastResolution,o),nextState:{committedClass:a.committedClass,pendingClass:a.pendingClass,pendingSinceMs:a.pendingSinceMs,lastResolution:o}}}var xI=`0.1.12`,SI=EF,CI=(()=>{try{return new URLSearchParams(globalThis.location?.search??``).get(`grid_enabled`)===`1`}catch{return!1}})(),wI=(()=>{try{return new URLSearchParams(globalThis.location?.search??``).get(`grid_debug`)===`1`}catch{return!1}})();function TI(e,t){return CI||e===!0||t===!0}function EI({instances:e,viewport:t,presence:n,callControlsBandPx:r,callControlsVisible:i,callControlsRect:a,reportedHeights:o}){return{container:{widthPx:t.width,heightPx:Math.round(Math.min(t.height,t.visualViewportHeight??t.height))},replica:n.hasPersonaVideo,selfView:n.hasSelfView,presentation:n.isPersonaPresenting?{}:null,userShare:n.isScreenSharing?{}:null,cards:e.map((e,t)=>({id:e.id,component:e.canvas_config.component,dispatchSeq:t+1,...o[e.id]===void 0?{}:{naturalHeightPx:o[e.id]}})),prefs:{},callControls:r>0,callControlsVisible:i??!0,...a===void 0?{}:{callControlsRect:a}}}var DI=16,OI=200,kI=Yt(null);function AI(e){kI.peek()===null&&(console.error(`Magic Grid engine error; rendering the legacy layout.`,e),kI.value=(e instanceof Error?`${e.name}: ${e.message}`:String(e)).slice(0,OI))}function jI(){kI.peek()!==null&&(kI.value=null)}function MI({instances:e,viewport:t,presence:n,callControlsBandPx:r,callControlsVisible:i,callControlsRect:a,enabled:o}){let s=N(SI),c=N(null),[l,u]=j({}),[d,f]=j(null),p=F((e,t)=>{o&&u(n=>n[e]===t?n:{...n,[e]:t})},[o]);M(()=>{u(t=>{let n=new Set(e.map(e=>e.id)),r={};for(let[e,i]of Object.entries(t))n.has(e)&&(r[e]=i);return Object.keys(r).length===Object.keys(t).length?t:r})},[e]);let m=P(()=>EI({instances:e,viewport:t,presence:n,callControlsBandPx:r,callControlsVisible:i,callControlsRect:a,reportedHeights:l}),[e,t,n,r,i,a,l]);return M(()=>{if(!o||kI.peek()!==null)return;c.current===null&&(c.current=Date.now());let e=null,t=()=>{if(e=null,kI.peek()!==null)return;let n=Date.now()-(c.current??0),r;try{r=bI(s.current,m,n,DF)}catch(e){AI(e);return}if(s.current=r.nextState,f(r),r.nextState.pendingClass!==null){let i=r.nextState.pendingSinceMs===null?0:Math.max(0,n-r.nextState.pendingSinceMs);e=setTimeout(t,Math.max(DI,DF.hysteresis.windowMs-i+DI))}};return t(),()=>{e!==null&&clearTimeout(e)}},[o,m]),{resolution:o?d?.resolution??null:null,inputs:o?m:null,transitions:o?d?.transitions??[]:[],reportedHeights:l,recordNaturalHeight:p}}function NI(e,t,n){return n?e===null?`no-presence`:t.hasPersonaVideo?e.degradations.evictedCardIds.length>0?`card-dropped`:e.tiles.some(e=>e.kind===`card`&&e.fit.kind===`scroll`)?`card-overflow`:null:`no-persona-video`:`flag-off`}function PI(e,t){if(t!==null||e===null)return null;let n=e.tiles.find(e=>e.kind===`card`&&e.sheet===!0);return n===void 0?null:n.rect.y+n.rect.height}var FI={driving:!1,containerPx:null,replica:null,selfView:null,content:null,replicaCollapsed:!1};function II(e,t,n){if(e===null)return FI;let r=t===null;if(!r&&!(t===`no-persona-video`&&n))return FI;let i=t=>e.tiles.find(e=>e.kind===t)?.rect??null;return{driving:r,containerPx:e.containerPx,replica:r?i(`replica`):null,selfView:i(`selfView`),content:r?i(`content`):null,replicaCollapsed:r?e.degradations.replicaCollapsed:!1}}function LI(e){return e.selfView===null?e.driving?`hidden`:`legacy`:`engine`}function RI(e,t){return e.containerPx===null||t.containerPx===null?!1:e.containerPx.width===t.containerPx.width&&e.containerPx.height===t.containerPx.height}var zI=`conversation.grid_status`,BI=6e4;function VI(e,t,n){return n?e&&t?`url+config+start`:e?`url+start`:t?`config+start`:`start`:e&&t?`both`:e?`url`:`config`}function HI(e,t){return{message_type:`conversation`,event_type:zI,conversation_id:e,properties:t}}function UI(e){return{template_id:e.templateId,size_class:`${e.sizeClass.width}/${e.sizeClass.height}`,container:{w:e.containerPx.width,h:e.containerPx.height},cards:e.tiles.filter(e=>e.kind===`card`).length}}function WI(e){let{send:t,enabledVia:n,engineVersion:r=xI,now:i=Date.now,transitionDebounceMs:a=500,summaryIntervalMs:o=BI}=e,s=i(),c=!1,l=!1,u,d=null,f=null,p=!1,m=null,h=0,g=0,_={},v=null,y=e=>{try{t(e)}catch{}},b=(e,t)=>({v:1,kind:e,engine_version:r,enabled_via:n,bail:t,...v}),x=e=>{f=null;let t=u;if(t!==void 0&&e===t)return;let n=i();t===null&&m!==null&&(h+=n-m,m=null),e===null?m=n:_[e]=(_[e]??0)+1,t!==void 0&&(g+=1),e===null&&!p?(p=!0,y({...b(`first_drive`,null),...t===void 0?{}:{prev_bail:t}})):t!==void 0&&y({...b(`transition`,e),prev_bail:t}),u=e},S=e=>{let t=i(),n=h+(m===null?0:t-m);y({...b(`summary`,u??d??null),driving_ms:Math.round(n),total_ms:Math.round(t-s),bail_counts:{..._},transitions:g,...e?{final:!0}:{}})},C=setInterval(()=>S(!1),o);return{update(e,t){if(c)return;t!==null&&(v=UI(t));let n=f===null?u:d;n!==void 0&&e===n||(d=e,f!==null&&clearTimeout(f),f=setTimeout(()=>x(e),a))},error(e){c||l||(l=!0,y({...b(`error`,`engine-error`),error:e}))},dispose(){c||(c=!0,clearInterval(C),f!==null&&(clearTimeout(f),x(d)),S(!0))}}}function GI({enabled:e,enabledVia:t,bail:n,resolution:r,engineError:i}){let a=Th(),o=Qg(),s=I(av),c=N({daily:a,meetingState:o,conversation:s});c.current={daily:a,meetingState:o,conversation:s};let l=N(null);M(()=>{if(!e)return;let n=WI({enabledVia:t,send:e=>{try{let t=c.current;if(!t.daily||t.meetingState!==`joined-meeting`)return;let n=t.conversation?.session.peek()?.conversationId;if(!n)return;t.daily.sendAppMessage(HI(n,e),`*`)}catch{}}});return l.current=n,()=>{l.current=null,n.dispose()}},[e,t]),M(()=>{l.current?.update(n,r)},[n,r]),M(()=>{i!==null&&l.current?.error(i)},[i])}var KI=(e,t)=>{let n=Array(e.length+t.length);for(let t=0;t<e.length;t++)n[t]=e[t];for(let r=0;r<t.length;r++)n[e.length+r]=t[r];return n},qI=(e,t)=>({classGroupId:e,validator:t}),JI=(e=new Map,t=null,n)=>({nextPart:e,validators:t,classGroupId:n}),YI=`-`,XI=[],ZI=`arbitrary..`,QI=e=>{let t=tL(e),{conflictingClassGroups:n,conflictingClassGroupModifiers:r}=e;return{getClassGroupId:e=>{if(e.startsWith(`[`)&&e.endsWith(`]`))return eL(e);let n=e.split(YI);return $I(n,+(n[0]===``&&n.length>1),t)},getConflictingClassGroupIds:(e,t)=>{if(t){let t=r[e],i=n[e];return t?i?KI(i,t):t:i||XI}return n[e]||XI}}},$I=(e,t,n)=>{if(e.length-t===0)return n.classGroupId;let r=e[t],i=n.nextPart.get(r);if(i){let n=$I(e,t+1,i);if(n)return n}let a=n.validators;if(a===null)return;let o=t===0?e.join(YI):e.slice(t).join(YI),s=a.length;for(let e=0;e<s;e++){let t=a[e];if(t.validator(o))return t.classGroupId}},eL=e=>e.slice(1,-1).indexOf(`:`)===-1?void 0:(()=>{let t=e.slice(1,-1),n=t.indexOf(`:`),r=t.slice(0,n);return r?ZI+r:void 0})(),tL=e=>{let{theme:t,classGroups:n}=e;return nL(n,t)},nL=(e,t)=>{let n=JI();for(let r in e){let i=e[r];rL(i,n,r,t)}return n},rL=(e,t,n,r)=>{let i=e.length;for(let a=0;a<i;a++){let i=e[a];iL(i,t,n,r)}},iL=(e,t,n,r)=>{if(typeof e==`string`){aL(e,t,n);return}if(typeof e==`function`){oL(e,t,n,r);return}sL(e,t,n,r)},aL=(e,t,n)=>{let r=e===``?t:cL(t,e);r.classGroupId=n},oL=(e,t,n,r)=>{if(lL(e)){rL(e(r),t,n,r);return}t.validators===null&&(t.validators=[]),t.validators.push(qI(n,e))},sL=(e,t,n,r)=>{let i=Object.entries(e),a=i.length;for(let e=0;e<a;e++){let[a,o]=i[e];rL(o,cL(t,a),n,r)}},cL=(e,t)=>{let n=e,r=t.split(YI),i=r.length;for(let e=0;e<i;e++){let t=r[e],i=n.nextPart.get(t);i||(i=JI(),n.nextPart.set(t,i)),n=i}return n},lL=e=>`isThemeGetter`in e&&e.isThemeGetter===!0,uL=e=>{if(e<1)return{get:()=>void 0,set:()=>{}};let t=0,n=Object.create(null),r=Object.create(null),i=(i,a)=>{n[i]=a,t++,t>e&&(t=0,r=n,n=Object.create(null))};return{get(e){let t=n[e];if(t!==void 0)return t;if((t=r[e])!==void 0)return i(e,t),t},set(e,t){e in n?n[e]=t:i(e,t)}}},dL=`!`,fL=`:`,pL=[],mL=(e,t,n,r,i)=>({modifiers:e,hasImportantModifier:t,baseClassName:n,maybePostfixModifierPosition:r,isExternal:i}),hL=e=>{let{prefix:t,experimentalParseClassName:n}=e,r=e=>{let t=[],n=0,r=0,i=0,a,o=e.length;for(let s=0;s<o;s++){let o=e[s];if(n===0&&r===0){if(o===fL){t.push(e.slice(i,s)),i=s+1;continue}if(o===`/`){a=s;continue}}o===`[`?n++:o===`]`?n--:o===`(`?r++:o===`)`&&r--}let s=t.length===0?e:e.slice(i),c=s,l=!1;s.endsWith(dL)?(c=s.slice(0,-1),l=!0):s.startsWith(dL)&&(c=s.slice(1),l=!0);let u=a&&a>i?a-i:void 0;return mL(t,l,c,u)};if(t){let e=t+fL,n=r;r=t=>t.startsWith(e)?n(t.slice(e.length)):mL(pL,!1,t,void 0,!0)}if(n){let e=r;r=t=>n({className:t,parseClassName:e})}return r},gL=e=>{let t=new Map;return e.orderSensitiveModifiers.forEach((e,n)=>{t.set(e,1e6+n)}),e=>{let n=[],r=[];for(let i=0;i<e.length;i++){let a=e[i],o=a[0]===`[`,s=t.has(a);o||s?(r.length>0&&(r.sort(),n.push(...r),r=[]),n.push(a)):r.push(a)}return r.length>0&&(r.sort(),n.push(...r)),n}},_L=e=>({cache:uL(e.cacheSize),parseClassName:hL(e),sortModifiers:gL(e),postfixLookupClassGroupIds:vL(e),...QI(e)}),vL=e=>{let t=Object.create(null),n=e.postfixLookupClassGroups;if(n)for(let e=0;e<n.length;e++)t[n[e]]=!0;return t},yL=/\s+/,bL=(e,t)=>{let{parseClassName:n,getClassGroupId:r,getConflictingClassGroupIds:i,sortModifiers:a,postfixLookupClassGroupIds:o}=t,s=[],c=e.trim().split(yL),l=``;for(let e=c.length-1;e>=0;--e){let t=c[e],{isExternal:u,modifiers:d,hasImportantModifier:f,baseClassName:p,maybePostfixModifierPosition:m}=n(t);if(u){l=t+(l.length>0?` `+l:l);continue}let h=!!m,g;if(h){g=r(p.substring(0,m));let e=g&&o[g]?r(p):void 0;e&&e!==g&&(g=e,h=!1)}else g=r(p);if(!g){if(!h){l=t+(l.length>0?` `+l:l);continue}if(g=r(p),!g){l=t+(l.length>0?` `+l:l);continue}h=!1}let _=d.length===0?``:d.length===1?d[0]:a(d).join(`:`),v=f?_+dL:_,y=v+g;if(s.indexOf(y)>-1)continue;s.push(y);let b=i(g,h);for(let e=0;e<b.length;++e){let t=b[e];s.push(v+t)}l=t+(l.length>0?` `+l:l)}return l},xL=(...e)=>{let t=0,n,r,i=``;for(;t<e.length;)(n=e[t++])&&(r=SL(n))&&(i&&(i+=` `),i+=r);return i},SL=e=>{if(typeof e==`string`)return e;let t,n=``;for(let r=0;r<e.length;r++)e[r]&&(t=SL(e[r]))&&(n&&(n+=` `),n+=t);return n},CL=(e,...t)=>{let n,r,i,a,o=o=>(n=_L(t.reduce((e,t)=>t(e),e())),r=n.cache.get,i=n.cache.set,a=s,s(o)),s=e=>{let t=r(e);if(t)return t;let a=bL(e,n);return i(e,a),a};return a=o,(...e)=>a(xL(...e))},wL=[],TL=e=>{let t=t=>t[e]||wL;return t.isThemeGetter=!0,t},EL=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,DL=/^\((?:(\w[\w-]*):)?(.+)\)$/i,OL=/^\d+(?:\.\d+)?\/\d+(?:\.\d+)?$/,kL=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,AL=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,jL=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,ML=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,NL=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,PL=e=>OL.test(e),FL=e=>!!e&&!Number.isNaN(Number(e)),IL=e=>!!e&&Number.isInteger(Number(e)),LL=e=>e.endsWith(`%`)&&FL(e.slice(0,-1)),RL=e=>kL.test(e),zL=()=>!0,BL=e=>AL.test(e)&&!jL.test(e),VL=()=>!1,HL=e=>ML.test(e),UL=e=>NL.test(e),WL=e=>!Q(e)&&!$(e),GL=e=>e.startsWith(`@container`)&&(e[10]===`/`&&e[11]!==void 0||e[11]===`s`&&e[16]!==void 0&&e.startsWith(`-size/`,10)||e[11]===`n`&&e[18]!==void 0&&e.startsWith(`-normal/`,10)),KL=e=>sR(e,dR,VL),Q=e=>EL.test(e),qL=e=>sR(e,fR,BL),JL=e=>sR(e,pR,FL),YL=e=>sR(e,hR,zL),XL=e=>sR(e,mR,VL),ZL=e=>sR(e,lR,VL),QL=e=>sR(e,uR,UL),$L=e=>sR(e,gR,HL),$=e=>DL.test(e),eR=e=>cR(e,fR),tR=e=>cR(e,mR),nR=e=>cR(e,lR),rR=e=>cR(e,dR),iR=e=>cR(e,uR),aR=e=>cR(e,gR,!0),oR=e=>cR(e,hR,!0),sR=(e,t,n)=>{let r=EL.exec(e);return r?r[1]?t(r[1]):n(r[2]):!1},cR=(e,t,n=!1)=>{let r=DL.exec(e);return r?r[1]?t(r[1]):n:!1},lR=e=>e===`position`||e===`percentage`,uR=e=>e===`image`||e===`url`,dR=e=>e===`length`||e===`size`||e===`bg-size`,fR=e=>e===`length`,pR=e=>e===`number`,mR=e=>e===`family-name`,hR=e=>e===`number`||e===`weight`,gR=e=>e===`shadow`,_R=CL(()=>{let e=TL(`color`),t=TL(`font`),n=TL(`text`),r=TL(`font-weight`),i=TL(`tracking`),a=TL(`leading`),o=TL(`breakpoint`),s=TL(`container`),c=TL(`spacing`),l=TL(`radius`),u=TL(`shadow`),d=TL(`inset-shadow`),f=TL(`text-shadow`),p=TL(`drop-shadow`),m=TL(`blur`),h=TL(`perspective`),g=TL(`aspect`),_=TL(`ease`),v=TL(`animate`),y=()=>[`auto`,`avoid`,`all`,`avoid-page`,`page`,`left`,`right`,`column`],b=()=>[`center`,`top`,`bottom`,`left`,`right`,`top-left`,`left-top`,`top-right`,`right-top`,`bottom-right`,`right-bottom`,`bottom-left`,`left-bottom`],x=()=>[...b(),$,Q],S=()=>[`auto`,`hidden`,`clip`,`visible`,`scroll`],C=()=>[`auto`,`contain`,`none`],w=()=>[$,Q,c],T=()=>[PL,`full`,`auto`,...w()],E=()=>[IL,`none`,`subgrid`,$,Q],D=()=>[`auto`,{span:[`full`,IL,$,Q]},IL,$,Q],ee=()=>[IL,`auto`,$,Q],te=()=>[`auto`,`min`,`max`,`fr`,$,Q],ne=()=>[`start`,`end`,`center`,`between`,`around`,`evenly`,`stretch`,`baseline`,`center-safe`,`end-safe`],re=()=>[`start`,`end`,`center`,`stretch`,`center-safe`,`end-safe`],O=()=>[`auto`,...w()],ie=()=>[PL,`auto`,`full`,`dvw`,`dvh`,`lvw`,`lvh`,`svw`,`svh`,`min`,`max`,`fit`,...w()],ae=()=>[PL,`screen`,`full`,`dvw`,`lvw`,`svw`,`min`,`max`,`fit`,...w()],k=()=>[PL,`screen`,`full`,`lh`,`dvh`,`lvh`,`svh`,`min`,`max`,`fit`,...w()],A=()=>[e,$,Q],oe=()=>[...b(),nR,ZL,{position:[$,Q]}],se=()=>[`no-repeat`,{repeat:[``,`x`,`y`,`space`,`round`]}],ce=()=>[`auto`,`cover`,`contain`,rR,KL,{size:[$,Q]}],le=()=>[LL,eR,qL],ue=()=>[``,`none`,`full`,l,$,Q],de=()=>[``,FL,eR,qL],fe=()=>[`solid`,`dashed`,`dotted`,`double`],pe=()=>[`normal`,`multiply`,`screen`,`overlay`,`darken`,`lighten`,`color-dodge`,`color-burn`,`hard-light`,`soft-light`,`difference`,`exclusion`,`hue`,`saturation`,`color`,`luminosity`],me=()=>[FL,LL,nR,ZL],he=()=>[``,`none`,m,$,Q],ge=()=>[`none`,FL,$,Q],_e=()=>[`none`,FL,$,Q],ve=()=>[FL,$,Q],ye=()=>[PL,`full`,...w()];return{cacheSize:500,theme:{animate:[`spin`,`ping`,`pulse`,`bounce`],aspect:[`video`],blur:[RL],breakpoint:[RL],color:[zL],container:[RL],"drop-shadow":[RL],ease:[`in`,`out`,`in-out`],font:[WL],"font-weight":[`thin`,`extralight`,`light`,`normal`,`medium`,`semibold`,`bold`,`extrabold`,`black`],"inset-shadow":[RL],leading:[`none`,`tight`,`snug`,`normal`,`relaxed`,`loose`],perspective:[`dramatic`,`near`,`normal`,`midrange`,`distant`,`none`],radius:[RL],shadow:[RL],spacing:[`px`,FL],text:[RL],"text-shadow":[RL],tracking:[`tighter`,`tight`,`normal`,`wide`,`wider`,`widest`]},classGroups:{aspect:[{aspect:[`auto`,`square`,PL,Q,$,g]}],container:[`container`],"container-type":[{"@container":[``,`normal`,`size`,$,Q]}],"container-named":[GL],columns:[{columns:[FL,Q,$,s]}],"break-after":[{"break-after":y()}],"break-before":[{"break-before":y()}],"break-inside":[{"break-inside":[`auto`,`avoid`,`avoid-page`,`avoid-column`]}],"box-decoration":[{"box-decoration":[`slice`,`clone`]}],box:[{box:[`border`,`content`]}],display:[`block`,`inline-block`,`inline`,`flex`,`inline-flex`,`table`,`inline-table`,`table-caption`,`table-cell`,`table-column`,`table-column-group`,`table-footer-group`,`table-header-group`,`table-row-group`,`table-row`,`flow-root`,`grid`,`inline-grid`,`contents`,`list-item`,`hidden`],sr:[`sr-only`,`not-sr-only`],float:[{float:[`right`,`left`,`none`,`start`,`end`]}],clear:[{clear:[`left`,`right`,`both`,`none`,`start`,`end`]}],isolation:[`isolate`,`isolation-auto`],"object-fit":[{object:[`contain`,`cover`,`fill`,`none`,`scale-down`]}],"object-position":[{object:x()}],overflow:[{overflow:S()}],"overflow-x":[{"overflow-x":S()}],"overflow-y":[{"overflow-y":S()}],overscroll:[{overscroll:C()}],"overscroll-x":[{"overscroll-x":C()}],"overscroll-y":[{"overscroll-y":C()}],position:[`static`,`fixed`,`absolute`,`relative`,`sticky`],inset:[{inset:T()}],"inset-x":[{"inset-x":T()}],"inset-y":[{"inset-y":T()}],start:[{"inset-s":T(),start:T()}],end:[{"inset-e":T(),end:T()}],"inset-bs":[{"inset-bs":T()}],"inset-be":[{"inset-be":T()}],top:[{top:T()}],right:[{right:T()}],bottom:[{bottom:T()}],left:[{left:T()}],visibility:[`visible`,`invisible`,`collapse`],z:[{z:[IL,`auto`,$,Q]}],basis:[{basis:[PL,`full`,`auto`,s,...w()]}],"flex-direction":[{flex:[`row`,`row-reverse`,`col`,`col-reverse`]}],"flex-wrap":[{flex:[`nowrap`,`wrap`,`wrap-reverse`]}],flex:[{flex:[FL,PL,`auto`,`initial`,`none`,Q]}],grow:[{grow:[``,FL,$,Q]}],shrink:[{shrink:[``,FL,$,Q]}],order:[{order:[IL,`first`,`last`,`none`,$,Q]}],"grid-cols":[{"grid-cols":E()}],"col-start-end":[{col:D()}],"col-start":[{"col-start":ee()}],"col-end":[{"col-end":ee()}],"grid-rows":[{"grid-rows":E()}],"row-start-end":[{row:D()}],"row-start":[{"row-start":ee()}],"row-end":[{"row-end":ee()}],"grid-flow":[{"grid-flow":[`row`,`col`,`dense`,`row-dense`,`col-dense`]}],"auto-cols":[{"auto-cols":te()}],"auto-rows":[{"auto-rows":te()}],gap:[{gap:w()}],"gap-x":[{"gap-x":w()}],"gap-y":[{"gap-y":w()}],"justify-content":[{justify:[...ne(),`normal`]}],"justify-items":[{"justify-items":[...re(),`normal`]}],"justify-self":[{"justify-self":[`auto`,...re()]}],"align-content":[{content:[`normal`,...ne()]}],"align-items":[{items:[...re(),{baseline:[``,`last`]}]}],"align-self":[{self:[`auto`,...re(),{baseline:[``,`last`]}]}],"place-content":[{"place-content":ne()}],"place-items":[{"place-items":[...re(),`baseline`]}],"place-self":[{"place-self":[`auto`,...re()]}],p:[{p:w()}],px:[{px:w()}],py:[{py:w()}],ps:[{ps:w()}],pe:[{pe:w()}],pbs:[{pbs:w()}],pbe:[{pbe:w()}],pt:[{pt:w()}],pr:[{pr:w()}],pb:[{pb:w()}],pl:[{pl:w()}],m:[{m:O()}],mx:[{mx:O()}],my:[{my:O()}],ms:[{ms:O()}],me:[{me:O()}],mbs:[{mbs:O()}],mbe:[{mbe:O()}],mt:[{mt:O()}],mr:[{mr:O()}],mb:[{mb:O()}],ml:[{ml:O()}],"space-x":[{"space-x":w()}],"space-x-reverse":[`space-x-reverse`],"space-y":[{"space-y":w()}],"space-y-reverse":[`space-y-reverse`],size:[{size:ie()}],"inline-size":[{inline:[`auto`,...ae()]}],"min-inline-size":[{"min-inline":[`auto`,...ae()]}],"max-inline-size":[{"max-inline":[`none`,...ae()]}],"block-size":[{block:[`auto`,...k()]}],"min-block-size":[{"min-block":[`auto`,...k()]}],"max-block-size":[{"max-block":[`none`,...k()]}],w:[{w:[s,`screen`,...ie()]}],"min-w":[{"min-w":[s,`screen`,`none`,...ie()]}],"max-w":[{"max-w":[s,`screen`,`none`,`prose`,{screen:[o]},...ie()]}],h:[{h:[`screen`,`lh`,...ie()]}],"min-h":[{"min-h":[`screen`,`lh`,`none`,...ie()]}],"max-h":[{"max-h":[`screen`,`lh`,...ie()]}],"font-size":[{text:[`base`,n,eR,qL]}],"font-smoothing":[`antialiased`,`subpixel-antialiased`],"font-style":[`italic`,`not-italic`],"font-weight":[{font:[r,oR,YL]}],"font-stretch":[{"font-stretch":[`ultra-condensed`,`extra-condensed`,`condensed`,`semi-condensed`,`normal`,`semi-expanded`,`expanded`,`extra-expanded`,`ultra-expanded`,LL,Q]}],"font-family":[{font:[tR,XL,t]}],"font-features":[{"font-features":[Q]}],"fvn-normal":[`normal-nums`],"fvn-ordinal":[`ordinal`],"fvn-slashed-zero":[`slashed-zero`],"fvn-figure":[`lining-nums`,`oldstyle-nums`],"fvn-spacing":[`proportional-nums`,`tabular-nums`],"fvn-fraction":[`diagonal-fractions`,`stacked-fractions`],tracking:[{tracking:[i,$,Q]}],"line-clamp":[{"line-clamp":[FL,`none`,$,JL]}],leading:[{leading:[a,...w()]}],"list-image":[{"list-image":[`none`,$,Q]}],"list-style-position":[{list:[`inside`,`outside`]}],"list-style-type":[{list:[`disc`,`decimal`,`none`,$,Q]}],"text-alignment":[{text:[`left`,`center`,`right`,`justify`,`start`,`end`]}],"placeholder-color":[{placeholder:A()}],"text-color":[{text:A()}],"text-decoration":[`underline`,`overline`,`line-through`,`no-underline`],"text-decoration-style":[{decoration:[...fe(),`wavy`]}],"text-decoration-thickness":[{decoration:[FL,`from-font`,`auto`,$,qL]}],"text-decoration-color":[{decoration:A()}],"underline-offset":[{"underline-offset":[FL,`auto`,$,Q]}],"text-transform":[`uppercase`,`lowercase`,`capitalize`,`normal-case`],"text-overflow":[`truncate`,`text-ellipsis`,`text-clip`],"text-wrap":[{text:[`wrap`,`nowrap`,`balance`,`pretty`]}],indent:[{indent:w()}],"tab-size":[{tab:[IL,$,Q]}],"vertical-align":[{align:[`baseline`,`top`,`middle`,`bottom`,`text-top`,`text-bottom`,`sub`,`super`,$,Q]}],whitespace:[{whitespace:[`normal`,`nowrap`,`pre`,`pre-line`,`pre-wrap`,`break-spaces`]}],break:[{break:[`normal`,`words`,`all`,`keep`]}],wrap:[{wrap:[`break-word`,`anywhere`,`normal`]}],hyphens:[{hyphens:[`none`,`manual`,`auto`]}],content:[{content:[`none`,$,Q]}],"bg-attachment":[{bg:[`fixed`,`local`,`scroll`]}],"bg-clip":[{"bg-clip":[`border`,`padding`,`content`,`text`]}],"bg-origin":[{"bg-origin":[`border`,`padding`,`content`]}],"bg-position":[{bg:oe()}],"bg-repeat":[{bg:se()}],"bg-size":[{bg:ce()}],"bg-image":[{bg:[`none`,{linear:[{to:[`t`,`tr`,`r`,`br`,`b`,`bl`,`l`,`tl`]},IL,$,Q],radial:[``,$,Q],conic:[IL,$,Q]},iR,QL]}],"bg-color":[{bg:A()}],"gradient-from-pos":[{from:le()}],"gradient-via-pos":[{via:le()}],"gradient-to-pos":[{to:le()}],"gradient-from":[{from:A()}],"gradient-via":[{via:A()}],"gradient-to":[{to:A()}],rounded:[{rounded:ue()}],"rounded-s":[{"rounded-s":ue()}],"rounded-e":[{"rounded-e":ue()}],"rounded-t":[{"rounded-t":ue()}],"rounded-r":[{"rounded-r":ue()}],"rounded-b":[{"rounded-b":ue()}],"rounded-l":[{"rounded-l":ue()}],"rounded-ss":[{"rounded-ss":ue()}],"rounded-se":[{"rounded-se":ue()}],"rounded-ee":[{"rounded-ee":ue()}],"rounded-es":[{"rounded-es":ue()}],"rounded-tl":[{"rounded-tl":ue()}],"rounded-tr":[{"rounded-tr":ue()}],"rounded-br":[{"rounded-br":ue()}],"rounded-bl":[{"rounded-bl":ue()}],"border-w":[{border:de()}],"border-w-x":[{"border-x":de()}],"border-w-y":[{"border-y":de()}],"border-w-s":[{"border-s":de()}],"border-w-e":[{"border-e":de()}],"border-w-bs":[{"border-bs":de()}],"border-w-be":[{"border-be":de()}],"border-w-t":[{"border-t":de()}],"border-w-r":[{"border-r":de()}],"border-w-b":[{"border-b":de()}],"border-w-l":[{"border-l":de()}],"divide-x":[{"divide-x":de()}],"divide-x-reverse":[`divide-x-reverse`],"divide-y":[{"divide-y":de()}],"divide-y-reverse":[`divide-y-reverse`],"border-style":[{border:[...fe(),`hidden`,`none`]}],"divide-style":[{divide:[...fe(),`hidden`,`none`]}],"border-color":[{border:A()}],"border-color-x":[{"border-x":A()}],"border-color-y":[{"border-y":A()}],"border-color-s":[{"border-s":A()}],"border-color-e":[{"border-e":A()}],"border-color-bs":[{"border-bs":A()}],"border-color-be":[{"border-be":A()}],"border-color-t":[{"border-t":A()}],"border-color-r":[{"border-r":A()}],"border-color-b":[{"border-b":A()}],"border-color-l":[{"border-l":A()}],"divide-color":[{divide:A()}],"outline-style":[{outline:[...fe(),`none`,`hidden`]}],"outline-offset":[{"outline-offset":[FL,$,Q]}],"outline-w":[{outline:[``,FL,eR,qL]}],"outline-color":[{outline:A()}],shadow:[{shadow:[``,`none`,u,aR,$L]}],"shadow-color":[{shadow:A()}],"inset-shadow":[{"inset-shadow":[`none`,d,aR,$L]}],"inset-shadow-color":[{"inset-shadow":A()}],"ring-w":[{ring:de()}],"ring-w-inset":[`ring-inset`],"ring-color":[{ring:A()}],"ring-offset-w":[{"ring-offset":[FL,qL]}],"ring-offset-color":[{"ring-offset":A()}],"inset-ring-w":[{"inset-ring":de()}],"inset-ring-color":[{"inset-ring":A()}],"text-shadow":[{"text-shadow":[`none`,f,aR,$L]}],"text-shadow-color":[{"text-shadow":A()}],opacity:[{opacity:[FL,$,Q]}],"mix-blend":[{"mix-blend":[...pe(),`plus-darker`,`plus-lighter`]}],"bg-blend":[{"bg-blend":pe()}],"mask-clip":[{"mask-clip":[`border`,`padding`,`content`,`fill`,`stroke`,`view`]},`mask-no-clip`],"mask-composite":[{mask:[`add`,`subtract`,`intersect`,`exclude`]}],"mask-image-linear-pos":[{"mask-linear":[FL]}],"mask-image-linear-from-pos":[{"mask-linear-from":me()}],"mask-image-linear-to-pos":[{"mask-linear-to":me()}],"mask-image-linear-from-color":[{"mask-linear-from":A()}],"mask-image-linear-to-color":[{"mask-linear-to":A()}],"mask-image-t-from-pos":[{"mask-t-from":me()}],"mask-image-t-to-pos":[{"mask-t-to":me()}],"mask-image-t-from-color":[{"mask-t-from":A()}],"mask-image-t-to-color":[{"mask-t-to":A()}],"mask-image-r-from-pos":[{"mask-r-from":me()}],"mask-image-r-to-pos":[{"mask-r-to":me()}],"mask-image-r-from-color":[{"mask-r-from":A()}],"mask-image-r-to-color":[{"mask-r-to":A()}],"mask-image-b-from-pos":[{"mask-b-from":me()}],"mask-image-b-to-pos":[{"mask-b-to":me()}],"mask-image-b-from-color":[{"mask-b-from":A()}],"mask-image-b-to-color":[{"mask-b-to":A()}],"mask-image-l-from-pos":[{"mask-l-from":me()}],"mask-image-l-to-pos":[{"mask-l-to":me()}],"mask-image-l-from-color":[{"mask-l-from":A()}],"mask-image-l-to-color":[{"mask-l-to":A()}],"mask-image-x-from-pos":[{"mask-x-from":me()}],"mask-image-x-to-pos":[{"mask-x-to":me()}],"mask-image-x-from-color":[{"mask-x-from":A()}],"mask-image-x-to-color":[{"mask-x-to":A()}],"mask-image-y-from-pos":[{"mask-y-from":me()}],"mask-image-y-to-pos":[{"mask-y-to":me()}],"mask-image-y-from-color":[{"mask-y-from":A()}],"mask-image-y-to-color":[{"mask-y-to":A()}],"mask-image-radial":[{"mask-radial":[$,Q]}],"mask-image-radial-from-pos":[{"mask-radial-from":me()}],"mask-image-radial-to-pos":[{"mask-radial-to":me()}],"mask-image-radial-from-color":[{"mask-radial-from":A()}],"mask-image-radial-to-color":[{"mask-radial-to":A()}],"mask-image-radial-shape":[{"mask-radial":[`circle`,`ellipse`]}],"mask-image-radial-size":[{"mask-radial":[{closest:[`side`,`corner`],farthest:[`side`,`corner`]}]}],"mask-image-radial-pos":[{"mask-radial-at":b()}],"mask-image-conic-pos":[{"mask-conic":[FL]}],"mask-image-conic-from-pos":[{"mask-conic-from":me()}],"mask-image-conic-to-pos":[{"mask-conic-to":me()}],"mask-image-conic-from-color":[{"mask-conic-from":A()}],"mask-image-conic-to-color":[{"mask-conic-to":A()}],"mask-mode":[{mask:[`alpha`,`luminance`,`match`]}],"mask-origin":[{"mask-origin":[`border`,`padding`,`content`,`fill`,`stroke`,`view`]}],"mask-position":[{mask:oe()}],"mask-repeat":[{mask:se()}],"mask-size":[{mask:ce()}],"mask-type":[{"mask-type":[`alpha`,`luminance`]}],"mask-image":[{mask:[`none`,$,Q]}],filter:[{filter:[``,`none`,$,Q]}],blur:[{blur:he()}],brightness:[{brightness:[FL,$,Q]}],contrast:[{contrast:[FL,$,Q]}],"drop-shadow":[{"drop-shadow":[``,`none`,p,aR,$L]}],"drop-shadow-color":[{"drop-shadow":A()}],grayscale:[{grayscale:[``,FL,$,Q]}],"hue-rotate":[{"hue-rotate":[FL,$,Q]}],invert:[{invert:[``,FL,$,Q]}],saturate:[{saturate:[FL,$,Q]}],sepia:[{sepia:[``,FL,$,Q]}],"backdrop-filter":[{"backdrop-filter":[``,`none`,$,Q]}],"backdrop-blur":[{"backdrop-blur":he()}],"backdrop-brightness":[{"backdrop-brightness":[FL,$,Q]}],"backdrop-contrast":[{"backdrop-contrast":[FL,$,Q]}],"backdrop-grayscale":[{"backdrop-grayscale":[``,FL,$,Q]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[FL,$,Q]}],"backdrop-invert":[{"backdrop-invert":[``,FL,$,Q]}],"backdrop-opacity":[{"backdrop-opacity":[FL,$,Q]}],"backdrop-saturate":[{"backdrop-saturate":[FL,$,Q]}],"backdrop-sepia":[{"backdrop-sepia":[``,FL,$,Q]}],"border-collapse":[{border:[`collapse`,`separate`]}],"border-spacing":[{"border-spacing":w()}],"border-spacing-x":[{"border-spacing-x":w()}],"border-spacing-y":[{"border-spacing-y":w()}],"table-layout":[{table:[`auto`,`fixed`]}],caption:[{caption:[`top`,`bottom`]}],transition:[{transition:[``,`all`,`colors`,`opacity`,`shadow`,`transform`,`none`,$,Q]}],"transition-behavior":[{transition:[`normal`,`discrete`]}],duration:[{duration:[FL,`initial`,$,Q]}],ease:[{ease:[`linear`,`initial`,_,$,Q]}],delay:[{delay:[FL,$,Q]}],animate:[{animate:[`none`,v,$,Q]}],backface:[{backface:[`hidden`,`visible`]}],perspective:[{perspective:[h,$,Q]}],"perspective-origin":[{"perspective-origin":x()}],rotate:[{rotate:ge()}],"rotate-x":[{"rotate-x":ge()}],"rotate-y":[{"rotate-y":ge()}],"rotate-z":[{"rotate-z":ge()}],scale:[{scale:_e()}],"scale-x":[{"scale-x":_e()}],"scale-y":[{"scale-y":_e()}],"scale-z":[{"scale-z":_e()}],"scale-3d":[`scale-3d`],skew:[{skew:ve()}],"skew-x":[{"skew-x":ve()}],"skew-y":[{"skew-y":ve()}],transform:[{transform:[$,Q,``,`none`,`gpu`,`cpu`]}],"transform-origin":[{origin:x()}],"transform-style":[{transform:[`3d`,`flat`]}],translate:[{translate:ye()}],"translate-x":[{"translate-x":ye()}],"translate-y":[{"translate-y":ye()}],"translate-z":[{"translate-z":ye()}],"translate-none":[`translate-none`],zoom:[{zoom:[IL,$,Q]}],accent:[{accent:A()}],appearance:[{appearance:[`none`,`auto`]}],"caret-color":[{caret:A()}],"color-scheme":[{scheme:[`normal`,`dark`,`light`,`light-dark`,`only-dark`,`only-light`]}],cursor:[{cursor:[`auto`,`default`,`pointer`,`wait`,`text`,`move`,`help`,`not-allowed`,`none`,`context-menu`,`progress`,`cell`,`crosshair`,`vertical-text`,`alias`,`copy`,`no-drop`,`grab`,`grabbing`,`all-scroll`,`col-resize`,`row-resize`,`n-resize`,`e-resize`,`s-resize`,`w-resize`,`ne-resize`,`nw-resize`,`se-resize`,`sw-resize`,`ew-resize`,`ns-resize`,`nesw-resize`,`nwse-resize`,`zoom-in`,`zoom-out`,$,Q]}],"field-sizing":[{"field-sizing":[`fixed`,`content`]}],"pointer-events":[{"pointer-events":[`auto`,`none`]}],resize:[{resize:[`none`,``,`y`,`x`]}],"scroll-behavior":[{scroll:[`auto`,`smooth`]}],"scrollbar-thumb-color":[{"scrollbar-thumb":A()}],"scrollbar-track-color":[{"scrollbar-track":A()}],"scrollbar-gutter":[{"scrollbar-gutter":[`auto`,`stable`,`both`]}],"scrollbar-w":[{scrollbar:[`auto`,`thin`,`none`]}],"scroll-m":[{"scroll-m":w()}],"scroll-mx":[{"scroll-mx":w()}],"scroll-my":[{"scroll-my":w()}],"scroll-ms":[{"scroll-ms":w()}],"scroll-me":[{"scroll-me":w()}],"scroll-mbs":[{"scroll-mbs":w()}],"scroll-mbe":[{"scroll-mbe":w()}],"scroll-mt":[{"scroll-mt":w()}],"scroll-mr":[{"scroll-mr":w()}],"scroll-mb":[{"scroll-mb":w()}],"scroll-ml":[{"scroll-ml":w()}],"scroll-p":[{"scroll-p":w()}],"scroll-px":[{"scroll-px":w()}],"scroll-py":[{"scroll-py":w()}],"scroll-ps":[{"scroll-ps":w()}],"scroll-pe":[{"scroll-pe":w()}],"scroll-pbs":[{"scroll-pbs":w()}],"scroll-pbe":[{"scroll-pbe":w()}],"scroll-pt":[{"scroll-pt":w()}],"scroll-pr":[{"scroll-pr":w()}],"scroll-pb":[{"scroll-pb":w()}],"scroll-pl":[{"scroll-pl":w()}],"snap-align":[{snap:[`start`,`end`,`center`,`align-none`]}],"snap-stop":[{snap:[`normal`,`always`]}],"snap-type":[{snap:[`none`,`x`,`y`,`both`]}],"snap-strictness":[{snap:[`mandatory`,`proximity`]}],touch:[{touch:[`auto`,`none`,`manipulation`]}],"touch-x":[{"touch-pan":[`x`,`left`,`right`]}],"touch-y":[{"touch-pan":[`y`,`up`,`down`]}],"touch-pz":[`touch-pinch-zoom`],select:[{select:[`none`,`text`,`all`,`auto`]}],"will-change":[{"will-change":[`auto`,`scroll`,`contents`,`transform`,$,Q]}],fill:[{fill:[`none`,...A()]}],"stroke-w":[{stroke:[FL,eR,qL,JL]}],stroke:[{stroke:[`none`,...A()]}],"forced-color-adjust":[{"forced-color-adjust":[`auto`,`none`]}]},conflictingClassGroups:{"container-named":[`container-type`],overflow:[`overflow-x`,`overflow-y`],overscroll:[`overscroll-x`,`overscroll-y`],inset:[`inset-x`,`inset-y`,`inset-bs`,`inset-be`,`start`,`end`,`top`,`right`,`bottom`,`left`],"inset-x":[`right`,`left`],"inset-y":[`top`,`bottom`],flex:[`basis`,`grow`,`shrink`],gap:[`gap-x`,`gap-y`],p:[`px`,`py`,`ps`,`pe`,`pbs`,`pbe`,`pt`,`pr`,`pb`,`pl`],px:[`pr`,`pl`],py:[`pt`,`pb`],m:[`mx`,`my`,`ms`,`me`,`mbs`,`mbe`,`mt`,`mr`,`mb`,`ml`],mx:[`mr`,`ml`],my:[`mt`,`mb`],size:[`w`,`h`],"font-size":[`leading`],"fvn-normal":[`fvn-ordinal`,`fvn-slashed-zero`,`fvn-figure`,`fvn-spacing`,`fvn-fraction`],"fvn-ordinal":[`fvn-normal`],"fvn-slashed-zero":[`fvn-normal`],"fvn-figure":[`fvn-normal`],"fvn-spacing":[`fvn-normal`],"fvn-fraction":[`fvn-normal`],"line-clamp":[`display`,`overflow`],rounded:[`rounded-s`,`rounded-e`,`rounded-t`,`rounded-r`,`rounded-b`,`rounded-l`,`rounded-ss`,`rounded-se`,`rounded-ee`,`rounded-es`,`rounded-tl`,`rounded-tr`,`rounded-br`,`rounded-bl`],"rounded-s":[`rounded-ss`,`rounded-es`],"rounded-e":[`rounded-se`,`rounded-ee`],"rounded-t":[`rounded-tl`,`rounded-tr`],"rounded-r":[`rounded-tr`,`rounded-br`],"rounded-b":[`rounded-br`,`rounded-bl`],"rounded-l":[`rounded-tl`,`rounded-bl`],"border-spacing":[`border-spacing-x`,`border-spacing-y`],"border-w":[`border-w-x`,`border-w-y`,`border-w-s`,`border-w-e`,`border-w-bs`,`border-w-be`,`border-w-t`,`border-w-r`,`border-w-b`,`border-w-l`],"border-w-x":[`border-w-r`,`border-w-l`],"border-w-y":[`border-w-t`,`border-w-b`],"border-color":[`border-color-x`,`border-color-y`,`border-color-s`,`border-color-e`,`border-color-bs`,`border-color-be`,`border-color-t`,`border-color-r`,`border-color-b`,`border-color-l`],"border-color-x":[`border-color-r`,`border-color-l`],"border-color-y":[`border-color-t`,`border-color-b`],translate:[`translate-x`,`translate-y`,`translate-none`],"translate-none":[`translate`,`translate-x`,`translate-y`,`translate-z`],"scroll-m":[`scroll-mx`,`scroll-my`,`scroll-ms`,`scroll-me`,`scroll-mbs`,`scroll-mbe`,`scroll-mt`,`scroll-mr`,`scroll-mb`,`scroll-ml`],"scroll-mx":[`scroll-mr`,`scroll-ml`],"scroll-my":[`scroll-mt`,`scroll-mb`],"scroll-p":[`scroll-px`,`scroll-py`,`scroll-ps`,`scroll-pe`,`scroll-pbs`,`scroll-pbe`,`scroll-pt`,`scroll-pr`,`scroll-pb`,`scroll-pl`],"scroll-px":[`scroll-pr`,`scroll-pl`],"scroll-py":[`scroll-pt`,`scroll-pb`],touch:[`touch-x`,`touch-y`,`touch-pz`],"touch-x":[`touch`],"touch-y":[`touch`],"touch-pz":[`touch`]},conflictingClassGroupModifiers:{"font-size":[`leading`]},postfixLookupClassGroups:[`container-type`],orderSensitiveModifiers:[`*`,`**`,`after`,`backdrop`,`before`,`details-content`,`file`,`first-letter`,`first-line`,`marker`,`placeholder`,`selection`]}});function vR({resolution:e,inputs:t,config:n,bailReason:r}){if(e===null||t===null)return null;let i=kF[e.templateId];if(i===void 0)return null;let a=r!==null,o=a?`border-warning/70 bg-warning/5`:`border-info/80 bg-info/5`,s=a?`bg-warning/85 text-warning-content`:`bg-info/85 text-info-content`,c=a?`border-warning`:`border-success`,l=a?`bg-warning/85 text-warning-content`:`bg-success/85 text-success-content`,u=t.userShare?`userShare`:t.presentation?`presentation`:null,{regions:d}=dI(i,{state:e.state,contentKind:u},t,e.sizeClass,e.containerPx,n);return L(`div`,{class:`pointer-events-none absolute inset-0 z-40`,"aria-hidden":`true`,children:[a&&L(`span`,{class:`absolute top-1 left-1/2 -translate-x-1/2 rounded bg-warning/90 px-2 py-0.5 font-mono text-[10px] text-warning-content`,children:[`engine plan only · legacy: `,r]}),d.map(e=>L(`div`,{class:_R(`absolute rounded-box border border-dashed`,o),style:{left:`${e.rect.x}px`,top:`${e.rect.y}px`,width:`${e.rect.width}px`,height:`${e.rect.height}px`},children:L(`span`,{class:_R(`absolute top-1 left-1 flex flex-col rounded px-1.5 py-0.5 font-mono text-[10px] leading-tight`,s),children:[L(`span`,{children:e.region.name}),L(`span`,{class:`opacity-75`,children:e.region.accepts.join(` · `)})]})},e.region.name)),e.tiles.map(e=>L(`div`,{class:_R(`absolute border`,c),style:{left:`${e.rect.x}px`,top:`${e.rect.y}px`,width:`${e.rect.width}px`,height:`${e.rect.height}px`},children:L(`span`,{class:_R(`absolute right-1 bottom-1 rounded px-1.5 py-0.5 font-mono text-[10px]`,l),children:[e.kind,` `,e.rect.width,`×`,e.rect.height]})},`tile-${e.id}`))]})}function yR(e){return{version:1,buildSha:xI,engineVersion:xI,config:DF,session:{containerPx:{width:Math.round(e.container.widthPx),height:Math.round(e.container.heightPx)},slots:{replica:e.replica,selfView:e.selfView,presentation:e.presentation!==null,userShare:e.userShare!==null,callControls:e.callControls,callControlsVisible:e.callControlsVisible??!0,...e.callControlsRect===void 0?{}:{callControlsRect:e.callControlsRect}},prefs:e.prefs,cards:e.cards}}}function bR({resolution:e,inputs:t,shadowing:n,bailReason:r,engineError:i=null}){let[a,o]=j(!1),s=N(null);if(M(()=>()=>{s.current!==null&&clearTimeout(s.current)},[]),e===null||t===null)return i===null?null:L(`div`,{class:`pointer-events-auto max-w-[22rem] rounded-box bg-base-100/95 p-3 font-mono text-[10px] leading-relaxed shadow-lg`,children:[L(`div`,{class:`mb-1 flex items-center justify-between gap-2`,children:[L(`span`,{class:`font-bold uppercase tracking-wide`,children:`magic grid`}),L(`span`,{class:`text-warning`,children:`observing`})]}),L(`dl`,{class:`grid grid-cols-[5.5rem_1fr] gap-x-2`,children:[L(`dt`,{class:`text-warning opacity-80`,children:`legacy`}),L(`dd`,{class:`text-warning`,children:r}),L(`dt`,{class:`text-error opacity-80`,children:`error`}),L(`dd`,{class:`text-error break-all`,children:i})]})]});let c=()=>{let e=JSON.stringify(yR(t),null,2);s.current!==null&&clearTimeout(s.current),navigator.clipboard?.writeText(e).then(()=>{o(!0),s.current=setTimeout(()=>o(!1),1500)},()=>o(!1))},l=e.degradations.evictedCardIds;return L(`div`,{class:`pointer-events-auto max-w-[22rem] rounded-box bg-base-100/95 p-3 font-mono text-[10px] leading-relaxed shadow-lg`,children:[L(`div`,{class:`mb-1 flex items-center justify-between gap-2`,children:[L(`span`,{class:`font-bold uppercase tracking-wide`,children:`magic grid`}),L(`span`,{class:n?`text-warning`:`text-success`,children:n?`observing`:`driving`})]}),L(`dl`,{class:`grid grid-cols-[5.5rem_1fr] gap-x-2`,children:[L(`dt`,{class:`opacity-60`,children:`state`}),L(`dd`,{children:e.state}),L(`dt`,{class:`opacity-60`,children:`template`}),L(`dd`,{children:e.templateId}),L(`dt`,{class:`opacity-60`,children:`class`}),L(`dd`,{children:[e.sizeClass.width,` / `,e.sizeClass.height]}),L(`dt`,{class:`opacity-60`,children:`container`}),L(`dd`,{children:[e.containerPx.width,`×`,e.containerPx.height]}),t.callControlsRect!==void 0&&L(k,{children:[L(`dt`,{class:`opacity-60`,children:`controls`}),L(`dd`,{children:[`x `,t.callControlsRect.x,`–`,t.callControlsRect.x+t.callControlsRect.width,t.callControlsVisible===!1?` · hidden`:` · shown`]})]}),L(`dt`,{class:`opacity-60`,children:`tiles`}),L(`dd`,{children:e.tiles.map(e=>`${e.kind}:${e.rect.width}×${e.rect.height}`).join(` `)||`none`}),l.length>0&&L(k,{children:[L(`dt`,{class:`text-error opacity-80`,children:`dropped`}),L(`dd`,{class:`text-error`,children:l.join(`, `)})]}),r!==null&&L(k,{children:[L(`dt`,{class:`text-warning opacity-80`,children:`legacy`}),L(`dd`,{class:`text-warning`,children:r})]}),i!==null&&L(k,{children:[L(`dt`,{class:`text-error opacity-80`,children:`error`}),L(`dd`,{class:`text-error break-all`,children:i})]})]}),L(`button`,{type:`button`,class:`btn btn-xs mt-2 w-full`,onClick:c,children:a?`copied`:`copy envelope for playground`})]})}var xR={effect:FI,animate:!1},SR=Yt(xR),CR={presence:{phase:`connecting`},localId:null,isScreenSharing:!1,isPersonaPresenting:!1,hasPersonaVideo:!1,hasSelfView:!1};function wR(e,t){return e===null||t===null?e===t:e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function TR(e,t){let n=e.containerPx===null||t.containerPx===null?e.containerPx===t.containerPx:e.containerPx.width===t.containerPx.width&&e.containerPx.height===t.containerPx.height;return e.driving===t.driving&&e.replicaCollapsed===t.replicaCollapsed&&n&&wR(e.replica,t.replica)&&wR(e.selfView,t.selfView)&&wR(e.content,t.content)}var ER=new Map;function DR({instances:e,viewport:t,callControlsBandPx:n,callPresence:r,callControlsVisible:i,callControlsRect:a,gridConfigEnabled:o,gridStartEnabled:s}){let c=TI(o,s)&&r!==void 0,l=r??CR,u=MI({instances:e,viewport:t,presence:l,callControlsBandPx:n,callControlsVisible:i,callControlsRect:a,enabled:c}),d=c?kI.value:null,f=d===null?NI(u.resolution,l,c):`engine-error`;GI({enabled:c,enabledVia:VI(CI,o===!0,s===!0),bail:f,resolution:u.resolution,engineError:d});let p=N(!1);l.presence.phase===`ready`?l.hasPersonaVideo&&(p.current=!0):p.current=!1;let m=!p.current,h;try{h=II(u.resolution,f,m)}catch(e){AI(e),h=FI}let g=N(FI),_=RI(g.current,h);M(()=>{g.current=h,TR(SR.peek().effect,h)||(SR.value={effect:h,animate:_})}),M(()=>()=>{jI(),SR.peek()!==xR&&(SR.value=xR)},[]);let v=u.resolution,y=P(()=>{if(f!==null||v===null)return ER;try{let e=new Map;for(let t of v.tiles)t.kind===`card`&&e.set(t.id,t.rect);return e}catch(e){return AI(e),ER}},[f,v]),b=wI?L(`div`,{class:`contents`,"data-grid-debug":!0,children:[L(vR,{resolution:u.resolution,inputs:u.inputs,config:DF,bailReason:f}),L(`div`,{class:`pointer-events-none absolute bottom-4 left-4 z-50`,children:L(bR,{resolution:u.resolution,inputs:u.inputs,shadowing:f!==null,bailReason:f,engineError:d})})]}):null;return{cardRects:y,sheetBottomPx:PI(v,f),animate:_,recordNaturalHeight:u.recordNaturalHeight,debug:b}}var OR=[`left`,`top`,`width`,`height`].map(e=>`${e} ${dw}`).join(`, `);function kR(e,t){return{left:`${e.x}px`,top:`${e.y}px`,width:`${e.width}px`,height:`${e.height}px`,transition:t&&!xw()?OR:`none`}}function AR({state:e}){return e.enabled?L(`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:[L(`summary`,{class:`cursor-pointer font-medium`,children:`Magic Canvas debug`}),L(`dl`,{class:`mt-2 grid gap-2`,children:[L(jR,{label:`iframe`,value:e.iframeLifecycleState}),L(jR,{label:`post`,value:e.lastInteractionPostResult}),L(jR,{label:`context`,value:e.lastModelContextUpdate}),L(jR,{label:`error`,value:e.lastError}),L(MR,{label:`tool_call`,value:e.lastToolCall}),L(MR,{label:`canvas_config`,value:e.parsedCanvasConfig})]})]}):null}function jR({label:e,value:t}){return t?L(`div`,{children:[L(`dt`,{class:`font-semibold`,children:e}),L(`dd`,{class:`break-words text-base-content/70`,children:t})]}):null}function MR({label:e,value:t}){return t===void 0?null:L(`div`,{children:[L(`dt`,{class:`font-semibold`,children:e}),L(`dd`,{children:L(`pre`,{class:`max-h-40 overflow-auto rounded bg-base-200 p-2 text-[10px] leading-relaxed`,children:JSON.stringify(t,null,2)})})]})}var NR=1e3,PR=5e3,FR=1200,IR=[2e3,6e3];async function LR(e,t,n){let r=new AbortController,i=globalThis.setTimeout(()=>r.abort(),PR);try{await jn(e,t,n,{signal:r.signal})}finally{globalThis.clearTimeout(i)}}function RR(e){return e instanceof Dn&&e.status>=400&&e.status<500&&e.status!==408&&e.status!==429}function zR(e,t){console.error(`Magic Canvas interaction POST failed; this interaction may not have been recorded server-side.`,e),t({lastInteractionPostResult:`error`,lastError:fz(e).message})}function BR(e,t,n,r){(async()=>{let i;for(let a of IR){await new Promise(e=>setTimeout(e,a));try{await LR(e,t,n),r({lastInteractionPostResult:`recovered`,lastError:void 0});return}catch(e){if(i=e,RR(e))break}}zR(i,r)})()}var VR=2e3;function HR(e){return e.correct_answer===void 0?FR:VR}var UR=48,WR=`allow-scripts`,GR={"canvas.scheduling_embed":`allow-scripts allow-same-origin allow-popups allow-forms`,"canvas.text":`allow-scripts allow-popups allow-popups-to-escape-sandbox`};function KR(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 qR=class{onmessage;onerror;onclose;#e;#t;constructor(e){this.#e=e}start(){let e=e=>{KR(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 JR(e){for(let t of rC)if(e.some(e=>cz(e)===t))return t;return null}function YR({onLayoutEffectChange:e,onRenderedSlotChange:t,debugEnabled:n=lz(),callPresence:r,callControlsVisible:i,callControlsRect:a,gridConfigEnabled:o,gridStartEnabled:s}={}){let{client:c}=Tv(),{dataTheme:l,cssVars:u}=TF(),d=Th(),f=Qg(),[p,m]=j([]),[h,g]=iz(),[_,v]=j(()=>({enabled:n,iframeLifecycleState:`idle`})),y=DR({instances:p,viewport:g,callControlsBandPx:72,callPresence:r,callControlsVisible:i,callControlsRect:a,gridConfigEnabled:o,gridStartEnabled:s}),b=F(e=>{v(t=>({...t,...e}))},[]),x=F((e,t=`*`)=>{if(f!==`joined-meeting`){b({lastError:`Dropped Magic Canvas app message because the Daily meeting is not joined.`});return}d?.sendAppMessage(e,t)},[d,f,b]),S=P(()=>({theme:l.value===`dark`?`dark`:`light`,cssVars:u.value}),[l.value,u.value]);M(()=>{v(e=>e.enabled===n?e:{...e,enabled:n})},[n]),u_({onAppMessage:F(e=>{if(f!==`joined-meeting`){b({lastToolCall:e.data,iframeLifecycleState:`idle`,lastError:`Dropped Magic Canvas tool call because the Daily meeting is not joined.`});return}try{let t=XC(e.data);if(!t)return;m(e=>hC(e,t)),b({lastToolCall:e.data,parsedCanvasConfig:t.kind===`show`?t.instance.canvas_config:void 0,iframeLifecycleState:t.kind===`clear`?`closed`:`received`,lastError:void 0})}catch(e){b({iframeLifecycleState:`error`,lastError:fz(e).message})}},[f,b])});let C=p.map(e=>{let t=SC(e,g),n=t.display_mode===`fullscreen`?null:y.cardRects.get(e.id)??null;return{instance:e,layout:n===null?t:{...t,viable_slot:`safe-area-right`},gridRect:n}}),w=CC(C.map(({layout:e})=>e),g),T=[...C].reverse().find(({layout:e})=>e.display_mode===`fullscreen`)?.instance.tool_call_id;M(()=>{e?.(w)},[e,w.active,w.side,w.video_shift_x,w.backdrop.type,w.safe_area?.x,w.safe_area?.y,w.safe_area?.width,w.safe_area?.height]);let E=JR(C.map(({layout:e})=>e));M(()=>{t?.(E)},[t,E]);let D=p.length>0||_.enabled;return L(`div`,{ref:h,"data-magic-canvas-root":!0,class:`pointer-events-none absolute inset-0 z-30`,children:[D&&T&&L(`div`,{class:`absolute inset-0 bg-black/45`}),D&&!T&&y.sheetBottomPx!==null&&L(`div`,{"data-grid-sheet-scrim":!0,class:`absolute inset-x-0 top-0`,style:{height:Math.min(y.sheetBottomPx+64,g.height),backgroundImage:`linear-gradient(to bottom, rgb(0 0 0 / 0.45) calc(100% - 64px), rgb(0 0 0 / 0))`}}),D&&C.map(({instance:e,layout:t,gridRect:n})=>L(ZR,{slot:cz(t),safeAreaTop:w.safe_area?.y,frameWidth:g.width,...n?{gridRect:n,gridAnimate:y.animate}:{},children:r=>L(QR,{availableHeight:r,client:c,gridDriven:n!==null,hostTheme:S,instance:e,layout:t,dimmed:!!(T&&T!==e.tool_call_id),onDebug:b,onNaturalHeightChange:y.recordNaturalHeight,onComplete:()=>{m(t=>t.filter(t=>t.id!==e.id))},onDisplayModeChange:t=>{m(n=>n.map(n=>n.tool_call_id===e.tool_call_id?{...n,layout:{...n.layout,display_mode:t}}:n))},sendAppMessage:x})},e.id)),D&&L(`div`,{class:`absolute right-4 bottom-24 @max-mobile:right-3 @max-mobile:bottom-20`,children:L(AR,{state:_})}),y.debug]})}var XR=16;function ZR({slot:e,safeAreaTop:t,frameWidth:n,gridRect:r,gridAnimate:i=!1,children:a}){let[o,s]=az(),c=a(r?r.height:e===`full`?void 0:s);if(r)return L(`div`,{ref:o,class:`pointer-events-auto absolute`,style:kR(r,i),"data-canvas-slot":e,"data-grid-driven":`true`,children:L(`div`,{class:`flex h-full w-full flex-col gap-2`,children:c})});if(e===`safe-area-left`||e===`safe-area-right`){let r=t==null?`1rem`:`${t*100}%`,i=n!=null&&n>0?Math.max(0,n-XR*2):void 0;return L(`div`,{ref:o,class:sz(e),style:{top:r,bottom:`72px`,maxWidth:i},"data-canvas-slot":e,children:L(`div`,{class:`my-auto flex w-full flex-col gap-2`,children:c})})}return L(`div`,{ref:o,class:sz(e),"data-canvas-slot":e,children:L(`div`,{class:`contents`,children:c})})}function QR({availableHeight:e,client:t,gridDriven:n=!1,hostTheme:r,instance:i,layout:a,dimmed:o,onDebug:s,onComplete:c,onDisplayModeChange:l,onNaturalHeightChange:u,sendAppMessage:d}){let f=N(null),p=N(null),m=N(e),h=N(320),g=N(r),_=N(i),v=N(a),y=N(-1),b=N(c),x=N(l),S=N(u),C=N(d),[w,T]=j(720);M(()=>{_.current=i},[i]),M(()=>{h.current=w,p.current?.setHostContext(nz(_.current,g.current,v.current,m.current,w))},[w]),M(()=>{m.current=e;let t=tz(r,f.current);g.current=t,p.current?.setHostContext(nz(_.current,t,v.current,e,h.current))},[e,r]),M(()=>{v.current=a,p.current?.setHostContext(nz(_.current,g.current,a,e,h.current))},[e,a]),M(()=>{b.current=c,x.current=l,S.current=u,C.current=d},[c,l,u,d]),M(()=>{let e=f.current;if(!e)return;let n=!1,r=null,a=null,o=null,c=null,l=new URL(i.canvas_config.sandbox_url,globalThis.location.href).href,u=e=>{n||s({iframeLifecycleState:`error`,lastError:fz(e).message})},d=()=>{if(n||!a)return;let e=_.current,t=bC(e,a);a=null,C.current({message_type:`conversation`,event_type:`conversation.append_llm_context`,conversation_id:e.conversation_id,properties:{context:t}}),s({lastModelContextUpdate:e.canvas_config.component,lastError:void 0})},w=()=>{if(r)return;if(e.src!==l){e.src;return}if(n||!e.contentWindow)return;let f=new CF(null,{name:`tavus-deployment`,version:`0.0.0`},{logging:{},message:{text:{},structuredContent:{}},updateModelContext:{text:{},structuredContent:{}}},{hostContext:nz(i,tz(g.current,e),v.current,m.current,h.current)});r=f,p.current=f,f.oninitialized=()=>{n||(s({iframeLifecycleState:`ready`}),y.current=_.current.revision,f.sendToolInput({arguments:_.current.arguments}).catch(u))},f.onsizechange=({height:e})=>{if(!n&&typeof e==`number`&&Number.isFinite(e)){let t=Math.min(Math.max(e,UR),720);T(t),S.current(_.current.id,t)}},f.onmessage=async e=>{let r=gC(e),i=yC(e);if(!r){if(i){let e=`Magic Canvas message included text without interaction metadata; no interaction row was recorded.`;return s({lastInteractionPostResult:`error`,lastError:e}),{isError:!0,code:`missing_interaction_metadata`,message:e}}return{}}let a=_.current,o=(()=>{try{let e=_C(a,r);return{interaction:e,request:ZC(e)}}catch(e){return{error:e}}})();if(`error`in o){let e=fz(o.error).message;return s({lastInteractionPostResult:`error`,lastError:e}),{isError:!0,code:`interaction_normalization_failed`,message:e}}let{interaction:l,request:u}=o,d=!0;try{await LR(t,l.conversation_id,u.body)}catch(e){d=!1,RR(e)?zR(e,s):(console.warn(`Magic Canvas interaction POST failed; continuing without it and retrying in the background.`,e),s({lastInteractionPostResult:`failed_open`,lastError:fz(e).message}),BR(t,l.conversation_id,u.body,s))}if(n)return{};if(i)try{C.current({message_type:`conversation`,event_type:`conversation.respond`,conversation_id:a.conversation_id,properties:{text:i}})}catch(e){console.error(`Magic Canvas respond send failed.`,e),s({lastError:fz(e).message})}return d&&s({lastInteractionPostResult:`success`,lastError:void 0}),vC(l)&&(l.type===`submit`?(c&&clearTimeout(c),c=setTimeout(()=>{c=null,n||b.current()},HR(a.arguments))):b.current()),{}},f.onupdatemodelcontext=async e=>(a=e,o||=setTimeout(()=>{o=null,d()},NR),{}),f.onrequestdisplaymode=async({mode:e})=>{let t=e===`fullscreen`?`fullscreen`:`inline`;return x.current(t),v.current={...v.current,display_mode:t,viable_slot:t===`fullscreen`?`full`:v.current.viable_slot},f.setHostContext(nz(_.current,g.current,v.current,m.current,h.current)),{mode:t}},f.connect(new qR(e)).then(()=>void 0).catch(u)};s({iframeLifecycleState:`mounting`,lastInteractionPostResult:void 0}),i.canvas_config.sandbox_url,e.src=i.canvas_config.sandbox_url;let E=()=>{w()};return e.addEventListener(`load`,E),w(),()=>{o&&=(clearTimeout(o),null),c&&=(clearTimeout(c),null),d(),n=!0,e.removeEventListener(`load`,E),p.current=null,s({iframeLifecycleState:`closed`}),r&&tC(r)}},[t,i.id,i.canvas_config.sandbox_url,s]),M(()=>{i.revision!==0&&(i.revision<=y.current||(y.current=i.revision,p.current?.sendToolInput({arguments:i.arguments}).catch(e=>{s({iframeLifecycleState:`error`,lastError:fz(e).message})})))},[i.arguments,i.revision,s]);let E=a.viable_slot===`full`||a.display_mode===`fullscreen`,D=E?null:rz(w,e),ee=D?.placeholderStyle,te=D?.cardStyle,ne=E?{height:`100%`}:D?.iframeStyle??{height:`${w}px`},re=[`pointer-events-auto w-full overflow-hidden rounded-box border-[length:var(--border)] border-base-300 bg-base-100 shadow-xl transition-[opacity,transform]`,E?`fixed inset-4 z-10 max-w-none`:n?`max-w-none`:`max-w-md`,o?`scale-[0.98] opacity-40`:``].filter(Boolean).join(` `),O=GR[i.canvas_config.component]??WR,ie=L(`div`,{class:re,style:te,"data-canvas-card":a.viable_slot,children:L(`iframe`,{ref:f,title:`${i.canvas_config.component} ${i.canvas_config.component_version}`,class:E?`block h-full w-full border-0 bg-transparent`:`block border-0 bg-transparent`,sandbox:O,style:ne})});return E?ie:L(`div`,{class:`block w-full`,style:ee,children:ie})}var $R=[`--color-base-100`,`--color-base-200`,`--color-base-300`,`--color-base-content`,`--color-primary`,`--color-error`];function ez(e){if(!e||typeof getComputedStyle!=`function`)return{};let t=getComputedStyle(e),n={};for(let e of $R){let r=t.getPropertyValue(e).trim();r&&(n[e]=r)}return n}function tz(e,t){let n=ez(t);return Object.keys(n).length===0?e:{...e,cssVars:{...e.cssVars,...n}}}function nz(e,t,n,r,i){let a=QC(t,n),o=n.viable_slot===`full`||n.display_mode===`fullscreen`,s=o?void 0:uz(r),c=o?1:rz(i??0,r)?.displayScale??1;return{...e.canvas_config.host_context,...a,containerDimensions:{...dz(a.containerDimensions)?a.containerDimensions:{},...s===void 0?{}:{maxHeight:s},displayScale:c}}}function rz(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{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`}}}function iz(){let e=N(null),[t,n]=j(()=>oz(null));return M(()=>{let t=()=>n(t=>{let n=oz(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 az(){let e=N(null),[t,n]=j();return M(()=>{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 oz(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}}function sz(e){let t=`absolute flex gap-2`;switch(e){case`safe-area-left`:return`${t} left-4 w-[28rem] flex-col overflow-y-auto [scrollbar-gutter:stable]`;case`safe-area-right`:return`${t} right-4 w-[28rem] flex-col overflow-y-auto [scrollbar-gutter:stable]`;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 cz(e){return e.display_mode===`fullscreen`&&e.preferred_slot!==`full`?e.preferred_slot:e.viable_slot}function lz(){return!1}function uz(e){return e===void 0||!Number.isFinite(e)||e<=0?720:Math.min(Math.floor(e),720)}function dz(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function fz(e){return e instanceof Error?e:Error(String(e))}var pz=class extends A{state={errored:!1};componentDidCatch(e){this.props.onError(e),this.setState({errored:!0})}render(){return this.state.errored?null:this.props.children}},mz=1e4;function hz(e,t=mz){let[n,r]=j(!1),i=N(!1);return M(()=>{if(!e){r(!1);return}if(i.current)return;i.current=!0,r(!0);let n=setTimeout(()=>r(!1),t);return()=>clearTimeout(n)},[e,t]),n}function gz(e){let t=lg(),n=C_(t??``),r=!x_(t??``).isOff,i=VS(e),a=i.phase===`ready`?i.replicaId:``,o=x_(a),s=!r&&(o.state===`playable`||o.state===`loading`),c=i.phase===`ready`&&!e&&!i.videoState.isOff,l=!e&&t!==null&&!n.isOff,u=i.phase!==`ready`||i.videoState.isOff;return P(()=>({presence:i,localId:t,isScreenSharing:r,isPersonaPresenting:s,hasPersonaVideo:c,hasSelfView:l}),[i.phase,a,u,t,r,s,c,l])}function _z(e,t,n){let[r,i]=j(!0);return M(()=>{if(!t)return;let n=e.current;if(!n||typeof matchMedia!=`function`)return;let r=matchMedia(`(hover: hover) and (pointer: fine)`),a=()=>{try{return n.matches(`:has(:focus-visible)`)}catch{return!1}},o=n.matches(`:hover`),s=()=>{i(!r.matches||o||a())},c=()=>{o=!0,s()},l=()=>{o=!1,s()};return n.addEventListener(`pointerenter`,c),n.addEventListener(`pointerleave`,l),n.addEventListener(`focusin`,s),n.addEventListener(`focusout`,s),r.addEventListener(`change`,s),s(),()=>{n.removeEventListener(`pointerenter`,c),n.removeEventListener(`pointerleave`,l),n.removeEventListener(`focusin`,s),n.removeEventListener(`focusout`,s),r.removeEventListener(`change`,s)}},[t,e,n]),r}function vz(e,t,n,r,i){let[a,o]=j(void 0);return M(()=>{if(!r)return;let i=e.current,a=t.current;if(!i||!a||typeof ResizeObserver>`u`)return;let s=()=>{let e=i.getBoundingClientRect(),t=1/0,r=-1/0;for(let e of a.children){let n=e.getBoundingClientRect();n.width!==0&&(t=Math.min(t,n.left),r=Math.max(r,n.right))}if(e.width===0||!Number.isFinite(t)||r<=t)return;let s={x:Math.round(t-e.left),y:Math.round(e.height-n),width:Math.round(r-t),height:n};o(e=>e!==void 0&&e.x===s.x&&e.y===s.y&&e.width===s.width&&e.height===s.height?e:s)},c=new ResizeObserver(s);c.observe(i),c.observe(a);for(let e of a.children)c.observe(e);return s(),()=>c.disconnect()},[r,e,t,n,i]),a}var yz=1e4;function bz({onTimeout:e,timeoutMs:t=yz,active:n=!0}){let r=BS().length>0,[i,a]=j(!1),o=N(e);return M(()=>{o.current=e},[e]),M(()=>{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 xz(e){if(typeof e!=`object`||!e)return!1;let t=e;return t.message_type===`system`&&t.event_type===`system.shutdown`}function Sz({onShutdown:e}){let t=N(e);M(()=>{t.current=e},[e]),u_({onAppMessage:F(e=>{xz(e?.data)&&t.current()},[])})}var Cz=wn(`PiP`),wz=360,Tz=280;function Ez(){return globalThis.window!==void 0&&`documentPictureInPicture`in globalThis.window}function Dz(e){let{enabled:t,active:n}=e,[r,i]=j(null),a=Ez(),o=I(ry),s=F(()=>{i(e=>(e&&!e.closed&&e.close(),null))},[]),c=F(async()=>{if(a&&!(!t||!n)&&!(r&&!r.closed))try{let e=await globalThis.window.documentPictureInPicture.requestWindow({width:wz,height:Tz}),t=Ue.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){Cz.warn(`Failed to open PiP window`,e)}},[a,t,n,r]);return M(()=>{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){Cz.warn(`mediaSession metadata setup failed`,e)}let t=(t,n)=>{try{e.setActionHandler(t,n),r.push(t)}catch(e){Cz.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]),M(()=>{(!n||!t)&&r&&!r.closed&&s()},[n,t,r,s]),M(()=>()=>{r&&!r.closed&&r.close()},[r]),M(()=>{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 Oz=Yt(null),kz={active:!1,video_shift_x:0,backdrop:{type:`snapshot_mirror`}},Az=Ea(({id:e,showAudioWave:t=!0})=>{let n=C_(e).isOff;return L(`div`,{class:`relative aspect-square w-32 @max-mobile:w-24 rounded-box overflow-hidden bg-black/30 z-10 ${n?`hidden`:``}`,children:[L(Cg,{automirror:!0,sessionId:e,type:`video`,fit:`cover`,className:`w-full h-full object-cover ${n?`hidden`:``}`}),t&&L(`div`,{class:`absolute bottom-2 right-2`,children:L(NS,{id:e})})]})}),jz=Ea(()=>{let e=lg(),{isScreenSharing:t}=Kx(),n=BS()[0];return L(k,{children:[t&&n&&L(Az,{id:n}),e&&L(Az,{id:e,showAudioWave:!1})]})}),Mz=Ea(()=>L(`div`,{class:`absolute bottom-4 @max-mobile:bottom-20 left-4 flex flex-col items-end gap-2 z-20`,children:L(jz,{})})),Nz=Ea(({personaSessionId:e,localId:t,isScreenSharing:n,avatarOff:r,effect:i,animate:a})=>L(k,{children:[L(`div`,{class:`absolute inset-0 bg-base-200`}),i.content&&L(`div`,{class:`absolute overflow-hidden rounded-box bg-black`,style:kR(i.content,a),children:L(Cg,{sessionId:n?t??``:e,type:`screenVideo`,fit:`contain`,className:`absolute inset-0 h-full w-full object-contain`})}),i.replica&&L(`div`,{class:_R(`absolute overflow-hidden`,i.replicaCollapsed&&`rounded-box`),style:kR(i.replica,a),children:L(GS,{personaSessionId:e,localSessionId:t,isScreenSharing:!1,avatarOff:r})})]})),Pz=Ea(()=>{let{effect:e,animate:t}=SR.value,n=lg();return n===null||e.selfView===null?null:L(`div`,{class:`absolute z-20 overflow-hidden rounded-box bg-black/30`,style:kR(e.selfView,t),children:L(Cg,{automirror:!0,sessionId:n,type:`video`,fit:`cover`,className:`h-full w-full object-cover`})})}),Fz=Ea(({canvasRenderedSlot:e})=>{let t=LI(SR.value.effect);return t===`hidden`?null:t===`engine`?L(pz,{onError:AI,children:L(Pz,{})}):e===`safe-area-bottom`?null:L(Mz,{})}),Iz=Ea(()=>{let e=BS()[0];return e?L(xg,{sessionId:e}):null}),Lz=Ea(e=>L(k,{children:[L(Iz,{}),L(Rz,{...e})]})),Rz=Ea(({isAudioOnly:e,presence:t,canvasLayoutEffect:n,canvasRenderedSlot:r})=>{let{presence:i,localId:a,isScreenSharing:o,isPersonaPresenting:s}=t,c=SR.value,l=n.active&&!o&&(!e||s);return i.phase===`left`?L(jS,{}):i.phase===`connecting`?L(AS,{}):e&&!s?L(`div`,{class:`absolute inset-0 flex items-center justify-center`,children:L(LS,{sessionId:i.replicaId})}):c.effect.driving?L(pz,{onError:AI,children:L(Nz,{personaSessionId:i.replicaId,localId:a,isScreenSharing:o,avatarOff:i.videoState.isOff,effect:c.effect,animate:c.animate})}):s?L(jw,{personaSessionId:i.replicaId,isAudioOnly:e,avatarOff:i.videoState.isOff,canvasLayoutEffect:n,smartSidecarActive:l}):L(zz,{personaSessionId:i.replicaId,localId:a,isScreenSharing:o,avatarOff:i.videoState.isOff,smartSidecarActive:l,canvasLayoutEffect:n,canvasRenderedSlot:r})}),zz=Ea(({personaSessionId:e,localId:t,isScreenSharing:n,avatarOff:r,smartSidecarActive:i,canvasLayoutEffect:a,canvasRenderedSlot:o})=>L(kw,{canvasLayoutEffect:a,smartSidecarActive:i,isScreenSharing:n,captureSnapshot:Uz,personaMode:`auto`,renderedSlot:o,fill:i=>L(GS,{personaSessionId:e,localSessionId:t,isScreenSharing:n,avatarOff:r,videoRef:i})})),Bz=Ea(({items:e})=>{let[t,n]=j(!1),r=N(null);return M(()=>{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]),L(`div`,{ref:r,class:`relative`,children:[L(`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:L(tx,{name:`more`})}),t&&L(`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})]})}),Vz=Ea(({items:e})=>e.length<=1?L(k,{children:e}):L(Bz,{items:e})),Hz=Ea(({onLeave:e})=>{let t=Qg(),{config:n}=Tv(),{session:r,end:i}=_S(),a=lg(),o=N(null),s=I(Ky)?.frameRef??o,[c,l]=j(!1),u=Cx()===`full-screen`,[d,f]=j(!1),[p,m]=j(kz),[h,g]=j(null),_=n.value.customization.conversation,v=hz(_.show_fullscreen_hint&&h!==null&&!c&&!u),y=N(null),b=N(null),x=r.value?.conversationUrl,S=r.value?.magicGrid===!0,C=TI(_.magic_grid,S),w=_z(y,C,x),T=vz(y,b,72,C,x),E=_.modality===`audio`,D=gz(E),ee=_.modality===`chat`,te=_.modality===`video`,ne=_.enable_chat,re=_.enable_closed_captions,O=_.enable_picture_in_picture,{pipWindow:ie}=Dz({enabled:O&&!ee,active:t===`joined-meeting`});M(()=>()=>{i()},[i]);let{camera:ae,requestCamera:k}=Yv(),{isCamMuted:A}=Wx(),oe=ae.isGranted&&!A;M(()=>{te&&t===`joined-meeting`&&(Oz.value=oe)},[te,t,oe]);let se=N(te&&!a&&Oz.value===!0);M(()=>{t===`joined-meeting`&&se.current&&(se.current=!1,k())},[t,k]),M(()=>{(t===`left-meeting`||t===`error`)&&e()},[t,e]),M(()=>{let e=()=>{let e=s.current,t=e?.getRootNode(),n=t instanceof Document||t instanceof ShadowRoot?t:null;l(!!e&&n?.fullscreenElement===e)};return document.addEventListener(`fullscreenchange`,e),()=>document.removeEventListener(`fullscreenchange`,e)},[]);let ce=F(()=>{let e=s.current;if(!e)return;let t=e.getRootNode();(t instanceof Document||t instanceof ShadowRoot?t:null)?.fullscreenElement===e?document.exitFullscreen?.():e.requestFullscreen?.()},[]);F(()=>{f(e=>!e)},[]);let le=F(()=>{i()},[i]);if(bz({active:!ee&&t===`joined-meeting`,onTimeout:le}),Sz({onShutdown:le}),!x)return null;if(ee)return L(wS,{defaultOpen:!0,children:L(`div`,{class:`cvi-call-surface absolute inset-0`,children:L(OS,{docked:!0,headerAction:L(`button`,{type:`button`,class:`btn btn-ghost btn-sm btn-circle text-base-content/60 hover:text-error`,onClick:le,"aria-label":`Leave conversation`,children:L(tx,{name:`leave`,size:20,"aria-label":`Leave conversation`})})})})});let ue=[L(gS,{compact:!0},`screen-share`)];ne&&ue.push(L(ES,{compact:!0},`chat`));let de=t===`left-meeting`;return L(yS,{children:L(wS,{children:L($x,{children:[L(`div`,{class:`cvi-call-surface absolute inset-0${E?``:` cvi-video-surface`}`,ref:y,children:[L(`div`,{class:`relative w-full h-full z-[5]`,children:[L(Lz,{isAudioOnly:E,presence:D,canvasLayoutEffect:p,canvasRenderedSlot:h}),!E&&L(Fz,{canvasRenderedSlot:h}),L(YR,{debugEnabled:d,callPresence:D,callControlsVisible:w,callControlsRect:T,gridConfigEnabled:_.magic_grid,gridStartEnabled:S,onLayoutEffectChange:m,onRenderedSlotChange:g}),!u&&L(`div`,{class:`cvi-autohide absolute top-4 right-4 z-20`,"data-hidden":de,"data-pinned":v,children:L(MS,{active:c,onToggle:ce,nudge:v,compact:!0})})]}),L(OS,{}),L(SS,{}),L(`div`,{class:`cvi-autohide cvi-autohide-slide pointer-events-none absolute bottom-6 left-0 right-0 z-20`,"data-hidden":de,"aria-hidden":de,children:L(`div`,{class:`cvi-control-rail flex justify-center items-center gap-2 @max-mobile:gap-1`,"data-hidden":de,ref:b,children:[L(dS,{level:!0}),!E&&L(pS,{}),re&&L(xS,{}),L(Vz,{items:ue}),L(`button`,{type:`button`,class:`btn btn-control btn-error`,onClick:le,"aria-label":`Leave call`,children:L(tx,{name:`leave`,"aria-label":`Leave Call`})})]})})]}),ie&&Ua(L(US,{onLeave:le}),ie.document.body)]})})})});function Uz(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 Wz({message:e,class:t}){return L(`div`,{class:`w-max max-w-[min(20rem,80vw)] ${t??``}`,children:[L(`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}),L(`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:L(`path`,{d:`M0 0 L8 8 L16 0 Z`,fill:`currentColor`})})]})}function Gz(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...`}}var Kz=Ea(({text:e,isJoining:t=!1,onJoin:n,onCancel:r})=>{let i=Th(),{config:a}=Tv(),{localSessionId:o,isCamMuted:s}=Wx(),{mic:c,camera:l,requestMic:u,requestCamera:d}=Yv(),f=a.value.customization.conversation.modality===`video`,p=ox(a.value),m=ax(a.value);M(()=>{u()},[]);let h=c.isGranted,g=N(!1);M(()=>{!f||!h||g.current||l.isGranted||l.isBlocked||(g.current=!0,d())},[f,h,l.isGranted,l.isBlocked,d]);let _=f&&h&&!l.isGranted,v=Gz(e,c.status,_);return L($x,{children:L(`div`,{class:`absolute inset-0 motion-safe:animate-[tavusFadeUp_280ms_ease-out]`,children:[l.isGranted&&!s?L(`div`,{class:`absolute inset-0 flex items-center justify-center bg-black overflow-hidden`,children:L(Cg,{type:`video`,sessionId:o??``,mirror:!0,fit:`cover`,className:`w-full h-full object-cover!`})}):L(`div`,{class:`absolute inset-0 overflow-hidden bg-base-300`,children:[L(dx,{variant:p.background,replica:m}),L(`div`,{class:`${Mx} backdrop-blur-xs`})]}),L(`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:[v&&L(Wz,{message:v,class:`relative`}),L(`div`,{class:`flex flex-wrap items-center justify-center gap-1.5 @max-mobile:gap-1`,children:[L(`div`,{class:`flex items-center justify-center gap-1.5 shrink-0 @max-mobile:gap-1`,children:[L(dS,{level:!0}),f&&L(pS,{})]}),L(Fx,{class:`btn-accent `,loading:t,disabled:!h,onClick:n,children:e?.join??`Join`}),L(`button`,{type:`button`,class:`btn btn-control ${c.isBlocked?`btn-error`:`btn-neutral`}`,onClick:()=>{i&&i.leave(),r?.()},"aria-label":e?.cancel??`Cancel`,title:e?.cancel??`Cancel`,children:L(tx,{name:`cancel`})})]})]})]})})}),qz=`Password required`,Jz=`Enter the password to start this conversation.`,Yz=`Password`,Xz=`Continue`;function Zz({onSubmit:e,text:t,isSubmitting:n=!1,errorMessage:r}){let[i,a]=j(``),o=ct();return L(`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:L(`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:L(`div`,{class:`card-body gap-3`,children:[L(`h3`,{id:`${o}-title`,class:`card-title text-base-content`,children:t?.title??qz}),L(`p`,{class:`text-sm text-base-content/70`,children:t?.description??Jz}),L(`input`,{id:o,type:`password`,autocomplete:`current-password`,class:`input input-bordered w-full`,placeholder:t?.placeholder??Yz,value:i,disabled:n,onInput:e=>a(e.target.value),autoFocus:!0}),r&&L(`p`,{class:`text-error text-xs`,role:`alert`,children:r}),L(Fx,{class:`btn-primary`,type:`submit`,disabled:!i.trim(),loading:n,children:t?.submit??Xz})]})})})}function Qz({kind:e,status:t}){if(e===`camera`)return`Allow camera access to use video. Camera is optional.`;switch(t){case`blocked`:return`Microphone is blocked. Allow access in your browser settings to continue.`;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.`;default:return`Allow microphone access to start the conversation.`}}function $z({text:e,onStart:t,isStarting:n,permissionRequest:r}){let{config:i,deploymentId:a}=Tv(),o=Cx()===`full-screen`,s=I(av),c=ox(i.value),l=c.btn_title??e?.fallback_button??`Start the conversation`,u=i.value.customization.terms_content?.trim()??``,d=i.value.customization.terms_enabled===!0,f=u.length>0,p=f&&d,m=P(()=>p&&P_(a,u),[p,a,u]),h=p&&!m,g=i.value.has_password===!0,_=s?.password.value??null,v=g&&!_,y=ct(),[b,x]=j(m),S=n||p&&!b||v;return L(Px,{title:c.title,description:c.description,overlay:v&&s?L(Zz,{onSubmit:s.setPassword}):null,children:[L(`div`,{class:`relative`,children:[r&&L(Wz,{message:Qz(r),class:`absolute bottom-full mb-3 z-20 ${o?`left-1/2 -translate-x-1/2`:`right-0`}`}),L(Rx,{onClick:()=>{p&&b&&!m&&L_(a,u),t()},disabled:S,loading:n,children:l})]}),f&&L(`div`,{class:`max-w-xs text-center`,children:h?L(`label`,{for:y,class:`flex items-center gap-2 text-xs text-left cursor-pointer`,children:[L(`input`,{id:y,type:`checkbox`,class:`checkbox checkbox-secondary checkbox-xs mt-0.5 shrink-0`,checked:b,onChange:e=>x(e.target.checked)}),L(`span`,{class:`leading-snug`,children:u})]}):L(`p`,{class:`text-xs leading-snug text-white/70`,children:u})})]})}function eB(...e){for(let t of e){let e=t?.trim();if(e)return e}}function tB(){let{config:e}=Tv(),{haircheck:t}=e.value.customization;return P(()=>({prompt:eB(t.permission_request_description,t.permission_request_title),ready:eB(t.permission_granted_description,t.permission_granted_title),denied:eB(t.permission_denied_description,t.permission_denied_title),join:eB(t.join_button),cancel:eB(t.cancel_btn)}),[t])}function nB({flow:e,welcomeText:t,onUnavailableCancel:n}){let r=tB();switch(e.state){case`idle`:return L($z,{text:t,onStart:()=>{e.start()},isStarting:e.isStarting,permissionRequest:e.permissionRequest});case`haircheck`:return L(Kz,{text:r,onJoin:()=>{e.join()},onCancel:()=>e.cancel(),isJoining:e.isStarting});case`call`:return L(Hz,{onLeave:()=>e.leave()});case`ended`:return L(Ux,{isStarting:e.isStarting,onRestart:()=>{e.start()}});case`unavailable`:return L(yx,{cause:e.unavailableCause??`busy`,canRetry:e.canRetry,onRetry:()=>{e.start()},onCancel:n});default:{let t=e.state;throw Error(`Unreachable flow state: ${String(t)}`)}}}function rB(){let{config:e,configError:t}=Tv(),n=Sx(),r=bx(),i=P(()=>({fallback_button:n.start_button}),[n.start_button]),a=e.value.is_available,o=e.value.unavailable_reason;return L(qy,{children:t.value?L(yx,{cause:`error`,canRetry:!1,onRetry:()=>{}}):a===!1?L(yx,{cause:o??`daily_limit`,canRetry:!1,onRetry:()=>{}}):L(nB,{flow:r,welcomeText:i})})}var iB=`:host {
163
+ - "app": Tool callable by the app from this server only`),csp:BA().optional(),permissions:BA().optional()}),X({mimeTypes:Y(J()).optional().describe('Array of supported MIME types for UI resources.\nMust include `"text/html;profile=mcp-app"` for MCP Apps support.')});var yF=X({method:Z(`ui/download-file`),params:X({contents:Y(HA([qN,JN])).describe(`Resource contents to download — embedded (inline data) or linked (host fetches). Uses standard MCP resource types.`)})}),bF=X({method:Z(`ui/message`),params:X({role:Z(`user`).describe(`Message role, currently only "user" is supported.`),content:Y(YN).describe(`Message content blocks (text, image, etc.).`)})});X({method:Z(`ui/notifications/sandbox-resource-ready`),params:X({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:oF.optional().describe(`CSP configuration from resource metadata.`),permissions:sF.optional().describe(`Sandbox permissions from resource metadata.`)})}),X({method:Z(`ui/notifications/tool-result`),params:iP.describe(`Standard MCP tool execution result.`)});var xF=X({toolInfo:X({id:wM.optional().describe(`JSON-RPC id of the tools/call request.`),tool:tP.describe(`Tool definition including name, inputSchema, etc.`)}).optional().describe(`Metadata of the tool call that instantiated this App.`),theme:tF.optional().describe(`Current color theme preference.`),styles:uF.optional().describe(`Style configuration for theming the app.`),displayMode:nF.optional().describe(`How the UI is currently displayed.`),availableDisplayModes:Y(nF).optional().describe(`Display modes the host supports.`),containerDimensions:HA([X({height:PA().describe(`Fixed container height in pixels.`)}),X({maxHeight:HA([PA(),LA()]).optional().describe(`Maximum container height in pixels.`)})]).and(HA([X({width:PA().describe(`Fixed container width in pixels.`)}),X({maxWidth:HA([PA(),LA()]).optional().describe(`Maximum container width in pixels.`)})])).optional().describe(`Container dimensions. Represents the dimensions of the iframe or other
164
+ 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:HA([Z(`web`),Z(`desktop`),Z(`mobile`)]).optional().describe(`Platform type for responsive design decisions.`),deviceCapabilities:X({touch:IA().optional().describe(`Whether the device supports touch input.`),hover:IA().optional().describe(`Whether the device supports hover interactions.`)}).optional().describe(`Device input capabilities.`),safeAreaInsets:X({top:PA().describe(`Top safe area inset in pixels.`),right:PA().describe(`Right safe area inset in pixels.`),bottom:PA().describe(`Bottom safe area inset in pixels.`),left:PA().describe(`Left safe area inset in pixels.`)}).optional().describe(`Mobile safe area boundaries in pixels.`)}).passthrough();X({method:Z(`ui/notifications/host-context-changed`),params:xF.describe(`Partial context update containing only changed fields.`)});var SF=X({method:Z(`ui/update-model-context`),params:X({content:Y(YN).optional().describe(`Context content blocks (text, image, etc.).`),structuredContent:GA(J(),zA().describe(`Structured content for machine-readable context data.`)).optional().describe(`Structured content for machine-readable context data.`)})}),CF=X({method:Z(`ui/initialize`),params:X({appInfo:zM.describe(`App identification (name and version).`),appCapabilities:hF.describe(`Features and capabilities this app provides.`),protocolVersion:J().describe(`Protocol version this app supports.`)})});X({protocolVersion:J().describe(`Negotiated protocol version string (e.g., "2025-11-21").`),hostInfo:zM.describe(`Host application identification and version.`),hostCapabilities:mF.describe(`Features and capabilities provided by the host.`),hostContext:xF.describe(`Rich context about the host environment.`)}).passthrough();var wF=[eF],TF=class extends $P{_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:cF,sandboxready:aF,initialized:gF,requestteardown:pF,loggingmessage:fP};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(CF,e=>this._oninitialize(e)),this.setRequestHandler(YM,(e,t)=>(this.onping?.(e.params,t),{})),this.replaceRequestHandler(_F,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(bF,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(iF,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(yF,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(_F,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(SF,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(oP,async(e,t)=>{if(!this._oncalltool)throw Error(`No oncalltool handler set`);return this._oncalltool(e.params,t)})}set oncreatesamplingmessage(e){this.setRequestHandler(bP,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(SN,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(wN,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(ON,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(zN,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:wF.includes(t)?t:eF,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];EF(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},dF,t)}sendResourceTeardown=this.teardownResource;callTool(e,t){return this.request({method:`tools/call`,params:e},iP,t)}listTools(e,t){return this.request({method:`tools/list`,params:e},rP,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},iP,{signal:t.signal}),e.tools.listChanged&&this._client.setNotificationHandler(sP,e=>this.sendToolListChanged(e.params))),e.resources&&(this.onlistresources=async(e,t)=>this._client.request({method:`resources/list`,params:e},CN,{signal:t.signal}),this.onlistresourcetemplates=async(e,t)=>this._client.request({method:`resources/templates/list`,params:e},TN,{signal:t.signal}),this.onreadresource=async(e,t)=>this._client.request({method:`resources/read`,params:e},kN,{signal:t.signal}),e.resources.listChanged&&this._client.setNotificationHandler(AN,e=>this.sendResourceListChanged(e.params))),e.prompts&&(this.onlistprompts=async(e,t)=>this._client.request({method:`prompts/list`,params:e},BN,{signal:t.signal}),e.prompts.listChanged&&this._client.setNotificationHandler(QN,e=>this.sendPromptListChanged(e.params)))}return super.connect(e)}};function EF(e,t){return JSON.stringify(e)===JSON.stringify(t)}function DF(){let e=I(iy);if(!e)throw Error(`useTheme must be used within ThemeProvider`);return e}var OF={committedClass:null,pendingClass:null,pendingSinceMs:null,lastResolution:null},kF={classes:{widthCompactMaxPx:767,widthMediumMaxPx:1023,heightShortMaxPx:479},hysteresis:{windowMs:250,decisiveJumpPxDelta:200},rail:{widthPx:448,insetPx:16,gutterPx:24},sidecar:{minViewportWidthPx:900,maxVideoShiftPx:360,maxVideoShiftFraction:.3},card:{maxHeightPx:720,reportedHeightFloorPx:48,coldDefaultHeightPx:320,minDisplayScale:.85,layoutDefaultMinHeightPx:240,stackBandMaxFraction:.6,stackMaxWidthPx:600,componentOverrides:{}},content:{stackedAspect:16/9},pip:{gapPaddingPx:24,minWidthPx:128,maxAreaRatio:.35},motion:{layoutTransitionMs:560},insets:{callControlsBottomPx:72,participantsPadPx:16,cardsPadPx:16,surfacePadPx:16,compactCardsPadPx:8,compactSurfacePadPx:8},eviction:{policy:`evict-oldest`,maxVisibleCards:2,compactTakeoverMaxCards:1},degradationLadder:[`evict-cards`,`drop-self-view`,`collapse-replica`]};function AF(e,t){let n=Math.round(e.widthPx),r=Math.round(e.heightPx);return{width:n<=t.classes.widthCompactMaxPx?`compact`:n<=t.classes.widthMediumMaxPx?`medium`:`expanded`,height:r<=t.classes.heightShortMaxPx?`short`:`regular`}}var jF={idle:{id:`idle`,regions:[]},"conversation-full":{id:`conversation-full`,regions:[{name:`stage`,x:{fraction:0},y:{fraction:0},width:{fraction:1},height:{fraction:1},accepts:[`replica`],zBase:0},{name:`pip`,x:{fraction:.72},y:{fraction:.72},width:{fraction:.24},height:{fraction:.24},accepts:[`selfView`],zBase:100}]},"canvas-rail":{id:`canvas-rail`,soloVariant:`canvas-solo`,regions:[{name:`stage`,x:{px:0},y:{px:0},width:{fraction:.62},height:{fraction:1},accepts:[`replica`],zBase:0},{name:`rail`,x:{px:-448},y:{px:0},width:{px:448},height:{fraction:1},accepts:[`card`],zBase:0},{name:`pip`,x:{fraction:.38},y:{fraction:.72},width:{fraction:.2},height:{fraction:.24},accepts:[`selfView`],zBase:100}]},"canvas-stack":{id:`canvas-stack`,soloVariant:`canvas-solo`,regions:[{name:`canvasBand`,x:{fraction:0},y:{fraction:0},width:{fraction:1},height:{fraction:.38},accepts:[`card`],zBase:0},{name:`stage`,x:{fraction:0},y:{fraction:.38},width:{fraction:1},height:{fraction:.62},accepts:[`replica`],zBase:0},{name:`pip`,x:{fraction:.72},y:{fraction:.76},width:{fraction:.24},height:{fraction:.2},accepts:[`selfView`],zBase:100}]},"canvas-sheet":{id:`canvas-sheet`,soloVariant:`canvas-solo`,regions:[{name:`stage`,x:{fraction:0},y:{fraction:0},width:{fraction:1},height:{fraction:.55},accepts:[`replica`],zBase:0},{name:`canvasSheet`,x:{fraction:0},y:{fraction:.55},width:{fraction:1},height:{fraction:.45},accepts:[`card`],zBase:10},{name:`pip`,x:{fraction:.66},y:{fraction:.33},width:{fraction:.3},height:{fraction:.18},accepts:[`selfView`],zBase:100}]},"content-columns":{id:`content-columns`,soloVariant:`content-solo`,regions:[{name:`replicaColumn`,x:{fraction:0},y:{fraction:0},width:{fraction:.25},height:{fraction:1},accepts:[`replica`,`selfView`],zBase:0},{name:`contentStage`,x:{fraction:.25},y:{fraction:0},width:{fraction:.75},height:{fraction:1},accepts:[`content`],zBase:0},{name:`pip`,x:{fraction:.02},y:{fraction:.76},width:{fraction:.2},height:{fraction:.2},accepts:[`selfView`],zBase:100}]},"content-stack":{id:`content-stack`,soloVariant:`content-solo`,regions:[{name:`contentStage`,x:{fraction:0},y:{fraction:0},width:{fraction:1},height:{fraction:.62},accepts:[`content`],zBase:0},{name:`replicaBand`,x:{fraction:0},y:{fraction:.62},width:{fraction:1},height:{fraction:.38},accepts:[`replica`],zBase:0},{name:`pip`,x:{fraction:.72},y:{fraction:.74},width:{fraction:.24},height:{fraction:.22},accepts:[`selfView`],zBase:100}]},"content-stack-compact":{id:`content-stack-compact`,soloVariant:`content-solo`,regions:[{name:`contentStage`,x:{fraction:0},y:{fraction:0},width:{fraction:1},height:{fraction:.58},accepts:[`content`],zBase:0},{name:`replicaStrip`,x:{fraction:0},y:{fraction:.58},width:{fraction:1},height:{fraction:.42},accepts:[`replica`],zBase:0},{name:`pip`,x:{fraction:.66},y:{fraction:.78},width:{fraction:.3},height:{fraction:.18},accepts:[`selfView`],zBase:100}]},"content-sheet-compact":{id:`content-sheet-compact`,soloVariant:`content-sheet-solo`,regions:[{name:`contentStage`,x:{fraction:0},y:{fraction:0},width:{fraction:1},height:{fraction:.58},accepts:[`content`],zBase:0},{name:`replicaStrip`,x:{fraction:0},y:{fraction:.58},width:{fraction:1},height:{fraction:.42},accepts:[`replica`],zBase:0},{name:`cardSheet`,x:{fraction:0},y:{fraction:0},width:{fraction:1},height:{fraction:1},accepts:[`card`],zBase:100},{name:`pip`,x:{fraction:.66},y:{fraction:.78},width:{fraction:.3},height:{fraction:.18},accepts:[`selfView`],zBase:110}]},"content-rail":{id:`content-rail`,soloVariant:`content-rail-solo`,regions:[{name:`replicaColumn`,x:{fraction:0},y:{fraction:0},width:{fraction:.22},height:{fraction:1},accepts:[`replica`,`selfView`],zBase:0},{name:`contentStage`,x:{fraction:.22},y:{fraction:0},width:{fraction:.48},height:{fraction:1},accepts:[`content`],zBase:0},{name:`rail`,x:{px:-448},y:{px:0},width:{px:448},height:{fraction:1},accepts:[`card`],zBase:0},{name:`pip`,x:{fraction:.02},y:{fraction:.78},width:{fraction:.18},height:{fraction:.18},accepts:[`selfView`],zBase:100}]},"content-stack-canvas":{id:`content-stack-canvas`,soloVariant:`content-sheet-solo`,regions:[{name:`contentStage`,x:{fraction:0},y:{fraction:0},width:{fraction:1},height:{fraction:.5},accepts:[`content`],zBase:0},{name:`replicaBand`,x:{fraction:0},y:{fraction:.5},width:{fraction:1},height:{fraction:.22},accepts:[`replica`],zBase:0},{name:`canvasBand`,x:{fraction:0},y:{fraction:.72},width:{fraction:1},height:{fraction:.28},accepts:[`card`],zBase:0},{name:`pip`,x:{fraction:.72},y:{fraction:.52},width:{fraction:.24},height:{fraction:.18},accepts:[`selfView`],zBase:100}]},"canvas-takeover-columns":{id:`canvas-takeover-columns`,soloVariant:`canvas-solo`,regions:[{name:`replicaColumn`,x:{fraction:0},y:{fraction:0},width:{fraction:.24},height:{fraction:1},accepts:[`replica`,`selfView`],zBase:0},{name:`canvasStage`,x:{fraction:.24},y:{fraction:0},width:{fraction:.76},height:{fraction:1},accepts:[`card`],zBase:0},{name:`pip`,x:{fraction:.02},y:{fraction:.78},width:{fraction:.18},height:{fraction:.18},accepts:[`selfView`],zBase:100}]},"canvas-takeover-strip":{id:`canvas-takeover-strip`,soloVariant:`canvas-solo`,regions:[{name:`canvasStage`,x:{fraction:0},y:{fraction:0},width:{fraction:1},height:{fraction:.78},accepts:[`card`],zBase:0},{name:`replicaStrip`,x:{fraction:0},y:{fraction:.78},width:{fraction:1},height:{fraction:.22},accepts:[`replica`],zBase:0},{name:`pip`,x:{fraction:.66},y:{fraction:.8},width:{fraction:.3},height:{fraction:.16},accepts:[`selfView`],zBase:100}]},"canvas-solo":{id:`canvas-solo`,regions:[{name:`canvasStage`,x:{fraction:0},y:{fraction:0},width:{fraction:1},height:{fraction:1},accepts:[`card`],zBase:0}]},"content-solo":{id:`content-solo`,regions:[{name:`contentStage`,x:{fraction:0},y:{fraction:0},width:{fraction:1},height:{fraction:1},accepts:[`content`],zBase:0}]},"content-rail-solo":{id:`content-rail-solo`,regions:[{name:`contentStage`,x:{px:0},y:{px:0},width:{fraction:1},height:{fraction:1},accepts:[`content`],zBase:0},{name:`rail`,x:{px:-448},y:{px:0},width:{px:448},height:{fraction:1},accepts:[`card`],zBase:0}]},"content-sheet-solo":{id:`content-sheet-solo`,regions:[{name:`contentStage`,x:{fraction:0},y:{fraction:0},width:{fraction:1},height:{fraction:.62},accepts:[`content`],zBase:0},{name:`canvasBand`,x:{fraction:0},y:{fraction:.62},width:{fraction:1},height:{fraction:.38},accepts:[`card`],zBase:10}]}},MF={idle:{compact:{short:`idle`,regular:`idle`},medium:{short:`idle`,regular:`idle`},expanded:{short:`idle`,regular:`idle`}},conversation:{compact:{short:`conversation-full`,regular:`conversation-full`},medium:{short:`conversation-full`,regular:`conversation-full`},expanded:{short:`conversation-full`,regular:`conversation-full`}},"conversation-canvas":{compact:{short:`canvas-sheet`,regular:`canvas-sheet`},medium:{short:`canvas-rail`,regular:`canvas-stack`},expanded:{short:`canvas-rail`,regular:`canvas-rail`}},"content-focus":{compact:{short:`content-stack-compact`,regular:`content-stack-compact`},medium:{short:`content-columns`,regular:`content-stack`},expanded:{short:`content-columns`,regular:`content-columns`}},"content-plus-canvas":{compact:{short:`content-sheet-compact`,regular:`content-sheet-compact`},medium:{short:`content-rail`,regular:`content-stack-canvas`},expanded:{short:`content-rail`,regular:`content-rail`}},"canvas-dominant":{compact:{short:`canvas-takeover-strip`,regular:`canvas-takeover-strip`},medium:{short:`canvas-takeover-columns`,regular:`canvas-takeover-columns`},expanded:{short:`canvas-takeover-columns`,regular:`canvas-takeover-columns`}}};function NF(e,t,n=jF,r=MF,i=!0){let a=r[e][t.width][t.height],o=n[a];if(!o)throw Error(`Template matrix references missing template id: ${a}`);if(!i&&o.soloVariant!==void 0){let e=n[o.soloVariant];if(!e)throw Error(`soloVariant references missing template id: ${o.soloVariant}`);return e}return o}function PF(e,t,n){let r=[],{prefs:i}=e,a=e.userShare?`userShare`:e.presentation?`presentation`:null,o=e.cards.length>0,s=t.width===`compact`;return i.pipCorner!==void 0&&s&&r.push(`pipCorner`),a===null?(i.expandCanvas&&!o&&r.push(`expandCanvas`),o&&(i.expandCanvas||s)?{state:`canvas-dominant`,suppressedPrefs:r,contentKind:null}:o?{state:`conversation-canvas`,suppressedPrefs:r,contentKind:null}:e.replica||e.selfView?{state:`conversation`,suppressedPrefs:r,contentKind:null}:{state:`idle`,suppressedPrefs:r,contentKind:null}):(i.expandCanvas&&r.push(`expandCanvas`),{state:o?`content-plus-canvas`:`content-focus`,suppressedPrefs:r,contentKind:a})}var FF={alert:{minWidthPx:220,sizeClass:()=>`S`,estimateHeightPx:e=>e.charCount===void 0?120:Math.min(400,Math.round(90+e.charCount*.26))},input:{minWidthPx:220,sizeClass:()=>`S`,estimateHeightPx:()=>182},question:{minWidthPx:240,sizeClass:e=>{let t=e.optionCount??4;return t<=2?`S`:t>=10?`L`:`M`},estimateHeightPx:e=>{let t=e.optionCount??4;return 72+t*48+(t-1)*8+64}},text:{minWidthPx:220,sizeClass:e=>(e.charCount??400)>1500?`L`:`M`,estimateHeightPx:e=>{let t=e.charCount??400,n=Math.max(1,e.widthPx/8);return Math.max(100,Math.round(t/n*22+40))}},chart:{minWidthPx:260,sizeClass:()=>`M`,estimateHeightPx:e=>Math.round(e.widthPx*(260/480))+90},calendar:{minWidthPx:320,sizeClass:e=>e.slotCount===void 0?`M`:`L`,estimateHeightPx:e=>e.slotCount===void 0?470:64+e.slotCount*48},image:{minWidthPx:240,sizeClass:()=>`M`,estimateHeightPx:e=>Math.round((Math.min(e.widthPx,520)-36)*(9/16))+95+((e.imageCount??1)>1?44:0)},scheduling_embed:{minWidthPx:320,hardMinHeightPx:640,sizeClass:()=>`L`,estimateHeightPx:()=>640}},IF={minWidthPx:240,sizeClass:()=>`M`,estimateHeightPx:e=>e.coldDefaultHeightPx??320},LF=`canvas.`;function RF(e){return e.startsWith(LF)?e.slice(7):e}function zF(e,t){let n=RF(e),r=FF[n]??IF,i=t?.[n]??t?.[e];return i===void 0?r:{...r,minWidthPx:i.minWidthPx??r.minWidthPx,...i.hardMinHeightPx===void 0?r.hardMinHeightPx===void 0?{}:{hardMinHeightPx:r.hardMinHeightPx}:{hardMinHeightPx:i.hardMinHeightPx}}}Object.keys(FF);function BF(e,t,n){let r=zF(e,n),i=(t.naturalHeightPx!==void 0&&Number.isFinite(t.naturalHeightPx)?t.naturalHeightPx:void 0)??r.estimateHeightPx(t),a=r.hardMinHeightPx===void 0?i:Math.max(r.hardMinHeightPx,i);return{sizeClass:r.sizeClass(t),minWidthPx:r.minWidthPx,naturalHeightPx:Math.round(a),hardMinHeightPx:r.hardMinHeightPx}}function VF(e,t){let n=RF(e);return FF[n]===void 0?(t?.[n]??t?.[e])?.hardMinHeightPx:zF(e,t).hardMinHeightPx}function HF(e,t){return zF(e,t).minWidthPx}function UF(e,t){let n=Number.isFinite(e)?e:t.card.coldDefaultHeightPx;return Math.min(t.card.maxHeightPx,Math.max(t.card.reportedHeightFloorPx,Math.round(n)))}function WF(e,t,n){if(t>=e)return{kind:`natural`};if(t<=0||e<=0)return{kind:`scroll`};let r=t/e;return r>=n.card.minDisplayScale?{kind:`scaled`,factor:r}:{kind:`scroll`}}function GF(e,t){return e.width>0&&e.height>0&&t.width>0&&t.height>0&&e.x<t.x+t.width&&t.x<e.x+e.width&&e.y<t.y+t.height&&t.y<e.y+e.height}function KF(e,t){return t.x>=e.x&&t.y>=e.y&&t.x+t.width<=e.x+e.width&&t.y+t.height<=e.y+e.height}function qF(e,t,n){let r=[],i=e.find(e=>e.kind===`replica`),a=e=>e.kind===`selfView`&&e.layer===`overlay`&&i!==void 0&&KF(i.rect,e.rect),o=e=>e.kind===`card`&&e.layer===`overlay`&&e.sheet===!0;for(let a of e){let e=a.rect;if(Number.isInteger(e.x)&&Number.isInteger(e.y)&&Number.isInteger(e.width)&&Number.isInteger(e.height)||r.push({kind:`bounds`,tileId:a.id,message:`${a.id} has non-integer coordinates`}),(e.x<0||e.y<0||e.width<0||e.height<0||e.x+e.width>t.width||e.y+e.height>t.height)&&r.push({kind:`bounds`,tileId:a.id,message:`${a.id} rect exceeds the container`}),a.layer===`overlay`&&a.kind!==`selfView`&&!o(a)&&r.push({kind:`overlay-legality`,tileId:a.id,message:`only selfView or a sheet card may ride the overlay layer, got ${a.kind}`}),a.kind===`selfView`&&a.layer===`overlay`&&i!==void 0&&!KF(i.rect,a.rect)&&r.push({kind:`overlay-legality`,tileId:a.id,message:`selfView escapes the replica rect`}),(a.kind===`content`||a.kind===`replica`)&&(e.width<48||e.height<48)&&r.push({kind:`degenerate-surface`,tileId:a.id,message:`${a.kind} tile ${a.id} is ${e.width}x${e.height}px, below the 48px visible floor`}),a.kind===`card`){a.fit.kind===`scaled`&&(a.fit.factor<n.card.minDisplayScale||a.fit.factor>1)&&r.push({kind:`min-content`,tileId:a.id,message:`card ${a.id} scaled to ${a.fit.factor}, outside [${n.card.minDisplayScale}, 1]`}),e.height<n.card.reportedHeightFloorPx&&r.push({kind:`min-content`,tileId:a.id,message:`card ${a.id} box ${e.height}px is below the ${n.card.reportedHeightFloorPx}px report floor`});let t=a.component===void 0?void 0:VF(a.component,n.card.componentOverrides);t!==void 0&&e.height<t&&a.fit.kind!==`scroll`&&r.push({kind:`min-content`,tileId:a.id,message:`card ${a.id} box ${e.height}px is below its ${t}px hard min without scroll`});let i=a.component===void 0?void 0:HF(a.component,n.card.componentOverrides);i!==void 0&&e.width<i&&r.push({kind:`min-content`,tileId:a.id,message:`card ${a.id} box ${e.width}px is below its ${i}px min width`})}}for(let t of e)if(!(t.kind!==`content`&&t.kind!==`card`))for(let n of e)n.id!==t.id&&GF(t.rect,n.rect)&&(a(n)&&!o(t)||o(n)&&!o(t)||o(t)&&n.layer===`grid`||r.push({kind:`never-covered`,tileId:t.id,otherTileId:n.id,message:`${n.id} covers ${t.kind} tile ${t.id}`}));return r}var JF=(e,t,n)=>Math.min(n,Math.max(t,e));function YF(e,t){let n=t===`compact`;return{surfacePad:Math.round(n?e.insets.compactSurfacePadPx:e.insets.surfacePadPx),cardsPad:Math.round(n?e.insets.compactCardsPadPx:e.insets.cardsPadPx)}}function XF(e,t,n){return e===`canvas-dominant`&&t.width===`compact`?n.eviction.compactTakeoverMaxCards:n.eviction.maxVisibleCards}function ZF(e,t,n){let r=[...e].sort((e,t)=>e.dispatchSeq-t.dispatchSeq),i=Math.floor(t);return r.length<=i?r:n===`evict-newest`?r.slice(0,i):r.slice(r.length-i)}function QF(e,t,n,r,i,a){let o=i??YF(n,r).cardsPad,s=Math.round(a??n.rail.widthPx),c=Math.max(1,Math.min(t-2*o,s-2*o));return{innerW:c,entries:e.map(e=>{let t=BF(e.component,{...e.contentOpts,naturalHeightPx:e.naturalHeightPx,widthPx:c,coldDefaultHeightPx:n.card.coldDefaultHeightPx},n.card.componentOverrides);return{card:e,constraints:t,clampedHeightPx:UF(t.naturalHeightPx,n)}})}}function $F(e,t){return`fraction`in e?e.fraction*t:e.px>=0?e.px:t+e.px}function eI(e,t,n,r){return e.name!==`rail`||`fraction`in t?t:r===`width`?{px:n.rail.widthPx}:{px:t.px<0?-n.rail.widthPx:t.px}}function tI(e,t,n,r,i,a){let o=n===`x`?t.width:t.height,s=[...e].sort((e,t)=>$F(n===`x`?e.x:e.y,o)-$F(n===`x`?t.x:t.y,o)),c=s.map(e=>n===`x`?eI(e,e.width,r,`width`):e.height),l=0,u=0;for(let e of c)`px`in e?l+=e.px:u+=e.fraction;let d=Math.max(0,o-l),f=c.map(e=>`px`in e?e.px:u>0?e.fraction/u*d:0);if(n===`y`&&i!==void 0){let e=s.findIndex((e,t)=>e.accepts.includes(`card`)&&`fraction`in(c[t]??e.height));if(e!==-1){let t=f[e]??0,n=i.shrinkToContent?Math.min(i.neededPx,Math.max(t,i.capPx)):JF(i.neededPx,t,Math.max(t,i.capPx)),r=0,a=0;c.forEach((t,n)=>{n!==e&&(`px`in t?r+=t.px:a+=f[n]??0)});let s=Math.max(0,o-r-n);f=f.map((t,r)=>{if(r===e)return n;let i=c[r];return i!==void 0&&`px`in i?t:a>0?t/a*s:0})}}if(n===`y`&&a!==void 0){let e=s.findIndex((e,t)=>e.accepts.includes(`content`)&&`fraction`in(c[t]??e.height)),t=s.findIndex((e,t)=>e.accepts.includes(`replica`)&&`fraction`in(c[t]??e.height));if(e!==-1&&t!==-1){let n=(f[e]??0)-a.maxPx;n>0&&(f[e]=a.maxPx,f[t]=(f[t]??0)+n)}}let p=s.map(e=>e.accepts.includes(`content`)||e.accepts.includes(`replica`)?48:0),m=p.reduce((e,t)=>e+t,0),h=m>o?o/m:1,g=f.map((e,t)=>Math.max(e,(p[t]??0)*h));if(g.reduce((e,t)=>e+t,0)>o){let e=g.map((e,t)=>e-(p[t]??0)*h),t=e.reduce((e,t)=>e+t,0),n=Math.max(0,o-m*h),r=t>0?n/t:0;f=g.map((t,n)=>(p[n]??0)*h+(e[n]??0)*r)}else f=g;let _=[0],v=0;for(let e of f)v+=e,_.push(JF(Math.round(v),0,o));return s.map((e,r)=>{let i=_[r]??0,a=_[r+1]??i;return{region:e,rect:n===`x`?{x:i,y:0,width:a-i,height:t.height}:{x:0,y:i,width:t.width,height:a-i}}})}function nI(e,t,n){let r=t.width,i=t.height,a=eI(e,e.width,n,`width`),o=eI(e,e.x,n,`x`),s=JF(Math.round($F(o,r)),0,r),c=JF(Math.round($F(e.y,i)),0,i);return{x:s,y:c,width:JF(Math.round(`fraction`in a?a.fraction*r:a.px),0,r-s),height:JF(Math.round(`fraction`in e.height?e.height.fraction*i:e.height.px),0,i-c)}}function rI(e,t,n,r,i){let a=e.regions.filter(e=>e.zBase<100),o=e=>`fraction`in e&&e.fraction===1;return a.length>1&&a.every(e=>o(e.height))?tI(a,t,`x`,n):a.length>1&&a.every(e=>o(e.width))?tI(a,t,`y`,n,r,i):a.map(e=>({region:e,rect:nI(e,t,n)}))}function iI(e,t,n,r,i,a,o,s,c,l,u){if(n!==null)return;let d=e.regions.filter(e=>e.zBase<100);if(!(d.length>1&&d.every(e=>`fraction`in e.width&&e.width.fraction===1)))return;let f=d.find(e=>e.accepts.includes(`card`)&&`fraction`in e.height);if(f===void 0||r.cards.length===0)return;let{innerW:p,entries:m}=QF(ZF(r.cards,u,c.eviction.policy),i.width,c,l,void 0,c.card.stackMaxWidthPx),h=m.reduce((e,t)=>t.constraints.minWidthPx>p?e:Math.max(e,t.clampedHeightPx),0),{cardsPad:g}=YF(c,l),_=$F(f.y,i.height),v=d.every(e=>$F(e.y,i.height)<=_),y=v?Math.max(0,o-s):0,b=!v&&h>0;return{neededPx:h+2*g+(b?0:y),capPx:Math.round(c.card.stackBandMaxFraction*a.height),...b&&{shrinkToContent:b}}}function aI(e,t,n,r){if(t===null)return;let i=e.regions.filter(e=>e.zBase<100);if(!(i.length>1&&i.every(e=>`fraction`in e.width&&e.width.fraction===1)))return;let a=i.some(e=>e.accepts.includes(`content`)&&`fraction`in e.height),o=i.some(e=>e.accepts.includes(`replica`)&&`fraction`in e.height);if(!a||!o)return;let s=r.content.stackedAspect;if(!(!Number.isFinite(s)||s<=0))return{maxPx:Math.round(n.width/s)}}var oI=`bottom-left`;function sI(e,t,n,r,i){let a=t.endsWith(`right`)?e.x+e.width-n-r:e.x+n,o=t.startsWith(`bottom`)?e.y+e.height-n-i:e.y+n;return{x:Math.round(a),y:Math.round(o),width:r,height:i}}function cI(e,t,n,r){let i=Math.max(n.pip.minWidthPx,Math.round(e.width*.25)),a=r?e.height-t:Math.round((e.height-t)*16/9),o=Math.min(i,e.width-t,a),s=r?o:Math.round(o*9/16);return o<n.pip.minWidthPx||o<=0||s<=0?null:{w:o,h:s}}function lI(e,t,n){return t===null||!GF(e,t)?e:{...e,y:Math.round(t.y)-n-e.height}}function uI(e){if(typeof e!=`object`||!e)return!1;let t=e;return[`x`,`y`,`width`,`height`].every(e=>typeof t[e]==`number`&&Number.isFinite(t[e]))}function dI(e,t,n){let r=e;for(let e of t.filter(uI).sort((e,t)=>t.y-e.y))r=lI(r,e,n);return r}function fI(e,t,n){if(t<=0)return e;let r=Math.min(t,e.length);return n===`evict-newest`?e.slice(0,e.length-r):e.slice(r)}function pI(e,t,n,r,i,a){let o=n.callControls===!0?Math.round(a.insets.callControlsBottomPx):0,s=i.height-o,c=n.selfView&&n.prefs.hideSelfView!==!0,l=(n.replica||c?1:0)+(t.contentKind===null?0:1)+ +(n.cards.length>0)>=2?YF(a,r.width).surfacePad:0,u={width:Math.max(0,i.width-2*l),height:Math.max(0,i.height-2*l)},d=n.callControlsRect??(o>0?{x:0,y:s,width:i.width,height:o}:null);return{regions:rI(e,u,a,iI(e,t.state,t.contentKind,n,u,i,o,l,a,r.width,XF(t.state,r,a)),aI(e,t.contentKind,u,a)).map(e=>({...e,rect:{...e.rect,x:e.rect.x+l,y:e.rect.y+l}})).map(e=>d===null||!e.region.accepts.includes(`card`)||!(e.rect.x<d.x+d.width&&e.rect.x+e.rect.width>d.x)?e:{...e,rect:{...e.rect,height:Math.max(0,Math.min(e.rect.height,s-e.rect.y))}}),surfacePad:l,controlsInset:o,bandTopY:s}}function mI(e,t,n,r,i,a){let o=n.selfView&&n.prefs.hideSelfView!==!0,{regions:s,surfacePad:c,controlsInset:l,bandTopY:u}=pI(t,e,n,r,i,a),d=s.find(e=>e.region.accepts.includes(`replica`)),f=s.find(e=>e.region.accepts.includes(`content`)),p=s.find(e=>e.region.accepts.includes(`card`)),m=t.regions.find(e=>e.zBase>=100&&e.accepts.includes(`selfView`)),h=t.regions.find(e=>e.zBase>=100&&e.accepts.includes(`card`)),g=Math.round(a.rail.gutterPx),_=Math.round(a.pip.gapPaddingPx),v=[...n.cards].sort((e,t)=>e.dispatchSeq-t.dispatchSeq),y=XF(e.state,r,a),b=p?ZF(n.cards,y,a.eviction.policy):h===void 0?[]:ZF(n.cards,1,a.eviction.policy),x=s=>{let y={evictedCardIds:[],selfViewDropped:!1,replicaCollapsed:!1},x=[],S=null,C=!1,w=d!==void 0&&d.region.accepts.includes(`selfView`);if(d&&w&&(n.replica||o)){let e=d.rect,t=o&&!s.selfViewDropped;o&&s.selfViewDropped&&(y.selfViewDropped=!0);let r=+!!n.replica+ +!!t,i=Math.round(a.insets.participantsPadPx),c=Math.max(1,e.width-2*i),l=Math.round(c*9/16),u=e=>r*e+(r-1)*i;u(l)>e.height&&(l=Math.max(1,Math.floor((e.height-(r-1)*i)/r)),c=Math.min(Math.max(1,e.width-2*i),Math.round(l*16/9))),l=Math.max(l,Math.min(48,e.height)),c=Math.max(c,Math.min(48,e.width));let f=e.x+Math.round((e.width-c)/2),p=e.y+Math.round((e.height-u(l))/2);if(n.replica){let e={x:f,y:p,width:c,height:l};if(s.replicaCollapsed){let t=Math.min(l,Math.max(64,Math.round(l*.25)));e={...e,height:t},y.replicaCollapsed=!0}S={id:`replica`,kind:`replica`,rect:e,layer:`grid`,order:d.region.zBase,fit:{kind:`natural`},region:d.region.name},x.push(S),p+=l+i}t&&(x.push({id:`selfView`,kind:`selfView`,rect:{x:f,y:p,width:c,height:l},layer:`grid`,order:d.region.zBase,fit:{kind:`natural`},region:d.region.name}),C=!0)}else if(d&&(n.replica||o)){let e=!n.replica,t=d.rect;if(!e&&s.replicaCollapsed){let e=Math.min(t.height,Math.max(64,Math.round(t.height*.25)));t={...t,height:e},y.replicaCollapsed=!0}let r={id:e?`selfView`:`replica`,kind:e?`selfView`:`replica`,rect:t,layer:`grid`,order:d.region.zBase,fit:{kind:`natural`},region:d.region.name};x.push(r),e?C=!0:S=r}e.contentKind!==null&&f&&x.push({id:`content`,kind:`content`,rect:f.rect,layer:`grid`,order:f.region.zBase,fit:{kind:`natural`},region:f.region.name});let T=fI(b,s.extraEvictions,a.eviction.policy),E=new Set(T.map(e=>e.id));if(y.evictedCardIds=v.filter(e=>!E.has(e.id)).map(e=>e.id),p&&T.length>0){let e=p.rect,n=t.regions.filter(e=>e.zBase<100),i=n.length>1&&n.every(e=>`fraction`in e.width&&e.width.fraction===1),{innerW:o,entries:s}=QF(T,e.width,a,r.width,void 0,i?a.card.stackMaxWidthPx:void 0),c=e.x+Math.round((e.width-o)/2),l=e.height-g*(s.length-1),u=s.reduce((e,t)=>e+t.clampedHeightPx,0),d;if(u<=l)d=s.map(e=>e.clampedHeightPx);else{let e=l>0?l/u:0;d=s.map(t=>Math.max(a.card.reportedHeightFloorPx,Math.floor(t.clampedHeightPx*e)));let t=d.reduce((e,t)=>e+t,0)-Math.max(0,l);for(;t>0;){let e=-1;for(let t=0;t<d.length;t++){let n=d[t]??0;n>a.card.reportedHeightFloorPx&&(e===-1||n>(d[e]??0))&&(e=t)}if(e===-1)break;d[e]=(d[e]??0)-1,--t}}let f=d.reduce((e,t)=>e+t,0)+g*(s.length-1),m=e.y+Math.max(0,Math.round((e.height-f)/2));s.forEach((t,n)=>{let r=Math.min(m,e.y+e.height),i=Math.max(0,Math.min(d[n]??0,e.y+e.height-r)),s=WF(t.clampedHeightPx,i,a),l=t.constraints.hardMinHeightPx;l!==void 0&&i<l&&s.kind!==`scroll`&&(s={kind:`scroll`}),x.push({id:t.card.id,kind:`card`,component:t.card.component,cardSizeClass:t.constraints.sizeClass,rect:{x:c,y:r,width:o,height:i},layer:`grid`,order:p.region.zBase+n,fit:s,region:p.region.name}),m=r+i+g})}let D=null;if(p===void 0&&h!==void 0&&T.length>0){let e={width:Math.max(0,i.width-2*c),height:Math.max(0,i.height-2*c)},t=nI(h,e,a),n={x:t.x+c,y:t.y+c,width:t.width,height:Math.max(0,Math.min(t.height,u-(t.y+c)))},{innerW:o,entries:s}=QF(T,n.width,a,r.width,0,a.card.stackMaxWidthPx),l=s[0];if(l!==void 0){let e=n.x+Math.round((n.width-o)/2),t=Math.max(0,Math.min(l.clampedHeightPx,n.height)),r=WF(l.clampedHeightPx,t,a),i=l.constraints.hardMinHeightPx;i!==void 0&&t<i&&r.kind!==`scroll`&&(r={kind:`scroll`}),D={id:l.card.id,kind:`card`,component:l.card.component,cardSizeClass:l.constraints.sizeClass,rect:{x:e,y:n.y,width:o,height:t},layer:`overlay`,order:h.zBase,fit:r,region:h.name,sheet:!0},x.push(D)}}if(!C){if(o&&s.selfViewDropped)y.selfViewDropped=!0;else if(o){let t=e.suppressedPrefs.includes(`pipCorner`)?oI:n.prefs.pipCorner??`bottom-left`,o=n.callControlsVisible===!1?null:n.callControlsRect??(l>0?{x:0,y:u,width:i.width,height:l}:null),s=[...o===null?[]:[o],...D===null?[]:[D.rect],...n.chromeObstacles??[]];if(S){let e=S.rect,n=cI(e,_,a,r.width===`compact`),i=n===null?null:sI(e,t,_,n.w,n.h),o=i===null?null:dI(i,s,_),c=n!==null&&o!==null&&o.y>=e.y&&n.w+_<=e.width&&n.h+_<=e.height,l=n!==null&&e.width>0&&e.height>0?n.w*n.h/(e.width*e.height):1/0;o!==null&&c&&l<=a.pip.maxAreaRatio?x.push({id:`selfView`,kind:`selfView`,rect:o,layer:`overlay`,order:m?.zBase??100,fit:{kind:`natural`},region:m?.name??`pip`}):y.selfViewDropped=!0}else{let e=a.pip.minWidthPx,n=r.width===`compact`?e:Math.round(e*9/16),o={x:0,y:0,width:i.width,height:i.height},c=dI(sI(o,t,_,e,n),s,_),l=c.y>=0&&e+_<=o.width&&n+_<=o.height,u=x.some(e=>(e.kind===`content`||e.kind===`card`)&&GF(e.rect,c));l&&!u?x.push({id:`selfView`,kind:`selfView`,rect:c,layer:`overlay`,order:m?.zBase??100,fit:{kind:`natural`},region:m?.name??`pip`}):y.selfViewDropped=!0}}}return{tiles:x,degradations:y}},S={extraEvictions:0,selfViewDropped:!1,replicaCollapsed:!1},C=x(S),w=qF(C.tiles,i,a);for(let e of a.degradationLadder){if(w.length===0)break;if(e===`evict-cards`)for(;w.length>0&&S.extraEvictions<b.length;)S={...S,extraEvictions:S.extraEvictions+1},C=x(S),w=qF(C.tiles,i,a);else e===`drop-self-view`?C.tiles.some(e=>e.kind===`selfView`)&&(S={...S,selfViewDropped:!0},C=x(S),w=qF(C.tiles,i,a)):e===`collapse-replica`&&!S.replicaCollapsed&&C.tiles.some(e=>e.kind===`replica`)&&(S={...S,replicaCollapsed:!0},C=x(S),w=qF(C.tiles,i,a))}return C}function hI(e){if(!(e===void 0||e.length===0))return{...jF,...Object.fromEntries(e.map(e=>[e.id,e]))}}function gI(e,t,n,r){let i={width:Math.max(0,Math.round(e.container.widthPx)),height:Math.max(0,Math.round(e.container.heightPx))},a=PF(e,t,n),o=e.replica||e.selfView&&e.prefs.hideSelfView!==!0,s=NF(a.state,t,hI(r?.templates),void 0,o),{tiles:c,degradations:l}=mI(a,s,e,t,i,n);return{state:a.state,sizeClass:t,containerPx:i,templateId:s.id,tiles:c,degradations:l,suppressedPrefs:[...a.suppressedPrefs]}}var _I={compact:0,medium:1,expanded:2};function vI(e,t){return e.width===t.width&&e.height===t.height}function yI(e,t,n,r,i){let a=e.committedClass;if(a===null)return{committedClass:t,pendingClass:null,pendingSinceMs:null};if(vI(t,a))return{committedClass:a,pendingClass:null,pendingSinceMs:null};let o=Math.abs(_I[t.width]-_I[a.width]),s=e.lastResolution?.containerPx.width??null;return o>1||s===null||Math.abs(Math.round(n)-s)>=i.hysteresis.decisiveJumpPxDelta?{committedClass:t,pendingClass:null,pendingSinceMs:null}:e.pendingClass!==null&&e.pendingSinceMs!==null&&vI(e.pendingClass,t)?r-e.pendingSinceMs>=i.hysteresis.windowMs?{committedClass:t,pendingClass:null,pendingSinceMs:null}:{committedClass:a,pendingClass:e.pendingClass,pendingSinceMs:e.pendingSinceMs}:{committedClass:a,pendingClass:t,pendingSinceMs:r}}var bI=(e,t)=>e<t?-1:+(e>t);function xI(e,t){let n=new Map((e?.tiles??[]).map(e=>[e.id,e])),r=new Map(t.tiles.map(e=>[e.id,e])),i=[];for(let e of[...n.keys()].sort(bI))r.has(e)||i.push({type:`exit`,tileId:e});let a=[],o=[],s=[];for(let e of[...r.keys()].sort(bI)){let t=n.get(e);if(t===void 0){a.push({type:`enter`,tileId:e});continue}let i=r.get(e);if(t.layer!==i.layer){o.push(i.layer===`overlay`?{type:`promote`,tileId:e,toLayer:i.layer}:{type:`demote`,tileId:e,toLayer:i.layer});continue}let c=t.rect.x!==i.rect.x||t.rect.y!==i.rect.y,l=t.rect.width!==i.rect.width||t.rect.height!==i.rect.height;c?s.push({type:`move`,tileId:e,from:t.rect,to:i.rect}):l&&s.push({type:`resize`,tileId:e,from:t.rect,to:i.rect})}return[...i,...a,...o,...s]}function SI(e,t,n,r,i){let a=yI(e,AF(t.container,r),t.container.widthPx,n,r),o=gI(t,a.committedClass,r,i);return{resolution:o,transitions:xI(e.lastResolution,o),nextState:{committedClass:a.committedClass,pendingClass:a.pendingClass,pendingSinceMs:a.pendingSinceMs,lastResolution:o}}}var CI=`0.1.12`,wI=OF,TI=(()=>{try{return new URLSearchParams(globalThis.location?.search??``).get(`grid_enabled`)===`1`}catch{return!1}})(),EI=(()=>{try{return new URLSearchParams(globalThis.location?.search??``).get(`grid_debug`)===`1`}catch{return!1}})();function DI(e,t){return TI||e===!0||t===!0}function OI({instances:e,viewport:t,presence:n,callControlsBandPx:r,callControlsVisible:i,callControlsRect:a,reportedHeights:o}){return{container:{widthPx:t.width,heightPx:Math.round(Math.min(t.height,t.visualViewportHeight??t.height))},replica:n.hasPersonaVideo,selfView:n.hasSelfView,presentation:n.isPersonaPresenting?{}:null,userShare:n.isScreenSharing?{}:null,cards:e.map((e,t)=>({id:e.id,component:e.canvas_config.component,dispatchSeq:t+1,...o[e.id]===void 0?{}:{naturalHeightPx:o[e.id]}})),prefs:{},callControls:r>0,callControlsVisible:i??!0,...a===void 0?{}:{callControlsRect:a}}}var kI=16,AI=200,jI=Yt(null);function MI(e){jI.peek()===null&&(console.error(`Magic Grid engine error; rendering the legacy layout.`,e),jI.value=(e instanceof Error?`${e.name}: ${e.message}`:String(e)).slice(0,AI))}function NI(){jI.peek()!==null&&(jI.value=null)}function PI({instances:e,viewport:t,presence:n,callControlsBandPx:r,callControlsVisible:i,callControlsRect:a,enabled:o}){let s=N(wI),c=N(null),[l,u]=j({}),[d,f]=j(null),p=F((e,t)=>{o&&u(n=>n[e]===t?n:{...n,[e]:t})},[o]);M(()=>{u(t=>{let n=new Set(e.map(e=>e.id)),r={};for(let[e,i]of Object.entries(t))n.has(e)&&(r[e]=i);return Object.keys(r).length===Object.keys(t).length?t:r})},[e]);let m=P(()=>OI({instances:e,viewport:t,presence:n,callControlsBandPx:r,callControlsVisible:i,callControlsRect:a,reportedHeights:l}),[e,t,n,r,i,a,l]);return M(()=>{if(!o||jI.peek()!==null)return;c.current===null&&(c.current=Date.now());let e=null,t=()=>{if(e=null,jI.peek()!==null)return;let n=Date.now()-(c.current??0),r;try{r=SI(s.current,m,n,kF)}catch(e){MI(e);return}if(s.current=r.nextState,f(r),r.nextState.pendingClass!==null){let i=r.nextState.pendingSinceMs===null?0:Math.max(0,n-r.nextState.pendingSinceMs);e=setTimeout(t,Math.max(kI,kF.hysteresis.windowMs-i+kI))}};return t(),()=>{e!==null&&clearTimeout(e)}},[o,m]),{resolution:o?d?.resolution??null:null,inputs:o?m:null,transitions:o?d?.transitions??[]:[],reportedHeights:l,recordNaturalHeight:p}}function FI(e,t,n){return n?e===null?`no-presence`:t.hasPersonaVideo?e.degradations.evictedCardIds.length>0?`card-dropped`:e.tiles.some(e=>e.kind===`card`&&e.fit.kind===`scroll`)?`card-overflow`:null:`no-persona-video`:`flag-off`}function II(e,t){if(t!==null||e===null)return null;let n=e.tiles.find(e=>e.kind===`card`&&e.sheet===!0);return n===void 0?null:n.rect.y+n.rect.height}var LI={driving:!1,containerPx:null,replica:null,selfView:null,content:null,replicaCollapsed:!1};function RI(e,t,n){if(e===null)return LI;let r=t===null;if(!r&&!(t===`no-persona-video`&&n))return LI;let i=t=>e.tiles.find(e=>e.kind===t)?.rect??null;return{driving:r,containerPx:e.containerPx,replica:r?i(`replica`):null,selfView:i(`selfView`),content:r?i(`content`):null,replicaCollapsed:r?e.degradations.replicaCollapsed:!1}}function zI(e){return e.selfView===null?e.driving?`hidden`:`legacy`:`engine`}function BI(e,t){return e.containerPx===null||t.containerPx===null?!1:e.containerPx.width===t.containerPx.width&&e.containerPx.height===t.containerPx.height}var VI=`conversation.grid_status`,HI=6e4;function UI(e,t,n){return n?e&&t?`url+config+start`:e?`url+start`:t?`config+start`:`start`:e&&t?`both`:e?`url`:`config`}function WI(e,t){return{message_type:`conversation`,event_type:VI,conversation_id:e,properties:t}}function GI(e){return{template_id:e.templateId,size_class:`${e.sizeClass.width}/${e.sizeClass.height}`,container:{w:e.containerPx.width,h:e.containerPx.height},cards:e.tiles.filter(e=>e.kind===`card`).length}}function KI(e){let{send:t,enabledVia:n,engineVersion:r=CI,now:i=Date.now,transitionDebounceMs:a=500,summaryIntervalMs:o=HI}=e,s=i(),c=!1,l=!1,u,d=null,f=null,p=!1,m=null,h=0,g=0,_={},v=null,y=e=>{try{t(e)}catch{}},b=(e,t)=>({v:1,kind:e,engine_version:r,enabled_via:n,bail:t,...v}),x=e=>{f=null;let t=u;if(t!==void 0&&e===t)return;let n=i();t===null&&m!==null&&(h+=n-m,m=null),e===null?m=n:_[e]=(_[e]??0)+1,t!==void 0&&(g+=1),e===null&&!p?(p=!0,y({...b(`first_drive`,null),...t===void 0?{}:{prev_bail:t}})):t!==void 0&&y({...b(`transition`,e),prev_bail:t}),u=e},S=e=>{let t=i(),n=h+(m===null?0:t-m);y({...b(`summary`,u??d??null),driving_ms:Math.round(n),total_ms:Math.round(t-s),bail_counts:{..._},transitions:g,...e?{final:!0}:{}})},C=setInterval(()=>S(!1),o);return{update(e,t){if(c)return;t!==null&&(v=GI(t));let n=f===null?u:d;n!==void 0&&e===n||(d=e,f!==null&&clearTimeout(f),f=setTimeout(()=>x(e),a))},error(e){c||l||(l=!0,y({...b(`error`,`engine-error`),error:e}))},dispose(){c||(c=!0,clearInterval(C),f!==null&&(clearTimeout(f),x(d)),S(!0))}}}function qI({enabled:e,enabledVia:t,bail:n,resolution:r,engineError:i}){let a=Th(),o=Qg(),s=I(av),c=N({daily:a,meetingState:o,conversation:s});c.current={daily:a,meetingState:o,conversation:s};let l=N(null);M(()=>{if(!e)return;let n=KI({enabledVia:t,send:e=>{try{let t=c.current;if(!t.daily||t.meetingState!==`joined-meeting`)return;let n=t.conversation?.session.peek()?.conversationId;if(!n)return;t.daily.sendAppMessage(WI(n,e),`*`)}catch{}}});return l.current=n,()=>{l.current=null,n.dispose()}},[e,t]),M(()=>{l.current?.update(n,r)},[n,r]),M(()=>{i!==null&&l.current?.error(i)},[i])}var JI=(e,t)=>{let n=Array(e.length+t.length);for(let t=0;t<e.length;t++)n[t]=e[t];for(let r=0;r<t.length;r++)n[e.length+r]=t[r];return n},YI=(e,t)=>({classGroupId:e,validator:t}),XI=(e=new Map,t=null,n)=>({nextPart:e,validators:t,classGroupId:n}),ZI=`-`,QI=[],$I=`arbitrary..`,eL=e=>{let t=rL(e),{conflictingClassGroups:n,conflictingClassGroupModifiers:r}=e;return{getClassGroupId:e=>{if(e.startsWith(`[`)&&e.endsWith(`]`))return nL(e);let n=e.split(ZI);return tL(n,+(n[0]===``&&n.length>1),t)},getConflictingClassGroupIds:(e,t)=>{if(t){let t=r[e],i=n[e];return t?i?JI(i,t):t:i||QI}return n[e]||QI}}},tL=(e,t,n)=>{if(e.length-t===0)return n.classGroupId;let r=e[t],i=n.nextPart.get(r);if(i){let n=tL(e,t+1,i);if(n)return n}let a=n.validators;if(a===null)return;let o=t===0?e.join(ZI):e.slice(t).join(ZI),s=a.length;for(let e=0;e<s;e++){let t=a[e];if(t.validator(o))return t.classGroupId}},nL=e=>e.slice(1,-1).indexOf(`:`)===-1?void 0:(()=>{let t=e.slice(1,-1),n=t.indexOf(`:`),r=t.slice(0,n);return r?$I+r:void 0})(),rL=e=>{let{theme:t,classGroups:n}=e;return iL(n,t)},iL=(e,t)=>{let n=XI();for(let r in e){let i=e[r];aL(i,n,r,t)}return n},aL=(e,t,n,r)=>{let i=e.length;for(let a=0;a<i;a++){let i=e[a];oL(i,t,n,r)}},oL=(e,t,n,r)=>{if(typeof e==`string`){sL(e,t,n);return}if(typeof e==`function`){cL(e,t,n,r);return}lL(e,t,n,r)},sL=(e,t,n)=>{let r=e===``?t:uL(t,e);r.classGroupId=n},cL=(e,t,n,r)=>{if(dL(e)){aL(e(r),t,n,r);return}t.validators===null&&(t.validators=[]),t.validators.push(YI(n,e))},lL=(e,t,n,r)=>{let i=Object.entries(e),a=i.length;for(let e=0;e<a;e++){let[a,o]=i[e];aL(o,uL(t,a),n,r)}},uL=(e,t)=>{let n=e,r=t.split(ZI),i=r.length;for(let e=0;e<i;e++){let t=r[e],i=n.nextPart.get(t);i||(i=XI(),n.nextPart.set(t,i)),n=i}return n},dL=e=>`isThemeGetter`in e&&e.isThemeGetter===!0,fL=e=>{if(e<1)return{get:()=>void 0,set:()=>{}};let t=0,n=Object.create(null),r=Object.create(null),i=(i,a)=>{n[i]=a,t++,t>e&&(t=0,r=n,n=Object.create(null))};return{get(e){let t=n[e];if(t!==void 0)return t;if((t=r[e])!==void 0)return i(e,t),t},set(e,t){e in n?n[e]=t:i(e,t)}}},pL=`!`,mL=`:`,hL=[],gL=(e,t,n,r,i)=>({modifiers:e,hasImportantModifier:t,baseClassName:n,maybePostfixModifierPosition:r,isExternal:i}),_L=e=>{let{prefix:t,experimentalParseClassName:n}=e,r=e=>{let t=[],n=0,r=0,i=0,a,o=e.length;for(let s=0;s<o;s++){let o=e[s];if(n===0&&r===0){if(o===mL){t.push(e.slice(i,s)),i=s+1;continue}if(o===`/`){a=s;continue}}o===`[`?n++:o===`]`?n--:o===`(`?r++:o===`)`&&r--}let s=t.length===0?e:e.slice(i),c=s,l=!1;s.endsWith(pL)?(c=s.slice(0,-1),l=!0):s.startsWith(pL)&&(c=s.slice(1),l=!0);let u=a&&a>i?a-i:void 0;return gL(t,l,c,u)};if(t){let e=t+mL,n=r;r=t=>t.startsWith(e)?n(t.slice(e.length)):gL(hL,!1,t,void 0,!0)}if(n){let e=r;r=t=>n({className:t,parseClassName:e})}return r},vL=e=>{let t=new Map;return e.orderSensitiveModifiers.forEach((e,n)=>{t.set(e,1e6+n)}),e=>{let n=[],r=[];for(let i=0;i<e.length;i++){let a=e[i],o=a[0]===`[`,s=t.has(a);o||s?(r.length>0&&(r.sort(),n.push(...r),r=[]),n.push(a)):r.push(a)}return r.length>0&&(r.sort(),n.push(...r)),n}},yL=e=>({cache:fL(e.cacheSize),parseClassName:_L(e),sortModifiers:vL(e),postfixLookupClassGroupIds:bL(e),...eL(e)}),bL=e=>{let t=Object.create(null),n=e.postfixLookupClassGroups;if(n)for(let e=0;e<n.length;e++)t[n[e]]=!0;return t},xL=/\s+/,SL=(e,t)=>{let{parseClassName:n,getClassGroupId:r,getConflictingClassGroupIds:i,sortModifiers:a,postfixLookupClassGroupIds:o}=t,s=[],c=e.trim().split(xL),l=``;for(let e=c.length-1;e>=0;--e){let t=c[e],{isExternal:u,modifiers:d,hasImportantModifier:f,baseClassName:p,maybePostfixModifierPosition:m}=n(t);if(u){l=t+(l.length>0?` `+l:l);continue}let h=!!m,g;if(h){g=r(p.substring(0,m));let e=g&&o[g]?r(p):void 0;e&&e!==g&&(g=e,h=!1)}else g=r(p);if(!g){if(!h){l=t+(l.length>0?` `+l:l);continue}if(g=r(p),!g){l=t+(l.length>0?` `+l:l);continue}h=!1}let _=d.length===0?``:d.length===1?d[0]:a(d).join(`:`),v=f?_+pL:_,y=v+g;if(s.indexOf(y)>-1)continue;s.push(y);let b=i(g,h);for(let e=0;e<b.length;++e){let t=b[e];s.push(v+t)}l=t+(l.length>0?` `+l:l)}return l},CL=(...e)=>{let t=0,n,r,i=``;for(;t<e.length;)(n=e[t++])&&(r=wL(n))&&(i&&(i+=` `),i+=r);return i},wL=e=>{if(typeof e==`string`)return e;let t,n=``;for(let r=0;r<e.length;r++)e[r]&&(t=wL(e[r]))&&(n&&(n+=` `),n+=t);return n},TL=(e,...t)=>{let n,r,i,a,o=o=>(n=yL(t.reduce((e,t)=>t(e),e())),r=n.cache.get,i=n.cache.set,a=s,s(o)),s=e=>{let t=r(e);if(t)return t;let a=SL(e,n);return i(e,a),a};return a=o,(...e)=>a(CL(...e))},EL=[],DL=e=>{let t=t=>t[e]||EL;return t.isThemeGetter=!0,t},OL=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,kL=/^\((?:(\w[\w-]*):)?(.+)\)$/i,AL=/^\d+(?:\.\d+)?\/\d+(?:\.\d+)?$/,jL=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,ML=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,NL=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,PL=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,FL=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,IL=e=>AL.test(e),LL=e=>!!e&&!Number.isNaN(Number(e)),RL=e=>!!e&&Number.isInteger(Number(e)),zL=e=>e.endsWith(`%`)&&LL(e.slice(0,-1)),BL=e=>jL.test(e),VL=()=>!0,HL=e=>ML.test(e)&&!NL.test(e),UL=()=>!1,WL=e=>PL.test(e),GL=e=>FL.test(e),KL=e=>!Q(e)&&!$(e),qL=e=>e.startsWith(`@container`)&&(e[10]===`/`&&e[11]!==void 0||e[11]===`s`&&e[16]!==void 0&&e.startsWith(`-size/`,10)||e[11]===`n`&&e[18]!==void 0&&e.startsWith(`-normal/`,10)),JL=e=>lR(e,pR,UL),Q=e=>OL.test(e),YL=e=>lR(e,mR,HL),XL=e=>lR(e,hR,LL),ZL=e=>lR(e,_R,VL),QL=e=>lR(e,gR,UL),$L=e=>lR(e,dR,UL),eR=e=>lR(e,fR,GL),tR=e=>lR(e,vR,WL),$=e=>kL.test(e),nR=e=>uR(e,mR),rR=e=>uR(e,gR),iR=e=>uR(e,dR),aR=e=>uR(e,pR),oR=e=>uR(e,fR),sR=e=>uR(e,vR,!0),cR=e=>uR(e,_R,!0),lR=(e,t,n)=>{let r=OL.exec(e);return r?r[1]?t(r[1]):n(r[2]):!1},uR=(e,t,n=!1)=>{let r=kL.exec(e);return r?r[1]?t(r[1]):n:!1},dR=e=>e===`position`||e===`percentage`,fR=e=>e===`image`||e===`url`,pR=e=>e===`length`||e===`size`||e===`bg-size`,mR=e=>e===`length`,hR=e=>e===`number`,gR=e=>e===`family-name`,_R=e=>e===`number`||e===`weight`,vR=e=>e===`shadow`,yR=TL(()=>{let e=DL(`color`),t=DL(`font`),n=DL(`text`),r=DL(`font-weight`),i=DL(`tracking`),a=DL(`leading`),o=DL(`breakpoint`),s=DL(`container`),c=DL(`spacing`),l=DL(`radius`),u=DL(`shadow`),d=DL(`inset-shadow`),f=DL(`text-shadow`),p=DL(`drop-shadow`),m=DL(`blur`),h=DL(`perspective`),g=DL(`aspect`),_=DL(`ease`),v=DL(`animate`),y=()=>[`auto`,`avoid`,`all`,`avoid-page`,`page`,`left`,`right`,`column`],b=()=>[`center`,`top`,`bottom`,`left`,`right`,`top-left`,`left-top`,`top-right`,`right-top`,`bottom-right`,`right-bottom`,`bottom-left`,`left-bottom`],x=()=>[...b(),$,Q],S=()=>[`auto`,`hidden`,`clip`,`visible`,`scroll`],C=()=>[`auto`,`contain`,`none`],w=()=>[$,Q,c],T=()=>[IL,`full`,`auto`,...w()],E=()=>[RL,`none`,`subgrid`,$,Q],D=()=>[`auto`,{span:[`full`,RL,$,Q]},RL,$,Q],ee=()=>[RL,`auto`,$,Q],te=()=>[`auto`,`min`,`max`,`fr`,$,Q],ne=()=>[`start`,`end`,`center`,`between`,`around`,`evenly`,`stretch`,`baseline`,`center-safe`,`end-safe`],re=()=>[`start`,`end`,`center`,`stretch`,`center-safe`,`end-safe`],O=()=>[`auto`,...w()],ie=()=>[IL,`auto`,`full`,`dvw`,`dvh`,`lvw`,`lvh`,`svw`,`svh`,`min`,`max`,`fit`,...w()],ae=()=>[IL,`screen`,`full`,`dvw`,`lvw`,`svw`,`min`,`max`,`fit`,...w()],k=()=>[IL,`screen`,`full`,`lh`,`dvh`,`lvh`,`svh`,`min`,`max`,`fit`,...w()],A=()=>[e,$,Q],oe=()=>[...b(),iR,$L,{position:[$,Q]}],se=()=>[`no-repeat`,{repeat:[``,`x`,`y`,`space`,`round`]}],ce=()=>[`auto`,`cover`,`contain`,aR,JL,{size:[$,Q]}],le=()=>[zL,nR,YL],ue=()=>[``,`none`,`full`,l,$,Q],de=()=>[``,LL,nR,YL],fe=()=>[`solid`,`dashed`,`dotted`,`double`],pe=()=>[`normal`,`multiply`,`screen`,`overlay`,`darken`,`lighten`,`color-dodge`,`color-burn`,`hard-light`,`soft-light`,`difference`,`exclusion`,`hue`,`saturation`,`color`,`luminosity`],me=()=>[LL,zL,iR,$L],he=()=>[``,`none`,m,$,Q],ge=()=>[`none`,LL,$,Q],_e=()=>[`none`,LL,$,Q],ve=()=>[LL,$,Q],ye=()=>[IL,`full`,...w()];return{cacheSize:500,theme:{animate:[`spin`,`ping`,`pulse`,`bounce`],aspect:[`video`],blur:[BL],breakpoint:[BL],color:[VL],container:[BL],"drop-shadow":[BL],ease:[`in`,`out`,`in-out`],font:[KL],"font-weight":[`thin`,`extralight`,`light`,`normal`,`medium`,`semibold`,`bold`,`extrabold`,`black`],"inset-shadow":[BL],leading:[`none`,`tight`,`snug`,`normal`,`relaxed`,`loose`],perspective:[`dramatic`,`near`,`normal`,`midrange`,`distant`,`none`],radius:[BL],shadow:[BL],spacing:[`px`,LL],text:[BL],"text-shadow":[BL],tracking:[`tighter`,`tight`,`normal`,`wide`,`wider`,`widest`]},classGroups:{aspect:[{aspect:[`auto`,`square`,IL,Q,$,g]}],container:[`container`],"container-type":[{"@container":[``,`normal`,`size`,$,Q]}],"container-named":[qL],columns:[{columns:[LL,Q,$,s]}],"break-after":[{"break-after":y()}],"break-before":[{"break-before":y()}],"break-inside":[{"break-inside":[`auto`,`avoid`,`avoid-page`,`avoid-column`]}],"box-decoration":[{"box-decoration":[`slice`,`clone`]}],box:[{box:[`border`,`content`]}],display:[`block`,`inline-block`,`inline`,`flex`,`inline-flex`,`table`,`inline-table`,`table-caption`,`table-cell`,`table-column`,`table-column-group`,`table-footer-group`,`table-header-group`,`table-row-group`,`table-row`,`flow-root`,`grid`,`inline-grid`,`contents`,`list-item`,`hidden`],sr:[`sr-only`,`not-sr-only`],float:[{float:[`right`,`left`,`none`,`start`,`end`]}],clear:[{clear:[`left`,`right`,`both`,`none`,`start`,`end`]}],isolation:[`isolate`,`isolation-auto`],"object-fit":[{object:[`contain`,`cover`,`fill`,`none`,`scale-down`]}],"object-position":[{object:x()}],overflow:[{overflow:S()}],"overflow-x":[{"overflow-x":S()}],"overflow-y":[{"overflow-y":S()}],overscroll:[{overscroll:C()}],"overscroll-x":[{"overscroll-x":C()}],"overscroll-y":[{"overscroll-y":C()}],position:[`static`,`fixed`,`absolute`,`relative`,`sticky`],inset:[{inset:T()}],"inset-x":[{"inset-x":T()}],"inset-y":[{"inset-y":T()}],start:[{"inset-s":T(),start:T()}],end:[{"inset-e":T(),end:T()}],"inset-bs":[{"inset-bs":T()}],"inset-be":[{"inset-be":T()}],top:[{top:T()}],right:[{right:T()}],bottom:[{bottom:T()}],left:[{left:T()}],visibility:[`visible`,`invisible`,`collapse`],z:[{z:[RL,`auto`,$,Q]}],basis:[{basis:[IL,`full`,`auto`,s,...w()]}],"flex-direction":[{flex:[`row`,`row-reverse`,`col`,`col-reverse`]}],"flex-wrap":[{flex:[`nowrap`,`wrap`,`wrap-reverse`]}],flex:[{flex:[LL,IL,`auto`,`initial`,`none`,Q]}],grow:[{grow:[``,LL,$,Q]}],shrink:[{shrink:[``,LL,$,Q]}],order:[{order:[RL,`first`,`last`,`none`,$,Q]}],"grid-cols":[{"grid-cols":E()}],"col-start-end":[{col:D()}],"col-start":[{"col-start":ee()}],"col-end":[{"col-end":ee()}],"grid-rows":[{"grid-rows":E()}],"row-start-end":[{row:D()}],"row-start":[{"row-start":ee()}],"row-end":[{"row-end":ee()}],"grid-flow":[{"grid-flow":[`row`,`col`,`dense`,`row-dense`,`col-dense`]}],"auto-cols":[{"auto-cols":te()}],"auto-rows":[{"auto-rows":te()}],gap:[{gap:w()}],"gap-x":[{"gap-x":w()}],"gap-y":[{"gap-y":w()}],"justify-content":[{justify:[...ne(),`normal`]}],"justify-items":[{"justify-items":[...re(),`normal`]}],"justify-self":[{"justify-self":[`auto`,...re()]}],"align-content":[{content:[`normal`,...ne()]}],"align-items":[{items:[...re(),{baseline:[``,`last`]}]}],"align-self":[{self:[`auto`,...re(),{baseline:[``,`last`]}]}],"place-content":[{"place-content":ne()}],"place-items":[{"place-items":[...re(),`baseline`]}],"place-self":[{"place-self":[`auto`,...re()]}],p:[{p:w()}],px:[{px:w()}],py:[{py:w()}],ps:[{ps:w()}],pe:[{pe:w()}],pbs:[{pbs:w()}],pbe:[{pbe:w()}],pt:[{pt:w()}],pr:[{pr:w()}],pb:[{pb:w()}],pl:[{pl:w()}],m:[{m:O()}],mx:[{mx:O()}],my:[{my:O()}],ms:[{ms:O()}],me:[{me:O()}],mbs:[{mbs:O()}],mbe:[{mbe:O()}],mt:[{mt:O()}],mr:[{mr:O()}],mb:[{mb:O()}],ml:[{ml:O()}],"space-x":[{"space-x":w()}],"space-x-reverse":[`space-x-reverse`],"space-y":[{"space-y":w()}],"space-y-reverse":[`space-y-reverse`],size:[{size:ie()}],"inline-size":[{inline:[`auto`,...ae()]}],"min-inline-size":[{"min-inline":[`auto`,...ae()]}],"max-inline-size":[{"max-inline":[`none`,...ae()]}],"block-size":[{block:[`auto`,...k()]}],"min-block-size":[{"min-block":[`auto`,...k()]}],"max-block-size":[{"max-block":[`none`,...k()]}],w:[{w:[s,`screen`,...ie()]}],"min-w":[{"min-w":[s,`screen`,`none`,...ie()]}],"max-w":[{"max-w":[s,`screen`,`none`,`prose`,{screen:[o]},...ie()]}],h:[{h:[`screen`,`lh`,...ie()]}],"min-h":[{"min-h":[`screen`,`lh`,`none`,...ie()]}],"max-h":[{"max-h":[`screen`,`lh`,...ie()]}],"font-size":[{text:[`base`,n,nR,YL]}],"font-smoothing":[`antialiased`,`subpixel-antialiased`],"font-style":[`italic`,`not-italic`],"font-weight":[{font:[r,cR,ZL]}],"font-stretch":[{"font-stretch":[`ultra-condensed`,`extra-condensed`,`condensed`,`semi-condensed`,`normal`,`semi-expanded`,`expanded`,`extra-expanded`,`ultra-expanded`,zL,Q]}],"font-family":[{font:[rR,QL,t]}],"font-features":[{"font-features":[Q]}],"fvn-normal":[`normal-nums`],"fvn-ordinal":[`ordinal`],"fvn-slashed-zero":[`slashed-zero`],"fvn-figure":[`lining-nums`,`oldstyle-nums`],"fvn-spacing":[`proportional-nums`,`tabular-nums`],"fvn-fraction":[`diagonal-fractions`,`stacked-fractions`],tracking:[{tracking:[i,$,Q]}],"line-clamp":[{"line-clamp":[LL,`none`,$,XL]}],leading:[{leading:[a,...w()]}],"list-image":[{"list-image":[`none`,$,Q]}],"list-style-position":[{list:[`inside`,`outside`]}],"list-style-type":[{list:[`disc`,`decimal`,`none`,$,Q]}],"text-alignment":[{text:[`left`,`center`,`right`,`justify`,`start`,`end`]}],"placeholder-color":[{placeholder:A()}],"text-color":[{text:A()}],"text-decoration":[`underline`,`overline`,`line-through`,`no-underline`],"text-decoration-style":[{decoration:[...fe(),`wavy`]}],"text-decoration-thickness":[{decoration:[LL,`from-font`,`auto`,$,YL]}],"text-decoration-color":[{decoration:A()}],"underline-offset":[{"underline-offset":[LL,`auto`,$,Q]}],"text-transform":[`uppercase`,`lowercase`,`capitalize`,`normal-case`],"text-overflow":[`truncate`,`text-ellipsis`,`text-clip`],"text-wrap":[{text:[`wrap`,`nowrap`,`balance`,`pretty`]}],indent:[{indent:w()}],"tab-size":[{tab:[RL,$,Q]}],"vertical-align":[{align:[`baseline`,`top`,`middle`,`bottom`,`text-top`,`text-bottom`,`sub`,`super`,$,Q]}],whitespace:[{whitespace:[`normal`,`nowrap`,`pre`,`pre-line`,`pre-wrap`,`break-spaces`]}],break:[{break:[`normal`,`words`,`all`,`keep`]}],wrap:[{wrap:[`break-word`,`anywhere`,`normal`]}],hyphens:[{hyphens:[`none`,`manual`,`auto`]}],content:[{content:[`none`,$,Q]}],"bg-attachment":[{bg:[`fixed`,`local`,`scroll`]}],"bg-clip":[{"bg-clip":[`border`,`padding`,`content`,`text`]}],"bg-origin":[{"bg-origin":[`border`,`padding`,`content`]}],"bg-position":[{bg:oe()}],"bg-repeat":[{bg:se()}],"bg-size":[{bg:ce()}],"bg-image":[{bg:[`none`,{linear:[{to:[`t`,`tr`,`r`,`br`,`b`,`bl`,`l`,`tl`]},RL,$,Q],radial:[``,$,Q],conic:[RL,$,Q]},oR,eR]}],"bg-color":[{bg:A()}],"gradient-from-pos":[{from:le()}],"gradient-via-pos":[{via:le()}],"gradient-to-pos":[{to:le()}],"gradient-from":[{from:A()}],"gradient-via":[{via:A()}],"gradient-to":[{to:A()}],rounded:[{rounded:ue()}],"rounded-s":[{"rounded-s":ue()}],"rounded-e":[{"rounded-e":ue()}],"rounded-t":[{"rounded-t":ue()}],"rounded-r":[{"rounded-r":ue()}],"rounded-b":[{"rounded-b":ue()}],"rounded-l":[{"rounded-l":ue()}],"rounded-ss":[{"rounded-ss":ue()}],"rounded-se":[{"rounded-se":ue()}],"rounded-ee":[{"rounded-ee":ue()}],"rounded-es":[{"rounded-es":ue()}],"rounded-tl":[{"rounded-tl":ue()}],"rounded-tr":[{"rounded-tr":ue()}],"rounded-br":[{"rounded-br":ue()}],"rounded-bl":[{"rounded-bl":ue()}],"border-w":[{border:de()}],"border-w-x":[{"border-x":de()}],"border-w-y":[{"border-y":de()}],"border-w-s":[{"border-s":de()}],"border-w-e":[{"border-e":de()}],"border-w-bs":[{"border-bs":de()}],"border-w-be":[{"border-be":de()}],"border-w-t":[{"border-t":de()}],"border-w-r":[{"border-r":de()}],"border-w-b":[{"border-b":de()}],"border-w-l":[{"border-l":de()}],"divide-x":[{"divide-x":de()}],"divide-x-reverse":[`divide-x-reverse`],"divide-y":[{"divide-y":de()}],"divide-y-reverse":[`divide-y-reverse`],"border-style":[{border:[...fe(),`hidden`,`none`]}],"divide-style":[{divide:[...fe(),`hidden`,`none`]}],"border-color":[{border:A()}],"border-color-x":[{"border-x":A()}],"border-color-y":[{"border-y":A()}],"border-color-s":[{"border-s":A()}],"border-color-e":[{"border-e":A()}],"border-color-bs":[{"border-bs":A()}],"border-color-be":[{"border-be":A()}],"border-color-t":[{"border-t":A()}],"border-color-r":[{"border-r":A()}],"border-color-b":[{"border-b":A()}],"border-color-l":[{"border-l":A()}],"divide-color":[{divide:A()}],"outline-style":[{outline:[...fe(),`none`,`hidden`]}],"outline-offset":[{"outline-offset":[LL,$,Q]}],"outline-w":[{outline:[``,LL,nR,YL]}],"outline-color":[{outline:A()}],shadow:[{shadow:[``,`none`,u,sR,tR]}],"shadow-color":[{shadow:A()}],"inset-shadow":[{"inset-shadow":[`none`,d,sR,tR]}],"inset-shadow-color":[{"inset-shadow":A()}],"ring-w":[{ring:de()}],"ring-w-inset":[`ring-inset`],"ring-color":[{ring:A()}],"ring-offset-w":[{"ring-offset":[LL,YL]}],"ring-offset-color":[{"ring-offset":A()}],"inset-ring-w":[{"inset-ring":de()}],"inset-ring-color":[{"inset-ring":A()}],"text-shadow":[{"text-shadow":[`none`,f,sR,tR]}],"text-shadow-color":[{"text-shadow":A()}],opacity:[{opacity:[LL,$,Q]}],"mix-blend":[{"mix-blend":[...pe(),`plus-darker`,`plus-lighter`]}],"bg-blend":[{"bg-blend":pe()}],"mask-clip":[{"mask-clip":[`border`,`padding`,`content`,`fill`,`stroke`,`view`]},`mask-no-clip`],"mask-composite":[{mask:[`add`,`subtract`,`intersect`,`exclude`]}],"mask-image-linear-pos":[{"mask-linear":[LL]}],"mask-image-linear-from-pos":[{"mask-linear-from":me()}],"mask-image-linear-to-pos":[{"mask-linear-to":me()}],"mask-image-linear-from-color":[{"mask-linear-from":A()}],"mask-image-linear-to-color":[{"mask-linear-to":A()}],"mask-image-t-from-pos":[{"mask-t-from":me()}],"mask-image-t-to-pos":[{"mask-t-to":me()}],"mask-image-t-from-color":[{"mask-t-from":A()}],"mask-image-t-to-color":[{"mask-t-to":A()}],"mask-image-r-from-pos":[{"mask-r-from":me()}],"mask-image-r-to-pos":[{"mask-r-to":me()}],"mask-image-r-from-color":[{"mask-r-from":A()}],"mask-image-r-to-color":[{"mask-r-to":A()}],"mask-image-b-from-pos":[{"mask-b-from":me()}],"mask-image-b-to-pos":[{"mask-b-to":me()}],"mask-image-b-from-color":[{"mask-b-from":A()}],"mask-image-b-to-color":[{"mask-b-to":A()}],"mask-image-l-from-pos":[{"mask-l-from":me()}],"mask-image-l-to-pos":[{"mask-l-to":me()}],"mask-image-l-from-color":[{"mask-l-from":A()}],"mask-image-l-to-color":[{"mask-l-to":A()}],"mask-image-x-from-pos":[{"mask-x-from":me()}],"mask-image-x-to-pos":[{"mask-x-to":me()}],"mask-image-x-from-color":[{"mask-x-from":A()}],"mask-image-x-to-color":[{"mask-x-to":A()}],"mask-image-y-from-pos":[{"mask-y-from":me()}],"mask-image-y-to-pos":[{"mask-y-to":me()}],"mask-image-y-from-color":[{"mask-y-from":A()}],"mask-image-y-to-color":[{"mask-y-to":A()}],"mask-image-radial":[{"mask-radial":[$,Q]}],"mask-image-radial-from-pos":[{"mask-radial-from":me()}],"mask-image-radial-to-pos":[{"mask-radial-to":me()}],"mask-image-radial-from-color":[{"mask-radial-from":A()}],"mask-image-radial-to-color":[{"mask-radial-to":A()}],"mask-image-radial-shape":[{"mask-radial":[`circle`,`ellipse`]}],"mask-image-radial-size":[{"mask-radial":[{closest:[`side`,`corner`],farthest:[`side`,`corner`]}]}],"mask-image-radial-pos":[{"mask-radial-at":b()}],"mask-image-conic-pos":[{"mask-conic":[LL]}],"mask-image-conic-from-pos":[{"mask-conic-from":me()}],"mask-image-conic-to-pos":[{"mask-conic-to":me()}],"mask-image-conic-from-color":[{"mask-conic-from":A()}],"mask-image-conic-to-color":[{"mask-conic-to":A()}],"mask-mode":[{mask:[`alpha`,`luminance`,`match`]}],"mask-origin":[{"mask-origin":[`border`,`padding`,`content`,`fill`,`stroke`,`view`]}],"mask-position":[{mask:oe()}],"mask-repeat":[{mask:se()}],"mask-size":[{mask:ce()}],"mask-type":[{"mask-type":[`alpha`,`luminance`]}],"mask-image":[{mask:[`none`,$,Q]}],filter:[{filter:[``,`none`,$,Q]}],blur:[{blur:he()}],brightness:[{brightness:[LL,$,Q]}],contrast:[{contrast:[LL,$,Q]}],"drop-shadow":[{"drop-shadow":[``,`none`,p,sR,tR]}],"drop-shadow-color":[{"drop-shadow":A()}],grayscale:[{grayscale:[``,LL,$,Q]}],"hue-rotate":[{"hue-rotate":[LL,$,Q]}],invert:[{invert:[``,LL,$,Q]}],saturate:[{saturate:[LL,$,Q]}],sepia:[{sepia:[``,LL,$,Q]}],"backdrop-filter":[{"backdrop-filter":[``,`none`,$,Q]}],"backdrop-blur":[{"backdrop-blur":he()}],"backdrop-brightness":[{"backdrop-brightness":[LL,$,Q]}],"backdrop-contrast":[{"backdrop-contrast":[LL,$,Q]}],"backdrop-grayscale":[{"backdrop-grayscale":[``,LL,$,Q]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[LL,$,Q]}],"backdrop-invert":[{"backdrop-invert":[``,LL,$,Q]}],"backdrop-opacity":[{"backdrop-opacity":[LL,$,Q]}],"backdrop-saturate":[{"backdrop-saturate":[LL,$,Q]}],"backdrop-sepia":[{"backdrop-sepia":[``,LL,$,Q]}],"border-collapse":[{border:[`collapse`,`separate`]}],"border-spacing":[{"border-spacing":w()}],"border-spacing-x":[{"border-spacing-x":w()}],"border-spacing-y":[{"border-spacing-y":w()}],"table-layout":[{table:[`auto`,`fixed`]}],caption:[{caption:[`top`,`bottom`]}],transition:[{transition:[``,`all`,`colors`,`opacity`,`shadow`,`transform`,`none`,$,Q]}],"transition-behavior":[{transition:[`normal`,`discrete`]}],duration:[{duration:[LL,`initial`,$,Q]}],ease:[{ease:[`linear`,`initial`,_,$,Q]}],delay:[{delay:[LL,$,Q]}],animate:[{animate:[`none`,v,$,Q]}],backface:[{backface:[`hidden`,`visible`]}],perspective:[{perspective:[h,$,Q]}],"perspective-origin":[{"perspective-origin":x()}],rotate:[{rotate:ge()}],"rotate-x":[{"rotate-x":ge()}],"rotate-y":[{"rotate-y":ge()}],"rotate-z":[{"rotate-z":ge()}],scale:[{scale:_e()}],"scale-x":[{"scale-x":_e()}],"scale-y":[{"scale-y":_e()}],"scale-z":[{"scale-z":_e()}],"scale-3d":[`scale-3d`],skew:[{skew:ve()}],"skew-x":[{"skew-x":ve()}],"skew-y":[{"skew-y":ve()}],transform:[{transform:[$,Q,``,`none`,`gpu`,`cpu`]}],"transform-origin":[{origin:x()}],"transform-style":[{transform:[`3d`,`flat`]}],translate:[{translate:ye()}],"translate-x":[{"translate-x":ye()}],"translate-y":[{"translate-y":ye()}],"translate-z":[{"translate-z":ye()}],"translate-none":[`translate-none`],zoom:[{zoom:[RL,$,Q]}],accent:[{accent:A()}],appearance:[{appearance:[`none`,`auto`]}],"caret-color":[{caret:A()}],"color-scheme":[{scheme:[`normal`,`dark`,`light`,`light-dark`,`only-dark`,`only-light`]}],cursor:[{cursor:[`auto`,`default`,`pointer`,`wait`,`text`,`move`,`help`,`not-allowed`,`none`,`context-menu`,`progress`,`cell`,`crosshair`,`vertical-text`,`alias`,`copy`,`no-drop`,`grab`,`grabbing`,`all-scroll`,`col-resize`,`row-resize`,`n-resize`,`e-resize`,`s-resize`,`w-resize`,`ne-resize`,`nw-resize`,`se-resize`,`sw-resize`,`ew-resize`,`ns-resize`,`nesw-resize`,`nwse-resize`,`zoom-in`,`zoom-out`,$,Q]}],"field-sizing":[{"field-sizing":[`fixed`,`content`]}],"pointer-events":[{"pointer-events":[`auto`,`none`]}],resize:[{resize:[`none`,``,`y`,`x`]}],"scroll-behavior":[{scroll:[`auto`,`smooth`]}],"scrollbar-thumb-color":[{"scrollbar-thumb":A()}],"scrollbar-track-color":[{"scrollbar-track":A()}],"scrollbar-gutter":[{"scrollbar-gutter":[`auto`,`stable`,`both`]}],"scrollbar-w":[{scrollbar:[`auto`,`thin`,`none`]}],"scroll-m":[{"scroll-m":w()}],"scroll-mx":[{"scroll-mx":w()}],"scroll-my":[{"scroll-my":w()}],"scroll-ms":[{"scroll-ms":w()}],"scroll-me":[{"scroll-me":w()}],"scroll-mbs":[{"scroll-mbs":w()}],"scroll-mbe":[{"scroll-mbe":w()}],"scroll-mt":[{"scroll-mt":w()}],"scroll-mr":[{"scroll-mr":w()}],"scroll-mb":[{"scroll-mb":w()}],"scroll-ml":[{"scroll-ml":w()}],"scroll-p":[{"scroll-p":w()}],"scroll-px":[{"scroll-px":w()}],"scroll-py":[{"scroll-py":w()}],"scroll-ps":[{"scroll-ps":w()}],"scroll-pe":[{"scroll-pe":w()}],"scroll-pbs":[{"scroll-pbs":w()}],"scroll-pbe":[{"scroll-pbe":w()}],"scroll-pt":[{"scroll-pt":w()}],"scroll-pr":[{"scroll-pr":w()}],"scroll-pb":[{"scroll-pb":w()}],"scroll-pl":[{"scroll-pl":w()}],"snap-align":[{snap:[`start`,`end`,`center`,`align-none`]}],"snap-stop":[{snap:[`normal`,`always`]}],"snap-type":[{snap:[`none`,`x`,`y`,`both`]}],"snap-strictness":[{snap:[`mandatory`,`proximity`]}],touch:[{touch:[`auto`,`none`,`manipulation`]}],"touch-x":[{"touch-pan":[`x`,`left`,`right`]}],"touch-y":[{"touch-pan":[`y`,`up`,`down`]}],"touch-pz":[`touch-pinch-zoom`],select:[{select:[`none`,`text`,`all`,`auto`]}],"will-change":[{"will-change":[`auto`,`scroll`,`contents`,`transform`,$,Q]}],fill:[{fill:[`none`,...A()]}],"stroke-w":[{stroke:[LL,nR,YL,XL]}],stroke:[{stroke:[`none`,...A()]}],"forced-color-adjust":[{"forced-color-adjust":[`auto`,`none`]}]},conflictingClassGroups:{"container-named":[`container-type`],overflow:[`overflow-x`,`overflow-y`],overscroll:[`overscroll-x`,`overscroll-y`],inset:[`inset-x`,`inset-y`,`inset-bs`,`inset-be`,`start`,`end`,`top`,`right`,`bottom`,`left`],"inset-x":[`right`,`left`],"inset-y":[`top`,`bottom`],flex:[`basis`,`grow`,`shrink`],gap:[`gap-x`,`gap-y`],p:[`px`,`py`,`ps`,`pe`,`pbs`,`pbe`,`pt`,`pr`,`pb`,`pl`],px:[`pr`,`pl`],py:[`pt`,`pb`],m:[`mx`,`my`,`ms`,`me`,`mbs`,`mbe`,`mt`,`mr`,`mb`,`ml`],mx:[`mr`,`ml`],my:[`mt`,`mb`],size:[`w`,`h`],"font-size":[`leading`],"fvn-normal":[`fvn-ordinal`,`fvn-slashed-zero`,`fvn-figure`,`fvn-spacing`,`fvn-fraction`],"fvn-ordinal":[`fvn-normal`],"fvn-slashed-zero":[`fvn-normal`],"fvn-figure":[`fvn-normal`],"fvn-spacing":[`fvn-normal`],"fvn-fraction":[`fvn-normal`],"line-clamp":[`display`,`overflow`],rounded:[`rounded-s`,`rounded-e`,`rounded-t`,`rounded-r`,`rounded-b`,`rounded-l`,`rounded-ss`,`rounded-se`,`rounded-ee`,`rounded-es`,`rounded-tl`,`rounded-tr`,`rounded-br`,`rounded-bl`],"rounded-s":[`rounded-ss`,`rounded-es`],"rounded-e":[`rounded-se`,`rounded-ee`],"rounded-t":[`rounded-tl`,`rounded-tr`],"rounded-r":[`rounded-tr`,`rounded-br`],"rounded-b":[`rounded-br`,`rounded-bl`],"rounded-l":[`rounded-tl`,`rounded-bl`],"border-spacing":[`border-spacing-x`,`border-spacing-y`],"border-w":[`border-w-x`,`border-w-y`,`border-w-s`,`border-w-e`,`border-w-bs`,`border-w-be`,`border-w-t`,`border-w-r`,`border-w-b`,`border-w-l`],"border-w-x":[`border-w-r`,`border-w-l`],"border-w-y":[`border-w-t`,`border-w-b`],"border-color":[`border-color-x`,`border-color-y`,`border-color-s`,`border-color-e`,`border-color-bs`,`border-color-be`,`border-color-t`,`border-color-r`,`border-color-b`,`border-color-l`],"border-color-x":[`border-color-r`,`border-color-l`],"border-color-y":[`border-color-t`,`border-color-b`],translate:[`translate-x`,`translate-y`,`translate-none`],"translate-none":[`translate`,`translate-x`,`translate-y`,`translate-z`],"scroll-m":[`scroll-mx`,`scroll-my`,`scroll-ms`,`scroll-me`,`scroll-mbs`,`scroll-mbe`,`scroll-mt`,`scroll-mr`,`scroll-mb`,`scroll-ml`],"scroll-mx":[`scroll-mr`,`scroll-ml`],"scroll-my":[`scroll-mt`,`scroll-mb`],"scroll-p":[`scroll-px`,`scroll-py`,`scroll-ps`,`scroll-pe`,`scroll-pbs`,`scroll-pbe`,`scroll-pt`,`scroll-pr`,`scroll-pb`,`scroll-pl`],"scroll-px":[`scroll-pr`,`scroll-pl`],"scroll-py":[`scroll-pt`,`scroll-pb`],touch:[`touch-x`,`touch-y`,`touch-pz`],"touch-x":[`touch`],"touch-y":[`touch`],"touch-pz":[`touch`]},conflictingClassGroupModifiers:{"font-size":[`leading`]},postfixLookupClassGroups:[`container-type`],orderSensitiveModifiers:[`*`,`**`,`after`,`backdrop`,`before`,`details-content`,`file`,`first-letter`,`first-line`,`marker`,`placeholder`,`selection`]}});function bR({resolution:e,inputs:t,config:n,bailReason:r}){if(e===null||t===null)return null;let i=jF[e.templateId];if(i===void 0)return null;let a=r!==null,o=a?`border-warning/70 bg-warning/5`:`border-info/80 bg-info/5`,s=a?`bg-warning/85 text-warning-content`:`bg-info/85 text-info-content`,c=a?`border-warning`:`border-success`,l=a?`bg-warning/85 text-warning-content`:`bg-success/85 text-success-content`,u=t.userShare?`userShare`:t.presentation?`presentation`:null,{regions:d}=pI(i,{state:e.state,contentKind:u},t,e.sizeClass,e.containerPx,n);return L(`div`,{class:`pointer-events-none absolute inset-0 z-40`,"aria-hidden":`true`,children:[a&&L(`span`,{class:`absolute top-1 left-1/2 -translate-x-1/2 rounded bg-warning/90 px-2 py-0.5 font-mono text-[10px] text-warning-content`,children:[`engine plan only · legacy: `,r]}),d.map(e=>L(`div`,{class:yR(`absolute rounded-box border border-dashed`,o),style:{left:`${e.rect.x}px`,top:`${e.rect.y}px`,width:`${e.rect.width}px`,height:`${e.rect.height}px`},children:L(`span`,{class:yR(`absolute top-1 left-1 flex flex-col rounded px-1.5 py-0.5 font-mono text-[10px] leading-tight`,s),children:[L(`span`,{children:e.region.name}),L(`span`,{class:`opacity-75`,children:e.region.accepts.join(` · `)})]})},e.region.name)),e.tiles.map(e=>L(`div`,{class:yR(`absolute border`,c),style:{left:`${e.rect.x}px`,top:`${e.rect.y}px`,width:`${e.rect.width}px`,height:`${e.rect.height}px`},children:L(`span`,{class:yR(`absolute right-1 bottom-1 rounded px-1.5 py-0.5 font-mono text-[10px]`,l),children:[e.kind,` `,e.rect.width,`×`,e.rect.height]})},`tile-${e.id}`))]})}function xR(e){return{version:1,buildSha:CI,engineVersion:CI,config:kF,session:{containerPx:{width:Math.round(e.container.widthPx),height:Math.round(e.container.heightPx)},slots:{replica:e.replica,selfView:e.selfView,presentation:e.presentation!==null,userShare:e.userShare!==null,callControls:e.callControls,callControlsVisible:e.callControlsVisible??!0,...e.callControlsRect===void 0?{}:{callControlsRect:e.callControlsRect}},prefs:e.prefs,cards:e.cards}}}function SR({resolution:e,inputs:t,shadowing:n,bailReason:r,engineError:i=null}){let[a,o]=j(!1),s=N(null);if(M(()=>()=>{s.current!==null&&clearTimeout(s.current)},[]),e===null||t===null)return i===null?null:L(`div`,{class:`pointer-events-auto max-w-[22rem] rounded-box bg-base-100/95 p-3 font-mono text-[10px] leading-relaxed shadow-lg`,children:[L(`div`,{class:`mb-1 flex items-center justify-between gap-2`,children:[L(`span`,{class:`font-bold uppercase tracking-wide`,children:`magic grid`}),L(`span`,{class:`text-warning`,children:`observing`})]}),L(`dl`,{class:`grid grid-cols-[5.5rem_1fr] gap-x-2`,children:[L(`dt`,{class:`text-warning opacity-80`,children:`legacy`}),L(`dd`,{class:`text-warning`,children:r}),L(`dt`,{class:`text-error opacity-80`,children:`error`}),L(`dd`,{class:`text-error break-all`,children:i})]})]});let c=()=>{let e=JSON.stringify(xR(t),null,2);s.current!==null&&clearTimeout(s.current),navigator.clipboard?.writeText(e).then(()=>{o(!0),s.current=setTimeout(()=>o(!1),1500)},()=>o(!1))},l=e.degradations.evictedCardIds;return L(`div`,{class:`pointer-events-auto max-w-[22rem] rounded-box bg-base-100/95 p-3 font-mono text-[10px] leading-relaxed shadow-lg`,children:[L(`div`,{class:`mb-1 flex items-center justify-between gap-2`,children:[L(`span`,{class:`font-bold uppercase tracking-wide`,children:`magic grid`}),L(`span`,{class:n?`text-warning`:`text-success`,children:n?`observing`:`driving`})]}),L(`dl`,{class:`grid grid-cols-[5.5rem_1fr] gap-x-2`,children:[L(`dt`,{class:`opacity-60`,children:`state`}),L(`dd`,{children:e.state}),L(`dt`,{class:`opacity-60`,children:`template`}),L(`dd`,{children:e.templateId}),L(`dt`,{class:`opacity-60`,children:`class`}),L(`dd`,{children:[e.sizeClass.width,` / `,e.sizeClass.height]}),L(`dt`,{class:`opacity-60`,children:`container`}),L(`dd`,{children:[e.containerPx.width,`×`,e.containerPx.height]}),t.callControlsRect!==void 0&&L(k,{children:[L(`dt`,{class:`opacity-60`,children:`controls`}),L(`dd`,{children:[`x `,t.callControlsRect.x,`–`,t.callControlsRect.x+t.callControlsRect.width,t.callControlsVisible===!1?` · hidden`:` · shown`]})]}),L(`dt`,{class:`opacity-60`,children:`tiles`}),L(`dd`,{children:e.tiles.map(e=>`${e.kind}:${e.rect.width}×${e.rect.height}`).join(` `)||`none`}),l.length>0&&L(k,{children:[L(`dt`,{class:`text-error opacity-80`,children:`dropped`}),L(`dd`,{class:`text-error`,children:l.join(`, `)})]}),r!==null&&L(k,{children:[L(`dt`,{class:`text-warning opacity-80`,children:`legacy`}),L(`dd`,{class:`text-warning`,children:r})]}),i!==null&&L(k,{children:[L(`dt`,{class:`text-error opacity-80`,children:`error`}),L(`dd`,{class:`text-error break-all`,children:i})]})]}),L(`button`,{type:`button`,class:`btn btn-xs mt-2 w-full`,onClick:c,children:a?`copied`:`copy envelope for playground`})]})}var CR={effect:LI,animate:!1},wR=Yt(CR),TR={presence:{phase:`connecting`},localId:null,isScreenSharing:!1,isPersonaPresenting:!1,hasPersonaVideo:!1,hasSelfView:!1};function ER(e,t){return e===null||t===null?e===t:e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function DR(e,t){let n=e.containerPx===null||t.containerPx===null?e.containerPx===t.containerPx:e.containerPx.width===t.containerPx.width&&e.containerPx.height===t.containerPx.height;return e.driving===t.driving&&e.replicaCollapsed===t.replicaCollapsed&&n&&ER(e.replica,t.replica)&&ER(e.selfView,t.selfView)&&ER(e.content,t.content)}var OR=new Map;function kR({instances:e,viewport:t,callControlsBandPx:n,callPresence:r,callControlsVisible:i,callControlsRect:a,gridConfigEnabled:o,gridStartEnabled:s}){let c=DI(o,s)&&r!==void 0,l=r??TR,u=PI({instances:e,viewport:t,presence:l,callControlsBandPx:n,callControlsVisible:i,callControlsRect:a,enabled:c}),d=c?jI.value:null,f=d===null?FI(u.resolution,l,c):`engine-error`;qI({enabled:c,enabledVia:UI(TI,o===!0,s===!0),bail:f,resolution:u.resolution,engineError:d});let p=N(!1);l.presence.phase===`ready`?l.hasPersonaVideo&&(p.current=!0):p.current=!1;let m=!p.current,h;try{h=RI(u.resolution,f,m)}catch(e){MI(e),h=LI}let g=N(LI),_=BI(g.current,h);M(()=>{g.current=h,DR(wR.peek().effect,h)||(wR.value={effect:h,animate:_})}),M(()=>()=>{NI(),wR.peek()!==CR&&(wR.value=CR)},[]);let v=u.resolution,y=P(()=>{if(f!==null||v===null)return OR;try{let e=new Map;for(let t of v.tiles)t.kind===`card`&&e.set(t.id,t.rect);return e}catch(e){return MI(e),OR}},[f,v]),b=EI?L(`div`,{class:`contents`,"data-grid-debug":!0,children:[L(bR,{resolution:u.resolution,inputs:u.inputs,config:kF,bailReason:f}),L(`div`,{class:`pointer-events-none absolute bottom-4 left-4 z-50`,children:L(SR,{resolution:u.resolution,inputs:u.inputs,shadowing:f!==null,bailReason:f,engineError:d})})]}):null;return{cardRects:y,sheetBottomPx:II(v,f),animate:_,recordNaturalHeight:u.recordNaturalHeight,debug:b}}var AR=[`left`,`top`,`width`,`height`].map(e=>`${e} ${pw}`).join(`, `);function jR(e,t){return{left:`${e.x}px`,top:`${e.y}px`,width:`${e.width}px`,height:`${e.height}px`,transition:t&&!Cw()?AR:`none`}}function MR({state:e}){return e.enabled?L(`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:[L(`summary`,{class:`cursor-pointer font-medium`,children:`Magic Canvas debug`}),L(`dl`,{class:`mt-2 grid gap-2`,children:[L(NR,{label:`iframe`,value:e.iframeLifecycleState}),L(NR,{label:`post`,value:e.lastInteractionPostResult}),L(NR,{label:`context`,value:e.lastModelContextUpdate}),L(NR,{label:`error`,value:e.lastError}),L(PR,{label:`tool_call`,value:e.lastToolCall}),L(PR,{label:`canvas_config`,value:e.parsedCanvasConfig})]})]}):null}function NR({label:e,value:t}){return t?L(`div`,{children:[L(`dt`,{class:`font-semibold`,children:e}),L(`dd`,{class:`break-words text-base-content/70`,children:t})]}):null}function PR({label:e,value:t}){return t===void 0?null:L(`div`,{children:[L(`dt`,{class:`font-semibold`,children:e}),L(`dd`,{children:L(`pre`,{class:`max-h-40 overflow-auto rounded bg-base-200 p-2 text-[10px] leading-relaxed`,children:JSON.stringify(t,null,2)})})]})}var FR=1e3,IR=5e3,LR=1200,RR=[2e3,6e3];async function zR(e,t,n){let r=new AbortController,i=globalThis.setTimeout(()=>r.abort(),IR);try{await jn(e,t,n,{signal:r.signal})}finally{globalThis.clearTimeout(i)}}function BR(e){return e instanceof Dn&&e.status>=400&&e.status<500&&e.status!==408&&e.status!==429}function VR(e,t){console.error(`Magic Canvas interaction POST failed; this interaction may not have been recorded server-side.`,e),t({lastInteractionPostResult:`error`,lastError:mz(e).message})}function HR(e,t,n,r){(async()=>{let i;for(let a of RR){await new Promise(e=>setTimeout(e,a));try{await zR(e,t,n),r({lastInteractionPostResult:`recovered`,lastError:void 0});return}catch(e){if(i=e,BR(e))break}}VR(i,r)})()}var UR=2e3;function WR(e){return e.correct_answer===void 0?LR:UR}var GR=48,KR=`allow-scripts`,qR={"canvas.scheduling_embed":`allow-scripts allow-same-origin allow-popups allow-forms`,"canvas.text":`allow-scripts allow-popups allow-popups-to-escape-sandbox`};function JR(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 YR=class{onmessage;onerror;onclose;#e;#t;constructor(e){this.#e=e}start(){let e=e=>{JR(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 XR(e){for(let t of aC)if(e.some(e=>uz(e)===t))return t;return null}function ZR({onLayoutEffectChange:e,onRenderedSlotChange:t,debugEnabled:n=dz(),callPresence:r,callControlsVisible:i,callControlsRect:a,gridConfigEnabled:o,gridStartEnabled:s}={}){let{client:c}=Ev(),{dataTheme:l,cssVars:u}=DF(),d=Th(),f=Qg(),[p,m]=j([]),[h,g]=oz(),[_,v]=j(()=>({enabled:n,iframeLifecycleState:`idle`})),y=kR({instances:p,viewport:g,callControlsBandPx:72,callPresence:r,callControlsVisible:i,callControlsRect:a,gridConfigEnabled:o,gridStartEnabled:s}),b=F(e=>{v(t=>({...t,...e}))},[]),x=F((e,t=`*`)=>{if(f!==`joined-meeting`){b({lastError:`Dropped Magic Canvas app message because the Daily meeting is not joined.`});return}d?.sendAppMessage(e,t)},[d,f,b]),S=P(()=>({theme:l.value===`dark`?`dark`:`light`,cssVars:u.value}),[l.value,u.value]);M(()=>{v(e=>e.enabled===n?e:{...e,enabled:n})},[n]),u_({onAppMessage:F(e=>{if(f!==`joined-meeting`){b({lastToolCall:e.data,iframeLifecycleState:`idle`,lastError:`Dropped Magic Canvas tool call because the Daily meeting is not joined.`});return}try{let t=QC(e.data);if(!t)return;m(e=>_C(e,t)),b({lastToolCall:e.data,parsedCanvasConfig:t.kind===`show`?t.instance.canvas_config:void 0,iframeLifecycleState:t.kind===`clear`?`closed`:`received`,lastError:void 0})}catch(e){b({iframeLifecycleState:`error`,lastError:mz(e).message})}},[f,b])});let C=p.map(e=>{let t=wC(e,g),n=t.display_mode===`fullscreen`?null:y.cardRects.get(e.id)??null;return{instance:e,layout:n===null?t:{...t,viable_slot:`safe-area-right`},gridRect:n}}),w=TC(C.map(({layout:e})=>e),g),T=[...C].reverse().find(({layout:e})=>e.display_mode===`fullscreen`)?.instance.tool_call_id;M(()=>{e?.(w)},[e,w.active,w.side,w.video_shift_x,w.backdrop.type,w.safe_area?.x,w.safe_area?.y,w.safe_area?.width,w.safe_area?.height]);let E=XR(C.map(({layout:e})=>e));M(()=>{t?.(E)},[t,E]);let D=p.length>0||_.enabled;return L(`div`,{ref:h,"data-magic-canvas-root":!0,class:`pointer-events-none absolute inset-0 z-30`,children:[D&&T&&L(`div`,{class:`absolute inset-0 bg-black/45`}),D&&!T&&y.sheetBottomPx!==null&&L(`div`,{"data-grid-sheet-scrim":!0,class:`absolute inset-x-0 top-0`,style:{height:Math.min(y.sheetBottomPx+64,g.height),backgroundImage:`linear-gradient(to bottom, rgb(0 0 0 / 0.45) calc(100% - 64px), rgb(0 0 0 / 0))`}}),D&&C.map(({instance:e,layout:t,gridRect:n})=>L($R,{slot:uz(t),safeAreaTop:w.safe_area?.y,frameWidth:g.width,...n?{gridRect:n,gridAnimate:y.animate}:{},children:r=>L(ez,{availableHeight:r,client:c,gridDriven:n!==null,hostTheme:S,instance:e,layout:t,dimmed:!!(T&&T!==e.tool_call_id),onDebug:b,onNaturalHeightChange:y.recordNaturalHeight,onComplete:()=>{m(t=>t.filter(t=>t.id!==e.id))},onDisplayModeChange:t=>{m(n=>n.map(n=>n.tool_call_id===e.tool_call_id?{...n,layout:{...n.layout,display_mode:t}}:n))},sendAppMessage:x})},e.id)),D&&L(`div`,{class:`absolute right-4 bottom-24 @max-mobile:right-3 @max-mobile:bottom-20`,children:L(MR,{state:_})}),y.debug]})}var QR=16;function $R({slot:e,safeAreaTop:t,frameWidth:n,gridRect:r,gridAnimate:i=!1,children:a}){let[o,s]=sz(),c=a(r?r.height:e===`full`?void 0:s);if(r)return L(`div`,{ref:o,class:`pointer-events-auto absolute`,style:jR(r,i),"data-canvas-slot":e,"data-grid-driven":`true`,children:L(`div`,{class:`flex h-full w-full flex-col gap-2`,children:c})});if(e===`safe-area-left`||e===`safe-area-right`){let r=t==null?`1rem`:`${t*100}%`,i=n!=null&&n>0?Math.max(0,n-QR*2):void 0;return L(`div`,{ref:o,class:lz(e),style:{top:r,bottom:`72px`,maxWidth:i},"data-canvas-slot":e,children:L(`div`,{class:`my-auto flex w-full flex-col gap-2`,children:c})})}return L(`div`,{ref:o,class:lz(e),"data-canvas-slot":e,children:L(`div`,{class:`contents`,children:c})})}function ez({availableHeight:e,client:t,gridDriven:n=!1,hostTheme:r,instance:i,layout:a,dimmed:o,onDebug:s,onComplete:c,onDisplayModeChange:l,onNaturalHeightChange:u,sendAppMessage:d}){let f=N(null),p=N(null),m=N(e),h=N(320),g=N(r),_=N(i),v=N(a),y=N(-1),b=N(c),x=N(l),S=N(u),C=N(d),[w,T]=j(720);M(()=>{_.current=i},[i]),M(()=>{h.current=w,p.current?.setHostContext(iz(_.current,g.current,v.current,m.current,w))},[w]),M(()=>{m.current=e;let t=rz(r,f.current);g.current=t,p.current?.setHostContext(iz(_.current,t,v.current,e,h.current))},[e,r]),M(()=>{v.current=a,p.current?.setHostContext(iz(_.current,g.current,a,e,h.current))},[e,a]),M(()=>{b.current=c,x.current=l,S.current=u,C.current=d},[c,l,u,d]),M(()=>{let e=f.current;if(!e)return;let n=!1,r=null,a=null,o=null,c=null,l=new URL(i.canvas_config.sandbox_url,globalThis.location.href).href,u=e=>{n||s({iframeLifecycleState:`error`,lastError:mz(e).message})},d=()=>{if(n||!a)return;let e=_.current,t=SC(e,a);a=null,C.current({message_type:`conversation`,event_type:`conversation.append_llm_context`,conversation_id:e.conversation_id,properties:{context:t}}),s({lastModelContextUpdate:e.canvas_config.component,lastError:void 0})},w=()=>{if(r)return;if(e.src!==l){e.src;return}if(n||!e.contentWindow)return;let f=new TF(null,{name:`tavus-deployment`,version:`0.0.0`},{logging:{},message:{text:{},structuredContent:{}},updateModelContext:{text:{},structuredContent:{}}},{hostContext:iz(i,rz(g.current,e),v.current,m.current,h.current)});r=f,p.current=f,f.oninitialized=()=>{n||(s({iframeLifecycleState:`ready`}),y.current=_.current.revision,f.sendToolInput({arguments:_.current.arguments}).catch(u))},f.onsizechange=({height:e})=>{if(!n&&typeof e==`number`&&Number.isFinite(e)){let t=Math.min(Math.max(e,GR),720);T(t),S.current(_.current.id,t)}},f.onmessage=async e=>{let r=vC(e),i=xC(e);if(!r){if(i){let e=`Magic Canvas message included text without interaction metadata; no interaction row was recorded.`;return s({lastInteractionPostResult:`error`,lastError:e}),{isError:!0,code:`missing_interaction_metadata`,message:e}}return{}}let a=_.current,o=(()=>{try{let e=yC(a,r);return{interaction:e,request:$C(e)}}catch(e){return{error:e}}})();if(`error`in o){let e=mz(o.error).message;return s({lastInteractionPostResult:`error`,lastError:e}),{isError:!0,code:`interaction_normalization_failed`,message:e}}let{interaction:l,request:u}=o,d=!0;try{await zR(t,l.conversation_id,u.body)}catch(e){d=!1,BR(e)?VR(e,s):(console.warn(`Magic Canvas interaction POST failed; continuing without it and retrying in the background.`,e),s({lastInteractionPostResult:`failed_open`,lastError:mz(e).message}),HR(t,l.conversation_id,u.body,s))}if(n)return{};if(i)try{C.current({message_type:`conversation`,event_type:`conversation.respond`,conversation_id:a.conversation_id,properties:{text:i}})}catch(e){console.error(`Magic Canvas respond send failed.`,e),s({lastError:mz(e).message})}return d&&s({lastInteractionPostResult:`success`,lastError:void 0}),bC(l)&&(l.type===`submit`?(c&&clearTimeout(c),c=setTimeout(()=>{c=null,n||b.current()},WR(a.arguments))):b.current()),{}},f.onupdatemodelcontext=async e=>(a=e,o||=setTimeout(()=>{o=null,d()},FR),{}),f.onrequestdisplaymode=async({mode:e})=>{let t=e===`fullscreen`?`fullscreen`:`inline`;return x.current(t),v.current={...v.current,display_mode:t,viable_slot:t===`fullscreen`?`full`:v.current.viable_slot},f.setHostContext(iz(_.current,g.current,v.current,m.current,h.current)),{mode:t}},f.connect(new YR(e)).then(()=>void 0).catch(u)};s({iframeLifecycleState:`mounting`,lastInteractionPostResult:void 0}),i.canvas_config.sandbox_url,e.src=i.canvas_config.sandbox_url;let E=()=>{w()};return e.addEventListener(`load`,E),w(),()=>{o&&=(clearTimeout(o),null),c&&=(clearTimeout(c),null),d(),n=!0,e.removeEventListener(`load`,E),p.current=null,s({iframeLifecycleState:`closed`}),r&&rC(r)}},[t,i.id,i.canvas_config.sandbox_url,s]),M(()=>{i.revision!==0&&(i.revision<=y.current||(y.current=i.revision,p.current?.sendToolInput({arguments:i.arguments}).catch(e=>{s({iframeLifecycleState:`error`,lastError:mz(e).message})})))},[i.arguments,i.revision,s]);let E=a.viable_slot===`full`||a.display_mode===`fullscreen`,D=E?null:az(w,e),ee=D?.placeholderStyle,te=D?.cardStyle,ne=E?{height:`100%`}:D?.iframeStyle??{height:`${w}px`},re=[`pointer-events-auto w-full overflow-hidden rounded-box border-[length:var(--border)] border-base-300 bg-base-100 shadow-xl transition-[opacity,transform]`,E?`fixed inset-4 z-10 max-w-none`:n?`max-w-none`:`max-w-md`,o?`scale-[0.98] opacity-40`:``].filter(Boolean).join(` `),O=qR[i.canvas_config.component]??KR,ie=L(`div`,{class:re,style:te,"data-canvas-card":a.viable_slot,children:L(`iframe`,{ref:f,title:`${i.canvas_config.component} ${i.canvas_config.component_version}`,class:E?`block h-full w-full border-0 bg-transparent`:`block border-0 bg-transparent`,sandbox:O,style:ne})});return E?ie:L(`div`,{class:`block w-full`,style:ee,children:ie})}var tz=[`--color-base-100`,`--color-base-200`,`--color-base-300`,`--color-base-content`,`--color-primary`,`--color-error`];function nz(e){if(!e||typeof getComputedStyle!=`function`)return{};let t=getComputedStyle(e),n={};for(let e of tz){let r=t.getPropertyValue(e).trim();r&&(n[e]=r)}return n}function rz(e,t){let n=nz(t);return Object.keys(n).length===0?e:{...e,cssVars:{...e.cssVars,...n}}}function iz(e,t,n,r,i){let a=ew(t,n),o=n.viable_slot===`full`||n.display_mode===`fullscreen`,s=o?void 0:fz(r),c=o?1:az(i??0,r)?.displayScale??1;return{...e.canvas_config.host_context,...a,containerDimensions:{...pz(a.containerDimensions)?a.containerDimensions:{},...s===void 0?{}:{maxHeight:s},displayScale:c}}}function az(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{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`}}}function oz(){let e=N(null),[t,n]=j(()=>cz(null));return M(()=>{let t=()=>n(t=>{let n=cz(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 sz(){let e=N(null),[t,n]=j();return M(()=>{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 cz(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}}function lz(e){let t=`absolute flex gap-2`;switch(e){case`safe-area-left`:return`${t} left-4 w-[28rem] flex-col overflow-y-auto [scrollbar-gutter:stable]`;case`safe-area-right`:return`${t} right-4 w-[28rem] flex-col overflow-y-auto [scrollbar-gutter:stable]`;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 uz(e){return e.display_mode===`fullscreen`&&e.preferred_slot!==`full`?e.preferred_slot:e.viable_slot}function dz(){return!1}function fz(e){return e===void 0||!Number.isFinite(e)||e<=0?720:Math.min(Math.floor(e),720)}function pz(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function mz(e){return e instanceof Error?e:Error(String(e))}var hz=class extends A{state={errored:!1};componentDidCatch(e){this.props.onError(e),this.setState({errored:!0})}render(){return this.state.errored?null:this.props.children}},gz=1e4;function _z(e,t=gz){let[n,r]=j(!1),i=N(!1);return M(()=>{if(!e){r(!1);return}if(i.current)return;i.current=!0,r(!0);let n=setTimeout(()=>r(!1),t);return()=>clearTimeout(n)},[e,t]),n}function vz(e){let t=lg(),n=C_(t??``),r=!x_(t??``).isOff,i=US(e),a=i.phase===`ready`?i.replicaId:``,o=x_(a),s=!r&&(o.state===`playable`||o.state===`loading`),c=i.phase===`ready`&&!e&&!i.videoState.isOff,l=!e&&t!==null&&!n.isOff,u=i.phase!==`ready`||i.videoState.isOff;return P(()=>({presence:i,localId:t,isScreenSharing:r,isPersonaPresenting:s,hasPersonaVideo:c,hasSelfView:l}),[i.phase,a,u,t,r,s,c,l])}function yz(e,t,n){let[r,i]=j(!0);return M(()=>{if(!t)return;let n=e.current;if(!n||typeof matchMedia!=`function`)return;let r=matchMedia(`(hover: hover) and (pointer: fine)`),a=()=>{try{return n.matches(`:has(:focus-visible)`)}catch{return!1}},o=n.matches(`:hover`),s=()=>{i(!r.matches||o||a())},c=()=>{o=!0,s()},l=()=>{o=!1,s()};return n.addEventListener(`pointerenter`,c),n.addEventListener(`pointerleave`,l),n.addEventListener(`focusin`,s),n.addEventListener(`focusout`,s),r.addEventListener(`change`,s),s(),()=>{n.removeEventListener(`pointerenter`,c),n.removeEventListener(`pointerleave`,l),n.removeEventListener(`focusin`,s),n.removeEventListener(`focusout`,s),r.removeEventListener(`change`,s)}},[t,e,n]),r}function bz(e,t,n,r,i){let[a,o]=j(void 0);return M(()=>{if(!r)return;let i=e.current,a=t.current;if(!i||!a||typeof ResizeObserver>`u`)return;let s=()=>{let e=i.getBoundingClientRect(),t=1/0,r=-1/0;for(let e of a.children){let n=e.getBoundingClientRect();n.width!==0&&(t=Math.min(t,n.left),r=Math.max(r,n.right))}if(e.width===0||!Number.isFinite(t)||r<=t)return;let s={x:Math.round(t-e.left),y:Math.round(e.height-n),width:Math.round(r-t),height:n};o(e=>e!==void 0&&e.x===s.x&&e.y===s.y&&e.width===s.width&&e.height===s.height?e:s)},c=new ResizeObserver(s);c.observe(i),c.observe(a);for(let e of a.children)c.observe(e);return s(),()=>c.disconnect()},[r,e,t,n,i]),a}var xz=1e4;function Sz({onTimeout:e,timeoutMs:t=xz,active:n=!0}){let r=HS().length>0,[i,a]=j(!1),o=N(e);return M(()=>{o.current=e},[e]),M(()=>{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 Cz(e){if(typeof e!=`object`||!e)return!1;let t=e;return t.message_type===`system`&&t.event_type===`system.shutdown`}function wz({onShutdown:e}){let t=N(e);M(()=>{t.current=e},[e]),u_({onAppMessage:F(e=>{Cz(e?.data)&&t.current()},[])})}var Tz=wn(`PiP`),Ez=360,Dz=280;function Oz(){return globalThis.window!==void 0&&`documentPictureInPicture`in globalThis.window}function kz(e){let{enabled:t,active:n}=e,[r,i]=j(null),a=Oz(),o=I(iy),s=F(()=>{i(e=>(e&&!e.closed&&e.close(),null))},[]),c=F(async()=>{if(a&&!(!t||!n)&&!(r&&!r.closed))try{let e=await globalThis.window.documentPictureInPicture.requestWindow({width:Ez,height:Dz}),t=Ue.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){Tz.warn(`Failed to open PiP window`,e)}},[a,t,n,r]);return M(()=>{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){Tz.warn(`mediaSession metadata setup failed`,e)}let t=(t,n)=>{try{e.setActionHandler(t,n),r.push(t)}catch(e){Tz.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]),M(()=>{(!n||!t)&&r&&!r.closed&&s()},[n,t,r,s]),M(()=>()=>{r&&!r.closed&&r.close()},[r]),M(()=>{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 Az=Yt(null),jz={active:!1,video_shift_x:0,backdrop:{type:`snapshot_mirror`}},Mz=Ea(({id:e,showAudioWave:t=!0})=>{let n=C_(e).isOff;return L(`div`,{class:`relative aspect-square w-32 @max-mobile:w-24 rounded-box overflow-hidden bg-black/30 z-10 ${n?`hidden`:``}`,children:[L(Cg,{automirror:!0,sessionId:e,type:`video`,fit:`cover`,className:`w-full h-full object-cover ${n?`hidden`:``}`}),t&&L(`div`,{class:`absolute bottom-2 right-2`,children:L(FS,{id:e})})]})}),Nz=Ea(()=>{let e=lg(),{isScreenSharing:t}=Jx(),n=HS()[0];return L(k,{children:[t&&n&&L(Mz,{id:n}),e&&L(Mz,{id:e,showAudioWave:!1})]})}),Pz=Ea(()=>L(`div`,{class:`absolute bottom-4 @max-mobile:bottom-20 left-4 flex flex-col items-end gap-2 z-20`,children:L(Nz,{})})),Fz=Ea(({personaSessionId:e,localId:t,isScreenSharing:n,avatarOff:r,effect:i,animate:a})=>L(k,{children:[L(`div`,{class:`absolute inset-0 bg-base-200`}),i.content&&L(`div`,{class:`absolute overflow-hidden rounded-box bg-black`,style:jR(i.content,a),children:L(Cg,{sessionId:n?t??``:e,type:`screenVideo`,fit:`contain`,className:`absolute inset-0 h-full w-full object-contain`})}),i.replica&&L(`div`,{class:yR(`absolute overflow-hidden`,i.replicaCollapsed&&`rounded-box`),style:jR(i.replica,a),children:L(qS,{personaSessionId:e,localSessionId:t,isScreenSharing:!1,avatarOff:r})})]})),Iz=Ea(()=>{let{effect:e,animate:t}=wR.value,n=lg();return n===null||e.selfView===null?null:L(`div`,{class:`absolute z-20 overflow-hidden rounded-box bg-black/30`,style:jR(e.selfView,t),children:L(Cg,{automirror:!0,sessionId:n,type:`video`,fit:`cover`,className:`h-full w-full object-cover`})})}),Lz=Ea(({canvasRenderedSlot:e})=>{let t=zI(wR.value.effect);return t===`hidden`?null:t===`engine`?L(hz,{onError:MI,children:L(Iz,{})}):e===`safe-area-bottom`?null:L(Pz,{})}),Rz=Ea(()=>{let e=HS()[0];return e?L(xg,{sessionId:e}):null}),zz=Ea(e=>L(k,{children:[L(Rz,{}),L(Bz,{...e})]})),Bz=Ea(({isAudioOnly:e,presence:t,canvasLayoutEffect:n,canvasRenderedSlot:r})=>{let{presence:i,localId:a,isScreenSharing:o,isPersonaPresenting:s}=t,c=wR.value,l=n.active&&!o&&(!e||s);return i.phase===`left`?L(NS,{}):i.phase===`connecting`?L(MS,{}):e&&!s?L(`div`,{class:`absolute inset-0 flex items-center justify-center`,children:L(zS,{sessionId:i.replicaId})}):c.effect.driving?L(hz,{onError:MI,children:L(Fz,{personaSessionId:i.replicaId,localId:a,isScreenSharing:o,avatarOff:i.videoState.isOff,effect:c.effect,animate:c.animate})}):s?L(Nw,{personaSessionId:i.replicaId,isAudioOnly:e,avatarOff:i.videoState.isOff,canvasLayoutEffect:n,smartSidecarActive:l}):L(Vz,{personaSessionId:i.replicaId,localId:a,isScreenSharing:o,avatarOff:i.videoState.isOff,smartSidecarActive:l,canvasLayoutEffect:n,canvasRenderedSlot:r})}),Vz=Ea(({personaSessionId:e,localId:t,isScreenSharing:n,avatarOff:r,smartSidecarActive:i,canvasLayoutEffect:a,canvasRenderedSlot:o})=>L(jw,{canvasLayoutEffect:a,smartSidecarActive:i,isScreenSharing:n,captureSnapshot:Gz,personaMode:`auto`,renderedSlot:o,fill:i=>L(qS,{personaSessionId:e,localSessionId:t,isScreenSharing:n,avatarOff:r,videoRef:i})})),Hz=Ea(({items:e})=>{let[t,n]=j(!1),r=N(null);return M(()=>{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]),L(`div`,{ref:r,class:`relative`,children:[L(`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:L(nx,{name:`more`})}),t&&L(`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})]})}),Uz=Ea(({items:e})=>e.length<=1?L(k,{children:e}):L(Hz,{items:e})),Wz=Ea(({onLeave:e})=>{let t=Qg(),{config:n}=Ev(),{session:r,end:i}=yS(),a=lg(),o=N(null),s=I(qy)?.frameRef??o,[c,l]=j(!1),u=Ex()===`full-screen`,[d,f]=j(!1),[p,m]=j(jz),[h,g]=j(null),_=n.value.customization.conversation,v=_z(_.show_fullscreen_hint&&h!==null&&!c&&!u),y=N(null),b=N(null),x=r.value?.conversationUrl,S=r.value?.magicGrid===!0,C=DI(_.magic_grid,S),w=yz(y,C,x),T=bz(y,b,72,C,x),E=_.modality===`audio`,D=vz(E),ee=_.modality===`chat`,te=_.modality===`video`,ne=_.enable_chat,re=_.enable_closed_captions,O=_.enable_picture_in_picture,{pipWindow:ie}=kz({enabled:O&&!ee,active:t===`joined-meeting`});M(()=>()=>{i()},[i]);let{camera:ae,requestCamera:k}=Xv(),{isCamMuted:A}=Kx(),oe=ae.isGranted&&!A;M(()=>{te&&t===`joined-meeting`&&(Az.value=oe)},[te,t,oe]);let se=N(te&&!a&&Az.value===!0);M(()=>{t===`joined-meeting`&&se.current&&(se.current=!1,k())},[t,k]),M(()=>{(t===`left-meeting`||t===`error`)&&e()},[t,e]),M(()=>{let e=()=>{let e=s.current,t=e?.getRootNode(),n=t instanceof Document||t instanceof ShadowRoot?t:null;l(!!e&&n?.fullscreenElement===e)};return document.addEventListener(`fullscreenchange`,e),()=>document.removeEventListener(`fullscreenchange`,e)},[]);let ce=F(()=>{let e=s.current;if(!e)return;let t=e.getRootNode();(t instanceof Document||t instanceof ShadowRoot?t:null)?.fullscreenElement===e?document.exitFullscreen?.():e.requestFullscreen?.()},[]);F(()=>{f(e=>!e)},[]);let le=F(()=>{i()},[i]);if(Sz({active:!ee&&t===`joined-meeting`,onTimeout:le}),wz({onShutdown:le}),!x)return null;if(ee)return L(ES,{defaultOpen:!0,children:L(`div`,{class:`cvi-call-surface absolute inset-0`,children:L(AS,{docked:!0,headerAction:L(`button`,{type:`button`,class:`btn btn-ghost btn-sm btn-circle text-base-content/60 hover:text-error`,onClick:le,"aria-label":`Leave conversation`,children:L(nx,{name:`leave`,size:20,"aria-label":`Leave conversation`})})})})});let ue=[L(vS,{compact:!0},`screen-share`)];ne&&ue.push(L(OS,{compact:!0},`chat`));let de=t===`left-meeting`;return L(xS,{children:L(ES,{children:L(tS,{children:[L(`div`,{class:`cvi-call-surface absolute inset-0${E?``:` cvi-video-surface`}`,ref:y,children:[L(`div`,{class:`relative w-full h-full z-[5]`,children:[L(zz,{isAudioOnly:E,presence:D,canvasLayoutEffect:p,canvasRenderedSlot:h}),!E&&L(Lz,{canvasRenderedSlot:h}),L(ZR,{debugEnabled:d,callPresence:D,callControlsVisible:w,callControlsRect:T,gridConfigEnabled:_.magic_grid,gridStartEnabled:S,onLayoutEffectChange:m,onRenderedSlotChange:g}),!u&&L(`div`,{class:`cvi-autohide absolute top-4 right-4 z-20`,"data-hidden":de,"data-pinned":v,children:L(PS,{active:c,onToggle:ce,nudge:v,compact:!0})})]}),L(AS,{}),L(wS,{}),L(`div`,{class:`cvi-autohide cvi-autohide-slide pointer-events-none absolute bottom-6 left-0 right-0 z-20`,"data-hidden":de,"aria-hidden":de,children:L(`div`,{class:`cvi-control-rail flex justify-center items-center gap-2 @max-mobile:gap-1`,"data-hidden":de,ref:b,children:[L(pS,{level:!0}),!E&&L(hS,{}),re&&L(CS,{}),L(Uz,{items:ue}),L(`button`,{type:`button`,class:`btn btn-control btn-error`,onClick:le,"aria-label":`Leave call`,children:L(nx,{name:`leave`,"aria-label":`Leave Call`})})]})})]}),ie&&Ua(L(GS,{onLeave:le}),ie.document.body)]})})})});function Gz(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 Kz({message:e,class:t}){return L(`div`,{class:`w-max max-w-[min(20rem,80vw)] ${t??``}`,children:[L(`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}),L(`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:L(`path`,{d:`M0 0 L8 8 L16 0 Z`,fill:`currentColor`})})]})}function qz(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...`}}var Jz=Ea(({text:e,isJoining:t=!1,onJoin:n,onCancel:r})=>{let i=Th(),{config:a}=Ev(),{localSessionId:o,isCamMuted:s}=Kx(),{mic:c,camera:l,requestMic:u,requestCamera:d}=Xv(),f=a.value.customization.conversation.modality===`video`,p=sx(a.value),m=ox(a.value);M(()=>{u()},[]);let h=c.isGranted,g=N(!1);M(()=>{!f||!h||g.current||l.isGranted||l.isBlocked||(g.current=!0,d())},[f,h,l.isGranted,l.isBlocked,d]);let _=f&&h&&!l.isGranted,v=qz(e,c.status,_);return L(tS,{children:L(`div`,{class:`absolute inset-0 motion-safe:animate-[tavusFadeUp_280ms_ease-out]`,children:[l.isGranted&&!s?L(`div`,{class:`absolute inset-0 flex items-center justify-center bg-black overflow-hidden`,children:L(Cg,{type:`video`,sessionId:o??``,mirror:!0,fit:`cover`,className:`w-full h-full object-cover!`})}):L(`div`,{class:`absolute inset-0 overflow-hidden bg-base-300`,children:[L(fx,{variant:p.background,replica:m}),L(`div`,{class:`${Fx} backdrop-blur-xs`})]}),L(`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:[v&&L(Kz,{message:v,class:`relative`}),L(`div`,{class:`flex flex-wrap items-center justify-center gap-1.5 @max-mobile:gap-1`,children:[L(`div`,{class:`flex items-center justify-center gap-1.5 shrink-0 @max-mobile:gap-1`,children:[L(pS,{level:!0}),f&&L(hS,{})]}),L(gx,{class:`btn-accent `,loading:t,disabled:!h,onClick:n,children:e?.join??`Join`}),L(`button`,{type:`button`,class:`btn btn-control ${c.isBlocked?`btn-error`:`btn-neutral`}`,onClick:()=>{i&&i.leave(),r?.()},"aria-label":e?.cancel??`Cancel`,title:e?.cancel??`Cancel`,children:L(nx,{name:`cancel`})})]})]})]})})}),Yz=`Password required`,Xz=`Enter the password to start this conversation.`,Zz=`Password`,Qz=`Continue`;function $z({onSubmit:e,text:t,isSubmitting:n=!1,errorMessage:r}){let[i,a]=j(``),o=ct();return L(`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:L(`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:L(`div`,{class:`card-body gap-3`,children:[L(`h3`,{id:`${o}-title`,class:`card-title text-base-content`,children:t?.title??Yz}),L(`p`,{class:`text-sm text-base-content/70`,children:t?.description??Xz}),L(`input`,{id:o,type:`password`,autocomplete:`current-password`,class:`input input-bordered w-full`,placeholder:t?.placeholder??Zz,value:i,disabled:n,onInput:e=>a(e.target.value),autoFocus:!0}),r&&L(`p`,{class:`text-error text-xs`,role:`alert`,children:r}),L(gx,{class:`btn-primary`,type:`submit`,disabled:!i.trim(),loading:n,children:t?.submit??Qz})]})})})}function eB({kind:e,status:t}){if(e===`camera`)return`Allow camera access to use video. Camera is optional.`;switch(t){case`blocked`:return`Microphone is blocked. Allow access in your browser settings to continue.`;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.`;default:return`Allow microphone access to start the conversation.`}}function tB({text:e,onStart:t,isStarting:n,permissionRequest:r}){let{config:i,deploymentId:a}=Ev(),o=Ex()===`full-screen`,s=I(av),c=sx(i.value),l=c.btn_title??e?.fallback_button??`Start the conversation`,u=i.value.customization.terms_content?.trim()??``,d=i.value.customization.terms_enabled===!0,f=u.length>0,p=f&&d,m=P(()=>p&&P_(a,u),[p,a,u]),h=p&&!m,g=i.value.has_password===!0,_=s?.password.value??null,v=g&&!_,y=ct(),[b,x]=j(m),S=n||p&&!b||v;return L(Lx,{title:c.title,description:c.description,overlay:v&&s?L($z,{onSubmit:s.setPassword}):null,children:[L(`div`,{class:`relative`,children:[r&&L(Kz,{message:eB(r),class:`absolute bottom-full mb-3 z-20 ${o?`left-1/2 -translate-x-1/2`:`right-0`}`}),L(Bx,{onClick:()=>{p&&b&&!m&&L_(a,u),t()},disabled:S,loading:n,children:l})]}),f&&L(`div`,{class:`max-w-xs text-center`,children:h?L(`label`,{for:y,class:`flex items-center gap-2 text-xs text-left cursor-pointer`,children:[L(`input`,{id:y,type:`checkbox`,class:`checkbox checkbox-secondary checkbox-xs mt-0.5 shrink-0`,checked:b,onChange:e=>x(e.target.checked)}),L(`span`,{class:`leading-snug`,children:u})]}):L(`p`,{class:`text-xs leading-snug text-white/70`,children:u})})]})}function nB(...e){for(let t of e){let e=t?.trim();if(e)return e}}function rB(){let{config:e}=Ev(),{haircheck:t}=e.value.customization;return P(()=>({prompt:nB(t.permission_request_description,t.permission_request_title),ready:nB(t.permission_granted_description,t.permission_granted_title),denied:nB(t.permission_denied_description,t.permission_denied_title),join:nB(t.join_button),cancel:nB(t.cancel_btn)}),[t])}function iB({flow:e,welcomeText:t,onUnavailableCancel:n}){let r=rB();switch(e.state){case`idle`:return L(tB,{text:t,onStart:()=>{e.start()},isStarting:e.isStarting,permissionRequest:e.permissionRequest});case`haircheck`:return L(Jz,{text:r,onJoin:()=>{e.join()},onCancel:()=>e.cancel(),isJoining:e.isStarting});case`call`:return L(Wz,{onLeave:()=>e.leave()});case`ended`:return L(Gx,{isStarting:e.isStarting,onRestart:()=>{e.start()}});case`unavailable`:return L(Sx,{cause:e.unavailableCause??`busy`,canRetry:e.canRetry,isStarting:e.isStarting,onRetry:()=>{e.start()},onCancel:n});default:{let t=e.state;throw Error(`Unreachable flow state: ${String(t)}`)}}}function aB(){let{config:e,configError:t}=Ev(),n=Tx(),r=Cx(),i=P(()=>({fallback_button:n.start_button}),[n.start_button]),a=e.value.is_available,o=e.value.unavailable_reason;return L(Jy,{children:t.value?L(Sx,{cause:`error`,canRetry:!1,onRetry:()=>{}}):a===!1?L(Sx,{cause:o??`daily_limit`,canRetry:!1,onRetry:()=>{}}):L(iB,{flow:r,welcomeText:i})})}var oB=`:host {
165
165
  display: block;
166
166
  /* Containing block for the captcha overlay, which is owned by a provider
167
167
  above the shells and so has no positioned ancestor of its own. */
@@ -172,4 +172,4 @@ container holding the app. Specify either width or maxWidth, and either height o
172
172
  overflow: hidden;
173
173
  background: transparent;
174
174
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
175
- }`;function aB(e){return L(k,{children:[L(`style`,{dangerouslySetInnerHTML:{__html:Ue}}),L(`style`,{dangerouslySetInnerHTML:{__html:iB}}),L(jt,{layout:e.layout,"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`],"expand-options":e[`expand-options`],token:e.token,children:L(Oi,{fallback:L(Gy,{}),children:L(Ai,{children:L(ov,{children:L(wv,{children:L(Qv,{children:L(ny,{children:L(iy,{children:L(Iy,{children:L(rB,{})})})})})})})})})})]})}var oB;function sB(){oB||=Fe(aB,`tavus-embed`,[`layout`,`deployment-id`,`override-config`,`conversational-context`,`custom-greeting`,`memory-stores`,`base-url`,`expand-options`,`token`],{shadow:!0,mode:`open`})}Ae(null),wn(`Widget`);var cB=[`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`],lB=class{element=null;tagName;constructor(e=`tavus-embed`){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`&&sB(),e.TAVUS_EVENT_NAMES=cB,e.TavusIntegration=lB,e})({});
175
+ }`;function sB(e){return L(k,{children:[L(`style`,{dangerouslySetInnerHTML:{__html:Ue}}),L(`style`,{dangerouslySetInnerHTML:{__html:oB}}),L(jt,{layout:e.layout,"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`],"expand-options":e[`expand-options`],token:e.token,children:L(Oi,{fallback:L(Ky,{}),children:L(Ai,{children:L(ov,{children:L(Tv,{children:L($v,{children:L(ry,{children:L(ay,{children:L(Ly,{children:L(aB,{})})})})})})})})})})]})}var cB;function lB(){cB||=Fe(sB,`tavus-embed`,[`layout`,`deployment-id`,`override-config`,`conversational-context`,`custom-greeting`,`memory-stores`,`base-url`,`expand-options`,`token`],{shadow:!0,mode:`open`})}Ae(null),wn(`Widget`);var uB=[`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`],dB=class{element=null;tagName;constructor(e=`tavus-embed`){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`&&lB(),e.TAVUS_EVENT_NAMES=uB,e.TavusIntegration=dB,e})({});