mirror of
https://github.com/thedotmack/claude-mem
synced 2026-04-25 17:15:04 +02:00
222 lines
378 KiB
JavaScript
Executable File
222 lines
378 KiB
JavaScript
Executable File
#!/usr/bin/env node
|
|
"use strict";var kb=Object.create;var nc=Object.defineProperty;var wb=Object.getOwnPropertyDescriptor;var Eb=Object.getOwnPropertyNames;var Ib=Object.getPrototypeOf,zb=Object.prototype.hasOwnProperty;var I=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),Fn=(e,t)=>{for(var r in t)nc(e,r,{get:t[r],enumerable:!0})},Pb=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Eb(t))!zb.call(e,o)&&o!==r&&nc(e,o,{get:()=>t[o],enumerable:!(n=wb(t,o))||n.enumerable});return e};var kt=(e,t,r)=>(r=e!=null?kb(Ib(e)):{},Pb(t||!e||!e.__esModule?nc(r,"default",{value:e,enumerable:!0}):r,e));var ti=I(re=>{"use strict";Object.defineProperty(re,"__esModule",{value:!0});re.regexpCode=re.getEsmExportName=re.getProperty=re.safeStringify=re.stringify=re.strConcat=re.addCodeArg=re.str=re._=re.nil=re._Code=re.Name=re.IDENTIFIER=re._CodeOrName=void 0;var Qo=class{};re._CodeOrName=Qo;re.IDENTIFIER=/^[a-z$_][a-z$_0-9]*$/i;var Or=class extends Qo{constructor(t){if(super(),!re.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}}};re.Name=Or;var ct=class extends Qo{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,n)=>`${r}${n}`,"")}get names(){var t;return(t=this._names)!==null&&t!==void 0?t:this._names=this._items.reduce((r,n)=>(n instanceof Or&&(r[n.str]=(r[n.str]||0)+1),r),{})}};re._Code=ct;re.nil=new ct("");function Nv(e,...t){let r=[e[0]],n=0;for(;n<t.length;)Qd(r,t[n]),r.push(e[++n]);return new ct(r)}re._=Nv;var Xd=new ct("+");function Rv(e,...t){let r=[ei(e[0])],n=0;for(;n<t.length;)r.push(Xd),Qd(r,t[n]),r.push(Xd,ei(e[++n]));return x0(r),new ct(r)}re.str=Rv;function Qd(e,t){t instanceof ct?e.push(...t._items):t instanceof Or?e.push(t):e.push(w0(t))}re.addCodeArg=Qd;function x0(e){let t=1;for(;t<e.length-1;){if(e[t]===Xd){let r=S0(e[t-1],e[t+1]);if(r!==void 0){e.splice(t-1,3,r);continue}e[t++]="+"}t++}}function S0(e,t){if(t==='""')return e;if(e==='""')return t;if(typeof e=="string")return t instanceof Or||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 Or))return`"${e}${t.slice(1)}`}function k0(e,t){return t.emptyStr()?e:e.emptyStr()?t:Rv`${e}${t}`}re.strConcat=k0;function w0(e){return typeof e=="number"||typeof e=="boolean"||e===null?e:ei(Array.isArray(e)?e.join(","):e)}function E0(e){return new ct(ei(e))}re.stringify=E0;function ei(e){return JSON.stringify(e).replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}re.safeStringify=ei;function I0(e){return typeof e=="string"&&re.IDENTIFIER.test(e)?new ct(`.${e}`):Nv`[${e}]`}re.getProperty=I0;function z0(e){if(typeof e=="string"&&re.IDENTIFIER.test(e))return new ct(`${e}`);throw new Error(`CodeGen: invalid export name: ${e}, use explicit $id name mapping`)}re.getEsmExportName=z0;function P0(e){return new ct(e.toString())}re.regexpCode=P0});var rp=I(Ge=>{"use strict";Object.defineProperty(Ge,"__esModule",{value:!0});Ge.ValueScope=Ge.ValueScopeName=Ge.Scope=Ge.varKinds=Ge.UsedValueState=void 0;var He=ti(),ep=class extends Error{constructor(t){super(`CodeGen: "code" for ${t} not defined`),this.value=t.value}},ss;(function(e){e[e.Started=0]="Started",e[e.Completed=1]="Completed"})(ss||(Ge.UsedValueState=ss={}));Ge.varKinds={const:new He.Name("const"),let:new He.Name("let"),var:new He.Name("var")};var cs=class{constructor({prefixes:t,parent:r}={}){this._names={},this._prefixes=t,this._parent=r}toName(t){return t instanceof He.Name?t:this.name(t)}name(t){return new He.Name(this._newName(t))}_newName(t){let r=this._names[t]||this._nameGroup(t);return`${t}${r.index++}`}_nameGroup(t){var r,n;if(!((n=(r=this._parent)===null||r===void 0?void 0:r._prefixes)===null||n===void 0)&&n.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}}};Ge.Scope=cs;var us=class extends He.Name{constructor(t,r){super(r),this.prefix=t}setValue(t,{property:r,itemIndex:n}){this.value=t,this.scopePath=(0,He._)`.${new He.Name(r)}[${n}]`}};Ge.ValueScopeName=us;var T0=(0,He._)`\n`,tp=class extends cs{constructor(t){super(t),this._values={},this._scope=t.scope,this.opts={...t,_n:t.lines?T0:He.nil}}get(){return this._scope}name(t){return new us(t,this._newName(t))}value(t,r){var n;if(r.ref===void 0)throw new Error("CodeGen: ref must be passed in value");let o=this.toName(t),{prefix:i}=o,a=(n=r.key)!==null&&n!==void 0?n:r.ref,s=this._values[i];if(s){let l=s.get(a);if(l)return l}else s=this._values[i]=new Map;s.set(a,o);let c=this._scope[i]||(this._scope[i]=[]),u=c.length;return c[u]=r.ref,o.setValue(r,{property:i,itemIndex:u}),o}getValue(t,r){let n=this._values[t];if(n)return n.get(r)}scopeRefs(t,r=this._values){return this._reduceValues(r,n=>{if(n.scopePath===void 0)throw new Error(`CodeGen: name "${n}" has no value`);return(0,He._)`${t}${n.scopePath}`})}scopeCode(t=this._values,r,n){return this._reduceValues(t,o=>{if(o.value===void 0)throw new Error(`CodeGen: name "${o}" has no value`);return o.value.code},r,n)}_reduceValues(t,r,n={},o){let i=He.nil;for(let a in t){let s=t[a];if(!s)continue;let c=n[a]=n[a]||new Map;s.forEach(u=>{if(c.has(u))return;c.set(u,ss.Started);let l=r(u);if(l){let d=this.opts.es5?Ge.varKinds.var:Ge.varKinds.const;i=(0,He._)`${i}${d} ${u} = ${l};${this.opts._n}`}else if(l=o?.(u))i=(0,He._)`${i}${l}${this.opts._n}`;else throw new ep(u);c.set(u,ss.Completed)})}return i}};Ge.ValueScope=tp});var H=I(K=>{"use strict";Object.defineProperty(K,"__esModule",{value:!0});K.or=K.and=K.not=K.CodeGen=K.operators=K.varKinds=K.ValueScopeName=K.ValueScope=K.Scope=K.Name=K.regexpCode=K.stringify=K.getProperty=K.nil=K.strConcat=K.str=K._=void 0;var ee=ti(),_t=rp(),mr=ti();Object.defineProperty(K,"_",{enumerable:!0,get:function(){return mr._}});Object.defineProperty(K,"str",{enumerable:!0,get:function(){return mr.str}});Object.defineProperty(K,"strConcat",{enumerable:!0,get:function(){return mr.strConcat}});Object.defineProperty(K,"nil",{enumerable:!0,get:function(){return mr.nil}});Object.defineProperty(K,"getProperty",{enumerable:!0,get:function(){return mr.getProperty}});Object.defineProperty(K,"stringify",{enumerable:!0,get:function(){return mr.stringify}});Object.defineProperty(K,"regexpCode",{enumerable:!0,get:function(){return mr.regexpCode}});Object.defineProperty(K,"Name",{enumerable:!0,get:function(){return mr.Name}});var fs=rp();Object.defineProperty(K,"Scope",{enumerable:!0,get:function(){return fs.Scope}});Object.defineProperty(K,"ValueScope",{enumerable:!0,get:function(){return fs.ValueScope}});Object.defineProperty(K,"ValueScopeName",{enumerable:!0,get:function(){return fs.ValueScopeName}});Object.defineProperty(K,"varKinds",{enumerable:!0,get:function(){return fs.varKinds}});K.operators={GT:new ee._Code(">"),GTE:new ee._Code(">="),LT:new ee._Code("<"),LTE:new ee._Code("<="),EQ:new ee._Code("==="),NEQ:new ee._Code("!=="),NOT:new ee._Code("!"),OR:new ee._Code("||"),AND:new ee._Code("&&"),ADD:new ee._Code("+")};var Jt=class{optimizeNodes(){return this}optimizeNames(t,r){return this}},np=class extends Jt{constructor(t,r,n){super(),this.varKind=t,this.name=r,this.rhs=n}render({es5:t,_n:r}){let n=t?_t.varKinds.var:this.varKind,o=this.rhs===void 0?"":` = ${this.rhs}`;return`${n} ${this.name}${o};`+r}optimizeNames(t,r){if(t[this.name.str])return this.rhs&&(this.rhs=yn(this.rhs,t,r)),this}get names(){return this.rhs instanceof ee._CodeOrName?this.rhs.names:{}}},ls=class extends Jt{constructor(t,r,n){super(),this.lhs=t,this.rhs=r,this.sideEffects=n}render({_n:t}){return`${this.lhs} = ${this.rhs};`+t}optimizeNames(t,r){if(!(this.lhs instanceof ee.Name&&!t[this.lhs.str]&&!this.sideEffects))return this.rhs=yn(this.rhs,t,r),this}get names(){let t=this.lhs instanceof ee.Name?{}:{...this.lhs.names};return ps(t,this.rhs)}},op=class extends ls{constructor(t,r,n,o){super(t,n,o),this.op=r}render({_n:t}){return`${this.lhs} ${this.op}= ${this.rhs};`+t}},ip=class extends Jt{constructor(t){super(),this.label=t,this.names={}}render({_n:t}){return`${this.label}:`+t}},ap=class extends Jt{constructor(t){super(),this.label=t,this.names={}}render({_n:t}){return`break${this.label?` ${this.label}`:""};`+t}},sp=class extends Jt{constructor(t){super(),this.error=t}render({_n:t}){return`throw ${this.error};`+t}get names(){return this.error.names}},cp=class extends Jt{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=yn(this.code,t,r),this}get names(){return this.code instanceof ee._CodeOrName?this.code.names:{}}},ri=class extends Jt{constructor(t=[]){super(),this.nodes=t}render(t){return this.nodes.reduce((r,n)=>r+n.render(t),"")}optimizeNodes(){let{nodes:t}=this,r=t.length;for(;r--;){let n=t[r].optimizeNodes();Array.isArray(n)?t.splice(r,1,...n):n?t[r]=n:t.splice(r,1)}return t.length>0?this:void 0}optimizeNames(t,r){let{nodes:n}=this,o=n.length;for(;o--;){let i=n[o];i.optimizeNames(t,r)||(O0(t,i.names),n.splice(o,1))}return n.length>0?this:void 0}get names(){return this.nodes.reduce((t,r)=>Nr(t,r.names),{})}},Ht=class extends ri{render(t){return"{"+t._n+super.render(t)+"}"+t._n}},up=class extends ri{},_n=class extends Ht{};_n.kind="else";var jr=class e extends Ht{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 n=r.optimizeNodes();r=this.else=Array.isArray(n)?new _n(n):n}if(r)return t===!1?r instanceof e?r:r.nodes:this.nodes.length?this:new e(Mv(t),r instanceof e?[r]:r.nodes);if(!(t===!1||!this.nodes.length))return this}optimizeNames(t,r){var n;if(this.else=(n=this.else)===null||n===void 0?void 0:n.optimizeNames(t,r),!!(super.optimizeNames(t,r)||this.else))return this.condition=yn(this.condition,t,r),this}get names(){let t=super.names;return ps(t,this.condition),this.else&&Nr(t,this.else.names),t}};jr.kind="if";var Dr=class extends Ht{};Dr.kind="for";var lp=class extends Dr{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=yn(this.iteration,t,r),this}get names(){return Nr(super.names,this.iteration.names)}},dp=class extends Dr{constructor(t,r,n,o){super(),this.varKind=t,this.name=r,this.from=n,this.to=o}render(t){let r=t.es5?_t.varKinds.var:this.varKind,{name:n,from:o,to:i}=this;return`for(${r} ${n}=${o}; ${n}<${i}; ${n}++)`+super.render(t)}get names(){let t=ps(super.names,this.from);return ps(t,this.to)}},ds=class extends Dr{constructor(t,r,n,o){super(),this.loop=t,this.varKind=r,this.name=n,this.iterable=o}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=yn(this.iterable,t,r),this}get names(){return Nr(super.names,this.iterable.names)}},ni=class extends Ht{constructor(t,r,n){super(),this.name=t,this.args=r,this.async=n}render(t){return`${this.async?"async ":""}function ${this.name}(${this.args})`+super.render(t)}};ni.kind="func";var oi=class extends ri{render(t){return"return "+super.render(t)}};oi.kind="return";var pp=class extends Ht{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 n,o;return super.optimizeNames(t,r),(n=this.catch)===null||n===void 0||n.optimizeNames(t,r),(o=this.finally)===null||o===void 0||o.optimizeNames(t,r),this}get names(){let t=super.names;return this.catch&&Nr(t,this.catch.names),this.finally&&Nr(t,this.finally.names),t}},ii=class extends Ht{constructor(t){super(),this.error=t}render(t){return`catch(${this.error})`+super.render(t)}};ii.kind="catch";var ai=class extends Ht{render(t){return"finally"+super.render(t)}};ai.kind="finally";var fp=class{constructor(t,r={}){this._values={},this._blockStarts=[],this._constants={},this.opts={...r,_n:r.lines?`
|
|
`:""},this._extScope=t,this._scope=new _t.Scope({parent:t}),this._nodes=[new up]}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 n=this._extScope.value(t,r);return(this._values[n.prefix]||(this._values[n.prefix]=new Set)).add(n),n}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,n,o){let i=this._scope.toName(r);return n!==void 0&&o&&(this._constants[i.str]=n),this._leafNode(new np(t,i,n)),i}const(t,r,n){return this._def(_t.varKinds.const,t,r,n)}let(t,r,n){return this._def(_t.varKinds.let,t,r,n)}var(t,r,n){return this._def(_t.varKinds.var,t,r,n)}assign(t,r,n){return this._leafNode(new ls(t,r,n))}add(t,r){return this._leafNode(new op(t,K.operators.ADD,r))}code(t){return typeof t=="function"?t():t!==ee.nil&&this._leafNode(new cp(t)),this}object(...t){let r=["{"];for(let[n,o]of t)r.length>1&&r.push(","),r.push(n),(n!==o||this.opts.es5)&&(r.push(":"),(0,ee.addCodeArg)(r,o));return r.push("}"),new ee._Code(r)}if(t,r,n){if(this._blockNode(new jr(t)),r&&n)this.code(r).else().code(n).endIf();else if(r)this.code(r).endIf();else if(n)throw new Error('CodeGen: "else" body without "then" body');return this}elseIf(t){return this._elseNode(new jr(t))}else(){return this._elseNode(new _n)}endIf(){return this._endBlockNode(jr,_n)}_for(t,r){return this._blockNode(t),r&&this.code(r).endFor(),this}for(t,r){return this._for(new lp(t),r)}forRange(t,r,n,o,i=this.opts.es5?_t.varKinds.var:_t.varKinds.let){let a=this._scope.toName(t);return this._for(new dp(i,a,r,n),()=>o(a))}forOf(t,r,n,o=_t.varKinds.const){let i=this._scope.toName(t);if(this.opts.es5){let a=r instanceof ee.Name?r:this.var("_arr",r);return this.forRange("_i",0,(0,ee._)`${a}.length`,s=>{this.var(i,(0,ee._)`${a}[${s}]`),n(i)})}return this._for(new ds("of",o,i,r),()=>n(i))}forIn(t,r,n,o=this.opts.es5?_t.varKinds.var:_t.varKinds.const){if(this.opts.ownProperties)return this.forOf(t,(0,ee._)`Object.keys(${r})`,n);let i=this._scope.toName(t);return this._for(new ds("in",o,i,r),()=>n(i))}endFor(){return this._endBlockNode(Dr)}label(t){return this._leafNode(new ip(t))}break(t){return this._leafNode(new ap(t))}return(t){let r=new oi;if(this._blockNode(r),this.code(t),r.nodes.length!==1)throw new Error('CodeGen: "return" should have one node');return this._endBlockNode(oi)}try(t,r,n){if(!r&&!n)throw new Error('CodeGen: "try" without "catch" and "finally"');let o=new pp;if(this._blockNode(o),this.code(t),r){let i=this.name("e");this._currNode=o.catch=new ii(i),r(i)}return n&&(this._currNode=o.finally=new ai,this.code(n)),this._endBlockNode(ii,ai)}throw(t){return this._leafNode(new sp(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 n=this._nodes.length-r;if(n<0||t!==void 0&&n!==t)throw new Error(`CodeGen: wrong number of nodes: ${n} vs ${t} expected`);return this._nodes.length=r,this}func(t,r=ee.nil,n,o){return this._blockNode(new ni(t,r,n)),o&&this.code(o).endFunc(),this}endFunc(){return this._endBlockNode(ni)}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 n=this._currNode;if(n instanceof t||r&&n 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 jr))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}};K.CodeGen=fp;function Nr(e,t){for(let r in t)e[r]=(e[r]||0)+(t[r]||0);return e}function ps(e,t){return t instanceof ee._CodeOrName?Nr(e,t.names):e}function yn(e,t,r){if(e instanceof ee.Name)return n(e);if(!o(e))return e;return new ee._Code(e._items.reduce((i,a)=>(a instanceof ee.Name&&(a=n(a)),a instanceof ee._Code?i.push(...a._items):i.push(a),i),[]));function n(i){let a=r[i.str];return a===void 0||t[i.str]!==1?i:(delete t[i.str],a)}function o(i){return i instanceof ee._Code&&i._items.some(a=>a instanceof ee.Name&&t[a.str]===1&&r[a.str]!==void 0)}}function O0(e,t){for(let r in t)e[r]=(e[r]||0)-(t[r]||0)}function Mv(e){return typeof e=="boolean"||typeof e=="number"||e===null?!e:(0,ee._)`!${mp(e)}`}K.not=Mv;var j0=Av(K.operators.AND);function D0(...e){return e.reduce(j0)}K.and=D0;var N0=Av(K.operators.OR);function R0(...e){return e.reduce(N0)}K.or=R0;function Av(e){return(t,r)=>t===ee.nil?r:r===ee.nil?t:(0,ee._)`${mp(t)} ${e} ${mp(r)}`}function mp(e){return e instanceof ee.Name?e:(0,ee._)`(${e})`}});var ne=I(Y=>{"use strict";Object.defineProperty(Y,"__esModule",{value:!0});Y.checkStrictMode=Y.getErrorPath=Y.Type=Y.useFunc=Y.setEvaluated=Y.evaluatedPropsToName=Y.mergeEvaluated=Y.eachItem=Y.unescapeJsonPointer=Y.escapeJsonPointer=Y.escapeFragment=Y.unescapeFragment=Y.schemaRefOrVal=Y.schemaHasRulesButRef=Y.schemaHasRules=Y.checkUnknownRules=Y.alwaysValidSchema=Y.toHash=void 0;var de=H(),M0=ti();function A0(e){let t={};for(let r of e)t[r]=!0;return t}Y.toHash=A0;function C0(e,t){return typeof t=="boolean"?t:Object.keys(t).length===0?!0:(Zv(e,t),!Lv(t,e.self.RULES.all))}Y.alwaysValidSchema=C0;function Zv(e,t=e.schema){let{opts:r,self:n}=e;if(!r.strictSchema||typeof t=="boolean")return;let o=n.RULES.keywords;for(let i in t)o[i]||Vv(e,`unknown keyword: "${i}"`)}Y.checkUnknownRules=Zv;function Lv(e,t){if(typeof e=="boolean")return!e;for(let r in e)if(t[r])return!0;return!1}Y.schemaHasRules=Lv;function U0(e,t){if(typeof e=="boolean")return!e;for(let r in e)if(r!=="$ref"&&t.all[r])return!0;return!1}Y.schemaHasRulesButRef=U0;function Z0({topSchemaRef:e,schemaPath:t},r,n,o){if(!o){if(typeof r=="number"||typeof r=="boolean")return r;if(typeof r=="string")return(0,de._)`${r}`}return(0,de._)`${e}${t}${(0,de.getProperty)(n)}`}Y.schemaRefOrVal=Z0;function L0(e){return Fv(decodeURIComponent(e))}Y.unescapeFragment=L0;function F0(e){return encodeURIComponent(gp(e))}Y.escapeFragment=F0;function gp(e){return typeof e=="number"?`${e}`:e.replace(/~/g,"~0").replace(/\//g,"~1")}Y.escapeJsonPointer=gp;function Fv(e){return e.replace(/~1/g,"/").replace(/~0/g,"~")}Y.unescapeJsonPointer=Fv;function q0(e,t){if(Array.isArray(e))for(let r of e)t(r);else t(e)}Y.eachItem=q0;function Cv({mergeNames:e,mergeToName:t,mergeValues:r,resultToName:n}){return(o,i,a,s)=>{let c=a===void 0?i:a instanceof de.Name?(i instanceof de.Name?e(o,i,a):t(o,i,a),a):i instanceof de.Name?(t(o,a,i),i):r(i,a);return s===de.Name&&!(c instanceof de.Name)?n(o,c):c}}Y.mergeEvaluated={props:Cv({mergeNames:(e,t,r)=>e.if((0,de._)`${r} !== true && ${t} !== undefined`,()=>{e.if((0,de._)`${t} === true`,()=>e.assign(r,!0),()=>e.assign(r,(0,de._)`${r} || {}`).code((0,de._)`Object.assign(${r}, ${t})`))}),mergeToName:(e,t,r)=>e.if((0,de._)`${r} !== true`,()=>{t===!0?e.assign(r,!0):(e.assign(r,(0,de._)`${r} || {}`),vp(e,r,t))}),mergeValues:(e,t)=>e===!0?!0:{...e,...t},resultToName:qv}),items:Cv({mergeNames:(e,t,r)=>e.if((0,de._)`${r} !== true && ${t} !== undefined`,()=>e.assign(r,(0,de._)`${t} === true ? true : ${r} > ${t} ? ${r} : ${t}`)),mergeToName:(e,t,r)=>e.if((0,de._)`${r} !== true`,()=>e.assign(r,t===!0?!0:(0,de._)`${r} > ${t} ? ${r} : ${t}`)),mergeValues:(e,t)=>e===!0?!0:Math.max(e,t),resultToName:(e,t)=>e.var("items",t)})};function qv(e,t){if(t===!0)return e.var("props",!0);let r=e.var("props",(0,de._)`{}`);return t!==void 0&&vp(e,r,t),r}Y.evaluatedPropsToName=qv;function vp(e,t,r){Object.keys(r).forEach(n=>e.assign((0,de._)`${t}${(0,de.getProperty)(n)}`,!0))}Y.setEvaluated=vp;var Uv={};function V0(e,t){return e.scopeValue("func",{ref:t,code:Uv[t.code]||(Uv[t.code]=new M0._Code(t.code))})}Y.useFunc=V0;var hp;(function(e){e[e.Num=0]="Num",e[e.Str=1]="Str"})(hp||(Y.Type=hp={}));function W0(e,t,r){if(e instanceof de.Name){let n=t===hp.Num;return r?n?(0,de._)`"[" + ${e} + "]"`:(0,de._)`"['" + ${e} + "']"`:n?(0,de._)`"/" + ${e}`:(0,de._)`"/" + ${e}.replace(/~/g, "~0").replace(/\\//g, "~1")`}return r?(0,de.getProperty)(e).toString():"/"+gp(e)}Y.getErrorPath=W0;function Vv(e,t,r=e.opts.strictSchema){if(r){if(t=`strict mode: ${t}`,r===!0)throw new Error(t);e.self.logger.warn(t)}}Y.checkStrictMode=Vv});var Gt=I(_p=>{"use strict";Object.defineProperty(_p,"__esModule",{value:!0});var je=H(),J0={data:new je.Name("data"),valCxt:new je.Name("valCxt"),instancePath:new je.Name("instancePath"),parentData:new je.Name("parentData"),parentDataProperty:new je.Name("parentDataProperty"),rootData:new je.Name("rootData"),dynamicAnchors:new je.Name("dynamicAnchors"),vErrors:new je.Name("vErrors"),errors:new je.Name("errors"),this:new je.Name("this"),self:new je.Name("self"),scope:new je.Name("scope"),json:new je.Name("json"),jsonPos:new je.Name("jsonPos"),jsonLen:new je.Name("jsonLen"),jsonPart:new je.Name("jsonPart")};_p.default=J0});var si=I(De=>{"use strict";Object.defineProperty(De,"__esModule",{value:!0});De.extendErrors=De.resetErrorsCount=De.reportExtraError=De.reportError=De.keyword$DataError=De.keywordError=void 0;var te=H(),ms=ne(),Le=Gt();De.keywordError={message:({keyword:e})=>(0,te.str)`must pass "${e}" keyword validation`};De.keyword$DataError={message:({keyword:e,schemaType:t})=>t?(0,te.str)`"${e}" keyword must be ${t} ($data)`:(0,te.str)`"${e}" keyword is invalid ($data)`};function H0(e,t=De.keywordError,r,n){let{it:o}=e,{gen:i,compositeRule:a,allErrors:s}=o,c=Hv(e,t,r);n??(a||s)?Wv(i,c):Jv(o,(0,te._)`[${c}]`)}De.reportError=H0;function G0(e,t=De.keywordError,r){let{it:n}=e,{gen:o,compositeRule:i,allErrors:a}=n,s=Hv(e,t,r);Wv(o,s),i||a||Jv(n,Le.default.vErrors)}De.reportExtraError=G0;function K0(e,t){e.assign(Le.default.errors,t),e.if((0,te._)`${Le.default.vErrors} !== null`,()=>e.if(t,()=>e.assign((0,te._)`${Le.default.vErrors}.length`,t),()=>e.assign(Le.default.vErrors,null)))}De.resetErrorsCount=K0;function B0({gen:e,keyword:t,schemaValue:r,data:n,errsCount:o,it:i}){if(o===void 0)throw new Error("ajv implementation error");let a=e.name("err");e.forRange("i",o,Le.default.errors,s=>{e.const(a,(0,te._)`${Le.default.vErrors}[${s}]`),e.if((0,te._)`${a}.instancePath === undefined`,()=>e.assign((0,te._)`${a}.instancePath`,(0,te.strConcat)(Le.default.instancePath,i.errorPath))),e.assign((0,te._)`${a}.schemaPath`,(0,te.str)`${i.errSchemaPath}/${t}`),i.opts.verbose&&(e.assign((0,te._)`${a}.schema`,r),e.assign((0,te._)`${a}.data`,n))})}De.extendErrors=B0;function Wv(e,t){let r=e.const("err",t);e.if((0,te._)`${Le.default.vErrors} === null`,()=>e.assign(Le.default.vErrors,(0,te._)`[${r}]`),(0,te._)`${Le.default.vErrors}.push(${r})`),e.code((0,te._)`${Le.default.errors}++`)}function Jv(e,t){let{gen:r,validateName:n,schemaEnv:o}=e;o.$async?r.throw((0,te._)`new ${e.ValidationError}(${t})`):(r.assign((0,te._)`${n}.errors`,t),r.return(!1))}var Rr={keyword:new te.Name("keyword"),schemaPath:new te.Name("schemaPath"),params:new te.Name("params"),propertyName:new te.Name("propertyName"),message:new te.Name("message"),schema:new te.Name("schema"),parentSchema:new te.Name("parentSchema")};function Hv(e,t,r){let{createErrors:n}=e.it;return n===!1?(0,te._)`{}`:Y0(e,t,r)}function Y0(e,t,r={}){let{gen:n,it:o}=e,i=[X0(o,r),Q0(e,r)];return eE(e,t,i),n.object(...i)}function X0({errorPath:e},{instancePath:t}){let r=t?(0,te.str)`${e}${(0,ms.getErrorPath)(t,ms.Type.Str)}`:e;return[Le.default.instancePath,(0,te.strConcat)(Le.default.instancePath,r)]}function Q0({keyword:e,it:{errSchemaPath:t}},{schemaPath:r,parentSchema:n}){let o=n?t:(0,te.str)`${t}/${e}`;return r&&(o=(0,te.str)`${o}${(0,ms.getErrorPath)(r,ms.Type.Str)}`),[Rr.schemaPath,o]}function eE(e,{params:t,message:r},n){let{keyword:o,data:i,schemaValue:a,it:s}=e,{opts:c,propertyName:u,topSchemaRef:l,schemaPath:d}=s;n.push([Rr.keyword,o],[Rr.params,typeof t=="function"?t(e):t||(0,te._)`{}`]),c.messages&&n.push([Rr.message,typeof r=="function"?r(e):r]),c.verbose&&n.push([Rr.schema,a],[Rr.parentSchema,(0,te._)`${l}${d}`],[Le.default.data,i]),u&&n.push([Rr.propertyName,u])}});var Kv=I($n=>{"use strict";Object.defineProperty($n,"__esModule",{value:!0});$n.boolOrEmptySchema=$n.topBoolOrEmptySchema=void 0;var tE=si(),rE=H(),nE=Gt(),oE={message:"boolean schema is false"};function iE(e){let{gen:t,schema:r,validateName:n}=e;r===!1?Gv(e,!1):typeof r=="object"&&r.$async===!0?t.return(nE.default.data):(t.assign((0,rE._)`${n}.errors`,null),t.return(!0))}$n.topBoolOrEmptySchema=iE;function aE(e,t){let{gen:r,schema:n}=e;n===!1?(r.var(t,!1),Gv(e)):r.var(t,!0)}$n.boolOrEmptySchema=aE;function Gv(e,t){let{gen:r,data:n}=e,o={gen:r,keyword:"false schema",data:n,schema:!1,schemaCode:!1,schemaValue:!1,params:{},it:e};(0,tE.reportError)(o,oE,void 0,t)}});var yp=I(bn=>{"use strict";Object.defineProperty(bn,"__esModule",{value:!0});bn.getRules=bn.isJSONType=void 0;var sE=["string","number","integer","boolean","null","object","array"],cE=new Set(sE);function uE(e){return typeof e=="string"&&cE.has(e)}bn.isJSONType=uE;function lE(){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:{}}}bn.getRules=lE});var $p=I(hr=>{"use strict";Object.defineProperty(hr,"__esModule",{value:!0});hr.shouldUseRule=hr.shouldUseGroup=hr.schemaHasRulesForType=void 0;function dE({schema:e,self:t},r){let n=t.RULES.types[r];return n&&n!==!0&&Bv(e,n)}hr.schemaHasRulesForType=dE;function Bv(e,t){return t.rules.some(r=>Yv(e,r))}hr.shouldUseGroup=Bv;function Yv(e,t){var r;return e[t.keyword]!==void 0||((r=t.definition.implements)===null||r===void 0?void 0:r.some(n=>e[n]!==void 0))}hr.shouldUseRule=Yv});var ci=I(Ne=>{"use strict";Object.defineProperty(Ne,"__esModule",{value:!0});Ne.reportTypeError=Ne.checkDataTypes=Ne.checkDataType=Ne.coerceAndCheckDataType=Ne.getJSONTypes=Ne.getSchemaTypes=Ne.DataType=void 0;var pE=yp(),fE=$p(),mE=si(),V=H(),Xv=ne(),xn;(function(e){e[e.Correct=0]="Correct",e[e.Wrong=1]="Wrong"})(xn||(Ne.DataType=xn={}));function hE(e){let t=Qv(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}Ne.getSchemaTypes=hE;function Qv(e){let t=Array.isArray(e)?e:e?[e]:[];if(t.every(pE.isJSONType))return t;throw new Error("type must be JSONType or JSONType[]: "+t.join(","))}Ne.getJSONTypes=Qv;function gE(e,t){let{gen:r,data:n,opts:o}=e,i=vE(t,o.coerceTypes),a=t.length>0&&!(i.length===0&&t.length===1&&(0,fE.schemaHasRulesForType)(e,t[0]));if(a){let s=xp(t,n,o.strictNumbers,xn.Wrong);r.if(s,()=>{i.length?_E(e,t,i):Sp(e)})}return a}Ne.coerceAndCheckDataType=gE;var e_=new Set(["string","number","integer","boolean","null"]);function vE(e,t){return t?e.filter(r=>e_.has(r)||t==="array"&&r==="array"):[]}function _E(e,t,r){let{gen:n,data:o,opts:i}=e,a=n.let("dataType",(0,V._)`typeof ${o}`),s=n.let("coerced",(0,V._)`undefined`);i.coerceTypes==="array"&&n.if((0,V._)`${a} == 'object' && Array.isArray(${o}) && ${o}.length == 1`,()=>n.assign(o,(0,V._)`${o}[0]`).assign(a,(0,V._)`typeof ${o}`).if(xp(t,o,i.strictNumbers),()=>n.assign(s,o))),n.if((0,V._)`${s} !== undefined`);for(let u of r)(e_.has(u)||u==="array"&&i.coerceTypes==="array")&&c(u);n.else(),Sp(e),n.endIf(),n.if((0,V._)`${s} !== undefined`,()=>{n.assign(o,s),yE(e,s)});function c(u){switch(u){case"string":n.elseIf((0,V._)`${a} == "number" || ${a} == "boolean"`).assign(s,(0,V._)`"" + ${o}`).elseIf((0,V._)`${o} === null`).assign(s,(0,V._)`""`);return;case"number":n.elseIf((0,V._)`${a} == "boolean" || ${o} === null
|
|
|| (${a} == "string" && ${o} && ${o} == +${o})`).assign(s,(0,V._)`+${o}`);return;case"integer":n.elseIf((0,V._)`${a} === "boolean" || ${o} === null
|
|
|| (${a} === "string" && ${o} && ${o} == +${o} && !(${o} % 1))`).assign(s,(0,V._)`+${o}`);return;case"boolean":n.elseIf((0,V._)`${o} === "false" || ${o} === 0 || ${o} === null`).assign(s,!1).elseIf((0,V._)`${o} === "true" || ${o} === 1`).assign(s,!0);return;case"null":n.elseIf((0,V._)`${o} === "" || ${o} === 0 || ${o} === false`),n.assign(s,null);return;case"array":n.elseIf((0,V._)`${a} === "string" || ${a} === "number"
|
|
|| ${a} === "boolean" || ${o} === null`).assign(s,(0,V._)`[${o}]`)}}}function yE({gen:e,parentData:t,parentDataProperty:r},n){e.if((0,V._)`${t} !== undefined`,()=>e.assign((0,V._)`${t}[${r}]`,n))}function bp(e,t,r,n=xn.Correct){let o=n===xn.Correct?V.operators.EQ:V.operators.NEQ,i;switch(e){case"null":return(0,V._)`${t} ${o} null`;case"array":i=(0,V._)`Array.isArray(${t})`;break;case"object":i=(0,V._)`${t} && typeof ${t} == "object" && !Array.isArray(${t})`;break;case"integer":i=a((0,V._)`!(${t} % 1) && !isNaN(${t})`);break;case"number":i=a();break;default:return(0,V._)`typeof ${t} ${o} ${e}`}return n===xn.Correct?i:(0,V.not)(i);function a(s=V.nil){return(0,V.and)((0,V._)`typeof ${t} == "number"`,s,r?(0,V._)`isFinite(${t})`:V.nil)}}Ne.checkDataType=bp;function xp(e,t,r,n){if(e.length===1)return bp(e[0],t,r,n);let o,i=(0,Xv.toHash)(e);if(i.array&&i.object){let a=(0,V._)`typeof ${t} != "object"`;o=i.null?a:(0,V._)`!${t} || ${a}`,delete i.null,delete i.array,delete i.object}else o=V.nil;i.number&&delete i.integer;for(let a in i)o=(0,V.and)(o,bp(a,t,r,n));return o}Ne.checkDataTypes=xp;var $E={message:({schema:e})=>`must be ${e}`,params:({schema:e,schemaValue:t})=>typeof e=="string"?(0,V._)`{type: ${e}}`:(0,V._)`{type: ${t}}`};function Sp(e){let t=bE(e);(0,mE.reportError)(t,$E)}Ne.reportTypeError=Sp;function bE(e){let{gen:t,data:r,schema:n}=e,o=(0,Xv.schemaRefOrVal)(e,n,"type");return{gen:t,keyword:"type",data:r,schema:n.type,schemaCode:o,schemaValue:o,parentSchema:n,params:{},it:e}}});var r_=I(hs=>{"use strict";Object.defineProperty(hs,"__esModule",{value:!0});hs.assignDefaults=void 0;var Sn=H(),xE=ne();function SE(e,t){let{properties:r,items:n}=e.schema;if(t==="object"&&r)for(let o in r)t_(e,o,r[o].default);else t==="array"&&Array.isArray(n)&&n.forEach((o,i)=>t_(e,i,o.default))}hs.assignDefaults=SE;function t_(e,t,r){let{gen:n,compositeRule:o,data:i,opts:a}=e;if(r===void 0)return;let s=(0,Sn._)`${i}${(0,Sn.getProperty)(t)}`;if(o){(0,xE.checkStrictMode)(e,`default is ignored for: ${s}`);return}let c=(0,Sn._)`${s} === undefined`;a.useDefaults==="empty"&&(c=(0,Sn._)`${c} || ${s} === null || ${s} === ""`),n.if(c,(0,Sn._)`${s} = ${(0,Sn.stringify)(r)}`)}});var ut=I(se=>{"use strict";Object.defineProperty(se,"__esModule",{value:!0});se.validateUnion=se.validateArray=se.usePattern=se.callValidateCode=se.schemaProperties=se.allSchemaProperties=se.noPropertyInData=se.propertyInData=se.isOwnProperty=se.hasPropFunc=se.reportMissingProp=se.checkMissingProp=se.checkReportMissingProp=void 0;var he=H(),kp=ne(),gr=Gt(),kE=ne();function wE(e,t){let{gen:r,data:n,it:o}=e;r.if(Ep(r,n,t,o.opts.ownProperties),()=>{e.setParams({missingProperty:(0,he._)`${t}`},!0),e.error()})}se.checkReportMissingProp=wE;function EE({gen:e,data:t,it:{opts:r}},n,o){return(0,he.or)(...n.map(i=>(0,he.and)(Ep(e,t,i,r.ownProperties),(0,he._)`${o} = ${i}`)))}se.checkMissingProp=EE;function IE(e,t){e.setParams({missingProperty:t},!0),e.error()}se.reportMissingProp=IE;function n_(e){return e.scopeValue("func",{ref:Object.prototype.hasOwnProperty,code:(0,he._)`Object.prototype.hasOwnProperty`})}se.hasPropFunc=n_;function wp(e,t,r){return(0,he._)`${n_(e)}.call(${t}, ${r})`}se.isOwnProperty=wp;function zE(e,t,r,n){let o=(0,he._)`${t}${(0,he.getProperty)(r)} !== undefined`;return n?(0,he._)`${o} && ${wp(e,t,r)}`:o}se.propertyInData=zE;function Ep(e,t,r,n){let o=(0,he._)`${t}${(0,he.getProperty)(r)} === undefined`;return n?(0,he.or)(o,(0,he.not)(wp(e,t,r))):o}se.noPropertyInData=Ep;function o_(e){return e?Object.keys(e).filter(t=>t!=="__proto__"):[]}se.allSchemaProperties=o_;function PE(e,t){return o_(t).filter(r=>!(0,kp.alwaysValidSchema)(e,t[r]))}se.schemaProperties=PE;function TE({schemaCode:e,data:t,it:{gen:r,topSchemaRef:n,schemaPath:o,errorPath:i},it:a},s,c,u){let l=u?(0,he._)`${e}, ${t}, ${n}${o}`:t,d=[[gr.default.instancePath,(0,he.strConcat)(gr.default.instancePath,i)],[gr.default.parentData,a.parentData],[gr.default.parentDataProperty,a.parentDataProperty],[gr.default.rootData,gr.default.rootData]];a.opts.dynamicRef&&d.push([gr.default.dynamicAnchors,gr.default.dynamicAnchors]);let p=(0,he._)`${l}, ${r.object(...d)}`;return c!==he.nil?(0,he._)`${s}.call(${c}, ${p})`:(0,he._)`${s}(${p})`}se.callValidateCode=TE;var OE=(0,he._)`new RegExp`;function jE({gen:e,it:{opts:t}},r){let n=t.unicodeRegExp?"u":"",{regExp:o}=t.code,i=o(r,n);return e.scopeValue("pattern",{key:i.toString(),ref:i,code:(0,he._)`${o.code==="new RegExp"?OE:(0,kE.useFunc)(e,o)}(${r}, ${n})`})}se.usePattern=jE;function DE(e){let{gen:t,data:r,keyword:n,it:o}=e,i=t.name("valid");if(o.allErrors){let s=t.let("valid",!0);return a(()=>t.assign(s,!1)),s}return t.var(i,!0),a(()=>t.break()),i;function a(s){let c=t.const("len",(0,he._)`${r}.length`);t.forRange("i",0,c,u=>{e.subschema({keyword:n,dataProp:u,dataPropType:kp.Type.Num},i),t.if((0,he.not)(i),s)})}}se.validateArray=DE;function NE(e){let{gen:t,schema:r,keyword:n,it:o}=e;if(!Array.isArray(r))throw new Error("ajv implementation error");if(r.some(c=>(0,kp.alwaysValidSchema)(o,c))&&!o.opts.unevaluated)return;let a=t.let("valid",!1),s=t.name("_valid");t.block(()=>r.forEach((c,u)=>{let l=e.subschema({keyword:n,schemaProp:u,compositeRule:!0},s);t.assign(a,(0,he._)`${a} || ${s}`),e.mergeValidEvaluated(l,s)||t.if((0,he.not)(a))})),e.result(a,()=>e.reset(),()=>e.error(!0))}se.validateUnion=NE});var s_=I(zt=>{"use strict";Object.defineProperty(zt,"__esModule",{value:!0});zt.validateKeywordUsage=zt.validSchemaType=zt.funcKeywordCode=zt.macroKeywordCode=void 0;var Fe=H(),Mr=Gt(),RE=ut(),ME=si();function AE(e,t){let{gen:r,keyword:n,schema:o,parentSchema:i,it:a}=e,s=t.macro.call(a.self,o,i,a),c=a_(r,n,s);a.opts.validateSchema!==!1&&a.self.validateSchema(s,!0);let u=r.name("valid");e.subschema({schema:s,schemaPath:Fe.nil,errSchemaPath:`${a.errSchemaPath}/${n}`,topSchemaRef:c,compositeRule:!0},u),e.pass(u,()=>e.error(!0))}zt.macroKeywordCode=AE;function CE(e,t){var r;let{gen:n,keyword:o,schema:i,parentSchema:a,$data:s,it:c}=e;ZE(c,t);let u=!s&&t.compile?t.compile.call(c.self,i,a,c):t.validate,l=a_(n,o,u),d=n.let("valid");e.block$data(d,p),e.ok((r=t.valid)!==null&&r!==void 0?r:d);function p(){if(t.errors===!1)g(),t.modifying&&i_(e),y(()=>e.error());else{let S=t.async?f():h();t.modifying&&i_(e),y(()=>UE(e,S))}}function f(){let S=n.let("ruleErrs",null);return n.try(()=>g((0,Fe._)`await `),x=>n.assign(d,!1).if((0,Fe._)`${x} instanceof ${c.ValidationError}`,()=>n.assign(S,(0,Fe._)`${x}.errors`),()=>n.throw(x))),S}function h(){let S=(0,Fe._)`${l}.errors`;return n.assign(S,null),g(Fe.nil),S}function g(S=t.async?(0,Fe._)`await `:Fe.nil){let x=c.opts.passContext?Mr.default.this:Mr.default.self,b=!("compile"in t&&!s||t.schema===!1);n.assign(d,(0,Fe._)`${S}${(0,RE.callValidateCode)(e,l,x,b)}`,t.modifying)}function y(S){var x;n.if((0,Fe.not)((x=t.valid)!==null&&x!==void 0?x:d),S)}}zt.funcKeywordCode=CE;function i_(e){let{gen:t,data:r,it:n}=e;t.if(n.parentData,()=>t.assign(r,(0,Fe._)`${n.parentData}[${n.parentDataProperty}]`))}function UE(e,t){let{gen:r}=e;r.if((0,Fe._)`Array.isArray(${t})`,()=>{r.assign(Mr.default.vErrors,(0,Fe._)`${Mr.default.vErrors} === null ? ${t} : ${Mr.default.vErrors}.concat(${t})`).assign(Mr.default.errors,(0,Fe._)`${Mr.default.vErrors}.length`),(0,ME.extendErrors)(e)},()=>e.error())}function ZE({schemaEnv:e},t){if(t.async&&!e.$async)throw new Error("async keyword in sync schema")}function a_(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,Fe.stringify)(r)})}function LE(e,t,r=!1){return!t.length||t.some(n=>n==="array"?Array.isArray(e):n==="object"?e&&typeof e=="object"&&!Array.isArray(e):typeof e==n||r&&typeof e>"u")}zt.validSchemaType=LE;function FE({schema:e,opts:t,self:r,errSchemaPath:n},o,i){if(Array.isArray(o.keyword)?!o.keyword.includes(i):o.keyword!==i)throw new Error("ajv implementation error");let a=o.dependencies;if(a?.some(s=>!Object.prototype.hasOwnProperty.call(e,s)))throw new Error(`parent schema must have dependencies of ${i}: ${a.join(",")}`);if(o.validateSchema&&!o.validateSchema(e[i])){let c=`keyword "${i}" value is invalid at path "${n}": `+r.errorsText(o.validateSchema.errors);if(t.validateSchema==="log")r.logger.error(c);else throw new Error(c)}}zt.validateKeywordUsage=FE});var u_=I(vr=>{"use strict";Object.defineProperty(vr,"__esModule",{value:!0});vr.extendSubschemaMode=vr.extendSubschemaData=vr.getSubschema=void 0;var Pt=H(),c_=ne();function qE(e,{keyword:t,schemaProp:r,schema:n,schemaPath:o,errSchemaPath:i,topSchemaRef:a}){if(t!==void 0&&n!==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,Pt._)`${e.schemaPath}${(0,Pt.getProperty)(t)}`,errSchemaPath:`${e.errSchemaPath}/${t}`}:{schema:s[r],schemaPath:(0,Pt._)`${e.schemaPath}${(0,Pt.getProperty)(t)}${(0,Pt.getProperty)(r)}`,errSchemaPath:`${e.errSchemaPath}/${t}/${(0,c_.escapeFragment)(r)}`}}if(n!==void 0){if(o===void 0||i===void 0||a===void 0)throw new Error('"schemaPath", "errSchemaPath" and "topSchemaRef" are required with "schema"');return{schema:n,schemaPath:o,topSchemaRef:a,errSchemaPath:i}}throw new Error('either "keyword" or "schema" must be passed')}vr.getSubschema=qE;function VE(e,t,{dataProp:r,dataPropType:n,data:o,dataTypes:i,propertyName:a}){if(o!==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:u,dataPathArr:l,opts:d}=t,p=s.let("data",(0,Pt._)`${t.data}${(0,Pt.getProperty)(r)}`,!0);c(p),e.errorPath=(0,Pt.str)`${u}${(0,c_.getErrorPath)(r,n,d.jsPropertySyntax)}`,e.parentDataProperty=(0,Pt._)`${r}`,e.dataPathArr=[...l,e.parentDataProperty]}if(o!==void 0){let u=o instanceof Pt.Name?o:s.let("data",o,!0);c(u),a!==void 0&&(e.propertyName=a)}i&&(e.dataTypes=i);function c(u){e.data=u,e.dataLevel=t.dataLevel+1,e.dataTypes=[],t.definedProperties=new Set,e.parentData=t.data,e.dataNames=[...t.dataNames,u]}}vr.extendSubschemaData=VE;function WE(e,{jtdDiscriminator:t,jtdMetadata:r,compositeRule:n,createErrors:o,allErrors:i}){n!==void 0&&(e.compositeRule=n),o!==void 0&&(e.createErrors=o),i!==void 0&&(e.allErrors=i),e.jtdDiscriminator=t,e.jtdMetadata=r}vr.extendSubschemaMode=WE});var Ip=I((QU,l_)=>{"use strict";l_.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 n,o,i;if(Array.isArray(t)){if(n=t.length,n!=r.length)return!1;for(o=n;o--!==0;)if(!e(t[o],r[o]))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),n=i.length,n!==Object.keys(r).length)return!1;for(o=n;o--!==0;)if(!Object.prototype.hasOwnProperty.call(r,i[o]))return!1;for(o=n;o--!==0;){var a=i[o];if(!e(t[a],r[a]))return!1}return!0}return t!==t&&r!==r}});var p_=I((eZ,d_)=>{"use strict";var _r=d_.exports=function(e,t,r){typeof t=="function"&&(r=t,t={}),r=t.cb||r;var n=typeof r=="function"?r:r.pre||function(){},o=r.post||function(){};gs(t,n,o,e,"",e)};_r.keywords={additionalItems:!0,items:!0,contains:!0,additionalProperties:!0,propertyNames:!0,not:!0,if:!0,then:!0,else:!0};_r.arrayKeywords={items:!0,allOf:!0,anyOf:!0,oneOf:!0};_r.propsKeywords={$defs:!0,definitions:!0,properties:!0,patternProperties:!0,dependencies:!0};_r.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 gs(e,t,r,n,o,i,a,s,c,u){if(n&&typeof n=="object"&&!Array.isArray(n)){t(n,o,i,a,s,c,u);for(var l in n){var d=n[l];if(Array.isArray(d)){if(l in _r.arrayKeywords)for(var p=0;p<d.length;p++)gs(e,t,r,d[p],o+"/"+l+"/"+p,i,o,l,n,p)}else if(l in _r.propsKeywords){if(d&&typeof d=="object")for(var f in d)gs(e,t,r,d[f],o+"/"+l+"/"+JE(f),i,o,l,n,f)}else(l in _r.keywords||e.allKeys&&!(l in _r.skipKeywords))&&gs(e,t,r,d,o+"/"+l,i,o,l,n)}r(n,o,i,a,s,c,u)}}function JE(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}});var ui=I(Ke=>{"use strict";Object.defineProperty(Ke,"__esModule",{value:!0});Ke.getSchemaRefs=Ke.resolveUrl=Ke.normalizeId=Ke._getFullPath=Ke.getFullPath=Ke.inlineRef=void 0;var HE=ne(),GE=Ip(),KE=p_(),BE=new Set(["type","format","pattern","maxLength","minLength","maxProperties","minProperties","maxItems","minItems","maximum","minimum","uniqueItems","multipleOf","required","enum","const"]);function YE(e,t=!0){return typeof e=="boolean"?!0:t===!0?!zp(e):t?f_(e)<=t:!1}Ke.inlineRef=YE;var XE=new Set(["$ref","$recursiveRef","$recursiveAnchor","$dynamicRef","$dynamicAnchor"]);function zp(e){for(let t in e){if(XE.has(t))return!0;let r=e[t];if(Array.isArray(r)&&r.some(zp)||typeof r=="object"&&zp(r))return!0}return!1}function f_(e){let t=0;for(let r in e){if(r==="$ref")return 1/0;if(t++,!BE.has(r)&&(typeof e[r]=="object"&&(0,HE.eachItem)(e[r],n=>t+=f_(n)),t===1/0))return 1/0}return t}function m_(e,t="",r){r!==!1&&(t=kn(t));let n=e.parse(t);return h_(e,n)}Ke.getFullPath=m_;function h_(e,t){return e.serialize(t).split("#")[0]+"#"}Ke._getFullPath=h_;var QE=/#\/?$/;function kn(e){return e?e.replace(QE,""):""}Ke.normalizeId=kn;function eI(e,t,r){return r=kn(r),e.resolve(t,r)}Ke.resolveUrl=eI;var tI=/^[a-z_][-a-z0-9._]*$/i;function rI(e,t){if(typeof e=="boolean")return{};let{schemaId:r,uriResolver:n}=this.opts,o=kn(e[r]||t),i={"":o},a=m_(n,o,!1),s={},c=new Set;return KE(e,{allKeys:!0},(d,p,f,h)=>{if(h===void 0)return;let g=a+p,y=i[h];typeof d[r]=="string"&&(y=S.call(this,d[r])),x.call(this,d.$anchor),x.call(this,d.$dynamicAnchor),i[p]=y;function S(b){let N=this.opts.uriResolver.resolve;if(b=kn(y?N(y,b):b),c.has(b))throw l(b);c.add(b);let T=this.refs[b];return typeof T=="string"&&(T=this.refs[T]),typeof T=="object"?u(d,T.schema,b):b!==kn(g)&&(b[0]==="#"?(u(d,s[b],b),s[b]=d):this.refs[b]=g),b}function x(b){if(typeof b=="string"){if(!tI.test(b))throw new Error(`invalid anchor "${b}"`);S.call(this,`#${b}`)}}}),s;function u(d,p,f){if(p!==void 0&&!GE(d,p))throw l(f)}function l(d){return new Error(`reference "${d}" resolves to more than one schema`)}}Ke.getSchemaRefs=rI});var pi=I(yr=>{"use strict";Object.defineProperty(yr,"__esModule",{value:!0});yr.getData=yr.KeywordCxt=yr.validateFunctionCode=void 0;var $_=Kv(),g_=ci(),Tp=$p(),vs=ci(),nI=r_(),di=s_(),Pp=u_(),D=H(),Z=Gt(),oI=ui(),Kt=ne(),li=si();function iI(e){if(S_(e)&&(k_(e),x_(e))){cI(e);return}b_(e,()=>(0,$_.topBoolOrEmptySchema)(e))}yr.validateFunctionCode=iI;function b_({gen:e,validateName:t,schema:r,schemaEnv:n,opts:o},i){o.code.es5?e.func(t,(0,D._)`${Z.default.data}, ${Z.default.valCxt}`,n.$async,()=>{e.code((0,D._)`"use strict"; ${v_(r,o)}`),sI(e,o),e.code(i)}):e.func(t,(0,D._)`${Z.default.data}, ${aI(o)}`,n.$async,()=>e.code(v_(r,o)).code(i))}function aI(e){return(0,D._)`{${Z.default.instancePath}="", ${Z.default.parentData}, ${Z.default.parentDataProperty}, ${Z.default.rootData}=${Z.default.data}${e.dynamicRef?(0,D._)`, ${Z.default.dynamicAnchors}={}`:D.nil}}={}`}function sI(e,t){e.if(Z.default.valCxt,()=>{e.var(Z.default.instancePath,(0,D._)`${Z.default.valCxt}.${Z.default.instancePath}`),e.var(Z.default.parentData,(0,D._)`${Z.default.valCxt}.${Z.default.parentData}`),e.var(Z.default.parentDataProperty,(0,D._)`${Z.default.valCxt}.${Z.default.parentDataProperty}`),e.var(Z.default.rootData,(0,D._)`${Z.default.valCxt}.${Z.default.rootData}`),t.dynamicRef&&e.var(Z.default.dynamicAnchors,(0,D._)`${Z.default.valCxt}.${Z.default.dynamicAnchors}`)},()=>{e.var(Z.default.instancePath,(0,D._)`""`),e.var(Z.default.parentData,(0,D._)`undefined`),e.var(Z.default.parentDataProperty,(0,D._)`undefined`),e.var(Z.default.rootData,Z.default.data),t.dynamicRef&&e.var(Z.default.dynamicAnchors,(0,D._)`{}`)})}function cI(e){let{schema:t,opts:r,gen:n}=e;b_(e,()=>{r.$comment&&t.$comment&&E_(e),fI(e),n.let(Z.default.vErrors,null),n.let(Z.default.errors,0),r.unevaluated&&uI(e),w_(e),gI(e)})}function uI(e){let{gen:t,validateName:r}=e;e.evaluated=t.const("evaluated",(0,D._)`${r}.evaluated`),t.if((0,D._)`${e.evaluated}.dynamicProps`,()=>t.assign((0,D._)`${e.evaluated}.props`,(0,D._)`undefined`)),t.if((0,D._)`${e.evaluated}.dynamicItems`,()=>t.assign((0,D._)`${e.evaluated}.items`,(0,D._)`undefined`))}function v_(e,t){let r=typeof e=="object"&&e[t.schemaId];return r&&(t.code.source||t.code.process)?(0,D._)`/*# sourceURL=${r} */`:D.nil}function lI(e,t){if(S_(e)&&(k_(e),x_(e))){dI(e,t);return}(0,$_.boolOrEmptySchema)(e,t)}function x_({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 S_(e){return typeof e.schema!="boolean"}function dI(e,t){let{schema:r,gen:n,opts:o}=e;o.$comment&&r.$comment&&E_(e),mI(e),hI(e);let i=n.const("_errs",Z.default.errors);w_(e,i),n.var(t,(0,D._)`${i} === ${Z.default.errors}`)}function k_(e){(0,Kt.checkUnknownRules)(e),pI(e)}function w_(e,t){if(e.opts.jtd)return __(e,[],!1,t);let r=(0,g_.getSchemaTypes)(e.schema),n=(0,g_.coerceAndCheckDataType)(e,r);__(e,r,!n,t)}function pI(e){let{schema:t,errSchemaPath:r,opts:n,self:o}=e;t.$ref&&n.ignoreKeywordsWithRef&&(0,Kt.schemaHasRulesButRef)(t,o.RULES)&&o.logger.warn(`$ref: keywords ignored in schema at path "${r}"`)}function fI(e){let{schema:t,opts:r}=e;t.default!==void 0&&r.useDefaults&&r.strictSchema&&(0,Kt.checkStrictMode)(e,"default is ignored in the schema root")}function mI(e){let t=e.schema[e.opts.schemaId];t&&(e.baseId=(0,oI.resolveUrl)(e.opts.uriResolver,e.baseId,t))}function hI(e){if(e.schema.$async&&!e.schemaEnv.$async)throw new Error("async schema in sync schema")}function E_({gen:e,schemaEnv:t,schema:r,errSchemaPath:n,opts:o}){let i=r.$comment;if(o.$comment===!0)e.code((0,D._)`${Z.default.self}.logger.log(${i})`);else if(typeof o.$comment=="function"){let a=(0,D.str)`${n}/$comment`,s=e.scopeValue("root",{ref:t.root});e.code((0,D._)`${Z.default.self}.opts.$comment(${i}, ${a}, ${s}.schema)`)}}function gI(e){let{gen:t,schemaEnv:r,validateName:n,ValidationError:o,opts:i}=e;r.$async?t.if((0,D._)`${Z.default.errors} === 0`,()=>t.return(Z.default.data),()=>t.throw((0,D._)`new ${o}(${Z.default.vErrors})`)):(t.assign((0,D._)`${n}.errors`,Z.default.vErrors),i.unevaluated&&vI(e),t.return((0,D._)`${Z.default.errors} === 0`))}function vI({gen:e,evaluated:t,props:r,items:n}){r instanceof D.Name&&e.assign((0,D._)`${t}.props`,r),n instanceof D.Name&&e.assign((0,D._)`${t}.items`,n)}function __(e,t,r,n){let{gen:o,schema:i,data:a,allErrors:s,opts:c,self:u}=e,{RULES:l}=u;if(i.$ref&&(c.ignoreKeywordsWithRef||!(0,Kt.schemaHasRulesButRef)(i,l))){o.block(()=>z_(e,"$ref",l.all.$ref.definition));return}c.jtd||_I(e,t),o.block(()=>{for(let p of l.rules)d(p);d(l.post)});function d(p){(0,Tp.shouldUseGroup)(i,p)&&(p.type?(o.if((0,vs.checkDataType)(p.type,a,c.strictNumbers)),y_(e,p),t.length===1&&t[0]===p.type&&r&&(o.else(),(0,vs.reportTypeError)(e)),o.endIf()):y_(e,p),s||o.if((0,D._)`${Z.default.errors} === ${n||0}`))}}function y_(e,t){let{gen:r,schema:n,opts:{useDefaults:o}}=e;o&&(0,nI.assignDefaults)(e,t.type),r.block(()=>{for(let i of t.rules)(0,Tp.shouldUseRule)(n,i)&&z_(e,i.keyword,i.definition,t.type)})}function _I(e,t){e.schemaEnv.meta||!e.opts.strictTypes||(yI(e,t),e.opts.allowUnionTypes||$I(e,t),bI(e,e.dataTypes))}function yI(e,t){if(t.length){if(!e.dataTypes.length){e.dataTypes=t;return}t.forEach(r=>{I_(e.dataTypes,r)||Op(e,`type "${r}" not allowed by context "${e.dataTypes.join(",")}"`)}),SI(e,t)}}function $I(e,t){t.length>1&&!(t.length===2&&t.includes("null"))&&Op(e,"use allowUnionTypes to allow union type keyword")}function bI(e,t){let r=e.self.RULES.all;for(let n in r){let o=r[n];if(typeof o=="object"&&(0,Tp.shouldUseRule)(e.schema,o)){let{type:i}=o.definition;i.length&&!i.some(a=>xI(t,a))&&Op(e,`missing type "${i.join(",")}" for keyword "${n}"`)}}}function xI(e,t){return e.includes(t)||t==="number"&&e.includes("integer")}function I_(e,t){return e.includes(t)||t==="integer"&&e.includes("number")}function SI(e,t){let r=[];for(let n of e.dataTypes)I_(t,n)?r.push(n):t.includes("integer")&&n==="number"&&r.push("integer");e.dataTypes=r}function Op(e,t){let r=e.schemaEnv.baseId+e.errSchemaPath;t+=` at "${r}" (strictTypes)`,(0,Kt.checkStrictMode)(e,t,e.opts.strictTypes)}var _s=class{constructor(t,r,n){if((0,di.validateKeywordUsage)(t,r,n),this.gen=t.gen,this.allErrors=t.allErrors,this.keyword=n,this.data=t.data,this.schema=t.schema[n],this.$data=r.$data&&t.opts.$data&&this.schema&&this.schema.$data,this.schemaValue=(0,Kt.schemaRefOrVal)(t,this.schema,n,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",P_(this.$data,t));else if(this.schemaCode=this.schemaValue,!(0,di.validSchemaType)(this.schema,r.schemaType,r.allowUndefined))throw new Error(`${n} value must be ${JSON.stringify(r.schemaType)}`);("code"in r?r.trackErrors:r.errors!==!1)&&(this.errsCount=t.gen.const("_errs",Z.default.errors))}result(t,r,n){this.failResult((0,D.not)(t),r,n)}failResult(t,r,n){this.gen.if(t),n?n():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,D.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,D._)`${r} !== undefined && (${(0,D.or)(this.invalid$data(),t)})`)}error(t,r,n){if(r){this.setParams(r),this._error(t,n),this.setParams({});return}this._error(t,n)}_error(t,r){(t?li.reportExtraError:li.reportError)(this,this.def.error,r)}$dataError(){(0,li.reportError)(this,this.def.$dataError||li.keyword$DataError)}reset(){if(this.errsCount===void 0)throw new Error('add "trackErrors" to keyword definition');(0,li.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,n=D.nil){this.gen.block(()=>{this.check$data(t,n),r()})}check$data(t=D.nil,r=D.nil){if(!this.$data)return;let{gen:n,schemaCode:o,schemaType:i,def:a}=this;n.if((0,D.or)((0,D._)`${o} === undefined`,r)),t!==D.nil&&n.assign(t,!0),(i.length||a.validateSchema)&&(n.elseIf(this.invalid$data()),this.$dataError(),t!==D.nil&&n.assign(t,!1)),n.else()}invalid$data(){let{gen:t,schemaCode:r,schemaType:n,def:o,it:i}=this;return(0,D.or)(a(),s());function a(){if(n.length){if(!(r instanceof D.Name))throw new Error("ajv implementation error");let c=Array.isArray(n)?n:[n];return(0,D._)`${(0,vs.checkDataTypes)(c,r,i.opts.strictNumbers,vs.DataType.Wrong)}`}return D.nil}function s(){if(o.validateSchema){let c=t.scopeValue("validate$data",{ref:o.validateSchema});return(0,D._)`!${c}(${r})`}return D.nil}}subschema(t,r){let n=(0,Pp.getSubschema)(this.it,t);(0,Pp.extendSubschemaData)(n,this.it,t),(0,Pp.extendSubschemaMode)(n,t);let o={...this.it,...n,items:void 0,props:void 0};return lI(o,r),o}mergeEvaluated(t,r){let{it:n,gen:o}=this;n.opts.unevaluated&&(n.props!==!0&&t.props!==void 0&&(n.props=Kt.mergeEvaluated.props(o,t.props,n.props,r)),n.items!==!0&&t.items!==void 0&&(n.items=Kt.mergeEvaluated.items(o,t.items,n.items,r)))}mergeValidEvaluated(t,r){let{it:n,gen:o}=this;if(n.opts.unevaluated&&(n.props!==!0||n.items!==!0))return o.if(r,()=>this.mergeEvaluated(t,D.Name)),!0}};yr.KeywordCxt=_s;function z_(e,t,r,n){let o=new _s(e,r,t);"code"in r?r.code(o,n):o.$data&&r.validate?(0,di.funcKeywordCode)(o,r):"macro"in r?(0,di.macroKeywordCode)(o,r):(r.compile||r.validate)&&(0,di.funcKeywordCode)(o,r)}var kI=/^\/(?:[^~]|~0|~1)*$/,wI=/^([0-9]+)(#|\/(?:[^~]|~0|~1)*)?$/;function P_(e,{dataLevel:t,dataNames:r,dataPathArr:n}){let o,i;if(e==="")return Z.default.rootData;if(e[0]==="/"){if(!kI.test(e))throw new Error(`Invalid JSON-pointer: ${e}`);o=e,i=Z.default.rootData}else{let u=wI.exec(e);if(!u)throw new Error(`Invalid JSON-pointer: ${e}`);let l=+u[1];if(o=u[2],o==="#"){if(l>=t)throw new Error(c("property/index",l));return n[t-l]}if(l>t)throw new Error(c("data",l));if(i=r[t-l],!o)return i}let a=i,s=o.split("/");for(let u of s)u&&(i=(0,D._)`${i}${(0,D.getProperty)((0,Kt.unescapeJsonPointer)(u))}`,a=(0,D._)`${a} && ${i}`);return a;function c(u,l){return`Cannot access ${u} ${l} levels up, current level is ${t}`}}yr.getData=P_});var ys=I(Dp=>{"use strict";Object.defineProperty(Dp,"__esModule",{value:!0});var jp=class extends Error{constructor(t){super("validation failed"),this.errors=t,this.ajv=this.validation=!0}};Dp.default=jp});var fi=I(Mp=>{"use strict";Object.defineProperty(Mp,"__esModule",{value:!0});var Np=ui(),Rp=class extends Error{constructor(t,r,n,o){super(o||`can't resolve reference ${n} from id ${r}`),this.missingRef=(0,Np.resolveUrl)(t,r,n),this.missingSchema=(0,Np.normalizeId)((0,Np.getFullPath)(t,this.missingRef))}};Mp.default=Rp});var bs=I(lt=>{"use strict";Object.defineProperty(lt,"__esModule",{value:!0});lt.resolveSchema=lt.getCompilingSchema=lt.resolveRef=lt.compileSchema=lt.SchemaEnv=void 0;var yt=H(),EI=ys(),Ar=Gt(),$t=ui(),T_=ne(),II=pi(),wn=class{constructor(t){var r;this.refs={},this.dynamicAnchors={};let n;typeof t.schema=="object"&&(n=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,$t.normalizeId)(n?.[t.schemaId||"$id"]),this.schemaPath=t.schemaPath,this.localRefs=t.localRefs,this.meta=t.meta,this.$async=n?.$async,this.refs={}}};lt.SchemaEnv=wn;function Cp(e){let t=O_.call(this,e);if(t)return t;let r=(0,$t.getFullPath)(this.opts.uriResolver,e.root.baseId),{es5:n,lines:o}=this.opts.code,{ownProperties:i}=this.opts,a=new yt.CodeGen(this.scope,{es5:n,lines:o,ownProperties:i}),s;e.$async&&(s=a.scopeValue("Error",{ref:EI.default,code:(0,yt._)`require("ajv/dist/runtime/validation_error").default`}));let c=a.scopeName("validate");e.validateName=c;let u={gen:a,allErrors:this.opts.allErrors,data:Ar.default.data,parentData:Ar.default.parentData,parentDataProperty:Ar.default.parentDataProperty,dataNames:[Ar.default.data],dataPathArr:[yt.nil],dataLevel:0,dataTypes:[],definedProperties:new Set,topSchemaRef:a.scopeValue("schema",this.opts.code.source===!0?{ref:e.schema,code:(0,yt.stringify)(e.schema)}:{ref:e.schema}),validateName:c,ValidationError:s,schema:e.schema,schemaEnv:e,rootId:r,baseId:e.baseId||r,schemaPath:yt.nil,errSchemaPath:e.schemaPath||(this.opts.jtd?"":"#"),errorPath:(0,yt._)`""`,opts:this.opts,self:this},l;try{this._compilations.add(e),(0,II.validateFunctionCode)(u),a.optimize(this.opts.code.optimize);let d=a.toString();l=`${a.scopeRefs(Ar.default.scope)}return ${d}`,this.opts.code.process&&(l=this.opts.code.process(l,e));let f=new Function(`${Ar.default.self}`,`${Ar.default.scope}`,l)(this,this.scope.get());if(this.scope.value(c,{ref:f}),f.errors=null,f.schema=e.schema,f.schemaEnv=e,e.$async&&(f.$async=!0),this.opts.code.source===!0&&(f.source={validateName:c,validateCode:d,scopeValues:a._values}),this.opts.unevaluated){let{props:h,items:g}=u;f.evaluated={props:h instanceof yt.Name?void 0:h,items:g instanceof yt.Name?void 0:g,dynamicProps:h instanceof yt.Name,dynamicItems:g instanceof yt.Name},f.source&&(f.source.evaluated=(0,yt.stringify)(f.evaluated))}return e.validate=f,e}catch(d){throw delete e.validate,delete e.validateName,l&&this.logger.error("Error compiling schema, function code:",l),d}finally{this._compilations.delete(e)}}lt.compileSchema=Cp;function zI(e,t,r){var n;r=(0,$t.resolveUrl)(this.opts.uriResolver,t,r);let o=e.refs[r];if(o)return o;let i=OI.call(this,e,r);if(i===void 0){let a=(n=e.localRefs)===null||n===void 0?void 0:n[r],{schemaId:s}=this.opts;a&&(i=new wn({schema:a,schemaId:s,root:e,baseId:t}))}if(i!==void 0)return e.refs[r]=PI.call(this,i)}lt.resolveRef=zI;function PI(e){return(0,$t.inlineRef)(e.schema,this.opts.inlineRefs)?e.schema:e.validate?e:Cp.call(this,e)}function O_(e){for(let t of this._compilations)if(TI(t,e))return t}lt.getCompilingSchema=O_;function TI(e,t){return e.schema===t.schema&&e.root===t.root&&e.baseId===t.baseId}function OI(e,t){let r;for(;typeof(r=this.refs[t])=="string";)t=r;return r||this.schemas[t]||$s.call(this,e,t)}function $s(e,t){let r=this.opts.uriResolver.parse(t),n=(0,$t._getFullPath)(this.opts.uriResolver,r),o=(0,$t.getFullPath)(this.opts.uriResolver,e.baseId,void 0);if(Object.keys(e.schema).length>0&&n===o)return Ap.call(this,r,e);let i=(0,$t.normalizeId)(n),a=this.refs[i]||this.schemas[i];if(typeof a=="string"){let s=$s.call(this,e,a);return typeof s?.schema!="object"?void 0:Ap.call(this,r,s)}if(typeof a?.schema=="object"){if(a.validate||Cp.call(this,a),i===(0,$t.normalizeId)(t)){let{schema:s}=a,{schemaId:c}=this.opts,u=s[c];return u&&(o=(0,$t.resolveUrl)(this.opts.uriResolver,o,u)),new wn({schema:s,schemaId:c,root:e,baseId:o})}return Ap.call(this,r,a)}}lt.resolveSchema=$s;var jI=new Set(["properties","patternProperties","enum","dependencies","definitions"]);function Ap(e,{baseId:t,schema:r,root:n}){var o;if(((o=e.fragment)===null||o===void 0?void 0:o[0])!=="/")return;for(let s of e.fragment.slice(1).split("/")){if(typeof r=="boolean")return;let c=r[(0,T_.unescapeFragment)(s)];if(c===void 0)return;r=c;let u=typeof r=="object"&&r[this.opts.schemaId];!jI.has(s)&&u&&(t=(0,$t.resolveUrl)(this.opts.uriResolver,t,u))}let i;if(typeof r!="boolean"&&r.$ref&&!(0,T_.schemaHasRulesButRef)(r,this.RULES)){let s=(0,$t.resolveUrl)(this.opts.uriResolver,t,r.$ref);i=$s.call(this,n,s)}let{schemaId:a}=this.opts;if(i=i||new wn({schema:r,schemaId:a,root:n,baseId:t}),i.schema!==i.root.schema)return i}});var j_=I((aZ,DI)=>{DI.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 Zp=I((sZ,M_)=>{"use strict";var NI=RegExp.prototype.test.bind(/^[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}$/iu),N_=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);function Up(e){let t="",r=0,n=0;for(n=0;n<e.length;n++)if(r=e[n].charCodeAt(0),r!==48){if(!(r>=48&&r<=57||r>=65&&r<=70||r>=97&&r<=102))return"";t+=e[n];break}for(n+=1;n<e.length;n++){if(r=e[n].charCodeAt(0),!(r>=48&&r<=57||r>=65&&r<=70||r>=97&&r<=102))return"";t+=e[n]}return t}var RI=RegExp.prototype.test.bind(/[^!"$&'()*+,\-.;=_`a-z{}~]/u);function D_(e){return e.length=0,!0}function MI(e,t,r){if(e.length){let n=Up(e);if(n!=="")t.push(n);else return r.error=!0,!1;e.length=0}return!0}function AI(e){let t=0,r={error:!1,address:"",zone:""},n=[],o=[],i=!1,a=!1,s=MI;for(let c=0;c<e.length;c++){let u=e[c];if(!(u==="["||u==="]"))if(u===":"){if(i===!0&&(a=!0),!s(o,n,r))break;if(++t>7){r.error=!0;break}c>0&&e[c-1]===":"&&(i=!0),n.push(":");continue}else if(u==="%"){if(!s(o,n,r))break;s=D_}else{o.push(u);continue}}return o.length&&(s===D_?r.zone=o.join(""):a?n.push(o.join("")):n.push(Up(o))),r.address=n.join(""),r}function R_(e){if(CI(e,":")<2)return{host:e,isIPV6:!1};let t=AI(e);if(t.error)return{host:e,isIPV6:!1};{let r=t.address,n=t.address;return t.zone&&(r+="%"+t.zone,n+="%25"+t.zone),{host:r,isIPV6:!0,escapedHost:n}}}function CI(e,t){let r=0;for(let n=0;n<e.length;n++)e[n]===t&&r++;return r}function UI(e){let t=e,r=[],n=-1,o=0;for(;o=t.length;){if(o===1){if(t===".")break;if(t==="/"){r.push("/");break}else{r.push(t);break}}else if(o===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(o===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((n=t.indexOf("/",1))===-1){r.push(t);break}else r.push(t.slice(0,n)),t=t.slice(n)}return r.join("")}function ZI(e,t){let r=t!==!0?escape:unescape;return e.scheme!==void 0&&(e.scheme=r(e.scheme)),e.userinfo!==void 0&&(e.userinfo=r(e.userinfo)),e.host!==void 0&&(e.host=r(e.host)),e.path!==void 0&&(e.path=r(e.path)),e.query!==void 0&&(e.query=r(e.query)),e.fragment!==void 0&&(e.fragment=r(e.fragment)),e}function LI(e){let t=[];if(e.userinfo!==void 0&&(t.push(e.userinfo),t.push("@")),e.host!==void 0){let r=unescape(e.host);if(!N_(r)){let n=R_(r);n.isIPV6===!0?r=`[${n.escapedHost}]`:r=e.host}t.push(r)}return(typeof e.port=="number"||typeof e.port=="string")&&(t.push(":"),t.push(String(e.port))),t.length?t.join(""):void 0}M_.exports={nonSimpleDomain:RI,recomposeAuthority:LI,normalizeComponentEncoding:ZI,removeDotSegments:UI,isIPv4:N_,isUUID:NI,normalizeIPv6:R_,stringArrayToHexStripped:Up}});var L_=I((cZ,Z_)=>{"use strict";var{isUUID:FI}=Zp(),qI=/([\da-z][\d\-a-z]{0,31}):((?:[\w!$'()*+,\-.:;=@]|%[\da-f]{2})+)/iu,VI=["http","https","ws","wss","urn","urn:uuid"];function WI(e){return VI.indexOf(e)!==-1}function Lp(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 A_(e){return e.host||(e.error=e.error||"HTTP URIs must have a host."),e}function C_(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 JI(e){return e.secure=Lp(e),e.resourceName=(e.path||"/")+(e.query?"?"+e.query:""),e.path=void 0,e.query=void 0,e}function HI(e){if((e.port===(Lp(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,r]=e.resourceName.split("?");e.path=t&&t!=="/"?t:void 0,e.query=r,e.resourceName=void 0}return e.fragment=void 0,e}function GI(e,t){if(!e.path)return e.error="URN can not be parsed",e;let r=e.path.match(qI);if(r){let n=t.scheme||e.scheme||"urn";e.nid=r[1].toLowerCase(),e.nss=r[2];let o=`${n}:${t.nid||e.nid}`,i=Fp(o);e.path=void 0,i&&(e=i.parse(e,t))}else e.error=e.error||"URN can not be parsed.";return e}function KI(e,t){if(e.nid===void 0)throw new Error("URN without nid cannot be serialized");let r=t.scheme||e.scheme||"urn",n=e.nid.toLowerCase(),o=`${r}:${t.nid||n}`,i=Fp(o);i&&(e=i.serialize(e,t));let a=e,s=e.nss;return a.path=`${n||t.nid}:${s}`,t.skipEscape=!0,a}function BI(e,t){let r=e;return r.uuid=r.nss,r.nss=void 0,!t.tolerant&&(!r.uuid||!FI(r.uuid))&&(r.error=r.error||"UUID is not valid."),r}function YI(e){let t=e;return t.nss=(e.uuid||"").toLowerCase(),t}var U_={scheme:"http",domainHost:!0,parse:A_,serialize:C_},XI={scheme:"https",domainHost:U_.domainHost,parse:A_,serialize:C_},xs={scheme:"ws",domainHost:!0,parse:JI,serialize:HI},QI={scheme:"wss",domainHost:xs.domainHost,parse:xs.parse,serialize:xs.serialize},ez={scheme:"urn",parse:GI,serialize:KI,skipNormalize:!0},tz={scheme:"urn:uuid",parse:BI,serialize:YI,skipNormalize:!0},Ss={http:U_,https:XI,ws:xs,wss:QI,urn:ez,"urn:uuid":tz};Object.setPrototypeOf(Ss,null);function Fp(e){return e&&(Ss[e]||Ss[e.toLowerCase()])||void 0}Z_.exports={wsIsSecure:Lp,SCHEMES:Ss,isValidSchemeName:WI,getSchemeHandler:Fp}});var V_=I((uZ,ws)=>{"use strict";var{normalizeIPv6:rz,removeDotSegments:mi,recomposeAuthority:nz,normalizeComponentEncoding:ks,isIPv4:oz,nonSimpleDomain:iz}=Zp(),{SCHEMES:az,getSchemeHandler:F_}=L_();function sz(e,t){return typeof e=="string"?e=Tt(Bt(e,t),t):typeof e=="object"&&(e=Bt(Tt(e,t),t)),e}function cz(e,t,r){let n=r?Object.assign({scheme:"null"},r):{scheme:"null"},o=q_(Bt(e,n),Bt(t,n),n,!0);return n.skipEscape=!0,Tt(o,n)}function q_(e,t,r,n){let o={};return n||(e=Bt(Tt(e,r),r),t=Bt(Tt(t,r),r)),r=r||{},!r.tolerant&&t.scheme?(o.scheme=t.scheme,o.userinfo=t.userinfo,o.host=t.host,o.port=t.port,o.path=mi(t.path||""),o.query=t.query):(t.userinfo!==void 0||t.host!==void 0||t.port!==void 0?(o.userinfo=t.userinfo,o.host=t.host,o.port=t.port,o.path=mi(t.path||""),o.query=t.query):(t.path?(t.path[0]==="/"?o.path=mi(t.path):((e.userinfo!==void 0||e.host!==void 0||e.port!==void 0)&&!e.path?o.path="/"+t.path:e.path?o.path=e.path.slice(0,e.path.lastIndexOf("/")+1)+t.path:o.path=t.path,o.path=mi(o.path)),o.query=t.query):(o.path=e.path,t.query!==void 0?o.query=t.query:o.query=e.query),o.userinfo=e.userinfo,o.host=e.host,o.port=e.port),o.scheme=e.scheme),o.fragment=t.fragment,o}function uz(e,t,r){return typeof e=="string"?(e=unescape(e),e=Tt(ks(Bt(e,r),!0),{...r,skipEscape:!0})):typeof e=="object"&&(e=Tt(ks(e,!0),{...r,skipEscape:!0})),typeof t=="string"?(t=unescape(t),t=Tt(ks(Bt(t,r),!0),{...r,skipEscape:!0})):typeof t=="object"&&(t=Tt(ks(t,!0),{...r,skipEscape:!0})),e.toLowerCase()===t.toLowerCase()}function Tt(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:""},n=Object.assign({},t),o=[],i=F_(n.scheme||r.scheme);i&&i.serialize&&i.serialize(r,n),r.path!==void 0&&(n.skipEscape?r.path=unescape(r.path):(r.path=escape(r.path),r.scheme!==void 0&&(r.path=r.path.split("%3A").join(":")))),n.reference!=="suffix"&&r.scheme&&o.push(r.scheme,":");let a=nz(r);if(a!==void 0&&(n.reference!=="suffix"&&o.push("//"),o.push(a),r.path&&r.path[0]!=="/"&&o.push("/")),r.path!==void 0){let s=r.path;!n.absolutePath&&(!i||!i.absolutePath)&&(s=mi(s)),a===void 0&&s[0]==="/"&&s[1]==="/"&&(s="/%2F"+s.slice(2)),o.push(s)}return r.query!==void 0&&o.push("?",r.query),r.fragment!==void 0&&o.push("#",r.fragment),o.join("")}var lz=/^(?:([^#/:?]+):)?(?:\/\/((?:([^#/?@]*)@)?(\[[^#/?\]]+\]|[^#/:?]*)(?::(\d*))?))?([^#?]*)(?:\?([^#]*))?(?:#((?:.|[\n\r])*))?/u;function Bt(e,t){let r=Object.assign({},t),n={scheme:void 0,userinfo:void 0,host:"",port:void 0,path:"",query:void 0,fragment:void 0},o=!1;r.reference==="suffix"&&(r.scheme?e=r.scheme+":"+e:e="//"+e);let i=e.match(lz);if(i){if(n.scheme=i[1],n.userinfo=i[3],n.host=i[4],n.port=parseInt(i[5],10),n.path=i[6]||"",n.query=i[7],n.fragment=i[8],isNaN(n.port)&&(n.port=i[5]),n.host)if(oz(n.host)===!1){let c=rz(n.host);n.host=c.host.toLowerCase(),o=c.isIPV6}else o=!0;n.scheme===void 0&&n.userinfo===void 0&&n.host===void 0&&n.port===void 0&&n.query===void 0&&!n.path?n.reference="same-document":n.scheme===void 0?n.reference="relative":n.fragment===void 0?n.reference="absolute":n.reference="uri",r.reference&&r.reference!=="suffix"&&r.reference!==n.reference&&(n.error=n.error||"URI is not a "+r.reference+" reference.");let a=F_(r.scheme||n.scheme);if(!r.unicodeSupport&&(!a||!a.unicodeSupport)&&n.host&&(r.domainHost||a&&a.domainHost)&&o===!1&&iz(n.host))try{n.host=URL.domainToASCII(n.host.toLowerCase())}catch(s){n.error=n.error||"Host's domain name can not be converted to ASCII: "+s}(!a||a&&!a.skipNormalize)&&(e.indexOf("%")!==-1&&(n.scheme!==void 0&&(n.scheme=unescape(n.scheme)),n.host!==void 0&&(n.host=unescape(n.host))),n.path&&(n.path=escape(unescape(n.path))),n.fragment&&(n.fragment=encodeURI(decodeURIComponent(n.fragment)))),a&&a.parse&&a.parse(n,r)}else n.error=n.error||"URI can not be parsed.";return n}var qp={SCHEMES:az,normalize:sz,resolve:cz,resolveComponent:q_,equal:uz,serialize:Tt,parse:Bt};ws.exports=qp;ws.exports.default=qp;ws.exports.fastUri=qp});var J_=I(Vp=>{"use strict";Object.defineProperty(Vp,"__esModule",{value:!0});var W_=V_();W_.code='require("ajv/dist/runtime/uri").default';Vp.default=W_});var ey=I(Ee=>{"use strict";Object.defineProperty(Ee,"__esModule",{value:!0});Ee.CodeGen=Ee.Name=Ee.nil=Ee.stringify=Ee.str=Ee._=Ee.KeywordCxt=void 0;var dz=pi();Object.defineProperty(Ee,"KeywordCxt",{enumerable:!0,get:function(){return dz.KeywordCxt}});var En=H();Object.defineProperty(Ee,"_",{enumerable:!0,get:function(){return En._}});Object.defineProperty(Ee,"str",{enumerable:!0,get:function(){return En.str}});Object.defineProperty(Ee,"stringify",{enumerable:!0,get:function(){return En.stringify}});Object.defineProperty(Ee,"nil",{enumerable:!0,get:function(){return En.nil}});Object.defineProperty(Ee,"Name",{enumerable:!0,get:function(){return En.Name}});Object.defineProperty(Ee,"CodeGen",{enumerable:!0,get:function(){return En.CodeGen}});var pz=ys(),Y_=fi(),fz=yp(),hi=bs(),mz=H(),gi=ui(),Es=ci(),Jp=ne(),H_=j_(),hz=J_(),X_=(e,t)=>new RegExp(e,t);X_.code="new RegExp";var gz=["removeAdditional","useDefaults","coerceTypes"],vz=new Set(["validate","serialize","parse","wrapper","root","schema","keyword","pattern","formats","validate$data","func","obj","Error"]),_z={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."},yz={ignoreKeywordsWithRef:"",jsPropertySyntax:"",unicode:'"minLength"/"maxLength" account for unicode characters by default.'},G_=200;function $z(e){var t,r,n,o,i,a,s,c,u,l,d,p,f,h,g,y,S,x,b,N,T,Ve,We,Zn,qr;let ye=e.strict,rr=(t=e.code)===null||t===void 0?void 0:t.optimize,mt=rr===!0||rr===void 0?1:rr||0,Ln=(n=(r=e.code)===null||r===void 0?void 0:r.regExp)!==null&&n!==void 0?n:X_,Sb=(o=e.uriResolver)!==null&&o!==void 0?o:hz.default;return{strictSchema:(a=(i=e.strictSchema)!==null&&i!==void 0?i:ye)!==null&&a!==void 0?a:!0,strictNumbers:(c=(s=e.strictNumbers)!==null&&s!==void 0?s:ye)!==null&&c!==void 0?c:!0,strictTypes:(l=(u=e.strictTypes)!==null&&u!==void 0?u:ye)!==null&&l!==void 0?l:"log",strictTuples:(p=(d=e.strictTuples)!==null&&d!==void 0?d:ye)!==null&&p!==void 0?p:"log",strictRequired:(h=(f=e.strictRequired)!==null&&f!==void 0?f:ye)!==null&&h!==void 0?h:!1,code:e.code?{...e.code,optimize:mt,regExp:Ln}:{optimize:mt,regExp:Ln},loopRequired:(g=e.loopRequired)!==null&&g!==void 0?g:G_,loopEnum:(y=e.loopEnum)!==null&&y!==void 0?y:G_,meta:(S=e.meta)!==null&&S!==void 0?S:!0,messages:(x=e.messages)!==null&&x!==void 0?x:!0,inlineRefs:(b=e.inlineRefs)!==null&&b!==void 0?b:!0,schemaId:(N=e.schemaId)!==null&&N!==void 0?N:"$id",addUsedSchema:(T=e.addUsedSchema)!==null&&T!==void 0?T:!0,validateSchema:(Ve=e.validateSchema)!==null&&Ve!==void 0?Ve:!0,validateFormats:(We=e.validateFormats)!==null&&We!==void 0?We:!0,unicodeRegExp:(Zn=e.unicodeRegExp)!==null&&Zn!==void 0?Zn:!0,int32range:(qr=e.int32range)!==null&&qr!==void 0?qr:!0,uriResolver:Sb}}var vi=class{constructor(t={}){this.schemas={},this.refs={},this.formats={},this._compilations=new Set,this._loading={},this._cache=new Map,t=this.opts={...t,...$z(t)};let{es5:r,lines:n}=this.opts.code;this.scope=new mz.ValueScope({scope:{},prefixes:vz,es5:r,lines:n}),this.logger=Ez(t.logger);let o=t.validateFormats;t.validateFormats=!1,this.RULES=(0,fz.getRules)(),K_.call(this,_z,t,"NOT SUPPORTED"),K_.call(this,yz,t,"DEPRECATED","warn"),this._metaOpts=kz.call(this),t.formats&&xz.call(this),this._addVocabularies(),this._addDefaultMetaSchema(),t.keywords&&Sz.call(this,t.keywords),typeof t.meta=="object"&&this.addMetaSchema(t.meta),bz.call(this),t.validateFormats=o}_addVocabularies(){this.addKeyword("$async")}_addDefaultMetaSchema(){let{$data:t,meta:r,schemaId:n}=this.opts,o=H_;n==="id"&&(o={...H_},o.id=o.$id,delete o.$id),r&&t&&this.addMetaSchema(o,o[n],!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 n;if(typeof t=="string"){if(n=this.getSchema(t),!n)throw new Error(`no schema with key or ref "${t}"`)}else n=this.compile(t);let o=n(r);return"$async"in n||(this.errors=n.errors),o}compile(t,r){let n=this._addSchema(t,r);return n.validate||this._compileSchemaEnv(n)}compileAsync(t,r){if(typeof this.opts.loadSchema!="function")throw new Error("options.loadSchema should be a function");let{loadSchema:n}=this.opts;return o.call(this,t,r);async function o(l,d){await i.call(this,l.$schema);let p=this._addSchema(l,d);return p.validate||a.call(this,p)}async function i(l){l&&!this.getSchema(l)&&await o.call(this,{$ref:l},!0)}async function a(l){try{return this._compileSchemaEnv(l)}catch(d){if(!(d instanceof Y_.default))throw d;return s.call(this,d),await c.call(this,d.missingSchema),a.call(this,l)}}function s({missingSchema:l,missingRef:d}){if(this.refs[l])throw new Error(`AnySchema ${l} is loaded but ${d} cannot be resolved`)}async function c(l){let d=await u.call(this,l);this.refs[l]||await i.call(this,d.$schema),this.refs[l]||this.addSchema(d,l,r)}async function u(l){let d=this._loading[l];if(d)return d;try{return await(this._loading[l]=n(l))}finally{delete this._loading[l]}}}addSchema(t,r,n,o=this.opts.validateSchema){if(Array.isArray(t)){for(let a of t)this.addSchema(a,void 0,n,o);return this}let i;if(typeof t=="object"){let{schemaId:a}=this.opts;if(i=t[a],i!==void 0&&typeof i!="string")throw new Error(`schema ${a} must be string`)}return r=(0,gi.normalizeId)(r||i),this._checkUnique(r),this.schemas[r]=this._addSchema(t,n,r,o,!0),this}addMetaSchema(t,r,n=this.opts.validateSchema){return this.addSchema(t,r,!0,n),this}validateSchema(t,r){if(typeof t=="boolean")return!0;let n;if(n=t.$schema,n!==void 0&&typeof n!="string")throw new Error("$schema must be a string");if(n=n||this.opts.defaultMeta||this.defaultMeta(),!n)return this.logger.warn("meta-schema not available"),this.errors=null,!0;let o=this.validate(n,t);if(!o&&r){let i="schema is invalid: "+this.errorsText();if(this.opts.validateSchema==="log")this.logger.error(i);else throw new Error(i)}return o}getSchema(t){let r;for(;typeof(r=B_.call(this,t))=="string";)t=r;if(r===void 0){let{schemaId:n}=this.opts,o=new hi.SchemaEnv({schema:{},schemaId:n});if(r=hi.resolveSchema.call(this,o,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=B_.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 n=t[this.opts.schemaId];return n&&(n=(0,gi.normalizeId)(n),delete this.schemas[n],delete this.refs[n]),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 n;if(typeof t=="string")n=t,typeof r=="object"&&(this.logger.warn("these parameters are deprecated, see docs for addKeyword"),r.keyword=n);else if(typeof t=="object"&&r===void 0){if(r=t,n=r.keyword,Array.isArray(n)&&!n.length)throw new Error("addKeywords: keyword must be string or non-empty array")}else throw new Error("invalid addKeywords parameters");if(zz.call(this,n,r),!r)return(0,Jp.eachItem)(n,i=>Wp.call(this,i)),this;Tz.call(this,r);let o={...r,type:(0,Es.getJSONTypes)(r.type),schemaType:(0,Es.getJSONTypes)(r.schemaType)};return(0,Jp.eachItem)(n,o.type.length===0?i=>Wp.call(this,i,o):i=>o.type.forEach(a=>Wp.call(this,i,o,a))),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 n of r.rules){let o=n.rules.findIndex(i=>i.keyword===t);o>=0&&n.rules.splice(o,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:n="data"}={}){return!t||t.length===0?"No errors":t.map(o=>`${n}${o.instancePath} ${o.message}`).reduce((o,i)=>o+r+i)}$dataMetaSchema(t,r){let n=this.RULES.all;t=JSON.parse(JSON.stringify(t));for(let o of r){let i=o.split("/").slice(1),a=t;for(let s of i)a=a[s];for(let s in n){let c=n[s];if(typeof c!="object")continue;let{$data:u}=c.definition,l=a[s];u&&l&&(a[s]=Q_(l))}}return t}_removeAllSchemas(t,r){for(let n in t){let o=t[n];(!r||r.test(n))&&(typeof o=="string"?delete t[n]:o&&!o.meta&&(this._cache.delete(o.schema),delete t[n]))}}_addSchema(t,r,n,o=this.opts.validateSchema,i=this.opts.addUsedSchema){let a,{schemaId:s}=this.opts;if(typeof t=="object")a=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 c=this._cache.get(t);if(c!==void 0)return c;n=(0,gi.normalizeId)(a||n);let u=gi.getSchemaRefs.call(this,t,n);return c=new hi.SchemaEnv({schema:t,schemaId:s,meta:r,baseId:n,localRefs:u}),this._cache.set(c.schema,c),i&&!n.startsWith("#")&&(n&&this._checkUnique(n),this.refs[n]=c),o&&this.validateSchema(t,!0),c}_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):hi.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{hi.compileSchema.call(this,t)}finally{this.opts=r}}};vi.ValidationError=pz.default;vi.MissingRefError=Y_.default;Ee.default=vi;function K_(e,t,r,n="error"){for(let o in e){let i=o;i in t&&this.logger[n](`${r}: option ${o}. ${e[i]}`)}}function B_(e){return e=(0,gi.normalizeId)(e),this.schemas[e]||this.refs[e]}function bz(){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 xz(){for(let e in this.opts.formats){let t=this.opts.formats[e];t&&this.addFormat(e,t)}}function Sz(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 kz(){let e={...this.opts};for(let t of gz)delete e[t];return e}var wz={log(){},warn(){},error(){}};function Ez(e){if(e===!1)return wz;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 Iz=/^[a-z_$][a-z0-9_$:-]*$/i;function zz(e,t){let{RULES:r}=this;if((0,Jp.eachItem)(e,n=>{if(r.keywords[n])throw new Error(`Keyword ${n} is already defined`);if(!Iz.test(n))throw new Error(`Keyword ${n} has invalid name`)}),!!t&&t.$data&&!("code"in t||"validate"in t))throw new Error('$data keyword must have "code" or "validate" function')}function Wp(e,t,r){var n;let o=t?.post;if(r&&o)throw new Error('keyword with "post" flag cannot have "type"');let{RULES:i}=this,a=o?i.post:i.rules.find(({type:c})=>c===r);if(a||(a={type:r,rules:[]},i.rules.push(a)),i.keywords[e]=!0,!t)return;let s={keyword:e,definition:{...t,type:(0,Es.getJSONTypes)(t.type),schemaType:(0,Es.getJSONTypes)(t.schemaType)}};t.before?Pz.call(this,a,s,t.before):a.rules.push(s),i.all[e]=s,(n=t.implements)===null||n===void 0||n.forEach(c=>this.addKeyword(c))}function Pz(e,t,r){let n=e.rules.findIndex(o=>o.keyword===r);n>=0?e.rules.splice(n,0,t):(e.rules.push(t),this.logger.warn(`rule ${r} is not defined`))}function Tz(e){let{metaSchema:t}=e;t!==void 0&&(e.$data&&this.opts.$data&&(t=Q_(t)),e.validateSchema=this.compile(t,!0))}var Oz={$ref:"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#"};function Q_(e){return{anyOf:[e,Oz]}}});var ty=I(Hp=>{"use strict";Object.defineProperty(Hp,"__esModule",{value:!0});var jz={keyword:"id",code(){throw new Error('NOT SUPPORTED: keyword "id", use "$id" for schema ID')}};Hp.default=jz});var iy=I(Cr=>{"use strict";Object.defineProperty(Cr,"__esModule",{value:!0});Cr.callRef=Cr.getValidate=void 0;var Dz=fi(),ry=ut(),Be=H(),In=Gt(),ny=bs(),Is=ne(),Nz={keyword:"$ref",schemaType:"string",code(e){let{gen:t,schema:r,it:n}=e,{baseId:o,schemaEnv:i,validateName:a,opts:s,self:c}=n,{root:u}=i;if((r==="#"||r==="#/")&&o===u.baseId)return d();let l=ny.resolveRef.call(c,u,o,r);if(l===void 0)throw new Dz.default(n.opts.uriResolver,o,r);if(l instanceof ny.SchemaEnv)return p(l);return f(l);function d(){if(i===u)return zs(e,a,i,i.$async);let h=t.scopeValue("root",{ref:u});return zs(e,(0,Be._)`${h}.validate`,u,u.$async)}function p(h){let g=oy(e,h);zs(e,g,h,h.$async)}function f(h){let g=t.scopeValue("schema",s.code.source===!0?{ref:h,code:(0,Be.stringify)(h)}:{ref:h}),y=t.name("valid"),S=e.subschema({schema:h,dataTypes:[],schemaPath:Be.nil,topSchemaRef:g,errSchemaPath:r},y);e.mergeEvaluated(S),e.ok(y)}}};function oy(e,t){let{gen:r}=e;return t.validate?r.scopeValue("validate",{ref:t.validate}):(0,Be._)`${r.scopeValue("wrapper",{ref:t})}.validate`}Cr.getValidate=oy;function zs(e,t,r,n){let{gen:o,it:i}=e,{allErrors:a,schemaEnv:s,opts:c}=i,u=c.passContext?In.default.this:Be.nil;n?l():d();function l(){if(!s.$async)throw new Error("async schema referenced by sync schema");let h=o.let("valid");o.try(()=>{o.code((0,Be._)`await ${(0,ry.callValidateCode)(e,t,u)}`),f(t),a||o.assign(h,!0)},g=>{o.if((0,Be._)`!(${g} instanceof ${i.ValidationError})`,()=>o.throw(g)),p(g),a||o.assign(h,!1)}),e.ok(h)}function d(){e.result((0,ry.callValidateCode)(e,t,u),()=>f(t),()=>p(t))}function p(h){let g=(0,Be._)`${h}.errors`;o.assign(In.default.vErrors,(0,Be._)`${In.default.vErrors} === null ? ${g} : ${In.default.vErrors}.concat(${g})`),o.assign(In.default.errors,(0,Be._)`${In.default.vErrors}.length`)}function f(h){var g;if(!i.opts.unevaluated)return;let y=(g=r?.validate)===null||g===void 0?void 0:g.evaluated;if(i.props!==!0)if(y&&!y.dynamicProps)y.props!==void 0&&(i.props=Is.mergeEvaluated.props(o,y.props,i.props));else{let S=o.var("props",(0,Be._)`${h}.evaluated.props`);i.props=Is.mergeEvaluated.props(o,S,i.props,Be.Name)}if(i.items!==!0)if(y&&!y.dynamicItems)y.items!==void 0&&(i.items=Is.mergeEvaluated.items(o,y.items,i.items));else{let S=o.var("items",(0,Be._)`${h}.evaluated.items`);i.items=Is.mergeEvaluated.items(o,S,i.items,Be.Name)}}}Cr.callRef=zs;Cr.default=Nz});var ay=I(Gp=>{"use strict";Object.defineProperty(Gp,"__esModule",{value:!0});var Rz=ty(),Mz=iy(),Az=["$schema","$id","$defs","$vocabulary",{keyword:"$comment"},"definitions",Rz.default,Mz.default];Gp.default=Az});var sy=I(Kp=>{"use strict";Object.defineProperty(Kp,"__esModule",{value:!0});var Ps=H(),$r=Ps.operators,Ts={maximum:{okStr:"<=",ok:$r.LTE,fail:$r.GT},minimum:{okStr:">=",ok:$r.GTE,fail:$r.LT},exclusiveMaximum:{okStr:"<",ok:$r.LT,fail:$r.GTE},exclusiveMinimum:{okStr:">",ok:$r.GT,fail:$r.LTE}},Cz={message:({keyword:e,schemaCode:t})=>(0,Ps.str)`must be ${Ts[e].okStr} ${t}`,params:({keyword:e,schemaCode:t})=>(0,Ps._)`{comparison: ${Ts[e].okStr}, limit: ${t}}`},Uz={keyword:Object.keys(Ts),type:"number",schemaType:"number",$data:!0,error:Cz,code(e){let{keyword:t,data:r,schemaCode:n}=e;e.fail$data((0,Ps._)`${r} ${Ts[t].fail} ${n} || isNaN(${r})`)}};Kp.default=Uz});var cy=I(Bp=>{"use strict";Object.defineProperty(Bp,"__esModule",{value:!0});var _i=H(),Zz={message:({schemaCode:e})=>(0,_i.str)`must be multiple of ${e}`,params:({schemaCode:e})=>(0,_i._)`{multipleOf: ${e}}`},Lz={keyword:"multipleOf",type:"number",schemaType:"number",$data:!0,error:Zz,code(e){let{gen:t,data:r,schemaCode:n,it:o}=e,i=o.opts.multipleOfPrecision,a=t.let("res"),s=i?(0,_i._)`Math.abs(Math.round(${a}) - ${a}) > 1e-${i}`:(0,_i._)`${a} !== parseInt(${a})`;e.fail$data((0,_i._)`(${n} === 0 || (${a} = ${r}/${n}, ${s}))`)}};Bp.default=Lz});var ly=I(Yp=>{"use strict";Object.defineProperty(Yp,"__esModule",{value:!0});function uy(e){let t=e.length,r=0,n=0,o;for(;n<t;)r++,o=e.charCodeAt(n++),o>=55296&&o<=56319&&n<t&&(o=e.charCodeAt(n),(o&64512)===56320&&n++);return r}Yp.default=uy;uy.code='require("ajv/dist/runtime/ucs2length").default'});var dy=I(Xp=>{"use strict";Object.defineProperty(Xp,"__esModule",{value:!0});var Ur=H(),Fz=ne(),qz=ly(),Vz={message({keyword:e,schemaCode:t}){let r=e==="maxLength"?"more":"fewer";return(0,Ur.str)`must NOT have ${r} than ${t} characters`},params:({schemaCode:e})=>(0,Ur._)`{limit: ${e}}`},Wz={keyword:["maxLength","minLength"],type:"string",schemaType:"number",$data:!0,error:Vz,code(e){let{keyword:t,data:r,schemaCode:n,it:o}=e,i=t==="maxLength"?Ur.operators.GT:Ur.operators.LT,a=o.opts.unicode===!1?(0,Ur._)`${r}.length`:(0,Ur._)`${(0,Fz.useFunc)(e.gen,qz.default)}(${r})`;e.fail$data((0,Ur._)`${a} ${i} ${n}`)}};Xp.default=Wz});var py=I(Qp=>{"use strict";Object.defineProperty(Qp,"__esModule",{value:!0});var Jz=ut(),Os=H(),Hz={message:({schemaCode:e})=>(0,Os.str)`must match pattern "${e}"`,params:({schemaCode:e})=>(0,Os._)`{pattern: ${e}}`},Gz={keyword:"pattern",type:"string",schemaType:"string",$data:!0,error:Hz,code(e){let{data:t,$data:r,schema:n,schemaCode:o,it:i}=e,a=i.opts.unicodeRegExp?"u":"",s=r?(0,Os._)`(new RegExp(${o}, ${a}))`:(0,Jz.usePattern)(e,n);e.fail$data((0,Os._)`!${s}.test(${t})`)}};Qp.default=Gz});var fy=I(ef=>{"use strict";Object.defineProperty(ef,"__esModule",{value:!0});var yi=H(),Kz={message({keyword:e,schemaCode:t}){let r=e==="maxProperties"?"more":"fewer";return(0,yi.str)`must NOT have ${r} than ${t} properties`},params:({schemaCode:e})=>(0,yi._)`{limit: ${e}}`},Bz={keyword:["maxProperties","minProperties"],type:"object",schemaType:"number",$data:!0,error:Kz,code(e){let{keyword:t,data:r,schemaCode:n}=e,o=t==="maxProperties"?yi.operators.GT:yi.operators.LT;e.fail$data((0,yi._)`Object.keys(${r}).length ${o} ${n}`)}};ef.default=Bz});var my=I(tf=>{"use strict";Object.defineProperty(tf,"__esModule",{value:!0});var $i=ut(),bi=H(),Yz=ne(),Xz={message:({params:{missingProperty:e}})=>(0,bi.str)`must have required property '${e}'`,params:({params:{missingProperty:e}})=>(0,bi._)`{missingProperty: ${e}}`},Qz={keyword:"required",type:"object",schemaType:"array",$data:!0,error:Xz,code(e){let{gen:t,schema:r,schemaCode:n,data:o,$data:i,it:a}=e,{opts:s}=a;if(!i&&r.length===0)return;let c=r.length>=s.loopRequired;if(a.allErrors?u():l(),s.strictRequired){let f=e.parentSchema.properties,{definedProperties:h}=e.it;for(let g of r)if(f?.[g]===void 0&&!h.has(g)){let y=a.schemaEnv.baseId+a.errSchemaPath,S=`required property "${g}" is not defined at "${y}" (strictRequired)`;(0,Yz.checkStrictMode)(a,S,a.opts.strictRequired)}}function u(){if(c||i)e.block$data(bi.nil,d);else for(let f of r)(0,$i.checkReportMissingProp)(e,f)}function l(){let f=t.let("missing");if(c||i){let h=t.let("valid",!0);e.block$data(h,()=>p(f,h)),e.ok(h)}else t.if((0,$i.checkMissingProp)(e,r,f)),(0,$i.reportMissingProp)(e,f),t.else()}function d(){t.forOf("prop",n,f=>{e.setParams({missingProperty:f}),t.if((0,$i.noPropertyInData)(t,o,f,s.ownProperties),()=>e.error())})}function p(f,h){e.setParams({missingProperty:f}),t.forOf(f,n,()=>{t.assign(h,(0,$i.propertyInData)(t,o,f,s.ownProperties)),t.if((0,bi.not)(h),()=>{e.error(),t.break()})},bi.nil)}}};tf.default=Qz});var hy=I(rf=>{"use strict";Object.defineProperty(rf,"__esModule",{value:!0});var xi=H(),eP={message({keyword:e,schemaCode:t}){let r=e==="maxItems"?"more":"fewer";return(0,xi.str)`must NOT have ${r} than ${t} items`},params:({schemaCode:e})=>(0,xi._)`{limit: ${e}}`},tP={keyword:["maxItems","minItems"],type:"array",schemaType:"number",$data:!0,error:eP,code(e){let{keyword:t,data:r,schemaCode:n}=e,o=t==="maxItems"?xi.operators.GT:xi.operators.LT;e.fail$data((0,xi._)`${r}.length ${o} ${n}`)}};rf.default=tP});var js=I(nf=>{"use strict";Object.defineProperty(nf,"__esModule",{value:!0});var gy=Ip();gy.code='require("ajv/dist/runtime/equal").default';nf.default=gy});var vy=I(af=>{"use strict";Object.defineProperty(af,"__esModule",{value:!0});var of=ci(),Ie=H(),rP=ne(),nP=js(),oP={message:({params:{i:e,j:t}})=>(0,Ie.str)`must NOT have duplicate items (items ## ${t} and ${e} are identical)`,params:({params:{i:e,j:t}})=>(0,Ie._)`{i: ${e}, j: ${t}}`},iP={keyword:"uniqueItems",type:"array",schemaType:"boolean",$data:!0,error:oP,code(e){let{gen:t,data:r,$data:n,schema:o,parentSchema:i,schemaCode:a,it:s}=e;if(!n&&!o)return;let c=t.let("valid"),u=i.items?(0,of.getSchemaTypes)(i.items):[];e.block$data(c,l,(0,Ie._)`${a} === false`),e.ok(c);function l(){let h=t.let("i",(0,Ie._)`${r}.length`),g=t.let("j");e.setParams({i:h,j:g}),t.assign(c,!0),t.if((0,Ie._)`${h} > 1`,()=>(d()?p:f)(h,g))}function d(){return u.length>0&&!u.some(h=>h==="object"||h==="array")}function p(h,g){let y=t.name("item"),S=(0,of.checkDataTypes)(u,y,s.opts.strictNumbers,of.DataType.Wrong),x=t.const("indices",(0,Ie._)`{}`);t.for((0,Ie._)`;${h}--;`,()=>{t.let(y,(0,Ie._)`${r}[${h}]`),t.if(S,(0,Ie._)`continue`),u.length>1&&t.if((0,Ie._)`typeof ${y} == "string"`,(0,Ie._)`${y} += "_"`),t.if((0,Ie._)`typeof ${x}[${y}] == "number"`,()=>{t.assign(g,(0,Ie._)`${x}[${y}]`),e.error(),t.assign(c,!1).break()}).code((0,Ie._)`${x}[${y}] = ${h}`)})}function f(h,g){let y=(0,rP.useFunc)(t,nP.default),S=t.name("outer");t.label(S).for((0,Ie._)`;${h}--;`,()=>t.for((0,Ie._)`${g} = ${h}; ${g}--;`,()=>t.if((0,Ie._)`${y}(${r}[${h}], ${r}[${g}])`,()=>{e.error(),t.assign(c,!1).break(S)})))}}};af.default=iP});var _y=I(cf=>{"use strict";Object.defineProperty(cf,"__esModule",{value:!0});var sf=H(),aP=ne(),sP=js(),cP={message:"must be equal to constant",params:({schemaCode:e})=>(0,sf._)`{allowedValue: ${e}}`},uP={keyword:"const",$data:!0,error:cP,code(e){let{gen:t,data:r,$data:n,schemaCode:o,schema:i}=e;n||i&&typeof i=="object"?e.fail$data((0,sf._)`!${(0,aP.useFunc)(t,sP.default)}(${r}, ${o})`):e.fail((0,sf._)`${i} !== ${r}`)}};cf.default=uP});var yy=I(uf=>{"use strict";Object.defineProperty(uf,"__esModule",{value:!0});var Si=H(),lP=ne(),dP=js(),pP={message:"must be equal to one of the allowed values",params:({schemaCode:e})=>(0,Si._)`{allowedValues: ${e}}`},fP={keyword:"enum",schemaType:"array",$data:!0,error:pP,code(e){let{gen:t,data:r,$data:n,schema:o,schemaCode:i,it:a}=e;if(!n&&o.length===0)throw new Error("enum must have non-empty array");let s=o.length>=a.opts.loopEnum,c,u=()=>c??(c=(0,lP.useFunc)(t,dP.default)),l;if(s||n)l=t.let("valid"),e.block$data(l,d);else{if(!Array.isArray(o))throw new Error("ajv implementation error");let f=t.const("vSchema",i);l=(0,Si.or)(...o.map((h,g)=>p(f,g)))}e.pass(l);function d(){t.assign(l,!1),t.forOf("v",i,f=>t.if((0,Si._)`${u()}(${r}, ${f})`,()=>t.assign(l,!0).break()))}function p(f,h){let g=o[h];return typeof g=="object"&&g!==null?(0,Si._)`${u()}(${r}, ${f}[${h}])`:(0,Si._)`${r} === ${g}`}}};uf.default=fP});var $y=I(lf=>{"use strict";Object.defineProperty(lf,"__esModule",{value:!0});var mP=sy(),hP=cy(),gP=dy(),vP=py(),_P=fy(),yP=my(),$P=hy(),bP=vy(),xP=_y(),SP=yy(),kP=[mP.default,hP.default,gP.default,vP.default,_P.default,yP.default,$P.default,bP.default,{keyword:"type",schemaType:["string","array"]},{keyword:"nullable",schemaType:"boolean"},xP.default,SP.default];lf.default=kP});var pf=I(ki=>{"use strict";Object.defineProperty(ki,"__esModule",{value:!0});ki.validateAdditionalItems=void 0;var Zr=H(),df=ne(),wP={message:({params:{len:e}})=>(0,Zr.str)`must NOT have more than ${e} items`,params:({params:{len:e}})=>(0,Zr._)`{limit: ${e}}`},EP={keyword:"additionalItems",type:"array",schemaType:["boolean","object"],before:"uniqueItems",error:wP,code(e){let{parentSchema:t,it:r}=e,{items:n}=t;if(!Array.isArray(n)){(0,df.checkStrictMode)(r,'"additionalItems" is ignored when "items" is not an array of schemas');return}by(e,n)}};function by(e,t){let{gen:r,schema:n,data:o,keyword:i,it:a}=e;a.items=!0;let s=r.const("len",(0,Zr._)`${o}.length`);if(n===!1)e.setParams({len:t.length}),e.pass((0,Zr._)`${s} <= ${t.length}`);else if(typeof n=="object"&&!(0,df.alwaysValidSchema)(a,n)){let u=r.var("valid",(0,Zr._)`${s} <= ${t.length}`);r.if((0,Zr.not)(u),()=>c(u)),e.ok(u)}function c(u){r.forRange("i",t.length,s,l=>{e.subschema({keyword:i,dataProp:l,dataPropType:df.Type.Num},u),a.allErrors||r.if((0,Zr.not)(u),()=>r.break())})}}ki.validateAdditionalItems=by;ki.default=EP});var ff=I(wi=>{"use strict";Object.defineProperty(wi,"__esModule",{value:!0});wi.validateTuple=void 0;var xy=H(),Ds=ne(),IP=ut(),zP={keyword:"items",type:"array",schemaType:["object","array","boolean"],before:"uniqueItems",code(e){let{schema:t,it:r}=e;if(Array.isArray(t))return Sy(e,"additionalItems",t);r.items=!0,!(0,Ds.alwaysValidSchema)(r,t)&&e.ok((0,IP.validateArray)(e))}};function Sy(e,t,r=e.schema){let{gen:n,parentSchema:o,data:i,keyword:a,it:s}=e;l(o),s.opts.unevaluated&&r.length&&s.items!==!0&&(s.items=Ds.mergeEvaluated.items(n,r.length,s.items));let c=n.name("valid"),u=n.const("len",(0,xy._)`${i}.length`);r.forEach((d,p)=>{(0,Ds.alwaysValidSchema)(s,d)||(n.if((0,xy._)`${u} > ${p}`,()=>e.subschema({keyword:a,schemaProp:p,dataProp:p},c)),e.ok(c))});function l(d){let{opts:p,errSchemaPath:f}=s,h=r.length,g=h===d.minItems&&(h===d.maxItems||d[t]===!1);if(p.strictTuples&&!g){let y=`"${a}" is ${h}-tuple, but minItems or maxItems/${t} are not specified or different at path "${f}"`;(0,Ds.checkStrictMode)(s,y,p.strictTuples)}}}wi.validateTuple=Sy;wi.default=zP});var ky=I(mf=>{"use strict";Object.defineProperty(mf,"__esModule",{value:!0});var PP=ff(),TP={keyword:"prefixItems",type:"array",schemaType:["array"],before:"uniqueItems",code:e=>(0,PP.validateTuple)(e,"items")};mf.default=TP});var Ey=I(hf=>{"use strict";Object.defineProperty(hf,"__esModule",{value:!0});var wy=H(),OP=ne(),jP=ut(),DP=pf(),NP={message:({params:{len:e}})=>(0,wy.str)`must NOT have more than ${e} items`,params:({params:{len:e}})=>(0,wy._)`{limit: ${e}}`},RP={keyword:"items",type:"array",schemaType:["object","boolean"],before:"uniqueItems",error:NP,code(e){let{schema:t,parentSchema:r,it:n}=e,{prefixItems:o}=r;n.items=!0,!(0,OP.alwaysValidSchema)(n,t)&&(o?(0,DP.validateAdditionalItems)(e,o):e.ok((0,jP.validateArray)(e)))}};hf.default=RP});var Iy=I(gf=>{"use strict";Object.defineProperty(gf,"__esModule",{value:!0});var dt=H(),Ns=ne(),MP={message:({params:{min:e,max:t}})=>t===void 0?(0,dt.str)`must contain at least ${e} valid item(s)`:(0,dt.str)`must contain at least ${e} and no more than ${t} valid item(s)`,params:({params:{min:e,max:t}})=>t===void 0?(0,dt._)`{minContains: ${e}}`:(0,dt._)`{minContains: ${e}, maxContains: ${t}}`},AP={keyword:"contains",type:"array",schemaType:["object","boolean"],before:"uniqueItems",trackErrors:!0,error:MP,code(e){let{gen:t,schema:r,parentSchema:n,data:o,it:i}=e,a,s,{minContains:c,maxContains:u}=n;i.opts.next?(a=c===void 0?1:c,s=u):a=1;let l=t.const("len",(0,dt._)`${o}.length`);if(e.setParams({min:a,max:s}),s===void 0&&a===0){(0,Ns.checkStrictMode)(i,'"minContains" == 0 without "maxContains": "contains" keyword ignored');return}if(s!==void 0&&a>s){(0,Ns.checkStrictMode)(i,'"minContains" > "maxContains" is always invalid'),e.fail();return}if((0,Ns.alwaysValidSchema)(i,r)){let g=(0,dt._)`${l} >= ${a}`;s!==void 0&&(g=(0,dt._)`${g} && ${l} <= ${s}`),e.pass(g);return}i.items=!0;let d=t.name("valid");s===void 0&&a===1?f(d,()=>t.if(d,()=>t.break())):a===0?(t.let(d,!0),s!==void 0&&t.if((0,dt._)`${o}.length > 0`,p)):(t.let(d,!1),p()),e.result(d,()=>e.reset());function p(){let g=t.name("_valid"),y=t.let("count",0);f(g,()=>t.if(g,()=>h(y)))}function f(g,y){t.forRange("i",0,l,S=>{e.subschema({keyword:"contains",dataProp:S,dataPropType:Ns.Type.Num,compositeRule:!0},g),y()})}function h(g){t.code((0,dt._)`${g}++`),s===void 0?t.if((0,dt._)`${g} >= ${a}`,()=>t.assign(d,!0).break()):(t.if((0,dt._)`${g} > ${s}`,()=>t.assign(d,!1).break()),a===1?t.assign(d,!0):t.if((0,dt._)`${g} >= ${a}`,()=>t.assign(d,!0)))}}};gf.default=AP});var Ty=I(Ot=>{"use strict";Object.defineProperty(Ot,"__esModule",{value:!0});Ot.validateSchemaDeps=Ot.validatePropertyDeps=Ot.error=void 0;var vf=H(),CP=ne(),Ei=ut();Ot.error={message:({params:{property:e,depsCount:t,deps:r}})=>{let n=t===1?"property":"properties";return(0,vf.str)`must have ${n} ${r} when property ${e} is present`},params:({params:{property:e,depsCount:t,deps:r,missingProperty:n}})=>(0,vf._)`{property: ${e},
|
|
missingProperty: ${n},
|
|
depsCount: ${t},
|
|
deps: ${r}}`};var UP={keyword:"dependencies",type:"object",schemaType:"object",error:Ot.error,code(e){let[t,r]=ZP(e);zy(e,t),Py(e,r)}};function ZP({schema:e}){let t={},r={};for(let n in e){if(n==="__proto__")continue;let o=Array.isArray(e[n])?t:r;o[n]=e[n]}return[t,r]}function zy(e,t=e.schema){let{gen:r,data:n,it:o}=e;if(Object.keys(t).length===0)return;let i=r.let("missing");for(let a in t){let s=t[a];if(s.length===0)continue;let c=(0,Ei.propertyInData)(r,n,a,o.opts.ownProperties);e.setParams({property:a,depsCount:s.length,deps:s.join(", ")}),o.allErrors?r.if(c,()=>{for(let u of s)(0,Ei.checkReportMissingProp)(e,u)}):(r.if((0,vf._)`${c} && (${(0,Ei.checkMissingProp)(e,s,i)})`),(0,Ei.reportMissingProp)(e,i),r.else())}}Ot.validatePropertyDeps=zy;function Py(e,t=e.schema){let{gen:r,data:n,keyword:o,it:i}=e,a=r.name("valid");for(let s in t)(0,CP.alwaysValidSchema)(i,t[s])||(r.if((0,Ei.propertyInData)(r,n,s,i.opts.ownProperties),()=>{let c=e.subschema({keyword:o,schemaProp:s},a);e.mergeValidEvaluated(c,a)},()=>r.var(a,!0)),e.ok(a))}Ot.validateSchemaDeps=Py;Ot.default=UP});var jy=I(_f=>{"use strict";Object.defineProperty(_f,"__esModule",{value:!0});var Oy=H(),LP=ne(),FP={message:"property name must be valid",params:({params:e})=>(0,Oy._)`{propertyName: ${e.propertyName}}`},qP={keyword:"propertyNames",type:"object",schemaType:["object","boolean"],error:FP,code(e){let{gen:t,schema:r,data:n,it:o}=e;if((0,LP.alwaysValidSchema)(o,r))return;let i=t.name("valid");t.forIn("key",n,a=>{e.setParams({propertyName:a}),e.subschema({keyword:"propertyNames",data:a,dataTypes:["string"],propertyName:a,compositeRule:!0},i),t.if((0,Oy.not)(i),()=>{e.error(!0),o.allErrors||t.break()})}),e.ok(i)}};_f.default=qP});var $f=I(yf=>{"use strict";Object.defineProperty(yf,"__esModule",{value:!0});var Rs=ut(),bt=H(),VP=Gt(),Ms=ne(),WP={message:"must NOT have additional properties",params:({params:e})=>(0,bt._)`{additionalProperty: ${e.additionalProperty}}`},JP={keyword:"additionalProperties",type:["object"],schemaType:["boolean","object"],allowUndefined:!0,trackErrors:!0,error:WP,code(e){let{gen:t,schema:r,parentSchema:n,data:o,errsCount:i,it:a}=e;if(!i)throw new Error("ajv implementation error");let{allErrors:s,opts:c}=a;if(a.props=!0,c.removeAdditional!=="all"&&(0,Ms.alwaysValidSchema)(a,r))return;let u=(0,Rs.allSchemaProperties)(n.properties),l=(0,Rs.allSchemaProperties)(n.patternProperties);d(),e.ok((0,bt._)`${i} === ${VP.default.errors}`);function d(){t.forIn("key",o,y=>{!u.length&&!l.length?h(y):t.if(p(y),()=>h(y))})}function p(y){let S;if(u.length>8){let x=(0,Ms.schemaRefOrVal)(a,n.properties,"properties");S=(0,Rs.isOwnProperty)(t,x,y)}else u.length?S=(0,bt.or)(...u.map(x=>(0,bt._)`${y} === ${x}`)):S=bt.nil;return l.length&&(S=(0,bt.or)(S,...l.map(x=>(0,bt._)`${(0,Rs.usePattern)(e,x)}.test(${y})`))),(0,bt.not)(S)}function f(y){t.code((0,bt._)`delete ${o}[${y}]`)}function h(y){if(c.removeAdditional==="all"||c.removeAdditional&&r===!1){f(y);return}if(r===!1){e.setParams({additionalProperty:y}),e.error(),s||t.break();return}if(typeof r=="object"&&!(0,Ms.alwaysValidSchema)(a,r)){let S=t.name("valid");c.removeAdditional==="failing"?(g(y,S,!1),t.if((0,bt.not)(S),()=>{e.reset(),f(y)})):(g(y,S),s||t.if((0,bt.not)(S),()=>t.break()))}}function g(y,S,x){let b={keyword:"additionalProperties",dataProp:y,dataPropType:Ms.Type.Str};x===!1&&Object.assign(b,{compositeRule:!0,createErrors:!1,allErrors:!1}),e.subschema(b,S)}}};yf.default=JP});var Ry=I(xf=>{"use strict";Object.defineProperty(xf,"__esModule",{value:!0});var HP=pi(),Dy=ut(),bf=ne(),Ny=$f(),GP={keyword:"properties",type:"object",schemaType:"object",code(e){let{gen:t,schema:r,parentSchema:n,data:o,it:i}=e;i.opts.removeAdditional==="all"&&n.additionalProperties===void 0&&Ny.default.code(new HP.KeywordCxt(i,Ny.default,"additionalProperties"));let a=(0,Dy.allSchemaProperties)(r);for(let d of a)i.definedProperties.add(d);i.opts.unevaluated&&a.length&&i.props!==!0&&(i.props=bf.mergeEvaluated.props(t,(0,bf.toHash)(a),i.props));let s=a.filter(d=>!(0,bf.alwaysValidSchema)(i,r[d]));if(s.length===0)return;let c=t.name("valid");for(let d of s)u(d)?l(d):(t.if((0,Dy.propertyInData)(t,o,d,i.opts.ownProperties)),l(d),i.allErrors||t.else().var(c,!0),t.endIf()),e.it.definedProperties.add(d),e.ok(c);function u(d){return i.opts.useDefaults&&!i.compositeRule&&r[d].default!==void 0}function l(d){e.subschema({keyword:"properties",schemaProp:d,dataProp:d},c)}}};xf.default=GP});var Uy=I(Sf=>{"use strict";Object.defineProperty(Sf,"__esModule",{value:!0});var My=ut(),As=H(),Ay=ne(),Cy=ne(),KP={keyword:"patternProperties",type:"object",schemaType:"object",code(e){let{gen:t,schema:r,data:n,parentSchema:o,it:i}=e,{opts:a}=i,s=(0,My.allSchemaProperties)(r),c=s.filter(g=>(0,Ay.alwaysValidSchema)(i,r[g]));if(s.length===0||c.length===s.length&&(!i.opts.unevaluated||i.props===!0))return;let u=a.strictSchema&&!a.allowMatchingProperties&&o.properties,l=t.name("valid");i.props!==!0&&!(i.props instanceof As.Name)&&(i.props=(0,Cy.evaluatedPropsToName)(t,i.props));let{props:d}=i;p();function p(){for(let g of s)u&&f(g),i.allErrors?h(g):(t.var(l,!0),h(g),t.if(l))}function f(g){for(let y in u)new RegExp(g).test(y)&&(0,Ay.checkStrictMode)(i,`property ${y} matches pattern ${g} (use allowMatchingProperties)`)}function h(g){t.forIn("key",n,y=>{t.if((0,As._)`${(0,My.usePattern)(e,g)}.test(${y})`,()=>{let S=c.includes(g);S||e.subschema({keyword:"patternProperties",schemaProp:g,dataProp:y,dataPropType:Cy.Type.Str},l),i.opts.unevaluated&&d!==!0?t.assign((0,As._)`${d}[${y}]`,!0):!S&&!i.allErrors&&t.if((0,As.not)(l),()=>t.break())})})}}};Sf.default=KP});var Zy=I(kf=>{"use strict";Object.defineProperty(kf,"__esModule",{value:!0});var BP=ne(),YP={keyword:"not",schemaType:["object","boolean"],trackErrors:!0,code(e){let{gen:t,schema:r,it:n}=e;if((0,BP.alwaysValidSchema)(n,r)){e.fail();return}let o=t.name("valid");e.subschema({keyword:"not",compositeRule:!0,createErrors:!1,allErrors:!1},o),e.failResult(o,()=>e.reset(),()=>e.error())},error:{message:"must NOT be valid"}};kf.default=YP});var Ly=I(wf=>{"use strict";Object.defineProperty(wf,"__esModule",{value:!0});var XP=ut(),QP={keyword:"anyOf",schemaType:"array",trackErrors:!0,code:XP.validateUnion,error:{message:"must match a schema in anyOf"}};wf.default=QP});var Fy=I(Ef=>{"use strict";Object.defineProperty(Ef,"__esModule",{value:!0});var Cs=H(),eT=ne(),tT={message:"must match exactly one schema in oneOf",params:({params:e})=>(0,Cs._)`{passingSchemas: ${e.passing}}`},rT={keyword:"oneOf",schemaType:"array",trackErrors:!0,error:tT,code(e){let{gen:t,schema:r,parentSchema:n,it:o}=e;if(!Array.isArray(r))throw new Error("ajv implementation error");if(o.opts.discriminator&&n.discriminator)return;let i=r,a=t.let("valid",!1),s=t.let("passing",null),c=t.name("_valid");e.setParams({passing:s}),t.block(u),e.result(a,()=>e.reset(),()=>e.error(!0));function u(){i.forEach((l,d)=>{let p;(0,eT.alwaysValidSchema)(o,l)?t.var(c,!0):p=e.subschema({keyword:"oneOf",schemaProp:d,compositeRule:!0},c),d>0&&t.if((0,Cs._)`${c} && ${a}`).assign(a,!1).assign(s,(0,Cs._)`[${s}, ${d}]`).else(),t.if(c,()=>{t.assign(a,!0),t.assign(s,d),p&&e.mergeEvaluated(p,Cs.Name)})})}}};Ef.default=rT});var qy=I(If=>{"use strict";Object.defineProperty(If,"__esModule",{value:!0});var nT=ne(),oT={keyword:"allOf",schemaType:"array",code(e){let{gen:t,schema:r,it:n}=e;if(!Array.isArray(r))throw new Error("ajv implementation error");let o=t.name("valid");r.forEach((i,a)=>{if((0,nT.alwaysValidSchema)(n,i))return;let s=e.subschema({keyword:"allOf",schemaProp:a},o);e.ok(o),e.mergeEvaluated(s)})}};If.default=oT});var Jy=I(zf=>{"use strict";Object.defineProperty(zf,"__esModule",{value:!0});var Us=H(),Wy=ne(),iT={message:({params:e})=>(0,Us.str)`must match "${e.ifClause}" schema`,params:({params:e})=>(0,Us._)`{failingKeyword: ${e.ifClause}}`},aT={keyword:"if",schemaType:["object","boolean"],trackErrors:!0,error:iT,code(e){let{gen:t,parentSchema:r,it:n}=e;r.then===void 0&&r.else===void 0&&(0,Wy.checkStrictMode)(n,'"if" without "then" and "else" is ignored');let o=Vy(n,"then"),i=Vy(n,"else");if(!o&&!i)return;let a=t.let("valid",!0),s=t.name("_valid");if(c(),e.reset(),o&&i){let l=t.let("ifClause");e.setParams({ifClause:l}),t.if(s,u("then",l),u("else",l))}else o?t.if(s,u("then")):t.if((0,Us.not)(s),u("else"));e.pass(a,()=>e.error(!0));function c(){let l=e.subschema({keyword:"if",compositeRule:!0,createErrors:!1,allErrors:!1},s);e.mergeEvaluated(l)}function u(l,d){return()=>{let p=e.subschema({keyword:l},s);t.assign(a,s),e.mergeValidEvaluated(p,a),d?t.assign(d,(0,Us._)`${l}`):e.setParams({ifClause:l})}}}};function Vy(e,t){let r=e.schema[t];return r!==void 0&&!(0,Wy.alwaysValidSchema)(e,r)}zf.default=aT});var Hy=I(Pf=>{"use strict";Object.defineProperty(Pf,"__esModule",{value:!0});var sT=ne(),cT={keyword:["then","else"],schemaType:["object","boolean"],code({keyword:e,parentSchema:t,it:r}){t.if===void 0&&(0,sT.checkStrictMode)(r,`"${e}" without "if" is ignored`)}};Pf.default=cT});var Gy=I(Tf=>{"use strict";Object.defineProperty(Tf,"__esModule",{value:!0});var uT=pf(),lT=ky(),dT=ff(),pT=Ey(),fT=Iy(),mT=Ty(),hT=jy(),gT=$f(),vT=Ry(),_T=Uy(),yT=Zy(),$T=Ly(),bT=Fy(),xT=qy(),ST=Jy(),kT=Hy();function wT(e=!1){let t=[yT.default,$T.default,bT.default,xT.default,ST.default,kT.default,hT.default,gT.default,mT.default,vT.default,_T.default];return e?t.push(lT.default,pT.default):t.push(uT.default,dT.default),t.push(fT.default),t}Tf.default=wT});var Ky=I(Of=>{"use strict";Object.defineProperty(Of,"__esModule",{value:!0});var ve=H(),ET={message:({schemaCode:e})=>(0,ve.str)`must match format "${e}"`,params:({schemaCode:e})=>(0,ve._)`{format: ${e}}`},IT={keyword:"format",type:["number","string"],schemaType:"string",$data:!0,error:ET,code(e,t){let{gen:r,data:n,$data:o,schema:i,schemaCode:a,it:s}=e,{opts:c,errSchemaPath:u,schemaEnv:l,self:d}=s;if(!c.validateFormats)return;o?p():f();function p(){let h=r.scopeValue("formats",{ref:d.formats,code:c.code.formats}),g=r.const("fDef",(0,ve._)`${h}[${a}]`),y=r.let("fType"),S=r.let("format");r.if((0,ve._)`typeof ${g} == "object" && !(${g} instanceof RegExp)`,()=>r.assign(y,(0,ve._)`${g}.type || "string"`).assign(S,(0,ve._)`${g}.validate`),()=>r.assign(y,(0,ve._)`"string"`).assign(S,g)),e.fail$data((0,ve.or)(x(),b()));function x(){return c.strictSchema===!1?ve.nil:(0,ve._)`${a} && !${S}`}function b(){let N=l.$async?(0,ve._)`(${g}.async ? await ${S}(${n}) : ${S}(${n}))`:(0,ve._)`${S}(${n})`,T=(0,ve._)`(typeof ${S} == "function" ? ${N} : ${S}.test(${n}))`;return(0,ve._)`${S} && ${S} !== true && ${y} === ${t} && !${T}`}}function f(){let h=d.formats[i];if(!h){x();return}if(h===!0)return;let[g,y,S]=b(h);g===t&&e.pass(N());function x(){if(c.strictSchema===!1){d.logger.warn(T());return}throw new Error(T());function T(){return`unknown format "${i}" ignored in schema at path "${u}"`}}function b(T){let Ve=T instanceof RegExp?(0,ve.regexpCode)(T):c.code.formats?(0,ve._)`${c.code.formats}${(0,ve.getProperty)(i)}`:void 0,We=r.scopeValue("formats",{key:i,ref:T,code:Ve});return typeof T=="object"&&!(T instanceof RegExp)?[T.type||"string",T.validate,(0,ve._)`${We}.validate`]:["string",T,We]}function N(){if(typeof h=="object"&&!(h instanceof RegExp)&&h.async){if(!l.$async)throw new Error("async format in sync schema");return(0,ve._)`await ${S}(${n})`}return typeof y=="function"?(0,ve._)`${S}(${n})`:(0,ve._)`${S}.test(${n})`}}}};Of.default=IT});var By=I(jf=>{"use strict";Object.defineProperty(jf,"__esModule",{value:!0});var zT=Ky(),PT=[zT.default];jf.default=PT});var Yy=I(zn=>{"use strict";Object.defineProperty(zn,"__esModule",{value:!0});zn.contentVocabulary=zn.metadataVocabulary=void 0;zn.metadataVocabulary=["title","description","default","deprecated","readOnly","writeOnly","examples"];zn.contentVocabulary=["contentMediaType","contentEncoding","contentSchema"]});var Qy=I(Df=>{"use strict";Object.defineProperty(Df,"__esModule",{value:!0});var TT=ay(),OT=$y(),jT=Gy(),DT=By(),Xy=Yy(),NT=[TT.default,OT.default,(0,jT.default)(),DT.default,Xy.metadataVocabulary,Xy.contentVocabulary];Df.default=NT});var t$=I(Zs=>{"use strict";Object.defineProperty(Zs,"__esModule",{value:!0});Zs.DiscrError=void 0;var e$;(function(e){e.Tag="tag",e.Mapping="mapping"})(e$||(Zs.DiscrError=e$={}))});var n$=I(Rf=>{"use strict";Object.defineProperty(Rf,"__esModule",{value:!0});var Pn=H(),Nf=t$(),r$=bs(),RT=fi(),MT=ne(),AT={message:({params:{discrError:e,tagName:t}})=>e===Nf.DiscrError.Tag?`tag "${t}" must be string`:`value of tag "${t}" must be in oneOf`,params:({params:{discrError:e,tag:t,tagName:r}})=>(0,Pn._)`{error: ${e}, tag: ${r}, tagValue: ${t}}`},CT={keyword:"discriminator",type:"object",schemaType:"object",error:AT,code(e){let{gen:t,data:r,schema:n,parentSchema:o,it:i}=e,{oneOf:a}=o;if(!i.opts.discriminator)throw new Error("discriminator: requires discriminator option");let s=n.propertyName;if(typeof s!="string")throw new Error("discriminator: requires propertyName");if(n.mapping)throw new Error("discriminator: mapping is not supported");if(!a)throw new Error("discriminator: requires oneOf keyword");let c=t.let("valid",!1),u=t.const("tag",(0,Pn._)`${r}${(0,Pn.getProperty)(s)}`);t.if((0,Pn._)`typeof ${u} == "string"`,()=>l(),()=>e.error(!1,{discrError:Nf.DiscrError.Tag,tag:u,tagName:s})),e.ok(c);function l(){let f=p();t.if(!1);for(let h in f)t.elseIf((0,Pn._)`${u} === ${h}`),t.assign(c,d(f[h]));t.else(),e.error(!1,{discrError:Nf.DiscrError.Mapping,tag:u,tagName:s}),t.endIf()}function d(f){let h=t.name("valid"),g=e.subschema({keyword:"oneOf",schemaProp:f},h);return e.mergeEvaluated(g,Pn.Name),h}function p(){var f;let h={},g=S(o),y=!0;for(let N=0;N<a.length;N++){let T=a[N];if(T?.$ref&&!(0,MT.schemaHasRulesButRef)(T,i.self.RULES)){let We=T.$ref;if(T=r$.resolveRef.call(i.self,i.schemaEnv.root,i.baseId,We),T instanceof r$.SchemaEnv&&(T=T.schema),T===void 0)throw new RT.default(i.opts.uriResolver,i.baseId,We)}let Ve=(f=T?.properties)===null||f===void 0?void 0:f[s];if(typeof Ve!="object")throw new Error(`discriminator: oneOf subschemas (or referenced schemas) must have "properties/${s}"`);y=y&&(g||S(T)),x(Ve,N)}if(!y)throw new Error(`discriminator: "${s}" must be required`);return h;function S({required:N}){return Array.isArray(N)&&N.includes(s)}function x(N,T){if(N.const)b(N.const,T);else if(N.enum)for(let Ve of N.enum)b(Ve,T);else throw new Error(`discriminator: "properties/${s}" must have "const" or "enum"`)}function b(N,T){if(typeof N!="string"||N in h)throw new Error(`discriminator: "${s}" values must be unique strings`);h[N]=T}}}};Rf.default=CT});var o$=I((YZ,UT)=>{UT.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 Af=I((ge,Mf)=>{"use strict";Object.defineProperty(ge,"__esModule",{value:!0});ge.MissingRefError=ge.ValidationError=ge.CodeGen=ge.Name=ge.nil=ge.stringify=ge.str=ge._=ge.KeywordCxt=ge.Ajv=void 0;var ZT=ey(),LT=Qy(),FT=n$(),i$=o$(),qT=["/properties"],Ls="http://json-schema.org/draft-07/schema",Tn=class extends ZT.default{_addVocabularies(){super._addVocabularies(),LT.default.forEach(t=>this.addVocabulary(t)),this.opts.discriminator&&this.addKeyword(FT.default)}_addDefaultMetaSchema(){if(super._addDefaultMetaSchema(),!this.opts.meta)return;let t=this.opts.$data?this.$dataMetaSchema(i$,qT):i$;this.addMetaSchema(t,Ls,!1),this.refs["http://json-schema.org/schema"]=Ls}defaultMeta(){return this.opts.defaultMeta=super.defaultMeta()||(this.getSchema(Ls)?Ls:void 0)}};ge.Ajv=Tn;Mf.exports=ge=Tn;Mf.exports.Ajv=Tn;Object.defineProperty(ge,"__esModule",{value:!0});ge.default=Tn;var VT=pi();Object.defineProperty(ge,"KeywordCxt",{enumerable:!0,get:function(){return VT.KeywordCxt}});var On=H();Object.defineProperty(ge,"_",{enumerable:!0,get:function(){return On._}});Object.defineProperty(ge,"str",{enumerable:!0,get:function(){return On.str}});Object.defineProperty(ge,"stringify",{enumerable:!0,get:function(){return On.stringify}});Object.defineProperty(ge,"nil",{enumerable:!0,get:function(){return On.nil}});Object.defineProperty(ge,"Name",{enumerable:!0,get:function(){return On.Name}});Object.defineProperty(ge,"CodeGen",{enumerable:!0,get:function(){return On.CodeGen}});var WT=ys();Object.defineProperty(ge,"ValidationError",{enumerable:!0,get:function(){return WT.default}});var JT=fi();Object.defineProperty(ge,"MissingRefError",{enumerable:!0,get:function(){return JT.default}})});var f$=I(Dt=>{"use strict";Object.defineProperty(Dt,"__esModule",{value:!0});Dt.formatNames=Dt.fastFormats=Dt.fullFormats=void 0;function jt(e,t){return{validate:e,compare:t}}Dt.fullFormats={date:jt(u$,Lf),time:jt(Uf(!0),Ff),"date-time":jt(a$(!0),d$),"iso-time":jt(Uf(),l$),"iso-date-time":jt(a$(),p$),duration:/^P(?!$)((\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+S)?)?|(\d+W)?)$/,uri:XT,"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:iO,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:QT,int32:{type:"number",validate:rO},int64:{type:"number",validate:nO},float:{type:"number",validate:c$},double:{type:"number",validate:c$},password:!0,binary:!0};Dt.fastFormats={...Dt.fullFormats,date:jt(/^\d\d\d\d-[0-1]\d-[0-3]\d$/,Lf),time:jt(/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)$/i,Ff),"date-time":jt(/^\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,d$),"iso-time":jt(/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)?$/i,l$),"iso-date-time":jt(/^\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,p$),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};Dt.formatNames=Object.keys(Dt.fullFormats);function HT(e){return e%4===0&&(e%100!==0||e%400===0)}var GT=/^(\d\d\d\d)-(\d\d)-(\d\d)$/,KT=[0,31,28,31,30,31,30,31,31,30,31,30,31];function u$(e){let t=GT.exec(e);if(!t)return!1;let r=+t[1],n=+t[2],o=+t[3];return n>=1&&n<=12&&o>=1&&o<=(n===2&&HT(r)?29:KT[n])}function Lf(e,t){if(e&&t)return e>t?1:e<t?-1:0}var Cf=/^(\d\d):(\d\d):(\d\d(?:\.\d+)?)(z|([+-])(\d\d)(?::?(\d\d))?)?$/i;function Uf(e){return function(r){let n=Cf.exec(r);if(!n)return!1;let o=+n[1],i=+n[2],a=+n[3],s=n[4],c=n[5]==="-"?-1:1,u=+(n[6]||0),l=+(n[7]||0);if(u>23||l>59||e&&!s)return!1;if(o<=23&&i<=59&&a<60)return!0;let d=i-l*c,p=o-u*c-(d<0?1:0);return(p===23||p===-1)&&(d===59||d===-1)&&a<61}}function Ff(e,t){if(!(e&&t))return;let r=new Date("2020-01-01T"+e).valueOf(),n=new Date("2020-01-01T"+t).valueOf();if(r&&n)return r-n}function l$(e,t){if(!(e&&t))return;let r=Cf.exec(e),n=Cf.exec(t);if(r&&n)return e=r[1]+r[2]+r[3],t=n[1]+n[2]+n[3],e>t?1:e<t?-1:0}var Zf=/t|\s/i;function a$(e){let t=Uf(e);return function(n){let o=n.split(Zf);return o.length===2&&u$(o[0])&&t(o[1])}}function d$(e,t){if(!(e&&t))return;let r=new Date(e).valueOf(),n=new Date(t).valueOf();if(r&&n)return r-n}function p$(e,t){if(!(e&&t))return;let[r,n]=e.split(Zf),[o,i]=t.split(Zf),a=Lf(r,o);if(a!==void 0)return a||Ff(n,i)}var BT=/\/|:/,YT=/^(?:[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 XT(e){return BT.test(e)&&YT.test(e)}var s$=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/gm;function QT(e){return s$.lastIndex=0,s$.test(e)}var eO=-(2**31),tO=2**31-1;function rO(e){return Number.isInteger(e)&&e<=tO&&e>=eO}function nO(e){return Number.isInteger(e)}function c$(){return!0}var oO=/[^\\]\\Z/;function iO(e){if(oO.test(e))return!1;try{return new RegExp(e),!0}catch{return!1}}});var m$=I(jn=>{"use strict";Object.defineProperty(jn,"__esModule",{value:!0});jn.formatLimitDefinition=void 0;var aO=Af(),xt=H(),br=xt.operators,Fs={formatMaximum:{okStr:"<=",ok:br.LTE,fail:br.GT},formatMinimum:{okStr:">=",ok:br.GTE,fail:br.LT},formatExclusiveMaximum:{okStr:"<",ok:br.LT,fail:br.GTE},formatExclusiveMinimum:{okStr:">",ok:br.GT,fail:br.LTE}},sO={message:({keyword:e,schemaCode:t})=>(0,xt.str)`should be ${Fs[e].okStr} ${t}`,params:({keyword:e,schemaCode:t})=>(0,xt._)`{comparison: ${Fs[e].okStr}, limit: ${t}}`};jn.formatLimitDefinition={keyword:Object.keys(Fs),type:"string",schemaType:"string",$data:!0,error:sO,code(e){let{gen:t,data:r,schemaCode:n,keyword:o,it:i}=e,{opts:a,self:s}=i;if(!a.validateFormats)return;let c=new aO.KeywordCxt(i,s.RULES.all.format.definition,"format");c.$data?u():l();function u(){let p=t.scopeValue("formats",{ref:s.formats,code:a.code.formats}),f=t.const("fmt",(0,xt._)`${p}[${c.schemaCode}]`);e.fail$data((0,xt.or)((0,xt._)`typeof ${f} != "object"`,(0,xt._)`${f} instanceof RegExp`,(0,xt._)`typeof ${f}.compare != "function"`,d(f)))}function l(){let p=c.schema,f=s.formats[p];if(!f||f===!0)return;if(typeof f!="object"||f instanceof RegExp||typeof f.compare!="function")throw new Error(`"${o}": format "${p}" does not define "compare" function`);let h=t.scopeValue("formats",{key:p,ref:f,code:a.code.formats?(0,xt._)`${a.code.formats}${(0,xt.getProperty)(p)}`:void 0});e.fail$data(d(h))}function d(p){return(0,xt._)`${p}.compare(${r}, ${n}) ${Fs[o].fail} 0`}},dependencies:["format"]};var cO=e=>(e.addKeyword(jn.formatLimitDefinition),e);jn.default=cO});var _$=I((Ii,v$)=>{"use strict";Object.defineProperty(Ii,"__esModule",{value:!0});var Dn=f$(),uO=m$(),qf=H(),h$=new qf.Name("fullFormats"),lO=new qf.Name("fastFormats"),Vf=(e,t={keywords:!0})=>{if(Array.isArray(t))return g$(e,t,Dn.fullFormats,h$),e;let[r,n]=t.mode==="fast"?[Dn.fastFormats,lO]:[Dn.fullFormats,h$],o=t.formats||Dn.formatNames;return g$(e,o,r,n),t.keywords&&(0,uO.default)(e),e};Vf.get=(e,t="full")=>{let n=(t==="fast"?Dn.fastFormats:Dn.fullFormats)[e];if(!n)throw new Error(`Unknown format "${e}"`);return n};function g$(e,t,r,n){var o,i;(o=(i=e.opts.code).formats)!==null&&o!==void 0||(i.formats=(0,qf._)`require("ajv-formats/dist/formats").${n}`);for(let a of t)e.addFormat(a,r[a])}v$.exports=Ii=Vf;Object.defineProperty(Ii,"__esModule",{value:!0});Ii.default=Vf});var Rt=require("fs"),qn=require("path"),ym=require("os"),oc=(i=>(i[i.DEBUG=0]="DEBUG",i[i.INFO=1]="INFO",i[i.WARN=2]="WARN",i[i.ERROR=3]="ERROR",i[i.SILENT=4]="SILENT",i))(oc||{}),_m=(0,qn.join)((0,ym.homedir)(),".claude-mem"),ic=class{level=null;useColor;logFilePath=null;logFileInitialized=!1;constructor(){this.useColor=process.stdout.isTTY??!1}ensureLogFileInitialized(){if(!this.logFileInitialized){this.logFileInitialized=!0;try{let t=(0,qn.join)(_m,"logs");(0,Rt.existsSync)(t)||(0,Rt.mkdirSync)(t,{recursive:!0});let r=new Date().toISOString().split("T")[0];this.logFilePath=(0,qn.join)(t,`claude-mem-${r}.log`)}catch(t){console.error("[LOGGER] Failed to initialize log file:",t),this.logFilePath=null}}}getLevel(){if(this.level===null)try{let t=(0,qn.join)(_m,"settings.json");if((0,Rt.existsSync)(t)){let r=(0,Rt.readFileSync)(t,"utf-8"),o=(JSON.parse(r).CLAUDE_MEM_LOG_LEVEL||"INFO").toUpperCase();this.level=oc[o]??1}else this.level=1}catch{this.level=1}return this.level}correlationId(t,r){return`obs-${t}-${r}`}sessionId(t){return`session-${t}`}formatData(t){if(t==null)return"";if(typeof t=="string")return t;if(typeof t=="number"||typeof t=="boolean")return t.toString();if(typeof t=="object"){if(t instanceof Error)return this.getLevel()===0?`${t.message}
|
|
${t.stack}`:t.message;if(Array.isArray(t))return`[${t.length} items]`;let r=Object.keys(t);return r.length===0?"{}":r.length<=3?JSON.stringify(t):`{${r.length} keys: ${r.slice(0,3).join(", ")}...}`}return String(t)}formatTool(t,r){if(!r)return t;let n=r;if(typeof r=="string")try{n=JSON.parse(r)}catch{n=r}if(t==="Bash"&&n.command)return`${t}(${n.command})`;if(n.file_path)return`${t}(${n.file_path})`;if(n.notebook_path)return`${t}(${n.notebook_path})`;if(t==="Glob"&&n.pattern)return`${t}(${n.pattern})`;if(t==="Grep"&&n.pattern)return`${t}(${n.pattern})`;if(n.url)return`${t}(${n.url})`;if(n.query)return`${t}(${n.query})`;if(t==="Task"){if(n.subagent_type)return`${t}(${n.subagent_type})`;if(n.description)return`${t}(${n.description})`}return t==="Skill"&&n.skill?`${t}(${n.skill})`:t==="LSP"&&n.operation?`${t}(${n.operation})`:t}formatTimestamp(t){let r=t.getFullYear(),n=String(t.getMonth()+1).padStart(2,"0"),o=String(t.getDate()).padStart(2,"0"),i=String(t.getHours()).padStart(2,"0"),a=String(t.getMinutes()).padStart(2,"0"),s=String(t.getSeconds()).padStart(2,"0"),c=String(t.getMilliseconds()).padStart(3,"0");return`${r}-${n}-${o} ${i}:${a}:${s}.${c}`}log(t,r,n,o,i){if(t<this.getLevel())return;this.ensureLogFileInitialized();let a=this.formatTimestamp(new Date),s=oc[t].padEnd(5),c=r.padEnd(6),u="";o?.correlationId?u=`[${o.correlationId}] `:o?.sessionId&&(u=`[session-${o.sessionId}] `);let l="";i!=null&&(i instanceof Error?l=this.getLevel()===0?`
|
|
${i.message}
|
|
${i.stack}`:` ${i.message}`:this.getLevel()===0&&typeof i=="object"?l=`
|
|
`+JSON.stringify(i,null,2):l=" "+this.formatData(i));let d="";if(o){let{sessionId:f,memorySessionId:h,correlationId:g,...y}=o;Object.keys(y).length>0&&(d=` {${Object.entries(y).map(([x,b])=>`${x}=${b}`).join(", ")}}`)}let p=`[${a}] [${s}] [${c}] ${u}${n}${d}${l}`;if(this.logFilePath)try{(0,Rt.appendFileSync)(this.logFilePath,p+`
|
|
`,"utf8")}catch(f){process.stderr.write(`[LOGGER] Failed to write to log file: ${f}
|
|
`)}else process.stderr.write(p+`
|
|
`)}debug(t,r,n,o){this.log(0,t,r,n,o)}info(t,r,n,o){this.log(1,t,r,n,o)}warn(t,r,n,o){this.log(2,t,r,n,o)}error(t,r,n,o){this.log(3,t,r,n,o)}dataIn(t,r,n,o){this.info(t,`\u2192 ${r}`,n,o)}dataOut(t,r,n,o){this.info(t,`\u2190 ${r}`,n,o)}success(t,r,n,o){this.info(t,`\u2713 ${r}`,n,o)}failure(t,r,n,o){this.error(t,`\u2717 ${r}`,n,o)}timing(t,r,n,o){this.info(t,`\u23F1 ${r}`,o,{duration:`${n}ms`})}happyPathError(t,r,n,o,i=""){let u=((new Error().stack||"").split(`
|
|
`)[2]||"").match(/at\s+(?:.*\s+)?\(?([^:]+):(\d+):(\d+)\)?/),l=u?`${u[1].split("/").pop()}:${u[2]}`:"unknown",d={...n,location:l};return this.warn(t,`[HAPPY-PATH] ${r}`,d,o),i}},w=new ic;var X;(function(e){e.assertEqual=o=>{};function t(o){}e.assertIs=t;function r(o){throw new Error}e.assertNever=r,e.arrayToEnum=o=>{let i={};for(let a of o)i[a]=a;return i},e.getValidEnumValues=o=>{let i=e.objectKeys(o).filter(s=>typeof o[o[s]]!="number"),a={};for(let s of i)a[s]=o[s];return e.objectValues(a)},e.objectValues=o=>e.objectKeys(o).map(function(i){return o[i]}),e.objectKeys=typeof Object.keys=="function"?o=>Object.keys(o):o=>{let i=[];for(let a in o)Object.prototype.hasOwnProperty.call(o,a)&&i.push(a);return i},e.find=(o,i)=>{for(let a of o)if(i(a))return a},e.isInteger=typeof Number.isInteger=="function"?o=>Number.isInteger(o):o=>typeof o=="number"&&Number.isFinite(o)&&Math.floor(o)===o;function n(o,i=" | "){return o.map(a=>typeof a=="string"?`'${a}'`:a).join(i)}e.joinValues=n,e.jsonStringifyReplacer=(o,i)=>typeof i=="bigint"?i.toString():i})(X||(X={}));var $m;(function(e){e.mergeShapes=(t,r)=>({...t,...r})})($m||($m={}));var z=X.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),Mt=e=>{switch(typeof e){case"undefined":return z.undefined;case"string":return z.string;case"number":return Number.isNaN(e)?z.nan:z.number;case"boolean":return z.boolean;case"function":return z.function;case"bigint":return z.bigint;case"symbol":return z.symbol;case"object":return Array.isArray(e)?z.array:e===null?z.null:e.then&&typeof e.then=="function"&&e.catch&&typeof e.catch=="function"?z.promise:typeof Map<"u"&&e instanceof Map?z.map:typeof Set<"u"&&e instanceof Set?z.set:typeof Date<"u"&&e instanceof Date?z.date:z.object;default:return z.unknown}};var _=X.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 Ye=class e extends Error{get errors(){return this.issues}constructor(t){super(),this.issues=[],this.addIssue=n=>{this.issues=[...this.issues,n]},this.addIssues=(n=[])=>{this.issues=[...this.issues,...n]};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},n={_errors:[]},o=i=>{for(let a of i.issues)if(a.code==="invalid_union")a.unionErrors.map(o);else if(a.code==="invalid_return_type")o(a.returnTypeError);else if(a.code==="invalid_arguments")o(a.argumentsError);else if(a.path.length===0)n._errors.push(r(a));else{let s=n,c=0;for(;c<a.path.length;){let u=a.path[c];c===a.path.length-1?(s[u]=s[u]||{_errors:[]},s[u]._errors.push(r(a))):s[u]=s[u]||{_errors:[]},s=s[u],c++}}};return o(this),n}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,X.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(t=r=>r.message){let r=Object.create(null),n=[];for(let o of this.issues)if(o.path.length>0){let i=o.path[0];r[i]=r[i]||[],r[i].push(t(o))}else n.push(t(o));return{formErrors:n,fieldErrors:r}}get formErrors(){return this.flatten()}};Ye.create=e=>new Ye(e);var Tb=(e,t)=>{let r;switch(e.code){case _.invalid_type:e.received===z.undefined?r="Required":r=`Expected ${e.expected}, received ${e.received}`;break;case _.invalid_literal:r=`Invalid literal value, expected ${JSON.stringify(e.expected,X.jsonStringifyReplacer)}`;break;case _.unrecognized_keys:r=`Unrecognized key(s) in object: ${X.joinValues(e.keys,", ")}`;break;case _.invalid_union:r="Invalid input";break;case _.invalid_union_discriminator:r=`Invalid discriminator value. Expected ${X.joinValues(e.options)}`;break;case _.invalid_enum_value:r=`Invalid enum value. Expected ${X.joinValues(e.options)}, received '${e.received}'`;break;case _.invalid_arguments:r="Invalid function arguments";break;case _.invalid_return_type:r="Invalid function return type";break;case _.invalid_date:r="Invalid date";break;case _.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}"`:X.assertNever(e.validation):e.validation!=="regex"?r=`Invalid ${e.validation}`:r="Invalid";break;case _.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 _.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 _.custom:r="Invalid input";break;case _.invalid_intersection_types:r="Intersection results could not be merged";break;case _.not_multiple_of:r=`Number must be a multiple of ${e.multipleOf}`;break;case _.not_finite:r="Number must be finite";break;default:r=t.defaultError,X.assertNever(e)}return{message:r}},nr=Tb;var Ob=nr;function Vn(){return Ob}var Ci=e=>{let{data:t,path:r,errorMaps:n,issueData:o}=e,i=[...r,...o.path||[]],a={...o,path:i};if(o.message!==void 0)return{...o,path:i,message:o.message};let s="",c=n.filter(u=>!!u).slice().reverse();for(let u of c)s=u(a,{data:t,defaultError:s}).message;return{...o,path:i,message:s}};function k(e,t){let r=Vn(),n=Ci({issueData:t,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,r,r===nr?void 0:nr].filter(o=>!!o)});e.common.issues.push(n)}var Pe=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 n=[];for(let o of r){if(o.status==="aborted")return C;o.status==="dirty"&&t.dirty(),n.push(o.value)}return{status:t.value,value:n}}static async mergeObjectAsync(t,r){let n=[];for(let o of r){let i=await o.key,a=await o.value;n.push({key:i,value:a})}return e.mergeObjectSync(t,n)}static mergeObjectSync(t,r){let n={};for(let o of r){let{key:i,value:a}=o;if(i.status==="aborted"||a.status==="aborted")return C;i.status==="dirty"&&t.dirty(),a.status==="dirty"&&t.dirty(),i.value!=="__proto__"&&(typeof a.value<"u"||o.alwaysSet)&&(n[i.value]=a.value)}return{status:t.value,value:n}}},C=Object.freeze({status:"aborted"}),Vr=e=>({status:"dirty",value:e}),Me=e=>({status:"valid",value:e}),ac=e=>e.status==="aborted",sc=e=>e.status==="dirty",xr=e=>e.status==="valid",Wn=e=>typeof Promise<"u"&&e instanceof Promise;var O;(function(e){e.errToObj=t=>typeof t=="string"?{message:t}:t||{},e.toString=t=>typeof t=="string"?t:t?.message})(O||(O={}));var nt=class{constructor(t,r,n,o){this._cachedPath=[],this.parent=t,this.data=r,this._path=n,this._key=o}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}},bm=(e,t)=>{if(xr(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 Ye(e.common.issues);return this._error=r,this._error}}};function F(e){if(!e)return{};let{errorMap:t,invalid_type_error:r,required_error:n,description:o}=e;if(t&&(r||n))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return t?{errorMap:t,description:o}:{errorMap:(a,s)=>{let{message:c}=e;return a.code==="invalid_enum_value"?{message:c??s.defaultError}:typeof s.data>"u"?{message:c??n??s.defaultError}:a.code!=="invalid_type"?{message:s.defaultError}:{message:c??r??s.defaultError}},description:o}}var G=class{get description(){return this._def.description}_getType(t){return Mt(t.data)}_getOrReturnCtx(t,r){return r||{common:t.parent.common,data:t.data,parsedType:Mt(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}_processInputParams(t){return{status:new Pe,ctx:{common:t.parent.common,data:t.data,parsedType:Mt(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}}_parseSync(t){let r=this._parse(t);if(Wn(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 n=this.safeParse(t,r);if(n.success)return n.data;throw n.error}safeParse(t,r){let n={common:{issues:[],async:r?.async??!1,contextualErrorMap:r?.errorMap},path:r?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:Mt(t)},o=this._parseSync({data:t,path:n.path,parent:n});return bm(n,o)}"~validate"(t){let r={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:Mt(t)};if(!this["~standard"].async)try{let n=this._parseSync({data:t,path:[],parent:r});return xr(n)?{value:n.value}:{issues:r.common.issues}}catch(n){n?.message?.toLowerCase()?.includes("encountered")&&(this["~standard"].async=!0),r.common={issues:[],async:!0}}return this._parseAsync({data:t,path:[],parent:r}).then(n=>xr(n)?{value:n.value}:{issues:r.common.issues})}async parseAsync(t,r){let n=await this.safeParseAsync(t,r);if(n.success)return n.data;throw n.error}async safeParseAsync(t,r){let n={common:{issues:[],contextualErrorMap:r?.errorMap,async:!0},path:r?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:Mt(t)},o=this._parse({data:t,path:n.path,parent:n}),i=await(Wn(o)?o:Promise.resolve(o));return bm(n,i)}refine(t,r){let n=o=>typeof r=="string"||typeof r>"u"?{message:r}:typeof r=="function"?r(o):r;return this._refinement((o,i)=>{let a=t(o),s=()=>i.addIssue({code:_.custom,...n(o)});return typeof Promise<"u"&&a instanceof Promise?a.then(c=>c?!0:(s(),!1)):a?!0:(s(),!1)})}refinement(t,r){return this._refinement((n,o)=>t(n)?!0:(o.addIssue(typeof r=="function"?r(n,o):r),!1))}_refinement(t){return new gt({schema:this,typeName:R.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 ht.create(this,this._def)}nullable(){return Ut.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return ir.create(this)}promise(){return Sr.create(this,this._def)}or(t){return Kr.create([this,t],this._def)}and(t){return Br.create(this,t,this._def)}transform(t){return new gt({...F(this._def),schema:this,typeName:R.ZodEffects,effect:{type:"transform",transform:t}})}default(t){let r=typeof t=="function"?t:()=>t;return new tn({...F(this._def),innerType:this,defaultValue:r,typeName:R.ZodDefault})}brand(){return new Ui({typeName:R.ZodBranded,type:this,...F(this._def)})}catch(t){let r=typeof t=="function"?t:()=>t;return new rn({...F(this._def),innerType:this,catchValue:r,typeName:R.ZodCatch})}describe(t){let r=this.constructor;return new r({...this._def,description:t})}pipe(t){return Zi.create(this,t)}readonly(){return nn.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},jb=/^c[^\s-]{8,}$/i,Db=/^[0-9a-z]+$/,Nb=/^[0-9A-HJKMNP-TV-Z]{26}$/i,Rb=/^[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,Mb=/^[a-z0-9_-]{21}$/i,Ab=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,Cb=/^[-+]?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)?)??$/,Ub=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,Zb="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",cc,Lb=/^(?:(?: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])$/,Fb=/^(?:(?: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])$/,qb=/^(([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]))$/,Vb=/^(([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])$/,Wb=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,Jb=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,xm="((\\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])))",Hb=new RegExp(`^${xm}$`);function Sm(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 Gb(e){return new RegExp(`^${Sm(e)}$`)}function Kb(e){let t=`${xm}T${Sm(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 Bb(e,t){return!!((t==="v4"||!t)&&Lb.test(e)||(t==="v6"||!t)&&qb.test(e))}function Yb(e,t){if(!Ab.test(e))return!1;try{let[r]=e.split(".");if(!r)return!1;let n=r.replace(/-/g,"+").replace(/_/g,"/").padEnd(r.length+(4-r.length%4)%4,"="),o=JSON.parse(atob(n));return!(typeof o!="object"||o===null||"typ"in o&&o?.typ!=="JWT"||!o.alg||t&&o.alg!==t)}catch{return!1}}function Xb(e,t){return!!((t==="v4"||!t)&&Fb.test(e)||(t==="v6"||!t)&&Vb.test(e))}var Jr=class e extends G{_parse(t){if(this._def.coerce&&(t.data=String(t.data)),this._getType(t)!==z.string){let i=this._getOrReturnCtx(t);return k(i,{code:_.invalid_type,expected:z.string,received:i.parsedType}),C}let n=new Pe,o;for(let i of this._def.checks)if(i.kind==="min")t.data.length<i.value&&(o=this._getOrReturnCtx(t,o),k(o,{code:_.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),n.dirty());else if(i.kind==="max")t.data.length>i.value&&(o=this._getOrReturnCtx(t,o),k(o,{code:_.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),n.dirty());else if(i.kind==="length"){let a=t.data.length>i.value,s=t.data.length<i.value;(a||s)&&(o=this._getOrReturnCtx(t,o),a?k(o,{code:_.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}):s&&k(o,{code:_.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}),n.dirty())}else if(i.kind==="email")Ub.test(t.data)||(o=this._getOrReturnCtx(t,o),k(o,{validation:"email",code:_.invalid_string,message:i.message}),n.dirty());else if(i.kind==="emoji")cc||(cc=new RegExp(Zb,"u")),cc.test(t.data)||(o=this._getOrReturnCtx(t,o),k(o,{validation:"emoji",code:_.invalid_string,message:i.message}),n.dirty());else if(i.kind==="uuid")Rb.test(t.data)||(o=this._getOrReturnCtx(t,o),k(o,{validation:"uuid",code:_.invalid_string,message:i.message}),n.dirty());else if(i.kind==="nanoid")Mb.test(t.data)||(o=this._getOrReturnCtx(t,o),k(o,{validation:"nanoid",code:_.invalid_string,message:i.message}),n.dirty());else if(i.kind==="cuid")jb.test(t.data)||(o=this._getOrReturnCtx(t,o),k(o,{validation:"cuid",code:_.invalid_string,message:i.message}),n.dirty());else if(i.kind==="cuid2")Db.test(t.data)||(o=this._getOrReturnCtx(t,o),k(o,{validation:"cuid2",code:_.invalid_string,message:i.message}),n.dirty());else if(i.kind==="ulid")Nb.test(t.data)||(o=this._getOrReturnCtx(t,o),k(o,{validation:"ulid",code:_.invalid_string,message:i.message}),n.dirty());else if(i.kind==="url")try{new URL(t.data)}catch{o=this._getOrReturnCtx(t,o),k(o,{validation:"url",code:_.invalid_string,message:i.message}),n.dirty()}else i.kind==="regex"?(i.regex.lastIndex=0,i.regex.test(t.data)||(o=this._getOrReturnCtx(t,o),k(o,{validation:"regex",code:_.invalid_string,message:i.message}),n.dirty())):i.kind==="trim"?t.data=t.data.trim():i.kind==="includes"?t.data.includes(i.value,i.position)||(o=this._getOrReturnCtx(t,o),k(o,{code:_.invalid_string,validation:{includes:i.value,position:i.position},message:i.message}),n.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)||(o=this._getOrReturnCtx(t,o),k(o,{code:_.invalid_string,validation:{startsWith:i.value},message:i.message}),n.dirty()):i.kind==="endsWith"?t.data.endsWith(i.value)||(o=this._getOrReturnCtx(t,o),k(o,{code:_.invalid_string,validation:{endsWith:i.value},message:i.message}),n.dirty()):i.kind==="datetime"?Kb(i).test(t.data)||(o=this._getOrReturnCtx(t,o),k(o,{code:_.invalid_string,validation:"datetime",message:i.message}),n.dirty()):i.kind==="date"?Hb.test(t.data)||(o=this._getOrReturnCtx(t,o),k(o,{code:_.invalid_string,validation:"date",message:i.message}),n.dirty()):i.kind==="time"?Gb(i).test(t.data)||(o=this._getOrReturnCtx(t,o),k(o,{code:_.invalid_string,validation:"time",message:i.message}),n.dirty()):i.kind==="duration"?Cb.test(t.data)||(o=this._getOrReturnCtx(t,o),k(o,{validation:"duration",code:_.invalid_string,message:i.message}),n.dirty()):i.kind==="ip"?Bb(t.data,i.version)||(o=this._getOrReturnCtx(t,o),k(o,{validation:"ip",code:_.invalid_string,message:i.message}),n.dirty()):i.kind==="jwt"?Yb(t.data,i.alg)||(o=this._getOrReturnCtx(t,o),k(o,{validation:"jwt",code:_.invalid_string,message:i.message}),n.dirty()):i.kind==="cidr"?Xb(t.data,i.version)||(o=this._getOrReturnCtx(t,o),k(o,{validation:"cidr",code:_.invalid_string,message:i.message}),n.dirty()):i.kind==="base64"?Wb.test(t.data)||(o=this._getOrReturnCtx(t,o),k(o,{validation:"base64",code:_.invalid_string,message:i.message}),n.dirty()):i.kind==="base64url"?Jb.test(t.data)||(o=this._getOrReturnCtx(t,o),k(o,{validation:"base64url",code:_.invalid_string,message:i.message}),n.dirty()):X.assertNever(i);return{status:n.value,value:t.data}}_regex(t,r,n){return this.refinement(o=>t.test(o),{validation:r,code:_.invalid_string,...O.errToObj(n)})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}email(t){return this._addCheck({kind:"email",...O.errToObj(t)})}url(t){return this._addCheck({kind:"url",...O.errToObj(t)})}emoji(t){return this._addCheck({kind:"emoji",...O.errToObj(t)})}uuid(t){return this._addCheck({kind:"uuid",...O.errToObj(t)})}nanoid(t){return this._addCheck({kind:"nanoid",...O.errToObj(t)})}cuid(t){return this._addCheck({kind:"cuid",...O.errToObj(t)})}cuid2(t){return this._addCheck({kind:"cuid2",...O.errToObj(t)})}ulid(t){return this._addCheck({kind:"ulid",...O.errToObj(t)})}base64(t){return this._addCheck({kind:"base64",...O.errToObj(t)})}base64url(t){return this._addCheck({kind:"base64url",...O.errToObj(t)})}jwt(t){return this._addCheck({kind:"jwt",...O.errToObj(t)})}ip(t){return this._addCheck({kind:"ip",...O.errToObj(t)})}cidr(t){return this._addCheck({kind:"cidr",...O.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,...O.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,...O.errToObj(t?.message)})}duration(t){return this._addCheck({kind:"duration",...O.errToObj(t)})}regex(t,r){return this._addCheck({kind:"regex",regex:t,...O.errToObj(r)})}includes(t,r){return this._addCheck({kind:"includes",value:t,position:r?.position,...O.errToObj(r?.message)})}startsWith(t,r){return this._addCheck({kind:"startsWith",value:t,...O.errToObj(r)})}endsWith(t,r){return this._addCheck({kind:"endsWith",value:t,...O.errToObj(r)})}min(t,r){return this._addCheck({kind:"min",value:t,...O.errToObj(r)})}max(t,r){return this._addCheck({kind:"max",value:t,...O.errToObj(r)})}length(t,r){return this._addCheck({kind:"length",value:t,...O.errToObj(r)})}nonempty(t){return this.min(1,O.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}};Jr.create=e=>new Jr({checks:[],typeName:R.ZodString,coerce:e?.coerce??!1,...F(e)});function Qb(e,t){let r=(e.toString().split(".")[1]||"").length,n=(t.toString().split(".")[1]||"").length,o=r>n?r:n,i=Number.parseInt(e.toFixed(o).replace(".","")),a=Number.parseInt(t.toFixed(o).replace(".",""));return i%a/10**o}var Jn=class e extends G{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)!==z.number){let i=this._getOrReturnCtx(t);return k(i,{code:_.invalid_type,expected:z.number,received:i.parsedType}),C}let n,o=new Pe;for(let i of this._def.checks)i.kind==="int"?X.isInteger(t.data)||(n=this._getOrReturnCtx(t,n),k(n,{code:_.invalid_type,expected:"integer",received:"float",message:i.message}),o.dirty()):i.kind==="min"?(i.inclusive?t.data<i.value:t.data<=i.value)&&(n=this._getOrReturnCtx(t,n),k(n,{code:_.too_small,minimum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),o.dirty()):i.kind==="max"?(i.inclusive?t.data>i.value:t.data>=i.value)&&(n=this._getOrReturnCtx(t,n),k(n,{code:_.too_big,maximum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),o.dirty()):i.kind==="multipleOf"?Qb(t.data,i.value)!==0&&(n=this._getOrReturnCtx(t,n),k(n,{code:_.not_multiple_of,multipleOf:i.value,message:i.message}),o.dirty()):i.kind==="finite"?Number.isFinite(t.data)||(n=this._getOrReturnCtx(t,n),k(n,{code:_.not_finite,message:i.message}),o.dirty()):X.assertNever(i);return{status:o.value,value:t.data}}gte(t,r){return this.setLimit("min",t,!0,O.toString(r))}gt(t,r){return this.setLimit("min",t,!1,O.toString(r))}lte(t,r){return this.setLimit("max",t,!0,O.toString(r))}lt(t,r){return this.setLimit("max",t,!1,O.toString(r))}setLimit(t,r,n,o){return new e({...this._def,checks:[...this._def.checks,{kind:t,value:r,inclusive:n,message:O.toString(o)}]})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}int(t){return this._addCheck({kind:"int",message:O.toString(t)})}positive(t){return this._addCheck({kind:"min",value:0,inclusive:!1,message:O.toString(t)})}negative(t){return this._addCheck({kind:"max",value:0,inclusive:!1,message:O.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:0,inclusive:!0,message:O.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:0,inclusive:!0,message:O.toString(t)})}multipleOf(t,r){return this._addCheck({kind:"multipleOf",value:t,message:O.toString(r)})}finite(t){return this._addCheck({kind:"finite",message:O.toString(t)})}safe(t){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:O.toString(t)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:O.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"&&X.isInteger(t.value))}get isFinite(){let t=null,r=null;for(let n of this._def.checks){if(n.kind==="finite"||n.kind==="int"||n.kind==="multipleOf")return!0;n.kind==="min"?(r===null||n.value>r)&&(r=n.value):n.kind==="max"&&(t===null||n.value<t)&&(t=n.value)}return Number.isFinite(r)&&Number.isFinite(t)}};Jn.create=e=>new Jn({checks:[],typeName:R.ZodNumber,coerce:e?.coerce||!1,...F(e)});var Hn=class e extends G{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)!==z.bigint)return this._getInvalidInput(t);let n,o=new Pe;for(let i of this._def.checks)i.kind==="min"?(i.inclusive?t.data<i.value:t.data<=i.value)&&(n=this._getOrReturnCtx(t,n),k(n,{code:_.too_small,type:"bigint",minimum:i.value,inclusive:i.inclusive,message:i.message}),o.dirty()):i.kind==="max"?(i.inclusive?t.data>i.value:t.data>=i.value)&&(n=this._getOrReturnCtx(t,n),k(n,{code:_.too_big,type:"bigint",maximum:i.value,inclusive:i.inclusive,message:i.message}),o.dirty()):i.kind==="multipleOf"?t.data%i.value!==BigInt(0)&&(n=this._getOrReturnCtx(t,n),k(n,{code:_.not_multiple_of,multipleOf:i.value,message:i.message}),o.dirty()):X.assertNever(i);return{status:o.value,value:t.data}}_getInvalidInput(t){let r=this._getOrReturnCtx(t);return k(r,{code:_.invalid_type,expected:z.bigint,received:r.parsedType}),C}gte(t,r){return this.setLimit("min",t,!0,O.toString(r))}gt(t,r){return this.setLimit("min",t,!1,O.toString(r))}lte(t,r){return this.setLimit("max",t,!0,O.toString(r))}lt(t,r){return this.setLimit("max",t,!1,O.toString(r))}setLimit(t,r,n,o){return new e({...this._def,checks:[...this._def.checks,{kind:t,value:r,inclusive:n,message:O.toString(o)}]})}_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:O.toString(t)})}negative(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:O.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:O.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:O.toString(t)})}multipleOf(t,r){return this._addCheck({kind:"multipleOf",value:t,message:O.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}};Hn.create=e=>new Hn({checks:[],typeName:R.ZodBigInt,coerce:e?.coerce??!1,...F(e)});var Gn=class extends G{_parse(t){if(this._def.coerce&&(t.data=!!t.data),this._getType(t)!==z.boolean){let n=this._getOrReturnCtx(t);return k(n,{code:_.invalid_type,expected:z.boolean,received:n.parsedType}),C}return Me(t.data)}};Gn.create=e=>new Gn({typeName:R.ZodBoolean,coerce:e?.coerce||!1,...F(e)});var Kn=class e extends G{_parse(t){if(this._def.coerce&&(t.data=new Date(t.data)),this._getType(t)!==z.date){let i=this._getOrReturnCtx(t);return k(i,{code:_.invalid_type,expected:z.date,received:i.parsedType}),C}if(Number.isNaN(t.data.getTime())){let i=this._getOrReturnCtx(t);return k(i,{code:_.invalid_date}),C}let n=new Pe,o;for(let i of this._def.checks)i.kind==="min"?t.data.getTime()<i.value&&(o=this._getOrReturnCtx(t,o),k(o,{code:_.too_small,message:i.message,inclusive:!0,exact:!1,minimum:i.value,type:"date"}),n.dirty()):i.kind==="max"?t.data.getTime()>i.value&&(o=this._getOrReturnCtx(t,o),k(o,{code:_.too_big,message:i.message,inclusive:!0,exact:!1,maximum:i.value,type:"date"}),n.dirty()):X.assertNever(i);return{status:n.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:O.toString(r)})}max(t,r){return this._addCheck({kind:"max",value:t.getTime(),message:O.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}};Kn.create=e=>new Kn({checks:[],coerce:e?.coerce||!1,typeName:R.ZodDate,...F(e)});var Bn=class extends G{_parse(t){if(this._getType(t)!==z.symbol){let n=this._getOrReturnCtx(t);return k(n,{code:_.invalid_type,expected:z.symbol,received:n.parsedType}),C}return Me(t.data)}};Bn.create=e=>new Bn({typeName:R.ZodSymbol,...F(e)});var Hr=class extends G{_parse(t){if(this._getType(t)!==z.undefined){let n=this._getOrReturnCtx(t);return k(n,{code:_.invalid_type,expected:z.undefined,received:n.parsedType}),C}return Me(t.data)}};Hr.create=e=>new Hr({typeName:R.ZodUndefined,...F(e)});var Gr=class extends G{_parse(t){if(this._getType(t)!==z.null){let n=this._getOrReturnCtx(t);return k(n,{code:_.invalid_type,expected:z.null,received:n.parsedType}),C}return Me(t.data)}};Gr.create=e=>new Gr({typeName:R.ZodNull,...F(e)});var Yn=class extends G{constructor(){super(...arguments),this._any=!0}_parse(t){return Me(t.data)}};Yn.create=e=>new Yn({typeName:R.ZodAny,...F(e)});var or=class extends G{constructor(){super(...arguments),this._unknown=!0}_parse(t){return Me(t.data)}};or.create=e=>new or({typeName:R.ZodUnknown,...F(e)});var wt=class extends G{_parse(t){let r=this._getOrReturnCtx(t);return k(r,{code:_.invalid_type,expected:z.never,received:r.parsedType}),C}};wt.create=e=>new wt({typeName:R.ZodNever,...F(e)});var Xn=class extends G{_parse(t){if(this._getType(t)!==z.undefined){let n=this._getOrReturnCtx(t);return k(n,{code:_.invalid_type,expected:z.void,received:n.parsedType}),C}return Me(t.data)}};Xn.create=e=>new Xn({typeName:R.ZodVoid,...F(e)});var ir=class e extends G{_parse(t){let{ctx:r,status:n}=this._processInputParams(t),o=this._def;if(r.parsedType!==z.array)return k(r,{code:_.invalid_type,expected:z.array,received:r.parsedType}),C;if(o.exactLength!==null){let a=r.data.length>o.exactLength.value,s=r.data.length<o.exactLength.value;(a||s)&&(k(r,{code:a?_.too_big:_.too_small,minimum:s?o.exactLength.value:void 0,maximum:a?o.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:o.exactLength.message}),n.dirty())}if(o.minLength!==null&&r.data.length<o.minLength.value&&(k(r,{code:_.too_small,minimum:o.minLength.value,type:"array",inclusive:!0,exact:!1,message:o.minLength.message}),n.dirty()),o.maxLength!==null&&r.data.length>o.maxLength.value&&(k(r,{code:_.too_big,maximum:o.maxLength.value,type:"array",inclusive:!0,exact:!1,message:o.maxLength.message}),n.dirty()),r.common.async)return Promise.all([...r.data].map((a,s)=>o.type._parseAsync(new nt(r,a,r.path,s)))).then(a=>Pe.mergeArray(n,a));let i=[...r.data].map((a,s)=>o.type._parseSync(new nt(r,a,r.path,s)));return Pe.mergeArray(n,i)}get element(){return this._def.type}min(t,r){return new e({...this._def,minLength:{value:t,message:O.toString(r)}})}max(t,r){return new e({...this._def,maxLength:{value:t,message:O.toString(r)}})}length(t,r){return new e({...this._def,exactLength:{value:t,message:O.toString(r)}})}nonempty(t){return this.min(1,t)}};ir.create=(e,t)=>new ir({type:e,minLength:null,maxLength:null,exactLength:null,typeName:R.ZodArray,...F(t)});function Wr(e){if(e instanceof Xe){let t={};for(let r in e.shape){let n=e.shape[r];t[r]=ht.create(Wr(n))}return new Xe({...e._def,shape:()=>t})}else return e instanceof ir?new ir({...e._def,type:Wr(e.element)}):e instanceof ht?ht.create(Wr(e.unwrap())):e instanceof Ut?Ut.create(Wr(e.unwrap())):e instanceof Ct?Ct.create(e.items.map(t=>Wr(t))):e}var Xe=class e extends G{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=X.objectKeys(t);return this._cached={shape:t,keys:r},this._cached}_parse(t){if(this._getType(t)!==z.object){let u=this._getOrReturnCtx(t);return k(u,{code:_.invalid_type,expected:z.object,received:u.parsedType}),C}let{status:n,ctx:o}=this._processInputParams(t),{shape:i,keys:a}=this._getCached(),s=[];if(!(this._def.catchall instanceof wt&&this._def.unknownKeys==="strip"))for(let u in o.data)a.includes(u)||s.push(u);let c=[];for(let u of a){let l=i[u],d=o.data[u];c.push({key:{status:"valid",value:u},value:l._parse(new nt(o,d,o.path,u)),alwaysSet:u in o.data})}if(this._def.catchall instanceof wt){let u=this._def.unknownKeys;if(u==="passthrough")for(let l of s)c.push({key:{status:"valid",value:l},value:{status:"valid",value:o.data[l]}});else if(u==="strict")s.length>0&&(k(o,{code:_.unrecognized_keys,keys:s}),n.dirty());else if(u!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{let u=this._def.catchall;for(let l of s){let d=o.data[l];c.push({key:{status:"valid",value:l},value:u._parse(new nt(o,d,o.path,l)),alwaysSet:l in o.data})}}return o.common.async?Promise.resolve().then(async()=>{let u=[];for(let l of c){let d=await l.key,p=await l.value;u.push({key:d,value:p,alwaysSet:l.alwaysSet})}return u}).then(u=>Pe.mergeObjectSync(n,u)):Pe.mergeObjectSync(n,c)}get shape(){return this._def.shape()}strict(t){return O.errToObj,new e({...this._def,unknownKeys:"strict",...t!==void 0?{errorMap:(r,n)=>{let o=this._def.errorMap?.(r,n).message??n.defaultError;return r.code==="unrecognized_keys"?{message:O.errToObj(t).message??o}:{message:o}}}:{}})}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:R.ZodObject})}setKey(t,r){return this.augment({[t]:r})}catchall(t){return new e({...this._def,catchall:t})}pick(t){let r={};for(let n of X.objectKeys(t))t[n]&&this.shape[n]&&(r[n]=this.shape[n]);return new e({...this._def,shape:()=>r})}omit(t){let r={};for(let n of X.objectKeys(this.shape))t[n]||(r[n]=this.shape[n]);return new e({...this._def,shape:()=>r})}deepPartial(){return Wr(this)}partial(t){let r={};for(let n of X.objectKeys(this.shape)){let o=this.shape[n];t&&!t[n]?r[n]=o:r[n]=o.optional()}return new e({...this._def,shape:()=>r})}required(t){let r={};for(let n of X.objectKeys(this.shape))if(t&&!t[n])r[n]=this.shape[n];else{let i=this.shape[n];for(;i instanceof ht;)i=i._def.innerType;r[n]=i}return new e({...this._def,shape:()=>r})}keyof(){return km(X.objectKeys(this.shape))}};Xe.create=(e,t)=>new Xe({shape:()=>e,unknownKeys:"strip",catchall:wt.create(),typeName:R.ZodObject,...F(t)});Xe.strictCreate=(e,t)=>new Xe({shape:()=>e,unknownKeys:"strict",catchall:wt.create(),typeName:R.ZodObject,...F(t)});Xe.lazycreate=(e,t)=>new Xe({shape:e,unknownKeys:"strip",catchall:wt.create(),typeName:R.ZodObject,...F(t)});var Kr=class extends G{_parse(t){let{ctx:r}=this._processInputParams(t),n=this._def.options;function o(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 a=i.map(s=>new Ye(s.ctx.common.issues));return k(r,{code:_.invalid_union,unionErrors:a}),C}if(r.common.async)return Promise.all(n.map(async i=>{let a={...r,common:{...r.common,issues:[]},parent:null};return{result:await i._parseAsync({data:r.data,path:r.path,parent:a}),ctx:a}})).then(o);{let i,a=[];for(let c of n){let u={...r,common:{...r.common,issues:[]},parent:null},l=c._parseSync({data:r.data,path:r.path,parent:u});if(l.status==="valid")return l;l.status==="dirty"&&!i&&(i={result:l,ctx:u}),u.common.issues.length&&a.push(u.common.issues)}if(i)return r.common.issues.push(...i.ctx.common.issues),i.result;let s=a.map(c=>new Ye(c));return k(r,{code:_.invalid_union,unionErrors:s}),C}}get options(){return this._def.options}};Kr.create=(e,t)=>new Kr({options:e,typeName:R.ZodUnion,...F(t)});var At=e=>e instanceof Yr?At(e.schema):e instanceof gt?At(e.innerType()):e instanceof Xr?[e.value]:e instanceof Qr?e.options:e instanceof en?X.objectValues(e.enum):e instanceof tn?At(e._def.innerType):e instanceof Hr?[void 0]:e instanceof Gr?[null]:e instanceof ht?[void 0,...At(e.unwrap())]:e instanceof Ut?[null,...At(e.unwrap())]:e instanceof Ui||e instanceof nn?At(e.unwrap()):e instanceof rn?At(e._def.innerType):[],uc=class e extends G{_parse(t){let{ctx:r}=this._processInputParams(t);if(r.parsedType!==z.object)return k(r,{code:_.invalid_type,expected:z.object,received:r.parsedType}),C;let n=this.discriminator,o=r.data[n],i=this.optionsMap.get(o);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}):(k(r,{code:_.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),C)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(t,r,n){let o=new Map;for(let i of r){let a=At(i.shape[t]);if(!a.length)throw new Error(`A discriminator value for key \`${t}\` could not be extracted from all schema options`);for(let s of a){if(o.has(s))throw new Error(`Discriminator property ${String(t)} has duplicate value ${String(s)}`);o.set(s,i)}}return new e({typeName:R.ZodDiscriminatedUnion,discriminator:t,options:r,optionsMap:o,...F(n)})}};function lc(e,t){let r=Mt(e),n=Mt(t);if(e===t)return{valid:!0,data:e};if(r===z.object&&n===z.object){let o=X.objectKeys(t),i=X.objectKeys(e).filter(s=>o.indexOf(s)!==-1),a={...e,...t};for(let s of i){let c=lc(e[s],t[s]);if(!c.valid)return{valid:!1};a[s]=c.data}return{valid:!0,data:a}}else if(r===z.array&&n===z.array){if(e.length!==t.length)return{valid:!1};let o=[];for(let i=0;i<e.length;i++){let a=e[i],s=t[i],c=lc(a,s);if(!c.valid)return{valid:!1};o.push(c.data)}return{valid:!0,data:o}}else return r===z.date&&n===z.date&&+e==+t?{valid:!0,data:e}:{valid:!1}}var Br=class extends G{_parse(t){let{status:r,ctx:n}=this._processInputParams(t),o=(i,a)=>{if(ac(i)||ac(a))return C;let s=lc(i.value,a.value);return s.valid?((sc(i)||sc(a))&&r.dirty(),{status:r.value,value:s.data}):(k(n,{code:_.invalid_intersection_types}),C)};return n.common.async?Promise.all([this._def.left._parseAsync({data:n.data,path:n.path,parent:n}),this._def.right._parseAsync({data:n.data,path:n.path,parent:n})]).then(([i,a])=>o(i,a)):o(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}};Br.create=(e,t,r)=>new Br({left:e,right:t,typeName:R.ZodIntersection,...F(r)});var Ct=class e extends G{_parse(t){let{status:r,ctx:n}=this._processInputParams(t);if(n.parsedType!==z.array)return k(n,{code:_.invalid_type,expected:z.array,received:n.parsedType}),C;if(n.data.length<this._def.items.length)return k(n,{code:_.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),C;!this._def.rest&&n.data.length>this._def.items.length&&(k(n,{code:_.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),r.dirty());let i=[...n.data].map((a,s)=>{let c=this._def.items[s]||this._def.rest;return c?c._parse(new nt(n,a,n.path,s)):null}).filter(a=>!!a);return n.common.async?Promise.all(i).then(a=>Pe.mergeArray(r,a)):Pe.mergeArray(r,i)}get items(){return this._def.items}rest(t){return new e({...this._def,rest:t})}};Ct.create=(e,t)=>{if(!Array.isArray(e))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new Ct({items:e,typeName:R.ZodTuple,rest:null,...F(t)})};var dc=class e extends G{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(t){let{status:r,ctx:n}=this._processInputParams(t);if(n.parsedType!==z.object)return k(n,{code:_.invalid_type,expected:z.object,received:n.parsedType}),C;let o=[],i=this._def.keyType,a=this._def.valueType;for(let s in n.data)o.push({key:i._parse(new nt(n,s,n.path,s)),value:a._parse(new nt(n,n.data[s],n.path,s)),alwaysSet:s in n.data});return n.common.async?Pe.mergeObjectAsync(r,o):Pe.mergeObjectSync(r,o)}get element(){return this._def.valueType}static create(t,r,n){return r instanceof G?new e({keyType:t,valueType:r,typeName:R.ZodRecord,...F(n)}):new e({keyType:Jr.create(),valueType:t,typeName:R.ZodRecord,...F(r)})}},Qn=class extends G{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(t){let{status:r,ctx:n}=this._processInputParams(t);if(n.parsedType!==z.map)return k(n,{code:_.invalid_type,expected:z.map,received:n.parsedType}),C;let o=this._def.keyType,i=this._def.valueType,a=[...n.data.entries()].map(([s,c],u)=>({key:o._parse(new nt(n,s,n.path,[u,"key"])),value:i._parse(new nt(n,c,n.path,[u,"value"]))}));if(n.common.async){let s=new Map;return Promise.resolve().then(async()=>{for(let c of a){let u=await c.key,l=await c.value;if(u.status==="aborted"||l.status==="aborted")return C;(u.status==="dirty"||l.status==="dirty")&&r.dirty(),s.set(u.value,l.value)}return{status:r.value,value:s}})}else{let s=new Map;for(let c of a){let u=c.key,l=c.value;if(u.status==="aborted"||l.status==="aborted")return C;(u.status==="dirty"||l.status==="dirty")&&r.dirty(),s.set(u.value,l.value)}return{status:r.value,value:s}}}};Qn.create=(e,t,r)=>new Qn({valueType:t,keyType:e,typeName:R.ZodMap,...F(r)});var eo=class e extends G{_parse(t){let{status:r,ctx:n}=this._processInputParams(t);if(n.parsedType!==z.set)return k(n,{code:_.invalid_type,expected:z.set,received:n.parsedType}),C;let o=this._def;o.minSize!==null&&n.data.size<o.minSize.value&&(k(n,{code:_.too_small,minimum:o.minSize.value,type:"set",inclusive:!0,exact:!1,message:o.minSize.message}),r.dirty()),o.maxSize!==null&&n.data.size>o.maxSize.value&&(k(n,{code:_.too_big,maximum:o.maxSize.value,type:"set",inclusive:!0,exact:!1,message:o.maxSize.message}),r.dirty());let i=this._def.valueType;function a(c){let u=new Set;for(let l of c){if(l.status==="aborted")return C;l.status==="dirty"&&r.dirty(),u.add(l.value)}return{status:r.value,value:u}}let s=[...n.data.values()].map((c,u)=>i._parse(new nt(n,c,n.path,u)));return n.common.async?Promise.all(s).then(c=>a(c)):a(s)}min(t,r){return new e({...this._def,minSize:{value:t,message:O.toString(r)}})}max(t,r){return new e({...this._def,maxSize:{value:t,message:O.toString(r)}})}size(t,r){return this.min(t,r).max(t,r)}nonempty(t){return this.min(1,t)}};eo.create=(e,t)=>new eo({valueType:e,minSize:null,maxSize:null,typeName:R.ZodSet,...F(t)});var pc=class e extends G{constructor(){super(...arguments),this.validate=this.implement}_parse(t){let{ctx:r}=this._processInputParams(t);if(r.parsedType!==z.function)return k(r,{code:_.invalid_type,expected:z.function,received:r.parsedType}),C;function n(s,c){return Ci({data:s,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,Vn(),nr].filter(u=>!!u),issueData:{code:_.invalid_arguments,argumentsError:c}})}function o(s,c){return Ci({data:s,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,Vn(),nr].filter(u=>!!u),issueData:{code:_.invalid_return_type,returnTypeError:c}})}let i={errorMap:r.common.contextualErrorMap},a=r.data;if(this._def.returns instanceof Sr){let s=this;return Me(async function(...c){let u=new Ye([]),l=await s._def.args.parseAsync(c,i).catch(f=>{throw u.addIssue(n(c,f)),u}),d=await Reflect.apply(a,this,l);return await s._def.returns._def.type.parseAsync(d,i).catch(f=>{throw u.addIssue(o(d,f)),u})})}else{let s=this;return Me(function(...c){let u=s._def.args.safeParse(c,i);if(!u.success)throw new Ye([n(c,u.error)]);let l=Reflect.apply(a,this,u.data),d=s._def.returns.safeParse(l,i);if(!d.success)throw new Ye([o(l,d.error)]);return d.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...t){return new e({...this._def,args:Ct.create(t).rest(or.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,n){return new e({args:t||Ct.create([]).rest(or.create()),returns:r||or.create(),typeName:R.ZodFunction,...F(n)})}},Yr=class extends G{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})}};Yr.create=(e,t)=>new Yr({getter:e,typeName:R.ZodLazy,...F(t)});var Xr=class extends G{_parse(t){if(t.data!==this._def.value){let r=this._getOrReturnCtx(t);return k(r,{received:r.data,code:_.invalid_literal,expected:this._def.value}),C}return{status:"valid",value:t.data}}get value(){return this._def.value}};Xr.create=(e,t)=>new Xr({value:e,typeName:R.ZodLiteral,...F(t)});function km(e,t){return new Qr({values:e,typeName:R.ZodEnum,...F(t)})}var Qr=class e extends G{_parse(t){if(typeof t.data!="string"){let r=this._getOrReturnCtx(t),n=this._def.values;return k(r,{expected:X.joinValues(n),received:r.parsedType,code:_.invalid_type}),C}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(t.data)){let r=this._getOrReturnCtx(t),n=this._def.values;return k(r,{received:r.data,code:_.invalid_enum_value,options:n}),C}return Me(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(n=>!t.includes(n)),{...this._def,...r})}};Qr.create=km;var en=class extends G{_parse(t){let r=X.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(t);if(n.parsedType!==z.string&&n.parsedType!==z.number){let o=X.objectValues(r);return k(n,{expected:X.joinValues(o),received:n.parsedType,code:_.invalid_type}),C}if(this._cache||(this._cache=new Set(X.getValidEnumValues(this._def.values))),!this._cache.has(t.data)){let o=X.objectValues(r);return k(n,{received:n.data,code:_.invalid_enum_value,options:o}),C}return Me(t.data)}get enum(){return this._def.values}};en.create=(e,t)=>new en({values:e,typeName:R.ZodNativeEnum,...F(t)});var Sr=class extends G{unwrap(){return this._def.type}_parse(t){let{ctx:r}=this._processInputParams(t);if(r.parsedType!==z.promise&&r.common.async===!1)return k(r,{code:_.invalid_type,expected:z.promise,received:r.parsedType}),C;let n=r.parsedType===z.promise?r.data:Promise.resolve(r.data);return Me(n.then(o=>this._def.type.parseAsync(o,{path:r.path,errorMap:r.common.contextualErrorMap})))}};Sr.create=(e,t)=>new Sr({type:e,typeName:R.ZodPromise,...F(t)});var gt=class extends G{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===R.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(t){let{status:r,ctx:n}=this._processInputParams(t),o=this._def.effect||null,i={addIssue:a=>{k(n,a),a.fatal?r.abort():r.dirty()},get path(){return n.path}};if(i.addIssue=i.addIssue.bind(i),o.type==="preprocess"){let a=o.transform(n.data,i);if(n.common.async)return Promise.resolve(a).then(async s=>{if(r.value==="aborted")return C;let c=await this._def.schema._parseAsync({data:s,path:n.path,parent:n});return c.status==="aborted"?C:c.status==="dirty"?Vr(c.value):r.value==="dirty"?Vr(c.value):c});{if(r.value==="aborted")return C;let s=this._def.schema._parseSync({data:a,path:n.path,parent:n});return s.status==="aborted"?C:s.status==="dirty"?Vr(s.value):r.value==="dirty"?Vr(s.value):s}}if(o.type==="refinement"){let a=s=>{let c=o.refinement(s,i);if(n.common.async)return Promise.resolve(c);if(c instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return s};if(n.common.async===!1){let s=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return s.status==="aborted"?C:(s.status==="dirty"&&r.dirty(),a(s.value),{status:r.value,value:s.value})}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(s=>s.status==="aborted"?C:(s.status==="dirty"&&r.dirty(),a(s.value).then(()=>({status:r.value,value:s.value}))))}if(o.type==="transform")if(n.common.async===!1){let a=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!xr(a))return C;let s=o.transform(a.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:n.data,path:n.path,parent:n}).then(a=>xr(a)?Promise.resolve(o.transform(a.value,i)).then(s=>({status:r.value,value:s})):C);X.assertNever(o)}};gt.create=(e,t,r)=>new gt({schema:e,typeName:R.ZodEffects,effect:t,...F(r)});gt.createWithPreprocess=(e,t,r)=>new gt({schema:t,effect:{type:"preprocess",transform:e},typeName:R.ZodEffects,...F(r)});var ht=class extends G{_parse(t){return this._getType(t)===z.undefined?Me(void 0):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}};ht.create=(e,t)=>new ht({innerType:e,typeName:R.ZodOptional,...F(t)});var Ut=class extends G{_parse(t){return this._getType(t)===z.null?Me(null):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}};Ut.create=(e,t)=>new Ut({innerType:e,typeName:R.ZodNullable,...F(t)});var tn=class extends G{_parse(t){let{ctx:r}=this._processInputParams(t),n=r.data;return r.parsedType===z.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:r.path,parent:r})}removeDefault(){return this._def.innerType}};tn.create=(e,t)=>new tn({innerType:e,typeName:R.ZodDefault,defaultValue:typeof t.default=="function"?t.default:()=>t.default,...F(t)});var rn=class extends G{_parse(t){let{ctx:r}=this._processInputParams(t),n={...r,common:{...r.common,issues:[]}},o=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return Wn(o)?o.then(i=>({status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new Ye(n.common.issues)},input:n.data})})):{status:"valid",value:o.status==="valid"?o.value:this._def.catchValue({get error(){return new Ye(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}};rn.create=(e,t)=>new rn({innerType:e,typeName:R.ZodCatch,catchValue:typeof t.catch=="function"?t.catch:()=>t.catch,...F(t)});var to=class extends G{_parse(t){if(this._getType(t)!==z.nan){let n=this._getOrReturnCtx(t);return k(n,{code:_.invalid_type,expected:z.nan,received:n.parsedType}),C}return{status:"valid",value:t.data}}};to.create=e=>new to({typeName:R.ZodNaN,...F(e)});var Ui=class extends G{_parse(t){let{ctx:r}=this._processInputParams(t),n=r.data;return this._def.type._parse({data:n,path:r.path,parent:r})}unwrap(){return this._def.type}},Zi=class e extends G{_parse(t){let{status:r,ctx:n}=this._processInputParams(t);if(n.common.async)return(async()=>{let i=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return i.status==="aborted"?C:i.status==="dirty"?(r.dirty(),Vr(i.value)):this._def.out._parseAsync({data:i.value,path:n.path,parent:n})})();{let o=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return o.status==="aborted"?C:o.status==="dirty"?(r.dirty(),{status:"dirty",value:o.value}):this._def.out._parseSync({data:o.value,path:n.path,parent:n})}}static create(t,r){return new e({in:t,out:r,typeName:R.ZodPipeline})}},nn=class extends G{_parse(t){let r=this._def.innerType._parse(t),n=o=>(xr(o)&&(o.value=Object.freeze(o.value)),o);return Wn(r)?r.then(o=>n(o)):n(r)}unwrap(){return this._def.innerType}};nn.create=(e,t)=>new nn({innerType:e,typeName:R.ZodReadonly,...F(t)});var Aj={object:Xe.lazycreate},R;(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"})(R||(R={}));var Cj=Jr.create,Uj=Jn.create,Zj=to.create,Lj=Hn.create,Fj=Gn.create,qj=Kn.create,Vj=Bn.create,Wj=Hr.create,Jj=Gr.create,Hj=Yn.create,Gj=or.create,Kj=wt.create,Bj=Xn.create,Yj=ir.create,ex=Xe.create,Xj=Xe.strictCreate,Qj=Kr.create,eD=uc.create,tD=Br.create,rD=Ct.create,nD=dc.create,oD=Qn.create,iD=eo.create,aD=pc.create,sD=Yr.create,cD=Xr.create,uD=Qr.create,lD=en.create,dD=Sr.create,pD=gt.create,fD=ht.create,mD=Ut.create,hD=gt.createWithPreprocess,gD=Zi.create;var wm=Object.freeze({status:"aborted"});function m(e,t,r){function n(s,c){if(s._zod||Object.defineProperty(s,"_zod",{value:{def:c,constr:a,traits:new Set},enumerable:!1}),s._zod.traits.has(e))return;s._zod.traits.add(e),t(s,c);let u=a.prototype,l=Object.keys(u);for(let d=0;d<l.length;d++){let p=l[d];p in s||(s[p]=u[p].bind(s))}}let o=r?.Parent??Object;class i extends o{}Object.defineProperty(i,"name",{value:e});function a(s){var c;let u=r?.Parent?new i:this;n(u,s),(c=u._zod).deferred??(c.deferred=[]);for(let l of u._zod.deferred)l();return u}return Object.defineProperty(a,"init",{value:n}),Object.defineProperty(a,Symbol.hasInstance,{value:s=>r?.Parent&&s instanceof r.Parent?!0:s?._zod?.traits?.has(e)}),Object.defineProperty(a,"name",{value:e}),a}var Et=class extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}},kr=class extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}},Li={};function be(e){return e&&Object.assign(Li,e),Li}var $={};Fn($,{BIGINT_FORMAT_RANGES:()=>bc,Class:()=>mc,NUMBER_FORMAT_RANGES:()=>$c,aborted:()=>ur,allowsEval:()=>vc,assert:()=>sx,assertEqual:()=>nx,assertIs:()=>ix,assertNever:()=>ax,assertNotEqual:()=>ox,assignProp:()=>sr,base64ToUint8Array:()=>zm,base64urlToUint8Array:()=>kx,cached:()=>an,captureStackTrace:()=>qi,cleanEnum:()=>Sx,cleanRegex:()=>oo,clone:()=>Ae,cloneDef:()=>ux,createTransparentProxy:()=>hx,defineLazy:()=>W,esc:()=>Fi,escapeRegex:()=>ot,extend:()=>_x,finalizeIssue:()=>Je,floatSafeRemainder:()=>hc,getElementAtPath:()=>lx,getEnumValues:()=>no,getLengthableOrigin:()=>so,getParsedType:()=>mx,getSizableOrigin:()=>ao,hexToUint8Array:()=>Ex,isObject:()=>wr,isPlainObject:()=>cr,issue:()=>sn,joinValues:()=>M,jsonStringifyReplacer:()=>on,merge:()=>$x,mergeDefs:()=>Zt,normalizeParams:()=>E,nullish:()=>ar,numKeys:()=>fx,objectClone:()=>cx,omit:()=>vx,optionalKeys:()=>yc,parsedType:()=>U,partial:()=>bx,pick:()=>gx,prefixIssues:()=>Qe,primitiveTypes:()=>_c,promiseAllObject:()=>dx,propertyKeyTypes:()=>io,randomString:()=>px,required:()=>xx,safeExtend:()=>yx,shallowClone:()=>Im,slugify:()=>gc,stringifyPrimitive:()=>A,uint8ArrayToBase64:()=>Pm,uint8ArrayToBase64url:()=>wx,uint8ArrayToHex:()=>Ix,unwrapMessage:()=>ro});function nx(e){return e}function ox(e){return e}function ix(e){}function ax(e){throw new Error("Unexpected value in exhaustive check")}function sx(e){}function no(e){let t=Object.values(e).filter(n=>typeof n=="number");return Object.entries(e).filter(([n,o])=>t.indexOf(+n)===-1).map(([n,o])=>o)}function M(e,t="|"){return e.map(r=>A(r)).join(t)}function on(e,t){return typeof t=="bigint"?t.toString():t}function an(e){return{get value(){{let r=e();return Object.defineProperty(this,"value",{value:r}),r}throw new Error("cached value already set")}}}function ar(e){return e==null}function oo(e){let t=e.startsWith("^")?1:0,r=e.endsWith("$")?e.length-1:e.length;return e.slice(t,r)}function hc(e,t){let r=(e.toString().split(".")[1]||"").length,n=t.toString(),o=(n.split(".")[1]||"").length;if(o===0&&/\d?e-\d?/.test(n)){let c=n.match(/\d?e-(\d?)/);c?.[1]&&(o=Number.parseInt(c[1]))}let i=r>o?r:o,a=Number.parseInt(e.toFixed(i).replace(".","")),s=Number.parseInt(t.toFixed(i).replace(".",""));return a%s/10**i}var Em=Symbol("evaluating");function W(e,t,r){let n;Object.defineProperty(e,t,{get(){if(n!==Em)return n===void 0&&(n=Em,n=r()),n},set(o){Object.defineProperty(e,t,{value:o})},configurable:!0})}function cx(e){return Object.create(Object.getPrototypeOf(e),Object.getOwnPropertyDescriptors(e))}function sr(e,t,r){Object.defineProperty(e,t,{value:r,writable:!0,enumerable:!0,configurable:!0})}function Zt(...e){let t={};for(let r of e){let n=Object.getOwnPropertyDescriptors(r);Object.assign(t,n)}return Object.defineProperties({},t)}function ux(e){return Zt(e._zod.def)}function lx(e,t){return t?t.reduce((r,n)=>r?.[n],e):e}function dx(e){let t=Object.keys(e),r=t.map(n=>e[n]);return Promise.all(r).then(n=>{let o={};for(let i=0;i<t.length;i++)o[t[i]]=n[i];return o})}function px(e=10){let t="abcdefghijklmnopqrstuvwxyz",r="";for(let n=0;n<e;n++)r+=t[Math.floor(Math.random()*t.length)];return r}function Fi(e){return JSON.stringify(e)}function gc(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}var qi="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function wr(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}var vc=an(()=>{if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{let e=Function;return new e(""),!0}catch{return!1}});function cr(e){if(wr(e)===!1)return!1;let t=e.constructor;if(t===void 0||typeof t!="function")return!0;let r=t.prototype;return!(wr(r)===!1||Object.prototype.hasOwnProperty.call(r,"isPrototypeOf")===!1)}function Im(e){return cr(e)?{...e}:Array.isArray(e)?[...e]:e}function fx(e){let t=0;for(let r in e)Object.prototype.hasOwnProperty.call(e,r)&&t++;return t}var mx=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}`)}},io=new Set(["string","number","symbol"]),_c=new Set(["string","number","bigint","boolean","symbol","undefined"]);function ot(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Ae(e,t,r){let n=new e._zod.constr(t??e._zod.def);return(!t||r?.parent)&&(n._zod.parent=e),n}function E(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 hx(e){let t;return new Proxy({},{get(r,n,o){return t??(t=e()),Reflect.get(t,n,o)},set(r,n,o,i){return t??(t=e()),Reflect.set(t,n,o,i)},has(r,n){return t??(t=e()),Reflect.has(t,n)},deleteProperty(r,n){return t??(t=e()),Reflect.deleteProperty(t,n)},ownKeys(r){return t??(t=e()),Reflect.ownKeys(t)},getOwnPropertyDescriptor(r,n){return t??(t=e()),Reflect.getOwnPropertyDescriptor(t,n)},defineProperty(r,n,o){return t??(t=e()),Reflect.defineProperty(t,n,o)}})}function A(e){return typeof e=="bigint"?e.toString()+"n":typeof e=="string"?`"${e}"`:`${e}`}function yc(e){return Object.keys(e).filter(t=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}var $c={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]},bc={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};function gx(e,t){let r=e._zod.def,n=r.checks;if(n&&n.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");let i=Zt(e._zod.def,{get shape(){let a={};for(let s in t){if(!(s in r.shape))throw new Error(`Unrecognized key: "${s}"`);t[s]&&(a[s]=r.shape[s])}return sr(this,"shape",a),a},checks:[]});return Ae(e,i)}function vx(e,t){let r=e._zod.def,n=r.checks;if(n&&n.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");let i=Zt(e._zod.def,{get shape(){let a={...e._zod.def.shape};for(let s in t){if(!(s in r.shape))throw new Error(`Unrecognized key: "${s}"`);t[s]&&delete a[s]}return sr(this,"shape",a),a},checks:[]});return Ae(e,i)}function _x(e,t){if(!cr(t))throw new Error("Invalid input to extend: expected a plain object");let r=e._zod.def.checks;if(r&&r.length>0){let i=e._zod.def.shape;for(let a in t)if(Object.getOwnPropertyDescriptor(i,a)!==void 0)throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}let o=Zt(e._zod.def,{get shape(){let i={...e._zod.def.shape,...t};return sr(this,"shape",i),i}});return Ae(e,o)}function yx(e,t){if(!cr(t))throw new Error("Invalid input to safeExtend: expected a plain object");let r=Zt(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t};return sr(this,"shape",n),n}});return Ae(e,r)}function $x(e,t){let r=Zt(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t._zod.def.shape};return sr(this,"shape",n),n},get catchall(){return t._zod.def.catchall},checks:[]});return Ae(e,r)}function bx(e,t,r){let o=t._zod.def.checks;if(o&&o.length>0)throw new Error(".partial() cannot be used on object schemas containing refinements");let a=Zt(t._zod.def,{get shape(){let s=t._zod.def.shape,c={...s};if(r)for(let u in r){if(!(u in s))throw new Error(`Unrecognized key: "${u}"`);r[u]&&(c[u]=e?new e({type:"optional",innerType:s[u]}):s[u])}else for(let u in s)c[u]=e?new e({type:"optional",innerType:s[u]}):s[u];return sr(this,"shape",c),c},checks:[]});return Ae(t,a)}function xx(e,t,r){let n=Zt(t._zod.def,{get shape(){let o=t._zod.def.shape,i={...o};if(r)for(let a in r){if(!(a in i))throw new Error(`Unrecognized key: "${a}"`);r[a]&&(i[a]=new e({type:"nonoptional",innerType:o[a]}))}else for(let a in o)i[a]=new e({type:"nonoptional",innerType:o[a]});return sr(this,"shape",i),i}});return Ae(t,n)}function ur(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 Qe(e,t){return t.map(r=>{var n;return(n=r).path??(n.path=[]),r.path.unshift(e),r})}function ro(e){return typeof e=="string"?e:e?.message}function Je(e,t,r){let n={...e,path:e.path??[]};if(!e.message){let o=ro(e.inst?._zod.def?.error?.(e))??ro(t?.error?.(e))??ro(r.customError?.(e))??ro(r.localeError?.(e))??"Invalid input";n.message=o}return delete n.inst,delete n.continue,t?.reportInput||delete n.input,n}function ao(e){return e instanceof Set?"set":e instanceof Map?"map":e instanceof File?"file":"unknown"}function so(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function U(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 sn(...e){let[t,r,n]=e;return typeof t=="string"?{message:t,code:"custom",input:r,inst:n}:{...t}}function Sx(e){return Object.entries(e).filter(([t,r])=>Number.isNaN(Number.parseInt(t,10))).map(t=>t[1])}function zm(e){let t=atob(e),r=new Uint8Array(t.length);for(let n=0;n<t.length;n++)r[n]=t.charCodeAt(n);return r}function Pm(e){let t="";for(let r=0;r<e.length;r++)t+=String.fromCharCode(e[r]);return btoa(t)}function kx(e){let t=e.replace(/-/g,"+").replace(/_/g,"/"),r="=".repeat((4-t.length%4)%4);return zm(t+r)}function wx(e){return Pm(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function Ex(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 n=0;n<t.length;n+=2)r[n/2]=Number.parseInt(t.slice(n,n+2),16);return r}function Ix(e){return Array.from(e).map(t=>t.toString(16).padStart(2,"0")).join("")}var mc=class{constructor(...t){}};var Tm=(e,t)=>{e.name="$ZodError",Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:t,enumerable:!1}),e.message=JSON.stringify(t,on,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},Vi=m("$ZodError",Tm),co=m("$ZodError",Tm,{Parent:Error});function Wi(e,t=r=>r.message){let r={},n=[];for(let o of e.issues)o.path.length>0?(r[o.path[0]]=r[o.path[0]]||[],r[o.path[0]].push(t(o))):n.push(t(o));return{formErrors:n,fieldErrors:r}}function Ji(e,t=r=>r.message){let r={_errors:[]},n=o=>{for(let i of o.issues)if(i.code==="invalid_union"&&i.errors.length)i.errors.map(a=>n({issues:a}));else if(i.code==="invalid_key")n({issues:i.issues});else if(i.code==="invalid_element")n({issues:i.issues});else if(i.path.length===0)r._errors.push(t(i));else{let a=r,s=0;for(;s<i.path.length;){let c=i.path[s];s===i.path.length-1?(a[c]=a[c]||{_errors:[]},a[c]._errors.push(t(i))):a[c]=a[c]||{_errors:[]},a=a[c],s++}}};return n(e),r}var uo=e=>(t,r,n,o)=>{let i=n?Object.assign(n,{async:!1}):{async:!1},a=t._zod.run({value:r,issues:[]},i);if(a instanceof Promise)throw new Et;if(a.issues.length){let s=new(o?.Err??e)(a.issues.map(c=>Je(c,i,be())));throw qi(s,o?.callee),s}return a.value},lo=uo(co),po=e=>async(t,r,n,o)=>{let i=n?Object.assign(n,{async:!0}):{async:!0},a=t._zod.run({value:r,issues:[]},i);if(a instanceof Promise&&(a=await a),a.issues.length){let s=new(o?.Err??e)(a.issues.map(c=>Je(c,i,be())));throw qi(s,o?.callee),s}return a.value},fo=po(co),mo=e=>(t,r,n)=>{let o=n?{...n,async:!1}:{async:!1},i=t._zod.run({value:r,issues:[]},o);if(i instanceof Promise)throw new Et;return i.issues.length?{success:!1,error:new(e??Vi)(i.issues.map(a=>Je(a,o,be())))}:{success:!0,data:i.value}},cn=mo(co),ho=e=>async(t,r,n)=>{let o=n?Object.assign(n,{async:!0}):{async:!0},i=t._zod.run({value:r,issues:[]},o);return i instanceof Promise&&(i=await i),i.issues.length?{success:!1,error:new e(i.issues.map(a=>Je(a,o,be())))}:{success:!0,data:i.value}},go=ho(co),Om=e=>(t,r,n)=>{let o=n?Object.assign(n,{direction:"backward"}):{direction:"backward"};return uo(e)(t,r,o)};var jm=e=>(t,r,n)=>uo(e)(t,r,n);var Dm=e=>async(t,r,n)=>{let o=n?Object.assign(n,{direction:"backward"}):{direction:"backward"};return po(e)(t,r,o)};var Nm=e=>async(t,r,n)=>po(e)(t,r,n);var Rm=e=>(t,r,n)=>{let o=n?Object.assign(n,{direction:"backward"}):{direction:"backward"};return mo(e)(t,r,o)};var Mm=e=>(t,r,n)=>mo(e)(t,r,n);var Am=e=>async(t,r,n)=>{let o=n?Object.assign(n,{direction:"backward"}):{direction:"backward"};return ho(e)(t,r,o)};var Cm=e=>async(t,r,n)=>ho(e)(t,r,n);var it={};Fn(it,{base64:()=>Ac,base64url:()=>Hi,bigint:()=>qc,boolean:()=>Wc,browserEmail:()=>Mx,cidrv4:()=>Rc,cidrv6:()=>Mc,cuid:()=>xc,cuid2:()=>Sc,date:()=>Uc,datetime:()=>Lc,domain:()=>Ux,duration:()=>zc,e164:()=>Cc,email:()=>Tc,emoji:()=>Oc,extendedDuration:()=>Px,guid:()=>Pc,hex:()=>Zx,hostname:()=>Cx,html5Email:()=>Dx,idnEmail:()=>Rx,integer:()=>Vc,ipv4:()=>jc,ipv6:()=>Dc,ksuid:()=>Ec,lowercase:()=>Gc,mac:()=>Nc,md5_base64:()=>Fx,md5_base64url:()=>qx,md5_hex:()=>Lx,nanoid:()=>Ic,null:()=>Jc,number:()=>Gi,rfc5322Email:()=>Nx,sha1_base64:()=>Wx,sha1_base64url:()=>Jx,sha1_hex:()=>Vx,sha256_base64:()=>Gx,sha256_base64url:()=>Kx,sha256_hex:()=>Hx,sha384_base64:()=>Yx,sha384_base64url:()=>Xx,sha384_hex:()=>Bx,sha512_base64:()=>eS,sha512_base64url:()=>tS,sha512_hex:()=>Qx,string:()=>Fc,time:()=>Zc,ulid:()=>kc,undefined:()=>Hc,unicodeEmail:()=>Um,uppercase:()=>Kc,uuid:()=>Er,uuid4:()=>Tx,uuid6:()=>Ox,uuid7:()=>jx,xid:()=>wc});var xc=/^[cC][^\s-]{8,}$/,Sc=/^[0-9a-z]+$/,kc=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,wc=/^[0-9a-vA-V]{20}$/,Ec=/^[A-Za-z0-9]{27}$/,Ic=/^[a-zA-Z0-9_-]{21}$/,zc=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,Px=/^[-+]?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)?)??$/,Pc=/^([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})$/,Er=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)$/,Tx=Er(4),Ox=Er(6),jx=Er(7),Tc=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,Dx=/^[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])?)*$/,Nx=/^(([^<>()\[\]\\.,;:\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,}))$/,Um=/^[^\s@"]{1,64}@[^\s@]{1,255}$/u,Rx=Um,Mx=/^[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])?)*$/,Ax="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function Oc(){return new RegExp(Ax,"u")}var jc=/^(?:(?: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])$/,Dc=/^(([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}|:))$/,Nc=e=>{let t=ot(e??":");return new RegExp(`^(?:[0-9A-F]{2}${t}){5}[0-9A-F]{2}$|^(?:[0-9a-f]{2}${t}){5}[0-9a-f]{2}$`)},Rc=/^((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])$/,Mc=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,Ac=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Hi=/^[A-Za-z0-9_-]*$/,Cx=/^(?=.{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])?)*\.?$/,Ux=/^([a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,}$/,Cc=/^\+[1-9]\d{6,14}$/,Zm="(?:(?:\\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])))",Uc=new RegExp(`^${Zm}$`);function Lm(e){let t="(?:[01]\\d|2[0-3]):[0-5]\\d";return typeof e.precision=="number"?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function Zc(e){return new RegExp(`^${Lm(e)}$`)}function Lc(e){let t=Lm({precision:e.precision}),r=["Z"];e.local&&r.push(""),e.offset&&r.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");let n=`${t}(?:${r.join("|")})`;return new RegExp(`^${Zm}T(?:${n})$`)}var Fc=e=>{let t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)},qc=/^-?\d+n?$/,Vc=/^-?\d+$/,Gi=/^-?\d+(?:\.\d+)?$/,Wc=/^(?:true|false)$/i,Jc=/^null$/i;var Hc=/^undefined$/i;var Gc=/^[^A-Z]*$/,Kc=/^[^a-z]*$/,Zx=/^[0-9a-fA-F]*$/;function vo(e,t){return new RegExp(`^[A-Za-z0-9+/]{${e}}${t}$`)}function _o(e){return new RegExp(`^[A-Za-z0-9_-]{${e}}$`)}var Lx=/^[0-9a-fA-F]{32}$/,Fx=vo(22,"=="),qx=_o(22),Vx=/^[0-9a-fA-F]{40}$/,Wx=vo(27,"="),Jx=_o(27),Hx=/^[0-9a-fA-F]{64}$/,Gx=vo(43,"="),Kx=_o(43),Bx=/^[0-9a-fA-F]{96}$/,Yx=vo(64,""),Xx=_o(64),Qx=/^[0-9a-fA-F]{128}$/,eS=vo(86,"=="),tS=_o(86);var ce=m("$ZodCheck",(e,t)=>{var r;e._zod??(e._zod={}),e._zod.def=t,(r=e._zod).onattach??(r.onattach=[])}),qm={number:"number",bigint:"bigint",object:"date"},Bc=m("$ZodCheckLessThan",(e,t)=>{ce.init(e,t);let r=qm[typeof t.value];e._zod.onattach.push(n=>{let o=n._zod.bag,i=(t.inclusive?o.maximum:o.exclusiveMaximum)??Number.POSITIVE_INFINITY;t.value<i&&(t.inclusive?o.maximum=t.value:o.exclusiveMaximum=t.value)}),e._zod.check=n=>{(t.inclusive?n.value<=t.value:n.value<t.value)||n.issues.push({origin:r,code:"too_big",maximum:typeof t.value=="object"?t.value.getTime():t.value,input:n.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Yc=m("$ZodCheckGreaterThan",(e,t)=>{ce.init(e,t);let r=qm[typeof t.value];e._zod.onattach.push(n=>{let o=n._zod.bag,i=(t.inclusive?o.minimum:o.exclusiveMinimum)??Number.NEGATIVE_INFINITY;t.value>i&&(t.inclusive?o.minimum=t.value:o.exclusiveMinimum=t.value)}),e._zod.check=n=>{(t.inclusive?n.value>=t.value:n.value>t.value)||n.issues.push({origin:r,code:"too_small",minimum:typeof t.value=="object"?t.value.getTime():t.value,input:n.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Vm=m("$ZodCheckMultipleOf",(e,t)=>{ce.init(e,t),e._zod.onattach.push(r=>{var n;(n=r._zod.bag).multipleOf??(n.multipleOf=t.value)}),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"?r.value%t.value===BigInt(0):hc(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})}}),Wm=m("$ZodCheckNumberFormat",(e,t)=>{ce.init(e,t),t.format=t.format||"float64";let r=t.format?.includes("int"),n=r?"int":"number",[o,i]=$c[t.format];e._zod.onattach.push(a=>{let s=a._zod.bag;s.format=t.format,s.minimum=o,s.maximum=i,r&&(s.pattern=Vc)}),e._zod.check=a=>{let s=a.value;if(r){if(!Number.isInteger(s)){a.issues.push({expected:n,format:t.format,code:"invalid_type",continue:!1,input:s,inst:e});return}if(!Number.isSafeInteger(s)){s>0?a.issues.push({input:s,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:n,inclusive:!0,continue:!t.abort}):a.issues.push({input:s,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:n,inclusive:!0,continue:!t.abort});return}}s<o&&a.issues.push({origin:"number",input:s,code:"too_small",minimum:o,inclusive:!0,inst:e,continue:!t.abort}),s>i&&a.issues.push({origin:"number",input:s,code:"too_big",maximum:i,inclusive:!0,inst:e,continue:!t.abort})}}),Jm=m("$ZodCheckBigIntFormat",(e,t)=>{ce.init(e,t);let[r,n]=bc[t.format];e._zod.onattach.push(o=>{let i=o._zod.bag;i.format=t.format,i.minimum=r,i.maximum=n}),e._zod.check=o=>{let i=o.value;i<r&&o.issues.push({origin:"bigint",input:i,code:"too_small",minimum:r,inclusive:!0,inst:e,continue:!t.abort}),i>n&&o.issues.push({origin:"bigint",input:i,code:"too_big",maximum:n,inclusive:!0,inst:e,continue:!t.abort})}}),Hm=m("$ZodCheckMaxSize",(e,t)=>{var r;ce.init(e,t),(r=e._zod.def).when??(r.when=n=>{let o=n.value;return!ar(o)&&o.size!==void 0}),e._zod.onattach.push(n=>{let o=n._zod.bag.maximum??Number.POSITIVE_INFINITY;t.maximum<o&&(n._zod.bag.maximum=t.maximum)}),e._zod.check=n=>{let o=n.value;o.size<=t.maximum||n.issues.push({origin:ao(o),code:"too_big",maximum:t.maximum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),Gm=m("$ZodCheckMinSize",(e,t)=>{var r;ce.init(e,t),(r=e._zod.def).when??(r.when=n=>{let o=n.value;return!ar(o)&&o.size!==void 0}),e._zod.onattach.push(n=>{let o=n._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>o&&(n._zod.bag.minimum=t.minimum)}),e._zod.check=n=>{let o=n.value;o.size>=t.minimum||n.issues.push({origin:ao(o),code:"too_small",minimum:t.minimum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),Km=m("$ZodCheckSizeEquals",(e,t)=>{var r;ce.init(e,t),(r=e._zod.def).when??(r.when=n=>{let o=n.value;return!ar(o)&&o.size!==void 0}),e._zod.onattach.push(n=>{let o=n._zod.bag;o.minimum=t.size,o.maximum=t.size,o.size=t.size}),e._zod.check=n=>{let o=n.value,i=o.size;if(i===t.size)return;let a=i>t.size;n.issues.push({origin:ao(o),...a?{code:"too_big",maximum:t.size}:{code:"too_small",minimum:t.size},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}}),Bm=m("$ZodCheckMaxLength",(e,t)=>{var r;ce.init(e,t),(r=e._zod.def).when??(r.when=n=>{let o=n.value;return!ar(o)&&o.length!==void 0}),e._zod.onattach.push(n=>{let o=n._zod.bag.maximum??Number.POSITIVE_INFINITY;t.maximum<o&&(n._zod.bag.maximum=t.maximum)}),e._zod.check=n=>{let o=n.value;if(o.length<=t.maximum)return;let a=so(o);n.issues.push({origin:a,code:"too_big",maximum:t.maximum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),Ym=m("$ZodCheckMinLength",(e,t)=>{var r;ce.init(e,t),(r=e._zod.def).when??(r.when=n=>{let o=n.value;return!ar(o)&&o.length!==void 0}),e._zod.onattach.push(n=>{let o=n._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>o&&(n._zod.bag.minimum=t.minimum)}),e._zod.check=n=>{let o=n.value;if(o.length>=t.minimum)return;let a=so(o);n.issues.push({origin:a,code:"too_small",minimum:t.minimum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),Xm=m("$ZodCheckLengthEquals",(e,t)=>{var r;ce.init(e,t),(r=e._zod.def).when??(r.when=n=>{let o=n.value;return!ar(o)&&o.length!==void 0}),e._zod.onattach.push(n=>{let o=n._zod.bag;o.minimum=t.length,o.maximum=t.length,o.length=t.length}),e._zod.check=n=>{let o=n.value,i=o.length;if(i===t.length)return;let a=so(o),s=i>t.length;n.issues.push({origin:a,...s?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}}),yo=m("$ZodCheckStringFormat",(e,t)=>{var r,n;ce.init(e,t),e._zod.onattach.push(o=>{let i=o._zod.bag;i.format=t.format,t.pattern&&(i.patterns??(i.patterns=new Set),i.patterns.add(t.pattern))}),t.pattern?(r=e._zod).check??(r.check=o=>{t.pattern.lastIndex=0,!t.pattern.test(o.value)&&o.issues.push({origin:"string",code:"invalid_format",format:t.format,input:o.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(n=e._zod).check??(n.check=()=>{})}),Qm=m("$ZodCheckRegex",(e,t)=>{yo.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})}}),eh=m("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=Gc),yo.init(e,t)}),th=m("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=Kc),yo.init(e,t)}),rh=m("$ZodCheckIncludes",(e,t)=>{ce.init(e,t);let r=ot(t.includes),n=new RegExp(typeof t.position=="number"?`^.{${t.position}}${r}`:r);t.pattern=n,e._zod.onattach.push(o=>{let i=o._zod.bag;i.patterns??(i.patterns=new Set),i.patterns.add(n)}),e._zod.check=o=>{o.value.includes(t.includes,t.position)||o.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:o.value,inst:e,continue:!t.abort})}}),nh=m("$ZodCheckStartsWith",(e,t)=>{ce.init(e,t);let r=new RegExp(`^${ot(t.prefix)}.*`);t.pattern??(t.pattern=r),e._zod.onattach.push(n=>{let o=n._zod.bag;o.patterns??(o.patterns=new Set),o.patterns.add(r)}),e._zod.check=n=>{n.value.startsWith(t.prefix)||n.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:n.value,inst:e,continue:!t.abort})}}),oh=m("$ZodCheckEndsWith",(e,t)=>{ce.init(e,t);let r=new RegExp(`.*${ot(t.suffix)}$`);t.pattern??(t.pattern=r),e._zod.onattach.push(n=>{let o=n._zod.bag;o.patterns??(o.patterns=new Set),o.patterns.add(r)}),e._zod.check=n=>{n.value.endsWith(t.suffix)||n.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:n.value,inst:e,continue:!t.abort})}});function Fm(e,t,r){e.issues.length&&t.issues.push(...Qe(r,e.issues))}var ih=m("$ZodCheckProperty",(e,t)=>{ce.init(e,t),e._zod.check=r=>{let n=t.schema._zod.run({value:r.value[t.property],issues:[]},{});if(n instanceof Promise)return n.then(o=>Fm(o,r,t.property));Fm(n,r,t.property)}}),ah=m("$ZodCheckMimeType",(e,t)=>{ce.init(e,t);let r=new Set(t.mime);e._zod.onattach.push(n=>{n._zod.bag.mime=t.mime}),e._zod.check=n=>{r.has(n.value.type)||n.issues.push({code:"invalid_value",values:t.mime,input:n.value.type,inst:e,continue:!t.abort})}}),sh=m("$ZodCheckOverwrite",(e,t)=>{ce.init(e,t),e._zod.check=r=>{r.value=t.tx(r.value)}});var Ki=class{constructor(t=[]){this.content=[],this.indent=0,this&&(this.args=t)}indented(t){this.indent+=1,t(this),this.indent-=1}write(t){if(typeof t=="function"){t(this,{execution:"sync"}),t(this,{execution:"async"});return}let n=t.split(`
|
|
`).filter(a=>a),o=Math.min(...n.map(a=>a.length-a.trimStart().length)),i=n.map(a=>a.slice(o)).map(a=>" ".repeat(this.indent*2)+a);for(let a of i)this.content.push(a)}compile(){let t=Function,r=this?.args,o=[...(this?.content??[""]).map(i=>` ${i}`)];return new t(...r,o.join(`
|
|
`))}};var uh={major:4,minor:3,patch:4};var L=m("$ZodType",(e,t)=>{var r;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=uh;let n=[...e._zod.def.checks??[]];e._zod.traits.has("$ZodCheck")&&n.unshift(e);for(let o of n)for(let i of o._zod.onattach)i(e);if(n.length===0)(r=e._zod).deferred??(r.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let o=(a,s,c)=>{let u=ur(a),l;for(let d of s){if(d._zod.def.when){if(!d._zod.def.when(a))continue}else if(u)continue;let p=a.issues.length,f=d._zod.check(a);if(f instanceof Promise&&c?.async===!1)throw new Et;if(l||f instanceof Promise)l=(l??Promise.resolve()).then(async()=>{await f,a.issues.length!==p&&(u||(u=ur(a,p)))});else{if(a.issues.length===p)continue;u||(u=ur(a,p))}}return l?l.then(()=>a):a},i=(a,s,c)=>{if(ur(a))return a.aborted=!0,a;let u=o(s,n,c);if(u instanceof Promise){if(c.async===!1)throw new Et;return u.then(l=>e._zod.parse(l,c))}return e._zod.parse(u,c)};e._zod.run=(a,s)=>{if(s.skipChecks)return e._zod.parse(a,s);if(s.direction==="backward"){let u=e._zod.parse({value:a.value,issues:[]},{...s,skipChecks:!0});return u instanceof Promise?u.then(l=>i(l,a,s)):i(u,a,s)}let c=e._zod.parse(a,s);if(c instanceof Promise){if(s.async===!1)throw new Et;return c.then(u=>o(u,n,s))}return o(c,n,s)}}W(e,"~standard",()=>({validate:o=>{try{let i=cn(e,o);return i.success?{value:i.data}:{issues:i.error?.issues}}catch{return go(e,o).then(a=>a.success?{value:a.data}:{issues:a.error?.issues})}},vendor:"zod",version:1}))}),Ir=m("$ZodString",(e,t)=>{L.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??Fc(e._zod.bag),e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=String(r.value)}catch{}return typeof r.value=="string"||r.issues.push({expected:"string",code:"invalid_type",input:r.value,inst:e}),r}}),ie=m("$ZodStringFormat",(e,t)=>{yo.init(e,t),Ir.init(e,t)}),Qc=m("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=Pc),ie.init(e,t)}),eu=m("$ZodUUID",(e,t)=>{if(t.version){let n={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(n===void 0)throw new Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=Er(n))}else t.pattern??(t.pattern=Er());ie.init(e,t)}),tu=m("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=Tc),ie.init(e,t)}),ru=m("$ZodURL",(e,t)=>{ie.init(e,t),e._zod.check=r=>{try{let n=r.value.trim(),o=new URL(n);t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(o.hostname)||r.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:t.hostname.source,input:r.value,inst:e,continue:!t.abort})),t.protocol&&(t.protocol.lastIndex=0,t.protocol.test(o.protocol.endsWith(":")?o.protocol.slice(0,-1):o.protocol)||r.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:r.value,inst:e,continue:!t.abort})),t.normalize?r.value=o.href:r.value=n;return}catch{r.issues.push({code:"invalid_format",format:"url",input:r.value,inst:e,continue:!t.abort})}}}),nu=m("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=Oc()),ie.init(e,t)}),ou=m("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=Ic),ie.init(e,t)}),iu=m("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=xc),ie.init(e,t)}),au=m("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=Sc),ie.init(e,t)}),su=m("$ZodULID",(e,t)=>{t.pattern??(t.pattern=kc),ie.init(e,t)}),cu=m("$ZodXID",(e,t)=>{t.pattern??(t.pattern=wc),ie.init(e,t)}),uu=m("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=Ec),ie.init(e,t)}),lu=m("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=Lc(t)),ie.init(e,t)}),du=m("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=Uc),ie.init(e,t)}),pu=m("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=Zc(t)),ie.init(e,t)}),fu=m("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=zc),ie.init(e,t)}),mu=m("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=jc),ie.init(e,t),e._zod.bag.format="ipv4"}),hu=m("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=Dc),ie.init(e,t),e._zod.bag.format="ipv6",e._zod.check=r=>{try{new URL(`http://[${r.value}]`)}catch{r.issues.push({code:"invalid_format",format:"ipv6",input:r.value,inst:e,continue:!t.abort})}}}),gu=m("$ZodMAC",(e,t)=>{t.pattern??(t.pattern=Nc(t.delimiter)),ie.init(e,t),e._zod.bag.format="mac"}),vu=m("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=Rc),ie.init(e,t)}),_u=m("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=Mc),ie.init(e,t),e._zod.check=r=>{let n=r.value.split("/");try{if(n.length!==2)throw new Error;let[o,i]=n;if(!i)throw new Error;let a=Number(i);if(`${a}`!==i)throw new Error;if(a<0||a>128)throw new Error;new URL(`http://[${o}]`)}catch{r.issues.push({code:"invalid_format",format:"cidrv6",input:r.value,inst:e,continue:!t.abort})}}});function bh(e){if(e==="")return!0;if(e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}var yu=m("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=Ac),ie.init(e,t),e._zod.bag.contentEncoding="base64",e._zod.check=r=>{bh(r.value)||r.issues.push({code:"invalid_format",format:"base64",input:r.value,inst:e,continue:!t.abort})}});function rS(e){if(!Hi.test(e))return!1;let t=e.replace(/[-_]/g,n=>n==="-"?"+":"/"),r=t.padEnd(Math.ceil(t.length/4)*4,"=");return bh(r)}var $u=m("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=Hi),ie.init(e,t),e._zod.bag.contentEncoding="base64url",e._zod.check=r=>{rS(r.value)||r.issues.push({code:"invalid_format",format:"base64url",input:r.value,inst:e,continue:!t.abort})}}),bu=m("$ZodE164",(e,t)=>{t.pattern??(t.pattern=Cc),ie.init(e,t)});function nS(e,t=null){try{let r=e.split(".");if(r.length!==3)return!1;let[n]=r;if(!n)return!1;let o=JSON.parse(atob(n));return!("typ"in o&&o?.typ!=="JWT"||!o.alg||t&&(!("alg"in o)||o.alg!==t))}catch{return!1}}var xu=m("$ZodJWT",(e,t)=>{ie.init(e,t),e._zod.check=r=>{nS(r.value,t.alg)||r.issues.push({code:"invalid_format",format:"jwt",input:r.value,inst:e,continue:!t.abort})}}),Su=m("$ZodCustomStringFormat",(e,t)=>{ie.init(e,t),e._zod.check=r=>{t.fn(r.value)||r.issues.push({code:"invalid_format",format:t.format,input:r.value,inst:e,continue:!t.abort})}}),ta=m("$ZodNumber",(e,t)=>{L.init(e,t),e._zod.pattern=e._zod.bag.pattern??Gi,e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=Number(r.value)}catch{}let o=r.value;if(typeof o=="number"&&!Number.isNaN(o)&&Number.isFinite(o))return r;let i=typeof o=="number"?Number.isNaN(o)?"NaN":Number.isFinite(o)?void 0:"Infinity":void 0;return r.issues.push({expected:"number",code:"invalid_type",input:o,inst:e,...i?{received:i}:{}}),r}}),ku=m("$ZodNumberFormat",(e,t)=>{Wm.init(e,t),ta.init(e,t)}),$o=m("$ZodBoolean",(e,t)=>{L.init(e,t),e._zod.pattern=Wc,e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=!!r.value}catch{}let o=r.value;return typeof o=="boolean"||r.issues.push({expected:"boolean",code:"invalid_type",input:o,inst:e}),r}}),ra=m("$ZodBigInt",(e,t)=>{L.init(e,t),e._zod.pattern=qc,e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=BigInt(r.value)}catch{}return typeof r.value=="bigint"||r.issues.push({expected:"bigint",code:"invalid_type",input:r.value,inst:e}),r}}),wu=m("$ZodBigIntFormat",(e,t)=>{Jm.init(e,t),ra.init(e,t)}),Eu=m("$ZodSymbol",(e,t)=>{L.init(e,t),e._zod.parse=(r,n)=>{let o=r.value;return typeof o=="symbol"||r.issues.push({expected:"symbol",code:"invalid_type",input:o,inst:e}),r}}),Iu=m("$ZodUndefined",(e,t)=>{L.init(e,t),e._zod.pattern=Hc,e._zod.values=new Set([void 0]),e._zod.optin="optional",e._zod.optout="optional",e._zod.parse=(r,n)=>{let o=r.value;return typeof o>"u"||r.issues.push({expected:"undefined",code:"invalid_type",input:o,inst:e}),r}}),zu=m("$ZodNull",(e,t)=>{L.init(e,t),e._zod.pattern=Jc,e._zod.values=new Set([null]),e._zod.parse=(r,n)=>{let o=r.value;return o===null||r.issues.push({expected:"null",code:"invalid_type",input:o,inst:e}),r}}),Pu=m("$ZodAny",(e,t)=>{L.init(e,t),e._zod.parse=r=>r}),Tu=m("$ZodUnknown",(e,t)=>{L.init(e,t),e._zod.parse=r=>r}),Ou=m("$ZodNever",(e,t)=>{L.init(e,t),e._zod.parse=(r,n)=>(r.issues.push({expected:"never",code:"invalid_type",input:r.value,inst:e}),r)}),ju=m("$ZodVoid",(e,t)=>{L.init(e,t),e._zod.parse=(r,n)=>{let o=r.value;return typeof o>"u"||r.issues.push({expected:"void",code:"invalid_type",input:o,inst:e}),r}}),Du=m("$ZodDate",(e,t)=>{L.init(e,t),e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=new Date(r.value)}catch{}let o=r.value,i=o instanceof Date;return i&&!Number.isNaN(o.getTime())||r.issues.push({expected:"date",code:"invalid_type",input:o,...i?{received:"Invalid Date"}:{},inst:e}),r}});function lh(e,t,r){e.issues.length&&t.issues.push(...Qe(r,e.issues)),t.value[r]=e.value}var Nu=m("$ZodArray",(e,t)=>{L.init(e,t),e._zod.parse=(r,n)=>{let o=r.value;if(!Array.isArray(o))return r.issues.push({expected:"array",code:"invalid_type",input:o,inst:e}),r;r.value=Array(o.length);let i=[];for(let a=0;a<o.length;a++){let s=o[a],c=t.element._zod.run({value:s,issues:[]},n);c instanceof Promise?i.push(c.then(u=>lh(u,r,a))):lh(c,r,a)}return i.length?Promise.all(i).then(()=>r):r}});function ea(e,t,r,n,o){if(e.issues.length){if(o&&!(r in n))return;t.issues.push(...Qe(r,e.issues))}e.value===void 0?r in n&&(t.value[r]=void 0):t.value[r]=e.value}function xh(e){let t=Object.keys(e.shape);for(let n of t)if(!e.shape?.[n]?._zod?.traits?.has("$ZodType"))throw new Error(`Invalid element at key "${n}": expected a Zod schema`);let r=yc(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(r)}}function Sh(e,t,r,n,o,i){let a=[],s=o.keySet,c=o.catchall._zod,u=c.def.type,l=c.optout==="optional";for(let d in t){if(s.has(d))continue;if(u==="never"){a.push(d);continue}let p=c.run({value:t[d],issues:[]},n);p instanceof Promise?e.push(p.then(f=>ea(f,r,d,t,l))):ea(p,r,d,t,l)}return a.length&&r.issues.push({code:"unrecognized_keys",keys:a,input:t,inst:i}),e.length?Promise.all(e).then(()=>r):r}var kh=m("$ZodObject",(e,t)=>{if(L.init(e,t),!Object.getOwnPropertyDescriptor(t,"shape")?.get){let s=t.shape;Object.defineProperty(t,"shape",{get:()=>{let c={...s};return Object.defineProperty(t,"shape",{value:c}),c}})}let n=an(()=>xh(t));W(e._zod,"propValues",()=>{let s=t.shape,c={};for(let u in s){let l=s[u]._zod;if(l.values){c[u]??(c[u]=new Set);for(let d of l.values)c[u].add(d)}}return c});let o=wr,i=t.catchall,a;e._zod.parse=(s,c)=>{a??(a=n.value);let u=s.value;if(!o(u))return s.issues.push({expected:"object",code:"invalid_type",input:u,inst:e}),s;s.value={};let l=[],d=a.shape;for(let p of a.keys){let f=d[p],h=f._zod.optout==="optional",g=f._zod.run({value:u[p],issues:[]},c);g instanceof Promise?l.push(g.then(y=>ea(y,s,p,u,h))):ea(g,s,p,u,h)}return i?Sh(l,u,s,c,n.value,e):l.length?Promise.all(l).then(()=>s):s}}),wh=m("$ZodObjectJIT",(e,t)=>{kh.init(e,t);let r=e._zod.parse,n=an(()=>xh(t)),o=p=>{let f=new Ki(["shape","payload","ctx"]),h=n.value,g=b=>{let N=Fi(b);return`shape[${N}]._zod.run({ value: input[${N}], issues: [] }, ctx)`};f.write("const input = payload.value;");let y=Object.create(null),S=0;for(let b of h.keys)y[b]=`key_${S++}`;f.write("const newResult = {};");for(let b of h.keys){let N=y[b],T=Fi(b),We=p[b]?._zod?.optout==="optional";f.write(`const ${N} = ${g(b)};`),We?f.write(`
|
|
if (${N}.issues.length) {
|
|
if (${T} in input) {
|
|
payload.issues = payload.issues.concat(${N}.issues.map(iss => ({
|
|
...iss,
|
|
path: iss.path ? [${T}, ...iss.path] : [${T}]
|
|
})));
|
|
}
|
|
}
|
|
|
|
if (${N}.value === undefined) {
|
|
if (${T} in input) {
|
|
newResult[${T}] = undefined;
|
|
}
|
|
} else {
|
|
newResult[${T}] = ${N}.value;
|
|
}
|
|
|
|
`):f.write(`
|
|
if (${N}.issues.length) {
|
|
payload.issues = payload.issues.concat(${N}.issues.map(iss => ({
|
|
...iss,
|
|
path: iss.path ? [${T}, ...iss.path] : [${T}]
|
|
})));
|
|
}
|
|
|
|
if (${N}.value === undefined) {
|
|
if (${T} in input) {
|
|
newResult[${T}] = undefined;
|
|
}
|
|
} else {
|
|
newResult[${T}] = ${N}.value;
|
|
}
|
|
|
|
`)}f.write("payload.value = newResult;"),f.write("return payload;");let x=f.compile();return(b,N)=>x(p,b,N)},i,a=wr,s=!Li.jitless,u=s&&vc.value,l=t.catchall,d;e._zod.parse=(p,f)=>{d??(d=n.value);let h=p.value;return a(h)?s&&u&&f?.async===!1&&f.jitless!==!0?(i||(i=o(t.shape)),p=i(p,f),l?Sh([],h,p,f,d,e):p):r(p,f):(p.issues.push({expected:"object",code:"invalid_type",input:h,inst:e}),p)}});function dh(e,t,r,n){for(let i of e)if(i.issues.length===0)return t.value=i.value,t;let o=e.filter(i=>!ur(i));return o.length===1?(t.value=o[0].value,o[0]):(t.issues.push({code:"invalid_union",input:t.value,inst:r,errors:e.map(i=>i.issues.map(a=>Je(a,n,be())))}),t)}var bo=m("$ZodUnion",(e,t)=>{L.init(e,t),W(e._zod,"optin",()=>t.options.some(o=>o._zod.optin==="optional")?"optional":void 0),W(e._zod,"optout",()=>t.options.some(o=>o._zod.optout==="optional")?"optional":void 0),W(e._zod,"values",()=>{if(t.options.every(o=>o._zod.values))return new Set(t.options.flatMap(o=>Array.from(o._zod.values)))}),W(e._zod,"pattern",()=>{if(t.options.every(o=>o._zod.pattern)){let o=t.options.map(i=>i._zod.pattern);return new RegExp(`^(${o.map(i=>oo(i.source)).join("|")})$`)}});let r=t.options.length===1,n=t.options[0]._zod.run;e._zod.parse=(o,i)=>{if(r)return n(o,i);let a=!1,s=[];for(let c of t.options){let u=c._zod.run({value:o.value,issues:[]},i);if(u instanceof Promise)s.push(u),a=!0;else{if(u.issues.length===0)return u;s.push(u)}}return a?Promise.all(s).then(c=>dh(c,o,e,i)):dh(s,o,e,i)}});function ph(e,t,r,n){let o=e.filter(i=>i.issues.length===0);return o.length===1?(t.value=o[0].value,t):(o.length===0?t.issues.push({code:"invalid_union",input:t.value,inst:r,errors:e.map(i=>i.issues.map(a=>Je(a,n,be())))}):t.issues.push({code:"invalid_union",input:t.value,inst:r,errors:[],inclusive:!1}),t)}var Ru=m("$ZodXor",(e,t)=>{bo.init(e,t),t.inclusive=!1;let r=t.options.length===1,n=t.options[0]._zod.run;e._zod.parse=(o,i)=>{if(r)return n(o,i);let a=!1,s=[];for(let c of t.options){let u=c._zod.run({value:o.value,issues:[]},i);u instanceof Promise?(s.push(u),a=!0):s.push(u)}return a?Promise.all(s).then(c=>ph(c,o,e,i)):ph(s,o,e,i)}}),Mu=m("$ZodDiscriminatedUnion",(e,t)=>{t.inclusive=!1,bo.init(e,t);let r=e._zod.parse;W(e._zod,"propValues",()=>{let o={};for(let i of t.options){let a=i._zod.propValues;if(!a||Object.keys(a).length===0)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(i)}"`);for(let[s,c]of Object.entries(a)){o[s]||(o[s]=new Set);for(let u of c)o[s].add(u)}}return o});let n=an(()=>{let o=t.options,i=new Map;for(let a of o){let s=a._zod.propValues?.[t.discriminator];if(!s||s.size===0)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(a)}"`);for(let c of s){if(i.has(c))throw new Error(`Duplicate discriminator value "${String(c)}"`);i.set(c,a)}}return i});e._zod.parse=(o,i)=>{let a=o.value;if(!wr(a))return o.issues.push({code:"invalid_type",expected:"object",input:a,inst:e}),o;let s=n.value.get(a?.[t.discriminator]);return s?s._zod.run(o,i):t.unionFallback?r(o,i):(o.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:t.discriminator,input:a,path:[t.discriminator],inst:e}),o)}}),Au=m("$ZodIntersection",(e,t)=>{L.init(e,t),e._zod.parse=(r,n)=>{let o=r.value,i=t.left._zod.run({value:o,issues:[]},n),a=t.right._zod.run({value:o,issues:[]},n);return i instanceof Promise||a instanceof Promise?Promise.all([i,a]).then(([c,u])=>fh(r,c,u)):fh(r,i,a)}});function Xc(e,t){if(e===t)return{valid:!0,data:e};if(e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(cr(e)&&cr(t)){let r=Object.keys(t),n=Object.keys(e).filter(i=>r.indexOf(i)!==-1),o={...e,...t};for(let i of n){let a=Xc(e[i],t[i]);if(!a.valid)return{valid:!1,mergeErrorPath:[i,...a.mergeErrorPath]};o[i]=a.data}return{valid:!0,data:o}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};let r=[];for(let n=0;n<e.length;n++){let o=e[n],i=t[n],a=Xc(o,i);if(!a.valid)return{valid:!1,mergeErrorPath:[n,...a.mergeErrorPath]};r.push(a.data)}return{valid:!0,data:r}}return{valid:!1,mergeErrorPath:[]}}function fh(e,t,r){let n=new Map,o;for(let s of t.issues)if(s.code==="unrecognized_keys"){o??(o=s);for(let c of s.keys)n.has(c)||n.set(c,{}),n.get(c).l=!0}else e.issues.push(s);for(let s of r.issues)if(s.code==="unrecognized_keys")for(let c of s.keys)n.has(c)||n.set(c,{}),n.get(c).r=!0;else e.issues.push(s);let i=[...n].filter(([,s])=>s.l&&s.r).map(([s])=>s);if(i.length&&o&&e.issues.push({...o,keys:i}),ur(e))return e;let a=Xc(t.value,r.value);if(!a.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(a.mergeErrorPath)}`);return e.value=a.data,e}var na=m("$ZodTuple",(e,t)=>{L.init(e,t);let r=t.items;e._zod.parse=(n,o)=>{let i=n.value;if(!Array.isArray(i))return n.issues.push({input:i,inst:e,expected:"tuple",code:"invalid_type"}),n;n.value=[];let a=[],s=[...r].reverse().findIndex(l=>l._zod.optin!=="optional"),c=s===-1?0:r.length-s;if(!t.rest){let l=i.length>r.length,d=i.length<c-1;if(l||d)return n.issues.push({...l?{code:"too_big",maximum:r.length,inclusive:!0}:{code:"too_small",minimum:r.length},input:i,inst:e,origin:"array"}),n}let u=-1;for(let l of r){if(u++,u>=i.length&&u>=c)continue;let d=l._zod.run({value:i[u],issues:[]},o);d instanceof Promise?a.push(d.then(p=>Bi(p,n,u))):Bi(d,n,u)}if(t.rest){let l=i.slice(r.length);for(let d of l){u++;let p=t.rest._zod.run({value:d,issues:[]},o);p instanceof Promise?a.push(p.then(f=>Bi(f,n,u))):Bi(p,n,u)}}return a.length?Promise.all(a).then(()=>n):n}});function Bi(e,t,r){e.issues.length&&t.issues.push(...Qe(r,e.issues)),t.value[r]=e.value}var Cu=m("$ZodRecord",(e,t)=>{L.init(e,t),e._zod.parse=(r,n)=>{let o=r.value;if(!cr(o))return r.issues.push({expected:"record",code:"invalid_type",input:o,inst:e}),r;let i=[],a=t.keyType._zod.values;if(a){r.value={};let s=new Set;for(let u of a)if(typeof u=="string"||typeof u=="number"||typeof u=="symbol"){s.add(typeof u=="number"?u.toString():u);let l=t.valueType._zod.run({value:o[u],issues:[]},n);l instanceof Promise?i.push(l.then(d=>{d.issues.length&&r.issues.push(...Qe(u,d.issues)),r.value[u]=d.value})):(l.issues.length&&r.issues.push(...Qe(u,l.issues)),r.value[u]=l.value)}let c;for(let u in o)s.has(u)||(c=c??[],c.push(u));c&&c.length>0&&r.issues.push({code:"unrecognized_keys",input:o,inst:e,keys:c})}else{r.value={};for(let s of Reflect.ownKeys(o)){if(s==="__proto__")continue;let c=t.keyType._zod.run({value:s,issues:[]},n);if(c instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(typeof s=="string"&&Gi.test(s)&&c.issues.length&&c.issues.some(d=>d.code==="invalid_type"&&d.expected==="number")){let d=t.keyType._zod.run({value:Number(s),issues:[]},n);if(d instanceof Promise)throw new Error("Async schemas not supported in object keys currently");d.issues.length===0&&(c=d)}if(c.issues.length){t.mode==="loose"?r.value[s]=o[s]:r.issues.push({code:"invalid_key",origin:"record",issues:c.issues.map(d=>Je(d,n,be())),input:s,path:[s],inst:e});continue}let l=t.valueType._zod.run({value:o[s],issues:[]},n);l instanceof Promise?i.push(l.then(d=>{d.issues.length&&r.issues.push(...Qe(s,d.issues)),r.value[c.value]=d.value})):(l.issues.length&&r.issues.push(...Qe(s,l.issues)),r.value[c.value]=l.value)}}return i.length?Promise.all(i).then(()=>r):r}}),Uu=m("$ZodMap",(e,t)=>{L.init(e,t),e._zod.parse=(r,n)=>{let o=r.value;if(!(o instanceof Map))return r.issues.push({expected:"map",code:"invalid_type",input:o,inst:e}),r;let i=[];r.value=new Map;for(let[a,s]of o){let c=t.keyType._zod.run({value:a,issues:[]},n),u=t.valueType._zod.run({value:s,issues:[]},n);c instanceof Promise||u instanceof Promise?i.push(Promise.all([c,u]).then(([l,d])=>{mh(l,d,r,a,o,e,n)})):mh(c,u,r,a,o,e,n)}return i.length?Promise.all(i).then(()=>r):r}});function mh(e,t,r,n,o,i,a){e.issues.length&&(io.has(typeof n)?r.issues.push(...Qe(n,e.issues)):r.issues.push({code:"invalid_key",origin:"map",input:o,inst:i,issues:e.issues.map(s=>Je(s,a,be()))})),t.issues.length&&(io.has(typeof n)?r.issues.push(...Qe(n,t.issues)):r.issues.push({origin:"map",code:"invalid_element",input:o,inst:i,key:n,issues:t.issues.map(s=>Je(s,a,be()))})),r.value.set(e.value,t.value)}var Zu=m("$ZodSet",(e,t)=>{L.init(e,t),e._zod.parse=(r,n)=>{let o=r.value;if(!(o instanceof Set))return r.issues.push({input:o,inst:e,expected:"set",code:"invalid_type"}),r;let i=[];r.value=new Set;for(let a of o){let s=t.valueType._zod.run({value:a,issues:[]},n);s instanceof Promise?i.push(s.then(c=>hh(c,r))):hh(s,r)}return i.length?Promise.all(i).then(()=>r):r}});function hh(e,t){e.issues.length&&t.issues.push(...e.issues),t.value.add(e.value)}var Lu=m("$ZodEnum",(e,t)=>{L.init(e,t);let r=no(t.entries),n=new Set(r);e._zod.values=n,e._zod.pattern=new RegExp(`^(${r.filter(o=>io.has(typeof o)).map(o=>typeof o=="string"?ot(o):o.toString()).join("|")})$`),e._zod.parse=(o,i)=>{let a=o.value;return n.has(a)||o.issues.push({code:"invalid_value",values:r,input:a,inst:e}),o}}),Fu=m("$ZodLiteral",(e,t)=>{if(L.init(e,t),t.values.length===0)throw new Error("Cannot create literal schema with no valid values");let r=new Set(t.values);e._zod.values=r,e._zod.pattern=new RegExp(`^(${t.values.map(n=>typeof n=="string"?ot(n):n?ot(n.toString()):String(n)).join("|")})$`),e._zod.parse=(n,o)=>{let i=n.value;return r.has(i)||n.issues.push({code:"invalid_value",values:t.values,input:i,inst:e}),n}}),qu=m("$ZodFile",(e,t)=>{L.init(e,t),e._zod.parse=(r,n)=>{let o=r.value;return o instanceof File||r.issues.push({expected:"file",code:"invalid_type",input:o,inst:e}),r}}),Vu=m("$ZodTransform",(e,t)=>{L.init(e,t),e._zod.parse=(r,n)=>{if(n.direction==="backward")throw new kr(e.constructor.name);let o=t.transform(r.value,r);if(n.async)return(o instanceof Promise?o:Promise.resolve(o)).then(a=>(r.value=a,r));if(o instanceof Promise)throw new Et;return r.value=o,r}});function gh(e,t){return e.issues.length&&t===void 0?{issues:[],value:void 0}:e}var oa=m("$ZodOptional",(e,t)=>{L.init(e,t),e._zod.optin="optional",e._zod.optout="optional",W(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),W(e._zod,"pattern",()=>{let r=t.innerType._zod.pattern;return r?new RegExp(`^(${oo(r.source)})?$`):void 0}),e._zod.parse=(r,n)=>{if(t.innerType._zod.optin==="optional"){let o=t.innerType._zod.run(r,n);return o instanceof Promise?o.then(i=>gh(i,r.value)):gh(o,r.value)}return r.value===void 0?r:t.innerType._zod.run(r,n)}}),Wu=m("$ZodExactOptional",(e,t)=>{oa.init(e,t),W(e._zod,"values",()=>t.innerType._zod.values),W(e._zod,"pattern",()=>t.innerType._zod.pattern),e._zod.parse=(r,n)=>t.innerType._zod.run(r,n)}),Ju=m("$ZodNullable",(e,t)=>{L.init(e,t),W(e._zod,"optin",()=>t.innerType._zod.optin),W(e._zod,"optout",()=>t.innerType._zod.optout),W(e._zod,"pattern",()=>{let r=t.innerType._zod.pattern;return r?new RegExp(`^(${oo(r.source)}|null)$`):void 0}),W(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(r,n)=>r.value===null?r:t.innerType._zod.run(r,n)}),Hu=m("$ZodDefault",(e,t)=>{L.init(e,t),e._zod.optin="optional",W(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(r,n)=>{if(n.direction==="backward")return t.innerType._zod.run(r,n);if(r.value===void 0)return r.value=t.defaultValue,r;let o=t.innerType._zod.run(r,n);return o instanceof Promise?o.then(i=>vh(i,t)):vh(o,t)}});function vh(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}var Gu=m("$ZodPrefault",(e,t)=>{L.init(e,t),e._zod.optin="optional",W(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(r,n)=>(n.direction==="backward"||r.value===void 0&&(r.value=t.defaultValue),t.innerType._zod.run(r,n))}),Ku=m("$ZodNonOptional",(e,t)=>{L.init(e,t),W(e._zod,"values",()=>{let r=t.innerType._zod.values;return r?new Set([...r].filter(n=>n!==void 0)):void 0}),e._zod.parse=(r,n)=>{let o=t.innerType._zod.run(r,n);return o instanceof Promise?o.then(i=>_h(i,e)):_h(o,e)}});function _h(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:"invalid_type",expected:"nonoptional",input:e.value,inst:t}),e}var Bu=m("$ZodSuccess",(e,t)=>{L.init(e,t),e._zod.parse=(r,n)=>{if(n.direction==="backward")throw new kr("ZodSuccess");let o=t.innerType._zod.run(r,n);return o instanceof Promise?o.then(i=>(r.value=i.issues.length===0,r)):(r.value=o.issues.length===0,r)}}),Yu=m("$ZodCatch",(e,t)=>{L.init(e,t),W(e._zod,"optin",()=>t.innerType._zod.optin),W(e._zod,"optout",()=>t.innerType._zod.optout),W(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(r,n)=>{if(n.direction==="backward")return t.innerType._zod.run(r,n);let o=t.innerType._zod.run(r,n);return o instanceof Promise?o.then(i=>(r.value=i.value,i.issues.length&&(r.value=t.catchValue({...r,error:{issues:i.issues.map(a=>Je(a,n,be()))},input:r.value}),r.issues=[]),r)):(r.value=o.value,o.issues.length&&(r.value=t.catchValue({...r,error:{issues:o.issues.map(i=>Je(i,n,be()))},input:r.value}),r.issues=[]),r)}}),Xu=m("$ZodNaN",(e,t)=>{L.init(e,t),e._zod.parse=(r,n)=>((typeof r.value!="number"||!Number.isNaN(r.value))&&r.issues.push({input:r.value,inst:e,expected:"nan",code:"invalid_type"}),r)}),Qu=m("$ZodPipe",(e,t)=>{L.init(e,t),W(e._zod,"values",()=>t.in._zod.values),W(e._zod,"optin",()=>t.in._zod.optin),W(e._zod,"optout",()=>t.out._zod.optout),W(e._zod,"propValues",()=>t.in._zod.propValues),e._zod.parse=(r,n)=>{if(n.direction==="backward"){let i=t.out._zod.run(r,n);return i instanceof Promise?i.then(a=>Yi(a,t.in,n)):Yi(i,t.in,n)}let o=t.in._zod.run(r,n);return o instanceof Promise?o.then(i=>Yi(i,t.out,n)):Yi(o,t.out,n)}});function Yi(e,t,r){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},r)}var xo=m("$ZodCodec",(e,t)=>{L.init(e,t),W(e._zod,"values",()=>t.in._zod.values),W(e._zod,"optin",()=>t.in._zod.optin),W(e._zod,"optout",()=>t.out._zod.optout),W(e._zod,"propValues",()=>t.in._zod.propValues),e._zod.parse=(r,n)=>{if((n.direction||"forward")==="forward"){let i=t.in._zod.run(r,n);return i instanceof Promise?i.then(a=>Xi(a,t,n)):Xi(i,t,n)}else{let i=t.out._zod.run(r,n);return i instanceof Promise?i.then(a=>Xi(a,t,n)):Xi(i,t,n)}}});function Xi(e,t,r){if(e.issues.length)return e.aborted=!0,e;if((r.direction||"forward")==="forward"){let o=t.transform(e.value,e);return o instanceof Promise?o.then(i=>Qi(e,i,t.out,r)):Qi(e,o,t.out,r)}else{let o=t.reverseTransform(e.value,e);return o instanceof Promise?o.then(i=>Qi(e,i,t.in,r)):Qi(e,o,t.in,r)}}function Qi(e,t,r,n){return e.issues.length?(e.aborted=!0,e):r._zod.run({value:t,issues:e.issues},n)}var el=m("$ZodReadonly",(e,t)=>{L.init(e,t),W(e._zod,"propValues",()=>t.innerType._zod.propValues),W(e._zod,"values",()=>t.innerType._zod.values),W(e._zod,"optin",()=>t.innerType?._zod?.optin),W(e._zod,"optout",()=>t.innerType?._zod?.optout),e._zod.parse=(r,n)=>{if(n.direction==="backward")return t.innerType._zod.run(r,n);let o=t.innerType._zod.run(r,n);return o instanceof Promise?o.then(yh):yh(o)}});function yh(e){return e.value=Object.freeze(e.value),e}var tl=m("$ZodTemplateLiteral",(e,t)=>{L.init(e,t);let r=[];for(let n of t.parts)if(typeof n=="object"&&n!==null){if(!n._zod.pattern)throw new Error(`Invalid template literal part, no pattern found: ${[...n._zod.traits].shift()}`);let o=n._zod.pattern instanceof RegExp?n._zod.pattern.source:n._zod.pattern;if(!o)throw new Error(`Invalid template literal part: ${n._zod.traits}`);let i=o.startsWith("^")?1:0,a=o.endsWith("$")?o.length-1:o.length;r.push(o.slice(i,a))}else if(n===null||_c.has(typeof n))r.push(ot(`${n}`));else throw new Error(`Invalid template literal part: ${n}`);e._zod.pattern=new RegExp(`^${r.join("")}$`),e._zod.parse=(n,o)=>typeof n.value!="string"?(n.issues.push({input:n.value,inst:e,expected:"string",code:"invalid_type"}),n):(e._zod.pattern.lastIndex=0,e._zod.pattern.test(n.value)||n.issues.push({input:n.value,inst:e,code:"invalid_format",format:t.format??"template_literal",pattern:e._zod.pattern.source}),n)}),rl=m("$ZodFunction",(e,t)=>(L.init(e,t),e._def=t,e._zod.def=t,e.implement=r=>{if(typeof r!="function")throw new Error("implement() must be called with a function");return function(...n){let o=e._def.input?lo(e._def.input,n):n,i=Reflect.apply(r,this,o);return e._def.output?lo(e._def.output,i):i}},e.implementAsync=r=>{if(typeof r!="function")throw new Error("implementAsync() must be called with a function");return async function(...n){let o=e._def.input?await fo(e._def.input,n):n,i=await Reflect.apply(r,this,o);return e._def.output?await fo(e._def.output,i):i}},e._zod.parse=(r,n)=>typeof r.value!="function"?(r.issues.push({code:"invalid_type",expected:"function",input:r.value,inst:e}),r):(e._def.output&&e._def.output._zod.def.type==="promise"?r.value=e.implementAsync(r.value):r.value=e.implement(r.value),r),e.input=(...r)=>{let n=e.constructor;return Array.isArray(r[0])?new n({type:"function",input:new na({type:"tuple",items:r[0],rest:r[1]}),output:e._def.output}):new n({type:"function",input:r[0],output:e._def.output})},e.output=r=>{let n=e.constructor;return new n({type:"function",input:e._def.input,output:r})},e)),nl=m("$ZodPromise",(e,t)=>{L.init(e,t),e._zod.parse=(r,n)=>Promise.resolve(r.value).then(o=>t.innerType._zod.run({value:o,issues:[]},n))}),ol=m("$ZodLazy",(e,t)=>{L.init(e,t),W(e._zod,"innerType",()=>t.getter()),W(e._zod,"pattern",()=>e._zod.innerType?._zod?.pattern),W(e._zod,"propValues",()=>e._zod.innerType?._zod?.propValues),W(e._zod,"optin",()=>e._zod.innerType?._zod?.optin??void 0),W(e._zod,"optout",()=>e._zod.innerType?._zod?.optout??void 0),e._zod.parse=(r,n)=>e._zod.innerType._zod.run(r,n)}),il=m("$ZodCustom",(e,t)=>{ce.init(e,t),L.init(e,t),e._zod.parse=(r,n)=>r,e._zod.check=r=>{let n=r.value,o=t.fn(n);if(o instanceof Promise)return o.then(i=>$h(i,r,n,e));$h(o,r,n,e)}});function $h(e,t,r,n){if(!e){let o={code:"custom",input:r,inst:n,path:[...n._zod.def.path??[]],continue:!n._zod.def.abort};n._zod.def.params&&(o.params=n._zod.def.params),t.issues.push(sn(o))}}var iS=()=>{let e={string:{unit:"characters",verb:"to have"},file:{unit:"bytes",verb:"to have"},array:{unit:"items",verb:"to have"},set:{unit:"items",verb:"to have"},map:{unit:"entries",verb:"to have"}};function t(o){return e[o]??null}let r={regex:"input",email:"email address",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO datetime",date:"ISO date",time:"ISO time",duration:"ISO duration",ipv4:"IPv4 address",ipv6:"IPv6 address",mac:"MAC address",cidrv4:"IPv4 range",cidrv6:"IPv6 range",base64:"base64-encoded string",base64url:"base64url-encoded string",json_string:"JSON string",e164:"E.164 number",jwt:"JWT",template_literal:"input"},n={nan:"NaN"};return o=>{switch(o.code){case"invalid_type":{let i=n[o.expected]??o.expected,a=U(o.input),s=n[a]??a;return`Invalid input: expected ${i}, received ${s}`}case"invalid_value":return o.values.length===1?`Invalid input: expected ${A(o.values[0])}`:`Invalid option: expected one of ${M(o.values,"|")}`;case"too_big":{let i=o.inclusive?"<=":"<",a=t(o.origin);return a?`Too big: expected ${o.origin??"value"} to have ${i}${o.maximum.toString()} ${a.unit??"elements"}`:`Too big: expected ${o.origin??"value"} to be ${i}${o.maximum.toString()}`}case"too_small":{let i=o.inclusive?">=":">",a=t(o.origin);return a?`Too small: expected ${o.origin} to have ${i}${o.minimum.toString()} ${a.unit}`:`Too small: expected ${o.origin} to be ${i}${o.minimum.toString()}`}case"invalid_format":{let i=o;return i.format==="starts_with"?`Invalid string: must start with "${i.prefix}"`:i.format==="ends_with"?`Invalid string: must end with "${i.suffix}"`:i.format==="includes"?`Invalid string: must include "${i.includes}"`:i.format==="regex"?`Invalid string: must match pattern ${i.pattern}`:`Invalid ${r[i.format]??o.format}`}case"not_multiple_of":return`Invalid number: must be a multiple of ${o.divisor}`;case"unrecognized_keys":return`Unrecognized key${o.keys.length>1?"s":""}: ${M(o.keys,", ")}`;case"invalid_key":return`Invalid key in ${o.origin}`;case"invalid_union":return"Invalid input";case"invalid_element":return`Invalid value in ${o.origin}`;default:return"Invalid input"}}};function al(){return{localeError:iS()}}var Eh;var cl=class{constructor(){this._map=new WeakMap,this._idmap=new Map}add(t,...r){let n=r[0];return this._map.set(t,n),n&&typeof n=="object"&&"id"in n&&this._idmap.set(n.id,t),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(t){let r=this._map.get(t);return r&&typeof r=="object"&&"id"in r&&this._idmap.delete(r.id),this._map.delete(t),this}get(t){let r=t._zod.parent;if(r){let n={...this.get(r)??{}};delete n.id;let o={...n,...this._map.get(t)};return Object.keys(o).length?o:void 0}return this._map.get(t)}has(t){return this._map.has(t)}};function ul(){return new cl}(Eh=globalThis).__zod_globalRegistry??(Eh.__zod_globalRegistry=ul());var Ce=globalThis.__zod_globalRegistry;function ll(e,t){return new e({type:"string",...E(t)})}function ia(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...E(t)})}function So(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...E(t)})}function aa(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...E(t)})}function sa(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...E(t)})}function ca(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...E(t)})}function ua(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...E(t)})}function ko(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...E(t)})}function la(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...E(t)})}function da(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...E(t)})}function pa(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...E(t)})}function fa(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...E(t)})}function ma(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...E(t)})}function ha(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...E(t)})}function ga(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...E(t)})}function va(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...E(t)})}function _a(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...E(t)})}function dl(e,t){return new e({type:"string",format:"mac",check:"string_format",abort:!1,...E(t)})}function ya(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...E(t)})}function $a(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...E(t)})}function ba(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...E(t)})}function xa(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...E(t)})}function Sa(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...E(t)})}function ka(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...E(t)})}function pl(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...E(t)})}function fl(e,t){return new e({type:"string",format:"date",check:"string_format",...E(t)})}function ml(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...E(t)})}function hl(e,t){return new e({type:"string",format:"duration",check:"string_format",...E(t)})}function gl(e,t){return new e({type:"number",checks:[],...E(t)})}function vl(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...E(t)})}function _l(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"float32",...E(t)})}function yl(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"float64",...E(t)})}function $l(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"int32",...E(t)})}function bl(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"uint32",...E(t)})}function xl(e,t){return new e({type:"boolean",...E(t)})}function Sl(e,t){return new e({type:"bigint",...E(t)})}function kl(e,t){return new e({type:"bigint",check:"bigint_format",abort:!1,format:"int64",...E(t)})}function wl(e,t){return new e({type:"bigint",check:"bigint_format",abort:!1,format:"uint64",...E(t)})}function El(e,t){return new e({type:"symbol",...E(t)})}function Il(e,t){return new e({type:"undefined",...E(t)})}function zl(e,t){return new e({type:"null",...E(t)})}function Pl(e){return new e({type:"any"})}function Tl(e){return new e({type:"unknown"})}function Ol(e,t){return new e({type:"never",...E(t)})}function jl(e,t){return new e({type:"void",...E(t)})}function Dl(e,t){return new e({type:"date",...E(t)})}function Nl(e,t){return new e({type:"nan",...E(t)})}function Lt(e,t){return new Bc({check:"less_than",...E(t),value:e,inclusive:!1})}function et(e,t){return new Bc({check:"less_than",...E(t),value:e,inclusive:!0})}function Ft(e,t){return new Yc({check:"greater_than",...E(t),value:e,inclusive:!1})}function Ue(e,t){return new Yc({check:"greater_than",...E(t),value:e,inclusive:!0})}function Rl(e){return Ft(0,e)}function Ml(e){return Lt(0,e)}function Al(e){return et(0,e)}function Cl(e){return Ue(0,e)}function zr(e,t){return new Vm({check:"multiple_of",...E(t),value:e})}function Pr(e,t){return new Hm({check:"max_size",...E(t),maximum:e})}function qt(e,t){return new Gm({check:"min_size",...E(t),minimum:e})}function un(e,t){return new Km({check:"size_equals",...E(t),size:e})}function ln(e,t){return new Bm({check:"max_length",...E(t),maximum:e})}function lr(e,t){return new Ym({check:"min_length",...E(t),minimum:e})}function dn(e,t){return new Xm({check:"length_equals",...E(t),length:e})}function wo(e,t){return new Qm({check:"string_format",format:"regex",...E(t),pattern:e})}function Eo(e){return new eh({check:"string_format",format:"lowercase",...E(e)})}function Io(e){return new th({check:"string_format",format:"uppercase",...E(e)})}function zo(e,t){return new rh({check:"string_format",format:"includes",...E(t),includes:e})}function Po(e,t){return new nh({check:"string_format",format:"starts_with",...E(t),prefix:e})}function To(e,t){return new oh({check:"string_format",format:"ends_with",...E(t),suffix:e})}function Ul(e,t,r){return new ih({check:"property",property:e,schema:t,...E(r)})}function Oo(e,t){return new ah({check:"mime_type",mime:e,...E(t)})}function It(e){return new sh({check:"overwrite",tx:e})}function jo(e){return It(t=>t.normalize(e))}function Do(){return It(e=>e.trim())}function No(){return It(e=>e.toLowerCase())}function Ro(){return It(e=>e.toUpperCase())}function wa(){return It(e=>gc(e))}function Ih(e,t,r){return new e({type:"array",element:t,...E(r)})}function Zl(e,t){return new e({type:"file",...E(t)})}function Ll(e,t,r){let n=E(r);return n.abort??(n.abort=!0),new e({type:"custom",check:"custom",fn:t,...n})}function Fl(e,t,r){return new e({type:"custom",check:"custom",fn:t,...E(r)})}function ql(e){let t=uS(r=>(r.addIssue=n=>{if(typeof n=="string")r.issues.push(sn(n,r.value,t._zod.def));else{let o=n;o.fatal&&(o.continue=!1),o.code??(o.code="custom"),o.input??(o.input=r.value),o.inst??(o.inst=t),o.continue??(o.continue=!t._zod.def.abort),r.issues.push(sn(o))}},e(r.value,r)));return t}function uS(e,t){let r=new ce({check:"custom",...E(t)});return r._zod.check=e,r}function Vl(e){let t=new ce({check:"describe"});return t._zod.onattach=[r=>{let n=Ce.get(r)??{};Ce.add(r,{...n,description:e})}],t._zod.check=()=>{},t}function Wl(e){let t=new ce({check:"meta"});return t._zod.onattach=[r=>{let n=Ce.get(r)??{};Ce.add(r,{...n,...e})}],t._zod.check=()=>{},t}function Jl(e,t){let r=E(t),n=r.truthy??["true","1","yes","on","y","enabled"],o=r.falsy??["false","0","no","off","n","disabled"];r.case!=="sensitive"&&(n=n.map(f=>typeof f=="string"?f.toLowerCase():f),o=o.map(f=>typeof f=="string"?f.toLowerCase():f));let i=new Set(n),a=new Set(o),s=e.Codec??xo,c=e.Boolean??$o,u=e.String??Ir,l=new u({type:"string",error:r.error}),d=new c({type:"boolean",error:r.error}),p=new s({type:"pipe",in:l,out:d,transform:((f,h)=>{let g=f;return r.case!=="sensitive"&&(g=g.toLowerCase()),i.has(g)?!0:a.has(g)?!1:(h.issues.push({code:"invalid_value",expected:"stringbool",values:[...i,...a],input:h.value,inst:p,continue:!1}),{})}),reverseTransform:((f,h)=>f===!0?n[0]||"true":o[0]||"false"),error:r.error});return p}function pn(e,t,r,n={}){let o=E(n),i={...E(n),check:"string_format",type:"string",format:t,fn:typeof r=="function"?r:s=>r.test(s),...o};return r instanceof RegExp&&(i.pattern=r),new e(i)}function Ea(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??Ce,target:t,unrepresentable:e?.unrepresentable??"throw",override:e?.override??(()=>{}),io:e?.io??"output",counter:0,seen:new Map,cycles:e?.cycles??"ref",reused:e?.reused??"inline",external:e?.external??void 0}}function pe(e,t,r={path:[],schemaPath:[]}){var n;let o=e._zod.def,i=t.seen.get(e);if(i)return i.count++,r.schemaPath.includes(e)&&(i.cycle=r.path),i.schema;let a={schema:{},count:1,cycle:void 0,path:r.path};t.seen.set(e,a);let s=e._zod.toJSONSchema?.();if(s)a.schema=s;else{let l={...r,schemaPath:[...r.schemaPath,e],path:r.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,a.schema,l);else{let p=a.schema,f=t.processors[o.type];if(!f)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${o.type}`);f(e,t,p,l)}let d=e._zod.parent;d&&(a.ref||(a.ref=d),pe(d,t,l),t.seen.get(d).isParent=!0)}let c=t.metadataRegistry.get(e);return c&&Object.assign(a.schema,c),t.io==="input"&&Ze(e)&&(delete a.schema.examples,delete a.schema.default),t.io==="input"&&a.schema._prefault&&((n=a.schema).default??(n.default=a.schema._prefault)),delete a.schema._prefault,t.seen.get(e).schema}function Ia(e,t){let r=e.seen.get(t);if(!r)throw new Error("Unprocessed schema. This is a bug in Zod.");let n=new Map;for(let a of e.seen.entries()){let s=e.metadataRegistry.get(a[0])?.id;if(s){let c=n.get(s);if(c&&c!==a[0])throw new Error(`Duplicate schema id "${s}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);n.set(s,a[0])}}let o=a=>{let s=e.target==="draft-2020-12"?"$defs":"definitions";if(e.external){let d=e.external.registry.get(a[0])?.id,p=e.external.uri??(h=>h);if(d)return{ref:p(d)};let f=a[1].defId??a[1].schema.id??`schema${e.counter++}`;return a[1].defId=f,{defId:f,ref:`${p("__shared")}#/${s}/${f}`}}if(a[1]===r)return{ref:"#"};let u=`#/${s}/`,l=a[1].schema.id??`__schema${e.counter++}`;return{defId:l,ref:u+l}},i=a=>{if(a[1].schema.$ref)return;let s=a[1],{ref:c,defId:u}=o(a);s.def={...s.schema},u&&(s.defId=u);let l=s.schema;for(let d in l)delete l[d];l.$ref=c};if(e.cycles==="throw")for(let a of e.seen.entries()){let s=a[1];if(s.cycle)throw new Error(`Cycle detected: #/${s.cycle?.join("/")}/<root>
|
|
|
|
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let a of e.seen.entries()){let s=a[1];if(t===a[0]){i(a);continue}if(e.external){let u=e.external.registry.get(a[0])?.id;if(t!==a[0]&&u){i(a);continue}}if(e.metadataRegistry.get(a[0])?.id){i(a);continue}if(s.cycle){i(a);continue}if(s.count>1&&e.reused==="ref"){i(a);continue}}}function za(e,t){let r=e.seen.get(t);if(!r)throw new Error("Unprocessed schema. This is a bug in Zod.");let n=a=>{let s=e.seen.get(a);if(s.ref===null)return;let c=s.def??s.schema,u={...c},l=s.ref;if(s.ref=null,l){n(l);let p=e.seen.get(l),f=p.schema;if(f.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0")?(c.allOf=c.allOf??[],c.allOf.push(f)):Object.assign(c,f),Object.assign(c,u),a._zod.parent===l)for(let g in c)g==="$ref"||g==="allOf"||g in u||delete c[g];if(f.$ref)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]}let d=a._zod.parent;if(d&&d!==l){n(d);let p=e.seen.get(d);if(p?.schema.$ref&&(c.$ref=p.schema.$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]}e.override({zodSchema:a,jsonSchema:c,path:s.path??[]})};for(let a of[...e.seen.entries()].reverse())n(a[0]);let o={};if(e.target==="draft-2020-12"?o.$schema="https://json-schema.org/draft/2020-12/schema":e.target==="draft-07"?o.$schema="http://json-schema.org/draft-07/schema#":e.target==="draft-04"?o.$schema="http://json-schema.org/draft-04/schema#":e.target,e.external?.uri){let a=e.external.registry.get(t)?.id;if(!a)throw new Error("Schema is missing an `id` property");o.$id=e.external.uri(a)}Object.assign(o,r.def??r.schema);let i=e.external?.defs??{};for(let a of e.seen.entries()){let s=a[1];s.def&&s.defId&&(i[s.defId]=s.def)}e.external||Object.keys(i).length>0&&(e.target==="draft-2020-12"?o.$defs=i:o.definitions=i);try{let a=JSON.parse(JSON.stringify(o));return Object.defineProperty(a,"~standard",{value:{...t["~standard"],jsonSchema:{input:Mo(t,"input",e.processors),output:Mo(t,"output",e.processors)}},enumerable:!1,writable:!1}),a}catch{throw new Error("Error converting schema to JSON.")}}function Ze(e,t){let r=t??{seen:new Set};if(r.seen.has(e))return!1;r.seen.add(e);let n=e._zod.def;if(n.type==="transform")return!0;if(n.type==="array")return Ze(n.element,r);if(n.type==="set")return Ze(n.valueType,r);if(n.type==="lazy")return Ze(n.getter(),r);if(n.type==="promise"||n.type==="optional"||n.type==="nonoptional"||n.type==="nullable"||n.type==="readonly"||n.type==="default"||n.type==="prefault")return Ze(n.innerType,r);if(n.type==="intersection")return Ze(n.left,r)||Ze(n.right,r);if(n.type==="record"||n.type==="map")return Ze(n.keyType,r)||Ze(n.valueType,r);if(n.type==="pipe")return Ze(n.in,r)||Ze(n.out,r);if(n.type==="object"){for(let o in n.shape)if(Ze(n.shape[o],r))return!0;return!1}if(n.type==="union"){for(let o of n.options)if(Ze(o,r))return!0;return!1}if(n.type==="tuple"){for(let o of n.items)if(Ze(o,r))return!0;return!!(n.rest&&Ze(n.rest,r))}return!1}var zh=(e,t={})=>r=>{let n=Ea({...r,processors:t});return pe(e,n),Ia(n,e),za(n,e)},Mo=(e,t,r={})=>n=>{let{libraryOptions:o,target:i}=n??{},a=Ea({...o??{},target:i,io:t,processors:r});return pe(e,a),Ia(a,e),za(a,e)};var lS={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},Ph=(e,t,r,n)=>{let o=r;o.type="string";let{minimum:i,maximum:a,format:s,patterns:c,contentEncoding:u}=e._zod.bag;if(typeof i=="number"&&(o.minLength=i),typeof a=="number"&&(o.maxLength=a),s&&(o.format=lS[s]??s,o.format===""&&delete o.format,s==="time"&&delete o.format),u&&(o.contentEncoding=u),c&&c.size>0){let l=[...c];l.length===1?o.pattern=l[0].source:l.length>1&&(o.allOf=[...l.map(d=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:d.source}))])}},Th=(e,t,r,n)=>{let o=r,{minimum:i,maximum:a,format:s,multipleOf:c,exclusiveMaximum:u,exclusiveMinimum:l}=e._zod.bag;typeof s=="string"&&s.includes("int")?o.type="integer":o.type="number",typeof l=="number"&&(t.target==="draft-04"||t.target==="openapi-3.0"?(o.minimum=l,o.exclusiveMinimum=!0):o.exclusiveMinimum=l),typeof i=="number"&&(o.minimum=i,typeof l=="number"&&t.target!=="draft-04"&&(l>=i?delete o.minimum:delete o.exclusiveMinimum)),typeof u=="number"&&(t.target==="draft-04"||t.target==="openapi-3.0"?(o.maximum=u,o.exclusiveMaximum=!0):o.exclusiveMaximum=u),typeof a=="number"&&(o.maximum=a,typeof u=="number"&&t.target!=="draft-04"&&(u<=a?delete o.maximum:delete o.exclusiveMaximum)),typeof c=="number"&&(o.multipleOf=c)},Oh=(e,t,r,n)=>{r.type="boolean"},jh=(e,t,r,n)=>{if(t.unrepresentable==="throw")throw new Error("BigInt cannot be represented in JSON Schema")},Dh=(e,t,r,n)=>{if(t.unrepresentable==="throw")throw new Error("Symbols cannot be represented in JSON Schema")},Nh=(e,t,r,n)=>{t.target==="openapi-3.0"?(r.type="string",r.nullable=!0,r.enum=[null]):r.type="null"},Rh=(e,t,r,n)=>{if(t.unrepresentable==="throw")throw new Error("Undefined cannot be represented in JSON Schema")},Mh=(e,t,r,n)=>{if(t.unrepresentable==="throw")throw new Error("Void cannot be represented in JSON Schema")},Ah=(e,t,r,n)=>{r.not={}},Ch=(e,t,r,n)=>{},Uh=(e,t,r,n)=>{},Zh=(e,t,r,n)=>{if(t.unrepresentable==="throw")throw new Error("Date cannot be represented in JSON Schema")},Lh=(e,t,r,n)=>{let o=e._zod.def,i=no(o.entries);i.every(a=>typeof a=="number")&&(r.type="number"),i.every(a=>typeof a=="string")&&(r.type="string"),r.enum=i},Fh=(e,t,r,n)=>{let o=e._zod.def,i=[];for(let a of o.values)if(a===void 0){if(t.unrepresentable==="throw")throw new Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof a=="bigint"){if(t.unrepresentable==="throw")throw new Error("BigInt literals cannot be represented in JSON Schema");i.push(Number(a))}else i.push(a);if(i.length!==0)if(i.length===1){let a=i[0];r.type=a===null?"null":typeof a,t.target==="draft-04"||t.target==="openapi-3.0"?r.enum=[a]:r.const=a}else i.every(a=>typeof a=="number")&&(r.type="number"),i.every(a=>typeof a=="string")&&(r.type="string"),i.every(a=>typeof a=="boolean")&&(r.type="boolean"),i.every(a=>a===null)&&(r.type="null"),r.enum=i},qh=(e,t,r,n)=>{if(t.unrepresentable==="throw")throw new Error("NaN cannot be represented in JSON Schema")},Vh=(e,t,r,n)=>{let o=r,i=e._zod.pattern;if(!i)throw new Error("Pattern not found in template literal");o.type="string",o.pattern=i.source},Wh=(e,t,r,n)=>{let o=r,i={type:"string",format:"binary",contentEncoding:"binary"},{minimum:a,maximum:s,mime:c}=e._zod.bag;a!==void 0&&(i.minLength=a),s!==void 0&&(i.maxLength=s),c?c.length===1?(i.contentMediaType=c[0],Object.assign(o,i)):(Object.assign(o,i),o.anyOf=c.map(u=>({contentMediaType:u}))):Object.assign(o,i)},Jh=(e,t,r,n)=>{r.type="boolean"},Hh=(e,t,r,n)=>{if(t.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema")},Gh=(e,t,r,n)=>{if(t.unrepresentable==="throw")throw new Error("Function types cannot be represented in JSON Schema")},Kh=(e,t,r,n)=>{if(t.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema")},Bh=(e,t,r,n)=>{if(t.unrepresentable==="throw")throw new Error("Map cannot be represented in JSON Schema")},Yh=(e,t,r,n)=>{if(t.unrepresentable==="throw")throw new Error("Set cannot be represented in JSON Schema")},Xh=(e,t,r,n)=>{let o=r,i=e._zod.def,{minimum:a,maximum:s}=e._zod.bag;typeof a=="number"&&(o.minItems=a),typeof s=="number"&&(o.maxItems=s),o.type="array",o.items=pe(i.element,t,{...n,path:[...n.path,"items"]})},Qh=(e,t,r,n)=>{let o=r,i=e._zod.def;o.type="object",o.properties={};let a=i.shape;for(let u in a)o.properties[u]=pe(a[u],t,{...n,path:[...n.path,"properties",u]});let s=new Set(Object.keys(a)),c=new Set([...s].filter(u=>{let l=i.shape[u]._zod;return t.io==="input"?l.optin===void 0:l.optout===void 0}));c.size>0&&(o.required=Array.from(c)),i.catchall?._zod.def.type==="never"?o.additionalProperties=!1:i.catchall?i.catchall&&(o.additionalProperties=pe(i.catchall,t,{...n,path:[...n.path,"additionalProperties"]})):t.io==="output"&&(o.additionalProperties=!1)},Hl=(e,t,r,n)=>{let o=e._zod.def,i=o.inclusive===!1,a=o.options.map((s,c)=>pe(s,t,{...n,path:[...n.path,i?"oneOf":"anyOf",c]}));i?r.oneOf=a:r.anyOf=a},eg=(e,t,r,n)=>{let o=e._zod.def,i=pe(o.left,t,{...n,path:[...n.path,"allOf",0]}),a=pe(o.right,t,{...n,path:[...n.path,"allOf",1]}),s=u=>"allOf"in u&&Object.keys(u).length===1,c=[...s(i)?i.allOf:[i],...s(a)?a.allOf:[a]];r.allOf=c},tg=(e,t,r,n)=>{let o=r,i=e._zod.def;o.type="array";let a=t.target==="draft-2020-12"?"prefixItems":"items",s=t.target==="draft-2020-12"||t.target==="openapi-3.0"?"items":"additionalItems",c=i.items.map((p,f)=>pe(p,t,{...n,path:[...n.path,a,f]})),u=i.rest?pe(i.rest,t,{...n,path:[...n.path,s,...t.target==="openapi-3.0"?[i.items.length]:[]]}):null;t.target==="draft-2020-12"?(o.prefixItems=c,u&&(o.items=u)):t.target==="openapi-3.0"?(o.items={anyOf:c},u&&o.items.anyOf.push(u),o.minItems=c.length,u||(o.maxItems=c.length)):(o.items=c,u&&(o.additionalItems=u));let{minimum:l,maximum:d}=e._zod.bag;typeof l=="number"&&(o.minItems=l),typeof d=="number"&&(o.maxItems=d)},rg=(e,t,r,n)=>{let o=r,i=e._zod.def;o.type="object";let a=i.keyType,c=a._zod.bag?.patterns;if(i.mode==="loose"&&c&&c.size>0){let l=pe(i.valueType,t,{...n,path:[...n.path,"patternProperties","*"]});o.patternProperties={};for(let d of c)o.patternProperties[d.source]=l}else(t.target==="draft-07"||t.target==="draft-2020-12")&&(o.propertyNames=pe(i.keyType,t,{...n,path:[...n.path,"propertyNames"]})),o.additionalProperties=pe(i.valueType,t,{...n,path:[...n.path,"additionalProperties"]});let u=a._zod.values;if(u){let l=[...u].filter(d=>typeof d=="string"||typeof d=="number");l.length>0&&(o.required=l)}},ng=(e,t,r,n)=>{let o=e._zod.def,i=pe(o.innerType,t,n),a=t.seen.get(e);t.target==="openapi-3.0"?(a.ref=o.innerType,r.nullable=!0):r.anyOf=[i,{type:"null"}]},og=(e,t,r,n)=>{let o=e._zod.def;pe(o.innerType,t,n);let i=t.seen.get(e);i.ref=o.innerType},ig=(e,t,r,n)=>{let o=e._zod.def;pe(o.innerType,t,n);let i=t.seen.get(e);i.ref=o.innerType,r.default=JSON.parse(JSON.stringify(o.defaultValue))},ag=(e,t,r,n)=>{let o=e._zod.def;pe(o.innerType,t,n);let i=t.seen.get(e);i.ref=o.innerType,t.io==="input"&&(r._prefault=JSON.parse(JSON.stringify(o.defaultValue)))},sg=(e,t,r,n)=>{let o=e._zod.def;pe(o.innerType,t,n);let i=t.seen.get(e);i.ref=o.innerType;let a;try{a=o.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}r.default=a},cg=(e,t,r,n)=>{let o=e._zod.def,i=t.io==="input"?o.in._zod.def.type==="transform"?o.out:o.in:o.out;pe(i,t,n);let a=t.seen.get(e);a.ref=i},ug=(e,t,r,n)=>{let o=e._zod.def;pe(o.innerType,t,n);let i=t.seen.get(e);i.ref=o.innerType,r.readOnly=!0},lg=(e,t,r,n)=>{let o=e._zod.def;pe(o.innerType,t,n);let i=t.seen.get(e);i.ref=o.innerType},Gl=(e,t,r,n)=>{let o=e._zod.def;pe(o.innerType,t,n);let i=t.seen.get(e);i.ref=o.innerType},dg=(e,t,r,n)=>{let o=e._zod.innerType;pe(o,t,n);let i=t.seen.get(e);i.ref=o};function fn(e){return!!e._zod}function dr(e,t){return fn(e)?cn(e,t):e.safeParse(t)}function Pa(e){if(!e)return;let t;if(fn(e)?t=e._zod?.def?.shape:t=e.shape,!!t){if(typeof t=="function")try{return t()}catch{return}return t}}function hg(e){if(fn(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 n=e.value;if(n!==void 0)return n}var Ao={};Fn(Ao,{ZodAny:()=>Dg,ZodArray:()=>Ag,ZodBase64:()=>_d,ZodBase64URL:()=>yd,ZodBigInt:()=>Ca,ZodBigIntFormat:()=>xd,ZodBoolean:()=>Aa,ZodCIDRv4:()=>gd,ZodCIDRv6:()=>vd,ZodCUID:()=>ud,ZodCUID2:()=>ld,ZodCatch:()=>nv,ZodCodec:()=>Pd,ZodCustom:()=>qa,ZodCustomStringFormat:()=>Uo,ZodDate:()=>kd,ZodDefault:()=>Yg,ZodDiscriminatedUnion:()=>Ug,ZodE164:()=>$d,ZodEmail:()=>ad,ZodEmoji:()=>sd,ZodEnum:()=>Co,ZodExactOptional:()=>Gg,ZodFile:()=>Jg,ZodFunction:()=>pv,ZodGUID:()=>Oa,ZodIPv4:()=>md,ZodIPv6:()=>hd,ZodIntersection:()=>Zg,ZodJWT:()=>bd,ZodKSUID:()=>fd,ZodLazy:()=>uv,ZodLiteral:()=>Wg,ZodMAC:()=>Pg,ZodMap:()=>qg,ZodNaN:()=>iv,ZodNanoID:()=>cd,ZodNever:()=>Rg,ZodNonOptional:()=>Id,ZodNull:()=>jg,ZodNullable:()=>Bg,ZodNumber:()=>Ma,ZodNumberFormat:()=>mn,ZodObject:()=>Ua,ZodOptional:()=>Ed,ZodPipe:()=>zd,ZodPrefault:()=>Qg,ZodPromise:()=>dv,ZodReadonly:()=>av,ZodRecord:()=>Fa,ZodSet:()=>Vg,ZodString:()=>Na,ZodStringFormat:()=>ue,ZodSuccess:()=>rv,ZodSymbol:()=>Tg,ZodTemplateLiteral:()=>cv,ZodTransform:()=>Hg,ZodTuple:()=>Lg,ZodType:()=>q,ZodULID:()=>dd,ZodURL:()=>Ra,ZodUUID:()=>Vt,ZodUndefined:()=>Og,ZodUnion:()=>Za,ZodUnknown:()=>Ng,ZodVoid:()=>Mg,ZodXID:()=>pd,ZodXor:()=>Cg,_ZodString:()=>id,_default:()=>Xg,_function:()=>zk,any:()=>lk,array:()=>B,base64:()=>HS,base64url:()=>GS,bigint:()=>ik,boolean:()=>$e,catch:()=>ov,check:()=>Pk,cidrv4:()=>WS,cidrv6:()=>JS,codec:()=>wk,cuid:()=>AS,cuid2:()=>CS,custom:()=>Td,date:()=>pk,describe:()=>Tk,discriminatedUnion:()=>La,e164:()=>KS,email:()=>IS,emoji:()=>RS,enum:()=>Oe,exactOptional:()=>Kg,file:()=>bk,float32:()=>tk,float64:()=>rk,function:()=>zk,guid:()=>zS,hash:()=>ek,hex:()=>QS,hostname:()=>XS,httpUrl:()=>NS,instanceof:()=>jk,int:()=>od,int32:()=>nk,int64:()=>ak,intersection:()=>Lo,ipv4:()=>FS,ipv6:()=>VS,json:()=>Nk,jwt:()=>BS,keyof:()=>fk,ksuid:()=>LS,lazy:()=>lv,literal:()=>j,looseObject:()=>Te,looseRecord:()=>vk,mac:()=>qS,map:()=>_k,meta:()=>Ok,nan:()=>kk,nanoid:()=>MS,nativeEnum:()=>$k,never:()=>Sd,nonoptional:()=>tv,null:()=>Zo,nullable:()=>ja,nullish:()=>xk,number:()=>oe,object:()=>P,optional:()=>me,partialRecord:()=>gk,pipe:()=>Da,prefault:()=>ev,preprocess:()=>Va,promise:()=>Ik,readonly:()=>sv,record:()=>fe,refine:()=>fv,set:()=>yk,strictObject:()=>mk,string:()=>v,stringFormat:()=>YS,stringbool:()=>Dk,success:()=>Sk,superRefine:()=>mv,symbol:()=>ck,templateLiteral:()=>Ek,transform:()=>wd,tuple:()=>Fg,uint32:()=>ok,uint64:()=>sk,ulid:()=>US,undefined:()=>uk,union:()=>ae,unknown:()=>le,url:()=>DS,uuid:()=>PS,uuidv4:()=>TS,uuidv6:()=>OS,uuidv7:()=>jS,void:()=>dk,xid:()=>ZS,xor:()=>hk});var Ta={};Fn(Ta,{endsWith:()=>To,gt:()=>Ft,gte:()=>Ue,includes:()=>zo,length:()=>dn,lowercase:()=>Eo,lt:()=>Lt,lte:()=>et,maxLength:()=>ln,maxSize:()=>Pr,mime:()=>Oo,minLength:()=>lr,minSize:()=>qt,multipleOf:()=>zr,negative:()=>Ml,nonnegative:()=>Cl,nonpositive:()=>Al,normalize:()=>jo,overwrite:()=>It,positive:()=>Rl,property:()=>Ul,regex:()=>wo,size:()=>un,slugify:()=>wa,startsWith:()=>Po,toLowerCase:()=>No,toUpperCase:()=>Ro,trim:()=>Do,uppercase:()=>Io});var Tr={};Fn(Tr,{ZodISODate:()=>Xl,ZodISODateTime:()=>Bl,ZodISODuration:()=>rd,ZodISOTime:()=>ed,date:()=>Ql,datetime:()=>Yl,duration:()=>nd,time:()=>td});var Bl=m("ZodISODateTime",(e,t)=>{lu.init(e,t),ue.init(e,t)});function Yl(e){return pl(Bl,e)}var Xl=m("ZodISODate",(e,t)=>{du.init(e,t),ue.init(e,t)});function Ql(e){return fl(Xl,e)}var ed=m("ZodISOTime",(e,t)=>{pu.init(e,t),ue.init(e,t)});function td(e){return ml(ed,e)}var rd=m("ZodISODuration",(e,t)=>{fu.init(e,t),ue.init(e,t)});function nd(e){return hl(rd,e)}var gg=(e,t)=>{Vi.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:r=>Ji(e,r)},flatten:{value:r=>Wi(e,r)},addIssue:{value:r=>{e.issues.push(r),e.message=JSON.stringify(e.issues,on,2)}},addIssues:{value:r=>{e.issues.push(...r),e.message=JSON.stringify(e.issues,on,2)}},isEmpty:{get(){return e.issues.length===0}}})},bA=m("ZodError",gg),tt=m("ZodError",gg,{Parent:Error});var vg=uo(tt),_g=po(tt),yg=mo(tt),$g=ho(tt),bg=Om(tt),xg=jm(tt),Sg=Dm(tt),kg=Nm(tt),wg=Rm(tt),Eg=Mm(tt),Ig=Am(tt),zg=Cm(tt);var q=m("ZodType",(e,t)=>(L.init(e,t),Object.assign(e["~standard"],{jsonSchema:{input:Mo(e,"input"),output:Mo(e,"output")}}),e.toJSONSchema=zh(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.check=(...r)=>e.clone($.mergeDefs(t,{checks:[...t.checks??[],...r.map(n=>typeof n=="function"?{_zod:{check:n,def:{check:"custom"},onattach:[]}}:n)]}),{parent:!0}),e.with=e.check,e.clone=(r,n)=>Ae(e,r,n),e.brand=()=>e,e.register=((r,n)=>(r.add(e,n),e)),e.parse=(r,n)=>vg(e,r,n,{callee:e.parse}),e.safeParse=(r,n)=>yg(e,r,n),e.parseAsync=async(r,n)=>_g(e,r,n,{callee:e.parseAsync}),e.safeParseAsync=async(r,n)=>$g(e,r,n),e.spa=e.safeParseAsync,e.encode=(r,n)=>bg(e,r,n),e.decode=(r,n)=>xg(e,r,n),e.encodeAsync=async(r,n)=>Sg(e,r,n),e.decodeAsync=async(r,n)=>kg(e,r,n),e.safeEncode=(r,n)=>wg(e,r,n),e.safeDecode=(r,n)=>Eg(e,r,n),e.safeEncodeAsync=async(r,n)=>Ig(e,r,n),e.safeDecodeAsync=async(r,n)=>zg(e,r,n),e.refine=(r,n)=>e.check(fv(r,n)),e.superRefine=r=>e.check(mv(r)),e.overwrite=r=>e.check(It(r)),e.optional=()=>me(e),e.exactOptional=()=>Kg(e),e.nullable=()=>ja(e),e.nullish=()=>me(ja(e)),e.nonoptional=r=>tv(e,r),e.array=()=>B(e),e.or=r=>ae([e,r]),e.and=r=>Lo(e,r),e.transform=r=>Da(e,wd(r)),e.default=r=>Xg(e,r),e.prefault=r=>ev(e,r),e.catch=r=>ov(e,r),e.pipe=r=>Da(e,r),e.readonly=()=>sv(e),e.describe=r=>{let n=e.clone();return Ce.add(n,{description:r}),n},Object.defineProperty(e,"description",{get(){return Ce.get(e)?.description},configurable:!0}),e.meta=(...r)=>{if(r.length===0)return Ce.get(e);let n=e.clone();return Ce.add(n,r[0]),n},e.isOptional=()=>e.safeParse(void 0).success,e.isNullable=()=>e.safeParse(null).success,e.apply=r=>r(e),e)),id=m("_ZodString",(e,t)=>{Ir.init(e,t),q.init(e,t),e._zod.processJSONSchema=(n,o,i)=>Ph(e,n,o,i);let r=e._zod.bag;e.format=r.format??null,e.minLength=r.minimum??null,e.maxLength=r.maximum??null,e.regex=(...n)=>e.check(wo(...n)),e.includes=(...n)=>e.check(zo(...n)),e.startsWith=(...n)=>e.check(Po(...n)),e.endsWith=(...n)=>e.check(To(...n)),e.min=(...n)=>e.check(lr(...n)),e.max=(...n)=>e.check(ln(...n)),e.length=(...n)=>e.check(dn(...n)),e.nonempty=(...n)=>e.check(lr(1,...n)),e.lowercase=n=>e.check(Eo(n)),e.uppercase=n=>e.check(Io(n)),e.trim=()=>e.check(Do()),e.normalize=(...n)=>e.check(jo(...n)),e.toLowerCase=()=>e.check(No()),e.toUpperCase=()=>e.check(Ro()),e.slugify=()=>e.check(wa())}),Na=m("ZodString",(e,t)=>{Ir.init(e,t),id.init(e,t),e.email=r=>e.check(ia(ad,r)),e.url=r=>e.check(ko(Ra,r)),e.jwt=r=>e.check(ka(bd,r)),e.emoji=r=>e.check(la(sd,r)),e.guid=r=>e.check(So(Oa,r)),e.uuid=r=>e.check(aa(Vt,r)),e.uuidv4=r=>e.check(sa(Vt,r)),e.uuidv6=r=>e.check(ca(Vt,r)),e.uuidv7=r=>e.check(ua(Vt,r)),e.nanoid=r=>e.check(da(cd,r)),e.guid=r=>e.check(So(Oa,r)),e.cuid=r=>e.check(pa(ud,r)),e.cuid2=r=>e.check(fa(ld,r)),e.ulid=r=>e.check(ma(dd,r)),e.base64=r=>e.check(ba(_d,r)),e.base64url=r=>e.check(xa(yd,r)),e.xid=r=>e.check(ha(pd,r)),e.ksuid=r=>e.check(ga(fd,r)),e.ipv4=r=>e.check(va(md,r)),e.ipv6=r=>e.check(_a(hd,r)),e.cidrv4=r=>e.check(ya(gd,r)),e.cidrv6=r=>e.check($a(vd,r)),e.e164=r=>e.check(Sa($d,r)),e.datetime=r=>e.check(Yl(r)),e.date=r=>e.check(Ql(r)),e.time=r=>e.check(td(r)),e.duration=r=>e.check(nd(r))});function v(e){return ll(Na,e)}var ue=m("ZodStringFormat",(e,t)=>{ie.init(e,t),id.init(e,t)}),ad=m("ZodEmail",(e,t)=>{tu.init(e,t),ue.init(e,t)});function IS(e){return ia(ad,e)}var Oa=m("ZodGUID",(e,t)=>{Qc.init(e,t),ue.init(e,t)});function zS(e){return So(Oa,e)}var Vt=m("ZodUUID",(e,t)=>{eu.init(e,t),ue.init(e,t)});function PS(e){return aa(Vt,e)}function TS(e){return sa(Vt,e)}function OS(e){return ca(Vt,e)}function jS(e){return ua(Vt,e)}var Ra=m("ZodURL",(e,t)=>{ru.init(e,t),ue.init(e,t)});function DS(e){return ko(Ra,e)}function NS(e){return ko(Ra,{protocol:/^https?$/,hostname:it.domain,...$.normalizeParams(e)})}var sd=m("ZodEmoji",(e,t)=>{nu.init(e,t),ue.init(e,t)});function RS(e){return la(sd,e)}var cd=m("ZodNanoID",(e,t)=>{ou.init(e,t),ue.init(e,t)});function MS(e){return da(cd,e)}var ud=m("ZodCUID",(e,t)=>{iu.init(e,t),ue.init(e,t)});function AS(e){return pa(ud,e)}var ld=m("ZodCUID2",(e,t)=>{au.init(e,t),ue.init(e,t)});function CS(e){return fa(ld,e)}var dd=m("ZodULID",(e,t)=>{su.init(e,t),ue.init(e,t)});function US(e){return ma(dd,e)}var pd=m("ZodXID",(e,t)=>{cu.init(e,t),ue.init(e,t)});function ZS(e){return ha(pd,e)}var fd=m("ZodKSUID",(e,t)=>{uu.init(e,t),ue.init(e,t)});function LS(e){return ga(fd,e)}var md=m("ZodIPv4",(e,t)=>{mu.init(e,t),ue.init(e,t)});function FS(e){return va(md,e)}var Pg=m("ZodMAC",(e,t)=>{gu.init(e,t),ue.init(e,t)});function qS(e){return dl(Pg,e)}var hd=m("ZodIPv6",(e,t)=>{hu.init(e,t),ue.init(e,t)});function VS(e){return _a(hd,e)}var gd=m("ZodCIDRv4",(e,t)=>{vu.init(e,t),ue.init(e,t)});function WS(e){return ya(gd,e)}var vd=m("ZodCIDRv6",(e,t)=>{_u.init(e,t),ue.init(e,t)});function JS(e){return $a(vd,e)}var _d=m("ZodBase64",(e,t)=>{yu.init(e,t),ue.init(e,t)});function HS(e){return ba(_d,e)}var yd=m("ZodBase64URL",(e,t)=>{$u.init(e,t),ue.init(e,t)});function GS(e){return xa(yd,e)}var $d=m("ZodE164",(e,t)=>{bu.init(e,t),ue.init(e,t)});function KS(e){return Sa($d,e)}var bd=m("ZodJWT",(e,t)=>{xu.init(e,t),ue.init(e,t)});function BS(e){return ka(bd,e)}var Uo=m("ZodCustomStringFormat",(e,t)=>{Su.init(e,t),ue.init(e,t)});function YS(e,t,r={}){return pn(Uo,e,t,r)}function XS(e){return pn(Uo,"hostname",it.hostname,e)}function QS(e){return pn(Uo,"hex",it.hex,e)}function ek(e,t){let r=t?.enc??"hex",n=`${e}_${r}`,o=it[n];if(!o)throw new Error(`Unrecognized hash format: ${n}`);return pn(Uo,n,o,t)}var Ma=m("ZodNumber",(e,t)=>{ta.init(e,t),q.init(e,t),e._zod.processJSONSchema=(n,o,i)=>Th(e,n,o,i),e.gt=(n,o)=>e.check(Ft(n,o)),e.gte=(n,o)=>e.check(Ue(n,o)),e.min=(n,o)=>e.check(Ue(n,o)),e.lt=(n,o)=>e.check(Lt(n,o)),e.lte=(n,o)=>e.check(et(n,o)),e.max=(n,o)=>e.check(et(n,o)),e.int=n=>e.check(od(n)),e.safe=n=>e.check(od(n)),e.positive=n=>e.check(Ft(0,n)),e.nonnegative=n=>e.check(Ue(0,n)),e.negative=n=>e.check(Lt(0,n)),e.nonpositive=n=>e.check(et(0,n)),e.multipleOf=(n,o)=>e.check(zr(n,o)),e.step=(n,o)=>e.check(zr(n,o)),e.finite=()=>e;let r=e._zod.bag;e.minValue=Math.max(r.minimum??Number.NEGATIVE_INFINITY,r.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,e.maxValue=Math.min(r.maximum??Number.POSITIVE_INFINITY,r.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,e.isInt=(r.format??"").includes("int")||Number.isSafeInteger(r.multipleOf??.5),e.isFinite=!0,e.format=r.format??null});function oe(e){return gl(Ma,e)}var mn=m("ZodNumberFormat",(e,t)=>{ku.init(e,t),Ma.init(e,t)});function od(e){return vl(mn,e)}function tk(e){return _l(mn,e)}function rk(e){return yl(mn,e)}function nk(e){return $l(mn,e)}function ok(e){return bl(mn,e)}var Aa=m("ZodBoolean",(e,t)=>{$o.init(e,t),q.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Oh(e,r,n,o)});function $e(e){return xl(Aa,e)}var Ca=m("ZodBigInt",(e,t)=>{ra.init(e,t),q.init(e,t),e._zod.processJSONSchema=(n,o,i)=>jh(e,n,o,i),e.gte=(n,o)=>e.check(Ue(n,o)),e.min=(n,o)=>e.check(Ue(n,o)),e.gt=(n,o)=>e.check(Ft(n,o)),e.gte=(n,o)=>e.check(Ue(n,o)),e.min=(n,o)=>e.check(Ue(n,o)),e.lt=(n,o)=>e.check(Lt(n,o)),e.lte=(n,o)=>e.check(et(n,o)),e.max=(n,o)=>e.check(et(n,o)),e.positive=n=>e.check(Ft(BigInt(0),n)),e.negative=n=>e.check(Lt(BigInt(0),n)),e.nonpositive=n=>e.check(et(BigInt(0),n)),e.nonnegative=n=>e.check(Ue(BigInt(0),n)),e.multipleOf=(n,o)=>e.check(zr(n,o));let r=e._zod.bag;e.minValue=r.minimum??null,e.maxValue=r.maximum??null,e.format=r.format??null});function ik(e){return Sl(Ca,e)}var xd=m("ZodBigIntFormat",(e,t)=>{wu.init(e,t),Ca.init(e,t)});function ak(e){return kl(xd,e)}function sk(e){return wl(xd,e)}var Tg=m("ZodSymbol",(e,t)=>{Eu.init(e,t),q.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Dh(e,r,n,o)});function ck(e){return El(Tg,e)}var Og=m("ZodUndefined",(e,t)=>{Iu.init(e,t),q.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Rh(e,r,n,o)});function uk(e){return Il(Og,e)}var jg=m("ZodNull",(e,t)=>{zu.init(e,t),q.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Nh(e,r,n,o)});function Zo(e){return zl(jg,e)}var Dg=m("ZodAny",(e,t)=>{Pu.init(e,t),q.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Ch(e,r,n,o)});function lk(){return Pl(Dg)}var Ng=m("ZodUnknown",(e,t)=>{Tu.init(e,t),q.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Uh(e,r,n,o)});function le(){return Tl(Ng)}var Rg=m("ZodNever",(e,t)=>{Ou.init(e,t),q.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Ah(e,r,n,o)});function Sd(e){return Ol(Rg,e)}var Mg=m("ZodVoid",(e,t)=>{ju.init(e,t),q.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Mh(e,r,n,o)});function dk(e){return jl(Mg,e)}var kd=m("ZodDate",(e,t)=>{Du.init(e,t),q.init(e,t),e._zod.processJSONSchema=(n,o,i)=>Zh(e,n,o,i),e.min=(n,o)=>e.check(Ue(n,o)),e.max=(n,o)=>e.check(et(n,o));let r=e._zod.bag;e.minDate=r.minimum?new Date(r.minimum):null,e.maxDate=r.maximum?new Date(r.maximum):null});function pk(e){return Dl(kd,e)}var Ag=m("ZodArray",(e,t)=>{Nu.init(e,t),q.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Xh(e,r,n,o),e.element=t.element,e.min=(r,n)=>e.check(lr(r,n)),e.nonempty=r=>e.check(lr(1,r)),e.max=(r,n)=>e.check(ln(r,n)),e.length=(r,n)=>e.check(dn(r,n)),e.unwrap=()=>e.element});function B(e,t){return Ih(Ag,e,t)}function fk(e){let t=e._zod.def.shape;return Oe(Object.keys(t))}var Ua=m("ZodObject",(e,t)=>{wh.init(e,t),q.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Qh(e,r,n,o),$.defineLazy(e,"shape",()=>t.shape),e.keyof=()=>Oe(Object.keys(e._zod.def.shape)),e.catchall=r=>e.clone({...e._zod.def,catchall:r}),e.passthrough=()=>e.clone({...e._zod.def,catchall:le()}),e.loose=()=>e.clone({...e._zod.def,catchall:le()}),e.strict=()=>e.clone({...e._zod.def,catchall:Sd()}),e.strip=()=>e.clone({...e._zod.def,catchall:void 0}),e.extend=r=>$.extend(e,r),e.safeExtend=r=>$.safeExtend(e,r),e.merge=r=>$.merge(e,r),e.pick=r=>$.pick(e,r),e.omit=r=>$.omit(e,r),e.partial=(...r)=>$.partial(Ed,e,r[0]),e.required=(...r)=>$.required(Id,e,r[0])});function P(e,t){let r={type:"object",shape:e??{},...$.normalizeParams(t)};return new Ua(r)}function mk(e,t){return new Ua({type:"object",shape:e,catchall:Sd(),...$.normalizeParams(t)})}function Te(e,t){return new Ua({type:"object",shape:e,catchall:le(),...$.normalizeParams(t)})}var Za=m("ZodUnion",(e,t)=>{bo.init(e,t),q.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Hl(e,r,n,o),e.options=t.options});function ae(e,t){return new Za({type:"union",options:e,...$.normalizeParams(t)})}var Cg=m("ZodXor",(e,t)=>{Za.init(e,t),Ru.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Hl(e,r,n,o),e.options=t.options});function hk(e,t){return new Cg({type:"union",options:e,inclusive:!1,...$.normalizeParams(t)})}var Ug=m("ZodDiscriminatedUnion",(e,t)=>{Za.init(e,t),Mu.init(e,t)});function La(e,t,r){return new Ug({type:"union",options:t,discriminator:e,...$.normalizeParams(r)})}var Zg=m("ZodIntersection",(e,t)=>{Au.init(e,t),q.init(e,t),e._zod.processJSONSchema=(r,n,o)=>eg(e,r,n,o)});function Lo(e,t){return new Zg({type:"intersection",left:e,right:t})}var Lg=m("ZodTuple",(e,t)=>{na.init(e,t),q.init(e,t),e._zod.processJSONSchema=(r,n,o)=>tg(e,r,n,o),e.rest=r=>e.clone({...e._zod.def,rest:r})});function Fg(e,t,r){let n=t instanceof L,o=n?r:t,i=n?t:null;return new Lg({type:"tuple",items:e,rest:i,...$.normalizeParams(o)})}var Fa=m("ZodRecord",(e,t)=>{Cu.init(e,t),q.init(e,t),e._zod.processJSONSchema=(r,n,o)=>rg(e,r,n,o),e.keyType=t.keyType,e.valueType=t.valueType});function fe(e,t,r){return new Fa({type:"record",keyType:e,valueType:t,...$.normalizeParams(r)})}function gk(e,t,r){let n=Ae(e);return n._zod.values=void 0,new Fa({type:"record",keyType:n,valueType:t,...$.normalizeParams(r)})}function vk(e,t,r){return new Fa({type:"record",keyType:e,valueType:t,mode:"loose",...$.normalizeParams(r)})}var qg=m("ZodMap",(e,t)=>{Uu.init(e,t),q.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Bh(e,r,n,o),e.keyType=t.keyType,e.valueType=t.valueType,e.min=(...r)=>e.check(qt(...r)),e.nonempty=r=>e.check(qt(1,r)),e.max=(...r)=>e.check(Pr(...r)),e.size=(...r)=>e.check(un(...r))});function _k(e,t,r){return new qg({type:"map",keyType:e,valueType:t,...$.normalizeParams(r)})}var Vg=m("ZodSet",(e,t)=>{Zu.init(e,t),q.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Yh(e,r,n,o),e.min=(...r)=>e.check(qt(...r)),e.nonempty=r=>e.check(qt(1,r)),e.max=(...r)=>e.check(Pr(...r)),e.size=(...r)=>e.check(un(...r))});function yk(e,t){return new Vg({type:"set",valueType:e,...$.normalizeParams(t)})}var Co=m("ZodEnum",(e,t)=>{Lu.init(e,t),q.init(e,t),e._zod.processJSONSchema=(n,o,i)=>Lh(e,n,o,i),e.enum=t.entries,e.options=Object.values(t.entries);let r=new Set(Object.keys(t.entries));e.extract=(n,o)=>{let i={};for(let a of n)if(r.has(a))i[a]=t.entries[a];else throw new Error(`Key ${a} not found in enum`);return new Co({...t,checks:[],...$.normalizeParams(o),entries:i})},e.exclude=(n,o)=>{let i={...t.entries};for(let a of n)if(r.has(a))delete i[a];else throw new Error(`Key ${a} not found in enum`);return new Co({...t,checks:[],...$.normalizeParams(o),entries:i})}});function Oe(e,t){let r=Array.isArray(e)?Object.fromEntries(e.map(n=>[n,n])):e;return new Co({type:"enum",entries:r,...$.normalizeParams(t)})}function $k(e,t){return new Co({type:"enum",entries:e,...$.normalizeParams(t)})}var Wg=m("ZodLiteral",(e,t)=>{Fu.init(e,t),q.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Fh(e,r,n,o),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function j(e,t){return new Wg({type:"literal",values:Array.isArray(e)?e:[e],...$.normalizeParams(t)})}var Jg=m("ZodFile",(e,t)=>{qu.init(e,t),q.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Wh(e,r,n,o),e.min=(r,n)=>e.check(qt(r,n)),e.max=(r,n)=>e.check(Pr(r,n)),e.mime=(r,n)=>e.check(Oo(Array.isArray(r)?r:[r],n))});function bk(e){return Zl(Jg,e)}var Hg=m("ZodTransform",(e,t)=>{Vu.init(e,t),q.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Kh(e,r,n,o),e._zod.parse=(r,n)=>{if(n.direction==="backward")throw new kr(e.constructor.name);r.addIssue=i=>{if(typeof i=="string")r.issues.push($.issue(i,r.value,t));else{let a=i;a.fatal&&(a.continue=!1),a.code??(a.code="custom"),a.input??(a.input=r.value),a.inst??(a.inst=e),r.issues.push($.issue(a))}};let o=t.transform(r.value,r);return o instanceof Promise?o.then(i=>(r.value=i,r)):(r.value=o,r)}});function wd(e){return new Hg({type:"transform",transform:e})}var Ed=m("ZodOptional",(e,t)=>{oa.init(e,t),q.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Gl(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function me(e){return new Ed({type:"optional",innerType:e})}var Gg=m("ZodExactOptional",(e,t)=>{Wu.init(e,t),q.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Gl(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function Kg(e){return new Gg({type:"optional",innerType:e})}var Bg=m("ZodNullable",(e,t)=>{Ju.init(e,t),q.init(e,t),e._zod.processJSONSchema=(r,n,o)=>ng(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function ja(e){return new Bg({type:"nullable",innerType:e})}function xk(e){return me(ja(e))}var Yg=m("ZodDefault",(e,t)=>{Hu.init(e,t),q.init(e,t),e._zod.processJSONSchema=(r,n,o)=>ig(e,r,n,o),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function Xg(e,t){return new Yg({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():$.shallowClone(t)}})}var Qg=m("ZodPrefault",(e,t)=>{Gu.init(e,t),q.init(e,t),e._zod.processJSONSchema=(r,n,o)=>ag(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function ev(e,t){return new Qg({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():$.shallowClone(t)}})}var Id=m("ZodNonOptional",(e,t)=>{Ku.init(e,t),q.init(e,t),e._zod.processJSONSchema=(r,n,o)=>og(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function tv(e,t){return new Id({type:"nonoptional",innerType:e,...$.normalizeParams(t)})}var rv=m("ZodSuccess",(e,t)=>{Bu.init(e,t),q.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Jh(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function Sk(e){return new rv({type:"success",innerType:e})}var nv=m("ZodCatch",(e,t)=>{Yu.init(e,t),q.init(e,t),e._zod.processJSONSchema=(r,n,o)=>sg(e,r,n,o),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function ov(e,t){return new nv({type:"catch",innerType:e,catchValue:typeof t=="function"?t:()=>t})}var iv=m("ZodNaN",(e,t)=>{Xu.init(e,t),q.init(e,t),e._zod.processJSONSchema=(r,n,o)=>qh(e,r,n,o)});function kk(e){return Nl(iv,e)}var zd=m("ZodPipe",(e,t)=>{Qu.init(e,t),q.init(e,t),e._zod.processJSONSchema=(r,n,o)=>cg(e,r,n,o),e.in=t.in,e.out=t.out});function Da(e,t){return new zd({type:"pipe",in:e,out:t})}var Pd=m("ZodCodec",(e,t)=>{zd.init(e,t),xo.init(e,t)});function wk(e,t,r){return new Pd({type:"pipe",in:e,out:t,transform:r.decode,reverseTransform:r.encode})}var av=m("ZodReadonly",(e,t)=>{el.init(e,t),q.init(e,t),e._zod.processJSONSchema=(r,n,o)=>ug(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function sv(e){return new av({type:"readonly",innerType:e})}var cv=m("ZodTemplateLiteral",(e,t)=>{tl.init(e,t),q.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Vh(e,r,n,o)});function Ek(e,t){return new cv({type:"template_literal",parts:e,...$.normalizeParams(t)})}var uv=m("ZodLazy",(e,t)=>{ol.init(e,t),q.init(e,t),e._zod.processJSONSchema=(r,n,o)=>dg(e,r,n,o),e.unwrap=()=>e._zod.def.getter()});function lv(e){return new uv({type:"lazy",getter:e})}var dv=m("ZodPromise",(e,t)=>{nl.init(e,t),q.init(e,t),e._zod.processJSONSchema=(r,n,o)=>lg(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function Ik(e){return new dv({type:"promise",innerType:e})}var pv=m("ZodFunction",(e,t)=>{rl.init(e,t),q.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Gh(e,r,n,o)});function zk(e){return new pv({type:"function",input:Array.isArray(e?.input)?Fg(e?.input):e?.input??B(le()),output:e?.output??le()})}var qa=m("ZodCustom",(e,t)=>{il.init(e,t),q.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Hh(e,r,n,o)});function Pk(e){let t=new ce({check:"custom"});return t._zod.check=e,t}function Td(e,t){return Ll(qa,e??(()=>!0),t)}function fv(e,t={}){return Fl(qa,e,t)}function mv(e){return ql(e)}var Tk=Vl,Ok=Wl;function jk(e,t={}){let r=new qa({type:"custom",check:"custom",fn:n=>n instanceof e,abort:!0,...$.normalizeParams(t)});return r._zod.bag.Class=e,r._zod.check=n=>{n.value instanceof e||n.issues.push({code:"invalid_type",expected:e.name,input:n.value,inst:r,path:[...r._zod.def.path??[]]})},r}var Dk=(...e)=>Jl({Codec:Pd,Boolean:Aa,String:Na},...e);function Nk(e){let t=lv(()=>ae([v(e),oe(),$e(),Zo(),B(t),fe(v(),t)]));return t}function Va(e,t){return Da(wd(e),t)}var hv;hv||(hv={});var PA={...Ao,...Ta,iso:Tr};be(al());var jd="2025-11-25";var gv=[jd,"2025-06-18","2025-03-26","2024-11-05","2024-10-07"],pr="io.modelcontextprotocol/related-task",Ja="2.0",xe=Td(e=>e!==null&&(typeof e=="object"||typeof e=="function")),vv=ae([v(),oe().int()]),_v=v(),GA=Te({ttl:ae([oe(),Zo()]).optional(),pollInterval:oe().optional()}),Ck=P({ttl:oe().optional()}),Uk=P({taskId:v()}),Dd=Te({progressToken:vv.optional(),[pr]:Uk.optional()}),rt=P({_meta:Dd.optional()}),Fo=rt.extend({task:Ck.optional()}),yv=e=>Fo.safeParse(e).success,Se=P({method:v(),params:rt.loose().optional()}),at=P({_meta:Dd.optional()}),st=P({method:v(),params:at.loose().optional()}),ke=Te({_meta:Dd.optional()}),Ha=ae([v(),oe().int()]),$v=P({jsonrpc:j(Ja),id:Ha,...Se.shape}).strict(),Nd=e=>$v.safeParse(e).success,bv=P({jsonrpc:j(Ja),...st.shape}).strict(),xv=e=>bv.safeParse(e).success,Rd=P({jsonrpc:j(Ja),id:Ha,result:ke}).strict(),qo=e=>Rd.safeParse(e).success;var Q;(function(e){e[e.ConnectionClosed=-32e3]="ConnectionClosed",e[e.RequestTimeout=-32001]="RequestTimeout",e[e.ParseError=-32700]="ParseError",e[e.InvalidRequest=-32600]="InvalidRequest",e[e.MethodNotFound=-32601]="MethodNotFound",e[e.InvalidParams=-32602]="InvalidParams",e[e.InternalError=-32603]="InternalError",e[e.UrlElicitationRequired=-32042]="UrlElicitationRequired"})(Q||(Q={}));var Md=P({jsonrpc:j(Ja),id:Ha.optional(),error:P({code:oe().int(),message:v(),data:le().optional()})}).strict();var Sv=e=>Md.safeParse(e).success;var kv=ae([$v,bv,Rd,Md]),KA=ae([Rd,Md]),Ga=ke.strict(),Zk=at.extend({requestId:Ha.optional(),reason:v().optional()}),Ka=st.extend({method:j("notifications/cancelled"),params:Zk}),Lk=P({src:v(),mimeType:v().optional(),sizes:B(v()).optional(),theme:Oe(["light","dark"]).optional()}),Vo=P({icons:B(Lk).optional()}),hn=P({name:v(),title:v().optional()}),wv=hn.extend({...hn.shape,...Vo.shape,version:v(),websiteUrl:v().optional(),description:v().optional()}),Fk=Lo(P({applyDefaults:$e().optional()}),fe(v(),le())),qk=Va(e=>e&&typeof e=="object"&&!Array.isArray(e)&&Object.keys(e).length===0?{form:{}}:e,Lo(P({form:Fk.optional(),url:xe.optional()}),fe(v(),le()).optional())),Vk=Te({list:xe.optional(),cancel:xe.optional(),requests:Te({sampling:Te({createMessage:xe.optional()}).optional(),elicitation:Te({create:xe.optional()}).optional()}).optional()}),Wk=Te({list:xe.optional(),cancel:xe.optional(),requests:Te({tools:Te({call:xe.optional()}).optional()}).optional()}),Jk=P({experimental:fe(v(),xe).optional(),sampling:P({context:xe.optional(),tools:xe.optional()}).optional(),elicitation:qk.optional(),roots:P({listChanged:$e().optional()}).optional(),tasks:Vk.optional()}),Hk=rt.extend({protocolVersion:v(),capabilities:Jk,clientInfo:wv}),Ad=Se.extend({method:j("initialize"),params:Hk});var Gk=P({experimental:fe(v(),xe).optional(),logging:xe.optional(),completions:xe.optional(),prompts:P({listChanged:$e().optional()}).optional(),resources:P({subscribe:$e().optional(),listChanged:$e().optional()}).optional(),tools:P({listChanged:$e().optional()}).optional(),tasks:Wk.optional()}),Kk=ke.extend({protocolVersion:v(),capabilities:Gk,serverInfo:wv,instructions:v().optional()}),Cd=st.extend({method:j("notifications/initialized"),params:at.optional()});var Ba=Se.extend({method:j("ping"),params:rt.optional()}),Bk=P({progress:oe(),total:me(oe()),message:me(v())}),Yk=P({...at.shape,...Bk.shape,progressToken:vv}),Ya=st.extend({method:j("notifications/progress"),params:Yk}),Xk=rt.extend({cursor:_v.optional()}),Wo=Se.extend({params:Xk.optional()}),Jo=ke.extend({nextCursor:_v.optional()}),Qk=Oe(["working","input_required","completed","failed","cancelled"]),Ho=P({taskId:v(),status:Qk,ttl:ae([oe(),Zo()]),createdAt:v(),lastUpdatedAt:v(),pollInterval:me(oe()),statusMessage:me(v())}),gn=ke.extend({task:Ho}),ew=at.merge(Ho),Go=st.extend({method:j("notifications/tasks/status"),params:ew}),Xa=Se.extend({method:j("tasks/get"),params:rt.extend({taskId:v()})}),Qa=ke.merge(Ho),es=Se.extend({method:j("tasks/result"),params:rt.extend({taskId:v()})}),BA=ke.loose(),ts=Wo.extend({method:j("tasks/list")}),rs=Jo.extend({tasks:B(Ho)}),ns=Se.extend({method:j("tasks/cancel"),params:rt.extend({taskId:v()})}),Ev=ke.merge(Ho),Iv=P({uri:v(),mimeType:me(v()),_meta:fe(v(),le()).optional()}),zv=Iv.extend({text:v()}),Ud=v().refine(e=>{try{return atob(e),!0}catch{return!1}},{message:"Invalid Base64 string"}),Pv=Iv.extend({blob:Ud}),Ko=Oe(["user","assistant"]),vn=P({audience:B(Ko).optional(),priority:oe().min(0).max(1).optional(),lastModified:Tr.datetime({offset:!0}).optional()}),Tv=P({...hn.shape,...Vo.shape,uri:v(),description:me(v()),mimeType:me(v()),annotations:vn.optional(),_meta:me(Te({}))}),tw=P({...hn.shape,...Vo.shape,uriTemplate:v(),description:me(v()),mimeType:me(v()),annotations:vn.optional(),_meta:me(Te({}))}),rw=Wo.extend({method:j("resources/list")}),nw=Jo.extend({resources:B(Tv)}),ow=Wo.extend({method:j("resources/templates/list")}),iw=Jo.extend({resourceTemplates:B(tw)}),Zd=rt.extend({uri:v()}),aw=Zd,sw=Se.extend({method:j("resources/read"),params:aw}),cw=ke.extend({contents:B(ae([zv,Pv]))}),uw=st.extend({method:j("notifications/resources/list_changed"),params:at.optional()}),lw=Zd,dw=Se.extend({method:j("resources/subscribe"),params:lw}),pw=Zd,fw=Se.extend({method:j("resources/unsubscribe"),params:pw}),mw=at.extend({uri:v()}),hw=st.extend({method:j("notifications/resources/updated"),params:mw}),gw=P({name:v(),description:me(v()),required:me($e())}),vw=P({...hn.shape,...Vo.shape,description:me(v()),arguments:me(B(gw)),_meta:me(Te({}))}),_w=Wo.extend({method:j("prompts/list")}),yw=Jo.extend({prompts:B(vw)}),$w=rt.extend({name:v(),arguments:fe(v(),v()).optional()}),bw=Se.extend({method:j("prompts/get"),params:$w}),Ld=P({type:j("text"),text:v(),annotations:vn.optional(),_meta:fe(v(),le()).optional()}),Fd=P({type:j("image"),data:Ud,mimeType:v(),annotations:vn.optional(),_meta:fe(v(),le()).optional()}),qd=P({type:j("audio"),data:Ud,mimeType:v(),annotations:vn.optional(),_meta:fe(v(),le()).optional()}),xw=P({type:j("tool_use"),name:v(),id:v(),input:fe(v(),le()),_meta:fe(v(),le()).optional()}),Sw=P({type:j("resource"),resource:ae([zv,Pv]),annotations:vn.optional(),_meta:fe(v(),le()).optional()}),kw=Tv.extend({type:j("resource_link")}),Vd=ae([Ld,Fd,qd,kw,Sw]),ww=P({role:Ko,content:Vd}),Ew=ke.extend({description:v().optional(),messages:B(ww)}),Iw=st.extend({method:j("notifications/prompts/list_changed"),params:at.optional()}),zw=P({title:v().optional(),readOnlyHint:$e().optional(),destructiveHint:$e().optional(),idempotentHint:$e().optional(),openWorldHint:$e().optional()}),Pw=P({taskSupport:Oe(["required","optional","forbidden"]).optional()}),Ov=P({...hn.shape,...Vo.shape,description:v().optional(),inputSchema:P({type:j("object"),properties:fe(v(),xe).optional(),required:B(v()).optional()}).catchall(le()),outputSchema:P({type:j("object"),properties:fe(v(),xe).optional(),required:B(v()).optional()}).catchall(le()).optional(),annotations:zw.optional(),execution:Pw.optional(),_meta:fe(v(),le()).optional()}),Wd=Wo.extend({method:j("tools/list")}),Tw=Jo.extend({tools:B(Ov)}),os=ke.extend({content:B(Vd).default([]),structuredContent:fe(v(),le()).optional(),isError:$e().optional()}),YA=os.or(ke.extend({toolResult:le()})),Ow=Fo.extend({name:v(),arguments:fe(v(),le()).optional()}),Bo=Se.extend({method:j("tools/call"),params:Ow}),jw=st.extend({method:j("notifications/tools/list_changed"),params:at.optional()}),XA=P({autoRefresh:$e().default(!0),debounceMs:oe().int().nonnegative().default(300)}),Yo=Oe(["debug","info","notice","warning","error","critical","alert","emergency"]),Dw=rt.extend({level:Yo}),Jd=Se.extend({method:j("logging/setLevel"),params:Dw}),Nw=at.extend({level:Yo,logger:v().optional(),data:le()}),Rw=st.extend({method:j("notifications/message"),params:Nw}),Mw=P({name:v().optional()}),Aw=P({hints:B(Mw).optional(),costPriority:oe().min(0).max(1).optional(),speedPriority:oe().min(0).max(1).optional(),intelligencePriority:oe().min(0).max(1).optional()}),Cw=P({mode:Oe(["auto","required","none"]).optional()}),Uw=P({type:j("tool_result"),toolUseId:v().describe("The unique identifier for the corresponding tool call."),content:B(Vd).default([]),structuredContent:P({}).loose().optional(),isError:$e().optional(),_meta:fe(v(),le()).optional()}),Zw=La("type",[Ld,Fd,qd]),Wa=La("type",[Ld,Fd,qd,xw,Uw]),Lw=P({role:Ko,content:ae([Wa,B(Wa)]),_meta:fe(v(),le()).optional()}),Fw=Fo.extend({messages:B(Lw),modelPreferences:Aw.optional(),systemPrompt:v().optional(),includeContext:Oe(["none","thisServer","allServers"]).optional(),temperature:oe().optional(),maxTokens:oe().int(),stopSequences:B(v()).optional(),metadata:xe.optional(),tools:B(Ov).optional(),toolChoice:Cw.optional()}),qw=Se.extend({method:j("sampling/createMessage"),params:Fw}),Hd=ke.extend({model:v(),stopReason:me(Oe(["endTurn","stopSequence","maxTokens"]).or(v())),role:Ko,content:Zw}),Gd=ke.extend({model:v(),stopReason:me(Oe(["endTurn","stopSequence","maxTokens","toolUse"]).or(v())),role:Ko,content:ae([Wa,B(Wa)])}),Vw=P({type:j("boolean"),title:v().optional(),description:v().optional(),default:$e().optional()}),Ww=P({type:j("string"),title:v().optional(),description:v().optional(),minLength:oe().optional(),maxLength:oe().optional(),format:Oe(["email","uri","date","date-time"]).optional(),default:v().optional()}),Jw=P({type:Oe(["number","integer"]),title:v().optional(),description:v().optional(),minimum:oe().optional(),maximum:oe().optional(),default:oe().optional()}),Hw=P({type:j("string"),title:v().optional(),description:v().optional(),enum:B(v()),default:v().optional()}),Gw=P({type:j("string"),title:v().optional(),description:v().optional(),oneOf:B(P({const:v(),title:v()})),default:v().optional()}),Kw=P({type:j("string"),title:v().optional(),description:v().optional(),enum:B(v()),enumNames:B(v()).optional(),default:v().optional()}),Bw=ae([Hw,Gw]),Yw=P({type:j("array"),title:v().optional(),description:v().optional(),minItems:oe().optional(),maxItems:oe().optional(),items:P({type:j("string"),enum:B(v())}),default:B(v()).optional()}),Xw=P({type:j("array"),title:v().optional(),description:v().optional(),minItems:oe().optional(),maxItems:oe().optional(),items:P({anyOf:B(P({const:v(),title:v()}))}),default:B(v()).optional()}),Qw=ae([Yw,Xw]),e0=ae([Kw,Bw,Qw]),t0=ae([e0,Vw,Ww,Jw]),r0=Fo.extend({mode:j("form").optional(),message:v(),requestedSchema:P({type:j("object"),properties:fe(v(),t0),required:B(v()).optional()})}),n0=Fo.extend({mode:j("url"),message:v(),elicitationId:v(),url:v().url()}),o0=ae([r0,n0]),i0=Se.extend({method:j("elicitation/create"),params:o0}),a0=at.extend({elicitationId:v()}),s0=st.extend({method:j("notifications/elicitation/complete"),params:a0}),is=ke.extend({action:Oe(["accept","decline","cancel"]),content:Va(e=>e===null?void 0:e,fe(v(),ae([v(),oe(),$e(),B(v())])).optional())}),c0=P({type:j("ref/resource"),uri:v()});var u0=P({type:j("ref/prompt"),name:v()}),l0=rt.extend({ref:ae([u0,c0]),argument:P({name:v(),value:v()}),context:P({arguments:fe(v(),v()).optional()}).optional()}),d0=Se.extend({method:j("completion/complete"),params:l0});var p0=ke.extend({completion:Te({values:B(v()).max(100),total:me(oe().int()),hasMore:me($e())})}),f0=P({uri:v().startsWith("file://"),name:v().optional(),_meta:fe(v(),le()).optional()}),m0=Se.extend({method:j("roots/list"),params:rt.optional()}),Kd=ke.extend({roots:B(f0)}),h0=st.extend({method:j("notifications/roots/list_changed"),params:at.optional()}),QA=ae([Ba,Ad,d0,Jd,bw,_w,rw,ow,sw,dw,fw,Bo,Wd,Xa,es,ts,ns]),eC=ae([Ka,Ya,Cd,h0,Go]),tC=ae([Ga,Hd,Gd,is,Kd,Qa,rs,gn]),rC=ae([Ba,qw,i0,m0,Xa,es,ts,ns]),nC=ae([Ka,Ya,Rw,hw,uw,jw,Iw,Go,s0]),oC=ae([Ga,Kk,p0,Ew,yw,nw,iw,cw,os,Tw,Qa,rs,gn]),J=class e extends Error{constructor(t,r,n){super(`MCP error ${t}: ${r}`),this.code=t,this.data=n,this.name="McpError"}static fromError(t,r,n){if(t===Q.UrlElicitationRequired&&n){let o=n;if(o.elicitations)return new Od(o.elicitations,r)}return new e(t,r,n)}},Od=class extends J{constructor(t,r=`URL elicitation${t.length>1?"s":""} required`){super(Q.UrlElicitationRequired,r,{elicitations:t})}get elicitations(){return this.data?.elicitations??[]}};function fr(e){return e==="completed"||e==="failed"||e==="cancelled"}var CC=new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");function Bd(e){let r=Pa(e)?.method;if(!r)throw new Error("Schema is missing a method literal");let n=hg(r);if(typeof n!="string")throw new Error("Schema method literal must be a string");return n}function Yd(e,t){let r=dr(e,t);if(!r.success)throw r.error;return r.data}var b0=6e4,as=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(Ka,r=>{this._oncancel(r)}),this.setNotificationHandler(Ya,r=>{this._onprogress(r)}),this.setRequestHandler(Ba,r=>({})),this._taskStore=t?.taskStore,this._taskMessageQueue=t?.taskMessageQueue,this._taskStore&&(this.setRequestHandler(Xa,async(r,n)=>{let o=await this._taskStore.getTask(r.params.taskId,n.sessionId);if(!o)throw new J(Q.InvalidParams,"Failed to retrieve task: Task not found");return{...o}}),this.setRequestHandler(es,async(r,n)=>{let o=async()=>{let i=r.params.taskId;if(this._taskMessageQueue){let s;for(;s=await this._taskMessageQueue.dequeue(i,n.sessionId);){if(s.type==="response"||s.type==="error"){let c=s.message,u=c.id,l=this._requestResolvers.get(u);if(l)if(this._requestResolvers.delete(u),s.type==="response")l(c);else{let d=c,p=new J(d.error.code,d.error.message,d.error.data);l(p)}else{let d=s.type==="response"?"Response":"Error";this._onerror(new Error(`${d} handler missing for request ${u}`))}continue}await this._transport?.send(s.message,{relatedRequestId:n.requestId})}}let a=await this._taskStore.getTask(i,n.sessionId);if(!a)throw new J(Q.InvalidParams,`Task not found: ${i}`);if(!fr(a.status))return await this._waitForTaskUpdate(i,n.signal),await o();if(fr(a.status)){let s=await this._taskStore.getTaskResult(i,n.sessionId);return this._clearTaskQueue(i),{...s,_meta:{...s._meta,[pr]:{taskId:i}}}}return await o()};return await o()}),this.setRequestHandler(ts,async(r,n)=>{try{let{tasks:o,nextCursor:i}=await this._taskStore.listTasks(r.params?.cursor,n.sessionId);return{tasks:o,nextCursor:i,_meta:{}}}catch(o){throw new J(Q.InvalidParams,`Failed to list tasks: ${o instanceof Error?o.message:String(o)}`)}}),this.setRequestHandler(ns,async(r,n)=>{try{let o=await this._taskStore.getTask(r.params.taskId,n.sessionId);if(!o)throw new J(Q.InvalidParams,`Task not found: ${r.params.taskId}`);if(fr(o.status))throw new J(Q.InvalidParams,`Cannot cancel task in terminal status: ${o.status}`);await this._taskStore.updateTaskStatus(r.params.taskId,"cancelled","Client cancelled task execution.",n.sessionId),this._clearTaskQueue(r.params.taskId);let i=await this._taskStore.getTask(r.params.taskId,n.sessionId);if(!i)throw new J(Q.InvalidParams,`Task not found after cancellation: ${r.params.taskId}`);return{_meta:{},...i}}catch(o){throw o instanceof J?o:new J(Q.InvalidRequest,`Failed to cancel task: ${o instanceof Error?o.message:String(o)}`)}}))}async _oncancel(t){if(!t.params.requestId)return;this._requestHandlerAbortControllers.get(t.params.requestId)?.abort(t.params.reason)}_setupTimeout(t,r,n,o,i=!1){this._timeoutInfo.set(t,{timeoutId:setTimeout(o,r),startTime:Date.now(),timeout:r,maxTotalTimeout:n,resetTimeoutOnProgress:i,onTimeout:o})}_resetTimeout(t){let r=this._timeoutInfo.get(t);if(!r)return!1;let n=Date.now()-r.startTime;if(r.maxTotalTimeout&&n>=r.maxTotalTimeout)throw this._timeoutInfo.delete(t),J.fromError(Q.RequestTimeout,"Maximum total timeout exceeded",{maxTotalTimeout:r.maxTotalTimeout,totalElapsed:n});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){this._transport=t;let r=this.transport?.onclose;this._transport.onclose=()=>{r?.(),this._onclose()};let n=this.transport?.onerror;this._transport.onerror=i=>{n?.(i),this._onerror(i)};let o=this._transport?.onmessage;this._transport.onmessage=(i,a)=>{o?.(i,a),qo(i)||Sv(i)?this._onresponse(i):Nd(i)?this._onrequest(i,a):xv(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();let r=J.fromError(Q.ConnectionClosed,"Connection closed");this._transport=void 0,this.onclose?.();for(let n of t.values())n(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(n=>this._onerror(new Error(`Uncaught error in notification handler: ${n}`)))}_onrequest(t,r){let n=this._requestHandlers.get(t.method)??this.fallbackRequestHandler,o=this._transport,i=t.params?._meta?.[pr]?.taskId;if(n===void 0){let l={jsonrpc:"2.0",id:t.id,error:{code:Q.MethodNotFound,message:"Method not found"}};i&&this._taskMessageQueue?this._enqueueTaskMessage(i,{type:"error",message:l,timestamp:Date.now()},o?.sessionId).catch(d=>this._onerror(new Error(`Failed to enqueue error response: ${d}`))):o?.send(l).catch(d=>this._onerror(new Error(`Failed to send an error response: ${d}`)));return}let a=new AbortController;this._requestHandlerAbortControllers.set(t.id,a);let s=yv(t.params)?t.params.task:void 0,c=this._taskStore?this.requestTaskStore(t,o?.sessionId):void 0,u={signal:a.signal,sessionId:o?.sessionId,_meta:t.params?._meta,sendNotification:async l=>{let d={relatedRequestId:t.id};i&&(d.relatedTask={taskId:i}),await this.notification(l,d)},sendRequest:async(l,d,p)=>{let f={...p,relatedRequestId:t.id};i&&!f.relatedTask&&(f.relatedTask={taskId:i});let h=f.relatedTask?.taskId??i;return h&&c&&await c.updateTaskStatus(h,"input_required"),await this.request(l,d,f)},authInfo:r?.authInfo,requestId:t.id,requestInfo:r?.requestInfo,taskId:i,taskStore:c,taskRequestedTtl:s?.ttl,closeSSEStream:r?.closeSSEStream,closeStandaloneSSEStream:r?.closeStandaloneSSEStream};Promise.resolve().then(()=>{s&&this.assertTaskHandlerCapability(t.method)}).then(()=>n(t,u)).then(async l=>{if(a.signal.aborted)return;let d={result:l,jsonrpc:"2.0",id:t.id};i&&this._taskMessageQueue?await this._enqueueTaskMessage(i,{type:"response",message:d,timestamp:Date.now()},o?.sessionId):await o?.send(d)},async l=>{if(a.signal.aborted)return;let d={jsonrpc:"2.0",id:t.id,error:{code:Number.isSafeInteger(l.code)?l.code:Q.InternalError,message:l.message??"Internal error",...l.data!==void 0&&{data:l.data}}};i&&this._taskMessageQueue?await this._enqueueTaskMessage(i,{type:"error",message:d,timestamp:Date.now()},o?.sessionId):await o?.send(d)}).catch(l=>this._onerror(new Error(`Failed to send response: ${l}`))).finally(()=>{this._requestHandlerAbortControllers.delete(t.id)})}_onprogress(t){let{progressToken:r,...n}=t.params,o=Number(r),i=this._progressHandlers.get(o);if(!i){this._onerror(new Error(`Received a progress notification for an unknown token: ${JSON.stringify(t)}`));return}let a=this._responseHandlers.get(o),s=this._timeoutInfo.get(o);if(s&&a&&s.resetTimeoutOnProgress)try{this._resetTimeout(o)}catch(c){this._responseHandlers.delete(o),this._progressHandlers.delete(o),this._cleanupTimeout(o),a(c);return}i(n)}_onresponse(t){let r=Number(t.id),n=this._requestResolvers.get(r);if(n){if(this._requestResolvers.delete(r),qo(t))n(t);else{let a=new J(t.error.code,t.error.message,t.error.data);n(a)}return}let o=this._responseHandlers.get(r);if(o===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(qo(t)&&t.result&&typeof t.result=="object"){let a=t.result;if(a.task&&typeof a.task=="object"){let s=a.task;typeof s.taskId=="string"&&(i=!0,this._taskProgressTokens.set(s.taskId,r))}}if(i||this._progressHandlers.delete(r),qo(t))o(t);else{let a=J.fromError(t.error.code,t.error.message,t.error.data);o(a)}}get transport(){return this._transport}async close(){await this._transport?.close()}async*requestStream(t,r,n){let{task:o}=n??{};if(!o){try{yield{type:"result",result:await this.request(t,r,n)}}catch(a){yield{type:"error",error:a instanceof J?a:new J(Q.InternalError,String(a))}}return}let i;try{let a=await this.request(t,gn,n);if(a.task)i=a.task.taskId,yield{type:"taskCreated",task:a.task};else throw new J(Q.InternalError,"Task creation did not return a task");for(;;){let s=await this.getTask({taskId:i},n);if(yield{type:"taskStatus",task:s},fr(s.status)){s.status==="completed"?yield{type:"result",result:await this.getTaskResult({taskId:i},r,n)}:s.status==="failed"?yield{type:"error",error:new J(Q.InternalError,`Task ${i} failed`)}:s.status==="cancelled"&&(yield{type:"error",error:new J(Q.InternalError,`Task ${i} was cancelled`)});return}if(s.status==="input_required"){yield{type:"result",result:await this.getTaskResult({taskId:i},r,n)};return}let c=s.pollInterval??this._options?.defaultTaskPollInterval??1e3;await new Promise(u=>setTimeout(u,c)),n?.signal?.throwIfAborted()}}catch(a){yield{type:"error",error:a instanceof J?a:new J(Q.InternalError,String(a))}}}request(t,r,n){let{relatedRequestId:o,resumptionToken:i,onresumptiontoken:a,task:s,relatedTask:c}=n??{};return new Promise((u,l)=>{let d=x=>{l(x)};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(x){d(x);return}n?.signal?.throwIfAborted();let p=this._requestMessageId++,f={...t,jsonrpc:"2.0",id:p};n?.onprogress&&(this._progressHandlers.set(p,n.onprogress),f.params={...t.params,_meta:{...t.params?._meta||{},progressToken:p}}),s&&(f.params={...f.params,task:s}),c&&(f.params={...f.params,_meta:{...f.params?._meta||{},[pr]:c}});let h=x=>{this._responseHandlers.delete(p),this._progressHandlers.delete(p),this._cleanupTimeout(p),this._transport?.send({jsonrpc:"2.0",method:"notifications/cancelled",params:{requestId:p,reason:String(x)}},{relatedRequestId:o,resumptionToken:i,onresumptiontoken:a}).catch(N=>this._onerror(new Error(`Failed to send cancellation: ${N}`)));let b=x instanceof J?x:new J(Q.RequestTimeout,String(x));l(b)};this._responseHandlers.set(p,x=>{if(!n?.signal?.aborted){if(x instanceof Error)return l(x);try{let b=dr(r,x.result);b.success?u(b.data):l(b.error)}catch(b){l(b)}}}),n?.signal?.addEventListener("abort",()=>{h(n?.signal?.reason)});let g=n?.timeout??b0,y=()=>h(J.fromError(Q.RequestTimeout,"Request timed out",{timeout:g}));this._setupTimeout(p,g,n?.maxTotalTimeout,y,n?.resetTimeoutOnProgress??!1);let S=c?.taskId;if(S){let x=b=>{let N=this._responseHandlers.get(p);N?N(b):this._onerror(new Error(`Response handler missing for side-channeled request ${p}`))};this._requestResolvers.set(p,x),this._enqueueTaskMessage(S,{type:"request",message:f,timestamp:Date.now()}).catch(b=>{this._cleanupTimeout(p),l(b)})}else this._transport.send(f,{relatedRequestId:o,resumptionToken:i,onresumptiontoken:a}).catch(x=>{this._cleanupTimeout(p),l(x)})})}async getTask(t,r){return this.request({method:"tasks/get",params:t},Qa,r)}async getTaskResult(t,r,n){return this.request({method:"tasks/result",params:t},r,n)}async listTasks(t,r){return this.request({method:"tasks/list",params:t},rs,r)}async cancelTask(t,r){return this.request({method:"tasks/cancel",params:t},Ev,r)}async notification(t,r){if(!this._transport)throw new Error("Not connected");this.assertNotificationCapability(t.method);let n=r?.relatedTask?.taskId;if(n){let s={...t,jsonrpc:"2.0",params:{...t.params,_meta:{...t.params?._meta||{},[pr]:r.relatedTask}}};await this._enqueueTaskMessage(n,{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(c=>this._onerror(c))});return}let a={...t,jsonrpc:"2.0"};r?.relatedTask&&(a={...a,params:{...a.params,_meta:{...a.params?._meta||{},[pr]:r.relatedTask}}}),await this._transport.send(a,r)}setRequestHandler(t,r){let n=Bd(t);this.assertRequestHandlerCapability(n),this._requestHandlers.set(n,(o,i)=>{let a=Yd(t,o);return Promise.resolve(r(a,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 n=Bd(t);this._notificationHandlers.set(n,o=>{let i=Yd(t,o);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,n){if(!this._taskStore||!this._taskMessageQueue)throw new Error("Cannot enqueue task message: taskStore and taskMessageQueue are not configured");let o=this._options?.maxTaskQueueSize;await this._taskMessageQueue.enqueue(t,r,n,o)}async _clearTaskQueue(t,r){if(this._taskMessageQueue){let n=await this._taskMessageQueue.dequeueAll(t,r);for(let o of n)if(o.type==="request"&&Nd(o.message)){let i=o.message.id,a=this._requestResolvers.get(i);a?(a(new J(Q.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){let n=this._options?.defaultTaskPollInterval??1e3;try{let o=await this._taskStore?.getTask(t);o?.pollInterval&&(n=o.pollInterval)}catch{}return new Promise((o,i)=>{if(r.aborted){i(new J(Q.InvalidRequest,"Request cancelled"));return}let a=setTimeout(o,n);r.addEventListener("abort",()=>{clearTimeout(a),i(new J(Q.InvalidRequest,"Request cancelled"))},{once:!0})})}requestTaskStore(t,r){let n=this._taskStore;if(!n)throw new Error("No task store configured");return{createTask:async o=>{if(!t)throw new Error("No request provided");return await n.createTask(o,t.id,{method:t.method,params:t.params},r)},getTask:async o=>{let i=await n.getTask(o,r);if(!i)throw new J(Q.InvalidParams,"Failed to retrieve task: Task not found");return i},storeTaskResult:async(o,i,a)=>{await n.storeTaskResult(o,i,a,r);let s=await n.getTask(o,r);if(s){let c=Go.parse({method:"notifications/tasks/status",params:s});await this.notification(c),fr(s.status)&&this._cleanupTaskProgressHandler(o)}},getTaskResult:o=>n.getTaskResult(o,r),updateTaskStatus:async(o,i,a)=>{let s=await n.getTask(o,r);if(!s)throw new J(Q.InvalidParams,`Task "${o}" not found - it may have been cleaned up`);if(fr(s.status))throw new J(Q.InvalidParams,`Cannot update task "${o}" from terminal status "${s.status}" to "${i}". Terminal states (completed, failed, cancelled) cannot transition to other states.`);await n.updateTaskStatus(o,i,a,r);let c=await n.getTask(o,r);if(c){let u=Go.parse({method:"notifications/tasks/status",params:c});await this.notification(u),fr(c.status)&&this._cleanupTaskProgressHandler(o)}},listTasks:o=>n.listTasks(o,r)}}};function jv(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function Dv(e,t){let r={...e};for(let n in t){let o=n,i=t[o];if(i===void 0)continue;let a=r[o];jv(a)&&jv(i)?r[o]={...a,...i}:r[o]=i}return r}var y$=kt(Af(),1),$$=kt(_$(),1);function dO(){let e=new y$.default({strict:!1,validateFormats:!0,validateSchema:!1,allErrors:!0});return(0,$$.default)(e),e}var qs=class{constructor(t){this._ajv=t??dO()}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 n=>r(n)?{valid:!0,data:n,errorMessage:void 0}:{valid:!1,data:void 0,errorMessage:this._ajv.errorsText(r.errors)}}};var Vs=class{constructor(t){this._server=t}requestStream(t,r,n){return this._server.requestStream(t,r,n)}async getTask(t,r){return this._server.getTask({taskId:t},r)}async getTaskResult(t,r,n){return this._server.getTaskResult({taskId:t},r,n)}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 b$(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 x$(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 Ws=class extends as{constructor(t,r){super(r),this._serverInfo=t,this._loggingLevels=new Map,this.LOG_LEVEL_SEVERITY=new Map(Yo.options.map((n,o)=>[n,o])),this.isMessageIgnored=(n,o)=>{let i=this._loggingLevels.get(o);return i?this.LOG_LEVEL_SEVERITY.get(n)<this.LOG_LEVEL_SEVERITY.get(i):!1},this._capabilities=r?.capabilities??{},this._instructions=r?.instructions,this._jsonSchemaValidator=r?.jsonSchemaValidator??new qs,this.setRequestHandler(Ad,n=>this._oninitialize(n)),this.setNotificationHandler(Cd,()=>this.oninitialized?.()),this._capabilities.logging&&this.setRequestHandler(Jd,async(n,o)=>{let i=o.sessionId||o.requestInfo?.headers["mcp-session-id"]||void 0,{level:a}=n.params,s=Yo.safeParse(a);return s.success&&this._loggingLevels.set(i,s.data),{}})}get experimental(){return this._experimental||(this._experimental={tasks:new Vs(this)}),this._experimental}registerCapabilities(t){if(this.transport)throw new Error("Cannot register capabilities after connecting to transport");this._capabilities=Dv(this._capabilities,t)}setRequestHandler(t,r){let o=Pa(t)?.method;if(!o)throw new Error("Schema is missing a method literal");let i;if(fn(o)){let s=o;i=s._zod?.def?.value??s.value}else{let s=o;i=s._def?.value??s.value}if(typeof i!="string")throw new Error("Schema method literal must be a string");if(i==="tools/call"){let s=async(c,u)=>{let l=dr(Bo,c);if(!l.success){let h=l.error instanceof Error?l.error.message:String(l.error);throw new J(Q.InvalidParams,`Invalid tools/call request: ${h}`)}let{params:d}=l.data,p=await Promise.resolve(r(c,u));if(d.task){let h=dr(gn,p);if(!h.success){let g=h.error instanceof Error?h.error.message:String(h.error);throw new J(Q.InvalidParams,`Invalid task creation result: ${g}`)}return h.data}let f=dr(os,p);if(!f.success){let h=f.error instanceof Error?f.error.message:String(f.error);throw new J(Q.InvalidParams,`Invalid tools/call result: ${h}`)}return f.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){x$(this._clientCapabilities?.tasks?.requests,t,"Client")}assertTaskHandlerCapability(t){this._capabilities&&b$(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:gv.includes(r)?r:jd,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"},Ga)}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 n=t.messages[t.messages.length-1],o=Array.isArray(n.content)?n.content:[n.content],i=o.some(u=>u.type==="tool_result"),a=t.messages.length>1?t.messages[t.messages.length-2]:void 0,s=a?Array.isArray(a.content)?a.content:[a.content]:[],c=s.some(u=>u.type==="tool_use");if(i){if(o.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(s.filter(d=>d.type==="tool_use").map(d=>d.id)),l=new Set(o.filter(d=>d.type==="tool_result").map(d=>d.toolUseId));if(u.size!==l.size||![...u].every(d=>l.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},Gd,r):this.request({method:"sampling/createMessage",params:t},Hd,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 o=t;return this.request({method:"elicitation/create",params:o},is,r)}case"form":{if(!this._clientCapabilities?.elicitation?.form)throw new Error("Client does not support form elicitation.");let o=t.mode==="form"?t:{...t,mode:"form"},i=await this.request({method:"elicitation/create",params:o},is,r);if(i.action==="accept"&&i.content&&o.requestedSchema)try{let s=this._jsonSchemaValidator.getValidator(o.requestedSchema)(i.content);if(!s.valid)throw new J(Q.InvalidParams,`Elicitation response content does not match requested schema: ${s.errorMessage}`)}catch(a){throw a instanceof J?a:new J(Q.InternalError,`Error validating elicitation response: ${a instanceof Error?a.message:String(a)}`)}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},Kd,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 Wf=kt(require("node:process"),1);var Js=class{append(t){this._buffer=this._buffer?Buffer.concat([this._buffer,t]):t}readMessage(){if(!this._buffer)return null;let t=this._buffer.indexOf(`
|
|
`);if(t===-1)return null;let r=this._buffer.toString("utf8",0,t).replace(/\r$/,"");return this._buffer=this._buffer.subarray(t+1),pO(r)}clear(){this._buffer=void 0}};function pO(e){return kv.parse(JSON.parse(e))}function S$(e){return JSON.stringify(e)+`
|
|
`}var Hs=class{constructor(t=Wf.default.stdin,r=Wf.default.stdout){this._stdin=t,this._stdout=r,this._readBuffer=new Js,this._started=!1,this._ondata=n=>{this._readBuffer.append(n),this.processReadBuffer()},this._onerror=n=>{this.onerror?.(n)}}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 n=S$(t);this._stdout.write(n)?r():this._stdout.once("drain",r)})}};var Kf=kt(require("path"),1);var pt={DEFAULT:3e5,HEALTH_CHECK:3e3,POST_SPAWN_WAIT:15e3,READINESS_WAIT:3e4,PORT_IN_USE_WAIT:3e3,WORKER_STARTUP_WAIT:1e3,PRE_RESTART_SETTLE_DELAY:2e3,POWERSHELL_COMMAND:1e4,WINDOWS_MULTIPLIER:1.5};function k$(e){return process.platform==="win32"?Math.round(e*pt.WINDOWS_MULTIPLIER):e}var Nt=require("fs"),zi=require("path"),Jf=require("os"),Yt=class{static DEFAULTS={CLAUDE_MEM_MODEL:"claude-sonnet-4-6",CLAUDE_MEM_CONTEXT_OBSERVATIONS:"50",CLAUDE_MEM_WORKER_PORT:"37777",CLAUDE_MEM_WORKER_HOST:"127.0.0.1",CLAUDE_MEM_SKIP_TOOLS:"ListMcpResourcesTool,SlashCommand,Skill,TodoWrite,AskUserQuestion",CLAUDE_MEM_PROVIDER:"claude",CLAUDE_MEM_CLAUDE_AUTH_METHOD:"cli",CLAUDE_MEM_GEMINI_API_KEY:"",CLAUDE_MEM_GEMINI_MODEL:"gemini-2.5-flash-lite",CLAUDE_MEM_GEMINI_RATE_LIMITING_ENABLED:"true",CLAUDE_MEM_GEMINI_MAX_CONTEXT_MESSAGES:"20",CLAUDE_MEM_GEMINI_MAX_TOKENS:"100000",CLAUDE_MEM_OPENROUTER_API_KEY:"",CLAUDE_MEM_OPENROUTER_MODEL:"xiaomi/mimo-v2-flash:free",CLAUDE_MEM_OPENROUTER_SITE_URL:"",CLAUDE_MEM_OPENROUTER_APP_NAME:"claude-mem",CLAUDE_MEM_OPENROUTER_MAX_CONTEXT_MESSAGES:"20",CLAUDE_MEM_OPENROUTER_MAX_TOKENS:"100000",CLAUDE_MEM_DATA_DIR:(0,zi.join)((0,Jf.homedir)(),".claude-mem"),CLAUDE_MEM_LOG_LEVEL:"INFO",CLAUDE_MEM_PYTHON_VERSION:"3.13",CLAUDE_CODE_PATH:"",CLAUDE_MEM_MODE:"code",CLAUDE_MEM_CONTEXT_SHOW_READ_TOKENS:"false",CLAUDE_MEM_CONTEXT_SHOW_WORK_TOKENS:"false",CLAUDE_MEM_CONTEXT_SHOW_SAVINGS_AMOUNT:"false",CLAUDE_MEM_CONTEXT_SHOW_SAVINGS_PERCENT:"true",CLAUDE_MEM_CONTEXT_FULL_COUNT:"0",CLAUDE_MEM_CONTEXT_FULL_FIELD:"narrative",CLAUDE_MEM_CONTEXT_SESSION_COUNT:"10",CLAUDE_MEM_CONTEXT_SHOW_LAST_SUMMARY:"true",CLAUDE_MEM_CONTEXT_SHOW_LAST_MESSAGE:"false",CLAUDE_MEM_CONTEXT_SHOW_TERMINAL_OUTPUT:"true",CLAUDE_MEM_FOLDER_CLAUDEMD_ENABLED:"false",CLAUDE_MEM_FOLDER_USE_LOCAL_MD:"false",CLAUDE_MEM_TRANSCRIPTS_ENABLED:"true",CLAUDE_MEM_TRANSCRIPTS_CONFIG_PATH:(0,zi.join)((0,Jf.homedir)(),".claude-mem","transcript-watch.json"),CLAUDE_MEM_MAX_CONCURRENT_AGENTS:"2",CLAUDE_MEM_EXCLUDED_PROJECTS:"",CLAUDE_MEM_FOLDER_MD_EXCLUDE:"[]",CLAUDE_MEM_SEMANTIC_INJECT:"false",CLAUDE_MEM_SEMANTIC_INJECT_LIMIT:"5",CLAUDE_MEM_TIER_ROUTING_ENABLED:"true",CLAUDE_MEM_TIER_SIMPLE_MODEL:"haiku",CLAUDE_MEM_TIER_SUMMARY_MODEL:"",CLAUDE_MEM_CHROMA_ENABLED:"true",CLAUDE_MEM_CHROMA_MODE:"local",CLAUDE_MEM_CHROMA_HOST:"127.0.0.1",CLAUDE_MEM_CHROMA_PORT:"8000",CLAUDE_MEM_CHROMA_SSL:"false",CLAUDE_MEM_CHROMA_API_KEY:"",CLAUDE_MEM_CHROMA_TENANT:"default_tenant",CLAUDE_MEM_CHROMA_DATABASE:"default_database"};static getAllDefaults(){return{...this.DEFAULTS}}static get(t){return process.env[t]??this.DEFAULTS[t]}static getInt(t){let r=this.get(t);return parseInt(r,10)}static getBool(t){let r=this.get(t);return r==="true"||r===!0}static applyEnvOverrides(t){let r={...t};for(let n of Object.keys(this.DEFAULTS))process.env[n]!==void 0&&(r[n]=process.env[n]);return r}static loadFromFile(t){try{if(!(0,Nt.existsSync)(t)){let a=this.getAllDefaults();try{let s=(0,zi.dirname)(t);(0,Nt.existsSync)(s)||(0,Nt.mkdirSync)(s,{recursive:!0}),(0,Nt.writeFileSync)(t,JSON.stringify(a,null,2),"utf-8"),console.log("[SETTINGS] Created settings file with defaults:",t)}catch(s){console.warn("[SETTINGS] Failed to create settings file, using in-memory defaults:",t,s)}return this.applyEnvOverrides(a)}let r=(0,Nt.readFileSync)(t,"utf-8"),n=JSON.parse(r),o=n;if(n.env&&typeof n.env=="object"){o=n.env;try{(0,Nt.writeFileSync)(t,JSON.stringify(o,null,2),"utf-8"),console.log("[SETTINGS] Migrated settings file from nested to flat schema:",t)}catch(a){console.warn("[SETTINGS] Failed to auto-migrate settings file:",t,a)}}let i={...this.DEFAULTS};for(let a of Object.keys(this.DEFAULTS))o[a]!==void 0&&(i[a]=o[a]);return this.applyEnvOverrides(i)}catch(r){return console.warn("[SETTINGS] Failed to load settings, using defaults:",t,r),this.applyEnvOverrides(this.getAllDefaults())}}};var _e=require("path"),Hf=require("os"),Gf=require("fs");var w$=require("url");var gO={};function fO(){return typeof __dirname<"u"?__dirname:(0,_e.dirname)((0,w$.fileURLToPath)(gO.url))}var _L=fO();function mO(){if(process.env.CLAUDE_MEM_DATA_DIR)return process.env.CLAUDE_MEM_DATA_DIR;let e=(0,_e.join)((0,Hf.homedir)(),".claude-mem"),t=(0,_e.join)(e,"settings.json");try{if((0,Gf.existsSync)(t)){let{readFileSync:r}=require("fs"),n=JSON.parse(r(t,"utf-8")),o=n.env??n;if(o.CLAUDE_MEM_DATA_DIR)return o.CLAUDE_MEM_DATA_DIR}}catch{}return e}var Xt=mO(),Gs=process.env.CLAUDE_CONFIG_DIR||(0,_e.join)((0,Hf.homedir)(),".claude"),E$=(0,_e.join)(Gs,"plugins","marketplaces","thedotmack"),yL=(0,_e.join)(Xt,"archives"),$L=(0,_e.join)(Xt,"logs"),bL=(0,_e.join)(Xt,"trash"),xL=(0,_e.join)(Xt,"backups"),SL=(0,_e.join)(Xt,"modes"),kL=(0,_e.join)(Xt,"settings.json"),wL=(0,_e.join)(Xt,"claude-mem.db"),EL=(0,_e.join)(Xt,"vector-db"),hO=(0,_e.join)(Xt,"observer-sessions"),IL=(0,_e.basename)(hO),zL=(0,_e.join)(Gs,"settings.json"),PL=(0,_e.join)(Gs,"commands"),TL=(0,_e.join)(Gs,"CLAUDE.md");var vO=(()=>{let e=process.env.CLAUDE_MEM_HEALTH_TIMEOUT_MS;if(e){let t=parseInt(e,10);if(Number.isFinite(t)&&t>=500&&t<=3e5)return t;w.warn("SYSTEM","Invalid CLAUDE_MEM_HEALTH_TIMEOUT_MS, using default",{value:e,min:500,max:3e5})}return k$(pt.HEALTH_CHECK)})();function _O(e,t={},r){return new Promise((n,o)=>{let i=setTimeout(()=>o(new Error(`Request timed out after ${r}ms`)),r);fetch(e,t).then(a=>{clearTimeout(i),n(a)},a=>{clearTimeout(i),o(a)})})}var Ks=null,Bs=null;function Bf(){if(Ks!==null)return Ks;let e=Kf.default.join(Yt.get("CLAUDE_MEM_DATA_DIR"),"settings.json"),t=Yt.loadFromFile(e);return Ks=parseInt(t.CLAUDE_MEM_WORKER_PORT,10),Ks}function yO(){if(Bs!==null)return Bs;let e=Kf.default.join(Yt.get("CLAUDE_MEM_DATA_DIR"),"settings.json");return Bs=Yt.loadFromFile(e).CLAUDE_MEM_WORKER_HOST,Bs}function $O(e){return`http://${yO()}:${Bf()}${e}`}function Ys(e,t={}){let r=t.method??"GET",n=t.timeoutMs??vO,o=$O(e),i={method:r};return t.headers&&(i.headers=t.headers),t.body&&(i.body=t.body),n>0?_O(o,i,n):fetch(o,i)}var am=kt(require("path"),1),ft=require("fs");var er=kt(require("path"),1),om=require("os"),qe=require("fs"),tr=require("child_process"),F$=require("util");var bO=["CLAUDECODE_","CLAUDE_CODE_"],xO=new Set(["CLAUDECODE","CLAUDE_CODE_SESSION","CLAUDE_CODE_ENTRYPOINT","MCP_SESSION_ID"]),SO=new Set(["CLAUDE_CODE_OAUTH_TOKEN","CLAUDE_CODE_GIT_BASH_PATH"]);function I$(e=process.env){let t={};for(let[r,n]of Object.entries(e))if(n!==void 0){if(SO.has(r)){t[r]=n;continue}xO.has(r)||bO.some(o=>r.startsWith(o))||(t[r]=n)}return t}var Lr=require("fs"),U$=require("os"),tm=kt(require("path"),1);var Qt=require("fs"),z$=require("os"),Pi=kt(require("path"),1);var kO=5e3,wO=1e3,EO=Pi.default.join((0,z$.homedir)(),".claude-mem"),IO=Pi.default.join(EO,"supervisor.json");function St(e){if(!Number.isInteger(e)||e<0||e===0)return!1;try{return process.kill(e,0),!0}catch(t){return t.code==="EPERM"}}var Xf=class{registryPath;entries=new Map;runtimeProcesses=new Map;initialized=!1;constructor(t=IO){this.registryPath=t}initialize(){if(this.initialized)return;if(this.initialized=!0,(0,Qt.mkdirSync)(Pi.default.dirname(this.registryPath),{recursive:!0}),!(0,Qt.existsSync)(this.registryPath)){this.persist();return}try{let n=JSON.parse((0,Qt.readFileSync)(this.registryPath,"utf-8")).processes??{};for(let[o,i]of Object.entries(n))this.entries.set(o,i)}catch(r){w.warn("SYSTEM","Failed to parse supervisor registry, rebuilding",{path:this.registryPath},r),this.entries.clear()}let t=this.pruneDeadEntries();t>0&&w.info("SYSTEM","Removed dead processes from supervisor registry",{removed:t}),this.persist()}register(t,r,n){this.initialize(),this.entries.set(t,r),n&&this.runtimeProcesses.set(t,n),this.persist()}unregister(t){this.initialize(),this.entries.delete(t),this.runtimeProcesses.delete(t),this.persist()}clear(){this.entries.clear(),this.runtimeProcesses.clear(),this.persist()}getAll(){return this.initialize(),Array.from(this.entries.entries()).map(([t,r])=>({id:t,...r})).sort((t,r)=>{let n=Date.parse(t.startedAt),o=Date.parse(r.startedAt);return(Number.isNaN(n)?0:n)-(Number.isNaN(o)?0:o)})}getBySession(t){let r=String(t);return this.getAll().filter(n=>n.sessionId!==void 0&&String(n.sessionId)===r)}getRuntimeProcess(t){return this.runtimeProcesses.get(t)}getByPid(t){return this.getAll().filter(r=>r.pid===t)}pruneDeadEntries(){this.initialize();let t=0;for(let[r,n]of this.entries)St(n.pid)||(this.entries.delete(r),this.runtimeProcesses.delete(r),t+=1);return t>0&&this.persist(),t}async reapSession(t){this.initialize();let r=this.getBySession(t);if(r.length===0)return 0;let n=typeof t=="number"?t:Number(t)||void 0;w.info("SYSTEM",`Reaping ${r.length} process(es) for session ${t}`,{sessionId:n,pids:r.map(s=>s.pid)});let o=r.filter(s=>St(s.pid));for(let s of o)try{process.kill(s.pid,"SIGTERM")}catch(c){c.code!=="ESRCH"&&w.debug("SYSTEM",`Failed to SIGTERM session process PID ${s.pid}`,{pid:s.pid},c)}let i=Date.now()+kO;for(;Date.now()<i&&o.filter(c=>St(c.pid)).length!==0;)await new Promise(c=>setTimeout(c,100));let a=o.filter(s=>St(s.pid));for(let s of a){w.warn("SYSTEM",`Session process PID ${s.pid} did not exit after SIGTERM, sending SIGKILL`,{pid:s.pid,sessionId:n});try{process.kill(s.pid,"SIGKILL")}catch(c){c.code!=="ESRCH"&&w.debug("SYSTEM",`Failed to SIGKILL session process PID ${s.pid}`,{pid:s.pid},c)}}if(a.length>0){let s=Date.now()+wO;for(;Date.now()<s&&a.filter(u=>St(u.pid)).length!==0;)await new Promise(u=>setTimeout(u,100))}for(let s of r)this.entries.delete(s.id),this.runtimeProcesses.delete(s.id);return this.persist(),w.info("SYSTEM",`Reaped ${r.length} process(es) for session ${t}`,{sessionId:n,reaped:r.length}),r.length}persist(){let t={processes:Object.fromEntries(this.entries.entries())};(0,Qt.mkdirSync)(Pi.default.dirname(this.registryPath),{recursive:!0}),(0,Qt.writeFileSync)(this.registryPath,JSON.stringify(t,null,2))}},Yf=null;function Xs(){return Yf||(Yf=new Xf),Yf}var O$=require("child_process"),j$=require("fs"),D$=require("os"),Qf=kt(require("path"),1),N$=require("util");var zO=(0,N$.promisify)(O$.execFile),PO=Qf.default.join((0,D$.homedir)(),".claude-mem"),TO=Qf.default.join(PO,"worker.pid");async function R$(e){let t=e.currentPid??process.pid,r=e.pidFilePath??TO,n=e.registry.getAll(),o=[...n].filter(a=>a.pid!==t).sort((a,s)=>Date.parse(s.startedAt)-Date.parse(a.startedAt));for(let a of o){if(!St(a.pid)){e.registry.unregister(a.id);continue}try{await T$(a.pid,"SIGTERM")}catch(s){w.debug("SYSTEM","Failed to send SIGTERM to child process",{pid:a.pid,type:a.type},s)}}await P$(o,5e3);let i=o.filter(a=>St(a.pid));for(let a of i)try{await T$(a.pid,"SIGKILL")}catch(s){w.debug("SYSTEM","Failed to force kill child process",{pid:a.pid,type:a.type},s)}await P$(i,1e3);for(let a of o)e.registry.unregister(a.id);for(let a of n.filter(s=>s.pid===t))e.registry.unregister(a.id);try{(0,j$.rmSync)(r,{force:!0})}catch(a){w.debug("SYSTEM","Failed to remove PID file during shutdown",{pidFilePath:r},a)}e.registry.pruneDeadEntries()}async function P$(e,t){let r=Date.now()+t;for(;Date.now()<r;){if(e.filter(o=>St(o.pid)).length===0)return;await new Promise(o=>setTimeout(o,100))}}async function T$(e,t){if(t==="SIGTERM"){try{process.kill(e,t)}catch(r){if(r.code==="ESRCH")return;throw r}return}if(process.platform==="win32"){let r=await OO();if(r){await new Promise((o,i)=>{r(e,t,a=>{if(!a){o();return}if(a.code==="ESRCH"){o();return}i(a)})});return}let n=["/PID",String(e),"/T"];t==="SIGKILL"&&n.push("/F"),await zO("taskkill",n,{timeout:pt.POWERSHELL_COMMAND,windowsHide:!0});return}try{process.kill(e,t)}catch(r){if(r.code==="ESRCH")return;throw r}}async function OO(){let e="tree-kill";try{let t=await import(e);return t.default??t}catch{return null}}var M$=3e4,Nn=null;function jO(){let t=Xs().pruneDeadEntries();t>0&&w.info("SYSTEM",`Health check: pruned ${t} dead process(es) from registry`)}function A$(){Nn===null&&(Nn=setInterval(jO,M$),Nn.unref(),w.debug("SYSTEM","Health checker started",{intervalMs:M$}))}function C$(){Nn!==null&&(clearInterval(Nn),Nn=null,w.debug("SYSTEM","Health checker stopped"))}var DO=tm.default.join((0,U$.homedir)(),".claude-mem"),NO=tm.default.join(DO,"worker.pid"),em=class{registry;started=!1;stopPromise=null;signalHandlersRegistered=!1;shutdownInitiated=!1;shutdownHandler=null;constructor(t){this.registry=t}async start(){if(this.started)return;if(this.registry.initialize(),rm({logAlive:!1})==="alive")throw new Error("Worker already running");this.started=!0,A$()}configureSignalHandlers(t){if(this.shutdownHandler=t,this.signalHandlersRegistered)return;this.signalHandlersRegistered=!0;let r=async n=>{if(this.shutdownInitiated){w.warn("SYSTEM",`Received ${n} but shutdown already in progress`);return}this.shutdownInitiated=!0,w.info("SYSTEM",`Received ${n}, shutting down...`);try{this.shutdownHandler?await this.shutdownHandler():await this.stop()}catch(o){w.error("SYSTEM","Error during shutdown",{},o);try{await this.stop()}catch(i){w.debug("SYSTEM","Supervisor shutdown fallback failed",{},i)}}process.exit(0)};process.on("SIGTERM",()=>{r("SIGTERM")}),process.on("SIGINT",()=>{r("SIGINT")}),process.platform!=="win32"&&(process.argv.includes("--daemon")?process.on("SIGHUP",()=>{w.debug("SYSTEM","Ignoring SIGHUP in daemon mode")}):process.on("SIGHUP",()=>{r("SIGHUP")}))}async stop(){if(this.stopPromise){await this.stopPromise;return}C$(),this.stopPromise=R$({registry:this.registry,currentPid:process.pid}).finally(()=>{this.started=!1,this.stopPromise=null}),await this.stopPromise}assertCanSpawn(t){if(this.stopPromise!==null)throw new Error(`Supervisor is shutting down, refusing to spawn ${t}`)}registerProcess(t,r,n){this.registry.register(t,r,n)}unregisterProcess(t){this.registry.unregister(t)}getRegistry(){return this.registry}},RO=new em(Xs());function Z$(){return RO}function rm(e={}){let t=e.pidFilePath??NO;if(!(0,Lr.existsSync)(t))return"missing";let r=null;try{r=JSON.parse((0,Lr.readFileSync)(t,"utf-8"))}catch(n){return w.warn("SYSTEM","Failed to parse worker PID file, removing it",{path:t},n),(0,Lr.rmSync)(t,{force:!0}),"invalid"}return St(r.pid)?((e.logAlive??!0)&&w.info("SYSTEM","Worker already running (PID alive)",{existingPid:r.pid,existingPort:r.port,startedAt:r.startedAt}),"alive"):(w.info("SYSTEM","Removing stale PID file (worker process is dead)",{pid:r.pid,port:r.port,startedAt:r.startedAt}),(0,Lr.rmSync)(t,{force:!0}),"stale")}var r6=(0,F$.promisify)(tr.exec),MO=er.default.join((0,om.homedir)(),".claude-mem"),Ti=er.default.join(MO,"worker.pid");function L$(e){return e?/(^|[\\/])bun(\.exe)?$/i.test(e.trim()):!1}function AO(e,t){let r=t==="win32"?`where ${e}`:`which ${e}`;try{return(0,tr.execSync)(r,{stdio:["ignore","pipe","ignore"],encoding:"utf-8",windowsHide:!0}).split(/\r?\n/).map(i=>i.trim()).find(i=>i.length>0)||null}catch{return null}}var nm;function CO(e={}){let t=Object.keys(e).length===0;if(t&&nm!==void 0)return nm;let r=UO(e);return t&&r!==null&&(nm=r),r}function UO(e){let t=e.platform??process.platform,r=e.execPath??process.execPath;if(L$(r))return r;let n=e.env??process.env,o=e.homeDirectory??(0,om.homedir)(),i=e.pathExists??qe.existsSync,a=e.lookupInPath??AO,s=t==="win32"?[n.BUN,n.BUN_PATH,er.default.join(o,".bun","bin","bun.exe"),er.default.join(o,".bun","bin","bun"),n.USERPROFILE?er.default.join(n.USERPROFILE,".bun","bin","bun.exe"):void 0,n.LOCALAPPDATA?er.default.join(n.LOCALAPPDATA,"bun","bun.exe"):void 0,n.LOCALAPPDATA?er.default.join(n.LOCALAPPDATA,"bun","bin","bun.exe"):void 0]:[n.BUN,n.BUN_PATH,er.default.join(o,".bun","bin","bun"),"/usr/local/bin/bun","/opt/homebrew/bin/bun","/home/linuxbrew/.linuxbrew/bin/bun","/usr/bin/bun","/snap/bin/bun"];for(let c of s){let u=c?.trim();if(u&&(L$(u)&&i(u)||u.toLowerCase()==="bun"))return u}return a("bun",t)}function q$(){if((0,qe.existsSync)(Ti))try{(0,qe.unlinkSync)(Ti)}catch(e){w.warn("SYSTEM","Failed to remove PID file",{path:Ti},e)}}function Rn(e){return process.platform==="win32"?Math.round(e*2):e}function V$(e,t,r={}){let n=process.platform==="win32";Z$().assertCanSpawn("worker daemon");let o=I$({...process.env,CLAUDE_MEM_WORKER_PORT:String(t),...r}),i=CO();if(!i){w.error("SYSTEM","Bun runtime not found \u2014 install from https://bun.sh and ensure it is on PATH or set BUN env var. The worker daemon requires Bun because it uses bun:sqlite.");return}if(n){let c=`Start-Process -FilePath '${i.replace(/'/g,"''")}' -ArgumentList @('${e.replace(/'/g,"''")}','--daemon') -WindowStyle Hidden`,u=Buffer.from(c,"utf16le").toString("base64");try{return(0,tr.execSync)(`powershell -NoProfile -EncodedCommand ${u}`,{stdio:"ignore",windowsHide:!0,env:o}),0}catch(l){w.error("SYSTEM","Failed to spawn worker daemon on Windows",{runtimePath:i},l);return}}let a="/usr/bin/setsid";if((0,qe.existsSync)(a)){let c=(0,tr.spawn)(a,[i,e,"--daemon"],{detached:!0,stdio:"ignore",env:o});return c.pid===void 0?void 0:(c.unref(),c.pid)}let s=(0,tr.spawn)(i,[e,"--daemon"],{detached:!0,stdio:"ignore",env:o});if(s.pid!==void 0)return s.unref(),s.pid}function W$(){try{if(!(0,qe.existsSync)(Ti))return;let e=new Date;(0,qe.utimesSync)(Ti,e,e)}catch{}}function J$(){return rm({logAlive:!1})}var H$=kt(require("net"),1);async function ZO(e,t,r="GET"){let n=await fetch(`http://127.0.0.1:${e}${t}`,{method:r}),o="";try{o=await n.text()}catch{}return{ok:n.ok,statusCode:n.status,body:o}}async function G$(e){if(process.platform==="win32")try{return(await fetch(`http://127.0.0.1:${e}/api/health`)).ok}catch{return!1}return new Promise(t=>{let r=H$.default.createServer();r.once("error",n=>{n.code==="EADDRINUSE"?t(!0):t(!1)}),r.once("listening",()=>{r.close(()=>t(!1))}),r.listen(e,"127.0.0.1")})}async function K$(e,t,r,n){let o=Date.now();for(;Date.now()-o<r;){try{if((await ZO(e,t)).ok)return!0}catch(i){w.debug("SYSTEM",n,{},i)}await new Promise(i=>setTimeout(i,500))}return!1}function Oi(e,t=3e4){return K$(e,"/api/health",t,"Service not ready yet, will retry")}function im(e,t=3e4){return K$(e,"/api/readiness",t,"Worker not ready yet, will retry")}var LO=120*1e3;function sm(){return am.default.join(Yt.get("CLAUDE_MEM_DATA_DIR"),".worker-start-attempted")}function FO(){if(process.platform!=="win32")return!1;let e=sm();if(!(0,ft.existsSync)(e))return!1;try{let t=(0,ft.statSync)(e).mtimeMs;return Date.now()-t<LO}catch{return!1}}function qO(){if(process.platform==="win32")try{let e=sm();(0,ft.mkdirSync)(am.default.dirname(e),{recursive:!0}),(0,ft.writeFileSync)(e,"","utf-8")}catch{}}function Qs(){if(process.platform==="win32")try{let e=sm();(0,ft.existsSync)(e)&&(0,ft.unlinkSync)(e)}catch{}}async function B$(e,t){return t?(0,ft.existsSync)(t)?J$()==="alive"?(w.info("SYSTEM","Worker PID file points to a live process, skipping duplicate spawn"),await Oi(e,Rn(pt.PORT_IN_USE_WAIT))?(Qs(),w.info("SYSTEM","Worker became healthy while waiting on live PID"),!0):(w.warn("SYSTEM","Live PID detected but worker did not become healthy before timeout"),!1)):await Oi(e,1e3)?(Qs(),await im(e,Rn(pt.READINESS_WAIT))||w.warn("SYSTEM","Worker is alive but readiness timed out \u2014 proceeding anyway"),w.info("SYSTEM","Worker already running and healthy"),!0):await G$(e)?(w.info("SYSTEM","Port in use, waiting for worker to become healthy"),await Oi(e,Rn(pt.PORT_IN_USE_WAIT))?(Qs(),w.info("SYSTEM","Worker is now healthy"),!0):(w.error("SYSTEM","Port in use but worker not responding to health checks"),!1)):FO()?(w.warn("SYSTEM","Worker unavailable on Windows \u2014 skipping spawn (recent attempt failed within cooldown)"),!1):(w.info("SYSTEM","Starting worker daemon",{workerScriptPath:t}),qO(),V$(t,e)===void 0?(w.error("SYSTEM","Failed to spawn worker daemon"),!1):await Oi(e,Rn(pt.POST_SPAWN_WAIT))?(await im(e,Rn(pt.READINESS_WAIT))||w.warn("SYSTEM","Worker is alive but readiness timed out \u2014 proceeding anyway"),Qs(),W$(),w.info("SYSTEM","Worker started successfully"),!0):(q$(),w.error("SYSTEM","Worker failed to start (health check timeout)"),!1)):(w.error("SYSTEM","ensureWorkerStarted: worker script not found at expected path \u2014 likely a partial install or build artifact missing",{workerScriptPath:t}),!1):(w.error("SYSTEM","ensureWorkerStarted called with empty workerScriptPath \u2014 caller bug"),!1)}var Cn=require("node:fs/promises"),Ri=require("node:path");var Q$=require("node:child_process"),Re=require("node:fs"),ze=require("node:path"),fm=require("node:os"),lm=require("node:module"),nj={},dm=typeof __filename<"u"?(0,lm.createRequire)(__filename):(0,lm.createRequire)(nj.url),pm={".js":"javascript",".mjs":"javascript",".cjs":"javascript",".jsx":"tsx",".ts":"typescript",".tsx":"tsx",".py":"python",".pyw":"python",".go":"go",".rs":"rust",".rb":"ruby",".java":"java",".c":"c",".h":"c",".cpp":"cpp",".cc":"cpp",".cxx":"cpp",".hpp":"cpp",".hh":"cpp",".kt":"kotlin",".kts":"kotlin",".swift":"swift",".php":"php",".ex":"elixir",".exs":"elixir",".lua":"lua",".scala":"scala",".sc":"scala",".sh":"bash",".bash":"bash",".zsh":"bash",".hs":"haskell",".zig":"zig",".css":"css",".scss":"scss",".toml":"toml",".yml":"yaml",".yaml":"yaml",".sql":"sql",".md":"markdown",".mdx":"markdown"};function eb(e,t){let r=e.slice(e.lastIndexOf("."));return pm[r]?pm[r]:t.extensionToLanguage[r]?t.extensionToLanguage[r]:"unknown"}function tb(e,t){return t.languageToQueryKey[e]?t.languageToQueryKey[e]:JO(e)}var ji=new Map,Mn={grammars:{},extensionToLanguage:{},languageToQueryKey:{}};function Ni(e){if(ji.has(e))return ji.get(e);let t=(0,ze.join)(e,".claude-mem.json"),r;try{let i=(0,Re.readFileSync)(t,"utf-8");r=JSON.parse(i)}catch{return ji.set(e,Mn),Mn}let n=r.grammars;if(!n||typeof n!="object"||Array.isArray(n))return ji.set(e,Mn),Mn;let o={grammars:{},extensionToLanguage:{},languageToQueryKey:{}};for(let[i,a]of Object.entries(n)){if(rb[i]||!a||typeof a!="object"||Array.isArray(a))continue;let s=a,c=s.package,u=s.extensions,l=s.query;if(!(typeof c!="string"||!Array.isArray(u))&&u.every(d=>typeof d=="string")){o.grammars[i]={package:c,extensions:u,query:typeof l=="string"?l:void 0};for(let d of u)pm[d]||(o.extensionToLanguage[d]=i);if(typeof l=="string"){let d=(0,ze.join)(e,l);try{let p=(0,Re.readFileSync)(d,"utf-8"),f=`user_${i}`;ob[f]=p,o.languageToQueryKey[i]=f}catch{console.error(`[smart-file-read] Custom query file not found: ${d}, falling back to generic`),o.languageToQueryKey[i]="generic"}}else o.languageToQueryKey[i]="generic"}}return ji.set(e,o),o}var rb={javascript:"tree-sitter-javascript",typescript:"tree-sitter-typescript/typescript",tsx:"tree-sitter-typescript/tsx",python:"tree-sitter-python",go:"tree-sitter-go",rust:"tree-sitter-rust",ruby:"tree-sitter-ruby",java:"tree-sitter-java",c:"tree-sitter-c",cpp:"tree-sitter-cpp",kotlin:"tree-sitter-kotlin",swift:"tree-sitter-swift",php:"tree-sitter-php/php",elixir:"tree-sitter-elixir",lua:"@tree-sitter-grammars/tree-sitter-lua",scala:"tree-sitter-scala",bash:"tree-sitter-bash",haskell:"tree-sitter-haskell",zig:"@tree-sitter-grammars/tree-sitter-zig",css:"tree-sitter-css",scss:"tree-sitter-scss",toml:"@tree-sitter-grammars/tree-sitter-toml",yaml:"@tree-sitter-grammars/tree-sitter-yaml",sql:"@derekstride/tree-sitter-sql",markdown:"@tree-sitter-grammars/tree-sitter-markdown"},VO={markdown:"tree-sitter-markdown"};function WO(e){let t=rb[e];if(!t)return null;let r=VO[e];if(r){try{let n=dm.resolve(t+"/package.json"),o=(0,ze.join)((0,ze.dirname)(n),r);if((0,Re.existsSync)((0,ze.join)(o,"src")))return o}catch{}return null}try{let n=dm.resolve(t+"/package.json");return(0,ze.dirname)(n)}catch{return null}}function nb(e,t){let r=WO(e);if(r)return r;if(!t)return null;let o=Ni(t).grammars[e];if(!o)return null;try{let i=(0,ze.join)(t,"node_modules",o.package,"package.json");if((0,Re.existsSync)(i)){let a=(0,ze.dirname)(i);if((0,Re.existsSync)((0,ze.join)(a,"src")))return a}}catch{}return console.error(`[smart-file-read] Grammar package not found for "${e}": ${o.package} (install it in your project's node_modules)`),null}var ob={jsts:`
|
|
(function_declaration name: (identifier) @name) @func
|
|
(lexical_declaration (variable_declarator name: (identifier) @name value: [(arrow_function) (function_expression)])) @const_func
|
|
(class_declaration name: (type_identifier) @name) @cls
|
|
(method_definition name: (property_identifier) @name) @method
|
|
(interface_declaration name: (type_identifier) @name) @iface
|
|
(type_alias_declaration name: (type_identifier) @name) @tdef
|
|
(enum_declaration name: (identifier) @name) @enm
|
|
(import_statement) @imp
|
|
(export_statement) @exp
|
|
`,python:`
|
|
(function_definition name: (identifier) @name) @func
|
|
(class_definition name: (identifier) @name) @cls
|
|
(import_statement) @imp
|
|
(import_from_statement) @imp
|
|
`,go:`
|
|
(function_declaration name: (identifier) @name) @func
|
|
(method_declaration name: (field_identifier) @name) @method
|
|
(type_declaration (type_spec name: (type_identifier) @name)) @tdef
|
|
(import_declaration) @imp
|
|
`,rust:`
|
|
(function_item name: (identifier) @name) @func
|
|
(struct_item name: (type_identifier) @name) @struct_def
|
|
(enum_item name: (type_identifier) @name) @enm
|
|
(trait_item name: (type_identifier) @name) @trait_def
|
|
(impl_item type: (type_identifier) @name) @impl_def
|
|
(use_declaration) @imp
|
|
`,ruby:`
|
|
(method name: (identifier) @name) @func
|
|
(class name: (constant) @name) @cls
|
|
(module name: (constant) @name) @cls
|
|
(call method: (identifier) @name) @imp
|
|
`,java:`
|
|
(method_declaration name: (identifier) @name) @method
|
|
(class_declaration name: (identifier) @name) @cls
|
|
(interface_declaration name: (identifier) @name) @iface
|
|
(enum_declaration name: (identifier) @name) @enm
|
|
(import_declaration) @imp
|
|
`,kotlin:`
|
|
(function_declaration (simple_identifier) @name) @func
|
|
(class_declaration (type_identifier) @name) @cls
|
|
(object_declaration (type_identifier) @name) @cls
|
|
(import_header) @imp
|
|
`,swift:`
|
|
(function_declaration name: (simple_identifier) @name) @func
|
|
(class_declaration name: (type_identifier) @name) @cls
|
|
(protocol_declaration name: (type_identifier) @name) @iface
|
|
(import_declaration) @imp
|
|
`,php:`
|
|
(function_definition name: (name) @name) @func
|
|
(class_declaration name: (name) @name) @cls
|
|
(interface_declaration name: (name) @name) @iface
|
|
(trait_declaration name: (name) @name) @trait_def
|
|
(method_declaration name: (name) @name) @method
|
|
(namespace_use_declaration) @imp
|
|
`,lua:`
|
|
(function_declaration name: (identifier) @name) @func
|
|
(function_declaration name: (dot_index_expression) @name) @func
|
|
(function_declaration name: (method_index_expression) @name) @func
|
|
`,scala:`
|
|
(function_definition name: (identifier) @name) @func
|
|
(class_definition name: (identifier) @name) @cls
|
|
(object_definition name: (identifier) @name) @cls
|
|
(trait_definition name: (identifier) @name) @trait_def
|
|
(import_declaration) @imp
|
|
`,bash:`
|
|
(function_definition name: (word) @name) @func
|
|
`,haskell:`
|
|
(function name: (variable) @name) @func
|
|
(type_synomym name: (name) @name) @tdef
|
|
(newtype name: (name) @name) @tdef
|
|
(data_type name: (name) @name) @tdef
|
|
(class name: (name) @name) @cls
|
|
(import) @imp
|
|
`,zig:`
|
|
(function_declaration name: (identifier) @name) @func
|
|
(test_declaration) @func
|
|
`,css:`
|
|
(rule_set (selectors) @name) @func
|
|
(media_statement) @cls
|
|
(keyframes_statement (keyframes_name) @name) @cls
|
|
(import_statement) @imp
|
|
`,scss:`
|
|
(rule_set (selectors) @name) @func
|
|
(media_statement) @cls
|
|
(keyframes_statement (keyframes_name) @name) @cls
|
|
(import_statement) @imp
|
|
(mixin_statement name: (identifier) @name) @mixin_def
|
|
(function_statement name: (identifier) @name) @func
|
|
(include_statement) @imp
|
|
`,toml:`
|
|
(table (bare_key) @name) @cls
|
|
(table (dotted_key) @name) @cls
|
|
(table_array_element (bare_key) @name) @cls
|
|
(table_array_element (dotted_key) @name) @cls
|
|
`,yaml:`
|
|
(block_mapping_pair key: (flow_node) @name) @func
|
|
`,sql:`
|
|
(create_table (object_reference) @name) @cls
|
|
(create_function (object_reference) @name) @func
|
|
(create_view (object_reference) @name) @cls
|
|
`,markdown:`
|
|
(atx_heading heading_content: (inline) @name) @heading
|
|
(setext_heading heading_content: (paragraph) @name) @heading
|
|
(fenced_code_block (info_string (language) @name)) @code_block
|
|
(fenced_code_block) @code_block
|
|
(minus_metadata) @frontmatter
|
|
(link_reference_definition (link_label) @name) @ref
|
|
`,generic:`
|
|
(function_declaration name: (identifier) @name) @func
|
|
(function_definition name: (identifier) @name) @func
|
|
(class_declaration name: (identifier) @name) @cls
|
|
(class_definition name: (identifier) @name) @cls
|
|
(import_statement) @imp
|
|
(import_declaration) @imp
|
|
`,php:`
|
|
(function_definition name: (name) @name) @func
|
|
(method_declaration name: (name) @name) @method
|
|
(class_declaration name: (name) @name) @cls
|
|
(interface_declaration name: (name) @name) @iface
|
|
(trait_declaration name: (name) @name) @trait_def
|
|
(namespace_use_declaration) @imp
|
|
`};function JO(e){switch(e){case"javascript":case"typescript":case"tsx":return"jsts";case"python":return"python";case"go":return"go";case"rust":return"rust";case"ruby":return"ruby";case"java":return"java";case"kotlin":return"kotlin";case"swift":return"swift";case"php":return"php";case"elixir":return"generic";case"lua":return"lua";case"scala":return"scala";case"bash":return"bash";case"haskell":return"haskell";case"zig":return"zig";case"css":return"css";case"scss":return"scss";case"toml":return"toml";case"yaml":return"yaml";case"sql":return"sql";case"markdown":return"markdown";default:return"generic"}}var cm=null,um=new Map;function ib(e){if(um.has(e))return um.get(e);cm||(cm=(0,Re.mkdtempSync)((0,ze.join)((0,fm.tmpdir)(),"smart-read-queries-")));let t=(0,ze.join)(cm,`${e}.scm`);return(0,Re.writeFileSync)(t,ob[e]),um.set(e,t),t}var Di=null;function HO(){if(Di)return Di;try{let e=dm.resolve("tree-sitter-cli/package.json"),t=(0,ze.join)((0,ze.dirname)(e),"tree-sitter");if((0,Re.existsSync)(t))return Di=t,t}catch{}return Di="tree-sitter",Di}function GO(e,t,r){return ab(e,[t],r).get(t)||[]}function ab(e,t,r){if(t.length===0)return new Map;let n=HO(),o=["query","-p",r,e,...t],i;try{i=(0,Q$.execFileSync)(n,o,{encoding:"utf-8",timeout:3e4,stdio:["pipe","pipe","pipe"]})}catch{return new Map}return KO(i)}function KO(e){let t=new Map,r=null,n=null;for(let o of e.split(`
|
|
`)){if(o.length>0&&!o.startsWith(" ")&&!o.startsWith(" ")){r=o.trim(),t.has(r)||t.set(r,[]),n=null;continue}if(!r)continue;let i=o.match(/^\s+pattern:\s+(\d+)/);if(i){n={pattern:parseInt(i[1]),captures:[]},t.get(r).push(n);continue}let a=o.match(/^\s+capture:\s+(?:\d+\s*-\s*)?(\w+),\s*start:\s*\((\d+),\s*(\d+)\),\s*end:\s*\((\d+),\s*(\d+)\)(?:,\s*text:\s*`([^`]*)`)?/);a&&n&&n.captures.push({tag:a[1],startRow:parseInt(a[2]),startCol:parseInt(a[3]),endRow:parseInt(a[4]),endCol:parseInt(a[5]),text:a[6]})}return t}var Y$={func:"function",const_func:"function",cls:"class",method:"method",iface:"interface",tdef:"type",enm:"enum",struct_def:"struct",trait_def:"trait",impl_def:"impl",mixin_def:"mixin",heading:"section",code_block:"code",frontmatter:"metadata",ref:"reference"},BO=new Set(["class","struct","impl","trait"]);function YO(e,t,r,n=200){let i=e[t]||"";if(!i.trimEnd().endsWith("{")&&!i.trimEnd().endsWith(":")){let a=e.slice(t,Math.min(t+10,r+1)).join(`
|
|
`),s=a.indexOf("{");s!==-1&&s<500&&(i=a.slice(0,s).replace(/\n/g," ").replace(/\s+/g," ").trim())}return i=i.replace(/\s*[{:]\s*$/,"").trim(),i.length>n&&(i=i.slice(0,n-3)+"..."),i}function XO(e,t){let r=[],n=!1;for(let o=t-1;o>=0;o--){let i=e[o].trim();if(i===""){if(n)break;continue}if(i.startsWith("/**")||i.startsWith("*")||i.startsWith("*/")||i.startsWith("//")||i.startsWith("///")||i.startsWith("//!")||i.startsWith("#")||i.startsWith("@"))r.unshift(e[o]),n=!0;else break}return r.length>0?r.join(`
|
|
`).trim():void 0}function QO(e,t,r){for(let n=t+1;n<=Math.min(t+3,r);n++){let o=e[n]?.trim();if(o){if(o.startsWith('"""')||o.startsWith("'''"))return o;break}}}function ej(e,t,r,n,o,i){switch(i){case"javascript":case"typescript":case"tsx":return n.some(a=>t>=a.startRow&&r<=a.endRow);case"python":return!e.startsWith("_");case"go":return e.length>0&&e[0]===e[0].toUpperCase()&&e[0]!==e[0].toLowerCase();case"rust":return o[t]?.trimStart().startsWith("pub")??!1;default:return!0}}function sb(e,t,r){let n=[],o=[],i=[],a=[];for(let c of e)for(let u of c.captures)u.tag==="exp"&&i.push({startRow:u.startRow,endRow:u.endRow}),u.tag==="imp"&&o.push(u.text||t[u.startRow]?.trim()||"");for(let c of e){let u=c.captures.find(b=>Y$[b.tag]),l=c.captures.find(b=>b.tag==="name");if(!u)continue;let d=u.startRow,p=u.endRow,f=Y$[u.tag],h=l?.text||"anonymous",g;if(r==="markdown"&&f==="section"){let N=(t[d]||"").match(/^(#{1,6})\s/),T=N?N[1].length:1;g=`${"#".repeat(T)} ${h}`}else if(r==="markdown"&&f==="code"){let b=h!=="anonymous"?h:"";g=b?"```"+b:"```"}else r==="markdown"&&f==="metadata"?g="---frontmatter---":r==="markdown"&&f==="reference"?g=t[d]?.trim()||h:g=YO(t,d,p);let y=r==="markdown"?void 0:XO(t,d),S=r==="python"?QO(t,d,p):void 0,x={name:h,kind:f,signature:g,jsdoc:y||S,lineStart:d,lineEnd:p,exported:ej(h,d,p,i,t,r)};BO.has(f)&&(x.children=[],a.push({sym:x,startRow:d,endRow:p})),n.push(x)}if(r==="markdown"){let c=new Map,u=new Set;for(let l of n){if(l.kind!=="code")continue;let d=`${l.lineStart}:${l.lineEnd}`,p=c.get(d);p?l.name!=="anonymous"?(u.add(p),c.set(d,l)):u.add(l):c.set(d,l)}if(u.size>0){let l=n.filter(d=>!u.has(d));n.length=0,n.push(...l)}}let s=new Set;for(let c of a)for(let u of n)u!==c.sym&&u.lineStart>c.startRow&&u.lineEnd<=c.endRow&&(u.kind==="function"&&(u.kind="method"),c.sym.children.push(u),s.add(u));return{symbols:n.filter(c=>!s.has(c)),imports:o}}function ec(e,t,r){let n=r?Ni(r):Mn,o=eb(t,n),i=e.split(`
|
|
`),a=nb(o,r);if(!a)return{filePath:t,language:o,symbols:[],imports:[],totalLines:i.length,foldedTokenEstimate:50};let s=tb(o,n),c=ib(s),u=t.slice(t.lastIndexOf("."))||".txt",l=(0,Re.mkdtempSync)((0,ze.join)((0,fm.tmpdir)(),"smart-src-")),d=(0,ze.join)(l,`source${u}`);(0,Re.writeFileSync)(d,e);try{let p=GO(c,d,a),f=sb(p,i,o),h=An({filePath:t,language:o,symbols:f.symbols,imports:f.imports,totalLines:i.length,foldedTokenEstimate:0});return{filePath:t,language:o,symbols:f.symbols,imports:f.imports,totalLines:i.length,foldedTokenEstimate:Math.ceil(h.length/4)}}finally{(0,Re.rmSync)(l,{recursive:!0,force:!0})}}function cb(e,t){let r=new Map,n=t?Ni(t):Mn,o=new Map;for(let i of e){let a=eb(i.relativePath,n);o.has(a)||o.set(a,[]),o.get(a).push(i)}for(let[i,a]of o){let s=nb(i,t);if(!s){for(let p of a){let f=p.content.split(`
|
|
`);r.set(p.relativePath,{filePath:p.relativePath,language:i,symbols:[],imports:[],totalLines:f.length,foldedTokenEstimate:50})}continue}let c=tb(i,n),u=ib(c),l=a.map(p=>p.absolutePath),d=ab(u,l,s);for(let p of a){let f=p.content.split(`
|
|
`),h=d.get(p.absolutePath)||[],g=sb(h,f,i),y=An({filePath:p.relativePath,language:i,symbols:g.symbols,imports:g.imports,totalLines:f.length,foldedTokenEstimate:0});r.set(p.relativePath,{filePath:p.relativePath,language:i,symbols:g.symbols,imports:g.imports,totalLines:f.length,foldedTokenEstimate:Math.ceil(y.length/4)})}}return r}function An(e){if(e.language==="markdown")return tj(e);let t=[];if(t.push(`\u{1F4C1} ${e.filePath} (${e.language}, ${e.totalLines} lines)`),t.push(""),e.imports.length>0){t.push(` \u{1F4E6} Imports: ${e.imports.length} statements`);for(let r of e.imports.slice(0,10))t.push(` ${r}`);e.imports.length>10&&t.push(` ... +${e.imports.length-10} more`),t.push("")}for(let r of e.symbols)t.push(ub(r," "));return t.join(`
|
|
`)}function tj(e){let t=[];t.push(`\u{1F4C4} ${e.filePath} (${e.language}, ${e.totalLines} lines)`);for(let n of e.symbols)if(n.kind==="section"){let o=n.signature.match(/^(#{1,6})\s/),i=o?o[1].length:1,a=" ".repeat(i),s=`L${n.lineStart+1}`,c=`${a}${n.signature}`;t.push(`${c.padEnd(56)}${s}`)}else if(n.kind==="code"){let o=X$(e.symbols,n.lineStart),i=" ".repeat(o+1),a=n.lineStart===n.lineEnd?`L${n.lineStart+1}`:`L${n.lineStart+1}-${n.lineEnd+1}`,s=`${i}${n.signature}`;t.push(`${s.padEnd(56)}${a}`)}else if(n.kind==="metadata"){let o=n.lineStart===n.lineEnd?`L${n.lineStart+1}`:`L${n.lineStart+1}-${n.lineEnd+1}`,i=` ${n.signature}`;t.push(`${i.padEnd(56)}${o}`)}else if(n.kind==="reference"){let o=X$(e.symbols,n.lineStart),i=" ".repeat(o+1),a=`L${n.lineStart+1}`,s=`${i}\u2197 ${n.name}`;t.push(`${s.padEnd(56)}${a}`)}return t.join(`
|
|
`)}function X$(e,t){let r=0;for(let n of e)if(n.kind==="section"&&n.lineStart<t){let o=n.signature.match(/^(#{1,6})\s/);r=o?o[1].length:1}return r}function ub(e,t){let r=[],n=rj(e.kind),o=e.exported?" [exported]":"",i=e.lineStart===e.lineEnd?`L${e.lineStart+1}`:`L${e.lineStart+1}-${e.lineEnd+1}`;if(r.push(`${t}${n} ${e.name}${o} (${i})`),r.push(`${t} ${e.signature}`),e.jsdoc){let s=e.jsdoc.split(`
|
|
`).find(c=>{let u=c.replace(/^[\s*/]+/,"").replace(/^['"`]{3}/,"").trim();return u.length>0&&!u.startsWith("/**")});if(s){let c=s.replace(/^[\s*/]+/,"").replace(/^['"`]{3}/,"").replace(/['"`]{3}$/,"").trim();c&&r.push(`${t} \u{1F4AC} ${c}`)}}if(e.children&&e.children.length>0)for(let a of e.children)r.push(ub(a,t+" "));return r.join(`
|
|
`)}function rj(e){return{function:"\u0192",method:"\u0192",class:"\u25C6",interface:"\u25C7",type:"\u25C7",const:"\u25CF",variable:"\u25CB",export:"\u2192",struct:"\u25C6",enum:"\u25A3",trait:"\u25C7",impl:"\u25C8",property:"\u25CB",getter:"\u21E2",setter:"\u21E0",mixin:"\u25C8",section:"\xA7",code:"\u2318",metadata:"\u25CA",reference:"\u2197"}[e]||"\xB7"}function lb(e,t,r){let n=ec(e,t),o=u=>{for(let l of u){if(l.name===r)return l;if(l.children){let d=o(l.children);if(d)return d}}return null},i=o(n.symbols);if(!i)return null;let a=e.split(`
|
|
`);if(n.language==="markdown"&&i.kind==="section"){let u=i.signature.match(/^(#{1,6})\s/),l=u?u[1].length:1,d=i.lineStart,p=a.length-1;for(let h of n.symbols)if(h.kind==="section"&&h.lineStart>d){let g=h.signature.match(/^(#{1,6})\s/);if((g?g[1].length:1)<=l){for(p=h.lineStart-1;p>d&&a[p].trim()==="";)p--;break}}let f=a.slice(d,p+1).join(`
|
|
`);return`<!-- \u{1F4CD} ${t} L${d+1}-${p+1} -->
|
|
${f}`}let s=i.lineStart;for(let u=i.lineStart-1;u>=0;u--){let l=a[u].trim();if(l===""||l.startsWith("*")||l.startsWith("/**")||l.startsWith("///")||l.startsWith("//")||l.startsWith("#")||l.startsWith("@")||l==="*/")s=u;else break}let c=a.slice(s,i.lineEnd+1).join(`
|
|
`);return`// \u{1F4CD} ${t} L${s+1}-${i.lineEnd+1}
|
|
${c}`}var db=new Set([".js",".jsx",".ts",".tsx",".mjs",".cjs",".py",".pyw",".go",".rs",".rb",".java",".cs",".cpp",".cc",".cxx",".c",".h",".hpp",".hh",".swift",".kt",".kts",".php",".vue",".svelte",".ex",".exs",".lua",".scala",".sc",".sh",".bash",".zsh",".hs",".zig",".css",".scss",".toml",".yml",".yaml",".sql",".md",".mdx"]),oj=new Set(["node_modules",".git","dist","build",".next","__pycache__",".venv","venv","env",".env","target","vendor",".cache",".turbo","coverage",".nyc_output",".claude",".smart-file-read"]),ij=512*1024;async function*pb(e,t,r=20,n){if(r<=0)return;let o;try{o=await(0,Cn.readdir)(e,{withFileTypes:!0})}catch{return}for(let i of o){if(i.name.startsWith(".")&&i.name!=="."||oj.has(i.name))continue;let a=(0,Ri.join)(e,i.name);if(i.isDirectory())yield*pb(a,t,r-1,n);else if(i.isFile()){let s=i.name.slice(i.name.lastIndexOf("."));(db.has(s)||n&&n.has(s))&&(yield a)}}}async function aj(e){try{let t=await(0,Cn.stat)(e);if(t.size>ij||t.size===0)return null;let r=await(0,Cn.readFile)(e,"utf-8");return r.slice(0,1e3).includes("\0")?null:r}catch{return null}}async function fb(e,t,r={}){let n=r.maxResults||20,o=t.toLowerCase(),i=o.split(/[\s_\-./]+/).filter(x=>x.length>0),a=r.projectRoot||e,s=Ni(a),c=new Set;for(let x of Object.values(s.grammars))for(let b of x.extensions)db.has(b)||c.add(b);let u=[];for await(let x of pb(e,e,20,c.size>0?c:void 0)){if(r.filePattern&&!(0,Ri.relative)(e,x).toLowerCase().includes(r.filePattern.toLowerCase()))continue;let b=await aj(x);b&&u.push({absolutePath:x,relativePath:(0,Ri.relative)(e,x),content:b})}let l=cb(u,a),d=[],p=[],f=0;for(let[x,b]of l){f+=sj(b);let T=tc(x.toLowerCase(),i)>0,Ve=[],We=(Zn,qr)=>{for(let ye of Zn){let rr=0,mt="",Ln=tc(ye.name.toLowerCase(),i);Ln>0&&(rr+=Ln*3,mt="name match"),ye.signature.toLowerCase().includes(o)&&(rr+=2,mt=mt?`${mt} + signature`:"signature match"),ye.jsdoc&&ye.jsdoc.toLowerCase().includes(o)&&(rr+=1,mt=mt?`${mt} + jsdoc`:"jsdoc match"),rr>0&&(T=!0,Ve.push({filePath:x,symbolName:qr?`${qr}.${ye.name}`:ye.name,kind:ye.kind,signature:ye.signature,jsdoc:ye.jsdoc,lineStart:ye.lineStart,lineEnd:ye.lineEnd,matchReason:mt})),ye.children&&We(ye.children,ye.name)}};We(b.symbols),T&&(d.push(b),p.push(...Ve))}p.sort((x,b)=>{let N=tc(x.symbolName.toLowerCase(),i);return tc(b.symbolName.toLowerCase(),i)-N});let h=p.slice(0,n),g=new Set(h.map(x=>x.filePath)),y=d.filter(x=>g.has(x.filePath)).slice(0,n),S=y.reduce((x,b)=>x+b.foldedTokenEstimate,0);return{foldedFiles:y,matchingSymbols:h,totalFilesScanned:u.length,totalSymbolsFound:f,tokenEstimate:S}}function tc(e,t){let r=0;for(let n of t)if(e===n)r+=10;else if(e.includes(n))r+=5;else{let o=0,i=0;for(let a of n){let s=e.indexOf(a,o);s!==-1&&(i++,o=s+1)}i===n.length&&(r+=1)}return r}function sj(e){let t=e.symbols.length;for(let r of e.symbols)r.children&&(t+=r.children.length);return t}function mb(e,t){let r=[];if(r.push(`\u{1F50D} Smart Search: "${t}"`),r.push(` Scanned ${e.totalFilesScanned} files, found ${e.totalSymbolsFound} symbols`),r.push(` ${e.matchingSymbols.length} matches across ${e.foldedFiles.length} files (~${e.tokenEstimate} tokens for folded view)`),r.push(""),e.matchingSymbols.length===0)return r.push(" No matching symbols found."),r.join(`
|
|
`);r.push("\u2500\u2500 Matching Symbols \u2500\u2500"),r.push("");for(let n of e.matchingSymbols){if(r.push(` ${n.kind} ${n.symbolName} (${n.filePath}:${n.lineStart+1})`),r.push(` ${n.signature}`),n.jsdoc){let o=n.jsdoc.split(`
|
|
`).find(i=>i.replace(/^[\s*/]+/,"").trim().length>0);o&&r.push(` \u{1F4AC} ${o.replace(/^[\s*/]+/,"").trim()}`)}r.push("")}r.push("\u2500\u2500 Folded File Views \u2500\u2500"),r.push("");for(let n of e.foldedFiles)r.push(An(n)),r.push("");return r.push("\u2500\u2500 Actions \u2500\u2500"),r.push(" To see full implementation: use smart_unfold with file path and symbol name"),r.join(`
|
|
`)}var hm=require("node:fs/promises"),vb=require("node:fs"),Fr=require("node:path"),_b=require("node:url"),vj={},cj="12.2.1";console.log=(...e)=>{w.error("CONSOLE","Intercepted console output (MCP protocol protection)",void 0,{args:e})};var yb=!1,$b=(()=>{if(typeof __dirname<"u")return __dirname;try{return(0,Fr.dirname)((0,_b.fileURLToPath)(vj.url))}catch{return yb=!0,process.cwd()}})(),gm=(0,Fr.resolve)($b,"worker-service.cjs");function uj(){yb&&((0,vb.existsSync)(gm)||w.error("SYSTEM","mcp-server: dirname resolution failed (both __dirname and import.meta.url are unavailable). Fell back to process.cwd() and the resolved WORKER_SCRIPT_PATH does not exist. This is the actual problem \u2014 the worker bundle is fine, but mcp-server cannot locate it. Worker auto-start will fail until the dirname-resolution path is fixed.",{workerScriptPath:gm,mcpServerDir:$b}))}var hb={search:"/api/search",timeline:"/api/timeline"};async function mm(e,t){w.debug("SYSTEM","\u2192 Worker API",void 0,{endpoint:e,params:t});try{let r=new URLSearchParams;for(let[a,s]of Object.entries(t))s!=null&&r.append(a,String(s));let n=`${e}?${r}`,o=await Ys(n);if(!o.ok){let a=await o.text();throw new Error(`Worker API error (${o.status}): ${a}`)}let i=await o.json();return w.debug("SYSTEM","\u2190 Worker API success",void 0,{endpoint:e}),i}catch(r){return w.error("SYSTEM","\u2190 Worker API error",{endpoint:e},r),{content:[{type:"text",text:`Error calling Worker API: ${r instanceof Error?r.message:String(r)}`}],isError:!0}}}async function Un(e,t){w.debug("HTTP","Worker API request (POST)",void 0,{endpoint:e});try{let r=await Ys(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!r.ok){let o=await r.text();throw new Error(`Worker API error (${r.status}): ${o}`)}let n=await r.json();return w.debug("HTTP","Worker API success (POST)",void 0,{endpoint:e}),{content:[{type:"text",text:JSON.stringify(n,null,2)}]}}catch(r){return w.error("HTTP","Worker API error (POST)",{endpoint:e},r),{content:[{type:"text",text:`Error calling Worker API: ${r instanceof Error?r.message:String(r)}`}],isError:!0}}}async function lj(){try{return(await Ys("/api/health")).ok}catch(e){return w.debug("SYSTEM","Worker health check failed",{},e),!1}}async function dj(){if(await lj())return!0;w.warn("SYSTEM","Worker not available, attempting auto-start for MCP client"),uj();try{let e=Bf(),t=await B$(e,gm);return t||w.error("SYSTEM","Worker auto-start returned false \u2014 MCP tools that require the worker (search, timeline, get_observations) will fail until the worker is running. Check earlier log lines for the specific failure reason (Bun not found, missing worker bundle, port conflict, etc.)."),t}catch(e){return w.error("SYSTEM","Worker auto-start threw \u2014 MCP tools that require the worker (search, timeline, get_observations) will fail until the worker is running.",void 0,e),!1}}var bb=[{name:"__IMPORTANT",description:`3-LAYER WORKFLOW (ALWAYS FOLLOW):
|
|
1. search(query) \u2192 Get index with IDs (~50-100 tokens/result)
|
|
2. timeline(anchor=ID) \u2192 Get context around interesting results
|
|
3. get_observations([IDs]) \u2192 Fetch full details ONLY for filtered IDs
|
|
NEVER fetch full details without filtering first. 10x token savings.`,inputSchema:{type:"object",properties:{}},handler:async()=>({content:[{type:"text",text:`# Memory Search Workflow
|
|
|
|
**3-Layer Pattern (ALWAYS follow this):**
|
|
|
|
1. **Search** - Get index of results with IDs
|
|
\`search(query="...", limit=20, project="...")\`
|
|
Returns: Table with IDs, titles, dates (~50-100 tokens/result)
|
|
|
|
2. **Timeline** - Get context around interesting results
|
|
\`timeline(anchor=<ID>, depth_before=3, depth_after=3)\`
|
|
Returns: Chronological context showing what was happening
|
|
|
|
3. **Fetch** - Get full details ONLY for relevant IDs
|
|
\`get_observations(ids=[...])\` # ALWAYS batch for 2+ items
|
|
Returns: Complete details (~500-1000 tokens/result)
|
|
|
|
**Why:** 10x token savings. Never fetch full details without filtering first.`}]})},{name:"search",description:"Step 1: Search memory. Returns index with IDs. Params: query, limit, project, type, obs_type, dateStart, dateEnd, offset, orderBy",inputSchema:{type:"object",properties:{query:{type:"string",description:"Search query"},limit:{type:"number",description:"Max results (default 20)"},project:{type:"string",description:"Filter by project name"},type:{type:"string",description:"Filter by observation type"},obs_type:{type:"string",description:"Filter by obs_type field"},dateStart:{type:"string",description:"Start date filter (ISO)"},dateEnd:{type:"string",description:"End date filter (ISO)"},offset:{type:"number",description:"Pagination offset"},orderBy:{type:"string",description:"Sort order: date_desc or date_asc"}},additionalProperties:!0},handler:async e=>{let t=hb.search;return await mm(t,e)}},{name:"timeline",description:"Step 2: Get context around results. Params: anchor (observation ID) OR query (finds anchor automatically), depth_before, depth_after, project",inputSchema:{type:"object",properties:{anchor:{type:"number",description:"Observation ID to center the timeline around"},query:{type:"string",description:"Query to find anchor automatically"},depth_before:{type:"number",description:"Items before anchor (default 3)"},depth_after:{type:"number",description:"Items after anchor (default 3)"},project:{type:"string",description:"Filter by project name"}},additionalProperties:!0},handler:async e=>{let t=hb.timeline;return await mm(t,e)}},{name:"get_observations",description:"Step 3: Fetch full details for filtered IDs. Params: ids (array of observation IDs, required), orderBy, limit, project",inputSchema:{type:"object",properties:{ids:{type:"array",items:{type:"number"},description:"Array of observation IDs to fetch (required)"}},required:["ids"],additionalProperties:!0},handler:async e=>await Un("/api/observations/batch",e)},{name:"smart_search",description:"Search codebase for symbols, functions, classes using tree-sitter AST parsing. Returns folded structural views with token counts. Use path parameter to scope the search.",inputSchema:{type:"object",properties:{query:{type:"string",description:"Search term \u2014 matches against symbol names, file names, and file content"},path:{type:"string",description:"Root directory to search (default: current working directory)"},max_results:{type:"number",description:"Maximum results to return (default: 20)"},file_pattern:{type:"string",description:'Substring filter for file paths (e.g. ".ts", "src/services")'}},required:["query"]},handler:async e=>{let t=(0,Fr.resolve)(e.path||process.cwd()),r=await fb(t,e.query,{maxResults:e.max_results||20,filePattern:e.file_pattern});return{content:[{type:"text",text:mb(r,e.query)}]}}},{name:"smart_unfold",description:"Expand a specific symbol (function, class, method) from a file. Returns the full source code of just that symbol. Use after smart_search or smart_outline to read specific code.",inputSchema:{type:"object",properties:{file_path:{type:"string",description:"Path to the source file"},symbol_name:{type:"string",description:"Name of the symbol to unfold (function, class, method, etc.)"}},required:["file_path","symbol_name"]},handler:async e=>{let t=(0,Fr.resolve)(e.file_path),r=await(0,hm.readFile)(t,"utf-8"),n=lb(r,t,e.symbol_name);if(n)return{content:[{type:"text",text:n}]};let o=ec(r,t);if(o.symbols.length>0){let i=o.symbols.map(a=>` - ${a.name} (${a.kind})`).join(`
|
|
`);return{content:[{type:"text",text:`Symbol "${e.symbol_name}" not found in ${e.file_path}.
|
|
|
|
Available symbols:
|
|
${i}`}]}}return{content:[{type:"text",text:`Could not parse ${e.file_path}. File may be unsupported or empty.`}]}}},{name:"smart_outline",description:"Get structural outline of a file \u2014 shows all symbols (functions, classes, methods, types) with signatures but bodies folded. Much cheaper than reading the full file.",inputSchema:{type:"object",properties:{file_path:{type:"string",description:"Path to the source file"}},required:["file_path"]},handler:async e=>{let t=(0,Fr.resolve)(e.file_path),r=await(0,hm.readFile)(t,"utf-8"),n=ec(r,t);return n.symbols.length>0?{content:[{type:"text",text:An(n)}]}:{content:[{type:"text",text:`Could not parse ${e.file_path}. File may use an unsupported language or be empty.`}]}}},{name:"build_corpus",description:"Build a knowledge corpus from filtered observations. Creates a queryable knowledge agent. Params: name (required), description, project, types (comma-separated), concepts (comma-separated), files (comma-separated), query, dateStart, dateEnd, limit",inputSchema:{type:"object",properties:{name:{type:"string",description:"Corpus name (used as filename)"},description:{type:"string",description:"What this corpus is about"},project:{type:"string",description:"Filter by project"},types:{type:"string",description:"Comma-separated observation types: decision,bugfix,feature,refactor,discovery,change"},concepts:{type:"string",description:"Comma-separated concepts to filter by"},files:{type:"string",description:"Comma-separated file paths to filter by"},query:{type:"string",description:"Semantic search query"},dateStart:{type:"string",description:"Start date (ISO format)"},dateEnd:{type:"string",description:"End date (ISO format)"},limit:{type:"number",description:"Maximum observations (default 500)"}},required:["name"],additionalProperties:!0},handler:async e=>await Un("/api/corpus",e)},{name:"list_corpora",description:"List all knowledge corpora with their stats and priming status",inputSchema:{type:"object",properties:{},additionalProperties:!0},handler:async e=>await mm("/api/corpus",e)},{name:"prime_corpus",description:"Prime a knowledge corpus \u2014 creates an AI session loaded with the corpus knowledge. Must be called before query_corpus.",inputSchema:{type:"object",properties:{name:{type:"string",description:"Name of the corpus to prime"}},required:["name"],additionalProperties:!0},handler:async e=>{let{name:t,...r}=e;if(typeof t!="string"||t.trim()==="")throw new Error("Missing required argument: name");return await Un(`/api/corpus/${encodeURIComponent(t)}/prime`,r)}},{name:"query_corpus",description:"Ask a question to a primed knowledge corpus. The corpus must be primed first with prime_corpus.",inputSchema:{type:"object",properties:{name:{type:"string",description:"Name of the corpus to query"},question:{type:"string",description:"The question to ask"}},required:["name","question"],additionalProperties:!0},handler:async e=>{let{name:t,...r}=e;if(typeof t!="string"||t.trim()==="")throw new Error("Missing required argument: name");return await Un(`/api/corpus/${encodeURIComponent(t)}/query`,r)}},{name:"rebuild_corpus",description:"Rebuild a knowledge corpus from its stored filter \u2014 re-runs the search to refresh with new observations. Does not re-prime the session.",inputSchema:{type:"object",properties:{name:{type:"string",description:"Name of the corpus to rebuild"}},required:["name"],additionalProperties:!0},handler:async e=>{let{name:t,...r}=e;if(typeof t!="string"||t.trim()==="")throw new Error("Missing required argument: name");return await Un(`/api/corpus/${encodeURIComponent(t)}/rebuild`,r)}},{name:"reprime_corpus",description:"Create a fresh knowledge agent session for a corpus, clearing prior Q&A context. Use when conversation has drifted or after rebuilding.",inputSchema:{type:"object",properties:{name:{type:"string",description:"Name of the corpus to reprime"}},required:["name"],additionalProperties:!0},handler:async e=>{let{name:t,...r}=e;if(typeof t!="string"||t.trim()==="")throw new Error("Missing required argument: name");return await Un(`/api/corpus/${encodeURIComponent(t)}/reprime`,r)}}],vm=new Ws({name:"claude-mem",version:cj},{capabilities:{tools:{}}});vm.setRequestHandler(Wd,async()=>({tools:bb.map(e=>({name:e.name,description:e.description,inputSchema:e.inputSchema}))}));vm.setRequestHandler(Bo,async e=>{let t=bb.find(r=>r.name===e.params.name);if(!t)throw new Error(`Unknown tool: ${e.params.name}`);try{return await t.handler(e.params.arguments||{})}catch(r){return w.error("SYSTEM","Tool execution failed",{tool:e.params.name},r),{content:[{type:"text",text:`Tool execution failed: ${r instanceof Error?r.message:String(r)}`}],isError:!0}}});var pj=3e4,Mi=null,gb=!1;function rc(){Ai("stdio-closed")}function xb(e){w.warn("SYSTEM","MCP stdio stream errored, shutting down",{message:e.message}),Ai("stdio-error")}function fj(){process.stdin.on("end",rc),process.stdin.on("close",rc),process.stdin.on("error",xb)}function mj(){process.stdin.off("end",rc),process.stdin.off("close",rc),process.stdin.off("error",xb)}function hj(){if(process.platform==="win32")return;let e=process.ppid;Mi=setInterval(()=>{(process.ppid===1||process.ppid!==e)&&(w.info("SYSTEM","Parent process died, self-exiting to prevent orphan",{initialPpid:e,currentPpid:process.ppid}),Ai())},pj),Mi.unref&&Mi.unref()}function Ai(e="shutdown"){gb||(gb=!0,Mi&&clearInterval(Mi),mj(),w.info("SYSTEM","MCP server shutting down",{reason:e}),process.exit(0))}process.on("SIGTERM",Ai);process.on("SIGINT",Ai);async function gj(){let e=new Hs;fj(),await vm.connect(e),w.info("SYSTEM","Claude-mem search server started"),hj(),setTimeout(async()=>{await dj()?w.info("SYSTEM","Worker available",void 0,{}):(w.error("SYSTEM","Worker not available",void 0,{}),w.error("SYSTEM","Tools will fail until Worker is started"),w.error("SYSTEM","Start Worker with: npm run worker:restart"))},0)}gj().catch(e=>{w.error("SYSTEM","Fatal error",void 0,e),process.exit(0)});
|