@mcp-b/global 2.0.9 → 2.0.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,7 +1,6 @@
1
- var WebMCP=(function(e,t){var n=Object.create,r=Object.defineProperty,i=Object.getOwnPropertyDescriptor,a=Object.getOwnPropertyNames,o=Object.getPrototypeOf,s=Object.prototype.hasOwnProperty,c=(e,t,n,o)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var c=a(t),l=0,u=c.length,d;l<u;l++)d=c[l],!s.call(e,d)&&d!==n&&r(e,d,{get:(e=>t[e]).bind(null,d),enumerable:!(o=i(t,d))||o.enumerable});return e};t=((e,t,i)=>(i=e==null?{}:n(o(e)),c(t||!e||!e.__esModule?r(i,`default`,{value:e,enumerable:!0}):i,e)))(t);function l(e,t){let n=typeof e;if(n!==typeof t)return!1;if(Array.isArray(e)){if(!Array.isArray(t))return!1;let n=e.length;if(n!==t.length)return!1;for(let r=0;r<n;r++)if(!l(e[r],t[r]))return!1;return!0}if(n===`object`){if(!e||!t)return e===t;let n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(let r of n)if(!l(e[r],t[r]))return!1;return!0}return e===t}function u(e){return encodeURI(d(e))}function d(e){return e.replace(/~/g,`~0`).replace(/\//g,`~1`)}let f={prefixItems:!0,items:!0,allOf:!0,anyOf:!0,oneOf:!0},ee={$defs:!0,definitions:!0,properties:!0,patternProperties:!0,dependentSchemas:!0},te={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},ne=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 re(e,t=Object.create(null),n=ne,r=``){if(e&&typeof e==`object`&&!Array.isArray(e)){let i=e.$id||e.id;if(i){let a=new URL(i,n.href);a.hash.length>1?t[a.href]=e:(a.hash=``,r===``?n=a:re(e,t,n))}}else if(e!==!0&&e!==!1)return t;let i=n.href+(r?`#`+r:``);if(t[i]!==void 0)throw Error(`Duplicate schema URI "${i}".`);if(t[i]=e,e===!0||e===!1)return t;if(e.__absolute_uri__===void 0&&Object.defineProperty(e,`__absolute_uri__`,{enumerable:!1,value:i}),e.$ref&&e.__absolute_ref__===void 0){let t=new URL(e.$ref,n.href);t.hash=t.hash,Object.defineProperty(e,`__absolute_ref__`,{enumerable:!1,value:t.href})}if(e.$recursiveRef&&e.__absolute_recursive_ref__===void 0){let t=new URL(e.$recursiveRef,n.href);t.hash=t.hash,Object.defineProperty(e,`__absolute_recursive_ref__`,{enumerable:!1,value:t.href})}if(e.$anchor){let r=new URL(`#`+e.$anchor,n.href);t[r.href]=e}for(let i in e){if(te[i])continue;let a=`${r}/${u(i)}`,o=e[i];if(Array.isArray(o)){if(f[i]){let e=o.length;for(let r=0;r<e;r++)re(o[r],t,n,`${a}/${r}`)}}else if(ee[i])for(let e in o)re(o[e],t,n,`${a}/${u(e)}`);else re(o,t,n,a)}return t}let ie=/^(\d\d\d\d)-(\d\d)-(\d\d)$/,ae=[0,31,28,31,30,31,30,31,31,30,31,30,31],oe=/^(\d\d):(\d\d):(\d\d)(\.\d+)?(z|[+-]\d\d(?::?\d\d)?)?$/i,se=/^(?=.{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,ce=/^(?:[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,le=/^(?:(?:[^\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,ue=/^(?:(?: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,de=/^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i,fe=/^(?:\/(?:[^~/]|~0|~1)*)*$/,pe=/^#(?:\/(?:[a-z0-9_\-.!$&'()*+,;:=@]|%[0-9a-f]{2}|~0|~1)*)*$/i,me=/^(?:0|[1-9][0-9]*)(?:#|(?:\/(?:[^~/]|~0|~1)*)*)$/,he=e=>{if(e[0]===`"`)return!1;let[t,n,...r]=e.split(`@`);return!t||!n||r.length!==0||t.length>64||n.length>253||t[0]===`.`||t.endsWith(`.`)||t.includes(`..`)||!/^[a-z0-9.-]+$/i.test(n)||!/^[a-z0-9.!#$%&'*+/=?^_`{|}~-]+$/i.test(t)?!1:n.split(`.`).every(e=>/^[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?$/i.test(e))},ge=/^(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)$/,_e=/^((([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,ve=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 ye(e){return e.test.bind(e)}let be={date:Se,time:Ce.bind(void 0,!1),"date-time":Te,duration:ve,uri:Oe,"uri-reference":ye(ce),"uri-template":ye(le),url:ye(ue),email:he,hostname:ye(se),ipv4:ye(ge),ipv6:ye(_e),regex:Ae,uuid:ye(de),"json-pointer":ye(fe),"json-pointer-uri-fragment":ye(pe),"relative-json-pointer":ye(me)};function xe(e){return e%4==0&&(e%100!=0||e%400==0)}function Se(e){let t=e.match(ie);if(!t)return!1;let n=+t[1],r=+t[2],i=+t[3];return r>=1&&r<=12&&i>=1&&i<=(r==2&&xe(n)?29:ae[r])}function Ce(e,t){let n=t.match(oe);if(!n)return!1;let r=+n[1],i=+n[2],a=+n[3],o=!!n[5];return(r<=23&&i<=59&&a<=59||r==23&&i==59&&a==60)&&(!e||o)}let we=/t|\s/i;function Te(e){let t=e.split(we);return t.length==2&&Se(t[0])&&Ce(!0,t[1])}let Ee=/\/|:/,De=/^(?:[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 Oe(e){return Ee.test(e)&&De.test(e)}let ke=/[^\\]\\Z/;function Ae(e){if(ke.test(e))return!1;try{return new RegExp(e,`u`),!0}catch{return!1}}function je(e){let t=0,n=e.length,r=0,i;for(;r<n;)t++,i=e.charCodeAt(r++),i>=55296&&i<=56319&&r<n&&(i=e.charCodeAt(r),(i&64512)==56320&&r++);return t}function p(e,t,n=`2019-09`,r=re(t),i=!0,a=null,o=`#`,s=`#`,c=Object.create(null)){if(t===!0)return{valid:!0,errors:[]};if(t===!1)return{valid:!1,errors:[{instanceLocation:o,keyword:`false`,keywordLocation:o,error:`False boolean schema.`}]};let d=typeof e,f;switch(d){case`boolean`:case`number`:case`string`:f=d;break;case`object`:f=e===null?`null`:Array.isArray(e)?`array`:`object`;break;default:throw Error(`Instances of "${d}" type are not supported.`)}let{$ref:ee,$recursiveRef:te,$recursiveAnchor:ne,type:ie,const:ae,enum:oe,required:se,not:ce,anyOf:le,allOf:ue,oneOf:de,if:fe,then:pe,else:me,format:he,properties:ge,patternProperties:_e,additionalProperties:ve,unevaluatedProperties:ye,minProperties:xe,maxProperties:Se,propertyNames:Ce,dependentRequired:we,dependentSchemas:Te,dependencies:Ee,prefixItems:De,items:Oe,additionalItems:ke,unevaluatedItems:Ae,contains:Me,minContains:Ne,maxContains:Pe,minItems:Fe,maxItems:Ie,uniqueItems:Le,minimum:Re,maximum:m,exclusiveMinimum:ze,exclusiveMaximum:h,multipleOf:Be,minLength:g,maxLength:Ve,pattern:He,__absolute_ref__:Ue,__absolute_recursive_ref__:We}=t,_=[];if(ne===!0&&a===null&&(a=t),te===`#`){let l=a===null?r[We]:a,u=`${s}/$recursiveRef`,d=p(e,a===null?t:a,n,r,i,l,o,u,c);d.valid||_.push({instanceLocation:o,keyword:`$recursiveRef`,keywordLocation:u,error:`A subschema had errors.`},...d.errors)}if(ee!==void 0){let t=r[Ue||ee];if(t===void 0){let e=`Unresolved $ref "${ee}".`;throw Ue&&Ue!==ee&&(e+=` Absolute URI "${Ue}".`),e+=`\nKnown schemas:\n- ${Object.keys(r).join(`
2
- - `)}`,Error(e)}let l=`${s}/$ref`,u=p(e,t,n,r,i,a,o,l,c);if(u.valid||_.push({instanceLocation:o,keyword:`$ref`,keywordLocation:l,error:`A subschema had errors.`},...u.errors),n===`4`||n===`7`)return{valid:_.length===0,errors:_}}if(Array.isArray(ie)){let t=ie.length,n=!1;for(let r=0;r<t;r++)if(f===ie[r]||ie[r]===`integer`&&f===`number`&&e%1==0&&e===e){n=!0;break}n||_.push({instanceLocation:o,keyword:`type`,keywordLocation:`${s}/type`,error:`Instance type "${f}" is invalid. Expected "${ie.join(`", "`)}".`})}else ie===`integer`?(f!==`number`||e%1||e!==e)&&_.push({instanceLocation:o,keyword:`type`,keywordLocation:`${s}/type`,error:`Instance type "${f}" is invalid. Expected "${ie}".`}):ie!==void 0&&f!==ie&&_.push({instanceLocation:o,keyword:`type`,keywordLocation:`${s}/type`,error:`Instance type "${f}" is invalid. Expected "${ie}".`});if(ae!==void 0&&(f===`object`||f===`array`?l(e,ae)||_.push({instanceLocation:o,keyword:`const`,keywordLocation:`${s}/const`,error:`Instance does not match ${JSON.stringify(ae)}.`}):e!==ae&&_.push({instanceLocation:o,keyword:`const`,keywordLocation:`${s}/const`,error:`Instance does not match ${JSON.stringify(ae)}.`})),oe!==void 0&&(f===`object`||f===`array`?oe.some(t=>l(e,t))||_.push({instanceLocation:o,keyword:`enum`,keywordLocation:`${s}/enum`,error:`Instance does not match any of ${JSON.stringify(oe)}.`}):oe.some(t=>e===t)||_.push({instanceLocation:o,keyword:`enum`,keywordLocation:`${s}/enum`,error:`Instance does not match any of ${JSON.stringify(oe)}.`})),ce!==void 0){let t=`${s}/not`;p(e,ce,n,r,i,a,o,t).valid&&_.push({instanceLocation:o,keyword:`not`,keywordLocation:t,error:`Instance matched "not" schema.`})}let Ge=[];if(le!==void 0){let t=`${s}/anyOf`,l=_.length,u=!1;for(let s=0;s<le.length;s++){let l=le[s],d=Object.create(c),f=p(e,l,n,r,i,ne===!0?a:null,o,`${t}/${s}`,d);_.push(...f.errors),u||=f.valid,f.valid&&Ge.push(d)}u?_.length=l:_.splice(l,0,{instanceLocation:o,keyword:`anyOf`,keywordLocation:t,error:`Instance does not match any subschemas.`})}if(ue!==void 0){let t=`${s}/allOf`,l=_.length,u=!0;for(let s=0;s<ue.length;s++){let l=ue[s],d=Object.create(c),f=p(e,l,n,r,i,ne===!0?a:null,o,`${t}/${s}`,d);_.push(...f.errors),u&&=f.valid,f.valid&&Ge.push(d)}u?_.length=l:_.splice(l,0,{instanceLocation:o,keyword:`allOf`,keywordLocation:t,error:`Instance does not match every subschema.`})}if(de!==void 0){let t=`${s}/oneOf`,l=_.length,u=de.filter((s,l)=>{let u=Object.create(c),d=p(e,s,n,r,i,ne===!0?a:null,o,`${t}/${l}`,u);return _.push(...d.errors),d.valid&&Ge.push(u),d.valid}).length;u===1?_.length=l:_.splice(l,0,{instanceLocation:o,keyword:`oneOf`,keywordLocation:t,error:`Instance does not match exactly one subschema (${u} matches).`})}if((f===`object`||f===`array`)&&Object.assign(c,...Ge),fe!==void 0){let t=`${s}/if`;if(p(e,fe,n,r,i,a,o,t,c).valid){if(pe!==void 0){let l=p(e,pe,n,r,i,a,o,`${s}/then`,c);l.valid||_.push({instanceLocation:o,keyword:`if`,keywordLocation:t,error:`Instance does not match "then" schema.`},...l.errors)}}else if(me!==void 0){let l=p(e,me,n,r,i,a,o,`${s}/else`,c);l.valid||_.push({instanceLocation:o,keyword:`if`,keywordLocation:t,error:`Instance does not match "else" schema.`},...l.errors)}}if(f===`object`){if(se!==void 0)for(let t of se)t in e||_.push({instanceLocation:o,keyword:`required`,keywordLocation:`${s}/required`,error:`Instance does not have required property "${t}".`});let t=Object.keys(e);if(xe!==void 0&&t.length<xe&&_.push({instanceLocation:o,keyword:`minProperties`,keywordLocation:`${s}/minProperties`,error:`Instance does not have at least ${xe} properties.`}),Se!==void 0&&t.length>Se&&_.push({instanceLocation:o,keyword:`maxProperties`,keywordLocation:`${s}/maxProperties`,error:`Instance does not have at least ${Se} properties.`}),Ce!==void 0){let t=`${s}/propertyNames`;for(let s in e){let e=`${o}/${u(s)}`,c=p(s,Ce,n,r,i,a,e,t);c.valid||_.push({instanceLocation:o,keyword:`propertyNames`,keywordLocation:t,error:`Property name "${s}" does not match schema.`},...c.errors)}}if(we!==void 0){let t=`${s}/dependantRequired`;for(let n in we)if(n in e){let r=we[n];for(let i of r)i in e||_.push({instanceLocation:o,keyword:`dependentRequired`,keywordLocation:t,error:`Instance has "${n}" but does not have "${i}".`})}}if(Te!==void 0)for(let t in Te){let l=`${s}/dependentSchemas`;if(t in e){let s=p(e,Te[t],n,r,i,a,o,`${l}/${u(t)}`,c);s.valid||_.push({instanceLocation:o,keyword:`dependentSchemas`,keywordLocation:l,error:`Instance has "${t}" but does not match dependant schema.`},...s.errors)}}if(Ee!==void 0){let t=`${s}/dependencies`;for(let s in Ee)if(s in e){let c=Ee[s];if(Array.isArray(c))for(let n of c)n in e||_.push({instanceLocation:o,keyword:`dependencies`,keywordLocation:t,error:`Instance has "${s}" but does not have "${n}".`});else{let l=p(e,c,n,r,i,a,o,`${t}/${u(s)}`);l.valid||_.push({instanceLocation:o,keyword:`dependencies`,keywordLocation:t,error:`Instance has "${s}" but does not match dependant schema.`},...l.errors)}}}let l=Object.create(null),d=!1;if(ge!==void 0){let t=`${s}/properties`;for(let s in ge){if(!(s in e))continue;let f=`${o}/${u(s)}`,ee=p(e[s],ge[s],n,r,i,a,f,`${t}/${u(s)}`);if(ee.valid)c[s]=l[s]=!0;else if(d=i,_.push({instanceLocation:o,keyword:`properties`,keywordLocation:t,error:`Property "${s}" does not match schema.`},...ee.errors),d)break}}if(!d&&_e!==void 0){let t=`${s}/patternProperties`;for(let s in _e){let f=new RegExp(s,`u`),ee=_e[s];for(let te in e){if(!f.test(te))continue;let ne=`${o}/${u(te)}`,re=p(e[te],ee,n,r,i,a,ne,`${t}/${u(s)}`);re.valid?c[te]=l[te]=!0:(d=i,_.push({instanceLocation:o,keyword:`patternProperties`,keywordLocation:t,error:`Property "${te}" matches pattern "${s}" but does not match associated schema.`},...re.errors))}}}if(!d&&ve!==void 0){let t=`${s}/additionalProperties`;for(let s in e){if(l[s])continue;let f=`${o}/${u(s)}`,ee=p(e[s],ve,n,r,i,a,f,t);ee.valid?c[s]=!0:(d=i,_.push({instanceLocation:o,keyword:`additionalProperties`,keywordLocation:t,error:`Property "${s}" does not match additional properties schema.`},...ee.errors))}}else if(!d&&ye!==void 0){let t=`${s}/unevaluatedProperties`;for(let s in e)if(!c[s]){let l=`${o}/${u(s)}`,d=p(e[s],ye,n,r,i,a,l,t);d.valid?c[s]=!0:_.push({instanceLocation:o,keyword:`unevaluatedProperties`,keywordLocation:t,error:`Property "${s}" does not match unevaluated properties schema.`},...d.errors)}}}else if(f===`array`){Ie!==void 0&&e.length>Ie&&_.push({instanceLocation:o,keyword:`maxItems`,keywordLocation:`${s}/maxItems`,error:`Array has too many items (${e.length} > ${Ie}).`}),Fe!==void 0&&e.length<Fe&&_.push({instanceLocation:o,keyword:`minItems`,keywordLocation:`${s}/minItems`,error:`Array has too few items (${e.length} < ${Fe}).`});let t=e.length,u=0,d=!1;if(De!==void 0){let l=`${s}/prefixItems`,f=Math.min(De.length,t);for(;u<f;u++){let t=p(e[u],De[u],n,r,i,a,`${o}/${u}`,`${l}/${u}`);if(c[u]=!0,!t.valid&&(d=i,_.push({instanceLocation:o,keyword:`prefixItems`,keywordLocation:l,error:`Items did not match schema.`},...t.errors),d))break}}if(Oe!==void 0){let l=`${s}/items`;if(Array.isArray(Oe)){let s=Math.min(Oe.length,t);for(;u<s;u++){let t=p(e[u],Oe[u],n,r,i,a,`${o}/${u}`,`${l}/${u}`);if(c[u]=!0,!t.valid&&(d=i,_.push({instanceLocation:o,keyword:`items`,keywordLocation:l,error:`Items did not match schema.`},...t.errors),d))break}}else for(;u<t;u++){let t=p(e[u],Oe,n,r,i,a,`${o}/${u}`,l);if(c[u]=!0,!t.valid&&(d=i,_.push({instanceLocation:o,keyword:`items`,keywordLocation:l,error:`Items did not match schema.`},...t.errors),d))break}if(!d&&ke!==void 0){let l=`${s}/additionalItems`;for(;u<t;u++){let t=p(e[u],ke,n,r,i,a,`${o}/${u}`,l);c[u]=!0,t.valid||(d=i,_.push({instanceLocation:o,keyword:`additionalItems`,keywordLocation:l,error:`Items did not match additional items schema.`},...t.errors))}}}if(Me!==void 0)if(t===0&&Ne===void 0)_.push({instanceLocation:o,keyword:`contains`,keywordLocation:`${s}/contains`,error:`Array is empty. It must contain at least one item matching the schema.`});else if(Ne!==void 0&&t<Ne)_.push({instanceLocation:o,keyword:`minContains`,keywordLocation:`${s}/minContains`,error:`Array has less items (${t}) than minContains (${Ne}).`});else{let l=`${s}/contains`,u=_.length,d=0;for(let s=0;s<t;s++){let t=p(e[s],Me,n,r,i,a,`${o}/${s}`,l);t.valid?(c[s]=!0,d++):_.push(...t.errors)}d>=(Ne||0)&&(_.length=u),Ne===void 0&&Pe===void 0&&d===0?_.splice(u,0,{instanceLocation:o,keyword:`contains`,keywordLocation:l,error:`Array does not contain item matching schema.`}):Ne!==void 0&&d<Ne?_.push({instanceLocation:o,keyword:`minContains`,keywordLocation:`${s}/minContains`,error:`Array must contain at least ${Ne} items matching schema. Only ${d} items were found.`}):Pe!==void 0&&d>Pe&&_.push({instanceLocation:o,keyword:`maxContains`,keywordLocation:`${s}/maxContains`,error:`Array may contain at most ${Pe} items matching schema. ${d} items were found.`})}if(!d&&Ae!==void 0){let l=`${s}/unevaluatedItems`;for(;u<t;u++){if(c[u])continue;let t=p(e[u],Ae,n,r,i,a,`${o}/${u}`,l);c[u]=!0,t.valid||_.push({instanceLocation:o,keyword:`unevaluatedItems`,keywordLocation:l,error:`Items did not match unevaluated items schema.`},...t.errors)}}if(Le)for(let n=0;n<t;n++){let r=e[n],i=typeof r==`object`&&!!r;for(let a=0;a<t;a++){if(n===a)continue;let t=e[a];(r===t||i&&typeof t==`object`&&t&&l(r,t))&&(_.push({instanceLocation:o,keyword:`uniqueItems`,keywordLocation:`${s}/uniqueItems`,error:`Duplicate items at indexes ${n} and ${a}.`}),n=2**53-1,a=2**53-1)}}}else if(f===`number`){if(n===`4`?(Re!==void 0&&(ze===!0&&e<=Re||e<Re)&&_.push({instanceLocation:o,keyword:`minimum`,keywordLocation:`${s}/minimum`,error:`${e} is less than ${ze?`or equal to `:``} ${Re}.`}),m!==void 0&&(h===!0&&e>=m||e>m)&&_.push({instanceLocation:o,keyword:`maximum`,keywordLocation:`${s}/maximum`,error:`${e} is greater than ${h?`or equal to `:``} ${m}.`})):(Re!==void 0&&e<Re&&_.push({instanceLocation:o,keyword:`minimum`,keywordLocation:`${s}/minimum`,error:`${e} is less than ${Re}.`}),m!==void 0&&e>m&&_.push({instanceLocation:o,keyword:`maximum`,keywordLocation:`${s}/maximum`,error:`${e} is greater than ${m}.`}),ze!==void 0&&e<=ze&&_.push({instanceLocation:o,keyword:`exclusiveMinimum`,keywordLocation:`${s}/exclusiveMinimum`,error:`${e} is less than ${ze}.`}),h!==void 0&&e>=h&&_.push({instanceLocation:o,keyword:`exclusiveMaximum`,keywordLocation:`${s}/exclusiveMaximum`,error:`${e} is greater than or equal to ${h}.`})),Be!==void 0){let t=e%Be;Math.abs(0-t)>=1.1920929e-7&&Math.abs(Be-t)>=1.1920929e-7&&_.push({instanceLocation:o,keyword:`multipleOf`,keywordLocation:`${s}/multipleOf`,error:`${e} is not a multiple of ${Be}.`})}}else if(f===`string`){let t=g===void 0&&Ve===void 0?0:je(e);g!==void 0&&t<g&&_.push({instanceLocation:o,keyword:`minLength`,keywordLocation:`${s}/minLength`,error:`String is too short (${t} < ${g}).`}),Ve!==void 0&&t>Ve&&_.push({instanceLocation:o,keyword:`maxLength`,keywordLocation:`${s}/maxLength`,error:`String is too long (${t} > ${Ve}).`}),He!==void 0&&!new RegExp(He,`u`).test(e)&&_.push({instanceLocation:o,keyword:`pattern`,keywordLocation:`${s}/pattern`,error:`String does not match pattern.`}),he!==void 0&&be[he]&&!be[he](e)&&_.push({instanceLocation:o,keyword:`format`,keywordLocation:`${s}/format`,error:`String does not match format "${he}".`})}return{valid:_.length===0,errors:_}}var Me=class{schema;draft;shortCircuit;lookup;constructor(e,t=`2019-09`,n=!0){this.schema=e,this.draft=t,this.shortCircuit=n,this.lookup=re(e)}validate(e){return p(e,this.schema,this.draft,this.lookup,this.shortCircuit)}addSchema(e,t){t&&(e={...e,$id:t}),re(e,this.lookup)}};let Ne=`Failed to parse input arguments`,Pe=`Tool was executed but the invocation failed. For example, the script function threw an error`,Fe=`Tool was cancelled`,Ie={type:`object`,properties:{}},Le=[`draft-2020-12`,`draft-07`],Re=Symbol(`standardValidator`),m={installed:!1,previousModelContextDescriptor:void 0,previousModelContextTestingDescriptor:void 0};var ze=class{tools=new Map;toolsChangedCallback=null;provideContext(e={}){let t=new Map;for(let n of e.tools??[]){let e=Je(n,t);t.set(e.name,e)}this.tools=t,this.notifyToolsChanged()}clearContext(){this.tools.clear(),this.notifyToolsChanged()}registerTool(e){let t=Je(e,this.tools);this.tools.set(t.name,t),this.notifyToolsChanged()}unregisterTool(e){this.tools.delete(e)&&this.notifyToolsChanged()}getTestingShim(){return{listTools:()=>[...this.tools.values()].map(e=>{let t={name:e.name,description:e.description};try{t.inputSchema=JSON.stringify(e.inputSchema)}catch{}return t}),executeTool:(e,t,n)=>this.executeToolForTesting(e,t,n),registerToolsChangedCallback:e=>{if(typeof e!=`function`)throw TypeError(`Failed to execute 'registerToolsChangedCallback' on 'ModelContextTesting': parameter 1 is not of type 'Function'.`);this.toolsChangedCallback=e},getCrossDocumentScriptToolResult:async()=>`[]`}}async executeToolForTesting(e,t,n){if(n?.signal?.aborted)throw h(Fe);let r=this.tools.get(e);if(!r)throw h(`Tool not found: ${e}`);let i=Be(t),a=await Qe(i,r);if(a)throw h(a);let o=!0,s={requestUserInteraction:async t=>{if(!o)throw Error(`ModelContextClient for tool "${e}" is no longer active after execute() resolved`);if(typeof t!=`function`)throw TypeError(`requestUserInteraction(callback) requires a function callback`);return t()}};try{let e=r.execute(i,s);return ot(it(await st(Promise.resolve(e),n?.signal)))}catch(e){throw h(e instanceof Error?`${Pe}: ${e.message}`:Pe)}finally{o=!1}}notifyToolsChanged(){this.toolsChangedCallback&&queueMicrotask(()=>{try{this.toolsChangedCallback?.()}catch(e){console.warn(`[WebMCPPolyfill] toolsChanged callback threw:`,e)}})}};function h(e){try{return new DOMException(e,`UnknownError`)}catch{let t=Error(e);return t.name=`UnknownError`,t}}function Be(e){let t;try{t=JSON.parse(e)}catch{throw h(Ne)}if(!t||typeof t!=`object`||Array.isArray(t))throw h(Ne);return t}function g(e){return!!e&&typeof e==`object`&&!Array.isArray(e)}function Ve(e){if(!g(e))return null;let t=e[`~standard`];return g(t)?t:null}function He(e){let t=Ve(e);return!!(t&&t.version===1&&typeof t.validate==`function`)}function Ue(e){let t=Ve(e);return!t||t.version!==1||!g(t.jsonSchema)?!1:typeof t.jsonSchema.input==`function`}function We(e){return{"~standard":{version:1,vendor:`@mcp-b/webmcp-polyfill-json-schema`,validate(t){if(!g(t))return{issues:[{message:`expected object arguments`}]};let n=Ye(t,e);return n?{issues:[n]}:{value:t}}}}}function _(e){for(let t of Le)try{let n=e[`~standard`].jsonSchema.input({target:t});return Ke(n),n}catch(e){console.warn(`[WebMCPPolyfill] Standard JSON Schema conversion failed for target "${t}":`,e)}throw Error(`Failed to convert Standard JSON Schema inputSchema to a JSON Schema object`)}function Ge(e){if(e===void 0){let e=Ie;return{inputSchema:e,standardValidator:We(e)}}if(Ue(e)){let t=_(e);return{inputSchema:t,standardValidator:We(t)}}if(He(e))return{inputSchema:Ie,standardValidator:e};if(Ke(e),Object.keys(e).length===0)return{inputSchema:Ie,standardValidator:We(Ie)};let t=e.type===void 0?{type:`object`,...e}:e;return{inputSchema:t,standardValidator:We(t)}}function Ke(e){if(!g(e))throw Error(`inputSchema must be a JSON Schema object`);qe(e,`$`)}function qe(e,t){let n=e.type;if(n!==void 0&&typeof n!=`string`&&!(Array.isArray(n)&&n.every(e=>typeof e==`string`&&e.length>0)))throw Error(`Invalid JSON Schema at ${t}: "type" must be a string or string[]`);let r=e.required;if(r!==void 0&&!(Array.isArray(r)&&r.every(e=>typeof e==`string`)))throw Error(`Invalid JSON Schema at ${t}: "required" must be an array of strings`);let i=e.properties;if(i!==void 0){if(!g(i))throw Error(`Invalid JSON Schema at ${t}: "properties" must be an object`);for(let[e,n]of Object.entries(i)){if(!g(n))throw Error(`Invalid JSON Schema at ${t}.properties.${e}: expected object schema`);qe(n,`${t}.properties.${e}`)}}let a=e.items;if(a!==void 0)if(Array.isArray(a))for(let[e,n]of a.entries()){if(!g(n))throw Error(`Invalid JSON Schema at ${t}.items[${e}]: expected object schema`);qe(n,`${t}.items[${e}]`)}else if(g(a))qe(a,`${t}.items`);else throw Error(`Invalid JSON Schema at ${t}: "items" must be an object or object[]`);for(let n of[`allOf`,`anyOf`,`oneOf`]){let r=e[n];if(r!==void 0){if(!Array.isArray(r))throw Error(`Invalid JSON Schema at ${t}: "${n}" must be an array`);for(let[e,i]of r.entries()){if(!g(i))throw Error(`Invalid JSON Schema at ${t}.${n}[${e}]: expected object schema`);qe(i,`${t}.${n}[${e}]`)}}}let o=e.not;if(o!==void 0){if(!g(o))throw Error(`Invalid JSON Schema at ${t}: "not" must be an object schema`);qe(o,`${t}.not`)}try{JSON.stringify(e)}catch{throw Error(`Invalid JSON Schema at ${t}: schema must be JSON-serializable`)}}function Je(e,t){if(!e||typeof e!=`object`)throw TypeError(`registerTool(tool) requires a tool object`);if(typeof e.name!=`string`||e.name.length===0)throw TypeError(`Tool "name" must be a non-empty string`);if(typeof e.description!=`string`||e.description.length===0)throw TypeError(`Tool "description" must be a non-empty string`);if(typeof e.execute!=`function`)throw TypeError(`Tool "execute" must be a function`);if(t.has(e.name))throw Error(`Tool already registered: ${e.name}`);let n=Ge(e.inputSchema),r=e.annotations,i=r?{...r,...r.readOnlyHint===`true`?{readOnlyHint:!0}:r.readOnlyHint===`false`?{readOnlyHint:!1}:{},...r.destructiveHint===`true`?{destructiveHint:!0}:r.destructiveHint===`false`?{destructiveHint:!1}:{},...r.idempotentHint===`true`?{idempotentHint:!0}:r.idempotentHint===`false`?{idempotentHint:!1}:{},...r.openWorldHint===`true`?{openWorldHint:!0}:r.openWorldHint===`false`?{openWorldHint:!1}:{}}:void 0;return{...e,...i?{annotations:i}:{},inputSchema:n.inputSchema,[Re]:n.standardValidator}}function Ye(e,t){let n=new Me(t,`2020-12`,!0).validate(e);if(n.valid)return null;let r=n.errors[n.errors.length-1];return r?{message:r.error}:{message:`Input validation failed`}}function Xe(e){if(!e||e.length===0)return null;let t=e.map(e=>g(e)&&`key`in e?e.key:e).map(e=>String(e)).filter(e=>e.length>0);return t.length===0?null:t.join(`.`)}async function Ze(e,t){let n;try{n=await Promise.resolve(t[`~standard`].validate(e))}catch(e){let t=e instanceof Error?`: ${e.message}`:``;return console.error(`[WebMCPPolyfill] Standard Schema validation threw unexpectedly:`,e),`Input validation error: schema validation failed${t}`}if(!n.issues||n.issues.length===0)return null;let r=n.issues[0];if(!r)return`Input validation error`;let i=Xe(r?.path);return i?`Input validation error: ${r.message} at ${i}`:`Input validation error: ${r.message}`}async function Qe(e,t){return Ze(e,t[Re])}function $e(e){return g(e)&&Array.isArray(e.content)}function et(e){return e===null||typeof e==`string`||typeof e==`number`||typeof e==`boolean`}function tt(e){return et(e)?Number.isFinite(e)||typeof e!=`number`:Array.isArray(e)?e.every(e=>tt(e)):g(e)?Object.values(e).every(e=>tt(e)):!1}function nt(e){if(!(!g(e)||!tt(e)))return e}function rt(e){if(typeof e==`string`)return e;try{return JSON.stringify(e)??String(e)}catch{return String(e)}}function it(e){if($e(e))return e;let t=nt(e);return{content:[{type:`text`,text:rt(e)}],...t?{structuredContent:t}:{},isError:!1}}function at(e){for(let t of e.content??[])if(t.type===`text`&&`text`in t&&typeof t.text==`string`)return t.text;return null}function ot(e){if(e.isError)throw h(at(e)?.replace(/^Error:\s*/i,``).trim()||Pe);let t=e.metadata;if(t&&typeof t==`object`&&t.willNavigate)return null;try{return JSON.stringify(e)}catch{throw h(Pe)}}function st(e,t){return t?t.aborted?Promise.reject(h(Fe)):new Promise((n,r)=>{let i=()=>{a(),r(h(Fe))},a=()=>{t.removeEventListener(`abort`,i)};t.addEventListener(`abort`,i,{once:!0}),e.then(e=>{a(),n(e)},e=>{a(),r(e)})}):e}function ct(){return typeof navigator<`u`?navigator:null}function lt(e,t,n){Object.defineProperty(e,t,{configurable:!0,enumerable:!0,writable:!1,value:n})}function ut(e){let t=ct();if(!t||t.modelContext)return;m.installed&&dt();let n=new ze,r=n;r.__isWebMCPPolyfill=!0,m.previousModelContextDescriptor=Object.getOwnPropertyDescriptor(t,`modelContext`),m.previousModelContextTestingDescriptor=Object.getOwnPropertyDescriptor(t,`modelContextTesting`),lt(t,`modelContext`,r);let i=e?.installTestingShim??`if-missing`,a=!!t.modelContextTesting;(i===`always`||(i===!0||i===`if-missing`)&&!a)&&lt(t,`modelContextTesting`,n.getTestingShim()),m.installed=!0}function dt(){let e=ct();if(!e||!m.installed)return;let t=(t,n)=>{if(n){Object.defineProperty(e,t,n);return}delete e[t]};t(`modelContext`,m.previousModelContextDescriptor),t(`modelContextTesting`,m.previousModelContextTestingDescriptor),m.installed=!1,m.previousModelContextDescriptor=void 0,m.previousModelContextTestingDescriptor=void 0}if(typeof window<`u`&&typeof document<`u`){let e=window.__webMCPPolyfillOptions;if(e?.autoInitialize!==!1)try{ut(e)}catch(e){console.error(`[WebMCPPolyfill] Auto-initialization failed:`,e)}}var v;(function(e){e.assertEqual=e=>{};function t(e){}e.assertIs=t;function n(e){throw Error()}e.assertNever=n,e.arrayToEnum=e=>{let t={};for(let n of e)t[n]=n;return t},e.getValidEnumValues=t=>{let n=e.objectKeys(t).filter(e=>typeof t[t[e]]!=`number`),r={};for(let e of n)r[e]=t[e];return e.objectValues(r)},e.objectValues=t=>e.objectKeys(t).map(function(e){return t[e]}),e.objectKeys=typeof Object.keys==`function`?e=>Object.keys(e):e=>{let t=[];for(let n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.push(n);return t},e.find=(e,t)=>{for(let n of e)if(t(n))return n},e.isInteger=typeof Number.isInteger==`function`?e=>Number.isInteger(e):e=>typeof e==`number`&&Number.isFinite(e)&&Math.floor(e)===e;function r(e,t=` | `){return e.map(e=>typeof e==`string`?`'${e}'`:e).join(t)}e.joinValues=r,e.jsonStringifyReplacer=(e,t)=>typeof t==`bigint`?t.toString():t})(v||={});var ft;(function(e){e.mergeShapes=(e,t)=>({...e,...t})})(ft||={});let y=v.arrayToEnum([`string`,`nan`,`number`,`integer`,`float`,`boolean`,`date`,`bigint`,`symbol`,`function`,`undefined`,`null`,`array`,`object`,`unknown`,`promise`,`void`,`never`,`map`,`set`]),pt=e=>{switch(typeof e){case`undefined`:return y.undefined;case`string`:return y.string;case`number`:return Number.isNaN(e)?y.nan:y.number;case`boolean`:return y.boolean;case`function`:return y.function;case`bigint`:return y.bigint;case`symbol`:return y.symbol;case`object`:return Array.isArray(e)?y.array:e===null?y.null:e.then&&typeof e.then==`function`&&e.catch&&typeof e.catch==`function`?y.promise:typeof Map<`u`&&e instanceof Map?y.map:typeof Set<`u`&&e instanceof Set?y.set:typeof Date<`u`&&e instanceof Date?y.date:y.object;default:return y.unknown}},b=v.arrayToEnum([`invalid_type`,`invalid_literal`,`custom`,`invalid_union`,`invalid_union_discriminator`,`invalid_enum_value`,`unrecognized_keys`,`invalid_arguments`,`invalid_return_type`,`invalid_date`,`invalid_string`,`too_small`,`too_big`,`invalid_intersection_types`,`not_multiple_of`,`not_finite`]);var mt=class e extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=e=>{this.issues=[...this.issues,e]},this.addIssues=(e=[])=>{this.issues=[...this.issues,...e]};let t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name=`ZodError`,this.issues=e}format(e){let t=e||function(e){return e.message},n={_errors:[]},r=e=>{for(let i of e.issues)if(i.code===`invalid_union`)i.unionErrors.map(r);else if(i.code===`invalid_return_type`)r(i.returnTypeError);else if(i.code===`invalid_arguments`)r(i.argumentsError);else if(i.path.length===0)n._errors.push(t(i));else{let e=n,r=0;for(;r<i.path.length;){let n=i.path[r];r===i.path.length-1?(e[n]=e[n]||{_errors:[]},e[n]._errors.push(t(i))):e[n]=e[n]||{_errors:[]},e=e[n],r++}}};return r(this),n}static assert(t){if(!(t instanceof e))throw Error(`Not a ZodError: ${t}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,v.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=e=>e.message){let t=Object.create(null),n=[];for(let r of this.issues)if(r.path.length>0){let n=r.path[0];t[n]=t[n]||[],t[n].push(e(r))}else n.push(e(r));return{formErrors:n,fieldErrors:t}}get formErrors(){return this.flatten()}};mt.create=e=>new mt(e);var ht=(e,t)=>{let n;switch(e.code){case b.invalid_type:n=e.received===y.undefined?`Required`:`Expected ${e.expected}, received ${e.received}`;break;case b.invalid_literal:n=`Invalid literal value, expected ${JSON.stringify(e.expected,v.jsonStringifyReplacer)}`;break;case b.unrecognized_keys:n=`Unrecognized key(s) in object: ${v.joinValues(e.keys,`, `)}`;break;case b.invalid_union:n=`Invalid input`;break;case b.invalid_union_discriminator:n=`Invalid discriminator value. Expected ${v.joinValues(e.options)}`;break;case b.invalid_enum_value:n=`Invalid enum value. Expected ${v.joinValues(e.options)}, received '${e.received}'`;break;case b.invalid_arguments:n=`Invalid function arguments`;break;case b.invalid_return_type:n=`Invalid function return type`;break;case b.invalid_date:n=`Invalid date`;break;case b.invalid_string:typeof e.validation==`object`?`includes`in e.validation?(n=`Invalid input: must include "${e.validation.includes}"`,typeof e.validation.position==`number`&&(n=`${n} at one or more positions greater than or equal to ${e.validation.position}`)):`startsWith`in e.validation?n=`Invalid input: must start with "${e.validation.startsWith}"`:`endsWith`in e.validation?n=`Invalid input: must end with "${e.validation.endsWith}"`:v.assertNever(e.validation):n=e.validation===`regex`?`Invalid`:`Invalid ${e.validation}`;break;case b.too_small:n=e.type===`array`?`Array must contain ${e.exact?`exactly`:e.inclusive?`at least`:`more than`} ${e.minimum} element(s)`:e.type===`string`?`String must contain ${e.exact?`exactly`:e.inclusive?`at least`:`over`} ${e.minimum} character(s)`:e.type===`number`||e.type===`bigint`?`Number must be ${e.exact?`exactly equal to `:e.inclusive?`greater than or equal to `:`greater than `}${e.minimum}`:e.type===`date`?`Date must be ${e.exact?`exactly equal to `:e.inclusive?`greater than or equal to `:`greater than `}${new Date(Number(e.minimum))}`:`Invalid input`;break;case b.too_big:n=e.type===`array`?`Array must contain ${e.exact?`exactly`:e.inclusive?`at most`:`less than`} ${e.maximum} element(s)`:e.type===`string`?`String must contain ${e.exact?`exactly`:e.inclusive?`at most`:`under`} ${e.maximum} character(s)`:e.type===`number`?`Number must be ${e.exact?`exactly`:e.inclusive?`less than or equal to`:`less than`} ${e.maximum}`:e.type===`bigint`?`BigInt must be ${e.exact?`exactly`:e.inclusive?`less than or equal to`:`less than`} ${e.maximum}`:e.type===`date`?`Date must be ${e.exact?`exactly`:e.inclusive?`smaller than or equal to`:`smaller than`} ${new Date(Number(e.maximum))}`:`Invalid input`;break;case b.custom:n=`Invalid input`;break;case b.invalid_intersection_types:n=`Intersection results could not be merged`;break;case b.not_multiple_of:n=`Number must be a multiple of ${e.multipleOf}`;break;case b.not_finite:n=`Number must be finite`;break;default:n=t.defaultError,v.assertNever(e)}return{message:n}};let gt=ht;function _t(){return gt}let vt=e=>{let{data:t,path:n,errorMaps:r,issueData:i}=e,a=[...n,...i.path||[]],o={...i,path:a};if(i.message!==void 0)return{...i,path:a,message:i.message};let s=``,c=r.filter(e=>!!e).slice().reverse();for(let e of c)s=e(o,{data:t,defaultError:s}).message;return{...i,path:a,message:s}};function x(e,t){let n=_t(),r=vt({issueData:t,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,n,n===ht?void 0:ht].filter(e=>!!e)});e.common.issues.push(r)}var yt=class e{constructor(){this.value=`valid`}dirty(){this.value===`valid`&&(this.value=`dirty`)}abort(){this.value!==`aborted`&&(this.value=`aborted`)}static mergeArray(e,t){let n=[];for(let r of t){if(r.status===`aborted`)return S;r.status===`dirty`&&e.dirty(),n.push(r.value)}return{status:e.value,value:n}}static async mergeObjectAsync(t,n){let r=[];for(let e of n){let t=await e.key,n=await e.value;r.push({key:t,value:n})}return e.mergeObjectSync(t,r)}static mergeObjectSync(e,t){let n={};for(let r of t){let{key:t,value:i}=r;if(t.status===`aborted`||i.status===`aborted`)return S;t.status===`dirty`&&e.dirty(),i.status===`dirty`&&e.dirty(),t.value!==`__proto__`&&(i.value!==void 0||r.alwaysSet)&&(n[t.value]=i.value)}return{status:e.value,value:n}}};let S=Object.freeze({status:`aborted`}),bt=e=>({status:`dirty`,value:e}),xt=e=>({status:`valid`,value:e}),St=e=>e.status===`aborted`,Ct=e=>e.status===`dirty`,wt=e=>e.status===`valid`,Tt=e=>typeof Promise<`u`&&e instanceof Promise;var C;(function(e){e.errToObj=e=>typeof e==`string`?{message:e}:e||{},e.toString=e=>typeof e==`string`?e:e?.message})(C||={});var Et=class{constructor(e,t,n,r){this._cachedPath=[],this.parent=e,this.data=t,this._path=n,this._key=r}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}};let Dt=(e,t)=>{if(wt(t))return{success:!0,data:t.value};if(!e.common.issues.length)throw Error(`Validation failed but no issues detected.`);return{success:!1,get error(){return this._error||=new mt(e.common.issues),this._error}}};function w(e){if(!e)return{};let{errorMap:t,invalid_type_error:n,required_error:r,description:i}=e;if(t&&(n||r))throw Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return t?{errorMap:t,description:i}:{errorMap:(t,i)=>{let{message:a}=e;return t.code===`invalid_enum_value`?{message:a??i.defaultError}:i.data===void 0?{message:a??r??i.defaultError}:t.code===`invalid_type`?{message:a??n??i.defaultError}:{message:i.defaultError}},description:i}}var T=class{get description(){return this._def.description}_getType(e){return pt(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:pt(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new yt,ctx:{common:e.parent.common,data:e.data,parsedType:pt(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let t=this._parse(e);if(Tt(t))throw Error(`Synchronous parse encountered promise.`);return t}_parseAsync(e){let t=this._parse(e);return Promise.resolve(t)}parse(e,t){let n=this.safeParse(e,t);if(n.success)return n.data;throw n.error}safeParse(e,t){let n={common:{issues:[],async:t?.async??!1,contextualErrorMap:t?.errorMap},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:pt(e)};return Dt(n,this._parseSync({data:e,path:n.path,parent:n}))}"~validate"(e){let t={common:{issues:[],async:!!this[`~standard`].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:pt(e)};if(!this[`~standard`].async)try{let n=this._parseSync({data:e,path:[],parent:t});return wt(n)?{value:n.value}:{issues:t.common.issues}}catch(e){e?.message?.toLowerCase()?.includes(`encountered`)&&(this[`~standard`].async=!0),t.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:t}).then(e=>wt(e)?{value:e.value}:{issues:t.common.issues})}async parseAsync(e,t){let n=await this.safeParseAsync(e,t);if(n.success)return n.data;throw n.error}async safeParseAsync(e,t){let n={common:{issues:[],contextualErrorMap:t?.errorMap,async:!0},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:pt(e)},r=this._parse({data:e,path:n.path,parent:n});return Dt(n,await(Tt(r)?r:Promise.resolve(r)))}refine(e,t){let n=e=>typeof t==`string`||t===void 0?{message:t}:typeof t==`function`?t(e):t;return this._refinement((t,r)=>{let i=e(t),a=()=>r.addIssue({code:b.custom,...n(t)});return typeof Promise<`u`&&i instanceof Promise?i.then(e=>e?!0:(a(),!1)):i?!0:(a(),!1)})}refinement(e,t){return this._refinement((n,r)=>e(n)?!0:(r.addIssue(typeof t==`function`?t(n,r):t),!1))}_refinement(e){return new An({schema:this,typeName:E.ZodEffects,effect:{type:`refinement`,refinement:e}})}superRefine(e){return this._refinement(e)}constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this[`~standard`]={version:1,vendor:`zod`,validate:e=>this[`~validate`](e)}}optional(){return jn.create(this,this._def)}nullable(){return Mn.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return dn.create(this)}promise(){return kn.create(this,this._def)}or(e){return mn.create([this,e],this._def)}and(e){return vn.create(this,e,this._def)}transform(e){return new An({...w(this._def),schema:this,typeName:E.ZodEffects,effect:{type:`transform`,transform:e}})}default(e){let t=typeof e==`function`?e:()=>e;return new Nn({...w(this._def),innerType:this,defaultValue:t,typeName:E.ZodDefault})}brand(){return new In({typeName:E.ZodBranded,type:this,...w(this._def)})}catch(e){let t=typeof e==`function`?e:()=>e;return new Pn({...w(this._def),innerType:this,catchValue:t,typeName:E.ZodCatch})}describe(e){let t=this.constructor;return new t({...this._def,description:e})}pipe(e){return Ln.create(this,e)}readonly(){return Rn.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}};let Ot=/^c[^\s-]{8,}$/i,kt=/^[0-9a-z]+$/,At=/^[0-9A-HJKMNP-TV-Z]{26}$/i,jt=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,Mt=/^[a-z0-9_-]{21}$/i,Nt=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,Pt=/^[-+]?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)?)??$/,Ft=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,It,Lt=/^(?:(?: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])$/,Rt=/^(?:(?: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])\/(3[0-2]|[12]?[0-9])$/,zt=/^(([0-9a-fA-F]{1,4}:){7,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}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,Bt=/^(([0-9a-fA-F]{1,4}:){7,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}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,Vt=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,Ht=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,Ut=`((\\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])))`,Wt=RegExp(`^${Ut}$`);function Gt(e){let t=`[0-5]\\d`;e.precision?t=`${t}\\.\\d{${e.precision}}`:e.precision??(t=`${t}(\\.\\d+)?`);let n=e.precision?`+`:`?`;return`([01]\\d|2[0-3]):[0-5]\\d(:${t})${n}`}function Kt(e){return RegExp(`^${Gt(e)}$`)}function qt(e){let t=`${Ut}T${Gt(e)}`,n=[];return n.push(e.local?`Z?`:`Z`),e.offset&&n.push(`([+-]\\d{2}:?\\d{2})`),t=`${t}(${n.join(`|`)})`,RegExp(`^${t}$`)}function Jt(e,t){return!!((t===`v4`||!t)&&Lt.test(e)||(t===`v6`||!t)&&zt.test(e))}function Yt(e,t){if(!Nt.test(e))return!1;try{let[n]=e.split(`.`);if(!n)return!1;let r=n.replace(/-/g,`+`).replace(/_/g,`/`).padEnd(n.length+(4-n.length%4)%4,`=`),i=JSON.parse(atob(r));return!(typeof i!=`object`||!i||`typ`in i&&i?.typ!==`JWT`||!i.alg||t&&i.alg!==t)}catch{return!1}}function Xt(e,t){return!!((t===`v4`||!t)&&Rt.test(e)||(t===`v6`||!t)&&Bt.test(e))}var Zt=class e extends T{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==y.string){let t=this._getOrReturnCtx(e);return x(t,{code:b.invalid_type,expected:y.string,received:t.parsedType}),S}let t=new yt,n;for(let r of this._def.checks)if(r.kind===`min`)e.data.length<r.value&&(n=this._getOrReturnCtx(e,n),x(n,{code:b.too_small,minimum:r.value,type:`string`,inclusive:!0,exact:!1,message:r.message}),t.dirty());else if(r.kind===`max`)e.data.length>r.value&&(n=this._getOrReturnCtx(e,n),x(n,{code:b.too_big,maximum:r.value,type:`string`,inclusive:!0,exact:!1,message:r.message}),t.dirty());else if(r.kind===`length`){let i=e.data.length>r.value,a=e.data.length<r.value;(i||a)&&(n=this._getOrReturnCtx(e,n),i?x(n,{code:b.too_big,maximum:r.value,type:`string`,inclusive:!0,exact:!0,message:r.message}):a&&x(n,{code:b.too_small,minimum:r.value,type:`string`,inclusive:!0,exact:!0,message:r.message}),t.dirty())}else if(r.kind===`email`)Ft.test(e.data)||(n=this._getOrReturnCtx(e,n),x(n,{validation:`email`,code:b.invalid_string,message:r.message}),t.dirty());else if(r.kind===`emoji`)It||=RegExp(`^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`,`u`),It.test(e.data)||(n=this._getOrReturnCtx(e,n),x(n,{validation:`emoji`,code:b.invalid_string,message:r.message}),t.dirty());else if(r.kind===`uuid`)jt.test(e.data)||(n=this._getOrReturnCtx(e,n),x(n,{validation:`uuid`,code:b.invalid_string,message:r.message}),t.dirty());else if(r.kind===`nanoid`)Mt.test(e.data)||(n=this._getOrReturnCtx(e,n),x(n,{validation:`nanoid`,code:b.invalid_string,message:r.message}),t.dirty());else if(r.kind===`cuid`)Ot.test(e.data)||(n=this._getOrReturnCtx(e,n),x(n,{validation:`cuid`,code:b.invalid_string,message:r.message}),t.dirty());else if(r.kind===`cuid2`)kt.test(e.data)||(n=this._getOrReturnCtx(e,n),x(n,{validation:`cuid2`,code:b.invalid_string,message:r.message}),t.dirty());else if(r.kind===`ulid`)At.test(e.data)||(n=this._getOrReturnCtx(e,n),x(n,{validation:`ulid`,code:b.invalid_string,message:r.message}),t.dirty());else if(r.kind===`url`)try{new URL(e.data)}catch{n=this._getOrReturnCtx(e,n),x(n,{validation:`url`,code:b.invalid_string,message:r.message}),t.dirty()}else r.kind===`regex`?(r.regex.lastIndex=0,r.regex.test(e.data)||(n=this._getOrReturnCtx(e,n),x(n,{validation:`regex`,code:b.invalid_string,message:r.message}),t.dirty())):r.kind===`trim`?e.data=e.data.trim():r.kind===`includes`?e.data.includes(r.value,r.position)||(n=this._getOrReturnCtx(e,n),x(n,{code:b.invalid_string,validation:{includes:r.value,position:r.position},message:r.message}),t.dirty()):r.kind===`toLowerCase`?e.data=e.data.toLowerCase():r.kind===`toUpperCase`?e.data=e.data.toUpperCase():r.kind===`startsWith`?e.data.startsWith(r.value)||(n=this._getOrReturnCtx(e,n),x(n,{code:b.invalid_string,validation:{startsWith:r.value},message:r.message}),t.dirty()):r.kind===`endsWith`?e.data.endsWith(r.value)||(n=this._getOrReturnCtx(e,n),x(n,{code:b.invalid_string,validation:{endsWith:r.value},message:r.message}),t.dirty()):r.kind===`datetime`?qt(r).test(e.data)||(n=this._getOrReturnCtx(e,n),x(n,{code:b.invalid_string,validation:`datetime`,message:r.message}),t.dirty()):r.kind===`date`?Wt.test(e.data)||(n=this._getOrReturnCtx(e,n),x(n,{code:b.invalid_string,validation:`date`,message:r.message}),t.dirty()):r.kind===`time`?Kt(r).test(e.data)||(n=this._getOrReturnCtx(e,n),x(n,{code:b.invalid_string,validation:`time`,message:r.message}),t.dirty()):r.kind===`duration`?Pt.test(e.data)||(n=this._getOrReturnCtx(e,n),x(n,{validation:`duration`,code:b.invalid_string,message:r.message}),t.dirty()):r.kind===`ip`?Jt(e.data,r.version)||(n=this._getOrReturnCtx(e,n),x(n,{validation:`ip`,code:b.invalid_string,message:r.message}),t.dirty()):r.kind===`jwt`?Yt(e.data,r.alg)||(n=this._getOrReturnCtx(e,n),x(n,{validation:`jwt`,code:b.invalid_string,message:r.message}),t.dirty()):r.kind===`cidr`?Xt(e.data,r.version)||(n=this._getOrReturnCtx(e,n),x(n,{validation:`cidr`,code:b.invalid_string,message:r.message}),t.dirty()):r.kind===`base64`?Vt.test(e.data)||(n=this._getOrReturnCtx(e,n),x(n,{validation:`base64`,code:b.invalid_string,message:r.message}),t.dirty()):r.kind===`base64url`?Ht.test(e.data)||(n=this._getOrReturnCtx(e,n),x(n,{validation:`base64url`,code:b.invalid_string,message:r.message}),t.dirty()):v.assertNever(r);return{status:t.value,value:e.data}}_regex(e,t,n){return this.refinement(t=>e.test(t),{validation:t,code:b.invalid_string,...C.errToObj(n)})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}email(e){return this._addCheck({kind:`email`,...C.errToObj(e)})}url(e){return this._addCheck({kind:`url`,...C.errToObj(e)})}emoji(e){return this._addCheck({kind:`emoji`,...C.errToObj(e)})}uuid(e){return this._addCheck({kind:`uuid`,...C.errToObj(e)})}nanoid(e){return this._addCheck({kind:`nanoid`,...C.errToObj(e)})}cuid(e){return this._addCheck({kind:`cuid`,...C.errToObj(e)})}cuid2(e){return this._addCheck({kind:`cuid2`,...C.errToObj(e)})}ulid(e){return this._addCheck({kind:`ulid`,...C.errToObj(e)})}base64(e){return this._addCheck({kind:`base64`,...C.errToObj(e)})}base64url(e){return this._addCheck({kind:`base64url`,...C.errToObj(e)})}jwt(e){return this._addCheck({kind:`jwt`,...C.errToObj(e)})}ip(e){return this._addCheck({kind:`ip`,...C.errToObj(e)})}cidr(e){return this._addCheck({kind:`cidr`,...C.errToObj(e)})}datetime(e){return typeof e==`string`?this._addCheck({kind:`datetime`,precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:`datetime`,precision:e?.precision===void 0?null:e?.precision,offset:e?.offset??!1,local:e?.local??!1,...C.errToObj(e?.message)})}date(e){return this._addCheck({kind:`date`,message:e})}time(e){return typeof e==`string`?this._addCheck({kind:`time`,precision:null,message:e}):this._addCheck({kind:`time`,precision:e?.precision===void 0?null:e?.precision,...C.errToObj(e?.message)})}duration(e){return this._addCheck({kind:`duration`,...C.errToObj(e)})}regex(e,t){return this._addCheck({kind:`regex`,regex:e,...C.errToObj(t)})}includes(e,t){return this._addCheck({kind:`includes`,value:e,position:t?.position,...C.errToObj(t?.message)})}startsWith(e,t){return this._addCheck({kind:`startsWith`,value:e,...C.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:`endsWith`,value:e,...C.errToObj(t)})}min(e,t){return this._addCheck({kind:`min`,value:e,...C.errToObj(t)})}max(e,t){return this._addCheck({kind:`max`,value:e,...C.errToObj(t)})}length(e,t){return this._addCheck({kind:`length`,value:e,...C.errToObj(t)})}nonempty(e){return this.min(1,C.errToObj(e))}trim(){return new e({...this._def,checks:[...this._def.checks,{kind:`trim`}]})}toLowerCase(){return new e({...this._def,checks:[...this._def.checks,{kind:`toLowerCase`}]})}toUpperCase(){return new e({...this._def,checks:[...this._def.checks,{kind:`toUpperCase`}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind===`datetime`)}get isDate(){return!!this._def.checks.find(e=>e.kind===`date`)}get isTime(){return!!this._def.checks.find(e=>e.kind===`time`)}get isDuration(){return!!this._def.checks.find(e=>e.kind===`duration`)}get isEmail(){return!!this._def.checks.find(e=>e.kind===`email`)}get isURL(){return!!this._def.checks.find(e=>e.kind===`url`)}get isEmoji(){return!!this._def.checks.find(e=>e.kind===`emoji`)}get isUUID(){return!!this._def.checks.find(e=>e.kind===`uuid`)}get isNANOID(){return!!this._def.checks.find(e=>e.kind===`nanoid`)}get isCUID(){return!!this._def.checks.find(e=>e.kind===`cuid`)}get isCUID2(){return!!this._def.checks.find(e=>e.kind===`cuid2`)}get isULID(){return!!this._def.checks.find(e=>e.kind===`ulid`)}get isIP(){return!!this._def.checks.find(e=>e.kind===`ip`)}get isCIDR(){return!!this._def.checks.find(e=>e.kind===`cidr`)}get isBase64(){return!!this._def.checks.find(e=>e.kind===`base64`)}get isBase64url(){return!!this._def.checks.find(e=>e.kind===`base64url`)}get minLength(){let e=null;for(let t of this._def.checks)t.kind===`min`&&(e===null||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(let t of this._def.checks)t.kind===`max`&&(e===null||t.value<e)&&(e=t.value);return e}};Zt.create=e=>new Zt({checks:[],typeName:E.ZodString,coerce:e?.coerce??!1,...w(e)});function Qt(e,t){let n=(e.toString().split(`.`)[1]||``).length,r=(t.toString().split(`.`)[1]||``).length,i=n>r?n:r;return Number.parseInt(e.toFixed(i).replace(`.`,``))%Number.parseInt(t.toFixed(i).replace(`.`,``))/10**i}var $t=class e extends T{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==y.number){let t=this._getOrReturnCtx(e);return x(t,{code:b.invalid_type,expected:y.number,received:t.parsedType}),S}let t,n=new yt;for(let r of this._def.checks)r.kind===`int`?v.isInteger(e.data)||(t=this._getOrReturnCtx(e,t),x(t,{code:b.invalid_type,expected:`integer`,received:`float`,message:r.message}),n.dirty()):r.kind===`min`?(r.inclusive?e.data<r.value:e.data<=r.value)&&(t=this._getOrReturnCtx(e,t),x(t,{code:b.too_small,minimum:r.value,type:`number`,inclusive:r.inclusive,exact:!1,message:r.message}),n.dirty()):r.kind===`max`?(r.inclusive?e.data>r.value:e.data>=r.value)&&(t=this._getOrReturnCtx(e,t),x(t,{code:b.too_big,maximum:r.value,type:`number`,inclusive:r.inclusive,exact:!1,message:r.message}),n.dirty()):r.kind===`multipleOf`?Qt(e.data,r.value)!==0&&(t=this._getOrReturnCtx(e,t),x(t,{code:b.not_multiple_of,multipleOf:r.value,message:r.message}),n.dirty()):r.kind===`finite`?Number.isFinite(e.data)||(t=this._getOrReturnCtx(e,t),x(t,{code:b.not_finite,message:r.message}),n.dirty()):v.assertNever(r);return{status:n.value,value:e.data}}gte(e,t){return this.setLimit(`min`,e,!0,C.toString(t))}gt(e,t){return this.setLimit(`min`,e,!1,C.toString(t))}lte(e,t){return this.setLimit(`max`,e,!0,C.toString(t))}lt(e,t){return this.setLimit(`max`,e,!1,C.toString(t))}setLimit(t,n,r,i){return new e({...this._def,checks:[...this._def.checks,{kind:t,value:n,inclusive:r,message:C.toString(i)}]})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}int(e){return this._addCheck({kind:`int`,message:C.toString(e)})}positive(e){return this._addCheck({kind:`min`,value:0,inclusive:!1,message:C.toString(e)})}negative(e){return this._addCheck({kind:`max`,value:0,inclusive:!1,message:C.toString(e)})}nonpositive(e){return this._addCheck({kind:`max`,value:0,inclusive:!0,message:C.toString(e)})}nonnegative(e){return this._addCheck({kind:`min`,value:0,inclusive:!0,message:C.toString(e)})}multipleOf(e,t){return this._addCheck({kind:`multipleOf`,value:e,message:C.toString(t)})}finite(e){return this._addCheck({kind:`finite`,message:C.toString(e)})}safe(e){return this._addCheck({kind:`min`,inclusive:!0,value:-(2**53-1),message:C.toString(e)})._addCheck({kind:`max`,inclusive:!0,value:2**53-1,message:C.toString(e)})}get minValue(){let e=null;for(let t of this._def.checks)t.kind===`min`&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(let t of this._def.checks)t.kind===`max`&&(e===null||t.value<e)&&(e=t.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind===`int`||e.kind===`multipleOf`&&v.isInteger(e.value))}get isFinite(){let e=null,t=null;for(let n of this._def.checks)if(n.kind===`finite`||n.kind===`int`||n.kind===`multipleOf`)return!0;else n.kind===`min`?(t===null||n.value>t)&&(t=n.value):n.kind===`max`&&(e===null||n.value<e)&&(e=n.value);return Number.isFinite(t)&&Number.isFinite(e)}};$t.create=e=>new $t({checks:[],typeName:E.ZodNumber,coerce:e?.coerce||!1,...w(e)});var en=class e extends T{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce)try{e.data=BigInt(e.data)}catch{return this._getInvalidInput(e)}if(this._getType(e)!==y.bigint)return this._getInvalidInput(e);let t,n=new yt;for(let r of this._def.checks)r.kind===`min`?(r.inclusive?e.data<r.value:e.data<=r.value)&&(t=this._getOrReturnCtx(e,t),x(t,{code:b.too_small,type:`bigint`,minimum:r.value,inclusive:r.inclusive,message:r.message}),n.dirty()):r.kind===`max`?(r.inclusive?e.data>r.value:e.data>=r.value)&&(t=this._getOrReturnCtx(e,t),x(t,{code:b.too_big,type:`bigint`,maximum:r.value,inclusive:r.inclusive,message:r.message}),n.dirty()):r.kind===`multipleOf`?e.data%r.value!==BigInt(0)&&(t=this._getOrReturnCtx(e,t),x(t,{code:b.not_multiple_of,multipleOf:r.value,message:r.message}),n.dirty()):v.assertNever(r);return{status:n.value,value:e.data}}_getInvalidInput(e){let t=this._getOrReturnCtx(e);return x(t,{code:b.invalid_type,expected:y.bigint,received:t.parsedType}),S}gte(e,t){return this.setLimit(`min`,e,!0,C.toString(t))}gt(e,t){return this.setLimit(`min`,e,!1,C.toString(t))}lte(e,t){return this.setLimit(`max`,e,!0,C.toString(t))}lt(e,t){return this.setLimit(`max`,e,!1,C.toString(t))}setLimit(t,n,r,i){return new e({...this._def,checks:[...this._def.checks,{kind:t,value:n,inclusive:r,message:C.toString(i)}]})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}positive(e){return this._addCheck({kind:`min`,value:BigInt(0),inclusive:!1,message:C.toString(e)})}negative(e){return this._addCheck({kind:`max`,value:BigInt(0),inclusive:!1,message:C.toString(e)})}nonpositive(e){return this._addCheck({kind:`max`,value:BigInt(0),inclusive:!0,message:C.toString(e)})}nonnegative(e){return this._addCheck({kind:`min`,value:BigInt(0),inclusive:!0,message:C.toString(e)})}multipleOf(e,t){return this._addCheck({kind:`multipleOf`,value:e,message:C.toString(t)})}get minValue(){let e=null;for(let t of this._def.checks)t.kind===`min`&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(let t of this._def.checks)t.kind===`max`&&(e===null||t.value<e)&&(e=t.value);return e}};en.create=e=>new en({checks:[],typeName:E.ZodBigInt,coerce:e?.coerce??!1,...w(e)});var tn=class extends T{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==y.boolean){let t=this._getOrReturnCtx(e);return x(t,{code:b.invalid_type,expected:y.boolean,received:t.parsedType}),S}return xt(e.data)}};tn.create=e=>new tn({typeName:E.ZodBoolean,coerce:e?.coerce||!1,...w(e)});var nn=class e extends T{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==y.date){let t=this._getOrReturnCtx(e);return x(t,{code:b.invalid_type,expected:y.date,received:t.parsedType}),S}if(Number.isNaN(e.data.getTime()))return x(this._getOrReturnCtx(e),{code:b.invalid_date}),S;let t=new yt,n;for(let r of this._def.checks)r.kind===`min`?e.data.getTime()<r.value&&(n=this._getOrReturnCtx(e,n),x(n,{code:b.too_small,message:r.message,inclusive:!0,exact:!1,minimum:r.value,type:`date`}),t.dirty()):r.kind===`max`?e.data.getTime()>r.value&&(n=this._getOrReturnCtx(e,n),x(n,{code:b.too_big,message:r.message,inclusive:!0,exact:!1,maximum:r.value,type:`date`}),t.dirty()):v.assertNever(r);return{status:t.value,value:new Date(e.data.getTime())}}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}min(e,t){return this._addCheck({kind:`min`,value:e.getTime(),message:C.toString(t)})}max(e,t){return this._addCheck({kind:`max`,value:e.getTime(),message:C.toString(t)})}get minDate(){let e=null;for(let t of this._def.checks)t.kind===`min`&&(e===null||t.value>e)&&(e=t.value);return e==null?null:new Date(e)}get maxDate(){let e=null;for(let t of this._def.checks)t.kind===`max`&&(e===null||t.value<e)&&(e=t.value);return e==null?null:new Date(e)}};nn.create=e=>new nn({checks:[],coerce:e?.coerce||!1,typeName:E.ZodDate,...w(e)});var rn=class extends T{_parse(e){if(this._getType(e)!==y.symbol){let t=this._getOrReturnCtx(e);return x(t,{code:b.invalid_type,expected:y.symbol,received:t.parsedType}),S}return xt(e.data)}};rn.create=e=>new rn({typeName:E.ZodSymbol,...w(e)});var an=class extends T{_parse(e){if(this._getType(e)!==y.undefined){let t=this._getOrReturnCtx(e);return x(t,{code:b.invalid_type,expected:y.undefined,received:t.parsedType}),S}return xt(e.data)}};an.create=e=>new an({typeName:E.ZodUndefined,...w(e)});var on=class extends T{_parse(e){if(this._getType(e)!==y.null){let t=this._getOrReturnCtx(e);return x(t,{code:b.invalid_type,expected:y.null,received:t.parsedType}),S}return xt(e.data)}};on.create=e=>new on({typeName:E.ZodNull,...w(e)});var sn=class extends T{constructor(){super(...arguments),this._any=!0}_parse(e){return xt(e.data)}};sn.create=e=>new sn({typeName:E.ZodAny,...w(e)});var cn=class extends T{constructor(){super(...arguments),this._unknown=!0}_parse(e){return xt(e.data)}};cn.create=e=>new cn({typeName:E.ZodUnknown,...w(e)});var ln=class extends T{_parse(e){let t=this._getOrReturnCtx(e);return x(t,{code:b.invalid_type,expected:y.never,received:t.parsedType}),S}};ln.create=e=>new ln({typeName:E.ZodNever,...w(e)});var un=class extends T{_parse(e){if(this._getType(e)!==y.undefined){let t=this._getOrReturnCtx(e);return x(t,{code:b.invalid_type,expected:y.void,received:t.parsedType}),S}return xt(e.data)}};un.create=e=>new un({typeName:E.ZodVoid,...w(e)});var dn=class e extends T{_parse(e){let{ctx:t,status:n}=this._processInputParams(e),r=this._def;if(t.parsedType!==y.array)return x(t,{code:b.invalid_type,expected:y.array,received:t.parsedType}),S;if(r.exactLength!==null){let e=t.data.length>r.exactLength.value,i=t.data.length<r.exactLength.value;(e||i)&&(x(t,{code:e?b.too_big:b.too_small,minimum:i?r.exactLength.value:void 0,maximum:e?r.exactLength.value:void 0,type:`array`,inclusive:!0,exact:!0,message:r.exactLength.message}),n.dirty())}if(r.minLength!==null&&t.data.length<r.minLength.value&&(x(t,{code:b.too_small,minimum:r.minLength.value,type:`array`,inclusive:!0,exact:!1,message:r.minLength.message}),n.dirty()),r.maxLength!==null&&t.data.length>r.maxLength.value&&(x(t,{code:b.too_big,maximum:r.maxLength.value,type:`array`,inclusive:!0,exact:!1,message:r.maxLength.message}),n.dirty()),t.common.async)return Promise.all([...t.data].map((e,n)=>r.type._parseAsync(new Et(t,e,t.path,n)))).then(e=>yt.mergeArray(n,e));let i=[...t.data].map((e,n)=>r.type._parseSync(new Et(t,e,t.path,n)));return yt.mergeArray(n,i)}get element(){return this._def.type}min(t,n){return new e({...this._def,minLength:{value:t,message:C.toString(n)}})}max(t,n){return new e({...this._def,maxLength:{value:t,message:C.toString(n)}})}length(t,n){return new e({...this._def,exactLength:{value:t,message:C.toString(n)}})}nonempty(e){return this.min(1,e)}};dn.create=(e,t)=>new dn({type:e,minLength:null,maxLength:null,exactLength:null,typeName:E.ZodArray,...w(t)});function fn(e){if(e instanceof pn){let t={};for(let n in e.shape){let r=e.shape[n];t[n]=jn.create(fn(r))}return new pn({...e._def,shape:()=>t})}else if(e instanceof dn)return new dn({...e._def,type:fn(e.element)});else if(e instanceof jn)return jn.create(fn(e.unwrap()));else if(e instanceof Mn)return Mn.create(fn(e.unwrap()));else if(e instanceof yn)return yn.create(e.items.map(e=>fn(e)));else return e}var pn=class e extends T{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;let e=this._def.shape();return this._cached={shape:e,keys:v.objectKeys(e)},this._cached}_parse(e){if(this._getType(e)!==y.object){let t=this._getOrReturnCtx(e);return x(t,{code:b.invalid_type,expected:y.object,received:t.parsedType}),S}let{status:t,ctx:n}=this._processInputParams(e),{shape:r,keys:i}=this._getCached(),a=[];if(!(this._def.catchall instanceof ln&&this._def.unknownKeys===`strip`))for(let e in n.data)i.includes(e)||a.push(e);let o=[];for(let e of i){let t=r[e],i=n.data[e];o.push({key:{status:`valid`,value:e},value:t._parse(new Et(n,i,n.path,e)),alwaysSet:e in n.data})}if(this._def.catchall instanceof ln){let e=this._def.unknownKeys;if(e===`passthrough`)for(let e of a)o.push({key:{status:`valid`,value:e},value:{status:`valid`,value:n.data[e]}});else if(e===`strict`)a.length>0&&(x(n,{code:b.unrecognized_keys,keys:a}),t.dirty());else if(e!==`strip`)throw Error(`Internal ZodObject error: invalid unknownKeys value.`)}else{let e=this._def.catchall;for(let t of a){let r=n.data[t];o.push({key:{status:`valid`,value:t},value:e._parse(new Et(n,r,n.path,t)),alwaysSet:t in n.data})}}return n.common.async?Promise.resolve().then(async()=>{let e=[];for(let t of o){let n=await t.key,r=await t.value;e.push({key:n,value:r,alwaysSet:t.alwaysSet})}return e}).then(e=>yt.mergeObjectSync(t,e)):yt.mergeObjectSync(t,o)}get shape(){return this._def.shape()}strict(t){return C.errToObj,new e({...this._def,unknownKeys:`strict`,...t===void 0?{}:{errorMap:(e,n)=>{let r=this._def.errorMap?.(e,n).message??n.defaultError;return e.code===`unrecognized_keys`?{message:C.errToObj(t).message??r}:{message:r}}}})}strip(){return new e({...this._def,unknownKeys:`strip`})}passthrough(){return new e({...this._def,unknownKeys:`passthrough`})}extend(t){return new e({...this._def,shape:()=>({...this._def.shape(),...t})})}merge(t){return new e({unknownKeys:t._def.unknownKeys,catchall:t._def.catchall,shape:()=>({...this._def.shape(),...t._def.shape()}),typeName:E.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(t){return new e({...this._def,catchall:t})}pick(t){let n={};for(let e of v.objectKeys(t))t[e]&&this.shape[e]&&(n[e]=this.shape[e]);return new e({...this._def,shape:()=>n})}omit(t){let n={};for(let e of v.objectKeys(this.shape))t[e]||(n[e]=this.shape[e]);return new e({...this._def,shape:()=>n})}deepPartial(){return fn(this)}partial(t){let n={};for(let e of v.objectKeys(this.shape)){let r=this.shape[e];t&&!t[e]?n[e]=r:n[e]=r.optional()}return new e({...this._def,shape:()=>n})}required(t){let n={};for(let e of v.objectKeys(this.shape))if(t&&!t[e])n[e]=this.shape[e];else{let t=this.shape[e];for(;t instanceof jn;)t=t._def.innerType;n[e]=t}return new e({...this._def,shape:()=>n})}keyof(){return En(v.objectKeys(this.shape))}};pn.create=(e,t)=>new pn({shape:()=>e,unknownKeys:`strip`,catchall:ln.create(),typeName:E.ZodObject,...w(t)}),pn.strictCreate=(e,t)=>new pn({shape:()=>e,unknownKeys:`strict`,catchall:ln.create(),typeName:E.ZodObject,...w(t)}),pn.lazycreate=(e,t)=>new pn({shape:e,unknownKeys:`strip`,catchall:ln.create(),typeName:E.ZodObject,...w(t)});var mn=class extends T{_parse(e){let{ctx:t}=this._processInputParams(e),n=this._def.options;function r(e){for(let t of e)if(t.result.status===`valid`)return t.result;for(let n of e)if(n.result.status===`dirty`)return t.common.issues.push(...n.ctx.common.issues),n.result;let n=e.map(e=>new mt(e.ctx.common.issues));return x(t,{code:b.invalid_union,unionErrors:n}),S}if(t.common.async)return Promise.all(n.map(async e=>{let n={...t,common:{...t.common,issues:[]},parent:null};return{result:await e._parseAsync({data:t.data,path:t.path,parent:n}),ctx:n}})).then(r);{let e,r=[];for(let i of n){let n={...t,common:{...t.common,issues:[]},parent:null},a=i._parseSync({data:t.data,path:t.path,parent:n});if(a.status===`valid`)return a;a.status===`dirty`&&!e&&(e={result:a,ctx:n}),n.common.issues.length&&r.push(n.common.issues)}if(e)return t.common.issues.push(...e.ctx.common.issues),e.result;let i=r.map(e=>new mt(e));return x(t,{code:b.invalid_union,unionErrors:i}),S}}get options(){return this._def.options}};mn.create=(e,t)=>new mn({options:e,typeName:E.ZodUnion,...w(t)});let hn=e=>e instanceof wn?hn(e.schema):e instanceof An?hn(e.innerType()):e instanceof Tn?[e.value]:e instanceof Dn?e.options:e instanceof On?v.objectValues(e.enum):e instanceof Nn?hn(e._def.innerType):e instanceof an?[void 0]:e instanceof on?[null]:e instanceof jn?[void 0,...hn(e.unwrap())]:e instanceof Mn?[null,...hn(e.unwrap())]:e instanceof In||e instanceof Rn?hn(e.unwrap()):e instanceof Pn?hn(e._def.innerType):[];var gn=class e extends T{_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==y.object)return x(t,{code:b.invalid_type,expected:y.object,received:t.parsedType}),S;let n=this.discriminator,r=t.data[n],i=this.optionsMap.get(r);return i?t.common.async?i._parseAsync({data:t.data,path:t.path,parent:t}):i._parseSync({data:t.data,path:t.path,parent:t}):(x(t,{code:b.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),S)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(t,n,r){let i=new Map;for(let e of n){let n=hn(e.shape[t]);if(!n.length)throw Error(`A discriminator value for key \`${t}\` could not be extracted from all schema options`);for(let r of n){if(i.has(r))throw Error(`Discriminator property ${String(t)} has duplicate value ${String(r)}`);i.set(r,e)}}return new e({typeName:E.ZodDiscriminatedUnion,discriminator:t,options:n,optionsMap:i,...w(r)})}};function _n(e,t){let n=pt(e),r=pt(t);if(e===t)return{valid:!0,data:e};if(n===y.object&&r===y.object){let n=v.objectKeys(t),r=v.objectKeys(e).filter(e=>n.indexOf(e)!==-1),i={...e,...t};for(let n of r){let r=_n(e[n],t[n]);if(!r.valid)return{valid:!1};i[n]=r.data}return{valid:!0,data:i}}else if(n===y.array&&r===y.array){if(e.length!==t.length)return{valid:!1};let n=[];for(let r=0;r<e.length;r++){let i=e[r],a=t[r],o=_n(i,a);if(!o.valid)return{valid:!1};n.push(o.data)}return{valid:!0,data:n}}else if(n===y.date&&r===y.date&&+e==+t)return{valid:!0,data:e};else return{valid:!1}}var vn=class extends T{_parse(e){let{status:t,ctx:n}=this._processInputParams(e),r=(e,r)=>{if(St(e)||St(r))return S;let i=_n(e.value,r.value);return i.valid?((Ct(e)||Ct(r))&&t.dirty(),{status:t.value,value:i.data}):(x(n,{code:b.invalid_intersection_types}),S)};return n.common.async?Promise.all([this._def.left._parseAsync({data:n.data,path:n.path,parent:n}),this._def.right._parseAsync({data:n.data,path:n.path,parent:n})]).then(([e,t])=>r(e,t)):r(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}};vn.create=(e,t,n)=>new vn({left:e,right:t,typeName:E.ZodIntersection,...w(n)});var yn=class e extends T{_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==y.array)return x(n,{code:b.invalid_type,expected:y.array,received:n.parsedType}),S;if(n.data.length<this._def.items.length)return x(n,{code:b.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:`array`}),S;!this._def.rest&&n.data.length>this._def.items.length&&(x(n,{code:b.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:`array`}),t.dirty());let r=[...n.data].map((e,t)=>{let r=this._def.items[t]||this._def.rest;return r?r._parse(new Et(n,e,n.path,t)):null}).filter(e=>!!e);return n.common.async?Promise.all(r).then(e=>yt.mergeArray(t,e)):yt.mergeArray(t,r)}get items(){return this._def.items}rest(t){return new e({...this._def,rest:t})}};yn.create=(e,t)=>{if(!Array.isArray(e))throw Error(`You must pass an array of schemas to z.tuple([ ... ])`);return new yn({items:e,typeName:E.ZodTuple,rest:null,...w(t)})};var bn=class e extends T{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==y.object)return x(n,{code:b.invalid_type,expected:y.object,received:n.parsedType}),S;let r=[],i=this._def.keyType,a=this._def.valueType;for(let e in n.data)r.push({key:i._parse(new Et(n,e,n.path,e)),value:a._parse(new Et(n,n.data[e],n.path,e)),alwaysSet:e in n.data});return n.common.async?yt.mergeObjectAsync(t,r):yt.mergeObjectSync(t,r)}get element(){return this._def.valueType}static create(t,n,r){return n instanceof T?new e({keyType:t,valueType:n,typeName:E.ZodRecord,...w(r)}):new e({keyType:Zt.create(),valueType:t,typeName:E.ZodRecord,...w(n)})}},xn=class extends T{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==y.map)return x(n,{code:b.invalid_type,expected:y.map,received:n.parsedType}),S;let r=this._def.keyType,i=this._def.valueType,a=[...n.data.entries()].map(([e,t],a)=>({key:r._parse(new Et(n,e,n.path,[a,`key`])),value:i._parse(new Et(n,t,n.path,[a,`value`]))}));if(n.common.async){let e=new Map;return Promise.resolve().then(async()=>{for(let n of a){let r=await n.key,i=await n.value;if(r.status===`aborted`||i.status===`aborted`)return S;(r.status===`dirty`||i.status===`dirty`)&&t.dirty(),e.set(r.value,i.value)}return{status:t.value,value:e}})}else{let e=new Map;for(let n of a){let r=n.key,i=n.value;if(r.status===`aborted`||i.status===`aborted`)return S;(r.status===`dirty`||i.status===`dirty`)&&t.dirty(),e.set(r.value,i.value)}return{status:t.value,value:e}}}};xn.create=(e,t,n)=>new xn({valueType:t,keyType:e,typeName:E.ZodMap,...w(n)});var Sn=class e extends T{_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==y.set)return x(n,{code:b.invalid_type,expected:y.set,received:n.parsedType}),S;let r=this._def;r.minSize!==null&&n.data.size<r.minSize.value&&(x(n,{code:b.too_small,minimum:r.minSize.value,type:`set`,inclusive:!0,exact:!1,message:r.minSize.message}),t.dirty()),r.maxSize!==null&&n.data.size>r.maxSize.value&&(x(n,{code:b.too_big,maximum:r.maxSize.value,type:`set`,inclusive:!0,exact:!1,message:r.maxSize.message}),t.dirty());let i=this._def.valueType;function a(e){let n=new Set;for(let r of e){if(r.status===`aborted`)return S;r.status===`dirty`&&t.dirty(),n.add(r.value)}return{status:t.value,value:n}}let o=[...n.data.values()].map((e,t)=>i._parse(new Et(n,e,n.path,t)));return n.common.async?Promise.all(o).then(e=>a(e)):a(o)}min(t,n){return new e({...this._def,minSize:{value:t,message:C.toString(n)}})}max(t,n){return new e({...this._def,maxSize:{value:t,message:C.toString(n)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}};Sn.create=(e,t)=>new Sn({valueType:e,minSize:null,maxSize:null,typeName:E.ZodSet,...w(t)});var Cn=class e extends T{constructor(){super(...arguments),this.validate=this.implement}_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==y.function)return x(t,{code:b.invalid_type,expected:y.function,received:t.parsedType}),S;function n(e,n){return vt({data:e,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,_t(),ht].filter(e=>!!e),issueData:{code:b.invalid_arguments,argumentsError:n}})}function r(e,n){return vt({data:e,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,_t(),ht].filter(e=>!!e),issueData:{code:b.invalid_return_type,returnTypeError:n}})}let i={errorMap:t.common.contextualErrorMap},a=t.data;if(this._def.returns instanceof kn){let e=this;return xt(async function(...t){let o=new mt([]),s=await e._def.args.parseAsync(t,i).catch(e=>{throw o.addIssue(n(t,e)),o}),c=await Reflect.apply(a,this,s);return await e._def.returns._def.type.parseAsync(c,i).catch(e=>{throw o.addIssue(r(c,e)),o})})}else{let e=this;return xt(function(...t){let o=e._def.args.safeParse(t,i);if(!o.success)throw new mt([n(t,o.error)]);let s=Reflect.apply(a,this,o.data),c=e._def.returns.safeParse(s,i);if(!c.success)throw new mt([r(s,c.error)]);return c.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...t){return new e({...this._def,args:yn.create(t).rest(cn.create())})}returns(t){return new e({...this._def,returns:t})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(t,n,r){return new e({args:t||yn.create([]).rest(cn.create()),returns:n||cn.create(),typeName:E.ZodFunction,...w(r)})}},wn=class extends T{get schema(){return this._def.getter()}_parse(e){let{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}};wn.create=(e,t)=>new wn({getter:e,typeName:E.ZodLazy,...w(t)});var Tn=class extends T{_parse(e){if(e.data!==this._def.value){let t=this._getOrReturnCtx(e);return x(t,{received:t.data,code:b.invalid_literal,expected:this._def.value}),S}return{status:`valid`,value:e.data}}get value(){return this._def.value}};Tn.create=(e,t)=>new Tn({value:e,typeName:E.ZodLiteral,...w(t)});function En(e,t){return new Dn({values:e,typeName:E.ZodEnum,...w(t)})}var Dn=class e extends T{_parse(e){if(typeof e.data!=`string`){let t=this._getOrReturnCtx(e),n=this._def.values;return x(t,{expected:v.joinValues(n),received:t.parsedType,code:b.invalid_type}),S}if(this._cache||=new Set(this._def.values),!this._cache.has(e.data)){let t=this._getOrReturnCtx(e),n=this._def.values;return x(t,{received:t.data,code:b.invalid_enum_value,options:n}),S}return xt(e.data)}get options(){return this._def.values}get enum(){let e={};for(let t of this._def.values)e[t]=t;return e}get Values(){let e={};for(let t of this._def.values)e[t]=t;return e}get Enum(){let e={};for(let t of this._def.values)e[t]=t;return e}extract(t,n=this._def){return e.create(t,{...this._def,...n})}exclude(t,n=this._def){return e.create(this.options.filter(e=>!t.includes(e)),{...this._def,...n})}};Dn.create=En;var On=class extends T{_parse(e){let t=v.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==y.string&&n.parsedType!==y.number){let e=v.objectValues(t);return x(n,{expected:v.joinValues(e),received:n.parsedType,code:b.invalid_type}),S}if(this._cache||=new Set(v.getValidEnumValues(this._def.values)),!this._cache.has(e.data)){let e=v.objectValues(t);return x(n,{received:n.data,code:b.invalid_enum_value,options:e}),S}return xt(e.data)}get enum(){return this._def.values}};On.create=(e,t)=>new On({values:e,typeName:E.ZodNativeEnum,...w(t)});var kn=class extends T{unwrap(){return this._def.type}_parse(e){let{ctx:t}=this._processInputParams(e);return t.parsedType!==y.promise&&t.common.async===!1?(x(t,{code:b.invalid_type,expected:y.promise,received:t.parsedType}),S):xt((t.parsedType===y.promise?t.data:Promise.resolve(t.data)).then(e=>this._def.type.parseAsync(e,{path:t.path,errorMap:t.common.contextualErrorMap})))}};kn.create=(e,t)=>new kn({type:e,typeName:E.ZodPromise,...w(t)});var An=class extends T{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===E.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){let{status:t,ctx:n}=this._processInputParams(e),r=this._def.effect||null,i={addIssue:e=>{x(n,e),e.fatal?t.abort():t.dirty()},get path(){return n.path}};if(i.addIssue=i.addIssue.bind(i),r.type===`preprocess`){let e=r.transform(n.data,i);if(n.common.async)return Promise.resolve(e).then(async e=>{if(t.value===`aborted`)return S;let r=await this._def.schema._parseAsync({data:e,path:n.path,parent:n});return r.status===`aborted`?S:r.status===`dirty`||t.value===`dirty`?bt(r.value):r});{if(t.value===`aborted`)return S;let r=this._def.schema._parseSync({data:e,path:n.path,parent:n});return r.status===`aborted`?S:r.status===`dirty`||t.value===`dirty`?bt(r.value):r}}if(r.type===`refinement`){let e=e=>{let t=r.refinement(e,i);if(n.common.async)return Promise.resolve(t);if(t instanceof Promise)throw Error(`Async refinement encountered during synchronous parse operation. Use .parseAsync instead.`);return e};if(n.common.async===!1){let r=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return r.status===`aborted`?S:(r.status===`dirty`&&t.dirty(),e(r.value),{status:t.value,value:r.value})}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(n=>n.status===`aborted`?S:(n.status===`dirty`&&t.dirty(),e(n.value).then(()=>({status:t.value,value:n.value}))))}if(r.type===`transform`)if(n.common.async===!1){let e=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!wt(e))return S;let a=r.transform(e.value,i);if(a instanceof Promise)throw Error(`Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.`);return{status:t.value,value:a}}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(e=>wt(e)?Promise.resolve(r.transform(e.value,i)).then(e=>({status:t.value,value:e})):S);v.assertNever(r)}};An.create=(e,t,n)=>new An({schema:e,typeName:E.ZodEffects,effect:t,...w(n)}),An.createWithPreprocess=(e,t,n)=>new An({schema:t,effect:{type:`preprocess`,transform:e},typeName:E.ZodEffects,...w(n)});var jn=class extends T{_parse(e){return this._getType(e)===y.undefined?xt(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};jn.create=(e,t)=>new jn({innerType:e,typeName:E.ZodOptional,...w(t)});var Mn=class extends T{_parse(e){return this._getType(e)===y.null?xt(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};Mn.create=(e,t)=>new Mn({innerType:e,typeName:E.ZodNullable,...w(t)});var Nn=class extends T{_parse(e){let{ctx:t}=this._processInputParams(e),n=t.data;return t.parsedType===y.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:t.path,parent:t})}removeDefault(){return this._def.innerType}};Nn.create=(e,t)=>new Nn({innerType:e,typeName:E.ZodDefault,defaultValue:typeof t.default==`function`?t.default:()=>t.default,...w(t)});var Pn=class extends T{_parse(e){let{ctx:t}=this._processInputParams(e),n={...t,common:{...t.common,issues:[]}},r=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return Tt(r)?r.then(e=>({status:`valid`,value:e.status===`valid`?e.value:this._def.catchValue({get error(){return new mt(n.common.issues)},input:n.data})})):{status:`valid`,value:r.status===`valid`?r.value:this._def.catchValue({get error(){return new mt(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}};Pn.create=(e,t)=>new Pn({innerType:e,typeName:E.ZodCatch,catchValue:typeof t.catch==`function`?t.catch:()=>t.catch,...w(t)});var Fn=class extends T{_parse(e){if(this._getType(e)!==y.nan){let t=this._getOrReturnCtx(e);return x(t,{code:b.invalid_type,expected:y.nan,received:t.parsedType}),S}return{status:`valid`,value:e.data}}};Fn.create=e=>new Fn({typeName:E.ZodNaN,...w(e)});var In=class extends T{_parse(e){let{ctx:t}=this._processInputParams(e),n=t.data;return this._def.type._parse({data:n,path:t.path,parent:t})}unwrap(){return this._def.type}},Ln=class e extends T{_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.common.async)return(async()=>{let e=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return e.status===`aborted`?S:e.status===`dirty`?(t.dirty(),bt(e.value)):this._def.out._parseAsync({data:e.value,path:n.path,parent:n})})();{let e=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return e.status===`aborted`?S:e.status===`dirty`?(t.dirty(),{status:`dirty`,value:e.value}):this._def.out._parseSync({data:e.value,path:n.path,parent:n})}}static create(t,n){return new e({in:t,out:n,typeName:E.ZodPipeline})}},Rn=class extends T{_parse(e){let t=this._def.innerType._parse(e),n=e=>(wt(e)&&(e.value=Object.freeze(e.value)),e);return Tt(t)?t.then(e=>n(e)):n(t)}unwrap(){return this._def.innerType}};Rn.create=(e,t)=>new Rn({innerType:e,typeName:E.ZodReadonly,...w(t)}),pn.lazycreate;var E;(function(e){e.ZodString=`ZodString`,e.ZodNumber=`ZodNumber`,e.ZodNaN=`ZodNaN`,e.ZodBigInt=`ZodBigInt`,e.ZodBoolean=`ZodBoolean`,e.ZodDate=`ZodDate`,e.ZodSymbol=`ZodSymbol`,e.ZodUndefined=`ZodUndefined`,e.ZodNull=`ZodNull`,e.ZodAny=`ZodAny`,e.ZodUnknown=`ZodUnknown`,e.ZodNever=`ZodNever`,e.ZodVoid=`ZodVoid`,e.ZodArray=`ZodArray`,e.ZodObject=`ZodObject`,e.ZodUnion=`ZodUnion`,e.ZodDiscriminatedUnion=`ZodDiscriminatedUnion`,e.ZodIntersection=`ZodIntersection`,e.ZodTuple=`ZodTuple`,e.ZodRecord=`ZodRecord`,e.ZodMap=`ZodMap`,e.ZodSet=`ZodSet`,e.ZodFunction=`ZodFunction`,e.ZodLazy=`ZodLazy`,e.ZodLiteral=`ZodLiteral`,e.ZodEnum=`ZodEnum`,e.ZodEffects=`ZodEffects`,e.ZodNativeEnum=`ZodNativeEnum`,e.ZodOptional=`ZodOptional`,e.ZodNullable=`ZodNullable`,e.ZodDefault=`ZodDefault`,e.ZodCatch=`ZodCatch`,e.ZodPromise=`ZodPromise`,e.ZodBranded=`ZodBranded`,e.ZodPipeline=`ZodPipeline`,e.ZodReadonly=`ZodReadonly`})(E||={}),Zt.create,$t.create,Fn.create,en.create,tn.create,nn.create,rn.create,an.create,on.create,sn.create,cn.create,ln.create,un.create,dn.create;let zn=pn.create;pn.strictCreate,mn.create,gn.create,vn.create,yn.create,bn.create,xn.create,Sn.create,Cn.create,wn.create,Tn.create,Dn.create,On.create,kn.create,An.create,jn.create,Mn.create,An.createWithPreprocess,Ln.create,Object.freeze({status:`aborted`});function D(e,t,n){function r(n,r){if(n._zod||Object.defineProperty(n,`_zod`,{value:{def:r,constr:o,traits:new Set},enumerable:!1}),n._zod.traits.has(e))return;n._zod.traits.add(e),t(n,r);let i=o.prototype,a=Object.keys(i);for(let e=0;e<a.length;e++){let t=a[e];t in n||(n[t]=i[t].bind(n))}}let i=n?.Parent??Object;class a extends i{}Object.defineProperty(a,`name`,{value:e});function o(e){var t;let i=n?.Parent?new a:this;r(i,e),(t=i._zod).deferred??(t.deferred=[]);for(let e of i._zod.deferred)e();return i}return Object.defineProperty(o,`init`,{value:r}),Object.defineProperty(o,Symbol.hasInstance,{value:t=>n?.Parent&&t instanceof n.Parent?!0:t?._zod?.traits?.has(e)}),Object.defineProperty(o,`name`,{value:e}),o}var Bn=class extends Error{constructor(){super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`)}},Vn=class extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name=`ZodEncodeError`}};let Hn={};function Un(e){return e&&Object.assign(Hn,e),Hn}function Wn(e){let t=Object.values(e).filter(e=>typeof e==`number`);return Object.entries(e).filter(([e,n])=>t.indexOf(+e)===-1).map(([e,t])=>t)}function Gn(e,t){return typeof t==`bigint`?t.toString():t}function Kn(e){return{get value(){{let t=e();return Object.defineProperty(this,`value`,{value:t}),t}throw Error(`cached value already set`)}}}function qn(e){return e==null}function Jn(e){let t=e.startsWith(`^`)?1:0,n=e.endsWith(`$`)?e.length-1:e.length;return e.slice(t,n)}function Yn(e,t){let n=(e.toString().split(`.`)[1]||``).length,r=t.toString(),i=(r.split(`.`)[1]||``).length;if(i===0&&/\d?e-\d?/.test(r)){let e=r.match(/\d?e-(\d?)/);e?.[1]&&(i=Number.parseInt(e[1]))}let a=n>i?n:i;return Number.parseInt(e.toFixed(a).replace(`.`,``))%Number.parseInt(t.toFixed(a).replace(`.`,``))/10**a}let Xn=Symbol(`evaluating`);function O(e,t,n){let r;Object.defineProperty(e,t,{get(){if(r!==Xn)return r===void 0&&(r=Xn,r=n()),r},set(n){Object.defineProperty(e,t,{value:n})},configurable:!0})}function Zn(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function Qn(...e){let t={};for(let n of e){let e=Object.getOwnPropertyDescriptors(n);Object.assign(t,e)}return Object.defineProperties({},t)}function $n(e){return JSON.stringify(e)}function er(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,``).replace(/[\s_-]+/g,`-`).replace(/^-+|-+$/g,``)}let tr=`captureStackTrace`in Error?Error.captureStackTrace:(...e)=>{};function nr(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}let rr=Kn(()=>{if(typeof navigator<`u`&&navigator?.userAgent?.includes(`Cloudflare`))return!1;try{return Function(``),!0}catch{return!1}});function ir(e){if(nr(e)===!1)return!1;let t=e.constructor;if(t===void 0||typeof t!=`function`)return!0;let n=t.prototype;return!(nr(n)===!1||Object.prototype.hasOwnProperty.call(n,`isPrototypeOf`)===!1)}function ar(e){return ir(e)?{...e}:Array.isArray(e)?[...e]:e}let or=new Set([`string`,`number`,`symbol`]);function sr(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function cr(e,t,n){let r=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(r._zod.parent=e),r}function k(e){let t=e;if(!t)return{};if(typeof t==`string`)return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error==`string`?{...t,error:()=>t.error}:t}function lr(e){return Object.keys(e).filter(t=>e[t]._zod.optin===`optional`&&e[t]._zod.optout===`optional`)}let ur={safeint:[-(2**53-1),2**53-1],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function dr(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw Error(`.pick() cannot be used on object schemas containing refinements`);return cr(e,Qn(e._zod.def,{get shape(){let e={};for(let r in t){if(!(r in n.shape))throw Error(`Unrecognized key: "${r}"`);t[r]&&(e[r]=n.shape[r])}return Zn(this,`shape`,e),e},checks:[]}))}function fr(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw Error(`.omit() cannot be used on object schemas containing refinements`);return cr(e,Qn(e._zod.def,{get shape(){let r={...e._zod.def.shape};for(let e in t){if(!(e in n.shape))throw Error(`Unrecognized key: "${e}"`);t[e]&&delete r[e]}return Zn(this,`shape`,r),r},checks:[]}))}function pr(e,t){if(!ir(t))throw Error(`Invalid input to extend: expected a plain object`);let n=e._zod.def.checks;if(n&&n.length>0){let n=e._zod.def.shape;for(let e in t)if(Object.getOwnPropertyDescriptor(n,e)!==void 0)throw Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}return cr(e,Qn(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t};return Zn(this,`shape`,n),n}}))}function mr(e,t){if(!ir(t))throw Error(`Invalid input to safeExtend: expected a plain object`);return cr(e,Qn(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t};return Zn(this,`shape`,n),n}}))}function hr(e,t){return cr(e,Qn(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t._zod.def.shape};return Zn(this,`shape`,n),n},get catchall(){return t._zod.def.catchall},checks:[]}))}function gr(e,t,n){let r=t._zod.def.checks;if(r&&r.length>0)throw Error(`.partial() cannot be used on object schemas containing refinements`);return cr(t,Qn(t._zod.def,{get shape(){let r=t._zod.def.shape,i={...r};if(n)for(let t in n){if(!(t in r))throw Error(`Unrecognized key: "${t}"`);n[t]&&(i[t]=e?new e({type:`optional`,innerType:r[t]}):r[t])}else for(let t in r)i[t]=e?new e({type:`optional`,innerType:r[t]}):r[t];return Zn(this,`shape`,i),i},checks:[]}))}function _r(e,t,n){return cr(t,Qn(t._zod.def,{get shape(){let r=t._zod.def.shape,i={...r};if(n)for(let t in n){if(!(t in i))throw Error(`Unrecognized key: "${t}"`);n[t]&&(i[t]=new e({type:`nonoptional`,innerType:r[t]}))}else for(let t in r)i[t]=new e({type:`nonoptional`,innerType:r[t]});return Zn(this,`shape`,i),i}}))}function vr(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue!==!0)return!0;return!1}function yr(e,t){return t.map(t=>{var n;return(n=t).path??(n.path=[]),t.path.unshift(e),t})}function br(e){return typeof e==`string`?e:e?.message}function xr(e,t,n){let r={...e,path:e.path??[]};return e.message||(r.message=br(e.inst?._zod.def?.error?.(e))??br(t?.error?.(e))??br(n.customError?.(e))??br(n.localeError?.(e))??`Invalid input`),delete r.inst,delete r.continue,t?.reportInput||delete r.input,r}function Sr(e){return Array.isArray(e)?`array`:typeof e==`string`?`string`:`unknown`}function Cr(...e){let[t,n,r]=e;return typeof t==`string`?{message:t,code:`custom`,input:n,inst:r}:{...t}}let wr=(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,Gn,2),Object.defineProperty(e,`toString`,{value:()=>e.message,enumerable:!1})},Tr=D(`$ZodError`,wr),Er=D(`$ZodError`,wr,{Parent:Error});function Dr(e,t=e=>e.message){let n={},r=[];for(let i of e.issues)i.path.length>0?(n[i.path[0]]=n[i.path[0]]||[],n[i.path[0]].push(t(i))):r.push(t(i));return{formErrors:r,fieldErrors:n}}function Or(e,t=e=>e.message){let n={_errors:[]},r=e=>{for(let i of e.issues)if(i.code===`invalid_union`&&i.errors.length)i.errors.map(e=>r({issues:e}));else if(i.code===`invalid_key`)r({issues:i.issues});else if(i.code===`invalid_element`)r({issues:i.issues});else if(i.path.length===0)n._errors.push(t(i));else{let e=n,r=0;for(;r<i.path.length;){let n=i.path[r];r===i.path.length-1?(e[n]=e[n]||{_errors:[]},e[n]._errors.push(t(i))):e[n]=e[n]||{_errors:[]},e=e[n],r++}}};return r(e),n}let kr=e=>(t,n,r,i)=>{let a=r?Object.assign(r,{async:!1}):{async:!1},o=t._zod.run({value:n,issues:[]},a);if(o instanceof Promise)throw new Bn;if(o.issues.length){let t=new(i?.Err??e)(o.issues.map(e=>xr(e,a,Un())));throw tr(t,i?.callee),t}return o.value},Ar=kr(Er),jr=e=>async(t,n,r,i)=>{let a=r?Object.assign(r,{async:!0}):{async:!0},o=t._zod.run({value:n,issues:[]},a);if(o instanceof Promise&&(o=await o),o.issues.length){let t=new(i?.Err??e)(o.issues.map(e=>xr(e,a,Un())));throw tr(t,i?.callee),t}return o.value},Mr=jr(Er),Nr=e=>(t,n,r)=>{let i=r?{...r,async:!1}:{async:!1},a=t._zod.run({value:n,issues:[]},i);if(a instanceof Promise)throw new Bn;return a.issues.length?{success:!1,error:new(e??Tr)(a.issues.map(e=>xr(e,i,Un())))}:{success:!0,data:a.value}},Pr=Nr(Er),Fr=e=>async(t,n,r)=>{let i=r?Object.assign(r,{async:!0}):{async:!0},a=t._zod.run({value:n,issues:[]},i);return a instanceof Promise&&(a=await a),a.issues.length?{success:!1,error:new e(a.issues.map(e=>xr(e,i,Un())))}:{success:!0,data:a.value}},Ir=Fr(Er),Lr=e=>(t,n,r)=>{let i=r?Object.assign(r,{direction:`backward`}):{direction:`backward`};return kr(e)(t,n,i)},Rr=e=>(t,n,r)=>kr(e)(t,n,r),zr=e=>async(t,n,r)=>{let i=r?Object.assign(r,{direction:`backward`}):{direction:`backward`};return jr(e)(t,n,i)},Br=e=>async(t,n,r)=>jr(e)(t,n,r),Vr=e=>(t,n,r)=>{let i=r?Object.assign(r,{direction:`backward`}):{direction:`backward`};return Nr(e)(t,n,i)},Hr=e=>(t,n,r)=>Nr(e)(t,n,r),Ur=e=>async(t,n,r)=>{let i=r?Object.assign(r,{direction:`backward`}):{direction:`backward`};return Fr(e)(t,n,i)},Wr=e=>async(t,n,r)=>Fr(e)(t,n,r),Gr=/^[cC][^\s-]{8,}$/,Kr=/^[0-9a-z]+$/,qr=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,Jr=/^[0-9a-vA-V]{20}$/,Yr=/^[A-Za-z0-9]{27}$/,Xr=/^[a-zA-Z0-9_-]{21}$/,Zr=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,Qr=/^([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})$/,$r=e=>e?RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,ei=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;function ti(){return RegExp(`^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`,`u`)}let ni=/^(?:(?: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])$/,ri=/^(([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}|:))$/,ii=/^((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])$/,ai=/^(([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])$/,oi=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,si=/^[A-Za-z0-9_-]*$/,ci=/^\+[1-9]\d{6,14}$/,li=`(?:(?:\\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])))`,ui=RegExp(`^${li}$`);function di(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 fi(e){return RegExp(`^${di(e)}$`)}function pi(e){let t=di({precision:e.precision}),n=[`Z`];e.local&&n.push(``),e.offset&&n.push(`([+-](?:[01]\\d|2[0-3]):[0-5]\\d)`);let r=`${t}(?:${n.join(`|`)})`;return RegExp(`^${li}T(?:${r})$`)}let mi=e=>{let t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??``}}`:`[\\s\\S]*`;return RegExp(`^${t}$`)},hi=/^-?\d+$/,gi=/^-?\d+(?:\.\d+)?$/,_i=/^(?:true|false)$/i,vi=/^null$/i,yi=/^[^A-Z]*$/,bi=/^[^a-z]*$/,xi=D(`$ZodCheck`,(e,t)=>{var n;e._zod??={},e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),Si={number:`number`,bigint:`bigint`,object:`date`},Ci=D(`$ZodCheckLessThan`,(e,t)=>{xi.init(e,t);let n=Si[typeof t.value];e._zod.onattach.push(e=>{let n=e._zod.bag,r=(t.inclusive?n.maximum:n.exclusiveMaximum)??1/0;t.value<r&&(t.inclusive?n.maximum=t.value:n.exclusiveMaximum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value<=t.value:r.value<t.value)||r.issues.push({origin:n,code:`too_big`,maximum:typeof t.value==`object`?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),wi=D(`$ZodCheckGreaterThan`,(e,t)=>{xi.init(e,t);let n=Si[typeof t.value];e._zod.onattach.push(e=>{let n=e._zod.bag,r=(t.inclusive?n.minimum:n.exclusiveMinimum)??-1/0;t.value>r&&(t.inclusive?n.minimum=t.value:n.exclusiveMinimum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value>=t.value:r.value>t.value)||r.issues.push({origin:n,code:`too_small`,minimum:typeof t.value==`object`?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Ti=D(`$ZodCheckMultipleOf`,(e,t)=>{xi.init(e,t),e._zod.onattach.push(e=>{var n;(n=e._zod.bag).multipleOf??(n.multipleOf=t.value)}),e._zod.check=n=>{if(typeof n.value!=typeof t.value)throw Error(`Cannot mix number and bigint in multiple_of check.`);(typeof n.value==`bigint`?n.value%t.value===BigInt(0):Yn(n.value,t.value)===0)||n.issues.push({origin:typeof n.value,code:`not_multiple_of`,divisor:t.value,input:n.value,inst:e,continue:!t.abort})}}),Ei=D(`$ZodCheckNumberFormat`,(e,t)=>{xi.init(e,t),t.format=t.format||`float64`;let n=t.format?.includes(`int`),r=n?`int`:`number`,[i,a]=ur[t.format];e._zod.onattach.push(e=>{let r=e._zod.bag;r.format=t.format,r.minimum=i,r.maximum=a,n&&(r.pattern=hi)}),e._zod.check=o=>{let s=o.value;if(n){if(!Number.isInteger(s)){o.issues.push({expected:r,format:t.format,code:`invalid_type`,continue:!1,input:s,inst:e});return}if(!Number.isSafeInteger(s)){s>0?o.issues.push({input:s,code:`too_big`,maximum:2**53-1,note:`Integers must be within the safe integer range.`,inst:e,origin:r,inclusive:!0,continue:!t.abort}):o.issues.push({input:s,code:`too_small`,minimum:-(2**53-1),note:`Integers must be within the safe integer range.`,inst:e,origin:r,inclusive:!0,continue:!t.abort});return}}s<i&&o.issues.push({origin:`number`,input:s,code:`too_small`,minimum:i,inclusive:!0,inst:e,continue:!t.abort}),s>a&&o.issues.push({origin:`number`,input:s,code:`too_big`,maximum:a,inclusive:!0,inst:e,continue:!t.abort})}}),Di=D(`$ZodCheckMaxLength`,(e,t)=>{var n;xi.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!qn(t)&&t.length!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag.maximum??1/0;t.maximum<n&&(e._zod.bag.maximum=t.maximum)}),e._zod.check=n=>{let r=n.value;if(r.length<=t.maximum)return;let i=Sr(r);n.issues.push({origin:i,code:`too_big`,maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),Oi=D(`$ZodCheckMinLength`,(e,t)=>{var n;xi.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!qn(t)&&t.length!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag.minimum??-1/0;t.minimum>n&&(e._zod.bag.minimum=t.minimum)}),e._zod.check=n=>{let r=n.value;if(r.length>=t.minimum)return;let i=Sr(r);n.issues.push({origin:i,code:`too_small`,minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),ki=D(`$ZodCheckLengthEquals`,(e,t)=>{var n;xi.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!qn(t)&&t.length!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag;n.minimum=t.length,n.maximum=t.length,n.length=t.length}),e._zod.check=n=>{let r=n.value,i=r.length;if(i===t.length)return;let a=Sr(r),o=i>t.length;n.issues.push({origin:a,...o?{code:`too_big`,maximum:t.length}:{code:`too_small`,minimum:t.length},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}}),Ai=D(`$ZodCheckStringFormat`,(e,t)=>{var n,r;xi.init(e,t),e._zod.onattach.push(e=>{let n=e._zod.bag;n.format=t.format,t.pattern&&(n.patterns??=new Set,n.patterns.add(t.pattern))}),t.pattern?(n=e._zod).check??(n.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:`string`,code:`invalid_format`,format:t.format,input:n.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(r=e._zod).check??(r.check=()=>{})}),ji=D(`$ZodCheckRegex`,(e,t)=>{Ai.init(e,t),e._zod.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:`string`,code:`invalid_format`,format:`regex`,input:n.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),Mi=D(`$ZodCheckLowerCase`,(e,t)=>{t.pattern??=yi,Ai.init(e,t)}),Ni=D(`$ZodCheckUpperCase`,(e,t)=>{t.pattern??=bi,Ai.init(e,t)}),Pi=D(`$ZodCheckIncludes`,(e,t)=>{xi.init(e,t);let n=sr(t.includes),r=new RegExp(typeof t.position==`number`?`^.{${t.position}}${n}`:n);t.pattern=r,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=new Set,t.patterns.add(r)}),e._zod.check=n=>{n.value.includes(t.includes,t.position)||n.issues.push({origin:`string`,code:`invalid_format`,format:`includes`,includes:t.includes,input:n.value,inst:e,continue:!t.abort})}}),Fi=D(`$ZodCheckStartsWith`,(e,t)=>{xi.init(e,t);let n=RegExp(`^${sr(t.prefix)}.*`);t.pattern??=n,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=new Set,t.patterns.add(n)}),e._zod.check=n=>{n.value.startsWith(t.prefix)||n.issues.push({origin:`string`,code:`invalid_format`,format:`starts_with`,prefix:t.prefix,input:n.value,inst:e,continue:!t.abort})}}),Ii=D(`$ZodCheckEndsWith`,(e,t)=>{xi.init(e,t);let n=RegExp(`.*${sr(t.suffix)}$`);t.pattern??=n,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=new Set,t.patterns.add(n)}),e._zod.check=n=>{n.value.endsWith(t.suffix)||n.issues.push({origin:`string`,code:`invalid_format`,format:`ends_with`,suffix:t.suffix,input:n.value,inst:e,continue:!t.abort})}}),Li=D(`$ZodCheckOverwrite`,(e,t)=>{xi.init(e,t),e._zod.check=e=>{e.value=t.tx(e.value)}});var Ri=class{constructor(e=[]){this.content=[],this.indent=0,this&&(this.args=e)}indented(e){this.indent+=1,e(this),--this.indent}write(e){if(typeof e==`function`){e(this,{execution:`sync`}),e(this,{execution:`async`});return}let t=e.split(`
1
+ var WebMCP=(function(e){var t;(function(e){e.assertEqual=e=>{};function t(e){}e.assertIs=t;function n(e){throw Error()}e.assertNever=n,e.arrayToEnum=e=>{let t={};for(let n of e)t[n]=n;return t},e.getValidEnumValues=t=>{let n=e.objectKeys(t).filter(e=>typeof t[t[e]]!=`number`),r={};for(let e of n)r[e]=t[e];return e.objectValues(r)},e.objectValues=t=>e.objectKeys(t).map(function(e){return t[e]}),e.objectKeys=typeof Object.keys==`function`?e=>Object.keys(e):e=>{let t=[];for(let n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.push(n);return t},e.find=(e,t)=>{for(let n of e)if(t(n))return n},e.isInteger=typeof Number.isInteger==`function`?e=>Number.isInteger(e):e=>typeof e==`number`&&Number.isFinite(e)&&Math.floor(e)===e;function r(e,t=` | `){return e.map(e=>typeof e==`string`?`'${e}'`:e).join(t)}e.joinValues=r,e.jsonStringifyReplacer=(e,t)=>typeof t==`bigint`?t.toString():t})(t||={});var n;(function(e){e.mergeShapes=(e,t)=>({...e,...t})})(n||={});let r=t.arrayToEnum([`string`,`nan`,`number`,`integer`,`float`,`boolean`,`date`,`bigint`,`symbol`,`function`,`undefined`,`null`,`array`,`object`,`unknown`,`promise`,`void`,`never`,`map`,`set`]),i=e=>{switch(typeof e){case`undefined`:return r.undefined;case`string`:return r.string;case`number`:return Number.isNaN(e)?r.nan:r.number;case`boolean`:return r.boolean;case`function`:return r.function;case`bigint`:return r.bigint;case`symbol`:return r.symbol;case`object`:return Array.isArray(e)?r.array:e===null?r.null:e.then&&typeof e.then==`function`&&e.catch&&typeof e.catch==`function`?r.promise:typeof Map<`u`&&e instanceof Map?r.map:typeof Set<`u`&&e instanceof Set?r.set:typeof Date<`u`&&e instanceof Date?r.date:r.object;default:return r.unknown}},a=t.arrayToEnum([`invalid_type`,`invalid_literal`,`custom`,`invalid_union`,`invalid_union_discriminator`,`invalid_enum_value`,`unrecognized_keys`,`invalid_arguments`,`invalid_return_type`,`invalid_date`,`invalid_string`,`too_small`,`too_big`,`invalid_intersection_types`,`not_multiple_of`,`not_finite`]);var o=class e extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=e=>{this.issues=[...this.issues,e]},this.addIssues=(e=[])=>{this.issues=[...this.issues,...e]};let t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name=`ZodError`,this.issues=e}format(e){let t=e||function(e){return e.message},n={_errors:[]},r=e=>{for(let i of e.issues)if(i.code===`invalid_union`)i.unionErrors.map(r);else if(i.code===`invalid_return_type`)r(i.returnTypeError);else if(i.code===`invalid_arguments`)r(i.argumentsError);else if(i.path.length===0)n._errors.push(t(i));else{let e=n,r=0;for(;r<i.path.length;){let n=i.path[r];r===i.path.length-1?(e[n]=e[n]||{_errors:[]},e[n]._errors.push(t(i))):e[n]=e[n]||{_errors:[]},e=e[n],r++}}};return r(this),n}static assert(t){if(!(t instanceof e))throw Error(`Not a ZodError: ${t}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,t.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=e=>e.message){let t=Object.create(null),n=[];for(let r of this.issues)if(r.path.length>0){let n=r.path[0];t[n]=t[n]||[],t[n].push(e(r))}else n.push(e(r));return{formErrors:n,fieldErrors:t}}get formErrors(){return this.flatten()}};o.create=e=>new o(e);var s=(e,n)=>{let i;switch(e.code){case a.invalid_type:i=e.received===r.undefined?`Required`:`Expected ${e.expected}, received ${e.received}`;break;case a.invalid_literal:i=`Invalid literal value, expected ${JSON.stringify(e.expected,t.jsonStringifyReplacer)}`;break;case a.unrecognized_keys:i=`Unrecognized key(s) in object: ${t.joinValues(e.keys,`, `)}`;break;case a.invalid_union:i=`Invalid input`;break;case a.invalid_union_discriminator:i=`Invalid discriminator value. Expected ${t.joinValues(e.options)}`;break;case a.invalid_enum_value:i=`Invalid enum value. Expected ${t.joinValues(e.options)}, received '${e.received}'`;break;case a.invalid_arguments:i=`Invalid function arguments`;break;case a.invalid_return_type:i=`Invalid function return type`;break;case a.invalid_date:i=`Invalid date`;break;case a.invalid_string:typeof e.validation==`object`?`includes`in e.validation?(i=`Invalid input: must include "${e.validation.includes}"`,typeof e.validation.position==`number`&&(i=`${i} at one or more positions greater than or equal to ${e.validation.position}`)):`startsWith`in e.validation?i=`Invalid input: must start with "${e.validation.startsWith}"`:`endsWith`in e.validation?i=`Invalid input: must end with "${e.validation.endsWith}"`:t.assertNever(e.validation):i=e.validation===`regex`?`Invalid`:`Invalid ${e.validation}`;break;case a.too_small:i=e.type===`array`?`Array must contain ${e.exact?`exactly`:e.inclusive?`at least`:`more than`} ${e.minimum} element(s)`:e.type===`string`?`String must contain ${e.exact?`exactly`:e.inclusive?`at least`:`over`} ${e.minimum} character(s)`:e.type===`number`||e.type===`bigint`?`Number must be ${e.exact?`exactly equal to `:e.inclusive?`greater than or equal to `:`greater than `}${e.minimum}`:e.type===`date`?`Date must be ${e.exact?`exactly equal to `:e.inclusive?`greater than or equal to `:`greater than `}${new Date(Number(e.minimum))}`:`Invalid input`;break;case a.too_big:i=e.type===`array`?`Array must contain ${e.exact?`exactly`:e.inclusive?`at most`:`less than`} ${e.maximum} element(s)`:e.type===`string`?`String must contain ${e.exact?`exactly`:e.inclusive?`at most`:`under`} ${e.maximum} character(s)`:e.type===`number`?`Number must be ${e.exact?`exactly`:e.inclusive?`less than or equal to`:`less than`} ${e.maximum}`:e.type===`bigint`?`BigInt must be ${e.exact?`exactly`:e.inclusive?`less than or equal to`:`less than`} ${e.maximum}`:e.type===`date`?`Date must be ${e.exact?`exactly`:e.inclusive?`smaller than or equal to`:`smaller than`} ${new Date(Number(e.maximum))}`:`Invalid input`;break;case a.custom:i=`Invalid input`;break;case a.invalid_intersection_types:i=`Intersection results could not be merged`;break;case a.not_multiple_of:i=`Number must be a multiple of ${e.multipleOf}`;break;case a.not_finite:i=`Number must be finite`;break;default:i=n.defaultError,t.assertNever(e)}return{message:i}};let c=s;function l(){return c}let u=e=>{let{data:t,path:n,errorMaps:r,issueData:i}=e,a=[...n,...i.path||[]],o={...i,path:a};if(i.message!==void 0)return{...i,path:a,message:i.message};let s=``,c=r.filter(e=>!!e).slice().reverse();for(let e of c)s=e(o,{data:t,defaultError:s}).message;return{...i,path:a,message:s}};function d(e,t){let n=l(),r=u({issueData:t,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,n,n===s?void 0:s].filter(e=>!!e)});e.common.issues.push(r)}var f=class e{constructor(){this.value=`valid`}dirty(){this.value===`valid`&&(this.value=`dirty`)}abort(){this.value!==`aborted`&&(this.value=`aborted`)}static mergeArray(e,t){let n=[];for(let r of t){if(r.status===`aborted`)return p;r.status===`dirty`&&e.dirty(),n.push(r.value)}return{status:e.value,value:n}}static async mergeObjectAsync(t,n){let r=[];for(let e of n){let t=await e.key,n=await e.value;r.push({key:t,value:n})}return e.mergeObjectSync(t,r)}static mergeObjectSync(e,t){let n={};for(let r of t){let{key:t,value:i}=r;if(t.status===`aborted`||i.status===`aborted`)return p;t.status===`dirty`&&e.dirty(),i.status===`dirty`&&e.dirty(),t.value!==`__proto__`&&(i.value!==void 0||r.alwaysSet)&&(n[t.value]=i.value)}return{status:e.value,value:n}}};let p=Object.freeze({status:`aborted`}),m=e=>({status:`dirty`,value:e}),h=e=>({status:`valid`,value:e}),ee=e=>e.status===`aborted`,te=e=>e.status===`dirty`,ne=e=>e.status===`valid`,re=e=>typeof Promise<`u`&&e instanceof Promise;var g;(function(e){e.errToObj=e=>typeof e==`string`?{message:e}:e||{},e.toString=e=>typeof e==`string`?e:e?.message})(g||={});var ie=class{constructor(e,t,n,r){this._cachedPath=[],this.parent=e,this.data=t,this._path=n,this._key=r}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}};let ae=(e,t)=>{if(ne(t))return{success:!0,data:t.value};if(!e.common.issues.length)throw Error(`Validation failed but no issues detected.`);return{success:!1,get error(){return this._error||=new o(e.common.issues),this._error}}};function _(e){if(!e)return{};let{errorMap:t,invalid_type_error:n,required_error:r,description:i}=e;if(t&&(n||r))throw Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return t?{errorMap:t,description:i}:{errorMap:(t,i)=>{let{message:a}=e;return t.code===`invalid_enum_value`?{message:a??i.defaultError}:i.data===void 0?{message:a??r??i.defaultError}:t.code===`invalid_type`?{message:a??n??i.defaultError}:{message:i.defaultError}},description:i}}var v=class{get description(){return this._def.description}_getType(e){return i(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:i(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new f,ctx:{common:e.parent.common,data:e.data,parsedType:i(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let t=this._parse(e);if(re(t))throw Error(`Synchronous parse encountered promise.`);return t}_parseAsync(e){let t=this._parse(e);return Promise.resolve(t)}parse(e,t){let n=this.safeParse(e,t);if(n.success)return n.data;throw n.error}safeParse(e,t){let n={common:{issues:[],async:t?.async??!1,contextualErrorMap:t?.errorMap},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:i(e)};return ae(n,this._parseSync({data:e,path:n.path,parent:n}))}"~validate"(e){let t={common:{issues:[],async:!!this[`~standard`].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:i(e)};if(!this[`~standard`].async)try{let n=this._parseSync({data:e,path:[],parent:t});return ne(n)?{value:n.value}:{issues:t.common.issues}}catch(e){e?.message?.toLowerCase()?.includes(`encountered`)&&(this[`~standard`].async=!0),t.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:t}).then(e=>ne(e)?{value:e.value}:{issues:t.common.issues})}async parseAsync(e,t){let n=await this.safeParseAsync(e,t);if(n.success)return n.data;throw n.error}async safeParseAsync(e,t){let n={common:{issues:[],contextualErrorMap:t?.errorMap,async:!0},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:i(e)},r=this._parse({data:e,path:n.path,parent:n});return ae(n,await(re(r)?r:Promise.resolve(r)))}refine(e,t){let n=e=>typeof t==`string`||t===void 0?{message:t}:typeof t==`function`?t(e):t;return this._refinement((t,r)=>{let i=e(t),o=()=>r.addIssue({code:a.custom,...n(t)});return typeof Promise<`u`&&i instanceof Promise?i.then(e=>e?!0:(o(),!1)):i?!0:(o(),!1)})}refinement(e,t){return this._refinement((n,r)=>e(n)?!0:(r.addIssue(typeof t==`function`?t(n,r):t),!1))}_refinement(e){return new ot({schema:this,typeName:b.ZodEffects,effect:{type:`refinement`,refinement:e}})}superRefine(e){return this._refinement(e)}constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this[`~standard`]={version:1,vendor:`zod`,validate:e=>this[`~validate`](e)}}optional(){return st.create(this,this._def)}nullable(){return ct.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return Ve.create(this)}promise(){return at.create(this,this._def)}or(e){return We.create([this,e],this._def)}and(e){return Je.create(this,e,this._def)}transform(e){return new ot({..._(this._def),schema:this,typeName:b.ZodEffects,effect:{type:`transform`,transform:e}})}default(e){let t=typeof e==`function`?e:()=>e;return new lt({..._(this._def),innerType:this,defaultValue:t,typeName:b.ZodDefault})}brand(){return new ft({typeName:b.ZodBranded,type:this,..._(this._def)})}catch(e){let t=typeof e==`function`?e:()=>e;return new ut({..._(this._def),innerType:this,catchValue:t,typeName:b.ZodCatch})}describe(e){let t=this.constructor;return new t({...this._def,description:e})}pipe(e){return pt.create(this,e)}readonly(){return mt.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}};let oe=/^c[^\s-]{8,}$/i,se=/^[0-9a-z]+$/,ce=/^[0-9A-HJKMNP-TV-Z]{26}$/i,le=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,ue=/^[a-z0-9_-]{21}$/i,de=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,fe=/^[-+]?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)?)??$/,pe=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,me,he=/^(?:(?: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])$/,ge=/^(?:(?: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])\/(3[0-2]|[12]?[0-9])$/,_e=/^(([0-9a-fA-F]{1,4}:){7,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}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,ve=/^(([0-9a-fA-F]{1,4}:){7,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}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,ye=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,be=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,xe=`((\\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])))`,Se=RegExp(`^${xe}$`);function Ce(e){let t=`[0-5]\\d`;e.precision?t=`${t}\\.\\d{${e.precision}}`:e.precision??(t=`${t}(\\.\\d+)?`);let n=e.precision?`+`:`?`;return`([01]\\d|2[0-3]):[0-5]\\d(:${t})${n}`}function we(e){return RegExp(`^${Ce(e)}$`)}function Te(e){let t=`${xe}T${Ce(e)}`,n=[];return n.push(e.local?`Z?`:`Z`),e.offset&&n.push(`([+-]\\d{2}:?\\d{2})`),t=`${t}(${n.join(`|`)})`,RegExp(`^${t}$`)}function Ee(e,t){return!!((t===`v4`||!t)&&he.test(e)||(t===`v6`||!t)&&_e.test(e))}function De(e,t){if(!de.test(e))return!1;try{let[n]=e.split(`.`);if(!n)return!1;let r=n.replace(/-/g,`+`).replace(/_/g,`/`).padEnd(n.length+(4-n.length%4)%4,`=`),i=JSON.parse(atob(r));return!(typeof i!=`object`||!i||`typ`in i&&i?.typ!==`JWT`||!i.alg||t&&i.alg!==t)}catch{return!1}}function Oe(e,t){return!!((t===`v4`||!t)&&ge.test(e)||(t===`v6`||!t)&&ve.test(e))}var ke=class e extends v{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==r.string){let t=this._getOrReturnCtx(e);return d(t,{code:a.invalid_type,expected:r.string,received:t.parsedType}),p}let n=new f,i;for(let r of this._def.checks)if(r.kind===`min`)e.data.length<r.value&&(i=this._getOrReturnCtx(e,i),d(i,{code:a.too_small,minimum:r.value,type:`string`,inclusive:!0,exact:!1,message:r.message}),n.dirty());else if(r.kind===`max`)e.data.length>r.value&&(i=this._getOrReturnCtx(e,i),d(i,{code:a.too_big,maximum:r.value,type:`string`,inclusive:!0,exact:!1,message:r.message}),n.dirty());else if(r.kind===`length`){let t=e.data.length>r.value,o=e.data.length<r.value;(t||o)&&(i=this._getOrReturnCtx(e,i),t?d(i,{code:a.too_big,maximum:r.value,type:`string`,inclusive:!0,exact:!0,message:r.message}):o&&d(i,{code:a.too_small,minimum:r.value,type:`string`,inclusive:!0,exact:!0,message:r.message}),n.dirty())}else if(r.kind===`email`)pe.test(e.data)||(i=this._getOrReturnCtx(e,i),d(i,{validation:`email`,code:a.invalid_string,message:r.message}),n.dirty());else if(r.kind===`emoji`)me||=RegExp(`^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`,`u`),me.test(e.data)||(i=this._getOrReturnCtx(e,i),d(i,{validation:`emoji`,code:a.invalid_string,message:r.message}),n.dirty());else if(r.kind===`uuid`)le.test(e.data)||(i=this._getOrReturnCtx(e,i),d(i,{validation:`uuid`,code:a.invalid_string,message:r.message}),n.dirty());else if(r.kind===`nanoid`)ue.test(e.data)||(i=this._getOrReturnCtx(e,i),d(i,{validation:`nanoid`,code:a.invalid_string,message:r.message}),n.dirty());else if(r.kind===`cuid`)oe.test(e.data)||(i=this._getOrReturnCtx(e,i),d(i,{validation:`cuid`,code:a.invalid_string,message:r.message}),n.dirty());else if(r.kind===`cuid2`)se.test(e.data)||(i=this._getOrReturnCtx(e,i),d(i,{validation:`cuid2`,code:a.invalid_string,message:r.message}),n.dirty());else if(r.kind===`ulid`)ce.test(e.data)||(i=this._getOrReturnCtx(e,i),d(i,{validation:`ulid`,code:a.invalid_string,message:r.message}),n.dirty());else if(r.kind===`url`)try{new URL(e.data)}catch{i=this._getOrReturnCtx(e,i),d(i,{validation:`url`,code:a.invalid_string,message:r.message}),n.dirty()}else r.kind===`regex`?(r.regex.lastIndex=0,r.regex.test(e.data)||(i=this._getOrReturnCtx(e,i),d(i,{validation:`regex`,code:a.invalid_string,message:r.message}),n.dirty())):r.kind===`trim`?e.data=e.data.trim():r.kind===`includes`?e.data.includes(r.value,r.position)||(i=this._getOrReturnCtx(e,i),d(i,{code:a.invalid_string,validation:{includes:r.value,position:r.position},message:r.message}),n.dirty()):r.kind===`toLowerCase`?e.data=e.data.toLowerCase():r.kind===`toUpperCase`?e.data=e.data.toUpperCase():r.kind===`startsWith`?e.data.startsWith(r.value)||(i=this._getOrReturnCtx(e,i),d(i,{code:a.invalid_string,validation:{startsWith:r.value},message:r.message}),n.dirty()):r.kind===`endsWith`?e.data.endsWith(r.value)||(i=this._getOrReturnCtx(e,i),d(i,{code:a.invalid_string,validation:{endsWith:r.value},message:r.message}),n.dirty()):r.kind===`datetime`?Te(r).test(e.data)||(i=this._getOrReturnCtx(e,i),d(i,{code:a.invalid_string,validation:`datetime`,message:r.message}),n.dirty()):r.kind===`date`?Se.test(e.data)||(i=this._getOrReturnCtx(e,i),d(i,{code:a.invalid_string,validation:`date`,message:r.message}),n.dirty()):r.kind===`time`?we(r).test(e.data)||(i=this._getOrReturnCtx(e,i),d(i,{code:a.invalid_string,validation:`time`,message:r.message}),n.dirty()):r.kind===`duration`?fe.test(e.data)||(i=this._getOrReturnCtx(e,i),d(i,{validation:`duration`,code:a.invalid_string,message:r.message}),n.dirty()):r.kind===`ip`?Ee(e.data,r.version)||(i=this._getOrReturnCtx(e,i),d(i,{validation:`ip`,code:a.invalid_string,message:r.message}),n.dirty()):r.kind===`jwt`?De(e.data,r.alg)||(i=this._getOrReturnCtx(e,i),d(i,{validation:`jwt`,code:a.invalid_string,message:r.message}),n.dirty()):r.kind===`cidr`?Oe(e.data,r.version)||(i=this._getOrReturnCtx(e,i),d(i,{validation:`cidr`,code:a.invalid_string,message:r.message}),n.dirty()):r.kind===`base64`?ye.test(e.data)||(i=this._getOrReturnCtx(e,i),d(i,{validation:`base64`,code:a.invalid_string,message:r.message}),n.dirty()):r.kind===`base64url`?be.test(e.data)||(i=this._getOrReturnCtx(e,i),d(i,{validation:`base64url`,code:a.invalid_string,message:r.message}),n.dirty()):t.assertNever(r);return{status:n.value,value:e.data}}_regex(e,t,n){return this.refinement(t=>e.test(t),{validation:t,code:a.invalid_string,...g.errToObj(n)})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}email(e){return this._addCheck({kind:`email`,...g.errToObj(e)})}url(e){return this._addCheck({kind:`url`,...g.errToObj(e)})}emoji(e){return this._addCheck({kind:`emoji`,...g.errToObj(e)})}uuid(e){return this._addCheck({kind:`uuid`,...g.errToObj(e)})}nanoid(e){return this._addCheck({kind:`nanoid`,...g.errToObj(e)})}cuid(e){return this._addCheck({kind:`cuid`,...g.errToObj(e)})}cuid2(e){return this._addCheck({kind:`cuid2`,...g.errToObj(e)})}ulid(e){return this._addCheck({kind:`ulid`,...g.errToObj(e)})}base64(e){return this._addCheck({kind:`base64`,...g.errToObj(e)})}base64url(e){return this._addCheck({kind:`base64url`,...g.errToObj(e)})}jwt(e){return this._addCheck({kind:`jwt`,...g.errToObj(e)})}ip(e){return this._addCheck({kind:`ip`,...g.errToObj(e)})}cidr(e){return this._addCheck({kind:`cidr`,...g.errToObj(e)})}datetime(e){return typeof e==`string`?this._addCheck({kind:`datetime`,precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:`datetime`,precision:e?.precision===void 0?null:e?.precision,offset:e?.offset??!1,local:e?.local??!1,...g.errToObj(e?.message)})}date(e){return this._addCheck({kind:`date`,message:e})}time(e){return typeof e==`string`?this._addCheck({kind:`time`,precision:null,message:e}):this._addCheck({kind:`time`,precision:e?.precision===void 0?null:e?.precision,...g.errToObj(e?.message)})}duration(e){return this._addCheck({kind:`duration`,...g.errToObj(e)})}regex(e,t){return this._addCheck({kind:`regex`,regex:e,...g.errToObj(t)})}includes(e,t){return this._addCheck({kind:`includes`,value:e,position:t?.position,...g.errToObj(t?.message)})}startsWith(e,t){return this._addCheck({kind:`startsWith`,value:e,...g.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:`endsWith`,value:e,...g.errToObj(t)})}min(e,t){return this._addCheck({kind:`min`,value:e,...g.errToObj(t)})}max(e,t){return this._addCheck({kind:`max`,value:e,...g.errToObj(t)})}length(e,t){return this._addCheck({kind:`length`,value:e,...g.errToObj(t)})}nonempty(e){return this.min(1,g.errToObj(e))}trim(){return new e({...this._def,checks:[...this._def.checks,{kind:`trim`}]})}toLowerCase(){return new e({...this._def,checks:[...this._def.checks,{kind:`toLowerCase`}]})}toUpperCase(){return new e({...this._def,checks:[...this._def.checks,{kind:`toUpperCase`}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind===`datetime`)}get isDate(){return!!this._def.checks.find(e=>e.kind===`date`)}get isTime(){return!!this._def.checks.find(e=>e.kind===`time`)}get isDuration(){return!!this._def.checks.find(e=>e.kind===`duration`)}get isEmail(){return!!this._def.checks.find(e=>e.kind===`email`)}get isURL(){return!!this._def.checks.find(e=>e.kind===`url`)}get isEmoji(){return!!this._def.checks.find(e=>e.kind===`emoji`)}get isUUID(){return!!this._def.checks.find(e=>e.kind===`uuid`)}get isNANOID(){return!!this._def.checks.find(e=>e.kind===`nanoid`)}get isCUID(){return!!this._def.checks.find(e=>e.kind===`cuid`)}get isCUID2(){return!!this._def.checks.find(e=>e.kind===`cuid2`)}get isULID(){return!!this._def.checks.find(e=>e.kind===`ulid`)}get isIP(){return!!this._def.checks.find(e=>e.kind===`ip`)}get isCIDR(){return!!this._def.checks.find(e=>e.kind===`cidr`)}get isBase64(){return!!this._def.checks.find(e=>e.kind===`base64`)}get isBase64url(){return!!this._def.checks.find(e=>e.kind===`base64url`)}get minLength(){let e=null;for(let t of this._def.checks)t.kind===`min`&&(e===null||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(let t of this._def.checks)t.kind===`max`&&(e===null||t.value<e)&&(e=t.value);return e}};ke.create=e=>new ke({checks:[],typeName:b.ZodString,coerce:e?.coerce??!1,..._(e)});function Ae(e,t){let n=(e.toString().split(`.`)[1]||``).length,r=(t.toString().split(`.`)[1]||``).length,i=n>r?n:r;return Number.parseInt(e.toFixed(i).replace(`.`,``))%Number.parseInt(t.toFixed(i).replace(`.`,``))/10**i}var je=class e extends v{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==r.number){let t=this._getOrReturnCtx(e);return d(t,{code:a.invalid_type,expected:r.number,received:t.parsedType}),p}let n,i=new f;for(let r of this._def.checks)r.kind===`int`?t.isInteger(e.data)||(n=this._getOrReturnCtx(e,n),d(n,{code:a.invalid_type,expected:`integer`,received:`float`,message:r.message}),i.dirty()):r.kind===`min`?(r.inclusive?e.data<r.value:e.data<=r.value)&&(n=this._getOrReturnCtx(e,n),d(n,{code:a.too_small,minimum:r.value,type:`number`,inclusive:r.inclusive,exact:!1,message:r.message}),i.dirty()):r.kind===`max`?(r.inclusive?e.data>r.value:e.data>=r.value)&&(n=this._getOrReturnCtx(e,n),d(n,{code:a.too_big,maximum:r.value,type:`number`,inclusive:r.inclusive,exact:!1,message:r.message}),i.dirty()):r.kind===`multipleOf`?Ae(e.data,r.value)!==0&&(n=this._getOrReturnCtx(e,n),d(n,{code:a.not_multiple_of,multipleOf:r.value,message:r.message}),i.dirty()):r.kind===`finite`?Number.isFinite(e.data)||(n=this._getOrReturnCtx(e,n),d(n,{code:a.not_finite,message:r.message}),i.dirty()):t.assertNever(r);return{status:i.value,value:e.data}}gte(e,t){return this.setLimit(`min`,e,!0,g.toString(t))}gt(e,t){return this.setLimit(`min`,e,!1,g.toString(t))}lte(e,t){return this.setLimit(`max`,e,!0,g.toString(t))}lt(e,t){return this.setLimit(`max`,e,!1,g.toString(t))}setLimit(t,n,r,i){return new e({...this._def,checks:[...this._def.checks,{kind:t,value:n,inclusive:r,message:g.toString(i)}]})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}int(e){return this._addCheck({kind:`int`,message:g.toString(e)})}positive(e){return this._addCheck({kind:`min`,value:0,inclusive:!1,message:g.toString(e)})}negative(e){return this._addCheck({kind:`max`,value:0,inclusive:!1,message:g.toString(e)})}nonpositive(e){return this._addCheck({kind:`max`,value:0,inclusive:!0,message:g.toString(e)})}nonnegative(e){return this._addCheck({kind:`min`,value:0,inclusive:!0,message:g.toString(e)})}multipleOf(e,t){return this._addCheck({kind:`multipleOf`,value:e,message:g.toString(t)})}finite(e){return this._addCheck({kind:`finite`,message:g.toString(e)})}safe(e){return this._addCheck({kind:`min`,inclusive:!0,value:-(2**53-1),message:g.toString(e)})._addCheck({kind:`max`,inclusive:!0,value:2**53-1,message:g.toString(e)})}get minValue(){let e=null;for(let t of this._def.checks)t.kind===`min`&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(let t of this._def.checks)t.kind===`max`&&(e===null||t.value<e)&&(e=t.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind===`int`||e.kind===`multipleOf`&&t.isInteger(e.value))}get isFinite(){let e=null,t=null;for(let n of this._def.checks)if(n.kind===`finite`||n.kind===`int`||n.kind===`multipleOf`)return!0;else n.kind===`min`?(t===null||n.value>t)&&(t=n.value):n.kind===`max`&&(e===null||n.value<e)&&(e=n.value);return Number.isFinite(t)&&Number.isFinite(e)}};je.create=e=>new je({checks:[],typeName:b.ZodNumber,coerce:e?.coerce||!1,..._(e)});var Me=class e extends v{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce)try{e.data=BigInt(e.data)}catch{return this._getInvalidInput(e)}if(this._getType(e)!==r.bigint)return this._getInvalidInput(e);let n,i=new f;for(let r of this._def.checks)r.kind===`min`?(r.inclusive?e.data<r.value:e.data<=r.value)&&(n=this._getOrReturnCtx(e,n),d(n,{code:a.too_small,type:`bigint`,minimum:r.value,inclusive:r.inclusive,message:r.message}),i.dirty()):r.kind===`max`?(r.inclusive?e.data>r.value:e.data>=r.value)&&(n=this._getOrReturnCtx(e,n),d(n,{code:a.too_big,type:`bigint`,maximum:r.value,inclusive:r.inclusive,message:r.message}),i.dirty()):r.kind===`multipleOf`?e.data%r.value!==BigInt(0)&&(n=this._getOrReturnCtx(e,n),d(n,{code:a.not_multiple_of,multipleOf:r.value,message:r.message}),i.dirty()):t.assertNever(r);return{status:i.value,value:e.data}}_getInvalidInput(e){let t=this._getOrReturnCtx(e);return d(t,{code:a.invalid_type,expected:r.bigint,received:t.parsedType}),p}gte(e,t){return this.setLimit(`min`,e,!0,g.toString(t))}gt(e,t){return this.setLimit(`min`,e,!1,g.toString(t))}lte(e,t){return this.setLimit(`max`,e,!0,g.toString(t))}lt(e,t){return this.setLimit(`max`,e,!1,g.toString(t))}setLimit(t,n,r,i){return new e({...this._def,checks:[...this._def.checks,{kind:t,value:n,inclusive:r,message:g.toString(i)}]})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}positive(e){return this._addCheck({kind:`min`,value:BigInt(0),inclusive:!1,message:g.toString(e)})}negative(e){return this._addCheck({kind:`max`,value:BigInt(0),inclusive:!1,message:g.toString(e)})}nonpositive(e){return this._addCheck({kind:`max`,value:BigInt(0),inclusive:!0,message:g.toString(e)})}nonnegative(e){return this._addCheck({kind:`min`,value:BigInt(0),inclusive:!0,message:g.toString(e)})}multipleOf(e,t){return this._addCheck({kind:`multipleOf`,value:e,message:g.toString(t)})}get minValue(){let e=null;for(let t of this._def.checks)t.kind===`min`&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(let t of this._def.checks)t.kind===`max`&&(e===null||t.value<e)&&(e=t.value);return e}};Me.create=e=>new Me({checks:[],typeName:b.ZodBigInt,coerce:e?.coerce??!1,..._(e)});var Ne=class extends v{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==r.boolean){let t=this._getOrReturnCtx(e);return d(t,{code:a.invalid_type,expected:r.boolean,received:t.parsedType}),p}return h(e.data)}};Ne.create=e=>new Ne({typeName:b.ZodBoolean,coerce:e?.coerce||!1,..._(e)});var Pe=class e extends v{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==r.date){let t=this._getOrReturnCtx(e);return d(t,{code:a.invalid_type,expected:r.date,received:t.parsedType}),p}if(Number.isNaN(e.data.getTime()))return d(this._getOrReturnCtx(e),{code:a.invalid_date}),p;let n=new f,i;for(let r of this._def.checks)r.kind===`min`?e.data.getTime()<r.value&&(i=this._getOrReturnCtx(e,i),d(i,{code:a.too_small,message:r.message,inclusive:!0,exact:!1,minimum:r.value,type:`date`}),n.dirty()):r.kind===`max`?e.data.getTime()>r.value&&(i=this._getOrReturnCtx(e,i),d(i,{code:a.too_big,message:r.message,inclusive:!0,exact:!1,maximum:r.value,type:`date`}),n.dirty()):t.assertNever(r);return{status:n.value,value:new Date(e.data.getTime())}}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}min(e,t){return this._addCheck({kind:`min`,value:e.getTime(),message:g.toString(t)})}max(e,t){return this._addCheck({kind:`max`,value:e.getTime(),message:g.toString(t)})}get minDate(){let e=null;for(let t of this._def.checks)t.kind===`min`&&(e===null||t.value>e)&&(e=t.value);return e==null?null:new Date(e)}get maxDate(){let e=null;for(let t of this._def.checks)t.kind===`max`&&(e===null||t.value<e)&&(e=t.value);return e==null?null:new Date(e)}};Pe.create=e=>new Pe({checks:[],coerce:e?.coerce||!1,typeName:b.ZodDate,..._(e)});var Fe=class extends v{_parse(e){if(this._getType(e)!==r.symbol){let t=this._getOrReturnCtx(e);return d(t,{code:a.invalid_type,expected:r.symbol,received:t.parsedType}),p}return h(e.data)}};Fe.create=e=>new Fe({typeName:b.ZodSymbol,..._(e)});var Ie=class extends v{_parse(e){if(this._getType(e)!==r.undefined){let t=this._getOrReturnCtx(e);return d(t,{code:a.invalid_type,expected:r.undefined,received:t.parsedType}),p}return h(e.data)}};Ie.create=e=>new Ie({typeName:b.ZodUndefined,..._(e)});var y=class extends v{_parse(e){if(this._getType(e)!==r.null){let t=this._getOrReturnCtx(e);return d(t,{code:a.invalid_type,expected:r.null,received:t.parsedType}),p}return h(e.data)}};y.create=e=>new y({typeName:b.ZodNull,..._(e)});var Le=class extends v{constructor(){super(...arguments),this._any=!0}_parse(e){return h(e.data)}};Le.create=e=>new Le({typeName:b.ZodAny,..._(e)});var Re=class extends v{constructor(){super(...arguments),this._unknown=!0}_parse(e){return h(e.data)}};Re.create=e=>new Re({typeName:b.ZodUnknown,..._(e)});var ze=class extends v{_parse(e){let t=this._getOrReturnCtx(e);return d(t,{code:a.invalid_type,expected:r.never,received:t.parsedType}),p}};ze.create=e=>new ze({typeName:b.ZodNever,..._(e)});var Be=class extends v{_parse(e){if(this._getType(e)!==r.undefined){let t=this._getOrReturnCtx(e);return d(t,{code:a.invalid_type,expected:r.void,received:t.parsedType}),p}return h(e.data)}};Be.create=e=>new Be({typeName:b.ZodVoid,..._(e)});var Ve=class e extends v{_parse(e){let{ctx:t,status:n}=this._processInputParams(e),i=this._def;if(t.parsedType!==r.array)return d(t,{code:a.invalid_type,expected:r.array,received:t.parsedType}),p;if(i.exactLength!==null){let e=t.data.length>i.exactLength.value,r=t.data.length<i.exactLength.value;(e||r)&&(d(t,{code:e?a.too_big:a.too_small,minimum:r?i.exactLength.value:void 0,maximum:e?i.exactLength.value:void 0,type:`array`,inclusive:!0,exact:!0,message:i.exactLength.message}),n.dirty())}if(i.minLength!==null&&t.data.length<i.minLength.value&&(d(t,{code:a.too_small,minimum:i.minLength.value,type:`array`,inclusive:!0,exact:!1,message:i.minLength.message}),n.dirty()),i.maxLength!==null&&t.data.length>i.maxLength.value&&(d(t,{code:a.too_big,maximum:i.maxLength.value,type:`array`,inclusive:!0,exact:!1,message:i.maxLength.message}),n.dirty()),t.common.async)return Promise.all([...t.data].map((e,n)=>i.type._parseAsync(new ie(t,e,t.path,n)))).then(e=>f.mergeArray(n,e));let o=[...t.data].map((e,n)=>i.type._parseSync(new ie(t,e,t.path,n)));return f.mergeArray(n,o)}get element(){return this._def.type}min(t,n){return new e({...this._def,minLength:{value:t,message:g.toString(n)}})}max(t,n){return new e({...this._def,maxLength:{value:t,message:g.toString(n)}})}length(t,n){return new e({...this._def,exactLength:{value:t,message:g.toString(n)}})}nonempty(e){return this.min(1,e)}};Ve.create=(e,t)=>new Ve({type:e,minLength:null,maxLength:null,exactLength:null,typeName:b.ZodArray,..._(t)});function He(e){if(e instanceof Ue){let t={};for(let n in e.shape){let r=e.shape[n];t[n]=st.create(He(r))}return new Ue({...e._def,shape:()=>t})}else if(e instanceof Ve)return new Ve({...e._def,type:He(e.element)});else if(e instanceof st)return st.create(He(e.unwrap()));else if(e instanceof ct)return ct.create(He(e.unwrap()));else if(e instanceof Ye)return Ye.create(e.items.map(e=>He(e)));else return e}var Ue=class e extends v{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;let e=this._def.shape();return this._cached={shape:e,keys:t.objectKeys(e)},this._cached}_parse(e){if(this._getType(e)!==r.object){let t=this._getOrReturnCtx(e);return d(t,{code:a.invalid_type,expected:r.object,received:t.parsedType}),p}let{status:t,ctx:n}=this._processInputParams(e),{shape:i,keys:o}=this._getCached(),s=[];if(!(this._def.catchall instanceof ze&&this._def.unknownKeys===`strip`))for(let e in n.data)o.includes(e)||s.push(e);let c=[];for(let e of o){let t=i[e],r=n.data[e];c.push({key:{status:`valid`,value:e},value:t._parse(new ie(n,r,n.path,e)),alwaysSet:e in n.data})}if(this._def.catchall instanceof ze){let e=this._def.unknownKeys;if(e===`passthrough`)for(let e of s)c.push({key:{status:`valid`,value:e},value:{status:`valid`,value:n.data[e]}});else if(e===`strict`)s.length>0&&(d(n,{code:a.unrecognized_keys,keys:s}),t.dirty());else if(e!==`strip`)throw Error(`Internal ZodObject error: invalid unknownKeys value.`)}else{let e=this._def.catchall;for(let t of s){let r=n.data[t];c.push({key:{status:`valid`,value:t},value:e._parse(new ie(n,r,n.path,t)),alwaysSet:t in n.data})}}return n.common.async?Promise.resolve().then(async()=>{let e=[];for(let t of c){let n=await t.key,r=await t.value;e.push({key:n,value:r,alwaysSet:t.alwaysSet})}return e}).then(e=>f.mergeObjectSync(t,e)):f.mergeObjectSync(t,c)}get shape(){return this._def.shape()}strict(t){return g.errToObj,new e({...this._def,unknownKeys:`strict`,...t===void 0?{}:{errorMap:(e,n)=>{let r=this._def.errorMap?.(e,n).message??n.defaultError;return e.code===`unrecognized_keys`?{message:g.errToObj(t).message??r}:{message:r}}}})}strip(){return new e({...this._def,unknownKeys:`strip`})}passthrough(){return new e({...this._def,unknownKeys:`passthrough`})}extend(t){return new e({...this._def,shape:()=>({...this._def.shape(),...t})})}merge(t){return new e({unknownKeys:t._def.unknownKeys,catchall:t._def.catchall,shape:()=>({...this._def.shape(),...t._def.shape()}),typeName:b.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(t){return new e({...this._def,catchall:t})}pick(n){let r={};for(let e of t.objectKeys(n))n[e]&&this.shape[e]&&(r[e]=this.shape[e]);return new e({...this._def,shape:()=>r})}omit(n){let r={};for(let e of t.objectKeys(this.shape))n[e]||(r[e]=this.shape[e]);return new e({...this._def,shape:()=>r})}deepPartial(){return He(this)}partial(n){let r={};for(let e of t.objectKeys(this.shape)){let t=this.shape[e];n&&!n[e]?r[e]=t:r[e]=t.optional()}return new e({...this._def,shape:()=>r})}required(n){let r={};for(let e of t.objectKeys(this.shape))if(n&&!n[e])r[e]=this.shape[e];else{let t=this.shape[e];for(;t instanceof st;)t=t._def.innerType;r[e]=t}return new e({...this._def,shape:()=>r})}keyof(){return nt(t.objectKeys(this.shape))}};Ue.create=(e,t)=>new Ue({shape:()=>e,unknownKeys:`strip`,catchall:ze.create(),typeName:b.ZodObject,..._(t)}),Ue.strictCreate=(e,t)=>new Ue({shape:()=>e,unknownKeys:`strict`,catchall:ze.create(),typeName:b.ZodObject,..._(t)}),Ue.lazycreate=(e,t)=>new Ue({shape:e,unknownKeys:`strip`,catchall:ze.create(),typeName:b.ZodObject,..._(t)});var We=class extends v{_parse(e){let{ctx:t}=this._processInputParams(e),n=this._def.options;function r(e){for(let t of e)if(t.result.status===`valid`)return t.result;for(let n of e)if(n.result.status===`dirty`)return t.common.issues.push(...n.ctx.common.issues),n.result;let n=e.map(e=>new o(e.ctx.common.issues));return d(t,{code:a.invalid_union,unionErrors:n}),p}if(t.common.async)return Promise.all(n.map(async e=>{let n={...t,common:{...t.common,issues:[]},parent:null};return{result:await e._parseAsync({data:t.data,path:t.path,parent:n}),ctx:n}})).then(r);{let e,r=[];for(let i of n){let n={...t,common:{...t.common,issues:[]},parent:null},a=i._parseSync({data:t.data,path:t.path,parent:n});if(a.status===`valid`)return a;a.status===`dirty`&&!e&&(e={result:a,ctx:n}),n.common.issues.length&&r.push(n.common.issues)}if(e)return t.common.issues.push(...e.ctx.common.issues),e.result;let i=r.map(e=>new o(e));return d(t,{code:a.invalid_union,unionErrors:i}),p}}get options(){return this._def.options}};We.create=(e,t)=>new We({options:e,typeName:b.ZodUnion,..._(t)});let Ge=e=>e instanceof et?Ge(e.schema):e instanceof ot?Ge(e.innerType()):e instanceof tt?[e.value]:e instanceof rt?e.options:e instanceof it?t.objectValues(e.enum):e instanceof lt?Ge(e._def.innerType):e instanceof Ie?[void 0]:e instanceof y?[null]:e instanceof st?[void 0,...Ge(e.unwrap())]:e instanceof ct?[null,...Ge(e.unwrap())]:e instanceof ft||e instanceof mt?Ge(e.unwrap()):e instanceof ut?Ge(e._def.innerType):[];var Ke=class e extends v{_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==r.object)return d(t,{code:a.invalid_type,expected:r.object,received:t.parsedType}),p;let n=this.discriminator,i=t.data[n],o=this.optionsMap.get(i);return o?t.common.async?o._parseAsync({data:t.data,path:t.path,parent:t}):o._parseSync({data:t.data,path:t.path,parent:t}):(d(t,{code:a.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),p)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(t,n,r){let i=new Map;for(let e of n){let n=Ge(e.shape[t]);if(!n.length)throw Error(`A discriminator value for key \`${t}\` could not be extracted from all schema options`);for(let r of n){if(i.has(r))throw Error(`Discriminator property ${String(t)} has duplicate value ${String(r)}`);i.set(r,e)}}return new e({typeName:b.ZodDiscriminatedUnion,discriminator:t,options:n,optionsMap:i,..._(r)})}};function qe(e,n){let a=i(e),o=i(n);if(e===n)return{valid:!0,data:e};if(a===r.object&&o===r.object){let r=t.objectKeys(n),i=t.objectKeys(e).filter(e=>r.indexOf(e)!==-1),a={...e,...n};for(let t of i){let r=qe(e[t],n[t]);if(!r.valid)return{valid:!1};a[t]=r.data}return{valid:!0,data:a}}else if(a===r.array&&o===r.array){if(e.length!==n.length)return{valid:!1};let t=[];for(let r=0;r<e.length;r++){let i=e[r],a=n[r],o=qe(i,a);if(!o.valid)return{valid:!1};t.push(o.data)}return{valid:!0,data:t}}else if(a===r.date&&o===r.date&&+e==+n)return{valid:!0,data:e};else return{valid:!1}}var Je=class extends v{_parse(e){let{status:t,ctx:n}=this._processInputParams(e),r=(e,r)=>{if(ee(e)||ee(r))return p;let i=qe(e.value,r.value);return i.valid?((te(e)||te(r))&&t.dirty(),{status:t.value,value:i.data}):(d(n,{code:a.invalid_intersection_types}),p)};return n.common.async?Promise.all([this._def.left._parseAsync({data:n.data,path:n.path,parent:n}),this._def.right._parseAsync({data:n.data,path:n.path,parent:n})]).then(([e,t])=>r(e,t)):r(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}};Je.create=(e,t,n)=>new Je({left:e,right:t,typeName:b.ZodIntersection,..._(n)});var Ye=class e extends v{_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==r.array)return d(n,{code:a.invalid_type,expected:r.array,received:n.parsedType}),p;if(n.data.length<this._def.items.length)return d(n,{code:a.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:`array`}),p;!this._def.rest&&n.data.length>this._def.items.length&&(d(n,{code:a.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:`array`}),t.dirty());let i=[...n.data].map((e,t)=>{let r=this._def.items[t]||this._def.rest;return r?r._parse(new ie(n,e,n.path,t)):null}).filter(e=>!!e);return n.common.async?Promise.all(i).then(e=>f.mergeArray(t,e)):f.mergeArray(t,i)}get items(){return this._def.items}rest(t){return new e({...this._def,rest:t})}};Ye.create=(e,t)=>{if(!Array.isArray(e))throw Error(`You must pass an array of schemas to z.tuple([ ... ])`);return new Ye({items:e,typeName:b.ZodTuple,rest:null,..._(t)})};var Xe=class e extends v{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==r.object)return d(n,{code:a.invalid_type,expected:r.object,received:n.parsedType}),p;let i=[],o=this._def.keyType,s=this._def.valueType;for(let e in n.data)i.push({key:o._parse(new ie(n,e,n.path,e)),value:s._parse(new ie(n,n.data[e],n.path,e)),alwaysSet:e in n.data});return n.common.async?f.mergeObjectAsync(t,i):f.mergeObjectSync(t,i)}get element(){return this._def.valueType}static create(t,n,r){return n instanceof v?new e({keyType:t,valueType:n,typeName:b.ZodRecord,..._(r)}):new e({keyType:ke.create(),valueType:t,typeName:b.ZodRecord,..._(n)})}},Ze=class extends v{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==r.map)return d(n,{code:a.invalid_type,expected:r.map,received:n.parsedType}),p;let i=this._def.keyType,o=this._def.valueType,s=[...n.data.entries()].map(([e,t],r)=>({key:i._parse(new ie(n,e,n.path,[r,`key`])),value:o._parse(new ie(n,t,n.path,[r,`value`]))}));if(n.common.async){let e=new Map;return Promise.resolve().then(async()=>{for(let n of s){let r=await n.key,i=await n.value;if(r.status===`aborted`||i.status===`aborted`)return p;(r.status===`dirty`||i.status===`dirty`)&&t.dirty(),e.set(r.value,i.value)}return{status:t.value,value:e}})}else{let e=new Map;for(let n of s){let r=n.key,i=n.value;if(r.status===`aborted`||i.status===`aborted`)return p;(r.status===`dirty`||i.status===`dirty`)&&t.dirty(),e.set(r.value,i.value)}return{status:t.value,value:e}}}};Ze.create=(e,t,n)=>new Ze({valueType:t,keyType:e,typeName:b.ZodMap,..._(n)});var Qe=class e extends v{_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==r.set)return d(n,{code:a.invalid_type,expected:r.set,received:n.parsedType}),p;let i=this._def;i.minSize!==null&&n.data.size<i.minSize.value&&(d(n,{code:a.too_small,minimum:i.minSize.value,type:`set`,inclusive:!0,exact:!1,message:i.minSize.message}),t.dirty()),i.maxSize!==null&&n.data.size>i.maxSize.value&&(d(n,{code:a.too_big,maximum:i.maxSize.value,type:`set`,inclusive:!0,exact:!1,message:i.maxSize.message}),t.dirty());let o=this._def.valueType;function s(e){let n=new Set;for(let r of e){if(r.status===`aborted`)return p;r.status===`dirty`&&t.dirty(),n.add(r.value)}return{status:t.value,value:n}}let c=[...n.data.values()].map((e,t)=>o._parse(new ie(n,e,n.path,t)));return n.common.async?Promise.all(c).then(e=>s(e)):s(c)}min(t,n){return new e({...this._def,minSize:{value:t,message:g.toString(n)}})}max(t,n){return new e({...this._def,maxSize:{value:t,message:g.toString(n)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}};Qe.create=(e,t)=>new Qe({valueType:e,minSize:null,maxSize:null,typeName:b.ZodSet,..._(t)});var $e=class e extends v{constructor(){super(...arguments),this.validate=this.implement}_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==r.function)return d(t,{code:a.invalid_type,expected:r.function,received:t.parsedType}),p;function n(e,n){return u({data:e,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,l(),s].filter(e=>!!e),issueData:{code:a.invalid_arguments,argumentsError:n}})}function i(e,n){return u({data:e,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,l(),s].filter(e=>!!e),issueData:{code:a.invalid_return_type,returnTypeError:n}})}let c={errorMap:t.common.contextualErrorMap},f=t.data;if(this._def.returns instanceof at){let e=this;return h(async function(...t){let r=new o([]),a=await e._def.args.parseAsync(t,c).catch(e=>{throw r.addIssue(n(t,e)),r}),s=await Reflect.apply(f,this,a);return await e._def.returns._def.type.parseAsync(s,c).catch(e=>{throw r.addIssue(i(s,e)),r})})}else{let e=this;return h(function(...t){let r=e._def.args.safeParse(t,c);if(!r.success)throw new o([n(t,r.error)]);let a=Reflect.apply(f,this,r.data),s=e._def.returns.safeParse(a,c);if(!s.success)throw new o([i(a,s.error)]);return s.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...t){return new e({...this._def,args:Ye.create(t).rest(Re.create())})}returns(t){return new e({...this._def,returns:t})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(t,n,r){return new e({args:t||Ye.create([]).rest(Re.create()),returns:n||Re.create(),typeName:b.ZodFunction,..._(r)})}},et=class extends v{get schema(){return this._def.getter()}_parse(e){let{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}};et.create=(e,t)=>new et({getter:e,typeName:b.ZodLazy,..._(t)});var tt=class extends v{_parse(e){if(e.data!==this._def.value){let t=this._getOrReturnCtx(e);return d(t,{received:t.data,code:a.invalid_literal,expected:this._def.value}),p}return{status:`valid`,value:e.data}}get value(){return this._def.value}};tt.create=(e,t)=>new tt({value:e,typeName:b.ZodLiteral,..._(t)});function nt(e,t){return new rt({values:e,typeName:b.ZodEnum,..._(t)})}var rt=class e extends v{_parse(e){if(typeof e.data!=`string`){let n=this._getOrReturnCtx(e),r=this._def.values;return d(n,{expected:t.joinValues(r),received:n.parsedType,code:a.invalid_type}),p}if(this._cache||=new Set(this._def.values),!this._cache.has(e.data)){let t=this._getOrReturnCtx(e),n=this._def.values;return d(t,{received:t.data,code:a.invalid_enum_value,options:n}),p}return h(e.data)}get options(){return this._def.values}get enum(){let e={};for(let t of this._def.values)e[t]=t;return e}get Values(){let e={};for(let t of this._def.values)e[t]=t;return e}get Enum(){let e={};for(let t of this._def.values)e[t]=t;return e}extract(t,n=this._def){return e.create(t,{...this._def,...n})}exclude(t,n=this._def){return e.create(this.options.filter(e=>!t.includes(e)),{...this._def,...n})}};rt.create=nt;var it=class extends v{_parse(e){let n=t.getValidEnumValues(this._def.values),i=this._getOrReturnCtx(e);if(i.parsedType!==r.string&&i.parsedType!==r.number){let e=t.objectValues(n);return d(i,{expected:t.joinValues(e),received:i.parsedType,code:a.invalid_type}),p}if(this._cache||=new Set(t.getValidEnumValues(this._def.values)),!this._cache.has(e.data)){let e=t.objectValues(n);return d(i,{received:i.data,code:a.invalid_enum_value,options:e}),p}return h(e.data)}get enum(){return this._def.values}};it.create=(e,t)=>new it({values:e,typeName:b.ZodNativeEnum,..._(t)});var at=class extends v{unwrap(){return this._def.type}_parse(e){let{ctx:t}=this._processInputParams(e);return t.parsedType!==r.promise&&t.common.async===!1?(d(t,{code:a.invalid_type,expected:r.promise,received:t.parsedType}),p):h((t.parsedType===r.promise?t.data:Promise.resolve(t.data)).then(e=>this._def.type.parseAsync(e,{path:t.path,errorMap:t.common.contextualErrorMap})))}};at.create=(e,t)=>new at({type:e,typeName:b.ZodPromise,..._(t)});var ot=class extends v{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===b.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){let{status:n,ctx:r}=this._processInputParams(e),i=this._def.effect||null,a={addIssue:e=>{d(r,e),e.fatal?n.abort():n.dirty()},get path(){return r.path}};if(a.addIssue=a.addIssue.bind(a),i.type===`preprocess`){let e=i.transform(r.data,a);if(r.common.async)return Promise.resolve(e).then(async e=>{if(n.value===`aborted`)return p;let t=await this._def.schema._parseAsync({data:e,path:r.path,parent:r});return t.status===`aborted`?p:t.status===`dirty`||n.value===`dirty`?m(t.value):t});{if(n.value===`aborted`)return p;let t=this._def.schema._parseSync({data:e,path:r.path,parent:r});return t.status===`aborted`?p:t.status===`dirty`||n.value===`dirty`?m(t.value):t}}if(i.type===`refinement`){let e=e=>{let t=i.refinement(e,a);if(r.common.async)return Promise.resolve(t);if(t instanceof Promise)throw Error(`Async refinement encountered during synchronous parse operation. Use .parseAsync instead.`);return e};if(r.common.async===!1){let t=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});return t.status===`aborted`?p:(t.status===`dirty`&&n.dirty(),e(t.value),{status:n.value,value:t.value})}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(t=>t.status===`aborted`?p:(t.status===`dirty`&&n.dirty(),e(t.value).then(()=>({status:n.value,value:t.value}))))}if(i.type===`transform`)if(r.common.async===!1){let e=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});if(!ne(e))return p;let t=i.transform(e.value,a);if(t instanceof Promise)throw Error(`Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.`);return{status:n.value,value:t}}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(e=>ne(e)?Promise.resolve(i.transform(e.value,a)).then(e=>({status:n.value,value:e})):p);t.assertNever(i)}};ot.create=(e,t,n)=>new ot({schema:e,typeName:b.ZodEffects,effect:t,..._(n)}),ot.createWithPreprocess=(e,t,n)=>new ot({schema:t,effect:{type:`preprocess`,transform:e},typeName:b.ZodEffects,..._(n)});var st=class extends v{_parse(e){return this._getType(e)===r.undefined?h(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};st.create=(e,t)=>new st({innerType:e,typeName:b.ZodOptional,..._(t)});var ct=class extends v{_parse(e){return this._getType(e)===r.null?h(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};ct.create=(e,t)=>new ct({innerType:e,typeName:b.ZodNullable,..._(t)});var lt=class extends v{_parse(e){let{ctx:t}=this._processInputParams(e),n=t.data;return t.parsedType===r.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:t.path,parent:t})}removeDefault(){return this._def.innerType}};lt.create=(e,t)=>new lt({innerType:e,typeName:b.ZodDefault,defaultValue:typeof t.default==`function`?t.default:()=>t.default,..._(t)});var ut=class extends v{_parse(e){let{ctx:t}=this._processInputParams(e),n={...t,common:{...t.common,issues:[]}},r=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return re(r)?r.then(e=>({status:`valid`,value:e.status===`valid`?e.value:this._def.catchValue({get error(){return new o(n.common.issues)},input:n.data})})):{status:`valid`,value:r.status===`valid`?r.value:this._def.catchValue({get error(){return new o(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}};ut.create=(e,t)=>new ut({innerType:e,typeName:b.ZodCatch,catchValue:typeof t.catch==`function`?t.catch:()=>t.catch,..._(t)});var dt=class extends v{_parse(e){if(this._getType(e)!==r.nan){let t=this._getOrReturnCtx(e);return d(t,{code:a.invalid_type,expected:r.nan,received:t.parsedType}),p}return{status:`valid`,value:e.data}}};dt.create=e=>new dt({typeName:b.ZodNaN,..._(e)});var ft=class extends v{_parse(e){let{ctx:t}=this._processInputParams(e),n=t.data;return this._def.type._parse({data:n,path:t.path,parent:t})}unwrap(){return this._def.type}},pt=class e extends v{_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.common.async)return(async()=>{let e=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return e.status===`aborted`?p:e.status===`dirty`?(t.dirty(),m(e.value)):this._def.out._parseAsync({data:e.value,path:n.path,parent:n})})();{let e=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return e.status===`aborted`?p:e.status===`dirty`?(t.dirty(),{status:`dirty`,value:e.value}):this._def.out._parseSync({data:e.value,path:n.path,parent:n})}}static create(t,n){return new e({in:t,out:n,typeName:b.ZodPipeline})}},mt=class extends v{_parse(e){let t=this._def.innerType._parse(e),n=e=>(ne(e)&&(e.value=Object.freeze(e.value)),e);return re(t)?t.then(e=>n(e)):n(t)}unwrap(){return this._def.innerType}};mt.create=(e,t)=>new mt({innerType:e,typeName:b.ZodReadonly,..._(t)}),Ue.lazycreate;var b;(function(e){e.ZodString=`ZodString`,e.ZodNumber=`ZodNumber`,e.ZodNaN=`ZodNaN`,e.ZodBigInt=`ZodBigInt`,e.ZodBoolean=`ZodBoolean`,e.ZodDate=`ZodDate`,e.ZodSymbol=`ZodSymbol`,e.ZodUndefined=`ZodUndefined`,e.ZodNull=`ZodNull`,e.ZodAny=`ZodAny`,e.ZodUnknown=`ZodUnknown`,e.ZodNever=`ZodNever`,e.ZodVoid=`ZodVoid`,e.ZodArray=`ZodArray`,e.ZodObject=`ZodObject`,e.ZodUnion=`ZodUnion`,e.ZodDiscriminatedUnion=`ZodDiscriminatedUnion`,e.ZodIntersection=`ZodIntersection`,e.ZodTuple=`ZodTuple`,e.ZodRecord=`ZodRecord`,e.ZodMap=`ZodMap`,e.ZodSet=`ZodSet`,e.ZodFunction=`ZodFunction`,e.ZodLazy=`ZodLazy`,e.ZodLiteral=`ZodLiteral`,e.ZodEnum=`ZodEnum`,e.ZodEffects=`ZodEffects`,e.ZodNativeEnum=`ZodNativeEnum`,e.ZodOptional=`ZodOptional`,e.ZodNullable=`ZodNullable`,e.ZodDefault=`ZodDefault`,e.ZodCatch=`ZodCatch`,e.ZodPromise=`ZodPromise`,e.ZodBranded=`ZodBranded`,e.ZodPipeline=`ZodPipeline`,e.ZodReadonly=`ZodReadonly`})(b||={}),ke.create,je.create,dt.create,Me.create,Ne.create,Pe.create,Fe.create,Ie.create,y.create,Le.create,Re.create,ze.create,Be.create,Ve.create;let ht=Ue.create;Ue.strictCreate,We.create,Ke.create,Je.create,Ye.create,Xe.create,Ze.create,Qe.create,$e.create,et.create,tt.create,rt.create,it.create,at.create,ot.create,st.create,ct.create,ot.createWithPreprocess,pt.create,Object.freeze({status:`aborted`});function x(e,t,n){function r(n,r){if(n._zod||Object.defineProperty(n,`_zod`,{value:{def:r,constr:o,traits:new Set},enumerable:!1}),n._zod.traits.has(e))return;n._zod.traits.add(e),t(n,r);let i=o.prototype,a=Object.keys(i);for(let e=0;e<a.length;e++){let t=a[e];t in n||(n[t]=i[t].bind(n))}}let i=n?.Parent??Object;class a extends i{}Object.defineProperty(a,`name`,{value:e});function o(e){var t;let i=n?.Parent?new a:this;r(i,e),(t=i._zod).deferred??(t.deferred=[]);for(let e of i._zod.deferred)e();return i}return Object.defineProperty(o,`init`,{value:r}),Object.defineProperty(o,Symbol.hasInstance,{value:t=>n?.Parent&&t instanceof n.Parent?!0:t?._zod?.traits?.has(e)}),Object.defineProperty(o,`name`,{value:e}),o}var gt=class extends Error{constructor(){super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`)}},_t=class extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name=`ZodEncodeError`}};let vt={};function yt(e){return e&&Object.assign(vt,e),vt}function bt(e){let t=Object.values(e).filter(e=>typeof e==`number`);return Object.entries(e).filter(([e,n])=>t.indexOf(+e)===-1).map(([e,t])=>t)}function xt(e,t){return typeof t==`bigint`?t.toString():t}function St(e){return{get value(){{let t=e();return Object.defineProperty(this,`value`,{value:t}),t}throw Error(`cached value already set`)}}}function Ct(e){return e==null}function wt(e){let t=e.startsWith(`^`)?1:0,n=e.endsWith(`$`)?e.length-1:e.length;return e.slice(t,n)}function Tt(e,t){let n=(e.toString().split(`.`)[1]||``).length,r=t.toString(),i=(r.split(`.`)[1]||``).length;if(i===0&&/\d?e-\d?/.test(r)){let e=r.match(/\d?e-(\d?)/);e?.[1]&&(i=Number.parseInt(e[1]))}let a=n>i?n:i;return Number.parseInt(e.toFixed(a).replace(`.`,``))%Number.parseInt(t.toFixed(a).replace(`.`,``))/10**a}let Et=Symbol(`evaluating`);function S(e,t,n){let r;Object.defineProperty(e,t,{get(){if(r!==Et)return r===void 0&&(r=Et,r=n()),r},set(n){Object.defineProperty(e,t,{value:n})},configurable:!0})}function Dt(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function Ot(...e){let t={};for(let n of e){let e=Object.getOwnPropertyDescriptors(n);Object.assign(t,e)}return Object.defineProperties({},t)}function kt(e){return JSON.stringify(e)}function At(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,``).replace(/[\s_-]+/g,`-`).replace(/^-+|-+$/g,``)}let jt=`captureStackTrace`in Error?Error.captureStackTrace:(...e)=>{};function Mt(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}let Nt=St(()=>{if(typeof navigator<`u`&&navigator?.userAgent?.includes(`Cloudflare`))return!1;try{return Function(``),!0}catch{return!1}});function Pt(e){if(Mt(e)===!1)return!1;let t=e.constructor;if(t===void 0||typeof t!=`function`)return!0;let n=t.prototype;return!(Mt(n)===!1||Object.prototype.hasOwnProperty.call(n,`isPrototypeOf`)===!1)}function Ft(e){return Pt(e)?{...e}:Array.isArray(e)?[...e]:e}let It=new Set([`string`,`number`,`symbol`]);function Lt(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function Rt(e,t,n){let r=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(r._zod.parent=e),r}function C(e){let t=e;if(!t)return{};if(typeof t==`string`)return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error==`string`?{...t,error:()=>t.error}:t}function zt(e){return Object.keys(e).filter(t=>e[t]._zod.optin===`optional`&&e[t]._zod.optout===`optional`)}let Bt={safeint:[-(2**53-1),2**53-1],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function Vt(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw Error(`.pick() cannot be used on object schemas containing refinements`);return Rt(e,Ot(e._zod.def,{get shape(){let e={};for(let r in t){if(!(r in n.shape))throw Error(`Unrecognized key: "${r}"`);t[r]&&(e[r]=n.shape[r])}return Dt(this,`shape`,e),e},checks:[]}))}function Ht(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw Error(`.omit() cannot be used on object schemas containing refinements`);return Rt(e,Ot(e._zod.def,{get shape(){let r={...e._zod.def.shape};for(let e in t){if(!(e in n.shape))throw Error(`Unrecognized key: "${e}"`);t[e]&&delete r[e]}return Dt(this,`shape`,r),r},checks:[]}))}function Ut(e,t){if(!Pt(t))throw Error(`Invalid input to extend: expected a plain object`);let n=e._zod.def.checks;if(n&&n.length>0){let n=e._zod.def.shape;for(let e in t)if(Object.getOwnPropertyDescriptor(n,e)!==void 0)throw Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}return Rt(e,Ot(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t};return Dt(this,`shape`,n),n}}))}function Wt(e,t){if(!Pt(t))throw Error(`Invalid input to safeExtend: expected a plain object`);return Rt(e,Ot(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t};return Dt(this,`shape`,n),n}}))}function Gt(e,t){return Rt(e,Ot(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t._zod.def.shape};return Dt(this,`shape`,n),n},get catchall(){return t._zod.def.catchall},checks:[]}))}function Kt(e,t,n){let r=t._zod.def.checks;if(r&&r.length>0)throw Error(`.partial() cannot be used on object schemas containing refinements`);return Rt(t,Ot(t._zod.def,{get shape(){let r=t._zod.def.shape,i={...r};if(n)for(let t in n){if(!(t in r))throw Error(`Unrecognized key: "${t}"`);n[t]&&(i[t]=e?new e({type:`optional`,innerType:r[t]}):r[t])}else for(let t in r)i[t]=e?new e({type:`optional`,innerType:r[t]}):r[t];return Dt(this,`shape`,i),i},checks:[]}))}function qt(e,t,n){return Rt(t,Ot(t._zod.def,{get shape(){let r=t._zod.def.shape,i={...r};if(n)for(let t in n){if(!(t in i))throw Error(`Unrecognized key: "${t}"`);n[t]&&(i[t]=new e({type:`nonoptional`,innerType:r[t]}))}else for(let t in r)i[t]=new e({type:`nonoptional`,innerType:r[t]});return Dt(this,`shape`,i),i}}))}function Jt(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue!==!0)return!0;return!1}function Yt(e,t){return t.map(t=>{var n;return(n=t).path??(n.path=[]),t.path.unshift(e),t})}function Xt(e){return typeof e==`string`?e:e?.message}function Zt(e,t,n){let r={...e,path:e.path??[]};return e.message||(r.message=Xt(e.inst?._zod.def?.error?.(e))??Xt(t?.error?.(e))??Xt(n.customError?.(e))??Xt(n.localeError?.(e))??`Invalid input`),delete r.inst,delete r.continue,t?.reportInput||delete r.input,r}function Qt(e){return Array.isArray(e)?`array`:typeof e==`string`?`string`:`unknown`}function $t(...e){let[t,n,r]=e;return typeof t==`string`?{message:t,code:`custom`,input:n,inst:r}:{...t}}let en=(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,xt,2),Object.defineProperty(e,`toString`,{value:()=>e.message,enumerable:!1})},tn=x(`$ZodError`,en),nn=x(`$ZodError`,en,{Parent:Error});function rn(e,t=e=>e.message){let n={},r=[];for(let i of e.issues)i.path.length>0?(n[i.path[0]]=n[i.path[0]]||[],n[i.path[0]].push(t(i))):r.push(t(i));return{formErrors:r,fieldErrors:n}}function an(e,t=e=>e.message){let n={_errors:[]},r=e=>{for(let i of e.issues)if(i.code===`invalid_union`&&i.errors.length)i.errors.map(e=>r({issues:e}));else if(i.code===`invalid_key`)r({issues:i.issues});else if(i.code===`invalid_element`)r({issues:i.issues});else if(i.path.length===0)n._errors.push(t(i));else{let e=n,r=0;for(;r<i.path.length;){let n=i.path[r];r===i.path.length-1?(e[n]=e[n]||{_errors:[]},e[n]._errors.push(t(i))):e[n]=e[n]||{_errors:[]},e=e[n],r++}}};return r(e),n}let on=e=>(t,n,r,i)=>{let a=r?Object.assign(r,{async:!1}):{async:!1},o=t._zod.run({value:n,issues:[]},a);if(o instanceof Promise)throw new gt;if(o.issues.length){let t=new(i?.Err??e)(o.issues.map(e=>Zt(e,a,yt())));throw jt(t,i?.callee),t}return o.value},sn=on(nn),cn=e=>async(t,n,r,i)=>{let a=r?Object.assign(r,{async:!0}):{async:!0},o=t._zod.run({value:n,issues:[]},a);if(o instanceof Promise&&(o=await o),o.issues.length){let t=new(i?.Err??e)(o.issues.map(e=>Zt(e,a,yt())));throw jt(t,i?.callee),t}return o.value},ln=cn(nn),un=e=>(t,n,r)=>{let i=r?{...r,async:!1}:{async:!1},a=t._zod.run({value:n,issues:[]},i);if(a instanceof Promise)throw new gt;return a.issues.length?{success:!1,error:new(e??tn)(a.issues.map(e=>Zt(e,i,yt())))}:{success:!0,data:a.value}},dn=un(nn),fn=e=>async(t,n,r)=>{let i=r?Object.assign(r,{async:!0}):{async:!0},a=t._zod.run({value:n,issues:[]},i);return a instanceof Promise&&(a=await a),a.issues.length?{success:!1,error:new e(a.issues.map(e=>Zt(e,i,yt())))}:{success:!0,data:a.value}},pn=fn(nn),mn=e=>(t,n,r)=>{let i=r?Object.assign(r,{direction:`backward`}):{direction:`backward`};return on(e)(t,n,i)},hn=e=>(t,n,r)=>on(e)(t,n,r),gn=e=>async(t,n,r)=>{let i=r?Object.assign(r,{direction:`backward`}):{direction:`backward`};return cn(e)(t,n,i)},_n=e=>async(t,n,r)=>cn(e)(t,n,r),vn=e=>(t,n,r)=>{let i=r?Object.assign(r,{direction:`backward`}):{direction:`backward`};return un(e)(t,n,i)},yn=e=>(t,n,r)=>un(e)(t,n,r),bn=e=>async(t,n,r)=>{let i=r?Object.assign(r,{direction:`backward`}):{direction:`backward`};return fn(e)(t,n,i)},xn=e=>async(t,n,r)=>fn(e)(t,n,r),Sn=/^[cC][^\s-]{8,}$/,Cn=/^[0-9a-z]+$/,wn=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,Tn=/^[0-9a-vA-V]{20}$/,En=/^[A-Za-z0-9]{27}$/,Dn=/^[a-zA-Z0-9_-]{21}$/,On=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,kn=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,An=e=>e?RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,jn=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;function Mn(){return RegExp(`^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`,`u`)}let Nn=/^(?:(?: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])$/,Pn=/^(([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}|:))$/,Fn=/^((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])$/,In=/^(([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])$/,Ln=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Rn=/^[A-Za-z0-9_-]*$/,zn=/^\+[1-9]\d{6,14}$/,Bn=`(?:(?:\\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])))`,Vn=RegExp(`^${Bn}$`);function Hn(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 Un(e){return RegExp(`^${Hn(e)}$`)}function Wn(e){let t=Hn({precision:e.precision}),n=[`Z`];e.local&&n.push(``),e.offset&&n.push(`([+-](?:[01]\\d|2[0-3]):[0-5]\\d)`);let r=`${t}(?:${n.join(`|`)})`;return RegExp(`^${Bn}T(?:${r})$`)}let Gn=e=>{let t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??``}}`:`[\\s\\S]*`;return RegExp(`^${t}$`)},Kn=/^-?\d+$/,qn=/^-?\d+(?:\.\d+)?$/,Jn=/^(?:true|false)$/i,Yn=/^null$/i,Xn=/^[^A-Z]*$/,Zn=/^[^a-z]*$/,w=x(`$ZodCheck`,(e,t)=>{var n;e._zod??={},e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),Qn={number:`number`,bigint:`bigint`,object:`date`},$n=x(`$ZodCheckLessThan`,(e,t)=>{w.init(e,t);let n=Qn[typeof t.value];e._zod.onattach.push(e=>{let n=e._zod.bag,r=(t.inclusive?n.maximum:n.exclusiveMaximum)??1/0;t.value<r&&(t.inclusive?n.maximum=t.value:n.exclusiveMaximum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value<=t.value:r.value<t.value)||r.issues.push({origin:n,code:`too_big`,maximum:typeof t.value==`object`?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),er=x(`$ZodCheckGreaterThan`,(e,t)=>{w.init(e,t);let n=Qn[typeof t.value];e._zod.onattach.push(e=>{let n=e._zod.bag,r=(t.inclusive?n.minimum:n.exclusiveMinimum)??-1/0;t.value>r&&(t.inclusive?n.minimum=t.value:n.exclusiveMinimum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value>=t.value:r.value>t.value)||r.issues.push({origin:n,code:`too_small`,minimum:typeof t.value==`object`?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),tr=x(`$ZodCheckMultipleOf`,(e,t)=>{w.init(e,t),e._zod.onattach.push(e=>{var n;(n=e._zod.bag).multipleOf??(n.multipleOf=t.value)}),e._zod.check=n=>{if(typeof n.value!=typeof t.value)throw Error(`Cannot mix number and bigint in multiple_of check.`);(typeof n.value==`bigint`?n.value%t.value===BigInt(0):Tt(n.value,t.value)===0)||n.issues.push({origin:typeof n.value,code:`not_multiple_of`,divisor:t.value,input:n.value,inst:e,continue:!t.abort})}}),nr=x(`$ZodCheckNumberFormat`,(e,t)=>{w.init(e,t),t.format=t.format||`float64`;let n=t.format?.includes(`int`),r=n?`int`:`number`,[i,a]=Bt[t.format];e._zod.onattach.push(e=>{let r=e._zod.bag;r.format=t.format,r.minimum=i,r.maximum=a,n&&(r.pattern=Kn)}),e._zod.check=o=>{let s=o.value;if(n){if(!Number.isInteger(s)){o.issues.push({expected:r,format:t.format,code:`invalid_type`,continue:!1,input:s,inst:e});return}if(!Number.isSafeInteger(s)){s>0?o.issues.push({input:s,code:`too_big`,maximum:2**53-1,note:`Integers must be within the safe integer range.`,inst:e,origin:r,inclusive:!0,continue:!t.abort}):o.issues.push({input:s,code:`too_small`,minimum:-(2**53-1),note:`Integers must be within the safe integer range.`,inst:e,origin:r,inclusive:!0,continue:!t.abort});return}}s<i&&o.issues.push({origin:`number`,input:s,code:`too_small`,minimum:i,inclusive:!0,inst:e,continue:!t.abort}),s>a&&o.issues.push({origin:`number`,input:s,code:`too_big`,maximum:a,inclusive:!0,inst:e,continue:!t.abort})}}),rr=x(`$ZodCheckMaxLength`,(e,t)=>{var n;w.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!Ct(t)&&t.length!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag.maximum??1/0;t.maximum<n&&(e._zod.bag.maximum=t.maximum)}),e._zod.check=n=>{let r=n.value;if(r.length<=t.maximum)return;let i=Qt(r);n.issues.push({origin:i,code:`too_big`,maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),ir=x(`$ZodCheckMinLength`,(e,t)=>{var n;w.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!Ct(t)&&t.length!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag.minimum??-1/0;t.minimum>n&&(e._zod.bag.minimum=t.minimum)}),e._zod.check=n=>{let r=n.value;if(r.length>=t.minimum)return;let i=Qt(r);n.issues.push({origin:i,code:`too_small`,minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),ar=x(`$ZodCheckLengthEquals`,(e,t)=>{var n;w.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!Ct(t)&&t.length!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag;n.minimum=t.length,n.maximum=t.length,n.length=t.length}),e._zod.check=n=>{let r=n.value,i=r.length;if(i===t.length)return;let a=Qt(r),o=i>t.length;n.issues.push({origin:a,...o?{code:`too_big`,maximum:t.length}:{code:`too_small`,minimum:t.length},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}}),or=x(`$ZodCheckStringFormat`,(e,t)=>{var n,r;w.init(e,t),e._zod.onattach.push(e=>{let n=e._zod.bag;n.format=t.format,t.pattern&&(n.patterns??=new Set,n.patterns.add(t.pattern))}),t.pattern?(n=e._zod).check??(n.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:`string`,code:`invalid_format`,format:t.format,input:n.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(r=e._zod).check??(r.check=()=>{})}),sr=x(`$ZodCheckRegex`,(e,t)=>{or.init(e,t),e._zod.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:`string`,code:`invalid_format`,format:`regex`,input:n.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),cr=x(`$ZodCheckLowerCase`,(e,t)=>{t.pattern??=Xn,or.init(e,t)}),lr=x(`$ZodCheckUpperCase`,(e,t)=>{t.pattern??=Zn,or.init(e,t)}),ur=x(`$ZodCheckIncludes`,(e,t)=>{w.init(e,t);let n=Lt(t.includes),r=new RegExp(typeof t.position==`number`?`^.{${t.position}}${n}`:n);t.pattern=r,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=new Set,t.patterns.add(r)}),e._zod.check=n=>{n.value.includes(t.includes,t.position)||n.issues.push({origin:`string`,code:`invalid_format`,format:`includes`,includes:t.includes,input:n.value,inst:e,continue:!t.abort})}}),dr=x(`$ZodCheckStartsWith`,(e,t)=>{w.init(e,t);let n=RegExp(`^${Lt(t.prefix)}.*`);t.pattern??=n,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=new Set,t.patterns.add(n)}),e._zod.check=n=>{n.value.startsWith(t.prefix)||n.issues.push({origin:`string`,code:`invalid_format`,format:`starts_with`,prefix:t.prefix,input:n.value,inst:e,continue:!t.abort})}}),fr=x(`$ZodCheckEndsWith`,(e,t)=>{w.init(e,t);let n=RegExp(`.*${Lt(t.suffix)}$`);t.pattern??=n,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=new Set,t.patterns.add(n)}),e._zod.check=n=>{n.value.endsWith(t.suffix)||n.issues.push({origin:`string`,code:`invalid_format`,format:`ends_with`,suffix:t.suffix,input:n.value,inst:e,continue:!t.abort})}}),pr=x(`$ZodCheckOverwrite`,(e,t)=>{w.init(e,t),e._zod.check=e=>{e.value=t.tx(e.value)}});var mr=class{constructor(e=[]){this.content=[],this.indent=0,this&&(this.args=e)}indented(e){this.indent+=1,e(this),--this.indent}write(e){if(typeof e==`function`){e(this,{execution:`sync`}),e(this,{execution:`async`});return}let t=e.split(`
3
2
  `).filter(e=>e),n=Math.min(...t.map(e=>e.length-e.trimStart().length)),r=t.map(e=>e.slice(n)).map(e=>` `.repeat(this.indent*2)+e);for(let e of r)this.content.push(e)}compile(){let e=Function,t=this?.args,n=[...(this?.content??[``]).map(e=>` ${e}`)];return new e(...t,n.join(`
4
- `))}};let zi={major:4,minor:3,patch:5},A=D(`$ZodType`,(e,t)=>{var n;e??={},e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=zi;let r=[...e._zod.def.checks??[]];e._zod.traits.has(`$ZodCheck`)&&r.unshift(e);for(let t of r)for(let n of t._zod.onattach)n(e);if(r.length===0)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let t=(e,t,n)=>{let r=vr(e),i;for(let a of t){if(a._zod.def.when){if(!a._zod.def.when(e))continue}else if(r)continue;let t=e.issues.length,o=a._zod.check(e);if(o instanceof Promise&&n?.async===!1)throw new Bn;if(i||o instanceof Promise)i=(i??Promise.resolve()).then(async()=>{await o,e.issues.length!==t&&(r||=vr(e,t))});else{if(e.issues.length===t)continue;r||=vr(e,t)}}return i?i.then(()=>e):e},n=(n,i,a)=>{if(vr(n))return n.aborted=!0,n;let o=t(i,r,a);if(o instanceof Promise){if(a.async===!1)throw new Bn;return o.then(t=>e._zod.parse(t,a))}return e._zod.parse(o,a)};e._zod.run=(i,a)=>{if(a.skipChecks)return e._zod.parse(i,a);if(a.direction===`backward`){let t=e._zod.parse({value:i.value,issues:[]},{...a,skipChecks:!0});return t instanceof Promise?t.then(e=>n(e,i,a)):n(t,i,a)}let o=e._zod.parse(i,a);if(o instanceof Promise){if(a.async===!1)throw new Bn;return o.then(e=>t(e,r,a))}return t(o,r,a)}}O(e,`~standard`,()=>({validate:t=>{try{let n=Pr(e,t);return n.success?{value:n.data}:{issues:n.error?.issues}}catch{return Ir(e,t).then(e=>e.success?{value:e.data}:{issues:e.error?.issues})}},vendor:`zod`,version:1}))}),Bi=D(`$ZodString`,(e,t)=>{A.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??mi(e._zod.bag),e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=String(n.value)}catch{}return typeof n.value==`string`||n.issues.push({expected:`string`,code:`invalid_type`,input:n.value,inst:e}),n}}),j=D(`$ZodStringFormat`,(e,t)=>{Ai.init(e,t),Bi.init(e,t)}),Vi=D(`$ZodGUID`,(e,t)=>{t.pattern??=Qr,j.init(e,t)}),Hi=D(`$ZodUUID`,(e,t)=>{if(t.version){let e={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(e===void 0)throw Error(`Invalid UUID version: "${t.version}"`);t.pattern??=$r(e)}else t.pattern??=$r();j.init(e,t)}),Ui=D(`$ZodEmail`,(e,t)=>{t.pattern??=ei,j.init(e,t)}),Wi=D(`$ZodURL`,(e,t)=>{j.init(e,t),e._zod.check=n=>{try{let r=n.value.trim(),i=new URL(r);t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(i.hostname)||n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid hostname`,pattern:t.hostname.source,input:n.value,inst:e,continue:!t.abort})),t.protocol&&(t.protocol.lastIndex=0,t.protocol.test(i.protocol.endsWith(`:`)?i.protocol.slice(0,-1):i.protocol)||n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid protocol`,pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort})),t.normalize?n.value=i.href:n.value=r;return}catch{n.issues.push({code:`invalid_format`,format:`url`,input:n.value,inst:e,continue:!t.abort})}}}),Gi=D(`$ZodEmoji`,(e,t)=>{t.pattern??=ti(),j.init(e,t)}),Ki=D(`$ZodNanoID`,(e,t)=>{t.pattern??=Xr,j.init(e,t)}),qi=D(`$ZodCUID`,(e,t)=>{t.pattern??=Gr,j.init(e,t)}),Ji=D(`$ZodCUID2`,(e,t)=>{t.pattern??=Kr,j.init(e,t)}),Yi=D(`$ZodULID`,(e,t)=>{t.pattern??=qr,j.init(e,t)}),Xi=D(`$ZodXID`,(e,t)=>{t.pattern??=Jr,j.init(e,t)}),Zi=D(`$ZodKSUID`,(e,t)=>{t.pattern??=Yr,j.init(e,t)}),Qi=D(`$ZodISODateTime`,(e,t)=>{t.pattern??=pi(t),j.init(e,t)}),$i=D(`$ZodISODate`,(e,t)=>{t.pattern??=ui,j.init(e,t)}),ea=D(`$ZodISOTime`,(e,t)=>{t.pattern??=fi(t),j.init(e,t)}),ta=D(`$ZodISODuration`,(e,t)=>{t.pattern??=Zr,j.init(e,t)}),na=D(`$ZodIPv4`,(e,t)=>{t.pattern??=ni,j.init(e,t),e._zod.bag.format=`ipv4`}),ra=D(`$ZodIPv6`,(e,t)=>{t.pattern??=ri,j.init(e,t),e._zod.bag.format=`ipv6`,e._zod.check=n=>{try{new URL(`http://[${n.value}]`)}catch{n.issues.push({code:`invalid_format`,format:`ipv6`,input:n.value,inst:e,continue:!t.abort})}}}),ia=D(`$ZodCIDRv4`,(e,t)=>{t.pattern??=ii,j.init(e,t)}),aa=D(`$ZodCIDRv6`,(e,t)=>{t.pattern??=ai,j.init(e,t),e._zod.check=n=>{let r=n.value.split(`/`);try{if(r.length!==2)throw Error();let[e,t]=r;if(!t)throw Error();let n=Number(t);if(`${n}`!==t||n<0||n>128)throw Error();new URL(`http://[${e}]`)}catch{n.issues.push({code:`invalid_format`,format:`cidrv6`,input:n.value,inst:e,continue:!t.abort})}}});function oa(e){if(e===``)return!0;if(e.length%4!=0)return!1;try{return atob(e),!0}catch{return!1}}let sa=D(`$ZodBase64`,(e,t)=>{t.pattern??=oi,j.init(e,t),e._zod.bag.contentEncoding=`base64`,e._zod.check=n=>{oa(n.value)||n.issues.push({code:`invalid_format`,format:`base64`,input:n.value,inst:e,continue:!t.abort})}});function ca(e){if(!si.test(e))return!1;let t=e.replace(/[-_]/g,e=>e===`-`?`+`:`/`);return oa(t.padEnd(Math.ceil(t.length/4)*4,`=`))}let la=D(`$ZodBase64URL`,(e,t)=>{t.pattern??=si,j.init(e,t),e._zod.bag.contentEncoding=`base64url`,e._zod.check=n=>{ca(n.value)||n.issues.push({code:`invalid_format`,format:`base64url`,input:n.value,inst:e,continue:!t.abort})}}),ua=D(`$ZodE164`,(e,t)=>{t.pattern??=ci,j.init(e,t)});function da(e,t=null){try{let n=e.split(`.`);if(n.length!==3)return!1;let[r]=n;if(!r)return!1;let i=JSON.parse(atob(r));return!(`typ`in i&&i?.typ!==`JWT`||!i.alg||t&&(!(`alg`in i)||i.alg!==t))}catch{return!1}}let fa=D(`$ZodJWT`,(e,t)=>{j.init(e,t),e._zod.check=n=>{da(n.value,t.alg)||n.issues.push({code:`invalid_format`,format:`jwt`,input:n.value,inst:e,continue:!t.abort})}}),pa=D(`$ZodNumber`,(e,t)=>{A.init(e,t),e._zod.pattern=e._zod.bag.pattern??gi,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=Number(n.value)}catch{}let i=n.value;if(typeof i==`number`&&!Number.isNaN(i)&&Number.isFinite(i))return n;let a=typeof i==`number`?Number.isNaN(i)?`NaN`:Number.isFinite(i)?void 0:`Infinity`:void 0;return n.issues.push({expected:`number`,code:`invalid_type`,input:i,inst:e,...a?{received:a}:{}}),n}}),ma=D(`$ZodNumberFormat`,(e,t)=>{Ei.init(e,t),pa.init(e,t)}),ha=D(`$ZodBoolean`,(e,t)=>{A.init(e,t),e._zod.pattern=_i,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=!!n.value}catch{}let i=n.value;return typeof i==`boolean`||n.issues.push({expected:`boolean`,code:`invalid_type`,input:i,inst:e}),n}}),ga=D(`$ZodNull`,(e,t)=>{A.init(e,t),e._zod.pattern=vi,e._zod.values=new Set([null]),e._zod.parse=(t,n)=>{let r=t.value;return r===null||t.issues.push({expected:`null`,code:`invalid_type`,input:r,inst:e}),t}}),_a=D(`$ZodUnknown`,(e,t)=>{A.init(e,t),e._zod.parse=e=>e}),va=D(`$ZodNever`,(e,t)=>{A.init(e,t),e._zod.parse=(t,n)=>(t.issues.push({expected:`never`,code:`invalid_type`,input:t.value,inst:e}),t)});function ya(e,t,n){e.issues.length&&t.issues.push(...yr(n,e.issues)),t.value[n]=e.value}let ba=D(`$ZodArray`,(e,t)=>{A.init(e,t),e._zod.parse=(n,r)=>{let i=n.value;if(!Array.isArray(i))return n.issues.push({expected:`array`,code:`invalid_type`,input:i,inst:e}),n;n.value=Array(i.length);let a=[];for(let e=0;e<i.length;e++){let o=i[e],s=t.element._zod.run({value:o,issues:[]},r);s instanceof Promise?a.push(s.then(t=>ya(t,n,e))):ya(s,n,e)}return a.length?Promise.all(a).then(()=>n):n}});function xa(e,t,n,r,i){if(e.issues.length){if(i&&!(n in r))return;t.issues.push(...yr(n,e.issues))}e.value===void 0?n in r&&(t.value[n]=void 0):t.value[n]=e.value}function Sa(e){let t=Object.keys(e.shape);for(let n of t)if(!e.shape?.[n]?._zod?.traits?.has(`$ZodType`))throw Error(`Invalid element at key "${n}": expected a Zod schema`);let n=lr(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(n)}}function Ca(e,t,n,r,i,a){let o=[],s=i.keySet,c=i.catchall._zod,l=c.def.type,u=c.optout===`optional`;for(let i in t){if(s.has(i))continue;if(l===`never`){o.push(i);continue}let a=c.run({value:t[i],issues:[]},r);a instanceof Promise?e.push(a.then(e=>xa(e,n,i,t,u))):xa(a,n,i,t,u)}return o.length&&n.issues.push({code:`unrecognized_keys`,keys:o,input:t,inst:a}),e.length?Promise.all(e).then(()=>n):n}let wa=D(`$ZodObject`,(e,t)=>{if(A.init(e,t),!Object.getOwnPropertyDescriptor(t,`shape`)?.get){let e=t.shape;Object.defineProperty(t,`shape`,{get:()=>{let n={...e};return Object.defineProperty(t,`shape`,{value:n}),n}})}let n=Kn(()=>Sa(t));O(e._zod,`propValues`,()=>{let e=t.shape,n={};for(let t in e){let r=e[t]._zod;if(r.values){n[t]??(n[t]=new Set);for(let e of r.values)n[t].add(e)}}return n});let r=nr,i=t.catchall,a;e._zod.parse=(t,o)=>{a??=n.value;let s=t.value;if(!r(s))return t.issues.push({expected:`object`,code:`invalid_type`,input:s,inst:e}),t;t.value={};let c=[],l=a.shape;for(let e of a.keys){let n=l[e],r=n._zod.optout===`optional`,i=n._zod.run({value:s[e],issues:[]},o);i instanceof Promise?c.push(i.then(n=>xa(n,t,e,s,r))):xa(i,t,e,s,r)}return i?Ca(c,s,t,o,n.value,e):c.length?Promise.all(c).then(()=>t):t}}),Ta=D(`$ZodObjectJIT`,(e,t)=>{wa.init(e,t);let n=e._zod.parse,r=Kn(()=>Sa(t)),i=e=>{let t=new Ri([`shape`,`payload`,`ctx`]),n=r.value,i=e=>{let t=$n(e);return`shape[${t}]._zod.run({ value: input[${t}], issues: [] }, ctx)`};t.write(`const input = payload.value;`);let a=Object.create(null),o=0;for(let e of n.keys)a[e]=`key_${o++}`;t.write(`const newResult = {};`);for(let r of n.keys){let n=a[r],o=$n(r),s=e[r]?._zod?.optout===`optional`;t.write(`const ${n} = ${i(r)};`),s?t.write(`
3
+ `))}};let hr={major:4,minor:3,patch:5},T=x(`$ZodType`,(e,t)=>{var n;e??={},e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=hr;let r=[...e._zod.def.checks??[]];e._zod.traits.has(`$ZodCheck`)&&r.unshift(e);for(let t of r)for(let n of t._zod.onattach)n(e);if(r.length===0)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let t=(e,t,n)=>{let r=Jt(e),i;for(let a of t){if(a._zod.def.when){if(!a._zod.def.when(e))continue}else if(r)continue;let t=e.issues.length,o=a._zod.check(e);if(o instanceof Promise&&n?.async===!1)throw new gt;if(i||o instanceof Promise)i=(i??Promise.resolve()).then(async()=>{await o,e.issues.length!==t&&(r||=Jt(e,t))});else{if(e.issues.length===t)continue;r||=Jt(e,t)}}return i?i.then(()=>e):e},n=(n,i,a)=>{if(Jt(n))return n.aborted=!0,n;let o=t(i,r,a);if(o instanceof Promise){if(a.async===!1)throw new gt;return o.then(t=>e._zod.parse(t,a))}return e._zod.parse(o,a)};e._zod.run=(i,a)=>{if(a.skipChecks)return e._zod.parse(i,a);if(a.direction===`backward`){let t=e._zod.parse({value:i.value,issues:[]},{...a,skipChecks:!0});return t instanceof Promise?t.then(e=>n(e,i,a)):n(t,i,a)}let o=e._zod.parse(i,a);if(o instanceof Promise){if(a.async===!1)throw new gt;return o.then(e=>t(e,r,a))}return t(o,r,a)}}S(e,`~standard`,()=>({validate:t=>{try{let n=dn(e,t);return n.success?{value:n.data}:{issues:n.error?.issues}}catch{return pn(e,t).then(e=>e.success?{value:e.data}:{issues:e.error?.issues})}},vendor:`zod`,version:1}))}),gr=x(`$ZodString`,(e,t)=>{T.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??Gn(e._zod.bag),e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=String(n.value)}catch{}return typeof n.value==`string`||n.issues.push({expected:`string`,code:`invalid_type`,input:n.value,inst:e}),n}}),E=x(`$ZodStringFormat`,(e,t)=>{or.init(e,t),gr.init(e,t)}),_r=x(`$ZodGUID`,(e,t)=>{t.pattern??=kn,E.init(e,t)}),vr=x(`$ZodUUID`,(e,t)=>{if(t.version){let e={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(e===void 0)throw Error(`Invalid UUID version: "${t.version}"`);t.pattern??=An(e)}else t.pattern??=An();E.init(e,t)}),yr=x(`$ZodEmail`,(e,t)=>{t.pattern??=jn,E.init(e,t)}),br=x(`$ZodURL`,(e,t)=>{E.init(e,t),e._zod.check=n=>{try{let r=n.value.trim(),i=new URL(r);t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(i.hostname)||n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid hostname`,pattern:t.hostname.source,input:n.value,inst:e,continue:!t.abort})),t.protocol&&(t.protocol.lastIndex=0,t.protocol.test(i.protocol.endsWith(`:`)?i.protocol.slice(0,-1):i.protocol)||n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid protocol`,pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort})),t.normalize?n.value=i.href:n.value=r;return}catch{n.issues.push({code:`invalid_format`,format:`url`,input:n.value,inst:e,continue:!t.abort})}}}),xr=x(`$ZodEmoji`,(e,t)=>{t.pattern??=Mn(),E.init(e,t)}),Sr=x(`$ZodNanoID`,(e,t)=>{t.pattern??=Dn,E.init(e,t)}),Cr=x(`$ZodCUID`,(e,t)=>{t.pattern??=Sn,E.init(e,t)}),wr=x(`$ZodCUID2`,(e,t)=>{t.pattern??=Cn,E.init(e,t)}),Tr=x(`$ZodULID`,(e,t)=>{t.pattern??=wn,E.init(e,t)}),Er=x(`$ZodXID`,(e,t)=>{t.pattern??=Tn,E.init(e,t)}),Dr=x(`$ZodKSUID`,(e,t)=>{t.pattern??=En,E.init(e,t)}),Or=x(`$ZodISODateTime`,(e,t)=>{t.pattern??=Wn(t),E.init(e,t)}),kr=x(`$ZodISODate`,(e,t)=>{t.pattern??=Vn,E.init(e,t)}),Ar=x(`$ZodISOTime`,(e,t)=>{t.pattern??=Un(t),E.init(e,t)}),jr=x(`$ZodISODuration`,(e,t)=>{t.pattern??=On,E.init(e,t)}),Mr=x(`$ZodIPv4`,(e,t)=>{t.pattern??=Nn,E.init(e,t),e._zod.bag.format=`ipv4`}),Nr=x(`$ZodIPv6`,(e,t)=>{t.pattern??=Pn,E.init(e,t),e._zod.bag.format=`ipv6`,e._zod.check=n=>{try{new URL(`http://[${n.value}]`)}catch{n.issues.push({code:`invalid_format`,format:`ipv6`,input:n.value,inst:e,continue:!t.abort})}}}),Pr=x(`$ZodCIDRv4`,(e,t)=>{t.pattern??=Fn,E.init(e,t)}),Fr=x(`$ZodCIDRv6`,(e,t)=>{t.pattern??=In,E.init(e,t),e._zod.check=n=>{let r=n.value.split(`/`);try{if(r.length!==2)throw Error();let[e,t]=r;if(!t)throw Error();let n=Number(t);if(`${n}`!==t||n<0||n>128)throw Error();new URL(`http://[${e}]`)}catch{n.issues.push({code:`invalid_format`,format:`cidrv6`,input:n.value,inst:e,continue:!t.abort})}}});function Ir(e){if(e===``)return!0;if(e.length%4!=0)return!1;try{return atob(e),!0}catch{return!1}}let Lr=x(`$ZodBase64`,(e,t)=>{t.pattern??=Ln,E.init(e,t),e._zod.bag.contentEncoding=`base64`,e._zod.check=n=>{Ir(n.value)||n.issues.push({code:`invalid_format`,format:`base64`,input:n.value,inst:e,continue:!t.abort})}});function Rr(e){if(!Rn.test(e))return!1;let t=e.replace(/[-_]/g,e=>e===`-`?`+`:`/`);return Ir(t.padEnd(Math.ceil(t.length/4)*4,`=`))}let zr=x(`$ZodBase64URL`,(e,t)=>{t.pattern??=Rn,E.init(e,t),e._zod.bag.contentEncoding=`base64url`,e._zod.check=n=>{Rr(n.value)||n.issues.push({code:`invalid_format`,format:`base64url`,input:n.value,inst:e,continue:!t.abort})}}),Br=x(`$ZodE164`,(e,t)=>{t.pattern??=zn,E.init(e,t)});function Vr(e,t=null){try{let n=e.split(`.`);if(n.length!==3)return!1;let[r]=n;if(!r)return!1;let i=JSON.parse(atob(r));return!(`typ`in i&&i?.typ!==`JWT`||!i.alg||t&&(!(`alg`in i)||i.alg!==t))}catch{return!1}}let Hr=x(`$ZodJWT`,(e,t)=>{E.init(e,t),e._zod.check=n=>{Vr(n.value,t.alg)||n.issues.push({code:`invalid_format`,format:`jwt`,input:n.value,inst:e,continue:!t.abort})}}),Ur=x(`$ZodNumber`,(e,t)=>{T.init(e,t),e._zod.pattern=e._zod.bag.pattern??qn,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=Number(n.value)}catch{}let i=n.value;if(typeof i==`number`&&!Number.isNaN(i)&&Number.isFinite(i))return n;let a=typeof i==`number`?Number.isNaN(i)?`NaN`:Number.isFinite(i)?void 0:`Infinity`:void 0;return n.issues.push({expected:`number`,code:`invalid_type`,input:i,inst:e,...a?{received:a}:{}}),n}}),Wr=x(`$ZodNumberFormat`,(e,t)=>{nr.init(e,t),Ur.init(e,t)}),Gr=x(`$ZodBoolean`,(e,t)=>{T.init(e,t),e._zod.pattern=Jn,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=!!n.value}catch{}let i=n.value;return typeof i==`boolean`||n.issues.push({expected:`boolean`,code:`invalid_type`,input:i,inst:e}),n}}),Kr=x(`$ZodNull`,(e,t)=>{T.init(e,t),e._zod.pattern=Yn,e._zod.values=new Set([null]),e._zod.parse=(t,n)=>{let r=t.value;return r===null||t.issues.push({expected:`null`,code:`invalid_type`,input:r,inst:e}),t}}),qr=x(`$ZodUnknown`,(e,t)=>{T.init(e,t),e._zod.parse=e=>e}),Jr=x(`$ZodNever`,(e,t)=>{T.init(e,t),e._zod.parse=(t,n)=>(t.issues.push({expected:`never`,code:`invalid_type`,input:t.value,inst:e}),t)});function Yr(e,t,n){e.issues.length&&t.issues.push(...Yt(n,e.issues)),t.value[n]=e.value}let Xr=x(`$ZodArray`,(e,t)=>{T.init(e,t),e._zod.parse=(n,r)=>{let i=n.value;if(!Array.isArray(i))return n.issues.push({expected:`array`,code:`invalid_type`,input:i,inst:e}),n;n.value=Array(i.length);let a=[];for(let e=0;e<i.length;e++){let o=i[e],s=t.element._zod.run({value:o,issues:[]},r);s instanceof Promise?a.push(s.then(t=>Yr(t,n,e))):Yr(s,n,e)}return a.length?Promise.all(a).then(()=>n):n}});function Zr(e,t,n,r,i){if(e.issues.length){if(i&&!(n in r))return;t.issues.push(...Yt(n,e.issues))}e.value===void 0?n in r&&(t.value[n]=void 0):t.value[n]=e.value}function Qr(e){let t=Object.keys(e.shape);for(let n of t)if(!e.shape?.[n]?._zod?.traits?.has(`$ZodType`))throw Error(`Invalid element at key "${n}": expected a Zod schema`);let n=zt(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(n)}}function $r(e,t,n,r,i,a){let o=[],s=i.keySet,c=i.catchall._zod,l=c.def.type,u=c.optout===`optional`;for(let i in t){if(s.has(i))continue;if(l===`never`){o.push(i);continue}let a=c.run({value:t[i],issues:[]},r);a instanceof Promise?e.push(a.then(e=>Zr(e,n,i,t,u))):Zr(a,n,i,t,u)}return o.length&&n.issues.push({code:`unrecognized_keys`,keys:o,input:t,inst:a}),e.length?Promise.all(e).then(()=>n):n}let ei=x(`$ZodObject`,(e,t)=>{if(T.init(e,t),!Object.getOwnPropertyDescriptor(t,`shape`)?.get){let e=t.shape;Object.defineProperty(t,`shape`,{get:()=>{let n={...e};return Object.defineProperty(t,`shape`,{value:n}),n}})}let n=St(()=>Qr(t));S(e._zod,`propValues`,()=>{let e=t.shape,n={};for(let t in e){let r=e[t]._zod;if(r.values){n[t]??(n[t]=new Set);for(let e of r.values)n[t].add(e)}}return n});let r=Mt,i=t.catchall,a;e._zod.parse=(t,o)=>{a??=n.value;let s=t.value;if(!r(s))return t.issues.push({expected:`object`,code:`invalid_type`,input:s,inst:e}),t;t.value={};let c=[],l=a.shape;for(let e of a.keys){let n=l[e],r=n._zod.optout===`optional`,i=n._zod.run({value:s[e],issues:[]},o);i instanceof Promise?c.push(i.then(n=>Zr(n,t,e,s,r))):Zr(i,t,e,s,r)}return i?$r(c,s,t,o,n.value,e):c.length?Promise.all(c).then(()=>t):t}}),ti=x(`$ZodObjectJIT`,(e,t)=>{ei.init(e,t);let n=e._zod.parse,r=St(()=>Qr(t)),i=e=>{let t=new mr([`shape`,`payload`,`ctx`]),n=r.value,i=e=>{let t=kt(e);return`shape[${t}]._zod.run({ value: input[${t}], issues: [] }, ctx)`};t.write(`const input = payload.value;`);let a=Object.create(null),o=0;for(let e of n.keys)a[e]=`key_${o++}`;t.write(`const newResult = {};`);for(let r of n.keys){let n=a[r],o=kt(r),s=e[r]?._zod?.optout===`optional`;t.write(`const ${n} = ${i(r)};`),s?t.write(`
5
4
  if (${n}.issues.length) {
6
5
  if (${o} in input) {
7
6
  payload.issues = payload.issues.concat(${n}.issues.map(iss => ({
@@ -35,8 +34,9 @@ var WebMCP=(function(e,t){var n=Object.create,r=Object.defineProperty,i=Object.g
35
34
  newResult[${o}] = ${n}.value;
36
35
  }
37
36
 
38
- `)}t.write(`payload.value = newResult;`),t.write(`return payload;`);let s=t.compile();return(t,n)=>s(e,t,n)},a,o=nr,s=!Hn.jitless,c=s&&rr.value,l=t.catchall,u;e._zod.parse=(d,f)=>{u??=r.value;let ee=d.value;return o(ee)?s&&c&&f?.async===!1&&f.jitless!==!0?(a||=i(t.shape),d=a(d,f),l?Ca([],ee,d,f,u,e):d):n(d,f):(d.issues.push({expected:`object`,code:`invalid_type`,input:ee,inst:e}),d)}});function Ea(e,t,n,r){for(let n of e)if(n.issues.length===0)return t.value=n.value,t;let i=e.filter(e=>!vr(e));return i.length===1?(t.value=i[0].value,i[0]):(t.issues.push({code:`invalid_union`,input:t.value,inst:n,errors:e.map(e=>e.issues.map(e=>xr(e,r,Un())))}),t)}let Da=D(`$ZodUnion`,(e,t)=>{A.init(e,t),O(e._zod,`optin`,()=>t.options.some(e=>e._zod.optin===`optional`)?`optional`:void 0),O(e._zod,`optout`,()=>t.options.some(e=>e._zod.optout===`optional`)?`optional`:void 0),O(e._zod,`values`,()=>{if(t.options.every(e=>e._zod.values))return new Set(t.options.flatMap(e=>Array.from(e._zod.values)))}),O(e._zod,`pattern`,()=>{if(t.options.every(e=>e._zod.pattern)){let e=t.options.map(e=>e._zod.pattern);return RegExp(`^(${e.map(e=>Jn(e.source)).join(`|`)})$`)}});let n=t.options.length===1,r=t.options[0]._zod.run;e._zod.parse=(i,a)=>{if(n)return r(i,a);let o=!1,s=[];for(let e of t.options){let t=e._zod.run({value:i.value,issues:[]},a);if(t instanceof Promise)s.push(t),o=!0;else{if(t.issues.length===0)return t;s.push(t)}}return o?Promise.all(s).then(t=>Ea(t,i,e,a)):Ea(s,i,e,a)}}),Oa=D(`$ZodDiscriminatedUnion`,(e,t)=>{t.inclusive=!1,Da.init(e,t);let n=e._zod.parse;O(e._zod,`propValues`,()=>{let e={};for(let n of t.options){let r=n._zod.propValues;if(!r||Object.keys(r).length===0)throw Error(`Invalid discriminated union option at index "${t.options.indexOf(n)}"`);for(let[t,n]of Object.entries(r)){e[t]||(e[t]=new Set);for(let r of n)e[t].add(r)}}return e});let r=Kn(()=>{let e=t.options,n=new Map;for(let r of e){let e=r._zod.propValues?.[t.discriminator];if(!e||e.size===0)throw Error(`Invalid discriminated union option at index "${t.options.indexOf(r)}"`);for(let t of e){if(n.has(t))throw Error(`Duplicate discriminator value "${String(t)}"`);n.set(t,r)}}return n});e._zod.parse=(i,a)=>{let o=i.value;if(!nr(o))return i.issues.push({code:`invalid_type`,expected:`object`,input:o,inst:e}),i;let s=r.value.get(o?.[t.discriminator]);return s?s._zod.run(i,a):t.unionFallback?n(i,a):(i.issues.push({code:`invalid_union`,errors:[],note:`No matching discriminator`,discriminator:t.discriminator,input:o,path:[t.discriminator],inst:e}),i)}}),ka=D(`$ZodIntersection`,(e,t)=>{A.init(e,t),e._zod.parse=(e,n)=>{let r=e.value,i=t.left._zod.run({value:r,issues:[]},n),a=t.right._zod.run({value:r,issues:[]},n);return i instanceof Promise||a instanceof Promise?Promise.all([i,a]).then(([t,n])=>ja(e,t,n)):ja(e,i,a)}});function Aa(e,t){if(e===t||e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(ir(e)&&ir(t)){let n=Object.keys(t),r=Object.keys(e).filter(e=>n.indexOf(e)!==-1),i={...e,...t};for(let n of r){let r=Aa(e[n],t[n]);if(!r.valid)return{valid:!1,mergeErrorPath:[n,...r.mergeErrorPath]};i[n]=r.data}return{valid:!0,data:i}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};let n=[];for(let r=0;r<e.length;r++){let i=e[r],a=t[r],o=Aa(i,a);if(!o.valid)return{valid:!1,mergeErrorPath:[r,...o.mergeErrorPath]};n.push(o.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function ja(e,t,n){let r=new Map,i;for(let n of t.issues)if(n.code===`unrecognized_keys`){i??=n;for(let e of n.keys)r.has(e)||r.set(e,{}),r.get(e).l=!0}else e.issues.push(n);for(let t of n.issues)if(t.code===`unrecognized_keys`)for(let e of t.keys)r.has(e)||r.set(e,{}),r.get(e).r=!0;else e.issues.push(t);let a=[...r].filter(([,e])=>e.l&&e.r).map(([e])=>e);if(a.length&&i&&e.issues.push({...i,keys:a}),vr(e))return e;let o=Aa(t.value,n.value);if(!o.valid)throw Error(`Unmergable intersection. Error path: ${JSON.stringify(o.mergeErrorPath)}`);return e.value=o.data,e}let Ma=D(`$ZodRecord`,(e,t)=>{A.init(e,t),e._zod.parse=(n,r)=>{let i=n.value;if(!ir(i))return n.issues.push({expected:`record`,code:`invalid_type`,input:i,inst:e}),n;let a=[],o=t.keyType._zod.values;if(o){n.value={};let s=new Set;for(let e of o)if(typeof e==`string`||typeof e==`number`||typeof e==`symbol`){s.add(typeof e==`number`?e.toString():e);let o=t.valueType._zod.run({value:i[e],issues:[]},r);o instanceof Promise?a.push(o.then(t=>{t.issues.length&&n.issues.push(...yr(e,t.issues)),n.value[e]=t.value})):(o.issues.length&&n.issues.push(...yr(e,o.issues)),n.value[e]=o.value)}let c;for(let e in i)s.has(e)||(c??=[],c.push(e));c&&c.length>0&&n.issues.push({code:`unrecognized_keys`,input:i,inst:e,keys:c})}else{n.value={};for(let o of Reflect.ownKeys(i)){if(o===`__proto__`)continue;let s=t.keyType._zod.run({value:o,issues:[]},r);if(s instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);if(typeof o==`string`&&gi.test(o)&&s.issues.length&&s.issues.some(e=>e.code===`invalid_type`&&e.expected===`number`)){let e=t.keyType._zod.run({value:Number(o),issues:[]},r);if(e instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);e.issues.length===0&&(s=e)}if(s.issues.length){t.mode===`loose`?n.value[o]=i[o]:n.issues.push({code:`invalid_key`,origin:`record`,issues:s.issues.map(e=>xr(e,r,Un())),input:o,path:[o],inst:e});continue}let c=t.valueType._zod.run({value:i[o],issues:[]},r);c instanceof Promise?a.push(c.then(e=>{e.issues.length&&n.issues.push(...yr(o,e.issues)),n.value[s.value]=e.value})):(c.issues.length&&n.issues.push(...yr(o,c.issues)),n.value[s.value]=c.value)}}return a.length?Promise.all(a).then(()=>n):n}}),Na=D(`$ZodEnum`,(e,t)=>{A.init(e,t);let n=Wn(t.entries),r=new Set(n);e._zod.values=r,e._zod.pattern=RegExp(`^(${n.filter(e=>or.has(typeof e)).map(e=>typeof e==`string`?sr(e):e.toString()).join(`|`)})$`),e._zod.parse=(t,i)=>{let a=t.value;return r.has(a)||t.issues.push({code:`invalid_value`,values:n,input:a,inst:e}),t}}),Pa=D(`$ZodLiteral`,(e,t)=>{if(A.init(e,t),t.values.length===0)throw Error(`Cannot create literal schema with no valid values`);let n=new Set(t.values);e._zod.values=n,e._zod.pattern=RegExp(`^(${t.values.map(e=>typeof e==`string`?sr(e):e?sr(e.toString()):String(e)).join(`|`)})$`),e._zod.parse=(r,i)=>{let a=r.value;return n.has(a)||r.issues.push({code:`invalid_value`,values:t.values,input:a,inst:e}),r}}),Fa=D(`$ZodTransform`,(e,t)=>{A.init(e,t),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new Vn(e.constructor.name);let i=t.transform(n.value,n);if(r.async)return(i instanceof Promise?i:Promise.resolve(i)).then(e=>(n.value=e,n));if(i instanceof Promise)throw new Bn;return n.value=i,n}});function Ia(e,t){return e.issues.length&&t===void 0?{issues:[],value:void 0}:e}let La=D(`$ZodOptional`,(e,t)=>{A.init(e,t),e._zod.optin=`optional`,e._zod.optout=`optional`,O(e._zod,`values`,()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),O(e._zod,`pattern`,()=>{let e=t.innerType._zod.pattern;return e?RegExp(`^(${Jn(e.source)})?$`):void 0}),e._zod.parse=(e,n)=>{if(t.innerType._zod.optin===`optional`){let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(t=>Ia(t,e.value)):Ia(r,e.value)}return e.value===void 0?e:t.innerType._zod.run(e,n)}}),Ra=D(`$ZodExactOptional`,(e,t)=>{La.init(e,t),O(e._zod,`values`,()=>t.innerType._zod.values),O(e._zod,`pattern`,()=>t.innerType._zod.pattern),e._zod.parse=(e,n)=>t.innerType._zod.run(e,n)}),za=D(`$ZodNullable`,(e,t)=>{A.init(e,t),O(e._zod,`optin`,()=>t.innerType._zod.optin),O(e._zod,`optout`,()=>t.innerType._zod.optout),O(e._zod,`pattern`,()=>{let e=t.innerType._zod.pattern;return e?RegExp(`^(${Jn(e.source)}|null)$`):void 0}),O(e._zod,`values`,()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(e,n)=>e.value===null?e:t.innerType._zod.run(e,n)}),Ba=D(`$ZodDefault`,(e,t)=>{A.init(e,t),e._zod.optin=`optional`,O(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);if(e.value===void 0)return e.value=t.defaultValue,e;let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(e=>Va(e,t)):Va(r,t)}});function Va(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}let Ha=D(`$ZodPrefault`,(e,t)=>{A.init(e,t),e._zod.optin=`optional`,O(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>(n.direction===`backward`||e.value===void 0&&(e.value=t.defaultValue),t.innerType._zod.run(e,n))}),Ua=D(`$ZodNonOptional`,(e,t)=>{A.init(e,t),O(e._zod,`values`,()=>{let e=t.innerType._zod.values;return e?new Set([...e].filter(e=>e!==void 0)):void 0}),e._zod.parse=(n,r)=>{let i=t.innerType._zod.run(n,r);return i instanceof Promise?i.then(t=>Wa(t,e)):Wa(i,e)}});function Wa(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:`invalid_type`,expected:`nonoptional`,input:e.value,inst:t}),e}let Ga=D(`$ZodCatch`,(e,t)=>{A.init(e,t),O(e._zod,`optin`,()=>t.innerType._zod.optin),O(e._zod,`optout`,()=>t.innerType._zod.optout),O(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(r=>(e.value=r.value,r.issues.length&&(e.value=t.catchValue({...e,error:{issues:r.issues.map(e=>xr(e,n,Un()))},input:e.value}),e.issues=[]),e)):(e.value=r.value,r.issues.length&&(e.value=t.catchValue({...e,error:{issues:r.issues.map(e=>xr(e,n,Un()))},input:e.value}),e.issues=[]),e)}}),Ka=D(`$ZodPipe`,(e,t)=>{A.init(e,t),O(e._zod,`values`,()=>t.in._zod.values),O(e._zod,`optin`,()=>t.in._zod.optin),O(e._zod,`optout`,()=>t.out._zod.optout),O(e._zod,`propValues`,()=>t.in._zod.propValues),e._zod.parse=(e,n)=>{if(n.direction===`backward`){let r=t.out._zod.run(e,n);return r instanceof Promise?r.then(e=>qa(e,t.in,n)):qa(r,t.in,n)}let r=t.in._zod.run(e,n);return r instanceof Promise?r.then(e=>qa(e,t.out,n)):qa(r,t.out,n)}});function qa(e,t,n){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},n)}let Ja=D(`$ZodReadonly`,(e,t)=>{A.init(e,t),O(e._zod,`propValues`,()=>t.innerType._zod.propValues),O(e._zod,`values`,()=>t.innerType._zod.values),O(e._zod,`optin`,()=>t.innerType?._zod?.optin),O(e._zod,`optout`,()=>t.innerType?._zod?.optout),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(Ya):Ya(r)}});function Ya(e){return e.value=Object.freeze(e.value),e}let Xa=D(`$ZodCustom`,(e,t)=>{xi.init(e,t),A.init(e,t),e._zod.parse=(e,t)=>e,e._zod.check=n=>{let r=n.value,i=t.fn(r);if(i instanceof Promise)return i.then(t=>Za(t,n,r,e));Za(i,n,r,e)}});function Za(e,t,n,r){if(!e){let e={code:`custom`,input:n,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(e.params=r._zod.def.params),t.issues.push(Cr(e))}}var Qa,$a=class{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...t){let n=t[0];return this._map.set(e,n),n&&typeof n==`object`&&`id`in n&&this._idmap.set(n.id,e),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(e){let t=this._map.get(e);return t&&typeof t==`object`&&`id`in t&&this._idmap.delete(t.id),this._map.delete(e),this}get(e){let t=e._zod.parent;if(t){let n={...this.get(t)??{}};delete n.id;let r={...n,...this._map.get(e)};return Object.keys(r).length?r:void 0}return this._map.get(e)}has(e){return this._map.has(e)}};function eo(){return new $a}(Qa=globalThis).__zod_globalRegistry??(Qa.__zod_globalRegistry=eo());let to=globalThis.__zod_globalRegistry;function no(e,t){return new e({type:`string`,...k(t)})}function ro(e,t){return new e({type:`string`,format:`email`,check:`string_format`,abort:!1,...k(t)})}function io(e,t){return new e({type:`string`,format:`guid`,check:`string_format`,abort:!1,...k(t)})}function ao(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,...k(t)})}function oo(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v4`,...k(t)})}function so(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v6`,...k(t)})}function co(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v7`,...k(t)})}function lo(e,t){return new e({type:`string`,format:`url`,check:`string_format`,abort:!1,...k(t)})}function uo(e,t){return new e({type:`string`,format:`emoji`,check:`string_format`,abort:!1,...k(t)})}function fo(e,t){return new e({type:`string`,format:`nanoid`,check:`string_format`,abort:!1,...k(t)})}function po(e,t){return new e({type:`string`,format:`cuid`,check:`string_format`,abort:!1,...k(t)})}function mo(e,t){return new e({type:`string`,format:`cuid2`,check:`string_format`,abort:!1,...k(t)})}function ho(e,t){return new e({type:`string`,format:`ulid`,check:`string_format`,abort:!1,...k(t)})}function go(e,t){return new e({type:`string`,format:`xid`,check:`string_format`,abort:!1,...k(t)})}function _o(e,t){return new e({type:`string`,format:`ksuid`,check:`string_format`,abort:!1,...k(t)})}function vo(e,t){return new e({type:`string`,format:`ipv4`,check:`string_format`,abort:!1,...k(t)})}function yo(e,t){return new e({type:`string`,format:`ipv6`,check:`string_format`,abort:!1,...k(t)})}function bo(e,t){return new e({type:`string`,format:`cidrv4`,check:`string_format`,abort:!1,...k(t)})}function xo(e,t){return new e({type:`string`,format:`cidrv6`,check:`string_format`,abort:!1,...k(t)})}function So(e,t){return new e({type:`string`,format:`base64`,check:`string_format`,abort:!1,...k(t)})}function Co(e,t){return new e({type:`string`,format:`base64url`,check:`string_format`,abort:!1,...k(t)})}function wo(e,t){return new e({type:`string`,format:`e164`,check:`string_format`,abort:!1,...k(t)})}function To(e,t){return new e({type:`string`,format:`jwt`,check:`string_format`,abort:!1,...k(t)})}function Eo(e,t){return new e({type:`string`,format:`datetime`,check:`string_format`,offset:!1,local:!1,precision:null,...k(t)})}function Do(e,t){return new e({type:`string`,format:`date`,check:`string_format`,...k(t)})}function Oo(e,t){return new e({type:`string`,format:`time`,check:`string_format`,precision:null,...k(t)})}function ko(e,t){return new e({type:`string`,format:`duration`,check:`string_format`,...k(t)})}function Ao(e,t){return new e({type:`number`,checks:[],...k(t)})}function jo(e,t){return new e({type:`number`,check:`number_format`,abort:!1,format:`safeint`,...k(t)})}function Mo(e,t){return new e({type:`boolean`,...k(t)})}function No(e,t){return new e({type:`null`,...k(t)})}function Po(e){return new e({type:`unknown`})}function Fo(e,t){return new e({type:`never`,...k(t)})}function Io(e,t){return new Ci({check:`less_than`,...k(t),value:e,inclusive:!1})}function Lo(e,t){return new Ci({check:`less_than`,...k(t),value:e,inclusive:!0})}function Ro(e,t){return new wi({check:`greater_than`,...k(t),value:e,inclusive:!1})}function zo(e,t){return new wi({check:`greater_than`,...k(t),value:e,inclusive:!0})}function Bo(e,t){return new Ti({check:`multiple_of`,...k(t),value:e})}function Vo(e,t){return new Di({check:`max_length`,...k(t),maximum:e})}function Ho(e,t){return new Oi({check:`min_length`,...k(t),minimum:e})}function Uo(e,t){return new ki({check:`length_equals`,...k(t),length:e})}function Wo(e,t){return new ji({check:`string_format`,format:`regex`,...k(t),pattern:e})}function Go(e){return new Mi({check:`string_format`,format:`lowercase`,...k(e)})}function Ko(e){return new Ni({check:`string_format`,format:`uppercase`,...k(e)})}function qo(e,t){return new Pi({check:`string_format`,format:`includes`,...k(t),includes:e})}function Jo(e,t){return new Fi({check:`string_format`,format:`starts_with`,...k(t),prefix:e})}function Yo(e,t){return new Ii({check:`string_format`,format:`ends_with`,...k(t),suffix:e})}function Xo(e){return new Li({check:`overwrite`,tx:e})}function Zo(e){return Xo(t=>t.normalize(e))}function Qo(){return Xo(e=>e.trim())}function $o(){return Xo(e=>e.toLowerCase())}function es(){return Xo(e=>e.toUpperCase())}function ts(){return Xo(e=>er(e))}function ns(e,t,n){return new e({type:`array`,element:t,...k(n)})}function rs(e,t,n){let r=k(n);return r.abort??=!0,new e({type:`custom`,check:`custom`,fn:t,...r})}function is(e,t,n){return new e({type:`custom`,check:`custom`,fn:t,...k(n)})}function as(e){let t=os(n=>(n.addIssue=e=>{if(typeof e==`string`)n.issues.push(Cr(e,n.value,t._zod.def));else{let r=e;r.fatal&&(r.continue=!1),r.code??=`custom`,r.input??=n.value,r.inst??=t,r.continue??=!t._zod.def.abort,n.issues.push(Cr(r))}},e(n.value,n)));return t}function os(e,t){let n=new xi({check:`custom`,...k(t)});return n._zod.check=e,n}function ss(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??to,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 M(e,t,n={path:[],schemaPath:[]}){var r;let i=e._zod.def,a=t.seen.get(e);if(a)return a.count++,n.schemaPath.includes(e)&&(a.cycle=n.path),a.schema;let o={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,o);let s=e._zod.toJSONSchema?.();if(s)o.schema=s;else{let r={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,o.schema,r);else{let n=o.schema,a=t.processors[i.type];if(!a)throw Error(`[toJSONSchema]: Non-representable type encountered: ${i.type}`);a(e,t,n,r)}let a=e._zod.parent;a&&(o.ref||=a,M(a,t,r),t.seen.get(a).isParent=!0)}let c=t.metadataRegistry.get(e);return c&&Object.assign(o.schema,c),t.io===`input`&&N(e)&&(delete o.schema.examples,delete o.schema.default),t.io===`input`&&o.schema._prefault&&((r=o.schema).default??(r.default=o.schema._prefault)),delete o.schema._prefault,t.seen.get(e).schema}function cs(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);let r=new Map;for(let t of e.seen.entries()){let n=e.metadataRegistry.get(t[0])?.id;if(n){let e=r.get(n);if(e&&e!==t[0])throw Error(`Duplicate schema id "${n}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);r.set(n,t[0])}}let i=t=>{let r=e.target===`draft-2020-12`?`$defs`:`definitions`;if(e.external){let n=e.external.registry.get(t[0])?.id,i=e.external.uri??(e=>e);if(n)return{ref:i(n)};let a=t[1].defId??t[1].schema.id??`schema${e.counter++}`;return t[1].defId=a,{defId:a,ref:`${i(`__shared`)}#/${r}/${a}`}}if(t[1]===n)return{ref:`#`};let i=`#/${r}/`,a=t[1].schema.id??`__schema${e.counter++}`;return{defId:a,ref:i+a}},a=e=>{if(e[1].schema.$ref)return;let t=e[1],{ref:n,defId:r}=i(e);t.def={...t.schema},r&&(t.defId=r);let a=t.schema;for(let e in a)delete a[e];a.$ref=n};if(e.cycles===`throw`)for(let t of e.seen.entries()){let e=t[1];if(e.cycle)throw Error(`Cycle detected: #/${e.cycle?.join(`/`)}/<root>
37
+ `)}t.write(`payload.value = newResult;`),t.write(`return payload;`);let s=t.compile();return(t,n)=>s(e,t,n)},a,o=Mt,s=!vt.jitless,c=s&&Nt.value,l=t.catchall,u;e._zod.parse=(d,f)=>{u??=r.value;let p=d.value;return o(p)?s&&c&&f?.async===!1&&f.jitless!==!0?(a||=i(t.shape),d=a(d,f),l?$r([],p,d,f,u,e):d):n(d,f):(d.issues.push({expected:`object`,code:`invalid_type`,input:p,inst:e}),d)}});function ni(e,t,n,r){for(let n of e)if(n.issues.length===0)return t.value=n.value,t;let i=e.filter(e=>!Jt(e));return i.length===1?(t.value=i[0].value,i[0]):(t.issues.push({code:`invalid_union`,input:t.value,inst:n,errors:e.map(e=>e.issues.map(e=>Zt(e,r,yt())))}),t)}let ri=x(`$ZodUnion`,(e,t)=>{T.init(e,t),S(e._zod,`optin`,()=>t.options.some(e=>e._zod.optin===`optional`)?`optional`:void 0),S(e._zod,`optout`,()=>t.options.some(e=>e._zod.optout===`optional`)?`optional`:void 0),S(e._zod,`values`,()=>{if(t.options.every(e=>e._zod.values))return new Set(t.options.flatMap(e=>Array.from(e._zod.values)))}),S(e._zod,`pattern`,()=>{if(t.options.every(e=>e._zod.pattern)){let e=t.options.map(e=>e._zod.pattern);return RegExp(`^(${e.map(e=>wt(e.source)).join(`|`)})$`)}});let n=t.options.length===1,r=t.options[0]._zod.run;e._zod.parse=(i,a)=>{if(n)return r(i,a);let o=!1,s=[];for(let e of t.options){let t=e._zod.run({value:i.value,issues:[]},a);if(t instanceof Promise)s.push(t),o=!0;else{if(t.issues.length===0)return t;s.push(t)}}return o?Promise.all(s).then(t=>ni(t,i,e,a)):ni(s,i,e,a)}}),ii=x(`$ZodDiscriminatedUnion`,(e,t)=>{t.inclusive=!1,ri.init(e,t);let n=e._zod.parse;S(e._zod,`propValues`,()=>{let e={};for(let n of t.options){let r=n._zod.propValues;if(!r||Object.keys(r).length===0)throw Error(`Invalid discriminated union option at index "${t.options.indexOf(n)}"`);for(let[t,n]of Object.entries(r)){e[t]||(e[t]=new Set);for(let r of n)e[t].add(r)}}return e});let r=St(()=>{let e=t.options,n=new Map;for(let r of e){let e=r._zod.propValues?.[t.discriminator];if(!e||e.size===0)throw Error(`Invalid discriminated union option at index "${t.options.indexOf(r)}"`);for(let t of e){if(n.has(t))throw Error(`Duplicate discriminator value "${String(t)}"`);n.set(t,r)}}return n});e._zod.parse=(i,a)=>{let o=i.value;if(!Mt(o))return i.issues.push({code:`invalid_type`,expected:`object`,input:o,inst:e}),i;let s=r.value.get(o?.[t.discriminator]);return s?s._zod.run(i,a):t.unionFallback?n(i,a):(i.issues.push({code:`invalid_union`,errors:[],note:`No matching discriminator`,discriminator:t.discriminator,input:o,path:[t.discriminator],inst:e}),i)}}),ai=x(`$ZodIntersection`,(e,t)=>{T.init(e,t),e._zod.parse=(e,n)=>{let r=e.value,i=t.left._zod.run({value:r,issues:[]},n),a=t.right._zod.run({value:r,issues:[]},n);return i instanceof Promise||a instanceof Promise?Promise.all([i,a]).then(([t,n])=>si(e,t,n)):si(e,i,a)}});function oi(e,t){if(e===t||e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(Pt(e)&&Pt(t)){let n=Object.keys(t),r=Object.keys(e).filter(e=>n.indexOf(e)!==-1),i={...e,...t};for(let n of r){let r=oi(e[n],t[n]);if(!r.valid)return{valid:!1,mergeErrorPath:[n,...r.mergeErrorPath]};i[n]=r.data}return{valid:!0,data:i}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};let n=[];for(let r=0;r<e.length;r++){let i=e[r],a=t[r],o=oi(i,a);if(!o.valid)return{valid:!1,mergeErrorPath:[r,...o.mergeErrorPath]};n.push(o.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function si(e,t,n){let r=new Map,i;for(let n of t.issues)if(n.code===`unrecognized_keys`){i??=n;for(let e of n.keys)r.has(e)||r.set(e,{}),r.get(e).l=!0}else e.issues.push(n);for(let t of n.issues)if(t.code===`unrecognized_keys`)for(let e of t.keys)r.has(e)||r.set(e,{}),r.get(e).r=!0;else e.issues.push(t);let a=[...r].filter(([,e])=>e.l&&e.r).map(([e])=>e);if(a.length&&i&&e.issues.push({...i,keys:a}),Jt(e))return e;let o=oi(t.value,n.value);if(!o.valid)throw Error(`Unmergable intersection. Error path: ${JSON.stringify(o.mergeErrorPath)}`);return e.value=o.data,e}let ci=x(`$ZodRecord`,(e,t)=>{T.init(e,t),e._zod.parse=(n,r)=>{let i=n.value;if(!Pt(i))return n.issues.push({expected:`record`,code:`invalid_type`,input:i,inst:e}),n;let a=[],o=t.keyType._zod.values;if(o){n.value={};let s=new Set;for(let e of o)if(typeof e==`string`||typeof e==`number`||typeof e==`symbol`){s.add(typeof e==`number`?e.toString():e);let o=t.valueType._zod.run({value:i[e],issues:[]},r);o instanceof Promise?a.push(o.then(t=>{t.issues.length&&n.issues.push(...Yt(e,t.issues)),n.value[e]=t.value})):(o.issues.length&&n.issues.push(...Yt(e,o.issues)),n.value[e]=o.value)}let c;for(let e in i)s.has(e)||(c??=[],c.push(e));c&&c.length>0&&n.issues.push({code:`unrecognized_keys`,input:i,inst:e,keys:c})}else{n.value={};for(let o of Reflect.ownKeys(i)){if(o===`__proto__`)continue;let s=t.keyType._zod.run({value:o,issues:[]},r);if(s instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);if(typeof o==`string`&&qn.test(o)&&s.issues.length&&s.issues.some(e=>e.code===`invalid_type`&&e.expected===`number`)){let e=t.keyType._zod.run({value:Number(o),issues:[]},r);if(e instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);e.issues.length===0&&(s=e)}if(s.issues.length){t.mode===`loose`?n.value[o]=i[o]:n.issues.push({code:`invalid_key`,origin:`record`,issues:s.issues.map(e=>Zt(e,r,yt())),input:o,path:[o],inst:e});continue}let c=t.valueType._zod.run({value:i[o],issues:[]},r);c instanceof Promise?a.push(c.then(e=>{e.issues.length&&n.issues.push(...Yt(o,e.issues)),n.value[s.value]=e.value})):(c.issues.length&&n.issues.push(...Yt(o,c.issues)),n.value[s.value]=c.value)}}return a.length?Promise.all(a).then(()=>n):n}}),li=x(`$ZodEnum`,(e,t)=>{T.init(e,t);let n=bt(t.entries),r=new Set(n);e._zod.values=r,e._zod.pattern=RegExp(`^(${n.filter(e=>It.has(typeof e)).map(e=>typeof e==`string`?Lt(e):e.toString()).join(`|`)})$`),e._zod.parse=(t,i)=>{let a=t.value;return r.has(a)||t.issues.push({code:`invalid_value`,values:n,input:a,inst:e}),t}}),ui=x(`$ZodLiteral`,(e,t)=>{if(T.init(e,t),t.values.length===0)throw Error(`Cannot create literal schema with no valid values`);let n=new Set(t.values);e._zod.values=n,e._zod.pattern=RegExp(`^(${t.values.map(e=>typeof e==`string`?Lt(e):e?Lt(e.toString()):String(e)).join(`|`)})$`),e._zod.parse=(r,i)=>{let a=r.value;return n.has(a)||r.issues.push({code:`invalid_value`,values:t.values,input:a,inst:e}),r}}),di=x(`$ZodTransform`,(e,t)=>{T.init(e,t),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new _t(e.constructor.name);let i=t.transform(n.value,n);if(r.async)return(i instanceof Promise?i:Promise.resolve(i)).then(e=>(n.value=e,n));if(i instanceof Promise)throw new gt;return n.value=i,n}});function fi(e,t){return e.issues.length&&t===void 0?{issues:[],value:void 0}:e}let pi=x(`$ZodOptional`,(e,t)=>{T.init(e,t),e._zod.optin=`optional`,e._zod.optout=`optional`,S(e._zod,`values`,()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),S(e._zod,`pattern`,()=>{let e=t.innerType._zod.pattern;return e?RegExp(`^(${wt(e.source)})?$`):void 0}),e._zod.parse=(e,n)=>{if(t.innerType._zod.optin===`optional`){let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(t=>fi(t,e.value)):fi(r,e.value)}return e.value===void 0?e:t.innerType._zod.run(e,n)}}),mi=x(`$ZodExactOptional`,(e,t)=>{pi.init(e,t),S(e._zod,`values`,()=>t.innerType._zod.values),S(e._zod,`pattern`,()=>t.innerType._zod.pattern),e._zod.parse=(e,n)=>t.innerType._zod.run(e,n)}),hi=x(`$ZodNullable`,(e,t)=>{T.init(e,t),S(e._zod,`optin`,()=>t.innerType._zod.optin),S(e._zod,`optout`,()=>t.innerType._zod.optout),S(e._zod,`pattern`,()=>{let e=t.innerType._zod.pattern;return e?RegExp(`^(${wt(e.source)}|null)$`):void 0}),S(e._zod,`values`,()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(e,n)=>e.value===null?e:t.innerType._zod.run(e,n)}),gi=x(`$ZodDefault`,(e,t)=>{T.init(e,t),e._zod.optin=`optional`,S(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);if(e.value===void 0)return e.value=t.defaultValue,e;let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(e=>_i(e,t)):_i(r,t)}});function _i(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}let vi=x(`$ZodPrefault`,(e,t)=>{T.init(e,t),e._zod.optin=`optional`,S(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>(n.direction===`backward`||e.value===void 0&&(e.value=t.defaultValue),t.innerType._zod.run(e,n))}),yi=x(`$ZodNonOptional`,(e,t)=>{T.init(e,t),S(e._zod,`values`,()=>{let e=t.innerType._zod.values;return e?new Set([...e].filter(e=>e!==void 0)):void 0}),e._zod.parse=(n,r)=>{let i=t.innerType._zod.run(n,r);return i instanceof Promise?i.then(t=>bi(t,e)):bi(i,e)}});function bi(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:`invalid_type`,expected:`nonoptional`,input:e.value,inst:t}),e}let xi=x(`$ZodCatch`,(e,t)=>{T.init(e,t),S(e._zod,`optin`,()=>t.innerType._zod.optin),S(e._zod,`optout`,()=>t.innerType._zod.optout),S(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(r=>(e.value=r.value,r.issues.length&&(e.value=t.catchValue({...e,error:{issues:r.issues.map(e=>Zt(e,n,yt()))},input:e.value}),e.issues=[]),e)):(e.value=r.value,r.issues.length&&(e.value=t.catchValue({...e,error:{issues:r.issues.map(e=>Zt(e,n,yt()))},input:e.value}),e.issues=[]),e)}}),Si=x(`$ZodPipe`,(e,t)=>{T.init(e,t),S(e._zod,`values`,()=>t.in._zod.values),S(e._zod,`optin`,()=>t.in._zod.optin),S(e._zod,`optout`,()=>t.out._zod.optout),S(e._zod,`propValues`,()=>t.in._zod.propValues),e._zod.parse=(e,n)=>{if(n.direction===`backward`){let r=t.out._zod.run(e,n);return r instanceof Promise?r.then(e=>Ci(e,t.in,n)):Ci(r,t.in,n)}let r=t.in._zod.run(e,n);return r instanceof Promise?r.then(e=>Ci(e,t.out,n)):Ci(r,t.out,n)}});function Ci(e,t,n){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},n)}let wi=x(`$ZodReadonly`,(e,t)=>{T.init(e,t),S(e._zod,`propValues`,()=>t.innerType._zod.propValues),S(e._zod,`values`,()=>t.innerType._zod.values),S(e._zod,`optin`,()=>t.innerType?._zod?.optin),S(e._zod,`optout`,()=>t.innerType?._zod?.optout),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(Ti):Ti(r)}});function Ti(e){return e.value=Object.freeze(e.value),e}let Ei=x(`$ZodCustom`,(e,t)=>{w.init(e,t),T.init(e,t),e._zod.parse=(e,t)=>e,e._zod.check=n=>{let r=n.value,i=t.fn(r);if(i instanceof Promise)return i.then(t=>Di(t,n,r,e));Di(i,n,r,e)}});function Di(e,t,n,r){if(!e){let e={code:`custom`,input:n,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(e.params=r._zod.def.params),t.issues.push($t(e))}}var Oi,ki=class{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...t){let n=t[0];return this._map.set(e,n),n&&typeof n==`object`&&`id`in n&&this._idmap.set(n.id,e),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(e){let t=this._map.get(e);return t&&typeof t==`object`&&`id`in t&&this._idmap.delete(t.id),this._map.delete(e),this}get(e){let t=e._zod.parent;if(t){let n={...this.get(t)??{}};delete n.id;let r={...n,...this._map.get(e)};return Object.keys(r).length?r:void 0}return this._map.get(e)}has(e){return this._map.has(e)}};function Ai(){return new ki}(Oi=globalThis).__zod_globalRegistry??(Oi.__zod_globalRegistry=Ai());let ji=globalThis.__zod_globalRegistry;function Mi(e,t){return new e({type:`string`,...C(t)})}function Ni(e,t){return new e({type:`string`,format:`email`,check:`string_format`,abort:!1,...C(t)})}function Pi(e,t){return new e({type:`string`,format:`guid`,check:`string_format`,abort:!1,...C(t)})}function Fi(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,...C(t)})}function Ii(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v4`,...C(t)})}function Li(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v6`,...C(t)})}function Ri(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v7`,...C(t)})}function zi(e,t){return new e({type:`string`,format:`url`,check:`string_format`,abort:!1,...C(t)})}function Bi(e,t){return new e({type:`string`,format:`emoji`,check:`string_format`,abort:!1,...C(t)})}function Vi(e,t){return new e({type:`string`,format:`nanoid`,check:`string_format`,abort:!1,...C(t)})}function Hi(e,t){return new e({type:`string`,format:`cuid`,check:`string_format`,abort:!1,...C(t)})}function Ui(e,t){return new e({type:`string`,format:`cuid2`,check:`string_format`,abort:!1,...C(t)})}function Wi(e,t){return new e({type:`string`,format:`ulid`,check:`string_format`,abort:!1,...C(t)})}function Gi(e,t){return new e({type:`string`,format:`xid`,check:`string_format`,abort:!1,...C(t)})}function Ki(e,t){return new e({type:`string`,format:`ksuid`,check:`string_format`,abort:!1,...C(t)})}function qi(e,t){return new e({type:`string`,format:`ipv4`,check:`string_format`,abort:!1,...C(t)})}function Ji(e,t){return new e({type:`string`,format:`ipv6`,check:`string_format`,abort:!1,...C(t)})}function Yi(e,t){return new e({type:`string`,format:`cidrv4`,check:`string_format`,abort:!1,...C(t)})}function Xi(e,t){return new e({type:`string`,format:`cidrv6`,check:`string_format`,abort:!1,...C(t)})}function Zi(e,t){return new e({type:`string`,format:`base64`,check:`string_format`,abort:!1,...C(t)})}function Qi(e,t){return new e({type:`string`,format:`base64url`,check:`string_format`,abort:!1,...C(t)})}function $i(e,t){return new e({type:`string`,format:`e164`,check:`string_format`,abort:!1,...C(t)})}function ea(e,t){return new e({type:`string`,format:`jwt`,check:`string_format`,abort:!1,...C(t)})}function ta(e,t){return new e({type:`string`,format:`datetime`,check:`string_format`,offset:!1,local:!1,precision:null,...C(t)})}function na(e,t){return new e({type:`string`,format:`date`,check:`string_format`,...C(t)})}function ra(e,t){return new e({type:`string`,format:`time`,check:`string_format`,precision:null,...C(t)})}function ia(e,t){return new e({type:`string`,format:`duration`,check:`string_format`,...C(t)})}function aa(e,t){return new e({type:`number`,checks:[],...C(t)})}function oa(e,t){return new e({type:`number`,check:`number_format`,abort:!1,format:`safeint`,...C(t)})}function sa(e,t){return new e({type:`boolean`,...C(t)})}function ca(e,t){return new e({type:`null`,...C(t)})}function la(e){return new e({type:`unknown`})}function ua(e,t){return new e({type:`never`,...C(t)})}function da(e,t){return new $n({check:`less_than`,...C(t),value:e,inclusive:!1})}function fa(e,t){return new $n({check:`less_than`,...C(t),value:e,inclusive:!0})}function pa(e,t){return new er({check:`greater_than`,...C(t),value:e,inclusive:!1})}function ma(e,t){return new er({check:`greater_than`,...C(t),value:e,inclusive:!0})}function ha(e,t){return new tr({check:`multiple_of`,...C(t),value:e})}function ga(e,t){return new rr({check:`max_length`,...C(t),maximum:e})}function _a(e,t){return new ir({check:`min_length`,...C(t),minimum:e})}function va(e,t){return new ar({check:`length_equals`,...C(t),length:e})}function ya(e,t){return new sr({check:`string_format`,format:`regex`,...C(t),pattern:e})}function ba(e){return new cr({check:`string_format`,format:`lowercase`,...C(e)})}function xa(e){return new lr({check:`string_format`,format:`uppercase`,...C(e)})}function Sa(e,t){return new ur({check:`string_format`,format:`includes`,...C(t),includes:e})}function Ca(e,t){return new dr({check:`string_format`,format:`starts_with`,...C(t),prefix:e})}function wa(e,t){return new fr({check:`string_format`,format:`ends_with`,...C(t),suffix:e})}function Ta(e){return new pr({check:`overwrite`,tx:e})}function Ea(e){return Ta(t=>t.normalize(e))}function Da(){return Ta(e=>e.trim())}function Oa(){return Ta(e=>e.toLowerCase())}function ka(){return Ta(e=>e.toUpperCase())}function Aa(){return Ta(e=>At(e))}function ja(e,t,n){return new e({type:`array`,element:t,...C(n)})}function Ma(e,t,n){let r=C(n);return r.abort??=!0,new e({type:`custom`,check:`custom`,fn:t,...r})}function Na(e,t,n){return new e({type:`custom`,check:`custom`,fn:t,...C(n)})}function Pa(e){let t=Fa(n=>(n.addIssue=e=>{if(typeof e==`string`)n.issues.push($t(e,n.value,t._zod.def));else{let r=e;r.fatal&&(r.continue=!1),r.code??=`custom`,r.input??=n.value,r.inst??=t,r.continue??=!t._zod.def.abort,n.issues.push($t(r))}},e(n.value,n)));return t}function Fa(e,t){let n=new w({check:`custom`,...C(t)});return n._zod.check=e,n}function Ia(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??ji,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 D(e,t,n={path:[],schemaPath:[]}){var r;let i=e._zod.def,a=t.seen.get(e);if(a)return a.count++,n.schemaPath.includes(e)&&(a.cycle=n.path),a.schema;let o={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,o);let s=e._zod.toJSONSchema?.();if(s)o.schema=s;else{let r={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,o.schema,r);else{let n=o.schema,a=t.processors[i.type];if(!a)throw Error(`[toJSONSchema]: Non-representable type encountered: ${i.type}`);a(e,t,n,r)}let a=e._zod.parent;a&&(o.ref||=a,D(a,t,r),t.seen.get(a).isParent=!0)}let c=t.metadataRegistry.get(e);return c&&Object.assign(o.schema,c),t.io===`input`&&O(e)&&(delete o.schema.examples,delete o.schema.default),t.io===`input`&&o.schema._prefault&&((r=o.schema).default??(r.default=o.schema._prefault)),delete o.schema._prefault,t.seen.get(e).schema}function La(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);let r=new Map;for(let t of e.seen.entries()){let n=e.metadataRegistry.get(t[0])?.id;if(n){let e=r.get(n);if(e&&e!==t[0])throw Error(`Duplicate schema id "${n}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);r.set(n,t[0])}}let i=t=>{let r=e.target===`draft-2020-12`?`$defs`:`definitions`;if(e.external){let n=e.external.registry.get(t[0])?.id,i=e.external.uri??(e=>e);if(n)return{ref:i(n)};let a=t[1].defId??t[1].schema.id??`schema${e.counter++}`;return t[1].defId=a,{defId:a,ref:`${i(`__shared`)}#/${r}/${a}`}}if(t[1]===n)return{ref:`#`};let i=`#/${r}/`,a=t[1].schema.id??`__schema${e.counter++}`;return{defId:a,ref:i+a}},a=e=>{if(e[1].schema.$ref)return;let t=e[1],{ref:n,defId:r}=i(e);t.def={...t.schema},r&&(t.defId=r);let a=t.schema;for(let e in a)delete a[e];a.$ref=n};if(e.cycles===`throw`)for(let t of e.seen.entries()){let e=t[1];if(e.cycle)throw Error(`Cycle detected: #/${e.cycle?.join(`/`)}/<root>
39
38
 
40
- Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let n of e.seen.entries()){let r=n[1];if(t===n[0]){a(n);continue}if(e.external){let r=e.external.registry.get(n[0])?.id;if(t!==n[0]&&r){a(n);continue}}if(e.metadataRegistry.get(n[0])?.id){a(n);continue}if(r.cycle){a(n);continue}if(r.count>1&&e.reused===`ref`){a(n);continue}}}function ls(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);let r=t=>{let n=e.seen.get(t);if(n.ref===null)return;let i=n.def??n.schema,a={...i},o=n.ref;if(n.ref=null,o){r(o);let n=e.seen.get(o),s=n.schema;if(s.$ref&&(e.target===`draft-07`||e.target===`draft-04`||e.target===`openapi-3.0`)?(i.allOf=i.allOf??[],i.allOf.push(s)):Object.assign(i,s),Object.assign(i,a),t._zod.parent===o)for(let e in i)e===`$ref`||e===`allOf`||e in a||delete i[e];if(s.$ref)for(let e in i)e===`$ref`||e===`allOf`||e in n.def&&JSON.stringify(i[e])===JSON.stringify(n.def[e])&&delete i[e]}let s=t._zod.parent;if(s&&s!==o){r(s);let t=e.seen.get(s);if(t?.schema.$ref&&(i.$ref=t.schema.$ref,t.def))for(let e in i)e===`$ref`||e===`allOf`||e in t.def&&JSON.stringify(i[e])===JSON.stringify(t.def[e])&&delete i[e]}e.override({zodSchema:t,jsonSchema:i,path:n.path??[]})};for(let t of[...e.seen.entries()].reverse())r(t[0]);let i={};if(e.target===`draft-2020-12`?i.$schema=`https://json-schema.org/draft/2020-12/schema`:e.target===`draft-07`?i.$schema=`http://json-schema.org/draft-07/schema#`:e.target===`draft-04`?i.$schema=`http://json-schema.org/draft-04/schema#`:e.target,e.external?.uri){let n=e.external.registry.get(t)?.id;if(!n)throw Error("Schema is missing an `id` property");i.$id=e.external.uri(n)}Object.assign(i,n.def??n.schema);let a=e.external?.defs??{};for(let t of e.seen.entries()){let e=t[1];e.def&&e.defId&&(a[e.defId]=e.def)}e.external||Object.keys(a).length>0&&(e.target===`draft-2020-12`?i.$defs=a:i.definitions=a);try{let n=JSON.parse(JSON.stringify(i));return Object.defineProperty(n,`~standard`,{value:{...t[`~standard`],jsonSchema:{input:ds(t,`input`,e.processors),output:ds(t,`output`,e.processors)}},enumerable:!1,writable:!1}),n}catch{throw Error(`Error converting schema to JSON.`)}}function N(e,t){let n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);let r=e._zod.def;if(r.type===`transform`)return!0;if(r.type===`array`)return N(r.element,n);if(r.type===`set`)return N(r.valueType,n);if(r.type===`lazy`)return N(r.getter(),n);if(r.type===`promise`||r.type===`optional`||r.type===`nonoptional`||r.type===`nullable`||r.type===`readonly`||r.type===`default`||r.type===`prefault`)return N(r.innerType,n);if(r.type===`intersection`)return N(r.left,n)||N(r.right,n);if(r.type===`record`||r.type===`map`)return N(r.keyType,n)||N(r.valueType,n);if(r.type===`pipe`)return N(r.in,n)||N(r.out,n);if(r.type===`object`){for(let e in r.shape)if(N(r.shape[e],n))return!0;return!1}if(r.type===`union`){for(let e of r.options)if(N(e,n))return!0;return!1}if(r.type===`tuple`){for(let e of r.items)if(N(e,n))return!0;return!!(r.rest&&N(r.rest,n))}return!1}let us=(e,t={})=>n=>{let r=ss({...n,processors:t});return M(e,r),cs(r,e),ls(r,e)},ds=(e,t,n={})=>r=>{let{libraryOptions:i,target:a}=r??{},o=ss({...i??{},target:a,io:t,processors:n});return M(e,o),cs(o,e),ls(o,e)},fs={guid:`uuid`,url:`uri`,datetime:`date-time`,json_string:`json-string`,regex:``},ps=(e,t,n,r)=>{let i=n;i.type=`string`;let{minimum:a,maximum:o,format:s,patterns:c,contentEncoding:l}=e._zod.bag;if(typeof a==`number`&&(i.minLength=a),typeof o==`number`&&(i.maxLength=o),s&&(i.format=fs[s]??s,i.format===``&&delete i.format,s===`time`&&delete i.format),l&&(i.contentEncoding=l),c&&c.size>0){let e=[...c];e.length===1?i.pattern=e[0].source:e.length>1&&(i.allOf=[...e.map(e=>({...t.target===`draft-07`||t.target===`draft-04`||t.target===`openapi-3.0`?{type:`string`}:{},pattern:e.source}))])}},ms=(e,t,n,r)=>{let i=n,{minimum:a,maximum:o,format:s,multipleOf:c,exclusiveMaximum:l,exclusiveMinimum:u}=e._zod.bag;typeof s==`string`&&s.includes(`int`)?i.type=`integer`:i.type=`number`,typeof u==`number`&&(t.target===`draft-04`||t.target===`openapi-3.0`?(i.minimum=u,i.exclusiveMinimum=!0):i.exclusiveMinimum=u),typeof a==`number`&&(i.minimum=a,typeof u==`number`&&t.target!==`draft-04`&&(u>=a?delete i.minimum:delete i.exclusiveMinimum)),typeof l==`number`&&(t.target===`draft-04`||t.target===`openapi-3.0`?(i.maximum=l,i.exclusiveMaximum=!0):i.exclusiveMaximum=l),typeof o==`number`&&(i.maximum=o,typeof l==`number`&&t.target!==`draft-04`&&(l<=o?delete i.maximum:delete i.exclusiveMaximum)),typeof c==`number`&&(i.multipleOf=c)},hs=(e,t,n,r)=>{n.type=`boolean`},gs=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`BigInt cannot be represented in JSON Schema`)},_s=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Symbols cannot be represented in JSON Schema`)},vs=(e,t,n,r)=>{t.target===`openapi-3.0`?(n.type=`string`,n.nullable=!0,n.enum=[null]):n.type=`null`},ys=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Undefined cannot be represented in JSON Schema`)},bs=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Void cannot be represented in JSON Schema`)},xs=(e,t,n,r)=>{n.not={}},Ss=(e,t,n,r)=>{},Cs=(e,t,n,r)=>{},ws=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Date cannot be represented in JSON Schema`)},Ts=(e,t,n,r)=>{let i=e._zod.def,a=Wn(i.entries);a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),n.enum=a},Es=(e,t,n,r)=>{let i=e._zod.def,a=[];for(let e of i.values)if(e===void 0){if(t.unrepresentable===`throw`)throw Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof e==`bigint`){if(t.unrepresentable===`throw`)throw Error(`BigInt literals cannot be represented in JSON Schema`);a.push(Number(e))}else a.push(e);if(a.length!==0)if(a.length===1){let e=a[0];n.type=e===null?`null`:typeof e,t.target===`draft-04`||t.target===`openapi-3.0`?n.enum=[e]:n.const=e}else a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),a.every(e=>typeof e==`boolean`)&&(n.type=`boolean`),a.every(e=>e===null)&&(n.type=`null`),n.enum=a},Ds=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`NaN cannot be represented in JSON Schema`)},Os=(e,t,n,r)=>{let i=n,a=e._zod.pattern;if(!a)throw Error(`Pattern not found in template literal`);i.type=`string`,i.pattern=a.source},ks=(e,t,n,r)=>{let i=n,a={type:`string`,format:`binary`,contentEncoding:`binary`},{minimum:o,maximum:s,mime:c}=e._zod.bag;o!==void 0&&(a.minLength=o),s!==void 0&&(a.maxLength=s),c?c.length===1?(a.contentMediaType=c[0],Object.assign(i,a)):(Object.assign(i,a),i.anyOf=c.map(e=>({contentMediaType:e}))):Object.assign(i,a)},As=(e,t,n,r)=>{n.type=`boolean`},js=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Custom types cannot be represented in JSON Schema`)},Ms=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Function types cannot be represented in JSON Schema`)},Ns=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Transforms cannot be represented in JSON Schema`)},Ps=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Map cannot be represented in JSON Schema`)},Fs=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Set cannot be represented in JSON Schema`)},Is=(e,t,n,r)=>{let i=n,a=e._zod.def,{minimum:o,maximum:s}=e._zod.bag;typeof o==`number`&&(i.minItems=o),typeof s==`number`&&(i.maxItems=s),i.type=`array`,i.items=M(a.element,t,{...r,path:[...r.path,`items`]})},Ls=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`object`,i.properties={};let o=a.shape;for(let e in o)i.properties[e]=M(o[e],t,{...r,path:[...r.path,`properties`,e]});let s=new Set(Object.keys(o)),c=new Set([...s].filter(e=>{let n=a.shape[e]._zod;return t.io===`input`?n.optin===void 0:n.optout===void 0}));c.size>0&&(i.required=Array.from(c)),a.catchall?._zod.def.type===`never`?i.additionalProperties=!1:a.catchall?a.catchall&&(i.additionalProperties=M(a.catchall,t,{...r,path:[...r.path,`additionalProperties`]})):t.io===`output`&&(i.additionalProperties=!1)},Rs=(e,t,n,r)=>{let i=e._zod.def,a=i.inclusive===!1,o=i.options.map((e,n)=>M(e,t,{...r,path:[...r.path,a?`oneOf`:`anyOf`,n]}));a?n.oneOf=o:n.anyOf=o},zs=(e,t,n,r)=>{let i=e._zod.def,a=M(i.left,t,{...r,path:[...r.path,`allOf`,0]}),o=M(i.right,t,{...r,path:[...r.path,`allOf`,1]}),s=e=>`allOf`in e&&Object.keys(e).length===1;n.allOf=[...s(a)?a.allOf:[a],...s(o)?o.allOf:[o]]},Bs=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`array`;let o=t.target===`draft-2020-12`?`prefixItems`:`items`,s=t.target===`draft-2020-12`||t.target===`openapi-3.0`?`items`:`additionalItems`,c=a.items.map((e,n)=>M(e,t,{...r,path:[...r.path,o,n]})),l=a.rest?M(a.rest,t,{...r,path:[...r.path,s,...t.target===`openapi-3.0`?[a.items.length]:[]]}):null;t.target===`draft-2020-12`?(i.prefixItems=c,l&&(i.items=l)):t.target===`openapi-3.0`?(i.items={anyOf:c},l&&i.items.anyOf.push(l),i.minItems=c.length,l||(i.maxItems=c.length)):(i.items=c,l&&(i.additionalItems=l));let{minimum:u,maximum:d}=e._zod.bag;typeof u==`number`&&(i.minItems=u),typeof d==`number`&&(i.maxItems=d)},Vs=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`object`;let o=a.keyType,s=o._zod.bag?.patterns;if(a.mode===`loose`&&s&&s.size>0){let e=M(a.valueType,t,{...r,path:[...r.path,`patternProperties`,`*`]});i.patternProperties={};for(let t of s)i.patternProperties[t.source]=e}else (t.target===`draft-07`||t.target===`draft-2020-12`)&&(i.propertyNames=M(a.keyType,t,{...r,path:[...r.path,`propertyNames`]})),i.additionalProperties=M(a.valueType,t,{...r,path:[...r.path,`additionalProperties`]});let c=o._zod.values;if(c){let e=[...c].filter(e=>typeof e==`string`||typeof e==`number`);e.length>0&&(i.required=e)}},Hs=(e,t,n,r)=>{let i=e._zod.def,a=M(i.innerType,t,r),o=t.seen.get(e);t.target===`openapi-3.0`?(o.ref=i.innerType,n.nullable=!0):n.anyOf=[a,{type:`null`}]},Us=(e,t,n,r)=>{let i=e._zod.def;M(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},Ws=(e,t,n,r)=>{let i=e._zod.def;M(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.default=JSON.parse(JSON.stringify(i.defaultValue))},Gs=(e,t,n,r)=>{let i=e._zod.def;M(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,t.io===`input`&&(n._prefault=JSON.parse(JSON.stringify(i.defaultValue)))},Ks=(e,t,n,r)=>{let i=e._zod.def;M(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o;try{o=i.catchValue(void 0)}catch{throw Error(`Dynamic catch values are not supported in JSON Schema`)}n.default=o},qs=(e,t,n,r)=>{let i=e._zod.def,a=t.io===`input`?i.in._zod.def.type===`transform`?i.out:i.in:i.out;M(a,t,r);let o=t.seen.get(e);o.ref=a},Js=(e,t,n,r)=>{let i=e._zod.def;M(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.readOnly=!0},Ys=(e,t,n,r)=>{let i=e._zod.def;M(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},Xs=(e,t,n,r)=>{let i=e._zod.def;M(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},Zs={string:ps,number:ms,boolean:hs,bigint:gs,symbol:_s,null:vs,undefined:ys,void:bs,never:xs,any:Ss,unknown:Cs,date:ws,enum:Ts,literal:Es,nan:Ds,template_literal:Os,file:ks,success:As,custom:js,function:Ms,transform:Ns,map:Ps,set:Fs,array:Is,object:Ls,union:Rs,intersection:zs,tuple:Bs,record:Vs,nullable:Hs,nonoptional:Us,default:Ws,prefault:Gs,catch:Ks,pipe:qs,readonly:Js,promise:Ys,optional:Xs,lazy:(e,t,n,r)=>{let i=e._zod.innerType;M(i,t,r);let a=t.seen.get(e);a.ref=i}};function Qs(e,t){if(`_idmap`in e){let n=e,r=ss({...t,processors:Zs}),i={};for(let e of n._idmap.entries()){let[t,n]=e;M(n,r)}let a={};r.external={registry:n,uri:t?.uri,defs:i};for(let e of n._idmap.entries()){let[t,n]=e;cs(r,n),a[t]=ls(r,n)}return Object.keys(i).length>0&&(a.__shared={[r.target===`draft-2020-12`?`$defs`:`definitions`]:i}),{schemas:a}}let n=ss({...t,processors:Zs});return M(e,n),cs(n,e),ls(n,e)}let $s=D(`ZodMiniType`,(e,t)=>{if(!e._zod)throw Error(`Uninitialized schema in ZodMiniType.`);A.init(e,t),e.def=t,e.type=t.type,e.parse=(t,n)=>Ar(e,t,n,{callee:e.parse}),e.safeParse=(t,n)=>Pr(e,t,n),e.parseAsync=async(t,n)=>Mr(e,t,n,{callee:e.parseAsync}),e.safeParseAsync=async(t,n)=>Ir(e,t,n),e.check=(...n)=>e.clone({...t,checks:[...t.checks??[],...n.map(e=>typeof e==`function`?{_zod:{check:e,def:{check:`custom`},onattach:[]}}:e)]},{parent:!0}),e.with=e.check,e.clone=(t,n)=>cr(e,t,n),e.brand=()=>e,e.register=((t,n)=>(t.add(e,n),e)),e.apply=t=>t(e)}),ec=D(`ZodMiniObject`,(e,t)=>{wa.init(e,t),$s.init(e,t),O(e,`shape`,()=>t.shape)});function tc(e,t){return new ec({type:`object`,shape:e??{},...k(t)})}let nc=D(`ZodISODateTime`,(e,t)=>{Qi.init(e,t),I.init(e,t)});function rc(e){return Eo(nc,e)}let ic=D(`ZodISODate`,(e,t)=>{$i.init(e,t),I.init(e,t)});function ac(e){return Do(ic,e)}let oc=D(`ZodISOTime`,(e,t)=>{ea.init(e,t),I.init(e,t)});function sc(e){return Oo(oc,e)}let cc=D(`ZodISODuration`,(e,t)=>{ta.init(e,t),I.init(e,t)});function lc(e){return ko(cc,e)}let uc=(e,t)=>{Tr.init(e,t),e.name=`ZodError`,Object.defineProperties(e,{format:{value:t=>Or(e,t)},flatten:{value:t=>Dr(e,t)},addIssue:{value:t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,Gn,2)}},addIssues:{value:t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,Gn,2)}},isEmpty:{get(){return e.issues.length===0}}})};D(`ZodError`,uc);let dc=D(`ZodError`,uc,{Parent:Error}),fc=kr(dc),pc=jr(dc),mc=Nr(dc),hc=Fr(dc),gc=Lr(dc),_c=Rr(dc),vc=zr(dc),yc=Br(dc),bc=Vr(dc),xc=Hr(dc),Sc=Ur(dc),Cc=Wr(dc),P=D(`ZodType`,(e,t)=>(A.init(e,t),Object.assign(e[`~standard`],{jsonSchema:{input:ds(e,`input`),output:ds(e,`output`)}}),e.toJSONSchema=us(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,`_def`,{value:t}),e.check=(...n)=>e.clone(Qn(t,{checks:[...t.checks??[],...n.map(e=>typeof e==`function`?{_zod:{check:e,def:{check:`custom`},onattach:[]}}:e)]}),{parent:!0}),e.with=e.check,e.clone=(t,n)=>cr(e,t,n),e.brand=()=>e,e.register=((t,n)=>(t.add(e,n),e)),e.parse=(t,n)=>fc(e,t,n,{callee:e.parse}),e.safeParse=(t,n)=>mc(e,t,n),e.parseAsync=async(t,n)=>pc(e,t,n,{callee:e.parseAsync}),e.safeParseAsync=async(t,n)=>hc(e,t,n),e.spa=e.safeParseAsync,e.encode=(t,n)=>gc(e,t,n),e.decode=(t,n)=>_c(e,t,n),e.encodeAsync=async(t,n)=>vc(e,t,n),e.decodeAsync=async(t,n)=>yc(e,t,n),e.safeEncode=(t,n)=>bc(e,t,n),e.safeDecode=(t,n)=>xc(e,t,n),e.safeEncodeAsync=async(t,n)=>Sc(e,t,n),e.safeDecodeAsync=async(t,n)=>Cc(e,t,n),e.refine=(t,n)=>e.check(Nl(t,n)),e.superRefine=t=>e.check(Pl(t)),e.overwrite=t=>e.check(Xo(t)),e.optional=()=>G(e),e.exactOptional=()=>gl(e),e.nullable=()=>vl(e),e.nullish=()=>G(vl(e)),e.nonoptional=t=>wl(e,t),e.array=()=>B(e),e.or=t=>H([e,t]),e.and=t=>sl(e,t),e.transform=t=>Ol(e,pl(t)),e.default=t=>bl(e,t),e.prefault=t=>Sl(e,t),e.catch=t=>El(e,t),e.pipe=t=>Ol(e,t),e.readonly=()=>Al(e),e.describe=t=>{let n=e.clone();return to.add(n,{description:t}),n},Object.defineProperty(e,`description`,{get(){return to.get(e)?.description},configurable:!0}),e.meta=(...t)=>{if(t.length===0)return to.get(e);let n=e.clone();return to.add(n,t[0]),n},e.isOptional=()=>e.safeParse(void 0).success,e.isNullable=()=>e.safeParse(null).success,e.apply=t=>t(e),e)),wc=D(`_ZodString`,(e,t)=>{Bi.init(e,t),P.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ps(e,t,n,r);let n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,e.regex=(...t)=>e.check(Wo(...t)),e.includes=(...t)=>e.check(qo(...t)),e.startsWith=(...t)=>e.check(Jo(...t)),e.endsWith=(...t)=>e.check(Yo(...t)),e.min=(...t)=>e.check(Ho(...t)),e.max=(...t)=>e.check(Vo(...t)),e.length=(...t)=>e.check(Uo(...t)),e.nonempty=(...t)=>e.check(Ho(1,...t)),e.lowercase=t=>e.check(Go(t)),e.uppercase=t=>e.check(Ko(t)),e.trim=()=>e.check(Qo()),e.normalize=(...t)=>e.check(Zo(...t)),e.toLowerCase=()=>e.check($o()),e.toUpperCase=()=>e.check(es()),e.slugify=()=>e.check(ts())}),Tc=D(`ZodString`,(e,t)=>{Bi.init(e,t),wc.init(e,t),e.email=t=>e.check(ro(Ec,t)),e.url=t=>e.check(lo(kc,t)),e.jwt=t=>e.check(To(Wc,t)),e.emoji=t=>e.check(uo(Ac,t)),e.guid=t=>e.check(io(Dc,t)),e.uuid=t=>e.check(ao(Oc,t)),e.uuidv4=t=>e.check(oo(Oc,t)),e.uuidv6=t=>e.check(so(Oc,t)),e.uuidv7=t=>e.check(co(Oc,t)),e.nanoid=t=>e.check(fo(jc,t)),e.guid=t=>e.check(io(Dc,t)),e.cuid=t=>e.check(po(Mc,t)),e.cuid2=t=>e.check(mo(Nc,t)),e.ulid=t=>e.check(ho(Pc,t)),e.base64=t=>e.check(So(Vc,t)),e.base64url=t=>e.check(Co(Hc,t)),e.xid=t=>e.check(go(Fc,t)),e.ksuid=t=>e.check(_o(Ic,t)),e.ipv4=t=>e.check(vo(Lc,t)),e.ipv6=t=>e.check(yo(Rc,t)),e.cidrv4=t=>e.check(bo(zc,t)),e.cidrv6=t=>e.check(xo(Bc,t)),e.e164=t=>e.check(wo(Uc,t)),e.datetime=t=>e.check(rc(t)),e.date=t=>e.check(ac(t)),e.time=t=>e.check(sc(t)),e.duration=t=>e.check(lc(t))});function F(e){return no(Tc,e)}let I=D(`ZodStringFormat`,(e,t)=>{j.init(e,t),wc.init(e,t)}),Ec=D(`ZodEmail`,(e,t)=>{Ui.init(e,t),I.init(e,t)}),Dc=D(`ZodGUID`,(e,t)=>{Vi.init(e,t),I.init(e,t)}),Oc=D(`ZodUUID`,(e,t)=>{Hi.init(e,t),I.init(e,t)}),kc=D(`ZodURL`,(e,t)=>{Wi.init(e,t),I.init(e,t)}),Ac=D(`ZodEmoji`,(e,t)=>{Gi.init(e,t),I.init(e,t)}),jc=D(`ZodNanoID`,(e,t)=>{Ki.init(e,t),I.init(e,t)}),Mc=D(`ZodCUID`,(e,t)=>{qi.init(e,t),I.init(e,t)}),Nc=D(`ZodCUID2`,(e,t)=>{Ji.init(e,t),I.init(e,t)}),Pc=D(`ZodULID`,(e,t)=>{Yi.init(e,t),I.init(e,t)}),Fc=D(`ZodXID`,(e,t)=>{Xi.init(e,t),I.init(e,t)}),Ic=D(`ZodKSUID`,(e,t)=>{Zi.init(e,t),I.init(e,t)}),Lc=D(`ZodIPv4`,(e,t)=>{na.init(e,t),I.init(e,t)}),Rc=D(`ZodIPv6`,(e,t)=>{ra.init(e,t),I.init(e,t)}),zc=D(`ZodCIDRv4`,(e,t)=>{ia.init(e,t),I.init(e,t)}),Bc=D(`ZodCIDRv6`,(e,t)=>{aa.init(e,t),I.init(e,t)}),Vc=D(`ZodBase64`,(e,t)=>{sa.init(e,t),I.init(e,t)}),Hc=D(`ZodBase64URL`,(e,t)=>{la.init(e,t),I.init(e,t)}),Uc=D(`ZodE164`,(e,t)=>{ua.init(e,t),I.init(e,t)}),Wc=D(`ZodJWT`,(e,t)=>{fa.init(e,t),I.init(e,t)}),Gc=D(`ZodNumber`,(e,t)=>{pa.init(e,t),P.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ms(e,t,n,r),e.gt=(t,n)=>e.check(Ro(t,n)),e.gte=(t,n)=>e.check(zo(t,n)),e.min=(t,n)=>e.check(zo(t,n)),e.lt=(t,n)=>e.check(Io(t,n)),e.lte=(t,n)=>e.check(Lo(t,n)),e.max=(t,n)=>e.check(Lo(t,n)),e.int=t=>e.check(qc(t)),e.safe=t=>e.check(qc(t)),e.positive=t=>e.check(Ro(0,t)),e.nonnegative=t=>e.check(zo(0,t)),e.negative=t=>e.check(Io(0,t)),e.nonpositive=t=>e.check(Lo(0,t)),e.multipleOf=(t,n)=>e.check(Bo(t,n)),e.step=(t,n)=>e.check(Bo(t,n)),e.finite=()=>e;let n=e._zod.bag;e.minValue=Math.max(n.minimum??-1/0,n.exclusiveMinimum??-1/0)??null,e.maxValue=Math.min(n.maximum??1/0,n.exclusiveMaximum??1/0)??null,e.isInt=(n.format??``).includes(`int`)||Number.isSafeInteger(n.multipleOf??.5),e.isFinite=!0,e.format=n.format??null});function L(e){return Ao(Gc,e)}let Kc=D(`ZodNumberFormat`,(e,t)=>{ma.init(e,t),Gc.init(e,t)});function qc(e){return jo(Kc,e)}let Jc=D(`ZodBoolean`,(e,t)=>{ha.init(e,t),P.init(e,t),e._zod.processJSONSchema=(t,n,r)=>hs(e,t,n,r)});function R(e){return Mo(Jc,e)}let Yc=D(`ZodNull`,(e,t)=>{ga.init(e,t),P.init(e,t),e._zod.processJSONSchema=(t,n,r)=>vs(e,t,n,r)});function Xc(e){return No(Yc,e)}let Zc=D(`ZodUnknown`,(e,t)=>{_a.init(e,t),P.init(e,t),e._zod.processJSONSchema=(e,t,n)=>void 0});function z(){return Po(Zc)}let Qc=D(`ZodNever`,(e,t)=>{va.init(e,t),P.init(e,t),e._zod.processJSONSchema=(t,n,r)=>xs(e,t,n,r)});function $c(e){return Fo(Qc,e)}let el=D(`ZodArray`,(e,t)=>{ba.init(e,t),P.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Is(e,t,n,r),e.element=t.element,e.min=(t,n)=>e.check(Ho(t,n)),e.nonempty=t=>e.check(Ho(1,t)),e.max=(t,n)=>e.check(Vo(t,n)),e.length=(t,n)=>e.check(Uo(t,n)),e.unwrap=()=>e.element});function B(e,t){return ns(el,e,t)}let tl=D(`ZodObject`,(e,t)=>{Ta.init(e,t),P.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ls(e,t,n,r),O(e,`shape`,()=>t.shape),e.keyof=()=>ul(Object.keys(e._zod.def.shape)),e.catchall=t=>e.clone({...e._zod.def,catchall:t}),e.passthrough=()=>e.clone({...e._zod.def,catchall:z()}),e.loose=()=>e.clone({...e._zod.def,catchall:z()}),e.strict=()=>e.clone({...e._zod.def,catchall:$c()}),e.strip=()=>e.clone({...e._zod.def,catchall:void 0}),e.extend=t=>pr(e,t),e.safeExtend=t=>mr(e,t),e.merge=t=>hr(e,t),e.pick=t=>dr(e,t),e.omit=t=>fr(e,t),e.partial=(...t)=>gr(ml,e,t[0]),e.required=(...t)=>_r(Cl,e,t[0])});function V(e,t){return new tl({type:`object`,shape:e??{},...k(t)})}function nl(e,t){return new tl({type:`object`,shape:e,catchall:z(),...k(t)})}let rl=D(`ZodUnion`,(e,t)=>{Da.init(e,t),P.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Rs(e,t,n,r),e.options=t.options});function H(e,t){return new rl({type:`union`,options:e,...k(t)})}let il=D(`ZodDiscriminatedUnion`,(e,t)=>{rl.init(e,t),Oa.init(e,t)});function al(e,t,n){return new il({type:`union`,options:t,discriminator:e,...k(n)})}let ol=D(`ZodIntersection`,(e,t)=>{ka.init(e,t),P.init(e,t),e._zod.processJSONSchema=(t,n,r)=>zs(e,t,n,r)});function sl(e,t){return new ol({type:`intersection`,left:e,right:t})}let cl=D(`ZodRecord`,(e,t)=>{Ma.init(e,t),P.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Vs(e,t,n,r),e.keyType=t.keyType,e.valueType=t.valueType});function U(e,t,n){return new cl({type:`record`,keyType:e,valueType:t,...k(n)})}let ll=D(`ZodEnum`,(e,t)=>{Na.init(e,t),P.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ts(e,t,n,r),e.enum=t.entries,e.options=Object.values(t.entries);let n=new Set(Object.keys(t.entries));e.extract=(e,r)=>{let i={};for(let r of e)if(n.has(r))i[r]=t.entries[r];else throw Error(`Key ${r} not found in enum`);return new ll({...t,checks:[],...k(r),entries:i})},e.exclude=(e,r)=>{let i={...t.entries};for(let t of e)if(n.has(t))delete i[t];else throw Error(`Key ${t} not found in enum`);return new ll({...t,checks:[],...k(r),entries:i})}});function ul(e,t){return new ll({type:`enum`,entries:Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e,...k(t)})}let dl=D(`ZodLiteral`,(e,t)=>{Pa.init(e,t),P.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Es(e,t,n,r),e.values=new Set(t.values),Object.defineProperty(e,`value`,{get(){if(t.values.length>1)throw Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function W(e,t){return new dl({type:`literal`,values:Array.isArray(e)?e:[e],...k(t)})}let fl=D(`ZodTransform`,(e,t)=>{Fa.init(e,t),P.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ns(e,t,n,r),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new Vn(e.constructor.name);n.addIssue=r=>{if(typeof r==`string`)n.issues.push(Cr(r,n.value,t));else{let t=r;t.fatal&&(t.continue=!1),t.code??=`custom`,t.input??=n.value,t.inst??=e,n.issues.push(Cr(t))}};let i=t.transform(n.value,n);return i instanceof Promise?i.then(e=>(n.value=e,n)):(n.value=i,n)}});function pl(e){return new fl({type:`transform`,transform:e})}let ml=D(`ZodOptional`,(e,t)=>{La.init(e,t),P.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Xs(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function G(e){return new ml({type:`optional`,innerType:e})}let hl=D(`ZodExactOptional`,(e,t)=>{Ra.init(e,t),P.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Xs(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function gl(e){return new hl({type:`optional`,innerType:e})}let _l=D(`ZodNullable`,(e,t)=>{za.init(e,t),P.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Hs(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function vl(e){return new _l({type:`nullable`,innerType:e})}let yl=D(`ZodDefault`,(e,t)=>{Ba.init(e,t),P.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ws(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function bl(e,t){return new yl({type:`default`,innerType:e,get defaultValue(){return typeof t==`function`?t():ar(t)}})}let xl=D(`ZodPrefault`,(e,t)=>{Ha.init(e,t),P.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Gs(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Sl(e,t){return new xl({type:`prefault`,innerType:e,get defaultValue(){return typeof t==`function`?t():ar(t)}})}let Cl=D(`ZodNonOptional`,(e,t)=>{Ua.init(e,t),P.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Us(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function wl(e,t){return new Cl({type:`nonoptional`,innerType:e,...k(t)})}let Tl=D(`ZodCatch`,(e,t)=>{Ga.init(e,t),P.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ks(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function El(e,t){return new Tl({type:`catch`,innerType:e,catchValue:typeof t==`function`?t:()=>t})}let Dl=D(`ZodPipe`,(e,t)=>{Ka.init(e,t),P.init(e,t),e._zod.processJSONSchema=(t,n,r)=>qs(e,t,n,r),e.in=t.in,e.out=t.out});function Ol(e,t){return new Dl({type:`pipe`,in:e,out:t})}let kl=D(`ZodReadonly`,(e,t)=>{Ja.init(e,t),P.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Js(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Al(e){return new kl({type:`readonly`,innerType:e})}let jl=D(`ZodCustom`,(e,t)=>{Xa.init(e,t),P.init(e,t),e._zod.processJSONSchema=(t,n,r)=>js(e,t,n,r)});function Ml(e,t){return rs(jl,e??(()=>!0),t)}function Nl(e,t={}){return is(jl,e,t)}function Pl(e){return as(e)}function Fl(e,t){return Ol(pl(e),t)}let Il=Symbol(`Let zodToJsonSchema decide on which parser to use`),Ll={name:void 0,$refStrategy:`root`,basePath:[`#`],effectStrategy:`input`,pipeStrategy:`all`,dateStrategy:`format:date-time`,mapStrategy:`entries`,removeAdditionalStrategy:`passthrough`,allowedAdditionalProperties:!0,rejectedAdditionalProperties:!1,definitionPath:`definitions`,target:`jsonSchema7`,strictUnions:!1,definitions:{},errorMessages:!1,markdownDescription:!1,patternStrategy:`escape`,applyRegexFlags:!1,emailStrategy:`format:email`,base64Strategy:`contentEncoding:base64`,nameStrategy:`ref`,openAiAnyTypeName:`OpenAiAnyType`},Rl=e=>typeof e==`string`?{...Ll,name:e}:{...Ll,...e},zl=e=>{let t=Rl(e),n=t.name===void 0?t.basePath:[...t.basePath,t.definitionPath,t.name];return{...t,flags:{hasReferencedOpenAiAnyType:!1},currentPath:n,propertyPath:void 0,seen:new Map(Object.entries(t.definitions).map(([e,n])=>[n._def,{def:n._def,path:[...t.basePath,t.definitionPath,e],jsonSchema:void 0}]))}};function Bl(e,t,n,r){r?.errorMessages&&n&&(e.errorMessage={...e.errorMessage,[t]:n})}function K(e,t,n,r,i){e[t]=n,Bl(e,t,r,i)}let Vl=(e,t)=>{let n=0;for(;n<e.length&&n<t.length&&e[n]===t[n];n++);return[(e.length-n).toString(),...t.slice(n)].join(`/`)};function Hl(e){if(e.target!==`openAi`)return{};let t=[...e.basePath,e.definitionPath,e.openAiAnyTypeName];return e.flags.hasReferencedOpenAiAnyType=!0,{$ref:e.$refStrategy===`relative`?Vl(t,e.currentPath):t.join(`/`)}}function Ul(e,t){let n={type:`array`};return e.type?._def&&e.type?._def?.typeName!==E.ZodAny&&(n.items=J(e.type._def,{...t,currentPath:[...t.currentPath,`items`]})),e.minLength&&K(n,`minItems`,e.minLength.value,e.minLength.message,t),e.maxLength&&K(n,`maxItems`,e.maxLength.value,e.maxLength.message,t),e.exactLength&&(K(n,`minItems`,e.exactLength.value,e.exactLength.message,t),K(n,`maxItems`,e.exactLength.value,e.exactLength.message,t)),n}function Wl(e,t){let n={type:`integer`,format:`int64`};if(!e.checks)return n;for(let r of e.checks)switch(r.kind){case`min`:t.target===`jsonSchema7`?r.inclusive?K(n,`minimum`,r.value,r.message,t):K(n,`exclusiveMinimum`,r.value,r.message,t):(r.inclusive||(n.exclusiveMinimum=!0),K(n,`minimum`,r.value,r.message,t));break;case`max`:t.target===`jsonSchema7`?r.inclusive?K(n,`maximum`,r.value,r.message,t):K(n,`exclusiveMaximum`,r.value,r.message,t):(r.inclusive||(n.exclusiveMaximum=!0),K(n,`maximum`,r.value,r.message,t));break;case`multipleOf`:K(n,`multipleOf`,r.value,r.message,t);break}return n}function Gl(){return{type:`boolean`}}function Kl(e,t){return J(e.type._def,t)}let ql=(e,t)=>J(e.innerType._def,t);function Jl(e,t,n){let r=n??t.dateStrategy;if(Array.isArray(r))return{anyOf:r.map((n,r)=>Jl(e,t,n))};switch(r){case`string`:case`format:date-time`:return{type:`string`,format:`date-time`};case`format:date`:return{type:`string`,format:`date`};case`integer`:return Yl(e,t)}}let Yl=(e,t)=>{let n={type:`integer`,format:`unix-time`};if(t.target===`openApi3`)return n;for(let r of e.checks)switch(r.kind){case`min`:K(n,`minimum`,r.value,r.message,t);break;case`max`:K(n,`maximum`,r.value,r.message,t);break}return n};function Xl(e,t){return{...J(e.innerType._def,t),default:e.defaultValue()}}function Zl(e,t){return t.effectStrategy===`input`?J(e.schema._def,t):Hl(t)}function Ql(e){return{type:`string`,enum:Array.from(e.values)}}let $l=e=>`type`in e&&e.type===`string`?!1:`allOf`in e;function eu(e,t){let n=[J(e.left._def,{...t,currentPath:[...t.currentPath,`allOf`,`0`]}),J(e.right._def,{...t,currentPath:[...t.currentPath,`allOf`,`1`]})].filter(e=>!!e),r=t.target===`jsonSchema2019-09`?{unevaluatedProperties:!1}:void 0,i=[];return n.forEach(e=>{if($l(e))i.push(...e.allOf),e.unevaluatedProperties===void 0&&(r=void 0);else{let t=e;if(`additionalProperties`in e&&e.additionalProperties===!1){let{additionalProperties:n,...r}=e;t=r}else r=void 0;i.push(t)}}),i.length?{allOf:i,...r}:void 0}function tu(e,t){let n=typeof e.value;return n!==`bigint`&&n!==`number`&&n!==`boolean`&&n!==`string`?{type:Array.isArray(e.value)?`array`:`object`}:t.target===`openApi3`?{type:n===`bigint`?`integer`:n,enum:[e.value]}:{type:n===`bigint`?`integer`:n,const:e.value}}let nu,ru={cuid:/^[cC][^\s-]{8,}$/,cuid2:/^[0-9a-z]+$/,ulid:/^[0-9A-HJKMNP-TV-Z]{26}$/,email:/^(?!\.)(?!.*\.\.)([a-zA-Z0-9_'+\-\.]*)[a-zA-Z0-9_+-]@([a-zA-Z0-9][a-zA-Z0-9\-]*\.)+[a-zA-Z]{2,}$/,emoji:()=>(nu===void 0&&(nu=RegExp(`^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`,`u`)),nu),uuid:/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/,ipv4:/^(?:(?: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])$/,ipv4Cidr:/^(?:(?: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])\/(3[0-2]|[12]?[0-9])$/,ipv6:/^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/,ipv6Cidr:/^(([0-9a-fA-F]{1,4}:){7,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}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,base64:/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,base64url:/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,nanoid:/^[a-zA-Z0-9_-]{21}$/,jwt:/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/};function iu(e,t){let n={type:`string`};if(e.checks)for(let r of e.checks)switch(r.kind){case`min`:K(n,`minLength`,typeof n.minLength==`number`?Math.max(n.minLength,r.value):r.value,r.message,t);break;case`max`:K(n,`maxLength`,typeof n.maxLength==`number`?Math.min(n.maxLength,r.value):r.value,r.message,t);break;case`email`:switch(t.emailStrategy){case`format:email`:cu(n,`email`,r.message,t);break;case`format:idn-email`:cu(n,`idn-email`,r.message,t);break;case`pattern:zod`:q(n,ru.email,r.message,t);break}break;case`url`:cu(n,`uri`,r.message,t);break;case`uuid`:cu(n,`uuid`,r.message,t);break;case`regex`:q(n,r.regex,r.message,t);break;case`cuid`:q(n,ru.cuid,r.message,t);break;case`cuid2`:q(n,ru.cuid2,r.message,t);break;case`startsWith`:q(n,RegExp(`^${au(r.value,t)}`),r.message,t);break;case`endsWith`:q(n,RegExp(`${au(r.value,t)}$`),r.message,t);break;case`datetime`:cu(n,`date-time`,r.message,t);break;case`date`:cu(n,`date`,r.message,t);break;case`time`:cu(n,`time`,r.message,t);break;case`duration`:cu(n,`duration`,r.message,t);break;case`length`:K(n,`minLength`,typeof n.minLength==`number`?Math.max(n.minLength,r.value):r.value,r.message,t),K(n,`maxLength`,typeof n.maxLength==`number`?Math.min(n.maxLength,r.value):r.value,r.message,t);break;case`includes`:q(n,RegExp(au(r.value,t)),r.message,t);break;case`ip`:r.version!==`v6`&&cu(n,`ipv4`,r.message,t),r.version!==`v4`&&cu(n,`ipv6`,r.message,t);break;case`base64url`:q(n,ru.base64url,r.message,t);break;case`jwt`:q(n,ru.jwt,r.message,t);break;case`cidr`:r.version!==`v6`&&q(n,ru.ipv4Cidr,r.message,t),r.version!==`v4`&&q(n,ru.ipv6Cidr,r.message,t);break;case`emoji`:q(n,ru.emoji(),r.message,t);break;case`ulid`:q(n,ru.ulid,r.message,t);break;case`base64`:switch(t.base64Strategy){case`format:binary`:cu(n,`binary`,r.message,t);break;case`contentEncoding:base64`:K(n,`contentEncoding`,`base64`,r.message,t);break;case`pattern:zod`:q(n,ru.base64,r.message,t);break}break;case`nanoid`:q(n,ru.nanoid,r.message,t);case`toLowerCase`:case`toUpperCase`:case`trim`:break;default:(e=>{})(r)}return n}function au(e,t){return t.patternStrategy===`escape`?su(e):e}let ou=new Set(`ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789`);function su(e){let t=``;for(let n=0;n<e.length;n++)ou.has(e[n])||(t+=`\\`),t+=e[n];return t}function cu(e,t,n,r){e.format||e.anyOf?.some(e=>e.format)?(e.anyOf||=[],e.format&&(e.anyOf.push({format:e.format,...e.errorMessage&&r.errorMessages&&{errorMessage:{format:e.errorMessage.format}}}),delete e.format,e.errorMessage&&(delete e.errorMessage.format,Object.keys(e.errorMessage).length===0&&delete e.errorMessage)),e.anyOf.push({format:t,...n&&r.errorMessages&&{errorMessage:{format:n}}})):K(e,`format`,t,n,r)}function q(e,t,n,r){e.pattern||e.allOf?.some(e=>e.pattern)?(e.allOf||=[],e.pattern&&(e.allOf.push({pattern:e.pattern,...e.errorMessage&&r.errorMessages&&{errorMessage:{pattern:e.errorMessage.pattern}}}),delete e.pattern,e.errorMessage&&(delete e.errorMessage.pattern,Object.keys(e.errorMessage).length===0&&delete e.errorMessage)),e.allOf.push({pattern:lu(t,r),...n&&r.errorMessages&&{errorMessage:{pattern:n}}})):K(e,`pattern`,lu(t,r),n,r)}function lu(e,t){if(!t.applyRegexFlags||!e.flags)return e.source;let n={i:e.flags.includes(`i`),m:e.flags.includes(`m`),s:e.flags.includes(`s`)},r=n.i?e.source.toLowerCase():e.source,i=``,a=!1,o=!1,s=!1;for(let e=0;e<r.length;e++){if(a){i+=r[e],a=!1;continue}if(n.i){if(o){if(r[e].match(/[a-z]/)){s?(i+=r[e],i+=`${r[e-2]}-${r[e]}`.toUpperCase(),s=!1):r[e+1]===`-`&&r[e+2]?.match(/[a-z]/)?(i+=r[e],s=!0):i+=`${r[e]}${r[e].toUpperCase()}`;continue}}else if(r[e].match(/[a-z]/)){i+=`[${r[e]}${r[e].toUpperCase()}]`;continue}}if(n.m){if(r[e]===`^`){i+=`(^|(?<=[\r
39
+ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let n of e.seen.entries()){let r=n[1];if(t===n[0]){a(n);continue}if(e.external){let r=e.external.registry.get(n[0])?.id;if(t!==n[0]&&r){a(n);continue}}if(e.metadataRegistry.get(n[0])?.id){a(n);continue}if(r.cycle){a(n);continue}if(r.count>1&&e.reused===`ref`){a(n);continue}}}function Ra(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);let r=t=>{let n=e.seen.get(t);if(n.ref===null)return;let i=n.def??n.schema,a={...i},o=n.ref;if(n.ref=null,o){r(o);let n=e.seen.get(o),s=n.schema;if(s.$ref&&(e.target===`draft-07`||e.target===`draft-04`||e.target===`openapi-3.0`)?(i.allOf=i.allOf??[],i.allOf.push(s)):Object.assign(i,s),Object.assign(i,a),t._zod.parent===o)for(let e in i)e===`$ref`||e===`allOf`||e in a||delete i[e];if(s.$ref)for(let e in i)e===`$ref`||e===`allOf`||e in n.def&&JSON.stringify(i[e])===JSON.stringify(n.def[e])&&delete i[e]}let s=t._zod.parent;if(s&&s!==o){r(s);let t=e.seen.get(s);if(t?.schema.$ref&&(i.$ref=t.schema.$ref,t.def))for(let e in i)e===`$ref`||e===`allOf`||e in t.def&&JSON.stringify(i[e])===JSON.stringify(t.def[e])&&delete i[e]}e.override({zodSchema:t,jsonSchema:i,path:n.path??[]})};for(let t of[...e.seen.entries()].reverse())r(t[0]);let i={};if(e.target===`draft-2020-12`?i.$schema=`https://json-schema.org/draft/2020-12/schema`:e.target===`draft-07`?i.$schema=`http://json-schema.org/draft-07/schema#`:e.target===`draft-04`?i.$schema=`http://json-schema.org/draft-04/schema#`:e.target,e.external?.uri){let n=e.external.registry.get(t)?.id;if(!n)throw Error("Schema is missing an `id` property");i.$id=e.external.uri(n)}Object.assign(i,n.def??n.schema);let a=e.external?.defs??{};for(let t of e.seen.entries()){let e=t[1];e.def&&e.defId&&(a[e.defId]=e.def)}e.external||Object.keys(a).length>0&&(e.target===`draft-2020-12`?i.$defs=a:i.definitions=a);try{let n=JSON.parse(JSON.stringify(i));return Object.defineProperty(n,`~standard`,{value:{...t[`~standard`],jsonSchema:{input:Ba(t,`input`,e.processors),output:Ba(t,`output`,e.processors)}},enumerable:!1,writable:!1}),n}catch{throw Error(`Error converting schema to JSON.`)}}function O(e,t){let n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);let r=e._zod.def;if(r.type===`transform`)return!0;if(r.type===`array`)return O(r.element,n);if(r.type===`set`)return O(r.valueType,n);if(r.type===`lazy`)return O(r.getter(),n);if(r.type===`promise`||r.type===`optional`||r.type===`nonoptional`||r.type===`nullable`||r.type===`readonly`||r.type===`default`||r.type===`prefault`)return O(r.innerType,n);if(r.type===`intersection`)return O(r.left,n)||O(r.right,n);if(r.type===`record`||r.type===`map`)return O(r.keyType,n)||O(r.valueType,n);if(r.type===`pipe`)return O(r.in,n)||O(r.out,n);if(r.type===`object`){for(let e in r.shape)if(O(r.shape[e],n))return!0;return!1}if(r.type===`union`){for(let e of r.options)if(O(e,n))return!0;return!1}if(r.type===`tuple`){for(let e of r.items)if(O(e,n))return!0;return!!(r.rest&&O(r.rest,n))}return!1}let za=(e,t={})=>n=>{let r=Ia({...n,processors:t});return D(e,r),La(r,e),Ra(r,e)},Ba=(e,t,n={})=>r=>{let{libraryOptions:i,target:a}=r??{},o=Ia({...i??{},target:a,io:t,processors:n});return D(e,o),La(o,e),Ra(o,e)},Va={guid:`uuid`,url:`uri`,datetime:`date-time`,json_string:`json-string`,regex:``},Ha=(e,t,n,r)=>{let i=n;i.type=`string`;let{minimum:a,maximum:o,format:s,patterns:c,contentEncoding:l}=e._zod.bag;if(typeof a==`number`&&(i.minLength=a),typeof o==`number`&&(i.maxLength=o),s&&(i.format=Va[s]??s,i.format===``&&delete i.format,s===`time`&&delete i.format),l&&(i.contentEncoding=l),c&&c.size>0){let e=[...c];e.length===1?i.pattern=e[0].source:e.length>1&&(i.allOf=[...e.map(e=>({...t.target===`draft-07`||t.target===`draft-04`||t.target===`openapi-3.0`?{type:`string`}:{},pattern:e.source}))])}},Ua=(e,t,n,r)=>{let i=n,{minimum:a,maximum:o,format:s,multipleOf:c,exclusiveMaximum:l,exclusiveMinimum:u}=e._zod.bag;typeof s==`string`&&s.includes(`int`)?i.type=`integer`:i.type=`number`,typeof u==`number`&&(t.target===`draft-04`||t.target===`openapi-3.0`?(i.minimum=u,i.exclusiveMinimum=!0):i.exclusiveMinimum=u),typeof a==`number`&&(i.minimum=a,typeof u==`number`&&t.target!==`draft-04`&&(u>=a?delete i.minimum:delete i.exclusiveMinimum)),typeof l==`number`&&(t.target===`draft-04`||t.target===`openapi-3.0`?(i.maximum=l,i.exclusiveMaximum=!0):i.exclusiveMaximum=l),typeof o==`number`&&(i.maximum=o,typeof l==`number`&&t.target!==`draft-04`&&(l<=o?delete i.maximum:delete i.exclusiveMaximum)),typeof c==`number`&&(i.multipleOf=c)},Wa=(e,t,n,r)=>{n.type=`boolean`},Ga=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`BigInt cannot be represented in JSON Schema`)},Ka=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Symbols cannot be represented in JSON Schema`)},qa=(e,t,n,r)=>{t.target===`openapi-3.0`?(n.type=`string`,n.nullable=!0,n.enum=[null]):n.type=`null`},Ja=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Undefined cannot be represented in JSON Schema`)},Ya=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Void cannot be represented in JSON Schema`)},Xa=(e,t,n,r)=>{n.not={}},Za=(e,t,n,r)=>{},Qa=(e,t,n,r)=>{},$a=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Date cannot be represented in JSON Schema`)},eo=(e,t,n,r)=>{let i=e._zod.def,a=bt(i.entries);a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),n.enum=a},to=(e,t,n,r)=>{let i=e._zod.def,a=[];for(let e of i.values)if(e===void 0){if(t.unrepresentable===`throw`)throw Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof e==`bigint`){if(t.unrepresentable===`throw`)throw Error(`BigInt literals cannot be represented in JSON Schema`);a.push(Number(e))}else a.push(e);if(a.length!==0)if(a.length===1){let e=a[0];n.type=e===null?`null`:typeof e,t.target===`draft-04`||t.target===`openapi-3.0`?n.enum=[e]:n.const=e}else a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),a.every(e=>typeof e==`boolean`)&&(n.type=`boolean`),a.every(e=>e===null)&&(n.type=`null`),n.enum=a},no=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`NaN cannot be represented in JSON Schema`)},ro=(e,t,n,r)=>{let i=n,a=e._zod.pattern;if(!a)throw Error(`Pattern not found in template literal`);i.type=`string`,i.pattern=a.source},io=(e,t,n,r)=>{let i=n,a={type:`string`,format:`binary`,contentEncoding:`binary`},{minimum:o,maximum:s,mime:c}=e._zod.bag;o!==void 0&&(a.minLength=o),s!==void 0&&(a.maxLength=s),c?c.length===1?(a.contentMediaType=c[0],Object.assign(i,a)):(Object.assign(i,a),i.anyOf=c.map(e=>({contentMediaType:e}))):Object.assign(i,a)},ao=(e,t,n,r)=>{n.type=`boolean`},oo=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Custom types cannot be represented in JSON Schema`)},so=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Function types cannot be represented in JSON Schema`)},co=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Transforms cannot be represented in JSON Schema`)},lo=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Map cannot be represented in JSON Schema`)},uo=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Set cannot be represented in JSON Schema`)},fo=(e,t,n,r)=>{let i=n,a=e._zod.def,{minimum:o,maximum:s}=e._zod.bag;typeof o==`number`&&(i.minItems=o),typeof s==`number`&&(i.maxItems=s),i.type=`array`,i.items=D(a.element,t,{...r,path:[...r.path,`items`]})},po=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`object`,i.properties={};let o=a.shape;for(let e in o)i.properties[e]=D(o[e],t,{...r,path:[...r.path,`properties`,e]});let s=new Set(Object.keys(o)),c=new Set([...s].filter(e=>{let n=a.shape[e]._zod;return t.io===`input`?n.optin===void 0:n.optout===void 0}));c.size>0&&(i.required=Array.from(c)),a.catchall?._zod.def.type===`never`?i.additionalProperties=!1:a.catchall?a.catchall&&(i.additionalProperties=D(a.catchall,t,{...r,path:[...r.path,`additionalProperties`]})):t.io===`output`&&(i.additionalProperties=!1)},mo=(e,t,n,r)=>{let i=e._zod.def,a=i.inclusive===!1,o=i.options.map((e,n)=>D(e,t,{...r,path:[...r.path,a?`oneOf`:`anyOf`,n]}));a?n.oneOf=o:n.anyOf=o},ho=(e,t,n,r)=>{let i=e._zod.def,a=D(i.left,t,{...r,path:[...r.path,`allOf`,0]}),o=D(i.right,t,{...r,path:[...r.path,`allOf`,1]}),s=e=>`allOf`in e&&Object.keys(e).length===1;n.allOf=[...s(a)?a.allOf:[a],...s(o)?o.allOf:[o]]},go=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`array`;let o=t.target===`draft-2020-12`?`prefixItems`:`items`,s=t.target===`draft-2020-12`||t.target===`openapi-3.0`?`items`:`additionalItems`,c=a.items.map((e,n)=>D(e,t,{...r,path:[...r.path,o,n]})),l=a.rest?D(a.rest,t,{...r,path:[...r.path,s,...t.target===`openapi-3.0`?[a.items.length]:[]]}):null;t.target===`draft-2020-12`?(i.prefixItems=c,l&&(i.items=l)):t.target===`openapi-3.0`?(i.items={anyOf:c},l&&i.items.anyOf.push(l),i.minItems=c.length,l||(i.maxItems=c.length)):(i.items=c,l&&(i.additionalItems=l));let{minimum:u,maximum:d}=e._zod.bag;typeof u==`number`&&(i.minItems=u),typeof d==`number`&&(i.maxItems=d)},_o=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`object`;let o=a.keyType,s=o._zod.bag?.patterns;if(a.mode===`loose`&&s&&s.size>0){let e=D(a.valueType,t,{...r,path:[...r.path,`patternProperties`,`*`]});i.patternProperties={};for(let t of s)i.patternProperties[t.source]=e}else (t.target===`draft-07`||t.target===`draft-2020-12`)&&(i.propertyNames=D(a.keyType,t,{...r,path:[...r.path,`propertyNames`]})),i.additionalProperties=D(a.valueType,t,{...r,path:[...r.path,`additionalProperties`]});let c=o._zod.values;if(c){let e=[...c].filter(e=>typeof e==`string`||typeof e==`number`);e.length>0&&(i.required=e)}},vo=(e,t,n,r)=>{let i=e._zod.def,a=D(i.innerType,t,r),o=t.seen.get(e);t.target===`openapi-3.0`?(o.ref=i.innerType,n.nullable=!0):n.anyOf=[a,{type:`null`}]},yo=(e,t,n,r)=>{let i=e._zod.def;D(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},bo=(e,t,n,r)=>{let i=e._zod.def;D(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.default=JSON.parse(JSON.stringify(i.defaultValue))},xo=(e,t,n,r)=>{let i=e._zod.def;D(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,t.io===`input`&&(n._prefault=JSON.parse(JSON.stringify(i.defaultValue)))},So=(e,t,n,r)=>{let i=e._zod.def;D(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o;try{o=i.catchValue(void 0)}catch{throw Error(`Dynamic catch values are not supported in JSON Schema`)}n.default=o},Co=(e,t,n,r)=>{let i=e._zod.def,a=t.io===`input`?i.in._zod.def.type===`transform`?i.out:i.in:i.out;D(a,t,r);let o=t.seen.get(e);o.ref=a},wo=(e,t,n,r)=>{let i=e._zod.def;D(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.readOnly=!0},To=(e,t,n,r)=>{let i=e._zod.def;D(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},Eo=(e,t,n,r)=>{let i=e._zod.def;D(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},Do={string:Ha,number:Ua,boolean:Wa,bigint:Ga,symbol:Ka,null:qa,undefined:Ja,void:Ya,never:Xa,any:Za,unknown:Qa,date:$a,enum:eo,literal:to,nan:no,template_literal:ro,file:io,success:ao,custom:oo,function:so,transform:co,map:lo,set:uo,array:fo,object:po,union:mo,intersection:ho,tuple:go,record:_o,nullable:vo,nonoptional:yo,default:bo,prefault:xo,catch:So,pipe:Co,readonly:wo,promise:To,optional:Eo,lazy:(e,t,n,r)=>{let i=e._zod.innerType;D(i,t,r);let a=t.seen.get(e);a.ref=i}};function Oo(e,t){if(`_idmap`in e){let n=e,r=Ia({...t,processors:Do}),i={};for(let e of n._idmap.entries()){let[t,n]=e;D(n,r)}let a={};r.external={registry:n,uri:t?.uri,defs:i};for(let e of n._idmap.entries()){let[t,n]=e;La(r,n),a[t]=Ra(r,n)}return Object.keys(i).length>0&&(a.__shared={[r.target===`draft-2020-12`?`$defs`:`definitions`]:i}),{schemas:a}}let n=Ia({...t,processors:Do});return D(e,n),La(n,e),Ra(n,e)}let ko=x(`ZodMiniType`,(e,t)=>{if(!e._zod)throw Error(`Uninitialized schema in ZodMiniType.`);T.init(e,t),e.def=t,e.type=t.type,e.parse=(t,n)=>sn(e,t,n,{callee:e.parse}),e.safeParse=(t,n)=>dn(e,t,n),e.parseAsync=async(t,n)=>ln(e,t,n,{callee:e.parseAsync}),e.safeParseAsync=async(t,n)=>pn(e,t,n),e.check=(...n)=>e.clone({...t,checks:[...t.checks??[],...n.map(e=>typeof e==`function`?{_zod:{check:e,def:{check:`custom`},onattach:[]}}:e)]},{parent:!0}),e.with=e.check,e.clone=(t,n)=>Rt(e,t,n),e.brand=()=>e,e.register=((t,n)=>(t.add(e,n),e)),e.apply=t=>t(e)}),Ao=x(`ZodMiniObject`,(e,t)=>{ei.init(e,t),ko.init(e,t),S(e,`shape`,()=>t.shape)});function jo(e,t){return new Ao({type:`object`,shape:e??{},...C(t)})}let Mo=x(`ZodISODateTime`,(e,t)=>{Or.init(e,t),j.init(e,t)});function No(e){return ta(Mo,e)}let Po=x(`ZodISODate`,(e,t)=>{kr.init(e,t),j.init(e,t)});function Fo(e){return na(Po,e)}let Io=x(`ZodISOTime`,(e,t)=>{Ar.init(e,t),j.init(e,t)});function Lo(e){return ra(Io,e)}let Ro=x(`ZodISODuration`,(e,t)=>{jr.init(e,t),j.init(e,t)});function zo(e){return ia(Ro,e)}let Bo=(e,t)=>{tn.init(e,t),e.name=`ZodError`,Object.defineProperties(e,{format:{value:t=>an(e,t)},flatten:{value:t=>rn(e,t)},addIssue:{value:t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,xt,2)}},addIssues:{value:t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,xt,2)}},isEmpty:{get(){return e.issues.length===0}}})};x(`ZodError`,Bo);let Vo=x(`ZodError`,Bo,{Parent:Error}),Ho=on(Vo),Uo=cn(Vo),Wo=un(Vo),Go=fn(Vo),Ko=mn(Vo),qo=hn(Vo),Jo=gn(Vo),Yo=_n(Vo),Xo=vn(Vo),Zo=yn(Vo),Qo=bn(Vo),$o=xn(Vo),k=x(`ZodType`,(e,t)=>(T.init(e,t),Object.assign(e[`~standard`],{jsonSchema:{input:Ba(e,`input`),output:Ba(e,`output`)}}),e.toJSONSchema=za(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,`_def`,{value:t}),e.check=(...n)=>e.clone(Ot(t,{checks:[...t.checks??[],...n.map(e=>typeof e==`function`?{_zod:{check:e,def:{check:`custom`},onattach:[]}}:e)]}),{parent:!0}),e.with=e.check,e.clone=(t,n)=>Rt(e,t,n),e.brand=()=>e,e.register=((t,n)=>(t.add(e,n),e)),e.parse=(t,n)=>Ho(e,t,n,{callee:e.parse}),e.safeParse=(t,n)=>Wo(e,t,n),e.parseAsync=async(t,n)=>Uo(e,t,n,{callee:e.parseAsync}),e.safeParseAsync=async(t,n)=>Go(e,t,n),e.spa=e.safeParseAsync,e.encode=(t,n)=>Ko(e,t,n),e.decode=(t,n)=>qo(e,t,n),e.encodeAsync=async(t,n)=>Jo(e,t,n),e.decodeAsync=async(t,n)=>Yo(e,t,n),e.safeEncode=(t,n)=>Xo(e,t,n),e.safeDecode=(t,n)=>Zo(e,t,n),e.safeEncodeAsync=async(t,n)=>Qo(e,t,n),e.safeDecodeAsync=async(t,n)=>$o(e,t,n),e.refine=(t,n)=>e.check(sc(t,n)),e.superRefine=t=>e.check(cc(t)),e.overwrite=t=>e.check(Ta(t)),e.optional=()=>H(e),e.exactOptional=()=>Ws(e),e.nullable=()=>Ks(e),e.nullish=()=>H(Ks(e)),e.nonoptional=t=>Qs(e,t),e.array=()=>F(e),e.or=t=>R([e,t]),e.and=t=>Is(e,t),e.transform=t=>nc(e,Vs(t)),e.default=t=>Js(e,t),e.prefault=t=>Xs(e,t),e.catch=t=>ec(e,t),e.pipe=t=>nc(e,t),e.readonly=()=>ic(e),e.describe=t=>{let n=e.clone();return ji.add(n,{description:t}),n},Object.defineProperty(e,`description`,{get(){return ji.get(e)?.description},configurable:!0}),e.meta=(...t)=>{if(t.length===0)return ji.get(e);let n=e.clone();return ji.add(n,t[0]),n},e.isOptional=()=>e.safeParse(void 0).success,e.isNullable=()=>e.safeParse(null).success,e.apply=t=>t(e),e)),es=x(`_ZodString`,(e,t)=>{gr.init(e,t),k.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ha(e,t,n,r);let n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,e.regex=(...t)=>e.check(ya(...t)),e.includes=(...t)=>e.check(Sa(...t)),e.startsWith=(...t)=>e.check(Ca(...t)),e.endsWith=(...t)=>e.check(wa(...t)),e.min=(...t)=>e.check(_a(...t)),e.max=(...t)=>e.check(ga(...t)),e.length=(...t)=>e.check(va(...t)),e.nonempty=(...t)=>e.check(_a(1,...t)),e.lowercase=t=>e.check(ba(t)),e.uppercase=t=>e.check(xa(t)),e.trim=()=>e.check(Da()),e.normalize=(...t)=>e.check(Ea(...t)),e.toLowerCase=()=>e.check(Oa()),e.toUpperCase=()=>e.check(ka()),e.slugify=()=>e.check(Aa())}),ts=x(`ZodString`,(e,t)=>{gr.init(e,t),es.init(e,t),e.email=t=>e.check(Ni(ns,t)),e.url=t=>e.check(zi(as,t)),e.jwt=t=>e.check(ea(bs,t)),e.emoji=t=>e.check(Bi(os,t)),e.guid=t=>e.check(Pi(rs,t)),e.uuid=t=>e.check(Fi(is,t)),e.uuidv4=t=>e.check(Ii(is,t)),e.uuidv6=t=>e.check(Li(is,t)),e.uuidv7=t=>e.check(Ri(is,t)),e.nanoid=t=>e.check(Vi(ss,t)),e.guid=t=>e.check(Pi(rs,t)),e.cuid=t=>e.check(Hi(cs,t)),e.cuid2=t=>e.check(Ui(ls,t)),e.ulid=t=>e.check(Wi(us,t)),e.base64=t=>e.check(Zi(_s,t)),e.base64url=t=>e.check(Qi(vs,t)),e.xid=t=>e.check(Gi(ds,t)),e.ksuid=t=>e.check(Ki(fs,t)),e.ipv4=t=>e.check(qi(ps,t)),e.ipv6=t=>e.check(Ji(ms,t)),e.cidrv4=t=>e.check(Yi(hs,t)),e.cidrv6=t=>e.check(Xi(gs,t)),e.e164=t=>e.check($i(ys,t)),e.datetime=t=>e.check(No(t)),e.date=t=>e.check(Fo(t)),e.time=t=>e.check(Lo(t)),e.duration=t=>e.check(zo(t))});function A(e){return Mi(ts,e)}let j=x(`ZodStringFormat`,(e,t)=>{E.init(e,t),es.init(e,t)}),ns=x(`ZodEmail`,(e,t)=>{yr.init(e,t),j.init(e,t)}),rs=x(`ZodGUID`,(e,t)=>{_r.init(e,t),j.init(e,t)}),is=x(`ZodUUID`,(e,t)=>{vr.init(e,t),j.init(e,t)}),as=x(`ZodURL`,(e,t)=>{br.init(e,t),j.init(e,t)}),os=x(`ZodEmoji`,(e,t)=>{xr.init(e,t),j.init(e,t)}),ss=x(`ZodNanoID`,(e,t)=>{Sr.init(e,t),j.init(e,t)}),cs=x(`ZodCUID`,(e,t)=>{Cr.init(e,t),j.init(e,t)}),ls=x(`ZodCUID2`,(e,t)=>{wr.init(e,t),j.init(e,t)}),us=x(`ZodULID`,(e,t)=>{Tr.init(e,t),j.init(e,t)}),ds=x(`ZodXID`,(e,t)=>{Er.init(e,t),j.init(e,t)}),fs=x(`ZodKSUID`,(e,t)=>{Dr.init(e,t),j.init(e,t)}),ps=x(`ZodIPv4`,(e,t)=>{Mr.init(e,t),j.init(e,t)}),ms=x(`ZodIPv6`,(e,t)=>{Nr.init(e,t),j.init(e,t)}),hs=x(`ZodCIDRv4`,(e,t)=>{Pr.init(e,t),j.init(e,t)}),gs=x(`ZodCIDRv6`,(e,t)=>{Fr.init(e,t),j.init(e,t)}),_s=x(`ZodBase64`,(e,t)=>{Lr.init(e,t),j.init(e,t)}),vs=x(`ZodBase64URL`,(e,t)=>{zr.init(e,t),j.init(e,t)}),ys=x(`ZodE164`,(e,t)=>{Br.init(e,t),j.init(e,t)}),bs=x(`ZodJWT`,(e,t)=>{Hr.init(e,t),j.init(e,t)}),xs=x(`ZodNumber`,(e,t)=>{Ur.init(e,t),k.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ua(e,t,n,r),e.gt=(t,n)=>e.check(pa(t,n)),e.gte=(t,n)=>e.check(ma(t,n)),e.min=(t,n)=>e.check(ma(t,n)),e.lt=(t,n)=>e.check(da(t,n)),e.lte=(t,n)=>e.check(fa(t,n)),e.max=(t,n)=>e.check(fa(t,n)),e.int=t=>e.check(Cs(t)),e.safe=t=>e.check(Cs(t)),e.positive=t=>e.check(pa(0,t)),e.nonnegative=t=>e.check(ma(0,t)),e.negative=t=>e.check(da(0,t)),e.nonpositive=t=>e.check(fa(0,t)),e.multipleOf=(t,n)=>e.check(ha(t,n)),e.step=(t,n)=>e.check(ha(t,n)),e.finite=()=>e;let n=e._zod.bag;e.minValue=Math.max(n.minimum??-1/0,n.exclusiveMinimum??-1/0)??null,e.maxValue=Math.min(n.maximum??1/0,n.exclusiveMaximum??1/0)??null,e.isInt=(n.format??``).includes(`int`)||Number.isSafeInteger(n.multipleOf??.5),e.isFinite=!0,e.format=n.format??null});function M(e){return aa(xs,e)}let Ss=x(`ZodNumberFormat`,(e,t)=>{Wr.init(e,t),xs.init(e,t)});function Cs(e){return oa(Ss,e)}let ws=x(`ZodBoolean`,(e,t)=>{Gr.init(e,t),k.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Wa(e,t,n,r)});function N(e){return sa(ws,e)}let Ts=x(`ZodNull`,(e,t)=>{Kr.init(e,t),k.init(e,t),e._zod.processJSONSchema=(t,n,r)=>qa(e,t,n,r)});function Es(e){return ca(Ts,e)}let Ds=x(`ZodUnknown`,(e,t)=>{qr.init(e,t),k.init(e,t),e._zod.processJSONSchema=(e,t,n)=>void 0});function P(){return la(Ds)}let Os=x(`ZodNever`,(e,t)=>{Jr.init(e,t),k.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Xa(e,t,n,r)});function ks(e){return ua(Os,e)}let As=x(`ZodArray`,(e,t)=>{Xr.init(e,t),k.init(e,t),e._zod.processJSONSchema=(t,n,r)=>fo(e,t,n,r),e.element=t.element,e.min=(t,n)=>e.check(_a(t,n)),e.nonempty=t=>e.check(_a(1,t)),e.max=(t,n)=>e.check(ga(t,n)),e.length=(t,n)=>e.check(va(t,n)),e.unwrap=()=>e.element});function F(e,t){return ja(As,e,t)}let js=x(`ZodObject`,(e,t)=>{ti.init(e,t),k.init(e,t),e._zod.processJSONSchema=(t,n,r)=>po(e,t,n,r),S(e,`shape`,()=>t.shape),e.keyof=()=>B(Object.keys(e._zod.def.shape)),e.catchall=t=>e.clone({...e._zod.def,catchall:t}),e.passthrough=()=>e.clone({...e._zod.def,catchall:P()}),e.loose=()=>e.clone({...e._zod.def,catchall:P()}),e.strict=()=>e.clone({...e._zod.def,catchall:ks()}),e.strip=()=>e.clone({...e._zod.def,catchall:void 0}),e.extend=t=>Ut(e,t),e.safeExtend=t=>Wt(e,t),e.merge=t=>Gt(e,t),e.pick=t=>Vt(e,t),e.omit=t=>Ht(e,t),e.partial=(...t)=>Kt(Hs,e,t[0]),e.required=(...t)=>qt(Zs,e,t[0])});function I(e,t){return new js({type:`object`,shape:e??{},...C(t)})}function L(e,t){return new js({type:`object`,shape:e,catchall:P(),...C(t)})}let Ms=x(`ZodUnion`,(e,t)=>{ri.init(e,t),k.init(e,t),e._zod.processJSONSchema=(t,n,r)=>mo(e,t,n,r),e.options=t.options});function R(e,t){return new Ms({type:`union`,options:e,...C(t)})}let Ns=x(`ZodDiscriminatedUnion`,(e,t)=>{Ms.init(e,t),ii.init(e,t)});function Ps(e,t,n){return new Ns({type:`union`,options:t,discriminator:e,...C(n)})}let Fs=x(`ZodIntersection`,(e,t)=>{ai.init(e,t),k.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ho(e,t,n,r)});function Is(e,t){return new Fs({type:`intersection`,left:e,right:t})}let Ls=x(`ZodRecord`,(e,t)=>{ci.init(e,t),k.init(e,t),e._zod.processJSONSchema=(t,n,r)=>_o(e,t,n,r),e.keyType=t.keyType,e.valueType=t.valueType});function z(e,t,n){return new Ls({type:`record`,keyType:e,valueType:t,...C(n)})}let Rs=x(`ZodEnum`,(e,t)=>{li.init(e,t),k.init(e,t),e._zod.processJSONSchema=(t,n,r)=>eo(e,t,n,r),e.enum=t.entries,e.options=Object.values(t.entries);let n=new Set(Object.keys(t.entries));e.extract=(e,r)=>{let i={};for(let r of e)if(n.has(r))i[r]=t.entries[r];else throw Error(`Key ${r} not found in enum`);return new Rs({...t,checks:[],...C(r),entries:i})},e.exclude=(e,r)=>{let i={...t.entries};for(let t of e)if(n.has(t))delete i[t];else throw Error(`Key ${t} not found in enum`);return new Rs({...t,checks:[],...C(r),entries:i})}});function B(e,t){return new Rs({type:`enum`,entries:Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e,...C(t)})}let zs=x(`ZodLiteral`,(e,t)=>{ui.init(e,t),k.init(e,t),e._zod.processJSONSchema=(t,n,r)=>to(e,t,n,r),e.values=new Set(t.values),Object.defineProperty(e,`value`,{get(){if(t.values.length>1)throw Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function V(e,t){return new zs({type:`literal`,values:Array.isArray(e)?e:[e],...C(t)})}let Bs=x(`ZodTransform`,(e,t)=>{di.init(e,t),k.init(e,t),e._zod.processJSONSchema=(t,n,r)=>co(e,t,n,r),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new _t(e.constructor.name);n.addIssue=r=>{if(typeof r==`string`)n.issues.push($t(r,n.value,t));else{let t=r;t.fatal&&(t.continue=!1),t.code??=`custom`,t.input??=n.value,t.inst??=e,n.issues.push($t(t))}};let i=t.transform(n.value,n);return i instanceof Promise?i.then(e=>(n.value=e,n)):(n.value=i,n)}});function Vs(e){return new Bs({type:`transform`,transform:e})}let Hs=x(`ZodOptional`,(e,t)=>{pi.init(e,t),k.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Eo(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function H(e){return new Hs({type:`optional`,innerType:e})}let Us=x(`ZodExactOptional`,(e,t)=>{mi.init(e,t),k.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Eo(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Ws(e){return new Us({type:`optional`,innerType:e})}let Gs=x(`ZodNullable`,(e,t)=>{hi.init(e,t),k.init(e,t),e._zod.processJSONSchema=(t,n,r)=>vo(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Ks(e){return new Gs({type:`nullable`,innerType:e})}let qs=x(`ZodDefault`,(e,t)=>{gi.init(e,t),k.init(e,t),e._zod.processJSONSchema=(t,n,r)=>bo(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function Js(e,t){return new qs({type:`default`,innerType:e,get defaultValue(){return typeof t==`function`?t():Ft(t)}})}let Ys=x(`ZodPrefault`,(e,t)=>{vi.init(e,t),k.init(e,t),e._zod.processJSONSchema=(t,n,r)=>xo(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Xs(e,t){return new Ys({type:`prefault`,innerType:e,get defaultValue(){return typeof t==`function`?t():Ft(t)}})}let Zs=x(`ZodNonOptional`,(e,t)=>{yi.init(e,t),k.init(e,t),e._zod.processJSONSchema=(t,n,r)=>yo(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Qs(e,t){return new Zs({type:`nonoptional`,innerType:e,...C(t)})}let $s=x(`ZodCatch`,(e,t)=>{xi.init(e,t),k.init(e,t),e._zod.processJSONSchema=(t,n,r)=>So(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function ec(e,t){return new $s({type:`catch`,innerType:e,catchValue:typeof t==`function`?t:()=>t})}let tc=x(`ZodPipe`,(e,t)=>{Si.init(e,t),k.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Co(e,t,n,r),e.in=t.in,e.out=t.out});function nc(e,t){return new tc({type:`pipe`,in:e,out:t})}let rc=x(`ZodReadonly`,(e,t)=>{wi.init(e,t),k.init(e,t),e._zod.processJSONSchema=(t,n,r)=>wo(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function ic(e){return new rc({type:`readonly`,innerType:e})}let ac=x(`ZodCustom`,(e,t)=>{Ei.init(e,t),k.init(e,t),e._zod.processJSONSchema=(t,n,r)=>oo(e,t,n,r)});function oc(e,t){return Ma(ac,e??(()=>!0),t)}function sc(e,t={}){return Na(ac,e,t)}function cc(e){return Pa(e)}function lc(e,t){return nc(Vs(e),t)}let uc=Symbol(`Let zodToJsonSchema decide on which parser to use`),dc={name:void 0,$refStrategy:`root`,basePath:[`#`],effectStrategy:`input`,pipeStrategy:`all`,dateStrategy:`format:date-time`,mapStrategy:`entries`,removeAdditionalStrategy:`passthrough`,allowedAdditionalProperties:!0,rejectedAdditionalProperties:!1,definitionPath:`definitions`,target:`jsonSchema7`,strictUnions:!1,definitions:{},errorMessages:!1,markdownDescription:!1,patternStrategy:`escape`,applyRegexFlags:!1,emailStrategy:`format:email`,base64Strategy:`contentEncoding:base64`,nameStrategy:`ref`,openAiAnyTypeName:`OpenAiAnyType`},fc=e=>typeof e==`string`?{...dc,name:e}:{...dc,...e},pc=e=>{let t=fc(e),n=t.name===void 0?t.basePath:[...t.basePath,t.definitionPath,t.name];return{...t,flags:{hasReferencedOpenAiAnyType:!1},currentPath:n,propertyPath:void 0,seen:new Map(Object.entries(t.definitions).map(([e,n])=>[n._def,{def:n._def,path:[...t.basePath,t.definitionPath,e],jsonSchema:void 0}]))}};function mc(e,t,n,r){r?.errorMessages&&n&&(e.errorMessage={...e.errorMessage,[t]:n})}function U(e,t,n,r,i){e[t]=n,mc(e,t,r,i)}let hc=(e,t)=>{let n=0;for(;n<e.length&&n<t.length&&e[n]===t[n];n++);return[(e.length-n).toString(),...t.slice(n)].join(`/`)};function W(e){if(e.target!==`openAi`)return{};let t=[...e.basePath,e.definitionPath,e.openAiAnyTypeName];return e.flags.hasReferencedOpenAiAnyType=!0,{$ref:e.$refStrategy===`relative`?hc(t,e.currentPath):t.join(`/`)}}function gc(e,t){let n={type:`array`};return e.type?._def&&e.type?._def?.typeName!==b.ZodAny&&(n.items=K(e.type._def,{...t,currentPath:[...t.currentPath,`items`]})),e.minLength&&U(n,`minItems`,e.minLength.value,e.minLength.message,t),e.maxLength&&U(n,`maxItems`,e.maxLength.value,e.maxLength.message,t),e.exactLength&&(U(n,`minItems`,e.exactLength.value,e.exactLength.message,t),U(n,`maxItems`,e.exactLength.value,e.exactLength.message,t)),n}function _c(e,t){let n={type:`integer`,format:`int64`};if(!e.checks)return n;for(let r of e.checks)switch(r.kind){case`min`:t.target===`jsonSchema7`?r.inclusive?U(n,`minimum`,r.value,r.message,t):U(n,`exclusiveMinimum`,r.value,r.message,t):(r.inclusive||(n.exclusiveMinimum=!0),U(n,`minimum`,r.value,r.message,t));break;case`max`:t.target===`jsonSchema7`?r.inclusive?U(n,`maximum`,r.value,r.message,t):U(n,`exclusiveMaximum`,r.value,r.message,t):(r.inclusive||(n.exclusiveMaximum=!0),U(n,`maximum`,r.value,r.message,t));break;case`multipleOf`:U(n,`multipleOf`,r.value,r.message,t);break}return n}function vc(){return{type:`boolean`}}function yc(e,t){return K(e.type._def,t)}let bc=(e,t)=>K(e.innerType._def,t);function xc(e,t,n){let r=n??t.dateStrategy;if(Array.isArray(r))return{anyOf:r.map((n,r)=>xc(e,t,n))};switch(r){case`string`:case`format:date-time`:return{type:`string`,format:`date-time`};case`format:date`:return{type:`string`,format:`date`};case`integer`:return Sc(e,t)}}let Sc=(e,t)=>{let n={type:`integer`,format:`unix-time`};if(t.target===`openApi3`)return n;for(let r of e.checks)switch(r.kind){case`min`:U(n,`minimum`,r.value,r.message,t);break;case`max`:U(n,`maximum`,r.value,r.message,t);break}return n};function Cc(e,t){return{...K(e.innerType._def,t),default:e.defaultValue()}}function wc(e,t){return t.effectStrategy===`input`?K(e.schema._def,t):W(t)}function Tc(e){return{type:`string`,enum:Array.from(e.values)}}let Ec=e=>`type`in e&&e.type===`string`?!1:`allOf`in e;function Dc(e,t){let n=[K(e.left._def,{...t,currentPath:[...t.currentPath,`allOf`,`0`]}),K(e.right._def,{...t,currentPath:[...t.currentPath,`allOf`,`1`]})].filter(e=>!!e),r=t.target===`jsonSchema2019-09`?{unevaluatedProperties:!1}:void 0,i=[];return n.forEach(e=>{if(Ec(e))i.push(...e.allOf),e.unevaluatedProperties===void 0&&(r=void 0);else{let t=e;if(`additionalProperties`in e&&e.additionalProperties===!1){let{additionalProperties:n,...r}=e;t=r}else r=void 0;i.push(t)}}),i.length?{allOf:i,...r}:void 0}function Oc(e,t){let n=typeof e.value;return n!==`bigint`&&n!==`number`&&n!==`boolean`&&n!==`string`?{type:Array.isArray(e.value)?`array`:`object`}:t.target===`openApi3`?{type:n===`bigint`?`integer`:n,enum:[e.value]}:{type:n===`bigint`?`integer`:n,const:e.value}}let kc,Ac={cuid:/^[cC][^\s-]{8,}$/,cuid2:/^[0-9a-z]+$/,ulid:/^[0-9A-HJKMNP-TV-Z]{26}$/,email:/^(?!\.)(?!.*\.\.)([a-zA-Z0-9_'+\-\.]*)[a-zA-Z0-9_+-]@([a-zA-Z0-9][a-zA-Z0-9\-]*\.)+[a-zA-Z]{2,}$/,emoji:()=>(kc===void 0&&(kc=RegExp(`^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`,`u`)),kc),uuid:/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/,ipv4:/^(?:(?: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])$/,ipv4Cidr:/^(?:(?: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])\/(3[0-2]|[12]?[0-9])$/,ipv6:/^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/,ipv6Cidr:/^(([0-9a-fA-F]{1,4}:){7,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}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,base64:/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,base64url:/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,nanoid:/^[a-zA-Z0-9_-]{21}$/,jwt:/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/};function jc(e,t){let n={type:`string`};if(e.checks)for(let r of e.checks)switch(r.kind){case`min`:U(n,`minLength`,typeof n.minLength==`number`?Math.max(n.minLength,r.value):r.value,r.message,t);break;case`max`:U(n,`maxLength`,typeof n.maxLength==`number`?Math.min(n.maxLength,r.value):r.value,r.message,t);break;case`email`:switch(t.emailStrategy){case`format:email`:Fc(n,`email`,r.message,t);break;case`format:idn-email`:Fc(n,`idn-email`,r.message,t);break;case`pattern:zod`:G(n,Ac.email,r.message,t);break}break;case`url`:Fc(n,`uri`,r.message,t);break;case`uuid`:Fc(n,`uuid`,r.message,t);break;case`regex`:G(n,r.regex,r.message,t);break;case`cuid`:G(n,Ac.cuid,r.message,t);break;case`cuid2`:G(n,Ac.cuid2,r.message,t);break;case`startsWith`:G(n,RegExp(`^${Mc(r.value,t)}`),r.message,t);break;case`endsWith`:G(n,RegExp(`${Mc(r.value,t)}$`),r.message,t);break;case`datetime`:Fc(n,`date-time`,r.message,t);break;case`date`:Fc(n,`date`,r.message,t);break;case`time`:Fc(n,`time`,r.message,t);break;case`duration`:Fc(n,`duration`,r.message,t);break;case`length`:U(n,`minLength`,typeof n.minLength==`number`?Math.max(n.minLength,r.value):r.value,r.message,t),U(n,`maxLength`,typeof n.maxLength==`number`?Math.min(n.maxLength,r.value):r.value,r.message,t);break;case`includes`:G(n,RegExp(Mc(r.value,t)),r.message,t);break;case`ip`:r.version!==`v6`&&Fc(n,`ipv4`,r.message,t),r.version!==`v4`&&Fc(n,`ipv6`,r.message,t);break;case`base64url`:G(n,Ac.base64url,r.message,t);break;case`jwt`:G(n,Ac.jwt,r.message,t);break;case`cidr`:r.version!==`v6`&&G(n,Ac.ipv4Cidr,r.message,t),r.version!==`v4`&&G(n,Ac.ipv6Cidr,r.message,t);break;case`emoji`:G(n,Ac.emoji(),r.message,t);break;case`ulid`:G(n,Ac.ulid,r.message,t);break;case`base64`:switch(t.base64Strategy){case`format:binary`:Fc(n,`binary`,r.message,t);break;case`contentEncoding:base64`:U(n,`contentEncoding`,`base64`,r.message,t);break;case`pattern:zod`:G(n,Ac.base64,r.message,t);break}break;case`nanoid`:G(n,Ac.nanoid,r.message,t);case`toLowerCase`:case`toUpperCase`:case`trim`:break;default:(e=>{})(r)}return n}function Mc(e,t){return t.patternStrategy===`escape`?Pc(e):e}let Nc=new Set(`ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789`);function Pc(e){let t=``;for(let n=0;n<e.length;n++)Nc.has(e[n])||(t+=`\\`),t+=e[n];return t}function Fc(e,t,n,r){e.format||e.anyOf?.some(e=>e.format)?(e.anyOf||=[],e.format&&(e.anyOf.push({format:e.format,...e.errorMessage&&r.errorMessages&&{errorMessage:{format:e.errorMessage.format}}}),delete e.format,e.errorMessage&&(delete e.errorMessage.format,Object.keys(e.errorMessage).length===0&&delete e.errorMessage)),e.anyOf.push({format:t,...n&&r.errorMessages&&{errorMessage:{format:n}}})):U(e,`format`,t,n,r)}function G(e,t,n,r){e.pattern||e.allOf?.some(e=>e.pattern)?(e.allOf||=[],e.pattern&&(e.allOf.push({pattern:e.pattern,...e.errorMessage&&r.errorMessages&&{errorMessage:{pattern:e.errorMessage.pattern}}}),delete e.pattern,e.errorMessage&&(delete e.errorMessage.pattern,Object.keys(e.errorMessage).length===0&&delete e.errorMessage)),e.allOf.push({pattern:Ic(t,r),...n&&r.errorMessages&&{errorMessage:{pattern:n}}})):U(e,`pattern`,Ic(t,r),n,r)}function Ic(e,t){if(!t.applyRegexFlags||!e.flags)return e.source;let n={i:e.flags.includes(`i`),m:e.flags.includes(`m`),s:e.flags.includes(`s`)},r=n.i?e.source.toLowerCase():e.source,i=``,a=!1,o=!1,s=!1;for(let e=0;e<r.length;e++){if(a){i+=r[e],a=!1;continue}if(n.i){if(o){if(r[e].match(/[a-z]/)){s?(i+=r[e],i+=`${r[e-2]}-${r[e]}`.toUpperCase(),s=!1):r[e+1]===`-`&&r[e+2]?.match(/[a-z]/)?(i+=r[e],s=!0):i+=`${r[e]}${r[e].toUpperCase()}`;continue}}else if(r[e].match(/[a-z]/)){i+=`[${r[e]}${r[e].toUpperCase()}]`;continue}}if(n.m){if(r[e]===`^`){i+=`(^|(?<=[\r
41
40
  ]))`;continue}else if(r[e]===`$`){i+=`($|(?=[\r
42
- ]))`;continue}}if(n.s&&r[e]===`.`){i+=o?`${r[e]}\r\n`:`[${r[e]}\r\n]`;continue}i+=r[e],r[e]===`\\`?a=!0:o&&r[e]===`]`?o=!1:!o&&r[e]===`[`&&(o=!0)}try{new RegExp(i)}catch{return console.warn(`Could not convert regex pattern at ${t.currentPath.join(`/`)} to a flag-independent form! Falling back to the flag-ignorant source`),e.source}return i}function uu(e,t){if(t.target===`openAi`&&console.warn(`Warning: OpenAI may not support records in schemas! Try an array of key-value pairs instead.`),t.target===`openApi3`&&e.keyType?._def.typeName===E.ZodEnum)return{type:`object`,required:e.keyType._def.values,properties:e.keyType._def.values.reduce((n,r)=>({...n,[r]:J(e.valueType._def,{...t,currentPath:[...t.currentPath,`properties`,r]})??Hl(t)}),{}),additionalProperties:t.rejectedAdditionalProperties};let n={type:`object`,additionalProperties:J(e.valueType._def,{...t,currentPath:[...t.currentPath,`additionalProperties`]})??t.allowedAdditionalProperties};if(t.target===`openApi3`)return n;if(e.keyType?._def.typeName===E.ZodString&&e.keyType._def.checks?.length){let{type:r,...i}=iu(e.keyType._def,t);return{...n,propertyNames:i}}else if(e.keyType?._def.typeName===E.ZodEnum)return{...n,propertyNames:{enum:e.keyType._def.values}};else if(e.keyType?._def.typeName===E.ZodBranded&&e.keyType._def.type._def.typeName===E.ZodString&&e.keyType._def.type._def.checks?.length){let{type:r,...i}=Kl(e.keyType._def,t);return{...n,propertyNames:i}}return n}function du(e,t){return t.mapStrategy===`record`?uu(e,t):{type:`array`,maxItems:125,items:{type:`array`,items:[J(e.keyType._def,{...t,currentPath:[...t.currentPath,`items`,`items`,`0`]})||Hl(t),J(e.valueType._def,{...t,currentPath:[...t.currentPath,`items`,`items`,`1`]})||Hl(t)],minItems:2,maxItems:2}}}function fu(e){let t=e.values,n=Object.keys(e.values).filter(e=>typeof t[t[e]]!=`number`).map(e=>t[e]),r=Array.from(new Set(n.map(e=>typeof e)));return{type:r.length===1?r[0]===`string`?`string`:`number`:[`string`,`number`],enum:n}}function pu(e){return e.target===`openAi`?void 0:{not:Hl({...e,currentPath:[...e.currentPath,`not`]})}}function mu(e){return e.target===`openApi3`?{enum:[`null`],nullable:!0}:{type:`null`}}let hu={ZodString:`string`,ZodNumber:`number`,ZodBigInt:`integer`,ZodBoolean:`boolean`,ZodNull:`null`};function gu(e,t){if(t.target===`openApi3`)return _u(e,t);let n=e.options instanceof Map?Array.from(e.options.values()):e.options;if(n.every(e=>e._def.typeName in hu&&(!e._def.checks||!e._def.checks.length))){let e=n.reduce((e,t)=>{let n=hu[t._def.typeName];return n&&!e.includes(n)?[...e,n]:e},[]);return{type:e.length>1?e:e[0]}}else if(n.every(e=>e._def.typeName===`ZodLiteral`&&!e.description)){let e=n.reduce((e,t)=>{let n=typeof t._def.value;switch(n){case`string`:case`number`:case`boolean`:return[...e,n];case`bigint`:return[...e,`integer`];case`object`:if(t._def.value===null)return[...e,`null`];case`symbol`:case`undefined`:case`function`:default:return e}},[]);if(e.length===n.length){let t=e.filter((e,t,n)=>n.indexOf(e)===t);return{type:t.length>1?t:t[0],enum:n.reduce((e,t)=>e.includes(t._def.value)?e:[...e,t._def.value],[])}}}else if(n.every(e=>e._def.typeName===`ZodEnum`))return{type:`string`,enum:n.reduce((e,t)=>[...e,...t._def.values.filter(t=>!e.includes(t))],[])};return _u(e,t)}let _u=(e,t)=>{let n=(e.options instanceof Map?Array.from(e.options.values()):e.options).map((e,n)=>J(e._def,{...t,currentPath:[...t.currentPath,`anyOf`,`${n}`]})).filter(e=>!!e&&(!t.strictUnions||typeof e==`object`&&Object.keys(e).length>0));return n.length?{anyOf:n}:void 0};function vu(e,t){if([`ZodString`,`ZodNumber`,`ZodBigInt`,`ZodBoolean`,`ZodNull`].includes(e.innerType._def.typeName)&&(!e.innerType._def.checks||!e.innerType._def.checks.length))return t.target===`openApi3`?{type:hu[e.innerType._def.typeName],nullable:!0}:{type:[hu[e.innerType._def.typeName],`null`]};if(t.target===`openApi3`){let n=J(e.innerType._def,{...t,currentPath:[...t.currentPath]});return n&&`$ref`in n?{allOf:[n],nullable:!0}:n&&{...n,nullable:!0}}let n=J(e.innerType._def,{...t,currentPath:[...t.currentPath,`anyOf`,`0`]});return n&&{anyOf:[n,{type:`null`}]}}function yu(e,t){let n={type:`number`};if(!e.checks)return n;for(let r of e.checks)switch(r.kind){case`int`:n.type=`integer`,Bl(n,`type`,r.message,t);break;case`min`:t.target===`jsonSchema7`?r.inclusive?K(n,`minimum`,r.value,r.message,t):K(n,`exclusiveMinimum`,r.value,r.message,t):(r.inclusive||(n.exclusiveMinimum=!0),K(n,`minimum`,r.value,r.message,t));break;case`max`:t.target===`jsonSchema7`?r.inclusive?K(n,`maximum`,r.value,r.message,t):K(n,`exclusiveMaximum`,r.value,r.message,t):(r.inclusive||(n.exclusiveMaximum=!0),K(n,`maximum`,r.value,r.message,t));break;case`multipleOf`:K(n,`multipleOf`,r.value,r.message,t);break}return n}function bu(e,t){let n=t.target===`openAi`,r={type:`object`,properties:{}},i=[],a=e.shape();for(let e in a){let o=a[e];if(o===void 0||o._def===void 0)continue;let s=Su(o);s&&n&&(o._def.typeName===`ZodOptional`&&(o=o._def.innerType),o.isNullable()||(o=o.nullable()),s=!1);let c=J(o._def,{...t,currentPath:[...t.currentPath,`properties`,e],propertyPath:[...t.currentPath,`properties`,e]});c!==void 0&&(r.properties[e]=c,s||i.push(e))}i.length&&(r.required=i);let o=xu(e,t);return o!==void 0&&(r.additionalProperties=o),r}function xu(e,t){if(e.catchall._def.typeName!==`ZodNever`)return J(e.catchall._def,{...t,currentPath:[...t.currentPath,`additionalProperties`]});switch(e.unknownKeys){case`passthrough`:return t.allowedAdditionalProperties;case`strict`:return t.rejectedAdditionalProperties;case`strip`:return t.removeAdditionalStrategy===`strict`?t.allowedAdditionalProperties:t.rejectedAdditionalProperties}}function Su(e){try{return e.isOptional()}catch{return!0}}let Cu=(e,t)=>{if(t.currentPath.toString()===t.propertyPath?.toString())return J(e.innerType._def,t);let n=J(e.innerType._def,{...t,currentPath:[...t.currentPath,`anyOf`,`1`]});return n?{anyOf:[{not:Hl(t)},n]}:Hl(t)},wu=(e,t)=>{if(t.pipeStrategy===`input`)return J(e.in._def,t);if(t.pipeStrategy===`output`)return J(e.out._def,t);let n=J(e.in._def,{...t,currentPath:[...t.currentPath,`allOf`,`0`]});return{allOf:[n,J(e.out._def,{...t,currentPath:[...t.currentPath,`allOf`,n?`1`:`0`]})].filter(e=>e!==void 0)}};function Tu(e,t){return J(e.type._def,t)}function Eu(e,t){let n={type:`array`,uniqueItems:!0,items:J(e.valueType._def,{...t,currentPath:[...t.currentPath,`items`]})};return e.minSize&&K(n,`minItems`,e.minSize.value,e.minSize.message,t),e.maxSize&&K(n,`maxItems`,e.maxSize.value,e.maxSize.message,t),n}function Du(e,t){return e.rest?{type:`array`,minItems:e.items.length,items:e.items.map((e,n)=>J(e._def,{...t,currentPath:[...t.currentPath,`items`,`${n}`]})).reduce((e,t)=>t===void 0?e:[...e,t],[]),additionalItems:J(e.rest._def,{...t,currentPath:[...t.currentPath,`additionalItems`]})}:{type:`array`,minItems:e.items.length,maxItems:e.items.length,items:e.items.map((e,n)=>J(e._def,{...t,currentPath:[...t.currentPath,`items`,`${n}`]})).reduce((e,t)=>t===void 0?e:[...e,t],[])}}function Ou(e){return{not:Hl(e)}}function ku(e){return Hl(e)}let Au=(e,t)=>J(e.innerType._def,t),ju=(e,t,n)=>{switch(t){case E.ZodString:return iu(e,n);case E.ZodNumber:return yu(e,n);case E.ZodObject:return bu(e,n);case E.ZodBigInt:return Wl(e,n);case E.ZodBoolean:return Gl();case E.ZodDate:return Jl(e,n);case E.ZodUndefined:return Ou(n);case E.ZodNull:return mu(n);case E.ZodArray:return Ul(e,n);case E.ZodUnion:case E.ZodDiscriminatedUnion:return gu(e,n);case E.ZodIntersection:return eu(e,n);case E.ZodTuple:return Du(e,n);case E.ZodRecord:return uu(e,n);case E.ZodLiteral:return tu(e,n);case E.ZodEnum:return Ql(e);case E.ZodNativeEnum:return fu(e);case E.ZodNullable:return vu(e,n);case E.ZodOptional:return Cu(e,n);case E.ZodMap:return du(e,n);case E.ZodSet:return Eu(e,n);case E.ZodLazy:return()=>e.getter()._def;case E.ZodPromise:return Tu(e,n);case E.ZodNaN:case E.ZodNever:return pu(n);case E.ZodEffects:return Zl(e,n);case E.ZodAny:return Hl(n);case E.ZodUnknown:return ku(n);case E.ZodDefault:return Xl(e,n);case E.ZodBranded:return Kl(e,n);case E.ZodReadonly:return Au(e,n);case E.ZodCatch:return ql(e,n);case E.ZodPipeline:return wu(e,n);case E.ZodFunction:case E.ZodVoid:case E.ZodSymbol:return;default:return(e=>void 0)(t)}};function J(e,t,n=!1){let r=t.seen.get(e);if(t.override){let i=t.override?.(e,t,r,n);if(i!==Il)return i}if(r&&!n){let e=Mu(r,t);if(e!==void 0)return e}let i={def:e,path:t.currentPath,jsonSchema:void 0};t.seen.set(e,i);let a=ju(e,e.typeName,t),o=typeof a==`function`?J(a(),t):a;if(o&&Nu(e,t,o),t.postProcess){let n=t.postProcess(o,e,t);return i.jsonSchema=o,n}return i.jsonSchema=o,o}let Mu=(e,t)=>{switch(t.$refStrategy){case`root`:return{$ref:e.path.join(`/`)};case`relative`:return{$ref:Vl(t.currentPath,e.path)};case`none`:case`seen`:return e.path.length<t.currentPath.length&&e.path.every((e,n)=>t.currentPath[n]===e)?(console.warn(`Recursive reference detected at ${t.currentPath.join(`/`)}! Defaulting to any`),Hl(t)):t.$refStrategy===`seen`?Hl(t):void 0}},Nu=(e,t,n)=>(e.description&&(n.description=e.description,t.markdownDescription&&(n.markdownDescription=e.description)),n),Pu=(e,t)=>{let n=zl(t),r=typeof t==`object`&&t.definitions?Object.entries(t.definitions).reduce((e,[t,r])=>({...e,[t]:J(r._def,{...n,currentPath:[...n.basePath,n.definitionPath,t]},!0)??Hl(n)}),{}):void 0,i=typeof t==`string`?t:t?.nameStrategy===`title`?void 0:t?.name,a=J(e._def,i===void 0?n:{...n,currentPath:[...n.basePath,n.definitionPath,i]},!1)??Hl(n),o=typeof t==`object`&&t.name!==void 0&&t.nameStrategy===`title`?t.name:void 0;o!==void 0&&(a.title=o),n.flags.hasReferencedOpenAiAnyType&&(r||={},r[n.openAiAnyTypeName]||(r[n.openAiAnyTypeName]={type:[`string`,`number`,`integer`,`boolean`,`array`,`null`],items:{$ref:n.$refStrategy===`relative`?`1`:[...n.basePath,n.definitionPath,n.openAiAnyTypeName].join(`/`)}}));let s=i===void 0?r?{...a,[n.definitionPath]:r}:a:{$ref:[...n.$refStrategy===`relative`?[]:n.basePath,n.definitionPath,i].join(`/`),[n.definitionPath]:{...r,[i]:a}};return n.target===`jsonSchema7`?s.$schema=`http://json-schema.org/draft-07/schema#`:(n.target===`jsonSchema2019-09`||n.target===`openAi`)&&(s.$schema=`https://json-schema.org/draft/2019-09/schema#`),n.target===`openAi`&&(`anyOf`in s||`oneOf`in s||`allOf`in s||`type`in s&&Array.isArray(s.type))&&console.warn(`Warning: OpenAI may not support schemas with unions as roots! Try wrapping it in an object property.`),s};function Fu(e){return!!e._zod}function Iu(e){let t=Object.values(e);if(t.length===0)return tc({});let n=t.every(Fu),r=t.every(e=>!Fu(e));if(n)return tc(e);if(r)return zn(e);throw Error(`Mixed Zod versions detected in object shape.`)}function Lu(e,t){return Fu(e)?Pr(e,t):e.safeParse(t)}async function Ru(e,t){return Fu(e)?await Ir(e,t):await e.safeParseAsync(t)}function zu(e){if(!e)return;let t;if(t=Fu(e)?e._zod?.def?.shape:e.shape,t){if(typeof t==`function`)try{return t()}catch{return}return t}}function Bu(e){if(e){if(typeof e==`object`){let t=e,n=e;if(!t._def&&!n._zod){let t=Object.values(e);if(t.length>0&&t.every(e=>typeof e==`object`&&!!e&&(e._def!==void 0||e._zod!==void 0||typeof e.parse==`function`)))return Iu(e)}}if(Fu(e)){let t=e._zod?.def;if(t&&(t.type===`object`||t.shape!==void 0))return e}else if(e.shape!==void 0)return e}}function Vu(e){if(e&&typeof e==`object`){if(`message`in e&&typeof e.message==`string`)return e.message;if(`issues`in e&&Array.isArray(e.issues)&&e.issues.length>0){let t=e.issues[0];if(t&&typeof t==`object`&&`message`in t)return String(t.message)}try{return JSON.stringify(e)}catch{return String(e)}}return String(e)}function Hu(e){return e.description}function Uu(e){if(Fu(e))return e._zod?.def?.type===`optional`;let t=e;return typeof e.isOptional==`function`?e.isOptional():t._def?.typeName===`ZodOptional`}function Wu(e){if(Fu(e)){let t=e._zod?.def;if(t){if(t.value!==void 0)return t.value;if(Array.isArray(t.values)&&t.values.length>0)return t.values[0]}}let t=e._def;if(t){if(t.value!==void 0)return t.value;if(Array.isArray(t.values)&&t.values.length>0)return t.values[0]}let n=e.value;if(n!==void 0)return n}let Gu=`2025-11-25`,Ku=[Gu,`2025-06-18`,`2025-03-26`,`2024-11-05`,`2024-10-07`],qu=`io.modelcontextprotocol/related-task`,Y=Ml(e=>e!==null&&(typeof e==`object`||typeof e==`function`)),Ju=H([F(),L().int()]),Yu=F();nl({ttl:H([L(),Xc()]).optional(),pollInterval:L().optional()});let Xu=V({ttl:L().optional()}),Zu=V({taskId:F()}),Qu=nl({progressToken:Ju.optional(),[qu]:Zu.optional()}),$u=V({_meta:Qu.optional()}),ed=$u.extend({task:Xu.optional()}),td=e=>ed.safeParse(e).success,X=V({method:F(),params:$u.loose().optional()}),nd=V({_meta:Qu.optional()}),rd=V({method:F(),params:nd.loose().optional()}),Z=nl({_meta:Qu.optional()}),id=H([F(),L().int()]),ad=V({jsonrpc:W(`2.0`),id,...X.shape}).strict(),od=e=>ad.safeParse(e).success,sd=V({jsonrpc:W(`2.0`),...rd.shape}).strict(),cd=e=>sd.safeParse(e).success,ld=V({jsonrpc:W(`2.0`),id,result:Z}).strict(),ud=e=>ld.safeParse(e).success;var Q;(function(e){e[e.ConnectionClosed=-32e3]=`ConnectionClosed`,e[e.RequestTimeout=-32001]=`RequestTimeout`,e[e.ParseError=-32700]=`ParseError`,e[e.InvalidRequest=-32600]=`InvalidRequest`,e[e.MethodNotFound=-32601]=`MethodNotFound`,e[e.InvalidParams=-32602]=`InvalidParams`,e[e.InternalError=-32603]=`InternalError`,e[e.UrlElicitationRequired=-32042]=`UrlElicitationRequired`})(Q||={});let dd=V({jsonrpc:W(`2.0`),id:id.optional(),error:V({code:L().int(),message:F(),data:z().optional()})}).strict(),fd=e=>dd.safeParse(e).success;H([ad,sd,ld,dd]),H([ld,dd]);let pd=Z.strict(),md=nd.extend({requestId:id.optional(),reason:F().optional()}),hd=rd.extend({method:W(`notifications/cancelled`),params:md}),gd=V({icons:B(V({src:F(),mimeType:F().optional(),sizes:B(F()).optional(),theme:ul([`light`,`dark`]).optional()})).optional()}),_d=V({name:F(),title:F().optional()}),vd=_d.extend({..._d.shape,...gd.shape,version:F(),websiteUrl:F().optional(),description:F().optional()}),yd=Fl(e=>e&&typeof e==`object`&&!Array.isArray(e)&&Object.keys(e).length===0?{form:{}}:e,sl(V({form:sl(V({applyDefaults:R().optional()}),U(F(),z())).optional(),url:Y.optional()}),U(F(),z()).optional())),bd=nl({list:Y.optional(),cancel:Y.optional(),requests:nl({sampling:nl({createMessage:Y.optional()}).optional(),elicitation:nl({create:Y.optional()}).optional()}).optional()}),xd=nl({list:Y.optional(),cancel:Y.optional(),requests:nl({tools:nl({call:Y.optional()}).optional()}).optional()}),Sd=V({experimental:U(F(),Y).optional(),sampling:V({context:Y.optional(),tools:Y.optional()}).optional(),elicitation:yd.optional(),roots:V({listChanged:R().optional()}).optional(),tasks:bd.optional()}),Cd=$u.extend({protocolVersion:F(),capabilities:Sd,clientInfo:vd}),wd=X.extend({method:W(`initialize`),params:Cd}),Td=V({experimental:U(F(),Y).optional(),logging:Y.optional(),completions:Y.optional(),prompts:V({listChanged:R().optional()}).optional(),resources:V({subscribe:R().optional(),listChanged:R().optional()}).optional(),tools:V({listChanged:R().optional()}).optional(),tasks:xd.optional()}),Ed=Z.extend({protocolVersion:F(),capabilities:Td,serverInfo:vd,instructions:F().optional()}),Dd=rd.extend({method:W(`notifications/initialized`),params:nd.optional()}),Od=X.extend({method:W(`ping`),params:$u.optional()}),kd=V({progress:L(),total:G(L()),message:G(F())}),Ad=V({...nd.shape,...kd.shape,progressToken:Ju}),jd=rd.extend({method:W(`notifications/progress`),params:Ad}),Md=$u.extend({cursor:Yu.optional()}),Nd=X.extend({params:Md.optional()}),Pd=Z.extend({nextCursor:Yu.optional()}),Fd=ul([`working`,`input_required`,`completed`,`failed`,`cancelled`]),Id=V({taskId:F(),status:Fd,ttl:H([L(),Xc()]),createdAt:F(),lastUpdatedAt:F(),pollInterval:G(L()),statusMessage:G(F())}),Ld=Z.extend({task:Id}),Rd=nd.merge(Id),zd=rd.extend({method:W(`notifications/tasks/status`),params:Rd}),Bd=X.extend({method:W(`tasks/get`),params:$u.extend({taskId:F()})}),Vd=Z.merge(Id),Hd=X.extend({method:W(`tasks/result`),params:$u.extend({taskId:F()})});Z.loose();let Ud=Nd.extend({method:W(`tasks/list`)}),Wd=Pd.extend({tasks:B(Id)}),Gd=X.extend({method:W(`tasks/cancel`),params:$u.extend({taskId:F()})}),Kd=Z.merge(Id),qd=V({uri:F(),mimeType:G(F()),_meta:U(F(),z()).optional()}),Jd=qd.extend({text:F()}),Yd=F().refine(e=>{try{return atob(e),!0}catch{return!1}},{message:`Invalid Base64 string`}),Xd=qd.extend({blob:Yd}),Zd=ul([`user`,`assistant`]),Qd=V({audience:B(Zd).optional(),priority:L().min(0).max(1).optional(),lastModified:rc({offset:!0}).optional()}),$d=V({..._d.shape,...gd.shape,uri:F(),description:G(F()),mimeType:G(F()),annotations:Qd.optional(),_meta:G(nl({}))}),ef=V({..._d.shape,...gd.shape,uriTemplate:F(),description:G(F()),mimeType:G(F()),annotations:Qd.optional(),_meta:G(nl({}))}),tf=Nd.extend({method:W(`resources/list`)}),nf=Pd.extend({resources:B($d)}),rf=Nd.extend({method:W(`resources/templates/list`)}),af=Pd.extend({resourceTemplates:B(ef)}),of=$u.extend({uri:F()}),sf=of,cf=X.extend({method:W(`resources/read`),params:sf}),lf=Z.extend({contents:B(H([Jd,Xd]))}),uf=rd.extend({method:W(`notifications/resources/list_changed`),params:nd.optional()}),df=of,ff=X.extend({method:W(`resources/subscribe`),params:df}),pf=of,mf=X.extend({method:W(`resources/unsubscribe`),params:pf}),hf=nd.extend({uri:F()}),gf=rd.extend({method:W(`notifications/resources/updated`),params:hf}),_f=V({name:F(),description:G(F()),required:G(R())}),vf=V({..._d.shape,...gd.shape,description:G(F()),arguments:G(B(_f)),_meta:G(nl({}))}),yf=Nd.extend({method:W(`prompts/list`)}),bf=Pd.extend({prompts:B(vf)}),xf=$u.extend({name:F(),arguments:U(F(),F()).optional()}),Sf=X.extend({method:W(`prompts/get`),params:xf}),Cf=V({type:W(`text`),text:F(),annotations:Qd.optional(),_meta:U(F(),z()).optional()}),wf=V({type:W(`image`),data:Yd,mimeType:F(),annotations:Qd.optional(),_meta:U(F(),z()).optional()}),Tf=V({type:W(`audio`),data:Yd,mimeType:F(),annotations:Qd.optional(),_meta:U(F(),z()).optional()}),Ef=V({type:W(`tool_use`),name:F(),id:F(),input:U(F(),z()),_meta:U(F(),z()).optional()}),Df=V({type:W(`resource`),resource:H([Jd,Xd]),annotations:Qd.optional(),_meta:U(F(),z()).optional()}),Of=H([Cf,wf,Tf,$d.extend({type:W(`resource_link`)}),Df]),kf=V({role:Zd,content:Of}),Af=Z.extend({description:F().optional(),messages:B(kf)}),jf=rd.extend({method:W(`notifications/prompts/list_changed`),params:nd.optional()}),Mf=V({title:F().optional(),readOnlyHint:R().optional(),destructiveHint:R().optional(),idempotentHint:R().optional(),openWorldHint:R().optional()}),Nf=V({taskSupport:ul([`required`,`optional`,`forbidden`]).optional()}),Pf=V({..._d.shape,...gd.shape,description:F().optional(),inputSchema:V({type:W(`object`),properties:U(F(),Y).optional(),required:B(F()).optional()}).catchall(z()),outputSchema:V({type:W(`object`),properties:U(F(),Y).optional(),required:B(F()).optional()}).catchall(z()).optional(),annotations:Mf.optional(),execution:Nf.optional(),_meta:U(F(),z()).optional()}),Ff=Nd.extend({method:W(`tools/list`)}),If=Pd.extend({tools:B(Pf)}),Lf=Z.extend({content:B(Of).default([]),structuredContent:U(F(),z()).optional(),isError:R().optional()});Lf.or(Z.extend({toolResult:z()}));let Rf=ed.extend({name:F(),arguments:U(F(),z()).optional()}),zf=X.extend({method:W(`tools/call`),params:Rf}),Bf=rd.extend({method:W(`notifications/tools/list_changed`),params:nd.optional()});V({autoRefresh:R().default(!0),debounceMs:L().int().nonnegative().default(300)});let Vf=ul([`debug`,`info`,`notice`,`warning`,`error`,`critical`,`alert`,`emergency`]),Hf=$u.extend({level:Vf}),Uf=X.extend({method:W(`logging/setLevel`),params:Hf}),Wf=nd.extend({level:Vf,logger:F().optional(),data:z()}),Gf=rd.extend({method:W(`notifications/message`),params:Wf}),Kf=V({hints:B(V({name:F().optional()})).optional(),costPriority:L().min(0).max(1).optional(),speedPriority:L().min(0).max(1).optional(),intelligencePriority:L().min(0).max(1).optional()}),qf=V({mode:ul([`auto`,`required`,`none`]).optional()}),Jf=V({type:W(`tool_result`),toolUseId:F().describe(`The unique identifier for the corresponding tool call.`),content:B(Of).default([]),structuredContent:V({}).loose().optional(),isError:R().optional(),_meta:U(F(),z()).optional()}),Yf=al(`type`,[Cf,wf,Tf]),Xf=al(`type`,[Cf,wf,Tf,Ef,Jf]),Zf=V({role:Zd,content:H([Xf,B(Xf)]),_meta:U(F(),z()).optional()}),Qf=ed.extend({messages:B(Zf),modelPreferences:Kf.optional(),systemPrompt:F().optional(),includeContext:ul([`none`,`thisServer`,`allServers`]).optional(),temperature:L().optional(),maxTokens:L().int(),stopSequences:B(F()).optional(),metadata:Y.optional(),tools:B(Pf).optional(),toolChoice:qf.optional()}),$f=X.extend({method:W(`sampling/createMessage`),params:Qf}),ep=Z.extend({model:F(),stopReason:G(ul([`endTurn`,`stopSequence`,`maxTokens`]).or(F())),role:Zd,content:Yf}),tp=Z.extend({model:F(),stopReason:G(ul([`endTurn`,`stopSequence`,`maxTokens`,`toolUse`]).or(F())),role:Zd,content:H([Xf,B(Xf)])}),np=V({type:W(`boolean`),title:F().optional(),description:F().optional(),default:R().optional()}),rp=V({type:W(`string`),title:F().optional(),description:F().optional(),minLength:L().optional(),maxLength:L().optional(),format:ul([`email`,`uri`,`date`,`date-time`]).optional(),default:F().optional()}),ip=V({type:ul([`number`,`integer`]),title:F().optional(),description:F().optional(),minimum:L().optional(),maximum:L().optional(),default:L().optional()}),ap=V({type:W(`string`),title:F().optional(),description:F().optional(),enum:B(F()),default:F().optional()}),op=V({type:W(`string`),title:F().optional(),description:F().optional(),oneOf:B(V({const:F(),title:F()})),default:F().optional()}),sp=H([H([V({type:W(`string`),title:F().optional(),description:F().optional(),enum:B(F()),enumNames:B(F()).optional(),default:F().optional()}),H([ap,op]),H([V({type:W(`array`),title:F().optional(),description:F().optional(),minItems:L().optional(),maxItems:L().optional(),items:V({type:W(`string`),enum:B(F())}),default:B(F()).optional()}),V({type:W(`array`),title:F().optional(),description:F().optional(),minItems:L().optional(),maxItems:L().optional(),items:V({anyOf:B(V({const:F(),title:F()}))}),default:B(F()).optional()})])]),np,rp,ip]),cp=H([ed.extend({mode:W(`form`).optional(),message:F(),requestedSchema:V({type:W(`object`),properties:U(F(),sp),required:B(F()).optional()})}),ed.extend({mode:W(`url`),message:F(),elicitationId:F(),url:F().url()})]),lp=X.extend({method:W(`elicitation/create`),params:cp}),up=nd.extend({elicitationId:F()}),dp=rd.extend({method:W(`notifications/elicitation/complete`),params:up}),fp=Z.extend({action:ul([`accept`,`decline`,`cancel`]),content:Fl(e=>e===null?void 0:e,U(F(),H([F(),L(),R(),B(F())])).optional())}),pp=V({type:W(`ref/resource`),uri:F()}),mp=V({type:W(`ref/prompt`),name:F()}),hp=$u.extend({ref:H([mp,pp]),argument:V({name:F(),value:F()}),context:V({arguments:U(F(),F()).optional()}).optional()}),gp=X.extend({method:W(`completion/complete`),params:hp});function _p(e){if(e.params.ref.type!==`ref/prompt`)throw TypeError(`Expected CompleteRequestPrompt, but got ${e.params.ref.type}`)}function vp(e){if(e.params.ref.type!==`ref/resource`)throw TypeError(`Expected CompleteRequestResourceTemplate, but got ${e.params.ref.type}`)}let yp=Z.extend({completion:nl({values:B(F()).max(100),total:G(L().int()),hasMore:G(R())})}),bp=V({uri:F().startsWith(`file://`),name:F().optional(),_meta:U(F(),z()).optional()}),xp=X.extend({method:W(`roots/list`),params:$u.optional()}),Sp=Z.extend({roots:B(bp)}),Cp=rd.extend({method:W(`notifications/roots/list_changed`),params:nd.optional()});H([Od,wd,gp,Uf,Sf,yf,tf,rf,cf,ff,mf,zf,Ff,Bd,Hd,Ud,Gd]),H([hd,jd,Dd,Cp,zd]),H([pd,ep,tp,fp,Sp,Vd,Wd,Ld]),H([Od,$f,lp,xp,Bd,Hd,Ud,Gd]),H([hd,jd,Gf,gf,uf,Bf,jf,zd,dp]),H([pd,Ed,yp,Af,bf,nf,af,lf,Lf,If,Vd,Wd,Ld]);var $=class e extends Error{constructor(e,t,n){super(`MCP error ${e}: ${t}`),this.code=e,this.data=n,this.name=`McpError`}static fromError(t,n,r){if(t===Q.UrlElicitationRequired&&r){let e=r;if(e.elicitations)return new wp(e.elicitations,n)}return new e(t,n,r)}},wp=class extends ${constructor(e,t=`URL elicitation${e.length>1?`s`:``} required`){super(Q.UrlElicitationRequired,t,{elicitations:e})}get elicitations(){return this.data?.elicitations??[]}};function Tp(e){return e===`completed`||e===`failed`||e===`cancelled`}function Ep(e){return!e||e===`jsonSchema7`||e===`draft-7`?`draft-7`:e===`jsonSchema2019-09`||e===`draft-2020-12`?`draft-2020-12`:`draft-7`}function Dp(e,t){return Fu(e)?Qs(e,{target:Ep(t?.target),io:t?.pipeStrategy??`input`}):Pu(e,{strictUnions:t?.strictUnions??!0,pipeStrategy:t?.pipeStrategy??`input`})}function Op(e){let t=zu(e)?.method;if(!t)throw Error(`Schema is missing a method literal`);let n=Wu(t);if(typeof n!=`string`)throw Error(`Schema method literal must be a string`);return n}function kp(e,t){let n=Lu(e,t);if(!n.success)throw n.error;return n.data}var Ap=class{constructor(e){this._options=e,this._requestMessageId=0,this._requestHandlers=new Map,this._requestHandlerAbortControllers=new Map,this._notificationHandlers=new Map,this._responseHandlers=new Map,this._progressHandlers=new Map,this._timeoutInfo=new Map,this._pendingDebouncedNotifications=new Set,this._taskProgressTokens=new Map,this._requestResolvers=new Map,this.setNotificationHandler(hd,e=>{this._oncancel(e)}),this.setNotificationHandler(jd,e=>{this._onprogress(e)}),this.setRequestHandler(Od,e=>({})),this._taskStore=e?.taskStore,this._taskMessageQueue=e?.taskMessageQueue,this._taskStore&&(this.setRequestHandler(Bd,async(e,t)=>{let n=await this._taskStore.getTask(e.params.taskId,t.sessionId);if(!n)throw new $(Q.InvalidParams,`Failed to retrieve task: Task not found`);return{...n}}),this.setRequestHandler(Hd,async(e,t)=>{let n=async()=>{let r=e.params.taskId;if(this._taskMessageQueue){let e;for(;e=await this._taskMessageQueue.dequeue(r,t.sessionId);){if(e.type===`response`||e.type===`error`){let t=e.message,n=t.id,r=this._requestResolvers.get(n);if(r)if(this._requestResolvers.delete(n),e.type===`response`)r(t);else{let e=t;r(new $(e.error.code,e.error.message,e.error.data))}else{let t=e.type===`response`?`Response`:`Error`;this._onerror(Error(`${t} handler missing for request ${n}`))}continue}await this._transport?.send(e.message,{relatedRequestId:t.requestId})}}let i=await this._taskStore.getTask(r,t.sessionId);if(!i)throw new $(Q.InvalidParams,`Task not found: ${r}`);if(!Tp(i.status))return await this._waitForTaskUpdate(r,t.signal),await n();if(Tp(i.status)){let e=await this._taskStore.getTaskResult(r,t.sessionId);return this._clearTaskQueue(r),{...e,_meta:{...e._meta,[qu]:{taskId:r}}}}return await n()};return await n()}),this.setRequestHandler(Ud,async(e,t)=>{try{let{tasks:n,nextCursor:r}=await this._taskStore.listTasks(e.params?.cursor,t.sessionId);return{tasks:n,nextCursor:r,_meta:{}}}catch(e){throw new $(Q.InvalidParams,`Failed to list tasks: ${e instanceof Error?e.message:String(e)}`)}}),this.setRequestHandler(Gd,async(e,t)=>{try{let n=await this._taskStore.getTask(e.params.taskId,t.sessionId);if(!n)throw new $(Q.InvalidParams,`Task not found: ${e.params.taskId}`);if(Tp(n.status))throw new $(Q.InvalidParams,`Cannot cancel task in terminal status: ${n.status}`);await this._taskStore.updateTaskStatus(e.params.taskId,`cancelled`,`Client cancelled task execution.`,t.sessionId),this._clearTaskQueue(e.params.taskId);let r=await this._taskStore.getTask(e.params.taskId,t.sessionId);if(!r)throw new $(Q.InvalidParams,`Task not found after cancellation: ${e.params.taskId}`);return{_meta:{},...r}}catch(e){throw e instanceof $?e:new $(Q.InvalidRequest,`Failed to cancel task: ${e instanceof Error?e.message:String(e)}`)}}))}async _oncancel(e){e.params.requestId&&this._requestHandlerAbortControllers.get(e.params.requestId)?.abort(e.params.reason)}_setupTimeout(e,t,n,r,i=!1){this._timeoutInfo.set(e,{timeoutId:setTimeout(r,t),startTime:Date.now(),timeout:t,maxTotalTimeout:n,resetTimeoutOnProgress:i,onTimeout:r})}_resetTimeout(e){let t=this._timeoutInfo.get(e);if(!t)return!1;let n=Date.now()-t.startTime;if(t.maxTotalTimeout&&n>=t.maxTotalTimeout)throw this._timeoutInfo.delete(e),$.fromError(Q.RequestTimeout,`Maximum total timeout exceeded`,{maxTotalTimeout:t.maxTotalTimeout,totalElapsed:n});return clearTimeout(t.timeoutId),t.timeoutId=setTimeout(t.onTimeout,t.timeout),!0}_cleanupTimeout(e){let t=this._timeoutInfo.get(e);t&&(clearTimeout(t.timeoutId),this._timeoutInfo.delete(e))}async connect(e){if(this._transport)throw Error(`Already connected to a transport. Call close() before connecting to a new transport, or use a separate Protocol instance per connection.`);this._transport=e;let t=this.transport?.onclose;this._transport.onclose=()=>{t?.(),this._onclose()};let n=this.transport?.onerror;this._transport.onerror=e=>{n?.(e),this._onerror(e)};let r=this._transport?.onmessage;this._transport.onmessage=(e,t)=>{r?.(e,t),ud(e)||fd(e)?this._onresponse(e):od(e)?this._onrequest(e,t):cd(e)?this._onnotification(e):this._onerror(Error(`Unknown message type: ${JSON.stringify(e)}`))},await this._transport.start()}_onclose(){let e=this._responseHandlers;this._responseHandlers=new Map,this._progressHandlers.clear(),this._taskProgressTokens.clear(),this._pendingDebouncedNotifications.clear();for(let e of this._requestHandlerAbortControllers.values())e.abort();this._requestHandlerAbortControllers.clear();let t=$.fromError(Q.ConnectionClosed,`Connection closed`);this._transport=void 0,this.onclose?.();for(let n of e.values())n(t)}_onerror(e){this.onerror?.(e)}_onnotification(e){let t=this._notificationHandlers.get(e.method)??this.fallbackNotificationHandler;t!==void 0&&Promise.resolve().then(()=>t(e)).catch(e=>this._onerror(Error(`Uncaught error in notification handler: ${e}`)))}_onrequest(e,t){let n=this._requestHandlers.get(e.method)??this.fallbackRequestHandler,r=this._transport,i=e.params?._meta?.[qu]?.taskId;if(n===void 0){let t={jsonrpc:`2.0`,id:e.id,error:{code:Q.MethodNotFound,message:`Method not found`}};i&&this._taskMessageQueue?this._enqueueTaskMessage(i,{type:`error`,message:t,timestamp:Date.now()},r?.sessionId).catch(e=>this._onerror(Error(`Failed to enqueue error response: ${e}`))):r?.send(t).catch(e=>this._onerror(Error(`Failed to send an error response: ${e}`)));return}let a=new AbortController;this._requestHandlerAbortControllers.set(e.id,a);let o=td(e.params)?e.params.task:void 0,s=this._taskStore?this.requestTaskStore(e,r?.sessionId):void 0,c={signal:a.signal,sessionId:r?.sessionId,_meta:e.params?._meta,sendNotification:async t=>{if(a.signal.aborted)return;let n={relatedRequestId:e.id};i&&(n.relatedTask={taskId:i}),await this.notification(t,n)},sendRequest:async(t,n,r)=>{if(a.signal.aborted)throw new $(Q.ConnectionClosed,`Request was cancelled`);let o={...r,relatedRequestId:e.id};i&&!o.relatedTask&&(o.relatedTask={taskId:i});let c=o.relatedTask?.taskId??i;return c&&s&&await s.updateTaskStatus(c,`input_required`),await this.request(t,n,o)},authInfo:t?.authInfo,requestId:e.id,requestInfo:t?.requestInfo,taskId:i,taskStore:s,taskRequestedTtl:o?.ttl,closeSSEStream:t?.closeSSEStream,closeStandaloneSSEStream:t?.closeStandaloneSSEStream};Promise.resolve().then(()=>{o&&this.assertTaskHandlerCapability(e.method)}).then(()=>n(e,c)).then(async t=>{if(a.signal.aborted)return;let n={result:t,jsonrpc:`2.0`,id:e.id};i&&this._taskMessageQueue?await this._enqueueTaskMessage(i,{type:`response`,message:n,timestamp:Date.now()},r?.sessionId):await r?.send(n)},async t=>{if(a.signal.aborted)return;let n={jsonrpc:`2.0`,id:e.id,error:{code:Number.isSafeInteger(t.code)?t.code:Q.InternalError,message:t.message??`Internal error`,...t.data!==void 0&&{data:t.data}}};i&&this._taskMessageQueue?await this._enqueueTaskMessage(i,{type:`error`,message:n,timestamp:Date.now()},r?.sessionId):await r?.send(n)}).catch(e=>this._onerror(Error(`Failed to send response: ${e}`))).finally(()=>{this._requestHandlerAbortControllers.delete(e.id)})}_onprogress(e){let{progressToken:t,...n}=e.params,r=Number(t),i=this._progressHandlers.get(r);if(!i){this._onerror(Error(`Received a progress notification for an unknown token: ${JSON.stringify(e)}`));return}let a=this._responseHandlers.get(r),o=this._timeoutInfo.get(r);if(o&&a&&o.resetTimeoutOnProgress)try{this._resetTimeout(r)}catch(e){this._responseHandlers.delete(r),this._progressHandlers.delete(r),this._cleanupTimeout(r),a(e);return}i(n)}_onresponse(e){let t=Number(e.id),n=this._requestResolvers.get(t);if(n){this._requestResolvers.delete(t),ud(e)?n(e):n(new $(e.error.code,e.error.message,e.error.data));return}let r=this._responseHandlers.get(t);if(r===void 0){this._onerror(Error(`Received a response for an unknown message ID: ${JSON.stringify(e)}`));return}this._responseHandlers.delete(t),this._cleanupTimeout(t);let i=!1;if(ud(e)&&e.result&&typeof e.result==`object`){let n=e.result;if(n.task&&typeof n.task==`object`){let e=n.task;typeof e.taskId==`string`&&(i=!0,this._taskProgressTokens.set(e.taskId,t))}}i||this._progressHandlers.delete(t),ud(e)?r(e):r($.fromError(e.error.code,e.error.message,e.error.data))}get transport(){return this._transport}async close(){await this._transport?.close()}async*requestStream(e,t,n){let{task:r}=n??{};if(!r){try{yield{type:`result`,result:await this.request(e,t,n)}}catch(e){yield{type:`error`,error:e instanceof $?e:new $(Q.InternalError,String(e))}}return}let i;try{let r=await this.request(e,Ld,n);if(r.task)i=r.task.taskId,yield{type:`taskCreated`,task:r.task};else throw new $(Q.InternalError,`Task creation did not return a task`);for(;;){let e=await this.getTask({taskId:i},n);if(yield{type:`taskStatus`,task:e},Tp(e.status)){e.status===`completed`?yield{type:`result`,result:await this.getTaskResult({taskId:i},t,n)}:e.status===`failed`?yield{type:`error`,error:new $(Q.InternalError,`Task ${i} failed`)}:e.status===`cancelled`&&(yield{type:`error`,error:new $(Q.InternalError,`Task ${i} was cancelled`)});return}if(e.status===`input_required`){yield{type:`result`,result:await this.getTaskResult({taskId:i},t,n)};return}let r=e.pollInterval??this._options?.defaultTaskPollInterval??1e3;await new Promise(e=>setTimeout(e,r)),n?.signal?.throwIfAborted()}}catch(e){yield{type:`error`,error:e instanceof $?e:new $(Q.InternalError,String(e))}}}request(e,t,n){let{relatedRequestId:r,resumptionToken:i,onresumptiontoken:a,task:o,relatedTask:s}=n??{};return new Promise((c,l)=>{let u=e=>{l(e)};if(!this._transport){u(Error(`Not connected`));return}if(this._options?.enforceStrictCapabilities===!0)try{this.assertCapabilityForMethod(e.method),o&&this.assertTaskCapability(e.method)}catch(e){u(e);return}n?.signal?.throwIfAborted();let d=this._requestMessageId++,f={...e,jsonrpc:`2.0`,id:d};n?.onprogress&&(this._progressHandlers.set(d,n.onprogress),f.params={...e.params,_meta:{...e.params?._meta||{},progressToken:d}}),o&&(f.params={...f.params,task:o}),s&&(f.params={...f.params,_meta:{...f.params?._meta||{},[qu]:s}});let ee=e=>{this._responseHandlers.delete(d),this._progressHandlers.delete(d),this._cleanupTimeout(d),this._transport?.send({jsonrpc:`2.0`,method:`notifications/cancelled`,params:{requestId:d,reason:String(e)}},{relatedRequestId:r,resumptionToken:i,onresumptiontoken:a}).catch(e=>this._onerror(Error(`Failed to send cancellation: ${e}`))),l(e instanceof $?e:new $(Q.RequestTimeout,String(e)))};this._responseHandlers.set(d,e=>{if(!n?.signal?.aborted){if(e instanceof Error)return l(e);try{let n=Lu(t,e.result);n.success?c(n.data):l(n.error)}catch(e){l(e)}}}),n?.signal?.addEventListener(`abort`,()=>{ee(n?.signal?.reason)});let te=n?.timeout??6e4;this._setupTimeout(d,te,n?.maxTotalTimeout,()=>ee($.fromError(Q.RequestTimeout,`Request timed out`,{timeout:te})),n?.resetTimeoutOnProgress??!1);let ne=s?.taskId;ne?(this._requestResolvers.set(d,e=>{let t=this._responseHandlers.get(d);t?t(e):this._onerror(Error(`Response handler missing for side-channeled request ${d}`))}),this._enqueueTaskMessage(ne,{type:`request`,message:f,timestamp:Date.now()}).catch(e=>{this._cleanupTimeout(d),l(e)})):this._transport.send(f,{relatedRequestId:r,resumptionToken:i,onresumptiontoken:a}).catch(e=>{this._cleanupTimeout(d),l(e)})})}async getTask(e,t){return this.request({method:`tasks/get`,params:e},Vd,t)}async getTaskResult(e,t,n){return this.request({method:`tasks/result`,params:e},t,n)}async listTasks(e,t){return this.request({method:`tasks/list`,params:e},Wd,t)}async cancelTask(e,t){return this.request({method:`tasks/cancel`,params:e},Kd,t)}async notification(e,t){if(!this._transport)throw Error(`Not connected`);this.assertNotificationCapability(e.method);let n=t?.relatedTask?.taskId;if(n){let r={...e,jsonrpc:`2.0`,params:{...e.params,_meta:{...e.params?._meta||{},[qu]:t.relatedTask}}};await this._enqueueTaskMessage(n,{type:`notification`,message:r,timestamp:Date.now()});return}if((this._options?.debouncedNotificationMethods??[]).includes(e.method)&&!e.params&&!t?.relatedRequestId&&!t?.relatedTask){if(this._pendingDebouncedNotifications.has(e.method))return;this._pendingDebouncedNotifications.add(e.method),Promise.resolve().then(()=>{if(this._pendingDebouncedNotifications.delete(e.method),!this._transport)return;let n={...e,jsonrpc:`2.0`};t?.relatedTask&&(n={...n,params:{...n.params,_meta:{...n.params?._meta||{},[qu]:t.relatedTask}}}),this._transport?.send(n,t).catch(e=>this._onerror(e))});return}let r={...e,jsonrpc:`2.0`};t?.relatedTask&&(r={...r,params:{...r.params,_meta:{...r.params?._meta||{},[qu]:t.relatedTask}}}),await this._transport.send(r,t)}setRequestHandler(e,t){let n=Op(e);this.assertRequestHandlerCapability(n),this._requestHandlers.set(n,(n,r)=>{let i=kp(e,n);return Promise.resolve(t(i,r))})}removeRequestHandler(e){this._requestHandlers.delete(e)}assertCanSetRequestHandler(e){if(this._requestHandlers.has(e))throw Error(`A request handler for ${e} already exists, which would be overridden`)}setNotificationHandler(e,t){let n=Op(e);this._notificationHandlers.set(n,n=>{let r=kp(e,n);return Promise.resolve(t(r))})}removeNotificationHandler(e){this._notificationHandlers.delete(e)}_cleanupTaskProgressHandler(e){let t=this._taskProgressTokens.get(e);t!==void 0&&(this._progressHandlers.delete(t),this._taskProgressTokens.delete(e))}async _enqueueTaskMessage(e,t,n){if(!this._taskStore||!this._taskMessageQueue)throw Error(`Cannot enqueue task message: taskStore and taskMessageQueue are not configured`);let r=this._options?.maxTaskQueueSize;await this._taskMessageQueue.enqueue(e,t,n,r)}async _clearTaskQueue(e,t){if(this._taskMessageQueue){let n=await this._taskMessageQueue.dequeueAll(e,t);for(let t of n)if(t.type===`request`&&od(t.message)){let n=t.message.id,r=this._requestResolvers.get(n);r?(r(new $(Q.InternalError,`Task cancelled or completed`)),this._requestResolvers.delete(n)):this._onerror(Error(`Resolver missing for request ${n} during task ${e} cleanup`))}}}async _waitForTaskUpdate(e,t){let n=this._options?.defaultTaskPollInterval??1e3;try{let t=await this._taskStore?.getTask(e);t?.pollInterval&&(n=t.pollInterval)}catch{}return new Promise((e,r)=>{if(t.aborted){r(new $(Q.InvalidRequest,`Request cancelled`));return}let i=setTimeout(e,n);t.addEventListener(`abort`,()=>{clearTimeout(i),r(new $(Q.InvalidRequest,`Request cancelled`))},{once:!0})})}requestTaskStore(e,t){let n=this._taskStore;if(!n)throw Error(`No task store configured`);return{createTask:async r=>{if(!e)throw Error(`No request provided`);return await n.createTask(r,e.id,{method:e.method,params:e.params},t)},getTask:async e=>{let r=await n.getTask(e,t);if(!r)throw new $(Q.InvalidParams,`Failed to retrieve task: Task not found`);return r},storeTaskResult:async(e,r,i)=>{await n.storeTaskResult(e,r,i,t);let a=await n.getTask(e,t);if(a){let t=zd.parse({method:`notifications/tasks/status`,params:a});await this.notification(t),Tp(a.status)&&this._cleanupTaskProgressHandler(e)}},getTaskResult:e=>n.getTaskResult(e,t),updateTaskStatus:async(e,r,i)=>{let a=await n.getTask(e,t);if(!a)throw new $(Q.InvalidParams,`Task "${e}" not found - it may have been cleaned up`);if(Tp(a.status))throw new $(Q.InvalidParams,`Cannot update task "${e}" from terminal status "${a.status}" to "${r}". Terminal states (completed, failed, cancelled) cannot transition to other states.`);await n.updateTaskStatus(e,r,i,t);let o=await n.getTask(e,t);if(o){let t=zd.parse({method:`notifications/tasks/status`,params:o});await this.notification(t),Tp(o.status)&&this._cleanupTaskProgressHandler(e)}},listTasks:e=>n.listTasks(e,t)}}};function jp(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Mp(e,t){let n={...e};for(let e in t){let r=e,i=t[r];if(i===void 0)continue;let a=n[r];jp(a)&&jp(i)?n[r]={...a,...i}:n[r]=i}return n}var Np=class{compile(e){throw Error(`[WebMCP] Ajv stub was invoked. This indicates the MCP SDK is bypassing PolyfillJsonSchemaValidator. Please report this as a bug.`)}getSchema(e){}errorsText(e){return``}};function Pp(){return new Np({strict:!1,validateFormats:!0,validateSchema:!1,allErrors:!0})}var Fp=class{constructor(e){this._ajv=e??Pp()}getValidator(e){let t=`$id`in e&&typeof e.$id==`string`?this._ajv.getSchema(e.$id)??this._ajv.compile(e):this._ajv.compile(e);return e=>t(e)?{valid:!0,data:e,errorMessage:void 0}:{valid:!1,data:void 0,errorMessage:this._ajv.errorsText(t.errors)}}};function Ip(e,t,n){if(!e)throw Error(`${n} does not support task creation (required for ${t})`);switch(t){case`tools/call`:if(!e.tools?.call)throw Error(`${n} does not support task creation for tools/call (required for ${t})`);break;default:break}}function Lp(e,t,n){if(!e)throw Error(`${n} does not support task creation (required for ${t})`);switch(t){case`sampling/createMessage`:if(!e.sampling?.createMessage)throw Error(`${n} does not support task creation for sampling/createMessage (required for ${t})`);break;case`elicitation/create`:if(!e.elicitation?.create)throw Error(`${n} does not support task creation for elicitation/create (required for ${t})`);break;default:break}}var Rp=class{constructor(e){this._server=e}requestStream(e,t,n){return this._server.requestStream(e,t,n)}async getTask(e,t){return this._server.getTask({taskId:e},t)}async getTaskResult(e,t,n){return this._server.getTaskResult({taskId:e},t,n)}async listTasks(e,t){return this._server.listTasks(e?{cursor:e}:void 0,t)}async cancelTask(e,t){return this._server.cancelTask({taskId:e},t)}},zp=class extends Ap{constructor(e,t){super(t),this._serverInfo=e,this._loggingLevels=new Map,this.LOG_LEVEL_SEVERITY=new Map(Vf.options.map((e,t)=>[e,t])),this.isMessageIgnored=(e,t)=>{let n=this._loggingLevels.get(t);return n?this.LOG_LEVEL_SEVERITY.get(e)<this.LOG_LEVEL_SEVERITY.get(n):!1},this._capabilities=t?.capabilities??{},this._instructions=t?.instructions,this._jsonSchemaValidator=t?.jsonSchemaValidator??new Fp,this.setRequestHandler(wd,e=>this._oninitialize(e)),this.setNotificationHandler(Dd,()=>this.oninitialized?.()),this._capabilities.logging&&this.setRequestHandler(Uf,async(e,t)=>{let n=t.sessionId||t.requestInfo?.headers[`mcp-session-id`]||void 0,{level:r}=e.params,i=Vf.safeParse(r);return i.success&&this._loggingLevels.set(n,i.data),{}})}get experimental(){return this._experimental||={tasks:new Rp(this)},this._experimental}registerCapabilities(e){if(this.transport)throw Error(`Cannot register capabilities after connecting to transport`);this._capabilities=Mp(this._capabilities,e)}setRequestHandler(e,t){let n=zu(e)?.method;if(!n)throw Error(`Schema is missing a method literal`);let r;if(Fu(n)){let e=n;r=e._zod?.def?.value??e.value}else{let e=n;r=e._def?.value??e.value}if(typeof r!=`string`)throw Error(`Schema method literal must be a string`);return r===`tools/call`?super.setRequestHandler(e,async(e,n)=>{let r=Lu(zf,e);if(!r.success){let e=r.error instanceof Error?r.error.message:String(r.error);throw new $(Q.InvalidParams,`Invalid tools/call request: ${e}`)}let{params:i}=r.data,a=await Promise.resolve(t(e,n));if(i.task){let e=Lu(Ld,a);if(!e.success){let t=e.error instanceof Error?e.error.message:String(e.error);throw new $(Q.InvalidParams,`Invalid task creation result: ${t}`)}return e.data}let o=Lu(Lf,a);if(!o.success){let e=o.error instanceof Error?o.error.message:String(o.error);throw new $(Q.InvalidParams,`Invalid tools/call result: ${e}`)}return o.data}):super.setRequestHandler(e,t)}assertCapabilityForMethod(e){switch(e){case`sampling/createMessage`:if(!this._clientCapabilities?.sampling)throw Error(`Client does not support sampling (required for ${e})`);break;case`elicitation/create`:if(!this._clientCapabilities?.elicitation)throw Error(`Client does not support elicitation (required for ${e})`);break;case`roots/list`:if(!this._clientCapabilities?.roots)throw Error(`Client does not support listing roots (required for ${e})`);break;case`ping`:break}}assertNotificationCapability(e){switch(e){case`notifications/message`:if(!this._capabilities.logging)throw Error(`Server does not support logging (required for ${e})`);break;case`notifications/resources/updated`:case`notifications/resources/list_changed`:if(!this._capabilities.resources)throw Error(`Server does not support notifying about resources (required for ${e})`);break;case`notifications/tools/list_changed`:if(!this._capabilities.tools)throw Error(`Server does not support notifying of tool list changes (required for ${e})`);break;case`notifications/prompts/list_changed`:if(!this._capabilities.prompts)throw Error(`Server does not support notifying of prompt list changes (required for ${e})`);break;case`notifications/elicitation/complete`:if(!this._clientCapabilities?.elicitation?.url)throw Error(`Client does not support URL elicitation (required for ${e})`);break;case`notifications/cancelled`:break;case`notifications/progress`:break}}assertRequestHandlerCapability(e){if(this._capabilities)switch(e){case`completion/complete`:if(!this._capabilities.completions)throw Error(`Server does not support completions (required for ${e})`);break;case`logging/setLevel`:if(!this._capabilities.logging)throw Error(`Server does not support logging (required for ${e})`);break;case`prompts/get`:case`prompts/list`:if(!this._capabilities.prompts)throw Error(`Server does not support prompts (required for ${e})`);break;case`resources/list`:case`resources/templates/list`:case`resources/read`:if(!this._capabilities.resources)throw Error(`Server does not support resources (required for ${e})`);break;case`tools/call`:case`tools/list`:if(!this._capabilities.tools)throw Error(`Server does not support tools (required for ${e})`);break;case`tasks/get`:case`tasks/list`:case`tasks/result`:case`tasks/cancel`:if(!this._capabilities.tasks)throw Error(`Server does not support tasks capability (required for ${e})`);break;case`ping`:case`initialize`:break}}assertTaskCapability(e){Lp(this._clientCapabilities?.tasks?.requests,e,`Client`)}assertTaskHandlerCapability(e){this._capabilities&&Ip(this._capabilities.tasks?.requests,e,`Server`)}async _oninitialize(e){let t=e.params.protocolVersion;return this._clientCapabilities=e.params.capabilities,this._clientVersion=e.params.clientInfo,{protocolVersion:Ku.includes(t)?t:Gu,capabilities:this.getCapabilities(),serverInfo:this._serverInfo,...this._instructions&&{instructions:this._instructions}}}getClientCapabilities(){return this._clientCapabilities}getClientVersion(){return this._clientVersion}getCapabilities(){return this._capabilities}async ping(){return this.request({method:`ping`},pd)}async createMessage(e,t){if((e.tools||e.toolChoice)&&!this._clientCapabilities?.sampling?.tools)throw Error(`Client does not support sampling tools capability.`);if(e.messages.length>0){let t=e.messages[e.messages.length-1],n=Array.isArray(t.content)?t.content:[t.content],r=n.some(e=>e.type===`tool_result`),i=e.messages.length>1?e.messages[e.messages.length-2]:void 0,a=i?Array.isArray(i.content)?i.content:[i.content]:[],o=a.some(e=>e.type===`tool_use`);if(r){if(n.some(e=>e.type!==`tool_result`))throw Error(`The last message must contain only tool_result content if any is present`);if(!o)throw Error(`tool_result blocks are not matching any tool_use from the previous message`)}if(o){let e=new Set(a.filter(e=>e.type===`tool_use`).map(e=>e.id)),t=new Set(n.filter(e=>e.type===`tool_result`).map(e=>e.toolUseId));if(e.size!==t.size||![...e].every(e=>t.has(e)))throw Error(`ids of tool_result blocks and tool_use blocks from previous message do not match`)}}return e.tools?this.request({method:`sampling/createMessage`,params:e},tp,t):this.request({method:`sampling/createMessage`,params:e},ep,t)}async elicitInput(e,t){switch(e.mode??`form`){case`url`:{if(!this._clientCapabilities?.elicitation?.url)throw Error(`Client does not support url elicitation.`);let n=e;return this.request({method:`elicitation/create`,params:n},fp,t)}case`form`:{if(!this._clientCapabilities?.elicitation?.form)throw Error(`Client does not support form elicitation.`);let n=e.mode===`form`?e:{...e,mode:`form`},r=await this.request({method:`elicitation/create`,params:n},fp,t);if(r.action===`accept`&&r.content&&n.requestedSchema)try{let e=this._jsonSchemaValidator.getValidator(n.requestedSchema)(r.content);if(!e.valid)throw new $(Q.InvalidParams,`Elicitation response content does not match requested schema: ${e.errorMessage}`)}catch(e){throw e instanceof $?e:new $(Q.InternalError,`Error validating elicitation response: ${e instanceof Error?e.message:String(e)}`)}return r}}}createElicitationCompletionNotifier(e,t){if(!this._clientCapabilities?.elicitation?.url)throw Error(`Client does not support URL elicitation (required for notifications/elicitation/complete)`);return()=>this.notification({method:`notifications/elicitation/complete`,params:{elicitationId:e}},t)}async listRoots(e,t){return this.request({method:`roots/list`,params:e},Sp,t)}async sendLoggingMessage(e,t){if(this._capabilities.logging&&!this.isMessageIgnored(e.level,t))return this.notification({method:`notifications/message`,params:e})}async sendResourceUpdated(e){return this.notification({method:`notifications/resources/updated`,params:e})}async sendResourceListChanged(){return this.notification({method:`notifications/resources/list_changed`})}async sendToolListChanged(){return this.notification({method:`notifications/tools/list_changed`})}async sendPromptListChanged(){return this.notification({method:`notifications/prompts/list_changed`})}};let Bp=Symbol.for(`mcp.completable`);function Vp(e){return!!e&&typeof e==`object`&&Bp in e}function Hp(e){return e[Bp]?.complete}var Up;(function(e){e.Completable=`McpCompletable`})(Up||={});let Wp=/^[A-Za-z0-9._-]{1,128}$/;function Gp(e){let t=[];if(e.length===0)return{isValid:!1,warnings:[`Tool name cannot be empty`]};if(e.length>128)return{isValid:!1,warnings:[`Tool name exceeds maximum length of 128 characters (current: ${e.length})`]};if(e.includes(` `)&&t.push(`Tool name contains spaces, which may cause parsing issues`),e.includes(`,`)&&t.push(`Tool name contains commas, which may cause parsing issues`),(e.startsWith(`-`)||e.endsWith(`-`))&&t.push(`Tool name starts or ends with a dash, which may cause parsing issues in some contexts`),(e.startsWith(`.`)||e.endsWith(`.`))&&t.push(`Tool name starts or ends with a dot, which may cause parsing issues in some contexts`),!Wp.test(e)){let n=e.split(``).filter(e=>!/[A-Za-z0-9._-]/.test(e)).filter((e,t,n)=>n.indexOf(e)===t);return t.push(`Tool name contains invalid characters: ${n.map(e=>`"${e}"`).join(`, `)}`,`Allowed characters are: A-Z, a-z, 0-9, underscore (_), dash (-), and dot (.)`),{isValid:!1,warnings:t}}return{isValid:!0,warnings:t}}function Kp(e,t){if(t.length>0){console.warn(`Tool name validation warning for "${e}":`);for(let e of t)console.warn(` - ${e}`);console.warn(`Tool registration will proceed, but this may cause compatibility issues.`),console.warn(`Consider updating the tool name to conform to the MCP tool naming standard.`),console.warn(`See SEP: Specify Format for Tool Names (https://github.com/modelcontextprotocol/modelcontextprotocol/issues/986) for more details.`)}}function qp(e){let t=Gp(e);return Kp(e,t.warnings),t.isValid}var Jp=class{constructor(e){this._mcpServer=e}registerToolTask(e,t,n){let r={taskSupport:`required`,...t.execution};if(r.taskSupport===`forbidden`)throw Error(`Cannot register task-based tool '${e}' with taskSupport 'forbidden'. Use registerTool() instead.`);return this._mcpServer._createRegisteredTool(e,t.title,t.description,t.inputSchema,t.outputSchema,t.annotations,r,t._meta,n)}},Yp=class{constructor(e,t){this._registeredResources={},this._registeredResourceTemplates={},this._registeredTools={},this._registeredPrompts={},this._toolHandlersInitialized=!1,this._completionHandlerInitialized=!1,this._resourceHandlersInitialized=!1,this._promptHandlersInitialized=!1,this.server=new zp(e,t)}get experimental(){return this._experimental||={tasks:new Jp(this)},this._experimental}async connect(e){return await this.server.connect(e)}async close(){await this.server.close()}setToolRequestHandlers(){this._toolHandlersInitialized||=(this.server.assertCanSetRequestHandler(nm(Ff)),this.server.assertCanSetRequestHandler(nm(zf)),this.server.registerCapabilities({tools:{listChanged:!0}}),this.server.setRequestHandler(Ff,()=>({tools:Object.entries(this._registeredTools).filter(([,e])=>e.enabled).map(([e,t])=>{let n={name:e,title:t.title,description:t.description,inputSchema:(()=>{let e=Bu(t.inputSchema);return e?Dp(e,{strictUnions:!0,pipeStrategy:`input`}):Xp})(),annotations:t.annotations,execution:t.execution,_meta:t._meta};if(t.outputSchema){let e=Bu(t.outputSchema);e&&(n.outputSchema=Dp(e,{strictUnions:!0,pipeStrategy:`output`}))}return n})})),this.server.setRequestHandler(zf,async(e,t)=>{try{let n=this._registeredTools[e.params.name];if(!n)throw new $(Q.InvalidParams,`Tool ${e.params.name} not found`);if(!n.enabled)throw new $(Q.InvalidParams,`Tool ${e.params.name} disabled`);let r=!!e.params.task,i=n.execution?.taskSupport,a=`createTask`in n.handler;if((i===`required`||i===`optional`)&&!a)throw new $(Q.InternalError,`Tool ${e.params.name} has taskSupport '${i}' but was not registered with registerToolTask`);if(i===`required`&&!r)throw new $(Q.MethodNotFound,`Tool ${e.params.name} requires task augmentation (taskSupport: 'required')`);if(i===`optional`&&!r&&a)return await this.handleAutomaticTaskPolling(n,e,t);let o=await this.validateToolInput(n,e.params.arguments,e.params.name),s=await this.executeToolHandler(n,o,t);return r||await this.validateToolOutput(n,s,e.params.name),s}catch(e){if(e instanceof $&&e.code===Q.UrlElicitationRequired)throw e;return this.createToolError(e instanceof Error?e.message:String(e))}}),!0)}createToolError(e){return{content:[{type:`text`,text:e}],isError:!0}}async validateToolInput(e,t,n){if(!e.inputSchema)return;let r=await Ru(Bu(e.inputSchema)??e.inputSchema,t);if(!r.success){let e=Vu(`error`in r?r.error:`Unknown error`);throw new $(Q.InvalidParams,`Input validation error: Invalid arguments for tool ${n}: ${e}`)}return r.data}async validateToolOutput(e,t,n){if(!e.outputSchema||!(`content`in t)||t.isError)return;if(!t.structuredContent)throw new $(Q.InvalidParams,`Output validation error: Tool ${n} has an output schema but no structured content was provided`);let r=await Ru(Bu(e.outputSchema),t.structuredContent);if(!r.success){let e=Vu(`error`in r?r.error:`Unknown error`);throw new $(Q.InvalidParams,`Output validation error: Invalid structured content for tool ${n}: ${e}`)}}async executeToolHandler(e,t,n){let r=e.handler;if(`createTask`in r){if(!n.taskStore)throw Error(`No task store provided.`);let i={...n,taskStore:n.taskStore};if(e.inputSchema){let e=r;return await Promise.resolve(e.createTask(t,i))}else{let e=r;return await Promise.resolve(e.createTask(i))}}if(e.inputSchema){let e=r;return await Promise.resolve(e(t,n))}else{let e=r;return await Promise.resolve(e(n))}}async handleAutomaticTaskPolling(e,t,n){if(!n.taskStore)throw Error(`No task store provided for task-capable tool.`);let r=await this.validateToolInput(e,t.params.arguments,t.params.name),i=e.handler,a={...n,taskStore:n.taskStore},o=r?await Promise.resolve(i.createTask(r,a)):await Promise.resolve(i.createTask(a)),s=o.task.taskId,c=o.task,l=c.pollInterval??5e3;for(;c.status!==`completed`&&c.status!==`failed`&&c.status!==`cancelled`;){await new Promise(e=>setTimeout(e,l));let e=await n.taskStore.getTask(s);if(!e)throw new $(Q.InternalError,`Task ${s} not found during polling`);c=e}return await n.taskStore.getTaskResult(s)}setCompletionRequestHandler(){this._completionHandlerInitialized||=(this.server.assertCanSetRequestHandler(nm(gp)),this.server.registerCapabilities({completions:{}}),this.server.setRequestHandler(gp,async e=>{switch(e.params.ref.type){case`ref/prompt`:return _p(e),this.handlePromptCompletion(e,e.params.ref);case`ref/resource`:return vp(e),this.handleResourceCompletion(e,e.params.ref);default:throw new $(Q.InvalidParams,`Invalid completion reference: ${e.params.ref}`)}}),!0)}async handlePromptCompletion(e,t){let n=this._registeredPrompts[t.name];if(!n)throw new $(Q.InvalidParams,`Prompt ${t.name} not found`);if(!n.enabled)throw new $(Q.InvalidParams,`Prompt ${t.name} disabled`);if(!n.argsSchema)return im;let r=zu(n.argsSchema)?.[e.params.argument.name];if(!Vp(r))return im;let i=Hp(r);return i?rm(await i(e.params.argument.value,e.params.context)):im}async handleResourceCompletion(e,t){let n=Object.values(this._registeredResourceTemplates).find(e=>e.resourceTemplate.uriTemplate.toString()===t.uri);if(!n){if(this._registeredResources[t.uri])return im;throw new $(Q.InvalidParams,`Resource template ${e.params.ref.uri} not found`)}let r=n.resourceTemplate.completeCallback(e.params.argument.name);return r?rm(await r(e.params.argument.value,e.params.context)):im}setResourceRequestHandlers(){this._resourceHandlersInitialized||=(this.server.assertCanSetRequestHandler(nm(tf)),this.server.assertCanSetRequestHandler(nm(rf)),this.server.assertCanSetRequestHandler(nm(cf)),this.server.registerCapabilities({resources:{listChanged:!0}}),this.server.setRequestHandler(tf,async(e,t)=>{let n=Object.entries(this._registeredResources).filter(([e,t])=>t.enabled).map(([e,t])=>({uri:e,name:t.name,...t.metadata})),r=[];for(let e of Object.values(this._registeredResourceTemplates)){if(!e.resourceTemplate.listCallback)continue;let n=await e.resourceTemplate.listCallback(t);for(let t of n.resources)r.push({...e.metadata,...t})}return{resources:[...n,...r]}}),this.server.setRequestHandler(rf,async()=>({resourceTemplates:Object.entries(this._registeredResourceTemplates).map(([e,t])=>({name:e,uriTemplate:t.resourceTemplate.uriTemplate.toString(),...t.metadata}))})),this.server.setRequestHandler(cf,async(e,t)=>{let n=new URL(e.params.uri),r=this._registeredResources[n.toString()];if(r){if(!r.enabled)throw new $(Q.InvalidParams,`Resource ${n} disabled`);return r.readCallback(n,t)}for(let e of Object.values(this._registeredResourceTemplates)){let r=e.resourceTemplate.uriTemplate.match(n.toString());if(r)return e.readCallback(n,r,t)}throw new $(Q.InvalidParams,`Resource ${n} not found`)}),!0)}setPromptRequestHandlers(){this._promptHandlersInitialized||=(this.server.assertCanSetRequestHandler(nm(yf)),this.server.assertCanSetRequestHandler(nm(Sf)),this.server.registerCapabilities({prompts:{listChanged:!0}}),this.server.setRequestHandler(yf,()=>({prompts:Object.entries(this._registeredPrompts).filter(([,e])=>e.enabled).map(([e,t])=>({name:e,title:t.title,description:t.description,arguments:t.argsSchema?tm(t.argsSchema):void 0}))})),this.server.setRequestHandler(Sf,async(e,t)=>{let n=this._registeredPrompts[e.params.name];if(!n)throw new $(Q.InvalidParams,`Prompt ${e.params.name} not found`);if(!n.enabled)throw new $(Q.InvalidParams,`Prompt ${e.params.name} disabled`);if(n.argsSchema){let r=await Ru(Bu(n.argsSchema),e.params.arguments);if(!r.success){let t=Vu(`error`in r?r.error:`Unknown error`);throw new $(Q.InvalidParams,`Invalid arguments for prompt ${e.params.name}: ${t}`)}let i=r.data,a=n.callback;return await Promise.resolve(a(i,t))}else{let e=n.callback;return await Promise.resolve(e(t))}}),!0)}resource(e,t,...n){let r;typeof n[0]==`object`&&(r=n.shift());let i=n[0];if(typeof t==`string`){if(this._registeredResources[t])throw Error(`Resource ${t} is already registered`);let n=this._createRegisteredResource(e,void 0,t,r,i);return this.setResourceRequestHandlers(),this.sendResourceListChanged(),n}else{if(this._registeredResourceTemplates[e])throw Error(`Resource template ${e} is already registered`);let n=this._createRegisteredResourceTemplate(e,void 0,t,r,i);return this.setResourceRequestHandlers(),this.sendResourceListChanged(),n}}registerResource(e,t,n,r){if(typeof t==`string`){if(this._registeredResources[t])throw Error(`Resource ${t} is already registered`);let i=this._createRegisteredResource(e,n.title,t,n,r);return this.setResourceRequestHandlers(),this.sendResourceListChanged(),i}else{if(this._registeredResourceTemplates[e])throw Error(`Resource template ${e} is already registered`);let i=this._createRegisteredResourceTemplate(e,n.title,t,n,r);return this.setResourceRequestHandlers(),this.sendResourceListChanged(),i}}_createRegisteredResource(e,t,n,r,i){let a={name:e,title:t,metadata:r,readCallback:i,enabled:!0,disable:()=>a.update({enabled:!1}),enable:()=>a.update({enabled:!0}),remove:()=>a.update({uri:null}),update:e=>{e.uri!==void 0&&e.uri!==n&&(delete this._registeredResources[n],e.uri&&(this._registeredResources[e.uri]=a)),e.name!==void 0&&(a.name=e.name),e.title!==void 0&&(a.title=e.title),e.metadata!==void 0&&(a.metadata=e.metadata),e.callback!==void 0&&(a.readCallback=e.callback),e.enabled!==void 0&&(a.enabled=e.enabled),this.sendResourceListChanged()}};return this._registeredResources[n]=a,a}_createRegisteredResourceTemplate(e,t,n,r,i){let a={resourceTemplate:n,title:t,metadata:r,readCallback:i,enabled:!0,disable:()=>a.update({enabled:!1}),enable:()=>a.update({enabled:!0}),remove:()=>a.update({name:null}),update:t=>{t.name!==void 0&&t.name!==e&&(delete this._registeredResourceTemplates[e],t.name&&(this._registeredResourceTemplates[t.name]=a)),t.title!==void 0&&(a.title=t.title),t.template!==void 0&&(a.resourceTemplate=t.template),t.metadata!==void 0&&(a.metadata=t.metadata),t.callback!==void 0&&(a.readCallback=t.callback),t.enabled!==void 0&&(a.enabled=t.enabled),this.sendResourceListChanged()}};this._registeredResourceTemplates[e]=a;let o=n.uriTemplate.variableNames;return Array.isArray(o)&&o.some(e=>!!n.completeCallback(e))&&this.setCompletionRequestHandler(),a}_createRegisteredPrompt(e,t,n,r,i){let a={title:t,description:n,argsSchema:r===void 0?void 0:Iu(r),callback:i,enabled:!0,disable:()=>a.update({enabled:!1}),enable:()=>a.update({enabled:!0}),remove:()=>a.update({name:null}),update:t=>{t.name!==void 0&&t.name!==e&&(delete this._registeredPrompts[e],t.name&&(this._registeredPrompts[t.name]=a)),t.title!==void 0&&(a.title=t.title),t.description!==void 0&&(a.description=t.description),t.argsSchema!==void 0&&(a.argsSchema=Iu(t.argsSchema)),t.callback!==void 0&&(a.callback=t.callback),t.enabled!==void 0&&(a.enabled=t.enabled),this.sendPromptListChanged()}};return this._registeredPrompts[e]=a,r&&Object.values(r).some(e=>Vp(e instanceof ml?e._def?.innerType:e))&&this.setCompletionRequestHandler(),a}_createRegisteredTool(e,t,n,r,i,a,o,s,c){qp(e);let l={title:t,description:n,inputSchema:em(r),outputSchema:em(i),annotations:a,execution:o,_meta:s,handler:c,enabled:!0,disable:()=>l.update({enabled:!1}),enable:()=>l.update({enabled:!0}),remove:()=>l.update({name:null}),update:t=>{t.name!==void 0&&t.name!==e&&(typeof t.name==`string`&&qp(t.name),delete this._registeredTools[e],t.name&&(this._registeredTools[t.name]=l)),t.title!==void 0&&(l.title=t.title),t.description!==void 0&&(l.description=t.description),t.paramsSchema!==void 0&&(l.inputSchema=Iu(t.paramsSchema)),t.outputSchema!==void 0&&(l.outputSchema=Iu(t.outputSchema)),t.callback!==void 0&&(l.handler=t.callback),t.annotations!==void 0&&(l.annotations=t.annotations),t._meta!==void 0&&(l._meta=t._meta),t.enabled!==void 0&&(l.enabled=t.enabled),this.sendToolListChanged()}};return this._registeredTools[e]=l,this.setToolRequestHandlers(),this.sendToolListChanged(),l}tool(e,...t){if(this._registeredTools[e])throw Error(`Tool ${e} is already registered`);let n,r,i;if(typeof t[0]==`string`&&(n=t.shift()),t.length>1){let e=t[0];$p(e)?(r=t.shift(),t.length>1&&typeof t[0]==`object`&&t[0]!==null&&!$p(t[0])&&(i=t.shift())):typeof e==`object`&&e&&(i=t.shift())}let a=t[0];return this._createRegisteredTool(e,void 0,n,r,void 0,i,{taskSupport:`forbidden`},void 0,a)}registerTool(e,t,n){if(this._registeredTools[e])throw Error(`Tool ${e} is already registered`);let{title:r,description:i,inputSchema:a,outputSchema:o,annotations:s,_meta:c}=t;return this._createRegisteredTool(e,r,i,a,o,s,{taskSupport:`forbidden`},c,n)}prompt(e,...t){if(this._registeredPrompts[e])throw Error(`Prompt ${e} is already registered`);let n;typeof t[0]==`string`&&(n=t.shift());let r;t.length>1&&(r=t.shift());let i=t[0],a=this._createRegisteredPrompt(e,void 0,n,r,i);return this.setPromptRequestHandlers(),this.sendPromptListChanged(),a}registerPrompt(e,t,n){if(this._registeredPrompts[e])throw Error(`Prompt ${e} is already registered`);let{title:r,description:i,argsSchema:a}=t,o=this._createRegisteredPrompt(e,r,i,a,n);return this.setPromptRequestHandlers(),this.sendPromptListChanged(),o}isConnected(){return this.server.transport!==void 0}async sendLoggingMessage(e,t){return this.server.sendLoggingMessage(e,t)}sendResourceListChanged(){this.isConnected()&&this.server.sendResourceListChanged()}sendToolListChanged(){this.isConnected()&&this.server.sendToolListChanged()}sendPromptListChanged(){this.isConnected()&&this.server.sendPromptListChanged()}};let Xp={type:`object`,properties:{}};function Zp(e){return typeof e==`object`&&!!e&&`parse`in e&&typeof e.parse==`function`&&`safeParse`in e&&typeof e.safeParse==`function`}function Qp(e){return`_def`in e||`_zod`in e||Zp(e)}function $p(e){return typeof e!=`object`||!e||Qp(e)?!1:Object.keys(e).length===0?!0:Object.values(e).some(Zp)}function em(e){if(e)return $p(e)?Iu(e):e}function tm(e){let t=zu(e);return t?Object.entries(t).map(([e,t])=>({name:e,description:Hu(t),required:!Uu(t)})):[]}function nm(e){let t=zu(e)?.method;if(!t)throw Error(`Schema is missing a method literal`);let n=Wu(t);if(typeof n==`string`)return n;throw Error(`Schema method literal must be a string`)}function rm(e){return{completion:{values:e.slice(0,100),total:e.length,hasMore:e.length>100}}}let im={completion:{values:[],hasMore:!1}};var am=class{getValidator(e){return t=>{if(!g(t))return{valid:!1,data:void 0,errorMessage:`expected object arguments`};let n=Ye(t,e);return n?{valid:!1,data:void 0,errorMessage:n.message}:{valid:!0,data:t,errorMessage:void 0}}}};let om={type:`object`,properties:{}},sm=`__isBrowserMcpServer`;function cm(e){return!!e&&typeof e==`object`&&!Array.isArray(e)}function lm(e){return cm(e)&&Array.isArray(e.content)}function um(e){return e===null||typeof e==`string`||typeof e==`number`||typeof e==`boolean`}function dm(e){return um(e)?Number.isFinite(e)||typeof e!=`number`:Array.isArray(e)?e.every(e=>dm(e)):cm(e)?Object.values(e).every(e=>dm(e)):!1}function fm(e){if(!(!cm(e)||!dm(e)))return e}function pm(e){if(typeof e==`string`)return e;try{return JSON.stringify(e)??String(e)}catch{return String(e)}}function mm(e){if(lm(e))return e;let t=fm(e);return{content:[{type:`text`,text:pm(e)}],...t?{structuredContent:t}:{},isError:!1}}function hm(e){return e?.signal?e:{...e,signal:AbortSignal.timeout(1e4)}}var gm=class extends Yp{[sm]=!0;native;_promptSchemas=new Map;_jsonValidator;_publicMethodsBound=!1;constructor(e,t){let n=new am,r={capabilities:Mp(t?.capabilities||{},{tools:{listChanged:!0},resources:{listChanged:!0},prompts:{listChanged:!0}}),jsonSchemaValidator:t?.jsonSchemaValidator??n};super(e,r),this._jsonValidator=n,this.native=t?.native,this.bindPublicApiMethods()}bindPublicApiMethods(){this._publicMethodsBound||=(this.registerTool=this.registerTool.bind(this),this.unregisterTool=this.unregisterTool.bind(this),this.provideContext=this.provideContext.bind(this),this.clearContext=this.clearContext.bind(this),this.listTools=this.listTools.bind(this),this.callTool=this.callTool.bind(this),this.executeTool=this.executeTool.bind(this),this.registerResource=this.registerResource.bind(this),this.listResources=this.listResources.bind(this),this.readResource=this.readResource.bind(this),this.registerPrompt=this.registerPrompt.bind(this),this.listPrompts=this.listPrompts.bind(this),this.getPrompt=this.getPrompt.bind(this),this.createMessage=this.createMessage.bind(this),this.elicitInput=this.elicitInput.bind(this),!0)}get _parentTools(){return this._registeredTools}get _parentResources(){return this._registeredResources}get _parentPrompts(){return this._registeredPrompts}toTransportSchema(e,t=!0){if(!e||typeof e!=`object`)return t?(console.warn(`[BrowserMcpServer] toTransportSchema received non-object schema (${typeof e}), using default`),om):{};let n=Bu(e),r=n?Dp(n,{strictUnions:!0,pipeStrategy:`input`}):e;return Object.keys(r).length===0?t?(console.warn(`[BrowserMcpServer] toTransportSchema received empty {} schema, normalizing to default object schema`),om):r:t&&r.type===void 0?(console.warn(`[BrowserMcpServer] toTransportSchema received schema without root type, prepending type:"object"`),{type:`object`,...r}):r}isZodSchema(e){if(!e||typeof e!=`object`)return!1;let t=e;return`_zod`in t||`_def`in t}getNativeToolsApi(){if(!this.native)return;let e=this.native;if(!(typeof e.listTools!=`function`||typeof e.callTool!=`function`))return e}registerToolInServer(e){let t=this.toTransportSchema(e.inputSchema);return super.registerTool(e.name,{description:e.description,inputSchema:t,...e.outputSchema?{outputSchema:e.outputSchema}:{},...e.annotations?{annotations:e.annotations}:{}},async t=>mm(await e.execute(t,{requestUserInteraction:async e=>e()}))),{unregister:()=>this.unregisterTool(e.name)}}backfillTools(e,t){let n=0;for(let r of e){if(!r?.name||this._parentTools[r.name])continue;let e={name:r.name,description:r.description??``,inputSchema:r.inputSchema??om,execute:async e=>t(r.name,e)};r.outputSchema&&(e.outputSchema=r.outputSchema),r.annotations&&(e.annotations=r.annotations),this.registerToolInServer(e),n++}return n}registerTool(e){this.native&&this.native.registerTool(e);try{return this.registerToolInServer(e)}catch(t){if(this.native)try{this.native.unregisterTool(e.name)}catch(e){console.error(`[BrowserMcpServer] Rollback of native tool registration failed:`,e)}throw t}}syncNativeTools(){let e=this.getNativeToolsApi();if(!e)return 0;let t=e.callTool.bind(e);return this.backfillTools(e.listTools(),async(e,n)=>t({name:e,arguments:n}))}unregisterTool(e){this._parentTools[e]?.remove(),this.native&&this.native.unregisterTool(e)}registerResource(e){let t=super.registerResource(e.name,e.uri,{...e.description!==void 0&&{description:e.description},...e.mimeType!==void 0&&{mimeType:e.mimeType}},async t=>({contents:(await e.read(t)).contents}));return{unregister:()=>t.remove()}}registerPrompt(e){e.argsSchema&&this._promptSchemas.set(e.name,e.argsSchema);let t=super.registerPrompt(e.name,{...e.description!==void 0&&{description:e.description}},async t=>({messages:(await e.get(t)).messages}));return{unregister:()=>{this._promptSchemas.delete(e.name),t.remove()}}}provideContext(e){for(let e of Object.values(this._parentTools))e.remove();this.native&&this.native.clearContext();for(let t of e?.tools??[])this.registerTool(t)}clearContext(){for(let e of Object.values(this._parentTools))e.remove();this.native&&this.native.clearContext()}listResources(){return Object.entries(this._parentResources).filter(([,e])=>e.enabled).map(([e,t])=>({uri:e,name:t.name,...t.metadata}))}async readResource(e){let t=this._parentResources[e];if(!t)throw Error(`Resource not found: ${e}`);return t.readCallback(new URL(e),{})}listPrompts(){return Object.entries(this._parentPrompts).filter(([,e])=>e.enabled).map(([e,t])=>{let n=this._promptSchemas.get(e);return{name:e,...t.description!==void 0&&{description:t.description},...n?.properties?{arguments:Object.entries(n.properties).map(([e,t])=>({name:e,...typeof t==`object`&&t&&`description`in t?{description:t.description}:{},...n.required?.includes(e)?{required:!0}:{}}))}:{}}})}async getPrompt(e,t={}){let n=this._parentPrompts[e];if(!n)throw Error(`Prompt not found: ${e}`);let r=this._promptSchemas.get(e);if(r){let n=this._jsonValidator.getValidator(r)(t);if(!n.valid)throw Error(`Invalid arguments for prompt ${e}: ${n.errorMessage}`)}return n.callback(t,{})}listTools(){return Object.entries(this._parentTools).filter(([,e])=>e.enabled).map(([e,t])=>{let n={name:e,description:t.description??``,inputSchema:this.toTransportSchema(t.inputSchema??om)};return t.outputSchema&&(n.outputSchema=this.toTransportSchema(t.outputSchema,!1)),t.annotations&&(n.annotations=t.annotations),n})}async validateToolInput(e,t,n){if(!e.inputSchema)return;if(this.isZodSchema(e.inputSchema)){let r=await Ru(e.inputSchema,t??{});if(!r.success)throw Error(`Invalid arguments for tool ${n}: ${Vu(r.error)}`);return r.data}let r=this._jsonValidator.getValidator(e.inputSchema)(t??{});if(!r.valid)throw Error(`Invalid arguments for tool ${n}: ${r.errorMessage}`);return r.data}async validateToolOutput(e,t,n){if(!e.outputSchema)return;let r=t;if(!(`content`in r)||r.isError||!r.structuredContent)return;if(this.isZodSchema(e.outputSchema)){let t=await Ru(e.outputSchema,r.structuredContent);if(!t.success)throw Error(`Output validation error: Invalid structured content for tool ${n}: ${Vu(t.error)}`);return}let i=this._jsonValidator.getValidator(e.outputSchema)(r.structuredContent);if(!i.valid)throw Error(`Output validation error: Invalid structured content for tool ${n}: ${i.errorMessage}`)}async callTool(e){let t=this._parentTools[e.name];if(!t)throw Error(`Tool not found: ${e.name}`);return t.handler(e.arguments??{},{})}async executeTool(e,t={}){return this.callTool({name:e,arguments:t})}async connect(e){return this.setToolRequestHandlers(),this.setResourceRequestHandlers(),this.setPromptRequestHandlers(),this.server.setRequestHandler(Ff,()=>({tools:this.listTools()})),this.server.setRequestHandler(yf,()=>({prompts:this.listPrompts()})),this.server.setRequestHandler(Sf,async e=>{let t=this._parentPrompts[e.params.name];if(!t)throw Error(`Prompt ${e.params.name} not found`);if(!t.enabled)throw Error(`Prompt ${e.params.name} disabled`);let n=this._promptSchemas.get(e.params.name);if(n){let r=this._jsonValidator.getValidator(n)(e.params.arguments??{});if(!r.valid)throw Error(`Invalid arguments for prompt ${e.params.name}: ${r.errorMessage}`);return t.callback(e.params.arguments,{})}return t.callback({},{})}),super.connect(e)}async createMessage(e,t){return this.server.createMessage(e,hm(t))}async elicitInput(e,t){return this.server.elicitInput(e,hm(t))}};let _m=null;function vm(){return typeof window<`u`&&window.navigator!==void 0}function ym(e){try{Object.defineProperty(navigator,`modelContext`,{configurable:!0,enumerable:!0,writable:!1,value:e})}catch{Object.defineProperty(Object.getPrototypeOf(navigator),`modelContext`,{configurable:!0,enumerable:!0,get(){return e}})}navigator.modelContext!==e&&console.error(`[WebModelContext] Failed to replace navigator.modelContext.`,`Descriptor:`,Object.getOwnPropertyDescriptor(navigator,`modelContext`))}function bm(e){if(window.parent!==window&&e?.iframeServer!==!1){let{allowedOrigins:n,...r}=typeof e?.iframeServer==`object`?e.iframeServer:{};return new t.IframeChildTransport({allowedOrigins:n??[`*`],...r})}if(e?.tabServer===!1)throw Error(`tabServer transport is disabled and iframe transport was not selected`);let{allowedOrigins:n,...r}=typeof e?.tabServer==`object`?e.tabServer:{};return new t.TabServerTransport({allowedOrigins:n??[`*`],...r})}function xm(e){if(e)try{let t=JSON.parse(e);return!t||typeof t!=`object`||Array.isArray(t)?void 0:t}catch(e){console.warn(`[WebMCP] Failed to parse testing inputSchema JSON:`,e);return}}function Sm(){let e=navigator.modelContextTesting;if(e){if(typeof e.getRegisteredTools==`function`)return{testingShim:e,tools:e.getRegisteredTools()};if(typeof e.listTools==`function`)return{testingShim:e,tools:e.listTools().map(e=>({name:e.name,description:e.description??``,inputSchema:xm(e.inputSchema)??{type:`object`,properties:{}}}))}}}function Cm(e){let t=Sm();if(!t)return 0;let{testingShim:n,tools:r}=t;return e.backfillTools(r,async(e,t)=>{let r=await n.executeTool(e,JSON.stringify(t??{}));if(r===null)return{content:[{type:`text`,text:`Tool execution interrupted by navigation`}],isError:!0};let i;try{i=JSON.parse(r)}catch(t){throw Error(`Failed to parse serialized tool response for ${e}: ${t instanceof Error?t.message:String(t)}`)}if(!i||typeof i!=`object`||Array.isArray(i))throw Error(`Invalid serialized tool response for ${e}`);return i})}function wm(e){if(!vm()||_m||navigator.modelContext?.[sm])return;ut({installTestingShim:e?.installTestingShim??`if-missing`});let t=navigator.modelContext;if(!t)throw Error(`navigator.modelContext is not available`);let n=new gm({name:`${window.location.hostname||`localhost`}-webmcp`,version:`1.0.0`},{native:t});n.syncNativeTools(),Cm(n),ym(n);let r=bm(e?.transport);_m={native:t,server:n,transport:r},n.connect(r).catch(e=>{console.error(`[WebModelContext] Failed to connect MCP transport:`,e)})}function Tm(){if(!_m)return;let{native:e,server:t,transport:n}=_m;_m=null,t.close(),n.close(),ym(e)}if(typeof window<`u`&&typeof document<`u`){let e=window.__webModelContextOptions;if(e?.autoInitialize!==!1)try{wm(e)}catch(e){console.error(`[WebModelContext] Auto-initialization failed:`,e)}}return e.cleanupWebModelContext=Tm,e.initializeWebModelContext=wm,e})({},__mcp_b_transports);
41
+ ]))`;continue}}if(n.s&&r[e]===`.`){i+=o?`${r[e]}\r\n`:`[${r[e]}\r\n]`;continue}i+=r[e],r[e]===`\\`?a=!0:o&&r[e]===`]`?o=!1:!o&&r[e]===`[`&&(o=!0)}try{new RegExp(i)}catch{return console.warn(`Could not convert regex pattern at ${t.currentPath.join(`/`)} to a flag-independent form! Falling back to the flag-ignorant source`),e.source}return i}function Lc(e,t){if(t.target===`openAi`&&console.warn(`Warning: OpenAI may not support records in schemas! Try an array of key-value pairs instead.`),t.target===`openApi3`&&e.keyType?._def.typeName===b.ZodEnum)return{type:`object`,required:e.keyType._def.values,properties:e.keyType._def.values.reduce((n,r)=>({...n,[r]:K(e.valueType._def,{...t,currentPath:[...t.currentPath,`properties`,r]})??W(t)}),{}),additionalProperties:t.rejectedAdditionalProperties};let n={type:`object`,additionalProperties:K(e.valueType._def,{...t,currentPath:[...t.currentPath,`additionalProperties`]})??t.allowedAdditionalProperties};if(t.target===`openApi3`)return n;if(e.keyType?._def.typeName===b.ZodString&&e.keyType._def.checks?.length){let{type:r,...i}=jc(e.keyType._def,t);return{...n,propertyNames:i}}else if(e.keyType?._def.typeName===b.ZodEnum)return{...n,propertyNames:{enum:e.keyType._def.values}};else if(e.keyType?._def.typeName===b.ZodBranded&&e.keyType._def.type._def.typeName===b.ZodString&&e.keyType._def.type._def.checks?.length){let{type:r,...i}=yc(e.keyType._def,t);return{...n,propertyNames:i}}return n}function Rc(e,t){return t.mapStrategy===`record`?Lc(e,t):{type:`array`,maxItems:125,items:{type:`array`,items:[K(e.keyType._def,{...t,currentPath:[...t.currentPath,`items`,`items`,`0`]})||W(t),K(e.valueType._def,{...t,currentPath:[...t.currentPath,`items`,`items`,`1`]})||W(t)],minItems:2,maxItems:2}}}function zc(e){let t=e.values,n=Object.keys(e.values).filter(e=>typeof t[t[e]]!=`number`).map(e=>t[e]),r=Array.from(new Set(n.map(e=>typeof e)));return{type:r.length===1?r[0]===`string`?`string`:`number`:[`string`,`number`],enum:n}}function Bc(e){return e.target===`openAi`?void 0:{not:W({...e,currentPath:[...e.currentPath,`not`]})}}function Vc(e){return e.target===`openApi3`?{enum:[`null`],nullable:!0}:{type:`null`}}let Hc={ZodString:`string`,ZodNumber:`number`,ZodBigInt:`integer`,ZodBoolean:`boolean`,ZodNull:`null`};function Uc(e,t){if(t.target===`openApi3`)return Wc(e,t);let n=e.options instanceof Map?Array.from(e.options.values()):e.options;if(n.every(e=>e._def.typeName in Hc&&(!e._def.checks||!e._def.checks.length))){let e=n.reduce((e,t)=>{let n=Hc[t._def.typeName];return n&&!e.includes(n)?[...e,n]:e},[]);return{type:e.length>1?e:e[0]}}else if(n.every(e=>e._def.typeName===`ZodLiteral`&&!e.description)){let e=n.reduce((e,t)=>{let n=typeof t._def.value;switch(n){case`string`:case`number`:case`boolean`:return[...e,n];case`bigint`:return[...e,`integer`];case`object`:if(t._def.value===null)return[...e,`null`];case`symbol`:case`undefined`:case`function`:default:return e}},[]);if(e.length===n.length){let t=e.filter((e,t,n)=>n.indexOf(e)===t);return{type:t.length>1?t:t[0],enum:n.reduce((e,t)=>e.includes(t._def.value)?e:[...e,t._def.value],[])}}}else if(n.every(e=>e._def.typeName===`ZodEnum`))return{type:`string`,enum:n.reduce((e,t)=>[...e,...t._def.values.filter(t=>!e.includes(t))],[])};return Wc(e,t)}let Wc=(e,t)=>{let n=(e.options instanceof Map?Array.from(e.options.values()):e.options).map((e,n)=>K(e._def,{...t,currentPath:[...t.currentPath,`anyOf`,`${n}`]})).filter(e=>!!e&&(!t.strictUnions||typeof e==`object`&&Object.keys(e).length>0));return n.length?{anyOf:n}:void 0};function Gc(e,t){if([`ZodString`,`ZodNumber`,`ZodBigInt`,`ZodBoolean`,`ZodNull`].includes(e.innerType._def.typeName)&&(!e.innerType._def.checks||!e.innerType._def.checks.length))return t.target===`openApi3`?{type:Hc[e.innerType._def.typeName],nullable:!0}:{type:[Hc[e.innerType._def.typeName],`null`]};if(t.target===`openApi3`){let n=K(e.innerType._def,{...t,currentPath:[...t.currentPath]});return n&&`$ref`in n?{allOf:[n],nullable:!0}:n&&{...n,nullable:!0}}let n=K(e.innerType._def,{...t,currentPath:[...t.currentPath,`anyOf`,`0`]});return n&&{anyOf:[n,{type:`null`}]}}function Kc(e,t){let n={type:`number`};if(!e.checks)return n;for(let r of e.checks)switch(r.kind){case`int`:n.type=`integer`,mc(n,`type`,r.message,t);break;case`min`:t.target===`jsonSchema7`?r.inclusive?U(n,`minimum`,r.value,r.message,t):U(n,`exclusiveMinimum`,r.value,r.message,t):(r.inclusive||(n.exclusiveMinimum=!0),U(n,`minimum`,r.value,r.message,t));break;case`max`:t.target===`jsonSchema7`?r.inclusive?U(n,`maximum`,r.value,r.message,t):U(n,`exclusiveMaximum`,r.value,r.message,t):(r.inclusive||(n.exclusiveMaximum=!0),U(n,`maximum`,r.value,r.message,t));break;case`multipleOf`:U(n,`multipleOf`,r.value,r.message,t);break}return n}function qc(e,t){let n=t.target===`openAi`,r={type:`object`,properties:{}},i=[],a=e.shape();for(let e in a){let o=a[e];if(o===void 0||o._def===void 0)continue;let s=Yc(o);s&&n&&(o._def.typeName===`ZodOptional`&&(o=o._def.innerType),o.isNullable()||(o=o.nullable()),s=!1);let c=K(o._def,{...t,currentPath:[...t.currentPath,`properties`,e],propertyPath:[...t.currentPath,`properties`,e]});c!==void 0&&(r.properties[e]=c,s||i.push(e))}i.length&&(r.required=i);let o=Jc(e,t);return o!==void 0&&(r.additionalProperties=o),r}function Jc(e,t){if(e.catchall._def.typeName!==`ZodNever`)return K(e.catchall._def,{...t,currentPath:[...t.currentPath,`additionalProperties`]});switch(e.unknownKeys){case`passthrough`:return t.allowedAdditionalProperties;case`strict`:return t.rejectedAdditionalProperties;case`strip`:return t.removeAdditionalStrategy===`strict`?t.allowedAdditionalProperties:t.rejectedAdditionalProperties}}function Yc(e){try{return e.isOptional()}catch{return!0}}let Xc=(e,t)=>{if(t.currentPath.toString()===t.propertyPath?.toString())return K(e.innerType._def,t);let n=K(e.innerType._def,{...t,currentPath:[...t.currentPath,`anyOf`,`1`]});return n?{anyOf:[{not:W(t)},n]}:W(t)},Zc=(e,t)=>{if(t.pipeStrategy===`input`)return K(e.in._def,t);if(t.pipeStrategy===`output`)return K(e.out._def,t);let n=K(e.in._def,{...t,currentPath:[...t.currentPath,`allOf`,`0`]});return{allOf:[n,K(e.out._def,{...t,currentPath:[...t.currentPath,`allOf`,n?`1`:`0`]})].filter(e=>e!==void 0)}};function Qc(e,t){return K(e.type._def,t)}function $c(e,t){let n={type:`array`,uniqueItems:!0,items:K(e.valueType._def,{...t,currentPath:[...t.currentPath,`items`]})};return e.minSize&&U(n,`minItems`,e.minSize.value,e.minSize.message,t),e.maxSize&&U(n,`maxItems`,e.maxSize.value,e.maxSize.message,t),n}function el(e,t){return e.rest?{type:`array`,minItems:e.items.length,items:e.items.map((e,n)=>K(e._def,{...t,currentPath:[...t.currentPath,`items`,`${n}`]})).reduce((e,t)=>t===void 0?e:[...e,t],[]),additionalItems:K(e.rest._def,{...t,currentPath:[...t.currentPath,`additionalItems`]})}:{type:`array`,minItems:e.items.length,maxItems:e.items.length,items:e.items.map((e,n)=>K(e._def,{...t,currentPath:[...t.currentPath,`items`,`${n}`]})).reduce((e,t)=>t===void 0?e:[...e,t],[])}}function tl(e){return{not:W(e)}}function nl(e){return W(e)}let rl=(e,t)=>K(e.innerType._def,t),il=(e,t,n)=>{switch(t){case b.ZodString:return jc(e,n);case b.ZodNumber:return Kc(e,n);case b.ZodObject:return qc(e,n);case b.ZodBigInt:return _c(e,n);case b.ZodBoolean:return vc();case b.ZodDate:return xc(e,n);case b.ZodUndefined:return tl(n);case b.ZodNull:return Vc(n);case b.ZodArray:return gc(e,n);case b.ZodUnion:case b.ZodDiscriminatedUnion:return Uc(e,n);case b.ZodIntersection:return Dc(e,n);case b.ZodTuple:return el(e,n);case b.ZodRecord:return Lc(e,n);case b.ZodLiteral:return Oc(e,n);case b.ZodEnum:return Tc(e);case b.ZodNativeEnum:return zc(e);case b.ZodNullable:return Gc(e,n);case b.ZodOptional:return Xc(e,n);case b.ZodMap:return Rc(e,n);case b.ZodSet:return $c(e,n);case b.ZodLazy:return()=>e.getter()._def;case b.ZodPromise:return Qc(e,n);case b.ZodNaN:case b.ZodNever:return Bc(n);case b.ZodEffects:return wc(e,n);case b.ZodAny:return W(n);case b.ZodUnknown:return nl(n);case b.ZodDefault:return Cc(e,n);case b.ZodBranded:return yc(e,n);case b.ZodReadonly:return rl(e,n);case b.ZodCatch:return bc(e,n);case b.ZodPipeline:return Zc(e,n);case b.ZodFunction:case b.ZodVoid:case b.ZodSymbol:return;default:return(e=>void 0)(t)}};function K(e,t,n=!1){let r=t.seen.get(e);if(t.override){let i=t.override?.(e,t,r,n);if(i!==uc)return i}if(r&&!n){let e=al(r,t);if(e!==void 0)return e}let i={def:e,path:t.currentPath,jsonSchema:void 0};t.seen.set(e,i);let a=il(e,e.typeName,t),o=typeof a==`function`?K(a(),t):a;if(o&&ol(e,t,o),t.postProcess){let n=t.postProcess(o,e,t);return i.jsonSchema=o,n}return i.jsonSchema=o,o}let al=(e,t)=>{switch(t.$refStrategy){case`root`:return{$ref:e.path.join(`/`)};case`relative`:return{$ref:hc(t.currentPath,e.path)};case`none`:case`seen`:return e.path.length<t.currentPath.length&&e.path.every((e,n)=>t.currentPath[n]===e)?(console.warn(`Recursive reference detected at ${t.currentPath.join(`/`)}! Defaulting to any`),W(t)):t.$refStrategy===`seen`?W(t):void 0}},ol=(e,t,n)=>(e.description&&(n.description=e.description,t.markdownDescription&&(n.markdownDescription=e.description)),n),sl=(e,t)=>{let n=pc(t),r=typeof t==`object`&&t.definitions?Object.entries(t.definitions).reduce((e,[t,r])=>({...e,[t]:K(r._def,{...n,currentPath:[...n.basePath,n.definitionPath,t]},!0)??W(n)}),{}):void 0,i=typeof t==`string`?t:t?.nameStrategy===`title`?void 0:t?.name,a=K(e._def,i===void 0?n:{...n,currentPath:[...n.basePath,n.definitionPath,i]},!1)??W(n),o=typeof t==`object`&&t.name!==void 0&&t.nameStrategy===`title`?t.name:void 0;o!==void 0&&(a.title=o),n.flags.hasReferencedOpenAiAnyType&&(r||={},r[n.openAiAnyTypeName]||(r[n.openAiAnyTypeName]={type:[`string`,`number`,`integer`,`boolean`,`array`,`null`],items:{$ref:n.$refStrategy===`relative`?`1`:[...n.basePath,n.definitionPath,n.openAiAnyTypeName].join(`/`)}}));let s=i===void 0?r?{...a,[n.definitionPath]:r}:a:{$ref:[...n.$refStrategy===`relative`?[]:n.basePath,n.definitionPath,i].join(`/`),[n.definitionPath]:{...r,[i]:a}};return n.target===`jsonSchema7`?s.$schema=`http://json-schema.org/draft-07/schema#`:(n.target===`jsonSchema2019-09`||n.target===`openAi`)&&(s.$schema=`https://json-schema.org/draft/2019-09/schema#`),n.target===`openAi`&&(`anyOf`in s||`oneOf`in s||`allOf`in s||`type`in s&&Array.isArray(s.type))&&console.warn(`Warning: OpenAI may not support schemas with unions as roots! Try wrapping it in an object property.`),s};function cl(e,t){let n=typeof e;if(n!==typeof t)return!1;if(Array.isArray(e)){if(!Array.isArray(t))return!1;let n=e.length;if(n!==t.length)return!1;for(let r=0;r<n;r++)if(!cl(e[r],t[r]))return!1;return!0}if(n===`object`){if(!e||!t)return e===t;let n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(let r of n)if(!cl(e[r],t[r]))return!1;return!0}return e===t}function ll(e){return encodeURI(ul(e))}function ul(e){return e.replace(/~/g,`~0`).replace(/\//g,`~1`)}let dl={prefixItems:!0,items:!0,allOf:!0,anyOf:!0,oneOf:!0},fl={$defs:!0,definitions:!0,properties:!0,patternProperties:!0,dependentSchemas:!0},pl={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},ml=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 hl(e,t=Object.create(null),n=ml,r=``){if(e&&typeof e==`object`&&!Array.isArray(e)){let i=e.$id||e.id;if(i){let a=new URL(i,n.href);a.hash.length>1?t[a.href]=e:(a.hash=``,r===``?n=a:hl(e,t,n))}}else if(e!==!0&&e!==!1)return t;let i=n.href+(r?`#`+r:``);if(t[i]!==void 0)throw Error(`Duplicate schema URI "${i}".`);if(t[i]=e,e===!0||e===!1)return t;if(e.__absolute_uri__===void 0&&Object.defineProperty(e,`__absolute_uri__`,{enumerable:!1,value:i}),e.$ref&&e.__absolute_ref__===void 0){let t=new URL(e.$ref,n.href);t.hash=t.hash,Object.defineProperty(e,`__absolute_ref__`,{enumerable:!1,value:t.href})}if(e.$recursiveRef&&e.__absolute_recursive_ref__===void 0){let t=new URL(e.$recursiveRef,n.href);t.hash=t.hash,Object.defineProperty(e,`__absolute_recursive_ref__`,{enumerable:!1,value:t.href})}if(e.$anchor){let r=new URL(`#`+e.$anchor,n.href);t[r.href]=e}for(let i in e){if(pl[i])continue;let a=`${r}/${ll(i)}`,o=e[i];if(Array.isArray(o)){if(dl[i]){let e=o.length;for(let r=0;r<e;r++)hl(o[r],t,n,`${a}/${r}`)}}else if(fl[i])for(let e in o)hl(o[e],t,n,`${a}/${ll(e)}`);else hl(o,t,n,a)}return t}let gl=/^(\d\d\d\d)-(\d\d)-(\d\d)$/,_l=[0,31,28,31,30,31,30,31,31,30,31,30,31],vl=/^(\d\d):(\d\d):(\d\d)(\.\d+)?(z|[+-]\d\d(?::?\d\d)?)?$/i,yl=/^(?=.{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,bl=/^(?:[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,xl=/^(?:(?:[^\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,Sl=/^(?:(?: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,Cl=/^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i,wl=/^(?:\/(?:[^~/]|~0|~1)*)*$/,Tl=/^#(?:\/(?:[a-z0-9_\-.!$&'()*+,;:=@]|%[0-9a-f]{2}|~0|~1)*)*$/i,El=/^(?:0|[1-9][0-9]*)(?:#|(?:\/(?:[^~/]|~0|~1)*)*)$/,Dl=e=>{if(e[0]===`"`)return!1;let[t,n,...r]=e.split(`@`);return!t||!n||r.length!==0||t.length>64||n.length>253||t[0]===`.`||t.endsWith(`.`)||t.includes(`..`)||!/^[a-z0-9.-]+$/i.test(n)||!/^[a-z0-9.!#$%&'*+/=?^_`{|}~-]+$/i.test(t)?!1:n.split(`.`).every(e=>/^[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?$/i.test(e))},Ol=/^(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)$/,kl=/^((([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,Al=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 jl(e){return e.test.bind(e)}let Ml={date:Pl,time:Fl.bind(void 0,!1),"date-time":Ll,duration:Al,uri:Bl,"uri-reference":jl(bl),"uri-template":jl(xl),url:jl(Sl),email:Dl,hostname:jl(yl),ipv4:jl(Ol),ipv6:jl(kl),regex:Hl,uuid:jl(Cl),"json-pointer":jl(wl),"json-pointer-uri-fragment":jl(Tl),"relative-json-pointer":jl(El)};function Nl(e){return e%4==0&&(e%100!=0||e%400==0)}function Pl(e){let t=e.match(gl);if(!t)return!1;let n=+t[1],r=+t[2],i=+t[3];return r>=1&&r<=12&&i>=1&&i<=(r==2&&Nl(n)?29:_l[r])}function Fl(e,t){let n=t.match(vl);if(!n)return!1;let r=+n[1],i=+n[2],a=+n[3],o=!!n[5];return(r<=23&&i<=59&&a<=59||r==23&&i==59&&a==60)&&(!e||o)}let Il=/t|\s/i;function Ll(e){let t=e.split(Il);return t.length==2&&Pl(t[0])&&Fl(!0,t[1])}let Rl=/\/|:/,zl=/^(?:[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 Bl(e){return Rl.test(e)&&zl.test(e)}let Vl=/[^\\]\\Z/;function Hl(e){if(Vl.test(e))return!1;try{return new RegExp(e,`u`),!0}catch{return!1}}function Ul(e){let t=0,n=e.length,r=0,i;for(;r<n;)t++,i=e.charCodeAt(r++),i>=55296&&i<=56319&&r<n&&(i=e.charCodeAt(r),(i&64512)==56320&&r++);return t}function q(e,t,n=`2019-09`,r=hl(t),i=!0,a=null,o=`#`,s=`#`,c=Object.create(null)){if(t===!0)return{valid:!0,errors:[]};if(t===!1)return{valid:!1,errors:[{instanceLocation:o,keyword:`false`,keywordLocation:o,error:`False boolean schema.`}]};let l=typeof e,u;switch(l){case`boolean`:case`number`:case`string`:u=l;break;case`object`:u=e===null?`null`:Array.isArray(e)?`array`:`object`;break;default:throw Error(`Instances of "${l}" type are not supported.`)}let{$ref:d,$recursiveRef:f,$recursiveAnchor:p,type:m,const:h,enum:ee,required:te,not:ne,anyOf:re,allOf:g,oneOf:ie,if:ae,then:_,else:v,format:oe,properties:se,patternProperties:ce,additionalProperties:le,unevaluatedProperties:ue,minProperties:de,maxProperties:fe,propertyNames:pe,dependentRequired:me,dependentSchemas:he,dependencies:ge,prefixItems:_e,items:ve,additionalItems:ye,unevaluatedItems:be,contains:xe,minContains:Se,maxContains:Ce,minItems:we,maxItems:Te,uniqueItems:Ee,minimum:De,maximum:Oe,exclusiveMinimum:ke,exclusiveMaximum:Ae,multipleOf:je,minLength:Me,maxLength:Ne,pattern:Pe,__absolute_ref__:Fe,__absolute_recursive_ref__:Ie}=t,y=[];if(p===!0&&a===null&&(a=t),f===`#`){let l=a===null?r[Ie]:a,u=`${s}/$recursiveRef`,d=q(e,a===null?t:a,n,r,i,l,o,u,c);d.valid||y.push({instanceLocation:o,keyword:`$recursiveRef`,keywordLocation:u,error:`A subschema had errors.`},...d.errors)}if(d!==void 0){let t=r[Fe||d];if(t===void 0){let e=`Unresolved $ref "${d}".`;throw Fe&&Fe!==d&&(e+=` Absolute URI "${Fe}".`),e+=`\nKnown schemas:\n- ${Object.keys(r).join(`
42
+ - `)}`,Error(e)}let l=`${s}/$ref`,u=q(e,t,n,r,i,a,o,l,c);if(u.valid||y.push({instanceLocation:o,keyword:`$ref`,keywordLocation:l,error:`A subschema had errors.`},...u.errors),n===`4`||n===`7`)return{valid:y.length===0,errors:y}}if(Array.isArray(m)){let t=m.length,n=!1;for(let r=0;r<t;r++)if(u===m[r]||m[r]===`integer`&&u===`number`&&e%1==0&&e===e){n=!0;break}n||y.push({instanceLocation:o,keyword:`type`,keywordLocation:`${s}/type`,error:`Instance type "${u}" is invalid. Expected "${m.join(`", "`)}".`})}else m===`integer`?(u!==`number`||e%1||e!==e)&&y.push({instanceLocation:o,keyword:`type`,keywordLocation:`${s}/type`,error:`Instance type "${u}" is invalid. Expected "${m}".`}):m!==void 0&&u!==m&&y.push({instanceLocation:o,keyword:`type`,keywordLocation:`${s}/type`,error:`Instance type "${u}" is invalid. Expected "${m}".`});if(h!==void 0&&(u===`object`||u===`array`?cl(e,h)||y.push({instanceLocation:o,keyword:`const`,keywordLocation:`${s}/const`,error:`Instance does not match ${JSON.stringify(h)}.`}):e!==h&&y.push({instanceLocation:o,keyword:`const`,keywordLocation:`${s}/const`,error:`Instance does not match ${JSON.stringify(h)}.`})),ee!==void 0&&(u===`object`||u===`array`?ee.some(t=>cl(e,t))||y.push({instanceLocation:o,keyword:`enum`,keywordLocation:`${s}/enum`,error:`Instance does not match any of ${JSON.stringify(ee)}.`}):ee.some(t=>e===t)||y.push({instanceLocation:o,keyword:`enum`,keywordLocation:`${s}/enum`,error:`Instance does not match any of ${JSON.stringify(ee)}.`})),ne!==void 0){let t=`${s}/not`;q(e,ne,n,r,i,a,o,t).valid&&y.push({instanceLocation:o,keyword:`not`,keywordLocation:t,error:`Instance matched "not" schema.`})}let Le=[];if(re!==void 0){let t=`${s}/anyOf`,l=y.length,u=!1;for(let s=0;s<re.length;s++){let l=re[s],d=Object.create(c),f=q(e,l,n,r,i,p===!0?a:null,o,`${t}/${s}`,d);y.push(...f.errors),u||=f.valid,f.valid&&Le.push(d)}u?y.length=l:y.splice(l,0,{instanceLocation:o,keyword:`anyOf`,keywordLocation:t,error:`Instance does not match any subschemas.`})}if(g!==void 0){let t=`${s}/allOf`,l=y.length,u=!0;for(let s=0;s<g.length;s++){let l=g[s],d=Object.create(c),f=q(e,l,n,r,i,p===!0?a:null,o,`${t}/${s}`,d);y.push(...f.errors),u&&=f.valid,f.valid&&Le.push(d)}u?y.length=l:y.splice(l,0,{instanceLocation:o,keyword:`allOf`,keywordLocation:t,error:`Instance does not match every subschema.`})}if(ie!==void 0){let t=`${s}/oneOf`,l=y.length,u=ie.filter((s,l)=>{let u=Object.create(c),d=q(e,s,n,r,i,p===!0?a:null,o,`${t}/${l}`,u);return y.push(...d.errors),d.valid&&Le.push(u),d.valid}).length;u===1?y.length=l:y.splice(l,0,{instanceLocation:o,keyword:`oneOf`,keywordLocation:t,error:`Instance does not match exactly one subschema (${u} matches).`})}if((u===`object`||u===`array`)&&Object.assign(c,...Le),ae!==void 0){let t=`${s}/if`;if(q(e,ae,n,r,i,a,o,t,c).valid){if(_!==void 0){let l=q(e,_,n,r,i,a,o,`${s}/then`,c);l.valid||y.push({instanceLocation:o,keyword:`if`,keywordLocation:t,error:`Instance does not match "then" schema.`},...l.errors)}}else if(v!==void 0){let l=q(e,v,n,r,i,a,o,`${s}/else`,c);l.valid||y.push({instanceLocation:o,keyword:`if`,keywordLocation:t,error:`Instance does not match "else" schema.`},...l.errors)}}if(u===`object`){if(te!==void 0)for(let t of te)t in e||y.push({instanceLocation:o,keyword:`required`,keywordLocation:`${s}/required`,error:`Instance does not have required property "${t}".`});let t=Object.keys(e);if(de!==void 0&&t.length<de&&y.push({instanceLocation:o,keyword:`minProperties`,keywordLocation:`${s}/minProperties`,error:`Instance does not have at least ${de} properties.`}),fe!==void 0&&t.length>fe&&y.push({instanceLocation:o,keyword:`maxProperties`,keywordLocation:`${s}/maxProperties`,error:`Instance does not have at least ${fe} properties.`}),pe!==void 0){let t=`${s}/propertyNames`;for(let s in e){let e=`${o}/${ll(s)}`,c=q(s,pe,n,r,i,a,e,t);c.valid||y.push({instanceLocation:o,keyword:`propertyNames`,keywordLocation:t,error:`Property name "${s}" does not match schema.`},...c.errors)}}if(me!==void 0){let t=`${s}/dependantRequired`;for(let n in me)if(n in e){let r=me[n];for(let i of r)i in e||y.push({instanceLocation:o,keyword:`dependentRequired`,keywordLocation:t,error:`Instance has "${n}" but does not have "${i}".`})}}if(he!==void 0)for(let t in he){let l=`${s}/dependentSchemas`;if(t in e){let s=q(e,he[t],n,r,i,a,o,`${l}/${ll(t)}`,c);s.valid||y.push({instanceLocation:o,keyword:`dependentSchemas`,keywordLocation:l,error:`Instance has "${t}" but does not match dependant schema.`},...s.errors)}}if(ge!==void 0){let t=`${s}/dependencies`;for(let s in ge)if(s in e){let c=ge[s];if(Array.isArray(c))for(let n of c)n in e||y.push({instanceLocation:o,keyword:`dependencies`,keywordLocation:t,error:`Instance has "${s}" but does not have "${n}".`});else{let l=q(e,c,n,r,i,a,o,`${t}/${ll(s)}`);l.valid||y.push({instanceLocation:o,keyword:`dependencies`,keywordLocation:t,error:`Instance has "${s}" but does not match dependant schema.`},...l.errors)}}}let l=Object.create(null),u=!1;if(se!==void 0){let t=`${s}/properties`;for(let s in se){if(!(s in e))continue;let d=`${o}/${ll(s)}`,f=q(e[s],se[s],n,r,i,a,d,`${t}/${ll(s)}`);if(f.valid)c[s]=l[s]=!0;else if(u=i,y.push({instanceLocation:o,keyword:`properties`,keywordLocation:t,error:`Property "${s}" does not match schema.`},...f.errors),u)break}}if(!u&&ce!==void 0){let t=`${s}/patternProperties`;for(let s in ce){let d=new RegExp(s,`u`),f=ce[s];for(let p in e){if(!d.test(p))continue;let m=`${o}/${ll(p)}`,h=q(e[p],f,n,r,i,a,m,`${t}/${ll(s)}`);h.valid?c[p]=l[p]=!0:(u=i,y.push({instanceLocation:o,keyword:`patternProperties`,keywordLocation:t,error:`Property "${p}" matches pattern "${s}" but does not match associated schema.`},...h.errors))}}}if(!u&&le!==void 0){let t=`${s}/additionalProperties`;for(let s in e){if(l[s])continue;let d=`${o}/${ll(s)}`,f=q(e[s],le,n,r,i,a,d,t);f.valid?c[s]=!0:(u=i,y.push({instanceLocation:o,keyword:`additionalProperties`,keywordLocation:t,error:`Property "${s}" does not match additional properties schema.`},...f.errors))}}else if(!u&&ue!==void 0){let t=`${s}/unevaluatedProperties`;for(let s in e)if(!c[s]){let l=`${o}/${ll(s)}`,u=q(e[s],ue,n,r,i,a,l,t);u.valid?c[s]=!0:y.push({instanceLocation:o,keyword:`unevaluatedProperties`,keywordLocation:t,error:`Property "${s}" does not match unevaluated properties schema.`},...u.errors)}}}else if(u===`array`){Te!==void 0&&e.length>Te&&y.push({instanceLocation:o,keyword:`maxItems`,keywordLocation:`${s}/maxItems`,error:`Array has too many items (${e.length} > ${Te}).`}),we!==void 0&&e.length<we&&y.push({instanceLocation:o,keyword:`minItems`,keywordLocation:`${s}/minItems`,error:`Array has too few items (${e.length} < ${we}).`});let t=e.length,l=0,u=!1;if(_e!==void 0){let d=`${s}/prefixItems`,f=Math.min(_e.length,t);for(;l<f;l++){let t=q(e[l],_e[l],n,r,i,a,`${o}/${l}`,`${d}/${l}`);if(c[l]=!0,!t.valid&&(u=i,y.push({instanceLocation:o,keyword:`prefixItems`,keywordLocation:d,error:`Items did not match schema.`},...t.errors),u))break}}if(ve!==void 0){let d=`${s}/items`;if(Array.isArray(ve)){let s=Math.min(ve.length,t);for(;l<s;l++){let t=q(e[l],ve[l],n,r,i,a,`${o}/${l}`,`${d}/${l}`);if(c[l]=!0,!t.valid&&(u=i,y.push({instanceLocation:o,keyword:`items`,keywordLocation:d,error:`Items did not match schema.`},...t.errors),u))break}}else for(;l<t;l++){let t=q(e[l],ve,n,r,i,a,`${o}/${l}`,d);if(c[l]=!0,!t.valid&&(u=i,y.push({instanceLocation:o,keyword:`items`,keywordLocation:d,error:`Items did not match schema.`},...t.errors),u))break}if(!u&&ye!==void 0){let d=`${s}/additionalItems`;for(;l<t;l++){let t=q(e[l],ye,n,r,i,a,`${o}/${l}`,d);c[l]=!0,t.valid||(u=i,y.push({instanceLocation:o,keyword:`additionalItems`,keywordLocation:d,error:`Items did not match additional items schema.`},...t.errors))}}}if(xe!==void 0)if(t===0&&Se===void 0)y.push({instanceLocation:o,keyword:`contains`,keywordLocation:`${s}/contains`,error:`Array is empty. It must contain at least one item matching the schema.`});else if(Se!==void 0&&t<Se)y.push({instanceLocation:o,keyword:`minContains`,keywordLocation:`${s}/minContains`,error:`Array has less items (${t}) than minContains (${Se}).`});else{let l=`${s}/contains`,u=y.length,d=0;for(let s=0;s<t;s++){let t=q(e[s],xe,n,r,i,a,`${o}/${s}`,l);t.valid?(c[s]=!0,d++):y.push(...t.errors)}d>=(Se||0)&&(y.length=u),Se===void 0&&Ce===void 0&&d===0?y.splice(u,0,{instanceLocation:o,keyword:`contains`,keywordLocation:l,error:`Array does not contain item matching schema.`}):Se!==void 0&&d<Se?y.push({instanceLocation:o,keyword:`minContains`,keywordLocation:`${s}/minContains`,error:`Array must contain at least ${Se} items matching schema. Only ${d} items were found.`}):Ce!==void 0&&d>Ce&&y.push({instanceLocation:o,keyword:`maxContains`,keywordLocation:`${s}/maxContains`,error:`Array may contain at most ${Ce} items matching schema. ${d} items were found.`})}if(!u&&be!==void 0){let u=`${s}/unevaluatedItems`;for(;l<t;l++){if(c[l])continue;let t=q(e[l],be,n,r,i,a,`${o}/${l}`,u);c[l]=!0,t.valid||y.push({instanceLocation:o,keyword:`unevaluatedItems`,keywordLocation:u,error:`Items did not match unevaluated items schema.`},...t.errors)}}if(Ee)for(let n=0;n<t;n++){let r=e[n],i=typeof r==`object`&&!!r;for(let a=0;a<t;a++){if(n===a)continue;let t=e[a];(r===t||i&&typeof t==`object`&&t&&cl(r,t))&&(y.push({instanceLocation:o,keyword:`uniqueItems`,keywordLocation:`${s}/uniqueItems`,error:`Duplicate items at indexes ${n} and ${a}.`}),n=2**53-1,a=2**53-1)}}}else if(u===`number`){if(n===`4`?(De!==void 0&&(ke===!0&&e<=De||e<De)&&y.push({instanceLocation:o,keyword:`minimum`,keywordLocation:`${s}/minimum`,error:`${e} is less than ${ke?`or equal to `:``} ${De}.`}),Oe!==void 0&&(Ae===!0&&e>=Oe||e>Oe)&&y.push({instanceLocation:o,keyword:`maximum`,keywordLocation:`${s}/maximum`,error:`${e} is greater than ${Ae?`or equal to `:``} ${Oe}.`})):(De!==void 0&&e<De&&y.push({instanceLocation:o,keyword:`minimum`,keywordLocation:`${s}/minimum`,error:`${e} is less than ${De}.`}),Oe!==void 0&&e>Oe&&y.push({instanceLocation:o,keyword:`maximum`,keywordLocation:`${s}/maximum`,error:`${e} is greater than ${Oe}.`}),ke!==void 0&&e<=ke&&y.push({instanceLocation:o,keyword:`exclusiveMinimum`,keywordLocation:`${s}/exclusiveMinimum`,error:`${e} is less than ${ke}.`}),Ae!==void 0&&e>=Ae&&y.push({instanceLocation:o,keyword:`exclusiveMaximum`,keywordLocation:`${s}/exclusiveMaximum`,error:`${e} is greater than or equal to ${Ae}.`})),je!==void 0){let t=e%je;Math.abs(0-t)>=1.1920929e-7&&Math.abs(je-t)>=1.1920929e-7&&y.push({instanceLocation:o,keyword:`multipleOf`,keywordLocation:`${s}/multipleOf`,error:`${e} is not a multiple of ${je}.`})}}else if(u===`string`){let t=Me===void 0&&Ne===void 0?0:Ul(e);Me!==void 0&&t<Me&&y.push({instanceLocation:o,keyword:`minLength`,keywordLocation:`${s}/minLength`,error:`String is too short (${t} < ${Me}).`}),Ne!==void 0&&t>Ne&&y.push({instanceLocation:o,keyword:`maxLength`,keywordLocation:`${s}/maxLength`,error:`String is too long (${t} > ${Ne}).`}),Pe!==void 0&&!new RegExp(Pe,`u`).test(e)&&y.push({instanceLocation:o,keyword:`pattern`,keywordLocation:`${s}/pattern`,error:`String does not match pattern.`}),oe!==void 0&&Ml[oe]&&!Ml[oe](e)&&y.push({instanceLocation:o,keyword:`format`,keywordLocation:`${s}/format`,error:`String does not match format "${oe}".`})}return{valid:y.length===0,errors:y}}var Wl=class{schema;draft;shortCircuit;lookup;constructor(e,t=`2019-09`,n=!0){this.schema=e,this.draft=t,this.shortCircuit=n,this.lookup=hl(e)}validate(e){return q(e,this.schema,this.draft,this.lookup,this.shortCircuit)}addSchema(e,t){t&&(e={...e,$id:t}),hl(e,this.lookup)}};let Gl=`Failed to parse input arguments`,Kl=`Tool was executed but the invocation failed. For example, the script function threw an error`,ql=`Tool was cancelled`,Jl={type:`object`,properties:{}},Yl=[`draft-2020-12`,`draft-07`],Xl=Symbol(`standardValidator`),Zl={installed:!1,previousModelContextDescriptor:void 0,previousModelContextTestingDescriptor:void 0};var Ql=class{tools=new Map;toolsChangedCallback=null;provideContext(e={}){let t=new Map;for(let n of e.tools??[]){let e=lu(n,t);t.set(e.name,e)}this.tools=t,this.notifyToolsChanged()}clearContext(){this.tools.clear(),this.notifyToolsChanged()}registerTool(e){let t=lu(e,this.tools);this.tools.set(t.name,t),this.notifyToolsChanged()}unregisterTool(e){this.tools.delete(e)&&this.notifyToolsChanged()}getTestingShim(){return{listTools:()=>[...this.tools.values()].map(e=>{let t={name:e.name,description:e.description};try{t.inputSchema=JSON.stringify(e.inputSchema)}catch{}return t}),executeTool:(e,t,n)=>this.executeToolForTesting(e,t,n),registerToolsChangedCallback:e=>{if(typeof e!=`function`)throw TypeError(`Failed to execute 'registerToolsChangedCallback' on 'ModelContextTesting': parameter 1 is not of type 'Function'.`);this.toolsChangedCallback=e},getCrossDocumentScriptToolResult:async()=>`[]`}}async executeToolForTesting(e,t,n){if(n?.signal?.aborted)throw $l(ql);let r=this.tools.get(e);if(!r)throw $l(`Tool not found: ${e}`);let i=eu(t),a=await pu(i,r);if(a)throw $l(a);let o=!0,s={requestUserInteraction:async t=>{if(!o)throw Error(`ModelContextClient for tool "${e}" is no longer active after execute() resolved`);if(typeof t!=`function`)throw TypeError(`requestUserInteraction(callback) requires a function callback`);return t()}};try{let e=r.execute(i,s);return xu(yu(await Su(Promise.resolve(e),n?.signal)))}catch(e){throw $l(e instanceof Error?`${Kl}: ${e.message}`:Kl)}finally{o=!1}}notifyToolsChanged(){this.toolsChangedCallback&&queueMicrotask(()=>{try{this.toolsChangedCallback?.()}catch(e){console.warn(`[WebMCPPolyfill] toolsChanged callback threw:`,e)}})}};function $l(e){try{return new DOMException(e,`UnknownError`)}catch{let t=Error(e);return t.name=`UnknownError`,t}}function eu(e){let t;try{t=JSON.parse(e)}catch{throw $l(Gl)}if(!t||typeof t!=`object`||Array.isArray(t))throw $l(Gl);return t}function J(e){return!!e&&typeof e==`object`&&!Array.isArray(e)}function tu(e){if(!J(e))return null;let t=e[`~standard`];return J(t)?t:null}function nu(e){let t=tu(e);return!!(t&&t.version===1&&typeof t.validate==`function`)}function ru(e){let t=tu(e);return!t||t.version!==1||!J(t.jsonSchema)?!1:typeof t.jsonSchema.input==`function`}function iu(e){return{"~standard":{version:1,vendor:`@mcp-b/webmcp-polyfill-json-schema`,validate(t){if(!J(t))return{issues:[{message:`expected object arguments`}]};let n=uu(t,e);return n?{issues:[n]}:{value:t}}}}}function au(e){for(let t of Yl)try{let n=e[`~standard`].jsonSchema.input({target:t});return su(n),n}catch(e){console.warn(`[WebMCPPolyfill] Standard JSON Schema conversion failed for target "${t}":`,e)}throw Error(`Failed to convert Standard JSON Schema inputSchema to a JSON Schema object`)}function ou(e){if(e===void 0){let e=Jl;return{inputSchema:e,standardValidator:iu(e)}}if(ru(e)){let t=au(e);return{inputSchema:t,standardValidator:iu(t)}}if(nu(e))return{inputSchema:Jl,standardValidator:e};if(su(e),Object.keys(e).length===0)return{inputSchema:Jl,standardValidator:iu(Jl)};let t=e.type===void 0?{type:`object`,...e}:e;return{inputSchema:t,standardValidator:iu(t)}}function su(e){if(!J(e))throw Error(`inputSchema must be a JSON Schema object`);cu(e,`$`)}function cu(e,t){let n=e.type;if(n!==void 0&&typeof n!=`string`&&!(Array.isArray(n)&&n.every(e=>typeof e==`string`&&e.length>0)))throw Error(`Invalid JSON Schema at ${t}: "type" must be a string or string[]`);let r=e.required;if(r!==void 0&&!(Array.isArray(r)&&r.every(e=>typeof e==`string`)))throw Error(`Invalid JSON Schema at ${t}: "required" must be an array of strings`);let i=e.properties;if(i!==void 0){if(!J(i))throw Error(`Invalid JSON Schema at ${t}: "properties" must be an object`);for(let[e,n]of Object.entries(i)){if(!J(n))throw Error(`Invalid JSON Schema at ${t}.properties.${e}: expected object schema`);cu(n,`${t}.properties.${e}`)}}let a=e.items;if(a!==void 0)if(Array.isArray(a))for(let[e,n]of a.entries()){if(!J(n))throw Error(`Invalid JSON Schema at ${t}.items[${e}]: expected object schema`);cu(n,`${t}.items[${e}]`)}else if(J(a))cu(a,`${t}.items`);else throw Error(`Invalid JSON Schema at ${t}: "items" must be an object or object[]`);for(let n of[`allOf`,`anyOf`,`oneOf`]){let r=e[n];if(r!==void 0){if(!Array.isArray(r))throw Error(`Invalid JSON Schema at ${t}: "${n}" must be an array`);for(let[e,i]of r.entries()){if(!J(i))throw Error(`Invalid JSON Schema at ${t}.${n}[${e}]: expected object schema`);cu(i,`${t}.${n}[${e}]`)}}}let o=e.not;if(o!==void 0){if(!J(o))throw Error(`Invalid JSON Schema at ${t}: "not" must be an object schema`);cu(o,`${t}.not`)}try{JSON.stringify(e)}catch{throw Error(`Invalid JSON Schema at ${t}: schema must be JSON-serializable`)}}function lu(e,t){if(!e||typeof e!=`object`)throw TypeError(`registerTool(tool) requires a tool object`);if(typeof e.name!=`string`||e.name.length===0)throw TypeError(`Tool "name" must be a non-empty string`);if(typeof e.description!=`string`||e.description.length===0)throw TypeError(`Tool "description" must be a non-empty string`);if(typeof e.execute!=`function`)throw TypeError(`Tool "execute" must be a function`);if(t.has(e.name))throw Error(`Tool already registered: ${e.name}`);let n=ou(e.inputSchema),r=e.annotations,i=r?{...r,...r.readOnlyHint===`true`?{readOnlyHint:!0}:r.readOnlyHint===`false`?{readOnlyHint:!1}:{},...r.destructiveHint===`true`?{destructiveHint:!0}:r.destructiveHint===`false`?{destructiveHint:!1}:{},...r.idempotentHint===`true`?{idempotentHint:!0}:r.idempotentHint===`false`?{idempotentHint:!1}:{},...r.openWorldHint===`true`?{openWorldHint:!0}:r.openWorldHint===`false`?{openWorldHint:!1}:{}}:void 0;return{...e,...i?{annotations:i}:{},inputSchema:n.inputSchema,[Xl]:n.standardValidator}}function uu(e,t){let n=new Wl(t,`2020-12`,!0).validate(e);if(n.valid)return null;let r=n.errors[n.errors.length-1];return r?{message:r.error}:{message:`Input validation failed`}}function du(e){if(!e||e.length===0)return null;let t=e.map(e=>J(e)&&`key`in e?e.key:e).map(e=>String(e)).filter(e=>e.length>0);return t.length===0?null:t.join(`.`)}async function fu(e,t){let n;try{n=await Promise.resolve(t[`~standard`].validate(e))}catch(e){let t=e instanceof Error?`: ${e.message}`:``;return console.error(`[WebMCPPolyfill] Standard Schema validation threw unexpectedly:`,e),`Input validation error: schema validation failed${t}`}if(!n.issues||n.issues.length===0)return null;let r=n.issues[0];if(!r)return`Input validation error`;let i=du(r?.path);return i?`Input validation error: ${r.message} at ${i}`:`Input validation error: ${r.message}`}async function pu(e,t){return fu(e,t[Xl])}function mu(e){return J(e)&&Array.isArray(e.content)}function hu(e){return e===null||typeof e==`string`||typeof e==`number`||typeof e==`boolean`}function gu(e){return hu(e)?Number.isFinite(e)||typeof e!=`number`:Array.isArray(e)?e.every(e=>gu(e)):J(e)?Object.values(e).every(e=>gu(e)):!1}function _u(e){if(!(!J(e)||!gu(e)))return e}function vu(e){if(typeof e==`string`)return e;try{return JSON.stringify(e)??String(e)}catch{return String(e)}}function yu(e){if(mu(e))return e;let t=_u(e);return{content:[{type:`text`,text:vu(e)}],...t?{structuredContent:t}:{},isError:!1}}function bu(e){for(let t of e.content??[])if(t.type===`text`&&`text`in t&&typeof t.text==`string`)return t.text;return null}function xu(e){if(e.isError)throw $l(bu(e)?.replace(/^Error:\s*/i,``).trim()||Kl);let t=e.metadata;if(t&&typeof t==`object`&&t.willNavigate)return null;try{return JSON.stringify(e)}catch{throw $l(Kl)}}function Su(e,t){return t?t.aborted?Promise.reject($l(ql)):new Promise((n,r)=>{let i=()=>{a(),r($l(ql))},a=()=>{t.removeEventListener(`abort`,i)};t.addEventListener(`abort`,i,{once:!0}),e.then(e=>{a(),n(e)},e=>{a(),r(e)})}):e}function Cu(){return typeof navigator<`u`?navigator:null}function wu(e,t,n){Object.defineProperty(e,t,{configurable:!0,enumerable:!0,writable:!1,value:n})}function Tu(e){let t=Cu();if(!t||t.modelContext)return;Zl.installed&&Eu();let n=new Ql,r=n;r.__isWebMCPPolyfill=!0,Zl.previousModelContextDescriptor=Object.getOwnPropertyDescriptor(t,`modelContext`),Zl.previousModelContextTestingDescriptor=Object.getOwnPropertyDescriptor(t,`modelContextTesting`),wu(t,`modelContext`,r);let i=e?.installTestingShim??`if-missing`,a=!!t.modelContextTesting;(i===`always`||(i===!0||i===`if-missing`)&&!a)&&wu(t,`modelContextTesting`,n.getTestingShim()),Zl.installed=!0}function Eu(){let e=Cu();if(!e||!Zl.installed)return;let t=(t,n)=>{if(n){Object.defineProperty(e,t,n);return}delete e[t]};t(`modelContext`,Zl.previousModelContextDescriptor),t(`modelContextTesting`,Zl.previousModelContextTestingDescriptor),Zl.installed=!1,Zl.previousModelContextDescriptor=void 0,Zl.previousModelContextTestingDescriptor=void 0}if(typeof window<`u`&&typeof document<`u`){let e=window.__webMCPPolyfillOptions;if(e?.autoInitialize!==!1)try{Tu(e)}catch(e){console.error(`[WebMCPPolyfill] Auto-initialization failed:`,e)}}function Du(e){return!!e._zod}function Ou(e){let t=Object.values(e);if(t.length===0)return jo({});let n=t.every(Du),r=t.every(e=>!Du(e));if(n)return jo(e);if(r)return ht(e);throw Error(`Mixed Zod versions detected in object shape.`)}function ku(e,t){return Du(e)?dn(e,t):e.safeParse(t)}async function Au(e,t){return Du(e)?await pn(e,t):await e.safeParseAsync(t)}function ju(e){if(!e)return;let t;if(t=Du(e)?e._zod?.def?.shape:e.shape,t){if(typeof t==`function`)try{return t()}catch{return}return t}}function Mu(e){if(e){if(typeof e==`object`){let t=e,n=e;if(!t._def&&!n._zod){let t=Object.values(e);if(t.length>0&&t.every(e=>typeof e==`object`&&!!e&&(e._def!==void 0||e._zod!==void 0||typeof e.parse==`function`)))return Ou(e)}}if(Du(e)){let t=e._zod?.def;if(t&&(t.type===`object`||t.shape!==void 0))return e}else if(e.shape!==void 0)return e}}function Nu(e){if(e&&typeof e==`object`){if(`message`in e&&typeof e.message==`string`)return e.message;if(`issues`in e&&Array.isArray(e.issues)&&e.issues.length>0){let t=e.issues[0];if(t&&typeof t==`object`&&`message`in t)return String(t.message)}try{return JSON.stringify(e)}catch{return String(e)}}return String(e)}function Pu(e){return e.description}function Fu(e){if(Du(e))return e._zod?.def?.type===`optional`;let t=e;return typeof e.isOptional==`function`?e.isOptional():t._def?.typeName===`ZodOptional`}function Iu(e){if(Du(e)){let t=e._zod?.def;if(t){if(t.value!==void 0)return t.value;if(Array.isArray(t.values)&&t.values.length>0)return t.values[0]}}let t=e._def;if(t){if(t.value!==void 0)return t.value;if(Array.isArray(t.values)&&t.values.length>0)return t.values[0]}let n=e.value;if(n!==void 0)return n}let Lu=`2025-11-25`,Ru=[Lu,`2025-06-18`,`2025-03-26`,`2024-11-05`,`2024-10-07`],zu=`io.modelcontextprotocol/related-task`,Y=oc(e=>e!==null&&(typeof e==`object`||typeof e==`function`)),Bu=R([A(),M().int()]),Vu=A();L({ttl:R([M(),Es()]).optional(),pollInterval:M().optional()});let Hu=I({ttl:M().optional()}),Uu=I({taskId:A()}),Wu=L({progressToken:Bu.optional(),[zu]:Uu.optional()}),Gu=I({_meta:Wu.optional()}),Ku=Gu.extend({task:Hu.optional()}),qu=e=>Ku.safeParse(e).success,X=I({method:A(),params:Gu.loose().optional()}),Ju=I({_meta:Wu.optional()}),Yu=I({method:A(),params:Ju.loose().optional()}),Z=L({_meta:Wu.optional()}),Xu=R([A(),M().int()]),Zu=I({jsonrpc:V(`2.0`),id:Xu,...X.shape}).strict(),Qu=e=>Zu.safeParse(e).success,$u=I({jsonrpc:V(`2.0`),...Yu.shape}).strict(),ed=e=>$u.safeParse(e).success,td=I({jsonrpc:V(`2.0`),id:Xu,result:Z}).strict(),nd=e=>td.safeParse(e).success;var Q;(function(e){e[e.ConnectionClosed=-32e3]=`ConnectionClosed`,e[e.RequestTimeout=-32001]=`RequestTimeout`,e[e.ParseError=-32700]=`ParseError`,e[e.InvalidRequest=-32600]=`InvalidRequest`,e[e.MethodNotFound=-32601]=`MethodNotFound`,e[e.InvalidParams=-32602]=`InvalidParams`,e[e.InternalError=-32603]=`InternalError`,e[e.UrlElicitationRequired=-32042]=`UrlElicitationRequired`})(Q||={});let rd=I({jsonrpc:V(`2.0`),id:Xu.optional(),error:I({code:M().int(),message:A(),data:P().optional()})}).strict(),id=e=>rd.safeParse(e).success,ad=R([Zu,$u,td,rd]);R([td,rd]);let od=Z.strict(),sd=Ju.extend({requestId:Xu.optional(),reason:A().optional()}),cd=Yu.extend({method:V(`notifications/cancelled`),params:sd}),ld=I({icons:F(I({src:A(),mimeType:A().optional(),sizes:F(A()).optional(),theme:B([`light`,`dark`]).optional()})).optional()}),ud=I({name:A(),title:A().optional()}),dd=ud.extend({...ud.shape,...ld.shape,version:A(),websiteUrl:A().optional(),description:A().optional()}),fd=lc(e=>e&&typeof e==`object`&&!Array.isArray(e)&&Object.keys(e).length===0?{form:{}}:e,Is(I({form:Is(I({applyDefaults:N().optional()}),z(A(),P())).optional(),url:Y.optional()}),z(A(),P()).optional())),pd=L({list:Y.optional(),cancel:Y.optional(),requests:L({sampling:L({createMessage:Y.optional()}).optional(),elicitation:L({create:Y.optional()}).optional()}).optional()}),md=L({list:Y.optional(),cancel:Y.optional(),requests:L({tools:L({call:Y.optional()}).optional()}).optional()}),hd=I({experimental:z(A(),Y).optional(),sampling:I({context:Y.optional(),tools:Y.optional()}).optional(),elicitation:fd.optional(),roots:I({listChanged:N().optional()}).optional(),tasks:pd.optional()}),gd=Gu.extend({protocolVersion:A(),capabilities:hd,clientInfo:dd}),_d=X.extend({method:V(`initialize`),params:gd}),vd=I({experimental:z(A(),Y).optional(),logging:Y.optional(),completions:Y.optional(),prompts:I({listChanged:N().optional()}).optional(),resources:I({subscribe:N().optional(),listChanged:N().optional()}).optional(),tools:I({listChanged:N().optional()}).optional(),tasks:md.optional()}),yd=Z.extend({protocolVersion:A(),capabilities:vd,serverInfo:dd,instructions:A().optional()}),bd=Yu.extend({method:V(`notifications/initialized`),params:Ju.optional()}),xd=X.extend({method:V(`ping`),params:Gu.optional()}),Sd=I({progress:M(),total:H(M()),message:H(A())}),Cd=I({...Ju.shape,...Sd.shape,progressToken:Bu}),wd=Yu.extend({method:V(`notifications/progress`),params:Cd}),Td=Gu.extend({cursor:Vu.optional()}),Ed=X.extend({params:Td.optional()}),Dd=Z.extend({nextCursor:Vu.optional()}),Od=B([`working`,`input_required`,`completed`,`failed`,`cancelled`]),kd=I({taskId:A(),status:Od,ttl:R([M(),Es()]),createdAt:A(),lastUpdatedAt:A(),pollInterval:H(M()),statusMessage:H(A())}),Ad=Z.extend({task:kd}),jd=Ju.merge(kd),Md=Yu.extend({method:V(`notifications/tasks/status`),params:jd}),Nd=X.extend({method:V(`tasks/get`),params:Gu.extend({taskId:A()})}),Pd=Z.merge(kd),Fd=X.extend({method:V(`tasks/result`),params:Gu.extend({taskId:A()})});Z.loose();let Id=Ed.extend({method:V(`tasks/list`)}),Ld=Dd.extend({tasks:F(kd)}),Rd=X.extend({method:V(`tasks/cancel`),params:Gu.extend({taskId:A()})}),zd=Z.merge(kd),Bd=I({uri:A(),mimeType:H(A()),_meta:z(A(),P()).optional()}),Vd=Bd.extend({text:A()}),Hd=A().refine(e=>{try{return atob(e),!0}catch{return!1}},{message:`Invalid Base64 string`}),Ud=Bd.extend({blob:Hd}),Wd=B([`user`,`assistant`]),Gd=I({audience:F(Wd).optional(),priority:M().min(0).max(1).optional(),lastModified:No({offset:!0}).optional()}),Kd=I({...ud.shape,...ld.shape,uri:A(),description:H(A()),mimeType:H(A()),annotations:Gd.optional(),_meta:H(L({}))}),qd=I({...ud.shape,...ld.shape,uriTemplate:A(),description:H(A()),mimeType:H(A()),annotations:Gd.optional(),_meta:H(L({}))}),Jd=Ed.extend({method:V(`resources/list`)}),Yd=Dd.extend({resources:F(Kd)}),Xd=Ed.extend({method:V(`resources/templates/list`)}),Zd=Dd.extend({resourceTemplates:F(qd)}),Qd=Gu.extend({uri:A()}),$d=Qd,ef=X.extend({method:V(`resources/read`),params:$d}),tf=Z.extend({contents:F(R([Vd,Ud]))}),nf=Yu.extend({method:V(`notifications/resources/list_changed`),params:Ju.optional()}),rf=Qd,af=X.extend({method:V(`resources/subscribe`),params:rf}),of=Qd,sf=X.extend({method:V(`resources/unsubscribe`),params:of}),cf=Ju.extend({uri:A()}),lf=Yu.extend({method:V(`notifications/resources/updated`),params:cf}),uf=I({name:A(),description:H(A()),required:H(N())}),df=I({...ud.shape,...ld.shape,description:H(A()),arguments:H(F(uf)),_meta:H(L({}))}),ff=Ed.extend({method:V(`prompts/list`)}),pf=Dd.extend({prompts:F(df)}),mf=Gu.extend({name:A(),arguments:z(A(),A()).optional()}),hf=X.extend({method:V(`prompts/get`),params:mf}),gf=I({type:V(`text`),text:A(),annotations:Gd.optional(),_meta:z(A(),P()).optional()}),_f=I({type:V(`image`),data:Hd,mimeType:A(),annotations:Gd.optional(),_meta:z(A(),P()).optional()}),vf=I({type:V(`audio`),data:Hd,mimeType:A(),annotations:Gd.optional(),_meta:z(A(),P()).optional()}),yf=I({type:V(`tool_use`),name:A(),id:A(),input:z(A(),P()),_meta:z(A(),P()).optional()}),bf=I({type:V(`resource`),resource:R([Vd,Ud]),annotations:Gd.optional(),_meta:z(A(),P()).optional()}),xf=R([gf,_f,vf,Kd.extend({type:V(`resource_link`)}),bf]),Sf=I({role:Wd,content:xf}),Cf=Z.extend({description:A().optional(),messages:F(Sf)}),wf=Yu.extend({method:V(`notifications/prompts/list_changed`),params:Ju.optional()}),Tf=I({title:A().optional(),readOnlyHint:N().optional(),destructiveHint:N().optional(),idempotentHint:N().optional(),openWorldHint:N().optional()}),Ef=I({taskSupport:B([`required`,`optional`,`forbidden`]).optional()}),Df=I({...ud.shape,...ld.shape,description:A().optional(),inputSchema:I({type:V(`object`),properties:z(A(),Y).optional(),required:F(A()).optional()}).catchall(P()),outputSchema:I({type:V(`object`),properties:z(A(),Y).optional(),required:F(A()).optional()}).catchall(P()).optional(),annotations:Tf.optional(),execution:Ef.optional(),_meta:z(A(),P()).optional()}),Of=Ed.extend({method:V(`tools/list`)}),kf=Dd.extend({tools:F(Df)}),Af=Z.extend({content:F(xf).default([]),structuredContent:z(A(),P()).optional(),isError:N().optional()});Af.or(Z.extend({toolResult:P()}));let jf=Ku.extend({name:A(),arguments:z(A(),P()).optional()}),Mf=X.extend({method:V(`tools/call`),params:jf}),Nf=Yu.extend({method:V(`notifications/tools/list_changed`),params:Ju.optional()});I({autoRefresh:N().default(!0),debounceMs:M().int().nonnegative().default(300)});let Pf=B([`debug`,`info`,`notice`,`warning`,`error`,`critical`,`alert`,`emergency`]),Ff=Gu.extend({level:Pf}),If=X.extend({method:V(`logging/setLevel`),params:Ff}),Lf=Ju.extend({level:Pf,logger:A().optional(),data:P()}),Rf=Yu.extend({method:V(`notifications/message`),params:Lf}),zf=I({hints:F(I({name:A().optional()})).optional(),costPriority:M().min(0).max(1).optional(),speedPriority:M().min(0).max(1).optional(),intelligencePriority:M().min(0).max(1).optional()}),Bf=I({mode:B([`auto`,`required`,`none`]).optional()}),Vf=I({type:V(`tool_result`),toolUseId:A().describe(`The unique identifier for the corresponding tool call.`),content:F(xf).default([]),structuredContent:I({}).loose().optional(),isError:N().optional(),_meta:z(A(),P()).optional()}),Hf=Ps(`type`,[gf,_f,vf]),Uf=Ps(`type`,[gf,_f,vf,yf,Vf]),Wf=I({role:Wd,content:R([Uf,F(Uf)]),_meta:z(A(),P()).optional()}),Gf=Ku.extend({messages:F(Wf),modelPreferences:zf.optional(),systemPrompt:A().optional(),includeContext:B([`none`,`thisServer`,`allServers`]).optional(),temperature:M().optional(),maxTokens:M().int(),stopSequences:F(A()).optional(),metadata:Y.optional(),tools:F(Df).optional(),toolChoice:Bf.optional()}),Kf=X.extend({method:V(`sampling/createMessage`),params:Gf}),qf=Z.extend({model:A(),stopReason:H(B([`endTurn`,`stopSequence`,`maxTokens`]).or(A())),role:Wd,content:Hf}),Jf=Z.extend({model:A(),stopReason:H(B([`endTurn`,`stopSequence`,`maxTokens`,`toolUse`]).or(A())),role:Wd,content:R([Uf,F(Uf)])}),Yf=I({type:V(`boolean`),title:A().optional(),description:A().optional(),default:N().optional()}),Xf=I({type:V(`string`),title:A().optional(),description:A().optional(),minLength:M().optional(),maxLength:M().optional(),format:B([`email`,`uri`,`date`,`date-time`]).optional(),default:A().optional()}),Zf=I({type:B([`number`,`integer`]),title:A().optional(),description:A().optional(),minimum:M().optional(),maximum:M().optional(),default:M().optional()}),Qf=I({type:V(`string`),title:A().optional(),description:A().optional(),enum:F(A()),default:A().optional()}),$f=I({type:V(`string`),title:A().optional(),description:A().optional(),oneOf:F(I({const:A(),title:A()})),default:A().optional()}),ep=R([R([I({type:V(`string`),title:A().optional(),description:A().optional(),enum:F(A()),enumNames:F(A()).optional(),default:A().optional()}),R([Qf,$f]),R([I({type:V(`array`),title:A().optional(),description:A().optional(),minItems:M().optional(),maxItems:M().optional(),items:I({type:V(`string`),enum:F(A())}),default:F(A()).optional()}),I({type:V(`array`),title:A().optional(),description:A().optional(),minItems:M().optional(),maxItems:M().optional(),items:I({anyOf:F(I({const:A(),title:A()}))}),default:F(A()).optional()})])]),Yf,Xf,Zf]),tp=R([Ku.extend({mode:V(`form`).optional(),message:A(),requestedSchema:I({type:V(`object`),properties:z(A(),ep),required:F(A()).optional()})}),Ku.extend({mode:V(`url`),message:A(),elicitationId:A(),url:A().url()})]),np=X.extend({method:V(`elicitation/create`),params:tp}),rp=Ju.extend({elicitationId:A()}),ip=Yu.extend({method:V(`notifications/elicitation/complete`),params:rp}),ap=Z.extend({action:B([`accept`,`decline`,`cancel`]),content:lc(e=>e===null?void 0:e,z(A(),R([A(),M(),N(),F(A())])).optional())}),op=I({type:V(`ref/resource`),uri:A()}),sp=I({type:V(`ref/prompt`),name:A()}),cp=Gu.extend({ref:R([sp,op]),argument:I({name:A(),value:A()}),context:I({arguments:z(A(),A()).optional()}).optional()}),lp=X.extend({method:V(`completion/complete`),params:cp});function up(e){if(e.params.ref.type!==`ref/prompt`)throw TypeError(`Expected CompleteRequestPrompt, but got ${e.params.ref.type}`)}function dp(e){if(e.params.ref.type!==`ref/resource`)throw TypeError(`Expected CompleteRequestResourceTemplate, but got ${e.params.ref.type}`)}let fp=Z.extend({completion:L({values:F(A()).max(100),total:H(M().int()),hasMore:H(N())})}),pp=I({uri:A().startsWith(`file://`),name:A().optional(),_meta:z(A(),P()).optional()}),mp=X.extend({method:V(`roots/list`),params:Gu.optional()}),hp=Z.extend({roots:F(pp)}),gp=Yu.extend({method:V(`notifications/roots/list_changed`),params:Ju.optional()});R([xd,_d,lp,If,hf,ff,Jd,Xd,ef,af,sf,Mf,Of,Nd,Fd,Id,Rd]),R([cd,wd,bd,gp,Md]),R([od,qf,Jf,ap,hp,Pd,Ld,Ad]),R([xd,Kf,np,mp,Nd,Fd,Id,Rd]),R([cd,wd,Rf,lf,nf,Nf,wf,Md,ip]),R([od,yd,fp,Cf,pf,Yd,Zd,tf,Af,kf,Pd,Ld,Ad]);var $=class e extends Error{constructor(e,t,n){super(`MCP error ${e}: ${t}`),this.code=e,this.data=n,this.name=`McpError`}static fromError(t,n,r){if(t===Q.UrlElicitationRequired&&r){let e=r;if(e.elicitations)return new _p(e.elicitations,n)}return new e(t,n,r)}},_p=class extends ${constructor(e,t=`URL elicitation${e.length>1?`s`:``} required`){super(Q.UrlElicitationRequired,t,{elicitations:e})}get elicitations(){return this.data?.elicitations??[]}};function vp(e){return e===`completed`||e===`failed`||e===`cancelled`}function yp(e){return!e||e===`jsonSchema7`||e===`draft-7`?`draft-7`:e===`jsonSchema2019-09`||e===`draft-2020-12`?`draft-2020-12`:`draft-7`}function bp(e,t){return Du(e)?Oo(e,{target:yp(t?.target),io:t?.pipeStrategy??`input`}):sl(e,{strictUnions:t?.strictUnions??!0,pipeStrategy:t?.pipeStrategy??`input`})}function xp(e){let t=ju(e)?.method;if(!t)throw Error(`Schema is missing a method literal`);let n=Iu(t);if(typeof n!=`string`)throw Error(`Schema method literal must be a string`);return n}function Sp(e,t){let n=ku(e,t);if(!n.success)throw n.error;return n.data}var Cp=class{constructor(e){this._options=e,this._requestMessageId=0,this._requestHandlers=new Map,this._requestHandlerAbortControllers=new Map,this._notificationHandlers=new Map,this._responseHandlers=new Map,this._progressHandlers=new Map,this._timeoutInfo=new Map,this._pendingDebouncedNotifications=new Set,this._taskProgressTokens=new Map,this._requestResolvers=new Map,this.setNotificationHandler(cd,e=>{this._oncancel(e)}),this.setNotificationHandler(wd,e=>{this._onprogress(e)}),this.setRequestHandler(xd,e=>({})),this._taskStore=e?.taskStore,this._taskMessageQueue=e?.taskMessageQueue,this._taskStore&&(this.setRequestHandler(Nd,async(e,t)=>{let n=await this._taskStore.getTask(e.params.taskId,t.sessionId);if(!n)throw new $(Q.InvalidParams,`Failed to retrieve task: Task not found`);return{...n}}),this.setRequestHandler(Fd,async(e,t)=>{let n=async()=>{let r=e.params.taskId;if(this._taskMessageQueue){let e;for(;e=await this._taskMessageQueue.dequeue(r,t.sessionId);){if(e.type===`response`||e.type===`error`){let t=e.message,n=t.id,r=this._requestResolvers.get(n);if(r)if(this._requestResolvers.delete(n),e.type===`response`)r(t);else{let e=t;r(new $(e.error.code,e.error.message,e.error.data))}else{let t=e.type===`response`?`Response`:`Error`;this._onerror(Error(`${t} handler missing for request ${n}`))}continue}await this._transport?.send(e.message,{relatedRequestId:t.requestId})}}let i=await this._taskStore.getTask(r,t.sessionId);if(!i)throw new $(Q.InvalidParams,`Task not found: ${r}`);if(!vp(i.status))return await this._waitForTaskUpdate(r,t.signal),await n();if(vp(i.status)){let e=await this._taskStore.getTaskResult(r,t.sessionId);return this._clearTaskQueue(r),{...e,_meta:{...e._meta,[zu]:{taskId:r}}}}return await n()};return await n()}),this.setRequestHandler(Id,async(e,t)=>{try{let{tasks:n,nextCursor:r}=await this._taskStore.listTasks(e.params?.cursor,t.sessionId);return{tasks:n,nextCursor:r,_meta:{}}}catch(e){throw new $(Q.InvalidParams,`Failed to list tasks: ${e instanceof Error?e.message:String(e)}`)}}),this.setRequestHandler(Rd,async(e,t)=>{try{let n=await this._taskStore.getTask(e.params.taskId,t.sessionId);if(!n)throw new $(Q.InvalidParams,`Task not found: ${e.params.taskId}`);if(vp(n.status))throw new $(Q.InvalidParams,`Cannot cancel task in terminal status: ${n.status}`);await this._taskStore.updateTaskStatus(e.params.taskId,`cancelled`,`Client cancelled task execution.`,t.sessionId),this._clearTaskQueue(e.params.taskId);let r=await this._taskStore.getTask(e.params.taskId,t.sessionId);if(!r)throw new $(Q.InvalidParams,`Task not found after cancellation: ${e.params.taskId}`);return{_meta:{},...r}}catch(e){throw e instanceof $?e:new $(Q.InvalidRequest,`Failed to cancel task: ${e instanceof Error?e.message:String(e)}`)}}))}async _oncancel(e){e.params.requestId&&this._requestHandlerAbortControllers.get(e.params.requestId)?.abort(e.params.reason)}_setupTimeout(e,t,n,r,i=!1){this._timeoutInfo.set(e,{timeoutId:setTimeout(r,t),startTime:Date.now(),timeout:t,maxTotalTimeout:n,resetTimeoutOnProgress:i,onTimeout:r})}_resetTimeout(e){let t=this._timeoutInfo.get(e);if(!t)return!1;let n=Date.now()-t.startTime;if(t.maxTotalTimeout&&n>=t.maxTotalTimeout)throw this._timeoutInfo.delete(e),$.fromError(Q.RequestTimeout,`Maximum total timeout exceeded`,{maxTotalTimeout:t.maxTotalTimeout,totalElapsed:n});return clearTimeout(t.timeoutId),t.timeoutId=setTimeout(t.onTimeout,t.timeout),!0}_cleanupTimeout(e){let t=this._timeoutInfo.get(e);t&&(clearTimeout(t.timeoutId),this._timeoutInfo.delete(e))}async connect(e){if(this._transport)throw Error(`Already connected to a transport. Call close() before connecting to a new transport, or use a separate Protocol instance per connection.`);this._transport=e;let t=this.transport?.onclose;this._transport.onclose=()=>{t?.(),this._onclose()};let n=this.transport?.onerror;this._transport.onerror=e=>{n?.(e),this._onerror(e)};let r=this._transport?.onmessage;this._transport.onmessage=(e,t)=>{r?.(e,t),nd(e)||id(e)?this._onresponse(e):Qu(e)?this._onrequest(e,t):ed(e)?this._onnotification(e):this._onerror(Error(`Unknown message type: ${JSON.stringify(e)}`))},await this._transport.start()}_onclose(){let e=this._responseHandlers;this._responseHandlers=new Map,this._progressHandlers.clear(),this._taskProgressTokens.clear(),this._pendingDebouncedNotifications.clear();for(let e of this._requestHandlerAbortControllers.values())e.abort();this._requestHandlerAbortControllers.clear();let t=$.fromError(Q.ConnectionClosed,`Connection closed`);this._transport=void 0,this.onclose?.();for(let n of e.values())n(t)}_onerror(e){this.onerror?.(e)}_onnotification(e){let t=this._notificationHandlers.get(e.method)??this.fallbackNotificationHandler;t!==void 0&&Promise.resolve().then(()=>t(e)).catch(e=>this._onerror(Error(`Uncaught error in notification handler: ${e}`)))}_onrequest(e,t){let n=this._requestHandlers.get(e.method)??this.fallbackRequestHandler,r=this._transport,i=e.params?._meta?.[zu]?.taskId;if(n===void 0){let t={jsonrpc:`2.0`,id:e.id,error:{code:Q.MethodNotFound,message:`Method not found`}};i&&this._taskMessageQueue?this._enqueueTaskMessage(i,{type:`error`,message:t,timestamp:Date.now()},r?.sessionId).catch(e=>this._onerror(Error(`Failed to enqueue error response: ${e}`))):r?.send(t).catch(e=>this._onerror(Error(`Failed to send an error response: ${e}`)));return}let a=new AbortController;this._requestHandlerAbortControllers.set(e.id,a);let o=qu(e.params)?e.params.task:void 0,s=this._taskStore?this.requestTaskStore(e,r?.sessionId):void 0,c={signal:a.signal,sessionId:r?.sessionId,_meta:e.params?._meta,sendNotification:async t=>{if(a.signal.aborted)return;let n={relatedRequestId:e.id};i&&(n.relatedTask={taskId:i}),await this.notification(t,n)},sendRequest:async(t,n,r)=>{if(a.signal.aborted)throw new $(Q.ConnectionClosed,`Request was cancelled`);let o={...r,relatedRequestId:e.id};i&&!o.relatedTask&&(o.relatedTask={taskId:i});let c=o.relatedTask?.taskId??i;return c&&s&&await s.updateTaskStatus(c,`input_required`),await this.request(t,n,o)},authInfo:t?.authInfo,requestId:e.id,requestInfo:t?.requestInfo,taskId:i,taskStore:s,taskRequestedTtl:o?.ttl,closeSSEStream:t?.closeSSEStream,closeStandaloneSSEStream:t?.closeStandaloneSSEStream};Promise.resolve().then(()=>{o&&this.assertTaskHandlerCapability(e.method)}).then(()=>n(e,c)).then(async t=>{if(a.signal.aborted)return;let n={result:t,jsonrpc:`2.0`,id:e.id};i&&this._taskMessageQueue?await this._enqueueTaskMessage(i,{type:`response`,message:n,timestamp:Date.now()},r?.sessionId):await r?.send(n)},async t=>{if(a.signal.aborted)return;let n={jsonrpc:`2.0`,id:e.id,error:{code:Number.isSafeInteger(t.code)?t.code:Q.InternalError,message:t.message??`Internal error`,...t.data!==void 0&&{data:t.data}}};i&&this._taskMessageQueue?await this._enqueueTaskMessage(i,{type:`error`,message:n,timestamp:Date.now()},r?.sessionId):await r?.send(n)}).catch(e=>this._onerror(Error(`Failed to send response: ${e}`))).finally(()=>{this._requestHandlerAbortControllers.delete(e.id)})}_onprogress(e){let{progressToken:t,...n}=e.params,r=Number(t),i=this._progressHandlers.get(r);if(!i){this._onerror(Error(`Received a progress notification for an unknown token: ${JSON.stringify(e)}`));return}let a=this._responseHandlers.get(r),o=this._timeoutInfo.get(r);if(o&&a&&o.resetTimeoutOnProgress)try{this._resetTimeout(r)}catch(e){this._responseHandlers.delete(r),this._progressHandlers.delete(r),this._cleanupTimeout(r),a(e);return}i(n)}_onresponse(e){let t=Number(e.id),n=this._requestResolvers.get(t);if(n){this._requestResolvers.delete(t),nd(e)?n(e):n(new $(e.error.code,e.error.message,e.error.data));return}let r=this._responseHandlers.get(t);if(r===void 0){this._onerror(Error(`Received a response for an unknown message ID: ${JSON.stringify(e)}`));return}this._responseHandlers.delete(t),this._cleanupTimeout(t);let i=!1;if(nd(e)&&e.result&&typeof e.result==`object`){let n=e.result;if(n.task&&typeof n.task==`object`){let e=n.task;typeof e.taskId==`string`&&(i=!0,this._taskProgressTokens.set(e.taskId,t))}}i||this._progressHandlers.delete(t),nd(e)?r(e):r($.fromError(e.error.code,e.error.message,e.error.data))}get transport(){return this._transport}async close(){await this._transport?.close()}async*requestStream(e,t,n){let{task:r}=n??{};if(!r){try{yield{type:`result`,result:await this.request(e,t,n)}}catch(e){yield{type:`error`,error:e instanceof $?e:new $(Q.InternalError,String(e))}}return}let i;try{let r=await this.request(e,Ad,n);if(r.task)i=r.task.taskId,yield{type:`taskCreated`,task:r.task};else throw new $(Q.InternalError,`Task creation did not return a task`);for(;;){let e=await this.getTask({taskId:i},n);if(yield{type:`taskStatus`,task:e},vp(e.status)){e.status===`completed`?yield{type:`result`,result:await this.getTaskResult({taskId:i},t,n)}:e.status===`failed`?yield{type:`error`,error:new $(Q.InternalError,`Task ${i} failed`)}:e.status===`cancelled`&&(yield{type:`error`,error:new $(Q.InternalError,`Task ${i} was cancelled`)});return}if(e.status===`input_required`){yield{type:`result`,result:await this.getTaskResult({taskId:i},t,n)};return}let r=e.pollInterval??this._options?.defaultTaskPollInterval??1e3;await new Promise(e=>setTimeout(e,r)),n?.signal?.throwIfAborted()}}catch(e){yield{type:`error`,error:e instanceof $?e:new $(Q.InternalError,String(e))}}}request(e,t,n){let{relatedRequestId:r,resumptionToken:i,onresumptiontoken:a,task:o,relatedTask:s}=n??{};return new Promise((c,l)=>{let u=e=>{l(e)};if(!this._transport){u(Error(`Not connected`));return}if(this._options?.enforceStrictCapabilities===!0)try{this.assertCapabilityForMethod(e.method),o&&this.assertTaskCapability(e.method)}catch(e){u(e);return}n?.signal?.throwIfAborted();let d=this._requestMessageId++,f={...e,jsonrpc:`2.0`,id:d};n?.onprogress&&(this._progressHandlers.set(d,n.onprogress),f.params={...e.params,_meta:{...e.params?._meta||{},progressToken:d}}),o&&(f.params={...f.params,task:o}),s&&(f.params={...f.params,_meta:{...f.params?._meta||{},[zu]:s}});let p=e=>{this._responseHandlers.delete(d),this._progressHandlers.delete(d),this._cleanupTimeout(d),this._transport?.send({jsonrpc:`2.0`,method:`notifications/cancelled`,params:{requestId:d,reason:String(e)}},{relatedRequestId:r,resumptionToken:i,onresumptiontoken:a}).catch(e=>this._onerror(Error(`Failed to send cancellation: ${e}`))),l(e instanceof $?e:new $(Q.RequestTimeout,String(e)))};this._responseHandlers.set(d,e=>{if(!n?.signal?.aborted){if(e instanceof Error)return l(e);try{let n=ku(t,e.result);n.success?c(n.data):l(n.error)}catch(e){l(e)}}}),n?.signal?.addEventListener(`abort`,()=>{p(n?.signal?.reason)});let m=n?.timeout??6e4;this._setupTimeout(d,m,n?.maxTotalTimeout,()=>p($.fromError(Q.RequestTimeout,`Request timed out`,{timeout:m})),n?.resetTimeoutOnProgress??!1);let h=s?.taskId;h?(this._requestResolvers.set(d,e=>{let t=this._responseHandlers.get(d);t?t(e):this._onerror(Error(`Response handler missing for side-channeled request ${d}`))}),this._enqueueTaskMessage(h,{type:`request`,message:f,timestamp:Date.now()}).catch(e=>{this._cleanupTimeout(d),l(e)})):this._transport.send(f,{relatedRequestId:r,resumptionToken:i,onresumptiontoken:a}).catch(e=>{this._cleanupTimeout(d),l(e)})})}async getTask(e,t){return this.request({method:`tasks/get`,params:e},Pd,t)}async getTaskResult(e,t,n){return this.request({method:`tasks/result`,params:e},t,n)}async listTasks(e,t){return this.request({method:`tasks/list`,params:e},Ld,t)}async cancelTask(e,t){return this.request({method:`tasks/cancel`,params:e},zd,t)}async notification(e,t){if(!this._transport)throw Error(`Not connected`);this.assertNotificationCapability(e.method);let n=t?.relatedTask?.taskId;if(n){let r={...e,jsonrpc:`2.0`,params:{...e.params,_meta:{...e.params?._meta||{},[zu]:t.relatedTask}}};await this._enqueueTaskMessage(n,{type:`notification`,message:r,timestamp:Date.now()});return}if((this._options?.debouncedNotificationMethods??[]).includes(e.method)&&!e.params&&!t?.relatedRequestId&&!t?.relatedTask){if(this._pendingDebouncedNotifications.has(e.method))return;this._pendingDebouncedNotifications.add(e.method),Promise.resolve().then(()=>{if(this._pendingDebouncedNotifications.delete(e.method),!this._transport)return;let n={...e,jsonrpc:`2.0`};t?.relatedTask&&(n={...n,params:{...n.params,_meta:{...n.params?._meta||{},[zu]:t.relatedTask}}}),this._transport?.send(n,t).catch(e=>this._onerror(e))});return}let r={...e,jsonrpc:`2.0`};t?.relatedTask&&(r={...r,params:{...r.params,_meta:{...r.params?._meta||{},[zu]:t.relatedTask}}}),await this._transport.send(r,t)}setRequestHandler(e,t){let n=xp(e);this.assertRequestHandlerCapability(n),this._requestHandlers.set(n,(n,r)=>{let i=Sp(e,n);return Promise.resolve(t(i,r))})}removeRequestHandler(e){this._requestHandlers.delete(e)}assertCanSetRequestHandler(e){if(this._requestHandlers.has(e))throw Error(`A request handler for ${e} already exists, which would be overridden`)}setNotificationHandler(e,t){let n=xp(e);this._notificationHandlers.set(n,n=>{let r=Sp(e,n);return Promise.resolve(t(r))})}removeNotificationHandler(e){this._notificationHandlers.delete(e)}_cleanupTaskProgressHandler(e){let t=this._taskProgressTokens.get(e);t!==void 0&&(this._progressHandlers.delete(t),this._taskProgressTokens.delete(e))}async _enqueueTaskMessage(e,t,n){if(!this._taskStore||!this._taskMessageQueue)throw Error(`Cannot enqueue task message: taskStore and taskMessageQueue are not configured`);let r=this._options?.maxTaskQueueSize;await this._taskMessageQueue.enqueue(e,t,n,r)}async _clearTaskQueue(e,t){if(this._taskMessageQueue){let n=await this._taskMessageQueue.dequeueAll(e,t);for(let t of n)if(t.type===`request`&&Qu(t.message)){let n=t.message.id,r=this._requestResolvers.get(n);r?(r(new $(Q.InternalError,`Task cancelled or completed`)),this._requestResolvers.delete(n)):this._onerror(Error(`Resolver missing for request ${n} during task ${e} cleanup`))}}}async _waitForTaskUpdate(e,t){let n=this._options?.defaultTaskPollInterval??1e3;try{let t=await this._taskStore?.getTask(e);t?.pollInterval&&(n=t.pollInterval)}catch{}return new Promise((e,r)=>{if(t.aborted){r(new $(Q.InvalidRequest,`Request cancelled`));return}let i=setTimeout(e,n);t.addEventListener(`abort`,()=>{clearTimeout(i),r(new $(Q.InvalidRequest,`Request cancelled`))},{once:!0})})}requestTaskStore(e,t){let n=this._taskStore;if(!n)throw Error(`No task store configured`);return{createTask:async r=>{if(!e)throw Error(`No request provided`);return await n.createTask(r,e.id,{method:e.method,params:e.params},t)},getTask:async e=>{let r=await n.getTask(e,t);if(!r)throw new $(Q.InvalidParams,`Failed to retrieve task: Task not found`);return r},storeTaskResult:async(e,r,i)=>{await n.storeTaskResult(e,r,i,t);let a=await n.getTask(e,t);if(a){let t=Md.parse({method:`notifications/tasks/status`,params:a});await this.notification(t),vp(a.status)&&this._cleanupTaskProgressHandler(e)}},getTaskResult:e=>n.getTaskResult(e,t),updateTaskStatus:async(e,r,i)=>{let a=await n.getTask(e,t);if(!a)throw new $(Q.InvalidParams,`Task "${e}" not found - it may have been cleaned up`);if(vp(a.status))throw new $(Q.InvalidParams,`Cannot update task "${e}" from terminal status "${a.status}" to "${r}". Terminal states (completed, failed, cancelled) cannot transition to other states.`);await n.updateTaskStatus(e,r,i,t);let o=await n.getTask(e,t);if(o){let t=Md.parse({method:`notifications/tasks/status`,params:o});await this.notification(t),vp(o.status)&&this._cleanupTaskProgressHandler(e)}},listTasks:e=>n.listTasks(e,t)}}};function wp(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Tp(e,t){let n={...e};for(let e in t){let r=e,i=t[r];if(i===void 0)continue;let a=n[r];wp(a)&&wp(i)?n[r]={...a,...i}:n[r]=i}return n}var Ep=class{compile(e){throw Error(`[WebMCP] Ajv stub was invoked. This indicates the MCP SDK is bypassing PolyfillJsonSchemaValidator. Please report this as a bug.`)}getSchema(e){}errorsText(e){return``}};function Dp(){return new Ep({strict:!1,validateFormats:!0,validateSchema:!1,allErrors:!0})}var Op=class{constructor(e){this._ajv=e??Dp()}getValidator(e){let t=`$id`in e&&typeof e.$id==`string`?this._ajv.getSchema(e.$id)??this._ajv.compile(e):this._ajv.compile(e);return e=>t(e)?{valid:!0,data:e,errorMessage:void 0}:{valid:!1,data:void 0,errorMessage:this._ajv.errorsText(t.errors)}}};function kp(e,t,n){if(!e)throw Error(`${n} does not support task creation (required for ${t})`);switch(t){case`tools/call`:if(!e.tools?.call)throw Error(`${n} does not support task creation for tools/call (required for ${t})`);break;default:break}}function Ap(e,t,n){if(!e)throw Error(`${n} does not support task creation (required for ${t})`);switch(t){case`sampling/createMessage`:if(!e.sampling?.createMessage)throw Error(`${n} does not support task creation for sampling/createMessage (required for ${t})`);break;case`elicitation/create`:if(!e.elicitation?.create)throw Error(`${n} does not support task creation for elicitation/create (required for ${t})`);break;default:break}}var jp=class{constructor(e){this._server=e}requestStream(e,t,n){return this._server.requestStream(e,t,n)}async getTask(e,t){return this._server.getTask({taskId:e},t)}async getTaskResult(e,t,n){return this._server.getTaskResult({taskId:e},t,n)}async listTasks(e,t){return this._server.listTasks(e?{cursor:e}:void 0,t)}async cancelTask(e,t){return this._server.cancelTask({taskId:e},t)}},Mp=class extends Cp{constructor(e,t){super(t),this._serverInfo=e,this._loggingLevels=new Map,this.LOG_LEVEL_SEVERITY=new Map(Pf.options.map((e,t)=>[e,t])),this.isMessageIgnored=(e,t)=>{let n=this._loggingLevels.get(t);return n?this.LOG_LEVEL_SEVERITY.get(e)<this.LOG_LEVEL_SEVERITY.get(n):!1},this._capabilities=t?.capabilities??{},this._instructions=t?.instructions,this._jsonSchemaValidator=t?.jsonSchemaValidator??new Op,this.setRequestHandler(_d,e=>this._oninitialize(e)),this.setNotificationHandler(bd,()=>this.oninitialized?.()),this._capabilities.logging&&this.setRequestHandler(If,async(e,t)=>{let n=t.sessionId||t.requestInfo?.headers[`mcp-session-id`]||void 0,{level:r}=e.params,i=Pf.safeParse(r);return i.success&&this._loggingLevels.set(n,i.data),{}})}get experimental(){return this._experimental||={tasks:new jp(this)},this._experimental}registerCapabilities(e){if(this.transport)throw Error(`Cannot register capabilities after connecting to transport`);this._capabilities=Tp(this._capabilities,e)}setRequestHandler(e,t){let n=ju(e)?.method;if(!n)throw Error(`Schema is missing a method literal`);let r;if(Du(n)){let e=n;r=e._zod?.def?.value??e.value}else{let e=n;r=e._def?.value??e.value}if(typeof r!=`string`)throw Error(`Schema method literal must be a string`);return r===`tools/call`?super.setRequestHandler(e,async(e,n)=>{let r=ku(Mf,e);if(!r.success){let e=r.error instanceof Error?r.error.message:String(r.error);throw new $(Q.InvalidParams,`Invalid tools/call request: ${e}`)}let{params:i}=r.data,a=await Promise.resolve(t(e,n));if(i.task){let e=ku(Ad,a);if(!e.success){let t=e.error instanceof Error?e.error.message:String(e.error);throw new $(Q.InvalidParams,`Invalid task creation result: ${t}`)}return e.data}let o=ku(Af,a);if(!o.success){let e=o.error instanceof Error?o.error.message:String(o.error);throw new $(Q.InvalidParams,`Invalid tools/call result: ${e}`)}return o.data}):super.setRequestHandler(e,t)}assertCapabilityForMethod(e){switch(e){case`sampling/createMessage`:if(!this._clientCapabilities?.sampling)throw Error(`Client does not support sampling (required for ${e})`);break;case`elicitation/create`:if(!this._clientCapabilities?.elicitation)throw Error(`Client does not support elicitation (required for ${e})`);break;case`roots/list`:if(!this._clientCapabilities?.roots)throw Error(`Client does not support listing roots (required for ${e})`);break;case`ping`:break}}assertNotificationCapability(e){switch(e){case`notifications/message`:if(!this._capabilities.logging)throw Error(`Server does not support logging (required for ${e})`);break;case`notifications/resources/updated`:case`notifications/resources/list_changed`:if(!this._capabilities.resources)throw Error(`Server does not support notifying about resources (required for ${e})`);break;case`notifications/tools/list_changed`:if(!this._capabilities.tools)throw Error(`Server does not support notifying of tool list changes (required for ${e})`);break;case`notifications/prompts/list_changed`:if(!this._capabilities.prompts)throw Error(`Server does not support notifying of prompt list changes (required for ${e})`);break;case`notifications/elicitation/complete`:if(!this._clientCapabilities?.elicitation?.url)throw Error(`Client does not support URL elicitation (required for ${e})`);break;case`notifications/cancelled`:break;case`notifications/progress`:break}}assertRequestHandlerCapability(e){if(this._capabilities)switch(e){case`completion/complete`:if(!this._capabilities.completions)throw Error(`Server does not support completions (required for ${e})`);break;case`logging/setLevel`:if(!this._capabilities.logging)throw Error(`Server does not support logging (required for ${e})`);break;case`prompts/get`:case`prompts/list`:if(!this._capabilities.prompts)throw Error(`Server does not support prompts (required for ${e})`);break;case`resources/list`:case`resources/templates/list`:case`resources/read`:if(!this._capabilities.resources)throw Error(`Server does not support resources (required for ${e})`);break;case`tools/call`:case`tools/list`:if(!this._capabilities.tools)throw Error(`Server does not support tools (required for ${e})`);break;case`tasks/get`:case`tasks/list`:case`tasks/result`:case`tasks/cancel`:if(!this._capabilities.tasks)throw Error(`Server does not support tasks capability (required for ${e})`);break;case`ping`:case`initialize`:break}}assertTaskCapability(e){Ap(this._clientCapabilities?.tasks?.requests,e,`Client`)}assertTaskHandlerCapability(e){this._capabilities&&kp(this._capabilities.tasks?.requests,e,`Server`)}async _oninitialize(e){let t=e.params.protocolVersion;return this._clientCapabilities=e.params.capabilities,this._clientVersion=e.params.clientInfo,{protocolVersion:Ru.includes(t)?t:Lu,capabilities:this.getCapabilities(),serverInfo:this._serverInfo,...this._instructions&&{instructions:this._instructions}}}getClientCapabilities(){return this._clientCapabilities}getClientVersion(){return this._clientVersion}getCapabilities(){return this._capabilities}async ping(){return this.request({method:`ping`},od)}async createMessage(e,t){if((e.tools||e.toolChoice)&&!this._clientCapabilities?.sampling?.tools)throw Error(`Client does not support sampling tools capability.`);if(e.messages.length>0){let t=e.messages[e.messages.length-1],n=Array.isArray(t.content)?t.content:[t.content],r=n.some(e=>e.type===`tool_result`),i=e.messages.length>1?e.messages[e.messages.length-2]:void 0,a=i?Array.isArray(i.content)?i.content:[i.content]:[],o=a.some(e=>e.type===`tool_use`);if(r){if(n.some(e=>e.type!==`tool_result`))throw Error(`The last message must contain only tool_result content if any is present`);if(!o)throw Error(`tool_result blocks are not matching any tool_use from the previous message`)}if(o){let e=new Set(a.filter(e=>e.type===`tool_use`).map(e=>e.id)),t=new Set(n.filter(e=>e.type===`tool_result`).map(e=>e.toolUseId));if(e.size!==t.size||![...e].every(e=>t.has(e)))throw Error(`ids of tool_result blocks and tool_use blocks from previous message do not match`)}}return e.tools?this.request({method:`sampling/createMessage`,params:e},Jf,t):this.request({method:`sampling/createMessage`,params:e},qf,t)}async elicitInput(e,t){switch(e.mode??`form`){case`url`:{if(!this._clientCapabilities?.elicitation?.url)throw Error(`Client does not support url elicitation.`);let n=e;return this.request({method:`elicitation/create`,params:n},ap,t)}case`form`:{if(!this._clientCapabilities?.elicitation?.form)throw Error(`Client does not support form elicitation.`);let n=e.mode===`form`?e:{...e,mode:`form`},r=await this.request({method:`elicitation/create`,params:n},ap,t);if(r.action===`accept`&&r.content&&n.requestedSchema)try{let e=this._jsonSchemaValidator.getValidator(n.requestedSchema)(r.content);if(!e.valid)throw new $(Q.InvalidParams,`Elicitation response content does not match requested schema: ${e.errorMessage}`)}catch(e){throw e instanceof $?e:new $(Q.InternalError,`Error validating elicitation response: ${e instanceof Error?e.message:String(e)}`)}return r}}}createElicitationCompletionNotifier(e,t){if(!this._clientCapabilities?.elicitation?.url)throw Error(`Client does not support URL elicitation (required for notifications/elicitation/complete)`);return()=>this.notification({method:`notifications/elicitation/complete`,params:{elicitationId:e}},t)}async listRoots(e,t){return this.request({method:`roots/list`,params:e},hp,t)}async sendLoggingMessage(e,t){if(this._capabilities.logging&&!this.isMessageIgnored(e.level,t))return this.notification({method:`notifications/message`,params:e})}async sendResourceUpdated(e){return this.notification({method:`notifications/resources/updated`,params:e})}async sendResourceListChanged(){return this.notification({method:`notifications/resources/list_changed`})}async sendToolListChanged(){return this.notification({method:`notifications/tools/list_changed`})}async sendPromptListChanged(){return this.notification({method:`notifications/prompts/list_changed`})}};let Np=Symbol.for(`mcp.completable`);function Pp(e){return!!e&&typeof e==`object`&&Np in e}function Fp(e){return e[Np]?.complete}var Ip;(function(e){e.Completable=`McpCompletable`})(Ip||={});let Lp=/^[A-Za-z0-9._-]{1,128}$/;function Rp(e){let t=[];if(e.length===0)return{isValid:!1,warnings:[`Tool name cannot be empty`]};if(e.length>128)return{isValid:!1,warnings:[`Tool name exceeds maximum length of 128 characters (current: ${e.length})`]};if(e.includes(` `)&&t.push(`Tool name contains spaces, which may cause parsing issues`),e.includes(`,`)&&t.push(`Tool name contains commas, which may cause parsing issues`),(e.startsWith(`-`)||e.endsWith(`-`))&&t.push(`Tool name starts or ends with a dash, which may cause parsing issues in some contexts`),(e.startsWith(`.`)||e.endsWith(`.`))&&t.push(`Tool name starts or ends with a dot, which may cause parsing issues in some contexts`),!Lp.test(e)){let n=e.split(``).filter(e=>!/[A-Za-z0-9._-]/.test(e)).filter((e,t,n)=>n.indexOf(e)===t);return t.push(`Tool name contains invalid characters: ${n.map(e=>`"${e}"`).join(`, `)}`,`Allowed characters are: A-Z, a-z, 0-9, underscore (_), dash (-), and dot (.)`),{isValid:!1,warnings:t}}return{isValid:!0,warnings:t}}function zp(e,t){if(t.length>0){console.warn(`Tool name validation warning for "${e}":`);for(let e of t)console.warn(` - ${e}`);console.warn(`Tool registration will proceed, but this may cause compatibility issues.`),console.warn(`Consider updating the tool name to conform to the MCP tool naming standard.`),console.warn(`See SEP: Specify Format for Tool Names (https://github.com/modelcontextprotocol/modelcontextprotocol/issues/986) for more details.`)}}function Bp(e){let t=Rp(e);return zp(e,t.warnings),t.isValid}var Vp=class{constructor(e){this._mcpServer=e}registerToolTask(e,t,n){let r={taskSupport:`required`,...t.execution};if(r.taskSupport===`forbidden`)throw Error(`Cannot register task-based tool '${e}' with taskSupport 'forbidden'. Use registerTool() instead.`);return this._mcpServer._createRegisteredTool(e,t.title,t.description,t.inputSchema,t.outputSchema,t.annotations,r,t._meta,n)}},Hp=class{constructor(e,t){this._registeredResources={},this._registeredResourceTemplates={},this._registeredTools={},this._registeredPrompts={},this._toolHandlersInitialized=!1,this._completionHandlerInitialized=!1,this._resourceHandlersInitialized=!1,this._promptHandlersInitialized=!1,this.server=new Mp(e,t)}get experimental(){return this._experimental||={tasks:new Vp(this)},this._experimental}async connect(e){return await this.server.connect(e)}async close(){await this.server.close()}setToolRequestHandlers(){this._toolHandlersInitialized||=(this.server.assertCanSetRequestHandler(Yp(Of)),this.server.assertCanSetRequestHandler(Yp(Mf)),this.server.registerCapabilities({tools:{listChanged:!0}}),this.server.setRequestHandler(Of,()=>({tools:Object.entries(this._registeredTools).filter(([,e])=>e.enabled).map(([e,t])=>{let n={name:e,title:t.title,description:t.description,inputSchema:(()=>{let e=Mu(t.inputSchema);return e?bp(e,{strictUnions:!0,pipeStrategy:`input`}):Up})(),annotations:t.annotations,execution:t.execution,_meta:t._meta};if(t.outputSchema){let e=Mu(t.outputSchema);e&&(n.outputSchema=bp(e,{strictUnions:!0,pipeStrategy:`output`}))}return n})})),this.server.setRequestHandler(Mf,async(e,t)=>{try{let n=this._registeredTools[e.params.name];if(!n)throw new $(Q.InvalidParams,`Tool ${e.params.name} not found`);if(!n.enabled)throw new $(Q.InvalidParams,`Tool ${e.params.name} disabled`);let r=!!e.params.task,i=n.execution?.taskSupport,a=`createTask`in n.handler;if((i===`required`||i===`optional`)&&!a)throw new $(Q.InternalError,`Tool ${e.params.name} has taskSupport '${i}' but was not registered with registerToolTask`);if(i===`required`&&!r)throw new $(Q.MethodNotFound,`Tool ${e.params.name} requires task augmentation (taskSupport: 'required')`);if(i===`optional`&&!r&&a)return await this.handleAutomaticTaskPolling(n,e,t);let o=await this.validateToolInput(n,e.params.arguments,e.params.name),s=await this.executeToolHandler(n,o,t);return r||await this.validateToolOutput(n,s,e.params.name),s}catch(e){if(e instanceof $&&e.code===Q.UrlElicitationRequired)throw e;return this.createToolError(e instanceof Error?e.message:String(e))}}),!0)}createToolError(e){return{content:[{type:`text`,text:e}],isError:!0}}async validateToolInput(e,t,n){if(!e.inputSchema)return;let r=await Au(Mu(e.inputSchema)??e.inputSchema,t);if(!r.success){let e=Nu(`error`in r?r.error:`Unknown error`);throw new $(Q.InvalidParams,`Input validation error: Invalid arguments for tool ${n}: ${e}`)}return r.data}async validateToolOutput(e,t,n){if(!e.outputSchema||!(`content`in t)||t.isError)return;if(!t.structuredContent)throw new $(Q.InvalidParams,`Output validation error: Tool ${n} has an output schema but no structured content was provided`);let r=await Au(Mu(e.outputSchema),t.structuredContent);if(!r.success){let e=Nu(`error`in r?r.error:`Unknown error`);throw new $(Q.InvalidParams,`Output validation error: Invalid structured content for tool ${n}: ${e}`)}}async executeToolHandler(e,t,n){let r=e.handler;if(`createTask`in r){if(!n.taskStore)throw Error(`No task store provided.`);let i={...n,taskStore:n.taskStore};if(e.inputSchema){let e=r;return await Promise.resolve(e.createTask(t,i))}else{let e=r;return await Promise.resolve(e.createTask(i))}}if(e.inputSchema){let e=r;return await Promise.resolve(e(t,n))}else{let e=r;return await Promise.resolve(e(n))}}async handleAutomaticTaskPolling(e,t,n){if(!n.taskStore)throw Error(`No task store provided for task-capable tool.`);let r=await this.validateToolInput(e,t.params.arguments,t.params.name),i=e.handler,a={...n,taskStore:n.taskStore},o=r?await Promise.resolve(i.createTask(r,a)):await Promise.resolve(i.createTask(a)),s=o.task.taskId,c=o.task,l=c.pollInterval??5e3;for(;c.status!==`completed`&&c.status!==`failed`&&c.status!==`cancelled`;){await new Promise(e=>setTimeout(e,l));let e=await n.taskStore.getTask(s);if(!e)throw new $(Q.InternalError,`Task ${s} not found during polling`);c=e}return await n.taskStore.getTaskResult(s)}setCompletionRequestHandler(){this._completionHandlerInitialized||=(this.server.assertCanSetRequestHandler(Yp(lp)),this.server.registerCapabilities({completions:{}}),this.server.setRequestHandler(lp,async e=>{switch(e.params.ref.type){case`ref/prompt`:return up(e),this.handlePromptCompletion(e,e.params.ref);case`ref/resource`:return dp(e),this.handleResourceCompletion(e,e.params.ref);default:throw new $(Q.InvalidParams,`Invalid completion reference: ${e.params.ref}`)}}),!0)}async handlePromptCompletion(e,t){let n=this._registeredPrompts[t.name];if(!n)throw new $(Q.InvalidParams,`Prompt ${t.name} not found`);if(!n.enabled)throw new $(Q.InvalidParams,`Prompt ${t.name} disabled`);if(!n.argsSchema)return Zp;let r=ju(n.argsSchema)?.[e.params.argument.name];if(!Pp(r))return Zp;let i=Fp(r);return i?Xp(await i(e.params.argument.value,e.params.context)):Zp}async handleResourceCompletion(e,t){let n=Object.values(this._registeredResourceTemplates).find(e=>e.resourceTemplate.uriTemplate.toString()===t.uri);if(!n){if(this._registeredResources[t.uri])return Zp;throw new $(Q.InvalidParams,`Resource template ${e.params.ref.uri} not found`)}let r=n.resourceTemplate.completeCallback(e.params.argument.name);return r?Xp(await r(e.params.argument.value,e.params.context)):Zp}setResourceRequestHandlers(){this._resourceHandlersInitialized||=(this.server.assertCanSetRequestHandler(Yp(Jd)),this.server.assertCanSetRequestHandler(Yp(Xd)),this.server.assertCanSetRequestHandler(Yp(ef)),this.server.registerCapabilities({resources:{listChanged:!0}}),this.server.setRequestHandler(Jd,async(e,t)=>{let n=Object.entries(this._registeredResources).filter(([e,t])=>t.enabled).map(([e,t])=>({uri:e,name:t.name,...t.metadata})),r=[];for(let e of Object.values(this._registeredResourceTemplates)){if(!e.resourceTemplate.listCallback)continue;let n=await e.resourceTemplate.listCallback(t);for(let t of n.resources)r.push({...e.metadata,...t})}return{resources:[...n,...r]}}),this.server.setRequestHandler(Xd,async()=>({resourceTemplates:Object.entries(this._registeredResourceTemplates).map(([e,t])=>({name:e,uriTemplate:t.resourceTemplate.uriTemplate.toString(),...t.metadata}))})),this.server.setRequestHandler(ef,async(e,t)=>{let n=new URL(e.params.uri),r=this._registeredResources[n.toString()];if(r){if(!r.enabled)throw new $(Q.InvalidParams,`Resource ${n} disabled`);return r.readCallback(n,t)}for(let e of Object.values(this._registeredResourceTemplates)){let r=e.resourceTemplate.uriTemplate.match(n.toString());if(r)return e.readCallback(n,r,t)}throw new $(Q.InvalidParams,`Resource ${n} not found`)}),!0)}setPromptRequestHandlers(){this._promptHandlersInitialized||=(this.server.assertCanSetRequestHandler(Yp(ff)),this.server.assertCanSetRequestHandler(Yp(hf)),this.server.registerCapabilities({prompts:{listChanged:!0}}),this.server.setRequestHandler(ff,()=>({prompts:Object.entries(this._registeredPrompts).filter(([,e])=>e.enabled).map(([e,t])=>({name:e,title:t.title,description:t.description,arguments:t.argsSchema?Jp(t.argsSchema):void 0}))})),this.server.setRequestHandler(hf,async(e,t)=>{let n=this._registeredPrompts[e.params.name];if(!n)throw new $(Q.InvalidParams,`Prompt ${e.params.name} not found`);if(!n.enabled)throw new $(Q.InvalidParams,`Prompt ${e.params.name} disabled`);if(n.argsSchema){let r=await Au(Mu(n.argsSchema),e.params.arguments);if(!r.success){let t=Nu(`error`in r?r.error:`Unknown error`);throw new $(Q.InvalidParams,`Invalid arguments for prompt ${e.params.name}: ${t}`)}let i=r.data,a=n.callback;return await Promise.resolve(a(i,t))}else{let e=n.callback;return await Promise.resolve(e(t))}}),!0)}resource(e,t,...n){let r;typeof n[0]==`object`&&(r=n.shift());let i=n[0];if(typeof t==`string`){if(this._registeredResources[t])throw Error(`Resource ${t} is already registered`);let n=this._createRegisteredResource(e,void 0,t,r,i);return this.setResourceRequestHandlers(),this.sendResourceListChanged(),n}else{if(this._registeredResourceTemplates[e])throw Error(`Resource template ${e} is already registered`);let n=this._createRegisteredResourceTemplate(e,void 0,t,r,i);return this.setResourceRequestHandlers(),this.sendResourceListChanged(),n}}registerResource(e,t,n,r){if(typeof t==`string`){if(this._registeredResources[t])throw Error(`Resource ${t} is already registered`);let i=this._createRegisteredResource(e,n.title,t,n,r);return this.setResourceRequestHandlers(),this.sendResourceListChanged(),i}else{if(this._registeredResourceTemplates[e])throw Error(`Resource template ${e} is already registered`);let i=this._createRegisteredResourceTemplate(e,n.title,t,n,r);return this.setResourceRequestHandlers(),this.sendResourceListChanged(),i}}_createRegisteredResource(e,t,n,r,i){let a={name:e,title:t,metadata:r,readCallback:i,enabled:!0,disable:()=>a.update({enabled:!1}),enable:()=>a.update({enabled:!0}),remove:()=>a.update({uri:null}),update:e=>{e.uri!==void 0&&e.uri!==n&&(delete this._registeredResources[n],e.uri&&(this._registeredResources[e.uri]=a)),e.name!==void 0&&(a.name=e.name),e.title!==void 0&&(a.title=e.title),e.metadata!==void 0&&(a.metadata=e.metadata),e.callback!==void 0&&(a.readCallback=e.callback),e.enabled!==void 0&&(a.enabled=e.enabled),this.sendResourceListChanged()}};return this._registeredResources[n]=a,a}_createRegisteredResourceTemplate(e,t,n,r,i){let a={resourceTemplate:n,title:t,metadata:r,readCallback:i,enabled:!0,disable:()=>a.update({enabled:!1}),enable:()=>a.update({enabled:!0}),remove:()=>a.update({name:null}),update:t=>{t.name!==void 0&&t.name!==e&&(delete this._registeredResourceTemplates[e],t.name&&(this._registeredResourceTemplates[t.name]=a)),t.title!==void 0&&(a.title=t.title),t.template!==void 0&&(a.resourceTemplate=t.template),t.metadata!==void 0&&(a.metadata=t.metadata),t.callback!==void 0&&(a.readCallback=t.callback),t.enabled!==void 0&&(a.enabled=t.enabled),this.sendResourceListChanged()}};this._registeredResourceTemplates[e]=a;let o=n.uriTemplate.variableNames;return Array.isArray(o)&&o.some(e=>!!n.completeCallback(e))&&this.setCompletionRequestHandler(),a}_createRegisteredPrompt(e,t,n,r,i){let a={title:t,description:n,argsSchema:r===void 0?void 0:Ou(r),callback:i,enabled:!0,disable:()=>a.update({enabled:!1}),enable:()=>a.update({enabled:!0}),remove:()=>a.update({name:null}),update:t=>{t.name!==void 0&&t.name!==e&&(delete this._registeredPrompts[e],t.name&&(this._registeredPrompts[t.name]=a)),t.title!==void 0&&(a.title=t.title),t.description!==void 0&&(a.description=t.description),t.argsSchema!==void 0&&(a.argsSchema=Ou(t.argsSchema)),t.callback!==void 0&&(a.callback=t.callback),t.enabled!==void 0&&(a.enabled=t.enabled),this.sendPromptListChanged()}};return this._registeredPrompts[e]=a,r&&Object.values(r).some(e=>Pp(e instanceof Hs?e._def?.innerType:e))&&this.setCompletionRequestHandler(),a}_createRegisteredTool(e,t,n,r,i,a,o,s,c){Bp(e);let l={title:t,description:n,inputSchema:qp(r),outputSchema:qp(i),annotations:a,execution:o,_meta:s,handler:c,enabled:!0,disable:()=>l.update({enabled:!1}),enable:()=>l.update({enabled:!0}),remove:()=>l.update({name:null}),update:t=>{t.name!==void 0&&t.name!==e&&(typeof t.name==`string`&&Bp(t.name),delete this._registeredTools[e],t.name&&(this._registeredTools[t.name]=l)),t.title!==void 0&&(l.title=t.title),t.description!==void 0&&(l.description=t.description),t.paramsSchema!==void 0&&(l.inputSchema=Ou(t.paramsSchema)),t.outputSchema!==void 0&&(l.outputSchema=Ou(t.outputSchema)),t.callback!==void 0&&(l.handler=t.callback),t.annotations!==void 0&&(l.annotations=t.annotations),t._meta!==void 0&&(l._meta=t._meta),t.enabled!==void 0&&(l.enabled=t.enabled),this.sendToolListChanged()}};return this._registeredTools[e]=l,this.setToolRequestHandlers(),this.sendToolListChanged(),l}tool(e,...t){if(this._registeredTools[e])throw Error(`Tool ${e} is already registered`);let n,r,i;if(typeof t[0]==`string`&&(n=t.shift()),t.length>1){let e=t[0];Kp(e)?(r=t.shift(),t.length>1&&typeof t[0]==`object`&&t[0]!==null&&!Kp(t[0])&&(i=t.shift())):typeof e==`object`&&e&&(i=t.shift())}let a=t[0];return this._createRegisteredTool(e,void 0,n,r,void 0,i,{taskSupport:`forbidden`},void 0,a)}registerTool(e,t,n){if(this._registeredTools[e])throw Error(`Tool ${e} is already registered`);let{title:r,description:i,inputSchema:a,outputSchema:o,annotations:s,_meta:c}=t;return this._createRegisteredTool(e,r,i,a,o,s,{taskSupport:`forbidden`},c,n)}prompt(e,...t){if(this._registeredPrompts[e])throw Error(`Prompt ${e} is already registered`);let n;typeof t[0]==`string`&&(n=t.shift());let r;t.length>1&&(r=t.shift());let i=t[0],a=this._createRegisteredPrompt(e,void 0,n,r,i);return this.setPromptRequestHandlers(),this.sendPromptListChanged(),a}registerPrompt(e,t,n){if(this._registeredPrompts[e])throw Error(`Prompt ${e} is already registered`);let{title:r,description:i,argsSchema:a}=t,o=this._createRegisteredPrompt(e,r,i,a,n);return this.setPromptRequestHandlers(),this.sendPromptListChanged(),o}isConnected(){return this.server.transport!==void 0}async sendLoggingMessage(e,t){return this.server.sendLoggingMessage(e,t)}sendResourceListChanged(){this.isConnected()&&this.server.sendResourceListChanged()}sendToolListChanged(){this.isConnected()&&this.server.sendToolListChanged()}sendPromptListChanged(){this.isConnected()&&this.server.sendPromptListChanged()}};let Up={type:`object`,properties:{}};function Wp(e){return typeof e==`object`&&!!e&&`parse`in e&&typeof e.parse==`function`&&`safeParse`in e&&typeof e.safeParse==`function`}function Gp(e){return`_def`in e||`_zod`in e||Wp(e)}function Kp(e){return typeof e!=`object`||!e||Gp(e)?!1:Object.keys(e).length===0?!0:Object.values(e).some(Wp)}function qp(e){if(e)return Kp(e)?Ou(e):e}function Jp(e){let t=ju(e);return t?Object.entries(t).map(([e,t])=>({name:e,description:Pu(t),required:!Fu(t)})):[]}function Yp(e){let t=ju(e)?.method;if(!t)throw Error(`Schema is missing a method literal`);let n=Iu(t);if(typeof n==`string`)return n;throw Error(`Schema method literal must be a string`)}function Xp(e){return{completion:{values:e.slice(0,100),total:e.length,hasMore:e.length>100}}}let Zp={completion:{values:[],hasMore:!1}};var Qp=class{getValidator(e){return t=>{if(!J(t))return{valid:!1,data:void 0,errorMessage:`expected object arguments`};let n=uu(t,e);return n?{valid:!1,data:void 0,errorMessage:n.message}:{valid:!0,data:t,errorMessage:void 0}}}};let $p={type:`object`,properties:{}},em=`__isBrowserMcpServer`;function tm(e){return!!e&&typeof e==`object`&&!Array.isArray(e)}function nm(e){return tm(e)&&Array.isArray(e.content)}function rm(e){return e===null||typeof e==`string`||typeof e==`number`||typeof e==`boolean`}function im(e){return rm(e)?Number.isFinite(e)||typeof e!=`number`:Array.isArray(e)?e.every(e=>im(e)):tm(e)?Object.values(e).every(e=>im(e)):!1}function am(e){if(!(!tm(e)||!im(e)))return e}function om(e){if(typeof e==`string`)return e;try{return JSON.stringify(e)??String(e)}catch{return String(e)}}function sm(e){if(nm(e))return e;let t=am(e);return{content:[{type:`text`,text:om(e)}],...t?{structuredContent:t}:{},isError:!1}}function cm(e){return e?.signal?e:{...e,signal:AbortSignal.timeout(1e4)}}var lm=class extends Hp{[em]=!0;native;_promptSchemas=new Map;_jsonValidator;_publicMethodsBound=!1;constructor(e,t){let n=new Qp,r={capabilities:Tp(t?.capabilities||{},{tools:{listChanged:!0},resources:{listChanged:!0},prompts:{listChanged:!0}}),jsonSchemaValidator:t?.jsonSchemaValidator??n};super(e,r),this._jsonValidator=n,this.native=t?.native,this.bindPublicApiMethods()}bindPublicApiMethods(){this._publicMethodsBound||=(this.registerTool=this.registerTool.bind(this),this.unregisterTool=this.unregisterTool.bind(this),this.provideContext=this.provideContext.bind(this),this.clearContext=this.clearContext.bind(this),this.listTools=this.listTools.bind(this),this.callTool=this.callTool.bind(this),this.executeTool=this.executeTool.bind(this),this.registerResource=this.registerResource.bind(this),this.listResources=this.listResources.bind(this),this.readResource=this.readResource.bind(this),this.registerPrompt=this.registerPrompt.bind(this),this.listPrompts=this.listPrompts.bind(this),this.getPrompt=this.getPrompt.bind(this),this.createMessage=this.createMessage.bind(this),this.elicitInput=this.elicitInput.bind(this),!0)}get _parentTools(){return this._registeredTools}get _parentResources(){return this._registeredResources}get _parentPrompts(){return this._registeredPrompts}toTransportSchema(e,t=!0){if(!e||typeof e!=`object`)return t?(console.warn(`[BrowserMcpServer] toTransportSchema received non-object schema (${typeof e}), using default`),$p):{};let n=Mu(e),r=n?bp(n,{strictUnions:!0,pipeStrategy:`input`}):e;return Object.keys(r).length===0?t?$p:r:t&&r.type===void 0?{type:`object`,...r}:r}isZodSchema(e){if(!e||typeof e!=`object`)return!1;let t=e;return`_zod`in t||`_def`in t}getNativeToolsApi(){if(!this.native)return;let e=this.native;if(!(typeof e.listTools!=`function`||typeof e.callTool!=`function`))return e}registerToolInServer(e){let t=this.toTransportSchema(e.inputSchema);return super.registerTool(e.name,{description:e.description,inputSchema:t,...e.outputSchema?{outputSchema:e.outputSchema}:{},...e.annotations?{annotations:e.annotations}:{}},async t=>sm(await e.execute(t,{requestUserInteraction:async e=>e()}))),{unregister:()=>this.unregisterTool(e.name)}}backfillTools(e,t){let n=0;for(let r of e){if(!r?.name||this._parentTools[r.name])continue;let e={name:r.name,description:r.description??``,inputSchema:r.inputSchema??$p,execute:async e=>t(r.name,e)};r.outputSchema&&(e.outputSchema=r.outputSchema),r.annotations&&(e.annotations=r.annotations),this.registerToolInServer(e),n++}return n}registerTool(e){this.native&&this.native.registerTool(e);try{return this.registerToolInServer(e)}catch(t){if(this.native)try{this.native.unregisterTool(e.name)}catch(e){console.error(`[BrowserMcpServer] Rollback of native tool registration failed:`,e)}throw t}}syncNativeTools(){let e=this.getNativeToolsApi();if(!e)return 0;let t=e.callTool.bind(e);return this.backfillTools(e.listTools(),async(e,n)=>t({name:e,arguments:n}))}unregisterTool(e){this._parentTools[e]?.remove(),this.native&&this.native.unregisterTool(e)}registerResource(e){let t=super.registerResource(e.name,e.uri,{...e.description!==void 0&&{description:e.description},...e.mimeType!==void 0&&{mimeType:e.mimeType}},async t=>({contents:(await e.read(t)).contents}));return{unregister:()=>t.remove()}}registerPrompt(e){e.argsSchema&&this._promptSchemas.set(e.name,e.argsSchema);let t=super.registerPrompt(e.name,{...e.description!==void 0&&{description:e.description}},async t=>({messages:(await e.get(t)).messages}));return{unregister:()=>{this._promptSchemas.delete(e.name),t.remove()}}}provideContext(e){for(let e of Object.values(this._parentTools))e.remove();this.native&&this.native.clearContext();for(let t of e?.tools??[])this.registerTool(t)}clearContext(){for(let e of Object.values(this._parentTools))e.remove();this.native&&this.native.clearContext()}listResources(){return Object.entries(this._parentResources).filter(([,e])=>e.enabled).map(([e,t])=>({uri:e,name:t.name,...t.metadata}))}async readResource(e){let t=this._parentResources[e];if(!t)throw Error(`Resource not found: ${e}`);return t.readCallback(new URL(e),{})}listPrompts(){return Object.entries(this._parentPrompts).filter(([,e])=>e.enabled).map(([e,t])=>{let n=this._promptSchemas.get(e);return{name:e,...t.description!==void 0&&{description:t.description},...n?.properties?{arguments:Object.entries(n.properties).map(([e,t])=>({name:e,...typeof t==`object`&&t&&`description`in t?{description:t.description}:{},...n.required?.includes(e)?{required:!0}:{}}))}:{}}})}async getPrompt(e,t={}){let n=this._parentPrompts[e];if(!n)throw Error(`Prompt not found: ${e}`);let r=this._promptSchemas.get(e);if(r){let n=this._jsonValidator.getValidator(r)(t);if(!n.valid)throw Error(`Invalid arguments for prompt ${e}: ${n.errorMessage}`)}return n.callback(t,{})}listTools(){return Object.entries(this._parentTools).filter(([,e])=>e.enabled).map(([e,t])=>{let n={name:e,description:t.description??``,inputSchema:this.toTransportSchema(t.inputSchema??$p)};return t.outputSchema&&(n.outputSchema=this.toTransportSchema(t.outputSchema,!1)),t.annotations&&(n.annotations=t.annotations),n})}async validateToolInput(e,t,n){if(!e.inputSchema)return;if(this.isZodSchema(e.inputSchema)){let r=await Au(e.inputSchema,t??{});if(!r.success)throw Error(`Invalid arguments for tool ${n}: ${Nu(r.error)}`);return r.data}let r=this._jsonValidator.getValidator(e.inputSchema)(t??{});if(!r.valid)throw Error(`Invalid arguments for tool ${n}: ${r.errorMessage}`);return r.data}async validateToolOutput(e,t,n){if(!e.outputSchema)return;let r=t;if(!(`content`in r)||r.isError||!r.structuredContent)return;if(this.isZodSchema(e.outputSchema)){let t=await Au(e.outputSchema,r.structuredContent);if(!t.success)throw Error(`Output validation error: Invalid structured content for tool ${n}: ${Nu(t.error)}`);return}let i=this._jsonValidator.getValidator(e.outputSchema)(r.structuredContent);if(!i.valid)throw Error(`Output validation error: Invalid structured content for tool ${n}: ${i.errorMessage}`)}async callTool(e){let t=this._parentTools[e.name];if(!t)throw Error(`Tool not found: ${e.name}`);return t.handler(e.arguments??{},{})}async executeTool(e,t={}){return this.callTool({name:e,arguments:t})}async connect(e){return this.setToolRequestHandlers(),this.setResourceRequestHandlers(),this.setPromptRequestHandlers(),this.server.setRequestHandler(Of,()=>({tools:this.listTools()})),this.server.setRequestHandler(ff,()=>({prompts:this.listPrompts()})),this.server.setRequestHandler(hf,async e=>{let t=this._parentPrompts[e.params.name];if(!t)throw Error(`Prompt ${e.params.name} not found`);if(!t.enabled)throw Error(`Prompt ${e.params.name} disabled`);let n=this._promptSchemas.get(e.params.name);if(n){let r=this._jsonValidator.getValidator(n)(e.params.arguments??{});if(!r.valid)throw Error(`Invalid arguments for prompt ${e.params.name}: ${r.errorMessage}`);return t.callback(e.params.arguments,{})}return t.callback({},{})}),super.connect(e)}async createMessage(e,t){return this.server.createMessage(e,cm(t))}async elicitInput(e,t){return this.server.elicitInput(e,cm(t))}};(function(e){return e.START=`start`,e.STARTED=`started`,e.STOP=`stop`,e.STOPPED=`stopped`,e.PING=`ping`,e.PONG=`pong`,e.ERROR=`error`,e.LIST_TOOLS=`list_tools`,e.CALL_TOOL=`call_tool`,e.TOOL_LIST_UPDATED=`tool_list_updated`,e.TOOL_LIST_UPDATED_ACK=`tool_list_updated_ack`,e.PROCESS_DATA=`process_data`,e.SERVER_STARTED=`server_started`,e.SERVER_STOPPED=`server_stopped`,e.ERROR_FROM_NATIVE_HOST=`error_from_native_host`,e.CONNECT_NATIVE=`connectNative`,e.PING_NATIVE=`ping_native`,e.DISCONNECT_NATIVE=`disconnect_native`,e})({}),{NAME:`com.chromemcp.nativehost`,DEFAULT_PORT:12306}.NAME;var um=class{_started=!1;_allowedOrigins;_channelId;_messageHandler;_clientOrigin;_serverReadyTimeout;_serverReadyRetryMs;onclose;onerror;onmessage;constructor(e){if(!e.allowedOrigins||e.allowedOrigins.length===0)throw Error(`At least one allowed origin must be specified`);this._allowedOrigins=e.allowedOrigins,this._channelId=e.channelId||`mcp-iframe`,this._serverReadyRetryMs=e.serverReadyRetryMs??250}async start(){if(this._started)throw Error(`Transport already started`);this._messageHandler=e=>{if(!this._allowedOrigins.includes(e.origin)&&!this._allowedOrigins.includes(`*`)||e.data?.channel!==this._channelId||e.data?.type!==`mcp`||e.data?.direction!==`client-to-server`)return;this._clientOrigin=e.origin;let t=e.data.payload;if(typeof t==`string`&&t===`mcp-check-ready`){this.broadcastServerReady();return}try{let e=ad.parse(t);this.onmessage?.(e)}catch(e){this.onerror?.(Error(`Invalid message: ${e instanceof Error?e.message:String(e)}`))}},window.addEventListener(`message`,this._messageHandler),this._started=!0,this.broadcastServerReady()}broadcastServerReady(){window.parent&&window.parent!==window?(window.parent.postMessage({channel:this._channelId,type:`mcp`,direction:`server-to-client`,payload:`mcp-server-ready`},`*`),this.clearServerReadyRetry()):this.scheduleServerReadyRetry()}scheduleServerReadyRetry(){this._serverReadyTimeout||=setTimeout(()=>{this._serverReadyTimeout=void 0,this._started&&this.broadcastServerReady()},this._serverReadyRetryMs)}clearServerReadyRetry(){this._serverReadyTimeout&&=(clearTimeout(this._serverReadyTimeout),void 0)}async send(e){if(!this._started)throw Error(`Transport not started`);if(!this._clientOrigin){console.debug(`[IframeChildTransport] No client connected, message not sent`);return}window.parent&&window.parent!==window?window.parent.postMessage({channel:this._channelId,type:`mcp`,direction:`server-to-client`,payload:e},this._clientOrigin):console.debug(`[IframeChildTransport] Not running in an iframe, message not sent`)}async close(){this._messageHandler&&window.removeEventListener(`message`,this._messageHandler),this._started=!1,this._clientOrigin&&window.parent&&window.parent!==window&&window.parent.postMessage({channel:this._channelId,type:`mcp`,direction:`server-to-client`,payload:`mcp-server-stopped`},`*`),this.clearServerReadyRetry(),this.onclose?.()}},dm=class{_started=!1;_allowedOrigins;_channelId;_messageHandler;_clientOrigin;_beforeUnloadHandler;_cleanupInterval;_pendingRequests=new Map;REQUEST_TIMEOUT_MS=3e5;onclose;onerror;onmessage;_resolveTargetOrigin(e){return e&&e!==`null`?e:`*`}constructor(e){if(!e.allowedOrigins||e.allowedOrigins.length===0)throw Error(`At least one allowed origin must be specified`);this._allowedOrigins=e.allowedOrigins,this._channelId=e.channelId||`mcp-default`}async start(){if(this._started)throw Error(`Transport already started`);this._messageHandler=e=>{if(!this._allowedOrigins.includes(e.origin)&&!this._allowedOrigins.includes(`*`)||e.data?.channel!==this._channelId||e.data?.type!==`mcp`||e.data?.direction!==`client-to-server`)return;this._clientOrigin=e.origin;let t=e.data.payload;if(typeof t==`string`&&t===`mcp-check-ready`){window.postMessage({channel:this._channelId,type:`mcp`,direction:`server-to-client`,payload:`mcp-server-ready`},this._resolveTargetOrigin(this._clientOrigin));return}try{let e=ad.parse(t);`method`in e&&`id`in e&&e.id!==void 0&&this._pendingRequests.set(e.id,{request:e,receivedAt:Date.now(),interruptedSent:!1}),this.onmessage?.(e)}catch(e){this.onerror?.(Error(`Invalid message: ${e instanceof Error?e.message:String(e)}`))}},window.addEventListener(`message`,this._messageHandler),this._started=!0,this._beforeUnloadHandler=()=>{this._handleBeforeUnload()},window.addEventListener(`beforeunload`,this._beforeUnloadHandler),this._cleanupInterval=setInterval(()=>{this._cleanupStaleRequests()},6e4),window.postMessage({channel:this._channelId,type:`mcp`,direction:`server-to-client`,payload:`mcp-server-ready`},`*`)}async send(e){if(!this._started)throw Error(`Transport not started`);if((`result`in e||`error`in e)&&e.id!==void 0){if(this._pendingRequests.get(e.id)?.interruptedSent){console.debug(`[TabServerTransport] Suppressing response for ${e.id} - interrupted response already sent`),this._pendingRequests.delete(e.id);return}this._pendingRequests.delete(e.id)}let t=this._resolveTargetOrigin(this._clientOrigin);window.postMessage({channel:this._channelId,type:`mcp`,direction:`server-to-client`,payload:e},t)}_handleBeforeUnload(){let e=Array.from(this._pendingRequests.entries()).reverse();for(let[t,n]of e){n.interruptedSent=!0;let e={jsonrpc:`2.0`,id:t,result:{content:[{type:`text`,text:`Tool execution interrupted by page navigation`}],metadata:{navigationInterrupted:!0,originalMethod:`method`in n.request?n.request.method:`unknown`,timestamp:Date.now()}}};try{window.postMessage({channel:this._channelId,type:`mcp`,direction:`server-to-client`,payload:e},this._resolveTargetOrigin(this._clientOrigin))}catch(e){console.error(`[TabServerTransport] Failed to send beforeunload response:`,e)}}this._pendingRequests.clear()}_cleanupStaleRequests(){let e=Date.now(),t=[];for(let[n,r]of this._pendingRequests)e-r.receivedAt>this.REQUEST_TIMEOUT_MS&&t.push(n);if(t.length>0){console.warn(`[TabServerTransport] Cleaning up ${t.length} stale requests`);for(let e of t)this._pendingRequests.delete(e)}}async close(){this._messageHandler&&window.removeEventListener(`message`,this._messageHandler),this._beforeUnloadHandler&&window.removeEventListener(`beforeunload`,this._beforeUnloadHandler),this._cleanupInterval!==void 0&&clearInterval(this._cleanupInterval),this._pendingRequests.clear(),this._started=!1,window.postMessage({channel:this._channelId,type:`mcp`,direction:`server-to-client`,payload:`mcp-server-stopped`},`*`),this.onclose?.()}};let fm=null;function pm(){return typeof window<`u`&&window.navigator!==void 0}function mm(e){try{Object.defineProperty(navigator,`modelContext`,{configurable:!0,enumerable:!0,writable:!1,value:e})}catch{Object.defineProperty(Object.getPrototypeOf(navigator),`modelContext`,{configurable:!0,enumerable:!0,get(){return e}})}navigator.modelContext!==e&&console.error(`[WebModelContext] Failed to replace navigator.modelContext.`,`Descriptor:`,Object.getOwnPropertyDescriptor(navigator,`modelContext`))}function hm(e){if(window.parent!==window&&e?.iframeServer!==!1){let{allowedOrigins:t,...n}=typeof e?.iframeServer==`object`?e.iframeServer:{};return new um({allowedOrigins:t??[`*`],...n})}if(e?.tabServer===!1)throw Error(`tabServer transport is disabled and iframe transport was not selected`);let{allowedOrigins:t,...n}=typeof e?.tabServer==`object`?e.tabServer:{};return new dm({allowedOrigins:t??[`*`],...n})}function gm(e){if(e)try{let t=JSON.parse(e);return!t||typeof t!=`object`||Array.isArray(t)?void 0:t}catch(e){console.warn(`[WebMCP] Failed to parse testing inputSchema JSON:`,e);return}}function _m(){let e=navigator.modelContextTesting;if(e){if(typeof e.getRegisteredTools==`function`)return{testingShim:e,tools:e.getRegisteredTools()};if(typeof e.listTools==`function`)return{testingShim:e,tools:e.listTools().map(e=>({name:e.name,description:e.description??``,inputSchema:gm(e.inputSchema)??{type:`object`,properties:{}}}))}}}function vm(e){let t=_m();if(!t)return 0;let{testingShim:n,tools:r}=t;return e.backfillTools(r,async(e,t)=>{let r=await n.executeTool(e,JSON.stringify(t??{}));if(r===null)return{content:[{type:`text`,text:`Tool execution interrupted by navigation`}],isError:!0};let i;try{i=JSON.parse(r)}catch(t){throw Error(`Failed to parse serialized tool response for ${e}: ${t instanceof Error?t.message:String(t)}`)}if(!i||typeof i!=`object`||Array.isArray(i))throw Error(`Invalid serialized tool response for ${e}`);return i})}function ym(e){if(!pm()||fm||navigator.modelContext?.[em])return;Tu({installTestingShim:e?.installTestingShim??`if-missing`});let t=navigator.modelContext;if(!t)throw Error(`navigator.modelContext is not available`);let n=new lm({name:`${window.location.hostname||`localhost`}-webmcp`,version:`1.0.0`},{native:t});n.syncNativeTools(),vm(n),mm(n);let r=hm(e?.transport);fm={native:t,server:n,transport:r},n.connect(r).catch(e=>{console.error(`[WebModelContext] Failed to connect MCP transport:`,e)})}function bm(){if(!fm)return;let{native:e,server:t,transport:n}=fm;fm=null,t.close(),n.close(),mm(e)}if(typeof window<`u`&&typeof document<`u`){let e=window.__webModelContextOptions;if(e?.autoInitialize!==!1)try{ym(e)}catch(e){console.error(`[WebModelContext] Auto-initialization failed:`,e)}}return e.cleanupWebModelContext=bm,e.initializeWebModelContext=ym,e})({});