@grackle-ai/web 0.119.0 → 0.120.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.html CHANGED
@@ -10,9 +10,9 @@
10
10
  <link rel="icon" type="image/x-icon" href="/favicon.ico" />
11
11
  <link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png" />
12
12
  <link rel="manifest" href="/manifest.json" />
13
- <script type="module" crossorigin src="/assets/index-Bw0E0QX1.js"></script>
13
+ <script type="module" crossorigin src="/assets/index-Cd2GfJNe.js"></script>
14
14
  <link rel="modulepreload" crossorigin href="/assets/dagview-tHPW3Rz3.js">
15
- <link rel="modulepreload" crossorigin href="/assets/grpc-dfCZg-0u.js">
15
+ <link rel="modulepreload" crossorigin href="/assets/grpc-3bXYIKhE.js">
16
16
  <link rel="modulepreload" crossorigin href="/assets/markdown-Yr3vTPLR.js">
17
17
  <link rel="stylesheet" crossorigin href="/assets/index-fl7Yu9Hf.css">
18
18
  </head>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@grackle-ai/web",
3
- "version": "0.119.0",
3
+ "version": "0.120.0",
4
4
  "description": "React web UI for the Grackle multi-agent coordination platform",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -38,8 +38,8 @@
38
38
  "rehype-prism-plus": "^2.0.0",
39
39
  "remark-gfm": "^4.0.0",
40
40
  "react-router": "^7.0.0",
41
- "@grackle-ai/common": "0.119.0",
42
- "@grackle-ai/web-components": "0.119.0"
41
+ "@grackle-ai/common": "0.120.0",
42
+ "@grackle-ai/web-components": "0.120.0"
43
43
  },
44
44
  "devDependencies": {
45
45
  "@rushstack/heft": "1.2.7",
@@ -1,77 +0,0 @@
1
- var Po=Object.defineProperty;var Eo=(e,t,n)=>t in e?Po(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var S=(e,t,n)=>Eo(e,typeof t!="symbol"?t+"":t,n);import{b as ce,j as Co}from"./dagview-tHPW3Rz3.js";const Zo={"--color-background-primary":"light-dark(#ffffff, #1a1a1a)","--color-background-secondary":"light-dark(#f5f5f5, #2d2d2d)","--color-background-tertiary":"light-dark(#e5e5e5, #404040)","--color-background-inverse":"light-dark(#1a1a1a, #ffffff)","--color-background-ghost":"light-dark(rgba(255,255,255,0), rgba(26,26,26,0))","--color-background-info":"light-dark(#eff6ff, #1e3a5f)","--color-background-danger":"light-dark(#fef2f2, #7f1d1d)","--color-background-success":"light-dark(#f0fdf4, #14532d)","--color-background-warning":"light-dark(#fefce8, #713f12)","--color-background-disabled":"light-dark(rgba(255,255,255,0.5), rgba(26,26,26,0.5))","--color-text-primary":"light-dark(#1f2937, #f3f4f6)","--color-text-secondary":"light-dark(#6b7280, #9ca3af)","--color-text-tertiary":"light-dark(#9ca3af, #6b7280)","--color-text-inverse":"light-dark(#f3f4f6, #1f2937)","--color-text-ghost":"light-dark(rgba(107,114,128,0.5), rgba(156,163,175,0.5))","--color-text-info":"light-dark(#1d4ed8, #60a5fa)","--color-text-danger":"light-dark(#b91c1c, #f87171)","--color-text-success":"light-dark(#15803d, #4ade80)","--color-text-warning":"light-dark(#a16207, #fbbf24)","--color-text-disabled":"light-dark(rgba(31,41,55,0.5), rgba(243,244,246,0.5))","--color-border-primary":"light-dark(#e5e7eb, #404040)","--color-border-secondary":"light-dark(#d1d5db, #525252)","--color-border-tertiary":"light-dark(#f3f4f6, #374151)","--color-border-inverse":"light-dark(rgba(255,255,255,0.3), rgba(0,0,0,0.3))","--color-border-ghost":"light-dark(rgba(229,231,235,0), rgba(64,64,64,0))","--color-border-info":"light-dark(#93c5fd, #1e40af)","--color-border-danger":"light-dark(#fca5a5, #991b1b)","--color-border-success":"light-dark(#86efac, #166534)","--color-border-warning":"light-dark(#fde047, #854d0e)","--color-border-disabled":"light-dark(rgba(229,231,235,0.5), rgba(64,64,64,0.5))","--color-ring-primary":"light-dark(#3b82f6, #60a5fa)","--color-ring-secondary":"light-dark(#6b7280, #9ca3af)","--color-ring-inverse":"light-dark(#ffffff, #1f2937)","--color-ring-info":"light-dark(#2563eb, #3b82f6)","--color-ring-danger":"light-dark(#dc2626, #ef4444)","--color-ring-success":"light-dark(#16a34a, #22c55e)","--color-ring-warning":"light-dark(#ca8a04, #eab308)","--font-sans":"system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif","--font-mono":"ui-monospace, 'SF Mono', Monaco, 'Cascadia Code', monospace","--font-weight-normal":"400","--font-weight-medium":"500","--font-weight-semibold":"600","--font-weight-bold":"700","--font-text-xs-size":"0.75rem","--font-text-sm-size":"0.875rem","--font-text-md-size":"1rem","--font-text-lg-size":"1.125rem","--font-heading-xs-size":"0.75rem","--font-heading-sm-size":"0.875rem","--font-heading-md-size":"1rem","--font-heading-lg-size":"1.25rem","--font-heading-xl-size":"1.5rem","--font-heading-2xl-size":"1.875rem","--font-heading-3xl-size":"2.25rem","--font-text-xs-line-height":"1.4","--font-text-sm-line-height":"1.4","--font-text-md-line-height":"1.5","--font-text-lg-line-height":"1.5","--font-heading-xs-line-height":"1.4","--font-heading-sm-line-height":"1.4","--font-heading-md-line-height":"1.4","--font-heading-lg-line-height":"1.3","--font-heading-xl-line-height":"1.25","--font-heading-2xl-line-height":"1.2","--font-heading-3xl-line-height":"1.1","--border-radius-xs":"2px","--border-radius-sm":"4px","--border-radius-md":"6px","--border-radius-lg":"8px","--border-radius-xl":"12px","--border-radius-full":"9999px","--border-width-regular":"1px","--shadow-hairline":"0 1px 2px 0 rgba(0, 0, 0, 0.05)","--shadow-sm":"0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px -1px rgba(0, 0, 0, 0.1)","--shadow-md":"0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1)","--shadow-lg":"0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1)"},Oo={"--color-background-primary":"--bg-base","--color-background-secondary":"--bg-surface","--color-background-tertiary":"--bg-elevated","--color-text-primary":"--text-primary","--color-text-secondary":"--text-secondary","--color-text-tertiary":"--text-tertiary","--color-border-primary":"--border-primary","--color-border-secondary":"--border-subtle","--font-sans":"--font-sans","--font-mono":"--font-mono","--border-radius-sm":"--radius-sm","--border-radius-md":"--radius-md","--border-radius-lg":"--radius-lg","--border-radius-full":"--radius-full"};function jt(){const e={...Zo};if(typeof window>"u"||typeof document>"u")return e;const t=window.getComputedStyle(document.documentElement),n=e;for(const[o,r]of Object.entries(Oo)){const s=t.getPropertyValue(r).trim();s&&(n[o]=s)}return e}function f(e,t,n){function o(a,c){if(a._zod||Object.defineProperty(a,"_zod",{value:{def:c,constr:i,traits:new Set},enumerable:!1}),a._zod.traits.has(e))return;a._zod.traits.add(e),t(a,c);const u=i.prototype,h=Object.keys(u);for(let m=0;m<h.length;m++){const g=h[m];g in a||(a[g]=u[g].bind(a))}}const r=(n==null?void 0:n.Parent)??Object;class s extends r{}Object.defineProperty(s,"name",{value:e});function i(a){var c;const u=n!=null&&n.Parent?new s:this;o(u,a),(c=u._zod).deferred??(c.deferred=[]);for(const h of u._zod.deferred)h();return u}return Object.defineProperty(i,"init",{value:o}),Object.defineProperty(i,Symbol.hasInstance,{value:a=>{var c,u;return n!=null&&n.Parent&&a instanceof n.Parent?!0:(u=(c=a==null?void 0:a._zod)==null?void 0:c.traits)==null?void 0:u.has(e)}}),Object.defineProperty(i,"name",{value:e}),i}class be extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class hn extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}}const fn={};function ue(e){return fn}function mn(e){const t=Object.values(e).filter(o=>typeof o=="number");return Object.entries(e).filter(([o,r])=>t.indexOf(+o)===-1).map(([o,r])=>r)}function st(e,t){return typeof t=="bigint"?t.toString():t}function Ke(e){return{get value(){{const t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function dt(e){return e==null}function pt(e){const t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}function No(e,t){const n=(e.toString().split(".")[1]||"").length,o=t.toString();let r=(o.split(".")[1]||"").length;if(r===0&&/\d?e-\d?/.test(o)){const c=o.match(/\d?e-(\d?)/);c!=null&&c[1]&&(r=Number.parseInt(c[1]))}const s=n>r?n:r,i=Number.parseInt(e.toFixed(s).replace(".","")),a=Number.parseInt(t.toFixed(s).replace(".",""));return i%a/10**s}const Dt=Symbol("evaluating");function I(e,t,n){let o;Object.defineProperty(e,t,{get(){if(o!==Dt)return o===void 0&&(o=Dt,o=n()),o},set(r){Object.defineProperty(e,t,{value:r})},configurable:!0})}function me(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function de(...e){const t={};for(const n of e){const o=Object.getOwnPropertyDescriptors(n);Object.assign(t,o)}return Object.defineProperties({},t)}function Ut(e){return JSON.stringify(e)}function qo(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}const gn="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function Ie(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}const Mo=Ke(()=>{var e;if(typeof navigator<"u"&&((e=navigator==null?void 0:navigator.userAgent)!=null&&e.includes("Cloudflare")))return!1;try{const t=Function;return new t(""),!0}catch{return!1}});function ve(e){if(Ie(e)===!1)return!1;const t=e.constructor;if(t===void 0||typeof t!="function")return!0;const n=t.prototype;return!(Ie(n)===!1||Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")===!1)}function _n(e){return ve(e)?{...e}:Array.isArray(e)?[...e]:e}const Ao=new Set(["string","number","symbol"]);function ye(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function pe(e,t,n){const o=new e._zod.constr(t??e._zod.def);return(!t||n!=null&&n.parent)&&(o._zod.parent=e),o}function b(e){const t=e;if(!t)return{};if(typeof t=="string")return{error:()=>t};if((t==null?void 0:t.message)!==void 0){if((t==null?void 0:t.error)!==void 0)throw new 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 Ho(e){return Object.keys(e).filter(t=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}const jo={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function Do(e,t){const n=e._zod.def,o=n.checks;if(o&&o.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");const s=de(e._zod.def,{get shape(){const i={};for(const a in t){if(!(a in n.shape))throw new Error(`Unrecognized key: "${a}"`);t[a]&&(i[a]=n.shape[a])}return me(this,"shape",i),i},checks:[]});return pe(e,s)}function Uo(e,t){const n=e._zod.def,o=n.checks;if(o&&o.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");const s=de(e._zod.def,{get shape(){const i={...e._zod.def.shape};for(const a in t){if(!(a in n.shape))throw new Error(`Unrecognized key: "${a}"`);t[a]&&delete i[a]}return me(this,"shape",i),i},checks:[]});return pe(e,s)}function Lo(e,t){if(!ve(t))throw new Error("Invalid input to extend: expected a plain object");const n=e._zod.def.checks;if(n&&n.length>0){const s=e._zod.def.shape;for(const i in t)if(Object.getOwnPropertyDescriptor(s,i)!==void 0)throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}const r=de(e._zod.def,{get shape(){const s={...e._zod.def.shape,...t};return me(this,"shape",s),s}});return pe(e,r)}function Fo(e,t){if(!ve(t))throw new Error("Invalid input to safeExtend: expected a plain object");const n=de(e._zod.def,{get shape(){const o={...e._zod.def.shape,...t};return me(this,"shape",o),o}});return pe(e,n)}function Jo(e,t){const n=de(e._zod.def,{get shape(){const o={...e._zod.def.shape,...t._zod.def.shape};return me(this,"shape",o),o},get catchall(){return t._zod.def.catchall},checks:[]});return pe(e,n)}function Vo(e,t,n){const r=t._zod.def.checks;if(r&&r.length>0)throw new Error(".partial() cannot be used on object schemas containing refinements");const i=de(t._zod.def,{get shape(){const a=t._zod.def.shape,c={...a};if(n)for(const u in n){if(!(u in a))throw new Error(`Unrecognized key: "${u}"`);n[u]&&(c[u]=e?new e({type:"optional",innerType:a[u]}):a[u])}else for(const u in a)c[u]=e?new e({type:"optional",innerType:a[u]}):a[u];return me(this,"shape",c),c},checks:[]});return pe(t,i)}function Bo(e,t,n){const o=de(t._zod.def,{get shape(){const r=t._zod.def.shape,s={...r};if(n)for(const i in n){if(!(i in s))throw new Error(`Unrecognized key: "${i}"`);n[i]&&(s[i]=new e({type:"nonoptional",innerType:r[i]}))}else for(const i in r)s[i]=new e({type:"nonoptional",innerType:r[i]});return me(this,"shape",s),s}});return pe(t,o)}function ge(e,t=0){var n;if(e.aborted===!0)return!0;for(let o=t;o<e.issues.length;o++)if(((n=e.issues[o])==null?void 0:n.continue)!==!0)return!0;return!1}function _e(e,t){return t.map(n=>{var o;return(o=n).path??(o.path=[]),n.path.unshift(e),n})}function je(e){return typeof e=="string"?e:e==null?void 0:e.message}function le(e,t,n){var r,s,i,a,c,u;const o={...e,path:e.path??[]};if(!e.message){const h=je((i=(s=(r=e.inst)==null?void 0:r._zod.def)==null?void 0:s.error)==null?void 0:i.call(s,e))??je((a=t==null?void 0:t.error)==null?void 0:a.call(t,e))??je((c=n.customError)==null?void 0:c.call(n,e))??je((u=n.localeError)==null?void 0:u.call(n,e))??"Invalid input";o.message=h}return delete o.inst,delete o.continue,t!=null&&t.reportInput||delete o.input,o}function ht(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function $e(...e){const[t,n,o]=e;return typeof t=="string"?{message:t,code:"custom",input:n,inst:o}:{...t}}const bn=(e,t)=>{e.name="$ZodError",Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:t,enumerable:!1}),e.message=JSON.stringify(t,st,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},vn=f("$ZodError",bn),yn=f("$ZodError",bn,{Parent:Error});function Wo(e,t=n=>n.message){const n={},o=[];for(const r of e.issues)r.path.length>0?(n[r.path[0]]=n[r.path[0]]||[],n[r.path[0]].push(t(r))):o.push(t(r));return{formErrors:o,fieldErrors:n}}function Ko(e,t=n=>n.message){const n={_errors:[]},o=r=>{for(const s of r.issues)if(s.code==="invalid_union"&&s.errors.length)s.errors.map(i=>o({issues:i}));else if(s.code==="invalid_key")o({issues:s.issues});else if(s.code==="invalid_element")o({issues:s.issues});else if(s.path.length===0)n._errors.push(t(s));else{let i=n,a=0;for(;a<s.path.length;){const c=s.path[a];a===s.path.length-1?(i[c]=i[c]||{_errors:[]},i[c]._errors.push(t(s))):i[c]=i[c]||{_errors:[]},i=i[c],a++}}};return o(e),n}const ft=e=>(t,n,o,r)=>{const s=o?Object.assign(o,{async:!1}):{async:!1},i=t._zod.run({value:n,issues:[]},s);if(i instanceof Promise)throw new be;if(i.issues.length){const a=new((r==null?void 0:r.Err)??e)(i.issues.map(c=>le(c,s,ue())));throw gn(a,r==null?void 0:r.callee),a}return i.value},mt=e=>async(t,n,o,r)=>{const s=o?Object.assign(o,{async:!0}):{async:!0};let i=t._zod.run({value:n,issues:[]},s);if(i instanceof Promise&&(i=await i),i.issues.length){const a=new((r==null?void 0:r.Err)??e)(i.issues.map(c=>le(c,s,ue())));throw gn(a,r==null?void 0:r.callee),a}return i.value},Ge=e=>(t,n,o)=>{const r=o?{...o,async:!1}:{async:!1},s=t._zod.run({value:n,issues:[]},r);if(s instanceof Promise)throw new be;return s.issues.length?{success:!1,error:new(e??vn)(s.issues.map(i=>le(i,r,ue())))}:{success:!0,data:s.value}},wn=Ge(yn),Qe=e=>async(t,n,o)=>{const r=o?Object.assign(o,{async:!0}):{async:!0};let s=t._zod.run({value:n,issues:[]},r);return s instanceof Promise&&(s=await s),s.issues.length?{success:!1,error:new e(s.issues.map(i=>le(i,r,ue())))}:{success:!0,data:s.value}},Go=Qe(yn),Qo=e=>(t,n,o)=>{const r=o?Object.assign(o,{direction:"backward"}):{direction:"backward"};return ft(e)(t,n,r)},Yo=e=>(t,n,o)=>ft(e)(t,n,o),Xo=e=>async(t,n,o)=>{const r=o?Object.assign(o,{direction:"backward"}):{direction:"backward"};return mt(e)(t,n,r)},er=e=>async(t,n,o)=>mt(e)(t,n,o),tr=e=>(t,n,o)=>{const r=o?Object.assign(o,{direction:"backward"}):{direction:"backward"};return Ge(e)(t,n,r)},nr=e=>(t,n,o)=>Ge(e)(t,n,o),or=e=>async(t,n,o)=>{const r=o?Object.assign(o,{direction:"backward"}):{direction:"backward"};return Qe(e)(t,n,r)},rr=e=>async(t,n,o)=>Qe(e)(t,n,o),sr=/^[cC][^\s-]{8,}$/,ir=/^[0-9a-z]+$/,ar=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,cr=/^[0-9a-vA-V]{20}$/,ur=/^[A-Za-z0-9]{27}$/,lr=/^[a-zA-Z0-9_-]{21}$/,dr=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,pr=/^([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})$/,Lt=e=>e?new 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)$/,hr=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,fr="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function mr(){return new RegExp(fr,"u")}const gr=/^(?:(?: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])$/,_r=/^(([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}|:))$/,br=/^((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])$/,vr=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,yr=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,kn=/^[A-Za-z0-9_-]*$/,wr=/^\+[1-9]\d{6,14}$/,Sn="(?:(?:\\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])))",kr=new RegExp(`^${Sn}$`);function zn(e){const t="(?:[01]\\d|2[0-3]):[0-5]\\d";return typeof e.precision=="number"?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function Sr(e){return new RegExp(`^${zn(e)}$`)}function zr(e){const t=zn({precision:e.precision}),n=["Z"];e.local&&n.push(""),e.offset&&n.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");const o=`${t}(?:${n.join("|")})`;return new RegExp(`^${Sn}T(?:${o})$`)}const Rr=e=>{const t=e?`[\\s\\S]{${(e==null?void 0:e.minimum)??0},${(e==null?void 0:e.maximum)??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)},Tr=/^-?\d+$/,Rn=/^-?\d+(?:\.\d+)?$/,xr=/^(?:true|false)$/i,Ir=/^null$/i,$r=/^undefined$/i,Pr=/^[^A-Z]*$/,Er=/^[^a-z]*$/,X=f("$ZodCheck",(e,t)=>{var n;e._zod??(e._zod={}),e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),Tn={number:"number",bigint:"bigint",object:"date"},xn=f("$ZodCheckLessThan",(e,t)=>{X.init(e,t);const n=Tn[typeof t.value];e._zod.onattach.push(o=>{const r=o._zod.bag,s=(t.inclusive?r.maximum:r.exclusiveMaximum)??Number.POSITIVE_INFINITY;t.value<s&&(t.inclusive?r.maximum=t.value:r.exclusiveMaximum=t.value)}),e._zod.check=o=>{(t.inclusive?o.value<=t.value:o.value<t.value)||o.issues.push({origin:n,code:"too_big",maximum:typeof t.value=="object"?t.value.getTime():t.value,input:o.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),In=f("$ZodCheckGreaterThan",(e,t)=>{X.init(e,t);const n=Tn[typeof t.value];e._zod.onattach.push(o=>{const r=o._zod.bag,s=(t.inclusive?r.minimum:r.exclusiveMinimum)??Number.NEGATIVE_INFINITY;t.value>s&&(t.inclusive?r.minimum=t.value:r.exclusiveMinimum=t.value)}),e._zod.check=o=>{(t.inclusive?o.value>=t.value:o.value>t.value)||o.issues.push({origin:n,code:"too_small",minimum:typeof t.value=="object"?t.value.getTime():t.value,input:o.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Cr=f("$ZodCheckMultipleOf",(e,t)=>{X.init(e,t),e._zod.onattach.push(n=>{var o;(o=n._zod.bag).multipleOf??(o.multipleOf=t.value)}),e._zod.check=n=>{if(typeof n.value!=typeof t.value)throw new Error("Cannot mix number and bigint in multiple_of check.");(typeof n.value=="bigint"?n.value%t.value===BigInt(0):No(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})}}),Zr=f("$ZodCheckNumberFormat",(e,t)=>{var i;X.init(e,t),t.format=t.format||"float64";const n=(i=t.format)==null?void 0:i.includes("int"),o=n?"int":"number",[r,s]=jo[t.format];e._zod.onattach.push(a=>{const c=a._zod.bag;c.format=t.format,c.minimum=r,c.maximum=s,n&&(c.pattern=Tr)}),e._zod.check=a=>{const c=a.value;if(n){if(!Number.isInteger(c)){a.issues.push({expected:o,format:t.format,code:"invalid_type",continue:!1,input:c,inst:e});return}if(!Number.isSafeInteger(c)){c>0?a.issues.push({input:c,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:o,inclusive:!0,continue:!t.abort}):a.issues.push({input:c,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:o,inclusive:!0,continue:!t.abort});return}}c<r&&a.issues.push({origin:"number",input:c,code:"too_small",minimum:r,inclusive:!0,inst:e,continue:!t.abort}),c>s&&a.issues.push({origin:"number",input:c,code:"too_big",maximum:s,inclusive:!0,inst:e,continue:!t.abort})}}),Or=f("$ZodCheckMaxLength",(e,t)=>{var n;X.init(e,t),(n=e._zod.def).when??(n.when=o=>{const r=o.value;return!dt(r)&&r.length!==void 0}),e._zod.onattach.push(o=>{const r=o._zod.bag.maximum??Number.POSITIVE_INFINITY;t.maximum<r&&(o._zod.bag.maximum=t.maximum)}),e._zod.check=o=>{const r=o.value;if(r.length<=t.maximum)return;const i=ht(r);o.issues.push({origin:i,code:"too_big",maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),Nr=f("$ZodCheckMinLength",(e,t)=>{var n;X.init(e,t),(n=e._zod.def).when??(n.when=o=>{const r=o.value;return!dt(r)&&r.length!==void 0}),e._zod.onattach.push(o=>{const r=o._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>r&&(o._zod.bag.minimum=t.minimum)}),e._zod.check=o=>{const r=o.value;if(r.length>=t.minimum)return;const i=ht(r);o.issues.push({origin:i,code:"too_small",minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),qr=f("$ZodCheckLengthEquals",(e,t)=>{var n;X.init(e,t),(n=e._zod.def).when??(n.when=o=>{const r=o.value;return!dt(r)&&r.length!==void 0}),e._zod.onattach.push(o=>{const r=o._zod.bag;r.minimum=t.length,r.maximum=t.length,r.length=t.length}),e._zod.check=o=>{const r=o.value,s=r.length;if(s===t.length)return;const i=ht(r),a=s>t.length;o.issues.push({origin:i,...a?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:o.value,inst:e,continue:!t.abort})}}),Ye=f("$ZodCheckStringFormat",(e,t)=>{var n,o;X.init(e,t),e._zod.onattach.push(r=>{const s=r._zod.bag;s.format=t.format,t.pattern&&(s.patterns??(s.patterns=new Set),s.patterns.add(t.pattern))}),t.pattern?(n=e._zod).check??(n.check=r=>{t.pattern.lastIndex=0,!t.pattern.test(r.value)&&r.issues.push({origin:"string",code:"invalid_format",format:t.format,input:r.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(o=e._zod).check??(o.check=()=>{})}),Mr=f("$ZodCheckRegex",(e,t)=>{Ye.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})}}),Ar=f("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=Pr),Ye.init(e,t)}),Hr=f("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=Er),Ye.init(e,t)}),jr=f("$ZodCheckIncludes",(e,t)=>{X.init(e,t);const n=ye(t.includes),o=new RegExp(typeof t.position=="number"?`^.{${t.position}}${n}`:n);t.pattern=o,e._zod.onattach.push(r=>{const s=r._zod.bag;s.patterns??(s.patterns=new Set),s.patterns.add(o)}),e._zod.check=r=>{r.value.includes(t.includes,t.position)||r.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:r.value,inst:e,continue:!t.abort})}}),Dr=f("$ZodCheckStartsWith",(e,t)=>{X.init(e,t);const n=new RegExp(`^${ye(t.prefix)}.*`);t.pattern??(t.pattern=n),e._zod.onattach.push(o=>{const r=o._zod.bag;r.patterns??(r.patterns=new Set),r.patterns.add(n)}),e._zod.check=o=>{o.value.startsWith(t.prefix)||o.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:o.value,inst:e,continue:!t.abort})}}),Ur=f("$ZodCheckEndsWith",(e,t)=>{X.init(e,t);const n=new RegExp(`.*${ye(t.suffix)}$`);t.pattern??(t.pattern=n),e._zod.onattach.push(o=>{const r=o._zod.bag;r.patterns??(r.patterns=new Set),r.patterns.add(n)}),e._zod.check=o=>{o.value.endsWith(t.suffix)||o.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:o.value,inst:e,continue:!t.abort})}}),Lr=f("$ZodCheckOverwrite",(e,t)=>{X.init(e,t),e._zod.check=n=>{n.value=t.tx(n.value)}});class Fr{constructor(t=[]){this.content=[],this.indent=0,this&&(this.args=t)}indented(t){this.indent+=1,t(this),this.indent-=1}write(t){if(typeof t=="function"){t(this,{execution:"sync"}),t(this,{execution:"async"});return}const o=t.split(`
2
- `).filter(i=>i),r=Math.min(...o.map(i=>i.length-i.trimStart().length)),s=o.map(i=>i.slice(r)).map(i=>" ".repeat(this.indent*2)+i);for(const i of s)this.content.push(i)}compile(){const t=Function,n=this==null?void 0:this.args,r=[...((this==null?void 0:this.content)??[""]).map(s=>` ${s}`)];return new t(...n,r.join(`
3
- `))}}const Jr={major:4,minor:3,patch:6},N=f("$ZodType",(e,t)=>{var r;var n;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=Jr;const o=[...e._zod.def.checks??[]];e._zod.traits.has("$ZodCheck")&&o.unshift(e);for(const s of o)for(const i of s._zod.onattach)i(e);if(o.length===0)(n=e._zod).deferred??(n.deferred=[]),(r=e._zod.deferred)==null||r.push(()=>{e._zod.run=e._zod.parse});else{const s=(a,c,u)=>{let h=ge(a),m;for(const g of c){if(g._zod.def.when){if(!g._zod.def.when(a))continue}else if(h)continue;const _=a.issues.length,v=g._zod.check(a);if(v instanceof Promise&&(u==null?void 0:u.async)===!1)throw new be;if(m||v instanceof Promise)m=(m??Promise.resolve()).then(async()=>{await v,a.issues.length!==_&&(h||(h=ge(a,_)))});else{if(a.issues.length===_)continue;h||(h=ge(a,_))}}return m?m.then(()=>a):a},i=(a,c,u)=>{if(ge(a))return a.aborted=!0,a;const h=s(c,o,u);if(h instanceof Promise){if(u.async===!1)throw new be;return h.then(m=>e._zod.parse(m,u))}return e._zod.parse(h,u)};e._zod.run=(a,c)=>{if(c.skipChecks)return e._zod.parse(a,c);if(c.direction==="backward"){const h=e._zod.parse({value:a.value,issues:[]},{...c,skipChecks:!0});return h instanceof Promise?h.then(m=>i(m,a,c)):i(h,a,c)}const u=e._zod.parse(a,c);if(u instanceof Promise){if(c.async===!1)throw new be;return u.then(h=>s(h,o,c))}return s(u,o,c)}}I(e,"~standard",()=>({validate:s=>{var i;try{const a=wn(e,s);return a.success?{value:a.data}:{issues:(i=a.error)==null?void 0:i.issues}}catch{return Go(e,s).then(c=>{var u;return c.success?{value:c.data}:{issues:(u=c.error)==null?void 0:u.issues}})}},vendor:"zod",version:1}))}),gt=f("$ZodString",(e,t)=>{var n;N.init(e,t),e._zod.pattern=[...((n=e==null?void 0:e._zod.bag)==null?void 0:n.patterns)??[]].pop()??Rr(e._zod.bag),e._zod.parse=(o,r)=>{if(t.coerce)try{o.value=String(o.value)}catch{}return typeof o.value=="string"||o.issues.push({expected:"string",code:"invalid_type",input:o.value,inst:e}),o}}),M=f("$ZodStringFormat",(e,t)=>{Ye.init(e,t),gt.init(e,t)}),Vr=f("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=pr),M.init(e,t)}),Br=f("$ZodUUID",(e,t)=>{if(t.version){const o={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(o===void 0)throw new Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=Lt(o))}else t.pattern??(t.pattern=Lt());M.init(e,t)}),Wr=f("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=hr),M.init(e,t)}),Kr=f("$ZodURL",(e,t)=>{M.init(e,t),e._zod.check=n=>{try{const o=n.value.trim(),r=new URL(o);t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(r.hostname)||n.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:t.hostname.source,input:n.value,inst:e,continue:!t.abort})),t.protocol&&(t.protocol.lastIndex=0,t.protocol.test(r.protocol.endsWith(":")?r.protocol.slice(0,-1):r.protocol)||n.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort})),t.normalize?n.value=r.href:n.value=o;return}catch{n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort})}}}),Gr=f("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=mr()),M.init(e,t)}),Qr=f("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=lr),M.init(e,t)}),Yr=f("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=sr),M.init(e,t)}),Xr=f("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=ir),M.init(e,t)}),es=f("$ZodULID",(e,t)=>{t.pattern??(t.pattern=ar),M.init(e,t)}),ts=f("$ZodXID",(e,t)=>{t.pattern??(t.pattern=cr),M.init(e,t)}),ns=f("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=ur),M.init(e,t)}),os=f("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=zr(t)),M.init(e,t)}),rs=f("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=kr),M.init(e,t)}),ss=f("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=Sr(t)),M.init(e,t)}),is=f("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=dr),M.init(e,t)}),as=f("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=gr),M.init(e,t),e._zod.bag.format="ipv4"}),cs=f("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=_r),M.init(e,t),e._zod.bag.format="ipv6",e._zod.check=n=>{try{new URL(`http://[${n.value}]`)}catch{n.issues.push({code:"invalid_format",format:"ipv6",input:n.value,inst:e,continue:!t.abort})}}}),us=f("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=br),M.init(e,t)}),ls=f("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=vr),M.init(e,t),e._zod.check=n=>{const o=n.value.split("/");try{if(o.length!==2)throw new Error;const[r,s]=o;if(!s)throw new Error;const i=Number(s);if(`${i}`!==s)throw new Error;if(i<0||i>128)throw new Error;new URL(`http://[${r}]`)}catch{n.issues.push({code:"invalid_format",format:"cidrv6",input:n.value,inst:e,continue:!t.abort})}}});function $n(e){if(e==="")return!0;if(e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}const ds=f("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=yr),M.init(e,t),e._zod.bag.contentEncoding="base64",e._zod.check=n=>{$n(n.value)||n.issues.push({code:"invalid_format",format:"base64",input:n.value,inst:e,continue:!t.abort})}});function ps(e){if(!kn.test(e))return!1;const t=e.replace(/[-_]/g,o=>o==="-"?"+":"/"),n=t.padEnd(Math.ceil(t.length/4)*4,"=");return $n(n)}const hs=f("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=kn),M.init(e,t),e._zod.bag.contentEncoding="base64url",e._zod.check=n=>{ps(n.value)||n.issues.push({code:"invalid_format",format:"base64url",input:n.value,inst:e,continue:!t.abort})}}),fs=f("$ZodE164",(e,t)=>{t.pattern??(t.pattern=wr),M.init(e,t)});function ms(e,t=null){try{const n=e.split(".");if(n.length!==3)return!1;const[o]=n;if(!o)return!1;const r=JSON.parse(atob(o));return!("typ"in r&&(r==null?void 0:r.typ)!=="JWT"||!r.alg||t&&(!("alg"in r)||r.alg!==t))}catch{return!1}}const gs=f("$ZodJWT",(e,t)=>{M.init(e,t),e._zod.check=n=>{ms(n.value,t.alg)||n.issues.push({code:"invalid_format",format:"jwt",input:n.value,inst:e,continue:!t.abort})}}),Pn=f("$ZodNumber",(e,t)=>{N.init(e,t),e._zod.pattern=e._zod.bag.pattern??Rn,e._zod.parse=(n,o)=>{if(t.coerce)try{n.value=Number(n.value)}catch{}const r=n.value;if(typeof r=="number"&&!Number.isNaN(r)&&Number.isFinite(r))return n;const s=typeof r=="number"?Number.isNaN(r)?"NaN":Number.isFinite(r)?void 0:"Infinity":void 0;return n.issues.push({expected:"number",code:"invalid_type",input:r,inst:e,...s?{received:s}:{}}),n}}),_s=f("$ZodNumberFormat",(e,t)=>{Zr.init(e,t),Pn.init(e,t)}),bs=f("$ZodBoolean",(e,t)=>{N.init(e,t),e._zod.pattern=xr,e._zod.parse=(n,o)=>{if(t.coerce)try{n.value=!!n.value}catch{}const r=n.value;return typeof r=="boolean"||n.issues.push({expected:"boolean",code:"invalid_type",input:r,inst:e}),n}}),vs=f("$ZodUndefined",(e,t)=>{N.init(e,t),e._zod.pattern=$r,e._zod.values=new Set([void 0]),e._zod.optin="optional",e._zod.optout="optional",e._zod.parse=(n,o)=>{const r=n.value;return typeof r>"u"||n.issues.push({expected:"undefined",code:"invalid_type",input:r,inst:e}),n}}),ys=f("$ZodNull",(e,t)=>{N.init(e,t),e._zod.pattern=Ir,e._zod.values=new Set([null]),e._zod.parse=(n,o)=>{const r=n.value;return r===null||n.issues.push({expected:"null",code:"invalid_type",input:r,inst:e}),n}}),ws=f("$ZodUnknown",(e,t)=>{N.init(e,t),e._zod.parse=n=>n}),ks=f("$ZodNever",(e,t)=>{N.init(e,t),e._zod.parse=(n,o)=>(n.issues.push({expected:"never",code:"invalid_type",input:n.value,inst:e}),n)});function Ft(e,t,n){e.issues.length&&t.issues.push(..._e(n,e.issues)),t.value[n]=e.value}const Ss=f("$ZodArray",(e,t)=>{N.init(e,t),e._zod.parse=(n,o)=>{const r=n.value;if(!Array.isArray(r))return n.issues.push({expected:"array",code:"invalid_type",input:r,inst:e}),n;n.value=Array(r.length);const s=[];for(let i=0;i<r.length;i++){const a=r[i],c=t.element._zod.run({value:a,issues:[]},o);c instanceof Promise?s.push(c.then(u=>Ft(u,n,i))):Ft(c,n,i)}return s.length?Promise.all(s).then(()=>n):n}});function Fe(e,t,n,o,r){if(e.issues.length){if(r&&!(n in o))return;t.issues.push(..._e(n,e.issues))}e.value===void 0?n in o&&(t.value[n]=void 0):t.value[n]=e.value}function En(e){var o,r,s,i;const t=Object.keys(e.shape);for(const a of t)if(!((i=(s=(r=(o=e.shape)==null?void 0:o[a])==null?void 0:r._zod)==null?void 0:s.traits)!=null&&i.has("$ZodType")))throw new Error(`Invalid element at key "${a}": expected a Zod schema`);const n=Ho(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(n)}}function Cn(e,t,n,o,r,s){const i=[],a=r.keySet,c=r.catchall._zod,u=c.def.type,h=c.optout==="optional";for(const m in t){if(a.has(m))continue;if(u==="never"){i.push(m);continue}const g=c.run({value:t[m],issues:[]},o);g instanceof Promise?e.push(g.then(_=>Fe(_,n,m,t,h))):Fe(g,n,m,t,h)}return i.length&&n.issues.push({code:"unrecognized_keys",keys:i,input:t,inst:s}),e.length?Promise.all(e).then(()=>n):n}const zs=f("$ZodObject",(e,t)=>{N.init(e,t);const n=Object.getOwnPropertyDescriptor(t,"shape");if(!(n!=null&&n.get)){const a=t.shape;Object.defineProperty(t,"shape",{get:()=>{const c={...a};return Object.defineProperty(t,"shape",{value:c}),c}})}const o=Ke(()=>En(t));I(e._zod,"propValues",()=>{const a=t.shape,c={};for(const u in a){const h=a[u]._zod;if(h.values){c[u]??(c[u]=new Set);for(const m of h.values)c[u].add(m)}}return c});const r=Ie,s=t.catchall;let i;e._zod.parse=(a,c)=>{i??(i=o.value);const u=a.value;if(!r(u))return a.issues.push({expected:"object",code:"invalid_type",input:u,inst:e}),a;a.value={};const h=[],m=i.shape;for(const g of i.keys){const _=m[g],v=_._zod.optout==="optional",y=_._zod.run({value:u[g],issues:[]},c);y instanceof Promise?h.push(y.then(x=>Fe(x,a,g,u,v))):Fe(y,a,g,u,v)}return s?Cn(h,u,a,c,o.value,e):h.length?Promise.all(h).then(()=>a):a}}),Rs=f("$ZodObjectJIT",(e,t)=>{zs.init(e,t);const n=e._zod.parse,o=Ke(()=>En(t)),r=g=>{var V;const _=new Fr(["shape","payload","ctx"]),v=o.value,y=K=>{const D=Ut(K);return`shape[${D}]._zod.run({ value: input[${D}], issues: [] }, ctx)`};_.write("const input = payload.value;");const x=Object.create(null);let L=0;for(const K of v.keys)x[K]=`key_${L++}`;_.write("const newResult = {};");for(const K of v.keys){const D=x[K],T=Ut(K),O=g[K],ee=((V=O==null?void 0:O._zod)==null?void 0:V.optout)==="optional";_.write(`const ${D} = ${y(K)};`),ee?_.write(`
4
- if (${D}.issues.length) {
5
- if (${T} in input) {
6
- payload.issues = payload.issues.concat(${D}.issues.map(iss => ({
7
- ...iss,
8
- path: iss.path ? [${T}, ...iss.path] : [${T}]
9
- })));
10
- }
11
- }
12
-
13
- if (${D}.value === undefined) {
14
- if (${T} in input) {
15
- newResult[${T}] = undefined;
16
- }
17
- } else {
18
- newResult[${T}] = ${D}.value;
19
- }
20
-
21
- `):_.write(`
22
- if (${D}.issues.length) {
23
- payload.issues = payload.issues.concat(${D}.issues.map(iss => ({
24
- ...iss,
25
- path: iss.path ? [${T}, ...iss.path] : [${T}]
26
- })));
27
- }
28
-
29
- if (${D}.value === undefined) {
30
- if (${T} in input) {
31
- newResult[${T}] = undefined;
32
- }
33
- } else {
34
- newResult[${T}] = ${D}.value;
35
- }
36
-
37
- `)}_.write("payload.value = newResult;"),_.write("return payload;");const C=_.compile();return(K,D)=>C(g,K,D)};let s;const i=Ie,a=!fn.jitless,u=a&&Mo.value,h=t.catchall;let m;e._zod.parse=(g,_)=>{m??(m=o.value);const v=g.value;return i(v)?a&&u&&(_==null?void 0:_.async)===!1&&_.jitless!==!0?(s||(s=r(t.shape)),g=s(g,_),h?Cn([],v,g,_,m,e):g):n(g,_):(g.issues.push({expected:"object",code:"invalid_type",input:v,inst:e}),g)}});function Jt(e,t,n,o){for(const s of e)if(s.issues.length===0)return t.value=s.value,t;const r=e.filter(s=>!ge(s));return r.length===1?(t.value=r[0].value,r[0]):(t.issues.push({code:"invalid_union",input:t.value,inst:n,errors:e.map(s=>s.issues.map(i=>le(i,o,ue())))}),t)}const Zn=f("$ZodUnion",(e,t)=>{N.init(e,t),I(e._zod,"optin",()=>t.options.some(r=>r._zod.optin==="optional")?"optional":void 0),I(e._zod,"optout",()=>t.options.some(r=>r._zod.optout==="optional")?"optional":void 0),I(e._zod,"values",()=>{if(t.options.every(r=>r._zod.values))return new Set(t.options.flatMap(r=>Array.from(r._zod.values)))}),I(e._zod,"pattern",()=>{if(t.options.every(r=>r._zod.pattern)){const r=t.options.map(s=>s._zod.pattern);return new RegExp(`^(${r.map(s=>pt(s.source)).join("|")})$`)}});const n=t.options.length===1,o=t.options[0]._zod.run;e._zod.parse=(r,s)=>{if(n)return o(r,s);let i=!1;const a=[];for(const c of t.options){const u=c._zod.run({value:r.value,issues:[]},s);if(u instanceof Promise)a.push(u),i=!0;else{if(u.issues.length===0)return u;a.push(u)}}return i?Promise.all(a).then(c=>Jt(c,r,e,s)):Jt(a,r,e,s)}}),Ts=f("$ZodDiscriminatedUnion",(e,t)=>{t.inclusive=!1,Zn.init(e,t);const n=e._zod.parse;I(e._zod,"propValues",()=>{const r={};for(const s of t.options){const i=s._zod.propValues;if(!i||Object.keys(i).length===0)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(s)}"`);for(const[a,c]of Object.entries(i)){r[a]||(r[a]=new Set);for(const u of c)r[a].add(u)}}return r});const o=Ke(()=>{var i;const r=t.options,s=new Map;for(const a of r){const c=(i=a._zod.propValues)==null?void 0:i[t.discriminator];if(!c||c.size===0)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(a)}"`);for(const u of c){if(s.has(u))throw new Error(`Duplicate discriminator value "${String(u)}"`);s.set(u,a)}}return s});e._zod.parse=(r,s)=>{const i=r.value;if(!Ie(i))return r.issues.push({code:"invalid_type",expected:"object",input:i,inst:e}),r;const a=o.value.get(i==null?void 0:i[t.discriminator]);return a?a._zod.run(r,s):t.unionFallback?n(r,s):(r.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:t.discriminator,input:i,path:[t.discriminator],inst:e}),r)}}),xs=f("$ZodIntersection",(e,t)=>{N.init(e,t),e._zod.parse=(n,o)=>{const r=n.value,s=t.left._zod.run({value:r,issues:[]},o),i=t.right._zod.run({value:r,issues:[]},o);return s instanceof Promise||i instanceof Promise?Promise.all([s,i]).then(([c,u])=>Vt(n,c,u)):Vt(n,s,i)}});function it(e,t){if(e===t)return{valid:!0,data:e};if(e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(ve(e)&&ve(t)){const n=Object.keys(t),o=Object.keys(e).filter(s=>n.indexOf(s)!==-1),r={...e,...t};for(const s of o){const i=it(e[s],t[s]);if(!i.valid)return{valid:!1,mergeErrorPath:[s,...i.mergeErrorPath]};r[s]=i.data}return{valid:!0,data:r}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};const n=[];for(let o=0;o<e.length;o++){const r=e[o],s=t[o],i=it(r,s);if(!i.valid)return{valid:!1,mergeErrorPath:[o,...i.mergeErrorPath]};n.push(i.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function Vt(e,t,n){const o=new Map;let r;for(const a of t.issues)if(a.code==="unrecognized_keys"){r??(r=a);for(const c of a.keys)o.has(c)||o.set(c,{}),o.get(c).l=!0}else e.issues.push(a);for(const a of n.issues)if(a.code==="unrecognized_keys")for(const c of a.keys)o.has(c)||o.set(c,{}),o.get(c).r=!0;else e.issues.push(a);const s=[...o].filter(([,a])=>a.l&&a.r).map(([a])=>a);if(s.length&&r&&e.issues.push({...r,keys:s}),ge(e))return e;const i=it(t.value,n.value);if(!i.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(i.mergeErrorPath)}`);return e.value=i.data,e}const Is=f("$ZodRecord",(e,t)=>{N.init(e,t),e._zod.parse=(n,o)=>{const r=n.value;if(!ve(r))return n.issues.push({expected:"record",code:"invalid_type",input:r,inst:e}),n;const s=[],i=t.keyType._zod.values;if(i){n.value={};const a=new Set;for(const u of i)if(typeof u=="string"||typeof u=="number"||typeof u=="symbol"){a.add(typeof u=="number"?u.toString():u);const h=t.valueType._zod.run({value:r[u],issues:[]},o);h instanceof Promise?s.push(h.then(m=>{m.issues.length&&n.issues.push(..._e(u,m.issues)),n.value[u]=m.value})):(h.issues.length&&n.issues.push(..._e(u,h.issues)),n.value[u]=h.value)}let c;for(const u in r)a.has(u)||(c=c??[],c.push(u));c&&c.length>0&&n.issues.push({code:"unrecognized_keys",input:r,inst:e,keys:c})}else{n.value={};for(const a of Reflect.ownKeys(r)){if(a==="__proto__")continue;let c=t.keyType._zod.run({value:a,issues:[]},o);if(c instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(typeof a=="string"&&Rn.test(a)&&c.issues.length){const m=t.keyType._zod.run({value:Number(a),issues:[]},o);if(m instanceof Promise)throw new Error("Async schemas not supported in object keys currently");m.issues.length===0&&(c=m)}if(c.issues.length){t.mode==="loose"?n.value[a]=r[a]:n.issues.push({code:"invalid_key",origin:"record",issues:c.issues.map(m=>le(m,o,ue())),input:a,path:[a],inst:e});continue}const h=t.valueType._zod.run({value:r[a],issues:[]},o);h instanceof Promise?s.push(h.then(m=>{m.issues.length&&n.issues.push(..._e(a,m.issues)),n.value[c.value]=m.value})):(h.issues.length&&n.issues.push(..._e(a,h.issues)),n.value[c.value]=h.value)}}return s.length?Promise.all(s).then(()=>n):n}}),$s=f("$ZodEnum",(e,t)=>{N.init(e,t);const n=mn(t.entries),o=new Set(n);e._zod.values=o,e._zod.pattern=new RegExp(`^(${n.filter(r=>Ao.has(typeof r)).map(r=>typeof r=="string"?ye(r):r.toString()).join("|")})$`),e._zod.parse=(r,s)=>{const i=r.value;return o.has(i)||r.issues.push({code:"invalid_value",values:n,input:i,inst:e}),r}}),Ps=f("$ZodLiteral",(e,t)=>{if(N.init(e,t),t.values.length===0)throw new Error("Cannot create literal schema with no valid values");const n=new Set(t.values);e._zod.values=n,e._zod.pattern=new RegExp(`^(${t.values.map(o=>typeof o=="string"?ye(o):o?ye(o.toString()):String(o)).join("|")})$`),e._zod.parse=(o,r)=>{const s=o.value;return n.has(s)||o.issues.push({code:"invalid_value",values:t.values,input:s,inst:e}),o}}),Es=f("$ZodTransform",(e,t)=>{N.init(e,t),e._zod.parse=(n,o)=>{if(o.direction==="backward")throw new hn(e.constructor.name);const r=t.transform(n.value,n);if(o.async)return(r instanceof Promise?r:Promise.resolve(r)).then(i=>(n.value=i,n));if(r instanceof Promise)throw new be;return n.value=r,n}});function Bt(e,t){return e.issues.length&&t===void 0?{issues:[],value:void 0}:e}const On=f("$ZodOptional",(e,t)=>{N.init(e,t),e._zod.optin="optional",e._zod.optout="optional",I(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),I(e._zod,"pattern",()=>{const n=t.innerType._zod.pattern;return n?new RegExp(`^(${pt(n.source)})?$`):void 0}),e._zod.parse=(n,o)=>{if(t.innerType._zod.optin==="optional"){const r=t.innerType._zod.run(n,o);return r instanceof Promise?r.then(s=>Bt(s,n.value)):Bt(r,n.value)}return n.value===void 0?n:t.innerType._zod.run(n,o)}}),Cs=f("$ZodExactOptional",(e,t)=>{On.init(e,t),I(e._zod,"values",()=>t.innerType._zod.values),I(e._zod,"pattern",()=>t.innerType._zod.pattern),e._zod.parse=(n,o)=>t.innerType._zod.run(n,o)}),Zs=f("$ZodNullable",(e,t)=>{N.init(e,t),I(e._zod,"optin",()=>t.innerType._zod.optin),I(e._zod,"optout",()=>t.innerType._zod.optout),I(e._zod,"pattern",()=>{const n=t.innerType._zod.pattern;return n?new RegExp(`^(${pt(n.source)}|null)$`):void 0}),I(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(n,o)=>n.value===null?n:t.innerType._zod.run(n,o)}),Os=f("$ZodDefault",(e,t)=>{N.init(e,t),e._zod.optin="optional",I(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,o)=>{if(o.direction==="backward")return t.innerType._zod.run(n,o);if(n.value===void 0)return n.value=t.defaultValue,n;const r=t.innerType._zod.run(n,o);return r instanceof Promise?r.then(s=>Wt(s,t)):Wt(r,t)}});function Wt(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}const Ns=f("$ZodPrefault",(e,t)=>{N.init(e,t),e._zod.optin="optional",I(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,o)=>(o.direction==="backward"||n.value===void 0&&(n.value=t.defaultValue),t.innerType._zod.run(n,o))}),qs=f("$ZodNonOptional",(e,t)=>{N.init(e,t),I(e._zod,"values",()=>{const n=t.innerType._zod.values;return n?new Set([...n].filter(o=>o!==void 0)):void 0}),e._zod.parse=(n,o)=>{const r=t.innerType._zod.run(n,o);return r instanceof Promise?r.then(s=>Kt(s,e)):Kt(r,e)}});function Kt(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:"invalid_type",expected:"nonoptional",input:e.value,inst:t}),e}const Ms=f("$ZodCatch",(e,t)=>{N.init(e,t),I(e._zod,"optin",()=>t.innerType._zod.optin),I(e._zod,"optout",()=>t.innerType._zod.optout),I(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,o)=>{if(o.direction==="backward")return t.innerType._zod.run(n,o);const r=t.innerType._zod.run(n,o);return r instanceof Promise?r.then(s=>(n.value=s.value,s.issues.length&&(n.value=t.catchValue({...n,error:{issues:s.issues.map(i=>le(i,o,ue()))},input:n.value}),n.issues=[]),n)):(n.value=r.value,r.issues.length&&(n.value=t.catchValue({...n,error:{issues:r.issues.map(s=>le(s,o,ue()))},input:n.value}),n.issues=[]),n)}}),As=f("$ZodPipe",(e,t)=>{N.init(e,t),I(e._zod,"values",()=>t.in._zod.values),I(e._zod,"optin",()=>t.in._zod.optin),I(e._zod,"optout",()=>t.out._zod.optout),I(e._zod,"propValues",()=>t.in._zod.propValues),e._zod.parse=(n,o)=>{if(o.direction==="backward"){const s=t.out._zod.run(n,o);return s instanceof Promise?s.then(i=>De(i,t.in,o)):De(s,t.in,o)}const r=t.in._zod.run(n,o);return r instanceof Promise?r.then(s=>De(s,t.out,o)):De(r,t.out,o)}});function De(e,t,n){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},n)}const Hs=f("$ZodReadonly",(e,t)=>{N.init(e,t),I(e._zod,"propValues",()=>t.innerType._zod.propValues),I(e._zod,"values",()=>t.innerType._zod.values),I(e._zod,"optin",()=>{var n,o;return(o=(n=t.innerType)==null?void 0:n._zod)==null?void 0:o.optin}),I(e._zod,"optout",()=>{var n,o;return(o=(n=t.innerType)==null?void 0:n._zod)==null?void 0:o.optout}),e._zod.parse=(n,o)=>{if(o.direction==="backward")return t.innerType._zod.run(n,o);const r=t.innerType._zod.run(n,o);return r instanceof Promise?r.then(Gt):Gt(r)}});function Gt(e){return e.value=Object.freeze(e.value),e}const js=f("$ZodCustom",(e,t)=>{X.init(e,t),N.init(e,t),e._zod.parse=(n,o)=>n,e._zod.check=n=>{const o=n.value,r=t.fn(o);if(r instanceof Promise)return r.then(s=>Qt(s,n,o,e));Qt(r,n,o,e)}});function Qt(e,t,n,o){if(!e){const r={code:"custom",input:n,inst:o,path:[...o._zod.def.path??[]],continue:!o._zod.def.abort};o._zod.def.params&&(r.params=o._zod.def.params),t.issues.push($e(r))}}var Yt;class Ds{constructor(){this._map=new WeakMap,this._idmap=new Map}add(t,...n){const o=n[0];return this._map.set(t,o),o&&typeof o=="object"&&"id"in o&&this._idmap.set(o.id,t),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(t){const n=this._map.get(t);return n&&typeof n=="object"&&"id"in n&&this._idmap.delete(n.id),this._map.delete(t),this}get(t){const n=t._zod.parent;if(n){const o={...this.get(n)??{}};delete o.id;const r={...o,...this._map.get(t)};return Object.keys(r).length?r:void 0}return this._map.get(t)}has(t){return this._map.has(t)}}function Us(){return new Ds}(Yt=globalThis).__zod_globalRegistry??(Yt.__zod_globalRegistry=Us());const xe=globalThis.__zod_globalRegistry;function Ls(e,t){return new e({type:"string",...b(t)})}function Fs(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...b(t)})}function Xt(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...b(t)})}function Js(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...b(t)})}function Vs(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...b(t)})}function Bs(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...b(t)})}function Ws(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...b(t)})}function Ks(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...b(t)})}function Gs(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...b(t)})}function Qs(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...b(t)})}function Ys(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...b(t)})}function Xs(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...b(t)})}function ei(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...b(t)})}function ti(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...b(t)})}function ni(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...b(t)})}function oi(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...b(t)})}function ri(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...b(t)})}function si(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...b(t)})}function ii(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...b(t)})}function ai(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...b(t)})}function ci(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...b(t)})}function ui(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...b(t)})}function li(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...b(t)})}function di(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...b(t)})}function pi(e,t){return new e({type:"string",format:"date",check:"string_format",...b(t)})}function hi(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...b(t)})}function fi(e,t){return new e({type:"string",format:"duration",check:"string_format",...b(t)})}function mi(e,t){return new e({type:"number",checks:[],...b(t)})}function gi(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...b(t)})}function _i(e,t){return new e({type:"boolean",...b(t)})}function bi(e,t){return new e({type:"undefined",...b(t)})}function vi(e,t){return new e({type:"null",...b(t)})}function yi(e){return new e({type:"unknown"})}function wi(e,t){return new e({type:"never",...b(t)})}function en(e,t){return new xn({check:"less_than",...b(t),value:e,inclusive:!1})}function ot(e,t){return new xn({check:"less_than",...b(t),value:e,inclusive:!0})}function tn(e,t){return new In({check:"greater_than",...b(t),value:e,inclusive:!1})}function rt(e,t){return new In({check:"greater_than",...b(t),value:e,inclusive:!0})}function nn(e,t){return new Cr({check:"multiple_of",...b(t),value:e})}function Nn(e,t){return new Or({check:"max_length",...b(t),maximum:e})}function Je(e,t){return new Nr({check:"min_length",...b(t),minimum:e})}function qn(e,t){return new qr({check:"length_equals",...b(t),length:e})}function ki(e,t){return new Mr({check:"string_format",format:"regex",...b(t),pattern:e})}function Si(e){return new Ar({check:"string_format",format:"lowercase",...b(e)})}function zi(e){return new Hr({check:"string_format",format:"uppercase",...b(e)})}function Ri(e,t){return new jr({check:"string_format",format:"includes",...b(t),includes:e})}function Ti(e,t){return new Dr({check:"string_format",format:"starts_with",...b(t),prefix:e})}function xi(e,t){return new Ur({check:"string_format",format:"ends_with",...b(t),suffix:e})}function ke(e){return new Lr({check:"overwrite",tx:e})}function Ii(e){return ke(t=>t.normalize(e))}function $i(){return ke(e=>e.trim())}function Pi(){return ke(e=>e.toLowerCase())}function Ei(){return ke(e=>e.toUpperCase())}function Ci(){return ke(e=>qo(e))}function Zi(e,t,n){return new e({type:"array",element:t,...b(n)})}function Oi(e,t,n){const o=b(n);return o.abort??(o.abort=!0),new e({type:"custom",check:"custom",fn:t,...o})}function Ni(e,t,n){return new e({type:"custom",check:"custom",fn:t,...b(n)})}function qi(e){const t=Mi(n=>(n.addIssue=o=>{if(typeof o=="string")n.issues.push($e(o,n.value,t._zod.def));else{const r=o;r.fatal&&(r.continue=!1),r.code??(r.code="custom"),r.input??(r.input=n.value),r.inst??(r.inst=t),r.continue??(r.continue=!t._zod.def.abort),n.issues.push($e(r))}},e(n.value,n)));return t}function Mi(e,t){const n=new X({check:"custom",...b(t)});return n._zod.check=e,n}function Mn(e){let t=(e==null?void 0:e.target)??"draft-2020-12";return t==="draft-4"&&(t="draft-04"),t==="draft-7"&&(t="draft-07"),{processors:e.processors??{},metadataRegistry:(e==null?void 0:e.metadata)??xe,target:t,unrepresentable:(e==null?void 0:e.unrepresentable)??"throw",override:(e==null?void 0:e.override)??(()=>{}),io:(e==null?void 0:e.io)??"output",counter:0,seen:new Map,cycles:(e==null?void 0:e.cycles)??"ref",reused:(e==null?void 0:e.reused)??"inline",external:(e==null?void 0:e.external)??void 0}}function j(e,t,n={path:[],schemaPath:[]}){var h,m;var o;const r=e._zod.def,s=t.seen.get(e);if(s)return s.count++,n.schemaPath.includes(e)&&(s.cycle=n.path),s.schema;const i={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,i);const a=(m=(h=e._zod).toJSONSchema)==null?void 0:m.call(h);if(a)i.schema=a;else{const g={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,i.schema,g);else{const v=i.schema,y=t.processors[r.type];if(!y)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${r.type}`);y(e,t,v,g)}const _=e._zod.parent;_&&(i.ref||(i.ref=_),j(_,t,g),t.seen.get(_).isParent=!0)}const c=t.metadataRegistry.get(e);return c&&Object.assign(i.schema,c),t.io==="input"&&G(e)&&(delete i.schema.examples,delete i.schema.default),t.io==="input"&&i.schema._prefault&&((o=i.schema).default??(o.default=i.schema._prefault)),delete i.schema._prefault,t.seen.get(e).schema}function An(e,t){var i,a,c,u;const n=e.seen.get(t);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");const o=new Map;for(const h of e.seen.entries()){const m=(i=e.metadataRegistry.get(h[0]))==null?void 0:i.id;if(m){const g=o.get(m);if(g&&g!==h[0])throw new Error(`Duplicate schema id "${m}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);o.set(m,h[0])}}const r=h=>{var y;const m=e.target==="draft-2020-12"?"$defs":"definitions";if(e.external){const x=(y=e.external.registry.get(h[0]))==null?void 0:y.id,L=e.external.uri??(V=>V);if(x)return{ref:L(x)};const C=h[1].defId??h[1].schema.id??`schema${e.counter++}`;return h[1].defId=C,{defId:C,ref:`${L("__shared")}#/${m}/${C}`}}if(h[1]===n)return{ref:"#"};const _=`#/${m}/`,v=h[1].schema.id??`__schema${e.counter++}`;return{defId:v,ref:_+v}},s=h=>{if(h[1].schema.$ref)return;const m=h[1],{ref:g,defId:_}=r(h);m.def={...m.schema},_&&(m.defId=_);const v=m.schema;for(const y in v)delete v[y];v.$ref=g};if(e.cycles==="throw")for(const h of e.seen.entries()){const m=h[1];if(m.cycle)throw new Error(`Cycle detected: #/${(a=m.cycle)==null?void 0:a.join("/")}/<root>
38
-
39
- Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(const h of e.seen.entries()){const m=h[1];if(t===h[0]){s(h);continue}if(e.external){const _=(c=e.external.registry.get(h[0]))==null?void 0:c.id;if(t!==h[0]&&_){s(h);continue}}if((u=e.metadataRegistry.get(h[0]))==null?void 0:u.id){s(h);continue}if(m.cycle){s(h);continue}if(m.count>1&&e.reused==="ref"){s(h);continue}}}function Hn(e,t){var i,a,c;const n=e.seen.get(t);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");const o=u=>{const h=e.seen.get(u);if(h.ref===null)return;const m=h.def??h.schema,g={...m},_=h.ref;if(h.ref=null,_){o(_);const y=e.seen.get(_),x=y.schema;if(x.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0")?(m.allOf=m.allOf??[],m.allOf.push(x)):Object.assign(m,x),Object.assign(m,g),u._zod.parent===_)for(const C in m)C==="$ref"||C==="allOf"||C in g||delete m[C];if(x.$ref&&y.def)for(const C in m)C==="$ref"||C==="allOf"||C in y.def&&JSON.stringify(m[C])===JSON.stringify(y.def[C])&&delete m[C]}const v=u._zod.parent;if(v&&v!==_){o(v);const y=e.seen.get(v);if(y!=null&&y.schema.$ref&&(m.$ref=y.schema.$ref,y.def))for(const x in m)x==="$ref"||x==="allOf"||x in y.def&&JSON.stringify(m[x])===JSON.stringify(y.def[x])&&delete m[x]}e.override({zodSchema:u,jsonSchema:m,path:h.path??[]})};for(const u of[...e.seen.entries()].reverse())o(u[0]);const r={};if(e.target==="draft-2020-12"?r.$schema="https://json-schema.org/draft/2020-12/schema":e.target==="draft-07"?r.$schema="http://json-schema.org/draft-07/schema#":e.target==="draft-04"?r.$schema="http://json-schema.org/draft-04/schema#":e.target,(i=e.external)!=null&&i.uri){const u=(a=e.external.registry.get(t))==null?void 0:a.id;if(!u)throw new Error("Schema is missing an `id` property");r.$id=e.external.uri(u)}Object.assign(r,n.def??n.schema);const s=((c=e.external)==null?void 0:c.defs)??{};for(const u of e.seen.entries()){const h=u[1];h.def&&h.defId&&(s[h.defId]=h.def)}e.external||Object.keys(s).length>0&&(e.target==="draft-2020-12"?r.$defs=s:r.definitions=s);try{const u=JSON.parse(JSON.stringify(r));return Object.defineProperty(u,"~standard",{value:{...t["~standard"],jsonSchema:{input:Ve(t,"input",e.processors),output:Ve(t,"output",e.processors)}},enumerable:!1,writable:!1}),u}catch{throw new Error("Error converting schema to JSON.")}}function G(e,t){const n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);const o=e._zod.def;if(o.type==="transform")return!0;if(o.type==="array")return G(o.element,n);if(o.type==="set")return G(o.valueType,n);if(o.type==="lazy")return G(o.getter(),n);if(o.type==="promise"||o.type==="optional"||o.type==="nonoptional"||o.type==="nullable"||o.type==="readonly"||o.type==="default"||o.type==="prefault")return G(o.innerType,n);if(o.type==="intersection")return G(o.left,n)||G(o.right,n);if(o.type==="record"||o.type==="map")return G(o.keyType,n)||G(o.valueType,n);if(o.type==="pipe")return G(o.in,n)||G(o.out,n);if(o.type==="object"){for(const r in o.shape)if(G(o.shape[r],n))return!0;return!1}if(o.type==="union"){for(const r of o.options)if(G(r,n))return!0;return!1}if(o.type==="tuple"){for(const r of o.items)if(G(r,n))return!0;return!!(o.rest&&G(o.rest,n))}return!1}const Ai=(e,t={})=>n=>{const o=Mn({...n,processors:t});return j(e,o),An(o,e),Hn(o,e)},Ve=(e,t,n={})=>o=>{const{libraryOptions:r,target:s}=o??{},i=Mn({...r??{},target:s,io:t,processors:n});return j(e,i),An(i,e),Hn(i,e)},Hi={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},ji=(e,t,n,o)=>{const r=n;r.type="string";const{minimum:s,maximum:i,format:a,patterns:c,contentEncoding:u}=e._zod.bag;if(typeof s=="number"&&(r.minLength=s),typeof i=="number"&&(r.maxLength=i),a&&(r.format=Hi[a]??a,r.format===""&&delete r.format,a==="time"&&delete r.format),u&&(r.contentEncoding=u),c&&c.size>0){const h=[...c];h.length===1?r.pattern=h[0].source:h.length>1&&(r.allOf=[...h.map(m=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:m.source}))])}},Di=(e,t,n,o)=>{const r=n,{minimum:s,maximum:i,format:a,multipleOf:c,exclusiveMaximum:u,exclusiveMinimum:h}=e._zod.bag;typeof a=="string"&&a.includes("int")?r.type="integer":r.type="number",typeof h=="number"&&(t.target==="draft-04"||t.target==="openapi-3.0"?(r.minimum=h,r.exclusiveMinimum=!0):r.exclusiveMinimum=h),typeof s=="number"&&(r.minimum=s,typeof h=="number"&&t.target!=="draft-04"&&(h>=s?delete r.minimum:delete r.exclusiveMinimum)),typeof u=="number"&&(t.target==="draft-04"||t.target==="openapi-3.0"?(r.maximum=u,r.exclusiveMaximum=!0):r.exclusiveMaximum=u),typeof i=="number"&&(r.maximum=i,typeof u=="number"&&t.target!=="draft-04"&&(u<=i?delete r.maximum:delete r.exclusiveMaximum)),typeof c=="number"&&(r.multipleOf=c)},Ui=(e,t,n,o)=>{n.type="boolean"},Li=(e,t,n,o)=>{t.target==="openapi-3.0"?(n.type="string",n.nullable=!0,n.enum=[null]):n.type="null"},Fi=(e,t,n,o)=>{if(t.unrepresentable==="throw")throw new Error("Undefined cannot be represented in JSON Schema")},Ji=(e,t,n,o)=>{n.not={}},Vi=(e,t,n,o)=>{},Bi=(e,t,n,o)=>{const r=e._zod.def,s=mn(r.entries);s.every(i=>typeof i=="number")&&(n.type="number"),s.every(i=>typeof i=="string")&&(n.type="string"),n.enum=s},Wi=(e,t,n,o)=>{const r=e._zod.def,s=[];for(const i of r.values)if(i===void 0){if(t.unrepresentable==="throw")throw new Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof i=="bigint"){if(t.unrepresentable==="throw")throw new Error("BigInt literals cannot be represented in JSON Schema");s.push(Number(i))}else s.push(i);if(s.length!==0)if(s.length===1){const i=s[0];n.type=i===null?"null":typeof i,t.target==="draft-04"||t.target==="openapi-3.0"?n.enum=[i]:n.const=i}else s.every(i=>typeof i=="number")&&(n.type="number"),s.every(i=>typeof i=="string")&&(n.type="string"),s.every(i=>typeof i=="boolean")&&(n.type="boolean"),s.every(i=>i===null)&&(n.type="null"),n.enum=s},Ki=(e,t,n,o)=>{if(t.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema")},Gi=(e,t,n,o)=>{if(t.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema")},Qi=(e,t,n,o)=>{const r=n,s=e._zod.def,{minimum:i,maximum:a}=e._zod.bag;typeof i=="number"&&(r.minItems=i),typeof a=="number"&&(r.maxItems=a),r.type="array",r.items=j(s.element,t,{...o,path:[...o.path,"items"]})},Yi=(e,t,n,o)=>{var u;const r=n,s=e._zod.def;r.type="object",r.properties={};const i=s.shape;for(const h in i)r.properties[h]=j(i[h],t,{...o,path:[...o.path,"properties",h]});const a=new Set(Object.keys(i)),c=new Set([...a].filter(h=>{const m=s.shape[h]._zod;return t.io==="input"?m.optin===void 0:m.optout===void 0}));c.size>0&&(r.required=Array.from(c)),((u=s.catchall)==null?void 0:u._zod.def.type)==="never"?r.additionalProperties=!1:s.catchall?s.catchall&&(r.additionalProperties=j(s.catchall,t,{...o,path:[...o.path,"additionalProperties"]})):t.io==="output"&&(r.additionalProperties=!1)},Xi=(e,t,n,o)=>{const r=e._zod.def,s=r.inclusive===!1,i=r.options.map((a,c)=>j(a,t,{...o,path:[...o.path,s?"oneOf":"anyOf",c]}));s?n.oneOf=i:n.anyOf=i},ea=(e,t,n,o)=>{const r=e._zod.def,s=j(r.left,t,{...o,path:[...o.path,"allOf",0]}),i=j(r.right,t,{...o,path:[...o.path,"allOf",1]}),a=u=>"allOf"in u&&Object.keys(u).length===1,c=[...a(s)?s.allOf:[s],...a(i)?i.allOf:[i]];n.allOf=c},ta=(e,t,n,o)=>{const r=n,s=e._zod.def;r.type="object";const i=s.keyType,a=i._zod.bag,c=a==null?void 0:a.patterns;if(s.mode==="loose"&&c&&c.size>0){const h=j(s.valueType,t,{...o,path:[...o.path,"patternProperties","*"]});r.patternProperties={};for(const m of c)r.patternProperties[m.source]=h}else(t.target==="draft-07"||t.target==="draft-2020-12")&&(r.propertyNames=j(s.keyType,t,{...o,path:[...o.path,"propertyNames"]})),r.additionalProperties=j(s.valueType,t,{...o,path:[...o.path,"additionalProperties"]});const u=i._zod.values;if(u){const h=[...u].filter(m=>typeof m=="string"||typeof m=="number");h.length>0&&(r.required=h)}},na=(e,t,n,o)=>{const r=e._zod.def,s=j(r.innerType,t,o),i=t.seen.get(e);t.target==="openapi-3.0"?(i.ref=r.innerType,n.nullable=!0):n.anyOf=[s,{type:"null"}]},oa=(e,t,n,o)=>{const r=e._zod.def;j(r.innerType,t,o);const s=t.seen.get(e);s.ref=r.innerType},ra=(e,t,n,o)=>{const r=e._zod.def;j(r.innerType,t,o);const s=t.seen.get(e);s.ref=r.innerType,n.default=JSON.parse(JSON.stringify(r.defaultValue))},sa=(e,t,n,o)=>{const r=e._zod.def;j(r.innerType,t,o);const s=t.seen.get(e);s.ref=r.innerType,t.io==="input"&&(n._prefault=JSON.parse(JSON.stringify(r.defaultValue)))},ia=(e,t,n,o)=>{const r=e._zod.def;j(r.innerType,t,o);const s=t.seen.get(e);s.ref=r.innerType;let i;try{i=r.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}n.default=i},aa=(e,t,n,o)=>{const r=e._zod.def,s=t.io==="input"?r.in._zod.def.type==="transform"?r.out:r.in:r.out;j(s,t,o);const i=t.seen.get(e);i.ref=s},ca=(e,t,n,o)=>{const r=e._zod.def;j(r.innerType,t,o);const s=t.seen.get(e);s.ref=r.innerType,n.readOnly=!0},jn=(e,t,n,o)=>{const r=e._zod.def;j(r.innerType,t,o);const s=t.seen.get(e);s.ref=r.innerType},ua=f("ZodISODateTime",(e,t)=>{os.init(e,t),H.init(e,t)});function Dn(e){return di(ua,e)}const la=f("ZodISODate",(e,t)=>{rs.init(e,t),H.init(e,t)});function da(e){return pi(la,e)}const pa=f("ZodISOTime",(e,t)=>{ss.init(e,t),H.init(e,t)});function ha(e){return hi(pa,e)}const fa=f("ZodISODuration",(e,t)=>{is.init(e,t),H.init(e,t)});function ma(e){return fi(fa,e)}const ga=(e,t)=>{vn.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:n=>Ko(e,n)},flatten:{value:n=>Wo(e,n)},addIssue:{value:n=>{e.issues.push(n),e.message=JSON.stringify(e.issues,st,2)}},addIssues:{value:n=>{e.issues.push(...n),e.message=JSON.stringify(e.issues,st,2)}},isEmpty:{get(){return e.issues.length===0}}})},oe=f("ZodError",ga,{Parent:Error}),_a=ft(oe),ba=mt(oe),va=Ge(oe),ya=Qe(oe),wa=Qo(oe),ka=Yo(oe),Sa=Xo(oe),za=er(oe),Ra=tr(oe),Ta=nr(oe),xa=or(oe),Ia=rr(oe),q=f("ZodType",(e,t)=>(N.init(e,t),Object.assign(e["~standard"],{jsonSchema:{input:Ve(e,"input"),output:Ve(e,"output")}}),e.toJSONSchema=Ai(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.check=(...n)=>e.clone(de(t,{checks:[...t.checks??[],...n.map(o=>typeof o=="function"?{_zod:{check:o,def:{check:"custom"},onattach:[]}}:o)]}),{parent:!0}),e.with=e.check,e.clone=(n,o)=>pe(e,n,o),e.brand=()=>e,e.register=((n,o)=>(n.add(e,o),e)),e.parse=(n,o)=>_a(e,n,o,{callee:e.parse}),e.safeParse=(n,o)=>va(e,n,o),e.parseAsync=async(n,o)=>ba(e,n,o,{callee:e.parseAsync}),e.safeParseAsync=async(n,o)=>ya(e,n,o),e.spa=e.safeParseAsync,e.encode=(n,o)=>wa(e,n,o),e.decode=(n,o)=>ka(e,n,o),e.encodeAsync=async(n,o)=>Sa(e,n,o),e.decodeAsync=async(n,o)=>za(e,n,o),e.safeEncode=(n,o)=>Ra(e,n,o),e.safeDecode=(n,o)=>Ta(e,n,o),e.safeEncodeAsync=async(n,o)=>xa(e,n,o),e.safeDecodeAsync=async(n,o)=>Ia(e,n,o),e.refine=(n,o)=>e.check(yc(n,o)),e.superRefine=n=>e.check(wc(n)),e.overwrite=n=>e.check(ke(n)),e.optional=()=>A(e),e.exactOptional=()=>ac(e),e.nullable=()=>sn(e),e.nullish=()=>A(sn(e)),e.nonoptional=n=>hc(e,n),e.array=()=>w(e),e.or=n=>z([e,n]),e.and=n=>_t(e,n),e.transform=n=>lt(e,Bn(n)),e.default=n=>lc(e,n),e.prefault=n=>pc(e,n),e.catch=n=>mc(e,n),e.pipe=n=>lt(e,n),e.readonly=()=>bc(e),e.describe=n=>{const o=e.clone();return xe.add(o,{description:n}),o},Object.defineProperty(e,"description",{get(){var n;return(n=xe.get(e))==null?void 0:n.description},configurable:!0}),e.meta=(...n)=>{if(n.length===0)return xe.get(e);const o=e.clone();return xe.add(o,n[0]),o},e.isOptional=()=>e.safeParse(void 0).success,e.isNullable=()=>e.safeParse(null).success,e.apply=n=>n(e),e)),Un=f("_ZodString",(e,t)=>{gt.init(e,t),q.init(e,t),e._zod.processJSONSchema=(o,r,s)=>ji(e,o,r);const n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,e.regex=(...o)=>e.check(ki(...o)),e.includes=(...o)=>e.check(Ri(...o)),e.startsWith=(...o)=>e.check(Ti(...o)),e.endsWith=(...o)=>e.check(xi(...o)),e.min=(...o)=>e.check(Je(...o)),e.max=(...o)=>e.check(Nn(...o)),e.length=(...o)=>e.check(qn(...o)),e.nonempty=(...o)=>e.check(Je(1,...o)),e.lowercase=o=>e.check(Si(o)),e.uppercase=o=>e.check(zi(o)),e.trim=()=>e.check($i()),e.normalize=(...o)=>e.check(Ii(...o)),e.toLowerCase=()=>e.check(Pi()),e.toUpperCase=()=>e.check(Ei()),e.slugify=()=>e.check(Ci())}),$a=f("ZodString",(e,t)=>{gt.init(e,t),Un.init(e,t),e.email=n=>e.check(Fs(Pa,n)),e.url=n=>e.check(Ks(Ea,n)),e.jwt=n=>e.check(li(Va,n)),e.emoji=n=>e.check(Gs(Ca,n)),e.guid=n=>e.check(Xt(on,n)),e.uuid=n=>e.check(Js(Ue,n)),e.uuidv4=n=>e.check(Vs(Ue,n)),e.uuidv6=n=>e.check(Bs(Ue,n)),e.uuidv7=n=>e.check(Ws(Ue,n)),e.nanoid=n=>e.check(Qs(Za,n)),e.guid=n=>e.check(Xt(on,n)),e.cuid=n=>e.check(Ys(Oa,n)),e.cuid2=n=>e.check(Xs(Na,n)),e.ulid=n=>e.check(ei(qa,n)),e.base64=n=>e.check(ai(La,n)),e.base64url=n=>e.check(ci(Fa,n)),e.xid=n=>e.check(ti(Ma,n)),e.ksuid=n=>e.check(ni(Aa,n)),e.ipv4=n=>e.check(oi(Ha,n)),e.ipv6=n=>e.check(ri(ja,n)),e.cidrv4=n=>e.check(si(Da,n)),e.cidrv6=n=>e.check(ii(Ua,n)),e.e164=n=>e.check(ui(Ja,n)),e.datetime=n=>e.check(Dn(n)),e.date=n=>e.check(da(n)),e.time=n=>e.check(ha(n)),e.duration=n=>e.check(ma(n))});function d(e){return Ls($a,e)}const H=f("ZodStringFormat",(e,t)=>{M.init(e,t),Un.init(e,t)}),Pa=f("ZodEmail",(e,t)=>{Wr.init(e,t),H.init(e,t)}),on=f("ZodGUID",(e,t)=>{Vr.init(e,t),H.init(e,t)}),Ue=f("ZodUUID",(e,t)=>{Br.init(e,t),H.init(e,t)}),Ea=f("ZodURL",(e,t)=>{Kr.init(e,t),H.init(e,t)}),Ca=f("ZodEmoji",(e,t)=>{Gr.init(e,t),H.init(e,t)}),Za=f("ZodNanoID",(e,t)=>{Qr.init(e,t),H.init(e,t)}),Oa=f("ZodCUID",(e,t)=>{Yr.init(e,t),H.init(e,t)}),Na=f("ZodCUID2",(e,t)=>{Xr.init(e,t),H.init(e,t)}),qa=f("ZodULID",(e,t)=>{es.init(e,t),H.init(e,t)}),Ma=f("ZodXID",(e,t)=>{ts.init(e,t),H.init(e,t)}),Aa=f("ZodKSUID",(e,t)=>{ns.init(e,t),H.init(e,t)}),Ha=f("ZodIPv4",(e,t)=>{as.init(e,t),H.init(e,t)}),ja=f("ZodIPv6",(e,t)=>{cs.init(e,t),H.init(e,t)}),Da=f("ZodCIDRv4",(e,t)=>{us.init(e,t),H.init(e,t)}),Ua=f("ZodCIDRv6",(e,t)=>{ls.init(e,t),H.init(e,t)}),La=f("ZodBase64",(e,t)=>{ds.init(e,t),H.init(e,t)}),Fa=f("ZodBase64URL",(e,t)=>{hs.init(e,t),H.init(e,t)}),Ja=f("ZodE164",(e,t)=>{fs.init(e,t),H.init(e,t)}),Va=f("ZodJWT",(e,t)=>{gs.init(e,t),H.init(e,t)}),Ln=f("ZodNumber",(e,t)=>{Pn.init(e,t),q.init(e,t),e._zod.processJSONSchema=(o,r,s)=>Di(e,o,r),e.gt=(o,r)=>e.check(tn(o,r)),e.gte=(o,r)=>e.check(rt(o,r)),e.min=(o,r)=>e.check(rt(o,r)),e.lt=(o,r)=>e.check(en(o,r)),e.lte=(o,r)=>e.check(ot(o,r)),e.max=(o,r)=>e.check(ot(o,r)),e.int=o=>e.check(rn(o)),e.safe=o=>e.check(rn(o)),e.positive=o=>e.check(tn(0,o)),e.nonnegative=o=>e.check(rt(0,o)),e.negative=o=>e.check(en(0,o)),e.nonpositive=o=>e.check(ot(0,o)),e.multipleOf=(o,r)=>e.check(nn(o,r)),e.step=(o,r)=>e.check(nn(o,r)),e.finite=()=>e;const n=e._zod.bag;e.minValue=Math.max(n.minimum??Number.NEGATIVE_INFINITY,n.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,e.maxValue=Math.min(n.maximum??Number.POSITIVE_INFINITY,n.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,e.isInt=(n.format??"").includes("int")||Number.isSafeInteger(n.multipleOf??.5),e.isFinite=!0,e.format=n.format??null});function k(e){return mi(Ln,e)}const Ba=f("ZodNumberFormat",(e,t)=>{_s.init(e,t),Ln.init(e,t)});function rn(e){return gi(Ba,e)}const Wa=f("ZodBoolean",(e,t)=>{bs.init(e,t),q.init(e,t),e._zod.processJSONSchema=(n,o,r)=>Ui(e,n,o)});function Z(e){return _i(Wa,e)}const Ka=f("ZodUndefined",(e,t)=>{vs.init(e,t),q.init(e,t),e._zod.processJSONSchema=(n,o,r)=>Fi(e,n)});function at(e){return bi(Ka,e)}const Ga=f("ZodNull",(e,t)=>{ys.init(e,t),q.init(e,t),e._zod.processJSONSchema=(n,o,r)=>Li(e,n,o)});function Qa(e){return vi(Ga,e)}const Ya=f("ZodUnknown",(e,t)=>{ws.init(e,t),q.init(e,t),e._zod.processJSONSchema=(n,o,r)=>Vi()});function E(){return yi(Ya)}const Xa=f("ZodNever",(e,t)=>{ks.init(e,t),q.init(e,t),e._zod.processJSONSchema=(n,o,r)=>Ji(e,n,o)});function ct(e){return wi(Xa,e)}const ec=f("ZodArray",(e,t)=>{Ss.init(e,t),q.init(e,t),e._zod.processJSONSchema=(n,o,r)=>Qi(e,n,o,r),e.element=t.element,e.min=(n,o)=>e.check(Je(n,o)),e.nonempty=n=>e.check(Je(1,n)),e.max=(n,o)=>e.check(Nn(n,o)),e.length=(n,o)=>e.check(qn(n,o)),e.unwrap=()=>e.element});function w(e,t){return Zi(ec,e,t)}const Fn=f("ZodObject",(e,t)=>{Rs.init(e,t),q.init(e,t),e._zod.processJSONSchema=(n,o,r)=>Yi(e,n,o,r),I(e,"shape",()=>t.shape),e.keyof=()=>te(Object.keys(e._zod.def.shape)),e.catchall=n=>e.clone({...e._zod.def,catchall:n}),e.passthrough=()=>e.clone({...e._zod.def,catchall:E()}),e.loose=()=>e.clone({...e._zod.def,catchall:E()}),e.strict=()=>e.clone({...e._zod.def,catchall:ct()}),e.strip=()=>e.clone({...e._zod.def,catchall:void 0}),e.extend=n=>Lo(e,n),e.safeExtend=n=>Fo(e,n),e.merge=n=>Jo(e,n),e.pick=n=>Do(e,n),e.omit=n=>Uo(e,n),e.partial=(...n)=>Vo(Wn,e,n[0]),e.required=(...n)=>Bo(Kn,e,n[0])});function p(e,t){const n={type:"object",shape:e??{},...b(t)};return new Fn(n)}function Y(e,t){return new Fn({type:"object",shape:e,catchall:E(),...b(t)})}const Jn=f("ZodUnion",(e,t)=>{Zn.init(e,t),q.init(e,t),e._zod.processJSONSchema=(n,o,r)=>Xi(e,n,o,r),e.options=t.options});function z(e,t){return new Jn({type:"union",options:e,...b(t)})}const tc=f("ZodDiscriminatedUnion",(e,t)=>{Jn.init(e,t),Ts.init(e,t)});function Vn(e,t,n){return new tc({type:"union",options:t,discriminator:e,...b(n)})}const nc=f("ZodIntersection",(e,t)=>{xs.init(e,t),q.init(e,t),e._zod.processJSONSchema=(n,o,r)=>ea(e,n,o,r)});function _t(e,t){return new nc({type:"intersection",left:e,right:t})}const oc=f("ZodRecord",(e,t)=>{Is.init(e,t),q.init(e,t),e._zod.processJSONSchema=(n,o,r)=>ta(e,n,o,r),e.keyType=t.keyType,e.valueType=t.valueType});function $(e,t,n){return new oc({type:"record",keyType:e,valueType:t,...b(n)})}const ut=f("ZodEnum",(e,t)=>{$s.init(e,t),q.init(e,t),e._zod.processJSONSchema=(o,r,s)=>Bi(e,o,r),e.enum=t.entries,e.options=Object.values(t.entries);const n=new Set(Object.keys(t.entries));e.extract=(o,r)=>{const s={};for(const i of o)if(n.has(i))s[i]=t.entries[i];else throw new Error(`Key ${i} not found in enum`);return new ut({...t,checks:[],...b(r),entries:s})},e.exclude=(o,r)=>{const s={...t.entries};for(const i of o)if(n.has(i))delete s[i];else throw new Error(`Key ${i} not found in enum`);return new ut({...t,checks:[],...b(r),entries:s})}});function te(e,t){const n=Array.isArray(e)?Object.fromEntries(e.map(o=>[o,o])):e;return new ut({type:"enum",entries:n,...b(t)})}const rc=f("ZodLiteral",(e,t)=>{Ps.init(e,t),q.init(e,t),e._zod.processJSONSchema=(n,o,r)=>Wi(e,n,o),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function l(e,t){return new rc({type:"literal",values:Array.isArray(e)?e:[e],...b(t)})}const sc=f("ZodTransform",(e,t)=>{Es.init(e,t),q.init(e,t),e._zod.processJSONSchema=(n,o,r)=>Gi(e,n),e._zod.parse=(n,o)=>{if(o.direction==="backward")throw new hn(e.constructor.name);n.addIssue=s=>{if(typeof s=="string")n.issues.push($e(s,n.value,t));else{const i=s;i.fatal&&(i.continue=!1),i.code??(i.code="custom"),i.input??(i.input=n.value),i.inst??(i.inst=e),n.issues.push($e(i))}};const r=t.transform(n.value,n);return r instanceof Promise?r.then(s=>(n.value=s,n)):(n.value=r,n)}});function Bn(e){return new sc({type:"transform",transform:e})}const Wn=f("ZodOptional",(e,t)=>{On.init(e,t),q.init(e,t),e._zod.processJSONSchema=(n,o,r)=>jn(e,n,o,r),e.unwrap=()=>e._zod.def.innerType});function A(e){return new Wn({type:"optional",innerType:e})}const ic=f("ZodExactOptional",(e,t)=>{Cs.init(e,t),q.init(e,t),e._zod.processJSONSchema=(n,o,r)=>jn(e,n,o,r),e.unwrap=()=>e._zod.def.innerType});function ac(e){return new ic({type:"optional",innerType:e})}const cc=f("ZodNullable",(e,t)=>{Zs.init(e,t),q.init(e,t),e._zod.processJSONSchema=(n,o,r)=>na(e,n,o,r),e.unwrap=()=>e._zod.def.innerType});function sn(e){return new cc({type:"nullable",innerType:e})}const uc=f("ZodDefault",(e,t)=>{Os.init(e,t),q.init(e,t),e._zod.processJSONSchema=(n,o,r)=>ra(e,n,o,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function lc(e,t){return new uc({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():_n(t)}})}const dc=f("ZodPrefault",(e,t)=>{Ns.init(e,t),q.init(e,t),e._zod.processJSONSchema=(n,o,r)=>sa(e,n,o,r),e.unwrap=()=>e._zod.def.innerType});function pc(e,t){return new dc({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():_n(t)}})}const Kn=f("ZodNonOptional",(e,t)=>{qs.init(e,t),q.init(e,t),e._zod.processJSONSchema=(n,o,r)=>oa(e,n,o,r),e.unwrap=()=>e._zod.def.innerType});function hc(e,t){return new Kn({type:"nonoptional",innerType:e,...b(t)})}const fc=f("ZodCatch",(e,t)=>{Ms.init(e,t),q.init(e,t),e._zod.processJSONSchema=(n,o,r)=>ia(e,n,o,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function mc(e,t){return new fc({type:"catch",innerType:e,catchValue:typeof t=="function"?t:()=>t})}const gc=f("ZodPipe",(e,t)=>{As.init(e,t),q.init(e,t),e._zod.processJSONSchema=(n,o,r)=>aa(e,n,o,r),e.in=t.in,e.out=t.out});function lt(e,t){return new gc({type:"pipe",in:e,out:t})}const _c=f("ZodReadonly",(e,t)=>{Hs.init(e,t),q.init(e,t),e._zod.processJSONSchema=(n,o,r)=>ca(e,n,o,r),e.unwrap=()=>e._zod.def.innerType});function bc(e){return new _c({type:"readonly",innerType:e})}const Gn=f("ZodCustom",(e,t)=>{js.init(e,t),q.init(e,t),e._zod.processJSONSchema=(n,o,r)=>Ki(e,n)});function vc(e,t){return Oi(Gn,e??(()=>!0),t)}function yc(e,t={}){return Ni(Gn,e,t)}function wc(e){return qi(e)}function Qn(e,t){return lt(Bn(e),t)}const fe="io.modelcontextprotocol/related-task",Xe="2.0",U=vc(e=>e!==null&&(typeof e=="object"||typeof e=="function")),Yn=z([d(),k().int()]),Xn=d();Y({ttl:k().optional(),pollInterval:k().optional()});const kc=p({ttl:k().optional()}),Sc=p({taskId:d()}),bt=Y({progressToken:Yn.optional(),[fe]:Sc.optional()}),ne=p({_meta:bt.optional()}),Ce=ne.extend({task:kc.optional()}),zc=e=>Ce.safeParse(e).success,B=p({method:d(),params:ne.loose().optional()}),re=p({_meta:bt.optional()}),se=p({method:d(),params:re.loose().optional()}),W=Y({_meta:bt.optional()}),Ze=z([d(),k().int()]),eo=p({jsonrpc:l(Xe),id:Ze,...B.shape}).strict(),an=e=>eo.safeParse(e).success,to=p({jsonrpc:l(Xe),...se.shape}).strict(),Rc=e=>to.safeParse(e).success,vt=p({jsonrpc:l(Xe),id:Ze,result:W}).strict(),Le=e=>vt.safeParse(e).success;var P;(function(e){e[e.ConnectionClosed=-32e3]="ConnectionClosed",e[e.RequestTimeout=-32001]="RequestTimeout",e[e.ParseError=-32700]="ParseError",e[e.InvalidRequest=-32600]="InvalidRequest",e[e.MethodNotFound=-32601]="MethodNotFound",e[e.InvalidParams=-32602]="InvalidParams",e[e.InternalError=-32603]="InternalError",e[e.UrlElicitationRequired=-32042]="UrlElicitationRequired"})(P||(P={}));const yt=p({jsonrpc:l(Xe),id:Ze.optional(),error:p({code:k().int(),message:d(),data:E().optional()})}).strict(),Tc=e=>yt.safeParse(e).success,xc=z([eo,to,vt,yt]);z([vt,yt]);const no=W.strict(),Ic=re.extend({requestId:Ze.optional(),reason:d().optional()}),wt=se.extend({method:l("notifications/cancelled"),params:Ic}),$c=p({src:d(),mimeType:d().optional(),sizes:w(d()).optional(),theme:te(["light","dark"]).optional()}),Oe=p({icons:w($c).optional()}),we=p({name:d(),title:d().optional()}),et=we.extend({...we.shape,...Oe.shape,version:d(),websiteUrl:d().optional(),description:d().optional()}),Pc=_t(p({applyDefaults:Z().optional()}),$(d(),E())),Ec=Qn(e=>e&&typeof e=="object"&&!Array.isArray(e)&&Object.keys(e).length===0?{form:{}}:e,_t(p({form:Pc.optional(),url:U.optional()}),$(d(),E()).optional())),Cc=Y({list:U.optional(),cancel:U.optional(),requests:Y({sampling:Y({createMessage:U.optional()}).optional(),elicitation:Y({create:U.optional()}).optional()}).optional()}),Zc=Y({list:U.optional(),cancel:U.optional(),requests:Y({tools:Y({call:U.optional()}).optional()}).optional()}),Oc=p({experimental:$(d(),U).optional(),sampling:p({context:U.optional(),tools:U.optional()}).optional(),elicitation:Ec.optional(),roots:p({listChanged:Z().optional()}).optional(),tasks:Cc.optional(),extensions:$(d(),U).optional()}),Nc=ne.extend({protocolVersion:d(),capabilities:Oc,clientInfo:et}),qc=B.extend({method:l("initialize"),params:Nc}),Mc=p({experimental:$(d(),U).optional(),logging:U.optional(),completions:U.optional(),prompts:p({listChanged:Z().optional()}).optional(),resources:p({subscribe:Z().optional(),listChanged:Z().optional()}).optional(),tools:p({listChanged:Z().optional()}).optional(),tasks:Zc.optional(),extensions:$(d(),U).optional()}),Ac=W.extend({protocolVersion:d(),capabilities:Mc,serverInfo:et,instructions:d().optional()}),Hc=se.extend({method:l("notifications/initialized"),params:re.optional()}),tt=B.extend({method:l("ping"),params:ne.optional()}),jc=p({progress:k(),total:A(k()),message:A(d())}),Dc=p({...re.shape,...jc.shape,progressToken:Yn}),kt=se.extend({method:l("notifications/progress"),params:Dc}),Uc=ne.extend({cursor:Xn.optional()}),Ne=B.extend({params:Uc.optional()}),qe=W.extend({nextCursor:Xn.optional()}),Lc=te(["working","input_required","completed","failed","cancelled"]),Me=p({taskId:d(),status:Lc,ttl:z([k(),Qa()]),createdAt:d(),lastUpdatedAt:d(),pollInterval:A(k()),statusMessage:A(d())}),St=W.extend({task:Me}),Fc=re.merge(Me),Be=se.extend({method:l("notifications/tasks/status"),params:Fc}),zt=B.extend({method:l("tasks/get"),params:ne.extend({taskId:d()})}),Rt=W.merge(Me),Tt=B.extend({method:l("tasks/result"),params:ne.extend({taskId:d()})});W.loose();const xt=Ne.extend({method:l("tasks/list")}),It=qe.extend({tasks:w(Me)}),$t=B.extend({method:l("tasks/cancel"),params:ne.extend({taskId:d()})}),Jc=W.merge(Me),oo=p({uri:d(),mimeType:A(d()),_meta:$(d(),E()).optional()}),ro=oo.extend({text:d()}),Pt=d().refine(e=>{try{return atob(e),!0}catch{return!1}},{message:"Invalid Base64 string"}),so=oo.extend({blob:Pt}),Ae=te(["user","assistant"]),Se=p({audience:w(Ae).optional(),priority:k().min(0).max(1).optional(),lastModified:Dn({offset:!0}).optional()}),io=p({...we.shape,...Oe.shape,uri:d(),description:A(d()),mimeType:A(d()),size:A(k()),annotations:Se.optional(),_meta:A(Y({}))}),Vc=p({...we.shape,...Oe.shape,uriTemplate:d(),description:A(d()),mimeType:A(d()),annotations:Se.optional(),_meta:A(Y({}))}),ao=Ne.extend({method:l("resources/list")}),co=qe.extend({resources:w(io)}),uo=Ne.extend({method:l("resources/templates/list")}),lo=qe.extend({resourceTemplates:w(Vc)}),Et=ne.extend({uri:d()}),Bc=Et,po=B.extend({method:l("resources/read"),params:Bc}),ho=W.extend({contents:w(z([ro,so]))}),fo=se.extend({method:l("notifications/resources/list_changed"),params:re.optional()}),Wc=Et,Kc=B.extend({method:l("resources/subscribe"),params:Wc}),Gc=Et,Qc=B.extend({method:l("resources/unsubscribe"),params:Gc}),Yc=re.extend({uri:d()}),Xc=se.extend({method:l("notifications/resources/updated"),params:Yc}),eu=p({name:d(),description:A(d()),required:A(Z())}),tu=p({...we.shape,...Oe.shape,description:A(d()),arguments:A(w(eu)),_meta:A(Y({}))}),mo=Ne.extend({method:l("prompts/list")}),go=qe.extend({prompts:w(tu)}),nu=ne.extend({name:d(),arguments:$(d(),d()).optional()}),ou=B.extend({method:l("prompts/get"),params:nu}),Ct=p({type:l("text"),text:d(),annotations:Se.optional(),_meta:$(d(),E()).optional()}),Zt=p({type:l("image"),data:Pt,mimeType:d(),annotations:Se.optional(),_meta:$(d(),E()).optional()}),Ot=p({type:l("audio"),data:Pt,mimeType:d(),annotations:Se.optional(),_meta:$(d(),E()).optional()}),ru=p({type:l("tool_use"),name:d(),id:d(),input:$(d(),E()),_meta:$(d(),E()).optional()}),_o=p({type:l("resource"),resource:z([ro,so]),annotations:Se.optional(),_meta:$(d(),E()).optional()}),bo=io.extend({type:l("resource_link")}),He=z([Ct,Zt,Ot,bo,_o]),su=p({role:Ae,content:He}),iu=W.extend({description:d().optional(),messages:w(su)}),vo=se.extend({method:l("notifications/prompts/list_changed"),params:re.optional()}),au=p({title:d().optional(),readOnlyHint:Z().optional(),destructiveHint:Z().optional(),idempotentHint:Z().optional(),openWorldHint:Z().optional()}),cu=p({taskSupport:te(["required","optional","forbidden"]).optional()}),Nt=p({...we.shape,...Oe.shape,description:d().optional(),inputSchema:p({type:l("object"),properties:$(d(),U).optional(),required:w(d()).optional()}).catchall(E()),outputSchema:p({type:l("object"),properties:$(d(),U).optional(),required:w(d()).optional()}).catchall(E()).optional(),annotations:au.optional(),execution:cu.optional(),_meta:$(d(),E()).optional()}),uu=Ne.extend({method:l("tools/list")}),yo=qe.extend({tools:w(Nt)}),Pe=W.extend({content:w(He).default([]),structuredContent:$(d(),E()).optional(),isError:Z().optional()});Pe.or(W.extend({toolResult:E()}));const lu=Ce.extend({name:d(),arguments:$(d(),E()).optional()}),wo=B.extend({method:l("tools/call"),params:lu}),ko=se.extend({method:l("notifications/tools/list_changed"),params:re.optional()});p({autoRefresh:Z().default(!0),debounceMs:k().int().nonnegative().default(300)});const So=te(["debug","info","notice","warning","error","critical","alert","emergency"]),du=ne.extend({level:So}),pu=B.extend({method:l("logging/setLevel"),params:du}),hu=re.extend({level:So,logger:d().optional(),data:E()}),zo=se.extend({method:l("notifications/message"),params:hu}),fu=p({name:d().optional()}),mu=p({hints:w(fu).optional(),costPriority:k().min(0).max(1).optional(),speedPriority:k().min(0).max(1).optional(),intelligencePriority:k().min(0).max(1).optional()}),gu=p({mode:te(["auto","required","none"]).optional()}),_u=p({type:l("tool_result"),toolUseId:d().describe("The unique identifier for the corresponding tool call."),content:w(He).default([]),structuredContent:p({}).loose().optional(),isError:Z().optional(),_meta:$(d(),E()).optional()}),bu=Vn("type",[Ct,Zt,Ot]),We=Vn("type",[Ct,Zt,Ot,ru,_u]),vu=p({role:Ae,content:z([We,w(We)]),_meta:$(d(),E()).optional()}),yu=Ce.extend({messages:w(vu),modelPreferences:mu.optional(),systemPrompt:d().optional(),includeContext:te(["none","thisServer","allServers"]).optional(),temperature:k().optional(),maxTokens:k().int(),stopSequences:w(d()).optional(),metadata:U.optional(),tools:w(Nt).optional(),toolChoice:gu.optional()}),Ro=B.extend({method:l("sampling/createMessage"),params:yu}),wu=W.extend({model:d(),stopReason:A(te(["endTurn","stopSequence","maxTokens"]).or(d())),role:Ae,content:bu}),ku=W.extend({model:d(),stopReason:A(te(["endTurn","stopSequence","maxTokens","toolUse"]).or(d())),role:Ae,content:z([We,w(We)])}),Su=p({type:l("boolean"),title:d().optional(),description:d().optional(),default:Z().optional()}),zu=p({type:l("string"),title:d().optional(),description:d().optional(),minLength:k().optional(),maxLength:k().optional(),format:te(["email","uri","date","date-time"]).optional(),default:d().optional()}),Ru=p({type:te(["number","integer"]),title:d().optional(),description:d().optional(),minimum:k().optional(),maximum:k().optional(),default:k().optional()}),Tu=p({type:l("string"),title:d().optional(),description:d().optional(),enum:w(d()),default:d().optional()}),xu=p({type:l("string"),title:d().optional(),description:d().optional(),oneOf:w(p({const:d(),title:d()})),default:d().optional()}),Iu=p({type:l("string"),title:d().optional(),description:d().optional(),enum:w(d()),enumNames:w(d()).optional(),default:d().optional()}),$u=z([Tu,xu]),Pu=p({type:l("array"),title:d().optional(),description:d().optional(),minItems:k().optional(),maxItems:k().optional(),items:p({type:l("string"),enum:w(d())}),default:w(d()).optional()}),Eu=p({type:l("array"),title:d().optional(),description:d().optional(),minItems:k().optional(),maxItems:k().optional(),items:p({anyOf:w(p({const:d(),title:d()}))}),default:w(d()).optional()}),Cu=z([Pu,Eu]),Zu=z([Iu,$u,Cu]),Ou=z([Zu,Su,zu,Ru]),Nu=Ce.extend({mode:l("form").optional(),message:d(),requestedSchema:p({type:l("object"),properties:$(d(),Ou),required:w(d()).optional()})}),qu=Ce.extend({mode:l("url"),message:d(),elicitationId:d(),url:d().url()}),Mu=z([Nu,qu]),Au=B.extend({method:l("elicitation/create"),params:Mu}),Hu=re.extend({elicitationId:d()}),ju=se.extend({method:l("notifications/elicitation/complete"),params:Hu}),Du=W.extend({action:te(["accept","decline","cancel"]),content:Qn(e=>e===null?void 0:e,$(d(),z([d(),k(),Z(),w(d())])).optional())}),Uu=p({type:l("ref/resource"),uri:d()}),Lu=p({type:l("ref/prompt"),name:d()}),Fu=ne.extend({ref:z([Lu,Uu]),argument:p({name:d(),value:d()}),context:p({arguments:$(d(),d()).optional()}).optional()}),Ju=B.extend({method:l("completion/complete"),params:Fu}),Vu=W.extend({completion:Y({values:w(d()).max(100),total:A(k().int()),hasMore:A(Z())})}),Bu=p({uri:d().startsWith("file://"),name:d().optional(),_meta:$(d(),E()).optional()}),Wu=B.extend({method:l("roots/list"),params:ne.optional()}),Ku=W.extend({roots:w(Bu)}),Gu=se.extend({method:l("notifications/roots/list_changed"),params:re.optional()});z([tt,qc,Ju,pu,ou,mo,ao,uo,po,Kc,Qc,wo,uu,zt,Tt,xt,$t]);z([wt,kt,Hc,Gu,Be]);z([no,wu,ku,Du,Ku,Rt,It,St]);z([tt,Ro,Au,Wu,zt,Tt,xt,$t]);z([wt,kt,zo,Xc,fo,ko,vo,Be,ju]);z([no,Ac,Vu,iu,go,co,lo,ho,Pe,yo,Rt,It,St]);class R extends Error{constructor(t,n,o){super(`MCP error ${t}: ${n}`),this.code=t,this.data=o,this.name="McpError"}static fromError(t,n,o){if(t===P.UrlElicitationRequired&&o){const r=o;if(r.elicitations)return new Qu(r.elicitations,n)}return new R(t,n,o)}}class Qu extends R{constructor(t,n=`URL elicitation${t.length>1?"s":""} required`){super(P.UrlElicitationRequired,n,{elicitations:t})}get elicitations(){var t;return((t=this.data)==null?void 0:t.elicitations)??[]}}function qt(e){return!!e._zod}function To(e,t){return qt(e)?wn(e,t):e.safeParse(t)}function Yu(e){var n,o;if(!e)return;let t;if(qt(e)?t=(o=(n=e._zod)==null?void 0:n.def)==null?void 0:o.shape:t=e.shape,!!t){if(typeof t=="function")try{return t()}catch{return}return t}}function Xu(e){var r;if(qt(e)){const i=(r=e._zod)==null?void 0:r.def;if(i){if(i.value!==void 0)return i.value;if(Array.isArray(i.values)&&i.values.length>0)return i.values[0]}}const n=e._def;if(n){if(n.value!==void 0)return n.value;if(Array.isArray(n.values)&&n.values.length>0)return n.values[0]}const o=e.value;if(o!==void 0)return o}function he(e){return e==="completed"||e==="failed"||e==="cancelled"}new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");function cn(e){const t=Yu(e),n=t==null?void 0:t.method;if(!n)throw new Error("Schema is missing a method literal");const o=Xu(n);if(typeof o!="string")throw new Error("Schema method literal must be a string");return o}function un(e,t){const n=To(e,t);if(!n.success)throw n.error;return n.data}const el=6e4;class tl{constructor(t){this._options=t,this._requestMessageId=0,this._requestHandlers=new Map,this._requestHandlerAbortControllers=new Map,this._notificationHandlers=new Map,this._responseHandlers=new Map,this._progressHandlers=new Map,this._timeoutInfo=new Map,this._pendingDebouncedNotifications=new Set,this._taskProgressTokens=new Map,this._requestResolvers=new Map,this.setNotificationHandler(wt,n=>{this._oncancel(n)}),this.setNotificationHandler(kt,n=>{this._onprogress(n)}),this.setRequestHandler(tt,n=>({})),this._taskStore=t==null?void 0:t.taskStore,this._taskMessageQueue=t==null?void 0:t.taskMessageQueue,this._taskStore&&(this.setRequestHandler(zt,async(n,o)=>{const r=await this._taskStore.getTask(n.params.taskId,o.sessionId);if(!r)throw new R(P.InvalidParams,"Failed to retrieve task: Task not found");return{...r}}),this.setRequestHandler(Tt,async(n,o)=>{const r=async()=>{var a;const s=n.params.taskId;if(this._taskMessageQueue){let c;for(;c=await this._taskMessageQueue.dequeue(s,o.sessionId);){if(c.type==="response"||c.type==="error"){const u=c.message,h=u.id,m=this._requestResolvers.get(h);if(m)if(this._requestResolvers.delete(h),c.type==="response")m(u);else{const g=u,_=new R(g.error.code,g.error.message,g.error.data);m(_)}else{const g=c.type==="response"?"Response":"Error";this._onerror(new Error(`${g} handler missing for request ${h}`))}continue}await((a=this._transport)==null?void 0:a.send(c.message,{relatedRequestId:o.requestId}))}}const i=await this._taskStore.getTask(s,o.sessionId);if(!i)throw new R(P.InvalidParams,`Task not found: ${s}`);if(!he(i.status))return await this._waitForTaskUpdate(s,o.signal),await r();if(he(i.status)){const c=await this._taskStore.getTaskResult(s,o.sessionId);return this._clearTaskQueue(s),{...c,_meta:{...c._meta,[fe]:{taskId:s}}}}return await r()};return await r()}),this.setRequestHandler(xt,async(n,o)=>{var r;try{const{tasks:s,nextCursor:i}=await this._taskStore.listTasks((r=n.params)==null?void 0:r.cursor,o.sessionId);return{tasks:s,nextCursor:i,_meta:{}}}catch(s){throw new R(P.InvalidParams,`Failed to list tasks: ${s instanceof Error?s.message:String(s)}`)}}),this.setRequestHandler($t,async(n,o)=>{try{const r=await this._taskStore.getTask(n.params.taskId,o.sessionId);if(!r)throw new R(P.InvalidParams,`Task not found: ${n.params.taskId}`);if(he(r.status))throw new R(P.InvalidParams,`Cannot cancel task in terminal status: ${r.status}`);await this._taskStore.updateTaskStatus(n.params.taskId,"cancelled","Client cancelled task execution.",o.sessionId),this._clearTaskQueue(n.params.taskId);const s=await this._taskStore.getTask(n.params.taskId,o.sessionId);if(!s)throw new R(P.InvalidParams,`Task not found after cancellation: ${n.params.taskId}`);return{_meta:{},...s}}catch(r){throw r instanceof R?r:new R(P.InvalidRequest,`Failed to cancel task: ${r instanceof Error?r.message:String(r)}`)}}))}async _oncancel(t){if(!t.params.requestId)return;const n=this._requestHandlerAbortControllers.get(t.params.requestId);n==null||n.abort(t.params.reason)}_setupTimeout(t,n,o,r,s=!1){this._timeoutInfo.set(t,{timeoutId:setTimeout(r,n),startTime:Date.now(),timeout:n,maxTotalTimeout:o,resetTimeoutOnProgress:s,onTimeout:r})}_resetTimeout(t){const n=this._timeoutInfo.get(t);if(!n)return!1;const o=Date.now()-n.startTime;if(n.maxTotalTimeout&&o>=n.maxTotalTimeout)throw this._timeoutInfo.delete(t),R.fromError(P.RequestTimeout,"Maximum total timeout exceeded",{maxTotalTimeout:n.maxTotalTimeout,totalElapsed:o});return clearTimeout(n.timeoutId),n.timeoutId=setTimeout(n.onTimeout,n.timeout),!0}_cleanupTimeout(t){const n=this._timeoutInfo.get(t);n&&(clearTimeout(n.timeoutId),this._timeoutInfo.delete(t))}async connect(t){var s,i,a;if(this._transport)throw new Error("Already connected to a transport. Call close() before connecting to a new transport, or use a separate Protocol instance per connection.");this._transport=t;const n=(s=this.transport)==null?void 0:s.onclose;this._transport.onclose=()=>{n==null||n(),this._onclose()};const o=(i=this.transport)==null?void 0:i.onerror;this._transport.onerror=c=>{o==null||o(c),this._onerror(c)};const r=(a=this._transport)==null?void 0:a.onmessage;this._transport.onmessage=(c,u)=>{r==null||r(c,u),Le(c)||Tc(c)?this._onresponse(c):an(c)?this._onrequest(c,u):Rc(c)?this._onnotification(c):this._onerror(new Error(`Unknown message type: ${JSON.stringify(c)}`))},await this._transport.start()}_onclose(){var o;const t=this._responseHandlers;this._responseHandlers=new Map,this._progressHandlers.clear(),this._taskProgressTokens.clear(),this._pendingDebouncedNotifications.clear();for(const r of this._timeoutInfo.values())clearTimeout(r.timeoutId);this._timeoutInfo.clear();for(const r of this._requestHandlerAbortControllers.values())r.abort();this._requestHandlerAbortControllers.clear();const n=R.fromError(P.ConnectionClosed,"Connection closed");this._transport=void 0,(o=this.onclose)==null||o.call(this);for(const r of t.values())r(n)}_onerror(t){var n;(n=this.onerror)==null||n.call(this,t)}_onnotification(t){const n=this._notificationHandlers.get(t.method)??this.fallbackNotificationHandler;n!==void 0&&Promise.resolve().then(()=>n(t)).catch(o=>this._onerror(new Error(`Uncaught error in notification handler: ${o}`)))}_onrequest(t,n){var h,m,g,_;const o=this._requestHandlers.get(t.method)??this.fallbackRequestHandler,r=this._transport,s=(g=(m=(h=t.params)==null?void 0:h._meta)==null?void 0:m[fe])==null?void 0:g.taskId;if(o===void 0){const v={jsonrpc:"2.0",id:t.id,error:{code:P.MethodNotFound,message:"Method not found"}};s&&this._taskMessageQueue?this._enqueueTaskMessage(s,{type:"error",message:v,timestamp:Date.now()},r==null?void 0:r.sessionId).catch(y=>this._onerror(new Error(`Failed to enqueue error response: ${y}`))):r==null||r.send(v).catch(y=>this._onerror(new Error(`Failed to send an error response: ${y}`)));return}const i=new AbortController;this._requestHandlerAbortControllers.set(t.id,i);const a=zc(t.params)?t.params.task:void 0,c=this._taskStore?this.requestTaskStore(t,r==null?void 0:r.sessionId):void 0,u={signal:i.signal,sessionId:r==null?void 0:r.sessionId,_meta:(_=t.params)==null?void 0:_._meta,sendNotification:async v=>{if(i.signal.aborted)return;const y={relatedRequestId:t.id};s&&(y.relatedTask={taskId:s}),await this.notification(v,y)},sendRequest:async(v,y,x)=>{var V;if(i.signal.aborted)throw new R(P.ConnectionClosed,"Request was cancelled");const L={...x,relatedRequestId:t.id};s&&!L.relatedTask&&(L.relatedTask={taskId:s});const C=((V=L.relatedTask)==null?void 0:V.taskId)??s;return C&&c&&await c.updateTaskStatus(C,"input_required"),await this.request(v,y,L)},authInfo:n==null?void 0:n.authInfo,requestId:t.id,requestInfo:n==null?void 0:n.requestInfo,taskId:s,taskStore:c,taskRequestedTtl:a==null?void 0:a.ttl,closeSSEStream:n==null?void 0:n.closeSSEStream,closeStandaloneSSEStream:n==null?void 0:n.closeStandaloneSSEStream};Promise.resolve().then(()=>{a&&this.assertTaskHandlerCapability(t.method)}).then(()=>o(t,u)).then(async v=>{if(i.signal.aborted)return;const y={result:v,jsonrpc:"2.0",id:t.id};s&&this._taskMessageQueue?await this._enqueueTaskMessage(s,{type:"response",message:y,timestamp:Date.now()},r==null?void 0:r.sessionId):await(r==null?void 0:r.send(y))},async v=>{if(i.signal.aborted)return;const y={jsonrpc:"2.0",id:t.id,error:{code:Number.isSafeInteger(v.code)?v.code:P.InternalError,message:v.message??"Internal error",...v.data!==void 0&&{data:v.data}}};s&&this._taskMessageQueue?await this._enqueueTaskMessage(s,{type:"error",message:y,timestamp:Date.now()},r==null?void 0:r.sessionId):await(r==null?void 0:r.send(y))}).catch(v=>this._onerror(new Error(`Failed to send response: ${v}`))).finally(()=>{this._requestHandlerAbortControllers.get(t.id)===i&&this._requestHandlerAbortControllers.delete(t.id)})}_onprogress(t){const{progressToken:n,...o}=t.params,r=Number(n),s=this._progressHandlers.get(r);if(!s){this._onerror(new Error(`Received a progress notification for an unknown token: ${JSON.stringify(t)}`));return}const i=this._responseHandlers.get(r),a=this._timeoutInfo.get(r);if(a&&i&&a.resetTimeoutOnProgress)try{this._resetTimeout(r)}catch(c){this._responseHandlers.delete(r),this._progressHandlers.delete(r),this._cleanupTimeout(r),i(c);return}s(o)}_onresponse(t){const n=Number(t.id),o=this._requestResolvers.get(n);if(o){if(this._requestResolvers.delete(n),Le(t))o(t);else{const i=new R(t.error.code,t.error.message,t.error.data);o(i)}return}const r=this._responseHandlers.get(n);if(r===void 0){this._onerror(new Error(`Received a response for an unknown message ID: ${JSON.stringify(t)}`));return}this._responseHandlers.delete(n),this._cleanupTimeout(n);let s=!1;if(Le(t)&&t.result&&typeof t.result=="object"){const i=t.result;if(i.task&&typeof i.task=="object"){const a=i.task;typeof a.taskId=="string"&&(s=!0,this._taskProgressTokens.set(a.taskId,n))}}if(s||this._progressHandlers.delete(n),Le(t))r(t);else{const i=R.fromError(t.error.code,t.error.message,t.error.data);r(i)}}get transport(){return this._transport}async close(){var t;await((t=this._transport)==null?void 0:t.close())}async*requestStream(t,n,o){var i,a;const{task:r}=o??{};if(!r){try{yield{type:"result",result:await this.request(t,n,o)}}catch(c){yield{type:"error",error:c instanceof R?c:new R(P.InternalError,String(c))}}return}let s;try{const c=await this.request(t,St,o);if(c.task)s=c.task.taskId,yield{type:"taskCreated",task:c.task};else throw new R(P.InternalError,"Task creation did not return a task");for(;;){const u=await this.getTask({taskId:s},o);if(yield{type:"taskStatus",task:u},he(u.status)){u.status==="completed"?yield{type:"result",result:await this.getTaskResult({taskId:s},n,o)}:u.status==="failed"?yield{type:"error",error:new R(P.InternalError,`Task ${s} failed`)}:u.status==="cancelled"&&(yield{type:"error",error:new R(P.InternalError,`Task ${s} was cancelled`)});return}if(u.status==="input_required"){yield{type:"result",result:await this.getTaskResult({taskId:s},n,o)};return}const h=u.pollInterval??((i=this._options)==null?void 0:i.defaultTaskPollInterval)??1e3;await new Promise(m=>setTimeout(m,h)),(a=o==null?void 0:o.signal)==null||a.throwIfAborted()}}catch(c){yield{type:"error",error:c instanceof R?c:new R(P.InternalError,String(c))}}}request(t,n,o){const{relatedRequestId:r,resumptionToken:s,onresumptiontoken:i,task:a,relatedTask:c}=o??{};return new Promise((u,h)=>{var C,V,K,D,T;const m=O=>{h(O)};if(!this._transport){m(new Error("Not connected"));return}if(((C=this._options)==null?void 0:C.enforceStrictCapabilities)===!0)try{this.assertCapabilityForMethod(t.method),a&&this.assertTaskCapability(t.method)}catch(O){m(O);return}(V=o==null?void 0:o.signal)==null||V.throwIfAborted();const g=this._requestMessageId++,_={...t,jsonrpc:"2.0",id:g};o!=null&&o.onprogress&&(this._progressHandlers.set(g,o.onprogress),_.params={...t.params,_meta:{...((K=t.params)==null?void 0:K._meta)||{},progressToken:g}}),a&&(_.params={..._.params,task:a}),c&&(_.params={..._.params,_meta:{...((D=_.params)==null?void 0:D._meta)||{},[fe]:c}});const v=O=>{var Q;this._responseHandlers.delete(g),this._progressHandlers.delete(g),this._cleanupTimeout(g),(Q=this._transport)==null||Q.send({jsonrpc:"2.0",method:"notifications/cancelled",params:{requestId:g,reason:String(O)}},{relatedRequestId:r,resumptionToken:s,onresumptiontoken:i}).catch(ze=>this._onerror(new Error(`Failed to send cancellation: ${ze}`)));const ee=O instanceof R?O:new R(P.RequestTimeout,String(O));h(ee)};this._responseHandlers.set(g,O=>{var ee;if(!((ee=o==null?void 0:o.signal)!=null&&ee.aborted)){if(O instanceof Error)return h(O);try{const Q=To(n,O.result);Q.success?u(Q.data):h(Q.error)}catch(Q){h(Q)}}}),(T=o==null?void 0:o.signal)==null||T.addEventListener("abort",()=>{var O;v((O=o==null?void 0:o.signal)==null?void 0:O.reason)});const y=(o==null?void 0:o.timeout)??el,x=()=>v(R.fromError(P.RequestTimeout,"Request timed out",{timeout:y}));this._setupTimeout(g,y,o==null?void 0:o.maxTotalTimeout,x,(o==null?void 0:o.resetTimeoutOnProgress)??!1);const L=c==null?void 0:c.taskId;if(L){const O=ee=>{const Q=this._responseHandlers.get(g);Q?Q(ee):this._onerror(new Error(`Response handler missing for side-channeled request ${g}`))};this._requestResolvers.set(g,O),this._enqueueTaskMessage(L,{type:"request",message:_,timestamp:Date.now()}).catch(ee=>{this._cleanupTimeout(g),h(ee)})}else this._transport.send(_,{relatedRequestId:r,resumptionToken:s,onresumptiontoken:i}).catch(O=>{this._cleanupTimeout(g),h(O)})})}async getTask(t,n){return this.request({method:"tasks/get",params:t},Rt,n)}async getTaskResult(t,n,o){return this.request({method:"tasks/result",params:t},n,o)}async listTasks(t,n){return this.request({method:"tasks/list",params:t},It,n)}async cancelTask(t,n){return this.request({method:"tasks/cancel",params:t},Jc,n)}async notification(t,n){var a,c,u,h;if(!this._transport)throw new Error("Not connected");this.assertNotificationCapability(t.method);const o=(a=n==null?void 0:n.relatedTask)==null?void 0:a.taskId;if(o){const m={...t,jsonrpc:"2.0",params:{...t.params,_meta:{...((c=t.params)==null?void 0:c._meta)||{},[fe]:n.relatedTask}}};await this._enqueueTaskMessage(o,{type:"notification",message:m,timestamp:Date.now()});return}if((((u=this._options)==null?void 0:u.debouncedNotificationMethods)??[]).includes(t.method)&&!t.params&&!(n!=null&&n.relatedRequestId)&&!(n!=null&&n.relatedTask)){if(this._pendingDebouncedNotifications.has(t.method))return;this._pendingDebouncedNotifications.add(t.method),Promise.resolve().then(()=>{var g,_;if(this._pendingDebouncedNotifications.delete(t.method),!this._transport)return;let m={...t,jsonrpc:"2.0"};n!=null&&n.relatedTask&&(m={...m,params:{...m.params,_meta:{...((g=m.params)==null?void 0:g._meta)||{},[fe]:n.relatedTask}}}),(_=this._transport)==null||_.send(m,n).catch(v=>this._onerror(v))});return}let i={...t,jsonrpc:"2.0"};n!=null&&n.relatedTask&&(i={...i,params:{...i.params,_meta:{...((h=i.params)==null?void 0:h._meta)||{},[fe]:n.relatedTask}}}),await this._transport.send(i,n)}setRequestHandler(t,n){const o=cn(t);this.assertRequestHandlerCapability(o),this._requestHandlers.set(o,(r,s)=>{const i=un(t,r);return Promise.resolve(n(i,s))})}removeRequestHandler(t){this._requestHandlers.delete(t)}assertCanSetRequestHandler(t){if(this._requestHandlers.has(t))throw new Error(`A request handler for ${t} already exists, which would be overridden`)}setNotificationHandler(t,n){const o=cn(t);this._notificationHandlers.set(o,r=>{const s=un(t,r);return Promise.resolve(n(s))})}removeNotificationHandler(t){this._notificationHandlers.delete(t)}_cleanupTaskProgressHandler(t){const n=this._taskProgressTokens.get(t);n!==void 0&&(this._progressHandlers.delete(n),this._taskProgressTokens.delete(t))}async _enqueueTaskMessage(t,n,o){var s;if(!this._taskStore||!this._taskMessageQueue)throw new Error("Cannot enqueue task message: taskStore and taskMessageQueue are not configured");const r=(s=this._options)==null?void 0:s.maxTaskQueueSize;await this._taskMessageQueue.enqueue(t,n,o,r)}async _clearTaskQueue(t,n){if(this._taskMessageQueue){const o=await this._taskMessageQueue.dequeueAll(t,n);for(const r of o)if(r.type==="request"&&an(r.message)){const s=r.message.id,i=this._requestResolvers.get(s);i?(i(new R(P.InternalError,"Task cancelled or completed")),this._requestResolvers.delete(s)):this._onerror(new Error(`Resolver missing for request ${s} during task ${t} cleanup`))}}}async _waitForTaskUpdate(t,n){var r,s;let o=((r=this._options)==null?void 0:r.defaultTaskPollInterval)??1e3;try{const i=await((s=this._taskStore)==null?void 0:s.getTask(t));i!=null&&i.pollInterval&&(o=i.pollInterval)}catch{}return new Promise((i,a)=>{if(n.aborted){a(new R(P.InvalidRequest,"Request cancelled"));return}const c=setTimeout(i,o);n.addEventListener("abort",()=>{clearTimeout(c),a(new R(P.InvalidRequest,"Request cancelled"))},{once:!0})})}requestTaskStore(t,n){const o=this._taskStore;if(!o)throw new Error("No task store configured");return{createTask:async r=>{if(!t)throw new Error("No request provided");return await o.createTask(r,t.id,{method:t.method,params:t.params},n)},getTask:async r=>{const s=await o.getTask(r,n);if(!s)throw new R(P.InvalidParams,"Failed to retrieve task: Task not found");return s},storeTaskResult:async(r,s,i)=>{await o.storeTaskResult(r,s,i,n);const a=await o.getTask(r,n);if(a){const c=Be.parse({method:"notifications/tasks/status",params:a});await this.notification(c),he(a.status)&&this._cleanupTaskProgressHandler(r)}},getTaskResult:r=>o.getTaskResult(r,n),updateTaskStatus:async(r,s,i)=>{const a=await o.getTask(r,n);if(!a)throw new R(P.InvalidParams,`Task "${r}" not found - it may have been cleaned up`);if(he(a.status))throw new R(P.InvalidParams,`Cannot update task "${r}" from terminal status "${a.status}" to "${s}". Terminal states (completed, failed, cancelled) cannot transition to other states.`);await o.updateTaskStatus(r,s,i,n);const c=await o.getTask(r,n);if(c){const u=Be.parse({method:"notifications/tasks/status",params:c});await this.notification(u),he(c.status)&&this._cleanupTaskProgressHandler(r)}},listTasks:r=>o.listTasks(r,n)}}}(e=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(e,{get:(t,n)=>(typeof require<"u"?require:t)[n]}):e)(function(e){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')});class nl extends tl{constructor(){super(...arguments);S(this,"_registeredMethods",new Set);S(this,"_eventSlots",new Map);S(this,"setRequestHandler",(n,o)=>{this._assertMethodNotRegistered(n,"setRequestHandler"),super.setRequestHandler(n,o)});S(this,"setNotificationHandler",(n,o)=>{this._assertMethodNotRegistered(n,"setNotificationHandler"),super.setNotificationHandler(n,o)});S(this,"replaceRequestHandler",(n,o)=>{let r=n.shape.method.value;this._registeredMethods.add(r),super.setRequestHandler(n,o)})}onEventDispatch(n,o){}_ensureEventSlot(n){let o=this._eventSlots.get(n);if(!o){let r=this.eventSchemas[n];if(!r)throw Error(`Unknown event: ${String(n)}`);o={listeners:[]},this._eventSlots.set(n,o);let s=r.shape.method.value;this._registeredMethods.add(s);let i=o;super.setNotificationHandler(r,a=>{var u;let c=a.params;this.onEventDispatch(n,c),(u=i.onHandler)==null||u.call(i,c);for(let h of[...i.listeners])h(c)})}return o}setEventHandler(n,o){let r=this._ensureEventSlot(n);r.onHandler&&o&&console.warn(`[MCP Apps] on${String(n)} handler replaced. Use addEventListener("${String(n)}", …) to add multiple listeners without replacing.`),r.onHandler=o}getEventHandler(n){var o;return(o=this._eventSlots.get(n))==null?void 0:o.onHandler}addEventListener(n,o){this._ensureEventSlot(n).listeners.push(o)}removeEventListener(n,o){let r=this._eventSlots.get(n);if(!r)return;let s=r.listeners.indexOf(o);s!==-1&&r.listeners.splice(s,1)}warnIfRequestHandlerReplaced(n,o,r){o&&r&&console.warn(`[MCP Apps] ${n} handler replaced. Previous handler will no longer be called.`)}_assertMethodNotRegistered(n,o){let r=n.shape.method.value;if(this._registeredMethods.has(r))throw Error(`Handler for "${r}" already registered (via ${o}). Use addEventListener() to attach multiple listeners, or the on* setter for replace semantics.`);this._registeredMethods.add(r)}}var xo="2026-01-26",ol="ui/notifications/tool-input-partial",rl=z([l("light"),l("dark")]).describe("Color theme preference for the host environment."),Ee=z([l("inline"),l("fullscreen"),l("pip")]).describe("Display mode for UI presentation."),sl=z([l("--color-background-primary"),l("--color-background-secondary"),l("--color-background-tertiary"),l("--color-background-inverse"),l("--color-background-ghost"),l("--color-background-info"),l("--color-background-danger"),l("--color-background-success"),l("--color-background-warning"),l("--color-background-disabled"),l("--color-text-primary"),l("--color-text-secondary"),l("--color-text-tertiary"),l("--color-text-inverse"),l("--color-text-ghost"),l("--color-text-info"),l("--color-text-danger"),l("--color-text-success"),l("--color-text-warning"),l("--color-text-disabled"),l("--color-border-primary"),l("--color-border-secondary"),l("--color-border-tertiary"),l("--color-border-inverse"),l("--color-border-ghost"),l("--color-border-info"),l("--color-border-danger"),l("--color-border-success"),l("--color-border-warning"),l("--color-border-disabled"),l("--color-ring-primary"),l("--color-ring-secondary"),l("--color-ring-inverse"),l("--color-ring-info"),l("--color-ring-danger"),l("--color-ring-success"),l("--color-ring-warning"),l("--font-sans"),l("--font-mono"),l("--font-weight-normal"),l("--font-weight-medium"),l("--font-weight-semibold"),l("--font-weight-bold"),l("--font-text-xs-size"),l("--font-text-sm-size"),l("--font-text-md-size"),l("--font-text-lg-size"),l("--font-heading-xs-size"),l("--font-heading-sm-size"),l("--font-heading-md-size"),l("--font-heading-lg-size"),l("--font-heading-xl-size"),l("--font-heading-2xl-size"),l("--font-heading-3xl-size"),l("--font-text-xs-line-height"),l("--font-text-sm-line-height"),l("--font-text-md-line-height"),l("--font-text-lg-line-height"),l("--font-heading-xs-line-height"),l("--font-heading-sm-line-height"),l("--font-heading-md-line-height"),l("--font-heading-lg-line-height"),l("--font-heading-xl-line-height"),l("--font-heading-2xl-line-height"),l("--font-heading-3xl-line-height"),l("--border-radius-xs"),l("--border-radius-sm"),l("--border-radius-md"),l("--border-radius-lg"),l("--border-radius-xl"),l("--border-radius-full"),l("--border-width-regular"),l("--shadow-hairline"),l("--shadow-sm"),l("--shadow-md"),l("--shadow-lg")]).describe("CSS variable keys available to MCP apps for theming."),il=$(sl.describe(`Style variables for theming MCP apps.
40
-
41
- Individual style keys are optional - hosts may provide any subset of these values.
42
- Values are strings containing CSS values (colors, sizes, font stacks, etc.).
43
-
44
- Note: This type uses \`Record<K, string | undefined>\` rather than \`Partial<Record<K, string>>\`
45
- for compatibility with Zod schema generation. Both are functionally equivalent for validation.`),z([d(),at()]).describe(`Style variables for theming MCP apps.
46
-
47
- Individual style keys are optional - hosts may provide any subset of these values.
48
- Values are strings containing CSS values (colors, sizes, font stacks, etc.).
49
-
50
- Note: This type uses \`Record<K, string | undefined>\` rather than \`Partial<Record<K, string>>\`
51
- for compatibility with Zod schema generation. Both are functionally equivalent for validation.`)).describe(`Style variables for theming MCP apps.
52
-
53
- Individual style keys are optional - hosts may provide any subset of these values.
54
- Values are strings containing CSS values (colors, sizes, font stacks, etc.).
55
-
56
- Note: This type uses \`Record<K, string | undefined>\` rather than \`Partial<Record<K, string>>\`
57
- for compatibility with Zod schema generation. Both are functionally equivalent for validation.`),al=p({method:l("ui/open-link"),params:p({url:d().describe("URL to open in the host's browser")})});p({isError:Z().optional().describe("True if the host failed to open the URL (e.g., due to security policy).")}).passthrough();p({isError:Z().optional().describe("True if the download failed (e.g., user cancelled or host denied).")}).passthrough();p({isError:Z().optional().describe("True if the host rejected or failed to deliver the message.")}).passthrough();var cl=p({method:l("ui/notifications/sandbox-proxy-ready"),params:p({})}),Mt=p({connectDomains:w(d()).optional().describe(`Origins for network requests (fetch/XHR/WebSocket).
58
-
59
- - Maps to CSP \`connect-src\` directive
60
- - Empty or omitted → no network connections (secure default)`),resourceDomains:w(d()).optional().describe("Origins for static resources (images, scripts, stylesheets, fonts, media).\n\n- Maps to CSP `img-src`, `script-src`, `style-src`, `font-src`, `media-src` directives\n- Wildcard subdomains supported: `https://*.example.com`\n- Empty or omitted → no network resources (secure default)"),frameDomains:w(d()).optional().describe("Origins for nested iframes.\n\n- Maps to CSP `frame-src` directive\n- Empty or omitted → no nested iframes allowed (`frame-src 'none'`)"),baseUriDomains:w(d()).optional().describe("Allowed base URIs for the document.\n\n- Maps to CSP `base-uri` directive\n- Empty or omitted → only same origin allowed (`base-uri 'self'`)")}),At=p({camera:p({}).optional().describe("Request camera access.\n\nMaps to Permission Policy `camera` feature."),microphone:p({}).optional().describe("Request microphone access.\n\nMaps to Permission Policy `microphone` feature."),geolocation:p({}).optional().describe("Request geolocation access.\n\nMaps to Permission Policy `geolocation` feature."),clipboardWrite:p({}).optional().describe("Request clipboard write access.\n\nMaps to Permission Policy `clipboard-write` feature.")}),ul=p({method:l("ui/notifications/size-changed"),params:p({width:k().optional().describe("New width in pixels."),height:k().optional().describe("New height in pixels.")})});p({method:l("ui/notifications/tool-input"),params:p({arguments:$(d(),E().describe("Complete tool call arguments as key-value pairs.")).optional().describe("Complete tool call arguments as key-value pairs.")})});p({method:l("ui/notifications/tool-input-partial"),params:p({arguments:$(d(),E().describe("Partial tool call arguments (incomplete, may change).")).optional().describe("Partial tool call arguments (incomplete, may change).")})});p({method:l("ui/notifications/tool-cancelled"),params:p({reason:d().optional().describe('Optional reason for the cancellation (e.g., "user action", "timeout").')})});var ll=p({fonts:d().optional()}),dl=p({variables:il.optional().describe("CSS variables for theming the app."),css:ll.optional().describe("CSS blocks that apps can inject.")});p({method:l("ui/resource-teardown"),params:p({})});var pl=$(d(),E()),ln=p({text:p({}).optional().describe("Host supports text content blocks."),image:p({}).optional().describe("Host supports image content blocks."),audio:p({}).optional().describe("Host supports audio content blocks."),resource:p({}).optional().describe("Host supports resource content blocks."),resourceLink:p({}).optional().describe("Host supports resource link content blocks."),structuredContent:p({}).optional().describe("Host supports structured content.")}),hl=p({method:l("ui/notifications/request-teardown"),params:p({}).optional()}),fl=p({experimental:p({}).optional().describe("Experimental features (structure TBD)."),openLinks:p({}).optional().describe("Host supports opening external URLs."),downloadFile:p({}).optional().describe("Host supports file downloads via ui/download-file."),serverTools:p({listChanged:Z().optional().describe("Host supports tools/list_changed notifications.")}).optional().describe("Host can proxy tool calls to the MCP server."),serverResources:p({listChanged:Z().optional().describe("Host supports resources/list_changed notifications.")}).optional().describe("Host can proxy resource reads to the MCP server."),logging:p({}).optional().describe("Host accepts log messages."),sandbox:p({permissions:At.optional().describe("Permissions granted by the host (camera, microphone, geolocation)."),csp:Mt.optional().describe("CSP domains approved by the host.")}).optional().describe("Sandbox configuration applied by the host."),updateModelContext:ln.optional().describe("Host accepts context updates (ui/update-model-context) to be included in the model's context for future turns."),message:ln.optional().describe("Host supports receiving content messages (ui/message) from the view."),sampling:p({tools:p({}).optional().describe("Host supports tool use via `tools` and `toolChoice` parameters.")}).optional().describe("Host supports LLM sampling (sampling/createMessage) from the view.\nMirrors the MCP `ClientCapabilities.sampling` shape so hosts can pass it through.")}),ml=p({experimental:p({}).optional().describe("Experimental features (structure TBD)."),tools:p({listChanged:Z().optional().describe("App supports tools/list_changed notifications.")}).optional().describe("App exposes MCP-style tools that the host can call."),availableDisplayModes:w(Ee).optional().describe("Display modes the app supports.")}),gl=p({method:l("ui/notifications/initialized"),params:p({}).optional()});p({csp:Mt.optional().describe("Content Security Policy configuration for UI resources."),permissions:At.optional().describe("Sandbox permissions requested by the UI resource."),domain:d().optional().describe(`Dedicated origin for view sandbox.
61
-
62
- Useful when views need stable, dedicated origins for OAuth callbacks, CORS policies, or API key allowlists.
63
-
64
- **Host-dependent:** The format and validation rules for this field are determined by each host. Servers MUST consult host-specific documentation for the expected domain format. Common patterns include:
65
- - Hash-based subdomains (e.g., \`{hash}.claudemcpcontent.com\`)
66
- - URL-derived subdomains (e.g., \`www-example-com.oaiusercontent.com\`)
67
-
68
- If omitted, host uses default sandbox origin (typically per-conversation).`),prefersBorder:Z().optional().describe(`Visual boundary preference - true if view prefers a visible border.
69
-
70
- Boolean requesting whether a visible border and background is provided by the host. Specifying an explicit value for this is recommended because hosts' defaults may vary.
71
-
72
- - \`true\`: request visible border + background
73
- - \`false\`: request no visible border + background
74
- - omitted: host decides border`)});var dn=p({method:l("ui/request-display-mode"),params:p({mode:Ee.describe("The display mode being requested.")})});p({mode:Ee.describe("The display mode that was actually set. May differ from requested if not supported.")}).passthrough();var _l=z([l("model"),l("app")]).describe("Tool visibility scope - who can access the tool.");p({resourceUri:d().optional(),visibility:w(_l).optional().describe(`Who can access this tool. Default: ["model", "app"]
75
- - "model": Tool visible to and callable by the agent
76
- - "app": Tool callable by the app from this server only`),csp:ct().optional(),permissions:ct().optional()});p({mimeTypes:w(d()).optional().describe('Array of supported MIME types for UI resources.\nMust include `"text/html;profile=mcp-app"` for MCP Apps support.')});var bl=p({method:l("ui/download-file"),params:p({contents:w(z([_o,bo])).describe("Resource contents to download — embedded (inline data) or linked (host fetches). Uses standard MCP resource types.")})}),vl=p({method:l("ui/message"),params:p({role:l("user").describe('Message role, currently only "user" is supported.'),content:w(He).describe("Message content blocks (text, image, etc.).")})});p({method:l("ui/notifications/sandbox-resource-ready"),params:p({html:d().describe("HTML content to load into the inner iframe."),sandbox:d().optional().describe("Optional override for the inner iframe's sandbox attribute."),csp:Mt.optional().describe("CSP configuration from resource metadata."),permissions:At.optional().describe("Sandbox permissions from resource metadata.")})});p({method:l("ui/notifications/tool-result"),params:Pe.describe("Standard MCP tool execution result.")});var Io=p({toolInfo:p({id:Ze.optional().describe("JSON-RPC id of the tools/call request."),tool:Nt.describe("Tool definition including name, inputSchema, etc.")}).optional().describe("Metadata of the tool call that instantiated this App."),theme:rl.optional().describe("Current color theme preference."),styles:dl.optional().describe("Style configuration for theming the app."),displayMode:Ee.optional().describe("How the UI is currently displayed."),availableDisplayModes:w(Ee).optional().describe("Display modes the host supports."),containerDimensions:z([p({height:k().describe("Fixed container height in pixels.")}),p({maxHeight:z([k(),at()]).optional().describe("Maximum container height in pixels.")})]).and(z([p({width:k().describe("Fixed container width in pixels.")}),p({maxWidth:z([k(),at()]).optional().describe("Maximum container width in pixels.")})])).optional().describe(`Container dimensions. Represents the dimensions of the iframe or other
77
- container holding the app. Specify either width or maxWidth, and either height or maxHeight.`),locale:d().optional().describe("User's language and region preference in BCP 47 format."),timeZone:d().optional().describe("User's timezone in IANA format."),userAgent:d().optional().describe("Host application identifier."),platform:z([l("web"),l("desktop"),l("mobile")]).optional().describe("Platform type for responsive design decisions."),deviceCapabilities:p({touch:Z().optional().describe("Whether the device supports touch input."),hover:Z().optional().describe("Whether the device supports hover interactions.")}).optional().describe("Device input capabilities."),safeAreaInsets:p({top:k().describe("Top safe area inset in pixels."),right:k().describe("Right safe area inset in pixels."),bottom:k().describe("Bottom safe area inset in pixels."),left:k().describe("Left safe area inset in pixels.")}).optional().describe("Mobile safe area boundaries in pixels.")}).passthrough();p({method:l("ui/notifications/host-context-changed"),params:Io.describe("Partial context update containing only changed fields.")});var yl=p({method:l("ui/update-model-context"),params:p({content:w(He).optional().describe("Context content blocks (text, image, etc.)."),structuredContent:$(d(),E().describe("Structured content for machine-readable context data.")).optional().describe("Structured content for machine-readable context data.")})}),wl=p({method:l("ui/initialize"),params:p({appInfo:et.describe("App identification (name and version)."),appCapabilities:ml.describe("Features and capabilities this app provides."),protocolVersion:d().describe("Protocol version this app supports.")})});p({protocolVersion:d().describe('Negotiated protocol version string (e.g., "2025-11-21").'),hostInfo:et.describe("Host application identification and version."),hostCapabilities:fl.describe("Features and capabilities provided by the host."),hostContext:Io.describe("Rich context about the host environment.")}).passthrough();class kl{constructor(t=window.parent,n){S(this,"eventTarget");S(this,"eventSource");S(this,"messageListener");S(this,"onclose");S(this,"onerror");S(this,"onmessage");S(this,"sessionId");S(this,"setProtocolVersion");this.eventTarget=t,this.eventSource=n,this.messageListener=o=>{var s,i,a;if(n&&o.source!==this.eventSource){console.debug("Ignoring message from unknown source",o);return}let r=xc.safeParse(o.data);r.success?(console.debug("Parsed message",r.data),(s=this.onmessage)==null||s.call(this,r.data)):((i=o.data)==null?void 0:i.jsonrpc)!=="2.0"?console.debug("Ignoring non-JSON-RPC message",r.error.message,o):(console.error("Failed to parse message",r.error.message,o),(a=this.onerror)==null||a.call(this,Error("Invalid JSON-RPC message received: "+r.error.message)))}}async start(){window.addEventListener("message",this.messageListener)}async send(t,n){t.method!==ol&&console.debug("Sending message",t),this.eventTarget.postMessage(t,"*")}async close(){var t;window.removeEventListener("message",this.messageListener),(t=this.onclose)==null||t.call(this)}}function Sl(e){if(!e)return"";let t=[];return e.camera&&t.push("camera"),e.microphone&&t.push("microphone"),e.geolocation&&t.push("geolocation"),e.clipboardWrite&&t.push("clipboard-write"),t.join("; ")}var zl=[xo];class Rl extends nl{constructor(n,o,r,s){super(s);S(this,"_client");S(this,"_hostInfo");S(this,"_capabilities");S(this,"_appCapabilities");S(this,"_hostContext",{});S(this,"_appInfo");S(this,"_initializedReceived",!1);S(this,"_baseReplaceRequestHandler",this.replaceRequestHandler);S(this,"replaceRequestHandler",(n,o)=>{this._baseReplaceRequestHandler(n,(r,s)=>(this._initializedReceived||console.warn(`[ext-apps] AppBridge received '${r.method}' before ui/notifications/initialized. The View is calling host methods before completing the handshake; it should await app.connect() first.`),o(r,s)))});S(this,"eventSchemas",{sizechange:ul,sandboxready:cl,initialized:gl,requestteardown:hl,loggingmessage:zo});S(this,"onping");S(this,"_onmessage");S(this,"_onopenlink");S(this,"_ondownloadfile");S(this,"_onrequestdisplaymode");S(this,"_onupdatemodelcontext");S(this,"_oncalltool");S(this,"_onlistresources");S(this,"_onlistresourcetemplates");S(this,"_onreadresource");S(this,"_onlistprompts");S(this,"sendResourceTeardown",this.teardownResource);this._client=n,this._hostInfo=o,this._capabilities=r,this.addEventListener("initialized",()=>{this._initializedReceived=!0}),this._hostContext=(s==null?void 0:s.hostContext)||{},this.setRequestHandler(wl,i=>this._oninitialize(i)),this.setRequestHandler(tt,(i,a)=>{var c;return(c=this.onping)==null||c.call(this,i.params,a),{}}),this.replaceRequestHandler(dn,i=>({mode:this._hostContext.displayMode??"inline"}))}getAppCapabilities(){return this._appCapabilities}getAppVersion(){return this._appInfo}get onsizechange(){return this.getEventHandler("sizechange")}set onsizechange(n){this.setEventHandler("sizechange",n)}get onsandboxready(){return this.getEventHandler("sandboxready")}set onsandboxready(n){this.setEventHandler("sandboxready",n)}get oninitialized(){return this.getEventHandler("initialized")}set oninitialized(n){this.setEventHandler("initialized",n)}get onmessage(){return this._onmessage}set onmessage(n){this.warnIfRequestHandlerReplaced("onmessage",this._onmessage,n),this._onmessage=n,this.replaceRequestHandler(vl,async(o,r)=>{if(!this._onmessage)throw Error("No onmessage handler set");return this._onmessage(o.params,r)})}get onopenlink(){return this._onopenlink}set onopenlink(n){this.warnIfRequestHandlerReplaced("onopenlink",this._onopenlink,n),this._onopenlink=n,this.replaceRequestHandler(al,async(o,r)=>{if(!this._onopenlink)throw Error("No onopenlink handler set");return this._onopenlink(o.params,r)})}get ondownloadfile(){return this._ondownloadfile}set ondownloadfile(n){this.warnIfRequestHandlerReplaced("ondownloadfile",this._ondownloadfile,n),this._ondownloadfile=n,this.replaceRequestHandler(bl,async(o,r)=>{if(!this._ondownloadfile)throw Error("No ondownloadfile handler set");return this._ondownloadfile(o.params,r)})}get onrequestteardown(){return this.getEventHandler("requestteardown")}set onrequestteardown(n){this.setEventHandler("requestteardown",n)}get onrequestdisplaymode(){return this._onrequestdisplaymode}set onrequestdisplaymode(n){this.warnIfRequestHandlerReplaced("onrequestdisplaymode",this._onrequestdisplaymode,n),this._onrequestdisplaymode=n,this.replaceRequestHandler(dn,async(o,r)=>{if(!this._onrequestdisplaymode)throw Error("No onrequestdisplaymode handler set");return this._onrequestdisplaymode(o.params,r)})}get onloggingmessage(){return this.getEventHandler("loggingmessage")}set onloggingmessage(n){this.setEventHandler("loggingmessage",n)}get onupdatemodelcontext(){return this._onupdatemodelcontext}set onupdatemodelcontext(n){this.warnIfRequestHandlerReplaced("onupdatemodelcontext",this._onupdatemodelcontext,n),this._onupdatemodelcontext=n,this.replaceRequestHandler(yl,async(o,r)=>{if(!this._onupdatemodelcontext)throw Error("No onupdatemodelcontext handler set");return this._onupdatemodelcontext(o.params,r)})}get oncalltool(){return this._oncalltool}set oncalltool(n){this.warnIfRequestHandlerReplaced("oncalltool",this._oncalltool,n),this._oncalltool=n,this.replaceRequestHandler(wo,async(o,r)=>{if(!this._oncalltool)throw Error("No oncalltool handler set");return this._oncalltool(o.params,r)})}set oncreatesamplingmessage(n){this.setRequestHandler(Ro,async(o,r)=>n(o.params,r))}sendToolListChanged(n={}){return this.notification({method:"notifications/tools/list_changed",params:n})}get onlistresources(){return this._onlistresources}set onlistresources(n){this.warnIfRequestHandlerReplaced("onlistresources",this._onlistresources,n),this._onlistresources=n,this.replaceRequestHandler(ao,async(o,r)=>{if(!this._onlistresources)throw Error("No onlistresources handler set");return this._onlistresources(o.params,r)})}get onlistresourcetemplates(){return this._onlistresourcetemplates}set onlistresourcetemplates(n){this.warnIfRequestHandlerReplaced("onlistresourcetemplates",this._onlistresourcetemplates,n),this._onlistresourcetemplates=n,this.replaceRequestHandler(uo,async(o,r)=>{if(!this._onlistresourcetemplates)throw Error("No onlistresourcetemplates handler set");return this._onlistresourcetemplates(o.params,r)})}get onreadresource(){return this._onreadresource}set onreadresource(n){this.warnIfRequestHandlerReplaced("onreadresource",this._onreadresource,n),this._onreadresource=n,this.replaceRequestHandler(po,async(o,r)=>{if(!this._onreadresource)throw Error("No onreadresource handler set");return this._onreadresource(o.params,r)})}sendResourceListChanged(n={}){return this.notification({method:"notifications/resources/list_changed",params:n})}get onlistprompts(){return this._onlistprompts}set onlistprompts(n){this.warnIfRequestHandlerReplaced("onlistprompts",this._onlistprompts,n),this._onlistprompts=n,this.replaceRequestHandler(mo,async(o,r)=>{if(!this._onlistprompts)throw Error("No onlistprompts handler set");return this._onlistprompts(o.params,r)})}sendPromptListChanged(n={}){return this.notification({method:"notifications/prompts/list_changed",params:n})}assertCapabilityForMethod(n){}assertRequestHandlerCapability(n){}assertNotificationCapability(n){}assertTaskCapability(n){throw Error("Tasks are not supported in MCP Apps")}assertTaskHandlerCapability(n){throw Error("Task handlers are not supported in MCP Apps")}getCapabilities(){return this._capabilities}async _oninitialize(n){let o=n.params.protocolVersion;return this._appInfo!==void 0&&console.warn("[ext-apps] AppBridge received a second ui/initialize. The View may be double-mounting (e.g. React StrictMode in dev) without closing the previous App instance. Responding normally; the latest appInfo/appCapabilities replace the previous values."),this._appCapabilities=n.params.appCapabilities,this._appInfo=n.params.appInfo,{protocolVersion:zl.includes(o)?o:xo,hostCapabilities:this.getCapabilities(),hostInfo:this._hostInfo,hostContext:this._hostContext}}setHostContext(n){let o={},r=!1;for(let s of Object.keys(n)){let i=this._hostContext[s],a=n[s];Tl(i,a)||(o[s]=a,r=!0)}r&&(this._hostContext=n,this.sendHostContextChange(o))}sendHostContextChange(n){return this.notification({method:"ui/notifications/host-context-changed",params:n})}sendToolInput(n){return this.notification({method:"ui/notifications/tool-input",params:n})}sendToolInputPartial(n){return this.notification({method:"ui/notifications/tool-input-partial",params:n})}sendToolResult(n){return this.notification({method:"ui/notifications/tool-result",params:n})}sendToolCancelled(n){return this.notification({method:"ui/notifications/tool-cancelled",params:n})}sendSandboxResourceReady(n){return this.notification({method:"ui/notifications/sandbox-resource-ready",params:n})}teardownResource(n,o){return this.request({method:"ui/resource-teardown",params:n},pl,o)}callTool(n,o){return this.request({method:"tools/call",params:n},Pe,o)}listTools(n,o){return this.request({method:"tools/list",params:n},yo,o)}async connect(n){if(this.transport)throw Error("AppBridge is already connected. Call close() before connecting again.");if(this._initializedReceived=!1,this._client){let o=this._client.getServerCapabilities();if(!o)throw Error("Client server capabilities not available");o.tools&&(this.oncalltool=async(r,s)=>this._client.request({method:"tools/call",params:r},Pe,{signal:s.signal}),o.tools.listChanged&&this._client.setNotificationHandler(ko,r=>this.sendToolListChanged(r.params))),o.resources&&(this.onlistresources=async(r,s)=>this._client.request({method:"resources/list",params:r},co,{signal:s.signal}),this.onlistresourcetemplates=async(r,s)=>this._client.request({method:"resources/templates/list",params:r},lo,{signal:s.signal}),this.onreadresource=async(r,s)=>this._client.request({method:"resources/read",params:r},ho,{signal:s.signal}),o.resources.listChanged&&this._client.setNotificationHandler(fo,r=>this.sendResourceListChanged(r.params))),o.prompts&&(this.onlistprompts=async(r,s)=>this._client.request({method:"prompts/list",params:r},go,{signal:s.signal}),o.prompts.listChanged&&this._client.setNotificationHandler(vo,r=>this.sendPromptListChanged(r.params)))}return super.connect(n)}}function Tl(e,t){return JSON.stringify(e)===JSON.stringify(t)}const xl="ui/notifications/sandbox-proxy-ready",Il={name:"Grackle",version:"0.0.0"},$l=new Set(["http:","https:"]);function Pl(e){try{return $l.has(new URL(e).protocol)}catch{return!1}}function pn(e){return e||(typeof document<"u"&&document.documentElement.getAttribute("data-theme")==="dark"?"dark":"light")}function El(e,t,n,o,r,s){if(e.src)return Promise.resolve(!1);e.setAttribute("sandbox","allow-scripts allow-same-origin allow-forms");const i=Sl(r);i&&e.setAttribute("allow",i);const a=new Promise(u=>{const h=m=>{const g=m.data;m.source===e.contentWindow&&m.origin===n&&(g==null?void 0:g.method)===xl&&u(!0)};window.addEventListener("message",h,{signal:s}),s.addEventListener("abort",()=>u(!1),{once:!0})}),c=new URL(t,window.location.href);return o&&c.searchParams.set("csp",JSON.stringify(o)),e.src=c.href,a}function Te(e){Promise.resolve(e).catch(()=>{})}function Nl(e){const{widgetHtml:t,sandboxProxyUrl:n,csp:o,permissions:r,hostStyleVariables:s,theme:i,hostInfo:a,toolInput:c,toolResult:u,onCallTool:h,onOpenLink:m,onSendMessage:g,onUpdateModelContext:_,onSizeChange:v}=e;if(typeof window<"u"&&new URL(n,window.location.href).origin===window.location.origin)throw new Error("McpAppWidget: sandboxProxyUrl must be served from a DIFFERENT origin than the host.");const y=ce.useRef(null),x=ce.useRef(void 0),[L,C]=ce.useState(!1),V=ce.useRef({onCallTool:h,onOpenLink:m,onSendMessage:g,onUpdateModelContext:_,onSizeChange:v});V.current={onCallTool:h,onOpenLink:m,onSendMessage:g,onUpdateModelContext:_,onSizeChange:v};const K=JSON.stringify(o??null),D=JSON.stringify(r??null);return ce.useEffect(()=>{const T=y.current;if(!T)return;const O=new URL(n,window.location.href).origin,ee=new AbortController,{signal:Q}=ee,ze=()=>Q.aborted;let Re;return(async()=>{if(!await El(T,n,O,o,r,Q)||ze())return;const ie=new Rl(null,a??Il,{openLinks:{},updateModelContext:{text:{}}},{hostContext:{theme:pn(i),platform:"web",styles:{variables:s??jt()},containerDimensions:{maxHeight:6e3},displayMode:"inline",availableDisplayModes:["inline"]}});x.current=ie,ie.oncalltool=async F=>{const J=V.current.onCallTool;return J?J({name:F.name,arguments:F.arguments}):{isError:!0,content:[{type:"text",text:"No MCP client is connected to this host."}]}},ie.onopenlink=async({url:F})=>{const J=V.current.onOpenLink;return J?J(F):Pl(F)&&window.open(F,"_blank","noopener,noreferrer"),{}},ie.onmessage=async F=>{var J,ae;return(ae=(J=V.current).onSendMessage)==null||ae.call(J,F),{}},ie.onupdatemodelcontext=async F=>{var J,ae;return(ae=(J=V.current).onUpdateModelContext)==null||ae.call(J,F),{}},ie.onsizechange=({width:F,height:J})=>{var ae,Ht;F!==void 0&&(T.style.minWidth=`min(${F}px, 100%)`),J!==void 0&&(T.style.height=`${J}px`),(Ht=(ae=V.current).onSizeChange)==null||Ht.call(ae,{width:F,height:J})},ie.onrequestdisplaymode=async()=>({mode:"inline"});const $o=new Promise(F=>{ie.oninitialized=()=>F()});await ie.connect(new kl(T.contentWindow,T.contentWindow)),!ze()&&(await ie.sendSandboxResourceReady({html:t,csp:o,permissions:r}),await $o,!ze()&&(C(!0),Re=new ResizeObserver(([F])=>{const J=Math.round(F.contentRect.width);J>0&&Te(ie.sendHostContextChange({containerDimensions:{width:J,maxHeight:6e3}}))}),Re.observe(T)))})().catch(()=>{}),()=>{ee.abort(),C(!1),Re==null||Re.disconnect();const nt=x.current;x.current=void 0,nt&&Te(nt.teardownResource({})),T.removeAttribute("src")}},[t,n,K,D]),ce.useEffect(()=>{var T;L&&Te((T=x.current)==null?void 0:T.sendToolInput({arguments:c??{}}))},[L,c]),ce.useEffect(()=>{var T;!L||!u||Te((T=x.current)==null?void 0:T.sendToolResult(u))},[L,u]),ce.useEffect(()=>{var T;Te((T=x.current)==null?void 0:T.sendHostContextChange({theme:pn(i),styles:{variables:s??jt()}}))},[i,s]),Co.jsx("iframe",{ref:y,"data-testid":"mcp-app-widget",title:"MCP App widget",style:{width:"100%",border:"none",display:"block"}})}export{Nl as McpAppWidget};