@reqvire-org/ads 0.3.11 → 0.3.13

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.
Files changed (46) hide show
  1. package/README.md +20 -1
  2. package/dist/capture/worker.mjs +38 -0
  3. package/dist/capture-store.mjs +123 -0
  4. package/dist/capture.mjs +117 -0
  5. package/dist/config.mjs +6 -1
  6. package/dist/mcp/catalog.mjs +3 -3
  7. package/dist/mcp/context.mjs +1 -1
  8. package/dist/mcp/mutations.mjs +26 -6
  9. package/dist/mcp/server.mjs +64 -17
  10. package/dist/project-documents.mjs +29 -6
  11. package/dist/scenarios.mjs +9 -3
  12. package/dist/showcase/client.bundle.js +18 -18
  13. package/dist/showcase/style.css +2 -0
  14. package/dist/skills/ads-break-ui/SKILL.md +12 -5
  15. package/dist/skills/ads-break-ui/references/captures.md +147 -0
  16. package/dist/skills/ads-break-ui/references/guarded-editing.md +68 -0
  17. package/dist/skills/ads-break-ui/references/scenarios.md +22 -0
  18. package/dist/skills/ads-designer/SKILL.md +13 -6
  19. package/dist/skills/ads-designer/references/captures.md +147 -0
  20. package/dist/skills/ads-designer/references/guarded-editing.md +68 -0
  21. package/dist/skills/ads-designer/references/scenarios.md +22 -0
  22. package/dist/skills/ads-import/SKILL.md +13 -6
  23. package/dist/skills/ads-import/references/captures.md +147 -0
  24. package/dist/skills/ads-import/references/guarded-editing.md +68 -0
  25. package/dist/skills/ads-import/references/implementation.md +3 -1
  26. package/dist/skills/ads-import/references/scenarios.md +22 -0
  27. package/dist/skills/ads-migrate/SKILL.md +12 -5
  28. package/dist/skills/ads-migrate/references/captures.md +147 -0
  29. package/dist/skills/ads-migrate/references/guarded-editing.md +68 -0
  30. package/dist/skills/ads-migrate/references/scenarios.md +22 -0
  31. package/dist/skills/ads-migrate/references/testing.md +5 -0
  32. package/dist/skills/ads-motion/SKILL.md +12 -5
  33. package/dist/skills/ads-motion/references/captures.md +147 -0
  34. package/dist/skills/ads-motion/references/guarded-editing.md +68 -0
  35. package/dist/skills/ads-motion/references/scenarios.md +22 -0
  36. package/dist/units.mjs +7 -6
  37. package/dist/verification/browser.mjs +8 -3
  38. package/dist/verification/playwright-reporter.cjs +23 -8
  39. package/dist/verification.mjs +137 -33
  40. package/docs/ADS.md +9 -0
  41. package/docs/ARCHITECTURE.md +44 -3
  42. package/docs/BEHAVIORS.md +57 -3
  43. package/docs/CHANGELOG.md +28 -0
  44. package/docs/GUIDE.md +48 -1
  45. package/docs/MCP.md +63 -2
  46. package/package.json +1 -1
@@ -1,7 +1,7 @@
1
- var Hy=Object.defineProperty;var Ut=(e,t)=>{for(var o in t)Hy(e,o,{get:t[o],enumerable:!0})};var Vy=Object.create,ac=Object.defineProperty,Jy=Object.getOwnPropertyDescriptor,By=Object.getOwnPropertyNames,Wy=Object.getPrototypeOf,Ky=Object.prototype.hasOwnProperty,Lg=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),Ug=(e,t)=>{let o={};for(var r in e)ac(o,r,{get:e[r],enumerable:!0});return t&&ac(o,Symbol.toStringTag,{value:"Module"}),o},Gy=(e,t,o,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(var n=By(t),s=0,i=n.length,a;s<i;s++)a=n[s],!Ky.call(e,a)&&a!==o&&ac(e,a,{get:(l=>t[l]).bind(null,a),enumerable:!(r=Jy(t,a))||r.enumerable});return e},Zg=(e,t,o)=>(o=e!=null?Vy(Wy(e)):{},Gy(t||!e||!e.__esModule?ac(o,"default",{value:e,enumerable:!0}):o,e));var Yy=new Set(["https://json-schema.org/draft/2020-12/schema","http://json-schema.org/draft/2020-12/schema"]),Dg=new Set(["https://json-schema.org/draft/2019-09/schema","http://json-schema.org/draft/2019-09/schema"]),Xy=new Set(["https://json-schema.org/draft-07/schema","http://json-schema.org/draft-07/schema"]),Qy=new Set(["https://json-schema.org/draft-06/schema","http://json-schema.org/draft-06/schema"]);function Fg(e){return typeof e=="string"&&Dg.has(e.replace(/#$/,""))}function Hg(e,t){if(!("$schema"in e)||typeof e.$schema!="string")return"2020-12";let o=e.$schema.replace(/#$/,"");if(Yy.has(o))return"2020-12";if(Dg.has(o))return"2019-09";if(Xy.has(o)||Qy.has(o))return"draft-7";throw new 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 p={};Ut(p,{$brand:()=>Uu,$input:()=>ch,$output:()=>ah,NEVER:()=>ys,TimePrecision:()=>ph,ZodAny:()=>Ym,ZodArray:()=>tf,ZodBase64:()=>Nl,ZodBase64URL:()=>ql,ZodBigInt:()=>on,ZodBigIntFormat:()=>jl,ZodBoolean:()=>tn,ZodCIDRv4:()=>Il,ZodCIDRv6:()=>Ol,ZodCUID:()=>xl,ZodCUID2:()=>Pl,ZodCatch:()=>vf,ZodCodec:()=>Ks,ZodCustom:()=>Gs,ZodCustomStringFormat:()=>Qr,ZodDate:()=>Vs,ZodDefault:()=>gf,ZodDiscriminatedUnion:()=>rf,ZodE164:()=>Ml,ZodEmail:()=>zl,ZodEmoji:()=>Rl,ZodEnum:()=>Gr,ZodError:()=>qv,ZodExactOptional:()=>hf,ZodFile:()=>df,ZodFirstPartyTypeKind:()=>Nf,ZodFunction:()=>Cf,ZodGUID:()=>Zs,ZodIPv4:()=>$l,ZodIPv6:()=>Cl,ZodISODate:()=>fl,ZodISODateTime:()=>ml,ZodISODuration:()=>Sl,ZodISOTime:()=>gl,ZodIntersection:()=>nf,ZodIssueCode:()=>qf,ZodJWT:()=>Al,ZodKSUID:()=>kl,ZodLazy:()=>kf,ZodLiteral:()=>uf,ZodMAC:()=>Bm,ZodMap:()=>cf,ZodNaN:()=>wf,ZodNanoID:()=>wl,ZodNever:()=>Qm,ZodNonOptional:()=>Fl,ZodNull:()=>Gm,ZodNullable:()=>ff,ZodNumber:()=>en,ZodNumberFormat:()=>Bo,ZodObject:()=>Js,ZodOptional:()=>Dl,ZodPipe:()=>Ws,ZodPrefault:()=>_f,ZodPreprocess:()=>xf,ZodPromise:()=>$f,ZodReadonly:()=>Pf,ZodRealError:()=>Ve,ZodRecord:()=>Kr,ZodSet:()=>lf,ZodString:()=>Yr,ZodStringFormat:()=>ce,ZodSuccess:()=>zf,ZodSymbol:()=>Wm,ZodTemplateLiteral:()=>Ef,ZodTransform:()=>pf,ZodTuple:()=>sf,ZodType:()=>Q,ZodULID:()=>Tl,ZodURL:()=>Hs,ZodUUID:()=>kt,ZodUndefined:()=>Km,ZodUnion:()=>Bs,ZodUnknown:()=>Xm,ZodVoid:()=>ef,ZodXID:()=>El,ZodXor:()=>of,_ZodString:()=>yl,_default:()=>Sf,_function:()=>P_,any:()=>Ll,array:()=>_,base64:()=>VS,base64url:()=>JS,bigint:()=>r_,boolean:()=>k,catch:()=>Rf,check:()=>T_,cidrv4:()=>FS,cidrv6:()=>HS,clone:()=>Me,codec:()=>v_,coerce:()=>Ys,config:()=>ge,core:()=>Ft,cuid:()=>qS,cuid2:()=>MS,custom:()=>E_,date:()=>l_,decode:()=>Um,decodeAsync:()=>Dm,describe:()=>k_,discriminatedUnion:()=>bo,e164:()=>BS,email:()=>vl,emoji:()=>OS,encode:()=>Lm,encodeAsync:()=>Zm,endsWith:()=>Ur,enum:()=>K,exactOptional:()=>mf,file:()=>__,flattenError:()=>Es,float32:()=>QS,float64:()=>e_,formatError:()=>ks,fromJSONSchema:()=>q_,function:()=>P_,getErrorMap:()=>jv,globalRegistry:()=>ve,gt:()=>Tt,gte:()=>je,guid:()=>TS,hash:()=>XS,hex:()=>YS,hostname:()=>GS,httpUrl:()=>IS,includes:()=>jr,instanceof:()=>C_,int:()=>_l,int32:()=>t_,int64:()=>n_,intersection:()=>pt,invertCodec:()=>R_,ipv4:()=>US,ipv6:()=>DS,iso:()=>Qe,json:()=>O_,jwt:()=>WS,keyof:()=>u_,ksuid:()=>LS,lazy:()=>yo,length:()=>Vo,literal:()=>b,locales:()=>Ms,looseObject:()=>U,looseRecord:()=>m_,lowercase:()=>Mr,lt:()=>Pt,lte:()=>Xe,mac:()=>ZS,map:()=>f_,maxLength:()=>Ho,maxSize:()=>fo,meta:()=>$_,mime:()=>Zr,minLength:()=>Dt,minSize:()=>Et,multipleOf:()=>mo,nan:()=>z_,nanoid:()=>NS,nativeEnum:()=>S_,negative:()=>sl,never:()=>Ul,nonnegative:()=>al,nonoptional:()=>yf,nonpositive:()=>il,normalize:()=>Dr,null:()=>$t,nullable:()=>Ds,nullish:()=>b_,number:()=>R,object:()=>m,optional:()=>L,overwrite:()=>dt,parse:()=>Mm,parseAsync:()=>Am,partialRecord:()=>h_,pipe:()=>bl,positive:()=>nl,prefault:()=>bf,preprocess:()=>Ht,prettifyError:()=>ed,promise:()=>x_,property:()=>cl,readonly:()=>Tf,record:()=>T,refine:()=>If,regex:()=>qr,regexes:()=>Ye,registry:()=>Ac,safeDecode:()=>Hm,safeDecodeAsync:()=>Jm,safeEncode:()=>Fm,safeEncodeAsync:()=>Vm,safeParse:()=>Us,safeParseAsync:()=>jm,set:()=>g_,setErrorMap:()=>Av,size:()=>Fo,slugify:()=>Jr,startsWith:()=>Lr,strictObject:()=>d_,string:()=>c,stringFormat:()=>KS,stringbool:()=>I_,success:()=>y_,superRefine:()=>Of,symbol:()=>i_,templateLiteral:()=>w_,toJSONSchema:()=>Jo,toLowerCase:()=>Hr,toUpperCase:()=>Vr,transform:()=>Zl,treeifyError:()=>Qu,trim:()=>Fr,tuple:()=>af,uint32:()=>o_,uint64:()=>s_,ulid:()=>AS,undefined:()=>a_,union:()=>C,unknown:()=>j,uppercase:()=>Ar,url:()=>Xr,util:()=>G,uuid:()=>ES,uuidv4:()=>kS,uuidv6:()=>$S,uuidv7:()=>CS,void:()=>c_,xid:()=>jS,xor:()=>p_});var Ft={};Ut(Ft,{$ZodAny:()=>kp,$ZodArray:()=>Np,$ZodAsyncError:()=>ut,$ZodBase64:()=>bp,$ZodBase64URL:()=>yp,$ZodBigInt:()=>Cc,$ZodBigIntFormat:()=>xp,$ZodBoolean:()=>Os,$ZodCIDRv4:()=>gp,$ZodCIDRv6:()=>Sp,$ZodCUID:()=>np,$ZodCUID2:()=>sp,$ZodCatch:()=>Xp,$ZodCheck:()=>le,$ZodCheckBigIntFormat:()=>Nd,$ZodCheckEndsWith:()=>Jd,$ZodCheckGreaterThan:()=>xc,$ZodCheckIncludes:()=>Hd,$ZodCheckLengthEquals:()=>Ud,$ZodCheckLessThan:()=>wc,$ZodCheckLowerCase:()=>Dd,$ZodCheckMaxLength:()=>jd,$ZodCheckMaxSize:()=>qd,$ZodCheckMimeType:()=>Wd,$ZodCheckMinLength:()=>Ld,$ZodCheckMinSize:()=>Md,$ZodCheckMultipleOf:()=>Id,$ZodCheckNumberFormat:()=>Od,$ZodCheckOverwrite:()=>Kd,$ZodCheckProperty:()=>Bd,$ZodCheckRegex:()=>Zd,$ZodCheckSizeEquals:()=>Ad,$ZodCheckStartsWith:()=>Vd,$ZodCheckStringFormat:()=>Nr,$ZodCheckUpperCase:()=>Fd,$ZodCodec:()=>qs,$ZodCustom:()=>ih,$ZodCustomStringFormat:()=>Rp,$ZodDate:()=>Op,$ZodDefault:()=>Wp,$ZodDiscriminatedUnion:()=>Ap,$ZodE164:()=>zp,$ZodEmail:()=>ep,$ZodEmoji:()=>op,$ZodEncodeError:()=>co,$ZodEnum:()=>Dp,$ZodError:()=>Ts,$ZodExactOptional:()=>Jp,$ZodFile:()=>Hp,$ZodFunction:()=>rh,$ZodGUID:()=>Xd,$ZodIPv4:()=>hp,$ZodIPv6:()=>mp,$ZodISODate:()=>up,$ZodISODateTime:()=>lp,$ZodISODuration:()=>pp,$ZodISOTime:()=>dp,$ZodIntersection:()=>jp,$ZodJWT:()=>vp,$ZodKSUID:()=>cp,$ZodLazy:()=>sh,$ZodLiteral:()=>Fp,$ZodMAC:()=>fp,$ZodMap:()=>Up,$ZodNaN:()=>Qp,$ZodNanoID:()=>rp,$ZodNever:()=>Cp,$ZodNonOptional:()=>Gp,$ZodNull:()=>Ep,$ZodNullable:()=>Bp,$ZodNumber:()=>$c,$ZodNumberFormat:()=>wp,$ZodObject:()=>zS,$ZodObjectJIT:()=>qp,$ZodOptional:()=>Oc,$ZodPipe:()=>Nc,$ZodPrefault:()=>Kp,$ZodPreprocess:()=>eh,$ZodPromise:()=>nh,$ZodReadonly:()=>th,$ZodRealError:()=>He,$ZodRecord:()=>Lp,$ZodRegistry:()=>Mc,$ZodSet:()=>Zp,$ZodString:()=>Do,$ZodStringFormat:()=>ae,$ZodSuccess:()=>Yp,$ZodSymbol:()=>Pp,$ZodTemplateLiteral:()=>oh,$ZodTransform:()=>Vp,$ZodTuple:()=>Ic,$ZodType:()=>Y,$ZodULID:()=>ip,$ZodURL:()=>tp,$ZodUUID:()=>Qd,$ZodUndefined:()=>Tp,$ZodUnion:()=>Ns,$ZodUnknown:()=>$p,$ZodVoid:()=>Ip,$ZodXID:()=>ap,$ZodXor:()=>Mp,$brand:()=>Uu,$constructor:()=>g,$input:()=>ch,$output:()=>ah,Doc:()=>Is,JSONSchema:()=>wS,JSONSchemaGenerator:()=>pl,NEVER:()=>ys,TimePrecision:()=>ph,_any:()=>Oh,_array:()=>Uh,_base64:()=>el,_base64url:()=>tl,_bigint:()=>Ph,_boolean:()=>wh,_catch:()=>Tv,_check:()=>RS,_cidrv4:()=>Xc,_cidrv6:()=>Qc,_coercedBigint:()=>Th,_coercedBoolean:()=>xh,_coercedDate:()=>jh,_coercedNumber:()=>_h,_coercedString:()=>uh,_cuid:()=>Vc,_cuid2:()=>Jc,_custom:()=>Dh,_date:()=>Ah,_decode:()=>fc,_decodeAsync:()=>Sc,_default:()=>wv,_discriminatedUnion:()=>pv,_e164:()=>ol,_email:()=>jc,_emoji:()=>Fc,_encode:()=>mc,_encodeAsync:()=>gc,_endsWith:()=>Ur,_enum:()=>_v,_file:()=>Zh,_float32:()=>yh,_float64:()=>zh,_gt:()=>Tt,_gte:()=>je,_guid:()=>As,_includes:()=>jr,_int:()=>bh,_int32:()=>vh,_int64:()=>Eh,_intersection:()=>hv,_ipv4:()=>Gc,_ipv6:()=>Yc,_isoDate:()=>mh,_isoDateTime:()=>hh,_isoDuration:()=>gh,_isoTime:()=>fh,_jwt:()=>rl,_ksuid:()=>Kc,_lazy:()=>Cv,_length:()=>Vo,_literal:()=>yv,_lowercase:()=>Mr,_lt:()=>Pt,_lte:()=>Xe,_mac:()=>dh,_map:()=>gv,_max:()=>Xe,_maxLength:()=>Ho,_maxSize:()=>fo,_mime:()=>Zr,_min:()=>je,_minLength:()=>Dt,_minSize:()=>Et,_multipleOf:()=>mo,_nan:()=>Lh,_nanoid:()=>Hc,_nativeEnum:()=>bv,_negative:()=>sl,_never:()=>qh,_nonnegative:()=>al,_nonoptional:()=>xv,_nonpositive:()=>il,_normalize:()=>Dr,_null:()=>Ih,_nullable:()=>Rv,_number:()=>Sh,_optional:()=>vv,_overwrite:()=>dt,_parse:()=>$r,_parseAsync:()=>Cr,_pipe:()=>Ev,_positive:()=>nl,_promise:()=>Iv,_property:()=>cl,_readonly:()=>kv,_record:()=>fv,_refine:()=>Fh,_regex:()=>qr,_safeDecode:()=>bc,_safeDecodeAsync:()=>zc,_safeEncode:()=>_c,_safeEncodeAsync:()=>yc,_safeParse:()=>Ir,_safeParseAsync:()=>Or,_set:()=>Sv,_size:()=>Fo,_slugify:()=>Jr,_startsWith:()=>Lr,_string:()=>lh,_stringFormat:()=>Br,_stringbool:()=>Bh,_success:()=>Pv,_superRefine:()=>Hh,_symbol:()=>$h,_templateLiteral:()=>$v,_toLowerCase:()=>Hr,_toUpperCase:()=>Vr,_transform:()=>zv,_trim:()=>Fr,_tuple:()=>mv,_uint32:()=>Rh,_uint64:()=>kh,_ulid:()=>Bc,_undefined:()=>Ch,_union:()=>uv,_unknown:()=>Nh,_uppercase:()=>Ar,_url:()=>js,_uuid:()=>Lc,_uuidv4:()=>Uc,_uuidv6:()=>Zc,_uuidv7:()=>Dc,_void:()=>Mh,_xid:()=>Wc,_xor:()=>dv,clone:()=>Me,config:()=>ge,createStandardJSONSchemaMethod:()=>Wr,createToJSONSchemaMethod:()=>Wh,decode:()=>Tz,decodeAsync:()=>kz,describe:()=>Vh,encode:()=>Pz,encodeAsync:()=>Ez,extractDefs:()=>So,finalize:()=>_o,flattenError:()=>Es,formatError:()=>ks,globalConfig:()=>Lo,globalRegistry:()=>ve,initializeContext:()=>go,isValidBase64:()=>_p,isValidBase64URL:()=>SS,isValidJWT:()=>_S,locales:()=>Ms,meta:()=>Jh,parse:()=>pc,parseAsync:()=>hc,prettifyError:()=>ed,process:()=>ne,regexes:()=>Ye,registry:()=>Ac,safeDecode:()=>Cz,safeDecodeAsync:()=>Oz,safeEncode:()=>$z,safeEncodeAsync:()=>Iz,safeParse:()=>td,safeParseAsync:()=>od,toDotPath:()=>Gg,toJSONSchema:()=>Jo,treeifyError:()=>Qu,util:()=>G,version:()=>Gd});var Vg,ys=Object.freeze({status:"aborted"});function g(e,t,o){function r(a,l){if(a._zod||Object.defineProperty(a,"_zod",{value:{def:l,constr:i,traits:new Set},enumerable:!1}),a._zod.traits.has(e))return;a._zod.traits.add(e),t(a,l);let u=i.prototype,d=Object.keys(u);for(let h=0;h<d.length;h++){let f=d[h];f in a||(a[f]=u[f].bind(a))}}let n=o?.Parent??Object;class s extends n{}Object.defineProperty(s,"name",{value:e});function i(a){var l;let u=o?.Parent?new s:this;r(u,a),(l=u._zod).deferred??(l.deferred=[]);for(let d of u._zod.deferred)d();return u}return Object.defineProperty(i,"init",{value:r}),Object.defineProperty(i,Symbol.hasInstance,{value:a=>o?.Parent&&a instanceof o.Parent?!0:a?._zod?.traits?.has(e)}),Object.defineProperty(i,"name",{value:e}),i}var Uu=Symbol("zod_brand"),ut=class extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}},co=class extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}};(Vg=globalThis).__zod_globalConfig??(Vg.__zod_globalConfig={});var Lo=globalThis.__zod_globalConfig;function ge(e){return e&&Object.assign(Lo,e),Lo}var G={};Ut(G,{BIGINT_FORMAT_RANGES:()=>Gu,Class:()=>Du,NUMBER_FORMAT_RANGES:()=>Ku,aborted:()=>ho,allowsEval:()=>Vu,assert:()=>nz,assertEqual:()=>ez,assertIs:()=>oz,assertNever:()=>rz,assertNotEqual:()=>tz,assignProp:()=>uo,base64ToUint8Array:()=>Bg,base64urlToUint8Array:()=>zz,cached:()=>Er,captureStackTrace:()=>uc,cleanEnum:()=>yz,cleanRegex:()=>Rs,clone:()=>Me,cloneDef:()=>iz,createTransparentProxy:()=>pz,defineLazy:()=>te,esc:()=>lc,escapeRegex:()=>it,explicitlyAborted:()=>Yu,extend:()=>fz,finalizeIssue:()=>Ae,floatSafeRemainder:()=>Fu,getElementAtPath:()=>az,getEnumValues:()=>vs,getLengthableOrigin:()=>Ps,getParsedType:()=>dz,getSizableOrigin:()=>xs,hexToUint8Array:()=>Rz,isObject:()=>Uo,isPlainObject:()=>po,issue:()=>kr,joinValues:()=>cc,jsonStringifyReplacer:()=>Tr,merge:()=>Sz,mergeDefs:()=>Zt,normalizeParams:()=>P,nullish:()=>lo,numKeys:()=>uz,objectClone:()=>sz,omit:()=>mz,optionalKeys:()=>Wu,parsedType:()=>Xu,partial:()=>_z,pick:()=>hz,prefixIssues:()=>Fe,primitiveTypes:()=>Bu,promiseAllObject:()=>cz,propertyKeyTypes:()=>ws,randomString:()=>lz,required:()=>bz,safeExtend:()=>gz,shallowClone:()=>Ju,slugify:()=>Hu,stringifyPrimitive:()=>dc,uint8ArrayToBase64:()=>Wg,uint8ArrayToBase64url:()=>vz,uint8ArrayToHex:()=>wz,unwrapMessage:()=>zs});function ez(e){return e}function tz(e){return e}function oz(e){}function rz(e){throw new Error("Unexpected value in exhaustive check")}function nz(e){}function vs(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 cc(e,t="|"){return e.map(o=>dc(o)).join(t)}function Tr(e,t){return typeof t=="bigint"?t.toString():t}function Er(e){return{get value(){{let o=e();return Object.defineProperty(this,"value",{value:o}),o}throw new Error("cached value already set")}}}function lo(e){return e==null}function Rs(e){let t=e.startsWith("^")?1:0,o=e.endsWith("$")?e.length-1:e.length;return e.slice(t,o)}function Fu(e,t){let o=e/t,r=Math.round(o),n=Number.EPSILON*Math.max(Math.abs(o),1);return Math.abs(o-r)<n?0:o-r}var Jg=Symbol("evaluating");function te(e,t,o){let r;Object.defineProperty(e,t,{get(){if(r!==Jg)return r===void 0&&(r=Jg,r=o()),r},set(n){Object.defineProperty(e,t,{value:n})},configurable:!0})}function sz(e){return Object.create(Object.getPrototypeOf(e),Object.getOwnPropertyDescriptors(e))}function uo(e,t,o){Object.defineProperty(e,t,{value:o,writable:!0,enumerable:!0,configurable:!0})}function Zt(...e){let t={};for(let o of e){let r=Object.getOwnPropertyDescriptors(o);Object.assign(t,r)}return Object.defineProperties({},t)}function iz(e){return Zt(e._zod.def)}function az(e,t){return t?t.reduce((o,r)=>o?.[r],e):e}function cz(e){let t=Object.keys(e),o=t.map(r=>e[r]);return Promise.all(o).then(r=>{let n={};for(let s=0;s<t.length;s++)n[t[s]]=r[s];return n})}function lz(e=10){let t="abcdefghijklmnopqrstuvwxyz",o="";for(let r=0;r<e;r++)o+=t[Math.floor(Math.random()*t.length)];return o}function lc(e){return JSON.stringify(e)}function Hu(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}var uc="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function Uo(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}var Vu=Er(()=>{if(Lo.jitless||typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{let e=Function;return new e(""),!0}catch{return!1}});function po(e){if(Uo(e)===!1)return!1;let t=e.constructor;if(t===void 0||typeof t!="function")return!0;let o=t.prototype;return!(Uo(o)===!1||Object.prototype.hasOwnProperty.call(o,"isPrototypeOf")===!1)}function Ju(e){return po(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}function uz(e){let t=0;for(let o in e)Object.prototype.hasOwnProperty.call(e,o)&&t++;return t}var dz=e=>{let t=typeof e;switch(t){case"undefined":return"undefined";case"string":return"string";case"number":return Number.isNaN(e)?"nan":"number";case"boolean":return"boolean";case"function":return"function";case"bigint":return"bigint";case"symbol":return"symbol";case"object":return Array.isArray(e)?"array":e===null?"null":e.then&&typeof e.then=="function"&&e.catch&&typeof e.catch=="function"?"promise":typeof Map<"u"&&e instanceof Map?"map":typeof Set<"u"&&e instanceof Set?"set":typeof Date<"u"&&e instanceof Date?"date":typeof File<"u"&&e instanceof File?"file":"object";default:throw new Error(`Unknown data type: ${t}`)}},ws=new Set(["string","number","symbol"]),Bu=new Set(["string","number","bigint","boolean","symbol","undefined"]);function it(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Me(e,t,o){let r=new e._zod.constr(t??e._zod.def);return(!t||o?.parent)&&(r._zod.parent=e),r}function P(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 new Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error=="string"?{...t,error:()=>t.error}:t}function pz(e){let t;return new Proxy({},{get(o,r,n){return t??(t=e()),Reflect.get(t,r,n)},set(o,r,n,s){return t??(t=e()),Reflect.set(t,r,n,s)},has(o,r){return t??(t=e()),Reflect.has(t,r)},deleteProperty(o,r){return t??(t=e()),Reflect.deleteProperty(t,r)},ownKeys(o){return t??(t=e()),Reflect.ownKeys(t)},getOwnPropertyDescriptor(o,r){return t??(t=e()),Reflect.getOwnPropertyDescriptor(t,r)},defineProperty(o,r,n){return t??(t=e()),Reflect.defineProperty(t,r,n)}})}function dc(e){return typeof e=="bigint"?e.toString()+"n":typeof e=="string"?`"${e}"`:`${e}`}function Wu(e){return Object.keys(e).filter(t=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}var Ku={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]},Gu={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};function hz(e,t){let o=e._zod.def,r=o.checks;if(r&&r.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");let s=Zt(e._zod.def,{get shape(){let i={};for(let a in t){if(!(a in o.shape))throw new Error(`Unrecognized key: "${a}"`);t[a]&&(i[a]=o.shape[a])}return uo(this,"shape",i),i},checks:[]});return Me(e,s)}function mz(e,t){let o=e._zod.def,r=o.checks;if(r&&r.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");let s=Zt(e._zod.def,{get shape(){let i={...e._zod.def.shape};for(let a in t){if(!(a in o.shape))throw new Error(`Unrecognized key: "${a}"`);t[a]&&delete i[a]}return uo(this,"shape",i),i},checks:[]});return Me(e,s)}function fz(e,t){if(!po(t))throw new 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 new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}let n=Zt(e._zod.def,{get shape(){let s={...e._zod.def.shape,...t};return uo(this,"shape",s),s}});return Me(e,n)}function gz(e,t){if(!po(t))throw new Error("Invalid input to safeExtend: expected a plain object");let o=Zt(e._zod.def,{get shape(){let r={...e._zod.def.shape,...t};return uo(this,"shape",r),r}});return Me(e,o)}function Sz(e,t){if(e._zod.def.checks?.length)throw new Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");let o=Zt(e._zod.def,{get shape(){let r={...e._zod.def.shape,...t._zod.def.shape};return uo(this,"shape",r),r},get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]});return Me(e,o)}function _z(e,t,o){let n=t._zod.def.checks;if(n&&n.length>0)throw new Error(".partial() cannot be used on object schemas containing refinements");let i=Zt(t._zod.def,{get shape(){let a=t._zod.def.shape,l={...a};if(o)for(let u in o){if(!(u in a))throw new Error(`Unrecognized key: "${u}"`);o[u]&&(l[u]=e?new e({type:"optional",innerType:a[u]}):a[u])}else for(let u in a)l[u]=e?new e({type:"optional",innerType:a[u]}):a[u];return uo(this,"shape",l),l},checks:[]});return Me(t,i)}function bz(e,t,o){let r=Zt(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 new Error(`Unrecognized key: "${i}"`);o[i]&&(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 uo(this,"shape",s),s}});return Me(t,r)}function ho(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 Yu(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 Fe(e,t){return t.map(o=>{var r;return(r=o).path??(r.path=[]),o.path.unshift(e),o})}function zs(e){return typeof e=="string"?e:e?.message}function Ae(e,t,o){let r=e.message?e.message:zs(e.inst?._zod.def?.error?.(e))??zs(t?.error?.(e))??zs(o.customError?.(e))??zs(o.localeError?.(e))??"Invalid input",{inst:n,continue:s,input:i,...a}=e;return a.path??(a.path=[]),a.message=r,t?.reportInput&&(a.input=i),a}function xs(e){return e instanceof Set?"set":e instanceof Map?"map":e instanceof File?"file":"unknown"}function Ps(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function Xu(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 kr(...e){let[t,o,r]=e;return typeof t=="string"?{message:t,code:"custom",input:o,inst:r}:{...t}}function yz(e){return Object.entries(e).filter(([t,o])=>Number.isNaN(Number.parseInt(t,10))).map(t=>t[1])}function Bg(e){let t=atob(e),o=new Uint8Array(t.length);for(let r=0;r<t.length;r++)o[r]=t.charCodeAt(r);return o}function Wg(e){let t="";for(let o=0;o<e.length;o++)t+=String.fromCharCode(e[o]);return btoa(t)}function zz(e){let t=e.replace(/-/g,"+").replace(/_/g,"/"),o="=".repeat((4-t.length%4)%4);return Bg(t+o)}function vz(e){return Wg(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function Rz(e){let t=e.replace(/^0x/,"");if(t.length%2!==0)throw new Error("Invalid hex string length");let o=new Uint8Array(t.length/2);for(let r=0;r<t.length;r+=2)o[r/2]=Number.parseInt(t.slice(r,r+2),16);return o}function wz(e){return Array.from(e).map(t=>t.toString(16).padStart(2,"0")).join("")}var Du=class{constructor(...t){}};var Kg=(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,Tr,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},Ts=g("$ZodError",Kg),He=g("$ZodError",Kg,{Parent:Error});function Es(e,t=o=>o.message){let o={},r=[];for(let n of e.issues)n.path.length>0?(o[n.path[0]]=o[n.path[0]]||[],o[n.path[0]].push(t(n))):r.push(t(n));return{formErrors:r,fieldErrors:o}}function ks(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(a=>r({issues:a},[...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 a=[...s,...i.path];if(a.length===0)o._errors.push(t(i));else{let l=o,u=0;for(;u<a.length;){let d=a[u];u===a.length-1?(l[d]=l[d]||{_errors:[]},l[d]._errors.push(t(i))):l[d]=l[d]||{_errors:[]},l=l[d],u++}}}};return r(e),o}function Qu(e,t=o=>o.message){let o={errors:[]},r=(n,s=[])=>{var i,a;for(let l of n.issues)if(l.code==="invalid_union"&&l.errors.length)l.errors.map(u=>r({issues:u},[...s,...l.path]));else if(l.code==="invalid_key")r({issues:l.issues},[...s,...l.path]);else if(l.code==="invalid_element")r({issues:l.issues},[...s,...l.path]);else{let u=[...s,...l.path];if(u.length===0){o.errors.push(t(l));continue}let d=o,h=0;for(;h<u.length;){let f=u[h],S=h===u.length-1;typeof f=="string"?(d.properties??(d.properties={}),(i=d.properties)[f]??(i[f]={errors:[]}),d=d.properties[f]):(d.items??(d.items=[]),(a=d.items)[f]??(a[f]={errors:[]}),d=d.items[f]),S&&d.errors.push(t(l)),h++}}};return r(e),o}function Gg(e){let t=[],o=e.map(r=>typeof r=="object"?r.key:r);for(let r of o)typeof r=="number"?t.push(`[${r}]`):typeof r=="symbol"?t.push(`[${JSON.stringify(String(r))}]`):/[^\w$]/.test(r)?t.push(`[${JSON.stringify(r)}]`):(t.length&&t.push("."),t.push(r));return t.join("")}function ed(e){let t=[],o=[...e.issues].sort((r,n)=>(r.path??[]).length-(n.path??[]).length);for(let r of o)t.push(`\u2716 ${r.message}`),r.path?.length&&t.push(` \u2192 at ${Gg(r.path)}`);return t.join(`
2
- `)}var $r=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 ut;if(i.issues.length){let a=new(n?.Err??e)(i.issues.map(l=>Ae(l,s,ge())));throw uc(a,n?.callee),a}return i.value},pc=$r(He),Cr=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),i.issues.length){let a=new(n?.Err??e)(i.issues.map(l=>Ae(l,s,ge())));throw uc(a,n?.callee),a}return i.value},hc=Cr(He),Ir=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 ut;return s.issues.length?{success:!1,error:new(e??Ts)(s.issues.map(i=>Ae(i,n,ge())))}:{success:!0,data:s.value}},td=Ir(He),Or=e=>async(t,o,r)=>{let n=r?{...r,async:!0}:{async:!0},s=t._zod.run({value:o,issues:[]},n);return s instanceof Promise&&(s=await s),s.issues.length?{success:!1,error:new e(s.issues.map(i=>Ae(i,n,ge())))}:{success:!0,data:s.value}},od=Or(He),mc=e=>(t,o,r)=>{let n=r?{...r,direction:"backward"}:{direction:"backward"};return $r(e)(t,o,n)},Pz=mc(He),fc=e=>(t,o,r)=>$r(e)(t,o,r),Tz=fc(He),gc=e=>async(t,o,r)=>{let n=r?{...r,direction:"backward"}:{direction:"backward"};return Cr(e)(t,o,n)},Ez=gc(He),Sc=e=>async(t,o,r)=>Cr(e)(t,o,r),kz=Sc(He),_c=e=>(t,o,r)=>{let n=r?{...r,direction:"backward"}:{direction:"backward"};return Ir(e)(t,o,n)},$z=_c(He),bc=e=>(t,o,r)=>Ir(e)(t,o,r),Cz=bc(He),yc=e=>async(t,o,r)=>{let n=r?{...r,direction:"backward"}:{direction:"backward"};return Or(e)(t,o,n)},Iz=yc(He),zc=e=>async(t,o,r)=>Or(e)(t,o,r),Oz=zc(He);var Ye={};Ut(Ye,{base64:()=>_d,base64url:()=>vc,bigint:()=>xd,boolean:()=>Td,browserEmail:()=>Zz,cidrv4:()=>gd,cidrv6:()=>Sd,cuid:()=>rd,cuid2:()=>nd,date:()=>zd,datetime:()=>Rd,domain:()=>Hz,duration:()=>ld,e164:()=>yd,email:()=>dd,emoji:()=>pd,extendedDuration:()=>Nz,guid:()=>ud,hex:()=>Vz,hostname:()=>Fz,html5Email:()=>jz,httpProtocol:()=>bd,idnEmail:()=>Uz,integer:()=>Pd,ipv4:()=>hd,ipv6:()=>md,ksuid:()=>ad,lowercase:()=>$d,mac:()=>fd,md5_base64:()=>Bz,md5_base64url:()=>Wz,md5_hex:()=>Jz,nanoid:()=>cd,null:()=>Ed,number:()=>Rc,rfc5322Email:()=>Lz,sha1_base64:()=>Gz,sha1_base64url:()=>Yz,sha1_hex:()=>Kz,sha256_base64:()=>Qz,sha256_base64url:()=>ev,sha256_hex:()=>Xz,sha384_base64:()=>ov,sha384_base64url:()=>rv,sha384_hex:()=>tv,sha512_base64:()=>sv,sha512_base64url:()=>iv,sha512_hex:()=>nv,string:()=>wd,time:()=>vd,ulid:()=>sd,undefined:()=>kd,unicodeEmail:()=>Yg,uppercase:()=>Cd,uuid:()=>Zo,uuid4:()=>qz,uuid6:()=>Mz,uuid7:()=>Az,xid:()=>id});var rd=/^[cC][0-9a-z]{6,}$/,nd=/^[0-9a-z]+$/,sd=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,id=/^[0-9a-vA-V]{20}$/,ad=/^[A-Za-z0-9]{27}$/,cd=/^[a-zA-Z0-9_-]{21}$/,ld=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,Nz=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,ud=/^([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})$/,Zo=e=>e?new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,qz=Zo(4),Mz=Zo(6),Az=Zo(7),dd=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,jz=/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/,Lz=/^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/,Yg=/^[^\s@"]{1,64}@[^\s@]{1,255}$/u,Uz=Yg,Zz=/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/,Dz="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function pd(){return new RegExp(Dz,"u")}var hd=/^(?:(?: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])$/,md=/^(([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}|:))$/,fd=e=>{let t=it(e??":");return new RegExp(`^(?:[0-9A-F]{2}${t}){5}[0-9A-F]{2}$|^(?:[0-9a-f]{2}${t}){5}[0-9a-f]{2}$`)},gd=/^((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])$/,Sd=/^(([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])$/,_d=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,vc=/^[A-Za-z0-9_-]*$/,Fz=/^(?=.{1,253}\.?$)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[-0-9a-zA-Z]{0,61}[0-9a-zA-Z])?)*\.?$/,Hz=/^([a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,}$/,bd=/^https?$/,yd=/^\+[1-9]\d{6,14}$/,Xg="(?:(?:\\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])))",zd=new RegExp(`^${Xg}$`);function Qg(e){let t="(?:[01]\\d|2[0-3]):[0-5]\\d";return typeof e.precision=="number"?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function vd(e){return new RegExp(`^${Qg(e)}$`)}function Rd(e){let t=Qg({precision:e.precision}),o=["Z"];e.local&&o.push(""),e.offset&&o.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");let r=`${t}(?:${o.join("|")})`;return new RegExp(`^${Xg}T(?:${r})$`)}var wd=e=>{let t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)},xd=/^-?\d+n?$/,Pd=/^-?\d+$/,Rc=/^-?\d+(?:\.\d+)?$/,Td=/^(?:true|false)$/i,Ed=/^null$/i;var kd=/^undefined$/i;var $d=/^[^A-Z]*$/,Cd=/^[^a-z]*$/,Vz=/^[0-9a-fA-F]*$/;function $s(e,t){return new RegExp(`^[A-Za-z0-9+/]{${e}}${t}$`)}function Cs(e){return new RegExp(`^[A-Za-z0-9_-]{${e}}$`)}var Jz=/^[0-9a-fA-F]{32}$/,Bz=$s(22,"=="),Wz=Cs(22),Kz=/^[0-9a-fA-F]{40}$/,Gz=$s(27,"="),Yz=Cs(27),Xz=/^[0-9a-fA-F]{64}$/,Qz=$s(43,"="),ev=Cs(43),tv=/^[0-9a-fA-F]{96}$/,ov=$s(64,""),rv=Cs(64),nv=/^[0-9a-fA-F]{128}$/,sv=$s(86,"=="),iv=Cs(86);var le=g("$ZodCheck",(e,t)=>{var o;e._zod??(e._zod={}),e._zod.def=t,(o=e._zod).onattach??(o.onattach=[])}),tS={number:"number",bigint:"bigint",object:"date"},wc=g("$ZodCheckLessThan",(e,t)=>{le.init(e,t);let o=tS[typeof t.value];e._zod.onattach.push(r=>{let n=r._zod.bag,s=(t.inclusive?n.maximum:n.exclusiveMaximum)??Number.POSITIVE_INFINITY;t.value<s&&(t.inclusive?n.maximum=t.value:n.exclusiveMaximum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value<=t.value:r.value<t.value)||r.issues.push({origin: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})}}),xc=g("$ZodCheckGreaterThan",(e,t)=>{le.init(e,t);let o=tS[typeof t.value];e._zod.onattach.push(r=>{let n=r._zod.bag,s=(t.inclusive?n.minimum:n.exclusiveMinimum)??Number.NEGATIVE_INFINITY;t.value>s&&(t.inclusive?n.minimum=t.value:n.exclusiveMinimum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value>=t.value:r.value>t.value)||r.issues.push({origin: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})}}),Id=g("$ZodCheckMultipleOf",(e,t)=>{le.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 new Error("Cannot mix number and bigint in multiple_of check.");(typeof o.value=="bigint"?o.value%t.value===BigInt(0):Fu(o.value,t.value)===0)||o.issues.push({origin:typeof o.value,code:"not_multiple_of",divisor:t.value,input:o.value,inst:e,continue:!t.abort})}}),Od=g("$ZodCheckNumberFormat",(e,t)=>{le.init(e,t),t.format=t.format||"float64";let o=t.format?.includes("int"),r=o?"int":"number",[n,s]=Ku[t.format];e._zod.onattach.push(i=>{let a=i._zod.bag;a.format=t.format,a.minimum=n,a.maximum=s,o&&(a.pattern=Pd)}),e._zod.check=i=>{let a=i.value;if(o){if(!Number.isInteger(a)){i.issues.push({expected:r,format:t.format,code:"invalid_type",continue:!1,input:a,inst:e});return}if(!Number.isSafeInteger(a)){a>0?i.issues.push({input:a,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}):i.issues.push({input:a,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}}a<n&&i.issues.push({origin:"number",input:a,code:"too_small",minimum:n,inclusive:!0,inst:e,continue:!t.abort}),a>s&&i.issues.push({origin:"number",input:a,code:"too_big",maximum:s,inclusive:!0,inst:e,continue:!t.abort})}}),Nd=g("$ZodCheckBigIntFormat",(e,t)=>{le.init(e,t);let[o,r]=Gu[t.format];e._zod.onattach.push(n=>{let s=n._zod.bag;s.format=t.format,s.minimum=o,s.maximum=r}),e._zod.check=n=>{let s=n.value;s<o&&n.issues.push({origin:"bigint",input:s,code:"too_small",minimum:o,inclusive:!0,inst:e,continue:!t.abort}),s>r&&n.issues.push({origin:"bigint",input:s,code:"too_big",maximum:r,inclusive:!0,inst:e,continue:!t.abort})}}),qd=g("$ZodCheckMaxSize",(e,t)=>{var o;le.init(e,t),(o=e._zod.def).when??(o.when=r=>{let n=r.value;return!lo(n)&&n.size!==void 0}),e._zod.onattach.push(r=>{let n=r._zod.bag.maximum??Number.POSITIVE_INFINITY;t.maximum<n&&(r._zod.bag.maximum=t.maximum)}),e._zod.check=r=>{let n=r.value;n.size<=t.maximum||r.issues.push({origin:xs(n),code:"too_big",maximum:t.maximum,inclusive:!0,input:n,inst:e,continue:!t.abort})}}),Md=g("$ZodCheckMinSize",(e,t)=>{var o;le.init(e,t),(o=e._zod.def).when??(o.when=r=>{let n=r.value;return!lo(n)&&n.size!==void 0}),e._zod.onattach.push(r=>{let n=r._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>n&&(r._zod.bag.minimum=t.minimum)}),e._zod.check=r=>{let n=r.value;n.size>=t.minimum||r.issues.push({origin:xs(n),code:"too_small",minimum:t.minimum,inclusive:!0,input:n,inst:e,continue:!t.abort})}}),Ad=g("$ZodCheckSizeEquals",(e,t)=>{var o;le.init(e,t),(o=e._zod.def).when??(o.when=r=>{let n=r.value;return!lo(n)&&n.size!==void 0}),e._zod.onattach.push(r=>{let n=r._zod.bag;n.minimum=t.size,n.maximum=t.size,n.size=t.size}),e._zod.check=r=>{let n=r.value,s=n.size;if(s===t.size)return;let i=s>t.size;r.issues.push({origin:xs(n),...i?{code:"too_big",maximum:t.size}:{code:"too_small",minimum:t.size},inclusive:!0,exact:!0,input:r.value,inst:e,continue:!t.abort})}}),jd=g("$ZodCheckMaxLength",(e,t)=>{var o;le.init(e,t),(o=e._zod.def).when??(o.when=r=>{let n=r.value;return!lo(n)&&n.length!==void 0}),e._zod.onattach.push(r=>{let n=r._zod.bag.maximum??Number.POSITIVE_INFINITY;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=Ps(n);r.issues.push({origin:i,code:"too_big",maximum:t.maximum,inclusive:!0,input:n,inst:e,continue:!t.abort})}}),Ld=g("$ZodCheckMinLength",(e,t)=>{var o;le.init(e,t),(o=e._zod.def).when??(o.when=r=>{let n=r.value;return!lo(n)&&n.length!==void 0}),e._zod.onattach.push(r=>{let n=r._zod.bag.minimum??Number.NEGATIVE_INFINITY;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=Ps(n);r.issues.push({origin:i,code:"too_small",minimum:t.minimum,inclusive:!0,input:n,inst:e,continue:!t.abort})}}),Ud=g("$ZodCheckLengthEquals",(e,t)=>{var o;le.init(e,t),(o=e._zod.def).when??(o.when=r=>{let n=r.value;return!lo(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=Ps(n),a=s>t.length;r.issues.push({origin:i,...a?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:r.value,inst:e,continue:!t.abort})}}),Nr=g("$ZodCheckStringFormat",(e,t)=>{var o,r;le.init(e,t),e._zod.onattach.push(n=>{let s=n._zod.bag;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=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:"string",code:"invalid_format",format:t.format,input:n.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(r=e._zod).check??(r.check=()=>{})}),Zd=g("$ZodCheckRegex",(e,t)=>{Nr.init(e,t),e._zod.check=o=>{t.pattern.lastIndex=0,!t.pattern.test(o.value)&&o.issues.push({origin:"string",code:"invalid_format",format:"regex",input:o.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),Dd=g("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=$d),Nr.init(e,t)}),Fd=g("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=Cd),Nr.init(e,t)}),Hd=g("$ZodCheckIncludes",(e,t)=>{le.init(e,t);let o=it(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=>{n.value.includes(t.includes,t.position)||n.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:n.value,inst:e,continue:!t.abort})}}),Vd=g("$ZodCheckStartsWith",(e,t)=>{le.init(e,t);let o=new RegExp(`^${it(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=>{r.value.startsWith(t.prefix)||r.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:r.value,inst:e,continue:!t.abort})}}),Jd=g("$ZodCheckEndsWith",(e,t)=>{le.init(e,t);let o=new RegExp(`.*${it(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=>{r.value.endsWith(t.suffix)||r.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:r.value,inst:e,continue:!t.abort})}});function eS(e,t,o){e.issues.length&&t.issues.push(...Fe(o,e.issues))}var Bd=g("$ZodCheckProperty",(e,t)=>{le.init(e,t),e._zod.check=o=>{let r=t.schema._zod.run({value:o.value[t.property],issues:[]},{});if(r instanceof Promise)return r.then(n=>eS(n,o,t.property));eS(r,o,t.property)}}),Wd=g("$ZodCheckMimeType",(e,t)=>{le.init(e,t);let o=new Set(t.mime);e._zod.onattach.push(r=>{r._zod.bag.mime=t.mime}),e._zod.check=r=>{o.has(r.value.type)||r.issues.push({code:"invalid_value",values:t.mime,input:r.value.type,inst:e,continue:!t.abort})}}),Kd=g("$ZodCheckOverwrite",(e,t)=>{le.init(e,t),e._zod.check=o=>{o.value=t.tx(o.value)}});var Is=class{constructor(t=[]){this.content=[],this.indent=0,this&&(this.args=t)}indented(t){this.indent+=1,t(this),this.indent-=1}write(t){if(typeof t=="function"){t(this,{execution:"sync"}),t(this,{execution:"async"});return}let r=t.split(`
1
+ var Hy=Object.defineProperty;var Ut=(e,t)=>{for(var o in t)Hy(e,o,{get:t[o],enumerable:!0})};var Vy=Object.create,cc=Object.defineProperty,Jy=Object.getOwnPropertyDescriptor,By=Object.getOwnPropertyNames,Wy=Object.getPrototypeOf,Ky=Object.prototype.hasOwnProperty,Ug=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),Zg=(e,t)=>{let o={};for(var r in e)cc(o,r,{get:e[r],enumerable:!0});return t&&cc(o,Symbol.toStringTag,{value:"Module"}),o},Gy=(e,t,o,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(var n=By(t),s=0,i=n.length,a;s<i;s++)a=n[s],!Ky.call(e,a)&&a!==o&&cc(e,a,{get:(l=>t[l]).bind(null,a),enumerable:!(r=Jy(t,a))||r.enumerable});return e},Dg=(e,t,o)=>(o=e!=null?Vy(Wy(e)):{},Gy(t||!e||!e.__esModule?cc(o,"default",{value:e,enumerable:!0}):o,e));var Yy=new Set(["https://json-schema.org/draft/2020-12/schema","http://json-schema.org/draft/2020-12/schema"]),Fg=new Set(["https://json-schema.org/draft/2019-09/schema","http://json-schema.org/draft/2019-09/schema"]),Xy=new Set(["https://json-schema.org/draft-07/schema","http://json-schema.org/draft-07/schema"]),Qy=new Set(["https://json-schema.org/draft-06/schema","http://json-schema.org/draft-06/schema"]);function Hg(e){return typeof e=="string"&&Fg.has(e.replace(/#$/,""))}function Vg(e,t){if(!("$schema"in e)||typeof e.$schema!="string")return"2020-12";let o=e.$schema.replace(/#$/,"");if(Yy.has(o))return"2020-12";if(Fg.has(o))return"2019-09";if(Xy.has(o)||Qy.has(o))return"draft-7";throw new 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 p={};Ut(p,{$brand:()=>Zu,$input:()=>lh,$output:()=>ch,NEVER:()=>ys,TimePrecision:()=>hh,ZodAny:()=>Xm,ZodArray:()=>of,ZodBase64:()=>ql,ZodBase64URL:()=>Ml,ZodBigInt:()=>rn,ZodBigIntFormat:()=>Ll,ZodBoolean:()=>on,ZodCIDRv4:()=>Ol,ZodCIDRv6:()=>Nl,ZodCUID:()=>Pl,ZodCUID2:()=>Tl,ZodCatch:()=>Rf,ZodCodec:()=>Ks,ZodCustom:()=>Gs,ZodCustomStringFormat:()=>en,ZodDate:()=>Vs,ZodDefault:()=>Sf,ZodDiscriminatedUnion:()=>nf,ZodE164:()=>Al,ZodEmail:()=>vl,ZodEmoji:()=>wl,ZodEnum:()=>Yr,ZodError:()=>qv,ZodExactOptional:()=>mf,ZodFile:()=>pf,ZodFirstPartyTypeKind:()=>qf,ZodFunction:()=>If,ZodGUID:()=>Zs,ZodIPv4:()=>Cl,ZodIPv6:()=>Il,ZodISODate:()=>gl,ZodISODateTime:()=>fl,ZodISODuration:()=>_l,ZodISOTime:()=>Sl,ZodIntersection:()=>sf,ZodIssueCode:()=>Mf,ZodJWT:()=>jl,ZodKSUID:()=>$l,ZodLazy:()=>$f,ZodLiteral:()=>df,ZodMAC:()=>Wm,ZodMap:()=>lf,ZodNaN:()=>xf,ZodNanoID:()=>xl,ZodNever:()=>ef,ZodNonOptional:()=>Hl,ZodNull:()=>Ym,ZodNullable:()=>gf,ZodNumber:()=>tn,ZodNumberFormat:()=>Bo,ZodObject:()=>Js,ZodOptional:()=>Fl,ZodPipe:()=>Ws,ZodPrefault:()=>bf,ZodPreprocess:()=>Pf,ZodPromise:()=>Cf,ZodReadonly:()=>Tf,ZodRealError:()=>Ve,ZodRecord:()=>Gr,ZodSet:()=>uf,ZodString:()=>Xr,ZodStringFormat:()=>ce,ZodSuccess:()=>vf,ZodSymbol:()=>Km,ZodTemplateLiteral:()=>kf,ZodTransform:()=>hf,ZodTuple:()=>af,ZodType:()=>Q,ZodULID:()=>El,ZodURL:()=>Hs,ZodUUID:()=>kt,ZodUndefined:()=>Gm,ZodUnion:()=>Bs,ZodUnknown:()=>Qm,ZodVoid:()=>tf,ZodXID:()=>kl,ZodXor:()=>rf,_ZodString:()=>zl,_default:()=>_f,_function:()=>T_,any:()=>Ul,array:()=>_,base64:()=>JS,base64url:()=>BS,bigint:()=>n_,boolean:()=>k,catch:()=>wf,check:()=>E_,cidrv4:()=>HS,cidrv6:()=>VS,clone:()=>Me,codec:()=>R_,coerce:()=>Ys,config:()=>ge,core:()=>Ft,cuid:()=>MS,cuid2:()=>AS,custom:()=>k_,date:()=>u_,decode:()=>Zm,decodeAsync:()=>Fm,describe:()=>$_,discriminatedUnion:()=>bo,e164:()=>WS,email:()=>Rl,emoji:()=>NS,encode:()=>Um,encodeAsync:()=>Dm,endsWith:()=>Zr,enum:()=>K,exactOptional:()=>ff,file:()=>b_,flattenError:()=>Es,float32:()=>e_,float64:()=>t_,formatError:()=>ks,fromJSONSchema:()=>M_,function:()=>T_,getErrorMap:()=>jv,globalRegistry:()=>ve,gt:()=>Tt,gte:()=>je,guid:()=>ES,hash:()=>QS,hex:()=>XS,hostname:()=>YS,httpUrl:()=>OS,includes:()=>Lr,instanceof:()=>I_,int:()=>bl,int32:()=>o_,int64:()=>s_,intersection:()=>pt,invertCodec:()=>w_,ipv4:()=>ZS,ipv6:()=>FS,iso:()=>Qe,json:()=>N_,jwt:()=>KS,keyof:()=>d_,ksuid:()=>US,lazy:()=>yo,length:()=>Vo,literal:()=>b,locales:()=>Ms,looseObject:()=>U,looseRecord:()=>f_,lowercase:()=>Ar,lt:()=>Pt,lte:()=>Xe,mac:()=>DS,map:()=>g_,maxLength:()=>Ho,maxSize:()=>fo,meta:()=>C_,mime:()=>Dr,minLength:()=>Dt,minSize:()=>Et,multipleOf:()=>mo,nan:()=>v_,nanoid:()=>qS,nativeEnum:()=>__,negative:()=>il,never:()=>Zl,nonnegative:()=>cl,nonoptional:()=>zf,nonpositive:()=>al,normalize:()=>Fr,null:()=>$t,nullable:()=>Ds,nullish:()=>y_,number:()=>R,object:()=>m,optional:()=>L,overwrite:()=>dt,parse:()=>Am,parseAsync:()=>jm,partialRecord:()=>m_,pipe:()=>yl,positive:()=>sl,prefault:()=>yf,preprocess:()=>Ht,prettifyError:()=>td,promise:()=>P_,property:()=>ll,readonly:()=>Ef,record:()=>T,refine:()=>Of,regex:()=>Mr,regexes:()=>Ye,registry:()=>jc,safeDecode:()=>Vm,safeDecodeAsync:()=>Bm,safeEncode:()=>Hm,safeEncodeAsync:()=>Jm,safeParse:()=>Us,safeParseAsync:()=>Lm,set:()=>S_,setErrorMap:()=>Av,size:()=>Fo,slugify:()=>Br,startsWith:()=>Ur,strictObject:()=>p_,string:()=>c,stringFormat:()=>GS,stringbool:()=>O_,success:()=>z_,superRefine:()=>Nf,symbol:()=>a_,templateLiteral:()=>x_,toJSONSchema:()=>Jo,toLowerCase:()=>Vr,toUpperCase:()=>Jr,transform:()=>Dl,treeifyError:()=>ed,trim:()=>Hr,tuple:()=>cf,uint32:()=>r_,uint64:()=>i_,ulid:()=>jS,undefined:()=>c_,union:()=>C,unknown:()=>j,uppercase:()=>jr,url:()=>Qr,util:()=>G,uuid:()=>kS,uuidv4:()=>$S,uuidv6:()=>CS,uuidv7:()=>IS,void:()=>l_,xid:()=>LS,xor:()=>h_});var Ft={};Ut(Ft,{$ZodAny:()=>$p,$ZodArray:()=>qp,$ZodAsyncError:()=>ut,$ZodBase64:()=>yp,$ZodBase64URL:()=>zp,$ZodBigInt:()=>Ic,$ZodBigIntFormat:()=>Pp,$ZodBoolean:()=>Os,$ZodCIDRv4:()=>Sp,$ZodCIDRv6:()=>_p,$ZodCUID:()=>sp,$ZodCUID2:()=>ip,$ZodCatch:()=>Qp,$ZodCheck:()=>le,$ZodCheckBigIntFormat:()=>qd,$ZodCheckEndsWith:()=>Bd,$ZodCheckGreaterThan:()=>Pc,$ZodCheckIncludes:()=>Vd,$ZodCheckLengthEquals:()=>Zd,$ZodCheckLessThan:()=>xc,$ZodCheckLowerCase:()=>Fd,$ZodCheckMaxLength:()=>Ld,$ZodCheckMaxSize:()=>Md,$ZodCheckMimeType:()=>Kd,$ZodCheckMinLength:()=>Ud,$ZodCheckMinSize:()=>Ad,$ZodCheckMultipleOf:()=>Od,$ZodCheckNumberFormat:()=>Nd,$ZodCheckOverwrite:()=>Gd,$ZodCheckProperty:()=>Wd,$ZodCheckRegex:()=>Dd,$ZodCheckSizeEquals:()=>jd,$ZodCheckStartsWith:()=>Jd,$ZodCheckStringFormat:()=>qr,$ZodCheckUpperCase:()=>Hd,$ZodCodec:()=>qs,$ZodCustom:()=>ah,$ZodCustomStringFormat:()=>wp,$ZodDate:()=>Np,$ZodDefault:()=>Kp,$ZodDiscriminatedUnion:()=>jp,$ZodE164:()=>vp,$ZodEmail:()=>tp,$ZodEmoji:()=>rp,$ZodEncodeError:()=>co,$ZodEnum:()=>Fp,$ZodError:()=>Ts,$ZodExactOptional:()=>Bp,$ZodFile:()=>Vp,$ZodFunction:()=>nh,$ZodGUID:()=>Qd,$ZodIPv4:()=>mp,$ZodIPv6:()=>fp,$ZodISODate:()=>dp,$ZodISODateTime:()=>up,$ZodISODuration:()=>hp,$ZodISOTime:()=>pp,$ZodIntersection:()=>Lp,$ZodJWT:()=>Rp,$ZodKSUID:()=>lp,$ZodLazy:()=>ih,$ZodLiteral:()=>Hp,$ZodMAC:()=>gp,$ZodMap:()=>Zp,$ZodNaN:()=>eh,$ZodNanoID:()=>np,$ZodNever:()=>Ip,$ZodNonOptional:()=>Yp,$ZodNull:()=>kp,$ZodNullable:()=>Wp,$ZodNumber:()=>Cc,$ZodNumberFormat:()=>xp,$ZodObject:()=>vS,$ZodObjectJIT:()=>Mp,$ZodOptional:()=>Nc,$ZodPipe:()=>qc,$ZodPrefault:()=>Gp,$ZodPreprocess:()=>th,$ZodPromise:()=>sh,$ZodReadonly:()=>oh,$ZodRealError:()=>He,$ZodRecord:()=>Up,$ZodRegistry:()=>Ac,$ZodSet:()=>Dp,$ZodString:()=>Do,$ZodStringFormat:()=>ae,$ZodSuccess:()=>Xp,$ZodSymbol:()=>Tp,$ZodTemplateLiteral:()=>rh,$ZodTransform:()=>Jp,$ZodTuple:()=>Oc,$ZodType:()=>Y,$ZodULID:()=>ap,$ZodURL:()=>op,$ZodUUID:()=>ep,$ZodUndefined:()=>Ep,$ZodUnion:()=>Ns,$ZodUnknown:()=>Cp,$ZodVoid:()=>Op,$ZodXID:()=>cp,$ZodXor:()=>Ap,$brand:()=>Zu,$constructor:()=>g,$input:()=>lh,$output:()=>ch,Doc:()=>Is,JSONSchema:()=>xS,JSONSchemaGenerator:()=>hl,NEVER:()=>ys,TimePrecision:()=>hh,_any:()=>Nh,_array:()=>Zh,_base64:()=>tl,_base64url:()=>ol,_bigint:()=>Th,_boolean:()=>xh,_catch:()=>Tv,_check:()=>wS,_cidrv4:()=>Qc,_cidrv6:()=>el,_coercedBigint:()=>Eh,_coercedBoolean:()=>Ph,_coercedDate:()=>Lh,_coercedNumber:()=>bh,_coercedString:()=>dh,_cuid:()=>Jc,_cuid2:()=>Bc,_custom:()=>Fh,_date:()=>jh,_decode:()=>gc,_decodeAsync:()=>_c,_default:()=>wv,_discriminatedUnion:()=>pv,_e164:()=>rl,_email:()=>Lc,_emoji:()=>Hc,_encode:()=>fc,_encodeAsync:()=>Sc,_endsWith:()=>Zr,_enum:()=>_v,_file:()=>Dh,_float32:()=>zh,_float64:()=>vh,_gt:()=>Tt,_gte:()=>je,_guid:()=>As,_includes:()=>Lr,_int:()=>yh,_int32:()=>Rh,_int64:()=>kh,_intersection:()=>hv,_ipv4:()=>Yc,_ipv6:()=>Xc,_isoDate:()=>fh,_isoDateTime:()=>mh,_isoDuration:()=>Sh,_isoTime:()=>gh,_jwt:()=>nl,_ksuid:()=>Gc,_lazy:()=>Cv,_length:()=>Vo,_literal:()=>yv,_lowercase:()=>Ar,_lt:()=>Pt,_lte:()=>Xe,_mac:()=>ph,_map:()=>gv,_max:()=>Xe,_maxLength:()=>Ho,_maxSize:()=>fo,_mime:()=>Dr,_min:()=>je,_minLength:()=>Dt,_minSize:()=>Et,_multipleOf:()=>mo,_nan:()=>Uh,_nanoid:()=>Vc,_nativeEnum:()=>bv,_negative:()=>il,_never:()=>Mh,_nonnegative:()=>cl,_nonoptional:()=>xv,_nonpositive:()=>al,_normalize:()=>Fr,_null:()=>Oh,_nullable:()=>Rv,_number:()=>_h,_optional:()=>vv,_overwrite:()=>dt,_parse:()=>Cr,_parseAsync:()=>Ir,_pipe:()=>Ev,_positive:()=>sl,_promise:()=>Iv,_property:()=>ll,_readonly:()=>kv,_record:()=>fv,_refine:()=>Hh,_regex:()=>Mr,_safeDecode:()=>yc,_safeDecodeAsync:()=>vc,_safeEncode:()=>bc,_safeEncodeAsync:()=>zc,_safeParse:()=>Or,_safeParseAsync:()=>Nr,_set:()=>Sv,_size:()=>Fo,_slugify:()=>Br,_startsWith:()=>Ur,_string:()=>uh,_stringFormat:()=>Wr,_stringbool:()=>Wh,_success:()=>Pv,_superRefine:()=>Vh,_symbol:()=>Ch,_templateLiteral:()=>$v,_toLowerCase:()=>Vr,_toUpperCase:()=>Jr,_transform:()=>zv,_trim:()=>Hr,_tuple:()=>mv,_uint32:()=>wh,_uint64:()=>$h,_ulid:()=>Wc,_undefined:()=>Ih,_union:()=>uv,_unknown:()=>qh,_uppercase:()=>jr,_url:()=>js,_uuid:()=>Uc,_uuidv4:()=>Zc,_uuidv6:()=>Dc,_uuidv7:()=>Fc,_void:()=>Ah,_xid:()=>Kc,_xor:()=>dv,clone:()=>Me,config:()=>ge,createStandardJSONSchemaMethod:()=>Kr,createToJSONSchemaMethod:()=>Kh,decode:()=>Tz,decodeAsync:()=>kz,describe:()=>Jh,encode:()=>Pz,encodeAsync:()=>Ez,extractDefs:()=>So,finalize:()=>_o,flattenError:()=>Es,formatError:()=>ks,globalConfig:()=>Lo,globalRegistry:()=>ve,initializeContext:()=>go,isValidBase64:()=>bp,isValidBase64URL:()=>_S,isValidJWT:()=>bS,locales:()=>Ms,meta:()=>Bh,parse:()=>hc,parseAsync:()=>mc,prettifyError:()=>td,process:()=>ne,regexes:()=>Ye,registry:()=>jc,safeDecode:()=>Cz,safeDecodeAsync:()=>Oz,safeEncode:()=>$z,safeEncodeAsync:()=>Iz,safeParse:()=>od,safeParseAsync:()=>rd,toDotPath:()=>Yg,toJSONSchema:()=>Jo,treeifyError:()=>ed,util:()=>G,version:()=>Yd});var Jg,ys=Object.freeze({status:"aborted"});function g(e,t,o){function r(a,l){if(a._zod||Object.defineProperty(a,"_zod",{value:{def:l,constr:i,traits:new Set},enumerable:!1}),a._zod.traits.has(e))return;a._zod.traits.add(e),t(a,l);let u=i.prototype,d=Object.keys(u);for(let h=0;h<d.length;h++){let f=d[h];f in a||(a[f]=u[f].bind(a))}}let n=o?.Parent??Object;class s extends n{}Object.defineProperty(s,"name",{value:e});function i(a){var l;let u=o?.Parent?new s:this;r(u,a),(l=u._zod).deferred??(l.deferred=[]);for(let d of u._zod.deferred)d();return u}return Object.defineProperty(i,"init",{value:r}),Object.defineProperty(i,Symbol.hasInstance,{value:a=>o?.Parent&&a instanceof o.Parent?!0:a?._zod?.traits?.has(e)}),Object.defineProperty(i,"name",{value:e}),i}var Zu=Symbol("zod_brand"),ut=class extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}},co=class extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}};(Jg=globalThis).__zod_globalConfig??(Jg.__zod_globalConfig={});var Lo=globalThis.__zod_globalConfig;function ge(e){return e&&Object.assign(Lo,e),Lo}var G={};Ut(G,{BIGINT_FORMAT_RANGES:()=>Yu,Class:()=>Fu,NUMBER_FORMAT_RANGES:()=>Gu,aborted:()=>ho,allowsEval:()=>Ju,assert:()=>nz,assertEqual:()=>ez,assertIs:()=>oz,assertNever:()=>rz,assertNotEqual:()=>tz,assignProp:()=>uo,base64ToUint8Array:()=>Wg,base64urlToUint8Array:()=>zz,cached:()=>kr,captureStackTrace:()=>dc,cleanEnum:()=>yz,cleanRegex:()=>Rs,clone:()=>Me,cloneDef:()=>iz,createTransparentProxy:()=>pz,defineLazy:()=>te,esc:()=>uc,escapeRegex:()=>it,explicitlyAborted:()=>Xu,extend:()=>fz,finalizeIssue:()=>Ae,floatSafeRemainder:()=>Hu,getElementAtPath:()=>az,getEnumValues:()=>vs,getLengthableOrigin:()=>Ps,getParsedType:()=>dz,getSizableOrigin:()=>xs,hexToUint8Array:()=>Rz,isObject:()=>Uo,isPlainObject:()=>po,issue:()=>$r,joinValues:()=>lc,jsonStringifyReplacer:()=>Er,merge:()=>Sz,mergeDefs:()=>Zt,normalizeParams:()=>P,nullish:()=>lo,numKeys:()=>uz,objectClone:()=>sz,omit:()=>mz,optionalKeys:()=>Ku,parsedType:()=>Qu,partial:()=>_z,pick:()=>hz,prefixIssues:()=>Fe,primitiveTypes:()=>Wu,promiseAllObject:()=>cz,propertyKeyTypes:()=>ws,randomString:()=>lz,required:()=>bz,safeExtend:()=>gz,shallowClone:()=>Bu,slugify:()=>Vu,stringifyPrimitive:()=>pc,uint8ArrayToBase64:()=>Kg,uint8ArrayToBase64url:()=>vz,uint8ArrayToHex:()=>wz,unwrapMessage:()=>zs});function ez(e){return e}function tz(e){return e}function oz(e){}function rz(e){throw new Error("Unexpected value in exhaustive check")}function nz(e){}function vs(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 lc(e,t="|"){return e.map(o=>pc(o)).join(t)}function Er(e,t){return typeof t=="bigint"?t.toString():t}function kr(e){return{get value(){{let o=e();return Object.defineProperty(this,"value",{value:o}),o}throw new Error("cached value already set")}}}function lo(e){return e==null}function Rs(e){let t=e.startsWith("^")?1:0,o=e.endsWith("$")?e.length-1:e.length;return e.slice(t,o)}function Hu(e,t){let o=e/t,r=Math.round(o),n=Number.EPSILON*Math.max(Math.abs(o),1);return Math.abs(o-r)<n?0:o-r}var Bg=Symbol("evaluating");function te(e,t,o){let r;Object.defineProperty(e,t,{get(){if(r!==Bg)return r===void 0&&(r=Bg,r=o()),r},set(n){Object.defineProperty(e,t,{value:n})},configurable:!0})}function sz(e){return Object.create(Object.getPrototypeOf(e),Object.getOwnPropertyDescriptors(e))}function uo(e,t,o){Object.defineProperty(e,t,{value:o,writable:!0,enumerable:!0,configurable:!0})}function Zt(...e){let t={};for(let o of e){let r=Object.getOwnPropertyDescriptors(o);Object.assign(t,r)}return Object.defineProperties({},t)}function iz(e){return Zt(e._zod.def)}function az(e,t){return t?t.reduce((o,r)=>o?.[r],e):e}function cz(e){let t=Object.keys(e),o=t.map(r=>e[r]);return Promise.all(o).then(r=>{let n={};for(let s=0;s<t.length;s++)n[t[s]]=r[s];return n})}function lz(e=10){let t="abcdefghijklmnopqrstuvwxyz",o="";for(let r=0;r<e;r++)o+=t[Math.floor(Math.random()*t.length)];return o}function uc(e){return JSON.stringify(e)}function Vu(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}var dc="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function Uo(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}var Ju=kr(()=>{if(Lo.jitless||typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{let e=Function;return new e(""),!0}catch{return!1}});function po(e){if(Uo(e)===!1)return!1;let t=e.constructor;if(t===void 0||typeof t!="function")return!0;let o=t.prototype;return!(Uo(o)===!1||Object.prototype.hasOwnProperty.call(o,"isPrototypeOf")===!1)}function Bu(e){return po(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}function uz(e){let t=0;for(let o in e)Object.prototype.hasOwnProperty.call(e,o)&&t++;return t}var dz=e=>{let t=typeof e;switch(t){case"undefined":return"undefined";case"string":return"string";case"number":return Number.isNaN(e)?"nan":"number";case"boolean":return"boolean";case"function":return"function";case"bigint":return"bigint";case"symbol":return"symbol";case"object":return Array.isArray(e)?"array":e===null?"null":e.then&&typeof e.then=="function"&&e.catch&&typeof e.catch=="function"?"promise":typeof Map<"u"&&e instanceof Map?"map":typeof Set<"u"&&e instanceof Set?"set":typeof Date<"u"&&e instanceof Date?"date":typeof File<"u"&&e instanceof File?"file":"object";default:throw new Error(`Unknown data type: ${t}`)}},ws=new Set(["string","number","symbol"]),Wu=new Set(["string","number","bigint","boolean","symbol","undefined"]);function it(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Me(e,t,o){let r=new e._zod.constr(t??e._zod.def);return(!t||o?.parent)&&(r._zod.parent=e),r}function P(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 new Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error=="string"?{...t,error:()=>t.error}:t}function pz(e){let t;return new Proxy({},{get(o,r,n){return t??(t=e()),Reflect.get(t,r,n)},set(o,r,n,s){return t??(t=e()),Reflect.set(t,r,n,s)},has(o,r){return t??(t=e()),Reflect.has(t,r)},deleteProperty(o,r){return t??(t=e()),Reflect.deleteProperty(t,r)},ownKeys(o){return t??(t=e()),Reflect.ownKeys(t)},getOwnPropertyDescriptor(o,r){return t??(t=e()),Reflect.getOwnPropertyDescriptor(t,r)},defineProperty(o,r,n){return t??(t=e()),Reflect.defineProperty(t,r,n)}})}function pc(e){return typeof e=="bigint"?e.toString()+"n":typeof e=="string"?`"${e}"`:`${e}`}function Ku(e){return Object.keys(e).filter(t=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}var Gu={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]},Yu={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};function hz(e,t){let o=e._zod.def,r=o.checks;if(r&&r.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");let s=Zt(e._zod.def,{get shape(){let i={};for(let a in t){if(!(a in o.shape))throw new Error(`Unrecognized key: "${a}"`);t[a]&&(i[a]=o.shape[a])}return uo(this,"shape",i),i},checks:[]});return Me(e,s)}function mz(e,t){let o=e._zod.def,r=o.checks;if(r&&r.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");let s=Zt(e._zod.def,{get shape(){let i={...e._zod.def.shape};for(let a in t){if(!(a in o.shape))throw new Error(`Unrecognized key: "${a}"`);t[a]&&delete i[a]}return uo(this,"shape",i),i},checks:[]});return Me(e,s)}function fz(e,t){if(!po(t))throw new 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 new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}let n=Zt(e._zod.def,{get shape(){let s={...e._zod.def.shape,...t};return uo(this,"shape",s),s}});return Me(e,n)}function gz(e,t){if(!po(t))throw new Error("Invalid input to safeExtend: expected a plain object");let o=Zt(e._zod.def,{get shape(){let r={...e._zod.def.shape,...t};return uo(this,"shape",r),r}});return Me(e,o)}function Sz(e,t){if(e._zod.def.checks?.length)throw new Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");let o=Zt(e._zod.def,{get shape(){let r={...e._zod.def.shape,...t._zod.def.shape};return uo(this,"shape",r),r},get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]});return Me(e,o)}function _z(e,t,o){let n=t._zod.def.checks;if(n&&n.length>0)throw new Error(".partial() cannot be used on object schemas containing refinements");let i=Zt(t._zod.def,{get shape(){let a=t._zod.def.shape,l={...a};if(o)for(let u in o){if(!(u in a))throw new Error(`Unrecognized key: "${u}"`);o[u]&&(l[u]=e?new e({type:"optional",innerType:a[u]}):a[u])}else for(let u in a)l[u]=e?new e({type:"optional",innerType:a[u]}):a[u];return uo(this,"shape",l),l},checks:[]});return Me(t,i)}function bz(e,t,o){let r=Zt(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 new Error(`Unrecognized key: "${i}"`);o[i]&&(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 uo(this,"shape",s),s}});return Me(t,r)}function ho(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 Xu(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 Fe(e,t){return t.map(o=>{var r;return(r=o).path??(r.path=[]),o.path.unshift(e),o})}function zs(e){return typeof e=="string"?e:e?.message}function Ae(e,t,o){let r=e.message?e.message:zs(e.inst?._zod.def?.error?.(e))??zs(t?.error?.(e))??zs(o.customError?.(e))??zs(o.localeError?.(e))??"Invalid input",{inst:n,continue:s,input:i,...a}=e;return a.path??(a.path=[]),a.message=r,t?.reportInput&&(a.input=i),a}function xs(e){return e instanceof Set?"set":e instanceof Map?"map":e instanceof File?"file":"unknown"}function Ps(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function Qu(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 $r(...e){let[t,o,r]=e;return typeof t=="string"?{message:t,code:"custom",input:o,inst:r}:{...t}}function yz(e){return Object.entries(e).filter(([t,o])=>Number.isNaN(Number.parseInt(t,10))).map(t=>t[1])}function Wg(e){let t=atob(e),o=new Uint8Array(t.length);for(let r=0;r<t.length;r++)o[r]=t.charCodeAt(r);return o}function Kg(e){let t="";for(let o=0;o<e.length;o++)t+=String.fromCharCode(e[o]);return btoa(t)}function zz(e){let t=e.replace(/-/g,"+").replace(/_/g,"/"),o="=".repeat((4-t.length%4)%4);return Wg(t+o)}function vz(e){return Kg(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function Rz(e){let t=e.replace(/^0x/,"");if(t.length%2!==0)throw new Error("Invalid hex string length");let o=new Uint8Array(t.length/2);for(let r=0;r<t.length;r+=2)o[r/2]=Number.parseInt(t.slice(r,r+2),16);return o}function wz(e){return Array.from(e).map(t=>t.toString(16).padStart(2,"0")).join("")}var Fu=class{constructor(...t){}};var Gg=(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,Er,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},Ts=g("$ZodError",Gg),He=g("$ZodError",Gg,{Parent:Error});function Es(e,t=o=>o.message){let o={},r=[];for(let n of e.issues)n.path.length>0?(o[n.path[0]]=o[n.path[0]]||[],o[n.path[0]].push(t(n))):r.push(t(n));return{formErrors:r,fieldErrors:o}}function ks(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(a=>r({issues:a},[...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 a=[...s,...i.path];if(a.length===0)o._errors.push(t(i));else{let l=o,u=0;for(;u<a.length;){let d=a[u];u===a.length-1?(l[d]=l[d]||{_errors:[]},l[d]._errors.push(t(i))):l[d]=l[d]||{_errors:[]},l=l[d],u++}}}};return r(e),o}function ed(e,t=o=>o.message){let o={errors:[]},r=(n,s=[])=>{var i,a;for(let l of n.issues)if(l.code==="invalid_union"&&l.errors.length)l.errors.map(u=>r({issues:u},[...s,...l.path]));else if(l.code==="invalid_key")r({issues:l.issues},[...s,...l.path]);else if(l.code==="invalid_element")r({issues:l.issues},[...s,...l.path]);else{let u=[...s,...l.path];if(u.length===0){o.errors.push(t(l));continue}let d=o,h=0;for(;h<u.length;){let f=u[h],S=h===u.length-1;typeof f=="string"?(d.properties??(d.properties={}),(i=d.properties)[f]??(i[f]={errors:[]}),d=d.properties[f]):(d.items??(d.items=[]),(a=d.items)[f]??(a[f]={errors:[]}),d=d.items[f]),S&&d.errors.push(t(l)),h++}}};return r(e),o}function Yg(e){let t=[],o=e.map(r=>typeof r=="object"?r.key:r);for(let r of o)typeof r=="number"?t.push(`[${r}]`):typeof r=="symbol"?t.push(`[${JSON.stringify(String(r))}]`):/[^\w$]/.test(r)?t.push(`[${JSON.stringify(r)}]`):(t.length&&t.push("."),t.push(r));return t.join("")}function td(e){let t=[],o=[...e.issues].sort((r,n)=>(r.path??[]).length-(n.path??[]).length);for(let r of o)t.push(`\u2716 ${r.message}`),r.path?.length&&t.push(` \u2192 at ${Yg(r.path)}`);return t.join(`
2
+ `)}var Cr=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 ut;if(i.issues.length){let a=new(n?.Err??e)(i.issues.map(l=>Ae(l,s,ge())));throw dc(a,n?.callee),a}return i.value},hc=Cr(He),Ir=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),i.issues.length){let a=new(n?.Err??e)(i.issues.map(l=>Ae(l,s,ge())));throw dc(a,n?.callee),a}return i.value},mc=Ir(He),Or=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 ut;return s.issues.length?{success:!1,error:new(e??Ts)(s.issues.map(i=>Ae(i,n,ge())))}:{success:!0,data:s.value}},od=Or(He),Nr=e=>async(t,o,r)=>{let n=r?{...r,async:!0}:{async:!0},s=t._zod.run({value:o,issues:[]},n);return s instanceof Promise&&(s=await s),s.issues.length?{success:!1,error:new e(s.issues.map(i=>Ae(i,n,ge())))}:{success:!0,data:s.value}},rd=Nr(He),fc=e=>(t,o,r)=>{let n=r?{...r,direction:"backward"}:{direction:"backward"};return Cr(e)(t,o,n)},Pz=fc(He),gc=e=>(t,o,r)=>Cr(e)(t,o,r),Tz=gc(He),Sc=e=>async(t,o,r)=>{let n=r?{...r,direction:"backward"}:{direction:"backward"};return Ir(e)(t,o,n)},Ez=Sc(He),_c=e=>async(t,o,r)=>Ir(e)(t,o,r),kz=_c(He),bc=e=>(t,o,r)=>{let n=r?{...r,direction:"backward"}:{direction:"backward"};return Or(e)(t,o,n)},$z=bc(He),yc=e=>(t,o,r)=>Or(e)(t,o,r),Cz=yc(He),zc=e=>async(t,o,r)=>{let n=r?{...r,direction:"backward"}:{direction:"backward"};return Nr(e)(t,o,n)},Iz=zc(He),vc=e=>async(t,o,r)=>Nr(e)(t,o,r),Oz=vc(He);var Ye={};Ut(Ye,{base64:()=>bd,base64url:()=>Rc,bigint:()=>Pd,boolean:()=>Ed,browserEmail:()=>Zz,cidrv4:()=>Sd,cidrv6:()=>_d,cuid:()=>nd,cuid2:()=>sd,date:()=>vd,datetime:()=>wd,domain:()=>Hz,duration:()=>ud,e164:()=>zd,email:()=>pd,emoji:()=>hd,extendedDuration:()=>Nz,guid:()=>dd,hex:()=>Vz,hostname:()=>Fz,html5Email:()=>jz,httpProtocol:()=>yd,idnEmail:()=>Uz,integer:()=>Td,ipv4:()=>md,ipv6:()=>fd,ksuid:()=>cd,lowercase:()=>Cd,mac:()=>gd,md5_base64:()=>Bz,md5_base64url:()=>Wz,md5_hex:()=>Jz,nanoid:()=>ld,null:()=>kd,number:()=>wc,rfc5322Email:()=>Lz,sha1_base64:()=>Gz,sha1_base64url:()=>Yz,sha1_hex:()=>Kz,sha256_base64:()=>Qz,sha256_base64url:()=>ev,sha256_hex:()=>Xz,sha384_base64:()=>ov,sha384_base64url:()=>rv,sha384_hex:()=>tv,sha512_base64:()=>sv,sha512_base64url:()=>iv,sha512_hex:()=>nv,string:()=>xd,time:()=>Rd,ulid:()=>id,undefined:()=>$d,unicodeEmail:()=>Xg,uppercase:()=>Id,uuid:()=>Zo,uuid4:()=>qz,uuid6:()=>Mz,uuid7:()=>Az,xid:()=>ad});var nd=/^[cC][0-9a-z]{6,}$/,sd=/^[0-9a-z]+$/,id=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,ad=/^[0-9a-vA-V]{20}$/,cd=/^[A-Za-z0-9]{27}$/,ld=/^[a-zA-Z0-9_-]{21}$/,ud=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,Nz=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,dd=/^([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})$/,Zo=e=>e?new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,qz=Zo(4),Mz=Zo(6),Az=Zo(7),pd=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,jz=/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/,Lz=/^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/,Xg=/^[^\s@"]{1,64}@[^\s@]{1,255}$/u,Uz=Xg,Zz=/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/,Dz="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function hd(){return new RegExp(Dz,"u")}var md=/^(?:(?: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])$/,fd=/^(([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}|:))$/,gd=e=>{let t=it(e??":");return new RegExp(`^(?:[0-9A-F]{2}${t}){5}[0-9A-F]{2}$|^(?:[0-9a-f]{2}${t}){5}[0-9a-f]{2}$`)},Sd=/^((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])$/,_d=/^(([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])$/,bd=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Rc=/^[A-Za-z0-9_-]*$/,Fz=/^(?=.{1,253}\.?$)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[-0-9a-zA-Z]{0,61}[0-9a-zA-Z])?)*\.?$/,Hz=/^([a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,}$/,yd=/^https?$/,zd=/^\+[1-9]\d{6,14}$/,Qg="(?:(?:\\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])))",vd=new RegExp(`^${Qg}$`);function eS(e){let t="(?:[01]\\d|2[0-3]):[0-5]\\d";return typeof e.precision=="number"?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function Rd(e){return new RegExp(`^${eS(e)}$`)}function wd(e){let t=eS({precision:e.precision}),o=["Z"];e.local&&o.push(""),e.offset&&o.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");let r=`${t}(?:${o.join("|")})`;return new RegExp(`^${Qg}T(?:${r})$`)}var xd=e=>{let t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)},Pd=/^-?\d+n?$/,Td=/^-?\d+$/,wc=/^-?\d+(?:\.\d+)?$/,Ed=/^(?:true|false)$/i,kd=/^null$/i;var $d=/^undefined$/i;var Cd=/^[^A-Z]*$/,Id=/^[^a-z]*$/,Vz=/^[0-9a-fA-F]*$/;function $s(e,t){return new RegExp(`^[A-Za-z0-9+/]{${e}}${t}$`)}function Cs(e){return new RegExp(`^[A-Za-z0-9_-]{${e}}$`)}var Jz=/^[0-9a-fA-F]{32}$/,Bz=$s(22,"=="),Wz=Cs(22),Kz=/^[0-9a-fA-F]{40}$/,Gz=$s(27,"="),Yz=Cs(27),Xz=/^[0-9a-fA-F]{64}$/,Qz=$s(43,"="),ev=Cs(43),tv=/^[0-9a-fA-F]{96}$/,ov=$s(64,""),rv=Cs(64),nv=/^[0-9a-fA-F]{128}$/,sv=$s(86,"=="),iv=Cs(86);var le=g("$ZodCheck",(e,t)=>{var o;e._zod??(e._zod={}),e._zod.def=t,(o=e._zod).onattach??(o.onattach=[])}),oS={number:"number",bigint:"bigint",object:"date"},xc=g("$ZodCheckLessThan",(e,t)=>{le.init(e,t);let o=oS[typeof t.value];e._zod.onattach.push(r=>{let n=r._zod.bag,s=(t.inclusive?n.maximum:n.exclusiveMaximum)??Number.POSITIVE_INFINITY;t.value<s&&(t.inclusive?n.maximum=t.value:n.exclusiveMaximum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value<=t.value:r.value<t.value)||r.issues.push({origin: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})}}),Pc=g("$ZodCheckGreaterThan",(e,t)=>{le.init(e,t);let o=oS[typeof t.value];e._zod.onattach.push(r=>{let n=r._zod.bag,s=(t.inclusive?n.minimum:n.exclusiveMinimum)??Number.NEGATIVE_INFINITY;t.value>s&&(t.inclusive?n.minimum=t.value:n.exclusiveMinimum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value>=t.value:r.value>t.value)||r.issues.push({origin: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})}}),Od=g("$ZodCheckMultipleOf",(e,t)=>{le.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 new Error("Cannot mix number and bigint in multiple_of check.");(typeof o.value=="bigint"?o.value%t.value===BigInt(0):Hu(o.value,t.value)===0)||o.issues.push({origin:typeof o.value,code:"not_multiple_of",divisor:t.value,input:o.value,inst:e,continue:!t.abort})}}),Nd=g("$ZodCheckNumberFormat",(e,t)=>{le.init(e,t),t.format=t.format||"float64";let o=t.format?.includes("int"),r=o?"int":"number",[n,s]=Gu[t.format];e._zod.onattach.push(i=>{let a=i._zod.bag;a.format=t.format,a.minimum=n,a.maximum=s,o&&(a.pattern=Td)}),e._zod.check=i=>{let a=i.value;if(o){if(!Number.isInteger(a)){i.issues.push({expected:r,format:t.format,code:"invalid_type",continue:!1,input:a,inst:e});return}if(!Number.isSafeInteger(a)){a>0?i.issues.push({input:a,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}):i.issues.push({input:a,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}}a<n&&i.issues.push({origin:"number",input:a,code:"too_small",minimum:n,inclusive:!0,inst:e,continue:!t.abort}),a>s&&i.issues.push({origin:"number",input:a,code:"too_big",maximum:s,inclusive:!0,inst:e,continue:!t.abort})}}),qd=g("$ZodCheckBigIntFormat",(e,t)=>{le.init(e,t);let[o,r]=Yu[t.format];e._zod.onattach.push(n=>{let s=n._zod.bag;s.format=t.format,s.minimum=o,s.maximum=r}),e._zod.check=n=>{let s=n.value;s<o&&n.issues.push({origin:"bigint",input:s,code:"too_small",minimum:o,inclusive:!0,inst:e,continue:!t.abort}),s>r&&n.issues.push({origin:"bigint",input:s,code:"too_big",maximum:r,inclusive:!0,inst:e,continue:!t.abort})}}),Md=g("$ZodCheckMaxSize",(e,t)=>{var o;le.init(e,t),(o=e._zod.def).when??(o.when=r=>{let n=r.value;return!lo(n)&&n.size!==void 0}),e._zod.onattach.push(r=>{let n=r._zod.bag.maximum??Number.POSITIVE_INFINITY;t.maximum<n&&(r._zod.bag.maximum=t.maximum)}),e._zod.check=r=>{let n=r.value;n.size<=t.maximum||r.issues.push({origin:xs(n),code:"too_big",maximum:t.maximum,inclusive:!0,input:n,inst:e,continue:!t.abort})}}),Ad=g("$ZodCheckMinSize",(e,t)=>{var o;le.init(e,t),(o=e._zod.def).when??(o.when=r=>{let n=r.value;return!lo(n)&&n.size!==void 0}),e._zod.onattach.push(r=>{let n=r._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>n&&(r._zod.bag.minimum=t.minimum)}),e._zod.check=r=>{let n=r.value;n.size>=t.minimum||r.issues.push({origin:xs(n),code:"too_small",minimum:t.minimum,inclusive:!0,input:n,inst:e,continue:!t.abort})}}),jd=g("$ZodCheckSizeEquals",(e,t)=>{var o;le.init(e,t),(o=e._zod.def).when??(o.when=r=>{let n=r.value;return!lo(n)&&n.size!==void 0}),e._zod.onattach.push(r=>{let n=r._zod.bag;n.minimum=t.size,n.maximum=t.size,n.size=t.size}),e._zod.check=r=>{let n=r.value,s=n.size;if(s===t.size)return;let i=s>t.size;r.issues.push({origin:xs(n),...i?{code:"too_big",maximum:t.size}:{code:"too_small",minimum:t.size},inclusive:!0,exact:!0,input:r.value,inst:e,continue:!t.abort})}}),Ld=g("$ZodCheckMaxLength",(e,t)=>{var o;le.init(e,t),(o=e._zod.def).when??(o.when=r=>{let n=r.value;return!lo(n)&&n.length!==void 0}),e._zod.onattach.push(r=>{let n=r._zod.bag.maximum??Number.POSITIVE_INFINITY;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=Ps(n);r.issues.push({origin:i,code:"too_big",maximum:t.maximum,inclusive:!0,input:n,inst:e,continue:!t.abort})}}),Ud=g("$ZodCheckMinLength",(e,t)=>{var o;le.init(e,t),(o=e._zod.def).when??(o.when=r=>{let n=r.value;return!lo(n)&&n.length!==void 0}),e._zod.onattach.push(r=>{let n=r._zod.bag.minimum??Number.NEGATIVE_INFINITY;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=Ps(n);r.issues.push({origin:i,code:"too_small",minimum:t.minimum,inclusive:!0,input:n,inst:e,continue:!t.abort})}}),Zd=g("$ZodCheckLengthEquals",(e,t)=>{var o;le.init(e,t),(o=e._zod.def).when??(o.when=r=>{let n=r.value;return!lo(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=Ps(n),a=s>t.length;r.issues.push({origin:i,...a?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:r.value,inst:e,continue:!t.abort})}}),qr=g("$ZodCheckStringFormat",(e,t)=>{var o,r;le.init(e,t),e._zod.onattach.push(n=>{let s=n._zod.bag;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=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:"string",code:"invalid_format",format:t.format,input:n.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(r=e._zod).check??(r.check=()=>{})}),Dd=g("$ZodCheckRegex",(e,t)=>{qr.init(e,t),e._zod.check=o=>{t.pattern.lastIndex=0,!t.pattern.test(o.value)&&o.issues.push({origin:"string",code:"invalid_format",format:"regex",input:o.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),Fd=g("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=Cd),qr.init(e,t)}),Hd=g("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=Id),qr.init(e,t)}),Vd=g("$ZodCheckIncludes",(e,t)=>{le.init(e,t);let o=it(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=>{n.value.includes(t.includes,t.position)||n.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:n.value,inst:e,continue:!t.abort})}}),Jd=g("$ZodCheckStartsWith",(e,t)=>{le.init(e,t);let o=new RegExp(`^${it(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=>{r.value.startsWith(t.prefix)||r.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:r.value,inst:e,continue:!t.abort})}}),Bd=g("$ZodCheckEndsWith",(e,t)=>{le.init(e,t);let o=new RegExp(`.*${it(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=>{r.value.endsWith(t.suffix)||r.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:r.value,inst:e,continue:!t.abort})}});function tS(e,t,o){e.issues.length&&t.issues.push(...Fe(o,e.issues))}var Wd=g("$ZodCheckProperty",(e,t)=>{le.init(e,t),e._zod.check=o=>{let r=t.schema._zod.run({value:o.value[t.property],issues:[]},{});if(r instanceof Promise)return r.then(n=>tS(n,o,t.property));tS(r,o,t.property)}}),Kd=g("$ZodCheckMimeType",(e,t)=>{le.init(e,t);let o=new Set(t.mime);e._zod.onattach.push(r=>{r._zod.bag.mime=t.mime}),e._zod.check=r=>{o.has(r.value.type)||r.issues.push({code:"invalid_value",values:t.mime,input:r.value.type,inst:e,continue:!t.abort})}}),Gd=g("$ZodCheckOverwrite",(e,t)=>{le.init(e,t),e._zod.check=o=>{o.value=t.tx(o.value)}});var Is=class{constructor(t=[]){this.content=[],this.indent=0,this&&(this.args=t)}indented(t){this.indent+=1,t(this),this.indent-=1}write(t){if(typeof t=="function"){t(this,{execution:"sync"}),t(this,{execution:"async"});return}let r=t.split(`
3
3
  `).filter(i=>i),n=Math.min(...r.map(i=>i.length-i.trimStart().length)),s=r.map(i=>i.slice(n)).map(i=>" ".repeat(this.indent*2)+i);for(let i of s)this.content.push(i)}compile(){let t=Function,o=this?.args,n=[...(this?.content??[""]).map(s=>` ${s}`)];return new t(...o,n.join(`
4
- `))}};var Gd={major:4,minor:4,patch:3};var Y=g("$ZodType",(e,t)=>{var o;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=Gd;let r=[...e._zod.def.checks??[]];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,a,l)=>{let u=ho(i),d;for(let h of a){if(h._zod.def.when){if(Yu(i)||!h._zod.def.when(i))continue}else if(u)continue;let f=i.issues.length,S=h._zod.check(i);if(S instanceof Promise&&l?.async===!1)throw new ut;if(d||S instanceof Promise)d=(d??Promise.resolve()).then(async()=>{await S,i.issues.length!==f&&(u||(u=ho(i,f)))});else{if(i.issues.length===f)continue;u||(u=ho(i,f))}}return d?d.then(()=>i):i},s=(i,a,l)=>{if(ho(i))return i.aborted=!0,i;let u=n(a,r,l);if(u instanceof Promise){if(l.async===!1)throw new ut;return u.then(d=>e._zod.parse(d,l))}return e._zod.parse(u,l)};e._zod.run=(i,a)=>{if(a.skipChecks)return e._zod.parse(i,a);if(a.direction==="backward"){let u=e._zod.parse({value:i.value,issues:[]},{...a,skipChecks:!0});return u instanceof Promise?u.then(d=>s(d,i,a)):s(u,i,a)}let l=e._zod.parse(i,a);if(l instanceof Promise){if(a.async===!1)throw new ut;return l.then(u=>n(u,r,a))}return n(l,r,a)}}te(e,"~standard",()=>({validate:n=>{try{let s=td(e,n);return s.success?{value:s.data}:{issues:s.error?.issues}}catch{return od(e,n).then(i=>i.success?{value:i.data}:{issues:i.error?.issues})}},vendor:"zod",version:1}))}),Do=g("$ZodString",(e,t)=>{Y.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??wd(e._zod.bag),e._zod.parse=(o,r)=>{if(t.coerce)try{o.value=String(o.value)}catch{}return typeof o.value=="string"||o.issues.push({expected:"string",code:"invalid_type",input:o.value,inst:e}),o}}),ae=g("$ZodStringFormat",(e,t)=>{Nr.init(e,t),Do.init(e,t)}),Xd=g("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=ud),ae.init(e,t)}),Qd=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 new Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=Zo(r))}else t.pattern??(t.pattern=Zo());ae.init(e,t)}),ep=g("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=dd),ae.init(e,t)}),tp=g("$ZodURL",(e,t)=>{ae.init(e,t),e._zod.check=o=>{try{let r=o.value.trim();if(!t.normalize&&t.protocol?.source===bd.source&&!/^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);t.hostname&&(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})),t.protocol&&(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})),t.normalize?o.value=n.href:o.value=r;return}catch{o.issues.push({code:"invalid_format",format:"url",input:o.value,inst:e,continue:!t.abort})}}}),op=g("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=pd()),ae.init(e,t)}),rp=g("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=cd),ae.init(e,t)}),np=g("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=rd),ae.init(e,t)}),sp=g("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=nd),ae.init(e,t)}),ip=g("$ZodULID",(e,t)=>{t.pattern??(t.pattern=sd),ae.init(e,t)}),ap=g("$ZodXID",(e,t)=>{t.pattern??(t.pattern=id),ae.init(e,t)}),cp=g("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=ad),ae.init(e,t)}),lp=g("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=Rd(t)),ae.init(e,t)}),up=g("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=zd),ae.init(e,t)}),dp=g("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=vd(t)),ae.init(e,t)}),pp=g("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=ld),ae.init(e,t)}),hp=g("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=hd),ae.init(e,t),e._zod.bag.format="ipv4"}),mp=g("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=md),ae.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})}}}),fp=g("$ZodMAC",(e,t)=>{t.pattern??(t.pattern=fd(t.delimiter)),ae.init(e,t),e._zod.bag.format="mac"}),gp=g("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=gd),ae.init(e,t)}),Sp=g("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=Sd),ae.init(e,t),e._zod.check=o=>{let r=o.value.split("/");try{if(r.length!==2)throw new Error;let[n,s]=r;if(!s)throw new Error;let i=Number(s);if(`${i}`!==s)throw new Error;if(i<0||i>128)throw new Error;new URL(`http://[${n}]`)}catch{o.issues.push({code:"invalid_format",format:"cidrv6",input:o.value,inst:e,continue:!t.abort})}}});function _p(e){if(e==="")return!0;if(/\s/.test(e)||e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}var bp=g("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=_d),ae.init(e,t),e._zod.bag.contentEncoding="base64",e._zod.check=o=>{_p(o.value)||o.issues.push({code:"invalid_format",format:"base64",input:o.value,inst:e,continue:!t.abort})}});function SS(e){if(!vc.test(e))return!1;let t=e.replace(/[-_]/g,r=>r==="-"?"+":"/"),o=t.padEnd(Math.ceil(t.length/4)*4,"=");return _p(o)}var yp=g("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=vc),ae.init(e,t),e._zod.bag.contentEncoding="base64url",e._zod.check=o=>{SS(o.value)||o.issues.push({code:"invalid_format",format:"base64url",input:o.value,inst:e,continue:!t.abort})}}),zp=g("$ZodE164",(e,t)=>{t.pattern??(t.pattern=yd),ae.init(e,t)});function _S(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));return!("typ"in n&&n?.typ!=="JWT"||!n.alg||t&&(!("alg"in n)||n.alg!==t))}catch{return!1}}var vp=g("$ZodJWT",(e,t)=>{ae.init(e,t),e._zod.check=o=>{_S(o.value,t.alg)||o.issues.push({code:"invalid_format",format:"jwt",input:o.value,inst:e,continue:!t.abort})}}),Rp=g("$ZodCustomStringFormat",(e,t)=>{ae.init(e,t),e._zod.check=o=>{t.fn(o.value)||o.issues.push({code:"invalid_format",format:t.format,input:o.value,inst:e,continue:!t.abort})}}),$c=g("$ZodNumber",(e,t)=>{Y.init(e,t),e._zod.pattern=e._zod.bag.pattern??Rc,e._zod.parse=(o,r)=>{if(t.coerce)try{o.value=Number(o.value)}catch{}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)?void 0:"Infinity":void 0;return o.issues.push({expected:"number",code:"invalid_type",input:n,inst:e,...s?{received:s}:{}}),o}}),wp=g("$ZodNumberFormat",(e,t)=>{Od.init(e,t),$c.init(e,t)}),Os=g("$ZodBoolean",(e,t)=>{Y.init(e,t),e._zod.pattern=Td,e._zod.parse=(o,r)=>{if(t.coerce)try{o.value=!!o.value}catch{}let n=o.value;return typeof n=="boolean"||o.issues.push({expected:"boolean",code:"invalid_type",input:n,inst:e}),o}}),Cc=g("$ZodBigInt",(e,t)=>{Y.init(e,t),e._zod.pattern=xd,e._zod.parse=(o,r)=>{if(t.coerce)try{o.value=BigInt(o.value)}catch{}return typeof o.value=="bigint"||o.issues.push({expected:"bigint",code:"invalid_type",input:o.value,inst:e}),o}}),xp=g("$ZodBigIntFormat",(e,t)=>{Nd.init(e,t),Cc.init(e,t)}),Pp=g("$ZodSymbol",(e,t)=>{Y.init(e,t),e._zod.parse=(o,r)=>{let n=o.value;return typeof n=="symbol"||o.issues.push({expected:"symbol",code:"invalid_type",input:n,inst:e}),o}}),Tp=g("$ZodUndefined",(e,t)=>{Y.init(e,t),e._zod.pattern=kd,e._zod.values=new Set([void 0]),e._zod.parse=(o,r)=>{let n=o.value;return typeof n>"u"||o.issues.push({expected:"undefined",code:"invalid_type",input:n,inst:e}),o}}),Ep=g("$ZodNull",(e,t)=>{Y.init(e,t),e._zod.pattern=Ed,e._zod.values=new Set([null]),e._zod.parse=(o,r)=>{let n=o.value;return n===null||o.issues.push({expected:"null",code:"invalid_type",input:n,inst:e}),o}}),kp=g("$ZodAny",(e,t)=>{Y.init(e,t),e._zod.parse=o=>o}),$p=g("$ZodUnknown",(e,t)=>{Y.init(e,t),e._zod.parse=o=>o}),Cp=g("$ZodNever",(e,t)=>{Y.init(e,t),e._zod.parse=(o,r)=>(o.issues.push({expected:"never",code:"invalid_type",input:o.value,inst:e}),o)}),Ip=g("$ZodVoid",(e,t)=>{Y.init(e,t),e._zod.parse=(o,r)=>{let n=o.value;return typeof n>"u"||o.issues.push({expected:"void",code:"invalid_type",input:n,inst:e}),o}}),Op=g("$ZodDate",(e,t)=>{Y.init(e,t),e._zod.parse=(o,r)=>{if(t.coerce)try{o.value=new Date(o.value)}catch{}let n=o.value,s=n instanceof Date;return s&&!Number.isNaN(n.getTime())||o.issues.push({expected:"date",code:"invalid_type",input:n,...s?{received:"Invalid Date"}:{},inst:e}),o}});function rS(e,t,o){e.issues.length&&t.issues.push(...Fe(o,e.issues)),t.value[o]=e.value}var Np=g("$ZodArray",(e,t)=>{Y.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 a=n[i],l=t.element._zod.run({value:a,issues:[]},r);l instanceof Promise?s.push(l.then(u=>rS(u,o,i))):rS(l,o,i)}return s.length?Promise.all(s).then(()=>o):o}});function kc(e,t,o,r,n,s){let i=o in r;if(e.issues.length){if(n&&s&&!i)return;t.issues.push(...Fe(o,e.issues))}if(!i&&!n){e.issues.length||t.issues.push({code:"invalid_type",expected:"nonoptional",input:void 0,path:[o]});return}e.value===void 0?i&&(t.value[o]=void 0):t.value[o]=e.value}function bS(e){let t=Object.keys(e.shape);for(let r of t)if(!e.shape?.[r]?._zod?.traits?.has("$ZodType"))throw new Error(`Invalid element at key "${r}": expected a Zod schema`);let o=Wu(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(o)}}function yS(e,t,o,r,n,s){let i=[],a=n.keySet,l=n.catchall._zod,u=l.def.type,d=l.optin==="optional",h=l.optout==="optional";for(let f in t){if(f==="__proto__"||a.has(f))continue;if(u==="never"){i.push(f);continue}let S=l.run({value:t[f],issues:[]},r);S instanceof Promise?e.push(S.then(y=>kc(y,o,f,t,d,h))):kc(S,o,f,t,d,h)}return i.length&&o.issues.push({code:"unrecognized_keys",keys:i,input:t,inst:s}),e.length?Promise.all(e).then(()=>o):o}var zS=g("$ZodObject",(e,t)=>{if(Y.init(e,t),!Object.getOwnPropertyDescriptor(t,"shape")?.get){let a=t.shape;Object.defineProperty(t,"shape",{get:()=>{let l={...a};return Object.defineProperty(t,"shape",{value:l}),l}})}let r=Er(()=>bS(t));te(e._zod,"propValues",()=>{let a=t.shape,l={};for(let u in a){let d=a[u]._zod;if(d.values){l[u]??(l[u]=new Set);for(let h of d.values)l[u].add(h)}}return l});let n=Uo,s=t.catchall,i;e._zod.parse=(a,l)=>{i??(i=r.value);let u=a.value;if(!n(u))return a.issues.push({expected:"object",code:"invalid_type",input:u,inst:e}),a;a.value={};let d=[],h=i.shape;for(let f of i.keys){let S=h[f],y=S._zod.optin==="optional",w=S._zod.optout==="optional",z=S._zod.run({value:u[f],issues:[]},l);z instanceof Promise?d.push(z.then(H=>kc(H,a,f,u,y,w))):kc(z,a,f,u,y,w)}return s?yS(d,u,a,l,r.value,e):d.length?Promise.all(d).then(()=>a):a}}),qp=g("$ZodObjectJIT",(e,t)=>{zS.init(e,t);let o=e._zod.parse,r=Er(()=>bS(t)),n=f=>{let S=new Is(["shape","payload","ctx"]),y=r.value,w=N=>{let D=lc(N);return`shape[${D}]._zod.run({ value: input[${D}], issues: [] }, ctx)`};S.write("const input = payload.value;");let z=Object.create(null),H=0;for(let N of y.keys)z[N]=`key_${H++}`;S.write("const newResult = {};");for(let N of y.keys){let D=z[N],x=lc(N),v=f[N],Z=v?._zod?.optin==="optional",oe=v?._zod?.optout==="optional";S.write(`const ${D} = ${w(N)};`),Z&&oe?S.write(`
4
+ `))}};var Yd={major:4,minor:4,patch:3};var Y=g("$ZodType",(e,t)=>{var o;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=Yd;let r=[...e._zod.def.checks??[]];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,a,l)=>{let u=ho(i),d;for(let h of a){if(h._zod.def.when){if(Xu(i)||!h._zod.def.when(i))continue}else if(u)continue;let f=i.issues.length,S=h._zod.check(i);if(S instanceof Promise&&l?.async===!1)throw new ut;if(d||S instanceof Promise)d=(d??Promise.resolve()).then(async()=>{await S,i.issues.length!==f&&(u||(u=ho(i,f)))});else{if(i.issues.length===f)continue;u||(u=ho(i,f))}}return d?d.then(()=>i):i},s=(i,a,l)=>{if(ho(i))return i.aborted=!0,i;let u=n(a,r,l);if(u instanceof Promise){if(l.async===!1)throw new ut;return u.then(d=>e._zod.parse(d,l))}return e._zod.parse(u,l)};e._zod.run=(i,a)=>{if(a.skipChecks)return e._zod.parse(i,a);if(a.direction==="backward"){let u=e._zod.parse({value:i.value,issues:[]},{...a,skipChecks:!0});return u instanceof Promise?u.then(d=>s(d,i,a)):s(u,i,a)}let l=e._zod.parse(i,a);if(l instanceof Promise){if(a.async===!1)throw new ut;return l.then(u=>n(u,r,a))}return n(l,r,a)}}te(e,"~standard",()=>({validate:n=>{try{let s=od(e,n);return s.success?{value:s.data}:{issues:s.error?.issues}}catch{return rd(e,n).then(i=>i.success?{value:i.data}:{issues:i.error?.issues})}},vendor:"zod",version:1}))}),Do=g("$ZodString",(e,t)=>{Y.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??xd(e._zod.bag),e._zod.parse=(o,r)=>{if(t.coerce)try{o.value=String(o.value)}catch{}return typeof o.value=="string"||o.issues.push({expected:"string",code:"invalid_type",input:o.value,inst:e}),o}}),ae=g("$ZodStringFormat",(e,t)=>{qr.init(e,t),Do.init(e,t)}),Qd=g("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=dd),ae.init(e,t)}),ep=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 new Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=Zo(r))}else t.pattern??(t.pattern=Zo());ae.init(e,t)}),tp=g("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=pd),ae.init(e,t)}),op=g("$ZodURL",(e,t)=>{ae.init(e,t),e._zod.check=o=>{try{let r=o.value.trim();if(!t.normalize&&t.protocol?.source===yd.source&&!/^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);t.hostname&&(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})),t.protocol&&(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})),t.normalize?o.value=n.href:o.value=r;return}catch{o.issues.push({code:"invalid_format",format:"url",input:o.value,inst:e,continue:!t.abort})}}}),rp=g("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=hd()),ae.init(e,t)}),np=g("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=ld),ae.init(e,t)}),sp=g("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=nd),ae.init(e,t)}),ip=g("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=sd),ae.init(e,t)}),ap=g("$ZodULID",(e,t)=>{t.pattern??(t.pattern=id),ae.init(e,t)}),cp=g("$ZodXID",(e,t)=>{t.pattern??(t.pattern=ad),ae.init(e,t)}),lp=g("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=cd),ae.init(e,t)}),up=g("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=wd(t)),ae.init(e,t)}),dp=g("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=vd),ae.init(e,t)}),pp=g("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=Rd(t)),ae.init(e,t)}),hp=g("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=ud),ae.init(e,t)}),mp=g("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=md),ae.init(e,t),e._zod.bag.format="ipv4"}),fp=g("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=fd),ae.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})}}}),gp=g("$ZodMAC",(e,t)=>{t.pattern??(t.pattern=gd(t.delimiter)),ae.init(e,t),e._zod.bag.format="mac"}),Sp=g("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=Sd),ae.init(e,t)}),_p=g("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=_d),ae.init(e,t),e._zod.check=o=>{let r=o.value.split("/");try{if(r.length!==2)throw new Error;let[n,s]=r;if(!s)throw new Error;let i=Number(s);if(`${i}`!==s)throw new Error;if(i<0||i>128)throw new Error;new URL(`http://[${n}]`)}catch{o.issues.push({code:"invalid_format",format:"cidrv6",input:o.value,inst:e,continue:!t.abort})}}});function bp(e){if(e==="")return!0;if(/\s/.test(e)||e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}var yp=g("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=bd),ae.init(e,t),e._zod.bag.contentEncoding="base64",e._zod.check=o=>{bp(o.value)||o.issues.push({code:"invalid_format",format:"base64",input:o.value,inst:e,continue:!t.abort})}});function _S(e){if(!Rc.test(e))return!1;let t=e.replace(/[-_]/g,r=>r==="-"?"+":"/"),o=t.padEnd(Math.ceil(t.length/4)*4,"=");return bp(o)}var zp=g("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=Rc),ae.init(e,t),e._zod.bag.contentEncoding="base64url",e._zod.check=o=>{_S(o.value)||o.issues.push({code:"invalid_format",format:"base64url",input:o.value,inst:e,continue:!t.abort})}}),vp=g("$ZodE164",(e,t)=>{t.pattern??(t.pattern=zd),ae.init(e,t)});function bS(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));return!("typ"in n&&n?.typ!=="JWT"||!n.alg||t&&(!("alg"in n)||n.alg!==t))}catch{return!1}}var Rp=g("$ZodJWT",(e,t)=>{ae.init(e,t),e._zod.check=o=>{bS(o.value,t.alg)||o.issues.push({code:"invalid_format",format:"jwt",input:o.value,inst:e,continue:!t.abort})}}),wp=g("$ZodCustomStringFormat",(e,t)=>{ae.init(e,t),e._zod.check=o=>{t.fn(o.value)||o.issues.push({code:"invalid_format",format:t.format,input:o.value,inst:e,continue:!t.abort})}}),Cc=g("$ZodNumber",(e,t)=>{Y.init(e,t),e._zod.pattern=e._zod.bag.pattern??wc,e._zod.parse=(o,r)=>{if(t.coerce)try{o.value=Number(o.value)}catch{}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)?void 0:"Infinity":void 0;return o.issues.push({expected:"number",code:"invalid_type",input:n,inst:e,...s?{received:s}:{}}),o}}),xp=g("$ZodNumberFormat",(e,t)=>{Nd.init(e,t),Cc.init(e,t)}),Os=g("$ZodBoolean",(e,t)=>{Y.init(e,t),e._zod.pattern=Ed,e._zod.parse=(o,r)=>{if(t.coerce)try{o.value=!!o.value}catch{}let n=o.value;return typeof n=="boolean"||o.issues.push({expected:"boolean",code:"invalid_type",input:n,inst:e}),o}}),Ic=g("$ZodBigInt",(e,t)=>{Y.init(e,t),e._zod.pattern=Pd,e._zod.parse=(o,r)=>{if(t.coerce)try{o.value=BigInt(o.value)}catch{}return typeof o.value=="bigint"||o.issues.push({expected:"bigint",code:"invalid_type",input:o.value,inst:e}),o}}),Pp=g("$ZodBigIntFormat",(e,t)=>{qd.init(e,t),Ic.init(e,t)}),Tp=g("$ZodSymbol",(e,t)=>{Y.init(e,t),e._zod.parse=(o,r)=>{let n=o.value;return typeof n=="symbol"||o.issues.push({expected:"symbol",code:"invalid_type",input:n,inst:e}),o}}),Ep=g("$ZodUndefined",(e,t)=>{Y.init(e,t),e._zod.pattern=$d,e._zod.values=new Set([void 0]),e._zod.parse=(o,r)=>{let n=o.value;return typeof n>"u"||o.issues.push({expected:"undefined",code:"invalid_type",input:n,inst:e}),o}}),kp=g("$ZodNull",(e,t)=>{Y.init(e,t),e._zod.pattern=kd,e._zod.values=new Set([null]),e._zod.parse=(o,r)=>{let n=o.value;return n===null||o.issues.push({expected:"null",code:"invalid_type",input:n,inst:e}),o}}),$p=g("$ZodAny",(e,t)=>{Y.init(e,t),e._zod.parse=o=>o}),Cp=g("$ZodUnknown",(e,t)=>{Y.init(e,t),e._zod.parse=o=>o}),Ip=g("$ZodNever",(e,t)=>{Y.init(e,t),e._zod.parse=(o,r)=>(o.issues.push({expected:"never",code:"invalid_type",input:o.value,inst:e}),o)}),Op=g("$ZodVoid",(e,t)=>{Y.init(e,t),e._zod.parse=(o,r)=>{let n=o.value;return typeof n>"u"||o.issues.push({expected:"void",code:"invalid_type",input:n,inst:e}),o}}),Np=g("$ZodDate",(e,t)=>{Y.init(e,t),e._zod.parse=(o,r)=>{if(t.coerce)try{o.value=new Date(o.value)}catch{}let n=o.value,s=n instanceof Date;return s&&!Number.isNaN(n.getTime())||o.issues.push({expected:"date",code:"invalid_type",input:n,...s?{received:"Invalid Date"}:{},inst:e}),o}});function nS(e,t,o){e.issues.length&&t.issues.push(...Fe(o,e.issues)),t.value[o]=e.value}var qp=g("$ZodArray",(e,t)=>{Y.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 a=n[i],l=t.element._zod.run({value:a,issues:[]},r);l instanceof Promise?s.push(l.then(u=>nS(u,o,i))):nS(l,o,i)}return s.length?Promise.all(s).then(()=>o):o}});function $c(e,t,o,r,n,s){let i=o in r;if(e.issues.length){if(n&&s&&!i)return;t.issues.push(...Fe(o,e.issues))}if(!i&&!n){e.issues.length||t.issues.push({code:"invalid_type",expected:"nonoptional",input:void 0,path:[o]});return}e.value===void 0?i&&(t.value[o]=void 0):t.value[o]=e.value}function yS(e){let t=Object.keys(e.shape);for(let r of t)if(!e.shape?.[r]?._zod?.traits?.has("$ZodType"))throw new Error(`Invalid element at key "${r}": expected a Zod schema`);let o=Ku(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(o)}}function zS(e,t,o,r,n,s){let i=[],a=n.keySet,l=n.catchall._zod,u=l.def.type,d=l.optin==="optional",h=l.optout==="optional";for(let f in t){if(f==="__proto__"||a.has(f))continue;if(u==="never"){i.push(f);continue}let S=l.run({value:t[f],issues:[]},r);S instanceof Promise?e.push(S.then(y=>$c(y,o,f,t,d,h))):$c(S,o,f,t,d,h)}return i.length&&o.issues.push({code:"unrecognized_keys",keys:i,input:t,inst:s}),e.length?Promise.all(e).then(()=>o):o}var vS=g("$ZodObject",(e,t)=>{if(Y.init(e,t),!Object.getOwnPropertyDescriptor(t,"shape")?.get){let a=t.shape;Object.defineProperty(t,"shape",{get:()=>{let l={...a};return Object.defineProperty(t,"shape",{value:l}),l}})}let r=kr(()=>yS(t));te(e._zod,"propValues",()=>{let a=t.shape,l={};for(let u in a){let d=a[u]._zod;if(d.values){l[u]??(l[u]=new Set);for(let h of d.values)l[u].add(h)}}return l});let n=Uo,s=t.catchall,i;e._zod.parse=(a,l)=>{i??(i=r.value);let u=a.value;if(!n(u))return a.issues.push({expected:"object",code:"invalid_type",input:u,inst:e}),a;a.value={};let d=[],h=i.shape;for(let f of i.keys){let S=h[f],y=S._zod.optin==="optional",w=S._zod.optout==="optional",z=S._zod.run({value:u[f],issues:[]},l);z instanceof Promise?d.push(z.then(H=>$c(H,a,f,u,y,w))):$c(z,a,f,u,y,w)}return s?zS(d,u,a,l,r.value,e):d.length?Promise.all(d).then(()=>a):a}}),Mp=g("$ZodObjectJIT",(e,t)=>{vS.init(e,t);let o=e._zod.parse,r=kr(()=>yS(t)),n=f=>{let S=new Is(["shape","payload","ctx"]),y=r.value,w=N=>{let D=uc(N);return`shape[${D}]._zod.run({ value: input[${D}], issues: [] }, ctx)`};S.write("const input = payload.value;");let z=Object.create(null),H=0;for(let N of y.keys)z[N]=`key_${H++}`;S.write("const newResult = {};");for(let N of y.keys){let D=z[N],x=uc(N),v=f[N],Z=v?._zod?.optin==="optional",oe=v?._zod?.optout==="optional";S.write(`const ${D} = ${w(N)};`),Z&&oe?S.write(`
5
5
  if (${D}.issues.length) {
6
6
  if (${x} in input) {
7
7
  payload.issues = payload.issues.concat(${D}.issues.map(iss => ({
@@ -60,21 +60,21 @@ var Hy=Object.defineProperty;var Ut=(e,t)=>{for(var o in t)Hy(e,o,{get:t[o],enum
60
60
  }
61
61
  }
62
62
 
63
- `)}S.write("payload.value = newResult;"),S.write("return payload;");let W=S.compile();return(N,D)=>W(f,N,D)},s,i=Uo,a=!Lo.jitless,u=a&&Vu.value,d=t.catchall,h;e._zod.parse=(f,S)=>{h??(h=r.value);let y=f.value;return i(y)?a&&u&&S?.async===!1&&S.jitless!==!0?(s||(s=n(t.shape)),f=s(f,S),d?yS([],y,f,S,h,e):f):o(f,S):(f.issues.push({expected:"object",code:"invalid_type",input:y,inst:e}),f)}});function nS(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=>!ho(s));return n.length===1?(t.value=n[0].value,n[0]):(t.issues.push({code:"invalid_union",input:t.value,inst:o,errors:e.map(s=>s.issues.map(i=>Ae(i,r,ge())))}),t)}var Ns=g("$ZodUnion",(e,t)=>{Y.init(e,t),te(e._zod,"optin",()=>t.options.some(r=>r._zod.optin==="optional")?"optional":void 0),te(e._zod,"optout",()=>t.options.some(r=>r._zod.optout==="optional")?"optional":void 0),te(e._zod,"values",()=>{if(t.options.every(r=>r._zod.values))return new Set(t.options.flatMap(r=>Array.from(r._zod.values)))}),te(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=>Rs(n.source)).join("|")})$`)}});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 a of t.options){let l=a._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)}}return s?Promise.all(i).then(a=>nS(a,r,e,n)):nS(i,r,e,n)}});function sS(e,t,o,r){let n=e.filter(s=>s.issues.length===0);return n.length===1?(t.value=n[0].value,t):(n.length===0?t.issues.push({code:"invalid_union",input:t.value,inst:o,errors:e.map(s=>s.issues.map(i=>Ae(i,r,ge())))}):t.issues.push({code:"invalid_union",input:t.value,inst:o,errors:[],inclusive:!1}),t)}var Mp=g("$ZodXor",(e,t)=>{Ns.init(e,t),t.inclusive=!1;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 a of t.options){let l=a._zod.run({value:r.value,issues:[]},n);l instanceof Promise?(i.push(l),s=!0):i.push(l)}return s?Promise.all(i).then(a=>sS(a,r,e,n)):sS(i,r,e,n)}}),Ap=g("$ZodDiscriminatedUnion",(e,t)=>{t.inclusive=!1,Ns.init(e,t);let o=e._zod.parse;te(e._zod,"propValues",()=>{let n={};for(let s of t.options){let i=s._zod.propValues;if(!i||Object.keys(i).length===0)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(s)}"`);for(let[a,l]of Object.entries(i)){n[a]||(n[a]=new Set);for(let u of l)n[a].add(u)}}return n});let r=Er(()=>{let n=t.options,s=new Map;for(let i of n){let a=i._zod.propValues?.[t.discriminator];if(!a||a.size===0)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(i)}"`);for(let l of a){if(s.has(l))throw new Error(`Duplicate discriminator value "${String(l)}"`);s.set(l,i)}}return s});e._zod.parse=(n,s)=>{let i=n.value;if(!Uo(i))return n.issues.push({code:"invalid_type",expected:"object",input:i,inst:e}),n;let a=r.value.get(i?.[t.discriminator]);return a?a._zod.run(n,s):t.unionFallback||s.direction==="backward"?o(n,s):(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)}}),jp=g("$ZodIntersection",(e,t)=>{Y.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);return s instanceof Promise||i instanceof Promise?Promise.all([s,i]).then(([l,u])=>iS(o,l,u)):iS(o,s,i)}});function Yd(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(po(e)&&po(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=Yd(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=Yd(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 iS(e,t,o){let r=new Map,n;for(let a of t.issues)if(a.code==="unrecognized_keys"){n??(n=a);for(let l of a.keys)r.has(l)||r.set(l,{}),r.get(l).l=!0}else e.issues.push(a);for(let a of o.issues)if(a.code==="unrecognized_keys")for(let l of a.keys)r.has(l)||r.set(l,{}),r.get(l).r=!0;else e.issues.push(a);let s=[...r].filter(([,a])=>a.l&&a.r).map(([a])=>a);if(s.length&&n&&e.issues.push({...n,keys:s}),ho(e))return e;let i=Yd(t.value,o.value);if(!i.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(i.mergeErrorPath)}`);return e.value=i.data,e}var Ic=g("$ZodTuple",(e,t)=>{Y.init(e,t);let o=t.items;e._zod.parse=(r,n)=>{let s=r.value;if(!Array.isArray(s))return r.issues.push({input:s,inst:e,expected:"tuple",code:"invalid_type"}),r;r.value=[];let i=[],a=aS(o,"optin"),l=aS(o,"optout");if(!t.rest){if(s.length<a)return r.issues.push({code:"too_small",minimum:a,inclusive:!0,input:s,inst:e,origin:"array"}),r;s.length>o.length&&r.issues.push({code:"too_big",maximum:o.length,inclusive:!0,input:s,inst:e,origin:"array"})}let u=new Array(o.length);for(let d=0;d<o.length;d++){let h=o[d]._zod.run({value:s[d],issues:[]},n);h instanceof Promise?i.push(h.then(f=>{u[d]=f})):u[d]=h}if(t.rest){let d=o.length-1,h=s.slice(o.length);for(let f of h){d++;let S=t.rest._zod.run({value:f,issues:[]},n);S instanceof Promise?i.push(S.then(y=>cS(y,r,d))):cS(S,r,d)}}return i.length?Promise.all(i).then(()=>lS(u,r,o,s,l)):lS(u,r,o,s,l)}});function aS(e,t){for(let o=e.length-1;o>=0;o--)if(e[o]._zod[t]!=="optional")return o+1;return 0}function cS(e,t,o){e.issues.length&&t.issues.push(...Fe(o,e.issues)),t.value[o]=e.value}function lS(e,t,o,r,n){for(let s=0;s<o.length;s++){let i=e[s],a=s<r.length;if(i.issues.length){if(!a&&s>=n){t.value.length=s;break}t.issues.push(...Fe(s,i.issues))}t.value[s]=i.value}for(let s=t.value.length-1;s>=r.length&&(o[s]._zod.optout==="optional"&&t.value[s]===void 0);s--)t.value.length=s;return t}var Lp=g("$ZodRecord",(e,t)=>{Y.init(e,t),e._zod.parse=(o,r)=>{let n=o.value;if(!po(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 a=new Set;for(let u of i)if(typeof u=="string"||typeof u=="number"||typeof u=="symbol"){a.add(typeof u=="number"?u.toString():u);let d=t.keyType._zod.run({value:u,issues:[]},r);if(d instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(d.issues.length){o.issues.push({code:"invalid_key",origin:"record",issues:d.issues.map(S=>Ae(S,r,ge())),input:u,path:[u],inst:e});continue}let h=d.value,f=t.valueType._zod.run({value:n[u],issues:[]},r);f instanceof Promise?s.push(f.then(S=>{S.issues.length&&o.issues.push(...Fe(u,S.issues)),o.value[h]=S.value})):(f.issues.length&&o.issues.push(...Fe(u,f.issues)),o.value[h]=f.value)}let l;for(let u in n)a.has(u)||(l=l??[],l.push(u));l&&l.length>0&&o.issues.push({code:"unrecognized_keys",input:n,inst:e,keys:l})}else{o.value={};for(let a of Reflect.ownKeys(n)){if(a==="__proto__"||!Object.prototype.propertyIsEnumerable.call(n,a))continue;let l=t.keyType._zod.run({value:a,issues:[]},r);if(l instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(typeof a=="string"&&Rc.test(a)&&l.issues.length){let h=t.keyType._zod.run({value:Number(a),issues:[]},r);if(h instanceof Promise)throw new Error("Async schemas not supported in object keys currently");h.issues.length===0&&(l=h)}if(l.issues.length){t.mode==="loose"?o.value[a]=n[a]:o.issues.push({code:"invalid_key",origin:"record",issues:l.issues.map(h=>Ae(h,r,ge())),input:a,path:[a],inst:e});continue}let d=t.valueType._zod.run({value:n[a],issues:[]},r);d instanceof Promise?s.push(d.then(h=>{h.issues.length&&o.issues.push(...Fe(a,h.issues)),o.value[l.value]=h.value})):(d.issues.length&&o.issues.push(...Fe(a,d.issues)),o.value[l.value]=d.value)}}return s.length?Promise.all(s).then(()=>o):o}}),Up=g("$ZodMap",(e,t)=>{Y.init(e,t),e._zod.parse=(o,r)=>{let n=o.value;if(!(n instanceof Map))return o.issues.push({expected:"map",code:"invalid_type",input:n,inst:e}),o;let s=[];o.value=new Map;for(let[i,a]of n){let l=t.keyType._zod.run({value:i,issues:[]},r),u=t.valueType._zod.run({value:a,issues:[]},r);l instanceof Promise||u instanceof Promise?s.push(Promise.all([l,u]).then(([d,h])=>{uS(d,h,o,i,n,e,r)})):uS(l,u,o,i,n,e,r)}return s.length?Promise.all(s).then(()=>o):o}});function uS(e,t,o,r,n,s,i){e.issues.length&&(ws.has(typeof r)?o.issues.push(...Fe(r,e.issues)):o.issues.push({code:"invalid_key",origin:"map",input:n,inst:s,issues:e.issues.map(a=>Ae(a,i,ge()))})),t.issues.length&&(ws.has(typeof r)?o.issues.push(...Fe(r,t.issues)):o.issues.push({origin:"map",code:"invalid_element",input:n,inst:s,key:r,issues:t.issues.map(a=>Ae(a,i,ge()))})),o.value.set(e.value,t.value)}var Zp=g("$ZodSet",(e,t)=>{Y.init(e,t),e._zod.parse=(o,r)=>{let n=o.value;if(!(n instanceof Set))return o.issues.push({input:n,inst:e,expected:"set",code:"invalid_type"}),o;let s=[];o.value=new Set;for(let i of n){let a=t.valueType._zod.run({value:i,issues:[]},r);a instanceof Promise?s.push(a.then(l=>dS(l,o))):dS(a,o)}return s.length?Promise.all(s).then(()=>o):o}});function dS(e,t){e.issues.length&&t.issues.push(...e.issues),t.value.add(e.value)}var Dp=g("$ZodEnum",(e,t)=>{Y.init(e,t);let o=vs(t.entries),r=new Set(o);e._zod.values=r,e._zod.pattern=new RegExp(`^(${o.filter(n=>ws.has(typeof n)).map(n=>typeof n=="string"?it(n):n.toString()).join("|")})$`),e._zod.parse=(n,s)=>{let i=n.value;return r.has(i)||n.issues.push({code:"invalid_value",values:o,input:i,inst:e}),n}}),Fp=g("$ZodLiteral",(e,t)=>{if(Y.init(e,t),t.values.length===0)throw new 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"?it(r):r?it(r.toString()):String(r)).join("|")})$`),e._zod.parse=(r,n)=>{let s=r.value;return o.has(s)||r.issues.push({code:"invalid_value",values:t.values,input:s,inst:e}),r}}),Hp=g("$ZodFile",(e,t)=>{Y.init(e,t),e._zod.parse=(o,r)=>{let n=o.value;return n instanceof File||o.issues.push({expected:"file",code:"invalid_type",input:n,inst:e}),o}}),Vp=g("$ZodTransform",(e,t)=>{Y.init(e,t),e._zod.optin="optional",e._zod.parse=(o,r)=>{if(r.direction==="backward")throw new co(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 ut;return o.value=n,o.fallback=!0,o}});function pS(e,t){return t===void 0&&(e.issues.length||e.fallback)?{issues:[],value:void 0}:e}var Oc=g("$ZodOptional",(e,t)=>{Y.init(e,t),e._zod.optin="optional",e._zod.optout="optional",te(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),te(e._zod,"pattern",()=>{let o=t.innerType._zod.pattern;return o?new RegExp(`^(${Rs(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);return s instanceof Promise?s.then(i=>pS(i,n)):pS(s,n)}return o.value===void 0?o:t.innerType._zod.run(o,r)}}),Jp=g("$ZodExactOptional",(e,t)=>{Oc.init(e,t),te(e._zod,"values",()=>t.innerType._zod.values),te(e._zod,"pattern",()=>t.innerType._zod.pattern),e._zod.parse=(o,r)=>t.innerType._zod.run(o,r)}),Bp=g("$ZodNullable",(e,t)=>{Y.init(e,t),te(e._zod,"optin",()=>t.innerType._zod.optin),te(e._zod,"optout",()=>t.innerType._zod.optout),te(e._zod,"pattern",()=>{let o=t.innerType._zod.pattern;return o?new RegExp(`^(${Rs(o.source)}|null)$`):void 0}),te(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(o,r)=>o.value===null?o:t.innerType._zod.run(o,r)}),Wp=g("$ZodDefault",(e,t)=>{Y.init(e,t),e._zod.optin="optional",te(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);return n instanceof Promise?n.then(s=>hS(s,t)):hS(n,t)}});function hS(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}var Kp=g("$ZodPrefault",(e,t)=>{Y.init(e,t),e._zod.optin="optional",te(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(o,r)=>(r.direction==="backward"||o.value===void 0&&(o.value=t.defaultValue),t.innerType._zod.run(o,r))}),Gp=g("$ZodNonOptional",(e,t)=>{Y.init(e,t),te(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);return n instanceof Promise?n.then(s=>mS(s,e)):mS(n,e)}});function mS(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:"invalid_type",expected:"nonoptional",input:e.value,inst:t}),e}var Yp=g("$ZodSuccess",(e,t)=>{Y.init(e,t),e._zod.parse=(o,r)=>{if(r.direction==="backward")throw new co("ZodSuccess");let n=t.innerType._zod.run(o,r);return n instanceof Promise?n.then(s=>(o.value=s.issues.length===0,o)):(o.value=n.issues.length===0,o)}}),Xp=g("$ZodCatch",(e,t)=>{Y.init(e,t),e._zod.optin="optional",te(e._zod,"optout",()=>t.innerType._zod.optout),te(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);return n instanceof Promise?n.then(s=>(o.value=s.value,s.issues.length&&(o.value=t.catchValue({...o,error:{issues:s.issues.map(i=>Ae(i,r,ge()))},input:o.value}),o.issues=[],o.fallback=!0),o)):(o.value=n.value,n.issues.length&&(o.value=t.catchValue({...o,error:{issues:n.issues.map(s=>Ae(s,r,ge()))},input:o.value}),o.issues=[],o.fallback=!0),o)}}),Qp=g("$ZodNaN",(e,t)=>{Y.init(e,t),e._zod.parse=(o,r)=>((typeof o.value!="number"||!Number.isNaN(o.value))&&o.issues.push({input:o.value,inst:e,expected:"nan",code:"invalid_type"}),o)}),Nc=g("$ZodPipe",(e,t)=>{Y.init(e,t),te(e._zod,"values",()=>t.in._zod.values),te(e._zod,"optin",()=>t.in._zod.optin),te(e._zod,"optout",()=>t.out._zod.optout),te(e._zod,"propValues",()=>t.in._zod.propValues),e._zod.parse=(o,r)=>{if(r.direction==="backward"){let s=t.out._zod.run(o,r);return s instanceof Promise?s.then(i=>Pc(i,t.in,r)):Pc(s,t.in,r)}let n=t.in._zod.run(o,r);return n instanceof Promise?n.then(s=>Pc(s,t.out,r)):Pc(n,t.out,r)}});function Pc(e,t,o){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues,fallback:e.fallback},o)}var qs=g("$ZodCodec",(e,t)=>{Y.init(e,t),te(e._zod,"values",()=>t.in._zod.values),te(e._zod,"optin",()=>t.in._zod.optin),te(e._zod,"optout",()=>t.out._zod.optout),te(e._zod,"propValues",()=>t.in._zod.propValues),e._zod.parse=(o,r)=>{if((r.direction||"forward")==="forward"){let s=t.in._zod.run(o,r);return s instanceof Promise?s.then(i=>Tc(i,t,r)):Tc(s,t,r)}else{let s=t.out._zod.run(o,r);return s instanceof Promise?s.then(i=>Tc(i,t,r)):Tc(s,t,r)}}});function Tc(e,t,o){if(e.issues.length)return e.aborted=!0,e;if((o.direction||"forward")==="forward"){let n=t.transform(e.value,e);return n instanceof Promise?n.then(s=>Ec(e,s,t.out,o)):Ec(e,n,t.out,o)}else{let n=t.reverseTransform(e.value,e);return n instanceof Promise?n.then(s=>Ec(e,s,t.in,o)):Ec(e,n,t.in,o)}}function Ec(e,t,o,r){return e.issues.length?(e.aborted=!0,e):o._zod.run({value:t,issues:e.issues},r)}var eh=g("$ZodPreprocess",(e,t)=>{Nc.init(e,t)}),th=g("$ZodReadonly",(e,t)=>{Y.init(e,t),te(e._zod,"propValues",()=>t.innerType._zod.propValues),te(e._zod,"values",()=>t.innerType._zod.values),te(e._zod,"optin",()=>t.innerType?._zod?.optin),te(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);return n instanceof Promise?n.then(fS):fS(n)}});function fS(e){return e.value=Object.freeze(e.value),e}var oh=g("$ZodTemplateLiteral",(e,t)=>{Y.init(e,t);let o=[];for(let r of t.parts)if(typeof r=="object"&&r!==null){if(!r._zod.pattern)throw new Error(`Invalid template literal part, no pattern found: ${[...r._zod.traits].shift()}`);let n=r._zod.pattern instanceof RegExp?r._zod.pattern.source:r._zod.pattern;if(!n)throw new Error(`Invalid template literal part: ${r._zod.traits}`);let s=n.startsWith("^")?1:0,i=n.endsWith("$")?n.length-1:n.length;o.push(n.slice(s,i))}else if(r===null||Bu.has(typeof r))o.push(it(`${r}`));else throw new Error(`Invalid template literal part: ${r}`);e._zod.pattern=new RegExp(`^${o.join("")}$`),e._zod.parse=(r,n)=>typeof r.value!="string"?(r.issues.push({input:r.value,inst:e,expected:"string",code:"invalid_type"}),r):(e._zod.pattern.lastIndex=0,e._zod.pattern.test(r.value)||r.issues.push({input:r.value,inst:e,code:"invalid_format",format:t.format??"template_literal",pattern:e._zod.pattern.source}),r)}),rh=g("$ZodFunction",(e,t)=>(Y.init(e,t),e._def=t,e._zod.def=t,e.implement=o=>{if(typeof o!="function")throw new Error("implement() must be called with a function");return function(...r){let n=e._def.input?pc(e._def.input,r):r,s=Reflect.apply(o,this,n);return e._def.output?pc(e._def.output,s):s}},e.implementAsync=o=>{if(typeof o!="function")throw new Error("implementAsync() must be called with a function");return async function(...r){let n=e._def.input?await hc(e._def.input,r):r,s=await Reflect.apply(o,this,n);return e._def.output?await hc(e._def.output,s):s}},e._zod.parse=(o,r)=>typeof o.value!="function"?(o.issues.push({code:"invalid_type",expected:"function",input:o.value,inst:e}),o):(e._def.output&&e._def.output._zod.def.type==="promise"?o.value=e.implementAsync(o.value):o.value=e.implement(o.value),o),e.input=(...o)=>{let r=e.constructor;return Array.isArray(o[0])?new r({type:"function",input:new Ic({type:"tuple",items:o[0],rest:o[1]}),output:e._def.output}):new r({type:"function",input:o[0],output:e._def.output})},e.output=o=>{let r=e.constructor;return new r({type:"function",input:e._def.input,output:o})},e)),nh=g("$ZodPromise",(e,t)=>{Y.init(e,t),e._zod.parse=(o,r)=>Promise.resolve(o.value).then(n=>t.innerType._zod.run({value:n,issues:[]},r))}),sh=g("$ZodLazy",(e,t)=>{Y.init(e,t),te(e._zod,"innerType",()=>{let o=t;return o._cachedInner||(o._cachedInner=t.getter()),o._cachedInner}),te(e._zod,"pattern",()=>e._zod.innerType?._zod?.pattern),te(e._zod,"propValues",()=>e._zod.innerType?._zod?.propValues),te(e._zod,"optin",()=>e._zod.innerType?._zod?.optin??void 0),te(e._zod,"optout",()=>e._zod.innerType?._zod?.optout??void 0),e._zod.parse=(o,r)=>e._zod.innerType._zod.run(o,r)}),ih=g("$ZodCustom",(e,t)=>{le.init(e,t),Y.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=>gS(s,o,r,e));gS(n,o,r,e)}});function gS(e,t,o,r){if(!e){let n={code:"custom",input:o,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(n.params=r._zod.def.params),t.issues.push(kr(n))}}var Ms={};Ut(Ms,{en:()=>qc});var cv=()=>{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=Xu(n.input),a=r[i]??i;return`Invalid input: expected ${s}, received ${a}`}case"invalid_value":return n.values.length===1?`Invalid input: expected ${dc(n.values[0])}`:`Invalid option: expected one of ${cc(n.values,"|")}`;case"too_big":{let s=n.inclusive?"<=":"<",i=t(n.origin);return i?`Too big: expected ${n.origin??"value"} to have ${s}${n.maximum.toString()} ${i.unit??"elements"}`:`Too big: expected ${n.origin??"value"} to be ${s}${n.maximum.toString()}`}case"too_small":{let s=n.inclusive?">=":">",i=t(n.origin);return i?`Too small: expected ${n.origin} to have ${s}${n.minimum.toString()} ${i.unit}`:`Too small: expected ${n.origin} to be ${s}${n.minimum.toString()}`}case"invalid_format":{let s=n;return s.format==="starts_with"?`Invalid string: must start with "${s.prefix}"`:s.format==="ends_with"?`Invalid string: must end with "${s.suffix}"`:s.format==="includes"?`Invalid string: must include "${s.includes}"`:s.format==="regex"?`Invalid string: must match pattern ${s.pattern}`:`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":""}: ${cc(n.keys,", ")}`;case"invalid_key":return`Invalid key in ${n.origin}`;case"invalid_union":return n.options&&Array.isArray(n.options)&&n.options.length>0?`Invalid discriminator value. Expected ${n.options.map(i=>`'${i}'`).join(" | ")}`:"Invalid input";case"invalid_element":return`Invalid value in ${n.origin}`;default:return"Invalid input"}}};function qc(){return{localeError:cv()}}var vS,ah=Symbol("ZodOutput"),ch=Symbol("ZodInput"),Mc=class{constructor(){this._map=new WeakMap,this._idmap=new Map}add(t,...o){let r=o[0];return this._map.set(t,r),r&&typeof r=="object"&&"id"in r&&this._idmap.set(r.id,t),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(t){let o=this._map.get(t);return o&&typeof o=="object"&&"id"in o&&this._idmap.delete(o.id),this._map.delete(t),this}get(t){let o=t._zod.parent;if(o){let r={...this.get(o)??{}};delete r.id;let n={...r,...this._map.get(t)};return Object.keys(n).length?n:void 0}return this._map.get(t)}has(t){return this._map.has(t)}};function Ac(){return new Mc}(vS=globalThis).__zod_globalRegistry??(vS.__zod_globalRegistry=Ac());var ve=globalThis.__zod_globalRegistry;function lh(e,t){return new e({type:"string",...P(t)})}function uh(e,t){return new e({type:"string",coerce:!0,...P(t)})}function jc(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...P(t)})}function As(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...P(t)})}function Lc(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...P(t)})}function Uc(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...P(t)})}function Zc(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...P(t)})}function Dc(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...P(t)})}function js(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...P(t)})}function Fc(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...P(t)})}function Hc(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...P(t)})}function Vc(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...P(t)})}function Jc(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...P(t)})}function Bc(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...P(t)})}function Wc(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...P(t)})}function Kc(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...P(t)})}function Gc(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...P(t)})}function Yc(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...P(t)})}function dh(e,t){return new e({type:"string",format:"mac",check:"string_format",abort:!1,...P(t)})}function Xc(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...P(t)})}function Qc(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...P(t)})}function el(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...P(t)})}function tl(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...P(t)})}function ol(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...P(t)})}function rl(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...P(t)})}var ph={Any:null,Minute:-1,Second:0,Millisecond:3,Microsecond:6};function hh(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...P(t)})}function mh(e,t){return new e({type:"string",format:"date",check:"string_format",...P(t)})}function fh(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...P(t)})}function gh(e,t){return new e({type:"string",format:"duration",check:"string_format",...P(t)})}function Sh(e,t){return new e({type:"number",checks:[],...P(t)})}function _h(e,t){return new e({type:"number",coerce:!0,checks:[],...P(t)})}function bh(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...P(t)})}function yh(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"float32",...P(t)})}function zh(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"float64",...P(t)})}function vh(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"int32",...P(t)})}function Rh(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"uint32",...P(t)})}function wh(e,t){return new e({type:"boolean",...P(t)})}function xh(e,t){return new e({type:"boolean",coerce:!0,...P(t)})}function Ph(e,t){return new e({type:"bigint",...P(t)})}function Th(e,t){return new e({type:"bigint",coerce:!0,...P(t)})}function Eh(e,t){return new e({type:"bigint",check:"bigint_format",abort:!1,format:"int64",...P(t)})}function kh(e,t){return new e({type:"bigint",check:"bigint_format",abort:!1,format:"uint64",...P(t)})}function $h(e,t){return new e({type:"symbol",...P(t)})}function Ch(e,t){return new e({type:"undefined",...P(t)})}function Ih(e,t){return new e({type:"null",...P(t)})}function Oh(e){return new e({type:"any"})}function Nh(e){return new e({type:"unknown"})}function qh(e,t){return new e({type:"never",...P(t)})}function Mh(e,t){return new e({type:"void",...P(t)})}function Ah(e,t){return new e({type:"date",...P(t)})}function jh(e,t){return new e({type:"date",coerce:!0,...P(t)})}function Lh(e,t){return new e({type:"nan",...P(t)})}function Pt(e,t){return new wc({check:"less_than",...P(t),value:e,inclusive:!1})}function Xe(e,t){return new wc({check:"less_than",...P(t),value:e,inclusive:!0})}function Tt(e,t){return new xc({check:"greater_than",...P(t),value:e,inclusive:!1})}function je(e,t){return new xc({check:"greater_than",...P(t),value:e,inclusive:!0})}function nl(e){return Tt(0,e)}function sl(e){return Pt(0,e)}function il(e){return Xe(0,e)}function al(e){return je(0,e)}function mo(e,t){return new Id({check:"multiple_of",...P(t),value:e})}function fo(e,t){return new qd({check:"max_size",...P(t),maximum:e})}function Et(e,t){return new Md({check:"min_size",...P(t),minimum:e})}function Fo(e,t){return new Ad({check:"size_equals",...P(t),size:e})}function Ho(e,t){return new jd({check:"max_length",...P(t),maximum:e})}function Dt(e,t){return new Ld({check:"min_length",...P(t),minimum:e})}function Vo(e,t){return new Ud({check:"length_equals",...P(t),length:e})}function qr(e,t){return new Zd({check:"string_format",format:"regex",...P(t),pattern:e})}function Mr(e){return new Dd({check:"string_format",format:"lowercase",...P(e)})}function Ar(e){return new Fd({check:"string_format",format:"uppercase",...P(e)})}function jr(e,t){return new Hd({check:"string_format",format:"includes",...P(t),includes:e})}function Lr(e,t){return new Vd({check:"string_format",format:"starts_with",...P(t),prefix:e})}function Ur(e,t){return new Jd({check:"string_format",format:"ends_with",...P(t),suffix:e})}function cl(e,t,o){return new Bd({check:"property",property:e,schema:t,...P(o)})}function Zr(e,t){return new Wd({check:"mime_type",mime:e,...P(t)})}function dt(e){return new Kd({check:"overwrite",tx:e})}function Dr(e){return dt(t=>t.normalize(e))}function Fr(){return dt(e=>e.trim())}function Hr(){return dt(e=>e.toLowerCase())}function Vr(){return dt(e=>e.toUpperCase())}function Jr(){return dt(e=>Hu(e))}function Uh(e,t,o){return new e({type:"array",element:t,...P(o)})}function uv(e,t,o){return new e({type:"union",options:t,...P(o)})}function dv(e,t,o){return new e({type:"union",options:t,inclusive:!1,...P(o)})}function pv(e,t,o,r){return new e({type:"union",options:o,discriminator:t,...P(r)})}function hv(e,t,o){return new e({type:"intersection",left:t,right:o})}function mv(e,t,o,r){let n=o instanceof Y,s=n?r:o,i=n?o:null;return new e({type:"tuple",items:t,rest:i,...P(s)})}function fv(e,t,o,r){return new e({type:"record",keyType:t,valueType:o,...P(r)})}function gv(e,t,o,r){return new e({type:"map",keyType:t,valueType:o,...P(r)})}function Sv(e,t,o){return new e({type:"set",valueType:t,...P(o)})}function _v(e,t,o){let r=Array.isArray(t)?Object.fromEntries(t.map(n=>[n,n])):t;return new e({type:"enum",entries:r,...P(o)})}function bv(e,t,o){return new e({type:"enum",entries:t,...P(o)})}function yv(e,t,o){return new e({type:"literal",values:Array.isArray(t)?t:[t],...P(o)})}function Zh(e,t){return new e({type:"file",...P(t)})}function zv(e,t){return new e({type:"transform",transform:t})}function vv(e,t){return new e({type:"optional",innerType:t})}function Rv(e,t){return new e({type:"nullable",innerType:t})}function wv(e,t,o){return new e({type:"default",innerType:t,get defaultValue(){return typeof o=="function"?o():Ju(o)}})}function xv(e,t,o){return new e({type:"nonoptional",innerType:t,...P(o)})}function Pv(e,t){return new e({type:"success",innerType:t})}function Tv(e,t,o){return new e({type:"catch",innerType:t,catchValue:typeof o=="function"?o:()=>o})}function Ev(e,t,o){return new e({type:"pipe",in:t,out:o})}function kv(e,t){return new e({type:"readonly",innerType:t})}function $v(e,t,o){return new e({type:"template_literal",parts:t,...P(o)})}function Cv(e,t){return new e({type:"lazy",getter:t})}function Iv(e,t){return new e({type:"promise",innerType:t})}function Dh(e,t,o){let r=P(o);return r.abort??(r.abort=!0),new e({type:"custom",check:"custom",fn:t,...r})}function Fh(e,t,o){return new e({type:"custom",check:"custom",fn:t,...P(o)})}function Hh(e,t){let o=RS(r=>(r.addIssue=n=>{if(typeof n=="string")r.issues.push(kr(n,r.value,o._zod.def));else{let s=n;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(kr(s))}},e(r.value,r)),t);return o}function RS(e,t){let o=new le({check:"custom",...P(t)});return o._zod.check=e,o}function Vh(e){let t=new le({check:"describe"});return t._zod.onattach=[o=>{let r=ve.get(o)??{};ve.add(o,{...r,description:e})}],t._zod.check=()=>{},t}function Jh(e){let t=new le({check:"meta"});return t._zod.onattach=[o=>{let r=ve.get(o)??{};ve.add(o,{...r,...e})}],t._zod.check=()=>{},t}function Bh(e,t){let o=P(t),r=o.truthy??["true","1","yes","on","y","enabled"],n=o.falsy??["false","0","no","off","n","disabled"];o.case!=="sensitive"&&(r=r.map(S=>typeof S=="string"?S.toLowerCase():S),n=n.map(S=>typeof S=="string"?S.toLowerCase():S));let s=new Set(r),i=new Set(n),a=e.Codec??qs,l=e.Boolean??Os,u=e.String??Do,d=new u({type:"string",error:o.error}),h=new l({type:"boolean",error:o.error}),f=new a({type:"pipe",in:d,out:h,transform:((S,y)=>{let w=S;return o.case!=="sensitive"&&(w=w.toLowerCase()),s.has(w)?!0:i.has(w)?!1:(y.issues.push({code:"invalid_value",expected:"stringbool",values:[...s,...i],input:y.value,inst:f,continue:!1}),{})}),reverseTransform:((S,y)=>S===!0?r[0]||"true":n[0]||"false"),error:o.error});return f}function Br(e,t,o,r={}){let n=P(r),s={...P(r),check:"string_format",type:"string",format:t,fn:typeof o=="function"?o:a=>o.test(a),...n};return o instanceof RegExp&&(s.pattern=o),new e(s)}function go(e){let t=e?.target??"draft-2020-12";return t==="draft-4"&&(t="draft-04"),t==="draft-7"&&(t="draft-07"),{processors:e.processors??{},metadataRegistry:e?.metadata??ve,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 ne(e,t,o={path:[],schemaPath:[]}){var r;let n=e._zod.def,s=t.seen.get(e);if(s)return s.count++,o.schemaPath.includes(e)&&(s.cycle=o.path),s.schema;let i={schema:{},count:1,cycle:void 0,path:o.path};t.seen.set(e,i);let a=e._zod.toJSONSchema?.();if(a)i.schema=a;else{let d={...o,schemaPath:[...o.schemaPath,e],path:o.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,i.schema,d);else{let f=i.schema,S=t.processors[n.type];if(!S)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${n.type}`);S(e,t,f,d)}let h=e._zod.parent;h&&(i.ref||(i.ref=h),ne(h,t,d),t.seen.get(h).isParent=!0)}let l=t.metadataRegistry.get(e);return l&&Object.assign(i.schema,l),t.io==="input"&&Le(e)&&(delete i.schema.examples,delete i.schema.default),t.io==="input"&&"_prefault"in i.schema&&((r=i.schema).default??(r.default=i.schema._prefault)),delete i.schema._prefault,t.seen.get(e).schema}function So(e,t){let o=e.seen.get(t);if(!o)throw new Error("Unprocessed schema. This is a bug in Zod.");let r=new Map;for(let i of e.seen.entries()){let a=e.metadataRegistry.get(i[0])?.id;if(a){let l=r.get(a);if(l&&l!==i[0])throw new Error(`Duplicate schema id "${a}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);r.set(a,i[0])}}let n=i=>{let a=e.target==="draft-2020-12"?"$defs":"definitions";if(e.external){let h=e.external.registry.get(i[0])?.id,f=e.external.uri??(y=>y);if(h)return{ref:f(h)};let S=i[1].defId??i[1].schema.id??`schema${e.counter++}`;return i[1].defId=S,{defId:S,ref:`${f("__shared")}#/${a}/${S}`}}if(i[1]===o)return{ref:"#"};let u=`#/${a}/`,d=i[1].schema.id??`__schema${e.counter++}`;return{defId:d,ref:u+d}},s=i=>{if(i[1].schema.$ref)return;let a=i[1],{ref:l,defId:u}=n(i);a.def={...a.schema},u&&(a.defId=u);let d=a.schema;for(let h in d)delete d[h];d.$ref=l};if(e.cycles==="throw")for(let i of e.seen.entries()){let a=i[1];if(a.cycle)throw new Error(`Cycle detected: #/${a.cycle?.join("/")}/<root>
63
+ `)}S.write("payload.value = newResult;"),S.write("return payload;");let W=S.compile();return(N,D)=>W(f,N,D)},s,i=Uo,a=!Lo.jitless,u=a&&Ju.value,d=t.catchall,h;e._zod.parse=(f,S)=>{h??(h=r.value);let y=f.value;return i(y)?a&&u&&S?.async===!1&&S.jitless!==!0?(s||(s=n(t.shape)),f=s(f,S),d?zS([],y,f,S,h,e):f):o(f,S):(f.issues.push({expected:"object",code:"invalid_type",input:y,inst:e}),f)}});function sS(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=>!ho(s));return n.length===1?(t.value=n[0].value,n[0]):(t.issues.push({code:"invalid_union",input:t.value,inst:o,errors:e.map(s=>s.issues.map(i=>Ae(i,r,ge())))}),t)}var Ns=g("$ZodUnion",(e,t)=>{Y.init(e,t),te(e._zod,"optin",()=>t.options.some(r=>r._zod.optin==="optional")?"optional":void 0),te(e._zod,"optout",()=>t.options.some(r=>r._zod.optout==="optional")?"optional":void 0),te(e._zod,"values",()=>{if(t.options.every(r=>r._zod.values))return new Set(t.options.flatMap(r=>Array.from(r._zod.values)))}),te(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=>Rs(n.source)).join("|")})$`)}});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 a of t.options){let l=a._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)}}return s?Promise.all(i).then(a=>sS(a,r,e,n)):sS(i,r,e,n)}});function iS(e,t,o,r){let n=e.filter(s=>s.issues.length===0);return n.length===1?(t.value=n[0].value,t):(n.length===0?t.issues.push({code:"invalid_union",input:t.value,inst:o,errors:e.map(s=>s.issues.map(i=>Ae(i,r,ge())))}):t.issues.push({code:"invalid_union",input:t.value,inst:o,errors:[],inclusive:!1}),t)}var Ap=g("$ZodXor",(e,t)=>{Ns.init(e,t),t.inclusive=!1;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 a of t.options){let l=a._zod.run({value:r.value,issues:[]},n);l instanceof Promise?(i.push(l),s=!0):i.push(l)}return s?Promise.all(i).then(a=>iS(a,r,e,n)):iS(i,r,e,n)}}),jp=g("$ZodDiscriminatedUnion",(e,t)=>{t.inclusive=!1,Ns.init(e,t);let o=e._zod.parse;te(e._zod,"propValues",()=>{let n={};for(let s of t.options){let i=s._zod.propValues;if(!i||Object.keys(i).length===0)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(s)}"`);for(let[a,l]of Object.entries(i)){n[a]||(n[a]=new Set);for(let u of l)n[a].add(u)}}return n});let r=kr(()=>{let n=t.options,s=new Map;for(let i of n){let a=i._zod.propValues?.[t.discriminator];if(!a||a.size===0)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(i)}"`);for(let l of a){if(s.has(l))throw new Error(`Duplicate discriminator value "${String(l)}"`);s.set(l,i)}}return s});e._zod.parse=(n,s)=>{let i=n.value;if(!Uo(i))return n.issues.push({code:"invalid_type",expected:"object",input:i,inst:e}),n;let a=r.value.get(i?.[t.discriminator]);return a?a._zod.run(n,s):t.unionFallback||s.direction==="backward"?o(n,s):(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)}}),Lp=g("$ZodIntersection",(e,t)=>{Y.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);return s instanceof Promise||i instanceof Promise?Promise.all([s,i]).then(([l,u])=>aS(o,l,u)):aS(o,s,i)}});function Xd(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(po(e)&&po(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=Xd(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=Xd(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 aS(e,t,o){let r=new Map,n;for(let a of t.issues)if(a.code==="unrecognized_keys"){n??(n=a);for(let l of a.keys)r.has(l)||r.set(l,{}),r.get(l).l=!0}else e.issues.push(a);for(let a of o.issues)if(a.code==="unrecognized_keys")for(let l of a.keys)r.has(l)||r.set(l,{}),r.get(l).r=!0;else e.issues.push(a);let s=[...r].filter(([,a])=>a.l&&a.r).map(([a])=>a);if(s.length&&n&&e.issues.push({...n,keys:s}),ho(e))return e;let i=Xd(t.value,o.value);if(!i.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(i.mergeErrorPath)}`);return e.value=i.data,e}var Oc=g("$ZodTuple",(e,t)=>{Y.init(e,t);let o=t.items;e._zod.parse=(r,n)=>{let s=r.value;if(!Array.isArray(s))return r.issues.push({input:s,inst:e,expected:"tuple",code:"invalid_type"}),r;r.value=[];let i=[],a=cS(o,"optin"),l=cS(o,"optout");if(!t.rest){if(s.length<a)return r.issues.push({code:"too_small",minimum:a,inclusive:!0,input:s,inst:e,origin:"array"}),r;s.length>o.length&&r.issues.push({code:"too_big",maximum:o.length,inclusive:!0,input:s,inst:e,origin:"array"})}let u=new Array(o.length);for(let d=0;d<o.length;d++){let h=o[d]._zod.run({value:s[d],issues:[]},n);h instanceof Promise?i.push(h.then(f=>{u[d]=f})):u[d]=h}if(t.rest){let d=o.length-1,h=s.slice(o.length);for(let f of h){d++;let S=t.rest._zod.run({value:f,issues:[]},n);S instanceof Promise?i.push(S.then(y=>lS(y,r,d))):lS(S,r,d)}}return i.length?Promise.all(i).then(()=>uS(u,r,o,s,l)):uS(u,r,o,s,l)}});function cS(e,t){for(let o=e.length-1;o>=0;o--)if(e[o]._zod[t]!=="optional")return o+1;return 0}function lS(e,t,o){e.issues.length&&t.issues.push(...Fe(o,e.issues)),t.value[o]=e.value}function uS(e,t,o,r,n){for(let s=0;s<o.length;s++){let i=e[s],a=s<r.length;if(i.issues.length){if(!a&&s>=n){t.value.length=s;break}t.issues.push(...Fe(s,i.issues))}t.value[s]=i.value}for(let s=t.value.length-1;s>=r.length&&(o[s]._zod.optout==="optional"&&t.value[s]===void 0);s--)t.value.length=s;return t}var Up=g("$ZodRecord",(e,t)=>{Y.init(e,t),e._zod.parse=(o,r)=>{let n=o.value;if(!po(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 a=new Set;for(let u of i)if(typeof u=="string"||typeof u=="number"||typeof u=="symbol"){a.add(typeof u=="number"?u.toString():u);let d=t.keyType._zod.run({value:u,issues:[]},r);if(d instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(d.issues.length){o.issues.push({code:"invalid_key",origin:"record",issues:d.issues.map(S=>Ae(S,r,ge())),input:u,path:[u],inst:e});continue}let h=d.value,f=t.valueType._zod.run({value:n[u],issues:[]},r);f instanceof Promise?s.push(f.then(S=>{S.issues.length&&o.issues.push(...Fe(u,S.issues)),o.value[h]=S.value})):(f.issues.length&&o.issues.push(...Fe(u,f.issues)),o.value[h]=f.value)}let l;for(let u in n)a.has(u)||(l=l??[],l.push(u));l&&l.length>0&&o.issues.push({code:"unrecognized_keys",input:n,inst:e,keys:l})}else{o.value={};for(let a of Reflect.ownKeys(n)){if(a==="__proto__"||!Object.prototype.propertyIsEnumerable.call(n,a))continue;let l=t.keyType._zod.run({value:a,issues:[]},r);if(l instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(typeof a=="string"&&wc.test(a)&&l.issues.length){let h=t.keyType._zod.run({value:Number(a),issues:[]},r);if(h instanceof Promise)throw new Error("Async schemas not supported in object keys currently");h.issues.length===0&&(l=h)}if(l.issues.length){t.mode==="loose"?o.value[a]=n[a]:o.issues.push({code:"invalid_key",origin:"record",issues:l.issues.map(h=>Ae(h,r,ge())),input:a,path:[a],inst:e});continue}let d=t.valueType._zod.run({value:n[a],issues:[]},r);d instanceof Promise?s.push(d.then(h=>{h.issues.length&&o.issues.push(...Fe(a,h.issues)),o.value[l.value]=h.value})):(d.issues.length&&o.issues.push(...Fe(a,d.issues)),o.value[l.value]=d.value)}}return s.length?Promise.all(s).then(()=>o):o}}),Zp=g("$ZodMap",(e,t)=>{Y.init(e,t),e._zod.parse=(o,r)=>{let n=o.value;if(!(n instanceof Map))return o.issues.push({expected:"map",code:"invalid_type",input:n,inst:e}),o;let s=[];o.value=new Map;for(let[i,a]of n){let l=t.keyType._zod.run({value:i,issues:[]},r),u=t.valueType._zod.run({value:a,issues:[]},r);l instanceof Promise||u instanceof Promise?s.push(Promise.all([l,u]).then(([d,h])=>{dS(d,h,o,i,n,e,r)})):dS(l,u,o,i,n,e,r)}return s.length?Promise.all(s).then(()=>o):o}});function dS(e,t,o,r,n,s,i){e.issues.length&&(ws.has(typeof r)?o.issues.push(...Fe(r,e.issues)):o.issues.push({code:"invalid_key",origin:"map",input:n,inst:s,issues:e.issues.map(a=>Ae(a,i,ge()))})),t.issues.length&&(ws.has(typeof r)?o.issues.push(...Fe(r,t.issues)):o.issues.push({origin:"map",code:"invalid_element",input:n,inst:s,key:r,issues:t.issues.map(a=>Ae(a,i,ge()))})),o.value.set(e.value,t.value)}var Dp=g("$ZodSet",(e,t)=>{Y.init(e,t),e._zod.parse=(o,r)=>{let n=o.value;if(!(n instanceof Set))return o.issues.push({input:n,inst:e,expected:"set",code:"invalid_type"}),o;let s=[];o.value=new Set;for(let i of n){let a=t.valueType._zod.run({value:i,issues:[]},r);a instanceof Promise?s.push(a.then(l=>pS(l,o))):pS(a,o)}return s.length?Promise.all(s).then(()=>o):o}});function pS(e,t){e.issues.length&&t.issues.push(...e.issues),t.value.add(e.value)}var Fp=g("$ZodEnum",(e,t)=>{Y.init(e,t);let o=vs(t.entries),r=new Set(o);e._zod.values=r,e._zod.pattern=new RegExp(`^(${o.filter(n=>ws.has(typeof n)).map(n=>typeof n=="string"?it(n):n.toString()).join("|")})$`),e._zod.parse=(n,s)=>{let i=n.value;return r.has(i)||n.issues.push({code:"invalid_value",values:o,input:i,inst:e}),n}}),Hp=g("$ZodLiteral",(e,t)=>{if(Y.init(e,t),t.values.length===0)throw new 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"?it(r):r?it(r.toString()):String(r)).join("|")})$`),e._zod.parse=(r,n)=>{let s=r.value;return o.has(s)||r.issues.push({code:"invalid_value",values:t.values,input:s,inst:e}),r}}),Vp=g("$ZodFile",(e,t)=>{Y.init(e,t),e._zod.parse=(o,r)=>{let n=o.value;return n instanceof File||o.issues.push({expected:"file",code:"invalid_type",input:n,inst:e}),o}}),Jp=g("$ZodTransform",(e,t)=>{Y.init(e,t),e._zod.optin="optional",e._zod.parse=(o,r)=>{if(r.direction==="backward")throw new co(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 ut;return o.value=n,o.fallback=!0,o}});function hS(e,t){return t===void 0&&(e.issues.length||e.fallback)?{issues:[],value:void 0}:e}var Nc=g("$ZodOptional",(e,t)=>{Y.init(e,t),e._zod.optin="optional",e._zod.optout="optional",te(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),te(e._zod,"pattern",()=>{let o=t.innerType._zod.pattern;return o?new RegExp(`^(${Rs(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);return s instanceof Promise?s.then(i=>hS(i,n)):hS(s,n)}return o.value===void 0?o:t.innerType._zod.run(o,r)}}),Bp=g("$ZodExactOptional",(e,t)=>{Nc.init(e,t),te(e._zod,"values",()=>t.innerType._zod.values),te(e._zod,"pattern",()=>t.innerType._zod.pattern),e._zod.parse=(o,r)=>t.innerType._zod.run(o,r)}),Wp=g("$ZodNullable",(e,t)=>{Y.init(e,t),te(e._zod,"optin",()=>t.innerType._zod.optin),te(e._zod,"optout",()=>t.innerType._zod.optout),te(e._zod,"pattern",()=>{let o=t.innerType._zod.pattern;return o?new RegExp(`^(${Rs(o.source)}|null)$`):void 0}),te(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(o,r)=>o.value===null?o:t.innerType._zod.run(o,r)}),Kp=g("$ZodDefault",(e,t)=>{Y.init(e,t),e._zod.optin="optional",te(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);return n instanceof Promise?n.then(s=>mS(s,t)):mS(n,t)}});function mS(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}var Gp=g("$ZodPrefault",(e,t)=>{Y.init(e,t),e._zod.optin="optional",te(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(o,r)=>(r.direction==="backward"||o.value===void 0&&(o.value=t.defaultValue),t.innerType._zod.run(o,r))}),Yp=g("$ZodNonOptional",(e,t)=>{Y.init(e,t),te(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);return n instanceof Promise?n.then(s=>fS(s,e)):fS(n,e)}});function fS(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:"invalid_type",expected:"nonoptional",input:e.value,inst:t}),e}var Xp=g("$ZodSuccess",(e,t)=>{Y.init(e,t),e._zod.parse=(o,r)=>{if(r.direction==="backward")throw new co("ZodSuccess");let n=t.innerType._zod.run(o,r);return n instanceof Promise?n.then(s=>(o.value=s.issues.length===0,o)):(o.value=n.issues.length===0,o)}}),Qp=g("$ZodCatch",(e,t)=>{Y.init(e,t),e._zod.optin="optional",te(e._zod,"optout",()=>t.innerType._zod.optout),te(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);return n instanceof Promise?n.then(s=>(o.value=s.value,s.issues.length&&(o.value=t.catchValue({...o,error:{issues:s.issues.map(i=>Ae(i,r,ge()))},input:o.value}),o.issues=[],o.fallback=!0),o)):(o.value=n.value,n.issues.length&&(o.value=t.catchValue({...o,error:{issues:n.issues.map(s=>Ae(s,r,ge()))},input:o.value}),o.issues=[],o.fallback=!0),o)}}),eh=g("$ZodNaN",(e,t)=>{Y.init(e,t),e._zod.parse=(o,r)=>((typeof o.value!="number"||!Number.isNaN(o.value))&&o.issues.push({input:o.value,inst:e,expected:"nan",code:"invalid_type"}),o)}),qc=g("$ZodPipe",(e,t)=>{Y.init(e,t),te(e._zod,"values",()=>t.in._zod.values),te(e._zod,"optin",()=>t.in._zod.optin),te(e._zod,"optout",()=>t.out._zod.optout),te(e._zod,"propValues",()=>t.in._zod.propValues),e._zod.parse=(o,r)=>{if(r.direction==="backward"){let s=t.out._zod.run(o,r);return s instanceof Promise?s.then(i=>Tc(i,t.in,r)):Tc(s,t.in,r)}let n=t.in._zod.run(o,r);return n instanceof Promise?n.then(s=>Tc(s,t.out,r)):Tc(n,t.out,r)}});function Tc(e,t,o){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues,fallback:e.fallback},o)}var qs=g("$ZodCodec",(e,t)=>{Y.init(e,t),te(e._zod,"values",()=>t.in._zod.values),te(e._zod,"optin",()=>t.in._zod.optin),te(e._zod,"optout",()=>t.out._zod.optout),te(e._zod,"propValues",()=>t.in._zod.propValues),e._zod.parse=(o,r)=>{if((r.direction||"forward")==="forward"){let s=t.in._zod.run(o,r);return s instanceof Promise?s.then(i=>Ec(i,t,r)):Ec(s,t,r)}else{let s=t.out._zod.run(o,r);return s instanceof Promise?s.then(i=>Ec(i,t,r)):Ec(s,t,r)}}});function Ec(e,t,o){if(e.issues.length)return e.aborted=!0,e;if((o.direction||"forward")==="forward"){let n=t.transform(e.value,e);return n instanceof Promise?n.then(s=>kc(e,s,t.out,o)):kc(e,n,t.out,o)}else{let n=t.reverseTransform(e.value,e);return n instanceof Promise?n.then(s=>kc(e,s,t.in,o)):kc(e,n,t.in,o)}}function kc(e,t,o,r){return e.issues.length?(e.aborted=!0,e):o._zod.run({value:t,issues:e.issues},r)}var th=g("$ZodPreprocess",(e,t)=>{qc.init(e,t)}),oh=g("$ZodReadonly",(e,t)=>{Y.init(e,t),te(e._zod,"propValues",()=>t.innerType._zod.propValues),te(e._zod,"values",()=>t.innerType._zod.values),te(e._zod,"optin",()=>t.innerType?._zod?.optin),te(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);return n instanceof Promise?n.then(gS):gS(n)}});function gS(e){return e.value=Object.freeze(e.value),e}var rh=g("$ZodTemplateLiteral",(e,t)=>{Y.init(e,t);let o=[];for(let r of t.parts)if(typeof r=="object"&&r!==null){if(!r._zod.pattern)throw new Error(`Invalid template literal part, no pattern found: ${[...r._zod.traits].shift()}`);let n=r._zod.pattern instanceof RegExp?r._zod.pattern.source:r._zod.pattern;if(!n)throw new Error(`Invalid template literal part: ${r._zod.traits}`);let s=n.startsWith("^")?1:0,i=n.endsWith("$")?n.length-1:n.length;o.push(n.slice(s,i))}else if(r===null||Wu.has(typeof r))o.push(it(`${r}`));else throw new Error(`Invalid template literal part: ${r}`);e._zod.pattern=new RegExp(`^${o.join("")}$`),e._zod.parse=(r,n)=>typeof r.value!="string"?(r.issues.push({input:r.value,inst:e,expected:"string",code:"invalid_type"}),r):(e._zod.pattern.lastIndex=0,e._zod.pattern.test(r.value)||r.issues.push({input:r.value,inst:e,code:"invalid_format",format:t.format??"template_literal",pattern:e._zod.pattern.source}),r)}),nh=g("$ZodFunction",(e,t)=>(Y.init(e,t),e._def=t,e._zod.def=t,e.implement=o=>{if(typeof o!="function")throw new Error("implement() must be called with a function");return function(...r){let n=e._def.input?hc(e._def.input,r):r,s=Reflect.apply(o,this,n);return e._def.output?hc(e._def.output,s):s}},e.implementAsync=o=>{if(typeof o!="function")throw new Error("implementAsync() must be called with a function");return async function(...r){let n=e._def.input?await mc(e._def.input,r):r,s=await Reflect.apply(o,this,n);return e._def.output?await mc(e._def.output,s):s}},e._zod.parse=(o,r)=>typeof o.value!="function"?(o.issues.push({code:"invalid_type",expected:"function",input:o.value,inst:e}),o):(e._def.output&&e._def.output._zod.def.type==="promise"?o.value=e.implementAsync(o.value):o.value=e.implement(o.value),o),e.input=(...o)=>{let r=e.constructor;return Array.isArray(o[0])?new r({type:"function",input:new Oc({type:"tuple",items:o[0],rest:o[1]}),output:e._def.output}):new r({type:"function",input:o[0],output:e._def.output})},e.output=o=>{let r=e.constructor;return new r({type:"function",input:e._def.input,output:o})},e)),sh=g("$ZodPromise",(e,t)=>{Y.init(e,t),e._zod.parse=(o,r)=>Promise.resolve(o.value).then(n=>t.innerType._zod.run({value:n,issues:[]},r))}),ih=g("$ZodLazy",(e,t)=>{Y.init(e,t),te(e._zod,"innerType",()=>{let o=t;return o._cachedInner||(o._cachedInner=t.getter()),o._cachedInner}),te(e._zod,"pattern",()=>e._zod.innerType?._zod?.pattern),te(e._zod,"propValues",()=>e._zod.innerType?._zod?.propValues),te(e._zod,"optin",()=>e._zod.innerType?._zod?.optin??void 0),te(e._zod,"optout",()=>e._zod.innerType?._zod?.optout??void 0),e._zod.parse=(o,r)=>e._zod.innerType._zod.run(o,r)}),ah=g("$ZodCustom",(e,t)=>{le.init(e,t),Y.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=>SS(s,o,r,e));SS(n,o,r,e)}});function SS(e,t,o,r){if(!e){let n={code:"custom",input:o,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(n.params=r._zod.def.params),t.issues.push($r(n))}}var Ms={};Ut(Ms,{en:()=>Mc});var cv=()=>{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=Qu(n.input),a=r[i]??i;return`Invalid input: expected ${s}, received ${a}`}case"invalid_value":return n.values.length===1?`Invalid input: expected ${pc(n.values[0])}`:`Invalid option: expected one of ${lc(n.values,"|")}`;case"too_big":{let s=n.inclusive?"<=":"<",i=t(n.origin);return i?`Too big: expected ${n.origin??"value"} to have ${s}${n.maximum.toString()} ${i.unit??"elements"}`:`Too big: expected ${n.origin??"value"} to be ${s}${n.maximum.toString()}`}case"too_small":{let s=n.inclusive?">=":">",i=t(n.origin);return i?`Too small: expected ${n.origin} to have ${s}${n.minimum.toString()} ${i.unit}`:`Too small: expected ${n.origin} to be ${s}${n.minimum.toString()}`}case"invalid_format":{let s=n;return s.format==="starts_with"?`Invalid string: must start with "${s.prefix}"`:s.format==="ends_with"?`Invalid string: must end with "${s.suffix}"`:s.format==="includes"?`Invalid string: must include "${s.includes}"`:s.format==="regex"?`Invalid string: must match pattern ${s.pattern}`:`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":""}: ${lc(n.keys,", ")}`;case"invalid_key":return`Invalid key in ${n.origin}`;case"invalid_union":return n.options&&Array.isArray(n.options)&&n.options.length>0?`Invalid discriminator value. Expected ${n.options.map(i=>`'${i}'`).join(" | ")}`:"Invalid input";case"invalid_element":return`Invalid value in ${n.origin}`;default:return"Invalid input"}}};function Mc(){return{localeError:cv()}}var RS,ch=Symbol("ZodOutput"),lh=Symbol("ZodInput"),Ac=class{constructor(){this._map=new WeakMap,this._idmap=new Map}add(t,...o){let r=o[0];return this._map.set(t,r),r&&typeof r=="object"&&"id"in r&&this._idmap.set(r.id,t),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(t){let o=this._map.get(t);return o&&typeof o=="object"&&"id"in o&&this._idmap.delete(o.id),this._map.delete(t),this}get(t){let o=t._zod.parent;if(o){let r={...this.get(o)??{}};delete r.id;let n={...r,...this._map.get(t)};return Object.keys(n).length?n:void 0}return this._map.get(t)}has(t){return this._map.has(t)}};function jc(){return new Ac}(RS=globalThis).__zod_globalRegistry??(RS.__zod_globalRegistry=jc());var ve=globalThis.__zod_globalRegistry;function uh(e,t){return new e({type:"string",...P(t)})}function dh(e,t){return new e({type:"string",coerce:!0,...P(t)})}function Lc(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...P(t)})}function As(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...P(t)})}function Uc(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...P(t)})}function Zc(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...P(t)})}function Dc(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...P(t)})}function Fc(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...P(t)})}function js(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...P(t)})}function Hc(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...P(t)})}function Vc(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...P(t)})}function Jc(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...P(t)})}function Bc(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...P(t)})}function Wc(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...P(t)})}function Kc(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...P(t)})}function Gc(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...P(t)})}function Yc(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...P(t)})}function Xc(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...P(t)})}function ph(e,t){return new e({type:"string",format:"mac",check:"string_format",abort:!1,...P(t)})}function Qc(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...P(t)})}function el(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...P(t)})}function tl(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...P(t)})}function ol(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...P(t)})}function rl(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...P(t)})}function nl(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...P(t)})}var hh={Any:null,Minute:-1,Second:0,Millisecond:3,Microsecond:6};function mh(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...P(t)})}function fh(e,t){return new e({type:"string",format:"date",check:"string_format",...P(t)})}function gh(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...P(t)})}function Sh(e,t){return new e({type:"string",format:"duration",check:"string_format",...P(t)})}function _h(e,t){return new e({type:"number",checks:[],...P(t)})}function bh(e,t){return new e({type:"number",coerce:!0,checks:[],...P(t)})}function yh(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...P(t)})}function zh(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"float32",...P(t)})}function vh(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"float64",...P(t)})}function Rh(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"int32",...P(t)})}function wh(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"uint32",...P(t)})}function xh(e,t){return new e({type:"boolean",...P(t)})}function Ph(e,t){return new e({type:"boolean",coerce:!0,...P(t)})}function Th(e,t){return new e({type:"bigint",...P(t)})}function Eh(e,t){return new e({type:"bigint",coerce:!0,...P(t)})}function kh(e,t){return new e({type:"bigint",check:"bigint_format",abort:!1,format:"int64",...P(t)})}function $h(e,t){return new e({type:"bigint",check:"bigint_format",abort:!1,format:"uint64",...P(t)})}function Ch(e,t){return new e({type:"symbol",...P(t)})}function Ih(e,t){return new e({type:"undefined",...P(t)})}function Oh(e,t){return new e({type:"null",...P(t)})}function Nh(e){return new e({type:"any"})}function qh(e){return new e({type:"unknown"})}function Mh(e,t){return new e({type:"never",...P(t)})}function Ah(e,t){return new e({type:"void",...P(t)})}function jh(e,t){return new e({type:"date",...P(t)})}function Lh(e,t){return new e({type:"date",coerce:!0,...P(t)})}function Uh(e,t){return new e({type:"nan",...P(t)})}function Pt(e,t){return new xc({check:"less_than",...P(t),value:e,inclusive:!1})}function Xe(e,t){return new xc({check:"less_than",...P(t),value:e,inclusive:!0})}function Tt(e,t){return new Pc({check:"greater_than",...P(t),value:e,inclusive:!1})}function je(e,t){return new Pc({check:"greater_than",...P(t),value:e,inclusive:!0})}function sl(e){return Tt(0,e)}function il(e){return Pt(0,e)}function al(e){return Xe(0,e)}function cl(e){return je(0,e)}function mo(e,t){return new Od({check:"multiple_of",...P(t),value:e})}function fo(e,t){return new Md({check:"max_size",...P(t),maximum:e})}function Et(e,t){return new Ad({check:"min_size",...P(t),minimum:e})}function Fo(e,t){return new jd({check:"size_equals",...P(t),size:e})}function Ho(e,t){return new Ld({check:"max_length",...P(t),maximum:e})}function Dt(e,t){return new Ud({check:"min_length",...P(t),minimum:e})}function Vo(e,t){return new Zd({check:"length_equals",...P(t),length:e})}function Mr(e,t){return new Dd({check:"string_format",format:"regex",...P(t),pattern:e})}function Ar(e){return new Fd({check:"string_format",format:"lowercase",...P(e)})}function jr(e){return new Hd({check:"string_format",format:"uppercase",...P(e)})}function Lr(e,t){return new Vd({check:"string_format",format:"includes",...P(t),includes:e})}function Ur(e,t){return new Jd({check:"string_format",format:"starts_with",...P(t),prefix:e})}function Zr(e,t){return new Bd({check:"string_format",format:"ends_with",...P(t),suffix:e})}function ll(e,t,o){return new Wd({check:"property",property:e,schema:t,...P(o)})}function Dr(e,t){return new Kd({check:"mime_type",mime:e,...P(t)})}function dt(e){return new Gd({check:"overwrite",tx:e})}function Fr(e){return dt(t=>t.normalize(e))}function Hr(){return dt(e=>e.trim())}function Vr(){return dt(e=>e.toLowerCase())}function Jr(){return dt(e=>e.toUpperCase())}function Br(){return dt(e=>Vu(e))}function Zh(e,t,o){return new e({type:"array",element:t,...P(o)})}function uv(e,t,o){return new e({type:"union",options:t,...P(o)})}function dv(e,t,o){return new e({type:"union",options:t,inclusive:!1,...P(o)})}function pv(e,t,o,r){return new e({type:"union",options:o,discriminator:t,...P(r)})}function hv(e,t,o){return new e({type:"intersection",left:t,right:o})}function mv(e,t,o,r){let n=o instanceof Y,s=n?r:o,i=n?o:null;return new e({type:"tuple",items:t,rest:i,...P(s)})}function fv(e,t,o,r){return new e({type:"record",keyType:t,valueType:o,...P(r)})}function gv(e,t,o,r){return new e({type:"map",keyType:t,valueType:o,...P(r)})}function Sv(e,t,o){return new e({type:"set",valueType:t,...P(o)})}function _v(e,t,o){let r=Array.isArray(t)?Object.fromEntries(t.map(n=>[n,n])):t;return new e({type:"enum",entries:r,...P(o)})}function bv(e,t,o){return new e({type:"enum",entries:t,...P(o)})}function yv(e,t,o){return new e({type:"literal",values:Array.isArray(t)?t:[t],...P(o)})}function Dh(e,t){return new e({type:"file",...P(t)})}function zv(e,t){return new e({type:"transform",transform:t})}function vv(e,t){return new e({type:"optional",innerType:t})}function Rv(e,t){return new e({type:"nullable",innerType:t})}function wv(e,t,o){return new e({type:"default",innerType:t,get defaultValue(){return typeof o=="function"?o():Bu(o)}})}function xv(e,t,o){return new e({type:"nonoptional",innerType:t,...P(o)})}function Pv(e,t){return new e({type:"success",innerType:t})}function Tv(e,t,o){return new e({type:"catch",innerType:t,catchValue:typeof o=="function"?o:()=>o})}function Ev(e,t,o){return new e({type:"pipe",in:t,out:o})}function kv(e,t){return new e({type:"readonly",innerType:t})}function $v(e,t,o){return new e({type:"template_literal",parts:t,...P(o)})}function Cv(e,t){return new e({type:"lazy",getter:t})}function Iv(e,t){return new e({type:"promise",innerType:t})}function Fh(e,t,o){let r=P(o);return r.abort??(r.abort=!0),new e({type:"custom",check:"custom",fn:t,...r})}function Hh(e,t,o){return new e({type:"custom",check:"custom",fn:t,...P(o)})}function Vh(e,t){let o=wS(r=>(r.addIssue=n=>{if(typeof n=="string")r.issues.push($r(n,r.value,o._zod.def));else{let s=n;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($r(s))}},e(r.value,r)),t);return o}function wS(e,t){let o=new le({check:"custom",...P(t)});return o._zod.check=e,o}function Jh(e){let t=new le({check:"describe"});return t._zod.onattach=[o=>{let r=ve.get(o)??{};ve.add(o,{...r,description:e})}],t._zod.check=()=>{},t}function Bh(e){let t=new le({check:"meta"});return t._zod.onattach=[o=>{let r=ve.get(o)??{};ve.add(o,{...r,...e})}],t._zod.check=()=>{},t}function Wh(e,t){let o=P(t),r=o.truthy??["true","1","yes","on","y","enabled"],n=o.falsy??["false","0","no","off","n","disabled"];o.case!=="sensitive"&&(r=r.map(S=>typeof S=="string"?S.toLowerCase():S),n=n.map(S=>typeof S=="string"?S.toLowerCase():S));let s=new Set(r),i=new Set(n),a=e.Codec??qs,l=e.Boolean??Os,u=e.String??Do,d=new u({type:"string",error:o.error}),h=new l({type:"boolean",error:o.error}),f=new a({type:"pipe",in:d,out:h,transform:((S,y)=>{let w=S;return o.case!=="sensitive"&&(w=w.toLowerCase()),s.has(w)?!0:i.has(w)?!1:(y.issues.push({code:"invalid_value",expected:"stringbool",values:[...s,...i],input:y.value,inst:f,continue:!1}),{})}),reverseTransform:((S,y)=>S===!0?r[0]||"true":n[0]||"false"),error:o.error});return f}function Wr(e,t,o,r={}){let n=P(r),s={...P(r),check:"string_format",type:"string",format:t,fn:typeof o=="function"?o:a=>o.test(a),...n};return o instanceof RegExp&&(s.pattern=o),new e(s)}function go(e){let t=e?.target??"draft-2020-12";return t==="draft-4"&&(t="draft-04"),t==="draft-7"&&(t="draft-07"),{processors:e.processors??{},metadataRegistry:e?.metadata??ve,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 ne(e,t,o={path:[],schemaPath:[]}){var r;let n=e._zod.def,s=t.seen.get(e);if(s)return s.count++,o.schemaPath.includes(e)&&(s.cycle=o.path),s.schema;let i={schema:{},count:1,cycle:void 0,path:o.path};t.seen.set(e,i);let a=e._zod.toJSONSchema?.();if(a)i.schema=a;else{let d={...o,schemaPath:[...o.schemaPath,e],path:o.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,i.schema,d);else{let f=i.schema,S=t.processors[n.type];if(!S)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${n.type}`);S(e,t,f,d)}let h=e._zod.parent;h&&(i.ref||(i.ref=h),ne(h,t,d),t.seen.get(h).isParent=!0)}let l=t.metadataRegistry.get(e);return l&&Object.assign(i.schema,l),t.io==="input"&&Le(e)&&(delete i.schema.examples,delete i.schema.default),t.io==="input"&&"_prefault"in i.schema&&((r=i.schema).default??(r.default=i.schema._prefault)),delete i.schema._prefault,t.seen.get(e).schema}function So(e,t){let o=e.seen.get(t);if(!o)throw new Error("Unprocessed schema. This is a bug in Zod.");let r=new Map;for(let i of e.seen.entries()){let a=e.metadataRegistry.get(i[0])?.id;if(a){let l=r.get(a);if(l&&l!==i[0])throw new Error(`Duplicate schema id "${a}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);r.set(a,i[0])}}let n=i=>{let a=e.target==="draft-2020-12"?"$defs":"definitions";if(e.external){let h=e.external.registry.get(i[0])?.id,f=e.external.uri??(y=>y);if(h)return{ref:f(h)};let S=i[1].defId??i[1].schema.id??`schema${e.counter++}`;return i[1].defId=S,{defId:S,ref:`${f("__shared")}#/${a}/${S}`}}if(i[1]===o)return{ref:"#"};let u=`#/${a}/`,d=i[1].schema.id??`__schema${e.counter++}`;return{defId:d,ref:u+d}},s=i=>{if(i[1].schema.$ref)return;let a=i[1],{ref:l,defId:u}=n(i);a.def={...a.schema},u&&(a.defId=u);let d=a.schema;for(let h in d)delete d[h];d.$ref=l};if(e.cycles==="throw")for(let i of e.seen.entries()){let a=i[1];if(a.cycle)throw new Error(`Cycle detected: #/${a.cycle?.join("/")}/<root>
64
64
 
65
- Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let i of e.seen.entries()){let a=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(a.cycle){s(i);continue}if(a.count>1&&e.reused==="ref"){s(i);continue}}}function _o(e,t){let o=e.seen.get(t);if(!o)throw new Error("Unprocessed schema. This is a bug in Zod.");let r=a=>{let l=e.seen.get(a);if(l.ref===null)return;let u=l.def??l.schema,d={...u},h=l.ref;if(l.ref=null,h){r(h);let S=e.seen.get(h),y=S.schema;if(y.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0")?(u.allOf=u.allOf??[],u.allOf.push(y)):Object.assign(u,y),Object.assign(u,d),a._zod.parent===h)for(let z in u)z==="$ref"||z==="allOf"||z in d||delete u[z];if(y.$ref&&S.def)for(let z in u)z==="$ref"||z==="allOf"||z in S.def&&JSON.stringify(u[z])===JSON.stringify(S.def[z])&&delete u[z]}let f=a._zod.parent;if(f&&f!==h){r(f);let S=e.seen.get(f);if(S?.schema.$ref&&(u.$ref=S.schema.$ref,S.def))for(let y in u)y==="$ref"||y==="allOf"||y in S.def&&JSON.stringify(u[y])===JSON.stringify(S.def[y])&&delete u[y]}e.override({zodSchema:a,jsonSchema:u,path:l.path??[]})};for(let a of[...e.seen.entries()].reverse())r(a[0]);let n={};if(e.target==="draft-2020-12"?n.$schema="https://json-schema.org/draft/2020-12/schema":e.target==="draft-07"?n.$schema="http://json-schema.org/draft-07/schema#":e.target==="draft-04"?n.$schema="http://json-schema.org/draft-04/schema#":e.target,e.external?.uri){let a=e.external.registry.get(t)?.id;if(!a)throw new Error("Schema is missing an `id` property");n.$id=e.external.uri(a)}Object.assign(n,o.def??o.schema);let s=e.metadataRegistry.get(t)?.id;s!==void 0&&n.id===s&&delete n.id;let i=e.external?.defs??{};for(let a of e.seen.entries()){let l=a[1];l.def&&l.defId&&(l.def.id===l.defId&&delete l.def.id,i[l.defId]=l.def)}e.external||Object.keys(i).length>0&&(e.target==="draft-2020-12"?n.$defs=i:n.definitions=i);try{let a=JSON.parse(JSON.stringify(n));return Object.defineProperty(a,"~standard",{value:{...t["~standard"],jsonSchema:{input:Wr(t,"input",e.processors),output:Wr(t,"output",e.processors)}},enumerable:!1,writable:!1}),a}catch{throw new Error("Error converting schema to JSON.")}}function Le(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 Le(r.element,o);if(r.type==="set")return Le(r.valueType,o);if(r.type==="lazy")return Le(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 Le(r.innerType,o);if(r.type==="intersection")return Le(r.left,o)||Le(r.right,o);if(r.type==="record"||r.type==="map")return Le(r.keyType,o)||Le(r.valueType,o);if(r.type==="pipe")return e._zod.traits.has("$ZodCodec")?!0:Le(r.in,o)||Le(r.out,o);if(r.type==="object"){for(let n in r.shape)if(Le(r.shape[n],o))return!0;return!1}if(r.type==="union"){for(let n of r.options)if(Le(n,o))return!0;return!1}if(r.type==="tuple"){for(let n of r.items)if(Le(n,o))return!0;return!!(r.rest&&Le(r.rest,o))}return!1}var Wh=(e,t={})=>o=>{let r=go({...o,processors:t});return ne(e,r),So(r,e),_o(r,e)},Wr=(e,t,o={})=>r=>{let{libraryOptions:n,target:s}=r??{},i=go({...n??{},target:s,io:t,processors:o});return ne(e,i),So(i,e),_o(i,e)};var Ov={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},Kh=(e,t,o,r)=>{let n=o;n.type="string";let{minimum:s,maximum:i,format:a,patterns:l,contentEncoding:u}=e._zod.bag;if(typeof s=="number"&&(n.minLength=s),typeof i=="number"&&(n.maxLength=i),a&&(n.format=Ov[a]??a,n.format===""&&delete n.format,a==="time"&&delete n.format),u&&(n.contentEncoding=u),l&&l.size>0){let d=[...l];d.length===1?n.pattern=d[0].source:d.length>1&&(n.allOf=[...d.map(h=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:h.source}))])}},Gh=(e,t,o,r)=>{let n=o,{minimum:s,maximum:i,format:a,multipleOf:l,exclusiveMaximum:u,exclusiveMinimum:d}=e._zod.bag;typeof a=="string"&&a.includes("int")?n.type="integer":n.type="number";let h=typeof d=="number"&&d>=(s??Number.NEGATIVE_INFINITY),f=typeof u=="number"&&u<=(i??Number.POSITIVE_INFINITY),S=t.target==="draft-04"||t.target==="openapi-3.0";h?S?(n.minimum=d,n.exclusiveMinimum=!0):n.exclusiveMinimum=d:typeof s=="number"&&(n.minimum=s),f?S?(n.maximum=u,n.exclusiveMaximum=!0):n.exclusiveMaximum=u:typeof i=="number"&&(n.maximum=i),typeof l=="number"&&(n.multipleOf=l)},Yh=(e,t,o,r)=>{o.type="boolean"},Xh=(e,t,o,r)=>{if(t.unrepresentable==="throw")throw new Error("BigInt cannot be represented in JSON Schema")},Qh=(e,t,o,r)=>{if(t.unrepresentable==="throw")throw new Error("Symbols cannot be represented in JSON Schema")},em=(e,t,o,r)=>{t.target==="openapi-3.0"?(o.type="string",o.nullable=!0,o.enum=[null]):o.type="null"},tm=(e,t,o,r)=>{if(t.unrepresentable==="throw")throw new Error("Undefined cannot be represented in JSON Schema")},om=(e,t,o,r)=>{if(t.unrepresentable==="throw")throw new Error("Void cannot be represented in JSON Schema")},rm=(e,t,o,r)=>{o.not={}},nm=(e,t,o,r)=>{},sm=(e,t,o,r)=>{},im=(e,t,o,r)=>{if(t.unrepresentable==="throw")throw new Error("Date cannot be represented in JSON Schema")},am=(e,t,o,r)=>{let n=e._zod.def,s=vs(n.entries);s.every(i=>typeof i=="number")&&(o.type="number"),s.every(i=>typeof i=="string")&&(o.type="string"),o.enum=s},cm=(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 new Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof i=="bigint"){if(t.unrepresentable==="throw")throw new Error("BigInt literals cannot be represented in JSON Schema");s.push(Number(i))}else s.push(i);if(s.length!==0)if(s.length===1){let i=s[0];o.type=i===null?"null":typeof i,t.target==="draft-04"||t.target==="openapi-3.0"?o.enum=[i]:o.const=i}else s.every(i=>typeof i=="number")&&(o.type="number"),s.every(i=>typeof i=="string")&&(o.type="string"),s.every(i=>typeof i=="boolean")&&(o.type="boolean"),s.every(i=>i===null)&&(o.type="null"),o.enum=s},lm=(e,t,o,r)=>{if(t.unrepresentable==="throw")throw new Error("NaN cannot be represented in JSON Schema")},um=(e,t,o,r)=>{let n=o,s=e._zod.pattern;if(!s)throw new Error("Pattern not found in template literal");n.type="string",n.pattern=s.source},dm=(e,t,o,r)=>{let n=o,s={type:"string",format:"binary",contentEncoding:"binary"},{minimum:i,maximum:a,mime:l}=e._zod.bag;i!==void 0&&(s.minLength=i),a!==void 0&&(s.maxLength=a),l?l.length===1?(s.contentMediaType=l[0],Object.assign(n,s)):(Object.assign(n,s),n.anyOf=l.map(u=>({contentMediaType:u}))):Object.assign(n,s)},pm=(e,t,o,r)=>{o.type="boolean"},hm=(e,t,o,r)=>{if(t.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema")},mm=(e,t,o,r)=>{if(t.unrepresentable==="throw")throw new Error("Function types cannot be represented in JSON Schema")},fm=(e,t,o,r)=>{if(t.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema")},gm=(e,t,o,r)=>{if(t.unrepresentable==="throw")throw new Error("Map cannot be represented in JSON Schema")},Sm=(e,t,o,r)=>{if(t.unrepresentable==="throw")throw new Error("Set cannot be represented in JSON Schema")},_m=(e,t,o,r)=>{let n=o,s=e._zod.def,{minimum:i,maximum:a}=e._zod.bag;typeof i=="number"&&(n.minItems=i),typeof a=="number"&&(n.maxItems=a),n.type="array",n.items=ne(s.element,t,{...r,path:[...r.path,"items"]})},bm=(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]=ne(i[u],t,{...r,path:[...r.path,"properties",u]});let a=new Set(Object.keys(i)),l=new Set([...a].filter(u=>{let d=s.shape[u]._zod;return t.io==="input"?d.optin===void 0:d.optout===void 0}));l.size>0&&(n.required=Array.from(l)),s.catchall?._zod.def.type==="never"?n.additionalProperties=!1:s.catchall?s.catchall&&(n.additionalProperties=ne(s.catchall,t,{...r,path:[...r.path,"additionalProperties"]})):t.io==="output"&&(n.additionalProperties=!1)},ul=(e,t,o,r)=>{let n=e._zod.def,s=n.inclusive===!1,i=n.options.map((a,l)=>ne(a,t,{...r,path:[...r.path,s?"oneOf":"anyOf",l]}));s?o.oneOf=i:o.anyOf=i},ym=(e,t,o,r)=>{let n=e._zod.def,s=ne(n.left,t,{...r,path:[...r.path,"allOf",0]}),i=ne(n.right,t,{...r,path:[...r.path,"allOf",1]}),a=u=>"allOf"in u&&Object.keys(u).length===1,l=[...a(s)?s.allOf:[s],...a(i)?i.allOf:[i]];o.allOf=l},zm=(e,t,o,r)=>{let n=o,s=e._zod.def;n.type="array";let i=t.target==="draft-2020-12"?"prefixItems":"items",a=t.target==="draft-2020-12"||t.target==="openapi-3.0"?"items":"additionalItems",l=s.items.map((f,S)=>ne(f,t,{...r,path:[...r.path,i,S]})),u=s.rest?ne(s.rest,t,{...r,path:[...r.path,a,...t.target==="openapi-3.0"?[s.items.length]:[]]}):null;t.target==="draft-2020-12"?(n.prefixItems=l,u&&(n.items=u)):t.target==="openapi-3.0"?(n.items={anyOf:l},u&&n.items.anyOf.push(u),n.minItems=l.length,u||(n.maxItems=l.length)):(n.items=l,u&&(n.additionalItems=u));let{minimum:d,maximum:h}=e._zod.bag;typeof d=="number"&&(n.minItems=d),typeof h=="number"&&(n.maxItems=h)},vm=(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 d=ne(s.valueType,t,{...r,path:[...r.path,"patternProperties","*"]});n.patternProperties={};for(let h of l)n.patternProperties[h.source]=d}else(t.target==="draft-07"||t.target==="draft-2020-12")&&(n.propertyNames=ne(s.keyType,t,{...r,path:[...r.path,"propertyNames"]})),n.additionalProperties=ne(s.valueType,t,{...r,path:[...r.path,"additionalProperties"]});let u=i._zod.values;if(u){let d=[...u].filter(h=>typeof h=="string"||typeof h=="number");d.length>0&&(n.required=d)}},Rm=(e,t,o,r)=>{let n=e._zod.def,s=ne(n.innerType,t,r),i=t.seen.get(e);t.target==="openapi-3.0"?(i.ref=n.innerType,o.nullable=!0):o.anyOf=[s,{type:"null"}]},wm=(e,t,o,r)=>{let n=e._zod.def;ne(n.innerType,t,r);let s=t.seen.get(e);s.ref=n.innerType},xm=(e,t,o,r)=>{let n=e._zod.def;ne(n.innerType,t,r);let s=t.seen.get(e);s.ref=n.innerType,o.default=JSON.parse(JSON.stringify(n.defaultValue))},Pm=(e,t,o,r)=>{let n=e._zod.def;ne(n.innerType,t,r);let s=t.seen.get(e);s.ref=n.innerType,t.io==="input"&&(o._prefault=JSON.parse(JSON.stringify(n.defaultValue)))},Tm=(e,t,o,r)=>{let n=e._zod.def;ne(n.innerType,t,r);let s=t.seen.get(e);s.ref=n.innerType;let i;try{i=n.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}o.default=i},Em=(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;ne(i,t,r);let a=t.seen.get(e);a.ref=i},km=(e,t,o,r)=>{let n=e._zod.def;ne(n.innerType,t,r);let s=t.seen.get(e);s.ref=n.innerType,o.readOnly=!0},$m=(e,t,o,r)=>{let n=e._zod.def;ne(n.innerType,t,r);let s=t.seen.get(e);s.ref=n.innerType},dl=(e,t,o,r)=>{let n=e._zod.def;ne(n.innerType,t,r);let s=t.seen.get(e);s.ref=n.innerType},Cm=(e,t,o,r)=>{let n=e._zod.innerType;ne(n,t,r);let s=t.seen.get(e);s.ref=n},ll={string:Kh,number:Gh,boolean:Yh,bigint:Xh,symbol:Qh,null:em,undefined:tm,void:om,never:rm,any:nm,unknown:sm,date:im,enum:am,literal:cm,nan:lm,template_literal:um,file:dm,success:pm,custom:hm,function:mm,transform:fm,map:gm,set:Sm,array:_m,object:bm,union:ul,intersection:ym,tuple:zm,record:vm,nullable:Rm,nonoptional:wm,default:xm,prefault:Pm,catch:Tm,pipe:Em,readonly:km,promise:$m,optional:dl,lazy:Cm};function Jo(e,t){if("_idmap"in e){let r=e,n=go({...t,processors:ll}),s={};for(let l of r._idmap.entries()){let[u,d]=l;ne(d,n)}let i={},a={registry:r,uri:t?.uri,defs:s};n.external=a;for(let l of r._idmap.entries()){let[u,d]=l;So(n,d),i[u]=_o(n,d)}if(Object.keys(s).length>0){let l=n.target==="draft-2020-12"?"$defs":"definitions";i.__shared={[l]:s}}return{schemas:i}}let o=go({...t,processors:ll});return ne(e,o),So(o,e),_o(o,e)}var pl=class{get metadataRegistry(){return this.ctx.metadataRegistry}get target(){return this.ctx.target}get unrepresentable(){return this.ctx.unrepresentable}get override(){return this.ctx.override}get io(){return this.ctx.io}get counter(){return this.ctx.counter}set counter(t){this.ctx.counter=t}get seen(){return this.ctx.seen}constructor(t){let o=t?.target??"draft-2020-12";o==="draft-4"&&(o="draft-04"),o==="draft-7"&&(o="draft-07"),this.ctx=go({processors:ll,target:o,...t?.metadata&&{metadata:t.metadata},...t?.unrepresentable&&{unrepresentable:t.unrepresentable},...t?.override&&{override:t.override},...t?.io&&{io:t.io}})}process(t,o={path:[],schemaPath:[]}){return ne(t,this.ctx,o)}emit(t,o){o&&(o.cycles&&(this.ctx.cycles=o.cycles),o.reused&&(this.ctx.reused=o.reused),o.external&&(this.ctx.external=o.external)),So(this.ctx,t);let r=_o(this.ctx,t),{"~standard":n,...s}=r;return s}};var wS={};var Ls={};Ut(Ls,{ZodAny:()=>Ym,ZodArray:()=>tf,ZodBase64:()=>Nl,ZodBase64URL:()=>ql,ZodBigInt:()=>on,ZodBigIntFormat:()=>jl,ZodBoolean:()=>tn,ZodCIDRv4:()=>Il,ZodCIDRv6:()=>Ol,ZodCUID:()=>xl,ZodCUID2:()=>Pl,ZodCatch:()=>vf,ZodCodec:()=>Ks,ZodCustom:()=>Gs,ZodCustomStringFormat:()=>Qr,ZodDate:()=>Vs,ZodDefault:()=>gf,ZodDiscriminatedUnion:()=>rf,ZodE164:()=>Ml,ZodEmail:()=>zl,ZodEmoji:()=>Rl,ZodEnum:()=>Gr,ZodExactOptional:()=>hf,ZodFile:()=>df,ZodFunction:()=>Cf,ZodGUID:()=>Zs,ZodIPv4:()=>$l,ZodIPv6:()=>Cl,ZodIntersection:()=>nf,ZodJWT:()=>Al,ZodKSUID:()=>kl,ZodLazy:()=>kf,ZodLiteral:()=>uf,ZodMAC:()=>Bm,ZodMap:()=>cf,ZodNaN:()=>wf,ZodNanoID:()=>wl,ZodNever:()=>Qm,ZodNonOptional:()=>Fl,ZodNull:()=>Gm,ZodNullable:()=>ff,ZodNumber:()=>en,ZodNumberFormat:()=>Bo,ZodObject:()=>Js,ZodOptional:()=>Dl,ZodPipe:()=>Ws,ZodPrefault:()=>_f,ZodPreprocess:()=>xf,ZodPromise:()=>$f,ZodReadonly:()=>Pf,ZodRecord:()=>Kr,ZodSet:()=>lf,ZodString:()=>Yr,ZodStringFormat:()=>ce,ZodSuccess:()=>zf,ZodSymbol:()=>Wm,ZodTemplateLiteral:()=>Ef,ZodTransform:()=>pf,ZodTuple:()=>sf,ZodType:()=>Q,ZodULID:()=>Tl,ZodURL:()=>Hs,ZodUUID:()=>kt,ZodUndefined:()=>Km,ZodUnion:()=>Bs,ZodUnknown:()=>Xm,ZodVoid:()=>ef,ZodXID:()=>El,ZodXor:()=>of,_ZodString:()=>yl,_default:()=>Sf,_function:()=>P_,any:()=>Ll,array:()=>_,base64:()=>VS,base64url:()=>JS,bigint:()=>r_,boolean:()=>k,catch:()=>Rf,check:()=>T_,cidrv4:()=>FS,cidrv6:()=>HS,codec:()=>v_,cuid:()=>qS,cuid2:()=>MS,custom:()=>E_,date:()=>l_,describe:()=>k_,discriminatedUnion:()=>bo,e164:()=>BS,email:()=>vl,emoji:()=>OS,enum:()=>K,exactOptional:()=>mf,file:()=>__,float32:()=>QS,float64:()=>e_,function:()=>P_,guid:()=>TS,hash:()=>XS,hex:()=>YS,hostname:()=>GS,httpUrl:()=>IS,instanceof:()=>C_,int:()=>_l,int32:()=>t_,int64:()=>n_,intersection:()=>pt,invertCodec:()=>R_,ipv4:()=>US,ipv6:()=>DS,json:()=>O_,jwt:()=>WS,keyof:()=>u_,ksuid:()=>LS,lazy:()=>yo,literal:()=>b,looseObject:()=>U,looseRecord:()=>m_,mac:()=>ZS,map:()=>f_,meta:()=>$_,nan:()=>z_,nanoid:()=>NS,nativeEnum:()=>S_,never:()=>Ul,nonoptional:()=>yf,null:()=>$t,nullable:()=>Ds,nullish:()=>b_,number:()=>R,object:()=>m,optional:()=>L,partialRecord:()=>h_,pipe:()=>bl,prefault:()=>bf,preprocess:()=>Ht,promise:()=>x_,readonly:()=>Tf,record:()=>T,refine:()=>If,set:()=>g_,strictObject:()=>d_,string:()=>c,stringFormat:()=>KS,stringbool:()=>I_,success:()=>y_,superRefine:()=>Of,symbol:()=>i_,templateLiteral:()=>w_,transform:()=>Zl,tuple:()=>af,uint32:()=>o_,uint64:()=>s_,ulid:()=>AS,undefined:()=>a_,union:()=>C,unknown:()=>j,url:()=>Xr,uuid:()=>ES,uuidv4:()=>kS,uuidv6:()=>$S,uuidv7:()=>CS,void:()=>c_,xid:()=>jS,xor:()=>p_});var hl={};Ut(hl,{endsWith:()=>Ur,gt:()=>Tt,gte:()=>je,includes:()=>jr,length:()=>Vo,lowercase:()=>Mr,lt:()=>Pt,lte:()=>Xe,maxLength:()=>Ho,maxSize:()=>fo,mime:()=>Zr,minLength:()=>Dt,minSize:()=>Et,multipleOf:()=>mo,negative:()=>sl,nonnegative:()=>al,nonpositive:()=>il,normalize:()=>Dr,overwrite:()=>dt,positive:()=>nl,property:()=>cl,regex:()=>qr,size:()=>Fo,slugify:()=>Jr,startsWith:()=>Lr,toLowerCase:()=>Hr,toUpperCase:()=>Vr,trim:()=>Fr,uppercase:()=>Ar});var Qe={};Ut(Qe,{ZodISODate:()=>fl,ZodISODateTime:()=>ml,ZodISODuration:()=>Sl,ZodISOTime:()=>gl,date:()=>Om,datetime:()=>Im,duration:()=>qm,time:()=>Nm});var ml=g("ZodISODateTime",(e,t)=>{lp.init(e,t),ce.init(e,t)});function Im(e){return hh(ml,e)}var fl=g("ZodISODate",(e,t)=>{up.init(e,t),ce.init(e,t)});function Om(e){return mh(fl,e)}var gl=g("ZodISOTime",(e,t)=>{dp.init(e,t),ce.init(e,t)});function Nm(e){return fh(gl,e)}var Sl=g("ZodISODuration",(e,t)=>{pp.init(e,t),ce.init(e,t)});function qm(e){return gh(Sl,e)}var xS=(e,t)=>{Ts.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:o=>ks(e,o)},flatten:{value:o=>Es(e,o)},addIssue:{value:o=>{e.issues.push(o),e.message=JSON.stringify(e.issues,Tr,2)}},addIssues:{value:o=>{e.issues.push(...o),e.message=JSON.stringify(e.issues,Tr,2)}},isEmpty:{get(){return e.issues.length===0}}})},qv=g("ZodError",xS),Ve=g("ZodError",xS,{Parent:Error});var Mm=$r(Ve),Am=Cr(Ve),Us=Ir(Ve),jm=Or(Ve),Lm=mc(Ve),Um=fc(Ve),Zm=gc(Ve),Dm=Sc(Ve),Fm=_c(Ve),Hm=bc(Ve),Vm=yc(Ve),Jm=zc(Ve);var PS=new WeakMap;function Fs(e,t,o){let r=Object.getPrototypeOf(e),n=PS.get(r);if(n||(n=new Set,PS.set(r,n)),!n.has(t)){n.add(t);for(let s in o){let i=o[s];Object.defineProperty(r,s,{configurable:!0,enumerable:!1,get(){let a=i.bind(this);return Object.defineProperty(this,s,{configurable:!0,writable:!0,enumerable:!0,value:a}),a},set(a){Object.defineProperty(this,s,{configurable:!0,writable:!0,enumerable:!0,value:a})}})}}}var Q=g("ZodType",(e,t)=>(Y.init(e,t),Object.assign(e["~standard"],{jsonSchema:{input:Wr(e,"input"),output:Wr(e,"output")}}),e.toJSONSchema=Wh(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.parse=(o,r)=>Mm(e,o,r,{callee:e.parse}),e.safeParse=(o,r)=>Us(e,o,r),e.parseAsync=async(o,r)=>Am(e,o,r,{callee:e.parseAsync}),e.safeParseAsync=async(o,r)=>jm(e,o,r),e.spa=e.safeParseAsync,e.encode=(o,r)=>Lm(e,o,r),e.decode=(o,r)=>Um(e,o,r),e.encodeAsync=async(o,r)=>Zm(e,o,r),e.decodeAsync=async(o,r)=>Dm(e,o,r),e.safeEncode=(o,r)=>Fm(e,o,r),e.safeDecode=(o,r)=>Hm(e,o,r),e.safeEncodeAsync=async(o,r)=>Vm(e,o,r),e.safeDecodeAsync=async(o,r)=>Jm(e,o,r),Fs(e,"ZodType",{check(...o){let r=this.def;return this.clone(G.mergeDefs(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 Me(this,o,r)},brand(){return this},register(o,r){return o.add(this,r),this},refine(o,r){return this.check(If(o,r))},superRefine(o,r){return this.check(Of(o,r))},overwrite(o){return this.check(dt(o))},optional(){return L(this)},exactOptional(){return mf(this)},nullable(){return Ds(this)},nullish(){return L(Ds(this))},nonoptional(o){return yf(this,o)},array(){return _(this)},or(o){return C([this,o])},and(o){return pt(this,o)},transform(o){return bl(this,Zl(o))},default(o){return Sf(this,o)},prefault(o){return bf(this,o)},catch(o){return Rf(this,o)},pipe(o){return bl(this,o)},readonly(){return Tf(this)},describe(o){let r=this.clone();return ve.add(r,{description:o}),r},meta(...o){if(o.length===0)return ve.get(this);let r=this.clone();return ve.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 ve.get(e)?.description},configurable:!0}),e)),yl=g("_ZodString",(e,t)=>{Do.init(e,t),Q.init(e,t),e._zod.processJSONSchema=(r,n,s)=>Kh(e,r,n,s);let o=e._zod.bag;e.format=o.format??null,e.minLength=o.minimum??null,e.maxLength=o.maximum??null,Fs(e,"_ZodString",{regex(...r){return this.check(qr(...r))},includes(...r){return this.check(jr(...r))},startsWith(...r){return this.check(Lr(...r))},endsWith(...r){return this.check(Ur(...r))},min(...r){return this.check(Dt(...r))},max(...r){return this.check(Ho(...r))},length(...r){return this.check(Vo(...r))},nonempty(...r){return this.check(Dt(1,...r))},lowercase(r){return this.check(Mr(r))},uppercase(r){return this.check(Ar(r))},trim(){return this.check(Fr())},normalize(...r){return this.check(Dr(...r))},toLowerCase(){return this.check(Hr())},toUpperCase(){return this.check(Vr())},slugify(){return this.check(Jr())}})}),Yr=g("ZodString",(e,t)=>{Do.init(e,t),yl.init(e,t),e.email=o=>e.check(jc(zl,o)),e.url=o=>e.check(js(Hs,o)),e.jwt=o=>e.check(rl(Al,o)),e.emoji=o=>e.check(Fc(Rl,o)),e.guid=o=>e.check(As(Zs,o)),e.uuid=o=>e.check(Lc(kt,o)),e.uuidv4=o=>e.check(Uc(kt,o)),e.uuidv6=o=>e.check(Zc(kt,o)),e.uuidv7=o=>e.check(Dc(kt,o)),e.nanoid=o=>e.check(Hc(wl,o)),e.guid=o=>e.check(As(Zs,o)),e.cuid=o=>e.check(Vc(xl,o)),e.cuid2=o=>e.check(Jc(Pl,o)),e.ulid=o=>e.check(Bc(Tl,o)),e.base64=o=>e.check(el(Nl,o)),e.base64url=o=>e.check(tl(ql,o)),e.xid=o=>e.check(Wc(El,o)),e.ksuid=o=>e.check(Kc(kl,o)),e.ipv4=o=>e.check(Gc($l,o)),e.ipv6=o=>e.check(Yc(Cl,o)),e.cidrv4=o=>e.check(Xc(Il,o)),e.cidrv6=o=>e.check(Qc(Ol,o)),e.e164=o=>e.check(ol(Ml,o)),e.datetime=o=>e.check(Im(o)),e.date=o=>e.check(Om(o)),e.time=o=>e.check(Nm(o)),e.duration=o=>e.check(qm(o))});function c(e){return lh(Yr,e)}var ce=g("ZodStringFormat",(e,t)=>{ae.init(e,t),yl.init(e,t)}),zl=g("ZodEmail",(e,t)=>{ep.init(e,t),ce.init(e,t)});function vl(e){return jc(zl,e)}var Zs=g("ZodGUID",(e,t)=>{Xd.init(e,t),ce.init(e,t)});function TS(e){return As(Zs,e)}var kt=g("ZodUUID",(e,t)=>{Qd.init(e,t),ce.init(e,t)});function ES(e){return Lc(kt,e)}function kS(e){return Uc(kt,e)}function $S(e){return Zc(kt,e)}function CS(e){return Dc(kt,e)}var Hs=g("ZodURL",(e,t)=>{tp.init(e,t),ce.init(e,t)});function Xr(e){return js(Hs,e)}function IS(e){return js(Hs,{protocol:Ye.httpProtocol,hostname:Ye.domain,...G.normalizeParams(e)})}var Rl=g("ZodEmoji",(e,t)=>{op.init(e,t),ce.init(e,t)});function OS(e){return Fc(Rl,e)}var wl=g("ZodNanoID",(e,t)=>{rp.init(e,t),ce.init(e,t)});function NS(e){return Hc(wl,e)}var xl=g("ZodCUID",(e,t)=>{np.init(e,t),ce.init(e,t)});function qS(e){return Vc(xl,e)}var Pl=g("ZodCUID2",(e,t)=>{sp.init(e,t),ce.init(e,t)});function MS(e){return Jc(Pl,e)}var Tl=g("ZodULID",(e,t)=>{ip.init(e,t),ce.init(e,t)});function AS(e){return Bc(Tl,e)}var El=g("ZodXID",(e,t)=>{ap.init(e,t),ce.init(e,t)});function jS(e){return Wc(El,e)}var kl=g("ZodKSUID",(e,t)=>{cp.init(e,t),ce.init(e,t)});function LS(e){return Kc(kl,e)}var $l=g("ZodIPv4",(e,t)=>{hp.init(e,t),ce.init(e,t)});function US(e){return Gc($l,e)}var Bm=g("ZodMAC",(e,t)=>{fp.init(e,t),ce.init(e,t)});function ZS(e){return dh(Bm,e)}var Cl=g("ZodIPv6",(e,t)=>{mp.init(e,t),ce.init(e,t)});function DS(e){return Yc(Cl,e)}var Il=g("ZodCIDRv4",(e,t)=>{gp.init(e,t),ce.init(e,t)});function FS(e){return Xc(Il,e)}var Ol=g("ZodCIDRv6",(e,t)=>{Sp.init(e,t),ce.init(e,t)});function HS(e){return Qc(Ol,e)}var Nl=g("ZodBase64",(e,t)=>{bp.init(e,t),ce.init(e,t)});function VS(e){return el(Nl,e)}var ql=g("ZodBase64URL",(e,t)=>{yp.init(e,t),ce.init(e,t)});function JS(e){return tl(ql,e)}var Ml=g("ZodE164",(e,t)=>{zp.init(e,t),ce.init(e,t)});function BS(e){return ol(Ml,e)}var Al=g("ZodJWT",(e,t)=>{vp.init(e,t),ce.init(e,t)});function WS(e){return rl(Al,e)}var Qr=g("ZodCustomStringFormat",(e,t)=>{Rp.init(e,t),ce.init(e,t)});function KS(e,t,o={}){return Br(Qr,e,t,o)}function GS(e){return Br(Qr,"hostname",Ye.hostname,e)}function YS(e){return Br(Qr,"hex",Ye.hex,e)}function XS(e,t){let o=t?.enc??"hex",r=`${e}_${o}`,n=Ye[r];if(!n)throw new Error(`Unrecognized hash format: ${r}`);return Br(Qr,r,n,t)}var en=g("ZodNumber",(e,t)=>{$c.init(e,t),Q.init(e,t),e._zod.processJSONSchema=(r,n,s)=>Gh(e,r,n,s),Fs(e,"ZodNumber",{gt(r,n){return this.check(Tt(r,n))},gte(r,n){return this.check(je(r,n))},min(r,n){return this.check(je(r,n))},lt(r,n){return this.check(Pt(r,n))},lte(r,n){return this.check(Xe(r,n))},max(r,n){return this.check(Xe(r,n))},int(r){return this.check(_l(r))},safe(r){return this.check(_l(r))},positive(r){return this.check(Tt(0,r))},nonnegative(r){return this.check(je(0,r))},negative(r){return this.check(Pt(0,r))},nonpositive(r){return this.check(Xe(0,r))},multipleOf(r,n){return this.check(mo(r,n))},step(r,n){return this.check(mo(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??.5),e.isFinite=!0,e.format=o.format??null});function R(e){return Sh(en,e)}var Bo=g("ZodNumberFormat",(e,t)=>{wp.init(e,t),en.init(e,t)});function _l(e){return bh(Bo,e)}function QS(e){return yh(Bo,e)}function e_(e){return zh(Bo,e)}function t_(e){return vh(Bo,e)}function o_(e){return Rh(Bo,e)}var tn=g("ZodBoolean",(e,t)=>{Os.init(e,t),Q.init(e,t),e._zod.processJSONSchema=(o,r,n)=>Yh(e,o,r,n)});function k(e){return wh(tn,e)}var on=g("ZodBigInt",(e,t)=>{Cc.init(e,t),Q.init(e,t),e._zod.processJSONSchema=(r,n,s)=>Xh(e,r,n,s),e.gte=(r,n)=>e.check(je(r,n)),e.min=(r,n)=>e.check(je(r,n)),e.gt=(r,n)=>e.check(Tt(r,n)),e.gte=(r,n)=>e.check(je(r,n)),e.min=(r,n)=>e.check(je(r,n)),e.lt=(r,n)=>e.check(Pt(r,n)),e.lte=(r,n)=>e.check(Xe(r,n)),e.max=(r,n)=>e.check(Xe(r,n)),e.positive=r=>e.check(Tt(BigInt(0),r)),e.negative=r=>e.check(Pt(BigInt(0),r)),e.nonpositive=r=>e.check(Xe(BigInt(0),r)),e.nonnegative=r=>e.check(je(BigInt(0),r)),e.multipleOf=(r,n)=>e.check(mo(r,n));let o=e._zod.bag;e.minValue=o.minimum??null,e.maxValue=o.maximum??null,e.format=o.format??null});function r_(e){return Ph(on,e)}var jl=g("ZodBigIntFormat",(e,t)=>{xp.init(e,t),on.init(e,t)});function n_(e){return Eh(jl,e)}function s_(e){return kh(jl,e)}var Wm=g("ZodSymbol",(e,t)=>{Pp.init(e,t),Q.init(e,t),e._zod.processJSONSchema=(o,r,n)=>Qh(e,o,r,n)});function i_(e){return $h(Wm,e)}var Km=g("ZodUndefined",(e,t)=>{Tp.init(e,t),Q.init(e,t),e._zod.processJSONSchema=(o,r,n)=>tm(e,o,r,n)});function a_(e){return Ch(Km,e)}var Gm=g("ZodNull",(e,t)=>{Ep.init(e,t),Q.init(e,t),e._zod.processJSONSchema=(o,r,n)=>em(e,o,r,n)});function $t(e){return Ih(Gm,e)}var Ym=g("ZodAny",(e,t)=>{kp.init(e,t),Q.init(e,t),e._zod.processJSONSchema=(o,r,n)=>nm(e,o,r,n)});function Ll(){return Oh(Ym)}var Xm=g("ZodUnknown",(e,t)=>{$p.init(e,t),Q.init(e,t),e._zod.processJSONSchema=(o,r,n)=>sm(e,o,r,n)});function j(){return Nh(Xm)}var Qm=g("ZodNever",(e,t)=>{Cp.init(e,t),Q.init(e,t),e._zod.processJSONSchema=(o,r,n)=>rm(e,o,r,n)});function Ul(e){return qh(Qm,e)}var ef=g("ZodVoid",(e,t)=>{Ip.init(e,t),Q.init(e,t),e._zod.processJSONSchema=(o,r,n)=>om(e,o,r,n)});function c_(e){return Mh(ef,e)}var Vs=g("ZodDate",(e,t)=>{Op.init(e,t),Q.init(e,t),e._zod.processJSONSchema=(r,n,s)=>im(e,r,n,s),e.min=(r,n)=>e.check(je(r,n)),e.max=(r,n)=>e.check(Xe(r,n));let o=e._zod.bag;e.minDate=o.minimum?new Date(o.minimum):null,e.maxDate=o.maximum?new Date(o.maximum):null});function l_(e){return Ah(Vs,e)}var tf=g("ZodArray",(e,t)=>{Np.init(e,t),Q.init(e,t),e._zod.processJSONSchema=(o,r,n)=>_m(e,o,r,n),e.element=t.element,Fs(e,"ZodArray",{min(o,r){return this.check(Dt(o,r))},nonempty(o){return this.check(Dt(1,o))},max(o,r){return this.check(Ho(o,r))},length(o,r){return this.check(Vo(o,r))},unwrap(){return this.element}})});function _(e,t){return Uh(tf,e,t)}function u_(e){let t=e._zod.def.shape;return K(Object.keys(t))}var Js=g("ZodObject",(e,t)=>{qp.init(e,t),Q.init(e,t),e._zod.processJSONSchema=(o,r,n)=>bm(e,o,r,n),G.defineLazy(e,"shape",()=>t.shape),Fs(e,"ZodObject",{keyof(){return K(Object.keys(this._zod.def.shape))},catchall(o){return this.clone({...this._zod.def,catchall:o})},passthrough(){return this.clone({...this._zod.def,catchall:j()})},loose(){return this.clone({...this._zod.def,catchall:j()})},strict(){return this.clone({...this._zod.def,catchall:Ul()})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(o){return G.extend(this,o)},safeExtend(o){return G.safeExtend(this,o)},merge(o){return G.merge(this,o)},pick(o){return G.pick(this,o)},omit(o){return G.omit(this,o)},partial(...o){return G.partial(Dl,this,o[0])},required(...o){return G.required(Fl,this,o[0])}})});function m(e,t){let o={type:"object",shape:e??{},...G.normalizeParams(t)};return new Js(o)}function d_(e,t){return new Js({type:"object",shape:e,catchall:Ul(),...G.normalizeParams(t)})}function U(e,t){return new Js({type:"object",shape:e,catchall:j(),...G.normalizeParams(t)})}var Bs=g("ZodUnion",(e,t)=>{Ns.init(e,t),Q.init(e,t),e._zod.processJSONSchema=(o,r,n)=>ul(e,o,r,n),e.options=t.options});function C(e,t){return new Bs({type:"union",options:e,...G.normalizeParams(t)})}var of=g("ZodXor",(e,t)=>{Bs.init(e,t),Mp.init(e,t),e._zod.processJSONSchema=(o,r,n)=>ul(e,o,r,n),e.options=t.options});function p_(e,t){return new of({type:"union",options:e,inclusive:!1,...G.normalizeParams(t)})}var rf=g("ZodDiscriminatedUnion",(e,t)=>{Bs.init(e,t),Ap.init(e,t)});function bo(e,t,o){return new rf({type:"union",options:t,discriminator:e,...G.normalizeParams(o)})}var nf=g("ZodIntersection",(e,t)=>{jp.init(e,t),Q.init(e,t),e._zod.processJSONSchema=(o,r,n)=>ym(e,o,r,n)});function pt(e,t){return new nf({type:"intersection",left:e,right:t})}var sf=g("ZodTuple",(e,t)=>{Ic.init(e,t),Q.init(e,t),e._zod.processJSONSchema=(o,r,n)=>zm(e,o,r,n),e.rest=o=>e.clone({...e._zod.def,rest:o})});function af(e,t,o){let r=t instanceof Y,n=r?o:t,s=r?t:null;return new sf({type:"tuple",items:e,rest:s,...G.normalizeParams(n)})}var Kr=g("ZodRecord",(e,t)=>{Lp.init(e,t),Q.init(e,t),e._zod.processJSONSchema=(o,r,n)=>vm(e,o,r,n),e.keyType=t.keyType,e.valueType=t.valueType});function T(e,t,o){return!t||!t._zod?new Kr({type:"record",keyType:c(),valueType:e,...G.normalizeParams(t)}):new Kr({type:"record",keyType:e,valueType:t,...G.normalizeParams(o)})}function h_(e,t,o){let r=Me(e);return r._zod.values=void 0,new Kr({type:"record",keyType:r,valueType:t,...G.normalizeParams(o)})}function m_(e,t,o){return new Kr({type:"record",keyType:e,valueType:t,mode:"loose",...G.normalizeParams(o)})}var cf=g("ZodMap",(e,t)=>{Up.init(e,t),Q.init(e,t),e._zod.processJSONSchema=(o,r,n)=>gm(e,o,r,n),e.keyType=t.keyType,e.valueType=t.valueType,e.min=(...o)=>e.check(Et(...o)),e.nonempty=o=>e.check(Et(1,o)),e.max=(...o)=>e.check(fo(...o)),e.size=(...o)=>e.check(Fo(...o))});function f_(e,t,o){return new cf({type:"map",keyType:e,valueType:t,...G.normalizeParams(o)})}var lf=g("ZodSet",(e,t)=>{Zp.init(e,t),Q.init(e,t),e._zod.processJSONSchema=(o,r,n)=>Sm(e,o,r,n),e.min=(...o)=>e.check(Et(...o)),e.nonempty=o=>e.check(Et(1,o)),e.max=(...o)=>e.check(fo(...o)),e.size=(...o)=>e.check(Fo(...o))});function g_(e,t){return new lf({type:"set",valueType:e,...G.normalizeParams(t)})}var Gr=g("ZodEnum",(e,t)=>{Dp.init(e,t),Q.init(e,t),e._zod.processJSONSchema=(r,n,s)=>am(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 new Error(`Key ${i} not found in enum`);return new Gr({...t,checks:[],...G.normalizeParams(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 new Error(`Key ${i} not found in enum`);return new Gr({...t,checks:[],...G.normalizeParams(n),entries:s})}});function K(e,t){let o=Array.isArray(e)?Object.fromEntries(e.map(r=>[r,r])):e;return new Gr({type:"enum",entries:o,...G.normalizeParams(t)})}function S_(e,t){return new Gr({type:"enum",entries:e,...G.normalizeParams(t)})}var uf=g("ZodLiteral",(e,t)=>{Fp.init(e,t),Q.init(e,t),e._zod.processJSONSchema=(o,r,n)=>cm(e,o,r,n),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function b(e,t){return new uf({type:"literal",values:Array.isArray(e)?e:[e],...G.normalizeParams(t)})}var df=g("ZodFile",(e,t)=>{Hp.init(e,t),Q.init(e,t),e._zod.processJSONSchema=(o,r,n)=>dm(e,o,r,n),e.min=(o,r)=>e.check(Et(o,r)),e.max=(o,r)=>e.check(fo(o,r)),e.mime=(o,r)=>e.check(Zr(Array.isArray(o)?o:[o],r))});function __(e){return Zh(df,e)}var pf=g("ZodTransform",(e,t)=>{Vp.init(e,t),Q.init(e,t),e._zod.processJSONSchema=(o,r,n)=>fm(e,o,r,n),e._zod.parse=(o,r)=>{if(r.direction==="backward")throw new co(e.constructor.name);o.addIssue=s=>{if(typeof s=="string")o.issues.push(G.issue(s,o.value,t));else{let i=s;i.fatal&&(i.continue=!1),i.code??(i.code="custom"),i.input??(i.input=o.value),i.inst??(i.inst=e),o.issues.push(G.issue(i))}};let n=t.transform(o.value,o);return n instanceof Promise?n.then(s=>(o.value=s,o.fallback=!0,o)):(o.value=n,o.fallback=!0,o)}});function Zl(e){return new pf({type:"transform",transform:e})}var Dl=g("ZodOptional",(e,t)=>{Oc.init(e,t),Q.init(e,t),e._zod.processJSONSchema=(o,r,n)=>dl(e,o,r,n),e.unwrap=()=>e._zod.def.innerType});function L(e){return new Dl({type:"optional",innerType:e})}var hf=g("ZodExactOptional",(e,t)=>{Jp.init(e,t),Q.init(e,t),e._zod.processJSONSchema=(o,r,n)=>dl(e,o,r,n),e.unwrap=()=>e._zod.def.innerType});function mf(e){return new hf({type:"optional",innerType:e})}var ff=g("ZodNullable",(e,t)=>{Bp.init(e,t),Q.init(e,t),e._zod.processJSONSchema=(o,r,n)=>Rm(e,o,r,n),e.unwrap=()=>e._zod.def.innerType});function Ds(e){return new ff({type:"nullable",innerType:e})}function b_(e){return L(Ds(e))}var gf=g("ZodDefault",(e,t)=>{Wp.init(e,t),Q.init(e,t),e._zod.processJSONSchema=(o,r,n)=>xm(e,o,r,n),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function Sf(e,t){return new gf({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():G.shallowClone(t)}})}var _f=g("ZodPrefault",(e,t)=>{Kp.init(e,t),Q.init(e,t),e._zod.processJSONSchema=(o,r,n)=>Pm(e,o,r,n),e.unwrap=()=>e._zod.def.innerType});function bf(e,t){return new _f({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():G.shallowClone(t)}})}var Fl=g("ZodNonOptional",(e,t)=>{Gp.init(e,t),Q.init(e,t),e._zod.processJSONSchema=(o,r,n)=>wm(e,o,r,n),e.unwrap=()=>e._zod.def.innerType});function yf(e,t){return new Fl({type:"nonoptional",innerType:e,...G.normalizeParams(t)})}var zf=g("ZodSuccess",(e,t)=>{Yp.init(e,t),Q.init(e,t),e._zod.processJSONSchema=(o,r,n)=>pm(e,o,r,n),e.unwrap=()=>e._zod.def.innerType});function y_(e){return new zf({type:"success",innerType:e})}var vf=g("ZodCatch",(e,t)=>{Xp.init(e,t),Q.init(e,t),e._zod.processJSONSchema=(o,r,n)=>Tm(e,o,r,n),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function Rf(e,t){return new vf({type:"catch",innerType:e,catchValue:typeof t=="function"?t:()=>t})}var wf=g("ZodNaN",(e,t)=>{Qp.init(e,t),Q.init(e,t),e._zod.processJSONSchema=(o,r,n)=>lm(e,o,r,n)});function z_(e){return Lh(wf,e)}var Ws=g("ZodPipe",(e,t)=>{Nc.init(e,t),Q.init(e,t),e._zod.processJSONSchema=(o,r,n)=>Em(e,o,r,n),e.in=t.in,e.out=t.out});function bl(e,t){return new Ws({type:"pipe",in:e,out:t})}var Ks=g("ZodCodec",(e,t)=>{Ws.init(e,t),qs.init(e,t)});function v_(e,t,o){return new Ks({type:"pipe",in:e,out:t,transform:o.decode,reverseTransform:o.encode})}function R_(e){let t=e._zod.def;return new Ks({type:"pipe",in:t.out,out:t.in,transform:t.reverseTransform,reverseTransform:t.transform})}var xf=g("ZodPreprocess",(e,t)=>{Ws.init(e,t),eh.init(e,t)}),Pf=g("ZodReadonly",(e,t)=>{th.init(e,t),Q.init(e,t),e._zod.processJSONSchema=(o,r,n)=>km(e,o,r,n),e.unwrap=()=>e._zod.def.innerType});function Tf(e){return new Pf({type:"readonly",innerType:e})}var Ef=g("ZodTemplateLiteral",(e,t)=>{oh.init(e,t),Q.init(e,t),e._zod.processJSONSchema=(o,r,n)=>um(e,o,r,n)});function w_(e,t){return new Ef({type:"template_literal",parts:e,...G.normalizeParams(t)})}var kf=g("ZodLazy",(e,t)=>{sh.init(e,t),Q.init(e,t),e._zod.processJSONSchema=(o,r,n)=>Cm(e,o,r,n),e.unwrap=()=>e._zod.def.getter()});function yo(e){return new kf({type:"lazy",getter:e})}var $f=g("ZodPromise",(e,t)=>{nh.init(e,t),Q.init(e,t),e._zod.processJSONSchema=(o,r,n)=>$m(e,o,r,n),e.unwrap=()=>e._zod.def.innerType});function x_(e){return new $f({type:"promise",innerType:e})}var Cf=g("ZodFunction",(e,t)=>{rh.init(e,t),Q.init(e,t),e._zod.processJSONSchema=(o,r,n)=>mm(e,o,r,n)});function P_(e){return new Cf({type:"function",input:Array.isArray(e?.input)?af(e?.input):e?.input??_(j()),output:e?.output??j()})}var Gs=g("ZodCustom",(e,t)=>{ih.init(e,t),Q.init(e,t),e._zod.processJSONSchema=(o,r,n)=>hm(e,o,r,n)});function T_(e){let t=new le({check:"custom"});return t._zod.check=e,t}function E_(e,t){return Dh(Gs,e??(()=>!0),t)}function If(e,t={}){return Fh(Gs,e,t)}function Of(e,t){return Hh(e,t)}var k_=Vh,$_=Jh;function C_(e,t={}){let o=new Gs({type:"custom",check:"custom",fn:r=>r instanceof e,abort:!0,...G.normalizeParams(t)});return o._zod.bag.Class=e,o._zod.check=r=>{r.value instanceof e||r.issues.push({code:"invalid_type",expected:e.name,input:r.value,inst:o,path:[...o._zod.def.path??[]]})},o}var I_=(...e)=>Bh({Codec:Ks,Boolean:tn,String:Yr},...e);function O_(e){let t=yo(()=>C([c(e),R(),k(),$t(),_(t),T(c(),t)]));return t}function Ht(e,t){return new xf({type:"pipe",in:Zl(e),out:t})}var qf={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"};function Av(e){ge({customError:e})}function jv(){return ge().customError}var Nf;Nf||(Nf={});var $={...Ls,...hl,iso:Qe},Lv=new Set(["$schema","$ref","$defs","definitions","$id","id","$comment","$anchor","$vocabulary","$dynamicRef","$dynamicAnchor","type","enum","const","anyOf","oneOf","allOf","not","properties","required","additionalProperties","patternProperties","propertyNames","minProperties","maxProperties","items","prefixItems","additionalItems","minItems","maxItems","uniqueItems","contains","minContains","maxContains","minLength","maxLength","pattern","format","minimum","maximum","exclusiveMinimum","exclusiveMaximum","multipleOf","description","default","contentEncoding","contentMediaType","contentSchema","unevaluatedItems","unevaluatedProperties","if","then","else","dependentSchemas","dependentRequired","nullable","readOnly"]);function Uv(e,t){let o=e.$schema;return o==="https://json-schema.org/draft/2020-12/schema"?"draft-2020-12":o==="http://json-schema.org/draft-07/schema#"?"draft-7":o==="http://json-schema.org/draft-04/schema#"?"draft-4":t??"draft-2020-12"}function Zv(e,t){if(!e.startsWith("#"))throw new Error("External $ref is not supported, only local refs (#/...) are allowed");let o=e.slice(1).split("/").filter(Boolean);if(o.length===0)return t.rootSchema;let r=t.version==="draft-2020-12"?"$defs":"definitions";if(o[0]===r){let n=o[1];if(!n||!t.defs[n])throw new Error(`Reference not found: ${e}`);return t.defs[n]}throw new Error(`Reference not found: ${e}`)}function N_(e,t){if(e.not!==void 0){if(typeof e.not=="object"&&Object.keys(e.not).length===0)return $.never();throw new Error("not is not supported in Zod (except { not: {} } for never)")}if(e.unevaluatedItems!==void 0)throw new Error("unevaluatedItems is not supported");if(e.unevaluatedProperties!==void 0)throw new Error("unevaluatedProperties is not supported");if(e.if!==void 0||e.then!==void 0||e.else!==void 0)throw new Error("Conditional schemas (if/then/else) are not supported");if(e.dependentSchemas!==void 0||e.dependentRequired!==void 0)throw new Error("dependentSchemas and dependentRequired are not supported");if(e.$ref){let n=e.$ref;if(t.refs.has(n))return t.refs.get(n);if(t.processing.has(n))return $.lazy(()=>{if(!t.refs.has(n))throw new Error(`Circular reference not resolved: ${n}`);return t.refs.get(n)});t.processing.add(n);let s=Zv(n,t),i=Ee(s,t);return t.refs.set(n,i),t.processing.delete(n),i}if(e.enum!==void 0){let n=e.enum;if(t.version==="openapi-3.0"&&e.nullable===!0&&n.length===1&&n[0]===null)return $.null();if(n.length===0)return $.never();if(n.length===1)return $.literal(n[0]);if(n.every(i=>typeof i=="string"))return $.enum(n);let s=n.map(i=>$.literal(i));return s.length<2?s[0]:$.union([s[0],s[1],...s.slice(2)])}if(e.const!==void 0)return $.literal(e.const);let o=e.type;if(Array.isArray(o)){let n=o.map(s=>{let i={...e,type:s};return N_(i,t)});return n.length===0?$.never():n.length===1?n[0]:$.union(n)}if(!o)return $.any();let r;switch(o){case"string":{let n=$.string();if(e.format){let s=e.format;s==="email"?n=n.check($.email()):s==="uri"||s==="uri-reference"?n=n.check($.url()):s==="uuid"||s==="guid"?n=n.check($.uuid()):s==="date-time"?n=n.check($.iso.datetime()):s==="date"?n=n.check($.iso.date()):s==="time"?n=n.check($.iso.time()):s==="duration"?n=n.check($.iso.duration()):s==="ipv4"?n=n.check($.ipv4()):s==="ipv6"?n=n.check($.ipv6()):s==="mac"?n=n.check($.mac()):s==="cidr"?n=n.check($.cidrv4()):s==="cidr-v6"?n=n.check($.cidrv6()):s==="base64"?n=n.check($.base64()):s==="base64url"?n=n.check($.base64url()):s==="e164"?n=n.check($.e164()):s==="jwt"?n=n.check($.jwt()):s==="emoji"?n=n.check($.emoji()):s==="nanoid"?n=n.check($.nanoid()):s==="cuid"?n=n.check($.cuid()):s==="cuid2"?n=n.check($.cuid2()):s==="ulid"?n=n.check($.ulid()):s==="xid"?n=n.check($.xid()):s==="ksuid"&&(n=n.check($.ksuid()))}typeof e.minLength=="number"&&(n=n.min(e.minLength)),typeof e.maxLength=="number"&&(n=n.max(e.maxLength)),e.pattern&&(n=n.regex(new RegExp(e.pattern))),r=n;break}case"number":case"integer":{let n=o==="integer"?$.number().int():$.number();typeof e.minimum=="number"&&(n=n.min(e.minimum)),typeof e.maximum=="number"&&(n=n.max(e.maximum)),typeof e.exclusiveMinimum=="number"?n=n.gt(e.exclusiveMinimum):e.exclusiveMinimum===!0&&typeof e.minimum=="number"&&(n=n.gt(e.minimum)),typeof e.exclusiveMaximum=="number"?n=n.lt(e.exclusiveMaximum):e.exclusiveMaximum===!0&&typeof e.maximum=="number"&&(n=n.lt(e.maximum)),typeof e.multipleOf=="number"&&(n=n.multipleOf(e.multipleOf)),r=n;break}case"boolean":{r=$.boolean();break}case"null":{r=$.null();break}case"object":{let n={},s=e.properties||{},i=new Set(e.required||[]);for(let[l,u]of Object.entries(s)){let d=Ee(u,t);n[l]=i.has(l)?d:d.optional()}if(e.propertyNames){let l=Ee(e.propertyNames,t),u=e.additionalProperties&&typeof e.additionalProperties=="object"?Ee(e.additionalProperties,t):$.any();if(Object.keys(n).length===0){r=$.record(l,u);break}let d=$.object(n).passthrough(),h=$.looseRecord(l,u);r=$.intersection(d,h);break}if(e.patternProperties){let l=e.patternProperties,u=Object.keys(l),d=[];for(let f of u){let S=Ee(l[f],t),y=$.string().regex(new RegExp(f));d.push($.looseRecord(y,S))}let h=[];if(Object.keys(n).length>0&&h.push($.object(n).passthrough()),h.push(...d),h.length===0)r=$.object({}).passthrough();else if(h.length===1)r=h[0];else{let f=$.intersection(h[0],h[1]);for(let S=2;S<h.length;S++)f=$.intersection(f,h[S]);r=f}break}let a=$.object(n);e.additionalProperties===!1?r=a.strict():typeof e.additionalProperties=="object"?r=a.catchall(Ee(e.additionalProperties,t)):r=a.passthrough();break}case"array":{let n=e.prefixItems,s=e.items;if(n&&Array.isArray(n)){let i=n.map(l=>Ee(l,t)),a=s&&typeof s=="object"&&!Array.isArray(s)?Ee(s,t):void 0;a?r=$.tuple(i).rest(a):r=$.tuple(i),typeof e.minItems=="number"&&(r=r.check($.minLength(e.minItems))),typeof e.maxItems=="number"&&(r=r.check($.maxLength(e.maxItems)))}else if(Array.isArray(s)){let i=s.map(l=>Ee(l,t)),a=e.additionalItems&&typeof e.additionalItems=="object"?Ee(e.additionalItems,t):void 0;a?r=$.tuple(i).rest(a):r=$.tuple(i),typeof e.minItems=="number"&&(r=r.check($.minLength(e.minItems))),typeof e.maxItems=="number"&&(r=r.check($.maxLength(e.maxItems)))}else if(s!==void 0){let i=Ee(s,t),a=$.array(i);typeof e.minItems=="number"&&(a=a.min(e.minItems)),typeof e.maxItems=="number"&&(a=a.max(e.maxItems)),r=a}else r=$.array($.any());break}default:throw new Error(`Unsupported type: ${o}`)}return r}function Ee(e,t){if(typeof e=="boolean")return e?$.any():$.never();let o=N_(e,t),r=e.type||e.enum!==void 0||e.const!==void 0;if(e.anyOf&&Array.isArray(e.anyOf)){let a=e.anyOf.map(u=>Ee(u,t)),l=$.union(a);o=r?$.intersection(o,l):l}if(e.oneOf&&Array.isArray(e.oneOf)){let a=e.oneOf.map(u=>Ee(u,t)),l=$.xor(a);o=r?$.intersection(o,l):l}if(e.allOf&&Array.isArray(e.allOf))if(e.allOf.length===0)o=r?o:$.any();else{let a=r?o:Ee(e.allOf[0],t),l=r?0:1;for(let u=l;u<e.allOf.length;u++)a=$.intersection(a,Ee(e.allOf[u],t));o=a}e.nullable===!0&&t.version==="openapi-3.0"&&(o=$.nullable(o)),e.readOnly===!0&&(o=$.readonly(o)),e.default!==void 0&&(o=o.default(e.default));let n={},s=["$id","id","$comment","$anchor","$vocabulary","$dynamicRef","$dynamicAnchor"];for(let a of s)a in e&&(n[a]=e[a]);let i=["contentEncoding","contentMediaType","contentSchema"];for(let a of i)a in e&&(n[a]=e[a]);for(let a of Object.keys(e))Lv.has(a)||(n[a]=e[a]);return Object.keys(n).length>0&&t.registry.add(o,n),e.description&&(o=o.describe(e.description)),o}function q_(e,t){if(typeof e=="boolean")return e?$.any():$.never();let o;try{o=JSON.parse(JSON.stringify(e))}catch{throw new Error("fromJSONSchema input is not valid JSON (possibly cyclic); use $defs/$ref for recursive schemas")}let r=Uv(o,t?.defaultTarget),n=o.$defs||o.definitions||{},s={version:r,defs:n,refs:new Map,processing:new Set,rootSchema:o,registry:t?.registry??ve};return Ee(o,s)}var Ys={};Ut(Ys,{bigint:()=>Vv,boolean:()=>Hv,date:()=>Jv,number:()=>Fv,string:()=>Dv});function Dv(e){return uh(Yr,e)}function Fv(e){return _h(en,e)}function Hv(e){return xh(tn,e)}function Vv(e){return Th(on,e)}function Jv(e){return jh(Vs,e)}ge(qc());var rn="2025-11-25";var Hl=[rn,"2025-06-18","2025-03-26","2024-11-05","2024-10-07"],Vl="io.modelcontextprotocol/related-task",Jt="io.modelcontextprotocol/protocolVersion",nn="io.modelcontextprotocol/clientInfo",Bt="io.modelcontextprotocol/serverInfo",Wo="io.modelcontextprotocol/clientCapabilities",Xs="io.modelcontextprotocol/subscriptionId",sn="io.modelcontextprotocol/logLevel";var Ko="2.0";var Vt=yo(()=>C([c(),R(),k(),$t(),T(c(),Vt),_(Vt)])),pe=T(c(),Vt),Jl=_(Vt),an=C([c(),R().int()]),cn=c(),Qs=m({ttl:R().optional()}),ei=m({taskId:c()}),ln=U({progressToken:an.optional(),[Vl]:ei.optional()}),ye=m({_meta:ln.optional()}),vo=ye.extend({task:Qs.optional()}),he=m({method:c(),params:ye.loose().optional()}),ke=m({_meta:ln.optional()}),Re=m({method:c(),params:ke.loose().optional()}),un=U({get[Bt](){return It.optional().catch(void 0)}}),me=U({_meta:un.optional()}),ht=C([c(),R().int()]),dn=m({jsonrpc:b(Ko),id:ht,...he.shape}).strict(),pn=m({jsonrpc:b(Ko),...Re.shape}).strict(),Go=m({jsonrpc:b(Ko),id:ht,result:me}).strict(),Yo=m({jsonrpc:b(Ko),id:ht.optional(),error:m({code:R().int(),message:c(),data:j().optional()})}).strict(),mt=C([dn,pn,Go,Yo]),Bl=C([Go,Yo]),Ro=me.strict(),ti=ke.extend({requestId:ht.optional(),reason:c().optional()}),hn=Re.extend({method:b("notifications/cancelled"),params:ti}),oi=m({src:c(),mimeType:c().optional(),sizes:_(c()).optional(),theme:K(["light","dark"]).optional()}),Wt=m({icons:_(oi).optional()}),Ct=m({name:c(),title:c().optional()}),It=Ct.extend({...Ct.shape,...Wt.shape,version:c(),websiteUrl:c().optional(),description:c().optional()}),Wv=pt(m({applyDefaults:k().optional()}),pe),Kv=Ht(e=>e&&typeof e=="object"&&!Array.isArray(e)&&Object.keys(e).length===0?{form:{}}:e,pt(m({form:Wv.optional(),url:pe.optional()}),pe.optional())),Wl=U({list:pe.optional(),cancel:pe.optional(),requests:U({sampling:U({createMessage:pe.optional()}).optional(),elicitation:U({create:pe.optional()}).optional()}).optional()}),Kl=U({list:pe.optional(),cancel:pe.optional(),requests:U({tools:U({call:pe.optional()}).optional()}).optional()}),ri=m({experimental:T(c(),pe).optional(),sampling:m({context:pe.optional(),tools:pe.optional()}).optional(),elicitation:Kv.optional(),roots:m({listChanged:k().optional()}).optional(),tasks:Wl.optional(),extensions:T(c(),pe).optional()}),ni=ye.extend({protocolVersion:c(),capabilities:ri,clientInfo:It}),mn=he.extend({method:b("initialize"),params:ni}),fn=m({experimental:T(c(),pe).optional(),logging:pe.optional(),completions:pe.optional(),prompts:m({listChanged:k().optional()}).optional(),resources:m({subscribe:k().optional(),listChanged:k().optional()}).optional(),tools:m({listChanged:k().optional()}).optional(),tasks:Kl.optional(),extensions:T(c(),pe).optional()}),si=me.extend({protocolVersion:c(),capabilities:fn,serverInfo:It,instructions:c().optional()}),gn=Re.extend({method:b("notifications/initialized"),params:ke.optional()}),ii=he.extend({method:b("server/discover"),params:ye.optional()}),wo=me.extend({supportedVersions:_(c()),capabilities:fn,instructions:c().optional()}),Sn=he.extend({method:b("ping"),params:ye.optional()}),ai=m({progress:R(),total:L(R()),message:L(c())}),ci=m({...ke.shape,...ai.shape,progressToken:an}),_n=Re.extend({method:b("notifications/progress"),params:ci}),li=ye.extend({cursor:cn.optional()}),Kt=he.extend({params:li.optional()}),Gt=me.extend({nextCursor:cn.optional()}),bn=m({uri:c(),mimeType:L(c()),_meta:T(c(),j()).optional()}),yn=bn.extend({text:c()}),Af=c().refine(e=>{try{return atob(e),!0}catch{return!1}},{message:"Invalid Base64 string"}),zn=bn.extend({blob:Af}),Yt=K(["user","assistant"]),Ot=m({audience:_(Yt).optional(),priority:R().min(0).max(1).optional(),lastModified:Qe.datetime({offset:!0}).optional()}),vn=m({...Ct.shape,...Wt.shape,uri:c(),description:L(c()),mimeType:L(c()),size:L(R()),annotations:Ot.optional(),_meta:L(U({}))}),ui=m({...Ct.shape,...Wt.shape,uriTemplate:c(),description:L(c()),mimeType:L(c()),annotations:Ot.optional(),_meta:L(U({}))}),di=Kt.extend({method:b("resources/list")}),pi=Gt.extend({resources:_(vn)}),hi=Kt.extend({method:b("resources/templates/list")}),mi=Gt.extend({resourceTemplates:_(ui)}),Xo=ye.extend({uri:c()}),fi=Xo,gi=he.extend({method:b("resources/read"),params:fi}),Si=me.extend({contents:_(C([yn,zn]))}),_i=Re.extend({method:b("notifications/resources/list_changed"),params:ke.optional()}),bi=Xo,yi=he.extend({method:b("resources/subscribe"),params:bi}),zi=Xo,vi=he.extend({method:b("resources/unsubscribe"),params:zi}),Rn=m({toolsListChanged:k().optional(),promptsListChanged:k().optional(),resourcesListChanged:k().optional(),resourceSubscriptions:_(c()).optional()}),Ri=ye.extend({notifications:Rn}),wi=he.extend({method:b("subscriptions/listen"),params:Ri}),xi=ke.extend({notifications:Rn}),Pi=Re.extend({method:b("notifications/subscriptions/acknowledged"),params:xi}),Ti=un.extend({[Xs]:ht}),Ei=me.extend({_meta:Ti}),ki=ke.extend({uri:c()}),$i=Re.extend({method:b("notifications/resources/updated"),params:ki}),Ci=m({name:c(),description:L(c()),required:L(k())}),Ii=m({...Ct.shape,...Wt.shape,description:L(c()),arguments:L(_(Ci)),_meta:L(U({}))}),Oi=Kt.extend({method:b("prompts/list")}),Ni=Gt.extend({prompts:_(Ii)}),qi=ye.extend({name:c(),arguments:T(c(),c()).optional()}),Mi=he.extend({method:b("prompts/get"),params:qi}),Qo=m({type:b("text"),text:c(),annotations:Ot.optional(),_meta:T(c(),j()).optional()}),er=m({type:b("image"),data:Af,mimeType:c(),annotations:Ot.optional(),_meta:T(c(),j()).optional()}),tr=m({type:b("audio"),data:Af,mimeType:c(),annotations:Ot.optional(),_meta:T(c(),j()).optional()}),Ai=m({type:b("tool_use"),name:c(),id:c(),input:T(c(),j()),_meta:T(c(),j()).optional()}),or=m({type:b("resource"),resource:C([yn,zn]),annotations:Ot.optional(),_meta:T(c(),j()).optional()}),rr=vn.extend({type:b("resource_link")}),Nt=C([Qo,er,tr,rr,or]),ji=m({role:Yt,content:Nt}),Li=me.extend({description:c().optional(),messages:_(ji)}),Ui=Re.extend({method:b("notifications/prompts/list_changed"),params:ke.optional()}),Zi=m({title:c().optional(),readOnlyHint:k().optional(),destructiveHint:k().optional(),idempotentHint:k().optional(),openWorldHint:k().optional()}),Di=m({taskSupport:K(["required","optional","forbidden"]).optional()}),xo=m({...Ct.shape,...Wt.shape,description:c().optional(),inputSchema:m({type:b("object"),properties:T(c(),Vt).optional(),required:_(c()).optional()}).catchall(j()),outputSchema:U({$schema:c().optional()}).optional(),annotations:Zi.optional(),execution:Di.optional(),_meta:T(c(),j()).optional()}),Fi=Kt.extend({method:b("tools/list")}),Hi=Gt.extend({tools:_(xo)}),Po=me.extend({content:_(Nt).default([]),structuredContent:j().optional(),isError:k().optional()}),Gl=Po.or(me.extend({toolResult:j()})),Vi=vo.extend({name:c(),arguments:T(c(),j()).optional()}),Ji=he.extend({method:b("tools/call"),params:Vi}),Bi=Re.extend({method:b("notifications/tools/list_changed"),params:ke.optional()}),Wi=m({autoRefresh:k().default(!0),debounceMs:R().int().nonnegative().default(300)}),wn=K(["debug","info","notice","warning","error","critical","alert","emergency"]),Ki=ye.extend({level:wn}),Gi=he.extend({method:b("logging/setLevel"),params:Ki}),Yi=ke.extend({level:wn,logger:c().optional(),data:j()}),nr=Re.extend({method:b("notifications/message"),params:Yi}),Xi=m({name:c().optional()}),Qi=m({hints:_(Xi).optional(),costPriority:R().min(0).max(1).optional(),speedPriority:R().min(0).max(1).optional(),intelligencePriority:R().min(0).max(1).optional()}),ea=m({mode:K(["auto","required","none"]).optional()}),ta=m({type:b("tool_result"),toolUseId:c().describe("The unique identifier for the corresponding tool call."),content:_(Nt),structuredContent:j().optional(),isError:k().optional(),_meta:T(c(),j()).optional()}),oa=bo("type",[Qo,er,tr]),zo=bo("type",[Qo,er,tr,Ai,ta]),ra=m({role:Yt,content:C([zo,_(zo)]),_meta:T(c(),j()).optional()}),na=vo.extend({messages:_(ra),modelPreferences:Qi.optional(),systemPrompt:c().optional(),includeContext:K(["none","thisServer","allServers"]).optional(),temperature:R().optional(),maxTokens:R().int(),stopSequences:_(c()).optional(),metadata:pe.optional(),tools:_(xo).optional(),toolChoice:ea.optional()}),sa=he.extend({method:b("sampling/createMessage"),params:na}),ia=me.extend({model:c(),stopReason:L(K(["endTurn","stopSequence","maxTokens"]).or(c())),role:Yt,content:oa}),aa=me.extend({model:c(),stopReason:L(K(["endTurn","stopSequence","maxTokens","toolUse"]).or(c())),role:Yt,content:C([zo,_(zo)])}),xn=m({type:b("boolean"),title:c().optional(),description:c().optional(),default:k().optional()}),sr=m({type:b("string"),title:c().optional(),description:c().optional(),minLength:R().optional(),maxLength:R().optional(),format:K(["email","uri","date","date-time"]).optional(),default:c().optional()}),ir=m({type:K(["number","integer"]),title:c().optional(),description:c().optional(),minimum:R().optional(),maximum:R().optional(),default:R().optional()}),Pn=m({type:b("string"),title:c().optional(),description:c().optional(),enum:_(c()),default:c().optional()}),Tn=m({type:b("string"),title:c().optional(),description:c().optional(),oneOf:_(m({const:c(),title:c()})),default:c().optional()}),En=m({type:b("string"),title:c().optional(),description:c().optional(),enum:_(c()),enumNames:_(c()).optional(),default:c().optional()}),ca=C([Pn,Tn]),kn=m({type:b("array"),title:c().optional(),description:c().optional(),minItems:R().optional(),maxItems:R().optional(),items:m({type:b("string"),enum:_(c())}),default:_(c()).optional()}),$n=m({type:b("array"),title:c().optional(),description:c().optional(),minItems:R().optional(),maxItems:R().optional(),items:m({anyOf:_(m({const:c(),title:c()}))}),default:_(c()).optional()}),la=C([kn,$n]),ua=C([En,ca,la]),Cn=C([ua,xn,sr,ir]),ar=vo.extend({mode:b("form").optional(),message:c(),requestedSchema:m({type:b("object"),properties:T(c(),Cn),required:_(c()).optional()}).catchall(j())}),da=vo.extend({mode:b("url"),message:c(),elicitationId:c(),url:c().url()}),pa=C([ar,da]),ha=he.extend({method:b("elicitation/create"),params:pa}),ma=ke.extend({elicitationId:c()}),fa=Re.extend({method:b("notifications/elicitation/complete"),params:ma}),ga=me.extend({action:K(["accept","decline","cancel"]),content:Ht(e=>e===null?void 0:e,T(c(),C([c(),R(),k(),_(c())])).optional())}),Sa=m({type:b("ref/resource"),uri:c()}),_a=m({type:b("ref/prompt"),name:c()}),ba=ye.extend({ref:C([_a,Sa]),argument:m({name:c(),value:c()}),context:m({arguments:T(c(),c()).optional()}).optional()}),ya=he.extend({method:b("completion/complete"),params:ba}),za=me.extend({completion:U({values:_(c()).max(100),total:L(R().int()),hasMore:L(k())})}),va=m({uri:c().startsWith("file://"),name:c().optional(),_meta:T(c(),j()).optional()}),Ra=he.extend({method:b("roots/list"),params:ye.optional()}),wa=me.extend({roots:_(va)}),xa=Re.extend({method:b("notifications/roots/list_changed"),params:ke.optional()}),Yl=U({ttl:R().optional(),pollInterval:R().optional()}),Pa=K(["working","input_required","completed","failed","cancelled"]),Xt=m({taskId:c(),status:Pa,ttl:C([R(),$t()]),createdAt:c(),lastUpdatedAt:c(),pollInterval:L(R()),statusMessage:L(c())}),Xl=me.extend({task:Xt}),Ta=ke.merge(Xt),Ql=Re.extend({method:b("notifications/tasks/status"),params:Ta}),eu=he.extend({method:b("tasks/get"),params:ye.extend({taskId:c()})}),tu=me.merge(Xt),ou=he.extend({method:b("tasks/result"),params:ye.extend({taskId:c()})}),ru=me.loose(),nu=Kt.extend({method:b("tasks/list")}),su=Gt.extend({tasks:_(Xt)}),iu=he.extend({method:b("tasks/cancel"),params:ye.extend({taskId:c()})}),au=me.merge(Xt),cu=C([Sn,mn,ii,ya,Gi,Mi,Oi,di,hi,gi,yi,vi,wi,Ji,Fi]),lu=C([hn,_n,gn,xa]),uu=C([Ro,ia,aa,ga,wa]),du=C([Sn,sa,ha,Ra]),pu=C([hn,_n,nr,$i,_i,Bi,Ui,Pi,fa]),hu=C([Ro,si,wo,za,Li,Ni,pi,mi,Si,Po,Hi,Ei]),be=Xr().superRefine((e,t)=>{if(!URL.canParse(e))return t.addIssue({code:qf.custom,message:"URL must be parseable",fatal:!0}),ys}).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"}),In=U({resource:c().url(),authorization_servers:_(be).optional(),jwks_uri:c().url().optional(),scopes_supported:_(c()).optional(),bearer_methods_supported:_(c()).optional(),resource_signing_alg_values_supported:_(c()).optional(),resource_name:c().optional(),resource_documentation:c().optional(),resource_policy_uri:c().url().optional(),resource_tos_uri:c().url().optional(),tls_client_certificate_bound_access_tokens:k().optional(),authorization_details_types_supported:_(c()).optional(),dpop_signing_alg_values_supported:_(c()).optional(),dpop_bound_access_tokens_required:k().optional()}),cr=U({issuer:c(),authorization_endpoint:be,token_endpoint:be,registration_endpoint:be.optional(),scopes_supported:_(c()).optional(),response_types_supported:_(c()),response_modes_supported:_(c()).optional(),grant_types_supported:_(c()).optional(),token_endpoint_auth_methods_supported:_(c()).optional(),token_endpoint_auth_signing_alg_values_supported:_(c()).optional(),service_documentation:be.optional(),revocation_endpoint:be.optional(),revocation_endpoint_auth_methods_supported:_(c()).optional(),revocation_endpoint_auth_signing_alg_values_supported:_(c()).optional(),introspection_endpoint:c().optional(),introspection_endpoint_auth_methods_supported:_(c()).optional(),introspection_endpoint_auth_signing_alg_values_supported:_(c()).optional(),code_challenge_methods_supported:_(c()).optional(),client_id_metadata_document_supported:k().optional(),authorization_response_iss_parameter_supported:k().optional().catch(void 0),dpop_signing_alg_values_supported:_(c()).optional()}),Ea=U({issuer:c(),authorization_endpoint:be,token_endpoint:be,userinfo_endpoint:be.optional(),jwks_uri:be,registration_endpoint:be.optional(),scopes_supported:_(c()).optional(),response_types_supported:_(c()),response_modes_supported:_(c()).optional(),grant_types_supported:_(c()).optional(),acr_values_supported:_(c()).optional(),subject_types_supported:_(c()),id_token_signing_alg_values_supported:_(c()),id_token_encryption_alg_values_supported:_(c()).optional(),id_token_encryption_enc_values_supported:_(c()).optional(),userinfo_signing_alg_values_supported:_(c()).optional(),userinfo_encryption_alg_values_supported:_(c()).optional(),userinfo_encryption_enc_values_supported:_(c()).optional(),request_object_signing_alg_values_supported:_(c()).optional(),request_object_encryption_alg_values_supported:_(c()).optional(),request_object_encryption_enc_values_supported:_(c()).optional(),token_endpoint_auth_methods_supported:_(c()).optional(),token_endpoint_auth_signing_alg_values_supported:_(c()).optional(),display_values_supported:_(c()).optional(),claim_types_supported:_(c()).optional(),claims_supported:_(c()).optional(),service_documentation:c().optional(),claims_locales_supported:_(c()).optional(),ui_locales_supported:_(c()).optional(),claims_parameter_supported:k().optional(),request_parameter_supported:k().optional(),request_uri_parameter_supported:k().optional(),require_request_uri_registration:k().optional(),op_policy_uri:be.optional(),op_tos_uri:be.optional(),client_id_metadata_document_supported:k().optional(),authorization_response_iss_parameter_supported:k().optional().catch(void 0)}),On=m({...Ea.shape,...cr.pick({code_challenge_methods_supported:!0}).shape}),Nn=m({access_token:c(),id_token:c().optional(),token_type:c(),expires_in:Ys.number().optional(),scope:c().optional(),refresh_token:c().optional(),issuer:c().optional().catch(void 0)}).strip(),ka=m({issued_token_type:b("urn:ietf:params:oauth:token-type:id-jag"),access_token:c(),token_type:c().optional(),expires_in:R().optional(),scope:c().optional()}).strip(),qn=m({error:c(),error_description:c().optional(),error_uri:c().optional()}),Mf=be.optional().or(b("").transform(()=>{})),$a=m({redirect_uris:_(be),token_endpoint_auth_method:c().optional(),grant_types:_(c()).optional(),response_types:_(c()).optional(),application_type:c().optional(),client_name:c().optional(),client_uri:be.optional(),logo_uri:Mf,scope:c().optional(),contacts:_(c()).optional(),tos_uri:Mf,policy_uri:c().optional(),jwks_uri:be.optional(),jwks:Ll().optional(),software_id:c().optional(),software_version:c().optional(),software_statement:c().optional()}).strip(),Ca=m({client_id:c(),client_secret:c().optional(),client_id_issued_at:R().optional(),client_secret_expires_at:R().optional(),issuer:c().optional().catch(void 0)}).strip(),Mn=$a.merge(Ca),mu=m({error:c(),error_description:c().optional()}).strip(),fu=m({token:c(),token_type_hint:c().optional()}).strip();var Df=Symbol.for("mcp.sdk.errorBrands");function lr(e,t){let o=new Set,r=t;for(;typeof r=="function";){let n=r.mcpBrand;Object.prototype.hasOwnProperty.call(r,"mcpBrand")&&typeof n=="string"&&o.add(n),r=Object.getPrototypeOf(r)}o.size!==0&&Object.defineProperty(e,Df,{value:o,enumerable:!1,configurable:!0})}function et(e,t){try{if(typeof t=="object"&&t!==null&&Object.prototype.hasOwnProperty.call(e,"mcpBrand")&&typeof e.mcpBrand=="string"&&Object.prototype.hasOwnProperty.call(t,Df)){let o=t[Df];if(o&&typeof o.has=="function"&&o.has(e.mcpBrand))return!0}}catch{}return Function.prototype[Symbol.hasInstance].call(e,t)}var eo=(function(e){return e.InvalidRequest="invalid_request",e.InvalidClient="invalid_client",e.InvalidGrant="invalid_grant",e.UnauthorizedClient="unauthorized_client",e.UnsupportedGrantType="unsupported_grant_type",e.InvalidScope="invalid_scope",e.AccessDenied="access_denied",e.ServerError="server_error",e.TemporarilyUnavailable="temporarily_unavailable",e.UnsupportedResponseType="unsupported_response_type",e.UnsupportedTokenType="unsupported_token_type",e.InvalidToken="invalid_token",e.MethodNotAllowed="method_not_allowed",e.TooManyRequests="too_many_requests",e.InvalidClientMetadata="invalid_client_metadata",e.InvalidRedirectUri="invalid_redirect_uri",e.InsufficientScope="insufficient_scope",e.InvalidTarget="invalid_target",e.InvalidDpopProof="invalid_dpop_proof",e.UseDpopNonce="use_dpop_nonce",e})({}),ur=class nb extends Error{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.OAuthError"})}static[Symbol.hasInstance](t){return et(this,t)}static isInstance(t){if(typeof this!="function")throw new TypeError("isInstance must be called on the class (e.g. `SdkError.isInstance(value)`); for callbacks use `v => SdkError.isInstance(v)`");return et(this,t)}constructor(t,o,r){super(o),this.code=t,this.errorUri=r,this.name="OAuthError",lr(this,new.target)}toResponseObject(){let t={error:this.code,error_description:this.message};return this.errorUri&&(t.error_uri=this.errorUri),t}static fromResponse(t){return new nb(t.error,t.error_description??t.error,t.error_uri)}},q=(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})({}),M=class extends Error{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.SdkError"})}static[Symbol.hasInstance](e){return et(this,e)}static isInstance(e){if(typeof this!="function")throw new TypeError("isInstance must be called on the class (e.g. `SdkError.isInstance(value)`); for callbacks use `v => SdkError.isInstance(v)`");return et(this,e)}constructor(e,t,o,r){super(t,r),this.code=e,this.data=o,this.name="SdkError",lr(this,new.target)}},qt=class extends M{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}};function sb(e){let t=typeof e=="string"?new URL(e):new URL(e.href);return t.hash="",t}function Bf(e){if(typeof e!="object"||e===null||Array.isArray(e))return e;let t={...e};return delete t.issuer,t}function ib({requestedResource:e,configuredResource:t}){let o=typeof e=="string"?new URL(e):new URL(e.href),r=typeof t=="string"?new URL(t):new URL(t.href);if(o.origin!==r.origin||o.pathname.length<r.pathname.length)return!1;let n=o.pathname.endsWith("/")?o.pathname:o.pathname+"/",s=r.pathname.endsWith("/")?r.pathname:r.pathname+"/";return n.startsWith(s)}var ab="2026-07-28",Wf=[ab];function to(e){return e>=ab}function Kf(e){return e.filter(t=>!to(t))}function Aa(e){return e.filter(t=>to(t))}function cb(e){let t=e.structuredContent;return t===void 0||!(typeof t!="object"||t===null||Array.isArray(t))||(e.content?.some(o=>o.type==="text")??!1)?e:{...e,content:[...e.content??[],{type:"text",text:JSON.stringify(t)}]}}var lb=["task","inputRequests","requestState"];function Gv(e){return e===null||typeof e!="object"||Array.isArray(e)||e.content!==void 0||lb.some(t=>t in e)?e:{...e,content:[]}}function Yv(){let e=yo(()=>C([c(),R(),k(),$t(),T(c(),e),_(e)])),t=T(c(),e),o=C([c(),R().int()]),r=c(),n=m({ttl:R().optional()}),s=m({taskId:c()}),i=U({progressToken:o.optional(),"io.modelcontextprotocol/related-task":s.optional()}),a=m({_meta:i.optional()}),l=a.extend({task:n.optional()}),u=m({method:c(),params:a.loose().optional()}),d=m({_meta:i.optional()}),h=m({method:c(),params:d.loose().optional()}),f=U({_meta:i.optional()}),S=C([c(),R().int()]),y=f.strict(),w=d.extend({requestId:S.optional(),reason:c().optional()}),z=h.extend({method:b("notifications/cancelled"),params:w}),H=m({src:c(),mimeType:c().optional(),sizes:_(c()).optional(),theme:K(["light","dark"]).optional()}),W=m({icons:_(H).optional()}),N=m({name:c(),title:c().optional()}),D=N.extend({...N.shape,...W.shape,version:c(),websiteUrl:c().optional(),description:c().optional()}),x=pt(m({applyDefaults:k().optional()}),t),v=Ht(Te=>Te&&typeof Te=="object"&&!Array.isArray(Te)&&Object.keys(Te).length===0?{form:{}}:Te,pt(m({form:x.optional(),url:t.optional()}),t.optional())),Z=U({list:t.optional(),cancel:t.optional(),requests:U({sampling:U({createMessage:t.optional()}).optional(),elicitation:U({create:t.optional()}).optional()}).optional()}),oe=U({list:t.optional(),cancel:t.optional(),requests:U({tools:U({call:t.optional()}).optional()}).optional()}),ee=m({experimental:T(c(),t).optional(),sampling:m({context:t.optional(),tools:t.optional()}).optional(),elicitation:v.optional(),roots:m({listChanged:k().optional()}).optional(),tasks:Z.optional(),extensions:T(c(),t).optional()}),de=a.extend({protocolVersion:c(),capabilities:ee,clientInfo:D}),$e=u.extend({method:b("initialize"),params:de}),ie=m({experimental:T(c(),t).optional(),logging:t.optional(),completions:t.optional(),prompts:m({listChanged:k().optional()}).optional(),resources:m({subscribe:k().optional(),listChanged:k().optional()}).optional(),tools:m({listChanged:k().optional()}).optional(),tasks:oe.optional(),extensions:T(c(),t).optional()}),ue=f.extend({protocolVersion:c(),capabilities:ie,serverInfo:D,instructions:c().optional()}),ze=h.extend({method:b("notifications/initialized"),params:d.optional()}),Ce=u.extend({method:b("ping"),params:a.optional()}),_t=m({progress:R(),total:L(R()),message:L(c())}),Ue=m({...d.shape,..._t.shape,progressToken:o}),ot=h.extend({method:b("notifications/progress"),params:Ue}),bt=a.extend({cursor:r.optional()}),Je=u.extend({params:bt.optional()}),Ie=f.extend({nextCursor:r.optional()}),jt=m({uri:c(),mimeType:L(c()),_meta:T(c(),j()).optional()}),Lt=jt.extend({text:c()}),yt=c().refine(Te=>{try{return atob(Te),!0}catch{return!1}},{message:"Invalid Base64 string"}),xe=jt.extend({blob:yt}),Oe=K(["user","assistant"]),Ne=m({audience:_(Oe).optional(),priority:R().min(0).max(1).optional(),lastModified:Qe.datetime({offset:!0}).optional()}),ct=m({...N.shape,...W.shape,uri:c(),description:L(c()),mimeType:L(c()),size:L(R()),annotations:Ne.optional(),_meta:L(U({}))}),Eo=m({...N.shape,...W.shape,uriTemplate:c(),description:L(c()),mimeType:L(c()),annotations:Ne.optional(),_meta:L(U({}))}),Be=Je.extend({method:b("resources/list")}),We=Ie.extend({resources:_(ct)}),Ze=Je.extend({method:b("resources/templates/list")}),rt=Ie.extend({resourceTemplates:_(Eo)}),nt=a.extend({uri:c()}),zt=nt,vt=u.extend({method:b("resources/read"),params:zt}),no=f.extend({contents:_(C([Lt,xe]))}),Rt=h.extend({method:b("notifications/resources/list_changed"),params:d.optional()}),ko=nt,I=u.extend({method:b("resources/subscribe"),params:ko}),wt=nt,F=u.extend({method:b("resources/unsubscribe"),params:wt}),A=d.extend({uri:c()}),X=h.extend({method:b("notifications/resources/updated"),params:A}),O=m({name:c(),description:L(c()),required:L(k())}),E=m({...N.shape,...W.shape,description:L(c()),arguments:L(_(O)),_meta:L(U({}))}),J=Je.extend({method:b("prompts/list")}),V=Ie.extend({prompts:_(E)}),_e=a.extend({name:c(),arguments:T(c(),c()).optional()}),$o=u.extend({method:b("prompts/get"),params:_e}),xt=m({type:b("text"),text:c(),annotations:Ne.optional(),_meta:T(c(),j()).optional()}),Co=m({type:b("image"),data:yt,mimeType:c(),annotations:Ne.optional(),_meta:T(c(),j()).optional()}),Io=m({type:b("audio"),data:yt,mimeType:c(),annotations:Ne.optional(),_meta:T(c(),j()).optional()}),Jn=m({type:b("tool_use"),name:c(),id:c(),input:T(c(),j()),_meta:T(c(),j()).optional()}),so=m({type:b("resource"),resource:C([Lt,xe]),annotations:Ne.optional(),_meta:T(c(),j()).optional()}),Bn=ct.extend({type:b("resource_link")}),st=C([xt,Co,Io,Bn,so]),gr=m({role:Oe,content:st}),Sr=f.extend({description:c().optional(),messages:_(gr)}),Oo=h.extend({method:b("notifications/prompts/list_changed"),params:d.optional()}),Wn=m({title:c().optional(),readOnlyHint:k().optional(),destructiveHint:k().optional(),idempotentHint:k().optional(),openWorldHint:k().optional()}),_r=m({taskSupport:K(["required","optional","forbidden"]).optional()}),No=m({...N.shape,...W.shape,description:c().optional(),inputSchema:m({type:b("object"),properties:T(c(),e).optional(),required:_(c()).optional()}).catchall(j()),outputSchema:m({type:b("object"),properties:T(c(),e).optional(),required:_(c()).optional()}).catchall(j()).optional(),annotations:Wn.optional(),execution:_r.optional(),_meta:T(c(),j()).optional()}),br=Je.extend({method:b("tools/list")}),yr=Ie.extend({tools:_(No)}),zr=f.extend({content:_(st),structuredContent:T(c(),j()).optional(),isError:k().optional()}),Pe=l.extend({name:c(),arguments:T(c(),j()).optional()}),Kn=u.extend({method:b("tools/call"),params:Pe}),Va=h.extend({method:b("notifications/tools/list_changed"),params:d.optional()}),vr=K(["debug","info","notice","warning","error","critical","alert","emergency"]),Gn=a.extend({level:vr}),Yn=u.extend({method:b("logging/setLevel"),params:Gn}),Xn=d.extend({level:vr,logger:c().optional(),data:j()}),Qn=h.extend({method:b("notifications/message"),params:Xn}),es=m({name:c().optional()}),ts=m({hints:_(es).optional(),costPriority:R().min(0).max(1).optional(),speedPriority:R().min(0).max(1).optional(),intelligencePriority:R().min(0).max(1).optional()}),os=m({mode:K(["auto","required","none"]).optional()}),Ja=m({type:b("tool_result"),toolUseId:c().describe("The unique identifier for the corresponding tool call."),content:_(st),structuredContent:m({}).loose().optional(),isError:k().optional(),_meta:T(c(),j()).optional()}),rs=bo("type",[xt,Co,Io]),io=bo("type",[xt,Co,Io,Jn,Ja]),ns=m({role:Oe,content:C([io,_(io)]),_meta:T(c(),j()).optional()}),ss=l.extend({messages:_(ns),modelPreferences:ts.optional(),systemPrompt:c().optional(),includeContext:K(["none","thisServer","allServers"]).optional(),temperature:R().optional(),maxTokens:R().int(),stopSequences:_(c()).optional(),metadata:t.optional(),tools:_(No).optional(),toolChoice:os.optional()}),is=u.extend({method:b("sampling/createMessage"),params:ss}),as=f.extend({model:c(),stopReason:L(K(["endTurn","stopSequence","maxTokens"]).or(c())),role:Oe,content:rs}),cs=f.extend({model:c(),stopReason:L(K(["endTurn","stopSequence","maxTokens","toolUse"]).or(c())),role:Oe,content:C([io,_(io)])}),ls=m({type:b("boolean"),title:c().optional(),description:c().optional(),default:k().optional()}),us=m({type:b("string"),title:c().optional(),description:c().optional(),minLength:R().optional(),maxLength:R().optional(),format:K(["email","uri","date","date-time"]).optional(),default:c().optional()}),ds=m({type:K(["number","integer"]),title:c().optional(),description:c().optional(),minimum:R().optional(),maximum:R().optional(),default:R().optional()}),ps=m({type:b("string"),title:c().optional(),description:c().optional(),enum:_(c()),default:c().optional()}),hs=m({type:b("string"),title:c().optional(),description:c().optional(),oneOf:_(m({const:c(),title:c()})),default:c().optional()}),ms=m({type:b("string"),title:c().optional(),description:c().optional(),enum:_(c()),enumNames:_(c()).optional(),default:c().optional()}),fs=C([ps,hs]),qo=m({type:b("array"),title:c().optional(),description:c().optional(),minItems:R().optional(),maxItems:R().optional(),items:m({type:b("string"),enum:_(c())}),default:_(c()).optional()}),Mo=m({type:b("array"),title:c().optional(),description:c().optional(),minItems:R().optional(),maxItems:R().optional(),items:m({anyOf:_(m({const:c(),title:c()}))}),default:_(c()).optional()}),Ba=C([qo,Mo]),Wa=C([ms,fs,Ba]),Ke=C([Wa,ls,us,ds]),Ge=l.extend({mode:b("form").optional(),message:c(),requestedSchema:m({type:b("object"),properties:T(c(),Ke),required:_(c()).optional()}).catchall(j())}),gs=l.extend({mode:b("url"),message:c(),elicitationId:c(),url:c().url()}),lt=C([Ge,gs]),Ka=u.extend({method:b("elicitation/create"),params:lt}),Ga=d.extend({elicitationId:c()}),Ya=h.extend({method:b("notifications/elicitation/complete"),params:Ga}),Xa=f.extend({action:K(["accept","decline","cancel"]),content:Ht(Te=>Te===null?void 0:Te,T(c(),C([c(),R(),k(),_(c())])).optional())}),Qa=m({type:b("ref/resource"),uri:c()}),ec=m({type:b("ref/prompt"),name:c()}),tc=a.extend({ref:C([ec,Qa]),argument:m({name:c(),value:c()}),context:m({arguments:T(c(),c()).optional()}).optional()}),Ss=u.extend({method:b("completion/complete"),params:tc}),oc=f.extend({completion:U({values:_(c()).max(100),total:L(R().int()),hasMore:L(k())})}),rc=m({uri:c().startsWith("file://"),name:c().optional(),_meta:T(c(),j()).optional()}),Rr=u.extend({method:b("roots/list"),params:a.optional()}),_s=f.extend({roots:_(rc)}),nc=h.extend({method:b("notifications/roots/list_changed"),params:d.optional()}),sc=U({ttl:R().optional(),pollInterval:R().optional()}),bs=K(["working","input_required","completed","failed","cancelled"]),ao=m({taskId:c(),status:bs,ttl:C([R(),$t()]),createdAt:c(),lastUpdatedAt:c(),pollInterval:L(R()),statusMessage:L(c())}),De=f.extend({task:ao}),ic=d.merge(ao),Ao=h.extend({method:b("notifications/tasks/status"),params:ic}),wr=u.extend({method:b("tasks/get"),params:a.extend({taskId:c()})}),xr=f.merge(ao),Pr=u.extend({method:b("tasks/result"),params:a.extend({taskId:c()})}),Lu=f.loose(),qe=Je.extend({method:b("tasks/list")}),Se=Ie.extend({tasks:_(ao)}),jo=u.extend({method:b("tasks/cancel"),params:a.extend({taskId:c()})});return{JSONValueSchema:e,JSONObjectSchema:t,ProgressTokenSchema:o,CursorSchema:r,TaskMetadataSchema:n,RelatedTaskMetadataSchema:s,RequestMetaSchema:i,BaseRequestParamsSchema:a,TaskAugmentedRequestParamsSchema:l,RequestSchema:u,NotificationsParamsSchema:d,NotificationSchema:h,ResultSchema:f,RequestIdSchema:S,EmptyResultSchema:y,CancelledNotificationParamsSchema:w,CancelledNotificationSchema:z,IconSchema:H,IconsSchema:W,BaseMetadataSchema:N,ImplementationSchema:D,ClientTasksCapabilitySchema:Z,ServerTasksCapabilitySchema:oe,ClientCapabilitiesSchema:ee,InitializeRequestParamsSchema:de,InitializeRequestSchema:$e,ServerCapabilitiesSchema:ie,InitializeResultSchema:ue,InitializedNotificationSchema:ze,PingRequestSchema:Ce,ProgressSchema:_t,ProgressNotificationParamsSchema:Ue,ProgressNotificationSchema:ot,PaginatedRequestParamsSchema:bt,PaginatedRequestSchema:Je,PaginatedResultSchema:Ie,ResourceContentsSchema:jt,TextResourceContentsSchema:Lt,BlobResourceContentsSchema:xe,RoleSchema:Oe,AnnotationsSchema:Ne,ResourceSchema:ct,ResourceTemplateSchema:Eo,ListResourcesRequestSchema:Be,ListResourcesResultSchema:We,ListResourceTemplatesRequestSchema:Ze,ListResourceTemplatesResultSchema:rt,ResourceRequestParamsSchema:nt,ReadResourceRequestParamsSchema:zt,ReadResourceRequestSchema:vt,ReadResourceResultSchema:no,ResourceListChangedNotificationSchema:Rt,SubscribeRequestParamsSchema:ko,SubscribeRequestSchema:I,UnsubscribeRequestParamsSchema:wt,UnsubscribeRequestSchema:F,ResourceUpdatedNotificationParamsSchema:A,ResourceUpdatedNotificationSchema:X,PromptArgumentSchema:O,PromptSchema:E,ListPromptsRequestSchema:J,ListPromptsResultSchema:V,GetPromptRequestParamsSchema:_e,GetPromptRequestSchema:$o,TextContentSchema:xt,ImageContentSchema:Co,AudioContentSchema:Io,ToolUseContentSchema:Jn,EmbeddedResourceSchema:so,ResourceLinkSchema:Bn,ContentBlockSchema:st,PromptMessageSchema:gr,GetPromptResultSchema:Sr,PromptListChangedNotificationSchema:Oo,ToolAnnotationsSchema:Wn,ToolExecutionSchema:_r,ToolSchema:No,ListToolsRequestSchema:br,ListToolsResultSchema:yr,CallToolResultSchema:zr,CallToolRequestParamsSchema:Pe,CallToolRequestSchema:Kn,ToolListChangedNotificationSchema:Va,LoggingLevelSchema:vr,SetLevelRequestParamsSchema:Gn,SetLevelRequestSchema:Yn,LoggingMessageNotificationParamsSchema:Xn,LoggingMessageNotificationSchema:Qn,ModelHintSchema:es,ModelPreferencesSchema:ts,ToolChoiceSchema:os,ToolResultContentSchema:Ja,SamplingContentSchema:rs,SamplingMessageContentBlockSchema:io,SamplingMessageSchema:ns,CreateMessageRequestParamsSchema:ss,CreateMessageRequestSchema:is,CreateMessageResultSchema:as,CreateMessageResultWithToolsSchema:cs,BooleanSchemaSchema:ls,StringSchemaSchema:us,NumberSchemaSchema:ds,UntitledSingleSelectEnumSchemaSchema:ps,TitledSingleSelectEnumSchemaSchema:hs,LegacyTitledEnumSchemaSchema:ms,SingleSelectEnumSchemaSchema:fs,UntitledMultiSelectEnumSchemaSchema:qo,TitledMultiSelectEnumSchemaSchema:Mo,MultiSelectEnumSchemaSchema:Ba,EnumSchemaSchema:Wa,PrimitiveSchemaDefinitionSchema:Ke,ElicitRequestFormParamsSchema:Ge,ElicitRequestURLParamsSchema:gs,ElicitRequestParamsSchema:lt,ElicitRequestSchema:Ka,ElicitationCompleteNotificationParamsSchema:Ga,ElicitationCompleteNotificationSchema:Ya,ElicitResultSchema:Xa,ResourceTemplateReferenceSchema:Qa,PromptReferenceSchema:ec,CompleteRequestParamsSchema:tc,CompleteRequestSchema:Ss,CompleteResultSchema:oc,RootSchema:rc,ListRootsRequestSchema:Rr,ListRootsResultSchema:_s,RootsListChangedNotificationSchema:nc,TaskCreationParamsSchema:sc,TaskStatusSchema:bs,TaskSchema:ao,CreateTaskResultSchema:De,TaskStatusNotificationParamsSchema:ic,TaskStatusNotificationSchema:Ao,GetTaskRequestSchema:wr,GetTaskResultSchema:xr,GetTaskPayloadRequestSchema:Pr,GetTaskPayloadResultSchema:Lu,ListTasksRequestSchema:qe,ListTasksResultSchema:Se,CancelTaskRequestSchema:jo,CancelTaskResultSchema:f.merge(ao),ClientRequestSchema:C([Ce,$e,Ss,Yn,$o,J,Be,Ze,vt,I,F,Kn,br,wr,Pr,qe,jo]),ClientNotificationSchema:C([z,ot,ze,nc,Ao]),ClientResultSchema:C([y,as,cs,Xa,_s,xr,Se,De]),ServerRequestSchema:C([Ce,is,Ka,Rr,wr,Pr,qe,jo]),ServerNotificationSchema:C([z,ot,Qn,X,Rt,Va,Oo,Ao,Ya]),ServerResultSchema:C([y,ue,oc,Sr,V,We,rt,no,zr,yr,xr,Se,De]),CallToolResultWireSchema:j().superRefine((Te,Fy)=>{if(!(typeof Te!="object"||Te===null||Array.isArray(Te)||Te.content!==void 0)){for(let jg of lb)if(jg in Te){Fy.addIssue({code:"custom",message:`content is required when the body carries '${jg}' \u2014 another result family cannot default into an empty tools/call success`});return}}}).transform(Gv).pipe(zr)}}var Xv;function ub(){return Xv??=Yv()}function db(e){return e.type!=="object"}var Qv=new Set(["const","enum","default","examples"]),eR=new Set(["properties","patternProperties","$defs","definitions","dependentSchemas","dependencies"]);function V_(e){return e!==void 0&&!(typeof e=="string"&&e.startsWith("#"))}function tR(e){let t=typeof e.$schema=="string"?e.$schema:void 0;if(V_(e.$id))return{...t!==void 0&&{$schema:t},type:"object",properties:{result:e},required:["result"]};let o=Fg(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"||!s&&V_(n.$id))return n;let i={},a=!1;for(let[l,u]of Object.entries(n))s?i[l]=r(u,!1):(l==="$ref"||l==="$dynamicRef")&&typeof u=="string"?i[l]=u==="#"?"#/properties/result":u.startsWith("#/")?`#/properties/result${u.slice(1)}`:u:l==="$recursiveRef"&&u==="#"&&o?a=!0:Qv.has(l)?i[l]=u:eR.has(l)?i[l]=r(u,!0):i[l]=r(u,!1);return a&&("$ref"in i?i.allOf=[...Array.isArray(i.allOf)?i.allOf:[],{$ref:"#/properties/result"}]:i.$ref="#/properties/result"),i};return{...t!==void 0&&{$schema:t},type:"object",properties:{result:r(e,!1)},required:["result"]}}var pb={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},hb={"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},oR={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},gu;function Gf(){if(gu)return gu;let e=ub();return gu={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}},gu}function mb(e){return Object.prototype.hasOwnProperty.call(pb,e)}function fb(e){return Object.prototype.hasOwnProperty.call(hb,e)}function rR(e){return Object.prototype.hasOwnProperty.call(oR,e)}function nR(e){return rR(e)?Gf().resultSchemas[e]:void 0}function sR(e){return mb(e)?Gf().requestSchemas[e]:void 0}function iR(e){return fb(e)?Gf().notificationSchemas[e]:void 0}var aE=Object.keys(pb),cE=Object.keys(hb);function Ff(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function Su(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 J_={ok:!1,reason:"not-in-era"};function B_(e){return Ff(e)&&Ff(e.outputSchema)&&db(e.outputSchema)}var Yf={era:"2025-11-25",hasRequestMethod:mb,hasNotificationMethod:fb,validateRequest:(e,t)=>Su(sR(e),t),validateResult:(e,t)=>Su(nR(e),t),validateNotification:(e,t)=>Su(iR(e),t),hasInputRequestMethod:()=>!1,validateInputRequest:()=>J_,validateInputResponse:()=>J_,samplingResultVariant:((e,t)=>{let o=ub();return Su(e?o.CreateMessageResultWithToolsSchema:o.CreateMessageResultSchema,t)}),outboundEnvelope:e=>{},validateEnvelopeMeta:e=>[],projectCallToolResult(e,t){let o=cb(e),r=o.structuredContent;if(r===void 0)return o;let n=typeof r!="object"||r===null||Array.isArray(r),s=t!==void 0&&db(t);return!n&&!s?o:{...o,structuredContent:{result:r}}},decodeResult(e,t){if(Ff(t)&&"resultType"in t){let o={...t};return delete o.resultType,{kind:"complete",result:o}}return{kind:"complete",result:t}},encodeResult(e,t){if(e!=="tools/list")return t;let o=t.tools;return!Array.isArray(o)||!o.some(r=>B_(r))?t:{...t,tools:o.map(r=>B_(r)?{...r,outputSchema:tR(r.outputSchema)}:r)}},encodeErrorCode:e=>e===-32002?-32602:e,checkInboundEnvelope:e=>{}};function aR(){let e=yo(()=>C([c(),R(),k(),$t(),T(c(),e),_(e)])),t=T(c(),e),o=C([c(),R().int()]),r=c(),n=C([c(),R().int()]),s=K(["user","assistant"]),i=K(["debug","info","notice","warning","error","critical","alert","emergency"]),a=c().refine(Se=>{try{return atob(Se),!0}catch{return!1}},{message:"Invalid Base64 string"}),l=m({ttl:R().optional()}),u=m({taskId:c()}),d=U({progressToken:o.optional(),"io.modelcontextprotocol/related-task":u.optional()}),h=m({_meta:d.optional()}),f=h.extend({task:l.optional()}),S=m({_meta:d.optional()}),y=m({method:c(),params:S.loose().optional()}),w=m({src:c(),mimeType:c().optional(),sizes:_(c()).optional(),theme:K(["light","dark"]).optional()}),z=m({icons:_(w).optional()}),H=m({name:c(),title:c().optional()}),W=H.extend({...H.shape,...z.shape,version:c(),websiteUrl:c().optional(),description:c().optional()}),N=pt(m({applyDefaults:k().optional()}),t),D=Ht(Se=>Se&&typeof Se=="object"&&!Array.isArray(Se)&&Object.keys(Se).length===0?{form:{}}:Se,pt(m({form:N.optional(),url:t.optional()}),t.optional())),x=U({list:t.optional(),cancel:t.optional(),requests:U({sampling:U({createMessage:t.optional()}).optional(),elicitation:U({create:t.optional()}).optional()}).optional()}),v=U({list:t.optional(),cancel:t.optional(),requests:U({tools:U({call:t.optional()}).optional()}).optional()}),Z=m({experimental:T(c(),t).optional(),sampling:m({context:t.optional(),tools:t.optional()}).optional(),elicitation:D.optional(),roots:m({listChanged:k().optional()}).optional(),tasks:x.optional(),extensions:T(c(),t).optional()}),oe=m({experimental:T(c(),t).optional(),logging:t.optional(),completions:t.optional(),prompts:m({listChanged:k().optional()}).optional(),resources:m({subscribe:k().optional(),listChanged:k().optional()}).optional(),tools:m({listChanged:k().optional()}).optional(),tasks:v.optional(),extensions:T(c(),t).optional()}),ee=m({progress:R(),total:L(R()),message:L(c())}),de=m({...S.shape,...ee.shape,progressToken:o}),$e=y.extend({method:b("notifications/progress"),params:de}),ie=S.extend({level:i,logger:c().optional(),data:j()}),ue=y.extend({method:b("notifications/message"),params:ie}),ze=m({uri:c(),mimeType:L(c()),_meta:T(c(),j()).optional()}),Ce=ze.extend({text:c()}),_t=ze.extend({blob:a}),Ue=m({audience:_(s).optional(),priority:R().min(0).max(1).optional(),lastModified:Qe.datetime({offset:!0}).optional()}),ot=m({...H.shape,...z.shape,uri:c(),description:L(c()),mimeType:L(c()),size:L(R()),annotations:Ue.optional(),_meta:L(U({}))}),bt=m({...H.shape,...z.shape,uriTemplate:c(),description:L(c()),mimeType:L(c()),annotations:Ue.optional(),_meta:L(U({}))}),Je=y.extend({method:b("notifications/resources/list_changed"),params:S.optional()}),Ie=S.extend({uri:c()}),jt=y.extend({method:b("notifications/resources/updated"),params:Ie}),Lt=m({name:c(),description:L(c()),required:L(k())}),yt=m({...H.shape,...z.shape,description:L(c()),arguments:L(_(Lt)),_meta:L(U({}))}),xe=y.extend({method:b("notifications/prompts/list_changed"),params:S.optional()}),Oe=m({type:b("text"),text:c(),annotations:Ue.optional(),_meta:T(c(),j()).optional()}),Ne=m({type:b("image"),data:a,mimeType:c(),annotations:Ue.optional(),_meta:T(c(),j()).optional()}),ct=m({type:b("audio"),data:a,mimeType:c(),annotations:Ue.optional(),_meta:T(c(),j()).optional()}),Eo=m({type:b("tool_use"),name:c(),id:c(),input:T(c(),j()),_meta:T(c(),j()).optional()}),Be=m({type:b("resource"),resource:C([Ce,_t]),annotations:Ue.optional(),_meta:T(c(),j()).optional()}),We=ot.extend({type:b("resource_link")}),Ze=C([Oe,Ne,ct,We,Be]),rt=m({role:s,content:Ze}),nt=m({title:c().optional(),readOnlyHint:k().optional(),destructiveHint:k().optional(),idempotentHint:k().optional(),openWorldHint:k().optional()}),zt=y.extend({method:b("notifications/tools/list_changed"),params:S.optional()}),vt=m({name:c().optional()}),no=m({hints:_(vt).optional(),costPriority:R().min(0).max(1).optional(),speedPriority:R().min(0).max(1).optional(),intelligencePriority:R().min(0).max(1).optional()}),Rt=m({mode:K(["auto","required","none"]).optional()}),ko=m({type:b("boolean"),title:c().optional(),description:c().optional(),default:k().optional()}),I=m({type:b("string"),title:c().optional(),description:c().optional(),minLength:R().optional(),maxLength:R().optional(),format:K(["email","uri","date","date-time"]).optional(),default:c().optional()}),wt=m({type:K(["number","integer"]),title:c().optional(),description:c().optional(),minimum:R().optional(),maximum:R().optional(),default:R().optional()}),F=m({type:b("string"),title:c().optional(),description:c().optional(),enum:_(c()),default:c().optional()}),A=m({type:b("string"),title:c().optional(),description:c().optional(),oneOf:_(m({const:c(),title:c()})),default:c().optional()}),X=m({type:b("string"),title:c().optional(),description:c().optional(),enum:_(c()),enumNames:_(c()).optional(),default:c().optional()}),O=C([F,A]),E=m({type:b("array"),title:c().optional(),description:c().optional(),minItems:R().optional(),maxItems:R().optional(),items:m({type:b("string"),enum:_(c())}),default:_(c()).optional()}),J=m({type:b("array"),title:c().optional(),description:c().optional(),minItems:R().optional(),maxItems:R().optional(),items:m({anyOf:_(m({const:c(),title:c()}))}),default:_(c()).optional()}),V=C([E,J]),_e=C([X,O,V]),$o=C([_e,ko,I,wt]),xt=f.extend({mode:b("form").optional(),message:c(),requestedSchema:m({type:b("object"),properties:T(c(),$o),required:_(c()).optional()}).catchall(j())}),Co=m({type:b("ref/resource"),uri:c()}),Io=m({type:b("ref/prompt"),name:c()}),Jn=m({uri:c().startsWith("file://"),name:c().optional(),_meta:T(c(),j()).optional()}),so=Z.shape,Bn=m({experimental:so.experimental,sampling:so.sampling,elicitation:so.elicitation,roots:so.roots,extensions:so.extensions}),st=oe.shape,gr=m({experimental:st.experimental,logging:st.logging,completions:st.completions,prompts:st.prompts,resources:st.resources,tools:st.tools,extensions:st.extensions}),Sr=U({progressToken:o.optional(),[Jt]:c(),[nn]:W.optional(),[Wo]:Bn,[sn]:i.optional()}),Oo=m({...H.shape,...z.shape,description:c().optional(),inputSchema:U({$schema:c().optional(),type:b("object")}),outputSchema:U({$schema:c().optional()}).optional(),annotations:nt.optional(),_meta:T(c(),j()).optional()}),Wn=m({type:b("tool_result"),toolUseId:c(),content:_(Ze),structuredContent:j().optional(),isError:k().optional(),_meta:T(c(),j()).optional()}),_r=C([Oe,Ne,ct,Eo,Wn]),No=m({role:s,content:C([_r,_(_r)]),_meta:T(c(),j()).optional()}),br=c(),yr=U({[Bt]:W.optional().catch(void 0)}),zr=yr.optional();function Pe(Se){return U({_meta:zr,resultType:br.default("complete"),...Se})}let Kn=Pe({}),Va=Pe({nextCursor:r.optional()}),vr=Pe({content:_(Ze),structuredContent:j().optional(),isError:k().optional()}),Gn=Pe({ttlMs:R().int().min(0),cacheScope:K(["public","private"]),tools:_(Oo),nextCursor:r.optional()}),Yn=Pe({ttlMs:R().int().min(0),cacheScope:K(["public","private"]),prompts:_(yt),nextCursor:r.optional()}),Xn=Pe({description:c().optional(),messages:_(rt)}),Qn=Pe({ttlMs:R().int().min(0),cacheScope:K(["public","private"]),resources:_(ot),nextCursor:r.optional()}),es=Pe({ttlMs:R().int().min(0),cacheScope:K(["public","private"]),resourceTemplates:_(bt),nextCursor:r.optional()}),ts=Pe({ttlMs:R().int().min(0),cacheScope:K(["public","private"]),contents:_(C([Ce,_t]))}),os=Pe({completion:m({values:_(c()).max(100),total:R().int().optional(),hasMore:k().optional()}).loose()}),Ja=Pe({ttlMs:R().int().min(0),cacheScope:K(["public","private"])}),rs=Pe({ttlMs:R().int().min(0).catch(0),cacheScope:K(["public","private"]).catch("private"),supportedVersions:_(c()),capabilities:gr,instructions:c().optional()}),io=m({messages:_(No),modelPreferences:no.optional(),systemPrompt:c().optional(),includeContext:K(["none","thisServer","allServers"]).optional(),temperature:R().optional(),maxTokens:R().int(),stopSequences:_(c()).optional(),metadata:t.optional(),tools:_(Oo).optional(),toolChoice:Rt.optional()}),ns=m({method:b("sampling/createMessage"),params:io}),ss=m({method:b("roots/list"),params:m({_meta:T(c(),j()).optional()}).optional()}),is=m({...No.shape,model:c(),stopReason:c().optional()}),as=m({roots:_(Jn)}),cs=m({action:K(["accept","decline","cancel"]),content:T(c(),C([c(),R(),k(),_(c())])).optional()}),ls=m({mode:b("url"),message:c(),url:c().url()}),us=C([xt,ls]),ds=m({method:b("elicitation/create"),params:us}),ps=C([ns,ss,ds]),hs=C([is,as,cs]),ms=T(c(),ps),fs=T(c(),hs),qo=Pe({inputRequests:ms.optional(),requestState:c().optional()}),Mo={inputResponses:fs.optional(),requestState:c().optional()},Ba=m({_meta:Sr,...Mo}),Wa=U({progressToken:o.optional()});function Ke(Se,jo){return m({method:b(Se),params:m({_meta:Sr,...jo})})}function Ge(Se,jo){return m({method:b(Se),params:m({_meta:Wa.optional(),...jo}).optional()})}let gs={name:c(),arguments:T(c(),j()).optional(),...Mo},lt={cursor:r.optional()},Ka=Ke("tools/call",gs),Ga=Ke("tools/list",lt),Ya=Ke("prompts/list",lt),Xa=Ke("prompts/get",{name:c(),arguments:T(c(),c()).optional(),...Mo}),Qa=Ke("resources/list",lt),ec=Ke("resources/templates/list",lt),tc=Ke("resources/read",{uri:c(),...Mo}),Ss={ref:C([Io,Co]),argument:m({name:c(),value:c()}),context:m({arguments:T(c(),c()).optional()}).optional()},oc=Ke("completion/complete",Ss),rc=Ke("server/discover",{}),Rr=m({toolsListChanged:k().optional(),promptsListChanged:k().optional(),resourcesListChanged:k().optional(),resourceSubscriptions:_(c()).optional()}),_s={notifications:Rr},nc=Ke("subscriptions/listen",_s),sc=yr.extend({"io.modelcontextprotocol/subscriptionId":n}),bs=U({_meta:sc,resultType:br.default("complete")}),ao={"tools/call":Ge("tools/call",gs),"tools/list":Ge("tools/list",lt),"prompts/get":Ge("prompts/get",{name:c(),arguments:T(c(),c()).optional()}),"prompts/list":Ge("prompts/list",lt),"resources/list":Ge("resources/list",lt),"resources/templates/list":Ge("resources/templates/list",lt),"resources/read":Ge("resources/read",{uri:c()}),"completion/complete":Ge("completion/complete",Ss),"server/discover":Ge("server/discover",{}),"subscriptions/listen":Ge("subscriptions/listen",_s)};function De(Se){return U({_meta:zr,...Se})}let ic={"tools/call":De({content:_(Ze),structuredContent:j().optional(),isError:k().optional()}),"tools/list":De({ttlMs:R().int().min(0),cacheScope:K(["public","private"]),tools:_(Oo),nextCursor:r.optional()}),"prompts/get":De({description:c().optional(),messages:_(rt)}),"prompts/list":De({ttlMs:R().int().min(0),cacheScope:K(["public","private"]),prompts:_(yt),nextCursor:r.optional()}),"resources/list":De({ttlMs:R().int().min(0),cacheScope:K(["public","private"]),resources:_(ot),nextCursor:r.optional()}),"resources/templates/list":De({ttlMs:R().int().min(0),cacheScope:K(["public","private"]),resourceTemplates:_(bt),nextCursor:r.optional()}),"resources/read":De({ttlMs:R().int().min(0),cacheScope:K(["public","private"]),contents:_(C([Ce,_t]))}),"completion/complete":De({completion:m({values:_(c()).max(100),total:R().int().optional(),hasMore:k().optional()}).loose()}),"server/discover":De({ttlMs:R().int().min(0).catch(0),cacheScope:K(["public","private"]).catch("private"),supportedVersions:_(c()),capabilities:gr,instructions:c().optional()}),"subscriptions/listen":De({})},Ao=U({"io.modelcontextprotocol/subscriptionId":n.optional()}),wr=m({method:b("notifications/subscriptions/acknowledged"),params:m({_meta:Ao.optional(),notifications:Rr})}),xr=m({_meta:Ao.optional(),requestId:n,reason:c().optional()}),Pr=m({method:b("notifications/cancelled"),params:xr}),Lu={"notifications/cancelled":Pr,"notifications/progress":$e,"notifications/message":ue,"notifications/resources/updated":jt,"notifications/resources/list_changed":Je,"notifications/tools/list_changed":zt,"notifications/prompts/list_changed":xe,"notifications/subscriptions/acknowledged":wr},qe=Se=>m({jsonrpc:b("2.0"),id:C([c(),R().int()]),result:Se}).strict();return{JSONValueSchema:e,JSONObjectSchema:t,ProgressTokenSchema:o,CursorSchema:r,RequestIdSchema:n,RoleSchema:s,LoggingLevelSchema:i,TaskMetadataSchema:l,RelatedTaskMetadataSchema:u,RequestMetaSchema:d,BaseRequestParamsSchema:h,TaskAugmentedRequestParamsSchema:f,NotificationsParamsSchema:S,NotificationSchema:y,IconSchema:w,IconsSchema:z,BaseMetadataSchema:H,ImplementationSchema:W,ClientTasksCapabilitySchema:x,ServerTasksCapabilitySchema:v,ClientCapabilitiesSchema:Z,ServerCapabilitiesSchema:oe,ProgressSchema:ee,ProgressNotificationParamsSchema:de,ProgressNotificationSchema:$e,LoggingMessageNotificationParamsSchema:ie,LoggingMessageNotificationSchema:ue,ResourceContentsSchema:ze,TextResourceContentsSchema:Ce,BlobResourceContentsSchema:_t,AnnotationsSchema:Ue,ResourceSchema:ot,ResourceTemplateSchema:bt,ResourceListChangedNotificationSchema:Je,ResourceUpdatedNotificationParamsSchema:Ie,ResourceUpdatedNotificationSchema:jt,PromptArgumentSchema:Lt,PromptSchema:yt,PromptListChangedNotificationSchema:xe,TextContentSchema:Oe,ImageContentSchema:Ne,AudioContentSchema:ct,ToolUseContentSchema:Eo,EmbeddedResourceSchema:Be,ResourceLinkSchema:We,ContentBlockSchema:Ze,PromptMessageSchema:rt,ToolAnnotationsSchema:nt,ToolListChangedNotificationSchema:zt,ModelHintSchema:vt,ModelPreferencesSchema:no,ToolChoiceSchema:Rt,BooleanSchemaSchema:ko,StringSchemaSchema:I,NumberSchemaSchema:wt,UntitledSingleSelectEnumSchemaSchema:F,TitledSingleSelectEnumSchemaSchema:A,LegacyTitledEnumSchemaSchema:X,SingleSelectEnumSchemaSchema:O,UntitledMultiSelectEnumSchemaSchema:E,TitledMultiSelectEnumSchemaSchema:J,MultiSelectEnumSchemaSchema:V,EnumSchemaSchema:_e,PrimitiveSchemaDefinitionSchema:$o,ElicitRequestFormParamsSchema:xt,ResourceTemplateReferenceSchema:Co,PromptReferenceSchema:Io,RootSchema:Jn,ClientCapabilities2026Schema:Bn,ServerCapabilities2026Schema:gr,RequestMetaEnvelopeSchema:Sr,ToolSchema:Oo,ToolResultContentSchema:Wn,SamplingMessageContentBlockSchema:_r,SamplingMessageSchema:No,ResultTypeSchema:br,ResultMetaSchema:yr,ResultSchema:Kn,PaginatedResultSchema:Va,CallToolResultSchema:vr,ListToolsResultSchema:Gn,ListPromptsResultSchema:Yn,GetPromptResultSchema:Xn,ListResourcesResultSchema:Qn,ListResourceTemplatesResultSchema:es,ReadResourceResultSchema:ts,CompleteResultSchema:os,CacheableResultSchema:Ja,DiscoverResultSchema:rs,CreateMessageRequestParamsSchema:io,CreateMessageRequestSchema:ns,ListRootsRequestSchema:ss,CreateMessageResultSchema:is,ListRootsResultSchema:as,ElicitResultSchema:cs,ElicitRequestURLParamsSchema:ls,ElicitRequestParamsSchema:us,ElicitRequestSchema:ds,InputRequestSchema:ps,InputResponseSchema:hs,InputRequestsSchema:ms,InputResponsesSchema:fs,InputRequiredResultSchema:qo,InputResponseRequestParamsSchema:Ba,CallToolRequestSchema:Ka,ListToolsRequestSchema:Ga,ListPromptsRequestSchema:Ya,GetPromptRequestSchema:Xa,ListResourcesRequestSchema:Qa,ListResourceTemplatesRequestSchema:ec,ReadResourceRequestSchema:tc,CompleteRequestSchema:oc,DiscoverRequestSchema:rc,SubscriptionFilterSchema:Rr,SubscriptionsListenRequestSchema:nc,SubscriptionsListenResultMetaSchema:sc,SubscriptionsListenResultSchema:bs,dispatchRequestSchemas:ao,dispatchResultSchemas:ic,NotificationMetaSchema:Ao,SubscriptionsAcknowledgedNotificationSchema:wr,CancelledNotificationParamsSchema:xr,CancelledNotificationSchema:Pr,notificationSchemas2026:Lu,JSONRPCResultResponseSchema:qe(Kn),CallToolResultResponseSchema:qe(C([vr,qo])),ListToolsResultResponseSchema:qe(Gn),ListPromptsResultResponseSchema:qe(Yn),GetPromptResultResponseSchema:qe(C([Xn,qo])),ListResourcesResultResponseSchema:qe(Qn),ListResourceTemplatesResultResponseSchema:qe(es),ReadResourceResultResponseSchema:qe(C([ts,qo])),CompleteResultResponseSchema:qe(os),DiscoverResultResponseSchema:qe(rs),SubscriptionsListenResultResponseSchema:qe(bs)}}var cR;function To(){return cR??=aR()}var lR=["tools/list","prompts/list","resources/list","resources/templates/list","resources/read","server/discover"];function uR(e){return lR.includes(e)}var Xf=Symbol("modelcontextprotocol.resultCacheHintFallback");function dR(e){return e[Xf]}function gb(e){return typeof e=="number"&&Number.isSafeInteger(e)&&e>=0}function Sb(e){return e==="public"||e==="private"}var B=(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})({}),se=class _b extends Error{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.ProtocolError"})}static[Symbol.hasInstance](t){return et(this,t)}static isInstance(t){if(typeof this!="function")throw new TypeError("isInstance must be called on the class (e.g. `SdkError.isInstance(value)`); for callbacks use `v => SdkError.isInstance(v)`");return et(this,t)}constructor(t,o,r){super(o),this.code=t,this.data=r,this.name="ProtocolError",lr(this,new.target)}static fromError(t,o,r){if(t===B.UrlElicitationRequired&&r){let n=r;if(n.elicitations)return new yb(n.elicitations,o)}if(t===B.UnsupportedProtocolVersion&&r){let n=r;if(Array.isArray(n.supported)&&typeof n.requested=="string")return new vu({supported:n.supported,requested:n.requested},o)}if(t===B.InvalidParams||t===B.ResourceNotFound){let n=r;if(typeof n?.uri=="string"&&(t===B.ResourceNotFound||Object.keys(n).length===1))return new bb(n.uri,o)}if(t===B.MissingRequiredClientCapability&&r){let n=r;if(n.requiredCapabilities!==null&&typeof n.requiredCapabilities=="object"&&!Array.isArray(n.requiredCapabilities))return new zb({requiredCapabilities:n.requiredCapabilities},o)}return new _b(t,o,r)}},bb=class extends se{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.ResourceNotFoundError"})}constructor(e,t=`Resource not found: ${e}`){super(B.InvalidParams,t,{uri:e})}get uri(){return this.data.uri}},yb=class extends se{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.UrlElicitationRequiredError"})}constructor(e,t=`URL elicitation${e.length>1?"s":""} required`){super(B.UrlElicitationRequired,t,{elicitations:e})}get elicitations(){return this.data?.elicitations??[]}},vu=class extends se{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.UnsupportedProtocolVersionError"})}constructor(e,t=`Unsupported protocol version: ${e.requested}`){super(B.UnsupportedProtocolVersion,t,e)}get supported(){return this.data.supported}get requested(){return this.data.requested}},zb=class extends se{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.MissingRequiredClientCapabilityError"})}constructor(e,t=`Missing required client capabilities: ${Object.keys(e.requiredCapabilities).join(", ")}`){super(B.MissingRequiredClientCapability,t,e)}get requiredCapabilities(){return this.data.requiredCapabilities}},pR=0,hR="private",mR=["tools/call","prompts/get","resources/read"];function fR(e,t){let o=t.resultType;if(o===void 0)return{...t,resultType:"complete"};if(o==="complete"||mR.includes(e))return t;throw new se(B.InternalError,`Handler for ${e} returned resultType '${String(o)}', but results of ${e} only support 'complete' on protocol revision 2026-07-28`)}function gR(e,t){let o=dR(t);if(t.resultType!=="complete"||!uR(e))return o===void 0?t:zR(t);let r=t,n=gb(r.ttlMs)?r.ttlMs:bR(o),s=Sb(r.cacheScope)?r.cacheScope:yR(o),i={...r,ttlMs:n,cacheScope:s};return delete i[Xf],i}function SR(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function _R(e,t){if(t===void 0)return e;let o=e._meta;return o===void 0?{...e,_meta:{[Bt]:t}}:!SR(o)||o[Bt]!==void 0?e:{...e,_meta:{...o,[Bt]:t}}}function bR(e){return e!==void 0&&gb(e.ttlMs)?e.ttlMs:pR}function yR(e){return e!==void 0&&Sb(e.cacheScope)?e.cacheScope:hR}function zR(e){let t={...e};return delete t[Xf],t}var vR=["elicitation/create","sampling/createMessage","roots/list"],_u;function vb(){if(_u)return _u;let e=To();return _u={request:{"elicitation/create":m({method:b("elicitation/create"),params:e.ElicitRequestParamsSchema}),"sampling/createMessage":m({method:b("sampling/createMessage"),params:e.CreateMessageRequestParamsSchema}),"roots/list":m({method:b("roots/list"),params:U({}).optional()})},response:{"elicitation/create":e.ElicitResultSchema,"sampling/createMessage":e.CreateMessageResultSchema,"roots/list":e.ListRootsResultSchema}},_u}function Rb(e){return vR.includes(e)}function jf(e){return Rb(e)?vb().request[e]:void 0}function RR(e){return Rb(e)?vb().response[e]:void 0}var Qf={"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},wb={"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 xb(e){return Object.prototype.hasOwnProperty.call(Qf,e)}function Pb(e){return Object.prototype.hasOwnProperty.call(wb,e)}function wR(e){return Object.prototype.hasOwnProperty.call(Qf,e)}function xR(e){return xb(e)?To().dispatchRequestSchemas[e]:void 0}function PR(e){return wR(e)?To().dispatchResultSchemas[e]:void 0}function TR(e){return Pb(e)?To().notificationSchemas2026[e]:void 0}var lE=Object.keys(Qf),uE=Object.keys(wb);function Na(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function Ia(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 ER={ok:!1,reason:"not-in-era"},kR=[Jt,Wo];function $R(e,t){let o=t,r=!1,n=()=>(r||(o={...o},r=!0),o),s=t.tools;e==="tools/list"&&Array.isArray(s)&&s.some(a=>Na(a)&&"execution"in a)&&(n().tools=s.map(a=>{if(!Na(a)||!("execution"in a))return a;let l={...a};return delete l.execution,l}));let i=t.capabilities;if(Na(i)&&"tasks"in i){let a={...i};delete a.tasks,n().capabilities=a}return o}var eg={era:"2026-07-28",hasRequestMethod:xb,hasNotificationMethod:Pb,hasInputRequestMethod:e=>jf(e)!==void 0,validateRequest:(e,t)=>Ia(xR(e),t),validateResult:(e,t)=>Ia(PR(e),t),validateNotification:(e,t)=>Ia(TR(e),t),validateInputRequest:(e,t)=>Ia(jf(e),t),validateInputResponse:(e,t)=>Ia(RR(e),t),samplingResultVariant:()=>ER,outboundEnvelope(e){return{[Jt]:e.protocolVersion,[nn]:e.clientInfo,[Wo]:e.clientCapabilities,...e.logLevel!==void 0&&{[sn]:e.logLevel}}},validateEnvelopeMeta(e){let t=[];for(let r of kR)r in e||t.push({key:r,problem:"missing"});let o=To().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";n.length===1&&t.some(i=>i.key===s&&i.problem==="missing")||t.push({key:s,problem:r.message})}return t},projectCallToolResult:e=>cb(e),inputRequestSchema:jf,decodeResult(e,t){if(!Na(t))return{kind:"invalid",error:new M(q.InvalidResult,`Invalid result for ${e}: not an object`,{method:e})};let o=t.resultType;if(o===void 0)return{kind:"invalid",error:new M(q.InvalidResult,`Invalid result for ${e}: missing required resultType \u2014 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 M(q.InvalidResult,`Invalid result for ${e}: non-string resultType`,{method:e,resultType:o})};if(o==="input_required"){let i=t.inputRequests,a=Na(i)?i:{},l=t.requestState,u=t._meta===void 0?void 0:To().ResultMetaSchema.safeParse(t._meta),d=u?.success?u.data:void 0;return Object.keys(a).length===0&&typeof l!="string"?{kind:"invalid",error:new M(q.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"})}:{kind:"input_required",inputRequests:a,...typeof l=="string"&&{requestState:l},...d!==void 0&&{_meta:d}}}if(o!=="complete")return{kind:"invalid",error:new M(q.UnsupportedResultType,`Unsupported result type '${o}' for ${e}`,{resultType:o,method:e})};let r=CR(),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 M(q.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 _R(gR(e,fR(e,$R(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=To().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("; ")}`}},bu;function CR(){if(bu)return bu;let e=To();return bu={"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},bu}var Ru="2026-07-28";function Qt(e){return e!==void 0&&to(e)?eg:Yf}function W_(e){return e.revision!==void 0?Qt(e.revision).era:e.era==="modern"?eg.era:Yf.era}function Lf(e){return Tb.some(t=>t.hasRequestMethod(e))}function Uf(e){return Tb.some(t=>t.hasNotificationMethod(e))}function K_(e){return e==="tasks/get"||e==="tasks/cancel"}var Tb=[Yf,eg],IR=Ug({AnnotationsSchema:()=>Ot,AudioContentSchema:()=>tr,BaseMetadataSchema:()=>Ct,BaseRequestParamsSchema:()=>ye,BlobResourceContentsSchema:()=>zn,BooleanSchemaSchema:()=>xn,CallToolRequestParamsSchema:()=>Vi,CallToolRequestSchema:()=>Ji,CallToolResultSchema:()=>Po,CancelTaskRequestSchema:()=>iu,CancelTaskResultSchema:()=>au,CancelledNotificationParamsSchema:()=>ti,CancelledNotificationSchema:()=>hn,ClientCapabilitiesSchema:()=>ri,ClientNotificationSchema:()=>lu,ClientRequestSchema:()=>cu,ClientResultSchema:()=>uu,ClientTasksCapabilitySchema:()=>Wl,CompatibilityCallToolResultSchema:()=>Gl,CompleteRequestParamsSchema:()=>ba,CompleteRequestSchema:()=>ya,CompleteResultSchema:()=>za,ContentBlockSchema:()=>Nt,CreateMessageRequestParamsSchema:()=>na,CreateMessageRequestSchema:()=>sa,CreateMessageResultSchema:()=>ia,CreateMessageResultWithToolsSchema:()=>aa,CreateTaskResultSchema:()=>Xl,CursorSchema:()=>cn,DiscoverRequestSchema:()=>ii,DiscoverResultSchema:()=>wo,ElicitRequestFormParamsSchema:()=>ar,ElicitRequestParamsSchema:()=>pa,ElicitRequestSchema:()=>ha,ElicitRequestURLParamsSchema:()=>da,ElicitResultSchema:()=>ga,ElicitationCompleteNotificationParamsSchema:()=>ma,ElicitationCompleteNotificationSchema:()=>fa,EmbeddedResourceSchema:()=>or,EmptyResultSchema:()=>Ro,EnumSchemaSchema:()=>ua,GetPromptRequestParamsSchema:()=>qi,GetPromptRequestSchema:()=>Mi,GetPromptResultSchema:()=>Li,GetTaskPayloadRequestSchema:()=>ou,GetTaskPayloadResultSchema:()=>ru,GetTaskRequestSchema:()=>eu,GetTaskResultSchema:()=>tu,IconSchema:()=>oi,IconsSchema:()=>Wt,ImageContentSchema:()=>er,ImplementationSchema:()=>It,InitializeRequestParamsSchema:()=>ni,InitializeRequestSchema:()=>mn,InitializeResultSchema:()=>si,InitializedNotificationSchema:()=>gn,JSONArraySchema:()=>Jl,JSONObjectSchema:()=>pe,JSONRPCErrorResponseSchema:()=>Yo,JSONRPCMessageSchema:()=>mt,JSONRPCNotificationSchema:()=>pn,JSONRPCRequestSchema:()=>dn,JSONRPCResponseSchema:()=>Bl,JSONRPCResultResponseSchema:()=>Go,JSONValueSchema:()=>Vt,LegacyTitledEnumSchemaSchema:()=>En,ListChangedOptionsBaseSchema:()=>Wi,ListPromptsRequestSchema:()=>Oi,ListPromptsResultSchema:()=>Ni,ListResourceTemplatesRequestSchema:()=>hi,ListResourceTemplatesResultSchema:()=>mi,ListResourcesRequestSchema:()=>di,ListResourcesResultSchema:()=>pi,ListRootsRequestSchema:()=>Ra,ListRootsResultSchema:()=>wa,ListTasksRequestSchema:()=>nu,ListTasksResultSchema:()=>su,ListToolsRequestSchema:()=>Fi,ListToolsResultSchema:()=>Hi,LoggingLevelSchema:()=>wn,LoggingMessageNotificationParamsSchema:()=>Yi,LoggingMessageNotificationSchema:()=>nr,ModelHintSchema:()=>Xi,ModelPreferencesSchema:()=>Qi,MultiSelectEnumSchemaSchema:()=>la,NotificationSchema:()=>Re,NotificationsParamsSchema:()=>ke,NumberSchemaSchema:()=>ir,PaginatedRequestParamsSchema:()=>li,PaginatedRequestSchema:()=>Kt,PaginatedResultSchema:()=>Gt,PingRequestSchema:()=>Sn,PrimitiveSchemaDefinitionSchema:()=>Cn,ProgressNotificationParamsSchema:()=>ci,ProgressNotificationSchema:()=>_n,ProgressSchema:()=>ai,ProgressTokenSchema:()=>an,PromptArgumentSchema:()=>Ci,PromptListChangedNotificationSchema:()=>Ui,PromptMessageSchema:()=>ji,PromptReferenceSchema:()=>_a,PromptSchema:()=>Ii,ReadResourceRequestParamsSchema:()=>fi,ReadResourceRequestSchema:()=>gi,ReadResourceResultSchema:()=>Si,RelatedTaskMetadataSchema:()=>ei,RequestIdSchema:()=>ht,RequestMetaSchema:()=>ln,RequestSchema:()=>he,ResourceContentsSchema:()=>bn,ResourceLinkSchema:()=>rr,ResourceListChangedNotificationSchema:()=>_i,ResourceRequestParamsSchema:()=>Xo,ResourceSchema:()=>vn,ResourceTemplateReferenceSchema:()=>Sa,ResourceTemplateSchema:()=>ui,ResourceUpdatedNotificationParamsSchema:()=>ki,ResourceUpdatedNotificationSchema:()=>$i,ResultMetaObjectSchema:()=>un,ResultSchema:()=>me,RoleSchema:()=>Yt,RootSchema:()=>va,RootsListChangedNotificationSchema:()=>xa,SamplingContentSchema:()=>oa,SamplingMessageContentBlockSchema:()=>zo,SamplingMessageSchema:()=>ra,ServerCapabilitiesSchema:()=>fn,ServerNotificationSchema:()=>pu,ServerRequestSchema:()=>du,ServerResultSchema:()=>hu,ServerTasksCapabilitySchema:()=>Kl,SetLevelRequestParamsSchema:()=>Ki,SetLevelRequestSchema:()=>Gi,SingleSelectEnumSchemaSchema:()=>ca,StringSchemaSchema:()=>sr,SubscribeRequestParamsSchema:()=>bi,SubscribeRequestSchema:()=>yi,SubscriptionFilterSchema:()=>Rn,SubscriptionsAcknowledgedNotificationParamsSchema:()=>xi,SubscriptionsAcknowledgedNotificationSchema:()=>Pi,SubscriptionsListenRequestParamsSchema:()=>Ri,SubscriptionsListenRequestSchema:()=>wi,SubscriptionsListenResultMetaSchema:()=>Ti,SubscriptionsListenResultSchema:()=>Ei,TaskAugmentedRequestParamsSchema:()=>vo,TaskCreationParamsSchema:()=>Yl,TaskMetadataSchema:()=>Qs,TaskSchema:()=>Xt,TaskStatusNotificationParamsSchema:()=>Ta,TaskStatusNotificationSchema:()=>Ql,TaskStatusSchema:()=>Pa,TextContentSchema:()=>Qo,TextResourceContentsSchema:()=>yn,TitledMultiSelectEnumSchemaSchema:()=>$n,TitledSingleSelectEnumSchemaSchema:()=>Tn,ToolAnnotationsSchema:()=>Zi,ToolChoiceSchema:()=>ea,ToolExecutionSchema:()=>Di,ToolListChangedNotificationSchema:()=>Bi,ToolResultContentSchema:()=>ta,ToolSchema:()=>xo,ToolUseContentSchema:()=>Ai,UnsubscribeRequestParamsSchema:()=>zi,UnsubscribeRequestSchema:()=>vi,UntitledMultiSelectEnumSchemaSchema:()=>kn,UntitledSingleSelectEnumSchemaSchema:()=>Pn});var dr=e=>dn.safeParse(e).success,Eb=e=>pn.safeParse(e).success,jn=e=>Go.safeParse(e).success,Ln=e=>Yo.safeParse(e).success;var kb=e=>typeof e=="object"&&e!==null&&!Array.isArray(e)&&e.resultType==="input_required";var tg=e=>mn.safeParse(e).success,$b=e=>gn.safeParse(e).success;var OR="Mcp-Param-",G_="x-mcp-header",NR=/^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/,qR=new Set(["string","integer","boolean","number"]);function og(e){let t=[],o=new Map,r=(s,i,a)=>{if(s===null||typeof s!="object")return;let l=s;if(G_ in l){if(!a||i.length===0)return`${yu(i)}: 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 d=l[G_];if(typeof d!="string"||d.length===0)return`${yu(i)}: x-mcp-header MUST be a non-empty string`;if(!NR.test(d))return`${yu(i)}: x-mcp-header '${d}' is not a valid RFC 9110 token (no spaces, control characters or HTTP delimiters)`;let h=typeof l.type=="string"?l.type:void 0;if(h===void 0||!qR.has(h))return`${yu(i)}: x-mcp-header is only permitted on primitive-typed properties (string, integer, boolean); got ${h??"<none>"}`;let f=d.toLowerCase(),S=o.get(f);if(S!==void 0)return`x-mcp-header '${d}' is not case-insensitively unique (also declared as '${S}')`;o.set(f,d),t.push({path:i,headerName:d,type:h})}let u=l.properties;if(u!==null&&typeof u=="object")for(let[d,h]of Object.entries(u)){let f=r(h,[...i,d],a);if(f!==void 0)return f}for(let d of MR){let h=l[d];if(h===void 0)continue;let f=Array.isArray(h)?h:h!==null&&typeof h=="object"&&AR.has(d)?Object.values(h):[h];for(let S of f){let y=r(S,[...i,`<${d}>`],!1);if(y!==void 0)return y}}},n=r(e,[],!0);return n===void 0?{valid:!0,declarations:t}:{valid:!1,reason:n}}var MR=["items","prefixItems","contains","additionalProperties","unevaluatedProperties","unevaluatedItems","propertyNames","patternProperties","dependentSchemas","oneOf","anyOf","allOf","not","if","then","else","$defs","definitions"],AR=new Set(["patternProperties","dependentSchemas","$defs","definitions"]);function yu(e){return e.length===0?"<root>":e.join(".")}var Cb="=?base64?",Ib="?=";function jR(e){if(typeof e=="string")return e;if(typeof e=="boolean")return e?"true":"false";if(typeof e=="number")return!Number.isFinite(e)||Number.isInteger(e)&&!Number.isSafeInteger(e)?void 0:String(e)}function LR(e){if(e.length===0||e.startsWith(Cb)&&e.endsWith(Ib)||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))return!0}return!1}function UR(e){let t=new TextEncoder().encode(e),o="";for(let r of t)o+=String.fromCodePoint(r);return btoa(o)}function rg(e){return LR(e)?`${Cb}${UR(e)}${Ib}`:e}function ZR(e,t){let o=e;for(let r of t){if(o===null||typeof o!="object")return;o=o[r]}return o}function Ob(e,t){let o={};for(let r of e){let n=ZR(t,r.path);if(n==null)continue;let s=jR(n);s!==void 0&&(o[`${OR}${r.headerName}`]=rg(s))}return o}var An=-32020,dE=[{rung:"http-method",order:1,evaluatedAt:"edge",codes:[-32e3],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:[B.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:[An,B.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:[B.InvalidParams],conformance:["server-stateless"],rationale:"A present envelope claim with a malformed envelope \u2014 and a missing envelope on a request whose protocol-version header names a modern revision \u2014 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:[B.MethodNotFound],conformance:["server-stateless"],rationale:"Method existence outranks parameter validity: a method absent from the negotiated revision\u2019s 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:[B.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:[An],conformance:["http-header-validation"],rationale:"SEP-2243 standard `MCP-Protocol-Version` / `Mcp-Method` / `Mcp-Name` headers \u2014 presence, sentinel decoding, and `Mcp-Name` \u2194 body cross-check \u2014 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\u2019s 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 \u2014 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\u20136) are consulted."},{rung:"client-capabilities",order:8,evaluatedAt:"pre-dispatch",codes:[B.MissingRequiredClientCapability],conformance:["server-stateless"],rationale:"The capability requirement is checked by the HTTP entry, pre-dispatch, against the validated envelope the classifier produced \u2014 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:[An],conformance:["http-custom-header-server-validation"],rationale:"SEP-2243 `Mcp-Param-*` headers are validated against the named tool\u2019s `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."}],pE={[B.ParseError]:400,[B.InvalidRequest]:400,[B.MethodNotFound]:404,[B.UnsupportedProtocolVersion]:400,[B.MissingRequiredClientCapability]:400,[An]:400},Y_={"tools/call":"name","prompts/get":"name","resources/read":"uri","tasks/get":"taskId","tasks/update":"taskId","tasks/cancel":"taskId"};function Nb(e,t){let o=Object.hasOwn(Y_,e)?Y_[e]:void 0;if(o===void 0)return;let r=DR(t)?t[o]:void 0;return{field:o,value:typeof r=="string"?r:void 0}}function DR(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function wu(e,t){return Us(e,t)}function Oa(e){return new Set(e.flatMap(t=>Object.keys(t.shape)))}function Hf(e){if(e==null)return!1;let t=typeof e;return t!=="object"&&t!=="function"||!("~standard"in e)?!1:typeof e["~standard"]?.validate=="function"}var X_=!1,Vf="draft-2020-12";function FR(e,t="input"){let o=e["~standard"],r;if(o.jsonSchema)r=o.jsonSchema[t]({target:Vf});else if(o.vendor==="zod"){if(!("_zod"in e))throw new 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().");X_||(X_=!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=Jo(e,{target:Vf,io:t})}else throw new 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")return r.type!==void 0?r:qb(r)?{type:"object",...r}:r;if(r.type!==void 0&&r.type!=="object")throw new 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 qb(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"||qb(r)))}return!1}function HR(e){return e.path?.length?`${e.path.map(t=>String(typeof t=="object"?t.key:t)).join(".")}: ${e.message}`:e.message}async function Zf(e,t){let o=await e["~standard"].validate(t);return o.issues&&o.issues.length>0?{success:!1,error:o.issues.map(r=>HR(r)).join(", ")}:{success:!0,data:o.value}}function VR(e){let t=Jo(e,{target:Vf,io:"input"});return typeof t.pattern=="string"?t.pattern:void 0}var JR=/\\\.\\d\{(\d+)\}/;function BR(e){let t=JR.exec(e),o=[void 0,-1,0];return t&&o.push(Number(t[1])),[!1,!0].flatMap(r=>[!1,!0].flatMap(n=>o.map(s=>Qe.datetime({local:r,offset:n,precision:s}))))}function WR(e,t){let o;switch(e){case"email":o=[vl()];break;case"uri":o=[Xr()];break;case"date":o=[Qe.date()];break;case"date-time":o=BR(t);break}return new Set(o.map(r=>VR(r)).filter(r=>r!==void 0))}function KR(e,t,o){return o!=="zod"?!0:WR(e,t).has(t)}function Ma(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function GR(e){try{return FR(e,"input")}catch(t){let o=t instanceof Error?t.message:String(t);throw new se(B.InvalidParams,`Elicitation requestedSchema must describe an object with flat primitive properties: ${o}`)}}var YR=new Set(["$comment","deprecated","description","examples","readOnly","title","writeOnly"]);function ng(e){return YR.has(e)||e.startsWith("x-")}var XR=new Set(["$schema",...Object.keys(ar.shape.requestedSchema.shape)]),Q_={string:Oa([sr,Pn,Tn,En]),number:Oa([ir]),integer:Oa([ir]),boolean:Oa([xn]),array:Oa([kn,$n])},QR=new Set(sr.shape.format.unwrap().options);function ew(e,t,o,r){if(!Ma(e))return e;let n=typeof e.type=="string"&&Object.hasOwn(Q_,e.type)?Q_[e.type]:void 0;if(n===void 0)return e;let s={};for(let[i,a]of Object.entries(e))n.has(i)||ng(i)?s[i]=a:i==="pattern"&&e.type==="string"&&typeof e.format=="string"?QR.has(e.format)?(typeof a!="string"||!KR(e.format,a,o))&&r.push(`${t}.${i}`):s[i]=a:r.push(`${t}.${i}`);return s}function tw(e,t){let o={},r=[];for(let[n,s]of Object.entries(e))n==="properties"&&Ma(s)?o[n]=Object.fromEntries(Object.entries(s).map(([i,a])=>[i,ew(a,`properties.${i}`,t,r)])):XR.has(n)?o[n]=s:ng(n)||r.push(n);if(r.length>0)throw new se(B.InvalidParams,`Elicitation requestedSchema contains unsupported JSON Schema constraint(s) after Standard Schema conversion: ${r.join(", ")}`);return o}function ow(e,t){if(!Ma(e.properties))return t;let o=Object.entries(e.properties).filter(([,r])=>!wu(Cn,r).success).map(([r])=>`properties.${r}`);return o.length>0?o.join(", "):t}function Jf(e,t,o=""){return Array.isArray(e)&&Array.isArray(t)?e.flatMap((r,n)=>Jf(r,t[n],`${o}[${n}]`)):!Ma(e)||!Ma(t)?[]:Object.entries(e).flatMap(([r,n])=>{let s=o?`${o}.${r}`:r;return Object.prototype.hasOwnProperty.call(t,r)?Jf(n,t[r],s):ng(r)?[]:[s]})}function rw(e){if(!Hf(e.requestedSchema))return{...e,mode:"form",requestedSchema:e.requestedSchema};let t=e.requestedSchema["~standard"].vendor,o=tw(GR(e.requestedSchema),t),r=wu(ar.shape.requestedSchema,o);if(!r.success)throw new se(B.InvalidParams,`Elicitation requestedSchema only supports flat primitive properties (string, number, integer, boolean, and string enums): ${ow(o,r.error.message)}`);let n=Jf(o,r.data);if(n.length>0)throw new se(B.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 se(B.InvalidParams,`Elicitation requestedSchema lists required properties that are not defined in properties: ${s.join(", ")}`);return{...e,mode:"form",requestedSchema:r.data}}function nw(e){let t=e.inputRequests!==void 0&&Object.keys(e.inputRequests).length>0,o=typeof e.requestState=="string";if(!t&&!o)throw new 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 hE=Object.assign(nw,{elicit(e){try{return{method:"elicitation/create",params:rw(e)}}catch(t){throw t instanceof se?new 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 sw=!0,iw=10,aw=250;function Mb(e){return{autoFulfill:e?.autoFulfill??sw,maxRounds:e?.maxRounds??iw}}function cw(e,t,o){let r=t!==void 0&&Object.keys(t).length>0;return!r&&o===void 0?e:{...e,...r&&{inputResponses:t},...o!==void 0&&{requestState:o}}}function lw(e,t){return`Multi-round-trip request '${e}' still required input after ${t} rounds (inputRequired.maxRounds)`}function uw(e,t){return new Promise((o,r)=>{if(t?.aborted){r(t.reason instanceof M?t.reason:new M(q.RequestTimeout,String(t.reason)));return}let n=setTimeout(()=>{t?.removeEventListener("abort",s),o()},e),s=()=>{clearTimeout(n),r(t?.reason instanceof M?t.reason:new M(q.RequestTimeout,String(t?.reason)))};t?.addEventListener("abort",s,{once:!0})})}function dw(e){let t=new AbortController,o=()=>t.abort(e?.reason);return e?.addEventListener("abort",o,{once:!0}),e?.aborted&&t.abort(e.reason),{signal:t.signal,abort:r=>t.abort(r),dispose:()=>e?.removeEventListener("abort",o)}}async function pw(e){let{config:t,method:o,originalParams:r,requestOptions:n,hooks:s,signal:i}=e,a=e.flowStartedAt??Date.now(),l=e.firstPayload,u=0;for(;;){if(u+=1,u>t.maxRounds)throw new M(q.InputRequiredRoundsExceeded,lw(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 d=Object.entries(l.inputRequests??{}),h;if(d.length>0){let y=dw(i);try{let w=await Promise.all(d.map(async([z,H])=>{try{return[z,await s.dispatchInputRequest(z,H,y.signal)]}catch(W){throw y.abort(W),W}}));h=Object.fromEntries(w)}finally{y.dispose()}}else await uw(aw,i);let f={...n.timeout!==void 0&&{timeout:n.timeout}};if(n.maxTotalTimeout!==void 0){let y=Date.now()-a,w=n.maxTotalTimeout-y;if(w<=0)throw new M(q.RequestTimeout,"Maximum total timeout exceeded",{maxTotalTimeout:n.maxTotalTimeout,totalElapsed:y});f.maxTotalTimeout=w}let S=await s.retry(cw(r,h,l.requestState),f);if(kb(S)){l={inputRequests:S.inputRequests??{},...S.requestState!==void 0&&{requestState:S.requestState}};continue}return S}}var hw=["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"],mw={IdJagTokenExchangeResponseSchema:ka,OAuthClientInformationFullSchema:Mn,OAuthClientInformationSchema:Ca,OAuthClientMetadataSchema:$a,OAuthClientRegistrationErrorSchema:mu,OAuthErrorResponseSchema:qn,OAuthMetadataSchema:cr,OAuthProtectedResourceMetadataSchema:In,OAuthTokenRevocationRequestSchema:fu,OAuthTokensSchema:Nn,OpenIdProviderDiscoveryMetadataSchema:On,OpenIdProviderMetadataSchema:Ea},Ab={},jb={};function Lb(e,t){let o=e.slice(0,-6);Ab[o]=t,jb[o]=r=>t.safeParse(r).success}for(let e of hw)Lb(e,IR[e]);for(let[e,t]of Object.entries(mw))Lb(e,t);var fw=Object.freeze(Ab),Ub=Object.freeze(jb);function gw(e){switch(e){case"initialize":case"notifications/initialized":return Qt(void 0);case"server/discover":return Qt(Ru);default:return}}var xu=6e4,Sw=[Jt,nn,Wo,sn],_w=["inputResponses","requestState"];function eb(e,t){let o=e.params;if(!qa(o))return{message:e,lifted:{}};let r=o._meta,n=qa(r)?Sw.filter(l=>l in r):[],s=t==="request"?_w.filter(l=>l in o):[];if(n.length===0&&s.length===0)return{message:e,lifted:{}};let i={},a={...o};if(n.length>0&&qa(r)){let l={},u={...r};for(let d of n)l[d]=r[d],delete u[d];i.envelope=l,Object.keys(u).length>0?a._meta=u:delete a._meta}for(let l of s)l==="inputResponses"&&(i.inputResponses=a[l]),l==="requestState"&&(i.requestState=a[l]),delete a[l];return{message:{...e,params:a},lifted:i}}function tb(e,t){let o=e.validateResult(t,void 0);if(!(!o.ok&&o.reason==="not-in-era"))return{"~standard":{version:1,vendor:"mcp-wire-codec",validate(r){let n=e.validateResult(t,r);return n.ok?{value:n.value}:{issues:[{message:n.reason==="invalid"?n.message:`not-in-era: ${t}`}]}}}}}function sg(e){return()=>e}var bw=sg(void 0),yw,Pu=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{yw=(e,t)=>{e._negotiatedProtocolVersion=t}}_supportedProtocolVersions;onclose;onerror;fallbackRequestHandler;fallbackNotificationHandler;constructor(e){this._options=e,this._supportedProtocolVersions=e?.supportedProtocolVersions??Hl,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 M(q.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){e.params.requestId!==void 0&&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 M(q.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);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)=>{r?.(n,s),jn(n)||Ln(n)?this._onresponse(n):dr(n)?this._onrequest(n,s):Eb(n)?this._onnotification(n,s):this._onerror(new 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 M(q.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}=eb(e,"notification"),r=this._negotiatedWireCodec();if(t?.classification===void 0&&this._shouldDropInbound(e)==="drop")return;if(t?.classification!==void 0){let i=W_(t.classification);if(i!==r.era){this._onerror(new Error(`Era mismatch on inbound notification '${o.method}': classified as ${i} but this instance serves ${r.era}`));return}}if(Uf(o.method)&&!r.hasNotificationMethod(o.method))return;let n=this._notificationHandlers.get(o.method),s=this.fallbackNotificationHandler;n===void 0&&s===void 0||Promise.resolve().then(()=>n===void 0?s(o):n(o,r)).catch(i=>this._onerror(new Error(`Uncaught error in notification handler: ${i}`)))}_onrequest(e,t){let{message:o,lifted:r}=eb(e,"request"),n=this._negotiatedWireCodec();if(t?.classification===void 0&&this._shouldDropInbound(e)==="drop"){this._onerror(new Error(`Dropped inbound request '${e.method}': not servable on this connection's protocol era`));return}let s=this._transport,i=(w,z,H)=>{let W={jsonrpc:"2.0",id:o.id,error:{code:w,message:z,...H!==void 0&&{data:H}}};s?.send(W).catch(N=>this._onerror(new Error(`Failed to send an error response: ${N}`)))};if(t?.classification!==void 0){let w=W_(t.classification);if(w!==n.era){this._onerror(new Error(`Era mismatch on inbound request '${o.method}': classified as ${w} but this instance serves ${n.era}`));let z=t.classification.revision??w;i(B.UnsupportedProtocolVersion,`Unsupported protocol version: ${z}`,{supported:this._supportedProtocolVersions,requested:z});return}}if(Lf(o.method)&&!n.hasRequestMethod(o.method)&&!(K_(o.method)&&this._customSchemaRequestMethods.has(o.method))){i(B.MethodNotFound,"Method not found");return}let a=this._requestHandlers.get(o.method)??this.fallbackRequestHandler;if(a===void 0){i(B.MethodNotFound,"Method not found");return}let l=n.checkInboundEnvelope(r);if(l!==void 0){i(B.InvalidParams,l);return}let u=(w,z)=>this._notificationViaCodec(this._resolveOutboundCodec(w.method),w,{...z,relatedRequestId:o.id}),d=(w,z,H)=>this._requestWithSchemaViaCodec(this._resolveOutboundCodec(w.method),w,z,{...H,relatedRequestId:o.id}),h=new AbortController;this._requestHandlerAbortControllers.set(o.id,h);let f=r.inputResponses===void 0?void 0:zw(r.inputResponses),S={sessionId:s?.sessionId,mcpReq:{id:o.id,method:o.method,_meta:o.params?._meta,...r.envelope!==void 0&&{envelope:r.envelope},...f!==void 0&&{inputResponses:f.accepted},...f!==void 0&&f.droppedKeys.length>0&&{droppedInputResponseKeys:f.droppedKeys},requestState:r.requestState===void 0?bw:sg(r.requestState),signal:h.signal,send:((w,z,H)=>{let W=this._resolveOutboundCodec(w.method);if(this._assertOutboundRequestInEra(W,w.method),Hf(z))return d(w,z,H);let N=tb(W,w.method);if(N===void 0)throw new TypeError(`'${w.method}' is not a spec method; pass a result schema as the second argument to ctx.mcpReq.send().`);return d(w,N,z)}),notify:u},http:t?.authInfo?{authInfo:t.authInfo}:void 0},y=this.buildContext(S,t);Promise.resolve().then(()=>a(o,y)).then(async w=>{if(h.signal.aborted)return;let z;try{z=n.encodeResult(o.method,w,this._outboundServerInfo())}catch(W){this._onerror(new Error(`Failed to encode result for ${o.method}: ${W}`)),i(B.InternalError,"Internal error");return}let H={result:z,jsonrpc:"2.0",id:o.id};await s?.send(H)},async w=>{if(h.signal.aborted)return;let z=Number.isSafeInteger(w.code)?w.code:B.InternalError,H={jsonrpc:"2.0",id:o.id,error:{code:n.encodeErrorCode(z),message:w.message??"Internal error",...w.data!==void 0&&{data:w.data}}};await s?.send(H)}).catch(w=>this._onerror(new Error(`Failed to send response: ${w}`))).finally(()=>{this._requestHandlerAbortControllers.get(o.id)===h&&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(new 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(a){this._responseHandlers.delete(r),this._progressHandlers.delete(r),this._cleanupTimeout(r),s(a);return}n(o)}_onresponse(e){let t=Number(e.id),o=this._responseHandlers.get(t);if(o===void 0){this._onerror(new Error(`Received a response for an unknown message ID: ${JSON.stringify(e)}`));return}this._responseHandlers.delete(t),this._cleanupTimeout(t),this._progressHandlers.delete(t),jn(e)?o(e):o(se.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(Hf(t))return K_(e.method)||this._assertOutboundRequestInEra(r,e.method),this._requestWithSchemaViaCodec(r,e,t,o);this._assertOutboundRequestInEra(r,e.method);let n=tb(r,e.method);if(n===void 0)throw new 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 Qt(this._negotiatedProtocolVersion)}_wireCodec(){return this._negotiatedWireCodec()}_resolveOutboundCodec(e){if(this._negotiatedProtocolVersion===void 0){let t=gw(e);if(t)return t}return this._negotiatedWireCodec()}_assertOutboundRequestInEra(e,t){if(Lf(t)&&!e.hasRequestMethod(t))throw new M(q.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:a}=r??{},l=Date.now(),u,d;return new Promise((h,f)=>{let S=v=>{f(v)};if(!this._transport){S(new Error("Not connected"));return}if(this._options?.enforceStrictCapabilities===!0)try{this.assertCapabilityForMethod(t.method)}catch(v){S(v);return}if(r?.signal?.aborted){let v=r.signal.reason;throw v instanceof M?v:new M(q.RequestTimeout,String(v))}let y=e.era===Ru&&this._transport.hasPerRequestStream===!0?new AbortController:void 0,w=this._requestMessageId++;d=w;let z={...t,jsonrpc:"2.0",id:w};r?.onprogress&&(this._progressHandlers.set(w,r.onprogress),z.params={...t.params,_meta:{...t.params?._meta,progressToken:w}});let H=this._envelopeOutbound(z),W=!1,N=v=>{W||(this._progressHandlers.delete(w),y===void 0?t.method!=="initialize"&&this._transport?.send(this._envelopeOutbound({jsonrpc:"2.0",method:"notifications/cancelled",params:{requestId:w,reason:String(v)}}),{relatedRequestId:n,resumptionToken:s,onresumptiontoken:i}).catch(Z=>this._onerror(new Error(`Failed to send cancellation: ${Z}`))):y.abort(),f(v instanceof M?v:new M(q.RequestTimeout,String(v))))};this._responseHandlers.set(w,v=>{if(r?.signal?.aborted)return;if(W=!0,v instanceof Error)return f(v);let Z;try{Z=e.decodeResult(t.method,v.result)}catch(ee){return f(ee instanceof Error?ee:new Error(String(ee)))}if(Z.kind==="invalid")return f(Z.error);if(Z.kind==="input_required"){if(r?.allowInputRequired===!0)return h(xw(Z));let ee={codec:e,request:t,resultSchema:o,options:r,flowStartedAt:l,retry:(de,$e)=>this._requestWithSchemaViaCodec(e,de===void 0?{method:t.method}:{method:t.method,params:de},o,$e)};return h(this._resolveNonCompleteResult(Z,ee))}let oe=Z.result;Zf(o,oe).then(ee=>{ee.success?h(ee.data):f(new M(q.InvalidResult,`Invalid result for ${t.method}: ${ee.error}`))},f)}),u=()=>N(r?.signal?.reason),r?.signal?.addEventListener("abort",u,{once:!0});let D=r?.timeout??xu,x=()=>N(new M(q.RequestTimeout,"Request timed out",{timeout:D}));this._setupTimeout(w,D,r?.maxTotalTimeout,x,r?.resetTimeoutOnProgress??!1),this._transport.send(H,{relatedRequestId:n,resumptionToken:s,onresumptiontoken:i,headers:a,requestSignal:y?.signal}).catch(v=>{this._progressHandlers.delete(w),f(v)})}).finally(()=>{u&&r?.signal?.removeEventListener("abort",u),d!==void 0&&(this._responseHandlers.delete(d),this._cleanupTimeout(d))})}async notification(e,t){return await this._notificationViaCodec(this._resolveOutboundCodec(e.method),e,t)}async _notificationViaCodec(e,t,o){if(!this._transport)throw new M(q.NotConnected,"Not connected");if(Uf(t.method)&&!e.hasNotificationMethod(t.method))throw new M(q.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(()=>{this._pendingDebouncedNotifications.delete(t.method),this._transport&&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(!Lf(e))throw new TypeError(`'${e}' is not a spec request method; pass schemas as the second argument to setRequestHandler().`);r=(n,s)=>{let i=this._negotiatedWireCodec(),a=i.validateRequest(e,n);if(!a.ok&&a.reason==="not-in-era"&&(a=i.validateInputRequest(e,n)),!a.ok)throw a.reason==="not-in-era"?new se(B.InternalError,`No wire schema for ${e} in the resolved era`):new Error(a.message);return Promise.resolve(t(a.value,s))}}else if(o)r=async(n,s)=>{let i=await Zf(t.params,{...n.params});if(!i.success)throw new se(B.InvalidParams,`Invalid params for ${e}: ${i.error}`);return o(i.data,s)};else throw new TypeError("setRequestHandler: handler is required");typeof t=="function"?this._customSchemaRequestMethods.delete(e):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 new Error(`A request handler for ${e} already exists, which would be overridden`)}setNotificationHandler(e,t,o){if(typeof t=="function"){if(!Uf(e))throw new 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)throw s.reason==="not-in-era"?new se(B.InternalError,`No wire schema for ${e} in the resolved era`):new Error(s.message);return Promise.resolve(t(s.value))});return}if(!o)throw new TypeError("setNotificationHandler: handler is required");this._notificationHandlers.set(e,async r=>{let n=await Zf(t.params,{...r.params});if(!n.success)throw new se(B.InvalidParams,`Invalid params for notification ${e}: ${n.error}`);await o(n.data,r)})}removeNotificationHandler(e){this._notificationHandlers.delete(e)}};function qa(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function Zb(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]=qa(i)&&qa(s)?{...i,...s}:s}return o}function zu(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function zw(e){let t={},o=[];if(!zu(e))return{accepted:t,droppedKeys:o};for(let[r,n]of Object.entries(e)){if(!zu(n)||"method"in n||"result"in n){o.push(r);continue}t[r]=n}return{accepted:t,droppedKeys:o}}function ob(e){throw new M(q.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 vw(e,t,o,r,n){return{sessionId:n,mcpReq:{id:e,method:t,_meta:o?._meta,requestState:sg(void 0),signal:r,send:(()=>ob("send")),notify:()=>ob("notify")}}}async function Rw(e,t,o,r,n){if(!zu(r)||typeof r.method!="string")throw new M(q.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 M(q.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 M(q.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 a=zu(r.params)?r.params:void 0;return await i({jsonrpc:"2.0",id:o,method:s,...a!==void 0&&{params:a}},e.buildContext(vw(o,s,a,n,e.sessionId)))}function ww(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 Db(e,t,o,r){let{codec:n,request:s,options:i,flowStartedAt:a}=r,l={inputRequests:o.inputRequests,...o.requestState!==void 0&&{requestState:o.requestState}},u={dispatchInputRequest:(d,h,f)=>Rw(e,n,d,h,f),retry:(d,h)=>r.retry(d,ww(i,h))};return pw({config:t,method:s.method,originalParams:s.params,firstPayload:l,flowStartedAt:a,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 xw(e){return{resultType:"input_required",inputRequests:e.inputRequests,...e.requestState!==void 0&&{requestState:e.requestState},...e._meta!==void 0&&{_meta:e._meta}}}var Pw=Lg((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(a){if(!a)throw new TypeError("argument string is required");var l=typeof a=="object"?s(a):a;if(typeof l!="string")throw new TypeError("argument string is required to be a string");var u=l.indexOf(";"),d=u!==-1?l.slice(0,u).trim():l.trim();if(!r.test(d))throw new TypeError("invalid media type");var h=new i(d.toLowerCase());if(u!==-1){var f,S,y;for(t.lastIndex=u;S=t.exec(l);){if(S.index!==u)throw new TypeError("invalid parameter format");u+=S[0].length,f=S[1].toLowerCase(),y=S[2],y.charCodeAt(0)===34&&(y=y.slice(1,-1),y.indexOf("\\")!==-1&&(y=y.replace(o,"$1"))),h.parameters[f]=y}if(u!==l.length)throw new TypeError("invalid parameter format")}return h}function s(a){var l;if(typeof a.getHeader=="function"?l=a.getHeader("content-type"):typeof a.headers=="object"&&(l=a.headers&&a.headers["content-type"]),typeof l!="string")throw new TypeError("content-type header is missing from object");return l}function i(a){this.parameters=Object.create(null),this.type=a}})),Tw=Zg(Pw(),1);function Fb(e){if(e)try{return Tw.parse(e).type}catch{let t=(e.split(";",1)[0]??"").trim().toLowerCase();return t===""||e.slice(t.length).includes(",")?void 0:t}}var Ew=10*1024*1024;function rb(e){return e?e instanceof Headers?Object.fromEntries(e.entries()):Array.isArray(e)?Object.fromEntries(e):{...e}:{}}function Hb(e=fetch,t){return t?async(o,r)=>e(o,{...t,...r,headers:r?.headers?{...rb(t.headers),...rb(r.headers)}:t.headers}):e}var kw=new Set([301,302,303,307,308]),$w=5;function Cw(e,t){return e.protocol===t.protocol&&e.host===t.host?!0:e.protocol==="http:"&&t.protocol==="https:"&&e.hostname===t.hostname&&!e.port&&!t.port}function Vb(e,t){let o=kw.has(t.status)?t.headers?.get("location"):void 0;if(o)try{return new URL(o,e)}catch{return}}var Jb=new WeakSet;function Bb(e){let t=(o,r)=>e(o,r);return Jb.add(t),t}function ja(e){return Jb.has(e)?e:async(t,o)=>{if(o?.redirect==="error"||o?.redirect==="manual")return e(t,o);let r=(o?.method??"GET").toUpperCase(),n=t;for(let s=0;;s++){let i=await e(n,{...o,redirect:"manual"}),a=Vb(n,i);if(!a||s===$w)return i;let l=new URL(n),u=r==="GET"||i.status===307||i.status===308,d=!(a.username||a.password)||a.username===l.username&&a.password===l.password;if(!u||!d||!Cw(l,a))return i;await i.text?.().catch(()=>{}),n=a}}}function Wb(e,t){if(t.type==="opaqueredirect")return"Redirect not followed: this runtime does not expose where it points";let o=Vb(t.url||e,t);if(o)return o.username=o.password=o.search=o.hash="",o.protocol==="http:"&&new URL(t.url||e).protocol==="https:"?(o.protocol="https:",`Redirect from https to plain http not followed; try ${o.href} as the endpoint`):`Redirect to ${o.href} not followed; use that URL as the endpoint if it is the intended server`}function La(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(!La(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(!La(e[s],t[s]))return!1;return!0}return e===t}function ft(e){return encodeURI(Iw(e))}function Iw(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}var Ow={prefixItems:!0,items:!0,allOf:!0,anyOf:!0,oneOf:!0},Nw={$defs:!0,definitions:!0,properties:!0,patternProperties:!0,dependentSchemas:!0},qw={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},Mw=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 pr(e,t=Object.create(null),o=Mw,r=""){if(e&&typeof e=="object"&&!Array.isArray(e)){let s=e.$id||e.id;if(s){let i=new URL(s,o.href);i.hash.length>1?t[i.href]=e:(i.hash="",r===""?o=i:pr(e,t,o))}}else if(e!==!0&&e!==!1)return t;let n=o.href+(r?"#"+r:"");if(t[n]!==void 0)throw new 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}),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(qw[s])continue;let i=`${r}/${ft(s)}`,a=e[s];if(Array.isArray(a)){if(Ow[s]){let l=a.length;for(let u=0;u<l;u++)pr(a[u],t,o,`${i}/${u}`)}}else if(Nw[s])for(let l in a)pr(a[l],t,o,`${i}/${ft(l)}`);else pr(a,t,o,i)}return t}var Aw=/^(\d\d\d\d)-(\d\d)-(\d\d)$/,jw=[0,31,28,31,30,31,30,31,31,30,31,30,31],Lw=/^(\d\d):(\d\d):(\d\d)(\.\d+)?(z|[+-]\d\d(?::?\d\d)?)?$/i,Uw=/^(?=.{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,Zw=/^(?:[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,Dw=/^(?:(?:[^\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,Fw=/^(?:(?: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,Hw=/^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i,Vw=/^(?:\/(?:[^~/]|~0|~1)*)*$/,Jw=/^#(?:\/(?:[a-z0-9_\-.!$&'()*+,;:=@]|%[0-9a-f]{2}|~0|~1)*)*$/i,Bw=/^(?:0|[1-9][0-9]*)(?:#|(?:\/(?:[^~/]|~0|~1)*)*)$/,Ww=e=>{if(e[0]==='"')return!1;let[t,o,...r]=e.split("@");return!t||!o||r.length!==0||t.length>64||o.length>253||t[0]==="."||t.endsWith(".")||t.includes("..")||!/^[a-z0-9.-]+$/i.test(o)||!/^[a-z0-9.!#$%&'*+/=?^_`{|}~-]+$/i.test(t)?!1:o.split(".").every(n=>/^[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?$/i.test(n))},Kw=/^(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)$/,Gw=/^((([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,Yw=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 Mt(e){return e.test.bind(e)}var Kb={date:Gb,time:Yb.bind(void 0,!1),"date-time":ex,duration:Yw,uri:rx,"uri-reference":Mt(Zw),"uri-template":Mt(Dw),url:Mt(Fw),email:Ww,hostname:Mt(Uw),ipv4:Mt(Kw),ipv6:Mt(Gw),regex:sx,uuid:Mt(Hw),"json-pointer":Mt(Vw),"json-pointer-uri-fragment":Mt(Jw),"relative-json-pointer":Mt(Bw)};function Xw(e){return e%4===0&&(e%100!==0||e%400===0)}function Gb(e){let t=e.match(Aw);if(!t)return!1;let o=+t[1],r=+t[2],n=+t[3];return r>=1&&r<=12&&n>=1&&n<=(r==2&&Xw(o)?29:jw[r])}function Yb(e,t){let o=t.match(Lw);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 Qw=/t|\s/i;function ex(e){let t=e.split(Qw);return t.length==2&&Gb(t[0])&&Yb(!0,t[1])}var tx=/\/|:/,ox=/^(?:[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 rx(e){return tx.test(e)&&ox.test(e)}var nx=/[^\\]\\Z/;function sx(e){if(nx.test(e))return!1;try{return new RegExp(e,"u"),!0}catch{return!1}}function ix(e){let t=0,o=e.length,r=0,n;for(;r<o;)t++,n=e.charCodeAt(r++),n>=55296&&n<=56319&&r<o&&(n=e.charCodeAt(r),(n&64512)==56320&&r++);return t}function fe(e,t,o="2019-09",r=pr(t),n=!0,s=null,i="#",a="#",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,d;switch(u){case"boolean":case"number":case"string":d=u;break;case"object":e===null?d="null":Array.isArray(e)?d="array":d="object";break;default:throw new Error(`Instances of "${u}" type are not supported.`)}let{$ref:h,$recursiveRef:f,$recursiveAnchor:S,type:y,const:w,enum:z,required:H,not:W,anyOf:N,allOf:D,oneOf:x,if:v,then:Z,else:oe,format:ee,properties:de,patternProperties:$e,additionalProperties:ie,unevaluatedProperties:ue,minProperties:ze,maxProperties:Ce,propertyNames:_t,dependentRequired:Ue,dependentSchemas:ot,dependencies:bt,prefixItems:Je,items:Ie,additionalItems:jt,unevaluatedItems:Lt,contains:yt,minContains:xe,maxContains:Oe,minItems:Ne,maxItems:ct,uniqueItems:Eo,minimum:Be,maximum:We,exclusiveMinimum:Ze,exclusiveMaximum:rt,multipleOf:nt,minLength:zt,maxLength:vt,pattern:no,__absolute_ref__:Rt,__absolute_recursive_ref__:ko}=t,I=[];if(S===!0&&s===null&&(s=t),f==="#"){let F=s===null?r[ko]:s,A=`${a}/$recursiveRef`,X=fe(e,s===null?t:s,o,r,n,F,i,A,l);X.valid||I.push({instanceLocation:i,keyword:"$recursiveRef",keywordLocation:A,error:"A subschema had errors."},...X.errors)}if(h!==void 0){let F=r[Rt||h];if(F===void 0){let O=`Unresolved $ref "${h}".`;throw Rt&&Rt!==h&&(O+=` Absolute URI "${Rt}".`),O+=`
65
+ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let i of e.seen.entries()){let a=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(a.cycle){s(i);continue}if(a.count>1&&e.reused==="ref"){s(i);continue}}}function _o(e,t){let o=e.seen.get(t);if(!o)throw new Error("Unprocessed schema. This is a bug in Zod.");let r=a=>{let l=e.seen.get(a);if(l.ref===null)return;let u=l.def??l.schema,d={...u},h=l.ref;if(l.ref=null,h){r(h);let S=e.seen.get(h),y=S.schema;if(y.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0")?(u.allOf=u.allOf??[],u.allOf.push(y)):Object.assign(u,y),Object.assign(u,d),a._zod.parent===h)for(let z in u)z==="$ref"||z==="allOf"||z in d||delete u[z];if(y.$ref&&S.def)for(let z in u)z==="$ref"||z==="allOf"||z in S.def&&JSON.stringify(u[z])===JSON.stringify(S.def[z])&&delete u[z]}let f=a._zod.parent;if(f&&f!==h){r(f);let S=e.seen.get(f);if(S?.schema.$ref&&(u.$ref=S.schema.$ref,S.def))for(let y in u)y==="$ref"||y==="allOf"||y in S.def&&JSON.stringify(u[y])===JSON.stringify(S.def[y])&&delete u[y]}e.override({zodSchema:a,jsonSchema:u,path:l.path??[]})};for(let a of[...e.seen.entries()].reverse())r(a[0]);let n={};if(e.target==="draft-2020-12"?n.$schema="https://json-schema.org/draft/2020-12/schema":e.target==="draft-07"?n.$schema="http://json-schema.org/draft-07/schema#":e.target==="draft-04"?n.$schema="http://json-schema.org/draft-04/schema#":e.target,e.external?.uri){let a=e.external.registry.get(t)?.id;if(!a)throw new Error("Schema is missing an `id` property");n.$id=e.external.uri(a)}Object.assign(n,o.def??o.schema);let s=e.metadataRegistry.get(t)?.id;s!==void 0&&n.id===s&&delete n.id;let i=e.external?.defs??{};for(let a of e.seen.entries()){let l=a[1];l.def&&l.defId&&(l.def.id===l.defId&&delete l.def.id,i[l.defId]=l.def)}e.external||Object.keys(i).length>0&&(e.target==="draft-2020-12"?n.$defs=i:n.definitions=i);try{let a=JSON.parse(JSON.stringify(n));return Object.defineProperty(a,"~standard",{value:{...t["~standard"],jsonSchema:{input:Kr(t,"input",e.processors),output:Kr(t,"output",e.processors)}},enumerable:!1,writable:!1}),a}catch{throw new Error("Error converting schema to JSON.")}}function Le(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 Le(r.element,o);if(r.type==="set")return Le(r.valueType,o);if(r.type==="lazy")return Le(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 Le(r.innerType,o);if(r.type==="intersection")return Le(r.left,o)||Le(r.right,o);if(r.type==="record"||r.type==="map")return Le(r.keyType,o)||Le(r.valueType,o);if(r.type==="pipe")return e._zod.traits.has("$ZodCodec")?!0:Le(r.in,o)||Le(r.out,o);if(r.type==="object"){for(let n in r.shape)if(Le(r.shape[n],o))return!0;return!1}if(r.type==="union"){for(let n of r.options)if(Le(n,o))return!0;return!1}if(r.type==="tuple"){for(let n of r.items)if(Le(n,o))return!0;return!!(r.rest&&Le(r.rest,o))}return!1}var Kh=(e,t={})=>o=>{let r=go({...o,processors:t});return ne(e,r),So(r,e),_o(r,e)},Kr=(e,t,o={})=>r=>{let{libraryOptions:n,target:s}=r??{},i=go({...n??{},target:s,io:t,processors:o});return ne(e,i),So(i,e),_o(i,e)};var Ov={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},Gh=(e,t,o,r)=>{let n=o;n.type="string";let{minimum:s,maximum:i,format:a,patterns:l,contentEncoding:u}=e._zod.bag;if(typeof s=="number"&&(n.minLength=s),typeof i=="number"&&(n.maxLength=i),a&&(n.format=Ov[a]??a,n.format===""&&delete n.format,a==="time"&&delete n.format),u&&(n.contentEncoding=u),l&&l.size>0){let d=[...l];d.length===1?n.pattern=d[0].source:d.length>1&&(n.allOf=[...d.map(h=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:h.source}))])}},Yh=(e,t,o,r)=>{let n=o,{minimum:s,maximum:i,format:a,multipleOf:l,exclusiveMaximum:u,exclusiveMinimum:d}=e._zod.bag;typeof a=="string"&&a.includes("int")?n.type="integer":n.type="number";let h=typeof d=="number"&&d>=(s??Number.NEGATIVE_INFINITY),f=typeof u=="number"&&u<=(i??Number.POSITIVE_INFINITY),S=t.target==="draft-04"||t.target==="openapi-3.0";h?S?(n.minimum=d,n.exclusiveMinimum=!0):n.exclusiveMinimum=d:typeof s=="number"&&(n.minimum=s),f?S?(n.maximum=u,n.exclusiveMaximum=!0):n.exclusiveMaximum=u:typeof i=="number"&&(n.maximum=i),typeof l=="number"&&(n.multipleOf=l)},Xh=(e,t,o,r)=>{o.type="boolean"},Qh=(e,t,o,r)=>{if(t.unrepresentable==="throw")throw new Error("BigInt cannot be represented in JSON Schema")},em=(e,t,o,r)=>{if(t.unrepresentable==="throw")throw new Error("Symbols cannot be represented in JSON Schema")},tm=(e,t,o,r)=>{t.target==="openapi-3.0"?(o.type="string",o.nullable=!0,o.enum=[null]):o.type="null"},om=(e,t,o,r)=>{if(t.unrepresentable==="throw")throw new Error("Undefined cannot be represented in JSON Schema")},rm=(e,t,o,r)=>{if(t.unrepresentable==="throw")throw new Error("Void cannot be represented in JSON Schema")},nm=(e,t,o,r)=>{o.not={}},sm=(e,t,o,r)=>{},im=(e,t,o,r)=>{},am=(e,t,o,r)=>{if(t.unrepresentable==="throw")throw new Error("Date cannot be represented in JSON Schema")},cm=(e,t,o,r)=>{let n=e._zod.def,s=vs(n.entries);s.every(i=>typeof i=="number")&&(o.type="number"),s.every(i=>typeof i=="string")&&(o.type="string"),o.enum=s},lm=(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 new Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof i=="bigint"){if(t.unrepresentable==="throw")throw new Error("BigInt literals cannot be represented in JSON Schema");s.push(Number(i))}else s.push(i);if(s.length!==0)if(s.length===1){let i=s[0];o.type=i===null?"null":typeof i,t.target==="draft-04"||t.target==="openapi-3.0"?o.enum=[i]:o.const=i}else s.every(i=>typeof i=="number")&&(o.type="number"),s.every(i=>typeof i=="string")&&(o.type="string"),s.every(i=>typeof i=="boolean")&&(o.type="boolean"),s.every(i=>i===null)&&(o.type="null"),o.enum=s},um=(e,t,o,r)=>{if(t.unrepresentable==="throw")throw new Error("NaN cannot be represented in JSON Schema")},dm=(e,t,o,r)=>{let n=o,s=e._zod.pattern;if(!s)throw new Error("Pattern not found in template literal");n.type="string",n.pattern=s.source},pm=(e,t,o,r)=>{let n=o,s={type:"string",format:"binary",contentEncoding:"binary"},{minimum:i,maximum:a,mime:l}=e._zod.bag;i!==void 0&&(s.minLength=i),a!==void 0&&(s.maxLength=a),l?l.length===1?(s.contentMediaType=l[0],Object.assign(n,s)):(Object.assign(n,s),n.anyOf=l.map(u=>({contentMediaType:u}))):Object.assign(n,s)},hm=(e,t,o,r)=>{o.type="boolean"},mm=(e,t,o,r)=>{if(t.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema")},fm=(e,t,o,r)=>{if(t.unrepresentable==="throw")throw new Error("Function types cannot be represented in JSON Schema")},gm=(e,t,o,r)=>{if(t.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema")},Sm=(e,t,o,r)=>{if(t.unrepresentable==="throw")throw new Error("Map cannot be represented in JSON Schema")},_m=(e,t,o,r)=>{if(t.unrepresentable==="throw")throw new Error("Set cannot be represented in JSON Schema")},bm=(e,t,o,r)=>{let n=o,s=e._zod.def,{minimum:i,maximum:a}=e._zod.bag;typeof i=="number"&&(n.minItems=i),typeof a=="number"&&(n.maxItems=a),n.type="array",n.items=ne(s.element,t,{...r,path:[...r.path,"items"]})},ym=(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]=ne(i[u],t,{...r,path:[...r.path,"properties",u]});let a=new Set(Object.keys(i)),l=new Set([...a].filter(u=>{let d=s.shape[u]._zod;return t.io==="input"?d.optin===void 0:d.optout===void 0}));l.size>0&&(n.required=Array.from(l)),s.catchall?._zod.def.type==="never"?n.additionalProperties=!1:s.catchall?s.catchall&&(n.additionalProperties=ne(s.catchall,t,{...r,path:[...r.path,"additionalProperties"]})):t.io==="output"&&(n.additionalProperties=!1)},dl=(e,t,o,r)=>{let n=e._zod.def,s=n.inclusive===!1,i=n.options.map((a,l)=>ne(a,t,{...r,path:[...r.path,s?"oneOf":"anyOf",l]}));s?o.oneOf=i:o.anyOf=i},zm=(e,t,o,r)=>{let n=e._zod.def,s=ne(n.left,t,{...r,path:[...r.path,"allOf",0]}),i=ne(n.right,t,{...r,path:[...r.path,"allOf",1]}),a=u=>"allOf"in u&&Object.keys(u).length===1,l=[...a(s)?s.allOf:[s],...a(i)?i.allOf:[i]];o.allOf=l},vm=(e,t,o,r)=>{let n=o,s=e._zod.def;n.type="array";let i=t.target==="draft-2020-12"?"prefixItems":"items",a=t.target==="draft-2020-12"||t.target==="openapi-3.0"?"items":"additionalItems",l=s.items.map((f,S)=>ne(f,t,{...r,path:[...r.path,i,S]})),u=s.rest?ne(s.rest,t,{...r,path:[...r.path,a,...t.target==="openapi-3.0"?[s.items.length]:[]]}):null;t.target==="draft-2020-12"?(n.prefixItems=l,u&&(n.items=u)):t.target==="openapi-3.0"?(n.items={anyOf:l},u&&n.items.anyOf.push(u),n.minItems=l.length,u||(n.maxItems=l.length)):(n.items=l,u&&(n.additionalItems=u));let{minimum:d,maximum:h}=e._zod.bag;typeof d=="number"&&(n.minItems=d),typeof h=="number"&&(n.maxItems=h)},Rm=(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 d=ne(s.valueType,t,{...r,path:[...r.path,"patternProperties","*"]});n.patternProperties={};for(let h of l)n.patternProperties[h.source]=d}else(t.target==="draft-07"||t.target==="draft-2020-12")&&(n.propertyNames=ne(s.keyType,t,{...r,path:[...r.path,"propertyNames"]})),n.additionalProperties=ne(s.valueType,t,{...r,path:[...r.path,"additionalProperties"]});let u=i._zod.values;if(u){let d=[...u].filter(h=>typeof h=="string"||typeof h=="number");d.length>0&&(n.required=d)}},wm=(e,t,o,r)=>{let n=e._zod.def,s=ne(n.innerType,t,r),i=t.seen.get(e);t.target==="openapi-3.0"?(i.ref=n.innerType,o.nullable=!0):o.anyOf=[s,{type:"null"}]},xm=(e,t,o,r)=>{let n=e._zod.def;ne(n.innerType,t,r);let s=t.seen.get(e);s.ref=n.innerType},Pm=(e,t,o,r)=>{let n=e._zod.def;ne(n.innerType,t,r);let s=t.seen.get(e);s.ref=n.innerType,o.default=JSON.parse(JSON.stringify(n.defaultValue))},Tm=(e,t,o,r)=>{let n=e._zod.def;ne(n.innerType,t,r);let s=t.seen.get(e);s.ref=n.innerType,t.io==="input"&&(o._prefault=JSON.parse(JSON.stringify(n.defaultValue)))},Em=(e,t,o,r)=>{let n=e._zod.def;ne(n.innerType,t,r);let s=t.seen.get(e);s.ref=n.innerType;let i;try{i=n.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}o.default=i},km=(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;ne(i,t,r);let a=t.seen.get(e);a.ref=i},$m=(e,t,o,r)=>{let n=e._zod.def;ne(n.innerType,t,r);let s=t.seen.get(e);s.ref=n.innerType,o.readOnly=!0},Cm=(e,t,o,r)=>{let n=e._zod.def;ne(n.innerType,t,r);let s=t.seen.get(e);s.ref=n.innerType},pl=(e,t,o,r)=>{let n=e._zod.def;ne(n.innerType,t,r);let s=t.seen.get(e);s.ref=n.innerType},Im=(e,t,o,r)=>{let n=e._zod.innerType;ne(n,t,r);let s=t.seen.get(e);s.ref=n},ul={string:Gh,number:Yh,boolean:Xh,bigint:Qh,symbol:em,null:tm,undefined:om,void:rm,never:nm,any:sm,unknown:im,date:am,enum:cm,literal:lm,nan:um,template_literal:dm,file:pm,success:hm,custom:mm,function:fm,transform:gm,map:Sm,set:_m,array:bm,object:ym,union:dl,intersection:zm,tuple:vm,record:Rm,nullable:wm,nonoptional:xm,default:Pm,prefault:Tm,catch:Em,pipe:km,readonly:$m,promise:Cm,optional:pl,lazy:Im};function Jo(e,t){if("_idmap"in e){let r=e,n=go({...t,processors:ul}),s={};for(let l of r._idmap.entries()){let[u,d]=l;ne(d,n)}let i={},a={registry:r,uri:t?.uri,defs:s};n.external=a;for(let l of r._idmap.entries()){let[u,d]=l;So(n,d),i[u]=_o(n,d)}if(Object.keys(s).length>0){let l=n.target==="draft-2020-12"?"$defs":"definitions";i.__shared={[l]:s}}return{schemas:i}}let o=go({...t,processors:ul});return ne(e,o),So(o,e),_o(o,e)}var hl=class{get metadataRegistry(){return this.ctx.metadataRegistry}get target(){return this.ctx.target}get unrepresentable(){return this.ctx.unrepresentable}get override(){return this.ctx.override}get io(){return this.ctx.io}get counter(){return this.ctx.counter}set counter(t){this.ctx.counter=t}get seen(){return this.ctx.seen}constructor(t){let o=t?.target??"draft-2020-12";o==="draft-4"&&(o="draft-04"),o==="draft-7"&&(o="draft-07"),this.ctx=go({processors:ul,target:o,...t?.metadata&&{metadata:t.metadata},...t?.unrepresentable&&{unrepresentable:t.unrepresentable},...t?.override&&{override:t.override},...t?.io&&{io:t.io}})}process(t,o={path:[],schemaPath:[]}){return ne(t,this.ctx,o)}emit(t,o){o&&(o.cycles&&(this.ctx.cycles=o.cycles),o.reused&&(this.ctx.reused=o.reused),o.external&&(this.ctx.external=o.external)),So(this.ctx,t);let r=_o(this.ctx,t),{"~standard":n,...s}=r;return s}};var xS={};var Ls={};Ut(Ls,{ZodAny:()=>Xm,ZodArray:()=>of,ZodBase64:()=>ql,ZodBase64URL:()=>Ml,ZodBigInt:()=>rn,ZodBigIntFormat:()=>Ll,ZodBoolean:()=>on,ZodCIDRv4:()=>Ol,ZodCIDRv6:()=>Nl,ZodCUID:()=>Pl,ZodCUID2:()=>Tl,ZodCatch:()=>Rf,ZodCodec:()=>Ks,ZodCustom:()=>Gs,ZodCustomStringFormat:()=>en,ZodDate:()=>Vs,ZodDefault:()=>Sf,ZodDiscriminatedUnion:()=>nf,ZodE164:()=>Al,ZodEmail:()=>vl,ZodEmoji:()=>wl,ZodEnum:()=>Yr,ZodExactOptional:()=>mf,ZodFile:()=>pf,ZodFunction:()=>If,ZodGUID:()=>Zs,ZodIPv4:()=>Cl,ZodIPv6:()=>Il,ZodIntersection:()=>sf,ZodJWT:()=>jl,ZodKSUID:()=>$l,ZodLazy:()=>$f,ZodLiteral:()=>df,ZodMAC:()=>Wm,ZodMap:()=>lf,ZodNaN:()=>xf,ZodNanoID:()=>xl,ZodNever:()=>ef,ZodNonOptional:()=>Hl,ZodNull:()=>Ym,ZodNullable:()=>gf,ZodNumber:()=>tn,ZodNumberFormat:()=>Bo,ZodObject:()=>Js,ZodOptional:()=>Fl,ZodPipe:()=>Ws,ZodPrefault:()=>bf,ZodPreprocess:()=>Pf,ZodPromise:()=>Cf,ZodReadonly:()=>Tf,ZodRecord:()=>Gr,ZodSet:()=>uf,ZodString:()=>Xr,ZodStringFormat:()=>ce,ZodSuccess:()=>vf,ZodSymbol:()=>Km,ZodTemplateLiteral:()=>kf,ZodTransform:()=>hf,ZodTuple:()=>af,ZodType:()=>Q,ZodULID:()=>El,ZodURL:()=>Hs,ZodUUID:()=>kt,ZodUndefined:()=>Gm,ZodUnion:()=>Bs,ZodUnknown:()=>Qm,ZodVoid:()=>tf,ZodXID:()=>kl,ZodXor:()=>rf,_ZodString:()=>zl,_default:()=>_f,_function:()=>T_,any:()=>Ul,array:()=>_,base64:()=>JS,base64url:()=>BS,bigint:()=>n_,boolean:()=>k,catch:()=>wf,check:()=>E_,cidrv4:()=>HS,cidrv6:()=>VS,codec:()=>R_,cuid:()=>MS,cuid2:()=>AS,custom:()=>k_,date:()=>u_,describe:()=>$_,discriminatedUnion:()=>bo,e164:()=>WS,email:()=>Rl,emoji:()=>NS,enum:()=>K,exactOptional:()=>ff,file:()=>b_,float32:()=>e_,float64:()=>t_,function:()=>T_,guid:()=>ES,hash:()=>QS,hex:()=>XS,hostname:()=>YS,httpUrl:()=>OS,instanceof:()=>I_,int:()=>bl,int32:()=>o_,int64:()=>s_,intersection:()=>pt,invertCodec:()=>w_,ipv4:()=>ZS,ipv6:()=>FS,json:()=>N_,jwt:()=>KS,keyof:()=>d_,ksuid:()=>US,lazy:()=>yo,literal:()=>b,looseObject:()=>U,looseRecord:()=>f_,mac:()=>DS,map:()=>g_,meta:()=>C_,nan:()=>v_,nanoid:()=>qS,nativeEnum:()=>__,never:()=>Zl,nonoptional:()=>zf,null:()=>$t,nullable:()=>Ds,nullish:()=>y_,number:()=>R,object:()=>m,optional:()=>L,partialRecord:()=>m_,pipe:()=>yl,prefault:()=>yf,preprocess:()=>Ht,promise:()=>P_,readonly:()=>Ef,record:()=>T,refine:()=>Of,set:()=>S_,strictObject:()=>p_,string:()=>c,stringFormat:()=>GS,stringbool:()=>O_,success:()=>z_,superRefine:()=>Nf,symbol:()=>a_,templateLiteral:()=>x_,transform:()=>Dl,tuple:()=>cf,uint32:()=>r_,uint64:()=>i_,ulid:()=>jS,undefined:()=>c_,union:()=>C,unknown:()=>j,url:()=>Qr,uuid:()=>kS,uuidv4:()=>$S,uuidv6:()=>CS,uuidv7:()=>IS,void:()=>l_,xid:()=>LS,xor:()=>h_});var ml={};Ut(ml,{endsWith:()=>Zr,gt:()=>Tt,gte:()=>je,includes:()=>Lr,length:()=>Vo,lowercase:()=>Ar,lt:()=>Pt,lte:()=>Xe,maxLength:()=>Ho,maxSize:()=>fo,mime:()=>Dr,minLength:()=>Dt,minSize:()=>Et,multipleOf:()=>mo,negative:()=>il,nonnegative:()=>cl,nonpositive:()=>al,normalize:()=>Fr,overwrite:()=>dt,positive:()=>sl,property:()=>ll,regex:()=>Mr,size:()=>Fo,slugify:()=>Br,startsWith:()=>Ur,toLowerCase:()=>Vr,toUpperCase:()=>Jr,trim:()=>Hr,uppercase:()=>jr});var Qe={};Ut(Qe,{ZodISODate:()=>gl,ZodISODateTime:()=>fl,ZodISODuration:()=>_l,ZodISOTime:()=>Sl,date:()=>Nm,datetime:()=>Om,duration:()=>Mm,time:()=>qm});var fl=g("ZodISODateTime",(e,t)=>{up.init(e,t),ce.init(e,t)});function Om(e){return mh(fl,e)}var gl=g("ZodISODate",(e,t)=>{dp.init(e,t),ce.init(e,t)});function Nm(e){return fh(gl,e)}var Sl=g("ZodISOTime",(e,t)=>{pp.init(e,t),ce.init(e,t)});function qm(e){return gh(Sl,e)}var _l=g("ZodISODuration",(e,t)=>{hp.init(e,t),ce.init(e,t)});function Mm(e){return Sh(_l,e)}var PS=(e,t)=>{Ts.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:o=>ks(e,o)},flatten:{value:o=>Es(e,o)},addIssue:{value:o=>{e.issues.push(o),e.message=JSON.stringify(e.issues,Er,2)}},addIssues:{value:o=>{e.issues.push(...o),e.message=JSON.stringify(e.issues,Er,2)}},isEmpty:{get(){return e.issues.length===0}}})},qv=g("ZodError",PS),Ve=g("ZodError",PS,{Parent:Error});var Am=Cr(Ve),jm=Ir(Ve),Us=Or(Ve),Lm=Nr(Ve),Um=fc(Ve),Zm=gc(Ve),Dm=Sc(Ve),Fm=_c(Ve),Hm=bc(Ve),Vm=yc(Ve),Jm=zc(Ve),Bm=vc(Ve);var TS=new WeakMap;function Fs(e,t,o){let r=Object.getPrototypeOf(e),n=TS.get(r);if(n||(n=new Set,TS.set(r,n)),!n.has(t)){n.add(t);for(let s in o){let i=o[s];Object.defineProperty(r,s,{configurable:!0,enumerable:!1,get(){let a=i.bind(this);return Object.defineProperty(this,s,{configurable:!0,writable:!0,enumerable:!0,value:a}),a},set(a){Object.defineProperty(this,s,{configurable:!0,writable:!0,enumerable:!0,value:a})}})}}}var Q=g("ZodType",(e,t)=>(Y.init(e,t),Object.assign(e["~standard"],{jsonSchema:{input:Kr(e,"input"),output:Kr(e,"output")}}),e.toJSONSchema=Kh(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.parse=(o,r)=>Am(e,o,r,{callee:e.parse}),e.safeParse=(o,r)=>Us(e,o,r),e.parseAsync=async(o,r)=>jm(e,o,r,{callee:e.parseAsync}),e.safeParseAsync=async(o,r)=>Lm(e,o,r),e.spa=e.safeParseAsync,e.encode=(o,r)=>Um(e,o,r),e.decode=(o,r)=>Zm(e,o,r),e.encodeAsync=async(o,r)=>Dm(e,o,r),e.decodeAsync=async(o,r)=>Fm(e,o,r),e.safeEncode=(o,r)=>Hm(e,o,r),e.safeDecode=(o,r)=>Vm(e,o,r),e.safeEncodeAsync=async(o,r)=>Jm(e,o,r),e.safeDecodeAsync=async(o,r)=>Bm(e,o,r),Fs(e,"ZodType",{check(...o){let r=this.def;return this.clone(G.mergeDefs(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 Me(this,o,r)},brand(){return this},register(o,r){return o.add(this,r),this},refine(o,r){return this.check(Of(o,r))},superRefine(o,r){return this.check(Nf(o,r))},overwrite(o){return this.check(dt(o))},optional(){return L(this)},exactOptional(){return ff(this)},nullable(){return Ds(this)},nullish(){return L(Ds(this))},nonoptional(o){return zf(this,o)},array(){return _(this)},or(o){return C([this,o])},and(o){return pt(this,o)},transform(o){return yl(this,Dl(o))},default(o){return _f(this,o)},prefault(o){return yf(this,o)},catch(o){return wf(this,o)},pipe(o){return yl(this,o)},readonly(){return Ef(this)},describe(o){let r=this.clone();return ve.add(r,{description:o}),r},meta(...o){if(o.length===0)return ve.get(this);let r=this.clone();return ve.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 ve.get(e)?.description},configurable:!0}),e)),zl=g("_ZodString",(e,t)=>{Do.init(e,t),Q.init(e,t),e._zod.processJSONSchema=(r,n,s)=>Gh(e,r,n,s);let o=e._zod.bag;e.format=o.format??null,e.minLength=o.minimum??null,e.maxLength=o.maximum??null,Fs(e,"_ZodString",{regex(...r){return this.check(Mr(...r))},includes(...r){return this.check(Lr(...r))},startsWith(...r){return this.check(Ur(...r))},endsWith(...r){return this.check(Zr(...r))},min(...r){return this.check(Dt(...r))},max(...r){return this.check(Ho(...r))},length(...r){return this.check(Vo(...r))},nonempty(...r){return this.check(Dt(1,...r))},lowercase(r){return this.check(Ar(r))},uppercase(r){return this.check(jr(r))},trim(){return this.check(Hr())},normalize(...r){return this.check(Fr(...r))},toLowerCase(){return this.check(Vr())},toUpperCase(){return this.check(Jr())},slugify(){return this.check(Br())}})}),Xr=g("ZodString",(e,t)=>{Do.init(e,t),zl.init(e,t),e.email=o=>e.check(Lc(vl,o)),e.url=o=>e.check(js(Hs,o)),e.jwt=o=>e.check(nl(jl,o)),e.emoji=o=>e.check(Hc(wl,o)),e.guid=o=>e.check(As(Zs,o)),e.uuid=o=>e.check(Uc(kt,o)),e.uuidv4=o=>e.check(Zc(kt,o)),e.uuidv6=o=>e.check(Dc(kt,o)),e.uuidv7=o=>e.check(Fc(kt,o)),e.nanoid=o=>e.check(Vc(xl,o)),e.guid=o=>e.check(As(Zs,o)),e.cuid=o=>e.check(Jc(Pl,o)),e.cuid2=o=>e.check(Bc(Tl,o)),e.ulid=o=>e.check(Wc(El,o)),e.base64=o=>e.check(tl(ql,o)),e.base64url=o=>e.check(ol(Ml,o)),e.xid=o=>e.check(Kc(kl,o)),e.ksuid=o=>e.check(Gc($l,o)),e.ipv4=o=>e.check(Yc(Cl,o)),e.ipv6=o=>e.check(Xc(Il,o)),e.cidrv4=o=>e.check(Qc(Ol,o)),e.cidrv6=o=>e.check(el(Nl,o)),e.e164=o=>e.check(rl(Al,o)),e.datetime=o=>e.check(Om(o)),e.date=o=>e.check(Nm(o)),e.time=o=>e.check(qm(o)),e.duration=o=>e.check(Mm(o))});function c(e){return uh(Xr,e)}var ce=g("ZodStringFormat",(e,t)=>{ae.init(e,t),zl.init(e,t)}),vl=g("ZodEmail",(e,t)=>{tp.init(e,t),ce.init(e,t)});function Rl(e){return Lc(vl,e)}var Zs=g("ZodGUID",(e,t)=>{Qd.init(e,t),ce.init(e,t)});function ES(e){return As(Zs,e)}var kt=g("ZodUUID",(e,t)=>{ep.init(e,t),ce.init(e,t)});function kS(e){return Uc(kt,e)}function $S(e){return Zc(kt,e)}function CS(e){return Dc(kt,e)}function IS(e){return Fc(kt,e)}var Hs=g("ZodURL",(e,t)=>{op.init(e,t),ce.init(e,t)});function Qr(e){return js(Hs,e)}function OS(e){return js(Hs,{protocol:Ye.httpProtocol,hostname:Ye.domain,...G.normalizeParams(e)})}var wl=g("ZodEmoji",(e,t)=>{rp.init(e,t),ce.init(e,t)});function NS(e){return Hc(wl,e)}var xl=g("ZodNanoID",(e,t)=>{np.init(e,t),ce.init(e,t)});function qS(e){return Vc(xl,e)}var Pl=g("ZodCUID",(e,t)=>{sp.init(e,t),ce.init(e,t)});function MS(e){return Jc(Pl,e)}var Tl=g("ZodCUID2",(e,t)=>{ip.init(e,t),ce.init(e,t)});function AS(e){return Bc(Tl,e)}var El=g("ZodULID",(e,t)=>{ap.init(e,t),ce.init(e,t)});function jS(e){return Wc(El,e)}var kl=g("ZodXID",(e,t)=>{cp.init(e,t),ce.init(e,t)});function LS(e){return Kc(kl,e)}var $l=g("ZodKSUID",(e,t)=>{lp.init(e,t),ce.init(e,t)});function US(e){return Gc($l,e)}var Cl=g("ZodIPv4",(e,t)=>{mp.init(e,t),ce.init(e,t)});function ZS(e){return Yc(Cl,e)}var Wm=g("ZodMAC",(e,t)=>{gp.init(e,t),ce.init(e,t)});function DS(e){return ph(Wm,e)}var Il=g("ZodIPv6",(e,t)=>{fp.init(e,t),ce.init(e,t)});function FS(e){return Xc(Il,e)}var Ol=g("ZodCIDRv4",(e,t)=>{Sp.init(e,t),ce.init(e,t)});function HS(e){return Qc(Ol,e)}var Nl=g("ZodCIDRv6",(e,t)=>{_p.init(e,t),ce.init(e,t)});function VS(e){return el(Nl,e)}var ql=g("ZodBase64",(e,t)=>{yp.init(e,t),ce.init(e,t)});function JS(e){return tl(ql,e)}var Ml=g("ZodBase64URL",(e,t)=>{zp.init(e,t),ce.init(e,t)});function BS(e){return ol(Ml,e)}var Al=g("ZodE164",(e,t)=>{vp.init(e,t),ce.init(e,t)});function WS(e){return rl(Al,e)}var jl=g("ZodJWT",(e,t)=>{Rp.init(e,t),ce.init(e,t)});function KS(e){return nl(jl,e)}var en=g("ZodCustomStringFormat",(e,t)=>{wp.init(e,t),ce.init(e,t)});function GS(e,t,o={}){return Wr(en,e,t,o)}function YS(e){return Wr(en,"hostname",Ye.hostname,e)}function XS(e){return Wr(en,"hex",Ye.hex,e)}function QS(e,t){let o=t?.enc??"hex",r=`${e}_${o}`,n=Ye[r];if(!n)throw new Error(`Unrecognized hash format: ${r}`);return Wr(en,r,n,t)}var tn=g("ZodNumber",(e,t)=>{Cc.init(e,t),Q.init(e,t),e._zod.processJSONSchema=(r,n,s)=>Yh(e,r,n,s),Fs(e,"ZodNumber",{gt(r,n){return this.check(Tt(r,n))},gte(r,n){return this.check(je(r,n))},min(r,n){return this.check(je(r,n))},lt(r,n){return this.check(Pt(r,n))},lte(r,n){return this.check(Xe(r,n))},max(r,n){return this.check(Xe(r,n))},int(r){return this.check(bl(r))},safe(r){return this.check(bl(r))},positive(r){return this.check(Tt(0,r))},nonnegative(r){return this.check(je(0,r))},negative(r){return this.check(Pt(0,r))},nonpositive(r){return this.check(Xe(0,r))},multipleOf(r,n){return this.check(mo(r,n))},step(r,n){return this.check(mo(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??.5),e.isFinite=!0,e.format=o.format??null});function R(e){return _h(tn,e)}var Bo=g("ZodNumberFormat",(e,t)=>{xp.init(e,t),tn.init(e,t)});function bl(e){return yh(Bo,e)}function e_(e){return zh(Bo,e)}function t_(e){return vh(Bo,e)}function o_(e){return Rh(Bo,e)}function r_(e){return wh(Bo,e)}var on=g("ZodBoolean",(e,t)=>{Os.init(e,t),Q.init(e,t),e._zod.processJSONSchema=(o,r,n)=>Xh(e,o,r,n)});function k(e){return xh(on,e)}var rn=g("ZodBigInt",(e,t)=>{Ic.init(e,t),Q.init(e,t),e._zod.processJSONSchema=(r,n,s)=>Qh(e,r,n,s),e.gte=(r,n)=>e.check(je(r,n)),e.min=(r,n)=>e.check(je(r,n)),e.gt=(r,n)=>e.check(Tt(r,n)),e.gte=(r,n)=>e.check(je(r,n)),e.min=(r,n)=>e.check(je(r,n)),e.lt=(r,n)=>e.check(Pt(r,n)),e.lte=(r,n)=>e.check(Xe(r,n)),e.max=(r,n)=>e.check(Xe(r,n)),e.positive=r=>e.check(Tt(BigInt(0),r)),e.negative=r=>e.check(Pt(BigInt(0),r)),e.nonpositive=r=>e.check(Xe(BigInt(0),r)),e.nonnegative=r=>e.check(je(BigInt(0),r)),e.multipleOf=(r,n)=>e.check(mo(r,n));let o=e._zod.bag;e.minValue=o.minimum??null,e.maxValue=o.maximum??null,e.format=o.format??null});function n_(e){return Th(rn,e)}var Ll=g("ZodBigIntFormat",(e,t)=>{Pp.init(e,t),rn.init(e,t)});function s_(e){return kh(Ll,e)}function i_(e){return $h(Ll,e)}var Km=g("ZodSymbol",(e,t)=>{Tp.init(e,t),Q.init(e,t),e._zod.processJSONSchema=(o,r,n)=>em(e,o,r,n)});function a_(e){return Ch(Km,e)}var Gm=g("ZodUndefined",(e,t)=>{Ep.init(e,t),Q.init(e,t),e._zod.processJSONSchema=(o,r,n)=>om(e,o,r,n)});function c_(e){return Ih(Gm,e)}var Ym=g("ZodNull",(e,t)=>{kp.init(e,t),Q.init(e,t),e._zod.processJSONSchema=(o,r,n)=>tm(e,o,r,n)});function $t(e){return Oh(Ym,e)}var Xm=g("ZodAny",(e,t)=>{$p.init(e,t),Q.init(e,t),e._zod.processJSONSchema=(o,r,n)=>sm(e,o,r,n)});function Ul(){return Nh(Xm)}var Qm=g("ZodUnknown",(e,t)=>{Cp.init(e,t),Q.init(e,t),e._zod.processJSONSchema=(o,r,n)=>im(e,o,r,n)});function j(){return qh(Qm)}var ef=g("ZodNever",(e,t)=>{Ip.init(e,t),Q.init(e,t),e._zod.processJSONSchema=(o,r,n)=>nm(e,o,r,n)});function Zl(e){return Mh(ef,e)}var tf=g("ZodVoid",(e,t)=>{Op.init(e,t),Q.init(e,t),e._zod.processJSONSchema=(o,r,n)=>rm(e,o,r,n)});function l_(e){return Ah(tf,e)}var Vs=g("ZodDate",(e,t)=>{Np.init(e,t),Q.init(e,t),e._zod.processJSONSchema=(r,n,s)=>am(e,r,n,s),e.min=(r,n)=>e.check(je(r,n)),e.max=(r,n)=>e.check(Xe(r,n));let o=e._zod.bag;e.minDate=o.minimum?new Date(o.minimum):null,e.maxDate=o.maximum?new Date(o.maximum):null});function u_(e){return jh(Vs,e)}var of=g("ZodArray",(e,t)=>{qp.init(e,t),Q.init(e,t),e._zod.processJSONSchema=(o,r,n)=>bm(e,o,r,n),e.element=t.element,Fs(e,"ZodArray",{min(o,r){return this.check(Dt(o,r))},nonempty(o){return this.check(Dt(1,o))},max(o,r){return this.check(Ho(o,r))},length(o,r){return this.check(Vo(o,r))},unwrap(){return this.element}})});function _(e,t){return Zh(of,e,t)}function d_(e){let t=e._zod.def.shape;return K(Object.keys(t))}var Js=g("ZodObject",(e,t)=>{Mp.init(e,t),Q.init(e,t),e._zod.processJSONSchema=(o,r,n)=>ym(e,o,r,n),G.defineLazy(e,"shape",()=>t.shape),Fs(e,"ZodObject",{keyof(){return K(Object.keys(this._zod.def.shape))},catchall(o){return this.clone({...this._zod.def,catchall:o})},passthrough(){return this.clone({...this._zod.def,catchall:j()})},loose(){return this.clone({...this._zod.def,catchall:j()})},strict(){return this.clone({...this._zod.def,catchall:Zl()})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(o){return G.extend(this,o)},safeExtend(o){return G.safeExtend(this,o)},merge(o){return G.merge(this,o)},pick(o){return G.pick(this,o)},omit(o){return G.omit(this,o)},partial(...o){return G.partial(Fl,this,o[0])},required(...o){return G.required(Hl,this,o[0])}})});function m(e,t){let o={type:"object",shape:e??{},...G.normalizeParams(t)};return new Js(o)}function p_(e,t){return new Js({type:"object",shape:e,catchall:Zl(),...G.normalizeParams(t)})}function U(e,t){return new Js({type:"object",shape:e,catchall:j(),...G.normalizeParams(t)})}var Bs=g("ZodUnion",(e,t)=>{Ns.init(e,t),Q.init(e,t),e._zod.processJSONSchema=(o,r,n)=>dl(e,o,r,n),e.options=t.options});function C(e,t){return new Bs({type:"union",options:e,...G.normalizeParams(t)})}var rf=g("ZodXor",(e,t)=>{Bs.init(e,t),Ap.init(e,t),e._zod.processJSONSchema=(o,r,n)=>dl(e,o,r,n),e.options=t.options});function h_(e,t){return new rf({type:"union",options:e,inclusive:!1,...G.normalizeParams(t)})}var nf=g("ZodDiscriminatedUnion",(e,t)=>{Bs.init(e,t),jp.init(e,t)});function bo(e,t,o){return new nf({type:"union",options:t,discriminator:e,...G.normalizeParams(o)})}var sf=g("ZodIntersection",(e,t)=>{Lp.init(e,t),Q.init(e,t),e._zod.processJSONSchema=(o,r,n)=>zm(e,o,r,n)});function pt(e,t){return new sf({type:"intersection",left:e,right:t})}var af=g("ZodTuple",(e,t)=>{Oc.init(e,t),Q.init(e,t),e._zod.processJSONSchema=(o,r,n)=>vm(e,o,r,n),e.rest=o=>e.clone({...e._zod.def,rest:o})});function cf(e,t,o){let r=t instanceof Y,n=r?o:t,s=r?t:null;return new af({type:"tuple",items:e,rest:s,...G.normalizeParams(n)})}var Gr=g("ZodRecord",(e,t)=>{Up.init(e,t),Q.init(e,t),e._zod.processJSONSchema=(o,r,n)=>Rm(e,o,r,n),e.keyType=t.keyType,e.valueType=t.valueType});function T(e,t,o){return!t||!t._zod?new Gr({type:"record",keyType:c(),valueType:e,...G.normalizeParams(t)}):new Gr({type:"record",keyType:e,valueType:t,...G.normalizeParams(o)})}function m_(e,t,o){let r=Me(e);return r._zod.values=void 0,new Gr({type:"record",keyType:r,valueType:t,...G.normalizeParams(o)})}function f_(e,t,o){return new Gr({type:"record",keyType:e,valueType:t,mode:"loose",...G.normalizeParams(o)})}var lf=g("ZodMap",(e,t)=>{Zp.init(e,t),Q.init(e,t),e._zod.processJSONSchema=(o,r,n)=>Sm(e,o,r,n),e.keyType=t.keyType,e.valueType=t.valueType,e.min=(...o)=>e.check(Et(...o)),e.nonempty=o=>e.check(Et(1,o)),e.max=(...o)=>e.check(fo(...o)),e.size=(...o)=>e.check(Fo(...o))});function g_(e,t,o){return new lf({type:"map",keyType:e,valueType:t,...G.normalizeParams(o)})}var uf=g("ZodSet",(e,t)=>{Dp.init(e,t),Q.init(e,t),e._zod.processJSONSchema=(o,r,n)=>_m(e,o,r,n),e.min=(...o)=>e.check(Et(...o)),e.nonempty=o=>e.check(Et(1,o)),e.max=(...o)=>e.check(fo(...o)),e.size=(...o)=>e.check(Fo(...o))});function S_(e,t){return new uf({type:"set",valueType:e,...G.normalizeParams(t)})}var Yr=g("ZodEnum",(e,t)=>{Fp.init(e,t),Q.init(e,t),e._zod.processJSONSchema=(r,n,s)=>cm(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 new Error(`Key ${i} not found in enum`);return new Yr({...t,checks:[],...G.normalizeParams(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 new Error(`Key ${i} not found in enum`);return new Yr({...t,checks:[],...G.normalizeParams(n),entries:s})}});function K(e,t){let o=Array.isArray(e)?Object.fromEntries(e.map(r=>[r,r])):e;return new Yr({type:"enum",entries:o,...G.normalizeParams(t)})}function __(e,t){return new Yr({type:"enum",entries:e,...G.normalizeParams(t)})}var df=g("ZodLiteral",(e,t)=>{Hp.init(e,t),Q.init(e,t),e._zod.processJSONSchema=(o,r,n)=>lm(e,o,r,n),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function b(e,t){return new df({type:"literal",values:Array.isArray(e)?e:[e],...G.normalizeParams(t)})}var pf=g("ZodFile",(e,t)=>{Vp.init(e,t),Q.init(e,t),e._zod.processJSONSchema=(o,r,n)=>pm(e,o,r,n),e.min=(o,r)=>e.check(Et(o,r)),e.max=(o,r)=>e.check(fo(o,r)),e.mime=(o,r)=>e.check(Dr(Array.isArray(o)?o:[o],r))});function b_(e){return Dh(pf,e)}var hf=g("ZodTransform",(e,t)=>{Jp.init(e,t),Q.init(e,t),e._zod.processJSONSchema=(o,r,n)=>gm(e,o,r,n),e._zod.parse=(o,r)=>{if(r.direction==="backward")throw new co(e.constructor.name);o.addIssue=s=>{if(typeof s=="string")o.issues.push(G.issue(s,o.value,t));else{let i=s;i.fatal&&(i.continue=!1),i.code??(i.code="custom"),i.input??(i.input=o.value),i.inst??(i.inst=e),o.issues.push(G.issue(i))}};let n=t.transform(o.value,o);return n instanceof Promise?n.then(s=>(o.value=s,o.fallback=!0,o)):(o.value=n,o.fallback=!0,o)}});function Dl(e){return new hf({type:"transform",transform:e})}var Fl=g("ZodOptional",(e,t)=>{Nc.init(e,t),Q.init(e,t),e._zod.processJSONSchema=(o,r,n)=>pl(e,o,r,n),e.unwrap=()=>e._zod.def.innerType});function L(e){return new Fl({type:"optional",innerType:e})}var mf=g("ZodExactOptional",(e,t)=>{Bp.init(e,t),Q.init(e,t),e._zod.processJSONSchema=(o,r,n)=>pl(e,o,r,n),e.unwrap=()=>e._zod.def.innerType});function ff(e){return new mf({type:"optional",innerType:e})}var gf=g("ZodNullable",(e,t)=>{Wp.init(e,t),Q.init(e,t),e._zod.processJSONSchema=(o,r,n)=>wm(e,o,r,n),e.unwrap=()=>e._zod.def.innerType});function Ds(e){return new gf({type:"nullable",innerType:e})}function y_(e){return L(Ds(e))}var Sf=g("ZodDefault",(e,t)=>{Kp.init(e,t),Q.init(e,t),e._zod.processJSONSchema=(o,r,n)=>Pm(e,o,r,n),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function _f(e,t){return new Sf({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():G.shallowClone(t)}})}var bf=g("ZodPrefault",(e,t)=>{Gp.init(e,t),Q.init(e,t),e._zod.processJSONSchema=(o,r,n)=>Tm(e,o,r,n),e.unwrap=()=>e._zod.def.innerType});function yf(e,t){return new bf({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():G.shallowClone(t)}})}var Hl=g("ZodNonOptional",(e,t)=>{Yp.init(e,t),Q.init(e,t),e._zod.processJSONSchema=(o,r,n)=>xm(e,o,r,n),e.unwrap=()=>e._zod.def.innerType});function zf(e,t){return new Hl({type:"nonoptional",innerType:e,...G.normalizeParams(t)})}var vf=g("ZodSuccess",(e,t)=>{Xp.init(e,t),Q.init(e,t),e._zod.processJSONSchema=(o,r,n)=>hm(e,o,r,n),e.unwrap=()=>e._zod.def.innerType});function z_(e){return new vf({type:"success",innerType:e})}var Rf=g("ZodCatch",(e,t)=>{Qp.init(e,t),Q.init(e,t),e._zod.processJSONSchema=(o,r,n)=>Em(e,o,r,n),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function wf(e,t){return new Rf({type:"catch",innerType:e,catchValue:typeof t=="function"?t:()=>t})}var xf=g("ZodNaN",(e,t)=>{eh.init(e,t),Q.init(e,t),e._zod.processJSONSchema=(o,r,n)=>um(e,o,r,n)});function v_(e){return Uh(xf,e)}var Ws=g("ZodPipe",(e,t)=>{qc.init(e,t),Q.init(e,t),e._zod.processJSONSchema=(o,r,n)=>km(e,o,r,n),e.in=t.in,e.out=t.out});function yl(e,t){return new Ws({type:"pipe",in:e,out:t})}var Ks=g("ZodCodec",(e,t)=>{Ws.init(e,t),qs.init(e,t)});function R_(e,t,o){return new Ks({type:"pipe",in:e,out:t,transform:o.decode,reverseTransform:o.encode})}function w_(e){let t=e._zod.def;return new Ks({type:"pipe",in:t.out,out:t.in,transform:t.reverseTransform,reverseTransform:t.transform})}var Pf=g("ZodPreprocess",(e,t)=>{Ws.init(e,t),th.init(e,t)}),Tf=g("ZodReadonly",(e,t)=>{oh.init(e,t),Q.init(e,t),e._zod.processJSONSchema=(o,r,n)=>$m(e,o,r,n),e.unwrap=()=>e._zod.def.innerType});function Ef(e){return new Tf({type:"readonly",innerType:e})}var kf=g("ZodTemplateLiteral",(e,t)=>{rh.init(e,t),Q.init(e,t),e._zod.processJSONSchema=(o,r,n)=>dm(e,o,r,n)});function x_(e,t){return new kf({type:"template_literal",parts:e,...G.normalizeParams(t)})}var $f=g("ZodLazy",(e,t)=>{ih.init(e,t),Q.init(e,t),e._zod.processJSONSchema=(o,r,n)=>Im(e,o,r,n),e.unwrap=()=>e._zod.def.getter()});function yo(e){return new $f({type:"lazy",getter:e})}var Cf=g("ZodPromise",(e,t)=>{sh.init(e,t),Q.init(e,t),e._zod.processJSONSchema=(o,r,n)=>Cm(e,o,r,n),e.unwrap=()=>e._zod.def.innerType});function P_(e){return new Cf({type:"promise",innerType:e})}var If=g("ZodFunction",(e,t)=>{nh.init(e,t),Q.init(e,t),e._zod.processJSONSchema=(o,r,n)=>fm(e,o,r,n)});function T_(e){return new If({type:"function",input:Array.isArray(e?.input)?cf(e?.input):e?.input??_(j()),output:e?.output??j()})}var Gs=g("ZodCustom",(e,t)=>{ah.init(e,t),Q.init(e,t),e._zod.processJSONSchema=(o,r,n)=>mm(e,o,r,n)});function E_(e){let t=new le({check:"custom"});return t._zod.check=e,t}function k_(e,t){return Fh(Gs,e??(()=>!0),t)}function Of(e,t={}){return Hh(Gs,e,t)}function Nf(e,t){return Vh(e,t)}var $_=Jh,C_=Bh;function I_(e,t={}){let o=new Gs({type:"custom",check:"custom",fn:r=>r instanceof e,abort:!0,...G.normalizeParams(t)});return o._zod.bag.Class=e,o._zod.check=r=>{r.value instanceof e||r.issues.push({code:"invalid_type",expected:e.name,input:r.value,inst:o,path:[...o._zod.def.path??[]]})},o}var O_=(...e)=>Wh({Codec:Ks,Boolean:on,String:Xr},...e);function N_(e){let t=yo(()=>C([c(e),R(),k(),$t(),_(t),T(c(),t)]));return t}function Ht(e,t){return new Pf({type:"pipe",in:Dl(e),out:t})}var Mf={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"};function Av(e){ge({customError:e})}function jv(){return ge().customError}var qf;qf||(qf={});var $={...Ls,...ml,iso:Qe},Lv=new Set(["$schema","$ref","$defs","definitions","$id","id","$comment","$anchor","$vocabulary","$dynamicRef","$dynamicAnchor","type","enum","const","anyOf","oneOf","allOf","not","properties","required","additionalProperties","patternProperties","propertyNames","minProperties","maxProperties","items","prefixItems","additionalItems","minItems","maxItems","uniqueItems","contains","minContains","maxContains","minLength","maxLength","pattern","format","minimum","maximum","exclusiveMinimum","exclusiveMaximum","multipleOf","description","default","contentEncoding","contentMediaType","contentSchema","unevaluatedItems","unevaluatedProperties","if","then","else","dependentSchemas","dependentRequired","nullable","readOnly"]);function Uv(e,t){let o=e.$schema;return o==="https://json-schema.org/draft/2020-12/schema"?"draft-2020-12":o==="http://json-schema.org/draft-07/schema#"?"draft-7":o==="http://json-schema.org/draft-04/schema#"?"draft-4":t??"draft-2020-12"}function Zv(e,t){if(!e.startsWith("#"))throw new Error("External $ref is not supported, only local refs (#/...) are allowed");let o=e.slice(1).split("/").filter(Boolean);if(o.length===0)return t.rootSchema;let r=t.version==="draft-2020-12"?"$defs":"definitions";if(o[0]===r){let n=o[1];if(!n||!t.defs[n])throw new Error(`Reference not found: ${e}`);return t.defs[n]}throw new Error(`Reference not found: ${e}`)}function q_(e,t){if(e.not!==void 0){if(typeof e.not=="object"&&Object.keys(e.not).length===0)return $.never();throw new Error("not is not supported in Zod (except { not: {} } for never)")}if(e.unevaluatedItems!==void 0)throw new Error("unevaluatedItems is not supported");if(e.unevaluatedProperties!==void 0)throw new Error("unevaluatedProperties is not supported");if(e.if!==void 0||e.then!==void 0||e.else!==void 0)throw new Error("Conditional schemas (if/then/else) are not supported");if(e.dependentSchemas!==void 0||e.dependentRequired!==void 0)throw new Error("dependentSchemas and dependentRequired are not supported");if(e.$ref){let n=e.$ref;if(t.refs.has(n))return t.refs.get(n);if(t.processing.has(n))return $.lazy(()=>{if(!t.refs.has(n))throw new Error(`Circular reference not resolved: ${n}`);return t.refs.get(n)});t.processing.add(n);let s=Zv(n,t),i=Ee(s,t);return t.refs.set(n,i),t.processing.delete(n),i}if(e.enum!==void 0){let n=e.enum;if(t.version==="openapi-3.0"&&e.nullable===!0&&n.length===1&&n[0]===null)return $.null();if(n.length===0)return $.never();if(n.length===1)return $.literal(n[0]);if(n.every(i=>typeof i=="string"))return $.enum(n);let s=n.map(i=>$.literal(i));return s.length<2?s[0]:$.union([s[0],s[1],...s.slice(2)])}if(e.const!==void 0)return $.literal(e.const);let o=e.type;if(Array.isArray(o)){let n=o.map(s=>{let i={...e,type:s};return q_(i,t)});return n.length===0?$.never():n.length===1?n[0]:$.union(n)}if(!o)return $.any();let r;switch(o){case"string":{let n=$.string();if(e.format){let s=e.format;s==="email"?n=n.check($.email()):s==="uri"||s==="uri-reference"?n=n.check($.url()):s==="uuid"||s==="guid"?n=n.check($.uuid()):s==="date-time"?n=n.check($.iso.datetime()):s==="date"?n=n.check($.iso.date()):s==="time"?n=n.check($.iso.time()):s==="duration"?n=n.check($.iso.duration()):s==="ipv4"?n=n.check($.ipv4()):s==="ipv6"?n=n.check($.ipv6()):s==="mac"?n=n.check($.mac()):s==="cidr"?n=n.check($.cidrv4()):s==="cidr-v6"?n=n.check($.cidrv6()):s==="base64"?n=n.check($.base64()):s==="base64url"?n=n.check($.base64url()):s==="e164"?n=n.check($.e164()):s==="jwt"?n=n.check($.jwt()):s==="emoji"?n=n.check($.emoji()):s==="nanoid"?n=n.check($.nanoid()):s==="cuid"?n=n.check($.cuid()):s==="cuid2"?n=n.check($.cuid2()):s==="ulid"?n=n.check($.ulid()):s==="xid"?n=n.check($.xid()):s==="ksuid"&&(n=n.check($.ksuid()))}typeof e.minLength=="number"&&(n=n.min(e.minLength)),typeof e.maxLength=="number"&&(n=n.max(e.maxLength)),e.pattern&&(n=n.regex(new RegExp(e.pattern))),r=n;break}case"number":case"integer":{let n=o==="integer"?$.number().int():$.number();typeof e.minimum=="number"&&(n=n.min(e.minimum)),typeof e.maximum=="number"&&(n=n.max(e.maximum)),typeof e.exclusiveMinimum=="number"?n=n.gt(e.exclusiveMinimum):e.exclusiveMinimum===!0&&typeof e.minimum=="number"&&(n=n.gt(e.minimum)),typeof e.exclusiveMaximum=="number"?n=n.lt(e.exclusiveMaximum):e.exclusiveMaximum===!0&&typeof e.maximum=="number"&&(n=n.lt(e.maximum)),typeof e.multipleOf=="number"&&(n=n.multipleOf(e.multipleOf)),r=n;break}case"boolean":{r=$.boolean();break}case"null":{r=$.null();break}case"object":{let n={},s=e.properties||{},i=new Set(e.required||[]);for(let[l,u]of Object.entries(s)){let d=Ee(u,t);n[l]=i.has(l)?d:d.optional()}if(e.propertyNames){let l=Ee(e.propertyNames,t),u=e.additionalProperties&&typeof e.additionalProperties=="object"?Ee(e.additionalProperties,t):$.any();if(Object.keys(n).length===0){r=$.record(l,u);break}let d=$.object(n).passthrough(),h=$.looseRecord(l,u);r=$.intersection(d,h);break}if(e.patternProperties){let l=e.patternProperties,u=Object.keys(l),d=[];for(let f of u){let S=Ee(l[f],t),y=$.string().regex(new RegExp(f));d.push($.looseRecord(y,S))}let h=[];if(Object.keys(n).length>0&&h.push($.object(n).passthrough()),h.push(...d),h.length===0)r=$.object({}).passthrough();else if(h.length===1)r=h[0];else{let f=$.intersection(h[0],h[1]);for(let S=2;S<h.length;S++)f=$.intersection(f,h[S]);r=f}break}let a=$.object(n);e.additionalProperties===!1?r=a.strict():typeof e.additionalProperties=="object"?r=a.catchall(Ee(e.additionalProperties,t)):r=a.passthrough();break}case"array":{let n=e.prefixItems,s=e.items;if(n&&Array.isArray(n)){let i=n.map(l=>Ee(l,t)),a=s&&typeof s=="object"&&!Array.isArray(s)?Ee(s,t):void 0;a?r=$.tuple(i).rest(a):r=$.tuple(i),typeof e.minItems=="number"&&(r=r.check($.minLength(e.minItems))),typeof e.maxItems=="number"&&(r=r.check($.maxLength(e.maxItems)))}else if(Array.isArray(s)){let i=s.map(l=>Ee(l,t)),a=e.additionalItems&&typeof e.additionalItems=="object"?Ee(e.additionalItems,t):void 0;a?r=$.tuple(i).rest(a):r=$.tuple(i),typeof e.minItems=="number"&&(r=r.check($.minLength(e.minItems))),typeof e.maxItems=="number"&&(r=r.check($.maxLength(e.maxItems)))}else if(s!==void 0){let i=Ee(s,t),a=$.array(i);typeof e.minItems=="number"&&(a=a.min(e.minItems)),typeof e.maxItems=="number"&&(a=a.max(e.maxItems)),r=a}else r=$.array($.any());break}default:throw new Error(`Unsupported type: ${o}`)}return r}function Ee(e,t){if(typeof e=="boolean")return e?$.any():$.never();let o=q_(e,t),r=e.type||e.enum!==void 0||e.const!==void 0;if(e.anyOf&&Array.isArray(e.anyOf)){let a=e.anyOf.map(u=>Ee(u,t)),l=$.union(a);o=r?$.intersection(o,l):l}if(e.oneOf&&Array.isArray(e.oneOf)){let a=e.oneOf.map(u=>Ee(u,t)),l=$.xor(a);o=r?$.intersection(o,l):l}if(e.allOf&&Array.isArray(e.allOf))if(e.allOf.length===0)o=r?o:$.any();else{let a=r?o:Ee(e.allOf[0],t),l=r?0:1;for(let u=l;u<e.allOf.length;u++)a=$.intersection(a,Ee(e.allOf[u],t));o=a}e.nullable===!0&&t.version==="openapi-3.0"&&(o=$.nullable(o)),e.readOnly===!0&&(o=$.readonly(o)),e.default!==void 0&&(o=o.default(e.default));let n={},s=["$id","id","$comment","$anchor","$vocabulary","$dynamicRef","$dynamicAnchor"];for(let a of s)a in e&&(n[a]=e[a]);let i=["contentEncoding","contentMediaType","contentSchema"];for(let a of i)a in e&&(n[a]=e[a]);for(let a of Object.keys(e))Lv.has(a)||(n[a]=e[a]);return Object.keys(n).length>0&&t.registry.add(o,n),e.description&&(o=o.describe(e.description)),o}function M_(e,t){if(typeof e=="boolean")return e?$.any():$.never();let o;try{o=JSON.parse(JSON.stringify(e))}catch{throw new Error("fromJSONSchema input is not valid JSON (possibly cyclic); use $defs/$ref for recursive schemas")}let r=Uv(o,t?.defaultTarget),n=o.$defs||o.definitions||{},s={version:r,defs:n,refs:new Map,processing:new Set,rootSchema:o,registry:t?.registry??ve};return Ee(o,s)}var Ys={};Ut(Ys,{bigint:()=>Vv,boolean:()=>Hv,date:()=>Jv,number:()=>Fv,string:()=>Dv});function Dv(e){return dh(Xr,e)}function Fv(e){return bh(tn,e)}function Hv(e){return Ph(on,e)}function Vv(e){return Eh(rn,e)}function Jv(e){return Lh(Vs,e)}ge(Mc());var nn="2025-11-25";var Vl=[nn,"2025-06-18","2025-03-26","2024-11-05","2024-10-07"],Jl="io.modelcontextprotocol/related-task",Jt="io.modelcontextprotocol/protocolVersion",sn="io.modelcontextprotocol/clientInfo",Bt="io.modelcontextprotocol/serverInfo",Wo="io.modelcontextprotocol/clientCapabilities",Xs="io.modelcontextprotocol/subscriptionId",an="io.modelcontextprotocol/logLevel";var Ko="2.0";var Vt=yo(()=>C([c(),R(),k(),$t(),T(c(),Vt),_(Vt)])),pe=T(c(),Vt),Bl=_(Vt),cn=C([c(),R().int()]),ln=c(),Qs=m({ttl:R().optional()}),ei=m({taskId:c()}),un=U({progressToken:cn.optional(),[Jl]:ei.optional()}),ye=m({_meta:un.optional()}),vo=ye.extend({task:Qs.optional()}),he=m({method:c(),params:ye.loose().optional()}),ke=m({_meta:un.optional()}),Re=m({method:c(),params:ke.loose().optional()}),dn=U({get[Bt](){return It.optional().catch(void 0)}}),me=U({_meta:dn.optional()}),ht=C([c(),R().int()]),pn=m({jsonrpc:b(Ko),id:ht,...he.shape}).strict(),hn=m({jsonrpc:b(Ko),...Re.shape}).strict(),Go=m({jsonrpc:b(Ko),id:ht,result:me}).strict(),Yo=m({jsonrpc:b(Ko),id:ht.optional(),error:m({code:R().int(),message:c(),data:j().optional()})}).strict(),mt=C([pn,hn,Go,Yo]),Wl=C([Go,Yo]),Ro=me.strict(),ti=ke.extend({requestId:ht.optional(),reason:c().optional()}),mn=Re.extend({method:b("notifications/cancelled"),params:ti}),oi=m({src:c(),mimeType:c().optional(),sizes:_(c()).optional(),theme:K(["light","dark"]).optional()}),Wt=m({icons:_(oi).optional()}),Ct=m({name:c(),title:c().optional()}),It=Ct.extend({...Ct.shape,...Wt.shape,version:c(),websiteUrl:c().optional(),description:c().optional()}),Wv=pt(m({applyDefaults:k().optional()}),pe),Kv=Ht(e=>e&&typeof e=="object"&&!Array.isArray(e)&&Object.keys(e).length===0?{form:{}}:e,pt(m({form:Wv.optional(),url:pe.optional()}),pe.optional())),Kl=U({list:pe.optional(),cancel:pe.optional(),requests:U({sampling:U({createMessage:pe.optional()}).optional(),elicitation:U({create:pe.optional()}).optional()}).optional()}),Gl=U({list:pe.optional(),cancel:pe.optional(),requests:U({tools:U({call:pe.optional()}).optional()}).optional()}),ri=m({experimental:T(c(),pe).optional(),sampling:m({context:pe.optional(),tools:pe.optional()}).optional(),elicitation:Kv.optional(),roots:m({listChanged:k().optional()}).optional(),tasks:Kl.optional(),extensions:T(c(),pe).optional()}),ni=ye.extend({protocolVersion:c(),capabilities:ri,clientInfo:It}),fn=he.extend({method:b("initialize"),params:ni}),gn=m({experimental:T(c(),pe).optional(),logging:pe.optional(),completions:pe.optional(),prompts:m({listChanged:k().optional()}).optional(),resources:m({subscribe:k().optional(),listChanged:k().optional()}).optional(),tools:m({listChanged:k().optional()}).optional(),tasks:Gl.optional(),extensions:T(c(),pe).optional()}),si=me.extend({protocolVersion:c(),capabilities:gn,serverInfo:It,instructions:c().optional()}),Sn=Re.extend({method:b("notifications/initialized"),params:ke.optional()}),ii=he.extend({method:b("server/discover"),params:ye.optional()}),wo=me.extend({supportedVersions:_(c()),capabilities:gn,instructions:c().optional()}),_n=he.extend({method:b("ping"),params:ye.optional()}),ai=m({progress:R(),total:L(R()),message:L(c())}),ci=m({...ke.shape,...ai.shape,progressToken:cn}),bn=Re.extend({method:b("notifications/progress"),params:ci}),li=ye.extend({cursor:ln.optional()}),Kt=he.extend({params:li.optional()}),Gt=me.extend({nextCursor:ln.optional()}),yn=m({uri:c(),mimeType:L(c()),_meta:T(c(),j()).optional()}),zn=yn.extend({text:c()}),jf=c().refine(e=>{try{return atob(e),!0}catch{return!1}},{message:"Invalid Base64 string"}),vn=yn.extend({blob:jf}),Yt=K(["user","assistant"]),Ot=m({audience:_(Yt).optional(),priority:R().min(0).max(1).optional(),lastModified:Qe.datetime({offset:!0}).optional()}),Rn=m({...Ct.shape,...Wt.shape,uri:c(),description:L(c()),mimeType:L(c()),size:L(R()),annotations:Ot.optional(),_meta:L(U({}))}),ui=m({...Ct.shape,...Wt.shape,uriTemplate:c(),description:L(c()),mimeType:L(c()),annotations:Ot.optional(),_meta:L(U({}))}),di=Kt.extend({method:b("resources/list")}),pi=Gt.extend({resources:_(Rn)}),hi=Kt.extend({method:b("resources/templates/list")}),mi=Gt.extend({resourceTemplates:_(ui)}),Xo=ye.extend({uri:c()}),fi=Xo,gi=he.extend({method:b("resources/read"),params:fi}),Si=me.extend({contents:_(C([zn,vn]))}),_i=Re.extend({method:b("notifications/resources/list_changed"),params:ke.optional()}),bi=Xo,yi=he.extend({method:b("resources/subscribe"),params:bi}),zi=Xo,vi=he.extend({method:b("resources/unsubscribe"),params:zi}),wn=m({toolsListChanged:k().optional(),promptsListChanged:k().optional(),resourcesListChanged:k().optional(),resourceSubscriptions:_(c()).optional()}),Ri=ye.extend({notifications:wn}),wi=he.extend({method:b("subscriptions/listen"),params:Ri}),xi=ke.extend({notifications:wn}),Pi=Re.extend({method:b("notifications/subscriptions/acknowledged"),params:xi}),Ti=dn.extend({[Xs]:ht}),Ei=me.extend({_meta:Ti}),ki=ke.extend({uri:c()}),$i=Re.extend({method:b("notifications/resources/updated"),params:ki}),Ci=m({name:c(),description:L(c()),required:L(k())}),Ii=m({...Ct.shape,...Wt.shape,description:L(c()),arguments:L(_(Ci)),_meta:L(U({}))}),Oi=Kt.extend({method:b("prompts/list")}),Ni=Gt.extend({prompts:_(Ii)}),qi=ye.extend({name:c(),arguments:T(c(),c()).optional()}),Mi=he.extend({method:b("prompts/get"),params:qi}),Qo=m({type:b("text"),text:c(),annotations:Ot.optional(),_meta:T(c(),j()).optional()}),er=m({type:b("image"),data:jf,mimeType:c(),annotations:Ot.optional(),_meta:T(c(),j()).optional()}),tr=m({type:b("audio"),data:jf,mimeType:c(),annotations:Ot.optional(),_meta:T(c(),j()).optional()}),Ai=m({type:b("tool_use"),name:c(),id:c(),input:T(c(),j()),_meta:T(c(),j()).optional()}),or=m({type:b("resource"),resource:C([zn,vn]),annotations:Ot.optional(),_meta:T(c(),j()).optional()}),rr=Rn.extend({type:b("resource_link")}),Nt=C([Qo,er,tr,rr,or]),ji=m({role:Yt,content:Nt}),Li=me.extend({description:c().optional(),messages:_(ji)}),Ui=Re.extend({method:b("notifications/prompts/list_changed"),params:ke.optional()}),Zi=m({title:c().optional(),readOnlyHint:k().optional(),destructiveHint:k().optional(),idempotentHint:k().optional(),openWorldHint:k().optional()}),Di=m({taskSupport:K(["required","optional","forbidden"]).optional()}),xo=m({...Ct.shape,...Wt.shape,description:c().optional(),inputSchema:m({type:b("object"),properties:T(c(),Vt).optional(),required:_(c()).optional()}).catchall(j()),outputSchema:U({$schema:c().optional()}).optional(),annotations:Zi.optional(),execution:Di.optional(),_meta:T(c(),j()).optional()}),Fi=Kt.extend({method:b("tools/list")}),Hi=Gt.extend({tools:_(xo)}),Po=me.extend({content:_(Nt).default([]),structuredContent:j().optional(),isError:k().optional()}),Yl=Po.or(me.extend({toolResult:j()})),Vi=vo.extend({name:c(),arguments:T(c(),j()).optional()}),Ji=he.extend({method:b("tools/call"),params:Vi}),Bi=Re.extend({method:b("notifications/tools/list_changed"),params:ke.optional()}),Wi=m({autoRefresh:k().default(!0),debounceMs:R().int().nonnegative().default(300)}),xn=K(["debug","info","notice","warning","error","critical","alert","emergency"]),Ki=ye.extend({level:xn}),Gi=he.extend({method:b("logging/setLevel"),params:Ki}),Yi=ke.extend({level:xn,logger:c().optional(),data:j()}),nr=Re.extend({method:b("notifications/message"),params:Yi}),Xi=m({name:c().optional()}),Qi=m({hints:_(Xi).optional(),costPriority:R().min(0).max(1).optional(),speedPriority:R().min(0).max(1).optional(),intelligencePriority:R().min(0).max(1).optional()}),ea=m({mode:K(["auto","required","none"]).optional()}),ta=m({type:b("tool_result"),toolUseId:c().describe("The unique identifier for the corresponding tool call."),content:_(Nt),structuredContent:j().optional(),isError:k().optional(),_meta:T(c(),j()).optional()}),oa=bo("type",[Qo,er,tr]),zo=bo("type",[Qo,er,tr,Ai,ta]),ra=m({role:Yt,content:C([zo,_(zo)]),_meta:T(c(),j()).optional()}),na=vo.extend({messages:_(ra),modelPreferences:Qi.optional(),systemPrompt:c().optional(),includeContext:K(["none","thisServer","allServers"]).optional(),temperature:R().optional(),maxTokens:R().int(),stopSequences:_(c()).optional(),metadata:pe.optional(),tools:_(xo).optional(),toolChoice:ea.optional()}),sa=he.extend({method:b("sampling/createMessage"),params:na}),ia=me.extend({model:c(),stopReason:L(K(["endTurn","stopSequence","maxTokens"]).or(c())),role:Yt,content:oa}),aa=me.extend({model:c(),stopReason:L(K(["endTurn","stopSequence","maxTokens","toolUse"]).or(c())),role:Yt,content:C([zo,_(zo)])}),Pn=m({type:b("boolean"),title:c().optional(),description:c().optional(),default:k().optional()}),sr=m({type:b("string"),title:c().optional(),description:c().optional(),minLength:R().optional(),maxLength:R().optional(),format:K(["email","uri","date","date-time"]).optional(),default:c().optional()}),ir=m({type:K(["number","integer"]),title:c().optional(),description:c().optional(),minimum:R().optional(),maximum:R().optional(),default:R().optional()}),Tn=m({type:b("string"),title:c().optional(),description:c().optional(),enum:_(c()),default:c().optional()}),En=m({type:b("string"),title:c().optional(),description:c().optional(),oneOf:_(m({const:c(),title:c()})),default:c().optional()}),kn=m({type:b("string"),title:c().optional(),description:c().optional(),enum:_(c()),enumNames:_(c()).optional(),default:c().optional()}),ca=C([Tn,En]),$n=m({type:b("array"),title:c().optional(),description:c().optional(),minItems:R().optional(),maxItems:R().optional(),items:m({type:b("string"),enum:_(c())}),default:_(c()).optional()}),Cn=m({type:b("array"),title:c().optional(),description:c().optional(),minItems:R().optional(),maxItems:R().optional(),items:m({anyOf:_(m({const:c(),title:c()}))}),default:_(c()).optional()}),la=C([$n,Cn]),ua=C([kn,ca,la]),In=C([ua,Pn,sr,ir]),ar=vo.extend({mode:b("form").optional(),message:c(),requestedSchema:m({type:b("object"),properties:T(c(),In),required:_(c()).optional()}).catchall(j())}),da=vo.extend({mode:b("url"),message:c(),elicitationId:c(),url:c().url()}),pa=C([ar,da]),ha=he.extend({method:b("elicitation/create"),params:pa}),ma=ke.extend({elicitationId:c()}),fa=Re.extend({method:b("notifications/elicitation/complete"),params:ma}),ga=me.extend({action:K(["accept","decline","cancel"]),content:Ht(e=>e===null?void 0:e,T(c(),C([c(),R(),k(),_(c())])).optional())}),Sa=m({type:b("ref/resource"),uri:c()}),_a=m({type:b("ref/prompt"),name:c()}),ba=ye.extend({ref:C([_a,Sa]),argument:m({name:c(),value:c()}),context:m({arguments:T(c(),c()).optional()}).optional()}),ya=he.extend({method:b("completion/complete"),params:ba}),za=me.extend({completion:U({values:_(c()).max(100),total:L(R().int()),hasMore:L(k())})}),va=m({uri:c().startsWith("file://"),name:c().optional(),_meta:T(c(),j()).optional()}),Ra=he.extend({method:b("roots/list"),params:ye.optional()}),wa=me.extend({roots:_(va)}),xa=Re.extend({method:b("notifications/roots/list_changed"),params:ke.optional()}),Xl=U({ttl:R().optional(),pollInterval:R().optional()}),Pa=K(["working","input_required","completed","failed","cancelled"]),Xt=m({taskId:c(),status:Pa,ttl:C([R(),$t()]),createdAt:c(),lastUpdatedAt:c(),pollInterval:L(R()),statusMessage:L(c())}),Ql=me.extend({task:Xt}),Ta=ke.merge(Xt),eu=Re.extend({method:b("notifications/tasks/status"),params:Ta}),tu=he.extend({method:b("tasks/get"),params:ye.extend({taskId:c()})}),ou=me.merge(Xt),ru=he.extend({method:b("tasks/result"),params:ye.extend({taskId:c()})}),nu=me.loose(),su=Kt.extend({method:b("tasks/list")}),iu=Gt.extend({tasks:_(Xt)}),au=he.extend({method:b("tasks/cancel"),params:ye.extend({taskId:c()})}),cu=me.merge(Xt),lu=C([_n,fn,ii,ya,Gi,Mi,Oi,di,hi,gi,yi,vi,wi,Ji,Fi]),uu=C([mn,bn,Sn,xa]),du=C([Ro,ia,aa,ga,wa]),pu=C([_n,sa,ha,Ra]),hu=C([mn,bn,nr,$i,_i,Bi,Ui,Pi,fa]),mu=C([Ro,si,wo,za,Li,Ni,pi,mi,Si,Po,Hi,Ei]),be=Qr().superRefine((e,t)=>{if(!URL.canParse(e))return t.addIssue({code:Mf.custom,message:"URL must be parseable",fatal:!0}),ys}).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"}),On=U({resource:c().url(),authorization_servers:_(be).optional(),jwks_uri:c().url().optional(),scopes_supported:_(c()).optional(),bearer_methods_supported:_(c()).optional(),resource_signing_alg_values_supported:_(c()).optional(),resource_name:c().optional(),resource_documentation:c().optional(),resource_policy_uri:c().url().optional(),resource_tos_uri:c().url().optional(),tls_client_certificate_bound_access_tokens:k().optional(),authorization_details_types_supported:_(c()).optional(),dpop_signing_alg_values_supported:_(c()).optional(),dpop_bound_access_tokens_required:k().optional()}),cr=U({issuer:c(),authorization_endpoint:be,token_endpoint:be,registration_endpoint:be.optional(),scopes_supported:_(c()).optional(),response_types_supported:_(c()),response_modes_supported:_(c()).optional(),grant_types_supported:_(c()).optional(),token_endpoint_auth_methods_supported:_(c()).optional(),token_endpoint_auth_signing_alg_values_supported:_(c()).optional(),service_documentation:be.optional(),revocation_endpoint:be.optional(),revocation_endpoint_auth_methods_supported:_(c()).optional(),revocation_endpoint_auth_signing_alg_values_supported:_(c()).optional(),introspection_endpoint:c().optional(),introspection_endpoint_auth_methods_supported:_(c()).optional(),introspection_endpoint_auth_signing_alg_values_supported:_(c()).optional(),code_challenge_methods_supported:_(c()).optional(),client_id_metadata_document_supported:k().optional(),authorization_response_iss_parameter_supported:k().optional().catch(void 0),dpop_signing_alg_values_supported:_(c()).optional()}),Ea=U({issuer:c(),authorization_endpoint:be,token_endpoint:be,userinfo_endpoint:be.optional(),jwks_uri:be,registration_endpoint:be.optional(),scopes_supported:_(c()).optional(),response_types_supported:_(c()),response_modes_supported:_(c()).optional(),grant_types_supported:_(c()).optional(),acr_values_supported:_(c()).optional(),subject_types_supported:_(c()),id_token_signing_alg_values_supported:_(c()),id_token_encryption_alg_values_supported:_(c()).optional(),id_token_encryption_enc_values_supported:_(c()).optional(),userinfo_signing_alg_values_supported:_(c()).optional(),userinfo_encryption_alg_values_supported:_(c()).optional(),userinfo_encryption_enc_values_supported:_(c()).optional(),request_object_signing_alg_values_supported:_(c()).optional(),request_object_encryption_alg_values_supported:_(c()).optional(),request_object_encryption_enc_values_supported:_(c()).optional(),token_endpoint_auth_methods_supported:_(c()).optional(),token_endpoint_auth_signing_alg_values_supported:_(c()).optional(),display_values_supported:_(c()).optional(),claim_types_supported:_(c()).optional(),claims_supported:_(c()).optional(),service_documentation:c().optional(),claims_locales_supported:_(c()).optional(),ui_locales_supported:_(c()).optional(),claims_parameter_supported:k().optional(),request_parameter_supported:k().optional(),request_uri_parameter_supported:k().optional(),require_request_uri_registration:k().optional(),op_policy_uri:be.optional(),op_tos_uri:be.optional(),client_id_metadata_document_supported:k().optional(),authorization_response_iss_parameter_supported:k().optional().catch(void 0)}),Nn=m({...Ea.shape,...cr.pick({code_challenge_methods_supported:!0}).shape}),qn=m({access_token:c(),id_token:c().optional(),token_type:c(),expires_in:Ys.number().optional(),scope:c().optional(),refresh_token:c().optional(),issuer:c().optional().catch(void 0)}).strip(),ka=m({issued_token_type:b("urn:ietf:params:oauth:token-type:id-jag"),access_token:c(),token_type:c().optional(),expires_in:R().optional(),scope:c().optional()}).strip(),Mn=m({error:c(),error_description:c().optional(),error_uri:c().optional()}),Af=be.optional().or(b("").transform(()=>{})),$a=m({redirect_uris:_(be),token_endpoint_auth_method:c().optional(),grant_types:_(c()).optional(),response_types:_(c()).optional(),application_type:c().optional(),client_name:c().optional(),client_uri:be.optional(),logo_uri:Af,scope:c().optional(),contacts:_(c()).optional(),tos_uri:Af,policy_uri:c().optional(),jwks_uri:be.optional(),jwks:Ul().optional(),software_id:c().optional(),software_version:c().optional(),software_statement:c().optional()}).strip(),Ca=m({client_id:c(),client_secret:c().optional(),client_id_issued_at:R().optional(),client_secret_expires_at:R().optional(),issuer:c().optional().catch(void 0)}).strip(),An=$a.merge(Ca),fu=m({error:c(),error_description:c().optional()}).strip(),gu=m({token:c(),token_type_hint:c().optional()}).strip();var Ff=Symbol.for("mcp.sdk.errorBrands");function lr(e,t){let o=new Set,r=t;for(;typeof r=="function";){let n=r.mcpBrand;Object.prototype.hasOwnProperty.call(r,"mcpBrand")&&typeof n=="string"&&o.add(n),r=Object.getPrototypeOf(r)}o.size!==0&&Object.defineProperty(e,Ff,{value:o,enumerable:!1,configurable:!0})}function et(e,t){try{if(typeof t=="object"&&t!==null&&Object.prototype.hasOwnProperty.call(e,"mcpBrand")&&typeof e.mcpBrand=="string"&&Object.prototype.hasOwnProperty.call(t,Ff)){let o=t[Ff];if(o&&typeof o.has=="function"&&o.has(e.mcpBrand))return!0}}catch{}return Function.prototype[Symbol.hasInstance].call(e,t)}var eo=(function(e){return e.InvalidRequest="invalid_request",e.InvalidClient="invalid_client",e.InvalidGrant="invalid_grant",e.UnauthorizedClient="unauthorized_client",e.UnsupportedGrantType="unsupported_grant_type",e.InvalidScope="invalid_scope",e.AccessDenied="access_denied",e.ServerError="server_error",e.TemporarilyUnavailable="temporarily_unavailable",e.UnsupportedResponseType="unsupported_response_type",e.UnsupportedTokenType="unsupported_token_type",e.InvalidToken="invalid_token",e.MethodNotAllowed="method_not_allowed",e.TooManyRequests="too_many_requests",e.InvalidClientMetadata="invalid_client_metadata",e.InvalidRedirectUri="invalid_redirect_uri",e.InsufficientScope="insufficient_scope",e.InvalidTarget="invalid_target",e.InvalidDpopProof="invalid_dpop_proof",e.UseDpopNonce="use_dpop_nonce",e})({}),ur=class sb extends Error{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.OAuthError"})}static[Symbol.hasInstance](t){return et(this,t)}static isInstance(t){if(typeof this!="function")throw new TypeError("isInstance must be called on the class (e.g. `SdkError.isInstance(value)`); for callbacks use `v => SdkError.isInstance(v)`");return et(this,t)}constructor(t,o,r){super(o),this.code=t,this.errorUri=r,this.name="OAuthError",lr(this,new.target)}toResponseObject(){let t={error:this.code,error_description:this.message};return this.errorUri&&(t.error_uri=this.errorUri),t}static fromResponse(t){return new sb(t.error,t.error_description??t.error,t.error_uri)}},q=(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})({}),M=class extends Error{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.SdkError"})}static[Symbol.hasInstance](e){return et(this,e)}static isInstance(e){if(typeof this!="function")throw new TypeError("isInstance must be called on the class (e.g. `SdkError.isInstance(value)`); for callbacks use `v => SdkError.isInstance(v)`");return et(this,e)}constructor(e,t,o,r){super(t,r),this.code=e,this.data=o,this.name="SdkError",lr(this,new.target)}},qt=class extends M{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}};function ib(e){let t=typeof e=="string"?new URL(e):new URL(e.href);return t.hash="",t}function Wf(e){if(typeof e!="object"||e===null||Array.isArray(e))return e;let t={...e};return delete t.issuer,t}function ab({requestedResource:e,configuredResource:t}){let o=typeof e=="string"?new URL(e):new URL(e.href),r=typeof t=="string"?new URL(t):new URL(t.href);if(o.origin!==r.origin||o.pathname.length<r.pathname.length)return!1;let n=o.pathname.endsWith("/")?o.pathname:o.pathname+"/",s=r.pathname.endsWith("/")?r.pathname:r.pathname+"/";return n.startsWith(s)}var cb="2026-07-28",Kf=[cb];function to(e){return e>=cb}function Gf(e){return e.filter(t=>!to(t))}function Aa(e){return e.filter(t=>to(t))}function lb(e){let t=e.structuredContent;return t===void 0||!(typeof t!="object"||t===null||Array.isArray(t))||(e.content?.some(o=>o.type==="text")??!1)?e:{...e,content:[...e.content??[],{type:"text",text:JSON.stringify(t)}]}}var ub=["task","inputRequests","requestState"];function Gv(e){return e===null||typeof e!="object"||Array.isArray(e)||e.content!==void 0||ub.some(t=>t in e)?e:{...e,content:[]}}function Yv(){let e=yo(()=>C([c(),R(),k(),$t(),T(c(),e),_(e)])),t=T(c(),e),o=C([c(),R().int()]),r=c(),n=m({ttl:R().optional()}),s=m({taskId:c()}),i=U({progressToken:o.optional(),"io.modelcontextprotocol/related-task":s.optional()}),a=m({_meta:i.optional()}),l=a.extend({task:n.optional()}),u=m({method:c(),params:a.loose().optional()}),d=m({_meta:i.optional()}),h=m({method:c(),params:d.loose().optional()}),f=U({_meta:i.optional()}),S=C([c(),R().int()]),y=f.strict(),w=d.extend({requestId:S.optional(),reason:c().optional()}),z=h.extend({method:b("notifications/cancelled"),params:w}),H=m({src:c(),mimeType:c().optional(),sizes:_(c()).optional(),theme:K(["light","dark"]).optional()}),W=m({icons:_(H).optional()}),N=m({name:c(),title:c().optional()}),D=N.extend({...N.shape,...W.shape,version:c(),websiteUrl:c().optional(),description:c().optional()}),x=pt(m({applyDefaults:k().optional()}),t),v=Ht(Te=>Te&&typeof Te=="object"&&!Array.isArray(Te)&&Object.keys(Te).length===0?{form:{}}:Te,pt(m({form:x.optional(),url:t.optional()}),t.optional())),Z=U({list:t.optional(),cancel:t.optional(),requests:U({sampling:U({createMessage:t.optional()}).optional(),elicitation:U({create:t.optional()}).optional()}).optional()}),oe=U({list:t.optional(),cancel:t.optional(),requests:U({tools:U({call:t.optional()}).optional()}).optional()}),ee=m({experimental:T(c(),t).optional(),sampling:m({context:t.optional(),tools:t.optional()}).optional(),elicitation:v.optional(),roots:m({listChanged:k().optional()}).optional(),tasks:Z.optional(),extensions:T(c(),t).optional()}),de=a.extend({protocolVersion:c(),capabilities:ee,clientInfo:D}),$e=u.extend({method:b("initialize"),params:de}),ie=m({experimental:T(c(),t).optional(),logging:t.optional(),completions:t.optional(),prompts:m({listChanged:k().optional()}).optional(),resources:m({subscribe:k().optional(),listChanged:k().optional()}).optional(),tools:m({listChanged:k().optional()}).optional(),tasks:oe.optional(),extensions:T(c(),t).optional()}),ue=f.extend({protocolVersion:c(),capabilities:ie,serverInfo:D,instructions:c().optional()}),ze=h.extend({method:b("notifications/initialized"),params:d.optional()}),Ce=u.extend({method:b("ping"),params:a.optional()}),_t=m({progress:R(),total:L(R()),message:L(c())}),Ue=m({...d.shape,..._t.shape,progressToken:o}),ot=h.extend({method:b("notifications/progress"),params:Ue}),bt=a.extend({cursor:r.optional()}),Je=u.extend({params:bt.optional()}),Ie=f.extend({nextCursor:r.optional()}),jt=m({uri:c(),mimeType:L(c()),_meta:T(c(),j()).optional()}),Lt=jt.extend({text:c()}),yt=c().refine(Te=>{try{return atob(Te),!0}catch{return!1}},{message:"Invalid Base64 string"}),xe=jt.extend({blob:yt}),Oe=K(["user","assistant"]),Ne=m({audience:_(Oe).optional(),priority:R().min(0).max(1).optional(),lastModified:Qe.datetime({offset:!0}).optional()}),ct=m({...N.shape,...W.shape,uri:c(),description:L(c()),mimeType:L(c()),size:L(R()),annotations:Ne.optional(),_meta:L(U({}))}),Eo=m({...N.shape,...W.shape,uriTemplate:c(),description:L(c()),mimeType:L(c()),annotations:Ne.optional(),_meta:L(U({}))}),Be=Je.extend({method:b("resources/list")}),We=Ie.extend({resources:_(ct)}),Ze=Je.extend({method:b("resources/templates/list")}),rt=Ie.extend({resourceTemplates:_(Eo)}),nt=a.extend({uri:c()}),zt=nt,vt=u.extend({method:b("resources/read"),params:zt}),no=f.extend({contents:_(C([Lt,xe]))}),Rt=h.extend({method:b("notifications/resources/list_changed"),params:d.optional()}),ko=nt,I=u.extend({method:b("resources/subscribe"),params:ko}),wt=nt,F=u.extend({method:b("resources/unsubscribe"),params:wt}),A=d.extend({uri:c()}),X=h.extend({method:b("notifications/resources/updated"),params:A}),O=m({name:c(),description:L(c()),required:L(k())}),E=m({...N.shape,...W.shape,description:L(c()),arguments:L(_(O)),_meta:L(U({}))}),J=Je.extend({method:b("prompts/list")}),V=Ie.extend({prompts:_(E)}),_e=a.extend({name:c(),arguments:T(c(),c()).optional()}),$o=u.extend({method:b("prompts/get"),params:_e}),xt=m({type:b("text"),text:c(),annotations:Ne.optional(),_meta:T(c(),j()).optional()}),Co=m({type:b("image"),data:yt,mimeType:c(),annotations:Ne.optional(),_meta:T(c(),j()).optional()}),Io=m({type:b("audio"),data:yt,mimeType:c(),annotations:Ne.optional(),_meta:T(c(),j()).optional()}),Jn=m({type:b("tool_use"),name:c(),id:c(),input:T(c(),j()),_meta:T(c(),j()).optional()}),so=m({type:b("resource"),resource:C([Lt,xe]),annotations:Ne.optional(),_meta:T(c(),j()).optional()}),Bn=ct.extend({type:b("resource_link")}),st=C([xt,Co,Io,Bn,so]),Sr=m({role:Oe,content:st}),_r=f.extend({description:c().optional(),messages:_(Sr)}),Oo=h.extend({method:b("notifications/prompts/list_changed"),params:d.optional()}),Wn=m({title:c().optional(),readOnlyHint:k().optional(),destructiveHint:k().optional(),idempotentHint:k().optional(),openWorldHint:k().optional()}),br=m({taskSupport:K(["required","optional","forbidden"]).optional()}),No=m({...N.shape,...W.shape,description:c().optional(),inputSchema:m({type:b("object"),properties:T(c(),e).optional(),required:_(c()).optional()}).catchall(j()),outputSchema:m({type:b("object"),properties:T(c(),e).optional(),required:_(c()).optional()}).catchall(j()).optional(),annotations:Wn.optional(),execution:br.optional(),_meta:T(c(),j()).optional()}),yr=Je.extend({method:b("tools/list")}),zr=Ie.extend({tools:_(No)}),vr=f.extend({content:_(st),structuredContent:T(c(),j()).optional(),isError:k().optional()}),Pe=l.extend({name:c(),arguments:T(c(),j()).optional()}),Kn=u.extend({method:b("tools/call"),params:Pe}),Ja=h.extend({method:b("notifications/tools/list_changed"),params:d.optional()}),Rr=K(["debug","info","notice","warning","error","critical","alert","emergency"]),Gn=a.extend({level:Rr}),Yn=u.extend({method:b("logging/setLevel"),params:Gn}),Xn=d.extend({level:Rr,logger:c().optional(),data:j()}),Qn=h.extend({method:b("notifications/message"),params:Xn}),es=m({name:c().optional()}),ts=m({hints:_(es).optional(),costPriority:R().min(0).max(1).optional(),speedPriority:R().min(0).max(1).optional(),intelligencePriority:R().min(0).max(1).optional()}),os=m({mode:K(["auto","required","none"]).optional()}),Ba=m({type:b("tool_result"),toolUseId:c().describe("The unique identifier for the corresponding tool call."),content:_(st),structuredContent:m({}).loose().optional(),isError:k().optional(),_meta:T(c(),j()).optional()}),rs=bo("type",[xt,Co,Io]),io=bo("type",[xt,Co,Io,Jn,Ba]),ns=m({role:Oe,content:C([io,_(io)]),_meta:T(c(),j()).optional()}),ss=l.extend({messages:_(ns),modelPreferences:ts.optional(),systemPrompt:c().optional(),includeContext:K(["none","thisServer","allServers"]).optional(),temperature:R().optional(),maxTokens:R().int(),stopSequences:_(c()).optional(),metadata:t.optional(),tools:_(No).optional(),toolChoice:os.optional()}),is=u.extend({method:b("sampling/createMessage"),params:ss}),as=f.extend({model:c(),stopReason:L(K(["endTurn","stopSequence","maxTokens"]).or(c())),role:Oe,content:rs}),cs=f.extend({model:c(),stopReason:L(K(["endTurn","stopSequence","maxTokens","toolUse"]).or(c())),role:Oe,content:C([io,_(io)])}),ls=m({type:b("boolean"),title:c().optional(),description:c().optional(),default:k().optional()}),us=m({type:b("string"),title:c().optional(),description:c().optional(),minLength:R().optional(),maxLength:R().optional(),format:K(["email","uri","date","date-time"]).optional(),default:c().optional()}),ds=m({type:K(["number","integer"]),title:c().optional(),description:c().optional(),minimum:R().optional(),maximum:R().optional(),default:R().optional()}),ps=m({type:b("string"),title:c().optional(),description:c().optional(),enum:_(c()),default:c().optional()}),hs=m({type:b("string"),title:c().optional(),description:c().optional(),oneOf:_(m({const:c(),title:c()})),default:c().optional()}),ms=m({type:b("string"),title:c().optional(),description:c().optional(),enum:_(c()),enumNames:_(c()).optional(),default:c().optional()}),fs=C([ps,hs]),qo=m({type:b("array"),title:c().optional(),description:c().optional(),minItems:R().optional(),maxItems:R().optional(),items:m({type:b("string"),enum:_(c())}),default:_(c()).optional()}),Mo=m({type:b("array"),title:c().optional(),description:c().optional(),minItems:R().optional(),maxItems:R().optional(),items:m({anyOf:_(m({const:c(),title:c()}))}),default:_(c()).optional()}),Wa=C([qo,Mo]),Ka=C([ms,fs,Wa]),Ke=C([Ka,ls,us,ds]),Ge=l.extend({mode:b("form").optional(),message:c(),requestedSchema:m({type:b("object"),properties:T(c(),Ke),required:_(c()).optional()}).catchall(j())}),gs=l.extend({mode:b("url"),message:c(),elicitationId:c(),url:c().url()}),lt=C([Ge,gs]),Ga=u.extend({method:b("elicitation/create"),params:lt}),Ya=d.extend({elicitationId:c()}),Xa=h.extend({method:b("notifications/elicitation/complete"),params:Ya}),Qa=f.extend({action:K(["accept","decline","cancel"]),content:Ht(Te=>Te===null?void 0:Te,T(c(),C([c(),R(),k(),_(c())])).optional())}),ec=m({type:b("ref/resource"),uri:c()}),tc=m({type:b("ref/prompt"),name:c()}),oc=a.extend({ref:C([tc,ec]),argument:m({name:c(),value:c()}),context:m({arguments:T(c(),c()).optional()}).optional()}),Ss=u.extend({method:b("completion/complete"),params:oc}),rc=f.extend({completion:U({values:_(c()).max(100),total:L(R().int()),hasMore:L(k())})}),nc=m({uri:c().startsWith("file://"),name:c().optional(),_meta:T(c(),j()).optional()}),wr=u.extend({method:b("roots/list"),params:a.optional()}),_s=f.extend({roots:_(nc)}),sc=h.extend({method:b("notifications/roots/list_changed"),params:d.optional()}),ic=U({ttl:R().optional(),pollInterval:R().optional()}),bs=K(["working","input_required","completed","failed","cancelled"]),ao=m({taskId:c(),status:bs,ttl:C([R(),$t()]),createdAt:c(),lastUpdatedAt:c(),pollInterval:L(R()),statusMessage:L(c())}),De=f.extend({task:ao}),ac=d.merge(ao),Ao=h.extend({method:b("notifications/tasks/status"),params:ac}),xr=u.extend({method:b("tasks/get"),params:a.extend({taskId:c()})}),Pr=f.merge(ao),Tr=u.extend({method:b("tasks/result"),params:a.extend({taskId:c()})}),Uu=f.loose(),qe=Je.extend({method:b("tasks/list")}),Se=Ie.extend({tasks:_(ao)}),jo=u.extend({method:b("tasks/cancel"),params:a.extend({taskId:c()})});return{JSONValueSchema:e,JSONObjectSchema:t,ProgressTokenSchema:o,CursorSchema:r,TaskMetadataSchema:n,RelatedTaskMetadataSchema:s,RequestMetaSchema:i,BaseRequestParamsSchema:a,TaskAugmentedRequestParamsSchema:l,RequestSchema:u,NotificationsParamsSchema:d,NotificationSchema:h,ResultSchema:f,RequestIdSchema:S,EmptyResultSchema:y,CancelledNotificationParamsSchema:w,CancelledNotificationSchema:z,IconSchema:H,IconsSchema:W,BaseMetadataSchema:N,ImplementationSchema:D,ClientTasksCapabilitySchema:Z,ServerTasksCapabilitySchema:oe,ClientCapabilitiesSchema:ee,InitializeRequestParamsSchema:de,InitializeRequestSchema:$e,ServerCapabilitiesSchema:ie,InitializeResultSchema:ue,InitializedNotificationSchema:ze,PingRequestSchema:Ce,ProgressSchema:_t,ProgressNotificationParamsSchema:Ue,ProgressNotificationSchema:ot,PaginatedRequestParamsSchema:bt,PaginatedRequestSchema:Je,PaginatedResultSchema:Ie,ResourceContentsSchema:jt,TextResourceContentsSchema:Lt,BlobResourceContentsSchema:xe,RoleSchema:Oe,AnnotationsSchema:Ne,ResourceSchema:ct,ResourceTemplateSchema:Eo,ListResourcesRequestSchema:Be,ListResourcesResultSchema:We,ListResourceTemplatesRequestSchema:Ze,ListResourceTemplatesResultSchema:rt,ResourceRequestParamsSchema:nt,ReadResourceRequestParamsSchema:zt,ReadResourceRequestSchema:vt,ReadResourceResultSchema:no,ResourceListChangedNotificationSchema:Rt,SubscribeRequestParamsSchema:ko,SubscribeRequestSchema:I,UnsubscribeRequestParamsSchema:wt,UnsubscribeRequestSchema:F,ResourceUpdatedNotificationParamsSchema:A,ResourceUpdatedNotificationSchema:X,PromptArgumentSchema:O,PromptSchema:E,ListPromptsRequestSchema:J,ListPromptsResultSchema:V,GetPromptRequestParamsSchema:_e,GetPromptRequestSchema:$o,TextContentSchema:xt,ImageContentSchema:Co,AudioContentSchema:Io,ToolUseContentSchema:Jn,EmbeddedResourceSchema:so,ResourceLinkSchema:Bn,ContentBlockSchema:st,PromptMessageSchema:Sr,GetPromptResultSchema:_r,PromptListChangedNotificationSchema:Oo,ToolAnnotationsSchema:Wn,ToolExecutionSchema:br,ToolSchema:No,ListToolsRequestSchema:yr,ListToolsResultSchema:zr,CallToolResultSchema:vr,CallToolRequestParamsSchema:Pe,CallToolRequestSchema:Kn,ToolListChangedNotificationSchema:Ja,LoggingLevelSchema:Rr,SetLevelRequestParamsSchema:Gn,SetLevelRequestSchema:Yn,LoggingMessageNotificationParamsSchema:Xn,LoggingMessageNotificationSchema:Qn,ModelHintSchema:es,ModelPreferencesSchema:ts,ToolChoiceSchema:os,ToolResultContentSchema:Ba,SamplingContentSchema:rs,SamplingMessageContentBlockSchema:io,SamplingMessageSchema:ns,CreateMessageRequestParamsSchema:ss,CreateMessageRequestSchema:is,CreateMessageResultSchema:as,CreateMessageResultWithToolsSchema:cs,BooleanSchemaSchema:ls,StringSchemaSchema:us,NumberSchemaSchema:ds,UntitledSingleSelectEnumSchemaSchema:ps,TitledSingleSelectEnumSchemaSchema:hs,LegacyTitledEnumSchemaSchema:ms,SingleSelectEnumSchemaSchema:fs,UntitledMultiSelectEnumSchemaSchema:qo,TitledMultiSelectEnumSchemaSchema:Mo,MultiSelectEnumSchemaSchema:Wa,EnumSchemaSchema:Ka,PrimitiveSchemaDefinitionSchema:Ke,ElicitRequestFormParamsSchema:Ge,ElicitRequestURLParamsSchema:gs,ElicitRequestParamsSchema:lt,ElicitRequestSchema:Ga,ElicitationCompleteNotificationParamsSchema:Ya,ElicitationCompleteNotificationSchema:Xa,ElicitResultSchema:Qa,ResourceTemplateReferenceSchema:ec,PromptReferenceSchema:tc,CompleteRequestParamsSchema:oc,CompleteRequestSchema:Ss,CompleteResultSchema:rc,RootSchema:nc,ListRootsRequestSchema:wr,ListRootsResultSchema:_s,RootsListChangedNotificationSchema:sc,TaskCreationParamsSchema:ic,TaskStatusSchema:bs,TaskSchema:ao,CreateTaskResultSchema:De,TaskStatusNotificationParamsSchema:ac,TaskStatusNotificationSchema:Ao,GetTaskRequestSchema:xr,GetTaskResultSchema:Pr,GetTaskPayloadRequestSchema:Tr,GetTaskPayloadResultSchema:Uu,ListTasksRequestSchema:qe,ListTasksResultSchema:Se,CancelTaskRequestSchema:jo,CancelTaskResultSchema:f.merge(ao),ClientRequestSchema:C([Ce,$e,Ss,Yn,$o,J,Be,Ze,vt,I,F,Kn,yr,xr,Tr,qe,jo]),ClientNotificationSchema:C([z,ot,ze,sc,Ao]),ClientResultSchema:C([y,as,cs,Qa,_s,Pr,Se,De]),ServerRequestSchema:C([Ce,is,Ga,wr,xr,Tr,qe,jo]),ServerNotificationSchema:C([z,ot,Qn,X,Rt,Ja,Oo,Ao,Xa]),ServerResultSchema:C([y,ue,rc,_r,V,We,rt,no,vr,zr,Pr,Se,De]),CallToolResultWireSchema:j().superRefine((Te,Fy)=>{if(!(typeof Te!="object"||Te===null||Array.isArray(Te)||Te.content!==void 0)){for(let Lg of ub)if(Lg in Te){Fy.addIssue({code:"custom",message:`content is required when the body carries '${Lg}' \u2014 another result family cannot default into an empty tools/call success`});return}}}).transform(Gv).pipe(vr)}}var Xv;function db(){return Xv??=Yv()}function pb(e){return e.type!=="object"}var Qv=new Set(["const","enum","default","examples"]),eR=new Set(["properties","patternProperties","$defs","definitions","dependentSchemas","dependencies"]);function J_(e){return e!==void 0&&!(typeof e=="string"&&e.startsWith("#"))}function tR(e){let t=typeof e.$schema=="string"?e.$schema:void 0;if(J_(e.$id))return{...t!==void 0&&{$schema:t},type:"object",properties:{result:e},required:["result"]};let o=Hg(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"||!s&&J_(n.$id))return n;let i={},a=!1;for(let[l,u]of Object.entries(n))s?i[l]=r(u,!1):(l==="$ref"||l==="$dynamicRef")&&typeof u=="string"?i[l]=u==="#"?"#/properties/result":u.startsWith("#/")?`#/properties/result${u.slice(1)}`:u:l==="$recursiveRef"&&u==="#"&&o?a=!0:Qv.has(l)?i[l]=u:eR.has(l)?i[l]=r(u,!0):i[l]=r(u,!1);return a&&("$ref"in i?i.allOf=[...Array.isArray(i.allOf)?i.allOf:[],{$ref:"#/properties/result"}]:i.$ref="#/properties/result"),i};return{...t!==void 0&&{$schema:t},type:"object",properties:{result:r(e,!1)},required:["result"]}}var hb={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},mb={"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},oR={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},Su;function Yf(){if(Su)return Su;let e=db();return Su={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}},Su}function fb(e){return Object.prototype.hasOwnProperty.call(hb,e)}function gb(e){return Object.prototype.hasOwnProperty.call(mb,e)}function rR(e){return Object.prototype.hasOwnProperty.call(oR,e)}function nR(e){return rR(e)?Yf().resultSchemas[e]:void 0}function sR(e){return fb(e)?Yf().requestSchemas[e]:void 0}function iR(e){return gb(e)?Yf().notificationSchemas[e]:void 0}var aE=Object.keys(hb),cE=Object.keys(mb);function Hf(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function _u(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 B_={ok:!1,reason:"not-in-era"};function W_(e){return Hf(e)&&Hf(e.outputSchema)&&pb(e.outputSchema)}var Xf={era:"2025-11-25",hasRequestMethod:fb,hasNotificationMethod:gb,validateRequest:(e,t)=>_u(sR(e),t),validateResult:(e,t)=>_u(nR(e),t),validateNotification:(e,t)=>_u(iR(e),t),hasInputRequestMethod:()=>!1,validateInputRequest:()=>B_,validateInputResponse:()=>B_,samplingResultVariant:((e,t)=>{let o=db();return _u(e?o.CreateMessageResultWithToolsSchema:o.CreateMessageResultSchema,t)}),outboundEnvelope:e=>{},validateEnvelopeMeta:e=>[],projectCallToolResult(e,t){let o=lb(e),r=o.structuredContent;if(r===void 0)return o;let n=typeof r!="object"||r===null||Array.isArray(r),s=t!==void 0&&pb(t);return!n&&!s?o:{...o,structuredContent:{result:r}}},decodeResult(e,t){if(Hf(t)&&"resultType"in t){let o={...t};return delete o.resultType,{kind:"complete",result:o}}return{kind:"complete",result:t}},encodeResult(e,t){if(e!=="tools/list")return t;let o=t.tools;return!Array.isArray(o)||!o.some(r=>W_(r))?t:{...t,tools:o.map(r=>W_(r)?{...r,outputSchema:tR(r.outputSchema)}:r)}},encodeErrorCode:e=>e===-32002?-32602:e,checkInboundEnvelope:e=>{}};function aR(){let e=yo(()=>C([c(),R(),k(),$t(),T(c(),e),_(e)])),t=T(c(),e),o=C([c(),R().int()]),r=c(),n=C([c(),R().int()]),s=K(["user","assistant"]),i=K(["debug","info","notice","warning","error","critical","alert","emergency"]),a=c().refine(Se=>{try{return atob(Se),!0}catch{return!1}},{message:"Invalid Base64 string"}),l=m({ttl:R().optional()}),u=m({taskId:c()}),d=U({progressToken:o.optional(),"io.modelcontextprotocol/related-task":u.optional()}),h=m({_meta:d.optional()}),f=h.extend({task:l.optional()}),S=m({_meta:d.optional()}),y=m({method:c(),params:S.loose().optional()}),w=m({src:c(),mimeType:c().optional(),sizes:_(c()).optional(),theme:K(["light","dark"]).optional()}),z=m({icons:_(w).optional()}),H=m({name:c(),title:c().optional()}),W=H.extend({...H.shape,...z.shape,version:c(),websiteUrl:c().optional(),description:c().optional()}),N=pt(m({applyDefaults:k().optional()}),t),D=Ht(Se=>Se&&typeof Se=="object"&&!Array.isArray(Se)&&Object.keys(Se).length===0?{form:{}}:Se,pt(m({form:N.optional(),url:t.optional()}),t.optional())),x=U({list:t.optional(),cancel:t.optional(),requests:U({sampling:U({createMessage:t.optional()}).optional(),elicitation:U({create:t.optional()}).optional()}).optional()}),v=U({list:t.optional(),cancel:t.optional(),requests:U({tools:U({call:t.optional()}).optional()}).optional()}),Z=m({experimental:T(c(),t).optional(),sampling:m({context:t.optional(),tools:t.optional()}).optional(),elicitation:D.optional(),roots:m({listChanged:k().optional()}).optional(),tasks:x.optional(),extensions:T(c(),t).optional()}),oe=m({experimental:T(c(),t).optional(),logging:t.optional(),completions:t.optional(),prompts:m({listChanged:k().optional()}).optional(),resources:m({subscribe:k().optional(),listChanged:k().optional()}).optional(),tools:m({listChanged:k().optional()}).optional(),tasks:v.optional(),extensions:T(c(),t).optional()}),ee=m({progress:R(),total:L(R()),message:L(c())}),de=m({...S.shape,...ee.shape,progressToken:o}),$e=y.extend({method:b("notifications/progress"),params:de}),ie=S.extend({level:i,logger:c().optional(),data:j()}),ue=y.extend({method:b("notifications/message"),params:ie}),ze=m({uri:c(),mimeType:L(c()),_meta:T(c(),j()).optional()}),Ce=ze.extend({text:c()}),_t=ze.extend({blob:a}),Ue=m({audience:_(s).optional(),priority:R().min(0).max(1).optional(),lastModified:Qe.datetime({offset:!0}).optional()}),ot=m({...H.shape,...z.shape,uri:c(),description:L(c()),mimeType:L(c()),size:L(R()),annotations:Ue.optional(),_meta:L(U({}))}),bt=m({...H.shape,...z.shape,uriTemplate:c(),description:L(c()),mimeType:L(c()),annotations:Ue.optional(),_meta:L(U({}))}),Je=y.extend({method:b("notifications/resources/list_changed"),params:S.optional()}),Ie=S.extend({uri:c()}),jt=y.extend({method:b("notifications/resources/updated"),params:Ie}),Lt=m({name:c(),description:L(c()),required:L(k())}),yt=m({...H.shape,...z.shape,description:L(c()),arguments:L(_(Lt)),_meta:L(U({}))}),xe=y.extend({method:b("notifications/prompts/list_changed"),params:S.optional()}),Oe=m({type:b("text"),text:c(),annotations:Ue.optional(),_meta:T(c(),j()).optional()}),Ne=m({type:b("image"),data:a,mimeType:c(),annotations:Ue.optional(),_meta:T(c(),j()).optional()}),ct=m({type:b("audio"),data:a,mimeType:c(),annotations:Ue.optional(),_meta:T(c(),j()).optional()}),Eo=m({type:b("tool_use"),name:c(),id:c(),input:T(c(),j()),_meta:T(c(),j()).optional()}),Be=m({type:b("resource"),resource:C([Ce,_t]),annotations:Ue.optional(),_meta:T(c(),j()).optional()}),We=ot.extend({type:b("resource_link")}),Ze=C([Oe,Ne,ct,We,Be]),rt=m({role:s,content:Ze}),nt=m({title:c().optional(),readOnlyHint:k().optional(),destructiveHint:k().optional(),idempotentHint:k().optional(),openWorldHint:k().optional()}),zt=y.extend({method:b("notifications/tools/list_changed"),params:S.optional()}),vt=m({name:c().optional()}),no=m({hints:_(vt).optional(),costPriority:R().min(0).max(1).optional(),speedPriority:R().min(0).max(1).optional(),intelligencePriority:R().min(0).max(1).optional()}),Rt=m({mode:K(["auto","required","none"]).optional()}),ko=m({type:b("boolean"),title:c().optional(),description:c().optional(),default:k().optional()}),I=m({type:b("string"),title:c().optional(),description:c().optional(),minLength:R().optional(),maxLength:R().optional(),format:K(["email","uri","date","date-time"]).optional(),default:c().optional()}),wt=m({type:K(["number","integer"]),title:c().optional(),description:c().optional(),minimum:R().optional(),maximum:R().optional(),default:R().optional()}),F=m({type:b("string"),title:c().optional(),description:c().optional(),enum:_(c()),default:c().optional()}),A=m({type:b("string"),title:c().optional(),description:c().optional(),oneOf:_(m({const:c(),title:c()})),default:c().optional()}),X=m({type:b("string"),title:c().optional(),description:c().optional(),enum:_(c()),enumNames:_(c()).optional(),default:c().optional()}),O=C([F,A]),E=m({type:b("array"),title:c().optional(),description:c().optional(),minItems:R().optional(),maxItems:R().optional(),items:m({type:b("string"),enum:_(c())}),default:_(c()).optional()}),J=m({type:b("array"),title:c().optional(),description:c().optional(),minItems:R().optional(),maxItems:R().optional(),items:m({anyOf:_(m({const:c(),title:c()}))}),default:_(c()).optional()}),V=C([E,J]),_e=C([X,O,V]),$o=C([_e,ko,I,wt]),xt=f.extend({mode:b("form").optional(),message:c(),requestedSchema:m({type:b("object"),properties:T(c(),$o),required:_(c()).optional()}).catchall(j())}),Co=m({type:b("ref/resource"),uri:c()}),Io=m({type:b("ref/prompt"),name:c()}),Jn=m({uri:c().startsWith("file://"),name:c().optional(),_meta:T(c(),j()).optional()}),so=Z.shape,Bn=m({experimental:so.experimental,sampling:so.sampling,elicitation:so.elicitation,roots:so.roots,extensions:so.extensions}),st=oe.shape,Sr=m({experimental:st.experimental,logging:st.logging,completions:st.completions,prompts:st.prompts,resources:st.resources,tools:st.tools,extensions:st.extensions}),_r=U({progressToken:o.optional(),[Jt]:c(),[sn]:W.optional(),[Wo]:Bn,[an]:i.optional()}),Oo=m({...H.shape,...z.shape,description:c().optional(),inputSchema:U({$schema:c().optional(),type:b("object")}),outputSchema:U({$schema:c().optional()}).optional(),annotations:nt.optional(),_meta:T(c(),j()).optional()}),Wn=m({type:b("tool_result"),toolUseId:c(),content:_(Ze),structuredContent:j().optional(),isError:k().optional(),_meta:T(c(),j()).optional()}),br=C([Oe,Ne,ct,Eo,Wn]),No=m({role:s,content:C([br,_(br)]),_meta:T(c(),j()).optional()}),yr=c(),zr=U({[Bt]:W.optional().catch(void 0)}),vr=zr.optional();function Pe(Se){return U({_meta:vr,resultType:yr.default("complete"),...Se})}let Kn=Pe({}),Ja=Pe({nextCursor:r.optional()}),Rr=Pe({content:_(Ze),structuredContent:j().optional(),isError:k().optional()}),Gn=Pe({ttlMs:R().int().min(0),cacheScope:K(["public","private"]),tools:_(Oo),nextCursor:r.optional()}),Yn=Pe({ttlMs:R().int().min(0),cacheScope:K(["public","private"]),prompts:_(yt),nextCursor:r.optional()}),Xn=Pe({description:c().optional(),messages:_(rt)}),Qn=Pe({ttlMs:R().int().min(0),cacheScope:K(["public","private"]),resources:_(ot),nextCursor:r.optional()}),es=Pe({ttlMs:R().int().min(0),cacheScope:K(["public","private"]),resourceTemplates:_(bt),nextCursor:r.optional()}),ts=Pe({ttlMs:R().int().min(0),cacheScope:K(["public","private"]),contents:_(C([Ce,_t]))}),os=Pe({completion:m({values:_(c()).max(100),total:R().int().optional(),hasMore:k().optional()}).loose()}),Ba=Pe({ttlMs:R().int().min(0),cacheScope:K(["public","private"])}),rs=Pe({ttlMs:R().int().min(0).catch(0),cacheScope:K(["public","private"]).catch("private"),supportedVersions:_(c()),capabilities:Sr,instructions:c().optional()}),io=m({messages:_(No),modelPreferences:no.optional(),systemPrompt:c().optional(),includeContext:K(["none","thisServer","allServers"]).optional(),temperature:R().optional(),maxTokens:R().int(),stopSequences:_(c()).optional(),metadata:t.optional(),tools:_(Oo).optional(),toolChoice:Rt.optional()}),ns=m({method:b("sampling/createMessage"),params:io}),ss=m({method:b("roots/list"),params:m({_meta:T(c(),j()).optional()}).optional()}),is=m({...No.shape,model:c(),stopReason:c().optional()}),as=m({roots:_(Jn)}),cs=m({action:K(["accept","decline","cancel"]),content:T(c(),C([c(),R(),k(),_(c())])).optional()}),ls=m({mode:b("url"),message:c(),url:c().url()}),us=C([xt,ls]),ds=m({method:b("elicitation/create"),params:us}),ps=C([ns,ss,ds]),hs=C([is,as,cs]),ms=T(c(),ps),fs=T(c(),hs),qo=Pe({inputRequests:ms.optional(),requestState:c().optional()}),Mo={inputResponses:fs.optional(),requestState:c().optional()},Wa=m({_meta:_r,...Mo}),Ka=U({progressToken:o.optional()});function Ke(Se,jo){return m({method:b(Se),params:m({_meta:_r,...jo})})}function Ge(Se,jo){return m({method:b(Se),params:m({_meta:Ka.optional(),...jo}).optional()})}let gs={name:c(),arguments:T(c(),j()).optional(),...Mo},lt={cursor:r.optional()},Ga=Ke("tools/call",gs),Ya=Ke("tools/list",lt),Xa=Ke("prompts/list",lt),Qa=Ke("prompts/get",{name:c(),arguments:T(c(),c()).optional(),...Mo}),ec=Ke("resources/list",lt),tc=Ke("resources/templates/list",lt),oc=Ke("resources/read",{uri:c(),...Mo}),Ss={ref:C([Io,Co]),argument:m({name:c(),value:c()}),context:m({arguments:T(c(),c()).optional()}).optional()},rc=Ke("completion/complete",Ss),nc=Ke("server/discover",{}),wr=m({toolsListChanged:k().optional(),promptsListChanged:k().optional(),resourcesListChanged:k().optional(),resourceSubscriptions:_(c()).optional()}),_s={notifications:wr},sc=Ke("subscriptions/listen",_s),ic=zr.extend({"io.modelcontextprotocol/subscriptionId":n}),bs=U({_meta:ic,resultType:yr.default("complete")}),ao={"tools/call":Ge("tools/call",gs),"tools/list":Ge("tools/list",lt),"prompts/get":Ge("prompts/get",{name:c(),arguments:T(c(),c()).optional()}),"prompts/list":Ge("prompts/list",lt),"resources/list":Ge("resources/list",lt),"resources/templates/list":Ge("resources/templates/list",lt),"resources/read":Ge("resources/read",{uri:c()}),"completion/complete":Ge("completion/complete",Ss),"server/discover":Ge("server/discover",{}),"subscriptions/listen":Ge("subscriptions/listen",_s)};function De(Se){return U({_meta:vr,...Se})}let ac={"tools/call":De({content:_(Ze),structuredContent:j().optional(),isError:k().optional()}),"tools/list":De({ttlMs:R().int().min(0),cacheScope:K(["public","private"]),tools:_(Oo),nextCursor:r.optional()}),"prompts/get":De({description:c().optional(),messages:_(rt)}),"prompts/list":De({ttlMs:R().int().min(0),cacheScope:K(["public","private"]),prompts:_(yt),nextCursor:r.optional()}),"resources/list":De({ttlMs:R().int().min(0),cacheScope:K(["public","private"]),resources:_(ot),nextCursor:r.optional()}),"resources/templates/list":De({ttlMs:R().int().min(0),cacheScope:K(["public","private"]),resourceTemplates:_(bt),nextCursor:r.optional()}),"resources/read":De({ttlMs:R().int().min(0),cacheScope:K(["public","private"]),contents:_(C([Ce,_t]))}),"completion/complete":De({completion:m({values:_(c()).max(100),total:R().int().optional(),hasMore:k().optional()}).loose()}),"server/discover":De({ttlMs:R().int().min(0).catch(0),cacheScope:K(["public","private"]).catch("private"),supportedVersions:_(c()),capabilities:Sr,instructions:c().optional()}),"subscriptions/listen":De({})},Ao=U({"io.modelcontextprotocol/subscriptionId":n.optional()}),xr=m({method:b("notifications/subscriptions/acknowledged"),params:m({_meta:Ao.optional(),notifications:wr})}),Pr=m({_meta:Ao.optional(),requestId:n,reason:c().optional()}),Tr=m({method:b("notifications/cancelled"),params:Pr}),Uu={"notifications/cancelled":Tr,"notifications/progress":$e,"notifications/message":ue,"notifications/resources/updated":jt,"notifications/resources/list_changed":Je,"notifications/tools/list_changed":zt,"notifications/prompts/list_changed":xe,"notifications/subscriptions/acknowledged":xr},qe=Se=>m({jsonrpc:b("2.0"),id:C([c(),R().int()]),result:Se}).strict();return{JSONValueSchema:e,JSONObjectSchema:t,ProgressTokenSchema:o,CursorSchema:r,RequestIdSchema:n,RoleSchema:s,LoggingLevelSchema:i,TaskMetadataSchema:l,RelatedTaskMetadataSchema:u,RequestMetaSchema:d,BaseRequestParamsSchema:h,TaskAugmentedRequestParamsSchema:f,NotificationsParamsSchema:S,NotificationSchema:y,IconSchema:w,IconsSchema:z,BaseMetadataSchema:H,ImplementationSchema:W,ClientTasksCapabilitySchema:x,ServerTasksCapabilitySchema:v,ClientCapabilitiesSchema:Z,ServerCapabilitiesSchema:oe,ProgressSchema:ee,ProgressNotificationParamsSchema:de,ProgressNotificationSchema:$e,LoggingMessageNotificationParamsSchema:ie,LoggingMessageNotificationSchema:ue,ResourceContentsSchema:ze,TextResourceContentsSchema:Ce,BlobResourceContentsSchema:_t,AnnotationsSchema:Ue,ResourceSchema:ot,ResourceTemplateSchema:bt,ResourceListChangedNotificationSchema:Je,ResourceUpdatedNotificationParamsSchema:Ie,ResourceUpdatedNotificationSchema:jt,PromptArgumentSchema:Lt,PromptSchema:yt,PromptListChangedNotificationSchema:xe,TextContentSchema:Oe,ImageContentSchema:Ne,AudioContentSchema:ct,ToolUseContentSchema:Eo,EmbeddedResourceSchema:Be,ResourceLinkSchema:We,ContentBlockSchema:Ze,PromptMessageSchema:rt,ToolAnnotationsSchema:nt,ToolListChangedNotificationSchema:zt,ModelHintSchema:vt,ModelPreferencesSchema:no,ToolChoiceSchema:Rt,BooleanSchemaSchema:ko,StringSchemaSchema:I,NumberSchemaSchema:wt,UntitledSingleSelectEnumSchemaSchema:F,TitledSingleSelectEnumSchemaSchema:A,LegacyTitledEnumSchemaSchema:X,SingleSelectEnumSchemaSchema:O,UntitledMultiSelectEnumSchemaSchema:E,TitledMultiSelectEnumSchemaSchema:J,MultiSelectEnumSchemaSchema:V,EnumSchemaSchema:_e,PrimitiveSchemaDefinitionSchema:$o,ElicitRequestFormParamsSchema:xt,ResourceTemplateReferenceSchema:Co,PromptReferenceSchema:Io,RootSchema:Jn,ClientCapabilities2026Schema:Bn,ServerCapabilities2026Schema:Sr,RequestMetaEnvelopeSchema:_r,ToolSchema:Oo,ToolResultContentSchema:Wn,SamplingMessageContentBlockSchema:br,SamplingMessageSchema:No,ResultTypeSchema:yr,ResultMetaSchema:zr,ResultSchema:Kn,PaginatedResultSchema:Ja,CallToolResultSchema:Rr,ListToolsResultSchema:Gn,ListPromptsResultSchema:Yn,GetPromptResultSchema:Xn,ListResourcesResultSchema:Qn,ListResourceTemplatesResultSchema:es,ReadResourceResultSchema:ts,CompleteResultSchema:os,CacheableResultSchema:Ba,DiscoverResultSchema:rs,CreateMessageRequestParamsSchema:io,CreateMessageRequestSchema:ns,ListRootsRequestSchema:ss,CreateMessageResultSchema:is,ListRootsResultSchema:as,ElicitResultSchema:cs,ElicitRequestURLParamsSchema:ls,ElicitRequestParamsSchema:us,ElicitRequestSchema:ds,InputRequestSchema:ps,InputResponseSchema:hs,InputRequestsSchema:ms,InputResponsesSchema:fs,InputRequiredResultSchema:qo,InputResponseRequestParamsSchema:Wa,CallToolRequestSchema:Ga,ListToolsRequestSchema:Ya,ListPromptsRequestSchema:Xa,GetPromptRequestSchema:Qa,ListResourcesRequestSchema:ec,ListResourceTemplatesRequestSchema:tc,ReadResourceRequestSchema:oc,CompleteRequestSchema:rc,DiscoverRequestSchema:nc,SubscriptionFilterSchema:wr,SubscriptionsListenRequestSchema:sc,SubscriptionsListenResultMetaSchema:ic,SubscriptionsListenResultSchema:bs,dispatchRequestSchemas:ao,dispatchResultSchemas:ac,NotificationMetaSchema:Ao,SubscriptionsAcknowledgedNotificationSchema:xr,CancelledNotificationParamsSchema:Pr,CancelledNotificationSchema:Tr,notificationSchemas2026:Uu,JSONRPCResultResponseSchema:qe(Kn),CallToolResultResponseSchema:qe(C([Rr,qo])),ListToolsResultResponseSchema:qe(Gn),ListPromptsResultResponseSchema:qe(Yn),GetPromptResultResponseSchema:qe(C([Xn,qo])),ListResourcesResultResponseSchema:qe(Qn),ListResourceTemplatesResultResponseSchema:qe(es),ReadResourceResultResponseSchema:qe(C([ts,qo])),CompleteResultResponseSchema:qe(os),DiscoverResultResponseSchema:qe(rs),SubscriptionsListenResultResponseSchema:qe(bs)}}var cR;function To(){return cR??=aR()}var lR=["tools/list","prompts/list","resources/list","resources/templates/list","resources/read","server/discover"];function uR(e){return lR.includes(e)}var Qf=Symbol("modelcontextprotocol.resultCacheHintFallback");function dR(e){return e[Qf]}function Sb(e){return typeof e=="number"&&Number.isSafeInteger(e)&&e>=0}function _b(e){return e==="public"||e==="private"}var B=(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})({}),se=class bb extends Error{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.ProtocolError"})}static[Symbol.hasInstance](t){return et(this,t)}static isInstance(t){if(typeof this!="function")throw new TypeError("isInstance must be called on the class (e.g. `SdkError.isInstance(value)`); for callbacks use `v => SdkError.isInstance(v)`");return et(this,t)}constructor(t,o,r){super(o),this.code=t,this.data=r,this.name="ProtocolError",lr(this,new.target)}static fromError(t,o,r){if(t===B.UrlElicitationRequired&&r){let n=r;if(n.elicitations)return new zb(n.elicitations,o)}if(t===B.UnsupportedProtocolVersion&&r){let n=r;if(Array.isArray(n.supported)&&typeof n.requested=="string")return new Ru({supported:n.supported,requested:n.requested},o)}if(t===B.InvalidParams||t===B.ResourceNotFound){let n=r;if(typeof n?.uri=="string"&&(t===B.ResourceNotFound||Object.keys(n).length===1))return new yb(n.uri,o)}if(t===B.MissingRequiredClientCapability&&r){let n=r;if(n.requiredCapabilities!==null&&typeof n.requiredCapabilities=="object"&&!Array.isArray(n.requiredCapabilities))return new vb({requiredCapabilities:n.requiredCapabilities},o)}return new bb(t,o,r)}},yb=class extends se{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.ResourceNotFoundError"})}constructor(e,t=`Resource not found: ${e}`){super(B.InvalidParams,t,{uri:e})}get uri(){return this.data.uri}},zb=class extends se{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.UrlElicitationRequiredError"})}constructor(e,t=`URL elicitation${e.length>1?"s":""} required`){super(B.UrlElicitationRequired,t,{elicitations:e})}get elicitations(){return this.data?.elicitations??[]}},Ru=class extends se{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.UnsupportedProtocolVersionError"})}constructor(e,t=`Unsupported protocol version: ${e.requested}`){super(B.UnsupportedProtocolVersion,t,e)}get supported(){return this.data.supported}get requested(){return this.data.requested}},vb=class extends se{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.MissingRequiredClientCapabilityError"})}constructor(e,t=`Missing required client capabilities: ${Object.keys(e.requiredCapabilities).join(", ")}`){super(B.MissingRequiredClientCapability,t,e)}get requiredCapabilities(){return this.data.requiredCapabilities}},pR=0,hR="private",mR=["tools/call","prompts/get","resources/read"];function fR(e,t){let o=t.resultType;if(o===void 0)return{...t,resultType:"complete"};if(o==="complete"||mR.includes(e))return t;throw new se(B.InternalError,`Handler for ${e} returned resultType '${String(o)}', but results of ${e} only support 'complete' on protocol revision 2026-07-28`)}function gR(e,t){let o=dR(t);if(t.resultType!=="complete"||!uR(e))return o===void 0?t:zR(t);let r=t,n=Sb(r.ttlMs)?r.ttlMs:bR(o),s=_b(r.cacheScope)?r.cacheScope:yR(o),i={...r,ttlMs:n,cacheScope:s};return delete i[Qf],i}function SR(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function _R(e,t){if(t===void 0)return e;let o=e._meta;return o===void 0?{...e,_meta:{[Bt]:t}}:!SR(o)||o[Bt]!==void 0?e:{...e,_meta:{...o,[Bt]:t}}}function bR(e){return e!==void 0&&Sb(e.ttlMs)?e.ttlMs:pR}function yR(e){return e!==void 0&&_b(e.cacheScope)?e.cacheScope:hR}function zR(e){let t={...e};return delete t[Qf],t}var vR=["elicitation/create","sampling/createMessage","roots/list"],bu;function Rb(){if(bu)return bu;let e=To();return bu={request:{"elicitation/create":m({method:b("elicitation/create"),params:e.ElicitRequestParamsSchema}),"sampling/createMessage":m({method:b("sampling/createMessage"),params:e.CreateMessageRequestParamsSchema}),"roots/list":m({method:b("roots/list"),params:U({}).optional()})},response:{"elicitation/create":e.ElicitResultSchema,"sampling/createMessage":e.CreateMessageResultSchema,"roots/list":e.ListRootsResultSchema}},bu}function wb(e){return vR.includes(e)}function Lf(e){return wb(e)?Rb().request[e]:void 0}function RR(e){return wb(e)?Rb().response[e]:void 0}var eg={"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},xb={"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 Pb(e){return Object.prototype.hasOwnProperty.call(eg,e)}function Tb(e){return Object.prototype.hasOwnProperty.call(xb,e)}function wR(e){return Object.prototype.hasOwnProperty.call(eg,e)}function xR(e){return Pb(e)?To().dispatchRequestSchemas[e]:void 0}function PR(e){return wR(e)?To().dispatchResultSchemas[e]:void 0}function TR(e){return Tb(e)?To().notificationSchemas2026[e]:void 0}var lE=Object.keys(eg),uE=Object.keys(xb);function Na(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function Ia(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 ER={ok:!1,reason:"not-in-era"},kR=[Jt,Wo];function $R(e,t){let o=t,r=!1,n=()=>(r||(o={...o},r=!0),o),s=t.tools;e==="tools/list"&&Array.isArray(s)&&s.some(a=>Na(a)&&"execution"in a)&&(n().tools=s.map(a=>{if(!Na(a)||!("execution"in a))return a;let l={...a};return delete l.execution,l}));let i=t.capabilities;if(Na(i)&&"tasks"in i){let a={...i};delete a.tasks,n().capabilities=a}return o}var tg={era:"2026-07-28",hasRequestMethod:Pb,hasNotificationMethod:Tb,hasInputRequestMethod:e=>Lf(e)!==void 0,validateRequest:(e,t)=>Ia(xR(e),t),validateResult:(e,t)=>Ia(PR(e),t),validateNotification:(e,t)=>Ia(TR(e),t),validateInputRequest:(e,t)=>Ia(Lf(e),t),validateInputResponse:(e,t)=>Ia(RR(e),t),samplingResultVariant:()=>ER,outboundEnvelope(e){return{[Jt]:e.protocolVersion,[sn]:e.clientInfo,[Wo]:e.clientCapabilities,...e.logLevel!==void 0&&{[an]:e.logLevel}}},validateEnvelopeMeta(e){let t=[];for(let r of kR)r in e||t.push({key:r,problem:"missing"});let o=To().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";n.length===1&&t.some(i=>i.key===s&&i.problem==="missing")||t.push({key:s,problem:r.message})}return t},projectCallToolResult:e=>lb(e),inputRequestSchema:Lf,decodeResult(e,t){if(!Na(t))return{kind:"invalid",error:new M(q.InvalidResult,`Invalid result for ${e}: not an object`,{method:e})};let o=t.resultType;if(o===void 0)return{kind:"invalid",error:new M(q.InvalidResult,`Invalid result for ${e}: missing required resultType \u2014 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 M(q.InvalidResult,`Invalid result for ${e}: non-string resultType`,{method:e,resultType:o})};if(o==="input_required"){let i=t.inputRequests,a=Na(i)?i:{},l=t.requestState,u=t._meta===void 0?void 0:To().ResultMetaSchema.safeParse(t._meta),d=u?.success?u.data:void 0;return Object.keys(a).length===0&&typeof l!="string"?{kind:"invalid",error:new M(q.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"})}:{kind:"input_required",inputRequests:a,...typeof l=="string"&&{requestState:l},...d!==void 0&&{_meta:d}}}if(o!=="complete")return{kind:"invalid",error:new M(q.UnsupportedResultType,`Unsupported result type '${o}' for ${e}`,{resultType:o,method:e})};let r=CR(),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 M(q.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 _R(gR(e,fR(e,$R(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=To().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("; ")}`}},yu;function CR(){if(yu)return yu;let e=To();return yu={"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},yu}var wu="2026-07-28";function Qt(e){return e!==void 0&&to(e)?tg:Xf}function K_(e){return e.revision!==void 0?Qt(e.revision).era:e.era==="modern"?tg.era:Xf.era}function Uf(e){return Eb.some(t=>t.hasRequestMethod(e))}function Zf(e){return Eb.some(t=>t.hasNotificationMethod(e))}function G_(e){return e==="tasks/get"||e==="tasks/cancel"}var Eb=[Xf,tg],IR=Zg({AnnotationsSchema:()=>Ot,AudioContentSchema:()=>tr,BaseMetadataSchema:()=>Ct,BaseRequestParamsSchema:()=>ye,BlobResourceContentsSchema:()=>vn,BooleanSchemaSchema:()=>Pn,CallToolRequestParamsSchema:()=>Vi,CallToolRequestSchema:()=>Ji,CallToolResultSchema:()=>Po,CancelTaskRequestSchema:()=>au,CancelTaskResultSchema:()=>cu,CancelledNotificationParamsSchema:()=>ti,CancelledNotificationSchema:()=>mn,ClientCapabilitiesSchema:()=>ri,ClientNotificationSchema:()=>uu,ClientRequestSchema:()=>lu,ClientResultSchema:()=>du,ClientTasksCapabilitySchema:()=>Kl,CompatibilityCallToolResultSchema:()=>Yl,CompleteRequestParamsSchema:()=>ba,CompleteRequestSchema:()=>ya,CompleteResultSchema:()=>za,ContentBlockSchema:()=>Nt,CreateMessageRequestParamsSchema:()=>na,CreateMessageRequestSchema:()=>sa,CreateMessageResultSchema:()=>ia,CreateMessageResultWithToolsSchema:()=>aa,CreateTaskResultSchema:()=>Ql,CursorSchema:()=>ln,DiscoverRequestSchema:()=>ii,DiscoverResultSchema:()=>wo,ElicitRequestFormParamsSchema:()=>ar,ElicitRequestParamsSchema:()=>pa,ElicitRequestSchema:()=>ha,ElicitRequestURLParamsSchema:()=>da,ElicitResultSchema:()=>ga,ElicitationCompleteNotificationParamsSchema:()=>ma,ElicitationCompleteNotificationSchema:()=>fa,EmbeddedResourceSchema:()=>or,EmptyResultSchema:()=>Ro,EnumSchemaSchema:()=>ua,GetPromptRequestParamsSchema:()=>qi,GetPromptRequestSchema:()=>Mi,GetPromptResultSchema:()=>Li,GetTaskPayloadRequestSchema:()=>ru,GetTaskPayloadResultSchema:()=>nu,GetTaskRequestSchema:()=>tu,GetTaskResultSchema:()=>ou,IconSchema:()=>oi,IconsSchema:()=>Wt,ImageContentSchema:()=>er,ImplementationSchema:()=>It,InitializeRequestParamsSchema:()=>ni,InitializeRequestSchema:()=>fn,InitializeResultSchema:()=>si,InitializedNotificationSchema:()=>Sn,JSONArraySchema:()=>Bl,JSONObjectSchema:()=>pe,JSONRPCErrorResponseSchema:()=>Yo,JSONRPCMessageSchema:()=>mt,JSONRPCNotificationSchema:()=>hn,JSONRPCRequestSchema:()=>pn,JSONRPCResponseSchema:()=>Wl,JSONRPCResultResponseSchema:()=>Go,JSONValueSchema:()=>Vt,LegacyTitledEnumSchemaSchema:()=>kn,ListChangedOptionsBaseSchema:()=>Wi,ListPromptsRequestSchema:()=>Oi,ListPromptsResultSchema:()=>Ni,ListResourceTemplatesRequestSchema:()=>hi,ListResourceTemplatesResultSchema:()=>mi,ListResourcesRequestSchema:()=>di,ListResourcesResultSchema:()=>pi,ListRootsRequestSchema:()=>Ra,ListRootsResultSchema:()=>wa,ListTasksRequestSchema:()=>su,ListTasksResultSchema:()=>iu,ListToolsRequestSchema:()=>Fi,ListToolsResultSchema:()=>Hi,LoggingLevelSchema:()=>xn,LoggingMessageNotificationParamsSchema:()=>Yi,LoggingMessageNotificationSchema:()=>nr,ModelHintSchema:()=>Xi,ModelPreferencesSchema:()=>Qi,MultiSelectEnumSchemaSchema:()=>la,NotificationSchema:()=>Re,NotificationsParamsSchema:()=>ke,NumberSchemaSchema:()=>ir,PaginatedRequestParamsSchema:()=>li,PaginatedRequestSchema:()=>Kt,PaginatedResultSchema:()=>Gt,PingRequestSchema:()=>_n,PrimitiveSchemaDefinitionSchema:()=>In,ProgressNotificationParamsSchema:()=>ci,ProgressNotificationSchema:()=>bn,ProgressSchema:()=>ai,ProgressTokenSchema:()=>cn,PromptArgumentSchema:()=>Ci,PromptListChangedNotificationSchema:()=>Ui,PromptMessageSchema:()=>ji,PromptReferenceSchema:()=>_a,PromptSchema:()=>Ii,ReadResourceRequestParamsSchema:()=>fi,ReadResourceRequestSchema:()=>gi,ReadResourceResultSchema:()=>Si,RelatedTaskMetadataSchema:()=>ei,RequestIdSchema:()=>ht,RequestMetaSchema:()=>un,RequestSchema:()=>he,ResourceContentsSchema:()=>yn,ResourceLinkSchema:()=>rr,ResourceListChangedNotificationSchema:()=>_i,ResourceRequestParamsSchema:()=>Xo,ResourceSchema:()=>Rn,ResourceTemplateReferenceSchema:()=>Sa,ResourceTemplateSchema:()=>ui,ResourceUpdatedNotificationParamsSchema:()=>ki,ResourceUpdatedNotificationSchema:()=>$i,ResultMetaObjectSchema:()=>dn,ResultSchema:()=>me,RoleSchema:()=>Yt,RootSchema:()=>va,RootsListChangedNotificationSchema:()=>xa,SamplingContentSchema:()=>oa,SamplingMessageContentBlockSchema:()=>zo,SamplingMessageSchema:()=>ra,ServerCapabilitiesSchema:()=>gn,ServerNotificationSchema:()=>hu,ServerRequestSchema:()=>pu,ServerResultSchema:()=>mu,ServerTasksCapabilitySchema:()=>Gl,SetLevelRequestParamsSchema:()=>Ki,SetLevelRequestSchema:()=>Gi,SingleSelectEnumSchemaSchema:()=>ca,StringSchemaSchema:()=>sr,SubscribeRequestParamsSchema:()=>bi,SubscribeRequestSchema:()=>yi,SubscriptionFilterSchema:()=>wn,SubscriptionsAcknowledgedNotificationParamsSchema:()=>xi,SubscriptionsAcknowledgedNotificationSchema:()=>Pi,SubscriptionsListenRequestParamsSchema:()=>Ri,SubscriptionsListenRequestSchema:()=>wi,SubscriptionsListenResultMetaSchema:()=>Ti,SubscriptionsListenResultSchema:()=>Ei,TaskAugmentedRequestParamsSchema:()=>vo,TaskCreationParamsSchema:()=>Xl,TaskMetadataSchema:()=>Qs,TaskSchema:()=>Xt,TaskStatusNotificationParamsSchema:()=>Ta,TaskStatusNotificationSchema:()=>eu,TaskStatusSchema:()=>Pa,TextContentSchema:()=>Qo,TextResourceContentsSchema:()=>zn,TitledMultiSelectEnumSchemaSchema:()=>Cn,TitledSingleSelectEnumSchemaSchema:()=>En,ToolAnnotationsSchema:()=>Zi,ToolChoiceSchema:()=>ea,ToolExecutionSchema:()=>Di,ToolListChangedNotificationSchema:()=>Bi,ToolResultContentSchema:()=>ta,ToolSchema:()=>xo,ToolUseContentSchema:()=>Ai,UnsubscribeRequestParamsSchema:()=>zi,UnsubscribeRequestSchema:()=>vi,UntitledMultiSelectEnumSchemaSchema:()=>$n,UntitledSingleSelectEnumSchemaSchema:()=>Tn});var dr=e=>pn.safeParse(e).success,kb=e=>hn.safeParse(e).success,Ln=e=>Go.safeParse(e).success,Un=e=>Yo.safeParse(e).success;var $b=e=>typeof e=="object"&&e!==null&&!Array.isArray(e)&&e.resultType==="input_required";var og=e=>fn.safeParse(e).success,Cb=e=>Sn.safeParse(e).success;var OR="Mcp-Param-",Y_="x-mcp-header",NR=/^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/,qR=new Set(["string","integer","boolean","number"]);function rg(e){let t=[],o=new Map,r=(s,i,a)=>{if(s===null||typeof s!="object")return;let l=s;if(Y_ in l){if(!a||i.length===0)return`${zu(i)}: 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 d=l[Y_];if(typeof d!="string"||d.length===0)return`${zu(i)}: x-mcp-header MUST be a non-empty string`;if(!NR.test(d))return`${zu(i)}: x-mcp-header '${d}' is not a valid RFC 9110 token (no spaces, control characters or HTTP delimiters)`;let h=typeof l.type=="string"?l.type:void 0;if(h===void 0||!qR.has(h))return`${zu(i)}: x-mcp-header is only permitted on primitive-typed properties (string, integer, boolean); got ${h??"<none>"}`;let f=d.toLowerCase(),S=o.get(f);if(S!==void 0)return`x-mcp-header '${d}' is not case-insensitively unique (also declared as '${S}')`;o.set(f,d),t.push({path:i,headerName:d,type:h})}let u=l.properties;if(u!==null&&typeof u=="object")for(let[d,h]of Object.entries(u)){let f=r(h,[...i,d],a);if(f!==void 0)return f}for(let d of MR){let h=l[d];if(h===void 0)continue;let f=Array.isArray(h)?h:h!==null&&typeof h=="object"&&AR.has(d)?Object.values(h):[h];for(let S of f){let y=r(S,[...i,`<${d}>`],!1);if(y!==void 0)return y}}},n=r(e,[],!0);return n===void 0?{valid:!0,declarations:t}:{valid:!1,reason:n}}var MR=["items","prefixItems","contains","additionalProperties","unevaluatedProperties","unevaluatedItems","propertyNames","patternProperties","dependentSchemas","oneOf","anyOf","allOf","not","if","then","else","$defs","definitions"],AR=new Set(["patternProperties","dependentSchemas","$defs","definitions"]);function zu(e){return e.length===0?"<root>":e.join(".")}var Ib="=?base64?",Ob="?=";function jR(e){if(typeof e=="string")return e;if(typeof e=="boolean")return e?"true":"false";if(typeof e=="number")return!Number.isFinite(e)||Number.isInteger(e)&&!Number.isSafeInteger(e)?void 0:String(e)}function LR(e){if(e.length===0||e.startsWith(Ib)&&e.endsWith(Ob)||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))return!0}return!1}function UR(e){let t=new TextEncoder().encode(e),o="";for(let r of t)o+=String.fromCodePoint(r);return btoa(o)}function ng(e){return LR(e)?`${Ib}${UR(e)}${Ob}`:e}function ZR(e,t){let o=e;for(let r of t){if(o===null||typeof o!="object")return;o=o[r]}return o}function Nb(e,t){let o={};for(let r of e){let n=ZR(t,r.path);if(n==null)continue;let s=jR(n);s!==void 0&&(o[`${OR}${r.headerName}`]=ng(s))}return o}var jn=-32020,dE=[{rung:"http-method",order:1,evaluatedAt:"edge",codes:[-32e3],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:[B.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:[jn,B.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:[B.InvalidParams],conformance:["server-stateless"],rationale:"A present envelope claim with a malformed envelope \u2014 and a missing envelope on a request whose protocol-version header names a modern revision \u2014 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:[B.MethodNotFound],conformance:["server-stateless"],rationale:"Method existence outranks parameter validity: a method absent from the negotiated revision\u2019s 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:[B.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:[jn],conformance:["http-header-validation"],rationale:"SEP-2243 standard `MCP-Protocol-Version` / `Mcp-Method` / `Mcp-Name` headers \u2014 presence, sentinel decoding, and `Mcp-Name` \u2194 body cross-check \u2014 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\u2019s 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 \u2014 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\u20136) are consulted."},{rung:"client-capabilities",order:8,evaluatedAt:"pre-dispatch",codes:[B.MissingRequiredClientCapability],conformance:["server-stateless"],rationale:"The capability requirement is checked by the HTTP entry, pre-dispatch, against the validated envelope the classifier produced \u2014 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:[jn],conformance:["http-custom-header-server-validation"],rationale:"SEP-2243 `Mcp-Param-*` headers are validated against the named tool\u2019s `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."}],pE={[B.ParseError]:400,[B.InvalidRequest]:400,[B.MethodNotFound]:404,[B.UnsupportedProtocolVersion]:400,[B.MissingRequiredClientCapability]:400,[jn]:400},X_={"tools/call":"name","prompts/get":"name","resources/read":"uri","tasks/get":"taskId","tasks/update":"taskId","tasks/cancel":"taskId"};function qb(e,t){let o=Object.hasOwn(X_,e)?X_[e]:void 0;if(o===void 0)return;let r=DR(t)?t[o]:void 0;return{field:o,value:typeof r=="string"?r:void 0}}function DR(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function xu(e,t){return Us(e,t)}function Oa(e){return new Set(e.flatMap(t=>Object.keys(t.shape)))}function Vf(e){if(e==null)return!1;let t=typeof e;return t!=="object"&&t!=="function"||!("~standard"in e)?!1:typeof e["~standard"]?.validate=="function"}var Q_=!1,Jf="draft-2020-12";function FR(e,t="input"){let o=e["~standard"],r;if(o.jsonSchema)r=o.jsonSchema[t]({target:Jf});else if(o.vendor==="zod"){if(!("_zod"in e))throw new 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().");Q_||(Q_=!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=Jo(e,{target:Jf,io:t})}else throw new 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")return r.type!==void 0?r:Mb(r)?{type:"object",...r}:r;if(r.type!==void 0&&r.type!=="object")throw new 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 Mb(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"||Mb(r)))}return!1}function HR(e){return e.path?.length?`${e.path.map(t=>String(typeof t=="object"?t.key:t)).join(".")}: ${e.message}`:e.message}async function Df(e,t){let o=await e["~standard"].validate(t);return o.issues&&o.issues.length>0?{success:!1,error:o.issues.map(r=>HR(r)).join(", ")}:{success:!0,data:o.value}}function VR(e){let t=Jo(e,{target:Jf,io:"input"});return typeof t.pattern=="string"?t.pattern:void 0}var JR=/\\\.\\d\{(\d+)\}/;function BR(e){let t=JR.exec(e),o=[void 0,-1,0];return t&&o.push(Number(t[1])),[!1,!0].flatMap(r=>[!1,!0].flatMap(n=>o.map(s=>Qe.datetime({local:r,offset:n,precision:s}))))}function WR(e,t){let o;switch(e){case"email":o=[Rl()];break;case"uri":o=[Qr()];break;case"date":o=[Qe.date()];break;case"date-time":o=BR(t);break}return new Set(o.map(r=>VR(r)).filter(r=>r!==void 0))}function KR(e,t,o){return o!=="zod"?!0:WR(e,t).has(t)}function Ma(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function GR(e){try{return FR(e,"input")}catch(t){let o=t instanceof Error?t.message:String(t);throw new se(B.InvalidParams,`Elicitation requestedSchema must describe an object with flat primitive properties: ${o}`)}}var YR=new Set(["$comment","deprecated","description","examples","readOnly","title","writeOnly"]);function sg(e){return YR.has(e)||e.startsWith("x-")}var XR=new Set(["$schema",...Object.keys(ar.shape.requestedSchema.shape)]),eb={string:Oa([sr,Tn,En,kn]),number:Oa([ir]),integer:Oa([ir]),boolean:Oa([Pn]),array:Oa([$n,Cn])},QR=new Set(sr.shape.format.unwrap().options);function ew(e,t,o,r){if(!Ma(e))return e;let n=typeof e.type=="string"&&Object.hasOwn(eb,e.type)?eb[e.type]:void 0;if(n===void 0)return e;let s={};for(let[i,a]of Object.entries(e))n.has(i)||sg(i)?s[i]=a:i==="pattern"&&e.type==="string"&&typeof e.format=="string"?QR.has(e.format)?(typeof a!="string"||!KR(e.format,a,o))&&r.push(`${t}.${i}`):s[i]=a:r.push(`${t}.${i}`);return s}function tw(e,t){let o={},r=[];for(let[n,s]of Object.entries(e))n==="properties"&&Ma(s)?o[n]=Object.fromEntries(Object.entries(s).map(([i,a])=>[i,ew(a,`properties.${i}`,t,r)])):XR.has(n)?o[n]=s:sg(n)||r.push(n);if(r.length>0)throw new se(B.InvalidParams,`Elicitation requestedSchema contains unsupported JSON Schema constraint(s) after Standard Schema conversion: ${r.join(", ")}`);return o}function ow(e,t){if(!Ma(e.properties))return t;let o=Object.entries(e.properties).filter(([,r])=>!xu(In,r).success).map(([r])=>`properties.${r}`);return o.length>0?o.join(", "):t}function Bf(e,t,o=""){return Array.isArray(e)&&Array.isArray(t)?e.flatMap((r,n)=>Bf(r,t[n],`${o}[${n}]`)):!Ma(e)||!Ma(t)?[]:Object.entries(e).flatMap(([r,n])=>{let s=o?`${o}.${r}`:r;return Object.prototype.hasOwnProperty.call(t,r)?Bf(n,t[r],s):sg(r)?[]:[s]})}function rw(e){if(!Vf(e.requestedSchema))return{...e,mode:"form",requestedSchema:e.requestedSchema};let t=e.requestedSchema["~standard"].vendor,o=tw(GR(e.requestedSchema),t),r=xu(ar.shape.requestedSchema,o);if(!r.success)throw new se(B.InvalidParams,`Elicitation requestedSchema only supports flat primitive properties (string, number, integer, boolean, and string enums): ${ow(o,r.error.message)}`);let n=Bf(o,r.data);if(n.length>0)throw new se(B.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 se(B.InvalidParams,`Elicitation requestedSchema lists required properties that are not defined in properties: ${s.join(", ")}`);return{...e,mode:"form",requestedSchema:r.data}}function nw(e){let t=e.inputRequests!==void 0&&Object.keys(e.inputRequests).length>0,o=typeof e.requestState=="string";if(!t&&!o)throw new 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 hE=Object.assign(nw,{elicit(e){try{return{method:"elicitation/create",params:rw(e)}}catch(t){throw t instanceof se?new 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 sw=!0,iw=10,aw=250;function Ab(e){return{autoFulfill:e?.autoFulfill??sw,maxRounds:e?.maxRounds??iw}}function cw(e,t,o){let r=t!==void 0&&Object.keys(t).length>0;return!r&&o===void 0?e:{...e,...r&&{inputResponses:t},...o!==void 0&&{requestState:o}}}function lw(e,t){return`Multi-round-trip request '${e}' still required input after ${t} rounds (inputRequired.maxRounds)`}function uw(e,t){return new Promise((o,r)=>{if(t?.aborted){r(t.reason instanceof M?t.reason:new M(q.RequestTimeout,String(t.reason)));return}let n=setTimeout(()=>{t?.removeEventListener("abort",s),o()},e),s=()=>{clearTimeout(n),r(t?.reason instanceof M?t.reason:new M(q.RequestTimeout,String(t?.reason)))};t?.addEventListener("abort",s,{once:!0})})}function dw(e){let t=new AbortController,o=()=>t.abort(e?.reason);return e?.addEventListener("abort",o,{once:!0}),e?.aborted&&t.abort(e.reason),{signal:t.signal,abort:r=>t.abort(r),dispose:()=>e?.removeEventListener("abort",o)}}async function pw(e){let{config:t,method:o,originalParams:r,requestOptions:n,hooks:s,signal:i}=e,a=e.flowStartedAt??Date.now(),l=e.firstPayload,u=0;for(;;){if(u+=1,u>t.maxRounds)throw new M(q.InputRequiredRoundsExceeded,lw(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 d=Object.entries(l.inputRequests??{}),h;if(d.length>0){let y=dw(i);try{let w=await Promise.all(d.map(async([z,H])=>{try{return[z,await s.dispatchInputRequest(z,H,y.signal)]}catch(W){throw y.abort(W),W}}));h=Object.fromEntries(w)}finally{y.dispose()}}else await uw(aw,i);let f={...n.timeout!==void 0&&{timeout:n.timeout}};if(n.maxTotalTimeout!==void 0){let y=Date.now()-a,w=n.maxTotalTimeout-y;if(w<=0)throw new M(q.RequestTimeout,"Maximum total timeout exceeded",{maxTotalTimeout:n.maxTotalTimeout,totalElapsed:y});f.maxTotalTimeout=w}let S=await s.retry(cw(r,h,l.requestState),f);if($b(S)){l={inputRequests:S.inputRequests??{},...S.requestState!==void 0&&{requestState:S.requestState}};continue}return S}}var hw=["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"],mw={IdJagTokenExchangeResponseSchema:ka,OAuthClientInformationFullSchema:An,OAuthClientInformationSchema:Ca,OAuthClientMetadataSchema:$a,OAuthClientRegistrationErrorSchema:fu,OAuthErrorResponseSchema:Mn,OAuthMetadataSchema:cr,OAuthProtectedResourceMetadataSchema:On,OAuthTokenRevocationRequestSchema:gu,OAuthTokensSchema:qn,OpenIdProviderDiscoveryMetadataSchema:Nn,OpenIdProviderMetadataSchema:Ea},jb={},Lb={};function Ub(e,t){let o=e.slice(0,-6);jb[o]=t,Lb[o]=r=>t.safeParse(r).success}for(let e of hw)Ub(e,IR[e]);for(let[e,t]of Object.entries(mw))Ub(e,t);var fw=Object.freeze(jb),Zb=Object.freeze(Lb);function gw(e){switch(e){case"initialize":case"notifications/initialized":return Qt(void 0);case"server/discover":return Qt(wu);default:return}}var Pu=6e4,Sw=[Jt,sn,Wo,an],_w=["inputResponses","requestState"];function tb(e,t){let o=e.params;if(!qa(o))return{message:e,lifted:{}};let r=o._meta,n=qa(r)?Sw.filter(l=>l in r):[],s=t==="request"?_w.filter(l=>l in o):[];if(n.length===0&&s.length===0)return{message:e,lifted:{}};let i={},a={...o};if(n.length>0&&qa(r)){let l={},u={...r};for(let d of n)l[d]=r[d],delete u[d];i.envelope=l,Object.keys(u).length>0?a._meta=u:delete a._meta}for(let l of s)l==="inputResponses"&&(i.inputResponses=a[l]),l==="requestState"&&(i.requestState=a[l]),delete a[l];return{message:{...e,params:a},lifted:i}}function ob(e,t){let o=e.validateResult(t,void 0);if(!(!o.ok&&o.reason==="not-in-era"))return{"~standard":{version:1,vendor:"mcp-wire-codec",validate(r){let n=e.validateResult(t,r);return n.ok?{value:n.value}:{issues:[{message:n.reason==="invalid"?n.message:`not-in-era: ${t}`}]}}}}}function ig(e){return()=>e}var bw=ig(void 0),yw,Tu=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{yw=(e,t)=>{e._negotiatedProtocolVersion=t}}_supportedProtocolVersions;onclose;onerror;fallbackRequestHandler;fallbackNotificationHandler;constructor(e){this._options=e,this._supportedProtocolVersions=e?.supportedProtocolVersions??Vl,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 M(q.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){e.params.requestId!==void 0&&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 M(q.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);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)=>{r?.(n,s),Ln(n)||Un(n)?this._onresponse(n):dr(n)?this._onrequest(n,s):kb(n)?this._onnotification(n,s):this._onerror(new 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 M(q.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}=tb(e,"notification"),r=this._negotiatedWireCodec();if(t?.classification===void 0&&this._shouldDropInbound(e)==="drop")return;if(t?.classification!==void 0){let i=K_(t.classification);if(i!==r.era){this._onerror(new Error(`Era mismatch on inbound notification '${o.method}': classified as ${i} but this instance serves ${r.era}`));return}}if(Zf(o.method)&&!r.hasNotificationMethod(o.method))return;let n=this._notificationHandlers.get(o.method),s=this.fallbackNotificationHandler;n===void 0&&s===void 0||Promise.resolve().then(()=>n===void 0?s(o):n(o,r)).catch(i=>this._onerror(new Error(`Uncaught error in notification handler: ${i}`)))}_onrequest(e,t){let{message:o,lifted:r}=tb(e,"request"),n=this._negotiatedWireCodec();if(t?.classification===void 0&&this._shouldDropInbound(e)==="drop"){this._onerror(new Error(`Dropped inbound request '${e.method}': not servable on this connection's protocol era`));return}let s=this._transport,i=(w,z,H)=>{let W={jsonrpc:"2.0",id:o.id,error:{code:w,message:z,...H!==void 0&&{data:H}}};s?.send(W).catch(N=>this._onerror(new Error(`Failed to send an error response: ${N}`)))};if(t?.classification!==void 0){let w=K_(t.classification);if(w!==n.era){this._onerror(new Error(`Era mismatch on inbound request '${o.method}': classified as ${w} but this instance serves ${n.era}`));let z=t.classification.revision??w;i(B.UnsupportedProtocolVersion,`Unsupported protocol version: ${z}`,{supported:this._supportedProtocolVersions,requested:z});return}}if(Uf(o.method)&&!n.hasRequestMethod(o.method)&&!(G_(o.method)&&this._customSchemaRequestMethods.has(o.method))){i(B.MethodNotFound,"Method not found");return}let a=this._requestHandlers.get(o.method)??this.fallbackRequestHandler;if(a===void 0){i(B.MethodNotFound,"Method not found");return}let l=n.checkInboundEnvelope(r);if(l!==void 0){i(B.InvalidParams,l);return}let u=(w,z)=>this._notificationViaCodec(this._resolveOutboundCodec(w.method),w,{...z,relatedRequestId:o.id}),d=(w,z,H)=>this._requestWithSchemaViaCodec(this._resolveOutboundCodec(w.method),w,z,{...H,relatedRequestId:o.id}),h=new AbortController;this._requestHandlerAbortControllers.set(o.id,h);let f=r.inputResponses===void 0?void 0:zw(r.inputResponses),S={sessionId:s?.sessionId,mcpReq:{id:o.id,method:o.method,_meta:o.params?._meta,...r.envelope!==void 0&&{envelope:r.envelope},...f!==void 0&&{inputResponses:f.accepted},...f!==void 0&&f.droppedKeys.length>0&&{droppedInputResponseKeys:f.droppedKeys},requestState:r.requestState===void 0?bw:ig(r.requestState),signal:h.signal,send:((w,z,H)=>{let W=this._resolveOutboundCodec(w.method);if(this._assertOutboundRequestInEra(W,w.method),Vf(z))return d(w,z,H);let N=ob(W,w.method);if(N===void 0)throw new TypeError(`'${w.method}' is not a spec method; pass a result schema as the second argument to ctx.mcpReq.send().`);return d(w,N,z)}),notify:u},http:t?.authInfo?{authInfo:t.authInfo}:void 0},y=this.buildContext(S,t);Promise.resolve().then(()=>a(o,y)).then(async w=>{if(h.signal.aborted)return;let z;try{z=n.encodeResult(o.method,w,this._outboundServerInfo())}catch(W){this._onerror(new Error(`Failed to encode result for ${o.method}: ${W}`)),i(B.InternalError,"Internal error");return}let H={result:z,jsonrpc:"2.0",id:o.id};await s?.send(H)},async w=>{if(h.signal.aborted)return;let z=Number.isSafeInteger(w.code)?w.code:B.InternalError,H={jsonrpc:"2.0",id:o.id,error:{code:n.encodeErrorCode(z),message:w.message??"Internal error",...w.data!==void 0&&{data:w.data}}};await s?.send(H)}).catch(w=>this._onerror(new Error(`Failed to send response: ${w}`))).finally(()=>{this._requestHandlerAbortControllers.get(o.id)===h&&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(new 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(a){this._responseHandlers.delete(r),this._progressHandlers.delete(r),this._cleanupTimeout(r),s(a);return}n(o)}_onresponse(e){let t=Number(e.id),o=this._responseHandlers.get(t);if(o===void 0){this._onerror(new Error(`Received a response for an unknown message ID: ${JSON.stringify(e)}`));return}this._responseHandlers.delete(t),this._cleanupTimeout(t),this._progressHandlers.delete(t),Ln(e)?o(e):o(se.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(Vf(t))return G_(e.method)||this._assertOutboundRequestInEra(r,e.method),this._requestWithSchemaViaCodec(r,e,t,o);this._assertOutboundRequestInEra(r,e.method);let n=ob(r,e.method);if(n===void 0)throw new 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 Qt(this._negotiatedProtocolVersion)}_wireCodec(){return this._negotiatedWireCodec()}_resolveOutboundCodec(e){if(this._negotiatedProtocolVersion===void 0){let t=gw(e);if(t)return t}return this._negotiatedWireCodec()}_assertOutboundRequestInEra(e,t){if(Uf(t)&&!e.hasRequestMethod(t))throw new M(q.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:a}=r??{},l=Date.now(),u,d;return new Promise((h,f)=>{let S=v=>{f(v)};if(!this._transport){S(new Error("Not connected"));return}if(this._options?.enforceStrictCapabilities===!0)try{this.assertCapabilityForMethod(t.method)}catch(v){S(v);return}if(r?.signal?.aborted){let v=r.signal.reason;throw v instanceof M?v:new M(q.RequestTimeout,String(v))}let y=e.era===wu&&this._transport.hasPerRequestStream===!0?new AbortController:void 0,w=this._requestMessageId++;d=w;let z={...t,jsonrpc:"2.0",id:w};r?.onprogress&&(this._progressHandlers.set(w,r.onprogress),z.params={...t.params,_meta:{...t.params?._meta,progressToken:w}});let H=this._envelopeOutbound(z),W=!1,N=v=>{W||(this._progressHandlers.delete(w),y===void 0?t.method!=="initialize"&&this._transport?.send(this._envelopeOutbound({jsonrpc:"2.0",method:"notifications/cancelled",params:{requestId:w,reason:String(v)}}),{relatedRequestId:n,resumptionToken:s,onresumptiontoken:i}).catch(Z=>this._onerror(new Error(`Failed to send cancellation: ${Z}`))):y.abort(),f(v instanceof M?v:new M(q.RequestTimeout,String(v))))};this._responseHandlers.set(w,v=>{if(r?.signal?.aborted)return;if(W=!0,v instanceof Error)return f(v);let Z;try{Z=e.decodeResult(t.method,v.result)}catch(ee){return f(ee instanceof Error?ee:new Error(String(ee)))}if(Z.kind==="invalid")return f(Z.error);if(Z.kind==="input_required"){if(r?.allowInputRequired===!0)return h(xw(Z));let ee={codec:e,request:t,resultSchema:o,options:r,flowStartedAt:l,retry:(de,$e)=>this._requestWithSchemaViaCodec(e,de===void 0?{method:t.method}:{method:t.method,params:de},o,$e)};return h(this._resolveNonCompleteResult(Z,ee))}let oe=Z.result;Df(o,oe).then(ee=>{ee.success?h(ee.data):f(new M(q.InvalidResult,`Invalid result for ${t.method}: ${ee.error}`))},f)}),u=()=>N(r?.signal?.reason),r?.signal?.addEventListener("abort",u,{once:!0});let D=r?.timeout??Pu,x=()=>N(new M(q.RequestTimeout,"Request timed out",{timeout:D}));this._setupTimeout(w,D,r?.maxTotalTimeout,x,r?.resetTimeoutOnProgress??!1),this._transport.send(H,{relatedRequestId:n,resumptionToken:s,onresumptiontoken:i,headers:a,requestSignal:y?.signal}).catch(v=>{this._progressHandlers.delete(w),f(v)})}).finally(()=>{u&&r?.signal?.removeEventListener("abort",u),d!==void 0&&(this._responseHandlers.delete(d),this._cleanupTimeout(d))})}async notification(e,t){return await this._notificationViaCodec(this._resolveOutboundCodec(e.method),e,t)}async _notificationViaCodec(e,t,o){if(!this._transport)throw new M(q.NotConnected,"Not connected");if(Zf(t.method)&&!e.hasNotificationMethod(t.method))throw new M(q.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(()=>{this._pendingDebouncedNotifications.delete(t.method),this._transport&&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(!Uf(e))throw new TypeError(`'${e}' is not a spec request method; pass schemas as the second argument to setRequestHandler().`);r=(n,s)=>{let i=this._negotiatedWireCodec(),a=i.validateRequest(e,n);if(!a.ok&&a.reason==="not-in-era"&&(a=i.validateInputRequest(e,n)),!a.ok)throw a.reason==="not-in-era"?new se(B.InternalError,`No wire schema for ${e} in the resolved era`):new Error(a.message);return Promise.resolve(t(a.value,s))}}else if(o)r=async(n,s)=>{let i=await Df(t.params,{...n.params});if(!i.success)throw new se(B.InvalidParams,`Invalid params for ${e}: ${i.error}`);return o(i.data,s)};else throw new TypeError("setRequestHandler: handler is required");typeof t=="function"?this._customSchemaRequestMethods.delete(e):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 new Error(`A request handler for ${e} already exists, which would be overridden`)}setNotificationHandler(e,t,o){if(typeof t=="function"){if(!Zf(e))throw new 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)throw s.reason==="not-in-era"?new se(B.InternalError,`No wire schema for ${e} in the resolved era`):new Error(s.message);return Promise.resolve(t(s.value))});return}if(!o)throw new TypeError("setNotificationHandler: handler is required");this._notificationHandlers.set(e,async r=>{let n=await Df(t.params,{...r.params});if(!n.success)throw new se(B.InvalidParams,`Invalid params for notification ${e}: ${n.error}`);await o(n.data,r)})}removeNotificationHandler(e){this._notificationHandlers.delete(e)}};function qa(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function Db(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]=qa(i)&&qa(s)?{...i,...s}:s}return o}function vu(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function zw(e){let t={},o=[];if(!vu(e))return{accepted:t,droppedKeys:o};for(let[r,n]of Object.entries(e)){if(!vu(n)||"method"in n||"result"in n){o.push(r);continue}t[r]=n}return{accepted:t,droppedKeys:o}}function rb(e){throw new M(q.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 vw(e,t,o,r,n){return{sessionId:n,mcpReq:{id:e,method:t,_meta:o?._meta,requestState:ig(void 0),signal:r,send:(()=>rb("send")),notify:()=>rb("notify")}}}async function Rw(e,t,o,r,n){if(!vu(r)||typeof r.method!="string")throw new M(q.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 M(q.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 M(q.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 a=vu(r.params)?r.params:void 0;return await i({jsonrpc:"2.0",id:o,method:s,...a!==void 0&&{params:a}},e.buildContext(vw(o,s,a,n,e.sessionId)))}function ww(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 Fb(e,t,o,r){let{codec:n,request:s,options:i,flowStartedAt:a}=r,l={inputRequests:o.inputRequests,...o.requestState!==void 0&&{requestState:o.requestState}},u={dispatchInputRequest:(d,h,f)=>Rw(e,n,d,h,f),retry:(d,h)=>r.retry(d,ww(i,h))};return pw({config:t,method:s.method,originalParams:s.params,firstPayload:l,flowStartedAt:a,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 xw(e){return{resultType:"input_required",inputRequests:e.inputRequests,...e.requestState!==void 0&&{requestState:e.requestState},...e._meta!==void 0&&{_meta:e._meta}}}var Pw=Ug((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(a){if(!a)throw new TypeError("argument string is required");var l=typeof a=="object"?s(a):a;if(typeof l!="string")throw new TypeError("argument string is required to be a string");var u=l.indexOf(";"),d=u!==-1?l.slice(0,u).trim():l.trim();if(!r.test(d))throw new TypeError("invalid media type");var h=new i(d.toLowerCase());if(u!==-1){var f,S,y;for(t.lastIndex=u;S=t.exec(l);){if(S.index!==u)throw new TypeError("invalid parameter format");u+=S[0].length,f=S[1].toLowerCase(),y=S[2],y.charCodeAt(0)===34&&(y=y.slice(1,-1),y.indexOf("\\")!==-1&&(y=y.replace(o,"$1"))),h.parameters[f]=y}if(u!==l.length)throw new TypeError("invalid parameter format")}return h}function s(a){var l;if(typeof a.getHeader=="function"?l=a.getHeader("content-type"):typeof a.headers=="object"&&(l=a.headers&&a.headers["content-type"]),typeof l!="string")throw new TypeError("content-type header is missing from object");return l}function i(a){this.parameters=Object.create(null),this.type=a}})),Tw=Dg(Pw(),1);function Hb(e){if(e)try{return Tw.parse(e).type}catch{let t=(e.split(";",1)[0]??"").trim().toLowerCase();return t===""||e.slice(t.length).includes(",")?void 0:t}}var Ew=10*1024*1024;function nb(e){return e?e instanceof Headers?Object.fromEntries(e.entries()):Array.isArray(e)?Object.fromEntries(e):{...e}:{}}function Vb(e=fetch,t){return t?async(o,r)=>e(o,{...t,...r,headers:r?.headers?{...nb(t.headers),...nb(r.headers)}:t.headers}):e}var kw=new Set([301,302,303,307,308]),$w=5;function Cw(e,t){return e.protocol===t.protocol&&e.host===t.host?!0:e.protocol==="http:"&&t.protocol==="https:"&&e.hostname===t.hostname&&!e.port&&!t.port}function Jb(e,t){let o=kw.has(t.status)?t.headers?.get("location"):void 0;if(o)try{return new URL(o,e)}catch{return}}var Bb=new WeakSet;function Wb(e){let t=(o,r)=>e(o,r);return Bb.add(t),t}function ja(e){return Bb.has(e)?e:async(t,o)=>{if(o?.redirect==="error"||o?.redirect==="manual")return e(t,o);let r=(o?.method??"GET").toUpperCase(),n=t;for(let s=0;;s++){let i=await e(n,{...o,redirect:"manual"}),a=Jb(n,i);if(!a||s===$w)return i;let l=new URL(n),u=r==="GET"||i.status===307||i.status===308,d=!(a.username||a.password)||a.username===l.username&&a.password===l.password;if(!u||!d||!Cw(l,a))return i;await i.text?.().catch(()=>{}),n=a}}}function Kb(e,t){if(t.type==="opaqueredirect")return"Redirect not followed: this runtime does not expose where it points";let o=Jb(t.url||e,t);if(o)return o.username=o.password=o.search=o.hash="",o.protocol==="http:"&&new URL(t.url||e).protocol==="https:"?(o.protocol="https:",`Redirect from https to plain http not followed; try ${o.href} as the endpoint`):`Redirect to ${o.href} not followed; use that URL as the endpoint if it is the intended server`}function La(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(!La(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(!La(e[s],t[s]))return!1;return!0}return e===t}function ft(e){return encodeURI(Iw(e))}function Iw(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}var Ow={prefixItems:!0,items:!0,allOf:!0,anyOf:!0,oneOf:!0},Nw={$defs:!0,definitions:!0,properties:!0,patternProperties:!0,dependentSchemas:!0},qw={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},Mw=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 pr(e,t=Object.create(null),o=Mw,r=""){if(e&&typeof e=="object"&&!Array.isArray(e)){let s=e.$id||e.id;if(s){let i=new URL(s,o.href);i.hash.length>1?t[i.href]=e:(i.hash="",r===""?o=i:pr(e,t,o))}}else if(e!==!0&&e!==!1)return t;let n=o.href+(r?"#"+r:"");if(t[n]!==void 0)throw new 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}),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(qw[s])continue;let i=`${r}/${ft(s)}`,a=e[s];if(Array.isArray(a)){if(Ow[s]){let l=a.length;for(let u=0;u<l;u++)pr(a[u],t,o,`${i}/${u}`)}}else if(Nw[s])for(let l in a)pr(a[l],t,o,`${i}/${ft(l)}`);else pr(a,t,o,i)}return t}var Aw=/^(\d\d\d\d)-(\d\d)-(\d\d)$/,jw=[0,31,28,31,30,31,30,31,31,30,31,30,31],Lw=/^(\d\d):(\d\d):(\d\d)(\.\d+)?(z|[+-]\d\d(?::?\d\d)?)?$/i,Uw=/^(?=.{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,Zw=/^(?:[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,Dw=/^(?:(?:[^\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,Fw=/^(?:(?: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,Hw=/^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i,Vw=/^(?:\/(?:[^~/]|~0|~1)*)*$/,Jw=/^#(?:\/(?:[a-z0-9_\-.!$&'()*+,;:=@]|%[0-9a-f]{2}|~0|~1)*)*$/i,Bw=/^(?:0|[1-9][0-9]*)(?:#|(?:\/(?:[^~/]|~0|~1)*)*)$/,Ww=e=>{if(e[0]==='"')return!1;let[t,o,...r]=e.split("@");return!t||!o||r.length!==0||t.length>64||o.length>253||t[0]==="."||t.endsWith(".")||t.includes("..")||!/^[a-z0-9.-]+$/i.test(o)||!/^[a-z0-9.!#$%&'*+/=?^_`{|}~-]+$/i.test(t)?!1:o.split(".").every(n=>/^[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?$/i.test(n))},Kw=/^(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)$/,Gw=/^((([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,Yw=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 Mt(e){return e.test.bind(e)}var Gb={date:Yb,time:Xb.bind(void 0,!1),"date-time":ex,duration:Yw,uri:rx,"uri-reference":Mt(Zw),"uri-template":Mt(Dw),url:Mt(Fw),email:Ww,hostname:Mt(Uw),ipv4:Mt(Kw),ipv6:Mt(Gw),regex:sx,uuid:Mt(Hw),"json-pointer":Mt(Vw),"json-pointer-uri-fragment":Mt(Jw),"relative-json-pointer":Mt(Bw)};function Xw(e){return e%4===0&&(e%100!==0||e%400===0)}function Yb(e){let t=e.match(Aw);if(!t)return!1;let o=+t[1],r=+t[2],n=+t[3];return r>=1&&r<=12&&n>=1&&n<=(r==2&&Xw(o)?29:jw[r])}function Xb(e,t){let o=t.match(Lw);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 Qw=/t|\s/i;function ex(e){let t=e.split(Qw);return t.length==2&&Yb(t[0])&&Xb(!0,t[1])}var tx=/\/|:/,ox=/^(?:[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 rx(e){return tx.test(e)&&ox.test(e)}var nx=/[^\\]\\Z/;function sx(e){if(nx.test(e))return!1;try{return new RegExp(e,"u"),!0}catch{return!1}}function ix(e){let t=0,o=e.length,r=0,n;for(;r<o;)t++,n=e.charCodeAt(r++),n>=55296&&n<=56319&&r<o&&(n=e.charCodeAt(r),(n&64512)==56320&&r++);return t}function fe(e,t,o="2019-09",r=pr(t),n=!0,s=null,i="#",a="#",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,d;switch(u){case"boolean":case"number":case"string":d=u;break;case"object":e===null?d="null":Array.isArray(e)?d="array":d="object";break;default:throw new Error(`Instances of "${u}" type are not supported.`)}let{$ref:h,$recursiveRef:f,$recursiveAnchor:S,type:y,const:w,enum:z,required:H,not:W,anyOf:N,allOf:D,oneOf:x,if:v,then:Z,else:oe,format:ee,properties:de,patternProperties:$e,additionalProperties:ie,unevaluatedProperties:ue,minProperties:ze,maxProperties:Ce,propertyNames:_t,dependentRequired:Ue,dependentSchemas:ot,dependencies:bt,prefixItems:Je,items:Ie,additionalItems:jt,unevaluatedItems:Lt,contains:yt,minContains:xe,maxContains:Oe,minItems:Ne,maxItems:ct,uniqueItems:Eo,minimum:Be,maximum:We,exclusiveMinimum:Ze,exclusiveMaximum:rt,multipleOf:nt,minLength:zt,maxLength:vt,pattern:no,__absolute_ref__:Rt,__absolute_recursive_ref__:ko}=t,I=[];if(S===!0&&s===null&&(s=t),f==="#"){let F=s===null?r[ko]:s,A=`${a}/$recursiveRef`,X=fe(e,s===null?t:s,o,r,n,F,i,A,l);X.valid||I.push({instanceLocation:i,keyword:"$recursiveRef",keywordLocation:A,error:"A subschema had errors."},...X.errors)}if(h!==void 0){let F=r[Rt||h];if(F===void 0){let O=`Unresolved $ref "${h}".`;throw Rt&&Rt!==h&&(O+=` Absolute URI "${Rt}".`),O+=`
66
66
  Known schemas:
67
67
  - ${Object.keys(r).join(`
68
- - `)}`,new Error(O)}let A=`${a}/$ref`,X=fe(e,F,o,r,n,s,i,A,l);if(X.valid||I.push({instanceLocation:i,keyword:"$ref",keywordLocation:A,error:"A subschema had errors."},...X.errors),o==="4"||o==="7")return{valid:I.length===0,errors:I}}if(Array.isArray(y)){let F=y.length,A=!1;for(let X=0;X<F;X++)if(d===y[X]||y[X]==="integer"&&d==="number"&&e%1===0&&e===e){A=!0;break}A||I.push({instanceLocation:i,keyword:"type",keywordLocation:`${a}/type`,error:`Instance type "${d}" is invalid. Expected "${y.join('", "')}".`})}else y==="integer"?(d!=="number"||e%1||e!==e)&&I.push({instanceLocation:i,keyword:"type",keywordLocation:`${a}/type`,error:`Instance type "${d}" is invalid. Expected "${y}".`}):y!==void 0&&d!==y&&I.push({instanceLocation:i,keyword:"type",keywordLocation:`${a}/type`,error:`Instance type "${d}" is invalid. Expected "${y}".`});if(w!==void 0&&(d==="object"||d==="array"?La(e,w)||I.push({instanceLocation:i,keyword:"const",keywordLocation:`${a}/const`,error:`Instance does not match ${JSON.stringify(w)}.`}):e!==w&&I.push({instanceLocation:i,keyword:"const",keywordLocation:`${a}/const`,error:`Instance does not match ${JSON.stringify(w)}.`})),z!==void 0&&(d==="object"||d==="array"?z.some(F=>La(e,F))||I.push({instanceLocation:i,keyword:"enum",keywordLocation:`${a}/enum`,error:`Instance does not match any of ${JSON.stringify(z)}.`}):z.some(F=>e===F)||I.push({instanceLocation:i,keyword:"enum",keywordLocation:`${a}/enum`,error:`Instance does not match any of ${JSON.stringify(z)}.`})),W!==void 0){let F=`${a}/not`;fe(e,W,o,r,n,s,i,F).valid&&I.push({instanceLocation:i,keyword:"not",keywordLocation:F,error:'Instance matched "not" schema.'})}let wt=[];if(N!==void 0){let F=`${a}/anyOf`,A=I.length,X=!1;for(let O=0;O<N.length;O++){let E=N[O],J=Object.create(l),V=fe(e,E,o,r,n,S===!0?s:null,i,`${F}/${O}`,J);I.push(...V.errors),X=X||V.valid,V.valid&&wt.push(J)}X?I.length=A:I.splice(A,0,{instanceLocation:i,keyword:"anyOf",keywordLocation:F,error:"Instance does not match any subschemas."})}if(D!==void 0){let F=`${a}/allOf`,A=I.length,X=!0;for(let O=0;O<D.length;O++){let E=D[O],J=Object.create(l),V=fe(e,E,o,r,n,S===!0?s:null,i,`${F}/${O}`,J);I.push(...V.errors),X=X&&V.valid,V.valid&&wt.push(J)}X?I.length=A:I.splice(A,0,{instanceLocation:i,keyword:"allOf",keywordLocation:F,error:"Instance does not match every subschema."})}if(x!==void 0){let F=`${a}/oneOf`,A=I.length,X=x.filter((O,E)=>{let J=Object.create(l),V=fe(e,O,o,r,n,S===!0?s:null,i,`${F}/${E}`,J);return I.push(...V.errors),V.valid&&wt.push(J),V.valid}).length;X===1?I.length=A:I.splice(A,0,{instanceLocation:i,keyword:"oneOf",keywordLocation:F,error:`Instance does not match exactly one subschema (${X} matches).`})}if((d==="object"||d==="array")&&Object.assign(l,...wt),v!==void 0){let F=`${a}/if`;if(fe(e,v,o,r,n,s,i,F,l).valid){if(Z!==void 0){let A=fe(e,Z,o,r,n,s,i,`${a}/then`,l);A.valid||I.push({instanceLocation:i,keyword:"if",keywordLocation:F,error:'Instance does not match "then" schema.'},...A.errors)}}else if(oe!==void 0){let A=fe(e,oe,o,r,n,s,i,`${a}/else`,l);A.valid||I.push({instanceLocation:i,keyword:"if",keywordLocation:F,error:'Instance does not match "else" schema.'},...A.errors)}}if(d==="object"){if(H!==void 0)for(let O of H)O in e||I.push({instanceLocation:i,keyword:"required",keywordLocation:`${a}/required`,error:`Instance does not have required property "${O}".`});let F=Object.keys(e);if(ze!==void 0&&F.length<ze&&I.push({instanceLocation:i,keyword:"minProperties",keywordLocation:`${a}/minProperties`,error:`Instance does not have at least ${ze} properties.`}),Ce!==void 0&&F.length>Ce&&I.push({instanceLocation:i,keyword:"maxProperties",keywordLocation:`${a}/maxProperties`,error:`Instance does not have at least ${Ce} properties.`}),_t!==void 0){let O=`${a}/propertyNames`;for(let E in e){let J=`${i}/${ft(E)}`,V=fe(E,_t,o,r,n,s,J,O);V.valid||I.push({instanceLocation:i,keyword:"propertyNames",keywordLocation:O,error:`Property name "${E}" does not match schema.`},...V.errors)}}if(Ue!==void 0){let O=`${a}/dependantRequired`;for(let E in Ue)if(E in e){let J=Ue[E];for(let V of J)V in e||I.push({instanceLocation:i,keyword:"dependentRequired",keywordLocation:O,error:`Instance has "${E}" but does not have "${V}".`})}}if(ot!==void 0)for(let O in ot){let E=`${a}/dependentSchemas`;if(O in e){let J=fe(e,ot[O],o,r,n,s,i,`${E}/${ft(O)}`,l);J.valid||I.push({instanceLocation:i,keyword:"dependentSchemas",keywordLocation:E,error:`Instance has "${O}" but does not match dependant schema.`},...J.errors)}}if(bt!==void 0){let O=`${a}/dependencies`;for(let E in bt)if(E in e){let J=bt[E];if(Array.isArray(J))for(let V of J)V in e||I.push({instanceLocation:i,keyword:"dependencies",keywordLocation:O,error:`Instance has "${E}" but does not have "${V}".`});else{let V=fe(e,J,o,r,n,s,i,`${O}/${ft(E)}`);V.valid||I.push({instanceLocation:i,keyword:"dependencies",keywordLocation:O,error:`Instance has "${E}" but does not match dependant schema.`},...V.errors)}}}let A=Object.create(null),X=!1;if(de!==void 0){let O=`${a}/properties`;for(let E in de){if(!(E in e))continue;let J=`${i}/${ft(E)}`,V=fe(e[E],de[E],o,r,n,s,J,`${O}/${ft(E)}`);if(V.valid)l[E]=A[E]=!0;else if(X=n,I.push({instanceLocation:i,keyword:"properties",keywordLocation:O,error:`Property "${E}" does not match schema.`},...V.errors),X)break}}if(!X&&$e!==void 0){let O=`${a}/patternProperties`;for(let E in $e){let J=new RegExp(E,"u"),V=$e[E];for(let _e in e){if(!J.test(_e))continue;let $o=`${i}/${ft(_e)}`,xt=fe(e[_e],V,o,r,n,s,$o,`${O}/${ft(E)}`);xt.valid?l[_e]=A[_e]=!0:(X=n,I.push({instanceLocation:i,keyword:"patternProperties",keywordLocation:O,error:`Property "${_e}" matches pattern "${E}" but does not match associated schema.`},...xt.errors))}}}if(!X&&ie!==void 0){let O=`${a}/additionalProperties`;for(let E in e){if(A[E])continue;let J=`${i}/${ft(E)}`,V=fe(e[E],ie,o,r,n,s,J,O);V.valid?l[E]=!0:(X=n,I.push({instanceLocation:i,keyword:"additionalProperties",keywordLocation:O,error:`Property "${E}" does not match additional properties schema.`},...V.errors))}}else if(!X&&ue!==void 0){let O=`${a}/unevaluatedProperties`;for(let E in e)if(!l[E]){let J=`${i}/${ft(E)}`,V=fe(e[E],ue,o,r,n,s,J,O);V.valid?l[E]=!0:I.push({instanceLocation:i,keyword:"unevaluatedProperties",keywordLocation:O,error:`Property "${E}" does not match unevaluated properties schema.`},...V.errors)}}}else if(d==="array"){ct!==void 0&&e.length>ct&&I.push({instanceLocation:i,keyword:"maxItems",keywordLocation:`${a}/maxItems`,error:`Array has too many items (${e.length} > ${ct}).`}),Ne!==void 0&&e.length<Ne&&I.push({instanceLocation:i,keyword:"minItems",keywordLocation:`${a}/minItems`,error:`Array has too few items (${e.length} < ${Ne}).`});let F=e.length,A=0,X=!1;if(Je!==void 0){let O=`${a}/prefixItems`,E=Math.min(Je.length,F);for(;A<E;A++){let J=fe(e[A],Je[A],o,r,n,s,`${i}/${A}`,`${O}/${A}`);if(l[A]=!0,!J.valid&&(X=n,I.push({instanceLocation:i,keyword:"prefixItems",keywordLocation:O,error:"Items did not match schema."},...J.errors),X))break}}if(Ie!==void 0){let O=`${a}/items`;if(Array.isArray(Ie)){let E=Math.min(Ie.length,F);for(;A<E;A++){let J=fe(e[A],Ie[A],o,r,n,s,`${i}/${A}`,`${O}/${A}`);if(l[A]=!0,!J.valid&&(X=n,I.push({instanceLocation:i,keyword:"items",keywordLocation:O,error:"Items did not match schema."},...J.errors),X))break}}else for(;A<F;A++){let E=fe(e[A],Ie,o,r,n,s,`${i}/${A}`,O);if(l[A]=!0,!E.valid&&(X=n,I.push({instanceLocation:i,keyword:"items",keywordLocation:O,error:"Items did not match schema."},...E.errors),X))break}if(!X&&jt!==void 0){let E=`${a}/additionalItems`;for(;A<F;A++){let J=fe(e[A],jt,o,r,n,s,`${i}/${A}`,E);l[A]=!0,J.valid||(X=n,I.push({instanceLocation:i,keyword:"additionalItems",keywordLocation:E,error:"Items did not match additional items schema."},...J.errors))}}}if(yt!==void 0)if(F===0&&xe===void 0)I.push({instanceLocation:i,keyword:"contains",keywordLocation:`${a}/contains`,error:"Array is empty. It must contain at least one item matching the schema."});else if(xe!==void 0&&F<xe)I.push({instanceLocation:i,keyword:"minContains",keywordLocation:`${a}/minContains`,error:`Array has less items (${F}) than minContains (${xe}).`});else{let O=`${a}/contains`,E=I.length,J=0;for(let V=0;V<F;V++){let _e=fe(e[V],yt,o,r,n,s,`${i}/${V}`,O);_e.valid?(l[V]=!0,J++):I.push(..._e.errors)}J>=(xe||0)&&(I.length=E),xe===void 0&&Oe===void 0&&J===0?I.splice(E,0,{instanceLocation:i,keyword:"contains",keywordLocation:O,error:"Array does not contain item matching schema."}):xe!==void 0&&J<xe?I.push({instanceLocation:i,keyword:"minContains",keywordLocation:`${a}/minContains`,error:`Array must contain at least ${xe} items matching schema. Only ${J} items were found.`}):Oe!==void 0&&J>Oe&&I.push({instanceLocation:i,keyword:"maxContains",keywordLocation:`${a}/maxContains`,error:`Array may contain at most ${Oe} items matching schema. ${J} items were found.`})}if(!X&&Lt!==void 0){let O=`${a}/unevaluatedItems`;for(;A<F;A++){if(l[A])continue;let E=fe(e[A],Lt,o,r,n,s,`${i}/${A}`,O);l[A]=!0,E.valid||I.push({instanceLocation:i,keyword:"unevaluatedItems",keywordLocation:O,error:"Items did not match unevaluated items schema."},...E.errors)}}if(Eo)for(let O=0;O<F;O++){let E=e[O],J=typeof E=="object"&&E!==null;for(let V=0;V<F;V++){if(O===V)continue;let _e=e[V];(E===_e||J&&typeof _e=="object"&&_e!==null&&La(E,_e))&&(I.push({instanceLocation:i,keyword:"uniqueItems",keywordLocation:`${a}/uniqueItems`,error:`Duplicate items at indexes ${O} and ${V}.`}),O=Number.MAX_SAFE_INTEGER,V=Number.MAX_SAFE_INTEGER)}}}else if(d==="number"){if(o==="4"?(Be!==void 0&&(Ze===!0&&e<=Be||e<Be)&&I.push({instanceLocation:i,keyword:"minimum",keywordLocation:`${a}/minimum`,error:`${e} is less than ${Ze?"or equal to ":""} ${Be}.`}),We!==void 0&&(rt===!0&&e>=We||e>We)&&I.push({instanceLocation:i,keyword:"maximum",keywordLocation:`${a}/maximum`,error:`${e} is greater than ${rt?"or equal to ":""} ${We}.`})):(Be!==void 0&&e<Be&&I.push({instanceLocation:i,keyword:"minimum",keywordLocation:`${a}/minimum`,error:`${e} is less than ${Be}.`}),We!==void 0&&e>We&&I.push({instanceLocation:i,keyword:"maximum",keywordLocation:`${a}/maximum`,error:`${e} is greater than ${We}.`}),Ze!==void 0&&e<=Ze&&I.push({instanceLocation:i,keyword:"exclusiveMinimum",keywordLocation:`${a}/exclusiveMinimum`,error:`${e} is less than ${Ze}.`}),rt!==void 0&&e>=rt&&I.push({instanceLocation:i,keyword:"exclusiveMaximum",keywordLocation:`${a}/exclusiveMaximum`,error:`${e} is greater than or equal to ${rt}.`})),nt!==void 0){let F=e%nt;Math.abs(0-F)>=11920929e-14&&Math.abs(nt-F)>=11920929e-14&&I.push({instanceLocation:i,keyword:"multipleOf",keywordLocation:`${a}/multipleOf`,error:`${e} is not a multiple of ${nt}.`})}}else if(d==="string"){let F=zt===void 0&&vt===void 0?0:ix(e);zt!==void 0&&F<zt&&I.push({instanceLocation:i,keyword:"minLength",keywordLocation:`${a}/minLength`,error:`String is too short (${F} < ${zt}).`}),vt!==void 0&&F>vt&&I.push({instanceLocation:i,keyword:"maxLength",keywordLocation:`${a}/maxLength`,error:`String is too long (${F} > ${vt}).`}),no!==void 0&&!new RegExp(no,"u").test(e)&&I.push({instanceLocation:i,keyword:"pattern",keywordLocation:`${a}/pattern`,error:"String does not match pattern."}),ee!==void 0&&Kb[ee]&&!Kb[ee](e)&&I.push({instanceLocation:i,keyword:"format",keywordLocation:`${a}/format`,error:`String does not match format "${ee}".`})}return{valid:I.length===0,errors:I}}var ax=class{schema;draft;shortCircuit;lookup;constructor(e,t="2019-09",o=!0){this.schema=e,this.draft=t,this.shortCircuit=o,this.lookup=pr(e)}validate(e){return fe(e,this.schema,this.draft,this.lookup,this.shortCircuit)}addSchema(e,t){t&&(e={...e,$id:t}),pr(e,this.lookup)}},ig=class{shortcircuit;draft;constructor(e){this.shortcircuit=e?.shortcircuit??!0,this.draft=e?.draft}_draftFor(e){let t=Hg(e,"pass an explicit { draft } to CfWorkerJsonSchemaValidator to validate other dialects.");return t==="draft-7"?"7":t}getValidator(e){let t=new ax(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 Xb=!0;var ag;ag=globalThis.crypto;async function cx(e){return(await ag).getRandomValues(new Uint8Array(e))}async function lx(e){let t="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-._~",o=Math.pow(2,8)-Math.pow(2,8)%t.length,r="";for(;r.length<e;){let n=await cx(e-r.length);for(let s of n)s<o&&(r+=t[s%t.length])}return r}async function ux(e){return await lx(e)}async function dx(e){let t=await(await ag).subtle.digest("SHA-256",new TextEncoder().encode(e));return btoa(String.fromCharCode(...new Uint8Array(t))).replace(/\//g,"_").replace(/\+/g,"-").replace(/=/g,"")}async function cg(e){if(e||(e=43),e<43||e>128)throw`Expected a length between 43 and 128. Received ${e}.`;let t=await ux(e),o=await dx(t);return{code_verifier:t,code_challenge:o}}var Ua=class extends Error{constructor(t,o){super(t),this.name="ParseError",this.type=o.type,this.field=o.field,this.value=o.value,this.line=o.line}},Qb=10,px=13,hr=32;function lg(e){}function oy(e){if(typeof e=="function")throw new TypeError("`config` must be an object, got a function instead. Did you mean `createParser({onEvent: fn})`?");let{onEvent:t=lg,onError:o=lg,onRetry:r=lg,onComment:n,maxBufferSize:s}=e,i=[],a=0,l=!0,u,d="",h=0,f,S=!1;function y(x){if(S)throw new Error("Cannot feed parser: it was terminated after exceeding the configured max buffer size. Call `reset()` to resume parsing.");if(l&&(l=!1,x.charCodeAt(0)===239&&x.charCodeAt(1)===187&&x.charCodeAt(2)===191&&(x=x.slice(3))),i.length===0){let oe=z(x);oe!==""&&(i.push(oe),a=oe.length),w();return}if(x.indexOf(`
68
+ - `)}`,new Error(O)}let A=`${a}/$ref`,X=fe(e,F,o,r,n,s,i,A,l);if(X.valid||I.push({instanceLocation:i,keyword:"$ref",keywordLocation:A,error:"A subschema had errors."},...X.errors),o==="4"||o==="7")return{valid:I.length===0,errors:I}}if(Array.isArray(y)){let F=y.length,A=!1;for(let X=0;X<F;X++)if(d===y[X]||y[X]==="integer"&&d==="number"&&e%1===0&&e===e){A=!0;break}A||I.push({instanceLocation:i,keyword:"type",keywordLocation:`${a}/type`,error:`Instance type "${d}" is invalid. Expected "${y.join('", "')}".`})}else y==="integer"?(d!=="number"||e%1||e!==e)&&I.push({instanceLocation:i,keyword:"type",keywordLocation:`${a}/type`,error:`Instance type "${d}" is invalid. Expected "${y}".`}):y!==void 0&&d!==y&&I.push({instanceLocation:i,keyword:"type",keywordLocation:`${a}/type`,error:`Instance type "${d}" is invalid. Expected "${y}".`});if(w!==void 0&&(d==="object"||d==="array"?La(e,w)||I.push({instanceLocation:i,keyword:"const",keywordLocation:`${a}/const`,error:`Instance does not match ${JSON.stringify(w)}.`}):e!==w&&I.push({instanceLocation:i,keyword:"const",keywordLocation:`${a}/const`,error:`Instance does not match ${JSON.stringify(w)}.`})),z!==void 0&&(d==="object"||d==="array"?z.some(F=>La(e,F))||I.push({instanceLocation:i,keyword:"enum",keywordLocation:`${a}/enum`,error:`Instance does not match any of ${JSON.stringify(z)}.`}):z.some(F=>e===F)||I.push({instanceLocation:i,keyword:"enum",keywordLocation:`${a}/enum`,error:`Instance does not match any of ${JSON.stringify(z)}.`})),W!==void 0){let F=`${a}/not`;fe(e,W,o,r,n,s,i,F).valid&&I.push({instanceLocation:i,keyword:"not",keywordLocation:F,error:'Instance matched "not" schema.'})}let wt=[];if(N!==void 0){let F=`${a}/anyOf`,A=I.length,X=!1;for(let O=0;O<N.length;O++){let E=N[O],J=Object.create(l),V=fe(e,E,o,r,n,S===!0?s:null,i,`${F}/${O}`,J);I.push(...V.errors),X=X||V.valid,V.valid&&wt.push(J)}X?I.length=A:I.splice(A,0,{instanceLocation:i,keyword:"anyOf",keywordLocation:F,error:"Instance does not match any subschemas."})}if(D!==void 0){let F=`${a}/allOf`,A=I.length,X=!0;for(let O=0;O<D.length;O++){let E=D[O],J=Object.create(l),V=fe(e,E,o,r,n,S===!0?s:null,i,`${F}/${O}`,J);I.push(...V.errors),X=X&&V.valid,V.valid&&wt.push(J)}X?I.length=A:I.splice(A,0,{instanceLocation:i,keyword:"allOf",keywordLocation:F,error:"Instance does not match every subschema."})}if(x!==void 0){let F=`${a}/oneOf`,A=I.length,X=x.filter((O,E)=>{let J=Object.create(l),V=fe(e,O,o,r,n,S===!0?s:null,i,`${F}/${E}`,J);return I.push(...V.errors),V.valid&&wt.push(J),V.valid}).length;X===1?I.length=A:I.splice(A,0,{instanceLocation:i,keyword:"oneOf",keywordLocation:F,error:`Instance does not match exactly one subschema (${X} matches).`})}if((d==="object"||d==="array")&&Object.assign(l,...wt),v!==void 0){let F=`${a}/if`;if(fe(e,v,o,r,n,s,i,F,l).valid){if(Z!==void 0){let A=fe(e,Z,o,r,n,s,i,`${a}/then`,l);A.valid||I.push({instanceLocation:i,keyword:"if",keywordLocation:F,error:'Instance does not match "then" schema.'},...A.errors)}}else if(oe!==void 0){let A=fe(e,oe,o,r,n,s,i,`${a}/else`,l);A.valid||I.push({instanceLocation:i,keyword:"if",keywordLocation:F,error:'Instance does not match "else" schema.'},...A.errors)}}if(d==="object"){if(H!==void 0)for(let O of H)O in e||I.push({instanceLocation:i,keyword:"required",keywordLocation:`${a}/required`,error:`Instance does not have required property "${O}".`});let F=Object.keys(e);if(ze!==void 0&&F.length<ze&&I.push({instanceLocation:i,keyword:"minProperties",keywordLocation:`${a}/minProperties`,error:`Instance does not have at least ${ze} properties.`}),Ce!==void 0&&F.length>Ce&&I.push({instanceLocation:i,keyword:"maxProperties",keywordLocation:`${a}/maxProperties`,error:`Instance does not have at least ${Ce} properties.`}),_t!==void 0){let O=`${a}/propertyNames`;for(let E in e){let J=`${i}/${ft(E)}`,V=fe(E,_t,o,r,n,s,J,O);V.valid||I.push({instanceLocation:i,keyword:"propertyNames",keywordLocation:O,error:`Property name "${E}" does not match schema.`},...V.errors)}}if(Ue!==void 0){let O=`${a}/dependantRequired`;for(let E in Ue)if(E in e){let J=Ue[E];for(let V of J)V in e||I.push({instanceLocation:i,keyword:"dependentRequired",keywordLocation:O,error:`Instance has "${E}" but does not have "${V}".`})}}if(ot!==void 0)for(let O in ot){let E=`${a}/dependentSchemas`;if(O in e){let J=fe(e,ot[O],o,r,n,s,i,`${E}/${ft(O)}`,l);J.valid||I.push({instanceLocation:i,keyword:"dependentSchemas",keywordLocation:E,error:`Instance has "${O}" but does not match dependant schema.`},...J.errors)}}if(bt!==void 0){let O=`${a}/dependencies`;for(let E in bt)if(E in e){let J=bt[E];if(Array.isArray(J))for(let V of J)V in e||I.push({instanceLocation:i,keyword:"dependencies",keywordLocation:O,error:`Instance has "${E}" but does not have "${V}".`});else{let V=fe(e,J,o,r,n,s,i,`${O}/${ft(E)}`);V.valid||I.push({instanceLocation:i,keyword:"dependencies",keywordLocation:O,error:`Instance has "${E}" but does not match dependant schema.`},...V.errors)}}}let A=Object.create(null),X=!1;if(de!==void 0){let O=`${a}/properties`;for(let E in de){if(!(E in e))continue;let J=`${i}/${ft(E)}`,V=fe(e[E],de[E],o,r,n,s,J,`${O}/${ft(E)}`);if(V.valid)l[E]=A[E]=!0;else if(X=n,I.push({instanceLocation:i,keyword:"properties",keywordLocation:O,error:`Property "${E}" does not match schema.`},...V.errors),X)break}}if(!X&&$e!==void 0){let O=`${a}/patternProperties`;for(let E in $e){let J=new RegExp(E,"u"),V=$e[E];for(let _e in e){if(!J.test(_e))continue;let $o=`${i}/${ft(_e)}`,xt=fe(e[_e],V,o,r,n,s,$o,`${O}/${ft(E)}`);xt.valid?l[_e]=A[_e]=!0:(X=n,I.push({instanceLocation:i,keyword:"patternProperties",keywordLocation:O,error:`Property "${_e}" matches pattern "${E}" but does not match associated schema.`},...xt.errors))}}}if(!X&&ie!==void 0){let O=`${a}/additionalProperties`;for(let E in e){if(A[E])continue;let J=`${i}/${ft(E)}`,V=fe(e[E],ie,o,r,n,s,J,O);V.valid?l[E]=!0:(X=n,I.push({instanceLocation:i,keyword:"additionalProperties",keywordLocation:O,error:`Property "${E}" does not match additional properties schema.`},...V.errors))}}else if(!X&&ue!==void 0){let O=`${a}/unevaluatedProperties`;for(let E in e)if(!l[E]){let J=`${i}/${ft(E)}`,V=fe(e[E],ue,o,r,n,s,J,O);V.valid?l[E]=!0:I.push({instanceLocation:i,keyword:"unevaluatedProperties",keywordLocation:O,error:`Property "${E}" does not match unevaluated properties schema.`},...V.errors)}}}else if(d==="array"){ct!==void 0&&e.length>ct&&I.push({instanceLocation:i,keyword:"maxItems",keywordLocation:`${a}/maxItems`,error:`Array has too many items (${e.length} > ${ct}).`}),Ne!==void 0&&e.length<Ne&&I.push({instanceLocation:i,keyword:"minItems",keywordLocation:`${a}/minItems`,error:`Array has too few items (${e.length} < ${Ne}).`});let F=e.length,A=0,X=!1;if(Je!==void 0){let O=`${a}/prefixItems`,E=Math.min(Je.length,F);for(;A<E;A++){let J=fe(e[A],Je[A],o,r,n,s,`${i}/${A}`,`${O}/${A}`);if(l[A]=!0,!J.valid&&(X=n,I.push({instanceLocation:i,keyword:"prefixItems",keywordLocation:O,error:"Items did not match schema."},...J.errors),X))break}}if(Ie!==void 0){let O=`${a}/items`;if(Array.isArray(Ie)){let E=Math.min(Ie.length,F);for(;A<E;A++){let J=fe(e[A],Ie[A],o,r,n,s,`${i}/${A}`,`${O}/${A}`);if(l[A]=!0,!J.valid&&(X=n,I.push({instanceLocation:i,keyword:"items",keywordLocation:O,error:"Items did not match schema."},...J.errors),X))break}}else for(;A<F;A++){let E=fe(e[A],Ie,o,r,n,s,`${i}/${A}`,O);if(l[A]=!0,!E.valid&&(X=n,I.push({instanceLocation:i,keyword:"items",keywordLocation:O,error:"Items did not match schema."},...E.errors),X))break}if(!X&&jt!==void 0){let E=`${a}/additionalItems`;for(;A<F;A++){let J=fe(e[A],jt,o,r,n,s,`${i}/${A}`,E);l[A]=!0,J.valid||(X=n,I.push({instanceLocation:i,keyword:"additionalItems",keywordLocation:E,error:"Items did not match additional items schema."},...J.errors))}}}if(yt!==void 0)if(F===0&&xe===void 0)I.push({instanceLocation:i,keyword:"contains",keywordLocation:`${a}/contains`,error:"Array is empty. It must contain at least one item matching the schema."});else if(xe!==void 0&&F<xe)I.push({instanceLocation:i,keyword:"minContains",keywordLocation:`${a}/minContains`,error:`Array has less items (${F}) than minContains (${xe}).`});else{let O=`${a}/contains`,E=I.length,J=0;for(let V=0;V<F;V++){let _e=fe(e[V],yt,o,r,n,s,`${i}/${V}`,O);_e.valid?(l[V]=!0,J++):I.push(..._e.errors)}J>=(xe||0)&&(I.length=E),xe===void 0&&Oe===void 0&&J===0?I.splice(E,0,{instanceLocation:i,keyword:"contains",keywordLocation:O,error:"Array does not contain item matching schema."}):xe!==void 0&&J<xe?I.push({instanceLocation:i,keyword:"minContains",keywordLocation:`${a}/minContains`,error:`Array must contain at least ${xe} items matching schema. Only ${J} items were found.`}):Oe!==void 0&&J>Oe&&I.push({instanceLocation:i,keyword:"maxContains",keywordLocation:`${a}/maxContains`,error:`Array may contain at most ${Oe} items matching schema. ${J} items were found.`})}if(!X&&Lt!==void 0){let O=`${a}/unevaluatedItems`;for(;A<F;A++){if(l[A])continue;let E=fe(e[A],Lt,o,r,n,s,`${i}/${A}`,O);l[A]=!0,E.valid||I.push({instanceLocation:i,keyword:"unevaluatedItems",keywordLocation:O,error:"Items did not match unevaluated items schema."},...E.errors)}}if(Eo)for(let O=0;O<F;O++){let E=e[O],J=typeof E=="object"&&E!==null;for(let V=0;V<F;V++){if(O===V)continue;let _e=e[V];(E===_e||J&&typeof _e=="object"&&_e!==null&&La(E,_e))&&(I.push({instanceLocation:i,keyword:"uniqueItems",keywordLocation:`${a}/uniqueItems`,error:`Duplicate items at indexes ${O} and ${V}.`}),O=Number.MAX_SAFE_INTEGER,V=Number.MAX_SAFE_INTEGER)}}}else if(d==="number"){if(o==="4"?(Be!==void 0&&(Ze===!0&&e<=Be||e<Be)&&I.push({instanceLocation:i,keyword:"minimum",keywordLocation:`${a}/minimum`,error:`${e} is less than ${Ze?"or equal to ":""} ${Be}.`}),We!==void 0&&(rt===!0&&e>=We||e>We)&&I.push({instanceLocation:i,keyword:"maximum",keywordLocation:`${a}/maximum`,error:`${e} is greater than ${rt?"or equal to ":""} ${We}.`})):(Be!==void 0&&e<Be&&I.push({instanceLocation:i,keyword:"minimum",keywordLocation:`${a}/minimum`,error:`${e} is less than ${Be}.`}),We!==void 0&&e>We&&I.push({instanceLocation:i,keyword:"maximum",keywordLocation:`${a}/maximum`,error:`${e} is greater than ${We}.`}),Ze!==void 0&&e<=Ze&&I.push({instanceLocation:i,keyword:"exclusiveMinimum",keywordLocation:`${a}/exclusiveMinimum`,error:`${e} is less than ${Ze}.`}),rt!==void 0&&e>=rt&&I.push({instanceLocation:i,keyword:"exclusiveMaximum",keywordLocation:`${a}/exclusiveMaximum`,error:`${e} is greater than or equal to ${rt}.`})),nt!==void 0){let F=e%nt;Math.abs(0-F)>=11920929e-14&&Math.abs(nt-F)>=11920929e-14&&I.push({instanceLocation:i,keyword:"multipleOf",keywordLocation:`${a}/multipleOf`,error:`${e} is not a multiple of ${nt}.`})}}else if(d==="string"){let F=zt===void 0&&vt===void 0?0:ix(e);zt!==void 0&&F<zt&&I.push({instanceLocation:i,keyword:"minLength",keywordLocation:`${a}/minLength`,error:`String is too short (${F} < ${zt}).`}),vt!==void 0&&F>vt&&I.push({instanceLocation:i,keyword:"maxLength",keywordLocation:`${a}/maxLength`,error:`String is too long (${F} > ${vt}).`}),no!==void 0&&!new RegExp(no,"u").test(e)&&I.push({instanceLocation:i,keyword:"pattern",keywordLocation:`${a}/pattern`,error:"String does not match pattern."}),ee!==void 0&&Gb[ee]&&!Gb[ee](e)&&I.push({instanceLocation:i,keyword:"format",keywordLocation:`${a}/format`,error:`String does not match format "${ee}".`})}return{valid:I.length===0,errors:I}}var ax=class{schema;draft;shortCircuit;lookup;constructor(e,t="2019-09",o=!0){this.schema=e,this.draft=t,this.shortCircuit=o,this.lookup=pr(e)}validate(e){return fe(e,this.schema,this.draft,this.lookup,this.shortCircuit)}addSchema(e,t){t&&(e={...e,$id:t}),pr(e,this.lookup)}},ag=class{shortcircuit;draft;constructor(e){this.shortcircuit=e?.shortcircuit??!0,this.draft=e?.draft}_draftFor(e){let t=Vg(e,"pass an explicit { draft } to CfWorkerJsonSchemaValidator to validate other dialects.");return t==="draft-7"?"7":t}getValidator(e){let t=new ax(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 Qb=!0;var cg;cg=globalThis.crypto;async function cx(e){return(await cg).getRandomValues(new Uint8Array(e))}async function lx(e){let t="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-._~",o=Math.pow(2,8)-Math.pow(2,8)%t.length,r="";for(;r.length<e;){let n=await cx(e-r.length);for(let s of n)s<o&&(r+=t[s%t.length])}return r}async function ux(e){return await lx(e)}async function dx(e){let t=await(await cg).subtle.digest("SHA-256",new TextEncoder().encode(e));return btoa(String.fromCharCode(...new Uint8Array(t))).replace(/\//g,"_").replace(/\+/g,"-").replace(/=/g,"")}async function lg(e){if(e||(e=43),e<43||e>128)throw`Expected a length between 43 and 128. Received ${e}.`;let t=await ux(e),o=await dx(t);return{code_verifier:t,code_challenge:o}}var Ua=class extends Error{constructor(t,o){super(t),this.name="ParseError",this.type=o.type,this.field=o.field,this.value=o.value,this.line=o.line}},ey=10,px=13,hr=32;function ug(e){}function ry(e){if(typeof e=="function")throw new TypeError("`config` must be an object, got a function instead. Did you mean `createParser({onEvent: fn})`?");let{onEvent:t=ug,onError:o=ug,onRetry:r=ug,onComment:n,maxBufferSize:s}=e,i=[],a=0,l=!0,u,d="",h=0,f,S=!1;function y(x){if(S)throw new Error("Cannot feed parser: it was terminated after exceeding the configured max buffer size. Call `reset()` to resume parsing.");if(l&&(l=!1,x.charCodeAt(0)===239&&x.charCodeAt(1)===187&&x.charCodeAt(2)===191&&(x=x.slice(3))),i.length===0){let oe=z(x);oe!==""&&(i.push(oe),a=oe.length),w();return}if(x.indexOf(`
69
69
  `)===-1&&x.indexOf("\r")===-1){i.push(x),a+=x.length,w();return}i.push(x);let v=i.join("");i.length=0,a=0;let Z=z(v);Z!==""&&(i.push(Z),a=Z.length),w()}function w(){s!==void 0&&(a+d.length<=s||(S=!0,i.length=0,a=0,u=void 0,d="",h=0,f=void 0,o(new Ua(`Buffered data exceeded max buffer size of ${s} characters`,{type:"max-buffer-size-exceeded"}))))}function z(x){let v=0;if(x.indexOf("\r")===-1){let Z=x.indexOf(`
70
70
  `,v);for(;Z!==-1;){if(v===Z){h>0&&t({id:u,event:f,data:d}),u=void 0,d="",h=0,f=void 0,v=Z+1,Z=x.indexOf(`
71
- `,v);continue}let oe=x.charCodeAt(v);if(ey(x,v,oe)){let ee=x.charCodeAt(v+5)===hr?v+6:v+5,de=x.slice(ee,Z);if(h===0&&x.charCodeAt(Z+1)===Qb){t({id:u,event:f,data:de}),u=void 0,d="",f=void 0,v=Z+2,Z=x.indexOf(`
71
+ `,v);continue}let oe=x.charCodeAt(v);if(ty(x,v,oe)){let ee=x.charCodeAt(v+5)===hr?v+6:v+5,de=x.slice(ee,Z);if(h===0&&x.charCodeAt(Z+1)===ey){t({id:u,event:f,data:de}),u=void 0,d="",f=void 0,v=Z+2,Z=x.indexOf(`
72
72
  `,v);continue}d=h===0?de:`${d}
73
- ${de}`,h++}else ty(x,v,oe)?f=x.slice(x.charCodeAt(v+6)===hr?v+7:v+6,Z)||void 0:H(x,v,Z);v=Z+1,Z=x.indexOf(`
73
+ ${de}`,h++}else oy(x,v,oe)?f=x.slice(x.charCodeAt(v+6)===hr?v+7:v+6,Z)||void 0:H(x,v,Z);v=Z+1,Z=x.indexOf(`
74
74
  `,v)}return x.slice(v)}for(;v<x.length;){let Z=x.indexOf("\r",v),oe=x.indexOf(`
75
- `,v),ee=-1;if(Z!==-1&&oe!==-1?ee=Z<oe?Z:oe:Z!==-1?Z===x.length-1?ee=-1:ee=Z:oe!==-1&&(ee=oe),ee===-1)break;H(x,v,ee),v=ee+1,x.charCodeAt(v-1)===px&&x.charCodeAt(v)===Qb&&v++}return x.slice(v)}function H(x,v,Z){if(v===Z){N();return}let oe=x.charCodeAt(v);if(ey(x,v,oe)){let ze=x.charCodeAt(v+5)===hr?v+6:v+5,Ce=x.slice(ze,Z);d=h===0?Ce:`${d}
76
- ${Ce}`,h++;return}if(ty(x,v,oe)){f=x.slice(x.charCodeAt(v+6)===hr?v+7:v+6,Z)||void 0;return}if(oe===105&&x.charCodeAt(v+1)===100&&x.charCodeAt(v+2)===58){let ze=x.slice(x.charCodeAt(v+3)===hr?v+4:v+3,Z);ze.includes("\0")||(u=ze);return}if(oe===58){if(n){let ze=x.slice(v,Z);n(ze.slice(x.charCodeAt(v+1)===hr?2:1))}return}let ee=x.slice(v,Z),de=ee.indexOf(":");if(de===-1){W(ee,"",ee);return}let $e=ee.slice(0,de),ie=ee.charCodeAt(de+1)===hr?2:1,ue=ee.slice(de+ie);W($e,ue,ee)}function W(x,v,Z){switch(x){case"event":f=v||void 0;break;case"data":d=h===0?v:`${d}
77
- ${v}`,h++;break;case"id":v.includes("\0")||(u=v);break;case"retry":/^\d+$/.test(v)?r(parseInt(v,10)):o(new Ua(`Invalid \`retry\` value: "${v}"`,{type:"invalid-retry",value:v,line:Z}));break;default:o(new Ua(`Unknown field "${x.length>20?`${x.slice(0,20)}\u2026`:x}"`,{type:"unknown-field",field:x,value:v,line:Z}));break}}function N(){h>0&&t({id:u,event:f,data:d}),u=void 0,d="",h=0,f=void 0}function D(x={}){if(x.consume&&i.length>0){let v=i.join("");H(v,0,v.length)}l=!0,u=void 0,d="",h=0,f=void 0,i.length=0,a=0,S=!1}return{feed:y,reset:D}}function ey(e,t,o){return o===100&&e.charCodeAt(t+1)===97&&e.charCodeAt(t+2)===116&&e.charCodeAt(t+3)===97&&e.charCodeAt(t+4)===58}function ty(e,t,o){return o===101&&e.charCodeAt(t+1)===118&&e.charCodeAt(t+2)===101&&e.charCodeAt(t+3)===110&&e.charCodeAt(t+4)===116&&e.charCodeAt(t+5)===58}var Tu=class extends TransformStream{constructor({onError:t,onRetry:o,onComment:r,maxBufferSize:n}={}){let s;super({start(i){s=oy({onEvent:a=>{i.enqueue(a)},onError(a){typeof t=="function"&&t(a),(t==="terminate"||a.type==="max-buffer-size-exceeded")&&i.error(a)},onRetry:o,onComment:r,maxBufferSize:n})},transform(i){s.feed(i)}})}};var Da=class extends Error{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.OAuthClientFlowError"})}static[Symbol.hasInstance](e){return et(this,e)}static isInstance(e){if(typeof this!="function")throw new TypeError("isInstance must be called on the class (e.g. `SdkError.isInstance(value)`); for callbacks use `v => SdkError.isInstance(v)`");return et(this,e)}constructor(e){super(e),this.name=new.target.name,lr(this,new.target)}},gg=class extends Da{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 \xA73.3)":"authorization response (RFC 9207)"}: expected ${JSON.stringify(t)}, received ${JSON.stringify(o)}`),this.kind=e,this.expected=t,this.received=o}},hx=class extends Da{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}},fy=class extends Da{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}},$u=class extends Da{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}},ry=class extends Da{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}};function Sg(e,t,o){if(e)return typeof e.issuer!="string"?(o?.canPersistStamp!==!1&&console.warn("[mcp-sdk] SEP-2352: stored OAuth credential has no 'issuer' stamp (pre-upgrade storage or provider not round-tripping the value). SEP-2352 isolation is inactive for this read; ensure your provider round-trips the issuer field."),e.issuer===void 0?e:{...e,issuer:void 0}):gy(e.issuer,t)?e:void 0}function gy(e,t){return e===t||e.endsWith("/")&&e.slice(0,-1)===t||t.endsWith("/")&&t.slice(0,-1)===e}function mx(e){if(e==null)return!1;let t=e;return typeof t.tokens=="function"&&typeof t.clientInformation=="function"}async function fx(e,t,o){let{resourceMetadataUrl:r,scope:n}=Za(t.response);if(await _g(e,{serverUrl:t.serverUrl,resourceMetadataUrl:r,scope:n,fetchFn:t.fetchFn,...o})!=="AUTHORIZED")throw new At}function gx(e,t){return{token:async()=>(await e.tokens())?.access_token,onUnauthorized:async o=>fx(e,o,t)}}var At=class extends Error{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.UnauthorizedError"})}static[Symbol.hasInstance](e){return et(this,e)}static isInstance(e){if(typeof this!="function")throw new TypeError("isInstance must be called on the class (e.g. `SdkError.isInstance(value)`); for callbacks use `v => SdkError.isInstance(v)`");return et(this,e)}constructor(e){super(e??"Unauthorized"),this.name="UnauthorizedError",lr(this,new.target)}};function yg(e){return e?.authorization_response_iss_parameter_supported===!0}function zg({iss:e,expectedIssuer:t,issParameterSupported:o}){if(t!==void 0){if(e===void 0){if(o)throw new gg("authorization_response",t,void 0);return}if(e!==t)throw new gg("authorization_response",t,e)}}function ug(...e){let t=new Set;for(let o of e)if(o)for(let r of o.split(/\s+/))r&&t.add(r);return t.size>0?[...t].join(" "):void 0}function Sx(e,t){if(!e)return!1;let o=new Set((t??"").split(/\s+/).filter(Boolean));for(let r of e.split(/\s+/))if(r&&!o.has(r))return!0;return!1}async function _x(e,t,o,r,n){if(typeof e=="string")return{authorizationCode:e,iss:t};let s=e.get("iss")??void 0,i=e.get("code");if(i)return{authorizationCode:i,iss:s};let a=(await o.discoveryState?.())?.authorizationServerMetadata;if(!a)try{a=(await zy(r,n)).authorizationServerMetadata}catch{a=void 0}if(!a)throw new At("Authorization callback failed and the issuer could not be verified");zg({iss:s,expectedIssuer:a.issuer,issParameterSupported:yg(a)});let l=e.get("error");throw l?new ur(l,e.get("error_description")??l,e.get("error_uri")??void 0):new At("Authorization callback contained neither `code` nor `error`")}function bx(e){return["client_secret_basic","client_secret_post","none"].includes(e)}var dg="code",pg="S256";function yx(e,t){let o=e.client_secret!==void 0;return"token_endpoint_auth_method"in e&&e.token_endpoint_auth_method&&bx(e.token_endpoint_auth_method)&&(t.length===0||t.includes(e.token_endpoint_auth_method))?e.token_endpoint_auth_method:t.length===0?o?"client_secret_basic":"none":o&&t.includes("client_secret_basic")?"client_secret_basic":o&&t.includes("client_secret_post")?"client_secret_post":t.includes("none")?"none":o?"client_secret_post":"none"}function zx(e,t,o,r){let{client_id:n,client_secret:s}=t;switch(e){case"client_secret_basic":vx(n,s,o);return;case"client_secret_post":Rx(n,s,r);return;case"none":wx(n,r);return;default:throw new Error(`Unsupported client authentication method: ${e}`)}}function vx(e,t,o){if(!t)throw new Error("client_secret_basic authentication requires a client_secret");let r=btoa(`${e}:${t}`);o.set("Authorization",`Basic ${r}`)}function Rx(e,t,o){o.set("client_id",e),t&&o.set("client_secret",t)}function wx(e,t){t.set("client_id",e)}function Sy(e){return e==="localhost"||e.endsWith(".localhost")||e==="127.0.0.1"||e==="[::1]"||e==="::1"}function xx(e){let t=new URL(String(e));if(t.protocol!=="https:"&&!Sy(t.hostname))throw new fy(t.href);return t}function Px(e){for(let t of e??[]){let o;try{o=new URL(t)}catch{continue}if(o.protocol!=="http:"&&o.protocol!=="https:"||Sy(o.hostname))return"native"}return"web"}function Tx(e){let t=e.clientMetadata;return{...t,grant_types:t.grant_types??(e.redirectUrl===void 0?void 0:["authorization_code","refresh_token"]),application_type:t.application_type??Px(t.redirect_uris)}}async function ny(e){let t=e instanceof Response?e.status:void 0,o=e instanceof Response?await e.text():e;try{let r=qn.parse(JSON.parse(o));return ur.fromResponse(r)}catch(r){let n=`${t?`HTTP ${t}: `:""}Invalid OAuth error response: ${r}. Raw body: ${o}`;return new ur(eo.ServerError,n)}}function sy(e,t,o){let r=e.invalidateCredentials===void 0?`retrying authorization without discarding the stored ${o} (provider implements no invalidateCredentials())`:`invalidating the stored ${o} and retrying authorization`;console.warn(`[mcp-sdk] OAuth ${JSON.stringify(t.code)} \u2014 ${r}. Cause: ${JSON.stringify(t.message)}`)}async function _g(e,t){try{return await hg(e,t)}catch(o){if(o instanceof ur){if(o.code===eo.InvalidClient||o.code===eo.UnauthorizedClient)return sy(e,o,"client credentials and tokens"),await e.invalidateCredentials?.("client"),await e.invalidateCredentials?.("tokens"),await hg(e,t);if(o.code===eo.InvalidGrant||o.code===eo.InvalidDpopProof)return sy(e,o,"tokens"),await e.invalidateCredentials?.("tokens"),await hg(e,t)}throw o}}function Ex(e){let{requestedScope:t,resourceMetadata:o,authServerMetadata:r,clientMetadata:n}=e,s=t||o?.scopes_supported?.join(" ")||n.scope;return s&&r?.scopes_supported?.includes("offline_access")&&!s.split(" ").includes("offline_access")&&n.grant_types?.includes("refresh_token")&&(s=`${s} offline_access`),s}async function hg(e,{serverUrl:t,authorizationCode:o,iss:r,scope:n,resourceMetadataUrl:s,fetchFn:i,skipIssuerMetadataValidation:a,forceReauthorization:l}){let u=Tx(e),d=await e.discoveryState?.(),h,f,S,y,w=s;if(!w&&d?.resourceMetadataUrl&&(w=new URL(d.resourceMetadataUrl)),d?.authorizationServerUrl){if(f=d.authorizationServerUrl,h=d.resourceMetadata,S=d.authorizationServerMetadata??await yy(f,{fetchFn:i,skipIssuerValidation:a}),!h)try{h=await _y(t,{resourceMetadataUrl:w},i)}catch(ie){if(ie instanceof TypeError)throw ie}(S!==d.authorizationServerMetadata||h!==d.resourceMetadata)&&await e.saveDiscoveryState?.({authorizationServerUrl:String(f),resourceMetadataUrl:w?.toString(),resourceMetadata:h,authorizationServerMetadata:S})}else{let ie=await zy(t,{resourceMetadataUrl:w,fetchFn:i,skipIssuerMetadataValidation:a});f=ie.authorizationServerUrl,S=ie.authorizationServerMetadata,h=ie.resourceMetadata,y={authorizationServerUrl:String(f),resourceMetadataUrl:w?.toString(),resourceMetadata:h,authorizationServerMetadata:S}}let z=S?.issuer??String(f),H={issuer:z};if(await e.saveAuthorizationServerUrl?.(z),o!==void 0){let ie=d?.authorizationServerMetadata?.issuer??d?.authorizationServerUrl;if(ie===void 0){if(e.saveDiscoveryState!==void 0)throw new $u("discoveryState was not available on the callback leg; ensure your provider persists discoveryState alongside codeVerifier",z);console.warn("[mcp-sdk] OAuthClientProvider does not implement saveDiscoveryState()/discoveryState(); the SEP-2352 callback-leg authorization-server binding cannot be checked. Implement discoveryState (persist alongside codeVerifier) \u2014 see docs/migration/upgrade-to-v2.md \xA7SEP-2352.")}else if(!gy(ie,z))throw new $u(ie,z)}y&&await e.saveDiscoveryState?.(y);let W=await $x(t,e,h),N=W&&h&&!e.validateResourceURL?h.resource:W;N&&await e.saveResourceUrl?.(vg(N));let D=Ex({requestedScope:n,resourceMetadata:h,authServerMetadata:S,clientMetadata:e.clientMetadata}),x=await Promise.resolve(e.clientInformation(H)),v=Sg(x,z,{canPersistStamp:e.saveClientInformation!==void 0});if(v===void 0&&x?.issuer&&e.saveClientInformation===void 0)throw new $u(x.issuer,z);if(v&&v.issuer===void 0&&(v={...v,issuer:z},await e.saveClientInformation?.(v,H)),!v){if(o!==void 0)throw new Error("Existing OAuth client information is required when exchanging an authorization code");let ie=S?.client_id_metadata_document_supported===!0,ue=e.clientMetadataUrl;if(ue&&!kx(ue))throw new ur(eo.InvalidClientMetadata,`clientMetadataUrl must be a valid HTTPS URL with a non-root pathname, got: ${ue}`);if(ie&&ue)v={client_id:ue,issuer:z},await e.saveClientInformation?.(v,H);else{if(!e.saveClientInformation)throw new Error("OAuth client information must be saveable for dynamic registration");v={...await Ux(f,{metadata:S,clientMetadata:u,scope:D,fetchFn:i}),issuer:z},await e.saveClientInformation(v,H)}}let Z=!e.redirectUrl;if(o!==void 0||Z){o!==void 0&&zg({iss:r,expectedIssuer:S?.issuer,issParameterSupported:yg(S)});let ie=await Lx(e,f,{metadata:S,resource:N,authorizationCode:o,iss:r,scope:D,fetchFn:i});return await e.saveTokens({...ie,issuer:z},H),"AUTHORIZED"}let oe=Sg(await e.tokens(H),z);if(oe&&oe.issuer===void 0&&(oe={...oe,issuer:z},await e.saveTokens(oe,H)),oe?.refresh_token&&!l){let ie;try{ie=await jx(f,{metadata:S,clientInformation:v,refreshToken:oe.refresh_token,resource:N,addClientAuthentication:e.addClientAuthentication,dpop:await e.dpop?.(),fetchFn:i})}catch(ue){if(ue instanceof fy)throw ue;if(!(ue instanceof ur)||ue.code===eo.ServerError)console.warn(`[mcp-sdk] Could not refresh OAuth tokens; falling back to a new authorization request. Cause: ${JSON.stringify(ue instanceof Error?ue.message:String(ue))}`);else throw ue}if(ie)return await e.saveTokens({...ie,issuer:z},H),"AUTHORIZED"}let ee=e.state?await e.state():void 0,{authorizationUrl:de,codeVerifier:$e}=await Mx(f,{metadata:S,clientInformation:v,state:ee,redirectUrl:e.redirectUrl,scope:D,resource:N});return await e.saveCodeVerifier($e),await e.redirectToAuthorization(de),"REDIRECT"}function kx(e){if(!e)return!1;try{let t=new URL(e);return t.protocol==="https:"&&t.pathname!=="/"}catch{return!1}}async function $x(e,t,o){let r=sb(e);if(t.validateResourceURL)return await t.validateResourceURL(r,o?.resource);if(o){if(!ib({requestedResource:r,configuredResource:o.resource}))throw new Error(`Protected resource ${o.resource} does not match expected ${r} (or origin)`);return new URL(o.resource)}}var Cx=new Set(["bearer","dpop"]);function Za(e){let t=e.headers.get("WWW-Authenticate");if(!t)return{};let[o,r]=t.split(" ");if(!o||!Cx.has(o.toLowerCase())||!r)return{};let n=Eu(e,"resource_metadata")||void 0,s;if(n)try{s=new URL(n)}catch{}let i=Eu(e,"scope")||void 0,a=Eu(e,"error")||void 0,l=Eu(e,"error_description")||void 0;return{resourceMetadataUrl:s,scope:i,error:a,errorDescription:l}}function Eu(e,t){let o=e.headers.get("WWW-Authenticate");if(!o)return null;let r=new RegExp(String.raw`${t}=(?:"([^"]+)"|([^\s,]+))`),n=o.match(r);if(n){let s=n[1]||n[2];if(s)return s}return null}async function _y(e,t,o=fetch){let r=await Nx(e,"oauth-protected-resource",o,{protocolVersion:t?.protocolVersion,metadataUrl:t?.resourceMetadataUrl});if(!r||r.status===404)throw await r?.text?.().catch(()=>{}),new Error("Resource server does not implement OAuth 2.0 Protected Resource Metadata.");if(!r.ok)throw await r.text?.().catch(()=>{}),new Error(`HTTP ${r.status} trying to load well-known OAuth protected resource metadata.`);return In.parse(await r.json())}async function by(e,t,o=fetch){let r=ja(o);try{return await r(e,{headers:t})}catch(n){if(!(n instanceof TypeError)||!Xb)throw n;if(t)try{return await r(e,{})}catch(s){if(!(s instanceof TypeError))throw s;return}return}}function Ix(e,t="",o={}){return t.endsWith("/")&&(t=t.slice(0,-1)),o.prependPathname?`${t}/.well-known/${e}`:`/.well-known/${e}${t}`}async function iy(e,t,o=fetch){return await by(e,{"MCP-Protocol-Version":t},o)}function Ox(e,t){return e?t==="/"?!1:!e.ok&&e.status<500||e.status===502:!0}async function Nx(e,t,o,r){let n=new URL(e),s=r?.protocolVersion??rn,i;if(r?.metadataUrl)i=new URL(r.metadataUrl);else{let l=Ix(t,n.pathname);i=new URL(l,r?.metadataServerUrl??n),i.search=n.search}let a=await iy(i,s,o);return!r?.metadataUrl&&Ox(a,n.pathname)&&(a=await iy(new URL(`/.well-known/${t}`,n),s,o)),a}function qx(e){let t=typeof e=="string"?new URL(e):e,o=t.pathname!=="/",r=[];if(!o)return r.push({url:new URL("/.well-known/oauth-authorization-server",t.origin),type:"oauth"},{url:new URL("/.well-known/openid-configuration",t.origin),type:"oidc"}),r;let n=t.pathname;return n.endsWith("/")&&(n=n.slice(0,-1)),r.push({url:new URL(`/.well-known/oauth-authorization-server${n}`,t.origin),type:"oauth"},{url:new URL(`/.well-known/openid-configuration${n}`,t.origin),type:"oidc"},{url:new URL(`${n}/.well-known/openid-configuration`,t.origin),type:"oidc"}),r}async function yy(e,{fetchFn:t=fetch,protocolVersion:o=rn,skipIssuerValidation:r=!1}={}){let n={"MCP-Protocol-Version":o,Accept:"application/json"},s=qx(e);for(let{url:i,type:a}of s){let l=await by(i,n,t);if(!l)continue;if(!l.ok){if(await l.text?.().catch(()=>{}),l.status<500||l.status===502)continue;throw new Error(`HTTP ${l.status} trying to load ${a==="oauth"?"OAuth":"OpenID provider"} metadata from ${i}`)}let u=a==="oauth"?cr.parse(await l.json()):On.parse(await l.json());if(!r){let d=typeof e=="string"?e:e.href;if(!(u.issuer===d||d.endsWith("/")&&u.issuer===d.slice(0,-1)))throw new gg("metadata",d,u.issuer)}return u}}async function zy(e,t){let o,r;try{o=await _y(e,{resourceMetadataUrl:t?.resourceMetadataUrl},t?.fetchFn),o.authorization_servers&&o.authorization_servers.length>0&&(r=o.authorization_servers[0])}catch(s){if(s instanceof TypeError)throw s}r||(r=String(new URL("/",e)));let n=await yy(r,{fetchFn:t?.fetchFn,skipIssuerValidation:t?.skipIssuerMetadataValidation});return{authorizationServerUrl:r,authorizationServerMetadata:n,resourceMetadata:o}}function vg(e){return typeof e=="string"?e:e.href}async function Mx(e,{metadata:t,clientInformation:o,redirectUrl:r,scope:n,state:s,resource:i}){let a;if(t){if(a=new URL(t.authorization_endpoint),!t.response_types_supported.includes(dg))throw new Error(`Incompatible auth server: does not support response type ${dg}`);if(t.code_challenge_methods_supported&&!t.code_challenge_methods_supported.includes(pg))throw new Error(`Incompatible auth server: does not support code challenge method ${pg}`)}else a=new URL("/authorize",e);let l=await cg(),u=l.code_verifier,d=l.code_challenge;return a.searchParams.set("response_type",dg),a.searchParams.set("client_id",o.client_id),a.searchParams.set("code_challenge",d),a.searchParams.set("code_challenge_method",pg),a.searchParams.set("redirect_uri",String(r)),s&&a.searchParams.set("state",s),n&&a.searchParams.set("scope",n),n?.split(" ").includes("offline_access")&&a.searchParams.append("prompt","consent"),i&&a.searchParams.set("resource",vg(i)),{authorizationUrl:a,codeVerifier:u}}function Ax(e,t,o){return new URLSearchParams({grant_type:"authorization_code",code:e,code_verifier:t,redirect_uri:String(o)})}async function vy(e,{metadata:t,tokenRequestParams:o,clientInformation:r,addClientAuthentication:n,resource:s,dpop:i,fetchFn:a}){let l=xx(t?.token_endpoint??new URL("/token",e)),u=new Headers({"Content-Type":"application/x-www-form-urlencoded",Accept:"application/json"});s&&o.set("resource",vg(s)),!n&&r&&zx(yx(r,t?.token_endpoint_auth_methods_supported??[]),r,u,o);let d=async()=>{let S=new Headers(u);return n&&await n(S,o,l,t),i&&S.set("DPoP",await i.buildProof({htm:"POST",htu:l})),ja(a??fetch)(l,{method:"POST",headers:S,body:o})},h=await d();if(i&&h.status===400&&(await h.clone().json().catch(()=>{}))?.error===eo.UseDpopNonce&&(i.observeNonce(h,l),h=await d()),i?.observeNonce(h,l),!h.ok)throw await ny(h);let f=await h.json();try{return Nn.parse(Bf(f))}catch(S){throw typeof f=="object"&&f!==null&&"error"in f?await ny(JSON.stringify(f)):S}}async function jx(e,{metadata:t,clientInformation:o,refreshToken:r,resource:n,addClientAuthentication:s,dpop:i,fetchFn:a}){return{refresh_token:r,...await vy(e,{metadata:t,tokenRequestParams:new URLSearchParams({grant_type:"refresh_token",refresh_token:r}),clientInformation:o,addClientAuthentication:s,resource:n,dpop:i,fetchFn:a})}}async function Lx(e,t,{metadata:o,resource:r,authorizationCode:n,iss:s,scope:i,fetchFn:a}={}){n!==void 0&&zg({iss:s,expectedIssuer:o?.issuer,issParameterSupported:yg(o)});let l=o?.issuer??String(t),u=async()=>{let S=await e.clientInformation({issuer:l}),y=Sg(S,l,{canPersistStamp:!1});if(S&&y===void 0)throw new $u(String(S.issuer),l);return y},d=await u(),h=i??e.clientMetadata.scope,f;if(e.prepareTokenRequest&&(f=await e.prepareTokenRequest(h)),!f){if(!n)throw new Error("Either provider.prepareTokenRequest() or authorizationCode is required");if(!e.redirectUrl)throw new Error("redirectUrl is required for authorization_code flow");f=Ax(n,await e.codeVerifier(),e.redirectUrl)}return d??=await u(),vy(t,{metadata:o,tokenRequestParams:f,clientInformation:d,addClientAuthentication:e.addClientAuthentication,resource:r,dpop:await e.dpop?.(),fetchFn:a})}async function Ux(e,{metadata:t,clientMetadata:o,scope:r,fetchFn:n}){let s;if(t){if(!t.registration_endpoint)throw new Error("Incompatible auth server: does not support dynamic client registration");s=new URL(t.registration_endpoint)}else s=new URL("/register",e);let i={...o,...r===void 0?{}:{scope:r}},a=await ja(n??fetch)(s,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(i)});if(!a.ok)throw new hx({status:a.status,body:await a.text(),submittedMetadata:i});return Mn.parse(Bf(await a.json()))}var ku=new Set(["tools/list","prompts/list","resources/list","resources/templates/list","server/discover"]),Zx=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(mg(e))}set(e,t){let o=mg(e),r=ku.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(!ku.has(i.slice(0,i.indexOf("\0")))){this._entries.delete(i),this._cappedSize--;break}}let s=++this._stamp;return this._entries.set(o,{...t,stamp:s}),n&&!r&&this._cappedSize++,s}delete(e){this._entries.delete(mg(e))&&!ku.has(e.method)&&this._cappedSize--}evict(e){let t=`${e}\0`,o=ku.has(e);for(let r of this._entries.keys())r.startsWith(t)&&(this._entries.delete(r),o||this._cappedSize--)}clear(){this._entries.clear(),this._cappedSize=0}};function mg(e){return`${e.method}\0${JSON.stringify([e.partition??"",e.params??""])}`}function fg(e,t){return t===void 0?e:`${e}\0${t}`}var Dx=864e5,Fx=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=fg(e,t),r=this._evictionGeneration.get(o);r!==void 0&&this._evictionGeneration.set(o,r+1),await this._deleteBoth(e,t)}captureGeneration(e,t){let o=fg(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(fg(e,r?.params))??0)!==o)return;let n=r?.params??"",s=this._partitionFor("private"),i=this._partitionFor("public"),a=(r?.scope??"private")==="public"?i:s;try{await this._store.set({method:e,params:n,partition:a},{value:Hx(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:a===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())))try{let r=JSON.parse(o.value);if(typeof r!="object"||r===null||Array.isArray(r))throw new TypeError("cached document is not an object");return{value:r}}catch(r){this._reportError(r),await this._deleteBoth(e,t??"");return}}resetForReconnect(){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);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 new TypeError("cached tools/list document has a malformed tools array");return t}catch(t){this._reportError(t);return}}};function Hx(e){let t;try{t=JSON.stringify(e)}catch(o){throw new TypeError(`cache value is not JSON-serializable: ${o instanceof Error?o.message:String(o)}`)}if(typeof t!="string")throw new TypeError("cache value is not JSON-serializable: it has no JSON representation");return t}var Ry=Symbol.for("mcp.authSeamEscape");function at(e){if(typeof e=="object"&&e!==null||typeof e=="function")try{Object.defineProperty(e,Ry,{value:!0,configurable:!0})}catch{}return e}function Vx(e){return(typeof e=="object"&&e!==null||typeof e=="function")&&e[Ry]===!0}var Jx=-32022,Bx=new Set([-32001,-32020,-32021]);function Wx(e,t){switch(e.kind){case"result":return Kx(e.result,t);case"rpc-error":return wy(e,t);case"http-error":return Gx(e,t);case"network-error":return ay(e.error,t);case"unusable-reply":return{kind:"error",error:new M(q.EraNegotiationFailed,`Version negotiation probe failed: the server answered with an unusable reply (${xy(e.error)})`,{cause:e.error},{cause:e.error})};case"auth-required":return{kind:"error",error:e.error};case"closed":return t.transportKind==="stdio"?{kind:"legacy"}:ay(new Error("Connection closed during the version negotiation probe"),t);case"timeout":return t.transportKind==="stdio"?{kind:"legacy"}:{kind:"error",error:new M(q.RequestTimeout,`Version negotiation probe timed out after ${e.timeoutMs}ms`,{timeout:e.timeoutMs})}}}function Kx(e,t){let o=Qt(Ru).validateResult("server/discover",e);if(!o.ok)return{kind:"legacy"};let r=o.value.supportedVersions,n=t.clientModernVersions.find(s=>r.includes(s));return n!==void 0?{kind:"modern",version:n,discover:o.value}:t.fallbackAvailable?{kind:"legacy"}:{kind:"error",error:new vu({supported:[...r],requested:t.requestedVersion})}}function wy(e,t){let{code:o,message:r,data:n}=e;if(o===Jx){let s=Xx(n);if(s===void 0)return{kind:"legacy"};let i=new vu({supported:s,requested:Qx(n)??t.requestedVersion},r),a=Aa(s),l=t.clientModernVersions.find(u=>a.includes(u));return l!==void 0?{kind:"corrective",version:l,error:i}:a.length>0?{kind:"error",error:i}:t.fallbackAvailable?{kind:"legacy"}:{kind:"error",error:i}}return Bx.has(o)?{kind:"legacy"}:{kind:"legacy"}}function Gx(e,t){if(e.status===401||e.status===403){let r=e.status===403;return{kind:"error",error:new qt(r?q.ClientHttpForbidden:q.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 qt(q.EraNegotiationFailed,`Version negotiation failed: the server answered the probe with HTTP ${e.status}`,{status:e.status,statusText:e.statusText,text:e.body})};let o=eP(e.body);return o!==void 0?wy(o,t):{kind:"legacy"}}function ay(e,t){return t.environment==="browser"&&Yx(e)?{kind:"legacy"}:{kind:"error",error:new M(q.EraNegotiationFailed,`Version negotiation probe failed: ${xy(e)}`,{cause:e},{cause:e})}}function Yx(e){return e instanceof TypeError||e instanceof Error&&e.name==="TypeError"}function xy(e){return e instanceof Error?e.message:String(e)}function Xx(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 t}function Qx(e){if(typeof e!="object"||e===null)return;let t=e.requested;return typeof t=="string"?t:void 0}function eP(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{code:r,message:typeof n=="string"?n:"",data:s}}var tP="legacy";function oP(e,t){let o=e?.mode??tP;if(o==="legacy")return{kind:"legacy"};let r=e?.probe??{};if(typeof o=="object"){if(!to(o.pin))throw new TypeError(`versionNegotiation: { pin: '${o.pin}' } is not a modern protocol revision \u2014 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?Aa(t):[];return{kind:"auto",modernVersions:n.length>0?n:[...Wf],fallbackAvailable:t?Kf(t).length>0:!0,probe:r}}function cy(){let e=globalThis;return e.window!==void 0&&e.document!==void 0?"browser":"node"}function ly(e){return"stderr"in e&&"pid"in e?"stdio":"http"}var rP=class Py{_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 Py(t);t.onmessage=r=>{let n=o._pending;if(n!==void 0&&(jn(r)||Ln(r))&&r.id===n.id){o._pending=void 0,jn(r)?n.resolve({kind:"response",result:r.result}):n.resolve({kind:"response",error:r.error});return}},t.onerror=r=>{o._savedOnError?.(r)},t.onclose=()=>{let r=o._pending;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=>{s||(s=!0,clearTimeout(a),this._pending?.id===r&&(this._pending=void 0),n(l))},a=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,bg.set(o,()=>{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)}}},bg=new WeakMap;function uy(e){let t=bg.get(e);bg.delete(e),t?.()}function nP(e,t,o,r){return{jsonrpc:"2.0",id:e,method:"server/discover",params:{_meta:Qt(t).outboundEnvelope({protocolVersion:t,clientInfo:o,clientCapabilities:r})}}}function sP(e){return e instanceof M&&e.code===q.ClientHttpUnexpectedContent?!0:e instanceof Error&&e.name==="SyntaxError"}function iP(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(Vx(o)||o instanceof At||o instanceof Error&&o.name==="UnauthorizedError")return{kind:"auth-required",error:o};if(o instanceof qt){let r=o.data?.text;return{kind:"http-error",status:o.data.status,body:typeof r=="string"?r:void 0,statusText:o.data.statusText}}return sP(o)?{kind:"unusable-reply",error:o}:{kind:"network-error",error:o}}case"closed":return{kind:"closed"};case"timeout":return{kind:"timeout",timeoutMs:t}}}async function Ty(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 rP.open(t.transport),a=async()=>{let u=n[0],d=!1,h=r;for(;;){let f=await i.exchange(w=>nP(w,u,t.clientInfo,t.capabilities),o);if(f.kind==="timeout"&&h>0){h--;continue}let S=iP(f,o),y=Wx(S,{clientModernVersions:n,requestedVersion:u,fallbackAvailable:s,environment:t.environment,transportKind:t.transportKind});switch(y.kind){case"modern":return{era:"modern",version:y.version,discover:y.discover};case"corrective":if(d)throw y.error;d=!0,u=y.version;continue;case"legacy":{let w=S.kind==="closed"?"the connection closed during the server/discover probe":void 0;if(e.kind==="pin")throw new M(q.EraNegotiationFailed,w===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: ${w} before the server offered pinned protocol version ${e.version} (no fallback in pin mode)`);if(!e.fallbackAvailable)throw new M(q.EraNegotiationFailed,w===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: ${w} and this client supports no pre-2026-07-28 protocol version to fall back to`);if(w!==void 0&&t.disposableProbe!==!0)throw new M(q.EraNegotiationFailed,`Version negotiation failed: ${w} (this transport probed in place \u2014 the disposable sibling probe requires the SDK's base StdioClientTransport)`);return{era:"legacy"}}case"error":throw y.error}}},l;try{l=await a()}catch(u){throw i.detach(),u}return i.release(),l}function aP(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 cP(e,t,o,r){let n=t.constructor,s=new n({...o,stderr:"ignore"}),i=t.close,a=!1,l,u=new Promise((h,f)=>{l=()=>f(dy())});t.close=async function(){return a=!0,l?.(),i.call(t)};let d;try{let h=Ty(e,{...r,transport:s,transportKind:"stdio",disposableProbe:!0});h.catch(()=>{}),d=await Promise.race([h,u])}finally{await lP(s),t.close=i}if(a)throw dy();return d}function dy(){return new M(q.EraNegotiationFailed,"Version negotiation failed: the transport was closed during the server/discover probe")}async function lP(e){try{let t=e._dispose;await(typeof t=="function"?t.call(e):e.close())}catch{}}function py(e){let t=e._meta?.[Bt];return Ub.Implementation(t)?t:void 0}function Cu(e,t){if(!(!e||t===null||typeof t!="object")){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];o[n]===void 0&&Object.prototype.hasOwnProperty.call(s,"default")&&(o[n]=s.default),o[n]!==void 0&&Cu(s,o[n])}}if(Array.isArray(e.anyOf))for(let o of e.anyOf)typeof o!="boolean"&&Cu(o,t);if(Array.isArray(e.oneOf))for(let o of e.oneOf)typeof o!="boolean"&&Cu(o,t)}}function uP(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 dP(e){if(typeof e=="object"&&e!==null&&(e.kind==="legacy"&&!("supportedVersions"in e)&&!("discover"in e)||e.kind==="modern"&&wo.safeParse(e.discover).success))return e;throw new M(q.EraNegotiationFailed,"connect({ prior }): unrecognized prior \u2014 expected { kind: 'modern', discover } or { kind: 'legacy' }")}var hy={"notifications/tools/list_changed":["tools/list"],"notifications/prompts/list_changed":["prompts/list"],"notifications/resources/list_changed":["resources/list","resources/templates/list"]},pP=64,Ey=class extends Pu{_serverCapabilities;_serverVersion;_capabilities;_instructions;_jsonSchemaValidator;_cache;_defaultCacheTtlMs;_listMaxPages;_listChangedDebounceTimers=new Map;_listChangedConfig;_enforceStrictCapabilities;_versionNegotiation;_supportedProtocolVersionsOption;_inputRequiredDriverConfig;_listenState=new Map;_nextListenId=0;_autoOpenedSubscription;_discoverResult;_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 M(q.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),this._clientInfo=e,this._capabilities=t?.capabilities?{...t.capabilities}:{},this._jsonSchemaValidator=t?.jsonSchemaValidator??new ig,this._enforceStrictCapabilities=t?.enforceStrictCapabilities??!1,this._versionNegotiation=t?.versionNegotiation,this._supportedProtocolVersionsOption=t?.supportedProtocolVersions,this._inputRequiredDriverConfig=Mb(t?.inputRequired),this._cache=new Fx(t?.responseCacheStore??new Zx,t?.responseCacheStore!==void 0,o=>this._reportStoreError(o),t?.cachePartition??""),this._defaultCacheTtlMs=t?.defaultCacheTtlMs??0,this._listMaxPages=t?.listMaxPages??pP,t?.listChanged&&(this._listChangedConfig=t.listChanged)}buildContext(e,t){return e}_shouldDropInbound(e){if(this._negotiatedProtocolVersion!==void 0&&to(this._negotiatedProtocolVersion)&&dr(e))return"drop"}_outboundMetaEnvelope(){let e=this._negotiatedProtocolVersion;if(e!==void 0)return this._wireCodec().outboundEnvelope({protocolVersion:e,clientInfo:this._clientInfo,clientCapabilities:this._capabilities})}_resolveNonCompleteResult(e,t){return this._inputRequiredDriverConfig.autoFulfill?Db({getRequestHandler:o=>this._getRequestHandler(o),buildContext:o=>this.buildContext(o,void 0),sessionId:this.transport?.sessionId},this._inputRequiredDriverConfig,e,t):Promise.reject(new M(q.UnsupportedResultType,`Unsupported result type 'input_required' for ${t.request.method}: multi-round-trip auto-fulfilment is not enabled on this instance \u2014 pass allowInputRequired: true to handle it manually, or enable inputRequired.autoFulfill`,{resultType:"input_required",method:t.request.method}))}_setupListChangedHandlers(e){e.tools&&this._serverCapabilities?.tools?.listChanged&&this._setupListChangedHandler("tools","notifications/tools/list_changed",e.tools,async()=>(await this.listTools(void 0,{cacheMode:"refresh"})).tools),e.prompts&&this._serverCapabilities?.prompts?.listChanged&&this._setupListChangedHandler("prompts","notifications/prompts/list_changed",e.prompts,async()=>(await this.listPrompts(void 0,{cacheMode:"refresh"})).prompts),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 new Error("Cannot register capabilities after connecting to transport");this._capabilities=Zb(this._capabilities,e)}setVersionNegotiation(e){if(this.transport)throw new Error("Cannot configure version negotiation after connecting to transport");this._versionNegotiation=e}_wrapHandler(e,t){return e==="elicitation/create"?async(o,r)=>{let n=Qt(this._negotiatedProtocolVersion),s=n.validateRequest("elicitation/create",o);if(!s.ok&&s.reason==="not-in-era"&&(s=n.validateInputRequest("elicitation/create",o)),!s.ok)throw new se(s.reason==="not-in-era"?B.InternalError:B.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:a,supportsUrlMode:l}=uP(this._capabilities.elicitation);if(i.mode==="form"&&!a)throw new se(B.InvalidParams,"Client does not support form-mode elicitation requests");if(i.mode==="url"&&!l)throw new se(B.InvalidParams,"Client does not support URL-mode elicitation requests");let u=await t(o,r),d=n.validateResult("elicitation/create",u);if(!d.ok&&d.reason==="not-in-era"&&(d=n.validateInputResponse("elicitation/create",u)),!d.ok)throw new se(d.reason==="not-in-era"?B.InternalError:B.InvalidParams,d.reason==="not-in-era"?"No wire schema for elicitation/create in the resolved era":`Invalid elicitation result: ${d.message}`);let h=d.value,f=i.mode==="form"?i.requestedSchema:void 0;if(i.mode==="form"&&h.action==="accept"&&h.content&&f&&this._capabilities.elicitation?.form?.applyDefaults)try{Cu(f,h.content)}catch{}return h}:e==="sampling/createMessage"?async(o,r)=>{let n=Qt(this._negotiatedProtocolVersion),s=n.validateRequest("sampling/createMessage",o);if(!s.ok&&s.reason==="not-in-era"&&(s=n.validateInputRequest("sampling/createMessage",o)),!s.ok)throw new se(s.reason==="not-in-era"?B.InternalError:B.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,a=await t(o,r),l=!!(i.tools||i.toolChoice),u=n.samplingResultVariant(l,a);if(!u.ok&&u.reason==="not-in-era"&&(u=n.validateInputResponse("sampling/createMessage",a)),!u.ok)throw new se(u.reason==="not-in-era"?B.InternalError:B.InvalidParams,u.reason==="not-in-era"?"No result schema for sampling/createMessage in the resolved era":`Invalid sampling result: ${u.message}`);return u.value}:t}assertCapability(e,t){if(!this._serverCapabilities?.[e])throw new M(q.CapabilityNotSupported,`Server does not support ${e} (required for ${t})`)}async connect(e,t){if(t?.prior!=null)return this._connectFromPrior(e,dP(t.prior),t);let o=oP(this._versionNegotiation,this._supportedProtocolVersionsOption);return o.kind!=="legacy"?this._connectNegotiated(e,o,t):this._connectPlainLegacy(e,t)}async _connectPlainLegacy(e,t){if(await super.connect(e),e.sessionId!==void 0){let o=this._negotiatedProtocolVersion;o!==void 0&&e.setProtocolVersion?.(o);return}this._resetConnectionState(),await this._legacyHandshake(e,t)}async _legacyHandshake(e,t){let o=Kf(this._supportedProtocolVersions);try{let r=o[0];if(r===void 0)throw new M(q.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 new Error(`Server sent invalid initialize result: ${n}`);if(!o.includes(n.protocolVersion))throw new Error(`Server's protocol version is not supported: ${n.protocolVersion}`);this._serverCapabilities=n.capabilities,this._serverVersion=n.serverInfo,this._cache.setServerIdentity(this._deriveServerIdentity(e)),e.setProtocolVersion&&e.setProtocolVersion(n.protocolVersion),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;n!==void 0&&e.setProtocolVersion&&e.setProtocolVersion(n);return}this._resetConnectionState();let r;try{let n=ly(e),s={clientInfo:this._clientInfo,capabilities:this._capabilities,environment:cy(),defaultTimeoutMs:o?.timeout??xu},i=n==="stdio"?aP(e):void 0;r=i===void 0?await Ty(t,{...s,transport:e,transportKind:n}):await cP(t,e,i,s)}catch(n){throw await e.close().catch(()=>{}),uy(e),n}if(uy(e),await super.connect(e),r.era==="legacy"){await this._legacyHandshake(e,o);return}if(this._serverCapabilities=r.discover.capabilities,this._serverVersion=py(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),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}},a=!0;try{this._setupListChangedHandlers(i)}catch(u){a=!1,this.onerror?.(u instanceof Error?u:new Error(String(u)))}let l=a?{...i.tools&&{toolsListChanged:!0},...i.prompts&&{promptsListChanged:!0},...i.resources&&{resourcesListChanged:!0}}:{};if(Object.keys(l).length>0){let u=new AbortController,d=()=>u.abort(o?.signal?.reason);o?.signal?.aborted&&d(),o?.signal?.addEventListener("abort",d);try{this._autoOpenedSubscription=await this.listen(l,{timeout:o?.timeout,signal:u.signal})}catch(h){if(o?.signal?.aborted)throw await this.close().catch(()=>{}),h;this.onerror?.(h instanceof Error?h:new Error(String(h)))}finally{o?.signal?.removeEventListener("abort",d)}}}}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&&Aa(n).length>0?Aa(n):Wf).find(i=>r.supportedVersions.includes(i));if(s===void 0)throw new M(q.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=py(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:new Error(String(i)))}}getServerCapabilities(){return this._serverCapabilities}getServerVersion(){return this._serverVersion}_deriveServerIdentity(e){let t=this._serverVersion;return t!==void 0?`${t.name}@${t.version}`: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 to(e)?"modern":"legacy"}getInstructions(){return this._instructions}getDiscoverResult(){return this._discoverResult}assertCapabilityForMethod(e){switch(e){case"logging/setLevel":if(!this._serverCapabilities?.logging)throw new M(q.CapabilityNotSupported,`Server does not support logging (required for ${e})`);break;case"prompts/get":case"prompts/list":if(!this._serverCapabilities?.prompts)throw new M(q.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 M(q.CapabilityNotSupported,`Server does not support resources (required for ${e})`);if(e==="resources/subscribe"&&!this._serverCapabilities.resources.subscribe)throw new M(q.CapabilityNotSupported,`Server does not support resource subscriptions (required for ${e})`);break;case"tools/call":case"tools/list":if(!this._serverCapabilities?.tools)throw new M(q.CapabilityNotSupported,`Server does not support tools (required for ${e})`);break;case"completion/complete":if(!this._serverCapabilities?.completions)throw new M(q.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 M(q.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 M(q.CapabilityNotSupported,`Client does not support sampling capability (required for ${e})`);break;case"elicitation/create":if(!this._capabilities.elicitation)throw new M(q.CapabilityNotSupported,`Client does not support elicitation capability (required for ${e})`);break;case"roots/list":if(!this._capabilities.roots)throw new M(q.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"},wo,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);return o!==void 0?o: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);return o!==void 0?o: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);return o!==void 0?o: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),a=await this.request({method:e,...t&&{params:{...t}}},o),l=a.nextCursor,u=a,d=1;for(;l!==void 0;){if(this._listMaxPages!==0&&d>=this._listMaxPages)throw new M(q.ListPaginationExceeded,`${e}: exceeded listMaxPages (${this._listMaxPages}); server pagination did not terminate`,{method:e,listMaxPages:this._listMaxPages});let h=await this.request({method:e,params:{...t,cursor:l}},o);if(h.nextCursor===l&&JSON.stringify(r(h))===JSON.stringify(r(u)))break;r(a).push(...r(h)),u=h,l=h.nextCursor,d++}return delete a.nextCursor,n?.(a),s||await this._cache.write(e,a,i,this._freshness(a)),a}_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),Dx),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 M?n:new M(q.RequestTimeout,String(n))}return r.value}}_reportStoreError(e){this.onerror?.(e instanceof Error?e:new Error(String(e)))}_compileOutputValidator(e){if(e.outputSchema)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:og(o.inputSchema)}async readResource(e,t){let o=await this._serveFromCache("resources/read",e.uri,t);if(o!==void 0)return o;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);s.expiresAt>this._cache.now()?await this._cache.write("resources/read",n,r,s):t?.cacheMode==="refresh"&&await this._cache.evictKey("resources/read",e.uri)}return n}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 M(q.NotConnected,"Not connected");let o=this._negotiatedProtocolVersion;if(o===void 0||!to(o))throw new M(q.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 N=t.signal.reason;throw N instanceof M?N:new M(q.RequestTimeout,String(N))}let r=new AbortController,n=`listen:${this._nextListenId++}`,s="opening",i,a,l,u,d=new Promise((N,D)=>{l=N,u=D}),h,f=new Promise(N=>{h=N}),S=N=>{if(s==="closed")return;let D=s==="opening";if(i!==void 0&&(clearTimeout(i),i=void 0),"ack"in N){s="open",l(N.ack);return}s="closed",a!==void 0&&t?.signal?.removeEventListener("abort",a),this._listenState.delete(n),r.abort(),h(N.cause),D&&u(N.error??new M(q.ConnectionClosed,"subscriptions/listen closed before the server acknowledged"))},y=async()=>{r.abort(),await this.notification({method:"notifications/cancelled",params:{requestId:n}}).catch(()=>{})},w=async()=>{s!=="closed"&&(S({cause:"local"}),await y())};this._listenState.set(n,{settle:S});let z=t?.timeout??xu;if(i=setTimeout(()=>{S({cause:"remote",error:new M(q.RequestTimeout,"subscriptions/listen ack timed out",{timeout:z})}),y().catch(()=>{})},z),t?.signal){let N=t.signal;a=()=>{if(s==="closed")return;let D=N.reason;S({cause:"local",error:D instanceof Error?D:new Error(String(D??"Aborted"))}),y().catch(()=>{})},N.addEventListener("abort",a,{once:!0})}let H={jsonrpc:"2.0",id:n,method:"subscriptions/listen",params:{_meta:{...this._outboundMetaEnvelope()},notifications:e}},W=N=>{S({cause:"remote",error:N instanceof Error?N:new Error(String(N))})};try{this.transport.send(H,{requestSignal:r.signal,onRequestStreamEnd:()=>S({cause:"remote",error:new Error("subscriptions/listen: stream ended")})}).catch(W)}catch(N){W(N)}return{honoredFilter:await d,close:w,closed:f}}get autoOpenedSubscription(){return this._autoOpenedSubscription}_onnotification(e,t){let o=Object.hasOwn(hy,e.method)?hy[e.method]:void 0;if(e.method==="notifications/resources/updated"){let r=e.params?.uri;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?.[Xs],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:new 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){Ln(e)?o.settle({cause:"remote",error:se.fromError(e.error.code,e.error.message,e.error.data)}):o.settle({cause:"graceful",error:new M(q.ConnectionClosed,"subscriptions/listen: server closed the subscription gracefully before acknowledging")});return}super._onresponse(e)}_onclose(){if(this._listenState.size>0){let e=new M(q.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"&&cy()!=="browser",r=async()=>{if(!o)return t;let l;try{l=await this._resolveXMcpHeaderScan(e.name,t?.toolDefinition)}catch(d){this._reportStoreError(d)}if(!l?.valid||l.declarations.length===0)return t;let u=Ob(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 se(B.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 se&&l.code===An;if(!o||!u||t?.toolDefinition!==void 0)throw l;let d={signal:t?.signal,timeout:t?.timeout,cacheMode:"refresh"};await this._cache.evict("tools/list"),await this.listTools(void 0,d).catch(h=>this._reportStoreError(h)),n=await this._cache.outputValidator(e.name,h=>this._compileOutputValidator(h)).catch(h=>void this._reportStoreError(h)),s(),i=await this.request({method:"tools/call",params:e},await r())}let a=n!==void 0&&n.ok?n.validator:void 0;if(a){if(i.structuredContent===void 0&&!i.isError)throw new se(B.InvalidRequest,`Tool ${e.name} has an output schema but did not return structured content`);if(i.structuredContent!==void 0&&!i.isError)try{let l=a(i.structuredContent);if(!l.valid)throw new se(B.InvalidParams,`Structured content does not match the tool's output schema: ${l.errorMessage}`)}catch(l){throw l instanceof se?l:new se(B.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);return o!==void 0?o:this._listAllPages("tools/list",e,t,r=>r.tools,r=>this._excludeInvalidXMcpHeaderTools(r))}_excludeInvalidXMcpHeaderTools(e){if(this.getProtocolEra()!=="modern"||!this.transport||ly(this.transport)==="stdio")return;let t=e.tools.filter(o=>{let r=og(o.inputSchema);return r.valid?!0:(console.warn(`[mcp-sdk] excluding tool '${o.name}' from tools/list: invalid x-mcp-header declaration \u2014 ${r.reason}`),!1)});t.length!==e.tools.length&&(e.tools=t)}_setupListChangedHandler(e,t,o,r){let n=wu(Wi,o);if(!n.success)throw new Error(`Invalid ${e} listChanged options: ${n.error.message}`);if(typeof o.onChanged!="function")throw new TypeError(`Invalid ${e} listChanged options: onChanged must be a function`);let{autoRefresh:s,debounceMs:i}=n.data,{onChanged:a}=o,l=async()=>{if(!s){a(null,null);return}try{a(null,await r())}catch(d){a(d instanceof Error?d:new Error(String(d)),null)}},u=()=>{if(i){let d=this._listChangedDebounceTimers.get(e);d&&clearTimeout(d);let h=setTimeout(l,i);this._listChangedDebounceTimers.set(e,h)}else l()};this.setNotificationHandler(t,u)}async sendRootsListChanged(){return this.notification({method:"notifications/roots/list_changed"})}};function hP(e){return/(?:^|,)\s*dpop(?:\s|$|,)/i.test(e)}function mP(e){if(e.status!==401)return!1;let t=e.headers.get("www-authenticate")??"";return hP(t)&&/use_dpop_nonce/i.test(t)}var fP=(e,t)=>o=>{let r=typeof e=="function"?e:()=>e;return async(n,s)=>{let i=(s?.method??"GET").toUpperCase(),a=new URL(n.toString()),l=await r();if(!l)return o(n,s);let u=async()=>{let h=await t();if(!h)return o(n,s);let f=new Headers(s?.headers),S=await l.buildProof({htm:i,htu:a,accessToken:h});return f.set("Authorization",`DPoP ${h}`),f.set("DPoP",S),o(n,{...s,headers:f})},d=await u();return mP(d)&&d.headers.has("dpop-nonce")&&(l.observeNonce(d,a),await d.text?.().catch(()=>{}),d=await u()),l.observeNonce(d,a),d}},gP=e=>fP(async()=>{try{return await e.dpop?.()}catch(t){throw at(t)}},async()=>{let t;try{t=await e.tokens()}catch(o){throw at(o)}return t?.token_type?.toLowerCase()==="dpop"?t.access_token:void 0});var XE=class extends Error{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.SseError"})}static[Symbol.hasInstance](e){return et(this,e)}static isInstance(e){if(typeof this!="function")throw new TypeError("isInstance must be called on the class (e.g. `SdkError.isInstance(value)`); for callbacks use `v => SdkError.isInstance(v)`");return et(this,e)}constructor(e,t,o){super(`SSE error: ${t}`),this.code=e,this.event=o,lr(this,new.target)}};var SP=1,_P={initialReconnectionDelay:1e3,maxReconnectionDelay:3e4,reconnectionDelayGrowFactor:1.5,maxRetries:2},bP=new Set(["authorization","dpop","content-type","mcp-protocol-version","mcp-method","mcp-name","mcp-session-id"]);function my(e,t){if(typeof AbortSignal.any=="function")return AbortSignal.any([e,t]);let o=new AbortController;if(e.aborted)return o.abort(e.reason),o.signal;if(t.aborted)return o.abort(t.reason),o.signal;let r=()=>{e.removeEventListener("abort",n),t.removeEventListener("abort",s)};function n(){r(),o.abort(e.reason)}function s(){r(),o.abort(t.reason)}return e.addEventListener("abort",n,{once:!0}),t.addEventListener("abort",s,{once:!0}),o.signal}var ky=class{_abortController;_url;_resourceMetadataUrl;_scope;_requestInit;_authProvider;_oauthProvider;_skipIssuerMetadataValidation;_fetch;_fetchWithInit;_redirectPolicy;_sessionId;_reconnectionOptions;_protocolVersion;_onInsufficientScope;_maxStepUpRetries;_serverRetryMs;_reconnectionScheduler;_cancelReconnection;onclose;onerror;onmessage;hasPerRequestStream=!0;constructor(e,t){this._url=e,this._resourceMetadataUrl=void 0,this._scope=void 0,this._requestInit=t?.requestInit,this._skipIssuerMetadataValidation=t?.skipIssuerMetadataValidation,this._fetch=t?.fetch,mx(t?.authProvider)?(this._oauthProvider=t.authProvider,this._authProvider=gx(t.authProvider,{skipIssuerMetadataValidation:t.skipIssuerMetadataValidation}),t.authProvider.dpop&&(this._fetch=gP(t.authProvider)(t.fetch??fetch))):this._authProvider=t?.authProvider,this._redirectPolicy=t?.redirectPolicy,this._fetchWithInit=Hb(t?.fetch,t?.requestInit),this._redirectPolicy==="follow"&&(this._fetchWithInit=Bb(this._fetchWithInit)),this._sessionId=t?.sessionId,this._protocolVersion=t?.protocolVersion,this._reconnectionOptions=t?.reconnectionOptions??_P,this._reconnectionScheduler=t?.reconnectionScheduler,this._onInsufficientScope=t?.onInsufficientScope??"reauthorize",this._maxStepUpRetries=Math.max(0,t?.maxStepUpRetries??SP)}async _stepUpAuthorize(e,t){try{return await this._stepUpAuthorizeInner(e,t)}catch(o){throw at(o)}}async _stepUpAuthorizeInner(e,t){if(this._onInsufficientScope==="throw")throw new ry({requiredScope:e.scope,resourceMetadataUrl:e.resourceMetadataUrl,errorDescription:e.errorDescription});if(!this._oauthProvider)throw new ry({requiredScope:e.scope,resourceMetadataUrl:e.resourceMetadataUrl,errorDescription:e.errorDescription});if(t>=this._maxStepUpRetries)throw new qt(q.ClientHttpForbidden,`Server returned 403 insufficient_scope after step-up re-authorization (retry limit ${this._maxStepUpRetries} reached)`,{status:403,statusText:e.statusText??"Forbidden",text:e.text});e.resourceMetadataUrl&&(this._resourceMetadataUrl=e.resourceMetadataUrl);let o=await this._oauthProvider.tokens(),r=ug(this._scope,o?.scope,e.scope);this._scope=r;let n=Sx(r,o?.scope);return _g(this._oauthProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:r,forceReauthorization:n,fetchFn:this._fetchWithInit,skipIssuerMetadataValidation:this._skipIssuerMetadataValidation})}_redirects(e){return this._redirectPolicy==="follow"?e:ja(e)}_unfollowedRedirect(e,t){let o=this._redirectPolicy==="follow"?void 0:Wb(e,t);return o&&`${o} (redirectPolicy: 'same-origin')`}async _commonHeaders(){let e=new Headers(this._requestInit?.headers||void 0),t;try{t=await this._authProvider?.token()}catch(o){throw at(o)}return t&&e.set("Authorization",`Bearer ${t}`),this._sessionId&&e.set("mcp-session-id",this._sessionId),this._protocolVersion&&e.set("mcp-protocol-version",this._protocolVersion),e}_applyBodyDerivedHeaders(e,t){if(Array.isArray(t)||!dr(t))return;let o=t.params?._meta?.[Jt];if(typeof o!="string")return;e.set("mcp-protocol-version",o),e.set("mcp-method",t.method);let r=Nb(t.method,t.params);r?.value!==void 0&&e.set("mcp-name",rg(r.value))}_isModernEnvelopedRequest(e){if(Array.isArray(e)||!dr(e))return!1;let t=e.params?._meta?.[Jt];return typeof t=="string"&&to(t)}async _startOrAuthSse(e,t=!1,o=0){let{resumptionToken:r,requestSignal:n}=e,s=()=>this._abortController?.signal.aborted===!0||n?.aborted===!0;try{let i=await this._commonHeaders(),a=[...i.get("accept")?.split(",").map(h=>h.trim().toLowerCase())??[],"text/event-stream"];i.set("accept",[...new Set(a)].join(", ")),r&&i.set("last-event-id",r);let l=this._abortController?.signal,u=n!==void 0&&l!==void 0?my(l,n):n??l,d=await this._redirects(this._fetch??fetch)(this._url,{...this._requestInit,method:"GET",headers:i,signal:u});if(!d.ok){if(d.status===401&&this._authProvider){if(d.headers.has("www-authenticate")){let{resourceMetadataUrl:f,scope:S}=Za(d);this._resourceMetadataUrl=f,this._scope=ug(this._scope,S)}if(this._authProvider.onUnauthorized&&!t){try{await this._authProvider.onUnauthorized({response:d,serverUrl:this._url,fetchFn:this._fetchWithInit})}catch(f){throw at(f)}return await d.text?.().catch(()=>{}),this._startOrAuthSse(e,!0,o)}throw await d.text?.().catch(()=>{}),at(t?new qt(q.ClientHttpAuthentication,"Server returned 401 after re-authentication",{status:401,statusText:d.statusText}):new At)}if(d.status===403){let{resourceMetadataUrl:f,scope:S,error:y,errorDescription:w}=Za(d);if(y==="insufficient_scope"){let z=await d.text?.().catch(()=>null);if(await this._stepUpAuthorize({scope:S,resourceMetadataUrl:f,errorDescription:w,statusText:d.statusText,text:z},o)!=="AUTHORIZED")throw at(new At);return this._startOrAuthSse(e,t,o+1)}}if(await d.text?.().catch(()=>{}),d.status===405){e.onRequestStreamEnd?.();return}let h=this._unfollowedRedirect(this._url,d)??d.statusText;throw new qt(q.ClientHttpFailedToOpenStream,`Failed to open SSE stream: ${h}`,{status:d.status,statusText:d.statusText})}this._handleSseStream(d.body,e,!0)}catch(i){throw s()||this.onerror?.(i),i}}_getNextReconnectionDelay(e){if(this._serverRetryMs!==void 0)return this._serverRetryMs;let t=this._reconnectionOptions.initialReconnectionDelay,o=this._reconnectionOptions.reconnectionDelayGrowFactor,r=this._reconnectionOptions.maxReconnectionDelay;return Math.min(t*Math.pow(o,e),r)}_scheduleReconnection(e,t=0){let o=this._reconnectionOptions.maxRetries;if(t>=o){this.onerror?.(new Error(`Maximum reconnection attempts (${o}) exceeded.`)),e.onRequestStreamEnd?.();return}let r=this._getNextReconnectionDelay(t),n=()=>{this._cancelReconnection=void 0,!(this._abortController?.signal.aborted||e.requestSignal?.aborted)&&this._startOrAuthSse(e).catch(s=>{if(!(this._abortController?.signal.aborted||e.requestSignal?.aborted)){this.onerror?.(new Error(`Failed to reconnect SSE stream: ${s instanceof Error?s.message:String(s)}`));try{this._scheduleReconnection(e,t+1)}catch(i){this.onerror?.(i instanceof Error?i:new Error(String(i)))}}})};if(this._reconnectionScheduler){let s=this._reconnectionScheduler(n,r,t);this._cancelReconnection=typeof s=="function"?s:void 0}else{let s=setTimeout(n,r);this._cancelReconnection=()=>clearTimeout(s)}}_handleSseStream(e,t,o){if(!e){t.onRequestStreamEnd?.();return}let{onresumptiontoken:r,replayMessageId:n,requestSignal:s,onRequestStreamEnd:i}=t,a=()=>this._abortController?.signal.aborted===!0||s?.aborted===!0,l,u=!1,d=!1;(async()=>{try{let f=e.pipeThrough(new TextDecoderStream).pipeThrough(new Tu({onRetry:S=>{this._serverRetryMs=S}})).getReader();for(;;){let{value:S,done:y}=await f.read();if(y)break;if(S.id&&(l=S.id,u=!0,r?.(S.id)),!!S.data&&(!S.event||S.event==="message"))try{let w=mt.parse(JSON.parse(S.data));(jn(w)||Ln(w))&&(d=!0,n!==void 0&&(w.id=n)),this.onmessage?.(w)}catch(w){this.onerror?.(w)}}(o||u)&&!d&&this._abortController&&!a()?this._scheduleReconnection({resumptionToken:l,onresumptiontoken:r,replayMessageId:n,requestSignal:s,onRequestStreamEnd:i},0):a()||i?.()}catch(f){if(a())return;if(this.onerror?.(new Error(`SSE stream disconnected: ${f}`)),(o||u)&&!d&&this._abortController&&!a())try{this._scheduleReconnection({resumptionToken:l,onresumptiontoken:r,replayMessageId:n,requestSignal:s,onRequestStreamEnd:i},0)}catch(S){this.onerror?.(new Error(`Failed to reconnect: ${S instanceof Error?S.message:String(S)}`)),i?.()}else i?.()}})()}async start(){if(this._abortController)throw new Error("StreamableHTTPClientTransport already started! If using Client class, note that connect() calls start() automatically.");this._abortController=new AbortController}async finishAuth(e,t){if(!this._oauthProvider)throw new At("finishAuth requires an OAuthClientProvider");let{authorizationCode:o,iss:r}=await _x(e,t,this._oauthProvider,this._url,{fetchFn:this._fetchWithInit,resourceMetadataUrl:this._resourceMetadataUrl});if(await _g(this._oauthProvider,{serverUrl:this._url,authorizationCode:o,iss:r,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit,skipIssuerMetadataValidation:this._skipIssuerMetadataValidation})!=="AUTHORIZED")throw new At("Failed to authorize")}async close(){try{this._cancelReconnection?.()}finally{this._cancelReconnection=void 0,this._abortController?.abort(),this.onclose?.()}}async send(e,t){return this._send(e,t,!1)}async _send(e,t,o,r=0){try{let{resumptionToken:n,onresumptiontoken:s}=t||{};if(n){this._startOrAuthSse({resumptionToken:n,replayMessageId:dr(e)?e.id:void 0,requestSignal:t?.requestSignal}).catch(z=>this.onerror?.(z));return}let i=await this._commonHeaders();this._applyBodyDerivedHeaders(i,e);let a=Array.isArray(e)?e.some(z=>tg(z)):tg(e);if(a&&i.delete("mcp-session-id"),t?.headers!==void 0)for(let[z,H]of Object.entries(t.headers))bP.has(z.toLowerCase())||i.set(z,H);i.set("content-type","application/json");let l=[...i.get("accept")?.split(",").map(z=>z.trim().toLowerCase())??[],"application/json","text/event-stream"];i.set("accept",[...new Set(l)].join(", "));let u=this._abortController?.signal,d=t?.requestSignal!==void 0&&u!==void 0?my(u,t.requestSignal):t?.requestSignal??u,h={...this._requestInit,method:"POST",headers:i,body:JSON.stringify(e),signal:d},f=await this._redirects(this._fetch??fetch)(this._url,h);if(a&&f.ok&&(this._sessionId=f.headers.get("mcp-session-id")||void 0),!f.ok){if(f.status===401&&this._authProvider){if(f.headers.has("www-authenticate")){let{resourceMetadataUrl:W,scope:N}=Za(f);this._resourceMetadataUrl=W,this._scope=ug(this._scope,N)}if(this._authProvider.onUnauthorized&&!o){try{await this._authProvider.onUnauthorized({response:f,serverUrl:this._url,fetchFn:this._fetchWithInit})}catch(W){throw at(W)}return await f.text?.().catch(()=>{}),this._send(e,t,!0,r)}throw await f.text?.().catch(()=>{}),at(o?new qt(q.ClientHttpAuthentication,"Server returned 401 after re-authentication",{status:401,statusText:f.statusText}):new At)}let z=await f.text?.().catch(()=>null);if(f.status===403){let{resourceMetadataUrl:W,scope:N,error:D,errorDescription:x}=Za(f);if(D==="insufficient_scope"){if(await this._stepUpAuthorize({scope:N,resourceMetadataUrl:W,errorDescription:x,statusText:f.statusText,text:z},r)!=="AUTHORIZED")throw at(new At);return this._send(e,t,o,r+1)}}if(f.status===400&&typeof z=="string"&&this._isModernEnvelopedRequest(e))try{let W=mt.parse(JSON.parse(z)),N=(Array.isArray(e)?e:[e]).filter(D=>dr(D));if(Ln(W)&&N.some(D=>D.id===W.id)){this.onmessage?.(W);return}}catch{}let H=this._unfollowedRedirect(this._url,f)??z;throw new qt(q.ClientHttpNotImplemented,`Error POSTing to endpoint: ${H}`,{status:f.status,statusText:f.statusText,text:z})}if(f.status===202){await f.text?.().catch(()=>{}),$b(e)&&this._startOrAuthSse({resumptionToken:void 0}).catch(z=>this.onerror?.(z));return}let S=(Array.isArray(e)?e:[e]).some(z=>"method"in z&&"id"in z&&z.id!==void 0),y=f.headers.get("content-type"),w=Fb(y);if(S)if(w==="text/event-stream")this._handleSseStream(f.body,{onresumptiontoken:s,requestSignal:t?.requestSignal,onRequestStreamEnd:t?.onRequestStreamEnd},!1);else if(w==="application/json"){let z=await f.json(),H=Array.isArray(z)?z.map(W=>mt.parse(W)):[mt.parse(z)];for(let W of H)this.onmessage?.(W)}else throw await f.text?.().catch(()=>{}),new M(q.ClientHttpUnexpectedContent,`Unexpected content type: ${y}`,{contentType:y});else await f.text?.().catch(()=>{})}catch(n){throw t?.requestSignal?.aborted!==!0&&this.onerror?.(n),n}}get sessionId(){return this._sessionId}async terminateSession(){if(this._sessionId)try{let e=await this._commonHeaders(),t={...this._requestInit,method:"DELETE",headers:e,signal:this._abortController?.signal},o=await this._redirects(this._fetch??fetch)(this._url,t);if(await o.text?.().catch(()=>{}),!o.ok&&o.status!==405)throw new qt(q.ClientHttpFailedToTerminateSession,`Failed to terminate session: ${this._unfollowedRedirect(this._url,o)??o.statusText}`,{status:o.status,statusText:o.statusText});this._sessionId=void 0}catch(e){throw this.onerror?.(e),e}}setProtocolVersion(e){this._protocolVersion=e}get protocolVersion(){return this._protocolVersion}async resumeStream(e,t){await this._startOrAuthSse({resumptionToken:e,onresumptiontoken:t?.onresumptiontoken})}};var Rg=class{_eventSlots=new Map;setHandler(t,o){let r=this._ensureEventSlot(t);r.onHandler&&o&&console.warn(`[MCP Apps] on${String(t)} handler replaced. Use addEventListener("${String(t)}", \u2026) to add multiple listeners without replacing.`),r.onHandler=o}getHandler(t){return this._eventSlots.get(t)?.onHandler}addEventListener(t,o){this._ensureEventSlot(t).listeners.push(o)}removeEventListener(t,o){let r=this._eventSlots.get(t);if(!r)return;let n=r.listeners.indexOf(o);n!==-1&&r.listeners.splice(n,1)}dispatch(t,o){let r=this._eventSlots.get(t);if(r){r.onHandler?.(o);for(let n of[...r.listeners])n(o)}}_ensureEventSlot(t){let o=this._eventSlots.get(t);return o||(o={listeners:[]},this._eventSlots.set(t,o)),o}},wg=class{_methods=new Set;claim(t,o){if(this._methods.has(t))throw Error(`Handler for "${t}" already registered (via ${o}). Use addEventListener() to attach multiple listeners, or the on* setter for replace semantics.`);this._methods.add(t)}replace(t){this._methods.add(t)}release(t){this._methods.delete(t)}has(t){return this._methods.has(t)}},$y=new Set;function Cy(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";$y.has(i)||($y.add(i),console.warn(`[ext-apps] ${i}(Schema, handler) is deprecated; use ${i}("${s}", { params: Schema.shape.params }, handler).`));let a=r;return[s,{params:n.params},e==="request"?(l,u)=>a({method:s,params:l},yP(u)):l=>a({method:s,params:l})]}function yP(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 qy="2026-01-26";var zP="ui/notifications/tool-input-partial";var vP=p.union([p.literal("light"),p.literal("dark")]).describe("Color theme preference for the host environment."),Fa=p.union([p.literal("inline"),p.literal("fullscreen"),p.literal("pip")]).describe("Display mode for UI presentation."),RP=p.union([p.literal("--color-background-primary"),p.literal("--color-background-secondary"),p.literal("--color-background-tertiary"),p.literal("--color-background-inverse"),p.literal("--color-background-ghost"),p.literal("--color-background-info"),p.literal("--color-background-danger"),p.literal("--color-background-success"),p.literal("--color-background-warning"),p.literal("--color-background-disabled"),p.literal("--color-text-primary"),p.literal("--color-text-secondary"),p.literal("--color-text-tertiary"),p.literal("--color-text-inverse"),p.literal("--color-text-ghost"),p.literal("--color-text-info"),p.literal("--color-text-danger"),p.literal("--color-text-success"),p.literal("--color-text-warning"),p.literal("--color-text-disabled"),p.literal("--color-border-primary"),p.literal("--color-border-secondary"),p.literal("--color-border-tertiary"),p.literal("--color-border-inverse"),p.literal("--color-border-ghost"),p.literal("--color-border-info"),p.literal("--color-border-danger"),p.literal("--color-border-success"),p.literal("--color-border-warning"),p.literal("--color-border-disabled"),p.literal("--color-ring-primary"),p.literal("--color-ring-secondary"),p.literal("--color-ring-inverse"),p.literal("--color-ring-info"),p.literal("--color-ring-danger"),p.literal("--color-ring-success"),p.literal("--color-ring-warning"),p.literal("--font-sans"),p.literal("--font-mono"),p.literal("--font-weight-normal"),p.literal("--font-weight-medium"),p.literal("--font-weight-semibold"),p.literal("--font-weight-bold"),p.literal("--font-text-xs-size"),p.literal("--font-text-sm-size"),p.literal("--font-text-md-size"),p.literal("--font-text-lg-size"),p.literal("--font-heading-xs-size"),p.literal("--font-heading-sm-size"),p.literal("--font-heading-md-size"),p.literal("--font-heading-lg-size"),p.literal("--font-heading-xl-size"),p.literal("--font-heading-2xl-size"),p.literal("--font-heading-3xl-size"),p.literal("--font-text-xs-line-height"),p.literal("--font-text-sm-line-height"),p.literal("--font-text-md-line-height"),p.literal("--font-text-lg-line-height"),p.literal("--font-heading-xs-line-height"),p.literal("--font-heading-sm-line-height"),p.literal("--font-heading-md-line-height"),p.literal("--font-heading-lg-line-height"),p.literal("--font-heading-xl-line-height"),p.literal("--font-heading-2xl-line-height"),p.literal("--font-heading-3xl-line-height"),p.literal("--border-radius-xs"),p.literal("--border-radius-sm"),p.literal("--border-radius-md"),p.literal("--border-radius-lg"),p.literal("--border-radius-xl"),p.literal("--border-radius-full"),p.literal("--border-width-regular"),p.literal("--shadow-hairline"),p.literal("--shadow-sm"),p.literal("--shadow-md"),p.literal("--shadow-lg")]).describe("CSS variable keys available to MCP apps for theming."),wP=p.record(RP.describe(`Style variables for theming MCP apps.
75
+ `,v),ee=-1;if(Z!==-1&&oe!==-1?ee=Z<oe?Z:oe:Z!==-1?Z===x.length-1?ee=-1:ee=Z:oe!==-1&&(ee=oe),ee===-1)break;H(x,v,ee),v=ee+1,x.charCodeAt(v-1)===px&&x.charCodeAt(v)===ey&&v++}return x.slice(v)}function H(x,v,Z){if(v===Z){N();return}let oe=x.charCodeAt(v);if(ty(x,v,oe)){let ze=x.charCodeAt(v+5)===hr?v+6:v+5,Ce=x.slice(ze,Z);d=h===0?Ce:`${d}
76
+ ${Ce}`,h++;return}if(oy(x,v,oe)){f=x.slice(x.charCodeAt(v+6)===hr?v+7:v+6,Z)||void 0;return}if(oe===105&&x.charCodeAt(v+1)===100&&x.charCodeAt(v+2)===58){let ze=x.slice(x.charCodeAt(v+3)===hr?v+4:v+3,Z);ze.includes("\0")||(u=ze);return}if(oe===58){if(n){let ze=x.slice(v,Z);n(ze.slice(x.charCodeAt(v+1)===hr?2:1))}return}let ee=x.slice(v,Z),de=ee.indexOf(":");if(de===-1){W(ee,"",ee);return}let $e=ee.slice(0,de),ie=ee.charCodeAt(de+1)===hr?2:1,ue=ee.slice(de+ie);W($e,ue,ee)}function W(x,v,Z){switch(x){case"event":f=v||void 0;break;case"data":d=h===0?v:`${d}
77
+ ${v}`,h++;break;case"id":v.includes("\0")||(u=v);break;case"retry":/^\d+$/.test(v)?r(parseInt(v,10)):o(new Ua(`Invalid \`retry\` value: "${v}"`,{type:"invalid-retry",value:v,line:Z}));break;default:o(new Ua(`Unknown field "${x.length>20?`${x.slice(0,20)}\u2026`:x}"`,{type:"unknown-field",field:x,value:v,line:Z}));break}}function N(){h>0&&t({id:u,event:f,data:d}),u=void 0,d="",h=0,f=void 0}function D(x={}){if(x.consume&&i.length>0){let v=i.join("");H(v,0,v.length)}l=!0,u=void 0,d="",h=0,f=void 0,i.length=0,a=0,S=!1}return{feed:y,reset:D}}function ty(e,t,o){return o===100&&e.charCodeAt(t+1)===97&&e.charCodeAt(t+2)===116&&e.charCodeAt(t+3)===97&&e.charCodeAt(t+4)===58}function oy(e,t,o){return o===101&&e.charCodeAt(t+1)===118&&e.charCodeAt(t+2)===101&&e.charCodeAt(t+3)===110&&e.charCodeAt(t+4)===116&&e.charCodeAt(t+5)===58}var Eu=class extends TransformStream{constructor({onError:t,onRetry:o,onComment:r,maxBufferSize:n}={}){let s;super({start(i){s=ry({onEvent:a=>{i.enqueue(a)},onError(a){typeof t=="function"&&t(a),(t==="terminate"||a.type==="max-buffer-size-exceeded")&&i.error(a)},onRetry:o,onComment:r,maxBufferSize:n})},transform(i){s.feed(i)}})}};var Da=class extends Error{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.OAuthClientFlowError"})}static[Symbol.hasInstance](e){return et(this,e)}static isInstance(e){if(typeof this!="function")throw new TypeError("isInstance must be called on the class (e.g. `SdkError.isInstance(value)`); for callbacks use `v => SdkError.isInstance(v)`");return et(this,e)}constructor(e){super(e),this.name=new.target.name,lr(this,new.target)}},Sg=class extends Da{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 \xA73.3)":"authorization response (RFC 9207)"}: expected ${JSON.stringify(t)}, received ${JSON.stringify(o)}`),this.kind=e,this.expected=t,this.received=o}},hx=class extends Da{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}},gy=class extends Da{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}},Cu=class extends Da{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}},ny=class extends Da{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}};function _g(e,t,o){if(e)return typeof e.issuer!="string"?(o?.canPersistStamp!==!1&&console.warn("[mcp-sdk] SEP-2352: stored OAuth credential has no 'issuer' stamp (pre-upgrade storage or provider not round-tripping the value). SEP-2352 isolation is inactive for this read; ensure your provider round-trips the issuer field."),e.issuer===void 0?e:{...e,issuer:void 0}):Sy(e.issuer,t)?e:void 0}function Sy(e,t){return e===t||e.endsWith("/")&&e.slice(0,-1)===t||t.endsWith("/")&&t.slice(0,-1)===e}function mx(e){if(e==null)return!1;let t=e;return typeof t.tokens=="function"&&typeof t.clientInformation=="function"}async function fx(e,t,o){let{resourceMetadataUrl:r,scope:n}=Za(t.response);if(await bg(e,{serverUrl:t.serverUrl,resourceMetadataUrl:r,scope:n,fetchFn:t.fetchFn,...o})!=="AUTHORIZED")throw new At}function gx(e,t){return{token:async()=>(await e.tokens())?.access_token,onUnauthorized:async o=>fx(e,o,t)}}var At=class extends Error{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.UnauthorizedError"})}static[Symbol.hasInstance](e){return et(this,e)}static isInstance(e){if(typeof this!="function")throw new TypeError("isInstance must be called on the class (e.g. `SdkError.isInstance(value)`); for callbacks use `v => SdkError.isInstance(v)`");return et(this,e)}constructor(e){super(e??"Unauthorized"),this.name="UnauthorizedError",lr(this,new.target)}};function zg(e){return e?.authorization_response_iss_parameter_supported===!0}function vg({iss:e,expectedIssuer:t,issParameterSupported:o}){if(t!==void 0){if(e===void 0){if(o)throw new Sg("authorization_response",t,void 0);return}if(e!==t)throw new Sg("authorization_response",t,e)}}function dg(...e){let t=new Set;for(let o of e)if(o)for(let r of o.split(/\s+/))r&&t.add(r);return t.size>0?[...t].join(" "):void 0}function Sx(e,t){if(!e)return!1;let o=new Set((t??"").split(/\s+/).filter(Boolean));for(let r of e.split(/\s+/))if(r&&!o.has(r))return!0;return!1}async function _x(e,t,o,r,n){if(typeof e=="string")return{authorizationCode:e,iss:t};let s=e.get("iss")??void 0,i=e.get("code");if(i)return{authorizationCode:i,iss:s};let a=(await o.discoveryState?.())?.authorizationServerMetadata;if(!a)try{a=(await vy(r,n)).authorizationServerMetadata}catch{a=void 0}if(!a)throw new At("Authorization callback failed and the issuer could not be verified");vg({iss:s,expectedIssuer:a.issuer,issParameterSupported:zg(a)});let l=e.get("error");throw l?new ur(l,e.get("error_description")??l,e.get("error_uri")??void 0):new At("Authorization callback contained neither `code` nor `error`")}function bx(e){return["client_secret_basic","client_secret_post","none"].includes(e)}var pg="code",hg="S256";function yx(e,t){let o=e.client_secret!==void 0;return"token_endpoint_auth_method"in e&&e.token_endpoint_auth_method&&bx(e.token_endpoint_auth_method)&&(t.length===0||t.includes(e.token_endpoint_auth_method))?e.token_endpoint_auth_method:t.length===0?o?"client_secret_basic":"none":o&&t.includes("client_secret_basic")?"client_secret_basic":o&&t.includes("client_secret_post")?"client_secret_post":t.includes("none")?"none":o?"client_secret_post":"none"}function zx(e,t,o,r){let{client_id:n,client_secret:s}=t;switch(e){case"client_secret_basic":vx(n,s,o);return;case"client_secret_post":Rx(n,s,r);return;case"none":wx(n,r);return;default:throw new Error(`Unsupported client authentication method: ${e}`)}}function vx(e,t,o){if(!t)throw new Error("client_secret_basic authentication requires a client_secret");let r=btoa(`${e}:${t}`);o.set("Authorization",`Basic ${r}`)}function Rx(e,t,o){o.set("client_id",e),t&&o.set("client_secret",t)}function wx(e,t){t.set("client_id",e)}function _y(e){return e==="localhost"||e.endsWith(".localhost")||e==="127.0.0.1"||e==="[::1]"||e==="::1"}function xx(e){let t=new URL(String(e));if(t.protocol!=="https:"&&!_y(t.hostname))throw new gy(t.href);return t}function Px(e){for(let t of e??[]){let o;try{o=new URL(t)}catch{continue}if(o.protocol!=="http:"&&o.protocol!=="https:"||_y(o.hostname))return"native"}return"web"}function Tx(e){let t=e.clientMetadata;return{...t,grant_types:t.grant_types??(e.redirectUrl===void 0?void 0:["authorization_code","refresh_token"]),application_type:t.application_type??Px(t.redirect_uris)}}async function sy(e){let t=e instanceof Response?e.status:void 0,o=e instanceof Response?await e.text():e;try{let r=Mn.parse(JSON.parse(o));return ur.fromResponse(r)}catch(r){let n=`${t?`HTTP ${t}: `:""}Invalid OAuth error response: ${r}. Raw body: ${o}`;return new ur(eo.ServerError,n)}}function iy(e,t,o){let r=e.invalidateCredentials===void 0?`retrying authorization without discarding the stored ${o} (provider implements no invalidateCredentials())`:`invalidating the stored ${o} and retrying authorization`;console.warn(`[mcp-sdk] OAuth ${JSON.stringify(t.code)} \u2014 ${r}. Cause: ${JSON.stringify(t.message)}`)}async function bg(e,t){try{return await mg(e,t)}catch(o){if(o instanceof ur){if(o.code===eo.InvalidClient||o.code===eo.UnauthorizedClient)return iy(e,o,"client credentials and tokens"),await e.invalidateCredentials?.("client"),await e.invalidateCredentials?.("tokens"),await mg(e,t);if(o.code===eo.InvalidGrant||o.code===eo.InvalidDpopProof)return iy(e,o,"tokens"),await e.invalidateCredentials?.("tokens"),await mg(e,t)}throw o}}function Ex(e){let{requestedScope:t,resourceMetadata:o,authServerMetadata:r,clientMetadata:n}=e,s=t||o?.scopes_supported?.join(" ")||n.scope;return s&&r?.scopes_supported?.includes("offline_access")&&!s.split(" ").includes("offline_access")&&n.grant_types?.includes("refresh_token")&&(s=`${s} offline_access`),s}async function mg(e,{serverUrl:t,authorizationCode:o,iss:r,scope:n,resourceMetadataUrl:s,fetchFn:i,skipIssuerMetadataValidation:a,forceReauthorization:l}){let u=Tx(e),d=await e.discoveryState?.(),h,f,S,y,w=s;if(!w&&d?.resourceMetadataUrl&&(w=new URL(d.resourceMetadataUrl)),d?.authorizationServerUrl){if(f=d.authorizationServerUrl,h=d.resourceMetadata,S=d.authorizationServerMetadata??await zy(f,{fetchFn:i,skipIssuerValidation:a}),!h)try{h=await by(t,{resourceMetadataUrl:w},i)}catch(ie){if(ie instanceof TypeError)throw ie}(S!==d.authorizationServerMetadata||h!==d.resourceMetadata)&&await e.saveDiscoveryState?.({authorizationServerUrl:String(f),resourceMetadataUrl:w?.toString(),resourceMetadata:h,authorizationServerMetadata:S})}else{let ie=await vy(t,{resourceMetadataUrl:w,fetchFn:i,skipIssuerMetadataValidation:a});f=ie.authorizationServerUrl,S=ie.authorizationServerMetadata,h=ie.resourceMetadata,y={authorizationServerUrl:String(f),resourceMetadataUrl:w?.toString(),resourceMetadata:h,authorizationServerMetadata:S}}let z=S?.issuer??String(f),H={issuer:z};if(await e.saveAuthorizationServerUrl?.(z),o!==void 0){let ie=d?.authorizationServerMetadata?.issuer??d?.authorizationServerUrl;if(ie===void 0){if(e.saveDiscoveryState!==void 0)throw new Cu("discoveryState was not available on the callback leg; ensure your provider persists discoveryState alongside codeVerifier",z);console.warn("[mcp-sdk] OAuthClientProvider does not implement saveDiscoveryState()/discoveryState(); the SEP-2352 callback-leg authorization-server binding cannot be checked. Implement discoveryState (persist alongside codeVerifier) \u2014 see docs/migration/upgrade-to-v2.md \xA7SEP-2352.")}else if(!Sy(ie,z))throw new Cu(ie,z)}y&&await e.saveDiscoveryState?.(y);let W=await $x(t,e,h),N=W&&h&&!e.validateResourceURL?h.resource:W;N&&await e.saveResourceUrl?.(Rg(N));let D=Ex({requestedScope:n,resourceMetadata:h,authServerMetadata:S,clientMetadata:e.clientMetadata}),x=await Promise.resolve(e.clientInformation(H)),v=_g(x,z,{canPersistStamp:e.saveClientInformation!==void 0});if(v===void 0&&x?.issuer&&e.saveClientInformation===void 0)throw new Cu(x.issuer,z);if(v&&v.issuer===void 0&&(v={...v,issuer:z},await e.saveClientInformation?.(v,H)),!v){if(o!==void 0)throw new Error("Existing OAuth client information is required when exchanging an authorization code");let ie=S?.client_id_metadata_document_supported===!0,ue=e.clientMetadataUrl;if(ue&&!kx(ue))throw new ur(eo.InvalidClientMetadata,`clientMetadataUrl must be a valid HTTPS URL with a non-root pathname, got: ${ue}`);if(ie&&ue)v={client_id:ue,issuer:z},await e.saveClientInformation?.(v,H);else{if(!e.saveClientInformation)throw new Error("OAuth client information must be saveable for dynamic registration");v={...await Ux(f,{metadata:S,clientMetadata:u,scope:D,fetchFn:i}),issuer:z},await e.saveClientInformation(v,H)}}let Z=!e.redirectUrl;if(o!==void 0||Z){o!==void 0&&vg({iss:r,expectedIssuer:S?.issuer,issParameterSupported:zg(S)});let ie=await Lx(e,f,{metadata:S,resource:N,authorizationCode:o,iss:r,scope:D,fetchFn:i});return await e.saveTokens({...ie,issuer:z},H),"AUTHORIZED"}let oe=_g(await e.tokens(H),z);if(oe&&oe.issuer===void 0&&(oe={...oe,issuer:z},await e.saveTokens(oe,H)),oe?.refresh_token&&!l){let ie;try{ie=await jx(f,{metadata:S,clientInformation:v,refreshToken:oe.refresh_token,resource:N,addClientAuthentication:e.addClientAuthentication,dpop:await e.dpop?.(),fetchFn:i})}catch(ue){if(ue instanceof gy)throw ue;if(!(ue instanceof ur)||ue.code===eo.ServerError)console.warn(`[mcp-sdk] Could not refresh OAuth tokens; falling back to a new authorization request. Cause: ${JSON.stringify(ue instanceof Error?ue.message:String(ue))}`);else throw ue}if(ie)return await e.saveTokens({...ie,issuer:z},H),"AUTHORIZED"}let ee=e.state?await e.state():void 0,{authorizationUrl:de,codeVerifier:$e}=await Mx(f,{metadata:S,clientInformation:v,state:ee,redirectUrl:e.redirectUrl,scope:D,resource:N});return await e.saveCodeVerifier($e),await e.redirectToAuthorization(de),"REDIRECT"}function kx(e){if(!e)return!1;try{let t=new URL(e);return t.protocol==="https:"&&t.pathname!=="/"}catch{return!1}}async function $x(e,t,o){let r=ib(e);if(t.validateResourceURL)return await t.validateResourceURL(r,o?.resource);if(o){if(!ab({requestedResource:r,configuredResource:o.resource}))throw new Error(`Protected resource ${o.resource} does not match expected ${r} (or origin)`);return new URL(o.resource)}}var Cx=new Set(["bearer","dpop"]);function Za(e){let t=e.headers.get("WWW-Authenticate");if(!t)return{};let[o,r]=t.split(" ");if(!o||!Cx.has(o.toLowerCase())||!r)return{};let n=ku(e,"resource_metadata")||void 0,s;if(n)try{s=new URL(n)}catch{}let i=ku(e,"scope")||void 0,a=ku(e,"error")||void 0,l=ku(e,"error_description")||void 0;return{resourceMetadataUrl:s,scope:i,error:a,errorDescription:l}}function ku(e,t){let o=e.headers.get("WWW-Authenticate");if(!o)return null;let r=new RegExp(String.raw`${t}=(?:"([^"]+)"|([^\s,]+))`),n=o.match(r);if(n){let s=n[1]||n[2];if(s)return s}return null}async function by(e,t,o=fetch){let r=await Nx(e,"oauth-protected-resource",o,{protocolVersion:t?.protocolVersion,metadataUrl:t?.resourceMetadataUrl});if(!r||r.status===404)throw await r?.text?.().catch(()=>{}),new Error("Resource server does not implement OAuth 2.0 Protected Resource Metadata.");if(!r.ok)throw await r.text?.().catch(()=>{}),new Error(`HTTP ${r.status} trying to load well-known OAuth protected resource metadata.`);return On.parse(await r.json())}async function yy(e,t,o=fetch){let r=ja(o);try{return await r(e,{headers:t})}catch(n){if(!(n instanceof TypeError)||!Qb)throw n;if(t)try{return await r(e,{})}catch(s){if(!(s instanceof TypeError))throw s;return}return}}function Ix(e,t="",o={}){return t.endsWith("/")&&(t=t.slice(0,-1)),o.prependPathname?`${t}/.well-known/${e}`:`/.well-known/${e}${t}`}async function ay(e,t,o=fetch){return await yy(e,{"MCP-Protocol-Version":t},o)}function Ox(e,t){return e?t==="/"?!1:!e.ok&&e.status<500||e.status===502:!0}async function Nx(e,t,o,r){let n=new URL(e),s=r?.protocolVersion??nn,i;if(r?.metadataUrl)i=new URL(r.metadataUrl);else{let l=Ix(t,n.pathname);i=new URL(l,r?.metadataServerUrl??n),i.search=n.search}let a=await ay(i,s,o);return!r?.metadataUrl&&Ox(a,n.pathname)&&(a=await ay(new URL(`/.well-known/${t}`,n),s,o)),a}function qx(e){let t=typeof e=="string"?new URL(e):e,o=t.pathname!=="/",r=[];if(!o)return r.push({url:new URL("/.well-known/oauth-authorization-server",t.origin),type:"oauth"},{url:new URL("/.well-known/openid-configuration",t.origin),type:"oidc"}),r;let n=t.pathname;return n.endsWith("/")&&(n=n.slice(0,-1)),r.push({url:new URL(`/.well-known/oauth-authorization-server${n}`,t.origin),type:"oauth"},{url:new URL(`/.well-known/openid-configuration${n}`,t.origin),type:"oidc"},{url:new URL(`${n}/.well-known/openid-configuration`,t.origin),type:"oidc"}),r}async function zy(e,{fetchFn:t=fetch,protocolVersion:o=nn,skipIssuerValidation:r=!1}={}){let n={"MCP-Protocol-Version":o,Accept:"application/json"},s=qx(e);for(let{url:i,type:a}of s){let l=await yy(i,n,t);if(!l)continue;if(!l.ok){if(await l.text?.().catch(()=>{}),l.status<500||l.status===502)continue;throw new Error(`HTTP ${l.status} trying to load ${a==="oauth"?"OAuth":"OpenID provider"} metadata from ${i}`)}let u=a==="oauth"?cr.parse(await l.json()):Nn.parse(await l.json());if(!r){let d=typeof e=="string"?e:e.href;if(!(u.issuer===d||d.endsWith("/")&&u.issuer===d.slice(0,-1)))throw new Sg("metadata",d,u.issuer)}return u}}async function vy(e,t){let o,r;try{o=await by(e,{resourceMetadataUrl:t?.resourceMetadataUrl},t?.fetchFn),o.authorization_servers&&o.authorization_servers.length>0&&(r=o.authorization_servers[0])}catch(s){if(s instanceof TypeError)throw s}r||(r=String(new URL("/",e)));let n=await zy(r,{fetchFn:t?.fetchFn,skipIssuerValidation:t?.skipIssuerMetadataValidation});return{authorizationServerUrl:r,authorizationServerMetadata:n,resourceMetadata:o}}function Rg(e){return typeof e=="string"?e:e.href}async function Mx(e,{metadata:t,clientInformation:o,redirectUrl:r,scope:n,state:s,resource:i}){let a;if(t){if(a=new URL(t.authorization_endpoint),!t.response_types_supported.includes(pg))throw new Error(`Incompatible auth server: does not support response type ${pg}`);if(t.code_challenge_methods_supported&&!t.code_challenge_methods_supported.includes(hg))throw new Error(`Incompatible auth server: does not support code challenge method ${hg}`)}else a=new URL("/authorize",e);let l=await lg(),u=l.code_verifier,d=l.code_challenge;return a.searchParams.set("response_type",pg),a.searchParams.set("client_id",o.client_id),a.searchParams.set("code_challenge",d),a.searchParams.set("code_challenge_method",hg),a.searchParams.set("redirect_uri",String(r)),s&&a.searchParams.set("state",s),n&&a.searchParams.set("scope",n),n?.split(" ").includes("offline_access")&&a.searchParams.append("prompt","consent"),i&&a.searchParams.set("resource",Rg(i)),{authorizationUrl:a,codeVerifier:u}}function Ax(e,t,o){return new URLSearchParams({grant_type:"authorization_code",code:e,code_verifier:t,redirect_uri:String(o)})}async function Ry(e,{metadata:t,tokenRequestParams:o,clientInformation:r,addClientAuthentication:n,resource:s,dpop:i,fetchFn:a}){let l=xx(t?.token_endpoint??new URL("/token",e)),u=new Headers({"Content-Type":"application/x-www-form-urlencoded",Accept:"application/json"});s&&o.set("resource",Rg(s)),!n&&r&&zx(yx(r,t?.token_endpoint_auth_methods_supported??[]),r,u,o);let d=async()=>{let S=new Headers(u);return n&&await n(S,o,l,t),i&&S.set("DPoP",await i.buildProof({htm:"POST",htu:l})),ja(a??fetch)(l,{method:"POST",headers:S,body:o})},h=await d();if(i&&h.status===400&&(await h.clone().json().catch(()=>{}))?.error===eo.UseDpopNonce&&(i.observeNonce(h,l),h=await d()),i?.observeNonce(h,l),!h.ok)throw await sy(h);let f=await h.json();try{return qn.parse(Wf(f))}catch(S){throw typeof f=="object"&&f!==null&&"error"in f?await sy(JSON.stringify(f)):S}}async function jx(e,{metadata:t,clientInformation:o,refreshToken:r,resource:n,addClientAuthentication:s,dpop:i,fetchFn:a}){return{refresh_token:r,...await Ry(e,{metadata:t,tokenRequestParams:new URLSearchParams({grant_type:"refresh_token",refresh_token:r}),clientInformation:o,addClientAuthentication:s,resource:n,dpop:i,fetchFn:a})}}async function Lx(e,t,{metadata:o,resource:r,authorizationCode:n,iss:s,scope:i,fetchFn:a}={}){n!==void 0&&vg({iss:s,expectedIssuer:o?.issuer,issParameterSupported:zg(o)});let l=o?.issuer??String(t),u=async()=>{let S=await e.clientInformation({issuer:l}),y=_g(S,l,{canPersistStamp:!1});if(S&&y===void 0)throw new Cu(String(S.issuer),l);return y},d=await u(),h=i??e.clientMetadata.scope,f;if(e.prepareTokenRequest&&(f=await e.prepareTokenRequest(h)),!f){if(!n)throw new Error("Either provider.prepareTokenRequest() or authorizationCode is required");if(!e.redirectUrl)throw new Error("redirectUrl is required for authorization_code flow");f=Ax(n,await e.codeVerifier(),e.redirectUrl)}return d??=await u(),Ry(t,{metadata:o,tokenRequestParams:f,clientInformation:d,addClientAuthentication:e.addClientAuthentication,resource:r,dpop:await e.dpop?.(),fetchFn:a})}async function Ux(e,{metadata:t,clientMetadata:o,scope:r,fetchFn:n}){let s;if(t){if(!t.registration_endpoint)throw new Error("Incompatible auth server: does not support dynamic client registration");s=new URL(t.registration_endpoint)}else s=new URL("/register",e);let i={...o,...r===void 0?{}:{scope:r}},a=await ja(n??fetch)(s,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(i)});if(!a.ok)throw new hx({status:a.status,body:await a.text(),submittedMetadata:i});return An.parse(Wf(await a.json()))}var $u=new Set(["tools/list","prompts/list","resources/list","resources/templates/list","server/discover"]),Zx=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(fg(e))}set(e,t){let o=fg(e),r=$u.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(!$u.has(i.slice(0,i.indexOf("\0")))){this._entries.delete(i),this._cappedSize--;break}}let s=++this._stamp;return this._entries.set(o,{...t,stamp:s}),n&&!r&&this._cappedSize++,s}delete(e){this._entries.delete(fg(e))&&!$u.has(e.method)&&this._cappedSize--}evict(e){let t=`${e}\0`,o=$u.has(e);for(let r of this._entries.keys())r.startsWith(t)&&(this._entries.delete(r),o||this._cappedSize--)}clear(){this._entries.clear(),this._cappedSize=0}};function fg(e){return`${e.method}\0${JSON.stringify([e.partition??"",e.params??""])}`}function gg(e,t){return t===void 0?e:`${e}\0${t}`}var Dx=864e5,Fx=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=gg(e,t),r=this._evictionGeneration.get(o);r!==void 0&&this._evictionGeneration.set(o,r+1),await this._deleteBoth(e,t)}captureGeneration(e,t){let o=gg(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(gg(e,r?.params))??0)!==o)return;let n=r?.params??"",s=this._partitionFor("private"),i=this._partitionFor("public"),a=(r?.scope??"private")==="public"?i:s;try{await this._store.set({method:e,params:n,partition:a},{value:Hx(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:a===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())))try{let r=JSON.parse(o.value);if(typeof r!="object"||r===null||Array.isArray(r))throw new TypeError("cached document is not an object");return{value:r}}catch(r){this._reportError(r),await this._deleteBoth(e,t??"");return}}resetForReconnect(){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);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 new TypeError("cached tools/list document has a malformed tools array");return t}catch(t){this._reportError(t);return}}};function Hx(e){let t;try{t=JSON.stringify(e)}catch(o){throw new TypeError(`cache value is not JSON-serializable: ${o instanceof Error?o.message:String(o)}`)}if(typeof t!="string")throw new TypeError("cache value is not JSON-serializable: it has no JSON representation");return t}var wy=Symbol.for("mcp.authSeamEscape");function at(e){if(typeof e=="object"&&e!==null||typeof e=="function")try{Object.defineProperty(e,wy,{value:!0,configurable:!0})}catch{}return e}function Vx(e){return(typeof e=="object"&&e!==null||typeof e=="function")&&e[wy]===!0}var Jx=-32022,Bx=new Set([-32001,-32020,-32021]);function Wx(e,t){switch(e.kind){case"result":return Kx(e.result,t);case"rpc-error":return xy(e,t);case"http-error":return Gx(e,t);case"network-error":return cy(e.error,t);case"unusable-reply":return{kind:"error",error:new M(q.EraNegotiationFailed,`Version negotiation probe failed: the server answered with an unusable reply (${Py(e.error)})`,{cause:e.error},{cause:e.error})};case"auth-required":return{kind:"error",error:e.error};case"closed":return t.transportKind==="stdio"?{kind:"legacy"}:cy(new Error("Connection closed during the version negotiation probe"),t);case"timeout":return t.transportKind==="stdio"?{kind:"legacy"}:{kind:"error",error:new M(q.RequestTimeout,`Version negotiation probe timed out after ${e.timeoutMs}ms`,{timeout:e.timeoutMs})}}}function Kx(e,t){let o=Qt(wu).validateResult("server/discover",e);if(!o.ok)return{kind:"legacy"};let r=o.value.supportedVersions,n=t.clientModernVersions.find(s=>r.includes(s));return n!==void 0?{kind:"modern",version:n,discover:o.value}:t.fallbackAvailable?{kind:"legacy"}:{kind:"error",error:new Ru({supported:[...r],requested:t.requestedVersion})}}function xy(e,t){let{code:o,message:r,data:n}=e;if(o===Jx){let s=Xx(n);if(s===void 0)return{kind:"legacy"};let i=new Ru({supported:s,requested:Qx(n)??t.requestedVersion},r),a=Aa(s),l=t.clientModernVersions.find(u=>a.includes(u));return l!==void 0?{kind:"corrective",version:l,error:i}:a.length>0?{kind:"error",error:i}:t.fallbackAvailable?{kind:"legacy"}:{kind:"error",error:i}}return Bx.has(o)?{kind:"legacy"}:{kind:"legacy"}}function Gx(e,t){if(e.status===401||e.status===403){let r=e.status===403;return{kind:"error",error:new qt(r?q.ClientHttpForbidden:q.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 qt(q.EraNegotiationFailed,`Version negotiation failed: the server answered the probe with HTTP ${e.status}`,{status:e.status,statusText:e.statusText,text:e.body})};let o=eP(e.body);return o!==void 0?xy(o,t):{kind:"legacy"}}function cy(e,t){return t.environment==="browser"&&Yx(e)?{kind:"legacy"}:{kind:"error",error:new M(q.EraNegotiationFailed,`Version negotiation probe failed: ${Py(e)}`,{cause:e},{cause:e})}}function Yx(e){return e instanceof TypeError||e instanceof Error&&e.name==="TypeError"}function Py(e){return e instanceof Error?e.message:String(e)}function Xx(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 t}function Qx(e){if(typeof e!="object"||e===null)return;let t=e.requested;return typeof t=="string"?t:void 0}function eP(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{code:r,message:typeof n=="string"?n:"",data:s}}var tP="legacy";function oP(e,t){let o=e?.mode??tP;if(o==="legacy")return{kind:"legacy"};let r=e?.probe??{};if(typeof o=="object"){if(!to(o.pin))throw new TypeError(`versionNegotiation: { pin: '${o.pin}' } is not a modern protocol revision \u2014 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?Aa(t):[];return{kind:"auto",modernVersions:n.length>0?n:[...Kf],fallbackAvailable:t?Gf(t).length>0:!0,probe:r}}function ly(){let e=globalThis;return e.window!==void 0&&e.document!==void 0?"browser":"node"}function uy(e){return"stderr"in e&&"pid"in e?"stdio":"http"}var rP=class Ty{_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 Ty(t);t.onmessage=r=>{let n=o._pending;if(n!==void 0&&(Ln(r)||Un(r))&&r.id===n.id){o._pending=void 0,Ln(r)?n.resolve({kind:"response",result:r.result}):n.resolve({kind:"response",error:r.error});return}},t.onerror=r=>{o._savedOnError?.(r)},t.onclose=()=>{let r=o._pending;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=>{s||(s=!0,clearTimeout(a),this._pending?.id===r&&(this._pending=void 0),n(l))},a=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,yg.set(o,()=>{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)}}},yg=new WeakMap;function dy(e){let t=yg.get(e);yg.delete(e),t?.()}function nP(e,t,o,r){return{jsonrpc:"2.0",id:e,method:"server/discover",params:{_meta:Qt(t).outboundEnvelope({protocolVersion:t,clientInfo:o,clientCapabilities:r})}}}function sP(e){return e instanceof M&&e.code===q.ClientHttpUnexpectedContent?!0:e instanceof Error&&e.name==="SyntaxError"}function iP(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(Vx(o)||o instanceof At||o instanceof Error&&o.name==="UnauthorizedError")return{kind:"auth-required",error:o};if(o instanceof qt){let r=o.data?.text;return{kind:"http-error",status:o.data.status,body:typeof r=="string"?r:void 0,statusText:o.data.statusText}}return sP(o)?{kind:"unusable-reply",error:o}:{kind:"network-error",error:o}}case"closed":return{kind:"closed"};case"timeout":return{kind:"timeout",timeoutMs:t}}}async function Ey(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 rP.open(t.transport),a=async()=>{let u=n[0],d=!1,h=r;for(;;){let f=await i.exchange(w=>nP(w,u,t.clientInfo,t.capabilities),o);if(f.kind==="timeout"&&h>0){h--;continue}let S=iP(f,o),y=Wx(S,{clientModernVersions:n,requestedVersion:u,fallbackAvailable:s,environment:t.environment,transportKind:t.transportKind});switch(y.kind){case"modern":return{era:"modern",version:y.version,discover:y.discover};case"corrective":if(d)throw y.error;d=!0,u=y.version;continue;case"legacy":{let w=S.kind==="closed"?"the connection closed during the server/discover probe":void 0;if(e.kind==="pin")throw new M(q.EraNegotiationFailed,w===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: ${w} before the server offered pinned protocol version ${e.version} (no fallback in pin mode)`);if(!e.fallbackAvailable)throw new M(q.EraNegotiationFailed,w===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: ${w} and this client supports no pre-2026-07-28 protocol version to fall back to`);if(w!==void 0&&t.disposableProbe!==!0)throw new M(q.EraNegotiationFailed,`Version negotiation failed: ${w} (this transport probed in place \u2014 the disposable sibling probe requires the SDK's base StdioClientTransport)`);return{era:"legacy"}}case"error":throw y.error}}},l;try{l=await a()}catch(u){throw i.detach(),u}return i.release(),l}function aP(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 cP(e,t,o,r){let n=t.constructor,s=new n({...o,stderr:"ignore"}),i=t.close,a=!1,l,u=new Promise((h,f)=>{l=()=>f(py())});t.close=async function(){return a=!0,l?.(),i.call(t)};let d;try{let h=Ey(e,{...r,transport:s,transportKind:"stdio",disposableProbe:!0});h.catch(()=>{}),d=await Promise.race([h,u])}finally{await lP(s),t.close=i}if(a)throw py();return d}function py(){return new M(q.EraNegotiationFailed,"Version negotiation failed: the transport was closed during the server/discover probe")}async function lP(e){try{let t=e._dispose;await(typeof t=="function"?t.call(e):e.close())}catch{}}function hy(e){let t=e._meta?.[Bt];return Zb.Implementation(t)?t:void 0}function Iu(e,t){if(!(!e||t===null||typeof t!="object")){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];o[n]===void 0&&Object.prototype.hasOwnProperty.call(s,"default")&&(o[n]=s.default),o[n]!==void 0&&Iu(s,o[n])}}if(Array.isArray(e.anyOf))for(let o of e.anyOf)typeof o!="boolean"&&Iu(o,t);if(Array.isArray(e.oneOf))for(let o of e.oneOf)typeof o!="boolean"&&Iu(o,t)}}function uP(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 dP(e){if(typeof e=="object"&&e!==null&&(e.kind==="legacy"&&!("supportedVersions"in e)&&!("discover"in e)||e.kind==="modern"&&wo.safeParse(e.discover).success))return e;throw new M(q.EraNegotiationFailed,"connect({ prior }): unrecognized prior \u2014 expected { kind: 'modern', discover } or { kind: 'legacy' }")}var my={"notifications/tools/list_changed":["tools/list"],"notifications/prompts/list_changed":["prompts/list"],"notifications/resources/list_changed":["resources/list","resources/templates/list"]},pP=64,ky=class extends Tu{_serverCapabilities;_serverVersion;_capabilities;_instructions;_jsonSchemaValidator;_cache;_defaultCacheTtlMs;_listMaxPages;_listChangedDebounceTimers=new Map;_listChangedConfig;_enforceStrictCapabilities;_versionNegotiation;_supportedProtocolVersionsOption;_inputRequiredDriverConfig;_listenState=new Map;_nextListenId=0;_autoOpenedSubscription;_discoverResult;_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 M(q.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),this._clientInfo=e,this._capabilities=t?.capabilities?{...t.capabilities}:{},this._jsonSchemaValidator=t?.jsonSchemaValidator??new ag,this._enforceStrictCapabilities=t?.enforceStrictCapabilities??!1,this._versionNegotiation=t?.versionNegotiation,this._supportedProtocolVersionsOption=t?.supportedProtocolVersions,this._inputRequiredDriverConfig=Ab(t?.inputRequired),this._cache=new Fx(t?.responseCacheStore??new Zx,t?.responseCacheStore!==void 0,o=>this._reportStoreError(o),t?.cachePartition??""),this._defaultCacheTtlMs=t?.defaultCacheTtlMs??0,this._listMaxPages=t?.listMaxPages??pP,t?.listChanged&&(this._listChangedConfig=t.listChanged)}buildContext(e,t){return e}_shouldDropInbound(e){if(this._negotiatedProtocolVersion!==void 0&&to(this._negotiatedProtocolVersion)&&dr(e))return"drop"}_outboundMetaEnvelope(){let e=this._negotiatedProtocolVersion;if(e!==void 0)return this._wireCodec().outboundEnvelope({protocolVersion:e,clientInfo:this._clientInfo,clientCapabilities:this._capabilities})}_resolveNonCompleteResult(e,t){return this._inputRequiredDriverConfig.autoFulfill?Fb({getRequestHandler:o=>this._getRequestHandler(o),buildContext:o=>this.buildContext(o,void 0),sessionId:this.transport?.sessionId},this._inputRequiredDriverConfig,e,t):Promise.reject(new M(q.UnsupportedResultType,`Unsupported result type 'input_required' for ${t.request.method}: multi-round-trip auto-fulfilment is not enabled on this instance \u2014 pass allowInputRequired: true to handle it manually, or enable inputRequired.autoFulfill`,{resultType:"input_required",method:t.request.method}))}_setupListChangedHandlers(e){e.tools&&this._serverCapabilities?.tools?.listChanged&&this._setupListChangedHandler("tools","notifications/tools/list_changed",e.tools,async()=>(await this.listTools(void 0,{cacheMode:"refresh"})).tools),e.prompts&&this._serverCapabilities?.prompts?.listChanged&&this._setupListChangedHandler("prompts","notifications/prompts/list_changed",e.prompts,async()=>(await this.listPrompts(void 0,{cacheMode:"refresh"})).prompts),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 new Error("Cannot register capabilities after connecting to transport");this._capabilities=Db(this._capabilities,e)}setVersionNegotiation(e){if(this.transport)throw new Error("Cannot configure version negotiation after connecting to transport");this._versionNegotiation=e}_wrapHandler(e,t){return e==="elicitation/create"?async(o,r)=>{let n=Qt(this._negotiatedProtocolVersion),s=n.validateRequest("elicitation/create",o);if(!s.ok&&s.reason==="not-in-era"&&(s=n.validateInputRequest("elicitation/create",o)),!s.ok)throw new se(s.reason==="not-in-era"?B.InternalError:B.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:a,supportsUrlMode:l}=uP(this._capabilities.elicitation);if(i.mode==="form"&&!a)throw new se(B.InvalidParams,"Client does not support form-mode elicitation requests");if(i.mode==="url"&&!l)throw new se(B.InvalidParams,"Client does not support URL-mode elicitation requests");let u=await t(o,r),d=n.validateResult("elicitation/create",u);if(!d.ok&&d.reason==="not-in-era"&&(d=n.validateInputResponse("elicitation/create",u)),!d.ok)throw new se(d.reason==="not-in-era"?B.InternalError:B.InvalidParams,d.reason==="not-in-era"?"No wire schema for elicitation/create in the resolved era":`Invalid elicitation result: ${d.message}`);let h=d.value,f=i.mode==="form"?i.requestedSchema:void 0;if(i.mode==="form"&&h.action==="accept"&&h.content&&f&&this._capabilities.elicitation?.form?.applyDefaults)try{Iu(f,h.content)}catch{}return h}:e==="sampling/createMessage"?async(o,r)=>{let n=Qt(this._negotiatedProtocolVersion),s=n.validateRequest("sampling/createMessage",o);if(!s.ok&&s.reason==="not-in-era"&&(s=n.validateInputRequest("sampling/createMessage",o)),!s.ok)throw new se(s.reason==="not-in-era"?B.InternalError:B.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,a=await t(o,r),l=!!(i.tools||i.toolChoice),u=n.samplingResultVariant(l,a);if(!u.ok&&u.reason==="not-in-era"&&(u=n.validateInputResponse("sampling/createMessage",a)),!u.ok)throw new se(u.reason==="not-in-era"?B.InternalError:B.InvalidParams,u.reason==="not-in-era"?"No result schema for sampling/createMessage in the resolved era":`Invalid sampling result: ${u.message}`);return u.value}:t}assertCapability(e,t){if(!this._serverCapabilities?.[e])throw new M(q.CapabilityNotSupported,`Server does not support ${e} (required for ${t})`)}async connect(e,t){if(t?.prior!=null)return this._connectFromPrior(e,dP(t.prior),t);let o=oP(this._versionNegotiation,this._supportedProtocolVersionsOption);return o.kind!=="legacy"?this._connectNegotiated(e,o,t):this._connectPlainLegacy(e,t)}async _connectPlainLegacy(e,t){if(await super.connect(e),e.sessionId!==void 0){let o=this._negotiatedProtocolVersion;o!==void 0&&e.setProtocolVersion?.(o);return}this._resetConnectionState(),await this._legacyHandshake(e,t)}async _legacyHandshake(e,t){let o=Gf(this._supportedProtocolVersions);try{let r=o[0];if(r===void 0)throw new M(q.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 new Error(`Server sent invalid initialize result: ${n}`);if(!o.includes(n.protocolVersion))throw new Error(`Server's protocol version is not supported: ${n.protocolVersion}`);this._serverCapabilities=n.capabilities,this._serverVersion=n.serverInfo,this._cache.setServerIdentity(this._deriveServerIdentity(e)),e.setProtocolVersion&&e.setProtocolVersion(n.protocolVersion),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;n!==void 0&&e.setProtocolVersion&&e.setProtocolVersion(n);return}this._resetConnectionState();let r;try{let n=uy(e),s={clientInfo:this._clientInfo,capabilities:this._capabilities,environment:ly(),defaultTimeoutMs:o?.timeout??Pu},i=n==="stdio"?aP(e):void 0;r=i===void 0?await Ey(t,{...s,transport:e,transportKind:n}):await cP(t,e,i,s)}catch(n){throw await e.close().catch(()=>{}),dy(e),n}if(dy(e),await super.connect(e),r.era==="legacy"){await this._legacyHandshake(e,o);return}if(this._serverCapabilities=r.discover.capabilities,this._serverVersion=hy(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),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}},a=!0;try{this._setupListChangedHandlers(i)}catch(u){a=!1,this.onerror?.(u instanceof Error?u:new Error(String(u)))}let l=a?{...i.tools&&{toolsListChanged:!0},...i.prompts&&{promptsListChanged:!0},...i.resources&&{resourcesListChanged:!0}}:{};if(Object.keys(l).length>0){let u=new AbortController,d=()=>u.abort(o?.signal?.reason);o?.signal?.aborted&&d(),o?.signal?.addEventListener("abort",d);try{this._autoOpenedSubscription=await this.listen(l,{timeout:o?.timeout,signal:u.signal})}catch(h){if(o?.signal?.aborted)throw await this.close().catch(()=>{}),h;this.onerror?.(h instanceof Error?h:new Error(String(h)))}finally{o?.signal?.removeEventListener("abort",d)}}}}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&&Aa(n).length>0?Aa(n):Kf).find(i=>r.supportedVersions.includes(i));if(s===void 0)throw new M(q.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=hy(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:new Error(String(i)))}}getServerCapabilities(){return this._serverCapabilities}getServerVersion(){return this._serverVersion}_deriveServerIdentity(e){let t=this._serverVersion;return t!==void 0?`${t.name}@${t.version}`: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 to(e)?"modern":"legacy"}getInstructions(){return this._instructions}getDiscoverResult(){return this._discoverResult}assertCapabilityForMethod(e){switch(e){case"logging/setLevel":if(!this._serverCapabilities?.logging)throw new M(q.CapabilityNotSupported,`Server does not support logging (required for ${e})`);break;case"prompts/get":case"prompts/list":if(!this._serverCapabilities?.prompts)throw new M(q.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 M(q.CapabilityNotSupported,`Server does not support resources (required for ${e})`);if(e==="resources/subscribe"&&!this._serverCapabilities.resources.subscribe)throw new M(q.CapabilityNotSupported,`Server does not support resource subscriptions (required for ${e})`);break;case"tools/call":case"tools/list":if(!this._serverCapabilities?.tools)throw new M(q.CapabilityNotSupported,`Server does not support tools (required for ${e})`);break;case"completion/complete":if(!this._serverCapabilities?.completions)throw new M(q.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 M(q.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 M(q.CapabilityNotSupported,`Client does not support sampling capability (required for ${e})`);break;case"elicitation/create":if(!this._capabilities.elicitation)throw new M(q.CapabilityNotSupported,`Client does not support elicitation capability (required for ${e})`);break;case"roots/list":if(!this._capabilities.roots)throw new M(q.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"},wo,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);return o!==void 0?o: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);return o!==void 0?o: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);return o!==void 0?o: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),a=await this.request({method:e,...t&&{params:{...t}}},o),l=a.nextCursor,u=a,d=1;for(;l!==void 0;){if(this._listMaxPages!==0&&d>=this._listMaxPages)throw new M(q.ListPaginationExceeded,`${e}: exceeded listMaxPages (${this._listMaxPages}); server pagination did not terminate`,{method:e,listMaxPages:this._listMaxPages});let h=await this.request({method:e,params:{...t,cursor:l}},o);if(h.nextCursor===l&&JSON.stringify(r(h))===JSON.stringify(r(u)))break;r(a).push(...r(h)),u=h,l=h.nextCursor,d++}return delete a.nextCursor,n?.(a),s||await this._cache.write(e,a,i,this._freshness(a)),a}_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),Dx),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 M?n:new M(q.RequestTimeout,String(n))}return r.value}}_reportStoreError(e){this.onerror?.(e instanceof Error?e:new Error(String(e)))}_compileOutputValidator(e){if(e.outputSchema)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:rg(o.inputSchema)}async readResource(e,t){let o=await this._serveFromCache("resources/read",e.uri,t);if(o!==void 0)return o;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);s.expiresAt>this._cache.now()?await this._cache.write("resources/read",n,r,s):t?.cacheMode==="refresh"&&await this._cache.evictKey("resources/read",e.uri)}return n}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 M(q.NotConnected,"Not connected");let o=this._negotiatedProtocolVersion;if(o===void 0||!to(o))throw new M(q.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 N=t.signal.reason;throw N instanceof M?N:new M(q.RequestTimeout,String(N))}let r=new AbortController,n=`listen:${this._nextListenId++}`,s="opening",i,a,l,u,d=new Promise((N,D)=>{l=N,u=D}),h,f=new Promise(N=>{h=N}),S=N=>{if(s==="closed")return;let D=s==="opening";if(i!==void 0&&(clearTimeout(i),i=void 0),"ack"in N){s="open",l(N.ack);return}s="closed",a!==void 0&&t?.signal?.removeEventListener("abort",a),this._listenState.delete(n),r.abort(),h(N.cause),D&&u(N.error??new M(q.ConnectionClosed,"subscriptions/listen closed before the server acknowledged"))},y=async()=>{r.abort(),await this.notification({method:"notifications/cancelled",params:{requestId:n}}).catch(()=>{})},w=async()=>{s!=="closed"&&(S({cause:"local"}),await y())};this._listenState.set(n,{settle:S});let z=t?.timeout??Pu;if(i=setTimeout(()=>{S({cause:"remote",error:new M(q.RequestTimeout,"subscriptions/listen ack timed out",{timeout:z})}),y().catch(()=>{})},z),t?.signal){let N=t.signal;a=()=>{if(s==="closed")return;let D=N.reason;S({cause:"local",error:D instanceof Error?D:new Error(String(D??"Aborted"))}),y().catch(()=>{})},N.addEventListener("abort",a,{once:!0})}let H={jsonrpc:"2.0",id:n,method:"subscriptions/listen",params:{_meta:{...this._outboundMetaEnvelope()},notifications:e}},W=N=>{S({cause:"remote",error:N instanceof Error?N:new Error(String(N))})};try{this.transport.send(H,{requestSignal:r.signal,onRequestStreamEnd:()=>S({cause:"remote",error:new Error("subscriptions/listen: stream ended")})}).catch(W)}catch(N){W(N)}return{honoredFilter:await d,close:w,closed:f}}get autoOpenedSubscription(){return this._autoOpenedSubscription}_onnotification(e,t){let o=Object.hasOwn(my,e.method)?my[e.method]:void 0;if(e.method==="notifications/resources/updated"){let r=e.params?.uri;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?.[Xs],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:new 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){Un(e)?o.settle({cause:"remote",error:se.fromError(e.error.code,e.error.message,e.error.data)}):o.settle({cause:"graceful",error:new M(q.ConnectionClosed,"subscriptions/listen: server closed the subscription gracefully before acknowledging")});return}super._onresponse(e)}_onclose(){if(this._listenState.size>0){let e=new M(q.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"&&ly()!=="browser",r=async()=>{if(!o)return t;let l;try{l=await this._resolveXMcpHeaderScan(e.name,t?.toolDefinition)}catch(d){this._reportStoreError(d)}if(!l?.valid||l.declarations.length===0)return t;let u=Nb(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 se(B.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 se&&l.code===jn;if(!o||!u||t?.toolDefinition!==void 0)throw l;let d={signal:t?.signal,timeout:t?.timeout,cacheMode:"refresh"};await this._cache.evict("tools/list"),await this.listTools(void 0,d).catch(h=>this._reportStoreError(h)),n=await this._cache.outputValidator(e.name,h=>this._compileOutputValidator(h)).catch(h=>void this._reportStoreError(h)),s(),i=await this.request({method:"tools/call",params:e},await r())}let a=n!==void 0&&n.ok?n.validator:void 0;if(a){if(i.structuredContent===void 0&&!i.isError)throw new se(B.InvalidRequest,`Tool ${e.name} has an output schema but did not return structured content`);if(i.structuredContent!==void 0&&!i.isError)try{let l=a(i.structuredContent);if(!l.valid)throw new se(B.InvalidParams,`Structured content does not match the tool's output schema: ${l.errorMessage}`)}catch(l){throw l instanceof se?l:new se(B.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);return o!==void 0?o:this._listAllPages("tools/list",e,t,r=>r.tools,r=>this._excludeInvalidXMcpHeaderTools(r))}_excludeInvalidXMcpHeaderTools(e){if(this.getProtocolEra()!=="modern"||!this.transport||uy(this.transport)==="stdio")return;let t=e.tools.filter(o=>{let r=rg(o.inputSchema);return r.valid?!0:(console.warn(`[mcp-sdk] excluding tool '${o.name}' from tools/list: invalid x-mcp-header declaration \u2014 ${r.reason}`),!1)});t.length!==e.tools.length&&(e.tools=t)}_setupListChangedHandler(e,t,o,r){let n=xu(Wi,o);if(!n.success)throw new Error(`Invalid ${e} listChanged options: ${n.error.message}`);if(typeof o.onChanged!="function")throw new TypeError(`Invalid ${e} listChanged options: onChanged must be a function`);let{autoRefresh:s,debounceMs:i}=n.data,{onChanged:a}=o,l=async()=>{if(!s){a(null,null);return}try{a(null,await r())}catch(d){a(d instanceof Error?d:new Error(String(d)),null)}},u=()=>{if(i){let d=this._listChangedDebounceTimers.get(e);d&&clearTimeout(d);let h=setTimeout(l,i);this._listChangedDebounceTimers.set(e,h)}else l()};this.setNotificationHandler(t,u)}async sendRootsListChanged(){return this.notification({method:"notifications/roots/list_changed"})}};function hP(e){return/(?:^|,)\s*dpop(?:\s|$|,)/i.test(e)}function mP(e){if(e.status!==401)return!1;let t=e.headers.get("www-authenticate")??"";return hP(t)&&/use_dpop_nonce/i.test(t)}var fP=(e,t)=>o=>{let r=typeof e=="function"?e:()=>e;return async(n,s)=>{let i=(s?.method??"GET").toUpperCase(),a=new URL(n.toString()),l=await r();if(!l)return o(n,s);let u=async()=>{let h=await t();if(!h)return o(n,s);let f=new Headers(s?.headers),S=await l.buildProof({htm:i,htu:a,accessToken:h});return f.set("Authorization",`DPoP ${h}`),f.set("DPoP",S),o(n,{...s,headers:f})},d=await u();return mP(d)&&d.headers.has("dpop-nonce")&&(l.observeNonce(d,a),await d.text?.().catch(()=>{}),d=await u()),l.observeNonce(d,a),d}},gP=e=>fP(async()=>{try{return await e.dpop?.()}catch(t){throw at(t)}},async()=>{let t;try{t=await e.tokens()}catch(o){throw at(o)}return t?.token_type?.toLowerCase()==="dpop"?t.access_token:void 0});var XE=class extends Error{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.SseError"})}static[Symbol.hasInstance](e){return et(this,e)}static isInstance(e){if(typeof this!="function")throw new TypeError("isInstance must be called on the class (e.g. `SdkError.isInstance(value)`); for callbacks use `v => SdkError.isInstance(v)`");return et(this,e)}constructor(e,t,o){super(`SSE error: ${t}`),this.code=e,this.event=o,lr(this,new.target)}};var SP=1,_P={initialReconnectionDelay:1e3,maxReconnectionDelay:3e4,reconnectionDelayGrowFactor:1.5,maxRetries:2},bP=new Set(["authorization","dpop","content-type","mcp-protocol-version","mcp-method","mcp-name","mcp-session-id"]);function fy(e,t){if(typeof AbortSignal.any=="function")return AbortSignal.any([e,t]);let o=new AbortController;if(e.aborted)return o.abort(e.reason),o.signal;if(t.aborted)return o.abort(t.reason),o.signal;let r=()=>{e.removeEventListener("abort",n),t.removeEventListener("abort",s)};function n(){r(),o.abort(e.reason)}function s(){r(),o.abort(t.reason)}return e.addEventListener("abort",n,{once:!0}),t.addEventListener("abort",s,{once:!0}),o.signal}var $y=class{_abortController;_url;_resourceMetadataUrl;_scope;_requestInit;_authProvider;_oauthProvider;_skipIssuerMetadataValidation;_fetch;_fetchWithInit;_redirectPolicy;_sessionId;_reconnectionOptions;_protocolVersion;_onInsufficientScope;_maxStepUpRetries;_serverRetryMs;_reconnectionScheduler;_cancelReconnection;onclose;onerror;onmessage;hasPerRequestStream=!0;constructor(e,t){this._url=e,this._resourceMetadataUrl=void 0,this._scope=void 0,this._requestInit=t?.requestInit,this._skipIssuerMetadataValidation=t?.skipIssuerMetadataValidation,this._fetch=t?.fetch,mx(t?.authProvider)?(this._oauthProvider=t.authProvider,this._authProvider=gx(t.authProvider,{skipIssuerMetadataValidation:t.skipIssuerMetadataValidation}),t.authProvider.dpop&&(this._fetch=gP(t.authProvider)(t.fetch??fetch))):this._authProvider=t?.authProvider,this._redirectPolicy=t?.redirectPolicy,this._fetchWithInit=Vb(t?.fetch,t?.requestInit),this._redirectPolicy==="follow"&&(this._fetchWithInit=Wb(this._fetchWithInit)),this._sessionId=t?.sessionId,this._protocolVersion=t?.protocolVersion,this._reconnectionOptions=t?.reconnectionOptions??_P,this._reconnectionScheduler=t?.reconnectionScheduler,this._onInsufficientScope=t?.onInsufficientScope??"reauthorize",this._maxStepUpRetries=Math.max(0,t?.maxStepUpRetries??SP)}async _stepUpAuthorize(e,t){try{return await this._stepUpAuthorizeInner(e,t)}catch(o){throw at(o)}}async _stepUpAuthorizeInner(e,t){if(this._onInsufficientScope==="throw")throw new ny({requiredScope:e.scope,resourceMetadataUrl:e.resourceMetadataUrl,errorDescription:e.errorDescription});if(!this._oauthProvider)throw new ny({requiredScope:e.scope,resourceMetadataUrl:e.resourceMetadataUrl,errorDescription:e.errorDescription});if(t>=this._maxStepUpRetries)throw new qt(q.ClientHttpForbidden,`Server returned 403 insufficient_scope after step-up re-authorization (retry limit ${this._maxStepUpRetries} reached)`,{status:403,statusText:e.statusText??"Forbidden",text:e.text});e.resourceMetadataUrl&&(this._resourceMetadataUrl=e.resourceMetadataUrl);let o=await this._oauthProvider.tokens(),r=dg(this._scope,o?.scope,e.scope);this._scope=r;let n=Sx(r,o?.scope);return bg(this._oauthProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:r,forceReauthorization:n,fetchFn:this._fetchWithInit,skipIssuerMetadataValidation:this._skipIssuerMetadataValidation})}_redirects(e){return this._redirectPolicy==="follow"?e:ja(e)}_unfollowedRedirect(e,t){let o=this._redirectPolicy==="follow"?void 0:Kb(e,t);return o&&`${o} (redirectPolicy: 'same-origin')`}async _commonHeaders(){let e=new Headers(this._requestInit?.headers||void 0),t;try{t=await this._authProvider?.token()}catch(o){throw at(o)}return t&&e.set("Authorization",`Bearer ${t}`),this._sessionId&&e.set("mcp-session-id",this._sessionId),this._protocolVersion&&e.set("mcp-protocol-version",this._protocolVersion),e}_applyBodyDerivedHeaders(e,t){if(Array.isArray(t)||!dr(t))return;let o=t.params?._meta?.[Jt];if(typeof o!="string")return;e.set("mcp-protocol-version",o),e.set("mcp-method",t.method);let r=qb(t.method,t.params);r?.value!==void 0&&e.set("mcp-name",ng(r.value))}_isModernEnvelopedRequest(e){if(Array.isArray(e)||!dr(e))return!1;let t=e.params?._meta?.[Jt];return typeof t=="string"&&to(t)}async _startOrAuthSse(e,t=!1,o=0){let{resumptionToken:r,requestSignal:n}=e,s=()=>this._abortController?.signal.aborted===!0||n?.aborted===!0;try{let i=await this._commonHeaders(),a=[...i.get("accept")?.split(",").map(h=>h.trim().toLowerCase())??[],"text/event-stream"];i.set("accept",[...new Set(a)].join(", ")),r&&i.set("last-event-id",r);let l=this._abortController?.signal,u=n!==void 0&&l!==void 0?fy(l,n):n??l,d=await this._redirects(this._fetch??fetch)(this._url,{...this._requestInit,method:"GET",headers:i,signal:u});if(!d.ok){if(d.status===401&&this._authProvider){if(d.headers.has("www-authenticate")){let{resourceMetadataUrl:f,scope:S}=Za(d);this._resourceMetadataUrl=f,this._scope=dg(this._scope,S)}if(this._authProvider.onUnauthorized&&!t){try{await this._authProvider.onUnauthorized({response:d,serverUrl:this._url,fetchFn:this._fetchWithInit})}catch(f){throw at(f)}return await d.text?.().catch(()=>{}),this._startOrAuthSse(e,!0,o)}throw await d.text?.().catch(()=>{}),at(t?new qt(q.ClientHttpAuthentication,"Server returned 401 after re-authentication",{status:401,statusText:d.statusText}):new At)}if(d.status===403){let{resourceMetadataUrl:f,scope:S,error:y,errorDescription:w}=Za(d);if(y==="insufficient_scope"){let z=await d.text?.().catch(()=>null);if(await this._stepUpAuthorize({scope:S,resourceMetadataUrl:f,errorDescription:w,statusText:d.statusText,text:z},o)!=="AUTHORIZED")throw at(new At);return this._startOrAuthSse(e,t,o+1)}}if(await d.text?.().catch(()=>{}),d.status===405){e.onRequestStreamEnd?.();return}let h=this._unfollowedRedirect(this._url,d)??d.statusText;throw new qt(q.ClientHttpFailedToOpenStream,`Failed to open SSE stream: ${h}`,{status:d.status,statusText:d.statusText})}this._handleSseStream(d.body,e,!0)}catch(i){throw s()||this.onerror?.(i),i}}_getNextReconnectionDelay(e){if(this._serverRetryMs!==void 0)return this._serverRetryMs;let t=this._reconnectionOptions.initialReconnectionDelay,o=this._reconnectionOptions.reconnectionDelayGrowFactor,r=this._reconnectionOptions.maxReconnectionDelay;return Math.min(t*Math.pow(o,e),r)}_scheduleReconnection(e,t=0){let o=this._reconnectionOptions.maxRetries;if(t>=o){this.onerror?.(new Error(`Maximum reconnection attempts (${o}) exceeded.`)),e.onRequestStreamEnd?.();return}let r=this._getNextReconnectionDelay(t),n=()=>{this._cancelReconnection=void 0,!(this._abortController?.signal.aborted||e.requestSignal?.aborted)&&this._startOrAuthSse(e).catch(s=>{if(!(this._abortController?.signal.aborted||e.requestSignal?.aborted)){this.onerror?.(new Error(`Failed to reconnect SSE stream: ${s instanceof Error?s.message:String(s)}`));try{this._scheduleReconnection(e,t+1)}catch(i){this.onerror?.(i instanceof Error?i:new Error(String(i)))}}})};if(this._reconnectionScheduler){let s=this._reconnectionScheduler(n,r,t);this._cancelReconnection=typeof s=="function"?s:void 0}else{let s=setTimeout(n,r);this._cancelReconnection=()=>clearTimeout(s)}}_handleSseStream(e,t,o){if(!e){t.onRequestStreamEnd?.();return}let{onresumptiontoken:r,replayMessageId:n,requestSignal:s,onRequestStreamEnd:i}=t,a=()=>this._abortController?.signal.aborted===!0||s?.aborted===!0,l,u=!1,d=!1;(async()=>{try{let f=e.pipeThrough(new TextDecoderStream).pipeThrough(new Eu({onRetry:S=>{this._serverRetryMs=S}})).getReader();for(;;){let{value:S,done:y}=await f.read();if(y)break;if(S.id&&(l=S.id,u=!0,r?.(S.id)),!!S.data&&(!S.event||S.event==="message"))try{let w=mt.parse(JSON.parse(S.data));(Ln(w)||Un(w))&&(d=!0,n!==void 0&&(w.id=n)),this.onmessage?.(w)}catch(w){this.onerror?.(w)}}(o||u)&&!d&&this._abortController&&!a()?this._scheduleReconnection({resumptionToken:l,onresumptiontoken:r,replayMessageId:n,requestSignal:s,onRequestStreamEnd:i},0):a()||i?.()}catch(f){if(a())return;if(this.onerror?.(new Error(`SSE stream disconnected: ${f}`)),(o||u)&&!d&&this._abortController&&!a())try{this._scheduleReconnection({resumptionToken:l,onresumptiontoken:r,replayMessageId:n,requestSignal:s,onRequestStreamEnd:i},0)}catch(S){this.onerror?.(new Error(`Failed to reconnect: ${S instanceof Error?S.message:String(S)}`)),i?.()}else i?.()}})()}async start(){if(this._abortController)throw new Error("StreamableHTTPClientTransport already started! If using Client class, note that connect() calls start() automatically.");this._abortController=new AbortController}async finishAuth(e,t){if(!this._oauthProvider)throw new At("finishAuth requires an OAuthClientProvider");let{authorizationCode:o,iss:r}=await _x(e,t,this._oauthProvider,this._url,{fetchFn:this._fetchWithInit,resourceMetadataUrl:this._resourceMetadataUrl});if(await bg(this._oauthProvider,{serverUrl:this._url,authorizationCode:o,iss:r,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit,skipIssuerMetadataValidation:this._skipIssuerMetadataValidation})!=="AUTHORIZED")throw new At("Failed to authorize")}async close(){try{this._cancelReconnection?.()}finally{this._cancelReconnection=void 0,this._abortController?.abort(),this.onclose?.()}}async send(e,t){return this._send(e,t,!1)}async _send(e,t,o,r=0){try{let{resumptionToken:n,onresumptiontoken:s}=t||{};if(n){this._startOrAuthSse({resumptionToken:n,replayMessageId:dr(e)?e.id:void 0,requestSignal:t?.requestSignal}).catch(z=>this.onerror?.(z));return}let i=await this._commonHeaders();this._applyBodyDerivedHeaders(i,e);let a=Array.isArray(e)?e.some(z=>og(z)):og(e);if(a&&i.delete("mcp-session-id"),t?.headers!==void 0)for(let[z,H]of Object.entries(t.headers))bP.has(z.toLowerCase())||i.set(z,H);i.set("content-type","application/json");let l=[...i.get("accept")?.split(",").map(z=>z.trim().toLowerCase())??[],"application/json","text/event-stream"];i.set("accept",[...new Set(l)].join(", "));let u=this._abortController?.signal,d=t?.requestSignal!==void 0&&u!==void 0?fy(u,t.requestSignal):t?.requestSignal??u,h={...this._requestInit,method:"POST",headers:i,body:JSON.stringify(e),signal:d},f=await this._redirects(this._fetch??fetch)(this._url,h);if(a&&f.ok&&(this._sessionId=f.headers.get("mcp-session-id")||void 0),!f.ok){if(f.status===401&&this._authProvider){if(f.headers.has("www-authenticate")){let{resourceMetadataUrl:W,scope:N}=Za(f);this._resourceMetadataUrl=W,this._scope=dg(this._scope,N)}if(this._authProvider.onUnauthorized&&!o){try{await this._authProvider.onUnauthorized({response:f,serverUrl:this._url,fetchFn:this._fetchWithInit})}catch(W){throw at(W)}return await f.text?.().catch(()=>{}),this._send(e,t,!0,r)}throw await f.text?.().catch(()=>{}),at(o?new qt(q.ClientHttpAuthentication,"Server returned 401 after re-authentication",{status:401,statusText:f.statusText}):new At)}let z=await f.text?.().catch(()=>null);if(f.status===403){let{resourceMetadataUrl:W,scope:N,error:D,errorDescription:x}=Za(f);if(D==="insufficient_scope"){if(await this._stepUpAuthorize({scope:N,resourceMetadataUrl:W,errorDescription:x,statusText:f.statusText,text:z},r)!=="AUTHORIZED")throw at(new At);return this._send(e,t,o,r+1)}}if(f.status===400&&typeof z=="string"&&this._isModernEnvelopedRequest(e))try{let W=mt.parse(JSON.parse(z)),N=(Array.isArray(e)?e:[e]).filter(D=>dr(D));if(Un(W)&&N.some(D=>D.id===W.id)){this.onmessage?.(W);return}}catch{}let H=this._unfollowedRedirect(this._url,f)??z;throw new qt(q.ClientHttpNotImplemented,`Error POSTing to endpoint: ${H}`,{status:f.status,statusText:f.statusText,text:z})}if(f.status===202){await f.text?.().catch(()=>{}),Cb(e)&&this._startOrAuthSse({resumptionToken:void 0}).catch(z=>this.onerror?.(z));return}let S=(Array.isArray(e)?e:[e]).some(z=>"method"in z&&"id"in z&&z.id!==void 0),y=f.headers.get("content-type"),w=Hb(y);if(S)if(w==="text/event-stream")this._handleSseStream(f.body,{onresumptiontoken:s,requestSignal:t?.requestSignal,onRequestStreamEnd:t?.onRequestStreamEnd},!1);else if(w==="application/json"){let z=await f.json(),H=Array.isArray(z)?z.map(W=>mt.parse(W)):[mt.parse(z)];for(let W of H)this.onmessage?.(W)}else throw await f.text?.().catch(()=>{}),new M(q.ClientHttpUnexpectedContent,`Unexpected content type: ${y}`,{contentType:y});else await f.text?.().catch(()=>{})}catch(n){throw t?.requestSignal?.aborted!==!0&&this.onerror?.(n),n}}get sessionId(){return this._sessionId}async terminateSession(){if(this._sessionId)try{let e=await this._commonHeaders(),t={...this._requestInit,method:"DELETE",headers:e,signal:this._abortController?.signal},o=await this._redirects(this._fetch??fetch)(this._url,t);if(await o.text?.().catch(()=>{}),!o.ok&&o.status!==405)throw new qt(q.ClientHttpFailedToTerminateSession,`Failed to terminate session: ${this._unfollowedRedirect(this._url,o)??o.statusText}`,{status:o.status,statusText:o.statusText});this._sessionId=void 0}catch(e){throw this.onerror?.(e),e}}setProtocolVersion(e){this._protocolVersion=e}get protocolVersion(){return this._protocolVersion}async resumeStream(e,t){await this._startOrAuthSse({resumptionToken:e,onresumptiontoken:t?.onresumptiontoken})}};var wg=class{_eventSlots=new Map;setHandler(t,o){let r=this._ensureEventSlot(t);r.onHandler&&o&&console.warn(`[MCP Apps] on${String(t)} handler replaced. Use addEventListener("${String(t)}", \u2026) to add multiple listeners without replacing.`),r.onHandler=o}getHandler(t){return this._eventSlots.get(t)?.onHandler}addEventListener(t,o){this._ensureEventSlot(t).listeners.push(o)}removeEventListener(t,o){let r=this._eventSlots.get(t);if(!r)return;let n=r.listeners.indexOf(o);n!==-1&&r.listeners.splice(n,1)}dispatch(t,o){let r=this._eventSlots.get(t);if(r){r.onHandler?.(o);for(let n of[...r.listeners])n(o)}}_ensureEventSlot(t){let o=this._eventSlots.get(t);return o||(o={listeners:[]},this._eventSlots.set(t,o)),o}},xg=class{_methods=new Set;claim(t,o){if(this._methods.has(t))throw Error(`Handler for "${t}" already registered (via ${o}). Use addEventListener() to attach multiple listeners, or the on* setter for replace semantics.`);this._methods.add(t)}replace(t){this._methods.add(t)}release(t){this._methods.delete(t)}has(t){return this._methods.has(t)}},Cy=new Set;function Iy(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";Cy.has(i)||(Cy.add(i),console.warn(`[ext-apps] ${i}(Schema, handler) is deprecated; use ${i}("${s}", { params: Schema.shape.params }, handler).`));let a=r;return[s,{params:n.params},e==="request"?(l,u)=>a({method:s,params:l},yP(u)):l=>a({method:s,params:l})]}function yP(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 My="2026-01-26";var zP="ui/notifications/tool-input-partial";var vP=p.union([p.literal("light"),p.literal("dark")]).describe("Color theme preference for the host environment."),Fa=p.union([p.literal("inline"),p.literal("fullscreen"),p.literal("pip")]).describe("Display mode for UI presentation."),RP=p.union([p.literal("--color-background-primary"),p.literal("--color-background-secondary"),p.literal("--color-background-tertiary"),p.literal("--color-background-inverse"),p.literal("--color-background-ghost"),p.literal("--color-background-info"),p.literal("--color-background-danger"),p.literal("--color-background-success"),p.literal("--color-background-warning"),p.literal("--color-background-disabled"),p.literal("--color-text-primary"),p.literal("--color-text-secondary"),p.literal("--color-text-tertiary"),p.literal("--color-text-inverse"),p.literal("--color-text-ghost"),p.literal("--color-text-info"),p.literal("--color-text-danger"),p.literal("--color-text-success"),p.literal("--color-text-warning"),p.literal("--color-text-disabled"),p.literal("--color-border-primary"),p.literal("--color-border-secondary"),p.literal("--color-border-tertiary"),p.literal("--color-border-inverse"),p.literal("--color-border-ghost"),p.literal("--color-border-info"),p.literal("--color-border-danger"),p.literal("--color-border-success"),p.literal("--color-border-warning"),p.literal("--color-border-disabled"),p.literal("--color-ring-primary"),p.literal("--color-ring-secondary"),p.literal("--color-ring-inverse"),p.literal("--color-ring-info"),p.literal("--color-ring-danger"),p.literal("--color-ring-success"),p.literal("--color-ring-warning"),p.literal("--font-sans"),p.literal("--font-mono"),p.literal("--font-weight-normal"),p.literal("--font-weight-medium"),p.literal("--font-weight-semibold"),p.literal("--font-weight-bold"),p.literal("--font-text-xs-size"),p.literal("--font-text-sm-size"),p.literal("--font-text-md-size"),p.literal("--font-text-lg-size"),p.literal("--font-heading-xs-size"),p.literal("--font-heading-sm-size"),p.literal("--font-heading-md-size"),p.literal("--font-heading-lg-size"),p.literal("--font-heading-xl-size"),p.literal("--font-heading-2xl-size"),p.literal("--font-heading-3xl-size"),p.literal("--font-text-xs-line-height"),p.literal("--font-text-sm-line-height"),p.literal("--font-text-md-line-height"),p.literal("--font-text-lg-line-height"),p.literal("--font-heading-xs-line-height"),p.literal("--font-heading-sm-line-height"),p.literal("--font-heading-md-line-height"),p.literal("--font-heading-lg-line-height"),p.literal("--font-heading-xl-line-height"),p.literal("--font-heading-2xl-line-height"),p.literal("--font-heading-3xl-line-height"),p.literal("--border-radius-xs"),p.literal("--border-radius-sm"),p.literal("--border-radius-md"),p.literal("--border-radius-lg"),p.literal("--border-radius-xl"),p.literal("--border-radius-full"),p.literal("--border-width-regular"),p.literal("--shadow-hairline"),p.literal("--shadow-sm"),p.literal("--shadow-md"),p.literal("--shadow-lg")]).describe("CSS variable keys available to MCP apps for theming."),wP=p.record(RP.describe(`Style variables for theming MCP apps.
78
78
 
79
79
  Individual style keys are optional - hosts may provide any subset of these values.
80
80
  Values are strings containing CSS values (colors, sizes, font stacks, etc.).
@@ -92,10 +92,10 @@ Individual style keys are optional - hosts may provide any subset of these value
92
92
  Values are strings containing CSS values (colors, sizes, font stacks, etc.).
93
93
 
94
94
  Note: This type uses \`Record<K, string | undefined>\` rather than \`Partial<Record<K, string>>\`
95
- for compatibility with Zod schema generation. Both are functionally equivalent for validation.`),xP=p.object({method:p.literal("ui/open-link"),params:p.object({url:p.string().describe("URL to open in the host's browser")})}),PP=p.object({isError:p.boolean().optional().describe("True if the host failed to open the URL (e.g., due to security policy).")}).passthrough(),TP=p.object({isError:p.boolean().optional().describe("True if the download failed (e.g., user cancelled or host denied).")}).passthrough(),EP=p.object({isError:p.boolean().optional().describe("True if the host rejected or failed to deliver the message.")}).passthrough(),kP=p.object({method:p.literal("ui/notifications/sandbox-proxy-ready"),params:p.object({})}),xg=p.object({connectDomains:p.array(p.string()).optional().describe(`Origins for network requests (fetch/XHR/WebSocket).
95
+ for compatibility with Zod schema generation. Both are functionally equivalent for validation.`),xP=p.object({method:p.literal("ui/open-link"),params:p.object({url:p.string().describe("URL to open in the host's browser")})}),PP=p.object({isError:p.boolean().optional().describe("True if the host failed to open the URL (e.g., due to security policy).")}).passthrough(),TP=p.object({isError:p.boolean().optional().describe("True if the download failed (e.g., user cancelled or host denied).")}).passthrough(),EP=p.object({isError:p.boolean().optional().describe("True if the host rejected or failed to deliver the message.")}).passthrough(),kP=p.object({method:p.literal("ui/notifications/sandbox-proxy-ready"),params:p.object({})}),Pg=p.object({connectDomains:p.array(p.string()).optional().describe(`Origins for network requests (fetch/XHR/WebSocket).
96
96
 
97
97
  - Maps to CSP \`connect-src\` directive
98
- - Empty or omitted \u2192 no network connections (secure default)`),resourceDomains:p.array(p.string()).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 \u2192 no network resources (secure default)"),frameDomains:p.array(p.string()).optional().describe("Origins for nested iframes.\n\n- Maps to CSP `frame-src` directive\n- Empty or omitted \u2192 no nested iframes allowed (`frame-src 'none'`)"),baseUriDomains:p.array(p.string()).optional().describe("Allowed base URIs for the document.\n\n- Maps to CSP `base-uri` directive\n- Empty or omitted \u2192 only same origin allowed (`base-uri 'self'`)")}),Pg=p.object({camera:p.object({}).optional().describe("Request camera access.\n\nMaps to Permission Policy `camera` feature."),microphone:p.object({}).optional().describe("Request microphone access.\n\nMaps to Permission Policy `microphone` feature."),geolocation:p.object({}).optional().describe("Request geolocation access.\n\nMaps to Permission Policy `geolocation` feature."),clipboardWrite:p.object({}).optional().describe("Request clipboard write access.\n\nMaps to Permission Policy `clipboard-write` feature.")}),$P=p.object({method:p.literal("ui/notifications/size-changed"),params:p.object({width:p.number().optional().describe("New width in pixels."),height:p.number().optional().describe("New height in pixels.")})}),_k=p.object({method:p.literal("ui/notifications/tool-input"),params:p.object({arguments:p.record(p.string(),p.unknown().describe("Complete tool call arguments as key-value pairs.")).optional().describe("Complete tool call arguments as key-value pairs.")})}),bk=p.object({method:p.literal("ui/notifications/tool-input-partial"),params:p.object({arguments:p.record(p.string(),p.unknown().describe("Partial tool call arguments (incomplete, may change).")).optional().describe("Partial tool call arguments (incomplete, may change).")})}),yk=p.object({method:p.literal("ui/notifications/tool-cancelled"),params:p.object({reason:p.string().optional().describe('Optional reason for the cancellation (e.g., "user action", "timeout").')})}),CP=p.object({fonts:p.string().optional()}),IP=p.object({variables:wP.optional().describe("CSS variables for theming the app."),css:CP.optional().describe("CSS blocks that apps can inject.")}),zk=p.object({method:p.literal("ui/resource-teardown"),params:p.object({})}),OP=p.record(p.string(),p.unknown()),Iy=p.object({text:p.object({}).optional().describe("Host supports text content blocks."),image:p.object({}).optional().describe("Host supports image content blocks."),audio:p.object({}).optional().describe("Host supports audio content blocks."),resource:p.object({}).optional().describe("Host supports resource content blocks."),resourceLink:p.object({}).optional().describe("Host supports resource link content blocks."),structuredContent:p.object({}).optional().describe("Host supports structured content.")}),NP=p.object({method:p.literal("ui/notifications/request-teardown"),params:p.object({}).optional()}),qP=p.object({experimental:p.record(p.string(),p.record(p.string(),p.any()).describe("Experimental features keyed by identifier.")).optional().describe("Experimental features keyed by identifier."),openLinks:p.object({}).optional().describe("Host supports opening external URLs."),downloadFile:p.object({}).optional().describe("Host supports file downloads via ui/download-file."),serverTools:p.object({listChanged:p.boolean().optional().describe("Host supports tools/list_changed notifications.")}).optional().describe("Host can proxy tool calls to the MCP server."),serverResources:p.object({listChanged:p.boolean().optional().describe("Host supports resources/list_changed notifications.")}).optional().describe("Host can proxy resource reads to the MCP server."),logging:p.object({}).optional().describe("Host accepts log messages."),sandbox:p.object({permissions:Pg.optional().describe("Permissions granted by the host (camera, microphone, geolocation)."),csp:xg.optional().describe("CSP domains approved by the host.")}).optional().describe("Sandbox configuration applied by the host."),updateModelContext:Iy.optional().describe("Host accepts context updates (ui/update-model-context) to be included in the model's context for future turns."),message:Iy.optional().describe("Host supports receiving content messages (ui/message) from the view."),sampling:p.object({tools:p.object({}).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.")}),MP=p.object({experimental:p.record(p.string(),p.record(p.string(),p.any()).describe("Experimental features keyed by identifier.")).optional().describe("Experimental features keyed by identifier."),tools:p.object({listChanged:p.boolean().optional().describe("App supports tools/list_changed notifications.")}).optional().describe("App exposes MCP-style tools that the host can call."),availableDisplayModes:p.array(Fa).optional().describe("Display modes the app supports.")}),AP=p.object({method:p.literal("ui/notifications/initialized"),params:p.object({}).optional()}),vk=p.object({csp:xg.optional().describe("Content Security Policy configuration for UI resources."),permissions:Pg.optional().describe("Sandbox permissions requested by the UI resource."),domain:p.string().optional().describe(`Dedicated origin for view sandbox.
98
+ - Empty or omitted \u2192 no network connections (secure default)`),resourceDomains:p.array(p.string()).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 \u2192 no network resources (secure default)"),frameDomains:p.array(p.string()).optional().describe("Origins for nested iframes.\n\n- Maps to CSP `frame-src` directive\n- Empty or omitted \u2192 no nested iframes allowed (`frame-src 'none'`)"),baseUriDomains:p.array(p.string()).optional().describe("Allowed base URIs for the document.\n\n- Maps to CSP `base-uri` directive\n- Empty or omitted \u2192 only same origin allowed (`base-uri 'self'`)")}),Tg=p.object({camera:p.object({}).optional().describe("Request camera access.\n\nMaps to Permission Policy `camera` feature."),microphone:p.object({}).optional().describe("Request microphone access.\n\nMaps to Permission Policy `microphone` feature."),geolocation:p.object({}).optional().describe("Request geolocation access.\n\nMaps to Permission Policy `geolocation` feature."),clipboardWrite:p.object({}).optional().describe("Request clipboard write access.\n\nMaps to Permission Policy `clipboard-write` feature.")}),$P=p.object({method:p.literal("ui/notifications/size-changed"),params:p.object({width:p.number().optional().describe("New width in pixels."),height:p.number().optional().describe("New height in pixels.")})}),_k=p.object({method:p.literal("ui/notifications/tool-input"),params:p.object({arguments:p.record(p.string(),p.unknown().describe("Complete tool call arguments as key-value pairs.")).optional().describe("Complete tool call arguments as key-value pairs.")})}),bk=p.object({method:p.literal("ui/notifications/tool-input-partial"),params:p.object({arguments:p.record(p.string(),p.unknown().describe("Partial tool call arguments (incomplete, may change).")).optional().describe("Partial tool call arguments (incomplete, may change).")})}),yk=p.object({method:p.literal("ui/notifications/tool-cancelled"),params:p.object({reason:p.string().optional().describe('Optional reason for the cancellation (e.g., "user action", "timeout").')})}),CP=p.object({fonts:p.string().optional()}),IP=p.object({variables:wP.optional().describe("CSS variables for theming the app."),css:CP.optional().describe("CSS blocks that apps can inject.")}),zk=p.object({method:p.literal("ui/resource-teardown"),params:p.object({})}),OP=p.record(p.string(),p.unknown()),Oy=p.object({text:p.object({}).optional().describe("Host supports text content blocks."),image:p.object({}).optional().describe("Host supports image content blocks."),audio:p.object({}).optional().describe("Host supports audio content blocks."),resource:p.object({}).optional().describe("Host supports resource content blocks."),resourceLink:p.object({}).optional().describe("Host supports resource link content blocks."),structuredContent:p.object({}).optional().describe("Host supports structured content.")}),NP=p.object({method:p.literal("ui/notifications/request-teardown"),params:p.object({}).optional()}),qP=p.object({experimental:p.record(p.string(),p.record(p.string(),p.any()).describe("Experimental features keyed by identifier.")).optional().describe("Experimental features keyed by identifier."),openLinks:p.object({}).optional().describe("Host supports opening external URLs."),downloadFile:p.object({}).optional().describe("Host supports file downloads via ui/download-file."),serverTools:p.object({listChanged:p.boolean().optional().describe("Host supports tools/list_changed notifications.")}).optional().describe("Host can proxy tool calls to the MCP server."),serverResources:p.object({listChanged:p.boolean().optional().describe("Host supports resources/list_changed notifications.")}).optional().describe("Host can proxy resource reads to the MCP server."),logging:p.object({}).optional().describe("Host accepts log messages."),sandbox:p.object({permissions:Tg.optional().describe("Permissions granted by the host (camera, microphone, geolocation)."),csp:Pg.optional().describe("CSP domains approved by the host.")}).optional().describe("Sandbox configuration applied by the host."),updateModelContext:Oy.optional().describe("Host accepts context updates (ui/update-model-context) to be included in the model's context for future turns."),message:Oy.optional().describe("Host supports receiving content messages (ui/message) from the view."),sampling:p.object({tools:p.object({}).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.")}),MP=p.object({experimental:p.record(p.string(),p.record(p.string(),p.any()).describe("Experimental features keyed by identifier.")).optional().describe("Experimental features keyed by identifier."),tools:p.object({listChanged:p.boolean().optional().describe("App supports tools/list_changed notifications.")}).optional().describe("App exposes MCP-style tools that the host can call."),availableDisplayModes:p.array(Fa).optional().describe("Display modes the app supports.")}),AP=p.object({method:p.literal("ui/notifications/initialized"),params:p.object({}).optional()}),vk=p.object({csp:Pg.optional().describe("Content Security Policy configuration for UI resources."),permissions:Tg.optional().describe("Sandbox permissions requested by the UI resource."),domain:p.string().optional().describe(`Dedicated origin for view sandbox.
99
99
 
100
100
  Useful when views need stable, dedicated origins for OAuth callbacks, CORS policies, or API key allowlists.
101
101
 
@@ -109,13 +109,13 @@ Boolean requesting whether a visible border and background is provided by the ho
109
109
 
110
110
  - \`true\`: request visible border + background
111
111
  - \`false\`: request no visible border + background
112
- - omitted: host decides border`)}),Oy=p.object({method:p.literal("ui/request-display-mode"),params:p.object({mode:Fa.describe("The display mode being requested.")})}),Ny=p.object({mode:Fa.describe("The display mode that was actually set. May differ from requested if not supported.")}).passthrough(),jP=p.union([p.literal("model"),p.literal("app")]).describe("Tool visibility scope - who can access the tool."),Rk=p.object({resourceUri:p.string().optional(),visibility:p.array(jP).optional().describe(`Who can access this tool. Default: ["model", "app"]
112
+ - omitted: host decides border`)}),Ny=p.object({method:p.literal("ui/request-display-mode"),params:p.object({mode:Fa.describe("The display mode being requested.")})}),qy=p.object({mode:Fa.describe("The display mode that was actually set. May differ from requested if not supported.")}).passthrough(),jP=p.union([p.literal("model"),p.literal("app")]).describe("Tool visibility scope - who can access the tool."),Rk=p.object({resourceUri:p.string().optional(),visibility:p.array(jP).optional().describe(`Who can access this tool. Default: ["model", "app"]
113
113
  - "model": Tool visible to and callable by the agent
114
- - "app": Tool callable by the app from this server only`),csp:p.never().optional(),permissions:p.never().optional()}),wk=p.object({mimeTypes:p.array(p.string()).optional().describe('Array of supported MIME types for UI resources.\nMust include `"text/html;profile=mcp-app"` for MCP Apps support.')}),LP=p.object({method:p.literal("ui/download-file"),params:p.object({contents:p.array(p.union([or,rr])).describe("Resource contents to download \u2014 embedded (inline data) or linked (host fetches). Uses standard MCP resource types.")})}),UP=p.object({method:p.literal("ui/message"),params:p.object({role:p.literal("user").describe('Message role, currently only "user" is supported.'),content:p.array(Nt).describe("Message content blocks (text, image, etc.).")})}),xk=p.object({method:p.literal("ui/notifications/sandbox-resource-ready"),params:p.object({html:p.string().describe("HTML content to load into the inner iframe."),sandbox:p.string().optional().describe("Optional override for the inner iframe's sandbox attribute."),csp:xg.optional().describe("CSP configuration from resource metadata."),permissions:Pg.optional().describe("Sandbox permissions from resource metadata.")})}),Pk=p.object({method:p.literal("ui/notifications/tool-result"),params:Po.describe("Standard MCP tool execution result.")}),My=p.object({toolInfo:p.object({id:ht.optional().describe("JSON-RPC id of the tools/call request."),tool:xo.describe("Tool definition including name, inputSchema, etc.")}).optional().describe("Metadata of the tool call that instantiated this App."),theme:vP.optional().describe("Current color theme preference."),styles:IP.optional().describe("Style configuration for theming the app."),displayMode:Fa.optional().describe("How the UI is currently displayed."),availableDisplayModes:p.array(Fa).optional().describe("Display modes the host supports."),containerDimensions:p.union([p.object({height:p.number().describe("Fixed container height in pixels.")}),p.object({maxHeight:p.union([p.number(),p.undefined()]).optional().describe("Maximum container height in pixels.")})]).and(p.union([p.object({width:p.number().describe("Fixed container width in pixels.")}),p.object({maxWidth:p.union([p.number(),p.undefined()]).optional().describe("Maximum container width in pixels.")})])).optional().describe(`Container dimensions. Represents the dimensions of the iframe or other
115
- container holding the app. Specify either width or maxWidth, and either height or maxHeight.`),locale:p.string().optional().describe("User's language and region preference in BCP 47 format."),timeZone:p.string().optional().describe("User's timezone in IANA format."),userAgent:p.string().optional().describe("Host application identifier."),platform:p.union([p.literal("web"),p.literal("desktop"),p.literal("mobile")]).optional().describe("Platform type for responsive design decisions."),deviceCapabilities:p.object({touch:p.boolean().optional().describe("Whether the device supports touch input."),hover:p.boolean().optional().describe("Whether the device supports hover interactions.")}).optional().describe("Device input capabilities."),safeAreaInsets:p.object({top:p.number().describe("Top safe area inset in pixels."),right:p.number().describe("Right safe area inset in pixels."),bottom:p.number().describe("Bottom safe area inset in pixels."),left:p.number().describe("Left safe area inset in pixels.")}).optional().describe("Mobile safe area boundaries in pixels.")}).passthrough(),Tk=p.object({method:p.literal("ui/notifications/host-context-changed"),params:My.describe("Partial context update containing only changed fields.")}),ZP=p.object({method:p.literal("ui/update-model-context"),params:p.object({content:p.array(Nt).optional().describe("Context content blocks (text, image, etc.)."),structuredContent:p.record(p.string(),p.unknown().describe("Structured content for machine-readable context data.")).optional().describe("Structured content for machine-readable context data.")})}),DP=p.object({method:p.literal("ui/initialize"),params:p.object({appInfo:It.describe("App identification (name and version)."),appCapabilities:MP.describe("Features and capabilities this app provides."),protocolVersion:p.string().describe("Protocol version this app supports.")})}),FP=p.object({protocolVersion:p.string().describe('Negotiated protocol version string (e.g., "2025-11-21").'),hostInfo:It.describe("Host application identification and version."),hostCapabilities:qP.describe("Features and capabilities provided by the host."),hostContext:My.describe("Rich context about the host environment.")}).passthrough();var Iu=class{eventTarget;eventSource;messageListener;constructor(t=window.parent,o){this.eventTarget=t,this.eventSource=o,this.messageListener=r=>{if(o&&r.source!==this.eventSource){console.debug("Ignoring message from unknown source",r);return}let n=mt.safeParse(r.data);n.success?(console.debug("Parsed message",n.data),this.onmessage?.(n.data)):r.data?.jsonrpc!=="2.0"?console.debug("Ignoring non-JSON-RPC message",n.error.message,r):(console.error("Failed to parse message",n.error.message,r),this.onerror?.(Error("Invalid JSON-RPC message received: "+n.error.message)))}}async start(){window.addEventListener("message",this.messageListener)}async send(t,o){t.method!==zP&&console.debug("Sending message",t),this.eventTarget.postMessage(t,"*")}async close(){window.removeEventListener("message",this.messageListener),this.onclose?.()}onclose;onerror;onmessage;sessionId;setProtocolVersion};var HP=[qy],Ou=class extends Pu{_client;_hostInfo;_hostCapabilities;_appCapabilities;_hostContext={};_appInfo;_initializedReceived=!1;_registeredEvents=new Set;_events=new Rg;_methods=new wg;setRequestHandler=(...t)=>{let[o,...r]=Cy("request",t)??t;this._methods.claim(o,"setRequestHandler"),super.setRequestHandler.call(this,o,...r)};setNotificationHandler=(...t)=>{let[o,...r]=Cy("notification",t)??t;this._methods.claim(o,"setNotificationHandler"),super.setNotificationHandler.call(this,o,...r)};removeRequestHandler=t=>{this._methods.release(t),super.removeRequestHandler(t)};removeNotificationHandler=t=>{this._methods.release(t),super.removeNotificationHandler(t)};replaceRequestHandler=(t,...o)=>{this._methods.replace(t),super.setRequestHandler.call(this,t,...o)};_wrapHandler(t,o){let r=super._wrapHandler(t,o);return t==="ui/initialize"||t==="ping"?r:async(n,s)=>(this._initializedReceived||console.warn(`[ext-apps] AppBridge received '${t}' before ui/notifications/initialized. The View is calling host methods before completing the handshake; it should await app.connect() first.`),r(n,s))}eventSchemas={sizechange:$P,sandboxready:kP,initialized:AP,requestteardown:NP,loggingmessage:nr};setEventHandler(t,o){this._ensureEventSlot(t),this._events.setHandler(t,o)}getEventHandler(t){return this._events.getHandler(t)}addEventListener(t,o){this._ensureEventSlot(t),this._events.addEventListener(t,o)}removeEventListener(t,o){this._events.removeEventListener(t,o)}_ensureEventSlot(t){if(this._registeredEvents.has(t))return;let o=this.eventSchemas[t];if(!o)throw Error(`Unknown event: ${String(t)}`);let r=n=>{t==="initialized"&&(this._initializedReceived=!0),this._events.dispatch(t,n)};t==="loggingmessage"?this.setNotificationHandler("notifications/message",n=>{r(n.params)}):this.setNotificationHandler(o.shape.method.value,{params:o.shape.params},n=>r(n)),this._registeredEvents.add(t)}warnIfRequestHandlerReplaced(t,o,r){o&&r&&console.warn(`[MCP Apps] ${t} handler replaced. Previous handler will no longer be called.`)}constructor(t,o,r,n){super(n),this._client=t,this._hostInfo=o,this._hostCapabilities=r,this._methods.replace("notifications/cancelled"),this._methods.replace("notifications/progress"),this._ensureEventSlot("initialized"),this._hostContext=n?.hostContext||{},this.replaceRequestHandler("ui/initialize",{params:DP.shape.params,result:FP},s=>this._onAppsInitialize(s)),this.replaceRequestHandler("ping",(s,i)=>(this.onping?.(s.params,i),{})),this.replaceRequestHandler("ui/request-display-mode",{params:Oy.shape.params,result:Ny},()=>({mode:this._hostContext.displayMode??"inline"}))}buildContext(t){return t}assertCapabilityForMethod(t){}assertRequestHandlerCapability(t){}assertNotificationCapability(t){}getAppCapabilities(){return this._appCapabilities}getAppVersion(){return this._appInfo}onping;get onsizechange(){return this.getEventHandler("sizechange")}set onsizechange(t){this.setEventHandler("sizechange",t)}get onsandboxready(){return this.getEventHandler("sandboxready")}set onsandboxready(t){this.setEventHandler("sandboxready",t)}get oninitialized(){return this.getEventHandler("initialized")}set oninitialized(t){this.setEventHandler("initialized",t)}_onmessage;get onmessage(){return this._onmessage}set onmessage(t){this.warnIfRequestHandlerReplaced("onmessage",this._onmessage,t),this._onmessage=t,this.replaceRequestHandler("ui/message",{params:UP.shape.params,result:EP},async(o,r)=>{if(!this._onmessage)throw Error("No onmessage handler set");return this._onmessage(o,r)})}_onopenlink;get onopenlink(){return this._onopenlink}set onopenlink(t){this.warnIfRequestHandlerReplaced("onopenlink",this._onopenlink,t),this._onopenlink=t,this.replaceRequestHandler("ui/open-link",{params:xP.shape.params,result:PP},async(o,r)=>{if(!this._onopenlink)throw Error("No onopenlink handler set");return this._onopenlink(o,r)})}_ondownloadfile;get ondownloadfile(){return this._ondownloadfile}set ondownloadfile(t){this.warnIfRequestHandlerReplaced("ondownloadfile",this._ondownloadfile,t),this._ondownloadfile=t,this.replaceRequestHandler("ui/download-file",{params:LP.shape.params,result:TP},async(o,r)=>{if(!this._ondownloadfile)throw Error("No ondownloadfile handler set");return this._ondownloadfile(o,r)})}get onrequestteardown(){return this.getEventHandler("requestteardown")}set onrequestteardown(t){this.setEventHandler("requestteardown",t)}_onrequestdisplaymode;get onrequestdisplaymode(){return this._onrequestdisplaymode}set onrequestdisplaymode(t){this.warnIfRequestHandlerReplaced("onrequestdisplaymode",this._onrequestdisplaymode,t),this._onrequestdisplaymode=t,this.replaceRequestHandler("ui/request-display-mode",{params:Oy.shape.params,result:Ny},async(o,r)=>{if(!this._onrequestdisplaymode)throw Error("No onrequestdisplaymode handler set");return this._onrequestdisplaymode(o,r)})}get onloggingmessage(){return this.getEventHandler("loggingmessage")}set onloggingmessage(t){this.setEventHandler("loggingmessage",t)}_onupdatemodelcontext;get onupdatemodelcontext(){return this._onupdatemodelcontext}set onupdatemodelcontext(t){this.warnIfRequestHandlerReplaced("onupdatemodelcontext",this._onupdatemodelcontext,t),this._onupdatemodelcontext=t,this.replaceRequestHandler("ui/update-model-context",{params:ZP.shape.params,result:Ro},async(o,r)=>{if(!this._onupdatemodelcontext)throw Error("No onupdatemodelcontext handler set");return this._onupdatemodelcontext(o,r)})}_oncalltool;get oncalltool(){return this._oncalltool}set oncalltool(t){this.warnIfRequestHandlerReplaced("oncalltool",this._oncalltool,t),this._oncalltool=t,this.replaceRequestHandler("tools/call",async(o,r)=>{if(!this._oncalltool)throw Error("No oncalltool handler set");return this._oncalltool(o.params,r)})}_oncreatesamplingmessage;get oncreatesamplingmessage(){return this._oncreatesamplingmessage}set oncreatesamplingmessage(t){this.warnIfRequestHandlerReplaced("oncreatesamplingmessage",this._oncreatesamplingmessage,t),this._oncreatesamplingmessage=t,this.replaceRequestHandler("sampling/createMessage",async(o,r)=>{if(!this._oncreatesamplingmessage)throw Error("No oncreatesamplingmessage handler set");return this._oncreatesamplingmessage(o.params,r)})}sendToolListChanged(t={}){return this.notification({method:"notifications/tools/list_changed",params:t})}_onlistresources;get onlistresources(){return this._onlistresources}set onlistresources(t){this.warnIfRequestHandlerReplaced("onlistresources",this._onlistresources,t),this._onlistresources=t,this.replaceRequestHandler("resources/list",async(o,r)=>{if(!this._onlistresources)throw Error("No onlistresources handler set");return this._onlistresources(o.params,r)})}_onlistresourcetemplates;get onlistresourcetemplates(){return this._onlistresourcetemplates}set onlistresourcetemplates(t){this.warnIfRequestHandlerReplaced("onlistresourcetemplates",this._onlistresourcetemplates,t),this._onlistresourcetemplates=t,this.replaceRequestHandler("resources/templates/list",async(o,r)=>{if(!this._onlistresourcetemplates)throw Error("No onlistresourcetemplates handler set");return this._onlistresourcetemplates(o.params,r)})}_onreadresource;get onreadresource(){return this._onreadresource}set onreadresource(t){this.warnIfRequestHandlerReplaced("onreadresource",this._onreadresource,t),this._onreadresource=t,this.replaceRequestHandler("resources/read",async(o,r)=>{if(!this._onreadresource)throw Error("No onreadresource handler set");return this._onreadresource(o.params,r)})}sendResourceListChanged(t={}){return this.notification({method:"notifications/resources/list_changed",params:t})}_onlistprompts;get onlistprompts(){return this._onlistprompts}set onlistprompts(t){this.warnIfRequestHandlerReplaced("onlistprompts",this._onlistprompts,t),this._onlistprompts=t,this.replaceRequestHandler("prompts/list",async(o,r)=>{if(!this._onlistprompts)throw Error("No onlistprompts handler set");return this._onlistprompts(o.params,r)})}sendPromptListChanged(t={}){return this.notification({method:"notifications/prompts/list_changed",params:t})}getCapabilities(){return this._hostCapabilities}async _onAppsInitialize(t){let o=t.protocolVersion;return this._appInfo!==void 0&&console.warn("[ext-apps] AppBridge received a second ui/initialize. The View may be double-mounting (e.g. React StrictMode in dev) without closing the previous App instance. Responding normally; the latest appInfo/appCapabilities replace the previous values."),this._appCapabilities=t.appCapabilities,this._appInfo=t.appInfo,{protocolVersion:HP.includes(o)?o:qy,hostCapabilities:this.getCapabilities(),hostInfo:this._hostInfo,hostContext:this._hostContext}}setHostContext(t){let o={},r=!1;for(let n of Object.keys(t)){let s=this._hostContext[n],i=t[n];VP(s,i)||(o[n]=i,r=!0)}r&&(this._hostContext=t,this.sendHostContextChange(o))}sendHostContextChange(t){return this.notification({method:"ui/notifications/host-context-changed",params:t})}sendToolInput(t){return this.notification({method:"ui/notifications/tool-input",params:t})}sendToolInputPartial(t){return this.notification({method:"ui/notifications/tool-input-partial",params:t})}sendToolResult(t){return this.notification({method:"ui/notifications/tool-result",params:t})}sendToolCancelled(t){return this.notification({method:"ui/notifications/tool-cancelled",params:t})}sendSandboxResourceReady(t){return this.notification({method:"ui/notifications/sandbox-resource-ready",params:t})}teardownResource(t,o){return this.request({method:"ui/resource-teardown",params:t},OP,o)}sendResourceTeardown=this.teardownResource;callTool(t,o){return this.request({method:"tools/call",params:t},o)}listTools(t,o){return this.request({method:"tools/list",params:t},o)}async connect(t){if(this.transport)throw Error("AppBridge is already connected. Call close() before connecting again.");if(this._initializedReceived=!1,this._client){let o=this._client.getServerCapabilities();if(!o)throw Error("Client server capabilities not available");o.tools&&(this.oncalltool=async(r,n)=>this._client.request({method:"tools/call",params:r},{signal:n.mcpReq.signal}),o.tools.listChanged&&this._client.setNotificationHandler("notifications/tools/list_changed",r=>this.sendToolListChanged(r.params))),o.resources&&(this.onlistresources=async(r,n)=>this._client.request({method:"resources/list",params:r},{signal:n.mcpReq.signal}),this.onlistresourcetemplates=async(r,n)=>this._client.request({method:"resources/templates/list",params:r},{signal:n.mcpReq.signal}),this.onreadresource=async(r,n)=>this._client.request({method:"resources/read",params:r},{signal:n.mcpReq.signal}),o.resources.listChanged&&this._client.setNotificationHandler("notifications/resources/list_changed",r=>this.sendResourceListChanged(r.params))),o.prompts&&(this.onlistprompts=async(r,n)=>this._client.request({method:"prompts/list",params:r},{signal:n.mcpReq.signal}),o.prompts.listChanged&&this._client.setNotificationHandler("notifications/prompts/list_changed",r=>this.sendPromptListChanged(r.params)))}return super.connect(t)}};function VP(e,t){return JSON.stringify(e)===JSON.stringify(t)}var re=e=>document.getElementById(e),Ay=new URLSearchParams(location.search),JP=Ay.get("scenario")??Ay.get("category"),BP=["tokens","components","patterns","composition"],we="tokens",oo={},Tg=!0,Ig=[],Og=[],qg=[],Eg,St,gt,Un,Zn=0,Dn="light",kg,$g=!1,Mu,Ng,Au=!1,Ha=!1,Fn,mr,Cg=0,Nu,tt=new Ey({name:"ads-showcase",version:"1.0.0"},{versionNegotiation:{mode:"auto"},capabilities:{extensions:{"io.modelcontextprotocol/ui":{mimeTypes:["text/html;profile=mcp-app"]}}}}),qu=(e,t={})=>tt.callTool({name:e,arguments:t}),WP=async e=>JSON.parse((await tt.readResource({uri:e})).contents.find(t=>typeof t.text=="string").text);function ro(e,t=!1){re("loader").hidden=!0,re("preview").removeAttribute("aria-busy"),re("status").hidden=!e,re("status").textContent=e,re("status").dataset.error=String(t),re("status").setAttribute("role",t?"alert":"status")}function Ly(){re("status").hidden=!0,re("loader").hidden=!1,re("preview").setAttribute("aria-busy","true")}function jy(e){let t=new URL(location.href);return t.searchParams.delete("scenario"),t.searchParams.delete("category"),e&&t.searchParams.set("scenario",e),t.pathname+t.search+t.hash}function KP(){return we==="tokens"?Ig:Og.filter(e=>e.kind===we)}function Mg(){return{theme:Dn,displayMode:"inline",containerDimensions:{width:re("frame-slot").clientWidth,height:re("frame-slot").clientHeight}}}function Ag(){let e=KP();e.some(o=>o.id===oo[we])||(oo[we]=e[0]?.id??null),history.replaceState(null,"",jy(oo[we]));let t=re("sidebar").scrollTop;re("entries").setAttribute("aria-label",we[0].toUpperCase()+we.slice(1)),re("entries").replaceChildren(...e.map(o=>{let r=document.createElement("a");return r.textContent=o.title,r.href=jy(o.id),o.id===oo[we]&&r.setAttribute("aria-current","page"),r.addEventListener("click",n=>{n.button||n.metaKey||n.ctrlKey||n.shiftKey||n.altKey||(n.preventDefault(),oo[we]=o.id,Ag(),Vn().catch(fr))}),r})),re("sidebar").scrollTop=t;for(let o of re("sections").querySelectorAll("button"))o.dataset.section===we?o.setAttribute("aria-current","page"):o.removeAttribute("aria-current")}function fr(e){!Au&&!Ha&&ro(`${e.message}${St?`
116
- The retained preview is not verified against the current source.`:""}`,!0)}async function Hn(e){if(e){try{await e.teardownResource({},{timeout:500})}catch{}await e.close()}}function Uy(){if(Au||Ha)return;Ha=!0,++Zn,clearTimeout(Mu),ro("MCP disconnected. The retained preview is stale. Refresh the page after restarting ADS.",!0);let e=gt;gt=void 0,Hn(e)}async function Zy(){Eg=(await qu("ads_status")).structuredContent,re("title").textContent=Eg.project.showcase.title,re("title").title=Eg.projectRoot;let e=[],t;do{let i=await tt.listTools(t?{cursor:t}:{});e.push(...i.tools),t=i.nextCursor}while(t);qg=e,Ig=(await qu("ads_tokens",{limit:1})).structuredContent.categories;let o=[],r=0;do{let i=(await qu("ads_scenarios",{limit:50,offset:r})).structuredContent;o.push(...i.scenarios),r=i.nextOffset}while(r!==void 0);Og=o;let n=Tg?JP:oo[we],s=Og.find(i=>i.id===n);s&&BP.includes(s.kind)?(we=s.kind,oo[we]=s.id):Tg&&Ig.some(i=>i.id===n)&&(oo.tokens=n),Tg=!1,Ag()}function Vn({force:e=!1}={}){if(Ha)return Promise.resolve();let t=oo[we],o=`${we}:${t}`;if(Un?.key===o)return Un.promise;if(!e&&!Un&&St?.key===o)return Promise.resolve();let r={key:o};return Un=r,r.promise=GP(t,o,we==="tokens").finally(()=>{Un===r&&(Un=void 0)}),r.promise}async function GP(e,t,o){let r=++Zn;try{if(!e&&!o){if(await Hn(gt),r!==Zn)return;gt=void 0,St=void 0,Fn=void 0,mr=void 0,re("frame-slot").replaceChildren(),ro("No scenarios discovered. Colocate an independently mountable scenario and fixture with the public implementation.");return}let n=qg.find(l=>l.name===(o?"ads_show_tokens":"ads_show_scenario"));if(!n?._meta?.ui?.resourceUri)throw new Error("The server did not expose a preview App tool.");let s=o?e?{category:e}:{}:{id:e};Ly();let i=await qu(n.name,s);if(r!==Zn)return;if(i.isError)throw new Error(i.content?.find(l=>l.type==="text")?.text??"Preview build failed.");St={key:t,id:e,token:o&&!i.structuredContent?.scenario,build:i.structuredContent?.build,manifestRevision:i.structuredContent?.manifestRevision};let a=await YP(n._meta.ui.resourceUri);if(r!==Zn)return;if(Fn==="ui://ads/preview"&&!St.manifestRevision)throw new Error("The resource preview has no manifest revision.");await a.sendToolInput({arguments:s}),await a.sendToolResult(i),i.structuredContent?.manifestUri||ro("")}catch(n){r===Zn&&fr(n)}}async function YP(e){if(Fn===e&&mr)return mr;let t=++Cg,o=gt;gt=void 0,Fn=e,mr=(async()=>{await Hn(o);let r=await tt.readResource({uri:e});if(t!==Cg||Au||Ha)throw new Error("Preview opening was superseded.");let n=r.contents.find(u=>u.mimeType==="text/html;profile=mcp-app"&&typeof u.text=="string");if(!n)throw new Error("The preview resource contains no MCP App.");let s=document.createElement("iframe");s.title="Design-system preview",s.setAttribute("sandbox","allow-scripts allow-same-origin"),s.src=Nu,re("frame-slot").replaceChildren(s);let i=new Ou(null,{name:"ADS showcase",version:"1.0.0"},{serverResources:{},serverTools:{},logging:{}},{hostContext:Mg()});gt=i,i.onreadresource=u=>tt.readResource(u),i.oncalltool=u=>{let d=qg.find(h=>h.name===u.name);if(!d||!(d._meta?.ui?.visibility??["model","app"]).includes("app"))throw new Error("This tool is not callable from an App.");return tt.callTool(u)},i.onloggingmessage=u=>{u.logger!=="ads-preview"||u.data?.id!==St?.id||(u.data.state==="ready"&&u.data.revision===St.manifestRevision?ro(""):u.data.code==="ADS_PREVIEW_REOPEN"?(gt=void 0,Fn=void 0,mr=void 0,Ly(),Hn(i).then(()=>Vn({force:!0})).catch(fr)):u.data.state==="error"&&ro(u.data.message,!0))},i.onerror=fr;let a,l=new Promise((u,d)=>{a=setTimeout(()=>d(new Error("MCP App initialization timed out.")),15e3),i.oninitialized=()=>{clearTimeout(a),u()}});i.onsandboxready=()=>i.sendSandboxResourceReady({html:n.text,csp:n._meta?.ui?.csp,sandbox:"allow-scripts"});try{await Promise.all([i.connect(new Iu(s.contentWindow,s.contentWindow)),l])}catch(u){throw await Hn(i),u}finally{clearTimeout(a)}return i})();try{return await mr}catch(r){throw t===Cg&&(Fn=void 0,mr=void 0),r}}async function XP(){let e=St;if(!e||e.token)return;let t=await WP("ads://project/build");if(St!==e)return;let o=t.previews.find(r=>r.id===e.id);if(!o){ro("The selected scenario is no longer registered.",!0);return}if(!(["idle","building"].includes(o.state)&&e.build?.current&&o.session===e.build.session&&o.revision<=e.build.revision)){if(o.state==="error"){ro(`Preview build failed. Showing an earlier view.
114
+ - "app": Tool callable by the app from this server only`),csp:p.never().optional(),permissions:p.never().optional()}),wk=p.object({mimeTypes:p.array(p.string()).optional().describe('Array of supported MIME types for UI resources.\nMust include `"text/html;profile=mcp-app"` for MCP Apps support.')}),LP=p.object({method:p.literal("ui/download-file"),params:p.object({contents:p.array(p.union([or,rr])).describe("Resource contents to download \u2014 embedded (inline data) or linked (host fetches). Uses standard MCP resource types.")})}),UP=p.object({method:p.literal("ui/message"),params:p.object({role:p.literal("user").describe('Message role, currently only "user" is supported.'),content:p.array(Nt).describe("Message content blocks (text, image, etc.).")})}),xk=p.object({method:p.literal("ui/notifications/sandbox-resource-ready"),params:p.object({html:p.string().describe("HTML content to load into the inner iframe."),sandbox:p.string().optional().describe("Optional override for the inner iframe's sandbox attribute."),csp:Pg.optional().describe("CSP configuration from resource metadata."),permissions:Tg.optional().describe("Sandbox permissions from resource metadata.")})}),Pk=p.object({method:p.literal("ui/notifications/tool-result"),params:Po.describe("Standard MCP tool execution result.")}),Ay=p.object({toolInfo:p.object({id:ht.optional().describe("JSON-RPC id of the tools/call request."),tool:xo.describe("Tool definition including name, inputSchema, etc.")}).optional().describe("Metadata of the tool call that instantiated this App."),theme:vP.optional().describe("Current color theme preference."),styles:IP.optional().describe("Style configuration for theming the app."),displayMode:Fa.optional().describe("How the UI is currently displayed."),availableDisplayModes:p.array(Fa).optional().describe("Display modes the host supports."),containerDimensions:p.union([p.object({height:p.number().describe("Fixed container height in pixels.")}),p.object({maxHeight:p.union([p.number(),p.undefined()]).optional().describe("Maximum container height in pixels.")})]).and(p.union([p.object({width:p.number().describe("Fixed container width in pixels.")}),p.object({maxWidth:p.union([p.number(),p.undefined()]).optional().describe("Maximum container width in pixels.")})])).optional().describe(`Container dimensions. Represents the dimensions of the iframe or other
115
+ container holding the app. Specify either width or maxWidth, and either height or maxHeight.`),locale:p.string().optional().describe("User's language and region preference in BCP 47 format."),timeZone:p.string().optional().describe("User's timezone in IANA format."),userAgent:p.string().optional().describe("Host application identifier."),platform:p.union([p.literal("web"),p.literal("desktop"),p.literal("mobile")]).optional().describe("Platform type for responsive design decisions."),deviceCapabilities:p.object({touch:p.boolean().optional().describe("Whether the device supports touch input."),hover:p.boolean().optional().describe("Whether the device supports hover interactions.")}).optional().describe("Device input capabilities."),safeAreaInsets:p.object({top:p.number().describe("Top safe area inset in pixels."),right:p.number().describe("Right safe area inset in pixels."),bottom:p.number().describe("Bottom safe area inset in pixels."),left:p.number().describe("Left safe area inset in pixels.")}).optional().describe("Mobile safe area boundaries in pixels.")}).passthrough(),Tk=p.object({method:p.literal("ui/notifications/host-context-changed"),params:Ay.describe("Partial context update containing only changed fields.")}),ZP=p.object({method:p.literal("ui/update-model-context"),params:p.object({content:p.array(Nt).optional().describe("Context content blocks (text, image, etc.)."),structuredContent:p.record(p.string(),p.unknown().describe("Structured content for machine-readable context data.")).optional().describe("Structured content for machine-readable context data.")})}),DP=p.object({method:p.literal("ui/initialize"),params:p.object({appInfo:It.describe("App identification (name and version)."),appCapabilities:MP.describe("Features and capabilities this app provides."),protocolVersion:p.string().describe("Protocol version this app supports.")})}),FP=p.object({protocolVersion:p.string().describe('Negotiated protocol version string (e.g., "2025-11-21").'),hostInfo:It.describe("Host application identification and version."),hostCapabilities:qP.describe("Features and capabilities provided by the host."),hostContext:Ay.describe("Rich context about the host environment.")}).passthrough();var Ou=class{eventTarget;eventSource;messageListener;constructor(t=window.parent,o){this.eventTarget=t,this.eventSource=o,this.messageListener=r=>{if(o&&r.source!==this.eventSource){console.debug("Ignoring message from unknown source",r);return}let n=mt.safeParse(r.data);n.success?(console.debug("Parsed message",n.data),this.onmessage?.(n.data)):r.data?.jsonrpc!=="2.0"?console.debug("Ignoring non-JSON-RPC message",n.error.message,r):(console.error("Failed to parse message",n.error.message,r),this.onerror?.(Error("Invalid JSON-RPC message received: "+n.error.message)))}}async start(){window.addEventListener("message",this.messageListener)}async send(t,o){t.method!==zP&&console.debug("Sending message",t),this.eventTarget.postMessage(t,"*")}async close(){window.removeEventListener("message",this.messageListener),this.onclose?.()}onclose;onerror;onmessage;sessionId;setProtocolVersion};var HP=[My],Nu=class extends Tu{_client;_hostInfo;_hostCapabilities;_appCapabilities;_hostContext={};_appInfo;_initializedReceived=!1;_registeredEvents=new Set;_events=new wg;_methods=new xg;setRequestHandler=(...t)=>{let[o,...r]=Iy("request",t)??t;this._methods.claim(o,"setRequestHandler"),super.setRequestHandler.call(this,o,...r)};setNotificationHandler=(...t)=>{let[o,...r]=Iy("notification",t)??t;this._methods.claim(o,"setNotificationHandler"),super.setNotificationHandler.call(this,o,...r)};removeRequestHandler=t=>{this._methods.release(t),super.removeRequestHandler(t)};removeNotificationHandler=t=>{this._methods.release(t),super.removeNotificationHandler(t)};replaceRequestHandler=(t,...o)=>{this._methods.replace(t),super.setRequestHandler.call(this,t,...o)};_wrapHandler(t,o){let r=super._wrapHandler(t,o);return t==="ui/initialize"||t==="ping"?r:async(n,s)=>(this._initializedReceived||console.warn(`[ext-apps] AppBridge received '${t}' before ui/notifications/initialized. The View is calling host methods before completing the handshake; it should await app.connect() first.`),r(n,s))}eventSchemas={sizechange:$P,sandboxready:kP,initialized:AP,requestteardown:NP,loggingmessage:nr};setEventHandler(t,o){this._ensureEventSlot(t),this._events.setHandler(t,o)}getEventHandler(t){return this._events.getHandler(t)}addEventListener(t,o){this._ensureEventSlot(t),this._events.addEventListener(t,o)}removeEventListener(t,o){this._events.removeEventListener(t,o)}_ensureEventSlot(t){if(this._registeredEvents.has(t))return;let o=this.eventSchemas[t];if(!o)throw Error(`Unknown event: ${String(t)}`);let r=n=>{t==="initialized"&&(this._initializedReceived=!0),this._events.dispatch(t,n)};t==="loggingmessage"?this.setNotificationHandler("notifications/message",n=>{r(n.params)}):this.setNotificationHandler(o.shape.method.value,{params:o.shape.params},n=>r(n)),this._registeredEvents.add(t)}warnIfRequestHandlerReplaced(t,o,r){o&&r&&console.warn(`[MCP Apps] ${t} handler replaced. Previous handler will no longer be called.`)}constructor(t,o,r,n){super(n),this._client=t,this._hostInfo=o,this._hostCapabilities=r,this._methods.replace("notifications/cancelled"),this._methods.replace("notifications/progress"),this._ensureEventSlot("initialized"),this._hostContext=n?.hostContext||{},this.replaceRequestHandler("ui/initialize",{params:DP.shape.params,result:FP},s=>this._onAppsInitialize(s)),this.replaceRequestHandler("ping",(s,i)=>(this.onping?.(s.params,i),{})),this.replaceRequestHandler("ui/request-display-mode",{params:Ny.shape.params,result:qy},()=>({mode:this._hostContext.displayMode??"inline"}))}buildContext(t){return t}assertCapabilityForMethod(t){}assertRequestHandlerCapability(t){}assertNotificationCapability(t){}getAppCapabilities(){return this._appCapabilities}getAppVersion(){return this._appInfo}onping;get onsizechange(){return this.getEventHandler("sizechange")}set onsizechange(t){this.setEventHandler("sizechange",t)}get onsandboxready(){return this.getEventHandler("sandboxready")}set onsandboxready(t){this.setEventHandler("sandboxready",t)}get oninitialized(){return this.getEventHandler("initialized")}set oninitialized(t){this.setEventHandler("initialized",t)}_onmessage;get onmessage(){return this._onmessage}set onmessage(t){this.warnIfRequestHandlerReplaced("onmessage",this._onmessage,t),this._onmessage=t,this.replaceRequestHandler("ui/message",{params:UP.shape.params,result:EP},async(o,r)=>{if(!this._onmessage)throw Error("No onmessage handler set");return this._onmessage(o,r)})}_onopenlink;get onopenlink(){return this._onopenlink}set onopenlink(t){this.warnIfRequestHandlerReplaced("onopenlink",this._onopenlink,t),this._onopenlink=t,this.replaceRequestHandler("ui/open-link",{params:xP.shape.params,result:PP},async(o,r)=>{if(!this._onopenlink)throw Error("No onopenlink handler set");return this._onopenlink(o,r)})}_ondownloadfile;get ondownloadfile(){return this._ondownloadfile}set ondownloadfile(t){this.warnIfRequestHandlerReplaced("ondownloadfile",this._ondownloadfile,t),this._ondownloadfile=t,this.replaceRequestHandler("ui/download-file",{params:LP.shape.params,result:TP},async(o,r)=>{if(!this._ondownloadfile)throw Error("No ondownloadfile handler set");return this._ondownloadfile(o,r)})}get onrequestteardown(){return this.getEventHandler("requestteardown")}set onrequestteardown(t){this.setEventHandler("requestteardown",t)}_onrequestdisplaymode;get onrequestdisplaymode(){return this._onrequestdisplaymode}set onrequestdisplaymode(t){this.warnIfRequestHandlerReplaced("onrequestdisplaymode",this._onrequestdisplaymode,t),this._onrequestdisplaymode=t,this.replaceRequestHandler("ui/request-display-mode",{params:Ny.shape.params,result:qy},async(o,r)=>{if(!this._onrequestdisplaymode)throw Error("No onrequestdisplaymode handler set");return this._onrequestdisplaymode(o,r)})}get onloggingmessage(){return this.getEventHandler("loggingmessage")}set onloggingmessage(t){this.setEventHandler("loggingmessage",t)}_onupdatemodelcontext;get onupdatemodelcontext(){return this._onupdatemodelcontext}set onupdatemodelcontext(t){this.warnIfRequestHandlerReplaced("onupdatemodelcontext",this._onupdatemodelcontext,t),this._onupdatemodelcontext=t,this.replaceRequestHandler("ui/update-model-context",{params:ZP.shape.params,result:Ro},async(o,r)=>{if(!this._onupdatemodelcontext)throw Error("No onupdatemodelcontext handler set");return this._onupdatemodelcontext(o,r)})}_oncalltool;get oncalltool(){return this._oncalltool}set oncalltool(t){this.warnIfRequestHandlerReplaced("oncalltool",this._oncalltool,t),this._oncalltool=t,this.replaceRequestHandler("tools/call",async(o,r)=>{if(!this._oncalltool)throw Error("No oncalltool handler set");return this._oncalltool(o.params,r)})}_oncreatesamplingmessage;get oncreatesamplingmessage(){return this._oncreatesamplingmessage}set oncreatesamplingmessage(t){this.warnIfRequestHandlerReplaced("oncreatesamplingmessage",this._oncreatesamplingmessage,t),this._oncreatesamplingmessage=t,this.replaceRequestHandler("sampling/createMessage",async(o,r)=>{if(!this._oncreatesamplingmessage)throw Error("No oncreatesamplingmessage handler set");return this._oncreatesamplingmessage(o.params,r)})}sendToolListChanged(t={}){return this.notification({method:"notifications/tools/list_changed",params:t})}_onlistresources;get onlistresources(){return this._onlistresources}set onlistresources(t){this.warnIfRequestHandlerReplaced("onlistresources",this._onlistresources,t),this._onlistresources=t,this.replaceRequestHandler("resources/list",async(o,r)=>{if(!this._onlistresources)throw Error("No onlistresources handler set");return this._onlistresources(o.params,r)})}_onlistresourcetemplates;get onlistresourcetemplates(){return this._onlistresourcetemplates}set onlistresourcetemplates(t){this.warnIfRequestHandlerReplaced("onlistresourcetemplates",this._onlistresourcetemplates,t),this._onlistresourcetemplates=t,this.replaceRequestHandler("resources/templates/list",async(o,r)=>{if(!this._onlistresourcetemplates)throw Error("No onlistresourcetemplates handler set");return this._onlistresourcetemplates(o.params,r)})}_onreadresource;get onreadresource(){return this._onreadresource}set onreadresource(t){this.warnIfRequestHandlerReplaced("onreadresource",this._onreadresource,t),this._onreadresource=t,this.replaceRequestHandler("resources/read",async(o,r)=>{if(!this._onreadresource)throw Error("No onreadresource handler set");return this._onreadresource(o.params,r)})}sendResourceListChanged(t={}){return this.notification({method:"notifications/resources/list_changed",params:t})}_onlistprompts;get onlistprompts(){return this._onlistprompts}set onlistprompts(t){this.warnIfRequestHandlerReplaced("onlistprompts",this._onlistprompts,t),this._onlistprompts=t,this.replaceRequestHandler("prompts/list",async(o,r)=>{if(!this._onlistprompts)throw Error("No onlistprompts handler set");return this._onlistprompts(o.params,r)})}sendPromptListChanged(t={}){return this.notification({method:"notifications/prompts/list_changed",params:t})}getCapabilities(){return this._hostCapabilities}async _onAppsInitialize(t){let o=t.protocolVersion;return this._appInfo!==void 0&&console.warn("[ext-apps] AppBridge received a second ui/initialize. The View may be double-mounting (e.g. React StrictMode in dev) without closing the previous App instance. Responding normally; the latest appInfo/appCapabilities replace the previous values."),this._appCapabilities=t.appCapabilities,this._appInfo=t.appInfo,{protocolVersion:HP.includes(o)?o:My,hostCapabilities:this.getCapabilities(),hostInfo:this._hostInfo,hostContext:this._hostContext}}setHostContext(t){let o={},r=!1;for(let n of Object.keys(t)){let s=this._hostContext[n],i=t[n];VP(s,i)||(o[n]=i,r=!0)}r&&(this._hostContext=t,this.sendHostContextChange(o))}sendHostContextChange(t){return this.notification({method:"ui/notifications/host-context-changed",params:t})}sendToolInput(t){return this.notification({method:"ui/notifications/tool-input",params:t})}sendToolInputPartial(t){return this.notification({method:"ui/notifications/tool-input-partial",params:t})}sendToolResult(t){return this.notification({method:"ui/notifications/tool-result",params:t})}sendToolCancelled(t){return this.notification({method:"ui/notifications/tool-cancelled",params:t})}sendSandboxResourceReady(t){return this.notification({method:"ui/notifications/sandbox-resource-ready",params:t})}teardownResource(t,o){return this.request({method:"ui/resource-teardown",params:t},OP,o)}sendResourceTeardown=this.teardownResource;callTool(t,o){return this.request({method:"tools/call",params:t},o)}listTools(t,o){return this.request({method:"tools/list",params:t},o)}async connect(t){if(this.transport)throw Error("AppBridge is already connected. Call close() before connecting again.");if(this._initializedReceived=!1,this._client){let o=this._client.getServerCapabilities();if(!o)throw Error("Client server capabilities not available");o.tools&&(this.oncalltool=async(r,n)=>this._client.request({method:"tools/call",params:r},{signal:n.mcpReq.signal}),o.tools.listChanged&&this._client.setNotificationHandler("notifications/tools/list_changed",r=>this.sendToolListChanged(r.params))),o.resources&&(this.onlistresources=async(r,n)=>this._client.request({method:"resources/list",params:r},{signal:n.mcpReq.signal}),this.onlistresourcetemplates=async(r,n)=>this._client.request({method:"resources/templates/list",params:r},{signal:n.mcpReq.signal}),this.onreadresource=async(r,n)=>this._client.request({method:"resources/read",params:r},{signal:n.mcpReq.signal}),o.resources.listChanged&&this._client.setNotificationHandler("notifications/resources/list_changed",r=>this.sendResourceListChanged(r.params))),o.prompts&&(this.onlistprompts=async(r,n)=>this._client.request({method:"prompts/list",params:r},{signal:n.mcpReq.signal}),o.prompts.listChanged&&this._client.setNotificationHandler("notifications/prompts/list_changed",r=>this.sendPromptListChanged(r.params)))}return super.connect(t)}};function VP(e,t){return JSON.stringify(e)===JSON.stringify(t)}var re=e=>document.getElementById(e),Ha=new URLSearchParams(location.search),JP=Ha.get("scenario")??Ha.get("category"),BP=["tokens","components","patterns","composition"],we="tokens",oo={},Eg=!0,Og=[],Ng=[],Mg=[],kg,St,gt,Zn,Dn=0,fr=Ha.get("capture")==="1"&&Ha.get("theme")==="dark"?"dark":"light";Ha.get("capture")==="1"&&(document.documentElement.dataset.capture="true");document.documentElement.dataset.theme=fr;var $g,Cg=!1,Au,qg,ju=!1,Va=!1,Fn,mr,Ig=0,qu,tt=new ky({name:"ads-showcase",version:"1.0.0"},{versionNegotiation:{mode:"auto"},capabilities:{extensions:{"io.modelcontextprotocol/ui":{mimeTypes:["text/html;profile=mcp-app"]}}}}),Mu=(e,t={})=>tt.callTool({name:e,arguments:t}),WP=async e=>JSON.parse((await tt.readResource({uri:e})).contents.find(t=>typeof t.text=="string").text);function ro(e,t=!1){re("loader").hidden=!0,re("preview").removeAttribute("aria-busy"),re("status").hidden=!e,re("status").textContent=e,re("status").dataset.error=String(t),re("status").setAttribute("role",t?"alert":"status")}function Ly(){re("status").hidden=!0,re("loader").hidden=!1,re("preview").setAttribute("aria-busy","true")}function jy(e){let t=new URL(location.href);return t.searchParams.delete("scenario"),t.searchParams.delete("category"),e&&t.searchParams.set("scenario",e),t.pathname+t.search+t.hash}function KP(){return we==="tokens"?Og:Ng.filter(e=>e.kind===we)}function Ag(){return{theme:fr,displayMode:"inline",containerDimensions:{width:re("frame-slot").clientWidth,height:re("frame-slot").clientHeight}}}function jg(){let e=KP();e.some(o=>o.id===oo[we])||(oo[we]=e[0]?.id??null),history.replaceState(null,"",jy(oo[we]));let t=re("sidebar").scrollTop;re("entries").setAttribute("aria-label",we[0].toUpperCase()+we.slice(1)),re("entries").replaceChildren(...e.map(o=>{let r=document.createElement("a");return r.textContent=o.title,r.href=jy(o.id),o.id===oo[we]&&r.setAttribute("aria-current","page"),r.addEventListener("click",n=>{n.button||n.metaKey||n.ctrlKey||n.shiftKey||n.altKey||(n.preventDefault(),oo[we]=o.id,jg(),Vn().catch(gr))}),r})),re("sidebar").scrollTop=t;for(let o of re("sections").querySelectorAll("button"))o.dataset.section===we?o.setAttribute("aria-current","page"):o.removeAttribute("aria-current")}function gr(e){!ju&&!Va&&ro(`${e.message}${St?`
116
+ The retained preview is not verified against the current source.`:""}`,!0)}async function Hn(e){if(e){try{await e.teardownResource({},{timeout:500})}catch{}await e.close()}}function Uy(){if(ju||Va)return;Va=!0,++Dn,clearTimeout(Au),ro("MCP disconnected. The retained preview is stale. Refresh the page after restarting ADS.",!0);let e=gt;gt=void 0,Hn(e)}async function Zy(){kg=(await Mu("ads_status")).structuredContent,re("title").textContent=kg.project.showcase.title,re("title").title=kg.projectRoot;let e=[],t;do{let i=await tt.listTools(t?{cursor:t}:{});e.push(...i.tools),t=i.nextCursor}while(t);Mg=e,Og=(await Mu("ads_tokens",{limit:1})).structuredContent.categories;let o=[],r=0;do{let i=(await Mu("ads_scenarios",{limit:50,offset:r})).structuredContent;o.push(...i.scenarios),r=i.nextOffset}while(r!==void 0);Ng=o;let n=Eg?JP:oo[we],s=Ng.find(i=>i.id===n);s&&BP.includes(s.kind)?(we=s.kind,oo[we]=s.id):Eg&&Og.some(i=>i.id===n)&&(oo.tokens=n),Eg=!1,jg()}function Vn({force:e=!1}={}){if(Va)return Promise.resolve();let t=oo[we],o=`${we}:${t}`;if(Zn?.key===o)return Zn.promise;if(!e&&!Zn&&St?.key===o)return Promise.resolve();let r={key:o};return Zn=r,r.promise=GP(t,o,we==="tokens").finally(()=>{Zn===r&&(Zn=void 0)}),r.promise}async function GP(e,t,o){let r=++Dn;try{if(!e&&!o){if(await Hn(gt),r!==Dn)return;gt=void 0,St=void 0,Fn=void 0,mr=void 0,re("frame-slot").replaceChildren(),ro("No scenarios discovered. Colocate an independently mountable scenario and fixture with the public implementation.");return}let n=Mg.find(l=>l.name===(o?"ads_show_tokens":"ads_show_scenario"));if(!n?._meta?.ui?.resourceUri)throw new Error("The server did not expose a preview App tool.");let s=o?e?{category:e}:{}:{id:e};Ly();let i=await Mu(n.name,s);if(r!==Dn)return;if(i.isError)throw new Error(i.content?.find(l=>l.type==="text")?.text??"Preview build failed.");St={key:t,id:e,token:o&&!i.structuredContent?.scenario,build:i.structuredContent?.build,manifestRevision:i.structuredContent?.manifestRevision};let a=await YP(n._meta.ui.resourceUri);if(r!==Dn)return;if(Fn==="ui://ads/preview"&&!St.manifestRevision)throw new Error("The resource preview has no manifest revision.");await a.sendToolInput({arguments:s}),await a.sendToolResult(i),i.structuredContent?.manifestUri||ro("")}catch(n){r===Dn&&gr(n)}}async function YP(e){if(Fn===e&&mr)return mr;let t=++Ig,o=gt;gt=void 0,Fn=e,mr=(async()=>{await Hn(o);let r=await tt.readResource({uri:e});if(t!==Ig||ju||Va)throw new Error("Preview opening was superseded.");let n=r.contents.find(u=>u.mimeType==="text/html;profile=mcp-app"&&typeof u.text=="string");if(!n)throw new Error("The preview resource contains no MCP App.");let s=document.createElement("iframe");s.title="Design-system preview",s.setAttribute("sandbox","allow-scripts allow-same-origin"),s.src=qu,re("frame-slot").replaceChildren(s);let i=new Nu(null,{name:"ADS showcase",version:"1.0.0"},{serverResources:{},serverTools:{},logging:{}},{hostContext:Ag()});gt=i,i.onreadresource=u=>tt.readResource(u),i.oncalltool=u=>{let d=Mg.find(h=>h.name===u.name);if(!d||!(d._meta?.ui?.visibility??["model","app"]).includes("app"))throw new Error("This tool is not callable from an App.");return tt.callTool(u)},i.onloggingmessage=u=>{u.logger!=="ads-preview"||u.data?.id!==St?.id||(u.data.state==="ready"&&u.data.revision===St.manifestRevision?ro(""):u.data.code==="ADS_PREVIEW_REOPEN"?(gt=void 0,Fn=void 0,mr=void 0,Ly(),Hn(i).then(()=>Vn({force:!0})).catch(gr)):u.data.state==="error"&&ro(u.data.message,!0))},i.onerror=gr;let a,l=new Promise((u,d)=>{a=setTimeout(()=>d(new Error("MCP App initialization timed out.")),15e3),i.oninitialized=()=>{clearTimeout(a),u()}});i.onsandboxready=()=>i.sendSandboxResourceReady({html:n.text,csp:n._meta?.ui?.csp,sandbox:"allow-scripts"});try{await Promise.all([i.connect(new Ou(s.contentWindow,s.contentWindow)),l])}catch(u){throw await Hn(i),u}finally{clearTimeout(a)}return i})();try{return await mr}catch(r){throw t===Ig&&(Fn=void 0,mr=void 0),r}}async function XP(){let e=St;if(!e||e.token)return;let t=await WP("ads://project/build");if(St!==e)return;let o=t.previews.find(r=>r.id===e.id);if(!o){ro("The selected scenario is no longer registered.",!0);return}if(!(["idle","building"].includes(o.state)&&e.build?.current&&o.session===e.build.session&&o.revision<=e.build.revision)){if(o.state==="error"){ro(`Preview build failed. Showing an earlier view.
117
117
  ${o.diagnostics.map(r=>`${r.file??""}${r.line?`:${r.line}`:""}: ${r.message}`).join(`
118
- `)}`,!0);return}if(["idle","building"].includes(o.state)){ro("Rebuilding\u2026 The current view is the previous preview.");return}o.current&&(o.revision!==e.build?.revision||o.session!==e.build?.session)&&await Vn({force:!0})}}function ju(e=!1,t=!1){$g||=e,t&&St?.token&&(St.key="invalidated"),clearTimeout(Mu),Mu=setTimeout(()=>{if(kg){ju(e,t);return}kg=(async()=>{$g&&($g=!1,await Zy()),await Vn(),await XP()})().catch(fr).finally(()=>{kg=void 0})},150)}for(let e of re("sections").querySelectorAll("button"))e.addEventListener("click",()=>{we=e.dataset.section,Ag(),Vn().catch(fr)});re("pane-toggle").addEventListener("click",()=>{let e=document.body.classList.toggle("collapsed");re("pane-toggle").setAttribute("aria-expanded",String(!e)),re("pane-toggle").setAttribute("aria-label",e?"Show navigation pane":"Hide navigation pane"),re("pane-toggle").title=e?"Show navigation pane":"Hide navigation pane",re("pane-toggle").querySelector("path").setAttribute("d",e?"M6 4l4 4-4 4":"M10 4l-4 4 4 4")});re("theme").addEventListener("click",()=>{Dn=Dn==="light"?"dark":"light",document.documentElement.dataset.theme=Dn,re("theme").setAttribute("aria-label",Dn==="dark"?"Use light theme":"Use dark theme"),re("theme").title=re("theme").getAttribute("aria-label"),re("theme").querySelector("svg").innerHTML=Dn==="dark"?'<circle cx="8" cy="8" r="3"/><path d="M8 1v1M8 14v1M1 8h1M14 8h1M3 3l1 1M12 12l1 1M3 13l1-1M12 4l1-1"/>':'<path d="M13.5 9a5.5 5.5 0 0 1-6.5-6.5A5.5 5.5 0 1 0 13.5 9Z"/>',gt?.setHostContext(Mg())});re("minimize").addEventListener("click",()=>{re("header").hidden=!0,document.body.classList.add("collapsed")});var Dy=new ResizeObserver(()=>gt?.setHostContext(Mg()));Dy.observe(re("frame-slot"));window.addEventListener("pagehide",()=>{Au=!0,clearTimeout(Mu),Dy.disconnect(),Hn(gt),Ng?.close(),tt.close()},{once:!0});tt.onclose=Uy;tt.setNotificationHandler("notifications/resources/list_changed",()=>ju(!0));tt.setNotificationHandler("notifications/tools/list_changed",()=>ju(!0));tt.setNotificationHandler("notifications/resources/updated",({params:e})=>ju(!1,e.uri==="ads://project/tokens"));try{if(Nu=(await fetch("/host.json").then(e=>e.json())).sandboxUrl,!Nu||new URL(Nu).origin===location.origin)throw new Error("The separate-origin MCP App sandbox is unavailable.");await tt.connect(new ky(new URL("/mcp",location.href))),Ng=await tt.listen({resourcesListChanged:!0,toolsListChanged:!0,resourceSubscriptions:["ads://project/build","ads://project/tokens","ads://project/scenarios","ads://project/status"]}),Ng.closed.then(e=>{e!=="local"&&Uy()}),await Zy(),await Vn()}catch(e){fr(e)}
118
+ `)}`,!0);return}if(["idle","building"].includes(o.state)){ro("Rebuilding\u2026 The current view is the previous preview.");return}o.current&&(o.revision!==e.build?.revision||o.session!==e.build?.session)&&await Vn({force:!0})}}function Lu(e=!1,t=!1){Cg||=e,t&&St?.token&&(St.key="invalidated"),clearTimeout(Au),Au=setTimeout(()=>{if($g){Lu(e,t);return}$g=(async()=>{Cg&&(Cg=!1,await Zy()),await Vn(),await XP()})().catch(gr).finally(()=>{$g=void 0})},150)}for(let e of re("sections").querySelectorAll("button"))e.addEventListener("click",()=>{we=e.dataset.section,jg(),Vn().catch(gr)});re("pane-toggle").addEventListener("click",()=>{let e=document.body.classList.toggle("collapsed");re("pane-toggle").setAttribute("aria-expanded",String(!e)),re("pane-toggle").setAttribute("aria-label",e?"Show navigation pane":"Hide navigation pane"),re("pane-toggle").title=e?"Show navigation pane":"Hide navigation pane",re("pane-toggle").querySelector("path").setAttribute("d",e?"M6 4l4 4-4 4":"M10 4l-4 4 4 4")});re("theme").addEventListener("click",()=>{fr=fr==="light"?"dark":"light",document.documentElement.dataset.theme=fr,re("theme").setAttribute("aria-label",fr==="dark"?"Use light theme":"Use dark theme"),re("theme").title=re("theme").getAttribute("aria-label"),re("theme").querySelector("svg").innerHTML=fr==="dark"?'<circle cx="8" cy="8" r="3"/><path d="M8 1v1M8 14v1M1 8h1M14 8h1M3 3l1 1M12 12l1 1M3 13l1-1M12 4l1-1"/>':'<path d="M13.5 9a5.5 5.5 0 0 1-6.5-6.5A5.5 5.5 0 1 0 13.5 9Z"/>',gt?.setHostContext(Ag())});re("minimize").addEventListener("click",()=>{re("header").hidden=!0,document.body.classList.add("collapsed")});var Dy=new ResizeObserver(()=>gt?.setHostContext(Ag()));Dy.observe(re("frame-slot"));window.addEventListener("pagehide",()=>{ju=!0,clearTimeout(Au),Dy.disconnect(),Hn(gt),qg?.close(),tt.close()},{once:!0});tt.onclose=Uy;tt.setNotificationHandler("notifications/resources/list_changed",()=>Lu(!0));tt.setNotificationHandler("notifications/tools/list_changed",()=>Lu(!0));tt.setNotificationHandler("notifications/resources/updated",({params:e})=>Lu(!1,e.uri==="ads://project/tokens"));try{if(qu=(await fetch("/host.json").then(e=>e.json())).sandboxUrl,!qu||new URL(qu).origin===location.origin)throw new Error("The separate-origin MCP App sandbox is unavailable.");await tt.connect(new $y(new URL("/mcp",location.href))),qg=await tt.listen({resourcesListChanged:!0,toolsListChanged:!0,resourceSubscriptions:["ads://project/build","ads://project/tokens","ads://project/scenarios","ads://project/status"]}),qg.closed.then(e=>{e!=="local"&&Uy()}),await Zy(),await Vn()}catch(e){gr(e)}
119
119
  /*! Bundled license information:
120
120
 
121
121
  @modelcontextprotocol/client/dist/src-WCy6ifGf.mjs: