@reqvire-org/ads 0.3.52 → 0.4.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/README.md +10 -9
- package/dist/assets.mjs +16 -2
- package/dist/behaviors.mjs +6 -5
- package/dist/boundaries.mjs +5 -5
- package/dist/browser-audit/first-render.mjs +22 -0
- package/dist/browser-audit/image-shape.mjs +36 -0
- package/dist/browser-audit/render-states.mjs +61 -35
- package/dist/browser-audit/worker.mjs +47 -12
- package/dist/browser-audit.mjs +75 -12
- package/dist/bun-compiler.mjs +14 -7
- package/dist/check-service.mjs +83 -0
- package/dist/check.mjs +20 -18
- package/dist/cli.mjs +5 -3
- package/dist/config.mjs +20 -41
- package/dist/contracts.d.mts +9 -0
- package/dist/finding-rules.mjs +8 -1
- package/dist/font-rules.mjs +103 -0
- package/dist/fonts-generated.mjs +32 -12
- package/dist/generated-entries.mjs +131 -0
- package/dist/icons.mjs +1 -1
- package/dist/init.mjs +11 -32
- package/dist/layers.mjs +7 -3
- package/dist/lint-config.mjs +4 -2
- package/dist/mcp/catalog.mjs +2 -1
- package/dist/mcp/context.mjs +3 -3
- package/dist/mcp/drafts.mjs +136 -121
- package/dist/mcp/mutations.mjs +65 -19
- package/dist/mcp/preview-watch.mjs +31 -5
- package/dist/mcp/preview-widget.bundle.js +50 -47
- package/dist/mcp/project-widget.bundle.js +45 -42
- package/dist/mcp/prompts.mjs +1 -1
- package/dist/mcp/server.mjs +81 -40
- package/dist/mcp/showcase-host.mjs +20 -7
- package/dist/mcp/widget.bundle.js +49 -46
- package/dist/oxlint.mjs +3 -2
- package/dist/program-cache.mjs +36 -0
- package/dist/public-api.mjs +2 -1
- package/dist/scenarios-compiler.mjs +82 -14
- package/dist/scenarios-vite.mjs +1 -1
- package/dist/scenarios.mjs +4 -3
- package/dist/showcase/client.bundle.js +27 -27
- package/dist/showcase/index.html +2 -2
- package/dist/skills/ads-break-ui/SKILL.md +25 -28
- package/dist/skills/ads-break-ui/references/behaviors.md +7 -6
- package/dist/skills/ads-break-ui/references/captures.md +7 -32
- package/dist/skills/ads-break-ui/references/contracts.md +58 -25
- package/dist/skills/ads-break-ui/references/drafts.md +59 -43
- package/dist/skills/ads-break-ui/references/evidence.md +1 -1
- package/dist/skills/ads-break-ui/references/guarded-editing.md +58 -47
- package/dist/skills/ads-break-ui/references/review.md +9 -8
- package/dist/skills/ads-break-ui/references/scenarios.md +1 -1
- package/dist/skills/ads-break-ui/references/validation.md +8 -4
- package/dist/skills/ads-break-ui/references/workflows.md +15 -8
- package/dist/skills/ads-designer/SKILL.md +30 -31
- package/dist/skills/ads-designer/references/accessibility.md +9 -5
- package/dist/skills/ads-designer/references/behaviors.md +7 -6
- package/dist/skills/ads-designer/references/branding.md +2 -2
- package/dist/skills/ads-designer/references/captures.md +7 -32
- package/dist/skills/ads-designer/references/cli.md +5 -1
- package/dist/skills/ads-designer/references/contracts.md +58 -25
- package/dist/skills/ads-designer/references/drafts.md +59 -43
- package/dist/skills/ads-designer/references/evidence.md +1 -1
- package/dist/skills/ads-designer/references/guarded-editing.md +58 -47
- package/dist/skills/ads-designer/references/performance.md +57 -6
- package/dist/skills/ads-designer/references/review.md +9 -8
- package/dist/skills/ads-designer/references/scenarios.md +1 -1
- package/dist/skills/ads-designer/references/validation.md +8 -4
- package/dist/skills/ads-designer/references/workflows.md +15 -8
- package/dist/skills/ads-import/SKILL.md +25 -28
- package/dist/skills/ads-import/references/behaviors.md +7 -6
- package/dist/skills/ads-import/references/captures.md +7 -32
- package/dist/skills/ads-import/references/cli.md +5 -1
- package/dist/skills/ads-import/references/contracts.md +58 -25
- package/dist/skills/ads-import/references/drafts.md +59 -43
- package/dist/skills/ads-import/references/evidence.md +1 -1
- package/dist/skills/ads-import/references/guarded-editing.md +58 -47
- package/dist/skills/ads-import/references/review.md +9 -8
- package/dist/skills/ads-import/references/scenarios.md +1 -1
- package/dist/skills/ads-import/references/validation.md +8 -4
- package/dist/skills/ads-import/references/workflows.md +15 -8
- package/dist/skills/ads-motion/SKILL.md +25 -28
- package/dist/skills/ads-motion/references/behaviors.md +7 -6
- package/dist/skills/ads-motion/references/captures.md +7 -32
- package/dist/skills/ads-motion/references/contracts.md +58 -25
- package/dist/skills/ads-motion/references/drafts.md +59 -43
- package/dist/skills/ads-motion/references/evidence.md +1 -1
- package/dist/skills/ads-motion/references/guarded-editing.md +58 -47
- package/dist/skills/ads-motion/references/review.md +9 -8
- package/dist/skills/ads-motion/references/scenarios.md +1 -1
- package/dist/skills/ads-motion/references/validation.md +8 -4
- package/dist/skills/ads-motion/references/workflows.md +15 -8
- package/dist/skills/ads-port/SKILL.md +25 -28
- package/dist/skills/ads-port/references/behaviors.md +7 -6
- package/dist/skills/ads-port/references/captures.md +7 -32
- package/dist/skills/ads-port/references/cli.md +5 -1
- package/dist/skills/ads-port/references/contracts.md +58 -25
- package/dist/skills/ads-port/references/drafts.md +59 -43
- package/dist/skills/ads-port/references/evidence.md +1 -1
- package/dist/skills/ads-port/references/guarded-editing.md +58 -47
- package/dist/skills/ads-port/references/native-implementation.md +6 -6
- package/dist/skills/ads-port/references/review.md +9 -8
- package/dist/skills/ads-port/references/scenarios.md +1 -1
- package/dist/skills/ads-port/references/validation.md +8 -4
- package/dist/skills/ads-port/references/workflows.md +15 -8
- package/dist/starters/preact/design-system/components/Layout/Grid/Grid.ads.contract.ts +6 -0
- package/dist/starters/preact/design-system/review/token-preview/TokenPreview.ads.contract.ts +6 -0
- package/dist/starters/preact/ds.config.json +0 -14
- package/dist/starters/react/README.md +9 -5
- package/dist/starters/react/design-system/brand/Icons/AppIcon/AppIcon.ads.fixture.ts +1 -1
- package/dist/starters/react/design-system/brand/Identity/Logo/Logo.ads.fixture.ts +2 -2
- package/dist/starters/react/design-system/components/Actions/Button/Button.ads.exports.ts +1 -0
- package/dist/starters/react/design-system/components/Actions/IconButton/IconButton.ads.exports.ts +1 -0
- package/dist/starters/react/design-system/components/Content/Icon/Icon.ads.exports.ts +1 -0
- package/dist/starters/react/design-system/components/Content/Image/Image.ads.exports.ts +1 -0
- package/dist/starters/react/design-system/components/Content/Logo/Logo.ads.exports.ts +1 -0
- package/dist/starters/react/design-system/components/Content/Logo/Logo.tsx +2 -2
- package/dist/starters/react/design-system/components/Forms/TextField/TextField.ads.exports.ts +1 -0
- package/dist/starters/react/design-system/components/Layout/Grid/Grid.ads.contract.ts +6 -0
- package/dist/starters/react/design-system/components/Layout/Grid/Grid.ads.exports.ts +1 -0
- package/dist/starters/react/design-system/controllers/Palette/Palette.ads.exports.ts +1 -0
- package/dist/starters/react/design-system/index.ts +3 -7
- package/dist/starters/react/design-system/patterns/Search/SearchBar/SearchBar.ads.exports.ts +1 -0
- package/dist/starters/react/design-system/review/brand-preview/BrandPreview.ads.exports.ts +1 -0
- package/dist/starters/react/design-system/review/demo-frame/DemoFrame.ads.exports.ts +1 -0
- package/dist/starters/react/design-system/review/grid-cell/GridCell.ads.exports.ts +1 -0
- package/dist/starters/react/design-system/review/index.ts +4 -3
- package/dist/starters/react/design-system/review/screen-frame/ScreenFrame.ads.exports.ts +1 -0
- package/dist/starters/react/design-system/review/token-preview/TokenPreview.ads.contract.ts +6 -0
- package/dist/starters/react/design-system/review/token-preview/TokenPreview.ads.exports.ts +1 -0
- package/dist/starters/react/design-system/styles.css +1 -0
- package/dist/starters/react/ds.config.json +0 -14
- package/dist/style-boundaries.mjs +7 -6
- package/dist/test-boundaries.mjs +2 -2
- package/dist/themes-watch.mjs +9 -3
- package/dist/token-fixtures.mjs +1 -1
- package/dist/unit-contracts.mjs +38 -4
- package/dist/units.mjs +16 -91
- package/dist/validation-checks.mjs +7 -1
- package/docs/ADS.md +10 -10
- package/docs/ARCHITECTURE.md +104 -44
- package/docs/BEHAVIORS.md +8 -7
- package/docs/CACHING.md +15 -6
- package/docs/CHANGELOG.md +107 -12
- package/docs/COMPARISON.md +1 -1
- package/docs/CONTRACTS.md +10 -25
- package/docs/GUIDE.md +98 -57
- package/docs/MCP.md +116 -151
- package/package.json +7 -7
- package/dist/contract-migration.mjs +0 -110
- package/dist/mcp/draft-exports.mjs +0 -40
- package/dist/mcp/edit-preparation.mjs +0 -115
|
@@ -1,77 +1,80 @@
|
|
|
1
|
-
var{create:Mm,defineProperty:Si,getOwnPropertyDescriptor:qm,getOwnPropertyNames:jm,getPrototypeOf:Lm}=Object,Um=Object.prototype.hasOwnProperty,gl=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),Sl=(e,t)=>{let o={};for(var r in e)Si(o,r,{get:e[r],enumerable:!0});if(t)Si(o,Symbol.toStringTag,{value:"Module"});return o},Zm=(e,t,o,r)=>{if(t&&typeof t==="object"||typeof t==="function"){for(var n=jm(t),i=0,a=n.length,c;i<a;i++)if(c=n[i],!Um.call(e,c)&&c!==o)Si(e,c,{get:((d)=>t[d]).bind(null,c),enumerable:!(r=qm(t,c))||r.enumerable})}return e},_l=(e,t,o)=>(o=e!=null?Mm(Lm(e)):{},Zm(t||!e||!e.__esModule?Si(o,"default",{value:e,enumerable:!0}):o,e));var Dm=new Set(["https://json-schema.org/draft/2019-09/schema","http://json-schema.org/draft/2019-09/schema"]);function yl(e){return typeof e==="string"&&Dm.has(e.replace(/#$/,""))}var bl,wa=Object.freeze({status:"aborted"});function g(e,t,o){function r(c,d){if(!c._zod)Object.defineProperty(c,"_zod",{value:{def:d,constr:a,traits:new Set},enumerable:!1});if(c._zod.traits.has(e))return;c._zod.traits.add(e),t(c,d);let p=a.prototype,m=Object.keys(p);for(let f=0;f<m.length;f++){let y=m[f];if(!(y in c))c[y]=p[y].bind(c)}}let n=o?.Parent??Object;class i extends n{}Object.defineProperty(i,"name",{value:e});function a(c){var d;let p=o?.Parent?new i:this;r(p,c),(d=p._zod).deferred??(d.deferred=[]);for(let m of p._zod.deferred)m();return p}return Object.defineProperty(a,"init",{value:r}),Object.defineProperty(a,Symbol.hasInstance,{value:(c)=>{if(o?.Parent&&c instanceof o.Parent)return!0;return c?._zod?.traits?.has(e)}}),Object.defineProperty(a,"name",{value:e}),a}var Vm=Symbol("zod_brand");class qe extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class Dr extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`);this.name="ZodEncodeError"}}(bl=globalThis).__zod_globalConfig??(bl.__zod_globalConfig={});var mo=globalThis.__zod_globalConfig;function le(e){if(e)Object.assign(mo,e);return mo}function yi(e){let t=Object.values(e).filter((r)=>typeof r==="number");return Object.entries(e).filter(([r,n])=>t.indexOf(+r)===-1).map(([r,n])=>n)}function xa(e,t="|"){return e.map((o)=>ka(o)).join(t)}function Vr(e,t){if(typeof t==="bigint")return t.toString();return t}function Hr(e){return{get value(){{let o=e();return Object.defineProperty(this,"value",{value:o}),o}throw Error("cached value already set")}}}function bi(e){return e===null||e===void 0}function vi(e){let t=e.startsWith("^")?1:0,o=e.endsWith("$")?e.length-1:e.length;return e.slice(t,o)}function zl(e,t){let o=e/t,r=Math.round(o),n=Number.EPSILON*Math.max(Math.abs(o),1);if(Math.abs(o-r)<n)return 0;return o-r}var vl=Symbol("evaluating");function L(e,t,o){let r=void 0;Object.defineProperty(e,t,{get(){if(r===vl)return;if(r===void 0)r=vl,r=o();return r},set(n){Object.defineProperty(e,t,{value:n})},configurable:!0})}function Pt(e,t,o){Object.defineProperty(e,t,{value:o,writable:!0,enumerable:!0,configurable:!0})}function Qe(...e){let t={};for(let o of e){let r=Object.getOwnPropertyDescriptors(o);Object.assign(t,r)}return Object.defineProperties({},t)}function Pa(e){return JSON.stringify(e)}function wl(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}var Ta="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function fo(e){return typeof e==="object"&&e!==null&&!Array.isArray(e)}var Rl=Hr(()=>{if(mo.jitless)return!1;if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{return new Function(""),!0}catch(e){return!1}});function Tt(e){if(fo(e)===!1)return!1;let t=e.constructor;if(t===void 0)return!0;if(typeof t!=="function")return!0;let o=t.prototype;if(fo(o)===!1)return!1;if(Object.prototype.hasOwnProperty.call(o,"isPrototypeOf")===!1)return!1;return!0}function Ea(e){if(Tt(e))return{...e};if(Array.isArray(e))return[...e];if(e instanceof Map)return new Map(e);if(e instanceof Set)return new Set(e);return e}var xl=new Set(["string","number","symbol"]);function Xe(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function ze(e,t,o){let r=new e._zod.constr(t??e._zod.def);if(!t||o?.parent)r._zod.parent=e;return r}function T(e){let t=e;if(!t)return{};if(typeof t==="string")return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw Error("Cannot specify both `message` and `error` params");t.error=t.message}if(delete t.message,typeof t.error==="string")return{...t,error:()=>t.error};return t}function ka(e){if(typeof e==="bigint")return e.toString()+"n";if(typeof e==="string")return`"${e}"`;return`${e}`}function Pl(e){return Object.keys(e).filter((t)=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}var Tl={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-340282346638528860000000000000000000000,340282346638528860000000000000000000000],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function Hm(e,t){let o=e._zod.def,r=o.checks;if(r&&r.length>0)throw Error(".pick() cannot be used on object schemas containing refinements");let i=Qe(e._zod.def,{get shape(){let a={};for(let c in t){if(!(c in o.shape))throw Error(`Unrecognized key: "${c}"`);if(!t[c])continue;a[c]=o.shape[c]}return Pt(this,"shape",a),a},checks:[]});return ze(e,i)}function Fm(e,t){let o=e._zod.def,r=o.checks;if(r&&r.length>0)throw Error(".omit() cannot be used on object schemas containing refinements");let i=Qe(e._zod.def,{get shape(){let a={...e._zod.def.shape};for(let c in t){if(!(c in o.shape))throw Error(`Unrecognized key: "${c}"`);if(!t[c])continue;delete a[c]}return Pt(this,"shape",a),a},checks:[]});return ze(e,i)}function Jm(e,t){if(!Tt(t))throw Error("Invalid input to extend: expected a plain object");let o=e._zod.def.checks;if(o&&o.length>0){let i=e._zod.def.shape;for(let a in t)if(Object.getOwnPropertyDescriptor(i,a)!==void 0)throw Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}let n=Qe(e._zod.def,{get shape(){let i={...e._zod.def.shape,...t};return Pt(this,"shape",i),i}});return ze(e,n)}function Bm(e,t){if(!Tt(t))throw Error("Invalid input to safeExtend: expected a plain object");let o=Qe(e._zod.def,{get shape(){let r={...e._zod.def.shape,...t};return Pt(this,"shape",r),r}});return ze(e,o)}function Gm(e,t){if(e._zod.def.checks?.length)throw Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");let o=Qe(e._zod.def,{get shape(){let r={...e._zod.def.shape,...t._zod.def.shape};return Pt(this,"shape",r),r},get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]});return ze(e,o)}function Wm(e,t,o){let n=t._zod.def.checks;if(n&&n.length>0)throw Error(".partial() cannot be used on object schemas containing refinements");let a=Qe(t._zod.def,{get shape(){let c=t._zod.def.shape,d={...c};if(o)for(let p in o){if(!(p in c))throw Error(`Unrecognized key: "${p}"`);if(!o[p])continue;d[p]=e?new e({type:"optional",innerType:c[p]}):c[p]}else for(let p in c)d[p]=e?new e({type:"optional",innerType:c[p]}):c[p];return Pt(this,"shape",d),d},checks:[]});return ze(t,a)}function Km(e,t,o){let r=Qe(t._zod.def,{get shape(){let n=t._zod.def.shape,i={...n};if(o)for(let a in o){if(!(a in i))throw Error(`Unrecognized key: "${a}"`);if(!o[a])continue;i[a]=new e({type:"nonoptional",innerType:n[a]})}else for(let a in n)i[a]=new e({type:"nonoptional",innerType:n[a]});return Pt(this,"shape",i),i}});return ze(t,r)}function Et(e,t=0){if(e.aborted===!0)return!0;for(let o=t;o<e.issues.length;o++)if(e.issues[o]?.continue!==!0)return!0;return!1}function El(e,t=0){if(e.aborted===!0)return!0;for(let o=t;o<e.issues.length;o++)if(e.issues[o]?.continue===!1)return!0;return!1}function et(e,t){return t.map((o)=>{var r;return(r=o).path??(r.path=[]),o.path.unshift(e),o})}function _i(e){return typeof e==="string"?e:e?.message}function we(e,t,o){let r=e.message?e.message:_i(e.inst?._zod.def?.error?.(e))??_i(t?.error?.(e))??_i(o.customError?.(e))??_i(o.localeError?.(e))??"Invalid input",{inst:n,continue:i,input:a,...c}=e;if(c.path??(c.path=[]),c.message=r,t?.reportInput)c.input=a;return c}function zi(e){if(Array.isArray(e))return"array";if(typeof e==="string")return"string";return"unknown"}function kl(e){let t=typeof e;switch(t){case"number":return Number.isNaN(e)?"nan":"number";case"object":{if(e===null)return"null";if(Array.isArray(e))return"array";let o=e;if(o&&Object.getPrototypeOf(o)!==Object.prototype&&"constructor"in o&&o.constructor)return o.constructor.name}}return t}function kt(...e){let[t,o,r]=e;if(typeof t==="string")return{message:t,code:"custom",input:o,inst:r};return{...t}}var $l=(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,Vr,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},wi=g("$ZodError",$l),$a=g("$ZodError",$l,{Parent:Error});function Ca(e,t=(o)=>o.message){let o={},r=[];for(let n of e.issues)if(n.path.length>0)o[n.path[0]]=o[n.path[0]]||[],o[n.path[0]].push(t(n));else r.push(t(n));return{formErrors:r,fieldErrors:o}}function Ia(e,t=(o)=>o.message){let o={_errors:[]},r=(n,i=[])=>{for(let a of n.issues)if(a.code==="invalid_union"&&a.errors.length)a.errors.map((c)=>r({issues:c},[...i,...a.path]));else if(a.code==="invalid_key")r({issues:a.issues},[...i,...a.path]);else if(a.code==="invalid_element")r({issues:a.issues},[...i,...a.path]);else{let c=[...i,...a.path];if(c.length===0)o._errors.push(t(a));else{let d=o,p=0;while(p<c.length){let m=c[p];if(p!==c.length-1)d[m]=d[m]||{_errors:[]};else d[m]=d[m]||{_errors:[]},d[m]._errors.push(t(a));d=d[m],p++}}}};return r(e),o}var Ri=(e)=>(t,o,r,n)=>{let i=r?{...r,async:!1}:{async:!1},a=t._zod.run({value:o,issues:[]},i);if(a instanceof Promise)throw new qe;if(a.issues.length){let c=new(n?.Err??e)(a.issues.map((d)=>we(d,i,le())));throw Ta(c,n?.callee),c}return a.value};var xi=(e)=>async(t,o,r,n)=>{let i=r?{...r,async:!0}:{async:!0},a=t._zod.run({value:o,issues:[]},i);if(a instanceof Promise)a=await a;if(a.issues.length){let c=new(n?.Err??e)(a.issues.map((d)=>we(d,i,le())));throw Ta(c,n?.callee),c}return a.value};var Fr=(e)=>(t,o,r)=>{let n=r?{...r,async:!1}:{async:!1},i=t._zod.run({value:o,issues:[]},n);if(i instanceof Promise)throw new qe;return i.issues.length?{success:!1,error:new(e??wi)(i.issues.map((a)=>we(a,n,le())))}:{success:!0,data:i.value}},Cl=Fr($a),Jr=(e)=>async(t,o,r)=>{let n=r?{...r,async:!0}:{async:!0},i=t._zod.run({value:o,issues:[]},n);if(i instanceof Promise)i=await i;return i.issues.length?{success:!1,error:new e(i.issues.map((a)=>we(a,n,le())))}:{success:!0,data:i.value}},Il=Jr($a),Ol=(e)=>(t,o,r)=>{let n=r?{...r,direction:"backward"}:{direction:"backward"};return Ri(e)(t,o,n)};var Nl=(e)=>(t,o,r)=>Ri(e)(t,o,r);var Al=(e)=>async(t,o,r)=>{let n=r?{...r,direction:"backward"}:{direction:"backward"};return xi(e)(t,o,n)};var Ml=(e)=>async(t,o,r)=>xi(e)(t,o,r);var ql=(e)=>(t,o,r)=>{let n=r?{...r,direction:"backward"}:{direction:"backward"};return Fr(e)(t,o,n)};var jl=(e)=>(t,o,r)=>Fr(e)(t,o,r);var Ll=(e)=>async(t,o,r)=>{let n=r?{...r,direction:"backward"}:{direction:"backward"};return Jr(e)(t,o,n)};var Ul=(e)=>async(t,o,r)=>Jr(e)(t,o,r);var Zl=/^[cC][0-9a-z]{6,}$/,Dl=/^[0-9a-z]+$/,Vl=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,Hl=/^[0-9a-vA-V]{20}$/,Fl=/^[A-Za-z0-9]{27}$/,Jl=/^[a-zA-Z0-9_-]{21}$/,Bl=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/;var Gl=/^([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})$/,Oa=(e)=>{if(!e)return/^([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)$/;return 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})$`)};var Wl=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;var Qm="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function Kl(){return new RegExp(Qm,"u")}var Yl=/^(?:(?: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])$/,Ql=/^(([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}|:))$/;var Xl=/^((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])$/,eu=/^(([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])$/,tu=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Na=/^[A-Za-z0-9_-]*$/;var ou=/^https?$/,ru=/^\+[1-9]\d{6,14}$/,nu="(?:(?:\\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])))",su=new RegExp(`^${nu}$`);function iu(e){return typeof e.precision==="number"?e.precision===-1?"(?:[01]\\d|2[0-3]):[0-5]\\d":e.precision===0?"(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d":`(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d\\.\\d{${e.precision}}`:"(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?"}function au(e){return new RegExp(`^${iu(e)}$`)}function cu(e){let t=iu({precision:e.precision}),o=["Z"];if(e.local)o.push("");if(e.offset)o.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");let r=`${t}(?:${o.join("|")})`;return new RegExp(`^${nu}T(?:${r})$`)}var lu=(e)=>{let t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)};var uu=/^-?\d+$/,Aa=/^-?\d+(?:\.\d+)?$/,du=/^(?:true|false)$/i,pu=/^null$/i;var hu=/^undefined$/i;var mu=/^[^A-Z]*$/,fu=/^[^a-z]*$/;var ee=g("$ZodCheck",(e,t)=>{var o;e._zod??(e._zod={}),e._zod.def=t,(o=e._zod).onattach??(o.onattach=[])}),gu={number:"number",bigint:"bigint",object:"date"},Ma=g("$ZodCheckLessThan",(e,t)=>{ee.init(e,t);let o=gu[typeof t.value];e._zod.onattach.push((r)=>{let n=r._zod.bag,i=(t.inclusive?n.maximum:n.exclusiveMaximum)??Number.POSITIVE_INFINITY;if(t.value<i)if(t.inclusive)n.maximum=t.value;else n.exclusiveMaximum=t.value}),e._zod.check=(r)=>{if(t.inclusive?r.value<=t.value:r.value<t.value)return;r.issues.push({origin:o,code:"too_big",maximum:typeof t.value==="object"?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),qa=g("$ZodCheckGreaterThan",(e,t)=>{ee.init(e,t);let o=gu[typeof t.value];e._zod.onattach.push((r)=>{let n=r._zod.bag,i=(t.inclusive?n.minimum:n.exclusiveMinimum)??Number.NEGATIVE_INFINITY;if(t.value>i)if(t.inclusive)n.minimum=t.value;else n.exclusiveMinimum=t.value}),e._zod.check=(r)=>{if(t.inclusive?r.value>=t.value:r.value>t.value)return;r.issues.push({origin:o,code:"too_small",minimum:typeof t.value==="object"?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Su=g("$ZodCheckMultipleOf",(e,t)=>{ee.init(e,t),e._zod.onattach.push((o)=>{var r;(r=o._zod.bag).multipleOf??(r.multipleOf=t.value)}),e._zod.check=(o)=>{if(typeof o.value!==typeof t.value)throw Error("Cannot mix number and bigint in multiple_of check.");if(typeof o.value==="bigint"?o.value%t.value===BigInt(0):zl(o.value,t.value)===0)return;o.issues.push({origin:typeof o.value,code:"not_multiple_of",divisor:t.value,input:o.value,inst:e,continue:!t.abort})}}),_u=g("$ZodCheckNumberFormat",(e,t)=>{ee.init(e,t),t.format=t.format||"float64";let o=t.format?.includes("int"),r=o?"int":"number",[n,i]=Tl[t.format];e._zod.onattach.push((a)=>{let c=a._zod.bag;if(c.format=t.format,c.minimum=n,c.maximum=i,o)c.pattern=uu}),e._zod.check=(a)=>{let c=a.value;if(o){if(!Number.isInteger(c)){a.issues.push({expected:r,format:t.format,code:"invalid_type",continue:!1,input:c,inst:e});return}if(!Number.isSafeInteger(c)){if(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:r,inclusive:!0,continue:!t.abort});else 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:r,inclusive:!0,continue:!t.abort});return}}if(c<n)a.issues.push({origin:"number",input:c,code:"too_small",minimum:n,inclusive:!0,inst:e,continue:!t.abort});if(c>i)a.issues.push({origin:"number",input:c,code:"too_big",maximum:i,inclusive:!0,inst:e,continue:!t.abort})}});var yu=g("$ZodCheckMaxLength",(e,t)=>{var o;ee.init(e,t),(o=e._zod.def).when??(o.when=(r)=>{let n=r.value;return!bi(n)&&n.length!==void 0}),e._zod.onattach.push((r)=>{let n=r._zod.bag.maximum??Number.POSITIVE_INFINITY;if(t.maximum<n)r._zod.bag.maximum=t.maximum}),e._zod.check=(r)=>{let n=r.value;if(n.length<=t.maximum)return;let a=zi(n);r.issues.push({origin:a,code:"too_big",maximum:t.maximum,inclusive:!0,input:n,inst:e,continue:!t.abort})}}),bu=g("$ZodCheckMinLength",(e,t)=>{var o;ee.init(e,t),(o=e._zod.def).when??(o.when=(r)=>{let n=r.value;return!bi(n)&&n.length!==void 0}),e._zod.onattach.push((r)=>{let n=r._zod.bag.minimum??Number.NEGATIVE_INFINITY;if(t.minimum>n)r._zod.bag.minimum=t.minimum}),e._zod.check=(r)=>{let n=r.value;if(n.length>=t.minimum)return;let a=zi(n);r.issues.push({origin:a,code:"too_small",minimum:t.minimum,inclusive:!0,input:n,inst:e,continue:!t.abort})}}),vu=g("$ZodCheckLengthEquals",(e,t)=>{var o;ee.init(e,t),(o=e._zod.def).when??(o.when=(r)=>{let n=r.value;return!bi(n)&&n.length!==void 0}),e._zod.onattach.push((r)=>{let n=r._zod.bag;n.minimum=t.length,n.maximum=t.length,n.length=t.length}),e._zod.check=(r)=>{let n=r.value,i=n.length;if(i===t.length)return;let a=zi(n),c=i>t.length;r.issues.push({origin:a,...c?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:r.value,inst:e,continue:!t.abort})}}),Gr=g("$ZodCheckStringFormat",(e,t)=>{var o,r;if(ee.init(e,t),e._zod.onattach.push((n)=>{let i=n._zod.bag;if(i.format=t.format,t.pattern)i.patterns??(i.patterns=new Set),i.patterns.add(t.pattern)}),t.pattern)(o=e._zod).check??(o.check=(n)=>{if(t.pattern.lastIndex=0,t.pattern.test(n.value))return;n.issues.push({origin:"string",code:"invalid_format",format:t.format,input:n.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})});else(r=e._zod).check??(r.check=()=>{})}),zu=g("$ZodCheckRegex",(e,t)=>{Gr.init(e,t),e._zod.check=(o)=>{if(t.pattern.lastIndex=0,t.pattern.test(o.value))return;o.issues.push({origin:"string",code:"invalid_format",format:"regex",input:o.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),wu=g("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=mu),Gr.init(e,t)}),Ru=g("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=fu),Gr.init(e,t)}),xu=g("$ZodCheckIncludes",(e,t)=>{ee.init(e,t);let o=Xe(t.includes),r=new RegExp(typeof t.position==="number"?`^.{${t.position}}${o}`:o);t.pattern=r,e._zod.onattach.push((n)=>{let i=n._zod.bag;i.patterns??(i.patterns=new Set),i.patterns.add(r)}),e._zod.check=(n)=>{if(n.value.includes(t.includes,t.position))return;n.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:n.value,inst:e,continue:!t.abort})}}),Pu=g("$ZodCheckStartsWith",(e,t)=>{ee.init(e,t);let o=new RegExp(`^${Xe(t.prefix)}.*`);t.pattern??(t.pattern=o),e._zod.onattach.push((r)=>{let n=r._zod.bag;n.patterns??(n.patterns=new Set),n.patterns.add(o)}),e._zod.check=(r)=>{if(r.value.startsWith(t.prefix))return;r.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:r.value,inst:e,continue:!t.abort})}}),Tu=g("$ZodCheckEndsWith",(e,t)=>{ee.init(e,t);let o=new RegExp(`.*${Xe(t.suffix)}$`);t.pattern??(t.pattern=o),e._zod.onattach.push((r)=>{let n=r._zod.bag;n.patterns??(n.patterns=new Set),n.patterns.add(o)}),e._zod.check=(r)=>{if(r.value.endsWith(t.suffix))return;r.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:r.value,inst:e,continue:!t.abort})}});var Eu=g("$ZodCheckOverwrite",(e,t)=>{ee.init(e,t),e._zod.check=(o)=>{o.value=t.tx(o.value)}});class ja{constructor(e=[]){if(this.content=[],this.indent=0,this)this.args=e}indented(e){this.indent+=1,e(this),this.indent-=1}write(e){if(typeof e==="function"){e(this,{execution:"sync"}),e(this,{execution:"async"});return}let o=e.split(`
|
|
2
|
-
`).filter((
|
|
3
|
-
`))}}var $u={major:4,minor:4,patch:3};var U=g("$ZodType",(e,t)=>{var o;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=$u;let r=[...e._zod.def.checks??[]];if(e._zod.traits.has("$ZodCheck"))r.unshift(e);for(let n of r)for(let i of n._zod.onattach)i(e);if(r.length===0)(o=e._zod).deferred??(o.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let n=(a,c,d)=>{let p=Et(a),m;for(let f of c){if(f._zod.def.when){if(El(a))continue;if(!f._zod.def.when(a))continue}else if(p)continue;let y=a.issues.length,S=f._zod.check(a);if(S instanceof Promise&&d?.async===!1)throw new qe;if(m||S instanceof Promise)m=(m??Promise.resolve()).then(async()=>{if(await S,a.issues.length===y)return;if(!p)p=Et(a,y)});else{if(a.issues.length===y)continue;if(!p)p=Et(a,y)}}if(m)return m.then(()=>a);return a},i=(a,c,d)=>{if(Et(a))return a.aborted=!0,a;let p=n(c,r,d);if(p instanceof Promise){if(d.async===!1)throw new qe;return p.then((m)=>e._zod.parse(m,d))}return e._zod.parse(p,d)};e._zod.run=(a,c)=>{if(c.skipChecks)return e._zod.parse(a,c);if(c.direction==="backward"){let p=e._zod.parse({value:a.value,issues:[]},{...c,skipChecks:!0});if(p instanceof Promise)return p.then((m)=>i(m,a,c));return i(p,a,c)}let d=e._zod.parse(a,c);if(d instanceof Promise){if(c.async===!1)throw new qe;return d.then((p)=>n(p,r,c))}return n(d,r,c)}}L(e,"~standard",()=>({validate:(n)=>{try{let i=Cl(e,n);return i.success?{value:i.data}:{issues:i.error?.issues}}catch(i){return Il(e,n).then((a)=>a.success?{value:a.data}:{issues:a.error?.issues})}},vendor:"zod",version:1}))}),Ei=g("$ZodString",(e,t)=>{U.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??lu(e._zod.bag),e._zod.parse=(o,r)=>{if(t.coerce)try{o.value=String(o.value)}catch(n){}if(typeof o.value==="string")return o;return o.issues.push({expected:"string",code:"invalid_type",input:o.value,inst:e}),o}}),H=g("$ZodStringFormat",(e,t)=>{Gr.init(e,t),Ei.init(e,t)}),Lu=g("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=Gl),H.init(e,t)}),Uu=g("$ZodUUID",(e,t)=>{if(t.version){let r={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(r===void 0)throw Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=Oa(r))}else t.pattern??(t.pattern=Oa());H.init(e,t)}),Zu=g("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=Wl),H.init(e,t)}),Du=g("$ZodURL",(e,t)=>{H.init(e,t),e._zod.check=(o)=>{try{let r=o.value.trim();if(!t.normalize&&t.protocol?.source===ou.source){if(!/^https?:\/\//i.test(r)){o.issues.push({code:"invalid_format",format:"url",note:"Invalid URL format",input:o.value,inst:e,continue:!t.abort});return}}let n=new URL(r);if(t.hostname){if(t.hostname.lastIndex=0,!t.hostname.test(n.hostname))o.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:t.hostname.source,input:o.value,inst:e,continue:!t.abort})}if(t.protocol){if(t.protocol.lastIndex=0,!t.protocol.test(n.protocol.endsWith(":")?n.protocol.slice(0,-1):n.protocol))o.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:o.value,inst:e,continue:!t.abort})}if(t.normalize)o.value=n.href;else o.value=r;return}catch(r){o.issues.push({code:"invalid_format",format:"url",input:o.value,inst:e,continue:!t.abort})}}}),Vu=g("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=Kl()),H.init(e,t)}),Hu=g("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=Jl),H.init(e,t)}),Fu=g("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=Zl),H.init(e,t)}),Ju=g("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=Dl),H.init(e,t)}),Bu=g("$ZodULID",(e,t)=>{t.pattern??(t.pattern=Vl),H.init(e,t)}),Gu=g("$ZodXID",(e,t)=>{t.pattern??(t.pattern=Hl),H.init(e,t)}),Wu=g("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=Fl),H.init(e,t)}),Ku=g("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=cu(t)),H.init(e,t)}),Yu=g("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=su),H.init(e,t)}),Qu=g("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=au(t)),H.init(e,t)}),Xu=g("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=Bl),H.init(e,t)}),ed=g("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=Yl),H.init(e,t),e._zod.bag.format="ipv4"}),td=g("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=Ql),H.init(e,t),e._zod.bag.format="ipv6",e._zod.check=(o)=>{try{new URL(`http://[${o.value}]`)}catch{o.issues.push({code:"invalid_format",format:"ipv6",input:o.value,inst:e,continue:!t.abort})}}});var od=g("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=Xl),H.init(e,t)}),rd=g("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=eu),H.init(e,t),e._zod.check=(o)=>{let r=o.value.split("/");try{if(r.length!==2)throw Error();let[n,i]=r;if(!i)throw Error();let a=Number(i);if(`${a}`!==i)throw Error();if(a<0||a>128)throw Error();new URL(`http://[${n}]`)}catch{o.issues.push({code:"invalid_format",format:"cidrv6",input:o.value,inst:e,continue:!t.abort})}}});function nd(e){if(e==="")return!0;if(/\s/.test(e))return!1;if(e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}var sd=g("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=tu),H.init(e,t),e._zod.bag.contentEncoding="base64",e._zod.check=(o)=>{if(nd(o.value))return;o.issues.push({code:"invalid_format",format:"base64",input:o.value,inst:e,continue:!t.abort})}});function Xm(e){if(!Na.test(e))return!1;let t=e.replace(/[-_]/g,(r)=>r==="-"?"+":"/"),o=t.padEnd(Math.ceil(t.length/4)*4,"=");return nd(o)}var id=g("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=Na),H.init(e,t),e._zod.bag.contentEncoding="base64url",e._zod.check=(o)=>{if(Xm(o.value))return;o.issues.push({code:"invalid_format",format:"base64url",input:o.value,inst:e,continue:!t.abort})}}),ad=g("$ZodE164",(e,t)=>{t.pattern??(t.pattern=ru),H.init(e,t)});function ef(e,t=null){try{let o=e.split(".");if(o.length!==3)return!1;let[r]=o;if(!r)return!1;let n=JSON.parse(atob(r));if("typ"in n&&n?.typ!=="JWT")return!1;if(!n.alg)return!1;if(t&&(!("alg"in n)||n.alg!==t))return!1;return!0}catch{return!1}}var cd=g("$ZodJWT",(e,t)=>{H.init(e,t),e._zod.check=(o)=>{if(ef(o.value,t.alg))return;o.issues.push({code:"invalid_format",format:"jwt",input:o.value,inst:e,continue:!t.abort})}});var Ua=g("$ZodNumber",(e,t)=>{U.init(e,t),e._zod.pattern=e._zod.bag.pattern??Aa,e._zod.parse=(o,r)=>{if(t.coerce)try{o.value=Number(o.value)}catch(a){}let n=o.value;if(typeof n==="number"&&!Number.isNaN(n)&&Number.isFinite(n))return o;let i=typeof n==="number"?Number.isNaN(n)?"NaN":!Number.isFinite(n)?"Infinity":void 0:void 0;return o.issues.push({expected:"number",code:"invalid_type",input:n,inst:e,...i?{received:i}:{}}),o}}),ld=g("$ZodNumberFormat",(e,t)=>{_u.init(e,t),Ua.init(e,t)}),ud=g("$ZodBoolean",(e,t)=>{U.init(e,t),e._zod.pattern=du,e._zod.parse=(o,r)=>{if(t.coerce)try{o.value=Boolean(o.value)}catch(i){}let n=o.value;if(typeof n==="boolean")return o;return o.issues.push({expected:"boolean",code:"invalid_type",input:n,inst:e}),o}});var dd=g("$ZodUndefined",(e,t)=>{U.init(e,t),e._zod.pattern=hu,e._zod.values=new Set([void 0]),e._zod.parse=(o,r)=>{let n=o.value;if(typeof n>"u")return o;return o.issues.push({expected:"undefined",code:"invalid_type",input:n,inst:e}),o}}),pd=g("$ZodNull",(e,t)=>{U.init(e,t),e._zod.pattern=pu,e._zod.values=new Set([null]),e._zod.parse=(o,r)=>{let n=o.value;if(n===null)return o;return o.issues.push({expected:"null",code:"invalid_type",input:n,inst:e}),o}}),hd=g("$ZodAny",(e,t)=>{U.init(e,t),e._zod.parse=(o)=>o}),md=g("$ZodUnknown",(e,t)=>{U.init(e,t),e._zod.parse=(o)=>o}),fd=g("$ZodNever",(e,t)=>{U.init(e,t),e._zod.parse=(o,r)=>(o.issues.push({expected:"never",code:"invalid_type",input:o.value,inst:e}),o)});function Cu(e,t,o){if(e.issues.length)t.issues.push(...et(o,e.issues));t.value[o]=e.value}var gd=g("$ZodArray",(e,t)=>{U.init(e,t),e._zod.parse=(o,r)=>{let n=o.value;if(!Array.isArray(n))return o.issues.push({expected:"array",code:"invalid_type",input:n,inst:e}),o;o.value=Array(n.length);let i=[];for(let a=0;a<n.length;a++){let c=n[a],d=t.element._zod.run({value:c,issues:[]},r);if(d instanceof Promise)i.push(d.then((p)=>Cu(p,o,a)));else Cu(d,o,a)}if(i.length)return Promise.all(i).then(()=>o);return o}});function Ti(e,t,o,r,n,i){let a=o in r;if(e.issues.length){if(n&&i&&!a)return;t.issues.push(...et(o,e.issues))}if(!a&&!n){if(!e.issues.length)t.issues.push({code:"invalid_type",expected:"nonoptional",input:void 0,path:[o]});return}if(e.value===void 0){if(a)t.value[o]=void 0}else t.value[o]=e.value}function Sd(e){let t=Object.keys(e.shape);for(let r of t)if(!e.shape?.[r]?._zod?.traits?.has("$ZodType"))throw Error(`Invalid element at key "${r}": expected a Zod schema`);let o=Pl(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(o)}}function _d(e,t,o,r,n,i){let a=[],c=n.keySet,d=n.catchall._zod,p=d.def.type,m=d.optin==="optional",f=d.optout==="optional";for(let y in t){if(y==="__proto__")continue;if(c.has(y))continue;if(p==="never"){a.push(y);continue}let S=d.run({value:t[y],issues:[]},r);if(S instanceof Promise)e.push(S.then((w)=>Ti(w,o,y,t,m,f)));else Ti(S,o,y,t,m,f)}if(a.length)o.issues.push({code:"unrecognized_keys",keys:a,input:t,inst:i});if(!e.length)return o;return Promise.all(e).then(()=>o)}var tf=g("$ZodObject",(e,t)=>{if(U.init(e,t),!Object.getOwnPropertyDescriptor(t,"shape")?.get){let c=t.shape;Object.defineProperty(t,"shape",{get:()=>{let d={...c};return Object.defineProperty(t,"shape",{value:d}),d}})}let r=Hr(()=>Sd(t));L(e._zod,"propValues",()=>{let c=t.shape,d={};for(let p in c){let m=c[p]._zod;if(m.values){d[p]??(d[p]=new Set);for(let f of m.values)d[p].add(f)}}return d});let n=fo,i=t.catchall,a;e._zod.parse=(c,d)=>{a??(a=r.value);let p=c.value;if(!n(p))return c.issues.push({expected:"object",code:"invalid_type",input:p,inst:e}),c;c.value={};let m=[],f=a.shape;for(let y of a.keys){let S=f[y],w=S._zod.optin==="optional",x=S._zod.optout==="optional",R=S._zod.run({value:p[y],issues:[]},d);if(R instanceof Promise)m.push(R.then((C)=>Ti(C,c,y,p,w,x)));else Ti(R,c,y,p,w,x)}if(!i)return m.length?Promise.all(m).then(()=>c):c;return _d(m,p,c,d,r.value,e)}}),yd=g("$ZodObjectJIT",(e,t)=>{tf.init(e,t);let o=e._zod.parse,r=Hr(()=>Sd(t)),n=(y)=>{let S=new ja(["shape","payload","ctx"]),w=r.value,x=(I)=>{let M=Pa(I);return`shape[${M}]._zod.run({ value: input[${M}], issues: [] }, ctx)`};S.write("const input = payload.value;");let R=Object.create(null),C=0;for(let I of w.keys)R[I]=`key_${C++}`;S.write("const newResult = {};");for(let I of w.keys){let M=R[I],A=Pa(I),j=y[I],V=j?._zod?.optin==="optional",ae=j?._zod?.optout==="optional";if(S.write(`const ${M} = ${x(I)};`),V&&ae)S.write(`
|
|
4
|
-
if (${
|
|
5
|
-
if (${
|
|
6
|
-
payload.issues = payload.issues.concat(${
|
|
1
|
+
var{create:Cf,defineProperty:Oi,getOwnPropertyDescriptor:If,getOwnPropertyNames:Of,getPrototypeOf:Nf}=Object,Af=Object.prototype.hasOwnProperty,Dl=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),Vl=(e,t)=>{let o={};for(var r in e)Oi(o,r,{get:e[r],enumerable:!0});if(t)Oi(o,Symbol.toStringTag,{value:"Module"});return o},Mf=(e,t,o,r)=>{if(t&&typeof t==="object"||typeof t==="function"){for(var n=Of(t),s=0,i=n.length,c;s<i;s++)if(c=n[s],!Af.call(e,c)&&c!==o)Oi(e,c,{get:((l)=>t[l]).bind(null,c),enumerable:!(r=If(t,c))||r.enumerable})}return e},Hl=(e,t,o)=>(o=e!=null?Cf(Nf(e)):{},Mf(t||!e||!e.__esModule?Oi(o,"default",{value:e,enumerable:!0}):o,e));var qf=new Set(["https://json-schema.org/draft/2020-12/schema","http://json-schema.org/draft/2020-12/schema"]),Fl=new Set(["https://json-schema.org/draft/2019-09/schema","http://json-schema.org/draft/2019-09/schema"]),jf=new Set(["https://json-schema.org/draft-07/schema","http://json-schema.org/draft-07/schema"]),Lf=new Set(["https://json-schema.org/draft-06/schema","http://json-schema.org/draft-06/schema"]);function Jl(e){return typeof e==="string"&&Fl.has(e.replace(/#$/,""))}function Bl(e,t){if(!("$schema"in e)||typeof e.$schema!=="string")return"2020-12";let o=e.$schema.replace(/#$/,"");if(qf.has(o))return"2020-12";if(Fl.has(o))return"2019-09";if(jf.has(o)||Lf.has(o))return"draft-7";throw Error(`JSON Schema declares an unsupported dialect ("$schema": "${e.$schema.slice(0,200)}"). The default validator supports JSON Schema 2020-12, 2019-09, draft-07, and draft-06; ${t}`)}var Gl,Ha=Object.freeze({status:"aborted"});function _(e,t,o){function r(c,l){if(!c._zod)Object.defineProperty(c,"_zod",{value:{def:l,constr:i,traits:new Set},enumerable:!1});if(c._zod.traits.has(e))return;c._zod.traits.add(e),t(c,l);let u=i.prototype,h=Object.keys(u);for(let m=0;m<h.length;m++){let S=h[m];if(!(S in c))c[S]=u[S].bind(c)}}let n=o?.Parent??Object;class s extends n{}Object.defineProperty(s,"name",{value:e});function i(c){var l;let u=o?.Parent?new s:this;r(u,c),(l=u._zod).deferred??(l.deferred=[]);for(let h of u._zod.deferred)h();return u}return Object.defineProperty(i,"init",{value:r}),Object.defineProperty(i,Symbol.hasInstance,{value:(c)=>{if(o?.Parent&&c instanceof o.Parent)return!0;return c?._zod?.traits?.has(e)}}),Object.defineProperty(i,"name",{value:e}),i}var Uf=Symbol("zod_brand");class gt extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class Xr extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`);this.name="ZodEncodeError"}}(Gl=globalThis).__zod_globalConfig??(Gl.__zod_globalConfig={});var Zo=globalThis.__zod_globalConfig;function we(e){if(e)Object.assign(Zo,e);return Zo}function Ai(e){let t=Object.values(e).filter((r)=>typeof r==="number");return Object.entries(e).filter(([r,n])=>t.indexOf(+r)===-1).map(([r,n])=>n)}function Ja(e,t="|"){return e.map((o)=>Ka(o)).join(t)}function en(e,t){if(typeof t==="bigint")return t.toString();return t}function tn(e){return{get value(){{let o=e();return Object.defineProperty(this,"value",{value:o}),o}throw Error("cached value already set")}}}function Mi(e){return e===null||e===void 0}function qi(e){let t=e.startsWith("^")?1:0,o=e.endsWith("$")?e.length-1:e.length;return e.slice(t,o)}function Kl(e,t){let o=e/t,r=Math.round(o),n=Number.EPSILON*Math.max(Math.abs(o),1);if(Math.abs(o-r)<n)return 0;return o-r}var Wl=Symbol("evaluating");function W(e,t,o){let r=void 0;Object.defineProperty(e,t,{get(){if(r===Wl)return;if(r===void 0)r=Wl,r=o();return r},set(n){Object.defineProperty(e,t,{value:n})},configurable:!0})}function so(e,t,o){Object.defineProperty(e,t,{value:o,writable:!0,enumerable:!0,configurable:!0})}function Ot(...e){let t={};for(let o of e){let r=Object.getOwnPropertyDescriptors(o);Object.assign(t,r)}return Object.defineProperties({},t)}function Ba(e){return JSON.stringify(e)}function Yl(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}var Ga="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function Do(e){return typeof e==="object"&&e!==null&&!Array.isArray(e)}var Ql=tn(()=>{if(Zo.jitless)return!1;if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{return new Function(""),!0}catch(e){return!1}});function io(e){if(Do(e)===!1)return!1;let t=e.constructor;if(t===void 0)return!0;if(typeof t!=="function")return!0;let o=t.prototype;if(Do(o)===!1)return!1;if(Object.prototype.hasOwnProperty.call(o,"isPrototypeOf")===!1)return!1;return!0}function Wa(e){if(io(e))return{...e};if(Array.isArray(e))return[...e];if(e instanceof Map)return new Map(e);if(e instanceof Set)return new Set(e);return e}var Xl=new Set(["string","number","symbol"]);function Nt(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Je(e,t,o){let r=new e._zod.constr(t??e._zod.def);if(!t||o?.parent)r._zod.parent=e;return r}function N(e){let t=e;if(!t)return{};if(typeof t==="string")return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw Error("Cannot specify both `message` and `error` params");t.error=t.message}if(delete t.message,typeof t.error==="string")return{...t,error:()=>t.error};return t}function Ka(e){if(typeof e==="bigint")return e.toString()+"n";if(typeof e==="string")return`"${e}"`;return`${e}`}function eu(e){return Object.keys(e).filter((t)=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}var tu={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-340282346638528860000000000000000000000,340282346638528860000000000000000000000],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function Zf(e,t){let o=e._zod.def,r=o.checks;if(r&&r.length>0)throw Error(".pick() cannot be used on object schemas containing refinements");let s=Ot(e._zod.def,{get shape(){let i={};for(let c in t){if(!(c in o.shape))throw Error(`Unrecognized key: "${c}"`);if(!t[c])continue;i[c]=o.shape[c]}return so(this,"shape",i),i},checks:[]});return Je(e,s)}function Df(e,t){let o=e._zod.def,r=o.checks;if(r&&r.length>0)throw Error(".omit() cannot be used on object schemas containing refinements");let s=Ot(e._zod.def,{get shape(){let i={...e._zod.def.shape};for(let c in t){if(!(c in o.shape))throw Error(`Unrecognized key: "${c}"`);if(!t[c])continue;delete i[c]}return so(this,"shape",i),i},checks:[]});return Je(e,s)}function Vf(e,t){if(!io(t))throw Error("Invalid input to extend: expected a plain object");let o=e._zod.def.checks;if(o&&o.length>0){let s=e._zod.def.shape;for(let i in t)if(Object.getOwnPropertyDescriptor(s,i)!==void 0)throw Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}let n=Ot(e._zod.def,{get shape(){let s={...e._zod.def.shape,...t};return so(this,"shape",s),s}});return Je(e,n)}function Hf(e,t){if(!io(t))throw Error("Invalid input to safeExtend: expected a plain object");let o=Ot(e._zod.def,{get shape(){let r={...e._zod.def.shape,...t};return so(this,"shape",r),r}});return Je(e,o)}function Ff(e,t){if(e._zod.def.checks?.length)throw Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");let o=Ot(e._zod.def,{get shape(){let r={...e._zod.def.shape,...t._zod.def.shape};return so(this,"shape",r),r},get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]});return Je(e,o)}function Jf(e,t,o){let n=t._zod.def.checks;if(n&&n.length>0)throw Error(".partial() cannot be used on object schemas containing refinements");let i=Ot(t._zod.def,{get shape(){let c=t._zod.def.shape,l={...c};if(o)for(let u in o){if(!(u in c))throw Error(`Unrecognized key: "${u}"`);if(!o[u])continue;l[u]=e?new e({type:"optional",innerType:c[u]}):c[u]}else for(let u in c)l[u]=e?new e({type:"optional",innerType:c[u]}):c[u];return so(this,"shape",l),l},checks:[]});return Je(t,i)}function Bf(e,t,o){let r=Ot(t._zod.def,{get shape(){let n=t._zod.def.shape,s={...n};if(o)for(let i in o){if(!(i in s))throw Error(`Unrecognized key: "${i}"`);if(!o[i])continue;s[i]=new e({type:"nonoptional",innerType:n[i]})}else for(let i in n)s[i]=new e({type:"nonoptional",innerType:n[i]});return so(this,"shape",s),s}});return Je(t,r)}function ao(e,t=0){if(e.aborted===!0)return!0;for(let o=t;o<e.issues.length;o++)if(e.issues[o]?.continue!==!0)return!0;return!1}function ou(e,t=0){if(e.aborted===!0)return!0;for(let o=t;o<e.issues.length;o++)if(e.issues[o]?.continue===!1)return!0;return!1}function At(e,t){return t.map((o)=>{var r;return(r=o).path??(r.path=[]),o.path.unshift(e),o})}function Ni(e){return typeof e==="string"?e:e?.message}function Be(e,t,o){let r=e.message?e.message:Ni(e.inst?._zod.def?.error?.(e))??Ni(t?.error?.(e))??Ni(o.customError?.(e))??Ni(o.localeError?.(e))??"Invalid input",{inst:n,continue:s,input:i,...c}=e;if(c.path??(c.path=[]),c.message=r,t?.reportInput)c.input=i;return c}function ji(e){if(Array.isArray(e))return"array";if(typeof e==="string")return"string";return"unknown"}function ru(e){let t=typeof e;switch(t){case"number":return Number.isNaN(e)?"nan":"number";case"object":{if(e===null)return"null";if(Array.isArray(e))return"array";let o=e;if(o&&Object.getPrototypeOf(o)!==Object.prototype&&"constructor"in o&&o.constructor)return o.constructor.name}}return t}function co(...e){let[t,o,r]=e;if(typeof t==="string")return{message:t,code:"custom",input:o,inst:r};return{...t}}var nu=(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,en,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},Li=_("$ZodError",nu),Ya=_("$ZodError",nu,{Parent:Error});function Qa(e,t=(o)=>o.message){let o={},r=[];for(let n of e.issues)if(n.path.length>0)o[n.path[0]]=o[n.path[0]]||[],o[n.path[0]].push(t(n));else r.push(t(n));return{formErrors:r,fieldErrors:o}}function Xa(e,t=(o)=>o.message){let o={_errors:[]},r=(n,s=[])=>{for(let i of n.issues)if(i.code==="invalid_union"&&i.errors.length)i.errors.map((c)=>r({issues:c},[...s,...i.path]));else if(i.code==="invalid_key")r({issues:i.issues},[...s,...i.path]);else if(i.code==="invalid_element")r({issues:i.issues},[...s,...i.path]);else{let c=[...s,...i.path];if(c.length===0)o._errors.push(t(i));else{let l=o,u=0;while(u<c.length){let h=c[u];if(u!==c.length-1)l[h]=l[h]||{_errors:[]};else l[h]=l[h]||{_errors:[]},l[h]._errors.push(t(i));l=l[h],u++}}}};return r(e),o}var Ui=(e)=>(t,o,r,n)=>{let s=r?{...r,async:!1}:{async:!1},i=t._zod.run({value:o,issues:[]},s);if(i instanceof Promise)throw new gt;if(i.issues.length){let c=new(n?.Err??e)(i.issues.map((l)=>Be(l,s,we())));throw Ga(c,n?.callee),c}return i.value};var Zi=(e)=>async(t,o,r,n)=>{let s=r?{...r,async:!0}:{async:!0},i=t._zod.run({value:o,issues:[]},s);if(i instanceof Promise)i=await i;if(i.issues.length){let c=new(n?.Err??e)(i.issues.map((l)=>Be(l,s,we())));throw Ga(c,n?.callee),c}return i.value};var on=(e)=>(t,o,r)=>{let n=r?{...r,async:!1}:{async:!1},s=t._zod.run({value:o,issues:[]},n);if(s instanceof Promise)throw new gt;return s.issues.length?{success:!1,error:new(e??Li)(s.issues.map((i)=>Be(i,n,we())))}:{success:!0,data:s.value}},su=on(Ya),rn=(e)=>async(t,o,r)=>{let n=r?{...r,async:!0}:{async:!0},s=t._zod.run({value:o,issues:[]},n);if(s instanceof Promise)s=await s;return s.issues.length?{success:!1,error:new e(s.issues.map((i)=>Be(i,n,we())))}:{success:!0,data:s.value}},iu=rn(Ya),au=(e)=>(t,o,r)=>{let n=r?{...r,direction:"backward"}:{direction:"backward"};return Ui(e)(t,o,n)};var cu=(e)=>(t,o,r)=>Ui(e)(t,o,r);var lu=(e)=>async(t,o,r)=>{let n=r?{...r,direction:"backward"}:{direction:"backward"};return Zi(e)(t,o,n)};var uu=(e)=>async(t,o,r)=>Zi(e)(t,o,r);var du=(e)=>(t,o,r)=>{let n=r?{...r,direction:"backward"}:{direction:"backward"};return on(e)(t,o,n)};var pu=(e)=>(t,o,r)=>on(e)(t,o,r);var hu=(e)=>async(t,o,r)=>{let n=r?{...r,direction:"backward"}:{direction:"backward"};return rn(e)(t,o,n)};var mu=(e)=>async(t,o,r)=>rn(e)(t,o,r);var fu=/^[cC][0-9a-z]{6,}$/,gu=/^[0-9a-z]+$/,Su=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,_u=/^[0-9a-vA-V]{20}$/,yu=/^[A-Za-z0-9]{27}$/,bu=/^[a-zA-Z0-9_-]{21}$/,vu=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/;var zu=/^([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})$/,ec=(e)=>{if(!e)return/^([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)$/;return 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})$`)};var Ru=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;var Wf="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function wu(){return new RegExp(Wf,"u")}var xu=/^(?:(?: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])$/,Pu=/^(([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}|:))$/;var Tu=/^((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])$/,Eu=/^(([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])$/,ku=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,tc=/^[A-Za-z0-9_-]*$/;var $u=/^https?$/,Cu=/^\+[1-9]\d{6,14}$/,Iu="(?:(?:\\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])))",Ou=new RegExp(`^${Iu}$`);function Nu(e){return typeof e.precision==="number"?e.precision===-1?"(?:[01]\\d|2[0-3]):[0-5]\\d":e.precision===0?"(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d":`(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d\\.\\d{${e.precision}}`:"(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?"}function Au(e){return new RegExp(`^${Nu(e)}$`)}function Mu(e){let t=Nu({precision:e.precision}),o=["Z"];if(e.local)o.push("");if(e.offset)o.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");let r=`${t}(?:${o.join("|")})`;return new RegExp(`^${Iu}T(?:${r})$`)}var qu=(e)=>{let t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)};var ju=/^-?\d+$/,oc=/^-?\d+(?:\.\d+)?$/,Lu=/^(?:true|false)$/i,Uu=/^null$/i;var Zu=/^undefined$/i;var Du=/^[^A-Z]*$/,Vu=/^[^a-z]*$/;var he=_("$ZodCheck",(e,t)=>{var o;e._zod??(e._zod={}),e._zod.def=t,(o=e._zod).onattach??(o.onattach=[])}),Hu={number:"number",bigint:"bigint",object:"date"},rc=_("$ZodCheckLessThan",(e,t)=>{he.init(e,t);let o=Hu[typeof t.value];e._zod.onattach.push((r)=>{let n=r._zod.bag,s=(t.inclusive?n.maximum:n.exclusiveMaximum)??Number.POSITIVE_INFINITY;if(t.value<s)if(t.inclusive)n.maximum=t.value;else n.exclusiveMaximum=t.value}),e._zod.check=(r)=>{if(t.inclusive?r.value<=t.value:r.value<t.value)return;r.issues.push({origin:o,code:"too_big",maximum:typeof t.value==="object"?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),nc=_("$ZodCheckGreaterThan",(e,t)=>{he.init(e,t);let o=Hu[typeof t.value];e._zod.onattach.push((r)=>{let n=r._zod.bag,s=(t.inclusive?n.minimum:n.exclusiveMinimum)??Number.NEGATIVE_INFINITY;if(t.value>s)if(t.inclusive)n.minimum=t.value;else n.exclusiveMinimum=t.value}),e._zod.check=(r)=>{if(t.inclusive?r.value>=t.value:r.value>t.value)return;r.issues.push({origin:o,code:"too_small",minimum:typeof t.value==="object"?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Fu=_("$ZodCheckMultipleOf",(e,t)=>{he.init(e,t),e._zod.onattach.push((o)=>{var r;(r=o._zod.bag).multipleOf??(r.multipleOf=t.value)}),e._zod.check=(o)=>{if(typeof o.value!==typeof t.value)throw Error("Cannot mix number and bigint in multiple_of check.");if(typeof o.value==="bigint"?o.value%t.value===BigInt(0):Kl(o.value,t.value)===0)return;o.issues.push({origin:typeof o.value,code:"not_multiple_of",divisor:t.value,input:o.value,inst:e,continue:!t.abort})}}),Ju=_("$ZodCheckNumberFormat",(e,t)=>{he.init(e,t),t.format=t.format||"float64";let o=t.format?.includes("int"),r=o?"int":"number",[n,s]=tu[t.format];e._zod.onattach.push((i)=>{let c=i._zod.bag;if(c.format=t.format,c.minimum=n,c.maximum=s,o)c.pattern=ju}),e._zod.check=(i)=>{let c=i.value;if(o){if(!Number.isInteger(c)){i.issues.push({expected:r,format:t.format,code:"invalid_type",continue:!1,input:c,inst:e});return}if(!Number.isSafeInteger(c)){if(c>0)i.issues.push({input:c,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:r,inclusive:!0,continue:!t.abort});else i.issues.push({input:c,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:r,inclusive:!0,continue:!t.abort});return}}if(c<n)i.issues.push({origin:"number",input:c,code:"too_small",minimum:n,inclusive:!0,inst:e,continue:!t.abort});if(c>s)i.issues.push({origin:"number",input:c,code:"too_big",maximum:s,inclusive:!0,inst:e,continue:!t.abort})}});var Bu=_("$ZodCheckMaxLength",(e,t)=>{var o;he.init(e,t),(o=e._zod.def).when??(o.when=(r)=>{let n=r.value;return!Mi(n)&&n.length!==void 0}),e._zod.onattach.push((r)=>{let n=r._zod.bag.maximum??Number.POSITIVE_INFINITY;if(t.maximum<n)r._zod.bag.maximum=t.maximum}),e._zod.check=(r)=>{let n=r.value;if(n.length<=t.maximum)return;let i=ji(n);r.issues.push({origin:i,code:"too_big",maximum:t.maximum,inclusive:!0,input:n,inst:e,continue:!t.abort})}}),Gu=_("$ZodCheckMinLength",(e,t)=>{var o;he.init(e,t),(o=e._zod.def).when??(o.when=(r)=>{let n=r.value;return!Mi(n)&&n.length!==void 0}),e._zod.onattach.push((r)=>{let n=r._zod.bag.minimum??Number.NEGATIVE_INFINITY;if(t.minimum>n)r._zod.bag.minimum=t.minimum}),e._zod.check=(r)=>{let n=r.value;if(n.length>=t.minimum)return;let i=ji(n);r.issues.push({origin:i,code:"too_small",minimum:t.minimum,inclusive:!0,input:n,inst:e,continue:!t.abort})}}),Wu=_("$ZodCheckLengthEquals",(e,t)=>{var o;he.init(e,t),(o=e._zod.def).when??(o.when=(r)=>{let n=r.value;return!Mi(n)&&n.length!==void 0}),e._zod.onattach.push((r)=>{let n=r._zod.bag;n.minimum=t.length,n.maximum=t.length,n.length=t.length}),e._zod.check=(r)=>{let n=r.value,s=n.length;if(s===t.length)return;let i=ji(n),c=s>t.length;r.issues.push({origin:i,...c?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:r.value,inst:e,continue:!t.abort})}}),sn=_("$ZodCheckStringFormat",(e,t)=>{var o,r;if(he.init(e,t),e._zod.onattach.push((n)=>{let s=n._zod.bag;if(s.format=t.format,t.pattern)s.patterns??(s.patterns=new Set),s.patterns.add(t.pattern)}),t.pattern)(o=e._zod).check??(o.check=(n)=>{if(t.pattern.lastIndex=0,t.pattern.test(n.value))return;n.issues.push({origin:"string",code:"invalid_format",format:t.format,input:n.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})});else(r=e._zod).check??(r.check=()=>{})}),Ku=_("$ZodCheckRegex",(e,t)=>{sn.init(e,t),e._zod.check=(o)=>{if(t.pattern.lastIndex=0,t.pattern.test(o.value))return;o.issues.push({origin:"string",code:"invalid_format",format:"regex",input:o.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),Yu=_("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=Du),sn.init(e,t)}),Qu=_("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=Vu),sn.init(e,t)}),Xu=_("$ZodCheckIncludes",(e,t)=>{he.init(e,t);let o=Nt(t.includes),r=new RegExp(typeof t.position==="number"?`^.{${t.position}}${o}`:o);t.pattern=r,e._zod.onattach.push((n)=>{let s=n._zod.bag;s.patterns??(s.patterns=new Set),s.patterns.add(r)}),e._zod.check=(n)=>{if(n.value.includes(t.includes,t.position))return;n.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:n.value,inst:e,continue:!t.abort})}}),ed=_("$ZodCheckStartsWith",(e,t)=>{he.init(e,t);let o=new RegExp(`^${Nt(t.prefix)}.*`);t.pattern??(t.pattern=o),e._zod.onattach.push((r)=>{let n=r._zod.bag;n.patterns??(n.patterns=new Set),n.patterns.add(o)}),e._zod.check=(r)=>{if(r.value.startsWith(t.prefix))return;r.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:r.value,inst:e,continue:!t.abort})}}),td=_("$ZodCheckEndsWith",(e,t)=>{he.init(e,t);let o=new RegExp(`.*${Nt(t.suffix)}$`);t.pattern??(t.pattern=o),e._zod.onattach.push((r)=>{let n=r._zod.bag;n.patterns??(n.patterns=new Set),n.patterns.add(o)}),e._zod.check=(r)=>{if(r.value.endsWith(t.suffix))return;r.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:r.value,inst:e,continue:!t.abort})}});var od=_("$ZodCheckOverwrite",(e,t)=>{he.init(e,t),e._zod.check=(o)=>{o.value=t.tx(o.value)}});class sc{constructor(e=[]){if(this.content=[],this.indent=0,this)this.args=e}indented(e){this.indent+=1,e(this),this.indent-=1}write(e){if(typeof e==="function"){e(this,{execution:"sync"}),e(this,{execution:"async"});return}let o=e.split(`
|
|
2
|
+
`).filter((s)=>s),r=Math.min(...o.map((s)=>s.length-s.trimStart().length)),n=o.map((s)=>s.slice(r)).map((s)=>" ".repeat(this.indent*2)+s);for(let s of n)this.content.push(s)}compile(){let e=Function,t=this?.args,r=[...(this?.content??[""]).map((n)=>` ${n}`)];return new e(...t,r.join(`
|
|
3
|
+
`))}}var nd={major:4,minor:4,patch:3};var Q=_("$ZodType",(e,t)=>{var o;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=nd;let r=[...e._zod.def.checks??[]];if(e._zod.traits.has("$ZodCheck"))r.unshift(e);for(let n of r)for(let s of n._zod.onattach)s(e);if(r.length===0)(o=e._zod).deferred??(o.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let n=(i,c,l)=>{let u=ao(i),h;for(let m of c){if(m._zod.def.when){if(ou(i))continue;if(!m._zod.def.when(i))continue}else if(u)continue;let S=i.issues.length,g=m._zod.check(i);if(g instanceof Promise&&l?.async===!1)throw new gt;if(h||g instanceof Promise)h=(h??Promise.resolve()).then(async()=>{if(await g,i.issues.length===S)return;if(!u)u=ao(i,S)});else{if(i.issues.length===S)continue;if(!u)u=ao(i,S)}}if(h)return h.then(()=>i);return i},s=(i,c,l)=>{if(ao(i))return i.aborted=!0,i;let u=n(c,r,l);if(u instanceof Promise){if(l.async===!1)throw new gt;return u.then((h)=>e._zod.parse(h,l))}return e._zod.parse(u,l)};e._zod.run=(i,c)=>{if(c.skipChecks)return e._zod.parse(i,c);if(c.direction==="backward"){let u=e._zod.parse({value:i.value,issues:[]},{...c,skipChecks:!0});if(u instanceof Promise)return u.then((h)=>s(h,i,c));return s(u,i,c)}let l=e._zod.parse(i,c);if(l instanceof Promise){if(c.async===!1)throw new gt;return l.then((u)=>n(u,r,c))}return n(l,r,c)}}W(e,"~standard",()=>({validate:(n)=>{try{let s=su(e,n);return s.success?{value:s.data}:{issues:s.error?.issues}}catch(s){return iu(e,n).then((i)=>i.success?{value:i.data}:{issues:i.error?.issues})}},vendor:"zod",version:1}))}),Hi=_("$ZodString",(e,t)=>{Q.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??qu(e._zod.bag),e._zod.parse=(o,r)=>{if(t.coerce)try{o.value=String(o.value)}catch(n){}if(typeof o.value==="string")return o;return o.issues.push({expected:"string",code:"invalid_type",input:o.value,inst:e}),o}}),te=_("$ZodStringFormat",(e,t)=>{sn.init(e,t),Hi.init(e,t)}),hd=_("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=zu),te.init(e,t)}),md=_("$ZodUUID",(e,t)=>{if(t.version){let r={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(r===void 0)throw Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=ec(r))}else t.pattern??(t.pattern=ec());te.init(e,t)}),fd=_("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=Ru),te.init(e,t)}),gd=_("$ZodURL",(e,t)=>{te.init(e,t),e._zod.check=(o)=>{try{let r=o.value.trim();if(!t.normalize&&t.protocol?.source===$u.source){if(!/^https?:\/\//i.test(r)){o.issues.push({code:"invalid_format",format:"url",note:"Invalid URL format",input:o.value,inst:e,continue:!t.abort});return}}let n=new URL(r);if(t.hostname){if(t.hostname.lastIndex=0,!t.hostname.test(n.hostname))o.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:t.hostname.source,input:o.value,inst:e,continue:!t.abort})}if(t.protocol){if(t.protocol.lastIndex=0,!t.protocol.test(n.protocol.endsWith(":")?n.protocol.slice(0,-1):n.protocol))o.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:o.value,inst:e,continue:!t.abort})}if(t.normalize)o.value=n.href;else o.value=r;return}catch(r){o.issues.push({code:"invalid_format",format:"url",input:o.value,inst:e,continue:!t.abort})}}}),Sd=_("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=wu()),te.init(e,t)}),_d=_("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=bu),te.init(e,t)}),yd=_("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=fu),te.init(e,t)}),bd=_("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=gu),te.init(e,t)}),vd=_("$ZodULID",(e,t)=>{t.pattern??(t.pattern=Su),te.init(e,t)}),zd=_("$ZodXID",(e,t)=>{t.pattern??(t.pattern=_u),te.init(e,t)}),Rd=_("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=yu),te.init(e,t)}),wd=_("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=Mu(t)),te.init(e,t)}),xd=_("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=Ou),te.init(e,t)}),Pd=_("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=Au(t)),te.init(e,t)}),Td=_("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=vu),te.init(e,t)}),Ed=_("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=xu),te.init(e,t),e._zod.bag.format="ipv4"}),kd=_("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=Pu),te.init(e,t),e._zod.bag.format="ipv6",e._zod.check=(o)=>{try{new URL(`http://[${o.value}]`)}catch{o.issues.push({code:"invalid_format",format:"ipv6",input:o.value,inst:e,continue:!t.abort})}}});var $d=_("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=Tu),te.init(e,t)}),Cd=_("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=Eu),te.init(e,t),e._zod.check=(o)=>{let r=o.value.split("/");try{if(r.length!==2)throw Error();let[n,s]=r;if(!s)throw Error();let i=Number(s);if(`${i}`!==s)throw Error();if(i<0||i>128)throw Error();new URL(`http://[${n}]`)}catch{o.issues.push({code:"invalid_format",format:"cidrv6",input:o.value,inst:e,continue:!t.abort})}}});function Id(e){if(e==="")return!0;if(/\s/.test(e))return!1;if(e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}var Od=_("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=ku),te.init(e,t),e._zod.bag.contentEncoding="base64",e._zod.check=(o)=>{if(Id(o.value))return;o.issues.push({code:"invalid_format",format:"base64",input:o.value,inst:e,continue:!t.abort})}});function Kf(e){if(!tc.test(e))return!1;let t=e.replace(/[-_]/g,(r)=>r==="-"?"+":"/"),o=t.padEnd(Math.ceil(t.length/4)*4,"=");return Id(o)}var Nd=_("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=tc),te.init(e,t),e._zod.bag.contentEncoding="base64url",e._zod.check=(o)=>{if(Kf(o.value))return;o.issues.push({code:"invalid_format",format:"base64url",input:o.value,inst:e,continue:!t.abort})}}),Ad=_("$ZodE164",(e,t)=>{t.pattern??(t.pattern=Cu),te.init(e,t)});function Yf(e,t=null){try{let o=e.split(".");if(o.length!==3)return!1;let[r]=o;if(!r)return!1;let n=JSON.parse(atob(r));if("typ"in n&&n?.typ!=="JWT")return!1;if(!n.alg)return!1;if(t&&(!("alg"in n)||n.alg!==t))return!1;return!0}catch{return!1}}var Md=_("$ZodJWT",(e,t)=>{te.init(e,t),e._zod.check=(o)=>{if(Yf(o.value,t.alg))return;o.issues.push({code:"invalid_format",format:"jwt",input:o.value,inst:e,continue:!t.abort})}});var ac=_("$ZodNumber",(e,t)=>{Q.init(e,t),e._zod.pattern=e._zod.bag.pattern??oc,e._zod.parse=(o,r)=>{if(t.coerce)try{o.value=Number(o.value)}catch(i){}let n=o.value;if(typeof n==="number"&&!Number.isNaN(n)&&Number.isFinite(n))return o;let s=typeof n==="number"?Number.isNaN(n)?"NaN":!Number.isFinite(n)?"Infinity":void 0:void 0;return o.issues.push({expected:"number",code:"invalid_type",input:n,inst:e,...s?{received:s}:{}}),o}}),qd=_("$ZodNumberFormat",(e,t)=>{Ju.init(e,t),ac.init(e,t)}),jd=_("$ZodBoolean",(e,t)=>{Q.init(e,t),e._zod.pattern=Lu,e._zod.parse=(o,r)=>{if(t.coerce)try{o.value=Boolean(o.value)}catch(s){}let n=o.value;if(typeof n==="boolean")return o;return o.issues.push({expected:"boolean",code:"invalid_type",input:n,inst:e}),o}});var Ld=_("$ZodUndefined",(e,t)=>{Q.init(e,t),e._zod.pattern=Zu,e._zod.values=new Set([void 0]),e._zod.parse=(o,r)=>{let n=o.value;if(typeof n>"u")return o;return o.issues.push({expected:"undefined",code:"invalid_type",input:n,inst:e}),o}}),Ud=_("$ZodNull",(e,t)=>{Q.init(e,t),e._zod.pattern=Uu,e._zod.values=new Set([null]),e._zod.parse=(o,r)=>{let n=o.value;if(n===null)return o;return o.issues.push({expected:"null",code:"invalid_type",input:n,inst:e}),o}}),Zd=_("$ZodAny",(e,t)=>{Q.init(e,t),e._zod.parse=(o)=>o}),Dd=_("$ZodUnknown",(e,t)=>{Q.init(e,t),e._zod.parse=(o)=>o}),Vd=_("$ZodNever",(e,t)=>{Q.init(e,t),e._zod.parse=(o,r)=>(o.issues.push({expected:"never",code:"invalid_type",input:o.value,inst:e}),o)});function sd(e,t,o){if(e.issues.length)t.issues.push(...At(o,e.issues));t.value[o]=e.value}var Hd=_("$ZodArray",(e,t)=>{Q.init(e,t),e._zod.parse=(o,r)=>{let n=o.value;if(!Array.isArray(n))return o.issues.push({expected:"array",code:"invalid_type",input:n,inst:e}),o;o.value=Array(n.length);let s=[];for(let i=0;i<n.length;i++){let c=n[i],l=t.element._zod.run({value:c,issues:[]},r);if(l instanceof Promise)s.push(l.then((u)=>sd(u,o,i)));else sd(l,o,i)}if(s.length)return Promise.all(s).then(()=>o);return o}});function Vi(e,t,o,r,n,s){let i=o in r;if(e.issues.length){if(n&&s&&!i)return;t.issues.push(...At(o,e.issues))}if(!i&&!n){if(!e.issues.length)t.issues.push({code:"invalid_type",expected:"nonoptional",input:void 0,path:[o]});return}if(e.value===void 0){if(i)t.value[o]=void 0}else t.value[o]=e.value}function Fd(e){let t=Object.keys(e.shape);for(let r of t)if(!e.shape?.[r]?._zod?.traits?.has("$ZodType"))throw Error(`Invalid element at key "${r}": expected a Zod schema`);let o=eu(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(o)}}function Jd(e,t,o,r,n,s){let i=[],c=n.keySet,l=n.catchall._zod,u=l.def.type,h=l.optin==="optional",m=l.optout==="optional";for(let S in t){if(S==="__proto__")continue;if(c.has(S))continue;if(u==="never"){i.push(S);continue}let g=l.run({value:t[S],issues:[]},r);if(g instanceof Promise)e.push(g.then((b)=>Vi(b,o,S,t,h,m)));else Vi(g,o,S,t,h,m)}if(i.length)o.issues.push({code:"unrecognized_keys",keys:i,input:t,inst:s});if(!e.length)return o;return Promise.all(e).then(()=>o)}var Qf=_("$ZodObject",(e,t)=>{if(Q.init(e,t),!Object.getOwnPropertyDescriptor(t,"shape")?.get){let c=t.shape;Object.defineProperty(t,"shape",{get:()=>{let l={...c};return Object.defineProperty(t,"shape",{value:l}),l}})}let r=tn(()=>Fd(t));W(e._zod,"propValues",()=>{let c=t.shape,l={};for(let u in c){let h=c[u]._zod;if(h.values){l[u]??(l[u]=new Set);for(let m of h.values)l[u].add(m)}}return l});let n=Do,s=t.catchall,i;e._zod.parse=(c,l)=>{i??(i=r.value);let u=c.value;if(!n(u))return c.issues.push({expected:"object",code:"invalid_type",input:u,inst:e}),c;c.value={};let h=[],m=i.shape;for(let S of i.keys){let g=m[S],b=g._zod.optin==="optional",v=g._zod.optout==="optional",R=g._zod.run({value:u[S],issues:[]},l);if(R instanceof Promise)h.push(R.then((q)=>Vi(q,c,S,u,b,v)));else Vi(R,c,S,u,b,v)}if(!s)return h.length?Promise.all(h).then(()=>c):c;return Jd(h,u,c,l,r.value,e)}}),Bd=_("$ZodObjectJIT",(e,t)=>{Qf.init(e,t);let o=e._zod.parse,r=tn(()=>Fd(t)),n=(S)=>{let g=new sc(["shape","payload","ctx"]),b=r.value,v=(P)=>{let H=Ba(P);return`shape[${H}]._zod.run({ value: input[${H}], issues: [] }, ctx)`};g.write("const input = payload.value;");let R=Object.create(null),q=0;for(let P of b.keys)R[P]=`key_${q++}`;g.write("const newResult = {};");for(let P of b.keys){let H=R[P],B=Ba(P),G=S[P],Y=G?._zod?.optin==="optional",ue=G?._zod?.optout==="optional";if(g.write(`const ${H} = ${v(P)};`),Y&&ue)g.write(`
|
|
4
|
+
if (${H}.issues.length) {
|
|
5
|
+
if (${B} in input) {
|
|
6
|
+
payload.issues = payload.issues.concat(${H}.issues.map(iss => ({
|
|
7
7
|
...iss,
|
|
8
|
-
path: iss.path ? [${
|
|
8
|
+
path: iss.path ? [${B}, ...iss.path] : [${B}]
|
|
9
9
|
})));
|
|
10
10
|
}
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
-
if (${
|
|
14
|
-
if (${
|
|
15
|
-
newResult[${
|
|
13
|
+
if (${H}.value === undefined) {
|
|
14
|
+
if (${B} in input) {
|
|
15
|
+
newResult[${B}] = undefined;
|
|
16
16
|
}
|
|
17
17
|
} else {
|
|
18
|
-
newResult[${
|
|
18
|
+
newResult[${B}] = ${H}.value;
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
-
`);else if(!
|
|
22
|
-
const ${
|
|
23
|
-
if (${
|
|
24
|
-
payload.issues = payload.issues.concat(${
|
|
21
|
+
`);else if(!Y)g.write(`
|
|
22
|
+
const ${H}_present = ${B} in input;
|
|
23
|
+
if (${H}.issues.length) {
|
|
24
|
+
payload.issues = payload.issues.concat(${H}.issues.map(iss => ({
|
|
25
25
|
...iss,
|
|
26
|
-
path: iss.path ? [${
|
|
26
|
+
path: iss.path ? [${B}, ...iss.path] : [${B}]
|
|
27
27
|
})));
|
|
28
28
|
}
|
|
29
|
-
if (!${
|
|
29
|
+
if (!${H}_present && !${H}.issues.length) {
|
|
30
30
|
payload.issues.push({
|
|
31
31
|
code: "invalid_type",
|
|
32
32
|
expected: "nonoptional",
|
|
33
33
|
input: undefined,
|
|
34
|
-
path: [${
|
|
34
|
+
path: [${B}]
|
|
35
35
|
});
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
-
if (${
|
|
39
|
-
if (${
|
|
40
|
-
newResult[${
|
|
38
|
+
if (${H}_present) {
|
|
39
|
+
if (${H}.value === undefined) {
|
|
40
|
+
newResult[${B}] = undefined;
|
|
41
41
|
} else {
|
|
42
|
-
newResult[${
|
|
42
|
+
newResult[${B}] = ${H}.value;
|
|
43
43
|
}
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
-
`);else
|
|
47
|
-
if (${
|
|
48
|
-
payload.issues = payload.issues.concat(${
|
|
46
|
+
`);else g.write(`
|
|
47
|
+
if (${H}.issues.length) {
|
|
48
|
+
payload.issues = payload.issues.concat(${H}.issues.map(iss => ({
|
|
49
49
|
...iss,
|
|
50
|
-
path: iss.path ? [${
|
|
50
|
+
path: iss.path ? [${B}, ...iss.path] : [${B}]
|
|
51
51
|
})));
|
|
52
52
|
}
|
|
53
53
|
|
|
54
|
-
if (${
|
|
55
|
-
if (${
|
|
56
|
-
newResult[${
|
|
54
|
+
if (${H}.value === undefined) {
|
|
55
|
+
if (${B} in input) {
|
|
56
|
+
newResult[${B}] = undefined;
|
|
57
57
|
}
|
|
58
58
|
} else {
|
|
59
|
-
newResult[${
|
|
59
|
+
newResult[${B}] = ${H}.value;
|
|
60
60
|
}
|
|
61
61
|
|
|
62
|
-
`)}S.write("payload.value = newResult;"),S.write("return payload;");let N=S.compile();return(I,M)=>N(y,I,M)},i,a=fo,c=!mo.jitless,p=c&&Rl.value,m=t.catchall,f;e._zod.parse=(y,S)=>{f??(f=r.value);let w=y.value;if(!a(w))return y.issues.push({expected:"object",code:"invalid_type",input:w,inst:e}),y;if(c&&p&&S?.async===!1&&S.jitless!==!0){if(!i)i=n(t.shape);if(y=i(y,S),!m)return y;return _d([],w,y,S,f,e)}return o(y,S)}});function Iu(e,t,o,r){for(let i of e)if(i.issues.length===0)return t.value=i.value,t;let n=e.filter((i)=>!Et(i));if(n.length===1)return t.value=n[0].value,n[0];return t.issues.push({code:"invalid_union",input:t.value,inst:o,errors:e.map((i)=>i.issues.map((a)=>we(a,r,le())))}),t}var Za=g("$ZodUnion",(e,t)=>{U.init(e,t),L(e._zod,"optin",()=>t.options.some((r)=>r._zod.optin==="optional")?"optional":void 0),L(e._zod,"optout",()=>t.options.some((r)=>r._zod.optout==="optional")?"optional":void 0),L(e._zod,"values",()=>{if(t.options.every((r)=>r._zod.values))return new Set(t.options.flatMap((r)=>Array.from(r._zod.values)));return}),L(e._zod,"pattern",()=>{if(t.options.every((r)=>r._zod.pattern)){let r=t.options.map((n)=>n._zod.pattern);return new RegExp(`^(${r.map((n)=>vi(n.source)).join("|")})$`)}return});let o=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(r,n)=>{if(o)return o(r,n);let i=!1,a=[];for(let c of t.options){let d=c._zod.run({value:r.value,issues:[]},n);if(d instanceof Promise)a.push(d),i=!0;else{if(d.issues.length===0)return d;a.push(d)}}if(!i)return Iu(a,r,e,n);return Promise.all(a).then((c)=>Iu(c,r,e,n))}});var bd=g("$ZodDiscriminatedUnion",(e,t)=>{t.inclusive=!1,Za.init(e,t);let o=e._zod.parse;L(e._zod,"propValues",()=>{let n={};for(let i of t.options){let a=i._zod.propValues;if(!a||Object.keys(a).length===0)throw Error(`Invalid discriminated union option at index "${t.options.indexOf(i)}"`);for(let[c,d]of Object.entries(a)){if(!n[c])n[c]=new Set;for(let p of d)n[c].add(p)}}return n});let r=Hr(()=>{let n=t.options,i=new Map;for(let a of n){let c=a._zod.propValues?.[t.discriminator];if(!c||c.size===0)throw Error(`Invalid discriminated union option at index "${t.options.indexOf(a)}"`);for(let d of c){if(i.has(d))throw Error(`Duplicate discriminator value "${String(d)}"`);i.set(d,a)}}return i});e._zod.parse=(n,i)=>{let a=n.value;if(!fo(a))return n.issues.push({code:"invalid_type",expected:"object",input:a,inst:e}),n;let c=r.value.get(a?.[t.discriminator]);if(c)return c._zod.run(n,i);if(t.unionFallback||i.direction==="backward")return o(n,i);return n.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:t.discriminator,options:Array.from(r.value.keys()),input:a,path:[t.discriminator],inst:e}),n}}),vd=g("$ZodIntersection",(e,t)=>{U.init(e,t),e._zod.parse=(o,r)=>{let n=o.value,i=t.left._zod.run({value:n,issues:[]},r),a=t.right._zod.run({value:n,issues:[]},r);if(i instanceof Promise||a instanceof Promise)return Promise.all([i,a]).then(([d,p])=>Ou(o,d,p));return Ou(o,i,a)}});function La(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(Tt(e)&&Tt(t)){let o=Object.keys(t),r=Object.keys(e).filter((i)=>o.indexOf(i)!==-1),n={...e,...t};for(let i of r){let a=La(e[i],t[i]);if(!a.valid)return{valid:!1,mergeErrorPath:[i,...a.mergeErrorPath]};n[i]=a.data}return{valid:!0,data:n}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};let o=[];for(let r=0;r<e.length;r++){let n=e[r],i=t[r],a=La(n,i);if(!a.valid)return{valid:!1,mergeErrorPath:[r,...a.mergeErrorPath]};o.push(a.data)}return{valid:!0,data:o}}return{valid:!1,mergeErrorPath:[]}}function Ou(e,t,o){let r=new Map,n;for(let c of t.issues)if(c.code==="unrecognized_keys"){n??(n=c);for(let d of c.keys){if(!r.has(d))r.set(d,{});r.get(d).l=!0}}else e.issues.push(c);for(let c of o.issues)if(c.code==="unrecognized_keys")for(let d of c.keys){if(!r.has(d))r.set(d,{});r.get(d).r=!0}else e.issues.push(c);let i=[...r].filter(([,c])=>c.l&&c.r).map(([c])=>c);if(i.length&&n)e.issues.push({...n,keys:i});if(Et(e))return e;let a=La(t.value,o.value);if(!a.valid)throw Error(`Unmergable intersection. Error path: ${JSON.stringify(a.mergeErrorPath)}`);return e.value=a.data,e}var zd=g("$ZodRecord",(e,t)=>{U.init(e,t),e._zod.parse=(o,r)=>{let n=o.value;if(!Tt(n))return o.issues.push({expected:"record",code:"invalid_type",input:n,inst:e}),o;let i=[],a=t.keyType._zod.values;if(a){o.value={};let c=new Set;for(let p of a)if(typeof p==="string"||typeof p==="number"||typeof p==="symbol"){c.add(typeof p==="number"?p.toString():p);let m=t.keyType._zod.run({value:p,issues:[]},r);if(m instanceof Promise)throw Error("Async schemas not supported in object keys currently");if(m.issues.length){o.issues.push({code:"invalid_key",origin:"record",issues:m.issues.map((S)=>we(S,r,le())),input:p,path:[p],inst:e});continue}let f=m.value,y=t.valueType._zod.run({value:n[p],issues:[]},r);if(y instanceof Promise)i.push(y.then((S)=>{if(S.issues.length)o.issues.push(...et(p,S.issues));o.value[f]=S.value}));else{if(y.issues.length)o.issues.push(...et(p,y.issues));o.value[f]=y.value}}let d;for(let p in n)if(!c.has(p))d=d??[],d.push(p);if(d&&d.length>0)o.issues.push({code:"unrecognized_keys",input:n,inst:e,keys:d})}else{o.value={};for(let c of Reflect.ownKeys(n)){if(c==="__proto__")continue;if(!Object.prototype.propertyIsEnumerable.call(n,c))continue;let d=t.keyType._zod.run({value:c,issues:[]},r);if(d instanceof Promise)throw Error("Async schemas not supported in object keys currently");if(typeof c==="string"&&Aa.test(c)&&d.issues.length){let f=t.keyType._zod.run({value:Number(c),issues:[]},r);if(f instanceof Promise)throw Error("Async schemas not supported in object keys currently");if(f.issues.length===0)d=f}if(d.issues.length){if(t.mode==="loose")o.value[c]=n[c];else o.issues.push({code:"invalid_key",origin:"record",issues:d.issues.map((f)=>we(f,r,le())),input:c,path:[c],inst:e});continue}let m=t.valueType._zod.run({value:n[c],issues:[]},r);if(m instanceof Promise)i.push(m.then((f)=>{if(f.issues.length)o.issues.push(...et(c,f.issues));o.value[d.value]=f.value}));else{if(m.issues.length)o.issues.push(...et(c,m.issues));o.value[d.value]=m.value}}}if(i.length)return Promise.all(i).then(()=>o);return o}});var wd=g("$ZodEnum",(e,t)=>{U.init(e,t);let o=yi(t.entries),r=new Set(o);e._zod.values=r,e._zod.pattern=new RegExp(`^(${o.filter((n)=>xl.has(typeof n)).map((n)=>typeof n==="string"?Xe(n):n.toString()).join("|")})$`),e._zod.parse=(n,i)=>{let a=n.value;if(r.has(a))return n;return n.issues.push({code:"invalid_value",values:o,input:a,inst:e}),n}}),Rd=g("$ZodLiteral",(e,t)=>{if(U.init(e,t),t.values.length===0)throw Error("Cannot create literal schema with no valid values");let o=new Set(t.values);e._zod.values=o,e._zod.pattern=new RegExp(`^(${t.values.map((r)=>typeof r==="string"?Xe(r):r?Xe(r.toString()):String(r)).join("|")})$`),e._zod.parse=(r,n)=>{let i=r.value;if(o.has(i))return r;return r.issues.push({code:"invalid_value",values:t.values,input:i,inst:e}),r}});var xd=g("$ZodTransform",(e,t)=>{U.init(e,t),e._zod.optin="optional",e._zod.parse=(o,r)=>{if(r.direction==="backward")throw new Dr(e.constructor.name);let n=t.transform(o.value,o);if(r.async)return(n instanceof Promise?n:Promise.resolve(n)).then((a)=>(o.value=a,o.fallback=!0,o));if(n instanceof Promise)throw new qe;return o.value=n,o.fallback=!0,o}});function Nu(e,t){if(t===void 0&&(e.issues.length||e.fallback))return{issues:[],value:void 0};return e}var Da=g("$ZodOptional",(e,t)=>{U.init(e,t),e._zod.optin="optional",e._zod.optout="optional",L(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),L(e._zod,"pattern",()=>{let o=t.innerType._zod.pattern;return o?new RegExp(`^(${vi(o.source)})?$`):void 0}),e._zod.parse=(o,r)=>{if(t.innerType._zod.optin==="optional"){let n=o.value,i=t.innerType._zod.run(o,r);if(i instanceof Promise)return i.then((a)=>Nu(a,n));return Nu(i,n)}if(o.value===void 0)return o;return t.innerType._zod.run(o,r)}}),Pd=g("$ZodExactOptional",(e,t)=>{Da.init(e,t),L(e._zod,"values",()=>t.innerType._zod.values),L(e._zod,"pattern",()=>t.innerType._zod.pattern),e._zod.parse=(o,r)=>t.innerType._zod.run(o,r)}),Td=g("$ZodNullable",(e,t)=>{U.init(e,t),L(e._zod,"optin",()=>t.innerType._zod.optin),L(e._zod,"optout",()=>t.innerType._zod.optout),L(e._zod,"pattern",()=>{let o=t.innerType._zod.pattern;return o?new RegExp(`^(${vi(o.source)}|null)$`):void 0}),L(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(o,r)=>{if(o.value===null)return o;return t.innerType._zod.run(o,r)}}),Ed=g("$ZodDefault",(e,t)=>{U.init(e,t),e._zod.optin="optional",L(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(o,r)=>{if(r.direction==="backward")return t.innerType._zod.run(o,r);if(o.value===void 0)return o.value=t.defaultValue,o;let n=t.innerType._zod.run(o,r);if(n instanceof Promise)return n.then((i)=>Au(i,t));return Au(n,t)}});function Au(e,t){if(e.value===void 0)e.value=t.defaultValue;return e}var kd=g("$ZodPrefault",(e,t)=>{U.init(e,t),e._zod.optin="optional",L(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(o,r)=>{if(r.direction==="backward")return t.innerType._zod.run(o,r);if(o.value===void 0)o.value=t.defaultValue;return t.innerType._zod.run(o,r)}}),$d=g("$ZodNonOptional",(e,t)=>{U.init(e,t),L(e._zod,"values",()=>{let o=t.innerType._zod.values;return o?new Set([...o].filter((r)=>r!==void 0)):void 0}),e._zod.parse=(o,r)=>{let n=t.innerType._zod.run(o,r);if(n instanceof Promise)return n.then((i)=>Mu(i,e));return Mu(n,e)}});function Mu(e,t){if(!e.issues.length&&e.value===void 0)e.issues.push({code:"invalid_type",expected:"nonoptional",input:e.value,inst:t});return e}var Cd=g("$ZodCatch",(e,t)=>{U.init(e,t),e._zod.optin="optional",L(e._zod,"optout",()=>t.innerType._zod.optout),L(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(o,r)=>{if(r.direction==="backward")return t.innerType._zod.run(o,r);let n=t.innerType._zod.run(o,r);if(n instanceof Promise)return n.then((i)=>{if(o.value=i.value,i.issues.length)o.value=t.catchValue({...o,error:{issues:i.issues.map((a)=>we(a,r,le()))},input:o.value}),o.issues=[],o.fallback=!0;return o});if(o.value=n.value,n.issues.length)o.value=t.catchValue({...o,error:{issues:n.issues.map((i)=>we(i,r,le()))},input:o.value}),o.issues=[],o.fallback=!0;return o}});var Va=g("$ZodPipe",(e,t)=>{U.init(e,t),L(e._zod,"values",()=>t.in._zod.values),L(e._zod,"optin",()=>t.in._zod.optin),L(e._zod,"optout",()=>t.out._zod.optout),L(e._zod,"propValues",()=>t.in._zod.propValues),e._zod.parse=(o,r)=>{if(r.direction==="backward"){let i=t.out._zod.run(o,r);if(i instanceof Promise)return i.then((a)=>Pi(a,t.in,r));return Pi(i,t.in,r)}let n=t.in._zod.run(o,r);if(n instanceof Promise)return n.then((i)=>Pi(i,t.out,r));return Pi(n,t.out,r)}});function Pi(e,t,o){if(e.issues.length)return e.aborted=!0,e;return t._zod.run({value:e.value,issues:e.issues,fallback:e.fallback},o)}var Id=g("$ZodPreprocess",(e,t)=>{Va.init(e,t)}),Od=g("$ZodReadonly",(e,t)=>{U.init(e,t),L(e._zod,"propValues",()=>t.innerType._zod.propValues),L(e._zod,"values",()=>t.innerType._zod.values),L(e._zod,"optin",()=>t.innerType?._zod?.optin),L(e._zod,"optout",()=>t.innerType?._zod?.optout),e._zod.parse=(o,r)=>{if(r.direction==="backward")return t.innerType._zod.run(o,r);let n=t.innerType._zod.run(o,r);if(n instanceof Promise)return n.then(qu);return qu(n)}});function qu(e){return e.value=Object.freeze(e.value),e}var Nd=g("$ZodLazy",(e,t)=>{U.init(e,t),L(e._zod,"innerType",()=>{let o=t;if(!o._cachedInner)o._cachedInner=t.getter();return o._cachedInner}),L(e._zod,"pattern",()=>e._zod.innerType?._zod?.pattern),L(e._zod,"propValues",()=>e._zod.innerType?._zod?.propValues),L(e._zod,"optin",()=>e._zod.innerType?._zod?.optin??void 0),L(e._zod,"optout",()=>e._zod.innerType?._zod?.optout??void 0),e._zod.parse=(o,r)=>e._zod.innerType._zod.run(o,r)}),Ad=g("$ZodCustom",(e,t)=>{ee.init(e,t),U.init(e,t),e._zod.parse=(o,r)=>o,e._zod.check=(o)=>{let r=o.value,n=t.fn(r);if(n instanceof Promise)return n.then((i)=>ju(i,o,r,e));ju(n,o,r,e);return}});function ju(e,t,o,r){if(!e){let n={code:"custom",input:o,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};if(r._zod.def.params)n.params=r._zod.def.params;t.issues.push(kt(n))}}var of=()=>{let e={string:{unit:"characters",verb:"to have"},file:{unit:"bytes",verb:"to have"},array:{unit:"items",verb:"to have"},set:{unit:"items",verb:"to have"},map:{unit:"entries",verb:"to have"}};function t(n){return e[n]??null}let o={regex:"input",email:"email address",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO datetime",date:"ISO date",time:"ISO time",duration:"ISO duration",ipv4:"IPv4 address",ipv6:"IPv6 address",mac:"MAC address",cidrv4:"IPv4 range",cidrv6:"IPv6 range",base64:"base64-encoded string",base64url:"base64url-encoded string",json_string:"JSON string",e164:"E.164 number",jwt:"JWT",template_literal:"input"},r={nan:"NaN"};return(n)=>{switch(n.code){case"invalid_type":{let i=r[n.expected]??n.expected,a=kl(n.input),c=r[a]??a;return`Invalid input: expected ${i}, received ${c}`}case"invalid_value":if(n.values.length===1)return`Invalid input: expected ${ka(n.values[0])}`;return`Invalid option: expected one of ${xa(n.values,"|")}`;case"too_big":{let i=n.inclusive?"<=":"<",a=t(n.origin);if(a)return`Too big: expected ${n.origin??"value"} to have ${i}${n.maximum.toString()} ${a.unit??"elements"}`;return`Too big: expected ${n.origin??"value"} to be ${i}${n.maximum.toString()}`}case"too_small":{let i=n.inclusive?">=":">",a=t(n.origin);if(a)return`Too small: expected ${n.origin} to have ${i}${n.minimum.toString()} ${a.unit}`;return`Too small: expected ${n.origin} to be ${i}${n.minimum.toString()}`}case"invalid_format":{let i=n;if(i.format==="starts_with")return`Invalid string: must start with "${i.prefix}"`;if(i.format==="ends_with")return`Invalid string: must end with "${i.suffix}"`;if(i.format==="includes")return`Invalid string: must include "${i.includes}"`;if(i.format==="regex")return`Invalid string: must match pattern ${i.pattern}`;return`Invalid ${o[i.format]??n.format}`}case"not_multiple_of":return`Invalid number: must be a multiple of ${n.divisor}`;case"unrecognized_keys":return`Unrecognized key${n.keys.length>1?"s":""}: ${xa(n.keys,", ")}`;case"invalid_key":return`Invalid key in ${n.origin}`;case"invalid_union":if(n.options&&Array.isArray(n.options)&&n.options.length>0)return`Invalid discriminator value. Expected ${n.options.map((a)=>`'${a}'`).join(" | ")}`;return"Invalid input";case"invalid_element":return`Invalid value in ${n.origin}`;default:return"Invalid input"}}};function Ha(){return{localeError:of()}}var Md,rf=Symbol("ZodOutput"),nf=Symbol("ZodInput");class qd{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...t){let o=t[0];if(this._map.set(e,o),o&&typeof o==="object"&&"id"in o)this._idmap.set(o.id,e);return this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(e){let t=this._map.get(e);if(t&&typeof t==="object"&&"id"in t)this._idmap.delete(t.id);return this._map.delete(e),this}get(e){let t=e._zod.parent;if(t){let o={...this.get(t)??{}};delete o.id;let r={...o,...this._map.get(e)};return Object.keys(r).length?r:void 0}return this._map.get(e)}has(e){return this._map.has(e)}}function jd(){return new qd}(Md=globalThis).__zod_globalRegistry??(Md.__zod_globalRegistry=jd());var tt=globalThis.__zod_globalRegistry;function Ld(e,t){return new e({type:"string",...T(t)})}function Fa(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...T(t)})}function Ja(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...T(t)})}function Ud(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...T(t)})}function Zd(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...T(t)})}function Dd(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...T(t)})}function Vd(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...T(t)})}function Ba(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...T(t)})}function Hd(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...T(t)})}function Fd(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...T(t)})}function Jd(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...T(t)})}function Bd(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...T(t)})}function Gd(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...T(t)})}function Wd(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...T(t)})}function Kd(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...T(t)})}function Yd(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...T(t)})}function Qd(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...T(t)})}function Xd(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...T(t)})}function ep(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...T(t)})}function tp(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...T(t)})}function op(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...T(t)})}function rp(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...T(t)})}function np(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...T(t)})}function sp(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...T(t)})}function ip(e,t){return new e({type:"string",format:"date",check:"string_format",...T(t)})}function ap(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...T(t)})}function cp(e,t){return new e({type:"string",format:"duration",check:"string_format",...T(t)})}function lp(e,t){return new e({type:"number",checks:[],...T(t)})}function up(e,t){return new e({type:"number",coerce:!0,checks:[],...T(t)})}function dp(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...T(t)})}function pp(e,t){return new e({type:"boolean",...T(t)})}function hp(e,t){return new e({type:"undefined",...T(t)})}function mp(e,t){return new e({type:"null",...T(t)})}function fp(e){return new e({type:"any"})}function gp(e){return new e({type:"unknown"})}function Sp(e,t){return new e({type:"never",...T(t)})}function ki(e,t){return new Ma({check:"less_than",...T(t),value:e,inclusive:!1})}function Wr(e,t){return new Ma({check:"less_than",...T(t),value:e,inclusive:!0})}function $i(e,t){return new qa({check:"greater_than",...T(t),value:e,inclusive:!1})}function Kr(e,t){return new qa({check:"greater_than",...T(t),value:e,inclusive:!0})}function Ci(e,t){return new Su({check:"multiple_of",...T(t),value:e})}function Ii(e,t){return new yu({check:"max_length",...T(t),maximum:e})}function go(e,t){return new bu({check:"min_length",...T(t),minimum:e})}function Oi(e,t){return new vu({check:"length_equals",...T(t),length:e})}function Ga(e,t){return new zu({check:"string_format",format:"regex",...T(t),pattern:e})}function Wa(e){return new wu({check:"string_format",format:"lowercase",...T(e)})}function Ka(e){return new Ru({check:"string_format",format:"uppercase",...T(e)})}function Ya(e,t){return new xu({check:"string_format",format:"includes",...T(t),includes:e})}function Qa(e,t){return new Pu({check:"string_format",format:"starts_with",...T(t),prefix:e})}function Xa(e,t){return new Tu({check:"string_format",format:"ends_with",...T(t),suffix:e})}function ot(e){return new Eu({check:"overwrite",tx:e})}function ec(e){return ot((t)=>t.normalize(e))}function tc(){return ot((e)=>e.trim())}function oc(){return ot((e)=>e.toLowerCase())}function rc(){return ot((e)=>e.toUpperCase())}function nc(){return ot((e)=>wl(e))}function _p(e,t,o){return new e({type:"array",element:t,...T(o)})}function yp(e,t,o){return new e({type:"custom",check:"custom",fn:t,...T(o)})}function bp(e,t){let o=sf((r)=>(r.addIssue=(n)=>{if(typeof n==="string")r.issues.push(kt(n,r.value,o._zod.def));else{let i=n;if(i.fatal)i.continue=!1;i.code??(i.code="custom"),i.input??(i.input=r.value),i.inst??(i.inst=o),i.continue??(i.continue=!o._zod.def.abort),r.issues.push(kt(i))}},e(r.value,r)),t);return o}function sf(e,t){let o=new ee({check:"custom",...T(t)});return o._zod.check=e,o}function Qr(e){let t=e?.target??"draft-2020-12";if(t==="draft-4")t="draft-04";if(t==="draft-7")t="draft-07";return{processors:e.processors??{},metadataRegistry:e?.metadata??tt,target:t,unrepresentable:e?.unrepresentable??"throw",override:e?.override??(()=>{}),io:e?.io??"output",counter:0,seen:new Map,cycles:e?.cycles??"ref",reused:e?.reused??"inline",external:e?.external??void 0}}function Z(e,t,o={path:[],schemaPath:[]}){var r;let n=e._zod.def,i=t.seen.get(e);if(i){if(i.count++,o.schemaPath.includes(e))i.cycle=o.path;return i.schema}let a={schema:{},count:1,cycle:void 0,path:o.path};t.seen.set(e,a);let c=e._zod.toJSONSchema?.();if(c)a.schema=c;else{let m={...o,schemaPath:[...o.schemaPath,e],path:o.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,a.schema,m);else{let y=a.schema,S=t.processors[n.type];if(!S)throw Error(`[toJSONSchema]: Non-representable type encountered: ${n.type}`);S(e,t,y,m)}let f=e._zod.parent;if(f){if(!a.ref)a.ref=f;Z(f,t,m),t.seen.get(f).isParent=!0}}let d=t.metadataRegistry.get(e);if(d)Object.assign(a.schema,d);if(t.io==="input"&&ue(e))delete a.schema.examples,delete a.schema.default;if(t.io==="input"&&"_prefault"in a.schema)(r=a.schema).default??(r.default=a.schema._prefault);return delete a.schema._prefault,t.seen.get(e).schema}function Xr(e,t){let o=e.seen.get(t);if(!o)throw Error("Unprocessed schema. This is a bug in Zod.");let r=new Map;for(let a of e.seen.entries()){let c=e.metadataRegistry.get(a[0])?.id;if(c){let d=r.get(c);if(d&&d!==a[0])throw Error(`Duplicate schema id "${c}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);r.set(c,a[0])}}let n=(a)=>{let c=e.target==="draft-2020-12"?"$defs":"definitions";if(e.external){let f=e.external.registry.get(a[0])?.id,y=e.external.uri??((w)=>w);if(f)return{ref:y(f)};let S=a[1].defId??a[1].schema.id??`schema${e.counter++}`;return a[1].defId=S,{defId:S,ref:`${y("__shared")}#/${c}/${S}`}}if(a[1]===o)return{ref:"#"};let p=`${"#"}/${c}/`,m=a[1].schema.id??`__schema${e.counter++}`;return{defId:m,ref:p+m}},i=(a)=>{if(a[1].schema.$ref)return;let c=a[1],{ref:d,defId:p}=n(a);if(c.def={...c.schema},p)c.defId=p;let m=c.schema;for(let f in m)delete m[f];m.$ref=d};if(e.cycles==="throw")for(let a of e.seen.entries()){let c=a[1];if(c.cycle)throw Error(`Cycle detected: #/${c.cycle?.join("/")}/<root>
|
|
62
|
+
`)}g.write("payload.value = newResult;"),g.write("return payload;");let V=g.compile();return(P,H)=>V(S,P,H)},s,i=Do,c=!Zo.jitless,u=c&&Ql.value,h=t.catchall,m;e._zod.parse=(S,g)=>{m??(m=r.value);let b=S.value;if(!i(b))return S.issues.push({expected:"object",code:"invalid_type",input:b,inst:e}),S;if(c&&u&&g?.async===!1&&g.jitless!==!0){if(!s)s=n(t.shape);if(S=s(S,g),!h)return S;return Jd([],b,S,g,m,e)}return o(S,g)}});function id(e,t,o,r){for(let s of e)if(s.issues.length===0)return t.value=s.value,t;let n=e.filter((s)=>!ao(s));if(n.length===1)return t.value=n[0].value,n[0];return t.issues.push({code:"invalid_union",input:t.value,inst:o,errors:e.map((s)=>s.issues.map((i)=>Be(i,r,we())))}),t}var cc=_("$ZodUnion",(e,t)=>{Q.init(e,t),W(e._zod,"optin",()=>t.options.some((r)=>r._zod.optin==="optional")?"optional":void 0),W(e._zod,"optout",()=>t.options.some((r)=>r._zod.optout==="optional")?"optional":void 0),W(e._zod,"values",()=>{if(t.options.every((r)=>r._zod.values))return new Set(t.options.flatMap((r)=>Array.from(r._zod.values)));return}),W(e._zod,"pattern",()=>{if(t.options.every((r)=>r._zod.pattern)){let r=t.options.map((n)=>n._zod.pattern);return new RegExp(`^(${r.map((n)=>qi(n.source)).join("|")})$`)}return});let o=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(r,n)=>{if(o)return o(r,n);let s=!1,i=[];for(let c of t.options){let l=c._zod.run({value:r.value,issues:[]},n);if(l instanceof Promise)i.push(l),s=!0;else{if(l.issues.length===0)return l;i.push(l)}}if(!s)return id(i,r,e,n);return Promise.all(i).then((c)=>id(c,r,e,n))}});var Gd=_("$ZodDiscriminatedUnion",(e,t)=>{t.inclusive=!1,cc.init(e,t);let o=e._zod.parse;W(e._zod,"propValues",()=>{let n={};for(let s of t.options){let i=s._zod.propValues;if(!i||Object.keys(i).length===0)throw Error(`Invalid discriminated union option at index "${t.options.indexOf(s)}"`);for(let[c,l]of Object.entries(i)){if(!n[c])n[c]=new Set;for(let u of l)n[c].add(u)}}return n});let r=tn(()=>{let n=t.options,s=new Map;for(let i of n){let c=i._zod.propValues?.[t.discriminator];if(!c||c.size===0)throw Error(`Invalid discriminated union option at index "${t.options.indexOf(i)}"`);for(let l of c){if(s.has(l))throw Error(`Duplicate discriminator value "${String(l)}"`);s.set(l,i)}}return s});e._zod.parse=(n,s)=>{let i=n.value;if(!Do(i))return n.issues.push({code:"invalid_type",expected:"object",input:i,inst:e}),n;let c=r.value.get(i?.[t.discriminator]);if(c)return c._zod.run(n,s);if(t.unionFallback||s.direction==="backward")return o(n,s);return n.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:t.discriminator,options:Array.from(r.value.keys()),input:i,path:[t.discriminator],inst:e}),n}}),Wd=_("$ZodIntersection",(e,t)=>{Q.init(e,t),e._zod.parse=(o,r)=>{let n=o.value,s=t.left._zod.run({value:n,issues:[]},r),i=t.right._zod.run({value:n,issues:[]},r);if(s instanceof Promise||i instanceof Promise)return Promise.all([s,i]).then(([l,u])=>ad(o,l,u));return ad(o,s,i)}});function ic(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(io(e)&&io(t)){let o=Object.keys(t),r=Object.keys(e).filter((s)=>o.indexOf(s)!==-1),n={...e,...t};for(let s of r){let i=ic(e[s],t[s]);if(!i.valid)return{valid:!1,mergeErrorPath:[s,...i.mergeErrorPath]};n[s]=i.data}return{valid:!0,data:n}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};let o=[];for(let r=0;r<e.length;r++){let n=e[r],s=t[r],i=ic(n,s);if(!i.valid)return{valid:!1,mergeErrorPath:[r,...i.mergeErrorPath]};o.push(i.data)}return{valid:!0,data:o}}return{valid:!1,mergeErrorPath:[]}}function ad(e,t,o){let r=new Map,n;for(let c of t.issues)if(c.code==="unrecognized_keys"){n??(n=c);for(let l of c.keys){if(!r.has(l))r.set(l,{});r.get(l).l=!0}}else e.issues.push(c);for(let c of o.issues)if(c.code==="unrecognized_keys")for(let l of c.keys){if(!r.has(l))r.set(l,{});r.get(l).r=!0}else e.issues.push(c);let s=[...r].filter(([,c])=>c.l&&c.r).map(([c])=>c);if(s.length&&n)e.issues.push({...n,keys:s});if(ao(e))return e;let i=ic(t.value,o.value);if(!i.valid)throw Error(`Unmergable intersection. Error path: ${JSON.stringify(i.mergeErrorPath)}`);return e.value=i.data,e}var Kd=_("$ZodRecord",(e,t)=>{Q.init(e,t),e._zod.parse=(o,r)=>{let n=o.value;if(!io(n))return o.issues.push({expected:"record",code:"invalid_type",input:n,inst:e}),o;let s=[],i=t.keyType._zod.values;if(i){o.value={};let c=new Set;for(let u of i)if(typeof u==="string"||typeof u==="number"||typeof u==="symbol"){c.add(typeof u==="number"?u.toString():u);let h=t.keyType._zod.run({value:u,issues:[]},r);if(h instanceof Promise)throw Error("Async schemas not supported in object keys currently");if(h.issues.length){o.issues.push({code:"invalid_key",origin:"record",issues:h.issues.map((g)=>Be(g,r,we())),input:u,path:[u],inst:e});continue}let m=h.value,S=t.valueType._zod.run({value:n[u],issues:[]},r);if(S instanceof Promise)s.push(S.then((g)=>{if(g.issues.length)o.issues.push(...At(u,g.issues));o.value[m]=g.value}));else{if(S.issues.length)o.issues.push(...At(u,S.issues));o.value[m]=S.value}}let l;for(let u in n)if(!c.has(u))l=l??[],l.push(u);if(l&&l.length>0)o.issues.push({code:"unrecognized_keys",input:n,inst:e,keys:l})}else{o.value={};for(let c of Reflect.ownKeys(n)){if(c==="__proto__")continue;if(!Object.prototype.propertyIsEnumerable.call(n,c))continue;let l=t.keyType._zod.run({value:c,issues:[]},r);if(l instanceof Promise)throw Error("Async schemas not supported in object keys currently");if(typeof c==="string"&&oc.test(c)&&l.issues.length){let m=t.keyType._zod.run({value:Number(c),issues:[]},r);if(m instanceof Promise)throw Error("Async schemas not supported in object keys currently");if(m.issues.length===0)l=m}if(l.issues.length){if(t.mode==="loose")o.value[c]=n[c];else o.issues.push({code:"invalid_key",origin:"record",issues:l.issues.map((m)=>Be(m,r,we())),input:c,path:[c],inst:e});continue}let h=t.valueType._zod.run({value:n[c],issues:[]},r);if(h instanceof Promise)s.push(h.then((m)=>{if(m.issues.length)o.issues.push(...At(c,m.issues));o.value[l.value]=m.value}));else{if(h.issues.length)o.issues.push(...At(c,h.issues));o.value[l.value]=h.value}}}if(s.length)return Promise.all(s).then(()=>o);return o}});var Yd=_("$ZodEnum",(e,t)=>{Q.init(e,t);let o=Ai(t.entries),r=new Set(o);e._zod.values=r,e._zod.pattern=new RegExp(`^(${o.filter((n)=>Xl.has(typeof n)).map((n)=>typeof n==="string"?Nt(n):n.toString()).join("|")})$`),e._zod.parse=(n,s)=>{let i=n.value;if(r.has(i))return n;return n.issues.push({code:"invalid_value",values:o,input:i,inst:e}),n}}),Qd=_("$ZodLiteral",(e,t)=>{if(Q.init(e,t),t.values.length===0)throw Error("Cannot create literal schema with no valid values");let o=new Set(t.values);e._zod.values=o,e._zod.pattern=new RegExp(`^(${t.values.map((r)=>typeof r==="string"?Nt(r):r?Nt(r.toString()):String(r)).join("|")})$`),e._zod.parse=(r,n)=>{let s=r.value;if(o.has(s))return r;return r.issues.push({code:"invalid_value",values:t.values,input:s,inst:e}),r}});var Xd=_("$ZodTransform",(e,t)=>{Q.init(e,t),e._zod.optin="optional",e._zod.parse=(o,r)=>{if(r.direction==="backward")throw new Xr(e.constructor.name);let n=t.transform(o.value,o);if(r.async)return(n instanceof Promise?n:Promise.resolve(n)).then((i)=>(o.value=i,o.fallback=!0,o));if(n instanceof Promise)throw new gt;return o.value=n,o.fallback=!0,o}});function cd(e,t){if(t===void 0&&(e.issues.length||e.fallback))return{issues:[],value:void 0};return e}var lc=_("$ZodOptional",(e,t)=>{Q.init(e,t),e._zod.optin="optional",e._zod.optout="optional",W(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),W(e._zod,"pattern",()=>{let o=t.innerType._zod.pattern;return o?new RegExp(`^(${qi(o.source)})?$`):void 0}),e._zod.parse=(o,r)=>{if(t.innerType._zod.optin==="optional"){let n=o.value,s=t.innerType._zod.run(o,r);if(s instanceof Promise)return s.then((i)=>cd(i,n));return cd(s,n)}if(o.value===void 0)return o;return t.innerType._zod.run(o,r)}}),ep=_("$ZodExactOptional",(e,t)=>{lc.init(e,t),W(e._zod,"values",()=>t.innerType._zod.values),W(e._zod,"pattern",()=>t.innerType._zod.pattern),e._zod.parse=(o,r)=>t.innerType._zod.run(o,r)}),tp=_("$ZodNullable",(e,t)=>{Q.init(e,t),W(e._zod,"optin",()=>t.innerType._zod.optin),W(e._zod,"optout",()=>t.innerType._zod.optout),W(e._zod,"pattern",()=>{let o=t.innerType._zod.pattern;return o?new RegExp(`^(${qi(o.source)}|null)$`):void 0}),W(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(o,r)=>{if(o.value===null)return o;return t.innerType._zod.run(o,r)}}),op=_("$ZodDefault",(e,t)=>{Q.init(e,t),e._zod.optin="optional",W(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(o,r)=>{if(r.direction==="backward")return t.innerType._zod.run(o,r);if(o.value===void 0)return o.value=t.defaultValue,o;let n=t.innerType._zod.run(o,r);if(n instanceof Promise)return n.then((s)=>ld(s,t));return ld(n,t)}});function ld(e,t){if(e.value===void 0)e.value=t.defaultValue;return e}var rp=_("$ZodPrefault",(e,t)=>{Q.init(e,t),e._zod.optin="optional",W(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(o,r)=>{if(r.direction==="backward")return t.innerType._zod.run(o,r);if(o.value===void 0)o.value=t.defaultValue;return t.innerType._zod.run(o,r)}}),np=_("$ZodNonOptional",(e,t)=>{Q.init(e,t),W(e._zod,"values",()=>{let o=t.innerType._zod.values;return o?new Set([...o].filter((r)=>r!==void 0)):void 0}),e._zod.parse=(o,r)=>{let n=t.innerType._zod.run(o,r);if(n instanceof Promise)return n.then((s)=>ud(s,e));return ud(n,e)}});function ud(e,t){if(!e.issues.length&&e.value===void 0)e.issues.push({code:"invalid_type",expected:"nonoptional",input:e.value,inst:t});return e}var sp=_("$ZodCatch",(e,t)=>{Q.init(e,t),e._zod.optin="optional",W(e._zod,"optout",()=>t.innerType._zod.optout),W(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(o,r)=>{if(r.direction==="backward")return t.innerType._zod.run(o,r);let n=t.innerType._zod.run(o,r);if(n instanceof Promise)return n.then((s)=>{if(o.value=s.value,s.issues.length)o.value=t.catchValue({...o,error:{issues:s.issues.map((i)=>Be(i,r,we()))},input:o.value}),o.issues=[],o.fallback=!0;return o});if(o.value=n.value,n.issues.length)o.value=t.catchValue({...o,error:{issues:n.issues.map((s)=>Be(s,r,we()))},input:o.value}),o.issues=[],o.fallback=!0;return o}});var uc=_("$ZodPipe",(e,t)=>{Q.init(e,t),W(e._zod,"values",()=>t.in._zod.values),W(e._zod,"optin",()=>t.in._zod.optin),W(e._zod,"optout",()=>t.out._zod.optout),W(e._zod,"propValues",()=>t.in._zod.propValues),e._zod.parse=(o,r)=>{if(r.direction==="backward"){let s=t.out._zod.run(o,r);if(s instanceof Promise)return s.then((i)=>Di(i,t.in,r));return Di(s,t.in,r)}let n=t.in._zod.run(o,r);if(n instanceof Promise)return n.then((s)=>Di(s,t.out,r));return Di(n,t.out,r)}});function Di(e,t,o){if(e.issues.length)return e.aborted=!0,e;return t._zod.run({value:e.value,issues:e.issues,fallback:e.fallback},o)}var ip=_("$ZodPreprocess",(e,t)=>{uc.init(e,t)}),ap=_("$ZodReadonly",(e,t)=>{Q.init(e,t),W(e._zod,"propValues",()=>t.innerType._zod.propValues),W(e._zod,"values",()=>t.innerType._zod.values),W(e._zod,"optin",()=>t.innerType?._zod?.optin),W(e._zod,"optout",()=>t.innerType?._zod?.optout),e._zod.parse=(o,r)=>{if(r.direction==="backward")return t.innerType._zod.run(o,r);let n=t.innerType._zod.run(o,r);if(n instanceof Promise)return n.then(dd);return dd(n)}});function dd(e){return e.value=Object.freeze(e.value),e}var cp=_("$ZodLazy",(e,t)=>{Q.init(e,t),W(e._zod,"innerType",()=>{let o=t;if(!o._cachedInner)o._cachedInner=t.getter();return o._cachedInner}),W(e._zod,"pattern",()=>e._zod.innerType?._zod?.pattern),W(e._zod,"propValues",()=>e._zod.innerType?._zod?.propValues),W(e._zod,"optin",()=>e._zod.innerType?._zod?.optin??void 0),W(e._zod,"optout",()=>e._zod.innerType?._zod?.optout??void 0),e._zod.parse=(o,r)=>e._zod.innerType._zod.run(o,r)}),lp=_("$ZodCustom",(e,t)=>{he.init(e,t),Q.init(e,t),e._zod.parse=(o,r)=>o,e._zod.check=(o)=>{let r=o.value,n=t.fn(r);if(n instanceof Promise)return n.then((s)=>pd(s,o,r,e));pd(n,o,r,e);return}});function pd(e,t,o,r){if(!e){let n={code:"custom",input:o,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};if(r._zod.def.params)n.params=r._zod.def.params;t.issues.push(co(n))}}var Xf=()=>{let e={string:{unit:"characters",verb:"to have"},file:{unit:"bytes",verb:"to have"},array:{unit:"items",verb:"to have"},set:{unit:"items",verb:"to have"},map:{unit:"entries",verb:"to have"}};function t(n){return e[n]??null}let o={regex:"input",email:"email address",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO datetime",date:"ISO date",time:"ISO time",duration:"ISO duration",ipv4:"IPv4 address",ipv6:"IPv6 address",mac:"MAC address",cidrv4:"IPv4 range",cidrv6:"IPv6 range",base64:"base64-encoded string",base64url:"base64url-encoded string",json_string:"JSON string",e164:"E.164 number",jwt:"JWT",template_literal:"input"},r={nan:"NaN"};return(n)=>{switch(n.code){case"invalid_type":{let s=r[n.expected]??n.expected,i=ru(n.input),c=r[i]??i;return`Invalid input: expected ${s}, received ${c}`}case"invalid_value":if(n.values.length===1)return`Invalid input: expected ${Ka(n.values[0])}`;return`Invalid option: expected one of ${Ja(n.values,"|")}`;case"too_big":{let s=n.inclusive?"<=":"<",i=t(n.origin);if(i)return`Too big: expected ${n.origin??"value"} to have ${s}${n.maximum.toString()} ${i.unit??"elements"}`;return`Too big: expected ${n.origin??"value"} to be ${s}${n.maximum.toString()}`}case"too_small":{let s=n.inclusive?">=":">",i=t(n.origin);if(i)return`Too small: expected ${n.origin} to have ${s}${n.minimum.toString()} ${i.unit}`;return`Too small: expected ${n.origin} to be ${s}${n.minimum.toString()}`}case"invalid_format":{let s=n;if(s.format==="starts_with")return`Invalid string: must start with "${s.prefix}"`;if(s.format==="ends_with")return`Invalid string: must end with "${s.suffix}"`;if(s.format==="includes")return`Invalid string: must include "${s.includes}"`;if(s.format==="regex")return`Invalid string: must match pattern ${s.pattern}`;return`Invalid ${o[s.format]??n.format}`}case"not_multiple_of":return`Invalid number: must be a multiple of ${n.divisor}`;case"unrecognized_keys":return`Unrecognized key${n.keys.length>1?"s":""}: ${Ja(n.keys,", ")}`;case"invalid_key":return`Invalid key in ${n.origin}`;case"invalid_union":if(n.options&&Array.isArray(n.options)&&n.options.length>0)return`Invalid discriminator value. Expected ${n.options.map((i)=>`'${i}'`).join(" | ")}`;return"Invalid input";case"invalid_element":return`Invalid value in ${n.origin}`;default:return"Invalid input"}}};function dc(){return{localeError:Xf()}}var up,eg=Symbol("ZodOutput"),tg=Symbol("ZodInput");class dp{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...t){let o=t[0];if(this._map.set(e,o),o&&typeof o==="object"&&"id"in o)this._idmap.set(o.id,e);return this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(e){let t=this._map.get(e);if(t&&typeof t==="object"&&"id"in t)this._idmap.delete(t.id);return this._map.delete(e),this}get(e){let t=e._zod.parent;if(t){let o={...this.get(t)??{}};delete o.id;let r={...o,...this._map.get(e)};return Object.keys(r).length?r:void 0}return this._map.get(e)}has(e){return this._map.has(e)}}function pp(){return new dp}(up=globalThis).__zod_globalRegistry??(up.__zod_globalRegistry=pp());var Mt=globalThis.__zod_globalRegistry;function hp(e,t){return new e({type:"string",...N(t)})}function pc(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...N(t)})}function hc(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...N(t)})}function mp(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...N(t)})}function fp(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...N(t)})}function gp(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...N(t)})}function Sp(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...N(t)})}function mc(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...N(t)})}function _p(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...N(t)})}function yp(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...N(t)})}function bp(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...N(t)})}function vp(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...N(t)})}function zp(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...N(t)})}function Rp(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...N(t)})}function wp(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...N(t)})}function xp(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...N(t)})}function Pp(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...N(t)})}function Tp(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...N(t)})}function Ep(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...N(t)})}function kp(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...N(t)})}function $p(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...N(t)})}function Cp(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...N(t)})}function Ip(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...N(t)})}function Op(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...N(t)})}function Np(e,t){return new e({type:"string",format:"date",check:"string_format",...N(t)})}function Ap(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...N(t)})}function Mp(e,t){return new e({type:"string",format:"duration",check:"string_format",...N(t)})}function qp(e,t){return new e({type:"number",checks:[],...N(t)})}function jp(e,t){return new e({type:"number",coerce:!0,checks:[],...N(t)})}function Lp(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...N(t)})}function Up(e,t){return new e({type:"boolean",...N(t)})}function Zp(e,t){return new e({type:"undefined",...N(t)})}function Dp(e,t){return new e({type:"null",...N(t)})}function Vp(e){return new e({type:"any"})}function Hp(e){return new e({type:"unknown"})}function Fp(e,t){return new e({type:"never",...N(t)})}function Fi(e,t){return new rc({check:"less_than",...N(t),value:e,inclusive:!1})}function an(e,t){return new rc({check:"less_than",...N(t),value:e,inclusive:!0})}function Ji(e,t){return new nc({check:"greater_than",...N(t),value:e,inclusive:!1})}function cn(e,t){return new nc({check:"greater_than",...N(t),value:e,inclusive:!0})}function Bi(e,t){return new Fu({check:"multiple_of",...N(t),value:e})}function Gi(e,t){return new Bu({check:"max_length",...N(t),maximum:e})}function Vo(e,t){return new Gu({check:"min_length",...N(t),minimum:e})}function Wi(e,t){return new Wu({check:"length_equals",...N(t),length:e})}function fc(e,t){return new Ku({check:"string_format",format:"regex",...N(t),pattern:e})}function gc(e){return new Yu({check:"string_format",format:"lowercase",...N(e)})}function Sc(e){return new Qu({check:"string_format",format:"uppercase",...N(e)})}function _c(e,t){return new Xu({check:"string_format",format:"includes",...N(t),includes:e})}function yc(e,t){return new ed({check:"string_format",format:"starts_with",...N(t),prefix:e})}function bc(e,t){return new td({check:"string_format",format:"ends_with",...N(t),suffix:e})}function qt(e){return new od({check:"overwrite",tx:e})}function vc(e){return qt((t)=>t.normalize(e))}function zc(){return qt((e)=>e.trim())}function Rc(){return qt((e)=>e.toLowerCase())}function wc(){return qt((e)=>e.toUpperCase())}function xc(){return qt((e)=>Yl(e))}function Jp(e,t,o){return new e({type:"array",element:t,...N(o)})}function Bp(e,t,o){return new e({type:"custom",check:"custom",fn:t,...N(o)})}function Gp(e,t){let o=og((r)=>(r.addIssue=(n)=>{if(typeof n==="string")r.issues.push(co(n,r.value,o._zod.def));else{let s=n;if(s.fatal)s.continue=!1;s.code??(s.code="custom"),s.input??(s.input=r.value),s.inst??(s.inst=o),s.continue??(s.continue=!o._zod.def.abort),r.issues.push(co(s))}},e(r.value,r)),t);return o}function og(e,t){let o=new he({check:"custom",...N(t)});return o._zod.check=e,o}function un(e){let t=e?.target??"draft-2020-12";if(t==="draft-4")t="draft-04";if(t==="draft-7")t="draft-07";return{processors:e.processors??{},metadataRegistry:e?.metadata??Mt,target:t,unrepresentable:e?.unrepresentable??"throw",override:e?.override??(()=>{}),io:e?.io??"output",counter:0,seen:new Map,cycles:e?.cycles??"ref",reused:e?.reused??"inline",external:e?.external??void 0}}function X(e,t,o={path:[],schemaPath:[]}){var r;let n=e._zod.def,s=t.seen.get(e);if(s){if(s.count++,o.schemaPath.includes(e))s.cycle=o.path;return s.schema}let i={schema:{},count:1,cycle:void 0,path:o.path};t.seen.set(e,i);let c=e._zod.toJSONSchema?.();if(c)i.schema=c;else{let h={...o,schemaPath:[...o.schemaPath,e],path:o.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,i.schema,h);else{let S=i.schema,g=t.processors[n.type];if(!g)throw Error(`[toJSONSchema]: Non-representable type encountered: ${n.type}`);g(e,t,S,h)}let m=e._zod.parent;if(m){if(!i.ref)i.ref=m;X(m,t,h),t.seen.get(m).isParent=!0}}let l=t.metadataRegistry.get(e);if(l)Object.assign(i.schema,l);if(t.io==="input"&&xe(e))delete i.schema.examples,delete i.schema.default;if(t.io==="input"&&"_prefault"in i.schema)(r=i.schema).default??(r.default=i.schema._prefault);return delete i.schema._prefault,t.seen.get(e).schema}function dn(e,t){let o=e.seen.get(t);if(!o)throw Error("Unprocessed schema. This is a bug in Zod.");let r=new Map;for(let i of e.seen.entries()){let c=e.metadataRegistry.get(i[0])?.id;if(c){let l=r.get(c);if(l&&l!==i[0])throw Error(`Duplicate schema id "${c}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);r.set(c,i[0])}}let n=(i)=>{let c=e.target==="draft-2020-12"?"$defs":"definitions";if(e.external){let m=e.external.registry.get(i[0])?.id,S=e.external.uri??((b)=>b);if(m)return{ref:S(m)};let g=i[1].defId??i[1].schema.id??`schema${e.counter++}`;return i[1].defId=g,{defId:g,ref:`${S("__shared")}#/${c}/${g}`}}if(i[1]===o)return{ref:"#"};let u=`${"#"}/${c}/`,h=i[1].schema.id??`__schema${e.counter++}`;return{defId:h,ref:u+h}},s=(i)=>{if(i[1].schema.$ref)return;let c=i[1],{ref:l,defId:u}=n(i);if(c.def={...c.schema},u)c.defId=u;let h=c.schema;for(let m in h)delete h[m];h.$ref=l};if(e.cycles==="throw")for(let i of e.seen.entries()){let c=i[1];if(c.cycle)throw Error(`Cycle detected: #/${c.cycle?.join("/")}/<root>
|
|
63
63
|
|
|
64
|
-
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let a of e.seen.entries()){let c=a[1];if(t===a[0]){i(a);continue}if(e.external){let p=e.external.registry.get(a[0])?.id;if(t!==a[0]&&p){i(a);continue}}if(e.metadataRegistry.get(a[0])?.id){i(a);continue}if(c.cycle){i(a);continue}if(c.count>1){if(e.reused==="ref"){i(a);continue}}}}function en(e,t){let o=e.seen.get(t);if(!o)throw Error("Unprocessed schema. This is a bug in Zod.");let r=(c)=>{let d=e.seen.get(c);if(d.ref===null)return;let p=d.def??d.schema,m={...p},f=d.ref;if(d.ref=null,f){r(f);let S=e.seen.get(f),w=S.schema;if(w.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0"))p.allOf=p.allOf??[],p.allOf.push(w);else Object.assign(p,w);if(Object.assign(p,m),c._zod.parent===f)for(let R in p){if(R==="$ref"||R==="allOf")continue;if(!(R in m))delete p[R]}if(w.$ref&&S.def)for(let R in p){if(R==="$ref"||R==="allOf")continue;if(R in S.def&&JSON.stringify(p[R])===JSON.stringify(S.def[R]))delete p[R]}}let y=c._zod.parent;if(y&&y!==f){r(y);let S=e.seen.get(y);if(S?.schema.$ref){if(p.$ref=S.schema.$ref,S.def)for(let w in p){if(w==="$ref"||w==="allOf")continue;if(w in S.def&&JSON.stringify(p[w])===JSON.stringify(S.def[w]))delete p[w]}}}e.override({zodSchema:c,jsonSchema:p,path:d.path??[]})};for(let c of[...e.seen.entries()].reverse())r(c[0]);let n={};if(e.target==="draft-2020-12")n.$schema="https://json-schema.org/draft/2020-12/schema";else if(e.target==="draft-07")n.$schema="http://json-schema.org/draft-07/schema#";else if(e.target==="draft-04")n.$schema="http://json-schema.org/draft-04/schema#";else if(e.target==="openapi-3.0");if(e.external?.uri){let c=e.external.registry.get(t)?.id;if(!c)throw Error("Schema is missing an `id` property");n.$id=e.external.uri(c)}Object.assign(n,o.def??o.schema);let i=e.metadataRegistry.get(t)?.id;if(i!==void 0&&n.id===i)delete n.id;let a=e.external?.defs??{};for(let c of e.seen.entries()){let d=c[1];if(d.def&&d.defId){if(d.def.id===d.defId)delete d.def.id;a[d.defId]=d.def}}if(e.external);else if(Object.keys(a).length>0)if(e.target==="draft-2020-12")n.$defs=a;else n.definitions=a;try{let c=JSON.parse(JSON.stringify(n));return Object.defineProperty(c,"~standard",{value:{...t["~standard"],jsonSchema:{input:Yr(t,"input",e.processors),output:Yr(t,"output",e.processors)}},enumerable:!1,writable:!1}),c}catch(c){throw Error("Error converting schema to JSON.")}}function ue(e,t){let o=t??{seen:new Set};if(o.seen.has(e))return!1;o.seen.add(e);let r=e._zod.def;if(r.type==="transform")return!0;if(r.type==="array")return ue(r.element,o);if(r.type==="set")return ue(r.valueType,o);if(r.type==="lazy")return ue(r.getter(),o);if(r.type==="promise"||r.type==="optional"||r.type==="nonoptional"||r.type==="nullable"||r.type==="readonly"||r.type==="default"||r.type==="prefault")return ue(r.innerType,o);if(r.type==="intersection")return ue(r.left,o)||ue(r.right,o);if(r.type==="record"||r.type==="map")return ue(r.keyType,o)||ue(r.valueType,o);if(r.type==="pipe"){if(e._zod.traits.has("$ZodCodec"))return!0;return ue(r.in,o)||ue(r.out,o)}if(r.type==="object"){for(let n in r.shape)if(ue(r.shape[n],o))return!0;return!1}if(r.type==="union"){for(let n of r.options)if(ue(n,o))return!0;return!1}if(r.type==="tuple"){for(let n of r.items)if(ue(n,o))return!0;if(r.rest&&ue(r.rest,o))return!0;return!1}return!1}var vp=(e,t={})=>(o)=>{let r=Qr({...o,processors:t});return Z(e,r),Xr(r,e),en(r,e)},Yr=(e,t,o={})=>(r)=>{let{libraryOptions:n,target:i}=r??{},a=Qr({...n??{},target:i,io:t,processors:o});return Z(e,a),Xr(a,e),en(a,e)};var af={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},sc=(e,t,o,r)=>{let n=o;n.type="string";let{minimum:i,maximum:a,format:c,patterns:d,contentEncoding:p}=e._zod.bag;if(typeof i==="number")n.minLength=i;if(typeof a==="number")n.maxLength=a;if(c){if(n.format=af[c]??c,n.format==="")delete n.format;if(c==="time")delete n.format}if(p)n.contentEncoding=p;if(d&&d.size>0){let m=[...d];if(m.length===1)n.pattern=m[0].source;else if(m.length>1)n.allOf=[...m.map((f)=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:f.source}))]}},ic=(e,t,o,r)=>{let n=o,{minimum:i,maximum:a,format:c,multipleOf:d,exclusiveMaximum:p,exclusiveMinimum:m}=e._zod.bag;if(typeof c==="string"&&c.includes("int"))n.type="integer";else n.type="number";let f=typeof m==="number"&&m>=(i??Number.NEGATIVE_INFINITY),y=typeof p==="number"&&p<=(a??Number.POSITIVE_INFINITY),S=t.target==="draft-04"||t.target==="openapi-3.0";if(f)if(S)n.minimum=m,n.exclusiveMinimum=!0;else n.exclusiveMinimum=m;else if(typeof i==="number")n.minimum=i;if(y)if(S)n.maximum=p,n.exclusiveMaximum=!0;else n.exclusiveMaximum=p;else if(typeof a==="number")n.maximum=a;if(typeof d==="number")n.multipleOf=d},ac=(e,t,o,r)=>{o.type="boolean"},wp=(e,t,o,r)=>{if(t.unrepresentable==="throw")throw Error("BigInt cannot be represented in JSON Schema")},Rp=(e,t,o,r)=>{if(t.unrepresentable==="throw")throw Error("Symbols cannot be represented in JSON Schema")},cc=(e,t,o,r)=>{if(t.target==="openapi-3.0")o.type="string",o.nullable=!0,o.enum=[null];else o.type="null"},lc=(e,t,o,r)=>{if(t.unrepresentable==="throw")throw Error("Undefined cannot be represented in JSON Schema")},xp=(e,t,o,r)=>{if(t.unrepresentable==="throw")throw Error("Void cannot be represented in JSON Schema")},uc=(e,t,o,r)=>{o.not={}},dc=(e,t,o,r)=>{},pc=(e,t,o,r)=>{},Pp=(e,t,o,r)=>{if(t.unrepresentable==="throw")throw Error("Date cannot be represented in JSON Schema")},hc=(e,t,o,r)=>{let n=e._zod.def,i=yi(n.entries);if(i.every((a)=>typeof a==="number"))o.type="number";if(i.every((a)=>typeof a==="string"))o.type="string";o.enum=i},mc=(e,t,o,r)=>{let n=e._zod.def,i=[];for(let a of n.values)if(a===void 0){if(t.unrepresentable==="throw")throw Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof a==="bigint")if(t.unrepresentable==="throw")throw Error("BigInt literals cannot be represented in JSON Schema");else i.push(Number(a));else i.push(a);if(i.length===0);else if(i.length===1){let a=i[0];if(o.type=a===null?"null":typeof a,t.target==="draft-04"||t.target==="openapi-3.0")o.enum=[a];else o.const=a}else{if(i.every((a)=>typeof a==="number"))o.type="number";if(i.every((a)=>typeof a==="string"))o.type="string";if(i.every((a)=>typeof a==="boolean"))o.type="boolean";if(i.every((a)=>a===null))o.type="null";o.enum=i}},Tp=(e,t,o,r)=>{if(t.unrepresentable==="throw")throw Error("NaN cannot be represented in JSON Schema")},Ep=(e,t,o,r)=>{let n=o,i=e._zod.pattern;if(!i)throw Error("Pattern not found in template literal");n.type="string",n.pattern=i.source},kp=(e,t,o,r)=>{let n=o,i={type:"string",format:"binary",contentEncoding:"binary"},{minimum:a,maximum:c,mime:d}=e._zod.bag;if(a!==void 0)i.minLength=a;if(c!==void 0)i.maxLength=c;if(d)if(d.length===1)i.contentMediaType=d[0],Object.assign(n,i);else Object.assign(n,i),n.anyOf=d.map((p)=>({contentMediaType:p}));else Object.assign(n,i)},$p=(e,t,o,r)=>{o.type="boolean"},fc=(e,t,o,r)=>{if(t.unrepresentable==="throw")throw Error("Custom types cannot be represented in JSON Schema")},Cp=(e,t,o,r)=>{if(t.unrepresentable==="throw")throw Error("Function types cannot be represented in JSON Schema")},gc=(e,t,o,r)=>{if(t.unrepresentable==="throw")throw Error("Transforms cannot be represented in JSON Schema")},Ip=(e,t,o,r)=>{if(t.unrepresentable==="throw")throw Error("Map cannot be represented in JSON Schema")},Op=(e,t,o,r)=>{if(t.unrepresentable==="throw")throw Error("Set cannot be represented in JSON Schema")},Sc=(e,t,o,r)=>{let n=o,i=e._zod.def,{minimum:a,maximum:c}=e._zod.bag;if(typeof a==="number")n.minItems=a;if(typeof c==="number")n.maxItems=c;n.type="array",n.items=Z(i.element,t,{...r,path:[...r.path,"items"]})},_c=(e,t,o,r)=>{let n=o,i=e._zod.def;n.type="object",n.properties={};let a=i.shape;for(let p in a)n.properties[p]=Z(a[p],t,{...r,path:[...r.path,"properties",p]});let c=new Set(Object.keys(a)),d=new Set([...c].filter((p)=>{let m=i.shape[p]._zod;if(t.io==="input")return m.optin===void 0;else return m.optout===void 0}));if(d.size>0)n.required=Array.from(d);if(i.catchall?._zod.def.type==="never")n.additionalProperties=!1;else if(!i.catchall){if(t.io==="output")n.additionalProperties=!1}else if(i.catchall)n.additionalProperties=Z(i.catchall,t,{...r,path:[...r.path,"additionalProperties"]})},yc=(e,t,o,r)=>{let n=e._zod.def,i=n.inclusive===!1,a=n.options.map((c,d)=>Z(c,t,{...r,path:[...r.path,i?"oneOf":"anyOf",d]}));if(i)o.oneOf=a;else o.anyOf=a},bc=(e,t,o,r)=>{let n=e._zod.def,i=Z(n.left,t,{...r,path:[...r.path,"allOf",0]}),a=Z(n.right,t,{...r,path:[...r.path,"allOf",1]}),c=(p)=>("allOf"in p)&&Object.keys(p).length===1,d=[...c(i)?i.allOf:[i],...c(a)?a.allOf:[a]];o.allOf=d},Np=(e,t,o,r)=>{let n=o,i=e._zod.def;n.type="array";let a=t.target==="draft-2020-12"?"prefixItems":"items",c=t.target==="draft-2020-12"?"items":t.target==="openapi-3.0"?"items":"additionalItems",d=i.items.map((y,S)=>Z(y,t,{...r,path:[...r.path,a,S]})),p=i.rest?Z(i.rest,t,{...r,path:[...r.path,c,...t.target==="openapi-3.0"?[i.items.length]:[]]}):null;if(t.target==="draft-2020-12"){if(n.prefixItems=d,p)n.items=p}else if(t.target==="openapi-3.0"){if(n.items={anyOf:d},p)n.items.anyOf.push(p);if(n.minItems=d.length,!p)n.maxItems=d.length}else if(n.items=d,p)n.additionalItems=p;let{minimum:m,maximum:f}=e._zod.bag;if(typeof m==="number")n.minItems=m;if(typeof f==="number")n.maxItems=f},vc=(e,t,o,r)=>{let n=o,i=e._zod.def;n.type="object";let a=i.keyType,d=a._zod.bag?.patterns;if(i.mode==="loose"&&d&&d.size>0){let m=Z(i.valueType,t,{...r,path:[...r.path,"patternProperties","*"]});n.patternProperties={};for(let f of d)n.patternProperties[f.source]=m}else{if(t.target==="draft-07"||t.target==="draft-2020-12")n.propertyNames=Z(i.keyType,t,{...r,path:[...r.path,"propertyNames"]});n.additionalProperties=Z(i.valueType,t,{...r,path:[...r.path,"additionalProperties"]})}let p=a._zod.values;if(p){let m=[...p].filter((f)=>typeof f==="string"||typeof f==="number");if(m.length>0)n.required=m}},zc=(e,t,o,r)=>{let n=e._zod.def,i=Z(n.innerType,t,r),a=t.seen.get(e);if(t.target==="openapi-3.0")a.ref=n.innerType,o.nullable=!0;else o.anyOf=[i,{type:"null"}]},wc=(e,t,o,r)=>{let n=e._zod.def;Z(n.innerType,t,r);let i=t.seen.get(e);i.ref=n.innerType},Rc=(e,t,o,r)=>{let n=e._zod.def;Z(n.innerType,t,r);let i=t.seen.get(e);i.ref=n.innerType,o.default=JSON.parse(JSON.stringify(n.defaultValue))},xc=(e,t,o,r)=>{let n=e._zod.def;Z(n.innerType,t,r);let i=t.seen.get(e);if(i.ref=n.innerType,t.io==="input")o._prefault=JSON.parse(JSON.stringify(n.defaultValue))},Pc=(e,t,o,r)=>{let n=e._zod.def;Z(n.innerType,t,r);let i=t.seen.get(e);i.ref=n.innerType;let a;try{a=n.catchValue(void 0)}catch{throw Error("Dynamic catch values are not supported in JSON Schema")}o.default=a},Tc=(e,t,o,r)=>{let n=e._zod.def,i=n.in._zod.traits.has("$ZodTransform"),a=t.io==="input"?i?n.out:n.in:n.out;Z(a,t,r);let c=t.seen.get(e);c.ref=a},Ec=(e,t,o,r)=>{let n=e._zod.def;Z(n.innerType,t,r);let i=t.seen.get(e);i.ref=n.innerType,o.readOnly=!0},Ap=(e,t,o,r)=>{let n=e._zod.def;Z(n.innerType,t,r);let i=t.seen.get(e);i.ref=n.innerType},Ni=(e,t,o,r)=>{let n=e._zod.def;Z(n.innerType,t,r);let i=t.seen.get(e);i.ref=n.innerType},kc=(e,t,o,r)=>{let n=e._zod.innerType;Z(n,t,r);let i=t.seen.get(e);i.ref=n},zp={string:sc,number:ic,boolean:ac,bigint:wp,symbol:Rp,null:cc,undefined:lc,void:xp,never:uc,any:dc,unknown:pc,date:Pp,enum:hc,literal:mc,nan:Tp,template_literal:Ep,file:kp,success:$p,custom:fc,function:Cp,transform:gc,map:Ip,set:Op,array:Sc,object:_c,union:yc,intersection:bc,tuple:Np,record:vc,nullable:zc,nonoptional:wc,default:Rc,prefault:xc,catch:Pc,pipe:Tc,readonly:Ec,promise:Ap,optional:Ni,lazy:kc};function Ai(e,t){if("_idmap"in e){let r=e,n=Qr({...t,processors:zp}),i={};for(let d of r._idmap.entries()){let[p,m]=d;Z(m,n)}let a={},c={registry:r,uri:t?.uri,defs:i};n.external=c;for(let d of r._idmap.entries()){let[p,m]=d;Xr(n,m),a[p]=en(n,m)}if(Object.keys(i).length>0){let d=n.target==="draft-2020-12"?"$defs":"definitions";a.__shared={[d]:i}}return{schemas:a}}let o=Qr({...t,processors:zp});return Z(e,o),Xr(o,e),en(o,e)}var ff=g("ZodISODateTime",(e,t)=>{Ku.init(e,t),F.init(e,t)});function _o(e){return sp(ff,e)}var gf=g("ZodISODate",(e,t)=>{Yu.init(e,t),F.init(e,t)});function $c(e){return ip(gf,e)}var Sf=g("ZodISOTime",(e,t)=>{Qu.init(e,t),F.init(e,t)});function Mp(e){return ap(Sf,e)}var _f=g("ZodISODuration",(e,t)=>{Xu.init(e,t),F.init(e,t)});function qp(e){return cp(_f,e)}var yf=(e,t)=>{wi.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:(o)=>Ia(e,o)},flatten:{value:(o)=>Ca(e,o)},addIssue:{value:(o)=>{e.issues.push(o),e.message=JSON.stringify(e.issues,Vr,2)}},addIssues:{value:(o)=>{e.issues.push(...o),e.message=JSON.stringify(e.issues,Vr,2)}},isEmpty:{get(){return e.issues.length===0}}})};var me=g("ZodError",yf,{Parent:Error});var Lp=Ri(me),Up=xi(me),qi=Fr(me),Zp=Jr(me),Dp=Ol(me),Vp=Nl(me),Hp=Al(me),Fp=Ml(me),Jp=ql(me),Bp=jl(me),Gp=Ll(me),Wp=Ul(me);var Kp=new WeakMap;function tn(e,t,o){let r=Object.getPrototypeOf(e),n=Kp.get(r);if(!n)n=new Set,Kp.set(r,n);if(n.has(t))return;n.add(t);for(let i in o){let a=o[i];Object.defineProperty(r,i,{configurable:!0,enumerable:!1,get(){let c=a.bind(this);return Object.defineProperty(this,i,{configurable:!0,writable:!0,enumerable:!0,value:c}),c},set(c){Object.defineProperty(this,i,{configurable:!0,writable:!0,enumerable:!0,value:c})}})}}var D=g("ZodType",(e,t)=>(U.init(e,t),Object.assign(e["~standard"],{jsonSchema:{input:Yr(e,"input"),output:Yr(e,"output")}}),e.toJSONSchema=vp(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.parse=(o,r)=>Lp(e,o,r,{callee:e.parse}),e.safeParse=(o,r)=>qi(e,o,r),e.parseAsync=async(o,r)=>Up(e,o,r,{callee:e.parseAsync}),e.safeParseAsync=async(o,r)=>Zp(e,o,r),e.spa=e.safeParseAsync,e.encode=(o,r)=>Dp(e,o,r),e.decode=(o,r)=>Vp(e,o,r),e.encodeAsync=async(o,r)=>Hp(e,o,r),e.decodeAsync=async(o,r)=>Fp(e,o,r),e.safeEncode=(o,r)=>Jp(e,o,r),e.safeDecode=(o,r)=>Bp(e,o,r),e.safeEncodeAsync=async(o,r)=>Gp(e,o,r),e.safeDecodeAsync=async(o,r)=>Wp(e,o,r),tn(e,"ZodType",{check(...o){let r=this.def;return this.clone(Qe(r,{checks:[...r.checks??[],...o.map((n)=>typeof n==="function"?{_zod:{check:n,def:{check:"custom"},onattach:[]}}:n)]}),{parent:!0})},with(...o){return this.check(...o)},clone(o,r){return ze(this,o,r)},brand(){return this},register(o,r){return o.add(this,r),this},refine(o,r){return this.check(cg(o,r))},superRefine(o,r){return this.check(lg(o,r))},overwrite(o){return this.check(ot(o))},optional(){return E(this)},exactOptional(){return Gf(this)},nullable(){return eh(this)},nullish(){return E(eh(this))},nonoptional(o){return eg(this,o)},array(){return h(this)},or(o){return v([this,o])},and(o){return je(this,o)},transform(o){return th(this,uh(o))},default(o){return Yf(this,o)},prefault(o){return Xf(this,o)},catch(o){return og(this,o)},pipe(o){return th(this,o)},readonly(){return sg(this)},describe(o){let r=this.clone();return tt.add(r,{description:o}),r},meta(...o){if(o.length===0)return tt.get(this);let r=this.clone();return tt.add(r,o[0]),r},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(o){return o(this)}}),Object.defineProperty(e,"description",{get(){return tt.get(e)?.description},configurable:!0}),e)),oh=g("_ZodString",(e,t)=>{Ei.init(e,t),D.init(e,t),e._zod.processJSONSchema=(r,n,i)=>sc(e,r,n,i);let o=e._zod.bag;e.format=o.format??null,e.minLength=o.minimum??null,e.maxLength=o.maximum??null,tn(e,"_ZodString",{regex(...r){return this.check(Ga(...r))},includes(...r){return this.check(Ya(...r))},startsWith(...r){return this.check(Qa(...r))},endsWith(...r){return this.check(Xa(...r))},min(...r){return this.check(go(...r))},max(...r){return this.check(Ii(...r))},length(...r){return this.check(Oi(...r))},nonempty(...r){return this.check(go(1,...r))},lowercase(r){return this.check(Wa(r))},uppercase(r){return this.check(Ka(r))},trim(){return this.check(tc())},normalize(...r){return this.check(ec(...r))},toLowerCase(){return this.check(oc())},toUpperCase(){return this.check(rc())},slugify(){return this.check(nc())}})}),rh=g("ZodString",(e,t)=>{Ei.init(e,t),oh.init(e,t),e.email=(o)=>e.check(Fa(nh,o)),e.url=(o)=>e.check(Ba(ih,o)),e.jwt=(o)=>e.check(np(Af,o)),e.emoji=(o)=>e.check(Hd(vf,o)),e.guid=(o)=>e.check(Ja(Yp,o)),e.uuid=(o)=>e.check(Ud(ji,o)),e.uuidv4=(o)=>e.check(Zd(ji,o)),e.uuidv6=(o)=>e.check(Dd(ji,o)),e.uuidv7=(o)=>e.check(Vd(ji,o)),e.nanoid=(o)=>e.check(Fd(zf,o)),e.guid=(o)=>e.check(Ja(Yp,o)),e.cuid=(o)=>e.check(Jd(wf,o)),e.cuid2=(o)=>e.check(Bd(Rf,o)),e.ulid=(o)=>e.check(Gd(xf,o)),e.base64=(o)=>e.check(tp(If,o)),e.base64url=(o)=>e.check(op(Of,o)),e.xid=(o)=>e.check(Wd(Pf,o)),e.ksuid=(o)=>e.check(Kd(Tf,o)),e.ipv4=(o)=>e.check(Yd(Ef,o)),e.ipv6=(o)=>e.check(Qd(kf,o)),e.cidrv4=(o)=>e.check(Xd($f,o)),e.cidrv6=(o)=>e.check(ep(Cf,o)),e.e164=(o)=>e.check(rp(Nf,o)),e.datetime=(o)=>e.check(_o(o)),e.date=(o)=>e.check($c(o)),e.time=(o)=>e.check(Mp(o)),e.duration=(o)=>e.check(qp(o))});function s(e){return Ld(rh,e)}var F=g("ZodStringFormat",(e,t)=>{H.init(e,t),oh.init(e,t)}),nh=g("ZodEmail",(e,t)=>{Zu.init(e,t),F.init(e,t)});function sh(e){return Fa(nh,e)}var Yp=g("ZodGUID",(e,t)=>{Lu.init(e,t),F.init(e,t)});var ji=g("ZodUUID",(e,t)=>{Uu.init(e,t),F.init(e,t)});var ih=g("ZodURL",(e,t)=>{Du.init(e,t),F.init(e,t)});function Li(e){return Ba(ih,e)}var vf=g("ZodEmoji",(e,t)=>{Vu.init(e,t),F.init(e,t)});var zf=g("ZodNanoID",(e,t)=>{Hu.init(e,t),F.init(e,t)});var wf=g("ZodCUID",(e,t)=>{Fu.init(e,t),F.init(e,t)});var Rf=g("ZodCUID2",(e,t)=>{Ju.init(e,t),F.init(e,t)});var xf=g("ZodULID",(e,t)=>{Bu.init(e,t),F.init(e,t)});var Pf=g("ZodXID",(e,t)=>{Gu.init(e,t),F.init(e,t)});var Tf=g("ZodKSUID",(e,t)=>{Wu.init(e,t),F.init(e,t)});var Ef=g("ZodIPv4",(e,t)=>{ed.init(e,t),F.init(e,t)});var kf=g("ZodIPv6",(e,t)=>{td.init(e,t),F.init(e,t)});var $f=g("ZodCIDRv4",(e,t)=>{od.init(e,t),F.init(e,t)});var Cf=g("ZodCIDRv6",(e,t)=>{rd.init(e,t),F.init(e,t)});var If=g("ZodBase64",(e,t)=>{sd.init(e,t),F.init(e,t)});var Of=g("ZodBase64URL",(e,t)=>{id.init(e,t),F.init(e,t)});var Nf=g("ZodE164",(e,t)=>{ad.init(e,t),F.init(e,t)});var Af=g("ZodJWT",(e,t)=>{cd.init(e,t),F.init(e,t)});var Ui=g("ZodNumber",(e,t)=>{Ua.init(e,t),D.init(e,t),e._zod.processJSONSchema=(r,n,i)=>ic(e,r,n,i),tn(e,"ZodNumber",{gt(r,n){return this.check($i(r,n))},gte(r,n){return this.check(Kr(r,n))},min(r,n){return this.check(Kr(r,n))},lt(r,n){return this.check(ki(r,n))},lte(r,n){return this.check(Wr(r,n))},max(r,n){return this.check(Wr(r,n))},int(r){return this.check(Qp(r))},safe(r){return this.check(Qp(r))},positive(r){return this.check($i(0,r))},nonnegative(r){return this.check(Kr(0,r))},negative(r){return this.check(ki(0,r))},nonpositive(r){return this.check(Wr(0,r))},multipleOf(r,n){return this.check(Ci(r,n))},step(r,n){return this.check(Ci(r,n))},finite(){return this}});let o=e._zod.bag;e.minValue=Math.max(o.minimum??Number.NEGATIVE_INFINITY,o.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,e.maxValue=Math.min(o.maximum??Number.POSITIVE_INFINITY,o.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,e.isInt=(o.format??"").includes("int")||Number.isSafeInteger(o.multipleOf??0.5),e.isFinite=!0,e.format=o.format??null});function _(e){return lp(Ui,e)}var Mf=g("ZodNumberFormat",(e,t)=>{ld.init(e,t),Ui.init(e,t)});function Qp(e){return dp(Mf,e)}var ah=g("ZodBoolean",(e,t)=>{ud.init(e,t),D.init(e,t),e._zod.processJSONSchema=(o,r,n)=>ac(e,o,r,n)});function z(e){return pp(ah,e)}var qf=g("ZodUndefined",(e,t)=>{dd.init(e,t),D.init(e,t),e._zod.processJSONSchema=(o,r,n)=>lc(e,o,r,n)});function Ic(e){return hp(qf,e)}var jf=g("ZodNull",(e,t)=>{pd.init(e,t),D.init(e,t),e._zod.processJSONSchema=(o,r,n)=>cc(e,o,r,n)});function $t(e){return mp(jf,e)}var Lf=g("ZodAny",(e,t)=>{hd.init(e,t),D.init(e,t),e._zod.processJSONSchema=(o,r,n)=>dc(e,o,r,n)});function Zi(){return fp(Lf)}var Uf=g("ZodUnknown",(e,t)=>{md.init(e,t),D.init(e,t),e._zod.processJSONSchema=(o,r,n)=>pc(e,o,r,n)});function P(){return gp(Uf)}var Zf=g("ZodNever",(e,t)=>{fd.init(e,t),D.init(e,t),e._zod.processJSONSchema=(o,r,n)=>uc(e,o,r,n)});function Oc(e){return Sp(Zf,e)}var Df=g("ZodArray",(e,t)=>{gd.init(e,t),D.init(e,t),e._zod.processJSONSchema=(o,r,n)=>Sc(e,o,r,n),e.element=t.element,tn(e,"ZodArray",{min(o,r){return this.check(go(o,r))},nonempty(o){return this.check(go(1,o))},max(o,r){return this.check(Ii(o,r))},length(o,r){return this.check(Oi(o,r))},unwrap(){return this.element}})});function h(e,t){return _p(Df,e,t)}var ch=g("ZodObject",(e,t)=>{yd.init(e,t),D.init(e,t),e._zod.processJSONSchema=(o,r,n)=>_c(e,o,r,n),L(e,"shape",()=>t.shape),tn(e,"ZodObject",{keyof(){return O(Object.keys(this._zod.def.shape))},catchall(o){return this.clone({...this._zod.def,catchall:o})},passthrough(){return this.clone({...this._zod.def,catchall:P()})},loose(){return this.clone({...this._zod.def,catchall:P()})},strict(){return this.clone({...this._zod.def,catchall:Oc()})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(o){return Jm(this,o)},safeExtend(o){return Bm(this,o)},merge(o){return Gm(this,o)},pick(o){return Hm(this,o)},omit(o){return Fm(this,o)},partial(...o){return Wm(dh,this,o[0])},required(...o){return Km(ph,this,o[0])}})});function l(e,t){let o={type:"object",shape:e??{},...T(t)};return new ch(o)}function k(e,t){return new ch({type:"object",shape:e,catchall:P(),...T(t)})}var lh=g("ZodUnion",(e,t)=>{Za.init(e,t),D.init(e,t),e._zod.processJSONSchema=(o,r,n)=>yc(e,o,r,n),e.options=t.options});function v(e,t){return new lh({type:"union",options:e,...T(t)})}var Vf=g("ZodDiscriminatedUnion",(e,t)=>{lh.init(e,t),bd.init(e,t)});function yo(e,t,o){return new Vf({type:"union",options:t,discriminator:e,...T(o)})}var Hf=g("ZodIntersection",(e,t)=>{vd.init(e,t),D.init(e,t),e._zod.processJSONSchema=(o,r,n)=>bc(e,o,r,n)});function je(e,t){return new Hf({type:"intersection",left:e,right:t})}var Xp=g("ZodRecord",(e,t)=>{zd.init(e,t),D.init(e,t),e._zod.processJSONSchema=(o,r,n)=>vc(e,o,r,n),e.keyType=t.keyType,e.valueType=t.valueType});function b(e,t,o){if(!t||!t._zod)return new Xp({type:"record",keyType:s(),valueType:e,...T(t)});return new Xp({type:"record",keyType:e,valueType:t,...T(o)})}var Cc=g("ZodEnum",(e,t)=>{wd.init(e,t),D.init(e,t),e._zod.processJSONSchema=(r,n,i)=>hc(e,r,n,i),e.enum=t.entries,e.options=Object.values(t.entries);let o=new Set(Object.keys(t.entries));e.extract=(r,n)=>{let i={};for(let a of r)if(o.has(a))i[a]=t.entries[a];else throw Error(`Key ${a} not found in enum`);return new Cc({...t,checks:[],...T(n),entries:i})},e.exclude=(r,n)=>{let i={...t.entries};for(let a of r)if(o.has(a))delete i[a];else throw Error(`Key ${a} not found in enum`);return new Cc({...t,checks:[],...T(n),entries:i})}});function O(e,t){let o=Array.isArray(e)?Object.fromEntries(e.map((r)=>[r,r])):e;return new Cc({type:"enum",entries:o,...T(t)})}var Ff=g("ZodLiteral",(e,t)=>{Rd.init(e,t),D.init(e,t),e._zod.processJSONSchema=(o,r,n)=>mc(e,o,r,n),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function u(e,t){return new Ff({type:"literal",values:Array.isArray(e)?e:[e],...T(t)})}var Jf=g("ZodTransform",(e,t)=>{xd.init(e,t),D.init(e,t),e._zod.processJSONSchema=(o,r,n)=>gc(e,o,r,n),e._zod.parse=(o,r)=>{if(r.direction==="backward")throw new Dr(e.constructor.name);o.addIssue=(i)=>{if(typeof i==="string")o.issues.push(kt(i,o.value,t));else{let a=i;if(a.fatal)a.continue=!1;a.code??(a.code="custom"),a.input??(a.input=o.value),a.inst??(a.inst=e),o.issues.push(kt(a))}};let n=t.transform(o.value,o);if(n instanceof Promise)return n.then((i)=>(o.value=i,o.fallback=!0,o));return o.value=n,o.fallback=!0,o}});function uh(e){return new Jf({type:"transform",transform:e})}var dh=g("ZodOptional",(e,t)=>{Da.init(e,t),D.init(e,t),e._zod.processJSONSchema=(o,r,n)=>Ni(e,o,r,n),e.unwrap=()=>e._zod.def.innerType});function E(e){return new dh({type:"optional",innerType:e})}var Bf=g("ZodExactOptional",(e,t)=>{Pd.init(e,t),D.init(e,t),e._zod.processJSONSchema=(o,r,n)=>Ni(e,o,r,n),e.unwrap=()=>e._zod.def.innerType});function Gf(e){return new Bf({type:"optional",innerType:e})}var Wf=g("ZodNullable",(e,t)=>{Td.init(e,t),D.init(e,t),e._zod.processJSONSchema=(o,r,n)=>zc(e,o,r,n),e.unwrap=()=>e._zod.def.innerType});function eh(e){return new Wf({type:"nullable",innerType:e})}var Kf=g("ZodDefault",(e,t)=>{Ed.init(e,t),D.init(e,t),e._zod.processJSONSchema=(o,r,n)=>Rc(e,o,r,n),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function Yf(e,t){return new Kf({type:"default",innerType:e,get defaultValue(){return typeof t==="function"?t():Ea(t)}})}var Qf=g("ZodPrefault",(e,t)=>{kd.init(e,t),D.init(e,t),e._zod.processJSONSchema=(o,r,n)=>xc(e,o,r,n),e.unwrap=()=>e._zod.def.innerType});function Xf(e,t){return new Qf({type:"prefault",innerType:e,get defaultValue(){return typeof t==="function"?t():Ea(t)}})}var ph=g("ZodNonOptional",(e,t)=>{$d.init(e,t),D.init(e,t),e._zod.processJSONSchema=(o,r,n)=>wc(e,o,r,n),e.unwrap=()=>e._zod.def.innerType});function eg(e,t){return new ph({type:"nonoptional",innerType:e,...T(t)})}var tg=g("ZodCatch",(e,t)=>{Cd.init(e,t),D.init(e,t),e._zod.processJSONSchema=(o,r,n)=>Pc(e,o,r,n),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function og(e,t){return new tg({type:"catch",innerType:e,catchValue:typeof t==="function"?t:()=>t})}var hh=g("ZodPipe",(e,t)=>{Va.init(e,t),D.init(e,t),e._zod.processJSONSchema=(o,r,n)=>Tc(e,o,r,n),e.in=t.in,e.out=t.out});function th(e,t){return new hh({type:"pipe",in:e,out:t})}var rg=g("ZodPreprocess",(e,t)=>{hh.init(e,t),Id.init(e,t)}),ng=g("ZodReadonly",(e,t)=>{Od.init(e,t),D.init(e,t),e._zod.processJSONSchema=(o,r,n)=>Ec(e,o,r,n),e.unwrap=()=>e._zod.def.innerType});function sg(e){return new ng({type:"readonly",innerType:e})}var ig=g("ZodLazy",(e,t)=>{Nd.init(e,t),D.init(e,t),e._zod.processJSONSchema=(o,r,n)=>kc(e,o,r,n),e.unwrap=()=>e._zod.def.getter()});function on(e){return new ig({type:"lazy",getter:e})}var ag=g("ZodCustom",(e,t)=>{Ad.init(e,t),D.init(e,t),e._zod.processJSONSchema=(o,r,n)=>fc(e,o,r,n)});function cg(e,t={}){return yp(ag,e,t)}function lg(e,t){return bp(e,t)}function Ct(e,t){return new rg({type:"pipe",in:uh(e),out:t})}var fh={invalid_type:"invalid_type",too_big:"too_big",too_small:"too_small",invalid_format:"invalid_format",not_multiple_of:"not_multiple_of",unrecognized_keys:"unrecognized_keys",invalid_union:"invalid_union",invalid_key:"invalid_key",invalid_element:"invalid_element",invalid_value:"invalid_value",custom:"custom"};var mh;(function(e){})(mh||(mh={}));function ug(e){return up(Ui,e)}le(Ha());var Di="2025-11-25";var Vi=[Di,"2025-06-18","2025-03-26","2024-11-05","2024-10-07"],Hi="io.modelcontextprotocol/related-task",It="io.modelcontextprotocol/protocolVersion",bo="io.modelcontextprotocol/clientInfo",nt="io.modelcontextprotocol/serverInfo",Ot="io.modelcontextprotocol/clientCapabilities",Fi="io.modelcontextprotocol/subscriptionId",vo="io.modelcontextprotocol/logLevel";var Nt="2.0";var Le=on(()=>v([s(),_(),z(),$t(),b(s(),Le),h(Le)])),J=b(s(),Le),Ji=h(Le),zo=v([s(),_().int()]),wo=s(),rn=l({ttl:_().optional()}),nn=l({taskId:s()}),Ro=k({progressToken:zo.optional(),[Hi]:nn.optional()}),X=l({_meta:Ro.optional()}),st=X.extend({task:rn.optional()}),B=l({method:s(),params:X.loose().optional()}),ie=l({_meta:Ro.optional()}),te=l({method:s(),params:ie.loose().optional()}),xo=k({get[nt](){return $e.optional().catch(void 0)}}),G=k({_meta:xo.optional()}),Re=v([s(),_().int()]),Po=l({jsonrpc:u(Nt),id:Re,...B.shape}).strict(),To=l({jsonrpc:u(Nt),...te.shape}).strict(),At=l({jsonrpc:u(Nt),id:Re,result:G}).strict(),Mt=l({jsonrpc:u(Nt),id:Re.optional(),error:l({code:_().int(),message:s(),data:P().optional()})}).strict(),qt=v([Po,To,At,Mt]),Bi=v([At,Mt]),it=G.strict(),sn=ie.extend({requestId:Re.optional(),reason:s().optional()}),Eo=te.extend({method:u("notifications/cancelled"),params:sn}),an=l({src:s(),mimeType:s().optional(),sizes:h(s()).optional(),theme:O(["light","dark"]).optional()}),Ue=l({icons:h(an).optional()}),ke=l({name:s(),title:s().optional()}),$e=ke.extend({...ke.shape,...Ue.shape,version:s(),websiteUrl:s().optional(),description:s().optional()}),pg=je(l({applyDefaults:z().optional()}),J),hg=Ct((e)=>{if(e&&typeof e==="object"&&!Array.isArray(e)&&Object.keys(e).length===0)return{form:{}};return e},je(l({form:pg.optional(),url:J.optional()}),J.optional())),Gi=k({list:J.optional(),cancel:J.optional(),requests:k({sampling:k({createMessage:J.optional()}).optional(),elicitation:k({create:J.optional()}).optional()}).optional()}),Wi=k({list:J.optional(),cancel:J.optional(),requests:k({tools:k({call:J.optional()}).optional()}).optional()}),cn=l({experimental:b(s(),J).optional(),sampling:l({context:J.optional(),tools:J.optional()}).optional(),elicitation:hg.optional(),roots:l({listChanged:z().optional()}).optional(),tasks:Gi.optional(),extensions:b(s(),J).optional()}),ln=X.extend({protocolVersion:s(),capabilities:cn,clientInfo:$e}),un=B.extend({method:u("initialize"),params:ln}),ko=l({experimental:b(s(),J).optional(),logging:J.optional(),completions:J.optional(),prompts:l({listChanged:z().optional()}).optional(),resources:l({subscribe:z().optional(),listChanged:z().optional()}).optional(),tools:l({listChanged:z().optional()}).optional(),tasks:Wi.optional(),extensions:b(s(),J).optional()}),dn=G.extend({protocolVersion:s(),capabilities:ko,serverInfo:$e,instructions:s().optional()}),pn=te.extend({method:u("notifications/initialized"),params:ie.optional()}),hn=B.extend({method:u("server/discover"),params:X.optional()}),$o=G.extend({supportedVersions:h(s()),capabilities:ko,instructions:s().optional()}),Co=B.extend({method:u("ping"),params:X.optional()}),mn=l({progress:_(),total:E(_()),message:E(s())}),fn=l({...ie.shape,...mn.shape,progressToken:zo}),Io=te.extend({method:u("notifications/progress"),params:fn}),gn=X.extend({cursor:wo.optional()}),Ze=B.extend({params:gn.optional()}),De=G.extend({nextCursor:wo.optional()}),Oo=l({uri:s(),mimeType:E(s()),_meta:b(s(),P()).optional()}),No=Oo.extend({text:s()}),Mc=s().refine((e)=>{try{return atob(e),!0}catch{return!1}},{message:"Invalid Base64 string"}),Ao=Oo.extend({blob:Mc}),Ve=O(["user","assistant"]),Ce=l({audience:h(Ve).optional(),priority:_().min(0).max(1).optional(),lastModified:_o({offset:!0}).optional()}),Mo=l({...ke.shape,...Ue.shape,uri:s(),description:E(s()),mimeType:E(s()),size:E(_()),annotations:Ce.optional(),_meta:E(k({}))}),Sn=l({...ke.shape,...Ue.shape,uriTemplate:s(),description:E(s()),mimeType:E(s()),annotations:Ce.optional(),_meta:E(k({}))}),_n=Ze.extend({method:u("resources/list")}),yn=De.extend({resources:h(Mo)}),bn=Ze.extend({method:u("resources/templates/list")}),vn=De.extend({resourceTemplates:h(Sn)}),jt=X.extend({uri:s()}),zn=jt,wn=B.extend({method:u("resources/read"),params:zn}),Rn=G.extend({contents:h(v([No,Ao]))}),xn=te.extend({method:u("notifications/resources/list_changed"),params:ie.optional()}),Pn=jt,Tn=B.extend({method:u("resources/subscribe"),params:Pn}),En=jt,kn=B.extend({method:u("resources/unsubscribe"),params:En}),qo=l({toolsListChanged:z().optional(),promptsListChanged:z().optional(),resourcesListChanged:z().optional(),resourceSubscriptions:h(s()).optional()}),$n=X.extend({notifications:qo}),Cn=B.extend({method:u("subscriptions/listen"),params:$n}),In=ie.extend({notifications:qo}),On=te.extend({method:u("notifications/subscriptions/acknowledged"),params:In}),Nn=xo.extend({[Fi]:Re}),An=G.extend({_meta:Nn}),Mn=ie.extend({uri:s()}),qn=te.extend({method:u("notifications/resources/updated"),params:Mn}),jn=l({name:s(),description:E(s()),required:E(z())}),Ln=l({...ke.shape,...Ue.shape,description:E(s()),arguments:E(h(jn)),_meta:E(k({}))}),Un=Ze.extend({method:u("prompts/list")}),Zn=De.extend({prompts:h(Ln)}),Dn=X.extend({name:s(),arguments:b(s(),s()).optional()}),Vn=B.extend({method:u("prompts/get"),params:Dn}),Lt=l({type:u("text"),text:s(),annotations:Ce.optional(),_meta:b(s(),P()).optional()}),Ut=l({type:u("image"),data:Mc,mimeType:s(),annotations:Ce.optional(),_meta:b(s(),P()).optional()}),Zt=l({type:u("audio"),data:Mc,mimeType:s(),annotations:Ce.optional(),_meta:b(s(),P()).optional()}),Hn=l({type:u("tool_use"),name:s(),id:s(),input:b(s(),P()),_meta:b(s(),P()).optional()}),Dt=l({type:u("resource"),resource:v([No,Ao]),annotations:Ce.optional(),_meta:b(s(),P()).optional()}),Vt=Mo.extend({type:u("resource_link")}),Ie=v([Lt,Ut,Zt,Vt,Dt]),Fn=l({role:Ve,content:Ie}),Jn=G.extend({description:s().optional(),messages:h(Fn)}),Bn=te.extend({method:u("notifications/prompts/list_changed"),params:ie.optional()}),Gn=l({title:s().optional(),readOnlyHint:z().optional(),destructiveHint:z().optional(),idempotentHint:z().optional(),openWorldHint:z().optional()}),Wn=l({taskSupport:O(["required","optional","forbidden"]).optional()}),at=l({...ke.shape,...Ue.shape,description:s().optional(),inputSchema:l({type:u("object"),properties:b(s(),Le).optional(),required:h(s()).optional()}).catchall(P()),outputSchema:k({$schema:s().optional()}).optional(),annotations:Gn.optional(),execution:Wn.optional(),_meta:b(s(),P()).optional()}),Kn=Ze.extend({method:u("tools/list")}),Yn=De.extend({tools:h(at)}),ct=G.extend({content:h(Ie).default([]),structuredContent:P().optional(),isError:z().optional()}),Ki=ct.or(G.extend({toolResult:P()})),Qn=st.extend({name:s(),arguments:b(s(),P()).optional()}),Xn=B.extend({method:u("tools/call"),params:Qn}),es=te.extend({method:u("notifications/tools/list_changed"),params:ie.optional()}),Yi=l({autoRefresh:z().default(!0),debounceMs:_().int().nonnegative().default(300)}),jo=O(["debug","info","notice","warning","error","critical","alert","emergency"]),ts=X.extend({level:jo}),os=B.extend({method:u("logging/setLevel"),params:ts}),rs=ie.extend({level:jo,logger:s().optional(),data:P()}),ns=te.extend({method:u("notifications/message"),params:rs}),ss=l({name:s().optional()}),is=l({hints:h(ss).optional(),costPriority:_().min(0).max(1).optional(),speedPriority:_().min(0).max(1).optional(),intelligencePriority:_().min(0).max(1).optional()}),as=l({mode:O(["auto","required","none"]).optional()}),cs=l({type:u("tool_result"),toolUseId:s().describe("The unique identifier for the corresponding tool call."),content:h(Ie),structuredContent:P().optional(),isError:z().optional(),_meta:b(s(),P()).optional()}),ls=yo("type",[Lt,Ut,Zt]),rt=yo("type",[Lt,Ut,Zt,Hn,cs]),us=l({role:Ve,content:v([rt,h(rt)]),_meta:b(s(),P()).optional()}),ds=st.extend({messages:h(us),modelPreferences:is.optional(),systemPrompt:s().optional(),includeContext:O(["none","thisServer","allServers"]).optional(),temperature:_().optional(),maxTokens:_().int(),stopSequences:h(s()).optional(),metadata:J.optional(),tools:h(at).optional(),toolChoice:as.optional()}),ps=B.extend({method:u("sampling/createMessage"),params:ds}),hs=G.extend({model:s(),stopReason:E(O(["endTurn","stopSequence","maxTokens"]).or(s())),role:Ve,content:ls}),ms=G.extend({model:s(),stopReason:E(O(["endTurn","stopSequence","maxTokens","toolUse"]).or(s())),role:Ve,content:v([rt,h(rt)])}),Lo=l({type:u("boolean"),title:s().optional(),description:s().optional(),default:z().optional()}),Ht=l({type:u("string"),title:s().optional(),description:s().optional(),minLength:_().optional(),maxLength:_().optional(),format:O(["email","uri","date","date-time"]).optional(),default:s().optional()}),Ft=l({type:O(["number","integer"]),title:s().optional(),description:s().optional(),minimum:_().optional(),maximum:_().optional(),default:_().optional()}),Uo=l({type:u("string"),title:s().optional(),description:s().optional(),enum:h(s()),default:s().optional()}),Zo=l({type:u("string"),title:s().optional(),description:s().optional(),oneOf:h(l({const:s(),title:s()})),default:s().optional()}),Do=l({type:u("string"),title:s().optional(),description:s().optional(),enum:h(s()),enumNames:h(s()).optional(),default:s().optional()}),fs=v([Uo,Zo]),Vo=l({type:u("array"),title:s().optional(),description:s().optional(),minItems:_().optional(),maxItems:_().optional(),items:l({type:u("string"),enum:h(s())}),default:h(s()).optional()}),Ho=l({type:u("array"),title:s().optional(),description:s().optional(),minItems:_().optional(),maxItems:_().optional(),items:l({anyOf:h(l({const:s(),title:s()}))}),default:h(s()).optional()}),gs=v([Vo,Ho]),Ss=v([Do,fs,gs]),Fo=v([Ss,Lo,Ht,Ft]),Jt=st.extend({mode:u("form").optional(),message:s(),requestedSchema:l({type:u("object"),properties:b(s(),Fo),required:h(s()).optional()}).catchall(P())}),_s=st.extend({mode:u("url"),message:s(),elicitationId:s(),url:s().url()}),ys=v([Jt,_s]),bs=B.extend({method:u("elicitation/create"),params:ys}),vs=ie.extend({elicitationId:s()}),zs=te.extend({method:u("notifications/elicitation/complete"),params:vs}),ws=G.extend({action:O(["accept","decline","cancel"]),content:Ct((e)=>e===null?void 0:e,b(s(),v([s(),_(),z(),h(s())])).optional())}),Rs=l({type:u("ref/resource"),uri:s()}),xs=l({type:u("ref/prompt"),name:s()}),Ps=X.extend({ref:v([xs,Rs]),argument:l({name:s(),value:s()}),context:l({arguments:b(s(),s()).optional()}).optional()}),Ts=B.extend({method:u("completion/complete"),params:Ps}),Es=G.extend({completion:k({values:h(s()).max(100),total:E(_().int()),hasMore:E(z())})}),ks=l({uri:s().startsWith("file://"),name:s().optional(),_meta:b(s(),P()).optional()}),$s=B.extend({method:u("roots/list"),params:X.optional()}),Cs=G.extend({roots:h(ks)}),Is=te.extend({method:u("notifications/roots/list_changed"),params:ie.optional()}),Qi=k({ttl:_().optional(),pollInterval:_().optional()}),Os=O(["working","input_required","completed","failed","cancelled"]),He=l({taskId:s(),status:Os,ttl:v([_(),$t()]),createdAt:s(),lastUpdatedAt:s(),pollInterval:E(_()),statusMessage:E(s())}),Xi=G.extend({task:He}),Ns=ie.merge(He),ea=te.extend({method:u("notifications/tasks/status"),params:Ns}),ta=B.extend({method:u("tasks/get"),params:X.extend({taskId:s()})}),oa=G.merge(He),ra=B.extend({method:u("tasks/result"),params:X.extend({taskId:s()})}),na=G.loose(),sa=Ze.extend({method:u("tasks/list")}),ia=De.extend({tasks:h(He)}),aa=B.extend({method:u("tasks/cancel"),params:X.extend({taskId:s()})}),ca=G.merge(He),la=v([Co,un,hn,Ts,os,Vn,Un,_n,bn,wn,Tn,kn,Cn,Xn,Kn]),ua=v([Eo,Io,pn,Is]),da=v([it,hs,ms,ws,Cs]),pa=v([Co,ps,bs,$s]),ha=v([Eo,Io,ns,qn,xn,es,Bn,On,zs]),ma=v([it,dn,$o,Es,Jn,Zn,yn,vn,Rn,ct,Yn,An]),Q=Li().superRefine((e,t)=>{if(!URL.canParse(e))return t.addIssue({code:fh.custom,message:"URL must be parseable",fatal:!0}),wa}).refine((e)=>{let t=new URL(e);return t.protocol!=="javascript:"&&t.protocol!=="data:"&&t.protocol!=="vbscript:"},{message:"URL cannot use javascript:, data:, or vbscript: scheme"}),As=k({resource:s().url(),authorization_servers:h(Q).optional(),jwks_uri:s().url().optional(),scopes_supported:h(s()).optional(),bearer_methods_supported:h(s()).optional(),resource_signing_alg_values_supported:h(s()).optional(),resource_name:s().optional(),resource_documentation:s().optional(),resource_policy_uri:s().url().optional(),resource_tos_uri:s().url().optional(),tls_client_certificate_bound_access_tokens:z().optional(),authorization_details_types_supported:h(s()).optional(),dpop_signing_alg_values_supported:h(s()).optional(),dpop_bound_access_tokens_required:z().optional()}),Jo=k({issuer:s(),authorization_endpoint:Q,token_endpoint:Q,registration_endpoint:Q.optional(),scopes_supported:h(s()).optional(),response_types_supported:h(s()),response_modes_supported:h(s()).optional(),grant_types_supported:h(s()).optional(),token_endpoint_auth_methods_supported:h(s()).optional(),token_endpoint_auth_signing_alg_values_supported:h(s()).optional(),service_documentation:Q.optional(),revocation_endpoint:Q.optional(),revocation_endpoint_auth_methods_supported:h(s()).optional(),revocation_endpoint_auth_signing_alg_values_supported:h(s()).optional(),introspection_endpoint:s().optional(),introspection_endpoint_auth_methods_supported:h(s()).optional(),introspection_endpoint_auth_signing_alg_values_supported:h(s()).optional(),code_challenge_methods_supported:h(s()).optional(),client_id_metadata_document_supported:z().optional(),authorization_response_iss_parameter_supported:z().optional().catch(void 0),dpop_signing_alg_values_supported:h(s()).optional()}),Ms=k({issuer:s(),authorization_endpoint:Q,token_endpoint:Q,userinfo_endpoint:Q.optional(),jwks_uri:Q,registration_endpoint:Q.optional(),scopes_supported:h(s()).optional(),response_types_supported:h(s()),response_modes_supported:h(s()).optional(),grant_types_supported:h(s()).optional(),acr_values_supported:h(s()).optional(),subject_types_supported:h(s()),id_token_signing_alg_values_supported:h(s()),id_token_encryption_alg_values_supported:h(s()).optional(),id_token_encryption_enc_values_supported:h(s()).optional(),userinfo_signing_alg_values_supported:h(s()).optional(),userinfo_encryption_alg_values_supported:h(s()).optional(),userinfo_encryption_enc_values_supported:h(s()).optional(),request_object_signing_alg_values_supported:h(s()).optional(),request_object_encryption_alg_values_supported:h(s()).optional(),request_object_encryption_enc_values_supported:h(s()).optional(),token_endpoint_auth_methods_supported:h(s()).optional(),token_endpoint_auth_signing_alg_values_supported:h(s()).optional(),display_values_supported:h(s()).optional(),claim_types_supported:h(s()).optional(),claims_supported:h(s()).optional(),service_documentation:s().optional(),claims_locales_supported:h(s()).optional(),ui_locales_supported:h(s()).optional(),claims_parameter_supported:z().optional(),request_parameter_supported:z().optional(),request_uri_parameter_supported:z().optional(),require_request_uri_registration:z().optional(),op_policy_uri:Q.optional(),op_tos_uri:Q.optional(),client_id_metadata_document_supported:z().optional(),authorization_response_iss_parameter_supported:z().optional().catch(void 0)}),qs=l({...Ms.shape,...Jo.pick({code_challenge_methods_supported:!0}).shape}),js=l({access_token:s(),id_token:s().optional(),token_type:s(),expires_in:ug().optional(),scope:s().optional(),refresh_token:s().optional(),issuer:s().optional().catch(void 0)}).strip(),Ls=l({issued_token_type:u("urn:ietf:params:oauth:token-type:id-jag"),access_token:s(),token_type:s().optional(),expires_in:_().optional(),scope:s().optional()}).strip(),Us=l({error:s(),error_description:s().optional(),error_uri:s().optional()}),Ac=Q.optional().or(u("").transform(()=>{return})),Zs=l({redirect_uris:h(Q),token_endpoint_auth_method:s().optional(),grant_types:h(s()).optional(),response_types:h(s()).optional(),application_type:s().optional(),client_name:s().optional(),client_uri:Q.optional(),logo_uri:Ac,scope:s().optional(),contacts:h(s()).optional(),tos_uri:Ac,policy_uri:s().optional(),jwks_uri:Q.optional(),jwks:Zi().optional(),software_id:s().optional(),software_version:s().optional(),software_statement:s().optional()}).strip(),Ds=l({client_id:s(),client_secret:s().optional(),client_id_issued_at:_().optional(),client_secret_expires_at:_().optional(),issuer:s().optional().catch(void 0)}).strip(),Vs=Zs.merge(Ds),fa=l({error:s(),error_description:s().optional()}).strip(),ga=l({token:s(),token_type_hint:s().optional()}).strip();var Dc=Symbol.for("mcp.sdk.errorBrands");function Bt(e,t){let o=new Set,r=t;while(typeof r==="function"){let n=r.mcpBrand;if(Object.prototype.hasOwnProperty.call(r,"mcpBrand")&&typeof n==="string")o.add(n);r=Object.getPrototypeOf(r)}if(o.size===0)return;Object.defineProperty(e,Dc,{value:o,enumerable:!1,configurable:!0})}function fe(e,t){try{if(typeof t==="object"&&t!==null&&Object.prototype.hasOwnProperty.call(e,"mcpBrand")&&typeof e.mcpBrand==="string"&&Object.prototype.hasOwnProperty.call(t,Dc)){let o=t[Dc];if(o&&typeof o.has==="function"&&o.has(e.mcpBrand))return!0}}catch{}return Function.prototype[Symbol.hasInstance].call(e,t)}var mg=class e extends Error{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.OAuthError"})}static[Symbol.hasInstance](t){return fe(this,t)}static isInstance(t){if(typeof this!=="function")throw TypeError("isInstance must be called on the class (e.g. `SdkError.isInstance(value)`); for callbacks use `v => SdkError.isInstance(v)`");return fe(this,t)}constructor(t,o,r){super(o);this.code=t,this.errorUri=r,this.name="OAuthError",Bt(this,new.target)}toResponseObject(){let t={error:this.code,error_description:this.message};if(this.errorUri)t.error_uri=this.errorUri;return t}static fromResponse(t){return new e(t.error,t.error_description??t.error,t.error_uri)}},oe=function(e){return e.NotConnected="NOT_CONNECTED",e.AlreadyConnected="ALREADY_CONNECTED",e.NotInitialized="NOT_INITIALIZED",e.CapabilityNotSupported="CAPABILITY_NOT_SUPPORTED",e.RequestTimeout="REQUEST_TIMEOUT",e.ConnectionClosed="CONNECTION_CLOSED",e.SendFailed="SEND_FAILED",e.InvalidResult="INVALID_RESULT",e.UnsupportedResultType="UNSUPPORTED_RESULT_TYPE",e.InputRequiredRoundsExceeded="INPUT_REQUIRED_ROUNDS_EXCEEDED",e.ListPaginationExceeded="LIST_PAGINATION_EXCEEDED",e.MethodNotSupportedByProtocolVersion="METHOD_NOT_SUPPORTED_BY_PROTOCOL_VERSION",e.EraNegotiationFailed="ERA_NEGOTIATION_FAILED",e.ClientHttpNotImplemented="CLIENT_HTTP_NOT_IMPLEMENTED",e.ClientHttpAuthentication="CLIENT_HTTP_AUTHENTICATION",e.ClientHttpForbidden="CLIENT_HTTP_FORBIDDEN",e.ClientHttpUnexpectedContent="CLIENT_HTTP_UNEXPECTED_CONTENT",e.ClientHttpFailedToOpenStream="CLIENT_HTTP_FAILED_TO_OPEN_STREAM",e.ClientHttpFailedToTerminateSession="CLIENT_HTTP_FAILED_TO_TERMINATE_SESSION",e}({}),K=class extends Error{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.SdkError"})}static[Symbol.hasInstance](e){return fe(this,e)}static isInstance(e){if(typeof this!=="function")throw TypeError("isInstance must be called on the class (e.g. `SdkError.isInstance(value)`); for callbacks use `v => SdkError.isInstance(v)`");return fe(this,e)}constructor(e,t,o,r){super(t,r);this.code=e,this.data=o,this.name="SdkError",Bt(this,new.target)}},fg=class extends K{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.SdkHttpError"})}constructor(e,t,o,r){super(e,t,o,r);this.name="SdkHttpError"}get status(){return this.data.status}get statusText(){return this.data.statusText}};var gg="2026-07-28";function qh(e){return e>=gg}function jh(e){let t=e.structuredContent;if(t===void 0)return e;if(!(typeof t!=="object"||t===null||Array.isArray(t)))return e;if(e.content?.some((o)=>o.type==="text")??!1)return e;return{...e,content:[...e.content??[],{type:"text",text:JSON.stringify(t)}]}}var Lh=["task","inputRequests","requestState"];function Sg(e){if(e===null||typeof e!=="object"||Array.isArray(e)||e.content!==void 0||Lh.some((t)=>(t in e)))return e;return{...e,content:[]}}function _g(){let e=on(()=>v([s(),_(),z(),$t(),b(s(),e),h(e)])),t=b(s(),e),o=v([s(),_().int()]),r=s(),n=l({ttl:_().optional()}),i=l({taskId:s()}),a=k({progressToken:o.optional(),"io.modelcontextprotocol/related-task":i.optional()}),c=l({_meta:a.optional()}),d=c.extend({task:n.optional()}),p=l({method:s(),params:c.loose().optional()}),m=l({_meta:a.optional()}),f=l({method:s(),params:m.loose().optional()}),y=k({_meta:a.optional()}),S=v([s(),_().int()]),w=y.strict(),x=m.extend({requestId:S.optional(),reason:s().optional()}),R=f.extend({method:u("notifications/cancelled"),params:x}),C=l({src:s(),mimeType:s().optional(),sizes:h(s()).optional(),theme:O(["light","dark"]).optional()}),N=l({icons:h(C).optional()}),I=l({name:s(),title:s().optional()}),M=I.extend({...I.shape,...N.shape,version:s(),websiteUrl:s().optional(),description:s().optional()}),A=je(l({applyDefaults:z().optional()}),t),j=Ct((se)=>{if(se&&typeof se==="object"&&!Array.isArray(se)&&Object.keys(se).length===0)return{form:{}};return se},je(l({form:A.optional(),url:t.optional()}),t.optional())),V=k({list:t.optional(),cancel:t.optional(),requests:k({sampling:k({createMessage:t.optional()}).optional(),elicitation:k({create:t.optional()}).optional()}).optional()}),ae=k({list:t.optional(),cancel:t.optional(),requests:k({tools:k({call:t.optional()}).optional()}).optional()}),Y=l({experimental:b(s(),t).optional(),sampling:l({context:t.optional(),tools:t.optional()}).optional(),elicitation:j.optional(),roots:l({listChanged:z().optional()}).optional(),tasks:V.optional(),extensions:b(s(),t).optional()}),ge=c.extend({protocolVersion:s(),capabilities:Y,clientInfo:M}),pt=p.extend({method:u("initialize"),params:ge}),Bo=l({experimental:b(s(),t).optional(),logging:t.optional(),completions:t.optional(),prompts:l({listChanged:z().optional()}).optional(),resources:l({subscribe:z().optional(),listChanged:z().optional()}).optional(),tools:l({listChanged:z().optional()}).optional(),tasks:ae.optional(),extensions:b(s(),t).optional()}),Go=y.extend({protocolVersion:s(),capabilities:Bo,serverInfo:M,instructions:s().optional()}),Kt=f.extend({method:u("notifications/initialized"),params:m.optional()}),Je=p.extend({method:u("ping"),params:c.optional()}),ht=l({progress:_(),total:E(_()),message:E(s())}),Pe=l({...m.shape,...ht.shape,progressToken:o}),Be=f.extend({method:u("notifications/progress"),params:Pe}),Yt=c.extend({cursor:r.optional()}),Ae=p.extend({params:Yt.optional()}),Me=y.extend({nextCursor:r.optional()}),Qt=l({uri:s(),mimeType:E(s()),_meta:b(s(),P()).optional()}),Xt=Qt.extend({text:s()}),mt=s().refine((se)=>{try{return atob(se),!0}catch{return!1}},{message:"Invalid Base64 string"}),eo=Qt.extend({blob:mt}),Te=O(["user","assistant"]),be=l({audience:h(Te).optional(),priority:_().min(0).max(1).optional(),lastModified:_o({offset:!0}).optional()}),ft=l({...I.shape,...N.shape,uri:s(),description:E(s()),mimeType:E(s()),size:E(_()),annotations:be.optional(),_meta:E(k({}))}),Wo=l({...I.shape,...N.shape,uriTemplate:s(),description:E(s()),mimeType:E(s()),annotations:be.optional(),_meta:E(k({}))}),Ko=Ae.extend({method:u("resources/list")}),Yo=Me.extend({resources:h(ft)}),Ge=Ae.extend({method:u("resources/templates/list")}),to=Me.extend({resourceTemplates:h(Wo)}),gt=c.extend({uri:s()}),Qo=gt,Xo=p.extend({method:u("resources/read"),params:Qo}),er=y.extend({contents:h(v([Xt,eo]))}),tr=f.extend({method:u("notifications/resources/list_changed"),params:m.optional()}),or=gt,rr=p.extend({method:u("resources/subscribe"),params:or}),nr=gt,sr=p.extend({method:u("resources/unsubscribe"),params:nr}),ir=m.extend({uri:s()}),ar=f.extend({method:u("notifications/resources/updated"),params:ir}),cr=l({name:s(),description:E(s()),required:E(z())}),lr=l({...I.shape,...N.shape,description:E(s()),arguments:E(h(cr)),_meta:E(k({}))}),ur=Ae.extend({method:u("prompts/list")}),dr=Me.extend({prompts:h(lr)}),pr=c.extend({name:s(),arguments:b(s(),s()).optional()}),hr=p.extend({method:u("prompts/get"),params:pr}),St=l({type:u("text"),text:s(),annotations:be.optional(),_meta:b(s(),P()).optional()}),_t=l({type:u("image"),data:mt,mimeType:s(),annotations:be.optional(),_meta:b(s(),P()).optional()}),yt=l({type:u("audio"),data:mt,mimeType:s(),annotations:be.optional(),_meta:b(s(),P()).optional()}),mr=l({type:u("tool_use"),name:s(),id:s(),input:b(s(),P()),_meta:b(s(),P()).optional()}),We=l({type:u("resource"),resource:v([Xt,eo]),annotations:be.optional(),_meta:b(s(),P()).optional()}),fr=ft.extend({type:u("resource_link")}),Se=v([St,_t,yt,fr,We]),oo=l({role:Te,content:Se}),ro=y.extend({description:s().optional(),messages:h(oo)}),bt=f.extend({method:u("notifications/prompts/list_changed"),params:m.optional()}),gr=l({title:s().optional(),readOnlyHint:z().optional(),destructiveHint:z().optional(),idempotentHint:z().optional(),openWorldHint:z().optional()}),no=l({taskSupport:O(["required","optional","forbidden"]).optional()}),vt=l({...I.shape,...N.shape,description:s().optional(),inputSchema:l({type:u("object"),properties:b(s(),e).optional(),required:h(s()).optional()}).catchall(P()),outputSchema:l({type:u("object"),properties:b(s(),e).optional(),required:h(s()).optional()}).catchall(P()).optional(),annotations:gr.optional(),execution:no.optional(),_meta:b(s(),P()).optional()}),so=Ae.extend({method:u("tools/list")}),io=Me.extend({tools:h(vt)}),ao=y.extend({content:h(Se),structuredContent:b(s(),P()).optional(),isError:z().optional()}),ne=d.extend({name:s(),arguments:b(s(),P()).optional()}),Sr=p.extend({method:u("tools/call"),params:ne}),ti=f.extend({method:u("notifications/tools/list_changed"),params:m.optional()}),co=O(["debug","info","notice","warning","error","critical","alert","emergency"]),_r=c.extend({level:co}),yr=p.extend({method:u("logging/setLevel"),params:_r}),br=m.extend({level:co,logger:s().optional(),data:P()}),vr=f.extend({method:u("notifications/message"),params:br}),zr=l({name:s().optional()}),wr=l({hints:h(zr).optional(),costPriority:_().min(0).max(1).optional(),speedPriority:_().min(0).max(1).optional(),intelligencePriority:_().min(0).max(1).optional()}),Rr=l({mode:O(["auto","required","none"]).optional()}),oi=l({type:u("tool_result"),toolUseId:s().describe("The unique identifier for the corresponding tool call."),content:h(Se),structuredContent:l({}).loose().optional(),isError:z().optional(),_meta:b(s(),P()).optional()}),xr=yo("type",[St,_t,yt]),Ke=yo("type",[St,_t,yt,mr,oi]),Pr=l({role:Te,content:v([Ke,h(Ke)]),_meta:b(s(),P()).optional()}),Tr=d.extend({messages:h(Pr),modelPreferences:wr.optional(),systemPrompt:s().optional(),includeContext:O(["none","thisServer","allServers"]).optional(),temperature:_().optional(),maxTokens:_().int(),stopSequences:h(s()).optional(),metadata:t.optional(),tools:h(vt).optional(),toolChoice:Rr.optional()}),Er=p.extend({method:u("sampling/createMessage"),params:Tr}),kr=y.extend({model:s(),stopReason:E(O(["endTurn","stopSequence","maxTokens"]).or(s())),role:Te,content:xr}),$r=y.extend({model:s(),stopReason:E(O(["endTurn","stopSequence","maxTokens","toolUse"]).or(s())),role:Te,content:v([Ke,h(Ke)])}),Cr=l({type:u("boolean"),title:s().optional(),description:s().optional(),default:z().optional()}),Ir=l({type:u("string"),title:s().optional(),description:s().optional(),minLength:_().optional(),maxLength:_().optional(),format:O(["email","uri","date","date-time"]).optional(),default:s().optional()}),Or=l({type:O(["number","integer"]),title:s().optional(),description:s().optional(),minimum:_().optional(),maximum:_().optional(),default:_().optional()}),Nr=l({type:u("string"),title:s().optional(),description:s().optional(),enum:h(s()),default:s().optional()}),Ar=l({type:u("string"),title:s().optional(),description:s().optional(),oneOf:h(l({const:s(),title:s()})),default:s().optional()}),Mr=l({type:u("string"),title:s().optional(),description:s().optional(),enum:h(s()),enumNames:h(s()).optional(),default:s().optional()}),qr=v([Nr,Ar]),zt=l({type:u("array"),title:s().optional(),description:s().optional(),minItems:_().optional(),maxItems:_().optional(),items:l({type:u("string"),enum:h(s())}),default:h(s()).optional()}),wt=l({type:u("array"),title:s().optional(),description:s().optional(),minItems:_().optional(),maxItems:_().optional(),items:l({anyOf:h(l({const:s(),title:s()}))}),default:h(s()).optional()}),ri=v([zt,wt]),ni=v([Mr,qr,ri]),pe=v([ni,Cr,Ir,Or]),he=d.extend({mode:u("form").optional(),message:s(),requestedSchema:l({type:u("object"),properties:b(s(),pe),required:h(s()).optional()}).catchall(P())}),jr=d.extend({mode:u("url"),message:s(),elicitationId:s(),url:s().url()}),ve=v([he,jr]),si=p.extend({method:u("elicitation/create"),params:ve}),ii=m.extend({elicitationId:s()}),ai=f.extend({method:u("notifications/elicitation/complete"),params:ii}),ci=y.extend({action:O(["accept","decline","cancel"]),content:Ct((se)=>se===null?void 0:se,b(s(),v([s(),_(),z(),h(s())])).optional())}),li=l({type:u("ref/resource"),uri:s()}),ui=l({type:u("ref/prompt"),name:s()}),di=c.extend({ref:v([ui,li]),argument:l({name:s(),value:s()}),context:l({arguments:b(s(),s()).optional()}).optional()}),Lr=p.extend({method:u("completion/complete"),params:di}),pi=y.extend({completion:k({values:h(s()).max(100),total:E(_().int()),hasMore:E(z())})}),hi=l({uri:s().startsWith("file://"),name:s().optional(),_meta:b(s(),P()).optional()}),lo=p.extend({method:u("roots/list"),params:c.optional()}),Ur=y.extend({roots:h(hi)}),mi=f.extend({method:u("notifications/roots/list_changed"),params:m.optional()}),fi=k({ttl:_().optional(),pollInterval:_().optional()}),Zr=O(["working","input_required","completed","failed","cancelled"]),Ye=l({taskId:s(),status:Zr,ttl:v([_(),$t()]),createdAt:s(),lastUpdatedAt:s(),pollInterval:E(_()),statusMessage:E(s())}),de=y.extend({task:Ye}),gi=m.merge(Ye),Rt=f.extend({method:u("notifications/tasks/status"),params:gi}),uo=p.extend({method:u("tasks/get"),params:c.extend({taskId:s()})}),po=y.merge(Ye),ho=p.extend({method:u("tasks/result"),params:c.extend({taskId:s()})}),za=y.loose(),ce=Ae.extend({method:u("tasks/list")}),W=Me.extend({tasks:h(Ye)}),xt=p.extend({method:u("tasks/cancel"),params:c.extend({taskId:s()})});return{JSONValueSchema:e,JSONObjectSchema:t,ProgressTokenSchema:o,CursorSchema:r,TaskMetadataSchema:n,RelatedTaskMetadataSchema:i,RequestMetaSchema:a,BaseRequestParamsSchema:c,TaskAugmentedRequestParamsSchema:d,RequestSchema:p,NotificationsParamsSchema:m,NotificationSchema:f,ResultSchema:y,RequestIdSchema:S,EmptyResultSchema:w,CancelledNotificationParamsSchema:x,CancelledNotificationSchema:R,IconSchema:C,IconsSchema:N,BaseMetadataSchema:I,ImplementationSchema:M,ClientTasksCapabilitySchema:V,ServerTasksCapabilitySchema:ae,ClientCapabilitiesSchema:Y,InitializeRequestParamsSchema:ge,InitializeRequestSchema:pt,ServerCapabilitiesSchema:Bo,InitializeResultSchema:Go,InitializedNotificationSchema:Kt,PingRequestSchema:Je,ProgressSchema:ht,ProgressNotificationParamsSchema:Pe,ProgressNotificationSchema:Be,PaginatedRequestParamsSchema:Yt,PaginatedRequestSchema:Ae,PaginatedResultSchema:Me,ResourceContentsSchema:Qt,TextResourceContentsSchema:Xt,BlobResourceContentsSchema:eo,RoleSchema:Te,AnnotationsSchema:be,ResourceSchema:ft,ResourceTemplateSchema:Wo,ListResourcesRequestSchema:Ko,ListResourcesResultSchema:Yo,ListResourceTemplatesRequestSchema:Ge,ListResourceTemplatesResultSchema:to,ResourceRequestParamsSchema:gt,ReadResourceRequestParamsSchema:Qo,ReadResourceRequestSchema:Xo,ReadResourceResultSchema:er,ResourceListChangedNotificationSchema:tr,SubscribeRequestParamsSchema:or,SubscribeRequestSchema:rr,UnsubscribeRequestParamsSchema:nr,UnsubscribeRequestSchema:sr,ResourceUpdatedNotificationParamsSchema:ir,ResourceUpdatedNotificationSchema:ar,PromptArgumentSchema:cr,PromptSchema:lr,ListPromptsRequestSchema:ur,ListPromptsResultSchema:dr,GetPromptRequestParamsSchema:pr,GetPromptRequestSchema:hr,TextContentSchema:St,ImageContentSchema:_t,AudioContentSchema:yt,ToolUseContentSchema:mr,EmbeddedResourceSchema:We,ResourceLinkSchema:fr,ContentBlockSchema:Se,PromptMessageSchema:oo,GetPromptResultSchema:ro,PromptListChangedNotificationSchema:bt,ToolAnnotationsSchema:gr,ToolExecutionSchema:no,ToolSchema:vt,ListToolsRequestSchema:so,ListToolsResultSchema:io,CallToolResultSchema:ao,CallToolRequestParamsSchema:ne,CallToolRequestSchema:Sr,ToolListChangedNotificationSchema:ti,LoggingLevelSchema:co,SetLevelRequestParamsSchema:_r,SetLevelRequestSchema:yr,LoggingMessageNotificationParamsSchema:br,LoggingMessageNotificationSchema:vr,ModelHintSchema:zr,ModelPreferencesSchema:wr,ToolChoiceSchema:Rr,ToolResultContentSchema:oi,SamplingContentSchema:xr,SamplingMessageContentBlockSchema:Ke,SamplingMessageSchema:Pr,CreateMessageRequestParamsSchema:Tr,CreateMessageRequestSchema:Er,CreateMessageResultSchema:kr,CreateMessageResultWithToolsSchema:$r,BooleanSchemaSchema:Cr,StringSchemaSchema:Ir,NumberSchemaSchema:Or,UntitledSingleSelectEnumSchemaSchema:Nr,TitledSingleSelectEnumSchemaSchema:Ar,LegacyTitledEnumSchemaSchema:Mr,SingleSelectEnumSchemaSchema:qr,UntitledMultiSelectEnumSchemaSchema:zt,TitledMultiSelectEnumSchemaSchema:wt,MultiSelectEnumSchemaSchema:ri,EnumSchemaSchema:ni,PrimitiveSchemaDefinitionSchema:pe,ElicitRequestFormParamsSchema:he,ElicitRequestURLParamsSchema:jr,ElicitRequestParamsSchema:ve,ElicitRequestSchema:si,ElicitationCompleteNotificationParamsSchema:ii,ElicitationCompleteNotificationSchema:ai,ElicitResultSchema:ci,ResourceTemplateReferenceSchema:li,PromptReferenceSchema:ui,CompleteRequestParamsSchema:di,CompleteRequestSchema:Lr,CompleteResultSchema:pi,RootSchema:hi,ListRootsRequestSchema:lo,ListRootsResultSchema:Ur,RootsListChangedNotificationSchema:mi,TaskCreationParamsSchema:fi,TaskStatusSchema:Zr,TaskSchema:Ye,CreateTaskResultSchema:de,TaskStatusNotificationParamsSchema:gi,TaskStatusNotificationSchema:Rt,GetTaskRequestSchema:uo,GetTaskResultSchema:po,GetTaskPayloadRequestSchema:ho,GetTaskPayloadResultSchema:za,ListTasksRequestSchema:ce,ListTasksResultSchema:W,CancelTaskRequestSchema:xt,CancelTaskResultSchema:y.merge(Ye),ClientRequestSchema:v([Je,pt,Lr,yr,hr,ur,Ko,Ge,Xo,rr,sr,Sr,so,uo,ho,ce,xt]),ClientNotificationSchema:v([R,Be,Kt,mi,Rt]),ClientResultSchema:v([w,kr,$r,ci,Ur,po,W,de]),ServerRequestSchema:v([Je,Er,si,lo,uo,ho,ce,xt]),ServerNotificationSchema:v([R,Be,vr,ar,tr,ti,bt,Rt,ai]),ServerResultSchema:v([w,Go,pi,ro,dr,Yo,to,er,ao,io,po,W,de]),CallToolResultWireSchema:P().superRefine((se,Am)=>{if(typeof se!=="object"||se===null||Array.isArray(se)||se.content!==void 0)return;for(let fl of Lh)if(fl in se){Am.addIssue({code:"custom",message:`content is required when the body carries '${fl}' — another result family cannot default into an empty tools/call success`});return}}).transform(Sg).pipe(ao)}}var yg;function Uh(){return yg??=_g()}function Zh(e){return e.type!=="object"}var bg=new Set(["const","enum","default","examples"]),vg=new Set(["properties","patternProperties","$defs","definitions","dependentSchemas","dependencies"]);function Ph(e){return e!==void 0&&!(typeof e==="string"&&e.startsWith("#"))}function zg(e){let t=typeof e.$schema==="string"?e.$schema:void 0;if(Ph(e.$id))return{...t!==void 0&&{$schema:t},type:"object",properties:{result:e},required:["result"]};let o=yl(e.$schema)&&e.$recursiveAnchor!==!0,r=(n,i)=>{if(Array.isArray(n))return n.map((d)=>r(d,!1));if(n===null||typeof n!=="object")return n;if(!i&&Ph(n.$id))return n;let a={},c=!1;for(let[d,p]of Object.entries(n))if(i)a[d]=r(p,!1);else if((d==="$ref"||d==="$dynamicRef")&&typeof p==="string")a[d]=p==="#"?"#/properties/result":p.startsWith("#/")?`#/properties/result${p.slice(1)}`:p;else if(d==="$recursiveRef"&&p==="#"&&o)c=!0;else if(bg.has(d))a[d]=p;else if(vg.has(d))a[d]=r(p,!0);else a[d]=r(p,!1);if(c)if("$ref"in a)a.allOf=[...Array.isArray(a.allOf)?a.allOf:[],{$ref:"#/properties/result"}];else a.$ref="#/properties/result";return a};return{...t!==void 0&&{$schema:t},type:"object",properties:{result:r(e,!1)},required:["result"]}}var Dh={ping:null,initialize:null,"completion/complete":null,"logging/setLevel":null,"prompts/get":null,"prompts/list":null,"resources/list":null,"resources/templates/list":null,"resources/read":null,"resources/subscribe":null,"resources/unsubscribe":null,"tools/call":null,"tools/list":null,"tasks/get":null,"tasks/result":null,"tasks/list":null,"tasks/cancel":null,"sampling/createMessage":null,"elicitation/create":null,"roots/list":null},Vh={"notifications/cancelled":null,"notifications/progress":null,"notifications/initialized":null,"notifications/roots/list_changed":null,"notifications/tasks/status":null,"notifications/message":null,"notifications/resources/updated":null,"notifications/resources/list_changed":null,"notifications/tools/list_changed":null,"notifications/prompts/list_changed":null,"notifications/elicitation/complete":null},wg={ping:null,initialize:null,"completion/complete":null,"logging/setLevel":null,"prompts/get":null,"prompts/list":null,"resources/list":null,"resources/templates/list":null,"resources/read":null,"resources/subscribe":null,"resources/unsubscribe":null,"tools/call":null,"tools/list":null,"sampling/createMessage":null,"elicitation/create":null,"roots/list":null},Sa;function Gc(){if(Sa)return Sa;let e=Uh();return Sa={requestSchemas:{ping:e.PingRequestSchema,initialize:e.InitializeRequestSchema,"completion/complete":e.CompleteRequestSchema,"logging/setLevel":e.SetLevelRequestSchema,"prompts/get":e.GetPromptRequestSchema,"prompts/list":e.ListPromptsRequestSchema,"resources/list":e.ListResourcesRequestSchema,"resources/templates/list":e.ListResourceTemplatesRequestSchema,"resources/read":e.ReadResourceRequestSchema,"resources/subscribe":e.SubscribeRequestSchema,"resources/unsubscribe":e.UnsubscribeRequestSchema,"tools/call":e.CallToolRequestSchema,"tools/list":e.ListToolsRequestSchema,"tasks/get":e.GetTaskRequestSchema,"tasks/result":e.GetTaskPayloadRequestSchema,"tasks/list":e.ListTasksRequestSchema,"tasks/cancel":e.CancelTaskRequestSchema,"sampling/createMessage":e.CreateMessageRequestSchema,"elicitation/create":e.ElicitRequestSchema,"roots/list":e.ListRootsRequestSchema},notificationSchemas:{"notifications/cancelled":e.CancelledNotificationSchema,"notifications/progress":e.ProgressNotificationSchema,"notifications/initialized":e.InitializedNotificationSchema,"notifications/roots/list_changed":e.RootsListChangedNotificationSchema,"notifications/tasks/status":e.TaskStatusNotificationSchema,"notifications/message":e.LoggingMessageNotificationSchema,"notifications/resources/updated":e.ResourceUpdatedNotificationSchema,"notifications/resources/list_changed":e.ResourceListChangedNotificationSchema,"notifications/tools/list_changed":e.ToolListChangedNotificationSchema,"notifications/prompts/list_changed":e.PromptListChangedNotificationSchema,"notifications/elicitation/complete":e.ElicitationCompleteNotificationSchema},resultSchemas:{ping:e.EmptyResultSchema,initialize:e.InitializeResultSchema,"completion/complete":e.CompleteResultSchema,"logging/setLevel":e.EmptyResultSchema,"prompts/get":e.GetPromptResultSchema,"prompts/list":e.ListPromptsResultSchema,"resources/list":e.ListResourcesResultSchema,"resources/templates/list":e.ListResourceTemplatesResultSchema,"resources/read":e.ReadResourceResultSchema,"resources/subscribe":e.EmptyResultSchema,"resources/unsubscribe":e.EmptyResultSchema,"tools/call":e.CallToolResultWireSchema,"tools/list":e.ListToolsResultSchema,"sampling/createMessage":e.CreateMessageResultWithToolsSchema,"elicitation/create":e.ElicitResultSchema,"roots/list":e.ListRootsResultSchema}},Sa}function Hh(e){return Object.prototype.hasOwnProperty.call(Dh,e)}function Fh(e){return Object.prototype.hasOwnProperty.call(Vh,e)}function Rg(e){return Object.prototype.hasOwnProperty.call(wg,e)}function xg(e){return Rg(e)?Gc().resultSchemas[e]:void 0}function Pg(e){return Hh(e)?Gc().requestSchemas[e]:void 0}function Tg(e){return Fh(e)?Gc().notificationSchemas[e]:void 0}var Mb=Object.keys(Dh),qb=Object.keys(Vh);function Vc(e){return e!==null&&typeof e==="object"&&!Array.isArray(e)}function _a(e,t){if(e===void 0)return{ok:!1,reason:"not-in-era"};let o=e.safeParse(t);return o.success?{ok:!0,value:o.data}:{ok:!1,reason:"invalid",message:String(o.error)}}var Th={ok:!1,reason:"not-in-era"};function Eh(e){return Vc(e)&&Vc(e.outputSchema)&&Zh(e.outputSchema)}function kh(e){return e}var Wc={era:"2025-11-25",hasRequestMethod:Hh,hasNotificationMethod:Fh,validateRequest:(e,t)=>_a(Pg(e),t),validateResult:(e,t)=>_a(xg(e),t),validateNotification:(e,t)=>_a(Tg(e),t),hasInputRequestMethod:()=>!1,validateInputRequest:()=>Th,validateInputResponse:()=>Th,samplingResultVariant:(e,t)=>{let o=Uh();return _a(e?o.CreateMessageResultWithToolsSchema:o.CreateMessageResultSchema,t)},outboundEnvelope:(e)=>{return},validateEnvelopeMeta:(e)=>[],projectCallToolResult(e,t){let o=jh(e),r=o.structuredContent;if(r===void 0)return o;let n=typeof r!=="object"||r===null||Array.isArray(r),i=t!==void 0&&Zh(t);if(!n&&!i)return o;return{...o,structuredContent:{result:r}}},decodeResult(e,t){if(Vc(t)&&"resultType"in t){let o={...t};return delete o.resultType,{kind:"complete",result:kh(o)}}return{kind:"complete",result:kh(t)}},encodeResult(e,t){if(e!=="tools/list")return t;let o=t.tools;if(!Array.isArray(o)||!o.some((r)=>Eh(r)))return t;return{...t,tools:o.map((r)=>Eh(r)?{...r,outputSchema:zg(r.outputSchema)}:r)}},encodeErrorCode:(e)=>e===-32002?-32602:e,checkInboundEnvelope:(e)=>{return}};function Eg(){let e=on(()=>v([s(),_(),z(),$t(),b(s(),e),h(e)])),t=b(s(),e),o=v([s(),_().int()]),r=s(),n=v([s(),_().int()]),i=O(["user","assistant"]),a=O(["debug","info","notice","warning","error","critical","alert","emergency"]),c=s().refine((W)=>{try{return atob(W),!0}catch{return!1}},{message:"Invalid Base64 string"}),d=l({ttl:_().optional()}),p=l({taskId:s()}),m=k({progressToken:o.optional(),"io.modelcontextprotocol/related-task":p.optional()}),f=l({_meta:m.optional()}),y=f.extend({task:d.optional()}),S=l({_meta:m.optional()}),w=l({method:s(),params:S.loose().optional()}),x=l({src:s(),mimeType:s().optional(),sizes:h(s()).optional(),theme:O(["light","dark"]).optional()}),R=l({icons:h(x).optional()}),C=l({name:s(),title:s().optional()}),N=C.extend({...C.shape,...R.shape,version:s(),websiteUrl:s().optional(),description:s().optional()}),I=je(l({applyDefaults:z().optional()}),t),M=Ct((W)=>{if(W&&typeof W==="object"&&!Array.isArray(W)&&Object.keys(W).length===0)return{form:{}};return W},je(l({form:I.optional(),url:t.optional()}),t.optional())),A=k({list:t.optional(),cancel:t.optional(),requests:k({sampling:k({createMessage:t.optional()}).optional(),elicitation:k({create:t.optional()}).optional()}).optional()}),j=k({list:t.optional(),cancel:t.optional(),requests:k({tools:k({call:t.optional()}).optional()}).optional()}),V=l({experimental:b(s(),t).optional(),sampling:l({context:t.optional(),tools:t.optional()}).optional(),elicitation:M.optional(),roots:l({listChanged:z().optional()}).optional(),tasks:A.optional(),extensions:b(s(),t).optional()}),ae=l({experimental:b(s(),t).optional(),logging:t.optional(),completions:t.optional(),prompts:l({listChanged:z().optional()}).optional(),resources:l({subscribe:z().optional(),listChanged:z().optional()}).optional(),tools:l({listChanged:z().optional()}).optional(),tasks:j.optional(),extensions:b(s(),t).optional()}),Y=l({progress:_(),total:E(_()),message:E(s())}),ge=l({...S.shape,...Y.shape,progressToken:o}),pt=w.extend({method:u("notifications/progress"),params:ge}),Bo=S.extend({level:a,logger:s().optional(),data:P()}),Go=w.extend({method:u("notifications/message"),params:Bo}),Kt=l({uri:s(),mimeType:E(s()),_meta:b(s(),P()).optional()}),Je=Kt.extend({text:s()}),ht=Kt.extend({blob:c}),Pe=l({audience:h(i).optional(),priority:_().min(0).max(1).optional(),lastModified:_o({offset:!0}).optional()}),Be=l({...C.shape,...R.shape,uri:s(),description:E(s()),mimeType:E(s()),size:E(_()),annotations:Pe.optional(),_meta:E(k({}))}),Yt=l({...C.shape,...R.shape,uriTemplate:s(),description:E(s()),mimeType:E(s()),annotations:Pe.optional(),_meta:E(k({}))}),Ae=w.extend({method:u("notifications/resources/list_changed"),params:S.optional()}),Me=S.extend({uri:s()}),Qt=w.extend({method:u("notifications/resources/updated"),params:Me}),Xt=l({name:s(),description:E(s()),required:E(z())}),mt=l({...C.shape,...R.shape,description:E(s()),arguments:E(h(Xt)),_meta:E(k({}))}),eo=w.extend({method:u("notifications/prompts/list_changed"),params:S.optional()}),Te=l({type:u("text"),text:s(),annotations:Pe.optional(),_meta:b(s(),P()).optional()}),be=l({type:u("image"),data:c,mimeType:s(),annotations:Pe.optional(),_meta:b(s(),P()).optional()}),ft=l({type:u("audio"),data:c,mimeType:s(),annotations:Pe.optional(),_meta:b(s(),P()).optional()}),Wo=l({type:u("tool_use"),name:s(),id:s(),input:b(s(),P()),_meta:b(s(),P()).optional()}),Ko=l({type:u("resource"),resource:v([Je,ht]),annotations:Pe.optional(),_meta:b(s(),P()).optional()}),Yo=Be.extend({type:u("resource_link")}),Ge=v([Te,be,ft,Yo,Ko]),to=l({role:i,content:Ge}),gt=l({title:s().optional(),readOnlyHint:z().optional(),destructiveHint:z().optional(),idempotentHint:z().optional(),openWorldHint:z().optional()}),Qo=w.extend({method:u("notifications/tools/list_changed"),params:S.optional()}),Xo=l({name:s().optional()}),er=l({hints:h(Xo).optional(),costPriority:_().min(0).max(1).optional(),speedPriority:_().min(0).max(1).optional(),intelligencePriority:_().min(0).max(1).optional()}),tr=l({mode:O(["auto","required","none"]).optional()}),or=l({type:u("boolean"),title:s().optional(),description:s().optional(),default:z().optional()}),rr=l({type:u("string"),title:s().optional(),description:s().optional(),minLength:_().optional(),maxLength:_().optional(),format:O(["email","uri","date","date-time"]).optional(),default:s().optional()}),nr=l({type:O(["number","integer"]),title:s().optional(),description:s().optional(),minimum:_().optional(),maximum:_().optional(),default:_().optional()}),sr=l({type:u("string"),title:s().optional(),description:s().optional(),enum:h(s()),default:s().optional()}),ir=l({type:u("string"),title:s().optional(),description:s().optional(),oneOf:h(l({const:s(),title:s()})),default:s().optional()}),ar=l({type:u("string"),title:s().optional(),description:s().optional(),enum:h(s()),enumNames:h(s()).optional(),default:s().optional()}),cr=v([sr,ir]),lr=l({type:u("array"),title:s().optional(),description:s().optional(),minItems:_().optional(),maxItems:_().optional(),items:l({type:u("string"),enum:h(s())}),default:h(s()).optional()}),ur=l({type:u("array"),title:s().optional(),description:s().optional(),minItems:_().optional(),maxItems:_().optional(),items:l({anyOf:h(l({const:s(),title:s()}))}),default:h(s()).optional()}),dr=v([lr,ur]),pr=v([ar,cr,dr]),hr=v([pr,or,rr,nr]),St=y.extend({mode:u("form").optional(),message:s(),requestedSchema:l({type:u("object"),properties:b(s(),hr),required:h(s()).optional()}).catchall(P())}),_t=l({type:u("ref/resource"),uri:s()}),yt=l({type:u("ref/prompt"),name:s()}),mr=l({uri:s().startsWith("file://"),name:s().optional(),_meta:b(s(),P()).optional()}),We=V.shape,fr=l({experimental:We.experimental,sampling:We.sampling,elicitation:We.elicitation,roots:We.roots,extensions:We.extensions}),Se=ae.shape,oo=l({experimental:Se.experimental,logging:Se.logging,completions:Se.completions,prompts:Se.prompts,resources:Se.resources,tools:Se.tools,extensions:Se.extensions}),ro=k({progressToken:o.optional(),[It]:s(),[bo]:N.optional(),[Ot]:fr,[vo]:a.optional()}),bt=l({...C.shape,...R.shape,description:s().optional(),inputSchema:k({$schema:s().optional(),type:u("object")}),outputSchema:k({$schema:s().optional()}).optional(),annotations:gt.optional(),_meta:b(s(),P()).optional()}),gr=l({type:u("tool_result"),toolUseId:s(),content:h(Ge),structuredContent:P().optional(),isError:z().optional(),_meta:b(s(),P()).optional()}),no=v([Te,be,ft,Wo,gr]),vt=l({role:i,content:v([no,h(no)]),_meta:b(s(),P()).optional()}),so=s(),io=k({[nt]:N.optional().catch(void 0)}),ao=io.optional();function ne(W){return k({_meta:ao,resultType:so.default("complete"),...W})}let Sr=ne({}),ti=ne({nextCursor:r.optional()}),co=ne({content:h(Ge),structuredContent:P().optional(),isError:z().optional()}),_r=ne({ttlMs:_().int().min(0),cacheScope:O(["public","private"]),tools:h(bt),nextCursor:r.optional()}),yr=ne({ttlMs:_().int().min(0),cacheScope:O(["public","private"]),prompts:h(mt),nextCursor:r.optional()}),br=ne({description:s().optional(),messages:h(to)}),vr=ne({ttlMs:_().int().min(0),cacheScope:O(["public","private"]),resources:h(Be),nextCursor:r.optional()}),zr=ne({ttlMs:_().int().min(0),cacheScope:O(["public","private"]),resourceTemplates:h(Yt),nextCursor:r.optional()}),wr=ne({ttlMs:_().int().min(0),cacheScope:O(["public","private"]),contents:h(v([Je,ht]))}),Rr=ne({completion:l({values:h(s()).max(100),total:_().int().optional(),hasMore:z().optional()}).loose()}),oi=ne({ttlMs:_().int().min(0),cacheScope:O(["public","private"])}),xr=ne({ttlMs:_().int().min(0).catch(0),cacheScope:O(["public","private"]).catch("private"),supportedVersions:h(s()),capabilities:oo,instructions:s().optional()}),Ke=l({messages:h(vt),modelPreferences:er.optional(),systemPrompt:s().optional(),includeContext:O(["none","thisServer","allServers"]).optional(),temperature:_().optional(),maxTokens:_().int(),stopSequences:h(s()).optional(),metadata:t.optional(),tools:h(bt).optional(),toolChoice:tr.optional()}),Pr=l({method:u("sampling/createMessage"),params:Ke}),Tr=l({method:u("roots/list"),params:l({_meta:b(s(),P()).optional()}).optional()}),Er=l({...vt.shape,model:s(),stopReason:s().optional()}),kr=l({roots:h(mr)}),$r=l({action:O(["accept","decline","cancel"]),content:b(s(),v([s(),_(),z(),h(s())])).optional()}),Cr=l({mode:u("url"),message:s(),url:s().url()}),Ir=v([St,Cr]),Or=l({method:u("elicitation/create"),params:Ir}),Nr=v([Pr,Tr,Or]),Ar=v([Er,kr,$r]),Mr=b(s(),Nr),qr=b(s(),Ar),zt=ne({inputRequests:Mr.optional(),requestState:s().optional()}),wt={inputResponses:qr.optional(),requestState:s().optional()},ri=l({_meta:ro,...wt}),ni=k({progressToken:o.optional()});function pe(W,xt){return l({method:u(W),params:l({_meta:ro,...xt})})}function he(W,xt){return l({method:u(W),params:l({_meta:ni.optional(),...xt}).optional()})}let jr={name:s(),arguments:b(s(),P()).optional(),...wt},ve={cursor:r.optional()},si=pe("tools/call",jr),ii=pe("tools/list",ve),ai=pe("prompts/list",ve),ci=pe("prompts/get",{name:s(),arguments:b(s(),s()).optional(),...wt}),li=pe("resources/list",ve),ui=pe("resources/templates/list",ve),di=pe("resources/read",{uri:s(),...wt}),Lr={ref:v([yt,_t]),argument:l({name:s(),value:s()}),context:l({arguments:b(s(),s()).optional()}).optional()},pi=pe("completion/complete",Lr),hi=pe("server/discover",{}),lo=l({toolsListChanged:z().optional(),promptsListChanged:z().optional(),resourcesListChanged:z().optional(),resourceSubscriptions:h(s()).optional()}),Ur={notifications:lo},mi=pe("subscriptions/listen",Ur),fi=io.extend({"io.modelcontextprotocol/subscriptionId":n}),Zr=k({_meta:fi,resultType:so.default("complete")}),Ye={"tools/call":he("tools/call",jr),"tools/list":he("tools/list",ve),"prompts/get":he("prompts/get",{name:s(),arguments:b(s(),s()).optional()}),"prompts/list":he("prompts/list",ve),"resources/list":he("resources/list",ve),"resources/templates/list":he("resources/templates/list",ve),"resources/read":he("resources/read",{uri:s()}),"completion/complete":he("completion/complete",Lr),"server/discover":he("server/discover",{}),"subscriptions/listen":he("subscriptions/listen",Ur)};function de(W){return k({_meta:ao,...W})}let gi={"tools/call":de({content:h(Ge),structuredContent:P().optional(),isError:z().optional()}),"tools/list":de({ttlMs:_().int().min(0),cacheScope:O(["public","private"]),tools:h(bt),nextCursor:r.optional()}),"prompts/get":de({description:s().optional(),messages:h(to)}),"prompts/list":de({ttlMs:_().int().min(0),cacheScope:O(["public","private"]),prompts:h(mt),nextCursor:r.optional()}),"resources/list":de({ttlMs:_().int().min(0),cacheScope:O(["public","private"]),resources:h(Be),nextCursor:r.optional()}),"resources/templates/list":de({ttlMs:_().int().min(0),cacheScope:O(["public","private"]),resourceTemplates:h(Yt),nextCursor:r.optional()}),"resources/read":de({ttlMs:_().int().min(0),cacheScope:O(["public","private"]),contents:h(v([Je,ht]))}),"completion/complete":de({completion:l({values:h(s()).max(100),total:_().int().optional(),hasMore:z().optional()}).loose()}),"server/discover":de({ttlMs:_().int().min(0).catch(0),cacheScope:O(["public","private"]).catch("private"),supportedVersions:h(s()),capabilities:oo,instructions:s().optional()}),"subscriptions/listen":de({})},Rt=k({"io.modelcontextprotocol/subscriptionId":n.optional()}),uo=l({method:u("notifications/subscriptions/acknowledged"),params:l({_meta:Rt.optional(),notifications:lo})}),po=l({_meta:Rt.optional(),requestId:n,reason:s().optional()}),ho=l({method:u("notifications/cancelled"),params:po}),za={"notifications/cancelled":ho,"notifications/progress":pt,"notifications/message":Go,"notifications/resources/updated":Qt,"notifications/resources/list_changed":Ae,"notifications/tools/list_changed":Qo,"notifications/prompts/list_changed":eo,"notifications/subscriptions/acknowledged":uo},ce=(W)=>l({jsonrpc:u("2.0"),id:v([s(),_().int()]),result:W}).strict();return{JSONValueSchema:e,JSONObjectSchema:t,ProgressTokenSchema:o,CursorSchema:r,RequestIdSchema:n,RoleSchema:i,LoggingLevelSchema:a,TaskMetadataSchema:d,RelatedTaskMetadataSchema:p,RequestMetaSchema:m,BaseRequestParamsSchema:f,TaskAugmentedRequestParamsSchema:y,NotificationsParamsSchema:S,NotificationSchema:w,IconSchema:x,IconsSchema:R,BaseMetadataSchema:C,ImplementationSchema:N,ClientTasksCapabilitySchema:A,ServerTasksCapabilitySchema:j,ClientCapabilitiesSchema:V,ServerCapabilitiesSchema:ae,ProgressSchema:Y,ProgressNotificationParamsSchema:ge,ProgressNotificationSchema:pt,LoggingMessageNotificationParamsSchema:Bo,LoggingMessageNotificationSchema:Go,ResourceContentsSchema:Kt,TextResourceContentsSchema:Je,BlobResourceContentsSchema:ht,AnnotationsSchema:Pe,ResourceSchema:Be,ResourceTemplateSchema:Yt,ResourceListChangedNotificationSchema:Ae,ResourceUpdatedNotificationParamsSchema:Me,ResourceUpdatedNotificationSchema:Qt,PromptArgumentSchema:Xt,PromptSchema:mt,PromptListChangedNotificationSchema:eo,TextContentSchema:Te,ImageContentSchema:be,AudioContentSchema:ft,ToolUseContentSchema:Wo,EmbeddedResourceSchema:Ko,ResourceLinkSchema:Yo,ContentBlockSchema:Ge,PromptMessageSchema:to,ToolAnnotationsSchema:gt,ToolListChangedNotificationSchema:Qo,ModelHintSchema:Xo,ModelPreferencesSchema:er,ToolChoiceSchema:tr,BooleanSchemaSchema:or,StringSchemaSchema:rr,NumberSchemaSchema:nr,UntitledSingleSelectEnumSchemaSchema:sr,TitledSingleSelectEnumSchemaSchema:ir,LegacyTitledEnumSchemaSchema:ar,SingleSelectEnumSchemaSchema:cr,UntitledMultiSelectEnumSchemaSchema:lr,TitledMultiSelectEnumSchemaSchema:ur,MultiSelectEnumSchemaSchema:dr,EnumSchemaSchema:pr,PrimitiveSchemaDefinitionSchema:hr,ElicitRequestFormParamsSchema:St,ResourceTemplateReferenceSchema:_t,PromptReferenceSchema:yt,RootSchema:mr,ClientCapabilities2026Schema:fr,ServerCapabilities2026Schema:oo,RequestMetaEnvelopeSchema:ro,ToolSchema:bt,ToolResultContentSchema:gr,SamplingMessageContentBlockSchema:no,SamplingMessageSchema:vt,ResultTypeSchema:so,ResultMetaSchema:io,ResultSchema:Sr,PaginatedResultSchema:ti,CallToolResultSchema:co,ListToolsResultSchema:_r,ListPromptsResultSchema:yr,GetPromptResultSchema:br,ListResourcesResultSchema:vr,ListResourceTemplatesResultSchema:zr,ReadResourceResultSchema:wr,CompleteResultSchema:Rr,CacheableResultSchema:oi,DiscoverResultSchema:xr,CreateMessageRequestParamsSchema:Ke,CreateMessageRequestSchema:Pr,ListRootsRequestSchema:Tr,CreateMessageResultSchema:Er,ListRootsResultSchema:kr,ElicitResultSchema:$r,ElicitRequestURLParamsSchema:Cr,ElicitRequestParamsSchema:Ir,ElicitRequestSchema:Or,InputRequestSchema:Nr,InputResponseSchema:Ar,InputRequestsSchema:Mr,InputResponsesSchema:qr,InputRequiredResultSchema:zt,InputResponseRequestParamsSchema:ri,CallToolRequestSchema:si,ListToolsRequestSchema:ii,ListPromptsRequestSchema:ai,GetPromptRequestSchema:ci,ListResourcesRequestSchema:li,ListResourceTemplatesRequestSchema:ui,ReadResourceRequestSchema:di,CompleteRequestSchema:pi,DiscoverRequestSchema:hi,SubscriptionFilterSchema:lo,SubscriptionsListenRequestSchema:mi,SubscriptionsListenResultMetaSchema:fi,SubscriptionsListenResultSchema:Zr,dispatchRequestSchemas:Ye,dispatchResultSchemas:gi,NotificationMetaSchema:Rt,SubscriptionsAcknowledgedNotificationSchema:uo,CancelledNotificationParamsSchema:po,CancelledNotificationSchema:ho,notificationSchemas2026:za,JSONRPCResultResponseSchema:ce(Sr),CallToolResultResponseSchema:ce(v([co,zt])),ListToolsResultResponseSchema:ce(_r),ListPromptsResultResponseSchema:ce(yr),GetPromptResultResponseSchema:ce(v([br,zt])),ListResourcesResultResponseSchema:ce(vr),ListResourceTemplatesResultResponseSchema:ce(zr),ReadResourceResultResponseSchema:ce(v([wr,zt])),CompleteResultResponseSchema:ce(Rr),DiscoverResultResponseSchema:ce(xr),SubscriptionsListenResultResponseSchema:ce(Zr)}}var kg;function lt(){return kg??=Eg()}var $g=["tools/list","prompts/list","resources/list","resources/templates/list","resources/read","server/discover"];function Cg(e){return $g.includes(e)}var Kc=Symbol("modelcontextprotocol.resultCacheHintFallback");function Ig(e){return e[Kc]}function Jh(e){return typeof e==="number"&&Number.isSafeInteger(e)&&e>=0}function Bh(e){return e==="public"||e==="private"}var q=function(e){return 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.ResourceNotFound=-32002]="ResourceNotFound",e[e.MissingRequiredClientCapability=-32021]="MissingRequiredClientCapability",e[e.UnsupportedProtocolVersion=-32022]="UnsupportedProtocolVersion",e[e.UrlElicitationRequired=-32042]="UrlElicitationRequired",e}({}),re=class e extends Error{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.ProtocolError"})}static[Symbol.hasInstance](t){return fe(this,t)}static isInstance(t){if(typeof this!=="function")throw TypeError("isInstance must be called on the class (e.g. `SdkError.isInstance(value)`); for callbacks use `v => SdkError.isInstance(v)`");return fe(this,t)}constructor(t,o,r){super(o);this.code=t,this.data=r,this.name="ProtocolError",Bt(this,new.target)}static fromError(t,o,r){if(t===q.UrlElicitationRequired&&r){let n=r;if(n.elicitations)return new Wh(n.elicitations,o)}if(t===q.UnsupportedProtocolVersion&&r){let n=r;if(Array.isArray(n.supported)&&typeof n.requested==="string")return new Kh({supported:n.supported,requested:n.requested},o)}if(t===q.InvalidParams||t===q.ResourceNotFound){let n=r;if(typeof n?.uri==="string"&&(t===q.ResourceNotFound||Object.keys(n).length===1))return new Gh(n.uri,o)}if(t===q.MissingRequiredClientCapability&&r){let n=r;if(n.requiredCapabilities!==null&&typeof n.requiredCapabilities==="object"&&!Array.isArray(n.requiredCapabilities))return new Yh({requiredCapabilities:n.requiredCapabilities},o)}return new e(t,o,r)}},Gh=class extends re{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.ResourceNotFoundError"})}constructor(e,t=`Resource not found: ${e}`){super(q.InvalidParams,t,{uri:e})}get uri(){return this.data.uri}},Wh=class extends re{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.UrlElicitationRequiredError"})}constructor(e,t=`URL elicitation${e.length>1?"s":""} required`){super(q.UrlElicitationRequired,t,{elicitations:e})}get elicitations(){return this.data?.elicitations??[]}},Kh=class extends re{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.UnsupportedProtocolVersionError"})}constructor(e,t=`Unsupported protocol version: ${e.requested}`){super(q.UnsupportedProtocolVersion,t,e)}get supported(){return this.data.supported}get requested(){return this.data.requested}},Yh=class extends re{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.MissingRequiredClientCapabilityError"})}constructor(e,t=`Missing required client capabilities: ${Object.keys(e.requiredCapabilities).join(", ")}`){super(q.MissingRequiredClientCapability,t,e)}get requiredCapabilities(){return this.data.requiredCapabilities}},Og=0,Ng="private",Ag=["tools/call","prompts/get","resources/read"];function Mg(e,t){let o=t.resultType;if(o===void 0)return{...t,resultType:"complete"};if(o==="complete")return t;if(Ag.includes(e))return t;throw new re(q.InternalError,`Handler for ${e} returned resultType '${String(o)}', but results of ${e} only support 'complete' on protocol revision 2026-07-28`)}function qg(e,t){let o=Ig(t);if(t.resultType!=="complete"||!Cg(e))return o===void 0?t:Dg(t);let r=t,n=Jh(r.ttlMs)?r.ttlMs:Ug(o),i=Bh(r.cacheScope)?r.cacheScope:Zg(o),a={...r,ttlMs:n,cacheScope:i};return delete a[Kc],a}function jg(e){return e!==null&&typeof e==="object"&&!Array.isArray(e)}function Lg(e,t){if(t===void 0)return e;let o=e._meta;if(o===void 0)return{...e,_meta:{[nt]:t}};if(!jg(o))return e;if(o[nt]!==void 0)return e;return{...e,_meta:{...o,[nt]:t}}}function Ug(e){return e!==void 0&&Jh(e.ttlMs)?e.ttlMs:Og}function Zg(e){return e!==void 0&&Bh(e.cacheScope)?e.cacheScope:Ng}function Dg(e){let t={...e};return delete t[Kc],t}var Vg=["elicitation/create","sampling/createMessage","roots/list"],ya;function Qh(){if(ya)return ya;let e=lt();return ya={request:{"elicitation/create":l({method:u("elicitation/create"),params:e.ElicitRequestParamsSchema}),"sampling/createMessage":l({method:u("sampling/createMessage"),params:e.CreateMessageRequestParamsSchema}),"roots/list":l({method:u("roots/list"),params:k({}).optional()})},response:{"elicitation/create":e.ElicitResultSchema,"sampling/createMessage":e.CreateMessageResultSchema,"roots/list":e.ListRootsResultSchema}},ya}function Xh(e){return Vg.includes(e)}function qc(e){return Xh(e)?Qh().request[e]:void 0}function Hg(e){return Xh(e)?Qh().response[e]:void 0}var Yc={"tools/call":null,"tools/list":null,"prompts/get":null,"prompts/list":null,"resources/list":null,"resources/templates/list":null,"resources/read":null,"completion/complete":null,"server/discover":null,"subscriptions/listen":null},em={"notifications/cancelled":null,"notifications/progress":null,"notifications/message":null,"notifications/resources/updated":null,"notifications/resources/list_changed":null,"notifications/tools/list_changed":null,"notifications/prompts/list_changed":null,"notifications/subscriptions/acknowledged":null};function tm(e){return Object.prototype.hasOwnProperty.call(Yc,e)}function om(e){return Object.prototype.hasOwnProperty.call(em,e)}function Fg(e){return Object.prototype.hasOwnProperty.call(Yc,e)}function Jg(e){return tm(e)?lt().dispatchRequestSchemas[e]:void 0}function Bg(e){return Fg(e)?lt().dispatchResultSchemas[e]:void 0}function Gg(e){return om(e)?lt().notificationSchemas2026[e]:void 0}var jb=Object.keys(Yc),Lb=Object.keys(em);function Js(e){return e!==null&&typeof e==="object"&&!Array.isArray(e)}function Hs(e,t){if(e===void 0)return{ok:!1,reason:"not-in-era"};let o=e.safeParse(t);return o.success?{ok:!0,value:o.data}:{ok:!1,reason:"invalid",message:String(o.error)}}var Wg={ok:!1,reason:"not-in-era"},Kg=[It,Ot];function Yg(e,t){let o=t,r=!1,n=()=>{if(!r)o={...o},r=!0;return o},i=t.tools;if(e==="tools/list"&&Array.isArray(i)&&i.some((c)=>Js(c)&&("execution"in c)))n().tools=i.map((c)=>{if(!Js(c)||!("execution"in c))return c;let d={...c};return delete d.execution,d});let a=t.capabilities;if(Js(a)&&"tasks"in a){let c={...a};delete c.tasks,n().capabilities=c}return o}var Qc={era:"2026-07-28",hasRequestMethod:tm,hasNotificationMethod:om,hasInputRequestMethod:(e)=>qc(e)!==void 0,validateRequest:(e,t)=>Hs(Jg(e),t),validateResult:(e,t)=>Hs(Bg(e),t),validateNotification:(e,t)=>Hs(Gg(e),t),validateInputRequest:(e,t)=>Hs(qc(e),t),validateInputResponse:(e,t)=>Hs(Hg(e),t),samplingResultVariant:()=>Wg,outboundEnvelope(e){return{[It]:e.protocolVersion,[bo]:e.clientInfo,[Ot]:e.clientCapabilities,...e.logLevel!==void 0&&{[vo]:e.logLevel}}},validateEnvelopeMeta(e){let t=[];for(let r of Kg)if(!(r in e))t.push({key:r,problem:"missing"});let o=lt().RequestMetaEnvelopeSchema.safeParse(e);if(!o.success)for(let r of o.error.issues){let n=r.path.map(String),i=n.length>0?n.join("."):"_meta";if(n.length===1&&t.some((a)=>a.key===i&&a.problem==="missing"))continue;t.push({key:i,problem:r.message})}return t},projectCallToolResult:(e)=>jh(e),inputRequestSchema:qc,decodeResult(e,t){if(!Js(t))return{kind:"invalid",error:new K(oe.InvalidResult,`Invalid result for ${e}: not an object`,{method:e})};let o=t.resultType;if(o===void 0)return{kind:"invalid",error:new K(oe.InvalidResult,`Invalid result for ${e}: missing required resultType — servers implementing protocol revision 2026-07-28 MUST include it (the absent-means-complete bridge applies only to earlier-revision servers)`,{method:e,violation:"missing-resultType"})};if(typeof o!=="string")return{kind:"invalid",error:new K(oe.InvalidResult,`Invalid result for ${e}: non-string resultType`,{method:e,resultType:o})};if(o==="input_required"){let a=t.inputRequests,c=Js(a)?a:{},d=t.requestState,p=t._meta===void 0?void 0:lt().ResultMetaSchema.safeParse(t._meta),m=p?.success?p.data:void 0;if(Object.keys(c).length===0&&typeof d!=="string")return{kind:"invalid",error:new K(oe.InvalidResult,`Invalid result for ${e}: input_required carries neither inputRequests nor requestState (every input_required result must include at least one of the two)`,{method:e,violation:"input-required-missing-both"})};return{kind:"input_required",inputRequests:c,...typeof d==="string"&&{requestState:d},...m!==void 0&&{_meta:m}}}if(o!=="complete")return{kind:"invalid",error:new K(oe.UnsupportedResultType,`Unsupported result type '${o}' for ${e}`,{resultType:o,method:e})};let r=Qg(),n=Object.hasOwn(r,e)?r[e]:void 0;if(n!==void 0){let a=n.safeParse(t);if(!a.success)return{kind:"invalid",error:new K(oe.InvalidResult,`Invalid result for ${e}: ${a.error}`,{method:e})}}let i={...t};return delete i.resultType,{kind:"complete",result:i}},encodeResult(e,t,o){return Lg(qg(e,Mg(e,Yg(e,t))),o)},encodeErrorCode:(e)=>e===-32002?-32602:e,checkInboundEnvelope(e){if(e.envelope===void 0)return"Request is missing the required _meta envelope for protocol revision 2026-07-28 (io.modelcontextprotocol/protocolVersion, io.modelcontextprotocol/clientCapabilities)";let t=lt().RequestMetaEnvelopeSchema.safeParse(e.envelope);if(!t.success)return`Invalid _meta envelope for protocol revision 2026-07-28: ${t.error.issues.map((o)=>o.message).join("; ")}`}},ba;function Qg(){if(ba)return ba;let e=lt();return ba={"tools/call":e.CallToolResultSchema,"tools/list":e.ListToolsResultSchema,"prompts/get":e.GetPromptResultSchema,"prompts/list":e.ListPromptsResultSchema,"resources/list":e.ListResourcesResultSchema,"resources/templates/list":e.ListResourceTemplatesResultSchema,"resources/read":e.ReadResourceResultSchema,"completion/complete":e.CompleteResultSchema,"server/discover":e.DiscoverResultSchema},ba}var Xc="2026-07-28";function Gs(e){return e!==void 0&&qh(e)?Qc:Wc}function $h(e){if(e.revision!==void 0)return Gs(e.revision).era;return e.era==="modern"?Qc.era:Wc.era}function jc(e){return rm.some((t)=>t.hasRequestMethod(e))}function Lc(e){return rm.some((t)=>t.hasNotificationMethod(e))}function Ch(e){return e==="tasks/get"||e==="tasks/cancel"}var rm=[Wc,Qc],Xg=Sl({AnnotationsSchema:()=>Ce,AudioContentSchema:()=>Zt,BaseMetadataSchema:()=>ke,BaseRequestParamsSchema:()=>X,BlobResourceContentsSchema:()=>Ao,BooleanSchemaSchema:()=>Lo,CallToolRequestParamsSchema:()=>Qn,CallToolRequestSchema:()=>Xn,CallToolResultSchema:()=>ct,CancelTaskRequestSchema:()=>aa,CancelTaskResultSchema:()=>ca,CancelledNotificationParamsSchema:()=>sn,CancelledNotificationSchema:()=>Eo,ClientCapabilitiesSchema:()=>cn,ClientNotificationSchema:()=>ua,ClientRequestSchema:()=>la,ClientResultSchema:()=>da,ClientTasksCapabilitySchema:()=>Gi,CompatibilityCallToolResultSchema:()=>Ki,CompleteRequestParamsSchema:()=>Ps,CompleteRequestSchema:()=>Ts,CompleteResultSchema:()=>Es,ContentBlockSchema:()=>Ie,CreateMessageRequestParamsSchema:()=>ds,CreateMessageRequestSchema:()=>ps,CreateMessageResultSchema:()=>hs,CreateMessageResultWithToolsSchema:()=>ms,CreateTaskResultSchema:()=>Xi,CursorSchema:()=>wo,DiscoverRequestSchema:()=>hn,DiscoverResultSchema:()=>$o,ElicitRequestFormParamsSchema:()=>Jt,ElicitRequestParamsSchema:()=>ys,ElicitRequestSchema:()=>bs,ElicitRequestURLParamsSchema:()=>_s,ElicitResultSchema:()=>ws,ElicitationCompleteNotificationParamsSchema:()=>vs,ElicitationCompleteNotificationSchema:()=>zs,EmbeddedResourceSchema:()=>Dt,EmptyResultSchema:()=>it,EnumSchemaSchema:()=>Ss,GetPromptRequestParamsSchema:()=>Dn,GetPromptRequestSchema:()=>Vn,GetPromptResultSchema:()=>Jn,GetTaskPayloadRequestSchema:()=>ra,GetTaskPayloadResultSchema:()=>na,GetTaskRequestSchema:()=>ta,GetTaskResultSchema:()=>oa,IconSchema:()=>an,IconsSchema:()=>Ue,ImageContentSchema:()=>Ut,ImplementationSchema:()=>$e,InitializeRequestParamsSchema:()=>ln,InitializeRequestSchema:()=>un,InitializeResultSchema:()=>dn,InitializedNotificationSchema:()=>pn,JSONArraySchema:()=>Ji,JSONObjectSchema:()=>J,JSONRPCErrorResponseSchema:()=>Mt,JSONRPCMessageSchema:()=>qt,JSONRPCNotificationSchema:()=>To,JSONRPCRequestSchema:()=>Po,JSONRPCResponseSchema:()=>Bi,JSONRPCResultResponseSchema:()=>At,JSONValueSchema:()=>Le,LegacyTitledEnumSchemaSchema:()=>Do,ListChangedOptionsBaseSchema:()=>Yi,ListPromptsRequestSchema:()=>Un,ListPromptsResultSchema:()=>Zn,ListResourceTemplatesRequestSchema:()=>bn,ListResourceTemplatesResultSchema:()=>vn,ListResourcesRequestSchema:()=>_n,ListResourcesResultSchema:()=>yn,ListRootsRequestSchema:()=>$s,ListRootsResultSchema:()=>Cs,ListTasksRequestSchema:()=>sa,ListTasksResultSchema:()=>ia,ListToolsRequestSchema:()=>Kn,ListToolsResultSchema:()=>Yn,LoggingLevelSchema:()=>jo,LoggingMessageNotificationParamsSchema:()=>rs,LoggingMessageNotificationSchema:()=>ns,ModelHintSchema:()=>ss,ModelPreferencesSchema:()=>is,MultiSelectEnumSchemaSchema:()=>gs,NotificationSchema:()=>te,NotificationsParamsSchema:()=>ie,NumberSchemaSchema:()=>Ft,PaginatedRequestParamsSchema:()=>gn,PaginatedRequestSchema:()=>Ze,PaginatedResultSchema:()=>De,PingRequestSchema:()=>Co,PrimitiveSchemaDefinitionSchema:()=>Fo,ProgressNotificationParamsSchema:()=>fn,ProgressNotificationSchema:()=>Io,ProgressSchema:()=>mn,ProgressTokenSchema:()=>zo,PromptArgumentSchema:()=>jn,PromptListChangedNotificationSchema:()=>Bn,PromptMessageSchema:()=>Fn,PromptReferenceSchema:()=>xs,PromptSchema:()=>Ln,ReadResourceRequestParamsSchema:()=>zn,ReadResourceRequestSchema:()=>wn,ReadResourceResultSchema:()=>Rn,RelatedTaskMetadataSchema:()=>nn,RequestIdSchema:()=>Re,RequestMetaSchema:()=>Ro,RequestSchema:()=>B,ResourceContentsSchema:()=>Oo,ResourceLinkSchema:()=>Vt,ResourceListChangedNotificationSchema:()=>xn,ResourceRequestParamsSchema:()=>jt,ResourceSchema:()=>Mo,ResourceTemplateReferenceSchema:()=>Rs,ResourceTemplateSchema:()=>Sn,ResourceUpdatedNotificationParamsSchema:()=>Mn,ResourceUpdatedNotificationSchema:()=>qn,ResultMetaObjectSchema:()=>xo,ResultSchema:()=>G,RoleSchema:()=>Ve,RootSchema:()=>ks,RootsListChangedNotificationSchema:()=>Is,SamplingContentSchema:()=>ls,SamplingMessageContentBlockSchema:()=>rt,SamplingMessageSchema:()=>us,ServerCapabilitiesSchema:()=>ko,ServerNotificationSchema:()=>ha,ServerRequestSchema:()=>pa,ServerResultSchema:()=>ma,ServerTasksCapabilitySchema:()=>Wi,SetLevelRequestParamsSchema:()=>ts,SetLevelRequestSchema:()=>os,SingleSelectEnumSchemaSchema:()=>fs,StringSchemaSchema:()=>Ht,SubscribeRequestParamsSchema:()=>Pn,SubscribeRequestSchema:()=>Tn,SubscriptionFilterSchema:()=>qo,SubscriptionsAcknowledgedNotificationParamsSchema:()=>In,SubscriptionsAcknowledgedNotificationSchema:()=>On,SubscriptionsListenRequestParamsSchema:()=>$n,SubscriptionsListenRequestSchema:()=>Cn,SubscriptionsListenResultMetaSchema:()=>Nn,SubscriptionsListenResultSchema:()=>An,TaskAugmentedRequestParamsSchema:()=>st,TaskCreationParamsSchema:()=>Qi,TaskMetadataSchema:()=>rn,TaskSchema:()=>He,TaskStatusNotificationParamsSchema:()=>Ns,TaskStatusNotificationSchema:()=>ea,TaskStatusSchema:()=>Os,TextContentSchema:()=>Lt,TextResourceContentsSchema:()=>No,TitledMultiSelectEnumSchemaSchema:()=>Ho,TitledSingleSelectEnumSchemaSchema:()=>Zo,ToolAnnotationsSchema:()=>Gn,ToolChoiceSchema:()=>as,ToolExecutionSchema:()=>Wn,ToolListChangedNotificationSchema:()=>es,ToolResultContentSchema:()=>cs,ToolSchema:()=>at,ToolUseContentSchema:()=>Hn,UnsubscribeRequestParamsSchema:()=>En,UnsubscribeRequestSchema:()=>kn,UntitledMultiSelectEnumSchemaSchema:()=>Vo,UntitledSingleSelectEnumSchemaSchema:()=>Uo});var nm=(e)=>Po.safeParse(e).success,sm=(e)=>To.safeParse(e).success,Hc=(e)=>At.safeParse(e).success,im=(e)=>Mt.safeParse(e).success;var Bs=-32020,Ub=[{rung:"http-method",order:1,evaluatedAt:"edge",codes:[-32000],conformance:[],rationale:"The modern era is POST-only; GET/DELETE are body-less 2025-era session operations and are method-routed to legacy serving (405 when legacy serving is not configured), before any body is read."},{rung:"jsonrpc-shape",order:2,evaluatedAt:"edge",codes:[q.InvalidRequest],conformance:["server-stateless"],rationale:"The body must be a JSON-RPC request or notification: posted responses and batch arrays containing a modern or invalid element are rejected before classification (element-wise batch rule); all-legacy arrays stay legacy traffic."},{rung:"era-classification",order:3,evaluatedAt:"edge",codes:[Bs,q.UnsupportedProtocolVersion],conformance:["server-stateless","http-header-validation","http-custom-header-server-validation"],rationale:"Body-primary era classification with the protocol-version header as a cross-check; a header/body disagreement is rejected with -32020 (HeaderMismatch), and an envelope-less request on a modern-only endpoint is answered with the unsupported-protocol-version error naming the supported revisions."},{rung:"envelope",order:4,evaluatedAt:"edge",codes:[q.InvalidParams],conformance:["server-stateless"],rationale:"A present envelope claim with a malformed envelope — and a missing envelope on a request whose protocol-version header names a modern revision — is an invalid-params rejection naming the offending or missing key(s); never a silent fall back to legacy handling. This is the only place an invalid-params rejection maps to HTTP 400."},{rung:"method-registry",order:5,evaluatedAt:"dispatch",codes:[q.MethodNotFound],conformance:["server-stateless"],rationale:"Method existence outranks parameter validity: a method absent from the negotiated revision’s registry (or with no handler installed) answers method-not-found before params or capabilities are looked at."},{rung:"request-params",order:6,evaluatedAt:"dispatch",codes:[q.InvalidParams],conformance:[],rationale:"Per-method params validation; emitted in-band by the dispatch layer (HTTP 200), never via the ladder status table."},{rung:"standard-header-validation",order:7,evaluatedAt:"pre-dispatch",codes:[Bs],conformance:["http-header-validation"],rationale:"SEP-2243 standard `MCP-Protocol-Version` / `Mcp-Method` / `Mcp-Name` headers — presence, sentinel decoding, and `Mcp-Name` ↔ body cross-check — are validated by the HTTP entry on a modern-classified request after the supported-revision gate and before dispatch. The spec requires `MCP-Protocol-Version` and `Mcp-Method` on every modern *request* POST (`Mcp-Name` only for the methods that mirror `params.name` / `params.uri` / `params.taskId`, see `MCP_NAME_HEADER_SOURCE`) and names them in that order, so a request missing several is answered by the earliest. Notification POSTs are exempt: the presence half runs on requests only, so a modern-enveloped notification is dispatched even with no standard headers at all. The classifier’s own header-mismatch cells (protocol-version, `Mcp-Method` mismatch) stay on the edge `era-classification` rung; this rung carries the entry-layer presence/`Mcp-Name` half — including the missing `MCP-Protocol-Version` cell, which cannot live on the edge rung without breaking body-primary classification. Evaluated before the capability gate, the factory call, and the `Mcp-Param-*` rung so a request that fails several rungs is answered by the standard-header rung first. The documented order (after method-registry 5 and request-params 6) is NOT the observed precedence: serveModern evaluates this rung immediately after the supported-revision gate, so a request that also fails a dispatch rung is answered here before the dispatch rungs (5–6) are consulted."},{rung:"client-capabilities",order:8,evaluatedAt:"pre-dispatch",codes:[q.MissingRequiredClientCapability],conformance:["server-stateless"],rationale:"The capability requirement is checked by the HTTP entry, pre-dispatch, against the validated envelope the classifier produced — pinning the spec-mandated HTTP 400 independently of how dispatch- and handler-produced errors are mapped. The documented order (after method resolution and params validation) is preserved observably only while the requirement table is empty: once a served method gains a requirement entry, a request that is missing the capability and would also fail a dispatch rung is answered by this gate first, so the entry must consult the method registry before the gate if the documented precedence is to stay observable."},{rung:"param-header-validation",order:9,evaluatedAt:"pre-dispatch",codes:[Bs],conformance:["http-custom-header-server-validation"],rationale:"SEP-2243 `Mcp-Param-*` headers are validated against the named tool’s `x-mcp-header` declarations and the body `arguments` after the tool registry is known and before dispatch reaches the handler; a missing/disagreeing/malformed header is rejected 400 / -32020 with the same shape as the standard-header cross-checks. The documented order (after method resolution and params validation) is preserved observably only when the body `arguments` would otherwise validate: the check runs pre-dispatch, so a `tools/call` that fails BOTH this rung and a dispatch-time rung (e.g. order-6 `request-params`, -32602) is answered by this gate first with 400 / -32020, not by the earlier-ordered rung."}],Zb={[q.ParseError]:400,[q.InvalidRequest]:400,[q.MethodNotFound]:404,[q.UnsupportedProtocolVersion]:400,[q.MissingRequiredClientCapability]:400,[Bs]:400};function el(e,t){return qi(e,t)}function Fs(e){return new Set(e.flatMap((t)=>Object.keys(t.shape)))}function Fc(e){if(e==null)return!1;let t=typeof e;if(t!=="object"&&t!=="function")return!1;if(!("~standard"in e))return!1;return typeof e["~standard"]?.validate==="function"}var Ih=!1,Jc="draft-2020-12";function eS(e,t="input"){let o=e["~standard"],r;if(o.jsonSchema)r=o.jsonSchema[t]({target:Jc});else if(o.vendor==="zod"){if(!("_zod"in e))throw Error("Schema appears to be from zod 3, which the SDK cannot convert to JSON Schema. Upgrade to zod >=4.2.0, or wrap your JSON Schema with fromJsonSchema().");if(!Ih)Ih=!0,console.warn("[mcp-sdk] Your zod version does not implement `~standard.jsonSchema` (added in zod 4.2.0). Falling back to z.toJSONSchema(). Upgrade to zod >=4.2.0 to silence this warning.");r=Ai(e,{target:Jc,io:t})}else throw Error(`Schema library "${o.vendor}" does not implement StandardJSONSchemaV1 (\`~standard.jsonSchema\`). Upgrade to a version that does, or wrap your JSON Schema with fromJsonSchema().`);if(t==="output"){if(r.type!==void 0)return r;return am(r)?{type:"object",...r}:r}if(r.type!==void 0&&r.type!=="object")throw Error(`MCP tool and prompt schemas must describe objects (got type: ${JSON.stringify(r.type)}). Wrap your schema in z.object({...}) or equivalent.`);return{type:"object",...r}}function am(e){if("properties"in e||"patternProperties"in e||"additionalProperties"in e||"required"in e)return!0;for(let t of["oneOf","anyOf","allOf"]){let o=e[t];if(Array.isArray(o)&&o.length>0)return o.every((r)=>r!==null&&typeof r==="object"&&(r.type==="object"||am(r)))}return!1}function tS(e){if(!e.path?.length)return e.message;return`${e.path.map((t)=>String(typeof t==="object"?t.key:t)).join(".")}: ${e.message}`}async function Uc(e,t){let o=await e["~standard"].validate(t);if(o.issues&&o.issues.length>0)return{success:!1,error:o.issues.map((r)=>tS(r)).join(", ")};return{success:!0,data:o.value}}function oS(e){let t=Ai(e,{target:Jc,io:"input"});return typeof t.pattern==="string"?t.pattern:void 0}var rS=/\\\.\\d\{(\d+)\}/;function nS(e){let t=rS.exec(e),o=[void 0,-1,0];if(t)o.push(Number(t[1]));return[!1,!0].flatMap((r)=>[!1,!0].flatMap((n)=>o.map((i)=>_o({local:r,offset:n,precision:i}))))}function sS(e,t){let o;switch(e){case"email":o=[sh()];break;case"uri":o=[Li()];break;case"date":o=[$c()];break;case"date-time":o=nS(t);break}return new Set(o.map((r)=>oS(r)).filter((r)=>r!==void 0))}function iS(e,t,o){if(o!=="zod")return!0;return sS(e,t).has(t)}function Ws(e){return typeof e==="object"&&e!==null&&!Array.isArray(e)}function aS(e){try{return eS(e,"input")}catch(t){let o=t instanceof Error?t.message:String(t);throw new re(q.InvalidParams,`Elicitation requestedSchema must describe an object with flat primitive properties: ${o}`)}}var cS=new Set(["$comment","deprecated","description","examples","readOnly","title","writeOnly"]);function tl(e){return cS.has(e)||e.startsWith("x-")}var lS=new Set(["$schema",...Object.keys(Jt.shape.requestedSchema.shape)]),Oh={string:Fs([Ht,Uo,Zo,Do]),number:Fs([Ft]),integer:Fs([Ft]),boolean:Fs([Lo]),array:Fs([Vo,Ho])},uS=new Set(Ht.shape.format.unwrap().options);function dS(e,t,o,r){if(!Ws(e))return e;let n=typeof e.type==="string"&&Object.hasOwn(Oh,e.type)?Oh[e.type]:void 0;if(n===void 0)return e;let i={};for(let[a,c]of Object.entries(e))if(n.has(a)||tl(a))i[a]=c;else if(a==="pattern"&&e.type==="string"&&typeof e.format==="string"){if(!uS.has(e.format))i[a]=c;else if(typeof c!=="string"||!iS(e.format,c,o))r.push(`${t}.${a}`)}else r.push(`${t}.${a}`);return i}function pS(e,t){let o={},r=[];for(let[n,i]of Object.entries(e))if(n==="properties"&&Ws(i))o[n]=Object.fromEntries(Object.entries(i).map(([a,c])=>[a,dS(c,`properties.${a}`,t,r)]));else if(lS.has(n))o[n]=i;else if(!tl(n))r.push(n);if(r.length>0)throw new re(q.InvalidParams,`Elicitation requestedSchema contains unsupported JSON Schema constraint(s) after Standard Schema conversion: ${r.join(", ")}`);return o}function hS(e,t){if(!Ws(e.properties))return t;let o=Object.entries(e.properties).filter(([,r])=>!el(Fo,r).success).map(([r])=>`properties.${r}`);return o.length>0?o.join(", "):t}function Bc(e,t,o=""){if(Array.isArray(e)&&Array.isArray(t))return e.flatMap((r,n)=>Bc(r,t[n],`${o}[${n}]`));if(!Ws(e)||!Ws(t))return[];return Object.entries(e).flatMap(([r,n])=>{let i=o?`${o}.${r}`:r;if(!Object.prototype.hasOwnProperty.call(t,r))return tl(r)?[]:[i];return Bc(n,t[r],i)})}function mS(e){if(!Fc(e.requestedSchema))return{...e,mode:"form",requestedSchema:e.requestedSchema};let t=e.requestedSchema["~standard"].vendor,o=pS(aS(e.requestedSchema),t),r=el(Jt.shape.requestedSchema,o);if(!r.success)throw new re(q.InvalidParams,`Elicitation requestedSchema only supports flat primitive properties (string, number, integer, boolean, and string enums): ${hS(o,r.error.message)}`);let n=Bc(o,r.data);if(n.length>0)throw new re(q.InvalidParams,`Elicitation requestedSchema contains unsupported JSON Schema constraint(s) after Standard Schema conversion: ${n.join(", ")}`);let i=(r.data.required??[]).filter((a)=>!Object.prototype.hasOwnProperty.call(r.data.properties,a));if(i.length>0)throw new re(q.InvalidParams,`Elicitation requestedSchema lists required properties that are not defined in properties: ${i.join(", ")}`);return{...e,mode:"form",requestedSchema:r.data}}function fS(e){let t=e.inputRequests!==void 0&&Object.keys(e.inputRequests).length>0,o=typeof e.requestState==="string";if(!t&&!o)throw TypeError("inputRequired() requires at least one of inputRequests (with at least one entry) or requestState (spec: every InputRequiredResult MUST include at least one of the two)");return{resultType:"input_required",...e.inputRequests!==void 0&&{inputRequests:e.inputRequests},...e.requestState!==void 0&&{requestState:e.requestState}}}var Db=Object.assign(fS,{elicit(e){try{return{method:"elicitation/create",params:mS(e)}}catch(t){throw t instanceof re?TypeError(t.message,{cause:t}):t}},elicitUrl(e){return{method:"elicitation/create",params:{...e,mode:"url"}}},createMessage(e){return{method:"sampling/createMessage",params:e}},listRoots(){return{method:"roots/list"}}});var gS=["AnnotationsSchema","AudioContentSchema","BaseMetadataSchema","BlobResourceContentsSchema","BooleanSchemaSchema","CallToolRequestSchema","CallToolRequestParamsSchema","CallToolResultSchema","CancelledNotificationSchema","CancelledNotificationParamsSchema","CancelTaskRequestSchema","CancelTaskResultSchema","ClientCapabilitiesSchema","ClientNotificationSchema","ClientRequestSchema","ClientResultSchema","CompatibilityCallToolResultSchema","CompleteRequestSchema","CompleteRequestParamsSchema","CompleteResultSchema","ContentBlockSchema","CreateMessageRequestSchema","CreateMessageRequestParamsSchema","CreateMessageResultSchema","CreateMessageResultWithToolsSchema","CreateTaskResultSchema","CursorSchema","DiscoverRequestSchema","DiscoverResultSchema","ElicitationCompleteNotificationSchema","ElicitationCompleteNotificationParamsSchema","ElicitRequestSchema","ElicitRequestFormParamsSchema","ElicitRequestParamsSchema","ElicitRequestURLParamsSchema","ElicitResultSchema","EmbeddedResourceSchema","EmptyResultSchema","EnumSchemaSchema","GetPromptRequestSchema","GetPromptRequestParamsSchema","GetPromptResultSchema","GetTaskPayloadRequestSchema","GetTaskPayloadResultSchema","GetTaskRequestSchema","GetTaskResultSchema","IconSchema","IconsSchema","ImageContentSchema","ImplementationSchema","InitializedNotificationSchema","InitializeRequestSchema","InitializeRequestParamsSchema","InitializeResultSchema","JSONArraySchema","JSONObjectSchema","JSONRPCErrorResponseSchema","JSONRPCMessageSchema","JSONRPCNotificationSchema","JSONRPCRequestSchema","JSONRPCResponseSchema","JSONRPCResultResponseSchema","JSONValueSchema","LegacyTitledEnumSchemaSchema","ListPromptsRequestSchema","ListPromptsResultSchema","ListResourcesRequestSchema","ListResourcesResultSchema","ListResourceTemplatesRequestSchema","ListResourceTemplatesResultSchema","ListRootsRequestSchema","ListRootsResultSchema","ListTasksRequestSchema","ListTasksResultSchema","ListToolsRequestSchema","ListToolsResultSchema","LoggingLevelSchema","LoggingMessageNotificationSchema","LoggingMessageNotificationParamsSchema","ModelHintSchema","ModelPreferencesSchema","MultiSelectEnumSchemaSchema","NotificationSchema","NumberSchemaSchema","PaginatedRequestSchema","PaginatedRequestParamsSchema","PaginatedResultSchema","PingRequestSchema","PrimitiveSchemaDefinitionSchema","ProgressSchema","ProgressNotificationSchema","ProgressNotificationParamsSchema","ProgressTokenSchema","PromptSchema","PromptArgumentSchema","PromptListChangedNotificationSchema","PromptMessageSchema","PromptReferenceSchema","ReadResourceRequestSchema","ReadResourceRequestParamsSchema","ReadResourceResultSchema","RelatedTaskMetadataSchema","RequestSchema","RequestIdSchema","RequestMetaSchema","ResourceSchema","ResourceContentsSchema","ResourceLinkSchema","ResourceListChangedNotificationSchema","ResourceRequestParamsSchema","ResourceTemplateSchema","ResourceTemplateReferenceSchema","ResourceUpdatedNotificationSchema","ResourceUpdatedNotificationParamsSchema","ResultMetaObjectSchema","ResultSchema","RoleSchema","RootSchema","RootsListChangedNotificationSchema","SamplingContentSchema","SamplingMessageSchema","SamplingMessageContentBlockSchema","ServerCapabilitiesSchema","ServerNotificationSchema","ServerRequestSchema","ServerResultSchema","SetLevelRequestSchema","SetLevelRequestParamsSchema","SingleSelectEnumSchemaSchema","StringSchemaSchema","SubscribeRequestSchema","SubscribeRequestParamsSchema","SubscriptionFilterSchema","SubscriptionsAcknowledgedNotificationSchema","SubscriptionsAcknowledgedNotificationParamsSchema","SubscriptionsListenRequestSchema","SubscriptionsListenRequestParamsSchema","SubscriptionsListenResultSchema","SubscriptionsListenResultMetaSchema","TaskAugmentedRequestParamsSchema","TaskCreationParamsSchema","TaskMetadataSchema","TaskSchema","TaskStatusSchema","TaskStatusNotificationSchema","TaskStatusNotificationParamsSchema","TextContentSchema","TextResourceContentsSchema","TitledMultiSelectEnumSchemaSchema","TitledSingleSelectEnumSchemaSchema","ToolSchema","ToolAnnotationsSchema","ToolChoiceSchema","ToolExecutionSchema","ToolListChangedNotificationSchema","ToolResultContentSchema","ToolUseContentSchema","UnsubscribeRequestSchema","UnsubscribeRequestParamsSchema","UntitledMultiSelectEnumSchemaSchema","UntitledSingleSelectEnumSchemaSchema"],SS={IdJagTokenExchangeResponseSchema:Ls,OAuthClientInformationFullSchema:Vs,OAuthClientInformationSchema:Ds,OAuthClientMetadataSchema:Zs,OAuthClientRegistrationErrorSchema:fa,OAuthErrorResponseSchema:Us,OAuthMetadataSchema:Jo,OAuthProtectedResourceMetadataSchema:As,OAuthTokenRevocationRequestSchema:ga,OAuthTokensSchema:js,OpenIdProviderDiscoveryMetadataSchema:qs,OpenIdProviderMetadataSchema:Ms},cm={},lm={};function um(e,t){let o=e.slice(0,-6);cm[o]=t,lm[o]=(r)=>t.safeParse(r).success}for(let e of gS)um(e,Xg[e]);for(let[e,t]of Object.entries(SS))um(e,t);var _S=Object.freeze(cm),yS=Object.freeze(lm);function bS(e){switch(e){case"initialize":case"notifications/initialized":return Gs(void 0);case"server/discover":return Gs(Xc);default:return}}var dm=60000,vS=[It,bo,Ot,vo],zS=["inputResponses","requestState"];function Nh(e,t){let o=e.params;if(!Zc(o))return{message:e,lifted:{}};let r=o._meta,n=Zc(r)?vS.filter((d)=>(d in r)):[],i=t==="request"?zS.filter((d)=>(d in o)):[];if(n.length===0&&i.length===0)return{message:e,lifted:{}};let a={},c={...o};if(n.length>0&&Zc(r)){let d={},p={...r};for(let m of n)d[m]=r[m],delete p[m];if(a.envelope=d,Object.keys(p).length>0)c._meta=p;else delete c._meta}for(let d of i){if(d==="inputResponses")a.inputResponses=c[d];if(d==="requestState")a.requestState=c[d];delete c[d]}return{message:{...e,params:c},lifted:a}}function Ah(e,t){let o=e.validateResult(t,void 0);if(!o.ok&&o.reason==="not-in-era")return;return{"~standard":{version:1,vendor:"mcp-wire-codec",validate(r){let n=e.validateResult(t,r);if(n.ok)return{value:n.value};return{issues:[{message:n.reason==="invalid"?n.message:`not-in-era: ${t}`}]}}}}}function pm(e){return()=>e}var wS=pm(void 0),RS,ol=class{_transport;_requestMessageId=0;_requestHandlers=new Map;_customSchemaRequestMethods=new Set;_requestHandlerAbortControllers=new Map;_notificationHandlers=new Map;_responseHandlers=new Map;_progressHandlers=new Map;_timeoutInfo=new Map;_pendingDebouncedNotifications=new Set;_negotiatedProtocolVersion;static{RS=(e,t)=>{e._negotiatedProtocolVersion=t}}_supportedProtocolVersions;onclose;onerror;fallbackRequestHandler;fallbackNotificationHandler;constructor(e){this._options=e,this._supportedProtocolVersions=e?.supportedProtocolVersions??Vi,this.setNotificationHandler("notifications/cancelled",(t)=>{this._oncancel(t)}),this.setNotificationHandler("notifications/progress",(t)=>{this._onprogress(t)}),this.setRequestHandler("ping",(t)=>({}))}_shouldDropInbound(e){}_outboundMetaEnvelope(){}_envelopeOutbound(e){let t=this._outboundMetaEnvelope();if(t===void 0)return e;let o=e.params??{};return{...e,params:{...o,_meta:{...t,...o._meta}}}}_resolveNonCompleteResult(e,t){return Promise.reject(new K(oe.UnsupportedResultType,`Unsupported result type '${e.kind}' for ${t.request.method}`,{resultType:e.kind,method:t.request.method}))}_getRequestHandler(e){return this._requestHandlers.get(e)}async _oncancel(e){if(e.params.requestId===void 0)return;this._requestHandlerAbortControllers.get(e.params.requestId)?.abort(e.params.reason)}_setupTimeout(e,t,o,r,n=!1){this._timeoutInfo.set(e,{timeoutId:setTimeout(r,t),startTime:Date.now(),timeout:t,maxTotalTimeout:o,resetTimeoutOnProgress:n,onTimeout:r})}_resetTimeout(e){let t=this._timeoutInfo.get(e);if(!t)return!1;let o=Date.now()-t.startTime;if(t.maxTotalTimeout&&o>=t.maxTotalTimeout)throw this._timeoutInfo.delete(e),new K(oe.RequestTimeout,"Maximum total timeout exceeded",{maxTotalTimeout:t.maxTotalTimeout,totalElapsed:o});return clearTimeout(t.timeoutId),t.timeoutId=setTimeout(t.onTimeout,t.timeout),!0}_cleanupTimeout(e){let t=this._timeoutInfo.get(e);if(t)clearTimeout(t.timeoutId),this._timeoutInfo.delete(e)}async connect(e){this._transport=e;let t=this.transport?.onclose;this._transport.onclose=()=>{try{t?.()}finally{this._onclose()}};let o=this.transport?.onerror;this._transport.onerror=(n)=>{o?.(n),this._onerror(n)};let r=this._transport?.onmessage;this._transport.onmessage=(n,i)=>{if(r?.(n,i),Hc(n)||im(n))this._onresponse(n);else if(nm(n))this._onrequest(n,i);else if(sm(n))this._onnotification(n,i);else this._onerror(Error(`Unknown message type: ${JSON.stringify(n)}`))},e.setSupportedProtocolVersions?.(this._supportedProtocolVersions),await this._transport.start()}_onclose(){let e=this._responseHandlers;this._responseHandlers=new Map,this._progressHandlers.clear(),this._pendingDebouncedNotifications.clear();for(let r of this._timeoutInfo.values())clearTimeout(r.timeoutId);this._timeoutInfo.clear();let t=this._requestHandlerAbortControllers;this._requestHandlerAbortControllers=new Map;let o=new K(oe.ConnectionClosed,"Connection closed");this._transport=void 0;try{this.onclose?.()}finally{for(let r of e.values())r(o);for(let r of t.values())r.abort(o)}}_onerror(e){this.onerror?.(e)}_onnotification(e,t){let{message:o}=Nh(e,"notification"),r=this._negotiatedWireCodec();if(t?.classification===void 0&&this._shouldDropInbound(e)==="drop")return;if(t?.classification!==void 0){let a=$h(t.classification);if(a!==r.era){this._onerror(Error(`Era mismatch on inbound notification '${o.method}': classified as ${a} but this instance serves ${r.era}`));return}}if(Lc(o.method)&&!r.hasNotificationMethod(o.method))return;let n=this._notificationHandlers.get(o.method),i=this.fallbackNotificationHandler;if(n===void 0&&i===void 0)return;Promise.resolve().then(()=>n===void 0?i(o):n(o,r)).catch((a)=>this._onerror(Error(`Uncaught error in notification handler: ${a}`)))}_onrequest(e,t){let{message:o,lifted:r}=Nh(e,"request"),n=this._negotiatedWireCodec();if(t?.classification===void 0&&this._shouldDropInbound(e)==="drop"){this._onerror(Error(`Dropped inbound request '${e.method}': not servable on this connection's protocol era`));return}let i=this._transport,a=(x,R,C)=>{let N={jsonrpc:"2.0",id:o.id,error:{code:x,message:R,...C!==void 0&&{data:C}}};i?.send(N).catch((I)=>this._onerror(Error(`Failed to send an error response: ${I}`)))};if(t?.classification!==void 0){let x=$h(t.classification);if(x!==n.era){this._onerror(Error(`Era mismatch on inbound request '${o.method}': classified as ${x} but this instance serves ${n.era}`));let R=t.classification.revision??x;a(q.UnsupportedProtocolVersion,`Unsupported protocol version: ${R}`,{supported:this._supportedProtocolVersions,requested:R});return}}if(jc(o.method)&&!n.hasRequestMethod(o.method)&&!(Ch(o.method)&&this._customSchemaRequestMethods.has(o.method))){a(q.MethodNotFound,"Method not found");return}let c=this._requestHandlers.get(o.method)??this.fallbackRequestHandler;if(c===void 0){a(q.MethodNotFound,"Method not found");return}let d=n.checkInboundEnvelope(r);if(d!==void 0){a(q.InvalidParams,d);return}let p=(x,R)=>this._notificationViaCodec(this._resolveOutboundCodec(x.method),x,{...R,relatedRequestId:o.id}),m=(x,R,C)=>this._requestWithSchemaViaCodec(this._resolveOutboundCodec(x.method),x,R,{...C,relatedRequestId:o.id}),f=new AbortController;this._requestHandlerAbortControllers.set(o.id,f);let y=r.inputResponses===void 0?void 0:xS(r.inputResponses),S={sessionId:i?.sessionId,mcpReq:{id:o.id,method:o.method,_meta:o.params?._meta,...r.envelope!==void 0&&{envelope:r.envelope},...y!==void 0&&{inputResponses:y.accepted},...y!==void 0&&y.droppedKeys.length>0&&{droppedInputResponseKeys:y.droppedKeys},requestState:r.requestState===void 0?wS:pm(r.requestState),signal:f.signal,send:(x,R,C)=>{let N=this._resolveOutboundCodec(x.method);if(this._assertOutboundRequestInEra(N,x.method),Fc(R))return m(x,R,C);let I=Ah(N,x.method);if(I===void 0)throw TypeError(`'${x.method}' is not a spec method; pass a result schema as the second argument to ctx.mcpReq.send().`);return m(x,I,R)},notify:p},http:t?.authInfo?{authInfo:t.authInfo}:void 0},w=this.buildContext(S,t);Promise.resolve().then(()=>c(o,w)).then(async(x)=>{if(f.signal.aborted)return;let R;try{R=n.encodeResult(o.method,x,this._outboundServerInfo())}catch(N){this._onerror(Error(`Failed to encode result for ${o.method}: ${N}`)),a(q.InternalError,"Internal error");return}let C={result:R,jsonrpc:"2.0",id:o.id};await i?.send(C)},async(x)=>{if(f.signal.aborted)return;let R=Number.isSafeInteger(x.code)?x.code:q.InternalError,C={jsonrpc:"2.0",id:o.id,error:{code:n.encodeErrorCode(R),message:x.message??"Internal error",...x.data!==void 0&&{data:x.data}}};await i?.send(C)}).catch((x)=>this._onerror(Error(`Failed to send response: ${x}`))).finally(()=>{if(this._requestHandlerAbortControllers.get(o.id)===f)this._requestHandlerAbortControllers.delete(o.id)})}_onprogress(e){let{progressToken:t,...o}=e.params,r=Number(t),n=this._progressHandlers.get(r);if(!n){this._onerror(Error(`Received a progress notification for an unknown token: ${JSON.stringify(e)}`));return}let 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}n(o)}_onresponse(e){let t=Number(e.id),o=this._responseHandlers.get(t);if(o===void 0){this._onerror(Error(`Received a response for an unknown message ID: ${JSON.stringify(e)}`));return}if(this._responseHandlers.delete(t),this._cleanupTimeout(t),this._progressHandlers.delete(t),Hc(e))o(e);else o(re.fromError(e.error.code,e.error.message,e.error.data))}get transport(){return this._transport}async close(){await this._transport?.close()}request(e,t,o){let r=this._resolveOutboundCodec(e.method);if(Fc(t)){if(!Ch(e.method))this._assertOutboundRequestInEra(r,e.method);return this._requestWithSchemaViaCodec(r,e,t,o)}this._assertOutboundRequestInEra(r,e.method);let n=Ah(r,e.method);if(n===void 0)throw TypeError(`'${e.method}' is not a spec method; pass a result schema as the second argument to request().`);return this._requestWithSchemaViaCodec(r,e,n,t)}_negotiatedWireCodec(){return Gs(this._negotiatedProtocolVersion)}_wireCodec(){return this._negotiatedWireCodec()}_resolveOutboundCodec(e){if(this._negotiatedProtocolVersion===void 0){let t=bS(e);if(t)return t}return this._negotiatedWireCodec()}_assertOutboundRequestInEra(e,t){if(jc(t)&&!e.hasRequestMethod(t))throw new K(oe.MethodNotSupportedByProtocolVersion,`Method '${t}' is not supported by the negotiated protocol version (wire era ${e.era})`,{method:t,era:e.era})}_requestWithSchema(e,t,o){let r=this._resolveOutboundCodec(e.method);return this._assertOutboundRequestInEra(r,e.method),this._requestWithSchemaViaCodec(r,e,t,o)}_requestWithSchemaViaCodec(e,t,o,r){let{relatedRequestId:n,resumptionToken:i,onresumptiontoken:a,headers:c}=r??{},d=Date.now(),p,m;return new Promise((f,y)=>{let S=(j)=>{y(j)};if(!this._transport){S(Error("Not connected"));return}if(this._options?.enforceStrictCapabilities===!0)try{this.assertCapabilityForMethod(t.method)}catch(j){S(j);return}if(r?.signal?.aborted){let j=r.signal.reason;throw j instanceof K?j:new K(oe.RequestTimeout,String(j))}let w=e.era===Xc&&this._transport.hasPerRequestStream===!0?new AbortController:void 0,x=this._requestMessageId++;m=x;let R={...t,jsonrpc:"2.0",id:x};if(r?.onprogress)this._progressHandlers.set(x,r.onprogress),R.params={...t.params,_meta:{...t.params?._meta,progressToken:x}};let C=this._envelopeOutbound(R),N=!1,I=(j)=>{if(N)return;if(this._progressHandlers.delete(x),w===void 0){if(t.method!=="initialize")this._transport?.send(this._envelopeOutbound({jsonrpc:"2.0",method:"notifications/cancelled",params:{requestId:x,reason:String(j)}}),{relatedRequestId:n,resumptionToken:i,onresumptiontoken:a}).catch((V)=>this._onerror(Error(`Failed to send cancellation: ${V}`)))}else w.abort();y(j instanceof K?j:new K(oe.RequestTimeout,String(j)))};this._responseHandlers.set(x,(j)=>{if(r?.signal?.aborted)return;if(N=!0,j instanceof Error)return y(j);let V;try{V=e.decodeResult(t.method,j.result)}catch(Y){return y(Y instanceof Error?Y:Error(String(Y)))}if(V.kind==="invalid")return y(V.error);if(V.kind==="input_required"){if(r?.allowInputRequired===!0)return f(PS(V));let Y={codec:e,request:t,resultSchema:o,options:r,flowStartedAt:d,retry:(ge,pt)=>this._requestWithSchemaViaCodec(e,ge===void 0?{method:t.method}:{method:t.method,params:ge},o,pt)};return f(this._resolveNonCompleteResult(V,Y))}let ae=V.result;Uc(o,ae).then((Y)=>{if(Y.success)f(Y.data);else y(new K(oe.InvalidResult,`Invalid result for ${t.method}: ${Y.error}`))},y)}),p=()=>I(r?.signal?.reason),r?.signal?.addEventListener("abort",p,{once:!0});let M=r?.timeout??dm,A=()=>I(new K(oe.RequestTimeout,"Request timed out",{timeout:M}));this._setupTimeout(x,M,r?.maxTotalTimeout,A,r?.resetTimeoutOnProgress??!1),this._transport.send(C,{relatedRequestId:n,resumptionToken:i,onresumptiontoken:a,headers:c,requestSignal:w?.signal}).catch((j)=>{this._progressHandlers.delete(x),y(j)})}).finally(()=>{if(p)r?.signal?.removeEventListener("abort",p);if(m!==void 0)this._responseHandlers.delete(m),this._cleanupTimeout(m)})}async notification(e,t){return await this._notificationViaCodec(this._resolveOutboundCodec(e.method),e,t)}async _notificationViaCodec(e,t,o){if(!this._transport)throw new K(oe.NotConnected,"Not connected");if(Lc(t.method)&&!e.hasNotificationMethod(t.method))throw new K(oe.MethodNotSupportedByProtocolVersion,`Notification '${t.method}' is not supported by the negotiated protocol version (wire era ${e.era})`,{method:t.method,era:e.era});this.assertNotificationCapability(t.method);let r=this._envelopeOutbound({jsonrpc:"2.0",...t});if((this._options?.debouncedNotificationMethods??[]).includes(t.method)&&!t.params&&o?.relatedRequestId===void 0){if(this._pendingDebouncedNotifications.has(t.method))return;this._pendingDebouncedNotifications.add(t.method),Promise.resolve().then(()=>{if(this._pendingDebouncedNotifications.delete(t.method),!this._transport)return;this._transport?.send(r,o).catch((n)=>this._onerror(n))});return}await this._transport.send(r,o)}setRequestHandler(e,t,o){this.assertRequestHandlerCapability(e);let r;if(typeof t==="function"){if(!jc(e))throw TypeError(`'${e}' is not a spec request method; pass schemas as the second argument to setRequestHandler().`);r=(n,i)=>{let a=this._negotiatedWireCodec(),c=a.validateRequest(e,n);if(!c.ok&&c.reason==="not-in-era")c=a.validateInputRequest(e,n);if(!c.ok){if(c.reason==="not-in-era")throw new re(q.InternalError,`No wire schema for ${e} in the resolved era`);throw Error(c.message)}return Promise.resolve(t(c.value,i))}}else if(o)r=async(n,i)=>{let a=await Uc(t.params,{...n.params});if(!a.success)throw new re(q.InvalidParams,`Invalid params for ${e}: ${a.error}`);return o(a.data,i)};else throw TypeError("setRequestHandler: handler is required");if(typeof t==="function")this._customSchemaRequestMethods.delete(e);else this._customSchemaRequestMethods.add(e);this._requestHandlers.set(e,this._wrapHandler(e,r))}_wrapHandler(e,t){return t}_outboundServerInfo(){}removeRequestHandler(e){this._requestHandlers.delete(e),this._customSchemaRequestMethods.delete(e)}assertCanSetRequestHandler(e){if(this._requestHandlers.has(e))throw Error(`A request handler for ${e} already exists, which would be overridden`)}setNotificationHandler(e,t,o){if(typeof t==="function"){if(!Lc(e))throw TypeError(`'${e}' is not a spec notification method; pass schemas as the second argument to setNotificationHandler().`);this._notificationHandlers.set(e,(r,n)=>{let i=n.validateNotification(e,r);if(!i.ok){if(i.reason==="not-in-era")throw new re(q.InternalError,`No wire schema for ${e} in the resolved era`);throw Error(i.message)}return Promise.resolve(t(i.value))});return}if(!o)throw TypeError("setNotificationHandler: handler is required");this._notificationHandlers.set(e,async(r)=>{let n=await Uc(t.params,{...r.params});if(!n.success)throw new re(q.InvalidParams,`Invalid params for notification ${e}: ${n.error}`);await o(n.data,r)})}removeNotificationHandler(e){this._notificationHandlers.delete(e)}};function Zc(e){return e!==null&&typeof e==="object"&&!Array.isArray(e)}function Mh(e){return typeof e==="object"&&e!==null&&!Array.isArray(e)}function xS(e){let t={},o=[];if(!Mh(e))return{accepted:t,droppedKeys:o};for(let[r,n]of Object.entries(e)){if(!Mh(n)||"method"in n||"result"in n){o.push(r);continue}t[r]=n}return{accepted:t,droppedKeys:o}}function PS(e){return{resultType:"input_required",inputRequests:e.inputRequests,...e.requestState!==void 0&&{requestState:e.requestState},...e._meta!==void 0&&{_meta:e._meta}}}/*!
|
|
64
|
+
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let i of e.seen.entries()){let c=i[1];if(t===i[0]){s(i);continue}if(e.external){let u=e.external.registry.get(i[0])?.id;if(t!==i[0]&&u){s(i);continue}}if(e.metadataRegistry.get(i[0])?.id){s(i);continue}if(c.cycle){s(i);continue}if(c.count>1){if(e.reused==="ref"){s(i);continue}}}}function pn(e,t){let o=e.seen.get(t);if(!o)throw Error("Unprocessed schema. This is a bug in Zod.");let r=(c)=>{let l=e.seen.get(c);if(l.ref===null)return;let u=l.def??l.schema,h={...u},m=l.ref;if(l.ref=null,m){r(m);let g=e.seen.get(m),b=g.schema;if(b.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0"))u.allOf=u.allOf??[],u.allOf.push(b);else Object.assign(u,b);if(Object.assign(u,h),c._zod.parent===m)for(let R in u){if(R==="$ref"||R==="allOf")continue;if(!(R in h))delete u[R]}if(b.$ref&&g.def)for(let R in u){if(R==="$ref"||R==="allOf")continue;if(R in g.def&&JSON.stringify(u[R])===JSON.stringify(g.def[R]))delete u[R]}}let S=c._zod.parent;if(S&&S!==m){r(S);let g=e.seen.get(S);if(g?.schema.$ref){if(u.$ref=g.schema.$ref,g.def)for(let b in u){if(b==="$ref"||b==="allOf")continue;if(b in g.def&&JSON.stringify(u[b])===JSON.stringify(g.def[b]))delete u[b]}}}e.override({zodSchema:c,jsonSchema:u,path:l.path??[]})};for(let c of[...e.seen.entries()].reverse())r(c[0]);let n={};if(e.target==="draft-2020-12")n.$schema="https://json-schema.org/draft/2020-12/schema";else if(e.target==="draft-07")n.$schema="http://json-schema.org/draft-07/schema#";else if(e.target==="draft-04")n.$schema="http://json-schema.org/draft-04/schema#";else if(e.target==="openapi-3.0");if(e.external?.uri){let c=e.external.registry.get(t)?.id;if(!c)throw Error("Schema is missing an `id` property");n.$id=e.external.uri(c)}Object.assign(n,o.def??o.schema);let s=e.metadataRegistry.get(t)?.id;if(s!==void 0&&n.id===s)delete n.id;let i=e.external?.defs??{};for(let c of e.seen.entries()){let l=c[1];if(l.def&&l.defId){if(l.def.id===l.defId)delete l.def.id;i[l.defId]=l.def}}if(e.external);else if(Object.keys(i).length>0)if(e.target==="draft-2020-12")n.$defs=i;else n.definitions=i;try{let c=JSON.parse(JSON.stringify(n));return Object.defineProperty(c,"~standard",{value:{...t["~standard"],jsonSchema:{input:ln(t,"input",e.processors),output:ln(t,"output",e.processors)}},enumerable:!1,writable:!1}),c}catch(c){throw Error("Error converting schema to JSON.")}}function xe(e,t){let o=t??{seen:new Set};if(o.seen.has(e))return!1;o.seen.add(e);let r=e._zod.def;if(r.type==="transform")return!0;if(r.type==="array")return xe(r.element,o);if(r.type==="set")return xe(r.valueType,o);if(r.type==="lazy")return xe(r.getter(),o);if(r.type==="promise"||r.type==="optional"||r.type==="nonoptional"||r.type==="nullable"||r.type==="readonly"||r.type==="default"||r.type==="prefault")return xe(r.innerType,o);if(r.type==="intersection")return xe(r.left,o)||xe(r.right,o);if(r.type==="record"||r.type==="map")return xe(r.keyType,o)||xe(r.valueType,o);if(r.type==="pipe"){if(e._zod.traits.has("$ZodCodec"))return!0;return xe(r.in,o)||xe(r.out,o)}if(r.type==="object"){for(let n in r.shape)if(xe(r.shape[n],o))return!0;return!1}if(r.type==="union"){for(let n of r.options)if(xe(n,o))return!0;return!1}if(r.type==="tuple"){for(let n of r.items)if(xe(n,o))return!0;if(r.rest&&xe(r.rest,o))return!0;return!1}return!1}var Wp=(e,t={})=>(o)=>{let r=un({...o,processors:t});return X(e,r),dn(r,e),pn(r,e)},ln=(e,t,o={})=>(r)=>{let{libraryOptions:n,target:s}=r??{},i=un({...n??{},target:s,io:t,processors:o});return X(e,i),dn(i,e),pn(i,e)};var rg={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},Pc=(e,t,o,r)=>{let n=o;n.type="string";let{minimum:s,maximum:i,format:c,patterns:l,contentEncoding:u}=e._zod.bag;if(typeof s==="number")n.minLength=s;if(typeof i==="number")n.maxLength=i;if(c){if(n.format=rg[c]??c,n.format==="")delete n.format;if(c==="time")delete n.format}if(u)n.contentEncoding=u;if(l&&l.size>0){let h=[...l];if(h.length===1)n.pattern=h[0].source;else if(h.length>1)n.allOf=[...h.map((m)=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:m.source}))]}},Tc=(e,t,o,r)=>{let n=o,{minimum:s,maximum:i,format:c,multipleOf:l,exclusiveMaximum:u,exclusiveMinimum:h}=e._zod.bag;if(typeof c==="string"&&c.includes("int"))n.type="integer";else n.type="number";let m=typeof h==="number"&&h>=(s??Number.NEGATIVE_INFINITY),S=typeof u==="number"&&u<=(i??Number.POSITIVE_INFINITY),g=t.target==="draft-04"||t.target==="openapi-3.0";if(m)if(g)n.minimum=h,n.exclusiveMinimum=!0;else n.exclusiveMinimum=h;else if(typeof s==="number")n.minimum=s;if(S)if(g)n.maximum=u,n.exclusiveMaximum=!0;else n.exclusiveMaximum=u;else if(typeof i==="number")n.maximum=i;if(typeof l==="number")n.multipleOf=l},Ec=(e,t,o,r)=>{o.type="boolean"},Yp=(e,t,o,r)=>{if(t.unrepresentable==="throw")throw Error("BigInt cannot be represented in JSON Schema")},Qp=(e,t,o,r)=>{if(t.unrepresentable==="throw")throw Error("Symbols cannot be represented in JSON Schema")},kc=(e,t,o,r)=>{if(t.target==="openapi-3.0")o.type="string",o.nullable=!0,o.enum=[null];else o.type="null"},$c=(e,t,o,r)=>{if(t.unrepresentable==="throw")throw Error("Undefined cannot be represented in JSON Schema")},Xp=(e,t,o,r)=>{if(t.unrepresentable==="throw")throw Error("Void cannot be represented in JSON Schema")},Cc=(e,t,o,r)=>{o.not={}},Ic=(e,t,o,r)=>{},Oc=(e,t,o,r)=>{},eh=(e,t,o,r)=>{if(t.unrepresentable==="throw")throw Error("Date cannot be represented in JSON Schema")},Nc=(e,t,o,r)=>{let n=e._zod.def,s=Ai(n.entries);if(s.every((i)=>typeof i==="number"))o.type="number";if(s.every((i)=>typeof i==="string"))o.type="string";o.enum=s},Ac=(e,t,o,r)=>{let n=e._zod.def,s=[];for(let i of n.values)if(i===void 0){if(t.unrepresentable==="throw")throw Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof i==="bigint")if(t.unrepresentable==="throw")throw Error("BigInt literals cannot be represented in JSON Schema");else s.push(Number(i));else s.push(i);if(s.length===0);else if(s.length===1){let i=s[0];if(o.type=i===null?"null":typeof i,t.target==="draft-04"||t.target==="openapi-3.0")o.enum=[i];else o.const=i}else{if(s.every((i)=>typeof i==="number"))o.type="number";if(s.every((i)=>typeof i==="string"))o.type="string";if(s.every((i)=>typeof i==="boolean"))o.type="boolean";if(s.every((i)=>i===null))o.type="null";o.enum=s}},th=(e,t,o,r)=>{if(t.unrepresentable==="throw")throw Error("NaN cannot be represented in JSON Schema")},oh=(e,t,o,r)=>{let n=o,s=e._zod.pattern;if(!s)throw Error("Pattern not found in template literal");n.type="string",n.pattern=s.source},rh=(e,t,o,r)=>{let n=o,s={type:"string",format:"binary",contentEncoding:"binary"},{minimum:i,maximum:c,mime:l}=e._zod.bag;if(i!==void 0)s.minLength=i;if(c!==void 0)s.maxLength=c;if(l)if(l.length===1)s.contentMediaType=l[0],Object.assign(n,s);else Object.assign(n,s),n.anyOf=l.map((u)=>({contentMediaType:u}));else Object.assign(n,s)},nh=(e,t,o,r)=>{o.type="boolean"},Mc=(e,t,o,r)=>{if(t.unrepresentable==="throw")throw Error("Custom types cannot be represented in JSON Schema")},sh=(e,t,o,r)=>{if(t.unrepresentable==="throw")throw Error("Function types cannot be represented in JSON Schema")},qc=(e,t,o,r)=>{if(t.unrepresentable==="throw")throw Error("Transforms cannot be represented in JSON Schema")},ih=(e,t,o,r)=>{if(t.unrepresentable==="throw")throw Error("Map cannot be represented in JSON Schema")},ah=(e,t,o,r)=>{if(t.unrepresentable==="throw")throw Error("Set cannot be represented in JSON Schema")},jc=(e,t,o,r)=>{let n=o,s=e._zod.def,{minimum:i,maximum:c}=e._zod.bag;if(typeof i==="number")n.minItems=i;if(typeof c==="number")n.maxItems=c;n.type="array",n.items=X(s.element,t,{...r,path:[...r.path,"items"]})},Lc=(e,t,o,r)=>{let n=o,s=e._zod.def;n.type="object",n.properties={};let i=s.shape;for(let u in i)n.properties[u]=X(i[u],t,{...r,path:[...r.path,"properties",u]});let c=new Set(Object.keys(i)),l=new Set([...c].filter((u)=>{let h=s.shape[u]._zod;if(t.io==="input")return h.optin===void 0;else return h.optout===void 0}));if(l.size>0)n.required=Array.from(l);if(s.catchall?._zod.def.type==="never")n.additionalProperties=!1;else if(!s.catchall){if(t.io==="output")n.additionalProperties=!1}else if(s.catchall)n.additionalProperties=X(s.catchall,t,{...r,path:[...r.path,"additionalProperties"]})},Uc=(e,t,o,r)=>{let n=e._zod.def,s=n.inclusive===!1,i=n.options.map((c,l)=>X(c,t,{...r,path:[...r.path,s?"oneOf":"anyOf",l]}));if(s)o.oneOf=i;else o.anyOf=i},Zc=(e,t,o,r)=>{let n=e._zod.def,s=X(n.left,t,{...r,path:[...r.path,"allOf",0]}),i=X(n.right,t,{...r,path:[...r.path,"allOf",1]}),c=(u)=>("allOf"in u)&&Object.keys(u).length===1,l=[...c(s)?s.allOf:[s],...c(i)?i.allOf:[i]];o.allOf=l},ch=(e,t,o,r)=>{let n=o,s=e._zod.def;n.type="array";let i=t.target==="draft-2020-12"?"prefixItems":"items",c=t.target==="draft-2020-12"?"items":t.target==="openapi-3.0"?"items":"additionalItems",l=s.items.map((S,g)=>X(S,t,{...r,path:[...r.path,i,g]})),u=s.rest?X(s.rest,t,{...r,path:[...r.path,c,...t.target==="openapi-3.0"?[s.items.length]:[]]}):null;if(t.target==="draft-2020-12"){if(n.prefixItems=l,u)n.items=u}else if(t.target==="openapi-3.0"){if(n.items={anyOf:l},u)n.items.anyOf.push(u);if(n.minItems=l.length,!u)n.maxItems=l.length}else if(n.items=l,u)n.additionalItems=u;let{minimum:h,maximum:m}=e._zod.bag;if(typeof h==="number")n.minItems=h;if(typeof m==="number")n.maxItems=m},Dc=(e,t,o,r)=>{let n=o,s=e._zod.def;n.type="object";let i=s.keyType,l=i._zod.bag?.patterns;if(s.mode==="loose"&&l&&l.size>0){let h=X(s.valueType,t,{...r,path:[...r.path,"patternProperties","*"]});n.patternProperties={};for(let m of l)n.patternProperties[m.source]=h}else{if(t.target==="draft-07"||t.target==="draft-2020-12")n.propertyNames=X(s.keyType,t,{...r,path:[...r.path,"propertyNames"]});n.additionalProperties=X(s.valueType,t,{...r,path:[...r.path,"additionalProperties"]})}let u=i._zod.values;if(u){let h=[...u].filter((m)=>typeof m==="string"||typeof m==="number");if(h.length>0)n.required=h}},Vc=(e,t,o,r)=>{let n=e._zod.def,s=X(n.innerType,t,r),i=t.seen.get(e);if(t.target==="openapi-3.0")i.ref=n.innerType,o.nullable=!0;else o.anyOf=[s,{type:"null"}]},Hc=(e,t,o,r)=>{let n=e._zod.def;X(n.innerType,t,r);let s=t.seen.get(e);s.ref=n.innerType},Fc=(e,t,o,r)=>{let n=e._zod.def;X(n.innerType,t,r);let s=t.seen.get(e);s.ref=n.innerType,o.default=JSON.parse(JSON.stringify(n.defaultValue))},Jc=(e,t,o,r)=>{let n=e._zod.def;X(n.innerType,t,r);let s=t.seen.get(e);if(s.ref=n.innerType,t.io==="input")o._prefault=JSON.parse(JSON.stringify(n.defaultValue))},Bc=(e,t,o,r)=>{let n=e._zod.def;X(n.innerType,t,r);let s=t.seen.get(e);s.ref=n.innerType;let i;try{i=n.catchValue(void 0)}catch{throw Error("Dynamic catch values are not supported in JSON Schema")}o.default=i},Gc=(e,t,o,r)=>{let n=e._zod.def,s=n.in._zod.traits.has("$ZodTransform"),i=t.io==="input"?s?n.out:n.in:n.out;X(i,t,r);let c=t.seen.get(e);c.ref=i},Wc=(e,t,o,r)=>{let n=e._zod.def;X(n.innerType,t,r);let s=t.seen.get(e);s.ref=n.innerType,o.readOnly=!0},lh=(e,t,o,r)=>{let n=e._zod.def;X(n.innerType,t,r);let s=t.seen.get(e);s.ref=n.innerType},Ki=(e,t,o,r)=>{let n=e._zod.def;X(n.innerType,t,r);let s=t.seen.get(e);s.ref=n.innerType},Kc=(e,t,o,r)=>{let n=e._zod.innerType;X(n,t,r);let s=t.seen.get(e);s.ref=n},Kp={string:Pc,number:Tc,boolean:Ec,bigint:Yp,symbol:Qp,null:kc,undefined:$c,void:Xp,never:Cc,any:Ic,unknown:Oc,date:eh,enum:Nc,literal:Ac,nan:th,template_literal:oh,file:rh,success:nh,custom:Mc,function:sh,transform:qc,map:ih,set:ah,array:jc,object:Lc,union:Uc,intersection:Zc,tuple:ch,record:Dc,nullable:Vc,nonoptional:Hc,default:Fc,prefault:Jc,catch:Bc,pipe:Gc,readonly:Wc,promise:lh,optional:Ki,lazy:Kc};function Yi(e,t){if("_idmap"in e){let r=e,n=un({...t,processors:Kp}),s={};for(let l of r._idmap.entries()){let[u,h]=l;X(h,n)}let i={},c={registry:r,uri:t?.uri,defs:s};n.external=c;for(let l of r._idmap.entries()){let[u,h]=l;dn(n,h),i[u]=pn(n,h)}if(Object.keys(s).length>0){let l=n.target==="draft-2020-12"?"$defs":"definitions";i.__shared={[l]:s}}return{schemas:i}}let o=un({...t,processors:Kp});return X(e,o),dn(o,e),pn(o,e)}var dg=_("ZodISODateTime",(e,t)=>{wd.init(e,t),re.init(e,t)});function Fo(e){return Op(dg,e)}var pg=_("ZodISODate",(e,t)=>{xd.init(e,t),re.init(e,t)});function Yc(e){return Np(pg,e)}var hg=_("ZodISOTime",(e,t)=>{Pd.init(e,t),re.init(e,t)});function uh(e){return Ap(hg,e)}var mg=_("ZodISODuration",(e,t)=>{Td.init(e,t),re.init(e,t)});function dh(e){return Mp(mg,e)}var fg=(e,t)=>{Li.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:(o)=>Xa(e,o)},flatten:{value:(o)=>Qa(e,o)},addIssue:{value:(o)=>{e.issues.push(o),e.message=JSON.stringify(e.issues,en,2)}},addIssues:{value:(o)=>{e.issues.push(...o),e.message=JSON.stringify(e.issues,en,2)}},isEmpty:{get(){return e.issues.length===0}}})};var Ae=_("ZodError",fg,{Parent:Error});var hh=Ui(Ae),mh=Zi(Ae),Xi=on(Ae),fh=rn(Ae),gh=au(Ae),Sh=cu(Ae),_h=lu(Ae),yh=uu(Ae),bh=du(Ae),vh=pu(Ae),zh=hu(Ae),Rh=mu(Ae);var wh=new WeakMap;function hn(e,t,o){let r=Object.getPrototypeOf(e),n=wh.get(r);if(!n)n=new Set,wh.set(r,n);if(n.has(t))return;n.add(t);for(let s in o){let i=o[s];Object.defineProperty(r,s,{configurable:!0,enumerable:!1,get(){let c=i.bind(this);return Object.defineProperty(this,s,{configurable:!0,writable:!0,enumerable:!0,value:c}),c},set(c){Object.defineProperty(this,s,{configurable:!0,writable:!0,enumerable:!0,value:c})}})}}var ee=_("ZodType",(e,t)=>(Q.init(e,t),Object.assign(e["~standard"],{jsonSchema:{input:ln(e,"input"),output:ln(e,"output")}}),e.toJSONSchema=Wp(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.parse=(o,r)=>hh(e,o,r,{callee:e.parse}),e.safeParse=(o,r)=>Xi(e,o,r),e.parseAsync=async(o,r)=>mh(e,o,r,{callee:e.parseAsync}),e.safeParseAsync=async(o,r)=>fh(e,o,r),e.spa=e.safeParseAsync,e.encode=(o,r)=>gh(e,o,r),e.decode=(o,r)=>Sh(e,o,r),e.encodeAsync=async(o,r)=>_h(e,o,r),e.decodeAsync=async(o,r)=>yh(e,o,r),e.safeEncode=(o,r)=>bh(e,o,r),e.safeDecode=(o,r)=>vh(e,o,r),e.safeEncodeAsync=async(o,r)=>zh(e,o,r),e.safeDecodeAsync=async(o,r)=>Rh(e,o,r),hn(e,"ZodType",{check(...o){let r=this.def;return this.clone(Ot(r,{checks:[...r.checks??[],...o.map((n)=>typeof n==="function"?{_zod:{check:n,def:{check:"custom"},onattach:[]}}:n)]}),{parent:!0})},with(...o){return this.check(...o)},clone(o,r){return Je(this,o,r)},brand(){return this},register(o,r){return o.add(this,r),this},refine(o,r){return this.check(nS(o,r))},superRefine(o,r){return this.check(sS(o,r))},overwrite(o){return this.check(qt(o))},optional(){return M(this)},exactOptional(){return Hg(this)},nullable(){return Eh(this)},nullish(){return M(Eh(this))},nonoptional(o){return Kg(this,o)},array(){return f(this)},or(o){return x([this,o])},and(o){return St(this,o)},transform(o){return kh(this,jh(o))},default(o){return Bg(this,o)},prefault(o){return Wg(this,o)},catch(o){return Qg(this,o)},pipe(o){return kh(this,o)},readonly(){return tS(this)},describe(o){let r=this.clone();return Mt.add(r,{description:o}),r},meta(...o){if(o.length===0)return Mt.get(this);let r=this.clone();return Mt.add(r,o[0]),r},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(o){return o(this)}}),Object.defineProperty(e,"description",{get(){return Mt.get(e)?.description},configurable:!0}),e)),$h=_("_ZodString",(e,t)=>{Hi.init(e,t),ee.init(e,t),e._zod.processJSONSchema=(r,n,s)=>Pc(e,r,n,s);let o=e._zod.bag;e.format=o.format??null,e.minLength=o.minimum??null,e.maxLength=o.maximum??null,hn(e,"_ZodString",{regex(...r){return this.check(fc(...r))},includes(...r){return this.check(_c(...r))},startsWith(...r){return this.check(yc(...r))},endsWith(...r){return this.check(bc(...r))},min(...r){return this.check(Vo(...r))},max(...r){return this.check(Gi(...r))},length(...r){return this.check(Wi(...r))},nonempty(...r){return this.check(Vo(1,...r))},lowercase(r){return this.check(gc(r))},uppercase(r){return this.check(Sc(r))},trim(){return this.check(zc())},normalize(...r){return this.check(vc(...r))},toLowerCase(){return this.check(Rc())},toUpperCase(){return this.check(wc())},slugify(){return this.check(xc())}})}),Ch=_("ZodString",(e,t)=>{Hi.init(e,t),$h.init(e,t),e.email=(o)=>e.check(pc(Ih,o)),e.url=(o)=>e.check(mc(Nh,o)),e.jwt=(o)=>e.check(Ip(Cg,o)),e.emoji=(o)=>e.check(_p(Sg,o)),e.guid=(o)=>e.check(hc(xh,o)),e.uuid=(o)=>e.check(mp(ea,o)),e.uuidv4=(o)=>e.check(fp(ea,o)),e.uuidv6=(o)=>e.check(gp(ea,o)),e.uuidv7=(o)=>e.check(Sp(ea,o)),e.nanoid=(o)=>e.check(yp(_g,o)),e.guid=(o)=>e.check(hc(xh,o)),e.cuid=(o)=>e.check(bp(yg,o)),e.cuid2=(o)=>e.check(vp(bg,o)),e.ulid=(o)=>e.check(zp(vg,o)),e.base64=(o)=>e.check(kp(Eg,o)),e.base64url=(o)=>e.check($p(kg,o)),e.xid=(o)=>e.check(Rp(zg,o)),e.ksuid=(o)=>e.check(wp(Rg,o)),e.ipv4=(o)=>e.check(xp(wg,o)),e.ipv6=(o)=>e.check(Pp(xg,o)),e.cidrv4=(o)=>e.check(Tp(Pg,o)),e.cidrv6=(o)=>e.check(Ep(Tg,o)),e.e164=(o)=>e.check(Cp($g,o)),e.datetime=(o)=>e.check(Fo(o)),e.date=(o)=>e.check(Yc(o)),e.time=(o)=>e.check(uh(o)),e.duration=(o)=>e.check(dh(o))});function a(e){return hp(Ch,e)}var re=_("ZodStringFormat",(e,t)=>{te.init(e,t),$h.init(e,t)}),Ih=_("ZodEmail",(e,t)=>{fd.init(e,t),re.init(e,t)});function Oh(e){return pc(Ih,e)}var xh=_("ZodGUID",(e,t)=>{hd.init(e,t),re.init(e,t)});var ea=_("ZodUUID",(e,t)=>{md.init(e,t),re.init(e,t)});var Nh=_("ZodURL",(e,t)=>{gd.init(e,t),re.init(e,t)});function ta(e){return mc(Nh,e)}var Sg=_("ZodEmoji",(e,t)=>{Sd.init(e,t),re.init(e,t)});var _g=_("ZodNanoID",(e,t)=>{_d.init(e,t),re.init(e,t)});var yg=_("ZodCUID",(e,t)=>{yd.init(e,t),re.init(e,t)});var bg=_("ZodCUID2",(e,t)=>{bd.init(e,t),re.init(e,t)});var vg=_("ZodULID",(e,t)=>{vd.init(e,t),re.init(e,t)});var zg=_("ZodXID",(e,t)=>{zd.init(e,t),re.init(e,t)});var Rg=_("ZodKSUID",(e,t)=>{Rd.init(e,t),re.init(e,t)});var wg=_("ZodIPv4",(e,t)=>{Ed.init(e,t),re.init(e,t)});var xg=_("ZodIPv6",(e,t)=>{kd.init(e,t),re.init(e,t)});var Pg=_("ZodCIDRv4",(e,t)=>{$d.init(e,t),re.init(e,t)});var Tg=_("ZodCIDRv6",(e,t)=>{Cd.init(e,t),re.init(e,t)});var Eg=_("ZodBase64",(e,t)=>{Od.init(e,t),re.init(e,t)});var kg=_("ZodBase64URL",(e,t)=>{Nd.init(e,t),re.init(e,t)});var $g=_("ZodE164",(e,t)=>{Ad.init(e,t),re.init(e,t)});var Cg=_("ZodJWT",(e,t)=>{Md.init(e,t),re.init(e,t)});var oa=_("ZodNumber",(e,t)=>{ac.init(e,t),ee.init(e,t),e._zod.processJSONSchema=(r,n,s)=>Tc(e,r,n,s),hn(e,"ZodNumber",{gt(r,n){return this.check(Ji(r,n))},gte(r,n){return this.check(cn(r,n))},min(r,n){return this.check(cn(r,n))},lt(r,n){return this.check(Fi(r,n))},lte(r,n){return this.check(an(r,n))},max(r,n){return this.check(an(r,n))},int(r){return this.check(Ph(r))},safe(r){return this.check(Ph(r))},positive(r){return this.check(Ji(0,r))},nonnegative(r){return this.check(cn(0,r))},negative(r){return this.check(Fi(0,r))},nonpositive(r){return this.check(an(0,r))},multipleOf(r,n){return this.check(Bi(r,n))},step(r,n){return this.check(Bi(r,n))},finite(){return this}});let o=e._zod.bag;e.minValue=Math.max(o.minimum??Number.NEGATIVE_INFINITY,o.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,e.maxValue=Math.min(o.maximum??Number.POSITIVE_INFINITY,o.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,e.isInt=(o.format??"").includes("int")||Number.isSafeInteger(o.multipleOf??0.5),e.isFinite=!0,e.format=o.format??null});function y(e){return qp(oa,e)}var Ig=_("ZodNumberFormat",(e,t)=>{qd.init(e,t),oa.init(e,t)});function Ph(e){return Lp(Ig,e)}var Ah=_("ZodBoolean",(e,t)=>{jd.init(e,t),ee.init(e,t),e._zod.processJSONSchema=(o,r,n)=>Ec(e,o,r,n)});function w(e){return Up(Ah,e)}var Og=_("ZodUndefined",(e,t)=>{Ld.init(e,t),ee.init(e,t),e._zod.processJSONSchema=(o,r,n)=>$c(e,o,r,n)});function Xc(e){return Zp(Og,e)}var Ng=_("ZodNull",(e,t)=>{Ud.init(e,t),ee.init(e,t),e._zod.processJSONSchema=(o,r,n)=>kc(e,o,r,n)});function lo(e){return Dp(Ng,e)}var Ag=_("ZodAny",(e,t)=>{Zd.init(e,t),ee.init(e,t),e._zod.processJSONSchema=(o,r,n)=>Ic(e,o,r,n)});function ra(){return Vp(Ag)}var Mg=_("ZodUnknown",(e,t)=>{Dd.init(e,t),ee.init(e,t),e._zod.processJSONSchema=(o,r,n)=>Oc(e,o,r,n)});function O(){return Hp(Mg)}var qg=_("ZodNever",(e,t)=>{Vd.init(e,t),ee.init(e,t),e._zod.processJSONSchema=(o,r,n)=>Cc(e,o,r,n)});function el(e){return Fp(qg,e)}var jg=_("ZodArray",(e,t)=>{Hd.init(e,t),ee.init(e,t),e._zod.processJSONSchema=(o,r,n)=>jc(e,o,r,n),e.element=t.element,hn(e,"ZodArray",{min(o,r){return this.check(Vo(o,r))},nonempty(o){return this.check(Vo(1,o))},max(o,r){return this.check(Gi(o,r))},length(o,r){return this.check(Wi(o,r))},unwrap(){return this.element}})});function f(e,t){return Jp(jg,e,t)}var Mh=_("ZodObject",(e,t)=>{Bd.init(e,t),ee.init(e,t),e._zod.processJSONSchema=(o,r,n)=>Lc(e,o,r,n),W(e,"shape",()=>t.shape),hn(e,"ZodObject",{keyof(){return F(Object.keys(this._zod.def.shape))},catchall(o){return this.clone({...this._zod.def,catchall:o})},passthrough(){return this.clone({...this._zod.def,catchall:O()})},loose(){return this.clone({...this._zod.def,catchall:O()})},strict(){return this.clone({...this._zod.def,catchall:el()})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(o){return Vf(this,o)},safeExtend(o){return Hf(this,o)},merge(o){return Ff(this,o)},pick(o){return Zf(this,o)},omit(o){return Df(this,o)},partial(...o){return Jf(Lh,this,o[0])},required(...o){return Bf(Uh,this,o[0])}})});function d(e,t){let o={type:"object",shape:e??{},...N(t)};return new Mh(o)}function j(e,t){return new Mh({type:"object",shape:e,catchall:O(),...N(t)})}var qh=_("ZodUnion",(e,t)=>{cc.init(e,t),ee.init(e,t),e._zod.processJSONSchema=(o,r,n)=>Uc(e,o,r,n),e.options=t.options});function x(e,t){return new qh({type:"union",options:e,...N(t)})}var Lg=_("ZodDiscriminatedUnion",(e,t)=>{qh.init(e,t),Gd.init(e,t)});function Jo(e,t,o){return new Lg({type:"union",options:t,discriminator:e,...N(o)})}var Ug=_("ZodIntersection",(e,t)=>{Wd.init(e,t),ee.init(e,t),e._zod.processJSONSchema=(o,r,n)=>Zc(e,o,r,n)});function St(e,t){return new Ug({type:"intersection",left:e,right:t})}var Th=_("ZodRecord",(e,t)=>{Kd.init(e,t),ee.init(e,t),e._zod.processJSONSchema=(o,r,n)=>Dc(e,o,r,n),e.keyType=t.keyType,e.valueType=t.valueType});function z(e,t,o){if(!t||!t._zod)return new Th({type:"record",keyType:a(),valueType:e,...N(t)});return new Th({type:"record",keyType:e,valueType:t,...N(o)})}var Qc=_("ZodEnum",(e,t)=>{Yd.init(e,t),ee.init(e,t),e._zod.processJSONSchema=(r,n,s)=>Nc(e,r,n,s),e.enum=t.entries,e.options=Object.values(t.entries);let o=new Set(Object.keys(t.entries));e.extract=(r,n)=>{let s={};for(let i of r)if(o.has(i))s[i]=t.entries[i];else throw Error(`Key ${i} not found in enum`);return new Qc({...t,checks:[],...N(n),entries:s})},e.exclude=(r,n)=>{let s={...t.entries};for(let i of r)if(o.has(i))delete s[i];else throw Error(`Key ${i} not found in enum`);return new Qc({...t,checks:[],...N(n),entries:s})}});function F(e,t){let o=Array.isArray(e)?Object.fromEntries(e.map((r)=>[r,r])):e;return new Qc({type:"enum",entries:o,...N(t)})}var Zg=_("ZodLiteral",(e,t)=>{Qd.init(e,t),ee.init(e,t),e._zod.processJSONSchema=(o,r,n)=>Ac(e,o,r,n),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function p(e,t){return new Zg({type:"literal",values:Array.isArray(e)?e:[e],...N(t)})}var Dg=_("ZodTransform",(e,t)=>{Xd.init(e,t),ee.init(e,t),e._zod.processJSONSchema=(o,r,n)=>qc(e,o,r,n),e._zod.parse=(o,r)=>{if(r.direction==="backward")throw new Xr(e.constructor.name);o.addIssue=(s)=>{if(typeof s==="string")o.issues.push(co(s,o.value,t));else{let i=s;if(i.fatal)i.continue=!1;i.code??(i.code="custom"),i.input??(i.input=o.value),i.inst??(i.inst=e),o.issues.push(co(i))}};let n=t.transform(o.value,o);if(n instanceof Promise)return n.then((s)=>(o.value=s,o.fallback=!0,o));return o.value=n,o.fallback=!0,o}});function jh(e){return new Dg({type:"transform",transform:e})}var Lh=_("ZodOptional",(e,t)=>{lc.init(e,t),ee.init(e,t),e._zod.processJSONSchema=(o,r,n)=>Ki(e,o,r,n),e.unwrap=()=>e._zod.def.innerType});function M(e){return new Lh({type:"optional",innerType:e})}var Vg=_("ZodExactOptional",(e,t)=>{ep.init(e,t),ee.init(e,t),e._zod.processJSONSchema=(o,r,n)=>Ki(e,o,r,n),e.unwrap=()=>e._zod.def.innerType});function Hg(e){return new Vg({type:"optional",innerType:e})}var Fg=_("ZodNullable",(e,t)=>{tp.init(e,t),ee.init(e,t),e._zod.processJSONSchema=(o,r,n)=>Vc(e,o,r,n),e.unwrap=()=>e._zod.def.innerType});function Eh(e){return new Fg({type:"nullable",innerType:e})}var Jg=_("ZodDefault",(e,t)=>{op.init(e,t),ee.init(e,t),e._zod.processJSONSchema=(o,r,n)=>Fc(e,o,r,n),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function Bg(e,t){return new Jg({type:"default",innerType:e,get defaultValue(){return typeof t==="function"?t():Wa(t)}})}var Gg=_("ZodPrefault",(e,t)=>{rp.init(e,t),ee.init(e,t),e._zod.processJSONSchema=(o,r,n)=>Jc(e,o,r,n),e.unwrap=()=>e._zod.def.innerType});function Wg(e,t){return new Gg({type:"prefault",innerType:e,get defaultValue(){return typeof t==="function"?t():Wa(t)}})}var Uh=_("ZodNonOptional",(e,t)=>{np.init(e,t),ee.init(e,t),e._zod.processJSONSchema=(o,r,n)=>Hc(e,o,r,n),e.unwrap=()=>e._zod.def.innerType});function Kg(e,t){return new Uh({type:"nonoptional",innerType:e,...N(t)})}var Yg=_("ZodCatch",(e,t)=>{sp.init(e,t),ee.init(e,t),e._zod.processJSONSchema=(o,r,n)=>Bc(e,o,r,n),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function Qg(e,t){return new Yg({type:"catch",innerType:e,catchValue:typeof t==="function"?t:()=>t})}var Zh=_("ZodPipe",(e,t)=>{uc.init(e,t),ee.init(e,t),e._zod.processJSONSchema=(o,r,n)=>Gc(e,o,r,n),e.in=t.in,e.out=t.out});function kh(e,t){return new Zh({type:"pipe",in:e,out:t})}var Xg=_("ZodPreprocess",(e,t)=>{Zh.init(e,t),ip.init(e,t)}),eS=_("ZodReadonly",(e,t)=>{ap.init(e,t),ee.init(e,t),e._zod.processJSONSchema=(o,r,n)=>Wc(e,o,r,n),e.unwrap=()=>e._zod.def.innerType});function tS(e){return new eS({type:"readonly",innerType:e})}var oS=_("ZodLazy",(e,t)=>{cp.init(e,t),ee.init(e,t),e._zod.processJSONSchema=(o,r,n)=>Kc(e,o,r,n),e.unwrap=()=>e._zod.def.getter()});function mn(e){return new oS({type:"lazy",getter:e})}var rS=_("ZodCustom",(e,t)=>{lp.init(e,t),ee.init(e,t),e._zod.processJSONSchema=(o,r,n)=>Mc(e,o,r,n)});function nS(e,t={}){return Bp(rS,e,t)}function sS(e,t){return Gp(e,t)}function uo(e,t){return new Xg({type:"pipe",in:jh(e),out:t})}var Vh={invalid_type:"invalid_type",too_big:"too_big",too_small:"too_small",invalid_format:"invalid_format",not_multiple_of:"not_multiple_of",unrecognized_keys:"unrecognized_keys",invalid_union:"invalid_union",invalid_key:"invalid_key",invalid_element:"invalid_element",invalid_value:"invalid_value",custom:"custom"};var Dh;(function(e){})(Dh||(Dh={}));function iS(e){return jp(oa,e)}we(dc());var fn="2025-11-25";var na=[fn,"2025-06-18","2025-03-26","2024-11-05","2024-10-07"],sa="io.modelcontextprotocol/related-task",po="io.modelcontextprotocol/protocolVersion",Bo="io.modelcontextprotocol/clientInfo",ct="io.modelcontextprotocol/serverInfo",ho="io.modelcontextprotocol/clientCapabilities",Go="io.modelcontextprotocol/subscriptionId",Wo="io.modelcontextprotocol/logLevel";var mo="2.0";var _t=mn(()=>x([a(),y(),w(),lo(),z(a(),_t),f(_t)])),ne=z(a(),_t),ia=f(_t),Ko=x([a(),y().int()]),Yo=a(),gn=d({ttl:y().optional()}),Sn=d({taskId:a()}),Qo=j({progressToken:Ko.optional(),[sa]:Sn.optional()}),de=d({_meta:Qo.optional()}),Lt=de.extend({task:gn.optional()}),se=d({method:a(),params:de.loose().optional()}),ye=d({_meta:Qo.optional()}),me=d({method:a(),params:ye.loose().optional()}),Xo=j({get[ct](){return lt.optional().catch(void 0)}}),ie=j({_meta:Xo.optional()}),Ge=x([a(),y().int()]),er=d({jsonrpc:p(mo),id:Ge,...se.shape}).strict(),tr=d({jsonrpc:p(mo),...me.shape}).strict(),fo=d({jsonrpc:p(mo),id:Ge,result:ie}).strict(),go=d({jsonrpc:p(mo),id:Ge.optional(),error:d({code:y().int(),message:a(),data:O().optional()})}).strict(),So=x([er,tr,fo,go]),aa=x([fo,go]),Ut=ie.strict(),_n=ye.extend({requestId:Ge.optional(),reason:a().optional()}),or=me.extend({method:p("notifications/cancelled"),params:_n}),yn=d({src:a(),mimeType:a().optional(),sizes:f(a()).optional(),theme:F(["light","dark"]).optional()}),yt=d({icons:f(yn).optional()}),at=d({name:a(),title:a().optional()}),lt=at.extend({...at.shape,...yt.shape,version:a(),websiteUrl:a().optional(),description:a().optional()}),aS=St(d({applyDefaults:w().optional()}),ne),cS=uo((e)=>{if(e&&typeof e==="object"&&!Array.isArray(e)&&Object.keys(e).length===0)return{form:{}};return e},St(d({form:aS.optional(),url:ne.optional()}),ne.optional())),ca=j({list:ne.optional(),cancel:ne.optional(),requests:j({sampling:j({createMessage:ne.optional()}).optional(),elicitation:j({create:ne.optional()}).optional()}).optional()}),la=j({list:ne.optional(),cancel:ne.optional(),requests:j({tools:j({call:ne.optional()}).optional()}).optional()}),bn=d({experimental:z(a(),ne).optional(),sampling:d({context:ne.optional(),tools:ne.optional()}).optional(),elicitation:cS.optional(),roots:d({listChanged:w().optional()}).optional(),tasks:ca.optional(),extensions:z(a(),ne).optional()}),vn=de.extend({protocolVersion:a(),capabilities:bn,clientInfo:lt}),zn=se.extend({method:p("initialize"),params:vn}),rr=d({experimental:z(a(),ne).optional(),logging:ne.optional(),completions:ne.optional(),prompts:d({listChanged:w().optional()}).optional(),resources:d({subscribe:w().optional(),listChanged:w().optional()}).optional(),tools:d({listChanged:w().optional()}).optional(),tasks:la.optional(),extensions:z(a(),ne).optional()}),Rn=ie.extend({protocolVersion:a(),capabilities:rr,serverInfo:lt,instructions:a().optional()}),wn=me.extend({method:p("notifications/initialized"),params:ye.optional()}),xn=se.extend({method:p("server/discover"),params:de.optional()}),Zt=ie.extend({supportedVersions:f(a()),capabilities:rr,instructions:a().optional()}),nr=se.extend({method:p("ping"),params:de.optional()}),Pn=d({progress:y(),total:M(y()),message:M(a())}),Tn=d({...ye.shape,...Pn.shape,progressToken:Ko}),sr=me.extend({method:p("notifications/progress"),params:Tn}),En=de.extend({cursor:Yo.optional()}),bt=se.extend({params:En.optional()}),vt=ie.extend({nextCursor:Yo.optional()}),ir=d({uri:a(),mimeType:M(a()),_meta:z(a(),O()).optional()}),ar=ir.extend({text:a()}),ol=a().refine((e)=>{try{return atob(e),!0}catch{return!1}},{message:"Invalid Base64 string"}),cr=ir.extend({blob:ol}),zt=F(["user","assistant"]),ut=d({audience:f(zt).optional(),priority:y().min(0).max(1).optional(),lastModified:Fo({offset:!0}).optional()}),lr=d({...at.shape,...yt.shape,uri:a(),description:M(a()),mimeType:M(a()),size:M(y()),annotations:ut.optional(),_meta:M(j({}))}),kn=d({...at.shape,...yt.shape,uriTemplate:a(),description:M(a()),mimeType:M(a()),annotations:ut.optional(),_meta:M(j({}))}),$n=bt.extend({method:p("resources/list")}),Cn=vt.extend({resources:f(lr)}),In=bt.extend({method:p("resources/templates/list")}),On=vt.extend({resourceTemplates:f(kn)}),_o=de.extend({uri:a()}),Nn=_o,An=se.extend({method:p("resources/read"),params:Nn}),Mn=ie.extend({contents:f(x([ar,cr]))}),qn=me.extend({method:p("notifications/resources/list_changed"),params:ye.optional()}),jn=_o,Ln=se.extend({method:p("resources/subscribe"),params:jn}),Un=_o,Zn=se.extend({method:p("resources/unsubscribe"),params:Un}),ur=d({toolsListChanged:w().optional(),promptsListChanged:w().optional(),resourcesListChanged:w().optional(),resourceSubscriptions:f(a()).optional()}),Dn=de.extend({notifications:ur}),Vn=se.extend({method:p("subscriptions/listen"),params:Dn}),Hn=ye.extend({notifications:ur}),Fn=me.extend({method:p("notifications/subscriptions/acknowledged"),params:Hn}),Jn=Xo.extend({[Go]:Ge}),Bn=ie.extend({_meta:Jn}),Gn=ye.extend({uri:a()}),Wn=me.extend({method:p("notifications/resources/updated"),params:Gn}),Kn=d({name:a(),description:M(a()),required:M(w())}),Yn=d({...at.shape,...yt.shape,description:M(a()),arguments:M(f(Kn)),_meta:M(j({}))}),Qn=bt.extend({method:p("prompts/list")}),Xn=vt.extend({prompts:f(Yn)}),es=de.extend({name:a(),arguments:z(a(),a()).optional()}),ts=se.extend({method:p("prompts/get"),params:es}),yo=d({type:p("text"),text:a(),annotations:ut.optional(),_meta:z(a(),O()).optional()}),bo=d({type:p("image"),data:ol,mimeType:a(),annotations:ut.optional(),_meta:z(a(),O()).optional()}),vo=d({type:p("audio"),data:ol,mimeType:a(),annotations:ut.optional(),_meta:z(a(),O()).optional()}),os=d({type:p("tool_use"),name:a(),id:a(),input:z(a(),O()),_meta:z(a(),O()).optional()}),zo=d({type:p("resource"),resource:x([ar,cr]),annotations:ut.optional(),_meta:z(a(),O()).optional()}),Ro=lr.extend({type:p("resource_link")}),dt=x([yo,bo,vo,Ro,zo]),rs=d({role:zt,content:dt}),ns=ie.extend({description:a().optional(),messages:f(rs)}),ss=me.extend({method:p("notifications/prompts/list_changed"),params:ye.optional()}),is=d({title:a().optional(),readOnlyHint:w().optional(),destructiveHint:w().optional(),idempotentHint:w().optional(),openWorldHint:w().optional()}),as=d({taskSupport:F(["required","optional","forbidden"]).optional()}),Dt=d({...at.shape,...yt.shape,description:a().optional(),inputSchema:d({type:p("object"),properties:z(a(),_t).optional(),required:f(a()).optional()}).catchall(O()),outputSchema:j({$schema:a().optional()}).optional(),annotations:is.optional(),execution:as.optional(),_meta:z(a(),O()).optional()}),cs=bt.extend({method:p("tools/list")}),ls=vt.extend({tools:f(Dt)}),Vt=ie.extend({content:f(dt).default([]),structuredContent:O().optional(),isError:w().optional()}),ua=Vt.or(ie.extend({toolResult:O()})),us=Lt.extend({name:a(),arguments:z(a(),O()).optional()}),ds=se.extend({method:p("tools/call"),params:us}),ps=me.extend({method:p("notifications/tools/list_changed"),params:ye.optional()}),hs=d({autoRefresh:w().default(!0),debounceMs:y().int().nonnegative().default(300)}),dr=F(["debug","info","notice","warning","error","critical","alert","emergency"]),ms=de.extend({level:dr}),fs=se.extend({method:p("logging/setLevel"),params:ms}),gs=ye.extend({level:dr,logger:a().optional(),data:O()}),Ss=me.extend({method:p("notifications/message"),params:gs}),_s=d({name:a().optional()}),ys=d({hints:f(_s).optional(),costPriority:y().min(0).max(1).optional(),speedPriority:y().min(0).max(1).optional(),intelligencePriority:y().min(0).max(1).optional()}),bs=d({mode:F(["auto","required","none"]).optional()}),vs=d({type:p("tool_result"),toolUseId:a().describe("The unique identifier for the corresponding tool call."),content:f(dt),structuredContent:O().optional(),isError:w().optional(),_meta:z(a(),O()).optional()}),zs=Jo("type",[yo,bo,vo]),jt=Jo("type",[yo,bo,vo,os,vs]),Rs=d({role:zt,content:x([jt,f(jt)]),_meta:z(a(),O()).optional()}),ws=Lt.extend({messages:f(Rs),modelPreferences:ys.optional(),systemPrompt:a().optional(),includeContext:F(["none","thisServer","allServers"]).optional(),temperature:y().optional(),maxTokens:y().int(),stopSequences:f(a()).optional(),metadata:ne.optional(),tools:f(Dt).optional(),toolChoice:bs.optional()}),xs=se.extend({method:p("sampling/createMessage"),params:ws}),Ps=ie.extend({model:a(),stopReason:M(F(["endTurn","stopSequence","maxTokens"]).or(a())),role:zt,content:zs}),Ts=ie.extend({model:a(),stopReason:M(F(["endTurn","stopSequence","maxTokens","toolUse"]).or(a())),role:zt,content:x([jt,f(jt)])}),pr=d({type:p("boolean"),title:a().optional(),description:a().optional(),default:w().optional()}),wo=d({type:p("string"),title:a().optional(),description:a().optional(),minLength:y().optional(),maxLength:y().optional(),format:F(["email","uri","date","date-time"]).optional(),default:a().optional()}),xo=d({type:F(["number","integer"]),title:a().optional(),description:a().optional(),minimum:y().optional(),maximum:y().optional(),default:y().optional()}),hr=d({type:p("string"),title:a().optional(),description:a().optional(),enum:f(a()),default:a().optional()}),mr=d({type:p("string"),title:a().optional(),description:a().optional(),oneOf:f(d({const:a(),title:a()})),default:a().optional()}),fr=d({type:p("string"),title:a().optional(),description:a().optional(),enum:f(a()),enumNames:f(a()).optional(),default:a().optional()}),Es=x([hr,mr]),gr=d({type:p("array"),title:a().optional(),description:a().optional(),minItems:y().optional(),maxItems:y().optional(),items:d({type:p("string"),enum:f(a())}),default:f(a()).optional()}),Sr=d({type:p("array"),title:a().optional(),description:a().optional(),minItems:y().optional(),maxItems:y().optional(),items:d({anyOf:f(d({const:a(),title:a()}))}),default:f(a()).optional()}),ks=x([gr,Sr]),$s=x([fr,Es,ks]),_r=x([$s,pr,wo,xo]),Po=Lt.extend({mode:p("form").optional(),message:a(),requestedSchema:d({type:p("object"),properties:z(a(),_r),required:f(a()).optional()}).catchall(O())}),Cs=Lt.extend({mode:p("url"),message:a(),elicitationId:a(),url:a().url()}),Is=x([Po,Cs]),Os=se.extend({method:p("elicitation/create"),params:Is}),Ns=ye.extend({elicitationId:a()}),As=me.extend({method:p("notifications/elicitation/complete"),params:Ns}),Ms=ie.extend({action:F(["accept","decline","cancel"]),content:uo((e)=>e===null?void 0:e,z(a(),x([a(),y(),w(),f(a())])).optional())}),qs=d({type:p("ref/resource"),uri:a()}),js=d({type:p("ref/prompt"),name:a()}),Ls=de.extend({ref:x([js,qs]),argument:d({name:a(),value:a()}),context:d({arguments:z(a(),a()).optional()}).optional()}),Us=se.extend({method:p("completion/complete"),params:Ls}),Zs=ie.extend({completion:j({values:f(a()).max(100),total:M(y().int()),hasMore:M(w())})}),Ds=d({uri:a().startsWith("file://"),name:a().optional(),_meta:z(a(),O()).optional()}),Vs=se.extend({method:p("roots/list"),params:de.optional()}),Hs=ie.extend({roots:f(Ds)}),Fs=me.extend({method:p("notifications/roots/list_changed"),params:ye.optional()}),da=j({ttl:y().optional(),pollInterval:y().optional()}),Js=F(["working","input_required","completed","failed","cancelled"]),Rt=d({taskId:a(),status:Js,ttl:x([y(),lo()]),createdAt:a(),lastUpdatedAt:a(),pollInterval:M(y()),statusMessage:M(a())}),pa=ie.extend({task:Rt}),Bs=ye.merge(Rt),ha=me.extend({method:p("notifications/tasks/status"),params:Bs}),ma=se.extend({method:p("tasks/get"),params:de.extend({taskId:a()})}),fa=ie.merge(Rt),ga=se.extend({method:p("tasks/result"),params:de.extend({taskId:a()})}),Sa=ie.loose(),_a=bt.extend({method:p("tasks/list")}),ya=vt.extend({tasks:f(Rt)}),ba=se.extend({method:p("tasks/cancel"),params:de.extend({taskId:a()})}),va=ie.merge(Rt),za=x([nr,zn,xn,Us,fs,ts,Qn,$n,In,An,Ln,Zn,Vn,ds,cs]),Ra=x([or,sr,wn,Fs]),wa=x([Ut,Ps,Ts,Ms,Hs]),xa=x([nr,xs,Os,Vs]),Pa=x([or,sr,Ss,Wn,qn,ps,ss,Fn,As]),Ta=x([Ut,Rn,Zt,Zs,ns,Xn,Cn,On,Mn,Vt,ls,Bn]);var pe=ta().superRefine((e,t)=>{if(!URL.canParse(e))return t.addIssue({code:Vh.custom,message:"URL must be parseable",fatal:!0}),Ha}).refine((e)=>{let t=new URL(e);return t.protocol!=="javascript:"&&t.protocol!=="data:"&&t.protocol!=="vbscript:"},{message:"URL cannot use javascript:, data:, or vbscript: scheme"}),Gs=j({resource:a().url(),authorization_servers:f(pe).optional(),jwks_uri:a().url().optional(),scopes_supported:f(a()).optional(),bearer_methods_supported:f(a()).optional(),resource_signing_alg_values_supported:f(a()).optional(),resource_name:a().optional(),resource_documentation:a().optional(),resource_policy_uri:a().url().optional(),resource_tos_uri:a().url().optional(),tls_client_certificate_bound_access_tokens:w().optional(),authorization_details_types_supported:f(a()).optional(),dpop_signing_alg_values_supported:f(a()).optional(),dpop_bound_access_tokens_required:w().optional()}),yr=j({issuer:a(),authorization_endpoint:pe,token_endpoint:pe,registration_endpoint:pe.optional(),scopes_supported:f(a()).optional(),response_types_supported:f(a()),response_modes_supported:f(a()).optional(),grant_types_supported:f(a()).optional(),token_endpoint_auth_methods_supported:f(a()).optional(),token_endpoint_auth_signing_alg_values_supported:f(a()).optional(),service_documentation:pe.optional(),revocation_endpoint:pe.optional(),revocation_endpoint_auth_methods_supported:f(a()).optional(),revocation_endpoint_auth_signing_alg_values_supported:f(a()).optional(),introspection_endpoint:a().optional(),introspection_endpoint_auth_methods_supported:f(a()).optional(),introspection_endpoint_auth_signing_alg_values_supported:f(a()).optional(),code_challenge_methods_supported:f(a()).optional(),client_id_metadata_document_supported:w().optional(),authorization_response_iss_parameter_supported:w().optional().catch(void 0),dpop_signing_alg_values_supported:f(a()).optional()}),Ws=j({issuer:a(),authorization_endpoint:pe,token_endpoint:pe,userinfo_endpoint:pe.optional(),jwks_uri:pe,registration_endpoint:pe.optional(),scopes_supported:f(a()).optional(),response_types_supported:f(a()),response_modes_supported:f(a()).optional(),grant_types_supported:f(a()).optional(),acr_values_supported:f(a()).optional(),subject_types_supported:f(a()),id_token_signing_alg_values_supported:f(a()),id_token_encryption_alg_values_supported:f(a()).optional(),id_token_encryption_enc_values_supported:f(a()).optional(),userinfo_signing_alg_values_supported:f(a()).optional(),userinfo_encryption_alg_values_supported:f(a()).optional(),userinfo_encryption_enc_values_supported:f(a()).optional(),request_object_signing_alg_values_supported:f(a()).optional(),request_object_encryption_alg_values_supported:f(a()).optional(),request_object_encryption_enc_values_supported:f(a()).optional(),token_endpoint_auth_methods_supported:f(a()).optional(),token_endpoint_auth_signing_alg_values_supported:f(a()).optional(),display_values_supported:f(a()).optional(),claim_types_supported:f(a()).optional(),claims_supported:f(a()).optional(),service_documentation:a().optional(),claims_locales_supported:f(a()).optional(),ui_locales_supported:f(a()).optional(),claims_parameter_supported:w().optional(),request_parameter_supported:w().optional(),request_uri_parameter_supported:w().optional(),require_request_uri_registration:w().optional(),op_policy_uri:pe.optional(),op_tos_uri:pe.optional(),client_id_metadata_document_supported:w().optional(),authorization_response_iss_parameter_supported:w().optional().catch(void 0)}),Ks=d({...Ws.shape,...yr.pick({code_challenge_methods_supported:!0}).shape}),br=d({access_token:a(),id_token:a().optional(),token_type:a(),expires_in:iS().optional(),scope:a().optional(),refresh_token:a().optional(),issuer:a().optional().catch(void 0)}).strip(),Ys=d({issued_token_type:p("urn:ietf:params:oauth:token-type:id-jag"),access_token:a(),token_type:a().optional(),expires_in:y().optional(),scope:a().optional()}).strip(),vr=d({error:a(),error_description:a().optional(),error_uri:a().optional()}),rl=pe.optional().or(p("").transform(()=>{return})),Qs=d({redirect_uris:f(pe),token_endpoint_auth_method:a().optional(),grant_types:f(a()).optional(),response_types:f(a()).optional(),application_type:a().optional(),client_name:a().optional(),client_uri:pe.optional(),logo_uri:rl,scope:a().optional(),contacts:f(a()).optional(),tos_uri:rl,policy_uri:a().optional(),jwks_uri:pe.optional(),jwks:ra().optional(),software_id:a().optional(),software_version:a().optional(),software_statement:a().optional()}).strip(),Xs=d({client_id:a(),client_secret:a().optional(),client_id_issued_at:y().optional(),client_secret_expires_at:y().optional(),issuer:a().optional().catch(void 0)}).strip(),ei=Qs.merge(Xs),Ea=d({error:a(),error_description:a().optional()}).strip(),ka=d({token:a(),token_type_hint:a().optional()}).strip();var cl=Symbol.for("mcp.sdk.errorBrands");function Ft(e,t){let o=new Set,r=t;while(typeof r==="function"){let n=r.mcpBrand;if(Object.prototype.hasOwnProperty.call(r,"mcpBrand")&&typeof n==="string")o.add(n);r=Object.getPrototypeOf(r)}if(o.size===0)return;Object.defineProperty(e,cl,{value:o,enumerable:!1,configurable:!0})}function ke(e,t){try{if(typeof t==="object"&&t!==null&&Object.prototype.hasOwnProperty.call(e,"mcpBrand")&&typeof e.mcpBrand==="string"&&Object.prototype.hasOwnProperty.call(t,cl)){let o=t[cl];if(o&&typeof o.has==="function"&&o.has(e.mcpBrand))return!0}}catch{}return Function.prototype[Symbol.hasInstance].call(e,t)}var hm=class e extends Error{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.OAuthError"})}static[Symbol.hasInstance](t){return ke(this,t)}static isInstance(t){if(typeof this!=="function")throw TypeError("isInstance must be called on the class (e.g. `SdkError.isInstance(value)`); for callbacks use `v => SdkError.isInstance(v)`");return ke(this,t)}constructor(t,o,r){super(o);this.code=t,this.errorUri=r,this.name="OAuthError",Ft(this,new.target)}toResponseObject(){let t={error:this.code,error_description:this.message};if(this.errorUri)t.error_uri=this.errorUri;return t}static fromResponse(t){return new e(t.error,t.error_description??t.error,t.error_uri)}},A=function(e){return e.NotConnected="NOT_CONNECTED",e.AlreadyConnected="ALREADY_CONNECTED",e.NotInitialized="NOT_INITIALIZED",e.CapabilityNotSupported="CAPABILITY_NOT_SUPPORTED",e.RequestTimeout="REQUEST_TIMEOUT",e.ConnectionClosed="CONNECTION_CLOSED",e.SendFailed="SEND_FAILED",e.InvalidResult="INVALID_RESULT",e.UnsupportedResultType="UNSUPPORTED_RESULT_TYPE",e.InputRequiredRoundsExceeded="INPUT_REQUIRED_ROUNDS_EXCEEDED",e.ListPaginationExceeded="LIST_PAGINATION_EXCEEDED",e.MethodNotSupportedByProtocolVersion="METHOD_NOT_SUPPORTED_BY_PROTOCOL_VERSION",e.EraNegotiationFailed="ERA_NEGOTIATION_FAILED",e.ClientHttpNotImplemented="CLIENT_HTTP_NOT_IMPLEMENTED",e.ClientHttpAuthentication="CLIENT_HTTP_AUTHENTICATION",e.ClientHttpForbidden="CLIENT_HTTP_FORBIDDEN",e.ClientHttpUnexpectedContent="CLIENT_HTTP_UNEXPECTED_CONTENT",e.ClientHttpFailedToOpenStream="CLIENT_HTTP_FAILED_TO_OPEN_STREAM",e.ClientHttpFailedToTerminateSession="CLIENT_HTTP_FAILED_TO_TERMINATE_SESSION",e}({}),C=class extends Error{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.SdkError"})}static[Symbol.hasInstance](e){return ke(this,e)}static isInstance(e){if(typeof this!=="function")throw TypeError("isInstance must be called on the class (e.g. `SdkError.isInstance(value)`); for callbacks use `v => SdkError.isInstance(v)`");return ke(this,e)}constructor(e,t,o,r){super(t,r);this.code=e,this.data=o,this.name="SdkError",Ft(this,new.target)}},ii=class extends C{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.SdkHttpError"})}constructor(e,t,o,r){super(e,t,o,r);this.name="SdkHttpError"}get status(){return this.data.status}get statusText(){return this.data.statusText}};var mm="2026-07-28",hl=[mm];function xt(e){return e>=mm}function ml(e){return e.filter((t)=>!xt(t))}function ai(e){return e.filter((t)=>xt(t))}function fm(e){let t=e.structuredContent;if(t===void 0)return e;if(!(typeof t!=="object"||t===null||Array.isArray(t)))return e;if(e.content?.some((o)=>o.type==="text")??!1)return e;return{...e,content:[...e.content??[],{type:"text",text:JSON.stringify(t)}]}}var gm=["task","inputRequests","requestState"];function lS(e){if(e===null||typeof e!=="object"||Array.isArray(e)||e.content!==void 0||gm.some((t)=>(t in e)))return e;return{...e,content:[]}}function uS(){let e=mn(()=>x([a(),y(),w(),lo(),z(a(),e),f(e)])),t=z(a(),e),o=x([a(),y().int()]),r=a(),n=d({ttl:y().optional()}),s=d({taskId:a()}),i=j({progressToken:o.optional(),"io.modelcontextprotocol/related-task":s.optional()}),c=d({_meta:i.optional()}),l=c.extend({task:n.optional()}),u=d({method:a(),params:c.loose().optional()}),h=d({_meta:i.optional()}),m=d({method:a(),params:h.loose().optional()}),S=j({_meta:i.optional()}),g=x([a(),y().int()]),b=S.strict(),v=h.extend({requestId:g.optional(),reason:a().optional()}),R=m.extend({method:p("notifications/cancelled"),params:v}),q=d({src:a(),mimeType:a().optional(),sizes:f(a()).optional(),theme:F(["light","dark"]).optional()}),V=d({icons:f(q).optional()}),P=d({name:a(),title:a().optional()}),H=P.extend({...P.shape,...V.shape,version:a(),websiteUrl:a().optional(),description:a().optional()}),B=St(d({applyDefaults:w().optional()}),t),G=uo((_e)=>{if(_e&&typeof _e==="object"&&!Array.isArray(_e)&&Object.keys(_e).length===0)return{form:{}};return _e},St(d({form:B.optional(),url:t.optional()}),t.optional())),Y=j({list:t.optional(),cancel:t.optional(),requests:j({sampling:j({createMessage:t.optional()}).optional(),elicitation:j({create:t.optional()}).optional()}).optional()}),ue=j({list:t.optional(),cancel:t.optional(),requests:j({tools:j({call:t.optional()}).optional()}).optional()}),oe=d({experimental:z(a(),t).optional(),sampling:d({context:t.optional(),tools:t.optional()}).optional(),elicitation:G.optional(),roots:d({listChanged:w().optional()}).optional(),tasks:Y.optional(),extensions:z(a(),t).optional()}),fe=c.extend({protocolVersion:a(),capabilities:oe,clientInfo:H}),Ve=u.extend({method:p("initialize"),params:fe}),Tt=d({experimental:z(a(),t).optional(),logging:t.optional(),completions:t.optional(),prompts:d({listChanged:w().optional()}).optional(),resources:d({subscribe:w().optional(),listChanged:w().optional()}).optional(),tools:d({listChanged:w().optional()}).optional(),tasks:ue.optional(),extensions:z(a(),t).optional()}),Et=S.extend({protocolVersion:a(),capabilities:Tt,serverInfo:H,instructions:a().optional()}),Ye=m.extend({method:p("notifications/initialized"),params:h.optional()}),Me=u.extend({method:p("ping"),params:c.optional()}),Qe=d({progress:y(),total:M(y()),message:M(a())}),Pe=d({...h.shape,...Qe.shape,progressToken:o}),qe=m.extend({method:p("notifications/progress"),params:Pe}),Xe=c.extend({cursor:r.optional()}),$e=u.extend({params:Xe.optional()}),be=S.extend({nextCursor:r.optional()}),mt=d({uri:a(),mimeType:M(a()),_meta:z(a(),O()).optional()}),ft=mt.extend({text:a()}),et=a().refine((_e)=>{try{return atob(_e),!0}catch{return!1}},{message:"Invalid Base64 string"}),ge=mt.extend({blob:et}),ve=F(["user","assistant"]),ze=d({audience:f(ve).optional(),priority:y().min(0).max(1).optional(),lastModified:Fo({offset:!0}).optional()}),He=d({...P.shape,...V.shape,uri:a(),description:M(a()),mimeType:M(a()),size:M(y()),annotations:ze.optional(),_meta:M(j({}))}),Gt=d({...P.shape,...V.shape,uriTemplate:a(),description:M(a()),mimeType:M(a()),annotations:ze.optional(),_meta:M(j({}))}),Ce=$e.extend({method:p("resources/list")}),Ie=be.extend({resources:f(He)}),Te=$e.extend({method:p("resources/templates/list")}),je=be.extend({resourceTemplates:f(Gt)}),Le=c.extend({uri:a()}),tt=Le,ot=u.extend({method:p("resources/read"),params:tt}),kt=S.extend({contents:f(x([ft,ge]))}),rt=m.extend({method:p("notifications/resources/list_changed"),params:h.optional()}),Wt=Le,E=u.extend({method:p("resources/subscribe"),params:Wt}),nt=Le,L=u.extend({method:p("resources/unsubscribe"),params:nt}),I=h.extend({uri:a()}),J=m.extend({method:p("notifications/resources/updated"),params:I}),k=d({name:a(),description:M(a()),required:M(w())}),T=d({...P.shape,...V.shape,description:M(a()),arguments:M(f(k)),_meta:M(j({}))}),D=$e.extend({method:p("prompts/list")}),U=be.extend({prompts:f(T)}),le=c.extend({name:a(),arguments:z(a(),a()).optional()}),Kt=u.extend({method:p("prompts/get"),params:le}),st=d({type:p("text"),text:a(),annotations:ze.optional(),_meta:z(a(),O()).optional()}),Yt=d({type:p("image"),data:et,mimeType:a(),annotations:ze.optional(),_meta:z(a(),O()).optional()}),Qt=d({type:p("audio"),data:et,mimeType:a(),annotations:ze.optional(),_meta:z(a(),O()).optional()}),xr=d({type:p("tool_use"),name:a(),id:a(),input:z(a(),O()),_meta:z(a(),O()).optional()}),$t=d({type:p("resource"),resource:x([ft,ge]),annotations:ze.optional(),_meta:z(a(),O()).optional()}),Pr=He.extend({type:p("resource_link")}),Ue=x([st,Yt,Qt,Pr,$t]),$o=d({role:ve,content:Ue}),Co=S.extend({description:a().optional(),messages:f($o)}),Xt=m.extend({method:p("notifications/prompts/list_changed"),params:h.optional()}),Tr=d({title:a().optional(),readOnlyHint:w().optional(),destructiveHint:w().optional(),idempotentHint:w().optional(),openWorldHint:w().optional()}),Io=d({taskSupport:F(["required","optional","forbidden"]).optional()}),eo=d({...P.shape,...V.shape,description:a().optional(),inputSchema:d({type:p("object"),properties:z(a(),e).optional(),required:f(a()).optional()}).catchall(O()),outputSchema:d({type:p("object"),properties:z(a(),e).optional(),required:f(a()).optional()}).catchall(O()).optional(),annotations:Tr.optional(),execution:Io.optional(),_meta:z(a(),O()).optional()}),Oo=$e.extend({method:p("tools/list")}),No=be.extend({tools:f(eo)}),Ao=S.extend({content:f(Ue),structuredContent:z(a(),O()).optional(),isError:w().optional()}),Se=l.extend({name:a(),arguments:z(a(),O()).optional()}),Er=u.extend({method:p("tools/call"),params:Se}),Si=m.extend({method:p("notifications/tools/list_changed"),params:h.optional()}),Mo=F(["debug","info","notice","warning","error","critical","alert","emergency"]),kr=c.extend({level:Mo}),$r=u.extend({method:p("logging/setLevel"),params:kr}),Cr=h.extend({level:Mo,logger:a().optional(),data:O()}),Ir=m.extend({method:p("notifications/message"),params:Cr}),Or=d({name:a().optional()}),Nr=d({hints:f(Or).optional(),costPriority:y().min(0).max(1).optional(),speedPriority:y().min(0).max(1).optional(),intelligencePriority:y().min(0).max(1).optional()}),Ar=d({mode:F(["auto","required","none"]).optional()}),_i=d({type:p("tool_result"),toolUseId:a().describe("The unique identifier for the corresponding tool call."),content:f(Ue),structuredContent:d({}).loose().optional(),isError:w().optional(),_meta:z(a(),O()).optional()}),Mr=Jo("type",[st,Yt,Qt]),Ct=Jo("type",[st,Yt,Qt,xr,_i]),qr=d({role:ve,content:x([Ct,f(Ct)]),_meta:z(a(),O()).optional()}),jr=l.extend({messages:f(qr),modelPreferences:Nr.optional(),systemPrompt:a().optional(),includeContext:F(["none","thisServer","allServers"]).optional(),temperature:y().optional(),maxTokens:y().int(),stopSequences:f(a()).optional(),metadata:t.optional(),tools:f(eo).optional(),toolChoice:Ar.optional()}),Lr=u.extend({method:p("sampling/createMessage"),params:jr}),Ur=S.extend({model:a(),stopReason:M(F(["endTurn","stopSequence","maxTokens"]).or(a())),role:ve,content:Mr}),Zr=S.extend({model:a(),stopReason:M(F(["endTurn","stopSequence","maxTokens","toolUse"]).or(a())),role:ve,content:x([Ct,f(Ct)])}),Dr=d({type:p("boolean"),title:a().optional(),description:a().optional(),default:w().optional()}),Vr=d({type:p("string"),title:a().optional(),description:a().optional(),minLength:y().optional(),maxLength:y().optional(),format:F(["email","uri","date","date-time"]).optional(),default:a().optional()}),Hr=d({type:F(["number","integer"]),title:a().optional(),description:a().optional(),minimum:y().optional(),maximum:y().optional(),default:y().optional()}),Fr=d({type:p("string"),title:a().optional(),description:a().optional(),enum:f(a()),default:a().optional()}),Jr=d({type:p("string"),title:a().optional(),description:a().optional(),oneOf:f(d({const:a(),title:a()})),default:a().optional()}),Br=d({type:p("string"),title:a().optional(),description:a().optional(),enum:f(a()),enumNames:f(a()).optional(),default:a().optional()}),Gr=x([Fr,Jr]),to=d({type:p("array"),title:a().optional(),description:a().optional(),minItems:y().optional(),maxItems:y().optional(),items:d({type:p("string"),enum:f(a())}),default:f(a()).optional()}),oo=d({type:p("array"),title:a().optional(),description:a().optional(),minItems:y().optional(),maxItems:y().optional(),items:d({anyOf:f(d({const:a(),title:a()}))}),default:f(a()).optional()}),yi=x([to,oo]),bi=x([Br,Gr,yi]),Oe=x([bi,Dr,Vr,Hr]),Ne=l.extend({mode:p("form").optional(),message:a(),requestedSchema:d({type:p("object"),properties:z(a(),Oe),required:f(a()).optional()}).catchall(O())}),Wr=l.extend({mode:p("url"),message:a(),elicitationId:a(),url:a().url()}),Fe=x([Ne,Wr]),vi=u.extend({method:p("elicitation/create"),params:Fe}),zi=h.extend({elicitationId:a()}),Ri=m.extend({method:p("notifications/elicitation/complete"),params:zi}),wi=S.extend({action:F(["accept","decline","cancel"]),content:uo((_e)=>_e===null?void 0:_e,z(a(),x([a(),y(),w(),f(a())])).optional())}),xi=d({type:p("ref/resource"),uri:a()}),Pi=d({type:p("ref/prompt"),name:a()}),Ti=c.extend({ref:x([Pi,xi]),argument:d({name:a(),value:a()}),context:d({arguments:z(a(),a()).optional()}).optional()}),Kr=u.extend({method:p("completion/complete"),params:Ti}),Ei=S.extend({completion:j({values:f(a()).max(100),total:M(y().int()),hasMore:M(w())})}),ki=d({uri:a().startsWith("file://"),name:a().optional(),_meta:z(a(),O()).optional()}),qo=u.extend({method:p("roots/list"),params:c.optional()}),Yr=S.extend({roots:f(ki)}),$i=m.extend({method:p("notifications/roots/list_changed"),params:h.optional()}),Ci=j({ttl:y().optional(),pollInterval:y().optional()}),Qr=F(["working","input_required","completed","failed","cancelled"]),It=d({taskId:a(),status:Qr,ttl:x([y(),lo()]),createdAt:a(),lastUpdatedAt:a(),pollInterval:M(y()),statusMessage:M(a())}),Ee=S.extend({task:It}),Ii=h.merge(It),ro=m.extend({method:p("notifications/tasks/status"),params:Ii}),jo=u.extend({method:p("tasks/get"),params:c.extend({taskId:a()})}),Lo=S.merge(It),Uo=u.extend({method:p("tasks/result"),params:c.extend({taskId:a()})}),Va=S.loose(),Re=$e.extend({method:p("tasks/list")}),ce=be.extend({tasks:f(It)}),no=u.extend({method:p("tasks/cancel"),params:c.extend({taskId:a()})});return{JSONValueSchema:e,JSONObjectSchema:t,ProgressTokenSchema:o,CursorSchema:r,TaskMetadataSchema:n,RelatedTaskMetadataSchema:s,RequestMetaSchema:i,BaseRequestParamsSchema:c,TaskAugmentedRequestParamsSchema:l,RequestSchema:u,NotificationsParamsSchema:h,NotificationSchema:m,ResultSchema:S,RequestIdSchema:g,EmptyResultSchema:b,CancelledNotificationParamsSchema:v,CancelledNotificationSchema:R,IconSchema:q,IconsSchema:V,BaseMetadataSchema:P,ImplementationSchema:H,ClientTasksCapabilitySchema:Y,ServerTasksCapabilitySchema:ue,ClientCapabilitiesSchema:oe,InitializeRequestParamsSchema:fe,InitializeRequestSchema:Ve,ServerCapabilitiesSchema:Tt,InitializeResultSchema:Et,InitializedNotificationSchema:Ye,PingRequestSchema:Me,ProgressSchema:Qe,ProgressNotificationParamsSchema:Pe,ProgressNotificationSchema:qe,PaginatedRequestParamsSchema:Xe,PaginatedRequestSchema:$e,PaginatedResultSchema:be,ResourceContentsSchema:mt,TextResourceContentsSchema:ft,BlobResourceContentsSchema:ge,RoleSchema:ve,AnnotationsSchema:ze,ResourceSchema:He,ResourceTemplateSchema:Gt,ListResourcesRequestSchema:Ce,ListResourcesResultSchema:Ie,ListResourceTemplatesRequestSchema:Te,ListResourceTemplatesResultSchema:je,ResourceRequestParamsSchema:Le,ReadResourceRequestParamsSchema:tt,ReadResourceRequestSchema:ot,ReadResourceResultSchema:kt,ResourceListChangedNotificationSchema:rt,SubscribeRequestParamsSchema:Wt,SubscribeRequestSchema:E,UnsubscribeRequestParamsSchema:nt,UnsubscribeRequestSchema:L,ResourceUpdatedNotificationParamsSchema:I,ResourceUpdatedNotificationSchema:J,PromptArgumentSchema:k,PromptSchema:T,ListPromptsRequestSchema:D,ListPromptsResultSchema:U,GetPromptRequestParamsSchema:le,GetPromptRequestSchema:Kt,TextContentSchema:st,ImageContentSchema:Yt,AudioContentSchema:Qt,ToolUseContentSchema:xr,EmbeddedResourceSchema:$t,ResourceLinkSchema:Pr,ContentBlockSchema:Ue,PromptMessageSchema:$o,GetPromptResultSchema:Co,PromptListChangedNotificationSchema:Xt,ToolAnnotationsSchema:Tr,ToolExecutionSchema:Io,ToolSchema:eo,ListToolsRequestSchema:Oo,ListToolsResultSchema:No,CallToolResultSchema:Ao,CallToolRequestParamsSchema:Se,CallToolRequestSchema:Er,ToolListChangedNotificationSchema:Si,LoggingLevelSchema:Mo,SetLevelRequestParamsSchema:kr,SetLevelRequestSchema:$r,LoggingMessageNotificationParamsSchema:Cr,LoggingMessageNotificationSchema:Ir,ModelHintSchema:Or,ModelPreferencesSchema:Nr,ToolChoiceSchema:Ar,ToolResultContentSchema:_i,SamplingContentSchema:Mr,SamplingMessageContentBlockSchema:Ct,SamplingMessageSchema:qr,CreateMessageRequestParamsSchema:jr,CreateMessageRequestSchema:Lr,CreateMessageResultSchema:Ur,CreateMessageResultWithToolsSchema:Zr,BooleanSchemaSchema:Dr,StringSchemaSchema:Vr,NumberSchemaSchema:Hr,UntitledSingleSelectEnumSchemaSchema:Fr,TitledSingleSelectEnumSchemaSchema:Jr,LegacyTitledEnumSchemaSchema:Br,SingleSelectEnumSchemaSchema:Gr,UntitledMultiSelectEnumSchemaSchema:to,TitledMultiSelectEnumSchemaSchema:oo,MultiSelectEnumSchemaSchema:yi,EnumSchemaSchema:bi,PrimitiveSchemaDefinitionSchema:Oe,ElicitRequestFormParamsSchema:Ne,ElicitRequestURLParamsSchema:Wr,ElicitRequestParamsSchema:Fe,ElicitRequestSchema:vi,ElicitationCompleteNotificationParamsSchema:zi,ElicitationCompleteNotificationSchema:Ri,ElicitResultSchema:wi,ResourceTemplateReferenceSchema:xi,PromptReferenceSchema:Pi,CompleteRequestParamsSchema:Ti,CompleteRequestSchema:Kr,CompleteResultSchema:Ei,RootSchema:ki,ListRootsRequestSchema:qo,ListRootsResultSchema:Yr,RootsListChangedNotificationSchema:$i,TaskCreationParamsSchema:Ci,TaskStatusSchema:Qr,TaskSchema:It,CreateTaskResultSchema:Ee,TaskStatusNotificationParamsSchema:Ii,TaskStatusNotificationSchema:ro,GetTaskRequestSchema:jo,GetTaskResultSchema:Lo,GetTaskPayloadRequestSchema:Uo,GetTaskPayloadResultSchema:Va,ListTasksRequestSchema:Re,ListTasksResultSchema:ce,CancelTaskRequestSchema:no,CancelTaskResultSchema:S.merge(It),ClientRequestSchema:x([Me,Ve,Kr,$r,Kt,D,Ce,Te,ot,E,L,Er,Oo,jo,Uo,Re,no]),ClientNotificationSchema:x([R,qe,Ye,$i,ro]),ClientResultSchema:x([b,Ur,Zr,wi,Yr,Lo,ce,Ee]),ServerRequestSchema:x([Me,Lr,vi,qo,jo,Uo,Re,no]),ServerNotificationSchema:x([R,qe,Ir,J,rt,Si,Xt,ro,Ri]),ServerResultSchema:x([b,Et,Ei,Co,U,Ie,je,kt,Ao,No,Lo,ce,Ee]),CallToolResultWireSchema:O().superRefine((_e,$f)=>{if(typeof _e!=="object"||_e===null||Array.isArray(_e)||_e.content!==void 0)return;for(let Zl of gm)if(Zl in _e){$f.addIssue({code:"custom",message:`content is required when the body carries '${Zl}' — another result family cannot default into an empty tools/call success`});return}}).transform(lS).pipe(Ao)}}var dS;function Sm(){return dS??=uS()}function _m(e){return e.type!=="object"}var pS=new Set(["const","enum","default","examples"]),hS=new Set(["properties","patternProperties","$defs","definitions","dependentSchemas","dependencies"]);function tm(e){return e!==void 0&&!(typeof e==="string"&&e.startsWith("#"))}function mS(e){let t=typeof e.$schema==="string"?e.$schema:void 0;if(tm(e.$id))return{...t!==void 0&&{$schema:t},type:"object",properties:{result:e},required:["result"]};let o=Jl(e.$schema)&&e.$recursiveAnchor!==!0,r=(n,s)=>{if(Array.isArray(n))return n.map((l)=>r(l,!1));if(n===null||typeof n!=="object")return n;if(!s&&tm(n.$id))return n;let i={},c=!1;for(let[l,u]of Object.entries(n))if(s)i[l]=r(u,!1);else if((l==="$ref"||l==="$dynamicRef")&&typeof u==="string")i[l]=u==="#"?"#/properties/result":u.startsWith("#/")?`#/properties/result${u.slice(1)}`:u;else if(l==="$recursiveRef"&&u==="#"&&o)c=!0;else if(pS.has(l))i[l]=u;else if(hS.has(l))i[l]=r(u,!0);else i[l]=r(u,!1);if(c)if("$ref"in i)i.allOf=[...Array.isArray(i.allOf)?i.allOf:[],{$ref:"#/properties/result"}];else i.$ref="#/properties/result";return i};return{...t!==void 0&&{$schema:t},type:"object",properties:{result:r(e,!1)},required:["result"]}}var ym={ping:null,initialize:null,"completion/complete":null,"logging/setLevel":null,"prompts/get":null,"prompts/list":null,"resources/list":null,"resources/templates/list":null,"resources/read":null,"resources/subscribe":null,"resources/unsubscribe":null,"tools/call":null,"tools/list":null,"tasks/get":null,"tasks/result":null,"tasks/list":null,"tasks/cancel":null,"sampling/createMessage":null,"elicitation/create":null,"roots/list":null},bm={"notifications/cancelled":null,"notifications/progress":null,"notifications/initialized":null,"notifications/roots/list_changed":null,"notifications/tasks/status":null,"notifications/message":null,"notifications/resources/updated":null,"notifications/resources/list_changed":null,"notifications/tools/list_changed":null,"notifications/prompts/list_changed":null,"notifications/elicitation/complete":null},fS={ping:null,initialize:null,"completion/complete":null,"logging/setLevel":null,"prompts/get":null,"prompts/list":null,"resources/list":null,"resources/templates/list":null,"resources/read":null,"resources/subscribe":null,"resources/unsubscribe":null,"tools/call":null,"tools/list":null,"sampling/createMessage":null,"elicitation/create":null,"roots/list":null},$a;function fl(){if($a)return $a;let e=Sm();return $a={requestSchemas:{ping:e.PingRequestSchema,initialize:e.InitializeRequestSchema,"completion/complete":e.CompleteRequestSchema,"logging/setLevel":e.SetLevelRequestSchema,"prompts/get":e.GetPromptRequestSchema,"prompts/list":e.ListPromptsRequestSchema,"resources/list":e.ListResourcesRequestSchema,"resources/templates/list":e.ListResourceTemplatesRequestSchema,"resources/read":e.ReadResourceRequestSchema,"resources/subscribe":e.SubscribeRequestSchema,"resources/unsubscribe":e.UnsubscribeRequestSchema,"tools/call":e.CallToolRequestSchema,"tools/list":e.ListToolsRequestSchema,"tasks/get":e.GetTaskRequestSchema,"tasks/result":e.GetTaskPayloadRequestSchema,"tasks/list":e.ListTasksRequestSchema,"tasks/cancel":e.CancelTaskRequestSchema,"sampling/createMessage":e.CreateMessageRequestSchema,"elicitation/create":e.ElicitRequestSchema,"roots/list":e.ListRootsRequestSchema},notificationSchemas:{"notifications/cancelled":e.CancelledNotificationSchema,"notifications/progress":e.ProgressNotificationSchema,"notifications/initialized":e.InitializedNotificationSchema,"notifications/roots/list_changed":e.RootsListChangedNotificationSchema,"notifications/tasks/status":e.TaskStatusNotificationSchema,"notifications/message":e.LoggingMessageNotificationSchema,"notifications/resources/updated":e.ResourceUpdatedNotificationSchema,"notifications/resources/list_changed":e.ResourceListChangedNotificationSchema,"notifications/tools/list_changed":e.ToolListChangedNotificationSchema,"notifications/prompts/list_changed":e.PromptListChangedNotificationSchema,"notifications/elicitation/complete":e.ElicitationCompleteNotificationSchema},resultSchemas:{ping:e.EmptyResultSchema,initialize:e.InitializeResultSchema,"completion/complete":e.CompleteResultSchema,"logging/setLevel":e.EmptyResultSchema,"prompts/get":e.GetPromptResultSchema,"prompts/list":e.ListPromptsResultSchema,"resources/list":e.ListResourcesResultSchema,"resources/templates/list":e.ListResourceTemplatesResultSchema,"resources/read":e.ReadResourceResultSchema,"resources/subscribe":e.EmptyResultSchema,"resources/unsubscribe":e.EmptyResultSchema,"tools/call":e.CallToolResultWireSchema,"tools/list":e.ListToolsResultSchema,"sampling/createMessage":e.CreateMessageResultWithToolsSchema,"elicitation/create":e.ElicitResultSchema,"roots/list":e.ListRootsResultSchema}},$a}function vm(e){return Object.prototype.hasOwnProperty.call(ym,e)}function zm(e){return Object.prototype.hasOwnProperty.call(bm,e)}function gS(e){return Object.prototype.hasOwnProperty.call(fS,e)}function SS(e){return gS(e)?fl().resultSchemas[e]:void 0}function _S(e){return vm(e)?fl().requestSchemas[e]:void 0}function yS(e){return zm(e)?fl().notificationSchemas[e]:void 0}var qz=Object.keys(ym),jz=Object.keys(bm);function ll(e){return e!==null&&typeof e==="object"&&!Array.isArray(e)}function Ca(e,t){if(e===void 0)return{ok:!1,reason:"not-in-era"};let o=e.safeParse(t);return o.success?{ok:!0,value:o.data}:{ok:!1,reason:"invalid",message:String(o.error)}}var om={ok:!1,reason:"not-in-era"};function rm(e){return ll(e)&&ll(e.outputSchema)&&_m(e.outputSchema)}function nm(e){return e}var gl={era:"2025-11-25",hasRequestMethod:vm,hasNotificationMethod:zm,validateRequest:(e,t)=>Ca(_S(e),t),validateResult:(e,t)=>Ca(SS(e),t),validateNotification:(e,t)=>Ca(yS(e),t),hasInputRequestMethod:()=>!1,validateInputRequest:()=>om,validateInputResponse:()=>om,samplingResultVariant:(e,t)=>{let o=Sm();return Ca(e?o.CreateMessageResultWithToolsSchema:o.CreateMessageResultSchema,t)},outboundEnvelope:(e)=>{return},validateEnvelopeMeta:(e)=>[],projectCallToolResult(e,t){let o=fm(e),r=o.structuredContent;if(r===void 0)return o;let n=typeof r!=="object"||r===null||Array.isArray(r),s=t!==void 0&&_m(t);if(!n&&!s)return o;return{...o,structuredContent:{result:r}}},decodeResult(e,t){if(ll(t)&&"resultType"in t){let o={...t};return delete o.resultType,{kind:"complete",result:nm(o)}}return{kind:"complete",result:nm(t)}},encodeResult(e,t){if(e!=="tools/list")return t;let o=t.tools;if(!Array.isArray(o)||!o.some((r)=>rm(r)))return t;return{...t,tools:o.map((r)=>rm(r)?{...r,outputSchema:mS(r.outputSchema)}:r)}},encodeErrorCode:(e)=>e===-32002?-32602:e,checkInboundEnvelope:(e)=>{return}};function bS(){let e=mn(()=>x([a(),y(),w(),lo(),z(a(),e),f(e)])),t=z(a(),e),o=x([a(),y().int()]),r=a(),n=x([a(),y().int()]),s=F(["user","assistant"]),i=F(["debug","info","notice","warning","error","critical","alert","emergency"]),c=a().refine((ce)=>{try{return atob(ce),!0}catch{return!1}},{message:"Invalid Base64 string"}),l=d({ttl:y().optional()}),u=d({taskId:a()}),h=j({progressToken:o.optional(),"io.modelcontextprotocol/related-task":u.optional()}),m=d({_meta:h.optional()}),S=m.extend({task:l.optional()}),g=d({_meta:h.optional()}),b=d({method:a(),params:g.loose().optional()}),v=d({src:a(),mimeType:a().optional(),sizes:f(a()).optional(),theme:F(["light","dark"]).optional()}),R=d({icons:f(v).optional()}),q=d({name:a(),title:a().optional()}),V=q.extend({...q.shape,...R.shape,version:a(),websiteUrl:a().optional(),description:a().optional()}),P=St(d({applyDefaults:w().optional()}),t),H=uo((ce)=>{if(ce&&typeof ce==="object"&&!Array.isArray(ce)&&Object.keys(ce).length===0)return{form:{}};return ce},St(d({form:P.optional(),url:t.optional()}),t.optional())),B=j({list:t.optional(),cancel:t.optional(),requests:j({sampling:j({createMessage:t.optional()}).optional(),elicitation:j({create:t.optional()}).optional()}).optional()}),G=j({list:t.optional(),cancel:t.optional(),requests:j({tools:j({call:t.optional()}).optional()}).optional()}),Y=d({experimental:z(a(),t).optional(),sampling:d({context:t.optional(),tools:t.optional()}).optional(),elicitation:H.optional(),roots:d({listChanged:w().optional()}).optional(),tasks:B.optional(),extensions:z(a(),t).optional()}),ue=d({experimental:z(a(),t).optional(),logging:t.optional(),completions:t.optional(),prompts:d({listChanged:w().optional()}).optional(),resources:d({subscribe:w().optional(),listChanged:w().optional()}).optional(),tools:d({listChanged:w().optional()}).optional(),tasks:G.optional(),extensions:z(a(),t).optional()}),oe=d({progress:y(),total:M(y()),message:M(a())}),fe=d({...g.shape,...oe.shape,progressToken:o}),Ve=b.extend({method:p("notifications/progress"),params:fe}),Tt=g.extend({level:i,logger:a().optional(),data:O()}),Et=b.extend({method:p("notifications/message"),params:Tt}),Ye=d({uri:a(),mimeType:M(a()),_meta:z(a(),O()).optional()}),Me=Ye.extend({text:a()}),Qe=Ye.extend({blob:c}),Pe=d({audience:f(s).optional(),priority:y().min(0).max(1).optional(),lastModified:Fo({offset:!0}).optional()}),qe=d({...q.shape,...R.shape,uri:a(),description:M(a()),mimeType:M(a()),size:M(y()),annotations:Pe.optional(),_meta:M(j({}))}),Xe=d({...q.shape,...R.shape,uriTemplate:a(),description:M(a()),mimeType:M(a()),annotations:Pe.optional(),_meta:M(j({}))}),$e=b.extend({method:p("notifications/resources/list_changed"),params:g.optional()}),be=g.extend({uri:a()}),mt=b.extend({method:p("notifications/resources/updated"),params:be}),ft=d({name:a(),description:M(a()),required:M(w())}),et=d({...q.shape,...R.shape,description:M(a()),arguments:M(f(ft)),_meta:M(j({}))}),ge=b.extend({method:p("notifications/prompts/list_changed"),params:g.optional()}),ve=d({type:p("text"),text:a(),annotations:Pe.optional(),_meta:z(a(),O()).optional()}),ze=d({type:p("image"),data:c,mimeType:a(),annotations:Pe.optional(),_meta:z(a(),O()).optional()}),He=d({type:p("audio"),data:c,mimeType:a(),annotations:Pe.optional(),_meta:z(a(),O()).optional()}),Gt=d({type:p("tool_use"),name:a(),id:a(),input:z(a(),O()),_meta:z(a(),O()).optional()}),Ce=d({type:p("resource"),resource:x([Me,Qe]),annotations:Pe.optional(),_meta:z(a(),O()).optional()}),Ie=qe.extend({type:p("resource_link")}),Te=x([ve,ze,He,Ie,Ce]),je=d({role:s,content:Te}),Le=d({title:a().optional(),readOnlyHint:w().optional(),destructiveHint:w().optional(),idempotentHint:w().optional(),openWorldHint:w().optional()}),tt=b.extend({method:p("notifications/tools/list_changed"),params:g.optional()}),ot=d({name:a().optional()}),kt=d({hints:f(ot).optional(),costPriority:y().min(0).max(1).optional(),speedPriority:y().min(0).max(1).optional(),intelligencePriority:y().min(0).max(1).optional()}),rt=d({mode:F(["auto","required","none"]).optional()}),Wt=d({type:p("boolean"),title:a().optional(),description:a().optional(),default:w().optional()}),E=d({type:p("string"),title:a().optional(),description:a().optional(),minLength:y().optional(),maxLength:y().optional(),format:F(["email","uri","date","date-time"]).optional(),default:a().optional()}),nt=d({type:F(["number","integer"]),title:a().optional(),description:a().optional(),minimum:y().optional(),maximum:y().optional(),default:y().optional()}),L=d({type:p("string"),title:a().optional(),description:a().optional(),enum:f(a()),default:a().optional()}),I=d({type:p("string"),title:a().optional(),description:a().optional(),oneOf:f(d({const:a(),title:a()})),default:a().optional()}),J=d({type:p("string"),title:a().optional(),description:a().optional(),enum:f(a()),enumNames:f(a()).optional(),default:a().optional()}),k=x([L,I]),T=d({type:p("array"),title:a().optional(),description:a().optional(),minItems:y().optional(),maxItems:y().optional(),items:d({type:p("string"),enum:f(a())}),default:f(a()).optional()}),D=d({type:p("array"),title:a().optional(),description:a().optional(),minItems:y().optional(),maxItems:y().optional(),items:d({anyOf:f(d({const:a(),title:a()}))}),default:f(a()).optional()}),U=x([T,D]),le=x([J,k,U]),Kt=x([le,Wt,E,nt]),st=S.extend({mode:p("form").optional(),message:a(),requestedSchema:d({type:p("object"),properties:z(a(),Kt),required:f(a()).optional()}).catchall(O())}),Yt=d({type:p("ref/resource"),uri:a()}),Qt=d({type:p("ref/prompt"),name:a()}),xr=d({uri:a().startsWith("file://"),name:a().optional(),_meta:z(a(),O()).optional()}),$t=Y.shape,Pr=d({experimental:$t.experimental,sampling:$t.sampling,elicitation:$t.elicitation,roots:$t.roots,extensions:$t.extensions}),Ue=ue.shape,$o=d({experimental:Ue.experimental,logging:Ue.logging,completions:Ue.completions,prompts:Ue.prompts,resources:Ue.resources,tools:Ue.tools,extensions:Ue.extensions}),Co=j({progressToken:o.optional(),[po]:a(),[Bo]:V.optional(),[ho]:Pr,[Wo]:i.optional()}),Xt=d({...q.shape,...R.shape,description:a().optional(),inputSchema:j({$schema:a().optional(),type:p("object")}),outputSchema:j({$schema:a().optional()}).optional(),annotations:Le.optional(),_meta:z(a(),O()).optional()}),Tr=d({type:p("tool_result"),toolUseId:a(),content:f(Te),structuredContent:O().optional(),isError:w().optional(),_meta:z(a(),O()).optional()}),Io=x([ve,ze,He,Gt,Tr]),eo=d({role:s,content:x([Io,f(Io)]),_meta:z(a(),O()).optional()}),Oo=a(),No=j({[ct]:V.optional().catch(void 0)}),Ao=No.optional();function Se(ce){return j({_meta:Ao,resultType:Oo.default("complete"),...ce})}let Er=Se({}),Si=Se({nextCursor:r.optional()}),Mo=Se({content:f(Te),structuredContent:O().optional(),isError:w().optional()}),kr=Se({ttlMs:y().int().min(0),cacheScope:F(["public","private"]),tools:f(Xt),nextCursor:r.optional()}),$r=Se({ttlMs:y().int().min(0),cacheScope:F(["public","private"]),prompts:f(et),nextCursor:r.optional()}),Cr=Se({description:a().optional(),messages:f(je)}),Ir=Se({ttlMs:y().int().min(0),cacheScope:F(["public","private"]),resources:f(qe),nextCursor:r.optional()}),Or=Se({ttlMs:y().int().min(0),cacheScope:F(["public","private"]),resourceTemplates:f(Xe),nextCursor:r.optional()}),Nr=Se({ttlMs:y().int().min(0),cacheScope:F(["public","private"]),contents:f(x([Me,Qe]))}),Ar=Se({completion:d({values:f(a()).max(100),total:y().int().optional(),hasMore:w().optional()}).loose()}),_i=Se({ttlMs:y().int().min(0),cacheScope:F(["public","private"])}),Mr=Se({ttlMs:y().int().min(0).catch(0),cacheScope:F(["public","private"]).catch("private"),supportedVersions:f(a()),capabilities:$o,instructions:a().optional()}),Ct=d({messages:f(eo),modelPreferences:kt.optional(),systemPrompt:a().optional(),includeContext:F(["none","thisServer","allServers"]).optional(),temperature:y().optional(),maxTokens:y().int(),stopSequences:f(a()).optional(),metadata:t.optional(),tools:f(Xt).optional(),toolChoice:rt.optional()}),qr=d({method:p("sampling/createMessage"),params:Ct}),jr=d({method:p("roots/list"),params:d({_meta:z(a(),O()).optional()}).optional()}),Lr=d({...eo.shape,model:a(),stopReason:a().optional()}),Ur=d({roots:f(xr)}),Zr=d({action:F(["accept","decline","cancel"]),content:z(a(),x([a(),y(),w(),f(a())])).optional()}),Dr=d({mode:p("url"),message:a(),url:a().url()}),Vr=x([st,Dr]),Hr=d({method:p("elicitation/create"),params:Vr}),Fr=x([qr,jr,Hr]),Jr=x([Lr,Ur,Zr]),Br=z(a(),Fr),Gr=z(a(),Jr),to=Se({inputRequests:Br.optional(),requestState:a().optional()}),oo={inputResponses:Gr.optional(),requestState:a().optional()},yi=d({_meta:Co,...oo}),bi=j({progressToken:o.optional()});function Oe(ce,no){return d({method:p(ce),params:d({_meta:Co,...no})})}function Ne(ce,no){return d({method:p(ce),params:d({_meta:bi.optional(),...no}).optional()})}let Wr={name:a(),arguments:z(a(),O()).optional(),...oo},Fe={cursor:r.optional()},vi=Oe("tools/call",Wr),zi=Oe("tools/list",Fe),Ri=Oe("prompts/list",Fe),wi=Oe("prompts/get",{name:a(),arguments:z(a(),a()).optional(),...oo}),xi=Oe("resources/list",Fe),Pi=Oe("resources/templates/list",Fe),Ti=Oe("resources/read",{uri:a(),...oo}),Kr={ref:x([Qt,Yt]),argument:d({name:a(),value:a()}),context:d({arguments:z(a(),a()).optional()}).optional()},Ei=Oe("completion/complete",Kr),ki=Oe("server/discover",{}),qo=d({toolsListChanged:w().optional(),promptsListChanged:w().optional(),resourcesListChanged:w().optional(),resourceSubscriptions:f(a()).optional()}),Yr={notifications:qo},$i=Oe("subscriptions/listen",Yr),Ci=No.extend({"io.modelcontextprotocol/subscriptionId":n}),Qr=j({_meta:Ci,resultType:Oo.default("complete")}),It={"tools/call":Ne("tools/call",Wr),"tools/list":Ne("tools/list",Fe),"prompts/get":Ne("prompts/get",{name:a(),arguments:z(a(),a()).optional()}),"prompts/list":Ne("prompts/list",Fe),"resources/list":Ne("resources/list",Fe),"resources/templates/list":Ne("resources/templates/list",Fe),"resources/read":Ne("resources/read",{uri:a()}),"completion/complete":Ne("completion/complete",Kr),"server/discover":Ne("server/discover",{}),"subscriptions/listen":Ne("subscriptions/listen",Yr)};function Ee(ce){return j({_meta:Ao,...ce})}let Ii={"tools/call":Ee({content:f(Te),structuredContent:O().optional(),isError:w().optional()}),"tools/list":Ee({ttlMs:y().int().min(0),cacheScope:F(["public","private"]),tools:f(Xt),nextCursor:r.optional()}),"prompts/get":Ee({description:a().optional(),messages:f(je)}),"prompts/list":Ee({ttlMs:y().int().min(0),cacheScope:F(["public","private"]),prompts:f(et),nextCursor:r.optional()}),"resources/list":Ee({ttlMs:y().int().min(0),cacheScope:F(["public","private"]),resources:f(qe),nextCursor:r.optional()}),"resources/templates/list":Ee({ttlMs:y().int().min(0),cacheScope:F(["public","private"]),resourceTemplates:f(Xe),nextCursor:r.optional()}),"resources/read":Ee({ttlMs:y().int().min(0),cacheScope:F(["public","private"]),contents:f(x([Me,Qe]))}),"completion/complete":Ee({completion:d({values:f(a()).max(100),total:y().int().optional(),hasMore:w().optional()}).loose()}),"server/discover":Ee({ttlMs:y().int().min(0).catch(0),cacheScope:F(["public","private"]).catch("private"),supportedVersions:f(a()),capabilities:$o,instructions:a().optional()}),"subscriptions/listen":Ee({})},ro=j({"io.modelcontextprotocol/subscriptionId":n.optional()}),jo=d({method:p("notifications/subscriptions/acknowledged"),params:d({_meta:ro.optional(),notifications:qo})}),Lo=d({_meta:ro.optional(),requestId:n,reason:a().optional()}),Uo=d({method:p("notifications/cancelled"),params:Lo}),Va={"notifications/cancelled":Uo,"notifications/progress":Ve,"notifications/message":Et,"notifications/resources/updated":mt,"notifications/resources/list_changed":$e,"notifications/tools/list_changed":tt,"notifications/prompts/list_changed":ge,"notifications/subscriptions/acknowledged":jo},Re=(ce)=>d({jsonrpc:p("2.0"),id:x([a(),y().int()]),result:ce}).strict();return{JSONValueSchema:e,JSONObjectSchema:t,ProgressTokenSchema:o,CursorSchema:r,RequestIdSchema:n,RoleSchema:s,LoggingLevelSchema:i,TaskMetadataSchema:l,RelatedTaskMetadataSchema:u,RequestMetaSchema:h,BaseRequestParamsSchema:m,TaskAugmentedRequestParamsSchema:S,NotificationsParamsSchema:g,NotificationSchema:b,IconSchema:v,IconsSchema:R,BaseMetadataSchema:q,ImplementationSchema:V,ClientTasksCapabilitySchema:B,ServerTasksCapabilitySchema:G,ClientCapabilitiesSchema:Y,ServerCapabilitiesSchema:ue,ProgressSchema:oe,ProgressNotificationParamsSchema:fe,ProgressNotificationSchema:Ve,LoggingMessageNotificationParamsSchema:Tt,LoggingMessageNotificationSchema:Et,ResourceContentsSchema:Ye,TextResourceContentsSchema:Me,BlobResourceContentsSchema:Qe,AnnotationsSchema:Pe,ResourceSchema:qe,ResourceTemplateSchema:Xe,ResourceListChangedNotificationSchema:$e,ResourceUpdatedNotificationParamsSchema:be,ResourceUpdatedNotificationSchema:mt,PromptArgumentSchema:ft,PromptSchema:et,PromptListChangedNotificationSchema:ge,TextContentSchema:ve,ImageContentSchema:ze,AudioContentSchema:He,ToolUseContentSchema:Gt,EmbeddedResourceSchema:Ce,ResourceLinkSchema:Ie,ContentBlockSchema:Te,PromptMessageSchema:je,ToolAnnotationsSchema:Le,ToolListChangedNotificationSchema:tt,ModelHintSchema:ot,ModelPreferencesSchema:kt,ToolChoiceSchema:rt,BooleanSchemaSchema:Wt,StringSchemaSchema:E,NumberSchemaSchema:nt,UntitledSingleSelectEnumSchemaSchema:L,TitledSingleSelectEnumSchemaSchema:I,LegacyTitledEnumSchemaSchema:J,SingleSelectEnumSchemaSchema:k,UntitledMultiSelectEnumSchemaSchema:T,TitledMultiSelectEnumSchemaSchema:D,MultiSelectEnumSchemaSchema:U,EnumSchemaSchema:le,PrimitiveSchemaDefinitionSchema:Kt,ElicitRequestFormParamsSchema:st,ResourceTemplateReferenceSchema:Yt,PromptReferenceSchema:Qt,RootSchema:xr,ClientCapabilities2026Schema:Pr,ServerCapabilities2026Schema:$o,RequestMetaEnvelopeSchema:Co,ToolSchema:Xt,ToolResultContentSchema:Tr,SamplingMessageContentBlockSchema:Io,SamplingMessageSchema:eo,ResultTypeSchema:Oo,ResultMetaSchema:No,ResultSchema:Er,PaginatedResultSchema:Si,CallToolResultSchema:Mo,ListToolsResultSchema:kr,ListPromptsResultSchema:$r,GetPromptResultSchema:Cr,ListResourcesResultSchema:Ir,ListResourceTemplatesResultSchema:Or,ReadResourceResultSchema:Nr,CompleteResultSchema:Ar,CacheableResultSchema:_i,DiscoverResultSchema:Mr,CreateMessageRequestParamsSchema:Ct,CreateMessageRequestSchema:qr,ListRootsRequestSchema:jr,CreateMessageResultSchema:Lr,ListRootsResultSchema:Ur,ElicitResultSchema:Zr,ElicitRequestURLParamsSchema:Dr,ElicitRequestParamsSchema:Vr,ElicitRequestSchema:Hr,InputRequestSchema:Fr,InputResponseSchema:Jr,InputRequestsSchema:Br,InputResponsesSchema:Gr,InputRequiredResultSchema:to,InputResponseRequestParamsSchema:yi,CallToolRequestSchema:vi,ListToolsRequestSchema:zi,ListPromptsRequestSchema:Ri,GetPromptRequestSchema:wi,ListResourcesRequestSchema:xi,ListResourceTemplatesRequestSchema:Pi,ReadResourceRequestSchema:Ti,CompleteRequestSchema:Ei,DiscoverRequestSchema:ki,SubscriptionFilterSchema:qo,SubscriptionsListenRequestSchema:$i,SubscriptionsListenResultMetaSchema:Ci,SubscriptionsListenResultSchema:Qr,dispatchRequestSchemas:It,dispatchResultSchemas:Ii,NotificationMetaSchema:ro,SubscriptionsAcknowledgedNotificationSchema:jo,CancelledNotificationParamsSchema:Lo,CancelledNotificationSchema:Uo,notificationSchemas2026:Va,JSONRPCResultResponseSchema:Re(Er),CallToolResultResponseSchema:Re(x([Mo,to])),ListToolsResultResponseSchema:Re(kr),ListPromptsResultResponseSchema:Re($r),GetPromptResultResponseSchema:Re(x([Cr,to])),ListResourcesResultResponseSchema:Re(Ir),ListResourceTemplatesResultResponseSchema:Re(Or),ReadResourceResultResponseSchema:Re(x([Nr,to])),CompleteResultResponseSchema:Re(Ar),DiscoverResultResponseSchema:Re(Mr),SubscriptionsListenResultResponseSchema:Re(Qr)}}var vS;function Ht(){return vS??=bS()}var zS=["tools/list","prompts/list","resources/list","resources/templates/list","resources/read","server/discover"];function RS(e){return zS.includes(e)}var Sl=Symbol("modelcontextprotocol.resultCacheHintFallback");function wS(e){return e[Sl]}function Rm(e){return typeof e==="number"&&Number.isSafeInteger(e)&&e>=0}function wm(e){return e==="public"||e==="private"}var Z=function(e){return 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.ResourceNotFound=-32002]="ResourceNotFound",e[e.MissingRequiredClientCapability=-32021]="MissingRequiredClientCapability",e[e.UnsupportedProtocolVersion=-32022]="UnsupportedProtocolVersion",e[e.UrlElicitationRequired=-32042]="UrlElicitationRequired",e}({}),K=class e extends Error{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.ProtocolError"})}static[Symbol.hasInstance](t){return ke(this,t)}static isInstance(t){if(typeof this!=="function")throw TypeError("isInstance must be called on the class (e.g. `SdkError.isInstance(value)`); for callbacks use `v => SdkError.isInstance(v)`");return ke(this,t)}constructor(t,o,r){super(o);this.code=t,this.data=r,this.name="ProtocolError",Ft(this,new.target)}static fromError(t,o,r){if(t===Z.UrlElicitationRequired&&r){let n=r;if(n.elicitations)return new Pm(n.elicitations,o)}if(t===Z.UnsupportedProtocolVersion&&r){let n=r;if(Array.isArray(n.supported)&&typeof n.requested==="string")return new ci({supported:n.supported,requested:n.requested},o)}if(t===Z.InvalidParams||t===Z.ResourceNotFound){let n=r;if(typeof n?.uri==="string"&&(t===Z.ResourceNotFound||Object.keys(n).length===1))return new xm(n.uri,o)}if(t===Z.MissingRequiredClientCapability&&r){let n=r;if(n.requiredCapabilities!==null&&typeof n.requiredCapabilities==="object"&&!Array.isArray(n.requiredCapabilities))return new Tm({requiredCapabilities:n.requiredCapabilities},o)}return new e(t,o,r)}},xm=class extends K{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.ResourceNotFoundError"})}constructor(e,t=`Resource not found: ${e}`){super(Z.InvalidParams,t,{uri:e})}get uri(){return this.data.uri}},Pm=class extends K{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.UrlElicitationRequiredError"})}constructor(e,t=`URL elicitation${e.length>1?"s":""} required`){super(Z.UrlElicitationRequired,t,{elicitations:e})}get elicitations(){return this.data?.elicitations??[]}},ci=class extends K{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.UnsupportedProtocolVersionError"})}constructor(e,t=`Unsupported protocol version: ${e.requested}`){super(Z.UnsupportedProtocolVersion,t,e)}get supported(){return this.data.supported}get requested(){return this.data.requested}},Tm=class extends K{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.MissingRequiredClientCapabilityError"})}constructor(e,t=`Missing required client capabilities: ${Object.keys(e.requiredCapabilities).join(", ")}`){super(Z.MissingRequiredClientCapability,t,e)}get requiredCapabilities(){return this.data.requiredCapabilities}},xS=0,PS="private",TS=["tools/call","prompts/get","resources/read"];function ES(e,t){let o=t.resultType;if(o===void 0)return{...t,resultType:"complete"};if(o==="complete")return t;if(TS.includes(e))return t;throw new K(Z.InternalError,`Handler for ${e} returned resultType '${String(o)}', but results of ${e} only support 'complete' on protocol revision 2026-07-28`)}function kS(e,t){let o=wS(t);if(t.resultType!=="complete"||!RS(e))return o===void 0?t:NS(t);let r=t,n=Rm(r.ttlMs)?r.ttlMs:IS(o),s=wm(r.cacheScope)?r.cacheScope:OS(o),i={...r,ttlMs:n,cacheScope:s};return delete i[Sl],i}function $S(e){return e!==null&&typeof e==="object"&&!Array.isArray(e)}function CS(e,t){if(t===void 0)return e;let o=e._meta;if(o===void 0)return{...e,_meta:{[ct]:t}};if(!$S(o))return e;if(o[ct]!==void 0)return e;return{...e,_meta:{...o,[ct]:t}}}function IS(e){return e!==void 0&&Rm(e.ttlMs)?e.ttlMs:xS}function OS(e){return e!==void 0&&wm(e.cacheScope)?e.cacheScope:PS}function NS(e){let t={...e};return delete t[Sl],t}var AS=["elicitation/create","sampling/createMessage","roots/list"],Ia;function Em(){if(Ia)return Ia;let e=Ht();return Ia={request:{"elicitation/create":d({method:p("elicitation/create"),params:e.ElicitRequestParamsSchema}),"sampling/createMessage":d({method:p("sampling/createMessage"),params:e.CreateMessageRequestParamsSchema}),"roots/list":d({method:p("roots/list"),params:j({}).optional()})},response:{"elicitation/create":e.ElicitResultSchema,"sampling/createMessage":e.CreateMessageResultSchema,"roots/list":e.ListRootsResultSchema}},Ia}function km(e){return AS.includes(e)}function nl(e){return km(e)?Em().request[e]:void 0}function MS(e){return km(e)?Em().response[e]:void 0}var _l={"tools/call":null,"tools/list":null,"prompts/get":null,"prompts/list":null,"resources/list":null,"resources/templates/list":null,"resources/read":null,"completion/complete":null,"server/discover":null,"subscriptions/listen":null},$m={"notifications/cancelled":null,"notifications/progress":null,"notifications/message":null,"notifications/resources/updated":null,"notifications/resources/list_changed":null,"notifications/tools/list_changed":null,"notifications/prompts/list_changed":null,"notifications/subscriptions/acknowledged":null};function Cm(e){return Object.prototype.hasOwnProperty.call(_l,e)}function Im(e){return Object.prototype.hasOwnProperty.call($m,e)}function qS(e){return Object.prototype.hasOwnProperty.call(_l,e)}function jS(e){return Cm(e)?Ht().dispatchRequestSchemas[e]:void 0}function LS(e){return qS(e)?Ht().dispatchResultSchemas[e]:void 0}function US(e){return Im(e)?Ht().notificationSchemas2026[e]:void 0}var Lz=Object.keys(_l),Uz=Object.keys($m);function ri(e){return e!==null&&typeof e==="object"&&!Array.isArray(e)}function ti(e,t){if(e===void 0)return{ok:!1,reason:"not-in-era"};let o=e.safeParse(t);return o.success?{ok:!0,value:o.data}:{ok:!1,reason:"invalid",message:String(o.error)}}var ZS={ok:!1,reason:"not-in-era"},DS=[po,ho];function VS(e,t){let o=t,r=!1,n=()=>{if(!r)o={...o},r=!0;return o},s=t.tools;if(e==="tools/list"&&Array.isArray(s)&&s.some((c)=>ri(c)&&("execution"in c)))n().tools=s.map((c)=>{if(!ri(c)||!("execution"in c))return c;let l={...c};return delete l.execution,l});let i=t.capabilities;if(ri(i)&&"tasks"in i){let c={...i};delete c.tasks,n().capabilities=c}return o}var yl={era:"2026-07-28",hasRequestMethod:Cm,hasNotificationMethod:Im,hasInputRequestMethod:(e)=>nl(e)!==void 0,validateRequest:(e,t)=>ti(jS(e),t),validateResult:(e,t)=>ti(LS(e),t),validateNotification:(e,t)=>ti(US(e),t),validateInputRequest:(e,t)=>ti(nl(e),t),validateInputResponse:(e,t)=>ti(MS(e),t),samplingResultVariant:()=>ZS,outboundEnvelope(e){return{[po]:e.protocolVersion,[Bo]:e.clientInfo,[ho]:e.clientCapabilities,...e.logLevel!==void 0&&{[Wo]:e.logLevel}}},validateEnvelopeMeta(e){let t=[];for(let r of DS)if(!(r in e))t.push({key:r,problem:"missing"});let o=Ht().RequestMetaEnvelopeSchema.safeParse(e);if(!o.success)for(let r of o.error.issues){let n=r.path.map(String),s=n.length>0?n.join("."):"_meta";if(n.length===1&&t.some((i)=>i.key===s&&i.problem==="missing"))continue;t.push({key:s,problem:r.message})}return t},projectCallToolResult:(e)=>fm(e),inputRequestSchema:nl,decodeResult(e,t){if(!ri(t))return{kind:"invalid",error:new C(A.InvalidResult,`Invalid result for ${e}: not an object`,{method:e})};let o=t.resultType;if(o===void 0)return{kind:"invalid",error:new C(A.InvalidResult,`Invalid result for ${e}: missing required resultType — servers implementing protocol revision 2026-07-28 MUST include it (the absent-means-complete bridge applies only to earlier-revision servers)`,{method:e,violation:"missing-resultType"})};if(typeof o!=="string")return{kind:"invalid",error:new C(A.InvalidResult,`Invalid result for ${e}: non-string resultType`,{method:e,resultType:o})};if(o==="input_required"){let i=t.inputRequests,c=ri(i)?i:{},l=t.requestState,u=t._meta===void 0?void 0:Ht().ResultMetaSchema.safeParse(t._meta),h=u?.success?u.data:void 0;if(Object.keys(c).length===0&&typeof l!=="string")return{kind:"invalid",error:new C(A.InvalidResult,`Invalid result for ${e}: input_required carries neither inputRequests nor requestState (every input_required result must include at least one of the two)`,{method:e,violation:"input-required-missing-both"})};return{kind:"input_required",inputRequests:c,...typeof l==="string"&&{requestState:l},...h!==void 0&&{_meta:h}}}if(o!=="complete")return{kind:"invalid",error:new C(A.UnsupportedResultType,`Unsupported result type '${o}' for ${e}`,{resultType:o,method:e})};let r=HS(),n=Object.hasOwn(r,e)?r[e]:void 0;if(n!==void 0){let i=n.safeParse(t);if(!i.success)return{kind:"invalid",error:new C(A.InvalidResult,`Invalid result for ${e}: ${i.error}`,{method:e})}}let s={...t};return delete s.resultType,{kind:"complete",result:s}},encodeResult(e,t,o){return CS(kS(e,ES(e,VS(e,t))),o)},encodeErrorCode:(e)=>e===-32002?-32602:e,checkInboundEnvelope(e){if(e.envelope===void 0)return"Request is missing the required _meta envelope for protocol revision 2026-07-28 (io.modelcontextprotocol/protocolVersion, io.modelcontextprotocol/clientCapabilities)";let t=Ht().RequestMetaEnvelopeSchema.safeParse(e.envelope);if(!t.success)return`Invalid _meta envelope for protocol revision 2026-07-28: ${t.error.issues.map((o)=>o.message).join("; ")}`}},Oa;function HS(){if(Oa)return Oa;let e=Ht();return Oa={"tools/call":e.CallToolResultSchema,"tools/list":e.ListToolsResultSchema,"prompts/get":e.GetPromptResultSchema,"prompts/list":e.ListPromptsResultSchema,"resources/list":e.ListResourcesResultSchema,"resources/templates/list":e.ListResourceTemplatesResultSchema,"resources/read":e.ReadResourceResultSchema,"completion/complete":e.CompleteResultSchema,"server/discover":e.DiscoverResultSchema},Oa}var Ma="2026-07-28";function wt(e){return e!==void 0&&xt(e)?yl:gl}function sm(e){if(e.revision!==void 0)return wt(e.revision).era;return e.era==="modern"?yl.era:gl.era}function sl(e){return Om.some((t)=>t.hasRequestMethod(e))}function il(e){return Om.some((t)=>t.hasNotificationMethod(e))}function im(e){return e==="tasks/get"||e==="tasks/cancel"}var Om=[gl,yl],FS=Vl({AnnotationsSchema:()=>ut,AudioContentSchema:()=>vo,BaseMetadataSchema:()=>at,BaseRequestParamsSchema:()=>de,BlobResourceContentsSchema:()=>cr,BooleanSchemaSchema:()=>pr,CallToolRequestParamsSchema:()=>us,CallToolRequestSchema:()=>ds,CallToolResultSchema:()=>Vt,CancelTaskRequestSchema:()=>ba,CancelTaskResultSchema:()=>va,CancelledNotificationParamsSchema:()=>_n,CancelledNotificationSchema:()=>or,ClientCapabilitiesSchema:()=>bn,ClientNotificationSchema:()=>Ra,ClientRequestSchema:()=>za,ClientResultSchema:()=>wa,ClientTasksCapabilitySchema:()=>ca,CompatibilityCallToolResultSchema:()=>ua,CompleteRequestParamsSchema:()=>Ls,CompleteRequestSchema:()=>Us,CompleteResultSchema:()=>Zs,ContentBlockSchema:()=>dt,CreateMessageRequestParamsSchema:()=>ws,CreateMessageRequestSchema:()=>xs,CreateMessageResultSchema:()=>Ps,CreateMessageResultWithToolsSchema:()=>Ts,CreateTaskResultSchema:()=>pa,CursorSchema:()=>Yo,DiscoverRequestSchema:()=>xn,DiscoverResultSchema:()=>Zt,ElicitRequestFormParamsSchema:()=>Po,ElicitRequestParamsSchema:()=>Is,ElicitRequestSchema:()=>Os,ElicitRequestURLParamsSchema:()=>Cs,ElicitResultSchema:()=>Ms,ElicitationCompleteNotificationParamsSchema:()=>Ns,ElicitationCompleteNotificationSchema:()=>As,EmbeddedResourceSchema:()=>zo,EmptyResultSchema:()=>Ut,EnumSchemaSchema:()=>$s,GetPromptRequestParamsSchema:()=>es,GetPromptRequestSchema:()=>ts,GetPromptResultSchema:()=>ns,GetTaskPayloadRequestSchema:()=>ga,GetTaskPayloadResultSchema:()=>Sa,GetTaskRequestSchema:()=>ma,GetTaskResultSchema:()=>fa,IconSchema:()=>yn,IconsSchema:()=>yt,ImageContentSchema:()=>bo,ImplementationSchema:()=>lt,InitializeRequestParamsSchema:()=>vn,InitializeRequestSchema:()=>zn,InitializeResultSchema:()=>Rn,InitializedNotificationSchema:()=>wn,JSONArraySchema:()=>ia,JSONObjectSchema:()=>ne,JSONRPCErrorResponseSchema:()=>go,JSONRPCMessageSchema:()=>So,JSONRPCNotificationSchema:()=>tr,JSONRPCRequestSchema:()=>er,JSONRPCResponseSchema:()=>aa,JSONRPCResultResponseSchema:()=>fo,JSONValueSchema:()=>_t,LegacyTitledEnumSchemaSchema:()=>fr,ListChangedOptionsBaseSchema:()=>hs,ListPromptsRequestSchema:()=>Qn,ListPromptsResultSchema:()=>Xn,ListResourceTemplatesRequestSchema:()=>In,ListResourceTemplatesResultSchema:()=>On,ListResourcesRequestSchema:()=>$n,ListResourcesResultSchema:()=>Cn,ListRootsRequestSchema:()=>Vs,ListRootsResultSchema:()=>Hs,ListTasksRequestSchema:()=>_a,ListTasksResultSchema:()=>ya,ListToolsRequestSchema:()=>cs,ListToolsResultSchema:()=>ls,LoggingLevelSchema:()=>dr,LoggingMessageNotificationParamsSchema:()=>gs,LoggingMessageNotificationSchema:()=>Ss,ModelHintSchema:()=>_s,ModelPreferencesSchema:()=>ys,MultiSelectEnumSchemaSchema:()=>ks,NotificationSchema:()=>me,NotificationsParamsSchema:()=>ye,NumberSchemaSchema:()=>xo,PaginatedRequestParamsSchema:()=>En,PaginatedRequestSchema:()=>bt,PaginatedResultSchema:()=>vt,PingRequestSchema:()=>nr,PrimitiveSchemaDefinitionSchema:()=>_r,ProgressNotificationParamsSchema:()=>Tn,ProgressNotificationSchema:()=>sr,ProgressSchema:()=>Pn,ProgressTokenSchema:()=>Ko,PromptArgumentSchema:()=>Kn,PromptListChangedNotificationSchema:()=>ss,PromptMessageSchema:()=>rs,PromptReferenceSchema:()=>js,PromptSchema:()=>Yn,ReadResourceRequestParamsSchema:()=>Nn,ReadResourceRequestSchema:()=>An,ReadResourceResultSchema:()=>Mn,RelatedTaskMetadataSchema:()=>Sn,RequestIdSchema:()=>Ge,RequestMetaSchema:()=>Qo,RequestSchema:()=>se,ResourceContentsSchema:()=>ir,ResourceLinkSchema:()=>Ro,ResourceListChangedNotificationSchema:()=>qn,ResourceRequestParamsSchema:()=>_o,ResourceSchema:()=>lr,ResourceTemplateReferenceSchema:()=>qs,ResourceTemplateSchema:()=>kn,ResourceUpdatedNotificationParamsSchema:()=>Gn,ResourceUpdatedNotificationSchema:()=>Wn,ResultMetaObjectSchema:()=>Xo,ResultSchema:()=>ie,RoleSchema:()=>zt,RootSchema:()=>Ds,RootsListChangedNotificationSchema:()=>Fs,SamplingContentSchema:()=>zs,SamplingMessageContentBlockSchema:()=>jt,SamplingMessageSchema:()=>Rs,ServerCapabilitiesSchema:()=>rr,ServerNotificationSchema:()=>Pa,ServerRequestSchema:()=>xa,ServerResultSchema:()=>Ta,ServerTasksCapabilitySchema:()=>la,SetLevelRequestParamsSchema:()=>ms,SetLevelRequestSchema:()=>fs,SingleSelectEnumSchemaSchema:()=>Es,StringSchemaSchema:()=>wo,SubscribeRequestParamsSchema:()=>jn,SubscribeRequestSchema:()=>Ln,SubscriptionFilterSchema:()=>ur,SubscriptionsAcknowledgedNotificationParamsSchema:()=>Hn,SubscriptionsAcknowledgedNotificationSchema:()=>Fn,SubscriptionsListenRequestParamsSchema:()=>Dn,SubscriptionsListenRequestSchema:()=>Vn,SubscriptionsListenResultMetaSchema:()=>Jn,SubscriptionsListenResultSchema:()=>Bn,TaskAugmentedRequestParamsSchema:()=>Lt,TaskCreationParamsSchema:()=>da,TaskMetadataSchema:()=>gn,TaskSchema:()=>Rt,TaskStatusNotificationParamsSchema:()=>Bs,TaskStatusNotificationSchema:()=>ha,TaskStatusSchema:()=>Js,TextContentSchema:()=>yo,TextResourceContentsSchema:()=>ar,TitledMultiSelectEnumSchemaSchema:()=>Sr,TitledSingleSelectEnumSchemaSchema:()=>mr,ToolAnnotationsSchema:()=>is,ToolChoiceSchema:()=>bs,ToolExecutionSchema:()=>as,ToolListChangedNotificationSchema:()=>ps,ToolResultContentSchema:()=>vs,ToolSchema:()=>Dt,ToolUseContentSchema:()=>os,UnsubscribeRequestParamsSchema:()=>Un,UnsubscribeRequestSchema:()=>Zn,UntitledMultiSelectEnumSchemaSchema:()=>gr,UntitledSingleSelectEnumSchemaSchema:()=>hr});var qa=(e)=>er.safeParse(e).success,Nm=(e)=>tr.safeParse(e).success,Rr=(e)=>fo.safeParse(e).success,li=(e)=>go.safeParse(e).success;var Am=(e)=>typeof e==="object"&&e!==null&&!Array.isArray(e)&&e.resultType==="input_required";var JS="Mcp-Param-",am="x-mcp-header",BS=/^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/,GS=new Set(["string","integer","boolean"]);function bl(e){let t=[],o=new Map,r,n=(i,c,l)=>{if(i===null||typeof i!=="object")return;let u=i;if(am in u){if(!l||c.length===0)return`${Na(c)}: x-mcp-header is only permitted on properties statically reachable via a chain of 'properties' keys (not under items, additionalProperties, oneOf/anyOf/allOf/not, if/then/else, or $ref)`;let m=u[am];if(typeof m!=="string"||m.length===0)return`${Na(c)}: x-mcp-header MUST be a non-empty string`;if(!BS.test(m))return`${Na(c)}: x-mcp-header '${m}' is not a valid RFC 9110 token (no spaces, control characters or HTTP delimiters)`;let S=typeof u.type==="string"?u.type:void 0;if(S===void 0||!GS.has(S)){let v=`${Na(c)}: x-mcp-header is only permitted on primitive-typed properties (string, integer, boolean); got ${S??"<none>"}`;if(S!=="number")return v;r??=v}let g=m.toLowerCase(),b=o.get(g);if(b!==void 0)return`x-mcp-header '${m}' is not case-insensitively unique (also declared as '${b}')`;o.set(g,m),t.push({path:c,headerName:m,type:S})}let h=u.properties;if(h!==null&&typeof h==="object")for(let[m,S]of Object.entries(h)){let g=n(S,[...c,m],l);if(g!==void 0)return g}for(let m of WS){let S=u[m];if(S===void 0)continue;let g=Array.isArray(S)?S:S!==null&&typeof S==="object"&&KS.has(m)?Object.values(S):[S];for(let b of g){let v=n(b,[...c,`<${m}>`],!1);if(v!==void 0)return v}}},s=n(e,[],!0);if(s!==void 0)return{valid:!1,reason:r??s};return r===void 0?{valid:!0,declarations:t}:{valid:!1,reason:r,declarations:t}}var WS=["items","prefixItems","contains","additionalProperties","unevaluatedProperties","unevaluatedItems","propertyNames","patternProperties","dependentSchemas","oneOf","anyOf","allOf","not","if","then","else","$defs","definitions"],KS=new Set(["patternProperties","dependentSchemas","$defs","definitions"]);function Na(e){return e.length===0?"<root>":e.join(".")}var Mm="=?base64?",qm="?=";function YS(e){if(typeof e==="string")return e;if(typeof e==="boolean")return e?"true":"false";if(typeof e==="number"){if(!Number.isFinite(e))return;if(Number.isInteger(e)&&!Number.isSafeInteger(e))return;return String(e)}}function QS(e){if(e.length===0)return!0;if(e.startsWith(Mm)&&e.endsWith(qm))return!0;if(e!==e.trim())return!0;for(let t=0;t<e.length;t++){let o=e.codePointAt(t);if(o===9||o>=32&&o<=126)continue;return!0}return!1}function XS(e){let t=new TextEncoder().encode(e),o="";for(let r of t)o+=String.fromCodePoint(r);return btoa(o)}function jm(e){return QS(e)?`${Mm}${XS(e)}${qm}`:e}function e_(e,t){let o=e;for(let r of t){if(o===null||typeof o!=="object")return;o=o[r]}return o}function Lm(e,t){let o={};for(let r of e){let n=e_(t,r.path);if(n===void 0||n===null)continue;let s=YS(n);if(s===void 0)continue;o[`${JS}${r.headerName}`]=jm(s)}return o}var zr=-32020,Zz=[{rung:"http-method",order:1,evaluatedAt:"edge",codes:[-32000],conformance:[],rationale:"The modern era is POST-only; GET/DELETE are body-less 2025-era session operations and are method-routed to legacy serving (405 when legacy serving is not configured), before any body is read."},{rung:"jsonrpc-shape",order:2,evaluatedAt:"edge",codes:[Z.InvalidRequest],conformance:["server-stateless"],rationale:"The body must be a JSON-RPC request or notification: posted responses and batch arrays containing a modern or invalid element are rejected before classification (element-wise batch rule); all-legacy arrays stay legacy traffic."},{rung:"era-classification",order:3,evaluatedAt:"edge",codes:[zr,Z.UnsupportedProtocolVersion],conformance:["server-stateless","http-header-validation","http-custom-header-server-validation"],rationale:"Body-primary era classification with the protocol-version header as a cross-check; a header/body disagreement is rejected with -32020 (HeaderMismatch), and an envelope-less request on a modern-only endpoint is answered with the unsupported-protocol-version error naming the supported revisions."},{rung:"envelope",order:4,evaluatedAt:"edge",codes:[Z.InvalidParams],conformance:["server-stateless"],rationale:"A present envelope claim with a malformed envelope — and a missing envelope on a request whose protocol-version header names a modern revision — is an invalid-params rejection naming the offending or missing key(s); never a silent fall back to legacy handling. This is the only place an invalid-params rejection maps to HTTP 400."},{rung:"method-registry",order:5,evaluatedAt:"dispatch",codes:[Z.MethodNotFound],conformance:["server-stateless"],rationale:"Method existence outranks parameter validity: a method absent from the negotiated revision’s registry (or with no handler installed) answers method-not-found before params or capabilities are looked at."},{rung:"request-params",order:6,evaluatedAt:"dispatch",codes:[Z.InvalidParams],conformance:[],rationale:"Per-method params validation; emitted in-band by the dispatch layer (HTTP 200), never via the ladder status table."},{rung:"standard-header-validation",order:7,evaluatedAt:"pre-dispatch",codes:[zr],conformance:["http-header-validation"],rationale:"SEP-2243 standard `MCP-Protocol-Version` / `Mcp-Method` / `Mcp-Name` headers — presence, sentinel decoding, and `Mcp-Name` ↔ body cross-check — are validated by the HTTP entry on a modern-classified request after the supported-revision gate and before dispatch. The spec requires `MCP-Protocol-Version` and `Mcp-Method` on every modern *request* POST (`Mcp-Name` only for the methods that mirror `params.name` / `params.uri` / `params.taskId`, see `MCP_NAME_HEADER_SOURCE`) and names them in that order, so a request missing several is answered by the earliest. Notification POSTs are exempt: the presence half runs on requests only, so a modern-enveloped notification is dispatched even with no standard headers at all. The classifier’s own header-mismatch cells (protocol-version, `Mcp-Method` mismatch) stay on the edge `era-classification` rung; this rung carries the entry-layer presence/`Mcp-Name` half — including the missing `MCP-Protocol-Version` cell, which cannot live on the edge rung without breaking body-primary classification. Evaluated before the capability gate, the factory call, and the `Mcp-Param-*` rung so a request that fails several rungs is answered by the standard-header rung first. The documented order (after method-registry 5 and request-params 6) is NOT the observed precedence: serveModern evaluates this rung immediately after the supported-revision gate, so a request that also fails a dispatch rung is answered here before the dispatch rungs (5–6) are consulted."},{rung:"client-capabilities",order:8,evaluatedAt:"pre-dispatch",codes:[Z.MissingRequiredClientCapability],conformance:["server-stateless"],rationale:"The capability requirement is checked by the HTTP entry, pre-dispatch, against the validated envelope the classifier produced — pinning the spec-mandated HTTP 400 independently of how dispatch- and handler-produced errors are mapped. The documented order (after method resolution and params validation) is preserved observably only while the requirement table is empty: once a served method gains a requirement entry, a request that is missing the capability and would also fail a dispatch rung is answered by this gate first, so the entry must consult the method registry before the gate if the documented precedence is to stay observable."},{rung:"param-header-validation",order:9,evaluatedAt:"pre-dispatch",codes:[zr],conformance:["http-custom-header-server-validation"],rationale:"SEP-2243 `Mcp-Param-*` headers are validated against the named tool’s `x-mcp-header` declarations and the body `arguments` after the tool registry is known and before dispatch reaches the handler; a missing/disagreeing/malformed header is rejected 400 / -32020 with the same shape as the standard-header cross-checks. The documented order (after method resolution and params validation) is preserved observably only when the body `arguments` would otherwise validate: the check runs pre-dispatch, so a `tools/call` that fails BOTH this rung and a dispatch-time rung (e.g. order-6 `request-params`, -32602) is answered by this gate first with 400 / -32020, not by the earlier-ordered rung."}],Dz={[Z.ParseError]:400,[Z.InvalidRequest]:400,[Z.MethodNotFound]:404,[Z.UnsupportedProtocolVersion]:400,[Z.MissingRequiredClientCapability]:400,[zr]:400};function ja(e,t){return Xi(e,t)}function oi(e){return new Set(e.flatMap((t)=>Object.keys(t.shape)))}function ul(e){if(e==null)return!1;let t=typeof e;if(t!=="object"&&t!=="function")return!1;if(!("~standard"in e))return!1;return typeof e["~standard"]?.validate==="function"}var cm=!1,dl="draft-2020-12";function t_(e,t="input"){let o=e["~standard"],r;if(o.jsonSchema)r=o.jsonSchema[t]({target:dl});else if(o.vendor==="zod"){if(!("_zod"in e))throw Error("Schema appears to be from zod 3, which the SDK cannot convert to JSON Schema. Upgrade to zod >=4.2.0, or wrap your JSON Schema with fromJsonSchema().");if(!cm)cm=!0,console.warn("[mcp-sdk] Your zod version does not implement `~standard.jsonSchema` (added in zod 4.2.0). Falling back to z.toJSONSchema(). Upgrade to zod >=4.2.0 to silence this warning.");r=Yi(e,{target:dl,io:t})}else throw Error(`Schema library "${o.vendor}" does not implement StandardJSONSchemaV1 (\`~standard.jsonSchema\`). Upgrade to a version that does, or wrap your JSON Schema with fromJsonSchema().`);if(t==="output"){if(r.type!==void 0)return r;return Um(r)?{type:"object",...r}:r}if(r.type!==void 0&&r.type!=="object")throw Error(`MCP tool and prompt schemas must describe objects (got type: ${JSON.stringify(r.type)}). Wrap your schema in z.object({...}) or equivalent.`);return{type:"object",...r}}var o_=/^#\/(\$defs|definitions)\/([^/~%]+)$/;function Um(e,t=e){if("properties"in e||"patternProperties"in e||"additionalProperties"in e||"required"in e)return!0;let o=typeof e.$ref==="string"&&o_.exec(e.$ref);if(o&&t[o[1]]?.[o[2]]?.type==="object")return!0;for(let r of["oneOf","anyOf","allOf"]){let n=e[r];if(Array.isArray(n)&&n.length>0)return n.every((s)=>s!==null&&typeof s==="object"&&(s.type==="object"||Um(s,"$id"in s?{}:t)))}return!1}function r_(e){if(!e.path?.length)return e.message;return`${e.path.map((t)=>String(typeof t==="object"?t.key:t)).join(".")}: ${e.message}`}async function al(e,t){let o=await e["~standard"].validate(t);if(o.issues&&o.issues.length>0)return{success:!1,error:o.issues.map((r)=>r_(r)).join(", ")};return{success:!0,data:o.value}}function n_(e){let t=Yi(e,{target:dl,io:"input"});return typeof t.pattern==="string"?t.pattern:void 0}var s_=/\\\.\\d\{(\d+)\}/;function i_(e){let t=s_.exec(e),o=[void 0,-1,0];if(t)o.push(Number(t[1]));return[!1,!0].flatMap((r)=>[!1,!0].flatMap((n)=>o.map((s)=>Fo({local:r,offset:n,precision:s}))))}function a_(e,t){let o;switch(e){case"email":o=[Oh()];break;case"uri":o=[ta()];break;case"date":o=[Yc()];break;case"date-time":o=i_(t);break}return new Set(o.map((r)=>n_(r)).filter((r)=>r!==void 0))}function c_(e,t,o){if(o!=="zod")return!0;return a_(e,t).has(t)}function si(e){return typeof e==="object"&&e!==null&&!Array.isArray(e)}function l_(e){try{return t_(e,"input")}catch(t){let o=t instanceof Error?t.message:String(t);throw new K(Z.InvalidParams,`Elicitation requestedSchema must describe an object with flat primitive properties: ${o}`)}}var u_=new Set(["$comment","deprecated","description","examples","readOnly","title","writeOnly"]);function vl(e){return u_.has(e)||e.startsWith("x-")}var d_=new Set(["$schema",...Object.keys(Po.shape.requestedSchema.shape)]),lm={string:oi([wo,hr,mr,fr]),number:oi([xo]),integer:oi([xo]),boolean:oi([pr]),array:oi([gr,Sr])},p_=new Set(wo.shape.format.unwrap().options);function h_(e,t,o,r){if(!si(e))return e;let n=typeof e.type==="string"&&Object.hasOwn(lm,e.type)?lm[e.type]:void 0;if(n===void 0)return e;let s={};for(let[i,c]of Object.entries(e))if(n.has(i)||vl(i))s[i]=c;else if(i==="pattern"&&e.type==="string"&&typeof e.format==="string"){if(!p_.has(e.format))s[i]=c;else if(typeof c!=="string"||!c_(e.format,c,o))r.push(`${t}.${i}`)}else r.push(`${t}.${i}`);return s}function m_(e,t){let o={},r=[];for(let[n,s]of Object.entries(e))if(n==="properties"&&si(s))o[n]=Object.fromEntries(Object.entries(s).map(([i,c])=>[i,h_(c,`properties.${i}`,t,r)]));else if(d_.has(n))o[n]=s;else if(!vl(n))r.push(n);if(r.length>0)throw new K(Z.InvalidParams,`Elicitation requestedSchema contains unsupported JSON Schema constraint(s) after Standard Schema conversion: ${r.join(", ")}`);return o}function f_(e,t){if(!si(e.properties))return t;let o=Object.entries(e.properties).filter(([,r])=>!ja(_r,r).success).map(([r])=>`properties.${r}`);return o.length>0?o.join(", "):t}function pl(e,t,o=""){if(Array.isArray(e)&&Array.isArray(t))return e.flatMap((r,n)=>pl(r,t[n],`${o}[${n}]`));if(!si(e)||!si(t))return[];return Object.entries(e).flatMap(([r,n])=>{let s=o?`${o}.${r}`:r;if(!Object.prototype.hasOwnProperty.call(t,r))return vl(r)?[]:[s];return pl(n,t[r],s)})}function g_(e){if(!ul(e.requestedSchema))return{...e,mode:"form",requestedSchema:e.requestedSchema};let t=e.requestedSchema["~standard"].vendor,o=m_(l_(e.requestedSchema),t),r=ja(Po.shape.requestedSchema,o);if(!r.success)throw new K(Z.InvalidParams,`Elicitation requestedSchema only supports flat primitive properties (string, number, integer, boolean, and string enums): ${f_(o,r.error.message)}`);let n=pl(o,r.data);if(n.length>0)throw new K(Z.InvalidParams,`Elicitation requestedSchema contains unsupported JSON Schema constraint(s) after Standard Schema conversion: ${n.join(", ")}`);let s=(r.data.required??[]).filter((i)=>!Object.prototype.hasOwnProperty.call(r.data.properties,i));if(s.length>0)throw new K(Z.InvalidParams,`Elicitation requestedSchema lists required properties that are not defined in properties: ${s.join(", ")}`);return{...e,mode:"form",requestedSchema:r.data}}function S_(e){let t=e.inputRequests!==void 0&&Object.keys(e.inputRequests).length>0,o=typeof e.requestState==="string";if(!t&&!o)throw TypeError("inputRequired() requires at least one of inputRequests (with at least one entry) or requestState (spec: every InputRequiredResult MUST include at least one of the two)");return{resultType:"input_required",...e.inputRequests!==void 0&&{inputRequests:e.inputRequests},...e.requestState!==void 0&&{requestState:e.requestState}}}var Vz=Object.assign(S_,{elicit(e){try{return{method:"elicitation/create",params:g_(e)}}catch(t){throw t instanceof K?TypeError(t.message,{cause:t}):t}},elicitUrl(e){return{method:"elicitation/create",params:{...e,mode:"url"}}},createMessage(e){return{method:"sampling/createMessage",params:e}},listRoots(){return{method:"roots/list"}}});var __=!0,y_=10,b_=250;function Zm(e){return{autoFulfill:e?.autoFulfill??__,maxRounds:e?.maxRounds??y_}}function v_(e,t,o){let r=t!==void 0&&Object.keys(t).length>0;if(!r&&o===void 0)return e;return{...e,...r&&{inputResponses:t},...o!==void 0&&{requestState:o}}}function z_(e,t){return`Multi-round-trip request '${e}' still required input after ${t} rounds (inputRequired.maxRounds)`}function R_(e,t){return new Promise((o,r)=>{if(t?.aborted){r(t.reason instanceof C?t.reason:new C(A.RequestTimeout,String(t.reason)));return}let n=setTimeout(()=>{t?.removeEventListener("abort",s),o()},e),s=()=>{clearTimeout(n),r(t?.reason instanceof C?t.reason:new C(A.RequestTimeout,String(t?.reason)))};t?.addEventListener("abort",s,{once:!0})})}function w_(e){let t=new AbortController,o=()=>t.abort(e?.reason);if(e?.addEventListener("abort",o,{once:!0}),e?.aborted)t.abort(e.reason);return{signal:t.signal,abort:(r)=>t.abort(r),dispose:()=>e?.removeEventListener("abort",o)}}async function x_(e){let{config:t,method:o,originalParams:r,requestOptions:n,hooks:s,signal:i}=e,c=e.flowStartedAt??Date.now(),l=e.firstPayload,u=0;while(!0){if(u+=1,u>t.maxRounds)throw new C(A.InputRequiredRoundsExceeded,z_(o,t.maxRounds),{rounds:t.maxRounds,lastResult:{inputRequests:l.inputRequests,...l.requestState!==void 0&&{requestState:l.requestState}}});n.onprogress?.({progress:u,message:`Fulfilling input required by '${o}' (round ${u})`});let h=Object.entries(l.inputRequests??{}),m;if(h.length>0){let b=w_(i);try{let v=await Promise.all(h.map(async([R,q])=>{try{return[R,await s.dispatchInputRequest(R,q,b.signal)]}catch(V){throw b.abort(V),V}}));m=Object.fromEntries(v)}finally{b.dispose()}}else await R_(b_,i);let S={...n.timeout!==void 0&&{timeout:n.timeout}};if(n.maxTotalTimeout!==void 0){let b=Date.now()-c,v=n.maxTotalTimeout-b;if(v<=0)throw new C(A.RequestTimeout,"Maximum total timeout exceeded",{maxTotalTimeout:n.maxTotalTimeout,totalElapsed:b});S.maxTotalTimeout=v}let g=await s.retry(v_(r,m,l.requestState),S);if(Am(g)){l={inputRequests:g.inputRequests??{},...g.requestState!==void 0&&{requestState:g.requestState}};continue}return g}}var P_=["AnnotationsSchema","AudioContentSchema","BaseMetadataSchema","BlobResourceContentsSchema","BooleanSchemaSchema","CallToolRequestSchema","CallToolRequestParamsSchema","CallToolResultSchema","CancelledNotificationSchema","CancelledNotificationParamsSchema","CancelTaskRequestSchema","CancelTaskResultSchema","ClientCapabilitiesSchema","ClientNotificationSchema","ClientRequestSchema","ClientResultSchema","CompatibilityCallToolResultSchema","CompleteRequestSchema","CompleteRequestParamsSchema","CompleteResultSchema","ContentBlockSchema","CreateMessageRequestSchema","CreateMessageRequestParamsSchema","CreateMessageResultSchema","CreateMessageResultWithToolsSchema","CreateTaskResultSchema","CursorSchema","DiscoverRequestSchema","DiscoverResultSchema","ElicitationCompleteNotificationSchema","ElicitationCompleteNotificationParamsSchema","ElicitRequestSchema","ElicitRequestFormParamsSchema","ElicitRequestParamsSchema","ElicitRequestURLParamsSchema","ElicitResultSchema","EmbeddedResourceSchema","EmptyResultSchema","EnumSchemaSchema","GetPromptRequestSchema","GetPromptRequestParamsSchema","GetPromptResultSchema","GetTaskPayloadRequestSchema","GetTaskPayloadResultSchema","GetTaskRequestSchema","GetTaskResultSchema","IconSchema","IconsSchema","ImageContentSchema","ImplementationSchema","InitializedNotificationSchema","InitializeRequestSchema","InitializeRequestParamsSchema","InitializeResultSchema","JSONArraySchema","JSONObjectSchema","JSONRPCErrorResponseSchema","JSONRPCMessageSchema","JSONRPCNotificationSchema","JSONRPCRequestSchema","JSONRPCResponseSchema","JSONRPCResultResponseSchema","JSONValueSchema","LegacyTitledEnumSchemaSchema","ListPromptsRequestSchema","ListPromptsResultSchema","ListResourcesRequestSchema","ListResourcesResultSchema","ListResourceTemplatesRequestSchema","ListResourceTemplatesResultSchema","ListRootsRequestSchema","ListRootsResultSchema","ListTasksRequestSchema","ListTasksResultSchema","ListToolsRequestSchema","ListToolsResultSchema","LoggingLevelSchema","LoggingMessageNotificationSchema","LoggingMessageNotificationParamsSchema","ModelHintSchema","ModelPreferencesSchema","MultiSelectEnumSchemaSchema","NotificationSchema","NumberSchemaSchema","PaginatedRequestSchema","PaginatedRequestParamsSchema","PaginatedResultSchema","PingRequestSchema","PrimitiveSchemaDefinitionSchema","ProgressSchema","ProgressNotificationSchema","ProgressNotificationParamsSchema","ProgressTokenSchema","PromptSchema","PromptArgumentSchema","PromptListChangedNotificationSchema","PromptMessageSchema","PromptReferenceSchema","ReadResourceRequestSchema","ReadResourceRequestParamsSchema","ReadResourceResultSchema","RelatedTaskMetadataSchema","RequestSchema","RequestIdSchema","RequestMetaSchema","ResourceSchema","ResourceContentsSchema","ResourceLinkSchema","ResourceListChangedNotificationSchema","ResourceRequestParamsSchema","ResourceTemplateSchema","ResourceTemplateReferenceSchema","ResourceUpdatedNotificationSchema","ResourceUpdatedNotificationParamsSchema","ResultMetaObjectSchema","ResultSchema","RoleSchema","RootSchema","RootsListChangedNotificationSchema","SamplingContentSchema","SamplingMessageSchema","SamplingMessageContentBlockSchema","ServerCapabilitiesSchema","ServerNotificationSchema","ServerRequestSchema","ServerResultSchema","SetLevelRequestSchema","SetLevelRequestParamsSchema","SingleSelectEnumSchemaSchema","StringSchemaSchema","SubscribeRequestSchema","SubscribeRequestParamsSchema","SubscriptionFilterSchema","SubscriptionsAcknowledgedNotificationSchema","SubscriptionsAcknowledgedNotificationParamsSchema","SubscriptionsListenRequestSchema","SubscriptionsListenRequestParamsSchema","SubscriptionsListenResultSchema","SubscriptionsListenResultMetaSchema","TaskAugmentedRequestParamsSchema","TaskCreationParamsSchema","TaskMetadataSchema","TaskSchema","TaskStatusSchema","TaskStatusNotificationSchema","TaskStatusNotificationParamsSchema","TextContentSchema","TextResourceContentsSchema","TitledMultiSelectEnumSchemaSchema","TitledSingleSelectEnumSchemaSchema","ToolSchema","ToolAnnotationsSchema","ToolChoiceSchema","ToolExecutionSchema","ToolListChangedNotificationSchema","ToolResultContentSchema","ToolUseContentSchema","UnsubscribeRequestSchema","UnsubscribeRequestParamsSchema","UntitledMultiSelectEnumSchemaSchema","UntitledSingleSelectEnumSchemaSchema"],T_={IdJagTokenExchangeResponseSchema:Ys,OAuthClientInformationFullSchema:ei,OAuthClientInformationSchema:Xs,OAuthClientMetadataSchema:Qs,OAuthClientRegistrationErrorSchema:Ea,OAuthErrorResponseSchema:vr,OAuthMetadataSchema:yr,OAuthProtectedResourceMetadataSchema:Gs,OAuthTokenRevocationRequestSchema:ka,OAuthTokensSchema:br,OpenIdProviderDiscoveryMetadataSchema:Ks,OpenIdProviderMetadataSchema:Ws},Dm={},Vm={};function Hm(e,t){let o=e.slice(0,-6);Dm[o]=t,Vm[o]=(r)=>t.safeParse(r).success}for(let e of P_)Hm(e,FS[e]);for(let[e,t]of Object.entries(T_))Hm(e,t);var E_=Object.freeze(Dm),zl=Object.freeze(Vm);function k_(e){switch(e){case"initialize":case"notifications/initialized":return wt(void 0);case"server/discover":return wt(Ma);default:return}}var ui=60000,$_=[po,Bo,ho,Wo],C_=["inputResponses","requestState"];function um(e,t){let o=e.params;if(!ni(o))return{message:e,lifted:{}};let r=o._meta,n=ni(r)?$_.filter((l)=>(l in r)):[],s=t==="request"?C_.filter((l)=>(l in o)):[];if(n.length===0&&s.length===0)return{message:e,lifted:{}};let i={},c={...o};if(n.length>0&&ni(r)){let l={},u={...r};for(let h of n)l[h]=r[h],delete u[h];if(i.envelope=l,Object.keys(u).length>0)c._meta=u;else delete c._meta}for(let l of s){if(l==="inputResponses")i.inputResponses=c[l];if(l==="requestState")i.requestState=c[l];delete c[l]}return{message:{...e,params:c},lifted:i}}function dm(e,t){let o=e.validateResult(t,void 0);if(!o.ok&&o.reason==="not-in-era")return;return{"~standard":{version:1,vendor:"mcp-wire-codec",validate(r){let n=e.validateResult(t,r);if(n.ok)return{value:n.value};return{issues:[{message:n.reason==="invalid"?n.message:`not-in-era: ${t}`}]}}}}}function Rl(e){return()=>e}var I_=Rl(void 0),O_,di=class{_transport;_requestMessageId=0;_requestHandlers=new Map;_customSchemaRequestMethods=new Set;_requestHandlerAbortControllers=new Map;_notificationHandlers=new Map;_responseHandlers=new Map;_progressHandlers=new Map;_timeoutInfo=new Map;_pendingDebouncedNotifications=new Set;_negotiatedProtocolVersion;static{O_=(e,t)=>{e._negotiatedProtocolVersion=t}}_supportedProtocolVersions;onclose;onerror;fallbackRequestHandler;fallbackNotificationHandler;constructor(e){this._options=e,this._supportedProtocolVersions=e?.supportedProtocolVersions??na,this.setNotificationHandler("notifications/cancelled",(t)=>{this._oncancel(t)}),this.setNotificationHandler("notifications/progress",(t)=>{this._onprogress(t)}),this.setRequestHandler("ping",(t)=>({}))}_shouldDropInbound(e){}_outboundMetaEnvelope(){}_envelopeOutbound(e){let t=this._outboundMetaEnvelope();if(t===void 0)return e;let o=e.params??{};return{...e,params:{...o,_meta:{...t,...o._meta}}}}_resolveNonCompleteResult(e,t){return Promise.reject(new C(A.UnsupportedResultType,`Unsupported result type '${e.kind}' for ${t.request.method}`,{resultType:e.kind,method:t.request.method}))}_getRequestHandler(e){return this._requestHandlers.get(e)}async _oncancel(e){if(e.params.requestId===void 0)return;this._requestHandlerAbortControllers.get(e.params.requestId)?.abort(e.params.reason)}_setupTimeout(e,t,o,r,n=!1){this._timeoutInfo.set(e,{timeoutId:setTimeout(r,t),startTime:Date.now(),timeout:t,maxTotalTimeout:o,resetTimeoutOnProgress:n,onTimeout:r})}_resetTimeout(e){let t=this._timeoutInfo.get(e);if(!t)return!1;let o=Date.now()-t.startTime;if(t.maxTotalTimeout&&o>=t.maxTotalTimeout)throw this._timeoutInfo.delete(e),new C(A.RequestTimeout,"Maximum total timeout exceeded",{maxTotalTimeout:t.maxTotalTimeout,totalElapsed:o});return clearTimeout(t.timeoutId),t.timeoutId=setTimeout(t.onTimeout,t.timeout),!0}_cleanupTimeout(e){let t=this._timeoutInfo.get(e);if(t)clearTimeout(t.timeoutId),this._timeoutInfo.delete(e)}async connect(e){this._transport=e;let t=this.transport?.onclose;this._transport.onclose=()=>{try{t?.()}finally{this._onclose()}};let o=this.transport?.onerror;this._transport.onerror=(n)=>{o?.(n),this._onerror(n)};let r=this._transport?.onmessage;this._transport.onmessage=(n,s)=>{if(r?.(n,s),Rr(n)||li(n))this._onresponse(n);else if(qa(n))this._onrequest(n,s);else if(Nm(n))this._onnotification(n,s);else this._onerror(Error(`Unknown message type: ${JSON.stringify(n)}`))},e.setSupportedProtocolVersions?.(this._supportedProtocolVersions),await this._transport.start()}_onclose(){let e=this._responseHandlers;this._responseHandlers=new Map,this._progressHandlers.clear(),this._pendingDebouncedNotifications.clear();for(let r of this._timeoutInfo.values())clearTimeout(r.timeoutId);this._timeoutInfo.clear();let t=this._requestHandlerAbortControllers;this._requestHandlerAbortControllers=new Map;let o=new C(A.ConnectionClosed,"Connection closed");this._transport=void 0;try{this.onclose?.()}finally{for(let r of e.values())r(o);for(let r of t.values())r.abort(o)}}_onerror(e){this.onerror?.(e)}_onnotification(e,t){let{message:o}=um(e,"notification"),r=this._negotiatedWireCodec();if(t?.classification===void 0&&this._shouldDropInbound(e)==="drop")return;if(t?.classification!==void 0){let i=sm(t.classification);if(i!==r.era){this._onerror(Error(`Era mismatch on inbound notification '${o.method}': classified as ${i} but this instance serves ${r.era}`));return}}if(il(o.method)&&!r.hasNotificationMethod(o.method))return;let n=this._notificationHandlers.get(o.method),s=this.fallbackNotificationHandler;if(n===void 0&&s===void 0)return;Promise.resolve().then(()=>n===void 0?s(o):n(o,r)).catch((i)=>this._onerror(Error(`Uncaught error in notification handler: ${i}`)))}_onrequest(e,t){let{message:o,lifted:r}=um(e,"request"),n=this._negotiatedWireCodec();if(t?.classification===void 0&&this._shouldDropInbound(e)==="drop"){this._onerror(Error(`Dropped inbound request '${e.method}': not servable on this connection's protocol era`));return}let s=this._transport,i=(v,R,q)=>{let V={jsonrpc:"2.0",id:o.id,error:{code:v,message:R,...q!==void 0&&{data:q}}};s?.send(V).catch((P)=>this._onerror(Error(`Failed to send an error response: ${P}`)))};if(t?.classification!==void 0){let v=sm(t.classification);if(v!==n.era){this._onerror(Error(`Era mismatch on inbound request '${o.method}': classified as ${v} but this instance serves ${n.era}`));let R=t.classification.revision??v;i(Z.UnsupportedProtocolVersion,`Unsupported protocol version: ${R}`,{supported:this._supportedProtocolVersions,requested:R});return}}if(sl(o.method)&&!n.hasRequestMethod(o.method)&&!(im(o.method)&&this._customSchemaRequestMethods.has(o.method))){i(Z.MethodNotFound,"Method not found");return}let c=this._requestHandlers.get(o.method)??this.fallbackRequestHandler;if(c===void 0){i(Z.MethodNotFound,"Method not found");return}let l=n.checkInboundEnvelope(r);if(l!==void 0){i(Z.InvalidParams,l);return}let u=(v,R)=>this._notificationViaCodec(this._resolveOutboundCodec(v.method),v,{...R,relatedRequestId:o.id}),h=(v,R,q)=>this._requestWithSchemaViaCodec(this._resolveOutboundCodec(v.method),v,R,{...q,relatedRequestId:o.id}),m=new AbortController;this._requestHandlerAbortControllers.set(o.id,m);let S=r.inputResponses===void 0?void 0:N_(r.inputResponses),g={sessionId:s?.sessionId,mcpReq:{id:o.id,method:o.method,_meta:o.params?._meta,...r.envelope!==void 0&&{envelope:r.envelope},...S!==void 0&&{inputResponses:S.accepted},...S!==void 0&&S.droppedKeys.length>0&&{droppedInputResponseKeys:S.droppedKeys},requestState:r.requestState===void 0?I_:Rl(r.requestState),signal:m.signal,send:(v,R,q)=>{let V=this._resolveOutboundCodec(v.method);if(this._assertOutboundRequestInEra(V,v.method),ul(R))return h(v,R,q);let P=dm(V,v.method);if(P===void 0)throw TypeError(`'${v.method}' is not a spec method; pass a result schema as the second argument to ctx.mcpReq.send().`);return h(v,P,R)},notify:u},http:t?.authInfo?{authInfo:t.authInfo}:void 0},b=this.buildContext(g,t);Promise.resolve().then(()=>c(o,b)).then(async(v)=>{if(m.signal.aborted)return;let R;try{R=n.encodeResult(o.method,v,this._outboundServerInfo())}catch(V){this._onerror(Error(`Failed to encode result for ${o.method}: ${V}`)),i(Z.InternalError,"Internal error");return}let q={result:R,jsonrpc:"2.0",id:o.id};await s?.send(q)},async(v)=>{if(m.signal.aborted)return;let R=Number.isSafeInteger(v.code)?v.code:Z.InternalError,q={jsonrpc:"2.0",id:o.id,error:{code:n.encodeErrorCode(R),message:v.message??"Internal error",...v.data!==void 0&&{data:v.data}}};await s?.send(q)}).catch((v)=>this._onerror(Error(`Failed to send response: ${v}`))).finally(()=>{if(this._requestHandlerAbortControllers.get(o.id)===m)this._requestHandlerAbortControllers.delete(o.id)})}_onprogress(e){let{progressToken:t,...o}=e.params,r=Number(t),n=this._progressHandlers.get(r);if(!n){this._onerror(Error(`Received a progress notification for an unknown token: ${JSON.stringify(e)}`));return}let s=this._responseHandlers.get(r),i=this._timeoutInfo.get(r);if(i&&s&&i.resetTimeoutOnProgress)try{this._resetTimeout(r)}catch(c){this._responseHandlers.delete(r),this._progressHandlers.delete(r),this._cleanupTimeout(r),s(c);return}n(o)}_onresponse(e){let t=Number(e.id),o=this._responseHandlers.get(t);if(o===void 0){this._onerror(Error(`Received a response for an unknown message ID: ${JSON.stringify(e)}`));return}if(this._responseHandlers.delete(t),this._cleanupTimeout(t),this._progressHandlers.delete(t),Rr(e))o(e);else o(K.fromError(e.error.code,e.error.message,e.error.data))}get transport(){return this._transport}async close(){await this._transport?.close()}request(e,t,o){let r=this._resolveOutboundCodec(e.method);if(ul(t)){if(!im(e.method))this._assertOutboundRequestInEra(r,e.method);return this._requestWithSchemaViaCodec(r,e,t,o)}this._assertOutboundRequestInEra(r,e.method);let n=dm(r,e.method);if(n===void 0)throw TypeError(`'${e.method}' is not a spec method; pass a result schema as the second argument to request().`);return this._requestWithSchemaViaCodec(r,e,n,t)}_negotiatedWireCodec(){return wt(this._negotiatedProtocolVersion)}_wireCodec(){return this._negotiatedWireCodec()}_resolveOutboundCodec(e){if(this._negotiatedProtocolVersion===void 0){let t=k_(e);if(t)return t}return this._negotiatedWireCodec()}_assertOutboundRequestInEra(e,t){if(sl(t)&&!e.hasRequestMethod(t))throw new C(A.MethodNotSupportedByProtocolVersion,`Method '${t}' is not supported by the negotiated protocol version (wire era ${e.era})`,{method:t,era:e.era})}_requestWithSchema(e,t,o){let r=this._resolveOutboundCodec(e.method);return this._assertOutboundRequestInEra(r,e.method),this._requestWithSchemaViaCodec(r,e,t,o)}_requestWithSchemaViaCodec(e,t,o,r){let{relatedRequestId:n,resumptionToken:s,onresumptiontoken:i,headers:c}=r??{},l=Date.now(),u,h;return new Promise((m,S)=>{let g=(G)=>{S(G)};if(!this._transport){g(Error("Not connected"));return}if(this._options?.enforceStrictCapabilities===!0)try{this.assertCapabilityForMethod(t.method)}catch(G){g(G);return}if(r?.signal?.aborted){let G=r.signal.reason;throw G instanceof C?G:new C(A.RequestTimeout,String(G))}let b=e.era===Ma&&this._transport.hasPerRequestStream===!0?new AbortController:void 0,v=this._requestMessageId++;h=v;let R={...t,jsonrpc:"2.0",id:v};if(r?.onprogress)this._progressHandlers.set(v,r.onprogress),R.params={...t.params,_meta:{...t.params?._meta,progressToken:v}};let q=this._envelopeOutbound(R),V=!1,P=(G)=>{if(V)return;if(this._progressHandlers.delete(v),b===void 0){if(t.method!=="initialize")this._transport?.send(this._envelopeOutbound({jsonrpc:"2.0",method:"notifications/cancelled",params:{requestId:v,reason:String(G)}}),{relatedRequestId:n,resumptionToken:s,onresumptiontoken:i}).catch((Y)=>this._onerror(Error(`Failed to send cancellation: ${Y}`)))}else b.abort();S(G instanceof C?G:new C(A.RequestTimeout,String(G)))};this._responseHandlers.set(v,(G)=>{if(r?.signal?.aborted)return;if(V=!0,G instanceof Error)return S(G);let Y;try{Y=e.decodeResult(t.method,G.result)}catch(oe){return S(oe instanceof Error?oe:Error(String(oe)))}if(Y.kind==="invalid")return S(Y.error);if(Y.kind==="input_required"){if(r?.allowInputRequired===!0)return m(j_(Y));let oe={codec:e,request:t,resultSchema:o,options:r,flowStartedAt:l,retry:(fe,Ve)=>this._requestWithSchemaViaCodec(e,fe===void 0?{method:t.method}:{method:t.method,params:fe},o,Ve)};return m(this._resolveNonCompleteResult(Y,oe))}let ue=Y.result;al(o,ue).then((oe)=>{if(oe.success)m(oe.data);else S(new C(A.InvalidResult,`Invalid result for ${t.method}: ${oe.error}`))},S)}),u=()=>P(r?.signal?.reason),r?.signal?.addEventListener("abort",u,{once:!0});let H=r?.timeout??ui,B=()=>P(new C(A.RequestTimeout,"Request timed out",{timeout:H}));this._setupTimeout(v,H,r?.maxTotalTimeout,B,r?.resetTimeoutOnProgress??!1),this._transport.send(q,{relatedRequestId:n,resumptionToken:s,onresumptiontoken:i,headers:c,requestSignal:b?.signal}).catch((G)=>{this._progressHandlers.delete(v),S(G)})}).finally(()=>{if(u)r?.signal?.removeEventListener("abort",u);if(h!==void 0)this._responseHandlers.delete(h),this._cleanupTimeout(h)})}async notification(e,t){return await this._notificationViaCodec(this._resolveOutboundCodec(e.method),e,t)}async _notificationViaCodec(e,t,o){if(!this._transport)throw new C(A.NotConnected,"Not connected");if(il(t.method)&&!e.hasNotificationMethod(t.method))throw new C(A.MethodNotSupportedByProtocolVersion,`Notification '${t.method}' is not supported by the negotiated protocol version (wire era ${e.era})`,{method:t.method,era:e.era});this.assertNotificationCapability(t.method);let r=this._envelopeOutbound({jsonrpc:"2.0",...t});if((this._options?.debouncedNotificationMethods??[]).includes(t.method)&&!t.params&&o?.relatedRequestId===void 0){if(this._pendingDebouncedNotifications.has(t.method))return;this._pendingDebouncedNotifications.add(t.method),Promise.resolve().then(()=>{if(this._pendingDebouncedNotifications.delete(t.method),!this._transport)return;this._transport?.send(r,o).catch((n)=>this._onerror(n))});return}await this._transport.send(r,o)}setRequestHandler(e,t,o){this.assertRequestHandlerCapability(e);let r;if(typeof t==="function"){if(!sl(e))throw TypeError(`'${e}' is not a spec request method; pass schemas as the second argument to setRequestHandler().`);r=(n,s)=>{let i=this._negotiatedWireCodec(),c=i.validateRequest(e,n);if(!c.ok&&c.reason==="not-in-era")c=i.validateInputRequest(e,n);if(!c.ok){if(c.reason==="not-in-era")throw new K(Z.InternalError,`No wire schema for ${e} in the resolved era`);throw Error(c.message)}return Promise.resolve(t(c.value,s))}}else if(o)r=async(n,s)=>{let i=await al(t.params,{...n.params});if(!i.success)throw new K(Z.InvalidParams,`Invalid params for ${e}: ${i.error}`);return o(i.data,s)};else throw TypeError("setRequestHandler: handler is required");if(typeof t==="function")this._customSchemaRequestMethods.delete(e);else this._customSchemaRequestMethods.add(e);this._requestHandlers.set(e,this._wrapHandler(e,r))}_wrapHandler(e,t){return t}_outboundServerInfo(){}removeRequestHandler(e){this._requestHandlers.delete(e),this._customSchemaRequestMethods.delete(e)}assertCanSetRequestHandler(e){if(this._requestHandlers.has(e))throw Error(`A request handler for ${e} already exists, which would be overridden`)}setNotificationHandler(e,t,o){if(typeof t==="function"){if(!il(e))throw TypeError(`'${e}' is not a spec notification method; pass schemas as the second argument to setNotificationHandler().`);this._notificationHandlers.set(e,(r,n)=>{let s=n.validateNotification(e,r);if(!s.ok){if(s.reason==="not-in-era")throw new K(Z.InternalError,`No wire schema for ${e} in the resolved era`);throw Error(s.message)}return Promise.resolve(t(s.value))});return}if(!o)throw TypeError("setNotificationHandler: handler is required");this._notificationHandlers.set(e,async(r)=>{let n=await al(t.params,{...r.params});if(!n.success)throw new K(Z.InvalidParams,`Invalid params for notification ${e}: ${n.error}`);await o(n.data,r)})}removeNotificationHandler(e){this._notificationHandlers.delete(e)}};function ni(e){return e!==null&&typeof e==="object"&&!Array.isArray(e)}function wl(e,t){let o={...e};for(let r in t){let n=r,s=t[n];if(s===void 0)continue;let i=o[n];o[n]=ni(i)&&ni(s)?{...i,...s}:s}return o}function Aa(e){return typeof e==="object"&&e!==null&&!Array.isArray(e)}function N_(e){let t={},o=[];if(!Aa(e))return{accepted:t,droppedKeys:o};for(let[r,n]of Object.entries(e)){if(!Aa(n)||"method"in n||"result"in n){o.push(r);continue}t[r]=n}return{accepted:t,droppedKeys:o}}function pm(e){throw new C(A.SendFailed,`ctx.mcpReq.${e} is not available while fulfilling an embedded input request: the request is fulfilled locally and has no related peer request`)}function A_(e,t,o,r,n){return{sessionId:n,mcpReq:{id:e,method:t,_meta:o?._meta,requestState:Rl(void 0),signal:r,send:()=>pm("send"),notify:()=>pm("notify")}}}async function M_(e,t,o,r,n){if(!Aa(r)||typeof r.method!=="string")throw new C(A.InvalidResult,`Invalid input request '${o}': each inputRequests entry must be an embedded request object with a method`,{key:o});let s=r.method;if(!t.hasInputRequestMethod(s))throw new C(A.InvalidResult,`Invalid input request '${o}': '${s}' is not an embedded request the ${t.era} revision defines (expected elicitation/create, sampling/createMessage, or roots/list)`,{key:o,method:s});let i=e.getRequestHandler(s);if(i===void 0)throw new C(A.CapabilityNotSupported,`Cannot fulfil input request '${o}': no handler is registered for '${s}' on this client. Declare the corresponding capability and register a handler, or handle input_required results manually.`,{key:o,method:s});let c=Aa(r.params)?r.params:void 0;return await i({jsonrpc:"2.0",id:o,method:s,...c!==void 0&&{params:c}},e.buildContext(A_(o,s,c,n,e.sessionId)))}function q_(e,t){return{...e?.signal!==void 0&&{signal:e.signal},...e?.onprogress!==void 0&&{onprogress:e.onprogress},...e?.resetTimeoutOnProgress!==void 0&&{resetTimeoutOnProgress:e.resetTimeoutOnProgress},...e?.headers!==void 0&&{headers:e.headers},...t.timeout!==void 0&&{timeout:t.timeout},...t.maxTotalTimeout!==void 0&&{maxTotalTimeout:t.maxTotalTimeout},allowInputRequired:!0}}function Fm(e,t,o,r){let{codec:n,request:s,options:i,flowStartedAt:c}=r,l={inputRequests:o.inputRequests,...o.requestState!==void 0&&{requestState:o.requestState}},u={dispatchInputRequest:(h,m,S)=>M_(e,n,h,m,S),retry:(h,m)=>r.retry(h,q_(i,m))};return x_({config:t,method:s.method,originalParams:s.params,firstPayload:l,flowStartedAt:c,signal:i?.signal,requestOptions:{...i?.timeout!==void 0&&{timeout:i.timeout},...i?.maxTotalTimeout!==void 0&&{maxTotalTimeout:i.maxTotalTimeout},...i?.onprogress!==void 0&&{onprogress:i.onprogress}},hooks:u})}function j_(e){return{resultType:"input_required",inputRequests:e.inputRequests,...e.requestState!==void 0&&{requestState:e.requestState},...e._meta!==void 0&&{_meta:e._meta}}}/*!
|
|
65
65
|
* content-type
|
|
66
66
|
* Copyright(c) 2015 Douglas Christopher Wilson
|
|
67
67
|
* MIT Licensed
|
|
68
|
-
*/var TS=gl((e)=>{var t=/; *([!#$%&'*+.^_`|~0-9A-Za-z-]+) *= *("(?:[\u000b\u0020\u0021\u0023-\u005b\u005d-\u007e\u0080-\u00ff]|\\[\u000b\u0020-\u00ff])*"|[!#$%&'*+.^_`|~0-9A-Za-z-]+) */g,o=/\\([\u000b\u0020-\u00ff])/g,r=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+\/[!#$%&'*+.^_`|~0-9A-Za-z-]+$/;e.parse=n;function n(c){if(!c)throw TypeError("argument string is required");var d=typeof c==="object"?i(c):c;if(typeof d!=="string")throw TypeError("argument string is required to be a string");var p=d.indexOf(";"),m=p!==-1?d.slice(0,p).trim():d.trim();if(!r.test(m))throw TypeError("invalid media type");var f=new a(m.toLowerCase());if(p!==-1){var y,S,w;t.lastIndex=p;while(S=t.exec(d)){if(S.index!==p)throw TypeError("invalid parameter format");if(p+=S[0].length,y=S[1].toLowerCase(),w=S[2],w.charCodeAt(0)===34){if(w=w.slice(1,-1),w.indexOf("\\")!==-1)w=w.replace(o,"$1")}f.parameters[y]=w}if(p!==d.length)throw TypeError("invalid parameter format")}return f}function i(c){var d;if(typeof c.getHeader==="function")d=c.getHeader("content-type");else if(typeof c.headers==="object")d=c.headers&&c.headers["content-type"];if(typeof d!=="string")throw TypeError("content-type header is missing from object");return d}function a(c){this.parameters=Object.create(null),this.type=c}}),Vb=_l(TS(),1);var ev=typeof self<"u"&&self.location&&self.location.origin!=="null"?new URL(self.location.origin+self.location.pathname+location.search):new URL("https://github.com/cfworker");var ES=/^(\d\d\d\d)-(\d\d)-(\d\d)$/,kS=[0,31,28,31,30,31,30,31,31,30,31,30,31],$S=/^(\d\d):(\d\d):(\d\d)(\.\d+)?(z|[+-]\d\d(?::?\d\d)?)?$/i,CS=/^(?=.{1,253}\.?$)[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[-0-9a-z]{0,61}[0-9a-z])?)*\.?$/i,IS=/^(?:[a-z][a-z0-9+\-.]*:)?(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'"()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?(?:\?(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i,OS=/^(?:(?:[^\x00-\x20"'<>%\\^`{|}]|%[0-9a-f]{2})|\{[+#./;?&=,!@|]?(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?(?:,(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?)*\})*$/i,NS=/^(?:(?:https?|ftp):\/\/)(?:\S+(?::\S*)?@)?(?:(?!10(?:\.\d{1,3}){3})(?!127(?:\.\d{1,3}){3})(?!169\.254(?:\.\d{1,3}){2})(?!192\.168(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z\u{00a1}-\u{ffff}0-9]+-?)*[a-z\u{00a1}-\u{ffff}0-9]+)(?:\.(?:[a-z\u{00a1}-\u{ffff}0-9]+-?)*[a-z\u{00a1}-\u{ffff}0-9]+)*(?:\.(?:[a-z\u{00a1}-\u{ffff}]{2,})))(?::\d{2,5})?(?:\/[^\s]*)?$/iu,AS=/^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i,MS=/^(?:\/(?:[^~/]|~0|~1)*)*$/,qS=/^#(?:\/(?:[a-z0-9_\-.!$&'()*+,;:=@]|%[0-9a-f]{2}|~0|~1)*)*$/i,jS=/^(?:0|[1-9][0-9]*)(?:#|(?:\/(?:[^~/]|~0|~1)*)*)$/,LS=(e)=>{if(e[0]==='"')return!1;let[t,o,...r]=e.split("@");if(!t||!o||r.length!==0||t.length>64||o.length>253)return!1;if(t[0]==="."||t.endsWith(".")||t.includes(".."))return!1;if(!/^[a-z0-9.-]+$/i.test(o)||!/^[a-z0-9.!#$%&'*+/=?^_`{|}~-]+$/i.test(t))return!1;return o.split(".").every((n)=>/^[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?$/i.test(n))},US=/^(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)$/,ZS=/^((([0-9a-f]{1,4}:){7}([0-9a-f]{1,4}|:))|(([0-9a-f]{1,4}:){6}(:[0-9a-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){5}(((:[0-9a-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){4}(((:[0-9a-f]{1,4}){1,3})|((:[0-9a-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){3}(((:[0-9a-f]{1,4}){1,4})|((:[0-9a-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){2}(((:[0-9a-f]{1,4}){1,5})|((:[0-9a-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){1}(((:[0-9a-f]{1,4}){1,6})|((:[0-9a-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9a-f]{1,4}){1,7})|((:[0-9a-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))$/i,DS=(e)=>e.length>1&&e.length<80&&(/^P\d+([.,]\d+)?W$/.test(e)||/^P[\dYMDTHS]*(\d[.,]\d+)?[YMDHS]$/.test(e)&&/^P([.,\d]+Y)?([.,\d]+M)?([.,\d]+D)?(T([.,\d]+H)?([.,\d]+M)?([.,\d]+S)?)?$/.test(e));function Oe(e){return e.test.bind(e)}var tv={date:hm,time:mm.bind(void 0,!1),"date-time":FS,duration:DS,uri:GS,"uri-reference":Oe(IS),"uri-template":Oe(OS),url:Oe(NS),email:LS,hostname:Oe(CS),ipv4:Oe(US),ipv6:Oe(ZS),regex:KS,uuid:Oe(AS),"json-pointer":Oe(MS),"json-pointer-uri-fragment":Oe(qS),"relative-json-pointer":Oe(jS)};function VS(e){return e%4===0&&(e%100!==0||e%400===0)}function hm(e){let t=e.match(ES);if(!t)return!1;let o=+t[1],r=+t[2],n=+t[3];return r>=1&&r<=12&&n>=1&&n<=(r==2&&VS(o)?29:kS[r])}function mm(e,t){let o=t.match($S);if(!o)return!1;let r=+o[1],n=+o[2],i=+o[3],a=!!o[5];return(r<=23&&n<=59&&i<=59||r==23&&n==59&&i==60)&&(!e||a)}var HS=/t|\s/i;function FS(e){let t=e.split(HS);return t.length==2&&hm(t[0])&&mm(!0,t[1])}var JS=/\/|:/,BS=/^(?:[a-z][a-z0-9+\-.]*:)(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)(?:\?(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i;function GS(e){return JS.test(e)&&BS.test(e)}var WS=/[^\\]\\Z/;function KS(e){if(WS.test(e))return!1;try{return new RegExp(e,"u"),!0}catch(t){return!1}}var QS;QS=globalThis.crypto;var Ks=class extends Error{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.OAuthClientFlowError"})}static[Symbol.hasInstance](e){return fe(this,e)}static isInstance(e){if(typeof this!=="function")throw TypeError("isInstance must be called on the class (e.g. `SdkError.isInstance(value)`); for callbacks use `v => SdkError.isInstance(v)`");return fe(this,e)}constructor(e){super(e);this.name=new.target.name,Bt(this,new.target)}},Kv=class extends Ks{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.IssuerMismatchError"})}kind;expected;received;constructor(e,t,o){super(`Issuer mismatch in ${e==="metadata"?"authorization server metadata (RFC 8414 §3.3)":"authorization response (RFC 9207)"}: expected ${JSON.stringify(t)}, received ${JSON.stringify(o)}`);this.kind=e,this.expected=t,this.received=o}},Yv=class extends Ks{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.RegistrationRejectedError"})}status;body;submittedMetadata;constructor(e){super(`Dynamic Client Registration rejected (HTTP ${e.status}): ${e.body}`);this.status=e.status,this.body=e.body,this.submittedMetadata=e.submittedMetadata}},Qv=class extends Ks{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.InsecureTokenEndpointError"})}tokenEndpoint;constructor(e){super(`Refusing to send credentials to non-https token endpoint '${e}'. OAuth token requests MUST use TLS (localhost / *.localhost / 127.0.0.1 / ::1 are exempt).`);this.tokenEndpoint=e}},Xv=class extends Ks{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.AuthorizationServerMismatchError"})}constructor(e,t){super(`Authorization server mismatch: credentials are bound to ${JSON.stringify(e)} but this call resolved ${JSON.stringify(t)}; refusing to present them to a different authorization server`);this.recordedIssuer=e,this.currentIssuer=t}},ez=class extends Ks{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.InsufficientScopeError"})}requiredScope;resourceMetadataUrl;errorDescription;constructor(e){super(`Insufficient scope${e.requiredScope?`: required "${e.requiredScope}"`:""}`);this.requiredScope=e.requiredScope,this.resourceMetadataUrl=e.resourceMetadataUrl,this.errorDescription=e.errorDescription}};var tz=class extends Error{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.UnauthorizedError"})}static[Symbol.hasInstance](e){return fe(this,e)}static isInstance(e){if(typeof this!=="function")throw TypeError("isInstance must be called on the class (e.g. `SdkError.isInstance(value)`); for callbacks use `v => SdkError.isInstance(v)`");return fe(this,e)}constructor(e){super(e??"Unauthorized");this.name="UnauthorizedError",Bt(this,new.target)}};var oz=class extends Error{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.SseError"})}static[Symbol.hasInstance](e){return fe(this,e)}static isInstance(e){if(typeof this!=="function")throw TypeError("isInstance must be called on the class (e.g. `SdkError.isInstance(value)`); for callbacks use `v => SdkError.isInstance(v)`");return fe(this,e)}constructor(e,t,o){super(`SSE error: ${t}`);this.code=e,this.event=o,Bt(this,new.target)}};class bm{_eventSlots=new Map;setHandler(e,t){let o=this._ensureEventSlot(e);if(o.onHandler&&t)console.warn(`[MCP Apps] on${String(e)} handler replaced. Use addEventListener("${String(e)}", …) to add multiple listeners without replacing.`);o.onHandler=t}getHandler(e){return this._eventSlots.get(e)?.onHandler}addEventListener(e,t){this._ensureEventSlot(e).listeners.push(t)}removeEventListener(e,t){let o=this._eventSlots.get(e);if(!o)return;let r=o.listeners.indexOf(t);if(r!==-1)o.listeners.splice(r,1)}dispatch(e,t){let o=this._eventSlots.get(e);if(!o)return;o.onHandler?.(t);for(let r of[...o.listeners])r(t)}_ensureEventSlot(e){let t=this._eventSlots.get(e);if(!t)t={listeners:[]},this._eventSlots.set(e,t);return t}}class vm{_methods=new Set;claim(e,t){if(this._methods.has(e))throw Error(`Handler for "${e}" already registered (via ${t}). Use addEventListener() to attach multiple listeners, or the on* setter for replace semantics.`);this._methods.add(e)}replace(e){this._methods.add(e)}release(e){this._methods.delete(e)}has(e){return this._methods.has(e)}}var fm=new Set;function gm(e,t){let[o,r]=t,n=o?.shape;if(typeof n?.method?.value!=="string")return;let i=n.method.value,a=e==="request"?"setRequestHandler":"setNotificationHandler";if(!fm.has(a))fm.add(a),console.warn(`[ext-apps] ${a}(Schema, handler) is deprecated; use ${a}("${i}", { params: Schema.shape.params }, handler).`);let c=r;return[i,{params:n.params},e==="request"?(d,p)=>c({method:i,params:d},XS(p)):(d)=>c({method:i,params:d})]}function XS(e){return{signal:e.mcpReq.signal,requestId:e.mcpReq.id,sessionId:e.sessionId,_meta:e.mcpReq._meta,sendRequest:e.mcpReq.send,sendNotification:e.mcpReq.notify,authInfo:e.http?.authInfo}}var e_="2026-01-26";var t_="ui/notifications/tool-input-partial";class zm{eventTarget;eventSource;messageListener;constructor(e=window.parent,t){this.eventTarget=e,this.eventSource=t,this.messageListener=(o)=>{if(t&&o.source!==this.eventSource){console.debug("Ignoring message from unknown source",o);return}let r=qt.safeParse(o.data);if(r.success)console.debug("Parsed message",r.data),this.onmessage?.(r.data);else if(o.data?.jsonrpc!=="2.0")console.debug("Ignoring non-JSON-RPC message",r.error.message,o);else console.error("Failed to parse message",r.error.message,o),this.onerror?.(Error("Invalid JSON-RPC message received: "+r.error.message))}}async start(){window.addEventListener("message",this.messageListener)}async send(e,t){if(e.method!==t_)console.debug("Sending message",e);this.eventTarget.postMessage(e,"*")}async close(){window.removeEventListener("message",this.messageListener),this.onclose?.()}onclose;onerror;onmessage;sessionId;setProtocolVersion}var o_=v([u("light"),u("dark")]).describe("Color theme preference for the host environment."),Ys=v([u("inline"),u("fullscreen"),u("pip")]).describe("Display mode for UI presentation."),r_=v([u("--color-background-primary"),u("--color-background-secondary"),u("--color-background-tertiary"),u("--color-background-inverse"),u("--color-background-ghost"),u("--color-background-info"),u("--color-background-danger"),u("--color-background-success"),u("--color-background-warning"),u("--color-background-disabled"),u("--color-text-primary"),u("--color-text-secondary"),u("--color-text-tertiary"),u("--color-text-inverse"),u("--color-text-ghost"),u("--color-text-info"),u("--color-text-danger"),u("--color-text-success"),u("--color-text-warning"),u("--color-text-disabled"),u("--color-border-primary"),u("--color-border-secondary"),u("--color-border-tertiary"),u("--color-border-inverse"),u("--color-border-ghost"),u("--color-border-info"),u("--color-border-danger"),u("--color-border-success"),u("--color-border-warning"),u("--color-border-disabled"),u("--color-ring-primary"),u("--color-ring-secondary"),u("--color-ring-inverse"),u("--color-ring-info"),u("--color-ring-danger"),u("--color-ring-success"),u("--color-ring-warning"),u("--font-sans"),u("--font-mono"),u("--font-weight-normal"),u("--font-weight-medium"),u("--font-weight-semibold"),u("--font-weight-bold"),u("--font-text-xs-size"),u("--font-text-sm-size"),u("--font-text-md-size"),u("--font-text-lg-size"),u("--font-heading-xs-size"),u("--font-heading-sm-size"),u("--font-heading-md-size"),u("--font-heading-lg-size"),u("--font-heading-xl-size"),u("--font-heading-2xl-size"),u("--font-heading-3xl-size"),u("--font-text-xs-line-height"),u("--font-text-sm-line-height"),u("--font-text-md-line-height"),u("--font-text-lg-line-height"),u("--font-heading-xs-line-height"),u("--font-heading-sm-line-height"),u("--font-heading-md-line-height"),u("--font-heading-lg-line-height"),u("--font-heading-xl-line-height"),u("--font-heading-2xl-line-height"),u("--font-heading-3xl-line-height"),u("--border-radius-xs"),u("--border-radius-sm"),u("--border-radius-md"),u("--border-radius-lg"),u("--border-radius-xl"),u("--border-radius-full"),u("--border-width-regular"),u("--shadow-hairline"),u("--shadow-sm"),u("--shadow-md"),u("--shadow-lg")]).describe("CSS variable keys available to MCP apps for theming."),n_=b(r_.describe(`Style variables for theming MCP apps.
|
|
68
|
+
*/var L_=Dl((e)=>{var t=/; *([!#$%&'*+.^_`|~0-9A-Za-z-]+) *= *("(?:[\u000b\u0020\u0021\u0023-\u005b\u005d-\u007e\u0080-\u00ff]|\\[\u000b\u0020-\u00ff])*"|[!#$%&'*+.^_`|~0-9A-Za-z-]+) */g,o=/\\([\u000b\u0020-\u00ff])/g,r=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+\/[!#$%&'*+.^_`|~0-9A-Za-z-]+$/;e.parse=n;function n(c){if(!c)throw TypeError("argument string is required");var l=typeof c==="object"?s(c):c;if(typeof l!=="string")throw TypeError("argument string is required to be a string");var u=l.indexOf(";"),h=u!==-1?l.slice(0,u).trim():l.trim();if(!r.test(h))throw TypeError("invalid media type");var m=new i(h.toLowerCase());if(u!==-1){var S,g,b;t.lastIndex=u;while(g=t.exec(l)){if(g.index!==u)throw TypeError("invalid parameter format");if(u+=g[0].length,S=g[1].toLowerCase(),b=g[2],b.charCodeAt(0)===34){if(b=b.slice(1,-1),b.indexOf("\\")!==-1)b=b.replace(o,"$1")}m.parameters[S]=b}if(u!==l.length)throw TypeError("invalid parameter format")}return m}function s(c){var l;if(typeof c.getHeader==="function")l=c.getHeader("content-type");else if(typeof c.headers==="object")l=c.headers&&c.headers["content-type"];if(typeof l!=="string")throw TypeError("content-type header is missing from object");return l}function i(c){this.parameters=Object.create(null),this.type=c}}),Hz=Hl(L_(),1);function pi(e,t){let o=typeof e;if(o!==typeof t)return!1;if(Array.isArray(e)){if(!Array.isArray(t))return!1;let r=e.length;if(r!==t.length)return!1;for(let n=0;n<r;n++)if(!pi(e[n],t[n]))return!1;return!0}if(o==="object"){if(!e||!t)return e===t;let r=Object.keys(e),n=Object.keys(t);if(r.length!==n.length)return!1;for(let s of r)if(!pi(e[s],t[s]))return!1;return!0}return e===t}function We(e){return encodeURI(U_(e))}function U_(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}var Z_={prefixItems:!0,items:!0,allOf:!0,anyOf:!0,oneOf:!0},D_={$defs:!0,definitions:!0,properties:!0,patternProperties:!0,dependentSchemas:!0},V_={id:!0,$id:!0,$ref:!0,$schema:!0,$anchor:!0,$vocabulary:!0,$comment:!0,default:!0,enum:!0,const:!0,required:!0,type:!0,maximum:!0,minimum:!0,exclusiveMaximum:!0,exclusiveMinimum:!0,multipleOf:!0,maxLength:!0,minLength:!0,pattern:!0,format:!0,maxItems:!0,minItems:!0,uniqueItems:!0,maxProperties:!0,minProperties:!0},H_=typeof self<"u"&&self.location&&self.location.origin!=="null"?new URL(self.location.origin+self.location.pathname+location.search):new URL("https://github.com/cfworker");function To(e,t=Object.create(null),o=H_,r=""){if(e&&typeof e==="object"&&!Array.isArray(e)){let s=e.$id||e.id;if(s){let i=new URL(s,o.href);if(i.hash.length>1)t[i.href]=e;else if(i.hash="",r==="")o=i;else To(e,t,o)}}else if(e!==!0&&e!==!1)return t;let n=o.href+(r?"#"+r:"");if(t[n]!==void 0)throw Error(`Duplicate schema URI "${n}".`);if(t[n]=e,e===!0||e===!1)return t;if(e.__absolute_uri__===void 0)Object.defineProperty(e,"__absolute_uri__",{enumerable:!1,value:n});if(e.$ref&&e.__absolute_ref__===void 0){let s=new URL(e.$ref,o.href);s.hash=s.hash,Object.defineProperty(e,"__absolute_ref__",{enumerable:!1,value:s.href})}if(e.$recursiveRef&&e.__absolute_recursive_ref__===void 0){let s=new URL(e.$recursiveRef,o.href);s.hash=s.hash,Object.defineProperty(e,"__absolute_recursive_ref__",{enumerable:!1,value:s.href})}if(e.$anchor){let s=new URL("#"+e.$anchor,o.href);t[s.href]=e}for(let s in e){if(V_[s])continue;let i=`${r}/${We(s)}`,c=e[s];if(Array.isArray(c)){if(Z_[s]){let l=c.length;for(let u=0;u<l;u++)To(c[u],t,o,`${i}/${u}`)}}else if(D_[s])for(let l in c)To(c[l],t,o,`${i}/${We(l)}`);else To(c,t,o,i)}return t}var F_=/^(\d\d\d\d)-(\d\d)-(\d\d)$/,J_=[0,31,28,31,30,31,30,31,31,30,31,30,31],B_=/^(\d\d):(\d\d):(\d\d)(\.\d+)?(z|[+-]\d\d(?::?\d\d)?)?$/i,G_=/^(?=.{1,253}\.?$)[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[-0-9a-z]{0,61}[0-9a-z])?)*\.?$/i,W_=/^(?:[a-z][a-z0-9+\-.]*:)?(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'"()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?(?:\?(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i,K_=/^(?:(?:[^\x00-\x20"'<>%\\^`{|}]|%[0-9a-f]{2})|\{[+#./;?&=,!@|]?(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?(?:,(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?)*\})*$/i,Y_=/^(?:(?:https?|ftp):\/\/)(?:\S+(?::\S*)?@)?(?:(?!10(?:\.\d{1,3}){3})(?!127(?:\.\d{1,3}){3})(?!169\.254(?:\.\d{1,3}){2})(?!192\.168(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z\u{00a1}-\u{ffff}0-9]+-?)*[a-z\u{00a1}-\u{ffff}0-9]+)(?:\.(?:[a-z\u{00a1}-\u{ffff}0-9]+-?)*[a-z\u{00a1}-\u{ffff}0-9]+)*(?:\.(?:[a-z\u{00a1}-\u{ffff}]{2,})))(?::\d{2,5})?(?:\/[^\s]*)?$/iu,Q_=/^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i,X_=/^(?:\/(?:[^~/]|~0|~1)*)*$/,ey=/^#(?:\/(?:[a-z0-9_\-.!$&'()*+,;:=@]|%[0-9a-f]{2}|~0|~1)*)*$/i,ty=/^(?:0|[1-9][0-9]*)(?:#|(?:\/(?:[^~/]|~0|~1)*)*)$/,oy=(e)=>{if(e[0]==='"')return!1;let[t,o,...r]=e.split("@");if(!t||!o||r.length!==0||t.length>64||o.length>253)return!1;if(t[0]==="."||t.endsWith(".")||t.includes(".."))return!1;if(!/^[a-z0-9.-]+$/i.test(o)||!/^[a-z0-9.!#$%&'*+/=?^_`{|}~-]+$/i.test(t))return!1;return o.split(".").every((n)=>/^[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?$/i.test(n))},ry=/^(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)$/,ny=/^((([0-9a-f]{1,4}:){7}([0-9a-f]{1,4}|:))|(([0-9a-f]{1,4}:){6}(:[0-9a-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){5}(((:[0-9a-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){4}(((:[0-9a-f]{1,4}){1,3})|((:[0-9a-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){3}(((:[0-9a-f]{1,4}){1,4})|((:[0-9a-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){2}(((:[0-9a-f]{1,4}){1,5})|((:[0-9a-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){1}(((:[0-9a-f]{1,4}){1,6})|((:[0-9a-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9a-f]{1,4}){1,7})|((:[0-9a-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))$/i,sy=(e)=>e.length>1&&e.length<80&&(/^P\d+([.,]\d+)?W$/.test(e)||/^P[\dYMDTHS]*(\d[.,]\d+)?[YMDHS]$/.test(e)&&/^P([.,\d]+Y)?([.,\d]+M)?([.,\d]+D)?(T([.,\d]+H)?([.,\d]+M)?([.,\d]+S)?)?$/.test(e));function pt(e){return e.test.bind(e)}var Jm={date:Bm,time:Gm.bind(void 0,!1),"date-time":cy,duration:sy,uri:dy,"uri-reference":pt(W_),"uri-template":pt(K_),url:pt(Y_),email:oy,hostname:pt(G_),ipv4:pt(ry),ipv6:pt(ny),regex:hy,uuid:pt(Q_),"json-pointer":pt(X_),"json-pointer-uri-fragment":pt(ey),"relative-json-pointer":pt(ty)};function iy(e){return e%4===0&&(e%100!==0||e%400===0)}function Bm(e){let t=e.match(F_);if(!t)return!1;let o=+t[1],r=+t[2],n=+t[3];return r>=1&&r<=12&&n>=1&&n<=(r==2&&iy(o)?29:J_[r])}function Gm(e,t){let o=t.match(B_);if(!o)return!1;let r=+o[1],n=+o[2],s=+o[3],i=!!o[5];return(r<=23&&n<=59&&s<=59||r==23&&n==59&&s==60)&&(!e||i)}var ay=/t|\s/i;function cy(e){let t=e.split(ay);return t.length==2&&Bm(t[0])&&Gm(!0,t[1])}var ly=/\/|:/,uy=/^(?:[a-z][a-z0-9+\-.]*:)(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)(?:\?(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i;function dy(e){return ly.test(e)&&uy.test(e)}var py=/[^\\]\\Z/;function hy(e){if(py.test(e))return!1;try{return new RegExp(e,"u"),!0}catch(t){return!1}}function my(e){let t=0,o=e.length,r=0,n;while(r<o)if(t++,n=e.charCodeAt(r++),n>=55296&&n<=56319&&r<o){if(n=e.charCodeAt(r),(n&64512)==56320)r++}return t}function ae(e,t,o="2019-09",r=To(t),n=!0,s=null,i="#",c="#",l=Object.create(null)){if(t===!0)return{valid:!0,errors:[]};if(t===!1)return{valid:!1,errors:[{instanceLocation:i,keyword:"false",keywordLocation:i,error:"False boolean schema."}]};let u=typeof e,h;switch(u){case"boolean":case"number":case"string":h=u;break;case"object":if(e===null)h="null";else if(Array.isArray(e))h="array";else h="object";break;default:throw Error(`Instances of "${u}" type are not supported.`)}let{$ref:m,$recursiveRef:S,$recursiveAnchor:g,type:b,const:v,enum:R,required:q,not:V,anyOf:P,allOf:H,oneOf:B,if:G,then:Y,else:ue,format:oe,properties:fe,patternProperties:Ve,additionalProperties:Tt,unevaluatedProperties:Et,minProperties:Ye,maxProperties:Me,propertyNames:Qe,dependentRequired:Pe,dependentSchemas:qe,dependencies:Xe,prefixItems:$e,items:be,additionalItems:mt,unevaluatedItems:ft,contains:et,minContains:ge,maxContains:ve,minItems:ze,maxItems:He,uniqueItems:Gt,minimum:Ce,maximum:Ie,exclusiveMinimum:Te,exclusiveMaximum:je,multipleOf:Le,minLength:tt,maxLength:ot,pattern:kt,__absolute_ref__:rt,__absolute_recursive_ref__:Wt}=t,E=[];if(g===!0&&s===null)s=t;if(S==="#"){let L=s===null?r[Wt]:s,I=`${c}/$recursiveRef`,J=ae(e,s===null?t:s,o,r,n,L,i,I,l);if(!J.valid)E.push({instanceLocation:i,keyword:"$recursiveRef",keywordLocation:I,error:"A subschema had errors."},...J.errors)}if(m!==void 0){let L=r[rt||m];if(L===void 0){let k=`Unresolved $ref "${m}".`;if(rt&&rt!==m)k+=` Absolute URI "${rt}".`;throw k+=`
|
|
69
|
+
Known schemas:
|
|
70
|
+
- ${Object.keys(r).join(`
|
|
71
|
+
- `)}`,Error(k)}let I=`${c}/$ref`,J=ae(e,L,o,r,n,s,i,I,l);if(!J.valid)E.push({instanceLocation:i,keyword:"$ref",keywordLocation:I,error:"A subschema had errors."},...J.errors);if(o==="4"||o==="7")return{valid:E.length===0,errors:E}}if(Array.isArray(b)){let L=b.length,I=!1;for(let J=0;J<L;J++)if(h===b[J]||b[J]==="integer"&&h==="number"&&e%1===0&&e===e){I=!0;break}if(!I)E.push({instanceLocation:i,keyword:"type",keywordLocation:`${c}/type`,error:`Instance type "${h}" is invalid. Expected "${b.join('", "')}".`})}else if(b==="integer"){if(h!=="number"||e%1||e!==e)E.push({instanceLocation:i,keyword:"type",keywordLocation:`${c}/type`,error:`Instance type "${h}" is invalid. Expected "${b}".`})}else if(b!==void 0&&h!==b)E.push({instanceLocation:i,keyword:"type",keywordLocation:`${c}/type`,error:`Instance type "${h}" is invalid. Expected "${b}".`});if(v!==void 0){if(h==="object"||h==="array"){if(!pi(e,v))E.push({instanceLocation:i,keyword:"const",keywordLocation:`${c}/const`,error:`Instance does not match ${JSON.stringify(v)}.`})}else if(e!==v)E.push({instanceLocation:i,keyword:"const",keywordLocation:`${c}/const`,error:`Instance does not match ${JSON.stringify(v)}.`})}if(R!==void 0){if(h==="object"||h==="array"){if(!R.some((L)=>pi(e,L)))E.push({instanceLocation:i,keyword:"enum",keywordLocation:`${c}/enum`,error:`Instance does not match any of ${JSON.stringify(R)}.`})}else if(!R.some((L)=>e===L))E.push({instanceLocation:i,keyword:"enum",keywordLocation:`${c}/enum`,error:`Instance does not match any of ${JSON.stringify(R)}.`})}if(V!==void 0){let L=`${c}/not`;if(ae(e,V,o,r,n,s,i,L).valid)E.push({instanceLocation:i,keyword:"not",keywordLocation:L,error:'Instance matched "not" schema.'})}let nt=[];if(P!==void 0){let L=`${c}/anyOf`,I=E.length,J=!1;for(let k=0;k<P.length;k++){let T=P[k],D=Object.create(l),U=ae(e,T,o,r,n,g===!0?s:null,i,`${L}/${k}`,D);if(E.push(...U.errors),J=J||U.valid,U.valid)nt.push(D)}if(J)E.length=I;else E.splice(I,0,{instanceLocation:i,keyword:"anyOf",keywordLocation:L,error:"Instance does not match any subschemas."})}if(H!==void 0){let L=`${c}/allOf`,I=E.length,J=!0;for(let k=0;k<H.length;k++){let T=H[k],D=Object.create(l),U=ae(e,T,o,r,n,g===!0?s:null,i,`${L}/${k}`,D);if(E.push(...U.errors),J=J&&U.valid,U.valid)nt.push(D)}if(J)E.length=I;else E.splice(I,0,{instanceLocation:i,keyword:"allOf",keywordLocation:L,error:"Instance does not match every subschema."})}if(B!==void 0){let L=`${c}/oneOf`,I=E.length,J=B.filter((k,T)=>{let D=Object.create(l),U=ae(e,k,o,r,n,g===!0?s:null,i,`${L}/${T}`,D);if(E.push(...U.errors),U.valid)nt.push(D);return U.valid}).length;if(J===1)E.length=I;else E.splice(I,0,{instanceLocation:i,keyword:"oneOf",keywordLocation:L,error:`Instance does not match exactly one subschema (${J} matches).`})}if(h==="object"||h==="array")Object.assign(l,...nt);if(G!==void 0){let L=`${c}/if`;if(ae(e,G,o,r,n,s,i,L,l).valid){if(Y!==void 0){let I=ae(e,Y,o,r,n,s,i,`${c}/then`,l);if(!I.valid)E.push({instanceLocation:i,keyword:"if",keywordLocation:L,error:'Instance does not match "then" schema.'},...I.errors)}}else if(ue!==void 0){let I=ae(e,ue,o,r,n,s,i,`${c}/else`,l);if(!I.valid)E.push({instanceLocation:i,keyword:"if",keywordLocation:L,error:'Instance does not match "else" schema.'},...I.errors)}}if(h==="object"){if(q!==void 0){for(let k of q)if(!(k in e))E.push({instanceLocation:i,keyword:"required",keywordLocation:`${c}/required`,error:`Instance does not have required property "${k}".`})}let L=Object.keys(e);if(Ye!==void 0&&L.length<Ye)E.push({instanceLocation:i,keyword:"minProperties",keywordLocation:`${c}/minProperties`,error:`Instance does not have at least ${Ye} properties.`});if(Me!==void 0&&L.length>Me)E.push({instanceLocation:i,keyword:"maxProperties",keywordLocation:`${c}/maxProperties`,error:`Instance does not have at least ${Me} properties.`});if(Qe!==void 0){let k=`${c}/propertyNames`;for(let T in e){let D=`${i}/${We(T)}`,U=ae(T,Qe,o,r,n,s,D,k);if(!U.valid)E.push({instanceLocation:i,keyword:"propertyNames",keywordLocation:k,error:`Property name "${T}" does not match schema.`},...U.errors)}}if(Pe!==void 0){let k=`${c}/dependantRequired`;for(let T in Pe)if(T in e){let D=Pe[T];for(let U of D)if(!(U in e))E.push({instanceLocation:i,keyword:"dependentRequired",keywordLocation:k,error:`Instance has "${T}" but does not have "${U}".`})}}if(qe!==void 0)for(let k in qe){let T=`${c}/dependentSchemas`;if(k in e){let D=ae(e,qe[k],o,r,n,s,i,`${T}/${We(k)}`,l);if(!D.valid)E.push({instanceLocation:i,keyword:"dependentSchemas",keywordLocation:T,error:`Instance has "${k}" but does not match dependant schema.`},...D.errors)}}if(Xe!==void 0){let k=`${c}/dependencies`;for(let T in Xe)if(T in e){let D=Xe[T];if(Array.isArray(D)){for(let U of D)if(!(U in e))E.push({instanceLocation:i,keyword:"dependencies",keywordLocation:k,error:`Instance has "${T}" but does not have "${U}".`})}else{let U=ae(e,D,o,r,n,s,i,`${k}/${We(T)}`);if(!U.valid)E.push({instanceLocation:i,keyword:"dependencies",keywordLocation:k,error:`Instance has "${T}" but does not match dependant schema.`},...U.errors)}}}let I=Object.create(null),J=!1;if(fe!==void 0){let k=`${c}/properties`;for(let T in fe){if(!(T in e))continue;let D=`${i}/${We(T)}`,U=ae(e[T],fe[T],o,r,n,s,D,`${k}/${We(T)}`);if(U.valid)l[T]=I[T]=!0;else if(J=n,E.push({instanceLocation:i,keyword:"properties",keywordLocation:k,error:`Property "${T}" does not match schema.`},...U.errors),J)break}}if(!J&&Ve!==void 0){let k=`${c}/patternProperties`;for(let T in Ve){let D=new RegExp(T,"u"),U=Ve[T];for(let le in e){if(!D.test(le))continue;let Kt=`${i}/${We(le)}`,st=ae(e[le],U,o,r,n,s,Kt,`${k}/${We(T)}`);if(st.valid)l[le]=I[le]=!0;else J=n,E.push({instanceLocation:i,keyword:"patternProperties",keywordLocation:k,error:`Property "${le}" matches pattern "${T}" but does not match associated schema.`},...st.errors)}}}if(!J&&Tt!==void 0){let k=`${c}/additionalProperties`;for(let T in e){if(I[T])continue;let D=`${i}/${We(T)}`,U=ae(e[T],Tt,o,r,n,s,D,k);if(U.valid)l[T]=!0;else J=n,E.push({instanceLocation:i,keyword:"additionalProperties",keywordLocation:k,error:`Property "${T}" does not match additional properties schema.`},...U.errors)}}else if(!J&&Et!==void 0){let k=`${c}/unevaluatedProperties`;for(let T in e)if(!l[T]){let D=`${i}/${We(T)}`,U=ae(e[T],Et,o,r,n,s,D,k);if(U.valid)l[T]=!0;else E.push({instanceLocation:i,keyword:"unevaluatedProperties",keywordLocation:k,error:`Property "${T}" does not match unevaluated properties schema.`},...U.errors)}}}else if(h==="array"){if(He!==void 0&&e.length>He)E.push({instanceLocation:i,keyword:"maxItems",keywordLocation:`${c}/maxItems`,error:`Array has too many items (${e.length} > ${He}).`});if(ze!==void 0&&e.length<ze)E.push({instanceLocation:i,keyword:"minItems",keywordLocation:`${c}/minItems`,error:`Array has too few items (${e.length} < ${ze}).`});let L=e.length,I=0,J=!1;if($e!==void 0){let k=`${c}/prefixItems`,T=Math.min($e.length,L);for(;I<T;I++){let D=ae(e[I],$e[I],o,r,n,s,`${i}/${I}`,`${k}/${I}`);if(l[I]=!0,!D.valid){if(J=n,E.push({instanceLocation:i,keyword:"prefixItems",keywordLocation:k,error:"Items did not match schema."},...D.errors),J)break}}}if(be!==void 0){let k=`${c}/items`;if(Array.isArray(be)){let T=Math.min(be.length,L);for(;I<T;I++){let D=ae(e[I],be[I],o,r,n,s,`${i}/${I}`,`${k}/${I}`);if(l[I]=!0,!D.valid){if(J=n,E.push({instanceLocation:i,keyword:"items",keywordLocation:k,error:"Items did not match schema."},...D.errors),J)break}}}else for(;I<L;I++){let T=ae(e[I],be,o,r,n,s,`${i}/${I}`,k);if(l[I]=!0,!T.valid){if(J=n,E.push({instanceLocation:i,keyword:"items",keywordLocation:k,error:"Items did not match schema."},...T.errors),J)break}}if(!J&&mt!==void 0){let T=`${c}/additionalItems`;for(;I<L;I++){let D=ae(e[I],mt,o,r,n,s,`${i}/${I}`,T);if(l[I]=!0,!D.valid)J=n,E.push({instanceLocation:i,keyword:"additionalItems",keywordLocation:T,error:"Items did not match additional items schema."},...D.errors)}}}if(et!==void 0)if(L===0&&ge===void 0)E.push({instanceLocation:i,keyword:"contains",keywordLocation:`${c}/contains`,error:"Array is empty. It must contain at least one item matching the schema."});else if(ge!==void 0&&L<ge)E.push({instanceLocation:i,keyword:"minContains",keywordLocation:`${c}/minContains`,error:`Array has less items (${L}) than minContains (${ge}).`});else{let k=`${c}/contains`,T=E.length,D=0;for(let U=0;U<L;U++){let le=ae(e[U],et,o,r,n,s,`${i}/${U}`,k);if(le.valid)l[U]=!0,D++;else E.push(...le.errors)}if(D>=(ge||0))E.length=T;if(ge===void 0&&ve===void 0&&D===0)E.splice(T,0,{instanceLocation:i,keyword:"contains",keywordLocation:k,error:"Array does not contain item matching schema."});else if(ge!==void 0&&D<ge)E.push({instanceLocation:i,keyword:"minContains",keywordLocation:`${c}/minContains`,error:`Array must contain at least ${ge} items matching schema. Only ${D} items were found.`});else if(ve!==void 0&&D>ve)E.push({instanceLocation:i,keyword:"maxContains",keywordLocation:`${c}/maxContains`,error:`Array may contain at most ${ve} items matching schema. ${D} items were found.`})}if(!J&&ft!==void 0){let k=`${c}/unevaluatedItems`;for(;I<L;I++){if(l[I])continue;let T=ae(e[I],ft,o,r,n,s,`${i}/${I}`,k);if(l[I]=!0,!T.valid)E.push({instanceLocation:i,keyword:"unevaluatedItems",keywordLocation:k,error:"Items did not match unevaluated items schema."},...T.errors)}}if(Gt)for(let k=0;k<L;k++){let T=e[k],D=typeof T==="object"&&T!==null;for(let U=0;U<L;U++){if(k===U)continue;let le=e[U];if(T===le||D&&typeof le==="object"&&le!==null&&pi(T,le))E.push({instanceLocation:i,keyword:"uniqueItems",keywordLocation:`${c}/uniqueItems`,error:`Duplicate items at indexes ${k} and ${U}.`}),k=Number.MAX_SAFE_INTEGER,U=Number.MAX_SAFE_INTEGER}}}else if(h==="number"){if(o==="4"){if(Ce!==void 0&&(Te===!0&&e<=Ce||e<Ce))E.push({instanceLocation:i,keyword:"minimum",keywordLocation:`${c}/minimum`,error:`${e} is less than ${Te?"or equal to ":""} ${Ce}.`});if(Ie!==void 0&&(je===!0&&e>=Ie||e>Ie))E.push({instanceLocation:i,keyword:"maximum",keywordLocation:`${c}/maximum`,error:`${e} is greater than ${je?"or equal to ":""} ${Ie}.`})}else{if(Ce!==void 0&&e<Ce)E.push({instanceLocation:i,keyword:"minimum",keywordLocation:`${c}/minimum`,error:`${e} is less than ${Ce}.`});if(Ie!==void 0&&e>Ie)E.push({instanceLocation:i,keyword:"maximum",keywordLocation:`${c}/maximum`,error:`${e} is greater than ${Ie}.`});if(Te!==void 0&&e<=Te)E.push({instanceLocation:i,keyword:"exclusiveMinimum",keywordLocation:`${c}/exclusiveMinimum`,error:`${e} is less than ${Te}.`});if(je!==void 0&&e>=je)E.push({instanceLocation:i,keyword:"exclusiveMaximum",keywordLocation:`${c}/exclusiveMaximum`,error:`${e} is greater than or equal to ${je}.`})}if(Le!==void 0){let L=e%Le;if(Math.abs(0-L)>=0.00000011920929&&Math.abs(Le-L)>=0.00000011920929)E.push({instanceLocation:i,keyword:"multipleOf",keywordLocation:`${c}/multipleOf`,error:`${e} is not a multiple of ${Le}.`})}}else if(h==="string"){let L=tt===void 0&&ot===void 0?0:my(e);if(tt!==void 0&&L<tt)E.push({instanceLocation:i,keyword:"minLength",keywordLocation:`${c}/minLength`,error:`String is too short (${L} < ${tt}).`});if(ot!==void 0&&L>ot)E.push({instanceLocation:i,keyword:"maxLength",keywordLocation:`${c}/maxLength`,error:`String is too long (${L} > ${ot}).`});if(kt!==void 0&&!new RegExp(kt,"u").test(e))E.push({instanceLocation:i,keyword:"pattern",keywordLocation:`${c}/pattern`,error:"String does not match pattern."});if(oe!==void 0&&Jm[oe]&&!Jm[oe](e))E.push({instanceLocation:i,keyword:"format",keywordLocation:`${c}/format`,error:`String does not match format "${oe}".`})}return{valid:E.length===0,errors:E}}var fy=class{schema;draft;shortCircuit;lookup;constructor(e,t="2019-09",o=!0){this.schema=e,this.draft=t,this.shortCircuit=o,this.lookup=To(e)}validate(e){return ae(e,this.schema,this.draft,this.lookup,this.shortCircuit)}addSchema(e,t){if(t)e={...e,$id:t};To(e,this.lookup)}},La=class{shortcircuit;draft;constructor(e){this.shortcircuit=e?.shortcircuit??!0,this.draft=e?.draft}_draftFor(e){let t=Bl(e,"pass an explicit { draft } to CfWorkerJsonSchemaValidator to validate other dialects.");return t==="draft-7"?"7":t}getValidator(e){let t=new fy(e,this.draft??this._draftFor(e),this.shortcircuit);return(o)=>{let r=t.validate(o);return r.valid?{valid:!0,data:o,errorMessage:void 0}:{valid:!1,data:void 0,errorMessage:r.errors.map((n)=>`${n.instanceLocation}: ${n.error}`).join("; ")}}}};var gy;gy=globalThis.crypto;var wr=class extends Error{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.OAuthClientFlowError"})}static[Symbol.hasInstance](e){return ke(this,e)}static isInstance(e){if(typeof this!=="function")throw TypeError("isInstance must be called on the class (e.g. `SdkError.isInstance(value)`); for callbacks use `v => SdkError.isInstance(v)`");return ke(this,e)}constructor(e){super(e);this.name=new.target.name,Ft(this,new.target)}},zy=class extends wr{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.IssuerMismatchError"})}kind;expected;received;constructor(e,t,o){super(`Issuer mismatch in ${e==="metadata"?"authorization server metadata (RFC 8414 §3.3)":"authorization response (RFC 9207)"}: expected ${JSON.stringify(t)}, received ${JSON.stringify(o)}`);this.kind=e,this.expected=t,this.received=o}},Ry=class extends wr{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.RegistrationRejectedError"})}status;body;submittedMetadata;constructor(e){super(`Dynamic Client Registration rejected (HTTP ${e.status}): ${e.body}`);this.status=e.status,this.body=e.body,this.submittedMetadata=e.submittedMetadata}},wy=class extends wr{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.InsecureTokenEndpointError"})}tokenEndpoint;constructor(e){super(`Refusing to send credentials to non-https token endpoint '${e}'. OAuth token requests MUST use TLS (localhost / *.localhost / 127.0.0.1 / ::1 are exempt).`);this.tokenEndpoint=e}},xy=class extends wr{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.AuthorizationServerMismatchError"})}constructor(e,t){super(`Authorization server mismatch: credentials are bound to ${JSON.stringify(e)} but this call resolved ${JSON.stringify(t)}; refusing to present them to a different authorization server`);this.recordedIssuer=e,this.currentIssuer=t}},Py=class extends wr{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.InsufficientScopeError"})}requiredScope;resourceMetadataUrl;errorDescription;constructor(e){super(`Insufficient scope${e.requiredScope?`: required "${e.requiredScope}"`:""}`);this.requiredScope=e.requiredScope,this.resourceMetadataUrl=e.resourceMetadataUrl,this.errorDescription=e.errorDescription}};var of=class extends Error{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.UnauthorizedError"})}static[Symbol.hasInstance](e){return ke(this,e)}static isInstance(e){if(typeof this!=="function")throw TypeError("isInstance must be called on the class (e.g. `SdkError.isInstance(value)`); for callbacks use `v => SdkError.isInstance(v)`");return ke(this,e)}constructor(e){super(e??"Unauthorized");this.name="UnauthorizedError",Ft(this,new.target)}};var Ua=new Set(["tools/list","prompts/list","resources/list","resources/templates/list","server/discover"]),rf=class{_entries=new Map;_maxEntries;_stamp=0;_cappedSize=0;constructor(e){this._maxEntries=e?.maxEntries??512}get size(){return this._entries.size}get(e){return this._entries.get(xl(e))}set(e,t){let o=xl(e),r=Ua.has(e.method),n=!this._entries.has(o);if(!r&&n&&this._maxEntries>0&&this._cappedSize>=this._maxEntries){for(let i of this._entries.keys())if(!Ua.has(i.slice(0,i.indexOf("\x00")))){this._entries.delete(i),this._cappedSize--;break}}let s=++this._stamp;if(this._entries.set(o,{...t,stamp:s}),n&&!r)this._cappedSize++;return s}delete(e){if(this._entries.delete(xl(e))&&!Ua.has(e.method))this._cappedSize--}evict(e){let t=`${e}\x00`,o=Ua.has(e);for(let r of this._entries.keys())if(r.startsWith(t)){if(this._entries.delete(r),!o)this._cappedSize--}}clear(){this._entries.clear(),this._cappedSize=0}};function xl(e){return`${e.method}\x00${JSON.stringify([e.partition??"",e.params??""])}`}function Pl(e,t){return t===void 0?e:`${e}\x00${t}`}var nf=86400000,Ty=class{_evictionGeneration=new Map;_toolIndex;_toolOutputValidatorIndex;_serverIdentity="";constructor(e,t,o=()=>{},r="",n=Date.now){this._store=e,this._isUserSupplied=t,this._reportError=o,this._cachePartition=r,this._now=n}now(){return this._now()}setServerIdentity(e){this._serverIdentity=e}_partitionFor(e){return JSON.stringify([this._serverIdentity,e==="public"?"":this._cachePartition])}async _probe(e,t){let o={method:e,params:t??""},r=this._partitionFor("private"),n=await this._store.get({...o,partition:r});if(n!==void 0)return n;let s=this._partitionFor("public");if(s===r)return;let i=await this._store.get({...o,partition:s});return i?.scope==="public"?i:void 0}async evict(e){this._evictionGeneration.set(e,(this._evictionGeneration.get(e)??0)+1),await this._deleteBoth(e,"")}async _deleteBoth(e,t){let o=this._partitionFor("private"),r=this._partitionFor("public");try{await this._store.delete({method:e,params:t,partition:o})}catch(n){this._reportError(n)}if(r!==o)try{await this._store.delete({method:e,params:t,partition:r})}catch(n){this._reportError(n)}}async evictKey(e,t){let o=Pl(e,t),r=this._evictionGeneration.get(o);if(r!==void 0)this._evictionGeneration.set(o,r+1);await this._deleteBoth(e,t)}captureGeneration(e,t){let o=Pl(e,t),r=this._evictionGeneration.get(o)??0;return this._evictionGeneration.set(o,r),r}async write(e,t,o,r){if((this._evictionGeneration.get(Pl(e,r?.params))??0)!==o)return;let n=r?.params??"",s=this._partitionFor("private"),i=this._partitionFor("public"),c=(r?.scope??"private")==="public"?i:s;try{await this._store.set({method:e,params:n,partition:c},{value:Ey(t),expiresAt:r?.expiresAt,scope:r?.scope})}catch(l){this._reportError(l)}if(i!==s)try{await this._store.delete({method:e,params:n,partition:c===s?i:s})}catch(l){this._reportError(l)}}async read(e,t){let o=await this._probe(e,t);if(o?.expiresAt===void 0||!(o.expiresAt>this.now()))return;try{let r=JSON.parse(o.value);if(typeof r!=="object"||r===null||Array.isArray(r))throw TypeError("cached document is not an object");return{value:r}}catch(r){this._reportError(r),await this._deleteBoth(e,t??"");return}}resetForReconnect(){if(!this._isUserSupplied)this._store.clear();this._evictionGeneration.clear(),this._toolIndex=void 0,this._toolOutputValidatorIndex=void 0,this._serverIdentity=""}async toolDefinition(e){let t=await this._probe("tools/list");if(t===void 0){this._toolIndex=void 0;return}if(this._toolIndex?.stamp!==t.stamp){let o=this._decodeListTools(t),r=new Map;if(o!==void 0)for(let n of o.tools)r.set(n.name,n);this._toolIndex={stamp:t.stamp,byName:r}}return this._toolIndex.byName.get(e)}async outputValidator(e,t){let o=await this._probe("tools/list");if(o===void 0){this._toolOutputValidatorIndex=void 0;return}if(this._toolOutputValidatorIndex?.stamp!==o.stamp){let r=this._decodeListTools(o)??{tools:[]},n=new Map;for(let s of r.tools){let i=t(s);if(i!==void 0)n.set(s.name,i)}this._toolOutputValidatorIndex={stamp:o.stamp,byName:n}}return this._toolOutputValidatorIndex.byName.get(e)}_decodeListTools(e){try{let t=JSON.parse(e.value);if(!Array.isArray(t?.tools)||!t.tools.every((o)=>o!==null&&typeof o==="object"))throw TypeError("cached tools/list document has a malformed tools array");return t}catch(t){this._reportError(t);return}}};function Ey(e){let t;try{t=JSON.stringify(e)}catch(o){throw TypeError(`cache value is not JSON-serializable: ${o instanceof Error?o.message:String(o)}`)}if(typeof t!=="string")throw TypeError("cache value is not JSON-serializable: it has no JSON representation");return t}var ky=Symbol.for("mcp.authSeamEscape");function $y(e){return(typeof e==="object"&&e!==null||typeof e==="function")&&e[ky]===!0}var Cy=-32022,Iy=new Set([-32001,-32020,-32021]);function Oy(e,t){switch(e.kind){case"result":return Ny(e.result,t);case"rpc-error":return sf(e,t);case"http-error":return Ay(e,t);case"network-error":return Wm(e.error,t);case"unusable-reply":return{kind:"error",error:new C(A.EraNegotiationFailed,`Version negotiation probe failed: the server answered with an unusable reply (${af(e.error)})`,{cause:e.error},{cause:e.error})};case"auth-required":return{kind:"error",error:e.error};case"closed":if(t.transportKind==="stdio")return{kind:"legacy"};return Wm(Error("Connection closed during the version negotiation probe"),t);case"timeout":if(t.transportKind==="stdio")return{kind:"legacy"};return{kind:"error",error:new C(A.RequestTimeout,`Version negotiation probe timed out after ${e.timeoutMs}ms`,{timeout:e.timeoutMs})}}}function Ny(e,t){let o=wt(Ma).validateResult("server/discover",e);if(!o.ok)return{kind:"legacy"};let r=o.value.supportedVersions,n=t.clientModernVersions.find((s)=>r.includes(s));if(n!==void 0)return{kind:"modern",version:n,discover:o.value};if(t.fallbackAvailable)return{kind:"legacy"};return{kind:"error",error:new ci({supported:[...r],requested:t.requestedVersion})}}function sf(e,t){let{code:o,message:r,data:n}=e;if(o===Cy){let s=qy(n);if(s===void 0)return{kind:"legacy"};let i=new ci({supported:s,requested:jy(n)??t.requestedVersion},r),c=ai(s),l=t.clientModernVersions.find((u)=>c.includes(u));if(l!==void 0)return{kind:"corrective",version:l,error:i};if(c.length>0)return{kind:"error",error:i};return t.fallbackAvailable?{kind:"legacy"}:{kind:"error",error:i}}if(Iy.has(o))return{kind:"legacy"};return{kind:"legacy"}}function Ay(e,t){if(e.status===401||e.status===403){let r=e.status===403;return{kind:"error",error:new ii(r?A.ClientHttpForbidden:A.ClientHttpAuthentication,`Version negotiation failed: ${r?"the server denied access (HTTP 403)":"the server requires authorization (HTTP 401)"}`,{status:e.status,statusText:e.statusText,text:e.body})}}if(e.status>=500)return{kind:"error",error:new ii(A.EraNegotiationFailed,`Version negotiation failed: the server answered the probe with HTTP ${e.status}`,{status:e.status,statusText:e.statusText,text:e.body})};let o=Ly(e.body);if(o!==void 0)return sf(o,t);return{kind:"legacy"}}function Wm(e,t){if(t.environment==="browser"&&My(e))return{kind:"legacy"};return{kind:"error",error:new C(A.EraNegotiationFailed,`Version negotiation probe failed: ${af(e)}`,{cause:e},{cause:e})}}function My(e){return e instanceof TypeError||e instanceof Error&&e.name==="TypeError"}function af(e){return e instanceof Error?e.message:String(e)}function qy(e){if(typeof e!=="object"||e===null)return;let t=e.supported;if(!Array.isArray(t)||t.length===0||!t.every((o)=>typeof o==="string"))return;return t}function jy(e){if(typeof e!=="object"||e===null)return;let t=e.requested;return typeof t==="string"?t:void 0}function Ly(e){if(e===void 0||e==="")return;let t;try{t=JSON.parse(e)}catch{return}if(typeof t!=="object"||t===null)return;let o=t.error;if(typeof o!=="object"||o===null)return;let{code:r,message:n,data:s}=o;if(typeof r!=="number")return;return{code:r,message:typeof n==="string"?n:"",data:s}}var Uy="legacy";function Zy(e,t){let o=e?.mode??Uy;if(o==="legacy")return{kind:"legacy"};let r=e?.probe??{};if(typeof o==="object"){if(!xt(o.pin))throw TypeError(`versionNegotiation: { pin: '${o.pin}' } is not a modern protocol revision — pinning is for 2026-07-28 and later; omit versionNegotiation (or use mode: 'legacy') for 2025-era servers.`);return{kind:"pin",version:o.pin,probe:r}}let n=t?ai(t):[];return{kind:"auto",modernVersions:n.length>0?n:[...hl],fallbackAvailable:t?ml(t).length>0:!0,probe:r}}function Km(){let e=globalThis;return e.window!==void 0&&e.document!==void 0?"browser":"node"}function Ym(e){return"stderr"in e&&"pid"in e?"stdio":"http"}var Dy=class e{_pending;_probeCounter=0;_savedOnMessage;_savedOnError;_savedOnClose;_closeDelivered=!1;constructor(t){this._transport=t,this._savedOnMessage=t.onmessage,this._savedOnError=t.onerror,this._savedOnClose=t.onclose}static async open(t){let o=new e(t);t.onmessage=(r)=>{let n=o._pending;if(n!==void 0&&(Rr(r)||li(r))&&r.id===n.id){if(o._pending=void 0,Rr(r))n.resolve({kind:"response",result:r.result});else n.resolve({kind:"response",error:r.error});return}},t.onerror=(r)=>{o._savedOnError?.(r)},t.onclose=()=>{let r=o._pending;if(r!==void 0)o._pending=void 0,r.resolve({kind:"closed"});o._closeDelivered=!0,o._savedOnClose?.()};try{await t.start()}catch(r){throw o.detach(),r}return o}async exchange(t,o){let r=`server-discover-probe-${++this._probeCounter}`;return new Promise((n)=>{let s=!1,i=(l)=>{if(s)return;if(s=!0,clearTimeout(c),this._pending?.id===r)this._pending=void 0;n(l)},c=setTimeout(()=>i({kind:"timeout"}),o);this._pending={id:r,resolve:i},this._transport.send(t(r)).catch((l)=>i({kind:"send-error",error:l}))})}detach(){if(this._pending=void 0,this._transport.onmessage=this._savedOnMessage,this._transport.onerror=this._savedOnError,this._closeDelivered&&this._savedOnClose!==void 0){let t=this._savedOnClose,o=this._transport,r=!1,n=()=>{if(!r){r=!0;return}t()};o.onclose=n,El.set(o,()=>{if(o.onclose===n)o.onclose=t})}else this._transport.onclose=this._savedOnClose}release(){this.detach();let t=this._transport,o=t.start,r=!0;t.start=async function(){if(r){r=!1,t.start=o;return}return o.call(t)}}},El=new WeakMap;function Qm(e){let t=El.get(e);El.delete(e),t?.()}function Vy(e,t,o,r){return{jsonrpc:"2.0",id:e,method:"server/discover",params:{_meta:wt(t).outboundEnvelope({protocolVersion:t,clientInfo:o,clientCapabilities:r})}}}function Hy(e){if(e instanceof C&&e.code===A.ClientHttpUnexpectedContent)return!0;return e instanceof Error&&e.name==="SyntaxError"}function Fy(e,t){switch(e.kind){case"response":return e.error===void 0?{kind:"result",result:e.result}:{kind:"rpc-error",...e.error};case"send-error":{let o=e.error;if($y(o)||o instanceof of||o instanceof Error&&o.name==="UnauthorizedError")return{kind:"auth-required",error:o};if(o instanceof ii){let r=o.data?.text;return{kind:"http-error",status:o.data.status,body:typeof r==="string"?r:void 0,statusText:o.data.statusText}}if(Hy(o))return{kind:"unusable-reply",error:o};return{kind:"network-error",error:o}}case"closed":return{kind:"closed"};case"timeout":return{kind:"timeout",timeoutMs:t}}}async function cf(e,t){let o=e.probe.timeoutMs??t.defaultTimeoutMs,r=Math.max(0,e.probe.maxRetries??0),n=e.kind==="pin"?[e.version]:e.modernVersions,s=e.kind==="auto"&&e.fallbackAvailable,i=await Dy.open(t.transport),c=async()=>{let u=n[0],h=!1,m=r;for(;;){let S=await i.exchange((v)=>Vy(v,u,t.clientInfo,t.capabilities),o);if(S.kind==="timeout"&&m>0){m--;continue}let g=Fy(S,o),b=Oy(g,{clientModernVersions:n,requestedVersion:u,fallbackAvailable:s,environment:t.environment,transportKind:t.transportKind});switch(b.kind){case"modern":return{era:"modern",version:b.version,discover:b.discover};case"corrective":if(h)throw b.error;h=!0,u=b.version;continue;case"legacy":{let v=g.kind==="closed"?"the connection closed during the server/discover probe":void 0;if(e.kind==="pin")throw new C(A.EraNegotiationFailed,v===void 0?`Version negotiation failed: the server did not offer pinned protocol version ${e.version} via server/discover (no fallback in pin mode)`:`Version negotiation failed: ${v} before the server offered pinned protocol version ${e.version} (no fallback in pin mode)`);if(!e.fallbackAvailable)throw new C(A.EraNegotiationFailed,v===void 0?"Version negotiation failed: the server gave no modern evidence and this client supports no pre-2026-07-28 protocol version to fall back to":`Version negotiation failed: ${v} and this client supports no pre-2026-07-28 protocol version to fall back to`);if(v!==void 0&&t.disposableProbe!==!0)throw new C(A.EraNegotiationFailed,`Version negotiation failed: ${v} (this transport probed in place — the disposable sibling probe requires the SDK's base StdioClientTransport)`);return{era:"legacy"}}case"error":throw b.error}}},l;try{l=await c()}catch(u){throw i.detach(),u}return i.release(),l}function Jy(e){let t=Object.getPrototypeOf(e);if(t===null||!Object.prototype.hasOwnProperty.call(t,"_dispose"))return;let o=e._serverParams;return typeof o==="object"&&o!==null&&typeof o.command==="string"?o:void 0}async function By(e,t,o,r){let s=new t.constructor({...o,stderr:"ignore"}),i=t.close,c=!1,l,u=new Promise((m,S)=>{l=()=>S(Xm())});t.close=async function(){return c=!0,l?.(),i.call(t)};let h;try{let m=cf(e,{...r,transport:s,transportKind:"stdio",disposableProbe:!0});m.catch(()=>{}),h=await Promise.race([m,u])}finally{await Gy(s),t.close=i}if(c)throw Xm();return h}function Xm(){return new C(A.EraNegotiationFailed,"Version negotiation failed: the transport was closed during the server/discover probe")}async function Gy(e){try{let t=e._dispose;await(typeof t==="function"?t.call(e):e.close())}catch{}}function ef(e){let t=e._meta?.[ct];return zl.Implementation(t)?t:void 0}function Za(e,t){if(!e||t===null||typeof t!=="object")return;if(e.type==="object"&&e.properties&&typeof e.properties==="object"){let o=t,r=e.properties;for(let n of Object.keys(r)){let s=r[n];if(o[n]===void 0&&Object.prototype.hasOwnProperty.call(s,"default"))o[n]=s.default;if(o[n]!==void 0)Za(s,o[n])}}if(Array.isArray(e.anyOf)){for(let o of e.anyOf)if(typeof o!=="boolean")Za(o,t)}if(Array.isArray(e.oneOf)){for(let o of e.oneOf)if(typeof o!=="boolean")Za(o,t)}}function lf(e){if(!e)return{supportsFormMode:!1,supportsUrlMode:!1};let t=e.form!==void 0,o=e.url!==void 0;return{supportsFormMode:t||!t&&!o,supportsUrlMode:o}}function Wy(e){if(typeof e==="object"&&e!==null){if(e.kind==="legacy"&&!("supportedVersions"in e)&&!("discover"in e))return e;if(e.kind==="modern"&&Zt.safeParse(e.discover).success)return e}throw new C(A.EraNegotiationFailed,"connect({ prior }): unrecognized prior — expected { kind: 'modern', discover } or { kind: 'legacy' }")}var tf={"notifications/tools/list_changed":["tools/list"],"notifications/prompts/list_changed":["prompts/list"],"notifications/resources/list_changed":["resources/list","resources/templates/list"]},Ky=64,Tl={},Yy=class extends di{_serverCapabilities;_serverVersion;_capabilities;_instructions;_jsonSchemaValidator;_cache;_defaultCacheTtlMs;_listMaxPages;_listChangedDebounceTimers=new Map;_listChangedConfig;_enforceStrictCapabilities;_versionNegotiation;_supportedProtocolVersionsOption;_inputRequiredDriverConfig;_listenState=new Map;_nextListenId=0;_autoOpenedSubscription;_discoverResult;static{Tl.enforceStrictCapabilities=(e)=>e._enforceStrictCapabilities,Tl.walkPages=(e,t,o,r)=>e._walkPages(t,o,r),Tl.readResource=(e,t,o)=>e._readResource(t,o)}_resetConnectionState(){if(this._negotiatedProtocolVersion=void 0,this._serverCapabilities=void 0,this._serverVersion=void 0,this._instructions=void 0,this._discoverResult=void 0,this._autoOpenedSubscription=void 0,this._listenState.size>0){let e=new C(A.ConnectionClosed,"subscriptions/listen: client reconnected or closed; subscription state from the previous connection was reset");for(let t of this._listenState.values())t.settle({cause:"remote",error:e})}this._listenState.clear();for(let e of this._listChangedDebounceTimers.values())clearTimeout(e);this._listChangedDebounceTimers.clear(),this._cache.resetForReconnect()}async close(){try{await super.close()}finally{this._resetConnectionState()}}constructor(e,t){super(t);if(this._clientInfo=e,this._capabilities=t?.capabilities?{...t.capabilities}:{},this._jsonSchemaValidator=t?.jsonSchemaValidator??new La,this._enforceStrictCapabilities=t?.enforceStrictCapabilities??!1,this._versionNegotiation=t?.versionNegotiation,this._supportedProtocolVersionsOption=t?.supportedProtocolVersions,this._inputRequiredDriverConfig=Zm(t?.inputRequired),this._cache=new Ty(t?.responseCacheStore??new rf,t?.responseCacheStore!==void 0,(o)=>this._reportStoreError(o),t?.cachePartition??""),this._defaultCacheTtlMs=t?.defaultCacheTtlMs??0,this._listMaxPages=t?.listMaxPages??Ky,t?.listChanged)this._listChangedConfig=t.listChanged}buildContext(e,t){return e}_shouldDropInbound(e){if(this._negotiatedProtocolVersion!==void 0&&xt(this._negotiatedProtocolVersion)&&qa(e))return"drop"}_outboundMetaEnvelope(){let e=this._negotiatedProtocolVersion;if(e===void 0)return;return this._wireCodec().outboundEnvelope({protocolVersion:e,clientInfo:this._clientInfo,clientCapabilities:this._capabilities})}_resolveNonCompleteResult(e,t){if(!this._inputRequiredDriverConfig.autoFulfill)return Promise.reject(new C(A.UnsupportedResultType,`Unsupported result type 'input_required' for ${t.request.method}: multi-round-trip auto-fulfilment is not enabled on this instance — pass allowInputRequired: true to handle it manually, or enable inputRequired.autoFulfill`,{resultType:"input_required",method:t.request.method}));return Fm({getRequestHandler:(o)=>this._getRequestHandler(o),buildContext:(o)=>this.buildContext(o,void 0),sessionId:this.transport?.sessionId},this._inputRequiredDriverConfig,e,t)}_setupListChangedHandlers(e){if(e.tools&&this._serverCapabilities?.tools?.listChanged)this._setupListChangedHandler("tools","notifications/tools/list_changed",e.tools,async()=>(await this.listTools(void 0,{cacheMode:"refresh"})).tools);if(e.prompts&&this._serverCapabilities?.prompts?.listChanged)this._setupListChangedHandler("prompts","notifications/prompts/list_changed",e.prompts,async()=>(await this.listPrompts(void 0,{cacheMode:"refresh"})).prompts);if(e.resources&&this._serverCapabilities?.resources?.listChanged)this._setupListChangedHandler("resources","notifications/resources/list_changed",e.resources,async()=>(await this.listResources(void 0,{cacheMode:"refresh"})).resources)}registerCapabilities(e){if(this.transport)throw Error("Cannot register capabilities after connecting to transport");this._capabilities=wl(this._capabilities,e)}setVersionNegotiation(e){if(this.transport)throw Error("Cannot configure version negotiation after connecting to transport");this._versionNegotiation=e}_wrapHandler(e,t){if(e==="elicitation/create")return async(o,r)=>{let n=wt(this._negotiatedProtocolVersion),s=n.validateRequest("elicitation/create",o);if(!s.ok&&s.reason==="not-in-era")s=n.validateInputRequest("elicitation/create",o);if(!s.ok)throw new K(s.reason==="not-in-era"?Z.InternalError:Z.InvalidParams,s.reason==="not-in-era"?"No wire schema for elicitation/create in the resolved era":`Invalid elicitation request: ${s.message}`);let{params:i}=s.value;i.mode=i.mode??"form";let{supportsFormMode:c,supportsUrlMode:l}=lf(this._capabilities.elicitation);if(i.mode==="form"&&!c)throw new K(Z.InvalidParams,"Client does not support form-mode elicitation requests");if(i.mode==="url"&&!l)throw new K(Z.InvalidParams,"Client does not support URL-mode elicitation requests");let u=await t(o,r),h=n.validateResult("elicitation/create",u);if(!h.ok&&h.reason==="not-in-era")h=n.validateInputResponse("elicitation/create",u);if(!h.ok)throw new K(h.reason==="not-in-era"?Z.InternalError:Z.InvalidParams,h.reason==="not-in-era"?"No wire schema for elicitation/create in the resolved era":`Invalid elicitation result: ${h.message}`);let m=h.value,S=i.mode==="form"?i.requestedSchema:void 0;if(i.mode==="form"&&m.action==="accept"&&m.content&&S&&this._capabilities.elicitation?.form?.applyDefaults)try{Za(S,m.content)}catch{}return m};if(e==="sampling/createMessage")return async(o,r)=>{let n=wt(this._negotiatedProtocolVersion),s=n.validateRequest("sampling/createMessage",o);if(!s.ok&&s.reason==="not-in-era")s=n.validateInputRequest("sampling/createMessage",o);if(!s.ok)throw new K(s.reason==="not-in-era"?Z.InternalError:Z.InvalidParams,s.reason==="not-in-era"?"No wire schema for sampling/createMessage in the resolved era":`Invalid sampling request: ${s.message}`);let{params:i}=s.value,c=await t(o,r),l=Boolean(i.tools||i.toolChoice),u=n.samplingResultVariant(l,c);if(!u.ok&&u.reason==="not-in-era")u=n.validateInputResponse("sampling/createMessage",c);if(!u.ok)throw new K(u.reason==="not-in-era"?Z.InternalError:Z.InvalidParams,u.reason==="not-in-era"?"No result schema for sampling/createMessage in the resolved era":`Invalid sampling result: ${u.message}`);return u.value};return t}assertCapability(e,t){if(!this._serverCapabilities?.[e])throw new C(A.CapabilityNotSupported,`Server does not support ${e} (required for ${t})`)}async connect(e,t){if(t?.prior!=null)return this._connectFromPrior(e,Wy(t.prior),t);let o=Zy(this._versionNegotiation,this._supportedProtocolVersionsOption);if(o.kind!=="legacy")return this._connectNegotiated(e,o,t);return this._connectPlainLegacy(e,t)}async _connectPlainLegacy(e,t){if(await super.connect(e),e.sessionId!==void 0){let o=this._negotiatedProtocolVersion;if(o!==void 0)e.setProtocolVersion?.(o);return}this._resetConnectionState(),await this._legacyHandshake(e,t)}async _legacyHandshake(e,t){let o=ml(this._supportedProtocolVersions);try{let r=o[0];if(r===void 0)throw new C(A.EraNegotiationFailed,"Cannot run the initialize handshake: supportedProtocolVersions contains no pre-2026-07-28 protocol version");let n=await this.request({method:"initialize",params:{protocolVersion:r,capabilities:this._capabilities,clientInfo:this._clientInfo}},t);if(n===void 0)throw Error(`Server sent invalid initialize result: ${n}`);if(!o.includes(n.protocolVersion))throw Error(`Server's protocol version is not supported: ${n.protocolVersion}`);if(this._serverCapabilities=n.capabilities,this._serverVersion=n.serverInfo,this._cache.setServerIdentity(this._deriveServerIdentity(e)),e.setProtocolVersion)e.setProtocolVersion(n.protocolVersion);if(this._instructions=n.instructions,await this.notification({method:"notifications/initialized"}),this._negotiatedProtocolVersion=n.protocolVersion,this._listChangedConfig)this._setupListChangedHandlers(this._listChangedConfig)}catch(r){throw this.close(),r}}async _connectNegotiated(e,t,o){if(e.sessionId!==void 0){await super.connect(e);let n=this._negotiatedProtocolVersion;if(n!==void 0&&e.setProtocolVersion)e.setProtocolVersion(n);return}this._resetConnectionState();let r;try{let n=Ym(e),s={clientInfo:this._clientInfo,capabilities:this._capabilities,environment:Km(),defaultTimeoutMs:o?.timeout??ui},i=n==="stdio"?Jy(e):void 0;r=i===void 0?await cf(t,{...s,transport:e,transportKind:n}):await By(t,e,i,s)}catch(n){throw await e.close().catch(()=>{}),Qm(e),n}if(Qm(e),await super.connect(e),r.era==="legacy"){await this._legacyHandshake(e,o);return}if(this._serverCapabilities=r.discover.capabilities,this._serverVersion=ef(r.discover),this._cache.setServerIdentity(this._deriveServerIdentity(e)),this._instructions=r.discover.instructions,this._discoverResult=r.discover,this._negotiatedProtocolVersion=r.version,e.setProtocolVersion)e.setProtocolVersion(r.version);if(this._listChangedConfig){let n=this._listChangedConfig,s=this._serverCapabilities,i={...n.tools&&s?.tools?.listChanged&&{tools:n.tools},...n.prompts&&s?.prompts?.listChanged&&{prompts:n.prompts},...n.resources&&s?.resources?.listChanged&&{resources:n.resources}},c=!0;try{this._setupListChangedHandlers(i)}catch(u){c=!1,this.onerror?.(u instanceof Error?u:Error(String(u)))}let l=c?{...i.tools&&{toolsListChanged:!0},...i.prompts&&{promptsListChanged:!0},...i.resources&&{resourcesListChanged:!0}}:{};if(Object.keys(l).length>0){let u=new AbortController,h=()=>u.abort(o?.signal?.reason);if(o?.signal?.aborted)h();o?.signal?.addEventListener("abort",h);try{this._autoOpenedSubscription=await this.listen(l,{timeout:o?.timeout,signal:u.signal})}catch(m){if(o?.signal?.aborted)throw await this.close().catch(()=>{}),m;this.onerror?.(m instanceof Error?m:Error(String(m)))}finally{o?.signal?.removeEventListener("abort",h)}}}}async _connectFromPrior(e,t,o){if(t.kind==="legacy")return this._connectPlainLegacy(e,o);let r=t.discover;this._resetConnectionState();let n=this._supportedProtocolVersionsOption,s=(n&&ai(n).length>0?ai(n):hl).find((i)=>r.supportedVersions.includes(i));if(s===void 0)throw new C(A.EraNegotiationFailed,"connect({ prior }) with a modern verdict requires a 2026-07-28+ mutual protocol version; the supplied DiscoverResult and this client's supportedProtocolVersions have no modern overlap. For a server known to be legacy, pass prior: { kind: 'legacy' } to skip the probe and initialize directly, or use versionNegotiation: { mode: 'auto' } to re-probe with legacy fallback.");if(await super.connect(e),this._discoverResult=r,this._serverCapabilities=r.capabilities,this._serverVersion=ef(r),this._cache.setServerIdentity(this._deriveServerIdentity(e)),this._instructions=r.instructions,this._negotiatedProtocolVersion=s,e.setProtocolVersion?.(s),this._listChangedConfig)try{this._setupListChangedHandlers(this._listChangedConfig)}catch(i){this.onerror?.(i instanceof Error?i:Error(String(i)))}}getServerCapabilities(){return this._serverCapabilities}getServerVersion(){return this._serverVersion}_deriveServerIdentity(e){let t=this._serverVersion;if(t!==void 0)return`${t.name}@${t.version}`;return e.sessionId??`anonymous:${Date.now()}-${Math.random().toString(36).slice(2)}`}getNegotiatedProtocolVersion(){return this._negotiatedProtocolVersion}getProtocolEra(){let e=this._negotiatedProtocolVersion;if(e===void 0)return;return xt(e)?"modern":"legacy"}getInstructions(){return this._instructions}getDiscoverResult(){return this._discoverResult}assertCapabilityForMethod(e){switch(e){case"logging/setLevel":if(!this._serverCapabilities?.logging)throw new C(A.CapabilityNotSupported,`Server does not support logging (required for ${e})`);break;case"prompts/get":case"prompts/list":if(!this._serverCapabilities?.prompts)throw new C(A.CapabilityNotSupported,`Server does not support prompts (required for ${e})`);break;case"resources/list":case"resources/templates/list":case"resources/read":case"resources/subscribe":case"resources/unsubscribe":if(!this._serverCapabilities?.resources)throw new C(A.CapabilityNotSupported,`Server does not support resources (required for ${e})`);if(e==="resources/subscribe"&&!this._serverCapabilities.resources.subscribe)throw new C(A.CapabilityNotSupported,`Server does not support resource subscriptions (required for ${e})`);break;case"tools/call":case"tools/list":if(!this._serverCapabilities?.tools)throw new C(A.CapabilityNotSupported,`Server does not support tools (required for ${e})`);break;case"completion/complete":if(!this._serverCapabilities?.completions)throw new C(A.CapabilityNotSupported,`Server does not support completions (required for ${e})`);break;case"initialize":break;case"server/discover":break;case"ping":break}}assertNotificationCapability(e){switch(e){case"notifications/roots/list_changed":if(!this._capabilities.roots?.listChanged)throw new C(A.CapabilityNotSupported,`Client does not support roots list changed notifications (required for ${e})`);break;case"notifications/initialized":break;case"notifications/cancelled":break;case"notifications/progress":break}}assertRequestHandlerCapability(e){switch(e){case"sampling/createMessage":if(!this._capabilities.sampling)throw new C(A.CapabilityNotSupported,`Client does not support sampling capability (required for ${e})`);break;case"elicitation/create":if(!this._capabilities.elicitation)throw new C(A.CapabilityNotSupported,`Client does not support elicitation capability (required for ${e})`);break;case"roots/list":if(!this._capabilities.roots)throw new C(A.CapabilityNotSupported,`Client does not support roots capability (required for ${e})`);break;case"ping":break}}async ping(e){return this.request({method:"ping"},e)}async discover(e){let t=await this._requestWithSchema({method:"server/discover"},Zt,e);return this._discoverResult=t,t}async complete(e,t){return this.request({method:"completion/complete",params:e},t)}async setLoggingLevel(e,t){return this.request({method:"logging/setLevel",params:{level:e}},t)}async getPrompt(e,t){return this.request({method:"prompts/get",params:e},t)}async listPrompts(e,t){if(!this._serverCapabilities?.prompts&&!this._enforceStrictCapabilities)return console.debug("Client.listPrompts() called but server does not advertise prompts capability - returning empty list"),{prompts:[]};if(e?.cursor!==void 0)return this.request({method:"prompts/list",params:e},t);let o=await this._serveFromCache("prompts/list",void 0,t);if(o!==void 0)return o;return this._listAllPages("prompts/list",e,t,(r)=>r.prompts)}async listResources(e,t){if(!this._serverCapabilities?.resources&&!this._enforceStrictCapabilities)return console.debug("Client.listResources() called but server does not advertise resources capability - returning empty list"),{resources:[]};if(e?.cursor!==void 0)return this.request({method:"resources/list",params:e},t);let o=await this._serveFromCache("resources/list",void 0,t);if(o!==void 0)return o;return this._listAllPages("resources/list",e,t,(r)=>r.resources)}async listResourceTemplates(e,t){if(!this._serverCapabilities?.resources&&!this._enforceStrictCapabilities)return console.debug("Client.listResourceTemplates() called but server does not advertise resources capability - returning empty list"),{resourceTemplates:[]};if(e?.cursor!==void 0)return this.request({method:"resources/templates/list",params:e},t);let o=await this._serveFromCache("resources/templates/list",void 0,t);if(o!==void 0)return o;return this._listAllPages("resources/templates/list",e,t,(r)=>r.resourceTemplates)}async _listAllPages(e,t,o,r,n){let s=o?.cacheMode==="bypass",i=this._cache.captureGeneration(e),c=(u)=>{let h=u===void 0?t&&{...t}:{...t,cursor:u};return this.request({method:e,...h&&{params:h}},o)},l=await this._walkPages(e,c,r);if(delete l.nextCursor,n?.(l),s)return l;return await this._cache.write(e,l,i,this._freshness(l)),l}async _walkPages(e,t,o){let r=await t(void 0),n=r.nextCursor,s=r,i=1;while(n!==void 0){if(this._listMaxPages!==0&&i>=this._listMaxPages)throw new C(A.ListPaginationExceeded,`${e}: exceeded listMaxPages (${this._listMaxPages}); server pagination did not terminate`,{method:e,listMaxPages:this._listMaxPages});let c=await t(n);if(c.nextCursor===n&&JSON.stringify(o(c))===JSON.stringify(o(s)))break;o(r).push(...o(c)),s=c,n=c.nextCursor,i++}return r}_freshness(e,t){let o=e,r=typeof o.ttlMs==="number"?o.ttlMs:this._defaultCacheTtlMs,n=o.cacheScope==="public"?"public":"private";return{expiresAt:this._cache.now()+Math.min(Math.max(0,r),nf),scope:n,params:t}}async _serveFromCache(e,t,o){if(o?.cacheMode==="bypass"||o?.cacheMode==="refresh")return;let r=await this._cache.read(e,t).catch((n)=>void this._reportStoreError(n));if(r!==void 0){if(o?.signal?.aborted){let n=o.signal.reason;throw n instanceof C?n:new C(A.RequestTimeout,String(n))}return r.value}}_reportStoreError(e){this.onerror?.(e instanceof Error?e:Error(String(e)))}_compileOutputValidator(e){if(!e.outputSchema)return;try{return{ok:!0,validator:this._jsonSchemaValidator.getValidator(e.outputSchema)}}catch(t){return{ok:!1,compileError:t}}}async _resolveXMcpHeaderScan(e,t){let o=t??await this._cache.toolDefinition(e);return o===void 0?void 0:bl(o.inputSchema)}async readResource(e,t){let{result:o}=await this._readResource(e,t);return o}async _readResource(e,t){let o=await this._serveFromCache("resources/read",e.uri,t);if(o!==void 0)return{result:o,cached:!0};let r=this._cache.captureGeneration("resources/read",e.uri),n=await this.request({method:"resources/read",params:e},t);if(t?.cacheMode!=="bypass"){let s=this._freshness(n,e.uri);if(s.expiresAt>this._cache.now())await this._cache.write("resources/read",n,r,s);else if(t?.cacheMode==="refresh")await this._cache.evictKey("resources/read",e.uri)}return{result:n,cached:!1}}async subscribeResource(e,t){return this.request({method:"resources/subscribe",params:e},t)}async unsubscribeResource(e,t){return this.request({method:"resources/unsubscribe",params:e},t)}async listen(e,t){if(this.transport===void 0)throw new C(A.NotConnected,"Not connected");let o=this._negotiatedProtocolVersion;if(o===void 0||!xt(o))throw new C(A.MethodNotSupportedByProtocolVersion,`subscriptions/listen requires a 2026-07-28-era connection (negotiated: ${o??"none"}). On a 2025-era connection, change notifications are delivered unsolicited: use ClientOptions.listChanged and resources/subscribe instead.`,{method:"subscriptions/listen",protocolVersion:o});if(t?.signal?.aborted){let P=t.signal.reason;throw P instanceof C?P:new C(A.RequestTimeout,String(P))}let r=new AbortController,n=`listen:${this._nextListenId++}`,s="opening",i,c,l,u,h=new Promise((P,H)=>{l=P,u=H}),m,S=new Promise((P)=>{m=P}),g=(P)=>{if(s==="closed")return;let H=s==="opening";if(i!==void 0)clearTimeout(i),i=void 0;if("ack"in P){s="open",l(P.ack);return}if(s="closed",c!==void 0)t?.signal?.removeEventListener("abort",c);if(this._listenState.delete(n),r.abort(),m(P.cause),H)u(P.error??new C(A.ConnectionClosed,"subscriptions/listen closed before the server acknowledged"))},b=async()=>{r.abort(),await this.notification({method:"notifications/cancelled",params:{requestId:n}}).catch(()=>{})},v=async()=>{if(s==="closed")return;g({cause:"local"}),await b()};this._listenState.set(n,{settle:g});let R=t?.timeout??ui;if(i=setTimeout(()=>{g({cause:"remote",error:new C(A.RequestTimeout,"subscriptions/listen ack timed out",{timeout:R})}),b().catch(()=>{})},R),t?.signal){let P=t.signal;c=()=>{if(s==="closed")return;let H=P.reason;g({cause:"local",error:H instanceof Error?H:Error(String(H??"Aborted"))}),b().catch(()=>{})},P.addEventListener("abort",c,{once:!0})}let q={jsonrpc:"2.0",id:n,method:"subscriptions/listen",params:{_meta:{...this._outboundMetaEnvelope()},notifications:e}},V=(P)=>{g({cause:"remote",error:P instanceof Error?P:Error(String(P))})};try{this.transport.send(q,{requestSignal:r.signal,onRequestStreamEnd:()=>g({cause:"remote",error:Error("subscriptions/listen: stream ended")})}).catch(V)}catch(P){V(P)}return{honoredFilter:await h,close:v,closed:S}}get autoOpenedSubscription(){return this._autoOpenedSubscription}_onnotification(e,t){let o=Object.hasOwn(tf,e.method)?tf[e.method]:void 0;if(e.method==="notifications/resources/updated"){let r=e.params?.uri;if(typeof r==="string")this._cache.evictKey("resources/read",r)}else if(o!==void 0)for(let r of o)this._cache.evict(r);if(e.method==="notifications/subscriptions/acknowledged"){let r=e.params?._meta?.[Go],n=typeof r==="string"?this._listenState.get(r):void 0;if(n!==void 0){let s=this._wireCodec().validateNotification("notifications/subscriptions/acknowledged",e);n.settle({ack:s.ok?s.value.params.notifications:{}});return}}if(e.method==="notifications/cancelled"){let r=e.params?.requestId,n=typeof r==="string"?this._listenState.get(r):void 0;if(n!==void 0){n.settle({cause:"remote",error:Error("subscriptions/listen: server cancelled the subscription")});return}}super._onnotification(e,t)}_onresponse(e){let t=e.id,o=typeof t==="string"?this._listenState.get(t):void 0;if(o!==void 0){if(li(e))o.settle({cause:"remote",error:K.fromError(e.error.code,e.error.message,e.error.data)});else o.settle({cause:"graceful",error:new C(A.ConnectionClosed,"subscriptions/listen: server closed the subscription gracefully before acknowledging")});return}super._onresponse(e)}_onclose(){if(this._listenState.size>0){let e=new C(A.ConnectionClosed,"Connection closed");for(let t of this._listenState.values())t.settle({cause:"remote",error:e});this._listenState.clear()}super._onclose()}async callTool(e,t){let o=this.getProtocolEra()==="modern"&&Km()!=="browser",r=async()=>{if(!o)return t;let l;try{l=await this._resolveXMcpHeaderScan(e.name,t?.toolDefinition)}catch(h){this._reportStoreError(h)}if(!l?.valid||l.declarations.length===0)return t;let u=Lm(l.declarations,e.arguments);return Object.keys(u).length===0?t:{...t,headers:{...t?.headers,...u}}},n=t?.toolDefinition===void 0?await this._cache.outputValidator(e.name,(l)=>this._compileOutputValidator(l)).catch((l)=>void this._reportStoreError(l)):this._compileOutputValidator(t.toolDefinition),s=()=>{if(n===void 0||n.ok)return;let l=n.compileError,u=(l instanceof Error?l.message:String(l)).slice(0,200);throw new K(Z.InvalidParams,`Tool '${e.name}' has an invalid outputSchema: ${u}`)};s();let i;try{i=await this.request({method:"tools/call",params:e},await r())}catch(l){let u=l instanceof K&&l.code===zr;if(!o||!u||t?.toolDefinition!==void 0)throw l;let h={signal:t?.signal,timeout:t?.timeout,cacheMode:"refresh"};await this._cache.evict("tools/list"),await this.listTools(void 0,h).catch((m)=>this._reportStoreError(m)),n=await this._cache.outputValidator(e.name,(m)=>this._compileOutputValidator(m)).catch((m)=>void this._reportStoreError(m)),s(),i=await this.request({method:"tools/call",params:e},await r())}let c=n!==void 0&&n.ok?n.validator:void 0;if(c){if(i.structuredContent===void 0&&!i.isError)throw new K(Z.InvalidRequest,`Tool ${e.name} has an output schema but did not return structured content`);if(i.structuredContent!==void 0&&!i.isError)try{let l=c(i.structuredContent);if(!l.valid)throw new K(Z.InvalidParams,`Structured content does not match the tool's output schema: ${l.errorMessage}`)}catch(l){if(l instanceof K)throw l;throw new K(Z.InvalidParams,`Failed to validate structured content: ${l instanceof Error?l.message:String(l)}`)}}return i}async listTools(e,t){if(!this._serverCapabilities?.tools&&!this._enforceStrictCapabilities)return console.debug("Client.listTools() called but server does not advertise tools capability - returning empty list"),{tools:[]};if(e?.cursor!==void 0){let r=await this.request({method:"tools/list",params:e},t);return this._excludeInvalidXMcpHeaderTools(r),r}let o=await this._serveFromCache("tools/list",void 0,t);if(o!==void 0)return o;return this._listAllPages("tools/list",e,t,(r)=>r.tools,(r)=>this._excludeInvalidXMcpHeaderTools(r))}_excludeInvalidXMcpHeaderTools(e){if(this.getProtocolEra()!=="modern"||!this.transport||Ym(this.transport)==="stdio")return;let t=e.tools.filter((o)=>{let r=bl(o.inputSchema);if(!r.valid)return console.warn(`[mcp-sdk] excluding tool '${o.name}' from tools/list: invalid x-mcp-header declaration — ${r.reason}`),!1;return!0});if(t.length!==e.tools.length)e.tools=t}_setupListChangedHandler(e,t,o,r){let n=ja(hs,o);if(!n.success)throw Error(`Invalid ${e} listChanged options: ${n.error.message}`);if(typeof o.onChanged!=="function")throw TypeError(`Invalid ${e} listChanged options: onChanged must be a function`);let{autoRefresh:s,debounceMs:i}=n.data,{onChanged:c}=o,l=async()=>{if(!s){c(null,null);return}try{c(null,await r())}catch(h){c(h instanceof Error?h:Error(String(h)),null)}},u=()=>{if(i){let h=this._listChangedDebounceTimers.get(e);if(h)clearTimeout(h);let m=setTimeout(l,i);this._listChangedDebounceTimers.set(e,m)}else l()};this.setNotificationHandler(t,u)}async sendRootsListChanged(){return this.notification({method:"notifications/roots/list_changed"})}};var ww=class extends Error{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.SseError"})}static[Symbol.hasInstance](e){return ke(this,e)}static isInstance(e){if(typeof this!=="function")throw TypeError("isInstance must be called on the class (e.g. `SdkError.isInstance(value)`); for callbacks use `v => SdkError.isInstance(v)`");return ke(this,e)}constructor(e,t,o){super(`SSE error: ${t}`);this.code=e,this.event=o,Ft(this,new.target)}};class ff{_eventSlots=new Map;setHandler(e,t){let o=this._ensureEventSlot(e);if(o.onHandler&&t)console.warn(`[MCP Apps] on${String(e)} handler replaced. Use addEventListener("${String(e)}", …) to add multiple listeners without replacing.`);o.onHandler=t}getHandler(e){return this._eventSlots.get(e)?.onHandler}addEventListener(e,t){this._ensureEventSlot(e).listeners.push(t)}removeEventListener(e,t){let o=this._eventSlots.get(e);if(!o)return;let r=o.listeners.indexOf(t);if(r!==-1)o.listeners.splice(r,1)}dispatch(e,t){let o=this._eventSlots.get(e);if(!o)return;o.onHandler?.(t);for(let r of[...o.listeners])r(t)}_ensureEventSlot(e){let t=this._eventSlots.get(e);if(!t)t={listeners:[]},this._eventSlots.set(e,t);return t}}class gf{_methods=new Set;claim(e,t){if(this._methods.has(e))throw Error(`Handler for "${e}" already registered (via ${t}). Use addEventListener() to attach multiple listeners, or the on* setter for replace semantics.`);this._methods.add(e)}replace(e){this._methods.add(e)}release(e){this._methods.delete(e)}has(e){return this._methods.has(e)}}var uf=new Set;function df(e,t){let[o,r]=t,n=o?.shape;if(typeof n?.method?.value!=="string")return;let s=n.method.value,i=e==="request"?"setRequestHandler":"setNotificationHandler";if(!uf.has(i))uf.add(i),console.warn(`[ext-apps] ${i}(Schema, handler) is deprecated; use ${i}("${s}", { params: Schema.shape.params }, handler).`);let c=r;return[s,{params:n.params},e==="request"?(l,u)=>c({method:s,params:l},Qy(u)):(l)=>c({method:s,params:l})]}function Qy(e){return{signal:e.mcpReq.signal,requestId:e.mcpReq.id,sessionId:e.sessionId,_meta:e.mcpReq._meta,sendRequest:e.mcpReq.send,sendNotification:e.mcpReq.notify,authInfo:e.http?.authInfo}}var Xy="2026-01-26";var eb="ui/notifications/tool-input-partial";class Sf{eventTarget;eventSource;messageListener;constructor(e=window.parent,t){this.eventTarget=e,this.eventSource=t,this.messageListener=(o)=>{if(t&&o.source!==this.eventSource){console.debug("Ignoring message from unknown source",o);return}let r=So.safeParse(o.data);if(r.success)console.debug("Parsed message",r.data),this.onmessage?.(r.data);else if(o.data?.jsonrpc!=="2.0")console.debug("Ignoring non-JSON-RPC message",r.error.message,o);else console.error("Failed to parse message",r.error.message,o),this.onerror?.(Error("Invalid JSON-RPC message received: "+r.error.message))}}async start(){window.addEventListener("message",this.messageListener)}async send(e,t){if(e.method!==eb)console.debug("Sending message",e);this.eventTarget.postMessage(e,"*")}async close(){window.removeEventListener("message",this.messageListener),this.onclose?.()}onclose;onerror;onmessage;sessionId;setProtocolVersion}var tb=x([p("light"),p("dark")]).describe("Color theme preference for the host environment."),hi=x([p("inline"),p("fullscreen"),p("pip")]).describe("Display mode for UI presentation."),ob=x([p("--color-background-primary"),p("--color-background-secondary"),p("--color-background-tertiary"),p("--color-background-inverse"),p("--color-background-ghost"),p("--color-background-info"),p("--color-background-danger"),p("--color-background-success"),p("--color-background-warning"),p("--color-background-disabled"),p("--color-text-primary"),p("--color-text-secondary"),p("--color-text-tertiary"),p("--color-text-inverse"),p("--color-text-ghost"),p("--color-text-info"),p("--color-text-danger"),p("--color-text-success"),p("--color-text-warning"),p("--color-text-disabled"),p("--color-border-primary"),p("--color-border-secondary"),p("--color-border-tertiary"),p("--color-border-inverse"),p("--color-border-ghost"),p("--color-border-info"),p("--color-border-danger"),p("--color-border-success"),p("--color-border-warning"),p("--color-border-disabled"),p("--color-ring-primary"),p("--color-ring-secondary"),p("--color-ring-inverse"),p("--color-ring-info"),p("--color-ring-danger"),p("--color-ring-success"),p("--color-ring-warning"),p("--font-sans"),p("--font-mono"),p("--font-weight-normal"),p("--font-weight-medium"),p("--font-weight-semibold"),p("--font-weight-bold"),p("--font-text-xs-size"),p("--font-text-sm-size"),p("--font-text-md-size"),p("--font-text-lg-size"),p("--font-heading-xs-size"),p("--font-heading-sm-size"),p("--font-heading-md-size"),p("--font-heading-lg-size"),p("--font-heading-xl-size"),p("--font-heading-2xl-size"),p("--font-heading-3xl-size"),p("--font-text-xs-line-height"),p("--font-text-sm-line-height"),p("--font-text-md-line-height"),p("--font-text-lg-line-height"),p("--font-heading-xs-line-height"),p("--font-heading-sm-line-height"),p("--font-heading-md-line-height"),p("--font-heading-lg-line-height"),p("--font-heading-xl-line-height"),p("--font-heading-2xl-line-height"),p("--font-heading-3xl-line-height"),p("--border-radius-xs"),p("--border-radius-sm"),p("--border-radius-md"),p("--border-radius-lg"),p("--border-radius-xl"),p("--border-radius-full"),p("--border-width-regular"),p("--shadow-hairline"),p("--shadow-sm"),p("--shadow-md"),p("--shadow-lg")]).describe("CSS variable keys available to MCP apps for theming."),rb=z(ob.describe(`Style variables for theming MCP apps.
|
|
69
72
|
|
|
70
73
|
Individual style keys are optional - hosts may provide any subset of these values.
|
|
71
74
|
Values are strings containing CSS values (colors, sizes, font stacks, etc.).
|
|
72
75
|
|
|
73
76
|
Note: This type uses \`Record<K, string | undefined>\` rather than \`Partial<Record<K, string>>\`
|
|
74
|
-
for compatibility with Zod schema generation. Both are functionally equivalent for validation.`),
|
|
77
|
+
for compatibility with Zod schema generation. Both are functionally equivalent for validation.`),x([a(),Xc()]).describe(`Style variables for theming MCP apps.
|
|
75
78
|
|
|
76
79
|
Individual style keys are optional - hosts may provide any subset of these values.
|
|
77
80
|
Values are strings containing CSS values (colors, sizes, font stacks, etc.).
|
|
@@ -83,10 +86,10 @@ Individual style keys are optional - hosts may provide any subset of these value
|
|
|
83
86
|
Values are strings containing CSS values (colors, sizes, font stacks, etc.).
|
|
84
87
|
|
|
85
88
|
Note: This type uses \`Record<K, string | undefined>\` rather than \`Partial<Record<K, string>>\`
|
|
86
|
-
for compatibility with Zod schema generation. Both are functionally equivalent for validation.`),
|
|
89
|
+
for compatibility with Zod schema generation. Both are functionally equivalent for validation.`),Aw=d({method:p("ui/open-link"),params:d({url:a().describe("URL to open in the host's browser")})}),nb=d({isError:w().optional().describe("True if the host failed to open the URL (e.g., due to security policy).")}).passthrough(),sb=d({isError:w().optional().describe("True if the download failed (e.g., user cancelled or host denied).")}).passthrough(),ib=d({isError:w().optional().describe("True if the host rejected or failed to deliver the message.")}).passthrough(),Mw=d({method:p("ui/notifications/sandbox-proxy-ready"),params:d({})}),kl=d({connectDomains:f(a()).optional().describe(`Origins for network requests (fetch/XHR/WebSocket).
|
|
87
90
|
|
|
88
91
|
- Maps to CSP \`connect-src\` directive
|
|
89
|
-
- Empty or omitted → no network connections (secure default)`),resourceDomains:
|
|
92
|
+
- Empty or omitted → no network connections (secure default)`),resourceDomains:f(a()).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:f(a()).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:f(a()).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'`)")}),$l=d({camera:d({}).optional().describe("Request camera access.\n\nMaps to Permission Policy `camera` feature."),microphone:d({}).optional().describe("Request microphone access.\n\nMaps to Permission Policy `microphone` feature."),geolocation:d({}).optional().describe("Request geolocation access.\n\nMaps to Permission Policy `geolocation` feature."),clipboardWrite:d({}).optional().describe("Request clipboard write access.\n\nMaps to Permission Policy `clipboard-write` feature.")}),qw=d({method:p("ui/notifications/size-changed"),params:d({width:y().optional().describe("New width in pixels."),height:y().optional().describe("New height in pixels.")})}),ab=d({method:p("ui/notifications/tool-input"),params:d({arguments:z(a(),O().describe("Complete tool call arguments as key-value pairs.")).optional().describe("Complete tool call arguments as key-value pairs.")})}),cb=d({method:p("ui/notifications/tool-input-partial"),params:d({arguments:z(a(),O().describe("Partial tool call arguments (incomplete, may change).")).optional().describe("Partial tool call arguments (incomplete, may change).")})}),lb=d({method:p("ui/notifications/tool-cancelled"),params:d({reason:a().optional().describe('Optional reason for the cancellation (e.g., "user action", "timeout").')})}),ub=d({fonts:a().optional()}),db=d({variables:rb.optional().describe("CSS variables for theming the app."),css:ub.optional().describe("CSS blocks that apps can inject.")}),pb=d({method:p("ui/resource-teardown"),params:d({})}),hb=z(a(),O()),pf=d({text:d({}).optional().describe("Host supports text content blocks."),image:d({}).optional().describe("Host supports image content blocks."),audio:d({}).optional().describe("Host supports audio content blocks."),resource:d({}).optional().describe("Host supports resource content blocks."),resourceLink:d({}).optional().describe("Host supports resource link content blocks."),structuredContent:d({}).optional().describe("Host supports structured content.")}),jw=d({method:p("ui/notifications/request-teardown"),params:d({}).optional()}),mb=d({experimental:z(a(),z(a(),ra()).describe("Experimental features keyed by identifier.")).optional().describe("Experimental features keyed by identifier."),openLinks:d({}).optional().describe("Host supports opening external URLs."),downloadFile:d({}).optional().describe("Host supports file downloads via ui/download-file."),serverTools:d({listChanged:w().optional().describe("Host supports tools/list_changed notifications.")}).optional().describe("Host can proxy tool calls to the MCP server."),serverResources:d({listChanged:w().optional().describe("Host supports resources/list_changed notifications.")}).optional().describe("Host can proxy resource reads to the MCP server."),logging:d({}).optional().describe("Host accepts log messages."),sandbox:d({permissions:$l.optional().describe("Permissions granted by the host (camera, microphone, geolocation)."),csp:kl.optional().describe("CSP domains approved by the host.")}).optional().describe("Sandbox configuration applied by the host."),updateModelContext:pf.optional().describe("Host accepts context updates (ui/update-model-context) to be included in the model's context for future turns."),message:pf.optional().describe("Host supports receiving content messages (ui/message) from the view."),sampling:d({tools:d({}).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.")}),fb=d({experimental:z(a(),z(a(),ra()).describe("Experimental features keyed by identifier.")).optional().describe("Experimental features keyed by identifier."),tools:d({listChanged:w().optional().describe("App supports tools/list_changed notifications.")}).optional().describe("App exposes MCP-style tools that the host can call."),availableDisplayModes:f(hi).optional().describe("Display modes the app supports.")}),Lw=d({method:p("ui/notifications/initialized"),params:d({}).optional()}),Uw=d({csp:kl.optional().describe("Content Security Policy configuration for UI resources."),permissions:$l.optional().describe("Sandbox permissions requested by the UI resource."),domain:a().optional().describe(`Dedicated origin for view sandbox.
|
|
90
93
|
|
|
91
94
|
Useful when views need stable, dedicated origins for OAuth callbacks, CORS policies, or API key allowlists.
|
|
92
95
|
|
|
@@ -94,25 +97,25 @@ Useful when views need stable, dedicated origins for OAuth callbacks, CORS polic
|
|
|
94
97
|
- Hash-based subdomains (e.g., \`{hash}.claudemcpcontent.com\`)
|
|
95
98
|
- URL-derived subdomains (e.g., \`www-example-com.oaiusercontent.com\`)
|
|
96
99
|
|
|
97
|
-
If omitted, host uses default sandbox origin (typically per-conversation).`),prefersBorder:
|
|
100
|
+
If omitted, host uses default sandbox origin (typically per-conversation).`),prefersBorder:w().optional().describe(`Visual boundary preference - true if view prefers a visible border.
|
|
98
101
|
|
|
99
102
|
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.
|
|
100
103
|
|
|
101
104
|
- \`true\`: request visible border + background
|
|
102
105
|
- \`false\`: request no visible border + background
|
|
103
|
-
- omitted: host decides border`)}),
|
|
106
|
+
- omitted: host decides border`)}),Zw=d({method:p("ui/request-display-mode"),params:d({mode:hi.describe("The display mode being requested.")})}),gb=d({mode:hi.describe("The display mode that was actually set. May differ from requested if not supported.")}).passthrough(),Sb=x([p("model"),p("app")]).describe("Tool visibility scope - who can access the tool."),Dw=d({resourceUri:a().optional(),visibility:f(Sb).optional().describe(`Who can access this tool. Default: ["model", "app"]
|
|
104
107
|
- "model": Tool visible to and callable by the agent
|
|
105
|
-
- "app": Tool callable by the app from this server only`),csp:
|
|
106
|
-
container holding the app. Specify either width or maxWidth, and either height or maxHeight.`),locale:s().optional().describe("User's language and region preference in BCP 47 format."),timeZone:s().optional().describe("User's timezone in IANA format."),userAgent:s().optional().describe("Host application identifier."),platform:v([u("web"),u("desktop"),u("mobile")]).optional().describe("Platform type for responsive design decisions."),deviceCapabilities:l({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:l({top:_().describe("Top safe area inset in pixels."),right:_().describe("Right safe area inset in pixels."),bottom:_().describe("Bottom safe area inset in pixels."),left:_().describe("Left safe area inset in pixels.")}).optional().describe("Mobile safe area boundaries in pixels.")}).passthrough(),b_=l({method:u("ui/notifications/host-context-changed"),params:wm.describe("Partial context update containing only changed fields.")}),Cz=l({method:u("ui/update-model-context"),params:l({content:h(Ie).optional().describe("Context content blocks (text, image, etc.)."),structuredContent:b(s(),P().describe("Structured content for machine-readable context data.")).optional().describe("Structured content for machine-readable context data.")})}),Iz=l({method:u("ui/initialize"),params:l({appInfo:$e.describe("App identification (name and version)."),appCapabilities:g_.describe("Features and capabilities this app provides."),protocolVersion:s().describe("Protocol version this app supports.")})}),v_=l({protocolVersion:s().describe('Negotiated protocol version string (e.g., "2025-11-21").'),hostInfo:$e.describe("Host application identification and version."),hostCapabilities:f_.describe("Features and capabilities provided by the host."),hostContext:wm.describe("Rich context about the host environment.")}).passthrough(),z_={target:"draft-2020-12"};async function _m(e,t){let o=e["~standard"];if(o.jsonSchema)return o.jsonSchema[t](z_);throw Error(`Schema (vendor: ${o.vendor}) does not implement Standard JSON Schema (~standard.jsonSchema). Use a library that does (zod v4, ArkType, Valibot) or wrap your schema accordingly.`)}async function ym(e,t,o=""){let r=await e["~standard"].validate(t);if(r.issues){let n=r.issues.map((i)=>{let a=i.path?.map((c)=>typeof c==="object"?c.key:c).join(".");return a?`${a}: ${i.message}`:i.message}).join("; ");throw Error(o+n)}return r.value}function w_(e,t){let o={...e,...t};if(t.experimental!==void 0)o.experimental={...e.experimental,...t.experimental};if(t.tools!==void 0)o.tools={...e.tools,...t.tools};return o}class va extends ol{_appInfo;_appCapabilities;options;_hostCapabilities;_hostInfo;_hostContext;_registeredTools={};_initializedSent=!1;_registeredEvents=new Set;_events=new bm;_methods=new vm;setRequestHandler=(...e)=>{let[t,...o]=gm("request",e)??e;this._methods.claim(t,"setRequestHandler"),super.setRequestHandler.call(this,t,...o)};setNotificationHandler=(...e)=>{let[t,...o]=gm("notification",e)??e;this._methods.claim(t,"setNotificationHandler"),super.setNotificationHandler.call(this,t,...o)};removeRequestHandler=(e)=>{this._methods.release(e),super.removeRequestHandler(e)};removeNotificationHandler=(e)=>{this._methods.release(e),super.removeNotificationHandler(e)};replaceRequestHandler=(e,...t)=>{this._methods.replace(e),super.setRequestHandler.call(this,e,...t)};_assertInitialized(e){if(this._initializedSent)return;let t=`[ext-apps] App.${e}() called before connect() completed the ui/initialize handshake. Await app.connect() before calling this method, or move data loading to an ontoolresult handler.`;if(this.options?.strict)throw Error(t);console.warn(`${t}. This will throw in a future release.`)}eventSchemas={toolinput:c_,toolinputpartial:l_,toolresult:y_,toolcancelled:u_,hostcontextchanged:b_};static ONE_SHOT_EVENTS=new Set(["toolinput","toolinputpartial","toolresult","toolcancelled"]);_everHadListener=new Set;_assertHandlerTiming(e){if(!va.ONE_SHOT_EVENTS.has(e)||this._everHadListener.has(e))return;if(this._everHadListener.add(e),!this._initializedSent)return;let t=`[ext-apps] "${String(e)}" handler registered after connect() completed the ui/initialize handshake. The host may have already sent this notification. Register handlers before calling app.connect().`;if(this.options?.strict)throw Error(t);console.warn(t)}setEventHandler(e,t){if(t)this._assertHandlerTiming(e);this._ensureEventSlot(e),this._events.setHandler(e,t)}addEventListener(e,t){this._assertHandlerTiming(e),this._ensureEventSlot(e),this._events.addEventListener(e,t)}removeEventListener(e,t){this._events.removeEventListener(e,t)}_ensureEventSlot(e){if(this._registeredEvents.has(e))return;let t=this.eventSchemas[e];if(!t)throw Error(`Unknown event: ${String(e)}`);this.setNotificationHandler(t.shape.method.value,{params:t.shape.params},(o)=>{let r=o;if(e==="hostcontextchanged")this._hostContext={...this._hostContext,...r};this._events.dispatch(e,r)}),this._registeredEvents.add(e)}getEventHandler(e){return this._events.getHandler(e)}warnIfRequestHandlerReplaced(e,t,o){if(t&&o)console.warn(`[MCP Apps] ${e} handler replaced. Previous handler will no longer be called.`)}constructor(e,t={},o={autoResize:!0}){super(o);if(this._appInfo=e,this._appCapabilities=t,this.options=o,this._methods.replace("notifications/cancelled"),this._methods.replace("notifications/progress"),!o.allowUnsafeEval)le({jitless:!0});this.replaceRequestHandler("ping",(r)=>(console.log("Received ping:",r.params),{})),this.setEventHandler("hostcontextchanged",void 0)}buildContext(e){return e}registerAppCapabilities(e){if(this.transport)throw Error("Cannot register capabilities after transport is established");this._appCapabilities=w_(this._appCapabilities,e)}registerTool(e,t,o){if(this._registeredTools[e])throw Error(`Tool ${e} is already registered`);let r=this,n=()=>{if(r._initializedSent&&r._appCapabilities.tools?.listChanged)r.sendToolListChanged()},i=t.inputSchema!==void 0,a={title:t.title,description:t.description,inputSchema:t.inputSchema,outputSchema:t.outputSchema,annotations:t.annotations,_meta:t._meta,enabled:!0,enable(){this.enabled=!0,n()},disable(){this.enabled=!1,n()},update(c){Object.assign(this,c),n()},remove(){if(r._registeredTools[e]!==a)return;delete r._registeredTools[e],n()},handler:async(c,d)=>{if(!a.enabled)throw Error(`Tool ${e} is disabled`);let p;if(i){let m=a.inputSchema,f=m?await ym(m,c??{},`Invalid input for tool ${e}: `):c??{};p=await o(f,d)}else p=await o(d);if(a.outputSchema&&!p.isError)p.structuredContent=await ym(a.outputSchema,p.structuredContent,`Invalid output for tool ${e}: `);return p}};if(this._registeredTools[e]=a,!this._appCapabilities.tools&&!this.transport)this.registerAppCapabilities({tools:{listChanged:!0}});return this.ensureToolHandlersInitialized(),n(),a}_toolHandlersInitialized=!1;ensureToolHandlersInitialized(){if(this._toolHandlersInitialized)return;this._toolHandlersInitialized=!0,this.oncalltool=async(e,t)=>{let o=this._registeredTools[e.name];if(!o)throw Error(`Tool ${e.name} not found`);return o.handler(e.arguments,t)},this.onlisttools=async(e,t)=>({tools:await Promise.all(Object.entries(this._registeredTools).filter(([o,r])=>r.enabled).map(async([o,r])=>{let n={name:o,title:r.title,description:r.description,inputSchema:r.inputSchema?await _m(r.inputSchema,"input"):{type:"object",properties:{}}};if(r.outputSchema)n.outputSchema=await _m(r.outputSchema,"output");if(r.annotations)n.annotations=r.annotations;if(r._meta)n._meta=r._meta;return n}))})}async sendToolListChanged(e={}){this._assertInitialized("sendToolListChanged"),await this.notification({method:"notifications/tools/list_changed",params:e})}getHostCapabilities(){return this._hostCapabilities}getHostVersion(){return this._hostInfo}getHostContext(){return this._hostContext}get ontoolinput(){return this.getEventHandler("toolinput")}set ontoolinput(e){this.setEventHandler("toolinput",e)}get ontoolinputpartial(){return this.getEventHandler("toolinputpartial")}set ontoolinputpartial(e){this.setEventHandler("toolinputpartial",e)}get ontoolresult(){return this.getEventHandler("toolresult")}set ontoolresult(e){this.setEventHandler("toolresult",e)}get ontoolcancelled(){return this.getEventHandler("toolcancelled")}set ontoolcancelled(e){this.setEventHandler("toolcancelled",e)}get onhostcontextchanged(){return this.getEventHandler("hostcontextchanged")}set onhostcontextchanged(e){this.setEventHandler("hostcontextchanged",e)}_onteardown;get onteardown(){return this._onteardown}set onteardown(e){this.warnIfRequestHandlerReplaced("onteardown",this._onteardown,e),this._onteardown=e,this.replaceRequestHandler("ui/resource-teardown",{params:h_.shape.params,result:m_},(t,o)=>{if(!this._onteardown)throw Error("No onteardown handler set");return this._onteardown(t,o)})}_oncalltool;get oncalltool(){return this._oncalltool}set oncalltool(e){this.warnIfRequestHandlerReplaced("oncalltool",this._oncalltool,e),this._oncalltool=e,this.replaceRequestHandler("tools/call",(t,o)=>{if(!this._oncalltool)throw Error("No oncalltool handler set");return this._oncalltool(t.params,o)})}_onlisttools;get onlisttools(){return this._onlisttools}set onlisttools(e){this.warnIfRequestHandlerReplaced("onlisttools",this._onlisttools,e),this._onlisttools=e,this.replaceRequestHandler("tools/list",(t,o)=>{if(!this._onlisttools)throw Error("No onlisttools handler set");return this._onlisttools(t.params,o)})}assertCapabilityForMethod(e){switch(e){case"sampling/createMessage":if(!this._hostCapabilities?.sampling)throw Error(`Host does not support sampling (required for ${e})`);break}}assertRequestHandlerCapability(e){switch(e){case"tools/call":case"tools/list":if(!this._appCapabilities.tools)throw Error(`Client does not support tool capability (required for ${e})`);return;default:return}}assertNotificationCapability(e){}async callServerTool(e,t){if(this._assertInitialized("callServerTool"),typeof e==="string")throw Error(`callServerTool() expects an object as its first argument, but received a string ("${e}"). Did you mean: callServerTool({ name: "${e}", arguments: { ... } })?`);return await this.request({method:"tools/call",params:e},{onprogress:()=>{},resetTimeoutOnProgress:!0,...t})}async readServerResource(e,t){return this._assertInitialized("readServerResource"),await this.request({method:"resources/read",params:e},t)}async listServerResources(e,t){return this._assertInitialized("listServerResources"),await this.request({method:"resources/list",params:e},t)}async createSamplingMessage(e,t){return this._assertInitialized("createSamplingMessage"),await this.request({method:"sampling/createMessage",params:e},t)}sendMessage(e,t){return this._assertInitialized("sendMessage"),this.request({method:"ui/message",params:e},a_,t)}sendLog(e){return this.notification({method:"notifications/message",params:e})}updateModelContext(e,t){return this._assertInitialized("updateModelContext"),this.request({method:"ui/update-model-context",params:e},it,t)}openLink(e,t){return this._assertInitialized("openLink"),this.request({method:"ui/open-link",params:e},s_,t)}sendOpenLink=this.openLink;downloadFile(e,t){return this._assertInitialized("downloadFile"),this.request({method:"ui/download-file",params:e},i_,t)}requestTeardown(e={}){return this.notification({method:"ui/notifications/request-teardown",params:e})}requestDisplayMode(e,t){return this._assertInitialized("requestDisplayMode"),this.request({method:"ui/request-display-mode",params:e},S_,t)}sendSizeChanged(e){return this.notification({method:"ui/notifications/size-changed",params:e})}setupSizeChangedNotifications(){let e=!1,t=0,o=0,r=()=>{if(e)return;e=!0,requestAnimationFrame(()=>{e=!1;let i=document.documentElement,a=i.style.height;i.style.height="max-content";let c=Math.ceil(i.getBoundingClientRect().height);i.style.height=a;let d=Math.ceil(window.innerWidth);if(d!==t||c!==o)t=d,o=c,this.sendSizeChanged({width:d,height:c})})};r();let n=new ResizeObserver(r);return n.observe(document.documentElement),n.observe(document.body),()=>n.disconnect()}async connect(e=new zm(window.parent,window.parent),t){if(this.transport)throw Error("App is already connected. Call close() before connecting again.");this._initializedSent=!1;try{await super.connect(e);let o=await this.request({method:"ui/initialize",params:{appCapabilities:this._appCapabilities,appInfo:this._appInfo,protocolVersion:e_}},v_,t);if(o===void 0)throw Error(`Server sent invalid initialize result: ${o}`);if(this._hostCapabilities=o.hostCapabilities,this._hostInfo=o.hostInfo,this._hostContext=o.hostContext,await this.notification({method:"ui/notifications/initialized"}),this._initializedSent=!0,this.options?.autoResize)this.setupSizeChangedNotifications()}catch(o){throw this.close(),o}}}function Rm(e,t){let o=[],r=new Set;function n(i){if(r.has(i))return;r.add(i);let a=e.get(i);if(!a)throw Error(`Missing preview dependency metadata: ${i}`);for(let c of[...a.imports,...a.styles,...a.references])n(c);o.push(i)}return n(t),o}function xm(e,t){if(!e||e.revision===t.revision)return[];let o=(r,n)=>{let i=new Map(Object.entries(r.assets));return JSON.stringify(Rm(i,n.module).map((a)=>[a,i.get(a)]))};return t.scenarios.filter((r)=>{let n=e.scenarios.find((i)=>i.id===r.id);return!n||o(e,n)!==o(t,r)}).map((r)=>r.id)}class sl{constructor(e){this.read=e,this.records=new Map,this.bytes=new Map,this.urls=new Map,this.styles=new Map,this.styleReady=new Map,this.revisions=new Set,this.loadedModules=new Set,this.importing=Promise.resolve(),this.generation=0,this.prefetchGeneration=0,this.closed=!1,globalThis.__dsPreviewImport=(t)=>this.importModule(t)}register(e){if(e.schemaVersion!==1||!Array.isArray(e.scenarios)||!e.assets||typeof e.revision!=="string")throw Error("Unsupported preview manifest. Rebuild previews with the installed ADS version.");for(let[t,o]of Object.entries(e.assets)){if(!/^ads:\/\/assets\/[a-f0-9]{64}\.[a-z0-9]+$/.test(t)||!/^sha256:[a-f0-9]{64}$/.test(o.digest)||!["imports","dynamicImports","styles","references"].every((r)=>Array.isArray(o[r])&&o[r].every((n)=>Object.hasOwn(e.assets,n))))throw Error("Invalid preview dependency graph.");if(this.records.has(t)&&this.records.get(t).digest!==o.digest)throw Object.assign(Error("An immutable preview resource changed its content. Rebuild previews with the current ADS version."),{code:"ADS_RESOURCE_IDENTITY",category:"build",resourceUri:t})}for(let[t,o]of Object.entries(e.assets))this.records.set(t,o)}async resource(e){if(!this.bytes.has(e)){let t=(async()=>{let o=this.records.get(e);if(!o)throw Error(`Unknown preview dependency: ${e}`);let r;try{r=await this.read(e)}catch(d){throw Object.assign(Error(`Preview resource read failed for ${e}: ${d.message}`,{cause:d}),{code:"ADS_RESOURCE_READ",category:"transport",resourceUri:e})}if(this.closed)throw Error("The preview App was closed.");let n=r.contents.find((d)=>d.uri===e);if(!n)throw Object.assign(Error(`Missing preview dependency: ${e}`),{code:"ADS_RESOURCE_CONTENT",category:"build",resourceUri:e});let i=typeof n.text==="string"?new TextEncoder().encode(n.text):Uint8Array.from(atob(n.blob),(d)=>d.charCodeAt(0)),a=await crypto.subtle.digest("SHA-256",i),c="sha256:"+[...new Uint8Array(a)].map((d)=>d.toString(16).padStart(2,"0")).join("");if(i.length!==o.size||c!==o.digest)throw Object.assign(Error("Preview resource integrity check failed. Rebuild and reopen the preview."),{code:"ADS_RESOURCE_INTEGRITY",category:"build",resourceUri:e});return i})();this.bytes.set(e,t),t.catch(()=>this.bytes.delete(e))}return this.bytes.get(e)}closure(e){return Rm(this.records,e)}async prefetch(e,t){if(this.closed)return;this.register(e);let o=++this.prefetchGeneration,r=new Set,n=[],i=0;for(let p of t){let m=e.scenarios.find((S)=>S.id===p);if(!m)continue;let f=this.closure(m.module).filter((S)=>!this.bytes.has(S)&&!r.has(S)),y=f.reduce((S,w)=>S+this.records.get(w).size,0);if(i+y>16777216||r.size+f.length>256)continue;i+=y,n.push(p);for(let S of f)r.add(S)}let a=[...r],c=0,d=async()=>{while(!this.closed&&o===this.prefetchGeneration&&c<a.length)await this.resource(a[c++])};return await Promise.all(Array.from({length:Math.min(3,a.length)},d)),{scenarios:n,resources:a.length}}async materialize(e){let t=this.closure(e);await Promise.all(t.map((r)=>this.resource(r)));let o={};for(let r of t){if(this.closed)throw Error("The preview App was closed.");if(this.urls.has(r))continue;let n=this.records.get(r),i=await this.resource(r);if(n.kind==="module"||n.mimeType==="text/css"||n.mimeType==="text/javascript"){let c=new TextDecoder().decode(i);for(let d of n.references){let p=this.urls.get(d);if(!p)throw Error("Unsupported cyclic asset reference.");c=c.replaceAll(d,p)}i=c}let a=URL.createObjectURL(new Blob([i],{type:n.mimeType}));if(this.urls.set(r,a),n.kind==="module")o[r]=a}if(Object.keys(o).length){let r=document.createElement("script");r.type="importmap",r.textContent=JSON.stringify({imports:o}),document.head.append(r)}return t}async importModule(e){let t=this.importing.then(()=>this.materialize(e));this.importing=t.catch(()=>{});let o=await t;await this.attachStyles(o);try{let r=await import(e);return this.loadedModules.add(e),r}catch(r){throw Error(`Preview module import failed for ${e}: ${r.message}. Inspect the App resource bridge, browser network/CSP diagnostics and current build.`,{cause:r})}}async attachStyles(e){for(let t of e){if(this.records.get(t).mimeType!=="text/css")continue;if(this.styles.has(t)){await this.styleReady.get(t);continue}let r=document.createElement("link");r.rel="stylesheet",r.href=this.urls.get(t),this.styles.set(t,r);let n=new Promise((i,a)=>{r.onload=i,r.onerror=()=>a(Error("The host CSP blocked a preview stylesheet."))});this.styleReady.set(t,n),document.head.append(r);try{await n}catch(i){throw r.remove(),this.styles.delete(t),this.styleReady.delete(t),i}}}async refreshStyles(e,t){let o=[e],r=new Set,n=new Set;for(let i=0;i<o.length;i++){let a=o[i];if(r.has(a))continue;r.add(a);for(let c of await this.materialize(a)){n.add(c);for(let d of this.records.get(c).dynamicImports)if(this.loadedModules.has(d))o.push(d)}}if(await this.attachStyles([...n]),t!==this.generation||this.closed)return!1;for(let[i,a]of this.styles)if(!n.has(i))a.remove(),this.styles.delete(i),this.styleReady.delete(i);for(let i of n)if(this.styles.has(i))document.head.append(this.styles.get(i));return!0}async mount(e,t,o){let r=++this.generation;this.register(e);let n=e.scenarios.find((d)=>d.id===t);if(!n)throw Error("The selected scenario is no longer registered.");let i=JSON.stringify(this.closure(n.module).map((d)=>[d,this.records.get(d)]));if(this.mounted?.id===t&&this.mounted.container===o&&this.mounted.signature===i)return this.refreshStyles(n.module,r);if(this.revisions.add(n.module),this.revisions.size>20)throw Object.assign(Error("Reopen the preview to release modules retained across 20 build revisions."),{code:"ADS_PREVIEW_REOPEN"});let a=await this.importModule(n.module);if(r!==this.generation)return!1;let c=this.unmount;if(this.unmount=void 0,this.mounted=void 0,await c?.(),r!==this.generation||this.closed)return!1;if(o.replaceChildren(),!await this.refreshStyles(n.module,r))return!1;if(typeof a.mount!=="function")throw Error("The compiled scenario has no mount adapter.");if(this.unmount=a.mount(o),typeof this.unmount!=="function")throw Error("The scenario mount adapter must return an unmount callback.");return this.mounted={id:t,container:o,signature:i},!0}async dispose(){if(this.closed)return;this.closed=!0,++this.generation,++this.prefetchGeneration,await this.unmount?.(),this.mounted=void 0;for(let e of this.styles.values())e.remove();for(let e of this.urls.values())URL.revokeObjectURL(e);this.styles.clear(),this.styleReady.clear(),this.urls.clear(),this.bytes.clear(),this.records.clear(),this.revisions.clear(),this.loadedModules.clear(),delete globalThis.__dsPreviewImport}}function Pm(e){return Array.isArray(e)&&e.length>0&&e.every((t)=>t&&typeof t==="object"&&typeof t.token==="string"&&/^--[\w-]+$/.test(t.token)&&typeof t.property==="string"&&/^-?[a-z][a-z0-9-]*$/.test(t.property)&&typeof t.probe==="string"&&t.probe.trim().length>0)&&new Set(e.map((t)=>`${t.token}:${t.property}`)).size===e.length}function Tm(e,t){let o=t.getComputedStyle(e),r=e.getBoundingClientRect();if(o.display==="none"||o.visibility!=="visible"||!e.getClientRects().length||!(r.width||r.height))return!1;for(let n=e;n;n=n.parentElement)if(Number(t.getComputedStyle(n).opacity)===0)return!1;return!0}function Em(e,t){if(!Pm(t))return{ok:!1,diagnostics:["Token preview needs explicit { token, property, probe } samples from the project fixture. Rebuild with the current compiler."]};let o=e.ownerDocument,{defaultView:r,documentElement:n}=o,i=[],a=[],c=[...e.querySelectorAll("[data-ads-token], [data-ads-property]")],d=new Set(t.map((p)=>`${p.token}:${p.property}`));for(let p of c)if(!d.has(`${p.dataset.adsToken}:${p.dataset.adsProperty}`))i.push(`Undeclared rendered token sample ${p.dataset.adsToken}:${p.dataset.adsProperty}.`);for(let p of t){if(!r.CSS.supports(p.property,p.probe)){i.push(`${p.token}: the fixture probe is invalid for ${p.property}.`);continue}let m=r.getComputedStyle(n).getPropertyValue(p.token).trim();if(!m||!r.CSS.supports(p.property,m)){i.push(`${p.token}: its current value is invalid for the fixture's ${p.property} binding.`);continue}let f=c.filter((S)=>S.dataset.adsToken===p.token&&S.dataset.adsProperty===p.property);if(!f.length){i.push(`${p.token} needs a rendered ${p.property} sample, not only a name/value label.`);continue}let y=!1;for(let S of f){let w=[];for(let C=S.parentElement;C&&C!==e;C=C.parentElement)if(C.tagName==="DETAILS"&&!C.open)C.open=!0,w.push(C);let x=n.getAttribute("style"),R=S.getAttribute("style");try{if(!/^(?:-[a-z]+-)?transition(?:-|$)/.test(p.property))S.style.setProperty("transition","none","important");let C=r.getComputedStyle(S).getPropertyValue(p.property),N=Tm(S,r);n.style.setProperty(p.token,p.probe,"important");let I=r.getComputedStyle(S).getPropertyValue(p.property);y=Boolean(I&&I!==C&&(N||Tm(S,r)))}finally{if(x===null)n.removeAttribute("style");else n.setAttribute("style",x);if(R===null)S.removeAttribute("style");else S.setAttribute("style",R);for(let C of w)C.open=!1}if(y)break}if(y)a.push(p);else i.push(`${p.token} has no visible ${p.property} sample that responds to its value. Hardcoded copies do not satisfy coverage.`)}return{ok:!i.length,verified:a,diagnostics:i}}function km({container:e=document.getElementById("root"),bindings:t=[],auditResources:o=!1}={}){let r=[],n=[],i=[];if(!e||!Array.isArray(t)||t.length>100)return{ok:!1,diagnostics:["Invalid bounded paint-audit descriptor."],verified:n};let a=e.ownerDocument,c=a.defaultView,d=["color","fill","stroke","stop-color","background-color","border-top-color","border-right-color","border-bottom-color","border-left-color"];function p(f,y,S,w=new Set){if(f=f.trim(),["none","currentColor"].includes(f))return!0;let x=/^var\(\s*(--[\w-]+)\s*\)$/.exec(f);if(x){let N=x[1];if(!S.tokens.includes(N)||w.has(N))return!1;let I=c.getComputedStyle(y).getPropertyValue(N).trim();return!!I&&c.CSS.supports("color",I)}let R=Array.isArray(S.themes)?S.themes:[];if(R.length&&f.startsWith("var(--ads-if-")){let N=/^var\(\s*--ads-if-([a-z][a-z0-9-]*)\s*,\s*(var\(\s*--[\w-]+\s*\)|currentColor|none)\s*\)/,I=f,M=[];while(I){let A=N.exec(I);if(!A)return!1;M.push(A),I=I.slice(A[0].length).trimStart()}return M.length===R.length&&M.every((A,j)=>A[1]===R[j]&&p(A[2],y,S,w))}let C=/^url\(\s*(["']?)#([^\s"'()#\\\p{Cc}]+)\1\s*\)$/u.exec(f);if(C&&c.CSS.supports("fill",f)){let N=[...a.querySelectorAll("[id]")].filter((I)=>I.id===C[2]);return N.length===1&&["linearGradient","radialGradient","pattern"].includes(N[0].localName)&&y.contains(N[0])}return!1}for(let f of t){if(!f||typeof f.scope!=="string"||!Array.isArray(f.tokens)||typeof f.prefix!=="string"||typeof f.suffix!=="string"){r.push("Invalid paint binding metadata; rebuild previews.");continue}let y;try{y=[...e.querySelectorAll(f.scope)]}catch{r.push(`${f.owner}: invalid binding scope.`);continue}if(y.length>20)i.push(`${f.owner}: only the first 20 instances were audited; use a focused scenario for complete evidence.`);for(let S of y.slice(0,20)){let w=[S,...S.querySelectorAll("*")];if(w.length>1000){i.push(`${f.owner}: instance exceeds 1000 elements; paint effects are not established.`);continue}let x=[...S.style].filter((R)=>R.startsWith(f.prefix)&&R.endsWith(f.suffix));if(x.length>100)i.push(`${f.owner}: only the first 100 binding keys were audited.`);for(let R of x.slice(0,100)){let C=S.style.getPropertyValue(R).trim(),N=R.slice(f.prefix.length,f.suffix?-f.suffix.length:void 0);if(!/^[A-Za-z0-9_-]+$/.test(N)||!p(C,S,f)){r.push(`${f.owner}: invalid or inaccessible paint ${R}: ${C}. Use an accessible token, instance-local SVG paint server, none or currentColor.`);continue}let I=S.getAttribute("style"),M=w.map((A)=>A.getAttribute("style"));try{for(let V of w)V.style.setProperty("transition","none","important");let A=w.map((V)=>d.map((ae)=>c.getComputedStyle(V).getPropertyValue(ae)));S.style.setProperty(R,"rgb(17, 103, 211)","important");let j=w.some((V,ae)=>d.some((Y,ge)=>c.getComputedStyle(V).getPropertyValue(Y)!==A[ae][ge]));if(!j)S.style.setProperty(R,"rgb(211, 67, 23)","important"),j=w.some((V,ae)=>d.some((Y,ge)=>c.getComputedStyle(V).getPropertyValue(Y)!==A[ae][ge]));if(!j)i.push(`${f.owner}: ${R} has no observed paint effect in its current instance. A written variable alone is not rendering evidence; check the relevant selected/visible consumer.`);else n.push({owner:f.owner,binding:f.name,variable:R})}finally{if(w.forEach((A,j)=>{if(M[j]===null)A.removeAttribute("style");else A.setAttribute("style",M[j])}),I===null)S.removeAttribute("style");else S.setAttribute("style",I)}}for(let R of w)for(let C of["fill","stroke","stop-color"]){let N=R.getAttribute(C);if(!N)continue;let I=/^var\(\s*(--[\w-]+)\s*\)$/.exec(N);if(I&&I[1].startsWith(f.prefix)&&I[1].endsWith(f.suffix)&&!x.includes(I[1]))r.push(`${f.owner}: ${I[1]} is consumed without a value in this instance.`);if(N.startsWith("url(")&&!p(N,S,f))r.push(`${f.owner}: missing, duplicated or out-of-instance local paint resource ${N}.`)}}}let m=o?[...e.querySelectorAll("[fill], [stroke], [style]")]:[];if(m.length>1000)i.push("Only the first 1000 potential SVG paint consumers were audited.");for(let f of m.slice(0,1000))for(let y of["fill","stroke"]){let S=f.getAttribute(y)??f.style.getPropertyValue(y);if(!S?.startsWith("url("))continue;let w=/^url\(\s*(["']?)#([^\s"'()#\\\p{Cc}]+)\1\s*\)$/u.exec(S)?.[2],x=w?[...a.querySelectorAll("[id]")].filter((C)=>C.id===w):[],R=f.ownerSVGElement??(f.localName==="svg"?f:null);if(x.length!==1||!R?.contains(x[0])||!["linearGradient","radialGradient","pattern"].includes(x[0]?.localName))r.push(`Invalid, missing, duplicated or nonlocal SVG paint resource ${S}. Keep IDs isolated per rendered instance.`)}return{ok:!r.length,complete:!i.length,verified:n,diagnostics:r.slice(0,40),limits:i.slice(0,20),scope:"observed App instances and current input; repeat after updates"}}var ye=new va({name:"ADS resource preview",version:"1.0.0"},{},{autoResize:!0}),Gt=document.getElementById("root"),il=document.getElementById("ads-preview-status"),ll,pl=async(e)=>{if(!ye.getHostCapabilities()?.serverResources)throw Error("This host does not forward MCP resource reads. Open the same preview in the ADS showcase.");try{return await ye.readServerResource({uri:ll?ll+encodeURIComponent(e):e},{timeout:15000})}catch(t){if(t.code===-32601||t.message==="Method not found")throw Error("This host does not forward MCP resource reads. Open the same preview in the ADS showcase.");throw t}},ei=new sl(pl),Fe,Cm,Wt,ul,hl,al=!1,ut=0,xe={},Im=[],_e="",Qs=!1,cl,$m,Om=new Set;function Nm(e){if(ye.getHostVersion()?.name!=="ADS showcase")return;let t=$m;if($m=e,!t)return;let o=xm(t,e).filter((r)=>r!==Fe&&Om.has(r));if(!o.length)return;ei.prefetch(e,o).then((r)=>dt("prefetched",{revision:e.revision,...r})).catch((r)=>console.warn("ADS preview prefetch",r.message))}function Ne(e,t=!1){il.textContent=e,il.hidden=!e||ye.getHostVersion()?.name==="ADS showcase",il.setAttribute("role",t?"alert":"status")}async function dt(e,t={}){try{if(ye.getHostCapabilities()?.logging)await ye.sendLog({level:e==="error"?"error":"info",logger:"ads-preview",data:{state:e,id:Fe,...t}})}catch{}}var R_=`#ads-grid-overlay{position:fixed;inset:0;z-index:2147483647;pointer-events:none;display:grid;
|
|
108
|
+
- "app": Tool callable by the app from this server only`),csp:el().optional(),permissions:el().optional()}),Vw=d({mimeTypes:f(a()).optional().describe('Array of supported MIME types for UI resources.\nMust include `"text/html;profile=mcp-app"` for MCP Apps support.')}),Hw=d({method:p("ui/download-file"),params:d({contents:f(x([zo,Ro])).describe("Resource contents to download — embedded (inline data) or linked (host fetches). Uses standard MCP resource types.")})}),Fw=d({method:p("ui/message"),params:d({role:p("user").describe('Message role, currently only "user" is supported.'),content:f(dt).describe("Message content blocks (text, image, etc.).")})}),Jw=d({method:p("ui/notifications/sandbox-resource-ready"),params:d({html:a().describe("HTML content to load into the inner iframe."),sandbox:a().optional().describe("Optional override for the inner iframe's sandbox attribute."),csp:kl.optional().describe("CSP configuration from resource metadata."),permissions:$l.optional().describe("Sandbox permissions from resource metadata.")})}),_b=d({method:p("ui/notifications/tool-result"),params:Vt.describe("Standard MCP tool execution result.")}),_f=d({toolInfo:d({id:Ge.optional().describe("JSON-RPC id of the tools/call request."),tool:Dt.describe("Tool definition including name, inputSchema, etc.")}).optional().describe("Metadata of the tool call that instantiated this App."),theme:tb.optional().describe("Current color theme preference."),styles:db.optional().describe("Style configuration for theming the app."),displayMode:hi.optional().describe("How the UI is currently displayed."),availableDisplayModes:f(hi).optional().describe("Display modes the host supports."),containerDimensions:x([d({height:y().describe("Fixed container height in pixels.")}),d({maxHeight:x([y(),Xc()]).optional().describe("Maximum container height in pixels.")})]).and(x([d({width:y().describe("Fixed container width in pixels.")}),d({maxWidth:x([y(),Xc()]).optional().describe("Maximum container width in pixels.")})])).optional().describe(`Container dimensions. Represents the dimensions of the iframe or other
|
|
109
|
+
container holding the app. Specify either width or maxWidth, and either height or maxHeight.`),locale:a().optional().describe("User's language and region preference in BCP 47 format."),timeZone:a().optional().describe("User's timezone in IANA format."),userAgent:a().optional().describe("Host application identifier."),platform:x([p("web"),p("desktop"),p("mobile")]).optional().describe("Platform type for responsive design decisions."),deviceCapabilities:d({touch:w().optional().describe("Whether the device supports touch input."),hover:w().optional().describe("Whether the device supports hover interactions.")}).optional().describe("Device input capabilities."),safeAreaInsets:d({top:y().describe("Top safe area inset in pixels."),right:y().describe("Right safe area inset in pixels."),bottom:y().describe("Bottom safe area inset in pixels."),left:y().describe("Left safe area inset in pixels.")}).optional().describe("Mobile safe area boundaries in pixels.")}).passthrough(),yb=d({method:p("ui/notifications/host-context-changed"),params:_f.describe("Partial context update containing only changed fields.")}),Bw=d({method:p("ui/update-model-context"),params:d({content:f(dt).optional().describe("Context content blocks (text, image, etc.)."),structuredContent:z(a(),O().describe("Structured content for machine-readable context data.")).optional().describe("Structured content for machine-readable context data.")})}),Gw=d({method:p("ui/initialize"),params:d({appInfo:lt.describe("App identification (name and version)."),appCapabilities:fb.describe("Features and capabilities this app provides."),protocolVersion:a().describe("Protocol version this app supports.")})}),bb=d({protocolVersion:a().describe('Negotiated protocol version string (e.g., "2025-11-21").'),hostInfo:lt.describe("Host application identification and version."),hostCapabilities:mb.describe("Features and capabilities provided by the host."),hostContext:_f.describe("Rich context about the host environment.")}).passthrough(),vb={target:"draft-2020-12"};async function hf(e,t){let o=e["~standard"];if(o.jsonSchema)return o.jsonSchema[t](vb);throw Error(`Schema (vendor: ${o.vendor}) does not implement Standard JSON Schema (~standard.jsonSchema). Use a library that does (zod v4, ArkType, Valibot) or wrap your schema accordingly.`)}async function mf(e,t,o=""){let r=await e["~standard"].validate(t);if(r.issues){let n=r.issues.map((s)=>{let i=s.path?.map((c)=>typeof c==="object"?c.key:c).join(".");return i?`${i}: ${s.message}`:s.message}).join("; ");throw Error(o+n)}return r.value}function zb(e,t){let o={...e,...t};if(t.experimental!==void 0)o.experimental={...e.experimental,...t.experimental};if(t.tools!==void 0)o.tools={...e.tools,...t.tools};return o}class Da extends di{_appInfo;_appCapabilities;options;_hostCapabilities;_hostInfo;_hostContext;_registeredTools={};_initializedSent=!1;_registeredEvents=new Set;_events=new ff;_methods=new gf;setRequestHandler=(...e)=>{let[t,...o]=df("request",e)??e;this._methods.claim(t,"setRequestHandler"),super.setRequestHandler.call(this,t,...o)};setNotificationHandler=(...e)=>{let[t,...o]=df("notification",e)??e;this._methods.claim(t,"setNotificationHandler"),super.setNotificationHandler.call(this,t,...o)};removeRequestHandler=(e)=>{this._methods.release(e),super.removeRequestHandler(e)};removeNotificationHandler=(e)=>{this._methods.release(e),super.removeNotificationHandler(e)};replaceRequestHandler=(e,...t)=>{this._methods.replace(e),super.setRequestHandler.call(this,e,...t)};_assertInitialized(e){if(this._initializedSent)return;let t=`[ext-apps] App.${e}() called before connect() completed the ui/initialize handshake. Await app.connect() before calling this method, or move data loading to an ontoolresult handler.`;if(this.options?.strict)throw Error(t);console.warn(`${t}. This will throw in a future release.`)}eventSchemas={toolinput:ab,toolinputpartial:cb,toolresult:_b,toolcancelled:lb,hostcontextchanged:yb};static ONE_SHOT_EVENTS=new Set(["toolinput","toolinputpartial","toolresult","toolcancelled"]);_everHadListener=new Set;_assertHandlerTiming(e){if(!Da.ONE_SHOT_EVENTS.has(e)||this._everHadListener.has(e))return;if(this._everHadListener.add(e),!this._initializedSent)return;let t=`[ext-apps] "${String(e)}" handler registered after connect() completed the ui/initialize handshake. The host may have already sent this notification. Register handlers before calling app.connect().`;if(this.options?.strict)throw Error(t);console.warn(t)}setEventHandler(e,t){if(t)this._assertHandlerTiming(e);this._ensureEventSlot(e),this._events.setHandler(e,t)}addEventListener(e,t){this._assertHandlerTiming(e),this._ensureEventSlot(e),this._events.addEventListener(e,t)}removeEventListener(e,t){this._events.removeEventListener(e,t)}_ensureEventSlot(e){if(this._registeredEvents.has(e))return;let t=this.eventSchemas[e];if(!t)throw Error(`Unknown event: ${String(e)}`);this.setNotificationHandler(t.shape.method.value,{params:t.shape.params},(o)=>{let r=o;if(e==="hostcontextchanged")this._hostContext={...this._hostContext,...r};this._events.dispatch(e,r)}),this._registeredEvents.add(e)}getEventHandler(e){return this._events.getHandler(e)}warnIfRequestHandlerReplaced(e,t,o){if(t&&o)console.warn(`[MCP Apps] ${e} handler replaced. Previous handler will no longer be called.`)}constructor(e,t={},o={autoResize:!0}){super(o);if(this._appInfo=e,this._appCapabilities=t,this.options=o,this._methods.replace("notifications/cancelled"),this._methods.replace("notifications/progress"),!o.allowUnsafeEval)we({jitless:!0});this.replaceRequestHandler("ping",(r)=>(console.log("Received ping:",r.params),{})),this.setEventHandler("hostcontextchanged",void 0)}buildContext(e){return e}registerAppCapabilities(e){if(this.transport)throw Error("Cannot register capabilities after transport is established");this._appCapabilities=zb(this._appCapabilities,e)}registerTool(e,t,o){if(this._registeredTools[e])throw Error(`Tool ${e} is already registered`);let r=this,n=()=>{if(r._initializedSent&&r._appCapabilities.tools?.listChanged)r.sendToolListChanged()},s=t.inputSchema!==void 0,i={title:t.title,description:t.description,inputSchema:t.inputSchema,outputSchema:t.outputSchema,annotations:t.annotations,_meta:t._meta,enabled:!0,enable(){this.enabled=!0,n()},disable(){this.enabled=!1,n()},update(c){Object.assign(this,c),n()},remove(){if(r._registeredTools[e]!==i)return;delete r._registeredTools[e],n()},handler:async(c,l)=>{if(!i.enabled)throw Error(`Tool ${e} is disabled`);let u;if(s){let h=i.inputSchema,m=h?await mf(h,c??{},`Invalid input for tool ${e}: `):c??{};u=await o(m,l)}else u=await o(l);if(i.outputSchema&&!u.isError)u.structuredContent=await mf(i.outputSchema,u.structuredContent,`Invalid output for tool ${e}: `);return u}};if(this._registeredTools[e]=i,!this._appCapabilities.tools&&!this.transport)this.registerAppCapabilities({tools:{listChanged:!0}});return this.ensureToolHandlersInitialized(),n(),i}_toolHandlersInitialized=!1;ensureToolHandlersInitialized(){if(this._toolHandlersInitialized)return;this._toolHandlersInitialized=!0,this.oncalltool=async(e,t)=>{let o=this._registeredTools[e.name];if(!o)throw Error(`Tool ${e.name} not found`);return o.handler(e.arguments,t)},this.onlisttools=async(e,t)=>({tools:await Promise.all(Object.entries(this._registeredTools).filter(([o,r])=>r.enabled).map(async([o,r])=>{let n={name:o,title:r.title,description:r.description,inputSchema:r.inputSchema?await hf(r.inputSchema,"input"):{type:"object",properties:{}}};if(r.outputSchema)n.outputSchema=await hf(r.outputSchema,"output");if(r.annotations)n.annotations=r.annotations;if(r._meta)n._meta=r._meta;return n}))})}async sendToolListChanged(e={}){this._assertInitialized("sendToolListChanged"),await this.notification({method:"notifications/tools/list_changed",params:e})}getHostCapabilities(){return this._hostCapabilities}getHostVersion(){return this._hostInfo}getHostContext(){return this._hostContext}get ontoolinput(){return this.getEventHandler("toolinput")}set ontoolinput(e){this.setEventHandler("toolinput",e)}get ontoolinputpartial(){return this.getEventHandler("toolinputpartial")}set ontoolinputpartial(e){this.setEventHandler("toolinputpartial",e)}get ontoolresult(){return this.getEventHandler("toolresult")}set ontoolresult(e){this.setEventHandler("toolresult",e)}get ontoolcancelled(){return this.getEventHandler("toolcancelled")}set ontoolcancelled(e){this.setEventHandler("toolcancelled",e)}get onhostcontextchanged(){return this.getEventHandler("hostcontextchanged")}set onhostcontextchanged(e){this.setEventHandler("hostcontextchanged",e)}_onteardown;get onteardown(){return this._onteardown}set onteardown(e){this.warnIfRequestHandlerReplaced("onteardown",this._onteardown,e),this._onteardown=e,this.replaceRequestHandler("ui/resource-teardown",{params:pb.shape.params,result:hb},(t,o)=>{if(!this._onteardown)throw Error("No onteardown handler set");return this._onteardown(t,o)})}_oncalltool;get oncalltool(){return this._oncalltool}set oncalltool(e){this.warnIfRequestHandlerReplaced("oncalltool",this._oncalltool,e),this._oncalltool=e,this.replaceRequestHandler("tools/call",(t,o)=>{if(!this._oncalltool)throw Error("No oncalltool handler set");return this._oncalltool(t.params,o)})}_onlisttools;get onlisttools(){return this._onlisttools}set onlisttools(e){this.warnIfRequestHandlerReplaced("onlisttools",this._onlisttools,e),this._onlisttools=e,this.replaceRequestHandler("tools/list",(t,o)=>{if(!this._onlisttools)throw Error("No onlisttools handler set");return this._onlisttools(t.params,o)})}assertCapabilityForMethod(e){switch(e){case"sampling/createMessage":if(!this._hostCapabilities?.sampling)throw Error(`Host does not support sampling (required for ${e})`);break}}assertRequestHandlerCapability(e){switch(e){case"tools/call":case"tools/list":if(!this._appCapabilities.tools)throw Error(`Client does not support tool capability (required for ${e})`);return;default:return}}assertNotificationCapability(e){}async callServerTool(e,t){if(this._assertInitialized("callServerTool"),typeof e==="string")throw Error(`callServerTool() expects an object as its first argument, but received a string ("${e}"). Did you mean: callServerTool({ name: "${e}", arguments: { ... } })?`);return await this.request({method:"tools/call",params:e},{onprogress:()=>{},resetTimeoutOnProgress:!0,...t})}async readServerResource(e,t){return this._assertInitialized("readServerResource"),await this.request({method:"resources/read",params:e},t)}async listServerResources(e,t){return this._assertInitialized("listServerResources"),await this.request({method:"resources/list",params:e},t)}async createSamplingMessage(e,t){return this._assertInitialized("createSamplingMessage"),await this.request({method:"sampling/createMessage",params:e},t)}sendMessage(e,t){return this._assertInitialized("sendMessage"),this.request({method:"ui/message",params:e},ib,t)}sendLog(e){return this.notification({method:"notifications/message",params:e})}updateModelContext(e,t){return this._assertInitialized("updateModelContext"),this.request({method:"ui/update-model-context",params:e},Ut,t)}openLink(e,t){return this._assertInitialized("openLink"),this.request({method:"ui/open-link",params:e},nb,t)}sendOpenLink=this.openLink;downloadFile(e,t){return this._assertInitialized("downloadFile"),this.request({method:"ui/download-file",params:e},sb,t)}requestTeardown(e={}){return this.notification({method:"ui/notifications/request-teardown",params:e})}requestDisplayMode(e,t){return this._assertInitialized("requestDisplayMode"),this.request({method:"ui/request-display-mode",params:e},gb,t)}sendSizeChanged(e){return this.notification({method:"ui/notifications/size-changed",params:e})}setupSizeChangedNotifications(){let e=!1,t=0,o=0,r=()=>{if(e)return;e=!0,requestAnimationFrame(()=>{e=!1;let s=document.documentElement,i=s.style.height;s.style.height="max-content";let c=Math.ceil(s.getBoundingClientRect().height);s.style.height=i;let l=Math.ceil(window.innerWidth);if(l!==t||c!==o)t=l,o=c,this.sendSizeChanged({width:l,height:c})})};r();let n=new ResizeObserver(r);return n.observe(document.documentElement),n.observe(document.body),()=>n.disconnect()}async connect(e=new Sf(window.parent,window.parent),t){if(this.transport)throw Error("App is already connected. Call close() before connecting again.");this._initializedSent=!1;try{await super.connect(e);let o=await this.request({method:"ui/initialize",params:{appCapabilities:this._appCapabilities,appInfo:this._appInfo,protocolVersion:Xy}},bb,t);if(o===void 0)throw Error(`Server sent invalid initialize result: ${o}`);if(this._hostCapabilities=o.hostCapabilities,this._hostInfo=o.hostInfo,this._hostContext=o.hostContext,await this.notification({method:"ui/notifications/initialized"}),this._initializedSent=!0,this.options?.autoResize)this.setupSizeChangedNotifications()}catch(o){throw this.close(),o}}}function yf(e,t){let o=[],r=new Set;function n(s){if(r.has(s))return;r.add(s);let i=e.get(s);if(!i)throw Error(`Missing preview dependency metadata: ${s}`);for(let c of[...i.imports,...i.styles,...i.references])n(c);o.push(s)}return n(t),o}function bf(e,t){if(!e||e.revision===t.revision)return[];let o=(r,n)=>{let s=new Map(Object.entries(r.assets));return JSON.stringify(yf(s,n.module).map((i)=>[i,s.get(i)]))};return t.scenarios.filter((r)=>{let n=e.scenarios.find((s)=>s.id===r.id);return!n||o(e,n)!==o(t,r)}).map((r)=>r.id)}class Cl{constructor(e){this.read=e,this.records=new Map,this.bytes=new Map,this.urls=new Map,this.styles=new Map,this.styleReady=new Map,this.revisions=new Set,this.loadedModules=new Set,this.importing=Promise.resolve(),this.generation=0,this.prefetchGeneration=0,this.closed=!1,globalThis.__dsPreviewImport=(t)=>this.importModule(t)}register(e){if(e.schemaVersion!==1||!Array.isArray(e.scenarios)||!e.assets||typeof e.revision!=="string")throw Error("Unsupported preview manifest. Rebuild previews with the installed ADS version.");for(let[t,o]of Object.entries(e.assets)){if(!/^ads:\/\/assets\/[a-f0-9]{64}\.[a-z0-9]+$/.test(t)||!/^sha256:[a-f0-9]{64}$/.test(o.digest)||!["imports","dynamicImports","styles","references"].every((r)=>Array.isArray(o[r])&&o[r].every((n)=>Object.hasOwn(e.assets,n))))throw Error("Invalid preview dependency graph.");if(this.records.has(t)&&this.records.get(t).digest!==o.digest)throw Object.assign(Error("An immutable preview resource changed its content. Rebuild previews with the current ADS version."),{code:"ADS_RESOURCE_IDENTITY",category:"build",resourceUri:t})}for(let[t,o]of Object.entries(e.assets))this.records.set(t,o)}async resource(e){if(!this.bytes.has(e)){let t=(async()=>{let o=this.records.get(e);if(!o)throw Error(`Unknown preview dependency: ${e}`);let r;try{r=await this.read(e)}catch(l){throw Object.assign(Error(`Preview resource read failed for ${e}: ${l.message}`,{cause:l}),{code:"ADS_RESOURCE_READ",category:"transport",resourceUri:e})}if(this.closed)throw Error("The preview App was closed.");let n=r.contents.find((l)=>l.uri===e);if(!n)throw Object.assign(Error(`Missing preview dependency: ${e}`),{code:"ADS_RESOURCE_CONTENT",category:"build",resourceUri:e});let s=typeof n.text==="string"?new TextEncoder().encode(n.text):Uint8Array.from(atob(n.blob),(l)=>l.charCodeAt(0)),i=await crypto.subtle.digest("SHA-256",s),c="sha256:"+[...new Uint8Array(i)].map((l)=>l.toString(16).padStart(2,"0")).join("");if(s.length!==o.size||c!==o.digest)throw Object.assign(Error("Preview resource integrity check failed. Rebuild and reopen the preview."),{code:"ADS_RESOURCE_INTEGRITY",category:"build",resourceUri:e});return s})();this.bytes.set(e,t),t.catch(()=>this.bytes.delete(e))}return this.bytes.get(e)}closure(e){return yf(this.records,e)}async prefetch(e,t){if(this.closed)return;this.register(e);let o=++this.prefetchGeneration,r=new Set,n=[],s=0;for(let u of t){let h=e.scenarios.find((g)=>g.id===u);if(!h)continue;let m=this.closure(h.module).filter((g)=>!this.bytes.has(g)&&!r.has(g)),S=m.reduce((g,b)=>g+this.records.get(b).size,0);if(s+S>16777216||r.size+m.length>256)continue;s+=S,n.push(u);for(let g of m)r.add(g)}let i=[...r],c=0,l=async()=>{while(!this.closed&&o===this.prefetchGeneration&&c<i.length)await this.resource(i[c++])};return await Promise.all(Array.from({length:Math.min(3,i.length)},l)),{scenarios:n,resources:i.length}}async materialize(e){let t=this.closure(e);await Promise.all(t.map((r)=>this.resource(r)));let o={};for(let r of t){if(this.closed)throw Error("The preview App was closed.");if(this.urls.has(r))continue;let n=this.records.get(r),s=await this.resource(r);if(n.kind==="module"||n.mimeType==="text/css"||n.mimeType==="text/javascript"){let c=new TextDecoder().decode(s);for(let l of n.references){let u=this.urls.get(l);if(!u)throw Error("Unsupported cyclic asset reference.");c=c.replaceAll(l,u)}s=c}let i=URL.createObjectURL(new Blob([s],{type:n.mimeType}));if(this.urls.set(r,i),n.kind==="module")o[r]=i}if(Object.keys(o).length){let r=document.createElement("script");r.type="importmap",r.textContent=JSON.stringify({imports:o}),document.head.append(r)}return t}async importModule(e){let t=this.importing.then(()=>this.materialize(e));this.importing=t.catch(()=>{});let o=await t;await this.attachStyles(o);try{let r=await import(e);return this.loadedModules.add(e),r}catch(r){throw Error(`Preview module import failed for ${e}: ${r.message}. Inspect the App resource bridge, browser network/CSP diagnostics and current build.`,{cause:r})}}async attachStyles(e){for(let t of e){if(this.records.get(t).mimeType!=="text/css")continue;if(this.styles.has(t)){await this.styleReady.get(t);continue}let r=document.createElement("link");r.rel="stylesheet",r.href=this.urls.get(t),this.styles.set(t,r);let n=new Promise((s,i)=>{r.onload=s,r.onerror=()=>i(Error("The host CSP blocked a preview stylesheet."))});this.styleReady.set(t,n),document.head.append(r);try{await n}catch(s){throw r.remove(),this.styles.delete(t),this.styleReady.delete(t),s}}}async refreshStyles(e,t){let o=[e],r=new Set,n=new Set;for(let s=0;s<o.length;s++){let i=o[s];if(r.has(i))continue;r.add(i);for(let c of await this.materialize(i)){n.add(c);for(let l of this.records.get(c).dynamicImports)if(this.loadedModules.has(l))o.push(l)}}if(await this.attachStyles([...n]),t!==this.generation||this.closed)return!1;for(let[s,i]of this.styles)if(!n.has(s))i.remove(),this.styles.delete(s),this.styleReady.delete(s);for(let s of n)if(this.styles.has(s))document.head.append(this.styles.get(s));return!0}async mount(e,t,o){let r=++this.generation;this.register(e);let n=e.scenarios.find((l)=>l.id===t);if(!n)throw Error("The selected scenario is no longer registered.");let s=JSON.stringify(this.closure(n.module).map((l)=>[l,this.records.get(l)]));if(this.mounted?.id===t&&this.mounted.container===o&&this.mounted.signature===s)return this.refreshStyles(n.module,r);if(this.revisions.add(n.module),this.revisions.size>20)throw Object.assign(Error("Reopen the preview to release modules retained across 20 build revisions."),{code:"ADS_PREVIEW_REOPEN"});let i=await this.importModule(n.module);if(r!==this.generation)return!1;let c=this.unmount;if(this.unmount=void 0,this.mounted=void 0,await c?.(),r!==this.generation||this.closed)return!1;if(o.replaceChildren(),!await this.refreshStyles(n.module,r))return!1;if(typeof i.mount!=="function")throw Error("The compiled scenario has no mount adapter.");if(this.unmount=i.mount(o),typeof this.unmount!=="function")throw Error("The scenario mount adapter must return an unmount callback.");return this.mounted={id:t,container:o,signature:s},!0}async dispose(){if(this.closed)return;this.closed=!0,++this.generation,++this.prefetchGeneration,await this.unmount?.(),this.mounted=void 0;for(let e of this.styles.values())e.remove();for(let e of this.urls.values())URL.revokeObjectURL(e);this.styles.clear(),this.styleReady.clear(),this.urls.clear(),this.bytes.clear(),this.records.clear(),this.revisions.clear(),this.loadedModules.clear(),delete globalThis.__dsPreviewImport}}function vf(e){return Array.isArray(e)&&e.length>0&&e.every((t)=>t&&typeof t==="object"&&typeof t.token==="string"&&/^--[\w-]+$/.test(t.token)&&typeof t.property==="string"&&/^-?[a-z][a-z0-9-]*$/.test(t.property)&&typeof t.probe==="string"&&t.probe.trim().length>0)&&new Set(e.map((t)=>`${t.token}:${t.property}`)).size===e.length}function zf(e,t){let o=t.getComputedStyle(e),r=e.getBoundingClientRect();if(o.display==="none"||o.visibility!=="visible"||!e.getClientRects().length||!(r.width||r.height))return!1;for(let n=e;n;n=n.parentElement)if(Number(t.getComputedStyle(n).opacity)===0)return!1;return!0}function Rf(e,t){if(!vf(t))return{ok:!1,diagnostics:["Token preview needs explicit { token, property, probe } samples from the project fixture. Rebuild with the current compiler."]};let o=e.ownerDocument,{defaultView:r,documentElement:n}=o,s=[],i=[],c=[...e.querySelectorAll("[data-ads-token], [data-ads-property]")],l=new Set(t.map((u)=>`${u.token}:${u.property}`));for(let u of c)if(!l.has(`${u.dataset.adsToken}:${u.dataset.adsProperty}`))s.push(`Undeclared rendered token sample ${u.dataset.adsToken}:${u.dataset.adsProperty}.`);for(let u of t){if(!r.CSS.supports(u.property,u.probe)){s.push(`${u.token}: the fixture probe is invalid for ${u.property}.`);continue}let h=r.getComputedStyle(n).getPropertyValue(u.token).trim();if(!h||!r.CSS.supports(u.property,h)){s.push(`${u.token}: its current value is invalid for the fixture's ${u.property} binding.`);continue}let m=c.filter((g)=>g.dataset.adsToken===u.token&&g.dataset.adsProperty===u.property);if(!m.length){s.push(`${u.token} needs a rendered ${u.property} sample, not only a name/value label.`);continue}let S=!1;for(let g of m){let b=[];for(let q=g.parentElement;q&&q!==e;q=q.parentElement)if(q.tagName==="DETAILS"&&!q.open)q.open=!0,b.push(q);let v=n.getAttribute("style"),R=g.getAttribute("style");try{if(!/^(?:-[a-z]+-)?transition(?:-|$)/.test(u.property))g.style.setProperty("transition","none","important");let q=r.getComputedStyle(g).getPropertyValue(u.property),V=zf(g,r);n.style.setProperty(u.token,u.probe,"important");let P=r.getComputedStyle(g).getPropertyValue(u.property);S=Boolean(P&&P!==q&&(V||zf(g,r)))}finally{if(v===null)n.removeAttribute("style");else n.setAttribute("style",v);if(R===null)g.removeAttribute("style");else g.setAttribute("style",R);for(let q of b)q.open=!1}if(S)break}if(S)i.push(u);else s.push(`${u.token} has no visible ${u.property} sample that responds to its value. Hardcoded copies do not satisfy coverage.`)}return{ok:!s.length,verified:i,diagnostics:s}}function wf({container:e=document.getElementById("root"),bindings:t=[],auditResources:o=!1}={}){let r=[],n=[],s=[];if(!e||!Array.isArray(t)||t.length>100)return{ok:!1,diagnostics:["Invalid bounded paint-audit descriptor."],verified:n};let i=e.ownerDocument,c=i.defaultView,l=["color","fill","stroke","stop-color","background-color","border-top-color","border-right-color","border-bottom-color","border-left-color"];function u(m,S,g,b=new Set){if(m=m.trim(),["none","currentColor"].includes(m))return!0;let v=/^var\(\s*(--[\w-]+)\s*\)$/.exec(m);if(v){let V=v[1];if(!g.tokens.includes(V)||b.has(V))return!1;let P=c.getComputedStyle(S).getPropertyValue(V).trim();return!!P&&c.CSS.supports("color",P)}let R=Array.isArray(g.themes)?g.themes:[];if(R.length&&m.startsWith("var(--ads-if-")){let V=/^var\(\s*--ads-if-([a-z][a-z0-9-]*)\s*,\s*(var\(\s*--[\w-]+\s*\)|currentColor|none)\s*\)/,P=m,H=[];while(P){let B=V.exec(P);if(!B)return!1;H.push(B),P=P.slice(B[0].length).trimStart()}return H.length===R.length&&H.every((B,G)=>B[1]===R[G]&&u(B[2],S,g,b))}let q=/^url\(\s*(["']?)#([^\s"'()#\\\p{Cc}]+)\1\s*\)$/u.exec(m);if(q&&c.CSS.supports("fill",m)){let V=[...i.querySelectorAll("[id]")].filter((P)=>P.id===q[2]);return V.length===1&&["linearGradient","radialGradient","pattern"].includes(V[0].localName)&&S.contains(V[0])}return!1}for(let m of t){if(!m||typeof m.scope!=="string"||!Array.isArray(m.tokens)||typeof m.prefix!=="string"||typeof m.suffix!=="string"){r.push("Invalid paint binding metadata; rebuild previews.");continue}let S;try{S=[...e.querySelectorAll(m.scope)]}catch{r.push(`${m.owner}: invalid binding scope.`);continue}if(S.length>20)s.push(`${m.owner}: only the first 20 instances were audited; use a focused scenario for complete evidence.`);for(let g of S.slice(0,20)){let b=[g,...g.querySelectorAll("*")];if(b.length>1000){s.push(`${m.owner}: instance exceeds 1000 elements; paint effects are not established.`);continue}let v=[...g.style].filter((R)=>R.startsWith(m.prefix)&&R.endsWith(m.suffix));if(v.length>100)s.push(`${m.owner}: only the first 100 binding keys were audited.`);for(let R of v.slice(0,100)){let q=g.style.getPropertyValue(R).trim(),V=R.slice(m.prefix.length,m.suffix?-m.suffix.length:void 0);if(!/^[A-Za-z0-9_-]+$/.test(V)||!u(q,g,m)){r.push(`${m.owner}: invalid or inaccessible paint ${R}: ${q}. Use an accessible token, instance-local SVG paint server, none or currentColor.`);continue}let P=g.getAttribute("style"),H=b.map((B)=>B.getAttribute("style"));try{for(let Y of b)Y.style.setProperty("transition","none","important");let B=b.map((Y)=>l.map((ue)=>c.getComputedStyle(Y).getPropertyValue(ue)));g.style.setProperty(R,"rgb(17, 103, 211)","important");let G=b.some((Y,ue)=>l.some((oe,fe)=>c.getComputedStyle(Y).getPropertyValue(oe)!==B[ue][fe]));if(!G)g.style.setProperty(R,"rgb(211, 67, 23)","important"),G=b.some((Y,ue)=>l.some((oe,fe)=>c.getComputedStyle(Y).getPropertyValue(oe)!==B[ue][fe]));if(!G)s.push(`${m.owner}: ${R} has no observed paint effect in its current instance. A written variable alone is not rendering evidence; check the relevant selected/visible consumer.`);else n.push({owner:m.owner,binding:m.name,variable:R})}finally{if(b.forEach((B,G)=>{if(H[G]===null)B.removeAttribute("style");else B.setAttribute("style",H[G])}),P===null)g.removeAttribute("style");else g.setAttribute("style",P)}}for(let R of b)for(let q of["fill","stroke","stop-color"]){let V=R.getAttribute(q);if(!V)continue;let P=/^var\(\s*(--[\w-]+)\s*\)$/.exec(V);if(P&&P[1].startsWith(m.prefix)&&P[1].endsWith(m.suffix)&&!v.includes(P[1]))r.push(`${m.owner}: ${P[1]} is consumed without a value in this instance.`);if(V.startsWith("url(")&&!u(V,g,m))r.push(`${m.owner}: missing, duplicated or out-of-instance local paint resource ${V}.`)}}}let h=o?[...e.querySelectorAll("[fill], [stroke], [style]")]:[];if(h.length>1000)s.push("Only the first 1000 potential SVG paint consumers were audited.");for(let m of h.slice(0,1000))for(let S of["fill","stroke"]){let g=m.getAttribute(S)??m.style.getPropertyValue(S);if(!g?.startsWith("url("))continue;let b=/^url\(\s*(["']?)#([^\s"'()#\\\p{Cc}]+)\1\s*\)$/u.exec(g)?.[2],v=b?[...i.querySelectorAll("[id]")].filter((q)=>q.id===b):[],R=m.ownerSVGElement??(m.localName==="svg"?m:null);if(v.length!==1||!R?.contains(v[0])||!["linearGradient","radialGradient","pattern"].includes(v[0]?.localName))r.push(`Invalid, missing, duplicated or nonlocal SVG paint resource ${g}. Keep IDs isolated per rendered instance.`)}return{ok:!r.length,complete:!s.length,verified:n,diagnostics:r.slice(0,40),limits:s.slice(0,20),scope:"observed App instances and current input; repeat after updates"}}var De=new Da({name:"ADS resource preview",version:"1.0.0"},{},{autoResize:!0}),Eo=document.getElementById("root"),Il=document.getElementById("ads-preview-status"),Al,jl=async(e)=>{if(!De.getHostCapabilities()?.serverResources)throw Error("This host does not forward MCP resource reads. Open the same preview in the ADS showcase.");try{return await De.readServerResource({uri:Al?Al+encodeURIComponent(e):e},{timeout:15000})}catch(t){if(t.code===-32601||t.message==="Method not found")throw Error("This host does not forward MCP resource reads. Open the same preview in the ADS showcase.");throw t}},gi=new Cl(jl),Pt,Pf,ko,Ml,Ll,Ol=!1,Jt=0,Ke={},Tf=[],Ze="",mi=!1,Nl,xf,Ef=new Set;function kf(e){if(De.getHostVersion()?.name!=="ADS showcase")return;let t=xf;if(xf=e,!t)return;let o=bf(t,e).filter((r)=>r!==Pt&&Ef.has(r));if(!o.length)return;gi.prefetch(e,o).then((r)=>Bt("prefetched",{revision:e.revision,...r})).catch((r)=>console.warn("ADS preview prefetch",r.message))}function ht(e,t=!1){Il.textContent=e,Il.hidden=!e||De.getHostVersion()?.name==="ADS showcase",Il.setAttribute("role",t?"alert":"status")}async function Bt(e,t={}){try{if(De.getHostCapabilities()?.logging)await De.sendLog({level:e==="error"?"error":"info",logger:"ads-preview",data:{state:e,id:Pt,...t}})}catch{}}var Rb=`#ads-grid-overlay{position:fixed;inset:0;z-index:2147483647;pointer-events:none;display:grid;
|
|
107
110
|
grid-template-columns:repeat(var(--grid-columns-sm,4),minmax(0,1fr));gap:var(--grid-gutter,32px);padding-inline:var(--grid-margin-sm,0px)}
|
|
108
111
|
#ads-grid-overlay>div{background:rgb(255 0 64 / 0.1);box-shadow:inset 1px 0 rgb(255 0 64 / 0.35),inset -1px 0 rgb(255 0 64 / 0.35)}
|
|
109
112
|
#ads-grid-overlay>div:nth-child(n+5){display:none}
|
|
110
113
|
@media (min-width:768px){#ads-grid-overlay{grid-template-columns:repeat(var(--grid-columns-md,8),minmax(0,1fr));padding-inline:var(--grid-margin-md,16px)}#ads-grid-overlay>div:nth-child(n+5){display:block}#ads-grid-overlay>div:nth-child(n+9){display:none}}
|
|
111
114
|
@media (min-width:1024px){#ads-grid-overlay{grid-template-columns:repeat(var(--grid-columns-lg,16),minmax(0,1fr))}#ads-grid-overlay>div:nth-child(n+9){display:block}}
|
|
112
|
-
@media (min-width:1280px){#ads-grid-overlay{padding-inline:var(--grid-margin-lg,24px)}}`;function
|
|
113
|
-
${
|
|
114
|
-
`)}`),{code:"ADS_PAINT_BINDING",category:"assertion"});if(
|
|
115
|
-
${
|
|
116
|
-
`)}`,Object.assign(Error(
|
|
117
|
-
${o}`)}
|
|
118
|
-
${o}`:"Rebuilding. This is the previous preview.",Boolean(o))}else{let o=await
|
|
115
|
+
@media (min-width:1280px){#ads-grid-overlay{padding-inline:var(--grid-margin-lg,24px)}}`;function wb(e){let t=document.getElementById("ads-grid-overlay"),o=getComputedStyle(document.documentElement).getPropertyValue("--grid-columns-sm").trim();if(!e||!o){t?.remove();return}if(t)return;if(!document.getElementById("ads-grid-overlay-style"))document.head.append(Object.assign(document.createElement("style"),{id:"ads-grid-overlay-style",textContent:Rb}));t=document.createElement("div"),t.id="ads-grid-overlay",t.setAttribute("aria-hidden","true"),t.append(...Array.from({length:16},()=>document.createElement("div"))),document.body.append(t)}function Ul(e){Ke={...Ke,...e,styles:{...Ke.styles,...e.styles}};let t=Ke.adsTheme??(["light","dark"].includes(Ke.theme)?(Tf.find((o)=>o.scheme===Ke.theme)??{name:Ke.theme}).name:void 0);if(t)document.documentElement.dataset.theme=t;if(typeof Ke.adsBrand==="string"&&/^[a-z][a-z0-9-]*$/.test(Ke.adsBrand))document.documentElement.dataset.brand=Ke.adsBrand;wb(Ke.gridOverlay===!0)}async function ql(e="ads://preview/manifest"){let t;try{t=await jl(e)}catch(o){throw Object.assign(Error(o.message,{cause:o}),{code:"ADS_MANIFEST_READ",category:"transport"})}return JSON.parse(t.contents.find((o)=>typeof o.text==="string").text)}async function fi(e,t,o=!1,r="",n=!1){let s=o||n;if(!r&&e===Pt&&t&&t===ko&&s===mi){ht(Ze||(s?"Checking changes…":""),Boolean(Ze)),await Bt(Ze?"error":s?"checking":"ready",Ze?{message:Ze}:{revision:ko});return}let i=++Jt;++gi.generation,Pt=e,Ef.add(e),document.documentElement.dataset.adsScenario=e,document.documentElement.dataset.adsPreviewState="loading";for(let c of["adsPreviewErrorCategory","adsPreviewErrorCode","adsPreviewResourceUri"])delete document.documentElement.dataset[c];Ze="",ht(""),await Bt(r?"reverting":"loading");try{let c=await ql(o?"ads://preview/live":"ads://preview/manifest");if(Array.isArray(c.themes))Tf=c.themes,Ul({});if(t&&c.revision!==t){if(i===Jt)ht("Updating preview…"),await Bt("loading",{code:"ADS_PREVIEW_CHANGED"});return}if(i!==Jt)return;if(!await gi.mount(c,e,Eo)||i!==Jt)return;if(ko=c.revision,Ml=c.session,mi=s,await new Promise((h)=>requestAnimationFrame(()=>requestAnimationFrame(h))),await document.fonts.ready,i!==Jt)return;let u=c.scenarios.find((h)=>h.id===e);if(Eo.dataset.adsPaintBindings=JSON.stringify(u?.paintBindings??[]),Eo.dataset.adsPaintAudit=String(Boolean(u?.paintAudit)),Eo.dataset.adsPaintAuditComplete="not-requested",u?.paintBindings?.length||u?.paintAudit){let h=wf({container:Eo,bindings:u.paintBindings??[],auditResources:Boolean(u.paintAudit)});if(!h.ok)throw Object.assign(Error(`Paint binding verification failed:
|
|
116
|
+
${h.diagnostics.join(`
|
|
117
|
+
`)}`),{code:"ADS_PAINT_BINDING",category:"assertion"});if(Eo.dataset.adsPaintAuditComplete=String(h.complete),!h.complete)await Bt("audit-limited",{limits:h.limits})}if(u?.kind==="tokens"){let h=Rf(Eo,u.samples);if(!h.ok)throw Ze=`Token preview verification failed:
|
|
118
|
+
${h.diagnostics.slice(0,20).join(`
|
|
119
|
+
`)}`,Object.assign(Error(Ze),{code:"ADS_TOKEN_SAMPLE",category:"assertion"})}if(i===Jt){if(document.documentElement.dataset.adsPreviewRevision=ko,document.documentElement.dataset.adsPreviewState=r?"error":s?"checking":"ready",ht(r||(s?"Checking changes…":""),Boolean(r)),await Bt(r?"error":s?"checking":"ready",{revision:ko,selectionRevision:Pf,...r?{message:r}:{}}),!s&&!r)kf(c)}}catch(c){if(i===Jt){if(document.documentElement.dataset.adsPreviewState="error",document.documentElement.dataset.adsPreviewErrorCategory=c.category??"runner",document.documentElement.dataset.adsPreviewErrorCode=c.code??"ADS_PREVIEW_STARTUP",c.resourceUri)document.documentElement.dataset.adsPreviewResourceUri=c.resourceUri;ht(c.message,!0),await Bt("error",{message:c.message,...c.code?{code:c.code}:{},...c.category?{category:c.category}:{},...c.resourceUri?{resourceUri:c.resourceUri}:{}})}}}async function xb(){if(!Pt||Ol||document.visibilityState==="hidden")return;Ol=!0;try{let e=JSON.parse((await jl("ads://project/build")).contents.find((o)=>typeof o.text==="string").text);Nl=void 0;let t=e.previews.find((o)=>o.id===Pt);if(t?.live&&!t.current)if(t.live.revision!==ko||e.session!==Ml||!mi)await fi(Pt,t.live.revision,!0);else ht(Ze||"Checking changes…",Boolean(Ze));else if(!t||!t.current){let o=t?.diagnostics?.[0]?.message;if(o&&mi){let r=await ql();await fi(Pt,r.revision,!1,`Build failed. Showing the previous preview.
|
|
120
|
+
${o}`)}ht(o?`Build failed. Showing the previous preview.
|
|
121
|
+
${o}`:"Rebuilding. This is the previous preview.",Boolean(o))}else{let o=await ql();if(o.revision!==ko||o.session!==Ml||mi)await fi(Pt,o.revision);else ht(Ze,Boolean(Ze)),kf(o)}}catch(e){let t=`Preview freshness unavailable: ${e.message}`;if(ht(t,!0),Nl!==t)Nl=t,await Bt("error",{message:t})}finally{Ol=!1}}De.ontoolresult=(e)=>{Al=e.structuredContent?.draftScope;let t=e.structuredContent?.previewResult?.structuredContent??e.structuredContent;if(t?.scenario?.id)Pf=t.manifestRevision,fi(t.scenario.id,t.manifestRevision,t.manifestUri==="ads://preview/live","",t.build?.current===!1)};De.onhostcontextchanged=Ul;De.onteardown=async()=>(++Jt,clearInterval(Ll),await gi.dispose(),{});try{if(await De.connect(),Ul(De.getHostContext()??{}),!De.getHostCapabilities()?.serverResources)throw Error("This host does not forward MCP resource reads. Open the same preview in the ADS showcase.");Ll=setInterval(()=>{xb()},150);let e=document.getElementById("ads-preview-selection");if(e)fi(JSON.parse(e.textContent).id)}catch(e){ht(e.message,!0)}window.addEventListener("pagehide",()=>{clearInterval(Ll),gi.dispose()},{once:!0});
|