@kunal_dutt/token-lens 0.2.55 → 0.2.57
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist-helper/core.js +3 -3
- package/package.json +1 -1
- package/server.mjs +24 -22
- package/token-lens.mcpb +0 -0
package/server.mjs
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { createRequire as __cr } from 'node:module'; const require = __cr(import.meta.url);
|
|
2
|
-
var c1=Object.create;var tg=Object.defineProperty;var u1=Object.getOwnPropertyDescriptor;var d1=Object.getOwnPropertyNames;var p1=Object.getPrototypeOf,m1=Object.prototype.hasOwnProperty;var j=(e,t)=>()=>{try{return t||e((t={exports:{}}).exports,t),t.exports}catch(r){throw t=0,r}},En=(e,t)=>{for(var r in t)tg(e,r,{get:t[r],enumerable:!0})},g1=(e,t,r,a)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of d1(t))!m1.call(e,n)&&n!==r&&tg(e,n,{get:()=>t[n],enumerable:!(a=u1(t,n))||a.enumerable});return e};var ng=(e,t,r)=>(r=e!=null?c1(p1(e)):{},g1(t||!e||!e.__esModule?tg(r,"default",{value:e,enumerable:!0}):r,e));var TT=j(wv=>{"use strict";var ST=/; *([!#$%&'*+.^_`|~0-9A-Za-z-]+) *= *("(?:[\u000b\u0020\u0021\u0023-\u005b\u005d-\u007e\u0080-\u00ff]|\\[\u000b\u0020-\u00ff])*"|[!#$%&'*+.^_`|~0-9A-Za-z-]+) */g,QO=/^[\u000b\u0020-\u007e\u0080-\u00ff]+$/,ET=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+$/,eN=/\\([\u000b\u0020-\u00ff])/g,tN=/([\\"])/g,xT=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+\/[!#$%&'*+.^_`|~0-9A-Za-z-]+$/;wv.format=nN;wv.parse=rN;function nN(e){if(!e||typeof e!="object")throw new TypeError("argument obj is required");var t=e.parameters,r=e.type;if(!r||!xT.test(r))throw new TypeError("invalid type");var a=r;if(t&&typeof t=="object")for(var n,i=Object.keys(t).sort(),o=0;o<i.length;o++){if(n=i[o],!ET.test(n))throw new TypeError("invalid parameter name");a+="; "+n+"="+iN(t[n])}return a}function rN(e){if(!e)throw new TypeError("argument string is required");var t=typeof e=="object"?aN(e):e;if(typeof t!="string")throw new TypeError("argument string is required to be a string");var r=t.indexOf(";"),a=r!==-1?t.slice(0,r).trim():t.trim();if(!xT.test(a))throw new TypeError("invalid media type");var n=new oN(a.toLowerCase());if(r!==-1){var i,o,s;for(ST.lastIndex=r;o=ST.exec(t);){if(o.index!==r)throw new TypeError("invalid parameter format");r+=o[0].length,i=o[1].toLowerCase(),s=o[2],s.charCodeAt(0)===34&&(s=s.slice(1,-1),s.indexOf("\\")!==-1&&(s=s.replace(eN,"$1"))),n.parameters[i]=s}if(r!==t.length)throw new TypeError("invalid parameter format")}return n}function aN(e){var t;if(typeof e.getHeader=="function"?t=e.getHeader("content-type"):typeof e.headers=="object"&&(t=e.headers&&e.headers["content-type"]),typeof t!="string")throw new TypeError("content-type header is missing from object");return t}function iN(e){var t=String(e);if(ET.test(t))return t;if(t.length>0&&!QO.test(t))throw new TypeError("invalid parameter value");return'"'+t.replace(tN,"\\$1")+'"'}function oN(e){this.parameters=Object.create(null),this.type=e}});var hl=j(fe=>{"use strict";Object.defineProperty(fe,"__esModule",{value:!0});fe.regexpCode=fe.getEsmExportName=fe.getProperty=fe.safeStringify=fe.stringify=fe.strConcat=fe.addCodeArg=fe.str=fe._=fe.nil=fe._Code=fe.Name=fe.IDENTIFIER=fe._CodeOrName=void 0;var ml=class{};fe._CodeOrName=ml;fe.IDENTIFIER=/^[a-z$_][a-z$_0-9]*$/i;var ia=class extends ml{constructor(t){if(super(),!fe.IDENTIFIER.test(t))throw new Error("CodeGen: name must be a valid identifier");this.str=t}toString(){return this.str}emptyStr(){return!1}get names(){return{[this.str]:1}}};fe.Name=ia;var Ft=class extends ml{constructor(t){super(),this._items=typeof t=="string"?[t]:t}toString(){return this.str}emptyStr(){if(this._items.length>1)return!1;let t=this._items[0];return t===""||t==='""'}get str(){var t;return(t=this._str)!==null&&t!==void 0?t:this._str=this._items.reduce((r,a)=>`${r}${a}`,"")}get names(){var t;return(t=this._names)!==null&&t!==void 0?t:this._names=this._items.reduce((r,a)=>(a instanceof ia&&(r[a.str]=(r[a.str]||0)+1),r),{})}};fe._Code=Ft;fe.nil=new Ft("");function BC(e,...t){let r=[e[0]],a=0;for(;a<t.length;)_y(r,t[a]),r.push(e[++a]);return new Ft(r)}fe._=BC;var ky=new Ft("+");function UC(e,...t){let r=[gl(e[0])],a=0;for(;a<t.length;)r.push(ky),_y(r,t[a]),r.push(ky,gl(e[++a]));return VM(r),new Ft(r)}fe.str=UC;function _y(e,t){t instanceof Ft?e.push(...t._items):t instanceof ia?e.push(t):e.push(ZM(t))}fe.addCodeArg=_y;function VM(e){let t=1;for(;t<e.length-1;){if(e[t]===ky){let r=WM(e[t-1],e[t+1]);if(r!==void 0){e.splice(t-1,3,r);continue}e[t++]="+"}t++}}function WM(e,t){if(t==='""')return e;if(e==='""')return t;if(typeof e=="string")return t instanceof ia||e[e.length-1]!=='"'?void 0:typeof t!="string"?`${e.slice(0,-1)}${t}"`:t[0]==='"'?e.slice(0,-1)+t.slice(1):void 0;if(typeof t=="string"&&t[0]==='"'&&!(e instanceof ia))return`"${e}${t.slice(1)}`}function KM(e,t){return t.emptyStr()?e:e.emptyStr()?t:UC`${e}${t}`}fe.strConcat=KM;function ZM(e){return typeof e=="number"||typeof e=="boolean"||e===null?e:gl(Array.isArray(e)?e.join(","):e)}function JM(e){return new Ft(gl(e))}fe.stringify=JM;function gl(e){return JSON.stringify(e).replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}fe.safeStringify=gl;function YM(e){return typeof e=="string"&&fe.IDENTIFIER.test(e)?new Ft(`.${e}`):BC`[${e}]`}fe.getProperty=YM;function XM(e){if(typeof e=="string"&&fe.IDENTIFIER.test(e))return new Ft(`${e}`);throw new Error(`CodeGen: invalid export name: ${e}, use explicit $id name mapping`)}fe.getEsmExportName=XM;function QM(e){return new Ft(e.toString())}fe.regexpCode=QM});var Ey=j(Et=>{"use strict";Object.defineProperty(Et,"__esModule",{value:!0});Et.ValueScope=Et.ValueScopeName=Et.Scope=Et.varKinds=Et.UsedValueState=void 0;var St=hl(),wy=class extends Error{constructor(t){super(`CodeGen: "code" for ${t} not defined`),this.value=t.value}},mm;(function(e){e[e.Started=0]="Started",e[e.Completed=1]="Completed"})(mm||(Et.UsedValueState=mm={}));Et.varKinds={const:new St.Name("const"),let:new St.Name("let"),var:new St.Name("var")};var gm=class{constructor({prefixes:t,parent:r}={}){this._names={},this._prefixes=t,this._parent=r}toName(t){return t instanceof St.Name?t:this.name(t)}name(t){return new St.Name(this._newName(t))}_newName(t){let r=this._names[t]||this._nameGroup(t);return`${t}${r.index++}`}_nameGroup(t){var r,a;if(!((a=(r=this._parent)===null||r===void 0?void 0:r._prefixes)===null||a===void 0)&&a.has(t)||this._prefixes&&!this._prefixes.has(t))throw new Error(`CodeGen: prefix "${t}" is not allowed in this scope`);return this._names[t]={prefix:t,index:0}}};Et.Scope=gm;var hm=class extends St.Name{constructor(t,r){super(r),this.prefix=t}setValue(t,{property:r,itemIndex:a}){this.value=t,this.scopePath=(0,St._)`.${new St.Name(r)}[${a}]`}};Et.ValueScopeName=hm;var eL=(0,St._)`\n`,Sy=class extends gm{constructor(t){super(t),this._values={},this._scope=t.scope,this.opts={...t,_n:t.lines?eL:St.nil}}get(){return this._scope}name(t){return new hm(t,this._newName(t))}value(t,r){var a;if(r.ref===void 0)throw new Error("CodeGen: ref must be passed in value");let n=this.toName(t),{prefix:i}=n,o=(a=r.key)!==null&&a!==void 0?a:r.ref,s=this._values[i];if(s){let u=s.get(o);if(u)return u}else s=this._values[i]=new Map;s.set(o,n);let l=this._scope[i]||(this._scope[i]=[]),c=l.length;return l[c]=r.ref,n.setValue(r,{property:i,itemIndex:c}),n}getValue(t,r){let a=this._values[t];if(a)return a.get(r)}scopeRefs(t,r=this._values){return this._reduceValues(r,a=>{if(a.scopePath===void 0)throw new Error(`CodeGen: name "${a}" has no value`);return(0,St._)`${t}${a.scopePath}`})}scopeCode(t=this._values,r,a){return this._reduceValues(t,n=>{if(n.value===void 0)throw new Error(`CodeGen: name "${n}" has no value`);return n.value.code},r,a)}_reduceValues(t,r,a={},n){let i=St.nil;for(let o in t){let s=t[o];if(!s)continue;let l=a[o]=a[o]||new Map;s.forEach(c=>{if(l.has(c))return;l.set(c,mm.Started);let u=r(c);if(u){let d=this.opts.es5?Et.varKinds.var:Et.varKinds.const;i=(0,St._)`${i}${d} ${c} = ${u};${this.opts._n}`}else if(u=n?.(c))i=(0,St._)`${i}${u}${this.opts._n}`;else throw new wy(c);l.set(c,mm.Completed)})}return i}};Et.ValueScope=Sy});var ne=j(oe=>{"use strict";Object.defineProperty(oe,"__esModule",{value:!0});oe.or=oe.and=oe.not=oe.CodeGen=oe.operators=oe.varKinds=oe.ValueScopeName=oe.ValueScope=oe.Scope=oe.Name=oe.regexpCode=oe.stringify=oe.getProperty=oe.nil=oe.strConcat=oe.str=oe._=void 0;var de=hl(),en=Ey(),wr=hl();Object.defineProperty(oe,"_",{enumerable:!0,get:function(){return wr._}});Object.defineProperty(oe,"str",{enumerable:!0,get:function(){return wr.str}});Object.defineProperty(oe,"strConcat",{enumerable:!0,get:function(){return wr.strConcat}});Object.defineProperty(oe,"nil",{enumerable:!0,get:function(){return wr.nil}});Object.defineProperty(oe,"getProperty",{enumerable:!0,get:function(){return wr.getProperty}});Object.defineProperty(oe,"stringify",{enumerable:!0,get:function(){return wr.stringify}});Object.defineProperty(oe,"regexpCode",{enumerable:!0,get:function(){return wr.regexpCode}});Object.defineProperty(oe,"Name",{enumerable:!0,get:function(){return wr.Name}});var ym=Ey();Object.defineProperty(oe,"Scope",{enumerable:!0,get:function(){return ym.Scope}});Object.defineProperty(oe,"ValueScope",{enumerable:!0,get:function(){return ym.ValueScope}});Object.defineProperty(oe,"ValueScopeName",{enumerable:!0,get:function(){return ym.ValueScopeName}});Object.defineProperty(oe,"varKinds",{enumerable:!0,get:function(){return ym.varKinds}});oe.operators={GT:new de._Code(">"),GTE:new de._Code(">="),LT:new de._Code("<"),LTE:new de._Code("<="),EQ:new de._Code("==="),NEQ:new de._Code("!=="),NOT:new de._Code("!"),OR:new de._Code("||"),AND:new de._Code("&&"),ADD:new de._Code("+")};var Wn=class{optimizeNodes(){return this}optimizeNames(t,r){return this}},xy=class extends Wn{constructor(t,r,a){super(),this.varKind=t,this.name=r,this.rhs=a}render({es5:t,_n:r}){let a=t?en.varKinds.var:this.varKind,n=this.rhs===void 0?"":` = ${this.rhs}`;return`${a} ${this.name}${n};`+r}optimizeNames(t,r){if(t[this.name.str])return this.rhs&&(this.rhs=Ki(this.rhs,t,r)),this}get names(){return this.rhs instanceof de._CodeOrName?this.rhs.names:{}}},fm=class extends Wn{constructor(t,r,a){super(),this.lhs=t,this.rhs=r,this.sideEffects=a}render({_n:t}){return`${this.lhs} = ${this.rhs};`+t}optimizeNames(t,r){if(!(this.lhs instanceof de.Name&&!t[this.lhs.str]&&!this.sideEffects))return this.rhs=Ki(this.rhs,t,r),this}get names(){let t=this.lhs instanceof de.Name?{}:{...this.lhs.names};return vm(t,this.rhs)}},Ty=class extends fm{constructor(t,r,a,n){super(t,a,n),this.op=r}render({_n:t}){return`${this.lhs} ${this.op}= ${this.rhs};`+t}},Ay=class extends Wn{constructor(t){super(),this.label=t,this.names={}}render({_n:t}){return`${this.label}:`+t}},Cy=class extends Wn{constructor(t){super(),this.label=t,this.names={}}render({_n:t}){return`break${this.label?` ${this.label}`:""};`+t}},zy=class extends Wn{constructor(t){super(),this.error=t}render({_n:t}){return`throw ${this.error};`+t}get names(){return this.error.names}},Iy=class extends Wn{constructor(t){super(),this.code=t}render({_n:t}){return`${this.code};`+t}optimizeNodes(){return`${this.code}`?this:void 0}optimizeNames(t,r){return this.code=Ki(this.code,t,r),this}get names(){return this.code instanceof de._CodeOrName?this.code.names:{}}},fl=class extends Wn{constructor(t=[]){super(),this.nodes=t}render(t){return this.nodes.reduce((r,a)=>r+a.render(t),"")}optimizeNodes(){let{nodes:t}=this,r=t.length;for(;r--;){let a=t[r].optimizeNodes();Array.isArray(a)?t.splice(r,1,...a):a?t[r]=a:t.splice(r,1)}return t.length>0?this:void 0}optimizeNames(t,r){let{nodes:a}=this,n=a.length;for(;n--;){let i=a[n];i.optimizeNames(t,r)||(tL(t,i.names),a.splice(n,1))}return a.length>0?this:void 0}get names(){return this.nodes.reduce((t,r)=>la(t,r.names),{})}},Kn=class extends fl{render(t){return"{"+t._n+super.render(t)+"}"+t._n}},Py=class extends fl{},Wi=class extends Kn{};Wi.kind="else";var oa=class e extends Kn{constructor(t,r){super(r),this.condition=t}render(t){let r=`if(${this.condition})`+super.render(t);return this.else&&(r+="else "+this.else.render(t)),r}optimizeNodes(){super.optimizeNodes();let t=this.condition;if(t===!0)return this.nodes;let r=this.else;if(r){let a=r.optimizeNodes();r=this.else=Array.isArray(a)?new Wi(a):a}if(r)return t===!1?r instanceof e?r:r.nodes:this.nodes.length?this:new e(FC(t),r instanceof e?[r]:r.nodes);if(!(t===!1||!this.nodes.length))return this}optimizeNames(t,r){var a;if(this.else=(a=this.else)===null||a===void 0?void 0:a.optimizeNames(t,r),!!(super.optimizeNames(t,r)||this.else))return this.condition=Ki(this.condition,t,r),this}get names(){let t=super.names;return vm(t,this.condition),this.else&&la(t,this.else.names),t}};oa.kind="if";var sa=class extends Kn{};sa.kind="for";var Ry=class extends sa{constructor(t){super(),this.iteration=t}render(t){return`for(${this.iteration})`+super.render(t)}optimizeNames(t,r){if(super.optimizeNames(t,r))return this.iteration=Ki(this.iteration,t,r),this}get names(){return la(super.names,this.iteration.names)}},$y=class extends sa{constructor(t,r,a,n){super(),this.varKind=t,this.name=r,this.from=a,this.to=n}render(t){let r=t.es5?en.varKinds.var:this.varKind,{name:a,from:n,to:i}=this;return`for(${r} ${a}=${n}; ${a}<${i}; ${a}++)`+super.render(t)}get names(){let t=vm(super.names,this.from);return vm(t,this.to)}},bm=class extends sa{constructor(t,r,a,n){super(),this.loop=t,this.varKind=r,this.name=a,this.iterable=n}render(t){return`for(${this.varKind} ${this.name} ${this.loop} ${this.iterable})`+super.render(t)}optimizeNames(t,r){if(super.optimizeNames(t,r))return this.iterable=Ki(this.iterable,t,r),this}get names(){return la(super.names,this.iterable.names)}},bl=class extends Kn{constructor(t,r,a){super(),this.name=t,this.args=r,this.async=a}render(t){return`${this.async?"async ":""}function ${this.name}(${this.args})`+super.render(t)}};bl.kind="func";var vl=class extends fl{render(t){return"return "+super.render(t)}};vl.kind="return";var jy=class extends Kn{render(t){let r="try"+super.render(t);return this.catch&&(r+=this.catch.render(t)),this.finally&&(r+=this.finally.render(t)),r}optimizeNodes(){var t,r;return super.optimizeNodes(),(t=this.catch)===null||t===void 0||t.optimizeNodes(),(r=this.finally)===null||r===void 0||r.optimizeNodes(),this}optimizeNames(t,r){var a,n;return super.optimizeNames(t,r),(a=this.catch)===null||a===void 0||a.optimizeNames(t,r),(n=this.finally)===null||n===void 0||n.optimizeNames(t,r),this}get names(){let t=super.names;return this.catch&&la(t,this.catch.names),this.finally&&la(t,this.finally.names),t}},yl=class extends Kn{constructor(t){super(),this.error=t}render(t){return`catch(${this.error})`+super.render(t)}};yl.kind="catch";var kl=class extends Kn{render(t){return"finally"+super.render(t)}};kl.kind="finally";var Oy=class{constructor(t,r={}){this._values={},this._blockStarts=[],this._constants={},this.opts={...r,_n:r.lines?`
|
|
3
|
-
`:""},this._extScope=t,this._scope=new en.Scope({parent:t}),this._nodes=[new Py]}toString(){return this._root.render(this.opts)}name(t){return this._scope.name(t)}scopeName(t){return this._extScope.name(t)}scopeValue(t,r){let a=this._extScope.value(t,r);return(this._values[a.prefix]||(this._values[a.prefix]=new Set)).add(a),a}getScopeValue(t,r){return this._extScope.getValue(t,r)}scopeRefs(t){return this._extScope.scopeRefs(t,this._values)}scopeCode(){return this._extScope.scopeCode(this._values)}_def(t,r,a,n){let i=this._scope.toName(r);return a!==void 0&&n&&(this._constants[i.str]=a),this._leafNode(new xy(t,i,a)),i}const(t,r,a){return this._def(en.varKinds.const,t,r,a)}let(t,r,a){return this._def(en.varKinds.let,t,r,a)}var(t,r,a){return this._def(en.varKinds.var,t,r,a)}assign(t,r,a){return this._leafNode(new fm(t,r,a))}add(t,r){return this._leafNode(new Ty(t,oe.operators.ADD,r))}code(t){return typeof t=="function"?t():t!==de.nil&&this._leafNode(new Iy(t)),this}object(...t){let r=["{"];for(let[a,n]of t)r.length>1&&r.push(","),r.push(a),(a!==n||this.opts.es5)&&(r.push(":"),(0,de.addCodeArg)(r,n));return r.push("}"),new de._Code(r)}if(t,r,a){if(this._blockNode(new oa(t)),r&&a)this.code(r).else().code(a).endIf();else if(r)this.code(r).endIf();else if(a)throw new Error('CodeGen: "else" body without "then" body');return this}elseIf(t){return this._elseNode(new oa(t))}else(){return this._elseNode(new Wi)}endIf(){return this._endBlockNode(oa,Wi)}_for(t,r){return this._blockNode(t),r&&this.code(r).endFor(),this}for(t,r){return this._for(new Ry(t),r)}forRange(t,r,a,n,i=this.opts.es5?en.varKinds.var:en.varKinds.let){let o=this._scope.toName(t);return this._for(new $y(i,o,r,a),()=>n(o))}forOf(t,r,a,n=en.varKinds.const){let i=this._scope.toName(t);if(this.opts.es5){let o=r instanceof de.Name?r:this.var("_arr",r);return this.forRange("_i",0,(0,de._)`${o}.length`,s=>{this.var(i,(0,de._)`${o}[${s}]`),a(i)})}return this._for(new bm("of",n,i,r),()=>a(i))}forIn(t,r,a,n=this.opts.es5?en.varKinds.var:en.varKinds.const){if(this.opts.ownProperties)return this.forOf(t,(0,de._)`Object.keys(${r})`,a);let i=this._scope.toName(t);return this._for(new bm("in",n,i,r),()=>a(i))}endFor(){return this._endBlockNode(sa)}label(t){return this._leafNode(new Ay(t))}break(t){return this._leafNode(new Cy(t))}return(t){let r=new vl;if(this._blockNode(r),this.code(t),r.nodes.length!==1)throw new Error('CodeGen: "return" should have one node');return this._endBlockNode(vl)}try(t,r,a){if(!r&&!a)throw new Error('CodeGen: "try" without "catch" and "finally"');let n=new jy;if(this._blockNode(n),this.code(t),r){let i=this.name("e");this._currNode=n.catch=new yl(i),r(i)}return a&&(this._currNode=n.finally=new kl,this.code(a)),this._endBlockNode(yl,kl)}throw(t){return this._leafNode(new zy(t))}block(t,r){return this._blockStarts.push(this._nodes.length),t&&this.code(t).endBlock(r),this}endBlock(t){let r=this._blockStarts.pop();if(r===void 0)throw new Error("CodeGen: not in self-balancing block");let a=this._nodes.length-r;if(a<0||t!==void 0&&a!==t)throw new Error(`CodeGen: wrong number of nodes: ${a} vs ${t} expected`);return this._nodes.length=r,this}func(t,r=de.nil,a,n){return this._blockNode(new bl(t,r,a)),n&&this.code(n).endFunc(),this}endFunc(){return this._endBlockNode(bl)}optimize(t=1){for(;t-- >0;)this._root.optimizeNodes(),this._root.optimizeNames(this._root.names,this._constants)}_leafNode(t){return this._currNode.nodes.push(t),this}_blockNode(t){this._currNode.nodes.push(t),this._nodes.push(t)}_endBlockNode(t,r){let a=this._currNode;if(a instanceof t||r&&a instanceof r)return this._nodes.pop(),this;throw new Error(`CodeGen: not in block "${r?`${t.kind}/${r.kind}`:t.kind}"`)}_elseNode(t){let r=this._currNode;if(!(r instanceof oa))throw new Error('CodeGen: "else" without "if"');return this._currNode=r.else=t,this}get _root(){return this._nodes[0]}get _currNode(){let t=this._nodes;return t[t.length-1]}set _currNode(t){let r=this._nodes;r[r.length-1]=t}};oe.CodeGen=Oy;function la(e,t){for(let r in t)e[r]=(e[r]||0)+(t[r]||0);return e}function vm(e,t){return t instanceof de._CodeOrName?la(e,t.names):e}function Ki(e,t,r){if(e instanceof de.Name)return a(e);if(!n(e))return e;return new de._Code(e._items.reduce((i,o)=>(o instanceof de.Name&&(o=a(o)),o instanceof de._Code?i.push(...o._items):i.push(o),i),[]));function a(i){let o=r[i.str];return o===void 0||t[i.str]!==1?i:(delete t[i.str],o)}function n(i){return i instanceof de._Code&&i._items.some(o=>o instanceof de.Name&&t[o.str]===1&&r[o.str]!==void 0)}}function tL(e,t){for(let r in t)e[r]=(e[r]||0)-(t[r]||0)}function FC(e){return typeof e=="boolean"||typeof e=="number"||e===null?!e:(0,de._)`!${Ny(e)}`}oe.not=FC;var nL=qC(oe.operators.AND);function rL(...e){return e.reduce(nL)}oe.and=rL;var aL=qC(oe.operators.OR);function iL(...e){return e.reduce(aL)}oe.or=iL;function qC(e){return(t,r)=>t===de.nil?r:r===de.nil?t:(0,de._)`${Ny(t)} ${e} ${Ny(r)}`}function Ny(e){return e instanceof de.Name?e:(0,de._)`(${e})`}});var pe=j(le=>{"use strict";Object.defineProperty(le,"__esModule",{value:!0});le.checkStrictMode=le.getErrorPath=le.Type=le.useFunc=le.setEvaluated=le.evaluatedPropsToName=le.mergeEvaluated=le.eachItem=le.unescapeJsonPointer=le.escapeJsonPointer=le.escapeFragment=le.unescapeFragment=le.schemaRefOrVal=le.schemaHasRulesButRef=le.schemaHasRules=le.checkUnknownRules=le.alwaysValidSchema=le.toHash=void 0;var ze=ne(),oL=hl();function sL(e){let t={};for(let r of e)t[r]=!0;return t}le.toHash=sL;function lL(e,t){return typeof t=="boolean"?t:Object.keys(t).length===0?!0:(VC(e,t),!WC(t,e.self.RULES.all))}le.alwaysValidSchema=lL;function VC(e,t=e.schema){let{opts:r,self:a}=e;if(!r.strictSchema||typeof t=="boolean")return;let n=a.RULES.keywords;for(let i in t)n[i]||JC(e,`unknown keyword: "${i}"`)}le.checkUnknownRules=VC;function WC(e,t){if(typeof e=="boolean")return!e;for(let r in e)if(t[r])return!0;return!1}le.schemaHasRules=WC;function cL(e,t){if(typeof e=="boolean")return!e;for(let r in e)if(r!=="$ref"&&t.all[r])return!0;return!1}le.schemaHasRulesButRef=cL;function uL({topSchemaRef:e,schemaPath:t},r,a,n){if(!n){if(typeof r=="number"||typeof r=="boolean")return r;if(typeof r=="string")return(0,ze._)`${r}`}return(0,ze._)`${e}${t}${(0,ze.getProperty)(a)}`}le.schemaRefOrVal=uL;function dL(e){return KC(decodeURIComponent(e))}le.unescapeFragment=dL;function pL(e){return encodeURIComponent(My(e))}le.escapeFragment=pL;function My(e){return typeof e=="number"?`${e}`:e.replace(/~/g,"~0").replace(/\//g,"~1")}le.escapeJsonPointer=My;function KC(e){return e.replace(/~1/g,"/").replace(/~0/g,"~")}le.unescapeJsonPointer=KC;function mL(e,t){if(Array.isArray(e))for(let r of e)t(r);else t(e)}le.eachItem=mL;function HC({mergeNames:e,mergeToName:t,mergeValues:r,resultToName:a}){return(n,i,o,s)=>{let l=o===void 0?i:o instanceof ze.Name?(i instanceof ze.Name?e(n,i,o):t(n,i,o),o):i instanceof ze.Name?(t(n,o,i),i):r(i,o);return s===ze.Name&&!(l instanceof ze.Name)?a(n,l):l}}le.mergeEvaluated={props:HC({mergeNames:(e,t,r)=>e.if((0,ze._)`${r} !== true && ${t} !== undefined`,()=>{e.if((0,ze._)`${t} === true`,()=>e.assign(r,!0),()=>e.assign(r,(0,ze._)`${r} || {}`).code((0,ze._)`Object.assign(${r}, ${t})`))}),mergeToName:(e,t,r)=>e.if((0,ze._)`${r} !== true`,()=>{t===!0?e.assign(r,!0):(e.assign(r,(0,ze._)`${r} || {}`),Ly(e,r,t))}),mergeValues:(e,t)=>e===!0?!0:{...e,...t},resultToName:ZC}),items:HC({mergeNames:(e,t,r)=>e.if((0,ze._)`${r} !== true && ${t} !== undefined`,()=>e.assign(r,(0,ze._)`${t} === true ? true : ${r} > ${t} ? ${r} : ${t}`)),mergeToName:(e,t,r)=>e.if((0,ze._)`${r} !== true`,()=>e.assign(r,t===!0?!0:(0,ze._)`${r} > ${t} ? ${r} : ${t}`)),mergeValues:(e,t)=>e===!0?!0:Math.max(e,t),resultToName:(e,t)=>e.var("items",t)})};function ZC(e,t){if(t===!0)return e.var("props",!0);let r=e.var("props",(0,ze._)`{}`);return t!==void 0&&Ly(e,r,t),r}le.evaluatedPropsToName=ZC;function Ly(e,t,r){Object.keys(r).forEach(a=>e.assign((0,ze._)`${t}${(0,ze.getProperty)(a)}`,!0))}le.setEvaluated=Ly;var GC={};function gL(e,t){return e.scopeValue("func",{ref:t,code:GC[t.code]||(GC[t.code]=new oL._Code(t.code))})}le.useFunc=gL;var Dy;(function(e){e[e.Num=0]="Num",e[e.Str=1]="Str"})(Dy||(le.Type=Dy={}));function hL(e,t,r){if(e instanceof ze.Name){let a=t===Dy.Num;return r?a?(0,ze._)`"[" + ${e} + "]"`:(0,ze._)`"['" + ${e} + "']"`:a?(0,ze._)`"/" + ${e}`:(0,ze._)`"/" + ${e}.replace(/~/g, "~0").replace(/\\//g, "~1")`}return r?(0,ze.getProperty)(e).toString():"/"+My(e)}le.getErrorPath=hL;function JC(e,t,r=e.opts.strictSchema){if(r){if(t=`strict mode: ${t}`,r===!0)throw new Error(t);e.self.logger.warn(t)}}le.checkStrictMode=JC});var Zn=j(By=>{"use strict";Object.defineProperty(By,"__esModule",{value:!0});var at=ne(),fL={data:new at.Name("data"),valCxt:new at.Name("valCxt"),instancePath:new at.Name("instancePath"),parentData:new at.Name("parentData"),parentDataProperty:new at.Name("parentDataProperty"),rootData:new at.Name("rootData"),dynamicAnchors:new at.Name("dynamicAnchors"),vErrors:new at.Name("vErrors"),errors:new at.Name("errors"),this:new at.Name("this"),self:new at.Name("self"),scope:new at.Name("scope"),json:new at.Name("json"),jsonPos:new at.Name("jsonPos"),jsonLen:new at.Name("jsonLen"),jsonPart:new at.Name("jsonPart")};By.default=fL});var _l=j(it=>{"use strict";Object.defineProperty(it,"__esModule",{value:!0});it.extendErrors=it.resetErrorsCount=it.reportExtraError=it.reportError=it.keyword$DataError=it.keywordError=void 0;var me=ne(),km=pe(),ft=Zn();it.keywordError={message:({keyword:e})=>(0,me.str)`must pass "${e}" keyword validation`};it.keyword$DataError={message:({keyword:e,schemaType:t})=>t?(0,me.str)`"${e}" keyword must be ${t} ($data)`:(0,me.str)`"${e}" keyword is invalid ($data)`};function bL(e,t=it.keywordError,r,a){let{it:n}=e,{gen:i,compositeRule:o,allErrors:s}=n,l=QC(e,t,r);a??(o||s)?YC(i,l):XC(n,(0,me._)`[${l}]`)}it.reportError=bL;function vL(e,t=it.keywordError,r){let{it:a}=e,{gen:n,compositeRule:i,allErrors:o}=a,s=QC(e,t,r);YC(n,s),i||o||XC(a,ft.default.vErrors)}it.reportExtraError=vL;function yL(e,t){e.assign(ft.default.errors,t),e.if((0,me._)`${ft.default.vErrors} !== null`,()=>e.if(t,()=>e.assign((0,me._)`${ft.default.vErrors}.length`,t),()=>e.assign(ft.default.vErrors,null)))}it.resetErrorsCount=yL;function kL({gen:e,keyword:t,schemaValue:r,data:a,errsCount:n,it:i}){if(n===void 0)throw new Error("ajv implementation error");let o=e.name("err");e.forRange("i",n,ft.default.errors,s=>{e.const(o,(0,me._)`${ft.default.vErrors}[${s}]`),e.if((0,me._)`${o}.instancePath === undefined`,()=>e.assign((0,me._)`${o}.instancePath`,(0,me.strConcat)(ft.default.instancePath,i.errorPath))),e.assign((0,me._)`${o}.schemaPath`,(0,me.str)`${i.errSchemaPath}/${t}`),i.opts.verbose&&(e.assign((0,me._)`${o}.schema`,r),e.assign((0,me._)`${o}.data`,a))})}it.extendErrors=kL;function YC(e,t){let r=e.const("err",t);e.if((0,me._)`${ft.default.vErrors} === null`,()=>e.assign(ft.default.vErrors,(0,me._)`[${r}]`),(0,me._)`${ft.default.vErrors}.push(${r})`),e.code((0,me._)`${ft.default.errors}++`)}function XC(e,t){let{gen:r,validateName:a,schemaEnv:n}=e;n.$async?r.throw((0,me._)`new ${e.ValidationError}(${t})`):(r.assign((0,me._)`${a}.errors`,t),r.return(!1))}var ca={keyword:new me.Name("keyword"),schemaPath:new me.Name("schemaPath"),params:new me.Name("params"),propertyName:new me.Name("propertyName"),message:new me.Name("message"),schema:new me.Name("schema"),parentSchema:new me.Name("parentSchema")};function QC(e,t,r){let{createErrors:a}=e.it;return a===!1?(0,me._)`{}`:_L(e,t,r)}function _L(e,t,r={}){let{gen:a,it:n}=e,i=[wL(n,r),SL(e,r)];return EL(e,t,i),a.object(...i)}function wL({errorPath:e},{instancePath:t}){let r=t?(0,me.str)`${e}${(0,km.getErrorPath)(t,km.Type.Str)}`:e;return[ft.default.instancePath,(0,me.strConcat)(ft.default.instancePath,r)]}function SL({keyword:e,it:{errSchemaPath:t}},{schemaPath:r,parentSchema:a}){let n=a?t:(0,me.str)`${t}/${e}`;return r&&(n=(0,me.str)`${n}${(0,km.getErrorPath)(r,km.Type.Str)}`),[ca.schemaPath,n]}function EL(e,{params:t,message:r},a){let{keyword:n,data:i,schemaValue:o,it:s}=e,{opts:l,propertyName:c,topSchemaRef:u,schemaPath:d}=s;a.push([ca.keyword,n],[ca.params,typeof t=="function"?t(e):t||(0,me._)`{}`]),l.messages&&a.push([ca.message,typeof r=="function"?r(e):r]),l.verbose&&a.push([ca.schema,o],[ca.parentSchema,(0,me._)`${u}${d}`],[ft.default.data,i]),c&&a.push([ca.propertyName,c])}});var tz=j(Zi=>{"use strict";Object.defineProperty(Zi,"__esModule",{value:!0});Zi.boolOrEmptySchema=Zi.topBoolOrEmptySchema=void 0;var xL=_l(),TL=ne(),AL=Zn(),CL={message:"boolean schema is false"};function zL(e){let{gen:t,schema:r,validateName:a}=e;r===!1?ez(e,!1):typeof r=="object"&&r.$async===!0?t.return(AL.default.data):(t.assign((0,TL._)`${a}.errors`,null),t.return(!0))}Zi.topBoolOrEmptySchema=zL;function IL(e,t){let{gen:r,schema:a}=e;a===!1?(r.var(t,!1),ez(e)):r.var(t,!0)}Zi.boolOrEmptySchema=IL;function ez(e,t){let{gen:r,data:a}=e,n={gen:r,keyword:"false schema",data:a,schema:!1,schemaCode:!1,schemaValue:!1,params:{},it:e};(0,xL.reportError)(n,CL,void 0,t)}});var Uy=j(Ji=>{"use strict";Object.defineProperty(Ji,"__esModule",{value:!0});Ji.getRules=Ji.isJSONType=void 0;var PL=["string","number","integer","boolean","null","object","array"],RL=new Set(PL);function $L(e){return typeof e=="string"&&RL.has(e)}Ji.isJSONType=$L;function jL(){let e={number:{type:"number",rules:[]},string:{type:"string",rules:[]},array:{type:"array",rules:[]},object:{type:"object",rules:[]}};return{types:{...e,integer:!0,boolean:!0,null:!0},rules:[{rules:[]},e.number,e.string,e.array,e.object],post:{rules:[]},all:{},keywords:{}}}Ji.getRules=jL});var Fy=j(Sr=>{"use strict";Object.defineProperty(Sr,"__esModule",{value:!0});Sr.shouldUseRule=Sr.shouldUseGroup=Sr.schemaHasRulesForType=void 0;function OL({schema:e,self:t},r){let a=t.RULES.types[r];return a&&a!==!0&&nz(e,a)}Sr.schemaHasRulesForType=OL;function nz(e,t){return t.rules.some(r=>rz(e,r))}Sr.shouldUseGroup=nz;function rz(e,t){var r;return e[t.keyword]!==void 0||((r=t.definition.implements)===null||r===void 0?void 0:r.some(a=>e[a]!==void 0))}Sr.shouldUseRule=rz});var wl=j(ot=>{"use strict";Object.defineProperty(ot,"__esModule",{value:!0});ot.reportTypeError=ot.checkDataTypes=ot.checkDataType=ot.coerceAndCheckDataType=ot.getJSONTypes=ot.getSchemaTypes=ot.DataType=void 0;var NL=Uy(),DL=Fy(),ML=_l(),te=ne(),az=pe(),Yi;(function(e){e[e.Correct=0]="Correct",e[e.Wrong=1]="Wrong"})(Yi||(ot.DataType=Yi={}));function LL(e){let t=iz(e.type);if(t.includes("null")){if(e.nullable===!1)throw new Error("type: null contradicts nullable: false")}else{if(!t.length&&e.nullable!==void 0)throw new Error('"nullable" cannot be used without "type"');e.nullable===!0&&t.push("null")}return t}ot.getSchemaTypes=LL;function iz(e){let t=Array.isArray(e)?e:e?[e]:[];if(t.every(NL.isJSONType))return t;throw new Error("type must be JSONType or JSONType[]: "+t.join(","))}ot.getJSONTypes=iz;function BL(e,t){let{gen:r,data:a,opts:n}=e,i=UL(t,n.coerceTypes),o=t.length>0&&!(i.length===0&&t.length===1&&(0,DL.schemaHasRulesForType)(e,t[0]));if(o){let s=Hy(t,a,n.strictNumbers,Yi.Wrong);r.if(s,()=>{i.length?FL(e,t,i):Gy(e)})}return o}ot.coerceAndCheckDataType=BL;var oz=new Set(["string","number","integer","boolean","null"]);function UL(e,t){return t?e.filter(r=>oz.has(r)||t==="array"&&r==="array"):[]}function FL(e,t,r){let{gen:a,data:n,opts:i}=e,o=a.let("dataType",(0,te._)`typeof ${n}`),s=a.let("coerced",(0,te._)`undefined`);i.coerceTypes==="array"&&a.if((0,te._)`${o} == 'object' && Array.isArray(${n}) && ${n}.length == 1`,()=>a.assign(n,(0,te._)`${n}[0]`).assign(o,(0,te._)`typeof ${n}`).if(Hy(t,n,i.strictNumbers),()=>a.assign(s,n))),a.if((0,te._)`${s} !== undefined`);for(let c of r)(oz.has(c)||c==="array"&&i.coerceTypes==="array")&&l(c);a.else(),Gy(e),a.endIf(),a.if((0,te._)`${s} !== undefined`,()=>{a.assign(n,s),qL(e,s)});function l(c){switch(c){case"string":a.elseIf((0,te._)`${o} == "number" || ${o} == "boolean"`).assign(s,(0,te._)`"" + ${n}`).elseIf((0,te._)`${n} === null`).assign(s,(0,te._)`""`);return;case"number":a.elseIf((0,te._)`${o} == "boolean" || ${n} === null
|
|
2
|
+
var c1=Object.create;var tg=Object.defineProperty;var u1=Object.getOwnPropertyDescriptor;var d1=Object.getOwnPropertyNames;var p1=Object.getPrototypeOf,m1=Object.prototype.hasOwnProperty;var j=(e,t)=>()=>{try{return t||e((t={exports:{}}).exports,t),t.exports}catch(r){throw t=0,r}},En=(e,t)=>{for(var r in t)tg(e,r,{get:t[r],enumerable:!0})},g1=(e,t,r,a)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of d1(t))!m1.call(e,n)&&n!==r&&tg(e,n,{get:()=>t[n],enumerable:!(a=u1(t,n))||a.enumerable});return e};var ng=(e,t,r)=>(r=e!=null?c1(p1(e)):{},g1(t||!e||!e.__esModule?tg(r,"default",{value:e,enumerable:!0}):r,e));var TT=j(wv=>{"use strict";var ST=/; *([!#$%&'*+.^_`|~0-9A-Za-z-]+) *= *("(?:[\u000b\u0020\u0021\u0023-\u005b\u005d-\u007e\u0080-\u00ff]|\\[\u000b\u0020-\u00ff])*"|[!#$%&'*+.^_`|~0-9A-Za-z-]+) */g,QO=/^[\u000b\u0020-\u007e\u0080-\u00ff]+$/,ET=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+$/,eN=/\\([\u000b\u0020-\u00ff])/g,tN=/([\\"])/g,xT=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+\/[!#$%&'*+.^_`|~0-9A-Za-z-]+$/;wv.format=nN;wv.parse=rN;function nN(e){if(!e||typeof e!="object")throw new TypeError("argument obj is required");var t=e.parameters,r=e.type;if(!r||!xT.test(r))throw new TypeError("invalid type");var a=r;if(t&&typeof t=="object")for(var n,i=Object.keys(t).sort(),o=0;o<i.length;o++){if(n=i[o],!ET.test(n))throw new TypeError("invalid parameter name");a+="; "+n+"="+iN(t[n])}return a}function rN(e){if(!e)throw new TypeError("argument string is required");var t=typeof e=="object"?aN(e):e;if(typeof t!="string")throw new TypeError("argument string is required to be a string");var r=t.indexOf(";"),a=r!==-1?t.slice(0,r).trim():t.trim();if(!xT.test(a))throw new TypeError("invalid media type");var n=new oN(a.toLowerCase());if(r!==-1){var i,o,s;for(ST.lastIndex=r;o=ST.exec(t);){if(o.index!==r)throw new TypeError("invalid parameter format");r+=o[0].length,i=o[1].toLowerCase(),s=o[2],s.charCodeAt(0)===34&&(s=s.slice(1,-1),s.indexOf("\\")!==-1&&(s=s.replace(eN,"$1"))),n.parameters[i]=s}if(r!==t.length)throw new TypeError("invalid parameter format")}return n}function aN(e){var t;if(typeof e.getHeader=="function"?t=e.getHeader("content-type"):typeof e.headers=="object"&&(t=e.headers&&e.headers["content-type"]),typeof t!="string")throw new TypeError("content-type header is missing from object");return t}function iN(e){var t=String(e);if(ET.test(t))return t;if(t.length>0&&!QO.test(t))throw new TypeError("invalid parameter value");return'"'+t.replace(tN,"\\$1")+'"'}function oN(e){this.parameters=Object.create(null),this.type=e}});var hl=j(fe=>{"use strict";Object.defineProperty(fe,"__esModule",{value:!0});fe.regexpCode=fe.getEsmExportName=fe.getProperty=fe.safeStringify=fe.stringify=fe.strConcat=fe.addCodeArg=fe.str=fe._=fe.nil=fe._Code=fe.Name=fe.IDENTIFIER=fe._CodeOrName=void 0;var ml=class{};fe._CodeOrName=ml;fe.IDENTIFIER=/^[a-z$_][a-z$_0-9]*$/i;var ia=class extends ml{constructor(t){if(super(),!fe.IDENTIFIER.test(t))throw new Error("CodeGen: name must be a valid identifier");this.str=t}toString(){return this.str}emptyStr(){return!1}get names(){return{[this.str]:1}}};fe.Name=ia;var Ft=class extends ml{constructor(t){super(),this._items=typeof t=="string"?[t]:t}toString(){return this.str}emptyStr(){if(this._items.length>1)return!1;let t=this._items[0];return t===""||t==='""'}get str(){var t;return(t=this._str)!==null&&t!==void 0?t:this._str=this._items.reduce((r,a)=>`${r}${a}`,"")}get names(){var t;return(t=this._names)!==null&&t!==void 0?t:this._names=this._items.reduce((r,a)=>(a instanceof ia&&(r[a.str]=(r[a.str]||0)+1),r),{})}};fe._Code=Ft;fe.nil=new Ft("");function BC(e,...t){let r=[e[0]],a=0;for(;a<t.length;)_y(r,t[a]),r.push(e[++a]);return new Ft(r)}fe._=BC;var ky=new Ft("+");function UC(e,...t){let r=[gl(e[0])],a=0;for(;a<t.length;)r.push(ky),_y(r,t[a]),r.push(ky,gl(e[++a]));return KM(r),new Ft(r)}fe.str=UC;function _y(e,t){t instanceof Ft?e.push(...t._items):t instanceof ia?e.push(t):e.push(YM(t))}fe.addCodeArg=_y;function KM(e){let t=1;for(;t<e.length-1;){if(e[t]===ky){let r=ZM(e[t-1],e[t+1]);if(r!==void 0){e.splice(t-1,3,r);continue}e[t++]="+"}t++}}function ZM(e,t){if(t==='""')return e;if(e==='""')return t;if(typeof e=="string")return t instanceof ia||e[e.length-1]!=='"'?void 0:typeof t!="string"?`${e.slice(0,-1)}${t}"`:t[0]==='"'?e.slice(0,-1)+t.slice(1):void 0;if(typeof t=="string"&&t[0]==='"'&&!(e instanceof ia))return`"${e}${t.slice(1)}`}function JM(e,t){return t.emptyStr()?e:e.emptyStr()?t:UC`${e}${t}`}fe.strConcat=JM;function YM(e){return typeof e=="number"||typeof e=="boolean"||e===null?e:gl(Array.isArray(e)?e.join(","):e)}function XM(e){return new Ft(gl(e))}fe.stringify=XM;function gl(e){return JSON.stringify(e).replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}fe.safeStringify=gl;function QM(e){return typeof e=="string"&&fe.IDENTIFIER.test(e)?new Ft(`.${e}`):BC`[${e}]`}fe.getProperty=QM;function eL(e){if(typeof e=="string"&&fe.IDENTIFIER.test(e))return new Ft(`${e}`);throw new Error(`CodeGen: invalid export name: ${e}, use explicit $id name mapping`)}fe.getEsmExportName=eL;function tL(e){return new Ft(e.toString())}fe.regexpCode=tL});var Ey=j(Et=>{"use strict";Object.defineProperty(Et,"__esModule",{value:!0});Et.ValueScope=Et.ValueScopeName=Et.Scope=Et.varKinds=Et.UsedValueState=void 0;var St=hl(),wy=class extends Error{constructor(t){super(`CodeGen: "code" for ${t} not defined`),this.value=t.value}},mm;(function(e){e[e.Started=0]="Started",e[e.Completed=1]="Completed"})(mm||(Et.UsedValueState=mm={}));Et.varKinds={const:new St.Name("const"),let:new St.Name("let"),var:new St.Name("var")};var gm=class{constructor({prefixes:t,parent:r}={}){this._names={},this._prefixes=t,this._parent=r}toName(t){return t instanceof St.Name?t:this.name(t)}name(t){return new St.Name(this._newName(t))}_newName(t){let r=this._names[t]||this._nameGroup(t);return`${t}${r.index++}`}_nameGroup(t){var r,a;if(!((a=(r=this._parent)===null||r===void 0?void 0:r._prefixes)===null||a===void 0)&&a.has(t)||this._prefixes&&!this._prefixes.has(t))throw new Error(`CodeGen: prefix "${t}" is not allowed in this scope`);return this._names[t]={prefix:t,index:0}}};Et.Scope=gm;var hm=class extends St.Name{constructor(t,r){super(r),this.prefix=t}setValue(t,{property:r,itemIndex:a}){this.value=t,this.scopePath=(0,St._)`.${new St.Name(r)}[${a}]`}};Et.ValueScopeName=hm;var nL=(0,St._)`\n`,Sy=class extends gm{constructor(t){super(t),this._values={},this._scope=t.scope,this.opts={...t,_n:t.lines?nL:St.nil}}get(){return this._scope}name(t){return new hm(t,this._newName(t))}value(t,r){var a;if(r.ref===void 0)throw new Error("CodeGen: ref must be passed in value");let n=this.toName(t),{prefix:i}=n,o=(a=r.key)!==null&&a!==void 0?a:r.ref,s=this._values[i];if(s){let u=s.get(o);if(u)return u}else s=this._values[i]=new Map;s.set(o,n);let l=this._scope[i]||(this._scope[i]=[]),c=l.length;return l[c]=r.ref,n.setValue(r,{property:i,itemIndex:c}),n}getValue(t,r){let a=this._values[t];if(a)return a.get(r)}scopeRefs(t,r=this._values){return this._reduceValues(r,a=>{if(a.scopePath===void 0)throw new Error(`CodeGen: name "${a}" has no value`);return(0,St._)`${t}${a.scopePath}`})}scopeCode(t=this._values,r,a){return this._reduceValues(t,n=>{if(n.value===void 0)throw new Error(`CodeGen: name "${n}" has no value`);return n.value.code},r,a)}_reduceValues(t,r,a={},n){let i=St.nil;for(let o in t){let s=t[o];if(!s)continue;let l=a[o]=a[o]||new Map;s.forEach(c=>{if(l.has(c))return;l.set(c,mm.Started);let u=r(c);if(u){let d=this.opts.es5?Et.varKinds.var:Et.varKinds.const;i=(0,St._)`${i}${d} ${c} = ${u};${this.opts._n}`}else if(u=n?.(c))i=(0,St._)`${i}${u}${this.opts._n}`;else throw new wy(c);l.set(c,mm.Completed)})}return i}};Et.ValueScope=Sy});var ne=j(oe=>{"use strict";Object.defineProperty(oe,"__esModule",{value:!0});oe.or=oe.and=oe.not=oe.CodeGen=oe.operators=oe.varKinds=oe.ValueScopeName=oe.ValueScope=oe.Scope=oe.Name=oe.regexpCode=oe.stringify=oe.getProperty=oe.nil=oe.strConcat=oe.str=oe._=void 0;var de=hl(),en=Ey(),wr=hl();Object.defineProperty(oe,"_",{enumerable:!0,get:function(){return wr._}});Object.defineProperty(oe,"str",{enumerable:!0,get:function(){return wr.str}});Object.defineProperty(oe,"strConcat",{enumerable:!0,get:function(){return wr.strConcat}});Object.defineProperty(oe,"nil",{enumerable:!0,get:function(){return wr.nil}});Object.defineProperty(oe,"getProperty",{enumerable:!0,get:function(){return wr.getProperty}});Object.defineProperty(oe,"stringify",{enumerable:!0,get:function(){return wr.stringify}});Object.defineProperty(oe,"regexpCode",{enumerable:!0,get:function(){return wr.regexpCode}});Object.defineProperty(oe,"Name",{enumerable:!0,get:function(){return wr.Name}});var ym=Ey();Object.defineProperty(oe,"Scope",{enumerable:!0,get:function(){return ym.Scope}});Object.defineProperty(oe,"ValueScope",{enumerable:!0,get:function(){return ym.ValueScope}});Object.defineProperty(oe,"ValueScopeName",{enumerable:!0,get:function(){return ym.ValueScopeName}});Object.defineProperty(oe,"varKinds",{enumerable:!0,get:function(){return ym.varKinds}});oe.operators={GT:new de._Code(">"),GTE:new de._Code(">="),LT:new de._Code("<"),LTE:new de._Code("<="),EQ:new de._Code("==="),NEQ:new de._Code("!=="),NOT:new de._Code("!"),OR:new de._Code("||"),AND:new de._Code("&&"),ADD:new de._Code("+")};var Wn=class{optimizeNodes(){return this}optimizeNames(t,r){return this}},xy=class extends Wn{constructor(t,r,a){super(),this.varKind=t,this.name=r,this.rhs=a}render({es5:t,_n:r}){let a=t?en.varKinds.var:this.varKind,n=this.rhs===void 0?"":` = ${this.rhs}`;return`${a} ${this.name}${n};`+r}optimizeNames(t,r){if(t[this.name.str])return this.rhs&&(this.rhs=Ki(this.rhs,t,r)),this}get names(){return this.rhs instanceof de._CodeOrName?this.rhs.names:{}}},fm=class extends Wn{constructor(t,r,a){super(),this.lhs=t,this.rhs=r,this.sideEffects=a}render({_n:t}){return`${this.lhs} = ${this.rhs};`+t}optimizeNames(t,r){if(!(this.lhs instanceof de.Name&&!t[this.lhs.str]&&!this.sideEffects))return this.rhs=Ki(this.rhs,t,r),this}get names(){let t=this.lhs instanceof de.Name?{}:{...this.lhs.names};return vm(t,this.rhs)}},Ty=class extends fm{constructor(t,r,a,n){super(t,a,n),this.op=r}render({_n:t}){return`${this.lhs} ${this.op}= ${this.rhs};`+t}},Ay=class extends Wn{constructor(t){super(),this.label=t,this.names={}}render({_n:t}){return`${this.label}:`+t}},Cy=class extends Wn{constructor(t){super(),this.label=t,this.names={}}render({_n:t}){return`break${this.label?` ${this.label}`:""};`+t}},zy=class extends Wn{constructor(t){super(),this.error=t}render({_n:t}){return`throw ${this.error};`+t}get names(){return this.error.names}},Iy=class extends Wn{constructor(t){super(),this.code=t}render({_n:t}){return`${this.code};`+t}optimizeNodes(){return`${this.code}`?this:void 0}optimizeNames(t,r){return this.code=Ki(this.code,t,r),this}get names(){return this.code instanceof de._CodeOrName?this.code.names:{}}},fl=class extends Wn{constructor(t=[]){super(),this.nodes=t}render(t){return this.nodes.reduce((r,a)=>r+a.render(t),"")}optimizeNodes(){let{nodes:t}=this,r=t.length;for(;r--;){let a=t[r].optimizeNodes();Array.isArray(a)?t.splice(r,1,...a):a?t[r]=a:t.splice(r,1)}return t.length>0?this:void 0}optimizeNames(t,r){let{nodes:a}=this,n=a.length;for(;n--;){let i=a[n];i.optimizeNames(t,r)||(rL(t,i.names),a.splice(n,1))}return a.length>0?this:void 0}get names(){return this.nodes.reduce((t,r)=>la(t,r.names),{})}},Kn=class extends fl{render(t){return"{"+t._n+super.render(t)+"}"+t._n}},Py=class extends fl{},Wi=class extends Kn{};Wi.kind="else";var oa=class e extends Kn{constructor(t,r){super(r),this.condition=t}render(t){let r=`if(${this.condition})`+super.render(t);return this.else&&(r+="else "+this.else.render(t)),r}optimizeNodes(){super.optimizeNodes();let t=this.condition;if(t===!0)return this.nodes;let r=this.else;if(r){let a=r.optimizeNodes();r=this.else=Array.isArray(a)?new Wi(a):a}if(r)return t===!1?r instanceof e?r:r.nodes:this.nodes.length?this:new e(FC(t),r instanceof e?[r]:r.nodes);if(!(t===!1||!this.nodes.length))return this}optimizeNames(t,r){var a;if(this.else=(a=this.else)===null||a===void 0?void 0:a.optimizeNames(t,r),!!(super.optimizeNames(t,r)||this.else))return this.condition=Ki(this.condition,t,r),this}get names(){let t=super.names;return vm(t,this.condition),this.else&&la(t,this.else.names),t}};oa.kind="if";var sa=class extends Kn{};sa.kind="for";var Ry=class extends sa{constructor(t){super(),this.iteration=t}render(t){return`for(${this.iteration})`+super.render(t)}optimizeNames(t,r){if(super.optimizeNames(t,r))return this.iteration=Ki(this.iteration,t,r),this}get names(){return la(super.names,this.iteration.names)}},$y=class extends sa{constructor(t,r,a,n){super(),this.varKind=t,this.name=r,this.from=a,this.to=n}render(t){let r=t.es5?en.varKinds.var:this.varKind,{name:a,from:n,to:i}=this;return`for(${r} ${a}=${n}; ${a}<${i}; ${a}++)`+super.render(t)}get names(){let t=vm(super.names,this.from);return vm(t,this.to)}},bm=class extends sa{constructor(t,r,a,n){super(),this.loop=t,this.varKind=r,this.name=a,this.iterable=n}render(t){return`for(${this.varKind} ${this.name} ${this.loop} ${this.iterable})`+super.render(t)}optimizeNames(t,r){if(super.optimizeNames(t,r))return this.iterable=Ki(this.iterable,t,r),this}get names(){return la(super.names,this.iterable.names)}},bl=class extends Kn{constructor(t,r,a){super(),this.name=t,this.args=r,this.async=a}render(t){return`${this.async?"async ":""}function ${this.name}(${this.args})`+super.render(t)}};bl.kind="func";var vl=class extends fl{render(t){return"return "+super.render(t)}};vl.kind="return";var jy=class extends Kn{render(t){let r="try"+super.render(t);return this.catch&&(r+=this.catch.render(t)),this.finally&&(r+=this.finally.render(t)),r}optimizeNodes(){var t,r;return super.optimizeNodes(),(t=this.catch)===null||t===void 0||t.optimizeNodes(),(r=this.finally)===null||r===void 0||r.optimizeNodes(),this}optimizeNames(t,r){var a,n;return super.optimizeNames(t,r),(a=this.catch)===null||a===void 0||a.optimizeNames(t,r),(n=this.finally)===null||n===void 0||n.optimizeNames(t,r),this}get names(){let t=super.names;return this.catch&&la(t,this.catch.names),this.finally&&la(t,this.finally.names),t}},yl=class extends Kn{constructor(t){super(),this.error=t}render(t){return`catch(${this.error})`+super.render(t)}};yl.kind="catch";var kl=class extends Kn{render(t){return"finally"+super.render(t)}};kl.kind="finally";var Oy=class{constructor(t,r={}){this._values={},this._blockStarts=[],this._constants={},this.opts={...r,_n:r.lines?`
|
|
3
|
+
`:""},this._extScope=t,this._scope=new en.Scope({parent:t}),this._nodes=[new Py]}toString(){return this._root.render(this.opts)}name(t){return this._scope.name(t)}scopeName(t){return this._extScope.name(t)}scopeValue(t,r){let a=this._extScope.value(t,r);return(this._values[a.prefix]||(this._values[a.prefix]=new Set)).add(a),a}getScopeValue(t,r){return this._extScope.getValue(t,r)}scopeRefs(t){return this._extScope.scopeRefs(t,this._values)}scopeCode(){return this._extScope.scopeCode(this._values)}_def(t,r,a,n){let i=this._scope.toName(r);return a!==void 0&&n&&(this._constants[i.str]=a),this._leafNode(new xy(t,i,a)),i}const(t,r,a){return this._def(en.varKinds.const,t,r,a)}let(t,r,a){return this._def(en.varKinds.let,t,r,a)}var(t,r,a){return this._def(en.varKinds.var,t,r,a)}assign(t,r,a){return this._leafNode(new fm(t,r,a))}add(t,r){return this._leafNode(new Ty(t,oe.operators.ADD,r))}code(t){return typeof t=="function"?t():t!==de.nil&&this._leafNode(new Iy(t)),this}object(...t){let r=["{"];for(let[a,n]of t)r.length>1&&r.push(","),r.push(a),(a!==n||this.opts.es5)&&(r.push(":"),(0,de.addCodeArg)(r,n));return r.push("}"),new de._Code(r)}if(t,r,a){if(this._blockNode(new oa(t)),r&&a)this.code(r).else().code(a).endIf();else if(r)this.code(r).endIf();else if(a)throw new Error('CodeGen: "else" body without "then" body');return this}elseIf(t){return this._elseNode(new oa(t))}else(){return this._elseNode(new Wi)}endIf(){return this._endBlockNode(oa,Wi)}_for(t,r){return this._blockNode(t),r&&this.code(r).endFor(),this}for(t,r){return this._for(new Ry(t),r)}forRange(t,r,a,n,i=this.opts.es5?en.varKinds.var:en.varKinds.let){let o=this._scope.toName(t);return this._for(new $y(i,o,r,a),()=>n(o))}forOf(t,r,a,n=en.varKinds.const){let i=this._scope.toName(t);if(this.opts.es5){let o=r instanceof de.Name?r:this.var("_arr",r);return this.forRange("_i",0,(0,de._)`${o}.length`,s=>{this.var(i,(0,de._)`${o}[${s}]`),a(i)})}return this._for(new bm("of",n,i,r),()=>a(i))}forIn(t,r,a,n=this.opts.es5?en.varKinds.var:en.varKinds.const){if(this.opts.ownProperties)return this.forOf(t,(0,de._)`Object.keys(${r})`,a);let i=this._scope.toName(t);return this._for(new bm("in",n,i,r),()=>a(i))}endFor(){return this._endBlockNode(sa)}label(t){return this._leafNode(new Ay(t))}break(t){return this._leafNode(new Cy(t))}return(t){let r=new vl;if(this._blockNode(r),this.code(t),r.nodes.length!==1)throw new Error('CodeGen: "return" should have one node');return this._endBlockNode(vl)}try(t,r,a){if(!r&&!a)throw new Error('CodeGen: "try" without "catch" and "finally"');let n=new jy;if(this._blockNode(n),this.code(t),r){let i=this.name("e");this._currNode=n.catch=new yl(i),r(i)}return a&&(this._currNode=n.finally=new kl,this.code(a)),this._endBlockNode(yl,kl)}throw(t){return this._leafNode(new zy(t))}block(t,r){return this._blockStarts.push(this._nodes.length),t&&this.code(t).endBlock(r),this}endBlock(t){let r=this._blockStarts.pop();if(r===void 0)throw new Error("CodeGen: not in self-balancing block");let a=this._nodes.length-r;if(a<0||t!==void 0&&a!==t)throw new Error(`CodeGen: wrong number of nodes: ${a} vs ${t} expected`);return this._nodes.length=r,this}func(t,r=de.nil,a,n){return this._blockNode(new bl(t,r,a)),n&&this.code(n).endFunc(),this}endFunc(){return this._endBlockNode(bl)}optimize(t=1){for(;t-- >0;)this._root.optimizeNodes(),this._root.optimizeNames(this._root.names,this._constants)}_leafNode(t){return this._currNode.nodes.push(t),this}_blockNode(t){this._currNode.nodes.push(t),this._nodes.push(t)}_endBlockNode(t,r){let a=this._currNode;if(a instanceof t||r&&a instanceof r)return this._nodes.pop(),this;throw new Error(`CodeGen: not in block "${r?`${t.kind}/${r.kind}`:t.kind}"`)}_elseNode(t){let r=this._currNode;if(!(r instanceof oa))throw new Error('CodeGen: "else" without "if"');return this._currNode=r.else=t,this}get _root(){return this._nodes[0]}get _currNode(){let t=this._nodes;return t[t.length-1]}set _currNode(t){let r=this._nodes;r[r.length-1]=t}};oe.CodeGen=Oy;function la(e,t){for(let r in t)e[r]=(e[r]||0)+(t[r]||0);return e}function vm(e,t){return t instanceof de._CodeOrName?la(e,t.names):e}function Ki(e,t,r){if(e instanceof de.Name)return a(e);if(!n(e))return e;return new de._Code(e._items.reduce((i,o)=>(o instanceof de.Name&&(o=a(o)),o instanceof de._Code?i.push(...o._items):i.push(o),i),[]));function a(i){let o=r[i.str];return o===void 0||t[i.str]!==1?i:(delete t[i.str],o)}function n(i){return i instanceof de._Code&&i._items.some(o=>o instanceof de.Name&&t[o.str]===1&&r[o.str]!==void 0)}}function rL(e,t){for(let r in t)e[r]=(e[r]||0)-(t[r]||0)}function FC(e){return typeof e=="boolean"||typeof e=="number"||e===null?!e:(0,de._)`!${Ny(e)}`}oe.not=FC;var aL=qC(oe.operators.AND);function iL(...e){return e.reduce(aL)}oe.and=iL;var oL=qC(oe.operators.OR);function sL(...e){return e.reduce(oL)}oe.or=sL;function qC(e){return(t,r)=>t===de.nil?r:r===de.nil?t:(0,de._)`${Ny(t)} ${e} ${Ny(r)}`}function Ny(e){return e instanceof de.Name?e:(0,de._)`(${e})`}});var pe=j(le=>{"use strict";Object.defineProperty(le,"__esModule",{value:!0});le.checkStrictMode=le.getErrorPath=le.Type=le.useFunc=le.setEvaluated=le.evaluatedPropsToName=le.mergeEvaluated=le.eachItem=le.unescapeJsonPointer=le.escapeJsonPointer=le.escapeFragment=le.unescapeFragment=le.schemaRefOrVal=le.schemaHasRulesButRef=le.schemaHasRules=le.checkUnknownRules=le.alwaysValidSchema=le.toHash=void 0;var ze=ne(),lL=hl();function cL(e){let t={};for(let r of e)t[r]=!0;return t}le.toHash=cL;function uL(e,t){return typeof t=="boolean"?t:Object.keys(t).length===0?!0:(VC(e,t),!WC(t,e.self.RULES.all))}le.alwaysValidSchema=uL;function VC(e,t=e.schema){let{opts:r,self:a}=e;if(!r.strictSchema||typeof t=="boolean")return;let n=a.RULES.keywords;for(let i in t)n[i]||JC(e,`unknown keyword: "${i}"`)}le.checkUnknownRules=VC;function WC(e,t){if(typeof e=="boolean")return!e;for(let r in e)if(t[r])return!0;return!1}le.schemaHasRules=WC;function dL(e,t){if(typeof e=="boolean")return!e;for(let r in e)if(r!=="$ref"&&t.all[r])return!0;return!1}le.schemaHasRulesButRef=dL;function pL({topSchemaRef:e,schemaPath:t},r,a,n){if(!n){if(typeof r=="number"||typeof r=="boolean")return r;if(typeof r=="string")return(0,ze._)`${r}`}return(0,ze._)`${e}${t}${(0,ze.getProperty)(a)}`}le.schemaRefOrVal=pL;function mL(e){return KC(decodeURIComponent(e))}le.unescapeFragment=mL;function gL(e){return encodeURIComponent(My(e))}le.escapeFragment=gL;function My(e){return typeof e=="number"?`${e}`:e.replace(/~/g,"~0").replace(/\//g,"~1")}le.escapeJsonPointer=My;function KC(e){return e.replace(/~1/g,"/").replace(/~0/g,"~")}le.unescapeJsonPointer=KC;function hL(e,t){if(Array.isArray(e))for(let r of e)t(r);else t(e)}le.eachItem=hL;function HC({mergeNames:e,mergeToName:t,mergeValues:r,resultToName:a}){return(n,i,o,s)=>{let l=o===void 0?i:o instanceof ze.Name?(i instanceof ze.Name?e(n,i,o):t(n,i,o),o):i instanceof ze.Name?(t(n,o,i),i):r(i,o);return s===ze.Name&&!(l instanceof ze.Name)?a(n,l):l}}le.mergeEvaluated={props:HC({mergeNames:(e,t,r)=>e.if((0,ze._)`${r} !== true && ${t} !== undefined`,()=>{e.if((0,ze._)`${t} === true`,()=>e.assign(r,!0),()=>e.assign(r,(0,ze._)`${r} || {}`).code((0,ze._)`Object.assign(${r}, ${t})`))}),mergeToName:(e,t,r)=>e.if((0,ze._)`${r} !== true`,()=>{t===!0?e.assign(r,!0):(e.assign(r,(0,ze._)`${r} || {}`),Ly(e,r,t))}),mergeValues:(e,t)=>e===!0?!0:{...e,...t},resultToName:ZC}),items:HC({mergeNames:(e,t,r)=>e.if((0,ze._)`${r} !== true && ${t} !== undefined`,()=>e.assign(r,(0,ze._)`${t} === true ? true : ${r} > ${t} ? ${r} : ${t}`)),mergeToName:(e,t,r)=>e.if((0,ze._)`${r} !== true`,()=>e.assign(r,t===!0?!0:(0,ze._)`${r} > ${t} ? ${r} : ${t}`)),mergeValues:(e,t)=>e===!0?!0:Math.max(e,t),resultToName:(e,t)=>e.var("items",t)})};function ZC(e,t){if(t===!0)return e.var("props",!0);let r=e.var("props",(0,ze._)`{}`);return t!==void 0&&Ly(e,r,t),r}le.evaluatedPropsToName=ZC;function Ly(e,t,r){Object.keys(r).forEach(a=>e.assign((0,ze._)`${t}${(0,ze.getProperty)(a)}`,!0))}le.setEvaluated=Ly;var GC={};function fL(e,t){return e.scopeValue("func",{ref:t,code:GC[t.code]||(GC[t.code]=new lL._Code(t.code))})}le.useFunc=fL;var Dy;(function(e){e[e.Num=0]="Num",e[e.Str=1]="Str"})(Dy||(le.Type=Dy={}));function bL(e,t,r){if(e instanceof ze.Name){let a=t===Dy.Num;return r?a?(0,ze._)`"[" + ${e} + "]"`:(0,ze._)`"['" + ${e} + "']"`:a?(0,ze._)`"/" + ${e}`:(0,ze._)`"/" + ${e}.replace(/~/g, "~0").replace(/\\//g, "~1")`}return r?(0,ze.getProperty)(e).toString():"/"+My(e)}le.getErrorPath=bL;function JC(e,t,r=e.opts.strictSchema){if(r){if(t=`strict mode: ${t}`,r===!0)throw new Error(t);e.self.logger.warn(t)}}le.checkStrictMode=JC});var Zn=j(By=>{"use strict";Object.defineProperty(By,"__esModule",{value:!0});var at=ne(),vL={data:new at.Name("data"),valCxt:new at.Name("valCxt"),instancePath:new at.Name("instancePath"),parentData:new at.Name("parentData"),parentDataProperty:new at.Name("parentDataProperty"),rootData:new at.Name("rootData"),dynamicAnchors:new at.Name("dynamicAnchors"),vErrors:new at.Name("vErrors"),errors:new at.Name("errors"),this:new at.Name("this"),self:new at.Name("self"),scope:new at.Name("scope"),json:new at.Name("json"),jsonPos:new at.Name("jsonPos"),jsonLen:new at.Name("jsonLen"),jsonPart:new at.Name("jsonPart")};By.default=vL});var _l=j(it=>{"use strict";Object.defineProperty(it,"__esModule",{value:!0});it.extendErrors=it.resetErrorsCount=it.reportExtraError=it.reportError=it.keyword$DataError=it.keywordError=void 0;var me=ne(),km=pe(),ft=Zn();it.keywordError={message:({keyword:e})=>(0,me.str)`must pass "${e}" keyword validation`};it.keyword$DataError={message:({keyword:e,schemaType:t})=>t?(0,me.str)`"${e}" keyword must be ${t} ($data)`:(0,me.str)`"${e}" keyword is invalid ($data)`};function yL(e,t=it.keywordError,r,a){let{it:n}=e,{gen:i,compositeRule:o,allErrors:s}=n,l=QC(e,t,r);a??(o||s)?YC(i,l):XC(n,(0,me._)`[${l}]`)}it.reportError=yL;function kL(e,t=it.keywordError,r){let{it:a}=e,{gen:n,compositeRule:i,allErrors:o}=a,s=QC(e,t,r);YC(n,s),i||o||XC(a,ft.default.vErrors)}it.reportExtraError=kL;function _L(e,t){e.assign(ft.default.errors,t),e.if((0,me._)`${ft.default.vErrors} !== null`,()=>e.if(t,()=>e.assign((0,me._)`${ft.default.vErrors}.length`,t),()=>e.assign(ft.default.vErrors,null)))}it.resetErrorsCount=_L;function wL({gen:e,keyword:t,schemaValue:r,data:a,errsCount:n,it:i}){if(n===void 0)throw new Error("ajv implementation error");let o=e.name("err");e.forRange("i",n,ft.default.errors,s=>{e.const(o,(0,me._)`${ft.default.vErrors}[${s}]`),e.if((0,me._)`${o}.instancePath === undefined`,()=>e.assign((0,me._)`${o}.instancePath`,(0,me.strConcat)(ft.default.instancePath,i.errorPath))),e.assign((0,me._)`${o}.schemaPath`,(0,me.str)`${i.errSchemaPath}/${t}`),i.opts.verbose&&(e.assign((0,me._)`${o}.schema`,r),e.assign((0,me._)`${o}.data`,a))})}it.extendErrors=wL;function YC(e,t){let r=e.const("err",t);e.if((0,me._)`${ft.default.vErrors} === null`,()=>e.assign(ft.default.vErrors,(0,me._)`[${r}]`),(0,me._)`${ft.default.vErrors}.push(${r})`),e.code((0,me._)`${ft.default.errors}++`)}function XC(e,t){let{gen:r,validateName:a,schemaEnv:n}=e;n.$async?r.throw((0,me._)`new ${e.ValidationError}(${t})`):(r.assign((0,me._)`${a}.errors`,t),r.return(!1))}var ca={keyword:new me.Name("keyword"),schemaPath:new me.Name("schemaPath"),params:new me.Name("params"),propertyName:new me.Name("propertyName"),message:new me.Name("message"),schema:new me.Name("schema"),parentSchema:new me.Name("parentSchema")};function QC(e,t,r){let{createErrors:a}=e.it;return a===!1?(0,me._)`{}`:SL(e,t,r)}function SL(e,t,r={}){let{gen:a,it:n}=e,i=[EL(n,r),xL(e,r)];return TL(e,t,i),a.object(...i)}function EL({errorPath:e},{instancePath:t}){let r=t?(0,me.str)`${e}${(0,km.getErrorPath)(t,km.Type.Str)}`:e;return[ft.default.instancePath,(0,me.strConcat)(ft.default.instancePath,r)]}function xL({keyword:e,it:{errSchemaPath:t}},{schemaPath:r,parentSchema:a}){let n=a?t:(0,me.str)`${t}/${e}`;return r&&(n=(0,me.str)`${n}${(0,km.getErrorPath)(r,km.Type.Str)}`),[ca.schemaPath,n]}function TL(e,{params:t,message:r},a){let{keyword:n,data:i,schemaValue:o,it:s}=e,{opts:l,propertyName:c,topSchemaRef:u,schemaPath:d}=s;a.push([ca.keyword,n],[ca.params,typeof t=="function"?t(e):t||(0,me._)`{}`]),l.messages&&a.push([ca.message,typeof r=="function"?r(e):r]),l.verbose&&a.push([ca.schema,o],[ca.parentSchema,(0,me._)`${u}${d}`],[ft.default.data,i]),c&&a.push([ca.propertyName,c])}});var tz=j(Zi=>{"use strict";Object.defineProperty(Zi,"__esModule",{value:!0});Zi.boolOrEmptySchema=Zi.topBoolOrEmptySchema=void 0;var AL=_l(),CL=ne(),zL=Zn(),IL={message:"boolean schema is false"};function PL(e){let{gen:t,schema:r,validateName:a}=e;r===!1?ez(e,!1):typeof r=="object"&&r.$async===!0?t.return(zL.default.data):(t.assign((0,CL._)`${a}.errors`,null),t.return(!0))}Zi.topBoolOrEmptySchema=PL;function RL(e,t){let{gen:r,schema:a}=e;a===!1?(r.var(t,!1),ez(e)):r.var(t,!0)}Zi.boolOrEmptySchema=RL;function ez(e,t){let{gen:r,data:a}=e,n={gen:r,keyword:"false schema",data:a,schema:!1,schemaCode:!1,schemaValue:!1,params:{},it:e};(0,AL.reportError)(n,IL,void 0,t)}});var Uy=j(Ji=>{"use strict";Object.defineProperty(Ji,"__esModule",{value:!0});Ji.getRules=Ji.isJSONType=void 0;var $L=["string","number","integer","boolean","null","object","array"],jL=new Set($L);function OL(e){return typeof e=="string"&&jL.has(e)}Ji.isJSONType=OL;function NL(){let e={number:{type:"number",rules:[]},string:{type:"string",rules:[]},array:{type:"array",rules:[]},object:{type:"object",rules:[]}};return{types:{...e,integer:!0,boolean:!0,null:!0},rules:[{rules:[]},e.number,e.string,e.array,e.object],post:{rules:[]},all:{},keywords:{}}}Ji.getRules=NL});var Fy=j(Sr=>{"use strict";Object.defineProperty(Sr,"__esModule",{value:!0});Sr.shouldUseRule=Sr.shouldUseGroup=Sr.schemaHasRulesForType=void 0;function DL({schema:e,self:t},r){let a=t.RULES.types[r];return a&&a!==!0&&nz(e,a)}Sr.schemaHasRulesForType=DL;function nz(e,t){return t.rules.some(r=>rz(e,r))}Sr.shouldUseGroup=nz;function rz(e,t){var r;return e[t.keyword]!==void 0||((r=t.definition.implements)===null||r===void 0?void 0:r.some(a=>e[a]!==void 0))}Sr.shouldUseRule=rz});var wl=j(ot=>{"use strict";Object.defineProperty(ot,"__esModule",{value:!0});ot.reportTypeError=ot.checkDataTypes=ot.checkDataType=ot.coerceAndCheckDataType=ot.getJSONTypes=ot.getSchemaTypes=ot.DataType=void 0;var ML=Uy(),LL=Fy(),BL=_l(),te=ne(),az=pe(),Yi;(function(e){e[e.Correct=0]="Correct",e[e.Wrong=1]="Wrong"})(Yi||(ot.DataType=Yi={}));function UL(e){let t=iz(e.type);if(t.includes("null")){if(e.nullable===!1)throw new Error("type: null contradicts nullable: false")}else{if(!t.length&&e.nullable!==void 0)throw new Error('"nullable" cannot be used without "type"');e.nullable===!0&&t.push("null")}return t}ot.getSchemaTypes=UL;function iz(e){let t=Array.isArray(e)?e:e?[e]:[];if(t.every(ML.isJSONType))return t;throw new Error("type must be JSONType or JSONType[]: "+t.join(","))}ot.getJSONTypes=iz;function FL(e,t){let{gen:r,data:a,opts:n}=e,i=qL(t,n.coerceTypes),o=t.length>0&&!(i.length===0&&t.length===1&&(0,LL.schemaHasRulesForType)(e,t[0]));if(o){let s=Hy(t,a,n.strictNumbers,Yi.Wrong);r.if(s,()=>{i.length?HL(e,t,i):Gy(e)})}return o}ot.coerceAndCheckDataType=FL;var oz=new Set(["string","number","integer","boolean","null"]);function qL(e,t){return t?e.filter(r=>oz.has(r)||t==="array"&&r==="array"):[]}function HL(e,t,r){let{gen:a,data:n,opts:i}=e,o=a.let("dataType",(0,te._)`typeof ${n}`),s=a.let("coerced",(0,te._)`undefined`);i.coerceTypes==="array"&&a.if((0,te._)`${o} == 'object' && Array.isArray(${n}) && ${n}.length == 1`,()=>a.assign(n,(0,te._)`${n}[0]`).assign(o,(0,te._)`typeof ${n}`).if(Hy(t,n,i.strictNumbers),()=>a.assign(s,n))),a.if((0,te._)`${s} !== undefined`);for(let c of r)(oz.has(c)||c==="array"&&i.coerceTypes==="array")&&l(c);a.else(),Gy(e),a.endIf(),a.if((0,te._)`${s} !== undefined`,()=>{a.assign(n,s),GL(e,s)});function l(c){switch(c){case"string":a.elseIf((0,te._)`${o} == "number" || ${o} == "boolean"`).assign(s,(0,te._)`"" + ${n}`).elseIf((0,te._)`${n} === null`).assign(s,(0,te._)`""`);return;case"number":a.elseIf((0,te._)`${o} == "boolean" || ${n} === null
|
|
4
4
|
|| (${o} == "string" && ${n} && ${n} == +${n})`).assign(s,(0,te._)`+${n}`);return;case"integer":a.elseIf((0,te._)`${o} === "boolean" || ${n} === null
|
|
5
5
|
|| (${o} === "string" && ${n} && ${n} == +${n} && !(${n} % 1))`).assign(s,(0,te._)`+${n}`);return;case"boolean":a.elseIf((0,te._)`${n} === "false" || ${n} === 0 || ${n} === null`).assign(s,!1).elseIf((0,te._)`${n} === "true" || ${n} === 1`).assign(s,!0);return;case"null":a.elseIf((0,te._)`${n} === "" || ${n} === 0 || ${n} === false`),a.assign(s,null);return;case"array":a.elseIf((0,te._)`${o} === "string" || ${o} === "number"
|
|
6
|
-
|| ${o} === "boolean" || ${n} === null`).assign(s,(0,te._)`[${n}]`)}}}function qL({gen:e,parentData:t,parentDataProperty:r},a){e.if((0,te._)`${t} !== undefined`,()=>e.assign((0,te._)`${t}[${r}]`,a))}function qy(e,t,r,a=Yi.Correct){let n=a===Yi.Correct?te.operators.EQ:te.operators.NEQ,i;switch(e){case"null":return(0,te._)`${t} ${n} null`;case"array":i=(0,te._)`Array.isArray(${t})`;break;case"object":i=(0,te._)`${t} && typeof ${t} == "object" && !Array.isArray(${t})`;break;case"integer":i=o((0,te._)`!(${t} % 1) && !isNaN(${t})`);break;case"number":i=o();break;default:return(0,te._)`typeof ${t} ${n} ${e}`}return a===Yi.Correct?i:(0,te.not)(i);function o(s=te.nil){return(0,te.and)((0,te._)`typeof ${t} == "number"`,s,r?(0,te._)`isFinite(${t})`:te.nil)}}ot.checkDataType=qy;function Hy(e,t,r,a){if(e.length===1)return qy(e[0],t,r,a);let n,i=(0,az.toHash)(e);if(i.array&&i.object){let o=(0,te._)`typeof ${t} != "object"`;n=i.null?o:(0,te._)`!${t} || ${o}`,delete i.null,delete i.array,delete i.object}else n=te.nil;i.number&&delete i.integer;for(let o in i)n=(0,te.and)(n,qy(o,t,r,a));return n}ot.checkDataTypes=Hy;var HL={message:({schema:e})=>`must be ${e}`,params:({schema:e,schemaValue:t})=>typeof e=="string"?(0,te._)`{type: ${e}}`:(0,te._)`{type: ${t}}`};function Gy(e){let t=GL(e);(0,ML.reportError)(t,HL)}ot.reportTypeError=Gy;function GL(e){let{gen:t,data:r,schema:a}=e,n=(0,az.schemaRefOrVal)(e,a,"type");return{gen:t,keyword:"type",data:r,schema:a.type,schemaCode:n,schemaValue:n,parentSchema:a,params:{},it:e}}});var lz=j(_m=>{"use strict";Object.defineProperty(_m,"__esModule",{value:!0});_m.assignDefaults=void 0;var Xi=ne(),VL=pe();function WL(e,t){let{properties:r,items:a}=e.schema;if(t==="object"&&r)for(let n in r)sz(e,n,r[n].default);else t==="array"&&Array.isArray(a)&&a.forEach((n,i)=>sz(e,i,n.default))}_m.assignDefaults=WL;function sz(e,t,r){let{gen:a,compositeRule:n,data:i,opts:o}=e;if(r===void 0)return;let s=(0,Xi._)`${i}${(0,Xi.getProperty)(t)}`;if(n){(0,VL.checkStrictMode)(e,`default is ignored for: ${s}`);return}let l=(0,Xi._)`${s} === undefined`;o.useDefaults==="empty"&&(l=(0,Xi._)`${l} || ${s} === null || ${s} === ""`),a.if(l,(0,Xi._)`${s} = ${(0,Xi.stringify)(r)}`)}});var qt=j(Ae=>{"use strict";Object.defineProperty(Ae,"__esModule",{value:!0});Ae.validateUnion=Ae.validateArray=Ae.usePattern=Ae.callValidateCode=Ae.schemaProperties=Ae.allSchemaProperties=Ae.noPropertyInData=Ae.propertyInData=Ae.isOwnProperty=Ae.hasPropFunc=Ae.reportMissingProp=Ae.checkMissingProp=Ae.checkReportMissingProp=void 0;var Pe=ne(),Vy=pe(),Er=Zn(),KL=pe();function ZL(e,t){let{gen:r,data:a,it:n}=e;r.if(Ky(r,a,t,n.opts.ownProperties),()=>{e.setParams({missingProperty:(0,Pe._)`${t}`},!0),e.error()})}Ae.checkReportMissingProp=ZL;function JL({gen:e,data:t,it:{opts:r}},a,n){return(0,Pe.or)(...a.map(i=>(0,Pe.and)(Ky(e,t,i,r.ownProperties),(0,Pe._)`${n} = ${i}`)))}Ae.checkMissingProp=JL;function YL(e,t){e.setParams({missingProperty:t},!0),e.error()}Ae.reportMissingProp=YL;function cz(e){return e.scopeValue("func",{ref:Object.prototype.hasOwnProperty,code:(0,Pe._)`Object.prototype.hasOwnProperty`})}Ae.hasPropFunc=cz;function Wy(e,t,r){return(0,Pe._)`${cz(e)}.call(${t}, ${r})`}Ae.isOwnProperty=Wy;function XL(e,t,r,a){let n=(0,Pe._)`${t}${(0,Pe.getProperty)(r)} !== undefined`;return a?(0,Pe._)`${n} && ${Wy(e,t,r)}`:n}Ae.propertyInData=XL;function Ky(e,t,r,a){let n=(0,Pe._)`${t}${(0,Pe.getProperty)(r)} === undefined`;return a?(0,Pe.or)(n,(0,Pe.not)(Wy(e,t,r))):n}Ae.noPropertyInData=Ky;function uz(e){return e?Object.keys(e).filter(t=>t!=="__proto__"):[]}Ae.allSchemaProperties=uz;function QL(e,t){return uz(t).filter(r=>!(0,Vy.alwaysValidSchema)(e,t[r]))}Ae.schemaProperties=QL;function e4({schemaCode:e,data:t,it:{gen:r,topSchemaRef:a,schemaPath:n,errorPath:i},it:o},s,l,c){let u=c?(0,Pe._)`${e}, ${t}, ${a}${n}`:t,d=[[Er.default.instancePath,(0,Pe.strConcat)(Er.default.instancePath,i)],[Er.default.parentData,o.parentData],[Er.default.parentDataProperty,o.parentDataProperty],[Er.default.rootData,Er.default.rootData]];o.opts.dynamicRef&&d.push([Er.default.dynamicAnchors,Er.default.dynamicAnchors]);let m=(0,Pe._)`${u}, ${r.object(...d)}`;return l!==Pe.nil?(0,Pe._)`${s}.call(${l}, ${m})`:(0,Pe._)`${s}(${m})`}Ae.callValidateCode=e4;var t4=(0,Pe._)`new RegExp`;function n4({gen:e,it:{opts:t}},r){let a=t.unicodeRegExp?"u":"",{regExp:n}=t.code,i=n(r,a);return e.scopeValue("pattern",{key:i.toString(),ref:i,code:(0,Pe._)`${n.code==="new RegExp"?t4:(0,KL.useFunc)(e,n)}(${r}, ${a})`})}Ae.usePattern=n4;function r4(e){let{gen:t,data:r,keyword:a,it:n}=e,i=t.name("valid");if(n.allErrors){let s=t.let("valid",!0);return o(()=>t.assign(s,!1)),s}return t.var(i,!0),o(()=>t.break()),i;function o(s){let l=t.const("len",(0,Pe._)`${r}.length`);t.forRange("i",0,l,c=>{e.subschema({keyword:a,dataProp:c,dataPropType:Vy.Type.Num},i),t.if((0,Pe.not)(i),s)})}}Ae.validateArray=r4;function a4(e){let{gen:t,schema:r,keyword:a,it:n}=e;if(!Array.isArray(r))throw new Error("ajv implementation error");if(r.some(l=>(0,Vy.alwaysValidSchema)(n,l))&&!n.opts.unevaluated)return;let o=t.let("valid",!1),s=t.name("_valid");t.block(()=>r.forEach((l,c)=>{let u=e.subschema({keyword:a,schemaProp:c,compositeRule:!0},s);t.assign(o,(0,Pe._)`${o} || ${s}`),e.mergeValidEvaluated(u,s)||t.if((0,Pe.not)(o))})),e.result(o,()=>e.reset(),()=>e.error(!0))}Ae.validateUnion=a4});var mz=j(vn=>{"use strict";Object.defineProperty(vn,"__esModule",{value:!0});vn.validateKeywordUsage=vn.validSchemaType=vn.funcKeywordCode=vn.macroKeywordCode=void 0;var bt=ne(),ua=Zn(),i4=qt(),o4=_l();function s4(e,t){let{gen:r,keyword:a,schema:n,parentSchema:i,it:o}=e,s=t.macro.call(o.self,n,i,o),l=pz(r,a,s);o.opts.validateSchema!==!1&&o.self.validateSchema(s,!0);let c=r.name("valid");e.subschema({schema:s,schemaPath:bt.nil,errSchemaPath:`${o.errSchemaPath}/${a}`,topSchemaRef:l,compositeRule:!0},c),e.pass(c,()=>e.error(!0))}vn.macroKeywordCode=s4;function l4(e,t){var r;let{gen:a,keyword:n,schema:i,parentSchema:o,$data:s,it:l}=e;u4(l,t);let c=!s&&t.compile?t.compile.call(l.self,i,o,l):t.validate,u=pz(a,n,c),d=a.let("valid");e.block$data(d,m),e.ok((r=t.valid)!==null&&r!==void 0?r:d);function m(){if(t.errors===!1)h(),t.modifying&&dz(e),f(()=>e.error());else{let _=t.async?p():g();t.modifying&&dz(e),f(()=>c4(e,_))}}function p(){let _=a.let("ruleErrs",null);return a.try(()=>h((0,bt._)`await `),b=>a.assign(d,!1).if((0,bt._)`${b} instanceof ${l.ValidationError}`,()=>a.assign(_,(0,bt._)`${b}.errors`),()=>a.throw(b))),_}function g(){let _=(0,bt._)`${u}.errors`;return a.assign(_,null),h(bt.nil),_}function h(_=t.async?(0,bt._)`await `:bt.nil){let b=l.opts.passContext?ua.default.this:ua.default.self,v=!("compile"in t&&!s||t.schema===!1);a.assign(d,(0,bt._)`${_}${(0,i4.callValidateCode)(e,u,b,v)}`,t.modifying)}function f(_){var b;a.if((0,bt.not)((b=t.valid)!==null&&b!==void 0?b:d),_)}}vn.funcKeywordCode=l4;function dz(e){let{gen:t,data:r,it:a}=e;t.if(a.parentData,()=>t.assign(r,(0,bt._)`${a.parentData}[${a.parentDataProperty}]`))}function c4(e,t){let{gen:r}=e;r.if((0,bt._)`Array.isArray(${t})`,()=>{r.assign(ua.default.vErrors,(0,bt._)`${ua.default.vErrors} === null ? ${t} : ${ua.default.vErrors}.concat(${t})`).assign(ua.default.errors,(0,bt._)`${ua.default.vErrors}.length`),(0,o4.extendErrors)(e)},()=>e.error())}function u4({schemaEnv:e},t){if(t.async&&!e.$async)throw new Error("async keyword in sync schema")}function pz(e,t,r){if(r===void 0)throw new Error(`keyword "${t}" failed to compile`);return e.scopeValue("keyword",typeof r=="function"?{ref:r}:{ref:r,code:(0,bt.stringify)(r)})}function d4(e,t,r=!1){return!t.length||t.some(a=>a==="array"?Array.isArray(e):a==="object"?e&&typeof e=="object"&&!Array.isArray(e):typeof e==a||r&&typeof e>"u")}vn.validSchemaType=d4;function p4({schema:e,opts:t,self:r,errSchemaPath:a},n,i){if(Array.isArray(n.keyword)?!n.keyword.includes(i):n.keyword!==i)throw new Error("ajv implementation error");let o=n.dependencies;if(o?.some(s=>!Object.prototype.hasOwnProperty.call(e,s)))throw new Error(`parent schema must have dependencies of ${i}: ${o.join(",")}`);if(n.validateSchema&&!n.validateSchema(e[i])){let l=`keyword "${i}" value is invalid at path "${a}": `+r.errorsText(n.validateSchema.errors);if(t.validateSchema==="log")r.logger.error(l);else throw new Error(l)}}vn.validateKeywordUsage=p4});var hz=j(xr=>{"use strict";Object.defineProperty(xr,"__esModule",{value:!0});xr.extendSubschemaMode=xr.extendSubschemaData=xr.getSubschema=void 0;var yn=ne(),gz=pe();function m4(e,{keyword:t,schemaProp:r,schema:a,schemaPath:n,errSchemaPath:i,topSchemaRef:o}){if(t!==void 0&&a!==void 0)throw new Error('both "keyword" and "schema" passed, only one allowed');if(t!==void 0){let s=e.schema[t];return r===void 0?{schema:s,schemaPath:(0,yn._)`${e.schemaPath}${(0,yn.getProperty)(t)}`,errSchemaPath:`${e.errSchemaPath}/${t}`}:{schema:s[r],schemaPath:(0,yn._)`${e.schemaPath}${(0,yn.getProperty)(t)}${(0,yn.getProperty)(r)}`,errSchemaPath:`${e.errSchemaPath}/${t}/${(0,gz.escapeFragment)(r)}`}}if(a!==void 0){if(n===void 0||i===void 0||o===void 0)throw new Error('"schemaPath", "errSchemaPath" and "topSchemaRef" are required with "schema"');return{schema:a,schemaPath:n,topSchemaRef:o,errSchemaPath:i}}throw new Error('either "keyword" or "schema" must be passed')}xr.getSubschema=m4;function g4(e,t,{dataProp:r,dataPropType:a,data:n,dataTypes:i,propertyName:o}){if(n!==void 0&&r!==void 0)throw new Error('both "data" and "dataProp" passed, only one allowed');let{gen:s}=t;if(r!==void 0){let{errorPath:c,dataPathArr:u,opts:d}=t,m=s.let("data",(0,yn._)`${t.data}${(0,yn.getProperty)(r)}`,!0);l(m),e.errorPath=(0,yn.str)`${c}${(0,gz.getErrorPath)(r,a,d.jsPropertySyntax)}`,e.parentDataProperty=(0,yn._)`${r}`,e.dataPathArr=[...u,e.parentDataProperty]}if(n!==void 0){let c=n instanceof yn.Name?n:s.let("data",n,!0);l(c),o!==void 0&&(e.propertyName=o)}i&&(e.dataTypes=i);function l(c){e.data=c,e.dataLevel=t.dataLevel+1,e.dataTypes=[],t.definedProperties=new Set,e.parentData=t.data,e.dataNames=[...t.dataNames,c]}}xr.extendSubschemaData=g4;function h4(e,{jtdDiscriminator:t,jtdMetadata:r,compositeRule:a,createErrors:n,allErrors:i}){a!==void 0&&(e.compositeRule=a),n!==void 0&&(e.createErrors=n),i!==void 0&&(e.allErrors=i),e.jtdDiscriminator=t,e.jtdMetadata=r}xr.extendSubschemaMode=h4});var Zy=j((pY,fz)=>{"use strict";fz.exports=function e(t,r){if(t===r)return!0;if(t&&r&&typeof t=="object"&&typeof r=="object"){if(t.constructor!==r.constructor)return!1;var a,n,i;if(Array.isArray(t)){if(a=t.length,a!=r.length)return!1;for(n=a;n--!==0;)if(!e(t[n],r[n]))return!1;return!0}if(t.constructor===RegExp)return t.source===r.source&&t.flags===r.flags;if(t.valueOf!==Object.prototype.valueOf)return t.valueOf()===r.valueOf();if(t.toString!==Object.prototype.toString)return t.toString()===r.toString();if(i=Object.keys(t),a=i.length,a!==Object.keys(r).length)return!1;for(n=a;n--!==0;)if(!Object.prototype.hasOwnProperty.call(r,i[n]))return!1;for(n=a;n--!==0;){var o=i[n];if(!e(t[o],r[o]))return!1}return!0}return t!==t&&r!==r}});var vz=j((mY,bz)=>{"use strict";var Tr=bz.exports=function(e,t,r){typeof t=="function"&&(r=t,t={}),r=t.cb||r;var a=typeof r=="function"?r:r.pre||function(){},n=r.post||function(){};wm(t,a,n,e,"",e)};Tr.keywords={additionalItems:!0,items:!0,contains:!0,additionalProperties:!0,propertyNames:!0,not:!0,if:!0,then:!0,else:!0};Tr.arrayKeywords={items:!0,allOf:!0,anyOf:!0,oneOf:!0};Tr.propsKeywords={$defs:!0,definitions:!0,properties:!0,patternProperties:!0,dependencies:!0};Tr.skipKeywords={default:!0,enum:!0,const:!0,required:!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};function wm(e,t,r,a,n,i,o,s,l,c){if(a&&typeof a=="object"&&!Array.isArray(a)){t(a,n,i,o,s,l,c);for(var u in a){var d=a[u];if(Array.isArray(d)){if(u in Tr.arrayKeywords)for(var m=0;m<d.length;m++)wm(e,t,r,d[m],n+"/"+u+"/"+m,i,n,u,a,m)}else if(u in Tr.propsKeywords){if(d&&typeof d=="object")for(var p in d)wm(e,t,r,d[p],n+"/"+u+"/"+f4(p),i,n,u,a,p)}else(u in Tr.keywords||e.allKeys&&!(u in Tr.skipKeywords))&&wm(e,t,r,d,n+"/"+u,i,n,u,a)}r(a,n,i,o,s,l,c)}}function f4(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}});var Sl=j(xt=>{"use strict";Object.defineProperty(xt,"__esModule",{value:!0});xt.getSchemaRefs=xt.resolveUrl=xt.normalizeId=xt._getFullPath=xt.getFullPath=xt.inlineRef=void 0;var b4=pe(),v4=Zy(),y4=vz(),k4=new Set(["type","format","pattern","maxLength","minLength","maxProperties","minProperties","maxItems","minItems","maximum","minimum","uniqueItems","multipleOf","required","enum","const"]);function _4(e,t=!0){return typeof e=="boolean"?!0:t===!0?!Jy(e):t?yz(e)<=t:!1}xt.inlineRef=_4;var w4=new Set(["$ref","$recursiveRef","$recursiveAnchor","$dynamicRef","$dynamicAnchor"]);function Jy(e){for(let t in e){if(w4.has(t))return!0;let r=e[t];if(Array.isArray(r)&&r.some(Jy)||typeof r=="object"&&Jy(r))return!0}return!1}function yz(e){let t=0;for(let r in e){if(r==="$ref")return 1/0;if(t++,!k4.has(r)&&(typeof e[r]=="object"&&(0,b4.eachItem)(e[r],a=>t+=yz(a)),t===1/0))return 1/0}return t}function kz(e,t="",r){r!==!1&&(t=Qi(t));let a=e.parse(t);return _z(e,a)}xt.getFullPath=kz;function _z(e,t){return e.serialize(t).split("#")[0]+"#"}xt._getFullPath=_z;var S4=/#\/?$/;function Qi(e){return e?e.replace(S4,""):""}xt.normalizeId=Qi;function E4(e,t,r){return r=Qi(r),e.resolve(t,r)}xt.resolveUrl=E4;var x4=/^[a-z_][-a-z0-9._]*$/i;function T4(e,t){if(typeof e=="boolean")return{};let{schemaId:r,uriResolver:a}=this.opts,n=Qi(e[r]||t),i={"":n},o=kz(a,n,!1),s={},l=new Set;return y4(e,{allKeys:!0},(d,m,p,g)=>{if(g===void 0)return;let h=o+m,f=i[g];typeof d[r]=="string"&&(f=_.call(this,d[r])),b.call(this,d.$anchor),b.call(this,d.$dynamicAnchor),i[m]=f;function _(v){let C=this.opts.uriResolver.resolve;if(v=Qi(f?C(f,v):v),l.has(v))throw u(v);l.add(v);let S=this.refs[v];return typeof S=="string"&&(S=this.refs[S]),typeof S=="object"?c(d,S.schema,v):v!==Qi(h)&&(v[0]==="#"?(c(d,s[v],v),s[v]=d):this.refs[v]=h),v}function b(v){if(typeof v=="string"){if(!x4.test(v))throw new Error(`invalid anchor "${v}"`);_.call(this,`#${v}`)}}}),s;function c(d,m,p){if(m!==void 0&&!v4(d,m))throw u(p)}function u(d){return new Error(`reference "${d}" resolves to more than one schema`)}}xt.getSchemaRefs=T4});var Tl=j(Ar=>{"use strict";Object.defineProperty(Ar,"__esModule",{value:!0});Ar.getData=Ar.KeywordCxt=Ar.validateFunctionCode=void 0;var Tz=tz(),wz=wl(),Xy=Fy(),Sm=wl(),A4=lz(),xl=mz(),Yy=hz(),q=ne(),J=Zn(),C4=Sl(),Jn=pe(),El=_l();function z4(e){if(zz(e)&&(Iz(e),Cz(e))){R4(e);return}Az(e,()=>(0,Tz.topBoolOrEmptySchema)(e))}Ar.validateFunctionCode=z4;function Az({gen:e,validateName:t,schema:r,schemaEnv:a,opts:n},i){n.code.es5?e.func(t,(0,q._)`${J.default.data}, ${J.default.valCxt}`,a.$async,()=>{e.code((0,q._)`"use strict"; ${Sz(r,n)}`),P4(e,n),e.code(i)}):e.func(t,(0,q._)`${J.default.data}, ${I4(n)}`,a.$async,()=>e.code(Sz(r,n)).code(i))}function I4(e){return(0,q._)`{${J.default.instancePath}="", ${J.default.parentData}, ${J.default.parentDataProperty}, ${J.default.rootData}=${J.default.data}${e.dynamicRef?(0,q._)`, ${J.default.dynamicAnchors}={}`:q.nil}}={}`}function P4(e,t){e.if(J.default.valCxt,()=>{e.var(J.default.instancePath,(0,q._)`${J.default.valCxt}.${J.default.instancePath}`),e.var(J.default.parentData,(0,q._)`${J.default.valCxt}.${J.default.parentData}`),e.var(J.default.parentDataProperty,(0,q._)`${J.default.valCxt}.${J.default.parentDataProperty}`),e.var(J.default.rootData,(0,q._)`${J.default.valCxt}.${J.default.rootData}`),t.dynamicRef&&e.var(J.default.dynamicAnchors,(0,q._)`${J.default.valCxt}.${J.default.dynamicAnchors}`)},()=>{e.var(J.default.instancePath,(0,q._)`""`),e.var(J.default.parentData,(0,q._)`undefined`),e.var(J.default.parentDataProperty,(0,q._)`undefined`),e.var(J.default.rootData,J.default.data),t.dynamicRef&&e.var(J.default.dynamicAnchors,(0,q._)`{}`)})}function R4(e){let{schema:t,opts:r,gen:a}=e;Az(e,()=>{r.$comment&&t.$comment&&Rz(e),D4(e),a.let(J.default.vErrors,null),a.let(J.default.errors,0),r.unevaluated&&$4(e),Pz(e),B4(e)})}function $4(e){let{gen:t,validateName:r}=e;e.evaluated=t.const("evaluated",(0,q._)`${r}.evaluated`),t.if((0,q._)`${e.evaluated}.dynamicProps`,()=>t.assign((0,q._)`${e.evaluated}.props`,(0,q._)`undefined`)),t.if((0,q._)`${e.evaluated}.dynamicItems`,()=>t.assign((0,q._)`${e.evaluated}.items`,(0,q._)`undefined`))}function Sz(e,t){let r=typeof e=="object"&&e[t.schemaId];return r&&(t.code.source||t.code.process)?(0,q._)`/*# sourceURL=${r} */`:q.nil}function j4(e,t){if(zz(e)&&(Iz(e),Cz(e))){O4(e,t);return}(0,Tz.boolOrEmptySchema)(e,t)}function Cz({schema:e,self:t}){if(typeof e=="boolean")return!e;for(let r in e)if(t.RULES.all[r])return!0;return!1}function zz(e){return typeof e.schema!="boolean"}function O4(e,t){let{schema:r,gen:a,opts:n}=e;n.$comment&&r.$comment&&Rz(e),M4(e),L4(e);let i=a.const("_errs",J.default.errors);Pz(e,i),a.var(t,(0,q._)`${i} === ${J.default.errors}`)}function Iz(e){(0,Jn.checkUnknownRules)(e),N4(e)}function Pz(e,t){if(e.opts.jtd)return Ez(e,[],!1,t);let r=(0,wz.getSchemaTypes)(e.schema),a=(0,wz.coerceAndCheckDataType)(e,r);Ez(e,r,!a,t)}function N4(e){let{schema:t,errSchemaPath:r,opts:a,self:n}=e;t.$ref&&a.ignoreKeywordsWithRef&&(0,Jn.schemaHasRulesButRef)(t,n.RULES)&&n.logger.warn(`$ref: keywords ignored in schema at path "${r}"`)}function D4(e){let{schema:t,opts:r}=e;t.default!==void 0&&r.useDefaults&&r.strictSchema&&(0,Jn.checkStrictMode)(e,"default is ignored in the schema root")}function M4(e){let t=e.schema[e.opts.schemaId];t&&(e.baseId=(0,C4.resolveUrl)(e.opts.uriResolver,e.baseId,t))}function L4(e){if(e.schema.$async&&!e.schemaEnv.$async)throw new Error("async schema in sync schema")}function Rz({gen:e,schemaEnv:t,schema:r,errSchemaPath:a,opts:n}){let i=r.$comment;if(n.$comment===!0)e.code((0,q._)`${J.default.self}.logger.log(${i})`);else if(typeof n.$comment=="function"){let o=(0,q.str)`${a}/$comment`,s=e.scopeValue("root",{ref:t.root});e.code((0,q._)`${J.default.self}.opts.$comment(${i}, ${o}, ${s}.schema)`)}}function B4(e){let{gen:t,schemaEnv:r,validateName:a,ValidationError:n,opts:i}=e;r.$async?t.if((0,q._)`${J.default.errors} === 0`,()=>t.return(J.default.data),()=>t.throw((0,q._)`new ${n}(${J.default.vErrors})`)):(t.assign((0,q._)`${a}.errors`,J.default.vErrors),i.unevaluated&&U4(e),t.return((0,q._)`${J.default.errors} === 0`))}function U4({gen:e,evaluated:t,props:r,items:a}){r instanceof q.Name&&e.assign((0,q._)`${t}.props`,r),a instanceof q.Name&&e.assign((0,q._)`${t}.items`,a)}function Ez(e,t,r,a){let{gen:n,schema:i,data:o,allErrors:s,opts:l,self:c}=e,{RULES:u}=c;if(i.$ref&&(l.ignoreKeywordsWithRef||!(0,Jn.schemaHasRulesButRef)(i,u))){n.block(()=>jz(e,"$ref",u.all.$ref.definition));return}l.jtd||F4(e,t),n.block(()=>{for(let m of u.rules)d(m);d(u.post)});function d(m){(0,Xy.shouldUseGroup)(i,m)&&(m.type?(n.if((0,Sm.checkDataType)(m.type,o,l.strictNumbers)),xz(e,m),t.length===1&&t[0]===m.type&&r&&(n.else(),(0,Sm.reportTypeError)(e)),n.endIf()):xz(e,m),s||n.if((0,q._)`${J.default.errors} === ${a||0}`))}}function xz(e,t){let{gen:r,schema:a,opts:{useDefaults:n}}=e;n&&(0,A4.assignDefaults)(e,t.type),r.block(()=>{for(let i of t.rules)(0,Xy.shouldUseRule)(a,i)&&jz(e,i.keyword,i.definition,t.type)})}function F4(e,t){e.schemaEnv.meta||!e.opts.strictTypes||(q4(e,t),e.opts.allowUnionTypes||H4(e,t),G4(e,e.dataTypes))}function q4(e,t){if(t.length){if(!e.dataTypes.length){e.dataTypes=t;return}t.forEach(r=>{$z(e.dataTypes,r)||Qy(e,`type "${r}" not allowed by context "${e.dataTypes.join(",")}"`)}),W4(e,t)}}function H4(e,t){t.length>1&&!(t.length===2&&t.includes("null"))&&Qy(e,"use allowUnionTypes to allow union type keyword")}function G4(e,t){let r=e.self.RULES.all;for(let a in r){let n=r[a];if(typeof n=="object"&&(0,Xy.shouldUseRule)(e.schema,n)){let{type:i}=n.definition;i.length&&!i.some(o=>V4(t,o))&&Qy(e,`missing type "${i.join(",")}" for keyword "${a}"`)}}}function V4(e,t){return e.includes(t)||t==="number"&&e.includes("integer")}function $z(e,t){return e.includes(t)||t==="integer"&&e.includes("number")}function W4(e,t){let r=[];for(let a of e.dataTypes)$z(t,a)?r.push(a):t.includes("integer")&&a==="number"&&r.push("integer");e.dataTypes=r}function Qy(e,t){let r=e.schemaEnv.baseId+e.errSchemaPath;t+=` at "${r}" (strictTypes)`,(0,Jn.checkStrictMode)(e,t,e.opts.strictTypes)}var Em=class{constructor(t,r,a){if((0,xl.validateKeywordUsage)(t,r,a),this.gen=t.gen,this.allErrors=t.allErrors,this.keyword=a,this.data=t.data,this.schema=t.schema[a],this.$data=r.$data&&t.opts.$data&&this.schema&&this.schema.$data,this.schemaValue=(0,Jn.schemaRefOrVal)(t,this.schema,a,this.$data),this.schemaType=r.schemaType,this.parentSchema=t.schema,this.params={},this.it=t,this.def=r,this.$data)this.schemaCode=t.gen.const("vSchema",Oz(this.$data,t));else if(this.schemaCode=this.schemaValue,!(0,xl.validSchemaType)(this.schema,r.schemaType,r.allowUndefined))throw new Error(`${a} value must be ${JSON.stringify(r.schemaType)}`);("code"in r?r.trackErrors:r.errors!==!1)&&(this.errsCount=t.gen.const("_errs",J.default.errors))}result(t,r,a){this.failResult((0,q.not)(t),r,a)}failResult(t,r,a){this.gen.if(t),a?a():this.error(),r?(this.gen.else(),r(),this.allErrors&&this.gen.endIf()):this.allErrors?this.gen.endIf():this.gen.else()}pass(t,r){this.failResult((0,q.not)(t),void 0,r)}fail(t){if(t===void 0){this.error(),this.allErrors||this.gen.if(!1);return}this.gen.if(t),this.error(),this.allErrors?this.gen.endIf():this.gen.else()}fail$data(t){if(!this.$data)return this.fail(t);let{schemaCode:r}=this;this.fail((0,q._)`${r} !== undefined && (${(0,q.or)(this.invalid$data(),t)})`)}error(t,r,a){if(r){this.setParams(r),this._error(t,a),this.setParams({});return}this._error(t,a)}_error(t,r){(t?El.reportExtraError:El.reportError)(this,this.def.error,r)}$dataError(){(0,El.reportError)(this,this.def.$dataError||El.keyword$DataError)}reset(){if(this.errsCount===void 0)throw new Error('add "trackErrors" to keyword definition');(0,El.resetErrorsCount)(this.gen,this.errsCount)}ok(t){this.allErrors||this.gen.if(t)}setParams(t,r){r?Object.assign(this.params,t):this.params=t}block$data(t,r,a=q.nil){this.gen.block(()=>{this.check$data(t,a),r()})}check$data(t=q.nil,r=q.nil){if(!this.$data)return;let{gen:a,schemaCode:n,schemaType:i,def:o}=this;a.if((0,q.or)((0,q._)`${n} === undefined`,r)),t!==q.nil&&a.assign(t,!0),(i.length||o.validateSchema)&&(a.elseIf(this.invalid$data()),this.$dataError(),t!==q.nil&&a.assign(t,!1)),a.else()}invalid$data(){let{gen:t,schemaCode:r,schemaType:a,def:n,it:i}=this;return(0,q.or)(o(),s());function o(){if(a.length){if(!(r instanceof q.Name))throw new Error("ajv implementation error");let l=Array.isArray(a)?a:[a];return(0,q._)`${(0,Sm.checkDataTypes)(l,r,i.opts.strictNumbers,Sm.DataType.Wrong)}`}return q.nil}function s(){if(n.validateSchema){let l=t.scopeValue("validate$data",{ref:n.validateSchema});return(0,q._)`!${l}(${r})`}return q.nil}}subschema(t,r){let a=(0,Yy.getSubschema)(this.it,t);(0,Yy.extendSubschemaData)(a,this.it,t),(0,Yy.extendSubschemaMode)(a,t);let n={...this.it,...a,items:void 0,props:void 0};return j4(n,r),n}mergeEvaluated(t,r){let{it:a,gen:n}=this;a.opts.unevaluated&&(a.props!==!0&&t.props!==void 0&&(a.props=Jn.mergeEvaluated.props(n,t.props,a.props,r)),a.items!==!0&&t.items!==void 0&&(a.items=Jn.mergeEvaluated.items(n,t.items,a.items,r)))}mergeValidEvaluated(t,r){let{it:a,gen:n}=this;if(a.opts.unevaluated&&(a.props!==!0||a.items!==!0))return n.if(r,()=>this.mergeEvaluated(t,q.Name)),!0}};Ar.KeywordCxt=Em;function jz(e,t,r,a){let n=new Em(e,r,t);"code"in r?r.code(n,a):n.$data&&r.validate?(0,xl.funcKeywordCode)(n,r):"macro"in r?(0,xl.macroKeywordCode)(n,r):(r.compile||r.validate)&&(0,xl.funcKeywordCode)(n,r)}var K4=/^\/(?:[^~]|~0|~1)*$/,Z4=/^([0-9]+)(#|\/(?:[^~]|~0|~1)*)?$/;function Oz(e,{dataLevel:t,dataNames:r,dataPathArr:a}){let n,i;if(e==="")return J.default.rootData;if(e[0]==="/"){if(!K4.test(e))throw new Error(`Invalid JSON-pointer: ${e}`);n=e,i=J.default.rootData}else{let c=Z4.exec(e);if(!c)throw new Error(`Invalid JSON-pointer: ${e}`);let u=+c[1];if(n=c[2],n==="#"){if(u>=t)throw new Error(l("property/index",u));return a[t-u]}if(u>t)throw new Error(l("data",u));if(i=r[t-u],!n)return i}let o=i,s=n.split("/");for(let c of s)c&&(i=(0,q._)`${i}${(0,q.getProperty)((0,Jn.unescapeJsonPointer)(c))}`,o=(0,q._)`${o} && ${i}`);return o;function l(c,u){return`Cannot access ${c} ${u} levels up, current level is ${t}`}}Ar.getData=Oz});var xm=j(tk=>{"use strict";Object.defineProperty(tk,"__esModule",{value:!0});var ek=class extends Error{constructor(t){super("validation failed"),this.errors=t,this.ajv=this.validation=!0}};tk.default=ek});var Al=j(ak=>{"use strict";Object.defineProperty(ak,"__esModule",{value:!0});var nk=Sl(),rk=class extends Error{constructor(t,r,a,n){super(n||`can't resolve reference ${a} from id ${r}`),this.missingRef=(0,nk.resolveUrl)(t,r,a),this.missingSchema=(0,nk.normalizeId)((0,nk.getFullPath)(t,this.missingRef))}};ak.default=rk});var Am=j(Ht=>{"use strict";Object.defineProperty(Ht,"__esModule",{value:!0});Ht.resolveSchema=Ht.getCompilingSchema=Ht.resolveRef=Ht.compileSchema=Ht.SchemaEnv=void 0;var tn=ne(),J4=xm(),da=Zn(),nn=Sl(),Nz=pe(),Y4=Tl(),eo=class{constructor(t){var r;this.refs={},this.dynamicAnchors={};let a;typeof t.schema=="object"&&(a=t.schema),this.schema=t.schema,this.schemaId=t.schemaId,this.root=t.root||this,this.baseId=(r=t.baseId)!==null&&r!==void 0?r:(0,nn.normalizeId)(a?.[t.schemaId||"$id"]),this.schemaPath=t.schemaPath,this.localRefs=t.localRefs,this.meta=t.meta,this.$async=a?.$async,this.refs={}}};Ht.SchemaEnv=eo;function ok(e){let t=Dz.call(this,e);if(t)return t;let r=(0,nn.getFullPath)(this.opts.uriResolver,e.root.baseId),{es5:a,lines:n}=this.opts.code,{ownProperties:i}=this.opts,o=new tn.CodeGen(this.scope,{es5:a,lines:n,ownProperties:i}),s;e.$async&&(s=o.scopeValue("Error",{ref:J4.default,code:(0,tn._)`require("ajv/dist/runtime/validation_error").default`}));let l=o.scopeName("validate");e.validateName=l;let c={gen:o,allErrors:this.opts.allErrors,data:da.default.data,parentData:da.default.parentData,parentDataProperty:da.default.parentDataProperty,dataNames:[da.default.data],dataPathArr:[tn.nil],dataLevel:0,dataTypes:[],definedProperties:new Set,topSchemaRef:o.scopeValue("schema",this.opts.code.source===!0?{ref:e.schema,code:(0,tn.stringify)(e.schema)}:{ref:e.schema}),validateName:l,ValidationError:s,schema:e.schema,schemaEnv:e,rootId:r,baseId:e.baseId||r,schemaPath:tn.nil,errSchemaPath:e.schemaPath||(this.opts.jtd?"":"#"),errorPath:(0,tn._)`""`,opts:this.opts,self:this},u;try{this._compilations.add(e),(0,Y4.validateFunctionCode)(c),o.optimize(this.opts.code.optimize);let d=o.toString();u=`${o.scopeRefs(da.default.scope)}return ${d}`,this.opts.code.process&&(u=this.opts.code.process(u,e));let p=new Function(`${da.default.self}`,`${da.default.scope}`,u)(this,this.scope.get());if(this.scope.value(l,{ref:p}),p.errors=null,p.schema=e.schema,p.schemaEnv=e,e.$async&&(p.$async=!0),this.opts.code.source===!0&&(p.source={validateName:l,validateCode:d,scopeValues:o._values}),this.opts.unevaluated){let{props:g,items:h}=c;p.evaluated={props:g instanceof tn.Name?void 0:g,items:h instanceof tn.Name?void 0:h,dynamicProps:g instanceof tn.Name,dynamicItems:h instanceof tn.Name},p.source&&(p.source.evaluated=(0,tn.stringify)(p.evaluated))}return e.validate=p,e}catch(d){throw delete e.validate,delete e.validateName,u&&this.logger.error("Error compiling schema, function code:",u),d}finally{this._compilations.delete(e)}}Ht.compileSchema=ok;function X4(e,t,r){var a;r=(0,nn.resolveUrl)(this.opts.uriResolver,t,r);let n=e.refs[r];if(n)return n;let i=tB.call(this,e,r);if(i===void 0){let o=(a=e.localRefs)===null||a===void 0?void 0:a[r],{schemaId:s}=this.opts;o&&(i=new eo({schema:o,schemaId:s,root:e,baseId:t}))}if(i!==void 0)return e.refs[r]=Q4.call(this,i)}Ht.resolveRef=X4;function Q4(e){return(0,nn.inlineRef)(e.schema,this.opts.inlineRefs)?e.schema:e.validate?e:ok.call(this,e)}function Dz(e){for(let t of this._compilations)if(eB(t,e))return t}Ht.getCompilingSchema=Dz;function eB(e,t){return e.schema===t.schema&&e.root===t.root&&e.baseId===t.baseId}function tB(e,t){let r;for(;typeof(r=this.refs[t])=="string";)t=r;return r||this.schemas[t]||Tm.call(this,e,t)}function Tm(e,t){let r=this.opts.uriResolver.parse(t),a=(0,nn._getFullPath)(this.opts.uriResolver,r),n=(0,nn.getFullPath)(this.opts.uriResolver,e.baseId,void 0);if(Object.keys(e.schema).length>0&&a===n)return ik.call(this,r,e);let i=(0,nn.normalizeId)(a),o=this.refs[i]||this.schemas[i];if(typeof o=="string"){let s=Tm.call(this,e,o);return typeof s?.schema!="object"?void 0:ik.call(this,r,s)}if(typeof o?.schema=="object"){if(o.validate||ok.call(this,o),i===(0,nn.normalizeId)(t)){let{schema:s}=o,{schemaId:l}=this.opts,c=s[l];return c&&(n=(0,nn.resolveUrl)(this.opts.uriResolver,n,c)),new eo({schema:s,schemaId:l,root:e,baseId:n})}return ik.call(this,r,o)}}Ht.resolveSchema=Tm;var nB=new Set(["properties","patternProperties","enum","dependencies","definitions"]);function ik(e,{baseId:t,schema:r,root:a}){var n;if(((n=e.fragment)===null||n===void 0?void 0:n[0])!=="/")return;for(let s of e.fragment.slice(1).split("/")){if(typeof r=="boolean")return;let l=r[(0,Nz.unescapeFragment)(s)];if(l===void 0)return;r=l;let c=typeof r=="object"&&r[this.opts.schemaId];!nB.has(s)&&c&&(t=(0,nn.resolveUrl)(this.opts.uriResolver,t,c))}let i;if(typeof r!="boolean"&&r.$ref&&!(0,Nz.schemaHasRulesButRef)(r,this.RULES)){let s=(0,nn.resolveUrl)(this.opts.uriResolver,t,r.$ref);i=Tm.call(this,a,s)}let{schemaId:o}=this.opts;if(i=i||new eo({schema:r,schemaId:o,root:a,baseId:t}),i.schema!==i.root.schema)return i}});var Mz=j((yY,rB)=>{rB.exports={$id:"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#",description:"Meta-schema for $data reference (JSON AnySchema extension proposal)",type:"object",required:["$data"],properties:{$data:{type:"string",anyOf:[{format:"relative-json-pointer"},{format:"json-pointer"}]}},additionalProperties:!1}});var pk=j((kY,Gz)=>{"use strict";var aB=RegExp.prototype.test.bind(/^[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}$/iu),lk=RegExp.prototype.test.bind(/^(?:(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)$/u),iB=RegExp.prototype.test.bind(/^\d*$/u),pa=RegExp.prototype.test.bind(/^[\da-f]{2}$/iu),ck=RegExp.prototype.test.bind(/^[\da-z\-._~]$/iu),Bz=RegExp.prototype.test.bind(/^[A-Za-z0-9\-._~!$&'()*+,;=:@/]$/u),uk=RegExp.prototype.test.bind(/^[A-Za-z0-9\-._~!$&'()*+,;=:@/?]$/u),oB=RegExp.prototype.test.bind(/^[A-Za-z0-9\-._~!$&'()*+,;=:]$/u),Tt=new Array(256);{let e="0123456789ABCDEF";for(let t=0;t<256;t++)Tt[t]="%"+e[t>>4]+e[t&15]}function st(e){return e<2048?Tt[192|e>>6]+Tt[128|e&63]:e<65536?Tt[224|e>>12]+Tt[128|e>>6&63]+Tt[128|e&63]:Tt[240|e>>18]+Tt[128|e>>12&63]+Tt[128|e>>6&63]+Tt[128|e&63]}function sB(e){let t="",r=0,a=0;for(a=0;a<e.length;a++)if(r=e[a].charCodeAt(0),r!==48){if(!(r>=48&&r<=57||r>=65&&r<=70||r>=97&&r<=102))return"";t+=e[a];break}for(a+=1;a<e.length;a++){if(r=e[a].charCodeAt(0),!(r>=48&&r<=57||r>=65&&r<=70||r>=97&&r<=102))return"";t+=e[a]}return t}var lB=RegExp.prototype.test.bind(/^[\dA-Fa-f]{1,4}$/),cB=RegExp.prototype.test.bind(/^[vV][\dA-Fa-f]+\.[A-Za-z\d\-._~!$&'()*+,;=:]+$/),uB=RegExp.prototype.test.bind(/^[A-Za-z\d\-._~]$/),dB=RegExp.prototype.test.bind(/[^!"$&'()*+,\-.;=_`a-z{}~]/u);function pB(e){if(e.length===0)return!1;for(let t=0;t<e.length;t++)if(!uB(e[t])){if(e[t]==="%"&&t+2<e.length&&pa(e.slice(t+1,t+3))){t+=2;continue}return!1}return!0}function Lz(e){let t=-1,r=0,a=-1,n=0;for(let s=0;s<e.length;s++)e[s]==="0"?(a===-1&&(a=s),n++,n>r&&(r=n,t=a)):(a=-1,n=0);if(r<2)return e.join(":");let i=e.slice(0,t).join(":"),o=e.slice(t+r).join(":");return i+"::"+o}function mB(e){let t=e.indexOf("::");if(t!==-1&&e.indexOf("::",t+1)!==-1)return;let r=t===-1?e.split(":"):e.slice(0,t).split(":"),a=t===-1?[]:e.slice(t+2).split(":");t!==-1&&(r.length===1&&r[0]===""&&(r.length=0),a.length===1&&a[0]===""&&(a.length=0));let n=r.concat(a),i=0;for(let s=0;s<n.length;s++){let l=n[s];if(l==="")return;if(l.indexOf(".")!==-1){if(s!==n.length-1||t!==-1&&a.length===0||!lk(l))return;i+=2;continue}if(!lB(l))return;n[s]=parseInt(l,16).toString(16),i++}if(t===-1)return i!==8?void 0:Lz(n);if(i>=8)return;let o=n.slice(0,r.length);for(let s=i;s<8;s++)o.push("0");for(let s=r.length;s<n.length;s++)o.push(n[s]);return Lz(o)}function sk(e){let t=e[0]==="["&&e[e.length-1]==="]";if((e[0]==="["||e[e.length-1]==="]")&&!t)return{host:e,isIPV6:!1,error:!0};let a=t?e.slice(1,-1):e;if(t&&cB(a))return a=a.toLowerCase(),{host:`[${a}]`,escapedHost:a,isIPV6:!1,isIPVFuture:!0};if(gB(a,":")<2)return{host:e,isIPV6:!1,error:t};let n="",i=a.indexOf("%");if(i!==-1){let s=a.slice(i,i+3).toLowerCase()==="%25"?3:1;if(n=a.slice(i+s),!pB(n))return{host:e,isIPV6:!1,error:!0};a=a.slice(0,i)}let o=mB(a);return o===void 0?{host:e,isIPV6:!1,error:!0}:{host:o+(n?"%"+n:""),escapedHost:o+(n?"%25"+n:""),isIPV6:!0}}function gB(e,t){let r=0;for(let a=0;a<e.length;a++)e[a]===t&&r++;return r}function hB(e){let t=e,r=[],a=-1,n=0;for(;n=t.length;){if(n===1){if(t===".")break;if(t==="/"){r.push("/");break}else{r.push(t);break}}else if(n===2){if(t[0]==="."){if(t[1]===".")break;if(t[1]==="/"){t=t.slice(2);continue}}else if(t[0]==="/"&&(t[1]==="."||t[1]==="/")){r.push("/");break}}else if(n===3&&t==="/.."){r.length!==0&&r.pop(),r.push("/");break}if(t[0]==="."){if(t[1]==="."){if(t[2]==="/"){t=t.slice(3);continue}}else if(t[1]==="/"){t=t.slice(2);continue}}else if(t[0]==="/"&&t[1]==="."){if(t[2]==="/"){t=t.slice(2);continue}else if(t[2]==="."&&t[3]==="/"){t=t.slice(3),r.length!==0&&r.pop();continue}}if((a=t.indexOf("/",1))===-1){r.push(t);break}else r.push(t.slice(0,a)),t=t.slice(a)}return r.join("")}var fB={"@":"%40","/":"%2F","?":"%3F","#":"%23",":":"%3A"},bB=/[@/?#:]/g,vB=/[@/?#]/g;function Uz(e,t){let r=t?vB:bB;return r.lastIndex=0,e.replace(r,a=>fB[a])}function Fz(e,t=!1){if(e.indexOf("%")===-1)return e;let r="";for(let a=0;a<e.length;a++){if(e[a]==="%"&&a+2<e.length){let n=e.slice(a+1,a+3);if(pa(n)){let i=n.toUpperCase(),o=String.fromCharCode(parseInt(i,16));t&&ck(o)?r+=o:r+="%"+i,a+=2;continue}}r+=e[a]}return r}function yB(e){let t="";for(let r=0;r<e.length;r++){let a=e[r];if(a==="%"&&r+2<e.length){let n=e.slice(r+1,r+3);if(pa(n)){let i=n.toUpperCase(),o=String.fromCharCode(parseInt(i,16));o!=="."&&ck(o)?t+=o:t+="%"+i,r+=2;continue}}if(Bz(a))t+=a;else{let n=e.charCodeAt(r);if(n<128)t+=Hz(n)?a:Tt[n];else if(n<55296||n>57343)t+=st(n);else if(n<=56319&&r+1<e.length){let i=e.charCodeAt(r+1);i>=56320&&i<=57343?(t+=st(65536+(n-55296<<10)+(i-56320)),r++):t+=st(65533)}else t+=st(65533)}}return t}function kB(e,t=!1){let r="",a=t&&e[0]!=="/";for(let n=0;n<e.length;n++){let i=e[n];if(i==="%"&&n+2<e.length){let o=e.slice(n+1,n+3);if(pa(o)){r+="%"+o.toUpperCase(),n+=2;continue}}if(i==="/"&&(a=!1),Bz(i)&&(i!==":"||!a))r+=i;else{let o=e.charCodeAt(n);if(o<128)r+=Tt[o];else if(o<55296||o>57343)r+=st(o);else if(o<=56319&&n+1<e.length){let s=e.charCodeAt(n+1);s>=56320&&s<=57343?(r+=st(65536+(o-55296<<10)+(s-56320)),n++):r+=st(65533)}else r+=st(65533)}}return r}function dk(e,t){let r="";for(let a=0;a<e.length;a++){let n=e[a];if(n==="%"&&a+2<e.length){let i=e.slice(a+1,a+3);if(pa(i)){r+="%"+i.toUpperCase(),a+=2;continue}}if(t(n))r+=n;else{let i=e.charCodeAt(a);if(i<128)r+=Tt[i];else if(i<55296||i>57343)r+=st(i);else if(i<=56319&&a+1<e.length){let o=e.charCodeAt(a+1);o>=56320&&o<=57343?(r+=st(65536+(i-55296<<10)+(o-56320)),a++):r+=st(65533)}else r+=st(65533)}}return r}function qz(e){return dk(e,oB)}function _B(e){return dk(e,uk)}function wB(e){return dk(e,uk)}function Hz(e){return e>=48&&e<=57||e>=65&&e<=90||e>=97&&e<=122||e===42||e===43||e===45||e===46||e===47||e===64||e===95}function SB(e){let t="";for(let r=0;r<e.length;r++){let a=e[r];if(a==="%"&&r+2<e.length){let n=e.slice(r+1,r+3);if(pa(n)){let i=n.toUpperCase(),o=String.fromCharCode(parseInt(i,16));ck(o)?t+=o:t+="%"+i,r+=2;continue}}if(uk(a))t+=a;else{let n=e.charCodeAt(r);if(n<128)t+=Hz(n)?a:Tt[n];else if(n<55296||n>57343)t+=st(n);else if(n<=56319&&r+1<e.length){let i=e.charCodeAt(r+1);i>=56320&&i<=57343?(t+=st(65536+(n-55296<<10)+(i-56320)),r++):t+=st(65533)}else t+=st(65533)}}return t}function EB(e){let t="";for(let r=0;r<e.length;r++){if(e[r]==="%"&&r+2<e.length){let a=e.slice(r+1,r+3);if(pa(a)){t+="%"+a.toUpperCase(),r+=2;continue}}t+=escape(e[r])}return t}function xB(e){let t=[];if(e.userinfo!==void 0&&(t.push(qz(e.userinfo)),t.push("@")),e.host!==void 0){let r=e.host;if(!lk(r)){let a=sk(r);a.isIPV6!==!0&&a.isIPVFuture!==!0&&(r=Fz(r,!0),a=sk(r)),a.isIPV6===!0||a.isIPVFuture===!0?r=`[${a.escapedHost}]`:r=Uz(r,!1)}t.push(r)}if(typeof e.port=="number"||typeof e.port=="string"){let r=String(e.port);if(!iB(r))throw new TypeError("URI port is malformed.");t.push(":"),t.push(r)}return t.length?t.join(""):void 0}Gz.exports={nonSimpleDomain:dB,recomposeAuthority:xB,reescapeHostDelimiters:Uz,normalizePercentEncoding:Fz,normalizePathEncoding:yB,serializePathEncoding:kB,normalizeQueryFragmentEncoding:SB,encodeUserinfo:qz,encodeQuery:_B,encodeFragment:wB,escapePreservingEscapes:EB,removeDotSegments:hB,isIPv4:lk,isUUID:aB,normalizeIPv6:sk,stringArrayToHexStripped:sB}});var Jz=j((_Y,Zz)=>{"use strict";var{isUUID:TB}=pk(),AB=/^([\da-z][\d\-a-z]{0,31}):((?:[\w!$'()*+,\-./:;=@]|%[\da-f]{2})+)$/iu,CB=["http","https","ws","wss","urn","urn:uuid"];function zB(e){return CB.indexOf(e)!==-1}function mk(e){return e.secure===!0?!0:e.secure===!1?!1:e.scheme?e.scheme.length===3&&(e.scheme[0]==="w"||e.scheme[0]==="W")&&(e.scheme[1]==="s"||e.scheme[1]==="S")&&(e.scheme[2]==="s"||e.scheme[2]==="S"):!1}function Vz(e){return e.host||(e.error=e.error||"HTTP URIs must have a host."),e}function Wz(e){let t=String(e.scheme).toLowerCase()==="https";return(e.port===(t?443:80)||e.port==="")&&(e.port=void 0),e.path||(e.path="/"),e}function IB(e){return e.secure=mk(e),e.resourceName=(e.path||"/")+(e.query?"?"+e.query:""),e.path=void 0,e.query=void 0,e}function PB(e){if((e.port===(mk(e)?443:80)||e.port==="")&&(e.port=void 0),typeof e.secure=="boolean"&&(e.scheme=e.secure?"wss":"ws",e.secure=void 0),e.resourceName){let t=e.resourceName.indexOf("?"),r=t===-1?e.resourceName:e.resourceName.slice(0,t);e.path=r&&r!=="/"?r:void 0,e.query=t===-1?void 0:e.resourceName.slice(t+1),e.resourceName=void 0}return e.fragment=void 0,e}function RB(e,t){if(!e.path)return e.error="URN can not be parsed",e;let r=e.path.match(AB);if(r&&r[0]===e.path){let a=t.scheme||e.scheme||"urn";e.nid=r[1].toLowerCase(),e.nss=r[2];let n=`${a}:${t.nid||e.nid}`,i=gk(n);e.path=void 0,i&&(e=i.parse(e,t))}else e.error=e.error||"URN can not be parsed.";return e}function $B(e,t){if(e.nid===void 0)throw new Error("URN without nid cannot be serialized");let r=t.scheme||e.scheme||"urn",a=e.nid.toLowerCase(),n=`${r}:${t.nid||a}`,i=gk(n);i&&(e=i.serialize(e,t));let o=e,s=e.nss;return o.path=`${a||t.nid}:${s}`,t.skipEscape=!0,o}function jB(e,t){let r=e;return r.uuid=r.nss,r.nss=void 0,!t.tolerant&&(!r.uuid||!TB(r.uuid))&&(r.error=r.error||"UUID is not valid."),r}function OB(e){let t=e;return t.nss=(e.uuid||"").toLowerCase(),t}var Kz={scheme:"http",domainHost:!0,parse:Vz,serialize:Wz},NB={scheme:"https",domainHost:Kz.domainHost,parse:Vz,serialize:Wz},Cm={scheme:"ws",domainHost:!0,parse:IB,serialize:PB},DB={scheme:"wss",domainHost:Cm.domainHost,parse:Cm.parse,serialize:Cm.serialize},MB={scheme:"urn",parse:RB,serialize:$B,skipNormalize:!0},LB={scheme:"urn:uuid",parse:jB,serialize:OB,skipNormalize:!0},zm={http:Kz,https:NB,ws:Cm,wss:DB,urn:MB,"urn:uuid":LB};Object.setPrototypeOf(zm,null);function gk(e){return e&&(zm[e]||zm[e.toLowerCase()])||void 0}Zz.exports={wsIsSecure:mk,SCHEMES:zm,isValidSchemeName:zB,getSchemeHandler:gk}});var cI=j((wY,Rm)=>{"use strict";var{normalizeIPv6:tI,removeDotSegments:zl,recomposeAuthority:BB,normalizePercentEncoding:hk,normalizePathEncoding:UB,serializePathEncoding:Yz,normalizeQueryFragmentEncoding:Xz,encodeQuery:FB,encodeFragment:qB,reescapeHostDelimiters:HB,isIPv4:nI,nonSimpleDomain:GB}=pk(),{SCHEMES:rI,getSchemeHandler:fk}=Jz(),aI=/^[A-Za-z][A-Za-z0-9+.-]*$/u,iI="URI scheme is malformed.";function Qz(e){let t=unescape(String(e));if(!aI.test(t))throw new TypeError(iI);return t}function VB(e,t){return typeof e=="string"?e=e3(e,t):typeof e=="object"&&(e=Pm(ma(e,t),t)),e}function WB(e,t,r){let a=r?Object.assign({scheme:"null"},r):{scheme:"null"},{parsed:n,malformedAuthorityOrPort:i,malformedPercentEncoding:o,malformedSchemeSpecific:s,malformedHost:l,malformedScheme:c}=Im(e,a),{parsed:u,malformedAuthorityOrPort:d,malformedPercentEncoding:m,malformedSchemeSpecific:p,malformedHost:g,malformedScheme:h}=Im(t,a);if(i||d||o||m||s||p||l||g||c||h)throw new Error(n.error||u.error||"URI is malformed.");let f=oI(n,u,a,!0),_=fk(r&&r.scheme||f.scheme),b=f.host,v=b!==void 0&&b!==""&&(nI(b)||tI(b).isIPV6);sI(f,r||{},_,v);let C=b&&b.indexOf("%")!==-1&&!new RegExp("\\P{ASCII}","u").test(b);if(f.error&&!C)throw new Error(f.error);return a.skipEscape=!0,ma(f,a)}function oI(e,t,r,a){let n={};return a||(e=Pm(ma(e,r),r),t=Pm(ma(t,r),r)),r=r||{},!r.tolerant&&t.scheme?(n.scheme=t.scheme,n.userinfo=t.userinfo,n.host=t.host,n.port=t.port,n.path=zl(t.path||""),n.query=t.query):(t.userinfo!==void 0||t.host!==void 0||t.port!==void 0?(n.userinfo=t.userinfo,n.host=t.host,n.port=t.port,n.path=zl(t.path||""),n.query=t.query):(t.path?(t.path[0]==="/"?n.path=zl(t.path):((e.userinfo!==void 0||e.host!==void 0||e.port!==void 0)&&!e.path?n.path="/"+t.path:e.path?n.path=e.path.slice(0,e.path.lastIndexOf("/")+1)+t.path:n.path=t.path,n.path=zl(n.path)),n.query=t.query):(n.path=e.path,t.query!==void 0?n.query=t.query:n.query=e.query),n.userinfo=e.userinfo,n.host=e.host,n.port=e.port),n.scheme=e.scheme),n.fragment=t.fragment,n}function KB(e,t,r){let a=eI(e,r),n=eI(t,r);return a!==void 0&&n!==void 0&&a===n}function ma(e,t){let r={host:e.host,scheme:e.scheme,userinfo:e.userinfo,port:e.port,path:e.path,query:e.query,nid:e.nid,nss:e.nss,uuid:e.uuid,fragment:e.fragment,reference:e.reference,resourceName:e.resourceName,secure:e.secure,error:""},a=Object.assign({},t),n=[];r.scheme&&(r.scheme=Qz(r.scheme));let i=fk(a.scheme||r.scheme);i&&i.serialize&&i.serialize(r,a);let o=r.userinfo!==void 0||r.host!==void 0||r.port!==void 0,s=!a.skipEscape&&r.scheme===void 0&&!o;r.path!==void 0&&(a.skipEscape?r.path=hk(r.path):r.path=Yz(r.path,s)),a.reference!=="suffix"&&r.scheme&&(r.scheme=Qz(r.scheme),n.push(r.scheme,":"));let l=BB(r);if(l!==void 0&&(a.reference!=="suffix"&&n.push("//"),n.push(l),r.path&&r.path[0]!=="/"&&n.push("/")),r.path!==void 0){let c=r.path;!a.absolutePath&&(!i||!i.absolutePath)&&(c=zl(c)),s&&(c=Yz(c,!0)),l===void 0&&c[0]==="/"&&c[1]==="/"&&(c="/%2F"+c.slice(2)),n.push(c)}return r.query!==void 0&&n.push("?",FB(r.query)),r.fragment!==void 0&&n.push("#",qB(r.fragment)),n.join("")}var ZB=/^(?:([^#/:?]+):)?(?:\/\/((?:([^#/?@]*)@)?(\[[^#/?\]]+\]|[^#/:?]*)(?::(\d*))?))?([^#?]*)(?:\?([^#]*))?(?:#((?:.|[\n\r])*))?/u,JB=/^(?:[^#/:?]+:)?\/\/([^/?#]*)/,YB=/^(?:[^#/:?]+:)?([/\\\t\n\r]*)/;function XB(e,t){if(t[2]!==void 0&&e.path&&e.path[0]!=="/")return'URI path must start with "/" when authority is present.';if(typeof e.port=="number"&&(e.port<0||e.port>65535))return"URI port is malformed."}function Cl(e){if(e===void 0)return!1;let t=e.indexOf("%");for(;t!==-1;){if(t+2>=e.length||!/^[\da-f]{2}$/iu.test(e.slice(t+1,t+3)))return!0;t=e.indexOf("%",t+3)}return!1}function bk(e){return e[0]==="["&&e[e.length-1]==="]"}function QB(e){let t=e[4];return Cl(e[3])||t!==void 0&&!bk(t)&&Cl(t)||Cl(e[6])||Cl(e[7])||Cl(e[8])}function sI(e,t,r,a){if(!t.unicodeSupport&&(!r||!r.unicodeSupport)&&e.host&&!bk(e.host)&&(t.domainHost||r&&r.domainHost)&&a===!1&&GB(e.host))try{e.host=new URL("http://"+e.host).hostname}catch(n){return e.error=e.error||"Host's domain name can not be converted to ASCII: "+n,!0}return!1}function Im(e,t){let r=Object.assign({},t),a={scheme:void 0,userinfo:void 0,host:"",port:void 0,path:"",query:void 0,fragment:void 0},n=!1,i=!1,o=!1,s=!1,l=!1,c=!1,u=!1;r.reference==="suffix"&&(r.scheme?e=r.scheme+":"+e:e="//"+e);let d=e.match(JB);d!==null&&d[1].indexOf("\\")!==-1&&(a.error="URI authority must not contain a literal backslash.",n=!0);let m=e.match(YB);if(m!==null){let g=m[1],h=g.replace(/[\t\n\r]/g,"");h.length>=2&&(h.slice(0,2)!=="//"?(a.error=a.error||"URI authority must not contain a literal backslash.",n=!0):g.length!==h.length&&(a.error=a.error||"URI authority introducer must not contain whitespace.",n=!0))}let p=e.match(ZB);if(p){if(a.scheme=p[1],a.userinfo=p[3],a.host=p[4],a.port=parseInt(p[5],10),a.path=p[6]||"",a.query=p[7],a.fragment=p[8],a.scheme!==void 0){let f=unescape(a.scheme);aI.test(f)?a.scheme=f.toLowerCase():(a.error=a.error||iI,c=!0)}i=QB(p),i&&(a.error=a.error||"URI contains malformed percent-encoding."),isNaN(a.port)&&(a.port=p[5]);let g=XB(a,p);if(g!==void 0&&(a.error=a.error||g,n=!0),a.host)if(nI(a.host)===!1){let _=bk(a.host),b=a.host.indexOf("[")!==-1||a.host.indexOf("]")!==-1,v=tI(a.host);u=v.isIPV6||v.isIPVFuture===!0,l=b&&(!_||v.error===!0),a.host=u?v.host:v.host.toLowerCase(),l&&(a.error=a.error||"URI host is malformed.",n=!0)}else u=!0;a.scheme===void 0&&a.userinfo===void 0&&a.host===void 0&&a.port===void 0&&a.query===void 0&&!a.path?a.reference="same-document":a.scheme===void 0?a.reference="relative":a.fragment===void 0?a.reference="absolute":a.reference="uri",r.reference&&r.reference!=="suffix"&&r.reference!==a.reference&&(a.error=a.error||"URI is not a "+r.reference+" reference.");let h=fk(r.scheme||a.scheme);if(l||(s=sI(a,r,h,u)),e.indexOf("%")!==-1&&a.host!==void 0&&!l){let f=u?a.host:hk(a.host,!0);u||(f=hk(f.toLowerCase())),a.host=HB(f,u)}(!h||h&&!h.skipNormalize)&&(a.path&&(a.path=UB(a.path)),a.query&&(a.query=Xz(a.query)),a.fragment&&(a.fragment=Xz(a.fragment))),h&&h.parse&&(h.parse(a,r),h===rI.urn&&a.nid===void 0&&(o=!0))}else a.error=a.error||"URI can not be parsed.";return{parsed:a,malformedAuthorityOrPort:n,malformedPercentEncoding:i,malformedSchemeSpecific:o,malformedHost:s,malformedScheme:c}}function Pm(e,t){return Im(e,t).parsed}function e3(e,t){return lI(e,t).normalized}function lI(e,t){let{parsed:r,malformedAuthorityOrPort:a,malformedPercentEncoding:n,malformedSchemeSpecific:i,malformedHost:o,malformedScheme:s}=Im(e,t);return{normalized:a||n||i||o||s?e:ma(r,t),malformedAuthorityOrPort:a,malformedPercentEncoding:n,malformedSchemeSpecific:i,malformedHost:o,malformedScheme:s}}function eI(e,t){if(typeof e!="string"&&typeof e!="object")return;let r;try{r=typeof e=="string"?e:ma(e,t)}catch{return}let{normalized:a,malformedAuthorityOrPort:n,malformedPercentEncoding:i,malformedSchemeSpecific:o,malformedHost:s,malformedScheme:l}=lI(r,t);return n||i||o||s||l?void 0:a}var vk={SCHEMES:rI,normalize:VB,resolve:WB,resolveComponent:oI,equal:KB,serialize:ma,parse:Pm};Rm.exports=vk;Rm.exports.default=vk;Rm.exports.fastUri=vk});var dI=j(yk=>{"use strict";Object.defineProperty(yk,"__esModule",{value:!0});var uI=cI();uI.code='require("ajv/dist/runtime/uri").default';yk.default=uI});var yI=j(Xe=>{"use strict";Object.defineProperty(Xe,"__esModule",{value:!0});Xe.CodeGen=Xe.Name=Xe.nil=Xe.stringify=Xe.str=Xe._=Xe.KeywordCxt=void 0;var t3=Tl();Object.defineProperty(Xe,"KeywordCxt",{enumerable:!0,get:function(){return t3.KeywordCxt}});var to=ne();Object.defineProperty(Xe,"_",{enumerable:!0,get:function(){return to._}});Object.defineProperty(Xe,"str",{enumerable:!0,get:function(){return to.str}});Object.defineProperty(Xe,"stringify",{enumerable:!0,get:function(){return to.stringify}});Object.defineProperty(Xe,"nil",{enumerable:!0,get:function(){return to.nil}});Object.defineProperty(Xe,"Name",{enumerable:!0,get:function(){return to.Name}});Object.defineProperty(Xe,"CodeGen",{enumerable:!0,get:function(){return to.CodeGen}});var n3=xm(),fI=Al(),r3=Uy(),Il=Am(),a3=ne(),Pl=Sl(),$m=wl(),_k=pe(),pI=Mz(),i3=dI(),bI=(e,t)=>new RegExp(e,t);bI.code="new RegExp";var o3=["removeAdditional","useDefaults","coerceTypes"],s3=new Set(["validate","serialize","parse","wrapper","root","schema","keyword","pattern","formats","validate$data","func","obj","Error"]),l3={errorDataPath:"",format:"`validateFormats: false` can be used instead.",nullable:'"nullable" keyword is supported by default.',jsonPointers:"Deprecated jsPropertySyntax can be used instead.",extendRefs:"Deprecated ignoreKeywordsWithRef can be used instead.",missingRefs:"Pass empty schema with $id that should be ignored to ajv.addSchema.",processCode:"Use option `code: {process: (code, schemaEnv: object) => string}`",sourceCode:"Use option `code: {source: true}`",strictDefaults:"It is default now, see option `strict`.",strictKeywords:"It is default now, see option `strict`.",uniqueItems:'"uniqueItems" keyword is always validated.',unknownFormats:"Disable strict mode or pass `true` to `ajv.addFormat` (or `formats` option).",cache:"Map is used as cache, schema object as key.",serialize:"Map is used as cache, schema object as key.",ajvErrors:"It is default now."},c3={ignoreKeywordsWithRef:"",jsPropertySyntax:"",unicode:'"minLength"/"maxLength" account for unicode characters by default.'},mI=200;function u3(e){var t,r,a,n,i,o,s,l,c,u,d,m,p,g,h,f,_,b,v,C,S,P,U,qe,D;let re=e.strict,Ie=(t=e.code)===null||t===void 0?void 0:t.optimize,et=Ie===!0||Ie===void 0?1:Ie||0,Le=(a=(r=e.code)===null||r===void 0?void 0:r.regExp)!==null&&a!==void 0?a:bI,on=(n=e.uriResolver)!==null&&n!==void 0?n:i3.default;return{strictSchema:(o=(i=e.strictSchema)!==null&&i!==void 0?i:re)!==null&&o!==void 0?o:!0,strictNumbers:(l=(s=e.strictNumbers)!==null&&s!==void 0?s:re)!==null&&l!==void 0?l:!0,strictTypes:(u=(c=e.strictTypes)!==null&&c!==void 0?c:re)!==null&&u!==void 0?u:"log",strictTuples:(m=(d=e.strictTuples)!==null&&d!==void 0?d:re)!==null&&m!==void 0?m:"log",strictRequired:(g=(p=e.strictRequired)!==null&&p!==void 0?p:re)!==null&&g!==void 0?g:!1,code:e.code?{...e.code,optimize:et,regExp:Le}:{optimize:et,regExp:Le},loopRequired:(h=e.loopRequired)!==null&&h!==void 0?h:mI,loopEnum:(f=e.loopEnum)!==null&&f!==void 0?f:mI,meta:(_=e.meta)!==null&&_!==void 0?_:!0,messages:(b=e.messages)!==null&&b!==void 0?b:!0,inlineRefs:(v=e.inlineRefs)!==null&&v!==void 0?v:!0,schemaId:(C=e.schemaId)!==null&&C!==void 0?C:"$id",addUsedSchema:(S=e.addUsedSchema)!==null&&S!==void 0?S:!0,validateSchema:(P=e.validateSchema)!==null&&P!==void 0?P:!0,validateFormats:(U=e.validateFormats)!==null&&U!==void 0?U:!0,unicodeRegExp:(qe=e.unicodeRegExp)!==null&&qe!==void 0?qe:!0,int32range:(D=e.int32range)!==null&&D!==void 0?D:!0,uriResolver:on}}var Rl=class{constructor(t={}){this.schemas={},this.refs={},this.formats=Object.create(null),this._compilations=new Set,this._loading={},this._cache=new Map,t=this.opts={...t,...u3(t)};let{es5:r,lines:a}=this.opts.code;this.scope=new a3.ValueScope({scope:{},prefixes:s3,es5:r,lines:a}),this.logger=f3(t.logger);let n=t.validateFormats;t.validateFormats=!1,this.RULES=(0,r3.getRules)(),gI.call(this,l3,t,"NOT SUPPORTED"),gI.call(this,c3,t,"DEPRECATED","warn"),this._metaOpts=g3.call(this),t.formats&&p3.call(this),this._addVocabularies(),this._addDefaultMetaSchema(),t.keywords&&m3.call(this,t.keywords),typeof t.meta=="object"&&this.addMetaSchema(t.meta),d3.call(this),t.validateFormats=n}_addVocabularies(){this.addKeyword("$async")}_addDefaultMetaSchema(){let{$data:t,meta:r,schemaId:a}=this.opts,n=pI;a==="id"&&(n={...pI},n.id=n.$id,delete n.$id),r&&t&&this.addMetaSchema(n,n[a],!1)}defaultMeta(){let{meta:t,schemaId:r}=this.opts;return this.opts.defaultMeta=typeof t=="object"?t[r]||t:void 0}validate(t,r){let a;if(typeof t=="string"){if(a=this.getSchema(t),!a)throw new Error(`no schema with key or ref "${t}"`)}else a=this.compile(t);let n=a(r);return"$async"in a||(this.errors=a.errors),n}compile(t,r){let a=this._addSchema(t,r);return a.validate||this._compileSchemaEnv(a)}compileAsync(t,r){if(typeof this.opts.loadSchema!="function")throw new Error("options.loadSchema should be a function");let{loadSchema:a}=this.opts;return n.call(this,t,r);async function n(u,d){await i.call(this,u.$schema);let m=this._addSchema(u,d);return m.validate||o.call(this,m)}async function i(u){u&&!this.getSchema(u)&&await n.call(this,{$ref:u},!0)}async function o(u){try{return this._compileSchemaEnv(u)}catch(d){if(!(d instanceof fI.default))throw d;return s.call(this,d),await l.call(this,d.missingSchema),o.call(this,u)}}function s({missingSchema:u,missingRef:d}){if(this.refs[u])throw new Error(`AnySchema ${u} is loaded but ${d} cannot be resolved`)}async function l(u){let d=await c.call(this,u);this.refs[u]||await i.call(this,d.$schema),this.refs[u]||this.addSchema(d,u,r)}async function c(u){let d=this._loading[u];if(d)return d;try{return await(this._loading[u]=a(u))}finally{delete this._loading[u]}}}addSchema(t,r,a,n=this.opts.validateSchema){if(Array.isArray(t)){for(let o of t)this.addSchema(o,void 0,a,n);return this}let i;if(typeof t=="object"){let{schemaId:o}=this.opts;if(i=t[o],i!==void 0&&typeof i!="string")throw new Error(`schema ${o} must be string`)}return r=(0,Pl.normalizeId)(r||i),this._checkUnique(r),this.schemas[r]=this._addSchema(t,a,r,n,!0),this}addMetaSchema(t,r,a=this.opts.validateSchema){return this.addSchema(t,r,!0,a),this}validateSchema(t,r){if(typeof t=="boolean")return!0;let a;if(a=t.$schema,a!==void 0&&typeof a!="string")throw new Error("$schema must be a string");if(a=a||this.opts.defaultMeta||this.defaultMeta(),!a)return this.logger.warn("meta-schema not available"),this.errors=null,!0;let n=this.validate(a,t);if(!n&&r){let i="schema is invalid: "+this.errorsText();if(this.opts.validateSchema==="log")this.logger.error(i);else throw new Error(i)}return n}getSchema(t){let r;for(;typeof(r=hI.call(this,t))=="string";)t=r;if(r===void 0){let{schemaId:a}=this.opts,n=new Il.SchemaEnv({schema:{},schemaId:a});if(r=Il.resolveSchema.call(this,n,t),!r)return;this.refs[t]=r}return r.validate||this._compileSchemaEnv(r)}removeSchema(t){if(t instanceof RegExp)return this._removeAllSchemas(this.schemas,t),this._removeAllSchemas(this.refs,t),this;switch(typeof t){case"undefined":return this._removeAllSchemas(this.schemas),this._removeAllSchemas(this.refs),this._cache.clear(),this;case"string":{let r=hI.call(this,t);return typeof r=="object"&&this._cache.delete(r.schema),delete this.schemas[t],delete this.refs[t],this}case"object":{let r=t;this._cache.delete(r);let a=t[this.opts.schemaId];return a&&(a=(0,Pl.normalizeId)(a),delete this.schemas[a],delete this.refs[a]),this}default:throw new Error("ajv.removeSchema: invalid parameter")}}addVocabulary(t){for(let r of t)this.addKeyword(r);return this}addKeyword(t,r){let a;if(typeof t=="string")a=t,typeof r=="object"&&(this.logger.warn("these parameters are deprecated, see docs for addKeyword"),r.keyword=a);else if(typeof t=="object"&&r===void 0){if(r=t,a=r.keyword,Array.isArray(a)&&!a.length)throw new Error("addKeywords: keyword must be string or non-empty array")}else throw new Error("invalid addKeywords parameters");if(v3.call(this,a,r),!r)return(0,_k.eachItem)(a,i=>kk.call(this,i)),this;k3.call(this,r);let n={...r,type:(0,$m.getJSONTypes)(r.type),schemaType:(0,$m.getJSONTypes)(r.schemaType)};return(0,_k.eachItem)(a,n.type.length===0?i=>kk.call(this,i,n):i=>n.type.forEach(o=>kk.call(this,i,n,o))),this}getKeyword(t){let r=this.RULES.all[t];return typeof r=="object"?r.definition:!!r}removeKeyword(t){let{RULES:r}=this;delete r.keywords[t],delete r.all[t];for(let a of r.rules){let n=a.rules.findIndex(i=>i.keyword===t);n>=0&&a.rules.splice(n,1)}return this}addFormat(t,r){return typeof r=="string"&&(r=new RegExp(r)),this.formats[t]=r,this}errorsText(t=this.errors,{separator:r=", ",dataVar:a="data"}={}){return!t||t.length===0?"No errors":t.map(n=>`${a}${n.instancePath} ${n.message}`).reduce((n,i)=>n+r+i)}$dataMetaSchema(t,r){let a=this.RULES.all;t=JSON.parse(JSON.stringify(t));for(let n of r){let i=n.split("/").slice(1),o=t;for(let s of i)o=o[s];for(let s in a){let l=a[s];if(typeof l!="object")continue;let{$data:c}=l.definition,u=o[s];c&&u&&(o[s]=vI(u))}}return t}_removeAllSchemas(t,r){for(let a in t){let n=t[a];(!r||r.test(a))&&(typeof n=="string"?delete t[a]:n&&!n.meta&&(this._cache.delete(n.schema),delete t[a]))}}_addSchema(t,r,a,n=this.opts.validateSchema,i=this.opts.addUsedSchema){let o,{schemaId:s}=this.opts;if(typeof t=="object")o=t[s];else{if(this.opts.jtd)throw new Error("schema must be object");if(typeof t!="boolean")throw new Error("schema must be object or boolean")}let l=this._cache.get(t);if(l!==void 0)return l;a=(0,Pl.normalizeId)(o||a);let c=Pl.getSchemaRefs.call(this,t,a);return l=new Il.SchemaEnv({schema:t,schemaId:s,meta:r,baseId:a,localRefs:c}),this._cache.set(l.schema,l),i&&!a.startsWith("#")&&(a&&this._checkUnique(a),this.refs[a]=l),n&&this.validateSchema(t,!0),l}_checkUnique(t){if(this.schemas[t]||this.refs[t])throw new Error(`schema with key or id "${t}" already exists`)}_compileSchemaEnv(t){if(t.meta?this._compileMetaSchema(t):Il.compileSchema.call(this,t),!t.validate)throw new Error("ajv implementation error");return t.validate}_compileMetaSchema(t){let r=this.opts;this.opts=this._metaOpts;try{Il.compileSchema.call(this,t)}finally{this.opts=r}}};Rl.ValidationError=n3.default;Rl.MissingRefError=fI.default;Xe.default=Rl;function gI(e,t,r,a="error"){for(let n in e){let i=n;i in t&&this.logger[a](`${r}: option ${n}. ${e[i]}`)}}function hI(e){return e=(0,Pl.normalizeId)(e),this.schemas[e]||this.refs[e]}function d3(){let e=this.opts.schemas;if(e)if(Array.isArray(e))this.addSchema(e);else for(let t in e)this.addSchema(e[t],t)}function p3(){for(let e in this.opts.formats){let t=this.opts.formats[e];t&&this.addFormat(e,t)}}function m3(e){if(Array.isArray(e)){this.addVocabulary(e);return}this.logger.warn("keywords option as map is deprecated, pass array");for(let t in e){let r=e[t];r.keyword||(r.keyword=t),this.addKeyword(r)}}function g3(){let e={...this.opts};for(let t of o3)delete e[t];return e}var h3={log(){},warn(){},error(){}};function f3(e){if(e===!1)return h3;if(e===void 0)return console;if(e.log&&e.warn&&e.error)return e;throw new Error("logger must implement log, warn and error methods")}var b3=/^[a-z_$][a-z0-9_$:-]*$/i;function v3(e,t){let{RULES:r}=this;if((0,_k.eachItem)(e,a=>{if(r.keywords[a])throw new Error(`Keyword ${a} is already defined`);if(!b3.test(a))throw new Error(`Keyword ${a} has invalid name`)}),!!t&&t.$data&&!("code"in t||"validate"in t))throw new Error('$data keyword must have "code" or "validate" function')}function kk(e,t,r){var a;let n=t?.post;if(r&&n)throw new Error('keyword with "post" flag cannot have "type"');let{RULES:i}=this,o=n?i.post:i.rules.find(({type:l})=>l===r);if(o||(o={type:r,rules:[]},i.rules.push(o)),i.keywords[e]=!0,!t)return;let s={keyword:e,definition:{...t,type:(0,$m.getJSONTypes)(t.type),schemaType:(0,$m.getJSONTypes)(t.schemaType)}};t.before?y3.call(this,o,s,t.before):o.rules.push(s),i.all[e]=s,(a=t.implements)===null||a===void 0||a.forEach(l=>this.addKeyword(l))}function y3(e,t,r){let a=e.rules.findIndex(n=>n.keyword===r);a>=0?e.rules.splice(a,0,t):(e.rules.push(t),this.logger.warn(`rule ${r} is not defined`))}function k3(e){let{metaSchema:t}=e;t!==void 0&&(e.$data&&this.opts.$data&&(t=vI(t)),e.validateSchema=this.compile(t,!0))}var _3={$ref:"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#"};function vI(e){return{anyOf:[e,_3]}}});var kI=j(wk=>{"use strict";Object.defineProperty(wk,"__esModule",{value:!0});var w3={keyword:"id",code(){throw new Error('NOT SUPPORTED: keyword "id", use "$id" for schema ID')}};wk.default=w3});var EI=j(ga=>{"use strict";Object.defineProperty(ga,"__esModule",{value:!0});ga.callRef=ga.getValidate=void 0;var S3=Al(),_I=qt(),At=ne(),no=Zn(),wI=Am(),jm=pe(),E3={keyword:"$ref",schemaType:"string",code(e){let{gen:t,schema:r,it:a}=e,{baseId:n,schemaEnv:i,validateName:o,opts:s,self:l}=a,{root:c}=i;if((r==="#"||r==="#/")&&n===c.baseId)return d();let u=wI.resolveRef.call(l,c,n,r);if(u===void 0)throw new S3.default(a.opts.uriResolver,n,r);if(u instanceof wI.SchemaEnv)return m(u);return p(u);function d(){if(i===c)return Om(e,o,i,i.$async);let g=t.scopeValue("root",{ref:c});return Om(e,(0,At._)`${g}.validate`,c,c.$async)}function m(g){let h=SI(e,g);Om(e,h,g,g.$async)}function p(g){let h=t.scopeValue("schema",s.code.source===!0?{ref:g,code:(0,At.stringify)(g)}:{ref:g}),f=t.name("valid"),_=e.subschema({schema:g,dataTypes:[],schemaPath:At.nil,topSchemaRef:h,errSchemaPath:r},f);e.mergeEvaluated(_),e.ok(f)}}};function SI(e,t){let{gen:r}=e;return t.validate?r.scopeValue("validate",{ref:t.validate}):(0,At._)`${r.scopeValue("wrapper",{ref:t})}.validate`}ga.getValidate=SI;function Om(e,t,r,a){let{gen:n,it:i}=e,{allErrors:o,schemaEnv:s,opts:l}=i,c=l.passContext?no.default.this:At.nil;a?u():d();function u(){if(!s.$async)throw new Error("async schema referenced by sync schema");let g=n.let("valid");n.try(()=>{n.code((0,At._)`await ${(0,_I.callValidateCode)(e,t,c)}`),p(t),o||n.assign(g,!0)},h=>{n.if((0,At._)`!(${h} instanceof ${i.ValidationError})`,()=>n.throw(h)),m(h),o||n.assign(g,!1)}),e.ok(g)}function d(){e.result((0,_I.callValidateCode)(e,t,c),()=>p(t),()=>m(t))}function m(g){let h=(0,At._)`${g}.errors`;n.assign(no.default.vErrors,(0,At._)`${no.default.vErrors} === null ? ${h} : ${no.default.vErrors}.concat(${h})`),n.assign(no.default.errors,(0,At._)`${no.default.vErrors}.length`)}function p(g){var h;if(!i.opts.unevaluated)return;let f=(h=r?.validate)===null||h===void 0?void 0:h.evaluated;if(i.props!==!0)if(f&&!f.dynamicProps)f.props!==void 0&&(i.props=jm.mergeEvaluated.props(n,f.props,i.props));else{let _=n.var("props",(0,At._)`${g}.evaluated.props`);i.props=jm.mergeEvaluated.props(n,_,i.props,At.Name)}if(i.items!==!0)if(f&&!f.dynamicItems)f.items!==void 0&&(i.items=jm.mergeEvaluated.items(n,f.items,i.items));else{let _=n.var("items",(0,At._)`${g}.evaluated.items`);i.items=jm.mergeEvaluated.items(n,_,i.items,At.Name)}}}ga.callRef=Om;ga.default=E3});var xI=j(Sk=>{"use strict";Object.defineProperty(Sk,"__esModule",{value:!0});var x3=kI(),T3=EI(),A3=["$schema","$id","$defs","$vocabulary",{keyword:"$comment"},"definitions",x3.default,T3.default];Sk.default=A3});var TI=j(Ek=>{"use strict";Object.defineProperty(Ek,"__esModule",{value:!0});var Nm=ne(),Cr=Nm.operators,Dm={maximum:{okStr:"<=",ok:Cr.LTE,fail:Cr.GT},minimum:{okStr:">=",ok:Cr.GTE,fail:Cr.LT},exclusiveMaximum:{okStr:"<",ok:Cr.LT,fail:Cr.GTE},exclusiveMinimum:{okStr:">",ok:Cr.GT,fail:Cr.LTE}},C3={message:({keyword:e,schemaCode:t})=>(0,Nm.str)`must be ${Dm[e].okStr} ${t}`,params:({keyword:e,schemaCode:t})=>(0,Nm._)`{comparison: ${Dm[e].okStr}, limit: ${t}}`},z3={keyword:Object.keys(Dm),type:"number",schemaType:"number",$data:!0,error:C3,code(e){let{keyword:t,data:r,schemaCode:a}=e;e.fail$data((0,Nm._)`${r} ${Dm[t].fail} ${a} || isNaN(${r})`)}};Ek.default=z3});var AI=j(xk=>{"use strict";Object.defineProperty(xk,"__esModule",{value:!0});var $l=ne(),I3={message:({schemaCode:e})=>(0,$l.str)`must be multiple of ${e}`,params:({schemaCode:e})=>(0,$l._)`{multipleOf: ${e}}`},P3={keyword:"multipleOf",type:"number",schemaType:"number",$data:!0,error:I3,code(e){let{gen:t,data:r,schemaCode:a,it:n}=e,i=n.opts.multipleOfPrecision,o=t.let("res"),s=i?(0,$l._)`Math.abs(Math.round(${o}) - ${o}) > 1e-${i}`:(0,$l._)`${o} !== parseInt(${o})`;e.fail$data((0,$l._)`(${a} === 0 || (${o} = ${r}/${a}, ${s}))`)}};xk.default=P3});var zI=j(Tk=>{"use strict";Object.defineProperty(Tk,"__esModule",{value:!0});function CI(e){let t=e.length,r=0,a=0,n;for(;a<t;)r++,n=e.charCodeAt(a++),n>=55296&&n<=56319&&a<t&&(n=e.charCodeAt(a),(n&64512)===56320&&a++);return r}Tk.default=CI;CI.code='require("ajv/dist/runtime/ucs2length").default'});var II=j(Ak=>{"use strict";Object.defineProperty(Ak,"__esModule",{value:!0});var ha=ne(),R3=pe(),$3=zI(),j3={message({keyword:e,schemaCode:t}){let r=e==="maxLength"?"more":"fewer";return(0,ha.str)`must NOT have ${r} than ${t} characters`},params:({schemaCode:e})=>(0,ha._)`{limit: ${e}}`},O3={keyword:["maxLength","minLength"],type:"string",schemaType:"number",$data:!0,error:j3,code(e){let{keyword:t,data:r,schemaCode:a,it:n}=e,i=t==="maxLength"?ha.operators.GT:ha.operators.LT,o=n.opts.unicode===!1?(0,ha._)`${r}.length`:(0,ha._)`${(0,R3.useFunc)(e.gen,$3.default)}(${r})`;e.fail$data((0,ha._)`${o} ${i} ${a}`)}};Ak.default=O3});var PI=j(Ck=>{"use strict";Object.defineProperty(Ck,"__esModule",{value:!0});var N3=qt(),D3=pe(),ro=ne(),M3={message:({schemaCode:e})=>(0,ro.str)`must match pattern "${e}"`,params:({schemaCode:e})=>(0,ro._)`{pattern: ${e}}`},L3={keyword:"pattern",type:"string",schemaType:"string",$data:!0,error:M3,code(e){let{gen:t,data:r,$data:a,schema:n,schemaCode:i,it:o}=e,s=o.opts.unicodeRegExp?"u":"";if(a){let{regExp:l}=o.opts.code,c=l.code==="new RegExp"?(0,ro._)`new RegExp`:(0,D3.useFunc)(t,l),u=t.let("valid");t.try(()=>t.assign(u,(0,ro._)`${c}(${i}, ${s}).test(${r})`),()=>t.assign(u,!1)),e.fail$data((0,ro._)`!${u}`)}else{let l=(0,N3.usePattern)(e,n);e.fail$data((0,ro._)`!${l}.test(${r})`)}}};Ck.default=L3});var RI=j(zk=>{"use strict";Object.defineProperty(zk,"__esModule",{value:!0});var jl=ne(),B3={message({keyword:e,schemaCode:t}){let r=e==="maxProperties"?"more":"fewer";return(0,jl.str)`must NOT have ${r} than ${t} properties`},params:({schemaCode:e})=>(0,jl._)`{limit: ${e}}`},U3={keyword:["maxProperties","minProperties"],type:"object",schemaType:"number",$data:!0,error:B3,code(e){let{keyword:t,data:r,schemaCode:a}=e,n=t==="maxProperties"?jl.operators.GT:jl.operators.LT;e.fail$data((0,jl._)`Object.keys(${r}).length ${n} ${a}`)}};zk.default=U3});var $I=j(Ik=>{"use strict";Object.defineProperty(Ik,"__esModule",{value:!0});var Ol=qt(),Nl=ne(),F3=pe(),q3={message:({params:{missingProperty:e}})=>(0,Nl.str)`must have required property '${e}'`,params:({params:{missingProperty:e}})=>(0,Nl._)`{missingProperty: ${e}}`},H3={keyword:"required",type:"object",schemaType:"array",$data:!0,error:q3,code(e){let{gen:t,schema:r,schemaCode:a,data:n,$data:i,it:o}=e,{opts:s}=o;if(!i&&r.length===0)return;let l=r.length>=s.loopRequired;if(o.allErrors?c():u(),s.strictRequired){let p=e.parentSchema.properties,{definedProperties:g}=e.it;for(let h of r)if(p?.[h]===void 0&&!g.has(h)){let f=o.schemaEnv.baseId+o.errSchemaPath,_=`required property "${h}" is not defined at "${f}" (strictRequired)`;(0,F3.checkStrictMode)(o,_,o.opts.strictRequired)}}function c(){if(l||i)e.block$data(Nl.nil,d);else for(let p of r)(0,Ol.checkReportMissingProp)(e,p)}function u(){let p=t.let("missing");if(l||i){let g=t.let("valid",!0);e.block$data(g,()=>m(p,g)),e.ok(g)}else t.if((0,Ol.checkMissingProp)(e,r,p)),(0,Ol.reportMissingProp)(e,p),t.else()}function d(){t.forOf("prop",a,p=>{e.setParams({missingProperty:p}),t.if((0,Ol.noPropertyInData)(t,n,p,s.ownProperties),()=>e.error())})}function m(p,g){e.setParams({missingProperty:p}),t.forOf(p,a,()=>{t.assign(g,(0,Ol.propertyInData)(t,n,p,s.ownProperties)),t.if((0,Nl.not)(g),()=>{e.error(),t.break()})},Nl.nil)}}};Ik.default=H3});var jI=j(Pk=>{"use strict";Object.defineProperty(Pk,"__esModule",{value:!0});var Dl=ne(),G3={message({keyword:e,schemaCode:t}){let r=e==="maxItems"?"more":"fewer";return(0,Dl.str)`must NOT have ${r} than ${t} items`},params:({schemaCode:e})=>(0,Dl._)`{limit: ${e}}`},V3={keyword:["maxItems","minItems"],type:"array",schemaType:"number",$data:!0,error:G3,code(e){let{keyword:t,data:r,schemaCode:a}=e,n=t==="maxItems"?Dl.operators.GT:Dl.operators.LT;e.fail$data((0,Dl._)`${r}.length ${n} ${a}`)}};Pk.default=V3});var Mm=j(Rk=>{"use strict";Object.defineProperty(Rk,"__esModule",{value:!0});var OI=Zy();OI.code='require("ajv/dist/runtime/equal").default';Rk.default=OI});var NI=j(jk=>{"use strict";Object.defineProperty(jk,"__esModule",{value:!0});var $k=wl(),Qe=ne(),W3=pe(),K3=Mm(),Z3={message:({params:{i:e,j:t}})=>(0,Qe.str)`must NOT have duplicate items (items ## ${t} and ${e} are identical)`,params:({params:{i:e,j:t}})=>(0,Qe._)`{i: ${e}, j: ${t}}`},J3={keyword:"uniqueItems",type:"array",schemaType:"boolean",$data:!0,error:Z3,code(e){let{gen:t,data:r,$data:a,schema:n,parentSchema:i,schemaCode:o,it:s}=e;if(!a&&!n)return;let l=t.let("valid"),c=i.items?(0,$k.getSchemaTypes)(i.items):[];e.block$data(l,u,(0,Qe._)`${o} === false`),e.ok(l);function u(){let g=t.let("i",(0,Qe._)`${r}.length`),h=t.let("j");e.setParams({i:g,j:h}),t.assign(l,!0),t.if((0,Qe._)`${g} > 1`,()=>(d()?m:p)(g,h))}function d(){return c.length>0&&!c.some(g=>g==="object"||g==="array")}function m(g,h){let f=t.name("item"),_=(0,$k.checkDataTypes)(c,f,s.opts.strictNumbers,$k.DataType.Wrong),b=t.const("indices",(0,Qe._)`{}`);t.for((0,Qe._)`;${g}--;`,()=>{t.let(f,(0,Qe._)`${r}[${g}]`),t.if(_,(0,Qe._)`continue`),c.length>1&&t.if((0,Qe._)`typeof ${f} == "string"`,(0,Qe._)`${f} += "_"`),t.if((0,Qe._)`typeof ${b}[${f}] == "number"`,()=>{t.assign(h,(0,Qe._)`${b}[${f}]`),e.error(),t.assign(l,!1).break()}).code((0,Qe._)`${b}[${f}] = ${g}`)})}function p(g,h){let f=(0,W3.useFunc)(t,K3.default),_=t.name("outer");t.label(_).for((0,Qe._)`;${g}--;`,()=>t.for((0,Qe._)`${h} = ${g}; ${h}--;`,()=>t.if((0,Qe._)`${f}(${r}[${g}], ${r}[${h}])`,()=>{e.error(),t.assign(l,!1).break(_)})))}}};jk.default=J3});var DI=j(Nk=>{"use strict";Object.defineProperty(Nk,"__esModule",{value:!0});var Ok=ne(),Y3=pe(),X3=Mm(),Q3={message:"must be equal to constant",params:({schemaCode:e})=>(0,Ok._)`{allowedValue: ${e}}`},eU={keyword:"const",$data:!0,error:Q3,code(e){let{gen:t,data:r,$data:a,schemaCode:n,schema:i}=e;a||i&&typeof i=="object"?e.fail$data((0,Ok._)`!${(0,Y3.useFunc)(t,X3.default)}(${r}, ${n})`):e.fail((0,Ok._)`${i} !== ${r}`)}};Nk.default=eU});var MI=j(Dk=>{"use strict";Object.defineProperty(Dk,"__esModule",{value:!0});var Ml=ne(),tU=pe(),nU=Mm(),rU={message:"must be equal to one of the allowed values",params:({schemaCode:e})=>(0,Ml._)`{allowedValues: ${e}}`},aU={keyword:"enum",schemaType:"array",$data:!0,error:rU,code(e){let{gen:t,data:r,$data:a,schema:n,schemaCode:i,it:o}=e;if(!a&&n.length===0)throw new Error("enum must have non-empty array");let s=n.length>=o.opts.loopEnum,l,c=()=>l??(l=(0,tU.useFunc)(t,nU.default)),u;if(s||a)u=t.let("valid"),e.block$data(u,d);else{if(!Array.isArray(n))throw new Error("ajv implementation error");let p=t.const("vSchema",i);u=(0,Ml.or)(...n.map((g,h)=>m(p,h)))}e.pass(u);function d(){t.assign(u,!1),t.forOf("v",i,p=>t.if((0,Ml._)`${c()}(${r}, ${p})`,()=>t.assign(u,!0).break()))}function m(p,g){let h=n[g];return typeof h=="object"&&h!==null?(0,Ml._)`${c()}(${r}, ${p}[${g}])`:(0,Ml._)`${r} === ${h}`}}};Dk.default=aU});var LI=j(Mk=>{"use strict";Object.defineProperty(Mk,"__esModule",{value:!0});var iU=TI(),oU=AI(),sU=II(),lU=PI(),cU=RI(),uU=$I(),dU=jI(),pU=NI(),mU=DI(),gU=MI(),hU=[iU.default,oU.default,sU.default,lU.default,cU.default,uU.default,dU.default,pU.default,{keyword:"type",schemaType:["string","array"]},{keyword:"nullable",schemaType:"boolean"},mU.default,gU.default];Mk.default=hU});var Bk=j(Ll=>{"use strict";Object.defineProperty(Ll,"__esModule",{value:!0});Ll.validateAdditionalItems=void 0;var fa=ne(),Lk=pe(),fU={message:({params:{len:e}})=>(0,fa.str)`must NOT have more than ${e} items`,params:({params:{len:e}})=>(0,fa._)`{limit: ${e}}`},bU={keyword:"additionalItems",type:"array",schemaType:["boolean","object"],before:"uniqueItems",error:fU,code(e){let{parentSchema:t,it:r}=e,{items:a}=t;if(!Array.isArray(a)){(0,Lk.checkStrictMode)(r,'"additionalItems" is ignored when "items" is not an array of schemas');return}BI(e,a)}};function BI(e,t){let{gen:r,schema:a,data:n,keyword:i,it:o}=e;o.items=!0;let s=r.const("len",(0,fa._)`${n}.length`);if(a===!1)e.setParams({len:t.length}),e.pass((0,fa._)`${s} <= ${t.length}`);else if(typeof a=="object"&&!(0,Lk.alwaysValidSchema)(o,a)){let c=r.var("valid",(0,fa._)`${s} <= ${t.length}`);r.if((0,fa.not)(c),()=>l(c)),e.ok(c)}function l(c){r.forRange("i",t.length,s,u=>{e.subschema({keyword:i,dataProp:u,dataPropType:Lk.Type.Num},c),o.allErrors||r.if((0,fa.not)(c),()=>r.break())})}}Ll.validateAdditionalItems=BI;Ll.default=bU});var Uk=j(Bl=>{"use strict";Object.defineProperty(Bl,"__esModule",{value:!0});Bl.validateTuple=void 0;var UI=ne(),Lm=pe(),vU=qt(),yU={keyword:"items",type:"array",schemaType:["object","array","boolean"],before:"uniqueItems",code(e){let{schema:t,it:r}=e;if(Array.isArray(t))return FI(e,"additionalItems",t);r.items=!0,!(0,Lm.alwaysValidSchema)(r,t)&&e.ok((0,vU.validateArray)(e))}};function FI(e,t,r=e.schema){let{gen:a,parentSchema:n,data:i,keyword:o,it:s}=e;u(n),s.opts.unevaluated&&r.length&&s.items!==!0&&(s.items=Lm.mergeEvaluated.items(a,r.length,s.items));let l=a.name("valid"),c=a.const("len",(0,UI._)`${i}.length`);r.forEach((d,m)=>{(0,Lm.alwaysValidSchema)(s,d)||(a.if((0,UI._)`${c} > ${m}`,()=>e.subschema({keyword:o,schemaProp:m,dataProp:m},l)),e.ok(l))});function u(d){let{opts:m,errSchemaPath:p}=s,g=r.length,h=g===d.minItems&&(g===d.maxItems||d[t]===!1);if(m.strictTuples&&!h){let f=`"${o}" is ${g}-tuple, but minItems or maxItems/${t} are not specified or different at path "${p}"`;(0,Lm.checkStrictMode)(s,f,m.strictTuples)}}}Bl.validateTuple=FI;Bl.default=yU});var qI=j(Fk=>{"use strict";Object.defineProperty(Fk,"__esModule",{value:!0});var kU=Uk(),_U={keyword:"prefixItems",type:"array",schemaType:["array"],before:"uniqueItems",code:e=>(0,kU.validateTuple)(e,"items")};Fk.default=_U});var GI=j(qk=>{"use strict";Object.defineProperty(qk,"__esModule",{value:!0});var HI=ne(),wU=pe(),SU=qt(),EU=Bk(),xU={message:({params:{len:e}})=>(0,HI.str)`must NOT have more than ${e} items`,params:({params:{len:e}})=>(0,HI._)`{limit: ${e}}`},TU={keyword:"items",type:"array",schemaType:["object","boolean"],before:"uniqueItems",error:xU,code(e){let{schema:t,parentSchema:r,it:a}=e,{prefixItems:n}=r;a.items=!0,!(0,wU.alwaysValidSchema)(a,t)&&(n?(0,EU.validateAdditionalItems)(e,n):e.ok((0,SU.validateArray)(e)))}};qk.default=TU});var VI=j(Hk=>{"use strict";Object.defineProperty(Hk,"__esModule",{value:!0});var Gt=ne(),Bm=pe(),AU={message:({params:{min:e,max:t}})=>t===void 0?(0,Gt.str)`must contain at least ${e} valid item(s)`:(0,Gt.str)`must contain at least ${e} and no more than ${t} valid item(s)`,params:({params:{min:e,max:t}})=>t===void 0?(0,Gt._)`{minContains: ${e}}`:(0,Gt._)`{minContains: ${e}, maxContains: ${t}}`},CU={keyword:"contains",type:"array",schemaType:["object","boolean"],before:"uniqueItems",trackErrors:!0,error:AU,code(e){let{gen:t,schema:r,parentSchema:a,data:n,it:i}=e,o,s,{minContains:l,maxContains:c}=a;i.opts.next?(o=l===void 0?1:l,s=c):o=1;let u=t.const("len",(0,Gt._)`${n}.length`);if(e.setParams({min:o,max:s}),s===void 0&&o===0){(0,Bm.checkStrictMode)(i,'"minContains" == 0 without "maxContains": "contains" keyword ignored');return}if(s!==void 0&&o>s){(0,Bm.checkStrictMode)(i,'"minContains" > "maxContains" is always invalid'),e.fail();return}if((0,Bm.alwaysValidSchema)(i,r)){let h=(0,Gt._)`${u} >= ${o}`;s!==void 0&&(h=(0,Gt._)`${h} && ${u} <= ${s}`),e.pass(h);return}i.items=!0;let d=t.name("valid");s===void 0&&o===1?p(d,()=>t.if(d,()=>t.break())):o===0?(t.let(d,!0),s!==void 0&&t.if((0,Gt._)`${n}.length > 0`,m)):(t.let(d,!1),m()),e.result(d,()=>e.reset());function m(){let h=t.name("_valid"),f=t.let("count",0);p(h,()=>t.if(h,()=>g(f)))}function p(h,f){t.forRange("i",0,u,_=>{e.subschema({keyword:"contains",dataProp:_,dataPropType:Bm.Type.Num,compositeRule:!0},h),f()})}function g(h){t.code((0,Gt._)`${h}++`),s===void 0?t.if((0,Gt._)`${h} >= ${o}`,()=>t.assign(d,!0).break()):(t.if((0,Gt._)`${h} > ${s}`,()=>t.assign(d,!1).break()),o===1?t.assign(d,!0):t.if((0,Gt._)`${h} >= ${o}`,()=>t.assign(d,!0)))}}};Hk.default=CU});var ZI=j(kn=>{"use strict";Object.defineProperty(kn,"__esModule",{value:!0});kn.validateSchemaDeps=kn.validatePropertyDeps=kn.error=void 0;var Gk=ne(),zU=pe(),Ul=qt();kn.error={message:({params:{property:e,depsCount:t,deps:r}})=>{let a=t===1?"property":"properties";return(0,Gk.str)`must have ${a} ${r} when property ${e} is present`},params:({params:{property:e,depsCount:t,deps:r,missingProperty:a}})=>(0,Gk._)`{property: ${e},
|
|
6
|
+
|| ${o} === "boolean" || ${n} === null`).assign(s,(0,te._)`[${n}]`)}}}function GL({gen:e,parentData:t,parentDataProperty:r},a){e.if((0,te._)`${t} !== undefined`,()=>e.assign((0,te._)`${t}[${r}]`,a))}function qy(e,t,r,a=Yi.Correct){let n=a===Yi.Correct?te.operators.EQ:te.operators.NEQ,i;switch(e){case"null":return(0,te._)`${t} ${n} null`;case"array":i=(0,te._)`Array.isArray(${t})`;break;case"object":i=(0,te._)`${t} && typeof ${t} == "object" && !Array.isArray(${t})`;break;case"integer":i=o((0,te._)`!(${t} % 1) && !isNaN(${t})`);break;case"number":i=o();break;default:return(0,te._)`typeof ${t} ${n} ${e}`}return a===Yi.Correct?i:(0,te.not)(i);function o(s=te.nil){return(0,te.and)((0,te._)`typeof ${t} == "number"`,s,r?(0,te._)`isFinite(${t})`:te.nil)}}ot.checkDataType=qy;function Hy(e,t,r,a){if(e.length===1)return qy(e[0],t,r,a);let n,i=(0,az.toHash)(e);if(i.array&&i.object){let o=(0,te._)`typeof ${t} != "object"`;n=i.null?o:(0,te._)`!${t} || ${o}`,delete i.null,delete i.array,delete i.object}else n=te.nil;i.number&&delete i.integer;for(let o in i)n=(0,te.and)(n,qy(o,t,r,a));return n}ot.checkDataTypes=Hy;var VL={message:({schema:e})=>`must be ${e}`,params:({schema:e,schemaValue:t})=>typeof e=="string"?(0,te._)`{type: ${e}}`:(0,te._)`{type: ${t}}`};function Gy(e){let t=WL(e);(0,BL.reportError)(t,VL)}ot.reportTypeError=Gy;function WL(e){let{gen:t,data:r,schema:a}=e,n=(0,az.schemaRefOrVal)(e,a,"type");return{gen:t,keyword:"type",data:r,schema:a.type,schemaCode:n,schemaValue:n,parentSchema:a,params:{},it:e}}});var lz=j(_m=>{"use strict";Object.defineProperty(_m,"__esModule",{value:!0});_m.assignDefaults=void 0;var Xi=ne(),KL=pe();function ZL(e,t){let{properties:r,items:a}=e.schema;if(t==="object"&&r)for(let n in r)sz(e,n,r[n].default);else t==="array"&&Array.isArray(a)&&a.forEach((n,i)=>sz(e,i,n.default))}_m.assignDefaults=ZL;function sz(e,t,r){let{gen:a,compositeRule:n,data:i,opts:o}=e;if(r===void 0)return;let s=(0,Xi._)`${i}${(0,Xi.getProperty)(t)}`;if(n){(0,KL.checkStrictMode)(e,`default is ignored for: ${s}`);return}let l=(0,Xi._)`${s} === undefined`;o.useDefaults==="empty"&&(l=(0,Xi._)`${l} || ${s} === null || ${s} === ""`),a.if(l,(0,Xi._)`${s} = ${(0,Xi.stringify)(r)}`)}});var qt=j(Ae=>{"use strict";Object.defineProperty(Ae,"__esModule",{value:!0});Ae.validateUnion=Ae.validateArray=Ae.usePattern=Ae.callValidateCode=Ae.schemaProperties=Ae.allSchemaProperties=Ae.noPropertyInData=Ae.propertyInData=Ae.isOwnProperty=Ae.hasPropFunc=Ae.reportMissingProp=Ae.checkMissingProp=Ae.checkReportMissingProp=void 0;var Pe=ne(),Vy=pe(),Er=Zn(),JL=pe();function YL(e,t){let{gen:r,data:a,it:n}=e;r.if(Ky(r,a,t,n.opts.ownProperties),()=>{e.setParams({missingProperty:(0,Pe._)`${t}`},!0),e.error()})}Ae.checkReportMissingProp=YL;function XL({gen:e,data:t,it:{opts:r}},a,n){return(0,Pe.or)(...a.map(i=>(0,Pe.and)(Ky(e,t,i,r.ownProperties),(0,Pe._)`${n} = ${i}`)))}Ae.checkMissingProp=XL;function QL(e,t){e.setParams({missingProperty:t},!0),e.error()}Ae.reportMissingProp=QL;function cz(e){return e.scopeValue("func",{ref:Object.prototype.hasOwnProperty,code:(0,Pe._)`Object.prototype.hasOwnProperty`})}Ae.hasPropFunc=cz;function Wy(e,t,r){return(0,Pe._)`${cz(e)}.call(${t}, ${r})`}Ae.isOwnProperty=Wy;function e4(e,t,r,a){let n=(0,Pe._)`${t}${(0,Pe.getProperty)(r)} !== undefined`;return a?(0,Pe._)`${n} && ${Wy(e,t,r)}`:n}Ae.propertyInData=e4;function Ky(e,t,r,a){let n=(0,Pe._)`${t}${(0,Pe.getProperty)(r)} === undefined`;return a?(0,Pe.or)(n,(0,Pe.not)(Wy(e,t,r))):n}Ae.noPropertyInData=Ky;function uz(e){return e?Object.keys(e).filter(t=>t!=="__proto__"):[]}Ae.allSchemaProperties=uz;function t4(e,t){return uz(t).filter(r=>!(0,Vy.alwaysValidSchema)(e,t[r]))}Ae.schemaProperties=t4;function n4({schemaCode:e,data:t,it:{gen:r,topSchemaRef:a,schemaPath:n,errorPath:i},it:o},s,l,c){let u=c?(0,Pe._)`${e}, ${t}, ${a}${n}`:t,d=[[Er.default.instancePath,(0,Pe.strConcat)(Er.default.instancePath,i)],[Er.default.parentData,o.parentData],[Er.default.parentDataProperty,o.parentDataProperty],[Er.default.rootData,Er.default.rootData]];o.opts.dynamicRef&&d.push([Er.default.dynamicAnchors,Er.default.dynamicAnchors]);let m=(0,Pe._)`${u}, ${r.object(...d)}`;return l!==Pe.nil?(0,Pe._)`${s}.call(${l}, ${m})`:(0,Pe._)`${s}(${m})`}Ae.callValidateCode=n4;var r4=(0,Pe._)`new RegExp`;function a4({gen:e,it:{opts:t}},r){let a=t.unicodeRegExp?"u":"",{regExp:n}=t.code,i=n(r,a);return e.scopeValue("pattern",{key:i.toString(),ref:i,code:(0,Pe._)`${n.code==="new RegExp"?r4:(0,JL.useFunc)(e,n)}(${r}, ${a})`})}Ae.usePattern=a4;function i4(e){let{gen:t,data:r,keyword:a,it:n}=e,i=t.name("valid");if(n.allErrors){let s=t.let("valid",!0);return o(()=>t.assign(s,!1)),s}return t.var(i,!0),o(()=>t.break()),i;function o(s){let l=t.const("len",(0,Pe._)`${r}.length`);t.forRange("i",0,l,c=>{e.subschema({keyword:a,dataProp:c,dataPropType:Vy.Type.Num},i),t.if((0,Pe.not)(i),s)})}}Ae.validateArray=i4;function o4(e){let{gen:t,schema:r,keyword:a,it:n}=e;if(!Array.isArray(r))throw new Error("ajv implementation error");if(r.some(l=>(0,Vy.alwaysValidSchema)(n,l))&&!n.opts.unevaluated)return;let o=t.let("valid",!1),s=t.name("_valid");t.block(()=>r.forEach((l,c)=>{let u=e.subschema({keyword:a,schemaProp:c,compositeRule:!0},s);t.assign(o,(0,Pe._)`${o} || ${s}`),e.mergeValidEvaluated(u,s)||t.if((0,Pe.not)(o))})),e.result(o,()=>e.reset(),()=>e.error(!0))}Ae.validateUnion=o4});var mz=j(vn=>{"use strict";Object.defineProperty(vn,"__esModule",{value:!0});vn.validateKeywordUsage=vn.validSchemaType=vn.funcKeywordCode=vn.macroKeywordCode=void 0;var bt=ne(),ua=Zn(),s4=qt(),l4=_l();function c4(e,t){let{gen:r,keyword:a,schema:n,parentSchema:i,it:o}=e,s=t.macro.call(o.self,n,i,o),l=pz(r,a,s);o.opts.validateSchema!==!1&&o.self.validateSchema(s,!0);let c=r.name("valid");e.subschema({schema:s,schemaPath:bt.nil,errSchemaPath:`${o.errSchemaPath}/${a}`,topSchemaRef:l,compositeRule:!0},c),e.pass(c,()=>e.error(!0))}vn.macroKeywordCode=c4;function u4(e,t){var r;let{gen:a,keyword:n,schema:i,parentSchema:o,$data:s,it:l}=e;p4(l,t);let c=!s&&t.compile?t.compile.call(l.self,i,o,l):t.validate,u=pz(a,n,c),d=a.let("valid");e.block$data(d,m),e.ok((r=t.valid)!==null&&r!==void 0?r:d);function m(){if(t.errors===!1)h(),t.modifying&&dz(e),f(()=>e.error());else{let _=t.async?p():g();t.modifying&&dz(e),f(()=>d4(e,_))}}function p(){let _=a.let("ruleErrs",null);return a.try(()=>h((0,bt._)`await `),b=>a.assign(d,!1).if((0,bt._)`${b} instanceof ${l.ValidationError}`,()=>a.assign(_,(0,bt._)`${b}.errors`),()=>a.throw(b))),_}function g(){let _=(0,bt._)`${u}.errors`;return a.assign(_,null),h(bt.nil),_}function h(_=t.async?(0,bt._)`await `:bt.nil){let b=l.opts.passContext?ua.default.this:ua.default.self,v=!("compile"in t&&!s||t.schema===!1);a.assign(d,(0,bt._)`${_}${(0,s4.callValidateCode)(e,u,b,v)}`,t.modifying)}function f(_){var b;a.if((0,bt.not)((b=t.valid)!==null&&b!==void 0?b:d),_)}}vn.funcKeywordCode=u4;function dz(e){let{gen:t,data:r,it:a}=e;t.if(a.parentData,()=>t.assign(r,(0,bt._)`${a.parentData}[${a.parentDataProperty}]`))}function d4(e,t){let{gen:r}=e;r.if((0,bt._)`Array.isArray(${t})`,()=>{r.assign(ua.default.vErrors,(0,bt._)`${ua.default.vErrors} === null ? ${t} : ${ua.default.vErrors}.concat(${t})`).assign(ua.default.errors,(0,bt._)`${ua.default.vErrors}.length`),(0,l4.extendErrors)(e)},()=>e.error())}function p4({schemaEnv:e},t){if(t.async&&!e.$async)throw new Error("async keyword in sync schema")}function pz(e,t,r){if(r===void 0)throw new Error(`keyword "${t}" failed to compile`);return e.scopeValue("keyword",typeof r=="function"?{ref:r}:{ref:r,code:(0,bt.stringify)(r)})}function m4(e,t,r=!1){return!t.length||t.some(a=>a==="array"?Array.isArray(e):a==="object"?e&&typeof e=="object"&&!Array.isArray(e):typeof e==a||r&&typeof e>"u")}vn.validSchemaType=m4;function g4({schema:e,opts:t,self:r,errSchemaPath:a},n,i){if(Array.isArray(n.keyword)?!n.keyword.includes(i):n.keyword!==i)throw new Error("ajv implementation error");let o=n.dependencies;if(o?.some(s=>!Object.prototype.hasOwnProperty.call(e,s)))throw new Error(`parent schema must have dependencies of ${i}: ${o.join(",")}`);if(n.validateSchema&&!n.validateSchema(e[i])){let l=`keyword "${i}" value is invalid at path "${a}": `+r.errorsText(n.validateSchema.errors);if(t.validateSchema==="log")r.logger.error(l);else throw new Error(l)}}vn.validateKeywordUsage=g4});var hz=j(xr=>{"use strict";Object.defineProperty(xr,"__esModule",{value:!0});xr.extendSubschemaMode=xr.extendSubschemaData=xr.getSubschema=void 0;var yn=ne(),gz=pe();function h4(e,{keyword:t,schemaProp:r,schema:a,schemaPath:n,errSchemaPath:i,topSchemaRef:o}){if(t!==void 0&&a!==void 0)throw new Error('both "keyword" and "schema" passed, only one allowed');if(t!==void 0){let s=e.schema[t];return r===void 0?{schema:s,schemaPath:(0,yn._)`${e.schemaPath}${(0,yn.getProperty)(t)}`,errSchemaPath:`${e.errSchemaPath}/${t}`}:{schema:s[r],schemaPath:(0,yn._)`${e.schemaPath}${(0,yn.getProperty)(t)}${(0,yn.getProperty)(r)}`,errSchemaPath:`${e.errSchemaPath}/${t}/${(0,gz.escapeFragment)(r)}`}}if(a!==void 0){if(n===void 0||i===void 0||o===void 0)throw new Error('"schemaPath", "errSchemaPath" and "topSchemaRef" are required with "schema"');return{schema:a,schemaPath:n,topSchemaRef:o,errSchemaPath:i}}throw new Error('either "keyword" or "schema" must be passed')}xr.getSubschema=h4;function f4(e,t,{dataProp:r,dataPropType:a,data:n,dataTypes:i,propertyName:o}){if(n!==void 0&&r!==void 0)throw new Error('both "data" and "dataProp" passed, only one allowed');let{gen:s}=t;if(r!==void 0){let{errorPath:c,dataPathArr:u,opts:d}=t,m=s.let("data",(0,yn._)`${t.data}${(0,yn.getProperty)(r)}`,!0);l(m),e.errorPath=(0,yn.str)`${c}${(0,gz.getErrorPath)(r,a,d.jsPropertySyntax)}`,e.parentDataProperty=(0,yn._)`${r}`,e.dataPathArr=[...u,e.parentDataProperty]}if(n!==void 0){let c=n instanceof yn.Name?n:s.let("data",n,!0);l(c),o!==void 0&&(e.propertyName=o)}i&&(e.dataTypes=i);function l(c){e.data=c,e.dataLevel=t.dataLevel+1,e.dataTypes=[],t.definedProperties=new Set,e.parentData=t.data,e.dataNames=[...t.dataNames,c]}}xr.extendSubschemaData=f4;function b4(e,{jtdDiscriminator:t,jtdMetadata:r,compositeRule:a,createErrors:n,allErrors:i}){a!==void 0&&(e.compositeRule=a),n!==void 0&&(e.createErrors=n),i!==void 0&&(e.allErrors=i),e.jtdDiscriminator=t,e.jtdMetadata=r}xr.extendSubschemaMode=b4});var Zy=j((gY,fz)=>{"use strict";fz.exports=function e(t,r){if(t===r)return!0;if(t&&r&&typeof t=="object"&&typeof r=="object"){if(t.constructor!==r.constructor)return!1;var a,n,i;if(Array.isArray(t)){if(a=t.length,a!=r.length)return!1;for(n=a;n--!==0;)if(!e(t[n],r[n]))return!1;return!0}if(t.constructor===RegExp)return t.source===r.source&&t.flags===r.flags;if(t.valueOf!==Object.prototype.valueOf)return t.valueOf()===r.valueOf();if(t.toString!==Object.prototype.toString)return t.toString()===r.toString();if(i=Object.keys(t),a=i.length,a!==Object.keys(r).length)return!1;for(n=a;n--!==0;)if(!Object.prototype.hasOwnProperty.call(r,i[n]))return!1;for(n=a;n--!==0;){var o=i[n];if(!e(t[o],r[o]))return!1}return!0}return t!==t&&r!==r}});var vz=j((hY,bz)=>{"use strict";var Tr=bz.exports=function(e,t,r){typeof t=="function"&&(r=t,t={}),r=t.cb||r;var a=typeof r=="function"?r:r.pre||function(){},n=r.post||function(){};wm(t,a,n,e,"",e)};Tr.keywords={additionalItems:!0,items:!0,contains:!0,additionalProperties:!0,propertyNames:!0,not:!0,if:!0,then:!0,else:!0};Tr.arrayKeywords={items:!0,allOf:!0,anyOf:!0,oneOf:!0};Tr.propsKeywords={$defs:!0,definitions:!0,properties:!0,patternProperties:!0,dependencies:!0};Tr.skipKeywords={default:!0,enum:!0,const:!0,required:!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};function wm(e,t,r,a,n,i,o,s,l,c){if(a&&typeof a=="object"&&!Array.isArray(a)){t(a,n,i,o,s,l,c);for(var u in a){var d=a[u];if(Array.isArray(d)){if(u in Tr.arrayKeywords)for(var m=0;m<d.length;m++)wm(e,t,r,d[m],n+"/"+u+"/"+m,i,n,u,a,m)}else if(u in Tr.propsKeywords){if(d&&typeof d=="object")for(var p in d)wm(e,t,r,d[p],n+"/"+u+"/"+v4(p),i,n,u,a,p)}else(u in Tr.keywords||e.allKeys&&!(u in Tr.skipKeywords))&&wm(e,t,r,d,n+"/"+u,i,n,u,a)}r(a,n,i,o,s,l,c)}}function v4(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}});var Sl=j(xt=>{"use strict";Object.defineProperty(xt,"__esModule",{value:!0});xt.getSchemaRefs=xt.resolveUrl=xt.normalizeId=xt._getFullPath=xt.getFullPath=xt.inlineRef=void 0;var y4=pe(),k4=Zy(),_4=vz(),w4=new Set(["type","format","pattern","maxLength","minLength","maxProperties","minProperties","maxItems","minItems","maximum","minimum","uniqueItems","multipleOf","required","enum","const"]);function S4(e,t=!0){return typeof e=="boolean"?!0:t===!0?!Jy(e):t?yz(e)<=t:!1}xt.inlineRef=S4;var E4=new Set(["$ref","$recursiveRef","$recursiveAnchor","$dynamicRef","$dynamicAnchor"]);function Jy(e){for(let t in e){if(E4.has(t))return!0;let r=e[t];if(Array.isArray(r)&&r.some(Jy)||typeof r=="object"&&Jy(r))return!0}return!1}function yz(e){let t=0;for(let r in e){if(r==="$ref")return 1/0;if(t++,!w4.has(r)&&(typeof e[r]=="object"&&(0,y4.eachItem)(e[r],a=>t+=yz(a)),t===1/0))return 1/0}return t}function kz(e,t="",r){r!==!1&&(t=Qi(t));let a=e.parse(t);return _z(e,a)}xt.getFullPath=kz;function _z(e,t){return e.serialize(t).split("#")[0]+"#"}xt._getFullPath=_z;var x4=/#\/?$/;function Qi(e){return e?e.replace(x4,""):""}xt.normalizeId=Qi;function T4(e,t,r){return r=Qi(r),e.resolve(t,r)}xt.resolveUrl=T4;var A4=/^[a-z_][-a-z0-9._]*$/i;function C4(e,t){if(typeof e=="boolean")return{};let{schemaId:r,uriResolver:a}=this.opts,n=Qi(e[r]||t),i={"":n},o=kz(a,n,!1),s={},l=new Set;return _4(e,{allKeys:!0},(d,m,p,g)=>{if(g===void 0)return;let h=o+m,f=i[g];typeof d[r]=="string"&&(f=_.call(this,d[r])),b.call(this,d.$anchor),b.call(this,d.$dynamicAnchor),i[m]=f;function _(v){let C=this.opts.uriResolver.resolve;if(v=Qi(f?C(f,v):v),l.has(v))throw u(v);l.add(v);let S=this.refs[v];return typeof S=="string"&&(S=this.refs[S]),typeof S=="object"?c(d,S.schema,v):v!==Qi(h)&&(v[0]==="#"?(c(d,s[v],v),s[v]=d):this.refs[v]=h),v}function b(v){if(typeof v=="string"){if(!A4.test(v))throw new Error(`invalid anchor "${v}"`);_.call(this,`#${v}`)}}}),s;function c(d,m,p){if(m!==void 0&&!k4(d,m))throw u(p)}function u(d){return new Error(`reference "${d}" resolves to more than one schema`)}}xt.getSchemaRefs=C4});var Tl=j(Ar=>{"use strict";Object.defineProperty(Ar,"__esModule",{value:!0});Ar.getData=Ar.KeywordCxt=Ar.validateFunctionCode=void 0;var Tz=tz(),wz=wl(),Xy=Fy(),Sm=wl(),z4=lz(),xl=mz(),Yy=hz(),q=ne(),J=Zn(),I4=Sl(),Jn=pe(),El=_l();function P4(e){if(zz(e)&&(Iz(e),Cz(e))){j4(e);return}Az(e,()=>(0,Tz.topBoolOrEmptySchema)(e))}Ar.validateFunctionCode=P4;function Az({gen:e,validateName:t,schema:r,schemaEnv:a,opts:n},i){n.code.es5?e.func(t,(0,q._)`${J.default.data}, ${J.default.valCxt}`,a.$async,()=>{e.code((0,q._)`"use strict"; ${Sz(r,n)}`),$4(e,n),e.code(i)}):e.func(t,(0,q._)`${J.default.data}, ${R4(n)}`,a.$async,()=>e.code(Sz(r,n)).code(i))}function R4(e){return(0,q._)`{${J.default.instancePath}="", ${J.default.parentData}, ${J.default.parentDataProperty}, ${J.default.rootData}=${J.default.data}${e.dynamicRef?(0,q._)`, ${J.default.dynamicAnchors}={}`:q.nil}}={}`}function $4(e,t){e.if(J.default.valCxt,()=>{e.var(J.default.instancePath,(0,q._)`${J.default.valCxt}.${J.default.instancePath}`),e.var(J.default.parentData,(0,q._)`${J.default.valCxt}.${J.default.parentData}`),e.var(J.default.parentDataProperty,(0,q._)`${J.default.valCxt}.${J.default.parentDataProperty}`),e.var(J.default.rootData,(0,q._)`${J.default.valCxt}.${J.default.rootData}`),t.dynamicRef&&e.var(J.default.dynamicAnchors,(0,q._)`${J.default.valCxt}.${J.default.dynamicAnchors}`)},()=>{e.var(J.default.instancePath,(0,q._)`""`),e.var(J.default.parentData,(0,q._)`undefined`),e.var(J.default.parentDataProperty,(0,q._)`undefined`),e.var(J.default.rootData,J.default.data),t.dynamicRef&&e.var(J.default.dynamicAnchors,(0,q._)`{}`)})}function j4(e){let{schema:t,opts:r,gen:a}=e;Az(e,()=>{r.$comment&&t.$comment&&Rz(e),L4(e),a.let(J.default.vErrors,null),a.let(J.default.errors,0),r.unevaluated&&O4(e),Pz(e),F4(e)})}function O4(e){let{gen:t,validateName:r}=e;e.evaluated=t.const("evaluated",(0,q._)`${r}.evaluated`),t.if((0,q._)`${e.evaluated}.dynamicProps`,()=>t.assign((0,q._)`${e.evaluated}.props`,(0,q._)`undefined`)),t.if((0,q._)`${e.evaluated}.dynamicItems`,()=>t.assign((0,q._)`${e.evaluated}.items`,(0,q._)`undefined`))}function Sz(e,t){let r=typeof e=="object"&&e[t.schemaId];return r&&(t.code.source||t.code.process)?(0,q._)`/*# sourceURL=${r} */`:q.nil}function N4(e,t){if(zz(e)&&(Iz(e),Cz(e))){D4(e,t);return}(0,Tz.boolOrEmptySchema)(e,t)}function Cz({schema:e,self:t}){if(typeof e=="boolean")return!e;for(let r in e)if(t.RULES.all[r])return!0;return!1}function zz(e){return typeof e.schema!="boolean"}function D4(e,t){let{schema:r,gen:a,opts:n}=e;n.$comment&&r.$comment&&Rz(e),B4(e),U4(e);let i=a.const("_errs",J.default.errors);Pz(e,i),a.var(t,(0,q._)`${i} === ${J.default.errors}`)}function Iz(e){(0,Jn.checkUnknownRules)(e),M4(e)}function Pz(e,t){if(e.opts.jtd)return Ez(e,[],!1,t);let r=(0,wz.getSchemaTypes)(e.schema),a=(0,wz.coerceAndCheckDataType)(e,r);Ez(e,r,!a,t)}function M4(e){let{schema:t,errSchemaPath:r,opts:a,self:n}=e;t.$ref&&a.ignoreKeywordsWithRef&&(0,Jn.schemaHasRulesButRef)(t,n.RULES)&&n.logger.warn(`$ref: keywords ignored in schema at path "${r}"`)}function L4(e){let{schema:t,opts:r}=e;t.default!==void 0&&r.useDefaults&&r.strictSchema&&(0,Jn.checkStrictMode)(e,"default is ignored in the schema root")}function B4(e){let t=e.schema[e.opts.schemaId];t&&(e.baseId=(0,I4.resolveUrl)(e.opts.uriResolver,e.baseId,t))}function U4(e){if(e.schema.$async&&!e.schemaEnv.$async)throw new Error("async schema in sync schema")}function Rz({gen:e,schemaEnv:t,schema:r,errSchemaPath:a,opts:n}){let i=r.$comment;if(n.$comment===!0)e.code((0,q._)`${J.default.self}.logger.log(${i})`);else if(typeof n.$comment=="function"){let o=(0,q.str)`${a}/$comment`,s=e.scopeValue("root",{ref:t.root});e.code((0,q._)`${J.default.self}.opts.$comment(${i}, ${o}, ${s}.schema)`)}}function F4(e){let{gen:t,schemaEnv:r,validateName:a,ValidationError:n,opts:i}=e;r.$async?t.if((0,q._)`${J.default.errors} === 0`,()=>t.return(J.default.data),()=>t.throw((0,q._)`new ${n}(${J.default.vErrors})`)):(t.assign((0,q._)`${a}.errors`,J.default.vErrors),i.unevaluated&&q4(e),t.return((0,q._)`${J.default.errors} === 0`))}function q4({gen:e,evaluated:t,props:r,items:a}){r instanceof q.Name&&e.assign((0,q._)`${t}.props`,r),a instanceof q.Name&&e.assign((0,q._)`${t}.items`,a)}function Ez(e,t,r,a){let{gen:n,schema:i,data:o,allErrors:s,opts:l,self:c}=e,{RULES:u}=c;if(i.$ref&&(l.ignoreKeywordsWithRef||!(0,Jn.schemaHasRulesButRef)(i,u))){n.block(()=>jz(e,"$ref",u.all.$ref.definition));return}l.jtd||H4(e,t),n.block(()=>{for(let m of u.rules)d(m);d(u.post)});function d(m){(0,Xy.shouldUseGroup)(i,m)&&(m.type?(n.if((0,Sm.checkDataType)(m.type,o,l.strictNumbers)),xz(e,m),t.length===1&&t[0]===m.type&&r&&(n.else(),(0,Sm.reportTypeError)(e)),n.endIf()):xz(e,m),s||n.if((0,q._)`${J.default.errors} === ${a||0}`))}}function xz(e,t){let{gen:r,schema:a,opts:{useDefaults:n}}=e;n&&(0,z4.assignDefaults)(e,t.type),r.block(()=>{for(let i of t.rules)(0,Xy.shouldUseRule)(a,i)&&jz(e,i.keyword,i.definition,t.type)})}function H4(e,t){e.schemaEnv.meta||!e.opts.strictTypes||(G4(e,t),e.opts.allowUnionTypes||V4(e,t),W4(e,e.dataTypes))}function G4(e,t){if(t.length){if(!e.dataTypes.length){e.dataTypes=t;return}t.forEach(r=>{$z(e.dataTypes,r)||Qy(e,`type "${r}" not allowed by context "${e.dataTypes.join(",")}"`)}),Z4(e,t)}}function V4(e,t){t.length>1&&!(t.length===2&&t.includes("null"))&&Qy(e,"use allowUnionTypes to allow union type keyword")}function W4(e,t){let r=e.self.RULES.all;for(let a in r){let n=r[a];if(typeof n=="object"&&(0,Xy.shouldUseRule)(e.schema,n)){let{type:i}=n.definition;i.length&&!i.some(o=>K4(t,o))&&Qy(e,`missing type "${i.join(",")}" for keyword "${a}"`)}}}function K4(e,t){return e.includes(t)||t==="number"&&e.includes("integer")}function $z(e,t){return e.includes(t)||t==="integer"&&e.includes("number")}function Z4(e,t){let r=[];for(let a of e.dataTypes)$z(t,a)?r.push(a):t.includes("integer")&&a==="number"&&r.push("integer");e.dataTypes=r}function Qy(e,t){let r=e.schemaEnv.baseId+e.errSchemaPath;t+=` at "${r}" (strictTypes)`,(0,Jn.checkStrictMode)(e,t,e.opts.strictTypes)}var Em=class{constructor(t,r,a){if((0,xl.validateKeywordUsage)(t,r,a),this.gen=t.gen,this.allErrors=t.allErrors,this.keyword=a,this.data=t.data,this.schema=t.schema[a],this.$data=r.$data&&t.opts.$data&&this.schema&&this.schema.$data,this.schemaValue=(0,Jn.schemaRefOrVal)(t,this.schema,a,this.$data),this.schemaType=r.schemaType,this.parentSchema=t.schema,this.params={},this.it=t,this.def=r,this.$data)this.schemaCode=t.gen.const("vSchema",Oz(this.$data,t));else if(this.schemaCode=this.schemaValue,!(0,xl.validSchemaType)(this.schema,r.schemaType,r.allowUndefined))throw new Error(`${a} value must be ${JSON.stringify(r.schemaType)}`);("code"in r?r.trackErrors:r.errors!==!1)&&(this.errsCount=t.gen.const("_errs",J.default.errors))}result(t,r,a){this.failResult((0,q.not)(t),r,a)}failResult(t,r,a){this.gen.if(t),a?a():this.error(),r?(this.gen.else(),r(),this.allErrors&&this.gen.endIf()):this.allErrors?this.gen.endIf():this.gen.else()}pass(t,r){this.failResult((0,q.not)(t),void 0,r)}fail(t){if(t===void 0){this.error(),this.allErrors||this.gen.if(!1);return}this.gen.if(t),this.error(),this.allErrors?this.gen.endIf():this.gen.else()}fail$data(t){if(!this.$data)return this.fail(t);let{schemaCode:r}=this;this.fail((0,q._)`${r} !== undefined && (${(0,q.or)(this.invalid$data(),t)})`)}error(t,r,a){if(r){this.setParams(r),this._error(t,a),this.setParams({});return}this._error(t,a)}_error(t,r){(t?El.reportExtraError:El.reportError)(this,this.def.error,r)}$dataError(){(0,El.reportError)(this,this.def.$dataError||El.keyword$DataError)}reset(){if(this.errsCount===void 0)throw new Error('add "trackErrors" to keyword definition');(0,El.resetErrorsCount)(this.gen,this.errsCount)}ok(t){this.allErrors||this.gen.if(t)}setParams(t,r){r?Object.assign(this.params,t):this.params=t}block$data(t,r,a=q.nil){this.gen.block(()=>{this.check$data(t,a),r()})}check$data(t=q.nil,r=q.nil){if(!this.$data)return;let{gen:a,schemaCode:n,schemaType:i,def:o}=this;a.if((0,q.or)((0,q._)`${n} === undefined`,r)),t!==q.nil&&a.assign(t,!0),(i.length||o.validateSchema)&&(a.elseIf(this.invalid$data()),this.$dataError(),t!==q.nil&&a.assign(t,!1)),a.else()}invalid$data(){let{gen:t,schemaCode:r,schemaType:a,def:n,it:i}=this;return(0,q.or)(o(),s());function o(){if(a.length){if(!(r instanceof q.Name))throw new Error("ajv implementation error");let l=Array.isArray(a)?a:[a];return(0,q._)`${(0,Sm.checkDataTypes)(l,r,i.opts.strictNumbers,Sm.DataType.Wrong)}`}return q.nil}function s(){if(n.validateSchema){let l=t.scopeValue("validate$data",{ref:n.validateSchema});return(0,q._)`!${l}(${r})`}return q.nil}}subschema(t,r){let a=(0,Yy.getSubschema)(this.it,t);(0,Yy.extendSubschemaData)(a,this.it,t),(0,Yy.extendSubschemaMode)(a,t);let n={...this.it,...a,items:void 0,props:void 0};return N4(n,r),n}mergeEvaluated(t,r){let{it:a,gen:n}=this;a.opts.unevaluated&&(a.props!==!0&&t.props!==void 0&&(a.props=Jn.mergeEvaluated.props(n,t.props,a.props,r)),a.items!==!0&&t.items!==void 0&&(a.items=Jn.mergeEvaluated.items(n,t.items,a.items,r)))}mergeValidEvaluated(t,r){let{it:a,gen:n}=this;if(a.opts.unevaluated&&(a.props!==!0||a.items!==!0))return n.if(r,()=>this.mergeEvaluated(t,q.Name)),!0}};Ar.KeywordCxt=Em;function jz(e,t,r,a){let n=new Em(e,r,t);"code"in r?r.code(n,a):n.$data&&r.validate?(0,xl.funcKeywordCode)(n,r):"macro"in r?(0,xl.macroKeywordCode)(n,r):(r.compile||r.validate)&&(0,xl.funcKeywordCode)(n,r)}var J4=/^\/(?:[^~]|~0|~1)*$/,Y4=/^([0-9]+)(#|\/(?:[^~]|~0|~1)*)?$/;function Oz(e,{dataLevel:t,dataNames:r,dataPathArr:a}){let n,i;if(e==="")return J.default.rootData;if(e[0]==="/"){if(!J4.test(e))throw new Error(`Invalid JSON-pointer: ${e}`);n=e,i=J.default.rootData}else{let c=Y4.exec(e);if(!c)throw new Error(`Invalid JSON-pointer: ${e}`);let u=+c[1];if(n=c[2],n==="#"){if(u>=t)throw new Error(l("property/index",u));return a[t-u]}if(u>t)throw new Error(l("data",u));if(i=r[t-u],!n)return i}let o=i,s=n.split("/");for(let c of s)c&&(i=(0,q._)`${i}${(0,q.getProperty)((0,Jn.unescapeJsonPointer)(c))}`,o=(0,q._)`${o} && ${i}`);return o;function l(c,u){return`Cannot access ${c} ${u} levels up, current level is ${t}`}}Ar.getData=Oz});var xm=j(tk=>{"use strict";Object.defineProperty(tk,"__esModule",{value:!0});var ek=class extends Error{constructor(t){super("validation failed"),this.errors=t,this.ajv=this.validation=!0}};tk.default=ek});var Al=j(ak=>{"use strict";Object.defineProperty(ak,"__esModule",{value:!0});var nk=Sl(),rk=class extends Error{constructor(t,r,a,n){super(n||`can't resolve reference ${a} from id ${r}`),this.missingRef=(0,nk.resolveUrl)(t,r,a),this.missingSchema=(0,nk.normalizeId)((0,nk.getFullPath)(t,this.missingRef))}};ak.default=rk});var Am=j(Ht=>{"use strict";Object.defineProperty(Ht,"__esModule",{value:!0});Ht.resolveSchema=Ht.getCompilingSchema=Ht.resolveRef=Ht.compileSchema=Ht.SchemaEnv=void 0;var tn=ne(),X4=xm(),da=Zn(),nn=Sl(),Nz=pe(),Q4=Tl(),eo=class{constructor(t){var r;this.refs={},this.dynamicAnchors={};let a;typeof t.schema=="object"&&(a=t.schema),this.schema=t.schema,this.schemaId=t.schemaId,this.root=t.root||this,this.baseId=(r=t.baseId)!==null&&r!==void 0?r:(0,nn.normalizeId)(a?.[t.schemaId||"$id"]),this.schemaPath=t.schemaPath,this.localRefs=t.localRefs,this.meta=t.meta,this.$async=a?.$async,this.refs={}}};Ht.SchemaEnv=eo;function ok(e){let t=Dz.call(this,e);if(t)return t;let r=(0,nn.getFullPath)(this.opts.uriResolver,e.root.baseId),{es5:a,lines:n}=this.opts.code,{ownProperties:i}=this.opts,o=new tn.CodeGen(this.scope,{es5:a,lines:n,ownProperties:i}),s;e.$async&&(s=o.scopeValue("Error",{ref:X4.default,code:(0,tn._)`require("ajv/dist/runtime/validation_error").default`}));let l=o.scopeName("validate");e.validateName=l;let c={gen:o,allErrors:this.opts.allErrors,data:da.default.data,parentData:da.default.parentData,parentDataProperty:da.default.parentDataProperty,dataNames:[da.default.data],dataPathArr:[tn.nil],dataLevel:0,dataTypes:[],definedProperties:new Set,topSchemaRef:o.scopeValue("schema",this.opts.code.source===!0?{ref:e.schema,code:(0,tn.stringify)(e.schema)}:{ref:e.schema}),validateName:l,ValidationError:s,schema:e.schema,schemaEnv:e,rootId:r,baseId:e.baseId||r,schemaPath:tn.nil,errSchemaPath:e.schemaPath||(this.opts.jtd?"":"#"),errorPath:(0,tn._)`""`,opts:this.opts,self:this},u;try{this._compilations.add(e),(0,Q4.validateFunctionCode)(c),o.optimize(this.opts.code.optimize);let d=o.toString();u=`${o.scopeRefs(da.default.scope)}return ${d}`,this.opts.code.process&&(u=this.opts.code.process(u,e));let p=new Function(`${da.default.self}`,`${da.default.scope}`,u)(this,this.scope.get());if(this.scope.value(l,{ref:p}),p.errors=null,p.schema=e.schema,p.schemaEnv=e,e.$async&&(p.$async=!0),this.opts.code.source===!0&&(p.source={validateName:l,validateCode:d,scopeValues:o._values}),this.opts.unevaluated){let{props:g,items:h}=c;p.evaluated={props:g instanceof tn.Name?void 0:g,items:h instanceof tn.Name?void 0:h,dynamicProps:g instanceof tn.Name,dynamicItems:h instanceof tn.Name},p.source&&(p.source.evaluated=(0,tn.stringify)(p.evaluated))}return e.validate=p,e}catch(d){throw delete e.validate,delete e.validateName,u&&this.logger.error("Error compiling schema, function code:",u),d}finally{this._compilations.delete(e)}}Ht.compileSchema=ok;function eB(e,t,r){var a;r=(0,nn.resolveUrl)(this.opts.uriResolver,t,r);let n=e.refs[r];if(n)return n;let i=rB.call(this,e,r);if(i===void 0){let o=(a=e.localRefs)===null||a===void 0?void 0:a[r],{schemaId:s}=this.opts;o&&(i=new eo({schema:o,schemaId:s,root:e,baseId:t}))}if(i!==void 0)return e.refs[r]=tB.call(this,i)}Ht.resolveRef=eB;function tB(e){return(0,nn.inlineRef)(e.schema,this.opts.inlineRefs)?e.schema:e.validate?e:ok.call(this,e)}function Dz(e){for(let t of this._compilations)if(nB(t,e))return t}Ht.getCompilingSchema=Dz;function nB(e,t){return e.schema===t.schema&&e.root===t.root&&e.baseId===t.baseId}function rB(e,t){let r;for(;typeof(r=this.refs[t])=="string";)t=r;return r||this.schemas[t]||Tm.call(this,e,t)}function Tm(e,t){let r=this.opts.uriResolver.parse(t),a=(0,nn._getFullPath)(this.opts.uriResolver,r),n=(0,nn.getFullPath)(this.opts.uriResolver,e.baseId,void 0);if(Object.keys(e.schema).length>0&&a===n)return ik.call(this,r,e);let i=(0,nn.normalizeId)(a),o=this.refs[i]||this.schemas[i];if(typeof o=="string"){let s=Tm.call(this,e,o);return typeof s?.schema!="object"?void 0:ik.call(this,r,s)}if(typeof o?.schema=="object"){if(o.validate||ok.call(this,o),i===(0,nn.normalizeId)(t)){let{schema:s}=o,{schemaId:l}=this.opts,c=s[l];return c&&(n=(0,nn.resolveUrl)(this.opts.uriResolver,n,c)),new eo({schema:s,schemaId:l,root:e,baseId:n})}return ik.call(this,r,o)}}Ht.resolveSchema=Tm;var aB=new Set(["properties","patternProperties","enum","dependencies","definitions"]);function ik(e,{baseId:t,schema:r,root:a}){var n;if(((n=e.fragment)===null||n===void 0?void 0:n[0])!=="/")return;for(let s of e.fragment.slice(1).split("/")){if(typeof r=="boolean")return;let l=r[(0,Nz.unescapeFragment)(s)];if(l===void 0)return;r=l;let c=typeof r=="object"&&r[this.opts.schemaId];!aB.has(s)&&c&&(t=(0,nn.resolveUrl)(this.opts.uriResolver,t,c))}let i;if(typeof r!="boolean"&&r.$ref&&!(0,Nz.schemaHasRulesButRef)(r,this.RULES)){let s=(0,nn.resolveUrl)(this.opts.uriResolver,t,r.$ref);i=Tm.call(this,a,s)}let{schemaId:o}=this.opts;if(i=i||new eo({schema:r,schemaId:o,root:a,baseId:t}),i.schema!==i.root.schema)return i}});var Mz=j((_Y,iB)=>{iB.exports={$id:"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#",description:"Meta-schema for $data reference (JSON AnySchema extension proposal)",type:"object",required:["$data"],properties:{$data:{type:"string",anyOf:[{format:"relative-json-pointer"},{format:"json-pointer"}]}},additionalProperties:!1}});var pk=j((wY,Gz)=>{"use strict";var oB=RegExp.prototype.test.bind(/^[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}$/iu),lk=RegExp.prototype.test.bind(/^(?:(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)$/u),sB=RegExp.prototype.test.bind(/^\d*$/u),pa=RegExp.prototype.test.bind(/^[\da-f]{2}$/iu),ck=RegExp.prototype.test.bind(/^[\da-z\-._~]$/iu),Bz=RegExp.prototype.test.bind(/^[A-Za-z0-9\-._~!$&'()*+,;=:@/]$/u),uk=RegExp.prototype.test.bind(/^[A-Za-z0-9\-._~!$&'()*+,;=:@/?]$/u),lB=RegExp.prototype.test.bind(/^[A-Za-z0-9\-._~!$&'()*+,;=:]$/u),Tt=new Array(256);{let e="0123456789ABCDEF";for(let t=0;t<256;t++)Tt[t]="%"+e[t>>4]+e[t&15]}function st(e){return e<2048?Tt[192|e>>6]+Tt[128|e&63]:e<65536?Tt[224|e>>12]+Tt[128|e>>6&63]+Tt[128|e&63]:Tt[240|e>>18]+Tt[128|e>>12&63]+Tt[128|e>>6&63]+Tt[128|e&63]}function cB(e){let t="",r=0,a=0;for(a=0;a<e.length;a++)if(r=e[a].charCodeAt(0),r!==48){if(!(r>=48&&r<=57||r>=65&&r<=70||r>=97&&r<=102))return"";t+=e[a];break}for(a+=1;a<e.length;a++){if(r=e[a].charCodeAt(0),!(r>=48&&r<=57||r>=65&&r<=70||r>=97&&r<=102))return"";t+=e[a]}return t}var uB=RegExp.prototype.test.bind(/^[\dA-Fa-f]{1,4}$/),dB=RegExp.prototype.test.bind(/^[vV][\dA-Fa-f]+\.[A-Za-z\d\-._~!$&'()*+,;=:]+$/),pB=RegExp.prototype.test.bind(/^[A-Za-z\d\-._~]$/),mB=RegExp.prototype.test.bind(/[^!"$&'()*+,\-.;=_`a-z{}~]/u);function gB(e){if(e.length===0)return!1;for(let t=0;t<e.length;t++)if(!pB(e[t])){if(e[t]==="%"&&t+2<e.length&&pa(e.slice(t+1,t+3))){t+=2;continue}return!1}return!0}function Lz(e){let t=-1,r=0,a=-1,n=0;for(let s=0;s<e.length;s++)e[s]==="0"?(a===-1&&(a=s),n++,n>r&&(r=n,t=a)):(a=-1,n=0);if(r<2)return e.join(":");let i=e.slice(0,t).join(":"),o=e.slice(t+r).join(":");return i+"::"+o}function hB(e){let t=e.indexOf("::");if(t!==-1&&e.indexOf("::",t+1)!==-1)return;let r=t===-1?e.split(":"):e.slice(0,t).split(":"),a=t===-1?[]:e.slice(t+2).split(":");t!==-1&&(r.length===1&&r[0]===""&&(r.length=0),a.length===1&&a[0]===""&&(a.length=0));let n=r.concat(a),i=0;for(let s=0;s<n.length;s++){let l=n[s];if(l==="")return;if(l.indexOf(".")!==-1){if(s!==n.length-1||t!==-1&&a.length===0||!lk(l))return;i+=2;continue}if(!uB(l))return;n[s]=parseInt(l,16).toString(16),i++}if(t===-1)return i!==8?void 0:Lz(n);if(i>=8)return;let o=n.slice(0,r.length);for(let s=i;s<8;s++)o.push("0");for(let s=r.length;s<n.length;s++)o.push(n[s]);return Lz(o)}function sk(e){let t=e[0]==="["&&e[e.length-1]==="]";if((e[0]==="["||e[e.length-1]==="]")&&!t)return{host:e,isIPV6:!1,error:!0};let a=t?e.slice(1,-1):e;if(t&&dB(a))return a=a.toLowerCase(),{host:`[${a}]`,escapedHost:a,isIPV6:!1,isIPVFuture:!0};if(fB(a,":")<2)return{host:e,isIPV6:!1,error:t};let n="",i=a.indexOf("%");if(i!==-1){let s=a.slice(i,i+3).toLowerCase()==="%25"?3:1;if(n=a.slice(i+s),!gB(n))return{host:e,isIPV6:!1,error:!0};a=a.slice(0,i)}let o=hB(a);return o===void 0?{host:e,isIPV6:!1,error:!0}:{host:o+(n?"%"+n:""),escapedHost:o+(n?"%25"+n:""),isIPV6:!0}}function fB(e,t){let r=0;for(let a=0;a<e.length;a++)e[a]===t&&r++;return r}function bB(e){let t=e,r=[],a=-1,n=0;for(;n=t.length;){if(n===1){if(t===".")break;if(t==="/"){r.push("/");break}else{r.push(t);break}}else if(n===2){if(t[0]==="."){if(t[1]===".")break;if(t[1]==="/"){t=t.slice(2);continue}}else if(t[0]==="/"&&(t[1]==="."||t[1]==="/")){r.push("/");break}}else if(n===3&&t==="/.."){r.length!==0&&r.pop(),r.push("/");break}if(t[0]==="."){if(t[1]==="."){if(t[2]==="/"){t=t.slice(3);continue}}else if(t[1]==="/"){t=t.slice(2);continue}}else if(t[0]==="/"&&t[1]==="."){if(t[2]==="/"){t=t.slice(2);continue}else if(t[2]==="."&&t[3]==="/"){t=t.slice(3),r.length!==0&&r.pop();continue}}if((a=t.indexOf("/",1))===-1){r.push(t);break}else r.push(t.slice(0,a)),t=t.slice(a)}return r.join("")}var vB={"@":"%40","/":"%2F","?":"%3F","#":"%23",":":"%3A"},yB=/[@/?#:]/g,kB=/[@/?#]/g;function Uz(e,t){let r=t?kB:yB;return r.lastIndex=0,e.replace(r,a=>vB[a])}function Fz(e,t=!1){if(e.indexOf("%")===-1)return e;let r="";for(let a=0;a<e.length;a++){if(e[a]==="%"&&a+2<e.length){let n=e.slice(a+1,a+3);if(pa(n)){let i=n.toUpperCase(),o=String.fromCharCode(parseInt(i,16));t&&ck(o)?r+=o:r+="%"+i,a+=2;continue}}r+=e[a]}return r}function _B(e){let t="";for(let r=0;r<e.length;r++){let a=e[r];if(a==="%"&&r+2<e.length){let n=e.slice(r+1,r+3);if(pa(n)){let i=n.toUpperCase(),o=String.fromCharCode(parseInt(i,16));o!=="."&&ck(o)?t+=o:t+="%"+i,r+=2;continue}}if(Bz(a))t+=a;else{let n=e.charCodeAt(r);if(n<128)t+=Hz(n)?a:Tt[n];else if(n<55296||n>57343)t+=st(n);else if(n<=56319&&r+1<e.length){let i=e.charCodeAt(r+1);i>=56320&&i<=57343?(t+=st(65536+(n-55296<<10)+(i-56320)),r++):t+=st(65533)}else t+=st(65533)}}return t}function wB(e,t=!1){let r="",a=t&&e[0]!=="/";for(let n=0;n<e.length;n++){let i=e[n];if(i==="%"&&n+2<e.length){let o=e.slice(n+1,n+3);if(pa(o)){r+="%"+o.toUpperCase(),n+=2;continue}}if(i==="/"&&(a=!1),Bz(i)&&(i!==":"||!a))r+=i;else{let o=e.charCodeAt(n);if(o<128)r+=Tt[o];else if(o<55296||o>57343)r+=st(o);else if(o<=56319&&n+1<e.length){let s=e.charCodeAt(n+1);s>=56320&&s<=57343?(r+=st(65536+(o-55296<<10)+(s-56320)),n++):r+=st(65533)}else r+=st(65533)}}return r}function dk(e,t){let r="";for(let a=0;a<e.length;a++){let n=e[a];if(n==="%"&&a+2<e.length){let i=e.slice(a+1,a+3);if(pa(i)){r+="%"+i.toUpperCase(),a+=2;continue}}if(t(n))r+=n;else{let i=e.charCodeAt(a);if(i<128)r+=Tt[i];else if(i<55296||i>57343)r+=st(i);else if(i<=56319&&a+1<e.length){let o=e.charCodeAt(a+1);o>=56320&&o<=57343?(r+=st(65536+(i-55296<<10)+(o-56320)),a++):r+=st(65533)}else r+=st(65533)}}return r}function qz(e){return dk(e,lB)}function SB(e){return dk(e,uk)}function EB(e){return dk(e,uk)}function Hz(e){return e>=48&&e<=57||e>=65&&e<=90||e>=97&&e<=122||e===42||e===43||e===45||e===46||e===47||e===64||e===95}function xB(e){let t="";for(let r=0;r<e.length;r++){let a=e[r];if(a==="%"&&r+2<e.length){let n=e.slice(r+1,r+3);if(pa(n)){let i=n.toUpperCase(),o=String.fromCharCode(parseInt(i,16));ck(o)?t+=o:t+="%"+i,r+=2;continue}}if(uk(a))t+=a;else{let n=e.charCodeAt(r);if(n<128)t+=Hz(n)?a:Tt[n];else if(n<55296||n>57343)t+=st(n);else if(n<=56319&&r+1<e.length){let i=e.charCodeAt(r+1);i>=56320&&i<=57343?(t+=st(65536+(n-55296<<10)+(i-56320)),r++):t+=st(65533)}else t+=st(65533)}}return t}function TB(e){let t="";for(let r=0;r<e.length;r++){if(e[r]==="%"&&r+2<e.length){let a=e.slice(r+1,r+3);if(pa(a)){t+="%"+a.toUpperCase(),r+=2;continue}}t+=escape(e[r])}return t}function AB(e){let t=[];if(e.userinfo!==void 0&&(t.push(qz(e.userinfo)),t.push("@")),e.host!==void 0){let r=e.host;if(!lk(r)){let a=sk(r);a.isIPV6!==!0&&a.isIPVFuture!==!0&&(r=Fz(r,!0),a=sk(r)),a.isIPV6===!0||a.isIPVFuture===!0?r=`[${a.escapedHost}]`:r=Uz(r,!1)}t.push(r)}if(typeof e.port=="number"||typeof e.port=="string"){let r=String(e.port);if(!sB(r))throw new TypeError("URI port is malformed.");t.push(":"),t.push(r)}return t.length?t.join(""):void 0}Gz.exports={nonSimpleDomain:mB,recomposeAuthority:AB,reescapeHostDelimiters:Uz,normalizePercentEncoding:Fz,normalizePathEncoding:_B,serializePathEncoding:wB,normalizeQueryFragmentEncoding:xB,encodeUserinfo:qz,encodeQuery:SB,encodeFragment:EB,escapePreservingEscapes:TB,removeDotSegments:bB,isIPv4:lk,isUUID:oB,normalizeIPv6:sk,stringArrayToHexStripped:cB}});var Jz=j((SY,Zz)=>{"use strict";var{isUUID:CB}=pk(),zB=/^([\da-z][\d\-a-z]{0,31}):((?:[\w!$'()*+,\-./:;=@]|%[\da-f]{2})+)$/iu,IB=["http","https","ws","wss","urn","urn:uuid"];function PB(e){return IB.indexOf(e)!==-1}function mk(e){return e.secure===!0?!0:e.secure===!1?!1:e.scheme?e.scheme.length===3&&(e.scheme[0]==="w"||e.scheme[0]==="W")&&(e.scheme[1]==="s"||e.scheme[1]==="S")&&(e.scheme[2]==="s"||e.scheme[2]==="S"):!1}function Vz(e){return e.host||(e.error=e.error||"HTTP URIs must have a host."),e}function Wz(e){let t=String(e.scheme).toLowerCase()==="https";return(e.port===(t?443:80)||e.port==="")&&(e.port=void 0),e.path||(e.path="/"),e}function RB(e){return e.secure=mk(e),e.resourceName=(e.path||"/")+(e.query?"?"+e.query:""),e.path=void 0,e.query=void 0,e}function $B(e){if((e.port===(mk(e)?443:80)||e.port==="")&&(e.port=void 0),typeof e.secure=="boolean"&&(e.scheme=e.secure?"wss":"ws",e.secure=void 0),e.resourceName){let t=e.resourceName.indexOf("?"),r=t===-1?e.resourceName:e.resourceName.slice(0,t);e.path=r&&r!=="/"?r:void 0,e.query=t===-1?void 0:e.resourceName.slice(t+1),e.resourceName=void 0}return e.fragment=void 0,e}function jB(e,t){if(!e.path)return e.error="URN can not be parsed",e;let r=e.path.match(zB);if(r&&r[0]===e.path){let a=t.scheme||e.scheme||"urn";e.nid=r[1].toLowerCase(),e.nss=r[2];let n=`${a}:${t.nid||e.nid}`,i=gk(n);e.path=void 0,i&&(e=i.parse(e,t))}else e.error=e.error||"URN can not be parsed.";return e}function OB(e,t){if(e.nid===void 0)throw new Error("URN without nid cannot be serialized");let r=t.scheme||e.scheme||"urn",a=e.nid.toLowerCase(),n=`${r}:${t.nid||a}`,i=gk(n);i&&(e=i.serialize(e,t));let o=e,s=e.nss;return o.path=`${a||t.nid}:${s}`,t.skipEscape=!0,o}function NB(e,t){let r=e;return r.uuid=r.nss,r.nss=void 0,!t.tolerant&&(!r.uuid||!CB(r.uuid))&&(r.error=r.error||"UUID is not valid."),r}function DB(e){let t=e;return t.nss=(e.uuid||"").toLowerCase(),t}var Kz={scheme:"http",domainHost:!0,parse:Vz,serialize:Wz},MB={scheme:"https",domainHost:Kz.domainHost,parse:Vz,serialize:Wz},Cm={scheme:"ws",domainHost:!0,parse:RB,serialize:$B},LB={scheme:"wss",domainHost:Cm.domainHost,parse:Cm.parse,serialize:Cm.serialize},BB={scheme:"urn",parse:jB,serialize:OB,skipNormalize:!0},UB={scheme:"urn:uuid",parse:NB,serialize:DB,skipNormalize:!0},zm={http:Kz,https:MB,ws:Cm,wss:LB,urn:BB,"urn:uuid":UB};Object.setPrototypeOf(zm,null);function gk(e){return e&&(zm[e]||zm[e.toLowerCase()])||void 0}Zz.exports={wsIsSecure:mk,SCHEMES:zm,isValidSchemeName:PB,getSchemeHandler:gk}});var cI=j((EY,Rm)=>{"use strict";var{normalizeIPv6:tI,removeDotSegments:zl,recomposeAuthority:FB,normalizePercentEncoding:hk,normalizePathEncoding:qB,serializePathEncoding:Yz,normalizeQueryFragmentEncoding:Xz,encodeQuery:HB,encodeFragment:GB,reescapeHostDelimiters:VB,isIPv4:nI,nonSimpleDomain:WB}=pk(),{SCHEMES:rI,getSchemeHandler:fk}=Jz(),aI=/^[A-Za-z][A-Za-z0-9+.-]*$/u,iI="URI scheme is malformed.";function Qz(e){let t=unescape(String(e));if(!aI.test(t))throw new TypeError(iI);return t}function KB(e,t){return typeof e=="string"?e=n3(e,t):typeof e=="object"&&(e=Pm(ma(e,t),t)),e}function ZB(e,t,r){let a=r?Object.assign({scheme:"null"},r):{scheme:"null"},{parsed:n,malformedAuthorityOrPort:i,malformedPercentEncoding:o,malformedSchemeSpecific:s,malformedHost:l,malformedScheme:c}=Im(e,a),{parsed:u,malformedAuthorityOrPort:d,malformedPercentEncoding:m,malformedSchemeSpecific:p,malformedHost:g,malformedScheme:h}=Im(t,a);if(i||d||o||m||s||p||l||g||c||h)throw new Error(n.error||u.error||"URI is malformed.");let f=oI(n,u,a,!0),_=fk(r&&r.scheme||f.scheme),b=f.host,v=b!==void 0&&b!==""&&(nI(b)||tI(b).isIPV6);sI(f,r||{},_,v);let C=b&&b.indexOf("%")!==-1&&!new RegExp("\\P{ASCII}","u").test(b);if(f.error&&!C)throw new Error(f.error);return a.skipEscape=!0,ma(f,a)}function oI(e,t,r,a){let n={};return a||(e=Pm(ma(e,r),r),t=Pm(ma(t,r),r)),r=r||{},!r.tolerant&&t.scheme?(n.scheme=t.scheme,n.userinfo=t.userinfo,n.host=t.host,n.port=t.port,n.path=zl(t.path||""),n.query=t.query):(t.userinfo!==void 0||t.host!==void 0||t.port!==void 0?(n.userinfo=t.userinfo,n.host=t.host,n.port=t.port,n.path=zl(t.path||""),n.query=t.query):(t.path?(t.path[0]==="/"?n.path=zl(t.path):((e.userinfo!==void 0||e.host!==void 0||e.port!==void 0)&&!e.path?n.path="/"+t.path:e.path?n.path=e.path.slice(0,e.path.lastIndexOf("/")+1)+t.path:n.path=t.path,n.path=zl(n.path)),n.query=t.query):(n.path=e.path,t.query!==void 0?n.query=t.query:n.query=e.query),n.userinfo=e.userinfo,n.host=e.host,n.port=e.port),n.scheme=e.scheme),n.fragment=t.fragment,n}function JB(e,t,r){let a=eI(e,r),n=eI(t,r);return a!==void 0&&n!==void 0&&a===n}function ma(e,t){let r={host:e.host,scheme:e.scheme,userinfo:e.userinfo,port:e.port,path:e.path,query:e.query,nid:e.nid,nss:e.nss,uuid:e.uuid,fragment:e.fragment,reference:e.reference,resourceName:e.resourceName,secure:e.secure,error:""},a=Object.assign({},t),n=[];r.scheme&&(r.scheme=Qz(r.scheme));let i=fk(a.scheme||r.scheme);i&&i.serialize&&i.serialize(r,a);let o=r.userinfo!==void 0||r.host!==void 0||r.port!==void 0,s=!a.skipEscape&&r.scheme===void 0&&!o;r.path!==void 0&&(a.skipEscape?r.path=hk(r.path):r.path=Yz(r.path,s)),a.reference!=="suffix"&&r.scheme&&(r.scheme=Qz(r.scheme),n.push(r.scheme,":"));let l=FB(r);if(l!==void 0&&(a.reference!=="suffix"&&n.push("//"),n.push(l),r.path&&r.path[0]!=="/"&&n.push("/")),r.path!==void 0){let c=r.path;!a.absolutePath&&(!i||!i.absolutePath)&&(c=zl(c)),s&&(c=Yz(c,!0)),l===void 0&&c[0]==="/"&&c[1]==="/"&&(c="/%2F"+c.slice(2)),n.push(c)}return r.query!==void 0&&n.push("?",HB(r.query)),r.fragment!==void 0&&n.push("#",GB(r.fragment)),n.join("")}var YB=/^(?:([^#/:?]+):)?(?:\/\/((?:([^#/?@]*)@)?(\[[^#/?\]]+\]|[^#/:?]*)(?::(\d*))?))?([^#?]*)(?:\?([^#]*))?(?:#((?:.|[\n\r])*))?/u,XB=/^(?:[^#/:?]+:)?\/\/([^/?#]*)/,QB=/^(?:[^#/:?]+:)?([/\\\t\n\r]*)/;function e3(e,t){if(t[2]!==void 0&&e.path&&e.path[0]!=="/")return'URI path must start with "/" when authority is present.';if(typeof e.port=="number"&&(e.port<0||e.port>65535))return"URI port is malformed."}function Cl(e){if(e===void 0)return!1;let t=e.indexOf("%");for(;t!==-1;){if(t+2>=e.length||!/^[\da-f]{2}$/iu.test(e.slice(t+1,t+3)))return!0;t=e.indexOf("%",t+3)}return!1}function bk(e){return e[0]==="["&&e[e.length-1]==="]"}function t3(e){let t=e[4];return Cl(e[3])||t!==void 0&&!bk(t)&&Cl(t)||Cl(e[6])||Cl(e[7])||Cl(e[8])}function sI(e,t,r,a){if(!t.unicodeSupport&&(!r||!r.unicodeSupport)&&e.host&&!bk(e.host)&&(t.domainHost||r&&r.domainHost)&&a===!1&&WB(e.host))try{e.host=new URL("http://"+e.host).hostname}catch(n){return e.error=e.error||"Host's domain name can not be converted to ASCII: "+n,!0}return!1}function Im(e,t){let r=Object.assign({},t),a={scheme:void 0,userinfo:void 0,host:"",port:void 0,path:"",query:void 0,fragment:void 0},n=!1,i=!1,o=!1,s=!1,l=!1,c=!1,u=!1;r.reference==="suffix"&&(r.scheme?e=r.scheme+":"+e:e="//"+e);let d=e.match(XB);d!==null&&d[1].indexOf("\\")!==-1&&(a.error="URI authority must not contain a literal backslash.",n=!0);let m=e.match(QB);if(m!==null){let g=m[1],h=g.replace(/[\t\n\r]/g,"");h.length>=2&&(h.slice(0,2)!=="//"?(a.error=a.error||"URI authority must not contain a literal backslash.",n=!0):g.length!==h.length&&(a.error=a.error||"URI authority introducer must not contain whitespace.",n=!0))}let p=e.match(YB);if(p){if(a.scheme=p[1],a.userinfo=p[3],a.host=p[4],a.port=parseInt(p[5],10),a.path=p[6]||"",a.query=p[7],a.fragment=p[8],a.scheme!==void 0){let f=unescape(a.scheme);aI.test(f)?a.scheme=f.toLowerCase():(a.error=a.error||iI,c=!0)}i=t3(p),i&&(a.error=a.error||"URI contains malformed percent-encoding."),isNaN(a.port)&&(a.port=p[5]);let g=e3(a,p);if(g!==void 0&&(a.error=a.error||g,n=!0),a.host)if(nI(a.host)===!1){let _=bk(a.host),b=a.host.indexOf("[")!==-1||a.host.indexOf("]")!==-1,v=tI(a.host);u=v.isIPV6||v.isIPVFuture===!0,l=b&&(!_||v.error===!0),a.host=u?v.host:v.host.toLowerCase(),l&&(a.error=a.error||"URI host is malformed.",n=!0)}else u=!0;a.scheme===void 0&&a.userinfo===void 0&&a.host===void 0&&a.port===void 0&&a.query===void 0&&!a.path?a.reference="same-document":a.scheme===void 0?a.reference="relative":a.fragment===void 0?a.reference="absolute":a.reference="uri",r.reference&&r.reference!=="suffix"&&r.reference!==a.reference&&(a.error=a.error||"URI is not a "+r.reference+" reference.");let h=fk(r.scheme||a.scheme);if(l||(s=sI(a,r,h,u)),e.indexOf("%")!==-1&&a.host!==void 0&&!l){let f=u?a.host:hk(a.host,!0);u||(f=hk(f.toLowerCase())),a.host=VB(f,u)}(!h||h&&!h.skipNormalize)&&(a.path&&(a.path=qB(a.path)),a.query&&(a.query=Xz(a.query)),a.fragment&&(a.fragment=Xz(a.fragment))),h&&h.parse&&(h.parse(a,r),h===rI.urn&&a.nid===void 0&&(o=!0))}else a.error=a.error||"URI can not be parsed.";return{parsed:a,malformedAuthorityOrPort:n,malformedPercentEncoding:i,malformedSchemeSpecific:o,malformedHost:s,malformedScheme:c}}function Pm(e,t){return Im(e,t).parsed}function n3(e,t){return lI(e,t).normalized}function lI(e,t){let{parsed:r,malformedAuthorityOrPort:a,malformedPercentEncoding:n,malformedSchemeSpecific:i,malformedHost:o,malformedScheme:s}=Im(e,t);return{normalized:a||n||i||o||s?e:ma(r,t),malformedAuthorityOrPort:a,malformedPercentEncoding:n,malformedSchemeSpecific:i,malformedHost:o,malformedScheme:s}}function eI(e,t){if(typeof e!="string"&&typeof e!="object")return;let r;try{r=typeof e=="string"?e:ma(e,t)}catch{return}let{normalized:a,malformedAuthorityOrPort:n,malformedPercentEncoding:i,malformedSchemeSpecific:o,malformedHost:s,malformedScheme:l}=lI(r,t);return n||i||o||s||l?void 0:a}var vk={SCHEMES:rI,normalize:KB,resolve:ZB,resolveComponent:oI,equal:JB,serialize:ma,parse:Pm};Rm.exports=vk;Rm.exports.default=vk;Rm.exports.fastUri=vk});var dI=j(yk=>{"use strict";Object.defineProperty(yk,"__esModule",{value:!0});var uI=cI();uI.code='require("ajv/dist/runtime/uri").default';yk.default=uI});var yI=j(Xe=>{"use strict";Object.defineProperty(Xe,"__esModule",{value:!0});Xe.CodeGen=Xe.Name=Xe.nil=Xe.stringify=Xe.str=Xe._=Xe.KeywordCxt=void 0;var r3=Tl();Object.defineProperty(Xe,"KeywordCxt",{enumerable:!0,get:function(){return r3.KeywordCxt}});var to=ne();Object.defineProperty(Xe,"_",{enumerable:!0,get:function(){return to._}});Object.defineProperty(Xe,"str",{enumerable:!0,get:function(){return to.str}});Object.defineProperty(Xe,"stringify",{enumerable:!0,get:function(){return to.stringify}});Object.defineProperty(Xe,"nil",{enumerable:!0,get:function(){return to.nil}});Object.defineProperty(Xe,"Name",{enumerable:!0,get:function(){return to.Name}});Object.defineProperty(Xe,"CodeGen",{enumerable:!0,get:function(){return to.CodeGen}});var a3=xm(),fI=Al(),i3=Uy(),Il=Am(),o3=ne(),Pl=Sl(),$m=wl(),_k=pe(),pI=Mz(),s3=dI(),bI=(e,t)=>new RegExp(e,t);bI.code="new RegExp";var l3=["removeAdditional","useDefaults","coerceTypes"],c3=new Set(["validate","serialize","parse","wrapper","root","schema","keyword","pattern","formats","validate$data","func","obj","Error"]),u3={errorDataPath:"",format:"`validateFormats: false` can be used instead.",nullable:'"nullable" keyword is supported by default.',jsonPointers:"Deprecated jsPropertySyntax can be used instead.",extendRefs:"Deprecated ignoreKeywordsWithRef can be used instead.",missingRefs:"Pass empty schema with $id that should be ignored to ajv.addSchema.",processCode:"Use option `code: {process: (code, schemaEnv: object) => string}`",sourceCode:"Use option `code: {source: true}`",strictDefaults:"It is default now, see option `strict`.",strictKeywords:"It is default now, see option `strict`.",uniqueItems:'"uniqueItems" keyword is always validated.',unknownFormats:"Disable strict mode or pass `true` to `ajv.addFormat` (or `formats` option).",cache:"Map is used as cache, schema object as key.",serialize:"Map is used as cache, schema object as key.",ajvErrors:"It is default now."},d3={ignoreKeywordsWithRef:"",jsPropertySyntax:"",unicode:'"minLength"/"maxLength" account for unicode characters by default.'},mI=200;function p3(e){var t,r,a,n,i,o,s,l,c,u,d,m,p,g,h,f,_,b,v,C,S,P,U,qe,D;let re=e.strict,Ie=(t=e.code)===null||t===void 0?void 0:t.optimize,et=Ie===!0||Ie===void 0?1:Ie||0,Le=(a=(r=e.code)===null||r===void 0?void 0:r.regExp)!==null&&a!==void 0?a:bI,on=(n=e.uriResolver)!==null&&n!==void 0?n:s3.default;return{strictSchema:(o=(i=e.strictSchema)!==null&&i!==void 0?i:re)!==null&&o!==void 0?o:!0,strictNumbers:(l=(s=e.strictNumbers)!==null&&s!==void 0?s:re)!==null&&l!==void 0?l:!0,strictTypes:(u=(c=e.strictTypes)!==null&&c!==void 0?c:re)!==null&&u!==void 0?u:"log",strictTuples:(m=(d=e.strictTuples)!==null&&d!==void 0?d:re)!==null&&m!==void 0?m:"log",strictRequired:(g=(p=e.strictRequired)!==null&&p!==void 0?p:re)!==null&&g!==void 0?g:!1,code:e.code?{...e.code,optimize:et,regExp:Le}:{optimize:et,regExp:Le},loopRequired:(h=e.loopRequired)!==null&&h!==void 0?h:mI,loopEnum:(f=e.loopEnum)!==null&&f!==void 0?f:mI,meta:(_=e.meta)!==null&&_!==void 0?_:!0,messages:(b=e.messages)!==null&&b!==void 0?b:!0,inlineRefs:(v=e.inlineRefs)!==null&&v!==void 0?v:!0,schemaId:(C=e.schemaId)!==null&&C!==void 0?C:"$id",addUsedSchema:(S=e.addUsedSchema)!==null&&S!==void 0?S:!0,validateSchema:(P=e.validateSchema)!==null&&P!==void 0?P:!0,validateFormats:(U=e.validateFormats)!==null&&U!==void 0?U:!0,unicodeRegExp:(qe=e.unicodeRegExp)!==null&&qe!==void 0?qe:!0,int32range:(D=e.int32range)!==null&&D!==void 0?D:!0,uriResolver:on}}var Rl=class{constructor(t={}){this.schemas={},this.refs={},this.formats=Object.create(null),this._compilations=new Set,this._loading={},this._cache=new Map,t=this.opts={...t,...p3(t)};let{es5:r,lines:a}=this.opts.code;this.scope=new o3.ValueScope({scope:{},prefixes:c3,es5:r,lines:a}),this.logger=v3(t.logger);let n=t.validateFormats;t.validateFormats=!1,this.RULES=(0,i3.getRules)(),gI.call(this,u3,t,"NOT SUPPORTED"),gI.call(this,d3,t,"DEPRECATED","warn"),this._metaOpts=f3.call(this),t.formats&&g3.call(this),this._addVocabularies(),this._addDefaultMetaSchema(),t.keywords&&h3.call(this,t.keywords),typeof t.meta=="object"&&this.addMetaSchema(t.meta),m3.call(this),t.validateFormats=n}_addVocabularies(){this.addKeyword("$async")}_addDefaultMetaSchema(){let{$data:t,meta:r,schemaId:a}=this.opts,n=pI;a==="id"&&(n={...pI},n.id=n.$id,delete n.$id),r&&t&&this.addMetaSchema(n,n[a],!1)}defaultMeta(){let{meta:t,schemaId:r}=this.opts;return this.opts.defaultMeta=typeof t=="object"?t[r]||t:void 0}validate(t,r){let a;if(typeof t=="string"){if(a=this.getSchema(t),!a)throw new Error(`no schema with key or ref "${t}"`)}else a=this.compile(t);let n=a(r);return"$async"in a||(this.errors=a.errors),n}compile(t,r){let a=this._addSchema(t,r);return a.validate||this._compileSchemaEnv(a)}compileAsync(t,r){if(typeof this.opts.loadSchema!="function")throw new Error("options.loadSchema should be a function");let{loadSchema:a}=this.opts;return n.call(this,t,r);async function n(u,d){await i.call(this,u.$schema);let m=this._addSchema(u,d);return m.validate||o.call(this,m)}async function i(u){u&&!this.getSchema(u)&&await n.call(this,{$ref:u},!0)}async function o(u){try{return this._compileSchemaEnv(u)}catch(d){if(!(d instanceof fI.default))throw d;return s.call(this,d),await l.call(this,d.missingSchema),o.call(this,u)}}function s({missingSchema:u,missingRef:d}){if(this.refs[u])throw new Error(`AnySchema ${u} is loaded but ${d} cannot be resolved`)}async function l(u){let d=await c.call(this,u);this.refs[u]||await i.call(this,d.$schema),this.refs[u]||this.addSchema(d,u,r)}async function c(u){let d=this._loading[u];if(d)return d;try{return await(this._loading[u]=a(u))}finally{delete this._loading[u]}}}addSchema(t,r,a,n=this.opts.validateSchema){if(Array.isArray(t)){for(let o of t)this.addSchema(o,void 0,a,n);return this}let i;if(typeof t=="object"){let{schemaId:o}=this.opts;if(i=t[o],i!==void 0&&typeof i!="string")throw new Error(`schema ${o} must be string`)}return r=(0,Pl.normalizeId)(r||i),this._checkUnique(r),this.schemas[r]=this._addSchema(t,a,r,n,!0),this}addMetaSchema(t,r,a=this.opts.validateSchema){return this.addSchema(t,r,!0,a),this}validateSchema(t,r){if(typeof t=="boolean")return!0;let a;if(a=t.$schema,a!==void 0&&typeof a!="string")throw new Error("$schema must be a string");if(a=a||this.opts.defaultMeta||this.defaultMeta(),!a)return this.logger.warn("meta-schema not available"),this.errors=null,!0;let n=this.validate(a,t);if(!n&&r){let i="schema is invalid: "+this.errorsText();if(this.opts.validateSchema==="log")this.logger.error(i);else throw new Error(i)}return n}getSchema(t){let r;for(;typeof(r=hI.call(this,t))=="string";)t=r;if(r===void 0){let{schemaId:a}=this.opts,n=new Il.SchemaEnv({schema:{},schemaId:a});if(r=Il.resolveSchema.call(this,n,t),!r)return;this.refs[t]=r}return r.validate||this._compileSchemaEnv(r)}removeSchema(t){if(t instanceof RegExp)return this._removeAllSchemas(this.schemas,t),this._removeAllSchemas(this.refs,t),this;switch(typeof t){case"undefined":return this._removeAllSchemas(this.schemas),this._removeAllSchemas(this.refs),this._cache.clear(),this;case"string":{let r=hI.call(this,t);return typeof r=="object"&&this._cache.delete(r.schema),delete this.schemas[t],delete this.refs[t],this}case"object":{let r=t;this._cache.delete(r);let a=t[this.opts.schemaId];return a&&(a=(0,Pl.normalizeId)(a),delete this.schemas[a],delete this.refs[a]),this}default:throw new Error("ajv.removeSchema: invalid parameter")}}addVocabulary(t){for(let r of t)this.addKeyword(r);return this}addKeyword(t,r){let a;if(typeof t=="string")a=t,typeof r=="object"&&(this.logger.warn("these parameters are deprecated, see docs for addKeyword"),r.keyword=a);else if(typeof t=="object"&&r===void 0){if(r=t,a=r.keyword,Array.isArray(a)&&!a.length)throw new Error("addKeywords: keyword must be string or non-empty array")}else throw new Error("invalid addKeywords parameters");if(k3.call(this,a,r),!r)return(0,_k.eachItem)(a,i=>kk.call(this,i)),this;w3.call(this,r);let n={...r,type:(0,$m.getJSONTypes)(r.type),schemaType:(0,$m.getJSONTypes)(r.schemaType)};return(0,_k.eachItem)(a,n.type.length===0?i=>kk.call(this,i,n):i=>n.type.forEach(o=>kk.call(this,i,n,o))),this}getKeyword(t){let r=this.RULES.all[t];return typeof r=="object"?r.definition:!!r}removeKeyword(t){let{RULES:r}=this;delete r.keywords[t],delete r.all[t];for(let a of r.rules){let n=a.rules.findIndex(i=>i.keyword===t);n>=0&&a.rules.splice(n,1)}return this}addFormat(t,r){return typeof r=="string"&&(r=new RegExp(r)),this.formats[t]=r,this}errorsText(t=this.errors,{separator:r=", ",dataVar:a="data"}={}){return!t||t.length===0?"No errors":t.map(n=>`${a}${n.instancePath} ${n.message}`).reduce((n,i)=>n+r+i)}$dataMetaSchema(t,r){let a=this.RULES.all;t=JSON.parse(JSON.stringify(t));for(let n of r){let i=n.split("/").slice(1),o=t;for(let s of i)o=o[s];for(let s in a){let l=a[s];if(typeof l!="object")continue;let{$data:c}=l.definition,u=o[s];c&&u&&(o[s]=vI(u))}}return t}_removeAllSchemas(t,r){for(let a in t){let n=t[a];(!r||r.test(a))&&(typeof n=="string"?delete t[a]:n&&!n.meta&&(this._cache.delete(n.schema),delete t[a]))}}_addSchema(t,r,a,n=this.opts.validateSchema,i=this.opts.addUsedSchema){let o,{schemaId:s}=this.opts;if(typeof t=="object")o=t[s];else{if(this.opts.jtd)throw new Error("schema must be object");if(typeof t!="boolean")throw new Error("schema must be object or boolean")}let l=this._cache.get(t);if(l!==void 0)return l;a=(0,Pl.normalizeId)(o||a);let c=Pl.getSchemaRefs.call(this,t,a);return l=new Il.SchemaEnv({schema:t,schemaId:s,meta:r,baseId:a,localRefs:c}),this._cache.set(l.schema,l),i&&!a.startsWith("#")&&(a&&this._checkUnique(a),this.refs[a]=l),n&&this.validateSchema(t,!0),l}_checkUnique(t){if(this.schemas[t]||this.refs[t])throw new Error(`schema with key or id "${t}" already exists`)}_compileSchemaEnv(t){if(t.meta?this._compileMetaSchema(t):Il.compileSchema.call(this,t),!t.validate)throw new Error("ajv implementation error");return t.validate}_compileMetaSchema(t){let r=this.opts;this.opts=this._metaOpts;try{Il.compileSchema.call(this,t)}finally{this.opts=r}}};Rl.ValidationError=a3.default;Rl.MissingRefError=fI.default;Xe.default=Rl;function gI(e,t,r,a="error"){for(let n in e){let i=n;i in t&&this.logger[a](`${r}: option ${n}. ${e[i]}`)}}function hI(e){return e=(0,Pl.normalizeId)(e),this.schemas[e]||this.refs[e]}function m3(){let e=this.opts.schemas;if(e)if(Array.isArray(e))this.addSchema(e);else for(let t in e)this.addSchema(e[t],t)}function g3(){for(let e in this.opts.formats){let t=this.opts.formats[e];t&&this.addFormat(e,t)}}function h3(e){if(Array.isArray(e)){this.addVocabulary(e);return}this.logger.warn("keywords option as map is deprecated, pass array");for(let t in e){let r=e[t];r.keyword||(r.keyword=t),this.addKeyword(r)}}function f3(){let e={...this.opts};for(let t of l3)delete e[t];return e}var b3={log(){},warn(){},error(){}};function v3(e){if(e===!1)return b3;if(e===void 0)return console;if(e.log&&e.warn&&e.error)return e;throw new Error("logger must implement log, warn and error methods")}var y3=/^[a-z_$][a-z0-9_$:-]*$/i;function k3(e,t){let{RULES:r}=this;if((0,_k.eachItem)(e,a=>{if(r.keywords[a])throw new Error(`Keyword ${a} is already defined`);if(!y3.test(a))throw new Error(`Keyword ${a} has invalid name`)}),!!t&&t.$data&&!("code"in t||"validate"in t))throw new Error('$data keyword must have "code" or "validate" function')}function kk(e,t,r){var a;let n=t?.post;if(r&&n)throw new Error('keyword with "post" flag cannot have "type"');let{RULES:i}=this,o=n?i.post:i.rules.find(({type:l})=>l===r);if(o||(o={type:r,rules:[]},i.rules.push(o)),i.keywords[e]=!0,!t)return;let s={keyword:e,definition:{...t,type:(0,$m.getJSONTypes)(t.type),schemaType:(0,$m.getJSONTypes)(t.schemaType)}};t.before?_3.call(this,o,s,t.before):o.rules.push(s),i.all[e]=s,(a=t.implements)===null||a===void 0||a.forEach(l=>this.addKeyword(l))}function _3(e,t,r){let a=e.rules.findIndex(n=>n.keyword===r);a>=0?e.rules.splice(a,0,t):(e.rules.push(t),this.logger.warn(`rule ${r} is not defined`))}function w3(e){let{metaSchema:t}=e;t!==void 0&&(e.$data&&this.opts.$data&&(t=vI(t)),e.validateSchema=this.compile(t,!0))}var S3={$ref:"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#"};function vI(e){return{anyOf:[e,S3]}}});var kI=j(wk=>{"use strict";Object.defineProperty(wk,"__esModule",{value:!0});var E3={keyword:"id",code(){throw new Error('NOT SUPPORTED: keyword "id", use "$id" for schema ID')}};wk.default=E3});var EI=j(ga=>{"use strict";Object.defineProperty(ga,"__esModule",{value:!0});ga.callRef=ga.getValidate=void 0;var x3=Al(),_I=qt(),At=ne(),no=Zn(),wI=Am(),jm=pe(),T3={keyword:"$ref",schemaType:"string",code(e){let{gen:t,schema:r,it:a}=e,{baseId:n,schemaEnv:i,validateName:o,opts:s,self:l}=a,{root:c}=i;if((r==="#"||r==="#/")&&n===c.baseId)return d();let u=wI.resolveRef.call(l,c,n,r);if(u===void 0)throw new x3.default(a.opts.uriResolver,n,r);if(u instanceof wI.SchemaEnv)return m(u);return p(u);function d(){if(i===c)return Om(e,o,i,i.$async);let g=t.scopeValue("root",{ref:c});return Om(e,(0,At._)`${g}.validate`,c,c.$async)}function m(g){let h=SI(e,g);Om(e,h,g,g.$async)}function p(g){let h=t.scopeValue("schema",s.code.source===!0?{ref:g,code:(0,At.stringify)(g)}:{ref:g}),f=t.name("valid"),_=e.subschema({schema:g,dataTypes:[],schemaPath:At.nil,topSchemaRef:h,errSchemaPath:r},f);e.mergeEvaluated(_),e.ok(f)}}};function SI(e,t){let{gen:r}=e;return t.validate?r.scopeValue("validate",{ref:t.validate}):(0,At._)`${r.scopeValue("wrapper",{ref:t})}.validate`}ga.getValidate=SI;function Om(e,t,r,a){let{gen:n,it:i}=e,{allErrors:o,schemaEnv:s,opts:l}=i,c=l.passContext?no.default.this:At.nil;a?u():d();function u(){if(!s.$async)throw new Error("async schema referenced by sync schema");let g=n.let("valid");n.try(()=>{n.code((0,At._)`await ${(0,_I.callValidateCode)(e,t,c)}`),p(t),o||n.assign(g,!0)},h=>{n.if((0,At._)`!(${h} instanceof ${i.ValidationError})`,()=>n.throw(h)),m(h),o||n.assign(g,!1)}),e.ok(g)}function d(){e.result((0,_I.callValidateCode)(e,t,c),()=>p(t),()=>m(t))}function m(g){let h=(0,At._)`${g}.errors`;n.assign(no.default.vErrors,(0,At._)`${no.default.vErrors} === null ? ${h} : ${no.default.vErrors}.concat(${h})`),n.assign(no.default.errors,(0,At._)`${no.default.vErrors}.length`)}function p(g){var h;if(!i.opts.unevaluated)return;let f=(h=r?.validate)===null||h===void 0?void 0:h.evaluated;if(i.props!==!0)if(f&&!f.dynamicProps)f.props!==void 0&&(i.props=jm.mergeEvaluated.props(n,f.props,i.props));else{let _=n.var("props",(0,At._)`${g}.evaluated.props`);i.props=jm.mergeEvaluated.props(n,_,i.props,At.Name)}if(i.items!==!0)if(f&&!f.dynamicItems)f.items!==void 0&&(i.items=jm.mergeEvaluated.items(n,f.items,i.items));else{let _=n.var("items",(0,At._)`${g}.evaluated.items`);i.items=jm.mergeEvaluated.items(n,_,i.items,At.Name)}}}ga.callRef=Om;ga.default=T3});var xI=j(Sk=>{"use strict";Object.defineProperty(Sk,"__esModule",{value:!0});var A3=kI(),C3=EI(),z3=["$schema","$id","$defs","$vocabulary",{keyword:"$comment"},"definitions",A3.default,C3.default];Sk.default=z3});var TI=j(Ek=>{"use strict";Object.defineProperty(Ek,"__esModule",{value:!0});var Nm=ne(),Cr=Nm.operators,Dm={maximum:{okStr:"<=",ok:Cr.LTE,fail:Cr.GT},minimum:{okStr:">=",ok:Cr.GTE,fail:Cr.LT},exclusiveMaximum:{okStr:"<",ok:Cr.LT,fail:Cr.GTE},exclusiveMinimum:{okStr:">",ok:Cr.GT,fail:Cr.LTE}},I3={message:({keyword:e,schemaCode:t})=>(0,Nm.str)`must be ${Dm[e].okStr} ${t}`,params:({keyword:e,schemaCode:t})=>(0,Nm._)`{comparison: ${Dm[e].okStr}, limit: ${t}}`},P3={keyword:Object.keys(Dm),type:"number",schemaType:"number",$data:!0,error:I3,code(e){let{keyword:t,data:r,schemaCode:a}=e;e.fail$data((0,Nm._)`${r} ${Dm[t].fail} ${a} || isNaN(${r})`)}};Ek.default=P3});var AI=j(xk=>{"use strict";Object.defineProperty(xk,"__esModule",{value:!0});var $l=ne(),R3={message:({schemaCode:e})=>(0,$l.str)`must be multiple of ${e}`,params:({schemaCode:e})=>(0,$l._)`{multipleOf: ${e}}`},$3={keyword:"multipleOf",type:"number",schemaType:"number",$data:!0,error:R3,code(e){let{gen:t,data:r,schemaCode:a,it:n}=e,i=n.opts.multipleOfPrecision,o=t.let("res"),s=i?(0,$l._)`Math.abs(Math.round(${o}) - ${o}) > 1e-${i}`:(0,$l._)`${o} !== parseInt(${o})`;e.fail$data((0,$l._)`(${a} === 0 || (${o} = ${r}/${a}, ${s}))`)}};xk.default=$3});var zI=j(Tk=>{"use strict";Object.defineProperty(Tk,"__esModule",{value:!0});function CI(e){let t=e.length,r=0,a=0,n;for(;a<t;)r++,n=e.charCodeAt(a++),n>=55296&&n<=56319&&a<t&&(n=e.charCodeAt(a),(n&64512)===56320&&a++);return r}Tk.default=CI;CI.code='require("ajv/dist/runtime/ucs2length").default'});var II=j(Ak=>{"use strict";Object.defineProperty(Ak,"__esModule",{value:!0});var ha=ne(),j3=pe(),O3=zI(),N3={message({keyword:e,schemaCode:t}){let r=e==="maxLength"?"more":"fewer";return(0,ha.str)`must NOT have ${r} than ${t} characters`},params:({schemaCode:e})=>(0,ha._)`{limit: ${e}}`},D3={keyword:["maxLength","minLength"],type:"string",schemaType:"number",$data:!0,error:N3,code(e){let{keyword:t,data:r,schemaCode:a,it:n}=e,i=t==="maxLength"?ha.operators.GT:ha.operators.LT,o=n.opts.unicode===!1?(0,ha._)`${r}.length`:(0,ha._)`${(0,j3.useFunc)(e.gen,O3.default)}(${r})`;e.fail$data((0,ha._)`${o} ${i} ${a}`)}};Ak.default=D3});var PI=j(Ck=>{"use strict";Object.defineProperty(Ck,"__esModule",{value:!0});var M3=qt(),L3=pe(),ro=ne(),B3={message:({schemaCode:e})=>(0,ro.str)`must match pattern "${e}"`,params:({schemaCode:e})=>(0,ro._)`{pattern: ${e}}`},U3={keyword:"pattern",type:"string",schemaType:"string",$data:!0,error:B3,code(e){let{gen:t,data:r,$data:a,schema:n,schemaCode:i,it:o}=e,s=o.opts.unicodeRegExp?"u":"";if(a){let{regExp:l}=o.opts.code,c=l.code==="new RegExp"?(0,ro._)`new RegExp`:(0,L3.useFunc)(t,l),u=t.let("valid");t.try(()=>t.assign(u,(0,ro._)`${c}(${i}, ${s}).test(${r})`),()=>t.assign(u,!1)),e.fail$data((0,ro._)`!${u}`)}else{let l=(0,M3.usePattern)(e,n);e.fail$data((0,ro._)`!${l}.test(${r})`)}}};Ck.default=U3});var RI=j(zk=>{"use strict";Object.defineProperty(zk,"__esModule",{value:!0});var jl=ne(),F3={message({keyword:e,schemaCode:t}){let r=e==="maxProperties"?"more":"fewer";return(0,jl.str)`must NOT have ${r} than ${t} properties`},params:({schemaCode:e})=>(0,jl._)`{limit: ${e}}`},q3={keyword:["maxProperties","minProperties"],type:"object",schemaType:"number",$data:!0,error:F3,code(e){let{keyword:t,data:r,schemaCode:a}=e,n=t==="maxProperties"?jl.operators.GT:jl.operators.LT;e.fail$data((0,jl._)`Object.keys(${r}).length ${n} ${a}`)}};zk.default=q3});var $I=j(Ik=>{"use strict";Object.defineProperty(Ik,"__esModule",{value:!0});var Ol=qt(),Nl=ne(),H3=pe(),G3={message:({params:{missingProperty:e}})=>(0,Nl.str)`must have required property '${e}'`,params:({params:{missingProperty:e}})=>(0,Nl._)`{missingProperty: ${e}}`},V3={keyword:"required",type:"object",schemaType:"array",$data:!0,error:G3,code(e){let{gen:t,schema:r,schemaCode:a,data:n,$data:i,it:o}=e,{opts:s}=o;if(!i&&r.length===0)return;let l=r.length>=s.loopRequired;if(o.allErrors?c():u(),s.strictRequired){let p=e.parentSchema.properties,{definedProperties:g}=e.it;for(let h of r)if(p?.[h]===void 0&&!g.has(h)){let f=o.schemaEnv.baseId+o.errSchemaPath,_=`required property "${h}" is not defined at "${f}" (strictRequired)`;(0,H3.checkStrictMode)(o,_,o.opts.strictRequired)}}function c(){if(l||i)e.block$data(Nl.nil,d);else for(let p of r)(0,Ol.checkReportMissingProp)(e,p)}function u(){let p=t.let("missing");if(l||i){let g=t.let("valid",!0);e.block$data(g,()=>m(p,g)),e.ok(g)}else t.if((0,Ol.checkMissingProp)(e,r,p)),(0,Ol.reportMissingProp)(e,p),t.else()}function d(){t.forOf("prop",a,p=>{e.setParams({missingProperty:p}),t.if((0,Ol.noPropertyInData)(t,n,p,s.ownProperties),()=>e.error())})}function m(p,g){e.setParams({missingProperty:p}),t.forOf(p,a,()=>{t.assign(g,(0,Ol.propertyInData)(t,n,p,s.ownProperties)),t.if((0,Nl.not)(g),()=>{e.error(),t.break()})},Nl.nil)}}};Ik.default=V3});var jI=j(Pk=>{"use strict";Object.defineProperty(Pk,"__esModule",{value:!0});var Dl=ne(),W3={message({keyword:e,schemaCode:t}){let r=e==="maxItems"?"more":"fewer";return(0,Dl.str)`must NOT have ${r} than ${t} items`},params:({schemaCode:e})=>(0,Dl._)`{limit: ${e}}`},K3={keyword:["maxItems","minItems"],type:"array",schemaType:"number",$data:!0,error:W3,code(e){let{keyword:t,data:r,schemaCode:a}=e,n=t==="maxItems"?Dl.operators.GT:Dl.operators.LT;e.fail$data((0,Dl._)`${r}.length ${n} ${a}`)}};Pk.default=K3});var Mm=j(Rk=>{"use strict";Object.defineProperty(Rk,"__esModule",{value:!0});var OI=Zy();OI.code='require("ajv/dist/runtime/equal").default';Rk.default=OI});var NI=j(jk=>{"use strict";Object.defineProperty(jk,"__esModule",{value:!0});var $k=wl(),Qe=ne(),Z3=pe(),J3=Mm(),Y3={message:({params:{i:e,j:t}})=>(0,Qe.str)`must NOT have duplicate items (items ## ${t} and ${e} are identical)`,params:({params:{i:e,j:t}})=>(0,Qe._)`{i: ${e}, j: ${t}}`},X3={keyword:"uniqueItems",type:"array",schemaType:"boolean",$data:!0,error:Y3,code(e){let{gen:t,data:r,$data:a,schema:n,parentSchema:i,schemaCode:o,it:s}=e;if(!a&&!n)return;let l=t.let("valid"),c=i.items?(0,$k.getSchemaTypes)(i.items):[];e.block$data(l,u,(0,Qe._)`${o} === false`),e.ok(l);function u(){let g=t.let("i",(0,Qe._)`${r}.length`),h=t.let("j");e.setParams({i:g,j:h}),t.assign(l,!0),t.if((0,Qe._)`${g} > 1`,()=>(d()?m:p)(g,h))}function d(){return c.length>0&&!c.some(g=>g==="object"||g==="array")}function m(g,h){let f=t.name("item"),_=(0,$k.checkDataTypes)(c,f,s.opts.strictNumbers,$k.DataType.Wrong),b=t.const("indices",(0,Qe._)`{}`);t.for((0,Qe._)`;${g}--;`,()=>{t.let(f,(0,Qe._)`${r}[${g}]`),t.if(_,(0,Qe._)`continue`),c.length>1&&t.if((0,Qe._)`typeof ${f} == "string"`,(0,Qe._)`${f} += "_"`),t.if((0,Qe._)`typeof ${b}[${f}] == "number"`,()=>{t.assign(h,(0,Qe._)`${b}[${f}]`),e.error(),t.assign(l,!1).break()}).code((0,Qe._)`${b}[${f}] = ${g}`)})}function p(g,h){let f=(0,Z3.useFunc)(t,J3.default),_=t.name("outer");t.label(_).for((0,Qe._)`;${g}--;`,()=>t.for((0,Qe._)`${h} = ${g}; ${h}--;`,()=>t.if((0,Qe._)`${f}(${r}[${g}], ${r}[${h}])`,()=>{e.error(),t.assign(l,!1).break(_)})))}}};jk.default=X3});var DI=j(Nk=>{"use strict";Object.defineProperty(Nk,"__esModule",{value:!0});var Ok=ne(),Q3=pe(),eU=Mm(),tU={message:"must be equal to constant",params:({schemaCode:e})=>(0,Ok._)`{allowedValue: ${e}}`},nU={keyword:"const",$data:!0,error:tU,code(e){let{gen:t,data:r,$data:a,schemaCode:n,schema:i}=e;a||i&&typeof i=="object"?e.fail$data((0,Ok._)`!${(0,Q3.useFunc)(t,eU.default)}(${r}, ${n})`):e.fail((0,Ok._)`${i} !== ${r}`)}};Nk.default=nU});var MI=j(Dk=>{"use strict";Object.defineProperty(Dk,"__esModule",{value:!0});var Ml=ne(),rU=pe(),aU=Mm(),iU={message:"must be equal to one of the allowed values",params:({schemaCode:e})=>(0,Ml._)`{allowedValues: ${e}}`},oU={keyword:"enum",schemaType:"array",$data:!0,error:iU,code(e){let{gen:t,data:r,$data:a,schema:n,schemaCode:i,it:o}=e;if(!a&&n.length===0)throw new Error("enum must have non-empty array");let s=n.length>=o.opts.loopEnum,l,c=()=>l??(l=(0,rU.useFunc)(t,aU.default)),u;if(s||a)u=t.let("valid"),e.block$data(u,d);else{if(!Array.isArray(n))throw new Error("ajv implementation error");let p=t.const("vSchema",i);u=(0,Ml.or)(...n.map((g,h)=>m(p,h)))}e.pass(u);function d(){t.assign(u,!1),t.forOf("v",i,p=>t.if((0,Ml._)`${c()}(${r}, ${p})`,()=>t.assign(u,!0).break()))}function m(p,g){let h=n[g];return typeof h=="object"&&h!==null?(0,Ml._)`${c()}(${r}, ${p}[${g}])`:(0,Ml._)`${r} === ${h}`}}};Dk.default=oU});var LI=j(Mk=>{"use strict";Object.defineProperty(Mk,"__esModule",{value:!0});var sU=TI(),lU=AI(),cU=II(),uU=PI(),dU=RI(),pU=$I(),mU=jI(),gU=NI(),hU=DI(),fU=MI(),bU=[sU.default,lU.default,cU.default,uU.default,dU.default,pU.default,mU.default,gU.default,{keyword:"type",schemaType:["string","array"]},{keyword:"nullable",schemaType:"boolean"},hU.default,fU.default];Mk.default=bU});var Bk=j(Ll=>{"use strict";Object.defineProperty(Ll,"__esModule",{value:!0});Ll.validateAdditionalItems=void 0;var fa=ne(),Lk=pe(),vU={message:({params:{len:e}})=>(0,fa.str)`must NOT have more than ${e} items`,params:({params:{len:e}})=>(0,fa._)`{limit: ${e}}`},yU={keyword:"additionalItems",type:"array",schemaType:["boolean","object"],before:"uniqueItems",error:vU,code(e){let{parentSchema:t,it:r}=e,{items:a}=t;if(!Array.isArray(a)){(0,Lk.checkStrictMode)(r,'"additionalItems" is ignored when "items" is not an array of schemas');return}BI(e,a)}};function BI(e,t){let{gen:r,schema:a,data:n,keyword:i,it:o}=e;o.items=!0;let s=r.const("len",(0,fa._)`${n}.length`);if(a===!1)e.setParams({len:t.length}),e.pass((0,fa._)`${s} <= ${t.length}`);else if(typeof a=="object"&&!(0,Lk.alwaysValidSchema)(o,a)){let c=r.var("valid",(0,fa._)`${s} <= ${t.length}`);r.if((0,fa.not)(c),()=>l(c)),e.ok(c)}function l(c){r.forRange("i",t.length,s,u=>{e.subschema({keyword:i,dataProp:u,dataPropType:Lk.Type.Num},c),o.allErrors||r.if((0,fa.not)(c),()=>r.break())})}}Ll.validateAdditionalItems=BI;Ll.default=yU});var Uk=j(Bl=>{"use strict";Object.defineProperty(Bl,"__esModule",{value:!0});Bl.validateTuple=void 0;var UI=ne(),Lm=pe(),kU=qt(),_U={keyword:"items",type:"array",schemaType:["object","array","boolean"],before:"uniqueItems",code(e){let{schema:t,it:r}=e;if(Array.isArray(t))return FI(e,"additionalItems",t);r.items=!0,!(0,Lm.alwaysValidSchema)(r,t)&&e.ok((0,kU.validateArray)(e))}};function FI(e,t,r=e.schema){let{gen:a,parentSchema:n,data:i,keyword:o,it:s}=e;u(n),s.opts.unevaluated&&r.length&&s.items!==!0&&(s.items=Lm.mergeEvaluated.items(a,r.length,s.items));let l=a.name("valid"),c=a.const("len",(0,UI._)`${i}.length`);r.forEach((d,m)=>{(0,Lm.alwaysValidSchema)(s,d)||(a.if((0,UI._)`${c} > ${m}`,()=>e.subschema({keyword:o,schemaProp:m,dataProp:m},l)),e.ok(l))});function u(d){let{opts:m,errSchemaPath:p}=s,g=r.length,h=g===d.minItems&&(g===d.maxItems||d[t]===!1);if(m.strictTuples&&!h){let f=`"${o}" is ${g}-tuple, but minItems or maxItems/${t} are not specified or different at path "${p}"`;(0,Lm.checkStrictMode)(s,f,m.strictTuples)}}}Bl.validateTuple=FI;Bl.default=_U});var qI=j(Fk=>{"use strict";Object.defineProperty(Fk,"__esModule",{value:!0});var wU=Uk(),SU={keyword:"prefixItems",type:"array",schemaType:["array"],before:"uniqueItems",code:e=>(0,wU.validateTuple)(e,"items")};Fk.default=SU});var GI=j(qk=>{"use strict";Object.defineProperty(qk,"__esModule",{value:!0});var HI=ne(),EU=pe(),xU=qt(),TU=Bk(),AU={message:({params:{len:e}})=>(0,HI.str)`must NOT have more than ${e} items`,params:({params:{len:e}})=>(0,HI._)`{limit: ${e}}`},CU={keyword:"items",type:"array",schemaType:["object","boolean"],before:"uniqueItems",error:AU,code(e){let{schema:t,parentSchema:r,it:a}=e,{prefixItems:n}=r;a.items=!0,!(0,EU.alwaysValidSchema)(a,t)&&(n?(0,TU.validateAdditionalItems)(e,n):e.ok((0,xU.validateArray)(e)))}};qk.default=CU});var VI=j(Hk=>{"use strict";Object.defineProperty(Hk,"__esModule",{value:!0});var Gt=ne(),Bm=pe(),zU={message:({params:{min:e,max:t}})=>t===void 0?(0,Gt.str)`must contain at least ${e} valid item(s)`:(0,Gt.str)`must contain at least ${e} and no more than ${t} valid item(s)`,params:({params:{min:e,max:t}})=>t===void 0?(0,Gt._)`{minContains: ${e}}`:(0,Gt._)`{minContains: ${e}, maxContains: ${t}}`},IU={keyword:"contains",type:"array",schemaType:["object","boolean"],before:"uniqueItems",trackErrors:!0,error:zU,code(e){let{gen:t,schema:r,parentSchema:a,data:n,it:i}=e,o,s,{minContains:l,maxContains:c}=a;i.opts.next?(o=l===void 0?1:l,s=c):o=1;let u=t.const("len",(0,Gt._)`${n}.length`);if(e.setParams({min:o,max:s}),s===void 0&&o===0){(0,Bm.checkStrictMode)(i,'"minContains" == 0 without "maxContains": "contains" keyword ignored');return}if(s!==void 0&&o>s){(0,Bm.checkStrictMode)(i,'"minContains" > "maxContains" is always invalid'),e.fail();return}if((0,Bm.alwaysValidSchema)(i,r)){let h=(0,Gt._)`${u} >= ${o}`;s!==void 0&&(h=(0,Gt._)`${h} && ${u} <= ${s}`),e.pass(h);return}i.items=!0;let d=t.name("valid");s===void 0&&o===1?p(d,()=>t.if(d,()=>t.break())):o===0?(t.let(d,!0),s!==void 0&&t.if((0,Gt._)`${n}.length > 0`,m)):(t.let(d,!1),m()),e.result(d,()=>e.reset());function m(){let h=t.name("_valid"),f=t.let("count",0);p(h,()=>t.if(h,()=>g(f)))}function p(h,f){t.forRange("i",0,u,_=>{e.subschema({keyword:"contains",dataProp:_,dataPropType:Bm.Type.Num,compositeRule:!0},h),f()})}function g(h){t.code((0,Gt._)`${h}++`),s===void 0?t.if((0,Gt._)`${h} >= ${o}`,()=>t.assign(d,!0).break()):(t.if((0,Gt._)`${h} > ${s}`,()=>t.assign(d,!1).break()),o===1?t.assign(d,!0):t.if((0,Gt._)`${h} >= ${o}`,()=>t.assign(d,!0)))}}};Hk.default=IU});var ZI=j(kn=>{"use strict";Object.defineProperty(kn,"__esModule",{value:!0});kn.validateSchemaDeps=kn.validatePropertyDeps=kn.error=void 0;var Gk=ne(),PU=pe(),Ul=qt();kn.error={message:({params:{property:e,depsCount:t,deps:r}})=>{let a=t===1?"property":"properties";return(0,Gk.str)`must have ${a} ${r} when property ${e} is present`},params:({params:{property:e,depsCount:t,deps:r,missingProperty:a}})=>(0,Gk._)`{property: ${e},
|
|
7
7
|
missingProperty: ${a},
|
|
8
8
|
depsCount: ${t},
|
|
9
|
-
deps: ${r}}`};var IU={keyword:"dependencies",type:"object",schemaType:"object",error:kn.error,code(e){let[t,r]=PU(e);WI(e,t),KI(e,r)}};function PU({schema:e}){let t={},r={};for(let a in e){if(a==="__proto__")continue;let n=Array.isArray(e[a])?t:r;n[a]=e[a]}return[t,r]}function WI(e,t=e.schema){let{gen:r,data:a,it:n}=e;if(Object.keys(t).length===0)return;let i=r.let("missing");for(let o in t){let s=t[o];if(s.length===0)continue;let l=(0,Ul.propertyInData)(r,a,o,n.opts.ownProperties);e.setParams({property:o,depsCount:s.length,deps:s.join(", ")}),n.allErrors?r.if(l,()=>{for(let c of s)(0,Ul.checkReportMissingProp)(e,c)}):(r.if((0,Gk._)`${l} && (${(0,Ul.checkMissingProp)(e,s,i)})`),(0,Ul.reportMissingProp)(e,i),r.else())}}kn.validatePropertyDeps=WI;function KI(e,t=e.schema){let{gen:r,data:a,keyword:n,it:i}=e,o=r.name("valid");for(let s in t)(0,zU.alwaysValidSchema)(i,t[s])||(r.if((0,Ul.propertyInData)(r,a,s,i.opts.ownProperties),()=>{let l=e.subschema({keyword:n,schemaProp:s},o);e.mergeValidEvaluated(l,o)},()=>r.var(o,!0)),e.ok(o))}kn.validateSchemaDeps=KI;kn.default=IU});var YI=j(Vk=>{"use strict";Object.defineProperty(Vk,"__esModule",{value:!0});var JI=ne(),RU=pe(),$U={message:"property name must be valid",params:({params:e})=>(0,JI._)`{propertyName: ${e.propertyName}}`},jU={keyword:"propertyNames",type:"object",schemaType:["object","boolean"],error:$U,code(e){let{gen:t,schema:r,data:a,it:n}=e;if((0,RU.alwaysValidSchema)(n,r))return;let i=t.name("valid");t.forIn("key",a,o=>{e.setParams({propertyName:o}),e.subschema({keyword:"propertyNames",data:o,dataTypes:["string"],propertyName:o,compositeRule:!0},i),t.if((0,JI.not)(i),()=>{e.error(!0),n.allErrors||t.break()})}),e.ok(i)}};Vk.default=jU});var Kk=j(Wk=>{"use strict";Object.defineProperty(Wk,"__esModule",{value:!0});var Um=qt(),rn=ne(),OU=Zn(),Fm=pe(),NU={message:"must NOT have additional properties",params:({params:e})=>(0,rn._)`{additionalProperty: ${e.additionalProperty}}`},DU={keyword:"additionalProperties",type:["object"],schemaType:["boolean","object"],allowUndefined:!0,trackErrors:!0,error:NU,code(e){let{gen:t,schema:r,parentSchema:a,data:n,errsCount:i,it:o}=e;if(!i)throw new Error("ajv implementation error");let{allErrors:s,opts:l}=o;if(o.props=!0,l.removeAdditional!=="all"&&(0,Fm.alwaysValidSchema)(o,r))return;let c=(0,Um.allSchemaProperties)(a.properties),u=(0,Um.allSchemaProperties)(a.patternProperties);d(),e.ok((0,rn._)`${i} === ${OU.default.errors}`);function d(){t.forIn("key",n,f=>{!c.length&&!u.length?g(f):t.if(m(f),()=>g(f))})}function m(f){let _;if(c.length>8){let b=(0,Fm.schemaRefOrVal)(o,a.properties,"properties");_=(0,Um.isOwnProperty)(t,b,f)}else c.length?_=(0,rn.or)(...c.map(b=>(0,rn._)`${f} === ${b}`)):_=rn.nil;return u.length&&(_=(0,rn.or)(_,...u.map(b=>(0,rn._)`${(0,Um.usePattern)(e,b)}.test(${f})`))),(0,rn.not)(_)}function p(f){t.code((0,rn._)`delete ${n}[${f}]`)}function g(f){if(l.removeAdditional==="all"||l.removeAdditional&&r===!1){p(f);return}if(r===!1){e.setParams({additionalProperty:f}),e.error(),s||t.break();return}if(typeof r=="object"&&!(0,Fm.alwaysValidSchema)(o,r)){let _=t.name("valid");l.removeAdditional==="failing"?(h(f,_,!1),t.if((0,rn.not)(_),()=>{e.reset(),p(f)})):(h(f,_),s||t.if((0,rn.not)(_),()=>t.break()))}}function h(f,_,b){let v={keyword:"additionalProperties",dataProp:f,dataPropType:Fm.Type.Str};b===!1&&Object.assign(v,{compositeRule:!0,createErrors:!1,allErrors:!1}),e.subschema(v,_)}}};Wk.default=DU});var eP=j(Jk=>{"use strict";Object.defineProperty(Jk,"__esModule",{value:!0});var MU=Tl(),XI=qt(),Zk=pe(),QI=Kk(),LU={keyword:"properties",type:"object",schemaType:"object",code(e){let{gen:t,schema:r,parentSchema:a,data:n,it:i}=e;i.opts.removeAdditional==="all"&&a.additionalProperties===void 0&&QI.default.code(new MU.KeywordCxt(i,QI.default,"additionalProperties"));let o=(0,XI.allSchemaProperties)(r);for(let d of o)i.definedProperties.add(d);i.opts.unevaluated&&o.length&&i.props!==!0&&(i.props=Zk.mergeEvaluated.props(t,(0,Zk.toHash)(o),i.props));let s=o.filter(d=>!(0,Zk.alwaysValidSchema)(i,r[d]));if(s.length===0)return;let l=t.name("valid");for(let d of s)c(d)?u(d):(t.if((0,XI.propertyInData)(t,n,d,i.opts.ownProperties)),u(d),i.allErrors||t.else().var(l,!0),t.endIf()),e.it.definedProperties.add(d),e.ok(l);function c(d){return i.opts.useDefaults&&!i.compositeRule&&r[d].default!==void 0}function u(d){e.subschema({keyword:"properties",schemaProp:d,dataProp:d},l)}}};Jk.default=LU});var aP=j(Yk=>{"use strict";Object.defineProperty(Yk,"__esModule",{value:!0});var tP=qt(),qm=ne(),nP=pe(),rP=pe(),BU={keyword:"patternProperties",type:"object",schemaType:"object",code(e){let{gen:t,schema:r,data:a,parentSchema:n,it:i}=e,{opts:o}=i,s=(0,tP.allSchemaProperties)(r),l=s.filter(h=>(0,nP.alwaysValidSchema)(i,r[h]));if(s.length===0||l.length===s.length&&(!i.opts.unevaluated||i.props===!0))return;let c=o.strictSchema&&!o.allowMatchingProperties&&n.properties,u=t.name("valid");i.props!==!0&&!(i.props instanceof qm.Name)&&(i.props=(0,rP.evaluatedPropsToName)(t,i.props));let{props:d}=i;m();function m(){for(let h of s)c&&p(h),i.allErrors?g(h):(t.var(u,!0),g(h),t.if(u))}function p(h){for(let f in c)new RegExp(h).test(f)&&(0,nP.checkStrictMode)(i,`property ${f} matches pattern ${h} (use allowMatchingProperties)`)}function g(h){t.forIn("key",a,f=>{t.if((0,qm._)`${(0,tP.usePattern)(e,h)}.test(${f})`,()=>{let _=l.includes(h);_||e.subschema({keyword:"patternProperties",schemaProp:h,dataProp:f,dataPropType:rP.Type.Str},u),i.opts.unevaluated&&d!==!0?t.assign((0,qm._)`${d}[${f}]`,!0):!_&&!i.allErrors&&t.if((0,qm.not)(u),()=>t.break())})})}}};Yk.default=BU});var iP=j(Xk=>{"use strict";Object.defineProperty(Xk,"__esModule",{value:!0});var UU=pe(),FU={keyword:"not",schemaType:["object","boolean"],trackErrors:!0,code(e){let{gen:t,schema:r,it:a}=e;if((0,UU.alwaysValidSchema)(a,r)){e.fail();return}let n=t.name("valid");e.subschema({keyword:"not",compositeRule:!0,createErrors:!1,allErrors:!1},n),e.failResult(n,()=>e.reset(),()=>e.error())},error:{message:"must NOT be valid"}};Xk.default=FU});var oP=j(Qk=>{"use strict";Object.defineProperty(Qk,"__esModule",{value:!0});var qU=qt(),HU={keyword:"anyOf",schemaType:"array",trackErrors:!0,code:qU.validateUnion,error:{message:"must match a schema in anyOf"}};Qk.default=HU});var sP=j(e_=>{"use strict";Object.defineProperty(e_,"__esModule",{value:!0});var Hm=ne(),GU=pe(),VU={message:"must match exactly one schema in oneOf",params:({params:e})=>(0,Hm._)`{passingSchemas: ${e.passing}}`},WU={keyword:"oneOf",schemaType:"array",trackErrors:!0,error:VU,code(e){let{gen:t,schema:r,parentSchema:a,it:n}=e;if(!Array.isArray(r))throw new Error("ajv implementation error");if(n.opts.discriminator&&a.discriminator)return;let i=r,o=t.let("valid",!1),s=t.let("passing",null),l=t.name("_valid");e.setParams({passing:s}),t.block(c),e.result(o,()=>e.reset(),()=>e.error(!0));function c(){i.forEach((u,d)=>{let m;(0,GU.alwaysValidSchema)(n,u)?t.var(l,!0):m=e.subschema({keyword:"oneOf",schemaProp:d,compositeRule:!0},l),d>0&&t.if((0,Hm._)`${l} && ${o}`).assign(o,!1).assign(s,(0,Hm._)`[${s}, ${d}]`).else(),t.if(l,()=>{t.assign(o,!0),t.assign(s,d),m&&e.mergeEvaluated(m,Hm.Name)})})}}};e_.default=WU});var lP=j(t_=>{"use strict";Object.defineProperty(t_,"__esModule",{value:!0});var KU=pe(),ZU={keyword:"allOf",schemaType:"array",code(e){let{gen:t,schema:r,it:a}=e;if(!Array.isArray(r))throw new Error("ajv implementation error");let n=t.name("valid");r.forEach((i,o)=>{if((0,KU.alwaysValidSchema)(a,i))return;let s=e.subschema({keyword:"allOf",schemaProp:o},n);e.ok(n),e.mergeEvaluated(s)})}};t_.default=ZU});var dP=j(n_=>{"use strict";Object.defineProperty(n_,"__esModule",{value:!0});var Gm=ne(),uP=pe(),JU={message:({params:e})=>(0,Gm.str)`must match "${e.ifClause}" schema`,params:({params:e})=>(0,Gm._)`{failingKeyword: ${e.ifClause}}`},YU={keyword:"if",schemaType:["object","boolean"],trackErrors:!0,error:JU,code(e){let{gen:t,parentSchema:r,it:a}=e;r.then===void 0&&r.else===void 0&&(0,uP.checkStrictMode)(a,'"if" without "then" and "else" is ignored');let n=cP(a,"then"),i=cP(a,"else");if(!n&&!i)return;let o=t.let("valid",!0),s=t.name("_valid");if(l(),e.reset(),n&&i){let u=t.let("ifClause");e.setParams({ifClause:u}),t.if(s,c("then",u),c("else",u))}else n?t.if(s,c("then")):t.if((0,Gm.not)(s),c("else"));e.pass(o,()=>e.error(!0));function l(){let u=e.subschema({keyword:"if",compositeRule:!0,createErrors:!1,allErrors:!1},s);e.mergeEvaluated(u)}function c(u,d){return()=>{let m=e.subschema({keyword:u},s);t.assign(o,s),e.mergeValidEvaluated(m,o),d?t.assign(d,(0,Gm._)`${u}`):e.setParams({ifClause:u})}}}};function cP(e,t){let r=e.schema[t];return r!==void 0&&!(0,uP.alwaysValidSchema)(e,r)}n_.default=YU});var pP=j(r_=>{"use strict";Object.defineProperty(r_,"__esModule",{value:!0});var XU=pe(),QU={keyword:["then","else"],schemaType:["object","boolean"],code({keyword:e,parentSchema:t,it:r}){t.if===void 0&&(0,XU.checkStrictMode)(r,`"${e}" without "if" is ignored`)}};r_.default=QU});var mP=j(a_=>{"use strict";Object.defineProperty(a_,"__esModule",{value:!0});var eF=Bk(),tF=qI(),nF=Uk(),rF=GI(),aF=VI(),iF=ZI(),oF=YI(),sF=Kk(),lF=eP(),cF=aP(),uF=iP(),dF=oP(),pF=sP(),mF=lP(),gF=dP(),hF=pP();function fF(e=!1){let t=[uF.default,dF.default,pF.default,mF.default,gF.default,hF.default,oF.default,sF.default,iF.default,lF.default,cF.default];return e?t.push(tF.default,rF.default):t.push(eF.default,nF.default),t.push(aF.default),t}a_.default=fF});var gP=j(i_=>{"use strict";Object.defineProperty(i_,"__esModule",{value:!0});var Me=ne(),bF={message:({schemaCode:e})=>(0,Me.str)`must match format "${e}"`,params:({schemaCode:e})=>(0,Me._)`{format: ${e}}`},vF={keyword:"format",type:["number","string"],schemaType:"string",$data:!0,error:bF,code(e,t){let{gen:r,data:a,$data:n,schema:i,schemaCode:o,it:s}=e,{opts:l,errSchemaPath:c,schemaEnv:u,self:d}=s;if(!l.validateFormats)return;n?m():p();function m(){let g=r.scopeValue("formats",{ref:d.formats,code:l.code.formats}),h=r.const("fDef",(0,Me._)`${g}[${o}]`),f=r.let("fType"),_=r.let("format");r.if((0,Me._)`typeof ${h} == "object" && !(${h} instanceof RegExp)`,()=>r.assign(f,(0,Me._)`${h}.type || "string"`).assign(_,(0,Me._)`${h}.validate`),()=>r.assign(f,(0,Me._)`"string"`).assign(_,h)),e.fail$data((0,Me.or)(b(),v()));function b(){return l.strictSchema===!1?Me.nil:(0,Me._)`${o} && !${_}`}function v(){let C=u.$async?(0,Me._)`(${h}.async ? await ${_}(${a}) : ${_}(${a}))`:(0,Me._)`${_}(${a})`,S=(0,Me._)`(typeof ${_} == "function" ? ${C} : ${_}.test(${a}))`;return(0,Me._)`${_} && ${_} !== true && ${f} === ${t} && !${S}`}}function p(){let g=d.formats[i];if(!g){b();return}if(g===!0)return;let[h,f,_]=v(g);h===t&&e.pass(C());function b(){if(l.strictSchema===!1){d.logger.warn(S());return}throw new Error(S());function S(){return`unknown format "${i}" ignored in schema at path "${c}"`}}function v(S){let P=S instanceof RegExp?(0,Me.regexpCode)(S):l.code.formats?(0,Me._)`${l.code.formats}${(0,Me.getProperty)(i)}`:void 0,U=r.scopeValue("formats",{key:i,ref:S,code:P});return typeof S=="object"&&!(S instanceof RegExp)?[S.type||"string",S.validate,(0,Me._)`${U}.validate`]:["string",S,U]}function C(){if(typeof g=="object"&&!(g instanceof RegExp)&&g.async){if(!u.$async)throw new Error("async format in sync schema");return(0,Me._)`await ${_}(${a})`}return typeof f=="function"?(0,Me._)`${_}(${a})`:(0,Me._)`${_}.test(${a})`}}}};i_.default=vF});var hP=j(o_=>{"use strict";Object.defineProperty(o_,"__esModule",{value:!0});var yF=gP(),kF=[yF.default];o_.default=kF});var fP=j(ao=>{"use strict";Object.defineProperty(ao,"__esModule",{value:!0});ao.contentVocabulary=ao.metadataVocabulary=void 0;ao.metadataVocabulary=["title","description","default","deprecated","readOnly","writeOnly","examples"];ao.contentVocabulary=["contentMediaType","contentEncoding","contentSchema"]});var vP=j(s_=>{"use strict";Object.defineProperty(s_,"__esModule",{value:!0});var _F=xI(),wF=LI(),SF=mP(),EF=hP(),bP=fP(),xF=[_F.default,wF.default,(0,SF.default)(),EF.default,bP.metadataVocabulary,bP.contentVocabulary];s_.default=xF});var kP=j(Vm=>{"use strict";Object.defineProperty(Vm,"__esModule",{value:!0});Vm.DiscrError=void 0;var yP;(function(e){e.Tag="tag",e.Mapping="mapping"})(yP||(Vm.DiscrError=yP={}))});var wP=j(c_=>{"use strict";Object.defineProperty(c_,"__esModule",{value:!0});var io=ne(),l_=kP(),_P=Am(),TF=Al(),AF=pe(),CF={message:({params:{discrError:e,tagName:t}})=>e===l_.DiscrError.Tag?`tag "${t}" must be string`:`value of tag "${t}" must be in oneOf`,params:({params:{discrError:e,tag:t,tagName:r}})=>(0,io._)`{error: ${e}, tag: ${r}, tagValue: ${t}}`},zF={keyword:"discriminator",type:"object",schemaType:"object",error:CF,code(e){let{gen:t,data:r,schema:a,parentSchema:n,it:i}=e,{oneOf:o}=n;if(!i.opts.discriminator)throw new Error("discriminator: requires discriminator option");let s=a.propertyName;if(typeof s!="string")throw new Error("discriminator: requires propertyName");if(a.mapping)throw new Error("discriminator: mapping is not supported");if(!o)throw new Error("discriminator: requires oneOf keyword");let l=t.let("valid",!1),c=t.const("tag",(0,io._)`${r}${(0,io.getProperty)(s)}`);t.if((0,io._)`typeof ${c} == "string"`,()=>u(),()=>e.error(!1,{discrError:l_.DiscrError.Tag,tag:c,tagName:s})),e.ok(l);function u(){let p=m();t.if(!1);for(let g in p)t.elseIf((0,io._)`${c} === ${g}`),t.assign(l,d(p[g]));t.else(),e.error(!1,{discrError:l_.DiscrError.Mapping,tag:c,tagName:s}),t.endIf()}function d(p){let g=t.name("valid"),h=e.subschema({keyword:"oneOf",schemaProp:p},g);return e.mergeEvaluated(h,io.Name),g}function m(){var p;let g={},h=_(n),f=!0;for(let C=0;C<o.length;C++){let S=o[C];if(S?.$ref&&!(0,AF.schemaHasRulesButRef)(S,i.self.RULES)){let U=S.$ref;if(S=_P.resolveRef.call(i.self,i.schemaEnv.root,i.baseId,U),S instanceof _P.SchemaEnv&&(S=S.schema),S===void 0)throw new TF.default(i.opts.uriResolver,i.baseId,U)}let P=(p=S?.properties)===null||p===void 0?void 0:p[s];if(typeof P!="object")throw new Error(`discriminator: oneOf subschemas (or referenced schemas) must have "properties/${s}"`);f=f&&(h||_(S)),b(P,C)}if(!f)throw new Error(`discriminator: "${s}" must be required`);return g;function _({required:C}){return Array.isArray(C)&&C.includes(s)}function b(C,S){if(C.const)v(C.const,S);else if(C.enum)for(let P of C.enum)v(P,S);else throw new Error(`discriminator: "properties/${s}" must have "const" or "enum"`)}function v(C,S){if(typeof C!="string"||C in g)throw new Error(`discriminator: "${s}" values must be unique strings`);g[C]=S}}}};c_.default=zF});var SP=j((uX,IF)=>{IF.exports={$schema:"http://json-schema.org/draft-07/schema#",$id:"http://json-schema.org/draft-07/schema#",title:"Core schema meta-schema",definitions:{schemaArray:{type:"array",minItems:1,items:{$ref:"#"}},nonNegativeInteger:{type:"integer",minimum:0},nonNegativeIntegerDefault0:{allOf:[{$ref:"#/definitions/nonNegativeInteger"},{default:0}]},simpleTypes:{enum:["array","boolean","integer","null","number","object","string"]},stringArray:{type:"array",items:{type:"string"},uniqueItems:!0,default:[]}},type:["object","boolean"],properties:{$id:{type:"string",format:"uri-reference"},$schema:{type:"string",format:"uri"},$ref:{type:"string",format:"uri-reference"},$comment:{type:"string"},title:{type:"string"},description:{type:"string"},default:!0,readOnly:{type:"boolean",default:!1},examples:{type:"array",items:!0},multipleOf:{type:"number",exclusiveMinimum:0},maximum:{type:"number"},exclusiveMaximum:{type:"number"},minimum:{type:"number"},exclusiveMinimum:{type:"number"},maxLength:{$ref:"#/definitions/nonNegativeInteger"},minLength:{$ref:"#/definitions/nonNegativeIntegerDefault0"},pattern:{type:"string",format:"regex"},additionalItems:{$ref:"#"},items:{anyOf:[{$ref:"#"},{$ref:"#/definitions/schemaArray"}],default:!0},maxItems:{$ref:"#/definitions/nonNegativeInteger"},minItems:{$ref:"#/definitions/nonNegativeIntegerDefault0"},uniqueItems:{type:"boolean",default:!1},contains:{$ref:"#"},maxProperties:{$ref:"#/definitions/nonNegativeInteger"},minProperties:{$ref:"#/definitions/nonNegativeIntegerDefault0"},required:{$ref:"#/definitions/stringArray"},additionalProperties:{$ref:"#"},definitions:{type:"object",additionalProperties:{$ref:"#"},default:{}},properties:{type:"object",additionalProperties:{$ref:"#"},default:{}},patternProperties:{type:"object",additionalProperties:{$ref:"#"},propertyNames:{format:"regex"},default:{}},dependencies:{type:"object",additionalProperties:{anyOf:[{$ref:"#"},{$ref:"#/definitions/stringArray"}]}},propertyNames:{$ref:"#"},const:!0,enum:{type:"array",items:!0,minItems:1,uniqueItems:!0},type:{anyOf:[{$ref:"#/definitions/simpleTypes"},{type:"array",items:{$ref:"#/definitions/simpleTypes"},minItems:1,uniqueItems:!0}]},format:{type:"string"},contentMediaType:{type:"string"},contentEncoding:{type:"string"},if:{$ref:"#"},then:{$ref:"#"},else:{$ref:"#"},allOf:{$ref:"#/definitions/schemaArray"},anyOf:{$ref:"#/definitions/schemaArray"},oneOf:{$ref:"#/definitions/schemaArray"},not:{$ref:"#"}},default:!0}});var d_=j((Re,u_)=>{"use strict";Object.defineProperty(Re,"__esModule",{value:!0});Re.MissingRefError=Re.ValidationError=Re.CodeGen=Re.Name=Re.nil=Re.stringify=Re.str=Re._=Re.KeywordCxt=Re.Ajv=void 0;var PF=yI(),RF=vP(),$F=wP(),EP=SP(),jF=["/properties"],Wm="http://json-schema.org/draft-07/schema",oo=class extends PF.default{_addVocabularies(){super._addVocabularies(),RF.default.forEach(t=>this.addVocabulary(t)),this.opts.discriminator&&this.addKeyword($F.default)}_addDefaultMetaSchema(){if(super._addDefaultMetaSchema(),!this.opts.meta)return;let t=this.opts.$data?this.$dataMetaSchema(EP,jF):EP;this.addMetaSchema(t,Wm,!1),this.refs["http://json-schema.org/schema"]=Wm}defaultMeta(){return this.opts.defaultMeta=super.defaultMeta()||(this.getSchema(Wm)?Wm:void 0)}};Re.Ajv=oo;u_.exports=Re=oo;u_.exports.Ajv=oo;Object.defineProperty(Re,"__esModule",{value:!0});Re.default=oo;var OF=Tl();Object.defineProperty(Re,"KeywordCxt",{enumerable:!0,get:function(){return OF.KeywordCxt}});var so=ne();Object.defineProperty(Re,"_",{enumerable:!0,get:function(){return so._}});Object.defineProperty(Re,"str",{enumerable:!0,get:function(){return so.str}});Object.defineProperty(Re,"stringify",{enumerable:!0,get:function(){return so.stringify}});Object.defineProperty(Re,"nil",{enumerable:!0,get:function(){return so.nil}});Object.defineProperty(Re,"Name",{enumerable:!0,get:function(){return so.Name}});Object.defineProperty(Re,"CodeGen",{enumerable:!0,get:function(){return so.CodeGen}});var NF=xm();Object.defineProperty(Re,"ValidationError",{enumerable:!0,get:function(){return NF.default}});var DF=Al();Object.defineProperty(Re,"MissingRefError",{enumerable:!0,get:function(){return DF.default}})});var RP=j(wn=>{"use strict";Object.defineProperty(wn,"__esModule",{value:!0});wn.formatNames=wn.fastFormats=wn.fullFormats=void 0;function _n(e,t){return{validate:e,compare:t}}wn.fullFormats={date:_n(CP,h_),time:_n(m_(!0),f_),"date-time":_n(xP(!0),IP),"iso-time":_n(m_(),zP),"iso-date-time":_n(xP(),PP),duration:/^P(?!$)((\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+S)?)?|(\d+W)?)$/,uri:qF,"uri-reference":/^(?:[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,"uri-template":/^(?:(?:[^\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,url:/^(?:https?|ftp):\/\/(?:\S+(?::\S*)?@)?(?:(?!(?:10|127)(?:\.\d{1,3}){3})(?!(?:169\.254|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-z0-9\u{00a1}-\u{ffff}]+-)*[a-z0-9\u{00a1}-\u{ffff}]+)(?:\.(?:[a-z0-9\u{00a1}-\u{ffff}]+-)*[a-z0-9\u{00a1}-\u{ffff}]+)*(?:\.(?:[a-z\u{00a1}-\u{ffff}]{2,})))(?::\d{2,5})?(?:\/[^\s]*)?$/iu,email:/^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/i,hostname:/^(?=.{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,ipv4:/^(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)$/,ipv6:/^((([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,regex:JF,uuid:/^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i,"json-pointer":/^(?:\/(?:[^~/]|~0|~1)*)*$/,"json-pointer-uri-fragment":/^#(?:\/(?:[a-z0-9_\-.!$&'()*+,;:=@]|%[0-9a-f]{2}|~0|~1)*)*$/i,"relative-json-pointer":/^(?:0|[1-9][0-9]*)(?:#|(?:\/(?:[^~/]|~0|~1)*)*)$/,byte:HF,int32:{type:"number",validate:WF},int64:{type:"number",validate:KF},float:{type:"number",validate:AP},double:{type:"number",validate:AP},password:!0,binary:!0};wn.fastFormats={...wn.fullFormats,date:_n(/^\d\d\d\d-[0-1]\d-[0-3]\d$/,h_),time:_n(/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)$/i,f_),"date-time":_n(/^\d\d\d\d-[0-1]\d-[0-3]\dt(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)$/i,IP),"iso-time":_n(/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)?$/i,zP),"iso-date-time":_n(/^\d\d\d\d-[0-1]\d-[0-3]\d[t\s](?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)?$/i,PP),uri:/^(?:[a-z][a-z0-9+\-.]*:)(?:\/?\/)?[^\s]*$/i,"uri-reference":/^(?:(?:[a-z][a-z0-9+\-.]*:)?\/?\/)?(?:[^\\\s#][^\s#]*)?(?:#[^\\\s]*)?$/i,email:/^[a-z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?)*$/i};wn.formatNames=Object.keys(wn.fullFormats);function MF(e){return e%4===0&&(e%100!==0||e%400===0)}var LF=/^(\d\d\d\d)-(\d\d)-(\d\d)$/,BF=[0,31,28,31,30,31,30,31,31,30,31,30,31];function CP(e){let t=LF.exec(e);if(!t)return!1;let r=+t[1],a=+t[2],n=+t[3];return a>=1&&a<=12&&n>=1&&n<=(a===2&&MF(r)?29:BF[a])}function h_(e,t){if(e&&t)return e>t?1:e<t?-1:0}var p_=/^(\d\d):(\d\d):(\d\d(?:\.\d+)?)(z|([+-])(\d\d)(?::?(\d\d))?)?$/i;function m_(e){return function(r){let a=p_.exec(r);if(!a)return!1;let n=+a[1],i=+a[2],o=+a[3],s=a[4],l=a[5]==="-"?-1:1,c=+(a[6]||0),u=+(a[7]||0);if(c>23||u>59||e&&!s)return!1;if(n<=23&&i<=59&&o<60)return!0;let d=i-u*l,m=n-c*l-(d<0?1:0);return(m===23||m===-1)&&(d===59||d===-1)&&o<61}}function f_(e,t){if(!(e&&t))return;let r=new Date("2020-01-01T"+e).valueOf(),a=new Date("2020-01-01T"+t).valueOf();if(r&&a)return r-a}function zP(e,t){if(!(e&&t))return;let r=p_.exec(e),a=p_.exec(t);if(r&&a)return e=r[1]+r[2]+r[3],t=a[1]+a[2]+a[3],e>t?1:e<t?-1:0}var g_=/t|\s/i;function xP(e){let t=m_(e);return function(a){let n=a.split(g_);return n.length===2&&CP(n[0])&&t(n[1])}}function IP(e,t){if(!(e&&t))return;let r=new Date(e).valueOf(),a=new Date(t).valueOf();if(r&&a)return r-a}function PP(e,t){if(!(e&&t))return;let[r,a]=e.split(g_),[n,i]=t.split(g_),o=h_(r,n);if(o!==void 0)return o||f_(a,i)}var UF=/\/|:/,FF=/^(?:[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 qF(e){return UF.test(e)&&FF.test(e)}var TP=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/gm;function HF(e){return TP.lastIndex=0,TP.test(e)}var GF=-(2**31),VF=2**31-1;function WF(e){return Number.isInteger(e)&&e<=VF&&e>=GF}function KF(e){return Number.isInteger(e)}function AP(){return!0}var ZF=/[^\\]\\Z/;function JF(e){if(ZF.test(e))return!1;try{return new RegExp(e),!0}catch{return!1}}});var $P=j(lo=>{"use strict";Object.defineProperty(lo,"__esModule",{value:!0});lo.formatLimitDefinition=void 0;var YF=d_(),an=ne(),zr=an.operators,Km={formatMaximum:{okStr:"<=",ok:zr.LTE,fail:zr.GT},formatMinimum:{okStr:">=",ok:zr.GTE,fail:zr.LT},formatExclusiveMaximum:{okStr:"<",ok:zr.LT,fail:zr.GTE},formatExclusiveMinimum:{okStr:">",ok:zr.GT,fail:zr.LTE}},XF={message:({keyword:e,schemaCode:t})=>(0,an.str)`should be ${Km[e].okStr} ${t}`,params:({keyword:e,schemaCode:t})=>(0,an._)`{comparison: ${Km[e].okStr}, limit: ${t}}`};lo.formatLimitDefinition={keyword:Object.keys(Km),type:"string",schemaType:"string",$data:!0,error:XF,code(e){let{gen:t,data:r,schemaCode:a,keyword:n,it:i}=e,{opts:o,self:s}=i;if(!o.validateFormats)return;let l=new YF.KeywordCxt(i,s.RULES.all.format.definition,"format");l.$data?c():u();function c(){let m=t.scopeValue("formats",{ref:s.formats,code:o.code.formats}),p=t.const("fmt",(0,an._)`${m}[${l.schemaCode}]`);e.fail$data((0,an.or)((0,an._)`typeof ${p} != "object"`,(0,an._)`${p} instanceof RegExp`,(0,an._)`typeof ${p}.compare != "function"`,d(p)))}function u(){let m=l.schema,p=s.formats[m];if(!p||p===!0)return;if(typeof p!="object"||p instanceof RegExp||typeof p.compare!="function")throw new Error(`"${n}": format "${m}" does not define "compare" function`);let g=t.scopeValue("formats",{key:m,ref:p,code:o.code.formats?(0,an._)`${o.code.formats}${(0,an.getProperty)(m)}`:void 0});e.fail$data(d(g))}function d(m){return(0,an._)`${m}.compare(${r}, ${a}) ${Km[n].fail} 0`}},dependencies:["format"]};var QF=e=>(e.addKeyword(lo.formatLimitDefinition),e);lo.default=QF});var DP=j((Fl,NP)=>{"use strict";Object.defineProperty(Fl,"__esModule",{value:!0});var co=RP(),eq=$P(),b_=ne(),jP=new b_.Name("fullFormats"),tq=new b_.Name("fastFormats"),v_=(e,t={keywords:!0})=>{if(Array.isArray(t))return OP(e,t,co.fullFormats,jP),e;let[r,a]=t.mode==="fast"?[co.fastFormats,tq]:[co.fullFormats,jP],n=t.formats||co.formatNames;return OP(e,n,r,a),t.keywords&&(0,eq.default)(e),e};v_.get=(e,t="full")=>{let a=(t==="fast"?co.fastFormats:co.fullFormats)[e];if(!a)throw new Error(`Unknown format "${e}"`);return a};function OP(e,t,r,a){var n,i;(n=(i=e.opts.code).formats)!==null&&n!==void 0||(i.formats=(0,b_._)`require("ajv-formats/dist/formats").${a}`);for(let o of t)e.addFormat(o,r[o])}NP.exports=Fl=v_;Object.defineProperty(Fl,"__esModule",{value:!0});Fl.default=v_});import{createServer as Lq}from"node:http";import Xx from"node:process";var H={};En(H,{$brand:()=>bg,$input:()=>Bh,$output:()=>Lh,INVALID:()=>ut,NEVER:()=>fg,TimePrecision:()=>Kh,ZodAny:()=>sb,ZodArray:()=>db,ZodBase64:()=>Hd,ZodBase64URL:()=>Gd,ZodBigInt:()=>pi,ZodBigIntFormat:()=>Kd,ZodBoolean:()=>di,ZodCIDRv4:()=>Fd,ZodCIDRv6:()=>qd,ZodCUID:()=>Od,ZodCUID2:()=>Nd,ZodCatch:()=>Ib,ZodCodec:()=>Es,ZodCompileAsyncError:()=>Vt,ZodCompileUnsupportedError:()=>se,ZodCreditCard:()=>nb,ZodCustom:()=>xs,ZodCustomStringFormat:()=>Vr,ZodDate:()=>ys,ZodDefault:()=>Eb,ZodDiscriminatedUnion:()=>mb,ZodE164:()=>Vd,ZodEmail:()=>Pd,ZodEmoji:()=>$d,ZodEnum:()=>li,ZodError:()=>h0,ZodExactOptional:()=>Yd,ZodFile:()=>kb,ZodFirstPartyTypeKind:()=>Hb,ZodFunction:()=>Bb,ZodGUID:()=>Rd,ZodIBAN:()=>rb,ZodIPv4:()=>Bd,ZodIPv6:()=>Ud,ZodISODate:()=>cr,ZodISODateTime:()=>lr,ZodISODuration:()=>dr,ZodISOTime:()=>ur,ZodInstanceOf:()=>qb,ZodIntersection:()=>gb,ZodIssueCode:()=>v0,ZodJWT:()=>Wd,ZodKSUID:()=>Ld,ZodLazy:()=>Db,ZodLiteral:()=>yb,ZodMAC:()=>tb,ZodMap:()=>bb,ZodNaN:()=>Rb,ZodNanoID:()=>jd,ZodNever:()=>cb,ZodNonOptional:()=>Xd,ZodNull:()=>ob,ZodNullable:()=>Sb,ZodNumber:()=>ui,ZodNumberFormat:()=>Wr,ZodObject:()=>ks,ZodOptional:()=>Kr,ZodPipe:()=>Ss,ZodPrefault:()=>Tb,ZodPreprocess:()=>$b,ZodPromise:()=>Lb,ZodReadonly:()=>jb,ZodRealError:()=>wt,ZodRecord:()=>si,ZodSet:()=>vb,ZodString:()=>ci,ZodStringFormat:()=>Se,ZodSuccess:()=>zb,ZodSymbol:()=>ab,ZodTemplateLiteral:()=>Nb,ZodTransform:()=>_b,ZodTuple:()=>hb,ZodType:()=>Y,ZodULID:()=>Dd,ZodURL:()=>bs,ZodUUID:()=>dn,ZodUndefined:()=>ib,ZodUnion:()=>_s,ZodUnknown:()=>lb,ZodVoid:()=>ub,ZodXID:()=>Md,ZodXor:()=>pb,_ZodString:()=>Id,_default:()=>xb,_function:()=>vx,any:()=>QE,array:()=>ae,base64:()=>$E,base64url:()=>jE,bigint:()=>KE,boolean:()=>De,catch:()=>Pb,check:()=>yx,cidrv4:()=>PE,cidrv6:()=>RE,clone:()=>ge,codec:()=>gx,coerce:()=>Vb,compile:()=>Hh,config:()=>Oe,core:()=>Kt,creditCard:()=>NE,cuid:()=>SE,cuid2:()=>EE,currencyCode:()=>FE,custom:()=>Qd,date:()=>tx,decode:()=>Kf,decodeAsync:()=>Jf,deepPartial:()=>Px,describe:()=>kx,discriminatedUnion:()=>ws,e164:()=>OE,email:()=>mE,emoji:()=>_E,encode:()=>Wf,encodeAsync:()=>Zf,endsWith:()=>Ja,enum:()=>Ke,exactOptional:()=>wb,file:()=>ux,flattenError:()=>So,float32:()=>HE,float64:()=>GE,formatError:()=>Eo,fromJSONSchema:()=>zx,function:()=>vx,getDiscriminatedOption:()=>Oh,getErrorMap:()=>k0,globalRegistry:()=>Ve,gt:()=>cn,gte:()=>It,guid:()=>gE,hash:()=>qE,hex:()=>UE,hostname:()=>BE,httpUrl:()=>kE,iban:()=>DE,includes:()=>Ka,input:()=>$x,instanceof:()=>wx,int:()=>Cd,int32:()=>VE,int64:()=>ZE,intersection:()=>mi,invertCodec:()=>hx,ipv4:()=>CE,ipv6:()=>IE,iso:()=>Zr,json:()=>Ex,jwt:()=>ME,keyof:()=>nx,ksuid:()=>AE,lazy:()=>Mb,length:()=>qr,literal:()=>B,locales:()=>Fa,looseObject:()=>We,looseRecord:()=>ox,lowercase:()=>Va,lt:()=>ln,lte:()=>zt,mac:()=>zE,map:()=>sx,maxLength:()=>Fr,maxSize:()=>rr,memoizer:()=>Uo,meta:()=>_x,mime:()=>Xa,minLength:()=>Cn,minSize:()=>un,multipleOf:()=>nr,nan:()=>mx,nanoid:()=>wE,nativeEnum:()=>cx,negative:()=>dd,never:()=>Zd,nonnegative:()=>md,nonoptional:()=>Cb,nonpositive:()=>pd,normalize:()=>Qa,null:()=>vs,nullable:()=>fs,nullish:()=>dx,number:()=>he,object:()=>O,optional:()=>we,output:()=>jx,overwrite:()=>Wt,parse:()=>qf,parseAsync:()=>Hf,partialRecord:()=>ix,pipe:()=>zd,positive:()=>ud,prefault:()=>Ab,preprocess:()=>Ts,prettifyError:()=>wg,promise:()=>bx,properties:()=>Ya,property:()=>gd,readonly:()=>Ob,record:()=>Ee,refine:()=>Ub,regex:()=>Ga,regexes:()=>Ct,registry:()=>Du,safeDecode:()=>Xf,safeDecodeAsync:()=>eb,safeEncode:()=>Yf,safeEncodeAsync:()=>Qf,safeParse:()=>Gf,safeParseAsync:()=>Vf,set:()=>lx,setErrorMap:()=>y0,size:()=>Ur,slugify:()=>ri,startsWith:()=>Za,strictObject:()=>rx,string:()=>w,stringFormat:()=>LE,stringbool:()=>Sx,success:()=>px,superRefine:()=>Fb,symbol:()=>YE,templateLiteral:()=>fx,toJSONSchema:()=>Hr,toLowerCase:()=>ti,toUpperCase:()=>ni,toZod:()=>go,transform:()=>Jd,treeifyError:()=>_g,trim:()=>ei,tuple:()=>fb,uint32:()=>WE,uint64:()=>JE,ulid:()=>xE,undefined:()=>XE,union:()=>ye,unknown:()=>xe,uppercase:()=>Wa,url:()=>yE,util:()=>E,uuid:()=>hE,uuidv4:()=>fE,uuidv6:()=>bE,uuidv7:()=>vE,validate:()=>Ra,validateAsync:()=>$a,void:()=>ex,withParser:()=>Mu,xid:()=>TE,xor:()=>ax});var Kt={};En(Kt,{$ZodAny:()=>Yc,$ZodArray:()=>nu,$ZodAsyncError:()=>kt,$ZodBase64:()=>Oc,$ZodBase64URL:()=>Dc,$ZodBigInt:()=>Oo,$ZodBigIntFormat:()=>Wc,$ZodBoolean:()=>Na,$ZodCIDRv4:()=>Pc,$ZodCIDRv6:()=>$c,$ZodCUID:()=>Sc,$ZodCUID2:()=>Ec,$ZodCatch:()=>ku,$ZodCheck:()=>_e,$ZodCheckBigIntFormat:()=>lh,$ZodCheckEndsWith:()=>kh,$ZodCheckGreaterThan:()=>lc,$ZodCheckIncludes:()=>vh,$ZodCheckLengthEquals:()=>gh,$ZodCheckLessThan:()=>sc,$ZodCheckLowerCase:()=>fh,$ZodCheckMaxLength:()=>ph,$ZodCheckMaxSize:()=>ch,$ZodCheckMimeType:()=>Sh,$ZodCheckMinLength:()=>mh,$ZodCheckMinSize:()=>uh,$ZodCheckMultipleOf:()=>oh,$ZodCheckNumberFormat:()=>sh,$ZodCheckOverwrite:()=>Eh,$ZodCheckProperties:()=>wh,$ZodCheckProperty:()=>_h,$ZodCheckRegex:()=>hh,$ZodCheckSizeEquals:()=>dh,$ZodCheckStartsWith:()=>yh,$ZodCheckStringFormat:()=>ja,$ZodCheckUpperCase:()=>bh,$ZodCodec:()=>Ma,$ZodCreditCard:()=>Bc,$ZodCustom:()=>Tu,$ZodCustomStringFormat:()=>Gc,$ZodCyclicError:()=>Iu,$ZodDate:()=>tu,$ZodDefault:()=>fu,$ZodDiscriminatedUnion:()=>iu,$ZodE164:()=>Mc,$ZodEmail:()=>fc,$ZodEmoji:()=>_c,$ZodEncodeError:()=>Qn,$ZodEnum:()=>uu,$ZodError:()=>kg,$ZodExactOptional:()=>gu,$ZodFile:()=>pu,$ZodFunction:()=>Eu,$ZodGUID:()=>gc,$ZodIBAN:()=>Fc,$ZodIPv4:()=>Cc,$ZodIPv6:()=>zc,$ZodISODate:()=>Ih,$ZodISODateTime:()=>zh,$ZodISODuration:()=>Rh,$ZodISOTime:()=>Ph,$ZodIntersection:()=>ou,$ZodJWT:()=>Hc,$ZodKSUID:()=>Ac,$ZodLazy:()=>La,$ZodLiteral:()=>du,$ZodMAC:()=>Ic,$ZodMap:()=>lu,$ZodNaN:()=>_u,$ZodNanoID:()=>wc,$ZodNever:()=>Qc,$ZodNonOptional:()=>vu,$ZodNull:()=>Jc,$ZodNullable:()=>hu,$ZodNumber:()=>jo,$ZodNumberFormat:()=>Vc,$ZodObject:()=>ru,$ZodObjectJIT:()=>jh,$ZodOptional:()=>Do,$ZodPipe:()=>Mo,$ZodPrefault:()=>bu,$ZodPreprocess:()=>Nh,$ZodPromise:()=>xu,$ZodReadonly:()=>wu,$ZodRealError:()=>_t,$ZodRecord:()=>su,$ZodRegistry:()=>Nu,$ZodSet:()=>cu,$ZodString:()=>er,$ZodStringFormat:()=>be,$ZodSuccess:()=>yu,$ZodSymbol:()=>Kc,$ZodTemplateLiteral:()=>Su,$ZodTransform:()=>mu,$ZodTuple:()=>No,$ZodType:()=>Z,$ZodULID:()=>xc,$ZodURL:()=>kc,$ZodUUID:()=>hc,$ZodUndefined:()=>Zc,$ZodUnion:()=>Da,$ZodUnknown:()=>Xc,$ZodVoid:()=>eu,$ZodXID:()=>Tc,$ZodXor:()=>au,$brand:()=>bg,$constructor:()=>y,$input:()=>Bh,$output:()=>Lh,Doc:()=>Dr,INVALID:()=>ut,JSONSchema:()=>uE,JSONSchemaGenerator:()=>xd,NEVER:()=>fg,TimePrecision:()=>Kh,URL_BAD_FORMAT:()=>Ah,URL_UNPARSEABLE:()=>zo,ZodCompileAsyncError:()=>Vt,ZodCompileUnsupportedError:()=>se,_any:()=>ad,_array:()=>Qh,_base64:()=>os,_base64url:()=>ss,_bigint:()=>Xu,_boolean:()=>Yu,_catch:()=>r0,_check:()=>KS,_cidrv4:()=>as,_cidrv6:()=>is,_coercedBigint:()=>Yh,_coercedBoolean:()=>Jh,_coercedDate:()=>Xh,_coercedNumber:()=>Zh,_coercedString:()=>Wh,_creditCard:()=>qu,_cuid:()=>Yo,_cuid2:()=>Xo,_custom:()=>fd,_date:()=>ld,_decode:()=>Jl,_decodeAsync:()=>Xl,_default:()=>e0,_discriminatedUnion:()=>F2,_e164:()=>ls,_email:()=>qo,_emoji:()=>Zo,_encode:()=>Zl,_encodeAsync:()=>Yl,_endsWith:()=>Ja,_enum:()=>K2,_file:()=>hd,_float32:()=>Wu,_float64:()=>Ku,_gt:()=>cn,_gte:()=>It,_guid:()=>Ho,_iban:()=>Hu,_includes:()=>Ka,_int:()=>Vu,_int32:()=>Zu,_int64:()=>Qu,_intersection:()=>q2,_ipv4:()=>ns,_ipv6:()=>rs,_isoDate:()=>ds,_isoDateTime:()=>us,_isoDuration:()=>ms,_isoTime:()=>ps,_jwt:()=>cs,_ksuid:()=>ts,_lazy:()=>s0,_length:()=>qr,_literal:()=>J2,_lowercase:()=>Va,_lt:()=>ln,_lte:()=>zt,_mac:()=>Fu,_map:()=>V2,_max:()=>zt,_maxLength:()=>Fr,_maxSize:()=>rr,_mime:()=>Xa,_min:()=>It,_minLength:()=>Cn,_minSize:()=>un,_multipleOf:()=>nr,_nan:()=>cd,_nanoid:()=>Jo,_nativeEnum:()=>Z2,_negative:()=>dd,_never:()=>od,_nonnegative:()=>md,_nonoptional:()=>t0,_nonpositive:()=>pd,_normalize:()=>Qa,_null:()=>rd,_nullable:()=>Q2,_number:()=>Gu,_optional:()=>X2,_overwrite:()=>Wt,_parse:()=>Ta,_parseAsync:()=>Aa,_pipe:()=>a0,_positive:()=>ud,_promise:()=>l0,_properties:()=>Ya,_property:()=>gd,_readonly:()=>i0,_record:()=>G2,_refine:()=>bd,_regex:()=>Ga,_safeDecode:()=>ec,_safeDecodeAsync:()=>nc,_safeEncode:()=>Ql,_safeEncodeAsync:()=>tc,_safeParse:()=>Ca,_safeParseAsync:()=>Ia,_set:()=>W2,_size:()=>Ur,_slugify:()=>ri,_startsWith:()=>Za,_string:()=>Uu,_stringFormat:()=>ar,_stringbool:()=>_d,_success:()=>n0,_superRefine:()=>vd,_symbol:()=>td,_templateLiteral:()=>o0,_toLowerCase:()=>ti,_toUpperCase:()=>ni,_transform:()=>Y2,_trim:()=>ei,_tuple:()=>H2,_uint32:()=>Ju,_uint64:()=>ed,_ulid:()=>Qo,_undefined:()=>nd,_union:()=>B2,_unknown:()=>id,_uppercase:()=>Wa,_url:()=>Ha,_uuid:()=>Go,_uuidv4:()=>Vo,_uuidv6:()=>Wo,_uuidv7:()=>Ko,_void:()=>sd,_xid:()=>es,_xor:()=>U2,base64Charset:()=>jc,base64urlCharset:()=>$o,canParseURL:()=>Ch,clone:()=>ge,compile:()=>Hh,compileFn:()=>Lu,config:()=>Oe,createStandardJSONSchemaMethod:()=>ai,createToJSONSchemaMethod:()=>tf,decode:()=>Z_,decodeAsync:()=>Y_,describe:()=>yd,encode:()=>K_,encodeAsync:()=>J_,extractDefs:()=>or,finalize:()=>sr,flattenError:()=>So,formatError:()=>Eo,getDiscriminatedOption:()=>Oh,globalConfig:()=>He,globalRegistry:()=>Ve,handleUnrepresentable:()=>Be,initializeContext:()=>ir,isBackEdge:()=>Ru,isRecursiveSchema:()=>Pu,isValidBase64:()=>Ro,isValidBase64URL:()=>Nc,isValidCIDRv6:()=>Rc,isValidCreditCard:()=>Lc,isValidIBAN:()=>Uc,isValidIPv6:()=>Po,isValidJWT:()=>qc,locales:()=>Fa,memoizer:()=>Uo,mergeValues:()=>Oa,meta:()=>kd,parse:()=>jr,parseAsync:()=>Or,parseURLObject:()=>_w,prettifyError:()=>wg,process:()=>ve,processSchema:()=>ve,regexes:()=>Ct,registry:()=>Du,safeDecode:()=>Q_,safeDecodeAsync:()=>tw,safeEncode:()=>X_,safeEncodeAsync:()=>ew,safeParse:()=>za,safeParseAsync:()=>Pa,standardProps:()=>mc,stripTabAndNewline:()=>Io,toDotPath:()=>V_,toJSONSchema:()=>Hr,toZod:()=>go,treeifyError:()=>_g,urlHostnameOk:()=>vc,urlProtocolOk:()=>yc,util:()=>E,validate:()=>Ra,validateAsync:()=>$a,validateURL:()=>bc,version:()=>xh,withParser:()=>Mu});var E={};En(E,{BIGINT_FORMAT_RANGES:()=>vo,CONSTANT_CATCH:()=>Wl,Class:()=>ig,NUMBER_FORMAT_RANGES:()=>bo,aborted:()=>ct,allowsEval:()=>lg,assert:()=>y1,assertEqual:()=>h1,assertIs:()=>b1,assertNever:()=>v1,assertNotEqual:()=>f1,assignProp:()=>Ge,attachSchema:()=>yo,base64ToUint8Array:()=>B_,base64urlToUint8Array:()=>P1,cached:()=>_a,captureStackTrace:()=>Gl,cleanEnum:()=>I1,cleanRegex:()=>Tn,clone:()=>ge,cloneDef:()=>w1,codePointLength:()=>$r,constantCatch:()=>gg,createTransparentProxy:()=>C1,defineLazy:()=>og,defineLazyInternal:()=>ee,derived:()=>O1,esc:()=>lt,escapeRegex:()=>Mt,explicitlyAborted:()=>dg,extend:()=>j_,finalizeIssue:()=>yt,floatSafeRemainder:()=>ho,getElementAtPath:()=>S1,getEnumValues:()=>ya,getLengthableOrigin:()=>_o,getParsedType:()=>A1,getSizableOrigin:()=>ko,hexToUint8Array:()=>$1,hide:()=>wo,installLazyProp:()=>mg,isObject:()=>Rr,isPlainObject:()=>Dt,issue:()=>xa,joinValues:()=>k,jsonStringifyReplacer:()=>ka,members:()=>pg,merge:()=>D_,mergeDefs:()=>Nt,normalizeParams:()=>z,nullish:()=>Hl,numKeys:()=>T1,objectClone:()=>k1,omit:()=>$_,optionalKeys:()=>ug,own:()=>sn,parsedType:()=>T,partial:()=>M_,pick:()=>R_,prefixIssues:()=>vt,primitiveTypes:()=>cg,promiseAllObject:()=>E1,propertyKeyTypes:()=>fo,randomString:()=>x1,rawShape:()=>wa,required:()=>L_,safeExtend:()=>N_,shallowClone:()=>Sa,sizeCaps:()=>Ea,slugify:()=>sg,stringifyPrimitive:()=>x,toZod:()=>go,uint8ArrayToBase64:()=>U_,uint8ArrayToBase64url:()=>R1,uint8ArrayToHex:()=>j1,unwrapMessage:()=>va});function h1(e){return e}function f1(e){return e}function go(){return e=>e}function b1(e){}function v1(e){throw new Error("Unexpected value in exhaustive check")}function y1(e){}function ya(e){let t=Object.values(e).filter(a=>typeof a=="number");return Object.entries(e).filter(([a,n])=>t.indexOf(+a)===-1).map(([a,n])=>n)}function k(e,t="|"){return e.map(r=>x(r)).join(t)}function ka(e,t){return typeof t=="bigint"?t.toString():t}var ag=class{constructor(t){this._getter=t,this._value=void 0}get value(){let t=this._getter;return t!==void 0&&(this._value=t(),this._getter=void 0),this._value}};function _a(e){return new ag(e)}function Hl(e){return e==null}function Tn(e){let t=e.startsWith("^")?1:0,r=e.endsWith("$")?e.length-1:e.length;return e.slice(t,r)}function ho(e,t){let r=e/t,a=Math.round(r),n=4*Number.EPSILON*Math.max(Math.abs(r),1);return Math.abs(r-a)<n?0:r-a}var z_=Symbol("evaluating");function og(e,t,r){let a;Object.defineProperty(e,t,{get(){if(a!==z_)return a===void 0&&(a=z_,a=r()),a},set(n){Object.defineProperty(e,t,{value:n})},configurable:!0})}function k1(e){return Object.create(Object.getPrototypeOf(e),Object.getOwnPropertyDescriptors(e))}function Ge(e,t,r){Object.defineProperty(e,t,{value:r,writable:!0,enumerable:!0,configurable:!0})}function wa(e){let t=Object.getOwnPropertyDescriptor(e,"shape");return t?.get?t.get.raw:t?.value}function xn(e){return wa(e._zod.def)??e._zod.def.shape}function I_(e,t,r){Object.defineProperty(e,t,{get(){let a=r();return Ge(this,t,a),a},enumerable:!0,configurable:!0})}function P_(e,t,r){t in e?Ge(e,t,r):e[t]=r}function Pr(e,t,r,a){let n=xn(t);for(let i of r){let o=Object.getOwnPropertyDescriptor(n,i);o.enumerable&&(o.get?I_(e,i,()=>{let s=t._zod.def.shape[i];return a?a(s,i):s}):P_(e,i,a?a(o.value,i):o.value))}}function _1(e,t){for(let r of Reflect.ownKeys(t)){let a=Object.getOwnPropertyDescriptor(t,r);a.enumerable&&(a.get?I_(e,r,()=>t[r]):P_(e,r,a.value))}}function Nt(...e){let t={};for(let r of e){let a=Object.getOwnPropertyDescriptors(r);Object.assign(t,a)}return Object.defineProperties({},t)}function w1(e){return Nt(e._zod.def)}function S1(e,t){return t?t.reduce((r,a)=>r?.[a],e):e}function E1(e){let t=Object.keys(e),r=t.map(a=>e[a]);return Promise.all(r).then(a=>{let n={};for(let i=0;i<t.length;i++)n[t[i]]=a[i];return n})}function x1(e=10){let t="abcdefghijklmnopqrstuvwxyz",r="";for(let a=0;a<e;a++)r+=t[Math.floor(Math.random()*t.length)];return r}function lt(e){return JSON.stringify(e)}function sg(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}var Gl="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function Rr(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}var lg=_a(()=>{if(He.jitless||typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{let e=Function;return new e(""),!0}catch{return!1}});function Dt(e){if(Rr(e)===!1)return!1;let t=e.constructor;if(t===void 0||typeof t!="function")return!0;let r=t.prototype;return!(Rr(r)===!1||Object.prototype.hasOwnProperty.call(r,"isPrototypeOf")===!1)}function Sa(e){return Dt(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}function T1(e){let t=0;for(let r in e)Object.prototype.hasOwnProperty.call(e,r)&&t++;return t}var A1=e=>{let t=typeof e;switch(t){case"undefined":return"undefined";case"string":return"string";case"number":return Number.isNaN(e)?"nan":"number";case"boolean":return"boolean";case"function":return"function";case"bigint":return"bigint";case"symbol":return"symbol";case"object":return Array.isArray(e)?"array":e===null?"null":e.then&&typeof e.then=="function"&&e.catch&&typeof e.catch=="function"?"promise":typeof Map<"u"&&e instanceof Map?"map":typeof Set<"u"&&e instanceof Set?"set":typeof Date<"u"&&e instanceof Date?"date":typeof File<"u"&&e instanceof File?"file":"object";default:throw new Error(`Unknown data type: ${t}`)}},fo=new Set(["string","number","symbol"]),cg=new Set(["string","number","bigint","boolean","symbol","undefined"]);function Mt(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function ge(e,t,r){let a=new e._zod.constr(t??e._zod.def);return(!t||r?.parent)&&(a._zod.parent=e),a}function z(e){let t=e;if(!t)return{};if(typeof t=="string")return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw new Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error=="string"?{...t,error:()=>t.error}:t}function C1(e){let t;return new Proxy({},{get(r,a,n){return t??(t=e()),Reflect.get(t,a,n)},set(r,a,n,i){return t??(t=e()),Reflect.set(t,a,n,i)},has(r,a){return t??(t=e()),Reflect.has(t,a)},deleteProperty(r,a){return t??(t=e()),Reflect.deleteProperty(t,a)},ownKeys(r){return t??(t=e()),Reflect.ownKeys(t)},getOwnPropertyDescriptor(r,a){return t??(t=e()),Reflect.getOwnPropertyDescriptor(t,a)},defineProperty(r,a,n){return t??(t=e()),Reflect.defineProperty(t,a,n)}})}function x(e){return typeof e=="bigint"?e.toString()+"n":typeof e=="string"?`"${e}"`:`${e}`}function ug(e){return Object.keys(e).filter(t=>e[t]._zod.optin!==void 0&&e[t]._zod.optout==="optional")}var bo={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]},vo={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};function R_(e,t){let r=e._zod.def,a=r.checks;if(a&&a.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");let i={};return Pr(i,e,Vl(e,t)),ge(e,Nt(r,{shape:i,checks:[]}))}function Vl(e,t){let r=xn(e),a=[];for(let n of Reflect.ownKeys(t)){if(!Object.getOwnPropertyDescriptor(r,n)?.enumerable)throw new Error(`Unrecognized key: "${String(n)}"`);t[n]&&a.push(n)}return a}function $_(e,t){let r=e._zod.def,a=r.checks;if(a&&a.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");let i=new Set(Vl(e,t)),o={};return Pr(o,e,Reflect.ownKeys(xn(e)).filter(s=>!i.has(s))),ge(e,Nt(r,{shape:o,checks:[]}))}function j_(e,t){if(!Dt(t))throw new Error("Invalid input to extend: expected a plain object");let r=e._zod.def.checks;if(r&&r.length>0){let n=xn(e);for(let i of Reflect.ownKeys(t))if(Object.getOwnPropertyDescriptor(n,i)!==void 0)throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}return ge(e,Nt(e._zod.def,{shape:O_(e,t)}))}function O_(e,t){let r={};return Pr(r,e,Reflect.ownKeys(xn(e))),_1(r,t),r}function N_(e,t){if(!Dt(t))throw new Error("Invalid input to safeExtend: expected a plain object");return ge(e,Nt(e._zod.def,{shape:O_(e,t)}))}function D_(e,t){if(!t?._zod?.def)throw new Error("Invalid input to merge: expected an object schema. To merge a plain shape, use `.extend()`.");if(e._zod.def.checks?.length)throw new Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");let r={};Pr(r,e,Reflect.ownKeys(xn(e))),Pr(r,t,Reflect.ownKeys(xn(t)));let a=Nt(e._zod.def,{shape:r,get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]});return ge(e,a)}function M_(e,t,r,a="partial"){let i=t._zod.def.checks;if(i&&i.length>0)throw new Error(`.${a}() cannot be used on object schemas containing refinements`);let s=r?new Set(Vl(t,r)):void 0,l={};return Pr(l,t,Reflect.ownKeys(xn(t)),e&&((c,u)=>s&&!s.has(u)?c:new e({type:"optional",innerType:c}))),ge(t,Nt(t._zod.def,{shape:l,checks:[]}))}function L_(e,t,r){let a=r?new Set(Vl(t,r)):void 0,n={};return Pr(n,t,Reflect.ownKeys(xn(t)),(i,o)=>a&&!a.has(o)?i:new e({type:"nonoptional",innerType:i})),ge(t,Nt(t._zod.def,{shape:n}))}function ct(e,t=0){if(e.aborted===!0)return!0;for(let r=t;r<e.issues.length;r++)if(e.issues[r]?.continue!==!0)return!0;return!1}function dg(e,t=0){if(e.aborted===!0)return!0;for(let r=t;r<e.issues.length;r++)if(e.issues[r]?.continue===!1)return!0;return!1}function vt(e,t){return t.map(r=>{var a;return(a=r).path??(a.path=[]),r.path.unshift(e),r})}function va(e){return typeof e=="string"?e:e?.message}function Ea(e){let t=[];for(let r of e??[]){let a=r._zod.def;if(!/_(length|size)$|_equals$/.test(a.check))break;let n=a.maximum??a.length??a.size;n>=0&&t.push([n,r])}return t}function yo(e,t,r){var a;for(let n=t;n<e.length;n++)(a=e[n]).schema??(a.schema=r)}function yt(e,t,r){var a;let n=e.inst?._zod?.traits;n?.has("$ZodType")&&(n.has("$ZodCheck")?(a=e).schema??(a.schema=e.inst):e.schema=e.inst);let i=e.schema!==e.inst?e.schema?._zod.def?.error:void 0,o=e.message?e.message:va(e.inst?._zod.def?.error?.(e))??va(i?.(e))??va(t?.error?.(e))??va(r.customError?.(e))??va(r.localeError?.(e))??"Invalid input",s={};for(let l of Object.keys(e))l==="inst"||l==="schema"||l==="continue"||l==="input"||l==="__proto__"||(s[l]=e[l]);return s.path??(s.path=[]),s.message=o,t?.reportInput&&(s.input=e.input),s}function ko(e){return e instanceof Set?"set":e instanceof Map?"map":e instanceof File?"file":"unknown"}var z1=/[\uD800-\uDBFF]/;function $r(e){let t=e.length;if(!z1.test(e))return t;let r=t;for(let a=0;a<t-1;a++)(e.charCodeAt(a)&64512)===55296&&(e.charCodeAt(a+1)&64512)===56320&&(r--,a++);return r}function _o(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function T(e){let t=typeof e;switch(t){case"number":return Number.isNaN(e)?"nan":"number";case"object":{if(e===null)return"null";if(Array.isArray(e))return"array";let r=e;if(r&&Object.getPrototypeOf(r)!==Object.prototype&&"constructor"in r&&r.constructor)return r.constructor.name}}return t}function xa(...e){let[t,r,a]=e;return typeof t=="string"?{message:t,code:"custom",input:r,inst:a}:{...t}}function I1(e){return Object.entries(e).filter(([t,r])=>Number.isNaN(Number.parseInt(t,10))).map(t=>t[1])}function B_(e){let t=atob(e),r=new Uint8Array(t.length);for(let a=0;a<t.length;a++)r[a]=t.charCodeAt(a);return r}function U_(e){let t="";for(let r=0;r<e.length;r++)t+=String.fromCharCode(e[r]);return btoa(t)}function P1(e){let t=e.replace(/-/g,"+").replace(/_/g,"/"),r="=".repeat((4-t.length%4)%4);return B_(t+r)}function R1(e){return U_(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function $1(e){let t=e.replace(/^0x/,"");if(t.length%2!==0)throw new Error("Invalid hex string length");let r=new Uint8Array(t.length/2);for(let a=0;a<t.length;a+=2)r[a/2]=Number.parseInt(t.slice(a,a+2),16);return r}function j1(e){return Array.from(e).map(t=>t.toString(16).padStart(2,"0")).join("")}var ig=class{constructor(...t){}};function pg(e,t){for(let r in t){let a=Object.getOwnPropertyDescriptor(t,r);a.get?Object.defineProperty(e,r,{...a,enumerable:!1}):N1(e,r,a.value)}}function sn(e,t,r,a=!0){return Object.defineProperty(e,t,{configurable:!0,writable:!0,enumerable:a,value:r}),r}function wo(e,t,r){return sn(e,t,r,!1)}function O1(e,t){for(let r in e){let a=e[r];Object.defineProperty(t,r,{configurable:!0,enumerable:!0,get(){return sn(this,r,a(this))},set(n){sn(this,r,n)}})}return t}function N1(e,t,r){Object.defineProperty(e,t,{configurable:!0,get(){return this==null?r:sn(this,t,r.bind(this))},set(a){sn(this,t,a)}})}function D1(e,t){let r=Object.getPrototypeOf(e);return t in r?void 0:r}var rg,Xn=!1,M1={configurable:!0,get(){Xn=!0}};function ee(e,t,r){let a=Object.getPrototypeOf(e._zod);if(t in a&&rg!==e._zod){rg=void 0;return}rg=e._zod,Object.defineProperty(a,t,{configurable:!0,get(){Object.defineProperty(this,t,M1);let n=Xn;Xn=!1;try{let i=r(this);return Xn?delete this[t]:Object.defineProperty(this,t,{configurable:!0,writable:!0,value:i}),Xn=Xn||n,i}catch(i){throw delete this[t],Xn=Xn||n,i}},set(n){Object.defineProperty(this,t,{configurable:!0,writable:!0,value:n})}})}function mg(e,t,r,a){let n=D1(e,t);n&&Object.defineProperty(n,t,{configurable:!0,get(){let i={configurable:!0,writable:!0,enumerable:a,value:void 0};return Object.defineProperty(this,t,i),i.value=r(this),Object.defineProperty(this,t,i),i.value},set(i){Object.defineProperty(this,t,{configurable:!0,writable:!0,enumerable:a,value:i})}})}var Wl="~constantCatch";function gg(e){let t=()=>e;return t[Wl]=!0,t}var F_,fg=Object.freeze({status:"aborted"}),hg={value:void 0,enumerable:!1},q_="captureStackTrace"in Error?Error:null;function L1(e){let t=q_;if(t){let r=t.stackTraceLimit;if(typeof r=="number"){try{t.stackTraceLimit=0}catch{return q_=null,new e}try{return new e}finally{t.stackTraceLimit=r}}}return new e}function y(e,t,r,a){let n={};function i(m){this.def=m,this.constr=d,this.traits=new Set}i.prototype=n;let o=r,s=o&&new WeakSet;function l(m,p){if(m._zod){if(m._zod.traits.has(e))return}else{hg.value=new i(p);try{Object.defineProperty(m,"_zod",hg)}finally{hg.value=void 0}}if(m._zod.traits.add(e),t(m,p),s){let h=Object.getPrototypeOf(m),f=m._zod.constr.prototype,_=h;for(;_&&_!==f;)_=Object.getPrototypeOf(_);let b=_??h;s.has(b)||(s.add(b),pg(b,o))}let g=d.prototype;for(let h in g)Object.prototype.hasOwnProperty.call(g,h)&&(h in m||(m[h]=g[h].bind(m)))}let c=a?.Parent??Object;class u extends c{}Object.defineProperty(u,"name",{value:e});function d(m){let p=a?.Parent?L1(u):this;l(p,m);let g=p._zod.deferred;if(g){for(let f of g)f();p._zod.deferred=void 0}let h=globalThis.__zod_globalConfig?.postProcessor;return h&&h(p),p}return Object.defineProperty(d,"init",{value:l}),Object.defineProperty(d,Symbol.hasInstance,{value:m=>a?.Parent&&m instanceof a.Parent?!0:m?._zod?.traits?.has(e)}),Object.defineProperty(d,"name",{value:e}),d}var bg=Symbol("zod_brand"),kt=class extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}},Qn=class extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}};(F_=globalThis).__zod_globalConfig??(F_.__zod_globalConfig={});var He=globalThis.__zod_globalConfig;function Oe(e){return e&&Object.assign(He,e),He}function B1(){let e=this._zod;return e.message??(e.message=JSON.stringify(e.def,ka,2)),e.message}function U1(e){this._zod.message=e}var F1={get:B1,set:U1,enumerable:!0,configurable:!0},yg={value:void 0,enumerable:!1},H_=new WeakSet([Object.prototype,Error.prototype]),G_=(e,t)=>{e.name="$ZodError",yg.value=t,Object.defineProperty(e,"issues",yg),yg.value=void 0,Object.defineProperty(e,"message",F1);let r=Object.getPrototypeOf(e);H_.has(r)||(H_.add(r),Object.defineProperty(r,"toString",{configurable:!0,enumerable:!1,get(){let a=()=>this.message;return Object.defineProperty(this,"toString",{value:a,configurable:!0,writable:!0}),a},set(a){Object.defineProperty(this,"toString",{value:a,configurable:!0,writable:!0})}}))},kg=y("$ZodError",G_),_t=y("$ZodError",G_,void 0,{Parent:Error});function q1(e,t,r){return Object.prototype.hasOwnProperty.call(e,t)||(t==="__proto__"?Object.defineProperty(e,t,{value:r(),writable:!0,enumerable:!0,configurable:!0}):e[t]=r()),e[t]}function So(e,t=r=>r.message){let r={},a=[];for(let n of e.issues)n.path.length>0?q1(r,n.path[0],()=>[]).push(t(n)):a.push(t(n));return{formErrors:a,fieldErrors:r}}function Eo(e,t=r=>r.message){let r={_errors:[]},a=(n,i=[])=>{for(let o of n.issues)if(o.code==="invalid_union"&&o.errors.length)o.errors.map(s=>a({issues:s},[...i,...o.path]));else if(o.code==="invalid_key")a({issues:o.issues},[...i,...o.path]);else if(o.code==="invalid_element")a({issues:o.issues},[...i,...o.path]);else{let s=[...i,...o.path];if(s.length===0)r._errors.push(t(o));else{let l=r,c=0;for(;c<s.length;){let u=s[c],d=c===s.length-1;if(u==="_errors"){d&&l._errors.push(t(o)),c++;continue}Object.prototype.hasOwnProperty.call(l,u)||Object.defineProperty(l,u,{value:{_errors:[]},enumerable:!0,writable:!0,configurable:!0});let m=l[u];d&&m._errors.push(t(o)),l=m,c++}}}};return a(e),r}function _g(e,t=r=>r.message){let r={errors:[]},a=(n,i=[])=>{var o;for(let s of n.issues)if(s.code==="invalid_union"&&s.errors.length)s.errors.map(l=>a({issues:l},[...i,...s.path]));else if(s.code==="invalid_key")a({issues:s.issues},[...i,...s.path]);else if(s.code==="invalid_element")a({issues:s.issues},[...i,...s.path]);else{let l=[...i,...s.path];if(l.length===0){r.errors.push(t(s));continue}let c=r,u=0;for(;u<l.length;){let d=l[u],m=u===l.length-1;typeof d=="string"?(c.properties??(c.properties={}),Object.prototype.hasOwnProperty.call(c.properties,d)||Object.defineProperty(c.properties,d,{value:{errors:[]},enumerable:!0,writable:!0,configurable:!0}),c=c.properties[d]):(c.items??(c.items=[]),(o=c.items)[d]??(o[d]={errors:[]}),c=c.items[d]),m&&c.errors.push(t(s)),u++}}};return a(e),r}function V_(e){let t=[],r=e.map(a=>typeof a=="object"?a.key:a);for(let a of r)typeof a=="number"?t.push(`[${a}]`):typeof a=="symbol"?t.push(`[${JSON.stringify(String(a))}]`):/[^\w$]/.test(a)?t.push(`[${JSON.stringify(a)}]`):(t.length&&t.push("."),t.push(a));return t.join("")}function wg(e){let t=[],r=[...e.issues].sort((a,n)=>(a.path??[]).length-(n.path??[]).length);for(let a of r)t.push(`\u2716 ${a.message}`),a.path?.length&&t.push(` \u2192 at ${V_(a.path)}`);return t.join(`
|
|
9
|
+
deps: ${r}}`};var RU={keyword:"dependencies",type:"object",schemaType:"object",error:kn.error,code(e){let[t,r]=$U(e);WI(e,t),KI(e,r)}};function $U({schema:e}){let t={},r={};for(let a in e){if(a==="__proto__")continue;let n=Array.isArray(e[a])?t:r;n[a]=e[a]}return[t,r]}function WI(e,t=e.schema){let{gen:r,data:a,it:n}=e;if(Object.keys(t).length===0)return;let i=r.let("missing");for(let o in t){let s=t[o];if(s.length===0)continue;let l=(0,Ul.propertyInData)(r,a,o,n.opts.ownProperties);e.setParams({property:o,depsCount:s.length,deps:s.join(", ")}),n.allErrors?r.if(l,()=>{for(let c of s)(0,Ul.checkReportMissingProp)(e,c)}):(r.if((0,Gk._)`${l} && (${(0,Ul.checkMissingProp)(e,s,i)})`),(0,Ul.reportMissingProp)(e,i),r.else())}}kn.validatePropertyDeps=WI;function KI(e,t=e.schema){let{gen:r,data:a,keyword:n,it:i}=e,o=r.name("valid");for(let s in t)(0,PU.alwaysValidSchema)(i,t[s])||(r.if((0,Ul.propertyInData)(r,a,s,i.opts.ownProperties),()=>{let l=e.subschema({keyword:n,schemaProp:s},o);e.mergeValidEvaluated(l,o)},()=>r.var(o,!0)),e.ok(o))}kn.validateSchemaDeps=KI;kn.default=RU});var YI=j(Vk=>{"use strict";Object.defineProperty(Vk,"__esModule",{value:!0});var JI=ne(),jU=pe(),OU={message:"property name must be valid",params:({params:e})=>(0,JI._)`{propertyName: ${e.propertyName}}`},NU={keyword:"propertyNames",type:"object",schemaType:["object","boolean"],error:OU,code(e){let{gen:t,schema:r,data:a,it:n}=e;if((0,jU.alwaysValidSchema)(n,r))return;let i=t.name("valid");t.forIn("key",a,o=>{e.setParams({propertyName:o}),e.subschema({keyword:"propertyNames",data:o,dataTypes:["string"],propertyName:o,compositeRule:!0},i),t.if((0,JI.not)(i),()=>{e.error(!0),n.allErrors||t.break()})}),e.ok(i)}};Vk.default=NU});var Kk=j(Wk=>{"use strict";Object.defineProperty(Wk,"__esModule",{value:!0});var Um=qt(),rn=ne(),DU=Zn(),Fm=pe(),MU={message:"must NOT have additional properties",params:({params:e})=>(0,rn._)`{additionalProperty: ${e.additionalProperty}}`},LU={keyword:"additionalProperties",type:["object"],schemaType:["boolean","object"],allowUndefined:!0,trackErrors:!0,error:MU,code(e){let{gen:t,schema:r,parentSchema:a,data:n,errsCount:i,it:o}=e;if(!i)throw new Error("ajv implementation error");let{allErrors:s,opts:l}=o;if(o.props=!0,l.removeAdditional!=="all"&&(0,Fm.alwaysValidSchema)(o,r))return;let c=(0,Um.allSchemaProperties)(a.properties),u=(0,Um.allSchemaProperties)(a.patternProperties);d(),e.ok((0,rn._)`${i} === ${DU.default.errors}`);function d(){t.forIn("key",n,f=>{!c.length&&!u.length?g(f):t.if(m(f),()=>g(f))})}function m(f){let _;if(c.length>8){let b=(0,Fm.schemaRefOrVal)(o,a.properties,"properties");_=(0,Um.isOwnProperty)(t,b,f)}else c.length?_=(0,rn.or)(...c.map(b=>(0,rn._)`${f} === ${b}`)):_=rn.nil;return u.length&&(_=(0,rn.or)(_,...u.map(b=>(0,rn._)`${(0,Um.usePattern)(e,b)}.test(${f})`))),(0,rn.not)(_)}function p(f){t.code((0,rn._)`delete ${n}[${f}]`)}function g(f){if(l.removeAdditional==="all"||l.removeAdditional&&r===!1){p(f);return}if(r===!1){e.setParams({additionalProperty:f}),e.error(),s||t.break();return}if(typeof r=="object"&&!(0,Fm.alwaysValidSchema)(o,r)){let _=t.name("valid");l.removeAdditional==="failing"?(h(f,_,!1),t.if((0,rn.not)(_),()=>{e.reset(),p(f)})):(h(f,_),s||t.if((0,rn.not)(_),()=>t.break()))}}function h(f,_,b){let v={keyword:"additionalProperties",dataProp:f,dataPropType:Fm.Type.Str};b===!1&&Object.assign(v,{compositeRule:!0,createErrors:!1,allErrors:!1}),e.subschema(v,_)}}};Wk.default=LU});var eP=j(Jk=>{"use strict";Object.defineProperty(Jk,"__esModule",{value:!0});var BU=Tl(),XI=qt(),Zk=pe(),QI=Kk(),UU={keyword:"properties",type:"object",schemaType:"object",code(e){let{gen:t,schema:r,parentSchema:a,data:n,it:i}=e;i.opts.removeAdditional==="all"&&a.additionalProperties===void 0&&QI.default.code(new BU.KeywordCxt(i,QI.default,"additionalProperties"));let o=(0,XI.allSchemaProperties)(r);for(let d of o)i.definedProperties.add(d);i.opts.unevaluated&&o.length&&i.props!==!0&&(i.props=Zk.mergeEvaluated.props(t,(0,Zk.toHash)(o),i.props));let s=o.filter(d=>!(0,Zk.alwaysValidSchema)(i,r[d]));if(s.length===0)return;let l=t.name("valid");for(let d of s)c(d)?u(d):(t.if((0,XI.propertyInData)(t,n,d,i.opts.ownProperties)),u(d),i.allErrors||t.else().var(l,!0),t.endIf()),e.it.definedProperties.add(d),e.ok(l);function c(d){return i.opts.useDefaults&&!i.compositeRule&&r[d].default!==void 0}function u(d){e.subschema({keyword:"properties",schemaProp:d,dataProp:d},l)}}};Jk.default=UU});var aP=j(Yk=>{"use strict";Object.defineProperty(Yk,"__esModule",{value:!0});var tP=qt(),qm=ne(),nP=pe(),rP=pe(),FU={keyword:"patternProperties",type:"object",schemaType:"object",code(e){let{gen:t,schema:r,data:a,parentSchema:n,it:i}=e,{opts:o}=i,s=(0,tP.allSchemaProperties)(r),l=s.filter(h=>(0,nP.alwaysValidSchema)(i,r[h]));if(s.length===0||l.length===s.length&&(!i.opts.unevaluated||i.props===!0))return;let c=o.strictSchema&&!o.allowMatchingProperties&&n.properties,u=t.name("valid");i.props!==!0&&!(i.props instanceof qm.Name)&&(i.props=(0,rP.evaluatedPropsToName)(t,i.props));let{props:d}=i;m();function m(){for(let h of s)c&&p(h),i.allErrors?g(h):(t.var(u,!0),g(h),t.if(u))}function p(h){for(let f in c)new RegExp(h).test(f)&&(0,nP.checkStrictMode)(i,`property ${f} matches pattern ${h} (use allowMatchingProperties)`)}function g(h){t.forIn("key",a,f=>{t.if((0,qm._)`${(0,tP.usePattern)(e,h)}.test(${f})`,()=>{let _=l.includes(h);_||e.subschema({keyword:"patternProperties",schemaProp:h,dataProp:f,dataPropType:rP.Type.Str},u),i.opts.unevaluated&&d!==!0?t.assign((0,qm._)`${d}[${f}]`,!0):!_&&!i.allErrors&&t.if((0,qm.not)(u),()=>t.break())})})}}};Yk.default=FU});var iP=j(Xk=>{"use strict";Object.defineProperty(Xk,"__esModule",{value:!0});var qU=pe(),HU={keyword:"not",schemaType:["object","boolean"],trackErrors:!0,code(e){let{gen:t,schema:r,it:a}=e;if((0,qU.alwaysValidSchema)(a,r)){e.fail();return}let n=t.name("valid");e.subschema({keyword:"not",compositeRule:!0,createErrors:!1,allErrors:!1},n),e.failResult(n,()=>e.reset(),()=>e.error())},error:{message:"must NOT be valid"}};Xk.default=HU});var oP=j(Qk=>{"use strict";Object.defineProperty(Qk,"__esModule",{value:!0});var GU=qt(),VU={keyword:"anyOf",schemaType:"array",trackErrors:!0,code:GU.validateUnion,error:{message:"must match a schema in anyOf"}};Qk.default=VU});var sP=j(e_=>{"use strict";Object.defineProperty(e_,"__esModule",{value:!0});var Hm=ne(),WU=pe(),KU={message:"must match exactly one schema in oneOf",params:({params:e})=>(0,Hm._)`{passingSchemas: ${e.passing}}`},ZU={keyword:"oneOf",schemaType:"array",trackErrors:!0,error:KU,code(e){let{gen:t,schema:r,parentSchema:a,it:n}=e;if(!Array.isArray(r))throw new Error("ajv implementation error");if(n.opts.discriminator&&a.discriminator)return;let i=r,o=t.let("valid",!1),s=t.let("passing",null),l=t.name("_valid");e.setParams({passing:s}),t.block(c),e.result(o,()=>e.reset(),()=>e.error(!0));function c(){i.forEach((u,d)=>{let m;(0,WU.alwaysValidSchema)(n,u)?t.var(l,!0):m=e.subschema({keyword:"oneOf",schemaProp:d,compositeRule:!0},l),d>0&&t.if((0,Hm._)`${l} && ${o}`).assign(o,!1).assign(s,(0,Hm._)`[${s}, ${d}]`).else(),t.if(l,()=>{t.assign(o,!0),t.assign(s,d),m&&e.mergeEvaluated(m,Hm.Name)})})}}};e_.default=ZU});var lP=j(t_=>{"use strict";Object.defineProperty(t_,"__esModule",{value:!0});var JU=pe(),YU={keyword:"allOf",schemaType:"array",code(e){let{gen:t,schema:r,it:a}=e;if(!Array.isArray(r))throw new Error("ajv implementation error");let n=t.name("valid");r.forEach((i,o)=>{if((0,JU.alwaysValidSchema)(a,i))return;let s=e.subschema({keyword:"allOf",schemaProp:o},n);e.ok(n),e.mergeEvaluated(s)})}};t_.default=YU});var dP=j(n_=>{"use strict";Object.defineProperty(n_,"__esModule",{value:!0});var Gm=ne(),uP=pe(),XU={message:({params:e})=>(0,Gm.str)`must match "${e.ifClause}" schema`,params:({params:e})=>(0,Gm._)`{failingKeyword: ${e.ifClause}}`},QU={keyword:"if",schemaType:["object","boolean"],trackErrors:!0,error:XU,code(e){let{gen:t,parentSchema:r,it:a}=e;r.then===void 0&&r.else===void 0&&(0,uP.checkStrictMode)(a,'"if" without "then" and "else" is ignored');let n=cP(a,"then"),i=cP(a,"else");if(!n&&!i)return;let o=t.let("valid",!0),s=t.name("_valid");if(l(),e.reset(),n&&i){let u=t.let("ifClause");e.setParams({ifClause:u}),t.if(s,c("then",u),c("else",u))}else n?t.if(s,c("then")):t.if((0,Gm.not)(s),c("else"));e.pass(o,()=>e.error(!0));function l(){let u=e.subschema({keyword:"if",compositeRule:!0,createErrors:!1,allErrors:!1},s);e.mergeEvaluated(u)}function c(u,d){return()=>{let m=e.subschema({keyword:u},s);t.assign(o,s),e.mergeValidEvaluated(m,o),d?t.assign(d,(0,Gm._)`${u}`):e.setParams({ifClause:u})}}}};function cP(e,t){let r=e.schema[t];return r!==void 0&&!(0,uP.alwaysValidSchema)(e,r)}n_.default=QU});var pP=j(r_=>{"use strict";Object.defineProperty(r_,"__esModule",{value:!0});var eF=pe(),tF={keyword:["then","else"],schemaType:["object","boolean"],code({keyword:e,parentSchema:t,it:r}){t.if===void 0&&(0,eF.checkStrictMode)(r,`"${e}" without "if" is ignored`)}};r_.default=tF});var mP=j(a_=>{"use strict";Object.defineProperty(a_,"__esModule",{value:!0});var nF=Bk(),rF=qI(),aF=Uk(),iF=GI(),oF=VI(),sF=ZI(),lF=YI(),cF=Kk(),uF=eP(),dF=aP(),pF=iP(),mF=oP(),gF=sP(),hF=lP(),fF=dP(),bF=pP();function vF(e=!1){let t=[pF.default,mF.default,gF.default,hF.default,fF.default,bF.default,lF.default,cF.default,sF.default,uF.default,dF.default];return e?t.push(rF.default,iF.default):t.push(nF.default,aF.default),t.push(oF.default),t}a_.default=vF});var gP=j(i_=>{"use strict";Object.defineProperty(i_,"__esModule",{value:!0});var Me=ne(),yF={message:({schemaCode:e})=>(0,Me.str)`must match format "${e}"`,params:({schemaCode:e})=>(0,Me._)`{format: ${e}}`},kF={keyword:"format",type:["number","string"],schemaType:"string",$data:!0,error:yF,code(e,t){let{gen:r,data:a,$data:n,schema:i,schemaCode:o,it:s}=e,{opts:l,errSchemaPath:c,schemaEnv:u,self:d}=s;if(!l.validateFormats)return;n?m():p();function m(){let g=r.scopeValue("formats",{ref:d.formats,code:l.code.formats}),h=r.const("fDef",(0,Me._)`${g}[${o}]`),f=r.let("fType"),_=r.let("format");r.if((0,Me._)`typeof ${h} == "object" && !(${h} instanceof RegExp)`,()=>r.assign(f,(0,Me._)`${h}.type || "string"`).assign(_,(0,Me._)`${h}.validate`),()=>r.assign(f,(0,Me._)`"string"`).assign(_,h)),e.fail$data((0,Me.or)(b(),v()));function b(){return l.strictSchema===!1?Me.nil:(0,Me._)`${o} && !${_}`}function v(){let C=u.$async?(0,Me._)`(${h}.async ? await ${_}(${a}) : ${_}(${a}))`:(0,Me._)`${_}(${a})`,S=(0,Me._)`(typeof ${_} == "function" ? ${C} : ${_}.test(${a}))`;return(0,Me._)`${_} && ${_} !== true && ${f} === ${t} && !${S}`}}function p(){let g=d.formats[i];if(!g){b();return}if(g===!0)return;let[h,f,_]=v(g);h===t&&e.pass(C());function b(){if(l.strictSchema===!1){d.logger.warn(S());return}throw new Error(S());function S(){return`unknown format "${i}" ignored in schema at path "${c}"`}}function v(S){let P=S instanceof RegExp?(0,Me.regexpCode)(S):l.code.formats?(0,Me._)`${l.code.formats}${(0,Me.getProperty)(i)}`:void 0,U=r.scopeValue("formats",{key:i,ref:S,code:P});return typeof S=="object"&&!(S instanceof RegExp)?[S.type||"string",S.validate,(0,Me._)`${U}.validate`]:["string",S,U]}function C(){if(typeof g=="object"&&!(g instanceof RegExp)&&g.async){if(!u.$async)throw new Error("async format in sync schema");return(0,Me._)`await ${_}(${a})`}return typeof f=="function"?(0,Me._)`${_}(${a})`:(0,Me._)`${_}.test(${a})`}}}};i_.default=kF});var hP=j(o_=>{"use strict";Object.defineProperty(o_,"__esModule",{value:!0});var _F=gP(),wF=[_F.default];o_.default=wF});var fP=j(ao=>{"use strict";Object.defineProperty(ao,"__esModule",{value:!0});ao.contentVocabulary=ao.metadataVocabulary=void 0;ao.metadataVocabulary=["title","description","default","deprecated","readOnly","writeOnly","examples"];ao.contentVocabulary=["contentMediaType","contentEncoding","contentSchema"]});var vP=j(s_=>{"use strict";Object.defineProperty(s_,"__esModule",{value:!0});var SF=xI(),EF=LI(),xF=mP(),TF=hP(),bP=fP(),AF=[SF.default,EF.default,(0,xF.default)(),TF.default,bP.metadataVocabulary,bP.contentVocabulary];s_.default=AF});var kP=j(Vm=>{"use strict";Object.defineProperty(Vm,"__esModule",{value:!0});Vm.DiscrError=void 0;var yP;(function(e){e.Tag="tag",e.Mapping="mapping"})(yP||(Vm.DiscrError=yP={}))});var wP=j(c_=>{"use strict";Object.defineProperty(c_,"__esModule",{value:!0});var io=ne(),l_=kP(),_P=Am(),CF=Al(),zF=pe(),IF={message:({params:{discrError:e,tagName:t}})=>e===l_.DiscrError.Tag?`tag "${t}" must be string`:`value of tag "${t}" must be in oneOf`,params:({params:{discrError:e,tag:t,tagName:r}})=>(0,io._)`{error: ${e}, tag: ${r}, tagValue: ${t}}`},PF={keyword:"discriminator",type:"object",schemaType:"object",error:IF,code(e){let{gen:t,data:r,schema:a,parentSchema:n,it:i}=e,{oneOf:o}=n;if(!i.opts.discriminator)throw new Error("discriminator: requires discriminator option");let s=a.propertyName;if(typeof s!="string")throw new Error("discriminator: requires propertyName");if(a.mapping)throw new Error("discriminator: mapping is not supported");if(!o)throw new Error("discriminator: requires oneOf keyword");let l=t.let("valid",!1),c=t.const("tag",(0,io._)`${r}${(0,io.getProperty)(s)}`);t.if((0,io._)`typeof ${c} == "string"`,()=>u(),()=>e.error(!1,{discrError:l_.DiscrError.Tag,tag:c,tagName:s})),e.ok(l);function u(){let p=m();t.if(!1);for(let g in p)t.elseIf((0,io._)`${c} === ${g}`),t.assign(l,d(p[g]));t.else(),e.error(!1,{discrError:l_.DiscrError.Mapping,tag:c,tagName:s}),t.endIf()}function d(p){let g=t.name("valid"),h=e.subschema({keyword:"oneOf",schemaProp:p},g);return e.mergeEvaluated(h,io.Name),g}function m(){var p;let g={},h=_(n),f=!0;for(let C=0;C<o.length;C++){let S=o[C];if(S?.$ref&&!(0,zF.schemaHasRulesButRef)(S,i.self.RULES)){let U=S.$ref;if(S=_P.resolveRef.call(i.self,i.schemaEnv.root,i.baseId,U),S instanceof _P.SchemaEnv&&(S=S.schema),S===void 0)throw new CF.default(i.opts.uriResolver,i.baseId,U)}let P=(p=S?.properties)===null||p===void 0?void 0:p[s];if(typeof P!="object")throw new Error(`discriminator: oneOf subschemas (or referenced schemas) must have "properties/${s}"`);f=f&&(h||_(S)),b(P,C)}if(!f)throw new Error(`discriminator: "${s}" must be required`);return g;function _({required:C}){return Array.isArray(C)&&C.includes(s)}function b(C,S){if(C.const)v(C.const,S);else if(C.enum)for(let P of C.enum)v(P,S);else throw new Error(`discriminator: "properties/${s}" must have "const" or "enum"`)}function v(C,S){if(typeof C!="string"||C in g)throw new Error(`discriminator: "${s}" values must be unique strings`);g[C]=S}}}};c_.default=PF});var SP=j((pX,RF)=>{RF.exports={$schema:"http://json-schema.org/draft-07/schema#",$id:"http://json-schema.org/draft-07/schema#",title:"Core schema meta-schema",definitions:{schemaArray:{type:"array",minItems:1,items:{$ref:"#"}},nonNegativeInteger:{type:"integer",minimum:0},nonNegativeIntegerDefault0:{allOf:[{$ref:"#/definitions/nonNegativeInteger"},{default:0}]},simpleTypes:{enum:["array","boolean","integer","null","number","object","string"]},stringArray:{type:"array",items:{type:"string"},uniqueItems:!0,default:[]}},type:["object","boolean"],properties:{$id:{type:"string",format:"uri-reference"},$schema:{type:"string",format:"uri"},$ref:{type:"string",format:"uri-reference"},$comment:{type:"string"},title:{type:"string"},description:{type:"string"},default:!0,readOnly:{type:"boolean",default:!1},examples:{type:"array",items:!0},multipleOf:{type:"number",exclusiveMinimum:0},maximum:{type:"number"},exclusiveMaximum:{type:"number"},minimum:{type:"number"},exclusiveMinimum:{type:"number"},maxLength:{$ref:"#/definitions/nonNegativeInteger"},minLength:{$ref:"#/definitions/nonNegativeIntegerDefault0"},pattern:{type:"string",format:"regex"},additionalItems:{$ref:"#"},items:{anyOf:[{$ref:"#"},{$ref:"#/definitions/schemaArray"}],default:!0},maxItems:{$ref:"#/definitions/nonNegativeInteger"},minItems:{$ref:"#/definitions/nonNegativeIntegerDefault0"},uniqueItems:{type:"boolean",default:!1},contains:{$ref:"#"},maxProperties:{$ref:"#/definitions/nonNegativeInteger"},minProperties:{$ref:"#/definitions/nonNegativeIntegerDefault0"},required:{$ref:"#/definitions/stringArray"},additionalProperties:{$ref:"#"},definitions:{type:"object",additionalProperties:{$ref:"#"},default:{}},properties:{type:"object",additionalProperties:{$ref:"#"},default:{}},patternProperties:{type:"object",additionalProperties:{$ref:"#"},propertyNames:{format:"regex"},default:{}},dependencies:{type:"object",additionalProperties:{anyOf:[{$ref:"#"},{$ref:"#/definitions/stringArray"}]}},propertyNames:{$ref:"#"},const:!0,enum:{type:"array",items:!0,minItems:1,uniqueItems:!0},type:{anyOf:[{$ref:"#/definitions/simpleTypes"},{type:"array",items:{$ref:"#/definitions/simpleTypes"},minItems:1,uniqueItems:!0}]},format:{type:"string"},contentMediaType:{type:"string"},contentEncoding:{type:"string"},if:{$ref:"#"},then:{$ref:"#"},else:{$ref:"#"},allOf:{$ref:"#/definitions/schemaArray"},anyOf:{$ref:"#/definitions/schemaArray"},oneOf:{$ref:"#/definitions/schemaArray"},not:{$ref:"#"}},default:!0}});var d_=j((Re,u_)=>{"use strict";Object.defineProperty(Re,"__esModule",{value:!0});Re.MissingRefError=Re.ValidationError=Re.CodeGen=Re.Name=Re.nil=Re.stringify=Re.str=Re._=Re.KeywordCxt=Re.Ajv=void 0;var $F=yI(),jF=vP(),OF=wP(),EP=SP(),NF=["/properties"],Wm="http://json-schema.org/draft-07/schema",oo=class extends $F.default{_addVocabularies(){super._addVocabularies(),jF.default.forEach(t=>this.addVocabulary(t)),this.opts.discriminator&&this.addKeyword(OF.default)}_addDefaultMetaSchema(){if(super._addDefaultMetaSchema(),!this.opts.meta)return;let t=this.opts.$data?this.$dataMetaSchema(EP,NF):EP;this.addMetaSchema(t,Wm,!1),this.refs["http://json-schema.org/schema"]=Wm}defaultMeta(){return this.opts.defaultMeta=super.defaultMeta()||(this.getSchema(Wm)?Wm:void 0)}};Re.Ajv=oo;u_.exports=Re=oo;u_.exports.Ajv=oo;Object.defineProperty(Re,"__esModule",{value:!0});Re.default=oo;var DF=Tl();Object.defineProperty(Re,"KeywordCxt",{enumerable:!0,get:function(){return DF.KeywordCxt}});var so=ne();Object.defineProperty(Re,"_",{enumerable:!0,get:function(){return so._}});Object.defineProperty(Re,"str",{enumerable:!0,get:function(){return so.str}});Object.defineProperty(Re,"stringify",{enumerable:!0,get:function(){return so.stringify}});Object.defineProperty(Re,"nil",{enumerable:!0,get:function(){return so.nil}});Object.defineProperty(Re,"Name",{enumerable:!0,get:function(){return so.Name}});Object.defineProperty(Re,"CodeGen",{enumerable:!0,get:function(){return so.CodeGen}});var MF=xm();Object.defineProperty(Re,"ValidationError",{enumerable:!0,get:function(){return MF.default}});var LF=Al();Object.defineProperty(Re,"MissingRefError",{enumerable:!0,get:function(){return LF.default}})});var RP=j(wn=>{"use strict";Object.defineProperty(wn,"__esModule",{value:!0});wn.formatNames=wn.fastFormats=wn.fullFormats=void 0;function _n(e,t){return{validate:e,compare:t}}wn.fullFormats={date:_n(CP,h_),time:_n(m_(!0),f_),"date-time":_n(xP(!0),IP),"iso-time":_n(m_(),zP),"iso-date-time":_n(xP(),PP),duration:/^P(?!$)((\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+S)?)?|(\d+W)?)$/,uri:GF,"uri-reference":/^(?:[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,"uri-template":/^(?:(?:[^\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,url:/^(?:https?|ftp):\/\/(?:\S+(?::\S*)?@)?(?:(?!(?:10|127)(?:\.\d{1,3}){3})(?!(?:169\.254|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-z0-9\u{00a1}-\u{ffff}]+-)*[a-z0-9\u{00a1}-\u{ffff}]+)(?:\.(?:[a-z0-9\u{00a1}-\u{ffff}]+-)*[a-z0-9\u{00a1}-\u{ffff}]+)*(?:\.(?:[a-z\u{00a1}-\u{ffff}]{2,})))(?::\d{2,5})?(?:\/[^\s]*)?$/iu,email:/^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/i,hostname:/^(?=.{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,ipv4:/^(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)$/,ipv6:/^((([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,regex:XF,uuid:/^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i,"json-pointer":/^(?:\/(?:[^~/]|~0|~1)*)*$/,"json-pointer-uri-fragment":/^#(?:\/(?:[a-z0-9_\-.!$&'()*+,;:=@]|%[0-9a-f]{2}|~0|~1)*)*$/i,"relative-json-pointer":/^(?:0|[1-9][0-9]*)(?:#|(?:\/(?:[^~/]|~0|~1)*)*)$/,byte:VF,int32:{type:"number",validate:ZF},int64:{type:"number",validate:JF},float:{type:"number",validate:AP},double:{type:"number",validate:AP},password:!0,binary:!0};wn.fastFormats={...wn.fullFormats,date:_n(/^\d\d\d\d-[0-1]\d-[0-3]\d$/,h_),time:_n(/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)$/i,f_),"date-time":_n(/^\d\d\d\d-[0-1]\d-[0-3]\dt(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)$/i,IP),"iso-time":_n(/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)?$/i,zP),"iso-date-time":_n(/^\d\d\d\d-[0-1]\d-[0-3]\d[t\s](?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)?$/i,PP),uri:/^(?:[a-z][a-z0-9+\-.]*:)(?:\/?\/)?[^\s]*$/i,"uri-reference":/^(?:(?:[a-z][a-z0-9+\-.]*:)?\/?\/)?(?:[^\\\s#][^\s#]*)?(?:#[^\\\s]*)?$/i,email:/^[a-z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?)*$/i};wn.formatNames=Object.keys(wn.fullFormats);function BF(e){return e%4===0&&(e%100!==0||e%400===0)}var UF=/^(\d\d\d\d)-(\d\d)-(\d\d)$/,FF=[0,31,28,31,30,31,30,31,31,30,31,30,31];function CP(e){let t=UF.exec(e);if(!t)return!1;let r=+t[1],a=+t[2],n=+t[3];return a>=1&&a<=12&&n>=1&&n<=(a===2&&BF(r)?29:FF[a])}function h_(e,t){if(e&&t)return e>t?1:e<t?-1:0}var p_=/^(\d\d):(\d\d):(\d\d(?:\.\d+)?)(z|([+-])(\d\d)(?::?(\d\d))?)?$/i;function m_(e){return function(r){let a=p_.exec(r);if(!a)return!1;let n=+a[1],i=+a[2],o=+a[3],s=a[4],l=a[5]==="-"?-1:1,c=+(a[6]||0),u=+(a[7]||0);if(c>23||u>59||e&&!s)return!1;if(n<=23&&i<=59&&o<60)return!0;let d=i-u*l,m=n-c*l-(d<0?1:0);return(m===23||m===-1)&&(d===59||d===-1)&&o<61}}function f_(e,t){if(!(e&&t))return;let r=new Date("2020-01-01T"+e).valueOf(),a=new Date("2020-01-01T"+t).valueOf();if(r&&a)return r-a}function zP(e,t){if(!(e&&t))return;let r=p_.exec(e),a=p_.exec(t);if(r&&a)return e=r[1]+r[2]+r[3],t=a[1]+a[2]+a[3],e>t?1:e<t?-1:0}var g_=/t|\s/i;function xP(e){let t=m_(e);return function(a){let n=a.split(g_);return n.length===2&&CP(n[0])&&t(n[1])}}function IP(e,t){if(!(e&&t))return;let r=new Date(e).valueOf(),a=new Date(t).valueOf();if(r&&a)return r-a}function PP(e,t){if(!(e&&t))return;let[r,a]=e.split(g_),[n,i]=t.split(g_),o=h_(r,n);if(o!==void 0)return o||f_(a,i)}var qF=/\/|:/,HF=/^(?:[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 GF(e){return qF.test(e)&&HF.test(e)}var TP=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/gm;function VF(e){return TP.lastIndex=0,TP.test(e)}var WF=-(2**31),KF=2**31-1;function ZF(e){return Number.isInteger(e)&&e<=KF&&e>=WF}function JF(e){return Number.isInteger(e)}function AP(){return!0}var YF=/[^\\]\\Z/;function XF(e){if(YF.test(e))return!1;try{return new RegExp(e),!0}catch{return!1}}});var $P=j(lo=>{"use strict";Object.defineProperty(lo,"__esModule",{value:!0});lo.formatLimitDefinition=void 0;var QF=d_(),an=ne(),zr=an.operators,Km={formatMaximum:{okStr:"<=",ok:zr.LTE,fail:zr.GT},formatMinimum:{okStr:">=",ok:zr.GTE,fail:zr.LT},formatExclusiveMaximum:{okStr:"<",ok:zr.LT,fail:zr.GTE},formatExclusiveMinimum:{okStr:">",ok:zr.GT,fail:zr.LTE}},eq={message:({keyword:e,schemaCode:t})=>(0,an.str)`should be ${Km[e].okStr} ${t}`,params:({keyword:e,schemaCode:t})=>(0,an._)`{comparison: ${Km[e].okStr}, limit: ${t}}`};lo.formatLimitDefinition={keyword:Object.keys(Km),type:"string",schemaType:"string",$data:!0,error:eq,code(e){let{gen:t,data:r,schemaCode:a,keyword:n,it:i}=e,{opts:o,self:s}=i;if(!o.validateFormats)return;let l=new QF.KeywordCxt(i,s.RULES.all.format.definition,"format");l.$data?c():u();function c(){let m=t.scopeValue("formats",{ref:s.formats,code:o.code.formats}),p=t.const("fmt",(0,an._)`${m}[${l.schemaCode}]`);e.fail$data((0,an.or)((0,an._)`typeof ${p} != "object"`,(0,an._)`${p} instanceof RegExp`,(0,an._)`typeof ${p}.compare != "function"`,d(p)))}function u(){let m=l.schema,p=s.formats[m];if(!p||p===!0)return;if(typeof p!="object"||p instanceof RegExp||typeof p.compare!="function")throw new Error(`"${n}": format "${m}" does not define "compare" function`);let g=t.scopeValue("formats",{key:m,ref:p,code:o.code.formats?(0,an._)`${o.code.formats}${(0,an.getProperty)(m)}`:void 0});e.fail$data(d(g))}function d(m){return(0,an._)`${m}.compare(${r}, ${a}) ${Km[n].fail} 0`}},dependencies:["format"]};var tq=e=>(e.addKeyword(lo.formatLimitDefinition),e);lo.default=tq});var DP=j((Fl,NP)=>{"use strict";Object.defineProperty(Fl,"__esModule",{value:!0});var co=RP(),nq=$P(),b_=ne(),jP=new b_.Name("fullFormats"),rq=new b_.Name("fastFormats"),v_=(e,t={keywords:!0})=>{if(Array.isArray(t))return OP(e,t,co.fullFormats,jP),e;let[r,a]=t.mode==="fast"?[co.fastFormats,rq]:[co.fullFormats,jP],n=t.formats||co.formatNames;return OP(e,n,r,a),t.keywords&&(0,nq.default)(e),e};v_.get=(e,t="full")=>{let a=(t==="fast"?co.fastFormats:co.fullFormats)[e];if(!a)throw new Error(`Unknown format "${e}"`);return a};function OP(e,t,r,a){var n,i;(n=(i=e.opts.code).formats)!==null&&n!==void 0||(i.formats=(0,b_._)`require("ajv-formats/dist/formats").${a}`);for(let o of t)e.addFormat(o,r[o])}NP.exports=Fl=v_;Object.defineProperty(Fl,"__esModule",{value:!0});Fl.default=v_});import{createServer as Uq}from"node:http";import Xx from"node:process";var H={};En(H,{$brand:()=>bg,$input:()=>Bh,$output:()=>Lh,INVALID:()=>ut,NEVER:()=>fg,TimePrecision:()=>Kh,ZodAny:()=>sb,ZodArray:()=>db,ZodBase64:()=>Hd,ZodBase64URL:()=>Gd,ZodBigInt:()=>pi,ZodBigIntFormat:()=>Kd,ZodBoolean:()=>di,ZodCIDRv4:()=>Fd,ZodCIDRv6:()=>qd,ZodCUID:()=>Od,ZodCUID2:()=>Nd,ZodCatch:()=>Ib,ZodCodec:()=>Es,ZodCompileAsyncError:()=>Vt,ZodCompileUnsupportedError:()=>se,ZodCreditCard:()=>nb,ZodCustom:()=>xs,ZodCustomStringFormat:()=>Vr,ZodDate:()=>ys,ZodDefault:()=>Eb,ZodDiscriminatedUnion:()=>mb,ZodE164:()=>Vd,ZodEmail:()=>Pd,ZodEmoji:()=>$d,ZodEnum:()=>li,ZodError:()=>h0,ZodExactOptional:()=>Yd,ZodFile:()=>kb,ZodFirstPartyTypeKind:()=>Hb,ZodFunction:()=>Bb,ZodGUID:()=>Rd,ZodIBAN:()=>rb,ZodIPv4:()=>Bd,ZodIPv6:()=>Ud,ZodISODate:()=>cr,ZodISODateTime:()=>lr,ZodISODuration:()=>dr,ZodISOTime:()=>ur,ZodInstanceOf:()=>qb,ZodIntersection:()=>gb,ZodIssueCode:()=>v0,ZodJWT:()=>Wd,ZodKSUID:()=>Ld,ZodLazy:()=>Db,ZodLiteral:()=>yb,ZodMAC:()=>tb,ZodMap:()=>bb,ZodNaN:()=>Rb,ZodNanoID:()=>jd,ZodNever:()=>cb,ZodNonOptional:()=>Xd,ZodNull:()=>ob,ZodNullable:()=>Sb,ZodNumber:()=>ui,ZodNumberFormat:()=>Wr,ZodObject:()=>ks,ZodOptional:()=>Kr,ZodPipe:()=>Ss,ZodPrefault:()=>Tb,ZodPreprocess:()=>$b,ZodPromise:()=>Lb,ZodReadonly:()=>jb,ZodRealError:()=>wt,ZodRecord:()=>si,ZodSet:()=>vb,ZodString:()=>ci,ZodStringFormat:()=>Se,ZodSuccess:()=>zb,ZodSymbol:()=>ab,ZodTemplateLiteral:()=>Nb,ZodTransform:()=>_b,ZodTuple:()=>hb,ZodType:()=>Y,ZodULID:()=>Dd,ZodURL:()=>bs,ZodUUID:()=>dn,ZodUndefined:()=>ib,ZodUnion:()=>_s,ZodUnknown:()=>lb,ZodVoid:()=>ub,ZodXID:()=>Md,ZodXor:()=>pb,_ZodString:()=>Id,_default:()=>xb,_function:()=>vx,any:()=>QE,array:()=>ae,base64:()=>$E,base64url:()=>jE,bigint:()=>KE,boolean:()=>De,catch:()=>Pb,check:()=>yx,cidrv4:()=>PE,cidrv6:()=>RE,clone:()=>ge,codec:()=>gx,coerce:()=>Vb,compile:()=>Hh,config:()=>Oe,core:()=>Kt,creditCard:()=>NE,cuid:()=>SE,cuid2:()=>EE,currencyCode:()=>FE,custom:()=>Qd,date:()=>tx,decode:()=>Kf,decodeAsync:()=>Jf,deepPartial:()=>Px,describe:()=>kx,discriminatedUnion:()=>ws,e164:()=>OE,email:()=>mE,emoji:()=>_E,encode:()=>Wf,encodeAsync:()=>Zf,endsWith:()=>Ja,enum:()=>Ke,exactOptional:()=>wb,file:()=>ux,flattenError:()=>So,float32:()=>HE,float64:()=>GE,formatError:()=>Eo,fromJSONSchema:()=>zx,function:()=>vx,getDiscriminatedOption:()=>Oh,getErrorMap:()=>k0,globalRegistry:()=>Ve,gt:()=>cn,gte:()=>It,guid:()=>gE,hash:()=>qE,hex:()=>UE,hostname:()=>BE,httpUrl:()=>kE,iban:()=>DE,includes:()=>Ka,input:()=>$x,instanceof:()=>wx,int:()=>Cd,int32:()=>VE,int64:()=>ZE,intersection:()=>mi,invertCodec:()=>hx,ipv4:()=>CE,ipv6:()=>IE,iso:()=>Zr,json:()=>Ex,jwt:()=>ME,keyof:()=>nx,ksuid:()=>AE,lazy:()=>Mb,length:()=>qr,literal:()=>B,locales:()=>Fa,looseObject:()=>We,looseRecord:()=>ox,lowercase:()=>Va,lt:()=>ln,lte:()=>zt,mac:()=>zE,map:()=>sx,maxLength:()=>Fr,maxSize:()=>rr,memoizer:()=>Uo,meta:()=>_x,mime:()=>Xa,minLength:()=>Cn,minSize:()=>un,multipleOf:()=>nr,nan:()=>mx,nanoid:()=>wE,nativeEnum:()=>cx,negative:()=>dd,never:()=>Zd,nonnegative:()=>md,nonoptional:()=>Cb,nonpositive:()=>pd,normalize:()=>Qa,null:()=>vs,nullable:()=>fs,nullish:()=>dx,number:()=>he,object:()=>O,optional:()=>we,output:()=>jx,overwrite:()=>Wt,parse:()=>qf,parseAsync:()=>Hf,partialRecord:()=>ix,pipe:()=>zd,positive:()=>ud,prefault:()=>Ab,preprocess:()=>Ts,prettifyError:()=>wg,promise:()=>bx,properties:()=>Ya,property:()=>gd,readonly:()=>Ob,record:()=>Ee,refine:()=>Ub,regex:()=>Ga,regexes:()=>Ct,registry:()=>Du,safeDecode:()=>Xf,safeDecodeAsync:()=>eb,safeEncode:()=>Yf,safeEncodeAsync:()=>Qf,safeParse:()=>Gf,safeParseAsync:()=>Vf,set:()=>lx,setErrorMap:()=>y0,size:()=>Ur,slugify:()=>ri,startsWith:()=>Za,strictObject:()=>rx,string:()=>w,stringFormat:()=>LE,stringbool:()=>Sx,success:()=>px,superRefine:()=>Fb,symbol:()=>YE,templateLiteral:()=>fx,toJSONSchema:()=>Hr,toLowerCase:()=>ti,toUpperCase:()=>ni,toZod:()=>go,transform:()=>Jd,treeifyError:()=>_g,trim:()=>ei,tuple:()=>fb,uint32:()=>WE,uint64:()=>JE,ulid:()=>xE,undefined:()=>XE,union:()=>ye,unknown:()=>xe,uppercase:()=>Wa,url:()=>yE,util:()=>E,uuid:()=>hE,uuidv4:()=>fE,uuidv6:()=>bE,uuidv7:()=>vE,validate:()=>Ra,validateAsync:()=>$a,void:()=>ex,withParser:()=>Mu,xid:()=>TE,xor:()=>ax});var Kt={};En(Kt,{$ZodAny:()=>Yc,$ZodArray:()=>nu,$ZodAsyncError:()=>kt,$ZodBase64:()=>Oc,$ZodBase64URL:()=>Dc,$ZodBigInt:()=>Oo,$ZodBigIntFormat:()=>Wc,$ZodBoolean:()=>Na,$ZodCIDRv4:()=>Pc,$ZodCIDRv6:()=>$c,$ZodCUID:()=>Sc,$ZodCUID2:()=>Ec,$ZodCatch:()=>ku,$ZodCheck:()=>_e,$ZodCheckBigIntFormat:()=>lh,$ZodCheckEndsWith:()=>kh,$ZodCheckGreaterThan:()=>lc,$ZodCheckIncludes:()=>vh,$ZodCheckLengthEquals:()=>gh,$ZodCheckLessThan:()=>sc,$ZodCheckLowerCase:()=>fh,$ZodCheckMaxLength:()=>ph,$ZodCheckMaxSize:()=>ch,$ZodCheckMimeType:()=>Sh,$ZodCheckMinLength:()=>mh,$ZodCheckMinSize:()=>uh,$ZodCheckMultipleOf:()=>oh,$ZodCheckNumberFormat:()=>sh,$ZodCheckOverwrite:()=>Eh,$ZodCheckProperties:()=>wh,$ZodCheckProperty:()=>_h,$ZodCheckRegex:()=>hh,$ZodCheckSizeEquals:()=>dh,$ZodCheckStartsWith:()=>yh,$ZodCheckStringFormat:()=>ja,$ZodCheckUpperCase:()=>bh,$ZodCodec:()=>Ma,$ZodCreditCard:()=>Bc,$ZodCustom:()=>Tu,$ZodCustomStringFormat:()=>Gc,$ZodCyclicError:()=>Iu,$ZodDate:()=>tu,$ZodDefault:()=>fu,$ZodDiscriminatedUnion:()=>iu,$ZodE164:()=>Mc,$ZodEmail:()=>fc,$ZodEmoji:()=>_c,$ZodEncodeError:()=>Qn,$ZodEnum:()=>uu,$ZodError:()=>kg,$ZodExactOptional:()=>gu,$ZodFile:()=>pu,$ZodFunction:()=>Eu,$ZodGUID:()=>gc,$ZodIBAN:()=>Fc,$ZodIPv4:()=>Cc,$ZodIPv6:()=>zc,$ZodISODate:()=>Ih,$ZodISODateTime:()=>zh,$ZodISODuration:()=>Rh,$ZodISOTime:()=>Ph,$ZodIntersection:()=>ou,$ZodJWT:()=>Hc,$ZodKSUID:()=>Ac,$ZodLazy:()=>La,$ZodLiteral:()=>du,$ZodMAC:()=>Ic,$ZodMap:()=>lu,$ZodNaN:()=>_u,$ZodNanoID:()=>wc,$ZodNever:()=>Qc,$ZodNonOptional:()=>vu,$ZodNull:()=>Jc,$ZodNullable:()=>hu,$ZodNumber:()=>jo,$ZodNumberFormat:()=>Vc,$ZodObject:()=>ru,$ZodObjectJIT:()=>jh,$ZodOptional:()=>Do,$ZodPipe:()=>Mo,$ZodPrefault:()=>bu,$ZodPreprocess:()=>Nh,$ZodPromise:()=>xu,$ZodReadonly:()=>wu,$ZodRealError:()=>_t,$ZodRecord:()=>su,$ZodRegistry:()=>Nu,$ZodSet:()=>cu,$ZodString:()=>er,$ZodStringFormat:()=>be,$ZodSuccess:()=>yu,$ZodSymbol:()=>Kc,$ZodTemplateLiteral:()=>Su,$ZodTransform:()=>mu,$ZodTuple:()=>No,$ZodType:()=>Z,$ZodULID:()=>xc,$ZodURL:()=>kc,$ZodUUID:()=>hc,$ZodUndefined:()=>Zc,$ZodUnion:()=>Da,$ZodUnknown:()=>Xc,$ZodVoid:()=>eu,$ZodXID:()=>Tc,$ZodXor:()=>au,$brand:()=>bg,$constructor:()=>y,$input:()=>Bh,$output:()=>Lh,Doc:()=>Dr,INVALID:()=>ut,JSONSchema:()=>uE,JSONSchemaGenerator:()=>xd,NEVER:()=>fg,TimePrecision:()=>Kh,URL_BAD_FORMAT:()=>Ah,URL_UNPARSEABLE:()=>zo,ZodCompileAsyncError:()=>Vt,ZodCompileUnsupportedError:()=>se,_any:()=>ad,_array:()=>Qh,_base64:()=>os,_base64url:()=>ss,_bigint:()=>Xu,_boolean:()=>Yu,_catch:()=>r0,_check:()=>KS,_cidrv4:()=>as,_cidrv6:()=>is,_coercedBigint:()=>Yh,_coercedBoolean:()=>Jh,_coercedDate:()=>Xh,_coercedNumber:()=>Zh,_coercedString:()=>Wh,_creditCard:()=>qu,_cuid:()=>Yo,_cuid2:()=>Xo,_custom:()=>fd,_date:()=>ld,_decode:()=>Jl,_decodeAsync:()=>Xl,_default:()=>e0,_discriminatedUnion:()=>F2,_e164:()=>ls,_email:()=>qo,_emoji:()=>Zo,_encode:()=>Zl,_encodeAsync:()=>Yl,_endsWith:()=>Ja,_enum:()=>K2,_file:()=>hd,_float32:()=>Wu,_float64:()=>Ku,_gt:()=>cn,_gte:()=>It,_guid:()=>Ho,_iban:()=>Hu,_includes:()=>Ka,_int:()=>Vu,_int32:()=>Zu,_int64:()=>Qu,_intersection:()=>q2,_ipv4:()=>ns,_ipv6:()=>rs,_isoDate:()=>ds,_isoDateTime:()=>us,_isoDuration:()=>ms,_isoTime:()=>ps,_jwt:()=>cs,_ksuid:()=>ts,_lazy:()=>s0,_length:()=>qr,_literal:()=>J2,_lowercase:()=>Va,_lt:()=>ln,_lte:()=>zt,_mac:()=>Fu,_map:()=>V2,_max:()=>zt,_maxLength:()=>Fr,_maxSize:()=>rr,_mime:()=>Xa,_min:()=>It,_minLength:()=>Cn,_minSize:()=>un,_multipleOf:()=>nr,_nan:()=>cd,_nanoid:()=>Jo,_nativeEnum:()=>Z2,_negative:()=>dd,_never:()=>od,_nonnegative:()=>md,_nonoptional:()=>t0,_nonpositive:()=>pd,_normalize:()=>Qa,_null:()=>rd,_nullable:()=>Q2,_number:()=>Gu,_optional:()=>X2,_overwrite:()=>Wt,_parse:()=>Ta,_parseAsync:()=>Aa,_pipe:()=>a0,_positive:()=>ud,_promise:()=>l0,_properties:()=>Ya,_property:()=>gd,_readonly:()=>i0,_record:()=>G2,_refine:()=>bd,_regex:()=>Ga,_safeDecode:()=>ec,_safeDecodeAsync:()=>nc,_safeEncode:()=>Ql,_safeEncodeAsync:()=>tc,_safeParse:()=>Ca,_safeParseAsync:()=>Ia,_set:()=>W2,_size:()=>Ur,_slugify:()=>ri,_startsWith:()=>Za,_string:()=>Uu,_stringFormat:()=>ar,_stringbool:()=>_d,_success:()=>n0,_superRefine:()=>vd,_symbol:()=>td,_templateLiteral:()=>o0,_toLowerCase:()=>ti,_toUpperCase:()=>ni,_transform:()=>Y2,_trim:()=>ei,_tuple:()=>H2,_uint32:()=>Ju,_uint64:()=>ed,_ulid:()=>Qo,_undefined:()=>nd,_union:()=>B2,_unknown:()=>id,_uppercase:()=>Wa,_url:()=>Ha,_uuid:()=>Go,_uuidv4:()=>Vo,_uuidv6:()=>Wo,_uuidv7:()=>Ko,_void:()=>sd,_xid:()=>es,_xor:()=>U2,base64Charset:()=>jc,base64urlCharset:()=>$o,canParseURL:()=>Ch,clone:()=>ge,compile:()=>Hh,compileFn:()=>Lu,config:()=>Oe,createStandardJSONSchemaMethod:()=>ai,createToJSONSchemaMethod:()=>tf,decode:()=>Z_,decodeAsync:()=>Y_,describe:()=>yd,encode:()=>K_,encodeAsync:()=>J_,extractDefs:()=>or,finalize:()=>sr,flattenError:()=>So,formatError:()=>Eo,getDiscriminatedOption:()=>Oh,globalConfig:()=>He,globalRegistry:()=>Ve,handleUnrepresentable:()=>Be,initializeContext:()=>ir,isBackEdge:()=>Ru,isRecursiveSchema:()=>Pu,isValidBase64:()=>Ro,isValidBase64URL:()=>Nc,isValidCIDRv6:()=>Rc,isValidCreditCard:()=>Lc,isValidIBAN:()=>Uc,isValidIPv6:()=>Po,isValidJWT:()=>qc,locales:()=>Fa,memoizer:()=>Uo,mergeValues:()=>Oa,meta:()=>kd,parse:()=>jr,parseAsync:()=>Or,parseURLObject:()=>_w,prettifyError:()=>wg,process:()=>ve,processSchema:()=>ve,regexes:()=>Ct,registry:()=>Du,safeDecode:()=>Q_,safeDecodeAsync:()=>tw,safeEncode:()=>X_,safeEncodeAsync:()=>ew,safeParse:()=>za,safeParseAsync:()=>Pa,standardProps:()=>mc,stripTabAndNewline:()=>Io,toDotPath:()=>V_,toJSONSchema:()=>Hr,toZod:()=>go,treeifyError:()=>_g,urlHostnameOk:()=>vc,urlProtocolOk:()=>yc,util:()=>E,validate:()=>Ra,validateAsync:()=>$a,validateURL:()=>bc,version:()=>xh,withParser:()=>Mu});var E={};En(E,{BIGINT_FORMAT_RANGES:()=>vo,CONSTANT_CATCH:()=>Wl,Class:()=>ig,NUMBER_FORMAT_RANGES:()=>bo,aborted:()=>ct,allowsEval:()=>lg,assert:()=>y1,assertEqual:()=>h1,assertIs:()=>b1,assertNever:()=>v1,assertNotEqual:()=>f1,assignProp:()=>Ge,attachSchema:()=>yo,base64ToUint8Array:()=>B_,base64urlToUint8Array:()=>P1,cached:()=>_a,captureStackTrace:()=>Gl,cleanEnum:()=>I1,cleanRegex:()=>Tn,clone:()=>ge,cloneDef:()=>w1,codePointLength:()=>$r,constantCatch:()=>gg,createTransparentProxy:()=>C1,defineLazy:()=>og,defineLazyInternal:()=>ee,derived:()=>O1,esc:()=>lt,escapeRegex:()=>Mt,explicitlyAborted:()=>dg,extend:()=>j_,finalizeIssue:()=>yt,floatSafeRemainder:()=>ho,getElementAtPath:()=>S1,getEnumValues:()=>ya,getLengthableOrigin:()=>_o,getParsedType:()=>A1,getSizableOrigin:()=>ko,hexToUint8Array:()=>$1,hide:()=>wo,installLazyProp:()=>mg,isObject:()=>Rr,isPlainObject:()=>Dt,issue:()=>xa,joinValues:()=>k,jsonStringifyReplacer:()=>ka,members:()=>pg,merge:()=>D_,mergeDefs:()=>Nt,normalizeParams:()=>z,nullish:()=>Hl,numKeys:()=>T1,objectClone:()=>k1,omit:()=>$_,optionalKeys:()=>ug,own:()=>sn,parsedType:()=>T,partial:()=>M_,pick:()=>R_,prefixIssues:()=>vt,primitiveTypes:()=>cg,promiseAllObject:()=>E1,propertyKeyTypes:()=>fo,randomString:()=>x1,rawShape:()=>wa,required:()=>L_,safeExtend:()=>N_,shallowClone:()=>Sa,sizeCaps:()=>Ea,slugify:()=>sg,stringifyPrimitive:()=>x,toZod:()=>go,uint8ArrayToBase64:()=>U_,uint8ArrayToBase64url:()=>R1,uint8ArrayToHex:()=>j1,unwrapMessage:()=>va});function h1(e){return e}function f1(e){return e}function go(){return e=>e}function b1(e){}function v1(e){throw new Error("Unexpected value in exhaustive check")}function y1(e){}function ya(e){let t=Object.values(e).filter(a=>typeof a=="number");return Object.entries(e).filter(([a,n])=>t.indexOf(+a)===-1).map(([a,n])=>n)}function k(e,t="|"){return e.map(r=>x(r)).join(t)}function ka(e,t){return typeof t=="bigint"?t.toString():t}var ag=class{constructor(t){this._getter=t,this._value=void 0}get value(){let t=this._getter;return t!==void 0&&(this._value=t(),this._getter=void 0),this._value}};function _a(e){return new ag(e)}function Hl(e){return e==null}function Tn(e){let t=e.startsWith("^")?1:0,r=e.endsWith("$")?e.length-1:e.length;return e.slice(t,r)}function ho(e,t){let r=e/t,a=Math.round(r),n=4*Number.EPSILON*Math.max(Math.abs(r),1);return Math.abs(r-a)<n?0:r-a}var z_=Symbol("evaluating");function og(e,t,r){let a;Object.defineProperty(e,t,{get(){if(a!==z_)return a===void 0&&(a=z_,a=r()),a},set(n){Object.defineProperty(e,t,{value:n})},configurable:!0})}function k1(e){return Object.create(Object.getPrototypeOf(e),Object.getOwnPropertyDescriptors(e))}function Ge(e,t,r){Object.defineProperty(e,t,{value:r,writable:!0,enumerable:!0,configurable:!0})}function wa(e){let t=Object.getOwnPropertyDescriptor(e,"shape");return t?.get?t.get.raw:t?.value}function xn(e){return wa(e._zod.def)??e._zod.def.shape}function I_(e,t,r){Object.defineProperty(e,t,{get(){let a=r();return Ge(this,t,a),a},enumerable:!0,configurable:!0})}function P_(e,t,r){t in e?Ge(e,t,r):e[t]=r}function Pr(e,t,r,a){let n=xn(t);for(let i of r){let o=Object.getOwnPropertyDescriptor(n,i);o.enumerable&&(o.get?I_(e,i,()=>{let s=t._zod.def.shape[i];return a?a(s,i):s}):P_(e,i,a?a(o.value,i):o.value))}}function _1(e,t){for(let r of Reflect.ownKeys(t)){let a=Object.getOwnPropertyDescriptor(t,r);a.enumerable&&(a.get?I_(e,r,()=>t[r]):P_(e,r,a.value))}}function Nt(...e){let t={};for(let r of e){let a=Object.getOwnPropertyDescriptors(r);Object.assign(t,a)}return Object.defineProperties({},t)}function w1(e){return Nt(e._zod.def)}function S1(e,t){return t?t.reduce((r,a)=>r?.[a],e):e}function E1(e){let t=Object.keys(e),r=t.map(a=>e[a]);return Promise.all(r).then(a=>{let n={};for(let i=0;i<t.length;i++)n[t[i]]=a[i];return n})}function x1(e=10){let t="abcdefghijklmnopqrstuvwxyz",r="";for(let a=0;a<e;a++)r+=t[Math.floor(Math.random()*t.length)];return r}function lt(e){return JSON.stringify(e)}function sg(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}var Gl="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function Rr(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}var lg=_a(()=>{if(He.jitless||typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{let e=Function;return new e(""),!0}catch{return!1}});function Dt(e){if(Rr(e)===!1)return!1;let t=e.constructor;if(t===void 0||typeof t!="function")return!0;let r=t.prototype;return!(Rr(r)===!1||Object.prototype.hasOwnProperty.call(r,"isPrototypeOf")===!1)}function Sa(e){return Dt(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}function T1(e){let t=0;for(let r in e)Object.prototype.hasOwnProperty.call(e,r)&&t++;return t}var A1=e=>{let t=typeof e;switch(t){case"undefined":return"undefined";case"string":return"string";case"number":return Number.isNaN(e)?"nan":"number";case"boolean":return"boolean";case"function":return"function";case"bigint":return"bigint";case"symbol":return"symbol";case"object":return Array.isArray(e)?"array":e===null?"null":e.then&&typeof e.then=="function"&&e.catch&&typeof e.catch=="function"?"promise":typeof Map<"u"&&e instanceof Map?"map":typeof Set<"u"&&e instanceof Set?"set":typeof Date<"u"&&e instanceof Date?"date":typeof File<"u"&&e instanceof File?"file":"object";default:throw new Error(`Unknown data type: ${t}`)}},fo=new Set(["string","number","symbol"]),cg=new Set(["string","number","bigint","boolean","symbol","undefined"]);function Mt(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function ge(e,t,r){let a=new e._zod.constr(t??e._zod.def);return(!t||r?.parent)&&(a._zod.parent=e),a}function z(e){let t=e;if(!t)return{};if(typeof t=="string")return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw new Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error=="string"?{...t,error:()=>t.error}:t}function C1(e){let t;return new Proxy({},{get(r,a,n){return t??(t=e()),Reflect.get(t,a,n)},set(r,a,n,i){return t??(t=e()),Reflect.set(t,a,n,i)},has(r,a){return t??(t=e()),Reflect.has(t,a)},deleteProperty(r,a){return t??(t=e()),Reflect.deleteProperty(t,a)},ownKeys(r){return t??(t=e()),Reflect.ownKeys(t)},getOwnPropertyDescriptor(r,a){return t??(t=e()),Reflect.getOwnPropertyDescriptor(t,a)},defineProperty(r,a,n){return t??(t=e()),Reflect.defineProperty(t,a,n)}})}function x(e){return typeof e=="bigint"?e.toString()+"n":typeof e=="string"?`"${e}"`:`${e}`}function ug(e){return Object.keys(e).filter(t=>e[t]._zod.optin!==void 0&&e[t]._zod.optout==="optional")}var bo={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]},vo={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};function R_(e,t){let r=e._zod.def,a=r.checks;if(a&&a.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");let i={};return Pr(i,e,Vl(e,t)),ge(e,Nt(r,{shape:i,checks:[]}))}function Vl(e,t){let r=xn(e),a=[];for(let n of Reflect.ownKeys(t)){if(!Object.getOwnPropertyDescriptor(r,n)?.enumerable)throw new Error(`Unrecognized key: "${String(n)}"`);t[n]&&a.push(n)}return a}function $_(e,t){let r=e._zod.def,a=r.checks;if(a&&a.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");let i=new Set(Vl(e,t)),o={};return Pr(o,e,Reflect.ownKeys(xn(e)).filter(s=>!i.has(s))),ge(e,Nt(r,{shape:o,checks:[]}))}function j_(e,t){if(!Dt(t))throw new Error("Invalid input to extend: expected a plain object");let r=e._zod.def.checks;if(r&&r.length>0){let n=xn(e);for(let i of Reflect.ownKeys(t))if(Object.getOwnPropertyDescriptor(n,i)!==void 0)throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}return ge(e,Nt(e._zod.def,{shape:O_(e,t)}))}function O_(e,t){let r={};return Pr(r,e,Reflect.ownKeys(xn(e))),_1(r,t),r}function N_(e,t){if(!Dt(t))throw new Error("Invalid input to safeExtend: expected a plain object");return ge(e,Nt(e._zod.def,{shape:O_(e,t)}))}function D_(e,t){if(!t?._zod?.def)throw new Error("Invalid input to merge: expected an object schema. To merge a plain shape, use `.extend()`.");if(e._zod.def.checks?.length)throw new Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");let r={};Pr(r,e,Reflect.ownKeys(xn(e))),Pr(r,t,Reflect.ownKeys(xn(t)));let a=Nt(e._zod.def,{shape:r,get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]});return ge(e,a)}function M_(e,t,r,a="partial"){let i=t._zod.def.checks;if(i&&i.length>0)throw new Error(`.${a}() cannot be used on object schemas containing refinements`);let s=r?new Set(Vl(t,r)):void 0,l={};return Pr(l,t,Reflect.ownKeys(xn(t)),e&&((c,u)=>s&&!s.has(u)?c:new e({type:"optional",innerType:c}))),ge(t,Nt(t._zod.def,{shape:l,checks:[]}))}function L_(e,t,r){let a=r?new Set(Vl(t,r)):void 0,n={};return Pr(n,t,Reflect.ownKeys(xn(t)),(i,o)=>a&&!a.has(o)?i:new e({type:"nonoptional",innerType:i})),ge(t,Nt(t._zod.def,{shape:n}))}function ct(e,t=0){if(e.aborted===!0)return!0;for(let r=t;r<e.issues.length;r++)if(e.issues[r]?.continue!==!0)return!0;return!1}function dg(e,t=0){if(e.aborted===!0)return!0;for(let r=t;r<e.issues.length;r++)if(e.issues[r]?.continue===!1)return!0;return!1}function vt(e,t){return t.map(r=>{var a;return(a=r).path??(a.path=[]),r.path.unshift(e),r})}function va(e){return typeof e=="string"?e:e?.message}function Ea(e){let t=[];for(let r of e??[]){let a=r._zod.def;if(!/_(length|size)$|_equals$/.test(a.check))break;let n=a.maximum??a.length??a.size;n>=0&&t.push([n,r])}return t}function yo(e,t,r){var a;for(let n=t;n<e.length;n++)(a=e[n]).schema??(a.schema=r)}function yt(e,t,r){var a;let n=e.inst?._zod?.traits;n?.has("$ZodType")&&(n.has("$ZodCheck")?(a=e).schema??(a.schema=e.inst):e.schema=e.inst);let i=e.schema!==e.inst?e.schema?._zod.def?.error:void 0,o=e.message?e.message:va(e.inst?._zod.def?.error?.(e))??va(i?.(e))??va(t?.error?.(e))??va(r.customError?.(e))??va(r.localeError?.(e))??"Invalid input",s={};for(let l of Object.keys(e))l==="inst"||l==="schema"||l==="continue"||l==="input"||l==="__proto__"||(s[l]=e[l]);return s.path??(s.path=[]),s.message=o,t?.reportInput&&(s.input=e.input),s}function ko(e){return e instanceof Set?"set":e instanceof Map?"map":e instanceof File?"file":"unknown"}var z1=/[\uD800-\uDBFF]/;function $r(e){let t=e.length;if(!z1.test(e))return t;let r=t;for(let a=0;a<t-1;a++)(e.charCodeAt(a)&64512)===55296&&(e.charCodeAt(a+1)&64512)===56320&&(r--,a++);return r}function _o(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function T(e){let t=typeof e;switch(t){case"number":return Number.isNaN(e)?"nan":"number";case"object":{if(e===null)return"null";if(Array.isArray(e))return"array";let r=e;if(r&&Object.getPrototypeOf(r)!==Object.prototype&&"constructor"in r&&r.constructor)return r.constructor.name}}return t}function xa(...e){let[t,r,a]=e;return typeof t=="string"?{message:t,code:"custom",input:r,inst:a}:{...t}}function I1(e){return Object.entries(e).filter(([t,r])=>Number.isNaN(Number.parseInt(t,10))).map(t=>t[1])}function B_(e){let t=atob(e),r=new Uint8Array(t.length);for(let a=0;a<t.length;a++)r[a]=t.charCodeAt(a);return r}function U_(e){let t="";for(let r=0;r<e.length;r++)t+=String.fromCharCode(e[r]);return btoa(t)}function P1(e){let t=e.replace(/-/g,"+").replace(/_/g,"/"),r="=".repeat((4-t.length%4)%4);return B_(t+r)}function R1(e){return U_(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function $1(e){let t=e.replace(/^0x/,"");if(t.length%2!==0)throw new Error("Invalid hex string length");let r=new Uint8Array(t.length/2);for(let a=0;a<t.length;a+=2)r[a/2]=Number.parseInt(t.slice(a,a+2),16);return r}function j1(e){return Array.from(e).map(t=>t.toString(16).padStart(2,"0")).join("")}var ig=class{constructor(...t){}};function pg(e,t){for(let r in t){let a=Object.getOwnPropertyDescriptor(t,r);a.get?Object.defineProperty(e,r,{...a,enumerable:!1}):N1(e,r,a.value)}}function sn(e,t,r,a=!0){return Object.defineProperty(e,t,{configurable:!0,writable:!0,enumerable:a,value:r}),r}function wo(e,t,r){return sn(e,t,r,!1)}function O1(e,t){for(let r in e){let a=e[r];Object.defineProperty(t,r,{configurable:!0,enumerable:!0,get(){return sn(this,r,a(this))},set(n){sn(this,r,n)}})}return t}function N1(e,t,r){Object.defineProperty(e,t,{configurable:!0,get(){return this==null?r:sn(this,t,r.bind(this))},set(a){sn(this,t,a)}})}function D1(e,t){let r=Object.getPrototypeOf(e);return t in r?void 0:r}var rg,Xn=!1,M1={configurable:!0,get(){Xn=!0}};function ee(e,t,r){let a=Object.getPrototypeOf(e._zod);if(t in a&&rg!==e._zod){rg=void 0;return}rg=e._zod,Object.defineProperty(a,t,{configurable:!0,get(){Object.defineProperty(this,t,M1);let n=Xn;Xn=!1;try{let i=r(this);return Xn?delete this[t]:Object.defineProperty(this,t,{configurable:!0,writable:!0,value:i}),Xn=Xn||n,i}catch(i){throw delete this[t],Xn=Xn||n,i}},set(n){Object.defineProperty(this,t,{configurable:!0,writable:!0,value:n})}})}function mg(e,t,r,a){let n=D1(e,t);n&&Object.defineProperty(n,t,{configurable:!0,get(){let i={configurable:!0,writable:!0,enumerable:a,value:void 0};return Object.defineProperty(this,t,i),i.value=r(this),Object.defineProperty(this,t,i),i.value},set(i){Object.defineProperty(this,t,{configurable:!0,writable:!0,enumerable:a,value:i})}})}var Wl="~constantCatch";function gg(e){let t=()=>e;return t[Wl]=!0,t}var F_,fg=Object.freeze({status:"aborted"}),hg={value:void 0,enumerable:!1},q_="captureStackTrace"in Error?Error:null;function L1(e){let t=q_;if(t){let r=t.stackTraceLimit;if(typeof r=="number"){try{t.stackTraceLimit=0}catch{return q_=null,new e}try{return new e}finally{t.stackTraceLimit=r}}}return new e}function y(e,t,r,a){let n={};function i(m){this.def=m,this.constr=d,this.traits=new Set}i.prototype=n;let o=r,s=o&&new WeakSet;function l(m,p){if(m._zod){if(m._zod.traits.has(e))return}else{hg.value=new i(p);try{Object.defineProperty(m,"_zod",hg)}finally{hg.value=void 0}}if(m._zod.traits.add(e),t(m,p),s){let h=Object.getPrototypeOf(m),f=m._zod.constr.prototype,_=h;for(;_&&_!==f;)_=Object.getPrototypeOf(_);let b=_??h;s.has(b)||(s.add(b),pg(b,o))}let g=d.prototype;for(let h in g)Object.prototype.hasOwnProperty.call(g,h)&&(h in m||(m[h]=g[h].bind(m)))}let c=a?.Parent??Object;class u extends c{}Object.defineProperty(u,"name",{value:e});function d(m){let p=a?.Parent?L1(u):this;l(p,m);let g=p._zod.deferred;if(g){for(let f of g)f();p._zod.deferred=void 0}let h=globalThis.__zod_globalConfig?.postProcessor;return h&&h(p),p}return Object.defineProperty(d,"init",{value:l}),Object.defineProperty(d,Symbol.hasInstance,{value:m=>a?.Parent&&m instanceof a.Parent?!0:m?._zod?.traits?.has(e)}),Object.defineProperty(d,"name",{value:e}),d}var bg=Symbol("zod_brand"),kt=class extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}},Qn=class extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}};(F_=globalThis).__zod_globalConfig??(F_.__zod_globalConfig={});var He=globalThis.__zod_globalConfig;function Oe(e){return e&&Object.assign(He,e),He}function B1(){let e=this._zod;return e.message??(e.message=JSON.stringify(e.def,ka,2)),e.message}function U1(e){this._zod.message=e}var F1={get:B1,set:U1,enumerable:!0,configurable:!0},yg={value:void 0,enumerable:!1},H_=new WeakSet([Object.prototype,Error.prototype]),G_=(e,t)=>{e.name="$ZodError",yg.value=t,Object.defineProperty(e,"issues",yg),yg.value=void 0,Object.defineProperty(e,"message",F1);let r=Object.getPrototypeOf(e);H_.has(r)||(H_.add(r),Object.defineProperty(r,"toString",{configurable:!0,enumerable:!1,get(){let a=()=>this.message;return Object.defineProperty(this,"toString",{value:a,configurable:!0,writable:!0}),a},set(a){Object.defineProperty(this,"toString",{value:a,configurable:!0,writable:!0})}}))},kg=y("$ZodError",G_),_t=y("$ZodError",G_,void 0,{Parent:Error});function q1(e,t,r){return Object.prototype.hasOwnProperty.call(e,t)||(t==="__proto__"?Object.defineProperty(e,t,{value:r(),writable:!0,enumerable:!0,configurable:!0}):e[t]=r()),e[t]}function So(e,t=r=>r.message){let r={},a=[];for(let n of e.issues)n.path.length>0?q1(r,n.path[0],()=>[]).push(t(n)):a.push(t(n));return{formErrors:a,fieldErrors:r}}function Eo(e,t=r=>r.message){let r={_errors:[]},a=(n,i=[])=>{for(let o of n.issues)if(o.code==="invalid_union"&&o.errors.length)o.errors.map(s=>a({issues:s},[...i,...o.path]));else if(o.code==="invalid_key")a({issues:o.issues},[...i,...o.path]);else if(o.code==="invalid_element")a({issues:o.issues},[...i,...o.path]);else{let s=[...i,...o.path];if(s.length===0)r._errors.push(t(o));else{let l=r,c=0;for(;c<s.length;){let u=s[c],d=c===s.length-1;if(u==="_errors"){d&&l._errors.push(t(o)),c++;continue}Object.prototype.hasOwnProperty.call(l,u)||Object.defineProperty(l,u,{value:{_errors:[]},enumerable:!0,writable:!0,configurable:!0});let m=l[u];d&&m._errors.push(t(o)),l=m,c++}}}};return a(e),r}function _g(e,t=r=>r.message){let r={errors:[]},a=(n,i=[])=>{var o;for(let s of n.issues)if(s.code==="invalid_union"&&s.errors.length)s.errors.map(l=>a({issues:l},[...i,...s.path]));else if(s.code==="invalid_key")a({issues:s.issues},[...i,...s.path]);else if(s.code==="invalid_element")a({issues:s.issues},[...i,...s.path]);else{let l=[...i,...s.path];if(l.length===0){r.errors.push(t(s));continue}let c=r,u=0;for(;u<l.length;){let d=l[u],m=u===l.length-1;typeof d=="string"?(c.properties??(c.properties={}),Object.prototype.hasOwnProperty.call(c.properties,d)||Object.defineProperty(c.properties,d,{value:{errors:[]},enumerable:!0,writable:!0,configurable:!0}),c=c.properties[d]):(c.items??(c.items=[]),(o=c.items)[d]??(o[d]={errors:[]}),c=c.items[d]),m&&c.errors.push(t(s)),u++}}};return a(e),r}function V_(e){let t=[],r=e.map(a=>typeof a=="object"?a.key:a);for(let a of r)typeof a=="number"?t.push(`[${a}]`):typeof a=="symbol"?t.push(`[${JSON.stringify(String(a))}]`):/[^\w$]/.test(a)?t.push(`[${JSON.stringify(a)}]`):(t.length&&t.push("."),t.push(a));return t.join("")}function wg(e){let t=[],r=[...e.issues].sort((a,n)=>(a.path??[]).length-(n.path??[]).length);for(let a of r)t.push(`\u2716 ${a.message}`),a.path?.length&&t.push(` \u2192 at ${V_(a.path)}`);return t.join(`
|
|
10
10
|
`)}function Kl(e,t){return{callee:t?.callee??e,Err:t?.Err}}var Ta=e=>{let t=(r,a,n,i)=>{let o=n?{...n,async:!1}:{async:!1},s=r._zod.run({value:a,issues:[]},o);if(s instanceof Promise)throw new kt;if(s.issues.length){let l=new(i?.Err??e)(s.issues.map(c=>yt(c,o,Oe())));throw Gl(l,i?.callee??t),l}return s.value};return t},jr=Ta(_t),Aa=e=>{let t=async(r,a,n,i)=>{let o=n?{...n,async:!0}:{async:!0},s=r._zod.run({value:a,issues:[]},o);if(s instanceof Promise&&(s=await s),s.issues.length){let l=new(i?.Err??e)(s.issues.map(c=>yt(c,o,Oe())));throw Gl(l,i?.callee??t),l}return s.value};return t},Or=Aa(_t),Ca=e=>(t,r,a)=>{let n=a?{...a,async:!1}:{async:!1},i=t._zod.run({value:r,issues:[]},n);if(i instanceof Promise)throw new kt;return i.issues.length?W_(e,i.issues,n):{success:!0,data:i.value}},za=Ca(_t);function W_(e,t,r){let a;return{success:!1,get error(){return a||(a=new e(t.map(n=>yt(n,r,Oe()))),t=void 0,r=void 0),a},set error(n){a=n,t=void 0,r=void 0}}}var Ia=e=>async(t,r,a)=>{let n=a?{...a,async:!0}:{async:!0},i=t._zod.run({value:r,issues:[]},n);return i instanceof Promise&&(i=await i),i.issues.length?W_(e,i.issues,n):{success:!0,data:i.value}},Pa=Ia(_t),G1=Symbol.for("zod.compile.invalid"),V1=Symbol.for("zod.compile.fallback"),Ra=((e,t,r)=>{let a=e._zod.bag.validator;if(a!==void 0){if(a(t)!==G1)return!0;if(a.definite===!0&&r===void 0)return!1}return W1(e,t,r)});function W1(e,t,r){let a=r?{...r,async:!1,abortEarly:!0}:{async:!1,abortEarly:!0},n=e._zod.bag.fallbackRun,i;if(n?(a[V1]=!0,i=n({value:t,issues:[]},a)):i=e._zod.run({value:t,issues:[]},a),i instanceof Promise)throw new kt;return i.issues.length===0}var $a=async(e,t,r)=>{let a=r?{...r,async:!0,abortEarly:!0}:{async:!0,abortEarly:!0},n=e._zod.run({value:t,issues:[]},a);return n instanceof Promise&&(n=await n),n.issues.length===0},Zl=e=>{let t=Ta(e),r=(a,n,i,o)=>{let s=i?{...i,direction:"backward"}:{direction:"backward"};return t(a,n,s,Kl(r,o))};return r},K_=Zl(_t),Jl=e=>{let t=Ta(e),r=(a,n,i,o)=>t(a,n,i,Kl(r,o));return r},Z_=Jl(_t),Yl=e=>{let t=Aa(e),r=async(a,n,i,o)=>{let s=i?{...i,direction:"backward"}:{direction:"backward"};return await t(a,n,s,Kl(r,o))};return r},J_=Yl(_t),Xl=e=>{let t=Aa(e),r=async(a,n,i,o)=>await t(a,n,i,Kl(r,o));return r},Y_=Xl(_t),Ql=e=>(t,r,a)=>{let n=a?{...a,direction:"backward"}:{direction:"backward"};return Ca(e)(t,r,n)},X_=Ql(_t),ec=e=>(t,r,a)=>Ca(e)(t,r,a),Q_=ec(_t),tc=e=>async(t,r,a)=>{let n=a?{...a,direction:"backward"}:{direction:"backward"};return Ia(e)(t,r,n)},ew=tc(_t),nc=e=>async(t,r,a)=>Ia(e)(t,r,a),tw=nc(_t);var Ct={};En(Ct,{anyString:()=>Zg,base64:()=>Bg,base64url:()=>Ug,bigint:()=>Yg,boolean:()=>Xg,browserEmail:()=>tR,cidrv4:()=>Mg,cidrv6:()=>Lg,creditCard:()=>rc,cuid:()=>Eg,cuid2:()=>xg,currencyCode:()=>Gg,date:()=>Vg,datetime:()=>Kg,domain:()=>qg,duration:()=>Pg,e164:()=>Hg,email:()=>$g,emoji:()=>jg,extendedDuration:()=>K1,guid:()=>Rg,hex:()=>rh,hostname:()=>Fg,html5Email:()=>X1,httpProtocol:()=>xo,iban:()=>ac,idnEmail:()=>eR,integer:()=>To,ipv4:()=>Og,ipv6:()=>Ng,ksuid:()=>Cg,lowercase:()=>th,mac:()=>Dg,md5_base64:()=>iR,md5_base64url:()=>oR,md5_hex:()=>aR,nanoid:()=>zg,nanoidOfLength:()=>Ig,null:()=>Qg,number:()=>An,rfc5322Email:()=>Q1,sha1_base64:()=>lR,sha1_base64url:()=>cR,sha1_hex:()=>sR,sha256_base64:()=>dR,sha256_base64url:()=>pR,sha256_hex:()=>uR,sha384_base64:()=>gR,sha384_base64url:()=>hR,sha384_hex:()=>mR,sha512_base64:()=>bR,sha512_base64url:()=>vR,sha512_hex:()=>fR,string:()=>Jg,time:()=>Wg,ulid:()=>Tg,undefined:()=>eh,unicodeEmail:()=>nw,uppercase:()=>nh,uuid:()=>Nr,uuid4:()=>Z1,uuid6:()=>J1,uuid7:()=>Y1,xid:()=>Ag});var Eg=/^[cC][0-9a-z]{6,}$/,xg=/^[0-9a-z]+$/,Tg=/^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$/,Ag=/^[0-9a-vA-V]{20}$/,Cg=/^[A-Za-z0-9]{27}$/,zg=/^[a-zA-Z0-9_-]{21}$/;function Ig(e){return new RegExp(`^[a-zA-Z0-9_-]{${e}}$`)}var Pg=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,K1=/^[-+]?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)?)??$/,Rg=/^([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})$/,Nr=e=>e?new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,Z1=Nr(4),J1=Nr(6),Y1=Nr(7),$g=/^(?:[A-Za-z0-9_'+\-]+\.)*[A-Za-z0-9_'+\-]*[A-Za-z0-9_+-]@(?:[A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,X1=/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/,Q1=/^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/,nw=/^[^\s@"]{1,64}@[^\s@]{1,255}$/u,eR=nw,tR=/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/,nR="^(?=[\\s\\S]*[\\p{Extended_Pictographic}\\p{Regional_Indicator}\\u20E3])[\\p{Extended_Pictographic}\\p{Emoji_Component}]+$";function jg(){return new RegExp(nR,"u")}var Og=/^(?:(?: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])$/,Ng=/^(([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}|:))$/,Dg=e=>{let t=Mt(e??":");return new RegExp(`^(?:[0-9A-F]{2}${t}){5}[0-9A-F]{2}$|^(?:[0-9a-f]{2}${t}){5}[0-9a-f]{2}$`)},Mg=/^((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])$/,Lg=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,Bg=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Ug=/^(?:[A-Za-z0-9_-]{4})*(?:[A-Za-z0-9_-]{2,3})?$/,Fg=/^(?=.{1,253}\.?$)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[-0-9a-zA-Z]{0,61}[0-9a-zA-Z])?)*\.?$/,qg=/^(?=.{1,253}$)([a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,63}$/,xo=/^https?$/,Hg=/^\+[1-9]\d{6,14}$/,rc=/^\d(?:[ -]?\d){11,18}$/,Gg=/^(?:AED|AFN|ALL|AMD|AOA|ARS|AUD|AWG|AZN|BAM|BBD|BDT|BHD|BIF|BMD|BND|BOB|BOV|BRL|BSD|BTN|BWP|BYN|BZD|CAD|CDF|CHE|CHF|CHW|CLF|CLP|CNY|COP|COU|CRC|CUP|CVE|CZK|DJF|DKK|DOP|DZD|EGP|ERN|ETB|EUR|FJD|FKP|GBP|GEL|GHS|GIP|GMD|GNF|GTQ|GYD|HKD|HNL|HTG|HUF|IDR|ILS|INR|IQD|IRR|ISK|JMD|JOD|JPY|KES|KGS|KHR|KMF|KPW|KRW|KWD|KYD|KZT|LAK|LBP|LKR|LRD|LSL|LYD|MAD|MDL|MGA|MKD|MMK|MNT|MOP|MRU|MUR|MVR|MWK|MXN|MXV|MYR|MZN|NAD|NGN|NIO|NOK|NPR|NZD|OMR|PAB|PEN|PGK|PHP|PKR|PLN|PYG|QAR|RON|RSD|RUB|RWF|SAR|SBD|SCR|SDG|SEK|SGD|SHP|SLE|SOS|SRD|SSP|STN|SVC|SYP|SZL|THB|TJS|TMT|TND|TOP|TRY|TTD|TWD|TZS|UAH|UGX|USD|USN|UYI|UYU|UYW|UZS|VED|VES|VND|VUV|WST|XAD|XAF|XAG|XAU|XBA|XBB|XBC|XBD|XCD|XCG|XDR|XOF|XPD|XPF|XPT|XSU|XTS|XUA|XXX|YER|ZAR|ZMW|ZWG)$/,ac=/^[A-Z]{2}(?!00|01|99)\d{2}[A-Z0-9]{11,30}$/,rw="(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))";function rR(e){return new RegExp(`^${e}$`)}var Vg=rR(rw);function Sg(e){let t="(?:[01]\\d|2[0-3]):[0-5]\\d";return typeof e.precision=="number"?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:e.seconds?`${t}:[0-5]\\d(?:\\.\\d+)?`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function Wg(e){return new RegExp(`^${Sg(e)}$`)}function Kg(e){let t=["Z"];e.offset&&t.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");let r=`${Sg({precision:e.precision,seconds:!0})}(?:${t.join("|")})`,a=e.local?`${r}|${Sg({precision:e.precision})}`:r;return new RegExp(`^${rw}T(?:${a})$`)}var Zg=/^[\s\S]{0,}$/,Jg=e=>{let t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)},Yg=/^-?\d+n?$/,To=/^-?\d+$/,An=/^-?\d+(?:\.\d+)?$/,Xg=/^(?:true|false)$/i,Qg=/^null$/i;var eh=/^undefined$/i;var th=/^[^A-Z]*$/,nh=/^[^a-z]*$/,rh=/^[0-9a-fA-F]*$/;function Ao(e,t){return new RegExp(`^[A-Za-z0-9+/]{${e}}${t}$`)}function Co(e){return new RegExp(`^[A-Za-z0-9_-]{${e}}$`)}var aR=/^[0-9a-fA-F]{32}$/,iR=Ao(22,"=="),oR=Co(22),sR=/^[0-9a-fA-F]{40}$/,lR=Ao(27,"="),cR=Co(27),uR=/^[0-9a-fA-F]{64}$/,dR=Ao(43,"="),pR=Co(43),mR=/^[0-9a-fA-F]{96}$/,gR=Ao(64,""),hR=Co(64),fR=/^[0-9a-fA-F]{128}$/,bR=Ao(86,"=="),vR=Co(86);var _e=y("$ZodCheck",(e,t)=>{var r;e._zod??(e._zod={}),e._zod.def=t,(r=e._zod).onattach??(r.onattach=[])}),ah=e=>{let t=e.value;return!Hl(t)&&t.size!==void 0},ih=e=>{let t=e.value;return!Hl(t)&&t.length!==void 0},ic={number:"number",bigint:"bigint",object:"date"},sc=y("$ZodCheckLessThan",(e,t)=>{_e.init(e,t);let r=ic[typeof t.value];e._zod.check=a=>{(t.inclusive?a.value<=t.value:a.value<t.value)||a.issues.push({origin:ic[typeof a.value]??r,code:"too_big",maximum:typeof t.value=="object"?t.value.getTime():t.value,input:a.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),lc=y("$ZodCheckGreaterThan",(e,t)=>{_e.init(e,t);let r=ic[typeof t.value];e._zod.check=a=>{(t.inclusive?a.value>=t.value:a.value>t.value)||a.issues.push({origin:ic[typeof a.value]??r,code:"too_small",minimum:typeof t.value=="object"?t.value.getTime():t.value,input:a.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),oh=y("$ZodCheckMultipleOf",(e,t)=>{_e.init(e,t),e._zod.check=r=>{if(typeof r.value!=typeof t.value)throw new Error("Cannot mix number and bigint in multiple_of check.");(typeof r.value=="bigint"?t.value!==BigInt(0)&&r.value%t.value===BigInt(0):ho(r.value,t.value)===0)||r.issues.push({origin:typeof r.value,code:"not_multiple_of",divisor:t.value,input:r.value,inst:e,continue:!t.abort})}}),sh=y("$ZodCheckNumberFormat",(e,t)=>{_e.init(e,t),t.format=t.format||"float64";let r=t.format?.includes("int"),a=r?"int":"number",[n,i]=bo[t.format];e._zod.check=o=>{let s=o.value;if(r){if(!Number.isInteger(s)){o.issues.push({expected:a,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:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:a,inclusive:!0,continue:!t.abort}):o.issues.push({input:s,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:a,inclusive:!0,continue:!t.abort});return}}s<n&&o.issues.push({origin:"number",input:s,code:"too_small",minimum:n,inclusive:!0,inst:e,continue:!t.abort}),s>i&&o.issues.push({origin:"number",input:s,code:"too_big",maximum:i,inclusive:!0,inst:e,continue:!t.abort})}}),lh=y("$ZodCheckBigIntFormat",(e,t)=>{_e.init(e,t);let[r,a]=vo[t.format];e._zod.check=n=>{let i=n.value;i<r&&n.issues.push({origin:"bigint",input:i,code:"too_small",minimum:r,inclusive:!0,inst:e,continue:!t.abort}),i>a&&n.issues.push({origin:"bigint",input:i,code:"too_big",maximum:a,inclusive:!0,inst:e,continue:!t.abort})}}),ch=y("$ZodCheckMaxSize",(e,t)=>{var r;_e.init(e,t),(r=e._zod.def).when??(r.when=ah),e._zod.check=a=>{let n=a.value;n.size<=t.maximum||a.issues.push({origin:ko(n),code:"too_big",maximum:t.maximum,inclusive:!0,input:n,inst:e,continue:!t.abort})}}),uh=y("$ZodCheckMinSize",(e,t)=>{var r;_e.init(e,t),(r=e._zod.def).when??(r.when=ah),e._zod.check=a=>{let n=a.value;n.size>=t.minimum||a.issues.push({origin:ko(n),code:"too_small",minimum:t.minimum,inclusive:!0,input:n,inst:e,continue:!t.abort})}}),dh=y("$ZodCheckSizeEquals",(e,t)=>{var r;_e.init(e,t),(r=e._zod.def).when??(r.when=ah),e._zod.check=a=>{let n=a.value,i=n.size;if(i===t.size)return;let o=i>t.size;a.issues.push({origin:ko(n),...o?{code:"too_big",maximum:t.size}:{code:"too_small",minimum:t.size},inclusive:!0,exact:!0,input:a.value,inst:e,continue:!t.abort})}}),ph=y("$ZodCheckMaxLength",(e,t)=>{var r;_e.init(e,t),(r=e._zod.def).when??(r.when=ih),e._zod.check=a=>{let n=a.value,i=n.length;if((typeof n=="string"&&i>t.maximum?$r(n):i)<=t.maximum)return;let s=_o(n);a.issues.push({origin:s,code:"too_big",maximum:t.maximum,inclusive:!0,input:n,inst:e,continue:!t.abort})}}),mh=y("$ZodCheckMinLength",(e,t)=>{var r;_e.init(e,t),(r=e._zod.def).when??(r.when=ih),e._zod.check=a=>{let n=a.value,i=n.length;if((typeof n=="string"&&i>=t.minimum&&i<t.minimum*2?$r(n):i)>=t.minimum)return;let s=_o(n);a.issues.push({origin:s,code:"too_small",minimum:t.minimum,inclusive:!0,input:n,inst:e,continue:!t.abort})}}),gh=y("$ZodCheckLengthEquals",(e,t)=>{var r;_e.init(e,t),(r=e._zod.def).when??(r.when=ih),e._zod.check=a=>{let n=a.value,i=n.length,o=typeof n=="string"&&i>=t.length&&i<=t.length*2?$r(n):i;if(o===t.length)return;let s=_o(n),l=o>t.length;a.issues.push({origin:s,...l?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:a.value,inst:e,continue:!t.abort})}}),ja=y("$ZodCheckStringFormat",(e,t)=>{var r,a;_e.init(e,t),t.pattern?(r=e._zod).check??(r.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})}):(a=e._zod).check??(a.check=()=>{})}),hh=y("$ZodCheckRegex",(e,t)=>{ja.init(e,t),e._zod.check=r=>{t.pattern.lastIndex=0,!t.pattern.test(r.value)&&r.issues.push({origin:"string",code:"invalid_format",format:"regex",input:r.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),fh=y("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=th),ja.init(e,t)}),bh=y("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=nh),ja.init(e,t)}),vh=y("$ZodCheckIncludes",(e,t)=>{_e.init(e,t);let r=Mt(t.includes),a=new RegExp(typeof t.position=="number"?`^.{${t.position},}${r}`:r);t.pattern=a,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})}}),yh=y("$ZodCheckStartsWith",(e,t)=>{_e.init(e,t);let r=new RegExp(`^${Mt(t.prefix)}.*`);t.pattern??(t.pattern=r),e._zod.check=a=>{a.value.startsWith(t.prefix)||a.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:a.value,inst:e,continue:!t.abort})}}),kh=y("$ZodCheckEndsWith",(e,t)=>{_e.init(e,t);let r=new RegExp(`.*${Mt(t.suffix)}$`);t.pattern??(t.pattern=r),e._zod.check=a=>{a.value.endsWith(t.suffix)||a.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:a.value,inst:e,continue:!t.abort})}});function oc(e,t,r){e.issues.length&&t.issues.push(...vt(r,e.issues))}var _h=y("$ZodCheckProperty",(e,t)=>{_e.init(e,t),e._zod.check=r=>{let a=t.schema._zod.run({value:r.value[t.property],issues:[]},{});if(a instanceof Promise)return a.then(n=>oc(n,r,t.property));oc(a,r,t.property)}}),wh=y("$ZodCheckProperties",(e,t)=>{_e.init(e,t),wo(e,Symbol.iterator,function*(){yield e});let r;e._zod.check=a=>{if(a.value==null){a.issues.push({expected:"object",code:"invalid_type",input:a.value,inst:e});return}r??(r=Reflect.ownKeys(t.shape).map(o=>[o,t.shape[o]]));let n=a.value,i;for(let[o,s]of r){let l=s._zod.run({value:n[o],issues:[]},{});l instanceof Promise?(i??(i=[]),i.push(l.then(c=>oc(c,a,o)))):oc(l,a,o)}if(i)return Promise.all(i).then(()=>{})}}),Sh=y("$ZodCheckMimeType",(e,t)=>{_e.init(e,t);let r=new Set(t.mime);e._zod.check=a=>{r.has(a.value.type)||a.issues.push({code:"invalid_value",values:t.mime,input:a.value.type,inst:e,continue:!t.abort})}}),Eh=y("$ZodCheckOverwrite",(e,t)=>{_e.init(e,t),e._zod.check=r=>{r.value=t.tx(r.value)}});var Dr=class{constructor(t=[],r={}){this.content=[],this.indent=0,this.args=t,this.closed=r}indented(t){this.indent+=1;try{t(this)}finally{this.indent-=1}}write(t){if(typeof t=="function"){t(this,{execution:"sync"}),t(this,{execution:"async"});return}let a=t.split(`
|
|
11
11
|
`).filter(o=>o),n=Math.min(...a.map(o=>o.length-o.trimStart().length)),i=a.map(o=>o.slice(n)).map(o=>" ".repeat(this.indent*2)+o);for(let o of i)this.content.push(o)}compile(){let t=Function,r=this?.content??[""];return new t(...Object.keys(this.closed),`return function (${this.args.join(", ")}) {
|
|
12
12
|
${r.join(`
|
|
@@ -67,9 +67,9 @@ ${l}`:l:"",u=Function,d=`return (input) => {
|
|
|
67
67
|
${l}
|
|
68
68
|
}`,m;try{m=new u(...o,d)(...s)}catch(p){throw new se(`this schema (generated code failed to evaluate: ${p.message})`)}return t?.debug&&(m.code=c),m.definite=a.definite,m}function V(e,t){for(let[a,n]of e.constants)if(n===t)return a;let r=`c${e.constantCounter++}`;return e.constants.set(r,t),r}function Lr(e,t){return e.definite=!1,V(e,t)}function G(e){return`v${e.varCounter++}`}function q$(e,t){let r=e._zod.run({value:t,issues:[]},{});if(r&&typeof r.then=="function")return ut;let a=r;return a.issues.length===0?a.value:ut}function tt(e,t,r,a,n=!0){let i=e.content.length,o=t.constants.size,s=t.constantCounter,l=t.varCounter;try{return $e(e,t,r,a,n)}catch(c){if(!(c instanceof se)||!c.islandable)throw c;if(e.content.length=i,t.constants.size>o){let u=Array.from(t.constants.keys()).slice(o);for(let d of u)t.constants.delete(d)}return t.constantCounter=s,t.varCounter=l,H$(e,t,r,a)}}function H$(e,t,r,a){t.definite=!1;let n=V(t,r),i=V(t,q$),o=G(t);return e.write(`const ${o} = ${i}(${n}, ${a});`),e.write(`if (${o} === INVALID) return INVALID;`),o}var G$=new Set(["max_size","min_size","size_equals","max_length","min_length","length_equals"]);function V$(e,t,r,a){let n=r._zod.def.checks;if(!n||n.length===0)return a;let i=a;for(let o of n){let s=o._zod.def;if(s.when&&!G$.has(s.check))throw new se('check with a custom "when" condition');switch(s.check){case"greater_than":W$(e,t,s,i);break;case"less_than":K$(e,t,s,i);break;case"multiple_of":Z$(e,t,s,i);break;case"number_format":VS(e,s,i);break;case"min_length":{let l=tr(s.minimum,"min_length"),c=Uh(e,t,i,`${i}.length >= ${l} && ${i}.length < ${s.minimum*2}`);e.write(`if (${c} < ${l}) return INVALID;`);break}case"max_length":{let l=tr(s.maximum,"max_length"),c=Uh(e,t,i,`${i}.length > ${l}`);e.write(`if (${c} > ${l}) return INVALID;`);break}case"length_equals":{let l=tr(s.length,"length_equals"),c=Uh(e,t,i,`${i}.length >= ${l} && ${i}.length <= ${s.length*2}`);e.write(`if (${c} !== ${l}) return INVALID;`);break}case"min_size":e.write(`if (${i}.size < ${tr(s.minimum,"min_size")}) return INVALID;`);break;case"max_size":e.write(`if (${i}.size > ${tr(s.maximum,"max_size")}) return INVALID;`);break;case"size_equals":e.write(`if (${i}.size !== ${tr(s.size,"size_equals")}) return INVALID;`);break;case"string_format":i=WS(e,t,s,i);break;case"custom":i=t2(e,t,o,i);break;case"bigint_format":J$(e,s,i);break;case"mime_type":Y$(e,t,s,i);break;case"property":Q$(e,t,s,i);break;case"properties":X$(e,t,s,i);break;case"overwrite":{let l=G(t);e2(e,t,o,i,l),i=l;break}default:throw new se(`check type ${s.check}`)}}return i}function Uh(e,t,r,a){let n=V(t,$r),i=G(t);return e.write(`const ${i} = typeof ${r} === "string" && ${a} ? ${n}(${r}) : ${r}.length;`),i}function tr(e,t){if(typeof e!="number"||!Number.isFinite(e))throw new se(`${t} bound of type ${typeof e}`);return`${e}`}function GS(e,t){if(typeof t=="bigint")return`${t}n`;if(typeof t=="number"){if(Number.isNaN(t))throw new se("comparison check with NaN bound");return`${t}`}if(t instanceof Date){if(Number.isNaN(t.getTime()))throw new se("comparison check with Invalid Date bound");return V(e,t)}throw new se(`comparison check bound of type ${typeof t}`)}function W$(e,t,r,a){let n=r.inclusive?"<":"<=";e.write(`if (${a} ${n} ${GS(t,r.value)}) return INVALID;`)}function K$(e,t,r,a){let n=r.inclusive?">":">=";e.write(`if (${a} ${n} ${GS(t,r.value)}) return INVALID;`)}function Z$(e,t,r,a){if(typeof r.value=="bigint"){if(r.value===BigInt(0))throw new se("multiple_of check with a zero divisor");e.write(`if (${a} % ${r.value}n !== 0n) return INVALID;`)}else{let n=V(t,ho);e.write(`if (${n}(${a}, ${tr(r.value,"multiple_of")}) !== 0) return INVALID;`)}}function VS(e,t,r){let a=t.format;switch(a){case"safeint":e.write(`if (!Number.isSafeInteger(${r})) return INVALID;`);break;case"int32":e.write(`if (!Number.isInteger(${r}) || ${r} < -2147483648 || ${r} > 2147483647) return INVALID;`);break;case"uint32":e.write(`if (!Number.isInteger(${r}) || ${r} < 0 || ${r} > 4294967295) return INVALID;`);break;case"float32":e.write(`if (!Number.isFinite(${r}) || ${r} < -3.4028234663852886e38 || ${r} > 3.4028234663852886e38) return INVALID;`);break;case"float64":e.write(`if (!Number.isFinite(${r})) return INVALID;`);break;default:throw new se(`number format ${a}`)}}function J$(e,t,r){let a=t.format;if(a)switch(a){case"int64":e.write(`if (${r} < -9223372036854775808n || ${r} > 9223372036854775807n) return INVALID;`);break;case"uint64":e.write(`if (${r} < 0n || ${r} > 18446744073709551615n) return INVALID;`);break;default:throw new se(`bigint format ${a}`)}}function Y$(e,t,r,a){let n=r.mime;if(n&&n.length>0){let i=V(t,new Set(n));e.write(`if (!${i}.has(${a}.type)) return INVALID;`)}}function X$(e,t,r,a){if(r.when)throw new se('check with a custom "when" condition');e.write(`if (${a} == null) return INVALID;`);let n=r.shape;for(let i of Reflect.ownKeys(n)){let o=typeof i=="symbol"?V(t,i):lt(i),s=G(t);e.write(`const ${s} = ${a}[${o}];`),tt(e,t,n[i],s,!1)}}function Q$(e,t,r,a){let n=`${a}[${JSON.stringify(r.property)}]`;$e(e,t,r.schema,n)}function e2(e,t,r,a,n){let i=r._zod.def.tx;if(!i)throw new se("overwrite check without a transform function");if(Br(i))throw new Vt("z.compile: async overwrite transforms are not supported");let o=V(t,i);e.write(`const ${n} = ${o}(${a});`)}function Fh(){throw new kt}function Gh(e){this.issues.push(e)}function t2(e,t,r,a){let n=r._zod.def;if(n.fn){if(Br(n.fn))throw new Vt("z.compile: async .refine() predicates are not supported");let i=Lr(t,n.fn),o=V(t,Fh),s=G(t);return e.write(`const ${s} = ${i}(${a});`),e.write(`if (${s} instanceof Promise) ${o}();`),e.write(`if (!${s}) return INVALID;`),a}if(r._zod.check){if(Br(r._zod.check))throw new Vt("z.compile: async .superRefine() / check functions are not supported");let i=r._zod.check,s=Lr(t,c=>{let u={value:c,issues:[],addIssue:Gh};return i(u)instanceof Promise&&Fh(),u.issues.length===0?u.value:ut}),l=G(t);return e.write(`const ${l} = ${s}(${a});`),e.write(`if (${l} === INVALID) return INVALID;`),l}throw new se("custom check without a predicate or check function")}var n2=new Set(["cidrv4","cuid","cuid2","date","datetime","duration","e164","email","emoji","ends_with","guid","includes","ipv4","ksuid","lowercase","mac","nanoid","regex","starts_with","time","ulid","uppercase","uuid","xid"]);function WS(e,t,r,a,n=!0){let i=r.format;if(i==="base64"){let c=V(t,Ro);return e.write(`if (!${c}(${a})) return INVALID;`),a}if(i==="base64url"){let c=V(t,Nc);return e.write(`if (!${c}(${a})) return INVALID;`),a}if(i==="jwt"){let c=V(t,qc),u=V(t,r.alg??null);return e.write(`if (!${c}(${a}, ${u})) return INVALID;`),a}if(i==="ipv6"){let c=V(t,Po);return e.write(`if (!${c}(${a})) return INVALID;`),a}if(i==="cidrv6"){let c=V(t,Rc);return e.write(`if (!${c}(${a})) return INVALID;`),a}if(i==="credit_card"){let c=V(t,Lc);return e.write(`if (!${c}(${a})) return INVALID;`),a}if(i==="iban"){let c=V(t,Uc);return e.write(`if (!${c}(${a})) return INVALID;`),a}let o=r;if(i==="url"||i==="httpurl"||o.normalize||o.hostname!==void 0||o.protocol!==void 0){let c=V(t,bc),u=V(t,r),d=G(t),m=G(t);if(e.write(`const ${d} = ${a}.trim();`),e.write(`const ${m} = ${c}(${d}, ${u});`),e.write(`if (typeof ${m} === "number") return INVALID;`),o.hostname!==void 0){let h=V(t,vc);e.write(`if (!${h}(${m}, ${u}.hostname)) return INVALID;`)}if(o.protocol!==void 0){let h=V(t,yc);e.write(`if (!${h}(${m}, ${u}.protocol)) return INVALID;`)}if(!n)return null;let p=G(t),g=o.normalize?`${m}.href`:`${V(t,Io)}(${d})`;return e.write(`const ${p} = ${g};`),p}let s=r.fn;if(s){if(Br(s))throw new se(`async string format ${i}`);let c=V(t,s);return e.write(`if (!${c}(${a})) return INVALID;`),a}if(n2.has(i)&&r.pattern){let c=V(t,r.pattern);return e.write(`${c}.lastIndex = 0;`),e.write(`if (!${c}.test(${a})) return INVALID;`),a}let l=r.format;switch(l){case"regex":throw new se("regex format without a pattern");case"lowercase":e.write(`if (${a} !== ${a}.toLowerCase()) return INVALID;`);break;case"uppercase":e.write(`if (${a} !== ${a}.toUpperCase()) return INVALID;`);break;case"includes":e.write(`if (!${a}.includes(${lt(r.includes)})) return INVALID;`);break;case"starts_with":{let c=r.prefix;e.write(`if (${a}.slice(0, ${c.length}) !== ${lt(c)}) return INVALID;`);break}case"ends_with":{let c=r.suffix;e.write(`if (${a}.slice(-${c.length}) !== ${lt(c)}) return INVALID;`);break}default:throw new se(`string format ${l}`)}return a}function $e(e,t,r,a,n=!0){let i=r._zod.def,o=i.type;if(i.coerce)throw new se(`coercion (z.coerce.${o}())`);let s=n||!!i.checks?.length,l;switch(o){case"string":l=r2(e,t,r,a,s);break;case"number":l=a2(e,r,a);break;case"boolean":l=i2(e,a);break;case"bigint":l=o2(e,r,a);break;case"symbol":l=s2(e,a);break;case"undefined":l=l2(e,a);break;case"null":l=c2(e,a);break;case"any":case"unknown":l=a;break;case"never":e.write("return INVALID;"),l=a;break;case"void":l=u2(e,a);break;case"nan":l=d2(e,a);break;case"date":l=p2(e,a);break;case"object":l=m2(e,t,r,a,s);break;case"optional":l=g2(e,t,r,a,s);break;case"nullable":l=b2(e,t,r,a,s);break;case"array":l=v2(e,t,r,a,s);break;case"literal":l=y2(e,t,r,a);break;case"enum":l=k2(e,t,r,a);break;case"readonly":{let c=FS(e,t,r,a),u=G(t);e.write(`const ${u} = Object.freeze(${c});`),l=u;break}case"success":FS(e,t,r,a),l="true";break;case"default":case"prefault":l=_2(e,t,r,a);break;case"nonoptional":l=w2(e,t,r,a);break;case"tuple":l=S2(e,t,r,a);break;case"union":l=E2(e,t,r,a);break;case"intersection":l=A2(e,t,r,a);break;case"record":l=C2(e,t,r,a);break;case"map":l=I2(e,t,r,a);break;case"set":l=P2(e,t,r,a);break;case"file":l=R2(e,a);break;case"template_literal":l=$2(e,t,r,a);break;case"lazy":l=j2(e,t,r,a);break;case"pipe":l=O2(e,t,r,a);break;case"custom":l=N2(e,t,r,a);break;case"transform":l=L2(e,t,r,a);break;case"catch":l=M2(e,t,r,a);break;default:throw new se(`schema type ${o}`)}return l===null?null:V$(e,t,r,l)}function r2(e,t,r,a,n=!0){e.write(`if (typeof ${a} !== "string") return INVALID;`);let i=r._zod.def;return i.format===void 0?a:WS(e,t,i,a,n)}function a2(e,t,r){e.write(`if (typeof ${r} !== "number" || !Number.isFinite(${r})) return INVALID;`);let a=t._zod.def;return a.check==="number_format"&&a.format&&VS(e,{format:a.format},r),r}function i2(e,t){return e.write(`if (typeof ${t} !== "boolean") return INVALID;`),t}function o2(e,t,r){e.write(`if (typeof ${r} !== "bigint") return INVALID;`);let a=t._zod.def;if(a.format)switch(a.format){case"int64":e.write(`if (${r} < -9223372036854775808n || ${r} > 9223372036854775807n) return INVALID;`);break;case"uint64":e.write(`if (${r} < 0n || ${r} > 18446744073709551615n) return INVALID;`);break}return r}function s2(e,t){return e.write(`if (typeof ${t} !== "symbol") return INVALID;`),t}function l2(e,t){return e.write(`if (${t} !== undefined) return INVALID;`),t}function c2(e,t){return e.write(`if (${t} !== null) return INVALID;`),t}function u2(e,t){return e.write(`if (${t} !== undefined) return INVALID;`),t}function d2(e,t){return e.write(`if (typeof ${t} !== "number" || !Number.isNaN(${t})) return INVALID;`),t}function p2(e,t){return e.write(`if (!(${t} instanceof Date) || Number.isNaN(${t}.getTime())) return INVALID;`),t}function m2(e,t,r,a,n=!0){let i=r._zod.def;e.write(`if (typeof ${a} !== "object" || ${a} === null || Array.isArray(${a})) return INVALID;`);let o=i.shape,s=Object.keys(o),l=Object.getOwnPropertySymbols(o),c=l.length?[...s,...l]:s,u=b=>typeof b=="symbol"?V(t,b):lt(b),d=b=>typeof b=="symbol"?`[${u(b)}]`:lt(b),m=o;if(s.includes("__proto__"))throw new se('object shape key "__proto__"');let p=new Map;for(let b of c){let v=m[b],C=u(b),S=G(t);if(e.write(`const ${S} = ${a}[${C}];`),v._zod.optin!==void 0){let P=G(t);e.write(`let ${P} = (() => {`),e.indented(U=>{let qe=tt(U,t,v,S);U.write(`return ${qe};`)}),e.write("})();"),v._zod.optout==="optional"?(e.write(`if (${P} === INVALID) {`),e.indented(U=>{U.write(`if (${C} in ${a}) return INVALID;`),U.write(`${P} = undefined;`)}),e.write("}")):e.write(`if (${P} === INVALID) return INVALID;`),p.set(b,P)}else{f2(v)&&e.write(`if (!(${C} in ${a})) return INVALID;`);let P=tt(e,t,v,S,n);P!==null&&p.set(b,P)}}let g=i.catchall,h="none";if(g){let b=g._zod.def.type;if(b==="never"){let v=s.map(C=>`k !== ${lt(C)}`).join(" && ")||"true";e.write(`for (const k in ${a}) {`),e.indented(C=>{C.write(`if (${v}) return INVALID;`)}),e.write("}")}else(b==="unknown"||b==="any")&&!g._zod.def.checks?.length?h="passthrough":h="schema"}let f=G(t),_=c.some(b=>US(m[b])||qh(m[b]));if(!n){if(h==="schema"){let b=s.length>0?V(t,new Set(s)):null;e.write(`for (const k in ${a}) {`),e.indented(v=>{v.write('if (k === "__proto__") continue;'),b&&v.write(`if (${b}.has(k)) continue;`);let C=G(t);v.write(`const ${C} = ${a}[k];`),tt(v,t,g,C,!1)}),e.write("}")}return null}if(_){e.write(`const ${f} = {};`);for(let b of c){let v=u(b),C=p.get(b);qh(m[b])?e.write(`if (${v} in ${a}) ${f}[${v}] = ${C};`):US(m[b])?e.write(`if (${C} !== undefined || ${v} in ${a}) ${f}[${v}] = ${C};`):e.write(`${f}[${v}] = ${C};`)}}else{let b=c.map(v=>`${d(v)}: ${p.get(v)}`).join(", ");e.write(`const ${f} = { ${b} };`)}if(h!=="none"){let b=s.length>0?V(t,new Set(s)):null;e.write(`for (const k in ${a}) {`),e.indented(v=>{if(v.write('if (k === "__proto__") continue;'),b&&v.write(`if (${b}.has(k)) continue;`),h==="passthrough")v.write(`${f}[k] = ${a}[k];`);else{let C=G(t);v.write(`const ${C} = ${a}[k];`);let S=tt(v,t,g,C);v.write(`${f}[k] = ${S};`)}}),e.write("}")}return f}function g2(e,t,r,a,n=!0){let i=r._zod.def;if(h2(r))return $e(e,t,i.innerType,a,n);if(i.innerType._zod.optin==="defaulted"){let s=G(t),l=G(t);return e.write(`let ${s};`),e.write(`if (${a} === undefined) {`),e.indented(c=>{c.write(`const ${l} = (() => {`),c.indented(u=>{let d=$e(u,t,i.innerType,a);u.write(`return ${d};`)}),c.write("})();"),c.write(`if (${l} !== INVALID) ${s} = ${l};`)}),e.write("} else {"),e.indented(c=>{let u=$e(c,t,i.innerType,a);c.write(`${s} = ${u};`)}),e.write("}"),s}let o=n?G(t):null;return o&&e.write(`let ${o};`),e.write(`if (${a} !== undefined) {`),e.indented(s=>{let l=$e(s,t,i.innerType,a,n);o&&l!==null&&s.write(`${o} = ${l};`)}),e.write("}"),o}function h2(e){return e._zod.traits?.has("$ZodExactOptional")===!0}function f2(e){return e._zod.optin===void 0&&Mr(e)}function Mr(e){if(e._zod.def.coerce)return!0;let t=e._zod.def;switch(t.type){case"any":case"unknown":case"undefined":case"void":case"default":case"prefault":case"transform":case"custom":case"lazy":return!0;case"string":case"number":case"boolean":case"bigint":case"symbol":case"null":case"never":case"nan":case"date":case"object":case"array":case"tuple":case"record":case"map":case"set":case"file":case"template_literal":return!1;case"nonoptional":return t.innerType?Mr(t.innerType):!1;case"literal":return!!t.values?.includes(void 0);case"enum":return!!e._zod.values?.has(void 0);case"optional":case"nullable":case"readonly":case"success":return t.innerType?Mr(t.innerType):!0;case"catch":return!0;case"union":return t.options?t.options.some(Mr):!0;case"intersection":return!t.left||!t.right?!0:Mr(t.left)&&Mr(t.right);case"pipe":return t.in?Mr(t.in):!0;default:return!0}}function qh(e){return e._zod.optin==="optional"&&e._zod.optout==="optional"}function US(e){return(e._zod.optin!=="defaulted"||e._zod.optout==="optional")&&qa(e)}function qa(e){let t=e._zod.def;switch(t.type){case"string":case"number":case"boolean":case"bigint":case"symbol":case"null":case"nan":case"date":case"object":case"array":case"tuple":case"record":case"map":case"set":case"file":case"template_literal":case"never":case"success":return!1;case"literal":return!!t.values?.includes(void 0);case"enum":return!!e._zod.values?.has(void 0);case"optional":return!0;case"nullable":case"readonly":case"nonoptional":return t.innerType?qa(t.innerType):!0;case"union":return t.options?t.options.some(qa):!0;case"intersection":return!t.left||!t.right||qa(t.left)||qa(t.right);case"pipe":return t.out?qa(t.out):!0;default:return!0}}function b2(e,t,r,a,n=!0){let i=r._zod.def,o=n?G(t):null;return o&&e.write(`let ${o} = null;`),e.write(`if (${a} !== null) {`),e.indented(s=>{let l=$e(s,t,i.innerType,a,n);o&&l!==null&&s.write(`${o} = ${l};`)}),e.write("}"),o}function Vh(e,t,r){for(let[a,n]of Ea(t._zod.def.checks))e.write(`if (${r} > ${tr(a,n._zod.def.check)}) return INVALID;`)}function v2(e,t,r,a,n=!0){let i=r._zod.def;e.write(`if (!Array.isArray(${a})) return INVALID;`),Vh(e,r,`${a}.length`);let o=n?G(t):null,s=G(t),l=G(t);return o&&e.write(`const ${o} = new Array(${a}.length);`),e.write(`for (let ${s} = 0; ${s} < ${a}.length; ${s}++) {`),e.indented(c=>{c.write(`const ${l} = ${a}[${s}];`);let u=tt(c,t,i.element,l,n);o&&u!==null&&c.write(`${o}[${s}] = ${u};`)}),e.write("}"),o}function y2(e,t,r,a){let i=r._zod.def.values;if(i.length!==1){let s=V(t,new Set(i));return e.write(`if (!${s}.has(${a})) return INVALID;`),a}let o=i[0];if(typeof o=="number"&&Number.isNaN(o)){let s=V(t,new Set(i));return e.write(`if (!${s}.has(${a})) return INVALID;`),a}if(typeof o=="string")e.write(`if (${a} !== ${lt(o)}) return INVALID;`);else if(typeof o=="number"||typeof o=="boolean")e.write(`if (${a} !== ${o}) return INVALID;`);else if(o===null)e.write(`if (${a} !== null) return INVALID;`);else if(o===void 0)e.write(`if (${a} !== undefined) return INVALID;`);else if(typeof o=="bigint")e.write(`if (${a} !== ${o}n) return INVALID;`);else throw new se(`literal type ${typeof o}`);return a}function k2(e,t,r,a){let n=r._zod.values;if(!n)throw new se("enum schema without enumerated values");let i=V(t,n);return e.write(`if (!${i}.has(${a})) return INVALID;`),a}function FS(e,t,r,a){let n=r._zod.def;return $e(e,t,n.innerType,a)}function _2(e,t,r,a){let n=r._zod.def,o=Object.getOwnPropertyDescriptor(r._zod.def,"defaultValue")?()=>r._zod.def.defaultValue:void 0;if(r._zod.def.type==="prefault"){if(!o)return $e(e,t,n.innerType,a);let l=V(t,o),c=G(t);return e.write(`let ${c} = ${a};`),e.write(`if (${a} === undefined) ${c} = ${l}();`),$e(e,t,n.innerType,c)}let s=G(t);if(o){let l=V(t,o),c=V(t,Sa);e.write(`let ${s};`),e.write(`if (${a} === undefined) {`),e.indented(u=>{u.write(`${s} = ${c}(${l}());`)}),e.write("} else {"),e.indented(u=>{let d=$e(u,t,n.innerType,a);u.write(`${s} = ${d} === undefined ? ${c}(${l}()) : ${d};`)}),e.write("}")}else e.write(`let ${s};`),e.write(`if (${a} !== undefined) {`),e.indented(l=>{let c=$e(l,t,n.innerType,a);l.write(`${s} = ${c};`)}),e.write("}");return s}function w2(e,t,r,a){let n=r._zod.def,i=$e(e,t,n.innerType,a),o=G(t);return e.write(`const ${o} = ${i};`),e.write(`if (${o} === undefined) return INVALID;`),o}function S2(e,t,r,a){let n=r._zod.def,i=n.items,o=n.rest;e.write(`if (!Array.isArray(${a})) return INVALID;`);let s=qS(i,"optin"),l=qS(i,"optout");o?e.write(`if (${a}.length < ${s}) return INVALID;`):e.write(`if (${a}.length < ${s} || ${a}.length > ${i.length}) return INVALID;`);let c=G(t);e.write(`const ${c} = [];`);for(let u=0;u<i.length;u++){let d=i[u];if(u>=l)e.write(`if (${c}.length === ${u}) {`),e.indented(m=>{m.write(`if (${u} < ${a}.length) {`),m.indented(p=>{let g=G(t);p.write(`const ${g} = ${a}[${u}];`);let h=tt(p,t,d,g);p.write(`${c}[${u}] = ${h};`)}),m.write("} else {"),m.indented(p=>{if(qh(d)){p.write(`${c}.length = ${u};`);return}let g=G(t),h=G(t);p.write(`const ${g} = undefined;`),p.write(`const ${h} = (() => {`),p.indented(f=>{let _=tt(f,t,d,g);f.write(`return ${_};`)}),p.write("})();"),p.write(`if (${h} === INVALID || ${h} === undefined) ${c}.length = ${u};`),p.write(`else ${c}[${u}] = ${h};`)}),m.write("}")}),e.write("}");else{let m=G(t);e.write(`const ${m} = ${a}[${u}];`);let p=tt(e,t,d,m);e.write(`${c}[${u}] = ${p};`)}}if(o){let u=G(t),d=G(t);e.write(`for (let ${u} = ${i.length}; ${u} < ${a}.length; ${u}++) {`),e.indented(m=>{m.write(`const ${d} = ${a}[${u}];`);let p=tt(m,t,o,d);m.write(`${c}[${u}] = ${p};`)}),e.write("}")}return c}function qS(e,t){for(let r=e.length-1;r>=0;r--)if(!(t==="optin"?e[r]._zod.optin!==void 0:e[r]._zod.optout==="optional"))return r+1;return 0}function E2(e,t,r,a){let n=r._zod.def,i=n.options;if(n.discriminator)return x2(e,t,n,a);if(n.inclusive===!1)throw new se("exclusive unions (z.xor)");if(i.length===0)return e.write("return INVALID;"),a;if(i.length===1)return $e(e,t,i[0],a);if(i.every(l=>l._zod.def.type==="literal"&&!l._zod.def.checks?.length)){let l=new Set(i.flatMap(u=>u._zod.def.values)),c=V(t,l);return e.write(`if (!${c}.has(${a})) return INVALID;`),a}let s=G(t);e.write(`let ${s};`);for(let l=0;l<i.length;l++){let c=i[l];l===0?e.write(`${s} = (() => {`):e.write(`if (${s} === INVALID) ${s} = (() => {`),e.indented(u=>{let d=$e(u,t,c,a);u.write(`return ${d};`)}),e.write("})();")}return e.write(`if (${s} === INVALID) return INVALID;`),s}function x2(e,t,r,a){if(r.unionFallback)throw new se("discriminated union with unionFallback");if(r.options.length===0)return e.write("return INVALID;"),a;let n=G(t),i=G(t);e.write(`const ${n} = ${a}?.[${lt(r.discriminator)}];`),e.write(`let ${i};`);let o=!0,s=new Set;for(let l of r.options){let c=l._zod.propValues?.[r.discriminator];if(!c||c.size===0)throw new se("discriminated union option without static discriminator values");for(let m of c){if(s.has(m))throw new se(`duplicate discriminator value ${String(m)}`);s.add(m)}let u=Array.from(c,m=>T2(t,n,m)),d=o?"if":"else if";e.write(`${d} (${u.join(" || ")}) {`),e.indented(m=>{let p=$e(m,t,l,a);m.write(`${i} = ${p};`)}),e.write("}"),o=!1}return e.write("else { return INVALID; }"),i}function T2(e,t,r){if(typeof r=="string")return`${t} === ${lt(r)}`;if(typeof r=="number")return Number.isNaN(r)?`Number.isNaN(${t})`:`${t} === ${r}`;if(typeof r=="boolean")return`${t} === ${r}`;if(r===null)return`${t} === null`;if(r===void 0)return`${t} === undefined`;if(typeof r=="bigint")return`${t} === ${r}n`;if(typeof r=="symbol"){let a=V(e,r);return`${t} === ${a}`}throw new se(`literal discriminator value ${String(r)}`)}function A2(e,t,r,a){let n=r._zod.def;t.definite=!1;let i=tt(e,t,n.left,a),o=tt(e,t,n.right,a),s=V(t,Oa),l=G(t);return e.write(`const ${l} = ${s}(${i}, ${o});`),e.write(`if (!${l}.valid) return INVALID;`),`${l}.data`}function C2(e,t,r,a){let n=r._zod.def,i=V(t,Dt);e.write(`if (!${i}(${a})) return INVALID;`);let o=G(t),s=G(t),l=G(t);e.write(`const ${o} = {};`);let c=n,u=c.partial?void 0:n.keyType._zod.values;if(u){let p=[];for(let h of u){if(!(typeof h=="string"||typeof h=="number"||typeof h=="symbol"))throw new se(`record key value ${String(h)}`);let f=typeof h=="number"?h.toString():h;if(f==="__proto__")throw new se('record key "__proto__"');p.push(f);let _=V(t,h),b=$e(e,t,n.keyType,_),v=G(t);e.write(`const ${v} = ${a}[${z2(t,f)}];`);let C=tt(e,t,n.valueType,v);e.write(`${o}[${b}] = ${C};`)}let g=V(t,new Set(p));return e.write(`for (const ${s} in ${a}) {`),e.indented(h=>{h.write(`if (${g}.has(${s})) continue;`),c.mode==="loose"?h.write(`if (${s} !== "__proto__") ${o}[${s}] = ${a}[${s}];`):h.write("return INVALID;")}),e.write("}"),o}let d=n.keyType._zod.def;if(!(d.type==="string"&&d.format===void 0&&!d.coerce&&(d.checks?.length??0)===0)){let p=n.mode==="loose",g=Lu(n.keyType);g.definite===!1&&(t.definite=!1);let h=V(t,g),f=V(t,An),_=G(t);return HS(e,t,a,s,b=>{b.write(`let ${_} = ${h}(${s});`),b.write(`if (${_} === INVALID && typeof ${s} === "string" && ${f}.test(${s})) ${_} = ${h}(Number(${s}));`),p?b.write(`if (${_} === INVALID) { ${o}[${s}] = ${a}[${s}]; continue; }`):b.write(`if (${_} === INVALID) return INVALID;`),b.write(`if (${_} === "__proto__") continue;`);let v=G(t);b.write(`const ${v} = ${a}[${s}];`);let C=tt(b,t,n.valueType,v);b.write(`${o}[${_}] = ${C};`)}),o}return HS(e,t,a,s,p=>{p.write(`const ${l} = ${a}[${s}];`);let g=tt(p,t,n.valueType,l);p.write(`${o}[${s}] = ${g};`)},"return INVALID;"),o}function HS(e,t,r,a,n,i){let o=V(t,Object.prototype.propertyIsEnumerable),s=G(t),l=G(t),c=G(t);e.write(`const ${s} = Object.getOwnPropertySymbols(${r});`),e.write(`const ${l} = Object.getOwnPropertyNames(${r});`),e.write(`for (let ${c} = 0; ${c} < ${l}.length; ${c}++) {`),e.indented(u=>{u.write(`const ${a} = ${l}[${c}];`),u.write(`if (${a} === "__proto__" || !${o}.call(${r}, ${a})) continue;`),n(u)}),e.write("}"),e.write(`for (let ${c} = 0; ${c} < ${s}.length; ${c}++) {`),e.indented(u=>{u.write(`const ${a} = ${s}[${c}];`),u.write(`if (!${o}.call(${r}, ${a})) continue;`),i?u.write(i):n(u)}),e.write("}")}function z2(e,t){return typeof t=="string"?lt(t):V(e,t)}function I2(e,t,r,a){let n=r._zod.def;e.write(`if (!(${a} instanceof Map)) return INVALID;`),Vh(e,r,`${a}.size`);let i=G(t),o=G(t),s=G(t);return e.write(`const ${i} = new Map();`),e.write(`for (const [${o}, ${s}] of ${a}) {`),e.indented(l=>{let c=$e(l,t,n.keyType,o),u=$e(l,t,n.valueType,s);l.write(`${i}.set(${c}, ${u});`)}),e.write("}"),i}function P2(e,t,r,a){let n=r._zod.def;e.write(`if (!(${a} instanceof Set)) return INVALID;`),Vh(e,r,`${a}.size`);let i=G(t),o=G(t);return e.write(`const ${i} = new Set();`),e.write(`for (const ${o} of ${a}) {`),e.indented(s=>{let l=$e(s,t,n.valueType,o);s.write(`${i}.add(${l});`)}),e.write("}"),i}function R2(e,t){return e.write(`if (!(${t} instanceof File)) return INVALID;`),t}function $2(e,t,r,a){e.write(`if (typeof ${a} !== "string") return INVALID;`);let n=r._zod.pattern;if(n){let i=V(t,n);e.write(`${i}.lastIndex = 0;`),e.write(`if (!${i}.test(${a})) return INVALID;`)}return a}function j2(e,t,r,a){let n=r._zod.def,i=Lr(t,n.getter),o=V(t,{parser:null});e.write(`if (!${o}.parser) {`),e.indented(l=>{l.write(`const inner = ${i}();`),l.write(`${o}.parser = function(input) {`),l.indented(c=>{c.write("const result = inner._zod.run({ value: input, issues: [] }, {});"),c.write("return result.issues.length === 0 ? result.value : INVALID;")}),l.write("};")}),e.write("}");let s=G(t);return e.write(`const ${s} = ${o}.parser(${a});`),e.write(`if (${s} === INVALID) return INVALID;`),s}function O2(e,t,r,a){let n=r._zod.def,i=$e(e,t,n.in,a);if(n.transform){if(Br(n.transform))throw new Vt("z.compile: async transforms in pipes are not supported");let o=n.transform,l=Lr(t,u=>{let d={value:u,issues:[],addIssue:Gh},m=o(u,d);return m instanceof Promise?ut:d.issues.length===0?m:ut}),c=G(t);return e.write(`const ${c} = ${l}(${i});`),e.write(`if (${c} === INVALID) return INVALID;`),$e(e,t,n.out,c)}else return $e(e,t,n.out,i)}function Br(e){return typeof e=="function"&&(e.constructor.name==="AsyncFunction"||e[Symbol.toStringTag]==="AsyncFunction")}function N2(e,t,r,a){let n=r._zod.def;if(n.fn){if(Br(n.fn))throw new Vt("z.compile: async custom predicates are not supported");let i=Lr(t,n.fn),o=V(t,Fh),s=G(t);e.write(`const ${s} = ${i}(${a});`),e.write(`if (${s} instanceof Promise) ${o}();`),e.write(`if (!${s}) return INVALID;`)}else throw new se("custom schema without a predicate function");return a}function D2(e,t,r){let a=e._zod.run({value:r,issues:[]},{});if(a&&typeof a.then=="function")return ut;let n=a;return n.issues.length===0?n.value:t()}function M2(e,t,r,a){let n=r._zod.def;if(!n.catchValue[Wl])throw new se("catch with a callback (only a constant catch value compiles)",!1);let i=G(t);e.write(`let ${i} = (() => {`),e.indented(c=>{let u=tt(c,t,n.innerType,a);c.write(`return ${u};`)}),e.write("})();");let o=V(t,n.innerType),s=Lr(t,n.catchValue),l=V(t,D2);return e.write(`if (${i} === INVALID) {`),e.indented(c=>{c.write(`${i} = ${l}(${o}, ${s}, ${a});`),c.write(`if (${i} === INVALID) return INVALID;`)}),e.write("}"),i}function L2(e,t,r,a){let n=r._zod.def;if(n.transform){if(Br(n.transform))throw new Vt("z.compile: async transforms are not supported");let i=n.transform,s=Lr(t,c=>{let u={value:c,issues:[],addIssue:Gh},d=i(c,u);return d instanceof Promise?ut:u.issues.length===0?d:ut}),l=G(t);return e.write(`const ${l} = ${s}(${a});`),e.write(`if (${l} === INVALID) return INVALID;`),l}return a}function Bu(e){return e.checks&&(e.checks=[...e.checks]),e}function Uu(e,t){return new e(Bu({type:"string",...z(t)}))}function Wh(e,t){return new e(Bu({type:"string",coerce:!0,...z(t)}))}function qo(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...z(t)})}function Ho(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...z(t)})}function Go(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...z(t)})}function Vo(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...z(t)})}function Wo(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...z(t)})}function Ko(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...z(t)})}function Ha(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...z(t)})}function Zo(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...z(t)})}function Jo(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...z(t)})}function Yo(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...z(t)})}function Xo(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...z(t)})}function Qo(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...z(t)})}function es(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...z(t)})}function ts(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...z(t)})}function ns(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...z(t)})}function rs(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...z(t)})}function Fu(e,t){return new e({type:"string",format:"mac",check:"string_format",abort:!1,...z(t)})}function as(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...z(t)})}function is(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...z(t)})}function os(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...z(t)})}function ss(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...z(t)})}function ls(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...z(t)})}function qu(e,t){return new e({type:"string",format:"credit_card",check:"string_format",abort:!1,...z(t)})}function Hu(e,t){return new e({type:"string",format:"iban",check:"string_format",abort:!1,...z(t)})}function cs(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...z(t)})}var Kh={Any:null,Minute:-1,Second:0,Millisecond:3,Microsecond:6};function us(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...z(t)})}function ds(e,t){return new e({type:"string",format:"date",check:"string_format",...z(t)})}function ps(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...z(t)})}function ms(e,t){return new e({type:"string",format:"duration",check:"string_format",...z(t)})}function Gu(e,t){return new e(Bu({type:"number",checks:[],...z(t)}))}function Zh(e,t){return new e(Bu({type:"number",coerce:!0,checks:[],...z(t)}))}function Vu(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...z(t)})}function Wu(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"float32",...z(t)})}function Ku(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"float64",...z(t)})}function Zu(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"int32",...z(t)})}function Ju(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"uint32",...z(t)})}function Yu(e,t){return new e({type:"boolean",...z(t)})}function Jh(e,t){return new e({type:"boolean",coerce:!0,...z(t)})}function Xu(e,t){return new e({type:"bigint",...z(t)})}function Yh(e,t){return new e({type:"bigint",coerce:!0,...z(t)})}function Qu(e,t){return new e({type:"bigint",check:"bigint_format",abort:!1,format:"int64",...z(t)})}function ed(e,t){return new e({type:"bigint",check:"bigint_format",abort:!1,format:"uint64",...z(t)})}function td(e,t){return new e({type:"symbol",...z(t)})}function nd(e,t){return new e({type:"undefined",...z(t)})}function rd(e,t){return new e({type:"null",...z(t)})}function ad(e){return new e({type:"any"})}function id(e){return new e({type:"unknown"})}function od(e,t){return new e({type:"never",...z(t)})}function sd(e,t){return new e({type:"void",...z(t)})}function ld(e,t){return new e({type:"date",...z(t)})}function Xh(e,t){return new e({type:"date",coerce:!0,...z(t)})}function cd(e,t){return new e({type:"nan",...z(t)})}function ln(e,t){return new sc({check:"less_than",...z(t),value:e,inclusive:!1})}function zt(e,t){return new sc({check:"less_than",...z(t),value:e,inclusive:!0})}function cn(e,t){return new lc({check:"greater_than",...z(t),value:e,inclusive:!1})}function It(e,t){return new lc({check:"greater_than",...z(t),value:e,inclusive:!0})}function ud(e){return cn(0,e)}function dd(e){return ln(0,e)}function pd(e){return zt(0,e)}function md(e){return It(0,e)}function nr(e,t){return new oh({check:"multiple_of",...z(t),value:e})}function rr(e,t){return new ch({check:"max_size",...z(t),maximum:e})}function un(e,t){return new uh({check:"min_size",...z(t),minimum:e})}function Ur(e,t){return new dh({check:"size_equals",...z(t),size:e})}function Fr(e,t){return new ph({check:"max_length",...z(t),maximum:e})}function Cn(e,t){return new mh({check:"min_length",...z(t),minimum:e})}function qr(e,t){return new gh({check:"length_equals",...z(t),length:e})}function Ga(e,t){return new hh({check:"string_format",format:"regex",...z(t),pattern:e})}function Va(e){return new fh({check:"string_format",format:"lowercase",...z(e)})}function Wa(e){return new bh({check:"string_format",format:"uppercase",...z(e)})}function Ka(e,t){return new vh({check:"string_format",format:"includes",...z(t),includes:e})}function Za(e,t){return new yh({check:"string_format",format:"starts_with",...z(t),prefix:e})}function Ja(e,t){return new kh({check:"string_format",format:"ends_with",...z(t),suffix:e})}function gd(e,t,r){return new _h({check:"property",property:e,schema:t,...z(r)})}function Ya(e,t){return new wh({check:"properties",shape:e,...z(t)})}function Xa(e,t){return new Sh({check:"mime_type",mime:e,...z(t)})}function Wt(e){return new Eh({check:"overwrite",tx:e})}function Qa(e){return Wt(t=>t.normalize(e))}function ei(){return Wt(e=>e.trim())}function ti(){return Wt(e=>e.toLowerCase())}function ni(){return Wt(e=>e.toUpperCase())}function ri(){return Wt(e=>sg(e))}function Qh(e,t,r){return new e({type:"array",element:t,...z(r)})}function B2(e,t,r){return new e({type:"union",options:t,...z(r)})}function U2(e,t,r){return new e({type:"union",options:t,inclusive:!1,...z(r)})}function F2(e,t,r,a){return new e({type:"union",options:r,discriminator:t,...z(a)})}function q2(e,t,r){return new e({type:"intersection",left:t,right:r})}function H2(e,t,r,a){let n=r instanceof Z,i=n?a:r,o=n?r:null;return new e({type:"tuple",items:t,rest:o,...z(i)})}function G2(e,t,r,a){return new e({type:"record",keyType:t,valueType:r,...z(a)})}function V2(e,t,r,a){return new e({type:"map",keyType:t,valueType:r,...z(a)})}function W2(e,t,r){return new e({type:"set",valueType:t,...z(r)})}function K2(e,t,r){let a=Array.isArray(t)?Object.fromEntries(t.map(n=>[n,n])):t;return new e({type:"enum",entries:a,...z(r)})}function Z2(e,t,r){return new e({type:"enum",entries:t,...z(r)})}function J2(e,t,r){return new e({type:"literal",values:Array.isArray(t)?t:[t],...z(r)})}function hd(e,t){return new e({type:"file",...z(t)})}function Y2(e,t){return new e({type:"transform",transform:t})}function X2(e,t){return new e({type:"optional",innerType:t})}function Q2(e,t){return new e({type:"nullable",innerType:t})}function e0(e,t,r){return new e({type:"default",innerType:t,get defaultValue(){return typeof r=="function"?r():Sa(r)}})}function t0(e,t,r){return new e({type:"nonoptional",innerType:t,...z(r)})}function n0(e,t){return new e({type:"success",innerType:t})}function r0(e,t,r){return new e({type:"catch",innerType:t,catchValue:typeof r=="function"?r:gg(r)})}function a0(e,t,r){return new e({type:"pipe",in:t,out:r})}function i0(e,t){return new e({type:"readonly",innerType:t})}function o0(e,t,r){return new e({type:"template_literal",parts:t,...z(r)})}function s0(e,t){return new e({type:"lazy",getter:t})}function l0(e,t){return new e({type:"promise",innerType:t})}function fd(e,t,r){let a=z(r);return a.abort??(a.abort=!0),new e({type:"custom",check:"custom",fn:t,...a})}function bd(e,t,r){return new e({type:"custom",check:"custom",fn:t,...z(r)})}function vd(e,t){let r=KS(a=>(a.addIssue=n=>{if(typeof n=="string")a.issues.push(xa(n,a.value,r._zod.def));else{let i=n;i.fatal&&(i.continue=!1),i.code??(i.code="custom"),"input"in i||(i.input=a.value),i.inst??(i.inst=r),i.continue??(i.continue=!r._zod.def.abort),a.issues.push(xa(i))}},e(a.value,a)),t);return r}function KS(e,t){let r=new _e({check:"custom",...z(t)});return r._zod.check=e,r}function yd(e){let t=new _e({check:"describe"});return t._zod.onattach=[r=>{let a=Ve.get(r)??{};Ve.add(r,{...a,description:e})}],t._zod.check=()=>{},t}function kd(e){let t=new _e({check:"meta"});return t._zod.onattach=[r=>{let a=Ve.get(r)??{};Ve.add(r,{...a,...e})}],t._zod.check=()=>{},t}function _d(e,t){let r=z(t),a=r.truthy??["true","1","yes","on","y","enabled"],n=r.falsy??["false","0","no","off","n","disabled"];r.case!=="sensitive"&&(a=a.map(p=>typeof p=="string"?p.toLowerCase():p),n=n.map(p=>typeof p=="string"?p.toLowerCase():p));let i=new Set(a),o=new Set(n),s=e.Codec??Ma,l=e.Boolean??Na,c=e.String??er,u=new c({type:"string",error:r.error}),d=new l({type:"boolean",error:r.error}),m=new s({type:"pipe",in:u,out:d,transform:((p,g)=>{let h=p;return r.case!=="sensitive"&&(h=h.toLowerCase()),i.has(h)?!0:o.has(h)?!1:(g.issues.push({code:"invalid_value",expected:"stringbool",values:[...i,...o],input:g.value,inst:m,continue:!1}),{})}),reverseTransform:((p,g)=>p===!0?a[0]||"true":n[0]||"false"),error:r.error});return m._zod.bag.truthy=a,m._zod.bag.falsy=n,m._zod.bag.case=r.case??"insensitive",m}function ar(e,t,r,a={}){let n=z(a),i={check:"string_format",type:"string",format:t,fn:typeof r=="function"?r:s=>r.test(s),...n};return r instanceof RegExp&&(i.pattern=r),new e(i)}function gs(e,...t){for(let r of t)for(let a of Reflect.ownKeys(r))Object.prototype.propertyIsEnumerable.call(r,a)&&Ge(e,a,r[a]);return e}function ir(e){let t=e?.target??"draft-2020-12";return t==="draft-4"&&(t="draft-04"),t==="draft-7"&&(t="draft-07"),{processors:e.processors??{},metadataRegistry:e?.metadata??Ve,target:t,unrepresentable:e?.unrepresentable??"throw",override:e?.override??(()=>{}),io:e?.io??"output",counter:0,seen:new Map,sharedDefsExtractedFor:void 0,sharedEmitDoneFor:void 0,cycles:e?.cycles??"ref",reused:e?.reused??"inline",intersections:[],deferred:[],external:e?.external??void 0}}function Be(e,t,r,a,n){let i=typeof t.unrepresentable=="function"?t.unrepresentable({zodSchema:e,path:a.path,message:n}):t.unrepresentable;if(i==="any")return!1;if(i===void 0||i==="throw")throw new Error(n);return Object.assign(r,i),!0}function ve(e,t,r={path:[],schemaPath:[]}){var a;let n=e._zod.def,i=t.seen.get(e);if(i)return i.count++,r.schemaPath.includes(e)&&(i.cycle=r.path),i.schema;let o={schema:{},count:1,cycle:void 0,path:r.path};t.seen.set(e,o),t.sharedDefsExtractedFor=void 0,t.sharedEmitDoneFor=void 0;let s=e._zod.toJSONSchema?.();if(s)o.schema=s;else{let u={...r,schemaPath:[...r.schemaPath,e],path:r.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,o.schema,u);else{let m=o.schema,p=t.processors[n.type];if(!p)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${n.type}`);p(e,t,m,u)}let d=e._zod.parent;d&&(o.ref||(o.ref=d),ve(d,t,u),t.seen.get(d).isParent=!0)}let l=t.metadataRegistry.get(e);return l&&gs(o.schema,l),t.io==="input"&&dt(e)&&(delete o.schema.examples,delete o.schema.default),t.io==="input"&&"_prefault"in o.schema&&((a=o.schema).default??(a.default=o.schema._prefault)),delete o.schema._prefault,t.seen.get(e).schema}function ZS(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}function or(e,t){let r=e.seen.get(t);if(!r)throw new Error("Unprocessed schema. This is a bug in Zod.");if(e.external&&e.sharedDefsExtractedFor===e.external)return;let a=new Map;for(let o of e.seen.entries()){let s=e.metadataRegistry.get(o[0])?.id;if(s){let l=a.get(s);if(l&&l!==o[0])throw new Error(`Duplicate schema id "${s}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);a.set(s,o[0])}}let n=o=>{let s=e.target==="draft-2020-12"?"$defs":"definitions";if(e.external){let d=e.external.registry.get(o[0])?.id,m=e.external.uri??(g=>g);if(d)return{ref:m(d)};let p=o[1].defId??o[1].schema.id??`schema${e.counter++}`;return o[1].defId=p,{defId:p,ref:`${m("__shared")}#/${s}/${ZS(p)}`}}let l="#",c=`${l}/${s}/`;if(o[1]===r&&!o[1].schema.id)return{ref:l};let u=o[1].schema.id??`__schema${e.counter++}`;return{defId:u,ref:c+ZS(u)}},i=o=>{if(o[1].schema.$ref)return;let s=o[1],{ref:l,defId:c}=n(o);s.def={...s.schema},c&&(s.defId=c);let u=s.schema;for(let d in u)delete u[d];u.$ref=l};if(e.cycles==="throw")for(let o of e.seen.entries()){let s=o[1];if(s.cycle)throw new Error(`Cycle detected: #/${s.cycle?.join("/")}/<root>
|
|
69
69
|
|
|
70
|
-
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let o of e.seen.entries()){let s=o[1];if(t===o[0]){i(o);continue}if(e.external){let c=e.external.registry.get(o[0])?.id;if(t!==o[0]&&c){i(o);continue}}if(e.metadataRegistry.get(o[0])?.id){i(o);continue}if(s.cycle){i(o);continue}s.count>1&&e.reused==="ref"&&i(o)}e.external&&(e.sharedDefsExtractedFor=e.external)}function XS(e){let t=e.anyOf;if(!Array.isArray(t)||t.length===0||e.type!==void 0)return;let r=[];for(let a of t){if(!a||typeof a!="object")return;XS(a);let n=Object.keys(a);if(n.length!==1||n[0]!=="type")return;let i=a.type;for(let o of Array.isArray(i)?i:[i]){if(typeof o!="string")return;r.includes(o)||r.push(o)}}delete e.anyOf,e.type=r.length===1?r[0]:r}var QS=new Set(["type","properties","required","additionalProperties"]),JS=["oneOf","anyOf"];function YS(e){let t=e.additionalProperties;return t===void 0||t===!1||typeof t!="object"||t===null?null:Object.keys(t).length?t:null}function ef(e){let t=[];for(let i of e){if(typeof i!="object"||i.type!=="object")return null;for(let o in i)if(!QS.has(o))return null;t.push(i)}let r={},a=new Set;for(let i of t){for(let o in i.properties){if(Object.prototype.hasOwnProperty.call(r,o))continue;let s=[];for(let c of t){let u=c.properties?.[o]??YS(c);u!=null&&(s.some(d=>JSON.stringify(d)===JSON.stringify(u))||s.push(u))}let l=s.length===1?s[0]:ef(s)??{allOf:s};Ge(r,o,l)}for(let o of i.required??[])a.add(o)}let n={type:"object",properties:r};if(a.size&&(n.required=[...a]),t.every(i=>i.additionalProperties===!1))n.additionalProperties=!1;else{let i=[];for(let o of t){let s=YS(o);s&&!i.some(l=>JSON.stringify(l)===JSON.stringify(s))&&i.push(s)}i.length===1?n.additionalProperties=i[0]:i.length>1&&(n.additionalProperties={allOf:i})}return n}function c0(e){let t=e.allOf;if(!Array.isArray(t)||t.length<2)return;for(let n of QS)if(n in e)return;let r=t.filter(n=>JS.some(i=>Array.isArray(n[i]))),a=null;if(!r.length)a=ef(t);else{let n=r[0],i=JS.find(l=>Array.isArray(n[l]));if(Object.keys(n).length!==1)return;let o=t.filter(l=>l!==n),s=n[i].map(l=>ef([...o,l]));if(s.some(l=>!l))return;a={[i]:s}}a&&(delete e.allOf,gs(e,a))}function sr(e,t){let r=e.seen.get(t);if(!r)throw new Error("Unprocessed schema. This is a bug in Zod.");let a=s=>{let l=e.seen.get(s);if(l.ref===null)return;let c=l.def??l.schema,u={...c},d=l.ref;if(l.ref=null,d){a(d);let p=e.seen.get(d),g=p.schema;if(g.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0")?(c.allOf=c.allOf??[],c.allOf.push(g)):gs(c,g),gs(c,u),s._zod.parent===d)for(let f in c)f==="$ref"||f==="allOf"||f in u||delete c[f];if(g.$ref&&p.def)for(let f in c)f==="$ref"||f==="allOf"||f in p.def&&JSON.stringify(c[f])===JSON.stringify(p.def[f])&&delete c[f]}let m=s._zod.parent;if(m&&m!==d){a(m);let p=e.seen.get(m);if(p?.schema.$ref&&(c.$ref=p.schema.$ref,p.def))for(let g in c)g==="$ref"||g==="allOf"||g in p.def&&JSON.stringify(c[g])===JSON.stringify(p.def[g])&&delete c[g]}e.override({zodSchema:s,jsonSchema:c,path:l.path??[]})};if(!e.external||e.sharedEmitDoneFor!==e.external){for(let s of[...e.seen.entries()].reverse())a(s[0]);if(e.target!=="openapi-3.0")for(let s of e.seen.entries())XS(s[1].def??s[1].schema);for(let s of e.deferred)s();if(e.intersections.length){let s=new Map;for(let l of e.seen.values())for(let c of[l.schema,l.def]){let u=c?.allOf;if(!Array.isArray(u))continue;let d=s.get(u);d?d.push(c):s.set(u,[c])}for(let l of e.intersections)for(let c of s.get(l)??[])c0(c)}}let n={};if(e.target==="draft-2020-12"?n.$schema="https://json-schema.org/draft/2020-12/schema":e.target==="draft-07"?n.$schema="http://json-schema.org/draft-07/schema#":e.target==="draft-04"?n.$schema="http://json-schema.org/draft-04/schema#":e.target,e.external?.uri){let s=e.external.registry.get(t)?.id;if(!s)throw new Error("Schema is missing an `id` property");n.$id=e.external.uri(s)}gs(n,r.defId?r.schema:r.def??r.schema);let i=e.metadataRegistry.get(t)?.id;i!==void 0&&n.id===i&&delete n.id;let o=e.external?.defs??{};if(!e.external||e.sharedEmitDoneFor!==e.external)for(let s of e.seen.entries()){let l=s[1];l.def&&l.defId&&(l.def.id===l.defId&&delete l.def.id,Ge(o,l.defId,l.def))}e.external&&(e.sharedEmitDoneFor=e.external),e.external||Object.keys(o).length>0&&(e.target==="draft-2020-12"?n.$defs=o:n.definitions=o);try{let s=JSON.parse(JSON.stringify(n));return Object.defineProperty(s,"~standard",{value:{...t["~standard"],jsonSchema:{input:ai(t,"input",e.processors),output:ai(t,"output",e.processors)}},enumerable:!1,writable:!1}),s}catch{throw new Error("Error converting schema to JSON.")}}function dt(e,t){let r=t??{seen:new Set};if(r.seen.has(e))return!1;r.seen.add(e);let a=e._zod.def;if(a.type==="transform")return!0;if(a.type==="array")return dt(a.element,r);if(a.type==="set")return dt(a.valueType,r);if(a.type==="lazy")return dt(a.getter(),r);if(a.type==="promise"||a.type==="optional"||a.type==="nonoptional"||a.type==="nullable"||a.type==="readonly"||a.type==="default"||a.type==="prefault"||a.type==="catch")return dt(a.innerType,r);if(a.type==="intersection")return dt(a.left,r)||dt(a.right,r);if(a.type==="record"||a.type==="map")return dt(a.keyType,r)||dt(a.valueType,r);if(a.type==="pipe")return e._zod.traits.has("$ZodCodec")?!0:dt(a.in,r)||dt(a.out,r);if(a.type==="object"){for(let n in a.shape)if(dt(a.shape[n],r))return!0;return!1}if(a.type==="union"){for(let n of a.options)if(dt(n,r))return!0;return!1}if(a.type==="tuple"){for(let n of a.items)if(dt(n,r))return!0;return!!(a.rest&&dt(a.rest,r))}return!1}var tf=(e,t={})=>r=>{let a=ir({...r,processors:t});return ve(e,a),or(a,e),sr(a,e)},ai=(e,t,r={})=>a=>{let{libraryOptions:n,target:i}=a??{},o=ir({...n??{},target:i,io:t,processors:r});return ve(e,o),or(o,e),sr(o,e)};var ii=(e,t,r)=>{(e[t]===void 0||r>e[t])&&(e[t]=r)},oi=(e,t,r)=>{(e[t]===void 0||r<e[t])&&(e[t]=r)},eE=(e,t)=>{ii(e,"minimum",t),oi(e,"maximum",t)},aE=(e,t)=>{e.multipleOf??(e.multipleOf=[]),e.multipleOf.includes(t)||e.multipleOf.push(t)},iE=(e,t)=>{e.patterns??(e.patterns=new Set),e.patterns.add(t)},oE=(e,t)=>{e.mime=e.mime?e.mime.filter(r=>t.includes(r)):[...t]},sE=(e,t)=>{e.format=t,t.includes("int")&&(e.isInt=!0)},tE=(e,t)=>ii(e,"minimum",t.minimum),nE=(e,t)=>oi(e,"maximum",t.maximum),rE=e=>(t,r)=>{sE(t,r.format);let[a,n]=e[r.format];ii(t,"minimum",a),oi(t,"maximum",n)},u0={greater_than:(e,t)=>ii(e,t.inclusive?"minimum":"exclusiveMinimum",t.value),less_than:(e,t)=>oi(e,t.inclusive?"maximum":"exclusiveMaximum",t.value),multiple_of:(e,t)=>aE(e,t.value),number_format:rE(bo),bigint_format:rE(vo),min_length:tE,max_length:nE,length_equals:(e,t)=>eE(e,t.length),min_size:tE,max_size:nE,size_equals:(e,t)=>eE(e,t.size),string_format:(e,t)=>{sE(e,t.format),t.pattern&&iE(e,t.pattern),(t.format==="base64"||t.format==="base64url")&&(e.contentEncoding=t.format),(t.local||t.precision===-1)&&(e.laxFormat=!0)},mime_type:(e,t)=>oE(e,t.mime)};function Ue(e){let t={},r=e._zod.def,a=e._zod.traits.has("$ZodCheck")?[e,...r.checks??[]]:r.checks??[];for(let i of a)u0[i._zod.def.check]?.(t,i._zod.def);let n=e._zod.bag;n.minimum!==void 0&&ii(t,"minimum",n.minimum),n.exclusiveMinimum!==void 0&&ii(t,"exclusiveMinimum",n.exclusiveMinimum),n.maximum!==void 0&&oi(t,"maximum",n.maximum),n.exclusiveMaximum!==void 0&&oi(t,"exclusiveMaximum",n.exclusiveMaximum),n.multipleOf!==void 0&&aE(t,n.multipleOf),n.format!==void 0&&(t.format??(t.format=n.format),n.format.includes("int")&&(t.isInt=!0)),n.mime&&oE(t,n.mime);for(let i of n.patterns??[])iE(t,i);return t}var d0={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},p0=new Map([[jc,Bg],[$o,Ug]]),lE=e=>p0.get(e)??e,af=(e,t,r,a)=>{let n=r;n.type="string";let{minimum:i,maximum:o,format:s,patterns:l,contentEncoding:c,laxFormat:u}=Ue(e);if(typeof i=="number"&&(n.minLength=i),typeof o=="number"&&(n.maxLength=o),s&&(n.format=d0[s]??s,n.format===""&&delete n.format,(s==="time"||u)&&delete n.format),c&&(n.contentEncoding=c),l&&l.size>0){let d=[...l].map(lE);d.length===1?n.pattern=d[0].source:d.length>1&&(n.allOf=[...d.map(m=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:m.source}))])}},of=(e,t,r,a)=>{let n=r,{minimum:i,maximum:o,multipleOf:s,exclusiveMaximum:l,exclusiveMinimum:c,isInt:u}=Ue(e);n.type=u?"integer":"number";let d=typeof c=="number"&&c>=(i??Number.NEGATIVE_INFINITY),m=typeof l=="number"&&l<=(o??Number.POSITIVE_INFINITY),p=t.target==="draft-04"||t.target==="openapi-3.0";if(d?p?(n.minimum=c,n.exclusiveMinimum=!0):n.exclusiveMinimum=c:typeof i=="number"&&(n.minimum=i),m?p?(n.maximum=l,n.exclusiveMaximum=!0):n.exclusiveMaximum=l:typeof o=="number"&&(n.maximum=o),s){let g=new Set;for(let _ of s)Number.isFinite(_)&&_!==0?g.add(Math.abs(_)):Be(e,t,n,a,`A multipleOf divisor of ${_} cannot be represented in JSON Schema`);let[h,...f]=g;h!==void 0&&(n.multipleOf=h),f.length&&(n.allOf=[...n.allOf??[],...f.map(_=>({multipleOf:_}))])}},sf=(e,t,r,a)=>{r.type="boolean"},lf=(e,t,r,a)=>{Be(e,t,r,a,"BigInt cannot be represented in JSON Schema")},cf=(e,t,r,a)=>{Be(e,t,r,a,"Symbols cannot be represented in JSON Schema")},uf=(e,t,r,a)=>{t.target==="openapi-3.0"?(r.type="string",r.nullable=!0,r.enum=[null]):r.type="null"},df=(e,t,r,a)=>{Be(e,t,r,a,"Undefined cannot be represented in JSON Schema")},pf=(e,t,r,a)=>{Be(e,t,r,a,"Void cannot be represented in JSON Schema")},mf=(e,t,r,a)=>{r.not={}},gf=(e,t,r,a)=>{},hf=(e,t,r,a)=>{},ff=(e,t,r,a)=>{Be(e,t,r,a,"Date cannot be represented in JSON Schema")},bf=(e,t,r,a)=>{let n=e._zod.def,i=ya(n.entries);if(i.length===0){r.not={};return}i.every(o=>typeof o=="number")&&(r.type="number"),i.every(o=>typeof o=="string")&&(r.type="string"),r.enum=i},vf=(e,t,r,a)=>{let n=e._zod.def;if(n.values.length===0){r.not={};return}let i=[];for(let o of n.values)if(o===void 0){if(Be(e,t,r,a,"Literal `undefined` cannot be represented in JSON Schema"))return}else if(typeof o=="bigint"){if(Be(e,t,r,a,"BigInt literals cannot be represented in JSON Schema"))return;i.push(Number(o))}else i.push(o);if(i.length!==0)if(i.length===1){let o=i[0];r.type=o===null?"null":typeof o,t.target==="draft-04"||t.target==="openapi-3.0"?r.enum=[o]:r.const=o}else i.every(o=>typeof o=="number")&&(r.type="number"),i.every(o=>typeof o=="string")&&(r.type="string"),i.every(o=>typeof o=="boolean")&&(r.type="boolean"),i.every(o=>o===null)&&(r.type="null"),r.enum=i},yf=(e,t,r,a)=>{Be(e,t,r,a,"NaN cannot be represented in JSON Schema")},kf=(e,t,r,a)=>{let n=r,i=e._zod.pattern;if(!i)throw new Error("Pattern not found in template literal");n.type="string",n.pattern=i.source},_f=(e,t,r,a)=>{let n=r;n.type="string",n.format="binary",n.contentEncoding="binary";let{minimum:i,maximum:o,mime:s}=Ue(e);i!==void 0&&(n.minLength=i),o!==void 0&&(n.maxLength=o),s&&(s.length===0?n.not={}:s.length===1?n.contentMediaType=s[0]:n.anyOf=s.map(l=>({contentMediaType:l})))},wf=(e,t,r,a)=>{r.type="boolean"},Sf=(e,t,r,a)=>{Be(e,t,r,a,"Custom types cannot be represented in JSON Schema")},Ef=(e,t,r,a)=>{Be(e,t,r,a,"Function types cannot be represented in JSON Schema")},xf=(e,t,r,a)=>{Be(e,t,r,a,"Transforms cannot be represented in JSON Schema")},Tf=(e,t,r,a)=>{Be(e,t,r,a,"Map cannot be represented in JSON Schema")},Af=(e,t,r,a)=>{Be(e,t,r,a,"Set cannot be represented in JSON Schema")},Cf=(e,t,r,a)=>{let n=r,i=e._zod.def,{minimum:o,maximum:s}=Ue(e);typeof o=="number"&&(n.minItems=o),typeof s=="number"&&(n.maxItems=s),n.type="array",n.items=ve(i.element,t,{...a,path:[...a.path,"items"]})};function hs(e){let t=e._zod.def;return t.type==="pipe"&&t.in._zod.traits.has("$ZodTransform")?hs(t.out):t.type==="catch"?hs(t.innerType):e._zod.optin}var zf=(e,t,r,a)=>{let n=r,i=e._zod.def,o=i.shape;if(Object.getOwnPropertySymbols(o).length&&Be(e,t,n,a,"Symbol keys cannot be represented in JSON Schema"))return;n.type="object",n.properties={};for(let c in o)Ge(n.properties,c,ve(o[c],t,{...a,path:[...a.path,"properties",c]}));let l=[];for(let c of Object.keys(o)){let u=i.shape[c];(t.io==="input"?hs(u)===void 0:u._zod.optout===void 0)&&l.push(c)}l.length>0&&(n.required=l),i.catchall?._zod.def.type==="never"?n.additionalProperties=!1:i.catchall?i.catchall&&(n.additionalProperties=ve(i.catchall,t,{...a,path:[...a.path,"additionalProperties"]})):t.io==="output"&&(n.additionalProperties=!1)},Sd=(e,t,r,a)=>{let n=e._zod.def,i=n.inclusive===!1,o=n.options.map((s,l)=>ve(s,t,{...a,path:[...a.path,i?"oneOf":"anyOf",l]}));i?r.oneOf=o:r.anyOf=o},If=(e,t,r,a)=>{let n=e._zod.def,i=ve(n.left,t,{...a,path:[...a.path,"allOf",0]}),o=ve(n.right,t,{...a,path:[...a.path,"allOf",1]}),s=c=>"allOf"in c&&Object.keys(c).length===1,l=[...s(i)?i.allOf:[i],...s(o)?o.allOf:[o]];r.allOf=l,t.intersections.push(l)},Pf=(e,t,r,a)=>{let n=r,i=e._zod.def;n.type="array";let o=t.target==="draft-2020-12"?"prefixItems":"items",s=t.target==="draft-2020-12"||t.target==="openapi-3.0"?"items":"additionalItems",l=i.items.map((h,f)=>ve(h,t,{...a,path:[...a.path,o,f]})),c=i.rest?ve(i.rest,t,{...a,path:[...a.path,s,...t.target==="openapi-3.0"?[i.items.length]:[]]}):null,u=i.items.length;for(;u>0;){let h=i.items[u-1];if(!(t.io==="input"?hs(h)!==void 0:h._zod.optout==="optional"))break;u--}let d=i.items.length,m=!i.rest;t.target==="draft-2020-12"?(n.prefixItems=l,m?n.items=!1:c&&(n.items=c),u>0&&(n.minItems=u),m&&(n.maxItems=d)):t.target==="openapi-3.0"?(n.items={anyOf:l},c&&n.items.anyOf.push(c),u>0&&(n.minItems=u),m&&(n.maxItems=d)):(n.items=l,m?n.additionalItems=!1:c&&(n.additionalItems=c),u>0&&(n.minItems=u),m&&(n.maxItems=d));let{minimum:p,maximum:g}=Ue(e);typeof p=="number"&&(n.minItems=p),typeof g=="number"&&(n.maxItems=g)};function nf(e,t,r){if(t.$ref){if(r.has(t))return t;r.add(t);let g=e.get(t)?.def;if(!g)return t;let h=nf(e,g,r);return h===g?t:h}for(let g of["anyOf","oneOf"]){let h=t[g];if(!Array.isArray(h))continue;let f=h.map(_=>nf(e,_,r));f.some((_,b)=>_!==h[b])&&(t={...t,[g]:f})}let a=Array.isArray(t.type)?t.type:[t.type],n=!a.includes("string")&&a.some(g=>g==="number"||g==="integer"),i=t.enum??(t.const!==void 0?[t.const]:void 0);if(!n&&!i?.some(g=>typeof g=="number"))return t;let{minimum:o,maximum:s,exclusiveMinimum:l,exclusiveMaximum:c,multipleOf:u,format:d,id:m,...p}=t;return p.enum?p.enum=p.enum.map(g=>typeof g=="number"?String(g):g):typeof p.const=="number"&&(p.const=String(p.const)),n&&(p.type="string",i||(p.pattern=(a.includes("number")?An:To).source)),p}var rf=new WeakMap;function m0(e){let t=new Map;for(let a of e.seen.values())a.def&&!t.has(a.schema)&&t.set(a.schema,a);let r=new Map;for(let a of rf.get(e)??[]){let n=e.seen.get(a),i=(n?.def??n?.schema)?.propertyNames;if(!i||i===!0||r.has(i))continue;let o=nf(t,i,new Set);o!==i&&r.set(i,o)}if(r.size)for(let a of e.seen.values())for(let n of[a.schema,a.def]){let i=n&&r.get(n.propertyNames);i&&(n.propertyNames=i)}}var Rf=(e,t,r,a)=>{let n=r,i=e._zod.def;n.type="object";let o=i.keyType,s=Ue(o).patterns;if(i.mode==="loose"&&s&&s.size>0){let u=ve(i.valueType,t,{...a,path:[...a.path,"patternProperties","*"]});n.patternProperties={};for(let d of s)Ge(n.patternProperties,lE(d).source,u)}else{if(t.target==="draft-07"||t.target==="draft-2020-12"){n.propertyNames=ve(i.keyType,t,{...a,path:[...a.path,"propertyNames"]});let u=rf.get(t);u||(u=[],rf.set(t,u),t.deferred.push(()=>m0(t))),u.push(e)}n.additionalProperties=ve(i.valueType,t,{...a,path:[...a.path,"additionalProperties"]})}let l=o._zod.values,c=t.io==="input"&&hs(i.valueType)!==void 0;if(l&&!i.partial&&!c){let u=[...l].filter(d=>typeof d=="string"||typeof d=="number");u.length>0&&(n.required=u.map(String))}},$f=(e,t,r,a)=>{let n=e._zod.def,i=ve(n.innerType,t,a),o=t.seen.get(e);t.target==="openapi-3.0"?(o.ref=n.innerType,r.nullable=!0):r.anyOf=[i,{type:"null"}]},jf=(e,t,r,a)=>{let n=e._zod.def;ve(n.innerType,t,a);let i=t.seen.get(e);i.ref=n.innerType},Of=Symbol();function cE(e,t,r,a,n){let i=!1,o=JSON.stringify(e,(s,l)=>typeof l!="bigint"?l:(i=!0,null));return i?(Be(t,r,a,n,"BigInt defaults cannot be represented in JSON Schema"),Of):JSON.parse(o)}var Nf=(e,t,r,a)=>{let n=e._zod.def;ve(n.innerType,t,a);let i=t.seen.get(e);i.ref=n.innerType;let o=cE(n.defaultValue,e,t,r,a);o!==Of&&(r.default=o)},Df=(e,t,r,a)=>{let n=e._zod.def;ve(n.innerType,t,a);let i=t.seen.get(e);if(i.ref=n.innerType,t.io!=="input")return;let o=cE(n.defaultValue,e,t,r,a);o!==Of&&(r._prefault=o)},Mf=(e,t,r,a)=>{let n=e._zod.def;ve(n.innerType,t,a);let i=t.seen.get(e);i.ref=n.innerType;let o;try{o=n.catchValue(void 0)}catch{Be(e,t,r,a,"Dynamic catch values are not supported in JSON Schema");return}r.default=o},Lf=(e,t,r,a)=>{let n=e._zod.def,i=n.in._zod.traits.has("$ZodTransform"),o=t.io==="input"?i?n.out:n.in:n.out;ve(o,t,a);let s=t.seen.get(e);s.ref=o},Bf=(e,t,r,a)=>{let n=e._zod.def;ve(n.innerType,t,a);let i=t.seen.get(e);i.ref=n.innerType,r.readOnly=!0},Uf=(e,t,r,a)=>{let n=e._zod.def;ve(n.innerType,t,a);let i=t.seen.get(e);i.ref=n.innerType},Ed=(e,t,r,a)=>{let n=e._zod.def;ve(n.innerType,t,a);let i=t.seen.get(e);i.ref=n.innerType},Ff=(e,t,r,a)=>{let n=e._zod.innerType;ve(n,t,a);let i=t.seen.get(e);i.ref=n},wd={string:af,number:of,boolean:sf,bigint:lf,symbol:cf,null:uf,undefined:df,void:pf,never:mf,any:gf,unknown:hf,date:ff,enum:bf,literal:vf,nan:yf,template_literal:kf,file:_f,success:wf,custom:Sf,function:Ef,transform:xf,map:Tf,set:Af,array:Cf,object:zf,union:Sd,intersection:If,tuple:Pf,record:Rf,nullable:$f,nonoptional:jf,default:Nf,prefault:Df,catch:Mf,pipe:Lf,readonly:Bf,promise:Uf,optional:Ed,lazy:Ff};function Hr(e,t){if("_idmap"in e){let a=e,n=ir({...t,processors:wd}),i={};for(let l of a._idmap.entries()){let[c,u]=l;ve(u,n)}let o={},s={registry:a,uri:t?.uri,defs:i};n.external=s;for(let l of a._idmap.entries()){let[c,u]=l;or(n,u),Ge(o,c,sr(n,u))}if(Object.keys(i).length>0){let l=n.target==="draft-2020-12"?"$defs":"definitions";o.__shared={[l]:i}}return{schemas:o}}let r=ir({...t,processors:wd});return ve(e,r),or(r,e),sr(r,e)}var xd=class{get metadataRegistry(){return this.ctx.metadataRegistry}get target(){return this.ctx.target}get unrepresentable(){return this.ctx.unrepresentable}get override(){return this.ctx.override}get io(){return this.ctx.io}get counter(){return this.ctx.counter}set counter(t){this.ctx.counter=t}get seen(){return this.ctx.seen}constructor(t){let r=t?.target??"draft-2020-12";r==="draft-4"&&(r="draft-04"),r==="draft-7"&&(r="draft-07"),this.ctx=ir({processors:wd,target:r,...t?.metadata&&{metadata:t.metadata},...t?.unrepresentable&&{unrepresentable:t.unrepresentable},...t?.override&&{override:t.override},...t?.io&&{io:t.io}})}process(t,r={path:[],schemaPath:[]}){return ve(t,this.ctx,r)}emit(t,r){r&&(r.cycles&&(this.ctx.cycles=r.cycles),r.reused&&(this.ctx.reused=r.reused),r.external&&(this.ctx.external=r.external)),this.ctx.sharedDefsExtractedFor=void 0,this.ctx.sharedEmitDoneFor=void 0,or(this.ctx,t);let a=sr(this.ctx,t),{"~standard":n,...i}=a;return i}};var uE={};var gi={};En(gi,{ZodAny:()=>sb,ZodArray:()=>db,ZodBase64:()=>Hd,ZodBase64URL:()=>Gd,ZodBigInt:()=>pi,ZodBigIntFormat:()=>Kd,ZodBoolean:()=>di,ZodCIDRv4:()=>Fd,ZodCIDRv6:()=>qd,ZodCUID:()=>Od,ZodCUID2:()=>Nd,ZodCatch:()=>Ib,ZodCodec:()=>Es,ZodCreditCard:()=>nb,ZodCustom:()=>xs,ZodCustomStringFormat:()=>Vr,ZodDate:()=>ys,ZodDefault:()=>Eb,ZodDiscriminatedUnion:()=>mb,ZodE164:()=>Vd,ZodEmail:()=>Pd,ZodEmoji:()=>$d,ZodEnum:()=>li,ZodExactOptional:()=>Yd,ZodFile:()=>kb,ZodFunction:()=>Bb,ZodGUID:()=>Rd,ZodIBAN:()=>rb,ZodIPv4:()=>Bd,ZodIPv6:()=>Ud,ZodISODate:()=>cr,ZodISODateTime:()=>lr,ZodISODuration:()=>dr,ZodISOTime:()=>ur,ZodInstanceOf:()=>qb,ZodIntersection:()=>gb,ZodJWT:()=>Wd,ZodKSUID:()=>Ld,ZodLazy:()=>Db,ZodLiteral:()=>yb,ZodMAC:()=>tb,ZodMap:()=>bb,ZodNaN:()=>Rb,ZodNanoID:()=>jd,ZodNever:()=>cb,ZodNonOptional:()=>Xd,ZodNull:()=>ob,ZodNullable:()=>Sb,ZodNumber:()=>ui,ZodNumberFormat:()=>Wr,ZodObject:()=>ks,ZodOptional:()=>Kr,ZodPipe:()=>Ss,ZodPrefault:()=>Tb,ZodPreprocess:()=>$b,ZodPromise:()=>Lb,ZodReadonly:()=>jb,ZodRecord:()=>si,ZodSet:()=>vb,ZodString:()=>ci,ZodStringFormat:()=>Se,ZodSuccess:()=>zb,ZodSymbol:()=>ab,ZodTemplateLiteral:()=>Nb,ZodTransform:()=>_b,ZodTuple:()=>hb,ZodType:()=>Y,ZodULID:()=>Dd,ZodURL:()=>bs,ZodUUID:()=>dn,ZodUndefined:()=>ib,ZodUnion:()=>_s,ZodUnknown:()=>lb,ZodVoid:()=>ub,ZodXID:()=>Md,ZodXor:()=>pb,_ZodString:()=>Id,_default:()=>xb,_function:()=>vx,any:()=>QE,array:()=>ae,base64:()=>$E,base64url:()=>jE,bigint:()=>KE,boolean:()=>De,catch:()=>Pb,check:()=>yx,cidrv4:()=>PE,cidrv6:()=>RE,codec:()=>gx,creditCard:()=>NE,cuid:()=>SE,cuid2:()=>EE,currencyCode:()=>FE,custom:()=>Qd,date:()=>tx,describe:()=>kx,discriminatedUnion:()=>ws,e164:()=>OE,email:()=>mE,emoji:()=>_E,enum:()=>Ke,exactOptional:()=>wb,file:()=>ux,float32:()=>HE,float64:()=>GE,function:()=>vx,guid:()=>gE,hash:()=>qE,hex:()=>UE,hostname:()=>BE,httpUrl:()=>kE,iban:()=>DE,instanceof:()=>wx,int:()=>Cd,int32:()=>VE,int64:()=>ZE,intersection:()=>mi,invertCodec:()=>hx,ipv4:()=>CE,ipv6:()=>IE,json:()=>Ex,jwt:()=>ME,keyof:()=>nx,ksuid:()=>AE,lazy:()=>Mb,literal:()=>B,looseObject:()=>We,looseRecord:()=>ox,mac:()=>zE,map:()=>sx,meta:()=>_x,nan:()=>mx,nanoid:()=>wE,nativeEnum:()=>cx,never:()=>Zd,nonoptional:()=>Cb,null:()=>vs,nullable:()=>fs,nullish:()=>dx,number:()=>he,object:()=>O,optional:()=>we,partialRecord:()=>ix,pipe:()=>zd,prefault:()=>Ab,preprocess:()=>Ts,promise:()=>bx,readonly:()=>Ob,record:()=>Ee,refine:()=>Ub,set:()=>lx,strictObject:()=>rx,string:()=>w,stringFormat:()=>LE,stringbool:()=>Sx,success:()=>px,superRefine:()=>Fb,symbol:()=>YE,templateLiteral:()=>fx,transform:()=>Jd,tuple:()=>fb,uint32:()=>WE,uint64:()=>JE,ulid:()=>xE,undefined:()=>XE,union:()=>ye,unknown:()=>xe,url:()=>yE,uuid:()=>hE,uuidv4:()=>fE,uuidv6:()=>bE,uuidv7:()=>vE,void:()=>ex,xid:()=>TE,xor:()=>ax});var Td={};En(Td,{endsWith:()=>Ja,gt:()=>cn,gte:()=>It,includes:()=>Ka,length:()=>qr,lowercase:()=>Va,lt:()=>ln,lte:()=>zt,maxLength:()=>Fr,maxSize:()=>rr,mime:()=>Xa,minLength:()=>Cn,minSize:()=>un,multipleOf:()=>nr,negative:()=>dd,nonnegative:()=>md,nonpositive:()=>pd,normalize:()=>Qa,overwrite:()=>Wt,positive:()=>ud,properties:()=>Ya,property:()=>gd,regex:()=>Ga,size:()=>Ur,slugify:()=>ri,startsWith:()=>Za,toLowerCase:()=>ti,toUpperCase:()=>ni,trim:()=>ei,uppercase:()=>Wa});var dE=new WeakSet([Object.prototype,Error.prototype]);function Ad(e,t,r){Object.defineProperty(e,t,{configurable:!0,enumerable:!1,get(){let a=r(this);return Object.defineProperty(this,t,{value:a,configurable:!0,writable:!0}),a},set(a){Object.defineProperty(this,t,{value:a,configurable:!0,writable:!0})}})}var pE=(e,t)=>{kg.init(e,t),e.name="ZodError";let r=Object.getPrototypeOf(e);dE.has(r)||(dE.add(r),Ad(r,"format",a=>n=>Eo(a,n)),Ad(r,"flatten",a=>n=>So(a,n)),Ad(r,"addIssue",a=>n=>{a.issues.push(n),a.message=JSON.stringify(a.issues,ka,2)}),Ad(r,"addIssues",a=>n=>{a.issues.push(...n),a.message=JSON.stringify(a.issues,ka,2)}),Object.defineProperty(r,"isEmpty",{configurable:!0,enumerable:!1,get(){return this.issues.length===0}}))},h0=y("ZodError",pE),wt=y("ZodError",pE,void 0,{Parent:Error});var qf=Ta(wt),Hf=Aa(wt),Gf=Ca(wt),Vf=Ia(wt),Wf=Zl(wt),Kf=Jl(wt),Zf=Yl(wt),Jf=Xl(wt),Yf=Ql(wt),Xf=ec(wt),Qf=tc(wt),eb=nc(wt);function b0(){He.localeError||Oe($u())}function Gr(){He.memoizer||Oe({memoizer:Uo()})}var Y=y("ZodType",(e,t)=>(b0(),Z.init(e,t),e.def=t,e.type=t.type,e),{check(...e){let t=this.def;return this.clone(E.mergeDefs(t,{checks:[...t.checks??[],...e.map(r=>typeof r=="function"?{_zod:{check:r,def:{check:"custom"},onattach:[]}}:r)]}),{parent:!0})},with(...e){return this.check(...e)},clone(e,t){return ge(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(Ub(e,t))},superRefine(e,t){return this.check(Fb(e,t))},overwrite(e){return this.check(Wt(e))},optional(){return we(this)},exactOptional(){return wb(this)},nullable(){return fs(this)},nullish(){return we(fs(this))},nonoptional(e){return Cb(this,e)},array(){return ae(this)},or(e){return ye([this,e])},and(e){return mi(this,e)},transform(e){return zd(this,Jd(e))},default(e){return xb(this,e)},prefault(e){return Ab(this,e)},catch(e){return Pb(this,e)},pipe(e){return zd(this,e)},readonly(){return Ob(this)},describe(e){let t=this.clone();return Ve.add(t,{description:e}),t},meta(...e){if(e.length===0)return Ve.get(this);let t=this.clone();return Ve.add(t,e[0]),t},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(e,...t){return t.length===0?e(this):e(this,...t)},get"~standard"(){return E.hide(this,"~standard",{...mc(this),jsonSchema:{input:ai(this,"input"),output:ai(this,"output")}})},set"~standard"(e){E.own(this,"~standard",e)},parse:function e(t,r){return qf(this,t,r,{callee:e})},parseAsync:async function e(t,r){return await Hf(this,t,r,{callee:e})},safeParse(e,t){return Gf(this,e,t)},async safeParseAsync(e,t){return Vf(this,e,t)},get spa(){return this?.safeParseAsync},set spa(e){E.own(this,"spa",e)},validate(e,t){return Ra(this,e,t)},validateAsync(e,t){return $a(this,e,t)},encode:function e(t,r){return Wf(this,t,r,{callee:e})},decode:function e(t,r){return Kf(this,t,r,{callee:e})},encodeAsync:async function e(t,r){return await Zf(this,t,r,{callee:e})},decodeAsync:async function e(t,r){return await Jf(this,t,r,{callee:e})},safeEncode(e,t){return Yf(this,e,t)},safeDecode(e,t){return Xf(this,e,t)},async safeEncodeAsync(e,t){return Qf(this,e,t)},async safeDecodeAsync(e,t){return eb(this,e,t)},toJSONSchema(e){return tf(this,{})(e)},get description(){return Ve.get(this)?.description},get _def(){return this._zod.def}}),Id=y("_ZodString",(e,t)=>{er.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(r,a,n)=>af(e,r,a,n)},E.derived({format:e=>Ue(e).format??null,minLength:e=>Ue(e).minimum??null,maxLength:e=>Ue(e).maximum??null},{regex(...e){return this.check(Ga(...e))},includes(...e){return this.check(Ka(...e))},startsWith(...e){return this.check(Za(...e))},endsWith(...e){return this.check(Ja(...e))},min(...e){return this.check(Cn(...e))},max(...e){return this.check(Fr(...e))},length(...e){return this.check(qr(...e))},nonempty(...e){return this.check(Cn(1,...e))},lowercase(e){return this.check(Va(e))},uppercase(e){return this.check(Wa(e))},trim(){return this.check(ei())},normalize(...e){return this.check(Qa(...e))},toLowerCase(){return this.check(ti())},toUpperCase(){return this.check(ni())},slugify(){return this.check(ri())}})),ci=y("ZodString",(e,t)=>{er.init(e,t),Id.init(e,t)},{email(e){return this.check(qo(Pd,e))},url(e){return this.check(Ha(bs,e))},jwt(e){return this.check(cs(Wd,e))},emoji(e){return this.check(Zo($d,e))},guid(e){return this.check(Ho(Rd,e))},uuid(e){return this.check(Go(dn,e))},uuidv4(e){return this.check(Vo(dn,e))},uuidv6(e){return this.check(Wo(dn,e))},uuidv7(e){return this.check(Ko(dn,e))},nanoid(e){return this.check(Jo(jd,e))},cuid(e){return this.check(Yo(Od,e))},cuid2(e){return this.check(Xo(Nd,e))},ulid(e){return this.check(Qo(Dd,e))},base64(e){return this.check(os(Hd,e))},base64url(e){return this.check(ss(Gd,e))},xid(e){return this.check(es(Md,e))},ksuid(e){return this.check(ts(Ld,e))},ipv4(e){return this.check(ns(Bd,e))},ipv6(e){return this.check(rs(Ud,e))},cidrv4(e){return this.check(as(Fd,e))},cidrv6(e){return this.check(is(qd,e))},e164(e){return this.check(ls(Vd,e))},datetime(e){return this.check(us(lr,e))},date(e){return this.check(ds(cr,e))},time(e){return this.check(ps(ur,e))},duration(e){return this.check(ms(dr,e))}});function w(e){return Uu(ci,e)}var Se=y("ZodStringFormat",(e,t)=>{be.init(e,t),Id.init(e,t)}),lr=y("ZodISODateTime",(e,t)=>{zh.init(e,t),Se.init(e,t)}),cr=y("ZodISODate",(e,t)=>{Ih.init(e,t),Se.init(e,t)}),ur=y("ZodISOTime",(e,t)=>{Ph.init(e,t),Se.init(e,t)}),dr=y("ZodISODuration",(e,t)=>{Rh.init(e,t),Se.init(e,t)}),Pd=y("ZodEmail",(e,t)=>{fc.init(e,t),Se.init(e,t)});function mE(e){return qo(Pd,e)}var Rd=y("ZodGUID",(e,t)=>{gc.init(e,t),Se.init(e,t)});function gE(e){return Ho(Rd,e)}var dn=y("ZodUUID",(e,t)=>{hc.init(e,t),Se.init(e,t)});function hE(e){return Go(dn,e)}function fE(e){return Vo(dn,e)}function bE(e){return Wo(dn,e)}function vE(e){return Ko(dn,e)}var bs=y("ZodURL",(e,t)=>{kc.init(e,t),Se.init(e,t)});function yE(e){return Ha(bs,e)}function kE(e){return Ha(bs,{protocol:xo,hostname:qg,...E.normalizeParams(e)})}var $d=y("ZodEmoji",(e,t)=>{_c.init(e,t),Se.init(e,t)});function _E(e){return Zo($d,e)}var jd=y("ZodNanoID",(e,t)=>{wc.init(e,t),Se.init(e,t)});function wE(e){return Jo(jd,e)}var Od=y("ZodCUID",(e,t)=>{Sc.init(e,t),Se.init(e,t)});function SE(e){return Yo(Od,e)}var Nd=y("ZodCUID2",(e,t)=>{Ec.init(e,t),Se.init(e,t)});function EE(e){return Xo(Nd,e)}var Dd=y("ZodULID",(e,t)=>{xc.init(e,t),Se.init(e,t)});function xE(e){return Qo(Dd,e)}var Md=y("ZodXID",(e,t)=>{Tc.init(e,t),Se.init(e,t)});function TE(e){return es(Md,e)}var Ld=y("ZodKSUID",(e,t)=>{Ac.init(e,t),Se.init(e,t)});function AE(e){return ts(Ld,e)}var Bd=y("ZodIPv4",(e,t)=>{Cc.init(e,t),Se.init(e,t)});function CE(e){return ns(Bd,e)}var tb=y("ZodMAC",(e,t)=>{Ic.init(e,t),Se.init(e,t)});function zE(e){return Fu(tb,e)}var Ud=y("ZodIPv6",(e,t)=>{zc.init(e,t),Se.init(e,t)});function IE(e){return rs(Ud,e)}var Fd=y("ZodCIDRv4",(e,t)=>{Pc.init(e,t),Se.init(e,t)});function PE(e){return as(Fd,e)}var qd=y("ZodCIDRv6",(e,t)=>{$c.init(e,t),Se.init(e,t)});function RE(e){return is(qd,e)}var Hd=y("ZodBase64",(e,t)=>{Oc.init(e,t),Se.init(e,t)});function $E(e){return os(Hd,e)}var Gd=y("ZodBase64URL",(e,t)=>{Dc.init(e,t),Se.init(e,t)});function jE(e){return ss(Gd,e)}var Vd=y("ZodE164",(e,t)=>{Mc.init(e,t),Se.init(e,t)});function OE(e){return ls(Vd,e)}var nb=y("ZodCreditCard",(e,t)=>{Bc.init(e,t),Se.init(e,t)});function NE(e){return qu(nb,e)}var rb=y("ZodIBAN",(e,t)=>{Fc.init(e,t),Se.init(e,t)});function DE(e){return Hu(rb,e)}var Wd=y("ZodJWT",(e,t)=>{Hc.init(e,t),Se.init(e,t)});function ME(e){return cs(Wd,e)}var Vr=y("ZodCustomStringFormat",(e,t)=>{Gc.init(e,t),Se.init(e,t)});function LE(e,t,r={}){return ar(Vr,e,t,r)}function BE(e){return ar(Vr,"hostname",Fg,e)}function UE(e){return ar(Vr,"hex",rh,e)}function FE(e){return ar(Vr,"currency_code",Gg,e)}function qE(e,t){let r=t?.enc??"hex",a=`${e}_${r}`,n=Ct[a];if(!n)throw new Error(`Unrecognized hash format: ${a}`);return ar(Vr,a,n,t)}var ui=y("ZodNumber",(e,t)=>{jo.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(r,a,n)=>of(e,r,a,n),e.isFinite=!0},E.derived({minValue:e=>{let{minimum:t,exclusiveMinimum:r}=Ue(e);return Math.max(t??Number.NEGATIVE_INFINITY,r??Number.NEGATIVE_INFINITY)},maxValue:e=>{let{maximum:t,exclusiveMaximum:r}=Ue(e);return Math.min(t??Number.POSITIVE_INFINITY,r??Number.POSITIVE_INFINITY)},isInt:e=>{let{isInt:t,multipleOf:r}=Ue(e);return!!t||!!r?.some(Number.isSafeInteger)},format:e=>Ue(e).format??null},{gt(e,t){return this.check(cn(e,t))},gte(e,t){return this.check(It(e,t))},min(e,t){return this.check(It(e,t))},lt(e,t){return this.check(ln(e,t))},lte(e,t){return this.check(zt(e,t))},max(e,t){return this.check(zt(e,t))},int(e){return this.check(Cd(e))},safe(e){return this.check(Cd(e))},positive(e){return this.check(cn(0,e))},nonnegative(e){return this.check(It(0,e))},negative(e){return this.check(ln(0,e))},nonpositive(e){return this.check(zt(0,e))},multipleOf(e,t){return this.check(nr(e,t))},step(e,t){return this.check(nr(e,t))},finite(){return this}}));function he(e){return Gu(ui,e)}var Wr=y("ZodNumberFormat",(e,t)=>{Vc.init(e,t),ui.init(e,t)});function Cd(e){return Vu(Wr,e)}function HE(e){return Wu(Wr,e)}function GE(e){return Ku(Wr,e)}function VE(e){return Zu(Wr,e)}function WE(e){return Ju(Wr,e)}var di=y("ZodBoolean",(e,t)=>{Na.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(r,a,n)=>sf(e,r,a,n)});function De(e){return Yu(di,e)}var pi=y("ZodBigInt",(e,t)=>{Oo.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(r,a,n)=>lf(e,r,a,n)},E.derived({minValue:e=>Ue(e).minimum??null,maxValue:e=>Ue(e).maximum??null,format:e=>Ue(e).format??null},{gte(e,t){return this.check(It(e,t))},min(e,t){return this.check(It(e,t))},gt(e,t){return this.check(cn(e,t))},lt(e,t){return this.check(ln(e,t))},lte(e,t){return this.check(zt(e,t))},max(e,t){return this.check(zt(e,t))},positive(e){return this.check(cn(BigInt(0),e))},negative(e){return this.check(ln(BigInt(0),e))},nonpositive(e){return this.check(zt(BigInt(0),e))},nonnegative(e){return this.check(It(BigInt(0),e))},multipleOf(e,t){return this.check(nr(e,t))}}));function KE(e){return Xu(pi,e)}var Kd=y("ZodBigIntFormat",(e,t)=>{Wc.init(e,t),pi.init(e,t)});function ZE(e){return Qu(Kd,e)}function JE(e){return ed(Kd,e)}var ab=y("ZodSymbol",(e,t)=>{Kc.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(r,a,n)=>cf(e,r,a,n)});function YE(e){return td(ab,e)}var ib=y("ZodUndefined",(e,t)=>{Zc.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(r,a,n)=>df(e,r,a,n)});function XE(e){return nd(ib,e)}var ob=y("ZodNull",(e,t)=>{Jc.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(r,a,n)=>uf(e,r,a,n)});function vs(e){return rd(ob,e)}var sb=y("ZodAny",(e,t)=>{Yc.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(r,a,n)=>gf(e,r,a,n)});function QE(){return ad(sb)}var lb=y("ZodUnknown",(e,t)=>{Xc.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(r,a,n)=>hf(e,r,a,n)});function xe(){return id(lb)}var cb=y("ZodNever",(e,t)=>{Qc.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(r,a,n)=>mf(e,r,a,n)});function Zd(e){return od(cb,e)}var ub=y("ZodVoid",(e,t)=>{eu.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(r,a,n)=>pf(e,r,a,n)});function ex(e){return sd(ub,e)}var ys=y("ZodDate",(e,t)=>{tu.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(r,a,n)=>ff(e,r,a,n),e.min=(r,a)=>e.check(It(r,a)),e.max=(r,a)=>e.check(zt(r,a))},E.derived({minDate:e=>{let{minimum:t}=Ue(e);return t?new Date(t):null},maxDate:e=>{let{maximum:t}=Ue(e);return t?new Date(t):null}},{}));function tx(e){return ld(ys,e)}var db=y("ZodArray",(e,t)=>{Gr(),nu.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(r,a,n)=>Cf(e,r,a,n),e.element=t.element},{min(e,t){return this.check(Cn(e,t))},nonempty(e){return this.check(Cn(1,e))},max(e,t){return this.check(Fr(e,t))},length(e,t){return this.check(qr(e,t))},unwrap(){return this.element}});function ae(e,t){return Qh(db,e,t)}function nx(e){let t=e._zod.def.shape;return Ke(Object.keys(t))}var ks=y("ZodObject",(e,t)=>{Gr(),jh.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(r,a,n)=>zf(e,r,a,n),E.installLazyProp(e,"shape",r=>r._zod.def.shape,!1)},{keyof(){return Ke(Object.keys(this._zod.def.shape))},catchall(e){return this.clone(E.mergeDefs(this._zod.def,{catchall:e}))},passthrough(){return this.clone(E.mergeDefs(this._zod.def,{catchall:xe()}))},loose(){return this.clone(E.mergeDefs(this._zod.def,{catchall:xe()}))},strict(){return this.clone(E.mergeDefs(this._zod.def,{catchall:Zd()}))},strip(){return this.clone(E.mergeDefs(this._zod.def,{catchall:void 0}))},extend(e){return E.extend(this,e)},safeExtend(e){return E.safeExtend(this,e)},merge(e){return E.merge(this,e)},pick(e){return E.pick(this,e)},omit(e){return E.omit(this,e)},partial(...e){return E.partial(Kr,this,e[0])},exactPartial(...e){return E.partial(Yd,this,e[0],"exactPartial")},required(...e){return E.required(Xd,this,e[0])}});function O(e,t){let r={type:"object",shape:e??{},...E.normalizeParams(t)};return new ks(r)}function rx(e,t){return new ks({type:"object",shape:e,catchall:Zd(),...E.normalizeParams(t)})}function We(e,t){return new ks({type:"object",shape:e,catchall:xe(),...E.normalizeParams(t)})}var _s=y("ZodUnion",(e,t)=>{Da.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(r,a,n)=>Sd(e,r,a,n),e.options=t.options});function ye(e,t){return new _s({type:"union",options:e,...E.normalizeParams(t)})}var pb=y("ZodXor",(e,t)=>{_s.init(e,t),au.init(e,t),e._zod.processJSONSchema=(r,a,n)=>Sd(e,r,a,n),e.options=t.options});function ax(e,t){return new pb({type:"union",options:e,inclusive:!1,...E.normalizeParams(t)})}var mb=y("ZodDiscriminatedUnion",(e,t)=>{_s.init(e,t),iu.init(e,t)});function ws(e,t,r){return new mb({type:"union",options:t,discriminator:e,...E.normalizeParams(r)})}var gb=y("ZodIntersection",(e,t)=>{ou.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(r,a,n)=>If(e,r,a,n)});function mi(e,t){return new gb({type:"intersection",left:e,right:t})}var hb=y("ZodTuple",(e,t)=>{Gr(),No.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(r,a,n)=>Pf(e,r,a,n)},{rest(e){return this.clone({...this._zod.def,rest:e})},partial(){let e=this._zod.def;if(e.checks?.length)throw new Error(".partial() cannot be used on tuple schemas containing refinements");return this.clone({...e,items:e.items.map(t=>new Kr({type:"optional",innerType:t}))})}});function fb(e,t,r){let a=t instanceof Z,n=a?r:t,i=a?t:null;return new hb({type:"tuple",items:e,rest:i,...E.normalizeParams(n)})}var si=y("ZodRecord",(e,t)=>{Gr(),su.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(r,a,n)=>Rf(e,r,a,n),e.keyType=t.keyType,e.valueType=t.valueType});function Ee(e,t,r){return!t||!t._zod?new si({type:"record",keyType:w(),valueType:e,...E.normalizeParams(t)}):new si({type:"record",keyType:e,valueType:t,...E.normalizeParams(r)})}function ix(e,t,r){return new si({type:"record",keyType:e,valueType:t,...E.normalizeParams(r),partial:!0})}function ox(e,t,r){return new si({type:"record",keyType:e,valueType:t,mode:"loose",...E.normalizeParams(r)})}var bb=y("ZodMap",(e,t)=>{Gr(),lu.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(r,a,n)=>Tf(e,r,a,n),e.keyType=t.keyType,e.valueType=t.valueType,e.min=(...r)=>e.check(un(...r)),e.nonempty=r=>e.check(un(1,r)),e.max=(...r)=>e.check(rr(...r)),e.size=(...r)=>e.check(Ur(...r))});function sx(e,t,r){return new bb({type:"map",keyType:e,valueType:t,...E.normalizeParams(r)})}var vb=y("ZodSet",(e,t)=>{Gr(),cu.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(r,a,n)=>Af(e,r,a,n),e.min=(...r)=>e.check(un(...r)),e.nonempty=r=>e.check(un(1,r)),e.max=(...r)=>e.check(rr(...r)),e.size=(...r)=>e.check(Ur(...r))});function lx(e,t){return new vb({type:"set",valueType:e,...E.normalizeParams(t)})}var li=y("ZodEnum",(e,t)=>{uu.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(a,n,i)=>bf(e,a,n,i),e.enum=t.entries,e.options=[...e._zod.values];let r=new Set(Object.keys(t.entries));e.extract=(a,n)=>{let i={};for(let o of a)if(r.has(o))i[o]=t.entries[o];else throw new Error(`Key ${o} not found in enum`);return new li({...t,checks:[],...E.normalizeParams(n),entries:i})},e.exclude=(a,n)=>{let i={...t.entries};for(let o of a)if(r.has(o))delete i[o];else throw new Error(`Key ${o} not found in enum`);return new li({...t,checks:[],...E.normalizeParams(n),entries:i})}});function Ke(e,t){let r=Array.isArray(e)?Object.fromEntries(e.map(a=>[a,a])):e;return new li({type:"enum",entries:r,...E.normalizeParams(t)})}function cx(e,t){return new li({type:"enum",entries:e,...E.normalizeParams(t)})}var yb=y("ZodLiteral",(e,t)=>{du.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(r,a,n)=>vf(e,r,a,n),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function B(e,t){return new yb({type:"literal",values:Array.isArray(e)?e:[e],...E.normalizeParams(t)})}var kb=y("ZodFile",(e,t)=>{pu.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(r,a,n)=>_f(e,r,a,n),e.min=(r,a)=>e.check(un(r,a)),e.max=(r,a)=>e.check(rr(r,a)),e.mime=(r,a)=>e.check(Xa(Array.isArray(r)?r:[r],a))});function ux(e){return hd(kb,e)}var _b=y("ZodTransform",(e,t)=>{Gr(),mu.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(r,a,n)=>xf(e,r,a,n),e._zod.parse=(r,a)=>{if(a.direction==="backward")throw new Qn(e.constructor.name);r.addIssue=i=>{if(typeof i=="string")r.issues.push(E.issue(i,r.value,t));else{let o=i;o.fatal&&(o.continue=!1),o.code??(o.code="custom"),"input"in o||(o.input=r.value),o.inst??(o.inst=e),r.issues.push(E.issue(o))}};let n=t.transform(r.value,r);return n instanceof Promise?n.then(i=>(r.value=i,r)):(r.value=n,r)}});function Jd(e){return new _b({type:"transform",transform:e})}var Kr=y("ZodOptional",(e,t)=>{Do.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(r,a,n)=>Ed(e,r,a,n),e.unwrap=()=>e._zod.def.innerType});function we(e){return new Kr({type:"optional",innerType:e})}var Yd=y("ZodExactOptional",(e,t)=>{gu.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(r,a,n)=>Ed(e,r,a,n),e.unwrap=()=>e._zod.def.innerType});function wb(e){return new Yd({type:"optional",innerType:e})}var Sb=y("ZodNullable",(e,t)=>{hu.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(r,a,n)=>$f(e,r,a,n),e.unwrap=()=>e._zod.def.innerType});function fs(e){return new Sb({type:"nullable",innerType:e})}function dx(e){return we(fs(e))}var Eb=y("ZodDefault",(e,t)=>{fu.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(r,a,n)=>Nf(e,r,a,n),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function xb(e,t){return new Eb({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():E.shallowClone(t)}})}var Tb=y("ZodPrefault",(e,t)=>{bu.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(r,a,n)=>Df(e,r,a,n),e.unwrap=()=>e._zod.def.innerType});function Ab(e,t){return new Tb({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():E.shallowClone(t)}})}var Xd=y("ZodNonOptional",(e,t)=>{vu.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(r,a,n)=>jf(e,r,a,n),e.unwrap=()=>e._zod.def.innerType});function Cb(e,t){return new Xd({type:"nonoptional",innerType:e,...E.normalizeParams(t)})}var zb=y("ZodSuccess",(e,t)=>{yu.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(r,a,n)=>wf(e,r,a,n),e.unwrap=()=>e._zod.def.innerType});function px(e){return new zb({type:"success",innerType:e})}var Ib=y("ZodCatch",(e,t)=>{ku.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(r,a,n)=>Mf(e,r,a,n),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function Pb(e,t){return new Ib({type:"catch",innerType:e,catchValue:typeof t=="function"?t:E.constantCatch(t)})}var Rb=y("ZodNaN",(e,t)=>{_u.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(r,a,n)=>yf(e,r,a,n)});function mx(e){return cd(Rb,e)}var Ss=y("ZodPipe",(e,t)=>{Mo.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(r,a,n)=>Lf(e,r,a,n),e.in=t.in,e.out=t.out});function zd(e,t){return new Ss({type:"pipe",in:e,out:t})}var Es=y("ZodCodec",(e,t)=>{Ss.init(e,t),Ma.init(e,t)});function gx(e,t,r){return new Es({type:"pipe",in:e,out:t,transform:r.decode,reverseTransform:r.encode})}function hx(e){let t=e._zod.def;return new Es({type:"pipe",in:t.out,out:t.in,transform:t.reverseTransform,reverseTransform:t.transform})}var $b=y("ZodPreprocess",(e,t)=>{Ss.init(e,t),Nh.init(e,t)}),jb=y("ZodReadonly",(e,t)=>{wu.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(r,a,n)=>Bf(e,r,a,n),e.unwrap=()=>e._zod.def.innerType});function Ob(e){return new jb({type:"readonly",innerType:e})}var Nb=y("ZodTemplateLiteral",(e,t)=>{Su.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(r,a,n)=>kf(e,r,a,n)});function fx(e,t){return new Nb({type:"template_literal",parts:e,...E.normalizeParams(t)})}var Db=y("ZodLazy",(e,t)=>{La.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(r,a,n)=>Ff(e,r,a,n),e.unwrap=()=>e._zod.def.getter()});function Mb(e){return new Db({type:"lazy",getter:e})}var Lb=y("ZodPromise",(e,t)=>{xu.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(r,a,n)=>Uf(e,r,a,n),e.unwrap=()=>e._zod.def.innerType});function bx(e){return new Lb({type:"promise",innerType:e})}var Bb=y("ZodFunction",(e,t)=>{Eu.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(r,a,n)=>Ef(e,r,a,n)});function vx(e){return new Bb({type:"function",input:Array.isArray(e?.input)?fb(e?.input):e?.input??ae(xe()),output:e?.output??xe()})}var xs=y("ZodCustom",(e,t)=>{Tu.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(r,a,n)=>Sf(e,r,a,n)});function yx(e){let t=new _e({check:"custom"});return t._zod.check=e,t}function Qd(e,t){return fd(xs,e??(()=>!0),t)}function Ub(e,t={}){return bd(xs,e,t)}function Fb(e,t){return vd(e,t)}var kx=yd,_x=kd,qb=y("ZodInstanceOf",(e,t)=>{xs.init(e,t)},{properties(e,t){return this.check(Ya(e,t))}});function wx(e,t={}){let r=new qb({type:"custom",check:"custom",fn:a=>a instanceof e,abort:!0,...E.normalizeParams(t)});return r._zod.bag.Class=e,r._zod.check=a=>{a.value instanceof e||a.issues.push({code:"invalid_type",expected:e.name,input:a.value,inst:r,path:[...r._zod.def.path??[]]})},r}var Sx=(...e)=>_d({Codec:Es,Boolean:di,String:ci},...e);function Ex(e){let t=Mb(()=>ye([w(e),he(),De(),vs(),ae(t),Ee(w(),t)]));return t}function Ts(e,t){return new $b({type:"pipe",in:Jd(e),out:t})}var v0={invalid_type:"invalid_type",too_big:"too_big",too_small:"too_small",invalid_format:"invalid_format",not_multiple_of:"not_multiple_of",unrecognized_keys:"unrecognized_keys",invalid_union:"invalid_union",invalid_key:"invalid_key",invalid_element:"invalid_element",invalid_value:"invalid_value",custom:"custom"};function y0(e){Oe({customError:e})}function k0(){return Oe().customError}var Hb;Hb||(Hb={});var Zr={};En(Zr,{ZodISODate:()=>cr,ZodISODateTime:()=>lr,ZodISODuration:()=>dr,ZodISOTime:()=>ur,date:()=>w0,datetime:()=>_0,duration:()=>E0,time:()=>S0});function _0(e){return us(lr,e)}function w0(e){return ds(cr,e)}function S0(e){return ps(ur,e)}function E0(e){return ms(dr,e)}var $={...gi,...Td,iso:Zr},x0=new Set(["$schema","$ref","$defs","definitions","$id","id","$comment","$anchor","$vocabulary","$dynamicRef","$dynamicAnchor","type","enum","const","anyOf","oneOf","allOf","not","properties","required","additionalProperties","patternProperties","propertyNames","minProperties","maxProperties","items","prefixItems","additionalItems","minItems","maxItems","uniqueItems","contains","minContains","maxContains","minLength","maxLength","pattern","format","minimum","maximum","exclusiveMinimum","exclusiveMaximum","multipleOf","description","default","contentEncoding","contentMediaType","contentSchema","unevaluatedItems","unevaluatedProperties","if","then","else","dependentSchemas","dependentRequired","nullable","readOnly"]);function T0(e,t){let r=e.$schema;return r==="https://json-schema.org/draft/2020-12/schema"?"draft-2020-12":r==="http://json-schema.org/draft-07/schema#"?"draft-7":r==="http://json-schema.org/draft-04/schema#"?"draft-4":t??"draft-2020-12"}function xx(e,t){return e.map((r,a)=>a<t?r:r.optional())}function A0(e){return e.replace(/~1/g,"/").replace(/~0/g,"~")}function C0(e,t){if(!e.startsWith("#"))throw new Error("External $ref is not supported, only local refs (#/...) are allowed");let r=e.slice(1).split("/").filter(Boolean);if(r.length===0)return t.rootSchema;let a=t.version==="draft-2020-12"?"$defs":"definitions";if(r[0]===a){let n=r[1]===void 0?void 0:A0(r[1]);if(!n||!t.defs[n])throw new Error(`Reference not found: ${e}`);return t.defs[n]}throw new Error(`Reference not found: ${e}`)}function z0(e,t){return $.transform(a=>a).check(a=>{let n=a.value;if(typeof n!="object"||n===null||Array.isArray(n))return;let i=Object.getOwnPropertyNames(n);if(t.minProperties!==void 0&&i.length<t.minProperties&&a.issues.push({origin:"object",code:"too_small",minimum:t.minProperties,inclusive:!0,message:`Too small: expected object to have >=${t.minProperties} properties`,input:n,inst:e,continue:!0}),t.maxProperties!==void 0&&i.length>t.maxProperties&&a.issues.push({origin:"object",code:"too_big",maximum:t.maxProperties,inclusive:!0,message:`Too big: expected object to have <=${t.maxProperties} properties`,input:n,inst:e,continue:!0}),t.keySchema)for(let o of i){let s=t.keySchema.safeParse(o);s.success||a.issues.push({code:"invalid_key",origin:"record",issues:s.error.issues,input:o,path:[o],continue:!0})}}).pipe(e)}function Gb(e,t){if(e===null)return"z";let r=typeof e;if(r!=="object"){if(r==="number"&&Number.isNaN(e))return null;let a=String(e);return`${r[0]}${a.length}:${a}`}if(t.has(e))return null;t.add(e);try{if(Array.isArray(e)){let i=[];for(let o of e){let s=Gb(o,t);if(s===null)return null;i.push(s)}return`a${i.length}:[${i.join(",")}]`}let a=Object.keys(e).sort(),n=[];for(let i of a){let o=Gb(e[i],t);if(o===null)return null;n.push(`${i.length}:${i}=${o}`)}return`o${n.length}:{${n.join(",")}}`}finally{t.delete(e)}}var I0=new Set(["items","prefixItems","additionalItems","additionalProperties","contains","propertyNames","not","if","then","else","allOf","anyOf","oneOf","unevaluatedItems","unevaluatedProperties","contentSchema"]),P0=new Set(["properties","patternProperties","dependentSchemas","dependencies","$defs","definitions"]);function As(e){return typeof e!="object"||e===null?!1:Array.isArray(e)?e.some(As):typeof e.$ref=="string"?!0:Object.entries(e).some(([t,r])=>I0.has(t)?As(r):!P0.has(t)||typeof r!="object"||r===null?!1:Object.values(r).some(As))}function Tx(e){return e===1?"element":"elements"}function R0(e,t){return $.transform(a=>a).check(a=>{let n=a.value;if(Array.isArray(n)){if(t.uniqueItems===!0){let i=new Map;for(let o=0;o<n.length;o++){let s=Gb(n[o],new Set);if(s===null)continue;let l=i.get(s);if(l===void 0){i.set(s,o);continue}a.issues.push({code:"custom",message:`Array items must be unique: element at index ${o} duplicates the one at index ${l}`,input:n,path:[o],continue:!0})}}if(t.containsSchema){let i=t.minContains??1,o=t.maxContains!==void 0?t.maxContains+1:Number.POSITIVE_INFINITY,s=0;for(let l of n)if(t.containsSchema.safeParse(l).success&&++s>=o)break;s<i&&a.issues.push({code:"custom",message:`Array must contain at least ${i} matching ${Tx(i)}; found ${s}`,input:n,continue:!0}),t.maxContains!==void 0&&s>t.maxContains&&a.issues.push({code:"custom",message:`Array must contain at most ${t.maxContains} matching ${Tx(t.maxContains)}`,input:n,continue:!0})}}}).pipe(e)}function Ax(e,t){if(e!==!1)return e===void 0||e===!0?$.any():pt(e,t)}var $0=/^(?:[01]\d|2[0-3]):[0-5]\d:[0-5]\d(?:\.\d+)?(?:Z|[+-](?:[01]\d|2[0-3]):[0-5]\d)$/;function Cx(e,t){if(e.not!==void 0){if(typeof e.not=="object"&&Object.keys(e.not).length===0)return $.never();throw new Error("not is not supported in Zod (except { not: {} } for never)")}if(e.unevaluatedItems!==void 0)throw new Error("unevaluatedItems is not supported");if(e.unevaluatedProperties!==void 0)throw new Error("unevaluatedProperties is not supported");if(e.if!==void 0||e.then!==void 0||e.else!==void 0)throw new Error("Conditional schemas (if/then/else) are not supported");if(e.dependentSchemas!==void 0||e.dependentRequired!==void 0)throw new Error("dependentSchemas and dependentRequired are not supported");if(e.$ref){let n=e.$ref;if(t.refs.has(n))return t.refs.get(n);if(t.processing.has(n))return $.lazy(()=>{if(!t.refs.has(n))throw new Error(`Circular reference not resolved: ${n}`);return t.refs.get(n)});t.processing.add(n);let i=C0(n,t),o=pt(i,t);return t.refs.set(n,o),t.processing.delete(n),o}if(e.enum!==void 0){let n=e.enum;if(t.version==="openapi-3.0"&&e.nullable===!0&&n.length===1&&n[0]===null)return $.null();if(n.length===0)return $.never();if(n.length===1)return $.literal(n[0]);if(n.every(o=>typeof o=="string"))return $.enum(n);let i=n.map(o=>$.literal(o));return i.length<2?i[0]:$.union([i[0],i[1],...i.slice(2)])}if(e.const!==void 0)return $.literal(e.const);let r=e.type;if(Array.isArray(r)){let n=r.map(i=>{let o={...e,type:i};return Cx(o,t)});return n.length===0?$.never():n.length===1?n[0]:$.union(n)}if(!r)return $.any();let a;switch(r){case"string":{let n=$.string();if(e.format){let i=e.format;i==="email"?n=n.check($.email()):i==="uri"||i==="uri-reference"?n=n.check($.url()):i==="uuid"||i==="guid"?n=n.check($.uuid()):i==="date-time"?n=n.check($.iso.datetime({offset:!0})):i==="date"?n=n.check($.iso.date()):i==="time"?n=n.check($.regex($0)):i==="duration"?n=n.check($.iso.duration()):i==="hostname"?n=n.check($.hostname()):i==="ipv4"?n=n.check($.ipv4()):i==="ipv6"?n=n.check($.ipv6()):i==="mac"?n=n.check($.mac()):i==="cidr"?n=n.check($.cidrv4()):i==="cidr-v6"?n=n.check($.cidrv6()):i==="base64"?n=n.check($.base64()):i==="base64url"?n=n.check($.base64url()):i==="e164"?n=n.check($.e164()):i==="credit_card"?n=n.check($.creditCard()):i==="iban"?n=n.check($.iban()):i==="jwt"?n=n.check($.jwt()):i==="emoji"?n=n.check($.emoji()):i==="nanoid"?n=n.check($.nanoid()):i==="cuid"?n=n.check($.cuid()):i==="cuid2"?n=n.check($.cuid2()):i==="ulid"?n=n.check($.ulid()):i==="xid"?n=n.check($.xid()):i==="ksuid"&&(n=n.check($.ksuid()))}typeof e.minLength=="number"&&(n=n.min(e.minLength)),typeof e.maxLength=="number"&&(n=n.max(e.maxLength)),e.pattern&&(n=n.regex(new RegExp(e.pattern))),a=n;break}case"number":case"integer":{let n=r==="integer"?$.number().int():$.number();typeof e.minimum=="number"&&e.exclusiveMinimum!==!0&&(n=n.min(e.minimum)),typeof e.maximum=="number"&&e.exclusiveMaximum!==!0&&(n=n.max(e.maximum)),typeof e.exclusiveMinimum=="number"?n=n.gt(e.exclusiveMinimum):e.exclusiveMinimum===!0&&typeof e.minimum=="number"&&(n=n.gt(e.minimum)),typeof e.exclusiveMaximum=="number"?n=n.lt(e.exclusiveMaximum):e.exclusiveMaximum===!0&&typeof e.maximum=="number"&&(n=n.lt(e.maximum)),typeof e.multipleOf=="number"&&(n=n.multipleOf(e.multipleOf)),a=n;break}case"boolean":{a=$.boolean();break}case"null":{a=$.null();break}case"object":{let n={},i=e.properties||{},o=new Set(e.required||[]),s=typeof e.additionalProperties=="object"?pt(e.additionalProperties,t):void 0;for(let[d,m]of Object.entries(i)){let p=pt(m,t);Ge(n,d,o.has(d)?p:p.optional())}if(e.patternProperties){let d=e.patternProperties,m=Object.keys(d),p=[];for(let h of m){let f=pt(d[h],t),_=$.string().regex(new RegExp(h));p.push($.looseRecord(_,f))}let g=[];if(Object.keys(n).length>0&&g.push($.object(n).passthrough()),g.push(...p),g.length===0)a=$.object({}).passthrough();else if(g.length===1)a=g[0];else{let h=$.intersection(g[0],g[1]);for(let f=2;f<g.length;f++)h=$.intersection(h,g[f]);a=h}if(e.additionalProperties===!1){let h=Object.keys(n),f=m.map(b=>new RegExp(b)),_=a;a=a.check(b=>{if(!Dt(b.value))return;let v=[];for(let C of Object.keys(b.value))h.includes(C)||f.some(S=>S.test(C))||v.push(C);v.length&&b.issues.push({code:"unrecognized_keys",keys:v,input:b.value,inst:_})})}}else{let d=$.object(n);e.additionalProperties===!1?a=d.strict():s?a=d.catchall(s):a=d.passthrough()}let l=e.propertyNames!==void 0&&e.propertyNames!==!0,c=typeof e.minProperties=="number"?e.minProperties:void 0,u=typeof e.maxProperties=="number"?e.maxProperties:void 0;if(l||c!==void 0||u!==void 0){let d;if(l){let m=typeof e.propertyNames=="object"&&e.propertyNames.type===void 0?{type:"string",...e.propertyNames}:e.propertyNames;d=pt(m,t)}a=z0(a,{keySchema:d,minProperties:c,maxProperties:u})}break}case"array":{let n=e.prefixItems,i=e.items;if(n&&Array.isArray(n)){let o=typeof e.minItems=="number"?e.minItems:0,s=n.map(d=>pt(d,t)),l=xx(s,o),c=Array.isArray(i)?void 0:Ax(i,t),u=$.tuple(l);a=c?u.rest(c):u,typeof e.minItems=="number"&&(a=a.check($.minLength(e.minItems))),typeof e.maxItems=="number"&&(a=a.check($.maxLength(e.maxItems)))}else if(Array.isArray(i)){let o=typeof e.minItems=="number"?e.minItems:0,s=i.map(d=>pt(d,t)),l=xx(s,o),c=Ax(e.additionalItems,t),u=$.tuple(l);a=c?u.rest(c):u,typeof e.minItems=="number"&&(a=a.check($.minLength(e.minItems))),typeof e.maxItems=="number"&&(a=a.check($.maxLength(e.maxItems)))}else if(i!==void 0){let o=pt(i,t),s=$.array(o);typeof e.minItems=="number"&&(s=s.min(e.minItems)),typeof e.maxItems=="number"&&(s=s.max(e.maxItems)),a=s}else a=$.array($.any());(e.uniqueItems===!0||e.contains!==void 0)&&(a=R0(a,{uniqueItems:e.uniqueItems===!0,containsSchema:e.contains!==void 0?pt(e.contains,t):void 0,minContains:typeof e.minContains=="number"?e.minContains:void 0,maxContains:typeof e.maxContains=="number"?e.maxContains:void 0}));break}default:throw new Error(`Unsupported type: ${r}`)}return a}function pt(e,t){if(typeof e=="boolean")return e?$.any():$.never();let r=Cx(e,t),a=e.type||e.enum!==void 0||e.const!==void 0;if(e.anyOf&&Array.isArray(e.anyOf)){let s=e.anyOf.map(c=>pt(c,t)),l=$.union(s);r=a?$.intersection(r,l):l}if(e.oneOf&&Array.isArray(e.oneOf)){let s=e.oneOf.map(c=>pt(c,t)),l=$.xor(s);r=a?$.intersection(r,l):l}if(e.allOf&&Array.isArray(e.allOf))if(e.allOf.length===0)r=a?r:$.any();else{let s=a?r:pt(e.allOf[0],t),l=a?0:1;for(let c=l;c<e.allOf.length;c++)s=$.intersection(s,pt(e.allOf[c],t));r=s}e.nullable===!0&&t.version==="openapi-3.0"&&(r=$.nullable(r)),e.readOnly===!0&&(r=$.readonly(r)),e.default!==void 0&&(r=r.default(e.default));let n={},i=["$id","id","$comment","$anchor","$vocabulary","$dynamicRef","$dynamicAnchor"];for(let s of i)s in e&&(n[s]=e[s]);let o=["contentEncoding","contentMediaType","contentSchema"];for(let s of o)s in e&&(n[s]=e[s]);if(e.type==="object"&&e.$ref===void 0){e.propertyNames!==void 0&&!As(e.propertyNames)&&(n.propertyNames=e.propertyNames);for(let s of["minProperties","maxProperties"])e[s]!==void 0&&(n[s]=e[s])}if(e.type==="array"&&e.$ref===void 0){e.contains!==void 0&&!As(e.contains)&&(n.contains=e.contains);for(let s of["uniqueItems","minContains","maxContains"])e[s]!==void 0&&(n[s]=e[s])}for(let s of Object.keys(e))x0.has(s)||Ge(n,s,e[s]);return Object.keys(n).length>0&&t.registry.add(r,n),e.description&&(r=r.describe(e.description)),r}function zx(e,t){if(typeof e=="boolean")return e?$.any():$.never();let r;try{r=JSON.parse(JSON.stringify(e))}catch{throw new Error("fromJSONSchema input is not valid JSON (possibly cyclic); use $defs/$ref for recursive schemas")}let a=T0(r,t?.defaultTarget),n=r.$defs||r.definitions||{},i={version:a,defs:n,refs:new Map,processing:new Set,rootSchema:r,registry:t?.registry??Ve};return pt(r,i)}var Ix=Symbol("z.visit/resolving");function Cs(e,t){let r=typeof t=="function"?t:(o,s)=>{let l=t[o._zod.def.type];return l?l(o,s):o},a=new Map;function n(o){let s=a.get(o);if(s===Ix)return new La({type:"lazy",getter:()=>a.get(o)});if(s!==void 0)return s;a.set(o,Ix);let l=i(o),c=r(l,l!==o);return a.set(o,c),c}function i(o){let s=o._zod.def,l=s.type;switch(l){case"object":{let c=s.shape,u=Object.keys(c),d=!1,m={};for(let g of u){let h=n(c[g]);h!==c[g]&&(d=!0),m[g]=h}let p=s.catchall;return s.catchall&&(p=n(s.catchall),p!==s.catchall&&(d=!0)),d?ge(o,{...s,shape:m,catchall:p}):o}case"array":{let c=n(s.element);return c===s.element?o:ge(o,{...s,element:c})}case"tuple":{let c=s.items,u=!1,d=[];for(let p of c){let g=n(p);g!==p&&(u=!0),d.push(g)}let m=s.rest;return s.rest&&(m=n(s.rest),m!==s.rest&&(u=!0)),u?ge(o,{...s,items:d,rest:m}):o}case"record":case"map":{let c=n(s.keyType),u=n(s.valueType);return c===s.keyType&&u===s.valueType?o:ge(o,{...s,keyType:c,valueType:u})}case"set":{let c=n(s.valueType);return c===s.valueType?o:ge(o,{...s,valueType:c})}case"union":{let c=s.options,u=!1,d=[];for(let m of c){let p=n(m);p!==m&&(u=!0),d.push(p)}return u?ge(o,{...s,options:d}):o}case"intersection":{let c=n(s.left),u=n(s.right);return c===s.left&&u===s.right?o:ge(o,{...s,left:c,right:u})}case"optional":case"nullable":case"default":case"prefault":case"catch":case"readonly":case"nonoptional":case"promise":case"success":{let c=n(s.innerType);return c===s.innerType?o:ge(o,{...s,innerType:c})}case"pipe":{let c=n(s.in),u=n(s.out);return c===s.in&&u===s.out?o:ge(o,{...s,in:c,out:u})}case"function":{let c=n(s.input),u=n(s.output);return c===s.input&&u===s.output?o:ge(o,{...s,input:c,output:u})}case"lazy":{let c=s.getter,{_cachedInner:u,...d}=s;return ge(o,{...d,getter:()=>n(c())})}case"template_literal":case"string":case"number":case"int":case"boolean":case"bigint":case"symbol":case"undefined":case"null":case"void":case"never":case"any":case"unknown":case"date":case"nan":case"enum":case"literal":case"file":case"transform":case"custom":return o;default:return o}}return n(e)}function Px(e){return Cs(e,{object:t=>t.partial(),union:t=>{let r=t._zod.def;return r.discriminator===void 0?t:ye(r.options)}})}function j0(e,t){if(!t?.length)return e;let r=e._zod.def;return ge(e,Nt(r,{checks:[...r.checks??[],...t]}),{parent:!0})}function Rx(e){return j0(e.out,e.checks)}function O0(e){return e.in._zod.traits.has("$ZodTransform")?Rx(e):e.in}function $x(e){return Cs(e,{pipe:t=>O0(t._zod.def),default:(t,r)=>r?we(t._zod.def.innerType):t,catch:(t,r)=>r?t._zod.def.innerType:t})}function jx(e){return Cs(e,{pipe:t=>Rx(t._zod.def),prefault:(t,r)=>r?t._zod.def.innerType:t})}var Vb={};En(Vb,{bigint:()=>L0,boolean:()=>M0,date:()=>B0,number:()=>D0,string:()=>N0});function N0(e){return Wh(ci,e)}function D0(e){return Zh(ui,e)}function M0(e){return Jh(di,e)}function L0(e){return Yh(pi,e)}function B0(e){return Xh(ys,e)}var Kb="2025-11-25",Ox="2025-03-26",fi=[Kb,"2025-06-18","2025-03-26","2024-11-05","2024-10-07"],pr="io.modelcontextprotocol/related-task",tp="2.0",Fe=Qd(e=>e!==null&&(typeof e=="object"||typeof e=="function")),Nx=ye([w(),he().int()]),Dx=w(),CV=We({ttl:he().optional(),pollInterval:he().optional()}),U0=O({ttl:he().optional()}),F0=O({taskId:w()}),Zb=We({progressToken:Nx.optional(),[pr]:F0.optional()}),Pt=O({_meta:Zb.optional()}),zs=Pt.extend({task:U0.optional()}),Mx=e=>zs.safeParse(e).success,Ze=O({method:w(),params:Pt.loose().optional()}),Lt=O({_meta:Zb.optional()}),Bt=O({method:w(),params:Lt.loose().optional()}),Je=We({_meta:Zb.optional()}),np=ye([w(),he().int()]),Lx=O({jsonrpc:B(tp),id:np,...Ze.shape}).strict(),zn=e=>Lx.safeParse(e).success,Bx=O({jsonrpc:B(tp),...Bt.shape}).strict(),Ux=e=>Bx.safeParse(e).success,Jb=O({jsonrpc:B(tp),id:np,result:Je}).strict(),In=e=>Jb.safeParse(e).success;var F;(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"})(F||(F={}));var Yb=O({jsonrpc:B(tp),id:np.optional(),error:O({code:he().int(),message:w(),data:xe().optional()})}).strict();var bi=e=>Yb.safeParse(e).success;var Is=ye([Lx,Bx,Jb,Yb]),zV=ye([Jb,Yb]),rp=Je.strict(),q0=Lt.extend({requestId:np.optional(),reason:w().optional()}),ap=Bt.extend({method:B("notifications/cancelled"),params:q0}),H0=O({src:w(),mimeType:w().optional(),sizes:ae(w()).optional(),theme:Ke(["light","dark"]).optional()}),Ps=O({icons:ae(H0).optional()}),hi=O({name:w(),title:w().optional()}),Fx=hi.extend({...hi.shape,...Ps.shape,version:w(),websiteUrl:w().optional(),description:w().optional()}),G0=mi(O({applyDefaults:De().optional()}),Ee(w(),xe())),V0=Ts(e=>e&&typeof e=="object"&&!Array.isArray(e)&&Object.keys(e).length===0?{form:{}}:e,mi(O({form:G0.optional(),url:Fe.optional()}),Ee(w(),xe()).optional())),W0=We({list:Fe.optional(),cancel:Fe.optional(),requests:We({sampling:We({createMessage:Fe.optional()}).optional(),elicitation:We({create:Fe.optional()}).optional()}).optional()}),K0=We({list:Fe.optional(),cancel:Fe.optional(),requests:We({tools:We({call:Fe.optional()}).optional()}).optional()}),Z0=O({experimental:Ee(w(),Fe).optional(),sampling:O({context:Fe.optional(),tools:Fe.optional()}).optional(),elicitation:V0.optional(),roots:O({listChanged:De().optional()}).optional(),tasks:W0.optional(),extensions:Ee(w(),Fe).optional()}),J0=Pt.extend({protocolVersion:w(),capabilities:Z0,clientInfo:Fx}),ip=Ze.extend({method:B("initialize"),params:J0}),Xb=e=>ip.safeParse(e).success,Y0=O({experimental:Ee(w(),Fe).optional(),logging:Fe.optional(),completions:Fe.optional(),prompts:O({listChanged:De().optional()}).optional(),resources:O({subscribe:De().optional(),listChanged:De().optional()}).optional(),tools:O({listChanged:De().optional()}).optional(),tasks:K0.optional(),extensions:Ee(w(),Fe).optional()}),X0=Je.extend({protocolVersion:w(),capabilities:Y0,serverInfo:Fx,instructions:w().optional()}),Qb=Bt.extend({method:B("notifications/initialized"),params:Lt.optional()});var op=Ze.extend({method:B("ping"),params:Pt.optional()}),Q0=O({progress:he(),total:we(he()),message:we(w())}),ej=O({...Lt.shape,...Q0.shape,progressToken:Nx}),sp=Bt.extend({method:B("notifications/progress"),params:ej}),tj=Pt.extend({cursor:Dx.optional()}),Rs=Ze.extend({params:tj.optional()}),$s=Je.extend({nextCursor:Dx.optional()}),nj=Ke(["working","input_required","completed","failed","cancelled"]),js=O({taskId:w(),status:nj,ttl:ye([he(),vs()]),createdAt:w(),lastUpdatedAt:w(),pollInterval:we(he()),statusMessage:we(w())}),vi=Je.extend({task:js}),rj=Lt.merge(js),Os=Bt.extend({method:B("notifications/tasks/status"),params:rj}),lp=Ze.extend({method:B("tasks/get"),params:Pt.extend({taskId:w()})}),cp=Je.merge(js),up=Ze.extend({method:B("tasks/result"),params:Pt.extend({taskId:w()})}),IV=Je.loose(),dp=Rs.extend({method:B("tasks/list")}),pp=$s.extend({tasks:ae(js)}),mp=Ze.extend({method:B("tasks/cancel"),params:Pt.extend({taskId:w()})}),qx=Je.merge(js),Hx=O({uri:w(),mimeType:we(w()),_meta:Ee(w(),xe()).optional()}),Gx=Hx.extend({text:w()}),ev=w().refine(e=>{try{return atob(e),!0}catch{return!1}},{message:"Invalid Base64 string"}),Vx=Hx.extend({blob:ev}),Ns=Ke(["user","assistant"]),yi=O({audience:ae(Ns).optional(),priority:he().min(0).max(1).optional(),lastModified:Zr.datetime({offset:!0}).optional()}),Wx=O({...hi.shape,...Ps.shape,uri:w(),description:we(w()),mimeType:we(w()),size:we(he()),annotations:yi.optional(),_meta:we(We({}))}),aj=O({...hi.shape,...Ps.shape,uriTemplate:w(),description:we(w()),mimeType:we(w()),annotations:yi.optional(),_meta:we(We({}))}),gp=Rs.extend({method:B("resources/list")}),ij=$s.extend({resources:ae(Wx)}),hp=Rs.extend({method:B("resources/templates/list")}),oj=$s.extend({resourceTemplates:ae(aj)}),tv=Pt.extend({uri:w()}),sj=tv,fp=Ze.extend({method:B("resources/read"),params:sj}),lj=Je.extend({contents:ae(ye([Gx,Vx]))}),cj=Bt.extend({method:B("notifications/resources/list_changed"),params:Lt.optional()}),uj=tv,dj=Ze.extend({method:B("resources/subscribe"),params:uj}),pj=tv,mj=Ze.extend({method:B("resources/unsubscribe"),params:pj}),gj=Lt.extend({uri:w()}),hj=Bt.extend({method:B("notifications/resources/updated"),params:gj}),fj=O({name:w(),description:we(w()),required:we(De())}),bj=O({...hi.shape,...Ps.shape,description:we(w()),arguments:we(ae(fj)),_meta:we(We({}))}),bp=Rs.extend({method:B("prompts/list")}),vj=$s.extend({prompts:ae(bj)}),yj=Pt.extend({name:w(),arguments:Ee(w(),w()).optional()}),vp=Ze.extend({method:B("prompts/get"),params:yj}),nv=O({type:B("text"),text:w(),annotations:yi.optional(),_meta:Ee(w(),xe()).optional()}),rv=O({type:B("image"),data:ev,mimeType:w(),annotations:yi.optional(),_meta:Ee(w(),xe()).optional()}),av=O({type:B("audio"),data:ev,mimeType:w(),annotations:yi.optional(),_meta:Ee(w(),xe()).optional()}),kj=O({type:B("tool_use"),name:w(),id:w(),input:Ee(w(),xe()),_meta:Ee(w(),xe()).optional()}),_j=O({type:B("resource"),resource:ye([Gx,Vx]),annotations:yi.optional(),_meta:Ee(w(),xe()).optional()}),wj=Wx.extend({type:B("resource_link")}),iv=ye([nv,rv,av,wj,_j]),Sj=O({role:Ns,content:iv}),Ej=Je.extend({description:w().optional(),messages:ae(Sj)}),xj=Bt.extend({method:B("notifications/prompts/list_changed"),params:Lt.optional()}),Tj=O({title:w().optional(),readOnlyHint:De().optional(),destructiveHint:De().optional(),idempotentHint:De().optional(),openWorldHint:De().optional()}),Aj=O({taskSupport:Ke(["required","optional","forbidden"]).optional()}),Kx=O({...hi.shape,...Ps.shape,description:w().optional(),inputSchema:O({type:B("object"),properties:Ee(w(),Fe).optional(),required:ae(w()).optional()}).catchall(xe()),outputSchema:O({type:B("object"),properties:Ee(w(),Fe).optional(),required:ae(w()).optional()}).catchall(xe()).optional(),annotations:Tj.optional(),execution:Aj.optional(),_meta:Ee(w(),xe()).optional()}),yp=Rs.extend({method:B("tools/list")}),Cj=$s.extend({tools:ae(Kx)}),kp=Je.extend({content:ae(iv).default([]),structuredContent:Ee(w(),xe()).optional(),isError:De().optional()}),PV=kp.or(Je.extend({toolResult:xe()})),zj=zs.extend({name:w(),arguments:Ee(w(),xe()).optional()}),ki=Ze.extend({method:B("tools/call"),params:zj}),Ij=Bt.extend({method:B("notifications/tools/list_changed"),params:Lt.optional()}),RV=O({autoRefresh:De().default(!0),debounceMs:he().int().nonnegative().default(300)}),Ds=Ke(["debug","info","notice","warning","error","critical","alert","emergency"]),Pj=Pt.extend({level:Ds}),ov=Ze.extend({method:B("logging/setLevel"),params:Pj}),Rj=Lt.extend({level:Ds,logger:w().optional(),data:xe()}),$j=Bt.extend({method:B("notifications/message"),params:Rj}),jj=O({name:w().optional()}),Oj=O({hints:ae(jj).optional(),costPriority:he().min(0).max(1).optional(),speedPriority:he().min(0).max(1).optional(),intelligencePriority:he().min(0).max(1).optional()}),Nj=O({mode:Ke(["auto","required","none"]).optional()}),Dj=O({type:B("tool_result"),toolUseId:w().describe("The unique identifier for the corresponding tool call."),content:ae(iv).default([]),structuredContent:O({}).loose().optional(),isError:De().optional(),_meta:Ee(w(),xe()).optional()}),Mj=ws("type",[nv,rv,av]),ep=ws("type",[nv,rv,av,kj,Dj]),Lj=O({role:Ns,content:ye([ep,ae(ep)]),_meta:Ee(w(),xe()).optional()}),Bj=zs.extend({messages:ae(Lj),modelPreferences:Oj.optional(),systemPrompt:w().optional(),includeContext:Ke(["none","thisServer","allServers"]).optional(),temperature:he().optional(),maxTokens:he().int(),stopSequences:ae(w()).optional(),metadata:Fe.optional(),tools:ae(Kx).optional(),toolChoice:Nj.optional()}),Uj=Ze.extend({method:B("sampling/createMessage"),params:Bj}),Ms=Je.extend({model:w(),stopReason:we(Ke(["endTurn","stopSequence","maxTokens"]).or(w())),role:Ns,content:Mj}),sv=Je.extend({model:w(),stopReason:we(Ke(["endTurn","stopSequence","maxTokens","toolUse"]).or(w())),role:Ns,content:ye([ep,ae(ep)])}),Fj=O({type:B("boolean"),title:w().optional(),description:w().optional(),default:De().optional()}),qj=O({type:B("string"),title:w().optional(),description:w().optional(),minLength:he().optional(),maxLength:he().optional(),format:Ke(["email","uri","date","date-time"]).optional(),default:w().optional()}),Hj=O({type:Ke(["number","integer"]),title:w().optional(),description:w().optional(),minimum:he().optional(),maximum:he().optional(),default:he().optional()}),Gj=O({type:B("string"),title:w().optional(),description:w().optional(),enum:ae(w()),default:w().optional()}),Vj=O({type:B("string"),title:w().optional(),description:w().optional(),oneOf:ae(O({const:w(),title:w()})),default:w().optional()}),Wj=O({type:B("string"),title:w().optional(),description:w().optional(),enum:ae(w()),enumNames:ae(w()).optional(),default:w().optional()}),Kj=ye([Gj,Vj]),Zj=O({type:B("array"),title:w().optional(),description:w().optional(),minItems:he().optional(),maxItems:he().optional(),items:O({type:B("string"),enum:ae(w())}),default:ae(w()).optional()}),Jj=O({type:B("array"),title:w().optional(),description:w().optional(),minItems:he().optional(),maxItems:he().optional(),items:O({anyOf:ae(O({const:w(),title:w()}))}),default:ae(w()).optional()}),Yj=ye([Zj,Jj]),Xj=ye([Wj,Kj,Yj]),Qj=ye([Xj,Fj,qj,Hj]),eO=zs.extend({mode:B("form").optional(),message:w(),requestedSchema:O({type:B("object"),properties:Ee(w(),Qj),required:ae(w()).optional()})}),tO=zs.extend({mode:B("url"),message:w(),elicitationId:w(),url:w().url()}),nO=ye([eO,tO]),rO=Ze.extend({method:B("elicitation/create"),params:nO}),aO=Lt.extend({elicitationId:w()}),iO=Bt.extend({method:B("notifications/elicitation/complete"),params:aO}),_i=Je.extend({action:Ke(["accept","decline","cancel"]),content:Ts(e=>e===null?void 0:e,Ee(w(),ye([w(),he(),De(),ae(w())])).optional())}),oO=O({type:B("ref/resource"),uri:w()});var sO=O({type:B("ref/prompt"),name:w()}),lO=Pt.extend({ref:ye([sO,oO]),argument:O({name:w(),value:w()}),context:O({arguments:Ee(w(),w()).optional()}).optional()}),_p=Ze.extend({method:B("completion/complete"),params:lO});function Zx(e){if(e.params.ref.type!=="ref/prompt")throw new TypeError(`Expected CompleteRequestPrompt, but got ${e.params.ref.type}`)}function Jx(e){if(e.params.ref.type!=="ref/resource")throw new TypeError(`Expected CompleteRequestResourceTemplate, but got ${e.params.ref.type}`)}var cO=Je.extend({completion:We({values:ae(w()).max(100),total:we(he().int()),hasMore:we(De())})}),uO=O({uri:w().startsWith("file://"),name:w().optional(),_meta:Ee(w(),xe()).optional()}),dO=Ze.extend({method:B("roots/list"),params:Pt.optional()}),lv=Je.extend({roots:ae(uO)}),pO=Bt.extend({method:B("notifications/roots/list_changed"),params:Lt.optional()}),$V=ye([op,ip,_p,ov,vp,bp,gp,hp,fp,dj,mj,ki,yp,lp,up,dp,mp]),jV=ye([ap,sp,Qb,pO,Os]),OV=ye([rp,Ms,sv,_i,lv,cp,pp,vi]),NV=ye([op,Uj,rO,dO,lp,up,dp,mp]),DV=ye([ap,sp,$j,hj,cj,Ij,xj,Os,iO]),MV=ye([rp,X0,cO,Ej,vj,ij,oj,lj,kp,Cj,cp,pp,vi]),M=class e extends Error{constructor(t,r,a){super(`MCP error ${t}: ${r}`),this.code=t,this.data=a,this.name="McpError"}static fromError(t,r,a){if(t===F.UrlElicitationRequired&&a){let n=a;if(n.elicitations)return new Wb(n.elicitations,r)}return new e(t,r,a)}},Wb=class extends M{constructor(t,r=`URL elicitation${t.length>1?"s":""} required`){super(F.UrlElicitationRequired,r,{elicitations:t})}get elicitations(){return this.data?.elicitations??[]}};var mO=10*1024*1024,wp=class{constructor(t){this._maxBufferSize=t?.maxBufferSize??mO}append(t){if((this._buffer?.length??0)+t.length>this._maxBufferSize)throw this.clear(),new Error(`ReadBuffer exceeded maximum size of ${this._maxBufferSize} bytes`);this._buffer=this._buffer?Buffer.concat([this._buffer,t]):t}readMessage(){if(!this._buffer)return null;let t=this._buffer.indexOf(`
|
|
70
|
+
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let o of e.seen.entries()){let s=o[1];if(t===o[0]){i(o);continue}if(e.external){let c=e.external.registry.get(o[0])?.id;if(t!==o[0]&&c){i(o);continue}}if(e.metadataRegistry.get(o[0])?.id){i(o);continue}if(s.cycle){i(o);continue}s.count>1&&e.reused==="ref"&&i(o)}e.external&&(e.sharedDefsExtractedFor=e.external)}function XS(e){let t=e.anyOf;if(!Array.isArray(t)||t.length===0||e.type!==void 0)return;let r=[];for(let a of t){if(!a||typeof a!="object")return;XS(a);let n=Object.keys(a);if(n.length!==1||n[0]!=="type")return;let i=a.type;for(let o of Array.isArray(i)?i:[i]){if(typeof o!="string")return;r.includes(o)||r.push(o)}}delete e.anyOf,e.type=r.length===1?r[0]:r}var QS=new Set(["type","properties","required","additionalProperties"]),JS=["oneOf","anyOf"];function YS(e){let t=e.additionalProperties;return t===void 0||t===!1||typeof t!="object"||t===null?null:Object.keys(t).length?t:null}function ef(e){let t=[];for(let i of e){if(typeof i!="object"||i.type!=="object")return null;for(let o in i)if(!QS.has(o))return null;t.push(i)}let r={},a=new Set;for(let i of t){for(let o in i.properties){if(Object.prototype.hasOwnProperty.call(r,o))continue;let s=[];for(let c of t){let u=c.properties?.[o]??YS(c);u!=null&&(s.some(d=>JSON.stringify(d)===JSON.stringify(u))||s.push(u))}let l=s.length===1?s[0]:ef(s)??{allOf:s};Ge(r,o,l)}for(let o of i.required??[])a.add(o)}let n={type:"object",properties:r};if(a.size&&(n.required=[...a]),t.every(i=>i.additionalProperties===!1))n.additionalProperties=!1;else{let i=[];for(let o of t){let s=YS(o);s&&!i.some(l=>JSON.stringify(l)===JSON.stringify(s))&&i.push(s)}i.length===1?n.additionalProperties=i[0]:i.length>1&&(n.additionalProperties={allOf:i})}return n}function c0(e){let t=e.allOf;if(!Array.isArray(t)||t.length<2)return;for(let n of QS)if(n in e)return;let r=t.filter(n=>JS.some(i=>Array.isArray(n[i]))),a=null;if(!r.length)a=ef(t);else{let n=r[0],i=JS.find(l=>Array.isArray(n[l]));if(Object.keys(n).length!==1)return;let o=t.filter(l=>l!==n),s=n[i].map(l=>ef([...o,l]));if(s.some(l=>!l))return;a={[i]:s}}a&&(delete e.allOf,gs(e,a))}function sr(e,t){let r=e.seen.get(t);if(!r)throw new Error("Unprocessed schema. This is a bug in Zod.");let a=s=>{let l=e.seen.get(s);if(l.ref===null)return;let c=l.def??l.schema,u={...c},d=l.ref;if(l.ref=null,d){a(d);let p=e.seen.get(d),g=p.schema;if(g.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0")?(c.allOf=c.allOf??[],c.allOf.push(g)):gs(c,g),gs(c,u),s._zod.parent===d)for(let f in c)f==="$ref"||f==="allOf"||f in u||delete c[f];if(g.$ref&&p.def)for(let f in c)f==="$ref"||f==="allOf"||f in p.def&&JSON.stringify(c[f])===JSON.stringify(p.def[f])&&delete c[f]}let m=s._zod.parent;if(m&&m!==d){a(m);let p=e.seen.get(m);if(p?.schema.$ref&&(c.$ref=p.schema.$ref,p.def))for(let g in c)g==="$ref"||g==="allOf"||g in p.def&&JSON.stringify(c[g])===JSON.stringify(p.def[g])&&delete c[g]}e.override({zodSchema:s,jsonSchema:c,path:l.path??[]})};if(!e.external||e.sharedEmitDoneFor!==e.external){for(let s of[...e.seen.entries()].reverse())a(s[0]);if(e.target!=="openapi-3.0")for(let s of e.seen.entries())XS(s[1].def??s[1].schema);for(let s of e.deferred)s();if(e.intersections.length){let s=new Map;for(let l of e.seen.values())for(let c of[l.schema,l.def]){let u=c?.allOf;if(!Array.isArray(u))continue;let d=s.get(u);d?d.push(c):s.set(u,[c])}for(let l of e.intersections)for(let c of s.get(l)??[])c0(c)}}let n={};if(e.target==="draft-2020-12"?n.$schema="https://json-schema.org/draft/2020-12/schema":e.target==="draft-07"?n.$schema="http://json-schema.org/draft-07/schema#":e.target==="draft-04"?n.$schema="http://json-schema.org/draft-04/schema#":e.target,e.external?.uri){let s=e.external.registry.get(t)?.id;if(!s)throw new Error("Schema is missing an `id` property");n.$id=e.external.uri(s)}gs(n,r.defId?r.schema:r.def??r.schema);let i=e.metadataRegistry.get(t)?.id;i!==void 0&&n.id===i&&delete n.id;let o=e.external?.defs??{};if(!e.external||e.sharedEmitDoneFor!==e.external)for(let s of e.seen.entries()){let l=s[1];l.def&&l.defId&&(l.def.id===l.defId&&delete l.def.id,Ge(o,l.defId,l.def))}e.external&&(e.sharedEmitDoneFor=e.external),e.external||Object.keys(o).length>0&&(e.target==="draft-2020-12"?n.$defs=o:n.definitions=o);try{let s=JSON.parse(JSON.stringify(n));return Object.defineProperty(s,"~standard",{value:{...t["~standard"],jsonSchema:{input:ai(t,"input",e.processors),output:ai(t,"output",e.processors)}},enumerable:!1,writable:!1}),s}catch{throw new Error("Error converting schema to JSON.")}}function dt(e,t){let r=t??{seen:new Set};if(r.seen.has(e))return!1;r.seen.add(e);let a=e._zod.def;if(a.type==="transform")return!0;if(a.type==="array")return dt(a.element,r);if(a.type==="set")return dt(a.valueType,r);if(a.type==="lazy")return dt(a.getter(),r);if(a.type==="promise"||a.type==="optional"||a.type==="nonoptional"||a.type==="nullable"||a.type==="readonly"||a.type==="default"||a.type==="prefault"||a.type==="catch")return dt(a.innerType,r);if(a.type==="intersection")return dt(a.left,r)||dt(a.right,r);if(a.type==="record"||a.type==="map")return dt(a.keyType,r)||dt(a.valueType,r);if(a.type==="pipe")return e._zod.traits.has("$ZodCodec")?!0:dt(a.in,r)||dt(a.out,r);if(a.type==="object"){for(let n in a.shape)if(dt(a.shape[n],r))return!0;return!1}if(a.type==="union"){for(let n of a.options)if(dt(n,r))return!0;return!1}if(a.type==="tuple"){for(let n of a.items)if(dt(n,r))return!0;return!!(a.rest&&dt(a.rest,r))}return!1}var tf=(e,t={})=>r=>{let a=ir({...r,processors:t});return ve(e,a),or(a,e),sr(a,e)},ai=(e,t,r={})=>a=>{let{libraryOptions:n,target:i}=a??{},o=ir({...n??{},target:i,io:t,processors:r});return ve(e,o),or(o,e),sr(o,e)};var ii=(e,t,r)=>{(e[t]===void 0||r>e[t])&&(e[t]=r)},oi=(e,t,r)=>{(e[t]===void 0||r<e[t])&&(e[t]=r)},eE=(e,t)=>{ii(e,"minimum",t),oi(e,"maximum",t)},aE=(e,t)=>{e.multipleOf??(e.multipleOf=[]),e.multipleOf.includes(t)||e.multipleOf.push(t)},iE=(e,t)=>{e.patterns??(e.patterns=new Set),e.patterns.add(t)},oE=(e,t)=>{e.mime=e.mime?e.mime.filter(r=>t.includes(r)):[...t]},sE=(e,t)=>{e.format=t,t.includes("int")&&(e.isInt=!0)},tE=(e,t)=>ii(e,"minimum",t.minimum),nE=(e,t)=>oi(e,"maximum",t.maximum),rE=e=>(t,r)=>{sE(t,r.format);let[a,n]=e[r.format];ii(t,"minimum",a),oi(t,"maximum",n)},u0={greater_than:(e,t)=>ii(e,t.inclusive?"minimum":"exclusiveMinimum",t.value),less_than:(e,t)=>oi(e,t.inclusive?"maximum":"exclusiveMaximum",t.value),multiple_of:(e,t)=>aE(e,t.value),number_format:rE(bo),bigint_format:rE(vo),min_length:tE,max_length:nE,length_equals:(e,t)=>eE(e,t.length),min_size:tE,max_size:nE,size_equals:(e,t)=>eE(e,t.size),string_format:(e,t)=>{sE(e,t.format),t.pattern&&iE(e,t.pattern),(t.format==="base64"||t.format==="base64url")&&(e.contentEncoding=t.format),(t.local||t.precision===-1)&&(e.laxFormat=!0)},mime_type:(e,t)=>oE(e,t.mime)};function Ue(e){let t={},r=e._zod.def,a=e._zod.traits.has("$ZodCheck")?[e,...r.checks??[]]:r.checks??[];for(let i of a)u0[i._zod.def.check]?.(t,i._zod.def);let n=e._zod.bag;n.minimum!==void 0&&ii(t,"minimum",n.minimum),n.exclusiveMinimum!==void 0&&ii(t,"exclusiveMinimum",n.exclusiveMinimum),n.maximum!==void 0&&oi(t,"maximum",n.maximum),n.exclusiveMaximum!==void 0&&oi(t,"exclusiveMaximum",n.exclusiveMaximum),n.multipleOf!==void 0&&aE(t,n.multipleOf),n.format!==void 0&&(t.format??(t.format=n.format),n.format.includes("int")&&(t.isInt=!0)),n.mime&&oE(t,n.mime);for(let i of n.patterns??[])iE(t,i);return t}var d0={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},p0=new Map([[jc,Bg],[$o,Ug]]),lE=e=>p0.get(e)??e,af=(e,t,r,a)=>{let n=r;n.type="string";let{minimum:i,maximum:o,format:s,patterns:l,contentEncoding:c,laxFormat:u}=Ue(e);if(typeof i=="number"&&(n.minLength=i),typeof o=="number"&&(n.maxLength=o),s&&(n.format=d0[s]??s,n.format===""&&delete n.format,(s==="time"||u)&&delete n.format),c&&(n.contentEncoding=c),l&&l.size>0){let d=[...l].map(lE);d.length===1?n.pattern=d[0].source:d.length>1&&(n.allOf=[...d.map(m=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:m.source}))])}},of=(e,t,r,a)=>{let n=r,{minimum:i,maximum:o,multipleOf:s,exclusiveMaximum:l,exclusiveMinimum:c,isInt:u}=Ue(e);n.type=u?"integer":"number";let d=typeof c=="number"&&c>=(i??Number.NEGATIVE_INFINITY),m=typeof l=="number"&&l<=(o??Number.POSITIVE_INFINITY),p=t.target==="draft-04"||t.target==="openapi-3.0";if(d?p?(n.minimum=c,n.exclusiveMinimum=!0):n.exclusiveMinimum=c:typeof i=="number"&&(n.minimum=i),m?p?(n.maximum=l,n.exclusiveMaximum=!0):n.exclusiveMaximum=l:typeof o=="number"&&(n.maximum=o),s){let g=new Set;for(let _ of s)Number.isFinite(_)&&_!==0?g.add(Math.abs(_)):Be(e,t,n,a,`A multipleOf divisor of ${_} cannot be represented in JSON Schema`);let[h,...f]=g;h!==void 0&&(n.multipleOf=h),f.length&&(n.allOf=[...n.allOf??[],...f.map(_=>({multipleOf:_}))])}},sf=(e,t,r,a)=>{r.type="boolean"},lf=(e,t,r,a)=>{Be(e,t,r,a,"BigInt cannot be represented in JSON Schema")},cf=(e,t,r,a)=>{Be(e,t,r,a,"Symbols cannot be represented in JSON Schema")},uf=(e,t,r,a)=>{t.target==="openapi-3.0"?(r.type="string",r.nullable=!0,r.enum=[null]):r.type="null"},df=(e,t,r,a)=>{Be(e,t,r,a,"Undefined cannot be represented in JSON Schema")},pf=(e,t,r,a)=>{Be(e,t,r,a,"Void cannot be represented in JSON Schema")},mf=(e,t,r,a)=>{r.not={}},gf=(e,t,r,a)=>{},hf=(e,t,r,a)=>{},ff=(e,t,r,a)=>{Be(e,t,r,a,"Date cannot be represented in JSON Schema")},bf=(e,t,r,a)=>{let n=e._zod.def,i=ya(n.entries);if(i.length===0){r.not={};return}i.every(o=>typeof o=="number")&&(r.type="number"),i.every(o=>typeof o=="string")&&(r.type="string"),r.enum=i},vf=(e,t,r,a)=>{let n=e._zod.def;if(n.values.length===0){r.not={};return}let i=[];for(let o of n.values)if(o===void 0){if(Be(e,t,r,a,"Literal `undefined` cannot be represented in JSON Schema"))return}else if(typeof o=="bigint"){if(Be(e,t,r,a,"BigInt literals cannot be represented in JSON Schema"))return;i.push(Number(o))}else i.push(o);if(i.length!==0)if(i.length===1){let o=i[0];r.type=o===null?"null":typeof o,t.target==="draft-04"||t.target==="openapi-3.0"?r.enum=[o]:r.const=o}else i.every(o=>typeof o=="number")&&(r.type="number"),i.every(o=>typeof o=="string")&&(r.type="string"),i.every(o=>typeof o=="boolean")&&(r.type="boolean"),i.every(o=>o===null)&&(r.type="null"),r.enum=i},yf=(e,t,r,a)=>{Be(e,t,r,a,"NaN cannot be represented in JSON Schema")},kf=(e,t,r,a)=>{let n=r,i=e._zod.pattern;if(!i)throw new Error("Pattern not found in template literal");n.type="string",n.pattern=i.source},_f=(e,t,r,a)=>{let n=r;n.type="string",n.format="binary",n.contentEncoding="binary";let{minimum:i,maximum:o,mime:s}=Ue(e);i!==void 0&&(n.minLength=i),o!==void 0&&(n.maxLength=o),s&&(s.length===0?n.not={}:s.length===1?n.contentMediaType=s[0]:n.anyOf=s.map(l=>({contentMediaType:l})))},wf=(e,t,r,a)=>{r.type="boolean"},Sf=(e,t,r,a)=>{Be(e,t,r,a,"Custom types cannot be represented in JSON Schema")},Ef=(e,t,r,a)=>{Be(e,t,r,a,"Function types cannot be represented in JSON Schema")},xf=(e,t,r,a)=>{Be(e,t,r,a,"Transforms cannot be represented in JSON Schema")},Tf=(e,t,r,a)=>{Be(e,t,r,a,"Map cannot be represented in JSON Schema")},Af=(e,t,r,a)=>{Be(e,t,r,a,"Set cannot be represented in JSON Schema")},Cf=(e,t,r,a)=>{let n=r,i=e._zod.def,{minimum:o,maximum:s}=Ue(e);typeof o=="number"&&(n.minItems=o),typeof s=="number"&&(n.maxItems=s),n.type="array",n.items=ve(i.element,t,{...a,path:[...a.path,"items"]})};function hs(e){let t=e._zod.def;return t.type==="pipe"&&t.in._zod.traits.has("$ZodTransform")?hs(t.out):t.type==="catch"?hs(t.innerType):e._zod.optin}var zf=(e,t,r,a)=>{let n=r,i=e._zod.def,o=i.shape;if(Object.getOwnPropertySymbols(o).length&&Be(e,t,n,a,"Symbol keys cannot be represented in JSON Schema"))return;n.type="object",n.properties={};for(let c in o)Ge(n.properties,c,ve(o[c],t,{...a,path:[...a.path,"properties",c]}));let l=[];for(let c of Object.keys(o)){let u=i.shape[c];(t.io==="input"?hs(u)===void 0:u._zod.optout===void 0)&&l.push(c)}l.length>0&&(n.required=l),i.catchall?._zod.def.type==="never"?n.additionalProperties=!1:i.catchall?i.catchall&&(n.additionalProperties=ve(i.catchall,t,{...a,path:[...a.path,"additionalProperties"]})):t.io==="output"&&(n.additionalProperties=!1)},Sd=(e,t,r,a)=>{let n=e._zod.def,i=n.inclusive===!1,o=n.options.map((s,l)=>ve(s,t,{...a,path:[...a.path,i?"oneOf":"anyOf",l]}));i?r.oneOf=o:r.anyOf=o},If=(e,t,r,a)=>{let n=e._zod.def,i=ve(n.left,t,{...a,path:[...a.path,"allOf",0]}),o=ve(n.right,t,{...a,path:[...a.path,"allOf",1]}),s=c=>"allOf"in c&&Object.keys(c).length===1,l=[...s(i)?i.allOf:[i],...s(o)?o.allOf:[o]];r.allOf=l,t.intersections.push(l)},Pf=(e,t,r,a)=>{let n=r,i=e._zod.def;n.type="array";let o=t.target==="draft-2020-12"?"prefixItems":"items",s=t.target==="draft-2020-12"||t.target==="openapi-3.0"?"items":"additionalItems",l=i.items.map((h,f)=>ve(h,t,{...a,path:[...a.path,o,f]})),c=i.rest?ve(i.rest,t,{...a,path:[...a.path,s,...t.target==="openapi-3.0"?[i.items.length]:[]]}):null,u=i.items.length;for(;u>0;){let h=i.items[u-1];if(!(t.io==="input"?hs(h)!==void 0:h._zod.optout==="optional"))break;u--}let d=i.items.length,m=!i.rest;t.target==="draft-2020-12"?(n.prefixItems=l,m?n.items=!1:c&&(n.items=c),u>0&&(n.minItems=u),m&&(n.maxItems=d)):t.target==="openapi-3.0"?(n.items={anyOf:l},c&&n.items.anyOf.push(c),u>0&&(n.minItems=u),m&&(n.maxItems=d)):(n.items=l,m?n.additionalItems=!1:c&&(n.additionalItems=c),u>0&&(n.minItems=u),m&&(n.maxItems=d));let{minimum:p,maximum:g}=Ue(e);typeof p=="number"&&(n.minItems=p),typeof g=="number"&&(n.maxItems=g)};function nf(e,t,r){if(t.$ref){if(r.has(t))return t;r.add(t);let g=e.get(t)?.def;if(!g)return t;let h=nf(e,g,r);return h===g?t:h}for(let g of["anyOf","oneOf"]){let h=t[g];if(!Array.isArray(h))continue;let f=h.map(_=>nf(e,_,r));f.some((_,b)=>_!==h[b])&&(t={...t,[g]:f})}let a=Array.isArray(t.type)?t.type:[t.type],n=!a.includes("string")&&a.some(g=>g==="number"||g==="integer"),i=t.enum??(t.const!==void 0?[t.const]:void 0);if(!n&&!i?.some(g=>typeof g=="number"))return t;let{minimum:o,maximum:s,exclusiveMinimum:l,exclusiveMaximum:c,multipleOf:u,format:d,id:m,...p}=t;return p.enum?p.enum=p.enum.map(g=>typeof g=="number"?String(g):g):typeof p.const=="number"&&(p.const=String(p.const)),n&&(p.type="string",i||(p.pattern=(a.includes("number")?An:To).source)),p}var rf=new WeakMap;function m0(e){let t=new Map;for(let a of e.seen.values())a.def&&!t.has(a.schema)&&t.set(a.schema,a);let r=new Map;for(let a of rf.get(e)??[]){let n=e.seen.get(a),i=(n?.def??n?.schema)?.propertyNames;if(!i||i===!0||r.has(i))continue;let o=nf(t,i,new Set);o!==i&&r.set(i,o)}if(r.size)for(let a of e.seen.values())for(let n of[a.schema,a.def]){let i=n&&r.get(n.propertyNames);i&&(n.propertyNames=i)}}var Rf=(e,t,r,a)=>{let n=r,i=e._zod.def;n.type="object";let o=i.keyType,s=Ue(o).patterns;if(i.mode==="loose"&&s&&s.size>0){let u=ve(i.valueType,t,{...a,path:[...a.path,"patternProperties","*"]});n.patternProperties={};for(let d of s)Ge(n.patternProperties,lE(d).source,u)}else{if(t.target==="draft-07"||t.target==="draft-2020-12"){n.propertyNames=ve(i.keyType,t,{...a,path:[...a.path,"propertyNames"]});let u=rf.get(t);u||(u=[],rf.set(t,u),t.deferred.push(()=>m0(t))),u.push(e)}n.additionalProperties=ve(i.valueType,t,{...a,path:[...a.path,"additionalProperties"]})}let l=o._zod.values,c=t.io==="input"&&hs(i.valueType)!==void 0;if(l&&!i.partial&&!c){let u=[...l].filter(d=>typeof d=="string"||typeof d=="number");u.length>0&&(n.required=u.map(String))}},$f=(e,t,r,a)=>{let n=e._zod.def,i=ve(n.innerType,t,a),o=t.seen.get(e);t.target==="openapi-3.0"?(o.ref=n.innerType,r.nullable=!0):r.anyOf=[i,{type:"null"}]},jf=(e,t,r,a)=>{let n=e._zod.def;ve(n.innerType,t,a);let i=t.seen.get(e);i.ref=n.innerType},Of=Symbol();function cE(e,t,r,a,n){let i=!1,o=JSON.stringify(e,(s,l)=>typeof l!="bigint"?l:(i=!0,null));return i?(Be(t,r,a,n,"BigInt defaults cannot be represented in JSON Schema"),Of):JSON.parse(o)}var Nf=(e,t,r,a)=>{let n=e._zod.def;ve(n.innerType,t,a);let i=t.seen.get(e);i.ref=n.innerType;let o=cE(n.defaultValue,e,t,r,a);o!==Of&&(r.default=o)},Df=(e,t,r,a)=>{let n=e._zod.def;ve(n.innerType,t,a);let i=t.seen.get(e);if(i.ref=n.innerType,t.io!=="input")return;let o=cE(n.defaultValue,e,t,r,a);o!==Of&&(r._prefault=o)},Mf=(e,t,r,a)=>{let n=e._zod.def;ve(n.innerType,t,a);let i=t.seen.get(e);i.ref=n.innerType;let o;try{o=n.catchValue(void 0)}catch{Be(e,t,r,a,"Dynamic catch values are not supported in JSON Schema");return}r.default=o},Lf=(e,t,r,a)=>{let n=e._zod.def,i=n.in._zod.traits.has("$ZodTransform"),o=t.io==="input"?i?n.out:n.in:n.out;ve(o,t,a);let s=t.seen.get(e);s.ref=o},Bf=(e,t,r,a)=>{let n=e._zod.def;ve(n.innerType,t,a);let i=t.seen.get(e);i.ref=n.innerType,r.readOnly=!0},Uf=(e,t,r,a)=>{let n=e._zod.def;ve(n.innerType,t,a);let i=t.seen.get(e);i.ref=n.innerType},Ed=(e,t,r,a)=>{let n=e._zod.def;ve(n.innerType,t,a);let i=t.seen.get(e);i.ref=n.innerType},Ff=(e,t,r,a)=>{let n=e._zod.innerType;ve(n,t,a);let i=t.seen.get(e);i.ref=n},wd={string:af,number:of,boolean:sf,bigint:lf,symbol:cf,null:uf,undefined:df,void:pf,never:mf,any:gf,unknown:hf,date:ff,enum:bf,literal:vf,nan:yf,template_literal:kf,file:_f,success:wf,custom:Sf,function:Ef,transform:xf,map:Tf,set:Af,array:Cf,object:zf,union:Sd,intersection:If,tuple:Pf,record:Rf,nullable:$f,nonoptional:jf,default:Nf,prefault:Df,catch:Mf,pipe:Lf,readonly:Bf,promise:Uf,optional:Ed,lazy:Ff};function Hr(e,t){if("_idmap"in e){let a=e,n=ir({...t,processors:wd}),i={};for(let l of a._idmap.entries()){let[c,u]=l;ve(u,n)}let o={},s={registry:a,uri:t?.uri,defs:i};n.external=s;for(let l of a._idmap.entries()){let[c,u]=l;or(n,u),Ge(o,c,sr(n,u))}if(Object.keys(i).length>0){let l=n.target==="draft-2020-12"?"$defs":"definitions";o.__shared={[l]:i}}return{schemas:o}}let r=ir({...t,processors:wd});return ve(e,r),or(r,e),sr(r,e)}var xd=class{get metadataRegistry(){return this.ctx.metadataRegistry}get target(){return this.ctx.target}get unrepresentable(){return this.ctx.unrepresentable}get override(){return this.ctx.override}get io(){return this.ctx.io}get counter(){return this.ctx.counter}set counter(t){this.ctx.counter=t}get seen(){return this.ctx.seen}constructor(t){let r=t?.target??"draft-2020-12";r==="draft-4"&&(r="draft-04"),r==="draft-7"&&(r="draft-07"),this.ctx=ir({processors:wd,target:r,...t?.metadata&&{metadata:t.metadata},...t?.unrepresentable&&{unrepresentable:t.unrepresentable},...t?.override&&{override:t.override},...t?.io&&{io:t.io}})}process(t,r={path:[],schemaPath:[]}){return ve(t,this.ctx,r)}emit(t,r){r&&(r.cycles&&(this.ctx.cycles=r.cycles),r.reused&&(this.ctx.reused=r.reused),r.external&&(this.ctx.external=r.external)),this.ctx.sharedDefsExtractedFor=void 0,this.ctx.sharedEmitDoneFor=void 0,or(this.ctx,t);let a=sr(this.ctx,t),{"~standard":n,...i}=a;return i}};var uE={};var gi={};En(gi,{ZodAny:()=>sb,ZodArray:()=>db,ZodBase64:()=>Hd,ZodBase64URL:()=>Gd,ZodBigInt:()=>pi,ZodBigIntFormat:()=>Kd,ZodBoolean:()=>di,ZodCIDRv4:()=>Fd,ZodCIDRv6:()=>qd,ZodCUID:()=>Od,ZodCUID2:()=>Nd,ZodCatch:()=>Ib,ZodCodec:()=>Es,ZodCreditCard:()=>nb,ZodCustom:()=>xs,ZodCustomStringFormat:()=>Vr,ZodDate:()=>ys,ZodDefault:()=>Eb,ZodDiscriminatedUnion:()=>mb,ZodE164:()=>Vd,ZodEmail:()=>Pd,ZodEmoji:()=>$d,ZodEnum:()=>li,ZodExactOptional:()=>Yd,ZodFile:()=>kb,ZodFunction:()=>Bb,ZodGUID:()=>Rd,ZodIBAN:()=>rb,ZodIPv4:()=>Bd,ZodIPv6:()=>Ud,ZodISODate:()=>cr,ZodISODateTime:()=>lr,ZodISODuration:()=>dr,ZodISOTime:()=>ur,ZodInstanceOf:()=>qb,ZodIntersection:()=>gb,ZodJWT:()=>Wd,ZodKSUID:()=>Ld,ZodLazy:()=>Db,ZodLiteral:()=>yb,ZodMAC:()=>tb,ZodMap:()=>bb,ZodNaN:()=>Rb,ZodNanoID:()=>jd,ZodNever:()=>cb,ZodNonOptional:()=>Xd,ZodNull:()=>ob,ZodNullable:()=>Sb,ZodNumber:()=>ui,ZodNumberFormat:()=>Wr,ZodObject:()=>ks,ZodOptional:()=>Kr,ZodPipe:()=>Ss,ZodPrefault:()=>Tb,ZodPreprocess:()=>$b,ZodPromise:()=>Lb,ZodReadonly:()=>jb,ZodRecord:()=>si,ZodSet:()=>vb,ZodString:()=>ci,ZodStringFormat:()=>Se,ZodSuccess:()=>zb,ZodSymbol:()=>ab,ZodTemplateLiteral:()=>Nb,ZodTransform:()=>_b,ZodTuple:()=>hb,ZodType:()=>Y,ZodULID:()=>Dd,ZodURL:()=>bs,ZodUUID:()=>dn,ZodUndefined:()=>ib,ZodUnion:()=>_s,ZodUnknown:()=>lb,ZodVoid:()=>ub,ZodXID:()=>Md,ZodXor:()=>pb,_ZodString:()=>Id,_default:()=>xb,_function:()=>vx,any:()=>QE,array:()=>ae,base64:()=>$E,base64url:()=>jE,bigint:()=>KE,boolean:()=>De,catch:()=>Pb,check:()=>yx,cidrv4:()=>PE,cidrv6:()=>RE,codec:()=>gx,creditCard:()=>NE,cuid:()=>SE,cuid2:()=>EE,currencyCode:()=>FE,custom:()=>Qd,date:()=>tx,describe:()=>kx,discriminatedUnion:()=>ws,e164:()=>OE,email:()=>mE,emoji:()=>_E,enum:()=>Ke,exactOptional:()=>wb,file:()=>ux,float32:()=>HE,float64:()=>GE,function:()=>vx,guid:()=>gE,hash:()=>qE,hex:()=>UE,hostname:()=>BE,httpUrl:()=>kE,iban:()=>DE,instanceof:()=>wx,int:()=>Cd,int32:()=>VE,int64:()=>ZE,intersection:()=>mi,invertCodec:()=>hx,ipv4:()=>CE,ipv6:()=>IE,json:()=>Ex,jwt:()=>ME,keyof:()=>nx,ksuid:()=>AE,lazy:()=>Mb,literal:()=>B,looseObject:()=>We,looseRecord:()=>ox,mac:()=>zE,map:()=>sx,meta:()=>_x,nan:()=>mx,nanoid:()=>wE,nativeEnum:()=>cx,never:()=>Zd,nonoptional:()=>Cb,null:()=>vs,nullable:()=>fs,nullish:()=>dx,number:()=>he,object:()=>O,optional:()=>we,partialRecord:()=>ix,pipe:()=>zd,prefault:()=>Ab,preprocess:()=>Ts,promise:()=>bx,readonly:()=>Ob,record:()=>Ee,refine:()=>Ub,set:()=>lx,strictObject:()=>rx,string:()=>w,stringFormat:()=>LE,stringbool:()=>Sx,success:()=>px,superRefine:()=>Fb,symbol:()=>YE,templateLiteral:()=>fx,transform:()=>Jd,tuple:()=>fb,uint32:()=>WE,uint64:()=>JE,ulid:()=>xE,undefined:()=>XE,union:()=>ye,unknown:()=>xe,url:()=>yE,uuid:()=>hE,uuidv4:()=>fE,uuidv6:()=>bE,uuidv7:()=>vE,void:()=>ex,xid:()=>TE,xor:()=>ax});var Td={};En(Td,{endsWith:()=>Ja,gt:()=>cn,gte:()=>It,includes:()=>Ka,length:()=>qr,lowercase:()=>Va,lt:()=>ln,lte:()=>zt,maxLength:()=>Fr,maxSize:()=>rr,mime:()=>Xa,minLength:()=>Cn,minSize:()=>un,multipleOf:()=>nr,negative:()=>dd,nonnegative:()=>md,nonpositive:()=>pd,normalize:()=>Qa,overwrite:()=>Wt,positive:()=>ud,properties:()=>Ya,property:()=>gd,regex:()=>Ga,size:()=>Ur,slugify:()=>ri,startsWith:()=>Za,toLowerCase:()=>ti,toUpperCase:()=>ni,trim:()=>ei,uppercase:()=>Wa});var dE=new WeakSet([Object.prototype,Error.prototype]);function Ad(e,t,r){Object.defineProperty(e,t,{configurable:!0,enumerable:!1,get(){let a=r(this);return Object.defineProperty(this,t,{value:a,configurable:!0,writable:!0}),a},set(a){Object.defineProperty(this,t,{value:a,configurable:!0,writable:!0})}})}var pE=(e,t)=>{kg.init(e,t),e.name="ZodError";let r=Object.getPrototypeOf(e);dE.has(r)||(dE.add(r),Ad(r,"format",a=>n=>Eo(a,n)),Ad(r,"flatten",a=>n=>So(a,n)),Ad(r,"addIssue",a=>n=>{a.issues.push(n),a.message=JSON.stringify(a.issues,ka,2)}),Ad(r,"addIssues",a=>n=>{a.issues.push(...n),a.message=JSON.stringify(a.issues,ka,2)}),Object.defineProperty(r,"isEmpty",{configurable:!0,enumerable:!1,get(){return this.issues.length===0}}))},h0=y("ZodError",pE),wt=y("ZodError",pE,void 0,{Parent:Error});var qf=Ta(wt),Hf=Aa(wt),Gf=Ca(wt),Vf=Ia(wt),Wf=Zl(wt),Kf=Jl(wt),Zf=Yl(wt),Jf=Xl(wt),Yf=Ql(wt),Xf=ec(wt),Qf=tc(wt),eb=nc(wt);function b0(){He.localeError||Oe($u())}function Gr(){He.memoizer||Oe({memoizer:Uo()})}var Y=y("ZodType",(e,t)=>(b0(),Z.init(e,t),e.def=t,e.type=t.type,e),{check(...e){let t=this.def;return this.clone(E.mergeDefs(t,{checks:[...t.checks??[],...e.map(r=>typeof r=="function"?{_zod:{check:r,def:{check:"custom"},onattach:[]}}:r)]}),{parent:!0})},with(...e){return this.check(...e)},clone(e,t){return ge(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(Ub(e,t))},superRefine(e,t){return this.check(Fb(e,t))},overwrite(e){return this.check(Wt(e))},optional(){return we(this)},exactOptional(){return wb(this)},nullable(){return fs(this)},nullish(){return we(fs(this))},nonoptional(e){return Cb(this,e)},array(){return ae(this)},or(e){return ye([this,e])},and(e){return mi(this,e)},transform(e){return zd(this,Jd(e))},default(e){return xb(this,e)},prefault(e){return Ab(this,e)},catch(e){return Pb(this,e)},pipe(e){return zd(this,e)},readonly(){return Ob(this)},describe(e){let t=this.clone();return Ve.add(t,{description:e}),t},meta(...e){if(e.length===0)return Ve.get(this);let t=this.clone();return Ve.add(t,e[0]),t},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(e,...t){return t.length===0?e(this):e(this,...t)},get"~standard"(){return E.hide(this,"~standard",{...mc(this),jsonSchema:{input:ai(this,"input"),output:ai(this,"output")}})},set"~standard"(e){E.own(this,"~standard",e)},parse:function e(t,r){return qf(this,t,r,{callee:e})},parseAsync:async function e(t,r){return await Hf(this,t,r,{callee:e})},safeParse(e,t){return Gf(this,e,t)},async safeParseAsync(e,t){return Vf(this,e,t)},get spa(){return this?.safeParseAsync},set spa(e){E.own(this,"spa",e)},validate(e,t){return Ra(this,e,t)},validateAsync(e,t){return $a(this,e,t)},encode:function e(t,r){return Wf(this,t,r,{callee:e})},decode:function e(t,r){return Kf(this,t,r,{callee:e})},encodeAsync:async function e(t,r){return await Zf(this,t,r,{callee:e})},decodeAsync:async function e(t,r){return await Jf(this,t,r,{callee:e})},safeEncode(e,t){return Yf(this,e,t)},safeDecode(e,t){return Xf(this,e,t)},async safeEncodeAsync(e,t){return Qf(this,e,t)},async safeDecodeAsync(e,t){return eb(this,e,t)},toJSONSchema(e){return tf(this,{})(e)},get description(){return Ve.get(this)?.description},get _def(){return this._zod.def}}),Id=y("_ZodString",(e,t)=>{er.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(r,a,n)=>af(e,r,a,n)},E.derived({format:e=>Ue(e).format??null,minLength:e=>Ue(e).minimum??null,maxLength:e=>Ue(e).maximum??null},{regex(...e){return this.check(Ga(...e))},includes(...e){return this.check(Ka(...e))},startsWith(...e){return this.check(Za(...e))},endsWith(...e){return this.check(Ja(...e))},min(...e){return this.check(Cn(...e))},max(...e){return this.check(Fr(...e))},length(...e){return this.check(qr(...e))},nonempty(...e){return this.check(Cn(1,...e))},lowercase(e){return this.check(Va(e))},uppercase(e){return this.check(Wa(e))},trim(){return this.check(ei())},normalize(...e){return this.check(Qa(...e))},toLowerCase(){return this.check(ti())},toUpperCase(){return this.check(ni())},slugify(){return this.check(ri())}})),ci=y("ZodString",(e,t)=>{er.init(e,t),Id.init(e,t)},{email(e){return this.check(qo(Pd,e))},url(e){return this.check(Ha(bs,e))},jwt(e){return this.check(cs(Wd,e))},emoji(e){return this.check(Zo($d,e))},guid(e){return this.check(Ho(Rd,e))},uuid(e){return this.check(Go(dn,e))},uuidv4(e){return this.check(Vo(dn,e))},uuidv6(e){return this.check(Wo(dn,e))},uuidv7(e){return this.check(Ko(dn,e))},nanoid(e){return this.check(Jo(jd,e))},cuid(e){return this.check(Yo(Od,e))},cuid2(e){return this.check(Xo(Nd,e))},ulid(e){return this.check(Qo(Dd,e))},base64(e){return this.check(os(Hd,e))},base64url(e){return this.check(ss(Gd,e))},xid(e){return this.check(es(Md,e))},ksuid(e){return this.check(ts(Ld,e))},ipv4(e){return this.check(ns(Bd,e))},ipv6(e){return this.check(rs(Ud,e))},cidrv4(e){return this.check(as(Fd,e))},cidrv6(e){return this.check(is(qd,e))},e164(e){return this.check(ls(Vd,e))},datetime(e){return this.check(us(lr,e))},date(e){return this.check(ds(cr,e))},time(e){return this.check(ps(ur,e))},duration(e){return this.check(ms(dr,e))}});function w(e){return Uu(ci,e)}var Se=y("ZodStringFormat",(e,t)=>{be.init(e,t),Id.init(e,t)}),lr=y("ZodISODateTime",(e,t)=>{zh.init(e,t),Se.init(e,t)}),cr=y("ZodISODate",(e,t)=>{Ih.init(e,t),Se.init(e,t)}),ur=y("ZodISOTime",(e,t)=>{Ph.init(e,t),Se.init(e,t)}),dr=y("ZodISODuration",(e,t)=>{Rh.init(e,t),Se.init(e,t)}),Pd=y("ZodEmail",(e,t)=>{fc.init(e,t),Se.init(e,t)});function mE(e){return qo(Pd,e)}var Rd=y("ZodGUID",(e,t)=>{gc.init(e,t),Se.init(e,t)});function gE(e){return Ho(Rd,e)}var dn=y("ZodUUID",(e,t)=>{hc.init(e,t),Se.init(e,t)});function hE(e){return Go(dn,e)}function fE(e){return Vo(dn,e)}function bE(e){return Wo(dn,e)}function vE(e){return Ko(dn,e)}var bs=y("ZodURL",(e,t)=>{kc.init(e,t),Se.init(e,t)});function yE(e){return Ha(bs,e)}function kE(e){return Ha(bs,{protocol:xo,hostname:qg,...E.normalizeParams(e)})}var $d=y("ZodEmoji",(e,t)=>{_c.init(e,t),Se.init(e,t)});function _E(e){return Zo($d,e)}var jd=y("ZodNanoID",(e,t)=>{wc.init(e,t),Se.init(e,t)});function wE(e){return Jo(jd,e)}var Od=y("ZodCUID",(e,t)=>{Sc.init(e,t),Se.init(e,t)});function SE(e){return Yo(Od,e)}var Nd=y("ZodCUID2",(e,t)=>{Ec.init(e,t),Se.init(e,t)});function EE(e){return Xo(Nd,e)}var Dd=y("ZodULID",(e,t)=>{xc.init(e,t),Se.init(e,t)});function xE(e){return Qo(Dd,e)}var Md=y("ZodXID",(e,t)=>{Tc.init(e,t),Se.init(e,t)});function TE(e){return es(Md,e)}var Ld=y("ZodKSUID",(e,t)=>{Ac.init(e,t),Se.init(e,t)});function AE(e){return ts(Ld,e)}var Bd=y("ZodIPv4",(e,t)=>{Cc.init(e,t),Se.init(e,t)});function CE(e){return ns(Bd,e)}var tb=y("ZodMAC",(e,t)=>{Ic.init(e,t),Se.init(e,t)});function zE(e){return Fu(tb,e)}var Ud=y("ZodIPv6",(e,t)=>{zc.init(e,t),Se.init(e,t)});function IE(e){return rs(Ud,e)}var Fd=y("ZodCIDRv4",(e,t)=>{Pc.init(e,t),Se.init(e,t)});function PE(e){return as(Fd,e)}var qd=y("ZodCIDRv6",(e,t)=>{$c.init(e,t),Se.init(e,t)});function RE(e){return is(qd,e)}var Hd=y("ZodBase64",(e,t)=>{Oc.init(e,t),Se.init(e,t)});function $E(e){return os(Hd,e)}var Gd=y("ZodBase64URL",(e,t)=>{Dc.init(e,t),Se.init(e,t)});function jE(e){return ss(Gd,e)}var Vd=y("ZodE164",(e,t)=>{Mc.init(e,t),Se.init(e,t)});function OE(e){return ls(Vd,e)}var nb=y("ZodCreditCard",(e,t)=>{Bc.init(e,t),Se.init(e,t)});function NE(e){return qu(nb,e)}var rb=y("ZodIBAN",(e,t)=>{Fc.init(e,t),Se.init(e,t)});function DE(e){return Hu(rb,e)}var Wd=y("ZodJWT",(e,t)=>{Hc.init(e,t),Se.init(e,t)});function ME(e){return cs(Wd,e)}var Vr=y("ZodCustomStringFormat",(e,t)=>{Gc.init(e,t),Se.init(e,t)});function LE(e,t,r={}){return ar(Vr,e,t,r)}function BE(e){return ar(Vr,"hostname",Fg,e)}function UE(e){return ar(Vr,"hex",rh,e)}function FE(e){return ar(Vr,"currency_code",Gg,e)}function qE(e,t){let r=t?.enc??"hex",a=`${e}_${r}`,n=Ct[a];if(!n)throw new Error(`Unrecognized hash format: ${a}`);return ar(Vr,a,n,t)}var ui=y("ZodNumber",(e,t)=>{jo.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(r,a,n)=>of(e,r,a,n),e.isFinite=!0},E.derived({minValue:e=>{let{minimum:t,exclusiveMinimum:r}=Ue(e);return Math.max(t??Number.NEGATIVE_INFINITY,r??Number.NEGATIVE_INFINITY)},maxValue:e=>{let{maximum:t,exclusiveMaximum:r}=Ue(e);return Math.min(t??Number.POSITIVE_INFINITY,r??Number.POSITIVE_INFINITY)},isInt:e=>{let{isInt:t,multipleOf:r}=Ue(e);return!!t||!!r?.some(Number.isSafeInteger)},format:e=>Ue(e).format??null},{gt(e,t){return this.check(cn(e,t))},gte(e,t){return this.check(It(e,t))},min(e,t){return this.check(It(e,t))},lt(e,t){return this.check(ln(e,t))},lte(e,t){return this.check(zt(e,t))},max(e,t){return this.check(zt(e,t))},int(e){return this.check(Cd(e))},safe(e){return this.check(Cd(e))},positive(e){return this.check(cn(0,e))},nonnegative(e){return this.check(It(0,e))},negative(e){return this.check(ln(0,e))},nonpositive(e){return this.check(zt(0,e))},multipleOf(e,t){return this.check(nr(e,t))},step(e,t){return this.check(nr(e,t))},finite(){return this}}));function he(e){return Gu(ui,e)}var Wr=y("ZodNumberFormat",(e,t)=>{Vc.init(e,t),ui.init(e,t)});function Cd(e){return Vu(Wr,e)}function HE(e){return Wu(Wr,e)}function GE(e){return Ku(Wr,e)}function VE(e){return Zu(Wr,e)}function WE(e){return Ju(Wr,e)}var di=y("ZodBoolean",(e,t)=>{Na.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(r,a,n)=>sf(e,r,a,n)});function De(e){return Yu(di,e)}var pi=y("ZodBigInt",(e,t)=>{Oo.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(r,a,n)=>lf(e,r,a,n)},E.derived({minValue:e=>Ue(e).minimum??null,maxValue:e=>Ue(e).maximum??null,format:e=>Ue(e).format??null},{gte(e,t){return this.check(It(e,t))},min(e,t){return this.check(It(e,t))},gt(e,t){return this.check(cn(e,t))},lt(e,t){return this.check(ln(e,t))},lte(e,t){return this.check(zt(e,t))},max(e,t){return this.check(zt(e,t))},positive(e){return this.check(cn(BigInt(0),e))},negative(e){return this.check(ln(BigInt(0),e))},nonpositive(e){return this.check(zt(BigInt(0),e))},nonnegative(e){return this.check(It(BigInt(0),e))},multipleOf(e,t){return this.check(nr(e,t))}}));function KE(e){return Xu(pi,e)}var Kd=y("ZodBigIntFormat",(e,t)=>{Wc.init(e,t),pi.init(e,t)});function ZE(e){return Qu(Kd,e)}function JE(e){return ed(Kd,e)}var ab=y("ZodSymbol",(e,t)=>{Kc.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(r,a,n)=>cf(e,r,a,n)});function YE(e){return td(ab,e)}var ib=y("ZodUndefined",(e,t)=>{Zc.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(r,a,n)=>df(e,r,a,n)});function XE(e){return nd(ib,e)}var ob=y("ZodNull",(e,t)=>{Jc.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(r,a,n)=>uf(e,r,a,n)});function vs(e){return rd(ob,e)}var sb=y("ZodAny",(e,t)=>{Yc.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(r,a,n)=>gf(e,r,a,n)});function QE(){return ad(sb)}var lb=y("ZodUnknown",(e,t)=>{Xc.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(r,a,n)=>hf(e,r,a,n)});function xe(){return id(lb)}var cb=y("ZodNever",(e,t)=>{Qc.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(r,a,n)=>mf(e,r,a,n)});function Zd(e){return od(cb,e)}var ub=y("ZodVoid",(e,t)=>{eu.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(r,a,n)=>pf(e,r,a,n)});function ex(e){return sd(ub,e)}var ys=y("ZodDate",(e,t)=>{tu.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(r,a,n)=>ff(e,r,a,n),e.min=(r,a)=>e.check(It(r,a)),e.max=(r,a)=>e.check(zt(r,a))},E.derived({minDate:e=>{let{minimum:t}=Ue(e);return t?new Date(t):null},maxDate:e=>{let{maximum:t}=Ue(e);return t?new Date(t):null}},{}));function tx(e){return ld(ys,e)}var db=y("ZodArray",(e,t)=>{Gr(),nu.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(r,a,n)=>Cf(e,r,a,n),e.element=t.element},{min(e,t){return this.check(Cn(e,t))},nonempty(e){return this.check(Cn(1,e))},max(e,t){return this.check(Fr(e,t))},length(e,t){return this.check(qr(e,t))},unwrap(){return this.element}});function ae(e,t){return Qh(db,e,t)}function nx(e){let t=e._zod.def.shape;return Ke(Object.keys(t))}var ks=y("ZodObject",(e,t)=>{Gr(),jh.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(r,a,n)=>zf(e,r,a,n),E.installLazyProp(e,"shape",r=>r._zod.def.shape,!1)},{keyof(){return Ke(Object.keys(this._zod.def.shape))},catchall(e){return this.clone(E.mergeDefs(this._zod.def,{catchall:e}))},passthrough(){return this.clone(E.mergeDefs(this._zod.def,{catchall:xe()}))},loose(){return this.clone(E.mergeDefs(this._zod.def,{catchall:xe()}))},strict(){return this.clone(E.mergeDefs(this._zod.def,{catchall:Zd()}))},strip(){return this.clone(E.mergeDefs(this._zod.def,{catchall:void 0}))},extend(e){return E.extend(this,e)},safeExtend(e){return E.safeExtend(this,e)},merge(e){return E.merge(this,e)},pick(e){return E.pick(this,e)},omit(e){return E.omit(this,e)},partial(...e){return E.partial(Kr,this,e[0])},exactPartial(...e){return E.partial(Yd,this,e[0],"exactPartial")},required(...e){return E.required(Xd,this,e[0])}});function O(e,t){let r={type:"object",shape:e??{},...E.normalizeParams(t)};return new ks(r)}function rx(e,t){return new ks({type:"object",shape:e,catchall:Zd(),...E.normalizeParams(t)})}function We(e,t){return new ks({type:"object",shape:e,catchall:xe(),...E.normalizeParams(t)})}var _s=y("ZodUnion",(e,t)=>{Da.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(r,a,n)=>Sd(e,r,a,n),e.options=t.options});function ye(e,t){return new _s({type:"union",options:e,...E.normalizeParams(t)})}var pb=y("ZodXor",(e,t)=>{_s.init(e,t),au.init(e,t),e._zod.processJSONSchema=(r,a,n)=>Sd(e,r,a,n),e.options=t.options});function ax(e,t){return new pb({type:"union",options:e,inclusive:!1,...E.normalizeParams(t)})}var mb=y("ZodDiscriminatedUnion",(e,t)=>{_s.init(e,t),iu.init(e,t)});function ws(e,t,r){return new mb({type:"union",options:t,discriminator:e,...E.normalizeParams(r)})}var gb=y("ZodIntersection",(e,t)=>{ou.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(r,a,n)=>If(e,r,a,n)});function mi(e,t){return new gb({type:"intersection",left:e,right:t})}var hb=y("ZodTuple",(e,t)=>{Gr(),No.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(r,a,n)=>Pf(e,r,a,n)},{rest(e){return this.clone({...this._zod.def,rest:e})},partial(){let e=this._zod.def;if(e.checks?.length)throw new Error(".partial() cannot be used on tuple schemas containing refinements");return this.clone({...e,items:e.items.map(t=>new Kr({type:"optional",innerType:t}))})}});function fb(e,t,r){let a=t instanceof Z,n=a?r:t,i=a?t:null;return new hb({type:"tuple",items:e,rest:i,...E.normalizeParams(n)})}var si=y("ZodRecord",(e,t)=>{Gr(),su.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(r,a,n)=>Rf(e,r,a,n),e.keyType=t.keyType,e.valueType=t.valueType});function Ee(e,t,r){return!t||!t._zod?new si({type:"record",keyType:w(),valueType:e,...E.normalizeParams(t)}):new si({type:"record",keyType:e,valueType:t,...E.normalizeParams(r)})}function ix(e,t,r){return new si({type:"record",keyType:e,valueType:t,...E.normalizeParams(r),partial:!0})}function ox(e,t,r){return new si({type:"record",keyType:e,valueType:t,mode:"loose",...E.normalizeParams(r)})}var bb=y("ZodMap",(e,t)=>{Gr(),lu.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(r,a,n)=>Tf(e,r,a,n),e.keyType=t.keyType,e.valueType=t.valueType,e.min=(...r)=>e.check(un(...r)),e.nonempty=r=>e.check(un(1,r)),e.max=(...r)=>e.check(rr(...r)),e.size=(...r)=>e.check(Ur(...r))});function sx(e,t,r){return new bb({type:"map",keyType:e,valueType:t,...E.normalizeParams(r)})}var vb=y("ZodSet",(e,t)=>{Gr(),cu.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(r,a,n)=>Af(e,r,a,n),e.min=(...r)=>e.check(un(...r)),e.nonempty=r=>e.check(un(1,r)),e.max=(...r)=>e.check(rr(...r)),e.size=(...r)=>e.check(Ur(...r))});function lx(e,t){return new vb({type:"set",valueType:e,...E.normalizeParams(t)})}var li=y("ZodEnum",(e,t)=>{uu.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(a,n,i)=>bf(e,a,n,i),e.enum=t.entries,e.options=[...e._zod.values];let r=new Set(Object.keys(t.entries));e.extract=(a,n)=>{let i={};for(let o of a)if(r.has(o))i[o]=t.entries[o];else throw new Error(`Key ${o} not found in enum`);return new li({...t,checks:[],...E.normalizeParams(n),entries:i})},e.exclude=(a,n)=>{let i={...t.entries};for(let o of a)if(r.has(o))delete i[o];else throw new Error(`Key ${o} not found in enum`);return new li({...t,checks:[],...E.normalizeParams(n),entries:i})}});function Ke(e,t){let r=Array.isArray(e)?Object.fromEntries(e.map(a=>[a,a])):e;return new li({type:"enum",entries:r,...E.normalizeParams(t)})}function cx(e,t){return new li({type:"enum",entries:e,...E.normalizeParams(t)})}var yb=y("ZodLiteral",(e,t)=>{du.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(r,a,n)=>vf(e,r,a,n),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function B(e,t){return new yb({type:"literal",values:Array.isArray(e)?e:[e],...E.normalizeParams(t)})}var kb=y("ZodFile",(e,t)=>{pu.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(r,a,n)=>_f(e,r,a,n),e.min=(r,a)=>e.check(un(r,a)),e.max=(r,a)=>e.check(rr(r,a)),e.mime=(r,a)=>e.check(Xa(Array.isArray(r)?r:[r],a))});function ux(e){return hd(kb,e)}var _b=y("ZodTransform",(e,t)=>{Gr(),mu.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(r,a,n)=>xf(e,r,a,n),e._zod.parse=(r,a)=>{if(a.direction==="backward")throw new Qn(e.constructor.name);r.addIssue=i=>{if(typeof i=="string")r.issues.push(E.issue(i,r.value,t));else{let o=i;o.fatal&&(o.continue=!1),o.code??(o.code="custom"),"input"in o||(o.input=r.value),o.inst??(o.inst=e),r.issues.push(E.issue(o))}};let n=t.transform(r.value,r);return n instanceof Promise?n.then(i=>(r.value=i,r)):(r.value=n,r)}});function Jd(e){return new _b({type:"transform",transform:e})}var Kr=y("ZodOptional",(e,t)=>{Do.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(r,a,n)=>Ed(e,r,a,n),e.unwrap=()=>e._zod.def.innerType});function we(e){return new Kr({type:"optional",innerType:e})}var Yd=y("ZodExactOptional",(e,t)=>{gu.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(r,a,n)=>Ed(e,r,a,n),e.unwrap=()=>e._zod.def.innerType});function wb(e){return new Yd({type:"optional",innerType:e})}var Sb=y("ZodNullable",(e,t)=>{hu.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(r,a,n)=>$f(e,r,a,n),e.unwrap=()=>e._zod.def.innerType});function fs(e){return new Sb({type:"nullable",innerType:e})}function dx(e){return we(fs(e))}var Eb=y("ZodDefault",(e,t)=>{fu.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(r,a,n)=>Nf(e,r,a,n),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function xb(e,t){return new Eb({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():E.shallowClone(t)}})}var Tb=y("ZodPrefault",(e,t)=>{bu.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(r,a,n)=>Df(e,r,a,n),e.unwrap=()=>e._zod.def.innerType});function Ab(e,t){return new Tb({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():E.shallowClone(t)}})}var Xd=y("ZodNonOptional",(e,t)=>{vu.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(r,a,n)=>jf(e,r,a,n),e.unwrap=()=>e._zod.def.innerType});function Cb(e,t){return new Xd({type:"nonoptional",innerType:e,...E.normalizeParams(t)})}var zb=y("ZodSuccess",(e,t)=>{yu.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(r,a,n)=>wf(e,r,a,n),e.unwrap=()=>e._zod.def.innerType});function px(e){return new zb({type:"success",innerType:e})}var Ib=y("ZodCatch",(e,t)=>{ku.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(r,a,n)=>Mf(e,r,a,n),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function Pb(e,t){return new Ib({type:"catch",innerType:e,catchValue:typeof t=="function"?t:E.constantCatch(t)})}var Rb=y("ZodNaN",(e,t)=>{_u.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(r,a,n)=>yf(e,r,a,n)});function mx(e){return cd(Rb,e)}var Ss=y("ZodPipe",(e,t)=>{Mo.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(r,a,n)=>Lf(e,r,a,n),e.in=t.in,e.out=t.out});function zd(e,t){return new Ss({type:"pipe",in:e,out:t})}var Es=y("ZodCodec",(e,t)=>{Ss.init(e,t),Ma.init(e,t)});function gx(e,t,r){return new Es({type:"pipe",in:e,out:t,transform:r.decode,reverseTransform:r.encode})}function hx(e){let t=e._zod.def;return new Es({type:"pipe",in:t.out,out:t.in,transform:t.reverseTransform,reverseTransform:t.transform})}var $b=y("ZodPreprocess",(e,t)=>{Ss.init(e,t),Nh.init(e,t)}),jb=y("ZodReadonly",(e,t)=>{wu.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(r,a,n)=>Bf(e,r,a,n),e.unwrap=()=>e._zod.def.innerType});function Ob(e){return new jb({type:"readonly",innerType:e})}var Nb=y("ZodTemplateLiteral",(e,t)=>{Su.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(r,a,n)=>kf(e,r,a,n)});function fx(e,t){return new Nb({type:"template_literal",parts:e,...E.normalizeParams(t)})}var Db=y("ZodLazy",(e,t)=>{La.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(r,a,n)=>Ff(e,r,a,n),e.unwrap=()=>e._zod.def.getter()});function Mb(e){return new Db({type:"lazy",getter:e})}var Lb=y("ZodPromise",(e,t)=>{xu.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(r,a,n)=>Uf(e,r,a,n),e.unwrap=()=>e._zod.def.innerType});function bx(e){return new Lb({type:"promise",innerType:e})}var Bb=y("ZodFunction",(e,t)=>{Eu.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(r,a,n)=>Ef(e,r,a,n)});function vx(e){return new Bb({type:"function",input:Array.isArray(e?.input)?fb(e?.input):e?.input??ae(xe()),output:e?.output??xe()})}var xs=y("ZodCustom",(e,t)=>{Tu.init(e,t),Y.init(e,t),e._zod.processJSONSchema=(r,a,n)=>Sf(e,r,a,n)});function yx(e){let t=new _e({check:"custom"});return t._zod.check=e,t}function Qd(e,t){return fd(xs,e??(()=>!0),t)}function Ub(e,t={}){return bd(xs,e,t)}function Fb(e,t){return vd(e,t)}var kx=yd,_x=kd,qb=y("ZodInstanceOf",(e,t)=>{xs.init(e,t)},{properties(e,t){return this.check(Ya(e,t))}});function wx(e,t={}){let r=new qb({type:"custom",check:"custom",fn:a=>a instanceof e,abort:!0,...E.normalizeParams(t)});return r._zod.bag.Class=e,r._zod.check=a=>{a.value instanceof e||a.issues.push({code:"invalid_type",expected:e.name,input:a.value,inst:r,path:[...r._zod.def.path??[]]})},r}var Sx=(...e)=>_d({Codec:Es,Boolean:di,String:ci},...e);function Ex(e){let t=Mb(()=>ye([w(e),he(),De(),vs(),ae(t),Ee(w(),t)]));return t}function Ts(e,t){return new $b({type:"pipe",in:Jd(e),out:t})}var v0={invalid_type:"invalid_type",too_big:"too_big",too_small:"too_small",invalid_format:"invalid_format",not_multiple_of:"not_multiple_of",unrecognized_keys:"unrecognized_keys",invalid_union:"invalid_union",invalid_key:"invalid_key",invalid_element:"invalid_element",invalid_value:"invalid_value",custom:"custom"};function y0(e){Oe({customError:e})}function k0(){return Oe().customError}var Hb;Hb||(Hb={});var Zr={};En(Zr,{ZodISODate:()=>cr,ZodISODateTime:()=>lr,ZodISODuration:()=>dr,ZodISOTime:()=>ur,date:()=>w0,datetime:()=>_0,duration:()=>E0,time:()=>S0});function _0(e){return us(lr,e)}function w0(e){return ds(cr,e)}function S0(e){return ps(ur,e)}function E0(e){return ms(dr,e)}var $={...gi,...Td,iso:Zr},x0=new Set(["$schema","$ref","$defs","definitions","$id","id","$comment","$anchor","$vocabulary","$dynamicRef","$dynamicAnchor","type","enum","const","anyOf","oneOf","allOf","not","properties","required","additionalProperties","patternProperties","propertyNames","minProperties","maxProperties","items","prefixItems","additionalItems","minItems","maxItems","uniqueItems","contains","minContains","maxContains","minLength","maxLength","pattern","format","minimum","maximum","exclusiveMinimum","exclusiveMaximum","multipleOf","description","default","contentEncoding","contentMediaType","contentSchema","unevaluatedItems","unevaluatedProperties","if","then","else","dependentSchemas","dependentRequired","nullable","readOnly"]);function T0(e,t){let r=e.$schema;return r==="https://json-schema.org/draft/2020-12/schema"?"draft-2020-12":r==="http://json-schema.org/draft-07/schema#"?"draft-7":r==="http://json-schema.org/draft-04/schema#"?"draft-4":t??"draft-2020-12"}function xx(e,t){return e.map((r,a)=>a<t?r:r.optional())}function A0(e){return e.replace(/~1/g,"/").replace(/~0/g,"~")}function C0(e,t){if(!e.startsWith("#"))throw new Error("External $ref is not supported, only local refs (#/...) are allowed");let r=e.slice(1).split("/").filter(Boolean);if(r.length===0)return t.rootSchema;let a=t.version==="draft-2020-12"?"$defs":"definitions";if(r[0]===a){let n=r[1]===void 0?void 0:A0(r[1]);if(!n||!t.defs[n])throw new Error(`Reference not found: ${e}`);return t.defs[n]}throw new Error(`Reference not found: ${e}`)}function z0(e,t){return $.transform(a=>a).check(a=>{let n=a.value;if(typeof n!="object"||n===null||Array.isArray(n))return;let i=Object.getOwnPropertyNames(n);if(t.minProperties!==void 0&&i.length<t.minProperties&&a.issues.push({origin:"object",code:"too_small",minimum:t.minProperties,inclusive:!0,message:`Too small: expected object to have >=${t.minProperties} properties`,input:n,inst:e,continue:!0}),t.maxProperties!==void 0&&i.length>t.maxProperties&&a.issues.push({origin:"object",code:"too_big",maximum:t.maxProperties,inclusive:!0,message:`Too big: expected object to have <=${t.maxProperties} properties`,input:n,inst:e,continue:!0}),t.keySchema)for(let o of i){let s=t.keySchema.safeParse(o);s.success||a.issues.push({code:"invalid_key",origin:"record",issues:s.error.issues,input:o,path:[o],continue:!0})}}).pipe(e)}function Gb(e,t){if(e===null)return"z";let r=typeof e;if(r!=="object"){if(r==="number"&&Number.isNaN(e))return null;let a=String(e);return`${r[0]}${a.length}:${a}`}if(t.has(e))return null;t.add(e);try{if(Array.isArray(e)){let i=[];for(let o of e){let s=Gb(o,t);if(s===null)return null;i.push(s)}return`a${i.length}:[${i.join(",")}]`}let a=Object.keys(e).sort(),n=[];for(let i of a){let o=Gb(e[i],t);if(o===null)return null;n.push(`${i.length}:${i}=${o}`)}return`o${n.length}:{${n.join(",")}}`}finally{t.delete(e)}}var I0=new Set(["items","prefixItems","additionalItems","additionalProperties","contains","propertyNames","not","if","then","else","allOf","anyOf","oneOf","unevaluatedItems","unevaluatedProperties","contentSchema"]),P0=new Set(["properties","patternProperties","dependentSchemas","dependencies","$defs","definitions"]);function As(e){return typeof e!="object"||e===null?!1:Array.isArray(e)?e.some(As):typeof e.$ref=="string"?!0:Object.entries(e).some(([t,r])=>I0.has(t)?As(r):!P0.has(t)||typeof r!="object"||r===null?!1:Object.values(r).some(As))}function Tx(e){return e===1?"element":"elements"}function R0(e,t){return $.transform(a=>a).check(a=>{let n=a.value;if(Array.isArray(n)){if(t.uniqueItems===!0){let i=new Map;for(let o=0;o<n.length;o++){let s=Gb(n[o],new Set);if(s===null)continue;let l=i.get(s);if(l===void 0){i.set(s,o);continue}a.issues.push({code:"custom",message:`Array items must be unique: element at index ${o} duplicates the one at index ${l}`,input:n,path:[o],continue:!0})}}if(t.containsSchema){let i=t.minContains??1,o=t.maxContains!==void 0?t.maxContains+1:Number.POSITIVE_INFINITY,s=0;for(let l of n)if(t.containsSchema.safeParse(l).success&&++s>=o)break;s<i&&a.issues.push({code:"custom",message:`Array must contain at least ${i} matching ${Tx(i)}; found ${s}`,input:n,continue:!0}),t.maxContains!==void 0&&s>t.maxContains&&a.issues.push({code:"custom",message:`Array must contain at most ${t.maxContains} matching ${Tx(t.maxContains)}`,input:n,continue:!0})}}}).pipe(e)}function Ax(e,t){if(e!==!1)return e===void 0||e===!0?$.any():pt(e,t)}var $0=/^(?:[01]\d|2[0-3]):[0-5]\d:[0-5]\d(?:\.\d+)?(?:Z|[+-](?:[01]\d|2[0-3]):[0-5]\d)$/;function Cx(e,t){if(e.not!==void 0){if(typeof e.not=="object"&&Object.keys(e.not).length===0)return $.never();throw new Error("not is not supported in Zod (except { not: {} } for never)")}if(e.unevaluatedItems!==void 0)throw new Error("unevaluatedItems is not supported");if(e.unevaluatedProperties!==void 0)throw new Error("unevaluatedProperties is not supported");if(e.if!==void 0||e.then!==void 0||e.else!==void 0)throw new Error("Conditional schemas (if/then/else) are not supported");if(e.dependentSchemas!==void 0||e.dependentRequired!==void 0)throw new Error("dependentSchemas and dependentRequired are not supported");if(e.$ref){let n=e.$ref;if(t.refs.has(n))return t.refs.get(n);if(t.processing.has(n))return $.lazy(()=>{if(!t.refs.has(n))throw new Error(`Circular reference not resolved: ${n}`);return t.refs.get(n)});t.processing.add(n);let i=C0(n,t),o=pt(i,t);return t.refs.set(n,o),t.processing.delete(n),o}if(e.enum!==void 0){let n=e.enum;if(t.version==="openapi-3.0"&&e.nullable===!0&&n.length===1&&n[0]===null)return $.null();if(n.length===0)return $.never();if(n.length===1)return $.literal(n[0]);if(n.every(o=>typeof o=="string"))return $.enum(n);let i=n.map(o=>$.literal(o));return i.length<2?i[0]:$.union([i[0],i[1],...i.slice(2)])}if(e.const!==void 0)return $.literal(e.const);let r=e.type;if(Array.isArray(r)){let n=r.map(i=>{let o={...e,type:i};return Cx(o,t)});return n.length===0?$.never():n.length===1?n[0]:$.union(n)}if(!r)return $.any();let a;switch(r){case"string":{let n=$.string();if(e.format){let i=e.format;i==="email"?n=n.check($.email()):i==="uri"||i==="uri-reference"?n=n.check($.url()):i==="uuid"||i==="guid"?n=n.check($.uuid()):i==="date-time"?n=n.check($.iso.datetime({offset:!0})):i==="date"?n=n.check($.iso.date()):i==="time"?n=n.check($.regex($0)):i==="duration"?n=n.check($.iso.duration()):i==="hostname"?n=n.check($.hostname()):i==="ipv4"?n=n.check($.ipv4()):i==="ipv6"?n=n.check($.ipv6()):i==="mac"?n=n.check($.mac()):i==="cidr"?n=n.check($.cidrv4()):i==="cidr-v6"?n=n.check($.cidrv6()):i==="base64"?n=n.check($.base64()):i==="base64url"?n=n.check($.base64url()):i==="e164"?n=n.check($.e164()):i==="credit_card"?n=n.check($.creditCard()):i==="iban"?n=n.check($.iban()):i==="jwt"?n=n.check($.jwt()):i==="emoji"?n=n.check($.emoji()):i==="nanoid"?n=n.check($.nanoid()):i==="cuid"?n=n.check($.cuid()):i==="cuid2"?n=n.check($.cuid2()):i==="ulid"?n=n.check($.ulid()):i==="xid"?n=n.check($.xid()):i==="ksuid"&&(n=n.check($.ksuid()))}typeof e.minLength=="number"&&(n=n.min(e.minLength)),typeof e.maxLength=="number"&&(n=n.max(e.maxLength)),e.pattern&&(n=n.regex(new RegExp(e.pattern))),a=n;break}case"number":case"integer":{let n=r==="integer"?$.number().int():$.number();typeof e.minimum=="number"&&e.exclusiveMinimum!==!0&&(n=n.min(e.minimum)),typeof e.maximum=="number"&&e.exclusiveMaximum!==!0&&(n=n.max(e.maximum)),typeof e.exclusiveMinimum=="number"?n=n.gt(e.exclusiveMinimum):e.exclusiveMinimum===!0&&typeof e.minimum=="number"&&(n=n.gt(e.minimum)),typeof e.exclusiveMaximum=="number"?n=n.lt(e.exclusiveMaximum):e.exclusiveMaximum===!0&&typeof e.maximum=="number"&&(n=n.lt(e.maximum)),typeof e.multipleOf=="number"&&(n=n.multipleOf(e.multipleOf)),a=n;break}case"boolean":{a=$.boolean();break}case"null":{a=$.null();break}case"object":{let n={},i=e.properties||{},o=new Set(e.required||[]),s=typeof e.additionalProperties=="object"?pt(e.additionalProperties,t):void 0;for(let[d,m]of Object.entries(i)){let p=pt(m,t);Ge(n,d,o.has(d)?p:p.optional())}if(e.patternProperties){let d=e.patternProperties,m=Object.keys(d),p=[];for(let h of m){let f=pt(d[h],t),_=$.string().regex(new RegExp(h));p.push($.looseRecord(_,f))}let g=[];if(Object.keys(n).length>0&&g.push($.object(n).passthrough()),g.push(...p),g.length===0)a=$.object({}).passthrough();else if(g.length===1)a=g[0];else{let h=$.intersection(g[0],g[1]);for(let f=2;f<g.length;f++)h=$.intersection(h,g[f]);a=h}if(e.additionalProperties===!1){let h=Object.keys(n),f=m.map(b=>new RegExp(b)),_=a;a=a.check(b=>{if(!Dt(b.value))return;let v=[];for(let C of Object.keys(b.value))h.includes(C)||f.some(S=>S.test(C))||v.push(C);v.length&&b.issues.push({code:"unrecognized_keys",keys:v,input:b.value,inst:_})})}}else{let d=$.object(n);e.additionalProperties===!1?a=d.strict():s?a=d.catchall(s):a=d.passthrough()}let l=e.propertyNames!==void 0&&e.propertyNames!==!0,c=typeof e.minProperties=="number"?e.minProperties:void 0,u=typeof e.maxProperties=="number"?e.maxProperties:void 0;if(l||c!==void 0||u!==void 0){let d;if(l){let m=typeof e.propertyNames=="object"&&e.propertyNames.type===void 0?{type:"string",...e.propertyNames}:e.propertyNames;d=pt(m,t)}a=z0(a,{keySchema:d,minProperties:c,maxProperties:u})}break}case"array":{let n=e.prefixItems,i=e.items;if(n&&Array.isArray(n)){let o=typeof e.minItems=="number"?e.minItems:0,s=n.map(d=>pt(d,t)),l=xx(s,o),c=Array.isArray(i)?void 0:Ax(i,t),u=$.tuple(l);a=c?u.rest(c):u,typeof e.minItems=="number"&&(a=a.check($.minLength(e.minItems))),typeof e.maxItems=="number"&&(a=a.check($.maxLength(e.maxItems)))}else if(Array.isArray(i)){let o=typeof e.minItems=="number"?e.minItems:0,s=i.map(d=>pt(d,t)),l=xx(s,o),c=Ax(e.additionalItems,t),u=$.tuple(l);a=c?u.rest(c):u,typeof e.minItems=="number"&&(a=a.check($.minLength(e.minItems))),typeof e.maxItems=="number"&&(a=a.check($.maxLength(e.maxItems)))}else if(i!==void 0){let o=pt(i,t),s=$.array(o);typeof e.minItems=="number"&&(s=s.min(e.minItems)),typeof e.maxItems=="number"&&(s=s.max(e.maxItems)),a=s}else a=$.array($.any());(e.uniqueItems===!0||e.contains!==void 0)&&(a=R0(a,{uniqueItems:e.uniqueItems===!0,containsSchema:e.contains!==void 0?pt(e.contains,t):void 0,minContains:typeof e.minContains=="number"?e.minContains:void 0,maxContains:typeof e.maxContains=="number"?e.maxContains:void 0}));break}default:throw new Error(`Unsupported type: ${r}`)}return a}function pt(e,t){if(typeof e=="boolean")return e?$.any():$.never();let r=Cx(e,t),a=e.type||e.enum!==void 0||e.const!==void 0;if(e.anyOf&&Array.isArray(e.anyOf)){let s=e.anyOf.map(c=>pt(c,t)),l=$.union(s);r=a?$.intersection(r,l):l}if(e.oneOf&&Array.isArray(e.oneOf)){let s=e.oneOf.map(c=>pt(c,t)),l=$.xor(s);r=a?$.intersection(r,l):l}if(e.allOf&&Array.isArray(e.allOf))if(e.allOf.length===0)r=a?r:$.any();else{let s=a?r:pt(e.allOf[0],t),l=a?0:1;for(let c=l;c<e.allOf.length;c++)s=$.intersection(s,pt(e.allOf[c],t));r=s}e.nullable===!0&&t.version==="openapi-3.0"&&(r=$.nullable(r)),e.readOnly===!0&&(r=$.readonly(r)),e.default!==void 0&&(r=r.default(e.default));let n={},i=["$id","id","$comment","$anchor","$vocabulary","$dynamicRef","$dynamicAnchor"];for(let s of i)s in e&&(n[s]=e[s]);let o=["contentEncoding","contentMediaType","contentSchema"];for(let s of o)s in e&&(n[s]=e[s]);if(e.type==="object"&&e.$ref===void 0){e.propertyNames!==void 0&&!As(e.propertyNames)&&(n.propertyNames=e.propertyNames);for(let s of["minProperties","maxProperties"])e[s]!==void 0&&(n[s]=e[s])}if(e.type==="array"&&e.$ref===void 0){e.contains!==void 0&&!As(e.contains)&&(n.contains=e.contains);for(let s of["uniqueItems","minContains","maxContains"])e[s]!==void 0&&(n[s]=e[s])}for(let s of Object.keys(e))x0.has(s)||Ge(n,s,e[s]);return Object.keys(n).length>0&&t.registry.add(r,n),e.description&&(r=r.describe(e.description)),r}function zx(e,t){if(typeof e=="boolean")return e?$.any():$.never();let r;try{r=JSON.parse(JSON.stringify(e))}catch{throw new Error("fromJSONSchema input is not valid JSON (possibly cyclic); use $defs/$ref for recursive schemas")}let a=T0(r,t?.defaultTarget),n=r.$defs||r.definitions||{},i={version:a,defs:n,refs:new Map,processing:new Set,rootSchema:r,registry:t?.registry??Ve};return pt(r,i)}var Ix=Symbol("z.visit/resolving");function Cs(e,t){let r=typeof t=="function"?t:(o,s)=>{let l=t[o._zod.def.type];return l?l(o,s):o},a=new Map;function n(o){let s=a.get(o);if(s===Ix)return new La({type:"lazy",getter:()=>a.get(o)});if(s!==void 0)return s;a.set(o,Ix);let l=i(o),c=r(l,l!==o);return a.set(o,c),c}function i(o){let s=o._zod.def,l=s.type;switch(l){case"object":{let c=s.shape,u=Object.keys(c),d=!1,m={};for(let g of u){let h=n(c[g]);h!==c[g]&&(d=!0),m[g]=h}let p=s.catchall;return s.catchall&&(p=n(s.catchall),p!==s.catchall&&(d=!0)),d?ge(o,{...s,shape:m,catchall:p}):o}case"array":{let c=n(s.element);return c===s.element?o:ge(o,{...s,element:c})}case"tuple":{let c=s.items,u=!1,d=[];for(let p of c){let g=n(p);g!==p&&(u=!0),d.push(g)}let m=s.rest;return s.rest&&(m=n(s.rest),m!==s.rest&&(u=!0)),u?ge(o,{...s,items:d,rest:m}):o}case"record":case"map":{let c=n(s.keyType),u=n(s.valueType);return c===s.keyType&&u===s.valueType?o:ge(o,{...s,keyType:c,valueType:u})}case"set":{let c=n(s.valueType);return c===s.valueType?o:ge(o,{...s,valueType:c})}case"union":{let c=s.options,u=!1,d=[];for(let m of c){let p=n(m);p!==m&&(u=!0),d.push(p)}return u?ge(o,{...s,options:d}):o}case"intersection":{let c=n(s.left),u=n(s.right);return c===s.left&&u===s.right?o:ge(o,{...s,left:c,right:u})}case"optional":case"nullable":case"default":case"prefault":case"catch":case"readonly":case"nonoptional":case"promise":case"success":{let c=n(s.innerType);return c===s.innerType?o:ge(o,{...s,innerType:c})}case"pipe":{let c=n(s.in),u=n(s.out);return c===s.in&&u===s.out?o:ge(o,{...s,in:c,out:u})}case"function":{let c=n(s.input),u=n(s.output);return c===s.input&&u===s.output?o:ge(o,{...s,input:c,output:u})}case"lazy":{let c=s.getter,{_cachedInner:u,...d}=s;return ge(o,{...d,getter:()=>n(c())})}case"template_literal":case"string":case"number":case"int":case"boolean":case"bigint":case"symbol":case"undefined":case"null":case"void":case"never":case"any":case"unknown":case"date":case"nan":case"enum":case"literal":case"file":case"transform":case"custom":return o;default:return o}}return n(e)}function Px(e){return Cs(e,{object:t=>t.partial(),union:t=>{let r=t._zod.def;return r.discriminator===void 0?t:ye(r.options)}})}function j0(e,t){if(!t?.length)return e;let r=e._zod.def;return ge(e,Nt(r,{checks:[...r.checks??[],...t]}),{parent:!0})}function Rx(e){return j0(e.out,e.checks)}function O0(e){return e.in._zod.traits.has("$ZodTransform")?Rx(e):e.in}function $x(e){return Cs(e,{pipe:t=>O0(t._zod.def),default:(t,r)=>r?we(t._zod.def.innerType):t,catch:(t,r)=>r?t._zod.def.innerType:t})}function jx(e){return Cs(e,{pipe:t=>Rx(t._zod.def),prefault:(t,r)=>r?t._zod.def.innerType:t})}var Vb={};En(Vb,{bigint:()=>L0,boolean:()=>M0,date:()=>B0,number:()=>D0,string:()=>N0});function N0(e){return Wh(ci,e)}function D0(e){return Zh(ui,e)}function M0(e){return Jh(di,e)}function L0(e){return Yh(pi,e)}function B0(e){return Xh(ys,e)}var Kb="2025-11-25",Ox="2025-03-26",fi=[Kb,"2025-06-18","2025-03-26","2024-11-05","2024-10-07"],pr="io.modelcontextprotocol/related-task",tp="2.0",Fe=Qd(e=>e!==null&&(typeof e=="object"||typeof e=="function")),Nx=ye([w(),he().int()]),Dx=w(),IV=We({ttl:he().optional(),pollInterval:he().optional()}),U0=O({ttl:he().optional()}),F0=O({taskId:w()}),Zb=We({progressToken:Nx.optional(),[pr]:F0.optional()}),Pt=O({_meta:Zb.optional()}),zs=Pt.extend({task:U0.optional()}),Mx=e=>zs.safeParse(e).success,Ze=O({method:w(),params:Pt.loose().optional()}),Lt=O({_meta:Zb.optional()}),Bt=O({method:w(),params:Lt.loose().optional()}),Je=We({_meta:Zb.optional()}),np=ye([w(),he().int()]),Lx=O({jsonrpc:B(tp),id:np,...Ze.shape}).strict(),zn=e=>Lx.safeParse(e).success,Bx=O({jsonrpc:B(tp),...Bt.shape}).strict(),Ux=e=>Bx.safeParse(e).success,Jb=O({jsonrpc:B(tp),id:np,result:Je}).strict(),In=e=>Jb.safeParse(e).success;var F;(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"})(F||(F={}));var Yb=O({jsonrpc:B(tp),id:np.optional(),error:O({code:he().int(),message:w(),data:xe().optional()})}).strict();var bi=e=>Yb.safeParse(e).success;var Is=ye([Lx,Bx,Jb,Yb]),PV=ye([Jb,Yb]),rp=Je.strict(),q0=Lt.extend({requestId:np.optional(),reason:w().optional()}),ap=Bt.extend({method:B("notifications/cancelled"),params:q0}),H0=O({src:w(),mimeType:w().optional(),sizes:ae(w()).optional(),theme:Ke(["light","dark"]).optional()}),Ps=O({icons:ae(H0).optional()}),hi=O({name:w(),title:w().optional()}),Fx=hi.extend({...hi.shape,...Ps.shape,version:w(),websiteUrl:w().optional(),description:w().optional()}),G0=mi(O({applyDefaults:De().optional()}),Ee(w(),xe())),V0=Ts(e=>e&&typeof e=="object"&&!Array.isArray(e)&&Object.keys(e).length===0?{form:{}}:e,mi(O({form:G0.optional(),url:Fe.optional()}),Ee(w(),xe()).optional())),W0=We({list:Fe.optional(),cancel:Fe.optional(),requests:We({sampling:We({createMessage:Fe.optional()}).optional(),elicitation:We({create:Fe.optional()}).optional()}).optional()}),K0=We({list:Fe.optional(),cancel:Fe.optional(),requests:We({tools:We({call:Fe.optional()}).optional()}).optional()}),Z0=O({experimental:Ee(w(),Fe).optional(),sampling:O({context:Fe.optional(),tools:Fe.optional()}).optional(),elicitation:V0.optional(),roots:O({listChanged:De().optional()}).optional(),tasks:W0.optional(),extensions:Ee(w(),Fe).optional()}),J0=Pt.extend({protocolVersion:w(),capabilities:Z0,clientInfo:Fx}),ip=Ze.extend({method:B("initialize"),params:J0}),Xb=e=>ip.safeParse(e).success,Y0=O({experimental:Ee(w(),Fe).optional(),logging:Fe.optional(),completions:Fe.optional(),prompts:O({listChanged:De().optional()}).optional(),resources:O({subscribe:De().optional(),listChanged:De().optional()}).optional(),tools:O({listChanged:De().optional()}).optional(),tasks:K0.optional(),extensions:Ee(w(),Fe).optional()}),X0=Je.extend({protocolVersion:w(),capabilities:Y0,serverInfo:Fx,instructions:w().optional()}),Qb=Bt.extend({method:B("notifications/initialized"),params:Lt.optional()});var op=Ze.extend({method:B("ping"),params:Pt.optional()}),Q0=O({progress:he(),total:we(he()),message:we(w())}),ej=O({...Lt.shape,...Q0.shape,progressToken:Nx}),sp=Bt.extend({method:B("notifications/progress"),params:ej}),tj=Pt.extend({cursor:Dx.optional()}),Rs=Ze.extend({params:tj.optional()}),$s=Je.extend({nextCursor:Dx.optional()}),nj=Ke(["working","input_required","completed","failed","cancelled"]),js=O({taskId:w(),status:nj,ttl:ye([he(),vs()]),createdAt:w(),lastUpdatedAt:w(),pollInterval:we(he()),statusMessage:we(w())}),vi=Je.extend({task:js}),rj=Lt.merge(js),Os=Bt.extend({method:B("notifications/tasks/status"),params:rj}),lp=Ze.extend({method:B("tasks/get"),params:Pt.extend({taskId:w()})}),cp=Je.merge(js),up=Ze.extend({method:B("tasks/result"),params:Pt.extend({taskId:w()})}),RV=Je.loose(),dp=Rs.extend({method:B("tasks/list")}),pp=$s.extend({tasks:ae(js)}),mp=Ze.extend({method:B("tasks/cancel"),params:Pt.extend({taskId:w()})}),qx=Je.merge(js),Hx=O({uri:w(),mimeType:we(w()),_meta:Ee(w(),xe()).optional()}),Gx=Hx.extend({text:w()}),ev=w().refine(e=>{try{return atob(e),!0}catch{return!1}},{message:"Invalid Base64 string"}),Vx=Hx.extend({blob:ev}),Ns=Ke(["user","assistant"]),yi=O({audience:ae(Ns).optional(),priority:he().min(0).max(1).optional(),lastModified:Zr.datetime({offset:!0}).optional()}),Wx=O({...hi.shape,...Ps.shape,uri:w(),description:we(w()),mimeType:we(w()),size:we(he()),annotations:yi.optional(),_meta:we(We({}))}),aj=O({...hi.shape,...Ps.shape,uriTemplate:w(),description:we(w()),mimeType:we(w()),annotations:yi.optional(),_meta:we(We({}))}),gp=Rs.extend({method:B("resources/list")}),ij=$s.extend({resources:ae(Wx)}),hp=Rs.extend({method:B("resources/templates/list")}),oj=$s.extend({resourceTemplates:ae(aj)}),tv=Pt.extend({uri:w()}),sj=tv,fp=Ze.extend({method:B("resources/read"),params:sj}),lj=Je.extend({contents:ae(ye([Gx,Vx]))}),cj=Bt.extend({method:B("notifications/resources/list_changed"),params:Lt.optional()}),uj=tv,dj=Ze.extend({method:B("resources/subscribe"),params:uj}),pj=tv,mj=Ze.extend({method:B("resources/unsubscribe"),params:pj}),gj=Lt.extend({uri:w()}),hj=Bt.extend({method:B("notifications/resources/updated"),params:gj}),fj=O({name:w(),description:we(w()),required:we(De())}),bj=O({...hi.shape,...Ps.shape,description:we(w()),arguments:we(ae(fj)),_meta:we(We({}))}),bp=Rs.extend({method:B("prompts/list")}),vj=$s.extend({prompts:ae(bj)}),yj=Pt.extend({name:w(),arguments:Ee(w(),w()).optional()}),vp=Ze.extend({method:B("prompts/get"),params:yj}),nv=O({type:B("text"),text:w(),annotations:yi.optional(),_meta:Ee(w(),xe()).optional()}),rv=O({type:B("image"),data:ev,mimeType:w(),annotations:yi.optional(),_meta:Ee(w(),xe()).optional()}),av=O({type:B("audio"),data:ev,mimeType:w(),annotations:yi.optional(),_meta:Ee(w(),xe()).optional()}),kj=O({type:B("tool_use"),name:w(),id:w(),input:Ee(w(),xe()),_meta:Ee(w(),xe()).optional()}),_j=O({type:B("resource"),resource:ye([Gx,Vx]),annotations:yi.optional(),_meta:Ee(w(),xe()).optional()}),wj=Wx.extend({type:B("resource_link")}),iv=ye([nv,rv,av,wj,_j]),Sj=O({role:Ns,content:iv}),Ej=Je.extend({description:w().optional(),messages:ae(Sj)}),xj=Bt.extend({method:B("notifications/prompts/list_changed"),params:Lt.optional()}),Tj=O({title:w().optional(),readOnlyHint:De().optional(),destructiveHint:De().optional(),idempotentHint:De().optional(),openWorldHint:De().optional()}),Aj=O({taskSupport:Ke(["required","optional","forbidden"]).optional()}),Kx=O({...hi.shape,...Ps.shape,description:w().optional(),inputSchema:O({type:B("object"),properties:Ee(w(),Fe).optional(),required:ae(w()).optional()}).catchall(xe()),outputSchema:O({type:B("object"),properties:Ee(w(),Fe).optional(),required:ae(w()).optional()}).catchall(xe()).optional(),annotations:Tj.optional(),execution:Aj.optional(),_meta:Ee(w(),xe()).optional()}),yp=Rs.extend({method:B("tools/list")}),Cj=$s.extend({tools:ae(Kx)}),kp=Je.extend({content:ae(iv).default([]),structuredContent:Ee(w(),xe()).optional(),isError:De().optional()}),$V=kp.or(Je.extend({toolResult:xe()})),zj=zs.extend({name:w(),arguments:Ee(w(),xe()).optional()}),ki=Ze.extend({method:B("tools/call"),params:zj}),Ij=Bt.extend({method:B("notifications/tools/list_changed"),params:Lt.optional()}),jV=O({autoRefresh:De().default(!0),debounceMs:he().int().nonnegative().default(300)}),Ds=Ke(["debug","info","notice","warning","error","critical","alert","emergency"]),Pj=Pt.extend({level:Ds}),ov=Ze.extend({method:B("logging/setLevel"),params:Pj}),Rj=Lt.extend({level:Ds,logger:w().optional(),data:xe()}),$j=Bt.extend({method:B("notifications/message"),params:Rj}),jj=O({name:w().optional()}),Oj=O({hints:ae(jj).optional(),costPriority:he().min(0).max(1).optional(),speedPriority:he().min(0).max(1).optional(),intelligencePriority:he().min(0).max(1).optional()}),Nj=O({mode:Ke(["auto","required","none"]).optional()}),Dj=O({type:B("tool_result"),toolUseId:w().describe("The unique identifier for the corresponding tool call."),content:ae(iv).default([]),structuredContent:O({}).loose().optional(),isError:De().optional(),_meta:Ee(w(),xe()).optional()}),Mj=ws("type",[nv,rv,av]),ep=ws("type",[nv,rv,av,kj,Dj]),Lj=O({role:Ns,content:ye([ep,ae(ep)]),_meta:Ee(w(),xe()).optional()}),Bj=zs.extend({messages:ae(Lj),modelPreferences:Oj.optional(),systemPrompt:w().optional(),includeContext:Ke(["none","thisServer","allServers"]).optional(),temperature:he().optional(),maxTokens:he().int(),stopSequences:ae(w()).optional(),metadata:Fe.optional(),tools:ae(Kx).optional(),toolChoice:Nj.optional()}),Uj=Ze.extend({method:B("sampling/createMessage"),params:Bj}),Ms=Je.extend({model:w(),stopReason:we(Ke(["endTurn","stopSequence","maxTokens"]).or(w())),role:Ns,content:Mj}),sv=Je.extend({model:w(),stopReason:we(Ke(["endTurn","stopSequence","maxTokens","toolUse"]).or(w())),role:Ns,content:ye([ep,ae(ep)])}),Fj=O({type:B("boolean"),title:w().optional(),description:w().optional(),default:De().optional()}),qj=O({type:B("string"),title:w().optional(),description:w().optional(),minLength:he().optional(),maxLength:he().optional(),format:Ke(["email","uri","date","date-time"]).optional(),default:w().optional()}),Hj=O({type:Ke(["number","integer"]),title:w().optional(),description:w().optional(),minimum:he().optional(),maximum:he().optional(),default:he().optional()}),Gj=O({type:B("string"),title:w().optional(),description:w().optional(),enum:ae(w()),default:w().optional()}),Vj=O({type:B("string"),title:w().optional(),description:w().optional(),oneOf:ae(O({const:w(),title:w()})),default:w().optional()}),Wj=O({type:B("string"),title:w().optional(),description:w().optional(),enum:ae(w()),enumNames:ae(w()).optional(),default:w().optional()}),Kj=ye([Gj,Vj]),Zj=O({type:B("array"),title:w().optional(),description:w().optional(),minItems:he().optional(),maxItems:he().optional(),items:O({type:B("string"),enum:ae(w())}),default:ae(w()).optional()}),Jj=O({type:B("array"),title:w().optional(),description:w().optional(),minItems:he().optional(),maxItems:he().optional(),items:O({anyOf:ae(O({const:w(),title:w()}))}),default:ae(w()).optional()}),Yj=ye([Zj,Jj]),Xj=ye([Wj,Kj,Yj]),Qj=ye([Xj,Fj,qj,Hj]),eO=zs.extend({mode:B("form").optional(),message:w(),requestedSchema:O({type:B("object"),properties:Ee(w(),Qj),required:ae(w()).optional()})}),tO=zs.extend({mode:B("url"),message:w(),elicitationId:w(),url:w().url()}),nO=ye([eO,tO]),rO=Ze.extend({method:B("elicitation/create"),params:nO}),aO=Lt.extend({elicitationId:w()}),iO=Bt.extend({method:B("notifications/elicitation/complete"),params:aO}),_i=Je.extend({action:Ke(["accept","decline","cancel"]),content:Ts(e=>e===null?void 0:e,Ee(w(),ye([w(),he(),De(),ae(w())])).optional())}),oO=O({type:B("ref/resource"),uri:w()});var sO=O({type:B("ref/prompt"),name:w()}),lO=Pt.extend({ref:ye([sO,oO]),argument:O({name:w(),value:w()}),context:O({arguments:Ee(w(),w()).optional()}).optional()}),_p=Ze.extend({method:B("completion/complete"),params:lO});function Zx(e){if(e.params.ref.type!=="ref/prompt")throw new TypeError(`Expected CompleteRequestPrompt, but got ${e.params.ref.type}`)}function Jx(e){if(e.params.ref.type!=="ref/resource")throw new TypeError(`Expected CompleteRequestResourceTemplate, but got ${e.params.ref.type}`)}var cO=Je.extend({completion:We({values:ae(w()).max(100),total:we(he().int()),hasMore:we(De())})}),uO=O({uri:w().startsWith("file://"),name:w().optional(),_meta:Ee(w(),xe()).optional()}),dO=Ze.extend({method:B("roots/list"),params:Pt.optional()}),lv=Je.extend({roots:ae(uO)}),pO=Bt.extend({method:B("notifications/roots/list_changed"),params:Lt.optional()}),OV=ye([op,ip,_p,ov,vp,bp,gp,hp,fp,dj,mj,ki,yp,lp,up,dp,mp]),NV=ye([ap,sp,Qb,pO,Os]),DV=ye([rp,Ms,sv,_i,lv,cp,pp,vi]),MV=ye([op,Uj,rO,dO,lp,up,dp,mp]),LV=ye([ap,sp,$j,hj,cj,Ij,xj,Os,iO]),BV=ye([rp,X0,cO,Ej,vj,ij,oj,lj,kp,Cj,cp,pp,vi]),M=class e extends Error{constructor(t,r,a){super(`MCP error ${t}: ${r}`),this.code=t,this.data=a,this.name="McpError"}static fromError(t,r,a){if(t===F.UrlElicitationRequired&&a){let n=a;if(n.elicitations)return new Wb(n.elicitations,r)}return new e(t,r,a)}},Wb=class extends M{constructor(t,r=`URL elicitation${t.length>1?"s":""} required`){super(F.UrlElicitationRequired,r,{elicitations:t})}get elicitations(){return this.data?.elicitations??[]}};var mO=10*1024*1024,wp=class{constructor(t){this._maxBufferSize=t?.maxBufferSize??mO}append(t){if((this._buffer?.length??0)+t.length>this._maxBufferSize)throw this.clear(),new Error(`ReadBuffer exceeded maximum size of ${this._maxBufferSize} bytes`);this._buffer=this._buffer?Buffer.concat([this._buffer,t]):t}readMessage(){if(!this._buffer)return null;let t=this._buffer.indexOf(`
|
|
71
71
|
`);if(t===-1)return null;let r=this._buffer.toString("utf8",0,t).replace(/\r$/,"");return this._buffer=this._buffer.subarray(t+1),gO(r)}clear(){this._buffer=void 0}};function gO(e){return Is.parse(JSON.parse(e))}function Yx(e){return JSON.stringify(e)+`
|
|
72
|
-
`}var Sp=class{constructor(t=Xx.stdin,r=Xx.stdout,a){this._stdin=t,this._stdout=r,this._started=!1,this._ondata=n=>{try{this._readBuffer.append(n),this.processReadBuffer()}catch(i){this.onerror?.(i),this.close().catch(()=>{})}},this._onerror=n=>{this.onerror?.(n)},this._readBuffer=new wp({maxBufferSize:a?.maxBufferSize})}async start(){if(this._started)throw new Error("StdioServerTransport already started! If using Server class, note that connect() calls start() automatically.");this._started=!0,this._stdin.on("data",this._ondata),this._stdin.on("error",this._onerror)}processReadBuffer(){for(;;)try{let t=this._readBuffer.readMessage();if(t===null)break;this.onmessage?.(t)}catch(t){this.onerror?.(t)}}async close(){this._stdin.off("data",this._ondata),this._stdin.off("error",this._onerror),this._stdin.listenerCount("data")===0&&this._stdin.pause(),this._readBuffer.clear(),this.onclose?.()}send(t){return new Promise(r=>{let a=Yx(t);this._stdout.write(a)?r():this._stdout.once("drain",r)})}};var Qx="x-hono-already-sent";import{STATUS_CODES as ZV,ServerResponse as hO,createServer as JV}from"node:http";import{Http2ServerRequest as $n,constants as fO}from"node:http2";import{Readable as tT}from"node:stream";var eT=e=>((...t)=>{if(typeof t[0]=="function"){let[r,a]=t;return async function(i,o){let s=await e(i,await r(i),a);if(s)return s;await o()}}else{let[r,a,n]=t;return(async()=>{let i=await e(r,a,n);if(!i)throw new Error("Failed to upgrade WebSocket");return i})()}});var pn=class extends Error{constructor(e,t){super(e,t),this.name="RequestError"}},bO=new Set(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","server","user-agent"]),vO=/^[!#$%&'*+\-.^_`|~\dA-Za-z]+$/,Ep=e=>e===9||e===10||e===13||e===32,nT=e=>{if(!Ep(e.charCodeAt(0))&&!Ep(e.charCodeAt(e.length-1)))return e;let t=0,r=e.length;for(;t<r&&Ep(e.charCodeAt(t));)t++;for(;r>t&&Ep(e.charCodeAt(r-1));)r--;return e.slice(t,r)},rT=/[\0\r\n]/,bv=globalThis.Headers,uT=(e,t=bv)=>{let r=new t;for(let a=0;a<e.length;a+=2){let n=e[a];n.startsWith(":")||r.append(n,e[a+1])}return r},vv=class{#e;#t;#r;#a;constructor(e){this.#e=e,e instanceof $n&&(this.#t=e.rawHeaders.slice())}get#i(){return this.#t??=this.#e.rawHeaders.slice()}get#n(){return this.#r||(this.#r=uT(this.#i),this.#t=void 0),this.#r}#o(e){if(typeof e=="string"){if(!vO.test(e))throw new TypeError(`Invalid header name: ${e}`);return e.toLowerCase()}}#s(e){let t=this.#e instanceof $n?void 0:this.#e.headers;if(!t||bO.has(e)||e==="set-cookie"||e==="__proto__")return;if(!Object.hasOwn(t,e))return null;let r=t[e];if(typeof r=="string"){let a=nT(r);return rT.test(a)?void 0:a}}#l(e,t){let r=t==="cookie"?"; ":", ",a=null;for(let n=0;n<e.length;n+=2){let i=e[n];if(i.length===t.length&&i.toLowerCase()===t){let o=nT(e[n+1]);if(rT.test(o)){this.#a=!0;return}a=a===null?o:a+r+o}}return a}append(e,t){this.#n.append(e,t)}delete(e){this.#n.delete(e)}get(e){let t=this.#o(e);if(t&&!this.#r&&!this.#a){let r=this.#s(t);if(r!==void 0)return r;let a=this.#l(this.#i,t);if(a!==void 0)return a}return this.#n.get(e)}has(e){let t=this.#o(e);if(t&&!this.#r&&!this.#a){let r=this.#s(t);if(r!==void 0)return r!==null;let a=this.#l(this.#i,t);if(a!==void 0)return a!==null}return this.#n.has(e)}set(e,t){this.#n.set(e,t)}getSetCookie(){return this.#n.getSetCookie()}keys(){return this.#n.keys()}values(){return this.#n.values()}entries(){return this.#n.entries()}forEach(e,t){this.#n.forEach((r,a)=>{e.call(t,r,a,this)})}[Symbol.iterator](){return this.entries()}};Object.defineProperty(vv.prototype,Symbol.for("nodejs.util.inspect.custom"),{value:function(e,t,r){return`Headers (lightweight) ${r(Object.fromEntries(this),{...t,depth:e==null?null:e-1})}`}});Object.setPrototypeOf(vv.prototype,bv.prototype);var dT=e=>globalThis.Headers===bv?new vv(e):uT(e.rawHeaders,globalThis.Headers),yO=/^\/[!#$&-;=?-\[\]_a-z~]*$/,kO=/\/\.\.?(?:[/?#]|$)/,_O=/^[a-z0-9._-]+(?::(?:[1-5]\d{3,4}|[6-9]\d{3}))?$/,wO=(e,t,r)=>{let a=`${e}://${t}${r}`;if(_O.test(t)){if(r.length===0)return a+"/";if(r.charCodeAt(0)!==47)throw new pn("Invalid URL");return!yO.test(r)||kO.test(r)?new URL(a).href:a}else{let n=new URL(a);if(n.hostname.length!==t.length&&n.hostname!==(t.includes(":")?t.replace(/:\d+$/,""):t).toLowerCase())throw new pn("Invalid host header");return n.href}},SO=e=>e instanceof pn?e:new pn(e.message,{cause:e}),EO=global.Request,Si=class extends EO{constructor(e,t){if(typeof e=="object"&&gr in e){let r=t!==void 0&&"body"in t&&t.body!=null;if(e[jn]&&!r)throw new TypeError("Cannot construct a Request with a Request object that has already been used.");e=e[gr]()}typeof t?.body?.getReader<"u"&&(t.duplex??="half"),super(e,t)}},pT=Symbol("wrapBodyStream"),xO=new Set(["latin1","binary","hex","base64","base64url"]),TO=e=>e===null||xO.has(e),cv=Symbol("bodyBufferedBeforeDisconnect"),dv=Symbol("bodyBufferedLengthBeforeDisconnect"),mT=(e,t)=>Buffer.isBuffer(e)?e:Buffer.from(e,t??"utf8"),yv=e=>!(e instanceof $n)&&!!e.complete&&!!e.readableAborted&&typeof e.read=="function"&&TO(e.readableEncoding),aT=e=>{if(e.readableDidRead||!yv(e))return;let t=e;t[dv]??=e.readableLength},Tp=(e,t)=>{if(e.readableDidRead&&!t||!yv(e))return;let r=e;if(r[cv]!==void 0)return r[cv];let a,n=e.errored;if(n&&n.code!=="ECONNRESET")a=n;else if(r[dv]!==void 0&&e.readableLength!==r[dv])a=Ap();else{let i=t??[],o=e.read();o!==null&&i.push(mT(o,e.readableEncoding));let s=i.length===1?i[0]:Buffer.concat(i);a=s;let l=e.headers["content-length"];if(typeof l=="string"&&/^\d+$/.test(l)){let c=Number(l);Number.isSafeInteger(c)&&s.length!==c&&(a=Ap())}}return r[cv]=a,a},iT=(e,t)=>{if(t instanceof Error){e.error(t);return}t.length>0&&e.enqueue(t),e.close()},AO=(e,t,r,a,n)=>{let i={method:e,headers:r,signal:n.signal};if(e==="TRACE"){i.method="GET";let o=new Si(t,i);return Object.defineProperty(o,"method",{get(){return"TRACE"}}),o}if(!(e==="GET"||e==="HEAD"))if("rawBody"in a&&a.rawBody instanceof Buffer)i.body=new ReadableStream({start(o){o.enqueue(a.rawBody),o.close()}});else if(a[pT]){let o;i.body=new ReadableStream({async pull(s){try{if(!o){let u=Tp(a);if(u!==void 0){iT(s,u);return}}o||=tT.toWeb(a).getReader();let{done:l,value:c}=await o.read();l?s.close():s.enqueue(c)}catch(l){s.error(l)}}})}else{let o=Tp(a);o!==void 0?i.body=new ReadableStream({start(s){iT(s,o)}}):i.body=tT.toWeb(a)}return new Si(t,i)},gr=Symbol("getRequestCache"),Pn=Symbol("requestCache"),Ei=Symbol("incomingKey"),Us=Symbol("urlKey"),gT=Symbol("methodKey"),hT=Symbol("headersKey"),Ls=Symbol("abortControllerKey"),pv=Symbol("getAbortController"),mv=Symbol("abortRequest"),mr=Symbol("bodyBuffer"),xp=Symbol("bodyReadPromise"),jn=Symbol("bodyConsumedDirectly"),oT=Symbol("bodyLockReader"),Bs=Symbol("abortReason"),Ap=()=>new TypeError("Body is unusable"),Fs=()=>Promise.reject(Ap()),CO=new TextDecoder,zO=e=>{if(e[jn])return Fs();e[jn]=!0},IO=e=>e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength),PO=e=>(e[hT]||=dT(e[Ei])).get("content-type")||"",RO=/^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/,$O=e=>{if(typeof e!="string"||e.length===0)return"GET";switch(e){case"DELETE":case"GET":case"HEAD":case"OPTIONS":case"PATCH":case"POST":case"PUT":case"QUERY":return e}let t=e.toUpperCase();switch(t){case"DELETE":case"GET":case"HEAD":case"OPTIONS":case"POST":case"PUT":return t;default:return e}},jO=e=>{if(!RO.test(e))return new TypeError(`'${e}' is not a valid HTTP method.`);let t=e.toUpperCase();if(t==="CONNECT"||t==="TRACK"||t==="TRACE"&&e!=="TRACE")return new TypeError(`'${e}' HTTP method is unsupported.`)},kv=(e,t,r)=>{if(e[jn])return Fs();let a=e.method;if(a==="GET"||a==="HEAD")return e[gr]()[t]();let n=jO(a);if(n)return Promise.reject(n);if(e[Pn]&&a!=="TRACE")return e[Pn][t]();let i=zO(e);if(i)return i;let o=OO(e);if(o){let s=Promise.resolve(r(o,e));return e[mr]=void 0,s}return NO(e).then(s=>{let l=r(s,e);return e[mr]=void 0,l})},OO=e=>{let t=e[Ei];if("rawBody"in t&&t.rawBody instanceof Buffer)return t.rawBody},sT=(e,t)=>{if(t.errored)return t.errored;let r=e[Bs];return r!==void 0?r instanceof Error?r:new Error(String(r)):new Error("Client connection prematurely closed.")},NO=e=>{if(e[mr])return Promise.resolve(e[mr]);if(e[xp])return e[xp];let t=e[Ei];if(t.readableDidRead)return Fs();let r=Tp(t);if(r!==void 0)return r instanceof Error?Promise.reject(r):(e[mr]=r,Promise.resolve(r));let a=new Promise((n,i)=>{let o=[],s=!1,l=h=>{s||(s=!0,g(),h())},c=h=>{let f=t.errored??h;return!yv(t)||f&&f.code!=="ECONNRESET"?!1:(l(()=>{let _=Tp(t,o);_ instanceof Error?i(_):_===void 0?i(h??sT(e,t)):(e[mr]=_,n(_))}),!0)},u=h=>{o.push(mT(h,t.readableEncoding))},d=()=>{l(()=>{let h=o.length===1?o[0]:Buffer.concat(o);e[mr]=h,n(h)})},m=h=>{c(h)||l(()=>{i(h)})},p=()=>{if(t.readableEnded){d();return}c()||l(()=>{i(sT(e,t))})},g=()=>{t.off("data",u),t.off("end",d),t.off("error",m),t.off("close",p),e[xp]=void 0};t.on("data",u),t.on("end",d),t.on("error",m),t.on("close",p),queueMicrotask(()=>{s||(t.readableEnded?d():t.errored?m(t.errored):t.destroyed&&p())})});return e[xp]=a,a},gn={get method(){return this[gT]},get url(){return this[Us]},get headers(){return this[hT]||=dT(this[Ei])},[mv](e){this[Bs]===void 0&&(this[Bs]=e);let t=this[Ls];t&&!t.signal.aborted&&t.abort(e)},[pv](){return this[Ls]||=new AbortController,this[Bs]!==void 0&&!this[Ls].signal.aborted&&this[Ls].abort(this[Bs]),this[Ls]},[gr](){let e=this[pv]();if(this[Pn])return this[Pn];let t=this.method;if(this[jn]&&!(t==="GET"||t==="HEAD")){this[mr]=void 0;let r={method:t==="TRACE"?"GET":t,headers:this.headers,signal:e.signal};t!=="TRACE"&&(r.body=new ReadableStream({start(n){n.close()}}),r.duplex="half");let a=new Si(this[Us],r);return t==="TRACE"&&Object.defineProperty(a,"method",{get(){return"TRACE"}}),this[Pn]=a}return this[Pn]=AO(this.method,this[Us],this.headers,this[Ei],e)},get body(){if(!this[jn])return this[gr]().body;let e=this[gr]();return!this[oT]&&e.body&&(this[oT]=e.body.getReader()),e.body},get bodyUsed(){return this[jn]?!0:this[Pn]?this[Pn].bodyUsed:!1}};Object.defineProperty(gn,"signal",{get(){return this[pv]().signal}});["cache","credentials","destination","integrity","mode","redirect","referrer","referrerPolicy","keepalive"].forEach(e=>{Object.defineProperty(gn,e,{get(){return this[gr]()[e]}})});["clone","formData"].forEach(e=>{Object.defineProperty(gn,e,{value:function(){if(this[jn]){if(e==="clone")throw Ap();return Fs()}return this[gr]()[e]()}})});Object.defineProperty(gn,"text",{value:function(){return kv(this,"text",e=>CO.decode(e))}});Object.defineProperty(gn,"arrayBuffer",{value:function(){return kv(this,"arrayBuffer",e=>IO(e))}});Object.defineProperty(gn,"blob",{value:function(){return kv(this,"blob",(e,t)=>{let r=PO(t),a=r?{headers:{"content-type":r}}:void 0;return new Response(e,a).blob()})}});Object.defineProperty(gn,"json",{value:function(){return this[jn]?Fs():this.text().then(JSON.parse)}});Object.defineProperty(gn,Symbol.for("nodejs.util.inspect.custom"),{value:function(e,t,r){return`Request (lightweight) ${r({method:this.method,url:this.url,headers:this.headers,nativeRequest:this[Pn]},{...t,depth:e==null?null:e-1})}`}});Object.setPrototypeOf(gn,Si.prototype);var DO=(e,t)=>{let r=Object.create(gn);r[Ei]=e,r[gT]=$O(e.method);let a=e.url||"";if(a[0]!=="/"&&(a.startsWith("http://")||a.startsWith("https://"))){if(e instanceof $n)throw new pn("Absolute URL for :path is not allowed in HTTP/2");try{r[Us]=new URL(a).href}catch(o){throw new pn("Invalid absolute URL",{cause:o})}return r}let n=(e instanceof $n?e.authority:e.headers.host)||t;if(!n)throw new pn("Missing host header");let i;if(e instanceof $n){if(i=e.scheme,!(i==="http"||i==="https"))throw new pn("Unsupported scheme")}else i=e.socket&&e.socket.encrypted?"https":"http";try{r[Us]=wO(i,n,a)}catch(o){throw o instanceof pn?o:new pn("Invalid URL",{cause:o})}return r},Jr="text/plain; charset=UTF-8",gv=Symbol("responseCache"),wi=Symbol("getResponseCache"),Rn=Symbol("cache"),Cp=global.Response,mn=class fT{#e;#t;[wi](){let t=this[Rn],r=t&&t[2]instanceof Headers?t[2]:void 0;return delete this[Rn],this[gv]||=new Cp(this.#e,r?{status:this.#t?.status,statusText:this.#t?.statusText,headers:r}:this.#t)}constructor(t,r){let a;if(this.#e=t,r instanceof Cp){let n=r[gv];if(n){this.#t=n,this[wi]();return}this.#t=r instanceof fT?r.#t:r,a=new Headers(r.headers)}else this.#t=r;(t==null||typeof t=="string"||typeof t?.getReader<"u"||t instanceof Blob||t instanceof Uint8Array)&&(this[Rn]=[r?.status||200,t??null,a||r?.headers])}get headers(){let t=this[Rn];return t?(t[2]instanceof Headers||(t[2]=new Headers(t[2]||(t[1]===null?void 0:{"content-type":Jr}))),t[2]):this[wi]().headers}get status(){return this[Rn]?.[0]??this[wi]().status}get ok(){let t=this.status;return t>=200&&t<300}};["body","bodyUsed","redirected","statusText","trailers","type","url"].forEach(e=>{Object.defineProperty(mn.prototype,e,{get(){return this[wi]()[e]}})});["arrayBuffer","blob","clone","formData","json","text"].forEach(e=>{Object.defineProperty(mn.prototype,e,{value:function(){return this[wi]()[e]()}})});Object.defineProperty(mn.prototype,Symbol.for("nodejs.util.inspect.custom"),{value:function(e,t,r){return`Response (lightweight) ${r({status:this.status,headers:this.headers,ok:this.ok,nativeResponse:this[gv]},{...t,depth:e==null?null:e-1})}`}});Object.setPrototypeOf(mn,Cp);Object.setPrototypeOf(mn.prototype,Cp.prototype);var MO=/^https?:\/\/[!#-;=?-[\]_a-z~A-Z]+$/,LO=e=>e instanceof URL?e.href:MO.test(e)?e:new URL(e).href,BO=new Set([301,302,303,307,308]);Object.defineProperty(mn,"redirect",{value:function(t,r=302){if(!BO.has(r))throw new RangeError("Invalid status code");return new mn(null,{status:r,headers:{location:LO(t)}})},writable:!0,configurable:!0});Object.defineProperty(mn,"json",{value:function(t,r){let a=JSON.stringify(t);if(a===void 0)throw new TypeError("The data is not JSON serializable");let n=r?.headers,i;return n?(i=new Headers(n),i.has("content-type")||i.set("content-type","application/json")):i={"content-type":"application/json"},new mn(a,{status:r?.status??200,statusText:r?.statusText,headers:i})},writable:!0,configurable:!0});async function UO(e){return Promise.race([e,Promise.resolve().then(()=>Promise.resolve(void 0))])}function bT(e,t,r){let a=s=>{e.cancel(s).catch(()=>{})};return t.on("close",a),t.on("error",a),(r??e.read()).then(o,n),e.closed.finally(()=>{t.off("close",a),t.off("error",a)});function n(s){s&&t.destroy(s)}function i(){e.read().then(o,n)}function o({done:s,value:l}){try{if(s)t.end();else if(!t.write(l))t.once("drain",i);else return e.read().then(o,n)}catch(c){n(c)}}}function lT(e,t){if(e.locked)throw new TypeError("ReadableStream is locked.");return t.destroyed?void 0:bT(e.getReader(),t)}var hv=(e,t)=>{let r={};if(e instanceof Headers||(e=new Headers(e??void 0)),e.has("set-cookie")){let a=[];for(let[n,i]of e)n==="set-cookie"?a.push(i):r[n]=i;a.length>0&&(r["set-cookie"]=a)}else for(let[a,n]of e)r[a]=n;return t&&(r["content-type"]??=t),r},zp=Symbol("outgoingEnded"),cT=Symbol("incomingDraining"),FO=500,qO=64*1024*1024,vT=e=>{let t=e;if(e.destroyed||t[cT])return;if(t[cT]=!0,e instanceof $n){try{e.stream?.close?.(fO.NGHTTP2_NO_ERROR)}catch{}return}let r=0,a=()=>{clearTimeout(i),e.off("data",o),e.off("end",a),e.off("error",a)},n=()=>{a();let s=e.socket;s&&!s.destroyed&&(typeof s.destroySoon=="function"?s.destroySoon():typeof s.destroy=="function"&&s.destroy())},i=setTimeout(n,FO);i.unref?.();let o=s=>{r+=s.length,r>qO&&n()};e.on("data",o),e.on("end",a),e.on("error",a),e.resume()},HO=(e,t,r,a)=>()=>{t.errored?(aT(t),e[mv](t.errored.toString())):(!r.writableFinished||t instanceof $n&&t.aborted)&&(aT(t),e[mv]("Client connection prematurely closed.")),a&&!t.readableEnded&&setTimeout(()=>{t.readableEnded||setTimeout(()=>{vT(t)})})},GO=e=>{if(!(Rn in e))return!1;let t=e[Rn][1];return t===null||typeof t=="string"||t instanceof Uint8Array},VO=()=>new Response(null,{status:400}),yT=e=>new Response(null,{status:e instanceof Error&&(e.name==="TimeoutError"||e.constructor.name==="TimeoutError")?504:500}),Ip=(e,t)=>{let r=e instanceof Error?e:new Error("unknown error",{cause:e});r.code==="ERR_STREAM_PREMATURE_CLOSE"?console.info("The user aborted a request."):(console.error(e),t.headersSent||(t instanceof hO&&(t._contentLength=null),t.writeHead(500,{"Content-Type":"text/plain"})),t.end(`Error: ${r.message}`),t.destroy(r))},fv=e=>{"flushHeaders"in e&&e.writable&&e.flushHeaders()},kT=(e,t,r)=>{let a=e;return a._contentLength===null&&a._hasBody&&a.useChunkedEncodingByDefault&&!a._removedContLen&&t>=200&&t!==204&&t!==304&&!e.hasHeader("content-length")&&!e.hasHeader("transfer-encoding")&&!e.hasHeader("trailer")?(a._contentLength=r,!0):!1},uv=(e,t,r)=>{kT(e,t,r)?e.writeHead(t,{"Content-Type":Jr}):e.writeHead(t,{"Content-Type":Jr,"Content-Length":r})},_T=async(e,t)=>{let[r,a,n]=e[Rn];if(!n){a===null?(t.writeHead(r),t.end()):typeof a=="string"?(uv(t,r,Buffer.byteLength(a)),t.end(a)):a instanceof Uint8Array?(uv(t,r,a.byteLength),t.end(a)):a instanceof Blob?(uv(t,r,a.size),t.end(new Uint8Array(await a.arrayBuffer()))):(t.writeHead(r,{"Content-Type":Jr}),fv(t),await lT(a,t)?.catch(l=>Ip(l,t))),t[zp]?.();return}let i=!1,o=!1,s=!0;if(n instanceof Headers)i=n.has("content-length"),n=hv(n,a===null?void 0:Jr);else if(Array.isArray(n)){let l=new Headers(n);i=l.has("content-length"),n=hv(l,a===null?void 0:Jr)}else{o=!0;for(let l in n){if(l.length===14&&l.toLowerCase()==="content-length"){i=!0;break}(l.length===17&&l.toLowerCase()==="transfer-encoding"||l.length===7&&l.toLowerCase()==="trailer")&&(s=!1)}}if(!i){let l;typeof a=="string"?l=Buffer.byteLength(a):a instanceof Uint8Array?l=a.byteLength:a instanceof Blob&&(l=a.size),l!==void 0&&(!o||!s||!kT(t,r,l))&&(o&&(n={...n}),n["Content-Length"]=l)}t.writeHead(r,n),a==null?t.end():typeof a=="string"||a instanceof Uint8Array?t.end(a):a instanceof Blob?t.end(new Uint8Array(await a.arrayBuffer())):(fv(t),await lT(a,t)?.catch(l=>Ip(l,t))),t[zp]?.()},wT=e=>typeof e.then=="function",WO=async(e,t,r={})=>{if(wT(e))if(r.errorHandler)try{e=await e}catch(n){let i=await r.errorHandler(n);if(!i)return;e=i}else e=await e.catch(yT);if(Rn in e)return _T(e,t);let a=hv(e.headers,e.body===null?void 0:Jr);if(e.body){let n=e.body.getReader(),i=[],o=!1,s;if(a["transfer-encoding"]!=="chunked"){let l=2;for(let c=0;c<l;c++){s||=n.read();let u=await UO(s).catch(d=>{console.error(d),o=!0});if(!u){if(c===1){await new Promise(d=>setTimeout(d)),l=3;continue}break}if(s=void 0,u.value&&i.push(u.value),u.done){o=!0;break}}o&&!("content-length"in a)&&(a["content-length"]=i.reduce((c,u)=>c+u.length,0))}t.writeHead(e.status,a),i.forEach(l=>{t.write(l)}),o?t.end():(i.length===0&&fv(t),await bT(n,t,s))}else a[Qx]||(t.writeHead(e.status,a),t.end());t[zp]?.()},_v=(e,t={})=>{let r=t.autoCleanupIncoming??!0;return t.overrideGlobalObjects!==!1&&global.Request!==Si&&(Object.defineProperty(global,"Request",{value:Si}),Object.defineProperty(global,"Response",{value:mn})),async(a,n)=>{let i,o,s=!1,l=!1,c=()=>{!o||l||(l=!0,n.on("close",HO(o,a,n,s)))};try{if(o=DO(a,t.hostname),s=r&&!(a.method==="GET"||a.method==="HEAD"),s&&(a[pT]=!0,a instanceof $n&&(n[zp]=()=>{a.readableEnded||setTimeout(()=>{a.readableEnded||setTimeout(()=>{a.destroy(),n.destroy()})})})),i=e(o,{incoming:a,outgoing:n}),!wT(i)&&GO(i))return s&&!a.readableEnded&&n.once("finish",()=>{a.readableEnded||vT(a)}),_T(i,n);c()}catch(u){if(i)return Ip(u,n);if(t.errorHandler){if(c(),i=await t.errorHandler(o?u:SO(u)),!i)return}else o?i=yT(u):i=VO()}try{return await WO(i,n,t)}catch(u){return Ip(u,n)}}},KO=globalThis.CloseEvent??class extends Event{#e;constructor(e,t={}){super(e,t),this.#e=t}get wasClean(){return this.#e.wasClean??!1}get code(){return this.#e.code??0}get reason(){return this.#e.reason??""}},ZO=globalThis.ErrorEvent??class extends Event{#e;constructor(e,t={}){super(e,t),this.#e=t}get message(){return this.#e.message??""}get filename(){return this.#e.filename??""}get lineno(){return this.#e.lineno??0}get colno(){return this.#e.colno??0}get error(){return this.#e.error??null}},JO=()=>Symbol("connection"),YO=Symbol("CONNECTION_SYMBOL_KEY"),XO=Symbol("WAIT_FOR_WEBSOCKET_SYMBOL");var e5=eT(async(e,t,r)=>{if(e.req.header("upgrade")?.toLowerCase()!=="websocket")return;let a=e.env,n=a[XO];if(!n||!a.incoming)return new Response(null,{status:500});let i=JO();return a[YO]=i,(async()=>{let o;try{o=await n(a.incoming,i)}catch{return}let s=[],l=(d,m)=>{s.push([d,m])};o.on("message",l);let c={binaryType:"arraybuffer",close(d,m){o.close(d,m)},protocol:o.protocol,raw:o,get readyState(){return o.readyState},send(d,m){o.send(d,{compress:m?.compress})},url:new URL(e.req.url)};try{t?.onOpen?.(new Event("open"),c)}catch(d){(r?.onError??console.error)(d)}let u=(d,m)=>{let p=Array.isArray(d)?d:[d];for(let g of p)try{t?.onMessage?.(new MessageEvent("message",{data:m?g instanceof ArrayBuffer?g:g.buffer.slice(g.byteOffset,g.byteOffset+g.byteLength):typeof g=="string"?g:Buffer.from(g).toString("utf-8")}),c)}catch(h){(r?.onError??console.error)(h)}};o.off("message",l);for(let d of s)u(...d);o.on("message",(d,m)=>{u(d,m)}),o.on("close",(d,m)=>{try{t?.onClose?.(new KO("close",{code:d,reason:m.toString()}),c)}catch(p){(r?.onError??console.error)(p)}}),o.on("error",d=>{try{t?.onError?.(new ZO("error",{error:d}),c)}catch(m){(r?.onError??console.error)(m)}})})(),new Response});var AT=ng(TT(),1);function sN(e){if(e)try{return AT.default.parse(e).type}catch{let t=(e.split(";",1)[0]??"").trim().toLowerCase();return t===""||e.slice(t.length).includes(",")?void 0:t}}function CT(e){return e==="application/json"?!0:sN(e)==="application/json"}function zT(e){return`Payload Too Large: Request body must not exceed ${e} bytes`}function IT(e){if(e===void 0)return 4194304;if(typeof e!="number"||!Number.isFinite(e)||e<=0)throw new RangeError(`maxRequestBodySize must be a positive number of bytes, got ${String(e)}`);return e}async function PT(e,t=4194304){if(Number(e.headers.get("content-length"))>t)return{tooLarge:!0};if(e.body===null)return{tooLarge:!1,text:""};let r=e.body.getReader(),a=new TextDecoder,n=0,i="";try{for(;;){let{done:o,value:s}=await r.read();if(o)break;if(n+=s.byteLength,n>t)return{tooLarge:!0};i+=a.decode(s,{stream:!0})}}finally{r.releaseLock()}return{tooLarge:!1,text:i+a.decode()}}function RT(e,t){if(!Number.isFinite(e)||e<1)return;let r=setInterval(t,Math.min(e,2147483647));return r.unref?.(),r}var Pp=class{constructor(t={}){this._started=!1,this._hasHandledRequest=!1,this._streamMapping=new Map,this._requestToStreamMapping=new Map,this._resumableStreams=new Set,this._requestResponseMap=new Map,this._initialized=!1,this._enableJsonResponse=!1,this._standaloneSseStreamId="_GET_stream",this._closed=!1,this.sessionIdGenerator=t.sessionIdGenerator,this._enableJsonResponse=t.enableJsonResponse??!1,this._eventStore=t.eventStore,this._onsessioninitialized=t.onsessioninitialized,this._onsessionclosed=t.onsessionclosed,this._allowedHosts=t.allowedHosts,this._allowedOrigins=t.allowedOrigins,this._enableDnsRebindingProtection=t.enableDnsRebindingProtection??!1,this._retryInterval=t.retryInterval,this._keepAliveMs=t.keepAliveMs??15e3,this._maxRequestBodySize=IT(t.maxRequestBodySize)}startKeepAlive(t,r){if(this._closed)return;let a=RT(this._keepAliveMs,()=>{try{t.enqueue(r.encode(`: keepalive
|
|
72
|
+
`}var Sp=class{constructor(t=Xx.stdin,r=Xx.stdout,a){this._stdin=t,this._stdout=r,this._started=!1,this._ondata=n=>{try{this._readBuffer.append(n),this.processReadBuffer()}catch(i){this.onerror?.(i),this.close().catch(()=>{})}},this._onerror=n=>{this.onerror?.(n)},this._readBuffer=new wp({maxBufferSize:a?.maxBufferSize})}async start(){if(this._started)throw new Error("StdioServerTransport already started! If using Server class, note that connect() calls start() automatically.");this._started=!0,this._stdin.on("data",this._ondata),this._stdin.on("error",this._onerror)}processReadBuffer(){for(;;)try{let t=this._readBuffer.readMessage();if(t===null)break;this.onmessage?.(t)}catch(t){this.onerror?.(t)}}async close(){this._stdin.off("data",this._ondata),this._stdin.off("error",this._onerror),this._stdin.listenerCount("data")===0&&this._stdin.pause(),this._readBuffer.clear(),this.onclose?.()}send(t){return new Promise(r=>{let a=Yx(t);this._stdout.write(a)?r():this._stdout.once("drain",r)})}};var Qx="x-hono-already-sent";import{STATUS_CODES as YV,ServerResponse as hO,createServer as XV}from"node:http";import{Http2ServerRequest as $n,constants as fO}from"node:http2";import{Readable as tT}from"node:stream";var eT=e=>((...t)=>{if(typeof t[0]=="function"){let[r,a]=t;return async function(i,o){let s=await e(i,await r(i),a);if(s)return s;await o()}}else{let[r,a,n]=t;return(async()=>{let i=await e(r,a,n);if(!i)throw new Error("Failed to upgrade WebSocket");return i})()}});var pn=class extends Error{constructor(e,t){super(e,t),this.name="RequestError"}},bO=new Set(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","server","user-agent"]),vO=/^[!#$%&'*+\-.^_`|~\dA-Za-z]+$/,Ep=e=>e===9||e===10||e===13||e===32,nT=e=>{if(!Ep(e.charCodeAt(0))&&!Ep(e.charCodeAt(e.length-1)))return e;let t=0,r=e.length;for(;t<r&&Ep(e.charCodeAt(t));)t++;for(;r>t&&Ep(e.charCodeAt(r-1));)r--;return e.slice(t,r)},rT=/[\0\r\n]/,bv=globalThis.Headers,uT=(e,t=bv)=>{let r=new t;for(let a=0;a<e.length;a+=2){let n=e[a];n.startsWith(":")||r.append(n,e[a+1])}return r},vv=class{#e;#t;#r;#a;constructor(e){this.#e=e,e instanceof $n&&(this.#t=e.rawHeaders.slice())}get#i(){return this.#t??=this.#e.rawHeaders.slice()}get#n(){return this.#r||(this.#r=uT(this.#i),this.#t=void 0),this.#r}#o(e){if(typeof e=="string"){if(!vO.test(e))throw new TypeError(`Invalid header name: ${e}`);return e.toLowerCase()}}#s(e){let t=this.#e instanceof $n?void 0:this.#e.headers;if(!t||bO.has(e)||e==="set-cookie"||e==="__proto__")return;if(!Object.hasOwn(t,e))return null;let r=t[e];if(typeof r=="string"){let a=nT(r);return rT.test(a)?void 0:a}}#l(e,t){let r=t==="cookie"?"; ":", ",a=null;for(let n=0;n<e.length;n+=2){let i=e[n];if(i.length===t.length&&i.toLowerCase()===t){let o=nT(e[n+1]);if(rT.test(o)){this.#a=!0;return}a=a===null?o:a+r+o}}return a}append(e,t){this.#n.append(e,t)}delete(e){this.#n.delete(e)}get(e){let t=this.#o(e);if(t&&!this.#r&&!this.#a){let r=this.#s(t);if(r!==void 0)return r;let a=this.#l(this.#i,t);if(a!==void 0)return a}return this.#n.get(e)}has(e){let t=this.#o(e);if(t&&!this.#r&&!this.#a){let r=this.#s(t);if(r!==void 0)return r!==null;let a=this.#l(this.#i,t);if(a!==void 0)return a!==null}return this.#n.has(e)}set(e,t){this.#n.set(e,t)}getSetCookie(){return this.#n.getSetCookie()}keys(){return this.#n.keys()}values(){return this.#n.values()}entries(){return this.#n.entries()}forEach(e,t){this.#n.forEach((r,a)=>{e.call(t,r,a,this)})}[Symbol.iterator](){return this.entries()}};Object.defineProperty(vv.prototype,Symbol.for("nodejs.util.inspect.custom"),{value:function(e,t,r){return`Headers (lightweight) ${r(Object.fromEntries(this),{...t,depth:e==null?null:e-1})}`}});Object.setPrototypeOf(vv.prototype,bv.prototype);var dT=e=>globalThis.Headers===bv?new vv(e):uT(e.rawHeaders,globalThis.Headers),yO=/^\/[!#$&-;=?-\[\]_a-z~]*$/,kO=/\/\.\.?(?:[/?#]|$)/,_O=/^[a-z0-9._-]+(?::(?:[1-5]\d{3,4}|[6-9]\d{3}))?$/,wO=(e,t,r)=>{let a=`${e}://${t}${r}`;if(_O.test(t)){if(r.length===0)return a+"/";if(r.charCodeAt(0)!==47)throw new pn("Invalid URL");return!yO.test(r)||kO.test(r)?new URL(a).href:a}else{let n=new URL(a);if(n.hostname.length!==t.length&&n.hostname!==(t.includes(":")?t.replace(/:\d+$/,""):t).toLowerCase())throw new pn("Invalid host header");return n.href}},SO=e=>e instanceof pn?e:new pn(e.message,{cause:e}),EO=global.Request,Si=class extends EO{constructor(e,t){if(typeof e=="object"&&gr in e){let r=t!==void 0&&"body"in t&&t.body!=null;if(e[jn]&&!r)throw new TypeError("Cannot construct a Request with a Request object that has already been used.");e=e[gr]()}typeof t?.body?.getReader<"u"&&(t.duplex??="half"),super(e,t)}},pT=Symbol("wrapBodyStream"),xO=new Set(["latin1","binary","hex","base64","base64url"]),TO=e=>e===null||xO.has(e),cv=Symbol("bodyBufferedBeforeDisconnect"),dv=Symbol("bodyBufferedLengthBeforeDisconnect"),mT=(e,t)=>Buffer.isBuffer(e)?e:Buffer.from(e,t??"utf8"),yv=e=>!(e instanceof $n)&&!!e.complete&&!!e.readableAborted&&typeof e.read=="function"&&TO(e.readableEncoding),aT=e=>{if(e.readableDidRead||!yv(e))return;let t=e;t[dv]??=e.readableLength},Tp=(e,t)=>{if(e.readableDidRead&&!t||!yv(e))return;let r=e;if(r[cv]!==void 0)return r[cv];let a,n=e.errored;if(n&&n.code!=="ECONNRESET")a=n;else if(r[dv]!==void 0&&e.readableLength!==r[dv])a=Ap();else{let i=t??[],o=e.read();o!==null&&i.push(mT(o,e.readableEncoding));let s=i.length===1?i[0]:Buffer.concat(i);a=s;let l=e.headers["content-length"];if(typeof l=="string"&&/^\d+$/.test(l)){let c=Number(l);Number.isSafeInteger(c)&&s.length!==c&&(a=Ap())}}return r[cv]=a,a},iT=(e,t)=>{if(t instanceof Error){e.error(t);return}t.length>0&&e.enqueue(t),e.close()},AO=(e,t,r,a,n)=>{let i={method:e,headers:r,signal:n.signal};if(e==="TRACE"){i.method="GET";let o=new Si(t,i);return Object.defineProperty(o,"method",{get(){return"TRACE"}}),o}if(!(e==="GET"||e==="HEAD"))if("rawBody"in a&&a.rawBody instanceof Buffer)i.body=new ReadableStream({start(o){o.enqueue(a.rawBody),o.close()}});else if(a[pT]){let o;i.body=new ReadableStream({async pull(s){try{if(!o){let u=Tp(a);if(u!==void 0){iT(s,u);return}}o||=tT.toWeb(a).getReader();let{done:l,value:c}=await o.read();l?s.close():s.enqueue(c)}catch(l){s.error(l)}}})}else{let o=Tp(a);o!==void 0?i.body=new ReadableStream({start(s){iT(s,o)}}):i.body=tT.toWeb(a)}return new Si(t,i)},gr=Symbol("getRequestCache"),Pn=Symbol("requestCache"),Ei=Symbol("incomingKey"),Us=Symbol("urlKey"),gT=Symbol("methodKey"),hT=Symbol("headersKey"),Ls=Symbol("abortControllerKey"),pv=Symbol("getAbortController"),mv=Symbol("abortRequest"),mr=Symbol("bodyBuffer"),xp=Symbol("bodyReadPromise"),jn=Symbol("bodyConsumedDirectly"),oT=Symbol("bodyLockReader"),Bs=Symbol("abortReason"),Ap=()=>new TypeError("Body is unusable"),Fs=()=>Promise.reject(Ap()),CO=new TextDecoder,zO=e=>{if(e[jn])return Fs();e[jn]=!0},IO=e=>e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength),PO=e=>(e[hT]||=dT(e[Ei])).get("content-type")||"",RO=/^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/,$O=e=>{if(typeof e!="string"||e.length===0)return"GET";switch(e){case"DELETE":case"GET":case"HEAD":case"OPTIONS":case"PATCH":case"POST":case"PUT":case"QUERY":return e}let t=e.toUpperCase();switch(t){case"DELETE":case"GET":case"HEAD":case"OPTIONS":case"POST":case"PUT":return t;default:return e}},jO=e=>{if(!RO.test(e))return new TypeError(`'${e}' is not a valid HTTP method.`);let t=e.toUpperCase();if(t==="CONNECT"||t==="TRACK"||t==="TRACE"&&e!=="TRACE")return new TypeError(`'${e}' HTTP method is unsupported.`)},kv=(e,t,r)=>{if(e[jn])return Fs();let a=e.method;if(a==="GET"||a==="HEAD")return e[gr]()[t]();let n=jO(a);if(n)return Promise.reject(n);if(e[Pn]&&a!=="TRACE")return e[Pn][t]();let i=zO(e);if(i)return i;let o=OO(e);if(o){let s=Promise.resolve(r(o,e));return e[mr]=void 0,s}return NO(e).then(s=>{let l=r(s,e);return e[mr]=void 0,l})},OO=e=>{let t=e[Ei];if("rawBody"in t&&t.rawBody instanceof Buffer)return t.rawBody},sT=(e,t)=>{if(t.errored)return t.errored;let r=e[Bs];return r!==void 0?r instanceof Error?r:new Error(String(r)):new Error("Client connection prematurely closed.")},NO=e=>{if(e[mr])return Promise.resolve(e[mr]);if(e[xp])return e[xp];let t=e[Ei];if(t.readableDidRead)return Fs();let r=Tp(t);if(r!==void 0)return r instanceof Error?Promise.reject(r):(e[mr]=r,Promise.resolve(r));let a=new Promise((n,i)=>{let o=[],s=!1,l=h=>{s||(s=!0,g(),h())},c=h=>{let f=t.errored??h;return!yv(t)||f&&f.code!=="ECONNRESET"?!1:(l(()=>{let _=Tp(t,o);_ instanceof Error?i(_):_===void 0?i(h??sT(e,t)):(e[mr]=_,n(_))}),!0)},u=h=>{o.push(mT(h,t.readableEncoding))},d=()=>{l(()=>{let h=o.length===1?o[0]:Buffer.concat(o);e[mr]=h,n(h)})},m=h=>{c(h)||l(()=>{i(h)})},p=()=>{if(t.readableEnded){d();return}c()||l(()=>{i(sT(e,t))})},g=()=>{t.off("data",u),t.off("end",d),t.off("error",m),t.off("close",p),e[xp]=void 0};t.on("data",u),t.on("end",d),t.on("error",m),t.on("close",p),queueMicrotask(()=>{s||(t.readableEnded?d():t.errored?m(t.errored):t.destroyed&&p())})});return e[xp]=a,a},gn={get method(){return this[gT]},get url(){return this[Us]},get headers(){return this[hT]||=dT(this[Ei])},[mv](e){this[Bs]===void 0&&(this[Bs]=e);let t=this[Ls];t&&!t.signal.aborted&&t.abort(e)},[pv](){return this[Ls]||=new AbortController,this[Bs]!==void 0&&!this[Ls].signal.aborted&&this[Ls].abort(this[Bs]),this[Ls]},[gr](){let e=this[pv]();if(this[Pn])return this[Pn];let t=this.method;if(this[jn]&&!(t==="GET"||t==="HEAD")){this[mr]=void 0;let r={method:t==="TRACE"?"GET":t,headers:this.headers,signal:e.signal};t!=="TRACE"&&(r.body=new ReadableStream({start(n){n.close()}}),r.duplex="half");let a=new Si(this[Us],r);return t==="TRACE"&&Object.defineProperty(a,"method",{get(){return"TRACE"}}),this[Pn]=a}return this[Pn]=AO(this.method,this[Us],this.headers,this[Ei],e)},get body(){if(!this[jn])return this[gr]().body;let e=this[gr]();return!this[oT]&&e.body&&(this[oT]=e.body.getReader()),e.body},get bodyUsed(){return this[jn]?!0:this[Pn]?this[Pn].bodyUsed:!1}};Object.defineProperty(gn,"signal",{get(){return this[pv]().signal}});["cache","credentials","destination","integrity","mode","redirect","referrer","referrerPolicy","keepalive"].forEach(e=>{Object.defineProperty(gn,e,{get(){return this[gr]()[e]}})});["clone","formData"].forEach(e=>{Object.defineProperty(gn,e,{value:function(){if(this[jn]){if(e==="clone")throw Ap();return Fs()}return this[gr]()[e]()}})});Object.defineProperty(gn,"text",{value:function(){return kv(this,"text",e=>CO.decode(e))}});Object.defineProperty(gn,"arrayBuffer",{value:function(){return kv(this,"arrayBuffer",e=>IO(e))}});Object.defineProperty(gn,"blob",{value:function(){return kv(this,"blob",(e,t)=>{let r=PO(t),a=r?{headers:{"content-type":r}}:void 0;return new Response(e,a).blob()})}});Object.defineProperty(gn,"json",{value:function(){return this[jn]?Fs():this.text().then(JSON.parse)}});Object.defineProperty(gn,Symbol.for("nodejs.util.inspect.custom"),{value:function(e,t,r){return`Request (lightweight) ${r({method:this.method,url:this.url,headers:this.headers,nativeRequest:this[Pn]},{...t,depth:e==null?null:e-1})}`}});Object.setPrototypeOf(gn,Si.prototype);var DO=(e,t)=>{let r=Object.create(gn);r[Ei]=e,r[gT]=$O(e.method);let a=e.url||"";if(a[0]!=="/"&&(a.startsWith("http://")||a.startsWith("https://"))){if(e instanceof $n)throw new pn("Absolute URL for :path is not allowed in HTTP/2");try{r[Us]=new URL(a).href}catch(o){throw new pn("Invalid absolute URL",{cause:o})}return r}let n=(e instanceof $n?e.authority:e.headers.host)||t;if(!n)throw new pn("Missing host header");let i;if(e instanceof $n){if(i=e.scheme,!(i==="http"||i==="https"))throw new pn("Unsupported scheme")}else i=e.socket&&e.socket.encrypted?"https":"http";try{r[Us]=wO(i,n,a)}catch(o){throw o instanceof pn?o:new pn("Invalid URL",{cause:o})}return r},Jr="text/plain; charset=UTF-8",gv=Symbol("responseCache"),wi=Symbol("getResponseCache"),Rn=Symbol("cache"),Cp=global.Response,mn=class fT{#e;#t;[wi](){let t=this[Rn],r=t&&t[2]instanceof Headers?t[2]:void 0;return delete this[Rn],this[gv]||=new Cp(this.#e,r?{status:this.#t?.status,statusText:this.#t?.statusText,headers:r}:this.#t)}constructor(t,r){let a;if(this.#e=t,r instanceof Cp){let n=r[gv];if(n){this.#t=n,this[wi]();return}this.#t=r instanceof fT?r.#t:r,a=new Headers(r.headers)}else this.#t=r;(t==null||typeof t=="string"||typeof t?.getReader<"u"||t instanceof Blob||t instanceof Uint8Array)&&(this[Rn]=[r?.status||200,t??null,a||r?.headers])}get headers(){let t=this[Rn];return t?(t[2]instanceof Headers||(t[2]=new Headers(t[2]||(t[1]===null?void 0:{"content-type":Jr}))),t[2]):this[wi]().headers}get status(){return this[Rn]?.[0]??this[wi]().status}get ok(){let t=this.status;return t>=200&&t<300}};["body","bodyUsed","redirected","statusText","trailers","type","url"].forEach(e=>{Object.defineProperty(mn.prototype,e,{get(){return this[wi]()[e]}})});["arrayBuffer","blob","clone","formData","json","text"].forEach(e=>{Object.defineProperty(mn.prototype,e,{value:function(){return this[wi]()[e]()}})});Object.defineProperty(mn.prototype,Symbol.for("nodejs.util.inspect.custom"),{value:function(e,t,r){return`Response (lightweight) ${r({status:this.status,headers:this.headers,ok:this.ok,nativeResponse:this[gv]},{...t,depth:e==null?null:e-1})}`}});Object.setPrototypeOf(mn,Cp);Object.setPrototypeOf(mn.prototype,Cp.prototype);var MO=/^https?:\/\/[!#-;=?-[\]_a-z~A-Z]+$/,LO=e=>e instanceof URL?e.href:MO.test(e)?e:new URL(e).href,BO=new Set([301,302,303,307,308]);Object.defineProperty(mn,"redirect",{value:function(t,r=302){if(!BO.has(r))throw new RangeError("Invalid status code");return new mn(null,{status:r,headers:{location:LO(t)}})},writable:!0,configurable:!0});Object.defineProperty(mn,"json",{value:function(t,r){let a=JSON.stringify(t);if(a===void 0)throw new TypeError("The data is not JSON serializable");let n=r?.headers,i;return n?(i=new Headers(n),i.has("content-type")||i.set("content-type","application/json")):i={"content-type":"application/json"},new mn(a,{status:r?.status??200,statusText:r?.statusText,headers:i})},writable:!0,configurable:!0});async function UO(e){return Promise.race([e,Promise.resolve().then(()=>Promise.resolve(void 0))])}function bT(e,t,r){let a=s=>{e.cancel(s).catch(()=>{})};return t.on("close",a),t.on("error",a),(r??e.read()).then(o,n),e.closed.finally(()=>{t.off("close",a),t.off("error",a)});function n(s){s&&t.destroy(s)}function i(){e.read().then(o,n)}function o({done:s,value:l}){try{if(s)t.end();else if(!t.write(l))t.once("drain",i);else return e.read().then(o,n)}catch(c){n(c)}}}function lT(e,t){if(e.locked)throw new TypeError("ReadableStream is locked.");return t.destroyed?void 0:bT(e.getReader(),t)}var hv=(e,t)=>{let r={};if(e instanceof Headers||(e=new Headers(e??void 0)),e.has("set-cookie")){let a=[];for(let[n,i]of e)n==="set-cookie"?a.push(i):r[n]=i;a.length>0&&(r["set-cookie"]=a)}else for(let[a,n]of e)r[a]=n;return t&&(r["content-type"]??=t),r},zp=Symbol("outgoingEnded"),cT=Symbol("incomingDraining"),FO=500,qO=64*1024*1024,vT=e=>{let t=e;if(e.destroyed||t[cT])return;if(t[cT]=!0,e instanceof $n){try{e.stream?.close?.(fO.NGHTTP2_NO_ERROR)}catch{}return}let r=0,a=()=>{clearTimeout(i),e.off("data",o),e.off("end",a),e.off("error",a)},n=()=>{a();let s=e.socket;s&&!s.destroyed&&(typeof s.destroySoon=="function"?s.destroySoon():typeof s.destroy=="function"&&s.destroy())},i=setTimeout(n,FO);i.unref?.();let o=s=>{r+=s.length,r>qO&&n()};e.on("data",o),e.on("end",a),e.on("error",a),e.resume()},HO=(e,t,r,a)=>()=>{t.errored?(aT(t),e[mv](t.errored.toString())):(!r.writableFinished||t instanceof $n&&t.aborted)&&(aT(t),e[mv]("Client connection prematurely closed.")),a&&!t.readableEnded&&setTimeout(()=>{t.readableEnded||setTimeout(()=>{vT(t)})})},GO=e=>{if(!(Rn in e))return!1;let t=e[Rn][1];return t===null||typeof t=="string"||t instanceof Uint8Array},VO=()=>new Response(null,{status:400}),yT=e=>new Response(null,{status:e instanceof Error&&(e.name==="TimeoutError"||e.constructor.name==="TimeoutError")?504:500}),Ip=(e,t)=>{let r=e instanceof Error?e:new Error("unknown error",{cause:e});r.code==="ERR_STREAM_PREMATURE_CLOSE"?console.info("The user aborted a request."):(console.error(e),t.headersSent||(t instanceof hO&&(t._contentLength=null),t.writeHead(500,{"Content-Type":"text/plain"})),t.end(`Error: ${r.message}`),t.destroy(r))},fv=e=>{"flushHeaders"in e&&e.writable&&e.flushHeaders()},kT=(e,t,r)=>{let a=e;return a._contentLength===null&&a._hasBody&&a.useChunkedEncodingByDefault&&!a._removedContLen&&t>=200&&t!==204&&t!==304&&!e.hasHeader("content-length")&&!e.hasHeader("transfer-encoding")&&!e.hasHeader("trailer")?(a._contentLength=r,!0):!1},uv=(e,t,r)=>{kT(e,t,r)?e.writeHead(t,{"Content-Type":Jr}):e.writeHead(t,{"Content-Type":Jr,"Content-Length":r})},_T=async(e,t)=>{let[r,a,n]=e[Rn];if(!n){a===null?(t.writeHead(r),t.end()):typeof a=="string"?(uv(t,r,Buffer.byteLength(a)),t.end(a)):a instanceof Uint8Array?(uv(t,r,a.byteLength),t.end(a)):a instanceof Blob?(uv(t,r,a.size),t.end(new Uint8Array(await a.arrayBuffer()))):(t.writeHead(r,{"Content-Type":Jr}),fv(t),await lT(a,t)?.catch(l=>Ip(l,t))),t[zp]?.();return}let i=!1,o=!1,s=!0;if(n instanceof Headers)i=n.has("content-length"),n=hv(n,a===null?void 0:Jr);else if(Array.isArray(n)){let l=new Headers(n);i=l.has("content-length"),n=hv(l,a===null?void 0:Jr)}else{o=!0;for(let l in n){if(l.length===14&&l.toLowerCase()==="content-length"){i=!0;break}(l.length===17&&l.toLowerCase()==="transfer-encoding"||l.length===7&&l.toLowerCase()==="trailer")&&(s=!1)}}if(!i){let l;typeof a=="string"?l=Buffer.byteLength(a):a instanceof Uint8Array?l=a.byteLength:a instanceof Blob&&(l=a.size),l!==void 0&&(!o||!s||!kT(t,r,l))&&(o&&(n={...n}),n["Content-Length"]=l)}t.writeHead(r,n),a==null?t.end():typeof a=="string"||a instanceof Uint8Array?t.end(a):a instanceof Blob?t.end(new Uint8Array(await a.arrayBuffer())):(fv(t),await lT(a,t)?.catch(l=>Ip(l,t))),t[zp]?.()},wT=e=>typeof e.then=="function",WO=async(e,t,r={})=>{if(wT(e))if(r.errorHandler)try{e=await e}catch(n){let i=await r.errorHandler(n);if(!i)return;e=i}else e=await e.catch(yT);if(Rn in e)return _T(e,t);let a=hv(e.headers,e.body===null?void 0:Jr);if(e.body){let n=e.body.getReader(),i=[],o=!1,s;if(a["transfer-encoding"]!=="chunked"){let l=2;for(let c=0;c<l;c++){s||=n.read();let u=await UO(s).catch(d=>{console.error(d),o=!0});if(!u){if(c===1){await new Promise(d=>setTimeout(d)),l=3;continue}break}if(s=void 0,u.value&&i.push(u.value),u.done){o=!0;break}}o&&!("content-length"in a)&&(a["content-length"]=i.reduce((c,u)=>c+u.length,0))}t.writeHead(e.status,a),i.forEach(l=>{t.write(l)}),o?t.end():(i.length===0&&fv(t),await bT(n,t,s))}else a[Qx]||(t.writeHead(e.status,a),t.end());t[zp]?.()},_v=(e,t={})=>{let r=t.autoCleanupIncoming??!0;return t.overrideGlobalObjects!==!1&&global.Request!==Si&&(Object.defineProperty(global,"Request",{value:Si}),Object.defineProperty(global,"Response",{value:mn})),async(a,n)=>{let i,o,s=!1,l=!1,c=()=>{!o||l||(l=!0,n.on("close",HO(o,a,n,s)))};try{if(o=DO(a,t.hostname),s=r&&!(a.method==="GET"||a.method==="HEAD"),s&&(a[pT]=!0,a instanceof $n&&(n[zp]=()=>{a.readableEnded||setTimeout(()=>{a.readableEnded||setTimeout(()=>{a.destroy(),n.destroy()})})})),i=e(o,{incoming:a,outgoing:n}),!wT(i)&&GO(i))return s&&!a.readableEnded&&n.once("finish",()=>{a.readableEnded||vT(a)}),_T(i,n);c()}catch(u){if(i)return Ip(u,n);if(t.errorHandler){if(c(),i=await t.errorHandler(o?u:SO(u)),!i)return}else o?i=yT(u):i=VO()}try{return await WO(i,n,t)}catch(u){return Ip(u,n)}}},KO=globalThis.CloseEvent??class extends Event{#e;constructor(e,t={}){super(e,t),this.#e=t}get wasClean(){return this.#e.wasClean??!1}get code(){return this.#e.code??0}get reason(){return this.#e.reason??""}},ZO=globalThis.ErrorEvent??class extends Event{#e;constructor(e,t={}){super(e,t),this.#e=t}get message(){return this.#e.message??""}get filename(){return this.#e.filename??""}get lineno(){return this.#e.lineno??0}get colno(){return this.#e.colno??0}get error(){return this.#e.error??null}},JO=()=>Symbol("connection"),YO=Symbol("CONNECTION_SYMBOL_KEY"),XO=Symbol("WAIT_FOR_WEBSOCKET_SYMBOL");var n5=eT(async(e,t,r)=>{if(e.req.header("upgrade")?.toLowerCase()!=="websocket")return;let a=e.env,n=a[XO];if(!n||!a.incoming)return new Response(null,{status:500});let i=JO();return a[YO]=i,(async()=>{let o;try{o=await n(a.incoming,i)}catch{return}let s=[],l=(d,m)=>{s.push([d,m])};o.on("message",l);let c={binaryType:"arraybuffer",close(d,m){o.close(d,m)},protocol:o.protocol,raw:o,get readyState(){return o.readyState},send(d,m){o.send(d,{compress:m?.compress})},url:new URL(e.req.url)};try{t?.onOpen?.(new Event("open"),c)}catch(d){(r?.onError??console.error)(d)}let u=(d,m)=>{let p=Array.isArray(d)?d:[d];for(let g of p)try{t?.onMessage?.(new MessageEvent("message",{data:m?g instanceof ArrayBuffer?g:g.buffer.slice(g.byteOffset,g.byteOffset+g.byteLength):typeof g=="string"?g:Buffer.from(g).toString("utf-8")}),c)}catch(h){(r?.onError??console.error)(h)}};o.off("message",l);for(let d of s)u(...d);o.on("message",(d,m)=>{u(d,m)}),o.on("close",(d,m)=>{try{t?.onClose?.(new KO("close",{code:d,reason:m.toString()}),c)}catch(p){(r?.onError??console.error)(p)}}),o.on("error",d=>{try{t?.onError?.(new ZO("error",{error:d}),c)}catch(m){(r?.onError??console.error)(m)}})})(),new Response});var AT=ng(TT(),1);function sN(e){if(e)try{return AT.default.parse(e).type}catch{let t=(e.split(";",1)[0]??"").trim().toLowerCase();return t===""||e.slice(t.length).includes(",")?void 0:t}}function CT(e){return e==="application/json"?!0:sN(e)==="application/json"}function zT(e){return`Payload Too Large: Request body must not exceed ${e} bytes`}function IT(e){if(e===void 0)return 4194304;if(typeof e!="number"||!Number.isFinite(e)||e<=0)throw new RangeError(`maxRequestBodySize must be a positive number of bytes, got ${String(e)}`);return e}async function PT(e,t=4194304){if(Number(e.headers.get("content-length"))>t)return{tooLarge:!0};if(e.body===null)return{tooLarge:!1,text:""};let r=e.body.getReader(),a=new TextDecoder,n=0,i="";try{for(;;){let{done:o,value:s}=await r.read();if(o)break;if(n+=s.byteLength,n>t)return{tooLarge:!0};i+=a.decode(s,{stream:!0})}}finally{r.releaseLock()}return{tooLarge:!1,text:i+a.decode()}}function RT(e,t){if(!Number.isFinite(e)||e<1)return;let r=setInterval(t,Math.min(e,2147483647));return r.unref?.(),r}var Pp=class{constructor(t={}){this._started=!1,this._hasHandledRequest=!1,this._streamMapping=new Map,this._requestToStreamMapping=new Map,this._resumableStreams=new Set,this._requestResponseMap=new Map,this._initialized=!1,this._enableJsonResponse=!1,this._standaloneSseStreamId="_GET_stream",this._closed=!1,this.sessionIdGenerator=t.sessionIdGenerator,this._enableJsonResponse=t.enableJsonResponse??!1,this._eventStore=t.eventStore,this._onsessioninitialized=t.onsessioninitialized,this._onsessionclosed=t.onsessionclosed,this._allowedHosts=t.allowedHosts,this._allowedOrigins=t.allowedOrigins,this._enableDnsRebindingProtection=t.enableDnsRebindingProtection??!1,this._retryInterval=t.retryInterval,this._keepAliveMs=t.keepAliveMs??15e3,this._maxRequestBodySize=IT(t.maxRequestBodySize)}startKeepAlive(t,r){if(this._closed)return;let a=RT(this._keepAliveMs,()=>{try{t.enqueue(r.encode(`: keepalive
|
|
73
73
|
|
|
74
74
|
`))}catch{a!==void 0&&clearInterval(a)}});return a}async start(){if(this._started)throw new Error("Transport already started");this._started=!0}createJsonErrorResponse(t,r,a,n){let i={code:r,message:a};return n?.data!==void 0&&(i.data=n.data),new Response(JSON.stringify({jsonrpc:"2.0",error:i,id:null}),{status:t,headers:{"Content-Type":"application/json",...n?.headers}})}validateRequestHeaders(t){if(this._enableDnsRebindingProtection){if(this._allowedHosts&&this._allowedHosts.length>0){let r=t.headers.get("host");if(!r||!this._allowedHosts.includes(r)){let a=`Invalid Host header: ${r}`;return this.onerror?.(new Error(a)),this.createJsonErrorResponse(403,-32e3,a)}}if(this._allowedOrigins&&this._allowedOrigins.length>0){let r=t.headers.get("origin");if(r&&!this._allowedOrigins.includes(r)){let a=`Invalid Origin header: ${r}`;return this.onerror?.(new Error(a)),this.createJsonErrorResponse(403,-32e3,a)}}}}async handleRequest(t,r){if(this._closed)return this.createJsonErrorResponse(404,-32001,"Session not found");if(!this.sessionIdGenerator&&this._hasHandledRequest)throw new Error("Stateless transport cannot be reused across requests. Create a new transport per request.");this._hasHandledRequest=!0;let a=this.validateRequestHeaders(t);if(a)return a;switch(t.method){case"POST":return this.handlePostRequest(t,r);case"GET":return this.handleGetRequest(t);case"DELETE":return this.handleDeleteRequest(t);default:return this.handleUnsupportedRequest()}}async writePrimingEvent(t,r,a,n){if(!this._eventStore||n<"2025-11-25")return;let i=await this._eventStore.storeEvent(a,{}),o=`id: ${i}
|
|
75
75
|
data:
|
|
@@ -82,7 +82,7 @@ data:
|
|
|
82
82
|
`;return n&&(i+=`id: ${n}
|
|
83
83
|
`),i+=`data: ${JSON.stringify(a)}
|
|
84
84
|
|
|
85
|
-
`,t.enqueue(r.encode(i)),!0}catch(i){return this.onerror?.(i),!1}}handleUnsupportedRequest(){return this.onerror?.(new Error("Method not allowed.")),new Response(JSON.stringify({jsonrpc:"2.0",error:{code:-32e3,message:"Method not allowed."},id:null}),{status:405,headers:{Allow:"GET, POST, DELETE","Content-Type":"application/json"}})}async handlePostRequest(t,r){try{let a=t.headers.get("accept");if(!a?.includes("application/json")||!a.includes("text/event-stream"))return this.onerror?.(new Error("Not Acceptable: Client must accept both application/json and text/event-stream")),this.createJsonErrorResponse(406,-32e3,"Not Acceptable: Client must accept both application/json and text/event-stream");let n=t.headers.get("content-type");if(!CT(n))return this.onerror?.(new Error("Unsupported Media Type: Content-Type must be application/json")),this.createJsonErrorResponse(415,-32e3,"Unsupported Media Type: Content-Type must be application/json");let i={headers:Object.fromEntries(t.headers.entries()),url:new URL(t.url)},o;if(r?.parsedBody!==void 0)o=r.parsedBody;else try{let b=await PT(t,this._maxRequestBodySize);if(b.tooLarge){let v=zT(this._maxRequestBodySize);return this.onerror?.(new Error(v)),this.createJsonErrorResponse(413,-32e3,v)}o=JSON.parse(b.text)}catch{return this.onerror?.(new Error("Parse error: Invalid JSON")),this.createJsonErrorResponse(400,-32700,"Parse error: Invalid JSON")}if(Array.isArray(o)&&o.length>100)return this.onerror?.(new Error(`Invalid Request: Batch must not exceed ${100} messages`)),this.createJsonErrorResponse(400,-32600,`Invalid Request: Batch must not exceed ${100} messages`);let s;try{Array.isArray(o)?s=o.map(b=>Is.parse(b)):s=[Is.parse(o)]}catch{return this.onerror?.(new Error("Parse error: Invalid JSON-RPC message")),this.createJsonErrorResponse(400,-32700,"Parse error: Invalid JSON-RPC message")}if(this._closed)return this.createJsonErrorResponse(404,-32001,"Session not found");let l=s.some(Xb);if(l){if(this._initialized&&this.sessionId!==void 0)return this.onerror?.(new Error("Invalid Request: Server already initialized")),this.createJsonErrorResponse(400,-32600,"Invalid Request: Server already initialized");if(s.length>1)return this.onerror?.(new Error("Invalid Request: Only one initialization request is allowed")),this.createJsonErrorResponse(400,-32600,"Invalid Request: Only one initialization request is allowed");this.sessionId=this.sessionIdGenerator?.(),this._initialized=!0,this.sessionId&&this._onsessioninitialized&&await Promise.resolve(this._onsessioninitialized(this.sessionId))}if(!l){let b=this.validateSession(t);if(b)return b;let v=this.validateProtocolVersion(t);if(v)return v}if(this._closed)return this.createJsonErrorResponse(404,-32001,"Session not found");if(!s.some(zn)){for(let b of s)this.onmessage?.(b,{authInfo:r?.authInfo,requestInfo:i});return new Response(null,{status:202})}let u=crypto.randomUUID(),d=s.find(b=>Xb(b)),m=d?d.params.protocolVersion:t.headers.get("mcp-protocol-version")??Ox;if(this._enableJsonResponse)return new Promise(b=>{this._streamMapping.set(u,{resolveJson:b,cleanup:()=>{this._streamMapping.delete(u)}});for(let v of s)zn(v)&&this._requestToStreamMapping.set(v.id,u);for(let v of s)this.onmessage?.(v,{authInfo:r?.authInfo,requestInfo:i})});let p=new TextEncoder,g,h,f=new ReadableStream({start:b=>{g=b},cancel:()=>{h!==void 0&&clearInterval(h),this._streamMapping.get(u)?.controller===g&&this._streamMapping.delete(u)}}),_={"Content-Type":"text/event-stream","Cache-Control":"no-cache, no-transform",Connection:"keep-alive","X-Accel-Buffering":"no"};this.sessionId!==void 0&&(_["mcp-session-id"]=this.sessionId);for(let b of s)zn(b)&&(this._streamMapping.set(u,{controller:g,encoder:p,cleanup:()=>{h!==void 0&&clearInterval(h),this._streamMapping.delete(u);try{g.close()}catch{}}}),this._requestToStreamMapping.set(b.id,u));try{await this.writePrimingEvent(g,p,u,m);for(let b of s){let v,C;zn(b)&&this._eventStore&&m>="2025-11-25"&&(v=()=>{this.closeSSEStream(b.id)},C=()=>{this.closeStandaloneSSEStream()}),this.onmessage?.(b,{authInfo:r?.authInfo,requestInfo:i,closeSSEStream:v,closeStandaloneSSEStream:C})}}catch(b){this._streamMapping.get(u)?.cleanup(),this._resumableStreams.delete(u);for(let v of s)zn(v)&&this._requestToStreamMapping.delete(v.id);throw b}return this._streamMapping.get(u)?.controller===g&&(h=this.startKeepAlive(g,p)),new Response(f,{status:200,headers:_})}catch(a){return this.onerror?.(a),this.createJsonErrorResponse(400,-32700,"Parse error",{data:String(a)})}}async handleDeleteRequest(t){let r=this.validateSession(t);if(r)return r;let a=this.validateProtocolVersion(t);if(a)return a;try{return await Promise.resolve(this._onsessionclosed?.(this.sessionId)),new Response(null,{status:200})}finally{await this.close()}}validateSession(t){if(this.sessionIdGenerator===void 0)return;if(!this._initialized)return this.onerror?.(new Error("Bad Request: Server not initialized")),this.createJsonErrorResponse(400,-32e3,"Bad Request: Server not initialized");let r=t.headers.get("mcp-session-id");if(!r)return this.onerror?.(new Error("Bad Request: Mcp-Session-Id header is required")),this.createJsonErrorResponse(400,-32e3,"Bad Request: Mcp-Session-Id header is required");if(r!==this.sessionId)return this.onerror?.(new Error("Session not found")),this.createJsonErrorResponse(404,-32001,"Session not found")}validateProtocolVersion(t){let r=t.headers.get("mcp-protocol-version");if(r!==null&&!fi.includes(r))return this.onerror?.(new Error(`Bad Request: Unsupported protocol version: ${r} (supported versions: ${fi.join(", ")})`)),this.createJsonErrorResponse(400,-32e3,`Bad Request: Unsupported protocol version: ${r} (supported versions: ${fi.join(", ")})`)}async close(){this._closed||(this._closed=!0,this._streamMapping.forEach(({cleanup:t})=>{t()}),this._streamMapping.clear(),this._requestResponseMap.clear(),this._resumableStreams.clear(),this.onclose?.())}closeSSEStream(t){let r=this._requestToStreamMapping.get(t);if(!r)return;let a=this._streamMapping.get(r);a&&a.cleanup()}closeStandaloneSSEStream(){let t=this._streamMapping.get(this._standaloneSseStreamId);t&&t.cleanup()}async send(t,r){let a=r?.relatedRequestId;if((In(t)||bi(t))&&(a=t.id),a===void 0){if(In(t)||bi(t))throw new Error("Cannot send a response on a standalone SSE stream unless resuming a previous client request");let o;this._eventStore&&(o=await this._eventStore.storeEvent(this._standaloneSseStreamId,t));let s=this._streamMapping.get(this._standaloneSseStreamId);if(s===void 0)return;s.controller&&s.encoder&&(o===void 0||!s.replayedEventIds?.has(o))&&this.writeSSEEvent(s.controller,s.encoder,t,o);return}let n=this._requestToStreamMapping.get(a);if(!n)throw new Error(`No connection established for request ID: ${String(a)}`);let i=this._streamMapping.get(n);if(!this._enableJsonResponse){let o;this._eventStore&&(o=await this._eventStore.storeEvent(n,t),i=this._streamMapping.get(n)),i?.controller&&i?.encoder&&(o===void 0||!i.replayedEventIds?.has(o))&&this.writeSSEEvent(i.controller,i.encoder,t,o)&&o!==void 0&&this._resumableStreams.add(n)}if(In(t)||bi(t)){this._requestResponseMap.set(a,t);let o=Array.from(this._requestToStreamMapping.entries()).filter(([l,c])=>c===n).map(([l])=>l);if(o.every(l=>this._requestResponseMap.has(l))){if(!i){if(this._closed){for(let l of o)this._requestResponseMap.delete(l),this._requestToStreamMapping.delete(l);return}if(!this._enableJsonResponse&&this._eventStore&&this._resumableStreams.has(n)){for(let l of o)this._requestResponseMap.delete(l),this._requestToStreamMapping.delete(l);this._resumableStreams.delete(n);return}for(let l of o)this._requestResponseMap.delete(l),this._requestToStreamMapping.delete(l);throw new Error(`No connection established for request ID: ${String(a)}`)}if(this._enableJsonResponse&&i.resolveJson){let l={"Content-Type":"application/json"};this.sessionId!==void 0&&(l["mcp-session-id"]=this.sessionId);let c=o.map(u=>this._requestResponseMap.get(u));c.length===1?i.resolveJson(new Response(JSON.stringify(c[0]),{status:200,headers:l})):i.resolveJson(new Response(JSON.stringify(c),{status:200,headers:l}))}else i.cleanup();for(let l of o)this._requestResponseMap.delete(l),this._requestToStreamMapping.delete(l);this._resumableStreams.delete(n)}}}};var Rp=class{constructor(t={}){this._requestContext=new WeakMap,this._webStandardTransport=new Pp(t),this._requestListener=_v(async r=>{let a=this._requestContext.get(r);return this._webStandardTransport.handleRequest(r,{authInfo:a?.authInfo,parsedBody:a?.parsedBody})},{overrideGlobalObjects:!1})}get sessionId(){return this._webStandardTransport.sessionId}set onclose(t){this._webStandardTransport.onclose=t}get onclose(){return this._webStandardTransport.onclose}set onerror(t){this._webStandardTransport.onerror=t}get onerror(){return this._webStandardTransport.onerror}set onmessage(t){this._webStandardTransport.onmessage=t}get onmessage(){return this._webStandardTransport.onmessage}async start(){return this._webStandardTransport.start()}async close(){return this._webStandardTransport.close()}async send(t,r){return this._webStandardTransport.send(t,r)}async handleRequest(t,r,a){let n=t.auth;await _v(async o=>this._webStandardTransport.handleRequest(o,{authInfo:n,parsedBody:a}),{overrideGlobalObjects:!1})(t,r)}closeSSEStream(t){this._webStandardTransport.closeSSEStream(t)}closeStandaloneSSEStream(){this._webStandardTransport.closeStandaloneSSEStream()}};import{mkdirSync as cN,readFileSync as uN,renameSync as dN,writeFileSync as pN}from"node:fs";import{homedir as mN}from"node:os";import{dirname as gN,join as hN}from"node:path";var fN=400;function $T(e=()=>new Date){let t=[];return{where:null,load(r){t=r},record(r,a,n,i){if(!(n>0))return;let o=e().toISOString().slice(0,10),s=t.find(c=>c.day===o&&c.action===r&&c.model===a);s?(s.count++,s.tokens+=n,s.usd+=i??0):t.push({day:o,action:r,model:a,count:1,tokens:n,usd:i??0});let l=new Date(e().getTime()-fN*864e5).toISOString().slice(0,10);t=t.filter(c=>c.day>=l)},rows:()=>t}}function bN(e,t){let r=$T(t);try{let a=JSON.parse(uN(e,"utf8"));Array.isArray(a.rows)&&r.load(a.rows.filter(n=>n&&typeof n.day=="string"&&typeof n.tokens=="number"&&typeof n.usd=="number"))}catch{}return{where:e,rows:r.rows,record(a,n,i,o){r.record(a,n,i,o);try{cN(gN(e),{recursive:!0});let s=`${e}.tmp`;pN(s,JSON.stringify({version:1,note:"Token Lens savings totals. Numbers only, no prompt text.",rows:r.rows()})),dN(s,e)}catch{}}}}function jT(){let e=process.env.TOKEN_LENS_LEDGER;if(!(e&&/^(off|0|false|no)$/i.test(e)))try{return bN(e||hN(mN(),".token-lens","savings.json"))}catch{return $T()}}function Ev(e,t=new Date){let r=i=>new Date(t.getTime()-i*864e5).toISOString().slice(0,10),a=i=>i.reduce((o,s)=>({count:o.count+s.count,tokens:o.tokens+s.tokens,usd:o.usd+s.usd}),{count:0,tokens:0,usd:0}),n=i=>{let o=new Map;for(let s of e)o.set(s[i],[...o.get(s[i])??[],s]);return[...o].map(([s,l])=>({[i]:s,...a(l)})).sort((s,l)=>l.tokens-s.tokens)};return{today:a(e.filter(i=>i.day===r(0))),last7:a(e.filter(i=>i.day>r(7))),last30:a(e.filter(i=>i.day>r(30))),all:a(e),since:e.length?e.map(i=>i.day).sort()[0]:null,byAction:n("action"),byModel:n("model")}}import{execFile as ry,execFileSync as JD,spawn as YD}from"node:child_process";import{mkdirSync as WA,readFileSync as KA,writeFileSync as ZA}from"node:fs";import{randomUUID as XD}from"node:crypto";import{createServer as QD}from"node:http";import{homedir as tm}from"node:os";import{join as nm}from"node:path";import{createInterface as eM}from"node:readline";function Yr(e,t,r,a){let n=a&&a>0?a:r.contextWindow,i=(e+t)/n,o=i>=.95?"full":i>=.8?"hot":i>=.5?"warm":"ok";return{conversationTokens:e,promptTokens:t,window:n,ratio:i,zone:o,longChat:e>=4e4}}function OT(e,t){return e!=="auto"?e:t.zone==="hot"||t.zone==="full"?"aggressive":"balanced"}var vN={coding:"the files and functions involved, the current state of the code (only the parts still changing, verbatim), and what is left to build",debugging:"the bug, what has been ruled out, the most likely cause, and the exact error message",writing:"the audience, tone, the current outline, and any passages I approved (verbatim)",editing:"the style rules we settled on and which parts are already done",analysis:"the dataset's shape, the findings so far with their numbers, and the next questions",research:"the question, the answers found so far with their sources, and what is still open"},Rt="Optional: the new chat only knows what the brief keeps, so later answers can differ. Check the brief before you rely on it.";function $p(e){return["Write a handoff brief of this conversation that I can paste into a new chat to continue without the history.",`Cover: ${vN[e]??"the goal, the decisions made, and the current state"}; plus open questions and my preferences.`,"Use terse bullets, under 250 words, and nothing else."].join(" ")}var xi=e=>e.toLocaleString("en-US");function xv(e){let{profile:t,task:r,signals:a,promptTokens:n,usage:i,text:o}=e,s=[];if(r==="coding"&&a.pastedTokens>1500&&s.push({id:"paste-less-code",text:`About ${xi(a.pastedTokens)} tokens of pasted code. Paste only the functions involved.`,saves:"input"}),r==="debugging"&&a.hasLogs&&a.pastedTokens>800&&s.push({id:"trim-logs",text:"Long log pasted. The first error and its stack are usually enough; Optimize collapses repeated lines and library frames.",saves:"input"}),r==="analysis"&&a.hasData&&a.pastedTokens>2e3&&s.push({id:"sample-data",text:"Large table pasted. The header plus ~20 sample rows and a description of the rest is usually enough; or attach the file instead.",saves:"input"}),a.pastedTokens>i.window*.4&&s.push({id:"split-material",text:`The pasted material is ${Math.round(a.pastedTokens/i.window*100)}% of ${t.label}'s context. Split it into parts or paste only what's needed.`,saves:"input"}),t.family==="anthropic"&&a.pastedTokens>300&&!/<[a-z][\w-]*>/i.test(o))for(let u of t.notes??[])s.push({id:"family-note",text:u,saves:"input"});i.zone==="hot"||i.zone==="full"?s.push({id:"handoff",text:`This chat fills about ${Math.round(i.ratio*100)}% of ${t.label}'s context. Older messages will be dropped or compacted soon. Hand off to a new chat. ${Rt}`,saves:"input"}):(i.longChat||i.zone==="warm")&&s.push({id:"handoff",text:`Every new message re-reads about ${xi(i.conversationTokens)} tokens of history. A handoff brief and a new chat cut that. ${Rt}`,saves:"input"});let l=t.pricing?.longContext,c=i.conversationTokens+n;return l&&t.pricing&&c>=l.aboveTokens*.85&&s.push({id:"price-threshold",text:c>l.aboveTokens?`This message reads \u2248${xi(c)} tokens, past ${xi(l.aboveTokens)}, so ${t.label} bills all of it at $${l.inputPerMTok}/M instead of $${t.pricing.inputPerMTok}/M. Continuing from a handoff brief in a new chat brings it back under. ${Rt}`:`This chat is \u2248${xi(c)} tokens; past ${xi(l.aboveTokens)}, ${t.label} bills every message at $${l.inputPerMTok}/M instead of $${t.pricing.inputPerMTok}/M. Hand off to a new chat before then. ${Rt}`,saves:"input"}),s}var mt="<|endoftext|>",On="<|fim_prefix|>",Nn="<|fim_middle|>",Dn="<|fim_suffix|>",Xr="<|im_start|>",Qr="<|im_end|>",Mn="<|im_sep|>",Ln="<|endofprompt|>",Tv="<|startoftext|>",qs="<|start|>",Hs="<|end|>",Gs="<|message|>",Vs="<|channel|>",Ws="<|return|>",Ks="<|constrain|>",Zs="<|call|>";var NT=e=>e<=127;function Av(e){if(e.length===0)return!1;let t=e.charCodeAt(e.length-1);return t>=55296&&t<=56319}function yN(e){let t=0;for(;t<e.length;){let r=e[t],a=0,n=0;if(r<=127)a=1,n=r;else if((r&224)===192){if(a=2,n=r&31,r<=193)return!1}else if((r&240)===224)a=3,n=r&15;else if((r&248)===240){if(a=4,n=r&7,r>244)return!1}else return!1;if(t+a>e.length)return!1;for(let i=1;i<a;i++){let o=e[t+i];if(o===void 0||(o&192)!==128)return!1;n=n<<6|o&63}if(a===2&&n<128||a===3&&n<2048||a===4&&n<65536||n>=55296&&n<=57343||n>1114111)return!1;t+=a}return!0}var kN=new TextDecoder("utf8",{fatal:!1});function DT(e){if(yN(e))return kN.decode(e)}function MT(e,t){let r=Math.min(e.length,t.length);for(let a=0;a<r;a++)if(e[a]!==t[a])return e[a]-t[a];return e.length-t.length}function LT(e){let t=0;return e.forEach(r=>{t=Math.max(t,r)}),t}function Cv(e){return e.replace(/[$()*+.?[\\\]^{|}]/g,"\\$&")}function zv(e){let t=[...e].map(Cv).join("|");return new RegExp(`(${t})`)}var jp=new Uint8Array(0),Ti=new TextDecoder("utf8"),UT=class{mergeableBytePairRankCount;bytePairRankDecoder;bytePairNonUtfRankDecoder=new Map;bytePairNonUtfSortedEncoder;bytePairStringRankEncoder;tokenSplitRegex;specialTokensEncoder;specialTokensDecoder;specialTokenPatternRegex;textEncoder=new TextEncoder;mergeCache;mergeCacheSize;constructor({bytePairRankDecoder:e,specialTokensEncoder:t,tokenSplitRegex:r,mergeCacheSize:a=1e5}){this.bytePairRankDecoder=e,this.bytePairStringRankEncoder=new Map,this.mergeCacheSize=a,a>0&&(this.mergeCache=new Map),this.mergeableBytePairRankCount=Object.keys(e).length;let n=[];e.forEach((o,s)=>{if(typeof o=="string"){this.bytePairStringRankEncoder.set(o,s);return}let l=new Uint8Array(o);n.push([l,s]),this.bytePairNonUtfRankDecoder.set(s,l)}),this.bytePairNonUtfSortedEncoder=n.sort((o,s)=>MT(o[0],s[0])),this.specialTokensEncoder=t??new Map,this.specialTokensDecoder=t?new Map([...t].map(([o,s])=>[s,o])):new Map,this.tokenSplitRegex=r;let i=[...this.specialTokensEncoder.keys()].map(Cv).join("|");try{this.specialTokenPatternRegex=new RegExp(i,"y")}catch{throw new Error("Invalid regular expression pattern.")}}setMergeCacheSize(e){this.mergeCacheSize===0&&e>0&&(this.mergeCache=new Map),this.mergeCacheSize=e,e===0&&(this.mergeCache=void 0)}clearMergeCache(){this.mergeCache?.clear()}*encodeNativeGenerator(e,t){let r=0,a=0;for(;;){let n=this.findNextSpecialToken(e,t,r),i=n?.[0],o=i??e.length,s=r===0&&o===e.length?e:e.slice(r,o);for(let[l]of s.matchAll(this.tokenSplitRegex)){let c=this.getBpeRankFromString(l);if(c!==void 0){a=1,yield[c];continue}let u=this.bytePairEncode(l);a=u.length,yield u}if(i!==void 0){let l=n[1],c=this.specialTokensEncoder.get(l);if(c===void 0)throw new Error(`Special token "${l}" is not in the special token encoder.`);yield[c],r=i+l.length,a=1}else break}return a}encodeNative(e,t){let r=0,a=[];for(;;){let n=this.findNextSpecialToken(e,t,r),i=n?.[0],o=i??e.length,s=r===0&&o===e.length?e:e.slice(r,o);for(let[l]of s.matchAll(this.tokenSplitRegex)){let c=this.getBpeRankFromString(l);if(c!==void 0){a.push(c);continue}let u=this.bytePairEncode(l);a.push(...u)}if(i!==void 0){let l=n[1],c=this.specialTokensEncoder.get(l);if(c===void 0)throw new Error(`Special token "${l}" is not in the special token encoder.`);a.push(c),r=i+l.length}else break}return a}countNative(e,t){let r=0,a=0;for(;;){let n=this.findNextSpecialToken(e,t,r),i=n?.[0],o=i??e.length,s=r===0&&o===e.length?e:e.slice(r,o);for(let[l]of s.matchAll(this.tokenSplitRegex)){if(this.getBpeRankFromString(l)!==void 0){a++;continue}let c=this.bytePairEncode(l);a+=c.length}if(i!==void 0){let l=n[1];if(this.specialTokensEncoder.get(l)===void 0)throw new Error(`Special token "${l}" is not in the special token encoder.`);a++,r=i+l.length}else break}return a}*decodeNativeGenerator(e){for(let t of e){let r=this.tryDecodeToken(t);r&&(yield r)}}decodeNative(e){let t="",r=jp;for(let a of e){let n=this.tryDecodeToken(a);if(n===void 0)throw new Error(`Token ${a} is not in the byte pair encoder.`);if(typeof n=="string")r!==jp&&(t+=Ti.decode(r,{stream:!0}),r=jp),t+=n;else{let i=new Uint8Array(r.length+n.length);i.set(r),i.set(n,r.length),r=i}}return r!==jp&&(t+=Ti.decode(r,{stream:!0})),t}async*decodeNativeAsyncIterable(e){for await(let t of e){let r=this.tryDecodeToken(t);r&&(yield r)}}getBpeRankFromString(e){return this.bytePairStringRankEncoder.get(e)}getBpeRankFromStringOrThrow(e){let t=this.getBpeRankFromString(e);if(t===void 0)throw new Error(`The byte-pair encoding does not contain a value for: ${e}`);return t}getBpeRankFromBytes(e){let t=DT(e);if(t!==void 0)return this.getBpeRankFromString(t);let r=this.binarySearch(e);if(r!==-1)return this.bytePairNonUtfSortedEncoder[r][1]}getBpeRankFromBytesOrThrow(e){let t=this.getBpeRankFromBytes(e);if(t===void 0)throw new Error(`The byte-pair encoding does not contain a value for: ${e.toString()}`);return t}binarySearch(e){let t=0,r=this.bytePairNonUtfSortedEncoder.length-1;for(;t<=r;){let a=t+r>>>1,n=this.bytePairNonUtfSortedEncoder[a][0],i=0,o=Math.min(n.length,e.length);for(let s=0;s<o&&(i=n[s]-e[s],i===0);s++);if(i===0&&(i=n.length-e.length),i===0)return a;i<0?t=a+1:r=a-1}return-1}findNextSpecialToken(e,t,r){let a=r;for(;;){this.specialTokenPatternRegex.lastIndex=a;let n=this.specialTokenPatternRegex.exec(e);if(!n)return;let i=n[0];if(t?.has(i))return[n.index+a,i];a=n.index+a+1}}tryDecodeToken(e){let t=this.bytePairRankDecoder[e];if(typeof t=="string")return t;if(typeof t=="object"){let r=this.bytePairNonUtfRankDecoder.get(e);if(r)return r}return this.specialTokensDecoder.get(e)}addToMergeCache(e,t){if(this.mergeCache){if(this.mergeCache.size>=this.mergeCacheSize){let r=this.mergeCache.keys().next().value;this.mergeCache.delete(r)}this.mergeCache.set(e,t)}}bytePairEncode(e){if(e.length===1&&NT(e.codePointAt(0)))return[this.getBpeRankFromStringOrThrow(e)];if(this.mergeCache?.has(e)){let a=this.mergeCache.get(e);return this.mergeCache.delete(e),this.mergeCache.set(e,a),a}let t=this.textEncoder.encode(e),r=this.bytePairMerge(t);return this.addToMergeCache(e,r),r}bytePairMerge(e){let t=[],r=[],a=(i,o=t[i],s=t[i+2])=>{if(s===void 0)return Number.POSITIVE_INFINITY;let l=e.subarray(o,s);return this.getBpeRankFromBytes(l)??Number.POSITIVE_INFINITY};for(let i=0;i<=e.length;i++)t.push(i),i<e.length-1?r.push(a(i,i,i+2)):r.push(Number.POSITIVE_INFINITY);for(;t.length>1;){let i=Number.POSITIVE_INFINITY,o=-1;for(let s=0;s<r.length-1;s++){let l=r[s];l<i&&(i=l,o=s)}if(i===Number.POSITIVE_INFINITY||o===-1)break;t.splice(o+1,1),r.splice(o,1),r[o]=a(o),o>0&&(r[o-1]=a(o-1))}let n=[];for(let i=0;i<t.length-1;i++){let o=t[i],s=t[i+1],l=this.getBpeRankFromBytesOrThrow(e.subarray(o,s));n.push(l)}return n}};function _N(e,t){let r=0;if(e.role&&(r+=t(e.role)),e.content&&(r+=t(e.content)),e.name&&(r+=t(e.name)+1),e.function_call){let{name:a,arguments:n}=e.function_call;a&&(r+=t(a)),n&&(r+=t(n)),r+=3}return r+=3,e.role==="function"&&(r-=2),r}function FT(e,t,r){if(!e.properties)return"";let a=[],n=new Set(e.required??[]),i=" ".repeat(t);for(let[o,s]of Object.entries(e.properties)){s.description&&t<2&&a.push(`${i}// ${s.description}`);let l=n.has(o),c=r(s,t);a.push(`${i}${o}${l?"":"?"}: ${c},`)}return a.join(`
|
|
85
|
+
`,t.enqueue(r.encode(i)),!0}catch(i){return this.onerror?.(i),!1}}handleUnsupportedRequest(){return this.onerror?.(new Error("Method not allowed.")),new Response(JSON.stringify({jsonrpc:"2.0",error:{code:-32e3,message:"Method not allowed."},id:null}),{status:405,headers:{Allow:"GET, POST, DELETE","Content-Type":"application/json"}})}async handlePostRequest(t,r){try{let a=t.headers.get("accept");if(!a?.includes("application/json")||!a.includes("text/event-stream"))return this.onerror?.(new Error("Not Acceptable: Client must accept both application/json and text/event-stream")),this.createJsonErrorResponse(406,-32e3,"Not Acceptable: Client must accept both application/json and text/event-stream");let n=t.headers.get("content-type");if(!CT(n))return this.onerror?.(new Error("Unsupported Media Type: Content-Type must be application/json")),this.createJsonErrorResponse(415,-32e3,"Unsupported Media Type: Content-Type must be application/json");let i={headers:Object.fromEntries(t.headers.entries()),url:new URL(t.url)},o;if(r?.parsedBody!==void 0)o=r.parsedBody;else try{let b=await PT(t,this._maxRequestBodySize);if(b.tooLarge){let v=zT(this._maxRequestBodySize);return this.onerror?.(new Error(v)),this.createJsonErrorResponse(413,-32e3,v)}o=JSON.parse(b.text)}catch{return this.onerror?.(new Error("Parse error: Invalid JSON")),this.createJsonErrorResponse(400,-32700,"Parse error: Invalid JSON")}if(Array.isArray(o)&&o.length>100)return this.onerror?.(new Error(`Invalid Request: Batch must not exceed ${100} messages`)),this.createJsonErrorResponse(400,-32600,`Invalid Request: Batch must not exceed ${100} messages`);let s;try{Array.isArray(o)?s=o.map(b=>Is.parse(b)):s=[Is.parse(o)]}catch{return this.onerror?.(new Error("Parse error: Invalid JSON-RPC message")),this.createJsonErrorResponse(400,-32700,"Parse error: Invalid JSON-RPC message")}if(this._closed)return this.createJsonErrorResponse(404,-32001,"Session not found");let l=s.some(Xb);if(l){if(this._initialized&&this.sessionId!==void 0)return this.onerror?.(new Error("Invalid Request: Server already initialized")),this.createJsonErrorResponse(400,-32600,"Invalid Request: Server already initialized");if(s.length>1)return this.onerror?.(new Error("Invalid Request: Only one initialization request is allowed")),this.createJsonErrorResponse(400,-32600,"Invalid Request: Only one initialization request is allowed");this.sessionId=this.sessionIdGenerator?.(),this._initialized=!0,this.sessionId&&this._onsessioninitialized&&await Promise.resolve(this._onsessioninitialized(this.sessionId))}if(!l){let b=this.validateSession(t);if(b)return b;let v=this.validateProtocolVersion(t);if(v)return v}if(this._closed)return this.createJsonErrorResponse(404,-32001,"Session not found");if(!s.some(zn)){for(let b of s)this.onmessage?.(b,{authInfo:r?.authInfo,requestInfo:i});return new Response(null,{status:202})}let u=crypto.randomUUID(),d=s.find(b=>Xb(b)),m=d?d.params.protocolVersion:t.headers.get("mcp-protocol-version")??Ox;if(this._enableJsonResponse)return new Promise(b=>{this._streamMapping.set(u,{resolveJson:b,cleanup:()=>{this._streamMapping.delete(u)}});for(let v of s)zn(v)&&this._requestToStreamMapping.set(v.id,u);for(let v of s)this.onmessage?.(v,{authInfo:r?.authInfo,requestInfo:i})});let p=new TextEncoder,g,h,f=new ReadableStream({start:b=>{g=b},cancel:()=>{h!==void 0&&clearInterval(h),this._streamMapping.get(u)?.controller===g&&this._streamMapping.delete(u)}}),_={"Content-Type":"text/event-stream","Cache-Control":"no-cache, no-transform",Connection:"keep-alive","X-Accel-Buffering":"no"};this.sessionId!==void 0&&(_["mcp-session-id"]=this.sessionId);for(let b of s)zn(b)&&(this._streamMapping.set(u,{controller:g,encoder:p,cleanup:()=>{h!==void 0&&clearInterval(h),this._streamMapping.delete(u);try{g.close()}catch{}}}),this._requestToStreamMapping.set(b.id,u));try{await this.writePrimingEvent(g,p,u,m);for(let b of s){let v,C;zn(b)&&this._eventStore&&m>="2025-11-25"&&(v=()=>{this.closeSSEStream(b.id)},C=()=>{this.closeStandaloneSSEStream()}),this.onmessage?.(b,{authInfo:r?.authInfo,requestInfo:i,closeSSEStream:v,closeStandaloneSSEStream:C})}}catch(b){this._streamMapping.get(u)?.cleanup(),this._resumableStreams.delete(u);for(let v of s)zn(v)&&this._requestToStreamMapping.delete(v.id);throw b}return this._streamMapping.get(u)?.controller===g&&(h=this.startKeepAlive(g,p)),new Response(f,{status:200,headers:_})}catch(a){return this.onerror?.(a),this.createJsonErrorResponse(400,-32700,"Parse error",{data:String(a)})}}async handleDeleteRequest(t){let r=this.validateSession(t);if(r)return r;let a=this.validateProtocolVersion(t);if(a)return a;try{return await Promise.resolve(this._onsessionclosed?.(this.sessionId)),new Response(null,{status:200})}finally{await this.close()}}validateSession(t){if(this.sessionIdGenerator===void 0)return;if(!this._initialized)return this.onerror?.(new Error("Bad Request: Server not initialized")),this.createJsonErrorResponse(400,-32e3,"Bad Request: Server not initialized");let r=t.headers.get("mcp-session-id");if(!r)return this.onerror?.(new Error("Bad Request: Mcp-Session-Id header is required")),this.createJsonErrorResponse(400,-32e3,"Bad Request: Mcp-Session-Id header is required");if(r!==this.sessionId)return this.onerror?.(new Error("Session not found")),this.createJsonErrorResponse(404,-32001,"Session not found")}validateProtocolVersion(t){let r=t.headers.get("mcp-protocol-version");if(r!==null&&!fi.includes(r))return this.onerror?.(new Error(`Bad Request: Unsupported protocol version: ${r} (supported versions: ${fi.join(", ")})`)),this.createJsonErrorResponse(400,-32e3,`Bad Request: Unsupported protocol version: ${r} (supported versions: ${fi.join(", ")})`)}async close(){this._closed||(this._closed=!0,this._streamMapping.forEach(({cleanup:t})=>{t()}),this._streamMapping.clear(),this._requestResponseMap.clear(),this._resumableStreams.clear(),this.onclose?.())}closeSSEStream(t){let r=this._requestToStreamMapping.get(t);if(!r)return;let a=this._streamMapping.get(r);a&&a.cleanup()}closeStandaloneSSEStream(){let t=this._streamMapping.get(this._standaloneSseStreamId);t&&t.cleanup()}async send(t,r){let a=r?.relatedRequestId;if((In(t)||bi(t))&&(a=t.id),a===void 0){if(In(t)||bi(t))throw new Error("Cannot send a response on a standalone SSE stream unless resuming a previous client request");let o;this._eventStore&&(o=await this._eventStore.storeEvent(this._standaloneSseStreamId,t));let s=this._streamMapping.get(this._standaloneSseStreamId);if(s===void 0)return;s.controller&&s.encoder&&(o===void 0||!s.replayedEventIds?.has(o))&&this.writeSSEEvent(s.controller,s.encoder,t,o);return}let n=this._requestToStreamMapping.get(a);if(!n)throw new Error(`No connection established for request ID: ${String(a)}`);let i=this._streamMapping.get(n);if(!this._enableJsonResponse){let o;this._eventStore&&(o=await this._eventStore.storeEvent(n,t),i=this._streamMapping.get(n)),i?.controller&&i?.encoder&&(o===void 0||!i.replayedEventIds?.has(o))&&this.writeSSEEvent(i.controller,i.encoder,t,o)&&o!==void 0&&this._resumableStreams.add(n)}if(In(t)||bi(t)){this._requestResponseMap.set(a,t);let o=Array.from(this._requestToStreamMapping.entries()).filter(([l,c])=>c===n).map(([l])=>l);if(o.every(l=>this._requestResponseMap.has(l))){if(!i){if(this._closed){for(let l of o)this._requestResponseMap.delete(l),this._requestToStreamMapping.delete(l);return}if(!this._enableJsonResponse&&this._eventStore&&this._resumableStreams.has(n)){for(let l of o)this._requestResponseMap.delete(l),this._requestToStreamMapping.delete(l);this._resumableStreams.delete(n);return}for(let l of o)this._requestResponseMap.delete(l),this._requestToStreamMapping.delete(l);throw new Error(`No connection established for request ID: ${String(a)}`)}if(this._enableJsonResponse&&i.resolveJson){let l={"Content-Type":"application/json"};this.sessionId!==void 0&&(l["mcp-session-id"]=this.sessionId);let c=o.map(u=>this._requestResponseMap.get(u));c.length===1?i.resolveJson(new Response(JSON.stringify(c[0]),{status:200,headers:l})):i.resolveJson(new Response(JSON.stringify(c),{status:200,headers:l}))}else i.cleanup();for(let l of o)this._requestResponseMap.delete(l),this._requestToStreamMapping.delete(l);this._resumableStreams.delete(n)}}}};var Rp=class{constructor(t={}){this._requestContext=new WeakMap,this._webStandardTransport=new Pp(t),this._requestListener=_v(async r=>{let a=this._requestContext.get(r);return this._webStandardTransport.handleRequest(r,{authInfo:a?.authInfo,parsedBody:a?.parsedBody})},{overrideGlobalObjects:!1})}get sessionId(){return this._webStandardTransport.sessionId}set onclose(t){this._webStandardTransport.onclose=t}get onclose(){return this._webStandardTransport.onclose}set onerror(t){this._webStandardTransport.onerror=t}get onerror(){return this._webStandardTransport.onerror}set onmessage(t){this._webStandardTransport.onmessage=t}get onmessage(){return this._webStandardTransport.onmessage}async start(){return this._webStandardTransport.start()}async close(){return this._webStandardTransport.close()}async send(t,r){return this._webStandardTransport.send(t,r)}async handleRequest(t,r,a){let n=t.auth;await _v(async o=>this._webStandardTransport.handleRequest(o,{authInfo:n,parsedBody:a}),{overrideGlobalObjects:!1})(t,r)}closeSSEStream(t){this._webStandardTransport.closeSSEStream(t)}closeStandaloneSSEStream(){this._webStandardTransport.closeStandaloneSSEStream()}};import{mkdirSync as cN,readFileSync as uN,renameSync as dN,writeFileSync as pN}from"node:fs";import{homedir as mN}from"node:os";import{dirname as gN,join as hN}from"node:path";var fN=400;function $T(e=()=>new Date){let t=[];return{where:null,load(r){t=r},record(r,a,n,i){if(!(n>0))return;let o=e().toISOString().slice(0,10),s=t.find(c=>c.day===o&&c.action===r&&c.model===a);s?(s.count++,s.tokens+=n,s.usd+=i??0):t.push({day:o,action:r,model:a,count:1,tokens:n,usd:i??0});let l=new Date(e().getTime()-fN*864e5).toISOString().slice(0,10);t=t.filter(c=>c.day>=l)},rows:()=>t}}function bN(e,t){let r=$T(t);try{let a=JSON.parse(uN(e,"utf8"));Array.isArray(a.rows)&&r.load(a.rows.filter(n=>n&&typeof n.day=="string"&&typeof n.tokens=="number"&&typeof n.usd=="number"))}catch{}return{where:e,rows:r.rows,record(a,n,i,o){r.record(a,n,i,o);try{cN(gN(e),{recursive:!0});let s=`${e}.tmp`;pN(s,JSON.stringify({version:1,note:"Token Lens savings totals. Numbers only, no prompt text.",rows:r.rows()})),dN(s,e)}catch{}}}}function jT(){let e=process.env.TOKEN_LENS_LEDGER;if(!(e&&/^(off|0|false|no)$/i.test(e)))try{return bN(e||hN(mN(),".token-lens","savings.json"))}catch{return $T()}}function Ev(e,t=new Date){let r=i=>new Date(t.getTime()-i*864e5).toISOString().slice(0,10),a=i=>i.reduce((o,s)=>({count:o.count+s.count,tokens:o.tokens+s.tokens,usd:o.usd+s.usd}),{count:0,tokens:0,usd:0}),n=i=>{let o=new Map;for(let s of e)o.set(s[i],[...o.get(s[i])??[],s]);return[...o].map(([s,l])=>({[i]:s,...a(l)})).sort((s,l)=>l.tokens-s.tokens)};return{today:a(e.filter(i=>i.day===r(0))),last7:a(e.filter(i=>i.day>r(7))),last30:a(e.filter(i=>i.day>r(30))),all:a(e),since:e.length?e.map(i=>i.day).sort()[0]:null,byAction:n("action"),byModel:n("model")}}import{execFile as ry,execFileSync as XD,spawn as QD}from"node:child_process";import{mkdirSync as WA,readFileSync as KA,writeFileSync as ZA}from"node:fs";import{randomUUID as eM}from"node:crypto";import{createServer as tM}from"node:http";import{homedir as tm}from"node:os";import{join as nm}from"node:path";import{createInterface as nM}from"node:readline";function Yr(e,t,r,a){let n=a&&a>0?a:r.contextWindow,i=(e+t)/n,o=i>=.95?"full":i>=.8?"hot":i>=.5?"warm":"ok";return{conversationTokens:e,promptTokens:t,window:n,ratio:i,zone:o,longChat:e>=4e4}}function OT(e,t){return e!=="auto"?e:t.zone==="hot"||t.zone==="full"?"aggressive":"balanced"}var vN={coding:"the files and functions involved, the current state of the code (only the parts still changing, verbatim), and what is left to build",debugging:"the bug, what has been ruled out, the most likely cause, and the exact error message",writing:"the audience, tone, the current outline, and any passages I approved (verbatim)",editing:"the style rules we settled on and which parts are already done",analysis:"the dataset's shape, the findings so far with their numbers, and the next questions",research:"the question, the answers found so far with their sources, and what is still open"},Rt="Optional: the new chat only knows what the brief keeps, so later answers can differ. Check the brief before you rely on it.";function $p(e){return["Write a handoff brief of this conversation that I can paste into a new chat to continue without the history.",`Cover: ${vN[e]??"the goal, the decisions made, and the current state"}; plus open questions and my preferences.`,"Use terse bullets, under 250 words, and nothing else."].join(" ")}var xi=e=>e.toLocaleString("en-US");function xv(e){let{profile:t,task:r,signals:a,promptTokens:n,usage:i,text:o}=e,s=[];if(r==="coding"&&a.pastedTokens>1500&&s.push({id:"paste-less-code",text:`About ${xi(a.pastedTokens)} tokens of pasted code. Paste only the functions involved.`,saves:"input"}),r==="debugging"&&a.hasLogs&&a.pastedTokens>800&&s.push({id:"trim-logs",text:"Long log pasted. The first error and its stack are usually enough; Optimize collapses repeated lines and library frames.",saves:"input"}),r==="analysis"&&a.hasData&&a.pastedTokens>2e3&&s.push({id:"sample-data",text:"Large table pasted. The header plus ~20 sample rows and a description of the rest is usually enough; or attach the file instead.",saves:"input"}),a.pastedTokens>i.window*.4&&s.push({id:"split-material",text:`The pasted material is ${Math.round(a.pastedTokens/i.window*100)}% of ${t.label}'s context. Split it into parts or paste only what's needed.`,saves:"input"}),t.family==="anthropic"&&a.pastedTokens>300&&!/<[a-z][\w-]*>/i.test(o))for(let u of t.notes??[])s.push({id:"family-note",text:u,saves:"input"});i.zone==="hot"||i.zone==="full"?s.push({id:"handoff",text:`This chat fills about ${Math.round(i.ratio*100)}% of ${t.label}'s context. Older messages will be dropped or compacted soon. Hand off to a new chat. ${Rt}`,saves:"input"}):(i.longChat||i.zone==="warm")&&s.push({id:"handoff",text:`Every new message re-reads about ${xi(i.conversationTokens)} tokens of history. A handoff brief and a new chat cut that. ${Rt}`,saves:"input"});let l=t.pricing?.longContext,c=i.conversationTokens+n;return l&&t.pricing&&c>=l.aboveTokens*.85&&s.push({id:"price-threshold",text:c>l.aboveTokens?`This message reads \u2248${xi(c)} tokens, past ${xi(l.aboveTokens)}, so ${t.label} bills all of it at $${l.inputPerMTok}/M instead of $${t.pricing.inputPerMTok}/M. Continuing from a handoff brief in a new chat brings it back under. ${Rt}`:`This chat is \u2248${xi(c)} tokens; past ${xi(l.aboveTokens)}, ${t.label} bills every message at $${l.inputPerMTok}/M instead of $${t.pricing.inputPerMTok}/M. Hand off to a new chat before then. ${Rt}`,saves:"input"}),s}var mt="<|endoftext|>",On="<|fim_prefix|>",Nn="<|fim_middle|>",Dn="<|fim_suffix|>",Xr="<|im_start|>",Qr="<|im_end|>",Mn="<|im_sep|>",Ln="<|endofprompt|>",Tv="<|startoftext|>",qs="<|start|>",Hs="<|end|>",Gs="<|message|>",Vs="<|channel|>",Ws="<|return|>",Ks="<|constrain|>",Zs="<|call|>";var NT=e=>e<=127;function Av(e){if(e.length===0)return!1;let t=e.charCodeAt(e.length-1);return t>=55296&&t<=56319}function yN(e){let t=0;for(;t<e.length;){let r=e[t],a=0,n=0;if(r<=127)a=1,n=r;else if((r&224)===192){if(a=2,n=r&31,r<=193)return!1}else if((r&240)===224)a=3,n=r&15;else if((r&248)===240){if(a=4,n=r&7,r>244)return!1}else return!1;if(t+a>e.length)return!1;for(let i=1;i<a;i++){let o=e[t+i];if(o===void 0||(o&192)!==128)return!1;n=n<<6|o&63}if(a===2&&n<128||a===3&&n<2048||a===4&&n<65536||n>=55296&&n<=57343||n>1114111)return!1;t+=a}return!0}var kN=new TextDecoder("utf8",{fatal:!1});function DT(e){if(yN(e))return kN.decode(e)}function MT(e,t){let r=Math.min(e.length,t.length);for(let a=0;a<r;a++)if(e[a]!==t[a])return e[a]-t[a];return e.length-t.length}function LT(e){let t=0;return e.forEach(r=>{t=Math.max(t,r)}),t}function Cv(e){return e.replace(/[$()*+.?[\\\]^{|}]/g,"\\$&")}function zv(e){let t=[...e].map(Cv).join("|");return new RegExp(`(${t})`)}var jp=new Uint8Array(0),Ti=new TextDecoder("utf8"),UT=class{mergeableBytePairRankCount;bytePairRankDecoder;bytePairNonUtfRankDecoder=new Map;bytePairNonUtfSortedEncoder;bytePairStringRankEncoder;tokenSplitRegex;specialTokensEncoder;specialTokensDecoder;specialTokenPatternRegex;textEncoder=new TextEncoder;mergeCache;mergeCacheSize;constructor({bytePairRankDecoder:e,specialTokensEncoder:t,tokenSplitRegex:r,mergeCacheSize:a=1e5}){this.bytePairRankDecoder=e,this.bytePairStringRankEncoder=new Map,this.mergeCacheSize=a,a>0&&(this.mergeCache=new Map),this.mergeableBytePairRankCount=Object.keys(e).length;let n=[];e.forEach((o,s)=>{if(typeof o=="string"){this.bytePairStringRankEncoder.set(o,s);return}let l=new Uint8Array(o);n.push([l,s]),this.bytePairNonUtfRankDecoder.set(s,l)}),this.bytePairNonUtfSortedEncoder=n.sort((o,s)=>MT(o[0],s[0])),this.specialTokensEncoder=t??new Map,this.specialTokensDecoder=t?new Map([...t].map(([o,s])=>[s,o])):new Map,this.tokenSplitRegex=r;let i=[...this.specialTokensEncoder.keys()].map(Cv).join("|");try{this.specialTokenPatternRegex=new RegExp(i,"y")}catch{throw new Error("Invalid regular expression pattern.")}}setMergeCacheSize(e){this.mergeCacheSize===0&&e>0&&(this.mergeCache=new Map),this.mergeCacheSize=e,e===0&&(this.mergeCache=void 0)}clearMergeCache(){this.mergeCache?.clear()}*encodeNativeGenerator(e,t){let r=0,a=0;for(;;){let n=this.findNextSpecialToken(e,t,r),i=n?.[0],o=i??e.length,s=r===0&&o===e.length?e:e.slice(r,o);for(let[l]of s.matchAll(this.tokenSplitRegex)){let c=this.getBpeRankFromString(l);if(c!==void 0){a=1,yield[c];continue}let u=this.bytePairEncode(l);a=u.length,yield u}if(i!==void 0){let l=n[1],c=this.specialTokensEncoder.get(l);if(c===void 0)throw new Error(`Special token "${l}" is not in the special token encoder.`);yield[c],r=i+l.length,a=1}else break}return a}encodeNative(e,t){let r=0,a=[];for(;;){let n=this.findNextSpecialToken(e,t,r),i=n?.[0],o=i??e.length,s=r===0&&o===e.length?e:e.slice(r,o);for(let[l]of s.matchAll(this.tokenSplitRegex)){let c=this.getBpeRankFromString(l);if(c!==void 0){a.push(c);continue}let u=this.bytePairEncode(l);a.push(...u)}if(i!==void 0){let l=n[1],c=this.specialTokensEncoder.get(l);if(c===void 0)throw new Error(`Special token "${l}" is not in the special token encoder.`);a.push(c),r=i+l.length}else break}return a}countNative(e,t){let r=0,a=0;for(;;){let n=this.findNextSpecialToken(e,t,r),i=n?.[0],o=i??e.length,s=r===0&&o===e.length?e:e.slice(r,o);for(let[l]of s.matchAll(this.tokenSplitRegex)){if(this.getBpeRankFromString(l)!==void 0){a++;continue}let c=this.bytePairEncode(l);a+=c.length}if(i!==void 0){let l=n[1];if(this.specialTokensEncoder.get(l)===void 0)throw new Error(`Special token "${l}" is not in the special token encoder.`);a++,r=i+l.length}else break}return a}*decodeNativeGenerator(e){for(let t of e){let r=this.tryDecodeToken(t);r&&(yield r)}}decodeNative(e){let t="",r=jp;for(let a of e){let n=this.tryDecodeToken(a);if(n===void 0)throw new Error(`Token ${a} is not in the byte pair encoder.`);if(typeof n=="string")r!==jp&&(t+=Ti.decode(r,{stream:!0}),r=jp),t+=n;else{let i=new Uint8Array(r.length+n.length);i.set(r),i.set(n,r.length),r=i}}return r!==jp&&(t+=Ti.decode(r,{stream:!0})),t}async*decodeNativeAsyncIterable(e){for await(let t of e){let r=this.tryDecodeToken(t);r&&(yield r)}}getBpeRankFromString(e){return this.bytePairStringRankEncoder.get(e)}getBpeRankFromStringOrThrow(e){let t=this.getBpeRankFromString(e);if(t===void 0)throw new Error(`The byte-pair encoding does not contain a value for: ${e}`);return t}getBpeRankFromBytes(e){let t=DT(e);if(t!==void 0)return this.getBpeRankFromString(t);let r=this.binarySearch(e);if(r!==-1)return this.bytePairNonUtfSortedEncoder[r][1]}getBpeRankFromBytesOrThrow(e){let t=this.getBpeRankFromBytes(e);if(t===void 0)throw new Error(`The byte-pair encoding does not contain a value for: ${e.toString()}`);return t}binarySearch(e){let t=0,r=this.bytePairNonUtfSortedEncoder.length-1;for(;t<=r;){let a=t+r>>>1,n=this.bytePairNonUtfSortedEncoder[a][0],i=0,o=Math.min(n.length,e.length);for(let s=0;s<o&&(i=n[s]-e[s],i===0);s++);if(i===0&&(i=n.length-e.length),i===0)return a;i<0?t=a+1:r=a-1}return-1}findNextSpecialToken(e,t,r){let a=r;for(;;){this.specialTokenPatternRegex.lastIndex=a;let n=this.specialTokenPatternRegex.exec(e);if(!n)return;let i=n[0];if(t?.has(i))return[n.index+a,i];a=n.index+a+1}}tryDecodeToken(e){let t=this.bytePairRankDecoder[e];if(typeof t=="string")return t;if(typeof t=="object"){let r=this.bytePairNonUtfRankDecoder.get(e);if(r)return r}return this.specialTokensDecoder.get(e)}addToMergeCache(e,t){if(this.mergeCache){if(this.mergeCache.size>=this.mergeCacheSize){let r=this.mergeCache.keys().next().value;this.mergeCache.delete(r)}this.mergeCache.set(e,t)}}bytePairEncode(e){if(e.length===1&&NT(e.codePointAt(0)))return[this.getBpeRankFromStringOrThrow(e)];if(this.mergeCache?.has(e)){let a=this.mergeCache.get(e);return this.mergeCache.delete(e),this.mergeCache.set(e,a),a}let t=this.textEncoder.encode(e),r=this.bytePairMerge(t);return this.addToMergeCache(e,r),r}bytePairMerge(e){let t=[],r=[],a=(i,o=t[i],s=t[i+2])=>{if(s===void 0)return Number.POSITIVE_INFINITY;let l=e.subarray(o,s);return this.getBpeRankFromBytes(l)??Number.POSITIVE_INFINITY};for(let i=0;i<=e.length;i++)t.push(i),i<e.length-1?r.push(a(i,i,i+2)):r.push(Number.POSITIVE_INFINITY);for(;t.length>1;){let i=Number.POSITIVE_INFINITY,o=-1;for(let s=0;s<r.length-1;s++){let l=r[s];l<i&&(i=l,o=s)}if(i===Number.POSITIVE_INFINITY||o===-1)break;t.splice(o+1,1),r.splice(o,1),r[o]=a(o),o>0&&(r[o-1]=a(o-1))}let n=[];for(let i=0;i<t.length-1;i++){let o=t[i],s=t[i+1],l=this.getBpeRankFromBytesOrThrow(e.subarray(o,s));n.push(l)}return n}};function _N(e,t){let r=0;if(e.role&&(r+=t(e.role)),e.content&&(r+=t(e.content)),e.name&&(r+=t(e.name)+1),e.function_call){let{name:a,arguments:n}=e.function_call;a&&(r+=t(a)),n&&(r+=t(n)),r+=3}return r+=3,e.role==="function"&&(r-=2),r}function FT(e,t,r){if(!e.properties)return"";let a=[],n=new Set(e.required??[]),i=" ".repeat(t);for(let[o,s]of Object.entries(e.properties)){s.description&&t<2&&a.push(`${i}// ${s.description}`);let l=n.has(o),c=r(s,t);a.push(`${i}${o}${l?"":"?"}: ${c},`)}return a.join(`
|
|
86
86
|
`)}function Iv(e,t){switch(e.type){case"string":return e.enum?.map(r=>JSON.stringify(r)).join(" | ")??"string";case"integer":case"number":return e.enum?.map(r=>`${r}`).join(" | ")??"number";case"boolean":return"boolean";case"null":return"null";case"array":return e.items?`${Iv(e.items,t)}[]`:"any[]";case"object":return`{
|
|
87
87
|
${FT(e,t+2,Iv)}
|
|
88
88
|
${" ".repeat(t)}}`;default:return"any"}}function wN(e){let t=["namespace functions {",""];for(let r of e){r.description&&t.push(`// ${r.description}`);let{parameters:a}=r,n=a?.properties;if(!a||!n||Object.keys(n).length===0)t.push(`type ${r.name} = () => any;`);else{t.push(`type ${r.name} = (_: {`);let i=FT(a,0,Iv);i.length>0&&t.push(i),t.push("}) => any;")}t.push("")}return t.push("} // namespace functions"),t.join(`
|
|
@@ -3349,7 +3349,7 @@ ${" ".repeat(t)}}`;default:return"any"}}function wN(e){let t=["namespace functio
|
|
|
3349
3349
|
`," ffur","-All","Constru","Retrieved"," incr\xEDveis"," \u0438\u043C\u043A\u043E"," foliga"," Balanced","\u1021\u101E"," schlechten"," \u03B1\u03BB\u03BB\u03B1\u03B3"," \u0436\u0430\u0441\u0430\u043F"," S\u01A1n","\u0438\u0440\u0430\u0438","\u10D8\u10DC\u10D4"," milioane","EMU","\u2019\xE9viter"," hyr"," encontre"," hallar"," tablas","_Long","<Cell"," interacted"," figsize"," \u10D6\u10E6"," \u0447\u043E\u0432\u0435\u043A"," Codigo"," dedica\xE7\xE3o"," stolet"," Orten","Philip"," \xE9mission","\u0E32\u0E2B\u0E25\u0E35"," bearbeiten"," mierda","holde","\u0443\u0432\u0430\u0432","<Component"," WPA","\u05E6\u05D9\u05DC\u05D5\u05DD","SSA"," Allies"," B\xE1r","_mer","_SMS"," \u0918\u0942\u092E"," Fixtures"," Bask"," \u5F90"," tradu\xE7\xE3o","blicke"," hammered"," \u0441\u04AF\u043F"," \u0431\u0438\u0433","olu\xE7\xE3o"," electricians","\u0631\u06CC\u0634\u0646"," pitsaaner"," cier"," Receita","\u9EBB\u5C06"," \u0437\u0430\u043A\u043E\u043D\u043E\u0434\u0430\u0442\u0435\u043B\u044C\u0441\u0442\u0432\u0430"," \u10DE\u10D0\u10E1\u10E3\u10EE\u10D8\u10E1\u10DB\u10D2","-operated","\u0D4A\u0D2A\u0D4D\u0D2A\u0D02"," hassles","\u093E\u0924\u0930","\u0430\u043D\u0430\u0433\u0430\u0440\u0430","\u05E0\u05D8\u05E8","Japgolly"," doeleinden"," \u043F\u0435\u0440\u0435\u0439\u0442\u0438"," temsil"," ol\xEDmp"," Spazier"," \u0627\u0644\u0633\u0645\u0627"," pressione"," fiscais","l\u0259rini"," abode"," tantric","()],","rello"," \u0437\u0430\u0447\u0430\u0441\u0442\u0443\u044E","\u5FAE\u8F6F\u96C5\u9ED1","\u0633\u0631\u0627\u0626\u064A\u0644\u064A\u0629"," uitzending","flok"," escult"," Cerro"," is\xE6r"," kobiet","uree","\u0C95\u0CCA","encha"," adhesives"," paura","\u30C3\u30D4\u30F3\u30B0","\u0E27\u0E31\u0E22"," names"," slimmer","milk"," \u0A95\u0AB0\u0AA4\u0AC0"," Cim"," \u0441\u0432\u044F\u0437\u0430\u043D","\u200C\u0C28\u0C4D"," Chauff"," vingers","\u0430\u0446\u0430\u0440\u0442"," webcast",".notice"," m\u1EB7c","Passengers"," \u05E4\u05BC\u05E8\u05D0\u05B8\u05D3\u05D5\u05E7\u05D8\u05DF","\u0430\u043C\u0435\u0442\u0440"," VBA"," \u0440\u0430\u0437\u0432\u0438\u0432\u0430\u0435\u0442\u0441\u044F",`])));
|
|
3350
3350
|
`," surfers"," \u05DE\u05EA\u05D0\u05D9\u05DD",`')):
|
|
3351
3351
|
`,".apk","\u1EDBm"," \u05D4\u05DE\u05D6"," brincar"," AMOLED"," nate"," ayaan"," phosphorylation"," \u0985\u09AA\u09C7\u0995\u09CD\u09B7"," Eats"," Converse","\u094D\u092F\u0942\u091F\u0930","Traveler","inggi","\u05D5\u05E8\u05D2"," almoh"," \u0625\u0641\u0631\u064A\u0642\u064A\u0627"," Magazin"," Arme","\u0E23\u0E01\u0E34\u0E08"," a\u015Fk","-lines"," \u0627\u0644\u0623\u0645\u0627\u0643\u0646","\u516C\u5E73"," kv\xE4ll"," mlx"," \u092E\u0928\u094D\u0924\u094D\u0930\u0940","\u10D0\u10D5\u10D8\u10D0"," teks"," lumea"," legyen"," zwing"," boost"," J\xFA","\u5F69\u7968\u8BBA\u575B"," \u0434\u044D"," \u043E\u0448\u0438\u0431\u043E\u043A","\u0561\u056F\u0561\u0576\u056B","\u0E24\u0E29\u0E20\u0E32\u0E04\u0E21","ebwa"," tipu"," domini"," Gurgaon","combat"," Resist"," \u0930\u094B\u091C\u0917\u093E\u0930","strategie","\u0A17\u0A40","(locator","MONTH"," atlik"," \uB79C","\u0627\u0644\u0633\u064A"," rzecz"," W\xE4"," deportivos"," Facilit","-able"," evitare"," thong"," \u6D3B","\uBB34\uB8CC"," mace"," Extraordinary","\u0927\u093E"," konflik"," livelihoods"," \u043A\u043E\u043C\u043F\u043E\u043D\u0435\u043D\u0442\u043E\u0432"," kuitenkaan","\u5E78\u8FD0\u98DE\u8247","Corpus"," besch\xE4d"," \u05D3\u05D5\u05D3"," dentant"," nweta"," heath"," \u0936\u0941\u0915\u094D\u0930\u092C\u093E\u0930"," mnemonic",".Filters",`','".$`," \u0905\u0938\u094D\u0924","isite"," asawa","\u5E74\u6708"," gotas"," \u0C2A\u0C28\u0C3F\u0C1A","Dek"," Pact","'agence","fei\xE7o"," B\xF6yle","venteen","notif"," \u0410\u043D\u0434\u0440\u0435\u0439","\u591A\u5E74","mittedly","\u8CA1\u5E03"," \u043A\u043E\u043C\u043F\u0430\u043A\u0442","trk","\u0928\u094D\u0926\u094D\u0930\u0940\u092F"," miesto"," Kait"," \u0CAC\u0CB8"," spec"," Injector"," logarith","entions"," \u0447\u0435\u043B","Collateral"," confes","\u093F\u0939\u0930"," sufri\xF3","CRI"," tuge","urllib"," k\u013C"," verpleeg"," application's","(Constructor","\u09BE\u09B2\u09BE"," vulputate"," \u043E\u043F\u0443\u0445"," Nordrhein","allage","\xEDsimas","ornado","\u0438\u0434\u0435\u0440","m\xE9nyek","Qua"," pelicula","\uC131\uACFC","\u3011-"," hemi"," touristes"," absentee"," Nether",".PAGE"," i\u015Fg\xE4r"," efectivos"," saav"," ","flashdata"," sembler"," ikuku"," \u099F\u09BE\u0987",` \u201D
|
|
3352
|
-
`,"\u5F69\u7968\u5E73\u53F0\u5F00\u6237","\u65C1",".\u0413","uckles"," \u0627\u0644\u062E\u0627\u0631","\u0432\u043E\u043B\u044C"," \u043D\u0435\u0432\u043E\u0437\u043C\u043E\u0436",".gradient"," ebile"," Athlete"," \u0442\u04B1\u0440\u0493\u0430\u043D"," Syrie",".processing"," Consultancy"," thrills","\u0642\u0631\u0627\u0621","(varargin","k\xFCnfte"," \u5F6D","-knit","riedenheit"," t\xE4nka","']//","udies","hacer"," Th\xE9\xE2tre","av\u7535\u5F71"," Armada","-techn","ibris","veli"," razloga","-Hop"," \u05DE\u05D7\u05D3\u05E9"," Bloggers"," controversies"," \u0C1A\u0C30\u0C4D\u0C2F"," \u0D2A\u0D4D\u0D30\u0D2E\u0D41\u0D16","_unc","werfen"," \u043B\u043E\u043C"," \u043F\u043E\u043A\u0443\u043F\u0430\u0442\u0435\u043B\u0435\u0439"," \u0433\u043B\u0430\u0437\u0430\u043C\u0438"," \u05D1\u05E2\u05D5\u05D3"," nanot"," ws"," \u043A\u0435\u0437\u0434\u0435\u0441","):("," Produit","Aircraft","iffen"," patrones"," par\xE2metros","Cursos"," cocos"],lA=oA.concat(sA);oA.length=0;sA.length=0;var UN=iA.getEncodingApi("o200k_base",()=>lA),{decode:
|
|
3352
|
+
`,"\u5F69\u7968\u5E73\u53F0\u5F00\u6237","\u65C1",".\u0413","uckles"," \u0627\u0644\u062E\u0627\u0631","\u0432\u043E\u043B\u044C"," \u043D\u0435\u0432\u043E\u0437\u043C\u043E\u0436",".gradient"," ebile"," Athlete"," \u0442\u04B1\u0440\u0493\u0430\u043D"," Syrie",".processing"," Consultancy"," thrills","\u0642\u0631\u0627\u0621","(varargin","k\xFCnfte"," \u5F6D","-knit","riedenheit"," t\xE4nka","']//","udies","hacer"," Th\xE9\xE2tre","av\u7535\u5F71"," Armada","-techn","ibris","veli"," razloga","-Hop"," \u05DE\u05D7\u05D3\u05E9"," Bloggers"," controversies"," \u0C1A\u0C30\u0C4D\u0C2F"," \u0D2A\u0D4D\u0D30\u0D2E\u0D41\u0D16","_unc","werfen"," \u043B\u043E\u043C"," \u043F\u043E\u043A\u0443\u043F\u0430\u0442\u0435\u043B\u0435\u0439"," \u0433\u043B\u0430\u0437\u0430\u043C\u0438"," \u05D1\u05E2\u05D5\u05D3"," nanot"," ws"," \u043A\u0435\u0437\u0434\u0435\u0441","):("," Produit","Aircraft","iffen"," patrones"," par\xE2metros","Cursos"," cocos"],lA=oA.concat(sA);oA.length=0;sA.length=0;var UN=iA.getEncodingApi("o200k_base",()=>lA),{decode:N9,decodeAsyncGenerator:D9,decodeGenerator:M9,encode:L9,encodeGenerator:B9,isWithinTokenLimit:U9,countTokens:cA,encodeChat:F9,encodeChatGenerator:q9,vocabularySize:H9,setMergeCacheSize:G9,clearMergeCache:V9,estimateCost:W9}=UN;var FN=/[A-Za-z]+|\d+|[^\sA-Za-z\d]|\n[ \t]*/g;function $v(e,t=4){if(!e)return 0;let r=e.length/t,a=0;for(let n of e.match(FN)??[]){let i=/^[A-Za-z]/.test(n)?6:/^\d/.test(n)?3:n[0]===`
|
|
3353
3353
|
`?16:1;a+=Math.max(1,Math.ceil(n.length/i))}return Math.max(1,Math.round(Math.max(r,a)))}function Ce(e,t){if(!e)return{tokens:0,exact:t.tokenizer!=="heuristic"};if(t.tokenizer==="o200k")try{return{tokens:cA(e),exact:!0}}catch{}return{tokens:$v(e,t.charsPerToken),exact:!1}}var qN={debugging:[/\b(error|exception|traceback|stack ?trace|crash(es|ed|ing)?|segfault|undefined is not|cannot read propert|null pointer|stack overflow)\b/],coding:[/\b(code|function|method|class|script|refactor|implement|api|endpoint|regex|sql|query|unit tests?|typescript|javascript|python|java|rust|golang|c\+\+|react|component|compile|deploy)\b/],editing:[/\b(proofread|rewrite|rephrase|reword|edit|polish|improve|fix (the )?grammar|make (it|this) (sound|more|less)|tone of)\b/],summarizing:[/\b(summari[sz]e|summary|tl;?dr|key (points|takeaways)|condense|recap|gist)\b/],translation:[/\btranslat(e|ion)\b|\b(in|into) (english|hindi|spanish|french|german|japanese|chinese|arabic|portuguese|italian|korean|russian)\b/],analysis:[/\b(analy[sz]e|analysis|dataset|csv|spreadsheet|table|chart|trend|average|median|correlat|statistics?|metrics?)\b/],brainstorming:[/\b(brainstorm|ideas? for|suggest (some|a few)|come up with|names? for|list of ideas)\b/],writing:[/\b(write|draft|compose|blog|essay|article|email|cover letter|post|story|poem|speech|announcement|outline)\b/],research:[/^(what|why|how|when|where|who|which|is|are|can|does|do|should|explain|compare|tell me)\b/,/\b(explain|difference between|compare|pros and cons|research|sources?)\b/]},HN=/\b(bug|broken|fails?|failing|doesn'?t work|not working|wrong output|fix (this|the|my|it))\b/,uA=["debugging","translation","summarizing","editing","analysis","coding","brainstorming","writing","research"],GN=/```[\s\S]*?```|~~~[\s\S]*?~~~/g,jv=/^\s*(def |class |function |const |let |var |import |from \S+ import|#include|public |private |return\b|if\s*\(|for\s*\(|while\s*\(|\}|\{|<\/?[a-z][\w-]*[ >])|;\s*$/,Np=/^\s*(\d{4}-\d{2}-\d{2}[T ]\d{2}:\d{2}|\[\d{2}:\d{2}:\d{2}|\[?(INFO|WARN|WARNING|ERROR|DEBUG|TRACE|FATAL)\]?\b|at .+[(:]\d+|File ".+", line \d+|Traceback \(most recent call last\)|\w+(Error|Exception)(: |$)|Caused by:)/,VN=/^\s*([^,\t\n]+[,\t]){2,}[^,\t\n]+\s*$|^\s*[[{]\s*"\w+"\s*:/,WN=/\b(in|under|within|at most|max(imum)?|no more than|about|around|exactly|only)\s+\d+\s*(words?|sentences?|bullets?|bullet points|lines?|paragraphs?|points?|items?|characters?|chars?|tokens?)\b|\b(\d+|one|two|three|four|five|six|seven|eight|nine|ten)[- ](words?|sentences?|bullets?|bullet points|lines?|paragraphs?|points?|ideas?|items?)\b|\b(brief(ly)?|concise(ly)?|short(ly)?|succinct(ly)?|tl;?dr|one[- ]liner|yes or no|just the (answer|code|diff))\b/,KN=/\b(full|entire|whole|complete)\s+(file|code|script|program|document|text|essay)\b|\brewrite (the )?(whole|entire)\b/;function ZN(e,t){let r=e.filter(a=>a.trim());return r.length?r.filter(a=>t.test(a)).length/r.length:0}function Ov(e){let t=e.replace(/^\s+/,""),r=e.length-t.length,a=/\n\s*\n|:\s*\n/.exec(t);if(!a)return{instruction:e,material:""};let n=r+a.index+a[0].length;return{instruction:e.slice(0,n),material:e.slice(n)}}function hr(e){let t=e.split(`
|
|
3354
3354
|
`),r=e.match(GN)??[],{instruction:a,material:n}=Ov(e),i=a.toLowerCase().trim(),o={hasCode:r.length>0||ZN(t,jv)>.3,hasLogs:t.filter(u=>Np.test(u)).length>=2,hasData:t.filter(u=>VN.test(u)).length>=3,pastedTokens:$v(n),hasLengthLimit:WN.test(e.toLowerCase()),asksForFullOutput:KN.test(i)},s=new Map;for(let u of uA){let d=qN[u],m=d.reduce((p,g)=>p+(g.test(i)?2:0),0);!m&&n&&(m=d.reduce((p,g)=>p+(g.test(n.slice(0,2e3).toLowerCase())?.5:0),0)),s.set(u,m)}(o.hasCode||o.hasLogs)&&HN.test(i)&&s.set("debugging",(s.get("debugging")??0)+2),o.hasLogs&&s.set("debugging",(s.get("debugging")??0)+2),o.hasCode&&s.set("coding",(s.get("coding")??0)+1.5),o.hasData&&s.set("analysis",(s.get("analysis")??0)+1);let l="chat",c=0;for(let u of uA){let d=s.get(u)??0;d>c&&(l=u,c=d)}return{task:l,confidence:Math.min(1,c/4),signals:o}}var dA=new Set(["chat","writing","brainstorming","research"]);var JN=[["number",/\b\d+(?:[.,]\d+)*%?/g],["url",/https?:\/\/\S+/g],["code",/`[^`\n]+`/g],["quote",/"[^"\n]{1,200}"|“[^”\n]{1,200}”/g],["negation",/\b(?:not|no|never|none|nothing|nor|without|cannot|can't|don't|doesn't|didn't|won't|wouldn't|shouldn't|isn't|aren't|wasn't|mustn't)\b/gi],["constraint",/\b(?:must|only|exactly|always|avoid|at least|at most|required|mandatory|strictly|unless|except)\b/gi]];function Dp(e){let t=new Map;for(let[r,a]of JN)for(let n of e.match(a)??[]){let i=`${r}:${n.toLowerCase()}`;t.set(i,(t.get(i)??0)+1)}return t}function ea(e,t,r="count"){let a=Dp(e),n=Dp(t),i=[];for(let[o,s]of a)(n.get(o)??0)<(r==="count"?s:1)&&i.push(o);return{ok:i.length===0,lost:i}}function Mp(e,t){let r=Dp(e),a=Dp(t),n={};for(let i of r.keys()){let o=i.slice(0,i.indexOf(":")),[s,l]=n[o]??[0,0];n[o]=[s+1,l+(a.has(i)?1:0)]}return n}var YN=new Set("please kindly thank thanks much lot advance hi hello hey there chatgpt claude gemini basically actually really very just simply quite literally totally definitely important worth noting note make sure order regard respect fact purpose event point time near future large number majority able wondering like love want need you your would could will can helpful assistant language model act possible mind think step breath deep take reasoning thought process work before answering answer show explain spite due lets let's the that this with for are was is it's its and".split(" ")),pA=/[a-z][a-z'-]{2,}/g;function Js(e,t){let r=new Set(t.toLowerCase().match(pA)??[]),a=new Set;for(let n of e.toLowerCase().match(pA)??[])!r.has(n)&&!YN.has(n)&&a.add(n);return[...a]}var fA=["light","balanced","aggressive"],ke=(e,t,r,a,n=!1)=>({re:new RegExp(e,"gim"),repl:t,name:r,level:a,reasoningOnly:n}),XN=[ke(String.raw`\bdue to the fact that\b`,"because","wordy phrasing","light"),ke(String.raw`\bin spite of the fact that\b`,"although","wordy phrasing","light"),ke(String.raw`\bin the event that\b`,"if","wordy phrasing","light"),ke(String.raw`\bfor the purpose of\b`,"for","wordy phrasing","light"),ke(String.raw`\bin order to\b`,"to","wordy phrasing","light"),ke(String.raw`\bwith (?:regard|respect) to\b`,"about","wordy phrasing","light"),ke(String.raw`\bat this point in time\b`,"now","wordy phrasing","light"),ke(String.raw`\bin the near future\b`,"soon","wordy phrasing","light"),ke(String.raw`\ba large number of\b`,"many","wordy phrasing","light"),ke(String.raw`\bthe majority of\b`,"most","wordy phrasing","light"),ke(String.raw`\b(is|are) able to\b`,"can","wordy phrasing","light"),ke(String.raw`\bmake sure that\b`,"ensure","wordy phrasing","light"),ke(String.raw`\b(?:let'?s|please)?\s*think (?:about (?:this|it) )?step[- ]by[- ]step\b[.,]?\s*`,"","step-by-step (model already reasons)","light",!0),ke(String.raw`\btake a deep breath(?: and)?[.,]?\s*`,"","step-by-step (model already reasons)","light",!0),ke(String.raw`\b(?:show|explain) your (?:reasoning|thought process|work) (?:step[- ]by[- ]step )?(?:before (?:answering|you answer))[.,]?\s*`,"","step-by-step (model already reasons)","light",!0),ke(String.raw`^\s*(?:hi|hello|hey)(?: there)?(?: chatgpt| claude| gemini)?[,!.]?\s*`,"","politeness","balanced"),ke(String.raw`(^|[.!?]\s+)(?:could|can|would|will) you (?:please )?(?:kindly )?([^.!?\n]*)\?`,"$1$2.","politeness","balanced"),ke(String.raw`(^|[.!?]\s+)(?:could|can|would|will) you (?:please )?(?:kindly )?`,"$1","politeness","balanced"),ke(String.raw`\bi would (?:really )?(?:like|love) (?:for )?you to\b\s*`,"","politeness","balanced"),ke(String.raw`\bi (?:want|need) you to\b\s*`,"","politeness","balanced"),ke(String.raw`\bplease\b,?\s*`,"","politeness","balanced"),ke(String.raw`\bkindly\b\s*`,"","politeness","balanced"),ke(String.raw`\bthank you(?: so much| very much| a lot)?(?: in advance)?[.!]?`,"","politeness","balanced"),ke(String.raw`\bthanks(?: so much| very much| a lot)?(?: in advance)?[.!]?`,"","politeness","balanced"),ke(String.raw`\b(?:it is|it's) (?:important|worth noting) (?:to note )?that\b\s*`,"","filler","balanced"),ke(String.raw`\b(?:please )?note that\b\s*`,"","filler","balanced"),ke(String.raw`\b(?:you are|act as|as) (?:an?|my) (?:ai|large language model|helpful assistant|ai assistant)[,.]?\s*`,"","filler","balanced"),ke(String.raw`\bi was wondering if\b\s*`,"","filler","balanced"),ke(String.raw`(?<!\bnot )\b(?:basically|actually|really|very|just|simply|quite|literally|totally|definitely)\b\s*`,"","hedges","aggressive"),ke(String.raw`\b(?:if possible|if you can|if you don't mind)\b[,.]?\s*`,"","hedges","aggressive")],Lp={light:0,balanced:1,aggressive:2},QN=/(```[\s\S]*?```|~~~[\s\S]*?~~~)/,eD=new RegExp(["`[^`\\n]+`","https?:\\/\\/\\S+","<([A-Za-z][\\w-]*)[^>]*>[\\s\\S]*?<\\/\\1>",'"""[\\s\\S]*?"""'].join("|"),"g");function tD(e){return/^\s*>/.test(e)||/^\s{4,}\S/.test(e)||jv.test(e)||Np.test(e)}function nD(e,t){return t&&/^[A-Z]/.test(e)?t[0].toUpperCase()+t.slice(1):t}function rD(e,t,r){for(let a of XN){if(Lp[a.level]>Lp[t.level]||a.reasoningOnly&&!t.profile.reasoning)continue;a.re.lastIndex=0;let n=e.replace(a.re,(...i)=>{let o=i[0],s=i.slice(1,-2),l=a.repl.replace(/\$(\d)/g,(u,d)=>s[Number(d)-1]??""),c=a.repl.startsWith("$1")?s[0]??"":"";return c+nD(o.slice(c.length),l.slice(c.length))});n!==e&&(r.push(a.name),e=n)}return e}function aD(e,t){let r=new Set;return e.split(`
|
|
3355
3355
|
`).map(a=>a.split(/(?<=[.!?])\s+/).filter(n=>{let i=n.replace(/\W+/g," ").trim().toLowerCase();return i.split(" ").length<4?!0:r.has(i)?(t.push("repeated sentence"),!1):(r.add(i),!0)}).join(" ")).join(`
|
|
@@ -3368,7 +3368,7 @@ ${" ".repeat(t)}}`;default:return"any"}}function wN(e){let t=["namespace functio
|
|
|
3368
3368
|
`),qe=h[P].trim().endsWith(",")?",":"",D=s(qe?U.replace(/,\s*$/,""):U,`lines ${v+1}-${P+1}`);if(D!==U&&D!==U.replace(/,\s*$/,"")){f.push(C[1]+D+qe),v=P;continue}}}f.push(h[v])}let _=f.join(`
|
|
3369
3369
|
`),b=_.replace(/[ \t]+$/gm,"").replace(/\n{3,}/g,`
|
|
3370
3370
|
|
|
3371
|
-
`);return b!==_&&(d=!0),_=b,_});return a.length&&n.push(`removed indentation and line breaks from ${a.length} JSON block${a.length>1?"s":""} (same data)`),d&&n.push("removed trailing spaces and extra blank lines outside code"),o(m.join(""),a.length||d?void 0:"Nothing to compact: no pretty-printed JSON or extra whitespace found.")}var Ne=e=>e,hn={"gpt-astra":Ne({id:"gpt-astra",label:"GPT-6 Astra",family:"openai",contextWindow:105e4,tokenizer:"heuristic",charsPerToken:4.2,reasoning:!0,pricing:{inputPerMTok:10,outputPerMTok:50}}),"gpt-reasoning":Ne({id:"gpt-reasoning",label:"GPT (thinking)",family:"openai",contextWindow:196e3,tokenizer:"o200k",charsPerToken:4.2,reasoning:!0,lighterAlternative:"the Instant / non-thinking model",pricing:{inputPerMTok:5,outputPerMTok:30,cachedInputPerMTok:.5}}),gpt:Ne({id:"gpt",label:"GPT",family:"openai",contextWindow:128e3,tokenizer:"o200k",charsPerToken:4.2,reasoning:!1,pricing:{inputPerMTok:2.5,outputPerMTok:15,cachedInputPerMTok:.25}}),"claude-fable":Ne({id:"claude-fable",label:"Claude Fable",family:"anthropic",contextWindow:1e6,tokenizer:"heuristic",charsPerToken:3.5,reasoning:!0,notes:["Claude reads XML-style tags well: wrap pasted material in <doc>\u2026</doc> instead of explaining it."],pricing:{inputPerMTok:10,outputPerMTok:50,cachedInputPerMTok:.25}}),"claude-opus":Ne({id:"claude-opus",label:"Claude Opus",family:"anthropic",contextWindow:2e5,tokenizer:"heuristic",charsPerToken:3.5,reasoning:!1,lighterAlternative:"Sonnet or Haiku",notes:["Claude reads XML-style tags well: wrap pasted material in <doc>\u2026</doc> instead of explaining it."],pricing:{inputPerMTok:4,outputPerMTok:20,cachedInputPerMTok:.2}}),"claude-sonnet":Ne({id:"claude-sonnet",label:"Claude Sonnet",family:"anthropic",contextWindow:2e5,tokenizer:"heuristic",charsPerToken:3.5,reasoning:!1,lighterAlternative:"Haiku",notes:["Claude reads XML-style tags well: wrap pasted material in <doc>\u2026</doc> instead of explaining it."],pricing:{inputPerMTok:2,outputPerMTok:10,cachedInputPerMTok:.2}}),"claude-haiku":Ne({id:"claude-haiku",label:"Claude Haiku",family:"anthropic",contextWindow:2e5,tokenizer:"heuristic",charsPerToken:3.5,reasoning:!1,pricing:{inputPerMTok:.1,outputPerMTok:.5,cachedInputPerMTok:.01}}),"gemini-pro":Ne({id:"gemini-pro",label:"Gemini Pro",family:"google",contextWindow:1e6,tokenizer:"heuristic",charsPerToken:4,reasoning:!0,lighterAlternative:"Flash",pricing:{inputPerMTok:2,outputPerMTok:12,cachedInputPerMTok:.2,longContext:{aboveTokens:2e5,inputPerMTok:4,outputPerMTok:18}}}),"gemini-flash":Ne({id:"gemini-flash",label:"Gemini Flash",family:"google",contextWindow:1e6,tokenizer:"heuristic",charsPerToken:4,reasoning:!1,pricing:{inputPerMTok:1.5,outputPerMTok:9,cachedInputPerMTok:.15}}),deepseek:Ne({id:"deepseek",label:"DeepSeek",family:"deepseek",contextWindow:128e3,tokenizer:"heuristic",charsPerToken:3.8,reasoning:!1,pricing:{inputPerMTok:.28,outputPerMTok:.42,cachedInputPerMTok:.028}}),"deepseek-reasoning":Ne({id:"deepseek-reasoning",label:"DeepSeek (thinking)",family:"deepseek",contextWindow:128e3,tokenizer:"heuristic",charsPerToken:3.8,reasoning:!0,lighterAlternative:"the non-thinking mode",pricing:{inputPerMTok:.55,outputPerMTok:2.19,cachedInputPerMTok:.14}}),mistral:Ne({id:"mistral",label:"Mistral",family:"mistral",contextWindow:128e3,tokenizer:"heuristic",charsPerToken:3.8,reasoning:!1,pricing:{inputPerMTok:2,outputPerMTok:6}}),grok:Ne({id:"grok",label:"Grok",family:"xai",contextWindow:128e3,tokenizer:"heuristic",charsPerToken:4,reasoning:!1,pricing:{inputPerMTok:2,outputPerMTok:6}}),llama:Ne({id:"llama",label:"Llama",family:"other",contextWindow:128e3,tokenizer:"heuristic",charsPerToken:3.9,reasoning:!1,pricing:{inputPerMTok:.27,outputPerMTok:.85}}),qwen:Ne({id:"qwen",label:"Qwen",family:"other",contextWindow:128e3,tokenizer:"heuristic",charsPerToken:3.8,reasoning:!1,pricing:{inputPerMTok:.4,outputPerMTok:1.2}}),kimi:Ne({id:"kimi",label:"Kimi",family:"other",contextWindow:256e3,tokenizer:"heuristic",charsPerToken:3.8,reasoning:!1,pricing:{inputPerMTok:.6,outputPerMTok:2.5,cachedInputPerMTok:.15}}),glm:Ne({id:"glm",label:"GLM",family:"other",contextWindow:2e5,tokenizer:"heuristic",charsPerToken:3.8,reasoning:!1,pricing:{inputPerMTok:.6,outputPerMTok:2.2,cachedInputPerMTok:.11}}),command:Ne({id:"command",label:"Cohere Command",family:"other",contextWindow:256e3,tokenizer:"heuristic",charsPerToken:4,reasoning:!1,pricing:{inputPerMTok:2.5,outputPerMTok:10}}),sonar:Ne({id:"sonar",label:"Perplexity Sonar",family:"other",contextWindow:128e3,tokenizer:"heuristic",charsPerToken:4,reasoning:!1,pricing:{inputPerMTok:1,outputPerMTok:1}}),gemma:Ne({id:"gemma",label:"Gemma",family:"other",contextWindow:128e3,tokenizer:"heuristic",charsPerToken:3.9,reasoning:!1,pricing:{inputPerMTok:.1,outputPerMTok:.2}}),phi:Ne({id:"phi",label:"Phi",family:"other",contextWindow:16e3,tokenizer:"heuristic",charsPerToken:3.9,reasoning:!1,pricing:{inputPerMTok:.07,outputPerMTok:.14}}),generic:Ne({id:"generic",label:"Unknown model",family:"other",contextWindow:128e3,tokenizer:"heuristic",charsPerToken:4,reasoning:!1,pricing:{inputPerMTok:2,outputPerMTok:10}})},dD=[[/\b(fable|mythos)\b/,"claude-fable"],[/\bastra\b|\bgpt[- ]?6\b/,"gpt-astra"],[/\bclaude\b.*\bopus\b|\bopus\b/,"claude-opus"],[/\bsonnet\b/,"claude-sonnet"],[/\bhaiku\b/,"claude-haiku"],[/\b(qwen|qwq)/,"qwen"],[/\b(glm|chatglm|zhipu)\b|\bglm-?\d/,"glm"],[/\b(kimi|moonshot)/,"kimi"],[/\bgemma/,"gemma"],[/\bgemini\b.*\bflash\b|\bflash\b/,"gemini-flash"],[/\bgemini\b.*\b(pro|ultra|deep think)\b|^\s*\d(\.\d)?\s*pro\b|\bdeep think\b/,"gemini-pro"],[/\bdeepseek\b.*\b(r1|reason|think|deepthink)|\bdeepthink\b/,"deepseek-reasoning"],[/\bdeepseek\b/,"deepseek"],[/\b(mistral|le chat|magistral|codestral)\b/,"mistral"],[/\bgrok\b/,"grok"],[/\bllama|codellama/,"llama"],[/\bcommand[- ]?(r|a)\b|\bcohere\b/,"command"],[/\bsonar\b|\bperplexity\b/,"sonar"],[/\bphi-?\d/,"phi"],[/\bo[1-9](-mini|-pro)?\b|\bgpt[- ]?\S*\s*(thinking|pro)\b|\bthinking\b/,"gpt-reasoning"],[/\b(gpt|chatgpt)\b|\bgpt-?\d/,"gpt"],[/\bgemini\b/,"gemini-pro"],[/\bclaude\b/,"claude-sonnet"]];var pD={chatgpt:"gpt",claude:"claude-sonnet",gemini:"gemini-flash",deepseek:"deepseek",mistral:"mistral",grok:"grok",generic:"generic"},mD=[];var iW={...hn};function Bn(e,t="generic"){let r=(e??"").toLowerCase().replace(/\s+/g," ").trim();if(r){for(let[a,n]of mD)if(a.test(r))return hn[n];if(t==="gemini"&&/\b(pro|deep think)\b/.test(r))return hn["gemini-pro"];if(t==="gemini"&&/\bflash\b/.test(r))return hn["gemini-flash"];if(t==="deepseek"&&/\b(deepthink|r1|think)/.test(r))return hn["deepseek-reasoning"];for(let[a,n]of dD)if(a.test(r))return hn[n]}return hn[pD[t]??"generic"]}var kA="ai-toolbox.co ChatGPT limits guide",Un={"chatgpt-free":{id:"chatgpt-free",site:"chatgpt",label:"ChatGPT Free",meter:"messages",caps:[]},"chatgpt-go":{id:"chatgpt-go",site:"chatgpt",label:"ChatGPT Go",meter:"messages",caps:[]},"chatgpt-plus":{id:"chatgpt-plus",site:"chatgpt",label:"ChatGPT Plus",meter:"messages",caps:[{models:["gpt"],messages:160,window:"3h",source:kA,asOf:"2026-10"},{models:["gpt-reasoning"],messages:3e3,window:"week",source:kA,asOf:"2026-10"}]},"chatgpt-pro":{id:"chatgpt-pro",site:"chatgpt",label:"ChatGPT Pro",meter:"messages",caps:[],note:"Pro is close to unlimited for everyday models, but GPT-6 Astra Pro use is capped (number not published)."},"chatgpt-business":{id:"chatgpt-business",site:"chatgpt",label:"ChatGPT Business",meter:"messages",caps:[]},"claude-free":{id:"claude-free",site:"claude",label:"Claude Free",meter:"compute",caps:[]},"claude-pro":{id:"claude-pro",site:"claude",label:"Claude Pro",meter:"compute",caps:[],note:"5-hour session and weekly limits shared across models; Fable runs on usage credits."},"claude-max":{id:"claude-max",site:"claude",label:"Claude Max",meter:"compute",caps:[],note:"5x or 20x Pro's session usage, with a weekly limit across models and one for the top models."},"claude-team":{id:"claude-team",site:"claude",label:"Claude Team",meter:"compute",caps:[]},"gemini-free":{id:"gemini-free",site:"gemini",label:"Gemini (free)",meter:"messages",caps:[]},"gemini-pro":{id:"gemini-pro",site:"gemini",label:"Google AI Pro",meter:"messages",caps:[]},"gemini-ultra":{id:"gemini-ultra",site:"gemini",label:"Google AI Ultra",meter:"messages",caps:[]}};var Fp=5*36e5,Lv=7*864e5,gD=1e3,hD=500,Ys=e=>Math.round(e).toLocaleString("en-US");function qp(e){let t=2166136261;for(let r=0;r<e.length;r++)t=Math.imul(t^e.charCodeAt(r),16777619)>>>0;return t.toString(36)}function _A(e){let t=/\b(Free|Pro|Max|Team|Enterprise)\s+plan\b/.exec(e);if(!t)return null;let r=t[1].toLowerCase();return Un[`claude-${r==="enterprise"?"team":r}`]??null}var fD=["sun","mon","tue","wed","thu","fri","sat"];function bD(e,t){let r=/\b(sun|mon|tue|wed|thu|fri|sat)\w*\s+(\d{1,2})(?::(\d{2}))?\s*(am|pm)?/i.exec(e);if(!r)return;let a=new Date(t),n=Number(r[2])%12;r[4]?.toLowerCase()==="pm"&&(n+=12),!r[4]&&Number(r[2])>=12&&(n=Number(r[2]));let i=(fD.indexOf(r[1].slice(0,3).toLowerCase())-a.getDay()+7)%7,o=new Date(a.getFullYear(),a.getMonth(),a.getDate()+i,n,Number(r[3]??0)).getTime();return o<=t?o+Lv:o}function vD(e){let t=/resets?\s+in\s+(?:(\d+)\s*(?:hr|hour|h)s?)?\s*(?:(\d+)\s*(?:min|minute|m)s?)?/i.exec(e);if(!(!t||!t[1]&&!t[2]))return(Number(t[1]??0)*60+Number(t[2]??0))*6e4}function wA(e,t){let r=e.replace(/\s+/g," "),a=/current session(.{0,160}?)(\d{1,3})\s*%\s*used/i.exec(r),n=/weekly (?:limits?|usage)(.{0,260}?)(\d{1,3})\s*%\s*used/i.exec(r),i=!a&&/(\d{1,3})\s*%\s+of\s+your\s+(session|5-hour|weekly)\s+(?:usage\s+)?limit/i.exec(r);if(!a&&!n&&!i)return null;let o={at:t};if(a){o.sessionPct=Math.min(100,Number(a[2]));let s=vD(a[1]);s!==void 0&&(o.sessionResetsAt=t+s)}if(n){o.weekPct=Math.min(100,Number(n[2]));let s=/resets?\s+((?:sun|mon|tue|wed|thu|fri|sat)\w*\s+\d{1,2}(?::\d{2})?\s*(?:am|pm)?)/i.exec(n[1]);s&&(o.weekResetsText=s[1].trim(),o.weekResetsAt=bD(s[1],t))}return i&&(/weekly/i.test(i[2])?o.weekPct=Math.min(100,Number(i[1])):o.sessionPct=Math.min(100,Number(i[1]))),o}var Mv=e=>new Date(e).toLocaleTimeString("en-US",{hour:"numeric",minute:"2-digit"});function Uv(e,t){return{...e,sends:e.sends.filter(r=>t-r.at<Lv).slice(-5e3),readings:e.readings.filter(r=>t-r.at<Lv).slice(-50)}}function SA(e,t){let r=[...e.readings].reverse().find(i=>i.sessionPct!==void 0),a=e.pctPer1k;if(r&&t.sessionPct!==void 0&&r.sessionPct!==void 0&&t.sessionPct>r.sessionPct&&t.at-r.at<Fp){let i=e.sends.filter(o=>o.at>r.at&&o.at<=t.at).reduce((o,s)=>o+s.tokens,0);if(i>=5e3){let o=(t.sessionPct-r.sessionPct)/i*1e3;a=a===void 0?o:a*.5+o*.5}}let n=r&&r.sessionPct===t.sessionPct&&r.weekPct===t.weekPct&&t.at-r.at<10*6e4;return{...e,pctPer1k:a,readings:n?e.readings:[...e.readings,t]}}function Hp(e){let{data:t,now:r,plan:a,current:n}=e,i=[...t.readings].reverse().find(S=>S.sessionPct!==void 0||S.weekPct!==void 0),o=[...t.readings].reverse().find(S=>S.weekPct!==void 0),s=[...t.readings].reverse().find(S=>S.sessionPct!==void 0),l=s&&(s.sessionResetsAt??s.at+Fp)>r,c=l&&s.sessionResetsAt?s.sessionResetsAt-Fp:r-Fp,u=t.sends.filter(S=>S.at>=c),d=S=>S.reduce((P,U)=>P+U.tokens,0),m=d(u),p={plan:a,planSource:e.planSource,session:{messages:u.length,tokens:m,since:c},week:{messages:t.sends.length,tokens:d(t.sends)},topChats:[],insights:[]};if(l&&s?.sessionPct!==void 0){let S=d(t.sends.filter(U=>U.at>s.at)),P=s.sessionPct+(t.pctPer1k?S/1e3*t.pctPer1k:0);p.sessionPct=Math.min(100,Math.round(P)),p.sessionResetsAt=s.sessionResetsAt,p.meterAgeMin=Math.round((r-s.at)/6e4)}o?.weekPct!==void 0&&(o.weekResetsAt??1/0)>r&&(p.weekPct=o.weekPct,p.weekResetsAt=o.weekResetsAt,p.weekResetsText=o.weekResetsText);let g=new Map;for(let S of u){let P=g.get(S.chat)??{chat:S.chat,title:e.titles?.get(S.chat),tokens:0,messages:0,share:0};P.tokens+=S.tokens,P.messages++,g.set(S.chat,P)}p.topChats=[...g.values()].map(S=>({...S,share:m?S.tokens/m:0})).sort((S,P)=>P.tokens-S.tokens).slice(0,5);let h=hD,f=(n?.tokens??0)+h,_=gD+h;if(p.sessionPct!==void 0&&t.pctPer1k){let S=Math.max(0,100-p.sessionPct)/t.pctPer1k*1e3;p.left={here:Math.floor(S/f),fresh:Math.floor(S/_)}}let b=p.insights,v=a?a.label:"your plan";if(p.sessionPct!==void 0){let S=p.sessionResetsAt?`; it resets at ${Mv(p.sessionResetsAt)}`:"";p.left&&n&&n.tokens>=1e4&&p.left.fresh>=p.left.here*2?b.push(`About ${Ys(p.left.here)} more messages fit in ${v}'s session at this chat's size, or about ${Ys(p.left.fresh)} in a new chat (${p.sessionPct}% used${S}). For a new topic, start a new chat. ${Rt}`):p.left?b.push(`About ${Ys(p.left.fresh)} more messages like your recent ones fit in this session (${p.sessionPct}% used${S}).`):b.push(`Session ${p.sessionPct}% used${S}.`);let P=s&&t.readings.find(U=>U.sessionPct!==void 0&&U.at>=c);if(P&&s&&P!==s&&p.sessionResetsAt&&p.sessionPct<100){let U=(p.sessionPct-(P.sessionPct??0))/Math.max(1,r-P.at),qe=U>0?r+(100-p.sessionPct)/U:1/0;qe<p.sessionResetsAt&&b.push(`At this pace the session runs out around ${Mv(qe)}, before it resets at ${Mv(p.sessionResetsAt)}. Save the big asks for after the reset, or start new topics in new chats.`)}}let C=p.topChats[0];return C&&u.length>=4&&C.share>=.5&&g.size>1&&b.push(`${Math.round(C.share*100)}% of this session's usage came from one chat${C.title?` ("${C.title}")`:""}: each message there re-read about ${Ys(C.tokens/C.messages)} tokens.`),p.weekPct!==void 0&&p.weekResetsAt&&((p.weekResetsAt-r)/36e5<=36&&p.weekPct<=50?b.push(`${100-p.weekPct}% of ${v}'s weekly allowance is unused and resets ${p.weekResetsText??"soon"}. It doesn't carry over, so this is a good time for the big jobs you've been holding back.`):p.weekPct>=80&&b.push(`Week ${p.weekPct}% used${p.weekResetsText?`, resets ${p.weekResetsText}`:""}. New topics in new chats and one complete message per ask stretch what's left.`)),n&&n.tokens>=2e4&&!b.some(S=>S.includes("new chat"))&&b.push(`Every message in this chat re-reads about ${Ys(n.tokens)} tokens, ${Math.max(2,Math.round(f/_))}\xD7 a new chat. On ${v} that's what uses your allowance fastest.`),a?p.sessionPct===void 0&&a.site==="claude"&&b.push("Open Settings > Usage in Claude once and Token Lens reads your meter from it, to count how many messages you have left."):b.push("Tell Token Lens your plan once (Free, Pro, Max or Team) for advice that fits it."),p}var yD=/^(?:ok(?:ay)?|k|thanks?(?: you)?(?: so much)?|thx|ty|great|perfect|nice|cool|awesome|got it|understood|sounds good|lgtm|yes|yep|sure|done|👍|🙏)[\s!.,🙂😊👍🙏]*$/i;function EA(e){return yD.test(e.trim())}var Bv=e=>e.toLowerCase().replace(/[^\p{L}\p{N}]+/gu," ").trim();function xA(e,t){let r=Bv(e);return r.split(" ").length<8?!1:Bv(t).includes(r)}function TA(e){return e.split(/\n\s*\n/).map(t=>t.trim()).filter(t=>t.length>=1200).map(t=>qp(Bv(t)))}function AA(e,t,r){let a=Ce(e,r).tokens,n=Ce(t,r).tokens,o=ea(e,t).lost.map(d=>d.replace(":",": ")),s=Js(e,t),l=o.length===0&&s.length===0,c=a-n,u=l?c>0?"Safe to send: the shorter version keeps every fact, constraint and instruction word.":"Same instructions, but no shorter: keep whichever you prefer.":o.length?"Check before sending: the edit drops facts or constraints that can change the answer.":"Check before sending: the edit drops words that may carry instructions.";return{before:a,after:n,saved:$t(c,r),sameInstructions:l,lostFacts:o,lostWords:s.slice(0,20),verdict:u}}var kD=new Set(["openai","anthropic","google"]);function CA(e,t){let r=e.pricing,a=Math.round(t.callsPerDay*(t.days??30));if(!r)return{priced:!1,callsPerMonth:a,longContext:!1,rates:{input:0,output:0,cached:null},lines:[]};let n=r.longContext&&t.inputTokens>r.longContext.aboveTokens?r.longContext:void 0,i=n?.inputPerMTok??r.inputPerMTok,o=n?.outputPerMTok??r.outputPerMTok,s=r.cachedInputPerMTok===void 0?null:r.cachedInputPerMTok*(i/r.inputPerMTok),l=Math.min(t.repeatedPrefixTokens??0,t.inputTokens),c=Math.min(1,Math.max(0,t.canWaitShare??0)),u=f=>{let _=f&&s!==null?t.inputTokens-l:t.inputTokens,b=f&&s!==null?l:0;return(_*i+b*(s??0)+t.outputTokens*o)/1e6},d=u(!1)*a,m=[{id:"now",label:"As it runs now",monthlyUsd:d,savedUsd:0,note:n?`Each call passes ${n.aboveTokens.toLocaleString("en-US")} input tokens, so the long-context rate applies.`:""}],p=s!==null&&l>0,g=kD.has(e.family)&&c>0;if(p){let f=u(!0)*a;m.push({id:"caching",label:"With prompt caching on the repeated part",monthlyUsd:f,savedUsd:d-f,note:"Same model, same request, same answer. Assumes calls come often enough to keep the cache warm (a few minutes apart); the first call after a gap pays full price, plus a small write fee on some providers."})}let h=f=>f-f*c*.5;if(g){let f=h(d);m.push({id:"batch",label:`Half-price batch for the ${Math.round(c*100)}% of calls that can wait`,monthlyUsd:f,savedUsd:d-f,note:"Same model and same answer, delivered within 24 hours instead of right away."})}if(p&&g){let f=h(u(!0)*a);m.push({id:"both",label:"Both together",monthlyUsd:f,savedUsd:d-f,note:""})}return{priced:!0,callsPerMonth:a,longContext:!!n,rates:{input:i,output:o,cached:s},lines:m}}function Vp(e,t){return e===t||ea(e,t,"presence").ok&&Js(e,t).length===0}function Fv(e){return Array.isArray(e)?e.map(Fv):!e||typeof e!="object"?e:Object.fromEntries(Object.entries(e).filter(([t])=>t!=="description").map(([t,r])=>[t,Fv(r)]))}function zA(e){let t=[];e.system&&t.push(["system prompt",e.system]);for(let r of e.tools??[]){r.description&&t.push([`tool ${r.name}`,r.description]);let a=(n,i)=>{if(Array.isArray(n))n.forEach((o,s)=>a(o,`${i}[${s}]`));else if(n&&typeof n=="object")for(let[o,s]of Object.entries(n))o==="description"&&typeof s=="string"?t.push([`tool ${r.name} ${i}`,s]):a(s,`${i}.${o}`)};a(r.parameters,"params")}for(let[r,a]of(e.examples??[]).entries())t.push([`example ${r+1}`,a]);return e.prompt&&t.push(["next prompt",e.prompt]),t}var Gp=(e,t)=>`${e} ${t}${e===1?"":"s"}`;function IA(e,t){let r=[],a=zA(e),n=new Map(zA(t)),i={},o=[];for(let[h,f]of a){let _=n.get(h)??"";for(let[b,[v,C]]of Object.entries(Mp(f,_))){let[S,P]=i[b]??[0,0];i[b]=[S+v,P+C]}ea(f,_,"presence").ok||o.push(h)}let s=Object.entries(i).map(([h,[f,_]])=>`${_}/${f} ${h}s`);r.push({name:"Facts and constraints kept",passed:o.length===0,detail:o.length?`Lost in: ${o.join(", ")}`:s.length?`Kept ${s.join(", ")}.`:"No numbers, links, code or constraint words to keep."});let l=[];for(let[h,f]of a){let _=Js(f,n.get(h)??"");_.length&&l.push(`${h}: ${_.join(", ")}`)}r.push({name:"Instructions kept",passed:l.length===0,detail:l.length?`Missing words: ${l.join("; ")}`:`Every content word of ${Gp(a.length,"text")} is still there; only filler was removed.`});let c=(h=[])=>JSON.stringify(h.map(f=>[f.name,Fv(f.parameters??null)])),u=c(e.tools)===c(t.tools);r.push({name:"Tool interface unchanged",passed:u,detail:u?`${Gp(e.tools?.length??0,"tool")}: same names, parameters, types, required fields and enums.`:"Tool names or parameter schemas differ."});let d=e.messages??[],m=t.messages??[],p=0,g=d.length===m.length&&d.every((h,f)=>{let _=m[f];if(_.role!==h.role)return!1;if(_.content===h.content)return!0;let b=/^\[Same content as message (\d+) above\.\]$/.exec(_.content),v=!!b&&d[Number(b[1])-1]?.content.trim()===h.content.trim();return v&&p++,v});return d.length&&r.push({name:"Conversation unchanged",passed:g,detail:g?`${Gp(d.length,"message")} in order${p?`; ${Gp(p,"exact repeat")} replaced by a pointer to the first copy`:", all verbatim"}.`:"Messages were dropped, reordered or edited."}),r.push({name:"Model and examples unchanged",passed:(e.examples?.length??0)===(t.examples?.length??0),detail:"Token Lens never switches the model or drops examples on its own."}),{passed:r.every(h=>h.passed),checks:r}}var Ye=e=>e.toLocaleString("en-US"),PA=(e,t)=>t?Math.round(e/t*100):0;function RA(e){return`${e.name}
|
|
3371
|
+
`);return b!==_&&(d=!0),_=b,_});return a.length&&n.push(`removed indentation and line breaks from ${a.length} JSON block${a.length>1?"s":""} (same data)`),d&&n.push("removed trailing spaces and extra blank lines outside code"),o(m.join(""),a.length||d?void 0:"Nothing to compact: no pretty-printed JSON or extra whitespace found.")}var Ne=e=>e,hn={"gpt-astra":Ne({id:"gpt-astra",label:"GPT-6 Astra",family:"openai",contextWindow:105e4,tokenizer:"heuristic",charsPerToken:4.2,reasoning:!0,pricing:{inputPerMTok:10,outputPerMTok:50}}),"gpt-reasoning":Ne({id:"gpt-reasoning",label:"GPT (thinking)",family:"openai",contextWindow:196e3,tokenizer:"o200k",charsPerToken:4.2,reasoning:!0,lighterAlternative:"the Instant / non-thinking model",pricing:{inputPerMTok:5,outputPerMTok:30,cachedInputPerMTok:.5}}),gpt:Ne({id:"gpt",label:"GPT",family:"openai",contextWindow:128e3,tokenizer:"o200k",charsPerToken:4.2,reasoning:!1,pricing:{inputPerMTok:2.5,outputPerMTok:15,cachedInputPerMTok:.25}}),"claude-fable":Ne({id:"claude-fable",label:"Claude Fable",family:"anthropic",contextWindow:1e6,tokenizer:"heuristic",charsPerToken:3.5,reasoning:!0,notes:["Claude reads XML-style tags well: wrap pasted material in <doc>\u2026</doc> instead of explaining it."],pricing:{inputPerMTok:10,outputPerMTok:50,cachedInputPerMTok:.25}}),"claude-opus":Ne({id:"claude-opus",label:"Claude Opus",family:"anthropic",contextWindow:2e5,tokenizer:"heuristic",charsPerToken:3.5,reasoning:!1,lighterAlternative:"Sonnet or Haiku",notes:["Claude reads XML-style tags well: wrap pasted material in <doc>\u2026</doc> instead of explaining it."],pricing:{inputPerMTok:4,outputPerMTok:20,cachedInputPerMTok:.2}}),"claude-sonnet":Ne({id:"claude-sonnet",label:"Claude Sonnet",family:"anthropic",contextWindow:2e5,tokenizer:"heuristic",charsPerToken:3.5,reasoning:!1,lighterAlternative:"Haiku",notes:["Claude reads XML-style tags well: wrap pasted material in <doc>\u2026</doc> instead of explaining it."],pricing:{inputPerMTok:2,outputPerMTok:10,cachedInputPerMTok:.2}}),"claude-haiku":Ne({id:"claude-haiku",label:"Claude Haiku",family:"anthropic",contextWindow:2e5,tokenizer:"heuristic",charsPerToken:3.5,reasoning:!1,pricing:{inputPerMTok:.1,outputPerMTok:.5,cachedInputPerMTok:.01}}),"gemini-pro":Ne({id:"gemini-pro",label:"Gemini Pro",family:"google",contextWindow:1e6,tokenizer:"heuristic",charsPerToken:4,reasoning:!0,lighterAlternative:"Flash",pricing:{inputPerMTok:2,outputPerMTok:12,cachedInputPerMTok:.2,longContext:{aboveTokens:2e5,inputPerMTok:4,outputPerMTok:18}}}),"gemini-flash":Ne({id:"gemini-flash",label:"Gemini Flash",family:"google",contextWindow:1e6,tokenizer:"heuristic",charsPerToken:4,reasoning:!1,pricing:{inputPerMTok:1.5,outputPerMTok:9,cachedInputPerMTok:.15}}),deepseek:Ne({id:"deepseek",label:"DeepSeek",family:"deepseek",contextWindow:128e3,tokenizer:"heuristic",charsPerToken:3.8,reasoning:!1,pricing:{inputPerMTok:.28,outputPerMTok:.42,cachedInputPerMTok:.028}}),"deepseek-reasoning":Ne({id:"deepseek-reasoning",label:"DeepSeek (thinking)",family:"deepseek",contextWindow:128e3,tokenizer:"heuristic",charsPerToken:3.8,reasoning:!0,lighterAlternative:"the non-thinking mode",pricing:{inputPerMTok:.55,outputPerMTok:2.19,cachedInputPerMTok:.14}}),mistral:Ne({id:"mistral",label:"Mistral",family:"mistral",contextWindow:128e3,tokenizer:"heuristic",charsPerToken:3.8,reasoning:!1,pricing:{inputPerMTok:2,outputPerMTok:6}}),grok:Ne({id:"grok",label:"Grok",family:"xai",contextWindow:128e3,tokenizer:"heuristic",charsPerToken:4,reasoning:!1,pricing:{inputPerMTok:2,outputPerMTok:6}}),llama:Ne({id:"llama",label:"Llama",family:"other",contextWindow:128e3,tokenizer:"heuristic",charsPerToken:3.9,reasoning:!1,pricing:{inputPerMTok:.27,outputPerMTok:.85}}),qwen:Ne({id:"qwen",label:"Qwen",family:"other",contextWindow:128e3,tokenizer:"heuristic",charsPerToken:3.8,reasoning:!1,pricing:{inputPerMTok:.4,outputPerMTok:1.2}}),kimi:Ne({id:"kimi",label:"Kimi",family:"other",contextWindow:256e3,tokenizer:"heuristic",charsPerToken:3.8,reasoning:!1,pricing:{inputPerMTok:.6,outputPerMTok:2.5,cachedInputPerMTok:.15}}),glm:Ne({id:"glm",label:"GLM",family:"other",contextWindow:2e5,tokenizer:"heuristic",charsPerToken:3.8,reasoning:!1,pricing:{inputPerMTok:.6,outputPerMTok:2.2,cachedInputPerMTok:.11}}),command:Ne({id:"command",label:"Cohere Command",family:"other",contextWindow:256e3,tokenizer:"heuristic",charsPerToken:4,reasoning:!1,pricing:{inputPerMTok:2.5,outputPerMTok:10}}),sonar:Ne({id:"sonar",label:"Perplexity Sonar",family:"other",contextWindow:128e3,tokenizer:"heuristic",charsPerToken:4,reasoning:!1,pricing:{inputPerMTok:1,outputPerMTok:1}}),gemma:Ne({id:"gemma",label:"Gemma",family:"other",contextWindow:128e3,tokenizer:"heuristic",charsPerToken:3.9,reasoning:!1,pricing:{inputPerMTok:.1,outputPerMTok:.2}}),phi:Ne({id:"phi",label:"Phi",family:"other",contextWindow:16e3,tokenizer:"heuristic",charsPerToken:3.9,reasoning:!1,pricing:{inputPerMTok:.07,outputPerMTok:.14}}),generic:Ne({id:"generic",label:"Unknown model",family:"other",contextWindow:128e3,tokenizer:"heuristic",charsPerToken:4,reasoning:!1,pricing:{inputPerMTok:2,outputPerMTok:10}})},dD=[[/\b(fable|mythos)\b/,"claude-fable"],[/\bastra\b|\bgpt[- ]?6\b/,"gpt-astra"],[/\bclaude\b.*\bopus\b|\bopus\b/,"claude-opus"],[/\bsonnet\b/,"claude-sonnet"],[/\bhaiku\b/,"claude-haiku"],[/\b(qwen|qwq)/,"qwen"],[/\b(glm|chatglm|zhipu)\b|\bglm-?\d/,"glm"],[/\b(kimi|moonshot)/,"kimi"],[/\bgemma/,"gemma"],[/\bgemini\b.*\bflash\b|\bflash\b/,"gemini-flash"],[/\bgemini\b.*\b(pro|ultra|deep think)\b|^\s*\d(\.\d)?\s*pro\b|\bdeep think\b/,"gemini-pro"],[/\bdeepseek\b.*\b(r1|reason|think|deepthink)|\bdeepthink\b/,"deepseek-reasoning"],[/\bdeepseek\b/,"deepseek"],[/\b(mistral|le chat|magistral|codestral)\b/,"mistral"],[/\bgrok\b/,"grok"],[/\bllama|codellama/,"llama"],[/\bcommand[- ]?(r|a)\b|\bcohere\b/,"command"],[/\bsonar\b|\bperplexity\b/,"sonar"],[/\bphi-?\d/,"phi"],[/\bo[1-9](-mini|-pro)?\b|\bgpt[- ]?\S*\s*(thinking|pro)\b|\bthinking\b/,"gpt-reasoning"],[/\b(gpt|chatgpt)\b|\bgpt-?\d/,"gpt"],[/\bgemini\b/,"gemini-pro"],[/\bclaude\b/,"claude-sonnet"]];var pD={chatgpt:"gpt",claude:"claude-sonnet",gemini:"gemini-flash",deepseek:"deepseek",mistral:"mistral",grok:"grok",generic:"generic"},mD=[];var sW={...hn};function Bn(e,t="generic"){let r=(e??"").toLowerCase().replace(/\s+/g," ").trim();if(r){for(let[a,n]of mD)if(a.test(r))return hn[n];if(t==="gemini"&&/\b(pro|deep think)\b/.test(r))return hn["gemini-pro"];if(t==="gemini"&&/\bflash\b/.test(r))return hn["gemini-flash"];if(t==="deepseek"&&/\b(deepthink|r1|think)/.test(r))return hn["deepseek-reasoning"];for(let[a,n]of dD)if(a.test(r))return hn[n]}return hn[pD[t]??"generic"]}var kA="ai-toolbox.co ChatGPT limits guide",Un={"chatgpt-free":{id:"chatgpt-free",site:"chatgpt",label:"ChatGPT Free",meter:"messages",caps:[]},"chatgpt-go":{id:"chatgpt-go",site:"chatgpt",label:"ChatGPT Go",meter:"messages",caps:[]},"chatgpt-plus":{id:"chatgpt-plus",site:"chatgpt",label:"ChatGPT Plus",meter:"messages",caps:[{models:["gpt"],messages:160,window:"3h",source:kA,asOf:"2026-10"},{models:["gpt-reasoning"],messages:3e3,window:"week",source:kA,asOf:"2026-10"}]},"chatgpt-pro":{id:"chatgpt-pro",site:"chatgpt",label:"ChatGPT Pro",meter:"messages",caps:[],note:"Pro is close to unlimited for everyday models, but GPT-6 Astra Pro use is capped (number not published)."},"chatgpt-business":{id:"chatgpt-business",site:"chatgpt",label:"ChatGPT Business",meter:"messages",caps:[]},"claude-free":{id:"claude-free",site:"claude",label:"Claude Free",meter:"compute",caps:[]},"claude-pro":{id:"claude-pro",site:"claude",label:"Claude Pro",meter:"compute",caps:[],note:"5-hour session and weekly limits shared across models; Fable runs on usage credits."},"claude-max":{id:"claude-max",site:"claude",label:"Claude Max",meter:"compute",caps:[],note:"5x or 20x Pro's session usage, with a weekly limit across models and one for the top models."},"claude-team":{id:"claude-team",site:"claude",label:"Claude Team",meter:"compute",caps:[]},"gemini-free":{id:"gemini-free",site:"gemini",label:"Gemini (free)",meter:"messages",caps:[]},"gemini-pro":{id:"gemini-pro",site:"gemini",label:"Google AI Pro",meter:"messages",caps:[]},"gemini-ultra":{id:"gemini-ultra",site:"gemini",label:"Google AI Ultra",meter:"messages",caps:[]}};var Fp=5*36e5,Lv=7*864e5,gD=1e3,hD=500,Ys=e=>Math.round(e).toLocaleString("en-US");function qp(e){let t=2166136261;for(let r=0;r<e.length;r++)t=Math.imul(t^e.charCodeAt(r),16777619)>>>0;return t.toString(36)}function _A(e){let t=/\b(Free|Pro|Max|Team|Enterprise)\s+plan\b/.exec(e);if(!t)return null;let r=t[1].toLowerCase();return Un[`claude-${r==="enterprise"?"team":r}`]??null}var fD=["sun","mon","tue","wed","thu","fri","sat"];function bD(e,t){let r=/\b(sun|mon|tue|wed|thu|fri|sat)\w*\s+(\d{1,2})(?::(\d{2}))?\s*(am|pm)?/i.exec(e);if(!r)return;let a=new Date(t),n=Number(r[2])%12;r[4]?.toLowerCase()==="pm"&&(n+=12),!r[4]&&Number(r[2])>=12&&(n=Number(r[2]));let i=(fD.indexOf(r[1].slice(0,3).toLowerCase())-a.getDay()+7)%7,o=new Date(a.getFullYear(),a.getMonth(),a.getDate()+i,n,Number(r[3]??0)).getTime();return o<=t?o+Lv:o}function vD(e){let t=/resets?\s+in\s+(?:(\d+)\s*(?:hr|hour|h)s?)?\s*(?:(\d+)\s*(?:min|minute|m)s?)?/i.exec(e);if(!(!t||!t[1]&&!t[2]))return(Number(t[1]??0)*60+Number(t[2]??0))*6e4}function wA(e,t){let r=e.replace(/\s+/g," "),a=/current session(.{0,160}?)(\d{1,3})\s*%\s*used/i.exec(r),n=/weekly (?:limits?|usage)(.{0,260}?)(\d{1,3})\s*%\s*used/i.exec(r),i=!a&&/(\d{1,3})\s*%\s+of\s+your\s+(session|5-hour|weekly)\s+(?:usage\s+)?limit/i.exec(r);if(!a&&!n&&!i)return null;let o={at:t};if(a){o.sessionPct=Math.min(100,Number(a[2]));let s=vD(a[1]);s!==void 0&&(o.sessionResetsAt=t+s)}if(n){o.weekPct=Math.min(100,Number(n[2]));let s=/resets?\s+((?:sun|mon|tue|wed|thu|fri|sat)\w*\s+\d{1,2}(?::\d{2})?\s*(?:am|pm)?)/i.exec(n[1]);s&&(o.weekResetsText=s[1].trim(),o.weekResetsAt=bD(s[1],t))}return i&&(/weekly/i.test(i[2])?o.weekPct=Math.min(100,Number(i[1])):o.sessionPct=Math.min(100,Number(i[1]))),o}var Mv=e=>new Date(e).toLocaleTimeString("en-US",{hour:"numeric",minute:"2-digit"});function Uv(e,t){return{...e,sends:e.sends.filter(r=>t-r.at<Lv).slice(-5e3),readings:e.readings.filter(r=>t-r.at<Lv).slice(-50)}}function SA(e,t){let r=[...e.readings].reverse().find(i=>i.sessionPct!==void 0),a=e.pctPer1k;if(r&&t.sessionPct!==void 0&&r.sessionPct!==void 0&&t.sessionPct>r.sessionPct&&t.at-r.at<Fp){let i=e.sends.filter(o=>o.at>r.at&&o.at<=t.at).reduce((o,s)=>o+s.tokens,0);if(i>=5e3){let o=(t.sessionPct-r.sessionPct)/i*1e3;a=a===void 0?o:a*.5+o*.5}}let n=r&&r.sessionPct===t.sessionPct&&r.weekPct===t.weekPct&&t.at-r.at<10*6e4;return{...e,pctPer1k:a,readings:n?e.readings:[...e.readings,t]}}function Hp(e){let{data:t,now:r,plan:a,current:n}=e,i=[...t.readings].reverse().find(S=>S.sessionPct!==void 0||S.weekPct!==void 0),o=[...t.readings].reverse().find(S=>S.weekPct!==void 0),s=[...t.readings].reverse().find(S=>S.sessionPct!==void 0),l=s&&(s.sessionResetsAt??s.at+Fp)>r,c=l&&s.sessionResetsAt?s.sessionResetsAt-Fp:r-Fp,u=t.sends.filter(S=>S.at>=c),d=S=>S.reduce((P,U)=>P+U.tokens,0),m=d(u),p={plan:a,planSource:e.planSource,session:{messages:u.length,tokens:m,since:c},week:{messages:t.sends.length,tokens:d(t.sends)},topChats:[],insights:[]};if(l&&s?.sessionPct!==void 0){let S=d(t.sends.filter(U=>U.at>s.at)),P=s.sessionPct+(t.pctPer1k?S/1e3*t.pctPer1k:0);p.sessionPct=Math.min(100,Math.round(P)),p.sessionResetsAt=s.sessionResetsAt,p.meterAgeMin=Math.round((r-s.at)/6e4)}o?.weekPct!==void 0&&(o.weekResetsAt??1/0)>r&&(p.weekPct=o.weekPct,p.weekResetsAt=o.weekResetsAt,p.weekResetsText=o.weekResetsText);let g=new Map;for(let S of u){let P=g.get(S.chat)??{chat:S.chat,title:e.titles?.get(S.chat),tokens:0,messages:0,share:0};P.tokens+=S.tokens,P.messages++,g.set(S.chat,P)}p.topChats=[...g.values()].map(S=>({...S,share:m?S.tokens/m:0})).sort((S,P)=>P.tokens-S.tokens).slice(0,5);let h=hD,f=(n?.tokens??0)+h,_=gD+h;if(p.sessionPct!==void 0&&t.pctPer1k){let S=Math.max(0,100-p.sessionPct)/t.pctPer1k*1e3;p.left={here:Math.floor(S/f),fresh:Math.floor(S/_)}}let b=p.insights,v=a?a.label:"your plan";if(p.sessionPct!==void 0){let S=p.sessionResetsAt?`; it resets at ${Mv(p.sessionResetsAt)}`:"";p.left&&n&&n.tokens>=1e4&&p.left.fresh>=p.left.here*2?b.push(`About ${Ys(p.left.here)} more messages fit in ${v}'s session at this chat's size, or about ${Ys(p.left.fresh)} in a new chat (${p.sessionPct}% used${S}). For a new topic, start a new chat. ${Rt}`):p.left?b.push(`About ${Ys(p.left.fresh)} more messages like your recent ones fit in this session (${p.sessionPct}% used${S}).`):b.push(`Session ${p.sessionPct}% used${S}.`);let P=s&&t.readings.find(U=>U.sessionPct!==void 0&&U.at>=c);if(P&&s&&P!==s&&p.sessionResetsAt&&p.sessionPct<100){let U=(p.sessionPct-(P.sessionPct??0))/Math.max(1,r-P.at),qe=U>0?r+(100-p.sessionPct)/U:1/0;qe<p.sessionResetsAt&&b.push(`At this pace the session runs out around ${Mv(qe)}, before it resets at ${Mv(p.sessionResetsAt)}. Save the big asks for after the reset, or start new topics in new chats.`)}}let C=p.topChats[0];return C&&u.length>=4&&C.share>=.5&&g.size>1&&b.push(`${Math.round(C.share*100)}% of this session's usage came from one chat${C.title?` ("${C.title}")`:""}: each message there re-read about ${Ys(C.tokens/C.messages)} tokens.`),p.weekPct!==void 0&&p.weekResetsAt&&((p.weekResetsAt-r)/36e5<=36&&p.weekPct<=50?b.push(`${100-p.weekPct}% of ${v}'s weekly allowance is unused and resets ${p.weekResetsText??"soon"}. It doesn't carry over, so this is a good time for the big jobs you've been holding back.`):p.weekPct>=80&&b.push(`Week ${p.weekPct}% used${p.weekResetsText?`, resets ${p.weekResetsText}`:""}. New topics in new chats and one complete message per ask stretch what's left.`)),n&&n.tokens>=2e4&&!b.some(S=>S.includes("new chat"))&&b.push(`Every message in this chat re-reads about ${Ys(n.tokens)} tokens, ${Math.max(2,Math.round(f/_))}\xD7 a new chat. On ${v} that's what uses your allowance fastest.`),a?p.sessionPct===void 0&&a.site==="claude"&&b.push("Open Settings > Usage in Claude once and Token Lens reads your meter from it, to count how many messages you have left."):b.push("Tell Token Lens your plan once (Free, Pro, Max or Team) for advice that fits it."),p}var yD=/^(?:ok(?:ay)?|k|thanks?(?: you)?(?: so much)?|thx|ty|great|perfect|nice|cool|awesome|got it|understood|sounds good|lgtm|yes|yep|sure|done|👍|🙏)[\s!.,🙂😊👍🙏]*$/i;function EA(e){return yD.test(e.trim())}var Bv=e=>e.toLowerCase().replace(/[^\p{L}\p{N}]+/gu," ").trim();function xA(e,t){let r=Bv(e);return r.split(" ").length<8?!1:Bv(t).includes(r)}function TA(e){return e.split(/\n\s*\n/).map(t=>t.trim()).filter(t=>t.length>=1200).map(t=>qp(Bv(t)))}function AA(e,t,r){let a=Ce(e,r).tokens,n=Ce(t,r).tokens,o=ea(e,t).lost.map(d=>d.replace(":",": ")),s=Js(e,t),l=o.length===0&&s.length===0,c=a-n,u=l?c>0?"Safe to send: the shorter version keeps every fact, constraint and instruction word.":"Same instructions, but no shorter: keep whichever you prefer.":o.length?"Check before sending: the edit drops facts or constraints that can change the answer.":"Check before sending: the edit drops words that may carry instructions.";return{before:a,after:n,saved:$t(c,r),sameInstructions:l,lostFacts:o,lostWords:s.slice(0,20),verdict:u}}var kD=new Set(["openai","anthropic","google"]);function CA(e,t){let r=e.pricing,a=Math.round(t.callsPerDay*(t.days??30));if(!r)return{priced:!1,callsPerMonth:a,longContext:!1,rates:{input:0,output:0,cached:null},lines:[]};let n=r.longContext&&t.inputTokens>r.longContext.aboveTokens?r.longContext:void 0,i=n?.inputPerMTok??r.inputPerMTok,o=n?.outputPerMTok??r.outputPerMTok,s=r.cachedInputPerMTok===void 0?null:r.cachedInputPerMTok*(i/r.inputPerMTok),l=Math.min(t.repeatedPrefixTokens??0,t.inputTokens),c=Math.min(1,Math.max(0,t.canWaitShare??0)),u=f=>{let _=f&&s!==null?t.inputTokens-l:t.inputTokens,b=f&&s!==null?l:0;return(_*i+b*(s??0)+t.outputTokens*o)/1e6},d=u(!1)*a,m=[{id:"now",label:"As it runs now",monthlyUsd:d,savedUsd:0,note:n?`Each call passes ${n.aboveTokens.toLocaleString("en-US")} input tokens, so the long-context rate applies.`:""}],p=s!==null&&l>0,g=kD.has(e.family)&&c>0;if(p){let f=u(!0)*a;m.push({id:"caching",label:"With prompt caching on the repeated part",monthlyUsd:f,savedUsd:d-f,note:"Same model, same request, same answer. Assumes calls come often enough to keep the cache warm (a few minutes apart); the first call after a gap pays full price, plus a small write fee on some providers."})}let h=f=>f-f*c*.5;if(g){let f=h(d);m.push({id:"batch",label:`Half-price batch for the ${Math.round(c*100)}% of calls that can wait`,monthlyUsd:f,savedUsd:d-f,note:"Same model and same answer, delivered within 24 hours instead of right away."})}if(p&&g){let f=h(u(!0)*a);m.push({id:"both",label:"Both together",monthlyUsd:f,savedUsd:d-f,note:""})}return{priced:!0,callsPerMonth:a,longContext:!!n,rates:{input:i,output:o,cached:s},lines:m}}function Vp(e,t){return e===t||ea(e,t,"presence").ok&&Js(e,t).length===0}function Fv(e){return Array.isArray(e)?e.map(Fv):!e||typeof e!="object"?e:Object.fromEntries(Object.entries(e).filter(([t])=>t!=="description").map(([t,r])=>[t,Fv(r)]))}function zA(e){let t=[];e.system&&t.push(["system prompt",e.system]);for(let r of e.tools??[]){r.description&&t.push([`tool ${r.name}`,r.description]);let a=(n,i)=>{if(Array.isArray(n))n.forEach((o,s)=>a(o,`${i}[${s}]`));else if(n&&typeof n=="object")for(let[o,s]of Object.entries(n))o==="description"&&typeof s=="string"?t.push([`tool ${r.name} ${i}`,s]):a(s,`${i}.${o}`)};a(r.parameters,"params")}for(let[r,a]of(e.examples??[]).entries())t.push([`example ${r+1}`,a]);return e.prompt&&t.push(["next prompt",e.prompt]),t}var Gp=(e,t)=>`${e} ${t}${e===1?"":"s"}`;function IA(e,t){let r=[],a=zA(e),n=new Map(zA(t)),i={},o=[];for(let[h,f]of a){let _=n.get(h)??"";for(let[b,[v,C]]of Object.entries(Mp(f,_))){let[S,P]=i[b]??[0,0];i[b]=[S+v,P+C]}ea(f,_,"presence").ok||o.push(h)}let s=Object.entries(i).map(([h,[f,_]])=>`${_}/${f} ${h}s`);r.push({name:"Facts and constraints kept",passed:o.length===0,detail:o.length?`Lost in: ${o.join(", ")}`:s.length?`Kept ${s.join(", ")}.`:"No numbers, links, code or constraint words to keep."});let l=[];for(let[h,f]of a){let _=Js(f,n.get(h)??"");_.length&&l.push(`${h}: ${_.join(", ")}`)}r.push({name:"Instructions kept",passed:l.length===0,detail:l.length?`Missing words: ${l.join("; ")}`:`Every content word of ${Gp(a.length,"text")} is still there; only filler was removed.`});let c=(h=[])=>JSON.stringify(h.map(f=>[f.name,Fv(f.parameters??null)])),u=c(e.tools)===c(t.tools);r.push({name:"Tool interface unchanged",passed:u,detail:u?`${Gp(e.tools?.length??0,"tool")}: same names, parameters, types, required fields and enums.`:"Tool names or parameter schemas differ."});let d=e.messages??[],m=t.messages??[],p=0,g=d.length===m.length&&d.every((h,f)=>{let _=m[f];if(_.role!==h.role)return!1;if(_.content===h.content)return!0;let b=/^\[Same content as message (\d+) above\.\]$/.exec(_.content),v=!!b&&d[Number(b[1])-1]?.content.trim()===h.content.trim();return v&&p++,v});return d.length&&r.push({name:"Conversation unchanged",passed:g,detail:g?`${Gp(d.length,"message")} in order${p?`; ${Gp(p,"exact repeat")} replaced by a pointer to the first copy`:", all verbatim"}.`:"Messages were dropped, reordered or edited."}),r.push({name:"Model and examples unchanged",passed:(e.examples?.length??0)===(t.examples?.length??0),detail:"Token Lens never switches the model or drops examples on its own."}),{passed:r.every(h=>h.passed),checks:r}}var Ye=e=>e.toLocaleString("en-US"),PA=(e,t)=>t?Math.round(e/t*100):0;function RA(e){return`${e.name}
|
|
3372
3372
|
${e.description??""}
|
|
3373
3373
|
${e.parameters?JSON.stringify(e.parameters):""}`}function NA(e,t=[]){if(e&&typeof e=="object")for(let[r,a]of Object.entries(e))r==="description"&&typeof a=="string"?t.push(a):NA(a,t);return t}function $A(e){let t=(e.description??"").replace(/\s+/g," ").trim().split(/(?<=[.!?])\s/)[0]??"";return t.length>100?`${t.slice(0,97).trimEnd()}...`:t}function Hv(e){let t=e.map(a=>`- ${a.name}${$A(a)?`: ${$A(a)}`:""}`).join(`
|
|
3374
3374
|
`),r=e.map(a=>a.name);return{tools:[{name:"get_tool_schema",description:`Get the full definition (description and parameters) of a tool before calling it. Available tools:
|
|
@@ -3494,7 +3494,7 @@ function run(argv) {
|
|
|
3494
3494
|
function emit(o) { out.writeData($.NSString.alloc.initWithUTF8String(JSON.stringify(o) + "\n").dataUsingEncoding($.NSUTF8StringEncoding)); }
|
|
3495
3495
|
tokenLensLoop([argv[0]], argv[1], emit, null, false);
|
|
3496
3496
|
}`,ny=qA+String.raw`
|
|
3497
|
-
function run(argv) { return tokenLensReplace(argv[0], argv[1], argv[2]); }`;var FD=60,qD=20,HD=12,GD=1800,VD=25e3,WD=15e3,KD=80,ZD=3*6e4,Ii=e=>Math.round(e).toLocaleString("en-US"),HA=e=>e.toLowerCase().replace(/[^\p{L}\p{N}]+/gu," ").trim(),Jp=class{profile;modelKnown=!1;draftText="";draftSince=0;draftDone="";lastDraftNotice=-1/0;chatTold=new Map;chatTokens=new Map;chatEpoch=new Map;chatText="";chatId="";chatTitle="";titles=new Map;pending=null;pastes=new Map;told=new Set;data;pickedPlan;appPlan=null;onData;state;constructor(t="claude-sonnet",r={}){this.profile=Bn(t),this.data=Uv(r.data??{sends:[],readings:[]},Date.now()),this.pickedPlan=r.plan&&Un[r.plan]||null,this.onData=r.onData,this.state={model:this.profile.label,draft:null,chat:null,coach:null},this.refreshCoach(Date.now())}get currentDraft(){return this.draftText}get plan(){return this.pickedPlan??this.appPlan}useModel(t){let r=Bn(t);r.id!=="generic"&&(this.profile=r,this.modelKnown=!0,this.state.model=this.profile.label)}setPlan(t,r=Date.now()){return this.pickedPlan=t&&Un[t]||null,this.refreshCoach(r),this.plan}draft(t,r){let a=(t??"").trim();if(a!==this.draftText)return t===""&&this.draftText.length>2&&this.chatId?this.pending={probe:HA(this.draftText).slice(0,80),tokens:this.state.chat?.tokens??0,chat:this.chatId,at:r,text:this.draftText}:this.pending&&a===this.pending.text&&(this.pending=null),this.draftText=a,this.draftSince=r,this.state.draft=a?this.analyzeDraft(a):null,null;let n=this.state.draft;if(!n||r-this.draftSince<GD)return null;let i=qp(a);if(i===this.draftDone||r-this.lastDraftNotice<VD)return null;let o=this.draftNotice(a,n);return o?(this.draftDone=i,this.lastDraftNotice=r,o):null}draftNotice(t,r){let a=this.state.chat?.tokens??0,n=this.plan?.label??"your plan";if(xA(t,this.chatText))return{title:"You already asked this in this chat",body:`Its answer is above. Sending it again re-reads about ${Ii(a+r.tokens)} tokens of ${n}'s usage for the same question.`};if(EA(t)&&a>=WD)return{title:`"${t.slice(0,24)}" re-reads this whole chat`,body:`Sending it uses about ${Ii(a)} tokens of ${n}'s usage, as much as a long question. If there's nothing to ask, you can skip it, or add it to your next real message.`};let i=TA(t);for(let s of i){let l=this.pastes.get(s)??new Set;if(l.add(this.chatId),this.pastes.set(s,l),l.size>=2&&!this.told.has(`paste:${s}`))return this.told.add(`paste:${s}`),{title:`You've pasted this text into ${l.size} chats`,body:"Put it in a Claude Project's knowledge or instructions once, and every chat in that Project has it without pasting it again."}}return r.tokens>=FD&&r.saved>=qD&&r.pct>=HD?{title:`Draft: ${Ii(r.tokens)} \u2192 ${Ii(r.optimizedTokens)} tokens (${r.pct}% fewer)`,body:`Same request, ${r.savedUsd===null?"fewer tokens":`${Te(r.savedUsd)} less per send at API prices`}. Token Lens can put the shorter version in the message box when you click.${r.tips[0]?` ${r.tips[0]}`:""}`}:r.tips.length?{title:"Token Lens tip for your draft",body:r.tips[0]}:null}chat(t,r,a=Date.now()){let{tokens:n}=Ce(r,this.profile),i=Yr(n,0,this.profile),o=nt(n,this.profile),s=[],l=null;i.zone==="hot"||i.zone==="full"?(l=i.zone,s.push(`This chat fills about ${Math.round(i.ratio*100)}% of the context, so older messages will soon be dropped or compacted. ${Rt}`)):(i.zone==="warm"||i.longChat)&&(l=i.zone==="warm"?"warm":"long",s.push(`Every message you send re-reads about ${Ii(n)} tokens of this chat (${Te(o)} each at API prices). Starting a new chat for a new topic avoids that.`)),this.state.chat={tokens:n,ratio:i.ratio,window:i.window,perMessageUsd:o,tips:s},n<(this.chatTokens.get(t)??0)*.5&&(this.chatTold.delete(t),this.chatEpoch.set(t,(this.chatEpoch.get(t)??0)+1)),this.chatTokens.set(t,n),this.chatText=r,this.chatId=qp(`${t}#${this.chatEpoch.get(t)??0}`),this.chatTitle=t&&!/^claude$/i.test(t)?t.slice(0,60):"",this.chatTitle&&this.titles.set(this.chatId,this.chatTitle);let c=this.observe(r,a),u=null;if(l){let d=this.chatTold.get(t)??new Set;this.chatTold.set(t,d),d.has(l)||(d.add(l),u={title:`This chat: ${Ii(n)} tokens (${Math.round(i.ratio*100)}% of context)`,body:s[0]})}return c??u}observe(t,r){let a=!1,n=_A(t);n&&(this.appPlan=n);let i=wA(t,r);i&&(this.data=SA(this.data,i),a=!0);let o=this.pending;o&&r-o.at>ZD?this.pending=null:o&&o.probe&&HA(t).includes(o.probe)&&(this.data.sends.push({at:o.at,tokens:o.tokens+Ce(o.text,this.profile).tokens,chat:o.chat}),this.pending=null,a=!0),a&&(this.data=Uv(this.data,r),this.onData?.(this.data));let s=this.refreshCoach(r);if(s.sessionPct!==void 0&&s.sessionPct>=KD){let c=`session:${Math.round(s.session.since/36e5)}`;if(!this.told.has(c))return this.told.add(c),{title:`${this.plan?.label??"Claude"} session ${s.sessionPct}% used`,body:s.insights[0]??"New topics in new chats stretch what's left."}}let l=s.insights.find(c=>c.includes("weekly allowance is unused"));if(l&&s.weekResetsAt){let c=`week:${Math.round(s.weekResetsAt/864e5)}`;if(!this.told.has(c))return this.told.add(c),{title:`${100-(s.weekPct??0)}% of your week is still unused`,body:l}}return null}refreshCoach(t=Date.now()){let r=Hp({data:this.data,now:t,plan:this.plan,planSource:this.pickedPlan?"set":this.appPlan?"app":"unknown",current:this.chatId?{chat:this.chatId,title:this.chatTitle,tokens:this.state.chat?.tokens??0}:void 0,titles:this.titles});return this.state.coach=r,r}analyzeDraft(t){let r=Xs({prompt:t,model:this.profile,conversationTokens:this.state.chat?.tokens??0,level:"auto"}),a=r.optimized.saved;return{tokens:r.promptTokens,optimizedTokens:r.optimized.tokens,saved:a,pct:r.optimized.originalTokens?Math.round(a/r.optimized.originalTokens*100):0,savedUsd:r.cost.saved.usd,best:a>0?r.best.text:t,kept:r.best.kept,tips:r.tips.filter(n=>!["handoff","price-threshold","family-note"].includes(n.id)).map(n=>n.text)}}};var Qp=Number(process.env.TOKEN_LENS_LIVE_PORT??4797),GA=`http://localhost:${Qp}`,JA=nm(tm(),".token-lens","live.json"),YA=nm(tm(),".token-lens","usage.json");function tM(){try{let e=JSON.parse(KA(YA,"utf8"));return Array.isArray(e.sends)&&Array.isArray(e.readings)?e:void 0}catch{return}}var Yp=null;function nM(e){Yp||(Yp=setTimeout(()=>{Yp=null;try{WA(nm(tm(),".token-lens"),{recursive:!0}),ZA(YA,JSON.stringify({note:"Token Lens plan coach. Times and token counts only, no text.",...e}))}catch{}},5e3),Yp.unref())}function ta(){try{return JSON.parse(KA(JA,"utf8"))}catch{return{}}}function Qs(e){try{WA(nm(tm(),".token-lens"),{recursive:!0}),ZA(JA,JSON.stringify({...ta(),...e},null,2))}catch{}}function rM(){if(process.env.__CFBundleIdentifier===ey)return!0;let e=process.ppid;for(let t=0;t<10&&e>1;t++){let r="";try{r=JD("ps",["-o","ppid=,command=","-p",String(e)],{encoding:"utf8"}).trim()}catch{return!1}let a=/^(\d+)\s+(.*)$/.exec(r);if(!a)return!1;if(/\/Claude\.app\//.test(a[2]))return!0;e=Number(a[1])}return!1}var VA=(e="")=>/-1719|-25211|-1743|assistive|not allowed|not authori[sz]ed/i.test(e),aM={off:"off",starting:"starting",watching:"watching Claude's message box and chat","cant-see-box":"Claude is open but its message box can't be read yet","needs-helper":`can't read the AI app without Accessibility; Token Lens won't ask for node: ${zi} can be set up from the chat`,helper:`${zi} shows live tips (its icon is in the menu bar)`,"claude-closed":"waiting for the Claude app",unsupported:"macOS only"},iM=45,em=class{url=GA;insights=new Jp(process.env.TOKEN_LENS_MODEL??"claude-sonnet",{data:tM(),plan:ta().plan,onData:nM});watchers=[];panel=null;running=!1;told=new Set;hooked=!1;blind=0;helperOn=!1;gen=0;app=ey;panelKey=XD();current="off";get status(){return this.current}set status(t){t!==this.current&&console.error(`Token Lens live tips: ${aM[t]}`),this.current=t}autoStart(){if(process.platform!=="darwin")return void(this.status="unsupported");let t=process.env.TOKEN_LENS_LIVE,r=ta().on,a=rM(),n=t==="0"?!1:t==="1"?!0:r??a;console.error(`Token Lens live tips: ${n?"starting":"off"} (macOS; started by the Claude app: ${a?"yes":"no"}; setting: ${r===void 0?"default":r?"on":"off"}${t?`; TOKEN_LENS_LIVE=${t}`:""})`),n&&this.start()}enable(){return Qs({on:!0}),process.platform!=="darwin"?this.status="unsupported":(this.start(),this.status)}disable(){return Qs({on:!1}),ta().nativeHelper&&Qv(),this.stop(),this.status}setPlan(t){Qs({plan:t??void 0}),this.insights.setPlan(t)}replaceDraft(){let t=this.insights.state.draft?.best,r=this.insights.currentDraft;return!t||!r||t===r?Promise.resolve("nothing"):new Promise(a=>ry("osascript",["-l","JavaScript","-e",ny,t,r,this.app],{timeout:8e3},(n,i)=>{let o=String(i??"").trim();a(n?"failed":o==="ok"||o==="changed"||o==="no-box"?o:"failed")}))}async setupHelper(){if(process.platform!=="darwin"||!Zv())return"unsupported";let t=await Yv();return t==="unavailable"||t==="failed"?t:(Qs({nativeHelper:!0,on:!0}),this.helperOn=!0,this.watchers.forEach(r=>r.kill()),this.watchers=[],Xv(),this.status="helper",this.running||this.start(),"started")}get helperOffer(){return!ta().nativeHelper&&Zv()&&Kp()!==null}openPanel(){ry("open",[`${GA}/#k=${this.panelKey}`],()=>{})}start(){if(this.running)return;this.running=!0;let t=++this.gen;this.status="starting",this.panel=QD((r,a)=>{let n=r.headers.host??"",i=r.headers.origin,o=[`localhost:${Qp}`,`127.0.0.1:${Qp}`];if(a.setHeader("x-frame-options","DENY"),a.setHeader("content-security-policy","frame-ancestors 'none'"),!o.includes(n)||i!==void 0&&!o.some(l=>i===`http://${l}`))return void a.writeHead(403).end();let s=r.headers["x-token-lens-key"]===this.panelKey;if(r.url==="/state")return a.writeHead(200,{"content-type":"application/json","cache-control":"no-store"}),s?(this.insights.refreshCoach(),void a.end(JSON.stringify({status:this.status,app:Zp[this.app]??"Claude",helperOffer:this.helperOffer,...this.insights.state}))):void a.end(JSON.stringify({status:this.status,locked:!0}));if(r.method==="POST"&&i!==void 0&&r.url==="/unlock")return this.openPanel(),void a.writeHead(204).end();if(r.method==="POST"&&!s)return void a.writeHead(403).end();if(r.method==="POST"&&i!==void 0){let l=u=>a.writeHead(200,{"content-type":"application/json"}).end(JSON.stringify(u));if(r.url==="/helper/setup")return void this.setupHelper().then(u=>l({result:u}),()=>l({result:"failed"}));if(r.url==="/replace")return void this.replaceDraft().then(u=>l({result:u}));let c=/^\/plan\/([a-z-]+)$/.exec(r.url??"");return c&&(c[1]==="auto"||c[1]in Un)?(this.setPlan(c[1]==="auto"?null:c[1]),void l({plan:this.insights.plan?.id??null})):void a.writeHead(404).end()}a.writeHead(200,{"content-type":"text/html; charset=utf-8"}).end(oM)}),this.panel.on("error",()=>this.stop()),this.panel.listen(Qp,"127.0.0.1",()=>{if(this.running){if(ta().nativeHelper)return void this.useHelper(t).catch(()=>{});this.watch("draft"),this.watch("chat")}}),this.hooked||(this.hooked=!0,process.stdin.on("end",()=>process.exit(0)),process.on("exit",()=>this.watchers.forEach(r=>r.kill())))}stop(){this.running=!1,this.helperOn=!1,this.gen++,this.status="off",this.watchers.forEach(t=>t.kill()),this.watchers=[],this.panel?.close(),this.panel=null}watch(t){if(!this.running||this.helperOn)return;let r=YD("osascript",["-l","JavaScript","-e",ty,t,String(process.pid)],{stdio:["ignore","pipe","pipe"]});this.watchers.push(r),r.on("error",()=>{});let a="";r.stderr.on("data",n=>a=(a+n.toString()).slice(-2e3)),eM({input:r.stdout}).on("line",n=>this.onRaw(n)),r.on("exit",()=>{this.watchers=this.watchers.filter(n=>n!==r),!this.helperOn&&(VA(a)&&this.needsPermission(),this.running&&setTimeout(()=>this.watch(t),3e4).unref())})}async useHelper(t){let r=Jv()?"current":await Yv();if(!(!this.running||t!==this.gen)){if(r==="unavailable"||r==="failed"){this.watch("draft"),this.watch("chat");return}this.helperOn=!0,this.status="helper",Xv()}}onRaw(t){if(this.helperOn)return;let r;try{r=JSON.parse(t)}catch{return}try{this.onLine(r)}catch{}}onLine(t){if(t.a&&Zp[t.a]&&(this.app=t.a),t.s==="error"){VA(t.e)&&this.needsPermission();return}if(t.s==="closed")return void(this.status="claude-closed");t.s==="ok"&&(t.d===null||t.d===void 0?(this.status!=="watching"&&++this.blind===iM&&this.cantSee(),this.status!=="watching"&&(this.status="cant-see-box")):(this.status="watching",this.welcome()));let r=null;t.s==="ok"?r=this.insights.draft(t.d??null,Date.now()):t.s==="chat"&&t.t&&(r=this.insights.chat(t.k??"",t.t,Date.now())),r&&Xp(r.title,r.body)}welcome(){this.told.has("welcome")||ta().sawBox||(this.told.add("welcome"),Qs({sawBox:!0}),Xp("Token Lens is on in Claude","As you type, it tells you here when a shorter prompt says the same thing, and when a chat gets costly. Nothing leaves your Mac."))}cantSee(){this.told.has("blind")||(this.told.add("blind"),Xp("Token Lens can't see Claude's message box yet","Click in the box where you type to Claude. If this shows again, quit Claude (Claude > Quit Claude) and open it again."))}needsPermission(){this.status="needs-helper",!(this.told.has("helper")||!this.helperOffer)&&(this.told.add("helper"),Xp("Live tips need one step",'Ask Claude to "set up Token Lens Helper" to see what it does and turn it on if you want it.'))}};function Xp(e,t){ry("osascript",["-e","on run argv","-e","display notification (item 2 of argv) with title (item 1 of argv)","-e","end run",e,t],()=>{})}var oM=`<!doctype html><html><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1">
|
|
3497
|
+
function run(argv) { return tokenLensReplace(argv[0], argv[1], argv[2]); }`;var FD=/^(ask anything|ask (chatgpt|claude|gemini|perplexity|grok|deepseek|le chat|copilot|a follow-?up)|message (chatgpt|claude|copilot|deepseek|le chat|grok)|reply to (claude|chatgpt)|how can i help( you)?( today)?|what do you want to know|what's on your mind|enter a prompt( here)?( for gemini)?|send a message|type a message|write (a|your) (message|prompt)( to claude)?)[\s.…?!]*$/i;function qD(e){let t=(e??"").replace(/[\u200B-\u200D\u2060\uFEFF]/g,"").trim();return FD.test(t)?"":t}var HD=60,GD=20,VD=12,WD=1800,KD=25e3,ZD=15e3,JD=80,YD=3*6e4,Ii=e=>Math.round(e).toLocaleString("en-US"),HA=e=>e.toLowerCase().replace(/[^\p{L}\p{N}]+/gu," ").trim(),Jp=class{profile;modelKnown=!1;draftText="";draftSince=0;draftDone="";lastDraftNotice=-1/0;chatTold=new Map;chatTokens=new Map;chatEpoch=new Map;chatText="";chatId="";chatTitle="";titles=new Map;pending=null;pastes=new Map;told=new Set;data;pickedPlan;appPlan=null;onData;state;constructor(t="claude-sonnet",r={}){this.profile=Bn(t),this.data=Uv(r.data??{sends:[],readings:[]},Date.now()),this.pickedPlan=r.plan&&Un[r.plan]||null,this.onData=r.onData,this.state={model:this.profile.label,draft:null,chat:null,coach:null},this.refreshCoach(Date.now())}get currentDraft(){return this.draftText}get plan(){return this.pickedPlan??this.appPlan}useModel(t){let r=Bn(t);r.id!=="generic"&&(this.profile=r,this.modelKnown=!0,this.state.model=this.profile.label)}setPlan(t,r=Date.now()){return this.pickedPlan=t&&Un[t]||null,this.refreshCoach(r),this.plan}draft(t,r){let a=qD(t);if(a!==this.draftText)return t!==null&&a===""&&this.draftText.length>2&&this.chatId?this.pending={probe:HA(this.draftText).slice(0,80),tokens:this.state.chat?.tokens??0,chat:this.chatId,at:r,text:this.draftText}:this.pending&&a===this.pending.text&&(this.pending=null),this.draftText=a,this.draftSince=r,this.state.draft=a?this.analyzeDraft(a):null,null;let n=this.state.draft;if(!n||r-this.draftSince<WD)return null;let i=qp(a);if(i===this.draftDone||r-this.lastDraftNotice<KD)return null;let o=this.draftNotice(a,n);return o?(this.draftDone=i,this.lastDraftNotice=r,o):null}draftNotice(t,r){let a=this.state.chat?.tokens??0,n=this.plan?.label??"your plan";if(xA(t,this.chatText))return{title:"You already asked this in this chat",body:`Its answer is above. Sending it again re-reads about ${Ii(a+r.tokens)} tokens of ${n}'s usage for the same question.`};if(EA(t)&&a>=ZD)return{title:`"${t.slice(0,24)}" re-reads this whole chat`,body:`Sending it uses about ${Ii(a)} tokens of ${n}'s usage, as much as a long question. If there's nothing to ask, you can skip it, or add it to your next real message.`};let i=TA(t);for(let s of i){let l=this.pastes.get(s)??new Set;if(l.add(this.chatId),this.pastes.set(s,l),l.size>=2&&!this.told.has(`paste:${s}`))return this.told.add(`paste:${s}`),{title:`You've pasted this text into ${l.size} chats`,body:"Put it in a Claude Project's knowledge or instructions once, and every chat in that Project has it without pasting it again."}}return r.tokens>=HD&&r.saved>=GD&&r.pct>=VD?{title:`Draft: ${Ii(r.tokens)} \u2192 ${Ii(r.optimizedTokens)} tokens (${r.pct}% fewer)`,body:`Same request, ${r.savedUsd===null?"fewer tokens":`${Te(r.savedUsd)} less per send at API prices`}. Token Lens can put the shorter version in the message box when you click.${r.tips[0]?` ${r.tips[0]}`:""}`}:r.tips.length?{title:"Token Lens tip for your draft",body:r.tips[0]}:null}chat(t,r,a=Date.now()){let{tokens:n}=Ce(r,this.profile),i=Yr(n,0,this.profile),o=nt(n,this.profile),s=[],l=null;i.zone==="hot"||i.zone==="full"?(l=i.zone,s.push(`This chat fills about ${Math.round(i.ratio*100)}% of the context, so older messages will soon be dropped or compacted. ${Rt}`)):(i.zone==="warm"||i.longChat)&&(l=i.zone==="warm"?"warm":"long",s.push(`Every message you send re-reads about ${Ii(n)} tokens of this chat (${Te(o)} each at API prices). Starting a new chat for a new topic avoids that.`)),this.state.chat={tokens:n,ratio:i.ratio,window:i.window,perMessageUsd:o,tips:s},n<(this.chatTokens.get(t)??0)*.5&&(this.chatTold.delete(t),this.chatEpoch.set(t,(this.chatEpoch.get(t)??0)+1)),this.chatTokens.set(t,n),this.chatText=r,this.chatId=qp(`${t}#${this.chatEpoch.get(t)??0}`),this.chatTitle=t&&!/^claude$/i.test(t)?t.slice(0,60):"",this.chatTitle&&this.titles.set(this.chatId,this.chatTitle);let c=this.observe(r,a),u=null;if(l){let d=this.chatTold.get(t)??new Set;this.chatTold.set(t,d),d.has(l)||(d.add(l),u={title:`This chat: ${Ii(n)} tokens (${Math.round(i.ratio*100)}% of context)`,body:s[0]})}return c??u}observe(t,r){let a=!1,n=_A(t);n&&(this.appPlan=n);let i=wA(t,r);i&&(this.data=SA(this.data,i),a=!0);let o=this.pending;o&&r-o.at>YD?this.pending=null:o&&o.probe&&HA(t).includes(o.probe)&&(this.data.sends.push({at:o.at,tokens:o.tokens+Ce(o.text,this.profile).tokens,chat:o.chat}),this.pending=null,a=!0),a&&(this.data=Uv(this.data,r),this.onData?.(this.data));let s=this.refreshCoach(r);if(s.sessionPct!==void 0&&s.sessionPct>=JD){let c=`session:${Math.round(s.session.since/36e5)}`;if(!this.told.has(c))return this.told.add(c),{title:`${this.plan?.label??"Claude"} session ${s.sessionPct}% used`,body:s.insights[0]??"New topics in new chats stretch what's left."}}let l=s.insights.find(c=>c.includes("weekly allowance is unused"));if(l&&s.weekResetsAt){let c=`week:${Math.round(s.weekResetsAt/864e5)}`;if(!this.told.has(c))return this.told.add(c),{title:`${100-(s.weekPct??0)}% of your week is still unused`,body:l}}return null}refreshCoach(t=Date.now()){let r=Hp({data:this.data,now:t,plan:this.plan,planSource:this.pickedPlan?"set":this.appPlan?"app":"unknown",current:this.chatId?{chat:this.chatId,title:this.chatTitle,tokens:this.state.chat?.tokens??0}:void 0,titles:this.titles});return this.state.coach=r,r}analyzeDraft(t){let r=Xs({prompt:t,model:this.profile,conversationTokens:this.state.chat?.tokens??0,level:"auto"}),a=r.optimized.saved;return{tokens:r.promptTokens,optimizedTokens:r.optimized.tokens,saved:a,pct:r.optimized.originalTokens?Math.round(a/r.optimized.originalTokens*100):0,savedUsd:r.cost.saved.usd,best:a>0?r.best.text:t,kept:r.best.kept,tips:r.tips.filter(n=>!["handoff","price-threshold","family-note"].includes(n.id)).map(n=>n.text)}}};var Qp=Number(process.env.TOKEN_LENS_LIVE_PORT??4797),GA=`http://localhost:${Qp}`,JA=nm(tm(),".token-lens","live.json"),YA=nm(tm(),".token-lens","usage.json");function rM(){try{let e=JSON.parse(KA(YA,"utf8"));return Array.isArray(e.sends)&&Array.isArray(e.readings)?e:void 0}catch{return}}var Yp=null;function aM(e){Yp||(Yp=setTimeout(()=>{Yp=null;try{WA(nm(tm(),".token-lens"),{recursive:!0}),ZA(YA,JSON.stringify({note:"Token Lens plan coach. Times and token counts only, no text.",...e}))}catch{}},5e3),Yp.unref())}function ta(){try{return JSON.parse(KA(JA,"utf8"))}catch{return{}}}function Qs(e){try{WA(nm(tm(),".token-lens"),{recursive:!0}),ZA(JA,JSON.stringify({...ta(),...e},null,2))}catch{}}function iM(){if(process.env.__CFBundleIdentifier===ey)return!0;let e=process.ppid;for(let t=0;t<10&&e>1;t++){let r="";try{r=XD("ps",["-o","ppid=,command=","-p",String(e)],{encoding:"utf8"}).trim()}catch{return!1}let a=/^(\d+)\s+(.*)$/.exec(r);if(!a)return!1;if(/\/Claude\.app\//.test(a[2]))return!0;e=Number(a[1])}return!1}var VA=(e="")=>/-1719|-25211|-1743|assistive|not allowed|not authori[sz]ed/i.test(e),oM={off:"off",starting:"starting",watching:"watching Claude's message box and chat","cant-see-box":"Claude is open but its message box can't be read yet","needs-helper":`can't read the AI app without Accessibility; Token Lens won't ask for node: ${zi} can be set up from the chat`,helper:`${zi} shows live tips (its icon is in the menu bar)`,"claude-closed":"waiting for the Claude app",unsupported:"macOS only"},sM=45,em=class{url=GA;insights=new Jp(process.env.TOKEN_LENS_MODEL??"claude-sonnet",{data:rM(),plan:ta().plan,onData:aM});watchers=[];panel=null;running=!1;told=new Set;hooked=!1;blind=0;helperOn=!1;gen=0;app=ey;panelKey=eM();current="off";get status(){return this.current}set status(t){t!==this.current&&console.error(`Token Lens live tips: ${oM[t]}`),this.current=t}autoStart(){if(process.platform!=="darwin")return void(this.status="unsupported");let t=process.env.TOKEN_LENS_LIVE,r=ta().on,a=iM(),n=t==="0"?!1:t==="1"?!0:r??a;console.error(`Token Lens live tips: ${n?"starting":"off"} (macOS; started by the Claude app: ${a?"yes":"no"}; setting: ${r===void 0?"default":r?"on":"off"}${t?`; TOKEN_LENS_LIVE=${t}`:""})`),n&&this.start()}enable(){return Qs({on:!0}),process.platform!=="darwin"?this.status="unsupported":(this.start(),this.status)}disable(){return Qs({on:!1}),ta().nativeHelper&&Qv(),this.stop(),this.status}setPlan(t){Qs({plan:t??void 0}),this.insights.setPlan(t)}replaceDraft(){let t=this.insights.state.draft?.best,r=this.insights.currentDraft;return!t||!r||t===r?Promise.resolve("nothing"):new Promise(a=>ry("osascript",["-l","JavaScript","-e",ny,t,r,this.app],{timeout:8e3},(n,i)=>{let o=String(i??"").trim();a(n?"failed":o==="ok"||o==="changed"||o==="no-box"?o:"failed")}))}async setupHelper(){if(process.platform!=="darwin"||!Zv())return"unsupported";let t=await Yv();return t==="unavailable"||t==="failed"?t:(Qs({nativeHelper:!0,on:!0}),this.helperOn=!0,this.watchers.forEach(r=>r.kill()),this.watchers=[],Xv(),this.status="helper",this.running||this.start(),"started")}get helperOffer(){return!ta().nativeHelper&&Zv()&&Kp()!==null}openPanel(){ry("open",[`${GA}/#k=${this.panelKey}`],()=>{})}start(){if(this.running)return;this.running=!0;let t=++this.gen;this.status="starting",this.panel=tM((r,a)=>{let n=r.headers.host??"",i=r.headers.origin,o=[`localhost:${Qp}`,`127.0.0.1:${Qp}`];if(a.setHeader("x-frame-options","DENY"),a.setHeader("content-security-policy","frame-ancestors 'none'"),!o.includes(n)||i!==void 0&&!o.some(l=>i===`http://${l}`))return void a.writeHead(403).end();let s=r.headers["x-token-lens-key"]===this.panelKey;if(r.url==="/state")return a.writeHead(200,{"content-type":"application/json","cache-control":"no-store"}),s?(this.insights.refreshCoach(),void a.end(JSON.stringify({status:this.status,app:Zp[this.app]??"Claude",helperOffer:this.helperOffer,...this.insights.state}))):void a.end(JSON.stringify({status:this.status,locked:!0}));if(r.method==="POST"&&i!==void 0&&r.url==="/unlock")return this.openPanel(),void a.writeHead(204).end();if(r.method==="POST"&&!s)return void a.writeHead(403).end();if(r.method==="POST"&&i!==void 0){let l=u=>a.writeHead(200,{"content-type":"application/json"}).end(JSON.stringify(u));if(r.url==="/helper/setup")return void this.setupHelper().then(u=>l({result:u}),()=>l({result:"failed"}));if(r.url==="/replace")return void this.replaceDraft().then(u=>l({result:u}));let c=/^\/plan\/([a-z-]+)$/.exec(r.url??"");return c&&(c[1]==="auto"||c[1]in Un)?(this.setPlan(c[1]==="auto"?null:c[1]),void l({plan:this.insights.plan?.id??null})):void a.writeHead(404).end()}a.writeHead(200,{"content-type":"text/html; charset=utf-8"}).end(lM)}),this.panel.on("error",()=>this.stop()),this.panel.listen(Qp,"127.0.0.1",()=>{if(this.running){if(ta().nativeHelper)return void this.useHelper(t).catch(()=>{});this.watch("draft"),this.watch("chat")}}),this.hooked||(this.hooked=!0,process.stdin.on("end",()=>process.exit(0)),process.on("exit",()=>this.watchers.forEach(r=>r.kill())))}stop(){this.running=!1,this.helperOn=!1,this.gen++,this.status="off",this.watchers.forEach(t=>t.kill()),this.watchers=[],this.panel?.close(),this.panel=null}watch(t){if(!this.running||this.helperOn)return;let r=QD("osascript",["-l","JavaScript","-e",ty,t,String(process.pid)],{stdio:["ignore","pipe","pipe"]});this.watchers.push(r),r.on("error",()=>{});let a="";r.stderr.on("data",n=>a=(a+n.toString()).slice(-2e3)),nM({input:r.stdout}).on("line",n=>this.onRaw(n)),r.on("exit",()=>{this.watchers=this.watchers.filter(n=>n!==r),!this.helperOn&&(VA(a)&&this.needsPermission(),this.running&&setTimeout(()=>this.watch(t),3e4).unref())})}async useHelper(t){let r=Jv()?"current":await Yv();if(!(!this.running||t!==this.gen)){if(r==="unavailable"||r==="failed"){this.watch("draft"),this.watch("chat");return}this.helperOn=!0,this.status="helper",Xv()}}onRaw(t){if(this.helperOn)return;let r;try{r=JSON.parse(t)}catch{return}try{this.onLine(r)}catch{}}onLine(t){if(t.a&&Zp[t.a]&&(this.app=t.a),t.s==="error"){VA(t.e)&&this.needsPermission();return}if(t.s==="closed")return void(this.status="claude-closed");t.s==="ok"&&(t.d===null||t.d===void 0?(this.status!=="watching"&&++this.blind===sM&&this.cantSee(),this.status!=="watching"&&(this.status="cant-see-box")):(this.status="watching",this.welcome()));let r=null;t.s==="ok"?r=this.insights.draft(t.d??null,Date.now()):t.s==="chat"&&t.t&&(r=this.insights.chat(t.k??"",t.t,Date.now())),r&&Xp(r.title,r.body)}welcome(){this.told.has("welcome")||ta().sawBox||(this.told.add("welcome"),Qs({sawBox:!0}),Xp("Token Lens is on in Claude","As you type, it tells you here when a shorter prompt says the same thing, and when a chat gets costly. Nothing leaves your Mac."))}cantSee(){this.told.has("blind")||(this.told.add("blind"),Xp("Token Lens can't see Claude's message box yet","Click in the box where you type to Claude. If this shows again, quit Claude (Claude > Quit Claude) and open it again."))}needsPermission(){this.status="needs-helper",!(this.told.has("helper")||!this.helperOffer)&&(this.told.add("helper"),Xp("Live tips need one step",'Ask Claude to "set up Token Lens Helper" to see what it does and turn it on if you want it.'))}};function Xp(e,t){ry("osascript",["-e","on run argv","-e","display notification (item 2 of argv) with title (item 1 of argv)","-e","end run",e,t],()=>{})}var lM=`<!doctype html><html><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1">
|
|
3498
3498
|
<title>Token Lens Live</title><style>
|
|
3499
3499
|
:root{--bg:#fafaf9;--fg:#1c1917;--muted:#78716c;--card:#fff;--line:#e7e5e4;--accent:#0f766e}
|
|
3500
3500
|
@media (prefers-color-scheme:dark){:root{--bg:#1c1917;--fg:#f5f5f4;--muted:#a8a29e;--card:#292524;--line:#44403c;--accent:#2dd4bf}}
|
|
@@ -3555,12 +3555,12 @@ if(k.insights.length)h+='<ul>'+k.insights.map(t=>'<li>'+esc(t)+'</li>').join("")
|
|
|
3555
3555
|
ke.innerHTML=h;document.querySelectorAll("#plans button").forEach(b=>b.classList.toggle("on",!!k.plan&&k.planSource==="set"&&b.dataset.p===k.plan.id))}
|
|
3556
3556
|
}catch(e){document.getElementById("status").textContent="Token Lens isn't running. Open Claude."}}
|
|
3557
3557
|
tick();setInterval(tick,1000);
|
|
3558
|
-
</script></body></html>`;import{execFile as mq}from"node:child_process";import{createHash as gq,randomUUID as hq}from"node:crypto";var ce;(function(e){e.assertEqual=n=>{};function t(n){}e.assertIs=t;function r(n){throw new Error}e.assertNever=r,e.arrayToEnum=n=>{let i={};for(let o of n)i[o]=o;return i},e.getValidEnumValues=n=>{let i=e.objectKeys(n).filter(s=>typeof n[n[s]]!="number"),o={};for(let s of i)o[s]=n[s];return e.objectValues(o)},e.objectValues=n=>e.objectKeys(n).map(function(i){return n[i]}),e.objectKeys=typeof Object.keys=="function"?n=>Object.keys(n):n=>{let i=[];for(let o in n)Object.prototype.hasOwnProperty.call(n,o)&&i.push(o);return i},e.find=(n,i)=>{for(let o of n)if(i(o))return o},e.isInteger=typeof Number.isInteger=="function"?n=>Number.isInteger(n):n=>typeof n=="number"&&Number.isFinite(n)&&Math.floor(n)===n;function a(n,i=" | "){return n.map(o=>typeof o=="string"?`'${o}'`:o).join(i)}e.joinValues=a,e.jsonStringifyReplacer=(n,i)=>typeof i=="bigint"?i.toString():i})(ce||(ce={}));var XA;(function(e){e.mergeShapes=(t,r)=>({...t,...r})})(XA||(XA={}));var N=ce.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),qn=e=>{switch(typeof e){case"undefined":return N.undefined;case"string":return N.string;case"number":return Number.isNaN(e)?N.nan:N.number;case"boolean":return N.boolean;case"function":return N.function;case"bigint":return N.bigint;case"symbol":return N.symbol;case"object":return Array.isArray(e)?N.array:e===null?N.null:e.then&&typeof e.then=="function"&&e.catch&&typeof e.catch=="function"?N.promise:typeof Map<"u"&&e instanceof Map?N.map:typeof Set<"u"&&e instanceof Set?N.set:typeof Date<"u"&&e instanceof Date?N.date:N.object;default:return N.unknown}};var A=ce.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 jt=class e extends Error{get errors(){return this.issues}constructor(t){super(),this.issues=[],this.addIssue=a=>{this.issues=[...this.issues,a]},this.addIssues=(a=[])=>{this.issues=[...this.issues,...a]};let r=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,r):this.__proto__=r,this.name="ZodError",this.issues=t}format(t){let r=t||function(i){return i.message},a={_errors:[]},n=i=>{for(let o of i.issues)if(o.code==="invalid_union")o.unionErrors.map(n);else if(o.code==="invalid_return_type")n(o.returnTypeError);else if(o.code==="invalid_arguments")n(o.argumentsError);else if(o.path.length===0)a._errors.push(r(o));else{let s=a,l=0;for(;l<o.path.length;){let c=o.path[l],u=l===o.path.length-1;if(c==="_errors"){u&&s._errors.push(r(o)),l++;continue}Object.prototype.hasOwnProperty.call(s,c)||(c==="__proto__"?Object.defineProperty(s,c,{value:{_errors:[]},writable:!0,enumerable:!0,configurable:!0}):s[c]={_errors:[]}),s=s[c],u&&s._errors.push(r(o)),l++}}};return n(this),a}static assert(t){if(!(t instanceof e))throw new Error(`Not a ZodError: ${t}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,ce.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(t=r=>r.message){let r=Object.create(null),a=[];for(let n of this.issues)if(n.path.length>0){let i=n.path[0];r[i]=r[i]||[],r[i].push(t(n))}else a.push(t(n));return{formErrors:a,fieldErrors:r}}get formErrors(){return this.flatten()}};jt.create=e=>new jt(e);var sM=(e,t)=>{let r;switch(e.code){case A.invalid_type:e.received===N.undefined?r="Required":r=`Expected ${e.expected}, received ${e.received}`;break;case A.invalid_literal:r=`Invalid literal value, expected ${JSON.stringify(e.expected,ce.jsonStringifyReplacer)}`;break;case A.unrecognized_keys:r=`Unrecognized key(s) in object: ${ce.joinValues(e.keys,", ")}`;break;case A.invalid_union:r="Invalid input";break;case A.invalid_union_discriminator:r=`Invalid discriminator value. Expected ${ce.joinValues(e.options)}`;break;case A.invalid_enum_value:r=`Invalid enum value. Expected ${ce.joinValues(e.options)}, received '${e.received}'`;break;case A.invalid_arguments:r="Invalid function arguments";break;case A.invalid_return_type:r="Invalid function return type";break;case A.invalid_date:r="Invalid date";break;case A.invalid_string:typeof e.validation=="object"?"includes"in e.validation?(r=`Invalid input: must include "${e.validation.includes}"`,typeof e.validation.position=="number"&&(r=`${r} at one or more positions greater than or equal to ${e.validation.position}`)):"startsWith"in e.validation?r=`Invalid input: must start with "${e.validation.startsWith}"`:"endsWith"in e.validation?r=`Invalid input: must end with "${e.validation.endsWith}"`:ce.assertNever(e.validation):e.validation!=="regex"?r=`Invalid ${e.validation}`:r="Invalid";break;case A.too_small:e.type==="array"?r=`Array must contain ${e.exact?"exactly":e.inclusive?"at least":"more than"} ${e.minimum} element(s)`:e.type==="string"?r=`String must contain ${e.exact?"exactly":e.inclusive?"at least":"over"} ${e.minimum} character(s)`:e.type==="number"?r=`Number must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${e.minimum}`:e.type==="bigint"?r=`Number must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${e.minimum}`:e.type==="date"?r=`Date must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(e.minimum))}`:r="Invalid input";break;case A.too_big:e.type==="array"?r=`Array must contain ${e.exact?"exactly":e.inclusive?"at most":"less than"} ${e.maximum} element(s)`:e.type==="string"?r=`String must contain ${e.exact?"exactly":e.inclusive?"at most":"under"} ${e.maximum} character(s)`:e.type==="number"?r=`Number must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:e.type==="bigint"?r=`BigInt must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:e.type==="date"?r=`Date must be ${e.exact?"exactly":e.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(e.maximum))}`:r="Invalid input";break;case A.custom:r="Invalid input";break;case A.invalid_intersection_types:r="Intersection results could not be merged";break;case A.not_multiple_of:r=`Number must be a multiple of ${e.multipleOf}`;break;case A.not_finite:r="Number must be finite";break;default:r=t.defaultError,ce.assertNever(e)}return{message:r}},fr=sM;var lM=fr;function el(){return lM}var rm=e=>{let{data:t,path:r,errorMaps:a,issueData:n}=e,i=[...r,...n.path||[]],o={...n,path:i};if(n.message!==void 0)return{...n,path:i,message:n.message};let s="",l=a.filter(c=>!!c).slice().reverse();for(let c of l)s=c(o,{data:t,defaultError:s}).message;return{...n,path:i,message:s}};function R(e,t){let r=el(),a=rm({issueData:t,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,r,r===fr?void 0:fr].filter(n=>!!n)});e.common.issues.push(a)}var rt=class e{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(t,r){let a=[];for(let n of r){if(n.status==="aborted")return W;n.status==="dirty"&&t.dirty(),a.push(n.value)}return{status:t.value,value:a}}static async mergeObjectAsync(t,r){let a=[];for(let n of r){let i=await n.key,o=await n.value;a.push({key:i,value:o})}return e.mergeObjectSync(t,a)}static mergeObjectSync(t,r){let a={};for(let n of r){let{key:i,value:o}=n;if(i.status==="aborted"||o.status==="aborted")return W;i.status==="dirty"&&t.dirty(),o.status==="dirty"&&t.dirty(),i.value!=="__proto__"&&(typeof o.value<"u"||n.alwaysSet)&&(a[i.value]=o.value)}return{status:t.value,value:a}}},W=Object.freeze({status:"aborted"}),Pi=e=>({status:"dirty",value:e}),gt=e=>({status:"valid",value:e}),ay=e=>e.status==="aborted",iy=e=>e.status==="dirty",na=e=>e.status==="valid",tl=e=>typeof Promise<"u"&&e instanceof Promise;var L;(function(e){e.errToObj=t=>typeof t=="string"?{message:t}:t||{},e.toString=t=>typeof t=="string"?t:t?.message})(L||(L={}));var Ut=class{constructor(t,r,a,n){this._cachedPath=[],this.parent=t,this.data=r,this._path=a,this._key=n}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}},QA=(e,t)=>{if(na(t))return{success:!0,data:t.value};if(!e.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;let r=new jt(e.common.issues);return this._error=r,this._error}}};function X(e){if(!e)return{};let{errorMap:t,invalid_type_error:r,required_error:a,description:n}=e;if(t&&(r||a))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return t?{errorMap:t,description:n}:{errorMap:(o,s)=>{let{message:l}=e;return o.code==="invalid_enum_value"?{message:l??s.defaultError}:typeof s.data>"u"?{message:l??a??s.defaultError}:o.code!=="invalid_type"?{message:s.defaultError}:{message:l??r??s.defaultError}},description:n}}var ie=class{get description(){return this._def.description}_getType(t){return qn(t.data)}_getOrReturnCtx(t,r){return r||{common:t.parent.common,data:t.data,parsedType:qn(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}_processInputParams(t){return{status:new rt,ctx:{common:t.parent.common,data:t.data,parsedType:qn(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}}_parseSync(t){let r=this._parse(t);if(tl(r))throw new Error("Synchronous parse encountered promise.");return r}_parseAsync(t){let r=this._parse(t);return Promise.resolve(r)}parse(t,r){let a=this.safeParse(t,r);if(a.success)return a.data;throw a.error}safeParse(t,r){let a={common:{issues:[],async:r?.async??!1,contextualErrorMap:r?.errorMap},path:r?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:qn(t)},n=this._parseSync({data:t,path:a.path,parent:a});return QA(a,n)}"~validate"(t){let r={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:qn(t)};if(!this["~standard"].async)try{let a=this._parseSync({data:t,path:[],parent:r});return na(a)?{value:a.value}:{issues:r.common.issues}}catch(a){a?.message?.toLowerCase()?.includes("encountered")&&(this["~standard"].async=!0),r.common={issues:[],async:!0}}return this._parseAsync({data:t,path:[],parent:r}).then(a=>na(a)?{value:a.value}:{issues:r.common.issues})}async parseAsync(t,r){let a=await this.safeParseAsync(t,r);if(a.success)return a.data;throw a.error}async safeParseAsync(t,r){let a={common:{issues:[],contextualErrorMap:r?.errorMap,async:!0},path:r?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:qn(t)},n=this._parse({data:t,path:a.path,parent:a}),i=await(tl(n)?n:Promise.resolve(n));return QA(a,i)}refine(t,r){let a=n=>typeof r=="string"||typeof r>"u"?{message:r}:typeof r=="function"?r(n):r;return this._refinement((n,i)=>{let o=t(n),s=()=>i.addIssue({code:A.custom,...a(n)});return typeof Promise<"u"&&o instanceof Promise?o.then(l=>l?!0:(s(),!1)):o?!0:(s(),!1)})}refinement(t,r){return this._refinement((a,n)=>t(a)?!0:(n.addIssue(typeof r=="function"?r(a,n):r),!1))}_refinement(t){return new Yt({schema:this,typeName:I.ZodEffects,effect:{type:"refinement",refinement:t}})}superRefine(t){return this._refinement(t)}constructor(t){this.spa=this.safeParseAsync,this._def=t,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:r=>this["~validate"](r)}}optional(){return Jt.create(this,this._def)}nullable(){return Vn.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return vr.create(this)}promise(){return ra.create(this,this._def)}or(t){return Ni.create([this,t],this._def)}and(t){return Di.create(this,t,this._def)}transform(t){return new Yt({...X(this._def),schema:this,typeName:I.ZodEffects,effect:{type:"transform",transform:t}})}default(t){let r=typeof t=="function"?t:()=>t;return new Fi({...X(this._def),innerType:this,defaultValue:r,typeName:I.ZodDefault})}brand(){return new am({typeName:I.ZodBranded,type:this,...X(this._def)})}catch(t){let r=typeof t=="function"?t:()=>t;return new qi({...X(this._def),innerType:this,catchValue:r,typeName:I.ZodCatch})}describe(t){let r=this.constructor;return new r({...this._def,description:t})}pipe(t){return im.create(this,t)}readonly(){return Hi.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},cM=/^c[^\s-]{8,}$/i,uM=/^[0-9a-z]+$/,dM=/^[0-9A-HJKMNP-TV-Z]{26}$/i,pM=/^[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,mM=/^[a-z0-9_-]{21}$/i,gM=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,hM=/^[-+]?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)?)??$/,fM=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,bM="^[\\p{Extended_Pictographic}\\p{Emoji_Component}]+$",oy,vM=/^(?:(?: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])$/,yM=/^(?:(?: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])$/,kM=/^(([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]))$/,_M=/^(([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])$/,wM=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,SM=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,eC="((\\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])))",EM=new RegExp(`^${eC}$`);function tC(e){let t="[0-5]\\d";e.precision?t=`${t}\\.\\d{${e.precision}}`:e.precision==null&&(t=`${t}(\\.\\d+)?`);let r=e.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${t})${r}`}function xM(e){return new RegExp(`^${tC(e)}$`)}function TM(e){let t=`${eC}T${tC(e)}`,r=[];return r.push(e.local?"Z?":"Z"),e.offset&&r.push("([+-]\\d{2}:?\\d{2})"),t=`${t}(${r.join("|")})`,new RegExp(`^${t}$`)}function AM(e,t){return!!((t==="v4"||!t)&&vM.test(e)||(t==="v6"||!t)&&kM.test(e))}function CM(e,t){if(!gM.test(e))return!1;try{let[r]=e.split(".");if(!r)return!1;let a=r.replace(/-/g,"+").replace(/_/g,"/").padEnd(r.length+(4-r.length%4)%4,"="),n=JSON.parse(atob(a));return!(typeof n!="object"||n===null||"typ"in n&&n?.typ!=="JWT"||!n.alg||t&&n.alg!==t)}catch{return!1}}function zM(e,t){return!!((t==="v4"||!t)&&yM.test(e)||(t==="v6"||!t)&&_M.test(e))}var $i=class e extends ie{_parse(t){if(this._def.coerce&&(t.data=String(t.data)),this._getType(t)!==N.string){let i=this._getOrReturnCtx(t);return R(i,{code:A.invalid_type,expected:N.string,received:i.parsedType}),W}let a=new rt,n;for(let i of this._def.checks)if(i.kind==="min")t.data.length<i.value&&(n=this._getOrReturnCtx(t,n),R(n,{code:A.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),a.dirty());else if(i.kind==="max")t.data.length>i.value&&(n=this._getOrReturnCtx(t,n),R(n,{code:A.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),a.dirty());else if(i.kind==="length"){let o=t.data.length>i.value,s=t.data.length<i.value;(o||s)&&(n=this._getOrReturnCtx(t,n),o?R(n,{code:A.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}):s&&R(n,{code:A.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}),a.dirty())}else if(i.kind==="email")fM.test(t.data)||(n=this._getOrReturnCtx(t,n),R(n,{validation:"email",code:A.invalid_string,message:i.message}),a.dirty());else if(i.kind==="emoji")oy||(oy=new RegExp(bM,"u")),oy.test(t.data)||(n=this._getOrReturnCtx(t,n),R(n,{validation:"emoji",code:A.invalid_string,message:i.message}),a.dirty());else if(i.kind==="uuid")pM.test(t.data)||(n=this._getOrReturnCtx(t,n),R(n,{validation:"uuid",code:A.invalid_string,message:i.message}),a.dirty());else if(i.kind==="nanoid")mM.test(t.data)||(n=this._getOrReturnCtx(t,n),R(n,{validation:"nanoid",code:A.invalid_string,message:i.message}),a.dirty());else if(i.kind==="cuid")cM.test(t.data)||(n=this._getOrReturnCtx(t,n),R(n,{validation:"cuid",code:A.invalid_string,message:i.message}),a.dirty());else if(i.kind==="cuid2")uM.test(t.data)||(n=this._getOrReturnCtx(t,n),R(n,{validation:"cuid2",code:A.invalid_string,message:i.message}),a.dirty());else if(i.kind==="ulid")dM.test(t.data)||(n=this._getOrReturnCtx(t,n),R(n,{validation:"ulid",code:A.invalid_string,message:i.message}),a.dirty());else if(i.kind==="url")try{new URL(t.data)}catch{n=this._getOrReturnCtx(t,n),R(n,{validation:"url",code:A.invalid_string,message:i.message}),a.dirty()}else i.kind==="regex"?(i.regex.lastIndex=0,i.regex.test(t.data)||(n=this._getOrReturnCtx(t,n),R(n,{validation:"regex",code:A.invalid_string,message:i.message}),a.dirty())):i.kind==="trim"?t.data=t.data.trim():i.kind==="includes"?t.data.includes(i.value,i.position)||(n=this._getOrReturnCtx(t,n),R(n,{code:A.invalid_string,validation:{includes:i.value,position:i.position},message:i.message}),a.dirty()):i.kind==="toLowerCase"?t.data=t.data.toLowerCase():i.kind==="toUpperCase"?t.data=t.data.toUpperCase():i.kind==="startsWith"?t.data.startsWith(i.value)||(n=this._getOrReturnCtx(t,n),R(n,{code:A.invalid_string,validation:{startsWith:i.value},message:i.message}),a.dirty()):i.kind==="endsWith"?t.data.endsWith(i.value)||(n=this._getOrReturnCtx(t,n),R(n,{code:A.invalid_string,validation:{endsWith:i.value},message:i.message}),a.dirty()):i.kind==="datetime"?TM(i).test(t.data)||(n=this._getOrReturnCtx(t,n),R(n,{code:A.invalid_string,validation:"datetime",message:i.message}),a.dirty()):i.kind==="date"?EM.test(t.data)||(n=this._getOrReturnCtx(t,n),R(n,{code:A.invalid_string,validation:"date",message:i.message}),a.dirty()):i.kind==="time"?xM(i).test(t.data)||(n=this._getOrReturnCtx(t,n),R(n,{code:A.invalid_string,validation:"time",message:i.message}),a.dirty()):i.kind==="duration"?hM.test(t.data)||(n=this._getOrReturnCtx(t,n),R(n,{validation:"duration",code:A.invalid_string,message:i.message}),a.dirty()):i.kind==="ip"?AM(t.data,i.version)||(n=this._getOrReturnCtx(t,n),R(n,{validation:"ip",code:A.invalid_string,message:i.message}),a.dirty()):i.kind==="jwt"?CM(t.data,i.alg)||(n=this._getOrReturnCtx(t,n),R(n,{validation:"jwt",code:A.invalid_string,message:i.message}),a.dirty()):i.kind==="cidr"?zM(t.data,i.version)||(n=this._getOrReturnCtx(t,n),R(n,{validation:"cidr",code:A.invalid_string,message:i.message}),a.dirty()):i.kind==="base64"?wM.test(t.data)||(n=this._getOrReturnCtx(t,n),R(n,{validation:"base64",code:A.invalid_string,message:i.message}),a.dirty()):i.kind==="base64url"?SM.test(t.data)||(n=this._getOrReturnCtx(t,n),R(n,{validation:"base64url",code:A.invalid_string,message:i.message}),a.dirty()):ce.assertNever(i);return{status:a.value,value:t.data}}_regex(t,r,a){return this.refinement(n=>t.test(n),{validation:r,code:A.invalid_string,...L.errToObj(a)})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}email(t){return this._addCheck({kind:"email",...L.errToObj(t)})}url(t){return this._addCheck({kind:"url",...L.errToObj(t)})}emoji(t){return this._addCheck({kind:"emoji",...L.errToObj(t)})}uuid(t){return this._addCheck({kind:"uuid",...L.errToObj(t)})}nanoid(t){return this._addCheck({kind:"nanoid",...L.errToObj(t)})}cuid(t){return this._addCheck({kind:"cuid",...L.errToObj(t)})}cuid2(t){return this._addCheck({kind:"cuid2",...L.errToObj(t)})}ulid(t){return this._addCheck({kind:"ulid",...L.errToObj(t)})}base64(t){return this._addCheck({kind:"base64",...L.errToObj(t)})}base64url(t){return this._addCheck({kind:"base64url",...L.errToObj(t)})}jwt(t){return this._addCheck({kind:"jwt",...L.errToObj(t)})}ip(t){return this._addCheck({kind:"ip",...L.errToObj(t)})}cidr(t){return this._addCheck({kind:"cidr",...L.errToObj(t)})}datetime(t){return typeof t=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:t}):this._addCheck({kind:"datetime",precision:typeof t?.precision>"u"?null:t?.precision,offset:t?.offset??!1,local:t?.local??!1,...L.errToObj(t?.message)})}date(t){return this._addCheck({kind:"date",message:t})}time(t){return typeof t=="string"?this._addCheck({kind:"time",precision:null,message:t}):this._addCheck({kind:"time",precision:typeof t?.precision>"u"?null:t?.precision,...L.errToObj(t?.message)})}duration(t){return this._addCheck({kind:"duration",...L.errToObj(t)})}regex(t,r){return this._addCheck({kind:"regex",regex:t,...L.errToObj(r)})}includes(t,r){return this._addCheck({kind:"includes",value:t,position:r?.position,...L.errToObj(r?.message)})}startsWith(t,r){return this._addCheck({kind:"startsWith",value:t,...L.errToObj(r)})}endsWith(t,r){return this._addCheck({kind:"endsWith",value:t,...L.errToObj(r)})}min(t,r){return this._addCheck({kind:"min",value:t,...L.errToObj(r)})}max(t,r){return this._addCheck({kind:"max",value:t,...L.errToObj(r)})}length(t,r){return this._addCheck({kind:"length",value:t,...L.errToObj(r)})}nonempty(t){return this.min(1,L.errToObj(t))}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(t=>t.kind==="datetime")}get isDate(){return!!this._def.checks.find(t=>t.kind==="date")}get isTime(){return!!this._def.checks.find(t=>t.kind==="time")}get isDuration(){return!!this._def.checks.find(t=>t.kind==="duration")}get isEmail(){return!!this._def.checks.find(t=>t.kind==="email")}get isURL(){return!!this._def.checks.find(t=>t.kind==="url")}get isEmoji(){return!!this._def.checks.find(t=>t.kind==="emoji")}get isUUID(){return!!this._def.checks.find(t=>t.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(t=>t.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(t=>t.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(t=>t.kind==="cuid2")}get isULID(){return!!this._def.checks.find(t=>t.kind==="ulid")}get isIP(){return!!this._def.checks.find(t=>t.kind==="ip")}get isCIDR(){return!!this._def.checks.find(t=>t.kind==="cidr")}get isBase64(){return!!this._def.checks.find(t=>t.kind==="base64")}get isBase64url(){return!!this._def.checks.find(t=>t.kind==="base64url")}get minLength(){let t=null;for(let r of this._def.checks)r.kind==="min"&&(t===null||r.value>t)&&(t=r.value);return t}get maxLength(){let t=null;for(let r of this._def.checks)r.kind==="max"&&(t===null||r.value<t)&&(t=r.value);return t}};$i.create=e=>new $i({checks:[],typeName:I.ZodString,coerce:e?.coerce??!1,...X(e)});function IM(e,t){let r=(e.toString().split(".")[1]||"").length,a=(t.toString().split(".")[1]||"").length,n=r>a?r:a,i=Number.parseInt(e.toFixed(n).replace(".","")),o=Number.parseInt(t.toFixed(n).replace(".",""));return i%o/10**n}var nl=class e extends ie{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(t){if(this._def.coerce&&(t.data=Number(t.data)),this._getType(t)!==N.number){let i=this._getOrReturnCtx(t);return R(i,{code:A.invalid_type,expected:N.number,received:i.parsedType}),W}let a,n=new rt;for(let i of this._def.checks)i.kind==="int"?ce.isInteger(t.data)||(a=this._getOrReturnCtx(t,a),R(a,{code:A.invalid_type,expected:"integer",received:"float",message:i.message}),n.dirty()):i.kind==="min"?(i.inclusive?t.data<i.value:t.data<=i.value)&&(a=this._getOrReturnCtx(t,a),R(a,{code:A.too_small,minimum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),n.dirty()):i.kind==="max"?(i.inclusive?t.data>i.value:t.data>=i.value)&&(a=this._getOrReturnCtx(t,a),R(a,{code:A.too_big,maximum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),n.dirty()):i.kind==="multipleOf"?IM(t.data,i.value)!==0&&(a=this._getOrReturnCtx(t,a),R(a,{code:A.not_multiple_of,multipleOf:i.value,message:i.message}),n.dirty()):i.kind==="finite"?Number.isFinite(t.data)||(a=this._getOrReturnCtx(t,a),R(a,{code:A.not_finite,message:i.message}),n.dirty()):ce.assertNever(i);return{status:n.value,value:t.data}}gte(t,r){return this.setLimit("min",t,!0,L.toString(r))}gt(t,r){return this.setLimit("min",t,!1,L.toString(r))}lte(t,r){return this.setLimit("max",t,!0,L.toString(r))}lt(t,r){return this.setLimit("max",t,!1,L.toString(r))}setLimit(t,r,a,n){return new e({...this._def,checks:[...this._def.checks,{kind:t,value:r,inclusive:a,message:L.toString(n)}]})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}int(t){return this._addCheck({kind:"int",message:L.toString(t)})}positive(t){return this._addCheck({kind:"min",value:0,inclusive:!1,message:L.toString(t)})}negative(t){return this._addCheck({kind:"max",value:0,inclusive:!1,message:L.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:0,inclusive:!0,message:L.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:0,inclusive:!0,message:L.toString(t)})}multipleOf(t,r){return this._addCheck({kind:"multipleOf",value:t,message:L.toString(r)})}finite(t){return this._addCheck({kind:"finite",message:L.toString(t)})}safe(t){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:L.toString(t)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:L.toString(t)})}get minValue(){let t=null;for(let r of this._def.checks)r.kind==="min"&&(t===null||r.value>t)&&(t=r.value);return t}get maxValue(){let t=null;for(let r of this._def.checks)r.kind==="max"&&(t===null||r.value<t)&&(t=r.value);return t}get isInt(){return!!this._def.checks.find(t=>t.kind==="int"||t.kind==="multipleOf"&&ce.isInteger(t.value))}get isFinite(){let t=null,r=null;for(let a of this._def.checks){if(a.kind==="finite"||a.kind==="int"||a.kind==="multipleOf")return!0;a.kind==="min"?(r===null||a.value>r)&&(r=a.value):a.kind==="max"&&(t===null||a.value<t)&&(t=a.value)}return Number.isFinite(r)&&Number.isFinite(t)}};nl.create=e=>new nl({checks:[],typeName:I.ZodNumber,coerce:e?.coerce||!1,...X(e)});var rl=class e extends ie{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(t){if(this._def.coerce)try{t.data=BigInt(t.data)}catch{return this._getInvalidInput(t)}if(this._getType(t)!==N.bigint)return this._getInvalidInput(t);let a,n=new rt;for(let i of this._def.checks)i.kind==="min"?(i.inclusive?t.data<i.value:t.data<=i.value)&&(a=this._getOrReturnCtx(t,a),R(a,{code:A.too_small,type:"bigint",minimum:i.value,inclusive:i.inclusive,message:i.message}),n.dirty()):i.kind==="max"?(i.inclusive?t.data>i.value:t.data>=i.value)&&(a=this._getOrReturnCtx(t,a),R(a,{code:A.too_big,type:"bigint",maximum:i.value,inclusive:i.inclusive,message:i.message}),n.dirty()):i.kind==="multipleOf"?t.data%i.value!==BigInt(0)&&(a=this._getOrReturnCtx(t,a),R(a,{code:A.not_multiple_of,multipleOf:i.value,message:i.message}),n.dirty()):ce.assertNever(i);return{status:n.value,value:t.data}}_getInvalidInput(t){let r=this._getOrReturnCtx(t);return R(r,{code:A.invalid_type,expected:N.bigint,received:r.parsedType}),W}gte(t,r){return this.setLimit("min",t,!0,L.toString(r))}gt(t,r){return this.setLimit("min",t,!1,L.toString(r))}lte(t,r){return this.setLimit("max",t,!0,L.toString(r))}lt(t,r){return this.setLimit("max",t,!1,L.toString(r))}setLimit(t,r,a,n){return new e({...this._def,checks:[...this._def.checks,{kind:t,value:r,inclusive:a,message:L.toString(n)}]})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}positive(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:L.toString(t)})}negative(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:L.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:L.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:L.toString(t)})}multipleOf(t,r){return this._addCheck({kind:"multipleOf",value:t,message:L.toString(r)})}get minValue(){let t=null;for(let r of this._def.checks)r.kind==="min"&&(t===null||r.value>t)&&(t=r.value);return t}get maxValue(){let t=null;for(let r of this._def.checks)r.kind==="max"&&(t===null||r.value<t)&&(t=r.value);return t}};rl.create=e=>new rl({checks:[],typeName:I.ZodBigInt,coerce:e?.coerce??!1,...X(e)});var al=class extends ie{_parse(t){if(this._def.coerce&&(t.data=!!t.data),this._getType(t)!==N.boolean){let a=this._getOrReturnCtx(t);return R(a,{code:A.invalid_type,expected:N.boolean,received:a.parsedType}),W}return gt(t.data)}};al.create=e=>new al({typeName:I.ZodBoolean,coerce:e?.coerce||!1,...X(e)});var il=class e extends ie{_parse(t){if(this._def.coerce&&(t.data=new Date(t.data)),this._getType(t)!==N.date){let i=this._getOrReturnCtx(t);return R(i,{code:A.invalid_type,expected:N.date,received:i.parsedType}),W}if(Number.isNaN(t.data.getTime())){let i=this._getOrReturnCtx(t);return R(i,{code:A.invalid_date}),W}let a=new rt,n;for(let i of this._def.checks)i.kind==="min"?t.data.getTime()<i.value&&(n=this._getOrReturnCtx(t,n),R(n,{code:A.too_small,message:i.message,inclusive:!0,exact:!1,minimum:i.value,type:"date"}),a.dirty()):i.kind==="max"?t.data.getTime()>i.value&&(n=this._getOrReturnCtx(t,n),R(n,{code:A.too_big,message:i.message,inclusive:!0,exact:!1,maximum:i.value,type:"date"}),a.dirty()):ce.assertNever(i);return{status:a.value,value:new Date(t.data.getTime())}}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}min(t,r){return this._addCheck({kind:"min",value:t.getTime(),message:L.toString(r)})}max(t,r){return this._addCheck({kind:"max",value:t.getTime(),message:L.toString(r)})}get minDate(){let t=null;for(let r of this._def.checks)r.kind==="min"&&(t===null||r.value>t)&&(t=r.value);return t!=null?new Date(t):null}get maxDate(){let t=null;for(let r of this._def.checks)r.kind==="max"&&(t===null||r.value<t)&&(t=r.value);return t!=null?new Date(t):null}};il.create=e=>new il({checks:[],coerce:e?.coerce||!1,typeName:I.ZodDate,...X(e)});var ol=class extends ie{_parse(t){if(this._getType(t)!==N.symbol){let a=this._getOrReturnCtx(t);return R(a,{code:A.invalid_type,expected:N.symbol,received:a.parsedType}),W}return gt(t.data)}};ol.create=e=>new ol({typeName:I.ZodSymbol,...X(e)});var ji=class extends ie{_parse(t){if(this._getType(t)!==N.undefined){let a=this._getOrReturnCtx(t);return R(a,{code:A.invalid_type,expected:N.undefined,received:a.parsedType}),W}return gt(t.data)}};ji.create=e=>new ji({typeName:I.ZodUndefined,...X(e)});var Oi=class extends ie{_parse(t){if(this._getType(t)!==N.null){let a=this._getOrReturnCtx(t);return R(a,{code:A.invalid_type,expected:N.null,received:a.parsedType}),W}return gt(t.data)}};Oi.create=e=>new Oi({typeName:I.ZodNull,...X(e)});var sl=class extends ie{constructor(){super(...arguments),this._any=!0}_parse(t){return gt(t.data)}};sl.create=e=>new sl({typeName:I.ZodAny,...X(e)});var br=class extends ie{constructor(){super(...arguments),this._unknown=!0}_parse(t){return gt(t.data)}};br.create=e=>new br({typeName:I.ZodUnknown,...X(e)});var fn=class extends ie{_parse(t){let r=this._getOrReturnCtx(t);return R(r,{code:A.invalid_type,expected:N.never,received:r.parsedType}),W}};fn.create=e=>new fn({typeName:I.ZodNever,...X(e)});var ll=class extends ie{_parse(t){if(this._getType(t)!==N.undefined){let a=this._getOrReturnCtx(t);return R(a,{code:A.invalid_type,expected:N.void,received:a.parsedType}),W}return gt(t.data)}};ll.create=e=>new ll({typeName:I.ZodVoid,...X(e)});var vr=class e extends ie{_parse(t){let{ctx:r,status:a}=this._processInputParams(t),n=this._def;if(r.parsedType!==N.array)return R(r,{code:A.invalid_type,expected:N.array,received:r.parsedType}),W;if(n.exactLength!==null){let o=r.data.length>n.exactLength.value,s=r.data.length<n.exactLength.value;(o||s)&&(R(r,{code:o?A.too_big:A.too_small,minimum:s?n.exactLength.value:void 0,maximum:o?n.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:n.exactLength.message}),a.dirty())}if(n.minLength!==null&&r.data.length<n.minLength.value&&(R(r,{code:A.too_small,minimum:n.minLength.value,type:"array",inclusive:!0,exact:!1,message:n.minLength.message}),a.dirty()),n.maxLength!==null&&r.data.length>n.maxLength.value&&(R(r,{code:A.too_big,maximum:n.maxLength.value,type:"array",inclusive:!0,exact:!1,message:n.maxLength.message}),a.dirty()),r.common.async)return Promise.all([...r.data].map((o,s)=>n.type._parseAsync(new Ut(r,o,r.path,s)))).then(o=>rt.mergeArray(a,o));let i=[...r.data].map((o,s)=>n.type._parseSync(new Ut(r,o,r.path,s)));return rt.mergeArray(a,i)}get element(){return this._def.type}min(t,r){return new e({...this._def,minLength:{value:t,message:L.toString(r)}})}max(t,r){return new e({...this._def,maxLength:{value:t,message:L.toString(r)}})}length(t,r){return new e({...this._def,exactLength:{value:t,message:L.toString(r)}})}nonempty(t){return this.min(1,t)}};vr.create=(e,t)=>new vr({type:e,minLength:null,maxLength:null,exactLength:null,typeName:I.ZodArray,...X(t)});function Ri(e){if(e instanceof Ot){let t={};for(let r in e.shape){let a=e.shape[r];t[r]=Jt.create(Ri(a))}return new Ot({...e._def,shape:()=>t})}else return e instanceof vr?new vr({...e._def,type:Ri(e.element)}):e instanceof Jt?Jt.create(Ri(e.unwrap())):e instanceof Vn?Vn.create(Ri(e.unwrap())):e instanceof Gn?Gn.create(e.items.map(t=>Ri(t))):e}var Ot=class e extends ie{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;let t=this._def.shape(),r=ce.objectKeys(t);return this._cached={shape:t,keys:r},this._cached}_parse(t){if(this._getType(t)!==N.object){let c=this._getOrReturnCtx(t);return R(c,{code:A.invalid_type,expected:N.object,received:c.parsedType}),W}let{status:a,ctx:n}=this._processInputParams(t),{shape:i,keys:o}=this._getCached(),s=[];if(!(this._def.catchall instanceof fn&&this._def.unknownKeys==="strip"))for(let c in n.data)o.includes(c)||s.push(c);let l=[];for(let c of o){let u=i[c],d=n.data[c];l.push({key:{status:"valid",value:c},value:u._parse(new Ut(n,d,n.path,c)),alwaysSet:c in n.data})}if(this._def.catchall instanceof fn){let c=this._def.unknownKeys;if(c==="passthrough")for(let u of s)l.push({key:{status:"valid",value:u},value:{status:"valid",value:n.data[u]}});else if(c==="strict")s.length>0&&(R(n,{code:A.unrecognized_keys,keys:s}),a.dirty());else if(c!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{let c=this._def.catchall;for(let u of s){let d=n.data[u];l.push({key:{status:"valid",value:u},value:c._parse(new Ut(n,d,n.path,u)),alwaysSet:u in n.data})}}return n.common.async?Promise.resolve().then(async()=>{let c=[];for(let u of l){let d=await u.key,m=await u.value;c.push({key:d,value:m,alwaysSet:u.alwaysSet})}return c}).then(c=>rt.mergeObjectSync(a,c)):rt.mergeObjectSync(a,l)}get shape(){return this._def.shape()}strict(t){return L.errToObj,new e({...this._def,unknownKeys:"strict",...t!==void 0?{errorMap:(r,a)=>{let n=this._def.errorMap?.(r,a).message??a.defaultError;return r.code==="unrecognized_keys"?{message:L.errToObj(t).message??n}:{message:n}}}:{}})}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:I.ZodObject})}setKey(t,r){return this.augment({[t]:r})}catchall(t){return new e({...this._def,catchall:t})}pick(t){let r={};for(let a of ce.objectKeys(t))t[a]&&this.shape[a]&&(r[a]=this.shape[a]);return new e({...this._def,shape:()=>r})}omit(t){let r={};for(let a of ce.objectKeys(this.shape))t[a]||(r[a]=this.shape[a]);return new e({...this._def,shape:()=>r})}deepPartial(){return Ri(this)}partial(t){let r={};for(let a of ce.objectKeys(this.shape)){let n=this.shape[a];t&&!t[a]?r[a]=n:r[a]=n.optional()}return new e({...this._def,shape:()=>r})}required(t){let r={};for(let a of ce.objectKeys(this.shape))if(t&&!t[a])r[a]=this.shape[a];else{let i=this.shape[a];for(;i instanceof Jt;)i=i._def.innerType;r[a]=i}return new e({...this._def,shape:()=>r})}keyof(){return nC(ce.objectKeys(this.shape))}};Ot.create=(e,t)=>new Ot({shape:()=>e,unknownKeys:"strip",catchall:fn.create(),typeName:I.ZodObject,...X(t)});Ot.strictCreate=(e,t)=>new Ot({shape:()=>e,unknownKeys:"strict",catchall:fn.create(),typeName:I.ZodObject,...X(t)});Ot.lazycreate=(e,t)=>new Ot({shape:e,unknownKeys:"strip",catchall:fn.create(),typeName:I.ZodObject,...X(t)});var Ni=class extends ie{_parse(t){let{ctx:r}=this._processInputParams(t),a=this._def.options;function n(i){for(let s of i)if(s.result.status==="valid")return s.result;for(let s of i)if(s.result.status==="dirty")return r.common.issues.push(...s.ctx.common.issues),s.result;let o=i.map(s=>new jt(s.ctx.common.issues));return R(r,{code:A.invalid_union,unionErrors:o}),W}if(r.common.async)return Promise.all(a.map(async i=>{let o={...r,common:{...r.common,issues:[]},parent:null};return{result:await i._parseAsync({data:r.data,path:r.path,parent:o}),ctx:o}})).then(n);{let i,o=[];for(let l of a){let c={...r,common:{...r.common,issues:[]},parent:null},u=l._parseSync({data:r.data,path:r.path,parent:c});if(u.status==="valid")return u;u.status==="dirty"&&!i&&(i={result:u,ctx:c}),c.common.issues.length&&o.push(c.common.issues)}if(i)return r.common.issues.push(...i.ctx.common.issues),i.result;let s=o.map(l=>new jt(l));return R(r,{code:A.invalid_union,unionErrors:s}),W}}get options(){return this._def.options}};Ni.create=(e,t)=>new Ni({options:e,typeName:I.ZodUnion,...X(t)});var Hn=e=>e instanceof Mi?Hn(e.schema):e instanceof Yt?Hn(e.innerType()):e instanceof Li?[e.value]:e instanceof Bi?e.options:e instanceof Ui?ce.objectValues(e.enum):e instanceof Fi?Hn(e._def.innerType):e instanceof ji?[void 0]:e instanceof Oi?[null]:e instanceof Jt?[void 0,...Hn(e.unwrap())]:e instanceof Vn?[null,...Hn(e.unwrap())]:e instanceof am||e instanceof Hi?Hn(e.unwrap()):e instanceof qi?Hn(e._def.innerType):[],sy=class e extends ie{_parse(t){let{ctx:r}=this._processInputParams(t);if(r.parsedType!==N.object)return R(r,{code:A.invalid_type,expected:N.object,received:r.parsedType}),W;let a=this.discriminator,n=r.data[a],i=this.optionsMap.get(n);return i?r.common.async?i._parseAsync({data:r.data,path:r.path,parent:r}):i._parseSync({data:r.data,path:r.path,parent:r}):(R(r,{code:A.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[a]}),W)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(t,r,a){let n=new Map;for(let i of r){let o=Hn(i.shape[t]);if(!o.length)throw new Error(`A discriminator value for key \`${t}\` could not be extracted from all schema options`);for(let s of o){if(n.has(s))throw new Error(`Discriminator property ${String(t)} has duplicate value ${String(s)}`);n.set(s,i)}}return new e({typeName:I.ZodDiscriminatedUnion,discriminator:t,options:r,optionsMap:n,...X(a)})}};function ly(e,t){let r=qn(e),a=qn(t);if(e===t)return{valid:!0,data:e};if(r===N.object&&a===N.object){let n=ce.objectKeys(t),i=ce.objectKeys(e).filter(s=>n.indexOf(s)!==-1),o={...e,...t};Object.prototype.hasOwnProperty.call(o,"__proto__")&&delete o.__proto__;for(let s of i){if(s==="__proto__")continue;let l=ly(e[s],t[s]);if(!l.valid)return{valid:!1};o[s]=l.data}return{valid:!0,data:o}}else if(r===N.array&&a===N.array){if(e.length!==t.length)return{valid:!1};let n=[];for(let i=0;i<e.length;i++){let o=e[i],s=t[i],l=ly(o,s);if(!l.valid)return{valid:!1};n.push(l.data)}return{valid:!0,data:n}}else return r===N.date&&a===N.date&&+e==+t?{valid:!0,data:e}:{valid:!1}}var Di=class extends ie{_parse(t){let{status:r,ctx:a}=this._processInputParams(t),n=(i,o)=>{if(ay(i)||ay(o))return W;let s=ly(i.value,o.value);return s.valid?((iy(i)||iy(o))&&r.dirty(),{status:r.value,value:s.data}):(R(a,{code:A.invalid_intersection_types}),W)};return a.common.async?Promise.all([this._def.left._parseAsync({data:a.data,path:a.path,parent:a}),this._def.right._parseAsync({data:a.data,path:a.path,parent:a})]).then(([i,o])=>n(i,o)):n(this._def.left._parseSync({data:a.data,path:a.path,parent:a}),this._def.right._parseSync({data:a.data,path:a.path,parent:a}))}};Di.create=(e,t,r)=>new Di({left:e,right:t,typeName:I.ZodIntersection,...X(r)});var Gn=class e extends ie{_parse(t){let{status:r,ctx:a}=this._processInputParams(t);if(a.parsedType!==N.array)return R(a,{code:A.invalid_type,expected:N.array,received:a.parsedType}),W;if(a.data.length<this._def.items.length)return R(a,{code:A.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),W;!this._def.rest&&a.data.length>this._def.items.length&&(R(a,{code:A.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),r.dirty());let i=[...a.data].map((o,s)=>{let l=this._def.items[s]||this._def.rest;return l?l._parse(new Ut(a,o,a.path,s)):null}).filter(o=>!!o);return a.common.async?Promise.all(i).then(o=>rt.mergeArray(r,o)):rt.mergeArray(r,i)}get items(){return this._def.items}rest(t){return new e({...this._def,rest:t})}};Gn.create=(e,t)=>{if(!Array.isArray(e))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new Gn({items:e,typeName:I.ZodTuple,rest:null,...X(t)})};var cy=class e extends ie{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(t){let{status:r,ctx:a}=this._processInputParams(t);if(a.parsedType!==N.object)return R(a,{code:A.invalid_type,expected:N.object,received:a.parsedType}),W;let n=[],i=this._def.keyType,o=this._def.valueType;for(let s in a.data)n.push({key:i._parse(new Ut(a,s,a.path,s)),value:o._parse(new Ut(a,a.data[s],a.path,s)),alwaysSet:s in a.data});return a.common.async?rt.mergeObjectAsync(r,n):rt.mergeObjectSync(r,n)}get element(){return this._def.valueType}static create(t,r,a){return r instanceof ie?new e({keyType:t,valueType:r,typeName:I.ZodRecord,...X(a)}):new e({keyType:$i.create(),valueType:t,typeName:I.ZodRecord,...X(r)})}},cl=class extends ie{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(t){let{status:r,ctx:a}=this._processInputParams(t);if(a.parsedType!==N.map)return R(a,{code:A.invalid_type,expected:N.map,received:a.parsedType}),W;let n=this._def.keyType,i=this._def.valueType,o=[...a.data.entries()].map(([s,l],c)=>({key:n._parse(new Ut(a,s,a.path,[c,"key"])),value:i._parse(new Ut(a,l,a.path,[c,"value"]))}));if(a.common.async){let s=new Map;return Promise.resolve().then(async()=>{for(let l of o){let c=await l.key,u=await l.value;if(c.status==="aborted"||u.status==="aborted")return W;(c.status==="dirty"||u.status==="dirty")&&r.dirty(),s.set(c.value,u.value)}return{status:r.value,value:s}})}else{let s=new Map;for(let l of o){let c=l.key,u=l.value;if(c.status==="aborted"||u.status==="aborted")return W;(c.status==="dirty"||u.status==="dirty")&&r.dirty(),s.set(c.value,u.value)}return{status:r.value,value:s}}}};cl.create=(e,t,r)=>new cl({valueType:t,keyType:e,typeName:I.ZodMap,...X(r)});var ul=class e extends ie{_parse(t){let{status:r,ctx:a}=this._processInputParams(t);if(a.parsedType!==N.set)return R(a,{code:A.invalid_type,expected:N.set,received:a.parsedType}),W;let n=this._def;n.minSize!==null&&a.data.size<n.minSize.value&&(R(a,{code:A.too_small,minimum:n.minSize.value,type:"set",inclusive:!0,exact:!1,message:n.minSize.message}),r.dirty()),n.maxSize!==null&&a.data.size>n.maxSize.value&&(R(a,{code:A.too_big,maximum:n.maxSize.value,type:"set",inclusive:!0,exact:!1,message:n.maxSize.message}),r.dirty());let i=this._def.valueType;function o(l){let c=new Set;for(let u of l){if(u.status==="aborted")return W;u.status==="dirty"&&r.dirty(),c.add(u.value)}return{status:r.value,value:c}}let s=[...a.data.values()].map((l,c)=>i._parse(new Ut(a,l,a.path,c)));return a.common.async?Promise.all(s).then(l=>o(l)):o(s)}min(t,r){return new e({...this._def,minSize:{value:t,message:L.toString(r)}})}max(t,r){return new e({...this._def,maxSize:{value:t,message:L.toString(r)}})}size(t,r){return this.min(t,r).max(t,r)}nonempty(t){return this.min(1,t)}};ul.create=(e,t)=>new ul({valueType:e,minSize:null,maxSize:null,typeName:I.ZodSet,...X(t)});var uy=class e extends ie{constructor(){super(...arguments),this.validate=this.implement}_parse(t){let{ctx:r}=this._processInputParams(t);if(r.parsedType!==N.function)return R(r,{code:A.invalid_type,expected:N.function,received:r.parsedType}),W;function a(s,l){return rm({data:s,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,el(),fr].filter(c=>!!c),issueData:{code:A.invalid_arguments,argumentsError:l}})}function n(s,l){return rm({data:s,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,el(),fr].filter(c=>!!c),issueData:{code:A.invalid_return_type,returnTypeError:l}})}let i={errorMap:r.common.contextualErrorMap},o=r.data;if(this._def.returns instanceof ra){let s=this;return gt(async function(...l){let c=new jt([]),u=await s._def.args.parseAsync(l,i).catch(p=>{throw c.addIssue(a(l,p)),c}),d=await Reflect.apply(o,this,u);return await s._def.returns._def.type.parseAsync(d,i).catch(p=>{throw c.addIssue(n(d,p)),c})})}else{let s=this;return gt(function(...l){let c=s._def.args.safeParse(l,i);if(!c.success)throw new jt([a(l,c.error)]);let u=Reflect.apply(o,this,c.data),d=s._def.returns.safeParse(u,i);if(!d.success)throw new jt([n(u,d.error)]);return d.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...t){return new e({...this._def,args:Gn.create(t).rest(br.create())})}returns(t){return new e({...this._def,returns:t})}implement(t){return this.parse(t)}strictImplement(t){return this.parse(t)}static create(t,r,a){return new e({args:t||Gn.create([]).rest(br.create()),returns:r||br.create(),typeName:I.ZodFunction,...X(a)})}},Mi=class extends ie{get schema(){return this._def.getter()}_parse(t){let{ctx:r}=this._processInputParams(t);return this._def.getter()._parse({data:r.data,path:r.path,parent:r})}};Mi.create=(e,t)=>new Mi({getter:e,typeName:I.ZodLazy,...X(t)});var Li=class extends ie{_parse(t){if(t.data!==this._def.value){let r=this._getOrReturnCtx(t);return R(r,{received:r.data,code:A.invalid_literal,expected:this._def.value}),W}return{status:"valid",value:t.data}}get value(){return this._def.value}};Li.create=(e,t)=>new Li({value:e,typeName:I.ZodLiteral,...X(t)});function nC(e,t){return new Bi({values:e,typeName:I.ZodEnum,...X(t)})}var Bi=class e extends ie{_parse(t){if(typeof t.data!="string"){let r=this._getOrReturnCtx(t),a=this._def.values;return R(r,{expected:ce.joinValues(a),received:r.parsedType,code:A.invalid_type}),W}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(t.data)){let r=this._getOrReturnCtx(t),a=this._def.values;return R(r,{received:r.data,code:A.invalid_enum_value,options:a}),W}return gt(t.data)}get options(){return this._def.values}get enum(){let t={};for(let r of this._def.values)t[r]=r;return t}get Values(){let t={};for(let r of this._def.values)t[r]=r;return t}get Enum(){let t={};for(let r of this._def.values)t[r]=r;return t}extract(t,r=this._def){return e.create(t,{...this._def,...r})}exclude(t,r=this._def){return e.create(this.options.filter(a=>!t.includes(a)),{...this._def,...r})}};Bi.create=nC;var Ui=class extends ie{_parse(t){let r=ce.getValidEnumValues(this._def.values),a=this._getOrReturnCtx(t);if(a.parsedType!==N.string&&a.parsedType!==N.number){let n=ce.objectValues(r);return R(a,{expected:ce.joinValues(n),received:a.parsedType,code:A.invalid_type}),W}if(this._cache||(this._cache=new Set(ce.getValidEnumValues(this._def.values))),!this._cache.has(t.data)){let n=ce.objectValues(r);return R(a,{received:a.data,code:A.invalid_enum_value,options:n}),W}return gt(t.data)}get enum(){return this._def.values}};Ui.create=(e,t)=>new Ui({values:e,typeName:I.ZodNativeEnum,...X(t)});var ra=class extends ie{unwrap(){return this._def.type}_parse(t){let{ctx:r}=this._processInputParams(t);if(r.parsedType!==N.promise&&r.common.async===!1)return R(r,{code:A.invalid_type,expected:N.promise,received:r.parsedType}),W;let a=r.parsedType===N.promise?r.data:Promise.resolve(r.data);return gt(a.then(n=>this._def.type.parseAsync(n,{path:r.path,errorMap:r.common.contextualErrorMap})))}};ra.create=(e,t)=>new ra({type:e,typeName:I.ZodPromise,...X(t)});var Yt=class extends ie{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===I.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(t){let{status:r,ctx:a}=this._processInputParams(t),n=this._def.effect||null,i={addIssue:o=>{R(a,o),o.fatal?r.abort():r.dirty()},get path(){return a.path}};if(i.addIssue=i.addIssue.bind(i),n.type==="preprocess"){let o=n.transform(a.data,i);if(a.common.async)return Promise.resolve(o).then(async s=>{if(r.value==="aborted")return W;let l=await this._def.schema._parseAsync({data:s,path:a.path,parent:a});return l.status==="aborted"?W:l.status==="dirty"?Pi(l.value):r.value==="dirty"?Pi(l.value):l});{if(r.value==="aborted")return W;let s=this._def.schema._parseSync({data:o,path:a.path,parent:a});return s.status==="aborted"?W:s.status==="dirty"?Pi(s.value):r.value==="dirty"?Pi(s.value):s}}if(n.type==="refinement"){let o=s=>{let l=n.refinement(s,i);if(a.common.async)return Promise.resolve(l);if(l instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return s};if(a.common.async===!1){let s=this._def.schema._parseSync({data:a.data,path:a.path,parent:a});return s.status==="aborted"?W:(s.status==="dirty"&&r.dirty(),o(s.value),{status:r.value,value:s.value})}else return this._def.schema._parseAsync({data:a.data,path:a.path,parent:a}).then(s=>s.status==="aborted"?W:(s.status==="dirty"&&r.dirty(),o(s.value).then(()=>({status:r.value,value:s.value}))))}if(n.type==="transform")if(a.common.async===!1){let o=this._def.schema._parseSync({data:a.data,path:a.path,parent:a});if(!na(o))return W;let s=n.transform(o.value,i);if(s instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:r.value,value:s}}else return this._def.schema._parseAsync({data:a.data,path:a.path,parent:a}).then(o=>na(o)?Promise.resolve(n.transform(o.value,i)).then(s=>({status:r.value,value:s})):W);ce.assertNever(n)}};Yt.create=(e,t,r)=>new Yt({schema:e,typeName:I.ZodEffects,effect:t,...X(r)});Yt.createWithPreprocess=(e,t,r)=>new Yt({schema:t,effect:{type:"preprocess",transform:e},typeName:I.ZodEffects,...X(r)});var Jt=class extends ie{_parse(t){return this._getType(t)===N.undefined?gt(void 0):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}};Jt.create=(e,t)=>new Jt({innerType:e,typeName:I.ZodOptional,...X(t)});var Vn=class extends ie{_parse(t){return this._getType(t)===N.null?gt(null):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}};Vn.create=(e,t)=>new Vn({innerType:e,typeName:I.ZodNullable,...X(t)});var Fi=class extends ie{_parse(t){let{ctx:r}=this._processInputParams(t),a=r.data;return r.parsedType===N.undefined&&(a=this._def.defaultValue()),this._def.innerType._parse({data:a,path:r.path,parent:r})}removeDefault(){return this._def.innerType}};Fi.create=(e,t)=>new Fi({innerType:e,typeName:I.ZodDefault,defaultValue:typeof t.default=="function"?t.default:()=>t.default,...X(t)});var qi=class extends ie{_parse(t){let{ctx:r}=this._processInputParams(t),a={...r,common:{...r.common,issues:[]}},n=this._def.innerType._parse({data:a.data,path:a.path,parent:{...a}});return tl(n)?n.then(i=>({status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new jt(a.common.issues)},input:a.data})})):{status:"valid",value:n.status==="valid"?n.value:this._def.catchValue({get error(){return new jt(a.common.issues)},input:a.data})}}removeCatch(){return this._def.innerType}};qi.create=(e,t)=>new qi({innerType:e,typeName:I.ZodCatch,catchValue:typeof t.catch=="function"?t.catch:()=>t.catch,...X(t)});var dl=class extends ie{_parse(t){if(this._getType(t)!==N.nan){let a=this._getOrReturnCtx(t);return R(a,{code:A.invalid_type,expected:N.nan,received:a.parsedType}),W}return{status:"valid",value:t.data}}};dl.create=e=>new dl({typeName:I.ZodNaN,...X(e)});var am=class extends ie{_parse(t){let{ctx:r}=this._processInputParams(t),a=r.data;return this._def.type._parse({data:a,path:r.path,parent:r})}unwrap(){return this._def.type}},im=class e extends ie{_parse(t){let{status:r,ctx:a}=this._processInputParams(t);if(a.common.async)return(async()=>{let i=await this._def.in._parseAsync({data:a.data,path:a.path,parent:a});return i.status==="aborted"?W:i.status==="dirty"?(r.dirty(),Pi(i.value)):this._def.out._parseAsync({data:i.value,path:a.path,parent:a})})();{let n=this._def.in._parseSync({data:a.data,path:a.path,parent:a});return n.status==="aborted"?W:n.status==="dirty"?(r.dirty(),{status:"dirty",value:n.value}):this._def.out._parseSync({data:n.value,path:a.path,parent:a})}}static create(t,r){return new e({in:t,out:r,typeName:I.ZodPipeline})}},Hi=class extends ie{_parse(t){let r=this._def.innerType._parse(t),a=n=>(na(n)&&(n.value=Object.freeze(n.value)),n);return tl(r)?r.then(n=>a(n)):a(r)}unwrap(){return this._def.innerType}};Hi.create=(e,t)=>new Hi({innerType:e,typeName:I.ZodReadonly,...X(t)});var oZ={object:Ot.lazycreate},I;(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"})(I||(I={}));var sZ=$i.create,lZ=nl.create,cZ=dl.create,uZ=rl.create,dZ=al.create,pZ=il.create,mZ=ol.create,gZ=ji.create,hZ=Oi.create,fZ=sl.create,bZ=br.create,vZ=fn.create,yZ=ll.create,kZ=vr.create,rC=Ot.create,_Z=Ot.strictCreate,wZ=Ni.create,SZ=sy.create,EZ=Di.create,xZ=Gn.create,TZ=cy.create,AZ=cl.create,CZ=ul.create,zZ=uy.create,IZ=Mi.create,PZ=Li.create,RZ=Bi.create,$Z=Ui.create,jZ=ra.create,OZ=Yt.create,NZ=Jt.create,DZ=Vn.create,MZ=Yt.createWithPreprocess,LZ=im.create;var RM=y("ZodMiniType",(e,t)=>{if(!e._zod)throw new Error("Uninitialized schema in ZodMiniType.");Z.init(e,t),e.def=t,e.type=t.type},{get with(){return this.check},set with(e){sn(this,"with",e)},parse(e,t){return jr(this,e,t,{callee:this.parse})},parseAsync(e,t){return Or(this,e,t,{callee:this.parseAsync})},safeParse(e,t){return za(this,e,t)},safeParseAsync(e,t){return Pa(this,e,t)},check(...e){let t=this.def;return this.clone({...t,checks:[...t.checks??[],...e.map(r=>typeof r=="function"?{_zod:{check:r,def:{check:"custom"},onattach:[]}}:r)]},{parent:!0})},clone(e,t){return ge(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},apply(e,...t){return t.length===0?e(this):e(this,...t)}});var $M=y("ZodMiniObject",(e,t)=>{ru.init(e,t),RM.init(e,t),mg(e,"shape",r=>r._zod.def.shape,!1)});function dy(e,t){let r={type:"object",shape:e??{},...z(t)};return new $M(r)}function bn(e){return!!e._zod}function aa(e){let t=Object.values(e);if(t.length===0)return dy({});let r=t.every(bn),a=t.every(n=>!bn(n));if(r)return dy(e);if(a)return rC(e);throw new Error("Mixed Zod versions detected in object shape.")}function yr(e,t){return bn(e)?za(e,t):e.safeParse(t)}async function om(e,t){return bn(e)?await Pa(e,t):await e.safeParseAsync(t)}function kr(e){if(!e)return;let t;if(bn(e)?t=e._zod?.def?.shape:t=e.shape,!!t){if(typeof t=="function")try{return t()}catch{return}return t}}function Gi(e){if(e){if(typeof e=="object"){let t=e,r=e;if(!t._def&&!r._zod){let a=Object.values(e);if(a.length>0&&a.every(n=>typeof n=="object"&&n!==null&&(n._def!==void 0||n._zod!==void 0||typeof n.parse=="function")))return aa(e)}}if(bn(e)){let r=e._zod?.def;if(r&&(r.type==="object"||r.shape!==void 0))return e}else if(e.shape!==void 0)return e}}function OM(e){return e.length===0?"object root":e.reduce((t,r,a)=>a===0?String(r):typeof r=="number"?`${t}[${r}]`:`${t}.${r}`,"")}function sm(e){if(e&&typeof e=="object"){if("issues"in e&&Array.isArray(e.issues)&&e.issues.length>0)return e.issues.map(t=>t.path?.length?`${t.message} at ${OM(t.path)}`:t.message).join(`
|
|
3559
|
-
`);if("message"in e&&typeof e.message=="string")return e.message;try{return JSON.stringify(e)}catch{return String(e)}}return String(e)}function aC(e){return e.description}function iC(e){if(bn(e))return e._zod?.def?.type==="optional";let t=e;return typeof e.isOptional=="function"?e.isOptional():t._def?.typeName==="ZodOptional"}function Vi(e){if(bn(e)){let i=e._zod?.def;if(i){if(i.value!==void 0)return i.value;if(Array.isArray(i.values)&&i.values.length>0)return i.values[0]}}let r=e._def;if(r){if(r.value!==void 0)return r.value;if(Array.isArray(r.values)&&r.values.length>0)return r.values[0]}let a=e.value;if(a!==void 0)return a}function _r(e){return e==="completed"||e==="failed"||e==="cancelled"}var sC=Symbol("Let zodToJsonSchema decide on which parser to use");var oC={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"},lC=e=>typeof e=="string"?{...oC,name:e}:{...oC,...e};var cC=e=>{let t=lC(e),r=t.name!==void 0?[...t.basePath,t.definitionPath,t.name]:t.basePath;return{...t,flags:{hasReferencedOpenAiAnyType:!1},currentPath:r,propertyPath:void 0,seen:new Map(Object.entries(t.definitions).map(([a,n])=>[n._def,{def:n._def,path:[...t.basePath,t.definitionPath,a],jsonSchema:void 0}]))}};function py(e,t,r,a){a?.errorMessages&&r&&(e.errorMessage={...e.errorMessage,[t]:r})}function ue(e,t,r,a,n){e[t]=r,py(e,t,a,n)}var lm=(e,t)=>{let r=0;for(;r<e.length&&r<t.length&&e[r]===t[r];r++);return[(e.length-r).toString(),...t.slice(r)].join("/")};function je(e){if(e.target!=="openAi")return{};let t=[...e.basePath,e.definitionPath,e.openAiAnyTypeName];return e.flags.hasReferencedOpenAiAnyType=!0,{$ref:e.$refStrategy==="relative"?lm(t,e.currentPath):t.join("/")}}function uC(e,t){let r={type:"array"};return e.type?._def&&e.type?._def?.typeName!==I.ZodAny&&(r.items=K(e.type._def,{...t,currentPath:[...t.currentPath,"items"]})),e.minLength&&ue(r,"minItems",e.minLength.value,e.minLength.message,t),e.maxLength&&ue(r,"maxItems",e.maxLength.value,e.maxLength.message,t),e.exactLength&&(ue(r,"minItems",e.exactLength.value,e.exactLength.message,t),ue(r,"maxItems",e.exactLength.value,e.exactLength.message,t)),r}function dC(e,t){let r={type:"integer",format:"int64"};if(!e.checks)return r;for(let a of e.checks)switch(a.kind){case"min":t.target==="jsonSchema7"?a.inclusive?ue(r,"minimum",a.value,a.message,t):ue(r,"exclusiveMinimum",a.value,a.message,t):(a.inclusive||(r.exclusiveMinimum=!0),ue(r,"minimum",a.value,a.message,t));break;case"max":t.target==="jsonSchema7"?a.inclusive?ue(r,"maximum",a.value,a.message,t):ue(r,"exclusiveMaximum",a.value,a.message,t):(a.inclusive||(r.exclusiveMaximum=!0),ue(r,"maximum",a.value,a.message,t));break;case"multipleOf":ue(r,"multipleOf",a.value,a.message,t);break}return r}function pC(){return{type:"boolean"}}function cm(e,t){return K(e.type._def,t)}var mC=(e,t)=>K(e.innerType._def,t);function my(e,t,r){let a=r??t.dateStrategy;if(Array.isArray(a))return{anyOf:a.map((n,i)=>my(e,t,n))};switch(a){case"string":case"format:date-time":return{type:"string",format:"date-time"};case"format:date":return{type:"string",format:"date"};case"integer":return NM(e,t)}}var NM=(e,t)=>{let r={type:"integer",format:"unix-time"};if(t.target==="openApi3")return r;for(let a of e.checks)switch(a.kind){case"min":ue(r,"minimum",a.value,a.message,t);break;case"max":ue(r,"maximum",a.value,a.message,t);break}return r};function gC(e,t){return{...K(e.innerType._def,t),default:e.defaultValue()}}function hC(e,t){return t.effectStrategy==="input"?K(e.schema._def,t):je(t)}function fC(e){return{type:"string",enum:Array.from(e.values)}}var DM=e=>"type"in e&&e.type==="string"?!1:"allOf"in e;function bC(e,t){let r=[K(e.left._def,{...t,currentPath:[...t.currentPath,"allOf","0"]}),K(e.right._def,{...t,currentPath:[...t.currentPath,"allOf","1"]})].filter(i=>!!i),a=t.target==="jsonSchema2019-09"?{unevaluatedProperties:!1}:void 0,n=[];return r.forEach(i=>{if(DM(i))n.push(...i.allOf),i.unevaluatedProperties===void 0&&(a=void 0);else{let o=i;if("additionalProperties"in i&&i.additionalProperties===!1){let{additionalProperties:s,...l}=i;o=l}else a=void 0;n.push(o)}}),n.length?{allOf:n,...a}:void 0}function vC(e,t){let r=typeof e.value;return r!=="bigint"&&r!=="number"&&r!=="boolean"&&r!=="string"?{type:Array.isArray(e.value)?"array":"object"}:t.target==="openApi3"?{type:r==="bigint"?"integer":r,enum:[e.value]}:{type:r==="bigint"?"integer":r,const:e.value}}var gy,Xt={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:()=>(gy===void 0&&(gy=RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),gy),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 um(e,t){let r={type:"string"};if(e.checks)for(let a of e.checks)switch(a.kind){case"min":ue(r,"minLength",typeof r.minLength=="number"?Math.max(r.minLength,a.value):a.value,a.message,t);break;case"max":ue(r,"maxLength",typeof r.maxLength=="number"?Math.min(r.maxLength,a.value):a.value,a.message,t);break;case"email":switch(t.emailStrategy){case"format:email":Qt(r,"email",a.message,t);break;case"format:idn-email":Qt(r,"idn-email",a.message,t);break;case"pattern:zod":ht(r,Xt.email,a.message,t);break}break;case"url":Qt(r,"uri",a.message,t);break;case"uuid":Qt(r,"uuid",a.message,t);break;case"regex":ht(r,a.regex,a.message,t);break;case"cuid":ht(r,Xt.cuid,a.message,t);break;case"cuid2":ht(r,Xt.cuid2,a.message,t);break;case"startsWith":ht(r,RegExp(`^${hy(a.value,t)}`),a.message,t);break;case"endsWith":ht(r,RegExp(`${hy(a.value,t)}$`),a.message,t);break;case"datetime":Qt(r,"date-time",a.message,t);break;case"date":Qt(r,"date",a.message,t);break;case"time":Qt(r,"time",a.message,t);break;case"duration":Qt(r,"duration",a.message,t);break;case"length":ue(r,"minLength",typeof r.minLength=="number"?Math.max(r.minLength,a.value):a.value,a.message,t),ue(r,"maxLength",typeof r.maxLength=="number"?Math.min(r.maxLength,a.value):a.value,a.message,t);break;case"includes":{ht(r,RegExp(hy(a.value,t)),a.message,t);break}case"ip":{a.version!=="v6"&&Qt(r,"ipv4",a.message,t),a.version!=="v4"&&Qt(r,"ipv6",a.message,t);break}case"base64url":ht(r,Xt.base64url,a.message,t);break;case"jwt":ht(r,Xt.jwt,a.message,t);break;case"cidr":{a.version!=="v6"&&ht(r,Xt.ipv4Cidr,a.message,t),a.version!=="v4"&&ht(r,Xt.ipv6Cidr,a.message,t);break}case"emoji":ht(r,Xt.emoji(),a.message,t);break;case"ulid":{ht(r,Xt.ulid,a.message,t);break}case"base64":{switch(t.base64Strategy){case"format:binary":{Qt(r,"binary",a.message,t);break}case"contentEncoding:base64":{ue(r,"contentEncoding","base64",a.message,t);break}case"pattern:zod":{ht(r,Xt.base64,a.message,t);break}}break}case"nanoid":ht(r,Xt.nanoid,a.message,t);case"toLowerCase":case"toUpperCase":case"trim":break;default:}return r}function hy(e,t){return t.patternStrategy==="escape"?LM(e):e}var MM=new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");function LM(e){let t="";for(let r=0;r<e.length;r++)MM.has(e[r])||(t+="\\"),t+=e[r];return t}function Qt(e,t,r,a){e.format||e.anyOf?.some(n=>n.format)?(e.anyOf||(e.anyOf=[]),e.format&&(e.anyOf.push({format:e.format,...e.errorMessage&&a.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,...r&&a.errorMessages&&{errorMessage:{format:r}}})):ue(e,"format",t,r,a)}function ht(e,t,r,a){e.pattern||e.allOf?.some(n=>n.pattern)?(e.allOf||(e.allOf=[]),e.pattern&&(e.allOf.push({pattern:e.pattern,...e.errorMessage&&a.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:yC(t,a),...r&&a.errorMessages&&{errorMessage:{pattern:r}}})):ue(e,"pattern",yC(t,a),r,a)}function yC(e,t){if(!t.applyRegexFlags||!e.flags)return e.source;let r={i:e.flags.includes("i"),m:e.flags.includes("m"),s:e.flags.includes("s")},a=r.i?e.source.toLowerCase():e.source,n="",i=!1,o=!1,s=!1;for(let l=0;l<a.length;l++){if(i){n+=a[l],i=!1;continue}if(r.i){if(o){if(a[l].match(/[a-z]/)){s?(n+=a[l],n+=`${a[l-2]}-${a[l]}`.toUpperCase(),s=!1):a[l+1]==="-"&&a[l+2]?.match(/[a-z]/)?(n+=a[l],s=!0):n+=`${a[l]}${a[l].toUpperCase()}`;continue}}else if(a[l].match(/[a-z]/)){n+=`[${a[l]}${a[l].toUpperCase()}]`;continue}}if(r.m){if(a[l]==="^"){n+=`(^|(?<=[\r
|
|
3558
|
+
</script></body></html>`;import{execFile as hq}from"node:child_process";import{createHash as fq,randomUUID as bq}from"node:crypto";var ce;(function(e){e.assertEqual=n=>{};function t(n){}e.assertIs=t;function r(n){throw new Error}e.assertNever=r,e.arrayToEnum=n=>{let i={};for(let o of n)i[o]=o;return i},e.getValidEnumValues=n=>{let i=e.objectKeys(n).filter(s=>typeof n[n[s]]!="number"),o={};for(let s of i)o[s]=n[s];return e.objectValues(o)},e.objectValues=n=>e.objectKeys(n).map(function(i){return n[i]}),e.objectKeys=typeof Object.keys=="function"?n=>Object.keys(n):n=>{let i=[];for(let o in n)Object.prototype.hasOwnProperty.call(n,o)&&i.push(o);return i},e.find=(n,i)=>{for(let o of n)if(i(o))return o},e.isInteger=typeof Number.isInteger=="function"?n=>Number.isInteger(n):n=>typeof n=="number"&&Number.isFinite(n)&&Math.floor(n)===n;function a(n,i=" | "){return n.map(o=>typeof o=="string"?`'${o}'`:o).join(i)}e.joinValues=a,e.jsonStringifyReplacer=(n,i)=>typeof i=="bigint"?i.toString():i})(ce||(ce={}));var XA;(function(e){e.mergeShapes=(t,r)=>({...t,...r})})(XA||(XA={}));var N=ce.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),qn=e=>{switch(typeof e){case"undefined":return N.undefined;case"string":return N.string;case"number":return Number.isNaN(e)?N.nan:N.number;case"boolean":return N.boolean;case"function":return N.function;case"bigint":return N.bigint;case"symbol":return N.symbol;case"object":return Array.isArray(e)?N.array:e===null?N.null:e.then&&typeof e.then=="function"&&e.catch&&typeof e.catch=="function"?N.promise:typeof Map<"u"&&e instanceof Map?N.map:typeof Set<"u"&&e instanceof Set?N.set:typeof Date<"u"&&e instanceof Date?N.date:N.object;default:return N.unknown}};var A=ce.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 jt=class e extends Error{get errors(){return this.issues}constructor(t){super(),this.issues=[],this.addIssue=a=>{this.issues=[...this.issues,a]},this.addIssues=(a=[])=>{this.issues=[...this.issues,...a]};let r=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,r):this.__proto__=r,this.name="ZodError",this.issues=t}format(t){let r=t||function(i){return i.message},a={_errors:[]},n=i=>{for(let o of i.issues)if(o.code==="invalid_union")o.unionErrors.map(n);else if(o.code==="invalid_return_type")n(o.returnTypeError);else if(o.code==="invalid_arguments")n(o.argumentsError);else if(o.path.length===0)a._errors.push(r(o));else{let s=a,l=0;for(;l<o.path.length;){let c=o.path[l],u=l===o.path.length-1;if(c==="_errors"){u&&s._errors.push(r(o)),l++;continue}Object.prototype.hasOwnProperty.call(s,c)||(c==="__proto__"?Object.defineProperty(s,c,{value:{_errors:[]},writable:!0,enumerable:!0,configurable:!0}):s[c]={_errors:[]}),s=s[c],u&&s._errors.push(r(o)),l++}}};return n(this),a}static assert(t){if(!(t instanceof e))throw new Error(`Not a ZodError: ${t}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,ce.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(t=r=>r.message){let r=Object.create(null),a=[];for(let n of this.issues)if(n.path.length>0){let i=n.path[0];r[i]=r[i]||[],r[i].push(t(n))}else a.push(t(n));return{formErrors:a,fieldErrors:r}}get formErrors(){return this.flatten()}};jt.create=e=>new jt(e);var cM=(e,t)=>{let r;switch(e.code){case A.invalid_type:e.received===N.undefined?r="Required":r=`Expected ${e.expected}, received ${e.received}`;break;case A.invalid_literal:r=`Invalid literal value, expected ${JSON.stringify(e.expected,ce.jsonStringifyReplacer)}`;break;case A.unrecognized_keys:r=`Unrecognized key(s) in object: ${ce.joinValues(e.keys,", ")}`;break;case A.invalid_union:r="Invalid input";break;case A.invalid_union_discriminator:r=`Invalid discriminator value. Expected ${ce.joinValues(e.options)}`;break;case A.invalid_enum_value:r=`Invalid enum value. Expected ${ce.joinValues(e.options)}, received '${e.received}'`;break;case A.invalid_arguments:r="Invalid function arguments";break;case A.invalid_return_type:r="Invalid function return type";break;case A.invalid_date:r="Invalid date";break;case A.invalid_string:typeof e.validation=="object"?"includes"in e.validation?(r=`Invalid input: must include "${e.validation.includes}"`,typeof e.validation.position=="number"&&(r=`${r} at one or more positions greater than or equal to ${e.validation.position}`)):"startsWith"in e.validation?r=`Invalid input: must start with "${e.validation.startsWith}"`:"endsWith"in e.validation?r=`Invalid input: must end with "${e.validation.endsWith}"`:ce.assertNever(e.validation):e.validation!=="regex"?r=`Invalid ${e.validation}`:r="Invalid";break;case A.too_small:e.type==="array"?r=`Array must contain ${e.exact?"exactly":e.inclusive?"at least":"more than"} ${e.minimum} element(s)`:e.type==="string"?r=`String must contain ${e.exact?"exactly":e.inclusive?"at least":"over"} ${e.minimum} character(s)`:e.type==="number"?r=`Number must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${e.minimum}`:e.type==="bigint"?r=`Number must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${e.minimum}`:e.type==="date"?r=`Date must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(e.minimum))}`:r="Invalid input";break;case A.too_big:e.type==="array"?r=`Array must contain ${e.exact?"exactly":e.inclusive?"at most":"less than"} ${e.maximum} element(s)`:e.type==="string"?r=`String must contain ${e.exact?"exactly":e.inclusive?"at most":"under"} ${e.maximum} character(s)`:e.type==="number"?r=`Number must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:e.type==="bigint"?r=`BigInt must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:e.type==="date"?r=`Date must be ${e.exact?"exactly":e.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(e.maximum))}`:r="Invalid input";break;case A.custom:r="Invalid input";break;case A.invalid_intersection_types:r="Intersection results could not be merged";break;case A.not_multiple_of:r=`Number must be a multiple of ${e.multipleOf}`;break;case A.not_finite:r="Number must be finite";break;default:r=t.defaultError,ce.assertNever(e)}return{message:r}},fr=cM;var uM=fr;function el(){return uM}var rm=e=>{let{data:t,path:r,errorMaps:a,issueData:n}=e,i=[...r,...n.path||[]],o={...n,path:i};if(n.message!==void 0)return{...n,path:i,message:n.message};let s="",l=a.filter(c=>!!c).slice().reverse();for(let c of l)s=c(o,{data:t,defaultError:s}).message;return{...n,path:i,message:s}};function R(e,t){let r=el(),a=rm({issueData:t,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,r,r===fr?void 0:fr].filter(n=>!!n)});e.common.issues.push(a)}var rt=class e{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(t,r){let a=[];for(let n of r){if(n.status==="aborted")return W;n.status==="dirty"&&t.dirty(),a.push(n.value)}return{status:t.value,value:a}}static async mergeObjectAsync(t,r){let a=[];for(let n of r){let i=await n.key,o=await n.value;a.push({key:i,value:o})}return e.mergeObjectSync(t,a)}static mergeObjectSync(t,r){let a={};for(let n of r){let{key:i,value:o}=n;if(i.status==="aborted"||o.status==="aborted")return W;i.status==="dirty"&&t.dirty(),o.status==="dirty"&&t.dirty(),i.value!=="__proto__"&&(typeof o.value<"u"||n.alwaysSet)&&(a[i.value]=o.value)}return{status:t.value,value:a}}},W=Object.freeze({status:"aborted"}),Pi=e=>({status:"dirty",value:e}),gt=e=>({status:"valid",value:e}),ay=e=>e.status==="aborted",iy=e=>e.status==="dirty",na=e=>e.status==="valid",tl=e=>typeof Promise<"u"&&e instanceof Promise;var L;(function(e){e.errToObj=t=>typeof t=="string"?{message:t}:t||{},e.toString=t=>typeof t=="string"?t:t?.message})(L||(L={}));var Ut=class{constructor(t,r,a,n){this._cachedPath=[],this.parent=t,this.data=r,this._path=a,this._key=n}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}},QA=(e,t)=>{if(na(t))return{success:!0,data:t.value};if(!e.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;let r=new jt(e.common.issues);return this._error=r,this._error}}};function X(e){if(!e)return{};let{errorMap:t,invalid_type_error:r,required_error:a,description:n}=e;if(t&&(r||a))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return t?{errorMap:t,description:n}:{errorMap:(o,s)=>{let{message:l}=e;return o.code==="invalid_enum_value"?{message:l??s.defaultError}:typeof s.data>"u"?{message:l??a??s.defaultError}:o.code!=="invalid_type"?{message:s.defaultError}:{message:l??r??s.defaultError}},description:n}}var ie=class{get description(){return this._def.description}_getType(t){return qn(t.data)}_getOrReturnCtx(t,r){return r||{common:t.parent.common,data:t.data,parsedType:qn(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}_processInputParams(t){return{status:new rt,ctx:{common:t.parent.common,data:t.data,parsedType:qn(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}}_parseSync(t){let r=this._parse(t);if(tl(r))throw new Error("Synchronous parse encountered promise.");return r}_parseAsync(t){let r=this._parse(t);return Promise.resolve(r)}parse(t,r){let a=this.safeParse(t,r);if(a.success)return a.data;throw a.error}safeParse(t,r){let a={common:{issues:[],async:r?.async??!1,contextualErrorMap:r?.errorMap},path:r?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:qn(t)},n=this._parseSync({data:t,path:a.path,parent:a});return QA(a,n)}"~validate"(t){let r={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:qn(t)};if(!this["~standard"].async)try{let a=this._parseSync({data:t,path:[],parent:r});return na(a)?{value:a.value}:{issues:r.common.issues}}catch(a){a?.message?.toLowerCase()?.includes("encountered")&&(this["~standard"].async=!0),r.common={issues:[],async:!0}}return this._parseAsync({data:t,path:[],parent:r}).then(a=>na(a)?{value:a.value}:{issues:r.common.issues})}async parseAsync(t,r){let a=await this.safeParseAsync(t,r);if(a.success)return a.data;throw a.error}async safeParseAsync(t,r){let a={common:{issues:[],contextualErrorMap:r?.errorMap,async:!0},path:r?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:qn(t)},n=this._parse({data:t,path:a.path,parent:a}),i=await(tl(n)?n:Promise.resolve(n));return QA(a,i)}refine(t,r){let a=n=>typeof r=="string"||typeof r>"u"?{message:r}:typeof r=="function"?r(n):r;return this._refinement((n,i)=>{let o=t(n),s=()=>i.addIssue({code:A.custom,...a(n)});return typeof Promise<"u"&&o instanceof Promise?o.then(l=>l?!0:(s(),!1)):o?!0:(s(),!1)})}refinement(t,r){return this._refinement((a,n)=>t(a)?!0:(n.addIssue(typeof r=="function"?r(a,n):r),!1))}_refinement(t){return new Yt({schema:this,typeName:I.ZodEffects,effect:{type:"refinement",refinement:t}})}superRefine(t){return this._refinement(t)}constructor(t){this.spa=this.safeParseAsync,this._def=t,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:r=>this["~validate"](r)}}optional(){return Jt.create(this,this._def)}nullable(){return Vn.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return vr.create(this)}promise(){return ra.create(this,this._def)}or(t){return Ni.create([this,t],this._def)}and(t){return Di.create(this,t,this._def)}transform(t){return new Yt({...X(this._def),schema:this,typeName:I.ZodEffects,effect:{type:"transform",transform:t}})}default(t){let r=typeof t=="function"?t:()=>t;return new Fi({...X(this._def),innerType:this,defaultValue:r,typeName:I.ZodDefault})}brand(){return new am({typeName:I.ZodBranded,type:this,...X(this._def)})}catch(t){let r=typeof t=="function"?t:()=>t;return new qi({...X(this._def),innerType:this,catchValue:r,typeName:I.ZodCatch})}describe(t){let r=this.constructor;return new r({...this._def,description:t})}pipe(t){return im.create(this,t)}readonly(){return Hi.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},dM=/^c[^\s-]{8,}$/i,pM=/^[0-9a-z]+$/,mM=/^[0-9A-HJKMNP-TV-Z]{26}$/i,gM=/^[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,hM=/^[a-z0-9_-]{21}$/i,fM=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,bM=/^[-+]?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)?)??$/,vM=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,yM="^[\\p{Extended_Pictographic}\\p{Emoji_Component}]+$",oy,kM=/^(?:(?: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])$/,_M=/^(?:(?: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])$/,wM=/^(([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]))$/,SM=/^(([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])$/,EM=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,xM=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,eC="((\\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])))",TM=new RegExp(`^${eC}$`);function tC(e){let t="[0-5]\\d";e.precision?t=`${t}\\.\\d{${e.precision}}`:e.precision==null&&(t=`${t}(\\.\\d+)?`);let r=e.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${t})${r}`}function AM(e){return new RegExp(`^${tC(e)}$`)}function CM(e){let t=`${eC}T${tC(e)}`,r=[];return r.push(e.local?"Z?":"Z"),e.offset&&r.push("([+-]\\d{2}:?\\d{2})"),t=`${t}(${r.join("|")})`,new RegExp(`^${t}$`)}function zM(e,t){return!!((t==="v4"||!t)&&kM.test(e)||(t==="v6"||!t)&&wM.test(e))}function IM(e,t){if(!fM.test(e))return!1;try{let[r]=e.split(".");if(!r)return!1;let a=r.replace(/-/g,"+").replace(/_/g,"/").padEnd(r.length+(4-r.length%4)%4,"="),n=JSON.parse(atob(a));return!(typeof n!="object"||n===null||"typ"in n&&n?.typ!=="JWT"||!n.alg||t&&n.alg!==t)}catch{return!1}}function PM(e,t){return!!((t==="v4"||!t)&&_M.test(e)||(t==="v6"||!t)&&SM.test(e))}var $i=class e extends ie{_parse(t){if(this._def.coerce&&(t.data=String(t.data)),this._getType(t)!==N.string){let i=this._getOrReturnCtx(t);return R(i,{code:A.invalid_type,expected:N.string,received:i.parsedType}),W}let a=new rt,n;for(let i of this._def.checks)if(i.kind==="min")t.data.length<i.value&&(n=this._getOrReturnCtx(t,n),R(n,{code:A.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),a.dirty());else if(i.kind==="max")t.data.length>i.value&&(n=this._getOrReturnCtx(t,n),R(n,{code:A.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),a.dirty());else if(i.kind==="length"){let o=t.data.length>i.value,s=t.data.length<i.value;(o||s)&&(n=this._getOrReturnCtx(t,n),o?R(n,{code:A.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}):s&&R(n,{code:A.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}),a.dirty())}else if(i.kind==="email")vM.test(t.data)||(n=this._getOrReturnCtx(t,n),R(n,{validation:"email",code:A.invalid_string,message:i.message}),a.dirty());else if(i.kind==="emoji")oy||(oy=new RegExp(yM,"u")),oy.test(t.data)||(n=this._getOrReturnCtx(t,n),R(n,{validation:"emoji",code:A.invalid_string,message:i.message}),a.dirty());else if(i.kind==="uuid")gM.test(t.data)||(n=this._getOrReturnCtx(t,n),R(n,{validation:"uuid",code:A.invalid_string,message:i.message}),a.dirty());else if(i.kind==="nanoid")hM.test(t.data)||(n=this._getOrReturnCtx(t,n),R(n,{validation:"nanoid",code:A.invalid_string,message:i.message}),a.dirty());else if(i.kind==="cuid")dM.test(t.data)||(n=this._getOrReturnCtx(t,n),R(n,{validation:"cuid",code:A.invalid_string,message:i.message}),a.dirty());else if(i.kind==="cuid2")pM.test(t.data)||(n=this._getOrReturnCtx(t,n),R(n,{validation:"cuid2",code:A.invalid_string,message:i.message}),a.dirty());else if(i.kind==="ulid")mM.test(t.data)||(n=this._getOrReturnCtx(t,n),R(n,{validation:"ulid",code:A.invalid_string,message:i.message}),a.dirty());else if(i.kind==="url")try{new URL(t.data)}catch{n=this._getOrReturnCtx(t,n),R(n,{validation:"url",code:A.invalid_string,message:i.message}),a.dirty()}else i.kind==="regex"?(i.regex.lastIndex=0,i.regex.test(t.data)||(n=this._getOrReturnCtx(t,n),R(n,{validation:"regex",code:A.invalid_string,message:i.message}),a.dirty())):i.kind==="trim"?t.data=t.data.trim():i.kind==="includes"?t.data.includes(i.value,i.position)||(n=this._getOrReturnCtx(t,n),R(n,{code:A.invalid_string,validation:{includes:i.value,position:i.position},message:i.message}),a.dirty()):i.kind==="toLowerCase"?t.data=t.data.toLowerCase():i.kind==="toUpperCase"?t.data=t.data.toUpperCase():i.kind==="startsWith"?t.data.startsWith(i.value)||(n=this._getOrReturnCtx(t,n),R(n,{code:A.invalid_string,validation:{startsWith:i.value},message:i.message}),a.dirty()):i.kind==="endsWith"?t.data.endsWith(i.value)||(n=this._getOrReturnCtx(t,n),R(n,{code:A.invalid_string,validation:{endsWith:i.value},message:i.message}),a.dirty()):i.kind==="datetime"?CM(i).test(t.data)||(n=this._getOrReturnCtx(t,n),R(n,{code:A.invalid_string,validation:"datetime",message:i.message}),a.dirty()):i.kind==="date"?TM.test(t.data)||(n=this._getOrReturnCtx(t,n),R(n,{code:A.invalid_string,validation:"date",message:i.message}),a.dirty()):i.kind==="time"?AM(i).test(t.data)||(n=this._getOrReturnCtx(t,n),R(n,{code:A.invalid_string,validation:"time",message:i.message}),a.dirty()):i.kind==="duration"?bM.test(t.data)||(n=this._getOrReturnCtx(t,n),R(n,{validation:"duration",code:A.invalid_string,message:i.message}),a.dirty()):i.kind==="ip"?zM(t.data,i.version)||(n=this._getOrReturnCtx(t,n),R(n,{validation:"ip",code:A.invalid_string,message:i.message}),a.dirty()):i.kind==="jwt"?IM(t.data,i.alg)||(n=this._getOrReturnCtx(t,n),R(n,{validation:"jwt",code:A.invalid_string,message:i.message}),a.dirty()):i.kind==="cidr"?PM(t.data,i.version)||(n=this._getOrReturnCtx(t,n),R(n,{validation:"cidr",code:A.invalid_string,message:i.message}),a.dirty()):i.kind==="base64"?EM.test(t.data)||(n=this._getOrReturnCtx(t,n),R(n,{validation:"base64",code:A.invalid_string,message:i.message}),a.dirty()):i.kind==="base64url"?xM.test(t.data)||(n=this._getOrReturnCtx(t,n),R(n,{validation:"base64url",code:A.invalid_string,message:i.message}),a.dirty()):ce.assertNever(i);return{status:a.value,value:t.data}}_regex(t,r,a){return this.refinement(n=>t.test(n),{validation:r,code:A.invalid_string,...L.errToObj(a)})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}email(t){return this._addCheck({kind:"email",...L.errToObj(t)})}url(t){return this._addCheck({kind:"url",...L.errToObj(t)})}emoji(t){return this._addCheck({kind:"emoji",...L.errToObj(t)})}uuid(t){return this._addCheck({kind:"uuid",...L.errToObj(t)})}nanoid(t){return this._addCheck({kind:"nanoid",...L.errToObj(t)})}cuid(t){return this._addCheck({kind:"cuid",...L.errToObj(t)})}cuid2(t){return this._addCheck({kind:"cuid2",...L.errToObj(t)})}ulid(t){return this._addCheck({kind:"ulid",...L.errToObj(t)})}base64(t){return this._addCheck({kind:"base64",...L.errToObj(t)})}base64url(t){return this._addCheck({kind:"base64url",...L.errToObj(t)})}jwt(t){return this._addCheck({kind:"jwt",...L.errToObj(t)})}ip(t){return this._addCheck({kind:"ip",...L.errToObj(t)})}cidr(t){return this._addCheck({kind:"cidr",...L.errToObj(t)})}datetime(t){return typeof t=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:t}):this._addCheck({kind:"datetime",precision:typeof t?.precision>"u"?null:t?.precision,offset:t?.offset??!1,local:t?.local??!1,...L.errToObj(t?.message)})}date(t){return this._addCheck({kind:"date",message:t})}time(t){return typeof t=="string"?this._addCheck({kind:"time",precision:null,message:t}):this._addCheck({kind:"time",precision:typeof t?.precision>"u"?null:t?.precision,...L.errToObj(t?.message)})}duration(t){return this._addCheck({kind:"duration",...L.errToObj(t)})}regex(t,r){return this._addCheck({kind:"regex",regex:t,...L.errToObj(r)})}includes(t,r){return this._addCheck({kind:"includes",value:t,position:r?.position,...L.errToObj(r?.message)})}startsWith(t,r){return this._addCheck({kind:"startsWith",value:t,...L.errToObj(r)})}endsWith(t,r){return this._addCheck({kind:"endsWith",value:t,...L.errToObj(r)})}min(t,r){return this._addCheck({kind:"min",value:t,...L.errToObj(r)})}max(t,r){return this._addCheck({kind:"max",value:t,...L.errToObj(r)})}length(t,r){return this._addCheck({kind:"length",value:t,...L.errToObj(r)})}nonempty(t){return this.min(1,L.errToObj(t))}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(t=>t.kind==="datetime")}get isDate(){return!!this._def.checks.find(t=>t.kind==="date")}get isTime(){return!!this._def.checks.find(t=>t.kind==="time")}get isDuration(){return!!this._def.checks.find(t=>t.kind==="duration")}get isEmail(){return!!this._def.checks.find(t=>t.kind==="email")}get isURL(){return!!this._def.checks.find(t=>t.kind==="url")}get isEmoji(){return!!this._def.checks.find(t=>t.kind==="emoji")}get isUUID(){return!!this._def.checks.find(t=>t.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(t=>t.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(t=>t.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(t=>t.kind==="cuid2")}get isULID(){return!!this._def.checks.find(t=>t.kind==="ulid")}get isIP(){return!!this._def.checks.find(t=>t.kind==="ip")}get isCIDR(){return!!this._def.checks.find(t=>t.kind==="cidr")}get isBase64(){return!!this._def.checks.find(t=>t.kind==="base64")}get isBase64url(){return!!this._def.checks.find(t=>t.kind==="base64url")}get minLength(){let t=null;for(let r of this._def.checks)r.kind==="min"&&(t===null||r.value>t)&&(t=r.value);return t}get maxLength(){let t=null;for(let r of this._def.checks)r.kind==="max"&&(t===null||r.value<t)&&(t=r.value);return t}};$i.create=e=>new $i({checks:[],typeName:I.ZodString,coerce:e?.coerce??!1,...X(e)});function RM(e,t){let r=(e.toString().split(".")[1]||"").length,a=(t.toString().split(".")[1]||"").length,n=r>a?r:a,i=Number.parseInt(e.toFixed(n).replace(".","")),o=Number.parseInt(t.toFixed(n).replace(".",""));return i%o/10**n}var nl=class e extends ie{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(t){if(this._def.coerce&&(t.data=Number(t.data)),this._getType(t)!==N.number){let i=this._getOrReturnCtx(t);return R(i,{code:A.invalid_type,expected:N.number,received:i.parsedType}),W}let a,n=new rt;for(let i of this._def.checks)i.kind==="int"?ce.isInteger(t.data)||(a=this._getOrReturnCtx(t,a),R(a,{code:A.invalid_type,expected:"integer",received:"float",message:i.message}),n.dirty()):i.kind==="min"?(i.inclusive?t.data<i.value:t.data<=i.value)&&(a=this._getOrReturnCtx(t,a),R(a,{code:A.too_small,minimum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),n.dirty()):i.kind==="max"?(i.inclusive?t.data>i.value:t.data>=i.value)&&(a=this._getOrReturnCtx(t,a),R(a,{code:A.too_big,maximum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),n.dirty()):i.kind==="multipleOf"?RM(t.data,i.value)!==0&&(a=this._getOrReturnCtx(t,a),R(a,{code:A.not_multiple_of,multipleOf:i.value,message:i.message}),n.dirty()):i.kind==="finite"?Number.isFinite(t.data)||(a=this._getOrReturnCtx(t,a),R(a,{code:A.not_finite,message:i.message}),n.dirty()):ce.assertNever(i);return{status:n.value,value:t.data}}gte(t,r){return this.setLimit("min",t,!0,L.toString(r))}gt(t,r){return this.setLimit("min",t,!1,L.toString(r))}lte(t,r){return this.setLimit("max",t,!0,L.toString(r))}lt(t,r){return this.setLimit("max",t,!1,L.toString(r))}setLimit(t,r,a,n){return new e({...this._def,checks:[...this._def.checks,{kind:t,value:r,inclusive:a,message:L.toString(n)}]})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}int(t){return this._addCheck({kind:"int",message:L.toString(t)})}positive(t){return this._addCheck({kind:"min",value:0,inclusive:!1,message:L.toString(t)})}negative(t){return this._addCheck({kind:"max",value:0,inclusive:!1,message:L.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:0,inclusive:!0,message:L.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:0,inclusive:!0,message:L.toString(t)})}multipleOf(t,r){return this._addCheck({kind:"multipleOf",value:t,message:L.toString(r)})}finite(t){return this._addCheck({kind:"finite",message:L.toString(t)})}safe(t){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:L.toString(t)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:L.toString(t)})}get minValue(){let t=null;for(let r of this._def.checks)r.kind==="min"&&(t===null||r.value>t)&&(t=r.value);return t}get maxValue(){let t=null;for(let r of this._def.checks)r.kind==="max"&&(t===null||r.value<t)&&(t=r.value);return t}get isInt(){return!!this._def.checks.find(t=>t.kind==="int"||t.kind==="multipleOf"&&ce.isInteger(t.value))}get isFinite(){let t=null,r=null;for(let a of this._def.checks){if(a.kind==="finite"||a.kind==="int"||a.kind==="multipleOf")return!0;a.kind==="min"?(r===null||a.value>r)&&(r=a.value):a.kind==="max"&&(t===null||a.value<t)&&(t=a.value)}return Number.isFinite(r)&&Number.isFinite(t)}};nl.create=e=>new nl({checks:[],typeName:I.ZodNumber,coerce:e?.coerce||!1,...X(e)});var rl=class e extends ie{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(t){if(this._def.coerce)try{t.data=BigInt(t.data)}catch{return this._getInvalidInput(t)}if(this._getType(t)!==N.bigint)return this._getInvalidInput(t);let a,n=new rt;for(let i of this._def.checks)i.kind==="min"?(i.inclusive?t.data<i.value:t.data<=i.value)&&(a=this._getOrReturnCtx(t,a),R(a,{code:A.too_small,type:"bigint",minimum:i.value,inclusive:i.inclusive,message:i.message}),n.dirty()):i.kind==="max"?(i.inclusive?t.data>i.value:t.data>=i.value)&&(a=this._getOrReturnCtx(t,a),R(a,{code:A.too_big,type:"bigint",maximum:i.value,inclusive:i.inclusive,message:i.message}),n.dirty()):i.kind==="multipleOf"?t.data%i.value!==BigInt(0)&&(a=this._getOrReturnCtx(t,a),R(a,{code:A.not_multiple_of,multipleOf:i.value,message:i.message}),n.dirty()):ce.assertNever(i);return{status:n.value,value:t.data}}_getInvalidInput(t){let r=this._getOrReturnCtx(t);return R(r,{code:A.invalid_type,expected:N.bigint,received:r.parsedType}),W}gte(t,r){return this.setLimit("min",t,!0,L.toString(r))}gt(t,r){return this.setLimit("min",t,!1,L.toString(r))}lte(t,r){return this.setLimit("max",t,!0,L.toString(r))}lt(t,r){return this.setLimit("max",t,!1,L.toString(r))}setLimit(t,r,a,n){return new e({...this._def,checks:[...this._def.checks,{kind:t,value:r,inclusive:a,message:L.toString(n)}]})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}positive(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:L.toString(t)})}negative(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:L.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:L.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:L.toString(t)})}multipleOf(t,r){return this._addCheck({kind:"multipleOf",value:t,message:L.toString(r)})}get minValue(){let t=null;for(let r of this._def.checks)r.kind==="min"&&(t===null||r.value>t)&&(t=r.value);return t}get maxValue(){let t=null;for(let r of this._def.checks)r.kind==="max"&&(t===null||r.value<t)&&(t=r.value);return t}};rl.create=e=>new rl({checks:[],typeName:I.ZodBigInt,coerce:e?.coerce??!1,...X(e)});var al=class extends ie{_parse(t){if(this._def.coerce&&(t.data=!!t.data),this._getType(t)!==N.boolean){let a=this._getOrReturnCtx(t);return R(a,{code:A.invalid_type,expected:N.boolean,received:a.parsedType}),W}return gt(t.data)}};al.create=e=>new al({typeName:I.ZodBoolean,coerce:e?.coerce||!1,...X(e)});var il=class e extends ie{_parse(t){if(this._def.coerce&&(t.data=new Date(t.data)),this._getType(t)!==N.date){let i=this._getOrReturnCtx(t);return R(i,{code:A.invalid_type,expected:N.date,received:i.parsedType}),W}if(Number.isNaN(t.data.getTime())){let i=this._getOrReturnCtx(t);return R(i,{code:A.invalid_date}),W}let a=new rt,n;for(let i of this._def.checks)i.kind==="min"?t.data.getTime()<i.value&&(n=this._getOrReturnCtx(t,n),R(n,{code:A.too_small,message:i.message,inclusive:!0,exact:!1,minimum:i.value,type:"date"}),a.dirty()):i.kind==="max"?t.data.getTime()>i.value&&(n=this._getOrReturnCtx(t,n),R(n,{code:A.too_big,message:i.message,inclusive:!0,exact:!1,maximum:i.value,type:"date"}),a.dirty()):ce.assertNever(i);return{status:a.value,value:new Date(t.data.getTime())}}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}min(t,r){return this._addCheck({kind:"min",value:t.getTime(),message:L.toString(r)})}max(t,r){return this._addCheck({kind:"max",value:t.getTime(),message:L.toString(r)})}get minDate(){let t=null;for(let r of this._def.checks)r.kind==="min"&&(t===null||r.value>t)&&(t=r.value);return t!=null?new Date(t):null}get maxDate(){let t=null;for(let r of this._def.checks)r.kind==="max"&&(t===null||r.value<t)&&(t=r.value);return t!=null?new Date(t):null}};il.create=e=>new il({checks:[],coerce:e?.coerce||!1,typeName:I.ZodDate,...X(e)});var ol=class extends ie{_parse(t){if(this._getType(t)!==N.symbol){let a=this._getOrReturnCtx(t);return R(a,{code:A.invalid_type,expected:N.symbol,received:a.parsedType}),W}return gt(t.data)}};ol.create=e=>new ol({typeName:I.ZodSymbol,...X(e)});var ji=class extends ie{_parse(t){if(this._getType(t)!==N.undefined){let a=this._getOrReturnCtx(t);return R(a,{code:A.invalid_type,expected:N.undefined,received:a.parsedType}),W}return gt(t.data)}};ji.create=e=>new ji({typeName:I.ZodUndefined,...X(e)});var Oi=class extends ie{_parse(t){if(this._getType(t)!==N.null){let a=this._getOrReturnCtx(t);return R(a,{code:A.invalid_type,expected:N.null,received:a.parsedType}),W}return gt(t.data)}};Oi.create=e=>new Oi({typeName:I.ZodNull,...X(e)});var sl=class extends ie{constructor(){super(...arguments),this._any=!0}_parse(t){return gt(t.data)}};sl.create=e=>new sl({typeName:I.ZodAny,...X(e)});var br=class extends ie{constructor(){super(...arguments),this._unknown=!0}_parse(t){return gt(t.data)}};br.create=e=>new br({typeName:I.ZodUnknown,...X(e)});var fn=class extends ie{_parse(t){let r=this._getOrReturnCtx(t);return R(r,{code:A.invalid_type,expected:N.never,received:r.parsedType}),W}};fn.create=e=>new fn({typeName:I.ZodNever,...X(e)});var ll=class extends ie{_parse(t){if(this._getType(t)!==N.undefined){let a=this._getOrReturnCtx(t);return R(a,{code:A.invalid_type,expected:N.void,received:a.parsedType}),W}return gt(t.data)}};ll.create=e=>new ll({typeName:I.ZodVoid,...X(e)});var vr=class e extends ie{_parse(t){let{ctx:r,status:a}=this._processInputParams(t),n=this._def;if(r.parsedType!==N.array)return R(r,{code:A.invalid_type,expected:N.array,received:r.parsedType}),W;if(n.exactLength!==null){let o=r.data.length>n.exactLength.value,s=r.data.length<n.exactLength.value;(o||s)&&(R(r,{code:o?A.too_big:A.too_small,minimum:s?n.exactLength.value:void 0,maximum:o?n.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:n.exactLength.message}),a.dirty())}if(n.minLength!==null&&r.data.length<n.minLength.value&&(R(r,{code:A.too_small,minimum:n.minLength.value,type:"array",inclusive:!0,exact:!1,message:n.minLength.message}),a.dirty()),n.maxLength!==null&&r.data.length>n.maxLength.value&&(R(r,{code:A.too_big,maximum:n.maxLength.value,type:"array",inclusive:!0,exact:!1,message:n.maxLength.message}),a.dirty()),r.common.async)return Promise.all([...r.data].map((o,s)=>n.type._parseAsync(new Ut(r,o,r.path,s)))).then(o=>rt.mergeArray(a,o));let i=[...r.data].map((o,s)=>n.type._parseSync(new Ut(r,o,r.path,s)));return rt.mergeArray(a,i)}get element(){return this._def.type}min(t,r){return new e({...this._def,minLength:{value:t,message:L.toString(r)}})}max(t,r){return new e({...this._def,maxLength:{value:t,message:L.toString(r)}})}length(t,r){return new e({...this._def,exactLength:{value:t,message:L.toString(r)}})}nonempty(t){return this.min(1,t)}};vr.create=(e,t)=>new vr({type:e,minLength:null,maxLength:null,exactLength:null,typeName:I.ZodArray,...X(t)});function Ri(e){if(e instanceof Ot){let t={};for(let r in e.shape){let a=e.shape[r];t[r]=Jt.create(Ri(a))}return new Ot({...e._def,shape:()=>t})}else return e instanceof vr?new vr({...e._def,type:Ri(e.element)}):e instanceof Jt?Jt.create(Ri(e.unwrap())):e instanceof Vn?Vn.create(Ri(e.unwrap())):e instanceof Gn?Gn.create(e.items.map(t=>Ri(t))):e}var Ot=class e extends ie{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;let t=this._def.shape(),r=ce.objectKeys(t);return this._cached={shape:t,keys:r},this._cached}_parse(t){if(this._getType(t)!==N.object){let c=this._getOrReturnCtx(t);return R(c,{code:A.invalid_type,expected:N.object,received:c.parsedType}),W}let{status:a,ctx:n}=this._processInputParams(t),{shape:i,keys:o}=this._getCached(),s=[];if(!(this._def.catchall instanceof fn&&this._def.unknownKeys==="strip"))for(let c in n.data)o.includes(c)||s.push(c);let l=[];for(let c of o){let u=i[c],d=n.data[c];l.push({key:{status:"valid",value:c},value:u._parse(new Ut(n,d,n.path,c)),alwaysSet:c in n.data})}if(this._def.catchall instanceof fn){let c=this._def.unknownKeys;if(c==="passthrough")for(let u of s)l.push({key:{status:"valid",value:u},value:{status:"valid",value:n.data[u]}});else if(c==="strict")s.length>0&&(R(n,{code:A.unrecognized_keys,keys:s}),a.dirty());else if(c!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{let c=this._def.catchall;for(let u of s){let d=n.data[u];l.push({key:{status:"valid",value:u},value:c._parse(new Ut(n,d,n.path,u)),alwaysSet:u in n.data})}}return n.common.async?Promise.resolve().then(async()=>{let c=[];for(let u of l){let d=await u.key,m=await u.value;c.push({key:d,value:m,alwaysSet:u.alwaysSet})}return c}).then(c=>rt.mergeObjectSync(a,c)):rt.mergeObjectSync(a,l)}get shape(){return this._def.shape()}strict(t){return L.errToObj,new e({...this._def,unknownKeys:"strict",...t!==void 0?{errorMap:(r,a)=>{let n=this._def.errorMap?.(r,a).message??a.defaultError;return r.code==="unrecognized_keys"?{message:L.errToObj(t).message??n}:{message:n}}}:{}})}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:I.ZodObject})}setKey(t,r){return this.augment({[t]:r})}catchall(t){return new e({...this._def,catchall:t})}pick(t){let r={};for(let a of ce.objectKeys(t))t[a]&&this.shape[a]&&(r[a]=this.shape[a]);return new e({...this._def,shape:()=>r})}omit(t){let r={};for(let a of ce.objectKeys(this.shape))t[a]||(r[a]=this.shape[a]);return new e({...this._def,shape:()=>r})}deepPartial(){return Ri(this)}partial(t){let r={};for(let a of ce.objectKeys(this.shape)){let n=this.shape[a];t&&!t[a]?r[a]=n:r[a]=n.optional()}return new e({...this._def,shape:()=>r})}required(t){let r={};for(let a of ce.objectKeys(this.shape))if(t&&!t[a])r[a]=this.shape[a];else{let i=this.shape[a];for(;i instanceof Jt;)i=i._def.innerType;r[a]=i}return new e({...this._def,shape:()=>r})}keyof(){return nC(ce.objectKeys(this.shape))}};Ot.create=(e,t)=>new Ot({shape:()=>e,unknownKeys:"strip",catchall:fn.create(),typeName:I.ZodObject,...X(t)});Ot.strictCreate=(e,t)=>new Ot({shape:()=>e,unknownKeys:"strict",catchall:fn.create(),typeName:I.ZodObject,...X(t)});Ot.lazycreate=(e,t)=>new Ot({shape:e,unknownKeys:"strip",catchall:fn.create(),typeName:I.ZodObject,...X(t)});var Ni=class extends ie{_parse(t){let{ctx:r}=this._processInputParams(t),a=this._def.options;function n(i){for(let s of i)if(s.result.status==="valid")return s.result;for(let s of i)if(s.result.status==="dirty")return r.common.issues.push(...s.ctx.common.issues),s.result;let o=i.map(s=>new jt(s.ctx.common.issues));return R(r,{code:A.invalid_union,unionErrors:o}),W}if(r.common.async)return Promise.all(a.map(async i=>{let o={...r,common:{...r.common,issues:[]},parent:null};return{result:await i._parseAsync({data:r.data,path:r.path,parent:o}),ctx:o}})).then(n);{let i,o=[];for(let l of a){let c={...r,common:{...r.common,issues:[]},parent:null},u=l._parseSync({data:r.data,path:r.path,parent:c});if(u.status==="valid")return u;u.status==="dirty"&&!i&&(i={result:u,ctx:c}),c.common.issues.length&&o.push(c.common.issues)}if(i)return r.common.issues.push(...i.ctx.common.issues),i.result;let s=o.map(l=>new jt(l));return R(r,{code:A.invalid_union,unionErrors:s}),W}}get options(){return this._def.options}};Ni.create=(e,t)=>new Ni({options:e,typeName:I.ZodUnion,...X(t)});var Hn=e=>e instanceof Mi?Hn(e.schema):e instanceof Yt?Hn(e.innerType()):e instanceof Li?[e.value]:e instanceof Bi?e.options:e instanceof Ui?ce.objectValues(e.enum):e instanceof Fi?Hn(e._def.innerType):e instanceof ji?[void 0]:e instanceof Oi?[null]:e instanceof Jt?[void 0,...Hn(e.unwrap())]:e instanceof Vn?[null,...Hn(e.unwrap())]:e instanceof am||e instanceof Hi?Hn(e.unwrap()):e instanceof qi?Hn(e._def.innerType):[],sy=class e extends ie{_parse(t){let{ctx:r}=this._processInputParams(t);if(r.parsedType!==N.object)return R(r,{code:A.invalid_type,expected:N.object,received:r.parsedType}),W;let a=this.discriminator,n=r.data[a],i=this.optionsMap.get(n);return i?r.common.async?i._parseAsync({data:r.data,path:r.path,parent:r}):i._parseSync({data:r.data,path:r.path,parent:r}):(R(r,{code:A.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[a]}),W)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(t,r,a){let n=new Map;for(let i of r){let o=Hn(i.shape[t]);if(!o.length)throw new Error(`A discriminator value for key \`${t}\` could not be extracted from all schema options`);for(let s of o){if(n.has(s))throw new Error(`Discriminator property ${String(t)} has duplicate value ${String(s)}`);n.set(s,i)}}return new e({typeName:I.ZodDiscriminatedUnion,discriminator:t,options:r,optionsMap:n,...X(a)})}};function ly(e,t){let r=qn(e),a=qn(t);if(e===t)return{valid:!0,data:e};if(r===N.object&&a===N.object){let n=ce.objectKeys(t),i=ce.objectKeys(e).filter(s=>n.indexOf(s)!==-1),o={...e,...t};Object.prototype.hasOwnProperty.call(o,"__proto__")&&delete o.__proto__;for(let s of i){if(s==="__proto__")continue;let l=ly(e[s],t[s]);if(!l.valid)return{valid:!1};o[s]=l.data}return{valid:!0,data:o}}else if(r===N.array&&a===N.array){if(e.length!==t.length)return{valid:!1};let n=[];for(let i=0;i<e.length;i++){let o=e[i],s=t[i],l=ly(o,s);if(!l.valid)return{valid:!1};n.push(l.data)}return{valid:!0,data:n}}else return r===N.date&&a===N.date&&+e==+t?{valid:!0,data:e}:{valid:!1}}var Di=class extends ie{_parse(t){let{status:r,ctx:a}=this._processInputParams(t),n=(i,o)=>{if(ay(i)||ay(o))return W;let s=ly(i.value,o.value);return s.valid?((iy(i)||iy(o))&&r.dirty(),{status:r.value,value:s.data}):(R(a,{code:A.invalid_intersection_types}),W)};return a.common.async?Promise.all([this._def.left._parseAsync({data:a.data,path:a.path,parent:a}),this._def.right._parseAsync({data:a.data,path:a.path,parent:a})]).then(([i,o])=>n(i,o)):n(this._def.left._parseSync({data:a.data,path:a.path,parent:a}),this._def.right._parseSync({data:a.data,path:a.path,parent:a}))}};Di.create=(e,t,r)=>new Di({left:e,right:t,typeName:I.ZodIntersection,...X(r)});var Gn=class e extends ie{_parse(t){let{status:r,ctx:a}=this._processInputParams(t);if(a.parsedType!==N.array)return R(a,{code:A.invalid_type,expected:N.array,received:a.parsedType}),W;if(a.data.length<this._def.items.length)return R(a,{code:A.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),W;!this._def.rest&&a.data.length>this._def.items.length&&(R(a,{code:A.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),r.dirty());let i=[...a.data].map((o,s)=>{let l=this._def.items[s]||this._def.rest;return l?l._parse(new Ut(a,o,a.path,s)):null}).filter(o=>!!o);return a.common.async?Promise.all(i).then(o=>rt.mergeArray(r,o)):rt.mergeArray(r,i)}get items(){return this._def.items}rest(t){return new e({...this._def,rest:t})}};Gn.create=(e,t)=>{if(!Array.isArray(e))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new Gn({items:e,typeName:I.ZodTuple,rest:null,...X(t)})};var cy=class e extends ie{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(t){let{status:r,ctx:a}=this._processInputParams(t);if(a.parsedType!==N.object)return R(a,{code:A.invalid_type,expected:N.object,received:a.parsedType}),W;let n=[],i=this._def.keyType,o=this._def.valueType;for(let s in a.data)n.push({key:i._parse(new Ut(a,s,a.path,s)),value:o._parse(new Ut(a,a.data[s],a.path,s)),alwaysSet:s in a.data});return a.common.async?rt.mergeObjectAsync(r,n):rt.mergeObjectSync(r,n)}get element(){return this._def.valueType}static create(t,r,a){return r instanceof ie?new e({keyType:t,valueType:r,typeName:I.ZodRecord,...X(a)}):new e({keyType:$i.create(),valueType:t,typeName:I.ZodRecord,...X(r)})}},cl=class extends ie{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(t){let{status:r,ctx:a}=this._processInputParams(t);if(a.parsedType!==N.map)return R(a,{code:A.invalid_type,expected:N.map,received:a.parsedType}),W;let n=this._def.keyType,i=this._def.valueType,o=[...a.data.entries()].map(([s,l],c)=>({key:n._parse(new Ut(a,s,a.path,[c,"key"])),value:i._parse(new Ut(a,l,a.path,[c,"value"]))}));if(a.common.async){let s=new Map;return Promise.resolve().then(async()=>{for(let l of o){let c=await l.key,u=await l.value;if(c.status==="aborted"||u.status==="aborted")return W;(c.status==="dirty"||u.status==="dirty")&&r.dirty(),s.set(c.value,u.value)}return{status:r.value,value:s}})}else{let s=new Map;for(let l of o){let c=l.key,u=l.value;if(c.status==="aborted"||u.status==="aborted")return W;(c.status==="dirty"||u.status==="dirty")&&r.dirty(),s.set(c.value,u.value)}return{status:r.value,value:s}}}};cl.create=(e,t,r)=>new cl({valueType:t,keyType:e,typeName:I.ZodMap,...X(r)});var ul=class e extends ie{_parse(t){let{status:r,ctx:a}=this._processInputParams(t);if(a.parsedType!==N.set)return R(a,{code:A.invalid_type,expected:N.set,received:a.parsedType}),W;let n=this._def;n.minSize!==null&&a.data.size<n.minSize.value&&(R(a,{code:A.too_small,minimum:n.minSize.value,type:"set",inclusive:!0,exact:!1,message:n.minSize.message}),r.dirty()),n.maxSize!==null&&a.data.size>n.maxSize.value&&(R(a,{code:A.too_big,maximum:n.maxSize.value,type:"set",inclusive:!0,exact:!1,message:n.maxSize.message}),r.dirty());let i=this._def.valueType;function o(l){let c=new Set;for(let u of l){if(u.status==="aborted")return W;u.status==="dirty"&&r.dirty(),c.add(u.value)}return{status:r.value,value:c}}let s=[...a.data.values()].map((l,c)=>i._parse(new Ut(a,l,a.path,c)));return a.common.async?Promise.all(s).then(l=>o(l)):o(s)}min(t,r){return new e({...this._def,minSize:{value:t,message:L.toString(r)}})}max(t,r){return new e({...this._def,maxSize:{value:t,message:L.toString(r)}})}size(t,r){return this.min(t,r).max(t,r)}nonempty(t){return this.min(1,t)}};ul.create=(e,t)=>new ul({valueType:e,minSize:null,maxSize:null,typeName:I.ZodSet,...X(t)});var uy=class e extends ie{constructor(){super(...arguments),this.validate=this.implement}_parse(t){let{ctx:r}=this._processInputParams(t);if(r.parsedType!==N.function)return R(r,{code:A.invalid_type,expected:N.function,received:r.parsedType}),W;function a(s,l){return rm({data:s,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,el(),fr].filter(c=>!!c),issueData:{code:A.invalid_arguments,argumentsError:l}})}function n(s,l){return rm({data:s,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,el(),fr].filter(c=>!!c),issueData:{code:A.invalid_return_type,returnTypeError:l}})}let i={errorMap:r.common.contextualErrorMap},o=r.data;if(this._def.returns instanceof ra){let s=this;return gt(async function(...l){let c=new jt([]),u=await s._def.args.parseAsync(l,i).catch(p=>{throw c.addIssue(a(l,p)),c}),d=await Reflect.apply(o,this,u);return await s._def.returns._def.type.parseAsync(d,i).catch(p=>{throw c.addIssue(n(d,p)),c})})}else{let s=this;return gt(function(...l){let c=s._def.args.safeParse(l,i);if(!c.success)throw new jt([a(l,c.error)]);let u=Reflect.apply(o,this,c.data),d=s._def.returns.safeParse(u,i);if(!d.success)throw new jt([n(u,d.error)]);return d.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...t){return new e({...this._def,args:Gn.create(t).rest(br.create())})}returns(t){return new e({...this._def,returns:t})}implement(t){return this.parse(t)}strictImplement(t){return this.parse(t)}static create(t,r,a){return new e({args:t||Gn.create([]).rest(br.create()),returns:r||br.create(),typeName:I.ZodFunction,...X(a)})}},Mi=class extends ie{get schema(){return this._def.getter()}_parse(t){let{ctx:r}=this._processInputParams(t);return this._def.getter()._parse({data:r.data,path:r.path,parent:r})}};Mi.create=(e,t)=>new Mi({getter:e,typeName:I.ZodLazy,...X(t)});var Li=class extends ie{_parse(t){if(t.data!==this._def.value){let r=this._getOrReturnCtx(t);return R(r,{received:r.data,code:A.invalid_literal,expected:this._def.value}),W}return{status:"valid",value:t.data}}get value(){return this._def.value}};Li.create=(e,t)=>new Li({value:e,typeName:I.ZodLiteral,...X(t)});function nC(e,t){return new Bi({values:e,typeName:I.ZodEnum,...X(t)})}var Bi=class e extends ie{_parse(t){if(typeof t.data!="string"){let r=this._getOrReturnCtx(t),a=this._def.values;return R(r,{expected:ce.joinValues(a),received:r.parsedType,code:A.invalid_type}),W}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(t.data)){let r=this._getOrReturnCtx(t),a=this._def.values;return R(r,{received:r.data,code:A.invalid_enum_value,options:a}),W}return gt(t.data)}get options(){return this._def.values}get enum(){let t={};for(let r of this._def.values)t[r]=r;return t}get Values(){let t={};for(let r of this._def.values)t[r]=r;return t}get Enum(){let t={};for(let r of this._def.values)t[r]=r;return t}extract(t,r=this._def){return e.create(t,{...this._def,...r})}exclude(t,r=this._def){return e.create(this.options.filter(a=>!t.includes(a)),{...this._def,...r})}};Bi.create=nC;var Ui=class extends ie{_parse(t){let r=ce.getValidEnumValues(this._def.values),a=this._getOrReturnCtx(t);if(a.parsedType!==N.string&&a.parsedType!==N.number){let n=ce.objectValues(r);return R(a,{expected:ce.joinValues(n),received:a.parsedType,code:A.invalid_type}),W}if(this._cache||(this._cache=new Set(ce.getValidEnumValues(this._def.values))),!this._cache.has(t.data)){let n=ce.objectValues(r);return R(a,{received:a.data,code:A.invalid_enum_value,options:n}),W}return gt(t.data)}get enum(){return this._def.values}};Ui.create=(e,t)=>new Ui({values:e,typeName:I.ZodNativeEnum,...X(t)});var ra=class extends ie{unwrap(){return this._def.type}_parse(t){let{ctx:r}=this._processInputParams(t);if(r.parsedType!==N.promise&&r.common.async===!1)return R(r,{code:A.invalid_type,expected:N.promise,received:r.parsedType}),W;let a=r.parsedType===N.promise?r.data:Promise.resolve(r.data);return gt(a.then(n=>this._def.type.parseAsync(n,{path:r.path,errorMap:r.common.contextualErrorMap})))}};ra.create=(e,t)=>new ra({type:e,typeName:I.ZodPromise,...X(t)});var Yt=class extends ie{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===I.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(t){let{status:r,ctx:a}=this._processInputParams(t),n=this._def.effect||null,i={addIssue:o=>{R(a,o),o.fatal?r.abort():r.dirty()},get path(){return a.path}};if(i.addIssue=i.addIssue.bind(i),n.type==="preprocess"){let o=n.transform(a.data,i);if(a.common.async)return Promise.resolve(o).then(async s=>{if(r.value==="aborted")return W;let l=await this._def.schema._parseAsync({data:s,path:a.path,parent:a});return l.status==="aborted"?W:l.status==="dirty"?Pi(l.value):r.value==="dirty"?Pi(l.value):l});{if(r.value==="aborted")return W;let s=this._def.schema._parseSync({data:o,path:a.path,parent:a});return s.status==="aborted"?W:s.status==="dirty"?Pi(s.value):r.value==="dirty"?Pi(s.value):s}}if(n.type==="refinement"){let o=s=>{let l=n.refinement(s,i);if(a.common.async)return Promise.resolve(l);if(l instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return s};if(a.common.async===!1){let s=this._def.schema._parseSync({data:a.data,path:a.path,parent:a});return s.status==="aborted"?W:(s.status==="dirty"&&r.dirty(),o(s.value),{status:r.value,value:s.value})}else return this._def.schema._parseAsync({data:a.data,path:a.path,parent:a}).then(s=>s.status==="aborted"?W:(s.status==="dirty"&&r.dirty(),o(s.value).then(()=>({status:r.value,value:s.value}))))}if(n.type==="transform")if(a.common.async===!1){let o=this._def.schema._parseSync({data:a.data,path:a.path,parent:a});if(!na(o))return W;let s=n.transform(o.value,i);if(s instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:r.value,value:s}}else return this._def.schema._parseAsync({data:a.data,path:a.path,parent:a}).then(o=>na(o)?Promise.resolve(n.transform(o.value,i)).then(s=>({status:r.value,value:s})):W);ce.assertNever(n)}};Yt.create=(e,t,r)=>new Yt({schema:e,typeName:I.ZodEffects,effect:t,...X(r)});Yt.createWithPreprocess=(e,t,r)=>new Yt({schema:t,effect:{type:"preprocess",transform:e},typeName:I.ZodEffects,...X(r)});var Jt=class extends ie{_parse(t){return this._getType(t)===N.undefined?gt(void 0):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}};Jt.create=(e,t)=>new Jt({innerType:e,typeName:I.ZodOptional,...X(t)});var Vn=class extends ie{_parse(t){return this._getType(t)===N.null?gt(null):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}};Vn.create=(e,t)=>new Vn({innerType:e,typeName:I.ZodNullable,...X(t)});var Fi=class extends ie{_parse(t){let{ctx:r}=this._processInputParams(t),a=r.data;return r.parsedType===N.undefined&&(a=this._def.defaultValue()),this._def.innerType._parse({data:a,path:r.path,parent:r})}removeDefault(){return this._def.innerType}};Fi.create=(e,t)=>new Fi({innerType:e,typeName:I.ZodDefault,defaultValue:typeof t.default=="function"?t.default:()=>t.default,...X(t)});var qi=class extends ie{_parse(t){let{ctx:r}=this._processInputParams(t),a={...r,common:{...r.common,issues:[]}},n=this._def.innerType._parse({data:a.data,path:a.path,parent:{...a}});return tl(n)?n.then(i=>({status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new jt(a.common.issues)},input:a.data})})):{status:"valid",value:n.status==="valid"?n.value:this._def.catchValue({get error(){return new jt(a.common.issues)},input:a.data})}}removeCatch(){return this._def.innerType}};qi.create=(e,t)=>new qi({innerType:e,typeName:I.ZodCatch,catchValue:typeof t.catch=="function"?t.catch:()=>t.catch,...X(t)});var dl=class extends ie{_parse(t){if(this._getType(t)!==N.nan){let a=this._getOrReturnCtx(t);return R(a,{code:A.invalid_type,expected:N.nan,received:a.parsedType}),W}return{status:"valid",value:t.data}}};dl.create=e=>new dl({typeName:I.ZodNaN,...X(e)});var am=class extends ie{_parse(t){let{ctx:r}=this._processInputParams(t),a=r.data;return this._def.type._parse({data:a,path:r.path,parent:r})}unwrap(){return this._def.type}},im=class e extends ie{_parse(t){let{status:r,ctx:a}=this._processInputParams(t);if(a.common.async)return(async()=>{let i=await this._def.in._parseAsync({data:a.data,path:a.path,parent:a});return i.status==="aborted"?W:i.status==="dirty"?(r.dirty(),Pi(i.value)):this._def.out._parseAsync({data:i.value,path:a.path,parent:a})})();{let n=this._def.in._parseSync({data:a.data,path:a.path,parent:a});return n.status==="aborted"?W:n.status==="dirty"?(r.dirty(),{status:"dirty",value:n.value}):this._def.out._parseSync({data:n.value,path:a.path,parent:a})}}static create(t,r){return new e({in:t,out:r,typeName:I.ZodPipeline})}},Hi=class extends ie{_parse(t){let r=this._def.innerType._parse(t),a=n=>(na(n)&&(n.value=Object.freeze(n.value)),n);return tl(r)?r.then(n=>a(n)):a(r)}unwrap(){return this._def.innerType}};Hi.create=(e,t)=>new Hi({innerType:e,typeName:I.ZodReadonly,...X(t)});var lZ={object:Ot.lazycreate},I;(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"})(I||(I={}));var cZ=$i.create,uZ=nl.create,dZ=dl.create,pZ=rl.create,mZ=al.create,gZ=il.create,hZ=ol.create,fZ=ji.create,bZ=Oi.create,vZ=sl.create,yZ=br.create,kZ=fn.create,_Z=ll.create,wZ=vr.create,rC=Ot.create,SZ=Ot.strictCreate,EZ=Ni.create,xZ=sy.create,TZ=Di.create,AZ=Gn.create,CZ=cy.create,zZ=cl.create,IZ=ul.create,PZ=uy.create,RZ=Mi.create,$Z=Li.create,jZ=Bi.create,OZ=Ui.create,NZ=ra.create,DZ=Yt.create,MZ=Jt.create,LZ=Vn.create,BZ=Yt.createWithPreprocess,UZ=im.create;var jM=y("ZodMiniType",(e,t)=>{if(!e._zod)throw new Error("Uninitialized schema in ZodMiniType.");Z.init(e,t),e.def=t,e.type=t.type},{get with(){return this.check},set with(e){sn(this,"with",e)},parse(e,t){return jr(this,e,t,{callee:this.parse})},parseAsync(e,t){return Or(this,e,t,{callee:this.parseAsync})},safeParse(e,t){return za(this,e,t)},safeParseAsync(e,t){return Pa(this,e,t)},check(...e){let t=this.def;return this.clone({...t,checks:[...t.checks??[],...e.map(r=>typeof r=="function"?{_zod:{check:r,def:{check:"custom"},onattach:[]}}:r)]},{parent:!0})},clone(e,t){return ge(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},apply(e,...t){return t.length===0?e(this):e(this,...t)}});var OM=y("ZodMiniObject",(e,t)=>{ru.init(e,t),jM.init(e,t),mg(e,"shape",r=>r._zod.def.shape,!1)});function dy(e,t){let r={type:"object",shape:e??{},...z(t)};return new OM(r)}function bn(e){return!!e._zod}function aa(e){let t=Object.values(e);if(t.length===0)return dy({});let r=t.every(bn),a=t.every(n=>!bn(n));if(r)return dy(e);if(a)return rC(e);throw new Error("Mixed Zod versions detected in object shape.")}function yr(e,t){return bn(e)?za(e,t):e.safeParse(t)}async function om(e,t){return bn(e)?await Pa(e,t):await e.safeParseAsync(t)}function kr(e){if(!e)return;let t;if(bn(e)?t=e._zod?.def?.shape:t=e.shape,!!t){if(typeof t=="function")try{return t()}catch{return}return t}}function Gi(e){if(e){if(typeof e=="object"){let t=e,r=e;if(!t._def&&!r._zod){let a=Object.values(e);if(a.length>0&&a.every(n=>typeof n=="object"&&n!==null&&(n._def!==void 0||n._zod!==void 0||typeof n.parse=="function")))return aa(e)}}if(bn(e)){let r=e._zod?.def;if(r&&(r.type==="object"||r.shape!==void 0))return e}else if(e.shape!==void 0)return e}}function DM(e){return e.length===0?"object root":e.reduce((t,r,a)=>a===0?String(r):typeof r=="number"?`${t}[${r}]`:`${t}.${r}`,"")}function sm(e){if(e&&typeof e=="object"){if("issues"in e&&Array.isArray(e.issues)&&e.issues.length>0)return e.issues.map(t=>t.path?.length?`${t.message} at ${DM(t.path)}`:t.message).join(`
|
|
3559
|
+
`);if("message"in e&&typeof e.message=="string")return e.message;try{return JSON.stringify(e)}catch{return String(e)}}return String(e)}function aC(e){return e.description}function iC(e){if(bn(e))return e._zod?.def?.type==="optional";let t=e;return typeof e.isOptional=="function"?e.isOptional():t._def?.typeName==="ZodOptional"}function Vi(e){if(bn(e)){let i=e._zod?.def;if(i){if(i.value!==void 0)return i.value;if(Array.isArray(i.values)&&i.values.length>0)return i.values[0]}}let r=e._def;if(r){if(r.value!==void 0)return r.value;if(Array.isArray(r.values)&&r.values.length>0)return r.values[0]}let a=e.value;if(a!==void 0)return a}function _r(e){return e==="completed"||e==="failed"||e==="cancelled"}var sC=Symbol("Let zodToJsonSchema decide on which parser to use");var oC={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"},lC=e=>typeof e=="string"?{...oC,name:e}:{...oC,...e};var cC=e=>{let t=lC(e),r=t.name!==void 0?[...t.basePath,t.definitionPath,t.name]:t.basePath;return{...t,flags:{hasReferencedOpenAiAnyType:!1},currentPath:r,propertyPath:void 0,seen:new Map(Object.entries(t.definitions).map(([a,n])=>[n._def,{def:n._def,path:[...t.basePath,t.definitionPath,a],jsonSchema:void 0}]))}};function py(e,t,r,a){a?.errorMessages&&r&&(e.errorMessage={...e.errorMessage,[t]:r})}function ue(e,t,r,a,n){e[t]=r,py(e,t,a,n)}var lm=(e,t)=>{let r=0;for(;r<e.length&&r<t.length&&e[r]===t[r];r++);return[(e.length-r).toString(),...t.slice(r)].join("/")};function je(e){if(e.target!=="openAi")return{};let t=[...e.basePath,e.definitionPath,e.openAiAnyTypeName];return e.flags.hasReferencedOpenAiAnyType=!0,{$ref:e.$refStrategy==="relative"?lm(t,e.currentPath):t.join("/")}}function uC(e,t){let r={type:"array"};return e.type?._def&&e.type?._def?.typeName!==I.ZodAny&&(r.items=K(e.type._def,{...t,currentPath:[...t.currentPath,"items"]})),e.minLength&&ue(r,"minItems",e.minLength.value,e.minLength.message,t),e.maxLength&&ue(r,"maxItems",e.maxLength.value,e.maxLength.message,t),e.exactLength&&(ue(r,"minItems",e.exactLength.value,e.exactLength.message,t),ue(r,"maxItems",e.exactLength.value,e.exactLength.message,t)),r}function dC(e,t){let r={type:"integer",format:"int64"};if(!e.checks)return r;for(let a of e.checks)switch(a.kind){case"min":t.target==="jsonSchema7"?a.inclusive?ue(r,"minimum",a.value,a.message,t):ue(r,"exclusiveMinimum",a.value,a.message,t):(a.inclusive||(r.exclusiveMinimum=!0),ue(r,"minimum",a.value,a.message,t));break;case"max":t.target==="jsonSchema7"?a.inclusive?ue(r,"maximum",a.value,a.message,t):ue(r,"exclusiveMaximum",a.value,a.message,t):(a.inclusive||(r.exclusiveMaximum=!0),ue(r,"maximum",a.value,a.message,t));break;case"multipleOf":ue(r,"multipleOf",a.value,a.message,t);break}return r}function pC(){return{type:"boolean"}}function cm(e,t){return K(e.type._def,t)}var mC=(e,t)=>K(e.innerType._def,t);function my(e,t,r){let a=r??t.dateStrategy;if(Array.isArray(a))return{anyOf:a.map((n,i)=>my(e,t,n))};switch(a){case"string":case"format:date-time":return{type:"string",format:"date-time"};case"format:date":return{type:"string",format:"date"};case"integer":return MM(e,t)}}var MM=(e,t)=>{let r={type:"integer",format:"unix-time"};if(t.target==="openApi3")return r;for(let a of e.checks)switch(a.kind){case"min":ue(r,"minimum",a.value,a.message,t);break;case"max":ue(r,"maximum",a.value,a.message,t);break}return r};function gC(e,t){return{...K(e.innerType._def,t),default:e.defaultValue()}}function hC(e,t){return t.effectStrategy==="input"?K(e.schema._def,t):je(t)}function fC(e){return{type:"string",enum:Array.from(e.values)}}var LM=e=>"type"in e&&e.type==="string"?!1:"allOf"in e;function bC(e,t){let r=[K(e.left._def,{...t,currentPath:[...t.currentPath,"allOf","0"]}),K(e.right._def,{...t,currentPath:[...t.currentPath,"allOf","1"]})].filter(i=>!!i),a=t.target==="jsonSchema2019-09"?{unevaluatedProperties:!1}:void 0,n=[];return r.forEach(i=>{if(LM(i))n.push(...i.allOf),i.unevaluatedProperties===void 0&&(a=void 0);else{let o=i;if("additionalProperties"in i&&i.additionalProperties===!1){let{additionalProperties:s,...l}=i;o=l}else a=void 0;n.push(o)}}),n.length?{allOf:n,...a}:void 0}function vC(e,t){let r=typeof e.value;return r!=="bigint"&&r!=="number"&&r!=="boolean"&&r!=="string"?{type:Array.isArray(e.value)?"array":"object"}:t.target==="openApi3"?{type:r==="bigint"?"integer":r,enum:[e.value]}:{type:r==="bigint"?"integer":r,const:e.value}}var gy,Xt={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:()=>(gy===void 0&&(gy=RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),gy),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 um(e,t){let r={type:"string"};if(e.checks)for(let a of e.checks)switch(a.kind){case"min":ue(r,"minLength",typeof r.minLength=="number"?Math.max(r.minLength,a.value):a.value,a.message,t);break;case"max":ue(r,"maxLength",typeof r.maxLength=="number"?Math.min(r.maxLength,a.value):a.value,a.message,t);break;case"email":switch(t.emailStrategy){case"format:email":Qt(r,"email",a.message,t);break;case"format:idn-email":Qt(r,"idn-email",a.message,t);break;case"pattern:zod":ht(r,Xt.email,a.message,t);break}break;case"url":Qt(r,"uri",a.message,t);break;case"uuid":Qt(r,"uuid",a.message,t);break;case"regex":ht(r,a.regex,a.message,t);break;case"cuid":ht(r,Xt.cuid,a.message,t);break;case"cuid2":ht(r,Xt.cuid2,a.message,t);break;case"startsWith":ht(r,RegExp(`^${hy(a.value,t)}`),a.message,t);break;case"endsWith":ht(r,RegExp(`${hy(a.value,t)}$`),a.message,t);break;case"datetime":Qt(r,"date-time",a.message,t);break;case"date":Qt(r,"date",a.message,t);break;case"time":Qt(r,"time",a.message,t);break;case"duration":Qt(r,"duration",a.message,t);break;case"length":ue(r,"minLength",typeof r.minLength=="number"?Math.max(r.minLength,a.value):a.value,a.message,t),ue(r,"maxLength",typeof r.maxLength=="number"?Math.min(r.maxLength,a.value):a.value,a.message,t);break;case"includes":{ht(r,RegExp(hy(a.value,t)),a.message,t);break}case"ip":{a.version!=="v6"&&Qt(r,"ipv4",a.message,t),a.version!=="v4"&&Qt(r,"ipv6",a.message,t);break}case"base64url":ht(r,Xt.base64url,a.message,t);break;case"jwt":ht(r,Xt.jwt,a.message,t);break;case"cidr":{a.version!=="v6"&&ht(r,Xt.ipv4Cidr,a.message,t),a.version!=="v4"&&ht(r,Xt.ipv6Cidr,a.message,t);break}case"emoji":ht(r,Xt.emoji(),a.message,t);break;case"ulid":{ht(r,Xt.ulid,a.message,t);break}case"base64":{switch(t.base64Strategy){case"format:binary":{Qt(r,"binary",a.message,t);break}case"contentEncoding:base64":{ue(r,"contentEncoding","base64",a.message,t);break}case"pattern:zod":{ht(r,Xt.base64,a.message,t);break}}break}case"nanoid":ht(r,Xt.nanoid,a.message,t);case"toLowerCase":case"toUpperCase":case"trim":break;default:}return r}function hy(e,t){return t.patternStrategy==="escape"?UM(e):e}var BM=new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");function UM(e){let t="";for(let r=0;r<e.length;r++)BM.has(e[r])||(t+="\\"),t+=e[r];return t}function Qt(e,t,r,a){e.format||e.anyOf?.some(n=>n.format)?(e.anyOf||(e.anyOf=[]),e.format&&(e.anyOf.push({format:e.format,...e.errorMessage&&a.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,...r&&a.errorMessages&&{errorMessage:{format:r}}})):ue(e,"format",t,r,a)}function ht(e,t,r,a){e.pattern||e.allOf?.some(n=>n.pattern)?(e.allOf||(e.allOf=[]),e.pattern&&(e.allOf.push({pattern:e.pattern,...e.errorMessage&&a.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:yC(t,a),...r&&a.errorMessages&&{errorMessage:{pattern:r}}})):ue(e,"pattern",yC(t,a),r,a)}function yC(e,t){if(!t.applyRegexFlags||!e.flags)return e.source;let r={i:e.flags.includes("i"),m:e.flags.includes("m"),s:e.flags.includes("s")},a=r.i?e.source.toLowerCase():e.source,n="",i=!1,o=!1,s=!1;for(let l=0;l<a.length;l++){if(i){n+=a[l],i=!1;continue}if(r.i){if(o){if(a[l].match(/[a-z]/)){s?(n+=a[l],n+=`${a[l-2]}-${a[l]}`.toUpperCase(),s=!1):a[l+1]==="-"&&a[l+2]?.match(/[a-z]/)?(n+=a[l],s=!0):n+=`${a[l]}${a[l].toUpperCase()}`;continue}}else if(a[l].match(/[a-z]/)){n+=`[${a[l]}${a[l].toUpperCase()}]`;continue}}if(r.m){if(a[l]==="^"){n+=`(^|(?<=[\r
|
|
3560
3560
|
]))`;continue}else if(a[l]==="$"){n+=`($|(?=[\r
|
|
3561
3561
|
]))`;continue}}if(r.s&&a[l]==="."){n+=o?`${a[l]}\r
|
|
3562
3562
|
`:`[${a[l]}\r
|
|
3563
|
-
]`;continue}n+=a[l],a[l]==="\\"?i=!0:o&&a[l]==="]"?o=!1:!o&&a[l]==="["&&(o=!0)}try{new RegExp(n)}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 n}function dm(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===I.ZodEnum)return{type:"object",required:e.keyType._def.values,properties:e.keyType._def.values.reduce((a,n)=>({...a,[n]:K(e.valueType._def,{...t,currentPath:[...t.currentPath,"properties",n]})??je(t)}),{}),additionalProperties:t.rejectedAdditionalProperties};let r={type:"object",additionalProperties:K(e.valueType._def,{...t,currentPath:[...t.currentPath,"additionalProperties"]})??t.allowedAdditionalProperties};if(t.target==="openApi3")return r;if(e.keyType?._def.typeName===I.ZodString&&e.keyType._def.checks?.length){let{type:a,...n}=um(e.keyType._def,t);return{...r,propertyNames:n}}else{if(e.keyType?._def.typeName===I.ZodEnum)return{...r,propertyNames:{enum:e.keyType._def.values}};if(e.keyType?._def.typeName===I.ZodBranded&&e.keyType._def.type._def.typeName===I.ZodString&&e.keyType._def.type._def.checks?.length){let{type:a,...n}=cm(e.keyType._def,t);return{...r,propertyNames:n}}}return r}function kC(e,t){if(t.mapStrategy==="record")return dm(e,t);let r=K(e.keyType._def,{...t,currentPath:[...t.currentPath,"items","items","0"]})||je(t),a=K(e.valueType._def,{...t,currentPath:[...t.currentPath,"items","items","1"]})||je(t);return{type:"array",maxItems:125,items:{type:"array",items:[r,a],minItems:2,maxItems:2}}}function _C(e){let t=e.values,a=Object.keys(e.values).filter(i=>typeof t[t[i]]!="number").map(i=>t[i]),n=Array.from(new Set(a.map(i=>typeof i)));return{type:n.length===1?n[0]==="string"?"string":"number":["string","number"],enum:a}}function wC(e){return e.target==="openAi"?void 0:{not:je({...e,currentPath:[...e.currentPath,"not"]})}}function SC(e){return e.target==="openApi3"?{enum:["null"],nullable:!0}:{type:"null"}}var pl={ZodString:"string",ZodNumber:"number",ZodBigInt:"integer",ZodBoolean:"boolean",ZodNull:"null"};function xC(e,t){if(t.target==="openApi3")return EC(e,t);let r=e.options instanceof Map?Array.from(e.options.values()):e.options;if(r.every(a=>a._def.typeName in pl&&(!a._def.checks||!a._def.checks.length))){let a=r.reduce((n,i)=>{let o=pl[i._def.typeName];return o&&!n.includes(o)?[...n,o]:n},[]);return{type:a.length>1?a:a[0]}}else if(r.every(a=>a._def.typeName==="ZodLiteral"&&!a.description)){let a=r.reduce((n,i)=>{let o=typeof i._def.value;switch(o){case"string":case"number":case"boolean":return[...n,o];case"bigint":return[...n,"integer"];case"object":if(i._def.value===null)return[...n,"null"];default:return n}},[]);if(a.length===r.length){let n=a.filter((i,o,s)=>s.indexOf(i)===o);return{type:n.length>1?n:n[0],enum:r.reduce((i,o)=>i.includes(o._def.value)?i:[...i,o._def.value],[])}}}else if(r.every(a=>a._def.typeName==="ZodEnum"))return{type:"string",enum:r.reduce((a,n)=>[...a,...n._def.values.filter(i=>!a.includes(i))],[])};return EC(e,t)}var EC=(e,t)=>{let r=(e.options instanceof Map?Array.from(e.options.values()):e.options).map((a,n)=>K(a._def,{...t,currentPath:[...t.currentPath,"anyOf",`${n}`]})).filter(a=>!!a&&(!t.strictUnions||typeof a=="object"&&Object.keys(a).length>0));return r.length?{anyOf:r}:void 0};function TC(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:pl[e.innerType._def.typeName],nullable:!0}:{type:[pl[e.innerType._def.typeName],"null"]};if(t.target==="openApi3"){let a=K(e.innerType._def,{...t,currentPath:[...t.currentPath]});return a&&"$ref"in a?{allOf:[a],nullable:!0}:a&&{...a,nullable:!0}}let r=K(e.innerType._def,{...t,currentPath:[...t.currentPath,"anyOf","0"]});return r&&{anyOf:[r,{type:"null"}]}}function AC(e,t){let r={type:"number"};if(!e.checks)return r;for(let a of e.checks)switch(a.kind){case"int":r.type="integer",py(r,"type",a.message,t);break;case"min":t.target==="jsonSchema7"?a.inclusive?ue(r,"minimum",a.value,a.message,t):ue(r,"exclusiveMinimum",a.value,a.message,t):(a.inclusive||(r.exclusiveMinimum=!0),ue(r,"minimum",a.value,a.message,t));break;case"max":t.target==="jsonSchema7"?a.inclusive?ue(r,"maximum",a.value,a.message,t):ue(r,"exclusiveMaximum",a.value,a.message,t):(a.inclusive||(r.exclusiveMaximum=!0),ue(r,"maximum",a.value,a.message,t));break;case"multipleOf":ue(r,"multipleOf",a.value,a.message,t);break}return r}function CC(e,t){let r=t.target==="openAi",a={type:"object",properties:{}},n=[],i=e.shape();for(let s in i){let l=i[s];if(l===void 0||l._def===void 0)continue;let c=UM(l);c&&r&&(l._def.typeName==="ZodOptional"&&(l=l._def.innerType),l.isNullable()||(l=l.nullable()),c=!1);let u=K(l._def,{...t,currentPath:[...t.currentPath,"properties",s],propertyPath:[...t.currentPath,"properties",s]});u!==void 0&&(a.properties[s]=u,c||n.push(s))}n.length&&(a.required=n);let o=BM(e,t);return o!==void 0&&(a.additionalProperties=o),a}function BM(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 UM(e){try{return e.isOptional()}catch{return!0}}var zC=(e,t)=>{if(t.currentPath.toString()===t.propertyPath?.toString())return K(e.innerType._def,t);let r=K(e.innerType._def,{...t,currentPath:[...t.currentPath,"anyOf","1"]});return r?{anyOf:[{not:je(t)},r]}:je(t)};var IC=(e,t)=>{if(t.pipeStrategy==="input")return K(e.in._def,t);if(t.pipeStrategy==="output")return K(e.out._def,t);let r=K(e.in._def,{...t,currentPath:[...t.currentPath,"allOf","0"]}),a=K(e.out._def,{...t,currentPath:[...t.currentPath,"allOf",r?"1":"0"]});return{allOf:[r,a].filter(n=>n!==void 0)}};function PC(e,t){return K(e.type._def,t)}function RC(e,t){let a={type:"array",uniqueItems:!0,items:K(e.valueType._def,{...t,currentPath:[...t.currentPath,"items"]})};return e.minSize&&ue(a,"minItems",e.minSize.value,e.minSize.message,t),e.maxSize&&ue(a,"maxItems",e.maxSize.value,e.maxSize.message,t),a}function $C(e,t){return e.rest?{type:"array",minItems:e.items.length,items:e.items.map((r,a)=>K(r._def,{...t,currentPath:[...t.currentPath,"items",`${a}`]})).reduce((r,a)=>a===void 0?r:[...r,a],[]),additionalItems:K(e.rest._def,{...t,currentPath:[...t.currentPath,"additionalItems"]})}:{type:"array",minItems:e.items.length,maxItems:e.items.length,items:e.items.map((r,a)=>K(r._def,{...t,currentPath:[...t.currentPath,"items",`${a}`]})).reduce((r,a)=>a===void 0?r:[...r,a],[])}}function jC(e){return{not:je(e)}}function OC(e){return je(e)}var NC=(e,t)=>K(e.innerType._def,t);var DC=(e,t,r)=>{switch(t){case I.ZodString:return um(e,r);case I.ZodNumber:return AC(e,r);case I.ZodObject:return CC(e,r);case I.ZodBigInt:return dC(e,r);case I.ZodBoolean:return pC();case I.ZodDate:return my(e,r);case I.ZodUndefined:return jC(r);case I.ZodNull:return SC(r);case I.ZodArray:return uC(e,r);case I.ZodUnion:case I.ZodDiscriminatedUnion:return xC(e,r);case I.ZodIntersection:return bC(e,r);case I.ZodTuple:return $C(e,r);case I.ZodRecord:return dm(e,r);case I.ZodLiteral:return vC(e,r);case I.ZodEnum:return fC(e);case I.ZodNativeEnum:return _C(e);case I.ZodNullable:return TC(e,r);case I.ZodOptional:return zC(e,r);case I.ZodMap:return kC(e,r);case I.ZodSet:return RC(e,r);case I.ZodLazy:return()=>e.getter()._def;case I.ZodPromise:return PC(e,r);case I.ZodNaN:case I.ZodNever:return wC(r);case I.ZodEffects:return hC(e,r);case I.ZodAny:return je(r);case I.ZodUnknown:return OC(r);case I.ZodDefault:return gC(e,r);case I.ZodBranded:return cm(e,r);case I.ZodReadonly:return NC(e,r);case I.ZodCatch:return mC(e,r);case I.ZodPipeline:return IC(e,r);case I.ZodFunction:case I.ZodVoid:case I.ZodSymbol:return;default:return(a=>{})(t)}};function K(e,t,r=!1){let a=t.seen.get(e);if(t.override){let s=t.override?.(e,t,a,r);if(s!==sC)return s}if(a&&!r){let s=FM(a,t);if(s!==void 0)return s}let n={def:e,path:t.currentPath,jsonSchema:void 0};t.seen.set(e,n);let i=DC(e,e.typeName,t),o=typeof i=="function"?K(i(),t):i;if(o&&qM(e,t,o),t.postProcess){let s=t.postProcess(o,e,t);return n.jsonSchema=o,s}return n.jsonSchema=o,o}var FM=(e,t)=>{switch(t.$refStrategy){case"root":return{$ref:e.path.join("/")};case"relative":return{$ref:lm(t.currentPath,e.path)};case"none":case"seen":return e.path.length<t.currentPath.length&&e.path.every((r,a)=>t.currentPath[a]===r)?(console.warn(`Recursive reference detected at ${t.currentPath.join("/")}! Defaulting to any`),je(t)):t.$refStrategy==="seen"?je(t):void 0}},qM=(e,t,r)=>(e.description&&(r.description=e.description,t.markdownDescription&&(r.markdownDescription=e.description)),r);var fy=(e,t)=>{let r=cC(t),a=typeof t=="object"&&t.definitions?Object.entries(t.definitions).reduce((l,[c,u])=>({...l,[c]:K(u._def,{...r,currentPath:[...r.basePath,r.definitionPath,c]},!0)??je(r)}),{}):void 0,n=typeof t=="string"?t:t?.nameStrategy==="title"?void 0:t?.name,i=K(e._def,n===void 0?r:{...r,currentPath:[...r.basePath,r.definitionPath,n]},!1)??je(r),o=typeof t=="object"&&t.name!==void 0&&t.nameStrategy==="title"?t.name:void 0;o!==void 0&&(i.title=o),r.flags.hasReferencedOpenAiAnyType&&(a||(a={}),a[r.openAiAnyTypeName]||(a[r.openAiAnyTypeName]={type:["string","number","integer","boolean","array","null"],items:{$ref:r.$refStrategy==="relative"?"1":[...r.basePath,r.definitionPath,r.openAiAnyTypeName].join("/")}}));let s=n===void 0?a?{...i,[r.definitionPath]:a}:i:{$ref:[...r.$refStrategy==="relative"?[]:r.basePath,r.definitionPath,n].join("/"),[r.definitionPath]:{...a,[n]:i}};return r.target==="jsonSchema7"?s.$schema="http://json-schema.org/draft-07/schema#":(r.target==="jsonSchema2019-09"||r.target==="openAi")&&(s.$schema="https://json-schema.org/draft/2019-09/schema#"),r.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 HM(e){return!e||e==="jsonSchema7"||e==="draft-7"?"draft-7":e==="jsonSchema2019-09"||e==="draft-2020-12"?"draft-2020-12":"draft-7"}function by(e,t){return bn(e)?Hr(e,{target:HM(t?.target),io:t?.pipeStrategy??"input"}):fy(e,{strictUnions:t?.strictUnions??!0,pipeStrategy:t?.pipeStrategy??"input"})}function vy(e){let r=kr(e)?.method;if(!r)throw new Error("Schema is missing a method literal");let a=Vi(r);if(typeof a!="string")throw new Error("Schema method literal must be a string");return a}function yy(e,t){let r=yr(e,t);if(!r.success)throw r.error;return r.data}var GM=6e4,pm=class{constructor(t){this._options=t,this._requestMessageId=0,this._requestHandlers=new Map,this._requestHandlerAbortControllers=new Map,this._notificationHandlers=new Map,this._responseHandlers=new Map,this._progressHandlers=new Map,this._timeoutInfo=new Map,this._pendingDebouncedNotifications=new Set,this._taskProgressTokens=new Map,this._requestResolvers=new Map,this.setNotificationHandler(ap,r=>{this._oncancel(r)}),this.setNotificationHandler(sp,r=>{this._onprogress(r)}),this.setRequestHandler(op,r=>({})),this._taskStore=t?.taskStore,this._taskMessageQueue=t?.taskMessageQueue,this._taskStore&&(this.setRequestHandler(lp,async(r,a)=>{let n=await this._taskStore.getTask(r.params.taskId,a.sessionId);if(!n)throw new M(F.InvalidParams,"Failed to retrieve task: Task not found");return{...n}}),this.setRequestHandler(up,async(r,a)=>{let n=async()=>{let i=r.params.taskId;if(!await this._taskStore.getTask(i,a.sessionId))throw new M(F.InvalidParams,`Task not found: ${i}`);if(this._taskMessageQueue){let s;for(;s=await this._taskMessageQueue.dequeue(i,a.sessionId);){if(s.type==="response"||s.type==="error"){let l=s.message,c=l.id,u=this._requestResolvers.get(c);if(u)if(this._requestResolvers.delete(c),s.type==="response")u(l);else{let d=l,m=new M(d.error.code,d.error.message,d.error.data);u(m)}else{let d=s.type==="response"?"Response":"Error";this._onerror(new Error(`${d} handler missing for request ${c}`))}continue}await this._transport?.send(s.message,{relatedRequestId:a.requestId})}}let o=await this._taskStore.getTask(i,a.sessionId);if(!o)throw new M(F.InvalidParams,`Task not found: ${i}`);if(!_r(o.status))return await this._waitForTaskUpdate(i,a.signal,a.sessionId),await n();if(_r(o.status)){let s=await this._taskStore.getTaskResult(i,a.sessionId);return this._clearTaskQueue(i,a.sessionId),{...s,_meta:{...s._meta,[pr]:{taskId:i}}}}return await n()};return await n()}),this.setRequestHandler(dp,async(r,a)=>{try{let{tasks:n,nextCursor:i}=await this._taskStore.listTasks(r.params?.cursor,a.sessionId);return{tasks:n,nextCursor:i,_meta:{}}}catch(n){throw new M(F.InvalidParams,`Failed to list tasks: ${n instanceof Error?n.message:String(n)}`)}}),this.setRequestHandler(mp,async(r,a)=>{try{let n=await this._taskStore.getTask(r.params.taskId,a.sessionId);if(!n)throw new M(F.InvalidParams,`Task not found: ${r.params.taskId}`);if(_r(n.status))throw new M(F.InvalidParams,`Cannot cancel task in terminal status: ${n.status}`);await this._taskStore.updateTaskStatus(r.params.taskId,"cancelled","Client cancelled task execution.",a.sessionId),this._clearTaskQueue(r.params.taskId,a.sessionId);let i=await this._taskStore.getTask(r.params.taskId,a.sessionId);if(!i)throw new M(F.InvalidParams,`Task not found after cancellation: ${r.params.taskId}`);return{_meta:{},...i}}catch(n){throw n instanceof M?n:new M(F.InvalidRequest,`Failed to cancel task: ${n instanceof Error?n.message:String(n)}`)}}))}async _oncancel(t){if(!t.params.requestId)return;this._requestHandlerAbortControllers.get(t.params.requestId)?.abort(t.params.reason)}_setupTimeout(t,r,a,n,i=!1){this._timeoutInfo.set(t,{timeoutId:setTimeout(n,r),startTime:Date.now(),timeout:r,maxTotalTimeout:a,resetTimeoutOnProgress:i,onTimeout:n})}_resetTimeout(t){let r=this._timeoutInfo.get(t);if(!r)return!1;let a=Date.now()-r.startTime;if(r.maxTotalTimeout&&a>=r.maxTotalTimeout)throw this._timeoutInfo.delete(t),M.fromError(F.RequestTimeout,"Maximum total timeout exceeded",{maxTotalTimeout:r.maxTotalTimeout,totalElapsed:a});return clearTimeout(r.timeoutId),r.timeoutId=setTimeout(r.onTimeout,r.timeout),!0}_cleanupTimeout(t){let r=this._timeoutInfo.get(t);r&&(clearTimeout(r.timeoutId),this._timeoutInfo.delete(t))}async connect(t){if(this._transport)throw new Error("Already connected to a transport. Call close() before connecting to a new transport, or use a separate Protocol instance per connection.");this._transport=t;let r=this.transport?.onclose;this._transport.onclose=()=>{r?.(),this._onclose()};let a=this.transport?.onerror;this._transport.onerror=i=>{a?.(i),this._onerror(i)};let n=this._transport?.onmessage;this._transport.onmessage=(i,o)=>{n?.(i,o),In(i)||bi(i)?this._onresponse(i):zn(i)?this._onrequest(i,o):Ux(i)?this._onnotification(i):this._onerror(new Error(`Unknown message type: ${JSON.stringify(i)}`))},await this._transport.start()}_onclose(){let t=this._responseHandlers;this._responseHandlers=new Map,this._progressHandlers.clear(),this._taskProgressTokens.clear(),this._pendingDebouncedNotifications.clear();for(let a of this._timeoutInfo.values())clearTimeout(a.timeoutId);this._timeoutInfo.clear();for(let a of this._requestHandlerAbortControllers.values())a.abort();this._requestHandlerAbortControllers.clear();let r=M.fromError(F.ConnectionClosed,"Connection closed");this._transport=void 0,this.onclose?.();for(let a of t.values())a(r)}_onerror(t){this.onerror?.(t)}_onnotification(t){let r=this._notificationHandlers.get(t.method)??this.fallbackNotificationHandler;r!==void 0&&Promise.resolve().then(()=>r(t)).catch(a=>this._onerror(new Error(`Uncaught error in notification handler: ${a}`)))}_onrequest(t,r){let a=this._requestHandlers.get(t.method)??this.fallbackRequestHandler,n=this._transport,i=t.params?._meta?.[pr]?.taskId,o=n?.sessionId,s=this._taskStore,l=!0,c;if(i&&s&&this._taskMessageQueue&&o!==void 0&&(l=!1,c=(async()=>{if(!await s.getTask(i,o))throw new M(F.InvalidParams,`Task not found: ${i}`);l=!0})()),a===void 0){let g={jsonrpc:"2.0",id:t.id,error:{code:F.MethodNotFound,message:"Method not found"}};if(i&&c){let h={type:"error",message:g,timestamp:Date.now()};c.then(()=>this._enqueueTaskMessage(i,h,o),()=>n?.send(g)).catch(f=>this._onerror(new Error(`Failed to send an error response: ${f}`)))}else i&&this._taskMessageQueue?this._enqueueTaskMessage(i,{type:"error",message:g,timestamp:Date.now()},n?.sessionId).catch(h=>this._onerror(new Error(`Failed to enqueue error response: ${h}`))):n?.send(g).catch(h=>this._onerror(new Error(`Failed to send an error response: ${h}`)));return}let u=new AbortController;this._requestHandlerAbortControllers.set(t.id,u);let d=Mx(t.params)?t.params.task:void 0,m=this._taskStore?this.requestTaskStore(t,n?.sessionId):void 0,p={signal:u.signal,sessionId:n?.sessionId,_meta:t.params?._meta,sendNotification:async g=>{if(u.signal.aborted)return;let h={relatedRequestId:t.id};i&&(h.relatedTask={taskId:i}),await this.notification(g,h)},sendRequest:async(g,h,f)=>{if(u.signal.aborted)throw new M(F.ConnectionClosed,"Request was cancelled");let _={...f,relatedRequestId:t.id};i&&!_.relatedTask&&(_.relatedTask={taskId:i});let b=_.relatedTask?.taskId??i;return b&&m&&await m.updateTaskStatus(b,"input_required"),await this.request(g,h,_)},authInfo:r?.authInfo,requestId:t.id,requestInfo:r?.requestInfo,taskId:i,taskStore:m,taskRequestedTtl:d?.ttl,closeSSEStream:r?.closeSSEStream,closeStandaloneSSEStream:r?.closeStandaloneSSEStream};(c??Promise.resolve()).then(()=>{if(c&&u.signal.aborted)throw new M(F.ConnectionClosed,"Request was cancelled");d&&this.assertTaskHandlerCapability(t.method)}).then(()=>a(t,p)).then(async g=>{if(u.signal.aborted)return;let h={result:g,jsonrpc:"2.0",id:t.id};i&&this._taskMessageQueue?await this._enqueueTaskMessage(i,{type:"response",message:h,timestamp:Date.now()},n?.sessionId):await n?.send(h)},async g=>{if(u.signal.aborted)return;let h={jsonrpc:"2.0",id:t.id,error:{code:Number.isSafeInteger(g.code)?g.code:F.InternalError,message:g.message??"Internal error",...g.data!==void 0&&{data:g.data}}};i&&this._taskMessageQueue&&l?await this._enqueueTaskMessage(i,{type:"error",message:h,timestamp:Date.now()},n?.sessionId):await n?.send(h)}).catch(g=>this._onerror(new Error(`Failed to send response: ${g}`))).finally(()=>{this._requestHandlerAbortControllers.get(t.id)===u&&this._requestHandlerAbortControllers.delete(t.id)})}_onprogress(t){let{progressToken:r,...a}=t.params,n=Number(r),i=this._progressHandlers.get(n);if(!i){this._onerror(new Error(`Received a progress notification for an unknown token: ${JSON.stringify(t)}`));return}let o=this._responseHandlers.get(n),s=this._timeoutInfo.get(n);if(s&&o&&s.resetTimeoutOnProgress)try{this._resetTimeout(n)}catch(l){this._responseHandlers.delete(n),this._progressHandlers.delete(n),this._cleanupTimeout(n),o(l);return}i(a)}_onresponse(t){let r=Number(t.id),a=this._requestResolvers.get(r);if(a){if(this._requestResolvers.delete(r),In(t))a(t);else{let o=new M(t.error.code,t.error.message,t.error.data);a(o)}return}let n=this._responseHandlers.get(r);if(n===void 0){this._onerror(new Error(`Received a response for an unknown message ID: ${JSON.stringify(t)}`));return}this._responseHandlers.delete(r),this._cleanupTimeout(r);let i=!1;if(In(t)&&t.result&&typeof t.result=="object"){let o=t.result;if(o.task&&typeof o.task=="object"){let s=o.task;typeof s.taskId=="string"&&(i=!0,this._taskProgressTokens.set(s.taskId,r))}}if(i||this._progressHandlers.delete(r),In(t))n(t);else{let o=M.fromError(t.error.code,t.error.message,t.error.data);n(o)}}get transport(){return this._transport}async close(){await this._transport?.close()}async*requestStream(t,r,a){let{task:n}=a??{};if(!n){try{yield{type:"result",result:await this.request(t,r,a)}}catch(o){yield{type:"error",error:o instanceof M?o:new M(F.InternalError,String(o))}}return}let i;try{let o=await this.request(t,vi,a);if(o.task)i=o.task.taskId,yield{type:"taskCreated",task:o.task};else throw new M(F.InternalError,"Task creation did not return a task");for(;;){let s=await this.getTask({taskId:i},a);if(yield{type:"taskStatus",task:s},_r(s.status)){s.status==="completed"?yield{type:"result",result:await this.getTaskResult({taskId:i},r,a)}:s.status==="failed"?yield{type:"error",error:new M(F.InternalError,`Task ${i} failed`)}:s.status==="cancelled"&&(yield{type:"error",error:new M(F.InternalError,`Task ${i} was cancelled`)});return}if(s.status==="input_required"){yield{type:"result",result:await this.getTaskResult({taskId:i},r,a)};return}let l=s.pollInterval??this._options?.defaultTaskPollInterval??1e3;await new Promise(c=>setTimeout(c,l)),a?.signal?.throwIfAborted()}}catch(o){yield{type:"error",error:o instanceof M?o:new M(F.InternalError,String(o))}}}request(t,r,a){let{relatedRequestId:n,resumptionToken:i,onresumptiontoken:o,task:s,relatedTask:l}=a??{};return new Promise((c,u)=>{let d=b=>{u(b)};if(!this._transport){d(new Error("Not connected"));return}if(this._options?.enforceStrictCapabilities===!0)try{this.assertCapabilityForMethod(t.method),s&&this.assertTaskCapability(t.method)}catch(b){d(b);return}a?.signal?.throwIfAborted();let m=this._requestMessageId++,p={...t,jsonrpc:"2.0",id:m};a?.onprogress&&(this._progressHandlers.set(m,a.onprogress),p.params={...t.params,_meta:{...t.params?._meta||{},progressToken:m}}),s&&(p.params={...p.params,task:s}),l&&(p.params={...p.params,_meta:{...p.params?._meta||{},[pr]:l}});let g=b=>{this._responseHandlers.delete(m),this._progressHandlers.delete(m),this._cleanupTimeout(m),this._transport?.send({jsonrpc:"2.0",method:"notifications/cancelled",params:{requestId:m,reason:String(b)}},{relatedRequestId:n,resumptionToken:i,onresumptiontoken:o}).catch(C=>this._onerror(new Error(`Failed to send cancellation: ${C}`)));let v=b instanceof M?b:new M(F.RequestTimeout,String(b));u(v)};this._responseHandlers.set(m,b=>{if(!a?.signal?.aborted){if(b instanceof Error)return u(b);try{let v=yr(r,b.result);v.success?c(v.data):u(v.error)}catch(v){u(v)}}}),a?.signal?.addEventListener("abort",()=>{g(a?.signal?.reason)});let h=a?.timeout??GM,f=()=>g(M.fromError(F.RequestTimeout,"Request timed out",{timeout:h}));this._setupTimeout(m,h,a?.maxTotalTimeout,f,a?.resetTimeoutOnProgress??!1);let _=l?.taskId;if(_){let b=v=>{let C=this._responseHandlers.get(m);C?C(v):this._onerror(new Error(`Response handler missing for side-channeled request ${m}`))};this._requestResolvers.set(m,b),this._enqueueTaskMessage(_,{type:"request",message:p,timestamp:Date.now()}).catch(v=>{this._cleanupTimeout(m),u(v)})}else this._transport.send(p,{relatedRequestId:n,resumptionToken:i,onresumptiontoken:o}).catch(b=>{this._cleanupTimeout(m),u(b)})})}async getTask(t,r){return this.request({method:"tasks/get",params:t},cp,r)}async getTaskResult(t,r,a){return this.request({method:"tasks/result",params:t},r,a)}async listTasks(t,r){return this.request({method:"tasks/list",params:t},pp,r)}async cancelTask(t,r){return this.request({method:"tasks/cancel",params:t},qx,r)}async notification(t,r){if(!this._transport)throw new Error("Not connected");this.assertNotificationCapability(t.method);let a=r?.relatedTask?.taskId;if(a){let s={...t,jsonrpc:"2.0",params:{...t.params,_meta:{...t.params?._meta||{},[pr]:r.relatedTask}}};await this._enqueueTaskMessage(a,{type:"notification",message:s,timestamp:Date.now()});return}if((this._options?.debouncedNotificationMethods??[]).includes(t.method)&&!t.params&&!r?.relatedRequestId&&!r?.relatedTask){if(this._pendingDebouncedNotifications.has(t.method))return;this._pendingDebouncedNotifications.add(t.method),Promise.resolve().then(()=>{if(this._pendingDebouncedNotifications.delete(t.method),!this._transport)return;let s={...t,jsonrpc:"2.0"};r?.relatedTask&&(s={...s,params:{...s.params,_meta:{...s.params?._meta||{},[pr]:r.relatedTask}}}),this._transport?.send(s,r).catch(l=>this._onerror(l))});return}let o={...t,jsonrpc:"2.0"};r?.relatedTask&&(o={...o,params:{...o.params,_meta:{...o.params?._meta||{},[pr]:r.relatedTask}}}),await this._transport.send(o,r)}setRequestHandler(t,r){let a=vy(t);this.assertRequestHandlerCapability(a),this._requestHandlers.set(a,(n,i)=>{let o=yy(t,n);return Promise.resolve(r(o,i))})}removeRequestHandler(t){this._requestHandlers.delete(t)}assertCanSetRequestHandler(t){if(this._requestHandlers.has(t))throw new Error(`A request handler for ${t} already exists, which would be overridden`)}setNotificationHandler(t,r){let a=vy(t);this._notificationHandlers.set(a,n=>{let i=yy(t,n);return Promise.resolve(r(i))})}removeNotificationHandler(t){this._notificationHandlers.delete(t)}_cleanupTaskProgressHandler(t){let r=this._taskProgressTokens.get(t);r!==void 0&&(this._progressHandlers.delete(r),this._taskProgressTokens.delete(t))}async _enqueueTaskMessage(t,r,a){if(!this._taskStore||!this._taskMessageQueue)throw new Error("Cannot enqueue task message: taskStore and taskMessageQueue are not configured");let n=this._options?.maxTaskQueueSize;await this._taskMessageQueue.enqueue(t,r,a??this._transport?.sessionId,n)}async _clearTaskQueue(t,r){if(this._taskMessageQueue){let a=await this._taskMessageQueue.dequeueAll(t,r);for(let n of a)if(n.type==="request"&&zn(n.message)){let i=n.message.id,o=this._requestResolvers.get(i);o?(o(new M(F.InternalError,"Task cancelled or completed")),this._requestResolvers.delete(i)):this._onerror(new Error(`Resolver missing for request ${i} during task ${t} cleanup`))}}}async _waitForTaskUpdate(t,r,a){let n=this._options?.defaultTaskPollInterval??1e3;try{let i=await this._taskStore?.getTask(t,a);i?.pollInterval&&(n=i.pollInterval)}catch{}return new Promise((i,o)=>{if(r.aborted){o(new M(F.InvalidRequest,"Request cancelled"));return}let s=setTimeout(i,n);r.addEventListener("abort",()=>{clearTimeout(s),o(new M(F.InvalidRequest,"Request cancelled"))},{once:!0})})}requestTaskStore(t,r){let a=this._taskStore;if(!a)throw new Error("No task store configured");return{createTask:async n=>{if(!t)throw new Error("No request provided");return await a.createTask(n,t.id,{method:t.method,params:t.params},r)},getTask:async n=>{let i=await a.getTask(n,r);if(!i)throw new M(F.InvalidParams,"Failed to retrieve task: Task not found");return i},storeTaskResult:async(n,i,o)=>{await a.storeTaskResult(n,i,o,r);let s=await a.getTask(n,r);if(s){let l=Os.parse({method:"notifications/tasks/status",params:s});await this.notification(l),_r(s.status)&&this._cleanupTaskProgressHandler(n)}},getTaskResult:n=>a.getTaskResult(n,r),updateTaskStatus:async(n,i,o)=>{let s=await a.getTask(n,r);if(!s)throw new M(F.InvalidParams,`Task "${n}" not found - it may have been cleaned up`);if(_r(s.status))throw new M(F.InvalidParams,`Cannot update task "${n}" from terminal status "${s.status}" to "${i}". Terminal states (completed, failed, cancelled) cannot transition to other states.`);await a.updateTaskStatus(n,i,o,r);let l=await a.getTask(n,r);if(l){let c=Os.parse({method:"notifications/tasks/status",params:l});await this.notification(c),_r(l.status)&&this._cleanupTaskProgressHandler(n)}},listTasks:n=>a.listTasks(n,r)}}};function MC(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function LC(e,t){let r={...e};for(let a in t){let n=a,i=t[n];if(i===void 0)continue;let o=r[n];MC(o)&&MC(i)?r[n]={...o,...i}:r[n]=i}return r}var MP=ng(d_(),1),LP=ng(DP(),1);function nq(){let e=new MP.default({strict:!1,validateFormats:!0,validateSchema:!1,allErrors:!0});return(0,LP.default)(e),e}var Zm=class{constructor(t){this._ajv=t??nq()}getValidator(t){let r="$id"in t&&typeof t.$id=="string"?this._ajv.getSchema(t.$id)??this._ajv.compile(t):this._ajv.compile(t);return a=>r(a)?{valid:!0,data:a,errorMessage:void 0}:{valid:!1,data:void 0,errorMessage:this._ajv.errorsText(r.errors)}}};var Jm=class{constructor(t){this._server=t}requestStream(t,r,a){return this._server.requestStream(t,r,a)}createMessageStream(t,r){let a=this._server.getClientCapabilities();if((t.tools||t.toolChoice)&&!a?.sampling?.tools)throw new Error("Client does not support sampling tools capability.");if(t.messages.length>0){let n=t.messages[t.messages.length-1],i=Array.isArray(n.content)?n.content:[n.content],o=i.some(u=>u.type==="tool_result"),s=t.messages.length>1?t.messages[t.messages.length-2]:void 0,l=s?Array.isArray(s.content)?s.content:[s.content]:[],c=l.some(u=>u.type==="tool_use");if(o){if(i.some(u=>u.type!=="tool_result"))throw new Error("The last message must contain only tool_result content if any is present");if(!c)throw new Error("tool_result blocks are not matching any tool_use from the previous message")}if(c){let u=new Set(l.filter(m=>m.type==="tool_use").map(m=>m.id)),d=new Set(i.filter(m=>m.type==="tool_result").map(m=>m.toolUseId));if(u.size!==d.size||![...u].every(m=>d.has(m)))throw new Error("ids of tool_result blocks and tool_use blocks from previous message do not match")}}return this.requestStream({method:"sampling/createMessage",params:t},Ms,r)}elicitInputStream(t,r){let a=this._server.getClientCapabilities(),n=t.mode??"form";switch(n){case"url":{if(!a?.elicitation?.url)throw new Error("Client does not support url elicitation.");break}case"form":{if(!a?.elicitation?.form)throw new Error("Client does not support form elicitation.");break}}let i=n==="form"&&t.mode===void 0?{...t,mode:"form"}:t;return this.requestStream({method:"elicitation/create",params:i},_i,r)}async getTask(t,r){return this._server.getTask({taskId:t},r)}async getTaskResult(t,r,a){return this._server.getTaskResult({taskId:t},r,a)}async listTasks(t,r){return this._server.listTasks(t?{cursor:t}:void 0,r)}async cancelTask(t,r){return this._server.cancelTask({taskId:t},r)}};function BP(e,t,r){if(!e)throw new Error(`${r} does not support task creation (required for ${t})`);switch(t){case"tools/call":if(!e.tools?.call)throw new Error(`${r} does not support task creation for tools/call (required for ${t})`);break;default:break}}function UP(e,t,r){if(!e)throw new Error(`${r} does not support task creation (required for ${t})`);switch(t){case"sampling/createMessage":if(!e.sampling?.createMessage)throw new Error(`${r} does not support task creation for sampling/createMessage (required for ${t})`);break;case"elicitation/create":if(!e.elicitation?.create)throw new Error(`${r} does not support task creation for elicitation/create (required for ${t})`);break;default:break}}var Ym=class extends pm{constructor(t,r){super(r),this._serverInfo=t,this._loggingLevels=new Map,this.LOG_LEVEL_SEVERITY=new Map(Ds.options.map((a,n)=>[a,n])),this.isMessageIgnored=(a,n)=>{let i=this._loggingLevels.get(n);return i?this.LOG_LEVEL_SEVERITY.get(a)<this.LOG_LEVEL_SEVERITY.get(i):!1},this._capabilities=r?.capabilities??{},this._instructions=r?.instructions,this._jsonSchemaValidator=r?.jsonSchemaValidator??new Zm,this.setRequestHandler(ip,a=>this._oninitialize(a)),this.setNotificationHandler(Qb,()=>this.oninitialized?.()),this._capabilities.logging&&this.setRequestHandler(ov,async(a,n)=>{let i=n.sessionId||n.requestInfo?.headers["mcp-session-id"]||void 0,{level:o}=a.params,s=Ds.safeParse(o);return s.success&&this._loggingLevels.set(i,s.data),{}})}get experimental(){return this._experimental||(this._experimental={tasks:new Jm(this)}),this._experimental}registerCapabilities(t){if(this.transport)throw new Error("Cannot register capabilities after connecting to transport");this._capabilities=LC(this._capabilities,t)}setRequestHandler(t,r){let n=kr(t)?.method;if(!n)throw new Error("Schema is missing a method literal");let i=Vi(n);if(typeof i!="string")throw new Error("Schema method literal must be a string");if(i==="tools/call"){let s=async(l,c)=>{let u=yr(ki,l);if(!u.success){let g=u.error instanceof Error?u.error.message:String(u.error);throw new M(F.InvalidParams,`Invalid tools/call request: ${g}`)}let{params:d}=u.data,m=await Promise.resolve(r(l,c));if(d.task){let g=yr(vi,m);if(!g.success){let h=g.error instanceof Error?g.error.message:String(g.error);throw new M(F.InvalidParams,`Invalid task creation result: ${h}`)}return g.data}let p=yr(kp,m);if(!p.success){let g=p.error instanceof Error?p.error.message:String(p.error);throw new M(F.InvalidParams,`Invalid tools/call result: ${g}`)}return p.data};return super.setRequestHandler(t,s)}return super.setRequestHandler(t,r)}assertCapabilityForMethod(t){switch(t){case"sampling/createMessage":if(!this._clientCapabilities?.sampling)throw new Error(`Client does not support sampling (required for ${t})`);break;case"elicitation/create":if(!this._clientCapabilities?.elicitation)throw new Error(`Client does not support elicitation (required for ${t})`);break;case"roots/list":if(!this._clientCapabilities?.roots)throw new Error(`Client does not support listing roots (required for ${t})`);break;case"ping":break}}assertNotificationCapability(t){switch(t){case"notifications/message":if(!this._capabilities.logging)throw new Error(`Server does not support logging (required for ${t})`);break;case"notifications/resources/updated":case"notifications/resources/list_changed":if(!this._capabilities.resources)throw new Error(`Server does not support notifying about resources (required for ${t})`);break;case"notifications/tools/list_changed":if(!this._capabilities.tools)throw new Error(`Server does not support notifying of tool list changes (required for ${t})`);break;case"notifications/prompts/list_changed":if(!this._capabilities.prompts)throw new Error(`Server does not support notifying of prompt list changes (required for ${t})`);break;case"notifications/elicitation/complete":if(!this._clientCapabilities?.elicitation?.url)throw new Error(`Client does not support URL elicitation (required for ${t})`);break;case"notifications/cancelled":break;case"notifications/progress":break}}assertRequestHandlerCapability(t){if(this._capabilities)switch(t){case"completion/complete":if(!this._capabilities.completions)throw new Error(`Server does not support completions (required for ${t})`);break;case"logging/setLevel":if(!this._capabilities.logging)throw new Error(`Server does not support logging (required for ${t})`);break;case"prompts/get":case"prompts/list":if(!this._capabilities.prompts)throw new Error(`Server does not support prompts (required for ${t})`);break;case"resources/list":case"resources/templates/list":case"resources/read":if(!this._capabilities.resources)throw new Error(`Server does not support resources (required for ${t})`);break;case"tools/call":case"tools/list":if(!this._capabilities.tools)throw new Error(`Server does not support tools (required for ${t})`);break;case"tasks/get":case"tasks/list":case"tasks/result":case"tasks/cancel":if(!this._capabilities.tasks)throw new Error(`Server does not support tasks capability (required for ${t})`);break;case"ping":case"initialize":break}}assertTaskCapability(t){UP(this._clientCapabilities?.tasks?.requests,t,"Client")}assertTaskHandlerCapability(t){this._capabilities&&BP(this._capabilities.tasks?.requests,t,"Server")}async _oninitialize(t){let r=t.params.protocolVersion;return this._clientCapabilities=t.params.capabilities,this._clientVersion=t.params.clientInfo,{protocolVersion:fi.includes(r)?r:Kb,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"},rp)}async createMessage(t,r){if((t.tools||t.toolChoice)&&!this._clientCapabilities?.sampling?.tools)throw new Error("Client does not support sampling tools capability.");if(t.messages.length>0){let a=t.messages[t.messages.length-1],n=Array.isArray(a.content)?a.content:[a.content],i=n.some(c=>c.type==="tool_result"),o=t.messages.length>1?t.messages[t.messages.length-2]:void 0,s=o?Array.isArray(o.content)?o.content:[o.content]:[],l=s.some(c=>c.type==="tool_use");if(i){if(n.some(c=>c.type!=="tool_result"))throw new Error("The last message must contain only tool_result content if any is present");if(!l)throw new Error("tool_result blocks are not matching any tool_use from the previous message")}if(l){let c=new Set(s.filter(d=>d.type==="tool_use").map(d=>d.id)),u=new Set(n.filter(d=>d.type==="tool_result").map(d=>d.toolUseId));if(c.size!==u.size||![...c].every(d=>u.has(d)))throw new Error("ids of tool_result blocks and tool_use blocks from previous message do not match")}}return t.tools?this.request({method:"sampling/createMessage",params:t},sv,r):this.request({method:"sampling/createMessage",params:t},Ms,r)}async elicitInput(t,r){switch(t.mode??"form"){case"url":{if(!this._clientCapabilities?.elicitation?.url)throw new Error("Client does not support url elicitation.");let n=t;return this.request({method:"elicitation/create",params:n},_i,r)}case"form":{if(!this._clientCapabilities?.elicitation?.form)throw new Error("Client does not support form elicitation.");let n=t.mode==="form"?t:{...t,mode:"form"},i=await this.request({method:"elicitation/create",params:n},_i,r);if(i.action==="accept"&&i.content&&n.requestedSchema)try{let s=this._jsonSchemaValidator.getValidator(n.requestedSchema)(i.content);if(!s.valid)throw new M(F.InvalidParams,`Elicitation response content does not match requested schema: ${s.errorMessage}`)}catch(o){throw o instanceof M?o:new M(F.InternalError,`Error validating elicitation response: ${o instanceof Error?o.message:String(o)}`)}return i}}}createElicitationCompletionNotifier(t,r){if(!this._clientCapabilities?.elicitation?.url)throw new Error("Client does not support URL elicitation (required for notifications/elicitation/complete)");return()=>this.notification({method:"notifications/elicitation/complete",params:{elicitationId:t}},r)}async listRoots(t,r){return this.request({method:"roots/list",params:t},lv,r)}async sendLoggingMessage(t,r){if(this._capabilities.logging&&!this.isMessageIgnored(t.level,r))return this.notification({method:"notifications/message",params:t})}async sendResourceUpdated(t){return this.notification({method:"notifications/resources/updated",params:t})}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"})}};var qP=Symbol.for("mcp.completable");function y_(e){return!!e&&typeof e=="object"&&qP in e}function HP(e){return e[qP]?.complete}var FP;(function(e){e.Completable="McpCompletable"})(FP||(FP={}));var rq=/^[A-Za-z0-9._-]{1,128}$/;function aq(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"),!rq.test(e)){let r=e.split("").filter(a=>!/[A-Za-z0-9._-]/.test(a)).filter((a,n,i)=>i.indexOf(a)===n);return t.push(`Tool name contains invalid characters: ${r.map(a=>`"${a}"`).join(", ")}`,"Allowed characters are: A-Z, a-z, 0-9, underscore (_), dash (-), and dot (.)"),{isValid:!1,warnings:t}}return{isValid:!0,warnings:t}}function iq(e,t){if(t.length>0){console.warn(`Tool name validation warning for "${e}":`);for(let r of t)console.warn(` - ${r}`);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 k_(e){let t=aq(e);return iq(e,t.warnings),t.isValid}var Xm=class{constructor(t){this._mcpServer=t}registerToolTask(t,r,a){let n={taskSupport:"required",...r.execution};if(n.taskSupport==="forbidden")throw new Error(`Cannot register task-based tool '${t}' with taskSupport 'forbidden'. Use registerTool() instead.`);return this._mcpServer._createRegisteredTool(t,r.title,r.description,r.inputSchema,r.outputSchema,r.annotations,n,r._meta,a)}};function oq(e,t){let r=0,a=[e];for(;a.length>0;){let n=a.pop();if(!(n===null||typeof n!="object"))if(Array.isArray(n))for(let i of n){if(++r>t)return r;i!==null&&typeof i=="object"&&a.push(i)}else for(let i in n){if(!Object.prototype.hasOwnProperty.call(n,i))continue;if(++r>t)return r;let o=n[i];o!==null&&typeof o=="object"&&a.push(o)}}return r}function sq(e){if(!(e===void 0||e===1/0)){if(typeof e!="number"||Number.isNaN(e)||e<1)throw new RangeError(`maxToolInputElements must be a number of at least 1, or Infinity, got ${String(e)}`);return e}}var Qm=class{constructor(t,r){this._registeredResources={},this._registeredResourceTemplates={},this._registeredTools={},this._registeredPrompts={},this._toolHandlersInitialized=!1,this._completionHandlerInitialized=!1,this._resourceHandlersInitialized=!1,this._promptHandlersInitialized=!1,this.server=new Ym(t,r),this._maxToolInputElements=sq(r?.maxToolInputElements)}get experimental(){return this._experimental||(this._experimental={tasks:new Xm(this)}),this._experimental}async connect(t){return await this.server.connect(t)}async close(){await this.server.close()}setToolRequestHandlers(){this._toolHandlersInitialized||(this.server.assertCanSetRequestHandler(Ir(yp)),this.server.assertCanSetRequestHandler(Ir(ki)),this.server.registerCapabilities({tools:{listChanged:!0}}),this.server.setRequestHandler(yp,()=>({tools:Object.entries(this._registeredTools).filter(([,t])=>t.enabled).map(([t,r])=>{let a={name:t,title:r.title,description:r.description,inputSchema:(()=>{let n=Gi(r.inputSchema);return n?by(n,{strictUnions:!0,pipeStrategy:"input"}):lq})(),annotations:r.annotations,execution:r.execution,_meta:r._meta};if(r.outputSchema){let n=Gi(r.outputSchema);n&&(a.outputSchema=by(n,{strictUnions:!0,pipeStrategy:"output"}))}return a})})),this.server.setRequestHandler(ki,async(t,r)=>{try{let a=this._registeredTools[t.params.name];if(!a)throw new M(F.InvalidParams,`Tool ${t.params.name} not found`);if(!a.enabled)throw new M(F.InvalidParams,`Tool ${t.params.name} disabled`);let n=!!t.params.task,i=a.execution?.taskSupport,o="createTask"in a.handler;if((i==="required"||i==="optional")&&!o)throw new M(F.InternalError,`Tool ${t.params.name} has taskSupport '${i}' but was not registered with registerToolTask`);if(i==="required"&&!n)throw new M(F.MethodNotFound,`Tool ${t.params.name} requires task augmentation (taskSupport: 'required')`);if(i==="optional"&&!n&&o)return await this.handleAutomaticTaskPolling(a,t,r);let s=await this.validateToolInput(a,t.params.arguments,t.params.name),l=await this.executeToolHandler(a,s,r);return n||await this.validateToolOutput(a,l,t.params.name),l}catch(a){if(a instanceof M&&a.code===F.UrlElicitationRequired)throw a;return this.createToolError(a instanceof Error?a.message:String(a))}}),this._toolHandlersInitialized=!0)}createToolError(t){return{content:[{type:"text",text:t}],isError:!0}}async validateToolInput(t,r,a){if(this._maxToolInputElements!==void 0&&oq(r,this._maxToolInputElements)>this._maxToolInputElements)throw new M(F.InvalidParams,`Invalid arguments for tool ${a}: arguments contain more than the maximum of ${this._maxToolInputElements} elements`);if(!t.inputSchema)return;let i=Gi(t.inputSchema)??t.inputSchema,o=await om(i,r??{});if(!o.success){let s="error"in o?o.error:"Unknown error",l=sm(s);throw new M(F.InvalidParams,`Input validation error: Invalid arguments for tool ${a}: ${l}`)}return o.data}async validateToolOutput(t,r,a){if(!t.outputSchema||!("content"in r)||r.isError)return;if(!r.structuredContent)throw new M(F.InvalidParams,`Output validation error: Tool ${a} has an output schema but no structured content was provided`);let n=Gi(t.outputSchema),i=await om(n,r.structuredContent);if(!i.success){let o="error"in i?i.error:"Unknown error",s=sm(o);throw new M(F.InvalidParams,`Output validation error: Invalid structured content for tool ${a}: ${s}`)}}async executeToolHandler(t,r,a){let n=t.handler;if("createTask"in n){if(!a.taskStore)throw new Error("No task store provided.");let o={...a,taskStore:a.taskStore};if(t.inputSchema){let s=n;return await Promise.resolve(s.createTask(r,o))}else{let s=n;return await Promise.resolve(s.createTask(o))}}if(t.inputSchema){let o=n;return await Promise.resolve(o(r,a))}else{let o=n;return await Promise.resolve(o(a))}}async handleAutomaticTaskPolling(t,r,a){if(!a.taskStore)throw new Error("No task store provided for task-capable tool.");let n=await this.validateToolInput(t,r.params.arguments,r.params.name),i=t.handler,o={...a,taskStore:a.taskStore},s=n?await Promise.resolve(i.createTask(n,o)):await Promise.resolve(i.createTask(o)),l=s.task.taskId,c=s.task,u=c.pollInterval??5e3;for(;c.status!=="completed"&&c.status!=="failed"&&c.status!=="cancelled";){await new Promise(m=>setTimeout(m,u));let d=await a.taskStore.getTask(l);if(!d)throw new M(F.InternalError,`Task ${l} not found during polling`);c=d}return await a.taskStore.getTaskResult(l)}setCompletionRequestHandler(){this._completionHandlerInitialized||(this.server.assertCanSetRequestHandler(Ir(_p)),this.server.registerCapabilities({completions:{}}),this.server.setRequestHandler(_p,async t=>{switch(t.params.ref.type){case"ref/prompt":return Zx(t),this.handlePromptCompletion(t,t.params.ref);case"ref/resource":return Jx(t),this.handleResourceCompletion(t,t.params.ref);default:throw new M(F.InvalidParams,`Invalid completion reference: ${t.params.ref}`)}}),this._completionHandlerInitialized=!0)}async handlePromptCompletion(t,r){let a=this._registeredPrompts[r.name];if(!a)throw new M(F.InvalidParams,`Prompt ${r.name} not found`);if(!a.enabled)throw new M(F.InvalidParams,`Prompt ${r.name} disabled`);if(!a.argsSchema)return ql;let i=kr(a.argsSchema)?.[t.params.argument.name];if(!y_(i))return ql;let o=HP(i);if(!o)return ql;let s=await o(t.params.argument.value,t.params.context);return VP(s)}async handleResourceCompletion(t,r){let a=Object.values(this._registeredResourceTemplates).find(o=>o.resourceTemplate.uriTemplate.toString()===r.uri);if(!a){if(this._registeredResources[r.uri])return ql;throw new M(F.InvalidParams,`Resource template ${t.params.ref.uri} not found`)}let n=a.resourceTemplate.completeCallback(t.params.argument.name);if(!n)return ql;let i=await n(t.params.argument.value,t.params.context);return VP(i)}setResourceRequestHandlers(){this._resourceHandlersInitialized||(this.server.assertCanSetRequestHandler(Ir(gp)),this.server.assertCanSetRequestHandler(Ir(hp)),this.server.assertCanSetRequestHandler(Ir(fp)),this.server.registerCapabilities({resources:{listChanged:!0}}),this.server.setRequestHandler(gp,async(t,r)=>{let a=Object.entries(this._registeredResources).filter(([i,o])=>o.enabled).map(([i,o])=>({uri:i,name:o.name,...o.metadata})),n=[];for(let i of Object.values(this._registeredResourceTemplates)){if(!i.resourceTemplate.listCallback)continue;let o=await i.resourceTemplate.listCallback(r);for(let s of o.resources)n.push({...i.metadata,...s})}return{resources:[...a,...n]}}),this.server.setRequestHandler(hp,async()=>({resourceTemplates:Object.entries(this._registeredResourceTemplates).map(([r,a])=>({name:r,uriTemplate:a.resourceTemplate.uriTemplate.toString(),...a.metadata}))})),this.server.setRequestHandler(fp,async(t,r)=>{let a=new URL(t.params.uri),n=this._registeredResources[a.toString()];if(n){if(!n.enabled)throw new M(F.InvalidParams,`Resource ${a} disabled`);return n.readCallback(a,r)}for(let i of Object.values(this._registeredResourceTemplates)){let o=i.resourceTemplate.uriTemplate.match(a.toString());if(o)return i.readCallback(a,o,r)}throw new M(F.InvalidParams,`Resource ${a} not found`)}),this._resourceHandlersInitialized=!0)}setPromptRequestHandlers(){this._promptHandlersInitialized||(this.server.assertCanSetRequestHandler(Ir(bp)),this.server.assertCanSetRequestHandler(Ir(vp)),this.server.registerCapabilities({prompts:{listChanged:!0}}),this.server.setRequestHandler(bp,()=>({prompts:Object.entries(this._registeredPrompts).filter(([,t])=>t.enabled).map(([t,r])=>({name:t,title:r.title,description:r.description,arguments:r.argsSchema?cq(r.argsSchema):void 0}))})),this.server.setRequestHandler(vp,async(t,r)=>{let a=this._registeredPrompts[t.params.name];if(!a)throw new M(F.InvalidParams,`Prompt ${t.params.name} not found`);if(!a.enabled)throw new M(F.InvalidParams,`Prompt ${t.params.name} disabled`);if(a.argsSchema){let n=Gi(a.argsSchema),i=await om(n,t.params.arguments??{});if(!i.success){let l="error"in i?i.error:"Unknown error",c=sm(l);throw new M(F.InvalidParams,`Invalid arguments for prompt ${t.params.name}: ${c}`)}let o=i.data,s=a.callback;return await Promise.resolve(s(o,r))}else{let n=a.callback;return await Promise.resolve(n(r))}}),this._promptHandlersInitialized=!0)}resource(t,r,...a){let n;typeof a[0]=="object"&&(n=a.shift());let i=a[0];if(typeof r=="string"){if(this._registeredResources[r])throw new Error(`Resource ${r} is already registered`);let o=this._createRegisteredResource(t,void 0,r,n,i);return this.setResourceRequestHandlers(),this.sendResourceListChanged(),o}else{if(this._registeredResourceTemplates[t])throw new Error(`Resource template ${t} is already registered`);let o=this._createRegisteredResourceTemplate(t,void 0,r,n,i);return this.setResourceRequestHandlers(),this.sendResourceListChanged(),o}}registerResource(t,r,a,n){if(typeof r=="string"){if(this._registeredResources[r])throw new Error(`Resource ${r} is already registered`);let i=this._createRegisteredResource(t,a.title,r,a,n);return this.setResourceRequestHandlers(),this.sendResourceListChanged(),i}else{if(this._registeredResourceTemplates[t])throw new Error(`Resource template ${t} is already registered`);let i=this._createRegisteredResourceTemplate(t,a.title,r,a,n);return this.setResourceRequestHandlers(),this.sendResourceListChanged(),i}}_createRegisteredResource(t,r,a,n,i){let o={name:t,title:r,metadata:n,readCallback:i,enabled:!0,disable:()=>o.update({enabled:!1}),enable:()=>o.update({enabled:!0}),remove:()=>o.update({uri:null}),update:s=>{typeof s.uri<"u"&&s.uri!==a&&(delete this._registeredResources[a],s.uri&&(this._registeredResources[s.uri]=o)),typeof s.name<"u"&&(o.name=s.name),typeof s.title<"u"&&(o.title=s.title),typeof s.metadata<"u"&&(o.metadata=s.metadata),typeof s.callback<"u"&&(o.readCallback=s.callback),typeof s.enabled<"u"&&(o.enabled=s.enabled),this.sendResourceListChanged()}};return this._registeredResources[a]=o,o}_createRegisteredResourceTemplate(t,r,a,n,i){let o={resourceTemplate:a,title:r,metadata:n,readCallback:i,enabled:!0,disable:()=>o.update({enabled:!1}),enable:()=>o.update({enabled:!0}),remove:()=>o.update({name:null}),update:c=>{typeof c.name<"u"&&c.name!==t&&(delete this._registeredResourceTemplates[t],c.name&&(this._registeredResourceTemplates[c.name]=o)),typeof c.title<"u"&&(o.title=c.title),typeof c.template<"u"&&(o.resourceTemplate=c.template),typeof c.metadata<"u"&&(o.metadata=c.metadata),typeof c.callback<"u"&&(o.readCallback=c.callback),typeof c.enabled<"u"&&(o.enabled=c.enabled),this.sendResourceListChanged()}};this._registeredResourceTemplates[t]=o;let s=a.uriTemplate.variableNames;return Array.isArray(s)&&s.some(c=>!!a.completeCallback(c))&&this.setCompletionRequestHandler(),o}_createRegisteredPrompt(t,r,a,n,i){let o={title:r,description:a,argsSchema:n===void 0?void 0:aa(n),callback:i,enabled:!0,disable:()=>o.update({enabled:!1}),enable:()=>o.update({enabled:!0}),remove:()=>o.update({name:null}),update:s=>{typeof s.name<"u"&&s.name!==t&&(delete this._registeredPrompts[t],s.name&&(this._registeredPrompts[s.name]=o)),typeof s.title<"u"&&(o.title=s.title),typeof s.description<"u"&&(o.description=s.description),typeof s.argsSchema<"u"&&(o.argsSchema=aa(s.argsSchema)),typeof s.callback<"u"&&(o.callback=s.callback),typeof s.enabled<"u"&&(o.enabled=s.enabled),this.sendPromptListChanged()}};return this._registeredPrompts[t]=o,n&&Object.values(n).some(l=>{let c=l instanceof Kr?l._def?.innerType:l;return y_(c)})&&this.setCompletionRequestHandler(),o}_createRegisteredTool(t,r,a,n,i,o,s,l,c){k_(t);let u={title:r,description:a,inputSchema:GP(n),outputSchema:GP(i),annotations:o,execution:s,_meta:l,handler:c,enabled:!0,disable:()=>u.update({enabled:!1}),enable:()=>u.update({enabled:!0}),remove:()=>u.update({name:null}),update:d=>{typeof d.name<"u"&&d.name!==t&&(typeof d.name=="string"&&k_(d.name),delete this._registeredTools[t],d.name&&(this._registeredTools[d.name]=u)),typeof d.title<"u"&&(u.title=d.title),typeof d.description<"u"&&(u.description=d.description),typeof d.paramsSchema<"u"&&(u.inputSchema=aa(d.paramsSchema)),typeof d.outputSchema<"u"&&(u.outputSchema=aa(d.outputSchema)),typeof d.callback<"u"&&(u.handler=d.callback),typeof d.annotations<"u"&&(u.annotations=d.annotations),typeof d._meta<"u"&&(u._meta=d._meta),typeof d.enabled<"u"&&(u.enabled=d.enabled),this.sendToolListChanged()}};return this._registeredTools[t]=u,this.setToolRequestHandlers(),this.sendToolListChanged(),u}tool(t,...r){if(this._registeredTools[t])throw new Error(`Tool ${t} is already registered`);let a,n,i,o;if(typeof r[0]=="string"&&(a=r.shift()),r.length>1){let l=r[0];if(__(l))n=r.shift(),r.length>1&&typeof r[0]=="object"&&r[0]!==null&&!__(r[0])&&(o=r.shift());else if(typeof l=="object"&&l!==null){if(Object.values(l).some(c=>typeof c=="object"&&c!==null))throw new Error(`Tool ${t} expected a Zod schema or ToolAnnotations, but received an unrecognized object`);o=r.shift()}}let s=r[0];return this._createRegisteredTool(t,void 0,a,n,i,o,{taskSupport:"forbidden"},void 0,s)}registerTool(t,r,a){if(this._registeredTools[t])throw new Error(`Tool ${t} is already registered`);let{title:n,description:i,inputSchema:o,outputSchema:s,annotations:l,_meta:c}=r;return this._createRegisteredTool(t,n,i,o,s,l,{taskSupport:"forbidden"},c,a)}prompt(t,...r){if(this._registeredPrompts[t])throw new Error(`Prompt ${t} is already registered`);let a;typeof r[0]=="string"&&(a=r.shift());let n;r.length>1&&(n=r.shift());let i=r[0],o=this._createRegisteredPrompt(t,void 0,a,n,i);return this.setPromptRequestHandlers(),this.sendPromptListChanged(),o}registerPrompt(t,r,a){if(this._registeredPrompts[t])throw new Error(`Prompt ${t} is already registered`);let{title:n,description:i,argsSchema:o}=r,s=this._createRegisteredPrompt(t,n,i,o,a);return this.setPromptRequestHandlers(),this.sendPromptListChanged(),s}isConnected(){return this.server.transport!==void 0}async sendLoggingMessage(t,r){return this.server.sendLoggingMessage(t,r)}sendResourceListChanged(){this.isConnected()&&this.server.sendResourceListChanged()}sendToolListChanged(){this.isConnected()&&this.server.sendToolListChanged()}sendPromptListChanged(){this.isConnected()&&this.server.sendPromptListChanged()}};var lq={type:"object",properties:{}};function WP(e){return e!==null&&typeof e=="object"&&"parse"in e&&typeof e.parse=="function"&&"safeParse"in e&&typeof e.safeParse=="function"}function KP(e){return"_def"in e||"_zod"in e||WP(e)}function __(e){return typeof e!="object"||e===null||KP(e)?!1:Object.keys(e).length===0?!0:Object.values(e).some(WP)}function GP(e){if(e){if(__(e))return aa(e);if(!KP(e))throw new Error("inputSchema must be a Zod schema or raw shape, received an unrecognized object");return e}}function cq(e){let t=kr(e);return t?Object.entries(t).map(([r,a])=>{let n=aC(a),i=iC(a);return{name:r,description:n,required:!i}}):[]}function Ir(e){let r=kr(e)?.method;if(!r)throw new Error("Schema is missing a method literal");let a=Vi(r);if(typeof a=="string")return a;throw new Error("Schema method literal must be a string")}function VP(e){return{completion:{values:e.slice(0,100),total:e.length,hasMore:e.length>100}}}var ql={completion:{values:[],hasMore:!1}};var JP="ui://token-lens/card.html",YP="ui://token-lens/card-openai.html",uq="text/html;profile=mcp-app",dq="text/html+skybridge",eg=(e,t)=>({ui:{resourceUri:JP},"openai/outputTemplate":YP,"openai/toolInvocation/invoking":e,"openai/toolInvocation/invoked":t,"openai/widgetAccessible":!0}),ZP={ui:{prefersBorder:!0,csp:{connectDomains:[],resourceDomains:[]},permissions:{clipboardWrite:{}}},"openai/widgetPrefersBorder":!0,"openai/widgetDescription":"Shows the shorter prompt with a Copy button, the tokens and money saved, and what Token Lens checked was kept. The user can read it; don't repeat the shorter prompt in full."};function XP(e){for(let[t,r,a]of[["token-lens-card",JP,uq],["token-lens-card-openai",YP,dq]])e.registerResource(t,r,{title:"Token Lens card",description:"Token Lens results inside the chat.",mimeType:a,_meta:ZP},async()=>({contents:[{uri:r,mimeType:a,text:pq,_meta:ZP}]}))}var pq=`<!doctype html>
|
|
3563
|
+
]`;continue}n+=a[l],a[l]==="\\"?i=!0:o&&a[l]==="]"?o=!1:!o&&a[l]==="["&&(o=!0)}try{new RegExp(n)}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 n}function dm(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===I.ZodEnum)return{type:"object",required:e.keyType._def.values,properties:e.keyType._def.values.reduce((a,n)=>({...a,[n]:K(e.valueType._def,{...t,currentPath:[...t.currentPath,"properties",n]})??je(t)}),{}),additionalProperties:t.rejectedAdditionalProperties};let r={type:"object",additionalProperties:K(e.valueType._def,{...t,currentPath:[...t.currentPath,"additionalProperties"]})??t.allowedAdditionalProperties};if(t.target==="openApi3")return r;if(e.keyType?._def.typeName===I.ZodString&&e.keyType._def.checks?.length){let{type:a,...n}=um(e.keyType._def,t);return{...r,propertyNames:n}}else{if(e.keyType?._def.typeName===I.ZodEnum)return{...r,propertyNames:{enum:e.keyType._def.values}};if(e.keyType?._def.typeName===I.ZodBranded&&e.keyType._def.type._def.typeName===I.ZodString&&e.keyType._def.type._def.checks?.length){let{type:a,...n}=cm(e.keyType._def,t);return{...r,propertyNames:n}}}return r}function kC(e,t){if(t.mapStrategy==="record")return dm(e,t);let r=K(e.keyType._def,{...t,currentPath:[...t.currentPath,"items","items","0"]})||je(t),a=K(e.valueType._def,{...t,currentPath:[...t.currentPath,"items","items","1"]})||je(t);return{type:"array",maxItems:125,items:{type:"array",items:[r,a],minItems:2,maxItems:2}}}function _C(e){let t=e.values,a=Object.keys(e.values).filter(i=>typeof t[t[i]]!="number").map(i=>t[i]),n=Array.from(new Set(a.map(i=>typeof i)));return{type:n.length===1?n[0]==="string"?"string":"number":["string","number"],enum:a}}function wC(e){return e.target==="openAi"?void 0:{not:je({...e,currentPath:[...e.currentPath,"not"]})}}function SC(e){return e.target==="openApi3"?{enum:["null"],nullable:!0}:{type:"null"}}var pl={ZodString:"string",ZodNumber:"number",ZodBigInt:"integer",ZodBoolean:"boolean",ZodNull:"null"};function xC(e,t){if(t.target==="openApi3")return EC(e,t);let r=e.options instanceof Map?Array.from(e.options.values()):e.options;if(r.every(a=>a._def.typeName in pl&&(!a._def.checks||!a._def.checks.length))){let a=r.reduce((n,i)=>{let o=pl[i._def.typeName];return o&&!n.includes(o)?[...n,o]:n},[]);return{type:a.length>1?a:a[0]}}else if(r.every(a=>a._def.typeName==="ZodLiteral"&&!a.description)){let a=r.reduce((n,i)=>{let o=typeof i._def.value;switch(o){case"string":case"number":case"boolean":return[...n,o];case"bigint":return[...n,"integer"];case"object":if(i._def.value===null)return[...n,"null"];default:return n}},[]);if(a.length===r.length){let n=a.filter((i,o,s)=>s.indexOf(i)===o);return{type:n.length>1?n:n[0],enum:r.reduce((i,o)=>i.includes(o._def.value)?i:[...i,o._def.value],[])}}}else if(r.every(a=>a._def.typeName==="ZodEnum"))return{type:"string",enum:r.reduce((a,n)=>[...a,...n._def.values.filter(i=>!a.includes(i))],[])};return EC(e,t)}var EC=(e,t)=>{let r=(e.options instanceof Map?Array.from(e.options.values()):e.options).map((a,n)=>K(a._def,{...t,currentPath:[...t.currentPath,"anyOf",`${n}`]})).filter(a=>!!a&&(!t.strictUnions||typeof a=="object"&&Object.keys(a).length>0));return r.length?{anyOf:r}:void 0};function TC(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:pl[e.innerType._def.typeName],nullable:!0}:{type:[pl[e.innerType._def.typeName],"null"]};if(t.target==="openApi3"){let a=K(e.innerType._def,{...t,currentPath:[...t.currentPath]});return a&&"$ref"in a?{allOf:[a],nullable:!0}:a&&{...a,nullable:!0}}let r=K(e.innerType._def,{...t,currentPath:[...t.currentPath,"anyOf","0"]});return r&&{anyOf:[r,{type:"null"}]}}function AC(e,t){let r={type:"number"};if(!e.checks)return r;for(let a of e.checks)switch(a.kind){case"int":r.type="integer",py(r,"type",a.message,t);break;case"min":t.target==="jsonSchema7"?a.inclusive?ue(r,"minimum",a.value,a.message,t):ue(r,"exclusiveMinimum",a.value,a.message,t):(a.inclusive||(r.exclusiveMinimum=!0),ue(r,"minimum",a.value,a.message,t));break;case"max":t.target==="jsonSchema7"?a.inclusive?ue(r,"maximum",a.value,a.message,t):ue(r,"exclusiveMaximum",a.value,a.message,t):(a.inclusive||(r.exclusiveMaximum=!0),ue(r,"maximum",a.value,a.message,t));break;case"multipleOf":ue(r,"multipleOf",a.value,a.message,t);break}return r}function CC(e,t){let r=t.target==="openAi",a={type:"object",properties:{}},n=[],i=e.shape();for(let s in i){let l=i[s];if(l===void 0||l._def===void 0)continue;let c=qM(l);c&&r&&(l._def.typeName==="ZodOptional"&&(l=l._def.innerType),l.isNullable()||(l=l.nullable()),c=!1);let u=K(l._def,{...t,currentPath:[...t.currentPath,"properties",s],propertyPath:[...t.currentPath,"properties",s]});u!==void 0&&(a.properties[s]=u,c||n.push(s))}n.length&&(a.required=n);let o=FM(e,t);return o!==void 0&&(a.additionalProperties=o),a}function FM(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 qM(e){try{return e.isOptional()}catch{return!0}}var zC=(e,t)=>{if(t.currentPath.toString()===t.propertyPath?.toString())return K(e.innerType._def,t);let r=K(e.innerType._def,{...t,currentPath:[...t.currentPath,"anyOf","1"]});return r?{anyOf:[{not:je(t)},r]}:je(t)};var IC=(e,t)=>{if(t.pipeStrategy==="input")return K(e.in._def,t);if(t.pipeStrategy==="output")return K(e.out._def,t);let r=K(e.in._def,{...t,currentPath:[...t.currentPath,"allOf","0"]}),a=K(e.out._def,{...t,currentPath:[...t.currentPath,"allOf",r?"1":"0"]});return{allOf:[r,a].filter(n=>n!==void 0)}};function PC(e,t){return K(e.type._def,t)}function RC(e,t){let a={type:"array",uniqueItems:!0,items:K(e.valueType._def,{...t,currentPath:[...t.currentPath,"items"]})};return e.minSize&&ue(a,"minItems",e.minSize.value,e.minSize.message,t),e.maxSize&&ue(a,"maxItems",e.maxSize.value,e.maxSize.message,t),a}function $C(e,t){return e.rest?{type:"array",minItems:e.items.length,items:e.items.map((r,a)=>K(r._def,{...t,currentPath:[...t.currentPath,"items",`${a}`]})).reduce((r,a)=>a===void 0?r:[...r,a],[]),additionalItems:K(e.rest._def,{...t,currentPath:[...t.currentPath,"additionalItems"]})}:{type:"array",minItems:e.items.length,maxItems:e.items.length,items:e.items.map((r,a)=>K(r._def,{...t,currentPath:[...t.currentPath,"items",`${a}`]})).reduce((r,a)=>a===void 0?r:[...r,a],[])}}function jC(e){return{not:je(e)}}function OC(e){return je(e)}var NC=(e,t)=>K(e.innerType._def,t);var DC=(e,t,r)=>{switch(t){case I.ZodString:return um(e,r);case I.ZodNumber:return AC(e,r);case I.ZodObject:return CC(e,r);case I.ZodBigInt:return dC(e,r);case I.ZodBoolean:return pC();case I.ZodDate:return my(e,r);case I.ZodUndefined:return jC(r);case I.ZodNull:return SC(r);case I.ZodArray:return uC(e,r);case I.ZodUnion:case I.ZodDiscriminatedUnion:return xC(e,r);case I.ZodIntersection:return bC(e,r);case I.ZodTuple:return $C(e,r);case I.ZodRecord:return dm(e,r);case I.ZodLiteral:return vC(e,r);case I.ZodEnum:return fC(e);case I.ZodNativeEnum:return _C(e);case I.ZodNullable:return TC(e,r);case I.ZodOptional:return zC(e,r);case I.ZodMap:return kC(e,r);case I.ZodSet:return RC(e,r);case I.ZodLazy:return()=>e.getter()._def;case I.ZodPromise:return PC(e,r);case I.ZodNaN:case I.ZodNever:return wC(r);case I.ZodEffects:return hC(e,r);case I.ZodAny:return je(r);case I.ZodUnknown:return OC(r);case I.ZodDefault:return gC(e,r);case I.ZodBranded:return cm(e,r);case I.ZodReadonly:return NC(e,r);case I.ZodCatch:return mC(e,r);case I.ZodPipeline:return IC(e,r);case I.ZodFunction:case I.ZodVoid:case I.ZodSymbol:return;default:return(a=>{})(t)}};function K(e,t,r=!1){let a=t.seen.get(e);if(t.override){let s=t.override?.(e,t,a,r);if(s!==sC)return s}if(a&&!r){let s=HM(a,t);if(s!==void 0)return s}let n={def:e,path:t.currentPath,jsonSchema:void 0};t.seen.set(e,n);let i=DC(e,e.typeName,t),o=typeof i=="function"?K(i(),t):i;if(o&&GM(e,t,o),t.postProcess){let s=t.postProcess(o,e,t);return n.jsonSchema=o,s}return n.jsonSchema=o,o}var HM=(e,t)=>{switch(t.$refStrategy){case"root":return{$ref:e.path.join("/")};case"relative":return{$ref:lm(t.currentPath,e.path)};case"none":case"seen":return e.path.length<t.currentPath.length&&e.path.every((r,a)=>t.currentPath[a]===r)?(console.warn(`Recursive reference detected at ${t.currentPath.join("/")}! Defaulting to any`),je(t)):t.$refStrategy==="seen"?je(t):void 0}},GM=(e,t,r)=>(e.description&&(r.description=e.description,t.markdownDescription&&(r.markdownDescription=e.description)),r);var fy=(e,t)=>{let r=cC(t),a=typeof t=="object"&&t.definitions?Object.entries(t.definitions).reduce((l,[c,u])=>({...l,[c]:K(u._def,{...r,currentPath:[...r.basePath,r.definitionPath,c]},!0)??je(r)}),{}):void 0,n=typeof t=="string"?t:t?.nameStrategy==="title"?void 0:t?.name,i=K(e._def,n===void 0?r:{...r,currentPath:[...r.basePath,r.definitionPath,n]},!1)??je(r),o=typeof t=="object"&&t.name!==void 0&&t.nameStrategy==="title"?t.name:void 0;o!==void 0&&(i.title=o),r.flags.hasReferencedOpenAiAnyType&&(a||(a={}),a[r.openAiAnyTypeName]||(a[r.openAiAnyTypeName]={type:["string","number","integer","boolean","array","null"],items:{$ref:r.$refStrategy==="relative"?"1":[...r.basePath,r.definitionPath,r.openAiAnyTypeName].join("/")}}));let s=n===void 0?a?{...i,[r.definitionPath]:a}:i:{$ref:[...r.$refStrategy==="relative"?[]:r.basePath,r.definitionPath,n].join("/"),[r.definitionPath]:{...a,[n]:i}};return r.target==="jsonSchema7"?s.$schema="http://json-schema.org/draft-07/schema#":(r.target==="jsonSchema2019-09"||r.target==="openAi")&&(s.$schema="https://json-schema.org/draft/2019-09/schema#"),r.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 VM(e){return!e||e==="jsonSchema7"||e==="draft-7"?"draft-7":e==="jsonSchema2019-09"||e==="draft-2020-12"?"draft-2020-12":"draft-7"}function by(e,t){return bn(e)?Hr(e,{target:VM(t?.target),io:t?.pipeStrategy??"input"}):fy(e,{strictUnions:t?.strictUnions??!0,pipeStrategy:t?.pipeStrategy??"input"})}function vy(e){let r=kr(e)?.method;if(!r)throw new Error("Schema is missing a method literal");let a=Vi(r);if(typeof a!="string")throw new Error("Schema method literal must be a string");return a}function yy(e,t){let r=yr(e,t);if(!r.success)throw r.error;return r.data}var WM=6e4,pm=class{constructor(t){this._options=t,this._requestMessageId=0,this._requestHandlers=new Map,this._requestHandlerAbortControllers=new Map,this._notificationHandlers=new Map,this._responseHandlers=new Map,this._progressHandlers=new Map,this._timeoutInfo=new Map,this._pendingDebouncedNotifications=new Set,this._taskProgressTokens=new Map,this._requestResolvers=new Map,this.setNotificationHandler(ap,r=>{this._oncancel(r)}),this.setNotificationHandler(sp,r=>{this._onprogress(r)}),this.setRequestHandler(op,r=>({})),this._taskStore=t?.taskStore,this._taskMessageQueue=t?.taskMessageQueue,this._taskStore&&(this.setRequestHandler(lp,async(r,a)=>{let n=await this._taskStore.getTask(r.params.taskId,a.sessionId);if(!n)throw new M(F.InvalidParams,"Failed to retrieve task: Task not found");return{...n}}),this.setRequestHandler(up,async(r,a)=>{let n=async()=>{let i=r.params.taskId;if(!await this._taskStore.getTask(i,a.sessionId))throw new M(F.InvalidParams,`Task not found: ${i}`);if(this._taskMessageQueue){let s;for(;s=await this._taskMessageQueue.dequeue(i,a.sessionId);){if(s.type==="response"||s.type==="error"){let l=s.message,c=l.id,u=this._requestResolvers.get(c);if(u)if(this._requestResolvers.delete(c),s.type==="response")u(l);else{let d=l,m=new M(d.error.code,d.error.message,d.error.data);u(m)}else{let d=s.type==="response"?"Response":"Error";this._onerror(new Error(`${d} handler missing for request ${c}`))}continue}await this._transport?.send(s.message,{relatedRequestId:a.requestId})}}let o=await this._taskStore.getTask(i,a.sessionId);if(!o)throw new M(F.InvalidParams,`Task not found: ${i}`);if(!_r(o.status))return await this._waitForTaskUpdate(i,a.signal,a.sessionId),await n();if(_r(o.status)){let s=await this._taskStore.getTaskResult(i,a.sessionId);return this._clearTaskQueue(i,a.sessionId),{...s,_meta:{...s._meta,[pr]:{taskId:i}}}}return await n()};return await n()}),this.setRequestHandler(dp,async(r,a)=>{try{let{tasks:n,nextCursor:i}=await this._taskStore.listTasks(r.params?.cursor,a.sessionId);return{tasks:n,nextCursor:i,_meta:{}}}catch(n){throw new M(F.InvalidParams,`Failed to list tasks: ${n instanceof Error?n.message:String(n)}`)}}),this.setRequestHandler(mp,async(r,a)=>{try{let n=await this._taskStore.getTask(r.params.taskId,a.sessionId);if(!n)throw new M(F.InvalidParams,`Task not found: ${r.params.taskId}`);if(_r(n.status))throw new M(F.InvalidParams,`Cannot cancel task in terminal status: ${n.status}`);await this._taskStore.updateTaskStatus(r.params.taskId,"cancelled","Client cancelled task execution.",a.sessionId),this._clearTaskQueue(r.params.taskId,a.sessionId);let i=await this._taskStore.getTask(r.params.taskId,a.sessionId);if(!i)throw new M(F.InvalidParams,`Task not found after cancellation: ${r.params.taskId}`);return{_meta:{},...i}}catch(n){throw n instanceof M?n:new M(F.InvalidRequest,`Failed to cancel task: ${n instanceof Error?n.message:String(n)}`)}}))}async _oncancel(t){if(!t.params.requestId)return;this._requestHandlerAbortControllers.get(t.params.requestId)?.abort(t.params.reason)}_setupTimeout(t,r,a,n,i=!1){this._timeoutInfo.set(t,{timeoutId:setTimeout(n,r),startTime:Date.now(),timeout:r,maxTotalTimeout:a,resetTimeoutOnProgress:i,onTimeout:n})}_resetTimeout(t){let r=this._timeoutInfo.get(t);if(!r)return!1;let a=Date.now()-r.startTime;if(r.maxTotalTimeout&&a>=r.maxTotalTimeout)throw this._timeoutInfo.delete(t),M.fromError(F.RequestTimeout,"Maximum total timeout exceeded",{maxTotalTimeout:r.maxTotalTimeout,totalElapsed:a});return clearTimeout(r.timeoutId),r.timeoutId=setTimeout(r.onTimeout,r.timeout),!0}_cleanupTimeout(t){let r=this._timeoutInfo.get(t);r&&(clearTimeout(r.timeoutId),this._timeoutInfo.delete(t))}async connect(t){if(this._transport)throw new Error("Already connected to a transport. Call close() before connecting to a new transport, or use a separate Protocol instance per connection.");this._transport=t;let r=this.transport?.onclose;this._transport.onclose=()=>{r?.(),this._onclose()};let a=this.transport?.onerror;this._transport.onerror=i=>{a?.(i),this._onerror(i)};let n=this._transport?.onmessage;this._transport.onmessage=(i,o)=>{n?.(i,o),In(i)||bi(i)?this._onresponse(i):zn(i)?this._onrequest(i,o):Ux(i)?this._onnotification(i):this._onerror(new Error(`Unknown message type: ${JSON.stringify(i)}`))},await this._transport.start()}_onclose(){let t=this._responseHandlers;this._responseHandlers=new Map,this._progressHandlers.clear(),this._taskProgressTokens.clear(),this._pendingDebouncedNotifications.clear();for(let a of this._timeoutInfo.values())clearTimeout(a.timeoutId);this._timeoutInfo.clear();for(let a of this._requestHandlerAbortControllers.values())a.abort();this._requestHandlerAbortControllers.clear();let r=M.fromError(F.ConnectionClosed,"Connection closed");this._transport=void 0,this.onclose?.();for(let a of t.values())a(r)}_onerror(t){this.onerror?.(t)}_onnotification(t){let r=this._notificationHandlers.get(t.method)??this.fallbackNotificationHandler;r!==void 0&&Promise.resolve().then(()=>r(t)).catch(a=>this._onerror(new Error(`Uncaught error in notification handler: ${a}`)))}_onrequest(t,r){let a=this._requestHandlers.get(t.method)??this.fallbackRequestHandler,n=this._transport,i=t.params?._meta?.[pr]?.taskId,o=n?.sessionId,s=this._taskStore,l=!0,c;if(i&&s&&this._taskMessageQueue&&o!==void 0&&(l=!1,c=(async()=>{if(!await s.getTask(i,o))throw new M(F.InvalidParams,`Task not found: ${i}`);l=!0})()),a===void 0){let g={jsonrpc:"2.0",id:t.id,error:{code:F.MethodNotFound,message:"Method not found"}};if(i&&c){let h={type:"error",message:g,timestamp:Date.now()};c.then(()=>this._enqueueTaskMessage(i,h,o),()=>n?.send(g)).catch(f=>this._onerror(new Error(`Failed to send an error response: ${f}`)))}else i&&this._taskMessageQueue?this._enqueueTaskMessage(i,{type:"error",message:g,timestamp:Date.now()},n?.sessionId).catch(h=>this._onerror(new Error(`Failed to enqueue error response: ${h}`))):n?.send(g).catch(h=>this._onerror(new Error(`Failed to send an error response: ${h}`)));return}let u=new AbortController;this._requestHandlerAbortControllers.set(t.id,u);let d=Mx(t.params)?t.params.task:void 0,m=this._taskStore?this.requestTaskStore(t,n?.sessionId):void 0,p={signal:u.signal,sessionId:n?.sessionId,_meta:t.params?._meta,sendNotification:async g=>{if(u.signal.aborted)return;let h={relatedRequestId:t.id};i&&(h.relatedTask={taskId:i}),await this.notification(g,h)},sendRequest:async(g,h,f)=>{if(u.signal.aborted)throw new M(F.ConnectionClosed,"Request was cancelled");let _={...f,relatedRequestId:t.id};i&&!_.relatedTask&&(_.relatedTask={taskId:i});let b=_.relatedTask?.taskId??i;return b&&m&&await m.updateTaskStatus(b,"input_required"),await this.request(g,h,_)},authInfo:r?.authInfo,requestId:t.id,requestInfo:r?.requestInfo,taskId:i,taskStore:m,taskRequestedTtl:d?.ttl,closeSSEStream:r?.closeSSEStream,closeStandaloneSSEStream:r?.closeStandaloneSSEStream};(c??Promise.resolve()).then(()=>{if(c&&u.signal.aborted)throw new M(F.ConnectionClosed,"Request was cancelled");d&&this.assertTaskHandlerCapability(t.method)}).then(()=>a(t,p)).then(async g=>{if(u.signal.aborted)return;let h={result:g,jsonrpc:"2.0",id:t.id};i&&this._taskMessageQueue?await this._enqueueTaskMessage(i,{type:"response",message:h,timestamp:Date.now()},n?.sessionId):await n?.send(h)},async g=>{if(u.signal.aborted)return;let h={jsonrpc:"2.0",id:t.id,error:{code:Number.isSafeInteger(g.code)?g.code:F.InternalError,message:g.message??"Internal error",...g.data!==void 0&&{data:g.data}}};i&&this._taskMessageQueue&&l?await this._enqueueTaskMessage(i,{type:"error",message:h,timestamp:Date.now()},n?.sessionId):await n?.send(h)}).catch(g=>this._onerror(new Error(`Failed to send response: ${g}`))).finally(()=>{this._requestHandlerAbortControllers.get(t.id)===u&&this._requestHandlerAbortControllers.delete(t.id)})}_onprogress(t){let{progressToken:r,...a}=t.params,n=Number(r),i=this._progressHandlers.get(n);if(!i){this._onerror(new Error(`Received a progress notification for an unknown token: ${JSON.stringify(t)}`));return}let o=this._responseHandlers.get(n),s=this._timeoutInfo.get(n);if(s&&o&&s.resetTimeoutOnProgress)try{this._resetTimeout(n)}catch(l){this._responseHandlers.delete(n),this._progressHandlers.delete(n),this._cleanupTimeout(n),o(l);return}i(a)}_onresponse(t){let r=Number(t.id),a=this._requestResolvers.get(r);if(a){if(this._requestResolvers.delete(r),In(t))a(t);else{let o=new M(t.error.code,t.error.message,t.error.data);a(o)}return}let n=this._responseHandlers.get(r);if(n===void 0){this._onerror(new Error(`Received a response for an unknown message ID: ${JSON.stringify(t)}`));return}this._responseHandlers.delete(r),this._cleanupTimeout(r);let i=!1;if(In(t)&&t.result&&typeof t.result=="object"){let o=t.result;if(o.task&&typeof o.task=="object"){let s=o.task;typeof s.taskId=="string"&&(i=!0,this._taskProgressTokens.set(s.taskId,r))}}if(i||this._progressHandlers.delete(r),In(t))n(t);else{let o=M.fromError(t.error.code,t.error.message,t.error.data);n(o)}}get transport(){return this._transport}async close(){await this._transport?.close()}async*requestStream(t,r,a){let{task:n}=a??{};if(!n){try{yield{type:"result",result:await this.request(t,r,a)}}catch(o){yield{type:"error",error:o instanceof M?o:new M(F.InternalError,String(o))}}return}let i;try{let o=await this.request(t,vi,a);if(o.task)i=o.task.taskId,yield{type:"taskCreated",task:o.task};else throw new M(F.InternalError,"Task creation did not return a task");for(;;){let s=await this.getTask({taskId:i},a);if(yield{type:"taskStatus",task:s},_r(s.status)){s.status==="completed"?yield{type:"result",result:await this.getTaskResult({taskId:i},r,a)}:s.status==="failed"?yield{type:"error",error:new M(F.InternalError,`Task ${i} failed`)}:s.status==="cancelled"&&(yield{type:"error",error:new M(F.InternalError,`Task ${i} was cancelled`)});return}if(s.status==="input_required"){yield{type:"result",result:await this.getTaskResult({taskId:i},r,a)};return}let l=s.pollInterval??this._options?.defaultTaskPollInterval??1e3;await new Promise(c=>setTimeout(c,l)),a?.signal?.throwIfAborted()}}catch(o){yield{type:"error",error:o instanceof M?o:new M(F.InternalError,String(o))}}}request(t,r,a){let{relatedRequestId:n,resumptionToken:i,onresumptiontoken:o,task:s,relatedTask:l}=a??{};return new Promise((c,u)=>{let d=b=>{u(b)};if(!this._transport){d(new Error("Not connected"));return}if(this._options?.enforceStrictCapabilities===!0)try{this.assertCapabilityForMethod(t.method),s&&this.assertTaskCapability(t.method)}catch(b){d(b);return}a?.signal?.throwIfAborted();let m=this._requestMessageId++,p={...t,jsonrpc:"2.0",id:m};a?.onprogress&&(this._progressHandlers.set(m,a.onprogress),p.params={...t.params,_meta:{...t.params?._meta||{},progressToken:m}}),s&&(p.params={...p.params,task:s}),l&&(p.params={...p.params,_meta:{...p.params?._meta||{},[pr]:l}});let g=b=>{this._responseHandlers.delete(m),this._progressHandlers.delete(m),this._cleanupTimeout(m),this._transport?.send({jsonrpc:"2.0",method:"notifications/cancelled",params:{requestId:m,reason:String(b)}},{relatedRequestId:n,resumptionToken:i,onresumptiontoken:o}).catch(C=>this._onerror(new Error(`Failed to send cancellation: ${C}`)));let v=b instanceof M?b:new M(F.RequestTimeout,String(b));u(v)};this._responseHandlers.set(m,b=>{if(!a?.signal?.aborted){if(b instanceof Error)return u(b);try{let v=yr(r,b.result);v.success?c(v.data):u(v.error)}catch(v){u(v)}}}),a?.signal?.addEventListener("abort",()=>{g(a?.signal?.reason)});let h=a?.timeout??WM,f=()=>g(M.fromError(F.RequestTimeout,"Request timed out",{timeout:h}));this._setupTimeout(m,h,a?.maxTotalTimeout,f,a?.resetTimeoutOnProgress??!1);let _=l?.taskId;if(_){let b=v=>{let C=this._responseHandlers.get(m);C?C(v):this._onerror(new Error(`Response handler missing for side-channeled request ${m}`))};this._requestResolvers.set(m,b),this._enqueueTaskMessage(_,{type:"request",message:p,timestamp:Date.now()}).catch(v=>{this._cleanupTimeout(m),u(v)})}else this._transport.send(p,{relatedRequestId:n,resumptionToken:i,onresumptiontoken:o}).catch(b=>{this._cleanupTimeout(m),u(b)})})}async getTask(t,r){return this.request({method:"tasks/get",params:t},cp,r)}async getTaskResult(t,r,a){return this.request({method:"tasks/result",params:t},r,a)}async listTasks(t,r){return this.request({method:"tasks/list",params:t},pp,r)}async cancelTask(t,r){return this.request({method:"tasks/cancel",params:t},qx,r)}async notification(t,r){if(!this._transport)throw new Error("Not connected");this.assertNotificationCapability(t.method);let a=r?.relatedTask?.taskId;if(a){let s={...t,jsonrpc:"2.0",params:{...t.params,_meta:{...t.params?._meta||{},[pr]:r.relatedTask}}};await this._enqueueTaskMessage(a,{type:"notification",message:s,timestamp:Date.now()});return}if((this._options?.debouncedNotificationMethods??[]).includes(t.method)&&!t.params&&!r?.relatedRequestId&&!r?.relatedTask){if(this._pendingDebouncedNotifications.has(t.method))return;this._pendingDebouncedNotifications.add(t.method),Promise.resolve().then(()=>{if(this._pendingDebouncedNotifications.delete(t.method),!this._transport)return;let s={...t,jsonrpc:"2.0"};r?.relatedTask&&(s={...s,params:{...s.params,_meta:{...s.params?._meta||{},[pr]:r.relatedTask}}}),this._transport?.send(s,r).catch(l=>this._onerror(l))});return}let o={...t,jsonrpc:"2.0"};r?.relatedTask&&(o={...o,params:{...o.params,_meta:{...o.params?._meta||{},[pr]:r.relatedTask}}}),await this._transport.send(o,r)}setRequestHandler(t,r){let a=vy(t);this.assertRequestHandlerCapability(a),this._requestHandlers.set(a,(n,i)=>{let o=yy(t,n);return Promise.resolve(r(o,i))})}removeRequestHandler(t){this._requestHandlers.delete(t)}assertCanSetRequestHandler(t){if(this._requestHandlers.has(t))throw new Error(`A request handler for ${t} already exists, which would be overridden`)}setNotificationHandler(t,r){let a=vy(t);this._notificationHandlers.set(a,n=>{let i=yy(t,n);return Promise.resolve(r(i))})}removeNotificationHandler(t){this._notificationHandlers.delete(t)}_cleanupTaskProgressHandler(t){let r=this._taskProgressTokens.get(t);r!==void 0&&(this._progressHandlers.delete(r),this._taskProgressTokens.delete(t))}async _enqueueTaskMessage(t,r,a){if(!this._taskStore||!this._taskMessageQueue)throw new Error("Cannot enqueue task message: taskStore and taskMessageQueue are not configured");let n=this._options?.maxTaskQueueSize;await this._taskMessageQueue.enqueue(t,r,a??this._transport?.sessionId,n)}async _clearTaskQueue(t,r){if(this._taskMessageQueue){let a=await this._taskMessageQueue.dequeueAll(t,r);for(let n of a)if(n.type==="request"&&zn(n.message)){let i=n.message.id,o=this._requestResolvers.get(i);o?(o(new M(F.InternalError,"Task cancelled or completed")),this._requestResolvers.delete(i)):this._onerror(new Error(`Resolver missing for request ${i} during task ${t} cleanup`))}}}async _waitForTaskUpdate(t,r,a){let n=this._options?.defaultTaskPollInterval??1e3;try{let i=await this._taskStore?.getTask(t,a);i?.pollInterval&&(n=i.pollInterval)}catch{}return new Promise((i,o)=>{if(r.aborted){o(new M(F.InvalidRequest,"Request cancelled"));return}let s=setTimeout(i,n);r.addEventListener("abort",()=>{clearTimeout(s),o(new M(F.InvalidRequest,"Request cancelled"))},{once:!0})})}requestTaskStore(t,r){let a=this._taskStore;if(!a)throw new Error("No task store configured");return{createTask:async n=>{if(!t)throw new Error("No request provided");return await a.createTask(n,t.id,{method:t.method,params:t.params},r)},getTask:async n=>{let i=await a.getTask(n,r);if(!i)throw new M(F.InvalidParams,"Failed to retrieve task: Task not found");return i},storeTaskResult:async(n,i,o)=>{await a.storeTaskResult(n,i,o,r);let s=await a.getTask(n,r);if(s){let l=Os.parse({method:"notifications/tasks/status",params:s});await this.notification(l),_r(s.status)&&this._cleanupTaskProgressHandler(n)}},getTaskResult:n=>a.getTaskResult(n,r),updateTaskStatus:async(n,i,o)=>{let s=await a.getTask(n,r);if(!s)throw new M(F.InvalidParams,`Task "${n}" not found - it may have been cleaned up`);if(_r(s.status))throw new M(F.InvalidParams,`Cannot update task "${n}" from terminal status "${s.status}" to "${i}". Terminal states (completed, failed, cancelled) cannot transition to other states.`);await a.updateTaskStatus(n,i,o,r);let l=await a.getTask(n,r);if(l){let c=Os.parse({method:"notifications/tasks/status",params:l});await this.notification(c),_r(l.status)&&this._cleanupTaskProgressHandler(n)}},listTasks:n=>a.listTasks(n,r)}}};function MC(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function LC(e,t){let r={...e};for(let a in t){let n=a,i=t[n];if(i===void 0)continue;let o=r[n];MC(o)&&MC(i)?r[n]={...o,...i}:r[n]=i}return r}var MP=ng(d_(),1),LP=ng(DP(),1);function aq(){let e=new MP.default({strict:!1,validateFormats:!0,validateSchema:!1,allErrors:!0});return(0,LP.default)(e),e}var Zm=class{constructor(t){this._ajv=t??aq()}getValidator(t){let r="$id"in t&&typeof t.$id=="string"?this._ajv.getSchema(t.$id)??this._ajv.compile(t):this._ajv.compile(t);return a=>r(a)?{valid:!0,data:a,errorMessage:void 0}:{valid:!1,data:void 0,errorMessage:this._ajv.errorsText(r.errors)}}};var Jm=class{constructor(t){this._server=t}requestStream(t,r,a){return this._server.requestStream(t,r,a)}createMessageStream(t,r){let a=this._server.getClientCapabilities();if((t.tools||t.toolChoice)&&!a?.sampling?.tools)throw new Error("Client does not support sampling tools capability.");if(t.messages.length>0){let n=t.messages[t.messages.length-1],i=Array.isArray(n.content)?n.content:[n.content],o=i.some(u=>u.type==="tool_result"),s=t.messages.length>1?t.messages[t.messages.length-2]:void 0,l=s?Array.isArray(s.content)?s.content:[s.content]:[],c=l.some(u=>u.type==="tool_use");if(o){if(i.some(u=>u.type!=="tool_result"))throw new Error("The last message must contain only tool_result content if any is present");if(!c)throw new Error("tool_result blocks are not matching any tool_use from the previous message")}if(c){let u=new Set(l.filter(m=>m.type==="tool_use").map(m=>m.id)),d=new Set(i.filter(m=>m.type==="tool_result").map(m=>m.toolUseId));if(u.size!==d.size||![...u].every(m=>d.has(m)))throw new Error("ids of tool_result blocks and tool_use blocks from previous message do not match")}}return this.requestStream({method:"sampling/createMessage",params:t},Ms,r)}elicitInputStream(t,r){let a=this._server.getClientCapabilities(),n=t.mode??"form";switch(n){case"url":{if(!a?.elicitation?.url)throw new Error("Client does not support url elicitation.");break}case"form":{if(!a?.elicitation?.form)throw new Error("Client does not support form elicitation.");break}}let i=n==="form"&&t.mode===void 0?{...t,mode:"form"}:t;return this.requestStream({method:"elicitation/create",params:i},_i,r)}async getTask(t,r){return this._server.getTask({taskId:t},r)}async getTaskResult(t,r,a){return this._server.getTaskResult({taskId:t},r,a)}async listTasks(t,r){return this._server.listTasks(t?{cursor:t}:void 0,r)}async cancelTask(t,r){return this._server.cancelTask({taskId:t},r)}};function BP(e,t,r){if(!e)throw new Error(`${r} does not support task creation (required for ${t})`);switch(t){case"tools/call":if(!e.tools?.call)throw new Error(`${r} does not support task creation for tools/call (required for ${t})`);break;default:break}}function UP(e,t,r){if(!e)throw new Error(`${r} does not support task creation (required for ${t})`);switch(t){case"sampling/createMessage":if(!e.sampling?.createMessage)throw new Error(`${r} does not support task creation for sampling/createMessage (required for ${t})`);break;case"elicitation/create":if(!e.elicitation?.create)throw new Error(`${r} does not support task creation for elicitation/create (required for ${t})`);break;default:break}}var Ym=class extends pm{constructor(t,r){super(r),this._serverInfo=t,this._loggingLevels=new Map,this.LOG_LEVEL_SEVERITY=new Map(Ds.options.map((a,n)=>[a,n])),this.isMessageIgnored=(a,n)=>{let i=this._loggingLevels.get(n);return i?this.LOG_LEVEL_SEVERITY.get(a)<this.LOG_LEVEL_SEVERITY.get(i):!1},this._capabilities=r?.capabilities??{},this._instructions=r?.instructions,this._jsonSchemaValidator=r?.jsonSchemaValidator??new Zm,this.setRequestHandler(ip,a=>this._oninitialize(a)),this.setNotificationHandler(Qb,()=>this.oninitialized?.()),this._capabilities.logging&&this.setRequestHandler(ov,async(a,n)=>{let i=n.sessionId||n.requestInfo?.headers["mcp-session-id"]||void 0,{level:o}=a.params,s=Ds.safeParse(o);return s.success&&this._loggingLevels.set(i,s.data),{}})}get experimental(){return this._experimental||(this._experimental={tasks:new Jm(this)}),this._experimental}registerCapabilities(t){if(this.transport)throw new Error("Cannot register capabilities after connecting to transport");this._capabilities=LC(this._capabilities,t)}setRequestHandler(t,r){let n=kr(t)?.method;if(!n)throw new Error("Schema is missing a method literal");let i=Vi(n);if(typeof i!="string")throw new Error("Schema method literal must be a string");if(i==="tools/call"){let s=async(l,c)=>{let u=yr(ki,l);if(!u.success){let g=u.error instanceof Error?u.error.message:String(u.error);throw new M(F.InvalidParams,`Invalid tools/call request: ${g}`)}let{params:d}=u.data,m=await Promise.resolve(r(l,c));if(d.task){let g=yr(vi,m);if(!g.success){let h=g.error instanceof Error?g.error.message:String(g.error);throw new M(F.InvalidParams,`Invalid task creation result: ${h}`)}return g.data}let p=yr(kp,m);if(!p.success){let g=p.error instanceof Error?p.error.message:String(p.error);throw new M(F.InvalidParams,`Invalid tools/call result: ${g}`)}return p.data};return super.setRequestHandler(t,s)}return super.setRequestHandler(t,r)}assertCapabilityForMethod(t){switch(t){case"sampling/createMessage":if(!this._clientCapabilities?.sampling)throw new Error(`Client does not support sampling (required for ${t})`);break;case"elicitation/create":if(!this._clientCapabilities?.elicitation)throw new Error(`Client does not support elicitation (required for ${t})`);break;case"roots/list":if(!this._clientCapabilities?.roots)throw new Error(`Client does not support listing roots (required for ${t})`);break;case"ping":break}}assertNotificationCapability(t){switch(t){case"notifications/message":if(!this._capabilities.logging)throw new Error(`Server does not support logging (required for ${t})`);break;case"notifications/resources/updated":case"notifications/resources/list_changed":if(!this._capabilities.resources)throw new Error(`Server does not support notifying about resources (required for ${t})`);break;case"notifications/tools/list_changed":if(!this._capabilities.tools)throw new Error(`Server does not support notifying of tool list changes (required for ${t})`);break;case"notifications/prompts/list_changed":if(!this._capabilities.prompts)throw new Error(`Server does not support notifying of prompt list changes (required for ${t})`);break;case"notifications/elicitation/complete":if(!this._clientCapabilities?.elicitation?.url)throw new Error(`Client does not support URL elicitation (required for ${t})`);break;case"notifications/cancelled":break;case"notifications/progress":break}}assertRequestHandlerCapability(t){if(this._capabilities)switch(t){case"completion/complete":if(!this._capabilities.completions)throw new Error(`Server does not support completions (required for ${t})`);break;case"logging/setLevel":if(!this._capabilities.logging)throw new Error(`Server does not support logging (required for ${t})`);break;case"prompts/get":case"prompts/list":if(!this._capabilities.prompts)throw new Error(`Server does not support prompts (required for ${t})`);break;case"resources/list":case"resources/templates/list":case"resources/read":if(!this._capabilities.resources)throw new Error(`Server does not support resources (required for ${t})`);break;case"tools/call":case"tools/list":if(!this._capabilities.tools)throw new Error(`Server does not support tools (required for ${t})`);break;case"tasks/get":case"tasks/list":case"tasks/result":case"tasks/cancel":if(!this._capabilities.tasks)throw new Error(`Server does not support tasks capability (required for ${t})`);break;case"ping":case"initialize":break}}assertTaskCapability(t){UP(this._clientCapabilities?.tasks?.requests,t,"Client")}assertTaskHandlerCapability(t){this._capabilities&&BP(this._capabilities.tasks?.requests,t,"Server")}async _oninitialize(t){let r=t.params.protocolVersion;return this._clientCapabilities=t.params.capabilities,this._clientVersion=t.params.clientInfo,{protocolVersion:fi.includes(r)?r:Kb,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"},rp)}async createMessage(t,r){if((t.tools||t.toolChoice)&&!this._clientCapabilities?.sampling?.tools)throw new Error("Client does not support sampling tools capability.");if(t.messages.length>0){let a=t.messages[t.messages.length-1],n=Array.isArray(a.content)?a.content:[a.content],i=n.some(c=>c.type==="tool_result"),o=t.messages.length>1?t.messages[t.messages.length-2]:void 0,s=o?Array.isArray(o.content)?o.content:[o.content]:[],l=s.some(c=>c.type==="tool_use");if(i){if(n.some(c=>c.type!=="tool_result"))throw new Error("The last message must contain only tool_result content if any is present");if(!l)throw new Error("tool_result blocks are not matching any tool_use from the previous message")}if(l){let c=new Set(s.filter(d=>d.type==="tool_use").map(d=>d.id)),u=new Set(n.filter(d=>d.type==="tool_result").map(d=>d.toolUseId));if(c.size!==u.size||![...c].every(d=>u.has(d)))throw new Error("ids of tool_result blocks and tool_use blocks from previous message do not match")}}return t.tools?this.request({method:"sampling/createMessage",params:t},sv,r):this.request({method:"sampling/createMessage",params:t},Ms,r)}async elicitInput(t,r){switch(t.mode??"form"){case"url":{if(!this._clientCapabilities?.elicitation?.url)throw new Error("Client does not support url elicitation.");let n=t;return this.request({method:"elicitation/create",params:n},_i,r)}case"form":{if(!this._clientCapabilities?.elicitation?.form)throw new Error("Client does not support form elicitation.");let n=t.mode==="form"?t:{...t,mode:"form"},i=await this.request({method:"elicitation/create",params:n},_i,r);if(i.action==="accept"&&i.content&&n.requestedSchema)try{let s=this._jsonSchemaValidator.getValidator(n.requestedSchema)(i.content);if(!s.valid)throw new M(F.InvalidParams,`Elicitation response content does not match requested schema: ${s.errorMessage}`)}catch(o){throw o instanceof M?o:new M(F.InternalError,`Error validating elicitation response: ${o instanceof Error?o.message:String(o)}`)}return i}}}createElicitationCompletionNotifier(t,r){if(!this._clientCapabilities?.elicitation?.url)throw new Error("Client does not support URL elicitation (required for notifications/elicitation/complete)");return()=>this.notification({method:"notifications/elicitation/complete",params:{elicitationId:t}},r)}async listRoots(t,r){return this.request({method:"roots/list",params:t},lv,r)}async sendLoggingMessage(t,r){if(this._capabilities.logging&&!this.isMessageIgnored(t.level,r))return this.notification({method:"notifications/message",params:t})}async sendResourceUpdated(t){return this.notification({method:"notifications/resources/updated",params:t})}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"})}};var qP=Symbol.for("mcp.completable");function y_(e){return!!e&&typeof e=="object"&&qP in e}function HP(e){return e[qP]?.complete}var FP;(function(e){e.Completable="McpCompletable"})(FP||(FP={}));var iq=/^[A-Za-z0-9._-]{1,128}$/;function oq(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"),!iq.test(e)){let r=e.split("").filter(a=>!/[A-Za-z0-9._-]/.test(a)).filter((a,n,i)=>i.indexOf(a)===n);return t.push(`Tool name contains invalid characters: ${r.map(a=>`"${a}"`).join(", ")}`,"Allowed characters are: A-Z, a-z, 0-9, underscore (_), dash (-), and dot (.)"),{isValid:!1,warnings:t}}return{isValid:!0,warnings:t}}function sq(e,t){if(t.length>0){console.warn(`Tool name validation warning for "${e}":`);for(let r of t)console.warn(` - ${r}`);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 k_(e){let t=oq(e);return sq(e,t.warnings),t.isValid}var Xm=class{constructor(t){this._mcpServer=t}registerToolTask(t,r,a){let n={taskSupport:"required",...r.execution};if(n.taskSupport==="forbidden")throw new Error(`Cannot register task-based tool '${t}' with taskSupport 'forbidden'. Use registerTool() instead.`);return this._mcpServer._createRegisteredTool(t,r.title,r.description,r.inputSchema,r.outputSchema,r.annotations,n,r._meta,a)}};function lq(e,t){let r=0,a=[e];for(;a.length>0;){let n=a.pop();if(!(n===null||typeof n!="object"))if(Array.isArray(n))for(let i of n){if(++r>t)return r;i!==null&&typeof i=="object"&&a.push(i)}else for(let i in n){if(!Object.prototype.hasOwnProperty.call(n,i))continue;if(++r>t)return r;let o=n[i];o!==null&&typeof o=="object"&&a.push(o)}}return r}function cq(e){if(!(e===void 0||e===1/0)){if(typeof e!="number"||Number.isNaN(e)||e<1)throw new RangeError(`maxToolInputElements must be a number of at least 1, or Infinity, got ${String(e)}`);return e}}var Qm=class{constructor(t,r){this._registeredResources={},this._registeredResourceTemplates={},this._registeredTools={},this._registeredPrompts={},this._toolHandlersInitialized=!1,this._completionHandlerInitialized=!1,this._resourceHandlersInitialized=!1,this._promptHandlersInitialized=!1,this.server=new Ym(t,r),this._maxToolInputElements=cq(r?.maxToolInputElements)}get experimental(){return this._experimental||(this._experimental={tasks:new Xm(this)}),this._experimental}async connect(t){return await this.server.connect(t)}async close(){await this.server.close()}setToolRequestHandlers(){this._toolHandlersInitialized||(this.server.assertCanSetRequestHandler(Ir(yp)),this.server.assertCanSetRequestHandler(Ir(ki)),this.server.registerCapabilities({tools:{listChanged:!0}}),this.server.setRequestHandler(yp,()=>({tools:Object.entries(this._registeredTools).filter(([,t])=>t.enabled).map(([t,r])=>{let a={name:t,title:r.title,description:r.description,inputSchema:(()=>{let n=Gi(r.inputSchema);return n?by(n,{strictUnions:!0,pipeStrategy:"input"}):uq})(),annotations:r.annotations,execution:r.execution,_meta:r._meta};if(r.outputSchema){let n=Gi(r.outputSchema);n&&(a.outputSchema=by(n,{strictUnions:!0,pipeStrategy:"output"}))}return a})})),this.server.setRequestHandler(ki,async(t,r)=>{try{let a=this._registeredTools[t.params.name];if(!a)throw new M(F.InvalidParams,`Tool ${t.params.name} not found`);if(!a.enabled)throw new M(F.InvalidParams,`Tool ${t.params.name} disabled`);let n=!!t.params.task,i=a.execution?.taskSupport,o="createTask"in a.handler;if((i==="required"||i==="optional")&&!o)throw new M(F.InternalError,`Tool ${t.params.name} has taskSupport '${i}' but was not registered with registerToolTask`);if(i==="required"&&!n)throw new M(F.MethodNotFound,`Tool ${t.params.name} requires task augmentation (taskSupport: 'required')`);if(i==="optional"&&!n&&o)return await this.handleAutomaticTaskPolling(a,t,r);let s=await this.validateToolInput(a,t.params.arguments,t.params.name),l=await this.executeToolHandler(a,s,r);return n||await this.validateToolOutput(a,l,t.params.name),l}catch(a){if(a instanceof M&&a.code===F.UrlElicitationRequired)throw a;return this.createToolError(a instanceof Error?a.message:String(a))}}),this._toolHandlersInitialized=!0)}createToolError(t){return{content:[{type:"text",text:t}],isError:!0}}async validateToolInput(t,r,a){if(this._maxToolInputElements!==void 0&&lq(r,this._maxToolInputElements)>this._maxToolInputElements)throw new M(F.InvalidParams,`Invalid arguments for tool ${a}: arguments contain more than the maximum of ${this._maxToolInputElements} elements`);if(!t.inputSchema)return;let i=Gi(t.inputSchema)??t.inputSchema,o=await om(i,r??{});if(!o.success){let s="error"in o?o.error:"Unknown error",l=sm(s);throw new M(F.InvalidParams,`Input validation error: Invalid arguments for tool ${a}: ${l}`)}return o.data}async validateToolOutput(t,r,a){if(!t.outputSchema||!("content"in r)||r.isError)return;if(!r.structuredContent)throw new M(F.InvalidParams,`Output validation error: Tool ${a} has an output schema but no structured content was provided`);let n=Gi(t.outputSchema),i=await om(n,r.structuredContent);if(!i.success){let o="error"in i?i.error:"Unknown error",s=sm(o);throw new M(F.InvalidParams,`Output validation error: Invalid structured content for tool ${a}: ${s}`)}}async executeToolHandler(t,r,a){let n=t.handler;if("createTask"in n){if(!a.taskStore)throw new Error("No task store provided.");let o={...a,taskStore:a.taskStore};if(t.inputSchema){let s=n;return await Promise.resolve(s.createTask(r,o))}else{let s=n;return await Promise.resolve(s.createTask(o))}}if(t.inputSchema){let o=n;return await Promise.resolve(o(r,a))}else{let o=n;return await Promise.resolve(o(a))}}async handleAutomaticTaskPolling(t,r,a){if(!a.taskStore)throw new Error("No task store provided for task-capable tool.");let n=await this.validateToolInput(t,r.params.arguments,r.params.name),i=t.handler,o={...a,taskStore:a.taskStore},s=n?await Promise.resolve(i.createTask(n,o)):await Promise.resolve(i.createTask(o)),l=s.task.taskId,c=s.task,u=c.pollInterval??5e3;for(;c.status!=="completed"&&c.status!=="failed"&&c.status!=="cancelled";){await new Promise(m=>setTimeout(m,u));let d=await a.taskStore.getTask(l);if(!d)throw new M(F.InternalError,`Task ${l} not found during polling`);c=d}return await a.taskStore.getTaskResult(l)}setCompletionRequestHandler(){this._completionHandlerInitialized||(this.server.assertCanSetRequestHandler(Ir(_p)),this.server.registerCapabilities({completions:{}}),this.server.setRequestHandler(_p,async t=>{switch(t.params.ref.type){case"ref/prompt":return Zx(t),this.handlePromptCompletion(t,t.params.ref);case"ref/resource":return Jx(t),this.handleResourceCompletion(t,t.params.ref);default:throw new M(F.InvalidParams,`Invalid completion reference: ${t.params.ref}`)}}),this._completionHandlerInitialized=!0)}async handlePromptCompletion(t,r){let a=this._registeredPrompts[r.name];if(!a)throw new M(F.InvalidParams,`Prompt ${r.name} not found`);if(!a.enabled)throw new M(F.InvalidParams,`Prompt ${r.name} disabled`);if(!a.argsSchema)return ql;let i=kr(a.argsSchema)?.[t.params.argument.name];if(!y_(i))return ql;let o=HP(i);if(!o)return ql;let s=await o(t.params.argument.value,t.params.context);return VP(s)}async handleResourceCompletion(t,r){let a=Object.values(this._registeredResourceTemplates).find(o=>o.resourceTemplate.uriTemplate.toString()===r.uri);if(!a){if(this._registeredResources[r.uri])return ql;throw new M(F.InvalidParams,`Resource template ${t.params.ref.uri} not found`)}let n=a.resourceTemplate.completeCallback(t.params.argument.name);if(!n)return ql;let i=await n(t.params.argument.value,t.params.context);return VP(i)}setResourceRequestHandlers(){this._resourceHandlersInitialized||(this.server.assertCanSetRequestHandler(Ir(gp)),this.server.assertCanSetRequestHandler(Ir(hp)),this.server.assertCanSetRequestHandler(Ir(fp)),this.server.registerCapabilities({resources:{listChanged:!0}}),this.server.setRequestHandler(gp,async(t,r)=>{let a=Object.entries(this._registeredResources).filter(([i,o])=>o.enabled).map(([i,o])=>({uri:i,name:o.name,...o.metadata})),n=[];for(let i of Object.values(this._registeredResourceTemplates)){if(!i.resourceTemplate.listCallback)continue;let o=await i.resourceTemplate.listCallback(r);for(let s of o.resources)n.push({...i.metadata,...s})}return{resources:[...a,...n]}}),this.server.setRequestHandler(hp,async()=>({resourceTemplates:Object.entries(this._registeredResourceTemplates).map(([r,a])=>({name:r,uriTemplate:a.resourceTemplate.uriTemplate.toString(),...a.metadata}))})),this.server.setRequestHandler(fp,async(t,r)=>{let a=new URL(t.params.uri),n=this._registeredResources[a.toString()];if(n){if(!n.enabled)throw new M(F.InvalidParams,`Resource ${a} disabled`);return n.readCallback(a,r)}for(let i of Object.values(this._registeredResourceTemplates)){let o=i.resourceTemplate.uriTemplate.match(a.toString());if(o)return i.readCallback(a,o,r)}throw new M(F.InvalidParams,`Resource ${a} not found`)}),this._resourceHandlersInitialized=!0)}setPromptRequestHandlers(){this._promptHandlersInitialized||(this.server.assertCanSetRequestHandler(Ir(bp)),this.server.assertCanSetRequestHandler(Ir(vp)),this.server.registerCapabilities({prompts:{listChanged:!0}}),this.server.setRequestHandler(bp,()=>({prompts:Object.entries(this._registeredPrompts).filter(([,t])=>t.enabled).map(([t,r])=>({name:t,title:r.title,description:r.description,arguments:r.argsSchema?dq(r.argsSchema):void 0}))})),this.server.setRequestHandler(vp,async(t,r)=>{let a=this._registeredPrompts[t.params.name];if(!a)throw new M(F.InvalidParams,`Prompt ${t.params.name} not found`);if(!a.enabled)throw new M(F.InvalidParams,`Prompt ${t.params.name} disabled`);if(a.argsSchema){let n=Gi(a.argsSchema),i=await om(n,t.params.arguments??{});if(!i.success){let l="error"in i?i.error:"Unknown error",c=sm(l);throw new M(F.InvalidParams,`Invalid arguments for prompt ${t.params.name}: ${c}`)}let o=i.data,s=a.callback;return await Promise.resolve(s(o,r))}else{let n=a.callback;return await Promise.resolve(n(r))}}),this._promptHandlersInitialized=!0)}resource(t,r,...a){let n;typeof a[0]=="object"&&(n=a.shift());let i=a[0];if(typeof r=="string"){if(this._registeredResources[r])throw new Error(`Resource ${r} is already registered`);let o=this._createRegisteredResource(t,void 0,r,n,i);return this.setResourceRequestHandlers(),this.sendResourceListChanged(),o}else{if(this._registeredResourceTemplates[t])throw new Error(`Resource template ${t} is already registered`);let o=this._createRegisteredResourceTemplate(t,void 0,r,n,i);return this.setResourceRequestHandlers(),this.sendResourceListChanged(),o}}registerResource(t,r,a,n){if(typeof r=="string"){if(this._registeredResources[r])throw new Error(`Resource ${r} is already registered`);let i=this._createRegisteredResource(t,a.title,r,a,n);return this.setResourceRequestHandlers(),this.sendResourceListChanged(),i}else{if(this._registeredResourceTemplates[t])throw new Error(`Resource template ${t} is already registered`);let i=this._createRegisteredResourceTemplate(t,a.title,r,a,n);return this.setResourceRequestHandlers(),this.sendResourceListChanged(),i}}_createRegisteredResource(t,r,a,n,i){let o={name:t,title:r,metadata:n,readCallback:i,enabled:!0,disable:()=>o.update({enabled:!1}),enable:()=>o.update({enabled:!0}),remove:()=>o.update({uri:null}),update:s=>{typeof s.uri<"u"&&s.uri!==a&&(delete this._registeredResources[a],s.uri&&(this._registeredResources[s.uri]=o)),typeof s.name<"u"&&(o.name=s.name),typeof s.title<"u"&&(o.title=s.title),typeof s.metadata<"u"&&(o.metadata=s.metadata),typeof s.callback<"u"&&(o.readCallback=s.callback),typeof s.enabled<"u"&&(o.enabled=s.enabled),this.sendResourceListChanged()}};return this._registeredResources[a]=o,o}_createRegisteredResourceTemplate(t,r,a,n,i){let o={resourceTemplate:a,title:r,metadata:n,readCallback:i,enabled:!0,disable:()=>o.update({enabled:!1}),enable:()=>o.update({enabled:!0}),remove:()=>o.update({name:null}),update:c=>{typeof c.name<"u"&&c.name!==t&&(delete this._registeredResourceTemplates[t],c.name&&(this._registeredResourceTemplates[c.name]=o)),typeof c.title<"u"&&(o.title=c.title),typeof c.template<"u"&&(o.resourceTemplate=c.template),typeof c.metadata<"u"&&(o.metadata=c.metadata),typeof c.callback<"u"&&(o.readCallback=c.callback),typeof c.enabled<"u"&&(o.enabled=c.enabled),this.sendResourceListChanged()}};this._registeredResourceTemplates[t]=o;let s=a.uriTemplate.variableNames;return Array.isArray(s)&&s.some(c=>!!a.completeCallback(c))&&this.setCompletionRequestHandler(),o}_createRegisteredPrompt(t,r,a,n,i){let o={title:r,description:a,argsSchema:n===void 0?void 0:aa(n),callback:i,enabled:!0,disable:()=>o.update({enabled:!1}),enable:()=>o.update({enabled:!0}),remove:()=>o.update({name:null}),update:s=>{typeof s.name<"u"&&s.name!==t&&(delete this._registeredPrompts[t],s.name&&(this._registeredPrompts[s.name]=o)),typeof s.title<"u"&&(o.title=s.title),typeof s.description<"u"&&(o.description=s.description),typeof s.argsSchema<"u"&&(o.argsSchema=aa(s.argsSchema)),typeof s.callback<"u"&&(o.callback=s.callback),typeof s.enabled<"u"&&(o.enabled=s.enabled),this.sendPromptListChanged()}};return this._registeredPrompts[t]=o,n&&Object.values(n).some(l=>{let c=l instanceof Kr?l._def?.innerType:l;return y_(c)})&&this.setCompletionRequestHandler(),o}_createRegisteredTool(t,r,a,n,i,o,s,l,c){k_(t);let u={title:r,description:a,inputSchema:GP(n),outputSchema:GP(i),annotations:o,execution:s,_meta:l,handler:c,enabled:!0,disable:()=>u.update({enabled:!1}),enable:()=>u.update({enabled:!0}),remove:()=>u.update({name:null}),update:d=>{typeof d.name<"u"&&d.name!==t&&(typeof d.name=="string"&&k_(d.name),delete this._registeredTools[t],d.name&&(this._registeredTools[d.name]=u)),typeof d.title<"u"&&(u.title=d.title),typeof d.description<"u"&&(u.description=d.description),typeof d.paramsSchema<"u"&&(u.inputSchema=aa(d.paramsSchema)),typeof d.outputSchema<"u"&&(u.outputSchema=aa(d.outputSchema)),typeof d.callback<"u"&&(u.handler=d.callback),typeof d.annotations<"u"&&(u.annotations=d.annotations),typeof d._meta<"u"&&(u._meta=d._meta),typeof d.enabled<"u"&&(u.enabled=d.enabled),this.sendToolListChanged()}};return this._registeredTools[t]=u,this.setToolRequestHandlers(),this.sendToolListChanged(),u}tool(t,...r){if(this._registeredTools[t])throw new Error(`Tool ${t} is already registered`);let a,n,i,o;if(typeof r[0]=="string"&&(a=r.shift()),r.length>1){let l=r[0];if(__(l))n=r.shift(),r.length>1&&typeof r[0]=="object"&&r[0]!==null&&!__(r[0])&&(o=r.shift());else if(typeof l=="object"&&l!==null){if(Object.values(l).some(c=>typeof c=="object"&&c!==null))throw new Error(`Tool ${t} expected a Zod schema or ToolAnnotations, but received an unrecognized object`);o=r.shift()}}let s=r[0];return this._createRegisteredTool(t,void 0,a,n,i,o,{taskSupport:"forbidden"},void 0,s)}registerTool(t,r,a){if(this._registeredTools[t])throw new Error(`Tool ${t} is already registered`);let{title:n,description:i,inputSchema:o,outputSchema:s,annotations:l,_meta:c}=r;return this._createRegisteredTool(t,n,i,o,s,l,{taskSupport:"forbidden"},c,a)}prompt(t,...r){if(this._registeredPrompts[t])throw new Error(`Prompt ${t} is already registered`);let a;typeof r[0]=="string"&&(a=r.shift());let n;r.length>1&&(n=r.shift());let i=r[0],o=this._createRegisteredPrompt(t,void 0,a,n,i);return this.setPromptRequestHandlers(),this.sendPromptListChanged(),o}registerPrompt(t,r,a){if(this._registeredPrompts[t])throw new Error(`Prompt ${t} is already registered`);let{title:n,description:i,argsSchema:o}=r,s=this._createRegisteredPrompt(t,n,i,o,a);return this.setPromptRequestHandlers(),this.sendPromptListChanged(),s}isConnected(){return this.server.transport!==void 0}async sendLoggingMessage(t,r){return this.server.sendLoggingMessage(t,r)}sendResourceListChanged(){this.isConnected()&&this.server.sendResourceListChanged()}sendToolListChanged(){this.isConnected()&&this.server.sendToolListChanged()}sendPromptListChanged(){this.isConnected()&&this.server.sendPromptListChanged()}};var uq={type:"object",properties:{}};function WP(e){return e!==null&&typeof e=="object"&&"parse"in e&&typeof e.parse=="function"&&"safeParse"in e&&typeof e.safeParse=="function"}function KP(e){return"_def"in e||"_zod"in e||WP(e)}function __(e){return typeof e!="object"||e===null||KP(e)?!1:Object.keys(e).length===0?!0:Object.values(e).some(WP)}function GP(e){if(e){if(__(e))return aa(e);if(!KP(e))throw new Error("inputSchema must be a Zod schema or raw shape, received an unrecognized object");return e}}function dq(e){let t=kr(e);return t?Object.entries(t).map(([r,a])=>{let n=aC(a),i=iC(a);return{name:r,description:n,required:!i}}):[]}function Ir(e){let r=kr(e)?.method;if(!r)throw new Error("Schema is missing a method literal");let a=Vi(r);if(typeof a=="string")return a;throw new Error("Schema method literal must be a string")}function VP(e){return{completion:{values:e.slice(0,100),total:e.length,hasMore:e.length>100}}}var ql={completion:{values:[],hasMore:!1}};var JP="ui://token-lens/card.html",YP="ui://token-lens/card-openai.html",pq="text/html;profile=mcp-app",mq="text/html+skybridge",eg=(e,t)=>({ui:{resourceUri:JP},"openai/outputTemplate":YP,"openai/toolInvocation/invoking":e,"openai/toolInvocation/invoked":t,"openai/widgetAccessible":!0}),ZP={ui:{prefersBorder:!0,csp:{connectDomains:[],resourceDomains:[]},permissions:{clipboardWrite:{}}},"openai/widgetPrefersBorder":!0,"openai/widgetDescription":"Shows the shorter prompt with a Copy button, the tokens and money saved, and what Token Lens checked was kept. The user can read it; don't repeat the shorter prompt in full."};function XP(e){for(let[t,r,a]of[["token-lens-card",JP,pq],["token-lens-card-openai",YP,mq]])e.registerResource(t,r,{title:"Token Lens card",description:"Token Lens results inside the chat.",mimeType:a,_meta:ZP},async()=>({contents:[{uri:r,mimeType:a,text:gq,_meta:ZP}]}))}var gq=`<!doctype html>
|
|
3564
3564
|
<html lang="en">
|
|
3565
3565
|
<head>
|
|
3566
3566
|
<meta charset="utf-8" />
|
|
@@ -3749,7 +3749,9 @@ tick();setInterval(tick,1000);
|
|
|
3749
3749
|
}).catch(function () { if (polling) { clearInterval(polling); polling = null; } });
|
|
3750
3750
|
}
|
|
3751
3751
|
var started = false;
|
|
3752
|
-
|
|
3752
|
+
// Connected to the app: the paste field shows now, not only once the tool's result arrives (some apps never pass it on).
|
|
3753
|
+
function ready() { $("wait").hidden = true; $("more").hidden = false; resize(); }
|
|
3754
|
+
function startPolling() { ready(); if (polling) return; started = true; refresh(); polling = setInterval(refresh, 5000); }
|
|
3753
3755
|
|
|
3754
3756
|
$("setup").addEventListener("click", function () {
|
|
3755
3757
|
$("setup").disabled = true;
|
|
@@ -3850,19 +3852,19 @@ tick();setInterval(tick,1000);
|
|
|
3850
3852
|
</script>
|
|
3851
3853
|
</body>
|
|
3852
3854
|
</html>
|
|
3853
|
-
`;var
|
|
3854
|
-
`),structuredContent:{model:t.label,profile:t.id,tokens:e,ratio:a.ratio,zone:a.zone,window:a.window,usdPerMessage:s,handoffSavesTokensPerMessage:l,handoffSavesUsdOver10Messages:c,handoffPrompt:o??null}}}function
|
|
3855
|
-
`)}function vq(e){let t=e.optimized.originalTokens?Math.round(e.optimized.saved/e.optimized.originalTokens*100):0;return e.optimized.saved>0?`Shown in the Token Lens card with Copy: ${Q(e.promptTokens)} -> ${Q(e.optimized.tokens)} tokens (${t}% fewer). Don't repeat the prompt; reply in one short line.`:"Shown in the Token Lens card: already tight. Reply in one short line."}function yq(e,t){let r=Ce(t,e.profile).tokens+30,a=e.promptTokens+20,n=e.profile.pricing;return{tokens:r+a,usd:n?(r*n.inputPerMTok+a*n.outputPerMTok)/1e6:null}}async function kq(e,t,r){try{let a=typeof process<"u"?process.env:{};if(r==="anthropic"&&a.ANTHROPIC_API_KEY&&/^claude-[\w.-]+$/.test(t)){let n=await fetch("https://api.anthropic.com/v1/messages/count_tokens",{method:"POST",headers:{"x-api-key":a.ANTHROPIC_API_KEY,"anthropic-version":"2023-06-01","content-type":"application/json"},body:JSON.stringify({model:t,messages:[{role:"user",content:e}]}),signal:AbortSignal.timeout(5e3)}),i=await n.json();return n.ok&&typeof i.input_tokens=="number"?{tokens:i.input_tokens,exact:!0}:null}if(r==="google"&&a.GEMINI_API_KEY&&/^gemini-[\w.-]+$/.test(t)){let n=await fetch(`https://generativelanguage.googleapis.com/v1beta/models/${t}:countTokens`,{method:"POST",headers:{"x-goog-api-key":a.GEMINI_API_KEY,"content-type":"application/json"},body:JSON.stringify({contents:[{parts:[{text:e}]}]}),signal:AbortSignal.timeout(5e3)}),i=await n.json();return n.ok&&typeof i.totalTokens=="number"?{tokens:i.totalTokens,exact:!0}:null}}catch{}return null}var _q={shorten:"Shorten my prompt before sending",optimize_prompt:"Optimized prompts",optimize_agent:"Agent fixes (per call)",audit_agent_rules:"Rule-file trims (per turn)",compact_data:"Compacted pasted data",compare_prompts:"Checked hand-shortened prompts"},wq="io.modelcontextprotocol/ui";function po(e,t){let r=e.server,a=r.getClientCapabilities();return a?!!a.extensions?.[wq]||/openai|chatgpt/i.test(r.getClientVersion()?.name??""):!!t}function Sq(e,t){return/code|cursor|vscode|windsurf|zed|cline|continue|jetbrains/i.test(e)?!1:t||/^claude-ai$|openai|chatgpt|le ?chat|mistral|perplexity|grok|gemini/i.test(e)}var Eq=["savings_report","plan_coach","live_tips","token_lens_helper"],xq="token-lens/via",e1=process.env.VERCEL_DEPLOYMENT_ID,a1=e1?gq("sha256").update(`token-lens-box:${e1}`).digest("hex").slice(0,32):hq(),w_={"token-lens/box":a1},i1=H.string().optional().describe("Set by the box itself.");function E_(e,t){return e?._meta?.[xq]==="box"||t?.box===a1}var o1={ui:{visibility:["app"]},"openai/visibility":"private","openai/widgetAccessible":!0},T_="For the Token Lens box only; never call it yourself.";function Tq(e){let t=e.server.getClientVersion()?.name??"";return[[/claude-code/i,"Claude Code"],[/claude/i,"Claude"],[/openai|chatgpt/i,"ChatGPT"],[/le ?chat|mistral/i,"Le Chat"],[/perplexity/i,"Perplexity"],[/grok/i,"Grok"],[/gemini/i,"Gemini"],[/cursor/i,"Cursor"],[/visual studio code|vscode/i,"VS Code"]].find(([a])=>a.test(t))?.[1]??""}var Aq={watching:"Shorten while you type is on: tips show here and as notifications.",starting:"Shorten while you type is starting.","cant-see-box":"Can't read the message box yet: click in it, or quit and reopen Claude.","needs-helper":"Shorten while you type needs Token Lens Helper on this Mac.",helper:"Shorten while you type is on: as you type in the message box, a Shorten button shows just above it when a shorter prompt says the same thing.","claude-closed":"Shorten while you type waits for the Claude app.",off:"Shorten while you type is off.",unsupported:""},Cq={watching:"Tips come as notifications while you type in the message box. Set up Token Lens Helper to get a Shorten button right above the box instead, so one click puts the shorter prompt in.","needs-helper":"To get tips while you type in the message box, set up Token Lens Helper. Then a Shorten button shows right above the box."};function zq(e,t){let r=t&&!["helper","off","unsupported"].includes(e);return{status:e,text:r&&Cq[e]||Aq[e]||"",helperOffer:r}}var s1={token_lens_state:{keep:["box"],description:T_},token_lens:{keep:["model","chat_tokens"],description:"Open the Token Lens box, where the user shortens prompts and sees costs without sending them to you. Use when asked to use Token Lens or shorten a prompt. Pass your rough estimate of this chat's tokens."},optimize_prompt:{keep:["prompt","model"],appOnly:!0,description:"Shorten a prompt to fewer tokens with the same meaning (every instruction, number, negation and code kept). Returns the shorter prompt and the savings. Use when asked to shorten or optimize a prompt."},check_conversation:{keep:["model","conversation_tokens"],appOnly:!0,description:"How full this chat's context is and what each new message costs. Pass your estimate of the chat's tokens; never copy the chat in."}};function Iq(e){let t=e.registerTool.bind(e);e.registerTool=(r,a,n)=>{let i=s1[r];if(i)return t(r,{...a,description:i.description,inputSchema:l1(a.inputSchema??{},i.keep),_meta:x_(a._meta,i.appOnly)},n)}}var t1=H.string().describe('Your model, e.g. "gpt-5".');function l1(e,t){return Object.fromEntries(Object.entries(e).filter(([r])=>t.includes(r)).map(([r,a])=>[r,r==="model"?a.isOptional()?t1.optional():t1:a]))}function x_(e,t){if(!t)return e;let r=e?.ui??{};return{...e,ui:{...r,visibility:["app"]},"openai/visibility":"private","openai/widgetAccessible":!0}}var Pq=["savings_report"];function Rq(e){let t=new Map,r=e.registerTool.bind(e);e.registerTool=(a,n,i)=>{let o=r(a,n,i);return t.set(a,{h:o,shape:n.inputSchema??{}}),o},e.server.oninitialized=()=>{if(Sq(e.server.getClientVersion()?.name??"",po(e)))for(let[a,{h:n,shape:i}]of t){let o=s1[a];o?(n.description=o.description,n.inputSchema=H.object(l1(i,o.keep)),n._meta=x_(n._meta,o.appOnly)):Pq.includes(a)?n._meta=x_(n._meta,!0):Eq.includes(a)||(n.enabled=!1)}}}function A_(e={}){let t=new Qm({name:"token-lens",version:fq}),r=e.ledger,a=(n,i,o,s)=>r?.record(n,i.id,o,s);return e.chat?Iq(t):process.env.TOKEN_LENS_TOOLS!=="all"&&Rq(t),e.live&&Oq(t,e.live),Mq(t,e.live),XP(t),t.registerPrompt("shorten",{title:"Shorten my prompt before sending",description:"Paste the prompt you're writing. Token Lens shortens it locally, keeping every instruction, fact, number, code block and constraint, and puts the shorter version in your message box. The long version never reaches the model.",argsSchema:{prompt:H.string().describe("The prompt you want to send, pasted in full."),model:H.string().optional().describe(`The model you'll send it to, e.g. "claude-sonnet-4-5" or "gpt-5". Leave blank for any model.`)}},({prompt:n,model:i})=>{let o=Xs({prompt:n,model:Sn(i??"",void 0),level:"auto"});a("shorten",o.profile,o.optimized.saved,o.cost.saved.usd);let s=o.optimized.originalTokens?Math.round(o.optimized.saved/o.optimized.originalTokens*100):0;return{description:o.optimized.saved>0?`Token Lens: ${Q(o.promptTokens)} -> ${Q(o.optimized.tokens)} tokens (${s}% fewer${o.cost.saved.usd===null?"":`, ${Te(o.cost.saved.usd)} saved`}). Kept: ${o.best.kept}.`:"Token Lens: already tight, sent unchanged.",messages:[{role:"user",content:{type:"text",text:o.optimized.saved>0?o.best.text:n}}]}}),t.registerTool("token_lens",{title:"Open Token Lens",description:"Open the Token Lens box in the chat, where the user shortens prompts without sending them to you. Use when asked to open or use Token Lens with no prompt given.",inputSchema:{model:Yn.optional(),chat_tokens:H.number().int().nonnegative().optional().describe("Rough tokens in this chat so far.")},annotations:{readOnlyHint:!0,openWorldHint:!1},_meta:eg("Opening Token Lens\u2026","Token Lens is open")},async({model:n,chat_tokens:i})=>{let o=Sn(n??"",void 0);n&&e.live?.insights.useModel(n);let s=i?QP(i,o,"").structuredContent:{};return{content:[{type:"text",text:po(t,e.chat)?'Token Lens box shown. Reply only "Open." If the user sees no box, ask for their prompt and call optimize_prompt.':"This app shows no Token Lens box. Ask the user to paste the prompt to shorten, then call optimize_prompt."}],structuredContent:{...s,panel:!0,model:n?o.label:"",profile:o.id},...po(t,e.chat)?{_meta:w_}:{}}}),t.registerTool("token_lens_state",{title:"Token Lens box status",description:T_,inputSchema:{box:i1},annotations:{readOnlyHint:!0,openWorldHint:!1},_meta:o1},async(n,i)=>{let o={app:Tq(t)},s=E_(i,n);if(r){let c=Ev(r.rows());o.savings={today:c.today,total:c.all}}let l=e.live;if(l){let c=l.insights.state;if(l.insights.refreshCoach(Date.now()),(l.insights.modelKnown||process.env.TOKEN_LENS_MODEL)&&(o.model=c.model),o.plan=l.insights.plan?.label??"",o.live=zq(l.status,l.helperOffer),s){let u=c.draft;o.draft=u&&{tokens:u.tokens,optimizedTokens:u.optimizedTokens,saved:u.saved,pct:u.pct,best:u.best},o.coach=c.coach?.insights.slice(0,3)??[]}}return{content:[{type:"text",text:"Token Lens box status."}],structuredContent:o}}),t.registerTool("optimize_prompt",{title:"Optimize a prompt for fewer tokens",description:"Shorten a prompt for a model with the same meaning (instructions, numbers, negations, code and quotes kept; task-aware). Returns the prompt to paste, savings and tips. Use when asked to shorten or optimize a prompt.",inputSchema:{prompt:H.string().describe("The prompt, as written."),model:Yn,level:H.enum(["auto",...fA]).optional().describe("Default auto."),conversation_tokens:H.number().int().nonnegative().optional().describe("Tokens already in the chat, if known."),pricing:uo},annotations:{readOnlyHint:!0,openWorldHint:!1},_meta:eg("Shortening the prompt\u2026","Shorter prompt ready")},async({prompt:n,model:i,level:o,conversation_tokens:s,pricing:l},c)=>{let u=Xs({prompt:n,model:Sn(i,l),conversationTokens:s,level:o??"auto"}),d=po(t,e.chat)?vq(u):bq(u),m=E_(c);!m&&i&&e.live?.insights.useModel(i);let p=m?{tokens:0,usd:0}:yq(u,d),g=u.optimized.saved-p.tokens;return a("optimize_prompt",u.profile,g,u.cost.saved.usd===null||p.usd===null?null:u.cost.saved.usd-p.usd),{content:[{type:"text",text:d}],structuredContent:{askTokens:p.tokens,askUsd:p.usd,model:u.profile.label,profile:u.profile.id,task:u.task.task,promptTokens:u.promptTokens,exact:u.exact,level:u.level,bestPrompt:u.best.text,kept:u.best.kept,optimizedTokens:u.optimized.tokens,saved:u.optimized.saved,savedUsd:u.cost.saved.usd,savedUsdPer1k:u.cost.saved.usdPer1k,promptUsd:u.cost.promptUsd,sendUsd:u.cost.sendUsd,pricing:u.cost.pricing??null,tips:u.tips.map(h=>h.text)},...po(t,e.chat)?{_meta:w_}:{}}}),t.registerTool("count_tokens",{title:"Count tokens",description:"Count a text's tokens for a model (exact for OpenAI; Claude and Gemini exact with the user's own API key set, else estimated). Use when asked how many tokens something is.",inputSchema:{text:H.string(),model:Yn,pricing:uo},annotations:{readOnlyHint:!0,openWorldHint:!1}},async({text:n,model:i,pricing:o})=>{let s=Sn(i,o),l=await kq(n,i,s.family)??Ce(n,s),{tokens:c,exact:u}=l,d=nt(c,s),m=Math.round(c/s.contextWindow*1e3)/10;return{content:[{type:"text",text:`${u?"":"\u2248"}${Q(c)} tokens for ${s.label} (${u?"exact":"estimate"}), ${m}% of a ~${Q(s.contextWindow)} token context. Costs ${Te(d)} as input each time it is sent (${Te(d===null?null:d*1e3)} per 1,000 sends). ${ba(s)}`}],structuredContent:{tokens:c,exact:u,profile:s.id,contextWindow:s.contextWindow,inputUsd:d,pricing:s.pricing??null}}}),t.registerTool("check_conversation",{title:"Check conversation token budget",description:"How full a chat's context is and what each message costs. Pass a token count (or the text). A long chat gets an optional new-chat handoff; present it as optional, since it can change later answers. Use for chat length, limits or forgotten context.",inputSchema:{model:Yn,conversation:H.string().optional().describe("The conversation so far, as text."),conversation_tokens:H.number().int().nonnegative().optional().describe("Or: its size in tokens."),latest_request:H.string().optional().describe("The latest message, to tailor the handoff."),pricing:uo},annotations:{readOnlyHint:!0,openWorldHint:!1},_meta:eg("Checking the chat\u2026","Chat checked")},async({model:n,conversation:i,conversation_tokens:o,latest_request:s,pricing:l})=>{let c=Sn(n,l),u=o??Ce(i??"",c).tokens,d=QP(u,c,s??i?.slice(-2e3)??"");return{content:[{type:"text",text:d.text}],structuredContent:d.structuredContent,...po(t,e.chat)?{_meta:w_}:{}}}),t.registerTool("optimize_agent",{title:"Find token hotspots and optimize an agent or conversation",description:"Find where an agent's tokens go (system prompt, tools, examples, history, next prompt), apply verified same-output fixes and return the optimized spec ready to paste, with the checks as evidence. Fixes that could change output are only listed, opt-in. Flags caching. Use when the user builds an agent or shares a system prompt or tools.",inputSchema:{model:Yn,system:H.string().optional().describe("System prompt / instructions."),tools:H.array(H.object({name:H.string(),description:H.string().optional(),parameters:H.any().optional()})).optional().describe("Tool definitions (parameters = JSON schema)."),examples:H.array(H.string()).optional().describe("Few-shot examples."),messages:H.array(H.object({role:H.enum(["user","assistant","tool","system"]),content:H.string(),toolCalls:H.array(H.string()).optional().describe("Names of tools called in this message.")})).optional().describe("Conversation history, oldest first."),prompt:H.string().optional().describe("The next user message."),pricing:uo,calls_per_month:H.number().int().positive().optional().describe("Calls per month, if known.")},annotations:{readOnlyHint:!0,openWorldHint:!1}},async({model:n,pricing:i,calls_per_month:o,...s})=>{let l=DA(s,Sn(n,i)),c=l.report;l.verification.passed&&a("optimize_agent",c.profile,l.savings.tokens,l.savings.usd);let u=v=>o&&v!==null?v*o:null,d=c.findings.filter(v=>v.risk==="review"),m=c.findings.filter(v=>v.risk==="safe"&&!v.applied),p=[l.verification.passed&&l.savings.tokens>0?`${Ci(l.savings)}${u(l.savings.usd)!==null?`, ${Te(u(l.savings.usd))} per month at ${Q(o)} calls`:""}: ${Q(l.before)} \u2192 ${Q(l.after)} tokens per call, same model and same output (checks below).`:l.verification.passed?"No wording savings to apply: the agent's text is already tight.":"No changes applied: a check failed, so the original spec is returned unchanged.",`Cost per call now: ${Te(c.costPerCall)} of input${l.savings.tokens>0?`, ${Te(nt(l.after,c.profile))} after the fixes`:""}. ${ba(c.profile)}`];m.length&&m[0].usd!==null&&p.push(`Also safe, needs a config change on your side: ${Te(m[0].usd)} more per call (${m[0].id}).`),d.length&&d[0].usd!==null&&p.push(`Opt-in fixes that could change the output (not applied): the biggest saves ${Te(d[0].usd)} more per call (${d[0].id}).`),p.push("",`Model profile: ${c.profile.label}. Total ${Q(c.total)} tokens per call; ${Q(c.fixedOverhead)} of it is re-sent every call (system + tools + examples).`,"","Where the tokens go:",...c.breakdown.map(v=>`- ${v.label}: ${Q(v.tokens)} (${c.total?Math.round(v.tokens/c.total*100):0}%)`)),c.growthPerTurn&&p.push(`Growing ~${Q(c.growthPerTurn)} tokens per user turn${c.turnsLeft!==null?`, about ${c.turnsLeft} turns of room left`:""}.`),p.push("",l.verification.passed?"Evidence the output is unchanged (same model, same tools, same instructions):":"Checks (one failed, so nothing was applied):",...l.verification.checks.map(v=>`${v.passed?"\u2713":"\u2717"} ${v.name}: ${v.detail}`));let g=c.findings.filter(v=>v.risk==="safe"),h=c.findings.filter(v=>v.risk==="review"),f=v=>v.id==="structured-output"?"saves every retry after a reply that doesn't parse":v.id==="price-threshold"&&!v.saves?"keeps the call at the lower rate":`saves ~${Q(v.saves)} tokens${v.usd!==null?`, ${Te(v.usd)} per call, ${Te(v.usd*1e3)} per 1,000 calls`:""}`;if(g.length&&p.push("","Safe fixes:",...g.map(v=>`- ${v.applied?"[applied] ":"[do this] "}${v.issue} ${v.fix} (${f(v)})`)),h.length&&p.push("","Could change the output, so not applied (ask the user):",...h.map(v=>`- ${v.issue} ${v.fix} (${f(v)})`)),l.verification.passed&&l.savings.tokens>0){let v=(C,S)=>["",`--- ${C} (paste this) ---`,S,"--- end ---"];l.spec.system&&l.spec.system!==s.system&&p.push(...v("optimized system prompt",l.spec.system)),l.spec.tools&&JSON.stringify(l.spec.tools)!==JSON.stringify(s.tools)&&p.push(...v("optimized tool definitions (JSON)",JSON.stringify(l.spec.tools,null,2))),l.spec.prompt&&l.spec.prompt!==s.prompt&&p.push(...v("optimized next prompt",l.spec.prompt)),l.spec.messages&&JSON.stringify(l.spec.messages)!==JSON.stringify(s.messages)&&p.push("","Conversation: exact repeats were replaced with pointers; the full list is in structuredContent.optimized.messages.")}s.system&&c.findings.some(v=>v.id==="volatile-prefix")&&p.push("","--- system prompt with the changing lines last (paste this) ---",Gv(l.spec.system??s.system).text,"--- end ---");let _=c.findings.some(v=>v.id==="structured-output")?Vv(s,c.profile):null;_&&p.push("",`--- strict JSON mode: add to the request (${c.profile.family==="anthropic"?"Anthropic Messages API":c.profile.family==="google"?"Gemini generateContent":"OpenAI-compatible API"}; paste this) ---`,JSON.stringify(_.setup,null,2),"--- end ---");let b=c.findings.some(v=>v.id==="lazy-tools")?Hv(l.spec.tools??[]):null;return b&&p.push("","--- on-demand tool loading: send these 2 tools instead of the full list (paste this) ---",JSON.stringify(b.tools,null,2),"--- end ---","Your runtime answers get_tool_schema with the tool's full definition (structuredContent.lazyTools.schemas) and runs invoke_tool by calling that tool with tool_input."),{content:[{type:"text",text:p.join(`
|
|
3855
|
+
`;var vq="0.1.0",Yn=H.string().describe('Model in use, e.g. "gpt-5"; yours if unsure.'),uo=H.object({input_per_mtok:H.number().nonnegative(),output_per_mtok:H.number().nonnegative(),cached_input_per_mtok:H.number().nonnegative().optional()}).optional().describe("USD per 1M tokens, only if not the list price.");function Sn(e,t){let r=Bn(e);return t?{...r,pricing:{inputPerMTok:t.input_per_mtok,outputPerMTok:t.output_per_mtok,cachedInputPerMTok:t.cached_input_per_mtok}}:r}var Q=e=>e.toLocaleString("en-US"),ba=e=>`Priced at ${e.label}: ${Dv(e.pricing)}.`;function QP(e,t,r){let a=Yr(e,0,t),n=hr(r).task,i=a.zone==="hot"||a.zone==="full"?`Context is nearly full; older messages will be dropped or compacted soon. A handoff to a new chat avoids that. ${Rt}`:a.longChat||a.zone==="warm"?`Every new message re-reads about ${Q(e)} tokens of history. A handoff to a new chat would cut that. ${Rt}`:"The conversation is still short; no handoff needed.",o=a.zone!=="ok"||a.longChat?$p(n):void 0,s=nt(e,t),l=o?Math.max(0,e-1e3):0,c=nt(l*10,t);return{text:[`${Q(e)} tokens, ${Math.round(a.ratio*100)}% of ${t.label}'s ~${Q(a.window)} token context.`,`Each new message re-reads this history: ${Te(s)} of input per message. ${ba(t)}`,...o?[`Optional: a handoff to a new chat saves about ${Q(l)} tokens (${Te(nt(l,t))}) per message, ${Te(c)} over the next 10 messages.`]:[],i,...o?["","Optional handoff request (can change later answers):",o]:[]].join(`
|
|
3856
|
+
`),structuredContent:{model:t.label,profile:t.id,tokens:e,ratio:a.ratio,zone:a.zone,window:a.window,usdPerMessage:s,handoffSavesTokensPerMessage:l,handoffSavesUsdOver10Messages:c,handoffPrompt:o??null}}}function yq(e){let t=e.optimized.originalTokens?Math.round(e.optimized.saved/e.optimized.originalTokens*100):0,r=[e.optimized.saved>0?`${Ci(e.cost.saved,"send")} (${t}% of the prompt). Meaning, numbers, code and constraints kept.`:`No saving: the prompt is already tight at the ${e.level} level.`,`${e.profile.label}: ${Q(e.promptTokens)} -> ${Q(e.optimized.tokens)} tokens${e.exact?"":" (estimate)"} (${Te(e.cost.promptUsd)} as sent).${e.usage.conversationTokens?` Context: ${Math.round(e.usage.ratio*100)}% of ~${Q(e.usage.window)} tokens.`:""}`];return e.optimized.saved>0&&r.push(`Kept: ${e.best.kept}.`,"--- best prompt, same answer (paste this) ---",e.best.text,"--- end ---"),e.tips.length&&r.push("Suggestions:",...e.tips.map(a=>`- ${a.text}${a.append?` (add: "${a.append}")`:""}`)),r.join(`
|
|
3857
|
+
`)}function kq(e){let t=e.optimized.originalTokens?Math.round(e.optimized.saved/e.optimized.originalTokens*100):0;return e.optimized.saved>0?`Shown in the Token Lens card with Copy: ${Q(e.promptTokens)} -> ${Q(e.optimized.tokens)} tokens (${t}% fewer). Don't repeat the prompt; reply in one short line.`:"Shown in the Token Lens card: already tight. Reply in one short line."}function _q(e,t){let r=Ce(t,e.profile).tokens+30,a=e.promptTokens+20,n=e.profile.pricing;return{tokens:r+a,usd:n?(r*n.inputPerMTok+a*n.outputPerMTok)/1e6:null}}async function wq(e,t,r){try{let a=typeof process<"u"?process.env:{};if(r==="anthropic"&&a.ANTHROPIC_API_KEY&&/^claude-[\w.-]+$/.test(t)){let n=await fetch("https://api.anthropic.com/v1/messages/count_tokens",{method:"POST",headers:{"x-api-key":a.ANTHROPIC_API_KEY,"anthropic-version":"2023-06-01","content-type":"application/json"},body:JSON.stringify({model:t,messages:[{role:"user",content:e}]}),signal:AbortSignal.timeout(5e3)}),i=await n.json();return n.ok&&typeof i.input_tokens=="number"?{tokens:i.input_tokens,exact:!0}:null}if(r==="google"&&a.GEMINI_API_KEY&&/^gemini-[\w.-]+$/.test(t)){let n=await fetch(`https://generativelanguage.googleapis.com/v1beta/models/${t}:countTokens`,{method:"POST",headers:{"x-goog-api-key":a.GEMINI_API_KEY,"content-type":"application/json"},body:JSON.stringify({contents:[{parts:[{text:e}]}]}),signal:AbortSignal.timeout(5e3)}),i=await n.json();return n.ok&&typeof i.totalTokens=="number"?{tokens:i.totalTokens,exact:!0}:null}}catch{}return null}var Sq={shorten:"Shorten my prompt before sending",optimize_prompt:"Optimized prompts",optimize_agent:"Agent fixes (per call)",audit_agent_rules:"Rule-file trims (per turn)",compact_data:"Compacted pasted data",compare_prompts:"Checked hand-shortened prompts"},Eq="io.modelcontextprotocol/ui";function po(e,t){let r=e.server,a=r.getClientCapabilities();return a?!!a.extensions?.[Eq]||/openai|chatgpt/i.test(r.getClientVersion()?.name??""):!!t}function xq(e,t){return/code|cursor|vscode|windsurf|zed|cline|continue|jetbrains/i.test(e)?!1:t||/^claude-ai$|openai|chatgpt|le ?chat|mistral|perplexity|grok|gemini/i.test(e)}var Tq=["savings_report","plan_coach","live_tips","token_lens_helper"],Aq="token-lens/via",e1=process.env.VERCEL_DEPLOYMENT_ID,a1=e1?fq("sha256").update(`token-lens-box:${e1}`).digest("hex").slice(0,32):bq(),w_={"token-lens/box":a1},i1=H.string().optional().describe("Set by the box itself.");function E_(e,t){return e?._meta?.[Aq]==="box"||t?.box===a1}var o1={ui:{visibility:["app"]},"openai/visibility":"private","openai/widgetAccessible":!0},T_="For the Token Lens box only; never call it yourself.";function Cq(e){let t=e.server.getClientVersion()?.name??"";return[[/claude-code/i,"Claude Code"],[/claude/i,"Claude"],[/openai|chatgpt/i,"ChatGPT"],[/le ?chat|mistral/i,"Le Chat"],[/perplexity/i,"Perplexity"],[/grok/i,"Grok"],[/gemini/i,"Gemini"],[/cursor/i,"Cursor"],[/visual studio code|vscode/i,"VS Code"]].find(([a])=>a.test(t))?.[1]??""}var zq={watching:"Shorten while you type is on: tips show here and as notifications.",starting:"Shorten while you type is starting.","cant-see-box":"Can't read the message box yet: click in it, or quit and reopen Claude.","needs-helper":"Shorten while you type needs Token Lens Helper on this Mac.",helper:"Shorten while you type is on: as you type in the message box, a Shorten button shows just above it when a shorter prompt says the same thing.","claude-closed":"Shorten while you type waits for the Claude app.",off:"Shorten while you type is off.",unsupported:""},Iq={watching:"Tips come as notifications while you type in the message box. Set up Token Lens Helper to get a Shorten button right above the box instead, so one click puts the shorter prompt in.","needs-helper":"To get tips while you type in the message box, set up Token Lens Helper. Then a Shorten button shows right above the box."};function Pq(e,t){let r=t&&!["helper","off","unsupported"].includes(e);return{status:e,text:r&&Iq[e]||zq[e]||"",helperOffer:r}}var s1={token_lens_state:{keep:["box"],description:T_},token_lens:{keep:["model","chat_tokens"],description:"Open the Token Lens box, where the user shortens prompts and sees costs without sending them to you. Use when asked to use Token Lens or shorten a prompt. Pass your rough estimate of this chat's tokens."},optimize_prompt:{keep:["prompt","model"],appOnly:!0,description:"Shorten a prompt to fewer tokens with the same meaning (every instruction, number, negation and code kept). Returns the shorter prompt and the savings. Use when asked to shorten or optimize a prompt."},check_conversation:{keep:["model","conversation_tokens"],appOnly:!0,description:"How full this chat's context is and what each new message costs. Pass your estimate of the chat's tokens; never copy the chat in."}};function Rq(e){let t=e.registerTool.bind(e);e.registerTool=(r,a,n)=>{let i=s1[r];if(i)return t(r,{...a,description:i.description,inputSchema:l1(a.inputSchema??{},i.keep),_meta:x_(a._meta,i.appOnly)},n)}}var t1=H.string().describe('Your model, e.g. "gpt-5".');function l1(e,t){return Object.fromEntries(Object.entries(e).filter(([r])=>t.includes(r)).map(([r,a])=>[r,r==="model"?a.isOptional()?t1.optional():t1:a]))}function x_(e,t){if(!t)return e;let r=e?.ui??{};return{...e,ui:{...r,visibility:["app"]},"openai/visibility":"private","openai/widgetAccessible":!0}}var $q=["savings_report"];function jq(e){let t=new Map,r=e.registerTool.bind(e);e.registerTool=(a,n,i)=>{let o=r(a,n,i);return t.set(a,{h:o,shape:n.inputSchema??{}}),o},e.server.oninitialized=()=>{if(xq(e.server.getClientVersion()?.name??"",po(e)))for(let[a,{h:n,shape:i}]of t){let o=s1[a];o?(n.description=o.description,n.inputSchema=H.object(l1(i,o.keep)),n._meta=x_(n._meta,o.appOnly)):$q.includes(a)?n._meta=x_(n._meta,!0):Tq.includes(a)||(n.enabled=!1)}}}function A_(e={}){let t=new Qm({name:"token-lens",version:vq}),r=e.ledger,a=(n,i,o,s)=>r?.record(n,i.id,o,s);return e.chat?Rq(t):process.env.TOKEN_LENS_TOOLS!=="all"&&jq(t),e.live&&Dq(t,e.live),Bq(t,e.live),XP(t),t.registerPrompt("shorten",{title:"Shorten my prompt before sending",description:"Paste the prompt you're writing. Token Lens shortens it locally, keeping every instruction, fact, number, code block and constraint, and puts the shorter version in your message box. The long version never reaches the model.",argsSchema:{prompt:H.string().describe("The prompt you want to send, pasted in full."),model:H.string().optional().describe(`The model you'll send it to, e.g. "claude-sonnet-4-5" or "gpt-5". Leave blank for any model.`)}},({prompt:n,model:i})=>{let o=Xs({prompt:n,model:Sn(i??"",void 0),level:"auto"});a("shorten",o.profile,o.optimized.saved,o.cost.saved.usd);let s=o.optimized.originalTokens?Math.round(o.optimized.saved/o.optimized.originalTokens*100):0;return{description:o.optimized.saved>0?`Token Lens: ${Q(o.promptTokens)} -> ${Q(o.optimized.tokens)} tokens (${s}% fewer${o.cost.saved.usd===null?"":`, ${Te(o.cost.saved.usd)} saved`}). Kept: ${o.best.kept}.`:"Token Lens: already tight, sent unchanged.",messages:[{role:"user",content:{type:"text",text:o.optimized.saved>0?o.best.text:n}}]}}),t.registerTool("token_lens",{title:"Open Token Lens",description:"Open the Token Lens box in the chat, where the user shortens prompts without sending them to you. Use when asked to open or use Token Lens with no prompt given.",inputSchema:{model:Yn.optional(),chat_tokens:H.number().int().nonnegative().optional().describe("Rough tokens in this chat so far.")},annotations:{readOnlyHint:!0,openWorldHint:!1},_meta:eg("Opening Token Lens\u2026","Token Lens is open")},async({model:n,chat_tokens:i})=>{let o=Sn(n??"",void 0);n&&e.live?.insights.useModel(n);let s=i?QP(i,o,"").structuredContent:{};return{content:[{type:"text",text:po(t,e.chat)?'Token Lens box shown. Reply only "Open." If the user sees no box, ask for their prompt and call optimize_prompt.':"This app shows no Token Lens box. Ask the user to paste the prompt to shorten, then call optimize_prompt."}],structuredContent:{...s,panel:!0,model:n?o.label:"",profile:o.id},...po(t,e.chat)?{_meta:w_}:{}}}),t.registerTool("token_lens_state",{title:"Token Lens box status",description:T_,inputSchema:{box:i1},annotations:{readOnlyHint:!0,openWorldHint:!1},_meta:o1},async(n,i)=>{let o={app:Cq(t)},s=E_(i,n);if(r){let c=Ev(r.rows());o.savings={today:c.today,total:c.all}}let l=e.live;if(l){let c=l.insights.state;if(l.insights.refreshCoach(Date.now()),(l.insights.modelKnown||process.env.TOKEN_LENS_MODEL)&&(o.model=c.model),o.plan=l.insights.plan?.label??"",o.live=Pq(l.status,l.helperOffer),s){let u=c.draft;o.draft=u&&{tokens:u.tokens,optimizedTokens:u.optimizedTokens,saved:u.saved,pct:u.pct,best:u.best},o.coach=c.coach?.insights.slice(0,3)??[]}}return{content:[{type:"text",text:"Token Lens box status."}],structuredContent:o}}),t.registerTool("optimize_prompt",{title:"Optimize a prompt for fewer tokens",description:"Shorten a prompt for a model with the same meaning (instructions, numbers, negations, code and quotes kept; task-aware). Returns the prompt to paste, savings and tips. Use when asked to shorten or optimize a prompt.",inputSchema:{prompt:H.string().describe("The prompt, as written."),model:Yn,level:H.enum(["auto",...fA]).optional().describe("Default auto."),conversation_tokens:H.number().int().nonnegative().optional().describe("Tokens already in the chat, if known."),pricing:uo},annotations:{readOnlyHint:!0,openWorldHint:!1},_meta:eg("Shortening the prompt\u2026","Shorter prompt ready")},async({prompt:n,model:i,level:o,conversation_tokens:s,pricing:l},c)=>{let u=Xs({prompt:n,model:Sn(i,l),conversationTokens:s,level:o??"auto"}),d=po(t,e.chat)?kq(u):yq(u),m=E_(c);!m&&i&&e.live?.insights.useModel(i);let p=m?{tokens:0,usd:0}:_q(u,d),g=u.optimized.saved-p.tokens;return a("optimize_prompt",u.profile,g,u.cost.saved.usd===null||p.usd===null?null:u.cost.saved.usd-p.usd),{content:[{type:"text",text:d}],structuredContent:{askTokens:p.tokens,askUsd:p.usd,model:u.profile.label,profile:u.profile.id,task:u.task.task,promptTokens:u.promptTokens,exact:u.exact,level:u.level,bestPrompt:u.best.text,kept:u.best.kept,optimizedTokens:u.optimized.tokens,saved:u.optimized.saved,savedUsd:u.cost.saved.usd,savedUsdPer1k:u.cost.saved.usdPer1k,promptUsd:u.cost.promptUsd,sendUsd:u.cost.sendUsd,pricing:u.cost.pricing??null,tips:u.tips.map(h=>h.text)},...po(t,e.chat)?{_meta:w_}:{}}}),t.registerTool("count_tokens",{title:"Count tokens",description:"Count a text's tokens for a model (exact for OpenAI; Claude and Gemini exact with the user's own API key set, else estimated). Use when asked how many tokens something is.",inputSchema:{text:H.string(),model:Yn,pricing:uo},annotations:{readOnlyHint:!0,openWorldHint:!1}},async({text:n,model:i,pricing:o})=>{let s=Sn(i,o),l=await wq(n,i,s.family)??Ce(n,s),{tokens:c,exact:u}=l,d=nt(c,s),m=Math.round(c/s.contextWindow*1e3)/10;return{content:[{type:"text",text:`${u?"":"\u2248"}${Q(c)} tokens for ${s.label} (${u?"exact":"estimate"}), ${m}% of a ~${Q(s.contextWindow)} token context. Costs ${Te(d)} as input each time it is sent (${Te(d===null?null:d*1e3)} per 1,000 sends). ${ba(s)}`}],structuredContent:{tokens:c,exact:u,profile:s.id,contextWindow:s.contextWindow,inputUsd:d,pricing:s.pricing??null}}}),t.registerTool("check_conversation",{title:"Check conversation token budget",description:"How full a chat's context is and what each message costs. Pass a token count (or the text). A long chat gets an optional new-chat handoff; present it as optional, since it can change later answers. Use for chat length, limits or forgotten context.",inputSchema:{model:Yn,conversation:H.string().optional().describe("The conversation so far, as text."),conversation_tokens:H.number().int().nonnegative().optional().describe("Or: its size in tokens."),latest_request:H.string().optional().describe("The latest message, to tailor the handoff."),pricing:uo},annotations:{readOnlyHint:!0,openWorldHint:!1},_meta:eg("Checking the chat\u2026","Chat checked")},async({model:n,conversation:i,conversation_tokens:o,latest_request:s,pricing:l})=>{let c=Sn(n,l),u=o??Ce(i??"",c).tokens,d=QP(u,c,s??i?.slice(-2e3)??"");return{content:[{type:"text",text:d.text}],structuredContent:d.structuredContent,...po(t,e.chat)?{_meta:w_}:{}}}),t.registerTool("optimize_agent",{title:"Find token hotspots and optimize an agent or conversation",description:"Find where an agent's tokens go (system prompt, tools, examples, history, next prompt), apply verified same-output fixes and return the optimized spec ready to paste, with the checks as evidence. Fixes that could change output are only listed, opt-in. Flags caching. Use when the user builds an agent or shares a system prompt or tools.",inputSchema:{model:Yn,system:H.string().optional().describe("System prompt / instructions."),tools:H.array(H.object({name:H.string(),description:H.string().optional(),parameters:H.any().optional()})).optional().describe("Tool definitions (parameters = JSON schema)."),examples:H.array(H.string()).optional().describe("Few-shot examples."),messages:H.array(H.object({role:H.enum(["user","assistant","tool","system"]),content:H.string(),toolCalls:H.array(H.string()).optional().describe("Names of tools called in this message.")})).optional().describe("Conversation history, oldest first."),prompt:H.string().optional().describe("The next user message."),pricing:uo,calls_per_month:H.number().int().positive().optional().describe("Calls per month, if known.")},annotations:{readOnlyHint:!0,openWorldHint:!1}},async({model:n,pricing:i,calls_per_month:o,...s})=>{let l=DA(s,Sn(n,i)),c=l.report;l.verification.passed&&a("optimize_agent",c.profile,l.savings.tokens,l.savings.usd);let u=v=>o&&v!==null?v*o:null,d=c.findings.filter(v=>v.risk==="review"),m=c.findings.filter(v=>v.risk==="safe"&&!v.applied),p=[l.verification.passed&&l.savings.tokens>0?`${Ci(l.savings)}${u(l.savings.usd)!==null?`, ${Te(u(l.savings.usd))} per month at ${Q(o)} calls`:""}: ${Q(l.before)} \u2192 ${Q(l.after)} tokens per call, same model and same output (checks below).`:l.verification.passed?"No wording savings to apply: the agent's text is already tight.":"No changes applied: a check failed, so the original spec is returned unchanged.",`Cost per call now: ${Te(c.costPerCall)} of input${l.savings.tokens>0?`, ${Te(nt(l.after,c.profile))} after the fixes`:""}. ${ba(c.profile)}`];m.length&&m[0].usd!==null&&p.push(`Also safe, needs a config change on your side: ${Te(m[0].usd)} more per call (${m[0].id}).`),d.length&&d[0].usd!==null&&p.push(`Opt-in fixes that could change the output (not applied): the biggest saves ${Te(d[0].usd)} more per call (${d[0].id}).`),p.push("",`Model profile: ${c.profile.label}. Total ${Q(c.total)} tokens per call; ${Q(c.fixedOverhead)} of it is re-sent every call (system + tools + examples).`,"","Where the tokens go:",...c.breakdown.map(v=>`- ${v.label}: ${Q(v.tokens)} (${c.total?Math.round(v.tokens/c.total*100):0}%)`)),c.growthPerTurn&&p.push(`Growing ~${Q(c.growthPerTurn)} tokens per user turn${c.turnsLeft!==null?`, about ${c.turnsLeft} turns of room left`:""}.`),p.push("",l.verification.passed?"Evidence the output is unchanged (same model, same tools, same instructions):":"Checks (one failed, so nothing was applied):",...l.verification.checks.map(v=>`${v.passed?"\u2713":"\u2717"} ${v.name}: ${v.detail}`));let g=c.findings.filter(v=>v.risk==="safe"),h=c.findings.filter(v=>v.risk==="review"),f=v=>v.id==="structured-output"?"saves every retry after a reply that doesn't parse":v.id==="price-threshold"&&!v.saves?"keeps the call at the lower rate":`saves ~${Q(v.saves)} tokens${v.usd!==null?`, ${Te(v.usd)} per call, ${Te(v.usd*1e3)} per 1,000 calls`:""}`;if(g.length&&p.push("","Safe fixes:",...g.map(v=>`- ${v.applied?"[applied] ":"[do this] "}${v.issue} ${v.fix} (${f(v)})`)),h.length&&p.push("","Could change the output, so not applied (ask the user):",...h.map(v=>`- ${v.issue} ${v.fix} (${f(v)})`)),l.verification.passed&&l.savings.tokens>0){let v=(C,S)=>["",`--- ${C} (paste this) ---`,S,"--- end ---"];l.spec.system&&l.spec.system!==s.system&&p.push(...v("optimized system prompt",l.spec.system)),l.spec.tools&&JSON.stringify(l.spec.tools)!==JSON.stringify(s.tools)&&p.push(...v("optimized tool definitions (JSON)",JSON.stringify(l.spec.tools,null,2))),l.spec.prompt&&l.spec.prompt!==s.prompt&&p.push(...v("optimized next prompt",l.spec.prompt)),l.spec.messages&&JSON.stringify(l.spec.messages)!==JSON.stringify(s.messages)&&p.push("","Conversation: exact repeats were replaced with pointers; the full list is in structuredContent.optimized.messages.")}s.system&&c.findings.some(v=>v.id==="volatile-prefix")&&p.push("","--- system prompt with the changing lines last (paste this) ---",Gv(l.spec.system??s.system).text,"--- end ---");let _=c.findings.some(v=>v.id==="structured-output")?Vv(s,c.profile):null;_&&p.push("",`--- strict JSON mode: add to the request (${c.profile.family==="anthropic"?"Anthropic Messages API":c.profile.family==="google"?"Gemini generateContent":"OpenAI-compatible API"}; paste this) ---`,JSON.stringify(_.setup,null,2),"--- end ---");let b=c.findings.some(v=>v.id==="lazy-tools")?Hv(l.spec.tools??[]):null;return b&&p.push("","--- on-demand tool loading: send these 2 tools instead of the full list (paste this) ---",JSON.stringify(b.tools,null,2),"--- end ---","Your runtime answers get_tool_schema with the tool's full definition (structuredContent.lazyTools.schemas) and runs invoke_tool by calling that tool with tool_input."),{content:[{type:"text",text:p.join(`
|
|
3856
3858
|
`)}],structuredContent:{lazyTools:b,structuredOutput:_?.setup??null,before:l.before,after:l.after,savedTokens:l.savings.tokens,savedUsdPerCall:l.savings.usd,savedUsdPer1kCalls:l.savings.usdPer1k,savedUsdPerMonth:u(l.savings.usd),costPerCallUsd:c.costPerCall,pricing:c.profile.pricing??null,breakdown:c.breakdown,growthPerTurn:c.growthPerTurn,turnsLeft:c.turnsLeft,findings:c.findings,optimized:l.spec,verification:l.verification}}}),t.registerTool("audit_agent_rules",{title:"Trim coding-agent rule files",description:"Trim coding-agent rule files (CLAUDE.md, AGENTS.md, .cursorrules and the like) without changing any instruction: repeats removed, wording tightened with every number and negation kept. Returns files to paste and savings per turn. Use when the user shares agent rule files.",inputSchema:{model:Yn,files:H.array(H.object({path:H.string(),content:H.string()})).min(1).describe("Each rule file: its path and full text."),repo_paths:H.array(H.string()).optional().describe("Repo file paths, to flag rules naming missing files."),pricing:uo},annotations:{readOnlyHint:!0,openWorldHint:!1}},async({model:n,files:i,repo_paths:o,pricing:s})=>{let l=Sn(n,s),c=MA(i,l,{knownPaths:o}),u=c.before-c.after;a("audit_agent_rules",l,c.saved.tokens,c.saved.usd);let d=[u>0?`${Ci(c.saved)} per turn: ${Q(c.before)} \u2192 ${Q(c.after)} tokens of rules re-sent every turn, same instructions.`:`Nothing to trim: ${Q(c.before)} tokens of rules, no repeats, wording already tight.`,ba(l)],m=c.findings.filter(g=>g.kind==="duplicate");m.length&&d.push("","Exact repeats removed:",...m.map(g=>`- ${g.path}:${g.line} ${g.text} (${g.detail})`));let p=c.findings.filter(g=>g.kind==="stale-path");p.length&&d.push("","Check these (not removed): they mention files that aren't in the repo.",...p.map(g=>`- ${g.path}:${g.line} ${g.detail}`));for(let g of c.files)g.trimmed!==i.find(h=>h.path===g.path)?.content&&d.push("",`--- ${g.path}, trimmed (${Q(g.tokens)} \u2192 ${Q(g.trimmedTokens)} tokens; paste this) ---`,g.trimmed,"--- end ---");return{content:[{type:"text",text:d.join(`
|
|
3857
3859
|
`)}],structuredContent:{before:c.before,after:c.after,savedTokensPerTurn:c.saved.tokens,savedUsdPerTurn:c.saved.usd,savedUsdPer1kTurns:c.saved.usdPer1k,files:c.files,findings:c.findings,pricing:l.pricing??null}}}),t.registerTool("list_model_profiles",{title:"List model profiles",description:"List the model families Token Lens knows, with context windows and prices.",inputSchema:{},annotations:{readOnlyHint:!0,openWorldHint:!1}},async()=>({content:[{type:"text",text:Object.values(hn).map(n=>`${n.id}: ${n.label}, ~${Q(n.contextWindow)} context, ${n.tokenizer==="o200k"?"exact":"estimated"} counts${n.reasoning?", reasoning model":""}, ${Dv(n.pricing)}`).join(`
|
|
3858
3860
|
`)}]})),t.registerTool("compact_data",{title:"Shrink pasted data without changing it",description:"Shrink pasted JSON or logs with the data unchanged (whitespace only, proven by parsing). Use when the user pastes large data.",inputSchema:{text:H.string().describe("Text with the pasted data, as written."),model:Yn},annotations:{readOnlyHint:!0,openWorldHint:!1}},async({text:n,model:i})=>{let o=Sn(i,void 0),s=Up(n,o),l=$t(s.saved,o);return a("compact_data",o,s.saved,l.usd),{content:[{type:"text",text:(s.saved>0?[`${Ci(l,"send")} (${Math.round(s.saved/s.before*100)}%): ${Q(s.before)} \u2192 ${Q(s.after)} tokens, same data. ${ba(o)}`,"","What changed:",...s.changes.map(u=>`- ${u}`),...s.checks.length?["","Evidence the data is unchanged:",...s.checks.map(u=>`\u2713 ${u.name}: ${u.detail}`)]:[],"","--- compact text, same data (paste this) ---",s.text,"--- end ---"]:[`No saving: ${s.skipped??"already compact."} ${Q(s.before)} tokens.`]).join(`
|
|
3859
3861
|
`)}],structuredContent:{before:s.before,after:s.after,savedTokens:s.saved,savedUsd:l.usd,compactText:s.text,changes:s.changes,blocks:s.blocks,checks:s.checks,skipped:s.skipped??null}}}),t.registerTool("compare_prompts",{title:"Check a shortened prompt against the original",description:"Check a shortened prompt against the original: savings and any number, negation or rule lost.",inputSchema:{original:H.string(),edited:H.string(),model:Yn},annotations:{readOnlyHint:!0,openWorldHint:!1}},async({original:n,edited:i,model:o})=>{let s=Sn(o,void 0),l=AA(n,i,s);l.sameInstructions&&a("compare_prompts",s,l.saved.tokens,l.saved.usd);let c=[l.verdict,l.saved.tokens>0?`${Ci(l.saved,"send")}: ${Q(l.before)} \u2192 ${Q(l.after)} tokens. ${ba(s)}`:`${Q(l.before)} \u2192 ${Q(l.after)} tokens: the edit is not shorter.`];return l.lostFacts.length&&c.push("","Missing from the shorter version (can change the answer):",...l.lostFacts.map(u=>`- ${u}`)),l.lostWords.length&&c.push("",`Words dropped that may carry instructions: ${l.lostWords.join(", ")}.`),{content:[{type:"text",text:c.join(`
|
|
3860
3862
|
`)}],structuredContent:{before:l.before,after:l.after,savedTokens:l.saved.tokens,savedUsd:l.saved.usd,sameInstructions:l.sameInstructions,lostFacts:l.lostFacts,lostWords:l.lostWords,verdict:l.verdict}}}),t.registerTool("estimate_cost",{title:"Forecast monthly cost and same-answer savings",description:"Monthly cost of an app or agent on its model, and what same-answer caching and batching save. Use for LLM budgets.",inputSchema:{model:Yn,input_tokens:H.number().int().nonnegative().describe("Per call."),output_tokens:H.number().int().nonnegative().describe("Per call, incl. reasoning."),calls_per_day:H.number().positive(),repeated_prefix_tokens:H.number().int().nonnegative().optional().describe("Unchanging start of each call: system, tools, examples."),can_wait_share:H.number().min(0).max(1).optional().describe("Share of calls that can wait 24h."),pricing:uo},annotations:{readOnlyHint:!0,openWorldHint:!1}},async({model:n,input_tokens:i,output_tokens:o,calls_per_day:s,repeated_prefix_tokens:l,can_wait_share:c,pricing:u})=>{let d=Sn(n,u),m=CA(d,{inputTokens:i,outputTokens:o,callsPerDay:s,repeatedPrefixTokens:l,canWaitShare:c});if(!m.priced)return{content:[{type:"text",text:`No price is set for ${d.label}. Pass pricing with your per-1M-token rates to get a forecast.`}]};let p=m.lines.reduce((h,f)=>f.monthlyUsd<h.monthlyUsd?f:h),g=[`${d.label}, ${Q(m.callsPerMonth)} calls a month: ${Te(m.lines[0].monthlyUsd)} a month now${p.id!=="now"?`; ${Te(p.monthlyUsd)} with ${p.label.toLowerCase()}, saving ${Te(p.savedUsd)} a month (${Te(p.savedUsd*12)} a year) with the same answers`:""}.`,ba(d),"",...m.lines.map(h=>`- ${h.label}: ${Te(h.monthlyUsd)} a month${h.savedUsd>0?`, saves ${Te(h.savedUsd)}`:""}.${h.note?` ${h.note}`:""}`)];return l?m.rates.cached===null&&g.push("",`${d.label} has no cached-input price on file; pass pricing.cached_input_per_mtok to include caching.`):g.push("","Tip: pass repeated_prefix_tokens (system prompt, tools and examples) to see what prompt caching saves."),!c&&["openai","anthropic","google"].includes(d.family)&&g.push("","Tip: if some calls can wait up to 24 hours (reports, bulk jobs), pass can_wait_share to see the half-price batch saving."),{content:[{type:"text",text:g.join(`
|
|
3861
|
-
`)}],structuredContent:{profile:d.id,callsPerMonth:m.callsPerMonth,longContext:m.longContext,rates:m.rates,options:m.lines}}}),t.registerTool("savings_report",{title:"Show total tokens and money saved",description:"Tokens and money Token Lens has saved: today, 7 and 30 days, total, by action and model.",inputSchema:{},annotations:{readOnlyHint:!0,openWorldHint:!1}},async()=>{if(!r)return{content:[{type:"text",text:"Totals aren't kept here: this copy of Token Lens stores nothing. Run Token Lens on your own computer (the npm package) and it keeps a running total of numbers only, never your text."}]};let n=Ev(r.rows()),i=s=>`${Q(s.tokens)} tokens, ${Te(s.usd)} (${Q(s.count)} ${s.count===1?"time":"times"})`;return{content:[{type:"text",text:(n.since?[`Token Lens has saved ${Q(n.all.tokens)} tokens and ${Te(n.all.usd)} since ${n.since}, priced for the model each saving was on.`,"",`Today: ${i(n.today)}`,`Last 7 days: ${i(n.last7)}`,`Last 30 days: ${i(n.last30)}`,"","By action:",...n.byAction.map(s=>`- ${
|
|
3862
|
-
`)}],structuredContent:{...n,where:r.where}}}),t}var
|
|
3863
|
+
`)}],structuredContent:{profile:d.id,callsPerMonth:m.callsPerMonth,longContext:m.longContext,rates:m.rates,options:m.lines}}}),t.registerTool("savings_report",{title:"Show total tokens and money saved",description:"Tokens and money Token Lens has saved: today, 7 and 30 days, total, by action and model.",inputSchema:{},annotations:{readOnlyHint:!0,openWorldHint:!1}},async()=>{if(!r)return{content:[{type:"text",text:"Totals aren't kept here: this copy of Token Lens stores nothing. Run Token Lens on your own computer (the npm package) and it keeps a running total of numbers only, never your text."}]};let n=Ev(r.rows()),i=s=>`${Q(s.tokens)} tokens, ${Te(s.usd)} (${Q(s.count)} ${s.count===1?"time":"times"})`;return{content:[{type:"text",text:(n.since?[`Token Lens has saved ${Q(n.all.tokens)} tokens and ${Te(n.all.usd)} since ${n.since}, priced for the model each saving was on.`,"",`Today: ${i(n.today)}`,`Last 7 days: ${i(n.last7)}`,`Last 30 days: ${i(n.last30)}`,"","By action:",...n.byAction.map(s=>`- ${Sq[s.action]??s.action}: ${i(s)}`),"","By model:",...n.byModel.map(s=>`- ${hn[s.model]?.label??s.model}: ${i(s)}`),"","Counts the saving each time Token Lens found one; agent and rule-file savings are per call or turn, so they repeat every time those run. Kept as numbers only"+(r.where?` in ${r.where} (set TOKEN_LENS_LEDGER=off to stop).`:" for this session.")]:["Nothing saved yet. Totals start the first time Token Lens shortens a prompt, data or an agent."]).join(`
|
|
3864
|
+
`)}],structuredContent:{...n,where:r.where}}}),t}var Oq={watching:"Live tips are on: Token Lens is watching the message box and the open chat in the Claude app.",starting:"Live tips are starting.","cant-see-box":"Live tips are on but can't read Claude's message box yet: click in it, or quit and reopen Claude.","needs-helper":"Live tips can't read the AI app on this Mac yet. Don't suggest turning on node: macOS would give that access to every Node program. Offer Token Lens Helper instead and explain it first: a small Mac app that gives live tips in Claude, ChatGPT and other desktop AI apps and in AI chat sites (chatgpt.com, claude.ai, Gemini, Perplexity, DeepSeek, Le Chat, Grok, Copilot) open in a browser; it reads only the message box and open chat of the AI app or AI chat page in front, never other tabs, keeps and sends none of that text, shows a Shorten button just above the message box while they type, changes the message box only when the user clicks, checks the npm registry daily for a newer Token Lens, and needs its own switch under System Settings > Privacy & Security > Accessibility. The user can click Set up Token Lens Helper in the Token Lens box, or say yes and you call live_tips with action setup_helper; either way their Mac asks them to confirm. Never send the user to a web page or localhost.",helper:"Live tips run in Token Lens Helper: while the user types, a Shorten button appears just above the message box when a shorter prompt says the same thing (one click swaps it in), and its menu bar icon shows the details. If they don't appear, the user turns on Token Lens Helper in System Settings > Privacy & Security > Accessibility. If they turned node on for Token Lens earlier, they can turn it off.","claude-closed":"Live tips are on and wait for the Claude app.",off:"Live tips are off.",unsupported:"Live tips work in the Claude desktop app on macOS only."},Nq=`Set up Token Lens Helper?
|
|
3863
3865
|
|
|
3864
3866
|
It's a small Mac app that shortens prompts while you type in Claude, ChatGPT and other AI apps, and in AI chat sites in your browser. It reads only the message box and the open chat of the AI app or AI chat page in front (never your other tabs), keeps and sends none of that text, changes your message only when you click, and checks the npm registry daily for a newer Token Lens.
|
|
3865
3867
|
|
|
3866
|
-
macOS will then ask you to turn it on under Privacy & Security > Accessibility.`,S_=!1;function n1(e){if(S_)return Promise.resolve("busy");S_=!0;let t=`display dialog ${JSON.stringify(`${e} ${
|
|
3867
|
-
`)}var r1={free:"claude-free",pro:"claude-pro",max:"claude-max",team:"claude-team"};function
|
|
3868
|
-
`);return}let i=A_({ledger:e}),o=new Rp({sessionIdGenerator:void 0});n.on("close",()=>{o.close(),i.close()}),await i.connect(o),await o.handleRequest(a,n)}).listen(r,()=>console.error(`Token Lens MCP server on http://localhost:${r}/mcp`))}
|
|
3868
|
+
macOS will then ask you to turn it on under Privacy & Security > Accessibility.`,S_=!1;function n1(e){if(S_)return Promise.resolve("busy");S_=!0;let t=`display dialog ${JSON.stringify(`${e} ${Nq}`)} with title "Token Lens" buttons {"Not now", "Set up"} default button "Not now" cancel button "Not now" with icon note`;return new Promise(r=>hq("osascript",["-e",t],{timeout:3e5},(a,n)=>{if(S_=!1,!a)return r(/button returned:Set up/.test(n)?"yes":"no");r(/-128/.test(String(a.message)+String(a.stderr??""))?"no":"no-dialog")}))}function Dq(e,t){e.registerTool("token_lens_helper",{title:"Set up Token Lens Helper from the box",description:T_,inputSchema:{box:i1},annotations:{readOnlyHint:!1,openWorldHint:!1},_meta:o1},async(r,a)=>{let i=E_(a,r)?t.status==="helper"?"on":t.helperOffer?await n1("You clicked Set up in the Token Lens box.").then(s=>s==="yes"?t.setupHelper():s):"unavailable":"not-box",o={on:"Token Lens Helper is already on.",started:"Set up. When macOS asks, click Open System Settings and turn on Token Lens Helper under Privacy & Security > Accessibility.",no:"Not set up.",busy:"The Mac is already asking: answer the Token Lens dialog.","no-dialog":"Your Mac couldn't show the question. Quit and reopen Claude, then click Set up again.","not-box":`This app didn't pass on your click. Type "Set up Token Lens Helper" in the chat instead; your Mac will ask you to confirm.`,unsupported:"Token Lens Helper needs macOS 13.3 or later.",unavailable:"This copy of Token Lens doesn't include Token Lens Helper yet.",failed:"Couldn't set up Token Lens Helper on this Mac."};return{content:[{type:"text",text:o[i]??o.failed}],structuredContent:{helper:i,text:o[i]??o.failed}}}),e.registerTool("live_tips",{title:"Live tips in the Claude app",description:"Turn Token Lens's live tips on or off, or check them. Live tips run on this Mac with no model calls: while the user types in an AI app (Claude, ChatGPT, Perplexity and others) or an AI chat site in a browser, a Shorten button appears above the message box when a shorter prompt says the same thing, and a notice comes when a chat gets costly. Action setup_helper asks the user in a Mac dialog to set up Token Lens Helper, which holds the Mac permission for Token Lens alone; nothing is set up unless they click Set up there. Explain what it reads first. Never send the user to a web page or localhost. Use when the user asks about live tips, the Shorten button or notifications, or wants them off or on.",inputSchema:{action:H.enum(["status","on","off","setup_helper"]).describe("What to do. Default status.").optional()},annotations:{readOnlyHint:!1,openWorldHint:!1}},async({action:r})=>{if(r==="setup_helper"){let i=t.status==="helper"?"started":await n1("The AI in your chat asked to set this up.").then(s=>s==="yes"?t.setupHelper():s);return{content:[{type:"text",text:i==="started"?"Token Lens Helper is set up. When macOS asks, the user clicks Open System Settings and turns on Token Lens Helper under Privacy & Security > Accessibility. Then, while they type, a Shorten button appears just above the message box. No need to turn on node.":i==="unsupported"?"Token Lens Helper needs macOS 13.3 or later.":i==="unavailable"?"This copy of Token Lens doesn't include Token Lens Helper yet.":i==="no"?"The user chose Not now on their Mac. Don't ask again unless they bring it up.":i==="busy"?"The Mac is already asking the user.":i==="no-dialog"?"The Mac couldn't show its question. The user can click Set up Token Lens Helper in the Token Lens box after reopening Claude.":"Couldn't set up Token Lens Helper on this Mac."}],structuredContent:{status:t.status,helper:i}}}let a=r==="on"?t.enable():r==="off"?t.disable():t.status;return{content:[{type:"text",text:Oq[a]??a}],structuredContent:{status:a,helperOffer:t.helperOffer}}})}var Mq=e=>new Date(e).toLocaleTimeString("en-US",{hour:"numeric",minute:"2-digit"});function Lq(e,t){let r=[e.plan?`Plan: ${e.plan.label}${e.planSource==="app"?" (read from the Claude app)":""}.`:"Plan: not known yet."];return e.sessionPct!==void 0&&r.push(`Session: ${e.sessionPct}% used${e.sessionResetsAt?`, resets ${Mq(e.sessionResetsAt)}`:""}${e.meterAgeMin?` (meter read ${e.meterAgeMin} min ago, carried forward by what was sent since)`:""}.`),e.weekPct!==void 0&&r.push(`Week: ${e.weekPct}% used${e.weekResetsText?`, resets ${e.weekResetsText}`:""}.`),e.left&&r.push(`Left this session: about ${Q(e.left.here)} messages in the open chat, or about ${Q(e.left.fresh)} in a new chat.`),t&&e.session.messages&&r.push(`This session: ${Q(e.session.messages)} messages, ${Q(e.session.tokens)} tokens read.`+(e.topChats.length>1?` Where it went: ${e.topChats.map(a=>`${a.title??"a chat"} ${Math.round(a.share*100)}%`).join(", ")}.`:"")),e.insights.length&&r.push("","What to do:",...e.insights.map(a=>`- ${a}`)),r.push("","None of this changes your model or its answers. Kept on this computer as times and token counts only, never text."),r.join(`
|
|
3869
|
+
`)}var r1={free:"claude-free",pro:"claude-pro",max:"claude-max",team:"claude-team"};function Bq(e,t){e.registerTool("plan_coach",{title:"Get the most out of your Claude plan",description:"How much of the user's Claude plan is used and left, how many messages fit, what drains it, and how to make it last. Never switches the model. Use for usage, limits or plan questions.",inputSchema:{plan:H.enum(["free","pro","max","team"]).optional().describe("The user's plan, if they said; saved for next time."),session_pct_used:H.number().min(0).max(100).optional().describe("Session usage % from Claude's Settings > Usage, if the user gave it."),session_resets_in_minutes:H.number().nonnegative().optional(),week_pct_used:H.number().min(0).max(100).optional(),chat_tokens:H.number().int().nonnegative().optional().describe("Your best estimate of this chat's size in tokens.")},annotations:{readOnlyHint:!1,openWorldHint:!1}},async r=>{let a=Date.now();t&&r.plan&&t.setPlan(r1[r.plan]);let n;if(t&&r.session_pct_used===void 0&&r.week_pct_used===void 0)n=t.insights.refreshCoach(a);else{let i={at:a,sessionPct:r.session_pct_used,sessionResetsAt:r.session_resets_in_minutes!==void 0?a+r.session_resets_in_minutes*6e4:void 0,weekPct:r.week_pct_used},o=r.plan?Un[r1[r.plan]]:t?.insights.plan??null;n=Hp({data:{sends:[],readings:r.session_pct_used!==void 0||r.week_pct_used!==void 0?[i]:[]},now:a,plan:o,planSource:o?"set":"unknown",current:r.chat_tokens?{chat:"this",tokens:r.chat_tokens}:void 0})}return{content:[{type:"text",text:Lq(n,!!t)}],structuredContent:{...n}}})}async function Fq(){let e=jT(),t=process.argv.indexOf("--http");if(t===-1){let a=process.platform==="darwin"?new em:void 0,n=A_({ledger:e,live:a}),i=!1,o=()=>{if(!i){i=!0;try{a?.autoStart()}catch{}}},s=n.server.oninitialized;n.server.oninitialized=()=>{s?.(),o()},setTimeout(o,1e4).unref(),await n.connect(new Sp);return}let r=Number(process.argv[t+1]??process.env.PORT??8787);Uq(async(a,n)=>{if(!a.url?.startsWith("/mcp")){n.writeHead(a.url==="/"?200:404,{"content-type":"text/plain"}).end(`Token Lens MCP server: POST /mcp
|
|
3870
|
+
`);return}let i=A_({ledger:e}),o=new Rp({sessionIdGenerator:void 0});n.on("close",()=>{o.close(),i.close()}),await i.connect(o),await o.handleRequest(a,n)}).listen(r,()=>console.error(`Token Lens MCP server on http://localhost:${r}/mcp`))}Fq();
|