@alexkroman1/aai-ui 0.14.1 → 0.14.3

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.
@@ -1,5 +1,5 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./capture-processor-X_vJUkv4.js","./_module-url-BX0RuRU2.js","./playback-processor-DdO-2G6m.js"])))=>i.map(i=>d[i]);
2
- var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),s=(e,n)=>{let r={};for(var i in e)t(r,i,{get:e[i],enumerable:!0});return n||t(r,Symbol.toStringTag,{value:`Module`}),r},c=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},l=(n,r,o)=>(o=n==null?{}:e(i(n)),c(r||!n||!n.__esModule||!a.call(n,`default`)?t(o,`default`,{value:n,enumerable:!0}):o,n));(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),t.credentials=e.crossOrigin===`use-credentials`?`include`:e.crossOrigin===`anonymous`?`omit`:`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var u=.1,d=1500,f=.001,p=1e3,m=65e3,h=1048576,g=1e4,_=2e3,v=15e3,y=/^[A-Za-z0-9_-]{1,64}$/,b=16e3,x=1e5,ee=1e4,S=192e3;function C(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function w(e){let t={};for(let[n,r]of Object.entries(e))r!==void 0&&(t[n]=r);return t}function T(e){try{return JSON.parse(e)}catch{}}var te=200,E=`…`;function ne(e){return e.length<=te?e:`${e.slice(0,te)}${E}`}function re(e,t,n){let r=n===void 0?`${e}`:`${n} ${e}`;return t?`${r}: ${ne(t)}`:r}async function ie(e,t){let n=await e.text().catch(()=>``),r=T(n);if(r===void 0)throw Error(re(e.status,n,t));return r}var ae={brands:{clientTool:`@alexkroman1/aai.clientTool`,clientToolCall:`@alexkroman1/aai.clientTool.call`,routeResponse:`@alexkroman1/aai.routeResponse`,routeError:`@alexkroman1/aai.routeError`,stepError:`@alexkroman1/aai.stepError`,keylessSynthesizer:`@alexkroman1/aai.speechSynthesizer.keyless`},slots:{channelOutbox:`@alexkroman1/aai.channelOutbox`,clientEventFeed:`@alexkroman1/aai-runtime.clientEventFeed`,clientInboxDefaults:`@alexkroman1/aai.clientInboxDefaults`,clientTranscriptReader:`@alexkroman1/aai.clientTranscriptReader`,metricsSinks:`@alexkroman1/aai-runtime.metricsSinks`,runtimeInstances:`@alexkroman1/aai-runtime.instances`,sessionCalls:`@alexkroman1/aai.sessionCalls`,sessionClients:`@alexkroman1/aai.sessionClients`,sessionEnders:`@alexkroman1/aai.sessionEnders`,sessionLocations:`@alexkroman1/aai.sessionLocations`,sessionPhones:`@alexkroman1/aai.sessionPhones`,speechSynthesizer:`@alexkroman1/aai.speechSynthesizer`,stepDelegate:`@alexkroman1/aai.stepDelegate`,stepEnv:`@alexkroman1/aai.stepEnv`,stepFetch:`@alexkroman1/aai.stepFetch`,stepInfoReader:`@alexkroman1/aai.stepInfoReader`,stepMcp:`@alexkroman1/aai.stepMcp`,stepNotifyClient:`@alexkroman1/aai.stepNotifyClient`,stepReporter:`@alexkroman1/aai.stepReporter`,stepWebhookUrl:`@alexkroman1/aai.stepWebhookUrl`,uploadReader:`@alexkroman1/aai.uploadReader`}};function oe(e){let t=Symbol.for(ae.slots[e]);return{get:()=>Reflect.get(globalThis,t),set:e=>{e===void 0?Reflect.deleteProperty(globalThis,t):Reflect.set(globalThis,t,e)}}}function se(e){return typeof e.get==`function`}function ce(e){let t=(se(e)?e:e.headers).get(`retry-after`)?.trim();if(!t)return;if(/^\d+$/.test(t)){let e=Number(t);return Number.isFinite(e)?new Date(Date.now()+e*1e3):void 0}let n=Date.parse(t);if(!Number.isNaN(n))return n>Date.now()?new Date(n):void 0}var le=4;function ue(e){return de(e,[],0)}function de(e,t,n){return e.map(e=>fe(e,t,n)).join(`; `)}function fe(e,t,n){let r=[...t,...e.path??[]],i=r.map(e=>String(C(e)?e.key:e)).join(`.`);if(n<le){let t=pe(e);if(t)return[...new Set(t.map(e=>de(e,r,n+1)))].join(` or `);let a=me(e);if(a){let t=de(a,[],n+1),r=t?`${e.message} — ${t}`:e.message;return i?`${i}: ${r}`:r}}return i?`${i}: ${e.message}`:e.message}function pe(e){if(!Array.isArray(e.errors))return;let t=e.errors,n=[];for(let e of t){if(!Array.isArray(e))continue;let t=e.filter(he);t.length>0&&n.push(t)}return n.length>0?n:void 0}function me(e){if(!Array.isArray(e.issues))return;let t=e.issues.filter(he);return t.length>0?t:void 0}function he(e){return C(e)&&typeof e.message==`string`}var ge=[`B`,`KB`,`MB`,`GB`,`TB`],_e=1024;function ve(e){let t=Number.isFinite(e)?Math.max(0,e):0,n=0;for(;t>=_e&&n<ge.length-1;)t/=_e,n+=1;let r=ye(t,n);return Number.parseFloat(r)>=_e&&n<ge.length-1&&(n+=1,r=ye(t/_e,n)),`${r} ${ge[n]}`}function ye(e,t){return t<=1?String(Math.round(e)):e.toFixed(1)}function be(e){return xe(e,new Set)??De(e)}var D=new Set([`fetch failed`,`failed to fetch`]),O=`Unknown error`;function xe(e,t){if(C(e)){if(t.has(e))return;t.add(e)}let n=ke(e);if(n!==void 0)return ue(n);let r=Ce(e,t);if(r!==void 0)return r;let i=Se(e);if(i!==void 0&&!D.has(i.toLowerCase()))return i;let a=Te(e,t);return a===void 0?i:i===void 0||a.includes(i)?a:`${i}: ${a}`}function Se(e){if(!C(e)||typeof e.message!=`string`)return;let t=e.message.trim();return t===``?void 0:t}function Ce(e,t){if(!C(e)||typeof e.statusCode!=`number`||!Number.isFinite(e.statusCode))return;let n=Ee(e.url),r=`HTTP ${e.statusCode}${n===void 0?``:` from ${n}`}`,i=Se(e)??we(e.responseBody)??we(e.data)??Te(e,t);return i===void 0?r:`${i} (${r})`}function we(e){if(typeof e==`string`){let t=e.trim();return t===``?void 0:we(T(t))??ne(t)}if(C(e))for(let t of[e.error,e.message,e.detail]){let e=typeof t==`string`?t.trim():Se(t)??``;if(e!==``)return e}}function Te(e,t){if(!C(e))return;if(e.cause!==void 0&&e.cause!==null){let n=xe(e.cause,t);if(n!==void 0)return n}if(!Array.isArray(e.errors))return;let n=e.errors.map(e=>xe(e,t)).filter(e=>e!==void 0);return n.length===0?void 0:n.join(`; `)}function Ee(e){if(typeof e==`string`&&e!==``)try{return new URL(e).host||void 0}catch{return}}function De(e){if(C(e)&&typeof e.name==`string`&&e.name.trim()!==``)return`${e.name.trim()} (no message)`;let t=Oe(e);return t===``||t===`[object Object]`?O:t}function Oe(e){try{return String(e).trim()}catch{return``}}function ke(e){if(!(C(e)&&Array.isArray(e.issues))||e.issues.length===0)return;let t=e.issues;return t.every(e=>C(e)&&typeof e.message==`string`)?t:void 0}async function Ae(e,t){let n=await e.text().catch(()=>``),r=T(n);if(C(r)){let{error:e}=r;if(typeof e==`string`&&e!==``)return e}return re(e.status,n,t)}function je(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 Me(e,t=`|`){return e.map(e=>rt(e)).join(t)}function Ne(e,t){return typeof t==`bigint`?t.toString():t}var Pe=class{constructor(e){this._getter=e,this._value=void 0}get value(){let e=this._getter;return e!==void 0&&(this._value=e(),this._getter=void 0),this._value}};function Fe(e){return new Pe(e)}function Ie(e){return e==null}function Le(e){let t=+!!e.startsWith(`^`),n=e.endsWith(`$`)?e.length-1:e.length;return e.slice(t,n)}function Re(e,t){let n=e/t,r=Math.round(n),i=4*2**-52*Math.max(Math.abs(n),1);return Math.abs(n-r)<i?0:n-r}function ze(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function Be(e){let t=Object.getOwnPropertyDescriptor(e,`shape`);return t?.get?t.get.raw:t?.value}function Ve(e){return Be(e._zod.def)??e._zod.def.shape}function He(e,t,n){Object.defineProperty(e,t,{get(){let e=n();return ze(this,t,e),e},enumerable:!0,configurable:!0})}function Ue(e,t,n){t in e?ze(e,t,n):e[t]=n}function We(e,t,n,r){let i=Ve(t);for(let a of n){let n=Object.getOwnPropertyDescriptor(i,a);n.enumerable&&(n.get?He(e,a,()=>{let e=t._zod.def.shape[a];return r?r(e,a):e}):Ue(e,a,r?r(n.value,a):n.value))}}function Ge(e,t){for(let n of Reflect.ownKeys(t)){let r=Object.getOwnPropertyDescriptor(t,n);r.enumerable&&(r.get?He(e,n,()=>t[n]):Ue(e,n,r.value))}}function Ke(...e){let t={};for(let n of e){let e=Object.getOwnPropertyDescriptors(n);Object.assign(t,e)}return Object.defineProperties({},t)}function qe(e){return JSON.stringify(e)}function Je(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,``).replace(/[\s_-]+/g,`-`).replace(/^-+|-+$/g,``)}var Ye=`captureStackTrace`in Error?Error.captureStackTrace:(...e)=>{};function Xe(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var Ze=Fe(()=>{if(Wt.jitless||typeof navigator<`u`&&navigator?.userAgent?.includes(`Cloudflare`))return!1;try{return Function(``),!0}catch{return!1}});function Qe(e){if(Xe(e)===!1)return!1;let t=e.constructor;if(t===void 0||typeof t!=`function`)return!0;let n=t.prototype;return Xe(n)!==!1&&Object.prototype.hasOwnProperty.call(n,`isPrototypeOf`)!==!1}function $e(e){return Qe(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}var et=new Set([`string`,`number`,`symbol`]);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 k(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!==void 0&&e[t]._zod.optout===`optional`)}var at={safeint:[-(2**53-1),2**53-1],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]},ot={int64:[BigInt(`-9223372036854775808`),BigInt(`9223372036854775807`)],uint64:[BigInt(0),BigInt(`18446744073709551615`)]};function st(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`);let i={};return We(i,e,ct(e,t)),nt(e,Ke(n,{shape:i,checks:[]}))}function ct(e,t){let n=Ve(e),r=[];for(let e of Reflect.ownKeys(t)){if(!Object.getOwnPropertyDescriptor(n,e)?.enumerable)throw Error(`Unrecognized key: "${String(e)}"`);t[e]&&r.push(e)}return r}function lt(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`);let i=new Set(ct(e,t)),a={};return We(a,e,Reflect.ownKeys(Ve(e)).filter(e=>!i.has(e))),nt(e,Ke(n,{shape:a,checks:[]}))}function ut(e,t){if(!Qe(t))throw Error(`Invalid input to extend: expected a plain object`);let n=e._zod.def.checks;if(n&&n.length>0){let n=Ve(e);for(let e of Reflect.ownKeys(t))if(Object.getOwnPropertyDescriptor(n,e)!==void 0)throw Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}return nt(e,Ke(e._zod.def,{shape:dt(e,t)}))}function dt(e,t){let n={};return We(n,e,Reflect.ownKeys(Ve(e))),Ge(n,t),n}function ft(e,t){if(!Qe(t))throw Error(`Invalid input to safeExtend: expected a plain object`);return nt(e,Ke(e._zod.def,{shape:dt(e,t)}))}function pt(e,t){if(!t?._zod?.def)throw Error("Invalid input to merge: expected an object schema. To merge a plain shape, use `.extend()`.");if(e._zod.def.checks?.length)throw Error(`.merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.`);let n={};return We(n,e,Reflect.ownKeys(Ve(e))),We(n,t,Reflect.ownKeys(Ve(t))),nt(e,Ke(e._zod.def,{shape:n,get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]}))}function mt(e,t,n,r=`partial`){let i=t._zod.def.checks;if(i&&i.length>0)throw Error(`.${r}() cannot be used on object schemas containing refinements`);let a=n?new Set(ct(t,n)):void 0,o={};return We(o,t,Reflect.ownKeys(Ve(t)),e&&((t,n)=>a&&!a.has(n)?t:new e({type:`optional`,innerType:t}))),nt(t,Ke(t._zod.def,{shape:o,checks:[]}))}function ht(e,t,n){let r=n?new Set(ct(t,n)):void 0,i={};return We(i,t,Reflect.ownKeys(Ve(t)),(t,n)=>r&&!r.has(n)?t:new e({type:`nonoptional`,innerType:t})),nt(t,Ke(t._zod.def,{shape:i}))}function gt(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 _t(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 vt(e,t){return t.map(t=>{var n;return(n=t).path??(n.path=[]),t.path.unshift(e),t})}function yt(e){return typeof e==`string`?e:e?.message}function bt(e,t,n){var r;for(let i=t;i<e.length;i++)(r=e[i]).schema??(r.schema=n)}function xt(e,t,n){var r;let i=e.inst?._zod?.traits;i?.has(`$ZodType`)&&(i.has(`$ZodCheck`)?(r=e).schema??(r.schema=e.inst):e.schema=e.inst);let a=e.schema===e.inst?void 0:e.schema?._zod.def?.error,o=e.message?e.message:yt(e.inst?._zod.def?.error?.(e))??yt(a?.(e))??yt(t?.error?.(e))??yt(n.customError?.(e))??yt(n.localeError?.(e))??`Invalid input`,s={};for(let t of Object.keys(e))t!==`inst`&&t!==`schema`&&t!==`continue`&&t!==`input`&&t!==`__proto__`&&(s[t]=e[t]);return s.path??=[],s.message=o,t?.reportInput&&(s.input=e.input),s}var St=/[\uD800-\uDBFF]/;function Ct(e){let t=e.length;if(!St.test(e))return t;let n=t;for(let r=0;r<t-1;r++)(e.charCodeAt(r)&64512)==55296&&(e.charCodeAt(r+1)&64512)==56320&&(n--,r++);return n}function wt(e){return Array.isArray(e)?`array`:typeof e==`string`?`string`:`unknown`}function Tt(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 Et(...e){let[t,n,r]=e;return typeof t==`string`?{message:t,code:`custom`,input:n,inst:r}:{...t}}function Dt(e,t){for(let n in t){let r=Object.getOwnPropertyDescriptor(t,n);r.get?Object.defineProperty(e,n,{...r,enumerable:!1}):At(e,n,r.value)}}function A(e,t,n,r=!0){return Object.defineProperty(e,t,{configurable:!0,writable:!0,enumerable:r,value:n}),n}function Ot(e,t,n){return A(e,t,n,!1)}function kt(e,t){for(let n in e){let r=e[n];Object.defineProperty(t,n,{configurable:!0,enumerable:!0,get(){return A(this,n,r(this))},set(e){A(this,n,e)}})}return t}function At(e,t,n){Object.defineProperty(e,t,{configurable:!0,get(){return this==null?n:A(this,t,n.bind(this))},set(e){A(this,t,e)}})}function jt(e,t){let n=Object.getPrototypeOf(e);return t in n?void 0:n}var Mt,Nt=!1,Pt={configurable:!0,get(){Nt=!0}};function j(e,t,n){let r=Object.getPrototypeOf(e._zod);if(t in r&&Mt!==e._zod){Mt=void 0;return}Mt=e._zod,Object.defineProperty(r,t,{configurable:!0,get(){Object.defineProperty(this,t,Pt);let e=Nt;Nt=!1;try{let r=n(this);return Nt?delete this[t]:Object.defineProperty(this,t,{configurable:!0,writable:!0,value:r}),Nt||=e,r}catch(n){throw delete this[t],Nt||=e,n}},set(e){Object.defineProperty(this,t,{configurable:!0,writable:!0,value:e})}})}function Ft(e,t,n,r){let i=jt(e,t);i&&Object.defineProperty(i,t,{configurable:!0,get(){let e={configurable:!0,writable:!0,enumerable:r,value:void 0};return Object.defineProperty(this,t,e),e.value=n(this),Object.defineProperty(this,t,e),e.value},set(e){Object.defineProperty(this,t,{configurable:!0,writable:!0,enumerable:r,value:e})}})}var It=`~constantCatch`;function Lt(e){let t=()=>e;return t[It]=!0,t}var Rt,zt={value:void 0,enumerable:!1},Bt=`captureStackTrace`in Error?Error:null;function Vt(e){let t=Bt;if(t){let n=t.stackTraceLimit;if(typeof n==`number`){try{t.stackTraceLimit=0}catch{return Bt=null,new e}try{return new e}finally{t.stackTraceLimit=n}}}return new e}function M(e,t,n,r){let i={};function a(e){this.def=e,this.constr=d,this.traits=new Set}a.prototype=i;let o=n,s=o&&new WeakSet;function c(n,r){if(!n._zod){zt.value=new a(r);try{Object.defineProperty(n,"_zod",zt)}finally{zt.value=void 0}}else if(n._zod.traits.has(e))return;if(n._zod.traits.add(e),t(n,r),s){let e=Object.getPrototypeOf(n),t=n._zod.constr.prototype,r=e;for(;r&&r!==t;)r=Object.getPrototypeOf(r);let i=r??e;s.has(i)||(s.add(i),Dt(i,o))}let i=d.prototype;for(let e in i)Object.prototype.hasOwnProperty.call(i,e)&&(e in n||(n[e]=i[e].bind(n)))}let l=r?.Parent??Object;class u extends l{}Object.defineProperty(u,"name",{value:e});function d(e){let t=r?.Parent?Vt(u):this;c(t,e);let n=t._zod.deferred;if(n){for(let e of n)e();t._zod.deferred=void 0}let i=globalThis.__zod_globalConfig?.postProcessor;return i&&i(t),t}return Object.defineProperty(d,"init",{value:c}),Object.defineProperty(d,Symbol.hasInstance,{value:t=>r?.Parent&&t instanceof r.Parent?!0:t?._zod?.traits?.has(e)}),Object.defineProperty(d,"name",{value:e}),d}var Ht=class extends Error{constructor(){super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`)}},Ut=class extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name=`ZodEncodeError`}};(Rt=globalThis).__zod_globalConfig??(Rt.__zod_globalConfig={});var Wt=globalThis.__zod_globalConfig;function Gt(e){return e&&Object.assign(Wt,e),Wt}function Kt(){let e=this._zod;return e.message??=JSON.stringify(e.def,Ne,2),e.message}function qt(e){this._zod.message=e}var Jt={get:Kt,set:qt,enumerable:!0,configurable:!0},N={value:void 0,enumerable:!1},Yt=new WeakSet([Object.prototype,Error.prototype]),Xt=(e,t)=>{e.name=`$ZodError`,N.value=t,Object.defineProperty(e,"issues",N),N.value=void 0,Object.defineProperty(e,"message",Jt);let n=Object.getPrototypeOf(e);Yt.has(n)||(Yt.add(n),Object.defineProperty(n,"toString",{configurable:!0,enumerable:!1,get(){let e=()=>this.message;return Object.defineProperty(this,"toString",{value:e,configurable:!0,writable:!0}),e},set(e){Object.defineProperty(this,"toString",{value:e,configurable:!0,writable:!0})}}))},Zt=M(`$ZodError`,Xt);M(`$ZodError`,Xt,void 0,{Parent:Error});function Qt(e,t,n){return Object.prototype.hasOwnProperty.call(e,t)||(t===`__proto__`?Object.defineProperty(e,t,{value:n(),writable:!0,enumerable:!0,configurable:!0}):e[t]=n()),e[t]}function $t(e,t=e=>e.message){let n={},r=[];for(let i of e.issues)i.path.length>0?Qt(n,i.path[0],()=>[]).push(t(i)):r.push(t(i));return{formErrors:r,fieldErrors:n}}function en(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],o=i===e.length-1;if(n===`_errors`){o&&r._errors.push(t(a)),i++;continue}Object.prototype.hasOwnProperty.call(r,n)||Object.defineProperty(r,n,{value:{_errors:[]},enumerable:!0,writable:!0,configurable:!0});let s=r[n];o&&s._errors.push(t(a)),r=s,i++}}}};return r(e),n}function tn(e,t){return{callee:t?.callee??e,Err:t?.Err}}var nn=e=>{let t=(n,r,i,a)=>{let o=i?{...i,async:!1}:{async:!1},s=n._zod.run({value:r,issues:[]},o);if(s instanceof Promise)throw new Ht;if(s.issues.length){let n=new((a?.Err)??e)(s.issues.map(e=>xt(e,o,Gt())));throw Ye(n,a?.callee??t),n}return s.value};return t},rn=e=>{let t=async(n,r,i,a)=>{let o=i?{...i,async:!0}:{async:!0},s=n._zod.run({value:r,issues:[]},o);if(s instanceof Promise&&(s=await s),s.issues.length){let n=new((a?.Err)??e)(s.issues.map(e=>xt(e,o,Gt())));throw Ye(n,a?.callee??t),n}return s.value};return t},an=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 Ht;return a.issues.length?on(e,a.issues,i):{success:!0,data:a.value}};function on(e,t,n){let r;return{success:!1,get error(){return r||(r=new e(t.map(e=>xt(e,n,Gt()))),t=void 0,n=void 0),r},set error(e){r=e,t=void 0,n=void 0}}}var sn=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?on(e,a.issues,i):{success:!0,data:a.value}},cn=Symbol.for(`zod.compile.invalid`),ln=Symbol.for(`zod.compile.fallback`),un=((e,t,n)=>{let r=e._zod.bag.validator;if(r!==void 0){if(r(t)!==cn)return!0;if(r.definite===!0&&n===void 0)return!1}return dn(e,t,n)});function dn(e,t,n){let r=n?{...n,async:!1,abortEarly:!0}:{async:!1,abortEarly:!0},i=e._zod.bag.fallbackRun,a;if(i?(r[ln]=!0,a=i({value:t,issues:[]},r)):a=e._zod.run({value:t,issues:[]},r),a instanceof Promise)throw new Ht;return a.issues.length===0}var fn=async(e,t,n)=>{let r=n?{...n,async:!0,abortEarly:!0}:{async:!0,abortEarly:!0},i=e._zod.run({value:t,issues:[]},r);return i instanceof Promise&&(i=await i),i.issues.length===0},pn=e=>{let t=nn(e),n=(e,r,i,a)=>{let o=i?{...i,direction:`backward`}:{direction:`backward`};return t(e,r,o,tn(n,a))};return n},mn=e=>{let t=nn(e),n=(e,r,i,a)=>t(e,r,i,tn(n,a));return n},hn=e=>{let t=rn(e),n=async(e,r,i,a)=>{let o=i?{...i,direction:`backward`}:{direction:`backward`};return await t(e,r,o,tn(n,a))};return n},gn=e=>{let t=rn(e),n=async(e,r,i,a)=>await t(e,r,i,tn(n,a));return n},_n=e=>(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return an(e)(t,n,i)},vn=e=>(t,n,r)=>an(e)(t,n,r),yn=e=>async(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return sn(e)(t,n,i)},bn=e=>async(t,n,r)=>sn(e)(t,n,r),xn=/^[cC][0-9a-z]{6,}$/,Sn=/^[0-9a-z]+$/,Cn=/^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$/,wn=/^[0-9a-vA-V]{20}$/,Tn=/^[A-Za-z0-9]{27}$/,En=/^[a-zA-Z0-9_-]{21}$/;function Dn(e){return RegExp(`^[a-zA-Z0-9_-]{${e}}$`)}var On=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,kn=/^([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})$/,An=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)$/,jn=/^(?:[A-Za-z0-9_'+\-]+\.)*[A-Za-z0-9_'+\-]*[A-Za-z0-9_+-]@(?:[A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,Mn=`^(?=[\\s\\S]*[\\p{Extended_Pictographic}\\p{Regional_Indicator}\\u20E3])[\\p{Extended_Pictographic}\\p{Emoji_Component}]+$`;function Nn(){return new RegExp(Mn,`u`)}var Pn=/^(?:(?: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])$/,Fn=/^(([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}|:))$/,In=/^((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])$/,Ln=/^(([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}|:))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,Rn=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,zn=/^(?:[A-Za-z0-9_-]{4})*(?:[A-Za-z0-9_-]{2,3})?$/,Bn=/^https?$/,Vn=/^\+[1-9]\d{6,14}$/,Hn=`(?:(?:\\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])))`;function Un(e){return RegExp(`^${e}$`)}var Wn=Un(Hn);function Gn(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}}`:e.seconds?`${t}:[0-5]\\d(?:\\.\\d+)?`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function Kn(e){return RegExp(`^${Gn(e)}$`)}function qn(e){let t=[`Z`];e.offset&&t.push(`([+-](?:[01]\\d|2[0-3]):[0-5]\\d)`);let n=`${Gn({precision:e.precision,seconds:!0})}(?:${t.join(`|`)})`,r=e.local?`${n}|${Gn({precision:e.precision})}`:n;return RegExp(`^${Hn}T(?:${r})$`)}var Jn=/^[\s\S]{0,}$/,Yn=/^-?\d+$/,Xn=/^-?\d+(?:\.\d+)?$/,Zn=/^(?:true|false)$/i,Qn=/^null$/i,$n=/^[^A-Z]*$/,er=/^[^a-z]*$/,tr=M(`$ZodCheck`,(e,t)=>{var n;e._zod??={},e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),nr=e=>{let t=e.value;return!Ie(t)&&t.length!==void 0},rr={number:`number`,bigint:`bigint`,object:`date`},ir=M(`$ZodCheckLessThan`,(e,t)=>{tr.init(e,t);let n=rr[typeof t.value];e._zod.check=r=>{(t.inclusive?r.value<=t.value:r.value<t.value)||r.issues.push({origin:rr[typeof r.value]??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})}}),ar=M(`$ZodCheckGreaterThan`,(e,t)=>{tr.init(e,t);let n=rr[typeof t.value];e._zod.check=r=>{(t.inclusive?r.value>=t.value:r.value>t.value)||r.issues.push({origin:rr[typeof r.value]??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})}}),or=M(`$ZodCheckMultipleOf`,(e,t)=>{tr.init(e,t),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`?t.value!==BigInt(0)&&n.value%t.value===BigInt(0):Re(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})}}),sr=M(`$ZodCheckNumberFormat`,(e,t)=>{tr.init(e,t),t.format=t.format||`float64`;let n=t.format?.includes(`int`),r=n?`int`:`number`,[i,a]=at[t.format];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})}}),cr=M(`$ZodCheckMaxLength`,(e,t)=>{var n;tr.init(e,t),(n=e._zod.def).when??(n.when=nr),e._zod.check=n=>{let r=n.value,i=r.length;if((typeof r==`string`&&i>t.maximum?Ct(r):i)<=t.maximum)return;let a=wt(r);n.issues.push({origin:a,code:`too_big`,maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),lr=M(`$ZodCheckMinLength`,(e,t)=>{var n;tr.init(e,t),(n=e._zod.def).when??(n.when=nr),e._zod.check=n=>{let r=n.value,i=r.length;if((typeof r==`string`&&i>=t.minimum&&i<t.minimum*2?Ct(r):i)>=t.minimum)return;let a=wt(r);n.issues.push({origin:a,code:`too_small`,minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),ur=M(`$ZodCheckLengthEquals`,(e,t)=>{var n;tr.init(e,t),(n=e._zod.def).when??(n.when=nr),e._zod.check=n=>{let r=n.value,i=r.length,a=typeof r==`string`&&i>=t.length&&i<=t.length*2?Ct(r):i;if(a===t.length)return;let o=wt(r),s=a>t.length;n.issues.push({origin:o,...s?{code:`too_big`,maximum:t.length}:{code:`too_small`,minimum:t.length},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}}),dr=M(`$ZodCheckStringFormat`,(e,t)=>{var n,r;tr.init(e,t),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=()=>{})}),fr=M(`$ZodCheckRegex`,(e,t)=>{dr.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})}}),pr=M(`$ZodCheckLowerCase`,(e,t)=>{t.pattern??=$n,dr.init(e,t)}),mr=M(`$ZodCheckUpperCase`,(e,t)=>{t.pattern??=er,dr.init(e,t)}),hr=M(`$ZodCheckIncludes`,(e,t)=>{tr.init(e,t);let n=tt(t.includes);t.pattern=new RegExp(typeof t.position==`number`?`^.{${t.position},}${n}`:n),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})}}),gr=M(`$ZodCheckStartsWith`,(e,t)=>{tr.init(e,t);let n=RegExp(`^${tt(t.prefix)}.*`);t.pattern??=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})}}),_r=M(`$ZodCheckEndsWith`,(e,t)=>{tr.init(e,t);let n=RegExp(`.*${tt(t.suffix)}$`);t.pattern??=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})}}),vr=M(`$ZodCheckOverwrite`,(e,t)=>{tr.init(e,t),e._zod.check=e=>{e.value=t.tx(e.value)}}),yr=class{constructor(e=[],t={}){this.content=[],this.indent=0,this.args=e,this.closed=t}indented(e){this.indent+=1;try{e(this)}finally{--this.indent}}write(e){if(typeof e==`function`){e(this,{execution:`sync`}),e(this,{execution:`async`});return}let t=e.split(`
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./capture-processor-BbngzdtV.js","./_module-url-BX0RuRU2.js","./playback-processor-zTrexiPF.js"])))=>i.map(i=>d[i]);
2
+ var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),s=(e,n)=>{let r={};for(var i in e)t(r,i,{get:e[i],enumerable:!0});return n||t(r,Symbol.toStringTag,{value:`Module`}),r},c=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},l=(n,r,o)=>(o=n==null?{}:e(i(n)),c(r||!n||!n.__esModule||!a.call(n,`default`)?t(o,`default`,{value:n,enumerable:!0}):o,n));(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),t.credentials=e.crossOrigin===`use-credentials`?`include`:e.crossOrigin===`anonymous`?`omit`:`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var u=.1,d=1500,f=.001,p=1e3,m=65e3,h=1048576,g=1e4,_=2e3,v=15e3,y=/^[A-Za-z0-9_-]{1,64}$/,b=16e3,x=1e5,ee=1e4,S=192e3;function C(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function w(e){let t={};for(let[n,r]of Object.entries(e))r!==void 0&&(t[n]=r);return t}function T(e){try{return JSON.parse(e)}catch{}}var te=200,E=`…`;function ne(e){return e.length<=te?e:`${e.slice(0,te)}${E}`}function re(e,t,n){let r=n===void 0?`${e}`:`${n} ${e}`;return t?`${r}: ${ne(t)}`:r}async function ie(e,t){let n=await e.text().catch(()=>``),r=T(n);if(r===void 0)throw Error(re(e.status,n,t));return r}var ae={brands:{clientTool:`@alexkroman1/aai.clientTool`,clientToolCall:`@alexkroman1/aai.clientTool.call`,routeResponse:`@alexkroman1/aai.routeResponse`,routeError:`@alexkroman1/aai.routeError`,stepError:`@alexkroman1/aai.stepError`,keylessSynthesizer:`@alexkroman1/aai.speechSynthesizer.keyless`},slots:{channelOutbox:`@alexkroman1/aai.channelOutbox`,clientEventFeed:`@alexkroman1/aai-runtime.clientEventFeed`,clientInboxDefaults:`@alexkroman1/aai.clientInboxDefaults`,clientTranscriptReader:`@alexkroman1/aai.clientTranscriptReader`,metricsSinks:`@alexkroman1/aai-runtime.metricsSinks`,runtimeInstances:`@alexkroman1/aai-runtime.instances`,sessionCalls:`@alexkroman1/aai.sessionCalls`,sessionClients:`@alexkroman1/aai.sessionClients`,sessionDtmfSenders:`@alexkroman1/aai.sessionDtmfSenders`,sessionEnders:`@alexkroman1/aai.sessionEnders`,sessionLocations:`@alexkroman1/aai.sessionLocations`,sessionPhones:`@alexkroman1/aai.sessionPhones`,speechSynthesizer:`@alexkroman1/aai.speechSynthesizer`,stepDelegate:`@alexkroman1/aai.stepDelegate`,stepEnv:`@alexkroman1/aai.stepEnv`,stepFetch:`@alexkroman1/aai.stepFetch`,stepInfoReader:`@alexkroman1/aai.stepInfoReader`,stepMcp:`@alexkroman1/aai.stepMcp`,stepNotifyClient:`@alexkroman1/aai.stepNotifyClient`,stepReporter:`@alexkroman1/aai.stepReporter`,stepWebhookUrl:`@alexkroman1/aai.stepWebhookUrl`,uploadReader:`@alexkroman1/aai.uploadReader`}};function oe(e){let t=Symbol.for(ae.slots[e]);return{get:()=>Reflect.get(globalThis,t),set:e=>{e===void 0?Reflect.deleteProperty(globalThis,t):Reflect.set(globalThis,t,e)}}}function se(e){return typeof e.get==`function`}function ce(e){let t=(se(e)?e:e.headers).get(`retry-after`)?.trim();if(!t)return;if(/^\d+$/.test(t)){let e=Number(t);return Number.isFinite(e)?new Date(Date.now()+e*1e3):void 0}let n=Date.parse(t);if(!Number.isNaN(n))return n>Date.now()?new Date(n):void 0}var le=4;function ue(e){return de(e,[],0)}function de(e,t,n){return e.map(e=>fe(e,t,n)).join(`; `)}function fe(e,t,n){let r=[...t,...e.path??[]],i=r.map(e=>String(C(e)?e.key:e)).join(`.`);if(n<le){let t=pe(e);if(t)return[...new Set(t.map(e=>de(e,r,n+1)))].join(` or `);let a=me(e);if(a){let t=de(a,[],n+1),r=t?`${e.message} — ${t}`:e.message;return i?`${i}: ${r}`:r}}return i?`${i}: ${e.message}`:e.message}function pe(e){if(!Array.isArray(e.errors))return;let t=e.errors,n=[];for(let e of t){if(!Array.isArray(e))continue;let t=e.filter(he);t.length>0&&n.push(t)}return n.length>0?n:void 0}function me(e){if(!Array.isArray(e.issues))return;let t=e.issues.filter(he);return t.length>0?t:void 0}function he(e){return C(e)&&typeof e.message==`string`}var ge=[`B`,`KB`,`MB`,`GB`,`TB`],_e=1024;function ve(e){let t=Number.isFinite(e)?Math.max(0,e):0,n=0;for(;t>=_e&&n<ge.length-1;)t/=_e,n+=1;let r=ye(t,n);return Number.parseFloat(r)>=_e&&n<ge.length-1&&(n+=1,r=ye(t/_e,n)),`${r} ${ge[n]}`}function ye(e,t){return t<=1?String(Math.round(e)):e.toFixed(1)}function be(e){return xe(e,new Set)??De(e)}var D=new Set([`fetch failed`,`failed to fetch`]),O=`Unknown error`;function xe(e,t){if(C(e)){if(t.has(e))return;t.add(e)}let n=ke(e);if(n!==void 0)return ue(n);let r=Ce(e,t);if(r!==void 0)return r;let i=Se(e);if(i!==void 0&&!D.has(i.toLowerCase()))return i;let a=Te(e,t);return a===void 0?i:i===void 0||a.includes(i)?a:`${i}: ${a}`}function Se(e){if(!C(e)||typeof e.message!=`string`)return;let t=e.message.trim();return t===``?void 0:t}function Ce(e,t){if(!C(e)||typeof e.statusCode!=`number`||!Number.isFinite(e.statusCode))return;let n=Ee(e.url),r=`HTTP ${e.statusCode}${n===void 0?``:` from ${n}`}`,i=Se(e)??we(e.responseBody)??we(e.data)??Te(e,t);return i===void 0?r:`${i} (${r})`}function we(e){if(typeof e==`string`){let t=e.trim();return t===``?void 0:we(T(t))??ne(t)}if(C(e))for(let t of[e.error,e.message,e.detail]){let e=typeof t==`string`?t.trim():Se(t)??``;if(e!==``)return e}}function Te(e,t){if(!C(e))return;if(e.cause!==void 0&&e.cause!==null){let n=xe(e.cause,t);if(n!==void 0)return n}if(!Array.isArray(e.errors))return;let n=e.errors.map(e=>xe(e,t)).filter(e=>e!==void 0);return n.length===0?void 0:n.join(`; `)}function Ee(e){if(typeof e==`string`&&e!==``)try{return new URL(e).host||void 0}catch{return}}function De(e){if(C(e)&&typeof e.name==`string`&&e.name.trim()!==``)return`${e.name.trim()} (no message)`;let t=Oe(e);return t===``||t===`[object Object]`?O:t}function Oe(e){try{return String(e).trim()}catch{return``}}function ke(e){if(!(C(e)&&Array.isArray(e.issues))||e.issues.length===0)return;let t=e.issues;return t.every(e=>C(e)&&typeof e.message==`string`)?t:void 0}async function Ae(e,t){let n=await e.text().catch(()=>``),r=T(n);if(C(r)){let{error:e}=r;if(typeof e==`string`&&e!==``)return e}return re(e.status,n,t)}function je(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 Me(e,t=`|`){return e.map(e=>rt(e)).join(t)}function Ne(e,t){return typeof t==`bigint`?t.toString():t}var Pe=class{constructor(e){this._getter=e,this._value=void 0}get value(){let e=this._getter;return e!==void 0&&(this._value=e(),this._getter=void 0),this._value}};function Fe(e){return new Pe(e)}function Ie(e){return e==null}function Le(e){let t=+!!e.startsWith(`^`),n=e.endsWith(`$`)?e.length-1:e.length;return e.slice(t,n)}function Re(e,t){let n=e/t,r=Math.round(n),i=4*2**-52*Math.max(Math.abs(n),1);return Math.abs(n-r)<i?0:n-r}function ze(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function Be(e){let t=Object.getOwnPropertyDescriptor(e,`shape`);return t?.get?t.get.raw:t?.value}function Ve(e){return Be(e._zod.def)??e._zod.def.shape}function He(e,t,n){Object.defineProperty(e,t,{get(){let e=n();return ze(this,t,e),e},enumerable:!0,configurable:!0})}function Ue(e,t,n){t in e?ze(e,t,n):e[t]=n}function We(e,t,n,r){let i=Ve(t);for(let a of n){let n=Object.getOwnPropertyDescriptor(i,a);n.enumerable&&(n.get?He(e,a,()=>{let e=t._zod.def.shape[a];return r?r(e,a):e}):Ue(e,a,r?r(n.value,a):n.value))}}function Ge(e,t){for(let n of Reflect.ownKeys(t)){let r=Object.getOwnPropertyDescriptor(t,n);r.enumerable&&(r.get?He(e,n,()=>t[n]):Ue(e,n,r.value))}}function Ke(...e){let t={};for(let n of e){let e=Object.getOwnPropertyDescriptors(n);Object.assign(t,e)}return Object.defineProperties({},t)}function qe(e){return JSON.stringify(e)}function Je(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,``).replace(/[\s_-]+/g,`-`).replace(/^-+|-+$/g,``)}var Ye=`captureStackTrace`in Error?Error.captureStackTrace:(...e)=>{};function Xe(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var Ze=Fe(()=>{if(Wt.jitless||typeof navigator<`u`&&navigator?.userAgent?.includes(`Cloudflare`))return!1;try{return Function(``),!0}catch{return!1}});function Qe(e){if(Xe(e)===!1)return!1;let t=e.constructor;if(t===void 0||typeof t!=`function`)return!0;let n=t.prototype;return Xe(n)!==!1&&Object.prototype.hasOwnProperty.call(n,`isPrototypeOf`)!==!1}function $e(e){return Qe(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}var et=new Set([`string`,`number`,`symbol`]);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 k(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!==void 0&&e[t]._zod.optout===`optional`)}var at={safeint:[-(2**53-1),2**53-1],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]},ot={int64:[BigInt(`-9223372036854775808`),BigInt(`9223372036854775807`)],uint64:[BigInt(0),BigInt(`18446744073709551615`)]};function st(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`);let i={};return We(i,e,ct(e,t)),nt(e,Ke(n,{shape:i,checks:[]}))}function ct(e,t){let n=Ve(e),r=[];for(let e of Reflect.ownKeys(t)){if(!Object.getOwnPropertyDescriptor(n,e)?.enumerable)throw Error(`Unrecognized key: "${String(e)}"`);t[e]&&r.push(e)}return r}function lt(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`);let i=new Set(ct(e,t)),a={};return We(a,e,Reflect.ownKeys(Ve(e)).filter(e=>!i.has(e))),nt(e,Ke(n,{shape:a,checks:[]}))}function ut(e,t){if(!Qe(t))throw Error(`Invalid input to extend: expected a plain object`);let n=e._zod.def.checks;if(n&&n.length>0){let n=Ve(e);for(let e of Reflect.ownKeys(t))if(Object.getOwnPropertyDescriptor(n,e)!==void 0)throw Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}return nt(e,Ke(e._zod.def,{shape:dt(e,t)}))}function dt(e,t){let n={};return We(n,e,Reflect.ownKeys(Ve(e))),Ge(n,t),n}function ft(e,t){if(!Qe(t))throw Error(`Invalid input to safeExtend: expected a plain object`);return nt(e,Ke(e._zod.def,{shape:dt(e,t)}))}function pt(e,t){if(!t?._zod?.def)throw Error("Invalid input to merge: expected an object schema. To merge a plain shape, use `.extend()`.");if(e._zod.def.checks?.length)throw Error(`.merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.`);let n={};return We(n,e,Reflect.ownKeys(Ve(e))),We(n,t,Reflect.ownKeys(Ve(t))),nt(e,Ke(e._zod.def,{shape:n,get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]}))}function mt(e,t,n,r=`partial`){let i=t._zod.def.checks;if(i&&i.length>0)throw Error(`.${r}() cannot be used on object schemas containing refinements`);let a=n?new Set(ct(t,n)):void 0,o={};return We(o,t,Reflect.ownKeys(Ve(t)),e&&((t,n)=>a&&!a.has(n)?t:new e({type:`optional`,innerType:t}))),nt(t,Ke(t._zod.def,{shape:o,checks:[]}))}function ht(e,t,n){let r=n?new Set(ct(t,n)):void 0,i={};return We(i,t,Reflect.ownKeys(Ve(t)),(t,n)=>r&&!r.has(n)?t:new e({type:`nonoptional`,innerType:t})),nt(t,Ke(t._zod.def,{shape:i}))}function gt(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 _t(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 vt(e,t){return t.map(t=>{var n;return(n=t).path??(n.path=[]),t.path.unshift(e),t})}function yt(e){return typeof e==`string`?e:e?.message}function bt(e,t,n){var r;for(let i=t;i<e.length;i++)(r=e[i]).schema??(r.schema=n)}function xt(e,t,n){var r;let i=e.inst?._zod?.traits;i?.has(`$ZodType`)&&(i.has(`$ZodCheck`)?(r=e).schema??(r.schema=e.inst):e.schema=e.inst);let a=e.schema===e.inst?void 0:e.schema?._zod.def?.error,o=e.message?e.message:yt(e.inst?._zod.def?.error?.(e))??yt(a?.(e))??yt(t?.error?.(e))??yt(n.customError?.(e))??yt(n.localeError?.(e))??`Invalid input`,s={};for(let t of Object.keys(e))t!==`inst`&&t!==`schema`&&t!==`continue`&&t!==`input`&&t!==`__proto__`&&(s[t]=e[t]);return s.path??=[],s.message=o,t?.reportInput&&(s.input=e.input),s}var St=/[\uD800-\uDBFF]/;function Ct(e){let t=e.length;if(!St.test(e))return t;let n=t;for(let r=0;r<t-1;r++)(e.charCodeAt(r)&64512)==55296&&(e.charCodeAt(r+1)&64512)==56320&&(n--,r++);return n}function wt(e){return Array.isArray(e)?`array`:typeof e==`string`?`string`:`unknown`}function Tt(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 Et(...e){let[t,n,r]=e;return typeof t==`string`?{message:t,code:`custom`,input:n,inst:r}:{...t}}function Dt(e,t){for(let n in t){let r=Object.getOwnPropertyDescriptor(t,n);r.get?Object.defineProperty(e,n,{...r,enumerable:!1}):At(e,n,r.value)}}function A(e,t,n,r=!0){return Object.defineProperty(e,t,{configurable:!0,writable:!0,enumerable:r,value:n}),n}function Ot(e,t,n){return A(e,t,n,!1)}function kt(e,t){for(let n in e){let r=e[n];Object.defineProperty(t,n,{configurable:!0,enumerable:!0,get(){return A(this,n,r(this))},set(e){A(this,n,e)}})}return t}function At(e,t,n){Object.defineProperty(e,t,{configurable:!0,get(){return this==null?n:A(this,t,n.bind(this))},set(e){A(this,t,e)}})}function jt(e,t){let n=Object.getPrototypeOf(e);return t in n?void 0:n}var Mt,Nt=!1,Pt={configurable:!0,get(){Nt=!0}};function j(e,t,n){let r=Object.getPrototypeOf(e._zod);if(t in r&&Mt!==e._zod){Mt=void 0;return}Mt=e._zod,Object.defineProperty(r,t,{configurable:!0,get(){Object.defineProperty(this,t,Pt);let e=Nt;Nt=!1;try{let r=n(this);return Nt?delete this[t]:Object.defineProperty(this,t,{configurable:!0,writable:!0,value:r}),Nt||=e,r}catch(n){throw delete this[t],Nt||=e,n}},set(e){Object.defineProperty(this,t,{configurable:!0,writable:!0,value:e})}})}function Ft(e,t,n,r){let i=jt(e,t);i&&Object.defineProperty(i,t,{configurable:!0,get(){let e={configurable:!0,writable:!0,enumerable:r,value:void 0};return Object.defineProperty(this,t,e),e.value=n(this),Object.defineProperty(this,t,e),e.value},set(e){Object.defineProperty(this,t,{configurable:!0,writable:!0,enumerable:r,value:e})}})}var It=`~constantCatch`;function Lt(e){let t=()=>e;return t[It]=!0,t}var Rt,zt={value:void 0,enumerable:!1},Bt=`captureStackTrace`in Error?Error:null;function Vt(e){let t=Bt;if(t){let n=t.stackTraceLimit;if(typeof n==`number`){try{t.stackTraceLimit=0}catch{return Bt=null,new e}try{return new e}finally{t.stackTraceLimit=n}}}return new e}function M(e,t,n,r){let i={};function a(e){this.def=e,this.constr=d,this.traits=new Set}a.prototype=i;let o=n,s=o&&new WeakSet;function c(n,r){if(!n._zod){zt.value=new a(r);try{Object.defineProperty(n,"_zod",zt)}finally{zt.value=void 0}}else if(n._zod.traits.has(e))return;if(n._zod.traits.add(e),t(n,r),s){let e=Object.getPrototypeOf(n),t=n._zod.constr.prototype,r=e;for(;r&&r!==t;)r=Object.getPrototypeOf(r);let i=r??e;s.has(i)||(s.add(i),Dt(i,o))}let i=d.prototype;for(let e in i)Object.prototype.hasOwnProperty.call(i,e)&&(e in n||(n[e]=i[e].bind(n)))}let l=r?.Parent??Object;class u extends l{}Object.defineProperty(u,"name",{value:e});function d(e){let t=r?.Parent?Vt(u):this;c(t,e);let n=t._zod.deferred;if(n){for(let e of n)e();t._zod.deferred=void 0}let i=globalThis.__zod_globalConfig?.postProcessor;return i&&i(t),t}return Object.defineProperty(d,"init",{value:c}),Object.defineProperty(d,Symbol.hasInstance,{value:t=>r?.Parent&&t instanceof r.Parent?!0:t?._zod?.traits?.has(e)}),Object.defineProperty(d,"name",{value:e}),d}var Ht=class extends Error{constructor(){super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`)}},Ut=class extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name=`ZodEncodeError`}};(Rt=globalThis).__zod_globalConfig??(Rt.__zod_globalConfig={});var Wt=globalThis.__zod_globalConfig;function Gt(e){return e&&Object.assign(Wt,e),Wt}function Kt(){let e=this._zod;return e.message??=JSON.stringify(e.def,Ne,2),e.message}function qt(e){this._zod.message=e}var Jt={get:Kt,set:qt,enumerable:!0,configurable:!0},N={value:void 0,enumerable:!1},Yt=new WeakSet([Object.prototype,Error.prototype]),Xt=(e,t)=>{e.name=`$ZodError`,N.value=t,Object.defineProperty(e,"issues",N),N.value=void 0,Object.defineProperty(e,"message",Jt);let n=Object.getPrototypeOf(e);Yt.has(n)||(Yt.add(n),Object.defineProperty(n,"toString",{configurable:!0,enumerable:!1,get(){let e=()=>this.message;return Object.defineProperty(this,"toString",{value:e,configurable:!0,writable:!0}),e},set(e){Object.defineProperty(this,"toString",{value:e,configurable:!0,writable:!0})}}))},Zt=M(`$ZodError`,Xt);M(`$ZodError`,Xt,void 0,{Parent:Error});function Qt(e,t,n){return Object.prototype.hasOwnProperty.call(e,t)||(t===`__proto__`?Object.defineProperty(e,t,{value:n(),writable:!0,enumerable:!0,configurable:!0}):e[t]=n()),e[t]}function $t(e,t=e=>e.message){let n={},r=[];for(let i of e.issues)i.path.length>0?Qt(n,i.path[0],()=>[]).push(t(i)):r.push(t(i));return{formErrors:r,fieldErrors:n}}function en(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],o=i===e.length-1;if(n===`_errors`){o&&r._errors.push(t(a)),i++;continue}Object.prototype.hasOwnProperty.call(r,n)||Object.defineProperty(r,n,{value:{_errors:[]},enumerable:!0,writable:!0,configurable:!0});let s=r[n];o&&s._errors.push(t(a)),r=s,i++}}}};return r(e),n}function tn(e,t){return{callee:t?.callee??e,Err:t?.Err}}var nn=e=>{let t=(n,r,i,a)=>{let o=i?{...i,async:!1}:{async:!1},s=n._zod.run({value:r,issues:[]},o);if(s instanceof Promise)throw new Ht;if(s.issues.length){let n=new((a?.Err)??e)(s.issues.map(e=>xt(e,o,Gt())));throw Ye(n,a?.callee??t),n}return s.value};return t},rn=e=>{let t=async(n,r,i,a)=>{let o=i?{...i,async:!0}:{async:!0},s=n._zod.run({value:r,issues:[]},o);if(s instanceof Promise&&(s=await s),s.issues.length){let n=new((a?.Err)??e)(s.issues.map(e=>xt(e,o,Gt())));throw Ye(n,a?.callee??t),n}return s.value};return t},an=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 Ht;return a.issues.length?on(e,a.issues,i):{success:!0,data:a.value}};function on(e,t,n){let r;return{success:!1,get error(){return r||(r=new e(t.map(e=>xt(e,n,Gt()))),t=void 0,n=void 0),r},set error(e){r=e,t=void 0,n=void 0}}}var sn=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?on(e,a.issues,i):{success:!0,data:a.value}},cn=Symbol.for(`zod.compile.invalid`),ln=Symbol.for(`zod.compile.fallback`),un=((e,t,n)=>{let r=e._zod.bag.validator;if(r!==void 0){if(r(t)!==cn)return!0;if(r.definite===!0&&n===void 0)return!1}return dn(e,t,n)});function dn(e,t,n){let r=n?{...n,async:!1,abortEarly:!0}:{async:!1,abortEarly:!0},i=e._zod.bag.fallbackRun,a;if(i?(r[ln]=!0,a=i({value:t,issues:[]},r)):a=e._zod.run({value:t,issues:[]},r),a instanceof Promise)throw new Ht;return a.issues.length===0}var fn=async(e,t,n)=>{let r=n?{...n,async:!0,abortEarly:!0}:{async:!0,abortEarly:!0},i=e._zod.run({value:t,issues:[]},r);return i instanceof Promise&&(i=await i),i.issues.length===0},pn=e=>{let t=nn(e),n=(e,r,i,a)=>{let o=i?{...i,direction:`backward`}:{direction:`backward`};return t(e,r,o,tn(n,a))};return n},mn=e=>{let t=nn(e),n=(e,r,i,a)=>t(e,r,i,tn(n,a));return n},hn=e=>{let t=rn(e),n=async(e,r,i,a)=>{let o=i?{...i,direction:`backward`}:{direction:`backward`};return await t(e,r,o,tn(n,a))};return n},gn=e=>{let t=rn(e),n=async(e,r,i,a)=>await t(e,r,i,tn(n,a));return n},_n=e=>(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return an(e)(t,n,i)},vn=e=>(t,n,r)=>an(e)(t,n,r),yn=e=>async(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return sn(e)(t,n,i)},bn=e=>async(t,n,r)=>sn(e)(t,n,r),xn=/^[cC][0-9a-z]{6,}$/,Sn=/^[0-9a-z]+$/,Cn=/^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$/,wn=/^[0-9a-vA-V]{20}$/,Tn=/^[A-Za-z0-9]{27}$/,En=/^[a-zA-Z0-9_-]{21}$/;function Dn(e){return RegExp(`^[a-zA-Z0-9_-]{${e}}$`)}var On=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,kn=/^([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})$/,An=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)$/,jn=/^(?:[A-Za-z0-9_'+\-]+\.)*[A-Za-z0-9_'+\-]*[A-Za-z0-9_+-]@(?:[A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,Mn=`^(?=[\\s\\S]*[\\p{Extended_Pictographic}\\p{Regional_Indicator}\\u20E3])[\\p{Extended_Pictographic}\\p{Emoji_Component}]+$`;function Nn(){return new RegExp(Mn,`u`)}var Pn=/^(?:(?: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])$/,Fn=/^(([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}|:))$/,In=/^((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])$/,Ln=/^(([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}|:))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,Rn=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,zn=/^(?:[A-Za-z0-9_-]{4})*(?:[A-Za-z0-9_-]{2,3})?$/,Bn=/^https?$/,Vn=/^\+[1-9]\d{6,14}$/,Hn=`(?:(?:\\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])))`;function Un(e){return RegExp(`^${e}$`)}var Wn=Un(Hn);function Gn(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}}`:e.seconds?`${t}:[0-5]\\d(?:\\.\\d+)?`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function Kn(e){return RegExp(`^${Gn(e)}$`)}function qn(e){let t=[`Z`];e.offset&&t.push(`([+-](?:[01]\\d|2[0-3]):[0-5]\\d)`);let n=`${Gn({precision:e.precision,seconds:!0})}(?:${t.join(`|`)})`,r=e.local?`${n}|${Gn({precision:e.precision})}`:n;return RegExp(`^${Hn}T(?:${r})$`)}var Jn=/^[\s\S]{0,}$/,Yn=/^-?\d+$/,Xn=/^-?\d+(?:\.\d+)?$/,Zn=/^(?:true|false)$/i,Qn=/^null$/i,$n=/^[^A-Z]*$/,er=/^[^a-z]*$/,tr=M(`$ZodCheck`,(e,t)=>{var n;e._zod??={},e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),nr=e=>{let t=e.value;return!Ie(t)&&t.length!==void 0},rr={number:`number`,bigint:`bigint`,object:`date`},ir=M(`$ZodCheckLessThan`,(e,t)=>{tr.init(e,t);let n=rr[typeof t.value];e._zod.check=r=>{(t.inclusive?r.value<=t.value:r.value<t.value)||r.issues.push({origin:rr[typeof r.value]??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})}}),ar=M(`$ZodCheckGreaterThan`,(e,t)=>{tr.init(e,t);let n=rr[typeof t.value];e._zod.check=r=>{(t.inclusive?r.value>=t.value:r.value>t.value)||r.issues.push({origin:rr[typeof r.value]??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})}}),or=M(`$ZodCheckMultipleOf`,(e,t)=>{tr.init(e,t),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`?t.value!==BigInt(0)&&n.value%t.value===BigInt(0):Re(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})}}),sr=M(`$ZodCheckNumberFormat`,(e,t)=>{tr.init(e,t),t.format=t.format||`float64`;let n=t.format?.includes(`int`),r=n?`int`:`number`,[i,a]=at[t.format];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})}}),cr=M(`$ZodCheckMaxLength`,(e,t)=>{var n;tr.init(e,t),(n=e._zod.def).when??(n.when=nr),e._zod.check=n=>{let r=n.value,i=r.length;if((typeof r==`string`&&i>t.maximum?Ct(r):i)<=t.maximum)return;let a=wt(r);n.issues.push({origin:a,code:`too_big`,maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),lr=M(`$ZodCheckMinLength`,(e,t)=>{var n;tr.init(e,t),(n=e._zod.def).when??(n.when=nr),e._zod.check=n=>{let r=n.value,i=r.length;if((typeof r==`string`&&i>=t.minimum&&i<t.minimum*2?Ct(r):i)>=t.minimum)return;let a=wt(r);n.issues.push({origin:a,code:`too_small`,minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),ur=M(`$ZodCheckLengthEquals`,(e,t)=>{var n;tr.init(e,t),(n=e._zod.def).when??(n.when=nr),e._zod.check=n=>{let r=n.value,i=r.length,a=typeof r==`string`&&i>=t.length&&i<=t.length*2?Ct(r):i;if(a===t.length)return;let o=wt(r),s=a>t.length;n.issues.push({origin:o,...s?{code:`too_big`,maximum:t.length}:{code:`too_small`,minimum:t.length},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}}),dr=M(`$ZodCheckStringFormat`,(e,t)=>{var n,r;tr.init(e,t),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=()=>{})}),fr=M(`$ZodCheckRegex`,(e,t)=>{dr.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})}}),pr=M(`$ZodCheckLowerCase`,(e,t)=>{t.pattern??=$n,dr.init(e,t)}),mr=M(`$ZodCheckUpperCase`,(e,t)=>{t.pattern??=er,dr.init(e,t)}),hr=M(`$ZodCheckIncludes`,(e,t)=>{tr.init(e,t);let n=tt(t.includes);t.pattern=new RegExp(typeof t.position==`number`?`^.{${t.position},}${n}`:n),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})}}),gr=M(`$ZodCheckStartsWith`,(e,t)=>{tr.init(e,t);let n=RegExp(`^${tt(t.prefix)}.*`);t.pattern??=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})}}),_r=M(`$ZodCheckEndsWith`,(e,t)=>{tr.init(e,t);let n=RegExp(`.*${tt(t.suffix)}$`);t.pattern??=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})}}),vr=M(`$ZodCheckOverwrite`,(e,t)=>{tr.init(e,t),e._zod.check=e=>{e.value=t.tx(e.value)}}),yr=class{constructor(e=[],t={}){this.content=[],this.indent=0,this.args=e,this.closed=t}indented(e){this.indent+=1;try{e(this)}finally{--this.indent}}write(e){if(typeof e==`function`){e(this,{execution:`sync`}),e(this,{execution:`async`});return}let t=e.split(`
3
3
  `).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?.content??[``];return new e(...Object.keys(this.closed),`return function (${this.args.join(`, `)}) {\n${t.join(`
4
4
  `)}\n};`)(...Object.values(this.closed))}},br={major:4,minor:6,patch:5},xr=M(`$ZodType`,(e,t)=>{var n;e??={},e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=br;let r=e._zod.def.checks,i=e._zod.traits.has(`$ZodCheck`)?[e,...r??[]]:r?.length?[...r]:[];for(let t of i)for(let n of t._zod.onattach)n(e);if(i.length===0)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let t=(t,n,r)=>{if(t.memo)return t;let i=gt(t),a;for(let o of n){if(o._zod.def.when){if(_t(t)||!o._zod.def.when(t))continue}else if(i)continue;let n=t.issues.length,s=o._zod.check(t);if(s instanceof Promise&&r?.async===!1)throw new Ht;if(a||s instanceof Promise)a=(a??Promise.resolve()).then(async()=>{await s,t.issues.length!==n&&(bt(t.issues,n,e),i||=gt(t,n))});else{if(t.issues.length===n)continue;bt(t.issues,n,e),i||=gt(t,n)}}return a?a.then(()=>t):t},n=(n,r,a)=>{if(gt(n))return n.aborted=!0,n;let o=t(r,i,a);if(o instanceof Promise){if(a.async===!1)throw new Ht;return o.then(t=>e._zod.parse(t,a))}return e._zod.parse(o,a)};e._zod.run=(r,a)=>{if(a.skipChecks)return e._zod.parse(r,a);if(a.direction===`backward`){let t=e._zod.parse({value:r.value,issues:[]},{...a,skipChecks:!0});return t instanceof Promise?t.then(e=>n(e,r,a)):n(t,r,a)}let o=e._zod.parse(r,a);if(o instanceof Promise){if(a.async===!1)throw new Ht;return o.then(e=>t(e,i,a))}return t(o,i,a)}}},{get"~standard"(){return Ot(this,`~standard`,wr(this))},set"~standard"(e){A(this,`~standard`,e)}}),Sr=(e,t)=>e.issues.length?{issues:e.issues.map(e=>xt(e,t,Gt()))}:{value:e.value};async function Cr(e,t){let n={async:!0};return Sr(await e._zod.run({value:t,issues:[]},n),n)}function wr(e){return{validate:t=>{let n={async:!1};try{let r=e._zod.run({value:t,issues:[]},n);if(!(r instanceof Promise))return Sr(r,n)}catch{}return Cr(e,t)},vendor:`zod`,version:1}}var Tr=M(`$ZodString`,(e,t)=>{xr.init(e,t),e._zod.pattern=t.pattern??Jn,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}}),Er=M(`$ZodStringFormat`,(e,t)=>{dr.init(e,t),Tr.init(e,t)}),Dr=M(`$ZodGUID`,(e,t)=>{t.pattern??=kn,Er.init(e,t)}),Or=M(`$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??=An(e)}else t.pattern??=An();Er.init(e,t)}),kr=M(`$ZodEmail`,(e,t)=>{t.pattern??=jn,Er.init(e,t)});function Ar(e){try{return typeof URL<`u`&&typeof URL.canParse==`function`?URL.canParse(e):(new URL(e),!0)}catch{return!1}}function jr(e,t){return!(`normalize`in t)&&!(`hostname`in t)&&!(`protocol`in t)?Ar(e)||2:Mr(e,t)}function Mr(e,t){if(!t.normalize&&t.protocol?.source===Bn.source&&!/^https?:\/\//i.test(e))return 1;try{if(typeof URL<`u`){let t=URL;if(typeof t.parse==`function`)return t.parse(e)??2}return new URL(e)}catch{return 2}}var Nr=/[\t\n\r]/g;function Pr(e){return e.replace(Nr,``)}function Fr(e,t){return t.lastIndex=0,t.test(e.hostname)}function Ir(e,t){return t.lastIndex=0,t.test(e.protocol.endsWith(`:`)?e.protocol.slice(0,-1):e.protocol)}var Lr=M(`$ZodURL`,(e,t)=>{Er.init(e,t),e._zod.check=n=>{try{let r=n.value.trim(),i=jr(r,t);if(i===1){n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid URL format`,input:n.value,inst:e,continue:!t.abort});return}if(i===2){n.issues.push({code:`invalid_format`,format:`url`,input:n.value,inst:e,continue:!t.abort});return}if(i===!0){n.value=Pr(r);return}t.hostname&&!Fr(i,t.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&&!Ir(i,t.protocol)&&n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid protocol`,pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort}),n.value=t.normalize?i.href:Pr(r);return}catch{n.issues.push({code:`invalid_format`,format:`url`,input:n.value,inst:e,continue:!t.abort})}}}),Rr=M(`$ZodEmoji`,(e,t)=>{t.pattern??=Nn(),Er.init(e,t)}),zr=M(`$ZodNanoID`,(e,t)=>{if(t.length!==void 0&&(!Number.isInteger(t.length)||t.length<1))throw Error(`Invalid nanoid length: ${t.length}`);t.pattern??=t.length===void 0?En:Dn(t.length),Er.init(e,t)}),Br=M(`$ZodCUID`,(e,t)=>{t.pattern??=xn,Er.init(e,t)}),Vr=M(`$ZodCUID2`,(e,t)=>{t.pattern??=Sn,Er.init(e,t)}),Hr=M(`$ZodULID`,(e,t)=>{t.pattern??=Cn,Er.init(e,t)}),Ur=M(`$ZodXID`,(e,t)=>{t.pattern??=wn,Er.init(e,t)}),Wr=M(`$ZodKSUID`,(e,t)=>{t.pattern??=Tn,Er.init(e,t)}),Gr=M(`$ZodISODateTime`,(e,t)=>{t.pattern??=qn(t),Er.init(e,t)}),Kr=M(`$ZodISODate`,(e,t)=>{t.pattern??=Wn,Er.init(e,t)}),qr=M(`$ZodISOTime`,(e,t)=>{t.pattern??=Kn(t),Er.init(e,t)}),Jr=M(`$ZodISODuration`,(e,t)=>{t.pattern??=On,Er.init(e,t)}),Yr=M(`$ZodIPv4`,(e,t)=>{t.pattern??=Pn,Er.init(e,t)}),Xr=/^[0-9a-fA-F:.]+$/;function Zr(e){return Xr.test(e)?Ar(`http://[${e}]`):!1}var Qr=M(`$ZodIPv6`,(e,t)=>{t.pattern??=Fn,Er.init(e,t),e._zod.check=n=>{Zr(n.value)||n.issues.push({code:`invalid_format`,format:`ipv6`,input:n.value,inst:e,continue:!t.abort})}}),$r=M(`$ZodCIDRv4`,(e,t)=>{t.pattern??=In,Er.init(e,t)});function ei(e){let t=e.split(`/`);if(t.length!==2)return!1;let[n,r]=t;if(!r)return!1;let i=Number(r);return`${i}`!==r||i<0||i>128?!1:Zr(n)}var ti=M(`$ZodCIDRv6`,(e,t)=>{t.pattern??=Ln,Er.init(e,t),e._zod.check=n=>{ei(n.value)||n.issues.push({code:`invalid_format`,format:`cidrv6`,input:n.value,inst:e,continue:!t.abort})}});function ni(e){if(e===``)return!0;if(/\s/.test(e)||e.length%4!=0)return!1;try{return atob(e),!0}catch{return!1}}var ri=/^[0-9a-zA-Z+/]*={0,2}$/,ii=M(`$ZodBase64`,(e,t)=>{t.pattern??=ri,Er.init(e,t),e._zod.check=n=>{ni(n.value)||n.issues.push({code:`invalid_format`,format:`base64`,input:n.value,inst:e,continue:!t.abort})}}),ai=/^[A-Za-z0-9_-]*$/;function oi(e){if(!ai.test(e))return!1;let t=e.replace(/[-_]/g,e=>e===`-`?`+`:`/`);return ni(t.padEnd(Math.ceil(t.length/4)*4,`=`))}var si=M(`$ZodBase64URL`,(e,t)=>{t.pattern??=ai,Er.init(e,t),e._zod.check=n=>{oi(n.value)||n.issues.push({code:`invalid_format`,format:`base64url`,input:n.value,inst:e,continue:!t.abort})}}),ci=M(`$ZodE164`,(e,t)=>{t.pattern??=Vn,Er.init(e,t)});function li(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}}var ui=M(`$ZodJWT`,(e,t)=>{Er.init(e,t),e._zod.check=n=>{li(n.value,t.alg)||n.issues.push({code:`invalid_format`,format:`jwt`,input:n.value,inst:e,continue:!t.abort})}}),di=M(`$ZodNumber`,(e,t)=>{xr.init(e,t),e._zod.pattern=Xn,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:String(i):void 0;return n.issues.push({expected:`number`,code:`invalid_type`,input:i,inst:e,...a?{received:a}:{}}),n}}),fi=M(`$ZodNumberFormat`,(e,t)=>{sr.init(e,t),di.init(e,t)}),pi=M(`$ZodBoolean`,(e,t)=>{xr.init(e,t),e._zod.pattern=Zn,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}}),mi=M(`$ZodNull`,(e,t)=>{xr.init(e,t),e._zod.pattern=Qn,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}}),hi=M(`$ZodUnknown`,(e,t)=>{xr.init(e,t),e._zod.parse=e=>e}),gi=M(`$ZodNever`,(e,t)=>{xr.init(e,t),e._zod.parse=(t,n)=>(t.issues.push({expected:`never`,code:`invalid_type`,input:t.value,inst:e}),t)});function _i(e,t,n){e.issues.length&&t.issues.push(...vt(n,e.issues)),t.value[n]=e.value}var vi=M(`$ZodArray`,(e,t)=>{xr.init(e,t);let n=Wt.memoizer;n?.attach(e),e._zod.parse=(r,i)=>{let a=r.value;if(!Array.isArray(a))return r.issues.push({expected:`array`,code:`invalid_type`,input:a,inst:e}),r;r.value=n?n.alloc(e,r,Array(a.length),i):Array(a.length);let o=[],s=i?.abortEarly;for(let e=0;e<a.length;e++){let n=a[e],c=t.element._zod.run({value:n,issues:[]},i);if(c instanceof Promise)o.push(c.then(t=>_i(t,r,e)));else if(_i(c,r,e),s&&c.issues.length!==0&&gt(c))break}return o.length?Promise.all(o).then(()=>r):r}});function yi(e,t,n,r,i,a){let o=n in r,s=a===`optional`;if(o||!s||i!==`optional`){if(e.issues.length){if(i!==void 0&&s&&!o)return;t.issues.push(...vt(n,e.issues))}if(!o&&i===void 0){e.issues.length||t.issues.push({code:`invalid_type`,expected:`nonoptional`,input:void 0,path:[n]});return}e.value===void 0?(o||i===`defaulted`&&!s)&&(t.value[n]=void 0):t.value[n]=e.value}}var bi=[];function xi(e){let t=Object.keys(e.shape),n=Object.getOwnPropertySymbols(e.shape),r=n.length?n:bi,i=r.length?[...t,...r]:t;for(let t of i)if(!e.shape?.[t]?._zod?.traits?.has(`$ZodType`))throw Error(`Invalid element at key "${String(t)}": expected a Zod schema`);let a=it(e.shape);return{...e,allKeys:i,symbolKeys:r,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(a)}}function Si(e,t,n,r,i,a,o){let s=[],c=i.keySet,l=i.catchall._zod,u=l.def.type,d=l.optin,f=l.optout,p=0;for(let i in t){if(o&&n.issues.length!==p){if(gt(n,p))break;p=n.issues.length}if(c.has(i))continue;if(i===`__proto__`){u===`never`&&s.push(i);continue}if(u===`never`){s.push(i);continue}let a=l.run({value:t[i],issues:[]},r);a instanceof Promise?e.push(a.then(e=>yi(e,n,i,t,d,f))):yi(a,n,i,t,d,f)}return s.length&&n.issues.push({code:`unrecognized_keys`,keys:s,input:t,inst:a,continue:!0}),e.length?Promise.all(e).then(()=>n):n}var Ci=M(`$ZodObject`,(e,t)=>{xr.init(e,t);let n=Object.getOwnPropertyDescriptor(t,`shape`),r=n?.get?n.get.raw:t.shape??{};if(r){let e=()=>{let n={...r};return Object.defineProperty(t,"shape",{value:n}),e.raw=n,n};e.raw=r,Object.defineProperty(t,"shape",{get:e})}let i=Fe(()=>xi(t));j(e,`propValues`,e=>{let t=e.def.shape,n={};for(let e in t){let r=t[e]._zod;if(r.values){Object.prototype.hasOwnProperty.call(n,e)||ze(n,e,new Set);for(let t of r.values)n[e].add(t);r.optin!==void 0&&n[e].add(void 0)}}return n});let a=Xe,o=t.catchall,s,c=Wt.memoizer;c?.attach(e),e._zod.parse=(t,n)=>{s??=i.value;let r=t.value;if(!a(r))return t.issues.push({expected:`object`,code:`invalid_type`,input:r,inst:e}),t;t.value=c?c.alloc(e,t,{},n):{};let l=[],u=s.shape,d=n?.abortEarly,f=t.issues.length;for(let e of s.allKeys){if(d&&t.issues.length!==f){if(gt(t,f))break;f=t.issues.length}if(e===`__proto__`)continue;let i=u[e],a=i._zod.optin,o=i._zod.optout,s=i._zod.run({value:r[e],issues:[]},n);s instanceof Promise?l.push(s.then(n=>yi(n,t,e,r,a,o))):yi(s,t,e,r,a,o)}return o?Si(l,r,t,n,i.value,e,d===!0):l.length?Promise.all(l).then(()=>t):t}}),wi=M(`$ZodObjectJIT`,(e,t)=>{Ci.init(e,t);let n=e._zod.parse,r=Fe(()=>xi(t)),i=Wt.memoizer,a=t=>{let n=r.value,a=n.symbolKeys,o=new yr([`payload`,`ctx`],{shape:t,inst:e,memo:i,syms:a}),s=e=>`shape[${e}]._zod.run({ value: input[${e}], issues: [] }, ctx)`,c=(e,t)=>`
5
5
  let ${e}_ab = false;
@@ -53,7 +53,7 @@ var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=
53
53
 
54
54
  `)}return o.write(`payload.value = newResult;`),o.write(`return payload;`),o.compile()},o,s=Xe,c=!Wt.jitless,l=c&&Ze.value,u=t.catchall,d;e._zod.parse=(i,f)=>{d??=r.value;let p=i.value;return s(p)?c&&l&&f?.async===!1&&f.jitless!==!0?(o||=a(t.shape),i=o(i,f),u?Si([],p,i,f,d,e,f?.abortEarly===!0):i):n(i,f):(i.issues.push({expected:`object`,code:`invalid_type`,input:p,inst:e}),i)}});function Ti(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=>!gt(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=>xt(e,r,Gt())))}),t)}var Ei=M(`$ZodUnion`,(e,t)=>{xr.init(e,t),j(e,`optin`,e=>e.def.options.some(e=>e._zod.optin===`defaulted`)?`defaulted`:e.def.options.some(e=>e._zod.optin!==void 0)?`optional`:void 0),j(e,`optout`,e=>e.def.options.some(e=>e._zod.optout===`optional`)?`optional`:void 0),j(e,`values`,e=>{if(e.def.options.every(e=>e._zod.values))return new Set(e.def.options.flatMap(e=>Array.from(e._zod.values)))}),j(e,`pattern`,e=>{if(e.def.options.every(e=>e._zod.pattern)){let t=e.def.options.map(e=>e._zod.pattern);return RegExp(`^(${t.map(e=>Le(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=>Ti(t,r,e,i)):Ti(o,r,e,i)}});function Di(e){let t=new Map;for(let n of e.options){let r=n._zod.propValues?.[e.discriminator];if(!r||r.size===0)throw Error(`Invalid discriminated union option at index "${e.options.indexOf(n)}"`);for(let e of r)if(t.has(e)){if(e!==void 0)throw Error(`Duplicate discriminator value "${String(e)}"`);t.set(e,null)}else t.set(e,n)}return t}var Oi=M(`$ZodDiscriminatedUnion`,(e,t)=>{t.inclusive=!1,Ei.init(e,t);let n=e._zod.parse;j(e,`propValues`,e=>{let t={},n=0;for(let r of e.def.options){let i=r._zod.propValues;if(!i||Object.keys(i).length===0)throw Error(`Invalid discriminated union option at index "${e.def.options.indexOf(r)}"`);i[e.def.discriminator]?.has(void 0)&&n++;for(let[e,n]of Object.entries(i)){Object.prototype.hasOwnProperty.call(t,e)||ze(t,e,new Set);for(let r of n)t[e].add(r)}}return!e.def.unionFallback&&n>1&&t[e.def.discriminator]?.delete(void 0),t}),t.options.forEach((e,n)=>{let r=Be(e._zod.def);if(r&&!Object.prototype.hasOwnProperty.call(r,t.discriminator))throw Error(`Invalid discriminated union option at index "${n}"`)});let r=Fe(()=>Di(t));e._zod.parse=(i,a)=>{let o=i.value;if(!Xe(o))return i.issues.push({code:`invalid_type`,expected:`object`,input:o,inst:e}),i;let s=o?.[t.discriminator],c=r.value.get(s);return c&&(s!==void 0||a.direction!==`backward`)?c._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()).filter(e=>r.value.get(e)!==null),input:o,path:[t.discriminator],inst:e}),i)}}),ki=M(`$ZodIntersection`,(e,t)=>{xr.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])=>ji(e,t,n)):ji(e,i,a)}});function Ai(e,t){if(e===t||e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(Qe(e)&&Qe(t)){let n=Object.keys(t),r=Object.keys(e).filter(e=>n.indexOf(e)!==-1),i={...e,...t};Object.prototype.hasOwnProperty.call(i,`__proto__`)&&delete i.__proto__;for(let n of r){if(n===`__proto__`)continue;let r=Ai(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=Ai(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 ji(e,t,n){let r=new Map,i,a=new Map,o=(e,t)=>{let n;if(e.code===`unrecognized_keys`&&!e.path?.length)i??=e,n=e.keys;else if(e.code===`invalid_key`&&e.origin===`record`&&e.path?.length===1){let t=String(e.path[0]);a.has(t)||a.set(t,e),n=[t]}else return!1;for(let e of n)r.has(e)||r.set(e,{}),r.get(e)[t]=!0;return!0};for(let n of t.issues)o(n,`l`)||e.issues.push(n);for(let t of n.issues)o(t,`r`)||e.issues.push(t);let s=[...r].filter(([,e])=>e.l&&e.r).map(([e])=>e);if(s.length){let t=i?s.filter(e=>i.keys.includes(e)):[];t.length&&e.issues.push({...i,keys:t});for(let n of s)!t.includes(n)&&a.has(n)&&e.issues.push(a.get(n))}let c=Ai(t.value,n.value);if(!c.valid){if(gt(e))return e;throw Error(`Unmergable intersection. Error path: ${JSON.stringify(c.mergeErrorPath)}`)}return e.value=c.data,e}var Mi=M(`$ZodRecord`,(e,t)=>{xr.init(e,t);let n=Wt.memoizer;n?.attach(e),e._zod.parse=(r,i)=>{let a=r.value;if(!Qe(a))return r.issues.push({expected:`record`,code:`invalid_type`,input:a,inst:e}),r;let o=[],s=t.keyType._zod.values;if(s&&!t.partial){r.value=n?n.alloc(e,r,{},i):{};let c=new Set;for(let n of s)if(typeof n==`string`||typeof n==`number`||typeof n==`symbol`){if(c.add(typeof n==`number`?n.toString():n),n===`__proto__`)continue;let s=t.keyType._zod.run({value:n,issues:[]},i);if(s instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);if(s.issues.length){r.issues.push({code:`invalid_key`,origin:`record`,issues:s.issues.map(e=>xt(e,i,Gt())),input:n,path:[n],inst:e});continue}let l=s.value;if(l===`__proto__`)continue;let u=t.valueType._zod.run({value:a[n],issues:[]},i);u instanceof Promise?o.push(u.then(e=>{e.issues.length&&r.issues.push(...vt(n,e.issues)),r.value[l]=e.value})):(u.issues.length&&r.issues.push(...vt(n,u.issues)),r.value[l]=u.value)}let l;for(let e in a)if(!c.has(e)){if(t.mode===`loose`){if(e===`__proto__`)continue;r.value[e]=a[e]}else l??=[],l.push(e)}l&&l.length>0&&r.issues.push({code:`unrecognized_keys`,input:a,inst:e,keys:l,continue:!0})}else{r.value=n?n.alloc(e,r,{},i):{};let c;for(let n of Reflect.ownKeys(a)){if(n===`__proto__`||!Object.prototype.propertyIsEnumerable.call(a,n))continue;let l=t.keyType._zod.run({value:n,issues:[]},i);if(l instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);if(typeof n==`string`&&Xn.test(n)&&l.issues.length){let e=t.keyType._zod.run({value:Number(n),issues:[]},i);if(e instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);e.issues.length===0&&(l=e)}if(l.issues.length){t.mode===`loose`?r.value[n]=a[n]:s?(c??=[],c.push(n)):r.issues.push({code:`invalid_key`,origin:`record`,issues:l.issues.map(e=>xt(e,i,Gt())),input:n,path:[n],inst:e});continue}let u=l.value;if(u===`__proto__`)continue;let d=t.valueType._zod.run({value:a[n],issues:[]},i);d instanceof Promise?o.push(d.then(e=>{e.issues.length&&r.issues.push(...vt(n,e.issues)),r.value[u]=e.value})):(d.issues.length&&r.issues.push(...vt(n,d.issues)),r.value[u]=d.value)}c&&c.length>0&&r.issues.push({code:`unrecognized_keys`,input:a,inst:e,keys:c,continue:!0})}return o.length?Promise.all(o).then(()=>r):r}}),Ni=M(`$ZodEnum`,(e,t)=>{xr.init(e,t);let n=je(t.entries),r=new Set(n);e._zod.values=r,j(e,`pattern`,e=>{let t=je(e.def.entries).filter(e=>et.has(typeof e));return RegExp(t.length?`^(${t.map(e=>tt(e.toString())).join(`|`)})$`:`^[^\\s\\S]$`)}),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}}),Pi=M(`$ZodLiteral`,(e,t)=>{xr.init(e,t);let n=new Set(t.values);e._zod.values=n,j(e,`pattern`,e=>{let t=e.def.values;return RegExp(t.length?`^(${t.map(e=>typeof e==`string`?tt(e):e?tt(e.toString()):String(e)).join(`|`)})$`:`^[^\\s\\S]$`)}),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}}),Fi=M(`$ZodTransform`,(e,t)=>{xr.init(e,t),e._zod.optin=`optional`,Wt.memoizer?.guard(e),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new Ut(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));if(i instanceof Promise)throw new Ht;return n.value=i,n}});function Ii(e,t){return e.value=t.issues.length?void 0:t.value,e}var Li=M(`$ZodOptional`,(e,t)=>{xr.init(e,t),j(e,`optin`,e=>e.def.innerType._zod.optin===`defaulted`?`defaulted`:`optional`),e._zod.optout=`optional`,j(e,`values`,e=>{let t=e.def.innerType._zod.values;return t?new Set([...t,void 0]):void 0}),j(e,`pattern`,e=>{let t=e.def.innerType._zod.pattern;return t?RegExp(`^(${Le(t.source)})?$`):void 0}),e._zod.parse=(e,n)=>{if(e.value===void 0){if(t.innerType._zod.optin!==`defaulted`)return e;let r=t.innerType._zod.run({value:e.value,issues:[]},n);return r instanceof Promise?r.then(t=>Ii(e,t)):Ii(e,r)}return t.innerType._zod.run(e,n)}}),Ri=M(`$ZodExactOptional`,(e,t)=>{Li.init(e,t),j(e,`values`,e=>e.def.innerType._zod.values),j(e,`pattern`,e=>e.def.innerType._zod.pattern),e._zod.parse=(e,n)=>t.innerType._zod.run(e,n)}),zi=M(`$ZodNullable`,(e,t)=>{xr.init(e,t),j(e,`optin`,e=>e.def.innerType._zod.optin),j(e,`optout`,e=>e.def.innerType._zod.optout),j(e,`pattern`,e=>{let t=e.def.innerType._zod.pattern;return t?RegExp(`^(${Le(t.source)}|null)$`):void 0}),j(e,`values`,e=>e.def.innerType._zod.values?new Set([...e.def.innerType._zod.values,null]):void 0),e._zod.parse=(e,n)=>e.value===null?e:t.innerType._zod.run(e,n)}),Bi=M(`$ZodDefault`,(e,t)=>{xr.init(e,t),e._zod.optin=`defaulted`,j(e,`values`,e=>e.def.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=>Vi(e,t)):Vi(r,t)}});function Vi(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}var Hi=M(`$ZodPrefault`,(e,t)=>{xr.init(e,t),e._zod.optin=`defaulted`,j(e,`values`,e=>e.def.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))}),Ui=M(`$ZodNonOptional`,(e,t)=>{xr.init(e,t),j(e,`values`,e=>{let t=e.def.innerType._zod.values;return t?new Set([...t].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=>Wi(t,e)):Wi(i,e)}});function Wi(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 Gi(e,t,n,r){return t.issues.length?(e.value=n.catchValue({...t,value:e.value,error:{issues:t.issues.map(e=>xt(e,r,Gt()))},input:e.value}),e):(e.value=t.value,t.memo&&(e.memo=!0),e)}var Ki=M(`$ZodCatch`,(e,t)=>{xr.init(e,t),j(e,`optin`,e=>e.def.innerType._zod.optin===`defaulted`?`defaulted`:`optional`),j(e,`optout`,e=>e.def.innerType._zod.optout),j(e,`values`,e=>e.def.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({value:e.value,issues:[]},n);return r instanceof Promise?r.then(r=>Gi(e,r,t,n)):Gi(e,r,t,n)}}),qi=M(`$ZodPipe`,(e,t)=>{xr.init(e,t),j(e,`values`,e=>e.def.in._zod.values),j(e,`optin`,e=>e.def.in._zod.optin),j(e,`optout`,e=>e.def.out._zod.optout),j(e,`propValues`,e=>e.def.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=>Ji(e,t.in,n)):Ji(r,t.in,n)}let r=t.in._zod.run(e,n);return r instanceof Promise?r.then(e=>Ji(e,t.out,n)):Ji(r,t.out,n)}});function Ji(e,t,n){return e.issues.some(e=>e.code!==`unrecognized_keys`)?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},n)}var Yi=M(`$ZodReadonly`,(e,t)=>{xr.init(e,t),j(e,`propValues`,e=>e.def.innerType._zod.propValues),j(e,`values`,e=>e.def.innerType._zod.values),j(e,`optin`,e=>e.def.innerType?._zod?.optin),j(e,`optout`,e=>e.def.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(Xi):Xi(r)}});function Xi(e){return e.memo||(e.value=Object.freeze(e.value)),e}var Zi=M(`$ZodCustom`,(e,t)=>{tr.init(e,t),xr.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=>Qi(t,n,r,e));Qi(i,n,r,e)}});function Qi(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(Et(e))}}var $i=class extends Error{constructor(){super(`Cannot parse a reference cycle that closes through a transform`),this.name=`ZodCyclicError`}},ea=`~memo`,ta=[];function na(e){return typeof e==`object`&&!!e}function ra(e){return e.map(e=>e.path?{...e,path:e.path.slice()}:{...e})}var ia=new WeakMap,aa=0,oa=1,P=2;function F(e,t,n){let r=ia.get(e);if(r!==void 0)return r?P:aa;if(t.has(e))return P;t.add(e);let i=aa,a=e=>{if(i!==P&&e?._zod){let r=F(e,t,n);r>i&&(i=r)}},o=(e,r)=>{let i=aa;for(let a of Reflect.ownKeys(e)){let o=Object.getOwnPropertyDescriptor(e,a);if(r&&!o.enumerable)continue;let s=o.get?oa:o.value?._zod?F(o.value,t,n):aa;s>i&&(i=s)}return i},s=e=>{e>i&&(i=e)},c=e._zod.def;switch(c.type){case`object`:{let e=Be(c);s(e?o(e,!0):oa),a(c.catchall);break}case`array`:a(c.element);break;case`tuple`:for(let e of c.items)a(e);a(c.rest);break;case`record`:case`map`:a(c.keyType),a(c.valueType);break;case`set`:a(c.valueType);break;case`union`:for(let e of c.options)a(e);break;case`intersection`:a(c.left),a(c.right);break;case`optional`:case`nullable`:case`default`:case`prefault`:case`catch`:case`readonly`:case`nonoptional`:case`promise`:case`success`:a(c.innerType);break;case`pipe`:a(c.in),a(c.out);break;case`function`:a(c.input),a(c.output);break;case`lazy`:{let r=c._cachedInner??(n?e._zod.innerType:void 0);s(r?F(r,t,!1):oa);break}case`template_literal`:case`string`:case`number`:case`int`:case`boolean`:case`bigint`:case`symbol`:case`undefined`:case`null`:case`void`:case`never`:case`any`:case`unknown`:case`date`:case`nan`:case`enum`:case`literal`:case`file`:case`transform`:case`custom`:break;default:for(let e in c){let t=Object.getOwnPropertyDescriptor(c,e);if(!t||t.get)continue;let n=t.value;if(n&&typeof n==`object`){if(n._zod)a(n);else if(Array.isArray(n))for(let e of n)a(e)}}}return t.delete(e),sa(e,i)}function sa(e,t){return t!==oa&&ia.set(e,t===P),t}function ca(e,t){let n=e.buckets.get(t);return n||(n=new WeakMap,e.buckets.set(t,n)),n}var la,ua=[],da={alloc(e,t,n){let r=la;if(!r)return n;la=void 0;let i={value:n,issues:null};return r.set(t.value,i),ua.push(i),n},guard(e){var t;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{let t=e._zod.parse,n=(e,n)=>{if(n.direction!==`backward`&&pa(n,e.value))throw new $i;return t(e,n)};e._zod.parse=n,e._zod.run===t&&(e._zod.run=n)})},attach(e){var t;let n,r=!1,i,a;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{let t=e._zod.parse,o=(s,c)=>{if(n===void 0){let i=F(e,new Set,!1);if(i===aa)return e._zod.parse=t,e._zod.run===o&&(e._zod.run=t),t(s,c);i===P||r?n=!0:r=!0}let l=s.value;if(!na(l))return t(s,c);let u=c[ea];u||(u={buckets:new WeakMap,backEdges:void 0},c[ea]=u);let d;i===c?d=a:(d=ca(u,e),i=c,a=d);let f=d.get(l);if(f)return s.value=f.value,f.issues?f.issues.length&&s.issues.push(...ra(f.issues)):(s.memo=!0,u.backEdges??(u.backEdges=new WeakSet),u.backEdges.add(f.value)),s;la=d;let p=ua.length,m=t(s,c);la=void 0;let h=ua.length>p?ua.pop():void 0;return m instanceof Promise?m.then(e=>(h&&(h.issues=e.issues.length?ra(e.issues):ta),e)):(h&&(h.issues=m.issues.length?ra(m.issues):ta),m)};e._zod.parse=o,e._zod.run===t&&(e._zod.run=o)})}};function fa(){return da}function pa(e,t){let n=e[ea]?.backEdges;return n!==void 0&&na(t)&&n.has(t)}var ma=()=>{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`,currency_code:`currency code`,credit_card:`credit card number`,iban:`IBAN`,jwt:`JWT`,template_literal:`input`},r={nan:`NaN`};function i(e,t){return e===`number`&&typeof t==`number`&&!Number.isFinite(t)?String(t):r[e]??e}return e=>{switch(e.code){case`invalid_type`:return`Invalid input: expected ${i(e.expected)}, received ${i(Tt(e.input),e.input)}`;case`invalid_value`:return e.values.length===1?`Invalid input: expected ${rt(e.values[0])}`:`Invalid option: expected one of ${Me(e.values,`|`)}`;case`too_big`:{let n=e.exact?`exactly `: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.exact?`exactly `: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`:``}: ${Me(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(` | `)}`:e.inclusive===!1?`Invalid input: more than one option matched`:`Invalid input`;case`invalid_element`:return`Invalid value in ${e.origin}`;default:return`Invalid input`}}};function ha(){return{localeError:ma()}}var ga,_a=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)}};function va(){return new _a}(ga=globalThis).__zod_globalRegistry??(ga.__zod_globalRegistry=va());var ya=globalThis.__zod_globalRegistry;function ba(e){return e.checks&&=[...e.checks],e}function xa(e,t){return new e(ba({type:`string`,...k(t)}))}function Sa(e,t){return new e({type:`string`,format:`email`,check:`string_format`,abort:!1,...k(t)})}function Ca(e,t){return new e({type:`string`,format:`guid`,check:`string_format`,abort:!1,...k(t)})}function wa(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,...k(t)})}function Ta(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v4`,...k(t)})}function Ea(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v6`,...k(t)})}function Da(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v7`,...k(t)})}function Oa(e,t){return new e({type:`string`,format:`url`,check:`string_format`,abort:!1,...k(t)})}function ka(e,t){return new e({type:`string`,format:`emoji`,check:`string_format`,abort:!1,...k(t)})}function Aa(e,t){return new e({type:`string`,format:`nanoid`,check:`string_format`,abort:!1,...k(t)})}function ja(e,t){return new e({type:`string`,format:`cuid`,check:`string_format`,abort:!1,...k(t)})}function Ma(e,t){return new e({type:`string`,format:`cuid2`,check:`string_format`,abort:!1,...k(t)})}function Na(e,t){return new e({type:`string`,format:`ulid`,check:`string_format`,abort:!1,...k(t)})}function Pa(e,t){return new e({type:`string`,format:`xid`,check:`string_format`,abort:!1,...k(t)})}function Fa(e,t){return new e({type:`string`,format:`ksuid`,check:`string_format`,abort:!1,...k(t)})}function Ia(e,t){return new e({type:`string`,format:`ipv4`,check:`string_format`,abort:!1,...k(t)})}function La(e,t){return new e({type:`string`,format:`ipv6`,check:`string_format`,abort:!1,...k(t)})}function Ra(e,t){return new e({type:`string`,format:`cidrv4`,check:`string_format`,abort:!1,...k(t)})}function za(e,t){return new e({type:`string`,format:`cidrv6`,check:`string_format`,abort:!1,...k(t)})}function Ba(e,t){return new e({type:`string`,format:`base64`,check:`string_format`,abort:!1,...k(t)})}function Va(e,t){return new e({type:`string`,format:`base64url`,check:`string_format`,abort:!1,...k(t)})}function Ha(e,t){return new e({type:`string`,format:`e164`,check:`string_format`,abort:!1,...k(t)})}function Ua(e,t){return new e({type:`string`,format:`jwt`,check:`string_format`,abort:!1,...k(t)})}function Wa(e,t){return new e({type:`string`,format:`datetime`,check:`string_format`,offset:!1,local:!1,precision:null,...k(t)})}function Ga(e,t){return new e({type:`string`,format:`date`,check:`string_format`,...k(t)})}function Ka(e,t){return new e({type:`string`,format:`time`,check:`string_format`,precision:null,...k(t)})}function qa(e,t){return new e({type:`string`,format:`duration`,check:`string_format`,...k(t)})}function Ja(e,t){return new e(ba({type:`number`,checks:[],...k(t)}))}function Ya(e,t){return new e({type:`number`,check:`number_format`,abort:!1,format:`safeint`,...k(t)})}function Xa(e,t){return new e({type:`boolean`,...k(t)})}function Za(e,t){return new e({type:`null`,...k(t)})}function Qa(e){return new e({type:`unknown`})}function $a(e,t){return new e({type:`never`,...k(t)})}function eo(e,t){return new ir({check:`less_than`,...k(t),value:e,inclusive:!1})}function to(e,t){return new ir({check:`less_than`,...k(t),value:e,inclusive:!0})}function no(e,t){return new ar({check:`greater_than`,...k(t),value:e,inclusive:!1})}function ro(e,t){return new ar({check:`greater_than`,...k(t),value:e,inclusive:!0})}function io(e,t){return new or({check:`multiple_of`,...k(t),value:e})}function ao(e,t){return new cr({check:`max_length`,...k(t),maximum:e})}function oo(e,t){return new lr({check:`min_length`,...k(t),minimum:e})}function so(e,t){return new ur({check:`length_equals`,...k(t),length:e})}function co(e,t){return new fr({check:`string_format`,format:`regex`,...k(t),pattern:e})}function lo(e){return new pr({check:`string_format`,format:`lowercase`,...k(e)})}function uo(e){return new mr({check:`string_format`,format:`uppercase`,...k(e)})}function fo(e,t){return new hr({check:`string_format`,format:`includes`,...k(t),includes:e})}function po(e,t){return new gr({check:`string_format`,format:`starts_with`,...k(t),prefix:e})}function mo(e,t){return new _r({check:`string_format`,format:`ends_with`,...k(t),suffix:e})}function ho(e){return new vr({check:`overwrite`,tx:e})}function go(e){return ho(t=>t.normalize(e))}function _o(){return ho(e=>e.trim())}function vo(){return ho(e=>e.toLowerCase())}function yo(){return ho(e=>e.toUpperCase())}function bo(){return ho(e=>Je(e))}function xo(e,t,n){return new e({type:`array`,element:t,...k(n)})}function So(e,t,n){return new e({type:`custom`,check:`custom`,fn:t,...k(n)})}function Co(e,t){let n=wo(t=>(t.addIssue=e=>{if(typeof e==`string`)t.issues.push(Et(e,t.value,n._zod.def));else{let r=e;r.fatal&&(r.continue=!1),r.code??=`custom`,`input`in r||(r.input=t.value),r.inst??=n,r.continue??=!n._zod.def.abort,t.issues.push(Et(r))}},e(t.value,t)),t);return n}function wo(e,t){let n=new tr({check:`custom`,...k(t)});return n._zod.check=e,n}function To(e,...t){for(let n of t)for(let t of Reflect.ownKeys(n))Object.prototype.propertyIsEnumerable.call(n,t)&&ze(e,t,n[t]);return e}function Eo(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??ya,target:t,unrepresentable:e?.unrepresentable??`throw`,override:e?.override??(()=>{}),io:e?.io??`output`,counter:0,seen:new Map,sharedDefsExtractedFor:void 0,sharedEmitDoneFor:void 0,cycles:e?.cycles??`ref`,reused:e?.reused??`inline`,intersections:[],deferred:[],external:e?.external??void 0}}function Do(e,t,n,r,i){let a=typeof t.unrepresentable==`function`?t.unrepresentable({zodSchema:e,path:r.path,message:i}):t.unrepresentable;if(a===`any`)return!1;if(a===void 0||a===`throw`)throw Error(i);return Object.assign(n,a),!0}function Oo(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),t.sharedDefsExtractedFor=void 0,t.sharedEmitDoneFor=void 0;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,Oo(a,t,r),t.seen.get(a).isParent=!0)}let c=t.metadataRegistry.get(e);return c&&To(o.schema,c),t.io===`input`&&Ro(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 ko(e){return e.replace(/~/g,`~0`).replace(/\//g,`~1`)}function Ao(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);if(e.external&&e.sharedDefsExtractedFor===e.external)return;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}/${ko(a)}`}}let i=`#/${r}/`;if(t[1]===n&&!t[1].schema.id)return{ref:`#`};let a=t[1].schema.id??`__schema${e.counter++}`;return{defId:a,ref:i+ko(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>
55
55
 
56
- 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}r.count>1&&e.reused===`ref`&&a(n)}e.external&&(e.sharedDefsExtractedFor=e.external)}function jo(e){let t=e.anyOf;if(!Array.isArray(t)||t.length===0||e.type!==void 0)return;let n=[];for(let e of t){if(!e||typeof e!=`object`)return;jo(e);let t=Object.keys(e);if(t.length!==1||t[0]!==`type`)return;let r=e.type;for(let e of Array.isArray(r)?r:[r]){if(typeof e!=`string`)return;n.includes(e)||n.push(e)}}delete e.anyOf,e.type=n.length===1?n[0]:n}var Mo=new Set([`type`,`properties`,`required`,`additionalProperties`]),No=[`oneOf`,`anyOf`];function Po(e){let t=e.additionalProperties;return t===void 0||t===!1||typeof t!=`object`||!t?null:Object.keys(t).length?t:null}function Fo(e){let t=[];for(let n of e){if(typeof n!=`object`||n.type!==`object`)return null;for(let e in n)if(!Mo.has(e))return null;t.push(n)}let n={},r=new Set;for(let e of t){for(let r in e.properties){if(Object.prototype.hasOwnProperty.call(n,r))continue;let e=[];for(let n of t){let t=n.properties?.[r]??Po(n);t!=null&&(e.some(e=>JSON.stringify(e)===JSON.stringify(t))||e.push(t))}ze(n,r,e.length===1?e[0]:Fo(e)??{allOf:e})}for(let t of e.required??[])r.add(t)}let i={type:`object`,properties:n};if(r.size&&(i.required=[...r]),t.every(e=>e.additionalProperties===!1))i.additionalProperties=!1;else{let e=[];for(let n of t){let t=Po(n);t&&!e.some(e=>JSON.stringify(e)===JSON.stringify(t))&&e.push(t)}e.length===1?i.additionalProperties=e[0]:e.length>1&&(i.additionalProperties={allOf:e})}return i}function Io(e){let t=e.allOf;if(!Array.isArray(t)||t.length<2)return;for(let t of Mo)if(t in e)return;let n=t.filter(e=>No.some(t=>Array.isArray(e[t]))),r=null;if(!n.length)r=Fo(t);else{let e=n[0],i=No.find(t=>Array.isArray(e[t]));if(Object.keys(e).length!==1)return;let a=t.filter(t=>t!==e),o=e[i].map(e=>Fo([...a,e]));if(o.some(e=>!e))return;r={[i]:o}}r&&(delete e.allOf,To(e,r))}function Lo(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)):To(i,s),To(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??[]})};if(!e.external||e.sharedEmitDoneFor!==e.external){for(let t of[...e.seen.entries()].reverse())r(t[0]);if(e.target!==`openapi-3.0`)for(let t of e.seen.entries())jo(t[1].def??t[1].schema);for(let t of e.deferred)t();if(e.intersections.length){let t=new Map;for(let n of e.seen.values())for(let e of[n.schema,n.def]){let n=e?.allOf;if(!Array.isArray(n))continue;let r=t.get(n);r?r.push(e):t.set(n,[e])}for(let n of e.intersections)for(let e of t.get(n)??[])Io(e)}}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)}To(i,n.defId?n.schema: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??{};if(!e.external||e.sharedEmitDoneFor!==e.external)for(let t of e.seen.entries()){let e=t[1];e.def&&e.defId&&(e.def.id===e.defId&&delete e.def.id,ze(o,e.defId,e.def))}e.external&&(e.sharedEmitDoneFor=e.external),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:Bo(t,`input`,e.processors),output:Bo(t,`output`,e.processors)}},enumerable:!1,writable:!1}),n}catch{throw Error(`Error converting schema to JSON.`)}}function Ro(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 Ro(r.element,n);if(r.type===`set`)return Ro(r.valueType,n);if(r.type===`lazy`)return Ro(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`||r.type===`catch`)return Ro(r.innerType,n);if(r.type===`intersection`)return Ro(r.left,n)||Ro(r.right,n);if(r.type===`record`||r.type===`map`)return Ro(r.keyType,n)||Ro(r.valueType,n);if(r.type===`pipe`)return e._zod.traits.has(`$ZodCodec`)?!0:Ro(r.in,n)||Ro(r.out,n);if(r.type===`object`){for(let e in r.shape)if(Ro(r.shape[e],n))return!0;return!1}if(r.type===`union`){for(let e of r.options)if(Ro(e,n))return!0;return!1}if(r.type===`tuple`){for(let e of r.items)if(Ro(e,n))return!0;return!!(r.rest&&Ro(r.rest,n))}return!1}var zo=(e,t={})=>n=>{let r=Eo({...n,processors:t});return Oo(e,r),Ao(r,e),Lo(r,e)},Bo=(e,t,n={})=>r=>{let{libraryOptions:i,target:a}=r??{},o=Eo({...i??{},target:a,io:t,processors:n});return Oo(e,o),Ao(o,e),Lo(o,e)},Vo=(e,t,n)=>{(e[t]===void 0||n>e[t])&&(e[t]=n)},Ho=(e,t,n)=>{(e[t]===void 0||n<e[t])&&(e[t]=n)},Uo=(e,t)=>{Vo(e,`minimum`,t),Ho(e,`maximum`,t)},Wo=(e,t)=>{e.multipleOf??=[],e.multipleOf.includes(t)||e.multipleOf.push(t)},I=(e,t)=>{e.patterns??=new Set,e.patterns.add(t)},Go=(e,t)=>{e.mime=e.mime?e.mime.filter(e=>t.includes(e)):[...t]},Ko=(e,t)=>{e.format=t,t.includes(`int`)&&(e.isInt=!0)},qo=(e,t)=>Vo(e,`minimum`,t.minimum),Jo=(e,t)=>Ho(e,`maximum`,t.maximum),Yo=e=>(t,n)=>{Ko(t,n.format);let[r,i]=e[n.format];Vo(t,`minimum`,r),Ho(t,`maximum`,i)},Xo={greater_than:(e,t)=>Vo(e,t.inclusive?`minimum`:`exclusiveMinimum`,t.value),less_than:(e,t)=>Ho(e,t.inclusive?`maximum`:`exclusiveMaximum`,t.value),multiple_of:(e,t)=>Wo(e,t.value),number_format:Yo(at),bigint_format:Yo(ot),min_length:qo,max_length:Jo,length_equals:(e,t)=>Uo(e,t.length),min_size:qo,max_size:Jo,size_equals:(e,t)=>Uo(e,t.size),string_format:(e,t)=>{Ko(e,t.format),t.pattern&&I(e,t.pattern),(t.format===`base64`||t.format===`base64url`)&&(e.contentEncoding=t.format),(t.local||t.precision===-1)&&(e.laxFormat=!0)},mime_type:(e,t)=>Go(e,t.mime)};function Zo(e){let t={},n=e._zod.def,r=e._zod.traits.has(`$ZodCheck`)?[e,...n.checks??[]]:n.checks??[];for(let e of r)Xo[e._zod.def.check]?.(t,e._zod.def);let i=e._zod.bag;i.minimum!==void 0&&Vo(t,`minimum`,i.minimum),i.exclusiveMinimum!==void 0&&Vo(t,`exclusiveMinimum`,i.exclusiveMinimum),i.maximum!==void 0&&Ho(t,`maximum`,i.maximum),i.exclusiveMaximum!==void 0&&Ho(t,`exclusiveMaximum`,i.exclusiveMaximum),i.multipleOf!==void 0&&Wo(t,i.multipleOf),i.format!==void 0&&(t.format??=i.format,i.format.includes(`int`)&&(t.isInt=!0)),i.mime&&Go(t,i.mime);for(let e of i.patterns??[])I(t,e);return t}var Qo={guid:`uuid`,url:`uri`,datetime:`date-time`,json_string:`json-string`,regex:``},$o=new Map([[ri,Rn],[ai,zn]]),es=e=>$o.get(e)??e,ts=(e,t,n,r)=>{let i=n;i.type=`string`;let{minimum:a,maximum:o,format:s,patterns:c,contentEncoding:l,laxFormat:u}=Zo(e);if(typeof a==`number`&&(i.minLength=a),typeof o==`number`&&(i.maxLength=o),s&&(i.format=Qo[s]??s,i.format===``&&delete i.format,(s===`time`||u)&&delete i.format),l&&(i.contentEncoding=l),c&&c.size>0){let e=[...c].map(es);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}))])}},ns=(e,t,n,r)=>{let i=n,{minimum:a,maximum:o,multipleOf:s,exclusiveMaximum:c,exclusiveMinimum:l,isInt:u}=Zo(e);i.type=u?`integer`:`number`;let d=typeof l==`number`&&l>=(a??-1/0),f=typeof c==`number`&&c<=(o??1/0),p=t.target===`draft-04`||t.target===`openapi-3.0`;if(d?p?(i.minimum=l,i.exclusiveMinimum=!0):i.exclusiveMinimum=l:typeof a==`number`&&(i.minimum=a),f?p?(i.maximum=c,i.exclusiveMaximum=!0):i.exclusiveMaximum=c:typeof o==`number`&&(i.maximum=o),s){let n=new Set;for(let a of s)Number.isFinite(a)&&a!==0?n.add(Math.abs(a)):Do(e,t,i,r,`A multipleOf divisor of ${a} cannot be represented in JSON Schema`);let[a,...o]=n;a!==void 0&&(i.multipleOf=a),o.length&&(i.allOf=[...i.allOf??[],...o.map(e=>({multipleOf:e}))])}},rs=(e,t,n,r)=>{n.type=`boolean`},is=(e,t,n,r)=>{t.target===`openapi-3.0`?(n.type=`string`,n.nullable=!0,n.enum=[null]):n.type=`null`},as=(e,t,n,r)=>{n.not={}},os=(e,t,n,r)=>{let i=e._zod.def,a=je(i.entries);if(a.length===0){n.not={};return}a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),n.enum=a},ss=(e,t,n,r)=>{let i=e._zod.def;if(i.values.length===0){n.not={};return}let a=[];for(let o of i.values)if(o===void 0){if(Do(e,t,n,r,"Literal `undefined` cannot be represented in JSON Schema"))return}else if(typeof o==`bigint`){if(Do(e,t,n,r,`BigInt literals cannot be represented in JSON Schema`))return;a.push(Number(o))}else a.push(o);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}},cs=(e,t,n,r)=>{Do(e,t,n,r,`Custom types cannot be represented in JSON Schema`)},ls=(e,t,n,r)=>{Do(e,t,n,r,`Transforms cannot be represented in JSON Schema`)},us=(e,t,n,r)=>{let i=n,a=e._zod.def,{minimum:o,maximum:s}=Zo(e);typeof o==`number`&&(i.minItems=o),typeof s==`number`&&(i.maxItems=s),i.type=`array`,i.items=Oo(a.element,t,{...r,path:[...r.path,`items`]})};function ds(e){let t=e._zod.def;return t.type===`pipe`&&t.in._zod.traits.has(`$ZodTransform`)?ds(t.out):t.type===`catch`?ds(t.innerType):e._zod.optin}var fs=(e,t,n,r)=>{let i=n,a=e._zod.def,o=a.shape;if(Object.getOwnPropertySymbols(o).length&&Do(e,t,i,r,`Symbol keys cannot be represented in JSON Schema`))return;i.type=`object`,i.properties={};for(let e in o)ze(i.properties,e,Oo(o[e],t,{...r,path:[...r.path,`properties`,e]}));let s=[];for(let e of Object.keys(o)){let n=a.shape[e];(t.io===`input`?ds(n)===void 0:n._zod.optout===void 0)&&s.push(e)}s.length>0&&(i.required=s),a.catchall?._zod.def.type===`never`?i.additionalProperties=!1:a.catchall?a.catchall&&(i.additionalProperties=Oo(a.catchall,t,{...r,path:[...r.path,`additionalProperties`]})):t.io===`output`&&(i.additionalProperties=!1)},ps=(e,t,n,r)=>{let i=e._zod.def,a=i.inclusive===!1,o=i.options.map((e,n)=>Oo(e,t,{...r,path:[...r.path,a?`oneOf`:`anyOf`,n]}));a?n.oneOf=o:n.anyOf=o},ms=(e,t,n,r)=>{let i=e._zod.def,a=Oo(i.left,t,{...r,path:[...r.path,`allOf`,0]}),o=Oo(i.right,t,{...r,path:[...r.path,`allOf`,1]}),s=e=>`allOf`in e&&Object.keys(e).length===1,c=[...s(a)?a.allOf:[a],...s(o)?o.allOf:[o]];n.allOf=c,t.intersections.push(c)};function hs(e,t,n){if(t.$ref){if(n.has(t))return t;n.add(t);let r=e.get(t)?.def;if(!r)return t;let i=hs(e,r,n);return i===r?t:i}for(let r of[`anyOf`,`oneOf`]){let i=t[r];if(!Array.isArray(i))continue;let a=i.map(t=>hs(e,t,n));a.some((e,t)=>e!==i[t])&&(t={...t,[r]:a})}let r=Array.isArray(t.type)?t.type:[t.type],i=!r.includes(`string`)&&r.some(e=>e===`number`||e===`integer`),a=t.enum??(t.const===void 0?void 0:[t.const]);if(!i&&!a?.some(e=>typeof e==`number`))return t;let{minimum:o,maximum:s,exclusiveMinimum:c,exclusiveMaximum:l,multipleOf:u,format:d,id:f,...p}=t;return p.enum?p.enum=p.enum.map(e=>typeof e==`number`?String(e):e):typeof p.const==`number`&&(p.const=String(p.const)),i?(p.type=`string`,a||(p.pattern=(r.includes(`number`)?Xn:Yn).source),p):p}var gs=new WeakMap;function _s(e){let t=new Map;for(let n of e.seen.values())n.def&&!t.has(n.schema)&&t.set(n.schema,n);let n=new Map;for(let r of gs.get(e)??[]){let i=e.seen.get(r),a=(i?.def??i?.schema)?.propertyNames;if(!a||a===!0||n.has(a))continue;let o=hs(t,a,new Set);o!==a&&n.set(a,o)}if(n.size)for(let t of e.seen.values())for(let e of[t.schema,t.def]){let t=e&&n.get(e.propertyNames);t&&(e.propertyNames=t)}}var vs=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`object`;let o=a.keyType,s=Zo(o).patterns;if(a.mode===`loose`&&s&&s.size>0){let e=Oo(a.valueType,t,{...r,path:[...r.path,`patternProperties`,`*`]});i.patternProperties={};for(let t of s)ze(i.patternProperties,es(t).source,e)}else{if(t.target===`draft-07`||t.target===`draft-2020-12`){i.propertyNames=Oo(a.keyType,t,{...r,path:[...r.path,`propertyNames`]});let n=gs.get(t);n||(n=[],gs.set(t,n),t.deferred.push(()=>_s(t))),n.push(e)}i.additionalProperties=Oo(a.valueType,t,{...r,path:[...r.path,`additionalProperties`]})}let c=o._zod.values,l=t.io===`input`&&ds(a.valueType)!==void 0;if(c&&!a.partial&&!l){let e=[...c].filter(e=>typeof e==`string`||typeof e==`number`);e.length>0&&(i.required=e.map(String))}},ys=(e,t,n,r)=>{let i=e._zod.def,a=Oo(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`}]},bs=(e,t,n,r)=>{let i=e._zod.def;Oo(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},xs=Symbol();function Ss(e,t,n,r,i){let a=!1,o=JSON.stringify(e,(e,t)=>typeof t==`bigint`?(a=!0,null):t);return a?(Do(t,n,r,i,`BigInt defaults cannot be represented in JSON Schema`),xs):JSON.parse(o)}var Cs=(e,t,n,r)=>{let i=e._zod.def;Oo(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o=Ss(i.defaultValue,e,t,n,r);o!==xs&&(n.default=o)},ws=(e,t,n,r)=>{let i=e._zod.def;Oo(i.innerType,t,r);let a=t.seen.get(e);if(a.ref=i.innerType,t.io!==`input`)return;let o=Ss(i.defaultValue,e,t,n,r);o!==xs&&(n._prefault=o)},Ts=(e,t,n,r)=>{let i=e._zod.def;Oo(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o;try{o=i.catchValue(void 0)}catch{Do(e,t,n,r,`Dynamic catch values are not supported in JSON Schema`);return}n.default=o},Es=(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;Oo(o,t,r);let s=t.seen.get(e);s.ref=o},Ds=(e,t,n,r)=>{let i=e._zod.def;Oo(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.readOnly=!0},Os=(e,t,n,r)=>{let i=e._zod.def;Oo(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},ks=new WeakSet([Object.prototype,Error.prototype]);function As(e,t,n){Object.defineProperty(e,t,{configurable:!0,enumerable:!1,get(){let e=n(this);return Object.defineProperty(this,t,{value:e,configurable:!0,writable:!0}),e},set(e){Object.defineProperty(this,t,{value:e,configurable:!0,writable:!0})}})}var js=M(`ZodError`,(e,t)=>{Zt.init(e,t),e.name=`ZodError`;let n=Object.getPrototypeOf(e);ks.has(n)||(ks.add(n),As(n,`format`,e=>t=>en(e,t)),As(n,`flatten`,e=>t=>$t(e,t)),As(n,`addIssue`,e=>t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,Ne,2)}),As(n,`addIssues`,e=>t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,Ne,2)}),Object.defineProperty(n,"isEmpty",{configurable:!0,enumerable:!1,get(){return this.issues.length===0}}))},void 0,{Parent:Error}),Ms=nn(js),Ns=rn(js),Ps=an(js),Fs=sn(js),Is=pn(js),Ls=mn(js),Rs=hn(js),zs=gn(js),Bs=_n(js),Vs=vn(js),Hs=yn(js),Us=bn(js);function Ws(){Wt.localeError||Gt(ha())}function Gs(){Wt.memoizer||Gt({memoizer:fa()})}var Ks=M(`ZodType`,(e,t)=>(Ws(),xr.init(e,t),e.def=t,e.type=t.type,e),{check(...e){let t=this.def;return this.clone(Ke(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(pl(e,t))},superRefine(e,t){return this.check(ml(e,t))},overwrite(e){return this.check(ho(e))},optional(){return Yc(this)},exactOptional(){return Zc(this)},nullable(){return $c(this)},nullish(){return Yc($c(this))},nonoptional(e){return al(this,e)},array(){return Mc(this)},or(e){return Fc([this,e])},and(e){return zc(this,e)},transform(e){return ll(this,qc(e))},default(e){return tl(this,e)},prefault(e){return rl(this,e)},catch(e){return sl(this,e)},pipe(e){return ll(this,e)},readonly(){return dl(this)},describe(e){let t=this.clone();return ya.add(t,{description:e}),t},meta(...e){if(e.length===0)return ya.get(this);let t=this.clone();return ya.add(t,e[0]),t},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(e,...t){return t.length===0?e(this):e(this,...t)},get"~standard"(){return Ot(this,`~standard`,{...wr(this),jsonSchema:{input:Bo(this,`input`),output:Bo(this,`output`)}})},set"~standard"(e){A(this,`~standard`,e)},parse:function e(t,n){return Ms(this,t,n,{callee:e})},parseAsync:async function e(t,n){return await Ns(this,t,n,{callee:e})},safeParse(e,t){return Ps(this,e,t)},async safeParseAsync(e,t){return Fs(this,e,t)},get spa(){return this?.safeParseAsync},set spa(e){A(this,`spa`,e)},validate(e,t){return un(this,e,t)},validateAsync(e,t){return fn(this,e,t)},encode:function e(t,n){return Is(this,t,n,{callee:e})},decode:function e(t,n){return Ls(this,t,n,{callee:e})},encodeAsync:async function e(t,n){return await Rs(this,t,n,{callee:e})},decodeAsync:async function e(t,n){return await zs(this,t,n,{callee:e})},safeEncode(e,t){return Bs(this,e,t)},safeDecode(e,t){return Vs(this,e,t)},async safeEncodeAsync(e,t){return Hs(this,e,t)},async safeDecodeAsync(e,t){return Us(this,e,t)},toJSONSchema(e){return zo(this,{})(e)},get description(){return ya.get(this)?.description},get _def(){return this._zod.def}}),qs=M(`_ZodString`,(e,t)=>{Tr.init(e,t),Ks.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ts(e,t,n,r)},kt({format:e=>Zo(e).format??null,minLength:e=>Zo(e).minimum??null,maxLength:e=>Zo(e).maximum??null},{regex(...e){return this.check(co(...e))},includes(...e){return this.check(fo(...e))},startsWith(...e){return this.check(po(...e))},endsWith(...e){return this.check(mo(...e))},min(...e){return this.check(oo(...e))},max(...e){return this.check(ao(...e))},length(...e){return this.check(so(...e))},nonempty(...e){return this.check(oo(1,...e))},lowercase(e){return this.check(lo(e))},uppercase(e){return this.check(uo(e))},trim(){return this.check(_o())},normalize(...e){return this.check(go(...e))},toLowerCase(){return this.check(vo())},toUpperCase(){return this.check(yo())},slugify(){return this.check(bo())}})),Js=M(`ZodString`,(e,t)=>{Tr.init(e,t),qs.init(e,t)},{email(e){return this.check(Sa(ec,e))},url(e){return this.check(Oa(rc,e))},jwt(e){return this.check(Ua(vc,e))},emoji(e){return this.check(ka(ic,e))},guid(e){return this.check(Ca(tc,e))},uuid(e){return this.check(wa(nc,e))},uuidv4(e){return this.check(Ta(nc,e))},uuidv6(e){return this.check(Ea(nc,e))},uuidv7(e){return this.check(Da(nc,e))},nanoid(e){return this.check(Aa(ac,e))},cuid(e){return this.check(ja(oc,e))},cuid2(e){return this.check(Ma(sc,e))},ulid(e){return this.check(Na(cc,e))},base64(e){return this.check(Ba(hc,e))},base64url(e){return this.check(Va(gc,e))},xid(e){return this.check(Pa(lc,e))},ksuid(e){return this.check(Fa(uc,e))},ipv4(e){return this.check(Ia(dc,e))},ipv6(e){return this.check(La(fc,e))},cidrv4(e){return this.check(Ra(pc,e))},cidrv6(e){return this.check(za(mc,e))},e164(e){return this.check(Ha(_c,e))},datetime(e){return this.check(Wa(Xs,e))},date(e){return this.check(Ga(Zs,e))},time(e){return this.check(Ka(Qs,e))},duration(e){return this.check(qa($s,e))}});function L(e){return xa(Js,e)}var Ys=M(`ZodStringFormat`,(e,t)=>{Er.init(e,t),qs.init(e,t)}),Xs=M(`ZodISODateTime`,(e,t)=>{Gr.init(e,t),Ys.init(e,t)}),Zs=M(`ZodISODate`,(e,t)=>{Kr.init(e,t),Ys.init(e,t)}),Qs=M(`ZodISOTime`,(e,t)=>{qr.init(e,t),Ys.init(e,t)}),$s=M(`ZodISODuration`,(e,t)=>{Jr.init(e,t),Ys.init(e,t)}),ec=M(`ZodEmail`,(e,t)=>{kr.init(e,t),Ys.init(e,t)}),tc=M(`ZodGUID`,(e,t)=>{Dr.init(e,t),Ys.init(e,t)}),nc=M(`ZodUUID`,(e,t)=>{Or.init(e,t),Ys.init(e,t)}),rc=M(`ZodURL`,(e,t)=>{Lr.init(e,t),Ys.init(e,t)}),ic=M(`ZodEmoji`,(e,t)=>{Rr.init(e,t),Ys.init(e,t)}),ac=M(`ZodNanoID`,(e,t)=>{zr.init(e,t),Ys.init(e,t)}),oc=M(`ZodCUID`,(e,t)=>{Br.init(e,t),Ys.init(e,t)}),sc=M(`ZodCUID2`,(e,t)=>{Vr.init(e,t),Ys.init(e,t)}),cc=M(`ZodULID`,(e,t)=>{Hr.init(e,t),Ys.init(e,t)}),lc=M(`ZodXID`,(e,t)=>{Ur.init(e,t),Ys.init(e,t)}),uc=M(`ZodKSUID`,(e,t)=>{Wr.init(e,t),Ys.init(e,t)}),dc=M(`ZodIPv4`,(e,t)=>{Yr.init(e,t),Ys.init(e,t)}),fc=M(`ZodIPv6`,(e,t)=>{Qr.init(e,t),Ys.init(e,t)}),pc=M(`ZodCIDRv4`,(e,t)=>{$r.init(e,t),Ys.init(e,t)}),mc=M(`ZodCIDRv6`,(e,t)=>{ti.init(e,t),Ys.init(e,t)}),hc=M(`ZodBase64`,(e,t)=>{ii.init(e,t),Ys.init(e,t)}),gc=M(`ZodBase64URL`,(e,t)=>{si.init(e,t),Ys.init(e,t)}),_c=M(`ZodE164`,(e,t)=>{ci.init(e,t),Ys.init(e,t)}),vc=M(`ZodJWT`,(e,t)=>{ui.init(e,t),Ys.init(e,t)}),yc=M(`ZodNumber`,(e,t)=>{di.init(e,t),Ks.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ns(e,t,n,r),e.isFinite=!0},kt({minValue:e=>{let{minimum:t,exclusiveMinimum:n}=Zo(e);return Math.max(t??-1/0,n??-1/0)},maxValue:e=>{let{maximum:t,exclusiveMaximum:n}=Zo(e);return Math.min(t??1/0,n??1/0)},isInt:e=>{let{isInt:t,multipleOf:n}=Zo(e);return!!t||!!n?.some(Number.isSafeInteger)},format:e=>Zo(e).format??null},{gt(e,t){return this.check(no(e,t))},gte(e,t){return this.check(ro(e,t))},min(e,t){return this.check(ro(e,t))},lt(e,t){return this.check(eo(e,t))},lte(e,t){return this.check(to(e,t))},max(e,t){return this.check(to(e,t))},int(e){return this.check(Sc(e))},safe(e){return this.check(Sc(e))},positive(e){return this.check(no(0,e))},nonnegative(e){return this.check(ro(0,e))},negative(e){return this.check(eo(0,e))},nonpositive(e){return this.check(to(0,e))},multipleOf(e,t){return this.check(io(e,t))},step(e,t){return this.check(io(e,t))},finite(){return this}}));function bc(e){return Ja(yc,e)}var xc=M(`ZodNumberFormat`,(e,t)=>{fi.init(e,t),yc.init(e,t)});function Sc(e){return Ya(xc,e)}var Cc=M(`ZodBoolean`,(e,t)=>{pi.init(e,t),Ks.init(e,t),e._zod.processJSONSchema=(t,n,r)=>rs(e,t,n,r)});function wc(e){return Xa(Cc,e)}var Tc=M(`ZodNull`,(e,t)=>{mi.init(e,t),Ks.init(e,t),e._zod.processJSONSchema=(t,n,r)=>is(e,t,n,r)});function Ec(e){return Za(Tc,e)}var Dc=M(`ZodUnknown`,(e,t)=>{hi.init(e,t),Ks.init(e,t),e._zod.processJSONSchema=(e,t,n)=>void 0});function Oc(){return Qa(Dc)}var kc=M(`ZodNever`,(e,t)=>{gi.init(e,t),Ks.init(e,t),e._zod.processJSONSchema=(t,n,r)=>as(e,t,n,r)});function Ac(e){return $a(kc,e)}var jc=M(`ZodArray`,(e,t)=>{Gs(),vi.init(e,t),Ks.init(e,t),e._zod.processJSONSchema=(t,n,r)=>us(e,t,n,r),e.element=t.element},{min(e,t){return this.check(oo(e,t))},nonempty(e){return this.check(oo(1,e))},max(e,t){return this.check(ao(e,t))},length(e,t){return this.check(so(e,t))},unwrap(){return this.element}});function Mc(e,t){return xo(jc,e,t)}var Nc=M(`ZodObject`,(e,t)=>{Gs(),wi.init(e,t),Ks.init(e,t),e._zod.processJSONSchema=(t,n,r)=>fs(e,t,n,r),Ft(e,`shape`,e=>e._zod.def.shape,!1)},{keyof(){return Uc(Object.keys(this._zod.def.shape))},catchall(e){return this.clone(Ke(this._zod.def,{catchall:e}))},passthrough(){return this.clone(Ke(this._zod.def,{catchall:Oc()}))},loose(){return this.clone(Ke(this._zod.def,{catchall:Oc()}))},strict(){return this.clone(Ke(this._zod.def,{catchall:Ac()}))},strip(){return this.clone(Ke(this._zod.def,{catchall:void 0}))},extend(e){return ut(this,e)},safeExtend(e){return ft(this,e)},merge(e){return pt(this,e)},pick(e){return st(this,e)},omit(e){return lt(this,e)},partial(...e){return mt(Jc,this,e[0])},exactPartial(...e){return mt(Xc,this,e[0],`exactPartial`)},required(...e){return ht(il,this,e[0])}});function R(e,t){return new Nc({type:`object`,shape:e??{},...k(t)})}var Pc=M(`ZodUnion`,(e,t)=>{Ei.init(e,t),Ks.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ps(e,t,n,r),e.options=t.options});function Fc(e,t){return new Pc({type:`union`,options:e,...k(t)})}var Ic=M(`ZodDiscriminatedUnion`,(e,t)=>{Pc.init(e,t),Oi.init(e,t)});function Lc(e,t,n){return new Ic({type:`union`,options:t,discriminator:e,...k(n)})}var Rc=M(`ZodIntersection`,(e,t)=>{ki.init(e,t),Ks.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ms(e,t,n,r)});function zc(e,t){return new Rc({type:`intersection`,left:e,right:t})}var Bc=M(`ZodRecord`,(e,t)=>{Gs(),Mi.init(e,t),Ks.init(e,t),e._zod.processJSONSchema=(t,n,r)=>vs(e,t,n,r),e.keyType=t.keyType,e.valueType=t.valueType});function Vc(e,t,n){return!t||!t._zod?new Bc({type:`record`,keyType:L(),valueType:e,...k(t)}):new Bc({type:`record`,keyType:e,valueType:t,...k(n)})}var Hc=M(`ZodEnum`,(e,t)=>{Ni.init(e,t),Ks.init(e,t),e._zod.processJSONSchema=(t,n,r)=>os(e,t,n,r),e.enum=t.entries,e.options=[...e._zod.values];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 Hc({...t,checks:[],...k(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 Hc({...t,checks:[],...k(r),entries:i})}});function Uc(e,t){return new Hc({type:`enum`,entries:Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e,...k(t)})}var Wc=M(`ZodLiteral`,(e,t)=>{Pi.init(e,t),Ks.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ss(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]}})});function Gc(e,t){return new Wc({type:`literal`,values:Array.isArray(e)?e:[e],...k(t)})}var Kc=M(`ZodTransform`,(e,t)=>{Gs(),Fi.init(e,t),Ks.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ls(e,t,n,r),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new Ut(e.constructor.name);n.addIssue=r=>{if(typeof r==`string`)n.issues.push(Et(r,n.value,t));else{let t=r;t.fatal&&(t.continue=!1),t.code??=`custom`,`input`in t||(t.input=n.value),t.inst??=e,n.issues.push(Et(t))}};let i=t.transform(n.value,n);return i instanceof Promise?i.then(e=>(n.value=e,n)):(n.value=i,n)}});function qc(e){return new Kc({type:`transform`,transform:e})}var Jc=M(`ZodOptional`,(e,t)=>{Li.init(e,t),Ks.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Os(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Yc(e){return new Jc({type:`optional`,innerType:e})}var Xc=M(`ZodExactOptional`,(e,t)=>{Ri.init(e,t),Ks.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Os(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Zc(e){return new Xc({type:`optional`,innerType:e})}var Qc=M(`ZodNullable`,(e,t)=>{zi.init(e,t),Ks.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ys(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function $c(e){return new Qc({type:`nullable`,innerType:e})}var el=M(`ZodDefault`,(e,t)=>{Bi.init(e,t),Ks.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Cs(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function tl(e,t){return new el({type:`default`,innerType:e,get defaultValue(){return typeof t==`function`?t():$e(t)}})}var nl=M(`ZodPrefault`,(e,t)=>{Hi.init(e,t),Ks.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ws(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function rl(e,t){return new nl({type:`prefault`,innerType:e,get defaultValue(){return typeof t==`function`?t():$e(t)}})}var il=M(`ZodNonOptional`,(e,t)=>{Ui.init(e,t),Ks.init(e,t),e._zod.processJSONSchema=(t,n,r)=>bs(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function al(e,t){return new il({type:`nonoptional`,innerType:e,...k(t)})}var ol=M(`ZodCatch`,(e,t)=>{Ki.init(e,t),Ks.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ts(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function sl(e,t){return new ol({type:`catch`,innerType:e,catchValue:typeof t==`function`?t:Lt(t)})}var cl=M(`ZodPipe`,(e,t)=>{qi.init(e,t),Ks.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Es(e,t,n,r),e.in=t.in,e.out=t.out});function ll(e,t){return new cl({type:`pipe`,in:e,out:t})}var ul=M(`ZodReadonly`,(e,t)=>{Yi.init(e,t),Ks.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ds(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function dl(e){return new ul({type:`readonly`,innerType:e})}var fl=M(`ZodCustom`,(e,t)=>{Zi.init(e,t),Ks.init(e,t),e._zod.processJSONSchema=(t,n,r)=>cs(e,t,n,r)});function pl(e,t={}){return So(fl,e,t)}function ml(e,t){return Co(e,t)}var hl=R({arg:L().min(1),op:Uc([`eq`,`neq`,`gt`,`gte`,`lt`,`lte`]).optional(),value:Fc([L(),bc(),wc(),Ec()])}),gl={content:L().min(1),when:Mc(hl).optional()},_l=R({start:Mc(R({...gl,blocking:wc().optional()})).optional(),delayed:Mc(R({...gl,afterMs:bc().int().nonnegative()})).optional(),complete:Mc(R({...gl,role:Uc([`assistant`,`system`]).optional()})).optional(),failed:Mc(R({...gl,role:Uc([`assistant`,`system`]).optional()})).optional()}),vl=R({type:Gc(`function`),name:L().min(1),description:L().min(1),parameters:Vc(L(),Oc()),messages:_l.optional()}),yl=`client-config`,bl=R({name:L().optional(),greeting:L().max(x).optional(),sessionUrl:L().optional(),page:Uc([`voice`,`static`]),sessionToken:L().optional()});function xl(e){return C(e)?e:{}}var Sl=`/workflows`,Cl=`Workflow API`;function wl(e){let t=e.endsWith(`/`)?e:`${e}/`;return new URL(Sl.replace(/^\//,``),t).toString()}async function Tl(e){return Object.assign(Error(await Ae(e,Cl)),{status:e.status})}function El(e){if(!C(e))return;let t=e.status;return typeof t==`number`?t:void 0}function Dl(e){return ie(e,Cl)}function Ol(e,t){return{runId:e,workflow:t,createdAt:Date.now(),status:`pending`}}function kl(e){let t=null,n=null,r=()=>{let n=Promise.resolve().then(e).finally(()=>{t===n&&(t=null)});return t=n,n},i=()=>t===null?r():(n===null&&(n=t.catch(()=>void 0).then(()=>(n=null,i()))),n);return{trigger:i}}function Al(){let e=0;return{current:()=>e,bump(){e+=1},isCurrent:t=>t===e}}var jl=class extends Error{invariant;constructor(e,t){super(t),this.name=`InvariantViolation`,this.invariant=e}};function Ml(e,t,n){if(!e)throw new jl(t,Nl(t,n))}function Nl(e,t){if(t===void 0)return`invariant ${e} violated`;try{return`invariant ${e} violated: ${JSON.stringify(t())}`}catch{return`invariant ${e} violated (detail unavailable)`}}function Pl(e,t){let n=t.baseMs*2**(e-1),r=t.maxMs===void 0?n:Math.min(n,t.maxMs);return r/2+r/2*Math.random()}function Fl(e,t={}){let{signal:n,unref:r}=t;return n?.aborted===!0?Promise.resolve():new Promise(t=>{let i,a=setTimeout(()=>{i!==void 0&&n?.removeEventListener(`abort`,i),t()},e);r===!0&&C(a)&&typeof a.unref==`function`&&a.unref(),n!==void 0&&(i=()=>{clearTimeout(a),t()},n.addEventListener(`abort`,i,{once:!0}))})}var Il=[`completed`,`failed`,`cancelled`];function Ll(e){return e!==void 0&&Il.includes(e.status)}var Rl=6e4;function zl(e){return e===void 0||!Number.isFinite(e)||e<=0?0:Math.min(e,Rl)}oe(`stepNotifyClient`);var Bl=/^[A-Za-z0-9_-]{1,64}$/,Vl=/^[A-Za-z0-9_-]{1,128}$/,Hl=R({id:L().startsWith(`evt_`),at:bc().int().nonnegative()}),Ul=R({type:Gc(`usage.updated`),meta:Hl,inputTokens:bc().int().nonnegative(),outputTokens:bc().int().nonnegative(),totalTokens:bc().int().nonnegative(),steps:bc().int().nonnegative()}),Wl=R({type:Gc(`guardrail.blocked`),meta:Hl,direction:Uc([`input`,`output`]),replacement:L().max(x)}),Gl=R({type:Gc(`userTurn.exceeded`),meta:Hl,limit:Uc([`words`,`duration`]),words:bc().int().nonnegative(),durationMs:bc().int().nonnegative()}),Kl=R({type:Gc(`provider.failedOver`),meta:Hl,stage:Uc([`stt`,`llm`,`tts`]),from:L(),to:L(),reason:L().max(500)}),ql=bc().int().nonnegative(),Jl=R({type:Gc(`metrics.collected`),meta:Hl,interrupted:wc(),latencyMs:ql.optional(),stt:R({endpointingMs:ql.optional()}).optional(),llm:R({ttftMs:ql.optional(),durationMs:ql,steps:bc().int().nonnegative(),inputTokens:bc().int().nonnegative().optional(),outputTokens:bc().int().nonnegative().optional()}).optional(),tts:R({ttfbMs:ql.optional(),characters:bc().int().nonnegative()}).optional()}),Yl=Uc([`stt`,`llm`,`tts`,`tool`,`protocol`,`connection`,`audio`,`internal`]),Xl=e=>R({type:Gc(e),meta:Hl}),Zl=R({callId:L(),name:L(),args:Vc(L(),Oc()),status:Uc([`pending`,`done`]),result:L().max(b).optional(),afterMessageIndex:bc().int().min(-1)}),Ql=Uc([`turn-failed`,`session-failed`]),$l=Lc(`type`,[R({type:Gc(`session.configured`),meta:Hl,audioFormat:L(),sampleRate:bc().int().positive().max(S),ttsSampleRate:bc().int().positive().max(S),sessionId:L()}),Xl(`audio.completed`),Xl(`speech.started`),Xl(`speech.stopped`),R({type:Gc(`userTranscript.updated`),meta:Hl,text:L().max(x),eotConfidence:bc().min(0).max(1).optional()}),R({type:Gc(`userTranscript.committed`),meta:Hl,text:L().max(x)}),R({type:Gc(`agentTranscript.updated`),meta:Hl,text:L().max(x)}),R({type:Gc(`agentTranscript.committed`),meta:Hl,text:L().max(x),recovery:Ql.optional(),recorded:Gc(!1).optional()}),R({type:Gc(`tool.called`),meta:Hl,toolCallId:L(),toolName:L(),args:Vc(L(),Oc())}),R({type:Gc(`tool.completed`),meta:Hl,toolCallId:L(),result:L().max(b)}),Xl(`reply.completed`),Xl(`reply.cancelled`),Xl(`session.reset`),Xl(`session.timedOut`),R({type:Gc(`error.reported`),meta:Hl,code:Yl,message:L().max(ee),fatal:wc()}),R({type:Gc(`custom.emitted`),meta:Hl,event:L().min(1).max(256),data:Oc()}),R({type:Gc(`state.updated`),meta:Hl,state:Vc(L(),Oc())}),Ul,Wl,Gl,Kl,Jl,R({type:Gc(`history.restored`),meta:Hl,messages:Mc(R({role:Uc([`user`,`assistant`]),content:L().max(x)})).max(200),toolCalls:Mc(Zl).max(200)})]);new Set($l.options.map(e=>e.shape.type.value));var eu=R({type:L()}).passthrough();function tu(e,t,n){let r=e.safeParse(t);if(r.success)return{ok:!0,data:r.data};let i=eu.safeParse(t);return{ok:!1,malformed:!i.success||(n?.has(i.data.type)??!1),error:r.error.message}}R({audioFormat:Uc([`pcm16`]),sampleRate:bc().int().positive(),ttsSampleRate:bc().int().positive()});var nu=R({systemPrompt:L().min(1),greeting:L().optional(),tools:Mc(vl),sttPrompt:L().optional(),credentials:Vc(L(),L().min(1)).optional(),audioLeadMs:Fc([bc().positive(),Ec()]).optional()});R({type:Gc(`config`),host:nu,audioFormat:Uc([`pcm16`]).optional(),sampleRate:bc().int().positive().max(S).optional(),ttsSampleRate:bc().int().positive().max(S).optional()});var ru=`aai.session`,iu=`aai.auth.`,au=`aai-session-ticket`,ou=o((e=>{Object.defineProperty(e,"__esModule",{value:!0});function t(){if(typeof globalThis<`u`)return globalThis;if(typeof self<`u`)return self;if(typeof window<`u`)return window;if(typeof global<`u`)return global}function n(){let e=t();if(e.__xstate__)return e.__xstate__}function r(e){if(typeof window>`u`)return;let t=n();t&&t.register(e)}e.devToolsAdapter=e=>{if(typeof window>`u`)return;let t=n();t&&t.register(e)},e.getGlobal=t,e.registerService=r})),su=o((e=>{var t=ou(),n=class{constructor(e){this._process=e,this._active=!1,this._current=null,this._last=null}start(){this._active=!0,this.flush()}clear(){this._current&&(this._current.next=null,this._last=this._current)}enqueue(e){let t={value:e,next:null};if(this._current){this._last.next=t,this._last=t;return}this._current=t,this._last=t,this._active&&this.flush()}flush(){for(;this._current;){let e=this._current;this._process(e.value),this._current=e.next}this._last=null}},r=`.`,i=``,a=``,o=`#`,s=`*`,c=`xstate.init`,l=`xstate.error`,u=`xstate.stop`;function d(e,t){return{type:`xstate.after.${e}.${t}`}}function f(e,t){return{type:`xstate.done.state.${e}`,output:t}}function p(e,t){return{type:`xstate.done.actor.${e}`,output:t,actorId:e}}function m(e,t){return{type:`xstate.error.actor.${e}`,error:t,actorId:e}}function h(e){return{type:c,input:e}}function g(e){setTimeout(()=>{throw e})}var _=typeof Symbol==`function`&&Symbol.observable||`@@observable`;function v(e,t){let n=b(e),r=b(t);return typeof r==`string`?typeof n==`string`&&r===n:typeof n==`string`?n in r:Object.keys(n).every(e=>e in r&&v(n[e],r[e]))}function y(e){if(T(e))return e;let t=[],n=``;for(let r=0;r<e.length;r++){switch(e.charCodeAt(r)){case 92:n+=e[r+1],r++;continue;case 46:t.push(n),n=``;continue}n+=e[r]}return t.push(n),t}function b(e){return Nt(e)?e.value:typeof e==`string`?x(y(e)):e}function x(e){if(e.length===1)return e[0];let t={},n=t;for(let t=0;t<e.length-1;t++)if(t===e.length-2)n[e[t]]=e[t+1];else{let r=n;n={},r[e[t]]=n}return t}function ee(e,t){let n={},r=Object.keys(e);for(let i=0;i<r.length;i++){let a=r[i];n[a]=t(e[a],a,e,i)}return n}function S(e){return T(e)?e:[e]}function C(e){return e===void 0?[]:S(e)}function w(e,t,n,r){return typeof e==`function`?e({context:t,event:n,self:r}):e}function T(e){return Array.isArray(e)}function te(e){return e.type.startsWith(`xstate.error.actor`)}function E(e){return S(e).map(e=>e===void 0||typeof e==`string`?{target:e}:e)}function ne(e){if(e!==void 0&&e!==i)return C(e)}function re(e,t,n){let r=typeof e==`object`,i=r?e:void 0;return{next:(r?e.next:e)?.bind(i),error:(r?e.error:t)?.bind(i),complete:(r?e.complete:n)?.bind(i)}}function ie(e,t){return`${t}.${e}`}function ae(e,t){let n=t.match(/^xstate\.invoke\.(\d+)\.(.*)/);if(!n)return e.implementations.actors[t];let[,r,i]=n,a=e.getStateNodeById(i).config.invoke;return(Array.isArray(a)?a[r]:a).src}function oe(e){return[...new Set([...e._nodes.flatMap(e=>e.ownEvents)])]}function se(e,t){if(t===e||t===s)return!0;if(!t.endsWith(`.*`))return!1;let n=t.split(`.`),r=e.split(`.`);for(let e=0;e<n.length;e++){let t=n[e],i=r[e];if(t===`*`)return e===n.length-1;if(t!==i)return!1}return!0}function ce(e,t){return`${e.sessionId}.${t}`}var le=0;function ue(e,t){let n=new Map,r=new Map,i=new WeakMap,a=new Set,o={},{clock:s,logger:c}=t,l={schedule:(e,t,n,r,i=Math.random().toString(36).slice(2))=>{let a={source:e,target:t,event:n,delay:r,id:i,startedAt:Date.now()},c=ce(e,i);u._snapshot._scheduledEvents[c]=a;let l=s.setTimeout(()=>{delete o[c],delete u._snapshot._scheduledEvents[c],u._relay(e,t,n)},r);o[c]=l},cancel:(e,t)=>{let n=ce(e,t),r=o[n];delete o[n],delete u._snapshot._scheduledEvents[n],r!==void 0&&s.clearTimeout(r)},cancelAll:e=>{for(let t in u._snapshot._scheduledEvents){let n=u._snapshot._scheduledEvents[t];n.source===e&&l.cancel(e,n.id)}}},u={_snapshot:{_scheduledEvents:(t?.snapshot&&t.snapshot.scheduler)??{}},_bookId:()=>`x:${le++}`,_register:(e,t)=>(n.set(e,t),e),_unregister:e=>{n.delete(e.sessionId);let t=i.get(e);t!==void 0&&(r.delete(t),i.delete(e))},get:e=>r.get(e),getAll:()=>Object.fromEntries(r.entries()),_set:(e,t)=>{let n=r.get(e);if(n&&n!==t)throw Error(`Actor with system ID '${e}' already exists.`);r.set(e,t),i.set(t,e)},inspect:e=>{let t=re(e);return a.add(t),{unsubscribe(){a.delete(t)}}},_sendInspectionEvent:t=>{if(!a.size)return;let n={...t,rootId:e.sessionId};a.forEach(e=>e.next?.(n))},_relay:(e,t,n)=>{u._sendInspectionEvent({type:`@xstate.event`,sourceRef:e,actorRef:t,event:n}),t._send(n)},scheduler:l,getSnapshot:()=>({_scheduledEvents:{...u._snapshot._scheduledEvents}}),start:()=>{let e=u._snapshot._scheduledEvents;u._snapshot._scheduledEvents={};for(let t in e){let{source:n,target:r,event:i,delay:a,id:o}=e[t];l.schedule(n,r,i,a,o)}},_clock:s,_logger:c};return u}var de=!1,fe=1,pe=function(e){return e[e.NotStarted=0]=`NotStarted`,e[e.Running=1]=`Running`,e[e.Stopped=2]=`Stopped`,e}({}),me={clock:{setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e)},logger:console.log.bind(console),devTools:!1},he=class{constructor(e,t){this.logic=e,this._snapshot=void 0,this.clock=void 0,this.options=void 0,this.id=void 0,this.mailbox=new n(this._process.bind(this)),this.observers=new Set,this.eventListeners=new Map,this.logger=void 0,this._processingStatus=pe.NotStarted,this._parent=void 0,this._syncSnapshot=void 0,this.ref=void 0,this._actorScope=void 0,this.systemId=void 0,this.sessionId=void 0,this.system=void 0,this._doneEvent=void 0,this.src=void 0,this._deferred=[];let r={...me,...t},{clock:i,logger:a,parent:o,syncSnapshot:s,id:c,systemId:l,inspect:u}=r;this.system=o?o.system:ue(this,{clock:i,logger:a}),u&&!o&&this.system.inspect(re(u)),this.sessionId=this.system._bookId(),this.id=c??this.sessionId,this.logger=t?.logger??this.system._logger,this.clock=t?.clock??this.system._clock,this._parent=o,this._syncSnapshot=s,this.options=r,this.src=r.src??e,this.ref=this,this._actorScope={self:this,id:this.id,sessionId:this.sessionId,logger:this.logger,defer:e=>{this._deferred.push(e)},system:this.system,stopChild:e=>{if(e._parent!==this)throw Error(`Cannot stop child actor ${e.id} of ${this.id} because it is not a child`);e._stop()},emit:e=>{let t=this.eventListeners.get(e.type),n=this.eventListeners.get(`*`);if(!t&&!n)return;let r=[...t?t.values():[],...n?n.values():[]];for(let t of r)try{t(e)}catch(e){g(e)}},actionExecutor:e=>{let t=()=>{if(this._actorScope.system._sendInspectionEvent({type:`@xstate.action`,actorRef:this,action:{type:e.type,params:e.params}}),!e.exec)return;let t=de;try{de=!0,e.exec(e.info,e.params)}finally{de=t}};this._processingStatus===pe.Running?t():this._deferred.push(t)}},this.send=this.send.bind(this),this.system._sendInspectionEvent({type:`@xstate.actor`,actorRef:this}),l&&(this.systemId=l,this.system._set(l,this)),this._initState(t?.snapshot??t?.state),l&&this._snapshot.status!==`active`&&this.system._unregister(this)}_initState(e){try{this._snapshot=e?this.logic.restoreSnapshot?this.logic.restoreSnapshot(e,this._actorScope):e:this.logic.getInitialSnapshot(this._actorScope,this.options?.input)}catch(e){this._snapshot={status:`error`,output:void 0,error:e}}}update(e,t){this._snapshot=e;let n;for(;n=this._deferred.shift();)try{n()}catch(t){this._deferred.length=0,this._snapshot={...e,status:`error`,error:t}}switch(this._snapshot.status){case`active`:for(let t of this.observers)try{t.next?.(e)}catch(e){g(e)}break;case`done`:for(let t of this.observers)try{t.next?.(e)}catch(e){g(e)}this._stopProcedure(),this._complete(),this._doneEvent=p(this.id,this._snapshot.output),this._parent&&this.system._relay(this,this._parent,this._doneEvent);break;case`error`:this._error(this._snapshot.error)}this.system._sendInspectionEvent({type:`@xstate.snapshot`,actorRef:this,event:t,snapshot:e})}subscribe(e,t,n){let r=re(e,t,n);if(this._processingStatus!==pe.Stopped)this.observers.add(r);else switch(this._snapshot.status){case`done`:try{r.complete?.()}catch(e){g(e)}break;case`error`:{let e=this._snapshot.error;if(!r.error)g(e);else try{r.error(e)}catch(e){g(e)}break}}return{unsubscribe:()=>{this.observers.delete(r)}}}on(e,t){let n=this.eventListeners.get(e);n||(n=new Set,this.eventListeners.set(e,n));let r=t.bind(void 0);return n.add(r),{unsubscribe:()=>{n.delete(r)}}}select(e,t=Object.is){return{subscribe:n=>{let r=re(n),i=e(this.getSnapshot());return this.subscribe(n=>{let a=e(n);t(i,a)||(i=a,r.next?.(a))})},get:()=>e(this.getSnapshot())}}start(){if(this._processingStatus===pe.Running)return this;this._syncSnapshot&&this.subscribe({next:e=>{e.status===`active`&&this.system._relay(this,this._parent,{type:`xstate.snapshot.${this.id}`,snapshot:e})},error:()=>{}}),this.system._register(this.sessionId,this),this.systemId&&this.system._set(this.systemId,this),this._processingStatus=pe.Running;let e=h(this.options.input);switch(this.system._sendInspectionEvent({type:`@xstate.event`,sourceRef:this._parent,actorRef:this,event:e}),this._snapshot.status){case`done`:return this.update(this._snapshot,e),this;case`error`:return this._error(this._snapshot.error),this}if(this._parent||this.system.start(),this.logic.start)try{this.logic.start(this._snapshot,this._actorScope)}catch(e){return this._snapshot={...this._snapshot,status:`error`,error:e},this._error(e),this}return this.update(this._snapshot,e),this.options.devTools&&this.attachDevTools(),this.mailbox.start(),this}_process(e){let t,n;try{t=this.logic.transition(this._snapshot,e,this._actorScope)}catch(e){n={err:e}}if(n){let{err:e}=n;this._snapshot={...this._snapshot,status:`error`,error:e},this._error(e);return}this.update(t,e),e.type===u&&(this._stopProcedure(),this._complete())}_stop(){return this._processingStatus===pe.Stopped?this:(this.mailbox.clear(),this._processingStatus===pe.NotStarted?(this._processingStatus=pe.Stopped,this):(this.mailbox.enqueue({type:u}),this))}stop(){if(this._parent)throw Error(`A non-root actor cannot be stopped directly.`);return this._stop()}_complete(){for(let e of this.observers)try{e.complete?.()}catch(e){g(e)}this.observers.clear(),this.eventListeners.clear()}_reportError(e){if(!this.observers.size){this._parent||g(e),this.eventListeners.clear();return}let t=!1;for(let n of this.observers){let r=n.error;t||=!r;try{r?.(e)}catch(e){g(e)}}this.observers.clear(),this.eventListeners.clear(),t&&g(e)}_error(e){this._stopProcedure(),this._reportError(e),this._parent&&this.system._relay(this,this._parent,m(this.id,e))}_stopProcedure(){return this._processingStatus===pe.Running?(this.system.scheduler.cancelAll(this),this.mailbox.clear(),this.mailbox=new n(this._process.bind(this)),this._processingStatus=pe.Stopped,this.system._unregister(this),this):this}_send(e){this._processingStatus!==pe.Stopped&&this.mailbox.enqueue(e)}send(e){this.system._relay(void 0,this,e)}attachDevTools(){let{devTools:e}=this.options;e&&(typeof e==`function`?e:t.devToolsAdapter)(this)}toJSON(){return{xstate$$type:fe,id:this.id}}getPersistedSnapshot(e){return this.logic.getPersistedSnapshot(this._snapshot,e)}[_](){return this}getSnapshot(){return this._snapshot}};function ge(e,...[t]){return new he(e,t)}var _e=ge;function ve(e,t,n,r,{sendId:i}){return[t,{sendId:typeof i==`function`?i(n,r):i},void 0]}function ye(e,t){e.defer(()=>{e.system.scheduler.cancel(e.self,t.sendId)})}function be(e){function t(e,t){}return t.type=`xstate.cancel`,t.sendId=e,t.resolve=ve,t.execute=ye,t}function D(e,t,n,r,{id:i,systemId:a,src:o,input:s,syncSnapshot:c}){let l=typeof o==`string`?ae(t.machine,o):o,u=typeof i==`function`?i(n):i,d,f;return l&&(f=typeof s==`function`?s({context:t.context,event:n.event,self:e.self}):s,d=ge(l,{id:u,src:o,parent:e.self,syncSnapshot:c,systemId:a,input:f})),[zt(t,{children:{...t.children,[u]:d}}),{id:i,systemId:a,actorRef:d,src:o,input:f},void 0]}function O(e,{actorRef:t}){t&&e.defer(()=>{t._processingStatus!==pe.Stopped&&t.start()})}function xe(...[e,{id:t,systemId:n,input:r,syncSnapshot:i=!1}={}]){function a(e,t){}return a.type=`xstate.spawnChild`,a.id=t,a.systemId=n,a.src=e,a.input=r,a.syncSnapshot=i,a.resolve=D,a.execute=O,a}function Se(e,t,n,r,{actorRef:i}){let a=typeof i==`function`?i(n,r):i,o=typeof a==`string`?t.children[a]:a,s=t.children;return o&&(s={...s},delete s[o.id]),[zt(t,{children:s}),o,void 0]}function Ce(e,t){let n=t.getSnapshot();if(n&&`children`in n)for(let t of Object.values(n.children))Ce(e,t);e.system._unregister(t)}function we(e,t){if(t){if(Ce(e,t),t._processingStatus!==pe.Running){e.stopChild(t);return}e.defer(()=>{e.stopChild(t)})}}function Te(e){function t(e,t){}return t.type=`xstate.stopChild`,t.actorRef=e,t.resolve=Se,t.execute=we,t}var Ee=Te;function De(e,t,{stateValue:n}){if(typeof n==`string`&&We(n)){let t=e.machine.getStateNodeById(n);return e._nodes.some(e=>e===t)}return e.matches(n)}function Oe(e){function t(){return!1}return t.check=De,t.stateValue=e,t}function ke(e,{context:t,event:n},{guards:r}){return!Fe(r[0],t,n,e)}function Ae(e){function t(e,t){return!1}return t.check=ke,t.guards=[e],t}function je(e,{context:t,event:n},{guards:r}){return r.every(r=>Fe(r,t,n,e))}function Me(e){function t(e,t){return!1}return t.check=je,t.guards=e,t}function Ne(e,{context:t,event:n},{guards:r}){return r.some(r=>Fe(r,t,n,e))}function Pe(e){function t(e,t){return!1}return t.check=Ne,t.guards=e,t}function Fe(e,t,n,r){let{machine:i}=r,a=typeof e==`function`,o=a?e:i.implementations.guards[typeof e==`string`?e:e.type];if(!a&&!o)throw Error(`Guard '${typeof e==`string`?e:e.type}' is not implemented.'.`);if(typeof o!=`function`)return Fe(o,t,n,r);let s={context:t,event:n},c=a||typeof e==`string`?void 0:`params`in e?typeof e.params==`function`?e.params({context:t,event:n}):e.params:void 0;return`check`in o?o.check(r,s,o):o(s,c)}function Ie(e){return e.type===`atomic`||e.type===`final`}function Le(e){return Object.values(e.states).filter(e=>e.type!==`history`)}function Re(e,t){let n=[];if(t===e)return n;let r=e.parent;for(;r&&r!==t;)n.push(r),r=r.parent;return n}function ze(e){let t=new Set(e),n=Ve(t);for(let e of t)if(e.type===`compound`&&(!n.get(e)||!n.get(e).length))et(e).forEach(e=>t.add(e));else if(e.type===`parallel`){for(let n of Le(e))if(n.type!==`history`&&!t.has(n)){let e=et(n);for(let n of e)t.add(n)}}for(let e of t){let n=e.parent;for(;n;)t.add(n),n=n.parent}return t}function Be(e,t){let n=t.get(e);if(!n)return{};if(e.type===`compound`){let e=n[0];if(e){if(Ie(e))return e.key}else return{}}let r={};for(let e of n)r[e.key]=Be(e,t);return r}function Ve(e){let t=new Map;for(let n of e)t.has(n)||t.set(n,[]),n.parent&&(t.has(n.parent)||t.set(n.parent,[]),t.get(n.parent).push(n));return t}function He(e,t){return Be(e,Ve(ze(t)))}function Ue(e,t){return t.type===`compound`?Le(t).some(t=>t.type===`final`&&e.has(t)):t.type===`parallel`?Le(t).every(t=>Ue(e,t)):t.type===`final`}var We=e=>e[0]===o;function Ge(e,t){let n=e.transitions.get(t),r=[...e.transitions.keys()].filter(e=>e!==t&&se(t,e)).sort((e,t)=>t.length-e.length).flatMap(t=>e.transitions.get(t));return n?[...n,...r]:r}function Ke(e){let t=e.config.after;if(!t)return[];let n=t=>{let n=d(t,e.id),r=n.type;return e.entry.push(Wt(n,{id:r,delay:t})),e.exit.push(be(r)),r};return Object.keys(t).flatMap(e=>{let r=t[e],i=typeof r==`string`?{target:r}:r,a=Number.isNaN(+e)?e:+e,o=n(a);return C(i).map(e=>({...e,event:o,delay:a}))}).map(t=>{let{delay:n}=t;return{...qe(e,t.event,t),delay:n}})}function qe(e,t,n){let r=ne(n.target),i=n.reenter??!1,a=Ze(e,r),o={...n,actions:C(n.actions),guard:n.guard,target:a,source:e,reenter:i,eventType:t,toJSON:()=>({...o,source:`#${e.id}`,target:a?a.map(e=>`#${e.id}`):void 0})};return o}function Je(e){let t=new Map;if(e.config.on)for(let n of Object.keys(e.config.on)){if(n===a)throw Error('Null events ("") cannot be specified as a transition key. Use `always: { ... }` instead.');let r=e.config.on[n];t.set(n,E(r).map(t=>qe(e,n,t)))}if(e.config.onDone){let n=`xstate.done.state.${e.id}`;t.set(n,E(e.config.onDone).map(t=>qe(e,n,t)))}for(let n of e.invoke){if(n.onDone){let r=`xstate.done.actor.${n.id}`;t.set(r,E(n.onDone).map(t=>qe(e,r,t)))}if(n.onError){let r=`xstate.error.actor.${n.id}`;t.set(r,E(n.onError).map(t=>qe(e,r,t)))}if(n.onSnapshot){let r=`xstate.snapshot.${n.id}`;t.set(r,E(n.onSnapshot).map(t=>qe(e,r,t)))}}for(let n of e.after){let e=t.get(n.eventType);e||(e=[],t.set(n.eventType,e)),e.push(n)}return t}function Ye(e){let t=[],n=r=>{Object.values(r).forEach(r=>{if(r.config.route&&r.config.id){let n=r.config.id,i=r.config.route.guard,a=({event:e})=>e.to===`#${n}`,o={...r.config.route,guard:i?Me([a,i]):a,target:`#${n}`};t.push(qe(e,`xstate.route`,o))}r.states&&n(r.states)})};n(e.states),t.length>0&&e.transitions.set(`xstate.route`,t)}function Xe(e,t){let n=typeof t==`string`?e.states[t]:t?e.states[t.target]:void 0;if(!n&&t)throw Error(`Initial state node "${t}" not found on parent state node #${e.id}`);let r={source:e,actions:!t||typeof t==`string`?[]:C(t.actions),eventType:null,reenter:!1,target:n?[n]:[],meta:typeof t==`object`?t.meta:void 0,description:typeof t==`object`?t.description:void 0,toJSON:()=>({...r,source:`#${e.id}`,target:n?[`#${n.id}`]:[]})};return r}function Ze(e,t){if(t!==void 0)return t.map(t=>{if(typeof t!=`string`)return t;if(We(t))return e.machine.getStateNodeById(t);let n=t[0]===r;if(n&&!e.parent)return k(e,t.slice(1));let i=n?e.key+t:t;if(e.parent)try{return k(e.parent,i)}catch(t){throw Error(`Invalid transition definition for state node '${e.id}':\n${t.message}`)}throw Error(`Invalid target: "${t}" is not a valid target from the root node. Did you mean ".${t}"?`)})}function Qe(e){let t=ne(e.config.target);return t?{target:t.map(t=>typeof t==`string`?k(e.parent,t):t)}:e.parent.type===`parallel`?{target:[e.parent]}:e.parent.initial}function $e(e){return e.type===`history`}function et(e){let t=tt(e);for(let n of t)for(let r of Re(n,e))t.add(r);return t}function tt(e){let t=new Set;function n(e){if(!t.has(e)){if(t.add(e),e.type===`compound`)n(e.initial.target[0]);else if(e.type===`parallel`)for(let t of Le(e))n(t)}}return n(e),t}function nt(e,t){if(We(t))return e.machine.getStateNodeById(t);if(!e.states)throw Error(`Unable to retrieve child state '${t}' from '${e.id}'; no child states exist.`);let n=e.states[t];if(!n)throw Error(`Child state '${t}' does not exist on '${e.id}'`);return n}function k(e,t){if(typeof t==`string`&&We(t))try{return e.machine.getStateNodeById(t)}catch{}let n=y(t).slice(),r=e;for(;n.length;){let e=n.shift();if(!e.length)break;r=nt(r,e)}return r}function rt(e,t){if(typeof t==`string`){let n=e.states[t];if(!n)throw Error(`State '${t}' does not exist on '${e.id}'`);return[e,n]}let n=Object.keys(t),r=n.map(t=>nt(e,t)).filter(Boolean);return[e.machine.root,e].concat(r,n.reduce((n,r)=>{let i=nt(e,r);if(!i)return n;let a=rt(i,t[r]);return n.concat(a)},[]))}function it(e,t,n,r){let i=nt(e,t).next(n,r);return!i||!i.length?e.next(n,r):i}function at(e,t,n,r){let i=Object.keys(t),a=st(nt(e,i[0]),t[i[0]],n,r);return!a||!a.length?e.next(n,r):a}function ot(e,t,n,r){let i=[];for(let a of Object.keys(t)){let o=t[a];if(!o)continue;let s=st(nt(e,a),o,n,r);s&&i.push(...s)}return i.length?i:e.next(n,r)}function st(e,t,n,r){return typeof t==`string`?it(e,t,n,r):Object.keys(t).length===1?at(e,t,n,r):ot(e,t,n,r)}function ct(e){return Object.keys(e.states).map(t=>e.states[t]).filter(e=>e.type===`history`)}function lt(e,t){let n=e;for(;n.parent&&n.parent!==t;)n=n.parent;return n.parent===t}function ut(e,t){let n=new Set(e),r=new Set(t);for(let e of n)if(r.has(e))return!0;for(let e of r)if(n.has(e))return!0;return!1}function dt(e,t,n){let r=new Set;for(let i of e){let e=!1,a=new Set;for(let o of r)if(ut(ht([i],t,n),ht([o],t,n))){if(lt(i.source,o.source))a.add(o);else{e=!0;break}}if(!e){for(let e of a)r.delete(e);r.add(i)}}return Array.from(r)}function ft(e){let[t,...n]=e;for(let e of Re(t,void 0))if(n.every(t=>lt(t,e)))return e}function pt(e,t){if(!e.target)return[];let n=new Set;for(let r of e.target)if($e(r)){if(t[r.id])for(let e of t[r.id])n.add(e);else for(let e of pt(Qe(r),t))n.add(e)}else n.add(r);return[...n]}function mt(e,t){let n=pt(e,t);if(!n)return;if(!e.reenter&&n.every(t=>t===e.source||lt(t,e.source)))return e.source;let r=ft(n.concat(e.source));if(r)return r;if(!e.reenter)return e.source.machine.root}function ht(e,t,n){let r=new Set;for(let i of e)if(i.target?.length){let e=mt(i,n);i.reenter&&i.source===e&&r.add(e);for(let n of t)lt(n,e)&&r.add(n)}return[...r]}function gt(e,t){if(e.length!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;return!0}function _t(e,t,n,r,i){return vt([{target:[...tt(e)],source:e,reenter:!0,actions:[],eventType:null,toJSON:null}],t,n,r,!0,i)}function vt(e,t,n,r,i,a){let o=[];if(!e.length)return[t,o];let s=n.actionExecutor;n.actionExecutor=e=>{o.push(e),s(e)};try{let s=new Set(t._nodes),c=t.historyValue,l=dt(e,s,c),u=t;i||([u,c]=Tt(u,r,n,l,s,c,a,n.actionExecutor)),u=A(u,r,n,l.flatMap(e=>e.actions),a,void 0),u=bt(u,r,n,l,s,a,c,i);let d=[...s];u.status===`done`&&(u=A(u,r,n,d.sort((e,t)=>t.order-e.order).flatMap(e=>e.exit),a,void 0));try{return c===t.historyValue&&gt(t._nodes,s)?[u,o]:[zt(u,{_nodes:d,historyValue:c}),o]}catch(e){throw e}}finally{n.actionExecutor=s}}function yt(e,t,n,r,i){if(r.output===void 0)return;let a=f(i.id,i.output!==void 0&&i.parent?w(i.output,e.context,t,n.self):void 0);return w(r.output,e.context,a,n.self)}function bt(e,t,n,r,i,a,o,s){let c=e,l=new Set,u=new Set;xt(r,o,u,l),s&&u.add(e.machine.root);let d=new Set;for(let e of[...l].sort((e,t)=>e.order-t.order)){i.add(e);let r=[];r.push(...e.entry);for(let t of e.invoke)r.push(xe(t.src,{...t,syncSnapshot:!!t.onSnapshot}));if(u.has(e)){let t=e.initial.actions;r.push(...t)}if(c=A(c,t,n,r,a,e.invoke.map(e=>e.id)),e.type===`final`){let r=e.parent,o=r?.type===`parallel`?r:r?.parent,s=o||e;for(r?.type===`compound`&&a.push(f(r.id,e.output===void 0?void 0:w(e.output,c.context,t,n.self)));o?.type===`parallel`&&!d.has(o)&&Ue(i,o);)d.add(o),a.push(f(o.id)),s=o,o=o.parent;if(o)continue;c=zt(c,{status:`done`,output:yt(c,t,n,c.machine.root,s)})}}return c}function xt(e,t,n,r){for(let i of e){let e=mt(i,t);for(let a of i.target||[])!$e(a)&&(i.source!==a||i.source!==e||i.reenter)&&(r.add(a),n.add(a)),St(a,t,n,r);let a=pt(i,t);for(let o of a){let a=Re(o,e);e?.type===`parallel`&&a.push(e),Ct(r,t,n,a,!i.source.parent&&i.reenter?void 0:e)}}}function St(e,t,n,r){if($e(e)){if(t[e.id]){let i=t[e.id];for(let e of i)r.add(e),St(e,t,n,r);for(let a of i)wt(a,e.parent,r,t,n)}else{let i=Qe(e);for(let a of i.target)r.add(a),i===e.parent?.initial&&n.add(e.parent),St(a,t,n,r);for(let a of i.target)wt(a,e.parent,r,t,n)}}else if(e.type===`compound`){let[i]=e.initial.target;$e(i)||(r.add(i),n.add(i)),St(i,t,n,r),wt(i,e,r,t,n)}else if(e.type===`parallel`)for(let i of Le(e).filter(e=>!$e(e)))[...r].some(e=>lt(e,i))||($e(i)||(r.add(i),n.add(i)),St(i,t,n,r))}function Ct(e,t,n,r,i){for(let a of r)if((!i||lt(a,i))&&e.add(a),a.type===`parallel`)for(let r of Le(a).filter(e=>!$e(e)))[...e].some(e=>lt(e,r))||(e.add(r),St(r,t,n,e))}function wt(e,t,n,r,i){Ct(n,r,i,Re(e,t))}function Tt(e,t,n,r,i,a,o,s){let c=e,l=ht(r,i,a);l.sort((e,t)=>t.order-e.order);let u;for(let e of l)for(let t of ct(e)){let n;n=t.history===`deep`?t=>Ie(t)&&lt(t,e):t=>t.parent===e,u??={...a},u[t.id]=Array.from(i).filter(n)}for(let e of l)c=A(c,t,n,[...e.exit,...e.invoke.map(e=>Te(e.id))],o,void 0),i.delete(e);return[c,u||a]}function Et(e,t){return e.implementations.actions[t]}function Dt(e,t,n,r,i,a){let{machine:o}=e,s=e;for(let e of r){let r=typeof e==`function`,c=r?e:Et(o,typeof e==`string`?e:e.type),l={context:s.context,event:t,self:n.self,system:n.system},u=r||typeof e==`string`?void 0:`params`in e?typeof e.params==`function`?e.params({context:s.context,event:t}):e.params:void 0;if(!c||!(`resolve`in c)){n.actionExecutor({type:typeof e==`string`?e:typeof e==`object`?e.type:e.name||`(anonymous)`,info:l,params:u,exec:c});continue}let d=c,[f,p,m]=d.resolve(n,s,l,u,c,i);s=f,`retryResolve`in d&&a?.push([d,p]),`execute`in d&&n.actionExecutor({type:d.type,info:l,params:p,exec:d.execute.bind(null,n,p)}),m&&(s=Dt(s,t,n,m,i,a))}return s}function A(e,t,n,r,i,a){let o=a?[]:void 0,s=Dt(e,t,n,r,{internalQueue:i,deferredActorIds:a},o);return o?.forEach(([e,t])=>{e.retryResolve(n,s,t)}),s}function Ot(e,t,n,r){let i=e,a=[];function o(e,t,r){n.system._sendInspectionEvent({type:`@xstate.microstep`,actorRef:n.self,event:t,snapshot:e[0],_transitions:r}),a.push(e)}if(t.type===u)return i=zt(kt(i,t,n),{status:`stopped`}),o([i,[]],t,[]),{snapshot:i,microsteps:a};let s=t;if(s.type!==c){let t=s,c=te(t),l=At(t,i);if(c&&!l.length)return i=zt(e,{status:`error`,error:t.error}),o([i,[]],t,[]),{snapshot:i,microsteps:a};let u=vt(l,e,n,s,!1,r);i=u[0],o(u,t,l)}let l=!0,d=e.machine.options?.maxIterations??1/0,f=0;for(;i.status===`active`;){if(f++,f>d)throw Error(`Infinite loop detected: the machine has processed more than ${d} microsteps without reaching a stable state. This usually happens when there's a cycle of transitions (e.g., eventless transitions or raised events causing state A -> B -> C -> A).`);let e=l?jt(i,s):[],t=e.length?i:void 0;if(!e.length){if(!r.length)break;s=r.shift(),e=At(s,i)}let a=vt(e,i,n,s,!1,r);i=a[0],l=i!==t,o(a,s,e)}return i.status!==`active`&&kt(i,s,n),{snapshot:i,microsteps:a}}function kt(e,t,n){return A(e,t,n,Object.values(e.children).map(e=>Te(e)),[],void 0)}function At(e,t){return t.machine.getTransitionData(t,e)}function jt(e,t){let n=new Set,r=e._nodes.filter(Ie);for(let i of r)loop:for(let r of[i].concat(Re(i,void 0)))if(r.always){for(let i of r.always)if(i.guard===void 0||Fe(i.guard,e.context,t,e)){n.add(i);break loop}}return dt(Array.from(n),new Set(e._nodes),e.historyValue)}function Mt(e,t){return He(e,[...ze(rt(e,t))])}function Nt(e){return!!e&&typeof e==`object`&&`machine`in e&&`value`in e}var Pt=function(e){return v(e,this.value)},j=function(e){return this.tags.has(e)},Ft=function(e){let t=this.machine.getTransitionData(this,e);return!!t?.length&&t.some(e=>e.target!==void 0||e.actions.length)},It=function(){let{_nodes:e,tags:t,machine:n,getMeta:r,toJSON:i,can:a,hasTag:o,matches:s,...c}=this;return{...c,tags:Array.from(t)}},Lt=function(){return this._nodes.reduce((e,t)=>(t.meta!==void 0&&(e[t.id]=t.meta),e),{})};function Rt(e,t){return{status:e.status,output:e.output,error:e.error,machine:t,context:e.context,_nodes:e._nodes,value:He(t.root,e._nodes),tags:new Set(e._nodes.flatMap(e=>e.tags)),children:e.children,historyValue:e.historyValue||{},matches:Pt,hasTag:j,can:Ft,getMeta:Lt,toJSON:It}}function zt(e,t={}){return Rt({...e,...t},e.machine)}function Bt(e){if(typeof e!=`object`||!e)return{};let t={};for(let n in e){let r=e[n];Array.isArray(r)&&(t[n]=r.map(e=>({id:e.id})))}return t}function Vt(e,t){let{_nodes:n,tags:r,machine:i,children:a,context:o,can:s,hasTag:c,matches:l,getMeta:u,toJSON:d,...f}=e,p={};for(let e in a){let n=a[e];p[e]={snapshot:n.getPersistedSnapshot(t),src:n.src,systemId:n.systemId,syncSnapshot:n._syncSnapshot}}return{...f,context:M(o),children:p,historyValue:Bt(f.historyValue)}}function M(e){let t;for(let n in e){let r=e[n];if(r&&typeof r==`object`){if(`sessionId`in r&&`send`in r&&`ref`in r)t??=Array.isArray(e)?e.slice():{...e},t[n]={xstate$$type:fe,id:r.id};else{let i=M(r);i!==r&&(t??=Array.isArray(e)?e.slice():{...e},t[n]=i)}}}return t??e}function Ht(e,t,n,r,{event:i,id:a,delay:o},{internalQueue:s}){let c=t.machine.implementations.delays;if(typeof i==`string`)throw Error(`Only event objects may be used with raise; use raise({ type: "${i}" }) instead`);let l=typeof i==`function`?i(n,r):i,u;if(typeof o==`string`){let e=c&&c[o];u=typeof e==`function`?e(n,r):e}else u=typeof o==`function`?o(n,r):o;return typeof u!=`number`&&s.push(l),[t,{event:l,id:a,delay:u},void 0]}function Ut(e,t){let{event:n,delay:r,id:i}=t;if(typeof r==`number`){e.defer(()=>{let t=e.self;e.system.scheduler.schedule(t,t,n,r,i)});return}}function Wt(e,t){function n(e,t){}return n.type=`xstate.raise`,n.event=e,n.id=t?.id,n.delay=t?.delay,n.resolve=Ht,n.execute=Ut,n}e.$$ACTOR_TYPE=fe,e.Actor=he,e.NULL_EVENT=a,e.ProcessingStatus=pe,e.STATE_DELIMITER=r,e.XSTATE_ERROR=l,e.XSTATE_STOP=u,e.and=Me,e.cancel=be,e.cloneMachineSnapshot=zt,e.createActor=ge,e.createErrorActorEvent=m,e.createInitEvent=h,e.createInvokeId=ie,e.createMachineSnapshot=Rt,e.createSystem=ue,e.evaluateGuard=Fe,e.formatInitialTransition=Xe,e.formatRouteTransitions=Ye,e.formatTransition=qe,e.formatTransitions=Je,e.getAllOwnEventDescriptors=oe,e.getAllStateNodes=ze,e.getCandidates=Ge,e.getDelayedTransitions=Ke,e.getPersistedSnapshot=Vt,e.getProperAncestors=Re,e.getStateNodeByPath=k,e.getStateNodes=rt,e.initialMicrostep=_t,e.interpret=_e,e.isAtomicStateNode=Ie,e.isInFinalState=Ue,e.isMachineSnapshot=Nt,e.isStateId=We,e.macrostep=Ot,e.mapValues=ee,e.matchesEventDescriptor=se,e.matchesState=v,e.not=Ae,e.or=Pe,e.pathToStateValue=x,e.raise=Wt,e.resolveActionsAndContext=A,e.resolveReferencedActor=ae,e.resolveStateValue=Mt,e.spawnChild=xe,e.stateIn=Oe,e.stop=Ee,e.stopChild=Te,e.toArray=C,e.toObserver=re,e.toStatePath=y,e.toTransitionConfigArray=E,e.transitionNode=st})),z=o((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=su();ou();function n(e,t){return{config:e,transition:(t,n,r)=>({...t,context:e(t.context,n,r)}),getInitialSnapshot:(e,n)=>({status:`active`,output:void 0,error:void 0,context:typeof t==`function`?t({input:n}):t}),getPersistedSnapshot:e=>e,restoreSnapshot:e=>e}}var r=new WeakMap;function i(e){return{config:e,start:(t,n)=>{let{self:i,system:a,emit:o}=n,s={receivers:void 0,dispose:void 0};r.set(i,s),s.dispose=e({input:t.input,system:a,self:i,sendBack:e=>{i.getSnapshot().status!==`stopped`&&i._parent&&a._relay(i,i._parent,e)},receive:e=>{s.receivers??=new Set,s.receivers.add(e)},emit:o})},transition:(e,n,i)=>{let a=r.get(i.self);return n.type===t.XSTATE_STOP?(e={...e,status:`stopped`,error:void 0},r.delete(i.self),a.receivers?.clear(),a.dispose?.(),e):(a.receivers?.forEach(e=>e(n)),e)},getInitialSnapshot:(e,t)=>({status:`active`,output:void 0,error:void 0,input:t}),getPersistedSnapshot:e=>e,restoreSnapshot:e=>e}}var a=`xstate.observable.next`,o=`xstate.observable.error`,s=`xstate.observable.complete`;function c(e){return{config:e,transition:(e,n)=>{if(e.status!==`active`)return e;switch(n.type){case a:return{...e,context:n.data};case o:return{...e,status:`error`,error:n.data,input:void 0,_subscription:void 0};case s:return{...e,status:`done`,input:void 0,_subscription:void 0};case t.XSTATE_STOP:return e._subscription.unsubscribe(),{...e,status:`stopped`,input:void 0,_subscription:void 0};default:return e}},getInitialSnapshot:(e,t)=>({status:`active`,output:void 0,error:void 0,context:void 0,input:t,_subscription:void 0}),start:(t,{self:n,system:r,emit:i})=>{t.status!==`done`&&(t._subscription=e({input:t.input,system:r,self:n,emit:i}).subscribe({next:e=>{r._relay(n,n,{type:a,data:e})},error:e=>{r._relay(n,n,{type:o,data:e})},complete:()=>{r._relay(n,n,{type:s})}}))},getPersistedSnapshot:({_subscription:e,...t})=>t,restoreSnapshot:e=>({...e,_subscription:void 0})}}function l(e){return{config:e,transition:(e,n)=>{if(e.status!==`active`)return e;switch(n.type){case o:return{...e,status:`error`,error:n.data,input:void 0,_subscription:void 0};case s:return{...e,status:`done`,input:void 0,_subscription:void 0};case t.XSTATE_STOP:return e._subscription.unsubscribe(),{...e,status:`stopped`,input:void 0,_subscription:void 0};default:return e}},getInitialSnapshot:(e,t)=>({status:`active`,output:void 0,error:void 0,context:void 0,input:t,_subscription:void 0}),start:(t,{self:n,system:r,emit:i})=>{t.status!==`done`&&(t._subscription=e({input:t.input,system:r,self:n,emit:i}).subscribe({next:e=>{n._parent&&r._relay(n,n._parent,e)},error:e=>{r._relay(n,n,{type:o,data:e})},complete:()=>{r._relay(n,n,{type:s})}}))},getPersistedSnapshot:({_subscription:e,...t})=>t,restoreSnapshot:e=>({...e,_subscription:void 0})}}var u=`xstate.promise.resolve`,d=`xstate.promise.reject`,f=new WeakMap;function p(e){return{config:e,transition:(e,n,r)=>{if(e.status!==`active`)return e;switch(n.type){case u:{let t=n.data;return{...e,status:`done`,output:t,input:void 0}}case d:return{...e,status:`error`,error:n.data,input:void 0};case t.XSTATE_STOP:return f.get(r.self)?.abort(),f.delete(r.self),{...e,status:`stopped`,input:void 0};default:return e}},start:(t,{self:n,system:r,emit:i})=>{if(t.status!==`active`)return;let a=new AbortController;f.set(n,a),Promise.resolve(e({input:t.input,system:r,self:n,signal:a.signal,emit:i})).then(e=>{n.getSnapshot().status===`active`&&(f.delete(n),r._relay(n,n,{type:u,data:e}))},e=>{n.getSnapshot().status===`active`&&(f.delete(n),r._relay(n,n,{type:d,data:e}))})},getInitialSnapshot:(e,t)=>({status:`active`,output:void 0,error:void 0,input:t}),getPersistedSnapshot:e=>e,restoreSnapshot:e=>e}}var m=n(e=>void 0,void 0);function h(){return t.createActor(m)}e.createEmptyActor=h,e.fromCallback=i,e.fromEventObservable=l,e.fromObservable=c,e.fromPromise=p,e.fromTransition=n})),cu=o((e=>{var t=su();function n(e,{machine:n,context:r},i,a){let o=(o,s)=>{if(typeof o==`string`){let c=t.resolveReferencedActor(n,o);if(!c)throw Error(`Actor logic '${o}' not implemented in machine '${n.id}'`);let l=t.createActor(c,{id:s?.id,parent:e.self,syncSnapshot:s?.syncSnapshot,input:typeof s?.input==`function`?s.input({context:r,event:i,self:e.self}):s?.input,src:o,systemId:s?.systemId});return a[l.id]=l,l}return t.createActor(o,{id:s?.id,parent:e.self,syncSnapshot:s?.syncSnapshot,input:s?.input,src:o,systemId:s?.systemId})};return(n,r)=>{let i=o(n,r);return a[i.id]=i,e.defer(()=>{i._processingStatus!==t.ProcessingStatus.Stopped&&i.start()}),i}}function r(e,r,i,a,{assignment:o}){if(!r.context)throw Error("Cannot assign to undefined `context`. Ensure that `context` is defined in the machine config.");let s={},c={context:r.context,event:i.event,spawn:n(e,r,i.event,s),self:e.self,system:e.system},l={};if(typeof o==`function`)l=o(c,a);else for(let e of Object.keys(o)){let t=o[e];l[e]=typeof t==`function`?t(c,a):t}let u=Object.assign({},r.context,l);return[t.cloneMachineSnapshot(r,{context:u,children:Object.keys(s).length?{...r.children,...s}:r.children}),void 0,void 0]}function i(e){function t(e,t){}return t.type=`xstate.assign`,t.assignment=e,t.resolve=r,t}e.assign=i})),lu=o((e=>{var t=su(),n=cu(),r=new WeakMap;function i(e,t,n){let i=r.get(e);return i?t in i||(i[t]=n()):(i={[t]:n()},r.set(e,i)),i[t]}var a={},o=e=>typeof e==`string`?{type:e}:typeof e==`function`?`resolve`in e?{type:e.type}:{type:e.name}:e,s=class e{constructor(n,r){if(this.config=n,this.key=void 0,this.id=void 0,this.type=void 0,this.path=void 0,this.states=void 0,this.history=void 0,this.entry=void 0,this.exit=void 0,this.parent=void 0,this.machine=void 0,this.meta=void 0,this.output=void 0,this.order=-1,this.description=void 0,this.tags=[],this.transitions=void 0,this.always=void 0,this.parent=r._parent,this.key=r._key,this.machine=r._machine,this.path=this.parent?this.parent.path.concat(this.key):[],this.id=this.config.id||[this.machine.id,...this.path].join(t.STATE_DELIMITER),this.type=this.config.type||(this.config.states&&Object.keys(this.config.states).length?`compound`:this.config.history?`history`:`atomic`),this.description=this.config.description,this.order=this.machine.idMap.size,this.machine.idMap.set(this.id,this),this.states=this.config.states?t.mapValues(this.config.states,(t,n)=>new e(t,{_parent:this,_key:n,_machine:this.machine})):a,this.type===`compound`&&!this.config.initial)throw Error(`No initial state specified for compound state node "#${this.id}". Try adding { initial: "${Object.keys(this.states)[0]}" } to the state config.`);this.history=this.config.history===!0?`shallow`:this.config.history||!1,this.entry=t.toArray(this.config.entry).slice(),this.exit=t.toArray(this.config.exit).slice(),this.meta=this.config.meta,this.output=this.type===`final`||!this.parent?this.config.output:void 0,this.tags=t.toArray(n.tags).slice()}_initialize(){this.transitions=t.formatTransitions(this),this.config.always&&(this.always=t.toTransitionConfigArray(this.config.always).map(e=>t.formatTransition(this,t.NULL_EVENT,e))),Object.keys(this.states).forEach(e=>{this.states[e]._initialize()})}get definition(){return{id:this.id,key:this.key,version:this.machine.version,type:this.type,initial:this.initial?{target:this.initial.target,source:this,actions:this.initial.actions.map(o),eventType:null,reenter:!1,meta:this.initial.meta,description:this.initial.description,toJSON:()=>({target:this.initial.target.map(e=>`#${e.id}`),source:`#${this.id}`,actions:this.initial.actions.map(o),eventType:null,meta:this.initial.meta,description:this.initial.description})}:void 0,history:this.history,states:t.mapValues(this.states,e=>e.definition),on:this.on,transitions:[...this.transitions.values()].flat().map(e=>({...e,actions:e.actions.map(o)})),entry:this.entry.map(o),exit:this.exit.map(o),meta:this.meta,order:this.order||-1,output:this.output,invoke:this.invoke,description:this.description,tags:this.tags}}toJSON(){return this.definition}get invoke(){return i(this,`invoke`,()=>t.toArray(this.config.invoke).map((e,n)=>{let{src:r,systemId:i}=e,a=e.id??t.createInvokeId(this.id,n),o=typeof r==`string`?r:`xstate.invoke.${t.createInvokeId(this.id,n)}`;return{...e,src:o,id:a,systemId:i,toJSON(){let{onDone:t,onError:n,...r}=e;return{...r,type:`xstate.invoke`,src:o,id:a}}}}))}get on(){return i(this,`on`,()=>[...this.transitions].flatMap(([e,t])=>t.map(t=>[e,t])).reduce((e,[t,n])=>(e[t]=e[t]||[],e[t].push(n),e),{}))}get after(){return i(this,`delayedTransitions`,()=>t.getDelayedTransitions(this))}get initial(){return i(this,`initial`,()=>t.formatInitialTransition(this,this.config.initial))}next(e,n){let r=n.type,a=[],o,s=i(this,`candidates-${r}`,()=>t.getCandidates(this,r));for(let i of s){let{guard:s}=i,c=e.context,l=!1;try{l=!s||t.evaluateGuard(s,c,n,e)}catch(e){let t=typeof s==`string`?s:typeof s==`object`?s.type:void 0;throw Error(`Unable to evaluate guard ${t?`'${t}' `:``}in transition for event '${r}' in state node '${this.id}':\n${e.message}`)}if(l){a.push(...i.actions),o=i;break}}return o?[o]:void 0}get events(){return i(this,`events`,()=>{let{states:e}=this,t=new Set(this.ownEvents);if(e)for(let n of Object.keys(e)){let r=e[n];if(r.states)for(let e of r.events)t.add(`${e}`)}return Array.from(t)})}get ownEvents(){let e=Object.keys(Object.fromEntries(this.transitions)),t=new Set(e.filter(e=>this.transitions.get(e).some(e=>!(!e.target&&!e.actions.length&&!e.reenter))));return Array.from(t)}};e.StateMachine=class e{constructor(e,n){this.config=e,this.version=void 0,this.schemas=void 0,this.implementations=void 0,this.options=void 0,this.__xstatenode=!0,this.idMap=new Map,this.root=void 0,this.id=void 0,this.states=void 0,this.events=void 0,this.id=e.id||`(machine)`,this.implementations={actors:n?.actors??{},actions:n?.actions??{},delays:n?.delays??{},guards:n?.guards??{}},this.version=this.config.version,this.schemas=this.config.schemas,this.options={maxIterations:1/0,...this.config.options},this.transition=this.transition.bind(this),this.getInitialSnapshot=this.getInitialSnapshot.bind(this),this.getPersistedSnapshot=this.getPersistedSnapshot.bind(this),this.restoreSnapshot=this.restoreSnapshot.bind(this),this.start=this.start.bind(this),this.root=new s(e,{_key:this.id,_machine:this}),this.root._initialize(),t.formatRouteTransitions(this.root),this.states=this.root.states,this.events=this.root.events}provide(t){let{actions:n,guards:r,actors:i,delays:a}=this.implementations;return new e(this.config,{actions:{...n,...t.actions},guards:{...r,...t.guards},actors:{...i,...t.actors},delays:{...a,...t.delays}})}resolveState(e){let n=t.resolveStateValue(this.root,e.value),r=t.getAllStateNodes(t.getStateNodes(this.root,n));return t.createMachineSnapshot({_nodes:[...r],context:e.context||{},children:{},status:t.isInFinalState(r,this.root)?`done`:e.status||`active`,output:e.output,error:e.error,historyValue:e.historyValue},this)}transition(e,n,r){return t.macrostep(e,n,r,[]).snapshot}microstep(e,n,r){return t.macrostep(e,n,r,[]).microsteps.map(([e])=>e)}getTransitionData(e,n){return t.transitionNode(this.root,e.value,e,n)||[]}_getPreInitialState(e,r,i){let{context:a}=this.config,o=t.createMachineSnapshot({context:typeof a!=`function`&&a?a:{},_nodes:[this.root],children:{},status:`active`},this);return typeof a==`function`?t.resolveActionsAndContext(o,r,e,[n.assign(({spawn:e,event:t,self:n})=>a({spawn:e,input:t.input,self:n}))],i,void 0):o}getInitialSnapshot(e,n){let r=t.createInitEvent(n),i=[],a=t.createMachineSnapshot({context:typeof this.config.context!=`function`&&this.config.context?this.config.context:{},_nodes:[this.root],children:{},status:`active`},this);try{a=this._getPreInitialState(e,r,i);let[n]=t.initialMicrostep(this.root,a,e,r,i),{snapshot:o}=t.macrostep(n,r,e,i);return o}catch(e){return t.cloneMachineSnapshot(a,{status:`error`,error:e})}}start(e){Object.values(e.children).forEach(e=>{e.getSnapshot().status===`active`&&e.start()})}getStateNodeById(e){let n=t.toStatePath(e),r=n.slice(1),i=t.isStateId(n[0])?n[0].slice(1):n[0],a=this.idMap.get(i);if(!a)throw Error(`Child state node '#${i}' does not exist on machine '${this.id}'`);return t.getStateNodeByPath(a,r)}get definition(){return this.root.definition}toJSON(){return this.definition}getPersistedSnapshot(e,n){return t.getPersistedSnapshot(e,n)}restoreSnapshot(e,n){let r={},i=e.children;Object.keys(i).forEach(e=>{let a=i[e],o=a.snapshot,s=a.src,c=typeof s==`string`?t.resolveReferencedActor(this,s):s;if(!c)return;let l=t.createActor(c,{id:e,parent:n.self,syncSnapshot:a.syncSnapshot,snapshot:o,src:s,systemId:a.systemId});r[e]=l});function a(e,t){if(t instanceof s)return t;try{return e.machine.getStateNodeById(t.id)}catch{}}function o(e,t){if(!t||typeof t!=`object`)return{};let n={};for(let r in t){let i=t[r];for(let t of i){let i=a(e,t);i&&(n[r]??=[],n[r].push(i))}}return n}let c=o(this.root,e.historyValue),l=t.createMachineSnapshot({...e,children:r,_nodes:Array.from(t.getAllStateNodes(t.getStateNodes(this.root,e.value))),historyValue:c},this),u=new Set;function d(e,n){if(!u.has(e)){u.add(e);for(let r in e){let i=e[r];if(i&&typeof i==`object`){if(`xstate$$type`in i&&i.xstate$$type===t.$$ACTOR_TYPE){e[r]=n[i.id];continue}d(i,n)}}}}return d(l.context,r),l}},e.StateNode=s})),uu=o((e=>{var t=su(),n=cu();function r(e,t,n,r,{event:i}){return[t,{event:typeof i==`function`?i(n,r):i},void 0]}function i(e,{event:t}){e.defer(()=>e.emit(t))}function a(e){function t(e,t){}return t.type=`xstate.emit`,t.event=e,t.resolve=r,t.execute=i,t}var o=function(e){return e.Parent=`#_parent`,e.Internal=`#_internal`,e}({});function s(e,t,n,r,{to:i,event:a,id:s,delay:c},l){let u=t.machine.implementations.delays;if(typeof a==`string`)throw Error(`Only event objects may be used with sendTo; use sendTo({ type: "${a}" }) instead`);let d=typeof a==`function`?a(n,r):a,f;if(typeof c==`string`){let e=u&&u[c];f=typeof e==`function`?e(n,r):e}else f=typeof c==`function`?c(n,r):c;let p=typeof i==`function`?i(n,r):i,m;if(typeof p==`string`){if(m=p===o.Parent?e.self._parent:p===o.Internal?e.self:p.startsWith(`#_`)?t.children[p.slice(2)]:l.deferredActorIds?.includes(p)?p:t.children[p],!m)throw Error(`Unable to send event to actor '${p}' from machine '${t.machine.id}'.`)}else m=p||e.self;return[t,{to:m,targetId:typeof p==`string`?p:void 0,event:d,id:s,delay:f},void 0]}function c(e,t,n){typeof n.to==`string`&&(n.to=t.children[n.to])}function l(e,n){e.defer(()=>{let{to:r,event:i,delay:a,id:o}=n;if(typeof a==`number`){e.system.scheduler.schedule(e.self,r,i,a,o);return}e.system._relay(e.self,r,i.type===t.XSTATE_ERROR?t.createErrorActorEvent(e.self.id,i.data):i)})}function u(e,t,n){function r(e,t){}return r.type=`xstate.sendTo`,r.to=e,r.event=t,r.id=n?.id,r.delay=n?.delay,r.resolve=s,r.retryResolve=c,r.execute=l,r}function d(e,t){return u(o.Parent,e,t)}function f(e,t){return u(e,({event:e})=>e,t)}function p(e,r,i,o,{collect:s}){let c=[],l=function(e){c.push(e)};return l.assign=(...e)=>{c.push(n.assign(...e))},l.cancel=(...e)=>{c.push(t.cancel(...e))},l.raise=(...e)=>{c.push(t.raise(...e))},l.sendTo=(...e)=>{c.push(u(...e))},l.sendParent=(...e)=>{c.push(d(...e))},l.spawnChild=(...e)=>{c.push(t.spawnChild(...e))},l.stopChild=(...e)=>{c.push(t.stopChild(...e))},l.emit=(...e)=>{c.push(a(...e))},s({context:i.context,event:i.event,enqueue:l,check:e=>t.evaluateGuard(e,r.context,i.event,r),self:e.self,system:e.system},o),[r,void 0,c]}function m(e){function t(e,t){}return t.type=`xstate.enqueueActions`,t.collect=e,t.resolve=p,t}function h(e,t,n,r,{value:i,label:a}){return[t,{value:typeof i==`function`?i(n,r):i,label:a},void 0]}function g({logger:e},{value:t,label:n}){n?e(n,t):e(t)}function _(e=({context:e,event:t})=>({context:e,event:t}),t){function n(e,t){}return n.type=`xstate.log`,n.value=e,n.label=t,n.resolve=h,n.execute=g,n}e.SpecialTargets=o,e.emit=a,e.enqueueActions=m,e.forwardTo=f,e.log=_,e.sendParent=d,e.sendTo=u})),B=o((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=z(),n=su(),r=lu(),i=cu(),a=uu();ou();function o(e,t){return new r.StateMachine(e,t)}function s({schemas:e,actors:t,actions:r,guards:c,delays:l}){return{assign:i.assign,sendTo:a.sendTo,raise:n.raise,log:a.log,cancel:n.cancel,stopChild:n.stopChild,enqueueActions:a.enqueueActions,emit:a.emit,spawnChild:n.spawnChild,createStateConfig:e=>e,createAction:e=>e,createMachine:n=>o({...n,schemas:e},{actors:t,actions:r,guards:c,delays:l}),extend:n=>s({schemas:e,actors:t,actions:{...r,...n.actions},guards:{...c,...n.guards},delays:{...l,...n.delays}})}}e.createEmptyActor=t.createEmptyActor,e.fromCallback=t.fromCallback,e.fromEventObservable=t.fromEventObservable,e.fromObservable=t.fromObservable,e.fromPromise=t.fromPromise,e.fromTransition=t.fromTransition,e.Actor=n.Actor,e.__unsafe_getAllOwnEventDescriptors=n.getAllOwnEventDescriptors,e.and=n.and,e.cancel=n.cancel,e.createActor=n.createActor,e.getStateNodes=n.getStateNodes,e.interpret=n.interpret,e.isMachineSnapshot=n.isMachineSnapshot,e.matchesState=n.matchesState,e.not=n.not,e.or=n.or,e.pathToStateValue=n.pathToStateValue,e.raise=n.raise,e.spawnChild=n.spawnChild,e.stateIn=n.stateIn,e.stop=n.stop,e.stopChild=n.stopChild,e.toObserver=n.toObserver,e.StateMachine=r.StateMachine,e.StateNode=r.StateNode,e.assign=i.assign,e.SpecialTargets=a.SpecialTargets,e.emit=a.emit,e.enqueueActions=a.enqueueActions,e.forwardTo=a.forwardTo,e.log=a.log,e.sendParent=a.sendParent,e.sendTo=a.sendTo,e.setup=s}))();function du(e){return e&&(T(e)??e)}function fu(e,t=80){return e.length>t?`${e.slice(0,t)}...`:e}function pu(){return typeof location>`u`?``:location.origin+location.pathname}function mu(e){e&&typeof document<`u`&&(document.title=e)}function hu(e,t){return new URL(t,e.endsWith(`/`)?e:`${e}/`)}var gu={page:`voice`},_u=1e4;async function vu(e,t,n){let r=t??((e,t)=>globalThis.fetch(e,t));try{let t=await r(hu(e,yl).href,{signal:AbortSignal.timeout(_u),...n===void 0?{}:{headers:{[au]:n}}});if(!t.ok)return null;let i=bl.safeParse(await t.json());return i.success?i.data:null}catch{return null}}async function yu(e=pu(),t){return await vu(e,t)??gu}var bu=o((e=>{var t=Symbol.for(`react.transitional.element`),n=Symbol.for(`react.portal`),r=Symbol.for(`react.fragment`),i=Symbol.for(`react.strict_mode`),a=Symbol.for(`react.profiler`),o=Symbol.for(`react.consumer`),s=Symbol.for(`react.context`),c=Symbol.for(`react.forward_ref`),l=Symbol.for(`react.suspense`),u=Symbol.for(`react.memo`),d=Symbol.for(`react.lazy`),f=Symbol.for(`react.activity`),p=Symbol.for(`react.view_transition`),m=Symbol.iterator;function h(e){return typeof e!=`object`||!e?null:(e=m&&e[m]||e[`@@iterator`],typeof e==`function`?e:null)}var g={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},_=Object.assign,v={};function y(e,t,n){this.props=e,this.context=t,this.refs=v,this.updater=n||g}y.prototype.isReactComponent={},y.prototype.setState=function(e,t){if(typeof e!=`object`&&typeof e!=`function`&&e!=null)throw Error(`takes an object of state variables to update or a function which returns an object of state variables.`);this.updater.enqueueSetState(this,e,t,`setState`)},y.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,`forceUpdate`)};function b(){}b.prototype=y.prototype;function x(e,t,n){this.props=e,this.context=t,this.refs=v,this.updater=n||g}var ee=x.prototype=new b;ee.constructor=x,_(ee,y.prototype),ee.isPureReactComponent=!0;var S=Array.isArray;function C(){}var w={H:null,A:null,T:null,S:null},T=Object.prototype.hasOwnProperty;function te(e,n,r){var i=r.ref;return{$$typeof:t,type:e,key:n,ref:i===void 0?null:i,props:r}}function E(e,t){return te(e.type,t,e.props)}function ne(e){return typeof e==`object`&&!!e&&e.$$typeof===t}function re(e){var t={"=":`=0`,":":`=2`};return`$`+e.replace(/[=:]/g,function(e){return t[e]})}var ie=/\/+/g;function ae(e,t){return typeof e==`object`&&e&&e.key!=null?re(``+e.key):t.toString(36)}function oe(e){switch(e.status){case`fulfilled`:return e.value;case`rejected`:throw e.reason;default:switch(typeof e.status==`string`?e.then(C,C):(e.status=`pending`,e.then(function(t){e.status===`pending`&&(e.status=`fulfilled`,e.value=t)},function(t){e.status===`pending`&&(e.status=`rejected`,e.reason=t)})),e.status){case`fulfilled`:return e.value;case`rejected`:throw e.reason}}throw e}function se(e,r,i,a,o){var s=typeof e;(s===`undefined`||s===`boolean`)&&(e=null);var c=!1;if(e===null)c=!0;else switch(s){case`bigint`:case`string`:case`number`:c=!0;break;case`object`:switch(e.$$typeof){case t:case n:c=!0;break;case d:return c=e._init,se(c(e._payload),r,i,a,o)}}if(c)return o=o(e),c=a===``?`.`+ae(e,0):a,S(o)?(i=``,c!=null&&(i=c.replace(ie,`$&/`)+`/`),se(o,r,i,``,function(e){return e})):o!=null&&(ne(o)&&(o=E(o,i+(o.key==null||e&&e.key===o.key?``:(``+o.key).replace(ie,`$&/`)+`/`)+c)),r.push(o)),1;c=0;var l=a===``?`.`:a+`:`;if(S(e))for(var u=0;u<e.length;u++)a=e[u],s=l+ae(a,u),c+=se(a,r,i,s,o);else if(u=h(e),typeof u==`function`)for(e=u.call(e),u=0;!(a=e.next()).done;)a=a.value,s=l+ae(a,u++),c+=se(a,r,i,s,o);else if(s===`object`){if(typeof e.then==`function`)return se(oe(e),r,i,a,o);throw r=String(e),Error(`Objects are not valid as a React child (found: `+(r===`[object Object]`?`object with keys {`+Object.keys(e).join(`, `)+`}`:r)+`). If you meant to render a collection of children, use an array instead.`)}return c}function ce(e,t,n){if(e==null)return e;var r=[],i=0;return se(e,r,``,``,function(e){return t.call(n,e,i++)}),r}function le(e){if(e._status===-1){var t=e._result,n=t();n.then(function(t){(e._status===0||e._status===-1)&&(e._status=1,e._result=t,n.status===void 0&&(n.status=`fulfilled`,n.value=t))},function(t){(e._status===0||e._status===-1)&&(e._status=2,e._result=t,n.status===void 0&&(n.status=`rejected`,n.reason=t))}),e._status===-1&&(e._status=0,e._result=n)}if(e._status===1)return e._result.default;throw e._result}var ue=typeof reportError==`function`?reportError:function(e){if(typeof window==`object`&&typeof window.ErrorEvent==`function`){var t=new window.ErrorEvent(`error`,{bubbles:!0,cancelable:!0,message:typeof e==`object`&&e&&typeof e.message==`string`?String(e.message):String(e),error:e});if(!window.dispatchEvent(t))return}else if(typeof process==`object`&&typeof process.emit==`function`){process.emit(`uncaughtException`,e);return}console.error(e)};function de(e){var t=w.T,n={};n.types=t===null?null:t.types,w.T=n;try{var r=e(),i=w.S;i!==null&&i(n,r),typeof r==`object`&&r&&typeof r.then==`function`&&r.then(C,ue)}catch(e){ue(e)}finally{t!==null&&n.types!==null&&(t.types=n.types),w.T=t}}function fe(e){var t=w.T;if(t!==null){var n=t.types;n===null?t.types=[e]:n.indexOf(e)===-1&&n.push(e)}else de(fe.bind(null,e))}var pe={map:ce,forEach:function(e,t,n){ce(e,function(){t.apply(this,arguments)},n)},count:function(e){var t=0;return ce(e,function(){t++}),t},toArray:function(e){return ce(e,function(e){return e})||[]},only:function(e){if(!ne(e))throw Error(`React.Children.only expected to receive a single React element child.`);return e}};e.Activity=f,e.Children=pe,e.Component=y,e.Fragment=r,e.Profiler=a,e.PureComponent=x,e.StrictMode=i,e.Suspense=l,e.ViewTransition=p,e.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=w,e.__COMPILER_RUNTIME={__proto__:null,c:function(e){return w.H.useMemoCache(e)}},e.addTransitionType=fe,e.cache=function(e){return function(){return e.apply(null,arguments)}},e.cacheSignal=function(){return null},e.cloneElement=function(e,t,n){if(e==null)throw Error(`The argument must be a React element, but you passed `+e+`.`);var r=_({},e.props),i=e.key;if(t!=null)for(a in t.key!==void 0&&(i=``+t.key),t)!T.call(t,a)||a===`key`||a===`__self`||a===`__source`||a===`ref`&&t.ref===void 0||(r[a]=t[a]);var a=arguments.length-2;if(a===1)r.children=n;else if(1<a){for(var o=Array(a),s=0;s<a;s++)o[s]=arguments[s+2];r.children=o}return te(e.type,i,r)},e.createContext=function(e){return e={$$typeof:s,_currentValue:e,_currentValue2:e,_threadCount:0,Provider:null,Consumer:null},e.Provider=e,e.Consumer={$$typeof:o,_context:e},e},e.createElement=function(e,t,n){var r,i={},a=null;if(t!=null)for(r in t.key!==void 0&&(a=``+t.key),t)T.call(t,r)&&r!==`key`&&r!==`__self`&&r!==`__source`&&(i[r]=t[r]);var o=arguments.length-2;if(o===1)i.children=n;else if(1<o){for(var s=Array(o),c=0;c<o;c++)s[c]=arguments[c+2];i.children=s}if(e&&e.defaultProps)for(r in o=e.defaultProps,o)i[r]===void 0&&(i[r]=o[r]);return te(e,a,i)},e.createRef=function(){return{current:null}},e.forwardRef=function(e){return{$$typeof:c,render:e}},e.isValidElement=ne,e.lazy=function(e){return{$$typeof:d,_payload:{_status:-1,_result:e},_init:le}},e.memo=function(e,t){return{$$typeof:u,type:e,compare:t===void 0?null:t}},e.startTransition=de,e.unstable_useCacheRefresh=function(){return w.H.useCacheRefresh()},e.use=function(e){return w.H.use(e)},e.useActionState=function(e,t,n){return w.H.useActionState(e,t,n)},e.useCallback=function(e,t){return w.H.useCallback(e,t)},e.useContext=function(e){return w.H.useContext(e)},e.useDebugValue=function(){},e.useDeferredValue=function(e,t){return w.H.useDeferredValue(e,t)},e.useEffect=function(e,t){return w.H.useEffect(e,t)},e.useEffectEvent=function(e){return w.H.useEffectEvent(e)},e.useId=function(){return w.H.useId()},e.useImperativeHandle=function(e,t,n){return w.H.useImperativeHandle(e,t,n)},e.useInsertionEffect=function(e,t){return w.H.useInsertionEffect(e,t)},e.useLayoutEffect=function(e,t){return w.H.useLayoutEffect(e,t)},e.useMemo=function(e,t){return w.H.useMemo(e,t)},e.useOptimistic=function(e,t){return w.H.useOptimistic(e,t)},e.useReducer=function(e,t,n){return w.H.useReducer(e,t,n)},e.useRef=function(e){return w.H.useRef(e)},e.useState=function(e){return w.H.useState(e)},e.useSyncExternalStore=function(e,t,n){return w.H.useSyncExternalStore(e,t,n)},e.useTransition=function(){return w.H.useTransition()},e.version=`19.3.0`})),xu=o(((e,t)=>{t.exports=bu()})),Su=o((e=>{var t=xu();function n(e){var t=`https://react.dev/errors/`+e;if(1<arguments.length){t+=`?args[]=`+encodeURIComponent(arguments[1]);for(var n=2;n<arguments.length;n++)t+=`&args[]=`+encodeURIComponent(arguments[n])}return`Minified React error #`+e+`; visit `+t+` for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`}function r(){}var i={d:{f:r,r:function(){throw Error(n(522))},D:r,C:r,L:r,m:r,X:r,S:r,M:r},p:0,findDOMNode:null},a=Symbol.for(`react.portal`),o=Symbol.for(`react.recoverable`),s=Symbol.for(`react.optimistic_key`);function c(e,t,n){var r=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:a,key:r==null?null:r===s?s:``+r,children:e,containerInfo:t,implementation:n}}var l=t.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function u(e,t){if(e===`font`)return``;if(typeof t==`string`)return t===`use-credentials`?t:``}e.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=i,e.browser=function(e){return{$$typeof:o,_reason:e}},e.createPortal=function(e,t){var r=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!t||t.nodeType!==1&&t.nodeType!==9&&t.nodeType!==11)throw Error(n(299));return c(e,t,null,r)},e.flushSync=function(e){var t=l.T,n=i.p;try{if(l.T=null,i.p=2,e)return e()}finally{l.T=t,i.p=n,i.d.f()}},e.preconnect=function(e,t){typeof e==`string`&&(t?(t=t.crossOrigin,t=typeof t==`string`?t===`use-credentials`?t:``:void 0):t=null,i.d.C(e,t))},e.prefetchDNS=function(e){typeof e==`string`&&i.d.D(e)},e.preinit=function(e,t){if(typeof e==`string`&&t&&typeof t.as==`string`){var n=t.as,r=u(n,t.crossOrigin),a=typeof t.integrity==`string`?t.integrity:void 0,o=typeof t.fetchPriority==`string`?t.fetchPriority:void 0;n===`style`?i.d.S(e,typeof t.precedence==`string`?t.precedence:void 0,{crossOrigin:r,integrity:a,fetchPriority:o}):n===`script`&&i.d.X(e,{crossOrigin:r,integrity:a,fetchPriority:o,nonce:typeof t.nonce==`string`?t.nonce:void 0})}},e.preinitModule=function(e,t){if(typeof e==`string`){if(typeof t==`object`&&t){if(t.as==null||t.as===`script`){var n=u(t.as,t.crossOrigin);i.d.M(e,{crossOrigin:n,integrity:typeof t.integrity==`string`?t.integrity:void 0,nonce:typeof t.nonce==`string`?t.nonce:void 0,fetchPriority:typeof t.fetchPriority==`string`?t.fetchPriority:void 0})}}else t??i.d.M(e)}},e.preload=function(e,t){if(typeof e==`string`&&typeof t==`object`&&t&&typeof t.as==`string`){var n=t.as,r=u(n,t.crossOrigin);i.d.L(e,n,{crossOrigin:r,integrity:typeof t.integrity==`string`?t.integrity:void 0,nonce:typeof t.nonce==`string`?t.nonce:void 0,type:typeof t.type==`string`?t.type:void 0,fetchPriority:typeof t.fetchPriority==`string`?t.fetchPriority:void 0,referrerPolicy:typeof t.referrerPolicy==`string`?t.referrerPolicy:void 0,imageSrcSet:typeof t.imageSrcSet==`string`?t.imageSrcSet:void 0,imageSizes:typeof t.imageSizes==`string`?t.imageSizes:void 0,media:typeof t.media==`string`?t.media:void 0})}},e.preloadModule=function(e,t){if(typeof e==`string`){if(t){var n=u(t.as,t.crossOrigin);i.d.m(e,{as:typeof t.as==`string`&&t.as!==`script`?t.as:void 0,crossOrigin:n,integrity:typeof t.integrity==`string`?t.integrity:void 0,nonce:typeof t.nonce==`string`?t.nonce:void 0,fetchPriority:typeof t.fetchPriority==`string`?t.fetchPriority:void 0})}else i.d.m(e)}},e.requestFormReset=function(e){i.d.r(e)},e.unstable_batchedUpdates=function(e,t){return e(t)},e.useFormState=function(e,t,n){return l.H.useFormState(e,t,n)},e.useFormStatus=function(){return l.H.useHostTransitionStatus()},e.version=`19.3.0`})),Cu=o(((e,t)=>{function n(){if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<`u`&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE==`function`)try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(e){console.error(e)}}n(),t.exports=Su()})),wu=o((e=>{function t(e,t){var n=e.length;e.push(t);a:for(;0<n;){var r=n-1>>>1,a=e[r];if(0<i(a,t))e[r]=t,e[n]=a,n=r;else break a}}function n(e){return e.length===0?null:e[0]}function r(e){if(e.length===0)return null;var t=e[0],n=e.pop();if(n!==t){e[0]=n;a:for(var r=0,a=e.length,o=a>>>1;r<o;){var s=2*(r+1)-1,c=e[s],l=s+1,u=e[l];if(0>i(c,n))l<a&&0>i(u,c)?(e[r]=u,e[l]=n,r=l):(e[r]=c,e[s]=n,r=s);else if(l<a&&0>i(u,n))e[r]=u,e[l]=n,r=l;else break a}}return t}function i(e,t){var n=e.sortIndex-t.sortIndex;return n===0?e.id-t.id:n}if(e.unstable_now=void 0,typeof performance==`object`&&typeof performance.now==`function`){var a=performance;e.unstable_now=function(){return a.now()}}else{var o=Date,s=o.now();e.unstable_now=function(){return o.now()-s}}var c=[],l=[],u=1,d=null,f=3,p=!1,m=!1,h=!1,g=!1,_=typeof setTimeout==`function`?setTimeout:null,v=typeof clearTimeout==`function`?clearTimeout:null,y=typeof setImmediate<`u`?setImmediate:null;function b(e){for(var i=n(l);i!==null;){if(i.callback===null)r(l);else if(i.startTime<=e)r(l),i.sortIndex=i.expirationTime,t(c,i);else break;i=n(l)}}function x(e){if(h=!1,b(e),!m){if(n(c)!==null)m=!0,ee||(ee=!0,E());else{var t=n(l);t!==null&&ie(x,t.startTime-e)}}}var ee=!1,S=-1,C=5,w=-1;function T(){return g?!0:!(e.unstable_now()-w<C)}function te(){if(g=!1,ee){var t=e.unstable_now();w=t;var i=!0;try{a:{m=!1,h&&(h=!1,v(S),S=-1),p=!0;var a=f;try{b:{for(b(t),d=n(c);d!==null&&!(d.expirationTime>t&&T());){var o=d.callback;if(typeof o==`function`){d.callback=null,f=d.priorityLevel;var s=o(d.expirationTime<=t);if(t=e.unstable_now(),typeof s==`function`){d.callback=s,b(t),i=!0;break b}d===n(c)&&r(c),b(t)}else r(c);d=n(c)}if(d!==null)i=!0;else{var u=n(l);u!==null&&ie(x,u.startTime-t),i=!1}}break a}finally{d=null,f=a,p=!1}i=void 0}}finally{i?E():ee=!1}}}var E;if(typeof y==`function`)E=function(){y(te)};else if(typeof MessageChannel<`u`){var ne=new MessageChannel,re=ne.port2;ne.port1.onmessage=te,E=function(){re.postMessage(null)}}else E=function(){_(te,0)};function ie(t,n){S=_(function(){t(e.unstable_now())},n)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(e){e.callback=null},e.unstable_forceFrameRate=function(e){0>e||125<e?console.error(`forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported`):C=0<e?Math.floor(1e3/e):5},e.unstable_getCurrentPriorityLevel=function(){return f},e.unstable_next=function(e){switch(f){case 1:case 2:case 3:var t=3;break;default:t=f}var n=f;f=t;try{return e()}finally{f=n}},e.unstable_requestPaint=function(){g=!0},e.unstable_runWithPriority=function(e,t){switch(e){case 1:case 2:case 3:case 4:case 5:break;default:e=3}var n=f;f=e;try{return t()}finally{f=n}},e.unstable_scheduleCallback=function(r,i,a){var o=e.unstable_now();switch(typeof a==`object`&&a?(a=a.delay,a=typeof a==`number`&&0<a?o+a:o):a=o,r){case 1:var s=-1;break;case 2:s=250;break;case 5:s=1073741823;break;case 4:s=1e4;break;default:s=5e3}return s=a+s,r={id:u++,callback:i,priorityLevel:r,startTime:a,expirationTime:s,sortIndex:-1},a>o?(r.sortIndex=a,t(l,r),n(c)===null&&r===n(l)&&(h?(v(S),S=-1):h=!0,ie(x,a-o))):(r.sortIndex=s,t(c,r),m||p||(m=!0,ee||(ee=!0,E()))),r},e.unstable_shouldYield=T,e.unstable_wrapCallback=function(e){var t=f;return function(){var n=f;f=t;try{return e.apply(this,arguments)}finally{f=n}}}})),Tu=o(((e,t)=>{t.exports=wu()})),Eu=o((e=>{var t=Tu(),n=xu(),r=Cu();function i(e){var t=`https://react.dev/errors/`+e;if(1<arguments.length){t+=`?args[]=`+encodeURIComponent(arguments[1]);for(var n=2;n<arguments.length;n++)t+=`&args[]=`+encodeURIComponent(arguments[n])}return`Minified React error #`+e+`; visit `+t+` for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`}function a(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function o(e){for(var t=e,n=t;n&&!n.alternate;)t=n,t.flags&4098&&(e=t.return),n=t.return;for(;t.return;)t=t.return;return t.tag===3?e:null}function s(e){if(e.tag===13){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function c(e){if(e.tag===31){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function l(e){if(o(e)!==e)throw Error(i(188))}function u(e){var t=e.alternate;if(!t){if(t=o(e),t===null)throw Error(i(188));return t===e?e:null}for(var n=e,r=t;;){var a=n.return;if(a===null)break;var s=a.alternate;if(s===null){if(r=a.return,r!==null){n=r;continue}break}if(a.child===s.child){for(s=a.child;s;){if(s===n)return l(a),e;if(s===r)return l(a),t;s=s.sibling}throw Error(i(188))}if(n.return!==r.return)n=a,r=s;else{for(var c=!1,u=a.child;u;){if(u===n){c=!0,n=a,r=s;break}if(u===r){c=!0,r=a,n=s;break}u=u.sibling}if(!c){for(u=s.child;u;){if(u===n){c=!0,n=s,r=a;break}if(u===r){c=!0,r=s,n=a;break}u=u.sibling}if(!c)throw Error(i(189))}}if(n.alternate!==r)throw Error(i(190))}if(n.tag!==3)throw Error(i(188));return n.stateNode.current===n?e:t}function d(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e;for(e=e.child;e!==null;){if(t=d(e),t!==null)return t;e=e.sibling}return null}function f(e,t,n,r,i,a){for(;e!==null;){if((e.tag===5||e.tag===27||e.tag===6)&&n(e,r,i,a)||(e.tag!==22||e.memoizedState===null)&&(t||e.tag!==5&&e.tag!==27)&&f(e.child,t,n,r,i,a))return!0;e=e.sibling}return!1}function p(e){for(e=e.return;e!==null;){if(e.tag===3||e.tag===5||e.tag===27)return e;e=e.return}return null}function m(e){var t=!1;for(e=e.return;e!==null&&(e.tag===4&&(t=!0),e.tag!==3&&e.tag!==5&&e.tag!==27);)e=e.return;return t}function h(e){var t=[null,null],n=p(e);return n===null||g(t,e,n.child,{foundSelf:!1}),t}function g(e,t,n,r){for(;n!==null;){if(n===t)r.foundSelf=!0;else if(n.tag===5||n.tag===27||n.tag===6){if(r.foundSelf)return e[1]=n,!0;e[0]=n}else if((n.tag!==22||n.memoizedState===null)&&g(e,t,n.child,r))return!0;n=n.sibling}return!1}function _(e){switch(e.tag){case 5:case 27:case 6:return e.stateNode;case 3:return e.stateNode.containerInfo;default:throw Error(i(559))}}var v=null,y=null;function b(e,t,n){return e===n||e===t&&(v=e,!0)}function x(e,t,n){return e===n?(y=e,!1):e===t&&(y!==null&&(v=e),!0)}function ee(e){if(e===null)return null;do e=e===null?null:e.return;while(e&&e.tag!==5&&e.tag!==27&&e.tag!==3);return e||null}function S(e,t,n){for(var r=0,i=e;i;i=n(i))r++;i=0;for(var a=t;a;a=n(a))i++;for(;0<r-i;)e=n(e),r--;for(;0<i-r;)t=n(t),i--;for(;r--;){if(e===t||t!==null&&e===t.alternate)return e;e=n(e),t=n(t)}return null}var C=Object.assign,w=Symbol.for(`react.element`),T=Symbol.for(`react.transitional.element`),te=Symbol.for(`react.portal`),E=Symbol.for(`react.fragment`),ne=Symbol.for(`react.strict_mode`),re=Symbol.for(`react.profiler`),ie=Symbol.for(`react.consumer`),ae=Symbol.for(`react.context`),oe=Symbol.for(`react.forward_ref`),se=Symbol.for(`react.suspense`),ce=Symbol.for(`react.suspense_list`),le=Symbol.for(`react.memo`),ue=Symbol.for(`react.lazy`),de=Symbol.for(`react.activity`),fe=Symbol.for(`react.legacy_hidden`),pe=Symbol.for(`react.memo_cache_sentinel`),me=Symbol.for(`react.view_transition`),he=Symbol.for(`react.recoverable`),ge=Symbol.iterator;function _e(e){return typeof e!=`object`||!e?null:(e=ge&&e[ge]||e[`@@iterator`],typeof e==`function`?e:null)}var ve=Symbol.for(`react.client.reference`);function ye(e){if(e==null)return null;if(typeof e==`function`)return e.$$typeof===ve?null:e.displayName||e.name||null;if(typeof e==`string`)return e;switch(e){case E:return`Fragment`;case re:return`Profiler`;case ne:return`StrictMode`;case se:return`Suspense`;case ce:return`SuspenseList`;case de:return`Activity`;case me:return`ViewTransition`}if(typeof e==`object`)switch(e.$$typeof){case te:return`Portal`;case ae:return e.displayName||`Context`;case ie:return(e._context.displayName||`Context`)+`.Consumer`;case oe:var t=e.render;return e=e.displayName,e||=(e=t.displayName||t.name||``,e===``?`ForwardRef`:`ForwardRef(`+e+`)`),e;case le:return t=e.displayName||null,t===null?ye(e.type)||`Memo`:t;case ue:t=e._payload,e=e._init;try{return ye(e(t))}catch{}}return null}var be=Array.isArray,D=n.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,O=r.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,xe={pending:!1,data:null,method:null,action:null},Se=[],Ce=-1;function we(e){return{current:e}}function Te(e){0>Ce||(e.current=Se[Ce],Se[Ce]=null,Ce--)}function Ee(e,t){Ce++,Se[Ce]=e.current,e.current=t}var De=we(null),Oe=we(null),ke=we(null),Ae=we(null);function je(e,t){switch(Ee(ke,t),Ee(Oe,e),Ee(De,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?pp(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)t=pp(t),e=mp(t,e);else switch(e){case`svg`:e=1;break;case`math`:e=2;break;default:e=0}}Te(De),Ee(De,e)}function Me(){Te(De),Te(Oe),Te(ke)}function Ne(e){var t=e.memoizedState;t!==null&&(sh._currentValue=t.memoizedState,Ee(Ae,e)),t=De.current;var n=mp(t,e.type);t!==n&&(Ee(Oe,e),Ee(De,n))}function Pe(e){Oe.current===e&&(Te(De),Te(Oe)),Ae.current===e&&(Te(Ae),sh._currentValue=xe)}var Fe,Ie;function Le(e){if(Fe===void 0)try{throw Error()}catch(e){var t=e.stack.trim().match(/\n( *(at )?)/);Fe=t&&t[1]||``,Ie=-1<e.stack.indexOf(`
56
+ 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}r.count>1&&e.reused===`ref`&&a(n)}e.external&&(e.sharedDefsExtractedFor=e.external)}function jo(e){let t=e.anyOf;if(!Array.isArray(t)||t.length===0||e.type!==void 0)return;let n=[];for(let e of t){if(!e||typeof e!=`object`)return;jo(e);let t=Object.keys(e);if(t.length!==1||t[0]!==`type`)return;let r=e.type;for(let e of Array.isArray(r)?r:[r]){if(typeof e!=`string`)return;n.includes(e)||n.push(e)}}delete e.anyOf,e.type=n.length===1?n[0]:n}var Mo=new Set([`type`,`properties`,`required`,`additionalProperties`]),No=[`oneOf`,`anyOf`];function Po(e){let t=e.additionalProperties;return t===void 0||t===!1||typeof t!=`object`||!t?null:Object.keys(t).length?t:null}function Fo(e){let t=[];for(let n of e){if(typeof n!=`object`||n.type!==`object`)return null;for(let e in n)if(!Mo.has(e))return null;t.push(n)}let n={},r=new Set;for(let e of t){for(let r in e.properties){if(Object.prototype.hasOwnProperty.call(n,r))continue;let e=[];for(let n of t){let t=n.properties?.[r]??Po(n);t!=null&&(e.some(e=>JSON.stringify(e)===JSON.stringify(t))||e.push(t))}ze(n,r,e.length===1?e[0]:Fo(e)??{allOf:e})}for(let t of e.required??[])r.add(t)}let i={type:`object`,properties:n};if(r.size&&(i.required=[...r]),t.every(e=>e.additionalProperties===!1))i.additionalProperties=!1;else{let e=[];for(let n of t){let t=Po(n);t&&!e.some(e=>JSON.stringify(e)===JSON.stringify(t))&&e.push(t)}e.length===1?i.additionalProperties=e[0]:e.length>1&&(i.additionalProperties={allOf:e})}return i}function Io(e){let t=e.allOf;if(!Array.isArray(t)||t.length<2)return;for(let t of Mo)if(t in e)return;let n=t.filter(e=>No.some(t=>Array.isArray(e[t]))),r=null;if(!n.length)r=Fo(t);else{let e=n[0],i=No.find(t=>Array.isArray(e[t]));if(Object.keys(e).length!==1)return;let a=t.filter(t=>t!==e),o=e[i].map(e=>Fo([...a,e]));if(o.some(e=>!e))return;r={[i]:o}}r&&(delete e.allOf,To(e,r))}function Lo(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)):To(i,s),To(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??[]})};if(!e.external||e.sharedEmitDoneFor!==e.external){for(let t of[...e.seen.entries()].reverse())r(t[0]);if(e.target!==`openapi-3.0`)for(let t of e.seen.entries())jo(t[1].def??t[1].schema);for(let t of e.deferred)t();if(e.intersections.length){let t=new Map;for(let n of e.seen.values())for(let e of[n.schema,n.def]){let n=e?.allOf;if(!Array.isArray(n))continue;let r=t.get(n);r?r.push(e):t.set(n,[e])}for(let n of e.intersections)for(let e of t.get(n)??[])Io(e)}}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)}To(i,n.defId?n.schema: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??{};if(!e.external||e.sharedEmitDoneFor!==e.external)for(let t of e.seen.entries()){let e=t[1];e.def&&e.defId&&(e.def.id===e.defId&&delete e.def.id,ze(o,e.defId,e.def))}e.external&&(e.sharedEmitDoneFor=e.external),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:Bo(t,`input`,e.processors),output:Bo(t,`output`,e.processors)}},enumerable:!1,writable:!1}),n}catch{throw Error(`Error converting schema to JSON.`)}}function Ro(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 Ro(r.element,n);if(r.type===`set`)return Ro(r.valueType,n);if(r.type===`lazy`)return Ro(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`||r.type===`catch`)return Ro(r.innerType,n);if(r.type===`intersection`)return Ro(r.left,n)||Ro(r.right,n);if(r.type===`record`||r.type===`map`)return Ro(r.keyType,n)||Ro(r.valueType,n);if(r.type===`pipe`)return e._zod.traits.has(`$ZodCodec`)?!0:Ro(r.in,n)||Ro(r.out,n);if(r.type===`object`){for(let e in r.shape)if(Ro(r.shape[e],n))return!0;return!1}if(r.type===`union`){for(let e of r.options)if(Ro(e,n))return!0;return!1}if(r.type===`tuple`){for(let e of r.items)if(Ro(e,n))return!0;return!!(r.rest&&Ro(r.rest,n))}return!1}var zo=(e,t={})=>n=>{let r=Eo({...n,processors:t});return Oo(e,r),Ao(r,e),Lo(r,e)},Bo=(e,t,n={})=>r=>{let{libraryOptions:i,target:a}=r??{},o=Eo({...i??{},target:a,io:t,processors:n});return Oo(e,o),Ao(o,e),Lo(o,e)},Vo=(e,t,n)=>{(e[t]===void 0||n>e[t])&&(e[t]=n)},Ho=(e,t,n)=>{(e[t]===void 0||n<e[t])&&(e[t]=n)},Uo=(e,t)=>{Vo(e,`minimum`,t),Ho(e,`maximum`,t)},Wo=(e,t)=>{e.multipleOf??=[],e.multipleOf.includes(t)||e.multipleOf.push(t)},I=(e,t)=>{e.patterns??=new Set,e.patterns.add(t)},Go=(e,t)=>{e.mime=e.mime?e.mime.filter(e=>t.includes(e)):[...t]},Ko=(e,t)=>{e.format=t,t.includes(`int`)&&(e.isInt=!0)},qo=(e,t)=>Vo(e,`minimum`,t.minimum),Jo=(e,t)=>Ho(e,`maximum`,t.maximum),Yo=e=>(t,n)=>{Ko(t,n.format);let[r,i]=e[n.format];Vo(t,`minimum`,r),Ho(t,`maximum`,i)},Xo={greater_than:(e,t)=>Vo(e,t.inclusive?`minimum`:`exclusiveMinimum`,t.value),less_than:(e,t)=>Ho(e,t.inclusive?`maximum`:`exclusiveMaximum`,t.value),multiple_of:(e,t)=>Wo(e,t.value),number_format:Yo(at),bigint_format:Yo(ot),min_length:qo,max_length:Jo,length_equals:(e,t)=>Uo(e,t.length),min_size:qo,max_size:Jo,size_equals:(e,t)=>Uo(e,t.size),string_format:(e,t)=>{Ko(e,t.format),t.pattern&&I(e,t.pattern),(t.format===`base64`||t.format===`base64url`)&&(e.contentEncoding=t.format),(t.local||t.precision===-1)&&(e.laxFormat=!0)},mime_type:(e,t)=>Go(e,t.mime)};function Zo(e){let t={},n=e._zod.def,r=e._zod.traits.has(`$ZodCheck`)?[e,...n.checks??[]]:n.checks??[];for(let e of r)Xo[e._zod.def.check]?.(t,e._zod.def);let i=e._zod.bag;i.minimum!==void 0&&Vo(t,`minimum`,i.minimum),i.exclusiveMinimum!==void 0&&Vo(t,`exclusiveMinimum`,i.exclusiveMinimum),i.maximum!==void 0&&Ho(t,`maximum`,i.maximum),i.exclusiveMaximum!==void 0&&Ho(t,`exclusiveMaximum`,i.exclusiveMaximum),i.multipleOf!==void 0&&Wo(t,i.multipleOf),i.format!==void 0&&(t.format??=i.format,i.format.includes(`int`)&&(t.isInt=!0)),i.mime&&Go(t,i.mime);for(let e of i.patterns??[])I(t,e);return t}var Qo={guid:`uuid`,url:`uri`,datetime:`date-time`,json_string:`json-string`,regex:``},$o=new Map([[ri,Rn],[ai,zn]]),es=e=>$o.get(e)??e,ts=(e,t,n,r)=>{let i=n;i.type=`string`;let{minimum:a,maximum:o,format:s,patterns:c,contentEncoding:l,laxFormat:u}=Zo(e);if(typeof a==`number`&&(i.minLength=a),typeof o==`number`&&(i.maxLength=o),s&&(i.format=Qo[s]??s,i.format===``&&delete i.format,(s===`time`||u)&&delete i.format),l&&(i.contentEncoding=l),c&&c.size>0){let e=[...c].map(es);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}))])}},ns=(e,t,n,r)=>{let i=n,{minimum:a,maximum:o,multipleOf:s,exclusiveMaximum:c,exclusiveMinimum:l,isInt:u}=Zo(e);i.type=u?`integer`:`number`;let d=typeof l==`number`&&l>=(a??-1/0),f=typeof c==`number`&&c<=(o??1/0),p=t.target===`draft-04`||t.target===`openapi-3.0`;if(d?p?(i.minimum=l,i.exclusiveMinimum=!0):i.exclusiveMinimum=l:typeof a==`number`&&(i.minimum=a),f?p?(i.maximum=c,i.exclusiveMaximum=!0):i.exclusiveMaximum=c:typeof o==`number`&&(i.maximum=o),s){let n=new Set;for(let a of s)Number.isFinite(a)&&a!==0?n.add(Math.abs(a)):Do(e,t,i,r,`A multipleOf divisor of ${a} cannot be represented in JSON Schema`);let[a,...o]=n;a!==void 0&&(i.multipleOf=a),o.length&&(i.allOf=[...i.allOf??[],...o.map(e=>({multipleOf:e}))])}},rs=(e,t,n,r)=>{n.type=`boolean`},is=(e,t,n,r)=>{t.target===`openapi-3.0`?(n.type=`string`,n.nullable=!0,n.enum=[null]):n.type=`null`},as=(e,t,n,r)=>{n.not={}},os=(e,t,n,r)=>{let i=e._zod.def,a=je(i.entries);if(a.length===0){n.not={};return}a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),n.enum=a},ss=(e,t,n,r)=>{let i=e._zod.def;if(i.values.length===0){n.not={};return}let a=[];for(let o of i.values)if(o===void 0){if(Do(e,t,n,r,"Literal `undefined` cannot be represented in JSON Schema"))return}else if(typeof o==`bigint`){if(Do(e,t,n,r,`BigInt literals cannot be represented in JSON Schema`))return;a.push(Number(o))}else a.push(o);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}},cs=(e,t,n,r)=>{Do(e,t,n,r,`Custom types cannot be represented in JSON Schema`)},ls=(e,t,n,r)=>{Do(e,t,n,r,`Transforms cannot be represented in JSON Schema`)},us=(e,t,n,r)=>{let i=n,a=e._zod.def,{minimum:o,maximum:s}=Zo(e);typeof o==`number`&&(i.minItems=o),typeof s==`number`&&(i.maxItems=s),i.type=`array`,i.items=Oo(a.element,t,{...r,path:[...r.path,`items`]})};function ds(e){let t=e._zod.def;return t.type===`pipe`&&t.in._zod.traits.has(`$ZodTransform`)?ds(t.out):t.type===`catch`?ds(t.innerType):e._zod.optin}var fs=(e,t,n,r)=>{let i=n,a=e._zod.def,o=a.shape;if(Object.getOwnPropertySymbols(o).length&&Do(e,t,i,r,`Symbol keys cannot be represented in JSON Schema`))return;i.type=`object`,i.properties={};for(let e in o)ze(i.properties,e,Oo(o[e],t,{...r,path:[...r.path,`properties`,e]}));let s=[];for(let e of Object.keys(o)){let n=a.shape[e];(t.io===`input`?ds(n)===void 0:n._zod.optout===void 0)&&s.push(e)}s.length>0&&(i.required=s),a.catchall?._zod.def.type===`never`?i.additionalProperties=!1:a.catchall?a.catchall&&(i.additionalProperties=Oo(a.catchall,t,{...r,path:[...r.path,`additionalProperties`]})):t.io===`output`&&(i.additionalProperties=!1)},ps=(e,t,n,r)=>{let i=e._zod.def,a=i.inclusive===!1,o=i.options.map((e,n)=>Oo(e,t,{...r,path:[...r.path,a?`oneOf`:`anyOf`,n]}));a?n.oneOf=o:n.anyOf=o},ms=(e,t,n,r)=>{let i=e._zod.def,a=Oo(i.left,t,{...r,path:[...r.path,`allOf`,0]}),o=Oo(i.right,t,{...r,path:[...r.path,`allOf`,1]}),s=e=>`allOf`in e&&Object.keys(e).length===1,c=[...s(a)?a.allOf:[a],...s(o)?o.allOf:[o]];n.allOf=c,t.intersections.push(c)};function hs(e,t,n){if(t.$ref){if(n.has(t))return t;n.add(t);let r=e.get(t)?.def;if(!r)return t;let i=hs(e,r,n);return i===r?t:i}for(let r of[`anyOf`,`oneOf`]){let i=t[r];if(!Array.isArray(i))continue;let a=i.map(t=>hs(e,t,n));a.some((e,t)=>e!==i[t])&&(t={...t,[r]:a})}let r=Array.isArray(t.type)?t.type:[t.type],i=!r.includes(`string`)&&r.some(e=>e===`number`||e===`integer`),a=t.enum??(t.const===void 0?void 0:[t.const]);if(!i&&!a?.some(e=>typeof e==`number`))return t;let{minimum:o,maximum:s,exclusiveMinimum:c,exclusiveMaximum:l,multipleOf:u,format:d,id:f,...p}=t;return p.enum?p.enum=p.enum.map(e=>typeof e==`number`?String(e):e):typeof p.const==`number`&&(p.const=String(p.const)),i?(p.type=`string`,a||(p.pattern=(r.includes(`number`)?Xn:Yn).source),p):p}var gs=new WeakMap;function _s(e){let t=new Map;for(let n of e.seen.values())n.def&&!t.has(n.schema)&&t.set(n.schema,n);let n=new Map;for(let r of gs.get(e)??[]){let i=e.seen.get(r),a=(i?.def??i?.schema)?.propertyNames;if(!a||a===!0||n.has(a))continue;let o=hs(t,a,new Set);o!==a&&n.set(a,o)}if(n.size)for(let t of e.seen.values())for(let e of[t.schema,t.def]){let t=e&&n.get(e.propertyNames);t&&(e.propertyNames=t)}}var vs=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`object`;let o=a.keyType,s=Zo(o).patterns;if(a.mode===`loose`&&s&&s.size>0){let e=Oo(a.valueType,t,{...r,path:[...r.path,`patternProperties`,`*`]});i.patternProperties={};for(let t of s)ze(i.patternProperties,es(t).source,e)}else{if(t.target===`draft-07`||t.target===`draft-2020-12`){i.propertyNames=Oo(a.keyType,t,{...r,path:[...r.path,`propertyNames`]});let n=gs.get(t);n||(n=[],gs.set(t,n),t.deferred.push(()=>_s(t))),n.push(e)}i.additionalProperties=Oo(a.valueType,t,{...r,path:[...r.path,`additionalProperties`]})}let c=o._zod.values,l=t.io===`input`&&ds(a.valueType)!==void 0;if(c&&!a.partial&&!l){let e=[...c].filter(e=>typeof e==`string`||typeof e==`number`);e.length>0&&(i.required=e.map(String))}},ys=(e,t,n,r)=>{let i=e._zod.def,a=Oo(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`}]},bs=(e,t,n,r)=>{let i=e._zod.def;Oo(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},xs=Symbol();function Ss(e,t,n,r,i){let a=!1,o=JSON.stringify(e,(e,t)=>typeof t==`bigint`?(a=!0,null):t);return a?(Do(t,n,r,i,`BigInt defaults cannot be represented in JSON Schema`),xs):JSON.parse(o)}var Cs=(e,t,n,r)=>{let i=e._zod.def;Oo(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o=Ss(i.defaultValue,e,t,n,r);o!==xs&&(n.default=o)},ws=(e,t,n,r)=>{let i=e._zod.def;Oo(i.innerType,t,r);let a=t.seen.get(e);if(a.ref=i.innerType,t.io!==`input`)return;let o=Ss(i.defaultValue,e,t,n,r);o!==xs&&(n._prefault=o)},Ts=(e,t,n,r)=>{let i=e._zod.def;Oo(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o;try{o=i.catchValue(void 0)}catch{Do(e,t,n,r,`Dynamic catch values are not supported in JSON Schema`);return}n.default=o},Es=(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;Oo(o,t,r);let s=t.seen.get(e);s.ref=o},Ds=(e,t,n,r)=>{let i=e._zod.def;Oo(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.readOnly=!0},Os=(e,t,n,r)=>{let i=e._zod.def;Oo(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},ks=new WeakSet([Object.prototype,Error.prototype]);function As(e,t,n){Object.defineProperty(e,t,{configurable:!0,enumerable:!1,get(){let e=n(this);return Object.defineProperty(this,t,{value:e,configurable:!0,writable:!0}),e},set(e){Object.defineProperty(this,t,{value:e,configurable:!0,writable:!0})}})}var js=M(`ZodError`,(e,t)=>{Zt.init(e,t),e.name=`ZodError`;let n=Object.getPrototypeOf(e);ks.has(n)||(ks.add(n),As(n,`format`,e=>t=>en(e,t)),As(n,`flatten`,e=>t=>$t(e,t)),As(n,`addIssue`,e=>t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,Ne,2)}),As(n,`addIssues`,e=>t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,Ne,2)}),Object.defineProperty(n,"isEmpty",{configurable:!0,enumerable:!1,get(){return this.issues.length===0}}))},void 0,{Parent:Error}),Ms=nn(js),Ns=rn(js),Ps=an(js),Fs=sn(js),Is=pn(js),Ls=mn(js),Rs=hn(js),zs=gn(js),Bs=_n(js),Vs=vn(js),Hs=yn(js),Us=bn(js);function Ws(){Wt.localeError||Gt(ha())}function Gs(){Wt.memoizer||Gt({memoizer:fa()})}var Ks=M(`ZodType`,(e,t)=>(Ws(),xr.init(e,t),e.def=t,e.type=t.type,e),{check(...e){let t=this.def;return this.clone(Ke(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(pl(e,t))},superRefine(e,t){return this.check(ml(e,t))},overwrite(e){return this.check(ho(e))},optional(){return Yc(this)},exactOptional(){return Zc(this)},nullable(){return $c(this)},nullish(){return Yc($c(this))},nonoptional(e){return al(this,e)},array(){return Mc(this)},or(e){return Fc([this,e])},and(e){return zc(this,e)},transform(e){return ll(this,qc(e))},default(e){return tl(this,e)},prefault(e){return rl(this,e)},catch(e){return sl(this,e)},pipe(e){return ll(this,e)},readonly(){return dl(this)},describe(e){let t=this.clone();return ya.add(t,{description:e}),t},meta(...e){if(e.length===0)return ya.get(this);let t=this.clone();return ya.add(t,e[0]),t},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(e,...t){return t.length===0?e(this):e(this,...t)},get"~standard"(){return Ot(this,`~standard`,{...wr(this),jsonSchema:{input:Bo(this,`input`),output:Bo(this,`output`)}})},set"~standard"(e){A(this,`~standard`,e)},parse:function e(t,n){return Ms(this,t,n,{callee:e})},parseAsync:async function e(t,n){return await Ns(this,t,n,{callee:e})},safeParse(e,t){return Ps(this,e,t)},async safeParseAsync(e,t){return Fs(this,e,t)},get spa(){return this?.safeParseAsync},set spa(e){A(this,`spa`,e)},validate(e,t){return un(this,e,t)},validateAsync(e,t){return fn(this,e,t)},encode:function e(t,n){return Is(this,t,n,{callee:e})},decode:function e(t,n){return Ls(this,t,n,{callee:e})},encodeAsync:async function e(t,n){return await Rs(this,t,n,{callee:e})},decodeAsync:async function e(t,n){return await zs(this,t,n,{callee:e})},safeEncode(e,t){return Bs(this,e,t)},safeDecode(e,t){return Vs(this,e,t)},async safeEncodeAsync(e,t){return Hs(this,e,t)},async safeDecodeAsync(e,t){return Us(this,e,t)},toJSONSchema(e){return zo(this,{})(e)},get description(){return ya.get(this)?.description},get _def(){return this._zod.def}}),qs=M(`_ZodString`,(e,t)=>{Tr.init(e,t),Ks.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ts(e,t,n,r)},kt({format:e=>Zo(e).format??null,minLength:e=>Zo(e).minimum??null,maxLength:e=>Zo(e).maximum??null},{regex(...e){return this.check(co(...e))},includes(...e){return this.check(fo(...e))},startsWith(...e){return this.check(po(...e))},endsWith(...e){return this.check(mo(...e))},min(...e){return this.check(oo(...e))},max(...e){return this.check(ao(...e))},length(...e){return this.check(so(...e))},nonempty(...e){return this.check(oo(1,...e))},lowercase(e){return this.check(lo(e))},uppercase(e){return this.check(uo(e))},trim(){return this.check(_o())},normalize(...e){return this.check(go(...e))},toLowerCase(){return this.check(vo())},toUpperCase(){return this.check(yo())},slugify(){return this.check(bo())}})),Js=M(`ZodString`,(e,t)=>{Tr.init(e,t),qs.init(e,t)},{email(e){return this.check(Sa(ec,e))},url(e){return this.check(Oa(rc,e))},jwt(e){return this.check(Ua(vc,e))},emoji(e){return this.check(ka(ic,e))},guid(e){return this.check(Ca(tc,e))},uuid(e){return this.check(wa(nc,e))},uuidv4(e){return this.check(Ta(nc,e))},uuidv6(e){return this.check(Ea(nc,e))},uuidv7(e){return this.check(Da(nc,e))},nanoid(e){return this.check(Aa(ac,e))},cuid(e){return this.check(ja(oc,e))},cuid2(e){return this.check(Ma(sc,e))},ulid(e){return this.check(Na(cc,e))},base64(e){return this.check(Ba(hc,e))},base64url(e){return this.check(Va(gc,e))},xid(e){return this.check(Pa(lc,e))},ksuid(e){return this.check(Fa(uc,e))},ipv4(e){return this.check(Ia(dc,e))},ipv6(e){return this.check(La(fc,e))},cidrv4(e){return this.check(Ra(pc,e))},cidrv6(e){return this.check(za(mc,e))},e164(e){return this.check(Ha(_c,e))},datetime(e){return this.check(Wa(Xs,e))},date(e){return this.check(Ga(Zs,e))},time(e){return this.check(Ka(Qs,e))},duration(e){return this.check(qa($s,e))}});function L(e){return xa(Js,e)}var Ys=M(`ZodStringFormat`,(e,t)=>{Er.init(e,t),qs.init(e,t)}),Xs=M(`ZodISODateTime`,(e,t)=>{Gr.init(e,t),Ys.init(e,t)}),Zs=M(`ZodISODate`,(e,t)=>{Kr.init(e,t),Ys.init(e,t)}),Qs=M(`ZodISOTime`,(e,t)=>{qr.init(e,t),Ys.init(e,t)}),$s=M(`ZodISODuration`,(e,t)=>{Jr.init(e,t),Ys.init(e,t)}),ec=M(`ZodEmail`,(e,t)=>{kr.init(e,t),Ys.init(e,t)}),tc=M(`ZodGUID`,(e,t)=>{Dr.init(e,t),Ys.init(e,t)}),nc=M(`ZodUUID`,(e,t)=>{Or.init(e,t),Ys.init(e,t)}),rc=M(`ZodURL`,(e,t)=>{Lr.init(e,t),Ys.init(e,t)}),ic=M(`ZodEmoji`,(e,t)=>{Rr.init(e,t),Ys.init(e,t)}),ac=M(`ZodNanoID`,(e,t)=>{zr.init(e,t),Ys.init(e,t)}),oc=M(`ZodCUID`,(e,t)=>{Br.init(e,t),Ys.init(e,t)}),sc=M(`ZodCUID2`,(e,t)=>{Vr.init(e,t),Ys.init(e,t)}),cc=M(`ZodULID`,(e,t)=>{Hr.init(e,t),Ys.init(e,t)}),lc=M(`ZodXID`,(e,t)=>{Ur.init(e,t),Ys.init(e,t)}),uc=M(`ZodKSUID`,(e,t)=>{Wr.init(e,t),Ys.init(e,t)}),dc=M(`ZodIPv4`,(e,t)=>{Yr.init(e,t),Ys.init(e,t)}),fc=M(`ZodIPv6`,(e,t)=>{Qr.init(e,t),Ys.init(e,t)}),pc=M(`ZodCIDRv4`,(e,t)=>{$r.init(e,t),Ys.init(e,t)}),mc=M(`ZodCIDRv6`,(e,t)=>{ti.init(e,t),Ys.init(e,t)}),hc=M(`ZodBase64`,(e,t)=>{ii.init(e,t),Ys.init(e,t)}),gc=M(`ZodBase64URL`,(e,t)=>{si.init(e,t),Ys.init(e,t)}),_c=M(`ZodE164`,(e,t)=>{ci.init(e,t),Ys.init(e,t)}),vc=M(`ZodJWT`,(e,t)=>{ui.init(e,t),Ys.init(e,t)}),yc=M(`ZodNumber`,(e,t)=>{di.init(e,t),Ks.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ns(e,t,n,r),e.isFinite=!0},kt({minValue:e=>{let{minimum:t,exclusiveMinimum:n}=Zo(e);return Math.max(t??-1/0,n??-1/0)},maxValue:e=>{let{maximum:t,exclusiveMaximum:n}=Zo(e);return Math.min(t??1/0,n??1/0)},isInt:e=>{let{isInt:t,multipleOf:n}=Zo(e);return!!t||!!n?.some(Number.isSafeInteger)},format:e=>Zo(e).format??null},{gt(e,t){return this.check(no(e,t))},gte(e,t){return this.check(ro(e,t))},min(e,t){return this.check(ro(e,t))},lt(e,t){return this.check(eo(e,t))},lte(e,t){return this.check(to(e,t))},max(e,t){return this.check(to(e,t))},int(e){return this.check(Sc(e))},safe(e){return this.check(Sc(e))},positive(e){return this.check(no(0,e))},nonnegative(e){return this.check(ro(0,e))},negative(e){return this.check(eo(0,e))},nonpositive(e){return this.check(to(0,e))},multipleOf(e,t){return this.check(io(e,t))},step(e,t){return this.check(io(e,t))},finite(){return this}}));function bc(e){return Ja(yc,e)}var xc=M(`ZodNumberFormat`,(e,t)=>{fi.init(e,t),yc.init(e,t)});function Sc(e){return Ya(xc,e)}var Cc=M(`ZodBoolean`,(e,t)=>{pi.init(e,t),Ks.init(e,t),e._zod.processJSONSchema=(t,n,r)=>rs(e,t,n,r)});function wc(e){return Xa(Cc,e)}var Tc=M(`ZodNull`,(e,t)=>{mi.init(e,t),Ks.init(e,t),e._zod.processJSONSchema=(t,n,r)=>is(e,t,n,r)});function Ec(e){return Za(Tc,e)}var Dc=M(`ZodUnknown`,(e,t)=>{hi.init(e,t),Ks.init(e,t),e._zod.processJSONSchema=(e,t,n)=>void 0});function Oc(){return Qa(Dc)}var kc=M(`ZodNever`,(e,t)=>{gi.init(e,t),Ks.init(e,t),e._zod.processJSONSchema=(t,n,r)=>as(e,t,n,r)});function Ac(e){return $a(kc,e)}var jc=M(`ZodArray`,(e,t)=>{Gs(),vi.init(e,t),Ks.init(e,t),e._zod.processJSONSchema=(t,n,r)=>us(e,t,n,r),e.element=t.element},{min(e,t){return this.check(oo(e,t))},nonempty(e){return this.check(oo(1,e))},max(e,t){return this.check(ao(e,t))},length(e,t){return this.check(so(e,t))},unwrap(){return this.element}});function Mc(e,t){return xo(jc,e,t)}var Nc=M(`ZodObject`,(e,t)=>{Gs(),wi.init(e,t),Ks.init(e,t),e._zod.processJSONSchema=(t,n,r)=>fs(e,t,n,r),Ft(e,`shape`,e=>e._zod.def.shape,!1)},{keyof(){return Uc(Object.keys(this._zod.def.shape))},catchall(e){return this.clone(Ke(this._zod.def,{catchall:e}))},passthrough(){return this.clone(Ke(this._zod.def,{catchall:Oc()}))},loose(){return this.clone(Ke(this._zod.def,{catchall:Oc()}))},strict(){return this.clone(Ke(this._zod.def,{catchall:Ac()}))},strip(){return this.clone(Ke(this._zod.def,{catchall:void 0}))},extend(e){return ut(this,e)},safeExtend(e){return ft(this,e)},merge(e){return pt(this,e)},pick(e){return st(this,e)},omit(e){return lt(this,e)},partial(...e){return mt(Jc,this,e[0])},exactPartial(...e){return mt(Xc,this,e[0],`exactPartial`)},required(...e){return ht(il,this,e[0])}});function R(e,t){return new Nc({type:`object`,shape:e??{},...k(t)})}var Pc=M(`ZodUnion`,(e,t)=>{Ei.init(e,t),Ks.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ps(e,t,n,r),e.options=t.options});function Fc(e,t){return new Pc({type:`union`,options:e,...k(t)})}var Ic=M(`ZodDiscriminatedUnion`,(e,t)=>{Pc.init(e,t),Oi.init(e,t)});function Lc(e,t,n){return new Ic({type:`union`,options:t,discriminator:e,...k(n)})}var Rc=M(`ZodIntersection`,(e,t)=>{ki.init(e,t),Ks.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ms(e,t,n,r)});function zc(e,t){return new Rc({type:`intersection`,left:e,right:t})}var Bc=M(`ZodRecord`,(e,t)=>{Gs(),Mi.init(e,t),Ks.init(e,t),e._zod.processJSONSchema=(t,n,r)=>vs(e,t,n,r),e.keyType=t.keyType,e.valueType=t.valueType});function Vc(e,t,n){return!t||!t._zod?new Bc({type:`record`,keyType:L(),valueType:e,...k(t)}):new Bc({type:`record`,keyType:e,valueType:t,...k(n)})}var Hc=M(`ZodEnum`,(e,t)=>{Ni.init(e,t),Ks.init(e,t),e._zod.processJSONSchema=(t,n,r)=>os(e,t,n,r),e.enum=t.entries,e.options=[...e._zod.values];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 Hc({...t,checks:[],...k(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 Hc({...t,checks:[],...k(r),entries:i})}});function Uc(e,t){return new Hc({type:`enum`,entries:Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e,...k(t)})}var Wc=M(`ZodLiteral`,(e,t)=>{Pi.init(e,t),Ks.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ss(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]}})});function Gc(e,t){return new Wc({type:`literal`,values:Array.isArray(e)?e:[e],...k(t)})}var Kc=M(`ZodTransform`,(e,t)=>{Gs(),Fi.init(e,t),Ks.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ls(e,t,n,r),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new Ut(e.constructor.name);n.addIssue=r=>{if(typeof r==`string`)n.issues.push(Et(r,n.value,t));else{let t=r;t.fatal&&(t.continue=!1),t.code??=`custom`,`input`in t||(t.input=n.value),t.inst??=e,n.issues.push(Et(t))}};let i=t.transform(n.value,n);return i instanceof Promise?i.then(e=>(n.value=e,n)):(n.value=i,n)}});function qc(e){return new Kc({type:`transform`,transform:e})}var Jc=M(`ZodOptional`,(e,t)=>{Li.init(e,t),Ks.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Os(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Yc(e){return new Jc({type:`optional`,innerType:e})}var Xc=M(`ZodExactOptional`,(e,t)=>{Ri.init(e,t),Ks.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Os(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Zc(e){return new Xc({type:`optional`,innerType:e})}var Qc=M(`ZodNullable`,(e,t)=>{zi.init(e,t),Ks.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ys(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function $c(e){return new Qc({type:`nullable`,innerType:e})}var el=M(`ZodDefault`,(e,t)=>{Bi.init(e,t),Ks.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Cs(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function tl(e,t){return new el({type:`default`,innerType:e,get defaultValue(){return typeof t==`function`?t():$e(t)}})}var nl=M(`ZodPrefault`,(e,t)=>{Hi.init(e,t),Ks.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ws(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function rl(e,t){return new nl({type:`prefault`,innerType:e,get defaultValue(){return typeof t==`function`?t():$e(t)}})}var il=M(`ZodNonOptional`,(e,t)=>{Ui.init(e,t),Ks.init(e,t),e._zod.processJSONSchema=(t,n,r)=>bs(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function al(e,t){return new il({type:`nonoptional`,innerType:e,...k(t)})}var ol=M(`ZodCatch`,(e,t)=>{Ki.init(e,t),Ks.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ts(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function sl(e,t){return new ol({type:`catch`,innerType:e,catchValue:typeof t==`function`?t:Lt(t)})}var cl=M(`ZodPipe`,(e,t)=>{qi.init(e,t),Ks.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Es(e,t,n,r),e.in=t.in,e.out=t.out});function ll(e,t){return new cl({type:`pipe`,in:e,out:t})}var ul=M(`ZodReadonly`,(e,t)=>{Yi.init(e,t),Ks.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ds(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function dl(e){return new ul({type:`readonly`,innerType:e})}var fl=M(`ZodCustom`,(e,t)=>{Zi.init(e,t),Ks.init(e,t),e._zod.processJSONSchema=(t,n,r)=>cs(e,t,n,r)});function pl(e,t={}){return So(fl,e,t)}function ml(e,t){return Co(e,t)}var hl=R({arg:L().min(1),op:Uc([`eq`,`neq`,`gt`,`gte`,`lt`,`lte`]).optional(),value:Fc([L(),bc(),wc(),Ec()])}),gl={content:L().min(1),when:Mc(hl).optional()},_l=R({start:Mc(R({...gl,blocking:wc().optional()})).optional(),delayed:Mc(R({...gl,afterMs:bc().int().nonnegative()})).optional(),complete:Mc(R({...gl,role:Uc([`assistant`,`system`]).optional()})).optional(),failed:Mc(R({...gl,role:Uc([`assistant`,`system`]).optional()})).optional()}),vl=R({type:Gc(`function`),name:L().min(1),description:L().min(1),parameters:Vc(L(),Oc()),messages:_l.optional()}),yl=`client-config`,bl=R({name:L().optional(),greeting:L().max(x).optional(),sessionUrl:L().optional(),page:Uc([`voice`,`static`]),sessionToken:L().optional()});function xl(e){return C(e)?e:{}}var Sl=`/workflows`,Cl=`Workflow API`;function wl(e){let t=e.endsWith(`/`)?e:`${e}/`;return new URL(Sl.replace(/^\//,``),t).toString()}async function Tl(e){return Object.assign(Error(await Ae(e,Cl)),{status:e.status})}function El(e){if(!C(e))return;let t=e.status;return typeof t==`number`?t:void 0}function Dl(e){return ie(e,Cl)}function Ol(e,t){return{runId:e,workflow:t,createdAt:Date.now(),status:`pending`}}function kl(e,t){let n=t.baseMs*2**(e-1),r=t.maxMs===void 0?n:Math.min(n,t.maxMs);return r/2+r/2*Math.random()}function Al(e){let t=null,n=null,r=()=>{let n=Promise.resolve().then(e).finally(()=>{t===n&&(t=null)});return t=n,n},i=()=>t===null?r():(n===null&&(n=t.catch(()=>void 0).then(()=>(n=null,i()))),n);return{trigger:i}}function jl(){let e=0;return{current:()=>e,bump(){e+=1},isCurrent:t=>t===e}}var Ml=class extends Error{invariant;constructor(e,t){super(t),this.name=`InvariantViolation`,this.invariant=e}};function Nl(e,t,n){if(!e)throw new Ml(t,Pl(t,n))}function Pl(e,t){if(t===void 0)return`invariant ${e} violated`;try{return`invariant ${e} violated: ${JSON.stringify(t())}`}catch{return`invariant ${e} violated (detail unavailable)`}}function Fl(e,t={}){let{signal:n,unref:r}=t;return n?.aborted===!0?Promise.resolve():new Promise(t=>{let i,a=setTimeout(()=>{i!==void 0&&n?.removeEventListener(`abort`,i),t()},e);r===!0&&C(a)&&typeof a.unref==`function`&&a.unref(),n!==void 0&&(i=()=>{clearTimeout(a),t()},n.addEventListener(`abort`,i,{once:!0}))})}var Il=[`completed`,`failed`,`cancelled`];function Ll(e){return e!==void 0&&Il.includes(e.status)}var Rl=6e4;function zl(e){return e===void 0||!Number.isFinite(e)||e<=0?0:Math.min(e,Rl)}oe(`stepNotifyClient`);var Bl=/^[A-Za-z0-9_-]{1,64}$/,Vl=/^[A-Za-z0-9_-]{1,128}$/,Hl=R({id:L().startsWith(`evt_`),at:bc().int().nonnegative()}),Ul=R({type:Gc(`usage.updated`),meta:Hl,inputTokens:bc().int().nonnegative(),outputTokens:bc().int().nonnegative(),totalTokens:bc().int().nonnegative(),steps:bc().int().nonnegative()}),Wl=R({type:Gc(`guardrail.blocked`),meta:Hl,direction:Uc([`input`,`output`]),replacement:L().max(x)}),Gl=R({type:Gc(`userTurn.exceeded`),meta:Hl,limit:Uc([`words`,`duration`]),words:bc().int().nonnegative(),durationMs:bc().int().nonnegative()}),Kl=R({type:Gc(`provider.failedOver`),meta:Hl,stage:Uc([`stt`,`llm`,`tts`]),from:L(),to:L(),reason:L().max(500)}),ql=bc().int().nonnegative(),Jl=R({type:Gc(`metrics.collected`),meta:Hl,interrupted:wc(),latencyMs:ql.optional(),stt:R({endpointingMs:ql.optional()}).optional(),llm:R({ttftMs:ql.optional(),durationMs:ql,steps:bc().int().nonnegative(),inputTokens:bc().int().nonnegative().optional(),outputTokens:bc().int().nonnegative().optional()}).optional(),tts:R({ttfbMs:ql.optional(),characters:bc().int().nonnegative()}).optional()}),Yl=Uc([`stt`,`llm`,`tts`,`tool`,`protocol`,`connection`,`audio`,`internal`]),Xl=e=>R({type:Gc(e),meta:Hl}),Zl=R({callId:L(),name:L(),args:Vc(L(),Oc()),status:Uc([`pending`,`done`]),result:L().max(b).optional(),afterMessageIndex:bc().int().min(-1)}),Ql=Uc([`turn-failed`,`session-failed`]),$l=Lc(`type`,[R({type:Gc(`session.configured`),meta:Hl,audioFormat:L(),sampleRate:bc().int().positive().max(S),ttsSampleRate:bc().int().positive().max(S),sessionId:L()}),Xl(`audio.completed`),Xl(`speech.started`),Xl(`speech.stopped`),R({type:Gc(`userTranscript.updated`),meta:Hl,text:L().max(x),eotConfidence:bc().min(0).max(1).optional()}),R({type:Gc(`userTranscript.committed`),meta:Hl,text:L().max(x)}),R({type:Gc(`agentTranscript.updated`),meta:Hl,text:L().max(x)}),R({type:Gc(`agentTranscript.committed`),meta:Hl,text:L().max(x),recovery:Ql.optional(),recorded:Gc(!1).optional()}),R({type:Gc(`tool.called`),meta:Hl,toolCallId:L(),toolName:L(),args:Vc(L(),Oc())}),R({type:Gc(`tool.completed`),meta:Hl,toolCallId:L(),result:L().max(b)}),Xl(`reply.completed`),Xl(`reply.cancelled`),Xl(`session.reset`),Xl(`session.timedOut`),R({type:Gc(`error.reported`),meta:Hl,code:Yl,message:L().max(ee),fatal:wc()}),R({type:Gc(`custom.emitted`),meta:Hl,event:L().min(1).max(256),data:Oc()}),R({type:Gc(`state.updated`),meta:Hl,state:Vc(L(),Oc())}),Ul,Wl,Gl,Kl,Jl,R({type:Gc(`history.restored`),meta:Hl,messages:Mc(R({role:Uc([`user`,`assistant`]),content:L().max(x)})).max(200),toolCalls:Mc(Zl).max(200)})]);new Set($l.options.map(e=>e.shape.type.value));var eu=R({type:L()}).passthrough();function tu(e,t,n){let r=e.safeParse(t);if(r.success)return{ok:!0,data:r.data};let i=eu.safeParse(t);return{ok:!1,malformed:!i.success||(n?.has(i.data.type)??!1),error:r.error.message}}R({audioFormat:Uc([`pcm16`]),sampleRate:bc().int().positive(),ttsSampleRate:bc().int().positive()});var nu=R({systemPrompt:L().min(1),greeting:L().optional(),tools:Mc(vl),sttPrompt:L().optional(),credentials:Vc(L(),L().min(1)).optional(),audioLeadMs:Fc([bc().positive(),Ec()]).optional()});R({type:Gc(`config`),host:nu,audioFormat:Uc([`pcm16`]).optional(),sampleRate:bc().int().positive().max(S).optional(),ttsSampleRate:bc().int().positive().max(S).optional()});var ru=`aai.session`,iu=`aai.auth.`,au=`aai-session-ticket`,ou=o((e=>{Object.defineProperty(e,"__esModule",{value:!0});function t(){if(typeof globalThis<`u`)return globalThis;if(typeof self<`u`)return self;if(typeof window<`u`)return window;if(typeof global<`u`)return global}function n(){let e=t();if(e.__xstate__)return e.__xstate__}function r(e){if(typeof window>`u`)return;let t=n();t&&t.register(e)}e.devToolsAdapter=e=>{if(typeof window>`u`)return;let t=n();t&&t.register(e)},e.getGlobal=t,e.registerService=r})),su=o((e=>{var t=ou(),n=class{constructor(e){this._process=e,this._active=!1,this._current=null,this._last=null}start(){this._active=!0,this.flush()}clear(){this._current&&(this._current.next=null,this._last=this._current)}enqueue(e){let t={value:e,next:null};if(this._current){this._last.next=t,this._last=t;return}this._current=t,this._last=t,this._active&&this.flush()}flush(){for(;this._current;){let e=this._current;this._process(e.value),this._current=e.next}this._last=null}},r=`.`,i=``,a=``,o=`#`,s=`*`,c=`xstate.init`,l=`xstate.error`,u=`xstate.stop`;function d(e,t){return{type:`xstate.after.${e}.${t}`}}function f(e,t){return{type:`xstate.done.state.${e}`,output:t}}function p(e,t){return{type:`xstate.done.actor.${e}`,output:t,actorId:e}}function m(e,t){return{type:`xstate.error.actor.${e}`,error:t,actorId:e}}function h(e){return{type:c,input:e}}function g(e){setTimeout(()=>{throw e})}var _=typeof Symbol==`function`&&Symbol.observable||`@@observable`;function v(e,t){let n=b(e),r=b(t);return typeof r==`string`?typeof n==`string`&&r===n:typeof n==`string`?n in r:Object.keys(n).every(e=>e in r&&v(n[e],r[e]))}function y(e){if(T(e))return e;let t=[],n=``;for(let r=0;r<e.length;r++){switch(e.charCodeAt(r)){case 92:n+=e[r+1],r++;continue;case 46:t.push(n),n=``;continue}n+=e[r]}return t.push(n),t}function b(e){return Nt(e)?e.value:typeof e==`string`?x(y(e)):e}function x(e){if(e.length===1)return e[0];let t={},n=t;for(let t=0;t<e.length-1;t++)if(t===e.length-2)n[e[t]]=e[t+1];else{let r=n;n={},r[e[t]]=n}return t}function ee(e,t){let n={},r=Object.keys(e);for(let i=0;i<r.length;i++){let a=r[i];n[a]=t(e[a],a,e,i)}return n}function S(e){return T(e)?e:[e]}function C(e){return e===void 0?[]:S(e)}function w(e,t,n,r){return typeof e==`function`?e({context:t,event:n,self:r}):e}function T(e){return Array.isArray(e)}function te(e){return e.type.startsWith(`xstate.error.actor`)}function E(e){return S(e).map(e=>e===void 0||typeof e==`string`?{target:e}:e)}function ne(e){if(e!==void 0&&e!==i)return C(e)}function re(e,t,n){let r=typeof e==`object`,i=r?e:void 0;return{next:(r?e.next:e)?.bind(i),error:(r?e.error:t)?.bind(i),complete:(r?e.complete:n)?.bind(i)}}function ie(e,t){return`${t}.${e}`}function ae(e,t){let n=t.match(/^xstate\.invoke\.(\d+)\.(.*)/);if(!n)return e.implementations.actors[t];let[,r,i]=n,a=e.getStateNodeById(i).config.invoke;return(Array.isArray(a)?a[r]:a).src}function oe(e){return[...new Set([...e._nodes.flatMap(e=>e.ownEvents)])]}function se(e,t){if(t===e||t===s)return!0;if(!t.endsWith(`.*`))return!1;let n=t.split(`.`),r=e.split(`.`);for(let e=0;e<n.length;e++){let t=n[e],i=r[e];if(t===`*`)return e===n.length-1;if(t!==i)return!1}return!0}function ce(e,t){return`${e.sessionId}.${t}`}var le=0;function ue(e,t){let n=new Map,r=new Map,i=new WeakMap,a=new Set,o={},{clock:s,logger:c}=t,l={schedule:(e,t,n,r,i=Math.random().toString(36).slice(2))=>{let a={source:e,target:t,event:n,delay:r,id:i,startedAt:Date.now()},c=ce(e,i);u._snapshot._scheduledEvents[c]=a;let l=s.setTimeout(()=>{delete o[c],delete u._snapshot._scheduledEvents[c],u._relay(e,t,n)},r);o[c]=l},cancel:(e,t)=>{let n=ce(e,t),r=o[n];delete o[n],delete u._snapshot._scheduledEvents[n],r!==void 0&&s.clearTimeout(r)},cancelAll:e=>{for(let t in u._snapshot._scheduledEvents){let n=u._snapshot._scheduledEvents[t];n.source===e&&l.cancel(e,n.id)}}},u={_snapshot:{_scheduledEvents:(t?.snapshot&&t.snapshot.scheduler)??{}},_bookId:()=>`x:${le++}`,_register:(e,t)=>(n.set(e,t),e),_unregister:e=>{n.delete(e.sessionId);let t=i.get(e);t!==void 0&&(r.delete(t),i.delete(e))},get:e=>r.get(e),getAll:()=>Object.fromEntries(r.entries()),_set:(e,t)=>{let n=r.get(e);if(n&&n!==t)throw Error(`Actor with system ID '${e}' already exists.`);r.set(e,t),i.set(t,e)},inspect:e=>{let t=re(e);return a.add(t),{unsubscribe(){a.delete(t)}}},_sendInspectionEvent:t=>{if(!a.size)return;let n={...t,rootId:e.sessionId};a.forEach(e=>e.next?.(n))},_relay:(e,t,n)=>{u._sendInspectionEvent({type:`@xstate.event`,sourceRef:e,actorRef:t,event:n}),t._send(n)},scheduler:l,getSnapshot:()=>({_scheduledEvents:{...u._snapshot._scheduledEvents}}),start:()=>{let e=u._snapshot._scheduledEvents;u._snapshot._scheduledEvents={};for(let t in e){let{source:n,target:r,event:i,delay:a,id:o}=e[t];l.schedule(n,r,i,a,o)}},_clock:s,_logger:c};return u}var de=!1,fe=1,pe=function(e){return e[e.NotStarted=0]=`NotStarted`,e[e.Running=1]=`Running`,e[e.Stopped=2]=`Stopped`,e}({}),me={clock:{setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e)},logger:console.log.bind(console),devTools:!1},he=class{constructor(e,t){this.logic=e,this._snapshot=void 0,this.clock=void 0,this.options=void 0,this.id=void 0,this.mailbox=new n(this._process.bind(this)),this.observers=new Set,this.eventListeners=new Map,this.logger=void 0,this._processingStatus=pe.NotStarted,this._parent=void 0,this._syncSnapshot=void 0,this.ref=void 0,this._actorScope=void 0,this.systemId=void 0,this.sessionId=void 0,this.system=void 0,this._doneEvent=void 0,this.src=void 0,this._deferred=[];let r={...me,...t},{clock:i,logger:a,parent:o,syncSnapshot:s,id:c,systemId:l,inspect:u}=r;this.system=o?o.system:ue(this,{clock:i,logger:a}),u&&!o&&this.system.inspect(re(u)),this.sessionId=this.system._bookId(),this.id=c??this.sessionId,this.logger=t?.logger??this.system._logger,this.clock=t?.clock??this.system._clock,this._parent=o,this._syncSnapshot=s,this.options=r,this.src=r.src??e,this.ref=this,this._actorScope={self:this,id:this.id,sessionId:this.sessionId,logger:this.logger,defer:e=>{this._deferred.push(e)},system:this.system,stopChild:e=>{if(e._parent!==this)throw Error(`Cannot stop child actor ${e.id} of ${this.id} because it is not a child`);e._stop()},emit:e=>{let t=this.eventListeners.get(e.type),n=this.eventListeners.get(`*`);if(!t&&!n)return;let r=[...t?t.values():[],...n?n.values():[]];for(let t of r)try{t(e)}catch(e){g(e)}},actionExecutor:e=>{let t=()=>{if(this._actorScope.system._sendInspectionEvent({type:`@xstate.action`,actorRef:this,action:{type:e.type,params:e.params}}),!e.exec)return;let t=de;try{de=!0,e.exec(e.info,e.params)}finally{de=t}};this._processingStatus===pe.Running?t():this._deferred.push(t)}},this.send=this.send.bind(this),this.system._sendInspectionEvent({type:`@xstate.actor`,actorRef:this}),l&&(this.systemId=l,this.system._set(l,this)),this._initState(t?.snapshot??t?.state),l&&this._snapshot.status!==`active`&&this.system._unregister(this)}_initState(e){try{this._snapshot=e?this.logic.restoreSnapshot?this.logic.restoreSnapshot(e,this._actorScope):e:this.logic.getInitialSnapshot(this._actorScope,this.options?.input)}catch(e){this._snapshot={status:`error`,output:void 0,error:e}}}update(e,t){this._snapshot=e;let n;for(;n=this._deferred.shift();)try{n()}catch(t){this._deferred.length=0,this._snapshot={...e,status:`error`,error:t}}switch(this._snapshot.status){case`active`:for(let t of this.observers)try{t.next?.(e)}catch(e){g(e)}break;case`done`:for(let t of this.observers)try{t.next?.(e)}catch(e){g(e)}this._stopProcedure(),this._complete(),this._doneEvent=p(this.id,this._snapshot.output),this._parent&&this.system._relay(this,this._parent,this._doneEvent);break;case`error`:this._error(this._snapshot.error)}this.system._sendInspectionEvent({type:`@xstate.snapshot`,actorRef:this,event:t,snapshot:e})}subscribe(e,t,n){let r=re(e,t,n);if(this._processingStatus!==pe.Stopped)this.observers.add(r);else switch(this._snapshot.status){case`done`:try{r.complete?.()}catch(e){g(e)}break;case`error`:{let e=this._snapshot.error;if(!r.error)g(e);else try{r.error(e)}catch(e){g(e)}break}}return{unsubscribe:()=>{this.observers.delete(r)}}}on(e,t){let n=this.eventListeners.get(e);n||(n=new Set,this.eventListeners.set(e,n));let r=t.bind(void 0);return n.add(r),{unsubscribe:()=>{n.delete(r)}}}select(e,t=Object.is){return{subscribe:n=>{let r=re(n),i=e(this.getSnapshot());return this.subscribe(n=>{let a=e(n);t(i,a)||(i=a,r.next?.(a))})},get:()=>e(this.getSnapshot())}}start(){if(this._processingStatus===pe.Running)return this;this._syncSnapshot&&this.subscribe({next:e=>{e.status===`active`&&this.system._relay(this,this._parent,{type:`xstate.snapshot.${this.id}`,snapshot:e})},error:()=>{}}),this.system._register(this.sessionId,this),this.systemId&&this.system._set(this.systemId,this),this._processingStatus=pe.Running;let e=h(this.options.input);switch(this.system._sendInspectionEvent({type:`@xstate.event`,sourceRef:this._parent,actorRef:this,event:e}),this._snapshot.status){case`done`:return this.update(this._snapshot,e),this;case`error`:return this._error(this._snapshot.error),this}if(this._parent||this.system.start(),this.logic.start)try{this.logic.start(this._snapshot,this._actorScope)}catch(e){return this._snapshot={...this._snapshot,status:`error`,error:e},this._error(e),this}return this.update(this._snapshot,e),this.options.devTools&&this.attachDevTools(),this.mailbox.start(),this}_process(e){let t,n;try{t=this.logic.transition(this._snapshot,e,this._actorScope)}catch(e){n={err:e}}if(n){let{err:e}=n;this._snapshot={...this._snapshot,status:`error`,error:e},this._error(e);return}this.update(t,e),e.type===u&&(this._stopProcedure(),this._complete())}_stop(){return this._processingStatus===pe.Stopped?this:(this.mailbox.clear(),this._processingStatus===pe.NotStarted?(this._processingStatus=pe.Stopped,this):(this.mailbox.enqueue({type:u}),this))}stop(){if(this._parent)throw Error(`A non-root actor cannot be stopped directly.`);return this._stop()}_complete(){for(let e of this.observers)try{e.complete?.()}catch(e){g(e)}this.observers.clear(),this.eventListeners.clear()}_reportError(e){if(!this.observers.size){this._parent||g(e),this.eventListeners.clear();return}let t=!1;for(let n of this.observers){let r=n.error;t||=!r;try{r?.(e)}catch(e){g(e)}}this.observers.clear(),this.eventListeners.clear(),t&&g(e)}_error(e){this._stopProcedure(),this._reportError(e),this._parent&&this.system._relay(this,this._parent,m(this.id,e))}_stopProcedure(){return this._processingStatus===pe.Running?(this.system.scheduler.cancelAll(this),this.mailbox.clear(),this.mailbox=new n(this._process.bind(this)),this._processingStatus=pe.Stopped,this.system._unregister(this),this):this}_send(e){this._processingStatus!==pe.Stopped&&this.mailbox.enqueue(e)}send(e){this.system._relay(void 0,this,e)}attachDevTools(){let{devTools:e}=this.options;e&&(typeof e==`function`?e:t.devToolsAdapter)(this)}toJSON(){return{xstate$$type:fe,id:this.id}}getPersistedSnapshot(e){return this.logic.getPersistedSnapshot(this._snapshot,e)}[_](){return this}getSnapshot(){return this._snapshot}};function ge(e,...[t]){return new he(e,t)}var _e=ge;function ve(e,t,n,r,{sendId:i}){return[t,{sendId:typeof i==`function`?i(n,r):i},void 0]}function ye(e,t){e.defer(()=>{e.system.scheduler.cancel(e.self,t.sendId)})}function be(e){function t(e,t){}return t.type=`xstate.cancel`,t.sendId=e,t.resolve=ve,t.execute=ye,t}function D(e,t,n,r,{id:i,systemId:a,src:o,input:s,syncSnapshot:c}){let l=typeof o==`string`?ae(t.machine,o):o,u=typeof i==`function`?i(n):i,d,f;return l&&(f=typeof s==`function`?s({context:t.context,event:n.event,self:e.self}):s,d=ge(l,{id:u,src:o,parent:e.self,syncSnapshot:c,systemId:a,input:f})),[zt(t,{children:{...t.children,[u]:d}}),{id:i,systemId:a,actorRef:d,src:o,input:f},void 0]}function O(e,{actorRef:t}){t&&e.defer(()=>{t._processingStatus!==pe.Stopped&&t.start()})}function xe(...[e,{id:t,systemId:n,input:r,syncSnapshot:i=!1}={}]){function a(e,t){}return a.type=`xstate.spawnChild`,a.id=t,a.systemId=n,a.src=e,a.input=r,a.syncSnapshot=i,a.resolve=D,a.execute=O,a}function Se(e,t,n,r,{actorRef:i}){let a=typeof i==`function`?i(n,r):i,o=typeof a==`string`?t.children[a]:a,s=t.children;return o&&(s={...s},delete s[o.id]),[zt(t,{children:s}),o,void 0]}function Ce(e,t){let n=t.getSnapshot();if(n&&`children`in n)for(let t of Object.values(n.children))Ce(e,t);e.system._unregister(t)}function we(e,t){if(t){if(Ce(e,t),t._processingStatus!==pe.Running){e.stopChild(t);return}e.defer(()=>{e.stopChild(t)})}}function Te(e){function t(e,t){}return t.type=`xstate.stopChild`,t.actorRef=e,t.resolve=Se,t.execute=we,t}var Ee=Te;function De(e,t,{stateValue:n}){if(typeof n==`string`&&We(n)){let t=e.machine.getStateNodeById(n);return e._nodes.some(e=>e===t)}return e.matches(n)}function Oe(e){function t(){return!1}return t.check=De,t.stateValue=e,t}function ke(e,{context:t,event:n},{guards:r}){return!Fe(r[0],t,n,e)}function Ae(e){function t(e,t){return!1}return t.check=ke,t.guards=[e],t}function je(e,{context:t,event:n},{guards:r}){return r.every(r=>Fe(r,t,n,e))}function Me(e){function t(e,t){return!1}return t.check=je,t.guards=e,t}function Ne(e,{context:t,event:n},{guards:r}){return r.some(r=>Fe(r,t,n,e))}function Pe(e){function t(e,t){return!1}return t.check=Ne,t.guards=e,t}function Fe(e,t,n,r){let{machine:i}=r,a=typeof e==`function`,o=a?e:i.implementations.guards[typeof e==`string`?e:e.type];if(!a&&!o)throw Error(`Guard '${typeof e==`string`?e:e.type}' is not implemented.'.`);if(typeof o!=`function`)return Fe(o,t,n,r);let s={context:t,event:n},c=a||typeof e==`string`?void 0:`params`in e?typeof e.params==`function`?e.params({context:t,event:n}):e.params:void 0;return`check`in o?o.check(r,s,o):o(s,c)}function Ie(e){return e.type===`atomic`||e.type===`final`}function Le(e){return Object.values(e.states).filter(e=>e.type!==`history`)}function Re(e,t){let n=[];if(t===e)return n;let r=e.parent;for(;r&&r!==t;)n.push(r),r=r.parent;return n}function ze(e){let t=new Set(e),n=Ve(t);for(let e of t)if(e.type===`compound`&&(!n.get(e)||!n.get(e).length))et(e).forEach(e=>t.add(e));else if(e.type===`parallel`){for(let n of Le(e))if(n.type!==`history`&&!t.has(n)){let e=et(n);for(let n of e)t.add(n)}}for(let e of t){let n=e.parent;for(;n;)t.add(n),n=n.parent}return t}function Be(e,t){let n=t.get(e);if(!n)return{};if(e.type===`compound`){let e=n[0];if(e){if(Ie(e))return e.key}else return{}}let r={};for(let e of n)r[e.key]=Be(e,t);return r}function Ve(e){let t=new Map;for(let n of e)t.has(n)||t.set(n,[]),n.parent&&(t.has(n.parent)||t.set(n.parent,[]),t.get(n.parent).push(n));return t}function He(e,t){return Be(e,Ve(ze(t)))}function Ue(e,t){return t.type===`compound`?Le(t).some(t=>t.type===`final`&&e.has(t)):t.type===`parallel`?Le(t).every(t=>Ue(e,t)):t.type===`final`}var We=e=>e[0]===o;function Ge(e,t){let n=e.transitions.get(t),r=[...e.transitions.keys()].filter(e=>e!==t&&se(t,e)).sort((e,t)=>t.length-e.length).flatMap(t=>e.transitions.get(t));return n?[...n,...r]:r}function Ke(e){let t=e.config.after;if(!t)return[];let n=t=>{let n=d(t,e.id),r=n.type;return e.entry.push(Wt(n,{id:r,delay:t})),e.exit.push(be(r)),r};return Object.keys(t).flatMap(e=>{let r=t[e],i=typeof r==`string`?{target:r}:r,a=Number.isNaN(+e)?e:+e,o=n(a);return C(i).map(e=>({...e,event:o,delay:a}))}).map(t=>{let{delay:n}=t;return{...qe(e,t.event,t),delay:n}})}function qe(e,t,n){let r=ne(n.target),i=n.reenter??!1,a=Ze(e,r),o={...n,actions:C(n.actions),guard:n.guard,target:a,source:e,reenter:i,eventType:t,toJSON:()=>({...o,source:`#${e.id}`,target:a?a.map(e=>`#${e.id}`):void 0})};return o}function Je(e){let t=new Map;if(e.config.on)for(let n of Object.keys(e.config.on)){if(n===a)throw Error('Null events ("") cannot be specified as a transition key. Use `always: { ... }` instead.');let r=e.config.on[n];t.set(n,E(r).map(t=>qe(e,n,t)))}if(e.config.onDone){let n=`xstate.done.state.${e.id}`;t.set(n,E(e.config.onDone).map(t=>qe(e,n,t)))}for(let n of e.invoke){if(n.onDone){let r=`xstate.done.actor.${n.id}`;t.set(r,E(n.onDone).map(t=>qe(e,r,t)))}if(n.onError){let r=`xstate.error.actor.${n.id}`;t.set(r,E(n.onError).map(t=>qe(e,r,t)))}if(n.onSnapshot){let r=`xstate.snapshot.${n.id}`;t.set(r,E(n.onSnapshot).map(t=>qe(e,r,t)))}}for(let n of e.after){let e=t.get(n.eventType);e||(e=[],t.set(n.eventType,e)),e.push(n)}return t}function Ye(e){let t=[],n=r=>{Object.values(r).forEach(r=>{if(r.config.route&&r.config.id){let n=r.config.id,i=r.config.route.guard,a=({event:e})=>e.to===`#${n}`,o={...r.config.route,guard:i?Me([a,i]):a,target:`#${n}`};t.push(qe(e,`xstate.route`,o))}r.states&&n(r.states)})};n(e.states),t.length>0&&e.transitions.set(`xstate.route`,t)}function Xe(e,t){let n=typeof t==`string`?e.states[t]:t?e.states[t.target]:void 0;if(!n&&t)throw Error(`Initial state node "${t}" not found on parent state node #${e.id}`);let r={source:e,actions:!t||typeof t==`string`?[]:C(t.actions),eventType:null,reenter:!1,target:n?[n]:[],meta:typeof t==`object`?t.meta:void 0,description:typeof t==`object`?t.description:void 0,toJSON:()=>({...r,source:`#${e.id}`,target:n?[`#${n.id}`]:[]})};return r}function Ze(e,t){if(t!==void 0)return t.map(t=>{if(typeof t!=`string`)return t;if(We(t))return e.machine.getStateNodeById(t);let n=t[0]===r;if(n&&!e.parent)return k(e,t.slice(1));let i=n?e.key+t:t;if(e.parent)try{return k(e.parent,i)}catch(t){throw Error(`Invalid transition definition for state node '${e.id}':\n${t.message}`)}throw Error(`Invalid target: "${t}" is not a valid target from the root node. Did you mean ".${t}"?`)})}function Qe(e){let t=ne(e.config.target);return t?{target:t.map(t=>typeof t==`string`?k(e.parent,t):t)}:e.parent.type===`parallel`?{target:[e.parent]}:e.parent.initial}function $e(e){return e.type===`history`}function et(e){let t=tt(e);for(let n of t)for(let r of Re(n,e))t.add(r);return t}function tt(e){let t=new Set;function n(e){if(!t.has(e)){if(t.add(e),e.type===`compound`)n(e.initial.target[0]);else if(e.type===`parallel`)for(let t of Le(e))n(t)}}return n(e),t}function nt(e,t){if(We(t))return e.machine.getStateNodeById(t);if(!e.states)throw Error(`Unable to retrieve child state '${t}' from '${e.id}'; no child states exist.`);let n=e.states[t];if(!n)throw Error(`Child state '${t}' does not exist on '${e.id}'`);return n}function k(e,t){if(typeof t==`string`&&We(t))try{return e.machine.getStateNodeById(t)}catch{}let n=y(t).slice(),r=e;for(;n.length;){let e=n.shift();if(!e.length)break;r=nt(r,e)}return r}function rt(e,t){if(typeof t==`string`){let n=e.states[t];if(!n)throw Error(`State '${t}' does not exist on '${e.id}'`);return[e,n]}let n=Object.keys(t),r=n.map(t=>nt(e,t)).filter(Boolean);return[e.machine.root,e].concat(r,n.reduce((n,r)=>{let i=nt(e,r);if(!i)return n;let a=rt(i,t[r]);return n.concat(a)},[]))}function it(e,t,n,r){let i=nt(e,t).next(n,r);return!i||!i.length?e.next(n,r):i}function at(e,t,n,r){let i=Object.keys(t),a=st(nt(e,i[0]),t[i[0]],n,r);return!a||!a.length?e.next(n,r):a}function ot(e,t,n,r){let i=[];for(let a of Object.keys(t)){let o=t[a];if(!o)continue;let s=st(nt(e,a),o,n,r);s&&i.push(...s)}return i.length?i:e.next(n,r)}function st(e,t,n,r){return typeof t==`string`?it(e,t,n,r):Object.keys(t).length===1?at(e,t,n,r):ot(e,t,n,r)}function ct(e){return Object.keys(e.states).map(t=>e.states[t]).filter(e=>e.type===`history`)}function lt(e,t){let n=e;for(;n.parent&&n.parent!==t;)n=n.parent;return n.parent===t}function ut(e,t){let n=new Set(e),r=new Set(t);for(let e of n)if(r.has(e))return!0;for(let e of r)if(n.has(e))return!0;return!1}function dt(e,t,n){let r=new Set;for(let i of e){let e=!1,a=new Set;for(let o of r)if(ut(ht([i],t,n),ht([o],t,n))){if(lt(i.source,o.source))a.add(o);else{e=!0;break}}if(!e){for(let e of a)r.delete(e);r.add(i)}}return Array.from(r)}function ft(e){let[t,...n]=e;for(let e of Re(t,void 0))if(n.every(t=>lt(t,e)))return e}function pt(e,t){if(!e.target)return[];let n=new Set;for(let r of e.target)if($e(r)){if(t[r.id])for(let e of t[r.id])n.add(e);else for(let e of pt(Qe(r),t))n.add(e)}else n.add(r);return[...n]}function mt(e,t){let n=pt(e,t);if(!n)return;if(!e.reenter&&n.every(t=>t===e.source||lt(t,e.source)))return e.source;let r=ft(n.concat(e.source));if(r)return r;if(!e.reenter)return e.source.machine.root}function ht(e,t,n){let r=new Set;for(let i of e)if(i.target?.length){let e=mt(i,n);i.reenter&&i.source===e&&r.add(e);for(let n of t)lt(n,e)&&r.add(n)}return[...r]}function gt(e,t){if(e.length!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;return!0}function _t(e,t,n,r,i){return vt([{target:[...tt(e)],source:e,reenter:!0,actions:[],eventType:null,toJSON:null}],t,n,r,!0,i)}function vt(e,t,n,r,i,a){let o=[];if(!e.length)return[t,o];let s=n.actionExecutor;n.actionExecutor=e=>{o.push(e),s(e)};try{let s=new Set(t._nodes),c=t.historyValue,l=dt(e,s,c),u=t;i||([u,c]=Tt(u,r,n,l,s,c,a,n.actionExecutor)),u=A(u,r,n,l.flatMap(e=>e.actions),a,void 0),u=bt(u,r,n,l,s,a,c,i);let d=[...s];u.status===`done`&&(u=A(u,r,n,d.sort((e,t)=>t.order-e.order).flatMap(e=>e.exit),a,void 0));try{return c===t.historyValue&&gt(t._nodes,s)?[u,o]:[zt(u,{_nodes:d,historyValue:c}),o]}catch(e){throw e}}finally{n.actionExecutor=s}}function yt(e,t,n,r,i){if(r.output===void 0)return;let a=f(i.id,i.output!==void 0&&i.parent?w(i.output,e.context,t,n.self):void 0);return w(r.output,e.context,a,n.self)}function bt(e,t,n,r,i,a,o,s){let c=e,l=new Set,u=new Set;xt(r,o,u,l),s&&u.add(e.machine.root);let d=new Set;for(let e of[...l].sort((e,t)=>e.order-t.order)){i.add(e);let r=[];r.push(...e.entry);for(let t of e.invoke)r.push(xe(t.src,{...t,syncSnapshot:!!t.onSnapshot}));if(u.has(e)){let t=e.initial.actions;r.push(...t)}if(c=A(c,t,n,r,a,e.invoke.map(e=>e.id)),e.type===`final`){let r=e.parent,o=r?.type===`parallel`?r:r?.parent,s=o||e;for(r?.type===`compound`&&a.push(f(r.id,e.output===void 0?void 0:w(e.output,c.context,t,n.self)));o?.type===`parallel`&&!d.has(o)&&Ue(i,o);)d.add(o),a.push(f(o.id)),s=o,o=o.parent;if(o)continue;c=zt(c,{status:`done`,output:yt(c,t,n,c.machine.root,s)})}}return c}function xt(e,t,n,r){for(let i of e){let e=mt(i,t);for(let a of i.target||[])!$e(a)&&(i.source!==a||i.source!==e||i.reenter)&&(r.add(a),n.add(a)),St(a,t,n,r);let a=pt(i,t);for(let o of a){let a=Re(o,e);e?.type===`parallel`&&a.push(e),Ct(r,t,n,a,!i.source.parent&&i.reenter?void 0:e)}}}function St(e,t,n,r){if($e(e)){if(t[e.id]){let i=t[e.id];for(let e of i)r.add(e),St(e,t,n,r);for(let a of i)wt(a,e.parent,r,t,n)}else{let i=Qe(e);for(let a of i.target)r.add(a),i===e.parent?.initial&&n.add(e.parent),St(a,t,n,r);for(let a of i.target)wt(a,e.parent,r,t,n)}}else if(e.type===`compound`){let[i]=e.initial.target;$e(i)||(r.add(i),n.add(i)),St(i,t,n,r),wt(i,e,r,t,n)}else if(e.type===`parallel`)for(let i of Le(e).filter(e=>!$e(e)))[...r].some(e=>lt(e,i))||($e(i)||(r.add(i),n.add(i)),St(i,t,n,r))}function Ct(e,t,n,r,i){for(let a of r)if((!i||lt(a,i))&&e.add(a),a.type===`parallel`)for(let r of Le(a).filter(e=>!$e(e)))[...e].some(e=>lt(e,r))||(e.add(r),St(r,t,n,e))}function wt(e,t,n,r,i){Ct(n,r,i,Re(e,t))}function Tt(e,t,n,r,i,a,o,s){let c=e,l=ht(r,i,a);l.sort((e,t)=>t.order-e.order);let u;for(let e of l)for(let t of ct(e)){let n;n=t.history===`deep`?t=>Ie(t)&&lt(t,e):t=>t.parent===e,u??={...a},u[t.id]=Array.from(i).filter(n)}for(let e of l)c=A(c,t,n,[...e.exit,...e.invoke.map(e=>Te(e.id))],o,void 0),i.delete(e);return[c,u||a]}function Et(e,t){return e.implementations.actions[t]}function Dt(e,t,n,r,i,a){let{machine:o}=e,s=e;for(let e of r){let r=typeof e==`function`,c=r?e:Et(o,typeof e==`string`?e:e.type),l={context:s.context,event:t,self:n.self,system:n.system},u=r||typeof e==`string`?void 0:`params`in e?typeof e.params==`function`?e.params({context:s.context,event:t}):e.params:void 0;if(!c||!(`resolve`in c)){n.actionExecutor({type:typeof e==`string`?e:typeof e==`object`?e.type:e.name||`(anonymous)`,info:l,params:u,exec:c});continue}let d=c,[f,p,m]=d.resolve(n,s,l,u,c,i);s=f,`retryResolve`in d&&a?.push([d,p]),`execute`in d&&n.actionExecutor({type:d.type,info:l,params:p,exec:d.execute.bind(null,n,p)}),m&&(s=Dt(s,t,n,m,i,a))}return s}function A(e,t,n,r,i,a){let o=a?[]:void 0,s=Dt(e,t,n,r,{internalQueue:i,deferredActorIds:a},o);return o?.forEach(([e,t])=>{e.retryResolve(n,s,t)}),s}function Ot(e,t,n,r){let i=e,a=[];function o(e,t,r){n.system._sendInspectionEvent({type:`@xstate.microstep`,actorRef:n.self,event:t,snapshot:e[0],_transitions:r}),a.push(e)}if(t.type===u)return i=zt(kt(i,t,n),{status:`stopped`}),o([i,[]],t,[]),{snapshot:i,microsteps:a};let s=t;if(s.type!==c){let t=s,c=te(t),l=At(t,i);if(c&&!l.length)return i=zt(e,{status:`error`,error:t.error}),o([i,[]],t,[]),{snapshot:i,microsteps:a};let u=vt(l,e,n,s,!1,r);i=u[0],o(u,t,l)}let l=!0,d=e.machine.options?.maxIterations??1/0,f=0;for(;i.status===`active`;){if(f++,f>d)throw Error(`Infinite loop detected: the machine has processed more than ${d} microsteps without reaching a stable state. This usually happens when there's a cycle of transitions (e.g., eventless transitions or raised events causing state A -> B -> C -> A).`);let e=l?jt(i,s):[],t=e.length?i:void 0;if(!e.length){if(!r.length)break;s=r.shift(),e=At(s,i)}let a=vt(e,i,n,s,!1,r);i=a[0],l=i!==t,o(a,s,e)}return i.status!==`active`&&kt(i,s,n),{snapshot:i,microsteps:a}}function kt(e,t,n){return A(e,t,n,Object.values(e.children).map(e=>Te(e)),[],void 0)}function At(e,t){return t.machine.getTransitionData(t,e)}function jt(e,t){let n=new Set,r=e._nodes.filter(Ie);for(let i of r)loop:for(let r of[i].concat(Re(i,void 0)))if(r.always){for(let i of r.always)if(i.guard===void 0||Fe(i.guard,e.context,t,e)){n.add(i);break loop}}return dt(Array.from(n),new Set(e._nodes),e.historyValue)}function Mt(e,t){return He(e,[...ze(rt(e,t))])}function Nt(e){return!!e&&typeof e==`object`&&`machine`in e&&`value`in e}var Pt=function(e){return v(e,this.value)},j=function(e){return this.tags.has(e)},Ft=function(e){let t=this.machine.getTransitionData(this,e);return!!t?.length&&t.some(e=>e.target!==void 0||e.actions.length)},It=function(){let{_nodes:e,tags:t,machine:n,getMeta:r,toJSON:i,can:a,hasTag:o,matches:s,...c}=this;return{...c,tags:Array.from(t)}},Lt=function(){return this._nodes.reduce((e,t)=>(t.meta!==void 0&&(e[t.id]=t.meta),e),{})};function Rt(e,t){return{status:e.status,output:e.output,error:e.error,machine:t,context:e.context,_nodes:e._nodes,value:He(t.root,e._nodes),tags:new Set(e._nodes.flatMap(e=>e.tags)),children:e.children,historyValue:e.historyValue||{},matches:Pt,hasTag:j,can:Ft,getMeta:Lt,toJSON:It}}function zt(e,t={}){return Rt({...e,...t},e.machine)}function Bt(e){if(typeof e!=`object`||!e)return{};let t={};for(let n in e){let r=e[n];Array.isArray(r)&&(t[n]=r.map(e=>({id:e.id})))}return t}function Vt(e,t){let{_nodes:n,tags:r,machine:i,children:a,context:o,can:s,hasTag:c,matches:l,getMeta:u,toJSON:d,...f}=e,p={};for(let e in a){let n=a[e];p[e]={snapshot:n.getPersistedSnapshot(t),src:n.src,systemId:n.systemId,syncSnapshot:n._syncSnapshot}}return{...f,context:M(o),children:p,historyValue:Bt(f.historyValue)}}function M(e){let t;for(let n in e){let r=e[n];if(r&&typeof r==`object`){if(`sessionId`in r&&`send`in r&&`ref`in r)t??=Array.isArray(e)?e.slice():{...e},t[n]={xstate$$type:fe,id:r.id};else{let i=M(r);i!==r&&(t??=Array.isArray(e)?e.slice():{...e},t[n]=i)}}}return t??e}function Ht(e,t,n,r,{event:i,id:a,delay:o},{internalQueue:s}){let c=t.machine.implementations.delays;if(typeof i==`string`)throw Error(`Only event objects may be used with raise; use raise({ type: "${i}" }) instead`);let l=typeof i==`function`?i(n,r):i,u;if(typeof o==`string`){let e=c&&c[o];u=typeof e==`function`?e(n,r):e}else u=typeof o==`function`?o(n,r):o;return typeof u!=`number`&&s.push(l),[t,{event:l,id:a,delay:u},void 0]}function Ut(e,t){let{event:n,delay:r,id:i}=t;if(typeof r==`number`){e.defer(()=>{let t=e.self;e.system.scheduler.schedule(t,t,n,r,i)});return}}function Wt(e,t){function n(e,t){}return n.type=`xstate.raise`,n.event=e,n.id=t?.id,n.delay=t?.delay,n.resolve=Ht,n.execute=Ut,n}e.$$ACTOR_TYPE=fe,e.Actor=he,e.NULL_EVENT=a,e.ProcessingStatus=pe,e.STATE_DELIMITER=r,e.XSTATE_ERROR=l,e.XSTATE_STOP=u,e.and=Me,e.cancel=be,e.cloneMachineSnapshot=zt,e.createActor=ge,e.createErrorActorEvent=m,e.createInitEvent=h,e.createInvokeId=ie,e.createMachineSnapshot=Rt,e.createSystem=ue,e.evaluateGuard=Fe,e.formatInitialTransition=Xe,e.formatRouteTransitions=Ye,e.formatTransition=qe,e.formatTransitions=Je,e.getAllOwnEventDescriptors=oe,e.getAllStateNodes=ze,e.getCandidates=Ge,e.getDelayedTransitions=Ke,e.getPersistedSnapshot=Vt,e.getProperAncestors=Re,e.getStateNodeByPath=k,e.getStateNodes=rt,e.initialMicrostep=_t,e.interpret=_e,e.isAtomicStateNode=Ie,e.isInFinalState=Ue,e.isMachineSnapshot=Nt,e.isStateId=We,e.macrostep=Ot,e.mapValues=ee,e.matchesEventDescriptor=se,e.matchesState=v,e.not=Ae,e.or=Pe,e.pathToStateValue=x,e.raise=Wt,e.resolveActionsAndContext=A,e.resolveReferencedActor=ae,e.resolveStateValue=Mt,e.spawnChild=xe,e.stateIn=Oe,e.stop=Ee,e.stopChild=Te,e.toArray=C,e.toObserver=re,e.toStatePath=y,e.toTransitionConfigArray=E,e.transitionNode=st})),z=o((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=su();ou();function n(e,t){return{config:e,transition:(t,n,r)=>({...t,context:e(t.context,n,r)}),getInitialSnapshot:(e,n)=>({status:`active`,output:void 0,error:void 0,context:typeof t==`function`?t({input:n}):t}),getPersistedSnapshot:e=>e,restoreSnapshot:e=>e}}var r=new WeakMap;function i(e){return{config:e,start:(t,n)=>{let{self:i,system:a,emit:o}=n,s={receivers:void 0,dispose:void 0};r.set(i,s),s.dispose=e({input:t.input,system:a,self:i,sendBack:e=>{i.getSnapshot().status!==`stopped`&&i._parent&&a._relay(i,i._parent,e)},receive:e=>{s.receivers??=new Set,s.receivers.add(e)},emit:o})},transition:(e,n,i)=>{let a=r.get(i.self);return n.type===t.XSTATE_STOP?(e={...e,status:`stopped`,error:void 0},r.delete(i.self),a.receivers?.clear(),a.dispose?.(),e):(a.receivers?.forEach(e=>e(n)),e)},getInitialSnapshot:(e,t)=>({status:`active`,output:void 0,error:void 0,input:t}),getPersistedSnapshot:e=>e,restoreSnapshot:e=>e}}var a=`xstate.observable.next`,o=`xstate.observable.error`,s=`xstate.observable.complete`;function c(e){return{config:e,transition:(e,n)=>{if(e.status!==`active`)return e;switch(n.type){case a:return{...e,context:n.data};case o:return{...e,status:`error`,error:n.data,input:void 0,_subscription:void 0};case s:return{...e,status:`done`,input:void 0,_subscription:void 0};case t.XSTATE_STOP:return e._subscription.unsubscribe(),{...e,status:`stopped`,input:void 0,_subscription:void 0};default:return e}},getInitialSnapshot:(e,t)=>({status:`active`,output:void 0,error:void 0,context:void 0,input:t,_subscription:void 0}),start:(t,{self:n,system:r,emit:i})=>{t.status!==`done`&&(t._subscription=e({input:t.input,system:r,self:n,emit:i}).subscribe({next:e=>{r._relay(n,n,{type:a,data:e})},error:e=>{r._relay(n,n,{type:o,data:e})},complete:()=>{r._relay(n,n,{type:s})}}))},getPersistedSnapshot:({_subscription:e,...t})=>t,restoreSnapshot:e=>({...e,_subscription:void 0})}}function l(e){return{config:e,transition:(e,n)=>{if(e.status!==`active`)return e;switch(n.type){case o:return{...e,status:`error`,error:n.data,input:void 0,_subscription:void 0};case s:return{...e,status:`done`,input:void 0,_subscription:void 0};case t.XSTATE_STOP:return e._subscription.unsubscribe(),{...e,status:`stopped`,input:void 0,_subscription:void 0};default:return e}},getInitialSnapshot:(e,t)=>({status:`active`,output:void 0,error:void 0,context:void 0,input:t,_subscription:void 0}),start:(t,{self:n,system:r,emit:i})=>{t.status!==`done`&&(t._subscription=e({input:t.input,system:r,self:n,emit:i}).subscribe({next:e=>{n._parent&&r._relay(n,n._parent,e)},error:e=>{r._relay(n,n,{type:o,data:e})},complete:()=>{r._relay(n,n,{type:s})}}))},getPersistedSnapshot:({_subscription:e,...t})=>t,restoreSnapshot:e=>({...e,_subscription:void 0})}}var u=`xstate.promise.resolve`,d=`xstate.promise.reject`,f=new WeakMap;function p(e){return{config:e,transition:(e,n,r)=>{if(e.status!==`active`)return e;switch(n.type){case u:{let t=n.data;return{...e,status:`done`,output:t,input:void 0}}case d:return{...e,status:`error`,error:n.data,input:void 0};case t.XSTATE_STOP:return f.get(r.self)?.abort(),f.delete(r.self),{...e,status:`stopped`,input:void 0};default:return e}},start:(t,{self:n,system:r,emit:i})=>{if(t.status!==`active`)return;let a=new AbortController;f.set(n,a),Promise.resolve(e({input:t.input,system:r,self:n,signal:a.signal,emit:i})).then(e=>{n.getSnapshot().status===`active`&&(f.delete(n),r._relay(n,n,{type:u,data:e}))},e=>{n.getSnapshot().status===`active`&&(f.delete(n),r._relay(n,n,{type:d,data:e}))})},getInitialSnapshot:(e,t)=>({status:`active`,output:void 0,error:void 0,input:t}),getPersistedSnapshot:e=>e,restoreSnapshot:e=>e}}var m=n(e=>void 0,void 0);function h(){return t.createActor(m)}e.createEmptyActor=h,e.fromCallback=i,e.fromEventObservable=l,e.fromObservable=c,e.fromPromise=p,e.fromTransition=n})),cu=o((e=>{var t=su();function n(e,{machine:n,context:r},i,a){let o=(o,s)=>{if(typeof o==`string`){let c=t.resolveReferencedActor(n,o);if(!c)throw Error(`Actor logic '${o}' not implemented in machine '${n.id}'`);let l=t.createActor(c,{id:s?.id,parent:e.self,syncSnapshot:s?.syncSnapshot,input:typeof s?.input==`function`?s.input({context:r,event:i,self:e.self}):s?.input,src:o,systemId:s?.systemId});return a[l.id]=l,l}return t.createActor(o,{id:s?.id,parent:e.self,syncSnapshot:s?.syncSnapshot,input:s?.input,src:o,systemId:s?.systemId})};return(n,r)=>{let i=o(n,r);return a[i.id]=i,e.defer(()=>{i._processingStatus!==t.ProcessingStatus.Stopped&&i.start()}),i}}function r(e,r,i,a,{assignment:o}){if(!r.context)throw Error("Cannot assign to undefined `context`. Ensure that `context` is defined in the machine config.");let s={},c={context:r.context,event:i.event,spawn:n(e,r,i.event,s),self:e.self,system:e.system},l={};if(typeof o==`function`)l=o(c,a);else for(let e of Object.keys(o)){let t=o[e];l[e]=typeof t==`function`?t(c,a):t}let u=Object.assign({},r.context,l);return[t.cloneMachineSnapshot(r,{context:u,children:Object.keys(s).length?{...r.children,...s}:r.children}),void 0,void 0]}function i(e){function t(e,t){}return t.type=`xstate.assign`,t.assignment=e,t.resolve=r,t}e.assign=i})),lu=o((e=>{var t=su(),n=cu(),r=new WeakMap;function i(e,t,n){let i=r.get(e);return i?t in i||(i[t]=n()):(i={[t]:n()},r.set(e,i)),i[t]}var a={},o=e=>typeof e==`string`?{type:e}:typeof e==`function`?`resolve`in e?{type:e.type}:{type:e.name}:e,s=class e{constructor(n,r){if(this.config=n,this.key=void 0,this.id=void 0,this.type=void 0,this.path=void 0,this.states=void 0,this.history=void 0,this.entry=void 0,this.exit=void 0,this.parent=void 0,this.machine=void 0,this.meta=void 0,this.output=void 0,this.order=-1,this.description=void 0,this.tags=[],this.transitions=void 0,this.always=void 0,this.parent=r._parent,this.key=r._key,this.machine=r._machine,this.path=this.parent?this.parent.path.concat(this.key):[],this.id=this.config.id||[this.machine.id,...this.path].join(t.STATE_DELIMITER),this.type=this.config.type||(this.config.states&&Object.keys(this.config.states).length?`compound`:this.config.history?`history`:`atomic`),this.description=this.config.description,this.order=this.machine.idMap.size,this.machine.idMap.set(this.id,this),this.states=this.config.states?t.mapValues(this.config.states,(t,n)=>new e(t,{_parent:this,_key:n,_machine:this.machine})):a,this.type===`compound`&&!this.config.initial)throw Error(`No initial state specified for compound state node "#${this.id}". Try adding { initial: "${Object.keys(this.states)[0]}" } to the state config.`);this.history=this.config.history===!0?`shallow`:this.config.history||!1,this.entry=t.toArray(this.config.entry).slice(),this.exit=t.toArray(this.config.exit).slice(),this.meta=this.config.meta,this.output=this.type===`final`||!this.parent?this.config.output:void 0,this.tags=t.toArray(n.tags).slice()}_initialize(){this.transitions=t.formatTransitions(this),this.config.always&&(this.always=t.toTransitionConfigArray(this.config.always).map(e=>t.formatTransition(this,t.NULL_EVENT,e))),Object.keys(this.states).forEach(e=>{this.states[e]._initialize()})}get definition(){return{id:this.id,key:this.key,version:this.machine.version,type:this.type,initial:this.initial?{target:this.initial.target,source:this,actions:this.initial.actions.map(o),eventType:null,reenter:!1,meta:this.initial.meta,description:this.initial.description,toJSON:()=>({target:this.initial.target.map(e=>`#${e.id}`),source:`#${this.id}`,actions:this.initial.actions.map(o),eventType:null,meta:this.initial.meta,description:this.initial.description})}:void 0,history:this.history,states:t.mapValues(this.states,e=>e.definition),on:this.on,transitions:[...this.transitions.values()].flat().map(e=>({...e,actions:e.actions.map(o)})),entry:this.entry.map(o),exit:this.exit.map(o),meta:this.meta,order:this.order||-1,output:this.output,invoke:this.invoke,description:this.description,tags:this.tags}}toJSON(){return this.definition}get invoke(){return i(this,`invoke`,()=>t.toArray(this.config.invoke).map((e,n)=>{let{src:r,systemId:i}=e,a=e.id??t.createInvokeId(this.id,n),o=typeof r==`string`?r:`xstate.invoke.${t.createInvokeId(this.id,n)}`;return{...e,src:o,id:a,systemId:i,toJSON(){let{onDone:t,onError:n,...r}=e;return{...r,type:`xstate.invoke`,src:o,id:a}}}}))}get on(){return i(this,`on`,()=>[...this.transitions].flatMap(([e,t])=>t.map(t=>[e,t])).reduce((e,[t,n])=>(e[t]=e[t]||[],e[t].push(n),e),{}))}get after(){return i(this,`delayedTransitions`,()=>t.getDelayedTransitions(this))}get initial(){return i(this,`initial`,()=>t.formatInitialTransition(this,this.config.initial))}next(e,n){let r=n.type,a=[],o,s=i(this,`candidates-${r}`,()=>t.getCandidates(this,r));for(let i of s){let{guard:s}=i,c=e.context,l=!1;try{l=!s||t.evaluateGuard(s,c,n,e)}catch(e){let t=typeof s==`string`?s:typeof s==`object`?s.type:void 0;throw Error(`Unable to evaluate guard ${t?`'${t}' `:``}in transition for event '${r}' in state node '${this.id}':\n${e.message}`)}if(l){a.push(...i.actions),o=i;break}}return o?[o]:void 0}get events(){return i(this,`events`,()=>{let{states:e}=this,t=new Set(this.ownEvents);if(e)for(let n of Object.keys(e)){let r=e[n];if(r.states)for(let e of r.events)t.add(`${e}`)}return Array.from(t)})}get ownEvents(){let e=Object.keys(Object.fromEntries(this.transitions)),t=new Set(e.filter(e=>this.transitions.get(e).some(e=>!(!e.target&&!e.actions.length&&!e.reenter))));return Array.from(t)}};e.StateMachine=class e{constructor(e,n){this.config=e,this.version=void 0,this.schemas=void 0,this.implementations=void 0,this.options=void 0,this.__xstatenode=!0,this.idMap=new Map,this.root=void 0,this.id=void 0,this.states=void 0,this.events=void 0,this.id=e.id||`(machine)`,this.implementations={actors:n?.actors??{},actions:n?.actions??{},delays:n?.delays??{},guards:n?.guards??{}},this.version=this.config.version,this.schemas=this.config.schemas,this.options={maxIterations:1/0,...this.config.options},this.transition=this.transition.bind(this),this.getInitialSnapshot=this.getInitialSnapshot.bind(this),this.getPersistedSnapshot=this.getPersistedSnapshot.bind(this),this.restoreSnapshot=this.restoreSnapshot.bind(this),this.start=this.start.bind(this),this.root=new s(e,{_key:this.id,_machine:this}),this.root._initialize(),t.formatRouteTransitions(this.root),this.states=this.root.states,this.events=this.root.events}provide(t){let{actions:n,guards:r,actors:i,delays:a}=this.implementations;return new e(this.config,{actions:{...n,...t.actions},guards:{...r,...t.guards},actors:{...i,...t.actors},delays:{...a,...t.delays}})}resolveState(e){let n=t.resolveStateValue(this.root,e.value),r=t.getAllStateNodes(t.getStateNodes(this.root,n));return t.createMachineSnapshot({_nodes:[...r],context:e.context||{},children:{},status:t.isInFinalState(r,this.root)?`done`:e.status||`active`,output:e.output,error:e.error,historyValue:e.historyValue},this)}transition(e,n,r){return t.macrostep(e,n,r,[]).snapshot}microstep(e,n,r){return t.macrostep(e,n,r,[]).microsteps.map(([e])=>e)}getTransitionData(e,n){return t.transitionNode(this.root,e.value,e,n)||[]}_getPreInitialState(e,r,i){let{context:a}=this.config,o=t.createMachineSnapshot({context:typeof a!=`function`&&a?a:{},_nodes:[this.root],children:{},status:`active`},this);return typeof a==`function`?t.resolveActionsAndContext(o,r,e,[n.assign(({spawn:e,event:t,self:n})=>a({spawn:e,input:t.input,self:n}))],i,void 0):o}getInitialSnapshot(e,n){let r=t.createInitEvent(n),i=[],a=t.createMachineSnapshot({context:typeof this.config.context!=`function`&&this.config.context?this.config.context:{},_nodes:[this.root],children:{},status:`active`},this);try{a=this._getPreInitialState(e,r,i);let[n]=t.initialMicrostep(this.root,a,e,r,i),{snapshot:o}=t.macrostep(n,r,e,i);return o}catch(e){return t.cloneMachineSnapshot(a,{status:`error`,error:e})}}start(e){Object.values(e.children).forEach(e=>{e.getSnapshot().status===`active`&&e.start()})}getStateNodeById(e){let n=t.toStatePath(e),r=n.slice(1),i=t.isStateId(n[0])?n[0].slice(1):n[0],a=this.idMap.get(i);if(!a)throw Error(`Child state node '#${i}' does not exist on machine '${this.id}'`);return t.getStateNodeByPath(a,r)}get definition(){return this.root.definition}toJSON(){return this.definition}getPersistedSnapshot(e,n){return t.getPersistedSnapshot(e,n)}restoreSnapshot(e,n){let r={},i=e.children;Object.keys(i).forEach(e=>{let a=i[e],o=a.snapshot,s=a.src,c=typeof s==`string`?t.resolveReferencedActor(this,s):s;if(!c)return;let l=t.createActor(c,{id:e,parent:n.self,syncSnapshot:a.syncSnapshot,snapshot:o,src:s,systemId:a.systemId});r[e]=l});function a(e,t){if(t instanceof s)return t;try{return e.machine.getStateNodeById(t.id)}catch{}}function o(e,t){if(!t||typeof t!=`object`)return{};let n={};for(let r in t){let i=t[r];for(let t of i){let i=a(e,t);i&&(n[r]??=[],n[r].push(i))}}return n}let c=o(this.root,e.historyValue),l=t.createMachineSnapshot({...e,children:r,_nodes:Array.from(t.getAllStateNodes(t.getStateNodes(this.root,e.value))),historyValue:c},this),u=new Set;function d(e,n){if(!u.has(e)){u.add(e);for(let r in e){let i=e[r];if(i&&typeof i==`object`){if(`xstate$$type`in i&&i.xstate$$type===t.$$ACTOR_TYPE){e[r]=n[i.id];continue}d(i,n)}}}}return d(l.context,r),l}},e.StateNode=s})),uu=o((e=>{var t=su(),n=cu();function r(e,t,n,r,{event:i}){return[t,{event:typeof i==`function`?i(n,r):i},void 0]}function i(e,{event:t}){e.defer(()=>e.emit(t))}function a(e){function t(e,t){}return t.type=`xstate.emit`,t.event=e,t.resolve=r,t.execute=i,t}var o=function(e){return e.Parent=`#_parent`,e.Internal=`#_internal`,e}({});function s(e,t,n,r,{to:i,event:a,id:s,delay:c},l){let u=t.machine.implementations.delays;if(typeof a==`string`)throw Error(`Only event objects may be used with sendTo; use sendTo({ type: "${a}" }) instead`);let d=typeof a==`function`?a(n,r):a,f;if(typeof c==`string`){let e=u&&u[c];f=typeof e==`function`?e(n,r):e}else f=typeof c==`function`?c(n,r):c;let p=typeof i==`function`?i(n,r):i,m;if(typeof p==`string`){if(m=p===o.Parent?e.self._parent:p===o.Internal?e.self:p.startsWith(`#_`)?t.children[p.slice(2)]:l.deferredActorIds?.includes(p)?p:t.children[p],!m)throw Error(`Unable to send event to actor '${p}' from machine '${t.machine.id}'.`)}else m=p||e.self;return[t,{to:m,targetId:typeof p==`string`?p:void 0,event:d,id:s,delay:f},void 0]}function c(e,t,n){typeof n.to==`string`&&(n.to=t.children[n.to])}function l(e,n){e.defer(()=>{let{to:r,event:i,delay:a,id:o}=n;if(typeof a==`number`){e.system.scheduler.schedule(e.self,r,i,a,o);return}e.system._relay(e.self,r,i.type===t.XSTATE_ERROR?t.createErrorActorEvent(e.self.id,i.data):i)})}function u(e,t,n){function r(e,t){}return r.type=`xstate.sendTo`,r.to=e,r.event=t,r.id=n?.id,r.delay=n?.delay,r.resolve=s,r.retryResolve=c,r.execute=l,r}function d(e,t){return u(o.Parent,e,t)}function f(e,t){return u(e,({event:e})=>e,t)}function p(e,r,i,o,{collect:s}){let c=[],l=function(e){c.push(e)};return l.assign=(...e)=>{c.push(n.assign(...e))},l.cancel=(...e)=>{c.push(t.cancel(...e))},l.raise=(...e)=>{c.push(t.raise(...e))},l.sendTo=(...e)=>{c.push(u(...e))},l.sendParent=(...e)=>{c.push(d(...e))},l.spawnChild=(...e)=>{c.push(t.spawnChild(...e))},l.stopChild=(...e)=>{c.push(t.stopChild(...e))},l.emit=(...e)=>{c.push(a(...e))},s({context:i.context,event:i.event,enqueue:l,check:e=>t.evaluateGuard(e,r.context,i.event,r),self:e.self,system:e.system},o),[r,void 0,c]}function m(e){function t(e,t){}return t.type=`xstate.enqueueActions`,t.collect=e,t.resolve=p,t}function h(e,t,n,r,{value:i,label:a}){return[t,{value:typeof i==`function`?i(n,r):i,label:a},void 0]}function g({logger:e},{value:t,label:n}){n?e(n,t):e(t)}function _(e=({context:e,event:t})=>({context:e,event:t}),t){function n(e,t){}return n.type=`xstate.log`,n.value=e,n.label=t,n.resolve=h,n.execute=g,n}e.SpecialTargets=o,e.emit=a,e.enqueueActions=m,e.forwardTo=f,e.log=_,e.sendParent=d,e.sendTo=u})),B=o((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=z(),n=su(),r=lu(),i=cu(),a=uu();ou();function o(e,t){return new r.StateMachine(e,t)}function s({schemas:e,actors:t,actions:r,guards:c,delays:l}){return{assign:i.assign,sendTo:a.sendTo,raise:n.raise,log:a.log,cancel:n.cancel,stopChild:n.stopChild,enqueueActions:a.enqueueActions,emit:a.emit,spawnChild:n.spawnChild,createStateConfig:e=>e,createAction:e=>e,createMachine:n=>o({...n,schemas:e},{actors:t,actions:r,guards:c,delays:l}),extend:n=>s({schemas:e,actors:t,actions:{...r,...n.actions},guards:{...c,...n.guards},delays:{...l,...n.delays}})}}e.createEmptyActor=t.createEmptyActor,e.fromCallback=t.fromCallback,e.fromEventObservable=t.fromEventObservable,e.fromObservable=t.fromObservable,e.fromPromise=t.fromPromise,e.fromTransition=t.fromTransition,e.Actor=n.Actor,e.__unsafe_getAllOwnEventDescriptors=n.getAllOwnEventDescriptors,e.and=n.and,e.cancel=n.cancel,e.createActor=n.createActor,e.getStateNodes=n.getStateNodes,e.interpret=n.interpret,e.isMachineSnapshot=n.isMachineSnapshot,e.matchesState=n.matchesState,e.not=n.not,e.or=n.or,e.pathToStateValue=n.pathToStateValue,e.raise=n.raise,e.spawnChild=n.spawnChild,e.stateIn=n.stateIn,e.stop=n.stop,e.stopChild=n.stopChild,e.toObserver=n.toObserver,e.StateMachine=r.StateMachine,e.StateNode=r.StateNode,e.assign=i.assign,e.SpecialTargets=a.SpecialTargets,e.emit=a.emit,e.enqueueActions=a.enqueueActions,e.forwardTo=a.forwardTo,e.log=a.log,e.sendParent=a.sendParent,e.sendTo=a.sendTo,e.setup=s}))();function du(e){return e&&(T(e)??e)}function fu(e,t=80){return e.length>t?`${e.slice(0,t)}...`:e}function pu(){return typeof location>`u`?``:location.origin+location.pathname}function mu(e){e&&typeof document<`u`&&(document.title=e)}function hu(e,t){return new URL(t,e.endsWith(`/`)?e:`${e}/`)}var gu={page:`voice`},_u=1e4;async function vu(e,t,n){let r=t??((e,t)=>globalThis.fetch(e,t));try{let t=await r(hu(e,yl).href,{signal:AbortSignal.timeout(_u),...n===void 0?{}:{headers:{[au]:n}}});if(!t.ok)return null;let i=bl.safeParse(await t.json());return i.success?i.data:null}catch{return null}}async function yu(e=pu(),t){return await vu(e,t)??gu}var bu=o((e=>{var t=Symbol.for(`react.transitional.element`),n=Symbol.for(`react.portal`),r=Symbol.for(`react.fragment`),i=Symbol.for(`react.strict_mode`),a=Symbol.for(`react.profiler`),o=Symbol.for(`react.consumer`),s=Symbol.for(`react.context`),c=Symbol.for(`react.forward_ref`),l=Symbol.for(`react.suspense`),u=Symbol.for(`react.memo`),d=Symbol.for(`react.lazy`),f=Symbol.for(`react.activity`),p=Symbol.for(`react.view_transition`),m=Symbol.iterator;function h(e){return typeof e!=`object`||!e?null:(e=m&&e[m]||e[`@@iterator`],typeof e==`function`?e:null)}var g={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},_=Object.assign,v={};function y(e,t,n){this.props=e,this.context=t,this.refs=v,this.updater=n||g}y.prototype.isReactComponent={},y.prototype.setState=function(e,t){if(typeof e!=`object`&&typeof e!=`function`&&e!=null)throw Error(`takes an object of state variables to update or a function which returns an object of state variables.`);this.updater.enqueueSetState(this,e,t,`setState`)},y.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,`forceUpdate`)};function b(){}b.prototype=y.prototype;function x(e,t,n){this.props=e,this.context=t,this.refs=v,this.updater=n||g}var ee=x.prototype=new b;ee.constructor=x,_(ee,y.prototype),ee.isPureReactComponent=!0;var S=Array.isArray;function C(){}var w={H:null,A:null,T:null,S:null},T=Object.prototype.hasOwnProperty;function te(e,n,r){var i=r.ref;return{$$typeof:t,type:e,key:n,ref:i===void 0?null:i,props:r}}function E(e,t){return te(e.type,t,e.props)}function ne(e){return typeof e==`object`&&!!e&&e.$$typeof===t}function re(e){var t={"=":`=0`,":":`=2`};return`$`+e.replace(/[=:]/g,function(e){return t[e]})}var ie=/\/+/g;function ae(e,t){return typeof e==`object`&&e&&e.key!=null?re(``+e.key):t.toString(36)}function oe(e){switch(e.status){case`fulfilled`:return e.value;case`rejected`:throw e.reason;default:switch(typeof e.status==`string`?e.then(C,C):(e.status=`pending`,e.then(function(t){e.status===`pending`&&(e.status=`fulfilled`,e.value=t)},function(t){e.status===`pending`&&(e.status=`rejected`,e.reason=t)})),e.status){case`fulfilled`:return e.value;case`rejected`:throw e.reason}}throw e}function se(e,r,i,a,o){var s=typeof e;(s===`undefined`||s===`boolean`)&&(e=null);var c=!1;if(e===null)c=!0;else switch(s){case`bigint`:case`string`:case`number`:c=!0;break;case`object`:switch(e.$$typeof){case t:case n:c=!0;break;case d:return c=e._init,se(c(e._payload),r,i,a,o)}}if(c)return o=o(e),c=a===``?`.`+ae(e,0):a,S(o)?(i=``,c!=null&&(i=c.replace(ie,`$&/`)+`/`),se(o,r,i,``,function(e){return e})):o!=null&&(ne(o)&&(o=E(o,i+(o.key==null||e&&e.key===o.key?``:(``+o.key).replace(ie,`$&/`)+`/`)+c)),r.push(o)),1;c=0;var l=a===``?`.`:a+`:`;if(S(e))for(var u=0;u<e.length;u++)a=e[u],s=l+ae(a,u),c+=se(a,r,i,s,o);else if(u=h(e),typeof u==`function`)for(e=u.call(e),u=0;!(a=e.next()).done;)a=a.value,s=l+ae(a,u++),c+=se(a,r,i,s,o);else if(s===`object`){if(typeof e.then==`function`)return se(oe(e),r,i,a,o);throw r=String(e),Error(`Objects are not valid as a React child (found: `+(r===`[object Object]`?`object with keys {`+Object.keys(e).join(`, `)+`}`:r)+`). If you meant to render a collection of children, use an array instead.`)}return c}function ce(e,t,n){if(e==null)return e;var r=[],i=0;return se(e,r,``,``,function(e){return t.call(n,e,i++)}),r}function le(e){if(e._status===-1){var t=e._result,n=t();n.then(function(t){(e._status===0||e._status===-1)&&(e._status=1,e._result=t,n.status===void 0&&(n.status=`fulfilled`,n.value=t))},function(t){(e._status===0||e._status===-1)&&(e._status=2,e._result=t,n.status===void 0&&(n.status=`rejected`,n.reason=t))}),e._status===-1&&(e._status=0,e._result=n)}if(e._status===1)return e._result.default;throw e._result}var ue=typeof reportError==`function`?reportError:function(e){if(typeof window==`object`&&typeof window.ErrorEvent==`function`){var t=new window.ErrorEvent(`error`,{bubbles:!0,cancelable:!0,message:typeof e==`object`&&e&&typeof e.message==`string`?String(e.message):String(e),error:e});if(!window.dispatchEvent(t))return}else if(typeof process==`object`&&typeof process.emit==`function`){process.emit(`uncaughtException`,e);return}console.error(e)};function de(e){var t=w.T,n={};n.types=t===null?null:t.types,w.T=n;try{var r=e(),i=w.S;i!==null&&i(n,r),typeof r==`object`&&r&&typeof r.then==`function`&&r.then(C,ue)}catch(e){ue(e)}finally{t!==null&&n.types!==null&&(t.types=n.types),w.T=t}}function fe(e){var t=w.T;if(t!==null){var n=t.types;n===null?t.types=[e]:n.indexOf(e)===-1&&n.push(e)}else de(fe.bind(null,e))}var pe={map:ce,forEach:function(e,t,n){ce(e,function(){t.apply(this,arguments)},n)},count:function(e){var t=0;return ce(e,function(){t++}),t},toArray:function(e){return ce(e,function(e){return e})||[]},only:function(e){if(!ne(e))throw Error(`React.Children.only expected to receive a single React element child.`);return e}};e.Activity=f,e.Children=pe,e.Component=y,e.Fragment=r,e.Profiler=a,e.PureComponent=x,e.StrictMode=i,e.Suspense=l,e.ViewTransition=p,e.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=w,e.__COMPILER_RUNTIME={__proto__:null,c:function(e){return w.H.useMemoCache(e)}},e.addTransitionType=fe,e.cache=function(e){return function(){return e.apply(null,arguments)}},e.cacheSignal=function(){return null},e.cloneElement=function(e,t,n){if(e==null)throw Error(`The argument must be a React element, but you passed `+e+`.`);var r=_({},e.props),i=e.key;if(t!=null)for(a in t.key!==void 0&&(i=``+t.key),t)!T.call(t,a)||a===`key`||a===`__self`||a===`__source`||a===`ref`&&t.ref===void 0||(r[a]=t[a]);var a=arguments.length-2;if(a===1)r.children=n;else if(1<a){for(var o=Array(a),s=0;s<a;s++)o[s]=arguments[s+2];r.children=o}return te(e.type,i,r)},e.createContext=function(e){return e={$$typeof:s,_currentValue:e,_currentValue2:e,_threadCount:0,Provider:null,Consumer:null},e.Provider=e,e.Consumer={$$typeof:o,_context:e},e},e.createElement=function(e,t,n){var r,i={},a=null;if(t!=null)for(r in t.key!==void 0&&(a=``+t.key),t)T.call(t,r)&&r!==`key`&&r!==`__self`&&r!==`__source`&&(i[r]=t[r]);var o=arguments.length-2;if(o===1)i.children=n;else if(1<o){for(var s=Array(o),c=0;c<o;c++)s[c]=arguments[c+2];i.children=s}if(e&&e.defaultProps)for(r in o=e.defaultProps,o)i[r]===void 0&&(i[r]=o[r]);return te(e,a,i)},e.createRef=function(){return{current:null}},e.forwardRef=function(e){return{$$typeof:c,render:e}},e.isValidElement=ne,e.lazy=function(e){return{$$typeof:d,_payload:{_status:-1,_result:e},_init:le}},e.memo=function(e,t){return{$$typeof:u,type:e,compare:t===void 0?null:t}},e.startTransition=de,e.unstable_useCacheRefresh=function(){return w.H.useCacheRefresh()},e.use=function(e){return w.H.use(e)},e.useActionState=function(e,t,n){return w.H.useActionState(e,t,n)},e.useCallback=function(e,t){return w.H.useCallback(e,t)},e.useContext=function(e){return w.H.useContext(e)},e.useDebugValue=function(){},e.useDeferredValue=function(e,t){return w.H.useDeferredValue(e,t)},e.useEffect=function(e,t){return w.H.useEffect(e,t)},e.useEffectEvent=function(e){return w.H.useEffectEvent(e)},e.useId=function(){return w.H.useId()},e.useImperativeHandle=function(e,t,n){return w.H.useImperativeHandle(e,t,n)},e.useInsertionEffect=function(e,t){return w.H.useInsertionEffect(e,t)},e.useLayoutEffect=function(e,t){return w.H.useLayoutEffect(e,t)},e.useMemo=function(e,t){return w.H.useMemo(e,t)},e.useOptimistic=function(e,t){return w.H.useOptimistic(e,t)},e.useReducer=function(e,t,n){return w.H.useReducer(e,t,n)},e.useRef=function(e){return w.H.useRef(e)},e.useState=function(e){return w.H.useState(e)},e.useSyncExternalStore=function(e,t,n){return w.H.useSyncExternalStore(e,t,n)},e.useTransition=function(){return w.H.useTransition()},e.version=`19.3.0`})),xu=o(((e,t)=>{t.exports=bu()})),Su=o((e=>{var t=xu();function n(e){var t=`https://react.dev/errors/`+e;if(1<arguments.length){t+=`?args[]=`+encodeURIComponent(arguments[1]);for(var n=2;n<arguments.length;n++)t+=`&args[]=`+encodeURIComponent(arguments[n])}return`Minified React error #`+e+`; visit `+t+` for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`}function r(){}var i={d:{f:r,r:function(){throw Error(n(522))},D:r,C:r,L:r,m:r,X:r,S:r,M:r},p:0,findDOMNode:null},a=Symbol.for(`react.portal`),o=Symbol.for(`react.recoverable`),s=Symbol.for(`react.optimistic_key`);function c(e,t,n){var r=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:a,key:r==null?null:r===s?s:``+r,children:e,containerInfo:t,implementation:n}}var l=t.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function u(e,t){if(e===`font`)return``;if(typeof t==`string`)return t===`use-credentials`?t:``}e.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=i,e.browser=function(e){return{$$typeof:o,_reason:e}},e.createPortal=function(e,t){var r=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!t||t.nodeType!==1&&t.nodeType!==9&&t.nodeType!==11)throw Error(n(299));return c(e,t,null,r)},e.flushSync=function(e){var t=l.T,n=i.p;try{if(l.T=null,i.p=2,e)return e()}finally{l.T=t,i.p=n,i.d.f()}},e.preconnect=function(e,t){typeof e==`string`&&(t?(t=t.crossOrigin,t=typeof t==`string`?t===`use-credentials`?t:``:void 0):t=null,i.d.C(e,t))},e.prefetchDNS=function(e){typeof e==`string`&&i.d.D(e)},e.preinit=function(e,t){if(typeof e==`string`&&t&&typeof t.as==`string`){var n=t.as,r=u(n,t.crossOrigin),a=typeof t.integrity==`string`?t.integrity:void 0,o=typeof t.fetchPriority==`string`?t.fetchPriority:void 0;n===`style`?i.d.S(e,typeof t.precedence==`string`?t.precedence:void 0,{crossOrigin:r,integrity:a,fetchPriority:o}):n===`script`&&i.d.X(e,{crossOrigin:r,integrity:a,fetchPriority:o,nonce:typeof t.nonce==`string`?t.nonce:void 0})}},e.preinitModule=function(e,t){if(typeof e==`string`){if(typeof t==`object`&&t){if(t.as==null||t.as===`script`){var n=u(t.as,t.crossOrigin);i.d.M(e,{crossOrigin:n,integrity:typeof t.integrity==`string`?t.integrity:void 0,nonce:typeof t.nonce==`string`?t.nonce:void 0,fetchPriority:typeof t.fetchPriority==`string`?t.fetchPriority:void 0})}}else t??i.d.M(e)}},e.preload=function(e,t){if(typeof e==`string`&&typeof t==`object`&&t&&typeof t.as==`string`){var n=t.as,r=u(n,t.crossOrigin);i.d.L(e,n,{crossOrigin:r,integrity:typeof t.integrity==`string`?t.integrity:void 0,nonce:typeof t.nonce==`string`?t.nonce:void 0,type:typeof t.type==`string`?t.type:void 0,fetchPriority:typeof t.fetchPriority==`string`?t.fetchPriority:void 0,referrerPolicy:typeof t.referrerPolicy==`string`?t.referrerPolicy:void 0,imageSrcSet:typeof t.imageSrcSet==`string`?t.imageSrcSet:void 0,imageSizes:typeof t.imageSizes==`string`?t.imageSizes:void 0,media:typeof t.media==`string`?t.media:void 0})}},e.preloadModule=function(e,t){if(typeof e==`string`){if(t){var n=u(t.as,t.crossOrigin);i.d.m(e,{as:typeof t.as==`string`&&t.as!==`script`?t.as:void 0,crossOrigin:n,integrity:typeof t.integrity==`string`?t.integrity:void 0,nonce:typeof t.nonce==`string`?t.nonce:void 0,fetchPriority:typeof t.fetchPriority==`string`?t.fetchPriority:void 0})}else i.d.m(e)}},e.requestFormReset=function(e){i.d.r(e)},e.unstable_batchedUpdates=function(e,t){return e(t)},e.useFormState=function(e,t,n){return l.H.useFormState(e,t,n)},e.useFormStatus=function(){return l.H.useHostTransitionStatus()},e.version=`19.3.0`})),Cu=o(((e,t)=>{function n(){if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<`u`&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE==`function`)try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(e){console.error(e)}}n(),t.exports=Su()})),wu=o((e=>{function t(e,t){var n=e.length;e.push(t);a:for(;0<n;){var r=n-1>>>1,a=e[r];if(0<i(a,t))e[r]=t,e[n]=a,n=r;else break a}}function n(e){return e.length===0?null:e[0]}function r(e){if(e.length===0)return null;var t=e[0],n=e.pop();if(n!==t){e[0]=n;a:for(var r=0,a=e.length,o=a>>>1;r<o;){var s=2*(r+1)-1,c=e[s],l=s+1,u=e[l];if(0>i(c,n))l<a&&0>i(u,c)?(e[r]=u,e[l]=n,r=l):(e[r]=c,e[s]=n,r=s);else if(l<a&&0>i(u,n))e[r]=u,e[l]=n,r=l;else break a}}return t}function i(e,t){var n=e.sortIndex-t.sortIndex;return n===0?e.id-t.id:n}if(e.unstable_now=void 0,typeof performance==`object`&&typeof performance.now==`function`){var a=performance;e.unstable_now=function(){return a.now()}}else{var o=Date,s=o.now();e.unstable_now=function(){return o.now()-s}}var c=[],l=[],u=1,d=null,f=3,p=!1,m=!1,h=!1,g=!1,_=typeof setTimeout==`function`?setTimeout:null,v=typeof clearTimeout==`function`?clearTimeout:null,y=typeof setImmediate<`u`?setImmediate:null;function b(e){for(var i=n(l);i!==null;){if(i.callback===null)r(l);else if(i.startTime<=e)r(l),i.sortIndex=i.expirationTime,t(c,i);else break;i=n(l)}}function x(e){if(h=!1,b(e),!m){if(n(c)!==null)m=!0,ee||(ee=!0,E());else{var t=n(l);t!==null&&ie(x,t.startTime-e)}}}var ee=!1,S=-1,C=5,w=-1;function T(){return g?!0:!(e.unstable_now()-w<C)}function te(){if(g=!1,ee){var t=e.unstable_now();w=t;var i=!0;try{a:{m=!1,h&&(h=!1,v(S),S=-1),p=!0;var a=f;try{b:{for(b(t),d=n(c);d!==null&&!(d.expirationTime>t&&T());){var o=d.callback;if(typeof o==`function`){d.callback=null,f=d.priorityLevel;var s=o(d.expirationTime<=t);if(t=e.unstable_now(),typeof s==`function`){d.callback=s,b(t),i=!0;break b}d===n(c)&&r(c),b(t)}else r(c);d=n(c)}if(d!==null)i=!0;else{var u=n(l);u!==null&&ie(x,u.startTime-t),i=!1}}break a}finally{d=null,f=a,p=!1}i=void 0}}finally{i?E():ee=!1}}}var E;if(typeof y==`function`)E=function(){y(te)};else if(typeof MessageChannel<`u`){var ne=new MessageChannel,re=ne.port2;ne.port1.onmessage=te,E=function(){re.postMessage(null)}}else E=function(){_(te,0)};function ie(t,n){S=_(function(){t(e.unstable_now())},n)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(e){e.callback=null},e.unstable_forceFrameRate=function(e){0>e||125<e?console.error(`forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported`):C=0<e?Math.floor(1e3/e):5},e.unstable_getCurrentPriorityLevel=function(){return f},e.unstable_next=function(e){switch(f){case 1:case 2:case 3:var t=3;break;default:t=f}var n=f;f=t;try{return e()}finally{f=n}},e.unstable_requestPaint=function(){g=!0},e.unstable_runWithPriority=function(e,t){switch(e){case 1:case 2:case 3:case 4:case 5:break;default:e=3}var n=f;f=e;try{return t()}finally{f=n}},e.unstable_scheduleCallback=function(r,i,a){var o=e.unstable_now();switch(typeof a==`object`&&a?(a=a.delay,a=typeof a==`number`&&0<a?o+a:o):a=o,r){case 1:var s=-1;break;case 2:s=250;break;case 5:s=1073741823;break;case 4:s=1e4;break;default:s=5e3}return s=a+s,r={id:u++,callback:i,priorityLevel:r,startTime:a,expirationTime:s,sortIndex:-1},a>o?(r.sortIndex=a,t(l,r),n(c)===null&&r===n(l)&&(h?(v(S),S=-1):h=!0,ie(x,a-o))):(r.sortIndex=s,t(c,r),m||p||(m=!0,ee||(ee=!0,E()))),r},e.unstable_shouldYield=T,e.unstable_wrapCallback=function(e){var t=f;return function(){var n=f;f=t;try{return e.apply(this,arguments)}finally{f=n}}}})),Tu=o(((e,t)=>{t.exports=wu()})),Eu=o((e=>{var t=Tu(),n=xu(),r=Cu();function i(e){var t=`https://react.dev/errors/`+e;if(1<arguments.length){t+=`?args[]=`+encodeURIComponent(arguments[1]);for(var n=2;n<arguments.length;n++)t+=`&args[]=`+encodeURIComponent(arguments[n])}return`Minified React error #`+e+`; visit `+t+` for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`}function a(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function o(e){for(var t=e,n=t;n&&!n.alternate;)t=n,t.flags&4098&&(e=t.return),n=t.return;for(;t.return;)t=t.return;return t.tag===3?e:null}function s(e){if(e.tag===13){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function c(e){if(e.tag===31){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function l(e){if(o(e)!==e)throw Error(i(188))}function u(e){var t=e.alternate;if(!t){if(t=o(e),t===null)throw Error(i(188));return t===e?e:null}for(var n=e,r=t;;){var a=n.return;if(a===null)break;var s=a.alternate;if(s===null){if(r=a.return,r!==null){n=r;continue}break}if(a.child===s.child){for(s=a.child;s;){if(s===n)return l(a),e;if(s===r)return l(a),t;s=s.sibling}throw Error(i(188))}if(n.return!==r.return)n=a,r=s;else{for(var c=!1,u=a.child;u;){if(u===n){c=!0,n=a,r=s;break}if(u===r){c=!0,r=a,n=s;break}u=u.sibling}if(!c){for(u=s.child;u;){if(u===n){c=!0,n=s,r=a;break}if(u===r){c=!0,r=s,n=a;break}u=u.sibling}if(!c)throw Error(i(189))}}if(n.alternate!==r)throw Error(i(190))}if(n.tag!==3)throw Error(i(188));return n.stateNode.current===n?e:t}function d(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e;for(e=e.child;e!==null;){if(t=d(e),t!==null)return t;e=e.sibling}return null}function f(e,t,n,r,i,a){for(;e!==null;){if((e.tag===5||e.tag===27||e.tag===6)&&n(e,r,i,a)||(e.tag!==22||e.memoizedState===null)&&(t||e.tag!==5&&e.tag!==27)&&f(e.child,t,n,r,i,a))return!0;e=e.sibling}return!1}function p(e){for(e=e.return;e!==null;){if(e.tag===3||e.tag===5||e.tag===27)return e;e=e.return}return null}function m(e){var t=!1;for(e=e.return;e!==null&&(e.tag===4&&(t=!0),e.tag!==3&&e.tag!==5&&e.tag!==27);)e=e.return;return t}function h(e){var t=[null,null],n=p(e);return n===null||g(t,e,n.child,{foundSelf:!1}),t}function g(e,t,n,r){for(;n!==null;){if(n===t)r.foundSelf=!0;else if(n.tag===5||n.tag===27||n.tag===6){if(r.foundSelf)return e[1]=n,!0;e[0]=n}else if((n.tag!==22||n.memoizedState===null)&&g(e,t,n.child,r))return!0;n=n.sibling}return!1}function _(e){switch(e.tag){case 5:case 27:case 6:return e.stateNode;case 3:return e.stateNode.containerInfo;default:throw Error(i(559))}}var v=null,y=null;function b(e,t,n){return e===n||e===t&&(v=e,!0)}function x(e,t,n){return e===n?(y=e,!1):e===t&&(y!==null&&(v=e),!0)}function ee(e){if(e===null)return null;do e=e===null?null:e.return;while(e&&e.tag!==5&&e.tag!==27&&e.tag!==3);return e||null}function S(e,t,n){for(var r=0,i=e;i;i=n(i))r++;i=0;for(var a=t;a;a=n(a))i++;for(;0<r-i;)e=n(e),r--;for(;0<i-r;)t=n(t),i--;for(;r--;){if(e===t||t!==null&&e===t.alternate)return e;e=n(e),t=n(t)}return null}var C=Object.assign,w=Symbol.for(`react.element`),T=Symbol.for(`react.transitional.element`),te=Symbol.for(`react.portal`),E=Symbol.for(`react.fragment`),ne=Symbol.for(`react.strict_mode`),re=Symbol.for(`react.profiler`),ie=Symbol.for(`react.consumer`),ae=Symbol.for(`react.context`),oe=Symbol.for(`react.forward_ref`),se=Symbol.for(`react.suspense`),ce=Symbol.for(`react.suspense_list`),le=Symbol.for(`react.memo`),ue=Symbol.for(`react.lazy`),de=Symbol.for(`react.activity`),fe=Symbol.for(`react.legacy_hidden`),pe=Symbol.for(`react.memo_cache_sentinel`),me=Symbol.for(`react.view_transition`),he=Symbol.for(`react.recoverable`),ge=Symbol.iterator;function _e(e){return typeof e!=`object`||!e?null:(e=ge&&e[ge]||e[`@@iterator`],typeof e==`function`?e:null)}var ve=Symbol.for(`react.client.reference`);function ye(e){if(e==null)return null;if(typeof e==`function`)return e.$$typeof===ve?null:e.displayName||e.name||null;if(typeof e==`string`)return e;switch(e){case E:return`Fragment`;case re:return`Profiler`;case ne:return`StrictMode`;case se:return`Suspense`;case ce:return`SuspenseList`;case de:return`Activity`;case me:return`ViewTransition`}if(typeof e==`object`)switch(e.$$typeof){case te:return`Portal`;case ae:return e.displayName||`Context`;case ie:return(e._context.displayName||`Context`)+`.Consumer`;case oe:var t=e.render;return e=e.displayName,e||=(e=t.displayName||t.name||``,e===``?`ForwardRef`:`ForwardRef(`+e+`)`),e;case le:return t=e.displayName||null,t===null?ye(e.type)||`Memo`:t;case ue:t=e._payload,e=e._init;try{return ye(e(t))}catch{}}return null}var be=Array.isArray,D=n.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,O=r.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,xe={pending:!1,data:null,method:null,action:null},Se=[],Ce=-1;function we(e){return{current:e}}function Te(e){0>Ce||(e.current=Se[Ce],Se[Ce]=null,Ce--)}function Ee(e,t){Ce++,Se[Ce]=e.current,e.current=t}var De=we(null),Oe=we(null),ke=we(null),Ae=we(null);function je(e,t){switch(Ee(ke,t),Ee(Oe,e),Ee(De,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?pp(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)t=pp(t),e=mp(t,e);else switch(e){case`svg`:e=1;break;case`math`:e=2;break;default:e=0}}Te(De),Ee(De,e)}function Me(){Te(De),Te(Oe),Te(ke)}function Ne(e){var t=e.memoizedState;t!==null&&(sh._currentValue=t.memoizedState,Ee(Ae,e)),t=De.current;var n=mp(t,e.type);t!==n&&(Ee(Oe,e),Ee(De,n))}function Pe(e){Oe.current===e&&(Te(De),Te(Oe)),Ae.current===e&&(Te(Ae),sh._currentValue=xe)}var Fe,Ie;function Le(e){if(Fe===void 0)try{throw Error()}catch(e){var t=e.stack.trim().match(/\n( *(at )?)/);Fe=t&&t[1]||``,Ie=-1<e.stack.indexOf(`
57
57
  at`)?` (<anonymous>)`:-1<e.stack.indexOf(`@`)?`@unknown:0:0`:``}return`
58
58
  `+Fe+e+Ie}var Re=!1;function ze(e,t){if(!e||Re)return``;Re=!0;var n=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var r={DetermineComponentFrameRoot:function(){try{if(t){var n=function(){throw Error()};if(Object.defineProperty(n.prototype,"props",{set:function(){throw Error()}}),typeof Reflect==`object`&&Reflect.construct){try{Reflect.construct(n,[])}catch(e){var r=e}Reflect.construct(e,[],n)}else{try{n.call()}catch(e){r=e}n=!1;try{var i=Object.getOwnPropertyDescriptor(e.prototype,`props`);Object.defineProperty(e.prototype,"props",{configurable:!0,set:function(){throw Error()}}),n=!0,new e}finally{n&&(i===void 0?delete e.prototype.props:Object.defineProperty(e.prototype,"props",i))}}}else{try{throw Error()}catch(e){r=e}(n=e())&&typeof n.catch==`function`&&n.catch(function(){})}}catch(e){if(e&&r&&typeof e.stack==`string`)return[e.stack,r.stack]}return[null,null]}};r.DetermineComponentFrameRoot.displayName=`DetermineComponentFrameRoot`;var i=Object.getOwnPropertyDescriptor(r.DetermineComponentFrameRoot,`name`);i&&i.configurable&&Object.defineProperty(r.DetermineComponentFrameRoot,"name",{value:`DetermineComponentFrameRoot`});var a=r.DetermineComponentFrameRoot(),o=a[0],s=a[1];if(o&&s){var c=o.split(`
59
59
  `),l=s.split(`
@@ -93,7 +93,7 @@ Error generating stack: `+e.message+`
93
93
  `))}function c(e,t,n,r){let i=n.enter(`tableCell`),o=n.enter(`phrasing`),s=n.containerPhrasing(e,{...r,before:a,after:a});return o(),i(),s}function l(e,t){return xy(e,{align:t,alignDelimiters:r,padding:n,stringLength:i})}function u(e,t,n){let r=e.children,i=-1,a=[],o=t.enter(`table`);for(;++i<r.length;)a[i]=d(r[i],t,n);return o(),a}function d(e,t,n){let r=e.children,i=-1,a=[],o=t.enter(`tableRow`);for(;++i<r.length;)a[i]=c(r[i],e,t,n);return o(),a}function f(e,t,n){let r=vb.inlineCode(e,t,n);return n.stack.includes(`tableCell`)&&(r=r.replace(/\|/g,`\\$&`)),r}}function Ob(){return{exit:{taskListCheckValueChecked:Ab,taskListCheckValueUnchecked:Ab,paragraph:jb}}}function kb(){return{unsafe:[{atBreak:!0,character:`-`,after:`[:|-]`}],handlers:{listItem:Mb}}}function Ab(e){let t=this.stack[this.stack.length-2];t.type,t.checked=e.type===`taskListCheckValueChecked`}function jb(e){let t=this.stack[this.stack.length-2];if(t&&t.type===`listItem`&&typeof t.checked==`boolean`){let e=this.stack[this.stack.length-1];e.type;let n=e.children[0];if(n&&n.type===`text`){let r=t.children,i=-1,a;for(;++i<r.length;){let e=r[i];if(e.type===`paragraph`){a=e;break}}a===e&&(n.value=n.value.slice(1),n.value.length===0?e.children.shift():e.position&&n.position&&typeof n.position.start.offset==`number`&&(n.position.start.column++,n.position.start.offset++,e.position.start=Object.assign({},n.position.start)))}}this.exit(e)}function Mb(e,t,n,r){let i=e.children[0],a=typeof e.checked==`boolean`&&i&&i.type===`paragraph`,o=`[`+(e.checked?`x`:` `)+`] `,s=n.createTracker(r);a&&s.move(o);let c=vb.listItem(e,t,n,{...r,...s.current()});return a&&(c=c.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,l)),c;function l(e){return e+o}}function Nb(){return[zv(),ly(),my(),yb(),Ob()]}function Pb(e){return{extensions:[Bv(),uy(e),hy(),Db(e),kb()]}}var Fb={tokenize:Yb,partial:!0},Ib={tokenize:Xb,partial:!0},Lb={tokenize:Zb,partial:!0},Rb={tokenize:Qb,partial:!0},zb={tokenize:$b,partial:!0},Bb={name:`wwwAutolink`,tokenize:qb,previous:ex},Vb={name:`protocolAutolink`,tokenize:Jb,previous:tx},Hb={name:`emailAutolink`,tokenize:Kb,previous:nx},Ub={};function Wb(){return{text:Ub}}for(var Gb=48;Gb<123;)Ub[Gb]=Hb,Gb++,Gb===58?Gb=65:Gb===91&&(Gb=97);Ub[43]=Hb,Ub[45]=Hb,Ub[46]=Hb,Ub[95]=Hb,Ub[72]=[Hb,Vb],Ub[104]=[Hb,Vb],Ub[87]=[Hb,Bb],Ub[119]=[Hb,Bb];function Kb(e,t,n){let r=this,i,a;return o;function o(t){return!rx(t)||!nx.call(r,r.previous)||ix(r.events)?n(t):(e.enter(`literalAutolink`),e.enter(`literalAutolinkEmail`),s(t))}function s(t){return rx(t)?(e.consume(t),s):t===64?(e.consume(t),c):n(t)}function c(t){return t===46?e.check(zb,u,l)(t):t===45||t===95||zp(t)?(a=!0,e.consume(t),c):u(t)}function l(t){return e.consume(t),i=!0,c}function u(o){return a&&i&&Rp(r.previous)?(e.exit(`literalAutolinkEmail`),e.exit(`literalAutolink`),t(o)):n(o)}}function qb(e,t,n){let r=this;return i;function i(t){return t!==87&&t!==119||!ex.call(r,r.previous)||ix(r.events)?n(t):(e.enter(`literalAutolink`),e.enter(`literalAutolinkWww`),e.check(Fb,e.attempt(Ib,e.attempt(Lb,a),n),n)(t))}function a(n){return e.exit(`literalAutolinkWww`),e.exit(`literalAutolink`),t(n)}}function Jb(e,t,n){let r=this,i=``,a=!1;return o;function o(t){return(t===72||t===104)&&tx.call(r,r.previous)&&!ix(r.events)?(e.enter(`literalAutolink`),e.enter(`literalAutolinkHttp`),i+=String.fromCodePoint(t),e.consume(t),s):n(t)}function s(t){if(Rp(t)&&i.length<5)return i+=String.fromCodePoint(t),e.consume(t),s;if(t===58){let n=i.toLowerCase();if(n===`http`||n===`https`)return e.consume(t),c}return n(t)}function c(t){return t===47?(e.consume(t),a?l:(a=!0,c)):n(t)}function l(t){return t===null||Vp(t)||Gp(t)||qp(t)||Kp(t)?n(t):e.attempt(Ib,e.attempt(Lb,u),n)(t)}function u(n){return e.exit(`literalAutolinkHttp`),e.exit(`literalAutolink`),t(n)}}function Yb(e,t,n){let r=0;return i;function i(t){return(t===87||t===119)&&r<3?(r++,e.consume(t),i):t===46&&r===3?(e.consume(t),a):n(t)}function a(e){return e===null?n(e):t(e)}}function Xb(e,t,n){let r,i,a;return o;function o(t){return t===46||t===95?e.check(Rb,c,s)(t):t===null||Gp(t)||qp(t)||t!==45&&Kp(t)?c(t):(a=!0,e.consume(t),o)}function s(t){return t===95?r=!0:(i=r,r=void 0),e.consume(t),o}function c(e){return i||r||!a?n(e):t(e)}}function Zb(e,t){let n=0,r=0;return i;function i(o){return o===40?(n++,e.consume(o),i):o===41&&r<n?a(o):o===33||o===34||o===38||o===39||o===41||o===42||o===44||o===46||o===58||o===59||o===60||o===63||o===93||o===95||o===126?e.check(Rb,t,a)(o):o===null||Gp(o)||qp(o)?t(o):(e.consume(o),i)}function a(t){return t===41&&r++,e.consume(t),i}}function Qb(e,t,n){return r;function r(o){return o===33||o===34||o===39||o===41||o===42||o===44||o===46||o===58||o===59||o===63||o===95||o===126?(e.consume(o),r):o===38?(e.consume(o),a):o===93?(e.consume(o),i):o===60||o===null||Gp(o)||qp(o)?t(o):n(o)}function i(e){return e===null||e===40||e===91||Gp(e)||qp(e)?t(e):r(e)}function a(e){return Rp(e)?o(e):n(e)}function o(t){return t===59?(e.consume(t),r):Rp(t)?(e.consume(t),o):n(t)}}function $b(e,t,n){return r;function r(t){return e.consume(t),i}function i(e){return zp(e)?n(e):t(e)}}function ex(e){return e===null||e===40||e===42||e===95||e===91||e===93||e===126||Gp(e)}function tx(e){return!Rp(e)}function nx(e){return!(e===47||rx(e))}function rx(e){return e===43||e===45||e===46||e===95||zp(e)}function ix(e){let t=e.length,n=!1;for(;t--;){let r=e[t][1];if((r.type===`labelLink`||r.type===`labelImage`)&&!r._balanced){n=!0;break}if(r._gfmAutolinkLiteralWalkedInto){n=!1;break}}return e.length>0&&!n&&(e[e.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),n}var ax={tokenize:px,partial:!0};function ox(){return{document:{91:{name:`gfmFootnoteDefinition`,tokenize:ux,continuation:{tokenize:dx},exit:fx}},text:{91:{name:`gfmFootnoteCall`,tokenize:lx},93:{name:`gfmPotentialFootnoteCall`,add:`after`,tokenize:sx,resolveTo:cx}}}}function sx(e,t,n){let r=this,i=r.events.length,a=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]),o;for(;i--;){let e=r.events[i][1];if(e.type===`labelImage`){o=e;break}if(e.type===`gfmFootnoteCall`||e.type===`labelLink`||e.type===`label`||e.type===`image`||e.type===`link`)break}return s;function s(i){if(!o||!o._balanced)return n(i);let s=Lp(r.sliceSerialize({start:o.end,end:r.now()}));return s.codePointAt(0)!==94||!a.includes(s.slice(1))?n(i):(e.enter(`gfmFootnoteCallLabelMarker`),e.consume(i),e.exit(`gfmFootnoteCallLabelMarker`),t(i))}}function cx(e,t){let n=e.length;for(;n--;)if(e[n][1].type===`labelImage`&&e[n][0]===`enter`){e[n][1];break}e[n+1][1].type=`data`,e[n+3][1].type=`gfmFootnoteCallLabelMarker`;let r={type:`gfmFootnoteCall`,start:Object.assign({},e[n+3][1].start),end:Object.assign({},e[e.length-1][1].end)},i={type:`gfmFootnoteCallMarker`,start:Object.assign({},e[n+3][1].end),end:Object.assign({},e[n+3][1].end)};i.end.column++,i.end.offset++,i.end._bufferIndex++;let a={type:`gfmFootnoteCallString`,start:Object.assign({},i.end),end:Object.assign({},e[e.length-1][1].start)},o={type:`chunkString`,contentType:`string`,start:Object.assign({},a.start),end:Object.assign({},a.end)},s=[e[n+1],e[n+2],[`enter`,r,t],e[n+3],e[n+4],[`enter`,i,t],[`exit`,i,t],[`enter`,a,t],[`enter`,o,t],[`exit`,o,t],[`exit`,a,t],e[e.length-2],e[e.length-1],[`exit`,r,t]];return e.splice(n,e.length-n+1,...s),e}function lx(e,t,n){let r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]),a=0,o;return s;function s(t){return e.enter(`gfmFootnoteCall`),e.enter(`gfmFootnoteCallLabelMarker`),e.consume(t),e.exit(`gfmFootnoteCallLabelMarker`),c}function c(t){return t===94?(e.enter(`gfmFootnoteCallMarker`),e.consume(t),e.exit(`gfmFootnoteCallMarker`),e.enter(`gfmFootnoteCallString`),e.enter(`chunkString`).contentType=`string`,l):n(t)}function l(s){if(a>999||s===93&&!o||s===null||s===91||Gp(s))return n(s);if(s===93){e.exit(`chunkString`);let a=e.exit(`gfmFootnoteCallString`);return i.includes(Lp(r.sliceSerialize(a)))?(e.enter(`gfmFootnoteCallLabelMarker`),e.consume(s),e.exit(`gfmFootnoteCallLabelMarker`),e.exit(`gfmFootnoteCall`),t):n(s)}return Gp(s)||(o=!0),a++,e.consume(s),s===92?u:l}function u(t){return t===91||t===92||t===93?(e.consume(t),a++,l):l(t)}}function ux(e,t,n){let r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]),a,o=0,s;return c;function c(t){return e.enter(`gfmFootnoteDefinition`)._container=!0,e.enter(`gfmFootnoteDefinitionLabel`),e.enter(`gfmFootnoteDefinitionLabelMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionLabelMarker`),l}function l(t){return t===94?(e.enter(`gfmFootnoteDefinitionMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionMarker`),e.enter(`gfmFootnoteDefinitionLabelString`),e.enter(`chunkString`).contentType=`string`,u):n(t)}function u(t){if(o>999||t===93&&!s||t===null||t===91||Gp(t))return n(t);if(t===93){e.exit(`chunkString`);let n=e.exit(`gfmFootnoteDefinitionLabelString`);return a=Lp(r.sliceSerialize(n)),e.enter(`gfmFootnoteDefinitionLabelMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionLabelMarker`),e.exit(`gfmFootnoteDefinitionLabel`),f}return Gp(t)||(s=!0),o++,e.consume(t),t===92?d:u}function d(t){return t===91||t===92||t===93?(e.consume(t),o++,u):u(t)}function f(t){return t===58?(e.enter(`definitionMarker`),e.consume(t),e.exit(`definitionMarker`),i.includes(a)||i.push(a),$(e,p,`gfmFootnoteDefinitionWhitespace`)):n(t)}function p(e){return t(e)}}function dx(e,t,n){return e.check(um,t,e.attempt(ax,t,n))}function fx(e){e.exit(`gfmFootnoteDefinition`)}function px(e,t,n){let r=this;return $(e,i,`gfmFootnoteDefinitionIndent`,5);function i(e){let i=r.events[r.events.length-1];return i&&i[1].type===`gfmFootnoteDefinitionIndent`&&i[2].sliceSerialize(i[1],!0).length===4?t(e):n(e)}}function mx(e){let t=(e||{}).singleTilde,n={name:`strikethrough`,tokenize:i,resolveAll:r};return t??=!0,{text:{126:n},insideSpan:{null:[n]},attentionMarkers:{null:[126]}};function r(e,t){let n=-1;for(;++n<e.length;)if(e[n][0]===`enter`&&e[n][1].type===`strikethroughSequenceTemporary`&&e[n][1]._close){let r=n;for(;r--;)if(e[r][0]===`exit`&&e[r][1].type===`strikethroughSequenceTemporary`&&e[r][1]._open&&e[n][1].end.offset-e[n][1].start.offset===e[r][1].end.offset-e[r][1].start.offset){e[n][1].type=`strikethroughSequence`,e[r][1].type=`strikethroughSequence`;let i={type:`strikethrough`,start:Object.assign({},e[r][1].start),end:Object.assign({},e[n][1].end)},a={type:`strikethroughText`,start:Object.assign({},e[r][1].end),end:Object.assign({},e[n][1].start)},o=[[`enter`,i,t],[`enter`,e[r][1],t],[`exit`,e[r][1],t],[`enter`,a,t]],s=t.parser.constructs.insideSpan.null;s&&Ap(o,o.length,0,rm(s,e.slice(r+1,n),t)),Ap(o,o.length,0,[[`exit`,a,t],[`enter`,e[n][1],t],[`exit`,e[n][1],t],[`exit`,i,t]]),Ap(e,r-1,n-r+3,o),n=r+o.length-2;break}}for(n=-1;++n<e.length;)e[n][1].type===`strikethroughSequenceTemporary`&&(e[n][1].type=`data`);return e}function i(e,n,r){let i=this.previous,a=this.events,o=0;return s;function s(t){return i===126&&a[a.length-1][1].type!==`characterEscape`?r(t):(e.enter(`strikethroughSequenceTemporary`),c(t))}function c(a){let s=nm(i);if(a===126)return o>1?r(a):(e.consume(a),o++,c);if(o<2&&!t)return r(a);let l=e.exit(`strikethroughSequenceTemporary`),u=nm(a);return l._open=!u||u===2&&!!s,l._close=!s||s===2&&!!u,n(a)}}}var hx=class{constructor(){this.map=[],this.index=new Map}add(e,t,n){gx(this,e,t,n)}consume(e){if(this.map.sort(function(e,t){return e[0]-t[0]}),this.map.length===0)return;let t=this.map.length,n=[];for(;t>0;)--t,n.push(e.slice(this.map[t][0]+this.map[t][1]),this.map[t][2]),e.length=this.map[t][0];n.push(e.slice()),e.length=0;let r=n.pop();for(;r;){for(let t of r)e.push(t);r=n.pop()}this.map.length=0,this.index.clear()}};function gx(e,t,n,r){if(n===0&&r.length===0)return;let i=e.index.get(t);if(i){i[1]+=n,i[2].push(...r);return}let a=[t,n,r];e.map.push(a),e.index.set(t,a)}function _x(e,t){let n=!1,r=[];for(;t<e.length;){let i=e[t];if(n){if(i[0]===`enter`)i[1].type===`tableContent`&&r.push(e[t+1][1].type===`tableDelimiterMarker`?`left`:`none`);else if(i[1].type===`tableContent`){if(e[t-1][1].type===`tableDelimiterMarker`){let e=r.length-1;r[e]=r[e]===`left`?`center`:`right`}}else if(i[1].type===`tableDelimiterRow`)break}else i[0]===`enter`&&i[1].type===`tableDelimiterRow`&&(n=!0);t+=1}return r}function vx(){return{flow:{null:{name:`table`,tokenize:yx,resolveAll:bx}}}}function yx(e,t,n){let r=this,i=0,a=0,o;return s;function s(e){let t=r.events.length-1;for(;t>-1;){let{type:e}=r.events[t][1];if(e===`lineEnding`||e===`linePrefix`)t--;else break}let i=t>-1?r.events[t][1].type:null,a=i===`tableHead`||i===`tableRow`?ee:c;return a===ee&&r.parser.lazy[r.now().line]?n(e):a(e)}function c(t){return e.enter(`tableHead`),e.enter(`tableRow`),l(t)}function l(e){return e===124?u(e):(o=!0,a+=1,u(e))}function u(t){return t===null?n(t):Z(t)?a>1?(a=0,r.interrupt=!0,e.exit(`tableRow`),e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),p):n(t):Q(t)?$(e,u,`whitespace`)(t):(a+=1,o&&(o=!1,i+=1),t===124?(e.enter(`tableCellDivider`),e.consume(t),e.exit(`tableCellDivider`),o=!0,u):(e.enter(`data`),d(t)))}function d(t){return t===null||t===124||Gp(t)?(e.exit(`data`),u(t)):(e.consume(t),t===92?f:d)}function f(t){return t===92||t===124?(e.consume(t),d):d(t)}function p(t){return r.interrupt=!1,r.parser.lazy[r.now().line]?n(t):(e.enter(`tableDelimiterRow`),o=!1,Q(t)?$(e,m,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):m(t))}function m(t){return t===45||t===58?g(t):t===124?(o=!0,e.enter(`tableCellDivider`),e.consume(t),e.exit(`tableCellDivider`),h):x(t)}function h(t){return Q(t)?$(e,g,`whitespace`)(t):g(t)}function g(t){return t===58?(a+=1,o=!0,e.enter(`tableDelimiterMarker`),e.consume(t),e.exit(`tableDelimiterMarker`),_):t===45?(a+=1,_(t)):t===null||Z(t)?b(t):x(t)}function _(t){return t===45?(e.enter(`tableDelimiterFiller`),v(t)):x(t)}function v(t){return t===45?(e.consume(t),v):t===58?(o=!0,e.exit(`tableDelimiterFiller`),e.enter(`tableDelimiterMarker`),e.consume(t),e.exit(`tableDelimiterMarker`),y):(e.exit(`tableDelimiterFiller`),y(t))}function y(t){return Q(t)?$(e,b,`whitespace`)(t):b(t)}function b(n){return n===124?m(n):n===null||Z(n)?!o||i!==a?x(n):(e.exit(`tableDelimiterRow`),e.exit(`tableHead`),t(n)):x(n)}function x(e){return n(e)}function ee(t){return e.enter(`tableRow`),S(t)}function S(n){return n===124?(e.enter(`tableCellDivider`),e.consume(n),e.exit(`tableCellDivider`),S):n===null||Z(n)?(e.exit(`tableRow`),t(n)):Q(n)?$(e,S,`whitespace`)(n):(e.enter(`data`),C(n))}function C(t){return t===null||t===124||Gp(t)?(e.exit(`data`),S(t)):(e.consume(t),t===92?w:C)}function w(t){return t===92||t===124?(e.consume(t),C):C(t)}}function bx(e,t){let n=-1,r=!0,i=0,a=[0,0,0,0],o=[0,0,0,0],s=!1,c=0,l,u,d,f=new hx;for(;++n<e.length;){let p=e[n],m=p[1];p[0]===`enter`?m.type===`tableHead`?(s=!1,c!==0&&(Sx(f,t,c,l,u),u=void 0,c=0),l={type:`table`,start:Object.assign({},m.start),end:Object.assign({},m.end)},f.add(n,0,[[`enter`,l,t]])):m.type===`tableRow`||m.type===`tableDelimiterRow`?(r=!0,d=void 0,a=[0,0,0,0],o=[0,n+1,0,0],s&&(s=!1,u={type:`tableBody`,start:Object.assign({},m.start),end:Object.assign({},m.end)},f.add(n,0,[[`enter`,u,t]])),i=m.type===`tableDelimiterRow`?2:u?3:1):i&&(m.type===`data`||m.type===`tableDelimiterMarker`||m.type===`tableDelimiterFiller`)?(r=!1,o[2]===0&&(a[1]!==0&&(o[0]=o[1],d=xx(f,t,a,i,void 0,d),a=[0,0,0,0]),o[2]=n)):m.type===`tableCellDivider`&&(r?r=!1:(a[1]!==0&&(o[0]=o[1],d=xx(f,t,a,i,void 0,d)),a=o,o=[a[1],n,0,0])):m.type===`tableHead`?(s=!0,c=n):m.type===`tableRow`||m.type===`tableDelimiterRow`?(c=n,a[1]===0?o[1]!==0&&(d=xx(f,t,o,i,n,d)):(o[0]=o[1],d=xx(f,t,a,i,n,d)),i=0):i&&(m.type===`data`||m.type===`tableDelimiterMarker`||m.type===`tableDelimiterFiller`)&&(o[3]=n)}for(c!==0&&Sx(f,t,c,l,u),f.consume(t.events),n=-1;++n<t.events.length;){let e=t.events[n];e[0]===`enter`&&e[1].type===`table`&&(e[1]._align=_x(t.events,n))}return e}function xx(e,t,n,r,i,a){let o=r===1?`tableHeader`:r===2?`tableDelimiter`:`tableData`;n[0]!==0&&(a.end=Object.assign({},Cx(t.events,n[0])),e.add(n[0],0,[[`exit`,a,t]]));let s=Cx(t.events,n[1]);if(a={type:o,start:Object.assign({},s),end:Object.assign({},s)},e.add(n[1],0,[[`enter`,a,t]]),n[2]!==0){let i=Cx(t.events,n[2]),a=Cx(t.events,n[3]),o={type:`tableContent`,start:Object.assign({},i),end:Object.assign({},a)};if(e.add(n[2],0,[[`enter`,o,t]]),r!==2){let r=t.events[n[2]],i=t.events[n[3]];if(r[1].end=Object.assign({},i[1].end),r[1].type=`chunkText`,r[1].contentType=`text`,n[3]>n[2]+1){let t=n[2]+1,r=n[3]-n[2]-1;e.add(t,r,[])}}e.add(n[3]+1,0,[[`exit`,o,t]])}return i!==void 0&&(a.end=Object.assign({},Cx(t.events,i)),e.add(i,0,[[`exit`,a,t]]),a=void 0),a}function Sx(e,t,n,r,i){let a=[],o=Cx(t.events,n);i&&(i.end=Object.assign({},o),a.push([`exit`,i,t])),r.end=Object.assign({},o),a.push([`exit`,r,t]),e.add(n+1,0,a)}function Cx(e,t){let n=e[t],r=n[0]===`enter`?`start`:`end`;return n[1][r]}var wx={name:`tasklistCheck`,tokenize:Ex};function Tx(){return{text:{91:wx}}}function Ex(e,t,n){let r=this;return i;function i(t){return r.previous!==null||!r._gfmTasklistFirstContentOfListItem?n(t):(e.enter(`taskListCheck`),e.enter(`taskListCheckMarker`),e.consume(t),e.exit(`taskListCheckMarker`),a)}function a(t){return Gp(t)?(e.enter(`taskListCheckValueUnchecked`),e.consume(t),e.exit(`taskListCheckValueUnchecked`),o):t===88||t===120?(e.enter(`taskListCheckValueChecked`),e.consume(t),e.exit(`taskListCheckValueChecked`),o):n(t)}function o(t){return t===93?(e.enter(`taskListCheckMarker`),e.consume(t),e.exit(`taskListCheckMarker`),e.exit(`taskListCheck`),s):n(t)}function s(r){return Z(r)?t(r):Q(r)?e.check({tokenize:Dx},t,n)(r):n(r)}}function Dx(e,t,n){return $(e,r,`whitespace`);function r(e){return e===null?n(e):t(e)}}function Ox(e){return Np([Wb(),ox(),mx(e),vx(),Tx()])}var kx={};function Ax(e){let t=this,n=e||kx,r=t.data(),i=r.micromarkExtensions||=[],a=r.fromMarkdownExtensions||=[],o=r.toMarkdownExtensions||=[];i.push(Ox(n)),a.push(Nb()),o.push(Pb(n))}var jx=/^(\s*)(\d{1,9})([.)])\s*$/,Mx=/^(\s*)([-*+])\s*$/,Nx=/^\s*(```|~~~)/;function Px(e){let t=!1;return e.split(`
94
94
  `).map(e=>{if(Nx.test(e))return t=!t,e;if(t)return e;let n=jx.exec(e);if(n)return`${n[1]}${n[2]}\\${n[3]}`;let r=Mx.exec(e);return r?`${r[1]}\\${r[2]}`:e}).join(`
95
95
  `)}var Fx={default:{h1:`mt-3 mb-1.5 text-[17px] font-semibold`,h2:`mt-3 mb-1.5 text-[16px] font-semibold`,h3:`mt-3 mb-1.5 text-[15px] font-semibold`,code:`text-[12.5px]`,table:`my-1.5 w-full border-collapse text-sm`},compact:{h1:`mt-3 mb-1.5 text-[15px] font-medium`,h2:`mt-3 mb-1.5 text-[14px] font-medium`,h3:`mt-3 mb-1.5 text-[13px] font-medium`,code:`text-[11px]`,table:`my-1.5 w-full border-collapse text-[12px]`}},Ix=(0,V.memo)(function({text:e,variant:t=`default`}){let n=Ku(),r=Fx[t],i=(0,V.useMemo)(()=>({p:e=>(0,U.jsx)(`p`,{className:`my-1.5 first:mt-0 last:mb-0`,...e}),ul:e=>(0,U.jsx)(`ul`,{className:`my-1.5 list-disc pl-5`,...e}),ol:e=>(0,U.jsx)(`ol`,{className:`my-1.5 list-decimal pl-5`,...e}),li:e=>(0,U.jsx)(`li`,{className:`my-0.5`,...e}),h1:e=>(0,U.jsx)(`h1`,{className:r.h1,...e}),h2:e=>(0,U.jsx)(`h2`,{className:r.h2,...e}),h3:e=>(0,U.jsx)(`h3`,{className:r.h3,...e}),a:({style:e,...t})=>(0,U.jsx)(`a`,{className:`underline underline-offset-2`,style:{color:n.primary,...e},target:`_blank`,rel:`noreferrer noopener`,...t}),code:({className:e,style:t,children:i,...a})=>/language-/.test(e??``)?(0,U.jsx)(`code`,{className:H(`font-aai-mono`,r.code),...a,children:i}):(0,U.jsx)(`code`,{className:H(`rounded-sm border px-1 py-0.5 font-aai-mono`,r.code),style:{borderColor:n.border,background:Ju(n.text,n.surface,3),...t},...a,children:i}),pre:({style:e,...t})=>(0,U.jsx)(`pre`,{className:`my-1.5 overflow-x-auto rounded-md border p-2.5 whitespace-pre-wrap wrap-break-word`,style:{borderColor:n.border,background:Ju(n.text,n.surface,3),...e},...t}),blockquote:({style:e,...t})=>(0,U.jsx)(`blockquote`,{className:`my-1.5 border-l-2 pl-3`,style:{borderColor:n.border,color:Ju(n.text,n.surface,75),...e},...t}),table:e=>(0,U.jsx)(`table`,{className:r.table,...e}),th:({style:e,...t})=>(0,U.jsx)(`th`,{className:`border px-2 py-1 text-left font-medium`,style:{borderColor:n.border,...e},...t}),td:({style:e,...t})=>(0,U.jsx)(`td`,{className:`border px-2 py-1`,style:{borderColor:n.border,...e},...t}),hr:({style:e,...t})=>(0,U.jsx)(`hr`,{className:`my-2.5 border-t`,style:{borderColor:n.border,...e},...t})}),[n,r]);return(0,U.jsx)(Ev,{remarkPlugins:[Ax],components:i,children:Px(e)})}),Lx=(0,V.createContext)({});function Rx(){return(0,V.useContext)(Lx)}function zx(e){let t=du(e);return t===e?e:JSON.stringify(t,null,2)}function Bx({result:e}){let t=Ku(),n=(0,V.useMemo)(()=>zx(e),[e]);return n?(0,U.jsx)(`pre`,{className:`font-aai-mono text-xs px-3.5 py-3 m-0 whitespace-pre-wrap wrap-break-word`,style:{color:Ju(t.text,t.surface,75)},children:n}):null}var Vx=(0,V.memo)(function({toolCall:e,className:t}){let n=Ku(),r=Rx(),i=Object.hasOwn(r,e.name)?r[e.name]:void 0,a=e.status===`pending`,o=i?.label||e.name,s=i?.icon,c=!a&&!!e.result,l=(0,V.useMemo)(()=>{let t=e.args;if(e.name===`run_code`&&t.code)return fu(String(t.code).split(`
96
- `)[0]??``);for(let e of[`query`,`url`,`question`])if(t[e])return String(t[e]);return fu(JSON.stringify(t))},[e.name,e.args]);return(0,U.jsx)(Fd,{title:o,detail:l,pending:a,icon:s,className:t,children:c?(0,U.jsxs)(U.Fragment,{children:[e.name===`run_code`&&!!e.args.code&&(0,U.jsx)(`pre`,{className:`font-aai-mono text-xs px-3.5 py-3 m-0 whitespace-pre-wrap wrap-break-word border-b`,style:{color:n.text,borderColor:n.border},children:String(e.args.code)}),e.result&&(0,U.jsx)(Bx,{result:e.result})]}):void 0})}),Hx=[0,.16,.32].map(e=>({animation:`aai-bounce 1.4s infinite ease-in-out both`,animationDelay:`${e}s`}));function Ux(){let e=Ku(),t=Ju(e.text,e.surface,75);return Hx.map(e=>(0,U.jsx)(`div`,{className:`w-1.5 h-1.5 rounded-full`,style:{...e,background:t}},e.animationDelay))}var Wx=`flex items-center gap-2 text-sm font-medium min-h-5`;function Gx(){return(0,U.jsx)(`div`,{role:`status`,"aria-label":`Thinking`,className:Wx,children:(0,U.jsx)(Ux,{})})}function Kx({theme:e,color:t,children:n}){return(0,U.jsx)(`div`,{className:`flex flex-col w-full items-end`,children:(0,U.jsx)(`div`,{className:`max-w-[min(78%,64ch)] border px-3.5 py-2.5 rounded-md whitespace-pre-wrap wrap-break-word text-[15px] font-normal leading-[22px]`,style:{background:Zu(e.primary,e.surface,7),borderColor:Zu(e.primary,e.surface,16),color:t},children:n})})}var qx=(0,V.memo)(function({message:e,theme:t}){return e.role===`user`?(0,U.jsx)(Kx,{theme:t,color:t.text,children:e.content}):(0,U.jsxs)(`div`,{className:`flex flex-col gap-1 max-w-[82%]`,children:[(0,U.jsx)(`span`,{className:`text-[10px] font-medium tracking-[1.2px] uppercase leading-none`,style:{color:Ju(t.text,t.surface,65)},children:`Agent`}),(0,U.jsx)(`div`,{className:`wrap-break-word text-[15px] font-normal leading-[23px]`,style:{color:t.text},children:(0,U.jsx)(Ix,{text:e.content})})]})}),Jx=(0,V.memo)(function({className:e,log:t}){let n=Ku(),r=(0,V.useCallback)(e=>(0,U.jsx)(qx,{message:e,theme:n}),[n]),i=(0,V.useCallback)(e=>(0,U.jsx)(Vx,{toolCall:e}),[]),a=(0,V.useCallback)(e=>(0,U.jsx)(Kx,{theme:n,color:Ju(n.text,n.surface,65),children:e.partial?e.partial:(0,U.jsx)(Gx,{})}),[n]);return(0,U.jsx)(Hd,{className:e,log:t,style:{background:n.surface},contentClassName:`flex flex-col gap-4 p-7`,renderMessage:r,renderTool:i,renderTranscript:a,thinkingClassName:Wx,thinkingIndicator:(0,U.jsx)(Ux,{})})}),Yx=new Set([`listening`,`speaking`]);function Xx({icon:e,title:t,className:n}){let r=Bu();return(0,U.jsx)(id,{icon:e,title:t,state:r,pulsing:Yx.has(r),className:n,footer:(0,U.jsx)(md,{}),children:(0,U.jsx)(Jx,{})})}function Zx({sidebar:e,children:t,sidebarWidth:n=`18rem`,sidebarPosition:r=`left`,className:i}){let a=Ku(),o=(0,U.jsx)(`div`,{className:H(`shrink-0 flex flex-col overflow-y-auto`,`w-full max-h-[40vh] md:w-(--aai-sidebar-w) md:max-h-none`,r===`left`?`border-b md:border-b-0 md:border-r`:`border-t md:border-t-0 md:border-l order-last md:order-none`),style:{borderColor:a.border},children:e}),s={background:a.bg,"--aai-sidebar-w":n};return(0,U.jsxs)(`div`,{className:H(`flex flex-col md:flex-row min-h-screen md:h-screen`,i),style:s,children:[r===`left`&&o,(0,U.jsx)(`div`,{className:`flex-1 min-w-0 min-h-0`,children:t}),r===`right`&&o]})}function Qx({children:e,icon:t,title:n,subtitle:r,buttonText:i=`Start Conversation`,className:a}){let o=Lu(e=>e.started),{start:s}=Iu(),c=Ku();return o?e:(0,U.jsx)(`div`,{className:H(`flex items-center justify-center h-screen font-aai`,a),style:{background:c.bg},children:(0,U.jsxs)(`div`,{className:`flex flex-col items-center gap-5 border rounded-xl px-10 py-12 sm:px-16 sm:py-14 max-w-105 text-center`,style:{background:c.surface,borderColor:c.border,boxShadow:`0 4px 12px -2px rgb(20 18 12 / 0.08)`},children:[t??(0,U.jsx)(W,{size:24}),(0,U.jsx)(nd,{children:`Voice Agent`}),n&&(0,U.jsx)(`h1`,{className:`font-aai-serif font-normal text-[32px] leading-[1.15] tracking-[-0.2px] m-0 text-balance`,style:{color:c.text},children:n}),r&&(0,U.jsx)(`p`,{className:`text-[15px] leading-[22px] m-0 max-w-75`,style:{color:Ju(c.text,c.surface,75)},children:r}),(0,U.jsx)(od,{size:`lg`,className:`mt-2`,onClick:s,children:i})]})})}var $x=`modulepreload`,eS=function(e,t){return new URL(e,t).href},tS={},nS=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e=document.getElementsByTagName(`link`),i=document.querySelector(`meta[property=csp-nonce]`),a=i?.nonce||i?.getAttribute(`nonce`);function o(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}function s(e){return import.meta.resolve?import.meta.resolve(e):new URL(e,import.meta.url).href}r=o(t.map(t=>{if(t=eS(t,n),t=s(t),t in tS)return;tS[t]=!0;let r=t.endsWith(`.css`);for(let n=e.length-1;n>=0;n--){let i=e[n];if(i.href===t&&(!r||i.rel===`stylesheet`))return}let i=document.createElement(`link`);if(i.rel=r?`stylesheet`:$x,r||(i.as=`script`),i.crossOrigin=``,i.href=t,a&&i.setAttribute(`nonce`,a),document.head.appendChild(i),r)return new Promise((e,n)=>{i.addEventListener(`load`,e),i.addEventListener(`error`,()=>n(Error(`Unable to preload CSS for ${t}`)))})}).filter(e=>e!==void 0))}function i(e){let t=new Event(`vite:preloadError`,{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return r.then(t=>{for(let e of t||[])e.status===`rejected`&&i(e.reason);return e().catch(i)})},rS=null;function iS(){return rS??=Promise.all([nS(()=>import(`./audio-CABEDpag.js`),[],import.meta.url),nS(()=>import(`./capture-processor-X_vJUkv4.js`).then(e=>e.default),__vite__mapDeps([0,1]),import.meta.url),nS(()=>import(`./playback-processor-DdO-2G6m.js`).then(e=>e.default),__vite__mapDeps([2,1]),import.meta.url)]).catch(e=>{throw rS=null,e}),rS}async function aS(e,t,n){let r=await n??void 0;try{return await oS(e,t,r)}catch(e){throw r?.close(),e}}async function oS(e,t,n){let[{createVoiceIO:r},i,a]=await iS();return r({preConnect:n,onPreConnectAudio:t.onPreConnectAudio,sttSampleRate:e.sampleRate,ttsSampleRate:e.ttsSampleRate,captureWorkletSrc:i,playbackWorkletSrc:a,onMicData:t.onMicData,onPlaybackProgress:t.onProgress,onError:e=>t.onFailure(e.message)})}function sS(e){return e===`local`?globalThis.localStorage:globalThis.sessionStorage}function cS(e,t){try{return sS(e)?.getItem(t)??void 0}catch{return}}function lS(e,t,n){try{sS(e)?.setItem(t,n)}catch{}}function uS(e,t){try{sS(e)?.removeItem(t)}catch{}}function dS(e,t){try{return`${e}${new URL(t,globalThis.location?.href).href}`}catch{return`${e}${t}`}}var fS=`aai:client:`;function pS(e){let t=crypto.getRandomValues(new Uint8Array(e));return Array.from(t,e=>e.toString(16).padStart(2,`0`)).join(``)}var mS=pS(4),hS=new Map;function gS(e=pu()){let t=dS(fS,e),n=hS.get(t);if(n)return n;let r=cS(`local`,t),i=r&&Bl.test(r)?r:`browser-${pS(16)}`;return i!==r&&lS(`local`,t,i),hS.set(t,i),i}function _S(e){return`${gS(e)}-${mS}`}function vS(e,t){return e===`auto`?()=>gS(t):e}function yS(e){let t=(typeof e==`function`?e():e)?.trim();return t===``?void 0:t}function bS(e,t){let n=vS(e.client,e.platformUrl);return Object.freeze({platformUrl:e.platformUrl,clientId:()=>yS(n),holderId:()=>_S(e.platformUrl),sessionId:()=>t()?.sessionId(),ticket:()=>t()?.ticket()})}var xS={running:!1,recording:!1};function SS(e,t){e.turn.bump(),t.flush()}function CS(e){let{conn:t,updateState:n,agentState:r,sendJson:i,mic:a,preConnect:o}=e;function s(e){let i=t.turn.current();e.done().then(()=>{t.turn.isCurrent(i)&&n(r.apply({type:`LISTEN`}))}).catch(e=>{console.warn(`Audio playback done failed:`,e)})}return{open:(t,n)=>(e.openAudioPath??aS)(t,n,o.take()),sendMicAudio:e=>{try{a.sendAudio(e)}catch{console.debug(`[aai-ui] sendAudio dropped: connection closed`)}},sendPreConnectAudio:e=>{try{a.sendBuffered(e)}catch{console.debug(`[aai-ui] pre-connect audio dropped: connection closed`)}},reportProgress:e=>{try{i({type:`playback_progress`,bufferedMs:e})}catch{}},announceReady:()=>i({type:`audio_ready`}),micLive:()=>n({recording:!0}),listen:()=>n(r.apply({type:`LISTEN`})),settleWhenDrained:s,reportFailure:e=>{n({...r.apply({type:`FAILED`,error:{code:`audio`,message:e,fatal:!1}}),...xS})},endTurn:()=>t.turn.bump(),release:e=>{e.close().catch(()=>{})}}}var wS=100,TS=Error(`audio path abandoned`),ES=(0,B.setup)({types:{},actors:{bringUp:(0,B.fromPromise)(async({input:e,signal:t})=>{let n=null,r=await e.effects.open(e.config,{onMicData:t=>e.effects.sendMicAudio(t),onPreConnectAudio:t=>e.effects.sendPreConnectAudio(t),onProgress:t=>{n&&e.send({type:`PROGRESS`,io:n,bufferedMs:t})},onFailure:t=>{n&&e.send({type:`IO_FAILED`,io:n,message:t})}});if(t.aborted)throw e.effects.release(r),TS;return n=r,r})},guards:{fromLiveIo:({context:e,event:t})=>(t.type===`PROGRESS`||t.type===`IO_FAILED`)&&e.io===t.io},actions:{rememberConfig:(0,B.assign)({config:({context:e,event:t})=>t.type===`START`?t.config:e.config}),buffer:(0,B.assign)({pending:({context:e,event:t})=>t.type===`CHUNK`&&e.pending.length<wS?[...e.pending,t.chunk]:e.pending}),rememberDone:(0,B.assign)({pendingDone:!0}),listenNow:({context:e})=>e.effects.listen(),forgetBuffered:(0,B.assign)({io:null,pending:[],pendingDone:!1}),endTurn:({context:e})=>e.effects.endTurn(),releaseIo:({context:e})=>{e.io&&e.effects.release(e.io)}}}).createMachine({id:`audioPath`,context:({input:e})=>({effects:e,io:null,pending:[],pendingDone:!1,config:null}),initial:`down`,on:{CHUNK:{actions:`buffer`},DONE:{actions:[`rememberDone`,`listenNow`]},TEARDOWN:`.down`},states:{down:{entry:[`endTurn`,`forgetBuffered`],on:{START:{target:`starting`,actions:`rememberConfig`}}},starting:{invoke:{src:`bringUp`,input:({context:e,self:t})=>({effects:e.effects,config:e.config??{sampleRate:0,ttsSampleRate:0},send:e=>{t.send(e)}}),onDone:{target:`up`,actions:[({context:e,event:t})=>{for(let n of e.pending)t.output.enqueue(n)},(0,B.assign)({io:({event:e})=>e.output,pending:[]}),({context:e,event:t})=>{e.effects.announceReady(),e.effects.micLive(),e.pendingDone?e.effects.settleWhenDrained(t.output):e.effects.listen()},(0,B.assign)({pendingDone:!1})]},onError:{target:`down`,actions:({context:e,event:t})=>{e.effects.reportFailure(`Microphone access failed: ${be(t.error)}`)}}}},up:{exit:`releaseIo`,on:{START:{target:`starting`,actions:`rememberConfig`},CHUNK:{actions:({context:e,event:t})=>e.io?.enqueue(t.chunk)},DONE:{actions:({context:e})=>{e.io&&e.effects.settleWhenDrained(e.io)}},PROGRESS:{guard:`fromLiveIo`,actions:({context:e,event:t})=>e.effects.reportProgress(t.bufferedMs)},IO_FAILED:{guard:`fromLiveIo`,target:`down`,actions:({context:e,event:t})=>e.effects.reportFailure(t.message)}}}}});function DS(e){let t=(0,B.createActor)(ES,{input:e}).start();return{phase:()=>t.getSnapshot().value,start:e=>{t.send({type:`START`,config:e})},enqueue:e=>{t.send({type:`CHUNK`,chunk:e})},done:()=>{t.send({type:`DONE`})},flush:()=>t.getSnapshot().context.io?.flush(),teardown:()=>{t.send({type:`TEARDOWN`})}}}var OS=1e3;function kS(e,t){let n=e.reason.trim();return n!==``&&e.code!==OS?n:t?`WebSocket connection error`:null}(!globalThis.EventTarget||!globalThis.Event)&&console.error(`
96
+ `)[0]??``);for(let e of[`query`,`url`,`question`])if(t[e])return String(t[e]);return fu(JSON.stringify(t))},[e.name,e.args]);return(0,U.jsx)(Fd,{title:o,detail:l,pending:a,icon:s,className:t,children:c?(0,U.jsxs)(U.Fragment,{children:[e.name===`run_code`&&!!e.args.code&&(0,U.jsx)(`pre`,{className:`font-aai-mono text-xs px-3.5 py-3 m-0 whitespace-pre-wrap wrap-break-word border-b`,style:{color:n.text,borderColor:n.border},children:String(e.args.code)}),e.result&&(0,U.jsx)(Bx,{result:e.result})]}):void 0})}),Hx=[0,.16,.32].map(e=>({animation:`aai-bounce 1.4s infinite ease-in-out both`,animationDelay:`${e}s`}));function Ux(){let e=Ku(),t=Ju(e.text,e.surface,75);return Hx.map(e=>(0,U.jsx)(`div`,{className:`w-1.5 h-1.5 rounded-full`,style:{...e,background:t}},e.animationDelay))}var Wx=`flex items-center gap-2 text-sm font-medium min-h-5`;function Gx(){return(0,U.jsx)(`div`,{role:`status`,"aria-label":`Thinking`,className:Wx,children:(0,U.jsx)(Ux,{})})}function Kx({theme:e,color:t,children:n}){return(0,U.jsx)(`div`,{className:`flex flex-col w-full items-end`,children:(0,U.jsx)(`div`,{className:`max-w-[min(78%,64ch)] border px-3.5 py-2.5 rounded-md whitespace-pre-wrap wrap-break-word text-[15px] font-normal leading-[22px]`,style:{background:Zu(e.primary,e.surface,7),borderColor:Zu(e.primary,e.surface,16),color:t},children:n})})}var qx=(0,V.memo)(function({message:e,theme:t}){return e.role===`user`?(0,U.jsx)(Kx,{theme:t,color:t.text,children:e.content}):(0,U.jsxs)(`div`,{className:`flex flex-col gap-1 max-w-[82%]`,children:[(0,U.jsx)(`span`,{className:`text-[10px] font-medium tracking-[1.2px] uppercase leading-none`,style:{color:Ju(t.text,t.surface,65)},children:`Agent`}),(0,U.jsx)(`div`,{className:`wrap-break-word text-[15px] font-normal leading-[23px]`,style:{color:t.text},children:(0,U.jsx)(Ix,{text:e.content})})]})}),Jx=(0,V.memo)(function({className:e,log:t}){let n=Ku(),r=(0,V.useCallback)(e=>(0,U.jsx)(qx,{message:e,theme:n}),[n]),i=(0,V.useCallback)(e=>(0,U.jsx)(Vx,{toolCall:e}),[]),a=(0,V.useCallback)(e=>(0,U.jsx)(Kx,{theme:n,color:Ju(n.text,n.surface,65),children:e.partial?e.partial:(0,U.jsx)(Gx,{})}),[n]);return(0,U.jsx)(Hd,{className:e,log:t,style:{background:n.surface},contentClassName:`flex flex-col gap-4 p-7`,renderMessage:r,renderTool:i,renderTranscript:a,thinkingClassName:Wx,thinkingIndicator:(0,U.jsx)(Ux,{})})}),Yx=new Set([`listening`,`speaking`]);function Xx({icon:e,title:t,className:n}){let r=Bu();return(0,U.jsx)(id,{icon:e,title:t,state:r,pulsing:Yx.has(r),className:n,footer:(0,U.jsx)(md,{}),children:(0,U.jsx)(Jx,{})})}function Zx({sidebar:e,children:t,sidebarWidth:n=`18rem`,sidebarPosition:r=`left`,className:i}){let a=Ku(),o=(0,U.jsx)(`div`,{className:H(`shrink-0 flex flex-col overflow-y-auto`,`w-full max-h-[40vh] md:w-(--aai-sidebar-w) md:max-h-none`,r===`left`?`border-b md:border-b-0 md:border-r`:`border-t md:border-t-0 md:border-l order-last md:order-none`),style:{borderColor:a.border},children:e}),s={background:a.bg,"--aai-sidebar-w":n};return(0,U.jsxs)(`div`,{className:H(`flex flex-col md:flex-row min-h-screen md:h-screen`,i),style:s,children:[r===`left`&&o,(0,U.jsx)(`div`,{className:`flex-1 min-w-0 min-h-0`,children:t}),r===`right`&&o]})}function Qx({children:e,icon:t,title:n,subtitle:r,buttonText:i=`Start Conversation`,className:a}){let o=Lu(e=>e.started),{start:s}=Iu(),c=Ku();return o?e:(0,U.jsx)(`div`,{className:H(`flex items-center justify-center h-screen font-aai`,a),style:{background:c.bg},children:(0,U.jsxs)(`div`,{className:`flex flex-col items-center gap-5 border rounded-xl px-10 py-12 sm:px-16 sm:py-14 max-w-105 text-center`,style:{background:c.surface,borderColor:c.border,boxShadow:`0 4px 12px -2px rgb(20 18 12 / 0.08)`},children:[t??(0,U.jsx)(W,{size:24}),(0,U.jsx)(nd,{children:`Voice Agent`}),n&&(0,U.jsx)(`h1`,{className:`font-aai-serif font-normal text-[32px] leading-[1.15] tracking-[-0.2px] m-0 text-balance`,style:{color:c.text},children:n}),r&&(0,U.jsx)(`p`,{className:`text-[15px] leading-[22px] m-0 max-w-75`,style:{color:Ju(c.text,c.surface,75)},children:r}),(0,U.jsx)(od,{size:`lg`,className:`mt-2`,onClick:s,children:i})]})})}var $x=`modulepreload`,eS=function(e,t){return new URL(e,t).href},tS={},nS=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e=document.getElementsByTagName(`link`),i=document.querySelector(`meta[property=csp-nonce]`),a=i?.nonce||i?.getAttribute(`nonce`);function o(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}function s(e){return import.meta.resolve?import.meta.resolve(e):new URL(e,import.meta.url).href}r=o(t.map(t=>{if(t=eS(t,n),t=s(t),t in tS)return;tS[t]=!0;let r=t.endsWith(`.css`);for(let n=e.length-1;n>=0;n--){let i=e[n];if(i.href===t&&(!r||i.rel===`stylesheet`))return}let i=document.createElement(`link`);if(i.rel=r?`stylesheet`:$x,r||(i.as=`script`),i.crossOrigin=``,i.href=t,a&&i.setAttribute(`nonce`,a),document.head.appendChild(i),r)return new Promise((e,n)=>{i.addEventListener(`load`,e),i.addEventListener(`error`,()=>n(Error(`Unable to preload CSS for ${t}`)))})}).filter(e=>e!==void 0))}function i(e){let t=new Event(`vite:preloadError`,{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return r.then(t=>{for(let e of t||[])e.status===`rejected`&&i(e.reason);return e().catch(i)})},rS=null;function iS(){return rS??=Promise.all([nS(()=>import(`./audio-BvhkVqBK.js`),[],import.meta.url),nS(()=>import(`./capture-processor-BbngzdtV.js`).then(e=>e.default),__vite__mapDeps([0,1]),import.meta.url),nS(()=>import(`./playback-processor-zTrexiPF.js`).then(e=>e.default),__vite__mapDeps([2,1]),import.meta.url)]).catch(e=>{throw rS=null,e}),rS}async function aS(e,t,n){let r=await n??void 0;try{return await oS(e,t,r)}catch(e){throw r?.close(),e}}async function oS(e,t,n){let[{createVoiceIO:r},i,a]=await iS();return r({preConnect:n,onPreConnectAudio:t.onPreConnectAudio,sttSampleRate:e.sampleRate,ttsSampleRate:e.ttsSampleRate,captureWorkletSrc:i,playbackWorkletSrc:a,onMicData:t.onMicData,onPlaybackProgress:t.onProgress,onError:e=>t.onFailure(e.message)})}function sS(e){return e===`local`?globalThis.localStorage:globalThis.sessionStorage}function cS(e,t){try{return sS(e)?.getItem(t)??void 0}catch{return}}function lS(e,t,n){try{sS(e)?.setItem(t,n)}catch{}}function uS(e,t){try{sS(e)?.removeItem(t)}catch{}}function dS(e,t){try{return`${e}${new URL(t,globalThis.location?.href).href}`}catch{return`${e}${t}`}}var fS=`aai:client:`;function pS(e){let t=crypto.getRandomValues(new Uint8Array(e));return Array.from(t,e=>e.toString(16).padStart(2,`0`)).join(``)}var mS=pS(4),hS=new Map;function gS(e=pu()){let t=dS(fS,e),n=hS.get(t);if(n)return n;let r=cS(`local`,t),i=r&&Bl.test(r)?r:`browser-${pS(16)}`;return i!==r&&lS(`local`,t,i),hS.set(t,i),i}function _S(e){return`${gS(e)}-${mS}`}function vS(e,t){return e===`auto`?()=>gS(t):e}function yS(e){let t=(typeof e==`function`?e():e)?.trim();return t===``?void 0:t}function bS(e,t){let n=vS(e.client,e.platformUrl);return Object.freeze({platformUrl:e.platformUrl,clientId:()=>yS(n),holderId:()=>_S(e.platformUrl),sessionId:()=>t()?.sessionId(),ticket:()=>t()?.ticket()})}var xS={running:!1,recording:!1};function SS(e,t){e.turn.bump(),t.flush()}function CS(e){let{conn:t,updateState:n,agentState:r,sendJson:i,mic:a,preConnect:o}=e;function s(e){let i=t.turn.current();e.done().then(()=>{t.turn.isCurrent(i)&&n(r.apply({type:`LISTEN`}))}).catch(e=>{console.warn(`Audio playback done failed:`,e)})}return{open:(t,n)=>(e.openAudioPath??aS)(t,n,o.take()),sendMicAudio:e=>{try{a.sendAudio(e)}catch{console.debug(`[aai-ui] sendAudio dropped: connection closed`)}},sendPreConnectAudio:e=>{try{a.sendBuffered(e)}catch{console.debug(`[aai-ui] pre-connect audio dropped: connection closed`)}},reportProgress:e=>{try{i({type:`playback_progress`,bufferedMs:e})}catch{}},announceReady:()=>i({type:`audio_ready`}),micLive:()=>n({recording:!0}),listen:()=>n(r.apply({type:`LISTEN`})),settleWhenDrained:s,reportFailure:e=>{n({...r.apply({type:`FAILED`,error:{code:`audio`,message:e,fatal:!1}}),...xS})},endTurn:()=>t.turn.bump(),release:e=>{e.close().catch(()=>{})}}}var wS=100,TS=Error(`audio path abandoned`),ES=(0,B.setup)({types:{},actors:{bringUp:(0,B.fromPromise)(async({input:e,signal:t})=>{let n=null,r=await e.effects.open(e.config,{onMicData:t=>e.effects.sendMicAudio(t),onPreConnectAudio:t=>e.effects.sendPreConnectAudio(t),onProgress:t=>{n&&e.send({type:`PROGRESS`,io:n,bufferedMs:t})},onFailure:t=>{n&&e.send({type:`IO_FAILED`,io:n,message:t})}});if(t.aborted)throw e.effects.release(r),TS;return n=r,r})},guards:{fromLiveIo:({context:e,event:t})=>(t.type===`PROGRESS`||t.type===`IO_FAILED`)&&e.io===t.io},actions:{rememberConfig:(0,B.assign)({config:({context:e,event:t})=>t.type===`START`?t.config:e.config}),buffer:(0,B.assign)({pending:({context:e,event:t})=>t.type===`CHUNK`&&e.pending.length<wS?[...e.pending,t.chunk]:e.pending}),rememberDone:(0,B.assign)({pendingDone:!0}),listenNow:({context:e})=>e.effects.listen(),forgetBuffered:(0,B.assign)({io:null,pending:[],pendingDone:!1}),endTurn:({context:e})=>e.effects.endTurn(),releaseIo:({context:e})=>{e.io&&e.effects.release(e.io)}}}).createMachine({id:`audioPath`,context:({input:e})=>({effects:e,io:null,pending:[],pendingDone:!1,config:null}),initial:`down`,on:{CHUNK:{actions:`buffer`},DONE:{actions:[`rememberDone`,`listenNow`]},TEARDOWN:`.down`},states:{down:{entry:[`endTurn`,`forgetBuffered`],on:{START:{target:`starting`,actions:`rememberConfig`}}},starting:{invoke:{src:`bringUp`,input:({context:e,self:t})=>({effects:e.effects,config:e.config??{sampleRate:0,ttsSampleRate:0},send:e=>{t.send(e)}}),onDone:{target:`up`,actions:[({context:e,event:t})=>{for(let n of e.pending)t.output.enqueue(n)},(0,B.assign)({io:({event:e})=>e.output,pending:[]}),({context:e,event:t})=>{e.effects.announceReady(),e.effects.micLive(),e.pendingDone?e.effects.settleWhenDrained(t.output):e.effects.listen()},(0,B.assign)({pendingDone:!1})]},onError:{target:`down`,actions:({context:e,event:t})=>{e.effects.reportFailure(`Microphone access failed: ${be(t.error)}`)}}}},up:{exit:`releaseIo`,on:{START:{target:`starting`,actions:`rememberConfig`},CHUNK:{actions:({context:e,event:t})=>e.io?.enqueue(t.chunk)},DONE:{actions:({context:e})=>{e.io&&e.effects.settleWhenDrained(e.io)}},PROGRESS:{guard:`fromLiveIo`,actions:({context:e,event:t})=>e.effects.reportProgress(t.bufferedMs)},IO_FAILED:{guard:`fromLiveIo`,target:`down`,actions:({context:e,event:t})=>e.effects.reportFailure(t.message)}}}}});function DS(e){let t=(0,B.createActor)(ES,{input:e}).start();return{phase:()=>t.getSnapshot().value,start:e=>{t.send({type:`START`,config:e})},enqueue:e=>{t.send({type:`CHUNK`,chunk:e})},done:()=>{t.send({type:`DONE`})},flush:()=>t.getSnapshot().context.io?.flush(),teardown:()=>{t.send({type:`TEARDOWN`})}}}var OS=1e3;function kS(e,t){let n=e.reason.trim();return n!==``&&e.code!==OS?n:t?`WebSocket connection error`:null}var AS={code:`connection`,message:`Agent did not complete the session handshake`,fatal:!1},jS=(0,B.setup)({types:{},delays:{HANDSHAKE_TIMEOUT:1e4},guards:{mayReconnect:(0,B.and)([({context:e,event:t})=>t.type===`DROPPED`&&t.reconnecting&&!e.effects.fatal(),(0,B.not)((0,B.stateIn)({retired:`yes`}))]),mayRedial:({context:e})=>e.timeouts+1<3&&e.effects.canRedial()},actions:{spend:(0,B.assign)({timeouts:({context:e})=>e.timeouts+1}),forgetError:(0,B.assign)({errored:!1}),retrying:({context:e})=>e.effects.retrying(),opened:({context:e})=>e.effects.opened(),dial:({context:e,event:t})=>e.link.dial(t.type===`DIAL`?t.signal:void 0),teardown:({context:e})=>e.link.teardown(),reportClose:({context:e,event:t})=>{t.type===`DROPPED`&&e.effects.closed(kS(t.event,e.errored))}}}).createMachine({id:`connection`,type:`parallel`,context:({input:e})=>({...e,timeouts:0,errored:!1}),states:{link:{initial:`closed`,on:{DIAL:{target:`.open`,reenter:!0},HANG_UP:`.closed`},states:{closed:{},open:{entry:[(0,B.assign)({timeouts:0,errored:!1}),`dial`],exit:`teardown`,initial:`dialing`,on:{ERRORED:{actions:(0,B.assign)({errored:!0})},CONFIGURED:{target:`.live`,actions:[(0,B.assign)({timeouts:0}),({context:e,event:t})=>e.effects.configured(t.config)]},DROPPED:[{guard:`mayReconnect`,target:`.dialing`,actions:[`forgetError`,`retrying`]},{target:`closed`,actions:`reportClose`}]},states:{dialing:{on:{OPENED:{target:`awaitingHandshake`,actions:`opened`}}},awaitingHandshake:{on:{OPENED:{target:`awaitingHandshake`,reenter:!0,actions:`opened`}},after:{HANDSHAKE_TIMEOUT:[{guard:`mayRedial`,target:`dialing`,actions:[`spend`,({context:e})=>e.effects.redial(),`retrying`]},{target:`#connection.link.closed`,actions:({context:e})=>e.effects.exhausted()}]}},live:{on:{OPENED:{target:`awaitingHandshake`,actions:`opened`}}}}}}},retired:{initial:`no`,states:{no:{on:{RETIRED:`yes`}},yes:{on:{DIAL:`no`}}}}}});function MS(e,t){let n=null;return{dial(r){let i=new AbortController,{signal:a}=i;r?.addEventListener(`abort`,()=>e.abandon(),{signal:a});let o=e.dial();n={socket:o,controller:i},o.addEventListener(`open`,()=>t({type:`OPENED`}),{signal:a}),o.addEventListener(`message`,n=>{let r=e.receive(n.data);r&&t({type:`CONFIGURED`,config:r})},{signal:a}),o.addEventListener(`error`,()=>t({type:`ERRORED`}),{signal:a}),o.addEventListener(`close`,n=>t({type:`DROPPED`,event:n,reconnecting:e.retryPending(o)}),{signal:a})},teardown(){if(n===null)return;let{socket:t,controller:r}=n;n=null,r.abort(),e.release(t)}}}function NS(e){let t=MS(e,e=>n.send(e)),n=(0,B.createActor)(jS,{input:{effects:e,link:t}}).start();return{dial:e=>{n.send({type:`DIAL`,signal:e})},hangUp:()=>{n.send({type:`HANG_UP`})},retire:()=>{n.send({type:`RETIRED`})},phase:()=>{let e=n.getSnapshot().value.link;return typeof e==`string`?`closed`:e.open}}}(!globalThis.EventTarget||!globalThis.Event)&&console.error(`
97
97
  PartySocket requires a global 'EventTarget' class to be available!
98
98
  You can polyfill this global by adding this to your code before any partysocket imports:
99
99
 
@@ -101,7 +101,7 @@ Error generating stack: `+e.message+`
101
101
  import 'partysocket/event-target-polyfill';
102
102
  \`\`\`
103
103
  Please file an issue at https://github.com/partykit/partykit if you're still having trouble.
104
- `);var AS=class extends Event{message;error;constructor(e,t){super(`error`,t),this.message=e.message,this.error=e}},jS=class extends Event{code;reason;wasClean=!0;constructor(e=1e3,t=``,n){super(`close`,n),this.code=e,this.reason=t}},MS={Event,ErrorEvent:AS,CloseEvent:jS};function NS(e,t){if(!e)throw Error(t)}function PS(e){return new e.constructor(e.type,e)}function FS(e){return`data`in e?new MessageEvent(e.type,e):`code`in e||`reason`in e?new jS(e.code||1999,e.reason||`unknown reason`,e):`error`in e?new AS(e.error,e):new Event(e.type,e)}var IS=typeof process<`u`&&process.versions?.node!==void 0,LS=typeof navigator<`u`&&navigator.product===`ReactNative`,RS=IS||LS?FS:PS,zS={maxReconnectionDelay:1e4,minReconnectionDelay:3e3,minUptime:5e3,reconnectionDelayGrowFactor:1.3,connectionTimeout:4e3,maxRetries:1/0,maxEnqueuedMessages:1/0,startClosed:!1,debug:!1},BS=!1;function VS(){}var HS=class e extends EventTarget{_ws;_retryCount=-1;_uptimeTimeout;_connectTimeout;_shouldReconnect=!0;_connectLock=!1;_binaryType=`blob`;_closeCalled=!1;_didWarnAboutClosedSend=!1;_messageQueue=[];_debugLogger=console.log.bind(console);_url;_protocols;_options;constructor(e,t,n={}){super(),this._url=e,this._protocols=t,this._options=n,this._options.startClosed&&(this._shouldReconnect=!1),this._options.debugLogger&&(this._debugLogger=this._options.debugLogger),this._connect()}static get CONNECTING(){return 0}static get OPEN(){return 1}static get CLOSING(){return 2}static get CLOSED(){return 3}get CONNECTING(){return e.CONNECTING}get OPEN(){return e.OPEN}get CLOSING(){return e.CLOSING}get CLOSED(){return e.CLOSED}get binaryType(){return this._ws?this._ws.binaryType:this._binaryType}set binaryType(e){this._binaryType=e,this._ws&&(this._ws.binaryType=e)}get retryCount(){return Math.max(this._retryCount,0)}get bufferedAmount(){return this._messageQueue.reduce((e,t)=>(typeof t==`string`?e+=t.length:t instanceof Blob?e+=t.size:e+=t.byteLength,e),0)+(this._ws?this._ws.bufferedAmount:0)}get extensions(){return this._ws?this._ws.extensions:``}get protocol(){return this._ws?this._ws.protocol:``}get readyState(){return this._closeCalled?e.CLOSED:this._ws?this._ws.readyState:this._options.startClosed?e.CLOSED:e.CONNECTING}get url(){return this._ws?this._ws.url:``}get shouldReconnect(){return this._shouldReconnect}onclose=null;onerror=null;onmessage=null;onopen=null;close(e=1e3,t){if(this._closeCalled=!0,this._shouldReconnect=!1,this._clearTimeouts(),!this._ws){this._debug(`close enqueued: no ws instance`);return}if(this._ws.readyState===this.CLOSED||this._ws.readyState===this.CLOSING){this._debug(`close: already closing or closed`);return}this._disconnect(e,t)}reconnect(e,t){this._shouldReconnect=!0,this._closeCalled=!1,this._didWarnAboutClosedSend=!1,this._retryCount=-1,!this._ws||this._ws.readyState===this.CLOSED||this._ws.readyState===this.CLOSING||this._disconnect(e,t),this._connect()}send(e){if(this._ws&&this._ws.readyState===this.OPEN)return this._debug(`send`,e),this._ws.send(e),!0;this._closeCalled&&!this._didWarnAboutClosedSend&&(this._didWarnAboutClosedSend=!0,console.warn(`ReconnectingWebSocket: send() was called after close(). The message has been buffered, but it will only be delivered if reconnect() is called on this socket. If this socket has been discarded, the message is lost — this usually means a stale socket reference is being used.`));let{maxEnqueuedMessages:t=zS.maxEnqueuedMessages}=this._options;return this._messageQueue.length<t&&(this._debug(`enqueue`,e),this._messageQueue.push(e)),!1}drainQueuedMessages(){let e=this._messageQueue;return this._messageQueue=[],e}_debug(...e){this._options.debug&&this._debugLogger(`RWS>`,...e)}_getNextDelay(){let{reconnectionDelayGrowFactor:e=zS.reconnectionDelayGrowFactor,minReconnectionDelay:t=zS.minReconnectionDelay,maxReconnectionDelay:n=zS.maxReconnectionDelay}=this._options,r=0;return this._retryCount>0&&(r=t*e**(this._retryCount-1),r>n&&(r=n)),this._debug(`next delay`,r),r}_wait(){return new Promise(e=>{setTimeout(e,this._getNextDelay())})}_getNextProtocols(e){if(!e)return Promise.resolve(null);if(typeof e==`string`||Array.isArray(e))return Promise.resolve(e);if(typeof e==`function`){let t=e();if(!t)return Promise.resolve(null);if(typeof t==`string`||Array.isArray(t))return Promise.resolve(t);if(t.then)return t}throw Error(`Invalid protocols`)}_getNextUrl(e){if(typeof e==`string`)return Promise.resolve(e);if(typeof e==`function`){let t=e();if(typeof t==`string`)return Promise.resolve(t);if(t.then)return t}throw Error(`Invalid URL`)}_connect(){if(this._connectLock||!this._shouldReconnect)return;this._connectLock=!0;let{maxRetries:e=zS.maxRetries,connectionTimeout:t=zS.connectionTimeout}=this._options;if(this._retryCount>=e){this._debug(`max retries reached`,this._retryCount,`>=`,e),this._connectLock=!1;return}this._retryCount++,this._debug(`connect`,this._retryCount),this._removeListeners(),this._wait().then(()=>Promise.all([this._getNextUrl(this._url),this._getNextProtocols(this._protocols||null)])).then(([e,n])=>{if(this._closeCalled){this._connectLock=!1;return}!this._options.WebSocket&&typeof WebSocket>`u`&&!BS&&(console.error(`‼️ No WebSocket implementation available. You should define options.WebSocket.
104
+ `);var PS=class extends Event{message;error;constructor(e,t){super(`error`,t),this.message=e.message,this.error=e}},FS=class extends Event{code;reason;wasClean=!0;constructor(e=1e3,t=``,n){super(`close`,n),this.code=e,this.reason=t}},IS={Event,ErrorEvent:PS,CloseEvent:FS};function LS(e,t){if(!e)throw Error(t)}function RS(e){return new e.constructor(e.type,e)}function zS(e){return`data`in e?new MessageEvent(e.type,e):`code`in e||`reason`in e?new FS(e.code||1999,e.reason||`unknown reason`,e):`error`in e?new PS(e.error,e):new Event(e.type,e)}var BS=typeof process<`u`&&process.versions?.node!==void 0,VS=typeof navigator<`u`&&navigator.product===`ReactNative`,HS=BS||VS?zS:RS,US={maxReconnectionDelay:1e4,minReconnectionDelay:3e3,minUptime:5e3,reconnectionDelayGrowFactor:1.3,connectionTimeout:4e3,maxRetries:1/0,maxEnqueuedMessages:1/0,startClosed:!1,debug:!1},WS=!1;function GS(){}var KS=class e extends EventTarget{_ws;_retryCount=-1;_uptimeTimeout;_connectTimeout;_shouldReconnect=!0;_connectLock=!1;_binaryType=`blob`;_closeCalled=!1;_didWarnAboutClosedSend=!1;_messageQueue=[];_debugLogger=console.log.bind(console);_url;_protocols;_options;constructor(e,t,n={}){super(),this._url=e,this._protocols=t,this._options=n,this._options.startClosed&&(this._shouldReconnect=!1),this._options.debugLogger&&(this._debugLogger=this._options.debugLogger),this._connect()}static get CONNECTING(){return 0}static get OPEN(){return 1}static get CLOSING(){return 2}static get CLOSED(){return 3}get CONNECTING(){return e.CONNECTING}get OPEN(){return e.OPEN}get CLOSING(){return e.CLOSING}get CLOSED(){return e.CLOSED}get binaryType(){return this._ws?this._ws.binaryType:this._binaryType}set binaryType(e){this._binaryType=e,this._ws&&(this._ws.binaryType=e)}get retryCount(){return Math.max(this._retryCount,0)}get bufferedAmount(){return this._messageQueue.reduce((e,t)=>(typeof t==`string`?e+=t.length:t instanceof Blob?e+=t.size:e+=t.byteLength,e),0)+(this._ws?this._ws.bufferedAmount:0)}get extensions(){return this._ws?this._ws.extensions:``}get protocol(){return this._ws?this._ws.protocol:``}get readyState(){return this._closeCalled?e.CLOSED:this._ws?this._ws.readyState:this._options.startClosed?e.CLOSED:e.CONNECTING}get url(){return this._ws?this._ws.url:``}get shouldReconnect(){return this._shouldReconnect}onclose=null;onerror=null;onmessage=null;onopen=null;close(e=1e3,t){if(this._closeCalled=!0,this._shouldReconnect=!1,this._clearTimeouts(),!this._ws){this._debug(`close enqueued: no ws instance`);return}if(this._ws.readyState===this.CLOSED||this._ws.readyState===this.CLOSING){this._debug(`close: already closing or closed`);return}this._disconnect(e,t)}reconnect(e,t){this._shouldReconnect=!0,this._closeCalled=!1,this._didWarnAboutClosedSend=!1,this._retryCount=-1,!this._ws||this._ws.readyState===this.CLOSED||this._ws.readyState===this.CLOSING||this._disconnect(e,t),this._connect()}send(e){if(this._ws&&this._ws.readyState===this.OPEN)return this._debug(`send`,e),this._ws.send(e),!0;this._closeCalled&&!this._didWarnAboutClosedSend&&(this._didWarnAboutClosedSend=!0,console.warn(`ReconnectingWebSocket: send() was called after close(). The message has been buffered, but it will only be delivered if reconnect() is called on this socket. If this socket has been discarded, the message is lost — this usually means a stale socket reference is being used.`));let{maxEnqueuedMessages:t=US.maxEnqueuedMessages}=this._options;return this._messageQueue.length<t&&(this._debug(`enqueue`,e),this._messageQueue.push(e)),!1}drainQueuedMessages(){let e=this._messageQueue;return this._messageQueue=[],e}_debug(...e){this._options.debug&&this._debugLogger(`RWS>`,...e)}_getNextDelay(){let{reconnectionDelayGrowFactor:e=US.reconnectionDelayGrowFactor,minReconnectionDelay:t=US.minReconnectionDelay,maxReconnectionDelay:n=US.maxReconnectionDelay}=this._options,r=0;return this._retryCount>0&&(r=t*e**(this._retryCount-1),r>n&&(r=n)),this._debug(`next delay`,r),r}_wait(){return new Promise(e=>{setTimeout(e,this._getNextDelay())})}_getNextProtocols(e){if(!e)return Promise.resolve(null);if(typeof e==`string`||Array.isArray(e))return Promise.resolve(e);if(typeof e==`function`){let t=e();if(!t)return Promise.resolve(null);if(typeof t==`string`||Array.isArray(t))return Promise.resolve(t);if(t.then)return t}throw Error(`Invalid protocols`)}_getNextUrl(e){if(typeof e==`string`)return Promise.resolve(e);if(typeof e==`function`){let t=e();if(typeof t==`string`)return Promise.resolve(t);if(t.then)return t}throw Error(`Invalid URL`)}_connect(){if(this._connectLock||!this._shouldReconnect)return;this._connectLock=!0;let{maxRetries:e=US.maxRetries,connectionTimeout:t=US.connectionTimeout}=this._options;if(this._retryCount>=e){this._debug(`max retries reached`,this._retryCount,`>=`,e),this._connectLock=!1;return}this._retryCount++,this._debug(`connect`,this._retryCount),this._removeListeners(),this._wait().then(()=>Promise.all([this._getNextUrl(this._url),this._getNextProtocols(this._protocols||null)])).then(([e,n])=>{if(this._closeCalled){this._connectLock=!1;return}!this._options.WebSocket&&typeof WebSocket>`u`&&!WS&&(console.error(`‼️ No WebSocket implementation available. You should define options.WebSocket.
105
105
 
106
106
  For example, if you're using node.js, run \`npm install ws\`, and then in your code:
107
107
 
@@ -114,13 +114,13 @@ const partysocket = new PartySocket({
114
114
  WebSocket: WS
115
115
  });
116
116
 
117
- `),BS=!0);let r=this._options.WebSocket||WebSocket;this._debug(`connect`,{url:e,protocols:n}),this._ws=n?new r(e,n):new r(e),this._ws.binaryType=this._binaryType,this._connectLock=!1,this._addListeners(),this._connectTimeout=setTimeout(()=>this._handleTimeout(),t)}).catch(e=>{this._connectLock=!1,this._handleError(new MS.ErrorEvent(Error(e.message),this))})}_handleTimeout(){this._debug(`timeout event`),this._handleError(new MS.ErrorEvent(Error(`TIMEOUT`),this))}_disconnect(e=1e3,t){if(this._clearTimeouts(),this._ws){this._removeListeners();try{(this._ws.readyState===this.OPEN||this._ws.readyState===this.CONNECTING)&&this._ws.close(e,t),this._handleClose(new MS.CloseEvent(e,t,this))}catch{}}}_acceptOpen(){this._debug(`accept open`),this._retryCount=0}_handleOpen=e=>{this._debug(`open event`);let{minUptime:t=zS.minUptime}=this._options;clearTimeout(this._connectTimeout),this._uptimeTimeout=setTimeout(()=>this._acceptOpen(),t),NS(this._ws,`WebSocket is not defined`),this._ws.binaryType=this._binaryType,this._messageQueue.forEach(e=>{this._ws?.send(e)}),this._messageQueue=[],this.onopen&&this.onopen(e),this.dispatchEvent(RS(e))};_handleMessage=e=>{this._debug(`message event`),this.onmessage&&this.onmessage(e),this.dispatchEvent(RS(e))};_handleError=e=>{this._debug(`error event`,e.message),this._disconnect(void 0,e.message===`TIMEOUT`?`timeout`:void 0),this.onerror&&this.onerror(e),this._debug(`exec error listeners`),this.dispatchEvent(RS(e)),this._connect()};_handleClose=e=>{this._debug(`close event`),this._clearTimeouts(),this._options.shouldReconnectOnClose&&!this._options.shouldReconnectOnClose(e)&&(this._shouldReconnect=!1),this._shouldReconnect&&this._connect(),this.onclose&&this.onclose(e),this.dispatchEvent(RS(e))};_removeListeners(){this._ws&&(this._debug(`removeListeners`),this._ws.removeEventListener(`open`,this._handleOpen),this._ws.removeEventListener(`close`,this._handleClose),this._ws.removeEventListener(`message`,this._handleMessage),this._ws.removeEventListener(`error`,this._handleError),this._ws.addEventListener(`error`,VS))}_addListeners(){this._ws&&(this._debug(`addListeners`),this._ws.addEventListener(`open`,this._handleOpen),this._ws.addEventListener(`close`,this._handleClose),this._ws.addEventListener(`message`,this._handleMessage),this._ws.addEventListener(`error`,this._handleError))}_clearTimeouts(){clearTimeout(this._connectTimeout),clearTimeout(this._uptimeTimeout)}},US={minReconnectionDelay:1e3,maxReconnectionDelay:15e3,reconnectionDelayGrowFactor:2,maxRetries:10};function WS(e,t){return new HS(e,t,US)}function GS(e){return e instanceof HS&&(e.reconnect(),!0)}function KS(e){return e instanceof HS&&e.shouldReconnect&&e.retryCount<US.maxRetries}var qS=`aai:session:`;function JS(e){return dS(qS,e)}function YS(e){return cS(`session`,JS(e))}function XS(e,t){lS(`session`,JS(e),t)}function ZS(e){uS(`session`,JS(e))}var QS=`aai:session-ticket:`;function $S(e){return cS(`session`,dS(QS,e))}function eC(e,t){lS(`session`,dS(QS,e),t)}function tC(e){uS(`session`,dS(QS,e))}var nC=/^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/;function rC(e){let t=e?.trim();return t===``?void 0:t}async function iC(e,t){if(typeof e!=`function`)return rC(e);try{return rC(await e(t))}catch(e){console.warn("session-core: the `token` getter failed; dialing without a ticket",e);return}}function aC(e,t){if(typeof e!=`function`)return rC(e);let n=e(t);if(typeof n!=`string`&&n!==void 0)throw TypeError("VoiceSessionOptions.token: an injected `WebSocket` opens synchronously, so its `token` getter must return a string, not a Promise");return rC(n)}function oC(e){if(e===void 0)return{};let t=`${iu}${e}`;return nC.test(t)?{protocols:[ru,t]}:{queryToken:e}}function sC(e,t,n={}){return uC(hu(e,`websocket`),t,n)}function cC(e,t,n={}){return uC(new URL(e),t,n)}var lC={"https:":`wss:`,"http:":`ws:`};function uC(e,t,n){return e.protocol=lC[e.protocol]??e.protocol,t&&e.searchParams.set(`sessionId`,t),n.location&&e.searchParams.set(`location`,n.location),n.phone&&e.searchParams.set(`phone`,n.phone),n.client&&e.searchParams.set(`client`,n.client),e}function dC(e,t){return t.queryToken!==void 0&&e.searchParams.set(`token`,t.queryToken),e.toString()}function fC(e,t){let n=e.resumeSessionId??YS(e.platformUrl),r,i=$S(e.platformUrl),a;function o(e){e!==a&&(a=e,t?.())}function s(){return{location:yS(e.location),phone:yS(e.phone),client:yS(e.client)}}async function c(){let t=iC(e.token,{sessionId:n}),a=n===void 0?void 0:i,o=r===!1?null:await vu(e.platformUrl,void 0,a);o&&(r=o.sessionUrl!==void 0||o.sessionToken!==void 0);let c=await t;c===void 0&&o?.sessionToken!==void 0&&(i=o.sessionToken,eC(e.platformUrl,i));let l=oC(c??o?.sessionToken);return{url:dC(o?.sessionUrl?cC(o.sessionUrl,n,s()):sC(e.platformUrl,n,s()),l),protocols:l.protocols}}let l;return{open:()=>{if(e.WebSocket){let t=oC(aC(e.token,{sessionId:n})),r=dC(sC(e.platformUrl,n,s()),t);return t.protocols?new e.WebSocket(r,t.protocols):new e.WebSocket(r)}return WS(async()=>(l=c(),(await l).url),async()=>(await(l??c())).protocols??null)},configured:t=>{n=t,XS(e.platformUrl,t),o(t)},adopt:t=>{n=t,XS(e.platformUrl,t)},forget:()=>{n=void 0,ZS(e.platformUrl),i=void 0,tC(e.platformUrl),o(void 0)},sessionId:()=>a,ticket:()=>{if(e.token!==void 0)return typeof e.token==`function`?iC(e.token,{sessionId:void 0}):aC(e.token,{sessionId:void 0});if(r!==!1)return vu(e.platformUrl).then(e=>(e&&(r=e.sessionUrl!==void 0||e.sessionToken!==void 0),e?.sessionToken))}}}var pC={code:`connection`,message:`Agent did not complete the session handshake`,fatal:!1},mC=1e4,hC=3;function gC(e){let t,n=0;function r(){t!==void 0&&(clearTimeout(t),t=void 0)}function i(){if(t=void 0,n+=1,n<hC&&GS(e.socket)){e.onRetry();return}e.onExhausted()}return e.signal.addEventListener(`abort`,r),{arm(){r(),t=setTimeout(i,mC)},disarm:r,succeeded(){r(),n=0}}}var _C=200,vC=200,yC={messages:[],toolCalls:[],customEvents:[],agentState:null,userTranscript:null,agentTranscript:null,error:null};function bC(e,t,n){if(e.length<n)return[...e,t];let r=e.slice(e.length-n+1);return r.push(t),r}function xC(e){let{getSnapshot:t,updateState:n,conn:r,agentState:i,audio:a}=e,o=0,s=0,c=0;function l(e,r){n({customEvents:bC(t().customEvents,{id:++o,event:e,data:r},_C)})}function u(e){r.turn.bump(),n({userTranscript:null,messages:bC(t().messages,{id:++s,role:`user`,content:e},vC),...i.apply({type:`THINK`})})}function d(e){n({agentTranscript:e})}function f(){let e=t().agentTranscript;if(e===null||e.length===0){n({agentTranscript:null});return}n({agentTranscript:null,messages:bC(t().messages,{id:++s,role:`assistant`,content:e},vC)})}function p(){n(i.apply({type:`ACTIVITY`}))}function m(e={}){n({...e,...i.apply({type:`LISTEN`})})}function h(e){console.error(`Agent error:`,e.message);let t={code:e.code,message:e.message,fatal:e.fatal};e.fatal?(a.teardown(),n({...i.apply({type:`FATAL`,error:t}),...xS})):n(i.apply({type:`TURN_ERROR`,error:t}))}function g(e){switch(e.type!==`error.reported`&&p(),e.type){case`speech.started`:n({userTranscript:``});break;case`speech.stopped`:break;case`userTranscript.committed`:u(e.text);break;case`userTranscript.updated`:n({userTranscript:e.text});break;case`agentTranscript.updated`:case`agentTranscript.committed`:d(e.text);break;case`tool.called`:n({toolCalls:bC(t().toolCalls,{callId:e.toolCallId,name:e.toolName,args:xl(e.args),status:`pending`,seq:++c,afterMessageId:t().messages.at(-1)?.id??-1},vC)});break;case`tool.completed`:{let r=t().toolCalls,i=r.findIndex(t=>t.callId===e.toolCallId),a=r[i];if(!a)break;let o=[...r];o[i]={...a,status:`done`,result:e.result},n({toolCalls:o});break}case`reply.completed`:f(),m();break;case`reply.cancelled`:SS(r,a),f(),m({userTranscript:null});break;case`session.reset`:{SS(r,a);let e=i.apply({type:`RESET`});n(i.fatal()?e:{...yC,...e});break}case`custom.emitted`:l(e.event,e.data);break;case`state.updated`:n({agentState:SC(t().agentState,e.state)});break;case`history.restored`:{s=0,c=0;let t=e.messages.slice(-vC).map(e=>({id:++s,role:e.role,content:e.content}));n({messages:t,toolCalls:e.toolCalls.slice(-vC).map(e=>({callId:e.callId,name:e.name,args:xl(e.args),status:e.status,...w({result:e.result}),seq:++c,afterMessageId:t[e.afterMessageIndex]?.id??-1}))});break}case`error.reported`:h(e);break;case`session.timedOut`:r.retiredByServer=!0}}function _(e){n(i.apply({type:`SPEAK`})),a.enqueue(e)}function v(){a.done()}function y(e){if(e instanceof ArrayBuffer){_(e);return}if(typeof e!=`string`){console.warn(`session-core: non-string, non-binary frame received; dropping`);return}let t=T(e);if(t===void 0){console.warn(`session-core: invalid JSON; dropping`);return}let n=tu($l,t);if(!n.ok){n.malformed&&console.warn(`session-core: malformed server message`,n.error);return}let r=n.data;if(r.type===`session.configured`)return i.apply({type:`HANDSHAKE_COMPLETE`}),{sampleRate:r.sampleRate,ttsSampleRate:r.ttsSampleRate,sid:r.sessionId};if(r.type===`audio.completed`){v();return}g(r)}return{handleMessage:y}}function SC(e,t){if(e===null)return t;let n={};for(let[r,i]of Object.entries(t)){let t=e[r];n[r]=r in e&&JSON.stringify(t)===JSON.stringify(i)?t:i}return n}function CC(e){let t=new ArrayBuffer(0),n=e=>(t.byteLength!==e&&(t=new ArrayBuffer(e)),t);return{sendAudio(t){let r=e.conn.ws;r?.readyState===1&&(r.bufferedAmount>65536||r.send(e.snapshot().micMuted?n(t.byteLength):t))},sendBuffered(t){let r=e.conn.ws;if(r?.readyState!==1)return;let i=e.snapshot().micMuted;for(let e of t)r.send(i?n(e.byteLength):e)},setMicMuted(t){e.updateState({micMuted:t})}}}var wC=16e3;function TC(e){let t=null,n=null;return{begin(){if(iS().catch(()=>{}),!e||t!==null)return;let r={released:!1};n=r,t=Promise.all([nS(()=>import(`./audio-CABEDpag.js`),[],import.meta.url),iS()]).then(([{openPreConnectCapture:e},[,t]])=>r.released?null:e({sampleRate:wC,captureWorkletSrc:t,maxSeconds:10})).catch(()=>null)},take(){let e=t;return t=null,n=null,e},release(){let e=t;t=null,n&&(n.released=!0),n=null,e?.then(e=>e?.close())}}}var EC=(0,B.not)((0,B.stateIn)({fatal:`yes`})),DC=(0,B.setup)({types:{},guards:{hasError:({context:e})=>e.error!==null},actions:{clearError:(0,B.assign)({error:null}),setError:(0,B.assign)({error:({context:e,event:t})=>t.type===`TURN_ERROR`||t.type===`FATAL`||t.type===`FAILED`?t.error:e.error})}}).createMachine({id:`sessionState`,type:`parallel`,context:{error:null},states:{phase:{initial:`disconnected`,on:{CONNECT:{target:`.connecting`,actions:`clearError`},CLOSED:{target:`.disconnected`,actions:`clearError`},DISCONNECT:`.disconnected`,END:{target:`.disconnected`,actions:`clearError`},TURN_ERROR:{actions:`setError`},FATAL:{target:`.error`,actions:`setError`},FAILED:{target:`.error`,actions:`setError`},LISTEN:{guard:EC,target:`.listening`},RESET:{guard:EC,target:`.listening`,actions:`clearError`},THINK:{guard:EC,target:`.thinking`},ACTIVITY:{guard:(0,B.and)([EC,`hasError`]),actions:`clearError`}},states:{disconnected:{on:{SPEAK:{guard:(0,B.not)(`hasError`),target:`speaking`}}},connecting:{on:{SOCKET_OPEN:`ready`}},ready:{on:{SPEAK:`speaking`}},listening:{on:{SPEAK:`speaking`}},thinking:{on:{SPEAK:`speaking`}},speaking:{},error:{on:{ACTIVITY:{guard:EC,target:`listening`,actions:`clearError`},CLOSED:{}}}}},fatal:{initial:`no`,states:{no:{on:{FATAL:`yes`}},yes:{on:{HANDSHAKE_COMPLETE:`no`}}}}}});function OC(){let e=(0,B.createActor)(DC).start();function t(){let t=e.getSnapshot();return{state:t.value.phase,error:t.context.error}}return{snapshot:t,apply(n){return e.send(n),t()},fatal:()=>e.getSnapshot().matches({fatal:`yes`})}}function kC(e){let{state:t}=e.snapshot();(t===`speaking`||t===`thinking`)&&(e.bargeIn(),e.updateState(e.agentState.apply({type:`LISTEN`})))}function AC(e){function t(t){kC(e),e.sendJson({type:`user_text`,text:t})}return{userTurn:MC(e),sendText(n,r){let i=n.trim();if(i!==``){if(e.connected()&&e.queued.length===0){t(i);return}(e.queued.length!==0||r?.connect===!0)&&(e.queued.push(i),e.open())}},flushQueued(){if(e.connected())for(let n of e.queued.splice(0))t(n)},sendToolResult(t,n){e.connected()&&e.sendJson({type:`tool_result`,toolCallId:t,...jC(n)})}}}function jC(e){if(`error`in e)return{result:``,error:e.error};try{return{result:JSON.stringify(e.result??null)??`null`}}catch(e){return{result:``,error:`Tool result is not JSON-serializable: ${String(e)}`}}}function MC(e){return{start(){e.connected()&&(kC(e),e.sendJson({type:`user_turn_start`}))},commit(){e.connected()&&e.sendJson({type:`user_turn_commit`})},clear(){e.connected()&&(e.updateState({userTranscript:null}),e.sendJson({type:`user_turn_clear`}))}}}function NC(e){return PC(e,{})}function PC(e,t){let n={...yC,state:`disconnected`,contentVersion:0,started:!1,running:!1,recording:!1,micMuted:!1,apiUrl:sC(e.platformUrl).toString()},r=new Set;function i(){for(let e of r)e()}let a=[`messages`,`toolCalls`,`userTranscript`,`agentTranscript`];function o(e,t){return t[e]===n[e]}let s=[];function c(e){e.running===!1&&(s.length=0),!Object.keys(e).every(t=>o(t,e))&&(n=a.some(t=>t in e&&e[t]!==n[t])?{...n,...e,contentVersion:n.contentVersion+1}:{...n,...e},i())}function l(){return n}function u(e){return r.add(e),()=>{r.delete(e)}}let d=OC(),f={ws:null,retiredByServer:!1,turn:Al()},p=null,m=bS(e,()=>h),h=fC({...e,client:m.clientId},i);function g(){c(yC)}function _(){return f.ws?.readyState===1?f.ws:null}function v(e){_()?.send(JSON.stringify(e))}let y=CC({conn:f,snapshot:()=>n,updateState:c}),b=TC(e.preConnectAudio!==!1),x=DS(CS({conn:f,updateState:c,agentState:d,sendJson:v,mic:y,preConnect:b,openAudioPath:t.openAudioPath})),{handleMessage:ee}=xC({getSnapshot:l,updateState:c,conn:f,agentState:d,audio:x});function S(){p?.abort(),p=null,b.release(),x.teardown(),f.ws?.close(),f.ws=null}function C(t){h.configured(t.sid),e.onSessionId?.(t.sid),ne(),x.start(t)}function w(e){if(e?.signal?.aborted){ae();return}c(d.apply({type:`CONNECT`})),S(),b.begin(),f.retiredByServer=!1;let t=new AbortController;p=t;let{signal:n}=t;e?.signal&&e.signal.addEventListener(`abort`,()=>ae(),{signal:n});let r=h.open();r.binaryType=`arraybuffer`,f.ws=r;let i=!1,a=gC({socket:r,signal:n,onRetry:()=>{x.teardown(),c({...d.apply({type:`CONNECT`}),recording:!1})},onExhausted:()=>{b.release(),x.teardown(),t.abort(),r.close(),f.ws=null,c({...d.apply({type:`FAILED`,error:pC}),...xS})}});r.addEventListener(`open`,()=>{c(d.apply({type:`SOCKET_OPEN`})),a.arm()},{signal:n}),r.addEventListener(`message`,e=>{let t=ee(e.data);t&&(a.succeeded(),C(t))},{signal:n}),r.addEventListener(`error`,()=>{i=!0},{signal:n}),r.addEventListener(`close`,e=>{if(n.aborted)return;if(a.disarm(),x.teardown(),!(f.retiredByServer||d.fatal())&&KS(r)){i=!1,c({...d.apply({type:`CONNECT`}),recording:!1});return}b.release(),t.abort(),r.close(),f.ws=null;let o=kS(e,i);c({...o===null?d.apply({type:`CLOSED`}):d.apply({type:`FAILED`,error:{code:`connection`,message:o,fatal:!1}}),...xS})},{signal:n})}function T(){_()&&(SS(f,x),c(d.apply({type:`LISTEN`})),v({type:`cancel`}))}let{userTurn:te,sendText:E,flushQueued:ne,sendToolResult:re}=AC({snapshot:()=>n,connected:()=>_()!==null,queued:s,open:()=>{n.running||(n.started?se:oe)()},bargeIn:()=>SS(f,x),agentState:d,updateState:c,sendJson:v});function ie(){if(SS(f,x),_()){v({type:`reset`});return}ce(),oe()}function ae(){S(),c({...d.apply({type:`DISCONNECT`}),...xS})}function oe(){c({started:!0,running:!0}),w()}function se(){n.running?ae():(c({running:!0}),w())}function ce(){S(),h.forget(),c({...yC,...d.apply({type:`END`}),started:!1,...xS})}function le(){ce(),oe()}function ue(e){if(!Vl.test(e))throw RangeError(`resume: "${e}" is not a session id (${Vl})`);ce(),h.adopt(e),oe()}return{getSnapshot:l,subscribe:u,connect:w,cancel:T,userTurn:Object.freeze(te),identity:m,sendText:E,sendToolResult:re,setMicMuted:y.setMicMuted,resetState:g,reset:ie,disconnect:ae,start:oe,toggle:se,end:ce,restart:le,resume:ue,[Symbol.dispose](){ae()}}}function FC(e=`#app`){if(typeof e!=`string`)return e;let t=document.querySelector(e);if(!t)throw Error(`Element not found: ${e} — no element matches that selector when the mount runs. Add \`<div id="app"></div>\` (or the element your selector names) to the page before the script, or pass the element itself as the mount's \`target\` option.`);return t}function IC(e,t,n){let r=(0,ju.createRoot)(e);return(0,Au.flushSync)(()=>{r.render(t)}),{dispose(){r.unmount(),n?.()},[Symbol.dispose](){this.dispose()}}}function LC({name:e,icon:t,subtitle:n,buttonText:r,Sidebar:i,...a}){let o=(0,U.jsx)(Xx,{title:e,icon:t});return(0,U.jsx)(Qx,{title:e,icon:t,subtitle:n,buttonText:r,children:i?(0,U.jsx)(Zx,{sidebar:(0,U.jsx)(i,{}),sidebarWidth:a.sidebarWidth,sidebarPosition:a.sidebarPosition,children:o}):o})}function RC({platformUrl:e,...t}){let{name:n}=t,[r,i]=(0,V.useState)(null),a=n===void 0;return(0,V.useEffect)(()=>{if(!a)return;let t=!1;return yu(e).then(e=>{t||i(e)}),()=>{t=!0}},[e,a]),(0,U.jsx)(LC,{...t,name:n??r?.name})}function zC(e,t){let n=e.component,r=e.sidebar;return n?r?(0,U.jsx)(Zx,{sidebar:(0,U.jsx)(r,{}),sidebarWidth:e.sidebarWidth,sidebarPosition:e.sidebarPosition,children:(0,U.jsx)(n,{})}):(0,U.jsx)(n,{}):(0,U.jsx)(RC,{platformUrl:t,name:e.name,icon:e.icon,subtitle:e.subtitle,buttonText:e.buttonText,Sidebar:r,sidebarWidth:e.sidebarWidth,sidebarPosition:e.sidebarPosition})}function BC(e){return VC(e,NC)}function VC(e,t){let n=FC(e.target),r=e.platformUrl??pu(),i=t({platformUrl:r,onSessionId:e.onSessionId,resumeSessionId:e.resumeSessionId,location:e.location,phone:e.phone,client:e.client,token:e.token,WebSocket:e.WebSocket});mu(e.name);let a=zC(e,r),o=e.tools??{};return{session:i,...IC(n,(0,V.createElement)(Lx.Provider,{value:o},(0,V.createElement)(Uu,{value:e.theme},(0,V.createElement)(Fu,{value:i},a))),()=>i[Symbol.dispose]())}}var HC=(0,V.createContext)(void 0),UC=HC.Provider;function WC(){let[e,t]=(0,V.useState)(()=>new Set),n=(0,V.useCallback)((e,n)=>{t(t=>{if(n===t.has(e))return t;let r=new Set(t);return n?r.add(e):r.delete(e),r})},[]);return{pending:e.size>0,declare:n}}function GC(e){let t=(0,V.useContext)(HC),n=(0,V.useId)();(0,V.useEffect)(()=>{if(t)return t(n,e),()=>t(n,!1)},[t,n,e])}async function KC(e){let t={};for(let n of Array.from(e.elements))n instanceof HTMLInputElement?await JC(n,t):(n instanceof HTMLTextAreaElement||n instanceof HTMLSelectElement)&&n.name!==``&&!n.disabled&&(t[n.name]=n instanceof HTMLSelectElement?qC(n):n.value);return t}function qC(e){return e.multiple?Array.from(e.selectedOptions,e=>e.value):e.value}async function JC(e,t){if(!(e.name===``||e.disabled))switch(e.type){case`checkbox`:t[e.name]=e.checked;return;case`radio`:e.checked&&(t[e.name]=e.value);return;case`number`:case`range`:{if(e.value===``)return;let n=e.valueAsNumber;t[e.name]=Number.isNaN(n)?e.value:n;return}case`file`:{let n=Array.from(e.files??[]);if(n.length===0)return;let r=await YC(n,XC(e.dataset.aaiRead));t[e.name]=e.multiple?r:r[0];return}default:t[e.name]=e.value}}function YC(e,t){return t===`upload`?Promise.resolve([...e]):Promise.all(e.map(e=>ZC(e,t)))}function XC(e){return e===`text`||e===`dataUrl`||e===`upload`?e:`none`}async function ZC(e,t){let n={name:e.name,size:e.size,type:e.type,lastModified:e.lastModified};return t===`none`?n:{...n,content:t===`text`?await e.text():await QC(e)}}function QC(e){return new Promise((t,n)=>{let r=new FileReader;r.onerror=()=>n(r.error??Error(`Could not read ${e.name}`)),r.onload=()=>t(String(r.result)),r.readAsDataURL(e)})}function $C({label:e,hint:t,htmlFor:n,className:r,children:i}){let a=Ku();return(0,U.jsxs)(`div`,{className:H(`flex flex-col gap-1.5`,r),children:[e!==void 0&&(0,U.jsx)(`label`,{htmlFor:n,className:`text-[11px] font-medium uppercase tracking-[1.2px]`,style:{color:a.text},children:e}),i,t!==void 0&&(0,U.jsx)(`p`,{className:`text-xs opacity-60`,style:{color:a.text},children:t})]})}function ew(){let e=Ku();return{className:H(`w-full rounded-aai border px-3 py-2 text-sm font-aai`,$u,`disabled:cursor-not-allowed disabled:opacity-50`),style:{background:e.surface,color:e.text,borderColor:e.border,...ed(e.primary)}}}function tw(){let e=Ku(),t=ew();return{className:H(t.className,`cursor-pointer py-1.5 pl-1.5`,`file:mr-3 file:cursor-pointer file:rounded-aai file:border-0 file:px-3 file:py-1.5`,`file:text-sm file:font-medium file:font-aai`,`file:[background:var(--aai-file-button-bg)] file:[color:var(--aai-file-button-fg)]`),style:{...t.style,"--aai-file-button-bg":e.primary,"--aai-file-button-fg":e.surface}}}function nw({defaultType:e,name:t,label:n,hint:r,className:i,...a}){let o=(0,V.useId)(),s=ew();return(0,U.jsx)($C,{label:n,hint:r,htmlFor:o,className:i,children:(0,U.jsx)(`input`,{id:o,name:t,type:e,...s,...a})})}function rw(e){return(0,U.jsx)(nw,{defaultType:`text`,...e})}function iw(e){return(0,U.jsx)(nw,{defaultType:`number`,...e})}function aw({name:e,label:t,hint:n,className:r,options:i,children:a,...o}){let s=(0,V.useId)(),c=ew();return(0,U.jsx)($C,{label:t,hint:n,htmlFor:s,className:r,children:(0,U.jsx)(`select`,{id:s,name:e,...c,...o,children:a??i?.map(e=>{let t=typeof e==`string`?e:e.value,n=typeof e==`string`?e:e.label;return(0,U.jsx)(`option`,{value:t,children:n},t)})})})}function ow({name:e,label:t,hint:n,className:r,...i}){let a=(0,V.useId)(),o=Ku();return(0,U.jsx)($C,{hint:n,className:r,children:(0,U.jsxs)(`label`,{htmlFor:a,className:`flex items-center gap-2 text-sm`,style:{color:o.text},children:[(0,U.jsx)(`input`,{id:a,name:e,type:`checkbox`,style:{accentColor:o.primary},...i}),t]})})}function sw({name:e,label:t,hint:n,className:r,read:i=`none`,upload:a=!1,...o}){let s=(0,V.useId)(),c=tw();return(0,U.jsx)($C,{label:t,hint:n,htmlFor:s,className:r,children:(0,U.jsx)(`input`,{id:s,name:e,type:`file`,"data-aai-read":a?`upload`:i,...c,...o})})}function cw({onSubmit:e,error:t,children:n,className:r,...i}){let a=Ku(),[o,s]=(0,V.useState)(!1),{pending:c,declare:l}=WC(),u=(0,V.useCallback)(t=>{if(t.preventDefault(),o||c)return;let n=t.currentTarget;s(!0),(async()=>{try{await e(await KC(n))}finally{s(!1)}})()},[o,c,e]);return(0,U.jsxs)(`form`,{onSubmit:u,className:H(`flex flex-col gap-5 font-aai`,r),...i,children:[(0,U.jsx)(`fieldset`,{disabled:o||c,className:`contents`,children:(0,U.jsx)(UC,{value:l,children:n})}),t!==void 0&&t!==``&&(0,U.jsx)(`p`,{role:`alert`,className:`text-sm`,style:{color:a.primary},children:t})]})}function lw({children:e,pending:t=!1,pendingLabel:n=`Working…`,size:r,variant:i,className:a,...o}){return(0,U.jsx)(od,{type:`submit`,disabled:t,...w({size:r,variant:i,className:a}),...o,children:t?n:e})}var uw=12;function dw({upload:e,onPause:t,onResume:n,className:r}){let i=Ku(),a=(0,V.useId)();if(!e)return null;let{name:o,index:s,count:c,loaded:l,total:u,fraction:d,paused:f}=e,p=t&&n?f?n:t:void 0,m=d===void 0?void 0:Math.round(d*100),h=Ju(i.text,i.surface,65);return(0,U.jsxs)(`div`,{className:H(r??`flex flex-col gap-1.5`),children:[(0,U.jsxs)(`div`,{className:`flex items-baseline justify-between gap-4 text-xs`,children:[(0,U.jsx)(`span`,{id:a,className:`truncate`,style:{color:h},children:`${f?`Paused`:`Uploading`} ${o}${c>1?` (${s} of ${c})`:``}`}),(0,U.jsxs)(`div`,{className:`flex shrink-0 items-baseline gap-3`,children:[(0,U.jsx)(`span`,{className:`tabular-nums`,style:{color:h},children:u===void 0?ve(l):`${ve(l)} of ${ve(u)}`}),p&&(0,U.jsx)(od,{type:`button`,variant:`ghost`,className:`h-6 px-2 text-[0.625rem]`,onClick:p,children:f?`Resume`:`Pause`})]})]}),(0,U.jsx)(`div`,{role:`progressbar`,"aria-labelledby":a,"aria-valuemin":0,"aria-valuemax":100,...w({"aria-valuenow":m}),className:`h-1.5 w-full overflow-hidden rounded-full`,style:{backgroundColor:Ju(i.text,i.surface,uw)},children:(0,U.jsx)(`div`,{className:H(`h-full rounded-full transition-[width] duration-200 ease-out`,m===void 0&&!f&&`animate-pulse`),style:{backgroundColor:i.primary,width:m===void 0?`100%`:`${m}%`}})})]})}var fw=class extends Error{constructor(e,t){super(e),this.name=`ParseError`,this.type=t.type,this.field=t.field,this.value=t.value,this.line=t.line}},pw=10,mw=13,hw=32,gw=6;function _w(e){if(typeof e==`function`)throw TypeError("`config` must be an object, got a function instead. Did you mean `createParser({onEvent: fn})`?");let{maxBufferSize:t,onComment:n,onError:r,onEvent:i,onId:a,onRetry:o}=e,s=[],c=0,l=``,u,d=``,f=0,p,m=!1,h=!1,g=!1;function _(e){if(m)throw Error("Cannot feed parser: it was terminated after exceeding the configured max buffer size. Call `reset()` to resume parsing.");if(l!==void 0){if(e=l+e,e===``||e===`ï`||e===`ï»`){l=e;return}l=void 0,e=e.replace(/^(?:\uFEFF|\xEF\xBB\xBF)/,``)}if((h||g)&&(e=v(e),!e))return;if(!s.length){let t=ee(e);t!==``&&y(t),x();return}if(e.indexOf(`
118
- `)===-1&&e.indexOf(`\r`)===-1){if(c<gw&&!b(s.join(``)+e.slice(0,gw-c))){s.length=0,c=0,h=!0;return}s.push(e),c+=e.length,x();return}s.push(e);let t=s.join(``);s.length=0,c=0,y(ee(t)),x()}function v(e){if(e.length===0)return e;if(g)return g=!1,e.charCodeAt(0)===pw?e.slice(1):e;let t=e.indexOf(`\r`),n=e.indexOf(`
119
- `),r=t===-1?n:n===-1||t<n?t:n;return r===-1?``:r===e.length-1&&e.charCodeAt(r)===mw?(h=!1,g=!0,``):(h=!1,e.slice(r+(e.charCodeAt(r)===mw&&e.charCodeAt(r+1)===pw?2:1)))}function y(e){if(e){if(e.charCodeAt(e.length-1)===mw){S(e,0,e.length-1),g=!0;return}if(b(e)){s.push(e),c=e.length;return}h=!0}}function b(e){let t=e.charCodeAt(0);return t===58&&!!n||t===100&&bw(e,`data`)||t===101&&bw(e,`event`)||t===105&&bw(e,`id`)||t===114&&bw(e,`retry`)}function x(){t!==void 0&&(c+d.length<=t||(m=!0,s.length=0,c=0,u=void 0,d=``,f=0,p=void 0,h=!1,g=!1,r?.(new fw(`Buffered data exceeded max buffer size of ${t} characters`,{type:`max-buffer-size-exceeded`}))))}function ee(e){let t=0;if(e.indexOf(`\r`)===-1){let n=e.indexOf(`
117
+ `),WS=!0);let r=this._options.WebSocket||WebSocket;this._debug(`connect`,{url:e,protocols:n}),this._ws=n?new r(e,n):new r(e),this._ws.binaryType=this._binaryType,this._connectLock=!1,this._addListeners(),this._connectTimeout=setTimeout(()=>this._handleTimeout(),t)}).catch(e=>{this._connectLock=!1,this._handleError(new IS.ErrorEvent(Error(e.message),this))})}_handleTimeout(){this._debug(`timeout event`),this._handleError(new IS.ErrorEvent(Error(`TIMEOUT`),this))}_disconnect(e=1e3,t){if(this._clearTimeouts(),this._ws){this._removeListeners();try{(this._ws.readyState===this.OPEN||this._ws.readyState===this.CONNECTING)&&this._ws.close(e,t),this._handleClose(new IS.CloseEvent(e,t,this))}catch{}}}_acceptOpen(){this._debug(`accept open`),this._retryCount=0}_handleOpen=e=>{this._debug(`open event`);let{minUptime:t=US.minUptime}=this._options;clearTimeout(this._connectTimeout),this._uptimeTimeout=setTimeout(()=>this._acceptOpen(),t),LS(this._ws,`WebSocket is not defined`),this._ws.binaryType=this._binaryType,this._messageQueue.forEach(e=>{this._ws?.send(e)}),this._messageQueue=[],this.onopen&&this.onopen(e),this.dispatchEvent(HS(e))};_handleMessage=e=>{this._debug(`message event`),this.onmessage&&this.onmessage(e),this.dispatchEvent(HS(e))};_handleError=e=>{this._debug(`error event`,e.message),this._disconnect(void 0,e.message===`TIMEOUT`?`timeout`:void 0),this.onerror&&this.onerror(e),this._debug(`exec error listeners`),this.dispatchEvent(HS(e)),this._connect()};_handleClose=e=>{this._debug(`close event`),this._clearTimeouts(),this._options.shouldReconnectOnClose&&!this._options.shouldReconnectOnClose(e)&&(this._shouldReconnect=!1),this._shouldReconnect&&this._connect(),this.onclose&&this.onclose(e),this.dispatchEvent(HS(e))};_removeListeners(){this._ws&&(this._debug(`removeListeners`),this._ws.removeEventListener(`open`,this._handleOpen),this._ws.removeEventListener(`close`,this._handleClose),this._ws.removeEventListener(`message`,this._handleMessage),this._ws.removeEventListener(`error`,this._handleError),this._ws.addEventListener(`error`,GS))}_addListeners(){this._ws&&(this._debug(`addListeners`),this._ws.addEventListener(`open`,this._handleOpen),this._ws.addEventListener(`close`,this._handleClose),this._ws.addEventListener(`message`,this._handleMessage),this._ws.addEventListener(`error`,this._handleError))}_clearTimeouts(){clearTimeout(this._connectTimeout),clearTimeout(this._uptimeTimeout)}},qS={minReconnectionDelay:1e3,maxReconnectionDelay:15e3,reconnectionDelayGrowFactor:2,maxRetries:10};function JS(e,t){return new KS(e,t,qS)}function YS(e){return e instanceof KS}function XS(e){return e instanceof KS&&(e.reconnect(),!0)}function ZS(e){return e instanceof KS&&e.shouldReconnect&&e.retryCount<qS.maxRetries}var QS=`aai:session:`;function $S(e){return dS(QS,e)}function eC(e){return cS(`session`,$S(e))}function tC(e,t){lS(`session`,$S(e),t)}function nC(e){uS(`session`,$S(e))}var rC=`aai:session-ticket:`;function iC(e){return cS(`session`,dS(rC,e))}function aC(e,t){lS(`session`,dS(rC,e),t)}function oC(e){uS(`session`,dS(rC,e))}var sC=/^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/;function cC(e){let t=e?.trim();return t===``?void 0:t}async function lC(e,t){if(typeof e!=`function`)return cC(e);try{return cC(await e(t))}catch(e){console.warn("session-core: the `token` getter failed; dialing without a ticket",e);return}}function uC(e,t){if(typeof e!=`function`)return cC(e);let n=e(t);if(typeof n!=`string`&&n!==void 0)throw TypeError("VoiceSessionOptions.token: an injected `WebSocket` opens synchronously, so its `token` getter must return a string, not a Promise");return cC(n)}function dC(e){if(e===void 0)return{};let t=`${iu}${e}`;return sC.test(t)?{protocols:[ru,t]}:{queryToken:e}}function fC(e,t,n={}){return hC(hu(e,`websocket`),t,n)}function pC(e,t,n={}){return hC(new URL(e),t,n)}var mC={"https:":`wss:`,"http:":`ws:`};function hC(e,t,n){return e.protocol=mC[e.protocol]??e.protocol,t&&e.searchParams.set(`sessionId`,t),n.location&&e.searchParams.set(`location`,n.location),n.phone&&e.searchParams.set(`phone`,n.phone),n.client&&e.searchParams.set(`client`,n.client),e}function gC(e,t){return t.queryToken!==void 0&&e.searchParams.set(`token`,t.queryToken),e.toString()}function _C(e,t){let n=e.resumeSessionId??eC(e.platformUrl),r,i=iC(e.platformUrl),a;function o(e){e!==a&&(a=e,t?.())}function s(){return{location:yS(e.location),phone:yS(e.phone),client:yS(e.client)}}async function c(){let t=lC(e.token,{sessionId:n}),a=n===void 0?void 0:i,o=r===!1?null:await vu(e.platformUrl,void 0,a);o&&(r=o.sessionUrl!==void 0||o.sessionToken!==void 0);let c=await t;c===void 0&&o?.sessionToken!==void 0&&(i=o.sessionToken,aC(e.platformUrl,i));let l=dC(c??o?.sessionToken);return{url:gC(o?.sessionUrl?pC(o.sessionUrl,n,s()):fC(e.platformUrl,n,s()),l),protocols:l.protocols}}let l;return{open:()=>{if(e.WebSocket){let t=dC(uC(e.token,{sessionId:n})),r=gC(fC(e.platformUrl,n,s()),t);return t.protocols?new e.WebSocket(r,t.protocols):new e.WebSocket(r)}return JS(async()=>(l=c(),(await l).url),async()=>(await(l??c())).protocols??null)},configured:t=>{n=t,tC(e.platformUrl,t),o(t)},adopt:t=>{n=t,tC(e.platformUrl,t)},forget:()=>{n=void 0,nC(e.platformUrl),i=void 0,oC(e.platformUrl),o(void 0)},sessionId:()=>a,ticket:()=>{if(e.token!==void 0)return typeof e.token==`function`?lC(e.token,{sessionId:void 0}):uC(e.token,{sessionId:void 0});if(r!==!1)return vu(e.platformUrl).then(e=>(e&&(r=e.sessionUrl!==void 0||e.sessionToken!==void 0),e?.sessionToken))}}}var vC=200,yC=200,bC={messages:[],toolCalls:[],customEvents:[],agentState:null,userTranscript:null,agentTranscript:null,error:null};function xC(e,t,n){if(e.length<n)return[...e,t];let r=e.slice(e.length-n+1);return r.push(t),r}function SC(e){let{getSnapshot:t,updateState:n,conn:r,agentState:i,audio:a,retire:o}=e,s=0,c=0,l=0;function u(e,r){n({customEvents:xC(t().customEvents,{id:++s,event:e,data:r},vC)})}function d(e){r.turn.bump(),n({userTranscript:null,messages:xC(t().messages,{id:++c,role:`user`,content:e},yC),...i.apply({type:`THINK`})})}function f(e){n({agentTranscript:e})}function p(){let e=t().agentTranscript;if(e===null||e.length===0){n({agentTranscript:null});return}n({agentTranscript:null,messages:xC(t().messages,{id:++c,role:`assistant`,content:e},yC)})}function m(){n(i.apply({type:`ACTIVITY`}))}function h(e={}){n({...e,...i.apply({type:`LISTEN`})})}function g(e){console.error(`Agent error:`,e.message);let t={code:e.code,message:e.message,fatal:e.fatal};e.fatal?(a.teardown(),n({...i.apply({type:`FATAL`,error:t}),...xS})):n(i.apply({type:`TURN_ERROR`,error:t}))}function _(e){switch(e.type!==`error.reported`&&m(),e.type){case`speech.started`:n({userTranscript:``});break;case`speech.stopped`:break;case`userTranscript.committed`:d(e.text);break;case`userTranscript.updated`:n({userTranscript:e.text});break;case`agentTranscript.updated`:case`agentTranscript.committed`:f(e.text);break;case`tool.called`:n({toolCalls:xC(t().toolCalls,{callId:e.toolCallId,name:e.toolName,args:xl(e.args),status:`pending`,seq:++l,afterMessageId:t().messages.at(-1)?.id??-1},yC)});break;case`tool.completed`:{let r=t().toolCalls,i=r.findIndex(t=>t.callId===e.toolCallId),a=r[i];if(!a)break;let o=[...r];o[i]={...a,status:`done`,result:e.result},n({toolCalls:o});break}case`reply.completed`:p(),h();break;case`reply.cancelled`:SS(r,a),p(),h({userTranscript:null});break;case`session.reset`:{SS(r,a);let e=i.apply({type:`RESET`});n(i.fatal()?e:{...bC,...e});break}case`custom.emitted`:u(e.event,e.data);break;case`state.updated`:n({agentState:CC(t().agentState,e.state)});break;case`history.restored`:{c=0,l=0;let t=e.messages.slice(-yC).map(e=>({id:++c,role:e.role,content:e.content}));n({messages:t,toolCalls:e.toolCalls.slice(-yC).map(e=>({callId:e.callId,name:e.name,args:xl(e.args),status:e.status,...w({result:e.result}),seq:++l,afterMessageId:t[e.afterMessageIndex]?.id??-1}))});break}case`error.reported`:g(e);break;case`session.timedOut`:o()}}function v(e){n(i.apply({type:`SPEAK`})),a.enqueue(e)}function y(){a.done()}function b(e){if(e instanceof ArrayBuffer){v(e);return}if(typeof e!=`string`){console.warn(`session-core: non-string, non-binary frame received; dropping`);return}let t=T(e);if(t===void 0){console.warn(`session-core: invalid JSON; dropping`);return}let n=tu($l,t);if(!n.ok){n.malformed&&console.warn(`session-core: malformed server message`,n.error);return}let r=n.data;if(r.type===`session.configured`)return i.apply({type:`HANDSHAKE_COMPLETE`}),{sampleRate:r.sampleRate,ttsSampleRate:r.ttsSampleRate,sid:r.sessionId};if(r.type===`audio.completed`){y();return}_(r)}return{handleMessage:b}}function CC(e,t){if(e===null)return t;let n={};for(let[r,i]of Object.entries(t)){let t=e[r];n[r]=r in e&&JSON.stringify(t)===JSON.stringify(i)?t:i}return n}function wC(e){let t=new ArrayBuffer(0),n=e=>(t.byteLength!==e&&(t=new ArrayBuffer(e)),t);return{sendAudio(t){let r=e.conn.ws;r?.readyState===1&&(r.bufferedAmount>65536||r.send(e.snapshot().micMuted?n(t.byteLength):t))},sendBuffered(t){let r=e.conn.ws;if(r?.readyState!==1)return;let i=e.snapshot().micMuted;for(let e of t)r.send(i?n(e.byteLength):e)},setMicMuted(t){e.updateState({micMuted:t})}}}var TC=16e3;function EC(e){let t=null,n=null;return{begin(){if(iS().catch(()=>{}),!e||t!==null)return;let r={released:!1};n=r,t=Promise.all([nS(()=>import(`./audio-BvhkVqBK.js`),[],import.meta.url),iS()]).then(([{openPreConnectCapture:e},[,t]])=>r.released?null:e({sampleRate:TC,captureWorkletSrc:t,maxSeconds:10})).catch(()=>null)},take(){let e=t;return t=null,n=null,e},release(){let e=t;t=null,n&&(n.released=!0),n=null,e?.then(e=>e?.close())}}}var DC=(0,B.not)((0,B.stateIn)({fatal:`yes`})),OC=(0,B.setup)({types:{},guards:{hasError:({context:e})=>e.error!==null},actions:{clearError:(0,B.assign)({error:null}),setError:(0,B.assign)({error:({context:e,event:t})=>t.type===`TURN_ERROR`||t.type===`FATAL`||t.type===`FAILED`?t.error:e.error})}}).createMachine({id:`sessionState`,type:`parallel`,context:{error:null},states:{phase:{initial:`disconnected`,on:{CONNECT:{target:`.connecting`,actions:`clearError`},CLOSED:{target:`.disconnected`,actions:`clearError`},DISCONNECT:`.disconnected`,END:{target:`.disconnected`,actions:`clearError`},TURN_ERROR:{actions:`setError`},FATAL:{target:`.error`,actions:`setError`},FAILED:{target:`.error`,actions:`setError`},LISTEN:{guard:DC,target:`.listening`},RESET:{guard:DC,target:`.listening`,actions:`clearError`},THINK:{guard:DC,target:`.thinking`},ACTIVITY:{guard:(0,B.and)([DC,`hasError`]),actions:`clearError`}},states:{disconnected:{on:{SPEAK:{guard:(0,B.not)(`hasError`),target:`speaking`}}},connecting:{on:{SOCKET_OPEN:`ready`}},ready:{on:{SPEAK:`speaking`}},listening:{on:{SPEAK:`speaking`}},thinking:{on:{SPEAK:`speaking`}},speaking:{},error:{on:{ACTIVITY:{guard:DC,target:`listening`,actions:`clearError`},CLOSED:{}}}}},fatal:{initial:`no`,states:{no:{on:{FATAL:`yes`}},yes:{on:{HANDSHAKE_COMPLETE:`no`}}}}}});function kC(){let e=(0,B.createActor)(OC).start();function t(){let t=e.getSnapshot();return{state:t.value.phase,error:t.context.error}}return{snapshot:t,apply(n){return e.send(n),t()},fatal:()=>e.getSnapshot().matches({fatal:`yes`})}}function AC(e){let{state:t}=e.snapshot();(t===`speaking`||t===`thinking`)&&(e.bargeIn(),e.updateState(e.agentState.apply({type:`LISTEN`})))}function jC(e){function t(t){AC(e),e.sendJson({type:`user_text`,text:t})}return{userTurn:NC(e),sendText(n,r){let i=n.trim();if(i!==``){if(e.connected()&&e.queued.length===0){t(i);return}(e.queued.length!==0||r?.connect===!0)&&(e.queued.push(i),e.open())}},flushQueued(){if(e.connected())for(let n of e.queued.splice(0))t(n)},sendToolResult(t,n){e.connected()&&e.sendJson({type:`tool_result`,toolCallId:t,...MC(n)})}}}function MC(e){if(`error`in e)return{result:``,error:e.error};try{return{result:JSON.stringify(e.result??null)??`null`}}catch(e){return{result:``,error:`Tool result is not JSON-serializable: ${String(e)}`}}}function NC(e){return{start(){e.connected()&&(AC(e),e.sendJson({type:`user_turn_start`}))},commit(){e.connected()&&e.sendJson({type:`user_turn_commit`})},clear(){e.connected()&&(e.updateState({userTranscript:null}),e.sendJson({type:`user_turn_clear`}))}}}function PC(e){return FC(e,{})}function FC(e,t){let n={...bC,state:`disconnected`,contentVersion:0,started:!1,running:!1,recording:!1,micMuted:!1,apiUrl:fC(e.platformUrl).toString()},r=new Set;function i(){for(let e of r)e()}let a=[`messages`,`toolCalls`,`userTranscript`,`agentTranscript`];function o(e,t){return t[e]===n[e]}let s=[];function c(e){e.running===!1&&(s.length=0),!Object.keys(e).every(t=>o(t,e))&&(n=a.some(t=>t in e&&e[t]!==n[t])?{...n,...e,contentVersion:n.contentVersion+1}:{...n,...e},i())}function l(){return n}function u(e){return r.add(e),()=>{r.delete(e)}}let d=kC(),f={ws:null,turn:jl()},p=bS(e,()=>m),m=_C({...e,client:p.clientId},i);function h(){c(bC)}function g(){return f.ws?.readyState===1?f.ws:null}function _(e){g()?.send(JSON.stringify(e))}let v=wC({conn:f,snapshot:()=>n,updateState:c}),y=EC(e.preConnectAudio!==!1),b=DS(CS({conn:f,updateState:c,agentState:d,sendJson:_,mic:v,preConnect:y,openAudioPath:t.openAudioPath})),{handleMessage:x}=SC({getSnapshot:l,updateState:c,conn:f,agentState:d,audio:b,retire:()=>S.retire()});function ee(t){m.configured(t.sid),e.onSessionId?.(t.sid),E(),b.start(t)}let S=NS({dial:()=>{y.begin();let e=m.open();return e.binaryType=`arraybuffer`,f.ws=e,e},release:e=>{y.release(),b.teardown(),e.close(),f.ws=null},abandon:()=>ie(),receive:x,opened:()=>c(d.apply({type:`SOCKET_OPEN`})),configured:ee,fatal:()=>d.fatal(),retryPending:ZS,canRedial:()=>YS(f.ws),redial:()=>{XS(f.ws)},retrying:()=>{b.teardown(),c({...d.apply({type:`CONNECT`}),recording:!1})},closed:e=>{c({...e===null?d.apply({type:`CLOSED`}):d.apply({type:`FAILED`,error:{code:`connection`,message:e,fatal:!1}}),...xS})},exhausted:()=>{c({...d.apply({type:`FAILED`,error:AS}),...xS})}});function C(e){if(e?.signal?.aborted){ie();return}c(d.apply({type:`CONNECT`})),S.dial(e?.signal)}function w(){g()&&(SS(f,b),c(d.apply({type:`LISTEN`})),_({type:`cancel`}))}let{userTurn:T,sendText:te,flushQueued:E,sendToolResult:ne}=jC({snapshot:()=>n,connected:()=>g()!==null,queued:s,open:()=>{n.running||(n.started?oe:ae)()},bargeIn:()=>SS(f,b),agentState:d,updateState:c,sendJson:_});function re(){if(SS(f,b),g()){_({type:`reset`});return}se(),ae()}function ie(){S.hangUp(),c({...d.apply({type:`DISCONNECT`}),...xS})}function ae(){c({started:!0,running:!0}),C()}function oe(){n.running?ie():(c({running:!0}),C())}function se(){S.hangUp(),m.forget(),c({...bC,...d.apply({type:`END`}),started:!1,...xS})}function ce(){se(),ae()}function le(e){if(!Vl.test(e))throw RangeError(`resume: "${e}" is not a session id (${Vl})`);se(),m.adopt(e),ae()}return{getSnapshot:l,subscribe:u,connect:C,cancel:w,userTurn:Object.freeze(T),identity:p,sendText:te,sendToolResult:ne,setMicMuted:v.setMicMuted,resetState:h,reset:re,disconnect:ie,start:ae,toggle:oe,end:se,restart:ce,resume:le,[Symbol.dispose](){ie()}}}function IC(e=`#app`){if(typeof e!=`string`)return e;let t=document.querySelector(e);if(!t)throw Error(`Element not found: ${e} — no element matches that selector when the mount runs. Add \`<div id="app"></div>\` (or the element your selector names) to the page before the script, or pass the element itself as the mount's \`target\` option.`);return t}function LC(e,t,n){let r=(0,ju.createRoot)(e);return(0,Au.flushSync)(()=>{r.render(t)}),{dispose(){r.unmount(),n?.()},[Symbol.dispose](){this.dispose()}}}function RC({name:e,icon:t,subtitle:n,buttonText:r,Sidebar:i,...a}){let o=(0,U.jsx)(Xx,{title:e,icon:t});return(0,U.jsx)(Qx,{title:e,icon:t,subtitle:n,buttonText:r,children:i?(0,U.jsx)(Zx,{sidebar:(0,U.jsx)(i,{}),sidebarWidth:a.sidebarWidth,sidebarPosition:a.sidebarPosition,children:o}):o})}function zC({platformUrl:e,...t}){let{name:n}=t,[r,i]=(0,V.useState)(null),a=n===void 0;return(0,V.useEffect)(()=>{if(!a)return;let t=!1;return yu(e).then(e=>{t||i(e)}),()=>{t=!0}},[e,a]),(0,U.jsx)(RC,{...t,name:n??r?.name})}function BC(e,t){let n=e.component,r=e.sidebar;return n?r?(0,U.jsx)(Zx,{sidebar:(0,U.jsx)(r,{}),sidebarWidth:e.sidebarWidth,sidebarPosition:e.sidebarPosition,children:(0,U.jsx)(n,{})}):(0,U.jsx)(n,{}):(0,U.jsx)(zC,{platformUrl:t,name:e.name,icon:e.icon,subtitle:e.subtitle,buttonText:e.buttonText,Sidebar:r,sidebarWidth:e.sidebarWidth,sidebarPosition:e.sidebarPosition})}function VC(e){return HC(e,PC)}function HC(e,t){let n=IC(e.target),r=e.platformUrl??pu(),i=t({platformUrl:r,onSessionId:e.onSessionId,resumeSessionId:e.resumeSessionId,location:e.location,phone:e.phone,client:e.client,token:e.token,WebSocket:e.WebSocket});mu(e.name);let a=BC(e,r),o=e.tools??{};return{session:i,...LC(n,(0,V.createElement)(Lx.Provider,{value:o},(0,V.createElement)(Uu,{value:e.theme},(0,V.createElement)(Fu,{value:i},a))),()=>i[Symbol.dispose]())}}var UC=(0,V.createContext)(void 0),WC=UC.Provider;function GC(){let[e,t]=(0,V.useState)(()=>new Set),n=(0,V.useCallback)((e,n)=>{t(t=>{if(n===t.has(e))return t;let r=new Set(t);return n?r.add(e):r.delete(e),r})},[]);return{pending:e.size>0,declare:n}}function KC(e){let t=(0,V.useContext)(UC),n=(0,V.useId)();(0,V.useEffect)(()=>{if(t)return t(n,e),()=>t(n,!1)},[t,n,e])}async function qC(e){let t={};for(let n of Array.from(e.elements))n instanceof HTMLInputElement?await YC(n,t):(n instanceof HTMLTextAreaElement||n instanceof HTMLSelectElement)&&n.name!==``&&!n.disabled&&(t[n.name]=n instanceof HTMLSelectElement?JC(n):n.value);return t}function JC(e){return e.multiple?Array.from(e.selectedOptions,e=>e.value):e.value}async function YC(e,t){if(!(e.name===``||e.disabled))switch(e.type){case`checkbox`:t[e.name]=e.checked;return;case`radio`:e.checked&&(t[e.name]=e.value);return;case`number`:case`range`:{if(e.value===``)return;let n=e.valueAsNumber;t[e.name]=Number.isNaN(n)?e.value:n;return}case`file`:{let n=Array.from(e.files??[]);if(n.length===0)return;let r=await XC(n,ZC(e.dataset.aaiRead));t[e.name]=e.multiple?r:r[0];return}default:t[e.name]=e.value}}function XC(e,t){return t===`upload`?Promise.resolve([...e]):Promise.all(e.map(e=>QC(e,t)))}function ZC(e){return e===`text`||e===`dataUrl`||e===`upload`?e:`none`}async function QC(e,t){let n={name:e.name,size:e.size,type:e.type,lastModified:e.lastModified};return t===`none`?n:{...n,content:t===`text`?await e.text():await $C(e)}}function $C(e){return new Promise((t,n)=>{let r=new FileReader;r.onerror=()=>n(r.error??Error(`Could not read ${e.name}`)),r.onload=()=>t(String(r.result)),r.readAsDataURL(e)})}function ew({label:e,hint:t,htmlFor:n,className:r,children:i}){let a=Ku();return(0,U.jsxs)(`div`,{className:H(`flex flex-col gap-1.5`,r),children:[e!==void 0&&(0,U.jsx)(`label`,{htmlFor:n,className:`text-[11px] font-medium uppercase tracking-[1.2px]`,style:{color:a.text},children:e}),i,t!==void 0&&(0,U.jsx)(`p`,{className:`text-xs opacity-60`,style:{color:a.text},children:t})]})}function tw(){let e=Ku();return{className:H(`w-full rounded-aai border px-3 py-2 text-sm font-aai`,$u,`disabled:cursor-not-allowed disabled:opacity-50`),style:{background:e.surface,color:e.text,borderColor:e.border,...ed(e.primary)}}}function nw(){let e=Ku(),t=tw();return{className:H(t.className,`cursor-pointer py-1.5 pl-1.5`,`file:mr-3 file:cursor-pointer file:rounded-aai file:border-0 file:px-3 file:py-1.5`,`file:text-sm file:font-medium file:font-aai`,`file:[background:var(--aai-file-button-bg)] file:[color:var(--aai-file-button-fg)]`),style:{...t.style,"--aai-file-button-bg":e.primary,"--aai-file-button-fg":e.surface}}}function rw({defaultType:e,name:t,label:n,hint:r,className:i,...a}){let o=(0,V.useId)(),s=tw();return(0,U.jsx)(ew,{label:n,hint:r,htmlFor:o,className:i,children:(0,U.jsx)(`input`,{id:o,name:t,type:e,...s,...a})})}function iw(e){return(0,U.jsx)(rw,{defaultType:`text`,...e})}function aw(e){return(0,U.jsx)(rw,{defaultType:`number`,...e})}function ow({name:e,label:t,hint:n,className:r,options:i,children:a,...o}){let s=(0,V.useId)(),c=tw();return(0,U.jsx)(ew,{label:t,hint:n,htmlFor:s,className:r,children:(0,U.jsx)(`select`,{id:s,name:e,...c,...o,children:a??i?.map(e=>{let t=typeof e==`string`?e:e.value,n=typeof e==`string`?e:e.label;return(0,U.jsx)(`option`,{value:t,children:n},t)})})})}function sw({name:e,label:t,hint:n,className:r,...i}){let a=(0,V.useId)(),o=Ku();return(0,U.jsx)(ew,{hint:n,className:r,children:(0,U.jsxs)(`label`,{htmlFor:a,className:`flex items-center gap-2 text-sm`,style:{color:o.text},children:[(0,U.jsx)(`input`,{id:a,name:e,type:`checkbox`,style:{accentColor:o.primary},...i}),t]})})}function cw({name:e,label:t,hint:n,className:r,read:i=`none`,upload:a=!1,...o}){let s=(0,V.useId)(),c=nw();return(0,U.jsx)(ew,{label:t,hint:n,htmlFor:s,className:r,children:(0,U.jsx)(`input`,{id:s,name:e,type:`file`,"data-aai-read":a?`upload`:i,...c,...o})})}function lw({onSubmit:e,error:t,children:n,className:r,...i}){let a=Ku(),[o,s]=(0,V.useState)(!1),{pending:c,declare:l}=GC(),u=(0,V.useCallback)(t=>{if(t.preventDefault(),o||c)return;let n=t.currentTarget;s(!0),(async()=>{try{await e(await qC(n))}finally{s(!1)}})()},[o,c,e]);return(0,U.jsxs)(`form`,{onSubmit:u,className:H(`flex flex-col gap-5 font-aai`,r),...i,children:[(0,U.jsx)(`fieldset`,{disabled:o||c,className:`contents`,children:(0,U.jsx)(WC,{value:l,children:n})}),t!==void 0&&t!==``&&(0,U.jsx)(`p`,{role:`alert`,className:`text-sm`,style:{color:a.primary},children:t})]})}function uw({children:e,pending:t=!1,pendingLabel:n=`Working…`,size:r,variant:i,className:a,...o}){return(0,U.jsx)(od,{type:`submit`,disabled:t,...w({size:r,variant:i,className:a}),...o,children:t?n:e})}var dw=12;function fw({upload:e,onPause:t,onResume:n,className:r}){let i=Ku(),a=(0,V.useId)();if(!e)return null;let{name:o,index:s,count:c,loaded:l,total:u,fraction:d,paused:f}=e,p=t&&n?f?n:t:void 0,m=d===void 0?void 0:Math.round(d*100),h=Ju(i.text,i.surface,65);return(0,U.jsxs)(`div`,{className:H(r??`flex flex-col gap-1.5`),children:[(0,U.jsxs)(`div`,{className:`flex items-baseline justify-between gap-4 text-xs`,children:[(0,U.jsx)(`span`,{id:a,className:`truncate`,style:{color:h},children:`${f?`Paused`:`Uploading`} ${o}${c>1?` (${s} of ${c})`:``}`}),(0,U.jsxs)(`div`,{className:`flex shrink-0 items-baseline gap-3`,children:[(0,U.jsx)(`span`,{className:`tabular-nums`,style:{color:h},children:u===void 0?ve(l):`${ve(l)} of ${ve(u)}`}),p&&(0,U.jsx)(od,{type:`button`,variant:`ghost`,className:`h-6 px-2 text-[0.625rem]`,onClick:p,children:f?`Resume`:`Pause`})]})]}),(0,U.jsx)(`div`,{role:`progressbar`,"aria-labelledby":a,"aria-valuemin":0,"aria-valuemax":100,...w({"aria-valuenow":m}),className:`h-1.5 w-full overflow-hidden rounded-full`,style:{backgroundColor:Ju(i.text,i.surface,dw)},children:(0,U.jsx)(`div`,{className:H(`h-full rounded-full transition-[width] duration-200 ease-out`,m===void 0&&!f&&`animate-pulse`),style:{backgroundColor:i.primary,width:m===void 0?`100%`:`${m}%`}})})]})}var pw=class extends Error{constructor(e,t){super(e),this.name=`ParseError`,this.type=t.type,this.field=t.field,this.value=t.value,this.line=t.line}},mw=10,hw=13,gw=32,_w=6;function vw(e){if(typeof e==`function`)throw TypeError("`config` must be an object, got a function instead. Did you mean `createParser({onEvent: fn})`?");let{maxBufferSize:t,onComment:n,onError:r,onEvent:i,onId:a,onRetry:o}=e,s=[],c=0,l=``,u,d=``,f=0,p,m=!1,h=!1,g=!1;function _(e){if(m)throw Error("Cannot feed parser: it was terminated after exceeding the configured max buffer size. Call `reset()` to resume parsing.");if(l!==void 0){if(e=l+e,e===``||e===`ï`||e===`ï»`){l=e;return}l=void 0,e=e.replace(/^(?:\uFEFF|\xEF\xBB\xBF)/,``)}if((h||g)&&(e=v(e),!e))return;if(!s.length){let t=ee(e);t!==``&&y(t),x();return}if(e.indexOf(`
118
+ `)===-1&&e.indexOf(`\r`)===-1){if(c<_w&&!b(s.join(``)+e.slice(0,_w-c))){s.length=0,c=0,h=!0;return}s.push(e),c+=e.length,x();return}s.push(e);let t=s.join(``);s.length=0,c=0,y(ee(t)),x()}function v(e){if(e.length===0)return e;if(g)return g=!1,e.charCodeAt(0)===mw?e.slice(1):e;let t=e.indexOf(`\r`),n=e.indexOf(`
119
+ `),r=t===-1?n:n===-1||t<n?t:n;return r===-1?``:r===e.length-1&&e.charCodeAt(r)===hw?(h=!1,g=!0,``):(h=!1,e.slice(r+(e.charCodeAt(r)===hw&&e.charCodeAt(r+1)===mw?2:1)))}function y(e){if(e){if(e.charCodeAt(e.length-1)===hw){S(e,0,e.length-1),g=!0;return}if(b(e)){s.push(e),c=e.length;return}h=!0}}function b(e){let t=e.charCodeAt(0);return t===58&&!!n||t===100&&xw(e,`data`)||t===101&&xw(e,`event`)||t===105&&xw(e,`id`)||t===114&&xw(e,`retry`)}function x(){t!==void 0&&(c+d.length<=t||(m=!0,s.length=0,c=0,u=void 0,d=``,f=0,p=void 0,h=!1,g=!1,r?.(new pw(`Buffered data exceeded max buffer size of ${t} characters`,{type:`max-buffer-size-exceeded`}))))}function ee(e){let t=0;if(e.indexOf(`\r`)===-1){let n=e.indexOf(`
120
120
  `,t);for(;n!==-1;){if(t===n){u!==void 0&&a?.(u),f>0&&i?.({id:u,event:p,data:d}),u=void 0,d=``,f=0,p=void 0,t=n+1,n=e.indexOf(`
121
- `,t);continue}let r=e.charCodeAt(t);if(vw(e,t,r)){let r=e.charCodeAt(t+5)===hw?t+6:t+5,o=e.slice(r,n);if(f===0&&e.charCodeAt(n+1)===pw){u!==void 0&&a?.(u),i?.({id:u,event:p,data:o}),u=void 0,d=``,p=void 0,t=n+2,n=e.indexOf(`
122
- `,t);continue}d=f===0?o:`${d}\n${o}`,f++}else yw(e,t,r)?p=e.slice(e.charCodeAt(t+6)===hw?t+7:t+6,n)||void 0:S(e,t,n);t=n+1,n=e.indexOf(`
121
+ `,t);continue}let r=e.charCodeAt(t);if(yw(e,t,r)){let r=e.charCodeAt(t+5)===gw?t+6:t+5,o=e.slice(r,n);if(f===0&&e.charCodeAt(n+1)===mw){u!==void 0&&a?.(u),i?.({id:u,event:p,data:o}),u=void 0,d=``,p=void 0,t=n+2,n=e.indexOf(`
122
+ `,t);continue}d=f===0?o:`${d}\n${o}`,f++}else bw(e,t,r)?p=e.slice(e.charCodeAt(t+6)===gw?t+7:t+6,n)||void 0:S(e,t,n);t=n+1,n=e.indexOf(`
123
123
  `,t)}return e.slice(t)}for(;t<e.length;){let n=e.indexOf(`\r`,t),r=e.indexOf(`
124
- `,t),i=-1;if(n!==-1&&r!==-1?i=n<r?n:r:n===-1?r!==-1&&(i=r):i=n===e.length-1?-1:n,i===-1)break;S(e,t,i),t=i+1,e.charCodeAt(t-1)===mw&&e.charCodeAt(t)===pw&&t++}return e.slice(t)}function S(e,t,r){if(t===r){w();return}let i=e.charCodeAt(t);if(vw(e,t,i)){let n=e.charCodeAt(t+5)===hw?t+6:t+5,i=e.slice(n,r);d=f===0?i:`${d}\n${i}`,f++;return}if(yw(e,t,i)){p=e.slice(e.charCodeAt(t+6)===hw?t+7:t+6,r)||void 0;return}if(i===105&&e.charCodeAt(t+1)===100&&e.charCodeAt(t+2)===58){let n=e.slice(e.charCodeAt(t+3)===hw?t+4:t+3,r);n.includes(`\0`)||(u=n);return}if(i===58){if(n){let i=e.slice(t,r);n(i.slice(e.charCodeAt(t+1)===hw?2:1))}return}let a=e.slice(t,r),o=a.indexOf(`:`);if(o===-1){C(a,``,a);return}let s=a.slice(0,o),c=a.charCodeAt(o+1)===hw?2:1;C(s,a.slice(o+c),a)}function C(e,t,n){switch(e){case`event`:p=t||void 0;break;case`data`:d=f===0?t:`${d}\n${t}`,f++;break;case`id`:t.includes(`\0`)||(u=t);break;case`retry`:/^\d+$/.test(t)?o?.(parseInt(t,10)):r?.(new fw(`Invalid \`retry\` value: "${t}"`,{type:`invalid-retry`,value:t,line:n}));break;default:r?.(new fw(`Unknown field "${e.length>20?`${e.slice(0,20)}…`:e}"`,{type:`unknown-field`,field:e,value:t,line:n}))}}function w(){u!==void 0&&a?.(u),f>0&&i?.({id:u,event:p,data:d}),u=void 0,d=``,f=0,p=void 0}function T(e={}){if(e.consume&&s.length>0){let e=s.join(``);S(e,0,e.length)}l=``,u=void 0,d=``,f=0,p=void 0,s.length=0,c=0,m=!1,h=!1,g=!1}return{feed:_,reset:T}}function vw(e,t,n){return n===100&&e.charCodeAt(t+1)===97&&e.charCodeAt(t+2)===116&&e.charCodeAt(t+3)===97&&e.charCodeAt(t+4)===58}function yw(e,t,n){return n===101&&e.charCodeAt(t+1)===118&&e.charCodeAt(t+2)===101&&e.charCodeAt(t+3)===110&&e.charCodeAt(t+4)===116&&e.charCodeAt(t+5)===58}function bw(e,t){let n=1;for(;n<e.length&&n<t.length;){if(e.charCodeAt(n)!==t.charCodeAt(n))return!1;n++}return e.length<=t.length||e.charCodeAt(t.length)===58}async function*xw(e,t){let n=e.getReader(),r=new TextDecoder,i=[],a=_w({onEvent:({event:e,data:t})=>{e!==void 0&&i.push({event:e,data:T(t)})}});try{for(;!t?.aborted;){let{done:e,value:t}=await n.read();if(e)return;if(a.feed(r.decode(t,{stream:!0})),i.length===0)continue;let o=i;i=[];for(let e of o)yield e}}finally{n.cancel().catch(()=>void 0)}}var Sw=1e3;async function Cw(e){if(!e.ok)throw await Tl(e);if(!e.body)throw Error(`The agent answered the event stream with no body`);return e.body}async function*ww(e,t,n){let r=await Cw(await e.watch(t,n));for await(let e of xw(r,n)){if(e.event===`run`&&e.data){let t=e.data;if(yield t,Ll(t))return`settled`;continue}if(e.event===`done`||e.event===`missing`)return`settled`;if(e.event===`idle`)return`handed-back`}return`dropped`}async function*Tw(e,t,n){for(;!n?.aborted;){let r=yield*ww(e,t,n);if(r===`settled`||n?.aborted)return;if(r===`dropped`)throw Error(`The event stream for run ${t} ended before the run settled`)}}async function*Ew(e,t,n,r){let i=await Cw(await e.streamOutput(t,w({namespace:n.namespace,startIndex:r,signal:n.signal}))),a=r;for await(let e of xw(i,n.signal)){if(e.event===`chunk`){a+=1,yield e.data;continue}if(e.event===`done`){let t=e.data?.complete===!0;return{next:a,complete:t}}if(e.event===`missing`)return{next:a,complete:!0}}return{next:a,complete:!1}}async function*Dw(e,t,n={}){let r=Math.max(0,n.fromIndex??0);for(;!n.signal?.aborted;){let i=yield*Ew(e,t,n,r);if(r=i.next,i.complete||n.signal?.aborted)return;await Fl(Sw,w({signal:n.signal}))}}function Ow(e,t){return{loaded:e,total:t,fraction:t!==void 0&&t>0?Math.min(1,e/t):void 0}}function kw(){let e=globalThis.XMLHttpRequest;return typeof e==`function`?e:void 0}var Aw=new Set([204,205,304]),jw=200,Mw=599;function Nw(e,t,n,r,i,a,o,s){return new Promise((c,l)=>{let u=new e,d=e=>t=>{s&&s.removeEventListener(`abort`,m),e(t)},f=d(c),p=d(l),m=()=>u.abort();u.open(t,n);for(let[e,t]of Object.entries(r))u.setRequestHeader(e,t);if(u.upload.addEventListener(`progress`,e=>{o(Ow(e.loaded,e.lengthComputable?e.total:a))}),u.addEventListener(`load`,()=>{if(u.status<jw||u.status>Mw){p(Pw());return}let e=u.getResponseHeader(`Content-Type`);f(new Response(Aw.has(u.status)?null:u.responseText,{status:u.status,statusText:u.statusText,headers:w({"Content-Type":e??void 0})}))}),u.addEventListener(`error`,()=>p(Pw())),u.addEventListener(`timeout`,()=>p(Pw())),u.addEventListener(`abort`,()=>p(s?.reason??Fw())),s){if(s.aborted){p(s.reason??Fw());return}s.addEventListener(`abort`,m,{once:!0})}u.send(i)})}function Pw(){return TypeError(`${Cl}: the upload did not reach the agent`)}function Fw(){return new DOMException(`The upload was aborted.`,`AbortError`)}var Iw=new Set([408,425,429,500,502,503,504]);function Lw(e,t){let n=t&&ce(t);return n?Math.min(Math.max(0,n.getTime()-Date.now()),g):Pl(e,{baseMs:500,maxMs:g})}async function Rw(e,t){for(let n=1;;n+=1){let r;try{r=await e()}catch(e){if(n>=t.attempts||t.signal.aborted)throw e}if(r&&(r.ok||!Iw.has(r.status))||r&&n>=t.attempts)return{res:r,attempts:n};await Fl(Lw(n,r),{signal:t.signal}),t.signal.throwIfAborted()}}function zw(e){let t=[],n,r=kl(async()=>{for(;t.length>0&&n===void 0;){let n=t.splice(0,e.batch).map(e=>`offset=${e}`).join(`&`),{res:r}=await Rw(()=>fetch(`${e.uploads}/parts?${n}&stored=1`,{method:`PUT`,headers:e.headers,signal:e.signal}),{attempts:e.attempts,signal:e.signal});if(!r.ok)throw await e.fail(r)}}),i=t=>{n??=t,e.onFail(t)};return{landed(e){t.push(e),r.trigger().catch(i)},async drain(){if(await r.trigger().catch(i),n!==void 0)throw n}}}function Bw(e){if(typeof e==`string`)return;if(e instanceof ArrayBuffer||ArrayBuffer.isView(e))return e.byteLength;let t=e;return typeof t.size==`number`&&typeof t.slice==`function`?t.size:void 0}function Vw(e,t,n){return e instanceof ArrayBuffer?new Uint8Array(e,t,n-t):ArrayBuffer.isView(e)?new Uint8Array(e.buffer,e.byteOffset+t,n-t):e.slice(t,n)}function Hw(e,t,n={}){let r=Bw(e);if(r===void 0)return;let i=Ww(r,t.partBytes??8388608);if(i.length>=Uw)return{total:r,parts:i};if(i.length!==0&&n.resumable===!0)return{total:r,parts:Ww(r,h)}}var Uw=2;function Ww(e,t){let n=Math.max(h,Math.ceil(t/h)*h),r=[];for(let t=0;t<e;t+=n)r.push({start:t,end:Math.min(t+n,e),index:r.length});return r}async function Gw(e,t,n){let r=Number.isFinite(t)?Math.max(1,Math.floor(t)):1,i=Array(e.length),a=0,o=!1,s;if(await Promise.allSettled(Array.from({length:Math.min(r,e.length)},async()=>{for(let t=a++;t<e.length&&!o;t=a++)try{i[t]=await n(e[t],t)}catch(e){throw o=!0,s??={reason:e},e}})),s!==void 0)throw s.reason;return i}async function Kw(e){let{missing:t,width:n,sendPart:r,failed:i}=e;try{await Gw(t,n,async e=>{try{await r(e)}catch(e){throw i.abort(e),e}})}catch(e){throw i.signal.aborted?i.signal.reason:e}}function qw(e){let{req:t,bytesBase:n,uploads:r,options:i,attempts:a,signal:o,report:s,claimer:c}=e;return async e=>{let l=n?`${n}/${encodeURIComponent(t.id)}/${e.start}`:`${r}/parts?offset=${e.start}`,{res:u}=await Rw(()=>(s(e.index,0),t.send(`PUT`,l,n?{"Content-Type":t.type}:{...t.headers,"Content-Type":t.type},Vw(t.file,e.start,e.end),Jw(i,e,s))),{attempts:a,signal:o});if(!u.ok)throw await t.fail(u);n&&c.landed(e.start),s(e.index,e.end-e.start)}}function Jw(e,t,n){return{...w({signal:e?.signal}),...e?.onProgress?{onProgress:e=>n(t.index,e.loaded)}:{}}}function Yw(e){if(e!==!1)return e===void 0||e===!0?{}:e}function Xw(e){let t=e.replace(/\/+$/,``);if(t.endsWith(`/workflows`))return`${t.slice(0,-Sl.length)}/uploads`}async function Zw(e){let{req:t,begun:n,begunAlready:r,uploads:i,signal:a,attempts:o,parts:s}=e,c=n.ok?await Dl(n).catch(()=>({})):{},l=r?await nT(t,i,a,o):void 0,u=n.ok?c:l?.capability??{};return{bytesBase:u.directParts===!0?Xw(t.base):void 0,claimBatch:Qw(u.claimBatch),missing:l?s.filter(e=>!rT(l.ranges,e)):s}}function Qw(e){return Number.isInteger(e)&&(e??0)>1?e??1:1}async function $w(e){let{total:t,parts:n}=e.plan,r=`${e.base}/uploads/${encodeURIComponent(e.id)}`,i=new AbortController,a=e.options?.signal?AbortSignal.any([e.options.signal,i.signal]):i.signal,o={...e.options,signal:a},{res:s,attempts:c}=await Rw(()=>fetch(`${r}/parts?name=${encodeURIComponent(e.name)}&total=${t}`,{method:`POST`,headers:{...e.headers,"Content-Type":e.type},signal:a}),{attempts:4,signal:a}),l=s.status===409&&(c>1||e.options?.resume===!0);if(!(s.ok||l))throw await e.fail(s);let{bytesBase:u,claimBatch:d,missing:f}=await Zw({req:e,begun:s,begunAlready:l,uploads:r,signal:a,attempts:4,parts:n}),p=zw({uploads:r,headers:e.headers,batch:d,attempts:4,signal:a,fail:e.fail,onFail:e=>i.abort(e)}),m=iT(t,n.length,e.options?.onProgress);for(let e of n)f.includes(e)||m(e.index,e.end-e.start);let h=qw({req:e,bytesBase:u,uploads:r,options:o,attempts:4,signal:a,report:m,claimer:p});await Kw({missing:f,width:e.settings.concurrency??8,sendPart:h,failed:i}),await p.drain();let{res:g}=await Rw(()=>fetch(`${r}/info`,{headers:e.headers,signal:a}),{attempts:4,signal:a});if(!g.ok)throw await e.fail(g);let _=await Dl(g);return eT(_,e.id,t),{..._,url:r}}function eT(e,t,n){if(!e.complete)throw new tT(`Workflow API: upload ${t} stored every part but reports ${e.size} of ${n} byte(s) and is not complete. The agent acknowledged each window and then did not record it, so nothing can read this upload.`)}var tT=class extends Error{name=`UploadNotRecordedError`};async function nT(e,t,n,r){let{res:i}=await Rw(()=>fetch(`${t}/info`,{headers:e.headers,signal:n}),{attempts:r,signal:n});if(!i.ok)throw await e.fail(i);let a=await Dl(i);return{ranges:a.complete?[{start:0,end:a.size}]:a.ranges??[],capability:a}}function rT(e,t){return e.some(e=>e.start<=t.start&&e.end>=t.end)}function iT(e,t,n){let r=Array(t).fill(0);return n?(n(Ow(0,e)),(t,i)=>{r[t]=i,n(Ow(r.reduce((e,t)=>e+t,0),e))}):()=>void 0}function aT(e){if(e instanceof tT||e instanceof Error&&e.name===`AbortError`)return!1;let t=El(e);return t===void 0||Iw.has(t)}function oT(e){return Pl(e,{baseMs:_,maxMs:v})}async function sT(e,t){let n=t.attempts??4;for(let r=1;;r+=1){try{return await e({resume:r!==1||t.resume,round:r})}catch(e){if(r>=n||t.signal?.aborted===!0||!aT(e))throw e}await Fl(oT(r),w({signal:t.signal})),t.signal?.throwIfAborted()}}function cT(e){if(typeof e==`string`)return;if(e instanceof ArrayBuffer||ArrayBuffer.isView(e))return e.byteLength;let t=e.size;return typeof t==`number`?t:void 0}async function lT(e,t,n,r,i){let a=i?.signal,o={method:e,headers:n,body:r,...w({signal:a})},s=i?.onProgress;if(!s)return await fetch(t,o);let c=cT(r),l=0,u=e=>{l=e.loaded,s(e)};u(Ow(0,c));let d=kw(),f=d?await Nw(d,e,t,n,r,c,u,a):await fetch(t,o);return u(Ow(c??l,c)),f}function uT(e,t){let n=e;return{name:t?.name??(typeof n.name==`string`?n.name:``),type:t?.type??(typeof n.type==`string`&&n.type?n.type:`application/octet-stream`)}}function dT(){let e=crypto.randomUUID().replaceAll(`-`,``);return Ml(y.test(e),`upload.id.minted`,()=>({id:e})),e}function fT(e,t){return sT(t=>$w({...e,send:lT,options:{...e.options,resume:t.resume}}),{resume:t,...w({signal:e.options?.signal})})}async function pT(e,t,n,r,i){let{name:a,type:o}=uT(r,i),s=Yw(i?.parallel),c=s&&Hw(r,s);if(s&&c)return fT({base:e,headers:t,fail:n,id:dT(),file:r,name:a,type:o,options:i,settings:s,plan:c},void 0);let l=await lT(`POST`,`${e}/uploads?name=${encodeURIComponent(a)}`,{...t,"Content-Type":o},r,i);if(!l.ok)throw await n(l);let u=await Dl(l);return{...u,url:`${e}/uploads/${encodeURIComponent(u.id)}`}}async function mT(e,t,n,r,i,a){let{name:o,type:s}=uT(i,a),c=Yw(a?.parallel),l=c&&Hw(i,c,{resumable:!0});if(c&&l)return fT({base:e,headers:t,fail:n,id:r,file:i,name:o,type:s,options:a,settings:c,plan:l},a?.resume);let u=await lT(`PUT`,`${e}/uploads/${encodeURIComponent(r)}?name=${encodeURIComponent(o)}`,{...t,"Content-Type":s},i,a);if(!u.ok)throw await n(u);let d=await Dl(u);return{...d,url:`${e}/uploads/${encodeURIComponent(d.id)}`}}async function hT(e,t,n,r,i){let a=await fetch(`${e}/uploads/${encodeURIComponent(r)}`,{headers:t,...w({signal:i})});if(!a.ok)throw await n(a);return await a.blob()}async function gT(e,t,n,r,i){let a=await fetch(`${e}/uploads/${encodeURIComponent(r)}/info`,{headers:t,...w({signal:i})});if(!a.ok)throw await n(a);return await Dl(a)}function _T(e){let t=wl(e.baseUrl),n=e.token?{Authorization:`Bearer ${e.token}`}:{};function r(t=0,n){let r=e.timeoutMs===void 0?void 0:AbortSignal.timeout(e.timeoutMs+t);return r===void 0?w({signal:n}):{signal:n?AbortSignal.any([n,r]):r}}async function i(e,i,a){let o=a.wait,s=await fetch(`${t}/runs`,{method:`POST`,headers:{...n,"Content-Type":`application/json`},body:JSON.stringify({workflow:e,...w({input:i,key:a.key,wait:o})}),...r(o,a.signal)});if(!s.ok)throw await Tl(s);return await Dl(s)}async function a(e,i,a){let o=new URLSearchParams(e);i!==void 0&&o.set(`limit`,String(i));let s=await fetch(`${t}/runs?${o.toString()}`,{headers:n,...r(0,a)});if(!s.ok)throw await Tl(s);return(await Dl(s)).runs??[]}let o={upload(e,r){return pT(t,n,Tl,e,r)},async list(e){let i=await fetch(t,{headers:n,...r(0,e?.signal)});if(!i.ok)throw await Tl(i);return(await Dl(i)).workflows??[]},async start(e,t,n){let{runId:r}=await i(e,t,{key:n?.key,signal:n?.signal});return r},async startAndWait(e,t,n){let r=zl(n?.wait??6e4),a=await i(e,t,{key:n?.key,wait:r,signal:n?.signal});return a.run??Ol(a.runId,e)},async get(e,i){let a=zl(i?.wait),o=a>0?`?wait=${a}`:``,s=await fetch(`${t}/runs/${encodeURIComponent(e)}${o}`,{headers:n,...r(a,i?.signal)});if(s.status!==404){if(!s.ok)throw await Tl(s);return await Dl(s)}},find(e,t,n){return a({workflow:e,key:t},n?.limit,n?.signal)},recent(e,t){return a({workflow:e},t?.limit,t?.signal)},watch(e,r){return fetch(`${t}/runs/${encodeURIComponent(e)}/events`,{headers:{...n,Accept:`text/event-stream`},...w({signal:r})})},streamOutput(e,r){let i=new URLSearchParams(w({namespace:r?.namespace,startIndex:r?.startIndex===void 0?void 0:String(r.startIndex)})),a=i.size>0?`?${i.toString()}`:``;return fetch(`${t}/runs/${encodeURIComponent(e)}/stream${a}`,{headers:{...n,Accept:`text/event-stream`},...w({signal:r?.signal})})},follow(e,t){return Tw(o,e,t?.signal)},followOutput(e,t){return Dw(o,e,t??{})},uploadStream:(e,r,i)=>mT(t,n,Tl,e,r,i),uploadInfo:(e,i)=>gT(t,n,Tl,e,r(0,i?.signal).signal),download:(e,r)=>hT(t,n,Tl,e,r?.signal),async wake(e,i){let a=yT(i?.correlationIds),o=await fetch(`${t}/runs/${encodeURIComponent(e)}/wake${a}`,{method:`POST`,headers:n,...r(0,i?.signal)});if(o.status===404)return 0;if(!o.ok)throw await Tl(o);return(await Dl(o)).woken??0},async cancel(e,i){let a=await fetch(`${t}/runs/${encodeURIComponent(e)}`,{method:`DELETE`,headers:n,...r(0,i?.signal)});if(!a.ok)throw await Tl(a);return(await Dl(a)).cancelled===!0}};return o}var vT=256;function yT(e){if(!e||e.length===0)return``;let t=new URLSearchParams;for(let n of e){if(n.trim()===``)throw Error("A workflow `correlationId` must not be empty");if(n.length>vT)throw Error(`A workflow \`correlationId\` must be at most ${vT} characters`);t.append(`correlationId`,n)}return`?${t.toString()}`}function bT(e){let t=_T(e),n=e.baseUrl.replace(/\/+$/,``),r=e.token?{Authorization:`Bearer ${e.token}`}:{};return{...t,baseUrl:n,async config(){let t=e.timeoutMs===void 0?void 0:AbortSignal.timeout(e.timeoutMs),i=await fetch(`${n}/${yl}`,{headers:r,...w({signal:t})});if(!i.ok)throw await Tl(i);return await Dl(i)}}}function xT(e={}){return bT({baseUrl:e.baseUrl??pu(),...w({token:e.token})})}function ST(e){let t=(0,V.useRef)(e);t.current=e;let n=(0,V.useRef)(void 0);return(0,V.useCallback)(()=>t.current||(n.current??=xT(),n.current),[])}function CT(e={}){let{api:t,skip:n=!1}=e,[r,i]=(0,V.useState)({workflows:[],loading:!n,error:void 0}),a=ST(t);return(0,V.useEffect)(()=>{if(n)return;let e=!1;return a().list().then(t=>{e||i({workflows:t,loading:!1,error:void 0})}).catch(t=>{e||i({workflows:[],loading:!1,error:be(t)})}),()=>{e=!0}},[n,a]),r}function wT(e){if(!C(e))return;let{type:t}=e;return typeof t==`string`?t:Array.isArray(t)?t.find(e=>e!==`null`):void 0}function TT(e,t){if(t?.upload===!0)return`file`;if(!C(e))return`none`;let{enum:n}=e;if(Array.isArray(n)&&n.length>0)return`select`;switch(wT(e)){case`boolean`:return`checkbox`;case`number`:case`integer`:return`number`;case`string`:return`text`;default:return`none`}}function ET({workflow:e}){let{workflows:t,loading:n}=CT(typeof e==`string`?{}:{skip:!0}),r=typeof e==`string`?t.find(t=>t.name===e):e;GC(n);let i=OT(r?.inputSchema);if(!i?.properties)return null;let a=new Set(i.required??[]),o=new Set(r?.uploads??[]);return(0,U.jsx)(U.Fragment,{children:Object.entries(i.properties).map(([e,t])=>(0,U.jsx)(DT,{name:e,property:t,required:a.has(e),upload:o.has(e)},e))})}function DT({name:e,property:t,required:n,upload:r=!1}){let i=kT(e),a=t.description===void 0?{}:{hint:t.description},o=t.default===void 0?{}:{defaultValue:String(t.default)};switch(TT(t,{upload:r})){case`file`:return(0,U.jsx)(sw,{name:e,label:i,required:n,upload:!0,...a});case`select`:return(0,U.jsx)(aw,{name:e,label:i,required:n,options:(t.enum??[]).map(e=>String(e)),...a,...o});case`checkbox`:return(0,U.jsx)(ow,{name:e,label:i,defaultChecked:t.default===!0,...a});case`number`:return(0,U.jsx)(iw,{name:e,label:i,required:n,step:wT(t)===`integer`?1:`any`,...a,...o});case`text`:return(0,U.jsx)(rw,{name:e,label:i,required:n,...a,...o});default:return null}}function OT(e){return C(e)?e:void 0}function kT(e){let t=e.replace(/[_-]+/g,` `).replace(/([a-z0-9])([A-Z])/g,`$1 $2`).trim().toLowerCase();return t.charAt(0).toUpperCase()+t.slice(1)}function AT(e,t){let n=new AbortController,r,i=async()=>{await t(n.signal)||n.signal.aborted||(r=setTimeout(()=>void i(),e))};return i(),()=>{n.abort(),r!==void 0&&clearTimeout(r)}}var jT=5e3;function MT(e){return e===408||e===429||e>=500}async function NT(e,t){let n=[],r=`partial`;for await(let i of xw(e,t))if(i.event===`chunk`)n.push(i.data);else if(i.event===`done`)r=i.data?.complete?`complete`:`partial`;else if(i.event===`missing`)return{ending:`complete`,chunks:n};return{ending:r,chunks:n}}function PT(e,t,n,r,i,a){let o=n.startIndex??0,s=o<0?-o:void 0,c=s===void 0?o:0,l=!0,u=async r=>{let a=await e().streamOutput(t,{...w({namespace:n.namespace,startIndex:c===0?void 0:c}),signal:r});if(!a.ok&&MT(a.status))return`partial`;if(!(a.ok&&a.body))return`unsupported`;let{ending:o,chunks:u}=await NT(a.body,r);c+=u.length;let d=l&&s!==void 0?u.slice(-s):u;return l=!1,d.length>0&&!r.aborted&&i(d),o};return AT(r,async e=>{let t;try{t=await u(e)}catch{t=`partial`}return e.aborted?!0:t!==`partial`&&(a(t),!0)})}function FT(e,t={}){let{api:n,namespace:r,startIndex:i,intervalMs:a=jT}=t,[o,s]=(0,V.useState)([]),[c,l]=(0,V.useState)(!1),[u,d]=(0,V.useState)(!0),f=ST(n);return(0,V.useEffect)(()=>{if(s([]),d(!0),l(!1),!e)return;l(!0);let t=PT(f,e,{namespace:r,startIndex:i},a,e=>s(t=>[...t,...e]),e=>{l(!1),e===`unsupported`&&d(!1)});return()=>{t(),l(!1)}},[e,r,i,a,f]),{progress:o,latest:o.at(-1),streaming:c,supported:u}}function IT({runId:e,api:t,className:n,placeholder:r,lines:i}){let{progress:a,streaming:o,supported:s}=FT(e,w({api:t})),c=(0,V.useMemo)(()=>{let e=i===void 0?a:a.slice(Math.max(a.length-i,0));return e.length===0?null:e.join(`
124
+ `,t),i=-1;if(n!==-1&&r!==-1?i=n<r?n:r:n===-1?r!==-1&&(i=r):i=n===e.length-1?-1:n,i===-1)break;S(e,t,i),t=i+1,e.charCodeAt(t-1)===hw&&e.charCodeAt(t)===mw&&t++}return e.slice(t)}function S(e,t,r){if(t===r){w();return}let i=e.charCodeAt(t);if(yw(e,t,i)){let n=e.charCodeAt(t+5)===gw?t+6:t+5,i=e.slice(n,r);d=f===0?i:`${d}\n${i}`,f++;return}if(bw(e,t,i)){p=e.slice(e.charCodeAt(t+6)===gw?t+7:t+6,r)||void 0;return}if(i===105&&e.charCodeAt(t+1)===100&&e.charCodeAt(t+2)===58){let n=e.slice(e.charCodeAt(t+3)===gw?t+4:t+3,r);n.includes(`\0`)||(u=n);return}if(i===58){if(n){let i=e.slice(t,r);n(i.slice(e.charCodeAt(t+1)===gw?2:1))}return}let a=e.slice(t,r),o=a.indexOf(`:`);if(o===-1){C(a,``,a);return}let s=a.slice(0,o),c=a.charCodeAt(o+1)===gw?2:1;C(s,a.slice(o+c),a)}function C(e,t,n){switch(e){case`event`:p=t||void 0;break;case`data`:d=f===0?t:`${d}\n${t}`,f++;break;case`id`:t.includes(`\0`)||(u=t);break;case`retry`:/^\d+$/.test(t)?o?.(parseInt(t,10)):r?.(new pw(`Invalid \`retry\` value: "${t}"`,{type:`invalid-retry`,value:t,line:n}));break;default:r?.(new pw(`Unknown field "${e.length>20?`${e.slice(0,20)}…`:e}"`,{type:`unknown-field`,field:e,value:t,line:n}))}}function w(){u!==void 0&&a?.(u),f>0&&i?.({id:u,event:p,data:d}),u=void 0,d=``,f=0,p=void 0}function T(e={}){if(e.consume&&s.length>0){let e=s.join(``);S(e,0,e.length)}l=``,u=void 0,d=``,f=0,p=void 0,s.length=0,c=0,m=!1,h=!1,g=!1}return{feed:_,reset:T}}function yw(e,t,n){return n===100&&e.charCodeAt(t+1)===97&&e.charCodeAt(t+2)===116&&e.charCodeAt(t+3)===97&&e.charCodeAt(t+4)===58}function bw(e,t,n){return n===101&&e.charCodeAt(t+1)===118&&e.charCodeAt(t+2)===101&&e.charCodeAt(t+3)===110&&e.charCodeAt(t+4)===116&&e.charCodeAt(t+5)===58}function xw(e,t){let n=1;for(;n<e.length&&n<t.length;){if(e.charCodeAt(n)!==t.charCodeAt(n))return!1;n++}return e.length<=t.length||e.charCodeAt(t.length)===58}async function*Sw(e,t){let n=e.getReader(),r=new TextDecoder,i=[],a=vw({onEvent:({event:e,data:t})=>{e!==void 0&&i.push({event:e,data:T(t)})}});try{for(;!t?.aborted;){let{done:e,value:t}=await n.read();if(e)return;if(a.feed(r.decode(t,{stream:!0})),i.length===0)continue;let o=i;i=[];for(let e of o)yield e}}finally{n.cancel().catch(()=>void 0)}}var Cw=1e3;async function ww(e){if(!e.ok)throw await Tl(e);if(!e.body)throw Error(`The agent answered the event stream with no body`);return e.body}async function*Tw(e,t,n){let r=await ww(await e.watch(t,n));for await(let e of Sw(r,n)){if(e.event===`run`&&e.data){let t=e.data;if(yield t,Ll(t))return`settled`;continue}if(e.event===`done`||e.event===`missing`)return`settled`;if(e.event===`idle`)return`handed-back`}return`dropped`}async function*Ew(e,t,n){for(;!n?.aborted;){let r=yield*Tw(e,t,n);if(r===`settled`||n?.aborted)return;if(r===`dropped`)throw Error(`The event stream for run ${t} ended before the run settled`)}}async function*Dw(e,t,n,r){let i=await ww(await e.streamOutput(t,w({namespace:n.namespace,startIndex:r,signal:n.signal}))),a=r;for await(let e of Sw(i,n.signal)){if(e.event===`chunk`){a+=1,yield e.data;continue}if(e.event===`done`){let t=e.data?.complete===!0;return{next:a,complete:t}}if(e.event===`missing`)return{next:a,complete:!0}}return{next:a,complete:!1}}async function*Ow(e,t,n={}){let r=Math.max(0,n.fromIndex??0);for(;!n.signal?.aborted;){let i=yield*Dw(e,t,n,r);if(r=i.next,i.complete||n.signal?.aborted)return;await Fl(Cw,w({signal:n.signal}))}}function kw(e,t){return{loaded:e,total:t,fraction:t!==void 0&&t>0?Math.min(1,e/t):void 0}}function Aw(){let e=globalThis.XMLHttpRequest;return typeof e==`function`?e:void 0}var jw=new Set([204,205,304]),Mw=200,Nw=599;function Pw(e,t,n,r,i,a,o,s){return new Promise((c,l)=>{let u=new e,d=e=>t=>{s&&s.removeEventListener(`abort`,m),e(t)},f=d(c),p=d(l),m=()=>u.abort();u.open(t,n);for(let[e,t]of Object.entries(r))u.setRequestHeader(e,t);if(u.upload.addEventListener(`progress`,e=>{o(kw(e.loaded,e.lengthComputable?e.total:a))}),u.addEventListener(`load`,()=>{if(u.status<Mw||u.status>Nw){p(Fw());return}let e=u.getResponseHeader(`Content-Type`);f(new Response(jw.has(u.status)?null:u.responseText,{status:u.status,statusText:u.statusText,headers:w({"Content-Type":e??void 0})}))}),u.addEventListener(`error`,()=>p(Fw())),u.addEventListener(`timeout`,()=>p(Fw())),u.addEventListener(`abort`,()=>p(s?.reason??Iw())),s){if(s.aborted){p(s.reason??Iw());return}s.addEventListener(`abort`,m,{once:!0})}u.send(i)})}function Fw(){return TypeError(`${Cl}: the upload did not reach the agent`)}function Iw(){return new DOMException(`The upload was aborted.`,`AbortError`)}var Lw=new Set([408,425,429,500,502,503,504]);function Rw(e,t){let n=t&&ce(t);return n?Math.min(Math.max(0,n.getTime()-Date.now()),g):kl(e,{baseMs:500,maxMs:g})}async function zw(e,t){for(let n=1;;n+=1){let r;try{r=await e()}catch(e){if(n>=t.attempts||t.signal.aborted)throw e}if(r&&(r.ok||!Lw.has(r.status))||r&&n>=t.attempts)return{res:r,attempts:n};await Fl(Rw(n,r),{signal:t.signal}),t.signal.throwIfAborted()}}function Bw(e){let t=[],n,r=Al(async()=>{for(;t.length>0&&n===void 0;){let n=t.splice(0,e.batch).map(e=>`offset=${e}`).join(`&`),{res:r}=await zw(()=>fetch(`${e.uploads}/parts?${n}&stored=1`,{method:`PUT`,headers:e.headers,signal:e.signal}),{attempts:e.attempts,signal:e.signal});if(!r.ok)throw await e.fail(r)}}),i=t=>{n??=t,e.onFail(t)};return{landed(e){t.push(e),r.trigger().catch(i)},async drain(){if(await r.trigger().catch(i),n!==void 0)throw n}}}function Vw(e){if(typeof e==`string`)return;if(e instanceof ArrayBuffer||ArrayBuffer.isView(e))return e.byteLength;let t=e;return typeof t.size==`number`&&typeof t.slice==`function`?t.size:void 0}function Hw(e,t,n){return e instanceof ArrayBuffer?new Uint8Array(e,t,n-t):ArrayBuffer.isView(e)?new Uint8Array(e.buffer,e.byteOffset+t,n-t):e.slice(t,n)}function Uw(e,t,n={}){let r=Vw(e);if(r===void 0)return;let i=Gw(r,t.partBytes??8388608);if(i.length>=Ww)return{total:r,parts:i};if(i.length!==0&&n.resumable===!0)return{total:r,parts:Gw(r,h)}}var Ww=2;function Gw(e,t){let n=Math.max(h,Math.ceil(t/h)*h),r=[];for(let t=0;t<e;t+=n)r.push({start:t,end:Math.min(t+n,e),index:r.length});return r}async function Kw(e,t,n){let r=Number.isFinite(t)?Math.max(1,Math.floor(t)):1,i=Array(e.length),a=0,o=!1,s;if(await Promise.allSettled(Array.from({length:Math.min(r,e.length)},async()=>{for(let t=a++;t<e.length&&!o;t=a++)try{i[t]=await n(e[t],t)}catch(e){throw o=!0,s??={reason:e},e}})),s!==void 0)throw s.reason;return i}async function qw(e){let{missing:t,width:n,sendPart:r,failed:i}=e;try{await Kw(t,n,async e=>{try{await r(e)}catch(e){throw i.abort(e),e}})}catch(e){throw i.signal.aborted?i.signal.reason:e}}function Jw(e){let{req:t,bytesBase:n,uploads:r,options:i,attempts:a,signal:o,report:s,claimer:c}=e;return async e=>{let l=n?`${n}/${encodeURIComponent(t.id)}/${e.start}`:`${r}/parts?offset=${e.start}`,{res:u}=await zw(()=>(s(e.index,0),t.send(`PUT`,l,n?{"Content-Type":t.type}:{...t.headers,"Content-Type":t.type},Hw(t.file,e.start,e.end),Yw(i,e,s))),{attempts:a,signal:o});if(!u.ok)throw await t.fail(u);n&&c.landed(e.start),s(e.index,e.end-e.start)}}function Yw(e,t,n){return{...w({signal:e?.signal}),...e?.onProgress?{onProgress:e=>n(t.index,e.loaded)}:{}}}function Xw(e){if(e!==!1)return e===void 0||e===!0?{}:e}function Zw(e){let t=e.replace(/\/+$/,``);if(t.endsWith(`/workflows`))return`${t.slice(0,-Sl.length)}/uploads`}async function Qw(e){let{req:t,begun:n,begunAlready:r,uploads:i,signal:a,attempts:o,parts:s}=e,c=n.ok?await Dl(n).catch(()=>({})):{},l=r?await rT(t,i,a,o):void 0,u=n.ok?c:l?.capability??{};return{bytesBase:u.directParts===!0?Zw(t.base):void 0,claimBatch:$w(u.claimBatch),missing:l?s.filter(e=>!iT(l.ranges,e)):s}}function $w(e){return Number.isInteger(e)&&(e??0)>1?e??1:1}async function eT(e){let{total:t,parts:n}=e.plan,r=`${e.base}/uploads/${encodeURIComponent(e.id)}`,i=new AbortController,a=e.options?.signal?AbortSignal.any([e.options.signal,i.signal]):i.signal,o={...e.options,signal:a},{res:s,attempts:c}=await zw(()=>fetch(`${r}/parts?name=${encodeURIComponent(e.name)}&total=${t}`,{method:`POST`,headers:{...e.headers,"Content-Type":e.type},signal:a}),{attempts:4,signal:a}),l=s.status===409&&(c>1||e.options?.resume===!0);if(!(s.ok||l))throw await e.fail(s);let{bytesBase:u,claimBatch:d,missing:f}=await Qw({req:e,begun:s,begunAlready:l,uploads:r,signal:a,attempts:4,parts:n}),p=Bw({uploads:r,headers:e.headers,batch:d,attempts:4,signal:a,fail:e.fail,onFail:e=>i.abort(e)}),m=aT(t,n.length,e.options?.onProgress);for(let e of n)f.includes(e)||m(e.index,e.end-e.start);let h=Jw({req:e,bytesBase:u,uploads:r,options:o,attempts:4,signal:a,report:m,claimer:p});await qw({missing:f,width:e.settings.concurrency??8,sendPart:h,failed:i}),await p.drain();let{res:g}=await zw(()=>fetch(`${r}/info`,{headers:e.headers,signal:a}),{attempts:4,signal:a});if(!g.ok)throw await e.fail(g);let _=await Dl(g);return tT(_,e.id,t),{..._,url:r}}function tT(e,t,n){if(!e.complete)throw new nT(`Workflow API: upload ${t} stored every part but reports ${e.size} of ${n} byte(s) and is not complete. The agent acknowledged each window and then did not record it, so nothing can read this upload.`)}var nT=class extends Error{name=`UploadNotRecordedError`};async function rT(e,t,n,r){let{res:i}=await zw(()=>fetch(`${t}/info`,{headers:e.headers,signal:n}),{attempts:r,signal:n});if(!i.ok)throw await e.fail(i);let a=await Dl(i);return{ranges:a.complete?[{start:0,end:a.size}]:a.ranges??[],capability:a}}function iT(e,t){return e.some(e=>e.start<=t.start&&e.end>=t.end)}function aT(e,t,n){let r=Array(t).fill(0);return n?(n(kw(0,e)),(t,i)=>{r[t]=i,n(kw(r.reduce((e,t)=>e+t,0),e))}):()=>void 0}function oT(e){if(e instanceof nT||e instanceof Error&&e.name===`AbortError`)return!1;let t=El(e);return t===void 0||Lw.has(t)}function sT(e){return kl(e,{baseMs:_,maxMs:v})}async function cT(e,t){let n=t.attempts??4;for(let r=1;;r+=1){try{return await e({resume:r!==1||t.resume,round:r})}catch(e){if(r>=n||t.signal?.aborted===!0||!oT(e))throw e}await Fl(sT(r),w({signal:t.signal})),t.signal?.throwIfAborted()}}function lT(e){if(typeof e==`string`)return;if(e instanceof ArrayBuffer||ArrayBuffer.isView(e))return e.byteLength;let t=e.size;return typeof t==`number`?t:void 0}async function uT(e,t,n,r,i){let a=i?.signal,o={method:e,headers:n,body:r,...w({signal:a})},s=i?.onProgress;if(!s)return await fetch(t,o);let c=lT(r),l=0,u=e=>{l=e.loaded,s(e)};u(kw(0,c));let d=Aw(),f=d?await Pw(d,e,t,n,r,c,u,a):await fetch(t,o);return u(kw(c??l,c)),f}function dT(e,t){let n=e;return{name:t?.name??(typeof n.name==`string`?n.name:``),type:t?.type??(typeof n.type==`string`&&n.type?n.type:`application/octet-stream`)}}function fT(){let e=crypto.randomUUID().replaceAll(`-`,``);return Nl(y.test(e),`upload.id.minted`,()=>({id:e})),e}function pT(e,t){return cT(t=>eT({...e,send:uT,options:{...e.options,resume:t.resume}}),{resume:t,...w({signal:e.options?.signal})})}async function mT(e,t,n,r,i){let{name:a,type:o}=dT(r,i),s=Xw(i?.parallel),c=s&&Uw(r,s);if(s&&c)return pT({base:e,headers:t,fail:n,id:fT(),file:r,name:a,type:o,options:i,settings:s,plan:c},void 0);let l=await uT(`POST`,`${e}/uploads?name=${encodeURIComponent(a)}`,{...t,"Content-Type":o},r,i);if(!l.ok)throw await n(l);let u=await Dl(l);return{...u,url:`${e}/uploads/${encodeURIComponent(u.id)}`}}async function hT(e,t,n,r,i,a){let{name:o,type:s}=dT(i,a),c=Xw(a?.parallel),l=c&&Uw(i,c,{resumable:!0});if(c&&l)return pT({base:e,headers:t,fail:n,id:r,file:i,name:o,type:s,options:a,settings:c,plan:l},a?.resume);let u=await uT(`PUT`,`${e}/uploads/${encodeURIComponent(r)}?name=${encodeURIComponent(o)}`,{...t,"Content-Type":s},i,a);if(!u.ok)throw await n(u);let d=await Dl(u);return{...d,url:`${e}/uploads/${encodeURIComponent(d.id)}`}}async function gT(e,t,n,r,i){let a=await fetch(`${e}/uploads/${encodeURIComponent(r)}`,{headers:t,...w({signal:i})});if(!a.ok)throw await n(a);return await a.blob()}async function _T(e,t,n,r,i){let a=await fetch(`${e}/uploads/${encodeURIComponent(r)}/info`,{headers:t,...w({signal:i})});if(!a.ok)throw await n(a);return await Dl(a)}function vT(e){let t=wl(e.baseUrl),n=e.token?{Authorization:`Bearer ${e.token}`}:{};function r(t=0,n){let r=e.timeoutMs===void 0?void 0:AbortSignal.timeout(e.timeoutMs+t);return r===void 0?w({signal:n}):{signal:n?AbortSignal.any([n,r]):r}}async function i(e,i,a){let o=a.wait,s=await fetch(`${t}/runs`,{method:`POST`,headers:{...n,"Content-Type":`application/json`},body:JSON.stringify({workflow:e,...w({input:i,key:a.key,wait:o})}),...r(o,a.signal)});if(!s.ok)throw await Tl(s);return await Dl(s)}async function a(e,i,a){let o=new URLSearchParams(e);i!==void 0&&o.set(`limit`,String(i));let s=await fetch(`${t}/runs?${o.toString()}`,{headers:n,...r(0,a)});if(!s.ok)throw await Tl(s);return(await Dl(s)).runs??[]}let o={upload(e,r){return mT(t,n,Tl,e,r)},async list(e){let i=await fetch(t,{headers:n,...r(0,e?.signal)});if(!i.ok)throw await Tl(i);return(await Dl(i)).workflows??[]},async start(e,t,n){let{runId:r}=await i(e,t,{key:n?.key,signal:n?.signal});return r},async startAndWait(e,t,n){let r=zl(n?.wait??6e4),a=await i(e,t,{key:n?.key,wait:r,signal:n?.signal});return a.run??Ol(a.runId,e)},async get(e,i){let a=zl(i?.wait),o=a>0?`?wait=${a}`:``,s=await fetch(`${t}/runs/${encodeURIComponent(e)}${o}`,{headers:n,...r(a,i?.signal)});if(s.status!==404){if(!s.ok)throw await Tl(s);return await Dl(s)}},find(e,t,n){return a({workflow:e,key:t},n?.limit,n?.signal)},recent(e,t){return a({workflow:e},t?.limit,t?.signal)},watch(e,r){return fetch(`${t}/runs/${encodeURIComponent(e)}/events`,{headers:{...n,Accept:`text/event-stream`},...w({signal:r})})},streamOutput(e,r){let i=new URLSearchParams(w({namespace:r?.namespace,startIndex:r?.startIndex===void 0?void 0:String(r.startIndex)})),a=i.size>0?`?${i.toString()}`:``;return fetch(`${t}/runs/${encodeURIComponent(e)}/stream${a}`,{headers:{...n,Accept:`text/event-stream`},...w({signal:r?.signal})})},follow(e,t){return Ew(o,e,t?.signal)},followOutput(e,t){return Ow(o,e,t??{})},uploadStream:(e,r,i)=>hT(t,n,Tl,e,r,i),uploadInfo:(e,i)=>_T(t,n,Tl,e,r(0,i?.signal).signal),download:(e,r)=>gT(t,n,Tl,e,r?.signal),async wake(e,i){let a=bT(i?.correlationIds),o=await fetch(`${t}/runs/${encodeURIComponent(e)}/wake${a}`,{method:`POST`,headers:n,...r(0,i?.signal)});if(o.status===404)return 0;if(!o.ok)throw await Tl(o);return(await Dl(o)).woken??0},async cancel(e,i){let a=await fetch(`${t}/runs/${encodeURIComponent(e)}`,{method:`DELETE`,headers:n,...r(0,i?.signal)});if(!a.ok)throw await Tl(a);return(await Dl(a)).cancelled===!0}};return o}var yT=256;function bT(e){if(!e||e.length===0)return``;let t=new URLSearchParams;for(let n of e){if(n.trim()===``)throw Error("A workflow `correlationId` must not be empty");if(n.length>yT)throw Error(`A workflow \`correlationId\` must be at most ${yT} characters`);t.append(`correlationId`,n)}return`?${t.toString()}`}function xT(e){let t=vT(e),n=e.baseUrl.replace(/\/+$/,``),r=e.token?{Authorization:`Bearer ${e.token}`}:{};return{...t,baseUrl:n,async config(){let t=e.timeoutMs===void 0?void 0:AbortSignal.timeout(e.timeoutMs),i=await fetch(`${n}/${yl}`,{headers:r,...w({signal:t})});if(!i.ok)throw await Tl(i);return await Dl(i)}}}function ST(e={}){return xT({baseUrl:e.baseUrl??pu(),...w({token:e.token})})}function CT(e){let t=(0,V.useRef)(e);t.current=e;let n=(0,V.useRef)(void 0);return(0,V.useCallback)(()=>t.current||(n.current??=ST(),n.current),[])}function wT(e={}){let{api:t,skip:n=!1}=e,[r,i]=(0,V.useState)({workflows:[],loading:!n,error:void 0}),a=CT(t);return(0,V.useEffect)(()=>{if(n)return;let e=!1;return a().list().then(t=>{e||i({workflows:t,loading:!1,error:void 0})}).catch(t=>{e||i({workflows:[],loading:!1,error:be(t)})}),()=>{e=!0}},[n,a]),r}function TT(e){if(!C(e))return;let{type:t}=e;return typeof t==`string`?t:Array.isArray(t)?t.find(e=>e!==`null`):void 0}function ET(e,t){if(t?.upload===!0)return`file`;if(!C(e))return`none`;let{enum:n}=e;if(Array.isArray(n)&&n.length>0)return`select`;switch(TT(e)){case`boolean`:return`checkbox`;case`number`:case`integer`:return`number`;case`string`:return`text`;default:return`none`}}function DT({workflow:e}){let{workflows:t,loading:n}=wT(typeof e==`string`?{}:{skip:!0}),r=typeof e==`string`?t.find(t=>t.name===e):e;KC(n);let i=kT(r?.inputSchema);if(!i?.properties)return null;let a=new Set(i.required??[]),o=new Set(r?.uploads??[]);return(0,U.jsx)(U.Fragment,{children:Object.entries(i.properties).map(([e,t])=>(0,U.jsx)(OT,{name:e,property:t,required:a.has(e),upload:o.has(e)},e))})}function OT({name:e,property:t,required:n,upload:r=!1}){let i=AT(e),a=t.description===void 0?{}:{hint:t.description},o=t.default===void 0?{}:{defaultValue:String(t.default)};switch(ET(t,{upload:r})){case`file`:return(0,U.jsx)(cw,{name:e,label:i,required:n,upload:!0,...a});case`select`:return(0,U.jsx)(ow,{name:e,label:i,required:n,options:(t.enum??[]).map(e=>String(e)),...a,...o});case`checkbox`:return(0,U.jsx)(sw,{name:e,label:i,defaultChecked:t.default===!0,...a});case`number`:return(0,U.jsx)(aw,{name:e,label:i,required:n,step:TT(t)===`integer`?1:`any`,...a,...o});case`text`:return(0,U.jsx)(iw,{name:e,label:i,required:n,...a,...o});default:return null}}function kT(e){return C(e)?e:void 0}function AT(e){let t=e.replace(/[_-]+/g,` `).replace(/([a-z0-9])([A-Z])/g,`$1 $2`).trim().toLowerCase();return t.charAt(0).toUpperCase()+t.slice(1)}function jT(e,t){let n=new AbortController,r,i=async()=>{await t(n.signal)||n.signal.aborted||(r=setTimeout(()=>void i(),e))};return i(),()=>{n.abort(),r!==void 0&&clearTimeout(r)}}var MT=5e3;function NT(e){return e===408||e===429||e>=500}async function PT(e,t){let n=[],r=`partial`;for await(let i of Sw(e,t))if(i.event===`chunk`)n.push(i.data);else if(i.event===`done`)r=i.data?.complete?`complete`:`partial`;else if(i.event===`missing`)return{ending:`complete`,chunks:n};return{ending:r,chunks:n}}function FT(e,t,n,r,i,a){let o=n.startIndex??0,s=o<0?-o:void 0,c=s===void 0?o:0,l=!0,u=async r=>{let a=await e().streamOutput(t,{...w({namespace:n.namespace,startIndex:c===0?void 0:c}),signal:r});if(!a.ok&&NT(a.status))return`partial`;if(!(a.ok&&a.body))return`unsupported`;let{ending:o,chunks:u}=await PT(a.body,r);c+=u.length;let d=l&&s!==void 0?u.slice(-s):u;return l=!1,d.length>0&&!r.aborted&&i(d),o};return jT(r,async e=>{let t;try{t=await u(e)}catch{t=`partial`}return e.aborted?!0:t!==`partial`&&(a(t),!0)})}function IT(e,t={}){let{api:n,namespace:r,startIndex:i,intervalMs:a=MT}=t,[o,s]=(0,V.useState)([]),[c,l]=(0,V.useState)(!1),[u,d]=(0,V.useState)(!0),f=CT(n);return(0,V.useEffect)(()=>{if(s([]),d(!0),l(!1),!e)return;l(!0);let t=FT(f,e,{namespace:r,startIndex:i},a,e=>s(t=>[...t,...e]),e=>{l(!1),e===`unsupported`&&d(!1)});return()=>{t(),l(!1)}},[e,r,i,a,f]),{progress:o,latest:o.at(-1),streaming:c,supported:u}}function LT({runId:e,api:t,className:n,placeholder:r,lines:i}){let{progress:a,streaming:o,supported:s}=IT(e,w({api:t})),c=(0,V.useMemo)(()=>{let e=i===void 0?a:a.slice(Math.max(a.length-i,0));return e.length===0?null:e.join(`
125
125
  `)},[a,i]);return!s||c===null?r??null:(0,U.jsxs)(`pre`,{role:`log`,"aria-live":`polite`,"aria-atomic":`false`,className:H(n??`whitespace-pre-wrap border-l pl-4 text-xs opacity-70`),children:[c,o&&`
126
- …`]})}function LT({run:e,className:t}){return e?.status===`failed`?(0,U.jsxs)(`p`,{role:`alert`,className:H(`text-red-600`,t),children:[`That run failed: `,e.error]}):null}function RT(e){let{workflow:t,key:n,enabled:r,getClient:i}=e,[a,o]=(0,V.useState)(r),s=(0,V.useRef)(e);return s.current=e,(0,V.useEffect)(()=>{if(!r)return;let e=!1;return o(!0),i().find(t,n,{limit:1}).then(t=>{if(e)return;let n=t[0];n!==void 0&&s.current.onFound(n.runId),o(!1)}).catch(t=>{e||(s.current.onError(be(t)),o(!1))}),()=>{e=!0}},[r,n,t,i]),a}function zT(e,t){return{wake:(0,V.useCallback)(async()=>e===void 0?0:await t().wake(e),[e,t]),cancel:(0,V.useCallback)(async()=>e!==void 0&&await t().cancel(e),[e,t])}}function BT(e){if(e instanceof File)return[e];if(!Array.isArray(e))return[];let t=e.filter(e=>e instanceof File);return t.length>0&&t.length===e.length?t:[]}var VT=`aai:upload:`,HT=32;function UT(e){return`${VT}${e}`}function WT(e){return`${e.size}:${e.lastModified}:${e.type}:${e.name}`}function GT(e){let t=cS(`session`,UT(e));if(t===void 0)return{};try{let e=JSON.parse(t);return C(e)?e:{}}catch{return{}}}function KT(e,t){lS(`session`,UT(e),JSON.stringify(t))}function qT(e,t){let n=GT(e)[WT(t)];return typeof n==`string`?n:void 0}function JT(e,t,n){let r=GT(e),i=WT(t);delete r[i],r[i]=n;let a=Object.keys(r);for(let e of a.slice(0,Math.max(0,a.length-HT)))delete r[e];KT(e,r)}function YT(e,t){let n=GT(e),r=WT(t);r in n&&(delete n[r],KT(e,n))}function XT(e){return e instanceof Error&&e.name===`AbortError`}function ZT(){return crypto.randomUUID().replaceAll(`-`,``)}async function QT(e,t){let n=!1;for(;;){if(await e.settle(),e.cancelled)throw Error(`Upload cancelled.`);let r=n;n=!0;try{await t(r);return}catch(t){if(e.cancelled||!XT(t))throw t}}}function $T(){let e=new AbortController,t=!1,n=!1,r,i;return{get paused(){return t},get cancelled(){return n},get signal(){return e.signal},pause(){if(t||n)return;t=!0;let a=Promise.withResolvers();i=a.promise,r=a.resolve,e.abort()},resume(){t&&!n&&(t=!1,e=new AbortController,r?.(),r=void 0,i=void 0)},cancel(){n||(n=!0,t=!1,e.abort(),r?.(),r=void 0,i=void 0)},async settle(){i&&await i}}}function eE(e){return{scope:e,ids:new Map,stored:new Map,tried:new Set,gate:$T()}}async function tE(e,t,n){let r=qT(t.scope,n);if(r===void 0)return{id:ZT(),complete:!1};let i=await e.uploadInfo(r).catch(()=>void 0);return i?.complete===!0?{id:r,complete:!0}:i!==void 0&&(i.ranges?.length??0)>0?(t.tried.add(n),{id:r,complete:!1}):(YT(t.scope,n),{id:ZT(),complete:!1})}async function nE(e,t,n,r,i){if(!C(t))return t;let a=Object.entries(t),o=a.reduce((e,[,t])=>e+BT(t).length,0),s=0,c=async t=>{s+=1;let a=i.stored.get(t);if(a!==void 0)return a;let c={name:t.name,index:s,count:o},l=i.ids.get(t),u=l===void 0?await tE(e,i,t):{id:l,complete:!1},d=u.id;return l===void 0&&(i.ids.set(t,d),JT(i.scope,t,d)),u.complete?(n({...c,loaded:t.size,total:t.size,fraction:1,paused:!1}),i.stored.set(t,d),d):(await QT(i.gate,async a=>{await e.uploadStream(d,t,{name:t.name,signal:i.gate.signal,onProgress:e=>n({...c,...e,paused:i.gate.paused}),...w({parallel:r,resume:a||i.tried.has(t)?!0:void 0})})}),i.stored.set(t,d),d)},l={};for(let[e,t]of a){if(t instanceof File){l[e]=await c(t);continue}let n=BT(t);if(n.length===0){l[e]=t;continue}let r=[];for(let e of n)r.push(await c(e));l[e]=r}return l}function rE(e,t){let n=(0,V.useCallback)(e=>{t(t=>t&&{...t,paused:e})},[t]);return{pauseUpload:(0,V.useCallback)(()=>{e()?.pause(),n(!0)},[e,n]),resumeUpload:(0,V.useCallback)(()=>{e()?.resume(),n(!1)},[e,n])}}function iE(e){let{name:t,index:n,count:r,loaded:i,total:a,fraction:o,paused:s}=e,c=o===void 0?i:Math.round(o*1e3);return`${s} ${n} ${r} ${a??-1} ${c} ${t}`}function aE(e){let t;return n=>{if(n===void 0){t=void 0,e(void 0);return}let r=iE(n);r!==t&&(t=r,e(n))}}function oE(){let[e,t]=(0,V.useState)(void 0),[n,r]=(0,V.useState)(!1),[i,a]=(0,V.useState)(void 0),[o,s]=(0,V.useState)(void 0),c=(0,V.useRef)(void 0),l=(0,V.useCallback)(e=>{r(!0),a(void 0),t(void 0),c.current?.gate.cancel(),c.current=e},[]),u=(0,V.useCallback)(e=>{c.current===e&&(c.current=void 0,r(!1),s(void 0))},[]),d=(0,V.useCallback)(()=>{c.current?.gate.cancel(),c.current=void 0,t(void 0),a(void 0),s(void 0)},[]),{pauseUpload:f,resumeUpload:p}=rE((0,V.useCallback)(()=>c.current?.gate,[]),s);return{runId:e,starting:n,startError:i,upload:o,actions:(0,V.useMemo)(()=>({setRunId:t,setStartError:a,setUpload:s,begin:l,end:u,reset:d,pauseUpload:f,resumeUpload:p}),[l,u,d,f,p])}}var sE=`aai:run-key:`;function cE(){return dS(sE,`./`)}function lE(e){let t=cE(),n=cS(e,t);if(n!==void 0)return n;let r=crypto.randomUUID();return lS(e,t,r),r}function uE(e){let[t]=(0,V.useState)(()=>e===void 0?lE(`session`):``);return e??t}function dE(e,t,n,r,i){let a=new AbortController,o=()=>{a.signal.aborted||i()};return(async()=>{let r=await e().watch(t,a.signal);if(!(r.ok&&r.body))return`fallback`;for await(let e of xw(r.body,a.signal)){e.event===`run`&&e.data&&n(e.data);let t=fE(e.event);if(t)return t}return`fallback`})().then(e=>e===`settled`?r():o(),()=>o()),()=>a.abort()}function fE(e){return e===`done`||e===`missing`?`settled`:e===`idle`?`fallback`:void 0}var pE=2e3;function mE(e,t,n,r,i,a){let o=0,s=e=>(o+=1,o<3?!1:(e.aborted||i(`No workflow run ${t}`),!0)),c=async n=>{try{let i=await e().get(t);return n.aborted?!0:i?(o=0,r(i),Ll(i)):s(n)}catch(e){return n.aborted||i(be(e)),!1}};return AT(n,async e=>await c(e)?(e.aborted||a(),!0):!1)}function hE(e,t={}){let{api:n,intervalMs:r=pE}=t,[i,a]=(0,V.useState)(void 0),[o,s]=(0,V.useState)(void 0),[c,l]=(0,V.useState)(!1),u=ST(n);return(0,V.useEffect)(()=>{if(a(void 0),s(void 0),l(!1),!e)return;let t=e=>{a(e),s(void 0)},n,i=dE(u,e,t,()=>l(!0),()=>{n=mE(u,e,r,t,s,()=>l(!0))});return()=>{i(),n?.()}},[e,r,u]),{run:i,error:o,polling:e!==void 0&&!c&&!Ll(i)}}function gE(e,t={}){let{api:n,recover:r=!0,wait:i,intervalMs:a,parallel:o}=t,s=uE(t.key),c=oE(),{runId:l,actions:u}=c,d=ST(n),f=hE(l,w({api:n,intervalMs:a})),{wake:p,cancel:m}=zT(l,d),[h,g]=(0,V.useState)(!1),_=RT({workflow:e,key:s,enabled:r,getClient:d,onFound:e=>{u.setRunId(t=>t??e)},onError:u.setStartError}),v=(0,V.useCallback)(async t=>{let n=d(),r=eE(e);g(!0),u.begin(r);try{let a=w({key:s}),c=await nE(n,t,aE(u.setUpload),o,r);u.setRunId(i===void 0?await n.start(e,c,a):(await n.startAndWait(e,c,{...a,wait:i})).runId)}catch(e){r.gate.cancelled||u.setStartError(be(e))}finally{u.end(r)}},[e,s,i,o,d,u]);return{submit:v,submitForm:v,reset:(0,V.useCallback)(()=>{g(!1),u.reset()},[u]),wake:p,cancel:m,pauseUpload:u.pauseUpload,resumeUpload:u.resumeUpload,run:f.run,startedHere:h,pending:_||c.starting||f.polling,upload:c.upload,error:c.startError??f.error}}function _E(){let[e,t]=(0,V.useState)();return(0,V.useEffect)(()=>{let e=!1;return yu().then(n=>{e||t(n)}),()=>{e=!0}},[]),e}function vE({workflow:e}){let{submitForm:t,run:n,pending:r,upload:i,pauseUpload:a,resumeUpload:o,error:s}=gE(e.name);return(0,U.jsxs)(`section`,{className:`flex flex-col gap-4`,children:[e.description===void 0?null:(0,U.jsx)(`p`,{className:`text-sm opacity-70`,children:e.description}),(0,U.jsxs)(cw,{onSubmit:e=>t(e),error:s,className:`flex flex-col gap-4`,children:[(0,U.jsx)(ET,{workflow:e}),(0,U.jsx)(lw,{pending:r,children:`Start`})]}),(0,U.jsx)(dw,{upload:i,onPause:a,onResume:o}),(0,U.jsx)(IT,{runId:n?.runId}),(0,U.jsx)(LT,{run:n}),n?.status===`completed`&&(0,U.jsx)(`pre`,{className:`overflow-x-auto rounded-md border p-4 text-xs`,children:JSON.stringify(n.output,null,2)})]})}function yE({name:e}){let t=_E(),{workflows:n,loading:r,error:i}=CT(),[a,o]=(0,V.useState)(),s=n.find(e=>e.name===a)??n[0];return(0,U.jsxs)(`main`,{className:`mx-auto flex max-w-2xl flex-col gap-6 p-8`,children:[(0,U.jsxs)(`header`,{className:`flex flex-col gap-1`,children:[(0,U.jsx)(`h1`,{className:`text-2xl font-medium`,children:e??t?.name??`Workflows`}),t?.greeting===void 0?null:(0,U.jsx)(`p`,{className:`text-sm opacity-70`,children:t.greeting})]}),i===void 0?null:(0,U.jsx)(`p`,{role:`alert`,className:`text-red-600`,children:i}),r&&(0,U.jsx)(`p`,{className:`text-sm opacity-70`,children:`Loading workflows…`}),!r&&i===void 0&&n.length===0&&(0,U.jsx)(`p`,{className:`text-sm opacity-70`,children:`This agent declares no workflows.`}),n.length>1&&(0,U.jsxs)(`label`,{className:`flex flex-col gap-1 text-sm`,children:[`Workflow`,(0,U.jsx)(`select`,{value:s?.name??``,onChange:e=>o(e.target.value),className:`rounded-md border px-3 py-2`,children:n.map(e=>(0,U.jsx)(`option`,{value:e.name,children:e.name},e.name))})]}),s&&(0,U.jsx)(vE,{workflow:s},s.name)]})}function bE(e={}){let t=FC(e.target);mu(e.name);let n=e.component;return IC(t,(0,V.createElement)(Uu,{value:e.theme},n?(0,V.createElement)(n):(0,V.createElement)(yE,{name:e.name})))}async function xE(e={mountClient:BC,mountPage:bE}){let t=await yu(),n=w({name:t.name});if(t.page===`static`){e.mountPage(n);return}e.mountClient(n)}xE();export{p as a,m as i,d as n,f as r,u as t};
126
+ …`]})}function RT({run:e,className:t}){return e?.status===`failed`?(0,U.jsxs)(`p`,{role:`alert`,className:H(`text-red-600`,t),children:[`That run failed: `,e.error]}):null}function zT(e,t){return{wake:(0,V.useCallback)(async()=>e===void 0?0:await t().wake(e),[e,t]),cancel:(0,V.useCallback)(async()=>e!==void 0&&await t().cancel(e),[e,t])}}async function BT(e,t,n){return(await e.find(t,n,{limit:1}))[0]?.runId}function VT(e,t){return e.start(),{send:t=>e.send(t),getView:t,subscribe(t){let n=e.subscribe(()=>t());return()=>n.unsubscribe()},stop:()=>e.stop()}}var HT=(0,B.setup)({types:{},actors:{lookup:(0,B.fromPromise)(({input:e})=>e.find()),submission:(0,B.fromPromise)(async({input:e,signal:t})=>{let{gate:n,work:r,settle:i,send:a}=e;t.addEventListener(`abort`,()=>n?.cancel(),{once:!0});let o=e=>{t.aborted||a(e)};try{await r?.({progress:e=>o({type:`PROGRESS`,upload:e}),started:e=>o({type:`STARTED`,runId:e})})}finally{t.aborted&&i?.()}})},guards:{found:({event:e})=>`output`in e&&typeof e.output==`string`,hasRun:({context:e})=>e.runId!==void 0,noRun:({context:e})=>e.runId===void 0},actions:{open:(0,B.assign)(({event:e})=>e.type===`SUBMIT`?{gate:e.gate,work:e.work,settle:e.settle,runId:void 0,startError:void 0,upload:void 0,startedHere:!0}:{}),close:(0,B.assign)({gate:void 0,work:void 0,settle:void 0,upload:void 0}),settle:({context:e})=>e.settle?.(),clear:(0,B.assign)({runId:void 0,startError:void 0,startedHere:!1}),pauseGate:({context:e})=>e.gate?.pause(),resumeGate:({context:e})=>e.gate?.resume(),markPaused:(0,B.assign)({upload:({context:e})=>e.upload?{...e.upload,paused:!0}:void 0}),markResumed:(0,B.assign)({upload:({context:e})=>e.upload?{...e.upload,paused:!1}:void 0})}}).createMachine({id:`workflowForm`,context:({input:e})=>({effects:e,runId:void 0,startError:void 0,upload:void 0,startedHere:!1,gate:void 0,work:void 0,settle:void 0}),initial:`idle`,on:{SUBMIT:{target:`.submitting`,reenter:!0,actions:`open`},RESET:{target:`.idle`,actions:`clear`}},states:{idle:{on:{RECOVER:`recovering`}},recovering:{entry:(0,B.assign)({startError:void 0}),invoke:{src:`lookup`,input:({context:e})=>e.effects,onDone:[{guard:`found`,target:`following`,actions:(0,B.assign)({runId:({event:e})=>e.output})},{target:`idle`}],onError:{target:`failed`,actions:(0,B.assign)({startError:({event:e})=>be(e.error)})}}},submitting:{initial:`active`,exit:[`settle`,`close`],invoke:{src:`submission`,input:({context:e,self:t})=>({gate:e.gate,work:e.work,settle:e.settle,send:e=>{t.send(e)}}),onDone:[{guard:`hasRun`,target:`following`},{target:`idle`}],onError:{target:`failed`,actions:(0,B.assign)({startError:({event:e})=>be(e.error)})}},on:{PROGRESS:{actions:(0,B.assign)({upload:({event:e})=>e.upload})},STARTED:{actions:(0,B.assign)({runId:({event:e})=>e.runId})}},states:{active:{on:{PAUSE:{target:`paused`,actions:[`pauseGate`,`markPaused`]}}},paused:{on:{RESUME:{target:`active`,actions:[`resumeGate`,`markResumed`]}}}}},following:{},failed:{on:{RECOVER:{guard:`noRun`,target:`recovering`}}}}});function UT(e){let t=(0,B.createActor)(HT,{input:e}),n={runId:void 0,startError:void 0,upload:void 0,startedHere:!1,busy:!1};return VT(t,()=>{let e=t.getSnapshot(),{runId:r,startError:i,upload:a,startedHere:o}=e.context,s=e.matches(`recovering`)||e.matches(`submitting`);return(r!==n.runId||i!==n.startError||a!==n.upload||o!==n.startedHere||s!==n.busy)&&(n={runId:r,startError:i,upload:a,startedHere:o,busy:s}),n})}var WT={runId:void 0,startError:void 0,upload:void 0,startedHere:!1,busy:!1},GT={...WT,busy:!0},KT=()=>()=>void 0,qT=()=>WT,JT=()=>GT;function YT(e){return e?.enabled?`${e.workflow}\n${e.key}`:void 0}function XT(e){let t=(0,V.useRef)(e);t.current=e;let n=(0,V.useRef)(void 0),r=(0,V.useRef)(null),[i,a]=(0,V.useState)(null);(0,V.useEffect)(()=>{let e=UT({find:async()=>{let e=t.current;if(e)return await BT(e.getClient(),e.workflow,e.key)}});return n.current=YT(t.current),n.current!==void 0&&e.send({type:`RECOVER`}),r.current=e,a(e),()=>{e.stop(),r.current=null,n.current=void 0,a(null)}},[]);let o=YT(e);(0,V.useEffect)(()=>{i&&o!==n.current&&(n.current=o,o!==void 0&&i.send({type:`RECOVER`}))},[i,o]);let s=o===void 0?qT:JT,c=(0,V.useSyncExternalStore)(i?.subscribe??KT,i?i.getView:s),l=(0,V.useCallback)((e,t)=>{let n=r.current;if(!n)return Promise.resolve();let i=Promise.withResolvers();return n.send({type:`SUBMIT`,gate:e,work:t,settle:()=>i.resolve()}),i.promise},[]),u=(0,V.useCallback)(()=>r.current?.send({type:`RESET`}),[]),d=(0,V.useCallback)(()=>r.current?.send({type:`PAUSE`}),[]),f=(0,V.useCallback)(()=>r.current?.send({type:`RESUME`}),[]),p=(0,V.useMemo)(()=>({submit:l,reset:u,pauseUpload:d,resumeUpload:f}),[l,u,d,f]);return{...c,actions:p}}function ZT(e){if(e instanceof File)return[e];if(!Array.isArray(e))return[];let t=e.filter(e=>e instanceof File);return t.length>0&&t.length===e.length?t:[]}var QT=`aai:upload:`,$T=32;function eE(e){return`${QT}${e}`}function tE(e){return`${e.size}:${e.lastModified}:${e.type}:${e.name}`}function nE(e){let t=cS(`session`,eE(e));if(t===void 0)return{};try{let e=JSON.parse(t);return C(e)?e:{}}catch{return{}}}function rE(e,t){lS(`session`,eE(e),JSON.stringify(t))}function iE(e,t){let n=nE(e)[tE(t)];return typeof n==`string`?n:void 0}function aE(e,t,n){let r=nE(e),i=tE(t);delete r[i],r[i]=n;let a=Object.keys(r);for(let e of a.slice(0,Math.max(0,a.length-$T)))delete r[e];rE(e,r)}function oE(e,t){let n=nE(e),r=tE(t);r in n&&(delete n[r],rE(e,n))}function sE(e){return e instanceof Error&&e.name===`AbortError`}function cE(){return crypto.randomUUID().replaceAll(`-`,``)}async function lE(e,t){let n=!1;for(;;){if(await e.settle(),e.cancelled)throw Error(`Upload cancelled.`);let r=n;n=!0;try{await t(r);return}catch(t){if(e.cancelled||!sE(t))throw t}}}function uE(){let e=new AbortController,t=`running`,n,r,i=()=>{n?.(),n=void 0,r=void 0};return{get paused(){return t===`paused`},get cancelled(){return t===`cancelled`},get signal(){return e.signal},pause(){if(t!==`running`)return;t=`paused`;let i=Promise.withResolvers();r=i.promise,n=i.resolve,e.abort()},resume(){t===`paused`&&(t=`running`,e=new AbortController,i())},cancel(){t!==`cancelled`&&(t=`cancelled`,e.abort(),i())},async settle(){r&&await r}}}function dE(e){return{scope:e,ids:new Map,stored:new Map,tried:new Set,gate:uE()}}async function fE(e,t,n){let r=iE(t.scope,n);if(r===void 0)return{id:cE(),complete:!1};let i=await e.uploadInfo(r).catch(()=>void 0);return i?.complete===!0?{id:r,complete:!0}:i!==void 0&&(i.ranges?.length??0)>0?(t.tried.add(n),{id:r,complete:!1}):(oE(t.scope,n),{id:cE(),complete:!1})}async function pE(e,t,n,r,i){if(!C(t))return t;let a=Object.entries(t),o=a.reduce((e,[,t])=>e+ZT(t).length,0),s=0,c=async t=>{s+=1;let a=i.stored.get(t);if(a!==void 0)return a;let c={name:t.name,index:s,count:o},l=i.ids.get(t),u=l===void 0?await fE(e,i,t):{id:l,complete:!1},d=u.id;return l===void 0&&(i.ids.set(t,d),aE(i.scope,t,d)),u.complete?(n({...c,loaded:t.size,total:t.size,fraction:1,paused:!1}),i.stored.set(t,d),d):(await lE(i.gate,async a=>{await e.uploadStream(d,t,{name:t.name,signal:i.gate.signal,onProgress:e=>n({...c,...e,paused:i.gate.paused}),...w({parallel:r,resume:a||i.tried.has(t)?!0:void 0})})}),i.stored.set(t,d),d)},l={};for(let[e,t]of a){if(t instanceof File){l[e]=await c(t);continue}let n=ZT(t);if(n.length===0){l[e]=t;continue}let r=[];for(let e of n)r.push(await c(e));l[e]=r}return l}function mE(e){let{name:t,index:n,count:r,loaded:i,total:a,fraction:o,paused:s}=e,c=o===void 0?i:Math.round(o*1e3);return`${s} ${n} ${r} ${a??-1} ${c} ${t}`}function hE(e){let t;return n=>{if(n===void 0){t=void 0,e(void 0);return}let r=mE(n);r!==t&&(t=r,e(n))}}var gE=`aai:run-key:`;function _E(){return dS(gE,`./`)}function vE(e){let t=_E(),n=cS(e,t);if(n!==void 0)return n;let r=crypto.randomUUID();return lS(e,t,r),r}function yE(e){let[t]=(0,V.useState)(()=>e===void 0?vE(`session`):``);return e??t}function bE(e,t,n,r,i){let a=new AbortController,o=()=>{a.signal.aborted||i()};return(async()=>{let r=await e().watch(t,a.signal);if(!(r.ok&&r.body))return`fallback`;for await(let e of Sw(r.body,a.signal)){e.event===`run`&&e.data&&n(e.data);let t=xE(e.event);if(t)return t}return`fallback`})().then(e=>e===`settled`?r():o(),()=>o()),()=>a.abort()}function xE(e){return e===`done`||e===`missing`?`settled`:e===`idle`?`fallback`:void 0}var SE=2e3;function CE(e,t,n,r,i,a){let o=0,s=e=>(o+=1,o<3?!1:(e.aborted||i(`No workflow run ${t}`),!0)),c=async n=>{try{let i=await e().get(t);return n.aborted?!0:i?(o=0,r(i),Ll(i)):s(n)}catch(e){return n.aborted||i(be(e)),!1}};return jT(n,async e=>await c(e)?(e.aborted||a(),!0):!1)}function wE(e,t={}){let{api:n,intervalMs:r=SE}=t,[i,a]=(0,V.useState)(void 0),[o,s]=(0,V.useState)(void 0),[c,l]=(0,V.useState)(!1),u=CT(n);return(0,V.useEffect)(()=>{if(a(void 0),s(void 0),l(!1),!e)return;let t=e=>{a(e),s(void 0)},n,i=bE(u,e,t,()=>l(!0),()=>{n=CE(u,e,r,t,s,()=>l(!0))});return()=>{i(),n?.()}},[e,r,u]),{run:i,error:o,polling:e!==void 0&&!c&&!Ll(i)}}function TE(e,t={}){let{api:n,recover:r=!0,wait:i,intervalMs:a,parallel:o}=t,s=yE(t.key),c=CT(n),l=XT({workflow:e,key:s,enabled:r,getClient:c}),{runId:u,actions:d}=l,f=wE(u,w({api:n,intervalMs:a})),{wake:p,cancel:m}=zT(u,c),h=(0,V.useCallback)(t=>{let n=c(),r=dE(e);return d.submit(r.gate,async({progress:a,started:c})=>{let l=w({key:s}),u=hE(a),d=await pE(n,t,u,o,r);c(i===void 0?await n.start(e,d,l):(await n.startAndWait(e,d,{...l,wait:i})).runId)})},[e,s,i,o,c,d]);return{submit:h,submitForm:h,reset:d.reset,wake:p,cancel:m,pauseUpload:d.pauseUpload,resumeUpload:d.resumeUpload,run:f.run,startedHere:l.startedHere,pending:l.busy||f.polling,upload:l.upload,error:l.startError??f.error}}function EE(){let[e,t]=(0,V.useState)();return(0,V.useEffect)(()=>{let e=!1;return yu().then(n=>{e||t(n)}),()=>{e=!0}},[]),e}function DE({workflow:e}){let{submitForm:t,run:n,pending:r,upload:i,pauseUpload:a,resumeUpload:o,error:s}=TE(e.name);return(0,U.jsxs)(`section`,{className:`flex flex-col gap-4`,children:[e.description===void 0?null:(0,U.jsx)(`p`,{className:`text-sm opacity-70`,children:e.description}),(0,U.jsxs)(lw,{onSubmit:e=>t(e),error:s,className:`flex flex-col gap-4`,children:[(0,U.jsx)(DT,{workflow:e}),(0,U.jsx)(uw,{pending:r,children:`Start`})]}),(0,U.jsx)(fw,{upload:i,onPause:a,onResume:o}),(0,U.jsx)(LT,{runId:n?.runId}),(0,U.jsx)(RT,{run:n}),n?.status===`completed`&&(0,U.jsx)(`pre`,{className:`overflow-x-auto rounded-md border p-4 text-xs`,children:JSON.stringify(n.output,null,2)})]})}function OE({name:e}){let t=EE(),{workflows:n,loading:r,error:i}=wT(),[a,o]=(0,V.useState)(),s=n.find(e=>e.name===a)??n[0];return(0,U.jsxs)(`main`,{className:`mx-auto flex max-w-2xl flex-col gap-6 p-8`,children:[(0,U.jsxs)(`header`,{className:`flex flex-col gap-1`,children:[(0,U.jsx)(`h1`,{className:`text-2xl font-medium`,children:e??t?.name??`Workflows`}),t?.greeting===void 0?null:(0,U.jsx)(`p`,{className:`text-sm opacity-70`,children:t.greeting})]}),i===void 0?null:(0,U.jsx)(`p`,{role:`alert`,className:`text-red-600`,children:i}),r&&(0,U.jsx)(`p`,{className:`text-sm opacity-70`,children:`Loading workflows…`}),!r&&i===void 0&&n.length===0&&(0,U.jsx)(`p`,{className:`text-sm opacity-70`,children:`This agent declares no workflows.`}),n.length>1&&(0,U.jsxs)(`label`,{className:`flex flex-col gap-1 text-sm`,children:[`Workflow`,(0,U.jsx)(`select`,{value:s?.name??``,onChange:e=>o(e.target.value),className:`rounded-md border px-3 py-2`,children:n.map(e=>(0,U.jsx)(`option`,{value:e.name,children:e.name},e.name))})]}),s&&(0,U.jsx)(DE,{workflow:s},s.name)]})}function kE(e={}){let t=IC(e.target);mu(e.name);let n=e.component;return LC(t,(0,V.createElement)(Uu,{value:e.theme},n?(0,V.createElement)(n):(0,V.createElement)(OE,{name:e.name})))}async function AE(e={mountClient:VC,mountPage:kE}){let t=await yu(),n=w({name:t.name});if(t.page===`static`){e.mountPage(n);return}e.mountClient(n)}AE();export{p as a,m as i,d as n,f as r,u as t};