dsh-palace 1.3.0 → 1.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +17 -2
- package/client/client.js +31 -23
- package/lib/index.js +652 -58
- package/lib/mcp.js +70 -66
- package/lib/palace-web.js +33 -25
- package/package.json +9 -4
package/lib/mcp.js
CHANGED
|
@@ -1,55 +1,55 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { createRequire } from "node:module"; const require = createRequire(import.meta.url);
|
|
3
|
-
var xw=Object.create;var $i=Object.defineProperty;var Sw=Object.getOwnPropertyDescriptor;var kw=Object.getOwnPropertyNames;var zw=Object.getPrototypeOf,Pw=Object.prototype.hasOwnProperty;var x=(e,t)=>()=>{try{return t||e((t={exports:{}}).exports,t),t.exports}catch(r){throw t=0,r}},ul=(e,t)=>{for(var r in t)$i(e,r,{get:t[r],enumerable:!0})},Ew=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of kw(t))!Pw.call(e,o)&&o!==r&&$i(e,o,{get:()=>t[o],enumerable:!(n=Sw(t,o))||n.enumerable});return e};var ll=(e,t,r)=>(r=e!=null?xw(zw(e)):{},Ew(t||!e||!e.__esModule?$i(r,"default",{value:e,enumerable:!0}):r,e));var Pn=x(V=>{"use strict";Object.defineProperty(V,"__esModule",{value:!0});V.regexpCode=V.getEsmExportName=V.getProperty=V.safeStringify=V.stringify=V.strConcat=V.addCodeArg=V.str=V._=V.nil=V._Code=V.Name=V.IDENTIFIER=V._CodeOrName=void 0;var kn=class{};V._CodeOrName=kn;V.IDENTIFIER=/^[a-z$_][a-z$_0-9]*$/i;var Ht=class extends kn{constructor(t){if(super(),!V.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}}};V.Name=Ht;var Le=class extends kn{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 Ht&&(r[n.str]=(r[n.str]||0)+1),r),{})}};V._Code=Le;V.nil=new Le("");function Ih(e,...t){let r=[e[0]],n=0;for(;n<t.length;)Qa(r,t[n]),r.push(e[++n]);return new Le(r)}V._=Ih;var Xa=new Le("+");function Th(e,...t){let r=[zn(e[0])],n=0;for(;n<t.length;)r.push(Xa),Qa(r,t[n]),r.push(Xa,zn(e[++n]));return W$(r),new Le(r)}V.str=Th;function Qa(e,t){t instanceof Le?e.push(...t._items):t instanceof Ht?e.push(t):e.push(Q$(t))}V.addCodeArg=Qa;function W$(e){let t=1;for(;t<e.length-1;){if(e[t]===Xa){let r=Y$(e[t-1],e[t+1]);if(r!==void 0){e.splice(t-1,3,r);continue}e[t++]="+"}t++}}function Y$(e,t){if(t==='""')return e;if(e==='""')return t;if(typeof e=="string")return t instanceof Ht||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 Ht))return`"${e}${t.slice(1)}`}function X$(e,t){return t.emptyStr()?e:e.emptyStr()?t:Th`${e}${t}`}V.strConcat=X$;function Q$(e){return typeof e=="number"||typeof e=="boolean"||e===null?e:zn(Array.isArray(e)?e.join(","):e)}function ex(e){return new Le(zn(e))}V.stringify=ex;function zn(e){return JSON.stringify(e).replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}V.safeStringify=zn;function tx(e){return typeof e=="string"&&V.IDENTIFIER.test(e)?new Le(`.${e}`):Ih`[${e}]`}V.getProperty=tx;function rx(e){if(typeof e=="string"&&V.IDENTIFIER.test(e))return new Le(`${e}`);throw new Error(`CodeGen: invalid export name: ${e}, use explicit $id name mapping`)}V.getEsmExportName=rx;function nx(e){return new Le(e.toString())}V.regexpCode=nx});var rc=x(Ee=>{"use strict";Object.defineProperty(Ee,"__esModule",{value:!0});Ee.ValueScope=Ee.ValueScopeName=Ee.Scope=Ee.varKinds=Ee.UsedValueState=void 0;var Pe=Pn(),ec=class extends Error{constructor(t){super(`CodeGen: "code" for ${t} not defined`),this.value=t.value}},Ts;(function(e){e[e.Started=0]="Started",e[e.Completed=1]="Completed"})(Ts||(Ee.UsedValueState=Ts={}));Ee.varKinds={const:new Pe.Name("const"),let:new Pe.Name("let"),var:new Pe.Name("var")};var Os=class{constructor({prefixes:t,parent:r}={}){this._names={},this._prefixes=t,this._parent=r}toName(t){return t instanceof Pe.Name?t:this.name(t)}name(t){return new Pe.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}}};Ee.Scope=Os;var Rs=class extends Pe.Name{constructor(t,r){super(r),this.prefix=t}setValue(t,{property:r,itemIndex:n}){this.value=t,this.scopePath=(0,Pe._)`.${new Pe.Name(r)}[${n}]`}};Ee.ValueScopeName=Rs;var ox=(0,Pe._)`\n`,tc=class extends Os{constructor(t){super(t),this._values={},this._scope=t.scope,this.opts={...t,_n:t.lines?ox:Pe.nil}}get(){return this._scope}name(t){return new Rs(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:s}=o,i=(n=r.key)!==null&&n!==void 0?n:r.ref,a=this._values[s];if(a){let l=a.get(i);if(l)return l}else a=this._values[s]=new Map;a.set(i,o);let c=this._scope[s]||(this._scope[s]=[]),u=c.length;return c[u]=r.ref,o.setValue(r,{property:s,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,Pe._)`${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 s=Pe.nil;for(let i in t){let a=t[i];if(!a)continue;let c=n[i]=n[i]||new Map;a.forEach(u=>{if(c.has(u))return;c.set(u,Ts.Started);let l=r(u);if(l){let d=this.opts.es5?Ee.varKinds.var:Ee.varKinds.const;s=(0,Pe._)`${s}${d} ${u} = ${l};${this.opts._n}`}else if(l=o?.(u))s=(0,Pe._)`${s}${l}${this.opts._n}`;else throw new ec(u);c.set(u,Ts.Completed)})}return s}};Ee.ValueScope=tc});var j=x(D=>{"use strict";Object.defineProperty(D,"__esModule",{value:!0});D.or=D.and=D.not=D.CodeGen=D.operators=D.varKinds=D.ValueScopeName=D.ValueScope=D.Scope=D.Name=D.regexpCode=D.stringify=D.getProperty=D.nil=D.strConcat=D.str=D._=void 0;var q=Pn(),Ye=rc(),It=Pn();Object.defineProperty(D,"_",{enumerable:!0,get:function(){return It._}});Object.defineProperty(D,"str",{enumerable:!0,get:function(){return It.str}});Object.defineProperty(D,"strConcat",{enumerable:!0,get:function(){return It.strConcat}});Object.defineProperty(D,"nil",{enumerable:!0,get:function(){return It.nil}});Object.defineProperty(D,"getProperty",{enumerable:!0,get:function(){return It.getProperty}});Object.defineProperty(D,"stringify",{enumerable:!0,get:function(){return It.stringify}});Object.defineProperty(D,"regexpCode",{enumerable:!0,get:function(){return It.regexpCode}});Object.defineProperty(D,"Name",{enumerable:!0,get:function(){return It.Name}});var js=rc();Object.defineProperty(D,"Scope",{enumerable:!0,get:function(){return js.Scope}});Object.defineProperty(D,"ValueScope",{enumerable:!0,get:function(){return js.ValueScope}});Object.defineProperty(D,"ValueScopeName",{enumerable:!0,get:function(){return js.ValueScopeName}});Object.defineProperty(D,"varKinds",{enumerable:!0,get:function(){return js.varKinds}});D.operators={GT:new q._Code(">"),GTE:new q._Code(">="),LT:new q._Code("<"),LTE:new q._Code("<="),EQ:new q._Code("==="),NEQ:new q._Code("!=="),NOT:new q._Code("!"),OR:new q._Code("||"),AND:new q._Code("&&"),ADD:new q._Code("+")};var mt=class{optimizeNodes(){return this}optimizeNames(t,r){return this}},nc=class extends mt{constructor(t,r,n){super(),this.varKind=t,this.name=r,this.rhs=n}render({es5:t,_n:r}){let n=t?Ye.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=xr(this.rhs,t,r)),this}get names(){return this.rhs instanceof q._CodeOrName?this.rhs.names:{}}},As=class extends mt{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 q.Name&&!t[this.lhs.str]&&!this.sideEffects))return this.rhs=xr(this.rhs,t,r),this}get names(){let t=this.lhs instanceof q.Name?{}:{...this.lhs.names};return Ns(t,this.rhs)}},oc=class extends As{constructor(t,r,n,o){super(t,n,o),this.op=r}render({_n:t}){return`${this.lhs} ${this.op}= ${this.rhs};`+t}},sc=class extends mt{constructor(t){super(),this.label=t,this.names={}}render({_n:t}){return`${this.label}:`+t}},ic=class extends mt{constructor(t){super(),this.label=t,this.names={}}render({_n:t}){return`break${this.label?` ${this.label}`:""};`+t}},ac=class extends mt{constructor(t){super(),this.error=t}render({_n:t}){return`throw ${this.error};`+t}get names(){return this.error.names}},cc=class extends mt{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=xr(this.code,t,r),this}get names(){return this.code instanceof q._CodeOrName?this.code.names:{}}},En=class extends mt{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 s=n[o];s.optimizeNames(t,r)||(sx(t,s.names),n.splice(o,1))}return n.length>0?this:void 0}get names(){return this.nodes.reduce((t,r)=>Kt(t,r.names),{})}},ht=class extends En{render(t){return"{"+t._n+super.render(t)+"}"+t._n}},uc=class extends En{},$r=class extends ht{};$r.kind="else";var Bt=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 $r(n):n}if(r)return t===!1?r instanceof e?r:r.nodes:this.nodes.length?this:new e(Oh(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=xr(this.condition,t,r),this}get names(){let t=super.names;return Ns(t,this.condition),this.else&&Kt(t,this.else.names),t}};Bt.kind="if";var Jt=class extends ht{};Jt.kind="for";var lc=class extends Jt{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=xr(this.iteration,t,r),this}get names(){return Kt(super.names,this.iteration.names)}},dc=class extends Jt{constructor(t,r,n,o){super(),this.varKind=t,this.name=r,this.from=n,this.to=o}render(t){let r=t.es5?Ye.varKinds.var:this.varKind,{name:n,from:o,to:s}=this;return`for(${r} ${n}=${o}; ${n}<${s}; ${n}++)`+super.render(t)}get names(){let t=Ns(super.names,this.from);return Ns(t,this.to)}},Cs=class extends Jt{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=xr(this.iterable,t,r),this}get names(){return Kt(super.names,this.iterable.names)}},In=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)}};In.kind="func";var Tn=class extends En{render(t){return"return "+super.render(t)}};Tn.kind="return";var fc=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&&Kt(t,this.catch.names),this.finally&&Kt(t,this.finally.names),t}},On=class extends ht{constructor(t){super(),this.error=t}render(t){return`catch(${this.error})`+super.render(t)}};On.kind="catch";var Rn=class extends ht{render(t){return"finally"+super.render(t)}};Rn.kind="finally";var pc=class{constructor(t,r={}){this._values={},this._blockStarts=[],this._constants={},this.opts={...r,_n:r.lines?`
|
|
4
|
-
`:""},this._extScope=t,this._scope=new Ye.Scope({parent:t}),this._nodes=[new uc]}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 s=this._scope.toName(r);return n!==void 0&&o&&(this._constants[s.str]=n),this._leafNode(new nc(t,s,n)),s}const(t,r,n){return this._def(Ye.varKinds.const,t,r,n)}let(t,r,n){return this._def(Ye.varKinds.let,t,r,n)}var(t,r,n){return this._def(Ye.varKinds.var,t,r,n)}assign(t,r,n){return this._leafNode(new As(t,r,n))}add(t,r){return this._leafNode(new oc(t,D.operators.ADD,r))}code(t){return typeof t=="function"?t():t!==q.nil&&this._leafNode(new cc(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,q.addCodeArg)(r,o));return r.push("}"),new q._Code(r)}if(t,r,n){if(this._blockNode(new Bt(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 Bt(t))}else(){return this._elseNode(new $r)}endIf(){return this._endBlockNode(Bt,$r)}_for(t,r){return this._blockNode(t),r&&this.code(r).endFor(),this}for(t,r){return this._for(new lc(t),r)}forRange(t,r,n,o,s=this.opts.es5?Ye.varKinds.var:Ye.varKinds.let){let i=this._scope.toName(t);return this._for(new dc(s,i,r,n),()=>o(i))}forOf(t,r,n,o=Ye.varKinds.const){let s=this._scope.toName(t);if(this.opts.es5){let i=r instanceof q.Name?r:this.var("_arr",r);return this.forRange("_i",0,(0,q._)`${i}.length`,a=>{this.var(s,(0,q._)`${i}[${a}]`),n(s)})}return this._for(new Cs("of",o,s,r),()=>n(s))}forIn(t,r,n,o=this.opts.es5?Ye.varKinds.var:Ye.varKinds.const){if(this.opts.ownProperties)return this.forOf(t,(0,q._)`Object.keys(${r})`,n);let s=this._scope.toName(t);return this._for(new Cs("in",o,s,r),()=>n(s))}endFor(){return this._endBlockNode(Jt)}label(t){return this._leafNode(new sc(t))}break(t){return this._leafNode(new ic(t))}return(t){let r=new Tn;if(this._blockNode(r),this.code(t),r.nodes.length!==1)throw new Error('CodeGen: "return" should have one node');return this._endBlockNode(Tn)}try(t,r,n){if(!r&&!n)throw new Error('CodeGen: "try" without "catch" and "finally"');let o=new fc;if(this._blockNode(o),this.code(t),r){let s=this.name("e");this._currNode=o.catch=new On(s),r(s)}return n&&(this._currNode=o.finally=new Rn,this.code(n)),this._endBlockNode(On,Rn)}throw(t){return this._leafNode(new ac(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=q.nil,n,o){return this._blockNode(new In(t,r,n)),o&&this.code(o).endFunc(),this}endFunc(){return this._endBlockNode(In)}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 Bt))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}};D.CodeGen=pc;function Kt(e,t){for(let r in t)e[r]=(e[r]||0)+(t[r]||0);return e}function Ns(e,t){return t instanceof q._CodeOrName?Kt(e,t.names):e}function xr(e,t,r){if(e instanceof q.Name)return n(e);if(!o(e))return e;return new q._Code(e._items.reduce((s,i)=>(i instanceof q.Name&&(i=n(i)),i instanceof q._Code?s.push(...i._items):s.push(i),s),[]));function n(s){let i=r[s.str];return i===void 0||t[s.str]!==1?s:(delete t[s.str],i)}function o(s){return s instanceof q._Code&&s._items.some(i=>i instanceof q.Name&&t[i.str]===1&&r[i.str]!==void 0)}}function sx(e,t){for(let r in t)e[r]=(e[r]||0)-(t[r]||0)}function Oh(e){return typeof e=="boolean"||typeof e=="number"||e===null?!e:(0,q._)`!${mc(e)}`}D.not=Oh;var ix=Rh(D.operators.AND);function ax(...e){return e.reduce(ix)}D.and=ax;var cx=Rh(D.operators.OR);function ux(...e){return e.reduce(cx)}D.or=ux;function Rh(e){return(t,r)=>t===q.nil?r:r===q.nil?t:(0,q._)`${mc(t)} ${e} ${mc(r)}`}function mc(e){return e instanceof q.Name?e:(0,q._)`(${e})`}});var F=x(Z=>{"use strict";Object.defineProperty(Z,"__esModule",{value:!0});Z.checkStrictMode=Z.getErrorPath=Z.Type=Z.useFunc=Z.setEvaluated=Z.evaluatedPropsToName=Z.mergeEvaluated=Z.eachItem=Z.unescapeJsonPointer=Z.escapeJsonPointer=Z.escapeFragment=Z.unescapeFragment=Z.schemaRefOrVal=Z.schemaHasRulesButRef=Z.schemaHasRules=Z.checkUnknownRules=Z.alwaysValidSchema=Z.toHash=void 0;var J=j(),lx=Pn();function dx(e){let t={};for(let r of e)t[r]=!0;return t}Z.toHash=dx;function fx(e,t){return typeof t=="boolean"?t:Object.keys(t).length===0?!0:(Nh(e,t),!jh(t,e.self.RULES.all))}Z.alwaysValidSchema=fx;function Nh(e,t=e.schema){let{opts:r,self:n}=e;if(!r.strictSchema||typeof t=="boolean")return;let o=n.RULES.keywords;for(let s in t)o[s]||Mh(e,`unknown keyword: "${s}"`)}Z.checkUnknownRules=Nh;function jh(e,t){if(typeof e=="boolean")return!e;for(let r in e)if(t[r])return!0;return!1}Z.schemaHasRules=jh;function px(e,t){if(typeof e=="boolean")return!e;for(let r in e)if(r!=="$ref"&&t.all[r])return!0;return!1}Z.schemaHasRulesButRef=px;function mx({topSchemaRef:e,schemaPath:t},r,n,o){if(!o){if(typeof r=="number"||typeof r=="boolean")return r;if(typeof r=="string")return(0,J._)`${r}`}return(0,J._)`${e}${t}${(0,J.getProperty)(n)}`}Z.schemaRefOrVal=mx;function hx(e){return Dh(decodeURIComponent(e))}Z.unescapeFragment=hx;function gx(e){return encodeURIComponent(gc(e))}Z.escapeFragment=gx;function gc(e){return typeof e=="number"?`${e}`:e.replace(/~/g,"~0").replace(/\//g,"~1")}Z.escapeJsonPointer=gc;function Dh(e){return e.replace(/~1/g,"/").replace(/~0/g,"~")}Z.unescapeJsonPointer=Dh;function yx(e,t){if(Array.isArray(e))for(let r of e)t(r);else t(e)}Z.eachItem=yx;function Ah({mergeNames:e,mergeToName:t,mergeValues:r,resultToName:n}){return(o,s,i,a)=>{let c=i===void 0?s:i instanceof J.Name?(s instanceof J.Name?e(o,s,i):t(o,s,i),i):s instanceof J.Name?(t(o,i,s),s):r(s,i);return a===J.Name&&!(c instanceof J.Name)?n(o,c):c}}Z.mergeEvaluated={props:Ah({mergeNames:(e,t,r)=>e.if((0,J._)`${r} !== true && ${t} !== undefined`,()=>{e.if((0,J._)`${t} === true`,()=>e.assign(r,!0),()=>e.assign(r,(0,J._)`${r} || {}`).code((0,J._)`Object.assign(${r}, ${t})`))}),mergeToName:(e,t,r)=>e.if((0,J._)`${r} !== true`,()=>{t===!0?e.assign(r,!0):(e.assign(r,(0,J._)`${r} || {}`),yc(e,r,t))}),mergeValues:(e,t)=>e===!0?!0:{...e,...t},resultToName:Zh}),items:Ah({mergeNames:(e,t,r)=>e.if((0,J._)`${r} !== true && ${t} !== undefined`,()=>e.assign(r,(0,J._)`${t} === true ? true : ${r} > ${t} ? ${r} : ${t}`)),mergeToName:(e,t,r)=>e.if((0,J._)`${r} !== true`,()=>e.assign(r,t===!0?!0:(0,J._)`${r} > ${t} ? ${r} : ${t}`)),mergeValues:(e,t)=>e===!0?!0:Math.max(e,t),resultToName:(e,t)=>e.var("items",t)})};function Zh(e,t){if(t===!0)return e.var("props",!0);let r=e.var("props",(0,J._)`{}`);return t!==void 0&&yc(e,r,t),r}Z.evaluatedPropsToName=Zh;function yc(e,t,r){Object.keys(r).forEach(n=>e.assign((0,J._)`${t}${(0,J.getProperty)(n)}`,!0))}Z.setEvaluated=yc;var Ch={};function _x(e,t){return e.scopeValue("func",{ref:t,code:Ch[t.code]||(Ch[t.code]=new lx._Code(t.code))})}Z.useFunc=_x;var hc;(function(e){e[e.Num=0]="Num",e[e.Str=1]="Str"})(hc||(Z.Type=hc={}));function wx(e,t,r){if(e instanceof J.Name){let n=t===hc.Num;return r?n?(0,J._)`"[" + ${e} + "]"`:(0,J._)`"['" + ${e} + "']"`:n?(0,J._)`"/" + ${e}`:(0,J._)`"/" + ${e}.replace(/~/g, "~0").replace(/\\//g, "~1")`}return r?(0,J.getProperty)(e).toString():"/"+gc(e)}Z.getErrorPath=wx;function Mh(e,t,r=e.opts.strictSchema){if(r){if(t=`strict mode: ${t}`,r===!0)throw new Error(t);e.self.logger.warn(t)}}Z.checkStrictMode=Mh});var gt=x(_c=>{"use strict";Object.defineProperty(_c,"__esModule",{value:!0});var ge=j(),bx={data:new ge.Name("data"),valCxt:new ge.Name("valCxt"),instancePath:new ge.Name("instancePath"),parentData:new ge.Name("parentData"),parentDataProperty:new ge.Name("parentDataProperty"),rootData:new ge.Name("rootData"),dynamicAnchors:new ge.Name("dynamicAnchors"),vErrors:new ge.Name("vErrors"),errors:new ge.Name("errors"),this:new ge.Name("this"),self:new ge.Name("self"),scope:new ge.Name("scope"),json:new ge.Name("json"),jsonPos:new ge.Name("jsonPos"),jsonLen:new ge.Name("jsonLen"),jsonPart:new ge.Name("jsonPart")};_c.default=bx});var An=x(ye=>{"use strict";Object.defineProperty(ye,"__esModule",{value:!0});ye.extendErrors=ye.resetErrorsCount=ye.reportExtraError=ye.reportError=ye.keyword$DataError=ye.keywordError=void 0;var L=j(),Ds=F(),$e=gt();ye.keywordError={message:({keyword:e})=>(0,L.str)`must pass "${e}" keyword validation`};ye.keyword$DataError={message:({keyword:e,schemaType:t})=>t?(0,L.str)`"${e}" keyword must be ${t} ($data)`:(0,L.str)`"${e}" keyword is invalid ($data)`};function vx(e,t=ye.keywordError,r,n){let{it:o}=e,{gen:s,compositeRule:i,allErrors:a}=o,c=Lh(e,t,r);n??(i||a)?qh(s,c):Fh(o,(0,L._)`[${c}]`)}ye.reportError=vx;function $x(e,t=ye.keywordError,r){let{it:n}=e,{gen:o,compositeRule:s,allErrors:i}=n,a=Lh(e,t,r);qh(o,a),s||i||Fh(n,$e.default.vErrors)}ye.reportExtraError=$x;function xx(e,t){e.assign($e.default.errors,t),e.if((0,L._)`${$e.default.vErrors} !== null`,()=>e.if(t,()=>e.assign((0,L._)`${$e.default.vErrors}.length`,t),()=>e.assign($e.default.vErrors,null)))}ye.resetErrorsCount=xx;function Sx({gen:e,keyword:t,schemaValue:r,data:n,errsCount:o,it:s}){if(o===void 0)throw new Error("ajv implementation error");let i=e.name("err");e.forRange("i",o,$e.default.errors,a=>{e.const(i,(0,L._)`${$e.default.vErrors}[${a}]`),e.if((0,L._)`${i}.instancePath === undefined`,()=>e.assign((0,L._)`${i}.instancePath`,(0,L.strConcat)($e.default.instancePath,s.errorPath))),e.assign((0,L._)`${i}.schemaPath`,(0,L.str)`${s.errSchemaPath}/${t}`),s.opts.verbose&&(e.assign((0,L._)`${i}.schema`,r),e.assign((0,L._)`${i}.data`,n))})}ye.extendErrors=Sx;function qh(e,t){let r=e.const("err",t);e.if((0,L._)`${$e.default.vErrors} === null`,()=>e.assign($e.default.vErrors,(0,L._)`[${r}]`),(0,L._)`${$e.default.vErrors}.push(${r})`),e.code((0,L._)`${$e.default.errors}++`)}function Fh(e,t){let{gen:r,validateName:n,schemaEnv:o}=e;o.$async?r.throw((0,L._)`new ${e.ValidationError}(${t})`):(r.assign((0,L._)`${n}.errors`,t),r.return(!1))}var Gt={keyword:new L.Name("keyword"),schemaPath:new L.Name("schemaPath"),params:new L.Name("params"),propertyName:new L.Name("propertyName"),message:new L.Name("message"),schema:new L.Name("schema"),parentSchema:new L.Name("parentSchema")};function Lh(e,t,r){let{createErrors:n}=e.it;return n===!1?(0,L._)`{}`:kx(e,t,r)}function kx(e,t,r={}){let{gen:n,it:o}=e,s=[zx(o,r),Px(e,r)];return Ex(e,t,s),n.object(...s)}function zx({errorPath:e},{instancePath:t}){let r=t?(0,L.str)`${e}${(0,Ds.getErrorPath)(t,Ds.Type.Str)}`:e;return[$e.default.instancePath,(0,L.strConcat)($e.default.instancePath,r)]}function Px({keyword:e,it:{errSchemaPath:t}},{schemaPath:r,parentSchema:n}){let o=n?t:(0,L.str)`${t}/${e}`;return r&&(o=(0,L.str)`${o}${(0,Ds.getErrorPath)(r,Ds.Type.Str)}`),[Gt.schemaPath,o]}function Ex(e,{params:t,message:r},n){let{keyword:o,data:s,schemaValue:i,it:a}=e,{opts:c,propertyName:u,topSchemaRef:l,schemaPath:d}=a;n.push([Gt.keyword,o],[Gt.params,typeof t=="function"?t(e):t||(0,L._)`{}`]),c.messages&&n.push([Gt.message,typeof r=="function"?r(e):r]),c.verbose&&n.push([Gt.schema,i],[Gt.parentSchema,(0,L._)`${l}${d}`],[$e.default.data,s]),u&&n.push([Gt.propertyName,u])}});var Vh=x(Sr=>{"use strict";Object.defineProperty(Sr,"__esModule",{value:!0});Sr.boolOrEmptySchema=Sr.topBoolOrEmptySchema=void 0;var Ix=An(),Tx=j(),Ox=gt(),Rx={message:"boolean schema is false"};function Ax(e){let{gen:t,schema:r,validateName:n}=e;r===!1?Uh(e,!1):typeof r=="object"&&r.$async===!0?t.return(Ox.default.data):(t.assign((0,Tx._)`${n}.errors`,null),t.return(!0))}Sr.topBoolOrEmptySchema=Ax;function Cx(e,t){let{gen:r,schema:n}=e;n===!1?(r.var(t,!1),Uh(e)):r.var(t,!0)}Sr.boolOrEmptySchema=Cx;function Uh(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,Ix.reportError)(o,Rx,void 0,t)}});var wc=x(kr=>{"use strict";Object.defineProperty(kr,"__esModule",{value:!0});kr.getRules=kr.isJSONType=void 0;var Nx=["string","number","integer","boolean","null","object","array"],jx=new Set(Nx);function Dx(e){return typeof e=="string"&&jx.has(e)}kr.isJSONType=Dx;function Zx(){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:{}}}kr.getRules=Zx});var bc=x(Tt=>{"use strict";Object.defineProperty(Tt,"__esModule",{value:!0});Tt.shouldUseRule=Tt.shouldUseGroup=Tt.schemaHasRulesForType=void 0;function Mx({schema:e,self:t},r){let n=t.RULES.types[r];return n&&n!==!0&&Hh(e,n)}Tt.schemaHasRulesForType=Mx;function Hh(e,t){return t.rules.some(r=>Bh(e,r))}Tt.shouldUseGroup=Hh;function Bh(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))}Tt.shouldUseRule=Bh});var Cn=x(_e=>{"use strict";Object.defineProperty(_e,"__esModule",{value:!0});_e.reportTypeError=_e.checkDataTypes=_e.checkDataType=_e.coerceAndCheckDataType=_e.getJSONTypes=_e.getSchemaTypes=_e.DataType=void 0;var qx=wc(),Fx=bc(),Lx=An(),C=j(),Jh=F(),zr;(function(e){e[e.Correct=0]="Correct",e[e.Wrong=1]="Wrong"})(zr||(_e.DataType=zr={}));function Ux(e){let t=Kh(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}_e.getSchemaTypes=Ux;function Kh(e){let t=Array.isArray(e)?e:e?[e]:[];if(t.every(qx.isJSONType))return t;throw new Error("type must be JSONType or JSONType[]: "+t.join(","))}_e.getJSONTypes=Kh;function Vx(e,t){let{gen:r,data:n,opts:o}=e,s=Hx(t,o.coerceTypes),i=t.length>0&&!(s.length===0&&t.length===1&&(0,Fx.schemaHasRulesForType)(e,t[0]));if(i){let a=$c(t,n,o.strictNumbers,zr.Wrong);r.if(a,()=>{s.length?Bx(e,t,s):xc(e)})}return i}_e.coerceAndCheckDataType=Vx;var Gh=new Set(["string","number","integer","boolean","null"]);function Hx(e,t){return t?e.filter(r=>Gh.has(r)||t==="array"&&r==="array"):[]}function Bx(e,t,r){let{gen:n,data:o,opts:s}=e,i=n.let("dataType",(0,C._)`typeof ${o}`),a=n.let("coerced",(0,C._)`undefined`);s.coerceTypes==="array"&&n.if((0,C._)`${i} == 'object' && Array.isArray(${o}) && ${o}.length == 1`,()=>n.assign(o,(0,C._)`${o}[0]`).assign(i,(0,C._)`typeof ${o}`).if($c(t,o,s.strictNumbers),()=>n.assign(a,o))),n.if((0,C._)`${a} !== undefined`);for(let u of r)(Gh.has(u)||u==="array"&&s.coerceTypes==="array")&&c(u);n.else(),xc(e),n.endIf(),n.if((0,C._)`${a} !== undefined`,()=>{n.assign(o,a),Jx(e,a)});function c(u){switch(u){case"string":n.elseIf((0,C._)`${i} == "number" || ${i} == "boolean"`).assign(a,(0,C._)`"" + ${o}`).elseIf((0,C._)`${o} === null`).assign(a,(0,C._)`""`);return;case"number":n.elseIf((0,C._)`${i} == "boolean" || ${o} === null
|
|
5
|
-
|| (${i} == "string" && ${o} && ${o} == +${o})`).assign(a,(0,
|
|
6
|
-
|| (${i} === "string" && ${o} && ${o} == +${o} && !(${o} % 1))`).assign(a,(0,
|
|
7
|
-
|| ${i} === "boolean" || ${o} === null`).assign(a,(0,C._)`[${o}]`)}}}function Jx({gen:e,parentData:t,parentDataProperty:r},n){e.if((0,C._)`${t} !== undefined`,()=>e.assign((0,C._)`${t}[${r}]`,n))}function vc(e,t,r,n=zr.Correct){let o=n===zr.Correct?C.operators.EQ:C.operators.NEQ,s;switch(e){case"null":return(0,C._)`${t} ${o} null`;case"array":s=(0,C._)`Array.isArray(${t})`;break;case"object":s=(0,C._)`${t} && typeof ${t} == "object" && !Array.isArray(${t})`;break;case"integer":s=i((0,C._)`!(${t} % 1) && !isNaN(${t})`);break;case"number":s=i();break;default:return(0,C._)`typeof ${t} ${o} ${e}`}return n===zr.Correct?s:(0,C.not)(s);function i(a=C.nil){return(0,C.and)((0,C._)`typeof ${t} == "number"`,a,r?(0,C._)`isFinite(${t})`:C.nil)}}_e.checkDataType=vc;function $c(e,t,r,n){if(e.length===1)return vc(e[0],t,r,n);let o,s=(0,Jh.toHash)(e);if(s.array&&s.object){let i=(0,C._)`typeof ${t} != "object"`;o=s.null?i:(0,C._)`!${t} || ${i}`,delete s.null,delete s.array,delete s.object}else o=C.nil;s.number&&delete s.integer;for(let i in s)o=(0,C.and)(o,vc(i,t,r,n));return o}_e.checkDataTypes=$c;var Kx={message:({schema:e})=>`must be ${e}`,params:({schema:e,schemaValue:t})=>typeof e=="string"?(0,C._)`{type: ${e}}`:(0,C._)`{type: ${t}}`};function xc(e){let t=Gx(e);(0,Lx.reportError)(t,Kx)}_e.reportTypeError=xc;function Gx(e){let{gen:t,data:r,schema:n}=e,o=(0,Jh.schemaRefOrVal)(e,n,"type");return{gen:t,keyword:"type",data:r,schema:n.type,schemaCode:o,schemaValue:o,parentSchema:n,params:{},it:e}}});var Yh=x(Zs=>{"use strict";Object.defineProperty(Zs,"__esModule",{value:!0});Zs.assignDefaults=void 0;var Pr=j(),Wx=F();function Yx(e,t){let{properties:r,items:n}=e.schema;if(t==="object"&&r)for(let o in r)Wh(e,o,r[o].default);else t==="array"&&Array.isArray(n)&&n.forEach((o,s)=>Wh(e,s,o.default))}Zs.assignDefaults=Yx;function Wh(e,t,r){let{gen:n,compositeRule:o,data:s,opts:i}=e;if(r===void 0)return;let a=(0,Pr._)`${s}${(0,Pr.getProperty)(t)}`;if(o){(0,Wx.checkStrictMode)(e,`default is ignored for: ${a}`);return}let c=(0,Pr._)`${a} === undefined`;i.useDefaults==="empty"&&(c=(0,Pr._)`${c} || ${a} === null || ${a} === ""`),n.if(c,(0,Pr._)`${a} = ${(0,Pr.stringify)(r)}`)}});var Ue=x(B=>{"use strict";Object.defineProperty(B,"__esModule",{value:!0});B.validateUnion=B.validateArray=B.usePattern=B.callValidateCode=B.schemaProperties=B.allSchemaProperties=B.noPropertyInData=B.propertyInData=B.isOwnProperty=B.hasPropFunc=B.reportMissingProp=B.checkMissingProp=B.checkReportMissingProp=void 0;var X=j(),Sc=F(),Ot=gt(),Xx=F();function Qx(e,t){let{gen:r,data:n,it:o}=e;r.if(zc(r,n,t,o.opts.ownProperties),()=>{e.setParams({missingProperty:(0,X._)`${t}`},!0),e.error()})}B.checkReportMissingProp=Qx;function eS({gen:e,data:t,it:{opts:r}},n,o){return(0,X.or)(...n.map(s=>(0,X.and)(zc(e,t,s,r.ownProperties),(0,X._)`${o} = ${s}`)))}B.checkMissingProp=eS;function tS(e,t){e.setParams({missingProperty:t},!0),e.error()}B.reportMissingProp=tS;function Xh(e){return e.scopeValue("func",{ref:Object.prototype.hasOwnProperty,code:(0,X._)`Object.prototype.hasOwnProperty`})}B.hasPropFunc=Xh;function kc(e,t,r){return(0,X._)`${Xh(e)}.call(${t}, ${r})`}B.isOwnProperty=kc;function rS(e,t,r,n){let o=(0,X._)`${t}${(0,X.getProperty)(r)} !== undefined`;return n?(0,X._)`${o} && ${kc(e,t,r)}`:o}B.propertyInData=rS;function zc(e,t,r,n){let o=(0,X._)`${t}${(0,X.getProperty)(r)} === undefined`;return n?(0,X.or)(o,(0,X.not)(kc(e,t,r))):o}B.noPropertyInData=zc;function Qh(e){return e?Object.keys(e).filter(t=>t!=="__proto__"):[]}B.allSchemaProperties=Qh;function nS(e,t){return Qh(t).filter(r=>!(0,Sc.alwaysValidSchema)(e,t[r]))}B.schemaProperties=nS;function oS({schemaCode:e,data:t,it:{gen:r,topSchemaRef:n,schemaPath:o,errorPath:s},it:i},a,c,u){let l=u?(0,X._)`${e}, ${t}, ${n}${o}`:t,d=[[Ot.default.instancePath,(0,X.strConcat)(Ot.default.instancePath,s)],[Ot.default.parentData,i.parentData],[Ot.default.parentDataProperty,i.parentDataProperty],[Ot.default.rootData,Ot.default.rootData]];i.opts.dynamicRef&&d.push([Ot.default.dynamicAnchors,Ot.default.dynamicAnchors]);let f=(0,X._)`${l}, ${r.object(...d)}`;return c!==X.nil?(0,X._)`${a}.call(${c}, ${f})`:(0,X._)`${a}(${f})`}B.callValidateCode=oS;var sS=(0,X._)`new RegExp`;function iS({gen:e,it:{opts:t}},r){let n=t.unicodeRegExp?"u":"",{regExp:o}=t.code,s=o(r,n);return e.scopeValue("pattern",{key:s.toString(),ref:s,code:(0,X._)`${o.code==="new RegExp"?sS:(0,Xx.useFunc)(e,o)}(${r}, ${n})`})}B.usePattern=iS;function aS(e){let{gen:t,data:r,keyword:n,it:o}=e,s=t.name("valid");if(o.allErrors){let a=t.let("valid",!0);return i(()=>t.assign(a,!1)),a}return t.var(s,!0),i(()=>t.break()),s;function i(a){let c=t.const("len",(0,X._)`${r}.length`);t.forRange("i",0,c,u=>{e.subschema({keyword:n,dataProp:u,dataPropType:Sc.Type.Num},s),t.if((0,X.not)(s),a)})}}B.validateArray=aS;function cS(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,Sc.alwaysValidSchema)(o,c))&&!o.opts.unevaluated)return;let i=t.let("valid",!1),a=t.name("_valid");t.block(()=>r.forEach((c,u)=>{let l=e.subschema({keyword:n,schemaProp:u,compositeRule:!0},a);t.assign(i,(0,X._)`${i} || ${a}`),e.mergeValidEvaluated(l,a)||t.if((0,X.not)(i))})),e.result(i,()=>e.reset(),()=>e.error(!0))}B.validateUnion=cS});var rg=x(rt=>{"use strict";Object.defineProperty(rt,"__esModule",{value:!0});rt.validateKeywordUsage=rt.validSchemaType=rt.funcKeywordCode=rt.macroKeywordCode=void 0;var xe=j(),Wt=gt(),uS=Ue(),lS=An();function dS(e,t){let{gen:r,keyword:n,schema:o,parentSchema:s,it:i}=e,a=t.macro.call(i.self,o,s,i),c=tg(r,n,a);i.opts.validateSchema!==!1&&i.self.validateSchema(a,!0);let u=r.name("valid");e.subschema({schema:a,schemaPath:xe.nil,errSchemaPath:`${i.errSchemaPath}/${n}`,topSchemaRef:c,compositeRule:!0},u),e.pass(u,()=>e.error(!0))}rt.macroKeywordCode=dS;function fS(e,t){var r;let{gen:n,keyword:o,schema:s,parentSchema:i,$data:a,it:c}=e;mS(c,t);let u=!a&&t.compile?t.compile.call(c.self,s,i,c):t.validate,l=tg(n,o,u),d=n.let("valid");e.block$data(d,f),e.ok((r=t.valid)!==null&&r!==void 0?r:d);function f(){if(t.errors===!1)h(),t.modifying&&eg(e),g(()=>e.error());else{let w=t.async?p():m();t.modifying&&eg(e),g(()=>pS(e,w))}}function p(){let w=n.let("ruleErrs",null);return n.try(()=>h((0,xe._)`await `),v=>n.assign(d,!1).if((0,xe._)`${v} instanceof ${c.ValidationError}`,()=>n.assign(w,(0,xe._)`${v}.errors`),()=>n.throw(v))),w}function m(){let w=(0,xe._)`${l}.errors`;return n.assign(w,null),h(xe.nil),w}function h(w=t.async?(0,xe._)`await `:xe.nil){let v=c.opts.passContext?Wt.default.this:Wt.default.self,$=!("compile"in t&&!a||t.schema===!1);n.assign(d,(0,xe._)`${w}${(0,uS.callValidateCode)(e,l,v,$)}`,t.modifying)}function g(w){var v;n.if((0,xe.not)((v=t.valid)!==null&&v!==void 0?v:d),w)}}rt.funcKeywordCode=fS;function eg(e){let{gen:t,data:r,it:n}=e;t.if(n.parentData,()=>t.assign(r,(0,xe._)`${n.parentData}[${n.parentDataProperty}]`))}function pS(e,t){let{gen:r}=e;r.if((0,xe._)`Array.isArray(${t})`,()=>{r.assign(Wt.default.vErrors,(0,xe._)`${Wt.default.vErrors} === null ? ${t} : ${Wt.default.vErrors}.concat(${t})`).assign(Wt.default.errors,(0,xe._)`${Wt.default.vErrors}.length`),(0,lS.extendErrors)(e)},()=>e.error())}function mS({schemaEnv:e},t){if(t.async&&!e.$async)throw new Error("async keyword in sync schema")}function tg(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,xe.stringify)(r)})}function hS(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")}rt.validSchemaType=hS;function gS({schema:e,opts:t,self:r,errSchemaPath:n},o,s){if(Array.isArray(o.keyword)?!o.keyword.includes(s):o.keyword!==s)throw new Error("ajv implementation error");let i=o.dependencies;if(i?.some(a=>!Object.prototype.hasOwnProperty.call(e,a)))throw new Error(`parent schema must have dependencies of ${s}: ${i.join(",")}`);if(o.validateSchema&&!o.validateSchema(e[s])){let c=`keyword "${s}" value is invalid at path "${n}": `+r.errorsText(o.validateSchema.errors);if(t.validateSchema==="log")r.logger.error(c);else throw new Error(c)}}rt.validateKeywordUsage=gS});var og=x(Rt=>{"use strict";Object.defineProperty(Rt,"__esModule",{value:!0});Rt.extendSubschemaMode=Rt.extendSubschemaData=Rt.getSubschema=void 0;var nt=j(),ng=F();function yS(e,{keyword:t,schemaProp:r,schema:n,schemaPath:o,errSchemaPath:s,topSchemaRef:i}){if(t!==void 0&&n!==void 0)throw new Error('both "keyword" and "schema" passed, only one allowed');if(t!==void 0){let a=e.schema[t];return r===void 0?{schema:a,schemaPath:(0,nt._)`${e.schemaPath}${(0,nt.getProperty)(t)}`,errSchemaPath:`${e.errSchemaPath}/${t}`}:{schema:a[r],schemaPath:(0,nt._)`${e.schemaPath}${(0,nt.getProperty)(t)}${(0,nt.getProperty)(r)}`,errSchemaPath:`${e.errSchemaPath}/${t}/${(0,ng.escapeFragment)(r)}`}}if(n!==void 0){if(o===void 0||s===void 0||i===void 0)throw new Error('"schemaPath", "errSchemaPath" and "topSchemaRef" are required with "schema"');return{schema:n,schemaPath:o,topSchemaRef:i,errSchemaPath:s}}throw new Error('either "keyword" or "schema" must be passed')}Rt.getSubschema=yS;function _S(e,t,{dataProp:r,dataPropType:n,data:o,dataTypes:s,propertyName:i}){if(o!==void 0&&r!==void 0)throw new Error('both "data" and "dataProp" passed, only one allowed');let{gen:a}=t;if(r!==void 0){let{errorPath:u,dataPathArr:l,opts:d}=t,f=a.let("data",(0,nt._)`${t.data}${(0,nt.getProperty)(r)}`,!0);c(f),e.errorPath=(0,nt.str)`${u}${(0,ng.getErrorPath)(r,n,d.jsPropertySyntax)}`,e.parentDataProperty=(0,nt._)`${r}`,e.dataPathArr=[...l,e.parentDataProperty]}if(o!==void 0){let u=o instanceof nt.Name?o:a.let("data",o,!0);c(u),i!==void 0&&(e.propertyName=i)}s&&(e.dataTypes=s);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]}}Rt.extendSubschemaData=_S;function wS(e,{jtdDiscriminator:t,jtdMetadata:r,compositeRule:n,createErrors:o,allErrors:s}){n!==void 0&&(e.compositeRule=n),o!==void 0&&(e.createErrors=o),s!==void 0&&(e.allErrors=s),e.jtdDiscriminator=t,e.jtdMetadata=r}Rt.extendSubschemaMode=wS});var Pc=x((yj,sg)=>{"use strict";sg.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,s;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(s=Object.keys(t),n=s.length,n!==Object.keys(r).length)return!1;for(o=n;o--!==0;)if(!Object.prototype.hasOwnProperty.call(r,s[o]))return!1;for(o=n;o--!==0;){var i=s[o];if(!e(t[i],r[i]))return!1}return!0}return t!==t&&r!==r}});var ag=x((_j,ig)=>{"use strict";var At=ig.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(){};Ms(t,n,o,e,"",e)};At.keywords={additionalItems:!0,items:!0,contains:!0,additionalProperties:!0,propertyNames:!0,not:!0,if:!0,then:!0,else:!0};At.arrayKeywords={items:!0,allOf:!0,anyOf:!0,oneOf:!0};At.propsKeywords={$defs:!0,definitions:!0,properties:!0,patternProperties:!0,dependencies:!0};At.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 Ms(e,t,r,n,o,s,i,a,c,u){if(n&&typeof n=="object"&&!Array.isArray(n)){t(n,o,s,i,a,c,u);for(var l in n){var d=n[l];if(Array.isArray(d)){if(l in At.arrayKeywords)for(var f=0;f<d.length;f++)Ms(e,t,r,d[f],o+"/"+l+"/"+f,s,o,l,n,f)}else if(l in At.propsKeywords){if(d&&typeof d=="object")for(var p in d)Ms(e,t,r,d[p],o+"/"+l+"/"+bS(p),s,o,l,n,p)}else(l in At.keywords||e.allKeys&&!(l in At.skipKeywords))&&Ms(e,t,r,d,o+"/"+l,s,o,l,n)}r(n,o,s,i,a,c,u)}}function bS(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}});var Nn=x(Ie=>{"use strict";Object.defineProperty(Ie,"__esModule",{value:!0});Ie.getSchemaRefs=Ie.resolveUrl=Ie.normalizeId=Ie._getFullPath=Ie.getFullPath=Ie.inlineRef=void 0;var vS=F(),$S=Pc(),xS=ag(),SS=new Set(["type","format","pattern","maxLength","minLength","maxProperties","minProperties","maxItems","minItems","maximum","minimum","uniqueItems","multipleOf","required","enum","const"]);function kS(e,t=!0){return typeof e=="boolean"?!0:t===!0?!Ec(e):t?cg(e)<=t:!1}Ie.inlineRef=kS;var zS=new Set(["$ref","$recursiveRef","$recursiveAnchor","$dynamicRef","$dynamicAnchor"]);function Ec(e){for(let t in e){if(zS.has(t))return!0;let r=e[t];if(Array.isArray(r)&&r.some(Ec)||typeof r=="object"&&Ec(r))return!0}return!1}function cg(e){let t=0;for(let r in e){if(r==="$ref")return 1/0;if(t++,!SS.has(r)&&(typeof e[r]=="object"&&(0,vS.eachItem)(e[r],n=>t+=cg(n)),t===1/0))return 1/0}return t}function ug(e,t="",r){r!==!1&&(t=Er(t));let n=e.parse(t);return lg(e,n)}Ie.getFullPath=ug;function lg(e,t){return e.serialize(t).split("#")[0]+"#"}Ie._getFullPath=lg;var PS=/#\/?$/;function Er(e){return e?e.replace(PS,""):""}Ie.normalizeId=Er;function ES(e,t,r){return r=Er(r),e.resolve(t,r)}Ie.resolveUrl=ES;var IS=/^[a-z_][-a-z0-9._]*$/i;function TS(e,t){if(typeof e=="boolean")return{};let{schemaId:r,uriResolver:n}=this.opts,o=Er(e[r]||t),s={"":o},i=ug(n,o,!1),a={},c=new Set;return xS(e,{allKeys:!0},(d,f,p,m)=>{if(m===void 0)return;let h=i+f,g=s[m];typeof d[r]=="string"&&(g=w.call(this,d[r])),v.call(this,d.$anchor),v.call(this,d.$dynamicAnchor),s[f]=g;function w($){let O=this.opts.uriResolver.resolve;if($=Er(g?O(g,$):$),c.has($))throw l($);c.add($);let k=this.refs[$];return typeof k=="string"&&(k=this.refs[k]),typeof k=="object"?u(d,k.schema,$):$!==Er(h)&&($[0]==="#"?(u(d,a[$],$),a[$]=d):this.refs[$]=h),$}function v($){if(typeof $=="string"){if(!IS.test($))throw new Error(`invalid anchor "${$}"`);w.call(this,`#${$}`)}}}),a;function u(d,f,p){if(f!==void 0&&!$S(d,f))throw l(p)}function l(d){return new Error(`reference "${d}" resolves to more than one schema`)}}Ie.getSchemaRefs=TS});var Zn=x(Ct=>{"use strict";Object.defineProperty(Ct,"__esModule",{value:!0});Ct.getData=Ct.KeywordCxt=Ct.validateFunctionCode=void 0;var hg=Vh(),dg=Cn(),Tc=bc(),qs=Cn(),OS=Yh(),Dn=rg(),Ic=og(),P=j(),R=gt(),RS=Nn(),yt=F(),jn=An();function AS(e){if(_g(e)&&(wg(e),yg(e))){jS(e);return}gg(e,()=>(0,hg.topBoolOrEmptySchema)(e))}Ct.validateFunctionCode=AS;function gg({gen:e,validateName:t,schema:r,schemaEnv:n,opts:o},s){o.code.es5?e.func(t,(0,P._)`${R.default.data}, ${R.default.valCxt}`,n.$async,()=>{e.code((0,P._)`"use strict"; ${fg(r,o)}`),NS(e,o),e.code(s)}):e.func(t,(0,P._)`${R.default.data}, ${CS(o)}`,n.$async,()=>e.code(fg(r,o)).code(s))}function CS(e){return(0,P._)`{${R.default.instancePath}="", ${R.default.parentData}, ${R.default.parentDataProperty}, ${R.default.rootData}=${R.default.data}${e.dynamicRef?(0,P._)`, ${R.default.dynamicAnchors}={}`:P.nil}}={}`}function NS(e,t){e.if(R.default.valCxt,()=>{e.var(R.default.instancePath,(0,P._)`${R.default.valCxt}.${R.default.instancePath}`),e.var(R.default.parentData,(0,P._)`${R.default.valCxt}.${R.default.parentData}`),e.var(R.default.parentDataProperty,(0,P._)`${R.default.valCxt}.${R.default.parentDataProperty}`),e.var(R.default.rootData,(0,P._)`${R.default.valCxt}.${R.default.rootData}`),t.dynamicRef&&e.var(R.default.dynamicAnchors,(0,P._)`${R.default.valCxt}.${R.default.dynamicAnchors}`)},()=>{e.var(R.default.instancePath,(0,P._)`""`),e.var(R.default.parentData,(0,P._)`undefined`),e.var(R.default.parentDataProperty,(0,P._)`undefined`),e.var(R.default.rootData,R.default.data),t.dynamicRef&&e.var(R.default.dynamicAnchors,(0,P._)`{}`)})}function jS(e){let{schema:t,opts:r,gen:n}=e;gg(e,()=>{r.$comment&&t.$comment&&vg(e),FS(e),n.let(R.default.vErrors,null),n.let(R.default.errors,0),r.unevaluated&&DS(e),bg(e),VS(e)})}function DS(e){let{gen:t,validateName:r}=e;e.evaluated=t.const("evaluated",(0,P._)`${r}.evaluated`),t.if((0,P._)`${e.evaluated}.dynamicProps`,()=>t.assign((0,P._)`${e.evaluated}.props`,(0,P._)`undefined`)),t.if((0,P._)`${e.evaluated}.dynamicItems`,()=>t.assign((0,P._)`${e.evaluated}.items`,(0,P._)`undefined`))}function fg(e,t){let r=typeof e=="object"&&e[t.schemaId];return r&&(t.code.source||t.code.process)?(0,P._)`/*# sourceURL=${r} */`:P.nil}function ZS(e,t){if(_g(e)&&(wg(e),yg(e))){MS(e,t);return}(0,hg.boolOrEmptySchema)(e,t)}function yg({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 _g(e){return typeof e.schema!="boolean"}function MS(e,t){let{schema:r,gen:n,opts:o}=e;o.$comment&&r.$comment&&vg(e),LS(e),US(e);let s=n.const("_errs",R.default.errors);bg(e,s),n.var(t,(0,P._)`${s} === ${R.default.errors}`)}function wg(e){(0,yt.checkUnknownRules)(e),qS(e)}function bg(e,t){if(e.opts.jtd)return pg(e,[],!1,t);let r=(0,dg.getSchemaTypes)(e.schema),n=(0,dg.coerceAndCheckDataType)(e,r);pg(e,r,!n,t)}function qS(e){let{schema:t,errSchemaPath:r,opts:n,self:o}=e;t.$ref&&n.ignoreKeywordsWithRef&&(0,yt.schemaHasRulesButRef)(t,o.RULES)&&o.logger.warn(`$ref: keywords ignored in schema at path "${r}"`)}function FS(e){let{schema:t,opts:r}=e;t.default!==void 0&&r.useDefaults&&r.strictSchema&&(0,yt.checkStrictMode)(e,"default is ignored in the schema root")}function LS(e){let t=e.schema[e.opts.schemaId];t&&(e.baseId=(0,RS.resolveUrl)(e.opts.uriResolver,e.baseId,t))}function US(e){if(e.schema.$async&&!e.schemaEnv.$async)throw new Error("async schema in sync schema")}function vg({gen:e,schemaEnv:t,schema:r,errSchemaPath:n,opts:o}){let s=r.$comment;if(o.$comment===!0)e.code((0,P._)`${R.default.self}.logger.log(${s})`);else if(typeof o.$comment=="function"){let i=(0,P.str)`${n}/$comment`,a=e.scopeValue("root",{ref:t.root});e.code((0,P._)`${R.default.self}.opts.$comment(${s}, ${i}, ${a}.schema)`)}}function VS(e){let{gen:t,schemaEnv:r,validateName:n,ValidationError:o,opts:s}=e;r.$async?t.if((0,P._)`${R.default.errors} === 0`,()=>t.return(R.default.data),()=>t.throw((0,P._)`new ${o}(${R.default.vErrors})`)):(t.assign((0,P._)`${n}.errors`,R.default.vErrors),s.unevaluated&&HS(e),t.return((0,P._)`${R.default.errors} === 0`))}function HS({gen:e,evaluated:t,props:r,items:n}){r instanceof P.Name&&e.assign((0,P._)`${t}.props`,r),n instanceof P.Name&&e.assign((0,P._)`${t}.items`,n)}function pg(e,t,r,n){let{gen:o,schema:s,data:i,allErrors:a,opts:c,self:u}=e,{RULES:l}=u;if(s.$ref&&(c.ignoreKeywordsWithRef||!(0,yt.schemaHasRulesButRef)(s,l))){o.block(()=>xg(e,"$ref",l.all.$ref.definition));return}c.jtd||BS(e,t),o.block(()=>{for(let f of l.rules)d(f);d(l.post)});function d(f){(0,Tc.shouldUseGroup)(s,f)&&(f.type?(o.if((0,qs.checkDataType)(f.type,i,c.strictNumbers)),mg(e,f),t.length===1&&t[0]===f.type&&r&&(o.else(),(0,qs.reportTypeError)(e)),o.endIf()):mg(e,f),a||o.if((0,P._)`${R.default.errors} === ${n||0}`))}}function mg(e,t){let{gen:r,schema:n,opts:{useDefaults:o}}=e;o&&(0,OS.assignDefaults)(e,t.type),r.block(()=>{for(let s of t.rules)(0,Tc.shouldUseRule)(n,s)&&xg(e,s.keyword,s.definition,t.type)})}function BS(e,t){e.schemaEnv.meta||!e.opts.strictTypes||(JS(e,t),e.opts.allowUnionTypes||KS(e,t),GS(e,e.dataTypes))}function JS(e,t){if(t.length){if(!e.dataTypes.length){e.dataTypes=t;return}t.forEach(r=>{$g(e.dataTypes,r)||Oc(e,`type "${r}" not allowed by context "${e.dataTypes.join(",")}"`)}),YS(e,t)}}function KS(e,t){t.length>1&&!(t.length===2&&t.includes("null"))&&Oc(e,"use allowUnionTypes to allow union type keyword")}function GS(e,t){let r=e.self.RULES.all;for(let n in r){let o=r[n];if(typeof o=="object"&&(0,Tc.shouldUseRule)(e.schema,o)){let{type:s}=o.definition;s.length&&!s.some(i=>WS(t,i))&&Oc(e,`missing type "${s.join(",")}" for keyword "${n}"`)}}}function WS(e,t){return e.includes(t)||t==="number"&&e.includes("integer")}function $g(e,t){return e.includes(t)||t==="integer"&&e.includes("number")}function YS(e,t){let r=[];for(let n of e.dataTypes)$g(t,n)?r.push(n):t.includes("integer")&&n==="number"&&r.push("integer");e.dataTypes=r}function Oc(e,t){let r=e.schemaEnv.baseId+e.errSchemaPath;t+=` at "${r}" (strictTypes)`,(0,yt.checkStrictMode)(e,t,e.opts.strictTypes)}var Fs=class{constructor(t,r,n){if((0,Dn.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,yt.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",Sg(this.$data,t));else if(this.schemaCode=this.schemaValue,!(0,Dn.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",R.default.errors))}result(t,r,n){this.failResult((0,P.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,P.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,P._)`${r} !== undefined && (${(0,P.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?jn.reportExtraError:jn.reportError)(this,this.def.error,r)}$dataError(){(0,jn.reportError)(this,this.def.$dataError||jn.keyword$DataError)}reset(){if(this.errsCount===void 0)throw new Error('add "trackErrors" to keyword definition');(0,jn.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=P.nil){this.gen.block(()=>{this.check$data(t,n),r()})}check$data(t=P.nil,r=P.nil){if(!this.$data)return;let{gen:n,schemaCode:o,schemaType:s,def:i}=this;n.if((0,P.or)((0,P._)`${o} === undefined`,r)),t!==P.nil&&n.assign(t,!0),(s.length||i.validateSchema)&&(n.elseIf(this.invalid$data()),this.$dataError(),t!==P.nil&&n.assign(t,!1)),n.else()}invalid$data(){let{gen:t,schemaCode:r,schemaType:n,def:o,it:s}=this;return(0,P.or)(i(),a());function i(){if(n.length){if(!(r instanceof P.Name))throw new Error("ajv implementation error");let c=Array.isArray(n)?n:[n];return(0,P._)`${(0,qs.checkDataTypes)(c,r,s.opts.strictNumbers,qs.DataType.Wrong)}`}return P.nil}function a(){if(o.validateSchema){let c=t.scopeValue("validate$data",{ref:o.validateSchema});return(0,P._)`!${c}(${r})`}return P.nil}}subschema(t,r){let n=(0,Ic.getSubschema)(this.it,t);(0,Ic.extendSubschemaData)(n,this.it,t),(0,Ic.extendSubschemaMode)(n,t);let o={...this.it,...n,items:void 0,props:void 0};return ZS(o,r),o}mergeEvaluated(t,r){let{it:n,gen:o}=this;n.opts.unevaluated&&(n.props!==!0&&t.props!==void 0&&(n.props=yt.mergeEvaluated.props(o,t.props,n.props,r)),n.items!==!0&&t.items!==void 0&&(n.items=yt.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,P.Name)),!0}};Ct.KeywordCxt=Fs;function xg(e,t,r,n){let o=new Fs(e,r,t);"code"in r?r.code(o,n):o.$data&&r.validate?(0,Dn.funcKeywordCode)(o,r):"macro"in r?(0,Dn.macroKeywordCode)(o,r):(r.compile||r.validate)&&(0,Dn.funcKeywordCode)(o,r)}var XS=/^\/(?:[^~]|~0|~1)*$/,QS=/^([0-9]+)(#|\/(?:[^~]|~0|~1)*)?$/;function Sg(e,{dataLevel:t,dataNames:r,dataPathArr:n}){let o,s;if(e==="")return R.default.rootData;if(e[0]==="/"){if(!XS.test(e))throw new Error(`Invalid JSON-pointer: ${e}`);o=e,s=R.default.rootData}else{let u=QS.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(s=r[t-l],!o)return s}let i=s,a=o.split("/");for(let u of a)u&&(s=(0,P._)`${s}${(0,P.getProperty)((0,yt.unescapeJsonPointer)(u))}`,i=(0,P._)`${i} && ${s}`);return i;function c(u,l){return`Cannot access ${u} ${l} levels up, current level is ${t}`}}Ct.getData=Sg});var Ls=x(Ac=>{"use strict";Object.defineProperty(Ac,"__esModule",{value:!0});var Rc=class extends Error{constructor(t){super("validation failed"),this.errors=t,this.ajv=this.validation=!0}};Ac.default=Rc});var Mn=x(jc=>{"use strict";Object.defineProperty(jc,"__esModule",{value:!0});var Cc=Nn(),Nc=class extends Error{constructor(t,r,n,o){super(o||`can't resolve reference ${n} from id ${r}`),this.missingRef=(0,Cc.resolveUrl)(t,r,n),this.missingSchema=(0,Cc.normalizeId)((0,Cc.getFullPath)(t,this.missingRef))}};jc.default=Nc});var Vs=x(Ve=>{"use strict";Object.defineProperty(Ve,"__esModule",{value:!0});Ve.resolveSchema=Ve.getCompilingSchema=Ve.resolveRef=Ve.compileSchema=Ve.SchemaEnv=void 0;var Xe=j(),ek=Ls(),Yt=gt(),Qe=Nn(),kg=F(),tk=Zn(),Ir=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,Qe.normalizeId)(n?.[t.schemaId||"$id"]),this.schemaPath=t.schemaPath,this.localRefs=t.localRefs,this.meta=t.meta,this.$async=n?.$async,this.refs={}}};Ve.SchemaEnv=Ir;function Zc(e){let t=zg.call(this,e);if(t)return t;let r=(0,Qe.getFullPath)(this.opts.uriResolver,e.root.baseId),{es5:n,lines:o}=this.opts.code,{ownProperties:s}=this.opts,i=new Xe.CodeGen(this.scope,{es5:n,lines:o,ownProperties:s}),a;e.$async&&(a=i.scopeValue("Error",{ref:ek.default,code:(0,Xe._)`require("ajv/dist/runtime/validation_error").default`}));let c=i.scopeName("validate");e.validateName=c;let u={gen:i,allErrors:this.opts.allErrors,data:Yt.default.data,parentData:Yt.default.parentData,parentDataProperty:Yt.default.parentDataProperty,dataNames:[Yt.default.data],dataPathArr:[Xe.nil],dataLevel:0,dataTypes:[],definedProperties:new Set,topSchemaRef:i.scopeValue("schema",this.opts.code.source===!0?{ref:e.schema,code:(0,Xe.stringify)(e.schema)}:{ref:e.schema}),validateName:c,ValidationError:a,schema:e.schema,schemaEnv:e,rootId:r,baseId:e.baseId||r,schemaPath:Xe.nil,errSchemaPath:e.schemaPath||(this.opts.jtd?"":"#"),errorPath:(0,Xe._)`""`,opts:this.opts,self:this},l;try{this._compilations.add(e),(0,tk.validateFunctionCode)(u),i.optimize(this.opts.code.optimize);let d=i.toString();l=`${i.scopeRefs(Yt.default.scope)}return ${d}`,this.opts.code.process&&(l=this.opts.code.process(l,e));let p=new Function(`${Yt.default.self}`,`${Yt.default.scope}`,l)(this,this.scope.get());if(this.scope.value(c,{ref:p}),p.errors=null,p.schema=e.schema,p.schemaEnv=e,e.$async&&(p.$async=!0),this.opts.code.source===!0&&(p.source={validateName:c,validateCode:d,scopeValues:i._values}),this.opts.unevaluated){let{props:m,items:h}=u;p.evaluated={props:m instanceof Xe.Name?void 0:m,items:h instanceof Xe.Name?void 0:h,dynamicProps:m instanceof Xe.Name,dynamicItems:h instanceof Xe.Name},p.source&&(p.source.evaluated=(0,Xe.stringify)(p.evaluated))}return e.validate=p,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)}}Ve.compileSchema=Zc;function rk(e,t,r){var n;r=(0,Qe.resolveUrl)(this.opts.uriResolver,t,r);let o=e.refs[r];if(o)return o;let s=sk.call(this,e,r);if(s===void 0){let i=(n=e.localRefs)===null||n===void 0?void 0:n[r],{schemaId:a}=this.opts;i&&(s=new Ir({schema:i,schemaId:a,root:e,baseId:t}))}if(s!==void 0)return e.refs[r]=nk.call(this,s)}Ve.resolveRef=rk;function nk(e){return(0,Qe.inlineRef)(e.schema,this.opts.inlineRefs)?e.schema:e.validate?e:Zc.call(this,e)}function zg(e){for(let t of this._compilations)if(ok(t,e))return t}Ve.getCompilingSchema=zg;function ok(e,t){return e.schema===t.schema&&e.root===t.root&&e.baseId===t.baseId}function sk(e,t){let r;for(;typeof(r=this.refs[t])=="string";)t=r;return r||this.schemas[t]||Us.call(this,e,t)}function Us(e,t){let r=this.opts.uriResolver.parse(t),n=(0,Qe._getFullPath)(this.opts.uriResolver,r),o=(0,Qe.getFullPath)(this.opts.uriResolver,e.baseId,void 0);if(Object.keys(e.schema).length>0&&n===o)return Dc.call(this,r,e);let s=(0,Qe.normalizeId)(n),i=this.refs[s]||this.schemas[s];if(typeof i=="string"){let a=Us.call(this,e,i);return typeof a?.schema!="object"?void 0:Dc.call(this,r,a)}if(typeof i?.schema=="object"){if(i.validate||Zc.call(this,i),s===(0,Qe.normalizeId)(t)){let{schema:a}=i,{schemaId:c}=this.opts,u=a[c];return u&&(o=(0,Qe.resolveUrl)(this.opts.uriResolver,o,u)),new Ir({schema:a,schemaId:c,root:e,baseId:o})}return Dc.call(this,r,i)}}Ve.resolveSchema=Us;var ik=new Set(["properties","patternProperties","enum","dependencies","definitions"]);function Dc(e,{baseId:t,schema:r,root:n}){var o;if(((o=e.fragment)===null||o===void 0?void 0:o[0])!=="/")return;for(let a of e.fragment.slice(1).split("/")){if(typeof r=="boolean")return;let c=r[(0,kg.unescapeFragment)(a)];if(c===void 0)return;r=c;let u=typeof r=="object"&&r[this.opts.schemaId];!ik.has(a)&&u&&(t=(0,Qe.resolveUrl)(this.opts.uriResolver,t,u))}let s;if(typeof r!="boolean"&&r.$ref&&!(0,kg.schemaHasRulesButRef)(r,this.RULES)){let a=(0,Qe.resolveUrl)(this.opts.uriResolver,t,r.$ref);s=Us.call(this,n,a)}let{schemaId:i}=this.opts;if(s=s||new Ir({schema:r,schemaId:i,root:n,baseId:t}),s.schema!==s.root.schema)return s}});var Pg=x((Sj,ak)=>{ak.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 Vc=x((kj,Ng)=>{"use strict";var ck=RegExp.prototype.test.bind(/^[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}$/iu),qc=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),uk=RegExp.prototype.test.bind(/^\d*$/u),Xt=RegExp.prototype.test.bind(/^[\da-f]{2}$/iu),Fc=RegExp.prototype.test.bind(/^[\da-z\-._~]$/iu),Ig=RegExp.prototype.test.bind(/^[A-Za-z0-9\-._~!$&'()*+,;=:@/]$/u),Lc=RegExp.prototype.test.bind(/^[A-Za-z0-9\-._~!$&'()*+,;=:@/?]$/u),lk=RegExp.prototype.test.bind(/^[A-Za-z0-9\-._~!$&'()*+,;=:]$/u),Te=new Array(256);{let e="0123456789ABCDEF";for(let t=0;t<256;t++)Te[t]="%"+e[t>>4]+e[t&15]}function we(e){return e<2048?Te[192|e>>6]+Te[128|e&63]:e<65536?Te[224|e>>12]+Te[128|e>>6&63]+Te[128|e&63]:Te[240|e>>18]+Te[128|e>>12&63]+Te[128|e>>6&63]+Te[128|e&63]}function dk(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 fk=RegExp.prototype.test.bind(/^[\dA-Fa-f]{1,4}$/),pk=RegExp.prototype.test.bind(/^[vV][\dA-Fa-f]+\.[A-Za-z\d\-._~!$&'()*+,;=:]+$/),mk=RegExp.prototype.test.bind(/^[A-Za-z\d\-._~]$/),hk=RegExp.prototype.test.bind(/[^!"$&'()*+,\-.;=_`a-z{}~]/u);function gk(e){if(e.length===0)return!1;for(let t=0;t<e.length;t++)if(!mk(e[t])){if(e[t]==="%"&&t+2<e.length&&Xt(e.slice(t+1,t+3))){t+=2;continue}return!1}return!0}function Eg(e){let t=-1,r=0,n=-1,o=0;for(let a=0;a<e.length;a++)e[a]==="0"?(n===-1&&(n=a),o++,o>r&&(r=o,t=n)):(n=-1,o=0);if(r<2)return e.join(":");let s=e.slice(0,t).join(":"),i=e.slice(t+r).join(":");return s+"::"+i}function yk(e){let t=e.indexOf("::");if(t!==-1&&e.indexOf("::",t+1)!==-1)return;let r=t===-1?e.split(":"):e.slice(0,t).split(":"),n=t===-1?[]:e.slice(t+2).split(":");t!==-1&&(r.length===1&&r[0]===""&&(r.length=0),n.length===1&&n[0]===""&&(n.length=0));let o=r.concat(n),s=0;for(let a=0;a<o.length;a++){let c=o[a];if(c==="")return;if(c.indexOf(".")!==-1){if(a!==o.length-1||t!==-1&&n.length===0||!qc(c))return;s+=2;continue}if(!fk(c))return;o[a]=parseInt(c,16).toString(16),s++}if(t===-1)return s!==8?void 0:Eg(o);if(s>=8)return;let i=o.slice(0,r.length);for(let a=s;a<8;a++)i.push("0");for(let a=r.length;a<o.length;a++)i.push(o[a]);return Eg(i)}function Mc(e){let t=e[0]==="["&&e[e.length-1]==="]";if((e[0]==="["||e[e.length-1]==="]")&&!t)return{host:e,isIPV6:!1,error:!0};let n=t?e.slice(1,-1):e;if(t&&pk(n))return n=n.toLowerCase(),{host:`[${n}]`,escapedHost:n,isIPV6:!1,isIPVFuture:!0};if(_k(n,":")<2)return{host:e,isIPV6:!1,error:t};let o="",s=n.indexOf("%");if(s!==-1){let a=n.slice(s,s+3).toLowerCase()==="%25"?3:1;if(o=n.slice(s+a),!gk(o))return{host:e,isIPV6:!1,error:!0};n=n.slice(0,s)}let i=yk(n);return i===void 0?{host:e,isIPV6:!1,error:!0}:{host:i+(o?"%"+o:""),escapedHost:i+(o?"%25"+o:""),isIPV6:!0}}function _k(e,t){let r=0;for(let n=0;n<e.length;n++)e[n]===t&&r++;return r}function Tg(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 wk(e){if(e===""||e[0]==="/")return Tg(e);let t=e.split("/"),r=t.length-1,n=[],o=!1;for(let s=0;s<=r;s++){let i=t[s];i==="."||i===".."?(i===".."&&(n.length!==0&&n[n.length-1]!==".."?n.pop():n.push("..")),o=s===r):n.push(i)}return o&&n[n.length-1]!==".."&&n.push(""),(n.length===0||n[0]===""||n[0].includes(":"))&&n.unshift("."),n.join("/")}var bk={"@":"%40","/":"%2F","?":"%3F","#":"%23",":":"%3A"},vk=/[@/?#:]/g,$k=/[@/?#]/g;function Og(e,t){let r=t?$k:vk;return r.lastIndex=0,e.replace(r,n=>bk[n])}function Rg(e,t=!1){if(e.indexOf("%")===-1)return e;let r="";for(let n=0;n<e.length;n++){if(e[n]==="%"&&n+2<e.length){let o=e.slice(n+1,n+3);if(Xt(o)){let s=o.toUpperCase(),i=String.fromCharCode(parseInt(s,16));t&&Fc(i)?r+=i:r+="%"+s,n+=2;continue}}r+=e[n]}return r}function xk(e){let t="";for(let r=0;r<e.length;r++){let n=e[r];if(n==="%"&&r+2<e.length){let o=e.slice(r+1,r+3);if(Xt(o)){let s=o.toUpperCase(),i=String.fromCharCode(parseInt(s,16));i!=="."&&Fc(i)?t+=i:t+="%"+s,r+=2;continue}}if(Ig(n))t+=n;else{let o=e.charCodeAt(r);if(o<128)t+=Cg(o)?n:Te[o];else if(o<55296||o>57343)t+=we(o);else if(o<=56319&&r+1<e.length){let s=e.charCodeAt(r+1);s>=56320&&s<=57343?(t+=we(65536+(o-55296<<10)+(s-56320)),r++):t+=we(65533)}else t+=we(65533)}}return t}function Sk(e,t=!1){let r="",n=t&&e[0]!=="/";for(let o=0;o<e.length;o++){let s=e[o];if(s==="%"&&o+2<e.length){let i=e.slice(o+1,o+3);if(Xt(i)){r+="%"+i.toUpperCase(),o+=2;continue}}if(s==="/"&&(n=!1),Ig(s)&&(s!==":"||!n))r+=s;else{let i=e.charCodeAt(o);if(i<128)r+=Te[i];else if(i<55296||i>57343)r+=we(i);else if(i<=56319&&o+1<e.length){let a=e.charCodeAt(o+1);a>=56320&&a<=57343?(r+=we(65536+(i-55296<<10)+(a-56320)),o++):r+=we(65533)}else r+=we(65533)}}return r}function Uc(e,t){let r="";for(let n=0;n<e.length;n++){let o=e[n];if(o==="%"&&n+2<e.length){let s=e.slice(n+1,n+3);if(Xt(s)){r+="%"+s.toUpperCase(),n+=2;continue}}if(t(o))r+=o;else{let s=e.charCodeAt(n);if(s<128)r+=Te[s];else if(s<55296||s>57343)r+=we(s);else if(s<=56319&&n+1<e.length){let i=e.charCodeAt(n+1);i>=56320&&i<=57343?(r+=we(65536+(s-55296<<10)+(i-56320)),n++):r+=we(65533)}else r+=we(65533)}}return r}function Ag(e){return Uc(e,lk)}function kk(e){return Uc(e,Lc)}function zk(e){return Uc(e,Lc)}function Cg(e){return e>=48&&e<=57||e>=65&&e<=90||e>=97&&e<=122||e===42||e===43||e===45||e===46||e===47||e===64||e===95}function Pk(e){let t="";for(let r=0;r<e.length;r++){let n=e[r];if(n==="%"&&r+2<e.length){let o=e.slice(r+1,r+3);if(Xt(o)){let s=o.toUpperCase(),i=String.fromCharCode(parseInt(s,16));Fc(i)?t+=i:t+="%"+s,r+=2;continue}}if(Lc(n))t+=n;else{let o=e.charCodeAt(r);if(o<128)t+=Cg(o)?n:Te[o];else if(o<55296||o>57343)t+=we(o);else if(o<=56319&&r+1<e.length){let s=e.charCodeAt(r+1);s>=56320&&s<=57343?(t+=we(65536+(o-55296<<10)+(s-56320)),r++):t+=we(65533)}else t+=we(65533)}}return t}function Ek(e){let t="";for(let r=0;r<e.length;r++){if(e[r]==="%"&&r+2<e.length){let n=e.slice(r+1,r+3);if(Xt(n)){t+="%"+n.toUpperCase(),r+=2;continue}}t+=escape(e[r])}return t}function Ik(e){let t=[];if(e.userinfo!==void 0&&(t.push(Ag(e.userinfo)),t.push("@")),e.host!==void 0){let r=e.host;if(!qc(r)){let n=Mc(r);n.isIPV6!==!0&&n.isIPVFuture!==!0&&(r=Rg(r,!0),n=Mc(r)),n.isIPV6===!0||n.isIPVFuture===!0?r=`[${n.escapedHost}]`:r=Og(r,!1)}t.push(r)}if(typeof e.port=="number"||typeof e.port=="string"){let r=String(e.port);if(!uk(r))throw new TypeError("URI port is malformed.");t.push(":"),t.push(r)}return t.length?t.join(""):void 0}Ng.exports={nonSimpleDomain:hk,recomposeAuthority:Ik,reescapeHostDelimiters:Og,normalizePercentEncoding:Rg,normalizePathEncoding:xk,serializePathEncoding:Sk,normalizeQueryFragmentEncoding:Pk,encodeUserinfo:Ag,encodeQuery:kk,encodeFragment:zk,escapePreservingEscapes:Ek,removeDotSegments:Tg,removeDotSegmentsRelative:wk,isIPv4:qc,isUUID:ck,normalizeIPv6:Mc,stringArrayToHexStripped:dk}});var qg=x((zj,Mg)=>{"use strict";var{isUUID:Tk}=Vc(),Ok=/^([\da-z][\d\-a-z]{0,31}):((?:[\w!$'()*+,\-./:;=@]|%[\da-f]{2})+)$/iu,Rk=["http","https","ws","wss","urn","urn:uuid"];function Ak(e){return Rk.indexOf(e)!==-1}function Hc(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 jg(e){return e.host||(e.error=e.error||"HTTP URIs must have a host."),e}function Dg(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 Ck(e){return e.secure=Hc(e),e.resourceName=(e.path||"/")+(e.query?"?"+e.query:""),e.path=void 0,e.query=void 0,e}function Nk(e){if((e.port===(Hc(e)?443:80)||e.port==="")&&(e.port=void 0),typeof e.secure=="boolean"&&(e.scheme=e.secure?"wss":"ws",e.secure=void 0),e.resourceName){let t=e.resourceName.indexOf("?"),r=t===-1?e.resourceName:e.resourceName.slice(0,t);e.path=r&&r!=="/"?r:void 0,e.query=t===-1?void 0:e.resourceName.slice(t+1),e.resourceName=void 0}return e.fragment=void 0,e}function jk(e,t){if(!e.path)return e.error="URN can not be parsed",e;let r=e.path.match(Ok);if(r&&r[0]===e.path){let n=t.scheme||e.scheme||"urn";e.nid=r[1].toLowerCase(),e.nss=r[2];let o=`${n}:${t.nid||e.nid}`,s=Bc(o);e.path=void 0,s&&(e=s.parse(e,t))}else e.error=e.error||"URN can not be parsed.";return e}function Dk(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}`,s=Bc(o);s&&(e=s.serialize(e,t));let i=e,a=e.nss;return i.path=`${n||t.nid}:${a}`,t.skipEscape=!0,i}function Zk(e,t){let r=e;return r.uuid=r.nss,r.nss=void 0,!t.tolerant&&(!r.uuid||!Tk(r.uuid))&&(r.error=r.error||"UUID is not valid."),r}function Mk(e){let t=e;return t.nss=(e.uuid||"").toLowerCase(),t}var Zg={scheme:"http",domainHost:!0,parse:jg,serialize:Dg},qk={scheme:"https",domainHost:Zg.domainHost,parse:jg,serialize:Dg},Hs={scheme:"ws",domainHost:!0,parse:Ck,serialize:Nk},Fk={scheme:"wss",domainHost:Hs.domainHost,parse:Hs.parse,serialize:Hs.serialize},Lk={scheme:"urn",parse:jk,serialize:Dk,skipNormalize:!0},Uk={scheme:"urn:uuid",parse:Zk,serialize:Mk,skipNormalize:!0},Bs={http:Zg,https:qk,ws:Hs,wss:Fk,urn:Lk,"urn:uuid":Uk};Object.setPrototypeOf(Bs,null);function Bc(e){return e&&(Bs[e]||Bs[e.toLowerCase()])||void 0}Mg.exports={wsIsSecure:Hc,SCHEMES:Bs,isValidSchemeName:Ak,getSchemeHandler:Bc}});var ty=x((Pj,Ys)=>{"use strict";var{normalizeIPv6:Hg,removeDotSegments:Fn,removeDotSegmentsRelative:Bg,recomposeAuthority:Vk,normalizePercentEncoding:Jc,normalizePathEncoding:Hk,serializePathEncoding:Fg,normalizeQueryFragmentEncoding:Lg,encodeQuery:Bk,encodeFragment:Jk,reescapeHostDelimiters:Kk,isIPv4:Jg,nonSimpleDomain:Gk}=Vc(),{SCHEMES:Kg,getSchemeHandler:Kc}=qg(),Gg=/^[A-Za-z][A-Za-z0-9+.-]*$/u,Wg="URI scheme is malformed.",Js="URI host is malformed.",Wk=/[\0-\x20"#/:<>?@[\\\]^`{|}\x7F]/u;function Ug(e){let t=String(e);if(!Gg.test(t))throw new TypeError(Wg);return t}function Yk(e,t){return typeof e=="string"?e=iz(e,t):typeof e=="object"&&(e=Gs(Qt(e,t),t)),e}function Xk(e,t,r){let n=r?Object.assign({scheme:"null"},r):{scheme:"null"},{parsed:o,malformedAuthorityOrPort:s,malformedPercentEncoding:i,malformedSchemeSpecific:a,malformedHost:c,malformedScheme:u}=Ks(e,n),{parsed:l,malformedAuthorityOrPort:d,malformedPercentEncoding:f,malformedSchemeSpecific:p,malformedHost:m,malformedScheme:h}=Ks(t,n);if(s||d||i||f||a||p||c||m||u||h)throw new Error(o.error||l.error||"URI is malformed.");let g=Yg(o,l,n,!0),w=Kc(r&&r.scheme||g.scheme),v=g.host,$=v!==void 0&&v!==""&&(Jg(v)||Hg(v).isIPV6);if(Qg(g,r||{},w,$))throw new Error(Js);Xg(g,r||{},w,$);let O=v&&v.indexOf("%")!==-1&&!new RegExp("\\P{ASCII}","u").test(v);if(g.error&&!O)throw new Error(g.error);return n.skipEscape=!0,Qt(g,n)}function Yg(e,t,r,n){let o={};if(n||(e=Gs(Qt(e,r),r),t=Gs(Qt(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=Fn(t.path||""),o.query=t.query;else{if(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=Fn(t.path||""),o.query=t.query;else{if(!t.path)o.path=e.path,t.query!==void 0?o.query=t.query:o.query=e.query;else{if(t.path[0]==="/")o.path=Fn(t.path);else{let s=e.userinfo!==void 0||e.host!==void 0||e.port!==void 0;s&&!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=e.scheme===void 0&&!s&&o.path[0]!=="/"?Bg(o.path):Fn(o.path)}o.query=t.query}o.userinfo=e.userinfo,o.host=e.host,o.port=e.port}o.scheme=e.scheme}return o.fragment=t.fragment,o}function Qk(e,t,r){let n=Vg(e,r),o=Vg(t,r);return n!==void 0&&o!==void 0&&n===o}function Qt(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=[];r.scheme&&(r.scheme=Ug(r.scheme));let s=Kc(n.scheme||r.scheme);s&&s.serialize&&s.serialize(r,n);let i=r.userinfo!==void 0||r.host!==void 0||r.port!==void 0,a=(r.scheme===void 0||n.reference==="suffix")&&!i,c=!n.skipEscape&&a;r.path!==void 0&&(n.skipEscape?r.path=Jc(r.path):r.path=Fg(r.path,c)),n.reference!=="suffix"&&r.scheme&&(r.scheme=Ug(r.scheme),o.push(r.scheme,":"));let u=Vk(r);if(u!==void 0&&(n.reference!=="suffix"&&o.push("//"),o.push(u),r.path&&r.path[0]!=="/"&&o.push("/")),r.path!==void 0){let l=r.path;!n.absolutePath&&(!s||!s.absolutePath)&&(l=a&&l[0]!=="/"?Bg(l):Fn(l)),a&&(l=Fg(l,!0)),u===void 0&&l[0]==="/"&&l[1]==="/"&&(l="/%2F"+l.slice(2)),o.push(l)}return r.query!==void 0&&o.push("?",Bk(r.query)),r.fragment!==void 0&&o.push("#",Jk(r.fragment)),o.join("")}var ez=/^(?:([^#/:?]+):)?(?:\/\/((?:([^#/?@]*)@)?(\[[^#/?\]]+\]|[^#/:?]*)(?::(\d*))?))?([^#?]*)(?:\?([^#]*))?(?:#((?:.|[\n\r])*))?/u,tz=/^(?:[^#/:?]+:)?\/\/([^/?#]*)/,rz=/^(?:[^#/:?]+:)?([/\\\t\n\r]*)/;function nz(e,t){if(t[2]!==void 0&&e.path&&e.path[0]!=="/")return'URI path must start with "/" when authority is present.';if(typeof e.port=="number"&&(e.port<0||e.port>65535))return"URI port is malformed."}function qn(e){if(e===void 0)return!1;let t=e.indexOf("%");for(;t!==-1;){if(t+2>=e.length||!/^[\da-f]{2}$/iu.test(e.slice(t+1,t+3)))return!0;t=e.indexOf("%",t+3)}return!1}function Ws(e){return e[0]==="["&&e[e.length-1]==="]"}function oz(e){let t=e[4];return qn(e[3])||t!==void 0&&!Ws(t)&&qn(t)||qn(e[6])||qn(e[7])||qn(e[8])}function Xg(e,t,r,n){if(Qg(e,t,r,n))return e.error=e.error||Js,!0;if(!t.unicodeSupport&&(!r||!r.unicodeSupport)&&e.host&&!Ws(e.host)&&(t.domainHost||r&&r.domainHost)&&n===!1&&Gk(e.host)){let o;try{o=new URL("http://"+e.host)}catch(s){return e.error=e.error||"Host's domain name can not be converted to ASCII: "+s,!0}if(!sz(o))return e.error=e.error||Js,!0;e.host=o.hostname}return!1}function Qg(e,t,r,n){return!!(e.host&&n===!1&&!Ws(e.host)&&(t.domainHost||r&&r.domainHost)&&Wk.test(e.host))}function sz(e){return e.username===""&&e.password===""&&e.port===""&&e.pathname==="/"&&e.search===""&&e.hash===""&&e.hostname!==""}function Ks(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,s=!1,i=!1,a=!1,c=!1,u=!1,l=!1;r.reference==="suffix"&&(r.scheme?e=r.scheme+":"+e:e="//"+e);let d=e.match(tz);d!==null&&d[1].indexOf("\\")!==-1&&(n.error="URI authority must not contain a literal backslash.",o=!0);let f=e.match(rz);if(f!==null){let m=f[1],h=m.replace(/[\t\n\r]/g,"");h.length>=2&&(h.slice(0,2)!=="//"?(n.error=n.error||"URI authority must not contain a literal backslash.",o=!0):m.length!==h.length&&(n.error=n.error||"URI authority introducer must not contain whitespace.",o=!0))}let p=e.match(ez);if(p){n.scheme=p[1],n.userinfo=p[3],n.host=p[4],n.port=parseInt(p[5],10),n.path=p[6]||"",n.query=p[7],n.fragment=p[8],n.scheme!==void 0&&(Gg.test(n.scheme)?n.scheme=n.scheme.toLowerCase():(n.error=n.error||Wg,u=!0)),s=oz(p),s&&(n.error=n.error||"URI contains malformed percent-encoding."),isNaN(n.port)&&(n.port=p[5]);let m=nz(n,p);if(m!==void 0&&(n.error=n.error||m,o=!0),n.host)if(Jg(n.host)===!1){let w=Ws(n.host),v=n.host.indexOf("[")!==-1||n.host.indexOf("]")!==-1,$=Hg(n.host);l=$.isIPV6||$.isIPVFuture===!0,c=v&&(!w||$.error===!0),n.host=l?$.host:$.host.toLowerCase(),c&&(n.error=n.error||Js,o=!0)}else l=!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 h=Kc(r.scheme||n.scheme);if(c||(a=Xg(n,r,h,l)),e.indexOf("%")!==-1&&n.host!==void 0&&!c){let g=l?n.host:Jc(n.host,!0);l||(g=Jc(g.toLowerCase())),n.host=l||r.scheme!=="null"?Kk(g,l):g}(!h||h&&!h.skipNormalize)&&(n.path&&(n.path=Hk(n.path)),n.query&&(n.query=Lg(n.query)),n.fragment&&(n.fragment=Lg(n.fragment))),h&&h.parse&&(h.parse(n,r),h===Kg.urn&&n.nid===void 0&&(i=!0))}else n.error=n.error||"URI can not be parsed.";return{parsed:n,malformedAuthorityOrPort:o,malformedPercentEncoding:s,malformedSchemeSpecific:i,malformedHost:a,malformedScheme:u}}function Gs(e,t){return Ks(e,t).parsed}function iz(e,t){return ey(e,t).normalized}function ey(e,t){let{parsed:r,malformedAuthorityOrPort:n,malformedPercentEncoding:o,malformedSchemeSpecific:s,malformedHost:i,malformedScheme:a}=Ks(e,t);return{normalized:n||o||s||i||a?e:Qt(r,t),malformedAuthorityOrPort:n,malformedPercentEncoding:o,malformedSchemeSpecific:s,malformedHost:i,malformedScheme:a}}function Vg(e,t){if(typeof e!="string"&&typeof e!="object")return;let r;try{r=typeof e=="string"?e:Qt(e,t)}catch{return}let{normalized:n,malformedAuthorityOrPort:o,malformedPercentEncoding:s,malformedSchemeSpecific:i,malformedHost:a,malformedScheme:c}=ey(r,t);return o||s||i||a||c?void 0:n}var Gc={SCHEMES:Kg,normalize:Yk,resolve:Xk,resolveComponent:Yg,equal:Qk,serialize:Qt,parse:Gs};Ys.exports=Gc;Ys.exports.default=Gc;Ys.exports.fastUri=Gc});var ny=x(Wc=>{"use strict";Object.defineProperty(Wc,"__esModule",{value:!0});var ry=ty();ry.code='require("ajv/dist/runtime/uri").default';Wc.default=ry});var dy=x(me=>{"use strict";Object.defineProperty(me,"__esModule",{value:!0});me.CodeGen=me.Name=me.nil=me.stringify=me.str=me._=me.KeywordCxt=void 0;var az=Zn();Object.defineProperty(me,"KeywordCxt",{enumerable:!0,get:function(){return az.KeywordCxt}});var Tr=j();Object.defineProperty(me,"_",{enumerable:!0,get:function(){return Tr._}});Object.defineProperty(me,"str",{enumerable:!0,get:function(){return Tr.str}});Object.defineProperty(me,"stringify",{enumerable:!0,get:function(){return Tr.stringify}});Object.defineProperty(me,"nil",{enumerable:!0,get:function(){return Tr.nil}});Object.defineProperty(me,"Name",{enumerable:!0,get:function(){return Tr.Name}});Object.defineProperty(me,"CodeGen",{enumerable:!0,get:function(){return Tr.CodeGen}});var cz=Ls(),cy=Mn(),uz=wc(),Ln=Vs(),lz=j(),Un=Nn(),Xs=Cn(),Xc=F(),oy=Pg(),dz=ny(),uy=(e,t)=>new RegExp(e,t);uy.code="new RegExp";var fz=["removeAdditional","useDefaults","coerceTypes"],pz=new Set(["validate","serialize","parse","wrapper","root","schema","keyword","pattern","formats","validate$data","func","obj","Error"]),mz={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."},hz={ignoreKeywordsWithRef:"",jsPropertySyntax:"",unicode:'"minLength"/"maxLength" account for unicode characters by default.'},sy=200;function gz(e){var t,r,n,o,s,i,a,c,u,l,d,f,p,m,h,g,w,v,$,O,k,N,se,Dt,sr;let at=e.strict,ir=(t=e.code)===null||t===void 0?void 0:t.optimize,co=ir===!0||ir===void 0?1:ir||0,uo=(n=(r=e.code)===null||r===void 0?void 0:r.regExp)!==null&&n!==void 0?n:uy,$w=(o=e.uriResolver)!==null&&o!==void 0?o:dz.default;return{strictSchema:(i=(s=e.strictSchema)!==null&&s!==void 0?s:at)!==null&&i!==void 0?i:!0,strictNumbers:(c=(a=e.strictNumbers)!==null&&a!==void 0?a:at)!==null&&c!==void 0?c:!0,strictTypes:(l=(u=e.strictTypes)!==null&&u!==void 0?u:at)!==null&&l!==void 0?l:"log",strictTuples:(f=(d=e.strictTuples)!==null&&d!==void 0?d:at)!==null&&f!==void 0?f:"log",strictRequired:(m=(p=e.strictRequired)!==null&&p!==void 0?p:at)!==null&&m!==void 0?m:!1,code:e.code?{...e.code,optimize:co,regExp:uo}:{optimize:co,regExp:uo},loopRequired:(h=e.loopRequired)!==null&&h!==void 0?h:sy,loopEnum:(g=e.loopEnum)!==null&&g!==void 0?g:sy,meta:(w=e.meta)!==null&&w!==void 0?w:!0,messages:(v=e.messages)!==null&&v!==void 0?v:!0,inlineRefs:($=e.inlineRefs)!==null&&$!==void 0?$:!0,schemaId:(O=e.schemaId)!==null&&O!==void 0?O:"$id",addUsedSchema:(k=e.addUsedSchema)!==null&&k!==void 0?k:!0,validateSchema:(N=e.validateSchema)!==null&&N!==void 0?N:!0,validateFormats:(se=e.validateFormats)!==null&&se!==void 0?se:!0,unicodeRegExp:(Dt=e.unicodeRegExp)!==null&&Dt!==void 0?Dt:!0,int32range:(sr=e.int32range)!==null&&sr!==void 0?sr:!0,uriResolver:$w}}var Vn=class{constructor(t={}){this.schemas={},this.refs={},this.formats=Object.create(null),this._compilations=new Set,this._loading={},this._cache=new Map,t=this.opts={...t,...gz(t)};let{es5:r,lines:n}=this.opts.code;this.scope=new lz.ValueScope({scope:{},prefixes:pz,es5:r,lines:n}),this.logger=$z(t.logger);let o=t.validateFormats;t.validateFormats=!1,this.RULES=(0,uz.getRules)(),iy.call(this,mz,t,"NOT SUPPORTED"),iy.call(this,hz,t,"DEPRECATED","warn"),this._metaOpts=bz.call(this),t.formats&&_z.call(this),this._addVocabularies(),this._addDefaultMetaSchema(),t.keywords&&wz.call(this,t.keywords),typeof t.meta=="object"&&this.addMetaSchema(t.meta),yz.call(this),t.validateFormats=o}_addVocabularies(){this.addKeyword("$async")}_addDefaultMetaSchema(){let{$data:t,meta:r,schemaId:n}=this.opts,o=oy;n==="id"&&(o={...oy},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 s.call(this,l.$schema);let f=this._addSchema(l,d);return f.validate||i.call(this,f)}async function s(l){l&&!this.getSchema(l)&&await o.call(this,{$ref:l},!0)}async function i(l){try{return this._compileSchemaEnv(l)}catch(d){if(!(d instanceof cy.default))throw d;return a.call(this,d),await c.call(this,d.missingSchema),i.call(this,l)}}function a({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 s.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 i of t)this.addSchema(i,void 0,n,o);return this}let s;if(typeof t=="object"){let{schemaId:i}=this.opts;if(s=t[i],s!==void 0&&typeof s!="string")throw new Error(`schema ${i} must be string`)}return r=(0,Un.normalizeId)(r||s),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 s="schema is invalid: "+this.errorsText();if(this.opts.validateSchema==="log")this.logger.error(s);else throw new Error(s)}return o}getSchema(t){let r;for(;typeof(r=ay.call(this,t))=="string";)t=r;if(r===void 0){let{schemaId:n}=this.opts,o=new Ln.SchemaEnv({schema:{},schemaId:n});if(r=Ln.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=ay.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,Un.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(Sz.call(this,n,r),!r)return(0,Xc.eachItem)(n,s=>Yc.call(this,s)),this;zz.call(this,r);let o={...r,type:(0,Xs.getJSONTypes)(r.type),schemaType:(0,Xs.getJSONTypes)(r.schemaType)};return(0,Xc.eachItem)(n,o.type.length===0?s=>Yc.call(this,s,o):s=>o.type.forEach(i=>Yc.call(this,s,o,i))),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(s=>s.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,s)=>o+r+s)}$dataMetaSchema(t,r){let n=this.RULES.all;t=JSON.parse(JSON.stringify(t));for(let o of r){let s=o.split("/").slice(1),i=t;for(let a of s)i=i[a];for(let a in n){let c=n[a];if(typeof c!="object")continue;let{$data:u}=c.definition,l=i[a];u&&l&&(i[a]=ly(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,s=this.opts.addUsedSchema){let i,{schemaId:a}=this.opts;if(typeof t=="object")i=t[a];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,Un.normalizeId)(i||n);let u=Un.getSchemaRefs.call(this,t,n);return c=new Ln.SchemaEnv({schema:t,schemaId:a,meta:r,baseId:n,localRefs:u}),this._cache.set(c.schema,c),s&&!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):Ln.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{Ln.compileSchema.call(this,t)}finally{this.opts=r}}};Vn.ValidationError=cz.default;Vn.MissingRefError=cy.default;me.default=Vn;function iy(e,t,r,n="error"){for(let o in e){let s=o;s in t&&this.logger[n](`${r}: option ${o}. ${e[s]}`)}}function ay(e){return e=(0,Un.normalizeId)(e),this.schemas[e]||this.refs[e]}function yz(){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 _z(){for(let e in this.opts.formats){let t=this.opts.formats[e];t&&this.addFormat(e,t)}}function wz(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 bz(){let e={...this.opts};for(let t of fz)delete e[t];return e}var vz={log(){},warn(){},error(){}};function $z(e){if(e===!1)return vz;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 xz=/^[a-z_$][a-z0-9_$:-]*$/i;function Sz(e,t){let{RULES:r}=this;if((0,Xc.eachItem)(e,n=>{if(r.keywords[n])throw new Error(`Keyword ${n} is already defined`);if(!xz.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 Yc(e,t,r){var n;let o=t?.post;if(r&&o)throw new Error('keyword with "post" flag cannot have "type"');let{RULES:s}=this,i=o?s.post:s.rules.find(({type:c})=>c===r);if(i||(i={type:r,rules:[]},s.rules.push(i)),s.keywords[e]=!0,!t)return;let a={keyword:e,definition:{...t,type:(0,Xs.getJSONTypes)(t.type),schemaType:(0,Xs.getJSONTypes)(t.schemaType)}};t.before?kz.call(this,i,a,t.before):i.rules.push(a),s.all[e]=a,(n=t.implements)===null||n===void 0||n.forEach(c=>this.addKeyword(c))}function kz(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 zz(e){let{metaSchema:t}=e;t!==void 0&&(e.$data&&this.opts.$data&&(t=ly(t)),e.validateSchema=this.compile(t,!0))}var Pz={$ref:"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#"};function ly(e){return{anyOf:[e,Pz]}}});var fy=x(Qc=>{"use strict";Object.defineProperty(Qc,"__esModule",{value:!0});var Ez={keyword:"id",code(){throw new Error('NOT SUPPORTED: keyword "id", use "$id" for schema ID')}};Qc.default=Ez});var gy=x(er=>{"use strict";Object.defineProperty(er,"__esModule",{value:!0});er.callRef=er.getValidate=void 0;var Iz=Mn(),py=Ue(),Oe=j(),Or=gt(),my=Vs(),Qs=F(),Tz={keyword:"$ref",schemaType:"string",code(e){let{gen:t,schema:r,it:n}=e,{baseId:o,schemaEnv:s,validateName:i,opts:a,self:c}=n,{root:u}=s;if((r==="#"||r==="#/")&&o===u.baseId)return d();let l=my.resolveRef.call(c,u,o,r);if(l===void 0)throw new Iz.default(n.opts.uriResolver,o,r);if(l instanceof my.SchemaEnv)return f(l);return p(l);function d(){if(s===u)return ei(e,i,s,s.$async);let m=t.scopeValue("root",{ref:u});return ei(e,(0,Oe._)`${m}.validate`,u,u.$async)}function f(m){let h=hy(e,m);ei(e,h,m,m.$async)}function p(m){let h=t.scopeValue("schema",a.code.source===!0?{ref:m,code:(0,Oe.stringify)(m)}:{ref:m}),g=t.name("valid"),w=e.subschema({schema:m,dataTypes:[],schemaPath:Oe.nil,topSchemaRef:h,errSchemaPath:r},g);e.mergeEvaluated(w),e.ok(g)}}};function hy(e,t){let{gen:r}=e;return t.validate?r.scopeValue("validate",{ref:t.validate}):(0,Oe._)`${r.scopeValue("wrapper",{ref:t})}.validate`}er.getValidate=hy;function ei(e,t,r,n){let{gen:o,it:s}=e,{allErrors:i,schemaEnv:a,opts:c}=s,u=c.passContext?Or.default.this:Oe.nil;n?l():d();function l(){if(!a.$async)throw new Error("async schema referenced by sync schema");let m=o.let("valid");o.try(()=>{o.code((0,Oe._)`await ${(0,py.callValidateCode)(e,t,u)}`),p(t),i||o.assign(m,!0)},h=>{o.if((0,Oe._)`!(${h} instanceof ${s.ValidationError})`,()=>o.throw(h)),f(h),i||o.assign(m,!1)}),e.ok(m)}function d(){e.result((0,py.callValidateCode)(e,t,u),()=>p(t),()=>f(t))}function f(m){let h=(0,Oe._)`${m}.errors`;o.assign(Or.default.vErrors,(0,Oe._)`${Or.default.vErrors} === null ? ${h} : ${Or.default.vErrors}.concat(${h})`),o.assign(Or.default.errors,(0,Oe._)`${Or.default.vErrors}.length`)}function p(m){var h;if(!s.opts.unevaluated)return;let g=(h=r?.validate)===null||h===void 0?void 0:h.evaluated;if(s.props!==!0)if(g&&!g.dynamicProps)g.props!==void 0&&(s.props=Qs.mergeEvaluated.props(o,g.props,s.props));else{let w=o.var("props",(0,Oe._)`${m}.evaluated.props`);s.props=Qs.mergeEvaluated.props(o,w,s.props,Oe.Name)}if(s.items!==!0)if(g&&!g.dynamicItems)g.items!==void 0&&(s.items=Qs.mergeEvaluated.items(o,g.items,s.items));else{let w=o.var("items",(0,Oe._)`${m}.evaluated.items`);s.items=Qs.mergeEvaluated.items(o,w,s.items,Oe.Name)}}}er.callRef=ei;er.default=Tz});var yy=x(eu=>{"use strict";Object.defineProperty(eu,"__esModule",{value:!0});var Oz=fy(),Rz=gy(),Az=["$schema","$id","$defs","$vocabulary",{keyword:"$comment"},"definitions",Oz.default,Rz.default];eu.default=Az});var _y=x(tu=>{"use strict";Object.defineProperty(tu,"__esModule",{value:!0});var ti=j(),Nt=ti.operators,ri={maximum:{okStr:"<=",ok:Nt.LTE,fail:Nt.GT},minimum:{okStr:">=",ok:Nt.GTE,fail:Nt.LT},exclusiveMaximum:{okStr:"<",ok:Nt.LT,fail:Nt.GTE},exclusiveMinimum:{okStr:">",ok:Nt.GT,fail:Nt.LTE}},Cz={message:({keyword:e,schemaCode:t})=>(0,ti.str)`must be ${ri[e].okStr} ${t}`,params:({keyword:e,schemaCode:t})=>(0,ti._)`{comparison: ${ri[e].okStr}, limit: ${t}}`},Nz={keyword:Object.keys(ri),type:"number",schemaType:"number",$data:!0,error:Cz,code(e){let{keyword:t,data:r,schemaCode:n}=e;e.fail$data((0,ti._)`${r} ${ri[t].fail} ${n} || isNaN(${r})`)}};tu.default=Nz});var wy=x(ru=>{"use strict";Object.defineProperty(ru,"__esModule",{value:!0});var Hn=j(),jz={message:({schemaCode:e})=>(0,Hn.str)`must be multiple of ${e}`,params:({schemaCode:e})=>(0,Hn._)`{multipleOf: ${e}}`},Dz={keyword:"multipleOf",type:"number",schemaType:"number",$data:!0,error:jz,code(e){let{gen:t,data:r,schemaCode:n,it:o}=e,s=o.opts.multipleOfPrecision,i=t.let("res"),a=s?(0,Hn._)`Math.abs(Math.round(${i}) - ${i}) > 1e-${s}`:(0,Hn._)`${i} !== parseInt(${i})`;e.fail$data((0,Hn._)`(${n} === 0 || (${i} = ${r}/${n}, ${a}))`)}};ru.default=Dz});var vy=x(nu=>{"use strict";Object.defineProperty(nu,"__esModule",{value:!0});function by(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}nu.default=by;by.code='require("ajv/dist/runtime/ucs2length").default'});var $y=x(ou=>{"use strict";Object.defineProperty(ou,"__esModule",{value:!0});var tr=j(),Zz=F(),Mz=vy(),qz={message({keyword:e,schemaCode:t}){let r=e==="maxLength"?"more":"fewer";return(0,tr.str)`must NOT have ${r} than ${t} characters`},params:({schemaCode:e})=>(0,tr._)`{limit: ${e}}`},Fz={keyword:["maxLength","minLength"],type:"string",schemaType:"number",$data:!0,error:qz,code(e){let{keyword:t,data:r,schemaCode:n,it:o}=e,s=t==="maxLength"?tr.operators.GT:tr.operators.LT,i=o.opts.unicode===!1?(0,tr._)`${r}.length`:(0,tr._)`${(0,Zz.useFunc)(e.gen,Mz.default)}(${r})`;e.fail$data((0,tr._)`${i} ${s} ${n}`)}};ou.default=Fz});var xy=x(su=>{"use strict";Object.defineProperty(su,"__esModule",{value:!0});var Lz=Ue(),Uz=F(),Rr=j(),Vz={message:({schemaCode:e})=>(0,Rr.str)`must match pattern "${e}"`,params:({schemaCode:e})=>(0,Rr._)`{pattern: ${e}}`},Hz={keyword:"pattern",type:"string",schemaType:"string",$data:!0,error:Vz,code(e){let{gen:t,data:r,$data:n,schema:o,schemaCode:s,it:i}=e,a=i.opts.unicodeRegExp?"u":"";if(n){let{regExp:c}=i.opts.code,u=c.code==="new RegExp"?(0,Rr._)`new RegExp`:(0,Uz.useFunc)(t,c),l=t.let("valid");t.try(()=>t.assign(l,(0,Rr._)`${u}(${s}, ${a}).test(${r})`),()=>t.assign(l,!1)),e.fail$data((0,Rr._)`!${l}`)}else{let c=(0,Lz.usePattern)(e,o);e.fail$data((0,Rr._)`!${c}.test(${r})`)}}};su.default=Hz});var Sy=x(iu=>{"use strict";Object.defineProperty(iu,"__esModule",{value:!0});var Bn=j(),Bz={message({keyword:e,schemaCode:t}){let r=e==="maxProperties"?"more":"fewer";return(0,Bn.str)`must NOT have ${r} than ${t} properties`},params:({schemaCode:e})=>(0,Bn._)`{limit: ${e}}`},Jz={keyword:["maxProperties","minProperties"],type:"object",schemaType:"number",$data:!0,error:Bz,code(e){let{keyword:t,data:r,schemaCode:n}=e,o=t==="maxProperties"?Bn.operators.GT:Bn.operators.LT;e.fail$data((0,Bn._)`Object.keys(${r}).length ${o} ${n}`)}};iu.default=Jz});var ky=x(au=>{"use strict";Object.defineProperty(au,"__esModule",{value:!0});var Jn=Ue(),Kn=j(),Kz=F(),Gz={message:({params:{missingProperty:e}})=>(0,Kn.str)`must have required property '${e}'`,params:({params:{missingProperty:e}})=>(0,Kn._)`{missingProperty: ${e}}`},Wz={keyword:"required",type:"object",schemaType:"array",$data:!0,error:Gz,code(e){let{gen:t,schema:r,schemaCode:n,data:o,$data:s,it:i}=e,{opts:a}=i;if(!s&&r.length===0)return;let c=r.length>=a.loopRequired;if(i.allErrors?u():l(),a.strictRequired){let p=e.parentSchema.properties,{definedProperties:m}=e.it;for(let h of r)if(p?.[h]===void 0&&!m.has(h)){let g=i.schemaEnv.baseId+i.errSchemaPath,w=`required property "${h}" is not defined at "${g}" (strictRequired)`;(0,Kz.checkStrictMode)(i,w,i.opts.strictRequired)}}function u(){if(c||s)e.block$data(Kn.nil,d);else for(let p of r)(0,Jn.checkReportMissingProp)(e,p)}function l(){let p=t.let("missing");if(c||s){let m=t.let("valid",!0);e.block$data(m,()=>f(p,m)),e.ok(m)}else t.if((0,Jn.checkMissingProp)(e,r,p)),(0,Jn.reportMissingProp)(e,p),t.else()}function d(){t.forOf("prop",n,p=>{e.setParams({missingProperty:p}),t.if((0,Jn.noPropertyInData)(t,o,p,a.ownProperties),()=>e.error())})}function f(p,m){e.setParams({missingProperty:p}),t.forOf(p,n,()=>{t.assign(m,(0,Jn.propertyInData)(t,o,p,a.ownProperties)),t.if((0,Kn.not)(m),()=>{e.error(),t.break()})},Kn.nil)}}};au.default=Wz});var zy=x(cu=>{"use strict";Object.defineProperty(cu,"__esModule",{value:!0});var Gn=j(),Yz={message({keyword:e,schemaCode:t}){let r=e==="maxItems"?"more":"fewer";return(0,Gn.str)`must NOT have ${r} than ${t} items`},params:({schemaCode:e})=>(0,Gn._)`{limit: ${e}}`},Xz={keyword:["maxItems","minItems"],type:"array",schemaType:"number",$data:!0,error:Yz,code(e){let{keyword:t,data:r,schemaCode:n}=e,o=t==="maxItems"?Gn.operators.GT:Gn.operators.LT;e.fail$data((0,Gn._)`${r}.length ${o} ${n}`)}};cu.default=Xz});var ni=x(uu=>{"use strict";Object.defineProperty(uu,"__esModule",{value:!0});var Py=Pc();Py.code='require("ajv/dist/runtime/equal").default';uu.default=Py});var Ey=x(du=>{"use strict";Object.defineProperty(du,"__esModule",{value:!0});var lu=Cn(),he=j(),Qz=F(),eP=ni(),tP={message:({params:{i:e,j:t}})=>(0,he.str)`must NOT have duplicate items (items ## ${t} and ${e} are identical)`,params:({params:{i:e,j:t}})=>(0,he._)`{i: ${e}, j: ${t}}`},rP={keyword:"uniqueItems",type:"array",schemaType:"boolean",$data:!0,error:tP,code(e){let{gen:t,data:r,$data:n,schema:o,parentSchema:s,schemaCode:i,it:a}=e;if(!n&&!o)return;let c=t.let("valid"),u=s.items?(0,lu.getSchemaTypes)(s.items):[];e.block$data(c,l,(0,he._)`${i} === false`),e.ok(c);function l(){let m=t.let("i",(0,he._)`${r}.length`),h=t.let("j");e.setParams({i:m,j:h}),t.assign(c,!0),t.if((0,he._)`${m} > 1`,()=>(d()?f:p)(m,h))}function d(){return u.length>0&&!u.some(m=>m==="object"||m==="array")}function f(m,h){let g=t.name("item"),w=(0,lu.checkDataTypes)(u,g,a.opts.strictNumbers,lu.DataType.Wrong),v=t.const("indices",(0,he._)`{}`);t.for((0,he._)`;${m}--;`,()=>{t.let(g,(0,he._)`${r}[${m}]`),t.if(w,(0,he._)`continue`),u.length>1&&t.if((0,he._)`typeof ${g} == "string"`,(0,he._)`${g} += "_"`),t.if((0,he._)`typeof ${v}[${g}] == "number"`,()=>{t.assign(h,(0,he._)`${v}[${g}]`),e.error(),t.assign(c,!1).break()}).code((0,he._)`${v}[${g}] = ${m}`)})}function p(m,h){let g=(0,Qz.useFunc)(t,eP.default),w=t.name("outer");t.label(w).for((0,he._)`;${m}--;`,()=>t.for((0,he._)`${h} = ${m}; ${h}--;`,()=>t.if((0,he._)`${g}(${r}[${m}], ${r}[${h}])`,()=>{e.error(),t.assign(c,!1).break(w)})))}}};du.default=rP});var Iy=x(pu=>{"use strict";Object.defineProperty(pu,"__esModule",{value:!0});var fu=j(),nP=F(),oP=ni(),sP={message:"must be equal to constant",params:({schemaCode:e})=>(0,fu._)`{allowedValue: ${e}}`},iP={keyword:"const",$data:!0,error:sP,code(e){let{gen:t,data:r,$data:n,schemaCode:o,schema:s}=e;n||s&&typeof s=="object"?e.fail$data((0,fu._)`!${(0,nP.useFunc)(t,oP.default)}(${r}, ${o})`):e.fail((0,fu._)`${s} !== ${r}`)}};pu.default=iP});var Ty=x(mu=>{"use strict";Object.defineProperty(mu,"__esModule",{value:!0});var Wn=j(),aP=F(),cP=ni(),uP={message:"must be equal to one of the allowed values",params:({schemaCode:e})=>(0,Wn._)`{allowedValues: ${e}}`},lP={keyword:"enum",schemaType:"array",$data:!0,error:uP,code(e){let{gen:t,data:r,$data:n,schema:o,schemaCode:s,it:i}=e;if(!n&&o.length===0)throw new Error("enum must have non-empty array");let a=o.length>=i.opts.loopEnum,c,u=()=>c??(c=(0,aP.useFunc)(t,cP.default)),l;if(a||n)l=t.let("valid"),e.block$data(l,d);else{if(!Array.isArray(o))throw new Error("ajv implementation error");let p=t.const("vSchema",s);l=(0,Wn.or)(...o.map((m,h)=>f(p,h)))}e.pass(l);function d(){t.assign(l,!1),t.forOf("v",s,p=>t.if((0,Wn._)`${u()}(${r}, ${p})`,()=>t.assign(l,!0).break()))}function f(p,m){let h=o[m];return typeof h=="object"&&h!==null?(0,Wn._)`${u()}(${r}, ${p}[${m}])`:(0,Wn._)`${r} === ${h}`}}};mu.default=lP});var Oy=x(hu=>{"use strict";Object.defineProperty(hu,"__esModule",{value:!0});var dP=_y(),fP=wy(),pP=$y(),mP=xy(),hP=Sy(),gP=ky(),yP=zy(),_P=Ey(),wP=Iy(),bP=Ty(),vP=[dP.default,fP.default,pP.default,mP.default,hP.default,gP.default,yP.default,_P.default,{keyword:"type",schemaType:["string","array"]},{keyword:"nullable",schemaType:"boolean"},wP.default,bP.default];hu.default=vP});var yu=x(Yn=>{"use strict";Object.defineProperty(Yn,"__esModule",{value:!0});Yn.validateAdditionalItems=void 0;var rr=j(),gu=F(),$P={message:({params:{len:e}})=>(0,rr.str)`must NOT have more than ${e} items`,params:({params:{len:e}})=>(0,rr._)`{limit: ${e}}`},xP={keyword:"additionalItems",type:"array",schemaType:["boolean","object"],before:"uniqueItems",error:$P,code(e){let{parentSchema:t,it:r}=e,{items:n}=t;if(!Array.isArray(n)){(0,gu.checkStrictMode)(r,'"additionalItems" is ignored when "items" is not an array of schemas');return}Ry(e,n)}};function Ry(e,t){let{gen:r,schema:n,data:o,keyword:s,it:i}=e;i.items=!0;let a=r.const("len",(0,rr._)`${o}.length`);if(n===!1)e.setParams({len:t.length}),e.pass((0,rr._)`${a} <= ${t.length}`);else if(typeof n=="object"&&!(0,gu.alwaysValidSchema)(i,n)){let u=r.var("valid",(0,rr._)`${a} <= ${t.length}`);r.if((0,rr.not)(u),()=>c(u)),e.ok(u)}function c(u){r.forRange("i",t.length,a,l=>{e.subschema({keyword:s,dataProp:l,dataPropType:gu.Type.Num},u),i.allErrors||r.if((0,rr.not)(u),()=>r.break())})}}Yn.validateAdditionalItems=Ry;Yn.default=xP});var _u=x(Xn=>{"use strict";Object.defineProperty(Xn,"__esModule",{value:!0});Xn.validateTuple=void 0;var Ay=j(),oi=F(),SP=Ue(),kP={keyword:"items",type:"array",schemaType:["object","array","boolean"],before:"uniqueItems",code(e){let{schema:t,it:r}=e;if(Array.isArray(t))return Cy(e,"additionalItems",t);r.items=!0,!(0,oi.alwaysValidSchema)(r,t)&&e.ok((0,SP.validateArray)(e))}};function Cy(e,t,r=e.schema){let{gen:n,parentSchema:o,data:s,keyword:i,it:a}=e;l(o),a.opts.unevaluated&&r.length&&a.items!==!0&&(a.items=oi.mergeEvaluated.items(n,r.length,a.items));let c=n.name("valid"),u=n.const("len",(0,Ay._)`${s}.length`);r.forEach((d,f)=>{(0,oi.alwaysValidSchema)(a,d)||(n.if((0,Ay._)`${u} > ${f}`,()=>e.subschema({keyword:i,schemaProp:f,dataProp:f},c)),e.ok(c))});function l(d){let{opts:f,errSchemaPath:p}=a,m=r.length,h=m===d.minItems&&(m===d.maxItems||d[t]===!1);if(f.strictTuples&&!h){let g=`"${i}" is ${m}-tuple, but minItems or maxItems/${t} are not specified or different at path "${p}"`;(0,oi.checkStrictMode)(a,g,f.strictTuples)}}}Xn.validateTuple=Cy;Xn.default=kP});var Ny=x(wu=>{"use strict";Object.defineProperty(wu,"__esModule",{value:!0});var zP=_u(),PP={keyword:"prefixItems",type:"array",schemaType:["array"],before:"uniqueItems",code:e=>(0,zP.validateTuple)(e,"items")};wu.default=PP});var Dy=x(bu=>{"use strict";Object.defineProperty(bu,"__esModule",{value:!0});var jy=j(),EP=F(),IP=Ue(),TP=yu(),OP={message:({params:{len:e}})=>(0,jy.str)`must NOT have more than ${e} items`,params:({params:{len:e}})=>(0,jy._)`{limit: ${e}}`},RP={keyword:"items",type:"array",schemaType:["object","boolean"],before:"uniqueItems",error:OP,code(e){let{schema:t,parentSchema:r,it:n}=e,{prefixItems:o}=r;n.items=!0,!(0,EP.alwaysValidSchema)(n,t)&&(o?(0,TP.validateAdditionalItems)(e,o):e.ok((0,IP.validateArray)(e)))}};bu.default=RP});var Zy=x(vu=>{"use strict";Object.defineProperty(vu,"__esModule",{value:!0});var He=j(),si=F(),AP={message:({params:{min:e,max:t}})=>t===void 0?(0,He.str)`must contain at least ${e} valid item(s)`:(0,He.str)`must contain at least ${e} and no more than ${t} valid item(s)`,params:({params:{min:e,max:t}})=>t===void 0?(0,He._)`{minContains: ${e}}`:(0,He._)`{minContains: ${e}, maxContains: ${t}}`},CP={keyword:"contains",type:"array",schemaType:["object","boolean"],before:"uniqueItems",trackErrors:!0,error:AP,code(e){let{gen:t,schema:r,parentSchema:n,data:o,it:s}=e,i,a,{minContains:c,maxContains:u}=n;s.opts.next?(i=c===void 0?1:c,a=u):i=1;let l=t.const("len",(0,He._)`${o}.length`);if(e.setParams({min:i,max:a}),a===void 0&&i===0){(0,si.checkStrictMode)(s,'"minContains" == 0 without "maxContains": "contains" keyword ignored');return}if(a!==void 0&&i>a){(0,si.checkStrictMode)(s,'"minContains" > "maxContains" is always invalid'),e.fail();return}if((0,si.alwaysValidSchema)(s,r)){let h=(0,He._)`${l} >= ${i}`;a!==void 0&&(h=(0,He._)`${h} && ${l} <= ${a}`),e.pass(h);return}s.items=!0;let d=t.name("valid");a===void 0&&i===1?p(d,()=>t.if(d,()=>t.break())):i===0?(t.let(d,!0),a!==void 0&&t.if((0,He._)`${o}.length > 0`,f)):(t.let(d,!1),f()),e.result(d,()=>e.reset());function f(){let h=t.name("_valid"),g=t.let("count",0);p(h,()=>t.if(h,()=>m(g)))}function p(h,g){t.forRange("i",0,l,w=>{e.subschema({keyword:"contains",dataProp:w,dataPropType:si.Type.Num,compositeRule:!0},h),g()})}function m(h){t.code((0,He._)`${h}++`),a===void 0?t.if((0,He._)`${h} >= ${i}`,()=>t.assign(d,!0).break()):(t.if((0,He._)`${h} > ${a}`,()=>t.assign(d,!1).break()),i===1?t.assign(d,!0):t.if((0,He._)`${h} >= ${i}`,()=>t.assign(d,!0)))}}};vu.default=CP});var Fy=x(ot=>{"use strict";Object.defineProperty(ot,"__esModule",{value:!0});ot.validateSchemaDeps=ot.validatePropertyDeps=ot.error=void 0;var $u=j(),NP=F(),Qn=Ue();ot.error={message:({params:{property:e,depsCount:t,deps:r}})=>{let n=t===1?"property":"properties";return(0,$u.str)`must have ${n} ${r} when property ${e} is present`},params:({params:{property:e,depsCount:t,deps:r,missingProperty:n}})=>(0,$u._)`{property: ${e},
|
|
3
|
+
var Kw=Object.create;var Ei=Object.defineProperty;var Jw=Object.getOwnPropertyDescriptor;var Gw=Object.getOwnPropertyNames;var Ww=Object.getPrototypeOf,Yw=Object.prototype.hasOwnProperty;var S=(e,t)=>()=>{try{return t||e((t={exports:{}}).exports,t),t.exports}catch(r){throw t=0,r}},wl=(e,t)=>{for(var r in t)Ei(e,r,{get:t[r],enumerable:!0})},Xw=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Gw(t))!Yw.call(e,o)&&o!==r&&Ei(e,o,{get:()=>t[o],enumerable:!(n=Jw(t,o))||n.enumerable});return e};var bl=(e,t,r)=>(r=e!=null?Kw(Ww(e)):{},Xw(t||!e||!e.__esModule?Ei(r,"default",{value:e,enumerable:!0}):r,e));var An=S(G=>{"use strict";Object.defineProperty(G,"__esModule",{value:!0});G.regexpCode=G.getEsmExportName=G.getProperty=G.safeStringify=G.stringify=G.strConcat=G.addCodeArg=G.str=G._=G.nil=G._Code=G.Name=G.IDENTIFIER=G._CodeOrName=void 0;var On=class{};G._CodeOrName=On;G.IDENTIFIER=/^[a-z$_][a-z$_0-9]*$/i;var Qt=class extends On{constructor(t){if(super(),!G.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}}};G.Name=Qt;var Ye=class extends On{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 Qt&&(r[n.str]=(r[n.str]||0)+1),r),{})}};G._Code=Ye;G.nil=new Ye("");function Zh(e,...t){let r=[e[0]],n=0;for(;n<t.length;)sc(r,t[n]),r.push(e[++n]);return new Ye(r)}G._=Zh;var oc=new Ye("+");function Mh(e,...t){let r=[Rn(e[0])],n=0;for(;n<t.length;)r.push(oc),sc(r,t[n]),r.push(oc,Rn(e[++n]));return bk(r),new Ye(r)}G.str=Mh;function sc(e,t){t instanceof Ye?e.push(...t._items):t instanceof Qt?e.push(t):e.push(kk(t))}G.addCodeArg=sc;function bk(e){let t=1;for(;t<e.length-1;){if(e[t]===oc){let r=vk(e[t-1],e[t+1]);if(r!==void 0){e.splice(t-1,3,r);continue}e[t++]="+"}t++}}function vk(e,t){if(t==='""')return e;if(e==='""')return t;if(typeof e=="string")return t instanceof Qt||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 Qt))return`"${e}${t.slice(1)}`}function $k(e,t){return t.emptyStr()?e:e.emptyStr()?t:Mh`${e}${t}`}G.strConcat=$k;function kk(e){return typeof e=="number"||typeof e=="boolean"||e===null?e:Rn(Array.isArray(e)?e.join(","):e)}function xk(e){return new Ye(Rn(e))}G.stringify=xk;function Rn(e){return JSON.stringify(e).replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}G.safeStringify=Rn;function Sk(e){return typeof e=="string"&&G.IDENTIFIER.test(e)?new Ye(`.${e}`):Zh`[${e}]`}G.getProperty=Sk;function zk(e){if(typeof e=="string"&&G.IDENTIFIER.test(e))return new Ye(`${e}`);throw new Error(`CodeGen: invalid export name: ${e}, use explicit $id name mapping`)}G.getEsmExportName=zk;function Pk(e){return new Ye(e.toString())}G.regexpCode=Pk});var cc=S(Ze=>{"use strict";Object.defineProperty(Ze,"__esModule",{value:!0});Ze.ValueScope=Ze.ValueScopeName=Ze.Scope=Ze.varKinds=Ze.UsedValueState=void 0;var De=An(),ic=class extends Error{constructor(t){super(`CodeGen: "code" for ${t} not defined`),this.value=t.value}},js;(function(e){e[e.Started=0]="Started",e[e.Completed=1]="Completed"})(js||(Ze.UsedValueState=js={}));Ze.varKinds={const:new De.Name("const"),let:new De.Name("let"),var:new De.Name("var")};var Ds=class{constructor({prefixes:t,parent:r}={}){this._names={},this._prefixes=t,this._parent=r}toName(t){return t instanceof De.Name?t:this.name(t)}name(t){return new De.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}}};Ze.Scope=Ds;var Zs=class extends De.Name{constructor(t,r){super(r),this.prefix=t}setValue(t,{property:r,itemIndex:n}){this.value=t,this.scopePath=(0,De._)`.${new De.Name(r)}[${n}]`}};Ze.ValueScopeName=Zs;var Ik=(0,De._)`\n`,ac=class extends Ds{constructor(t){super(t),this._values={},this._scope=t.scope,this.opts={...t,_n:t.lines?Ik:De.nil}}get(){return this._scope}name(t){return new Zs(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:s}=o,i=(n=r.key)!==null&&n!==void 0?n:r.ref,a=this._values[s];if(a){let l=a.get(i);if(l)return l}else a=this._values[s]=new Map;a.set(i,o);let c=this._scope[s]||(this._scope[s]=[]),u=c.length;return c[u]=r.ref,o.setValue(r,{property:s,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,De._)`${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 s=De.nil;for(let i in t){let a=t[i];if(!a)continue;let c=n[i]=n[i]||new Map;a.forEach(u=>{if(c.has(u))return;c.set(u,js.Started);let l=r(u);if(l){let d=this.opts.es5?Ze.varKinds.var:Ze.varKinds.const;s=(0,De._)`${s}${d} ${u} = ${l};${this.opts._n}`}else if(l=o?.(u))s=(0,De._)`${s}${l}${this.opts._n}`;else throw new ic(u);c.set(u,js.Completed)})}return s}};Ze.ValueScope=ac});var q=S(L=>{"use strict";Object.defineProperty(L,"__esModule",{value:!0});L.or=L.and=L.not=L.CodeGen=L.operators=L.varKinds=L.ValueScopeName=L.ValueScope=L.Scope=L.Name=L.regexpCode=L.stringify=L.getProperty=L.nil=L.strConcat=L.str=L._=void 0;var B=An(),st=cc(),Mt=An();Object.defineProperty(L,"_",{enumerable:!0,get:function(){return Mt._}});Object.defineProperty(L,"str",{enumerable:!0,get:function(){return Mt.str}});Object.defineProperty(L,"strConcat",{enumerable:!0,get:function(){return Mt.strConcat}});Object.defineProperty(L,"nil",{enumerable:!0,get:function(){return Mt.nil}});Object.defineProperty(L,"getProperty",{enumerable:!0,get:function(){return Mt.getProperty}});Object.defineProperty(L,"stringify",{enumerable:!0,get:function(){return Mt.stringify}});Object.defineProperty(L,"regexpCode",{enumerable:!0,get:function(){return Mt.regexpCode}});Object.defineProperty(L,"Name",{enumerable:!0,get:function(){return Mt.Name}});var Ls=cc();Object.defineProperty(L,"Scope",{enumerable:!0,get:function(){return Ls.Scope}});Object.defineProperty(L,"ValueScope",{enumerable:!0,get:function(){return Ls.ValueScope}});Object.defineProperty(L,"ValueScopeName",{enumerable:!0,get:function(){return Ls.ValueScopeName}});Object.defineProperty(L,"varKinds",{enumerable:!0,get:function(){return Ls.varKinds}});L.operators={GT:new B._Code(">"),GTE:new B._Code(">="),LT:new B._Code("<"),LTE:new B._Code("<="),EQ:new B._Code("==="),NEQ:new B._Code("!=="),NOT:new B._Code("!"),OR:new B._Code("||"),AND:new B._Code("&&"),ADD:new B._Code("+")};var $t=class{optimizeNodes(){return this}optimizeNames(t,r){return this}},uc=class extends $t{constructor(t,r,n){super(),this.varKind=t,this.name=r,this.rhs=n}render({es5:t,_n:r}){let n=t?st.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=Ir(this.rhs,t,r)),this}get names(){return this.rhs instanceof B._CodeOrName?this.rhs.names:{}}},Ms=class extends $t{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 B.Name&&!t[this.lhs.str]&&!this.sideEffects))return this.rhs=Ir(this.rhs,t,r),this}get names(){let t=this.lhs instanceof B.Name?{}:{...this.lhs.names};return Fs(t,this.rhs)}},lc=class extends Ms{constructor(t,r,n,o){super(t,n,o),this.op=r}render({_n:t}){return`${this.lhs} ${this.op}= ${this.rhs};`+t}},dc=class extends $t{constructor(t){super(),this.label=t,this.names={}}render({_n:t}){return`${this.label}:`+t}},fc=class extends $t{constructor(t){super(),this.label=t,this.names={}}render({_n:t}){return`break${this.label?` ${this.label}`:""};`+t}},pc=class extends $t{constructor(t){super(),this.error=t}render({_n:t}){return`throw ${this.error};`+t}get names(){return this.error.names}},mc=class extends $t{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=Ir(this.code,t,r),this}get names(){return this.code instanceof B._CodeOrName?this.code.names:{}}},Cn=class extends $t{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 s=n[o];s.optimizeNames(t,r)||(Ek(t,s.names),n.splice(o,1))}return n.length>0?this:void 0}get names(){return this.nodes.reduce((t,r)=>rr(t,r.names),{})}},kt=class extends Cn{render(t){return"{"+t._n+super.render(t)+"}"+t._n}},hc=class extends Cn{},Pr=class extends kt{};Pr.kind="else";var er=class e extends kt{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 Pr(n):n}if(r)return t===!1?r instanceof e?r:r.nodes:this.nodes.length?this:new e(qh(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=Ir(this.condition,t,r),this}get names(){let t=super.names;return Fs(t,this.condition),this.else&&rr(t,this.else.names),t}};er.kind="if";var tr=class extends kt{};tr.kind="for";var gc=class extends tr{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=Ir(this.iteration,t,r),this}get names(){return rr(super.names,this.iteration.names)}},yc=class extends tr{constructor(t,r,n,o){super(),this.varKind=t,this.name=r,this.from=n,this.to=o}render(t){let r=t.es5?st.varKinds.var:this.varKind,{name:n,from:o,to:s}=this;return`for(${r} ${n}=${o}; ${n}<${s}; ${n}++)`+super.render(t)}get names(){let t=Fs(super.names,this.from);return Fs(t,this.to)}},qs=class extends tr{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=Ir(this.iterable,t,r),this}get names(){return rr(super.names,this.iterable.names)}},Nn=class extends kt{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)}};Nn.kind="func";var jn=class extends Cn{render(t){return"return "+super.render(t)}};jn.kind="return";var _c=class extends kt{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&&rr(t,this.catch.names),this.finally&&rr(t,this.finally.names),t}},Dn=class extends kt{constructor(t){super(),this.error=t}render(t){return`catch(${this.error})`+super.render(t)}};Dn.kind="catch";var Zn=class extends kt{render(t){return"finally"+super.render(t)}};Zn.kind="finally";var wc=class{constructor(t,r={}){this._values={},this._blockStarts=[],this._constants={},this.opts={...r,_n:r.lines?`
|
|
4
|
+
`:""},this._extScope=t,this._scope=new st.Scope({parent:t}),this._nodes=[new hc]}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 s=this._scope.toName(r);return n!==void 0&&o&&(this._constants[s.str]=n),this._leafNode(new uc(t,s,n)),s}const(t,r,n){return this._def(st.varKinds.const,t,r,n)}let(t,r,n){return this._def(st.varKinds.let,t,r,n)}var(t,r,n){return this._def(st.varKinds.var,t,r,n)}assign(t,r,n){return this._leafNode(new Ms(t,r,n))}add(t,r){return this._leafNode(new lc(t,L.operators.ADD,r))}code(t){return typeof t=="function"?t():t!==B.nil&&this._leafNode(new mc(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,B.addCodeArg)(r,o));return r.push("}"),new B._Code(r)}if(t,r,n){if(this._blockNode(new er(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 er(t))}else(){return this._elseNode(new Pr)}endIf(){return this._endBlockNode(er,Pr)}_for(t,r){return this._blockNode(t),r&&this.code(r).endFor(),this}for(t,r){return this._for(new gc(t),r)}forRange(t,r,n,o,s=this.opts.es5?st.varKinds.var:st.varKinds.let){let i=this._scope.toName(t);return this._for(new yc(s,i,r,n),()=>o(i))}forOf(t,r,n,o=st.varKinds.const){let s=this._scope.toName(t);if(this.opts.es5){let i=r instanceof B.Name?r:this.var("_arr",r);return this.forRange("_i",0,(0,B._)`${i}.length`,a=>{this.var(s,(0,B._)`${i}[${a}]`),n(s)})}return this._for(new qs("of",o,s,r),()=>n(s))}forIn(t,r,n,o=this.opts.es5?st.varKinds.var:st.varKinds.const){if(this.opts.ownProperties)return this.forOf(t,(0,B._)`Object.keys(${r})`,n);let s=this._scope.toName(t);return this._for(new qs("in",o,s,r),()=>n(s))}endFor(){return this._endBlockNode(tr)}label(t){return this._leafNode(new dc(t))}break(t){return this._leafNode(new fc(t))}return(t){let r=new jn;if(this._blockNode(r),this.code(t),r.nodes.length!==1)throw new Error('CodeGen: "return" should have one node');return this._endBlockNode(jn)}try(t,r,n){if(!r&&!n)throw new Error('CodeGen: "try" without "catch" and "finally"');let o=new _c;if(this._blockNode(o),this.code(t),r){let s=this.name("e");this._currNode=o.catch=new Dn(s),r(s)}return n&&(this._currNode=o.finally=new Zn,this.code(n)),this._endBlockNode(Dn,Zn)}throw(t){return this._leafNode(new pc(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=B.nil,n,o){return this._blockNode(new Nn(t,r,n)),o&&this.code(o).endFunc(),this}endFunc(){return this._endBlockNode(Nn)}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 er))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}};L.CodeGen=wc;function rr(e,t){for(let r in t)e[r]=(e[r]||0)+(t[r]||0);return e}function Fs(e,t){return t instanceof B._CodeOrName?rr(e,t.names):e}function Ir(e,t,r){if(e instanceof B.Name)return n(e);if(!o(e))return e;return new B._Code(e._items.reduce((s,i)=>(i instanceof B.Name&&(i=n(i)),i instanceof B._Code?s.push(...i._items):s.push(i),s),[]));function n(s){let i=r[s.str];return i===void 0||t[s.str]!==1?s:(delete t[s.str],i)}function o(s){return s instanceof B._Code&&s._items.some(i=>i instanceof B.Name&&t[i.str]===1&&r[i.str]!==void 0)}}function Ek(e,t){for(let r in t)e[r]=(e[r]||0)-(t[r]||0)}function qh(e){return typeof e=="boolean"||typeof e=="number"||e===null?!e:(0,B._)`!${bc(e)}`}L.not=qh;var Tk=Fh(L.operators.AND);function Ok(...e){return e.reduce(Tk)}L.and=Ok;var Rk=Fh(L.operators.OR);function Ak(...e){return e.reduce(Rk)}L.or=Ak;function Fh(e){return(t,r)=>t===B.nil?r:r===B.nil?t:(0,B._)`${bc(t)} ${e} ${bc(r)}`}function bc(e){return e instanceof B.Name?e:(0,B._)`(${e})`}});var H=S(U=>{"use strict";Object.defineProperty(U,"__esModule",{value:!0});U.checkStrictMode=U.getErrorPath=U.Type=U.useFunc=U.setEvaluated=U.evaluatedPropsToName=U.mergeEvaluated=U.eachItem=U.unescapeJsonPointer=U.escapeJsonPointer=U.escapeFragment=U.unescapeFragment=U.schemaRefOrVal=U.schemaHasRulesButRef=U.schemaHasRules=U.checkUnknownRules=U.alwaysValidSchema=U.toHash=void 0;var X=q(),Ck=An();function Nk(e){let t={};for(let r of e)t[r]=!0;return t}U.toHash=Nk;function jk(e,t){return typeof t=="boolean"?t:Object.keys(t).length===0?!0:(Vh(e,t),!Bh(t,e.self.RULES.all))}U.alwaysValidSchema=jk;function Vh(e,t=e.schema){let{opts:r,self:n}=e;if(!r.strictSchema||typeof t=="boolean")return;let o=n.RULES.keywords;for(let s in t)o[s]||Jh(e,`unknown keyword: "${s}"`)}U.checkUnknownRules=Vh;function Bh(e,t){if(typeof e=="boolean")return!e;for(let r in e)if(t[r])return!0;return!1}U.schemaHasRules=Bh;function Dk(e,t){if(typeof e=="boolean")return!e;for(let r in e)if(r!=="$ref"&&t.all[r])return!0;return!1}U.schemaHasRulesButRef=Dk;function Zk({topSchemaRef:e,schemaPath:t},r,n,o){if(!o){if(typeof r=="number"||typeof r=="boolean")return r;if(typeof r=="string")return(0,X._)`${r}`}return(0,X._)`${e}${t}${(0,X.getProperty)(n)}`}U.schemaRefOrVal=Zk;function Mk(e){return Hh(decodeURIComponent(e))}U.unescapeFragment=Mk;function qk(e){return encodeURIComponent($c(e))}U.escapeFragment=qk;function $c(e){return typeof e=="number"?`${e}`:e.replace(/~/g,"~0").replace(/\//g,"~1")}U.escapeJsonPointer=$c;function Hh(e){return e.replace(/~1/g,"/").replace(/~0/g,"~")}U.unescapeJsonPointer=Hh;function Fk(e,t){if(Array.isArray(e))for(let r of e)t(r);else t(e)}U.eachItem=Fk;function Lh({mergeNames:e,mergeToName:t,mergeValues:r,resultToName:n}){return(o,s,i,a)=>{let c=i===void 0?s:i instanceof X.Name?(s instanceof X.Name?e(o,s,i):t(o,s,i),i):s instanceof X.Name?(t(o,i,s),s):r(s,i);return a===X.Name&&!(c instanceof X.Name)?n(o,c):c}}U.mergeEvaluated={props:Lh({mergeNames:(e,t,r)=>e.if((0,X._)`${r} !== true && ${t} !== undefined`,()=>{e.if((0,X._)`${t} === true`,()=>e.assign(r,!0),()=>e.assign(r,(0,X._)`${r} || {}`).code((0,X._)`Object.assign(${r}, ${t})`))}),mergeToName:(e,t,r)=>e.if((0,X._)`${r} !== true`,()=>{t===!0?e.assign(r,!0):(e.assign(r,(0,X._)`${r} || {}`),kc(e,r,t))}),mergeValues:(e,t)=>e===!0?!0:{...e,...t},resultToName:Kh}),items:Lh({mergeNames:(e,t,r)=>e.if((0,X._)`${r} !== true && ${t} !== undefined`,()=>e.assign(r,(0,X._)`${t} === true ? true : ${r} > ${t} ? ${r} : ${t}`)),mergeToName:(e,t,r)=>e.if((0,X._)`${r} !== true`,()=>e.assign(r,t===!0?!0:(0,X._)`${r} > ${t} ? ${r} : ${t}`)),mergeValues:(e,t)=>e===!0?!0:Math.max(e,t),resultToName:(e,t)=>e.var("items",t)})};function Kh(e,t){if(t===!0)return e.var("props",!0);let r=e.var("props",(0,X._)`{}`);return t!==void 0&&kc(e,r,t),r}U.evaluatedPropsToName=Kh;function kc(e,t,r){Object.keys(r).forEach(n=>e.assign((0,X._)`${t}${(0,X.getProperty)(n)}`,!0))}U.setEvaluated=kc;var Uh={};function Lk(e,t){return e.scopeValue("func",{ref:t,code:Uh[t.code]||(Uh[t.code]=new Ck._Code(t.code))})}U.useFunc=Lk;var vc;(function(e){e[e.Num=0]="Num",e[e.Str=1]="Str"})(vc||(U.Type=vc={}));function Uk(e,t,r){if(e instanceof X.Name){let n=t===vc.Num;return r?n?(0,X._)`"[" + ${e} + "]"`:(0,X._)`"['" + ${e} + "']"`:n?(0,X._)`"/" + ${e}`:(0,X._)`"/" + ${e}.replace(/~/g, "~0").replace(/\\//g, "~1")`}return r?(0,X.getProperty)(e).toString():"/"+$c(e)}U.getErrorPath=Uk;function Jh(e,t,r=e.opts.strictSchema){if(r){if(t=`strict mode: ${t}`,r===!0)throw new Error(t);e.self.logger.warn(t)}}U.checkStrictMode=Jh});var xt=S(xc=>{"use strict";Object.defineProperty(xc,"__esModule",{value:!0});var ke=q(),Vk={data:new ke.Name("data"),valCxt:new ke.Name("valCxt"),instancePath:new ke.Name("instancePath"),parentData:new ke.Name("parentData"),parentDataProperty:new ke.Name("parentDataProperty"),rootData:new ke.Name("rootData"),dynamicAnchors:new ke.Name("dynamicAnchors"),vErrors:new ke.Name("vErrors"),errors:new ke.Name("errors"),this:new ke.Name("this"),self:new ke.Name("self"),scope:new ke.Name("scope"),json:new ke.Name("json"),jsonPos:new ke.Name("jsonPos"),jsonLen:new ke.Name("jsonLen"),jsonPart:new ke.Name("jsonPart")};xc.default=Vk});var Mn=S(xe=>{"use strict";Object.defineProperty(xe,"__esModule",{value:!0});xe.extendErrors=xe.resetErrorsCount=xe.reportExtraError=xe.reportError=xe.keyword$DataError=xe.keywordError=void 0;var K=q(),Us=H(),Re=xt();xe.keywordError={message:({keyword:e})=>(0,K.str)`must pass "${e}" keyword validation`};xe.keyword$DataError={message:({keyword:e,schemaType:t})=>t?(0,K.str)`"${e}" keyword must be ${t} ($data)`:(0,K.str)`"${e}" keyword is invalid ($data)`};function Bk(e,t=xe.keywordError,r,n){let{it:o}=e,{gen:s,compositeRule:i,allErrors:a}=o,c=Yh(e,t,r);n??(i||a)?Gh(s,c):Wh(o,(0,K._)`[${c}]`)}xe.reportError=Bk;function Hk(e,t=xe.keywordError,r){let{it:n}=e,{gen:o,compositeRule:s,allErrors:i}=n,a=Yh(e,t,r);Gh(o,a),s||i||Wh(n,Re.default.vErrors)}xe.reportExtraError=Hk;function Kk(e,t){e.assign(Re.default.errors,t),e.if((0,K._)`${Re.default.vErrors} !== null`,()=>e.if(t,()=>e.assign((0,K._)`${Re.default.vErrors}.length`,t),()=>e.assign(Re.default.vErrors,null)))}xe.resetErrorsCount=Kk;function Jk({gen:e,keyword:t,schemaValue:r,data:n,errsCount:o,it:s}){if(o===void 0)throw new Error("ajv implementation error");let i=e.name("err");e.forRange("i",o,Re.default.errors,a=>{e.const(i,(0,K._)`${Re.default.vErrors}[${a}]`),e.if((0,K._)`${i}.instancePath === undefined`,()=>e.assign((0,K._)`${i}.instancePath`,(0,K.strConcat)(Re.default.instancePath,s.errorPath))),e.assign((0,K._)`${i}.schemaPath`,(0,K.str)`${s.errSchemaPath}/${t}`),s.opts.verbose&&(e.assign((0,K._)`${i}.schema`,r),e.assign((0,K._)`${i}.data`,n))})}xe.extendErrors=Jk;function Gh(e,t){let r=e.const("err",t);e.if((0,K._)`${Re.default.vErrors} === null`,()=>e.assign(Re.default.vErrors,(0,K._)`[${r}]`),(0,K._)`${Re.default.vErrors}.push(${r})`),e.code((0,K._)`${Re.default.errors}++`)}function Wh(e,t){let{gen:r,validateName:n,schemaEnv:o}=e;o.$async?r.throw((0,K._)`new ${e.ValidationError}(${t})`):(r.assign((0,K._)`${n}.errors`,t),r.return(!1))}var nr={keyword:new K.Name("keyword"),schemaPath:new K.Name("schemaPath"),params:new K.Name("params"),propertyName:new K.Name("propertyName"),message:new K.Name("message"),schema:new K.Name("schema"),parentSchema:new K.Name("parentSchema")};function Yh(e,t,r){let{createErrors:n}=e.it;return n===!1?(0,K._)`{}`:Gk(e,t,r)}function Gk(e,t,r={}){let{gen:n,it:o}=e,s=[Wk(o,r),Yk(e,r)];return Xk(e,t,s),n.object(...s)}function Wk({errorPath:e},{instancePath:t}){let r=t?(0,K.str)`${e}${(0,Us.getErrorPath)(t,Us.Type.Str)}`:e;return[Re.default.instancePath,(0,K.strConcat)(Re.default.instancePath,r)]}function Yk({keyword:e,it:{errSchemaPath:t}},{schemaPath:r,parentSchema:n}){let o=n?t:(0,K.str)`${t}/${e}`;return r&&(o=(0,K.str)`${o}${(0,Us.getErrorPath)(r,Us.Type.Str)}`),[nr.schemaPath,o]}function Xk(e,{params:t,message:r},n){let{keyword:o,data:s,schemaValue:i,it:a}=e,{opts:c,propertyName:u,topSchemaRef:l,schemaPath:d}=a;n.push([nr.keyword,o],[nr.params,typeof t=="function"?t(e):t||(0,K._)`{}`]),c.messages&&n.push([nr.message,typeof r=="function"?r(e):r]),c.verbose&&n.push([nr.schema,i],[nr.parentSchema,(0,K._)`${l}${d}`],[Re.default.data,s]),u&&n.push([nr.propertyName,u])}});var Qh=S(Er=>{"use strict";Object.defineProperty(Er,"__esModule",{value:!0});Er.boolOrEmptySchema=Er.topBoolOrEmptySchema=void 0;var Qk=Mn(),ex=q(),tx=xt(),rx={message:"boolean schema is false"};function nx(e){let{gen:t,schema:r,validateName:n}=e;r===!1?Xh(e,!1):typeof r=="object"&&r.$async===!0?t.return(tx.default.data):(t.assign((0,ex._)`${n}.errors`,null),t.return(!0))}Er.topBoolOrEmptySchema=nx;function ox(e,t){let{gen:r,schema:n}=e;n===!1?(r.var(t,!1),Xh(e)):r.var(t,!0)}Er.boolOrEmptySchema=ox;function Xh(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,Qk.reportError)(o,rx,void 0,t)}});var Sc=S(Tr=>{"use strict";Object.defineProperty(Tr,"__esModule",{value:!0});Tr.getRules=Tr.isJSONType=void 0;var sx=["string","number","integer","boolean","null","object","array"],ix=new Set(sx);function ax(e){return typeof e=="string"&&ix.has(e)}Tr.isJSONType=ax;function cx(){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:{}}}Tr.getRules=cx});var zc=S(qt=>{"use strict";Object.defineProperty(qt,"__esModule",{value:!0});qt.shouldUseRule=qt.shouldUseGroup=qt.schemaHasRulesForType=void 0;function ux({schema:e,self:t},r){let n=t.RULES.types[r];return n&&n!==!0&&eg(e,n)}qt.schemaHasRulesForType=ux;function eg(e,t){return t.rules.some(r=>tg(e,r))}qt.shouldUseGroup=eg;function tg(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))}qt.shouldUseRule=tg});var qn=S(Se=>{"use strict";Object.defineProperty(Se,"__esModule",{value:!0});Se.reportTypeError=Se.checkDataTypes=Se.checkDataType=Se.coerceAndCheckDataType=Se.getJSONTypes=Se.getSchemaTypes=Se.DataType=void 0;var lx=Sc(),dx=zc(),fx=Mn(),Z=q(),rg=H(),Or;(function(e){e[e.Correct=0]="Correct",e[e.Wrong=1]="Wrong"})(Or||(Se.DataType=Or={}));function px(e){let t=ng(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}Se.getSchemaTypes=px;function ng(e){let t=Array.isArray(e)?e:e?[e]:[];if(t.every(lx.isJSONType))return t;throw new Error("type must be JSONType or JSONType[]: "+t.join(","))}Se.getJSONTypes=ng;function mx(e,t){let{gen:r,data:n,opts:o}=e,s=hx(t,o.coerceTypes),i=t.length>0&&!(s.length===0&&t.length===1&&(0,dx.schemaHasRulesForType)(e,t[0]));if(i){let a=Ic(t,n,o.strictNumbers,Or.Wrong);r.if(a,()=>{s.length?gx(e,t,s):Ec(e)})}return i}Se.coerceAndCheckDataType=mx;var og=new Set(["string","number","integer","boolean","null"]);function hx(e,t){return t?e.filter(r=>og.has(r)||t==="array"&&r==="array"):[]}function gx(e,t,r){let{gen:n,data:o,opts:s}=e,i=n.let("dataType",(0,Z._)`typeof ${o}`),a=n.let("coerced",(0,Z._)`undefined`);s.coerceTypes==="array"&&n.if((0,Z._)`${i} == 'object' && Array.isArray(${o}) && ${o}.length == 1`,()=>n.assign(o,(0,Z._)`${o}[0]`).assign(i,(0,Z._)`typeof ${o}`).if(Ic(t,o,s.strictNumbers),()=>n.assign(a,o))),n.if((0,Z._)`${a} !== undefined`);for(let u of r)(og.has(u)||u==="array"&&s.coerceTypes==="array")&&c(u);n.else(),Ec(e),n.endIf(),n.if((0,Z._)`${a} !== undefined`,()=>{n.assign(o,a),yx(e,a)});function c(u){switch(u){case"string":n.elseIf((0,Z._)`${i} == "number" || ${i} == "boolean"`).assign(a,(0,Z._)`"" + ${o}`).elseIf((0,Z._)`${o} === null`).assign(a,(0,Z._)`""`);return;case"number":n.elseIf((0,Z._)`${i} == "boolean" || ${o} === null
|
|
5
|
+
|| (${i} == "string" && ${o} && ${o} == +${o})`).assign(a,(0,Z._)`+${o}`);return;case"integer":n.elseIf((0,Z._)`${i} === "boolean" || ${o} === null
|
|
6
|
+
|| (${i} === "string" && ${o} && ${o} == +${o} && !(${o} % 1))`).assign(a,(0,Z._)`+${o}`);return;case"boolean":n.elseIf((0,Z._)`${o} === "false" || ${o} === 0 || ${o} === null`).assign(a,!1).elseIf((0,Z._)`${o} === "true" || ${o} === 1`).assign(a,!0);return;case"null":n.elseIf((0,Z._)`${o} === "" || ${o} === 0 || ${o} === false`),n.assign(a,null);return;case"array":n.elseIf((0,Z._)`${i} === "string" || ${i} === "number"
|
|
7
|
+
|| ${i} === "boolean" || ${o} === null`).assign(a,(0,Z._)`[${o}]`)}}}function yx({gen:e,parentData:t,parentDataProperty:r},n){e.if((0,Z._)`${t} !== undefined`,()=>e.assign((0,Z._)`${t}[${r}]`,n))}function Pc(e,t,r,n=Or.Correct){let o=n===Or.Correct?Z.operators.EQ:Z.operators.NEQ,s;switch(e){case"null":return(0,Z._)`${t} ${o} null`;case"array":s=(0,Z._)`Array.isArray(${t})`;break;case"object":s=(0,Z._)`${t} && typeof ${t} == "object" && !Array.isArray(${t})`;break;case"integer":s=i((0,Z._)`!(${t} % 1) && !isNaN(${t})`);break;case"number":s=i();break;default:return(0,Z._)`typeof ${t} ${o} ${e}`}return n===Or.Correct?s:(0,Z.not)(s);function i(a=Z.nil){return(0,Z.and)((0,Z._)`typeof ${t} == "number"`,a,r?(0,Z._)`isFinite(${t})`:Z.nil)}}Se.checkDataType=Pc;function Ic(e,t,r,n){if(e.length===1)return Pc(e[0],t,r,n);let o,s=(0,rg.toHash)(e);if(s.array&&s.object){let i=(0,Z._)`typeof ${t} != "object"`;o=s.null?i:(0,Z._)`!${t} || ${i}`,delete s.null,delete s.array,delete s.object}else o=Z.nil;s.number&&delete s.integer;for(let i in s)o=(0,Z.and)(o,Pc(i,t,r,n));return o}Se.checkDataTypes=Ic;var _x={message:({schema:e})=>`must be ${e}`,params:({schema:e,schemaValue:t})=>typeof e=="string"?(0,Z._)`{type: ${e}}`:(0,Z._)`{type: ${t}}`};function Ec(e){let t=wx(e);(0,fx.reportError)(t,_x)}Se.reportTypeError=Ec;function wx(e){let{gen:t,data:r,schema:n}=e,o=(0,rg.schemaRefOrVal)(e,n,"type");return{gen:t,keyword:"type",data:r,schema:n.type,schemaCode:o,schemaValue:o,parentSchema:n,params:{},it:e}}});var ig=S(Vs=>{"use strict";Object.defineProperty(Vs,"__esModule",{value:!0});Vs.assignDefaults=void 0;var Rr=q(),bx=H();function vx(e,t){let{properties:r,items:n}=e.schema;if(t==="object"&&r)for(let o in r)sg(e,o,r[o].default);else t==="array"&&Array.isArray(n)&&n.forEach((o,s)=>sg(e,s,o.default))}Vs.assignDefaults=vx;function sg(e,t,r){let{gen:n,compositeRule:o,data:s,opts:i}=e;if(r===void 0)return;let a=(0,Rr._)`${s}${(0,Rr.getProperty)(t)}`;if(o){(0,bx.checkStrictMode)(e,`default is ignored for: ${a}`);return}let c=(0,Rr._)`${a} === undefined`;i.useDefaults==="empty"&&(c=(0,Rr._)`${c} || ${a} === null || ${a} === ""`),n.if(c,(0,Rr._)`${a} = ${(0,Rr.stringify)(r)}`)}});var Xe=S(Y=>{"use strict";Object.defineProperty(Y,"__esModule",{value:!0});Y.validateUnion=Y.validateArray=Y.usePattern=Y.callValidateCode=Y.schemaProperties=Y.allSchemaProperties=Y.noPropertyInData=Y.propertyInData=Y.isOwnProperty=Y.hasPropFunc=Y.reportMissingProp=Y.checkMissingProp=Y.checkReportMissingProp=void 0;var ne=q(),Tc=H(),Ft=xt(),$x=H();function kx(e,t){let{gen:r,data:n,it:o}=e;r.if(Rc(r,n,t,o.opts.ownProperties),()=>{e.setParams({missingProperty:(0,ne._)`${t}`},!0),e.error()})}Y.checkReportMissingProp=kx;function xx({gen:e,data:t,it:{opts:r}},n,o){return(0,ne.or)(...n.map(s=>(0,ne.and)(Rc(e,t,s,r.ownProperties),(0,ne._)`${o} = ${s}`)))}Y.checkMissingProp=xx;function Sx(e,t){e.setParams({missingProperty:t},!0),e.error()}Y.reportMissingProp=Sx;function ag(e){return e.scopeValue("func",{ref:Object.prototype.hasOwnProperty,code:(0,ne._)`Object.prototype.hasOwnProperty`})}Y.hasPropFunc=ag;function Oc(e,t,r){return(0,ne._)`${ag(e)}.call(${t}, ${r})`}Y.isOwnProperty=Oc;function zx(e,t,r,n){let o=(0,ne._)`${t}${(0,ne.getProperty)(r)} !== undefined`;return n?(0,ne._)`${o} && ${Oc(e,t,r)}`:o}Y.propertyInData=zx;function Rc(e,t,r,n){let o=(0,ne._)`${t}${(0,ne.getProperty)(r)} === undefined`;return n?(0,ne.or)(o,(0,ne.not)(Oc(e,t,r))):o}Y.noPropertyInData=Rc;function cg(e){return e?Object.keys(e).filter(t=>t!=="__proto__"):[]}Y.allSchemaProperties=cg;function Px(e,t){return cg(t).filter(r=>!(0,Tc.alwaysValidSchema)(e,t[r]))}Y.schemaProperties=Px;function Ix({schemaCode:e,data:t,it:{gen:r,topSchemaRef:n,schemaPath:o,errorPath:s},it:i},a,c,u){let l=u?(0,ne._)`${e}, ${t}, ${n}${o}`:t,d=[[Ft.default.instancePath,(0,ne.strConcat)(Ft.default.instancePath,s)],[Ft.default.parentData,i.parentData],[Ft.default.parentDataProperty,i.parentDataProperty],[Ft.default.rootData,Ft.default.rootData]];i.opts.dynamicRef&&d.push([Ft.default.dynamicAnchors,Ft.default.dynamicAnchors]);let f=(0,ne._)`${l}, ${r.object(...d)}`;return c!==ne.nil?(0,ne._)`${a}.call(${c}, ${f})`:(0,ne._)`${a}(${f})`}Y.callValidateCode=Ix;var Ex=(0,ne._)`new RegExp`;function Tx({gen:e,it:{opts:t}},r){let n=t.unicodeRegExp?"u":"",{regExp:o}=t.code,s=o(r,n);return e.scopeValue("pattern",{key:s.toString(),ref:s,code:(0,ne._)`${o.code==="new RegExp"?Ex:(0,$x.useFunc)(e,o)}(${r}, ${n})`})}Y.usePattern=Tx;function Ox(e){let{gen:t,data:r,keyword:n,it:o}=e,s=t.name("valid");if(o.allErrors){let a=t.let("valid",!0);return i(()=>t.assign(a,!1)),a}return t.var(s,!0),i(()=>t.break()),s;function i(a){let c=t.const("len",(0,ne._)`${r}.length`);t.forRange("i",0,c,u=>{e.subschema({keyword:n,dataProp:u,dataPropType:Tc.Type.Num},s),t.if((0,ne.not)(s),a)})}}Y.validateArray=Ox;function Rx(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,Tc.alwaysValidSchema)(o,c))&&!o.opts.unevaluated)return;let i=t.let("valid",!1),a=t.name("_valid");t.block(()=>r.forEach((c,u)=>{let l=e.subschema({keyword:n,schemaProp:u,compositeRule:!0},a);t.assign(i,(0,ne._)`${i} || ${a}`),e.mergeValidEvaluated(l,a)||t.if((0,ne.not)(i))})),e.result(i,()=>e.reset(),()=>e.error(!0))}Y.validateUnion=Rx});var dg=S(lt=>{"use strict";Object.defineProperty(lt,"__esModule",{value:!0});lt.validateKeywordUsage=lt.validSchemaType=lt.funcKeywordCode=lt.macroKeywordCode=void 0;var Ae=q(),or=xt(),Ax=Xe(),Cx=Mn();function Nx(e,t){let{gen:r,keyword:n,schema:o,parentSchema:s,it:i}=e,a=t.macro.call(i.self,o,s,i),c=lg(r,n,a);i.opts.validateSchema!==!1&&i.self.validateSchema(a,!0);let u=r.name("valid");e.subschema({schema:a,schemaPath:Ae.nil,errSchemaPath:`${i.errSchemaPath}/${n}`,topSchemaRef:c,compositeRule:!0},u),e.pass(u,()=>e.error(!0))}lt.macroKeywordCode=Nx;function jx(e,t){var r;let{gen:n,keyword:o,schema:s,parentSchema:i,$data:a,it:c}=e;Zx(c,t);let u=!a&&t.compile?t.compile.call(c.self,s,i,c):t.validate,l=lg(n,o,u),d=n.let("valid");e.block$data(d,f),e.ok((r=t.valid)!==null&&r!==void 0?r:d);function f(){if(t.errors===!1)h(),t.modifying&&ug(e),g(()=>e.error());else{let y=t.async?p():m();t.modifying&&ug(e),g(()=>Dx(e,y))}}function p(){let y=n.let("ruleErrs",null);return n.try(()=>h((0,Ae._)`await `),v=>n.assign(d,!1).if((0,Ae._)`${v} instanceof ${c.ValidationError}`,()=>n.assign(y,(0,Ae._)`${v}.errors`),()=>n.throw(v))),y}function m(){let y=(0,Ae._)`${l}.errors`;return n.assign(y,null),h(Ae.nil),y}function h(y=t.async?(0,Ae._)`await `:Ae.nil){let v=c.opts.passContext?or.default.this:or.default.self,k=!("compile"in t&&!a||t.schema===!1);n.assign(d,(0,Ae._)`${y}${(0,Ax.callValidateCode)(e,l,v,k)}`,t.modifying)}function g(y){var v;n.if((0,Ae.not)((v=t.valid)!==null&&v!==void 0?v:d),y)}}lt.funcKeywordCode=jx;function ug(e){let{gen:t,data:r,it:n}=e;t.if(n.parentData,()=>t.assign(r,(0,Ae._)`${n.parentData}[${n.parentDataProperty}]`))}function Dx(e,t){let{gen:r}=e;r.if((0,Ae._)`Array.isArray(${t})`,()=>{r.assign(or.default.vErrors,(0,Ae._)`${or.default.vErrors} === null ? ${t} : ${or.default.vErrors}.concat(${t})`).assign(or.default.errors,(0,Ae._)`${or.default.vErrors}.length`),(0,Cx.extendErrors)(e)},()=>e.error())}function Zx({schemaEnv:e},t){if(t.async&&!e.$async)throw new Error("async keyword in sync schema")}function lg(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,Ae.stringify)(r)})}function Mx(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")}lt.validSchemaType=Mx;function qx({schema:e,opts:t,self:r,errSchemaPath:n},o,s){if(Array.isArray(o.keyword)?!o.keyword.includes(s):o.keyword!==s)throw new Error("ajv implementation error");let i=o.dependencies;if(i?.some(a=>!Object.prototype.hasOwnProperty.call(e,a)))throw new Error(`parent schema must have dependencies of ${s}: ${i.join(",")}`);if(o.validateSchema&&!o.validateSchema(e[s])){let c=`keyword "${s}" value is invalid at path "${n}": `+r.errorsText(o.validateSchema.errors);if(t.validateSchema==="log")r.logger.error(c);else throw new Error(c)}}lt.validateKeywordUsage=qx});var pg=S(Lt=>{"use strict";Object.defineProperty(Lt,"__esModule",{value:!0});Lt.extendSubschemaMode=Lt.extendSubschemaData=Lt.getSubschema=void 0;var dt=q(),fg=H();function Fx(e,{keyword:t,schemaProp:r,schema:n,schemaPath:o,errSchemaPath:s,topSchemaRef:i}){if(t!==void 0&&n!==void 0)throw new Error('both "keyword" and "schema" passed, only one allowed');if(t!==void 0){let a=e.schema[t];return r===void 0?{schema:a,schemaPath:(0,dt._)`${e.schemaPath}${(0,dt.getProperty)(t)}`,errSchemaPath:`${e.errSchemaPath}/${t}`}:{schema:a[r],schemaPath:(0,dt._)`${e.schemaPath}${(0,dt.getProperty)(t)}${(0,dt.getProperty)(r)}`,errSchemaPath:`${e.errSchemaPath}/${t}/${(0,fg.escapeFragment)(r)}`}}if(n!==void 0){if(o===void 0||s===void 0||i===void 0)throw new Error('"schemaPath", "errSchemaPath" and "topSchemaRef" are required with "schema"');return{schema:n,schemaPath:o,topSchemaRef:i,errSchemaPath:s}}throw new Error('either "keyword" or "schema" must be passed')}Lt.getSubschema=Fx;function Lx(e,t,{dataProp:r,dataPropType:n,data:o,dataTypes:s,propertyName:i}){if(o!==void 0&&r!==void 0)throw new Error('both "data" and "dataProp" passed, only one allowed');let{gen:a}=t;if(r!==void 0){let{errorPath:u,dataPathArr:l,opts:d}=t,f=a.let("data",(0,dt._)`${t.data}${(0,dt.getProperty)(r)}`,!0);c(f),e.errorPath=(0,dt.str)`${u}${(0,fg.getErrorPath)(r,n,d.jsPropertySyntax)}`,e.parentDataProperty=(0,dt._)`${r}`,e.dataPathArr=[...l,e.parentDataProperty]}if(o!==void 0){let u=o instanceof dt.Name?o:a.let("data",o,!0);c(u),i!==void 0&&(e.propertyName=i)}s&&(e.dataTypes=s);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]}}Lt.extendSubschemaData=Lx;function Ux(e,{jtdDiscriminator:t,jtdMetadata:r,compositeRule:n,createErrors:o,allErrors:s}){n!==void 0&&(e.compositeRule=n),o!==void 0&&(e.createErrors=o),s!==void 0&&(e.allErrors=s),e.jtdDiscriminator=t,e.jtdMetadata=r}Lt.extendSubschemaMode=Ux});var Ac=S((pD,mg)=>{"use strict";mg.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,s;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(s=Object.keys(t),n=s.length,n!==Object.keys(r).length)return!1;for(o=n;o--!==0;)if(!Object.prototype.hasOwnProperty.call(r,s[o]))return!1;for(o=n;o--!==0;){var i=s[o];if(!e(t[i],r[i]))return!1}return!0}return t!==t&&r!==r}});var gg=S((mD,hg)=>{"use strict";var Ut=hg.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(){};Bs(t,n,o,e,"",e)};Ut.keywords={additionalItems:!0,items:!0,contains:!0,additionalProperties:!0,propertyNames:!0,not:!0,if:!0,then:!0,else:!0};Ut.arrayKeywords={items:!0,allOf:!0,anyOf:!0,oneOf:!0};Ut.propsKeywords={$defs:!0,definitions:!0,properties:!0,patternProperties:!0,dependencies:!0};Ut.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 Bs(e,t,r,n,o,s,i,a,c,u){if(n&&typeof n=="object"&&!Array.isArray(n)){t(n,o,s,i,a,c,u);for(var l in n){var d=n[l];if(Array.isArray(d)){if(l in Ut.arrayKeywords)for(var f=0;f<d.length;f++)Bs(e,t,r,d[f],o+"/"+l+"/"+f,s,o,l,n,f)}else if(l in Ut.propsKeywords){if(d&&typeof d=="object")for(var p in d)Bs(e,t,r,d[p],o+"/"+l+"/"+Vx(p),s,o,l,n,p)}else(l in Ut.keywords||e.allKeys&&!(l in Ut.skipKeywords))&&Bs(e,t,r,d,o+"/"+l,s,o,l,n)}r(n,o,s,i,a,c,u)}}function Vx(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}});var Fn=S(Me=>{"use strict";Object.defineProperty(Me,"__esModule",{value:!0});Me.getSchemaRefs=Me.resolveUrl=Me.normalizeId=Me._getFullPath=Me.getFullPath=Me.inlineRef=void 0;var Bx=H(),Hx=Ac(),Kx=gg(),Jx=new Set(["type","format","pattern","maxLength","minLength","maxProperties","minProperties","maxItems","minItems","maximum","minimum","uniqueItems","multipleOf","required","enum","const"]);function Gx(e,t=!0){return typeof e=="boolean"?!0:t===!0?!Cc(e):t?yg(e)<=t:!1}Me.inlineRef=Gx;var Wx=new Set(["$ref","$recursiveRef","$recursiveAnchor","$dynamicRef","$dynamicAnchor"]);function Cc(e){for(let t in e){if(Wx.has(t))return!0;let r=e[t];if(Array.isArray(r)&&r.some(Cc)||typeof r=="object"&&Cc(r))return!0}return!1}function yg(e){let t=0;for(let r in e){if(r==="$ref")return 1/0;if(t++,!Jx.has(r)&&(typeof e[r]=="object"&&(0,Bx.eachItem)(e[r],n=>t+=yg(n)),t===1/0))return 1/0}return t}function _g(e,t="",r){r!==!1&&(t=Ar(t));let n=e.parse(t);return wg(e,n)}Me.getFullPath=_g;function wg(e,t){return e.serialize(t).split("#")[0]+"#"}Me._getFullPath=wg;var Yx=/#\/?$/;function Ar(e){return e?e.replace(Yx,""):""}Me.normalizeId=Ar;function Xx(e,t,r){return r=Ar(r),e.resolve(t,r)}Me.resolveUrl=Xx;var Qx=/^[a-z_][-a-z0-9._]*$/i;function eS(e,t){if(typeof e=="boolean")return{};let{schemaId:r,uriResolver:n}=this.opts,o=Ar(e[r]||t),s={"":o},i=_g(n,o,!1),a={},c=new Set;return Kx(e,{allKeys:!0},(d,f,p,m)=>{if(m===void 0)return;let h=i+f,g=s[m];typeof d[r]=="string"&&(g=y.call(this,d[r])),v.call(this,d.$anchor),v.call(this,d.$dynamicAnchor),s[f]=g;function y(k){let T=this.opts.uriResolver.resolve;if(k=Ar(g?T(g,k):k),c.has(k))throw l(k);c.add(k);let x=this.refs[k];return typeof x=="string"&&(x=this.refs[x]),typeof x=="object"?u(d,x.schema,k):k!==Ar(h)&&(k[0]==="#"?(u(d,a[k],k),a[k]=d):this.refs[k]=h),k}function v(k){if(typeof k=="string"){if(!Qx.test(k))throw new Error(`invalid anchor "${k}"`);y.call(this,`#${k}`)}}}),a;function u(d,f,p){if(f!==void 0&&!Hx(d,f))throw l(p)}function l(d){return new Error(`reference "${d}" resolves to more than one schema`)}}Me.getSchemaRefs=eS});var Vn=S(Vt=>{"use strict";Object.defineProperty(Vt,"__esModule",{value:!0});Vt.getData=Vt.KeywordCxt=Vt.validateFunctionCode=void 0;var xg=Qh(),bg=qn(),jc=zc(),Hs=qn(),tS=ig(),Un=dg(),Nc=pg(),E=q(),N=xt(),rS=Fn(),St=H(),Ln=Mn();function nS(e){if(Pg(e)&&(Ig(e),zg(e))){iS(e);return}Sg(e,()=>(0,xg.topBoolOrEmptySchema)(e))}Vt.validateFunctionCode=nS;function Sg({gen:e,validateName:t,schema:r,schemaEnv:n,opts:o},s){o.code.es5?e.func(t,(0,E._)`${N.default.data}, ${N.default.valCxt}`,n.$async,()=>{e.code((0,E._)`"use strict"; ${vg(r,o)}`),sS(e,o),e.code(s)}):e.func(t,(0,E._)`${N.default.data}, ${oS(o)}`,n.$async,()=>e.code(vg(r,o)).code(s))}function oS(e){return(0,E._)`{${N.default.instancePath}="", ${N.default.parentData}, ${N.default.parentDataProperty}, ${N.default.rootData}=${N.default.data}${e.dynamicRef?(0,E._)`, ${N.default.dynamicAnchors}={}`:E.nil}}={}`}function sS(e,t){e.if(N.default.valCxt,()=>{e.var(N.default.instancePath,(0,E._)`${N.default.valCxt}.${N.default.instancePath}`),e.var(N.default.parentData,(0,E._)`${N.default.valCxt}.${N.default.parentData}`),e.var(N.default.parentDataProperty,(0,E._)`${N.default.valCxt}.${N.default.parentDataProperty}`),e.var(N.default.rootData,(0,E._)`${N.default.valCxt}.${N.default.rootData}`),t.dynamicRef&&e.var(N.default.dynamicAnchors,(0,E._)`${N.default.valCxt}.${N.default.dynamicAnchors}`)},()=>{e.var(N.default.instancePath,(0,E._)`""`),e.var(N.default.parentData,(0,E._)`undefined`),e.var(N.default.parentDataProperty,(0,E._)`undefined`),e.var(N.default.rootData,N.default.data),t.dynamicRef&&e.var(N.default.dynamicAnchors,(0,E._)`{}`)})}function iS(e){let{schema:t,opts:r,gen:n}=e;Sg(e,()=>{r.$comment&&t.$comment&&Tg(e),dS(e),n.let(N.default.vErrors,null),n.let(N.default.errors,0),r.unevaluated&&aS(e),Eg(e),mS(e)})}function aS(e){let{gen:t,validateName:r}=e;e.evaluated=t.const("evaluated",(0,E._)`${r}.evaluated`),t.if((0,E._)`${e.evaluated}.dynamicProps`,()=>t.assign((0,E._)`${e.evaluated}.props`,(0,E._)`undefined`)),t.if((0,E._)`${e.evaluated}.dynamicItems`,()=>t.assign((0,E._)`${e.evaluated}.items`,(0,E._)`undefined`))}function vg(e,t){let r=typeof e=="object"&&e[t.schemaId];return r&&(t.code.source||t.code.process)?(0,E._)`/*# sourceURL=${r} */`:E.nil}function cS(e,t){if(Pg(e)&&(Ig(e),zg(e))){uS(e,t);return}(0,xg.boolOrEmptySchema)(e,t)}function zg({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 Pg(e){return typeof e.schema!="boolean"}function uS(e,t){let{schema:r,gen:n,opts:o}=e;o.$comment&&r.$comment&&Tg(e),fS(e),pS(e);let s=n.const("_errs",N.default.errors);Eg(e,s),n.var(t,(0,E._)`${s} === ${N.default.errors}`)}function Ig(e){(0,St.checkUnknownRules)(e),lS(e)}function Eg(e,t){if(e.opts.jtd)return $g(e,[],!1,t);let r=(0,bg.getSchemaTypes)(e.schema),n=(0,bg.coerceAndCheckDataType)(e,r);$g(e,r,!n,t)}function lS(e){let{schema:t,errSchemaPath:r,opts:n,self:o}=e;t.$ref&&n.ignoreKeywordsWithRef&&(0,St.schemaHasRulesButRef)(t,o.RULES)&&o.logger.warn(`$ref: keywords ignored in schema at path "${r}"`)}function dS(e){let{schema:t,opts:r}=e;t.default!==void 0&&r.useDefaults&&r.strictSchema&&(0,St.checkStrictMode)(e,"default is ignored in the schema root")}function fS(e){let t=e.schema[e.opts.schemaId];t&&(e.baseId=(0,rS.resolveUrl)(e.opts.uriResolver,e.baseId,t))}function pS(e){if(e.schema.$async&&!e.schemaEnv.$async)throw new Error("async schema in sync schema")}function Tg({gen:e,schemaEnv:t,schema:r,errSchemaPath:n,opts:o}){let s=r.$comment;if(o.$comment===!0)e.code((0,E._)`${N.default.self}.logger.log(${s})`);else if(typeof o.$comment=="function"){let i=(0,E.str)`${n}/$comment`,a=e.scopeValue("root",{ref:t.root});e.code((0,E._)`${N.default.self}.opts.$comment(${s}, ${i}, ${a}.schema)`)}}function mS(e){let{gen:t,schemaEnv:r,validateName:n,ValidationError:o,opts:s}=e;r.$async?t.if((0,E._)`${N.default.errors} === 0`,()=>t.return(N.default.data),()=>t.throw((0,E._)`new ${o}(${N.default.vErrors})`)):(t.assign((0,E._)`${n}.errors`,N.default.vErrors),s.unevaluated&&hS(e),t.return((0,E._)`${N.default.errors} === 0`))}function hS({gen:e,evaluated:t,props:r,items:n}){r instanceof E.Name&&e.assign((0,E._)`${t}.props`,r),n instanceof E.Name&&e.assign((0,E._)`${t}.items`,n)}function $g(e,t,r,n){let{gen:o,schema:s,data:i,allErrors:a,opts:c,self:u}=e,{RULES:l}=u;if(s.$ref&&(c.ignoreKeywordsWithRef||!(0,St.schemaHasRulesButRef)(s,l))){o.block(()=>Rg(e,"$ref",l.all.$ref.definition));return}c.jtd||gS(e,t),o.block(()=>{for(let f of l.rules)d(f);d(l.post)});function d(f){(0,jc.shouldUseGroup)(s,f)&&(f.type?(o.if((0,Hs.checkDataType)(f.type,i,c.strictNumbers)),kg(e,f),t.length===1&&t[0]===f.type&&r&&(o.else(),(0,Hs.reportTypeError)(e)),o.endIf()):kg(e,f),a||o.if((0,E._)`${N.default.errors} === ${n||0}`))}}function kg(e,t){let{gen:r,schema:n,opts:{useDefaults:o}}=e;o&&(0,tS.assignDefaults)(e,t.type),r.block(()=>{for(let s of t.rules)(0,jc.shouldUseRule)(n,s)&&Rg(e,s.keyword,s.definition,t.type)})}function gS(e,t){e.schemaEnv.meta||!e.opts.strictTypes||(yS(e,t),e.opts.allowUnionTypes||_S(e,t),wS(e,e.dataTypes))}function yS(e,t){if(t.length){if(!e.dataTypes.length){e.dataTypes=t;return}t.forEach(r=>{Og(e.dataTypes,r)||Dc(e,`type "${r}" not allowed by context "${e.dataTypes.join(",")}"`)}),vS(e,t)}}function _S(e,t){t.length>1&&!(t.length===2&&t.includes("null"))&&Dc(e,"use allowUnionTypes to allow union type keyword")}function wS(e,t){let r=e.self.RULES.all;for(let n in r){let o=r[n];if(typeof o=="object"&&(0,jc.shouldUseRule)(e.schema,o)){let{type:s}=o.definition;s.length&&!s.some(i=>bS(t,i))&&Dc(e,`missing type "${s.join(",")}" for keyword "${n}"`)}}}function bS(e,t){return e.includes(t)||t==="number"&&e.includes("integer")}function Og(e,t){return e.includes(t)||t==="integer"&&e.includes("number")}function vS(e,t){let r=[];for(let n of e.dataTypes)Og(t,n)?r.push(n):t.includes("integer")&&n==="number"&&r.push("integer");e.dataTypes=r}function Dc(e,t){let r=e.schemaEnv.baseId+e.errSchemaPath;t+=` at "${r}" (strictTypes)`,(0,St.checkStrictMode)(e,t,e.opts.strictTypes)}var Ks=class{constructor(t,r,n){if((0,Un.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,St.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",Ag(this.$data,t));else if(this.schemaCode=this.schemaValue,!(0,Un.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",N.default.errors))}result(t,r,n){this.failResult((0,E.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,E.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,E._)`${r} !== undefined && (${(0,E.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?Ln.reportExtraError:Ln.reportError)(this,this.def.error,r)}$dataError(){(0,Ln.reportError)(this,this.def.$dataError||Ln.keyword$DataError)}reset(){if(this.errsCount===void 0)throw new Error('add "trackErrors" to keyword definition');(0,Ln.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=E.nil){this.gen.block(()=>{this.check$data(t,n),r()})}check$data(t=E.nil,r=E.nil){if(!this.$data)return;let{gen:n,schemaCode:o,schemaType:s,def:i}=this;n.if((0,E.or)((0,E._)`${o} === undefined`,r)),t!==E.nil&&n.assign(t,!0),(s.length||i.validateSchema)&&(n.elseIf(this.invalid$data()),this.$dataError(),t!==E.nil&&n.assign(t,!1)),n.else()}invalid$data(){let{gen:t,schemaCode:r,schemaType:n,def:o,it:s}=this;return(0,E.or)(i(),a());function i(){if(n.length){if(!(r instanceof E.Name))throw new Error("ajv implementation error");let c=Array.isArray(n)?n:[n];return(0,E._)`${(0,Hs.checkDataTypes)(c,r,s.opts.strictNumbers,Hs.DataType.Wrong)}`}return E.nil}function a(){if(o.validateSchema){let c=t.scopeValue("validate$data",{ref:o.validateSchema});return(0,E._)`!${c}(${r})`}return E.nil}}subschema(t,r){let n=(0,Nc.getSubschema)(this.it,t);(0,Nc.extendSubschemaData)(n,this.it,t),(0,Nc.extendSubschemaMode)(n,t);let o={...this.it,...n,items:void 0,props:void 0};return cS(o,r),o}mergeEvaluated(t,r){let{it:n,gen:o}=this;n.opts.unevaluated&&(n.props!==!0&&t.props!==void 0&&(n.props=St.mergeEvaluated.props(o,t.props,n.props,r)),n.items!==!0&&t.items!==void 0&&(n.items=St.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,E.Name)),!0}};Vt.KeywordCxt=Ks;function Rg(e,t,r,n){let o=new Ks(e,r,t);"code"in r?r.code(o,n):o.$data&&r.validate?(0,Un.funcKeywordCode)(o,r):"macro"in r?(0,Un.macroKeywordCode)(o,r):(r.compile||r.validate)&&(0,Un.funcKeywordCode)(o,r)}var $S=/^\/(?:[^~]|~0|~1)*$/,kS=/^([0-9]+)(#|\/(?:[^~]|~0|~1)*)?$/;function Ag(e,{dataLevel:t,dataNames:r,dataPathArr:n}){let o,s;if(e==="")return N.default.rootData;if(e[0]==="/"){if(!$S.test(e))throw new Error(`Invalid JSON-pointer: ${e}`);o=e,s=N.default.rootData}else{let u=kS.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(s=r[t-l],!o)return s}let i=s,a=o.split("/");for(let u of a)u&&(s=(0,E._)`${s}${(0,E.getProperty)((0,St.unescapeJsonPointer)(u))}`,i=(0,E._)`${i} && ${s}`);return i;function c(u,l){return`Cannot access ${u} ${l} levels up, current level is ${t}`}}Vt.getData=Ag});var Js=S(Mc=>{"use strict";Object.defineProperty(Mc,"__esModule",{value:!0});var Zc=class extends Error{constructor(t){super("validation failed"),this.errors=t,this.ajv=this.validation=!0}};Mc.default=Zc});var Bn=S(Lc=>{"use strict";Object.defineProperty(Lc,"__esModule",{value:!0});var qc=Fn(),Fc=class extends Error{constructor(t,r,n,o){super(o||`can't resolve reference ${n} from id ${r}`),this.missingRef=(0,qc.resolveUrl)(t,r,n),this.missingSchema=(0,qc.normalizeId)((0,qc.getFullPath)(t,this.missingRef))}};Lc.default=Fc});var Ws=S(Qe=>{"use strict";Object.defineProperty(Qe,"__esModule",{value:!0});Qe.resolveSchema=Qe.getCompilingSchema=Qe.resolveRef=Qe.compileSchema=Qe.SchemaEnv=void 0;var it=q(),xS=Js(),sr=xt(),at=Fn(),Cg=H(),SS=Vn(),Cr=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,at.normalizeId)(n?.[t.schemaId||"$id"]),this.schemaPath=t.schemaPath,this.localRefs=t.localRefs,this.meta=t.meta,this.$async=n?.$async,this.refs={}}};Qe.SchemaEnv=Cr;function Vc(e){let t=Ng.call(this,e);if(t)return t;let r=(0,at.getFullPath)(this.opts.uriResolver,e.root.baseId),{es5:n,lines:o}=this.opts.code,{ownProperties:s}=this.opts,i=new it.CodeGen(this.scope,{es5:n,lines:o,ownProperties:s}),a;e.$async&&(a=i.scopeValue("Error",{ref:xS.default,code:(0,it._)`require("ajv/dist/runtime/validation_error").default`}));let c=i.scopeName("validate");e.validateName=c;let u={gen:i,allErrors:this.opts.allErrors,data:sr.default.data,parentData:sr.default.parentData,parentDataProperty:sr.default.parentDataProperty,dataNames:[sr.default.data],dataPathArr:[it.nil],dataLevel:0,dataTypes:[],definedProperties:new Set,topSchemaRef:i.scopeValue("schema",this.opts.code.source===!0?{ref:e.schema,code:(0,it.stringify)(e.schema)}:{ref:e.schema}),validateName:c,ValidationError:a,schema:e.schema,schemaEnv:e,rootId:r,baseId:e.baseId||r,schemaPath:it.nil,errSchemaPath:e.schemaPath||(this.opts.jtd?"":"#"),errorPath:(0,it._)`""`,opts:this.opts,self:this},l;try{this._compilations.add(e),(0,SS.validateFunctionCode)(u),i.optimize(this.opts.code.optimize);let d=i.toString();l=`${i.scopeRefs(sr.default.scope)}return ${d}`,this.opts.code.process&&(l=this.opts.code.process(l,e));let p=new Function(`${sr.default.self}`,`${sr.default.scope}`,l)(this,this.scope.get());if(this.scope.value(c,{ref:p}),p.errors=null,p.schema=e.schema,p.schemaEnv=e,e.$async&&(p.$async=!0),this.opts.code.source===!0&&(p.source={validateName:c,validateCode:d,scopeValues:i._values}),this.opts.unevaluated){let{props:m,items:h}=u;p.evaluated={props:m instanceof it.Name?void 0:m,items:h instanceof it.Name?void 0:h,dynamicProps:m instanceof it.Name,dynamicItems:h instanceof it.Name},p.source&&(p.source.evaluated=(0,it.stringify)(p.evaluated))}return e.validate=p,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)}}Qe.compileSchema=Vc;function zS(e,t,r){var n;r=(0,at.resolveUrl)(this.opts.uriResolver,t,r);let o=e.refs[r];if(o)return o;let s=ES.call(this,e,r);if(s===void 0){let i=(n=e.localRefs)===null||n===void 0?void 0:n[r],{schemaId:a}=this.opts;i&&(s=new Cr({schema:i,schemaId:a,root:e,baseId:t}))}if(s!==void 0)return e.refs[r]=PS.call(this,s)}Qe.resolveRef=zS;function PS(e){return(0,at.inlineRef)(e.schema,this.opts.inlineRefs)?e.schema:e.validate?e:Vc.call(this,e)}function Ng(e){for(let t of this._compilations)if(IS(t,e))return t}Qe.getCompilingSchema=Ng;function IS(e,t){return e.schema===t.schema&&e.root===t.root&&e.baseId===t.baseId}function ES(e,t){let r;for(;typeof(r=this.refs[t])=="string";)t=r;return r||this.schemas[t]||Gs.call(this,e,t)}function Gs(e,t){let r=this.opts.uriResolver.parse(t),n=(0,at._getFullPath)(this.opts.uriResolver,r),o=(0,at.getFullPath)(this.opts.uriResolver,e.baseId,void 0);if(Object.keys(e.schema).length>0&&n===o)return Uc.call(this,r,e);let s=(0,at.normalizeId)(n),i=this.refs[s]||this.schemas[s];if(typeof i=="string"){let a=Gs.call(this,e,i);return typeof a?.schema!="object"?void 0:Uc.call(this,r,a)}if(typeof i?.schema=="object"){if(i.validate||Vc.call(this,i),s===(0,at.normalizeId)(t)){let{schema:a}=i,{schemaId:c}=this.opts,u=a[c];return u&&(o=(0,at.resolveUrl)(this.opts.uriResolver,o,u)),new Cr({schema:a,schemaId:c,root:e,baseId:o})}return Uc.call(this,r,i)}}Qe.resolveSchema=Gs;var TS=new Set(["properties","patternProperties","enum","dependencies","definitions"]);function Uc(e,{baseId:t,schema:r,root:n}){var o;if(((o=e.fragment)===null||o===void 0?void 0:o[0])!=="/")return;for(let a of e.fragment.slice(1).split("/")){if(typeof r=="boolean")return;let c=r[(0,Cg.unescapeFragment)(a)];if(c===void 0)return;r=c;let u=typeof r=="object"&&r[this.opts.schemaId];!TS.has(a)&&u&&(t=(0,at.resolveUrl)(this.opts.uriResolver,t,u))}let s;if(typeof r!="boolean"&&r.$ref&&!(0,Cg.schemaHasRulesButRef)(r,this.RULES)){let a=(0,at.resolveUrl)(this.opts.uriResolver,t,r.$ref);s=Gs.call(this,n,a)}let{schemaId:i}=this.opts;if(s=s||new Cr({schema:r,schemaId:i,root:n,baseId:t}),s.schema!==s.root.schema)return s}});var jg=S((bD,OS)=>{OS.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 Wc=S((vD,Vg)=>{"use strict";var RS=RegExp.prototype.test.bind(/^[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}$/iu),Hc=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),AS=RegExp.prototype.test.bind(/^\d*$/u),ir=RegExp.prototype.test.bind(/^[\da-f]{2}$/iu),Kc=RegExp.prototype.test.bind(/^[\da-z\-._~]$/iu),Zg=RegExp.prototype.test.bind(/^[A-Za-z0-9\-._~!$&'()*+,;=:@/]$/u),Jc=RegExp.prototype.test.bind(/^[A-Za-z0-9\-._~!$&'()*+,;=:@/?]$/u),CS=RegExp.prototype.test.bind(/^[A-Za-z0-9\-._~!$&'()*+,;=:]$/u),qe=new Array(256);{let e="0123456789ABCDEF";for(let t=0;t<256;t++)qe[t]="%"+e[t>>4]+e[t&15]}function ze(e){return e<2048?qe[192|e>>6]+qe[128|e&63]:e<65536?qe[224|e>>12]+qe[128|e>>6&63]+qe[128|e&63]:qe[240|e>>18]+qe[128|e>>12&63]+qe[128|e>>6&63]+qe[128|e&63]}function NS(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 jS=RegExp.prototype.test.bind(/^[\dA-Fa-f]{1,4}$/),DS=RegExp.prototype.test.bind(/^[vV][\dA-Fa-f]+\.[A-Za-z\d\-._~!$&'()*+,;=:]+$/),ZS=RegExp.prototype.test.bind(/^[A-Za-z\d\-._~]$/),MS=RegExp.prototype.test.bind(/[^!"$&'()*+,\-.;=_`a-z{}~]/u);function qS(e){if(e.length===0)return!1;for(let t=0;t<e.length;t++)if(!ZS(e[t])){if(e[t]==="%"&&t+2<e.length&&ir(e.slice(t+1,t+3))){t+=2;continue}return!1}return!0}function Dg(e){let t=-1,r=0,n=-1,o=0;for(let a=0;a<e.length;a++)e[a]==="0"?(n===-1&&(n=a),o++,o>r&&(r=o,t=n)):(n=-1,o=0);if(r<2)return e.join(":");let s=e.slice(0,t).join(":"),i=e.slice(t+r).join(":");return s+"::"+i}function FS(e){let t=e.indexOf("::");if(t!==-1&&e.indexOf("::",t+1)!==-1)return;let r=t===-1?e.split(":"):e.slice(0,t).split(":"),n=t===-1?[]:e.slice(t+2).split(":");t!==-1&&(r.length===1&&r[0]===""&&(r.length=0),n.length===1&&n[0]===""&&(n.length=0));let o=r.concat(n),s=0;for(let a=0;a<o.length;a++){let c=o[a];if(c==="")return;if(c.indexOf(".")!==-1){if(a!==o.length-1||t!==-1&&n.length===0||!Hc(c))return;s+=2;continue}if(!jS(c))return;o[a]=parseInt(c,16).toString(16),s++}if(t===-1)return s!==8?void 0:Dg(o);if(s>=8)return;let i=o.slice(0,r.length);for(let a=s;a<8;a++)i.push("0");for(let a=r.length;a<o.length;a++)i.push(o[a]);return Dg(i)}function Bc(e){let t=e[0]==="["&&e[e.length-1]==="]";if((e[0]==="["||e[e.length-1]==="]")&&!t)return{host:e,isIPV6:!1,error:!0};let n=t?e.slice(1,-1):e;if(t&&DS(n))return n=n.toLowerCase(),{host:`[${n}]`,escapedHost:n,isIPV6:!1,isIPVFuture:!0};if(LS(n,":")<2)return{host:e,isIPV6:!1,error:t};let o="",s=n.indexOf("%");if(s!==-1){let a=n.slice(s,s+3).toLowerCase()==="%25"?3:1;if(o=n.slice(s+a),!qS(o))return{host:e,isIPV6:!1,error:!0};n=n.slice(0,s)}let i=FS(n);return i===void 0?{host:e,isIPV6:!1,error:!0}:{host:i+(o?"%"+o:""),escapedHost:i+(o?"%25"+o:""),isIPV6:!0}}function LS(e,t){let r=0;for(let n=0;n<e.length;n++)e[n]===t&&r++;return r}function Mg(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 US(e){if(e===""||e[0]==="/")return Mg(e);let t=e.split("/"),r=t.length-1,n=[],o=!1;for(let s=0;s<=r;s++){let i=t[s];i==="."||i===".."?(i===".."&&(n.length!==0&&n[n.length-1]!==".."?n.pop():n.push("..")),o=s===r):n.push(i)}return o&&n[n.length-1]!==".."&&n.push(""),(n.length===0||n[0]===""||n[0].includes(":"))&&n.unshift("."),n.join("/")}var VS={"@":"%40","/":"%2F","?":"%3F","#":"%23",":":"%3A"},BS=/[@/?#:]/g,HS=/[@/?#]/g;function qg(e,t){let r=t?HS:BS;return r.lastIndex=0,e.replace(r,n=>VS[n])}function Fg(e,t=!1){if(e.indexOf("%")===-1)return e;let r="";for(let n=0;n<e.length;n++){if(e[n]==="%"&&n+2<e.length){let o=e.slice(n+1,n+3);if(ir(o)){let s=o.toUpperCase(),i=String.fromCharCode(parseInt(s,16));t&&Kc(i)?r+=i:r+="%"+s,n+=2;continue}}r+=e[n]}return r}function KS(e){let t="";for(let r=0;r<e.length;r++){let n=e[r];if(n==="%"&&r+2<e.length){let o=e.slice(r+1,r+3);if(ir(o)){let s=o.toUpperCase(),i=String.fromCharCode(parseInt(s,16));i!=="."&&Kc(i)?t+=i:t+="%"+s,r+=2;continue}}if(Zg(n))t+=n;else{let o=e.charCodeAt(r);if(o<128)t+=Ug(o)?n:qe[o];else if(o<55296||o>57343)t+=ze(o);else if(o<=56319&&r+1<e.length){let s=e.charCodeAt(r+1);s>=56320&&s<=57343?(t+=ze(65536+(o-55296<<10)+(s-56320)),r++):t+=ze(65533)}else t+=ze(65533)}}return t}function JS(e,t=!1){let r="",n=t&&e[0]!=="/";for(let o=0;o<e.length;o++){let s=e[o];if(s==="%"&&o+2<e.length){let i=e.slice(o+1,o+3);if(ir(i)){r+="%"+i.toUpperCase(),o+=2;continue}}if(s==="/"&&(n=!1),Zg(s)&&(s!==":"||!n))r+=s;else{let i=e.charCodeAt(o);if(i<128)r+=qe[i];else if(i<55296||i>57343)r+=ze(i);else if(i<=56319&&o+1<e.length){let a=e.charCodeAt(o+1);a>=56320&&a<=57343?(r+=ze(65536+(i-55296<<10)+(a-56320)),o++):r+=ze(65533)}else r+=ze(65533)}}return r}function Gc(e,t){let r="";for(let n=0;n<e.length;n++){let o=e[n];if(o==="%"&&n+2<e.length){let s=e.slice(n+1,n+3);if(ir(s)){r+="%"+s.toUpperCase(),n+=2;continue}}if(t(o))r+=o;else{let s=e.charCodeAt(n);if(s<128)r+=qe[s];else if(s<55296||s>57343)r+=ze(s);else if(s<=56319&&n+1<e.length){let i=e.charCodeAt(n+1);i>=56320&&i<=57343?(r+=ze(65536+(s-55296<<10)+(i-56320)),n++):r+=ze(65533)}else r+=ze(65533)}}return r}function Lg(e){return Gc(e,CS)}function GS(e){return Gc(e,Jc)}function WS(e){return Gc(e,Jc)}function Ug(e){return e>=48&&e<=57||e>=65&&e<=90||e>=97&&e<=122||e===42||e===43||e===45||e===46||e===47||e===64||e===95}function YS(e){let t="";for(let r=0;r<e.length;r++){let n=e[r];if(n==="%"&&r+2<e.length){let o=e.slice(r+1,r+3);if(ir(o)){let s=o.toUpperCase(),i=String.fromCharCode(parseInt(s,16));Kc(i)?t+=i:t+="%"+s,r+=2;continue}}if(Jc(n))t+=n;else{let o=e.charCodeAt(r);if(o<128)t+=Ug(o)?n:qe[o];else if(o<55296||o>57343)t+=ze(o);else if(o<=56319&&r+1<e.length){let s=e.charCodeAt(r+1);s>=56320&&s<=57343?(t+=ze(65536+(o-55296<<10)+(s-56320)),r++):t+=ze(65533)}else t+=ze(65533)}}return t}function XS(e){let t="";for(let r=0;r<e.length;r++){if(e[r]==="%"&&r+2<e.length){let n=e.slice(r+1,r+3);if(ir(n)){t+="%"+n.toUpperCase(),r+=2;continue}}t+=escape(e[r])}return t}function QS(e){let t=[];if(e.userinfo!==void 0&&(t.push(Lg(e.userinfo)),t.push("@")),e.host!==void 0){let r=e.host;if(!Hc(r)){let n=Bc(r);n.isIPV6!==!0&&n.isIPVFuture!==!0&&(r=Fg(r,!0),n=Bc(r)),n.isIPV6===!0||n.isIPVFuture===!0?r=`[${n.escapedHost}]`:r=qg(r,!1)}t.push(r)}if(typeof e.port=="number"||typeof e.port=="string"){let r=String(e.port);if(!AS(r))throw new TypeError("URI port is malformed.");t.push(":"),t.push(r)}return t.length?t.join(""):void 0}Vg.exports={nonSimpleDomain:MS,recomposeAuthority:QS,reescapeHostDelimiters:qg,normalizePercentEncoding:Fg,normalizePathEncoding:KS,serializePathEncoding:JS,normalizeQueryFragmentEncoding:YS,encodeUserinfo:Lg,encodeQuery:GS,encodeFragment:WS,escapePreservingEscapes:XS,removeDotSegments:Mg,removeDotSegmentsRelative:US,isIPv4:Hc,isUUID:RS,normalizeIPv6:Bc,stringArrayToHexStripped:NS}});var Gg=S(($D,Jg)=>{"use strict";var{isUUID:ez}=Wc(),tz=/^([\da-z][\d\-a-z]{0,31}):((?:[\w!$'()*+,\-./:;=@]|%[\da-f]{2})+)$/iu,rz=["http","https","ws","wss","urn","urn:uuid"];function nz(e){return rz.indexOf(e)!==-1}function Yc(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 Bg(e){return e.host||(e.error=e.error||"HTTP URIs must have a host."),e}function Hg(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 oz(e){return e.secure=Yc(e),e.resourceName=(e.path||"/")+(e.query?"?"+e.query:""),e.path=void 0,e.query=void 0,e}function sz(e){if((e.port===(Yc(e)?443:80)||e.port==="")&&(e.port=void 0),typeof e.secure=="boolean"&&(e.scheme=e.secure?"wss":"ws",e.secure=void 0),e.resourceName){let t=e.resourceName.indexOf("?"),r=t===-1?e.resourceName:e.resourceName.slice(0,t);e.path=r&&r!=="/"?r:void 0,e.query=t===-1?void 0:e.resourceName.slice(t+1),e.resourceName=void 0}return e.fragment=void 0,e}function iz(e,t){if(!e.path)return e.error="URN can not be parsed",e;let r=e.path.match(tz);if(r&&r[0]===e.path){let n=t.scheme||e.scheme||"urn";e.nid=r[1].toLowerCase(),e.nss=r[2];let o=`${n}:${t.nid||e.nid}`,s=Xc(o);e.path=void 0,s&&(e=s.parse(e,t))}else e.error=e.error||"URN can not be parsed.";return e}function az(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}`,s=Xc(o);s&&(e=s.serialize(e,t));let i=e,a=e.nss;return i.path=`${n||t.nid}:${a}`,t.skipEscape=!0,i}function cz(e,t){let r=e;return r.uuid=r.nss,r.nss=void 0,!t.tolerant&&(!r.uuid||!ez(r.uuid))&&(r.error=r.error||"UUID is not valid."),r}function uz(e){let t=e;return t.nss=(e.uuid||"").toLowerCase(),t}var Kg={scheme:"http",domainHost:!0,parse:Bg,serialize:Hg},lz={scheme:"https",domainHost:Kg.domainHost,parse:Bg,serialize:Hg},Ys={scheme:"ws",domainHost:!0,parse:oz,serialize:sz},dz={scheme:"wss",domainHost:Ys.domainHost,parse:Ys.parse,serialize:Ys.serialize},fz={scheme:"urn",parse:iz,serialize:az,skipNormalize:!0},pz={scheme:"urn:uuid",parse:cz,serialize:uz,skipNormalize:!0},Xs={http:Kg,https:lz,ws:Ys,wss:dz,urn:fz,"urn:uuid":pz};Object.setPrototypeOf(Xs,null);function Xc(e){return e&&(Xs[e]||Xs[e.toLowerCase()])||void 0}Jg.exports={wsIsSecure:Yc,SCHEMES:Xs,isValidSchemeName:nz,getSchemeHandler:Xc}});var ly=S((kD,ni)=>{"use strict";var{normalizeIPv6:ey,removeDotSegments:Kn,removeDotSegmentsRelative:ty,recomposeAuthority:mz,normalizePercentEncoding:Qc,normalizePathEncoding:hz,serializePathEncoding:Wg,normalizeQueryFragmentEncoding:Yg,encodeQuery:gz,encodeFragment:yz,reescapeHostDelimiters:_z,isIPv4:ry,nonSimpleDomain:wz}=Wc(),{SCHEMES:ny,getSchemeHandler:eu}=Gg(),oy=/^[A-Za-z][A-Za-z0-9+.-]*$/u,sy="URI scheme is malformed.",Qs="URI host is malformed.",bz=/[\0-\x20"#/:<>?@[\\\]^`{|}\x7F]/u;function Xg(e){let t=String(e);if(!oy.test(t))throw new TypeError(sy);return t}function vz(e,t){return typeof e=="string"?e=Tz(e,t):typeof e=="object"&&(e=ti(ar(e,t),t)),e}function $z(e,t,r){let n=r?Object.assign({scheme:"null"},r):{scheme:"null"},{parsed:o,malformedAuthorityOrPort:s,malformedPercentEncoding:i,malformedSchemeSpecific:a,malformedHost:c,malformedScheme:u}=ei(e,n),{parsed:l,malformedAuthorityOrPort:d,malformedPercentEncoding:f,malformedSchemeSpecific:p,malformedHost:m,malformedScheme:h}=ei(t,n);if(s||d||i||f||a||p||c||m||u||h)throw new Error(o.error||l.error||"URI is malformed.");let g=iy(o,l,n,!0),y=eu(r&&r.scheme||g.scheme),v=g.host,k=v!==void 0&&v!==""&&(ry(v)||ey(v).isIPV6);if(cy(g,r||{},y,k))throw new Error(Qs);ay(g,r||{},y,k);let T=v&&v.indexOf("%")!==-1&&!new RegExp("\\P{ASCII}","u").test(v);if(g.error&&!T)throw new Error(g.error);return n.skipEscape=!0,ar(g,n)}function iy(e,t,r,n){let o={};if(n||(e=ti(ar(e,r),r),t=ti(ar(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=Kn(t.path||""),o.query=t.query;else{if(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=Kn(t.path||""),o.query=t.query;else{if(!t.path)o.path=e.path,t.query!==void 0?o.query=t.query:o.query=e.query;else{if(t.path[0]==="/")o.path=Kn(t.path);else{let s=e.userinfo!==void 0||e.host!==void 0||e.port!==void 0;s&&!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=e.scheme===void 0&&!s&&o.path[0]!=="/"?ty(o.path):Kn(o.path)}o.query=t.query}o.userinfo=e.userinfo,o.host=e.host,o.port=e.port}o.scheme=e.scheme}return o.fragment=t.fragment,o}function kz(e,t,r){let n=Qg(e,r),o=Qg(t,r);return n!==void 0&&o!==void 0&&n===o}function ar(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=[];r.scheme&&(r.scheme=Xg(r.scheme));let s=eu(n.scheme||r.scheme);s&&s.serialize&&s.serialize(r,n);let i=r.userinfo!==void 0||r.host!==void 0||r.port!==void 0,a=(r.scheme===void 0||n.reference==="suffix")&&!i,c=!n.skipEscape&&a;r.path!==void 0&&(n.skipEscape?r.path=Qc(r.path):r.path=Wg(r.path,c)),n.reference!=="suffix"&&r.scheme&&(r.scheme=Xg(r.scheme),o.push(r.scheme,":"));let u=mz(r);if(u!==void 0&&(n.reference!=="suffix"&&o.push("//"),o.push(u),r.path&&r.path[0]!=="/"&&o.push("/")),r.path!==void 0){let l=r.path;!n.absolutePath&&(!s||!s.absolutePath)&&(l=a&&l[0]!=="/"?ty(l):Kn(l)),a&&(l=Wg(l,!0)),u===void 0&&l[0]==="/"&&l[1]==="/"&&(l="/%2F"+l.slice(2)),o.push(l)}return r.query!==void 0&&o.push("?",gz(r.query)),r.fragment!==void 0&&o.push("#",yz(r.fragment)),o.join("")}var xz=/^(?:([^#/:?]+):)?(?:\/\/((?:([^#/?@]*)@)?(\[[^#/?\]]+\]|[^#/:?]*)(?::(\d*))?))?([^#?]*)(?:\?([^#]*))?(?:#((?:.|[\n\r])*))?/u,Sz=/^(?:[^#/:?]+:)?\/\/([^/?#]*)/,zz=/^(?:[^#/:?]+:)?([/\\\t\n\r]*)/;function Pz(e,t){if(t[2]!==void 0&&e.path&&e.path[0]!=="/")return'URI path must start with "/" when authority is present.';if(typeof e.port=="number"&&(e.port<0||e.port>65535))return"URI port is malformed."}function Hn(e){if(e===void 0)return!1;let t=e.indexOf("%");for(;t!==-1;){if(t+2>=e.length||!/^[\da-f]{2}$/iu.test(e.slice(t+1,t+3)))return!0;t=e.indexOf("%",t+3)}return!1}function ri(e){return e[0]==="["&&e[e.length-1]==="]"}function Iz(e){let t=e[4];return Hn(e[3])||t!==void 0&&!ri(t)&&Hn(t)||Hn(e[6])||Hn(e[7])||Hn(e[8])}function ay(e,t,r,n){if(cy(e,t,r,n))return e.error=e.error||Qs,!0;if(!t.unicodeSupport&&(!r||!r.unicodeSupport)&&e.host&&!ri(e.host)&&(t.domainHost||r&&r.domainHost)&&n===!1&&wz(e.host)){let o;try{o=new URL("http://"+e.host)}catch(s){return e.error=e.error||"Host's domain name can not be converted to ASCII: "+s,!0}if(!Ez(o))return e.error=e.error||Qs,!0;e.host=o.hostname}return!1}function cy(e,t,r,n){return!!(e.host&&n===!1&&!ri(e.host)&&(t.domainHost||r&&r.domainHost)&&bz.test(e.host))}function Ez(e){return e.username===""&&e.password===""&&e.port===""&&e.pathname==="/"&&e.search===""&&e.hash===""&&e.hostname!==""}function ei(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,s=!1,i=!1,a=!1,c=!1,u=!1,l=!1;r.reference==="suffix"&&(r.scheme?e=r.scheme+":"+e:e="//"+e);let d=e.match(Sz);d!==null&&d[1].indexOf("\\")!==-1&&(n.error="URI authority must not contain a literal backslash.",o=!0);let f=e.match(zz);if(f!==null){let m=f[1],h=m.replace(/[\t\n\r]/g,"");h.length>=2&&(h.slice(0,2)!=="//"?(n.error=n.error||"URI authority must not contain a literal backslash.",o=!0):m.length!==h.length&&(n.error=n.error||"URI authority introducer must not contain whitespace.",o=!0))}let p=e.match(xz);if(p){n.scheme=p[1],n.userinfo=p[3],n.host=p[4],n.port=parseInt(p[5],10),n.path=p[6]||"",n.query=p[7],n.fragment=p[8],n.scheme!==void 0&&(oy.test(n.scheme)?n.scheme=n.scheme.toLowerCase():(n.error=n.error||sy,u=!0)),s=Iz(p),s&&(n.error=n.error||"URI contains malformed percent-encoding."),isNaN(n.port)&&(n.port=p[5]);let m=Pz(n,p);if(m!==void 0&&(n.error=n.error||m,o=!0),n.host)if(ry(n.host)===!1){let y=ri(n.host),v=n.host.indexOf("[")!==-1||n.host.indexOf("]")!==-1,k=ey(n.host);l=k.isIPV6||k.isIPVFuture===!0,c=v&&(!y||k.error===!0),n.host=l?k.host:k.host.toLowerCase(),c&&(n.error=n.error||Qs,o=!0)}else l=!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 h=eu(r.scheme||n.scheme);if(c||(a=ay(n,r,h,l)),e.indexOf("%")!==-1&&n.host!==void 0&&!c){let g=l?n.host:Qc(n.host,!0);l||(g=Qc(g.toLowerCase())),n.host=l||r.scheme!=="null"?_z(g,l):g}(!h||h&&!h.skipNormalize)&&(n.path&&(n.path=hz(n.path)),n.query&&(n.query=Yg(n.query)),n.fragment&&(n.fragment=Yg(n.fragment))),h&&h.parse&&(h.parse(n,r),h===ny.urn&&n.nid===void 0&&(i=!0))}else n.error=n.error||"URI can not be parsed.";return{parsed:n,malformedAuthorityOrPort:o,malformedPercentEncoding:s,malformedSchemeSpecific:i,malformedHost:a,malformedScheme:u}}function ti(e,t){return ei(e,t).parsed}function Tz(e,t){return uy(e,t).normalized}function uy(e,t){let{parsed:r,malformedAuthorityOrPort:n,malformedPercentEncoding:o,malformedSchemeSpecific:s,malformedHost:i,malformedScheme:a}=ei(e,t);return{normalized:n||o||s||i||a?e:ar(r,t),malformedAuthorityOrPort:n,malformedPercentEncoding:o,malformedSchemeSpecific:s,malformedHost:i,malformedScheme:a}}function Qg(e,t){if(typeof e!="string"&&typeof e!="object")return;let r;try{r=typeof e=="string"?e:ar(e,t)}catch{return}let{normalized:n,malformedAuthorityOrPort:o,malformedPercentEncoding:s,malformedSchemeSpecific:i,malformedHost:a,malformedScheme:c}=uy(r,t);return o||s||i||a||c?void 0:n}var tu={SCHEMES:ny,normalize:vz,resolve:$z,resolveComponent:iy,equal:kz,serialize:ar,parse:ti};ni.exports=tu;ni.exports.default=tu;ni.exports.fastUri=tu});var fy=S(ru=>{"use strict";Object.defineProperty(ru,"__esModule",{value:!0});var dy=ly();dy.code='require("ajv/dist/runtime/uri").default';ru.default=dy});var by=S(ve=>{"use strict";Object.defineProperty(ve,"__esModule",{value:!0});ve.CodeGen=ve.Name=ve.nil=ve.stringify=ve.str=ve._=ve.KeywordCxt=void 0;var Oz=Vn();Object.defineProperty(ve,"KeywordCxt",{enumerable:!0,get:function(){return Oz.KeywordCxt}});var Nr=q();Object.defineProperty(ve,"_",{enumerable:!0,get:function(){return Nr._}});Object.defineProperty(ve,"str",{enumerable:!0,get:function(){return Nr.str}});Object.defineProperty(ve,"stringify",{enumerable:!0,get:function(){return Nr.stringify}});Object.defineProperty(ve,"nil",{enumerable:!0,get:function(){return Nr.nil}});Object.defineProperty(ve,"Name",{enumerable:!0,get:function(){return Nr.Name}});Object.defineProperty(ve,"CodeGen",{enumerable:!0,get:function(){return Nr.CodeGen}});var Rz=Js(),yy=Bn(),Az=Sc(),Jn=Ws(),Cz=q(),Gn=Fn(),oi=qn(),ou=H(),py=jg(),Nz=fy(),_y=(e,t)=>new RegExp(e,t);_y.code="new RegExp";var jz=["removeAdditional","useDefaults","coerceTypes"],Dz=new Set(["validate","serialize","parse","wrapper","root","schema","keyword","pattern","formats","validate$data","func","obj","Error"]),Zz={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."},Mz={ignoreKeywordsWithRef:"",jsPropertySyntax:"",unicode:'"minLength"/"maxLength" account for unicode characters by default.'},my=200;function qz(e){var t,r,n,o,s,i,a,c,u,l,d,f,p,m,h,g,y,v,k,T,x,$,P,F,C;let D=e.strict,de=(t=e.code)===null||t===void 0?void 0:t.optimize,M=de===!0||de===void 0?1:de||0,me=(n=(r=e.code)===null||r===void 0?void 0:r.regExp)!==null&&n!==void 0?n:_y,se=(o=e.uriResolver)!==null&&o!==void 0?o:Nz.default;return{strictSchema:(i=(s=e.strictSchema)!==null&&s!==void 0?s:D)!==null&&i!==void 0?i:!0,strictNumbers:(c=(a=e.strictNumbers)!==null&&a!==void 0?a:D)!==null&&c!==void 0?c:!0,strictTypes:(l=(u=e.strictTypes)!==null&&u!==void 0?u:D)!==null&&l!==void 0?l:"log",strictTuples:(f=(d=e.strictTuples)!==null&&d!==void 0?d:D)!==null&&f!==void 0?f:"log",strictRequired:(m=(p=e.strictRequired)!==null&&p!==void 0?p:D)!==null&&m!==void 0?m:!1,code:e.code?{...e.code,optimize:M,regExp:me}:{optimize:M,regExp:me},loopRequired:(h=e.loopRequired)!==null&&h!==void 0?h:my,loopEnum:(g=e.loopEnum)!==null&&g!==void 0?g:my,meta:(y=e.meta)!==null&&y!==void 0?y:!0,messages:(v=e.messages)!==null&&v!==void 0?v:!0,inlineRefs:(k=e.inlineRefs)!==null&&k!==void 0?k:!0,schemaId:(T=e.schemaId)!==null&&T!==void 0?T:"$id",addUsedSchema:(x=e.addUsedSchema)!==null&&x!==void 0?x:!0,validateSchema:($=e.validateSchema)!==null&&$!==void 0?$:!0,validateFormats:(P=e.validateFormats)!==null&&P!==void 0?P:!0,unicodeRegExp:(F=e.unicodeRegExp)!==null&&F!==void 0?F:!0,int32range:(C=e.int32range)!==null&&C!==void 0?C:!0,uriResolver:se}}var Wn=class{constructor(t={}){this.schemas={},this.refs={},this.formats=Object.create(null),this._compilations=new Set,this._loading={},this._cache=new Map,t=this.opts={...t,...qz(t)};let{es5:r,lines:n}=this.opts.code;this.scope=new Cz.ValueScope({scope:{},prefixes:Dz,es5:r,lines:n}),this.logger=Hz(t.logger);let o=t.validateFormats;t.validateFormats=!1,this.RULES=(0,Az.getRules)(),hy.call(this,Zz,t,"NOT SUPPORTED"),hy.call(this,Mz,t,"DEPRECATED","warn"),this._metaOpts=Vz.call(this),t.formats&&Lz.call(this),this._addVocabularies(),this._addDefaultMetaSchema(),t.keywords&&Uz.call(this,t.keywords),typeof t.meta=="object"&&this.addMetaSchema(t.meta),Fz.call(this),t.validateFormats=o}_addVocabularies(){this.addKeyword("$async")}_addDefaultMetaSchema(){let{$data:t,meta:r,schemaId:n}=this.opts,o=py;n==="id"&&(o={...py},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 s.call(this,l.$schema);let f=this._addSchema(l,d);return f.validate||i.call(this,f)}async function s(l){l&&!this.getSchema(l)&&await o.call(this,{$ref:l},!0)}async function i(l){try{return this._compileSchemaEnv(l)}catch(d){if(!(d instanceof yy.default))throw d;return a.call(this,d),await c.call(this,d.missingSchema),i.call(this,l)}}function a({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 s.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 i of t)this.addSchema(i,void 0,n,o);return this}let s;if(typeof t=="object"){let{schemaId:i}=this.opts;if(s=t[i],s!==void 0&&typeof s!="string")throw new Error(`schema ${i} must be string`)}return r=(0,Gn.normalizeId)(r||s),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 s="schema is invalid: "+this.errorsText();if(this.opts.validateSchema==="log")this.logger.error(s);else throw new Error(s)}return o}getSchema(t){let r;for(;typeof(r=gy.call(this,t))=="string";)t=r;if(r===void 0){let{schemaId:n}=this.opts,o=new Jn.SchemaEnv({schema:{},schemaId:n});if(r=Jn.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=gy.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,Gn.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(Jz.call(this,n,r),!r)return(0,ou.eachItem)(n,s=>nu.call(this,s)),this;Wz.call(this,r);let o={...r,type:(0,oi.getJSONTypes)(r.type),schemaType:(0,oi.getJSONTypes)(r.schemaType)};return(0,ou.eachItem)(n,o.type.length===0?s=>nu.call(this,s,o):s=>o.type.forEach(i=>nu.call(this,s,o,i))),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(s=>s.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,s)=>o+r+s)}$dataMetaSchema(t,r){let n=this.RULES.all;t=JSON.parse(JSON.stringify(t));for(let o of r){let s=o.split("/").slice(1),i=t;for(let a of s)i=i[a];for(let a in n){let c=n[a];if(typeof c!="object")continue;let{$data:u}=c.definition,l=i[a];u&&l&&(i[a]=wy(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,s=this.opts.addUsedSchema){let i,{schemaId:a}=this.opts;if(typeof t=="object")i=t[a];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,Gn.normalizeId)(i||n);let u=Gn.getSchemaRefs.call(this,t,n);return c=new Jn.SchemaEnv({schema:t,schemaId:a,meta:r,baseId:n,localRefs:u}),this._cache.set(c.schema,c),s&&!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):Jn.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{Jn.compileSchema.call(this,t)}finally{this.opts=r}}};Wn.ValidationError=Rz.default;Wn.MissingRefError=yy.default;ve.default=Wn;function hy(e,t,r,n="error"){for(let o in e){let s=o;s in t&&this.logger[n](`${r}: option ${o}. ${e[s]}`)}}function gy(e){return e=(0,Gn.normalizeId)(e),this.schemas[e]||this.refs[e]}function Fz(){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 Lz(){for(let e in this.opts.formats){let t=this.opts.formats[e];t&&this.addFormat(e,t)}}function Uz(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 Vz(){let e={...this.opts};for(let t of jz)delete e[t];return e}var Bz={log(){},warn(){},error(){}};function Hz(e){if(e===!1)return Bz;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 Kz=/^[a-z_$][a-z0-9_$:-]*$/i;function Jz(e,t){let{RULES:r}=this;if((0,ou.eachItem)(e,n=>{if(r.keywords[n])throw new Error(`Keyword ${n} is already defined`);if(!Kz.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 nu(e,t,r){var n;let o=t?.post;if(r&&o)throw new Error('keyword with "post" flag cannot have "type"');let{RULES:s}=this,i=o?s.post:s.rules.find(({type:c})=>c===r);if(i||(i={type:r,rules:[]},s.rules.push(i)),s.keywords[e]=!0,!t)return;let a={keyword:e,definition:{...t,type:(0,oi.getJSONTypes)(t.type),schemaType:(0,oi.getJSONTypes)(t.schemaType)}};t.before?Gz.call(this,i,a,t.before):i.rules.push(a),s.all[e]=a,(n=t.implements)===null||n===void 0||n.forEach(c=>this.addKeyword(c))}function Gz(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 Wz(e){let{metaSchema:t}=e;t!==void 0&&(e.$data&&this.opts.$data&&(t=wy(t)),e.validateSchema=this.compile(t,!0))}var Yz={$ref:"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#"};function wy(e){return{anyOf:[e,Yz]}}});var vy=S(su=>{"use strict";Object.defineProperty(su,"__esModule",{value:!0});var Xz={keyword:"id",code(){throw new Error('NOT SUPPORTED: keyword "id", use "$id" for schema ID')}};su.default=Xz});var Sy=S(cr=>{"use strict";Object.defineProperty(cr,"__esModule",{value:!0});cr.callRef=cr.getValidate=void 0;var Qz=Bn(),$y=Xe(),Fe=q(),jr=xt(),ky=Ws(),si=H(),eP={keyword:"$ref",schemaType:"string",code(e){let{gen:t,schema:r,it:n}=e,{baseId:o,schemaEnv:s,validateName:i,opts:a,self:c}=n,{root:u}=s;if((r==="#"||r==="#/")&&o===u.baseId)return d();let l=ky.resolveRef.call(c,u,o,r);if(l===void 0)throw new Qz.default(n.opts.uriResolver,o,r);if(l instanceof ky.SchemaEnv)return f(l);return p(l);function d(){if(s===u)return ii(e,i,s,s.$async);let m=t.scopeValue("root",{ref:u});return ii(e,(0,Fe._)`${m}.validate`,u,u.$async)}function f(m){let h=xy(e,m);ii(e,h,m,m.$async)}function p(m){let h=t.scopeValue("schema",a.code.source===!0?{ref:m,code:(0,Fe.stringify)(m)}:{ref:m}),g=t.name("valid"),y=e.subschema({schema:m,dataTypes:[],schemaPath:Fe.nil,topSchemaRef:h,errSchemaPath:r},g);e.mergeEvaluated(y),e.ok(g)}}};function xy(e,t){let{gen:r}=e;return t.validate?r.scopeValue("validate",{ref:t.validate}):(0,Fe._)`${r.scopeValue("wrapper",{ref:t})}.validate`}cr.getValidate=xy;function ii(e,t,r,n){let{gen:o,it:s}=e,{allErrors:i,schemaEnv:a,opts:c}=s,u=c.passContext?jr.default.this:Fe.nil;n?l():d();function l(){if(!a.$async)throw new Error("async schema referenced by sync schema");let m=o.let("valid");o.try(()=>{o.code((0,Fe._)`await ${(0,$y.callValidateCode)(e,t,u)}`),p(t),i||o.assign(m,!0)},h=>{o.if((0,Fe._)`!(${h} instanceof ${s.ValidationError})`,()=>o.throw(h)),f(h),i||o.assign(m,!1)}),e.ok(m)}function d(){e.result((0,$y.callValidateCode)(e,t,u),()=>p(t),()=>f(t))}function f(m){let h=(0,Fe._)`${m}.errors`;o.assign(jr.default.vErrors,(0,Fe._)`${jr.default.vErrors} === null ? ${h} : ${jr.default.vErrors}.concat(${h})`),o.assign(jr.default.errors,(0,Fe._)`${jr.default.vErrors}.length`)}function p(m){var h;if(!s.opts.unevaluated)return;let g=(h=r?.validate)===null||h===void 0?void 0:h.evaluated;if(s.props!==!0)if(g&&!g.dynamicProps)g.props!==void 0&&(s.props=si.mergeEvaluated.props(o,g.props,s.props));else{let y=o.var("props",(0,Fe._)`${m}.evaluated.props`);s.props=si.mergeEvaluated.props(o,y,s.props,Fe.Name)}if(s.items!==!0)if(g&&!g.dynamicItems)g.items!==void 0&&(s.items=si.mergeEvaluated.items(o,g.items,s.items));else{let y=o.var("items",(0,Fe._)`${m}.evaluated.items`);s.items=si.mergeEvaluated.items(o,y,s.items,Fe.Name)}}}cr.callRef=ii;cr.default=eP});var zy=S(iu=>{"use strict";Object.defineProperty(iu,"__esModule",{value:!0});var tP=vy(),rP=Sy(),nP=["$schema","$id","$defs","$vocabulary",{keyword:"$comment"},"definitions",tP.default,rP.default];iu.default=nP});var Py=S(au=>{"use strict";Object.defineProperty(au,"__esModule",{value:!0});var ai=q(),Bt=ai.operators,ci={maximum:{okStr:"<=",ok:Bt.LTE,fail:Bt.GT},minimum:{okStr:">=",ok:Bt.GTE,fail:Bt.LT},exclusiveMaximum:{okStr:"<",ok:Bt.LT,fail:Bt.GTE},exclusiveMinimum:{okStr:">",ok:Bt.GT,fail:Bt.LTE}},oP={message:({keyword:e,schemaCode:t})=>(0,ai.str)`must be ${ci[e].okStr} ${t}`,params:({keyword:e,schemaCode:t})=>(0,ai._)`{comparison: ${ci[e].okStr}, limit: ${t}}`},sP={keyword:Object.keys(ci),type:"number",schemaType:"number",$data:!0,error:oP,code(e){let{keyword:t,data:r,schemaCode:n}=e;e.fail$data((0,ai._)`${r} ${ci[t].fail} ${n} || isNaN(${r})`)}};au.default=sP});var Iy=S(cu=>{"use strict";Object.defineProperty(cu,"__esModule",{value:!0});var Yn=q(),iP={message:({schemaCode:e})=>(0,Yn.str)`must be multiple of ${e}`,params:({schemaCode:e})=>(0,Yn._)`{multipleOf: ${e}}`},aP={keyword:"multipleOf",type:"number",schemaType:"number",$data:!0,error:iP,code(e){let{gen:t,data:r,schemaCode:n,it:o}=e,s=o.opts.multipleOfPrecision,i=t.let("res"),a=s?(0,Yn._)`Math.abs(Math.round(${i}) - ${i}) > 1e-${s}`:(0,Yn._)`${i} !== parseInt(${i})`;e.fail$data((0,Yn._)`(${n} === 0 || (${i} = ${r}/${n}, ${a}))`)}};cu.default=aP});var Ty=S(uu=>{"use strict";Object.defineProperty(uu,"__esModule",{value:!0});function Ey(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}uu.default=Ey;Ey.code='require("ajv/dist/runtime/ucs2length").default'});var Oy=S(lu=>{"use strict";Object.defineProperty(lu,"__esModule",{value:!0});var ur=q(),cP=H(),uP=Ty(),lP={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}}`},dP={keyword:["maxLength","minLength"],type:"string",schemaType:"number",$data:!0,error:lP,code(e){let{keyword:t,data:r,schemaCode:n,it:o}=e,s=t==="maxLength"?ur.operators.GT:ur.operators.LT,i=o.opts.unicode===!1?(0,ur._)`${r}.length`:(0,ur._)`${(0,cP.useFunc)(e.gen,uP.default)}(${r})`;e.fail$data((0,ur._)`${i} ${s} ${n}`)}};lu.default=dP});var Ry=S(du=>{"use strict";Object.defineProperty(du,"__esModule",{value:!0});var fP=Xe(),pP=H(),Dr=q(),mP={message:({schemaCode:e})=>(0,Dr.str)`must match pattern "${e}"`,params:({schemaCode:e})=>(0,Dr._)`{pattern: ${e}}`},hP={keyword:"pattern",type:"string",schemaType:"string",$data:!0,error:mP,code(e){let{gen:t,data:r,$data:n,schema:o,schemaCode:s,it:i}=e,a=i.opts.unicodeRegExp?"u":"";if(n){let{regExp:c}=i.opts.code,u=c.code==="new RegExp"?(0,Dr._)`new RegExp`:(0,pP.useFunc)(t,c),l=t.let("valid");t.try(()=>t.assign(l,(0,Dr._)`${u}(${s}, ${a}).test(${r})`),()=>t.assign(l,!1)),e.fail$data((0,Dr._)`!${l}`)}else{let c=(0,fP.usePattern)(e,o);e.fail$data((0,Dr._)`!${c}.test(${r})`)}}};du.default=hP});var Ay=S(fu=>{"use strict";Object.defineProperty(fu,"__esModule",{value:!0});var Xn=q(),gP={message({keyword:e,schemaCode:t}){let r=e==="maxProperties"?"more":"fewer";return(0,Xn.str)`must NOT have ${r} than ${t} properties`},params:({schemaCode:e})=>(0,Xn._)`{limit: ${e}}`},yP={keyword:["maxProperties","minProperties"],type:"object",schemaType:"number",$data:!0,error:gP,code(e){let{keyword:t,data:r,schemaCode:n}=e,o=t==="maxProperties"?Xn.operators.GT:Xn.operators.LT;e.fail$data((0,Xn._)`Object.keys(${r}).length ${o} ${n}`)}};fu.default=yP});var Cy=S(pu=>{"use strict";Object.defineProperty(pu,"__esModule",{value:!0});var Qn=Xe(),eo=q(),_P=H(),wP={message:({params:{missingProperty:e}})=>(0,eo.str)`must have required property '${e}'`,params:({params:{missingProperty:e}})=>(0,eo._)`{missingProperty: ${e}}`},bP={keyword:"required",type:"object",schemaType:"array",$data:!0,error:wP,code(e){let{gen:t,schema:r,schemaCode:n,data:o,$data:s,it:i}=e,{opts:a}=i;if(!s&&r.length===0)return;let c=r.length>=a.loopRequired;if(i.allErrors?u():l(),a.strictRequired){let p=e.parentSchema.properties,{definedProperties:m}=e.it;for(let h of r)if(p?.[h]===void 0&&!m.has(h)){let g=i.schemaEnv.baseId+i.errSchemaPath,y=`required property "${h}" is not defined at "${g}" (strictRequired)`;(0,_P.checkStrictMode)(i,y,i.opts.strictRequired)}}function u(){if(c||s)e.block$data(eo.nil,d);else for(let p of r)(0,Qn.checkReportMissingProp)(e,p)}function l(){let p=t.let("missing");if(c||s){let m=t.let("valid",!0);e.block$data(m,()=>f(p,m)),e.ok(m)}else t.if((0,Qn.checkMissingProp)(e,r,p)),(0,Qn.reportMissingProp)(e,p),t.else()}function d(){t.forOf("prop",n,p=>{e.setParams({missingProperty:p}),t.if((0,Qn.noPropertyInData)(t,o,p,a.ownProperties),()=>e.error())})}function f(p,m){e.setParams({missingProperty:p}),t.forOf(p,n,()=>{t.assign(m,(0,Qn.propertyInData)(t,o,p,a.ownProperties)),t.if((0,eo.not)(m),()=>{e.error(),t.break()})},eo.nil)}}};pu.default=bP});var Ny=S(mu=>{"use strict";Object.defineProperty(mu,"__esModule",{value:!0});var to=q(),vP={message({keyword:e,schemaCode:t}){let r=e==="maxItems"?"more":"fewer";return(0,to.str)`must NOT have ${r} than ${t} items`},params:({schemaCode:e})=>(0,to._)`{limit: ${e}}`},$P={keyword:["maxItems","minItems"],type:"array",schemaType:"number",$data:!0,error:vP,code(e){let{keyword:t,data:r,schemaCode:n}=e,o=t==="maxItems"?to.operators.GT:to.operators.LT;e.fail$data((0,to._)`${r}.length ${o} ${n}`)}};mu.default=$P});var ui=S(hu=>{"use strict";Object.defineProperty(hu,"__esModule",{value:!0});var jy=Ac();jy.code='require("ajv/dist/runtime/equal").default';hu.default=jy});var Dy=S(yu=>{"use strict";Object.defineProperty(yu,"__esModule",{value:!0});var gu=qn(),$e=q(),kP=H(),xP=ui(),SP={message:({params:{i:e,j:t}})=>(0,$e.str)`must NOT have duplicate items (items ## ${t} and ${e} are identical)`,params:({params:{i:e,j:t}})=>(0,$e._)`{i: ${e}, j: ${t}}`},zP={keyword:"uniqueItems",type:"array",schemaType:"boolean",$data:!0,error:SP,code(e){let{gen:t,data:r,$data:n,schema:o,parentSchema:s,schemaCode:i,it:a}=e;if(!n&&!o)return;let c=t.let("valid"),u=s.items?(0,gu.getSchemaTypes)(s.items):[];e.block$data(c,l,(0,$e._)`${i} === false`),e.ok(c);function l(){let m=t.let("i",(0,$e._)`${r}.length`),h=t.let("j");e.setParams({i:m,j:h}),t.assign(c,!0),t.if((0,$e._)`${m} > 1`,()=>(d()?f:p)(m,h))}function d(){return u.length>0&&!u.some(m=>m==="object"||m==="array")}function f(m,h){let g=t.name("item"),y=(0,gu.checkDataTypes)(u,g,a.opts.strictNumbers,gu.DataType.Wrong),v=t.const("indices",(0,$e._)`{}`);t.for((0,$e._)`;${m}--;`,()=>{t.let(g,(0,$e._)`${r}[${m}]`),t.if(y,(0,$e._)`continue`),u.length>1&&t.if((0,$e._)`typeof ${g} == "string"`,(0,$e._)`${g} += "_"`),t.if((0,$e._)`typeof ${v}[${g}] == "number"`,()=>{t.assign(h,(0,$e._)`${v}[${g}]`),e.error(),t.assign(c,!1).break()}).code((0,$e._)`${v}[${g}] = ${m}`)})}function p(m,h){let g=(0,kP.useFunc)(t,xP.default),y=t.name("outer");t.label(y).for((0,$e._)`;${m}--;`,()=>t.for((0,$e._)`${h} = ${m}; ${h}--;`,()=>t.if((0,$e._)`${g}(${r}[${m}], ${r}[${h}])`,()=>{e.error(),t.assign(c,!1).break(y)})))}}};yu.default=zP});var Zy=S(wu=>{"use strict";Object.defineProperty(wu,"__esModule",{value:!0});var _u=q(),PP=H(),IP=ui(),EP={message:"must be equal to constant",params:({schemaCode:e})=>(0,_u._)`{allowedValue: ${e}}`},TP={keyword:"const",$data:!0,error:EP,code(e){let{gen:t,data:r,$data:n,schemaCode:o,schema:s}=e;n||s&&typeof s=="object"?e.fail$data((0,_u._)`!${(0,PP.useFunc)(t,IP.default)}(${r}, ${o})`):e.fail((0,_u._)`${s} !== ${r}`)}};wu.default=TP});var My=S(bu=>{"use strict";Object.defineProperty(bu,"__esModule",{value:!0});var ro=q(),OP=H(),RP=ui(),AP={message:"must be equal to one of the allowed values",params:({schemaCode:e})=>(0,ro._)`{allowedValues: ${e}}`},CP={keyword:"enum",schemaType:"array",$data:!0,error:AP,code(e){let{gen:t,data:r,$data:n,schema:o,schemaCode:s,it:i}=e;if(!n&&o.length===0)throw new Error("enum must have non-empty array");let a=o.length>=i.opts.loopEnum,c,u=()=>c??(c=(0,OP.useFunc)(t,RP.default)),l;if(a||n)l=t.let("valid"),e.block$data(l,d);else{if(!Array.isArray(o))throw new Error("ajv implementation error");let p=t.const("vSchema",s);l=(0,ro.or)(...o.map((m,h)=>f(p,h)))}e.pass(l);function d(){t.assign(l,!1),t.forOf("v",s,p=>t.if((0,ro._)`${u()}(${r}, ${p})`,()=>t.assign(l,!0).break()))}function f(p,m){let h=o[m];return typeof h=="object"&&h!==null?(0,ro._)`${u()}(${r}, ${p}[${m}])`:(0,ro._)`${r} === ${h}`}}};bu.default=CP});var qy=S(vu=>{"use strict";Object.defineProperty(vu,"__esModule",{value:!0});var NP=Py(),jP=Iy(),DP=Oy(),ZP=Ry(),MP=Ay(),qP=Cy(),FP=Ny(),LP=Dy(),UP=Zy(),VP=My(),BP=[NP.default,jP.default,DP.default,ZP.default,MP.default,qP.default,FP.default,LP.default,{keyword:"type",schemaType:["string","array"]},{keyword:"nullable",schemaType:"boolean"},UP.default,VP.default];vu.default=BP});var ku=S(no=>{"use strict";Object.defineProperty(no,"__esModule",{value:!0});no.validateAdditionalItems=void 0;var lr=q(),$u=H(),HP={message:({params:{len:e}})=>(0,lr.str)`must NOT have more than ${e} items`,params:({params:{len:e}})=>(0,lr._)`{limit: ${e}}`},KP={keyword:"additionalItems",type:"array",schemaType:["boolean","object"],before:"uniqueItems",error:HP,code(e){let{parentSchema:t,it:r}=e,{items:n}=t;if(!Array.isArray(n)){(0,$u.checkStrictMode)(r,'"additionalItems" is ignored when "items" is not an array of schemas');return}Fy(e,n)}};function Fy(e,t){let{gen:r,schema:n,data:o,keyword:s,it:i}=e;i.items=!0;let a=r.const("len",(0,lr._)`${o}.length`);if(n===!1)e.setParams({len:t.length}),e.pass((0,lr._)`${a} <= ${t.length}`);else if(typeof n=="object"&&!(0,$u.alwaysValidSchema)(i,n)){let u=r.var("valid",(0,lr._)`${a} <= ${t.length}`);r.if((0,lr.not)(u),()=>c(u)),e.ok(u)}function c(u){r.forRange("i",t.length,a,l=>{e.subschema({keyword:s,dataProp:l,dataPropType:$u.Type.Num},u),i.allErrors||r.if((0,lr.not)(u),()=>r.break())})}}no.validateAdditionalItems=Fy;no.default=KP});var xu=S(oo=>{"use strict";Object.defineProperty(oo,"__esModule",{value:!0});oo.validateTuple=void 0;var Ly=q(),li=H(),JP=Xe(),GP={keyword:"items",type:"array",schemaType:["object","array","boolean"],before:"uniqueItems",code(e){let{schema:t,it:r}=e;if(Array.isArray(t))return Uy(e,"additionalItems",t);r.items=!0,!(0,li.alwaysValidSchema)(r,t)&&e.ok((0,JP.validateArray)(e))}};function Uy(e,t,r=e.schema){let{gen:n,parentSchema:o,data:s,keyword:i,it:a}=e;l(o),a.opts.unevaluated&&r.length&&a.items!==!0&&(a.items=li.mergeEvaluated.items(n,r.length,a.items));let c=n.name("valid"),u=n.const("len",(0,Ly._)`${s}.length`);r.forEach((d,f)=>{(0,li.alwaysValidSchema)(a,d)||(n.if((0,Ly._)`${u} > ${f}`,()=>e.subschema({keyword:i,schemaProp:f,dataProp:f},c)),e.ok(c))});function l(d){let{opts:f,errSchemaPath:p}=a,m=r.length,h=m===d.minItems&&(m===d.maxItems||d[t]===!1);if(f.strictTuples&&!h){let g=`"${i}" is ${m}-tuple, but minItems or maxItems/${t} are not specified or different at path "${p}"`;(0,li.checkStrictMode)(a,g,f.strictTuples)}}}oo.validateTuple=Uy;oo.default=GP});var Vy=S(Su=>{"use strict";Object.defineProperty(Su,"__esModule",{value:!0});var WP=xu(),YP={keyword:"prefixItems",type:"array",schemaType:["array"],before:"uniqueItems",code:e=>(0,WP.validateTuple)(e,"items")};Su.default=YP});var Hy=S(zu=>{"use strict";Object.defineProperty(zu,"__esModule",{value:!0});var By=q(),XP=H(),QP=Xe(),eI=ku(),tI={message:({params:{len:e}})=>(0,By.str)`must NOT have more than ${e} items`,params:({params:{len:e}})=>(0,By._)`{limit: ${e}}`},rI={keyword:"items",type:"array",schemaType:["object","boolean"],before:"uniqueItems",error:tI,code(e){let{schema:t,parentSchema:r,it:n}=e,{prefixItems:o}=r;n.items=!0,!(0,XP.alwaysValidSchema)(n,t)&&(o?(0,eI.validateAdditionalItems)(e,o):e.ok((0,QP.validateArray)(e)))}};zu.default=rI});var Ky=S(Pu=>{"use strict";Object.defineProperty(Pu,"__esModule",{value:!0});var et=q(),di=H(),nI={message:({params:{min:e,max:t}})=>t===void 0?(0,et.str)`must contain at least ${e} valid item(s)`:(0,et.str)`must contain at least ${e} and no more than ${t} valid item(s)`,params:({params:{min:e,max:t}})=>t===void 0?(0,et._)`{minContains: ${e}}`:(0,et._)`{minContains: ${e}, maxContains: ${t}}`},oI={keyword:"contains",type:"array",schemaType:["object","boolean"],before:"uniqueItems",trackErrors:!0,error:nI,code(e){let{gen:t,schema:r,parentSchema:n,data:o,it:s}=e,i,a,{minContains:c,maxContains:u}=n;s.opts.next?(i=c===void 0?1:c,a=u):i=1;let l=t.const("len",(0,et._)`${o}.length`);if(e.setParams({min:i,max:a}),a===void 0&&i===0){(0,di.checkStrictMode)(s,'"minContains" == 0 without "maxContains": "contains" keyword ignored');return}if(a!==void 0&&i>a){(0,di.checkStrictMode)(s,'"minContains" > "maxContains" is always invalid'),e.fail();return}if((0,di.alwaysValidSchema)(s,r)){let h=(0,et._)`${l} >= ${i}`;a!==void 0&&(h=(0,et._)`${h} && ${l} <= ${a}`),e.pass(h);return}s.items=!0;let d=t.name("valid");a===void 0&&i===1?p(d,()=>t.if(d,()=>t.break())):i===0?(t.let(d,!0),a!==void 0&&t.if((0,et._)`${o}.length > 0`,f)):(t.let(d,!1),f()),e.result(d,()=>e.reset());function f(){let h=t.name("_valid"),g=t.let("count",0);p(h,()=>t.if(h,()=>m(g)))}function p(h,g){t.forRange("i",0,l,y=>{e.subschema({keyword:"contains",dataProp:y,dataPropType:di.Type.Num,compositeRule:!0},h),g()})}function m(h){t.code((0,et._)`${h}++`),a===void 0?t.if((0,et._)`${h} >= ${i}`,()=>t.assign(d,!0).break()):(t.if((0,et._)`${h} > ${a}`,()=>t.assign(d,!1).break()),i===1?t.assign(d,!0):t.if((0,et._)`${h} >= ${i}`,()=>t.assign(d,!0)))}}};Pu.default=oI});var Wy=S(ft=>{"use strict";Object.defineProperty(ft,"__esModule",{value:!0});ft.validateSchemaDeps=ft.validatePropertyDeps=ft.error=void 0;var Iu=q(),sI=H(),so=Xe();ft.error={message:({params:{property:e,depsCount:t,deps:r}})=>{let n=t===1?"property":"properties";return(0,Iu.str)`must have ${n} ${r} when property ${e} is present`},params:({params:{property:e,depsCount:t,deps:r,missingProperty:n}})=>(0,Iu._)`{property: ${e},
|
|
8
8
|
missingProperty: ${n},
|
|
9
9
|
depsCount: ${t},
|
|
10
|
-
deps: ${r}}`};var jP={keyword:"dependencies",type:"object",schemaType:"object",error:ot.error,code(e){let[t,r]=DP(e);My(e,t),qy(e,r)}};function DP({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 My(e,t=e.schema){let{gen:r,data:n,it:o}=e;if(Object.keys(t).length===0)return;let s=r.let("missing");for(let i in t){let a=t[i];if(a.length===0)continue;let c=(0,Qn.propertyInData)(r,n,i,o.opts.ownProperties);e.setParams({property:i,depsCount:a.length,deps:a.join(", ")}),o.allErrors?r.if(c,()=>{for(let u of a)(0,Qn.checkReportMissingProp)(e,u)}):(r.if((0,$u._)`${c} && (${(0,Qn.checkMissingProp)(e,a,s)})`),(0,Qn.reportMissingProp)(e,s),r.else())}}ot.validatePropertyDeps=My;function qy(e,t=e.schema){let{gen:r,data:n,keyword:o,it:s}=e,i=r.name("valid");for(let a in t)(0,NP.alwaysValidSchema)(s,t[a])||(r.if((0,Qn.propertyInData)(r,n,a,s.opts.ownProperties),()=>{let c=e.subschema({keyword:o,schemaProp:a},i);e.mergeValidEvaluated(c,i)},()=>r.var(i,!0)),e.ok(i))}ot.validateSchemaDeps=qy;ot.default=jP});var Uy=x(xu=>{"use strict";Object.defineProperty(xu,"__esModule",{value:!0});var Ly=j(),ZP=F(),MP={message:"property name must be valid",params:({params:e})=>(0,Ly._)`{propertyName: ${e.propertyName}}`},qP={keyword:"propertyNames",type:"object",schemaType:["object","boolean"],error:MP,code(e){let{gen:t,schema:r,data:n,it:o}=e;if((0,ZP.alwaysValidSchema)(o,r))return;let s=t.name("valid");t.forIn("key",n,i=>{e.setParams({propertyName:i}),e.subschema({keyword:"propertyNames",data:i,dataTypes:["string"],propertyName:i,compositeRule:!0},s),t.if((0,Ly.not)(s),()=>{e.error(!0),o.allErrors||t.break()})}),e.ok(s)}};xu.default=qP});var ku=x(Su=>{"use strict";Object.defineProperty(Su,"__esModule",{value:!0});var ii=Ue(),et=j(),FP=gt(),ai=F(),LP={message:"must NOT have additional properties",params:({params:e})=>(0,et._)`{additionalProperty: ${e.additionalProperty}}`},UP={keyword:"additionalProperties",type:["object"],schemaType:["boolean","object"],allowUndefined:!0,trackErrors:!0,error:LP,code(e){let{gen:t,schema:r,parentSchema:n,data:o,errsCount:s,it:i}=e;if(!s)throw new Error("ajv implementation error");let{allErrors:a,opts:c}=i;if(i.props=!0,c.removeAdditional!=="all"&&(0,ai.alwaysValidSchema)(i,r))return;let u=(0,ii.allSchemaProperties)(n.properties),l=(0,ii.allSchemaProperties)(n.patternProperties);d(),e.ok((0,et._)`${s} === ${FP.default.errors}`);function d(){t.forIn("key",o,g=>{!u.length&&!l.length?m(g):t.if(f(g),()=>m(g))})}function f(g){let w;if(u.length>8){let v=(0,ai.schemaRefOrVal)(i,n.properties,"properties");w=(0,ii.isOwnProperty)(t,v,g)}else u.length?w=(0,et.or)(...u.map(v=>(0,et._)`${g} === ${v}`)):w=et.nil;return l.length&&(w=(0,et.or)(w,...l.map(v=>(0,et._)`${(0,ii.usePattern)(e,v)}.test(${g})`))),(0,et.not)(w)}function p(g){t.code((0,et._)`delete ${o}[${g}]`)}function m(g){if(c.removeAdditional==="all"||c.removeAdditional&&r===!1){p(g);return}if(r===!1){e.setParams({additionalProperty:g}),e.error(),a||t.break();return}if(typeof r=="object"&&!(0,ai.alwaysValidSchema)(i,r)){let w=t.name("valid");c.removeAdditional==="failing"?(h(g,w,!1),t.if((0,et.not)(w),()=>{e.reset(),p(g)})):(h(g,w),a||t.if((0,et.not)(w),()=>t.break()))}}function h(g,w,v){let $={keyword:"additionalProperties",dataProp:g,dataPropType:ai.Type.Str};v===!1&&Object.assign($,{compositeRule:!0,createErrors:!1,allErrors:!1}),e.subschema($,w)}}};Su.default=UP});var By=x(Pu=>{"use strict";Object.defineProperty(Pu,"__esModule",{value:!0});var VP=Zn(),Vy=Ue(),zu=F(),Hy=ku(),HP={keyword:"properties",type:"object",schemaType:"object",code(e){let{gen:t,schema:r,parentSchema:n,data:o,it:s}=e;s.opts.removeAdditional==="all"&&n.additionalProperties===void 0&&Hy.default.code(new VP.KeywordCxt(s,Hy.default,"additionalProperties"));let i=(0,Vy.allSchemaProperties)(r);for(let d of i)s.definedProperties.add(d);s.opts.unevaluated&&i.length&&s.props!==!0&&(s.props=zu.mergeEvaluated.props(t,(0,zu.toHash)(i),s.props));let a=i.filter(d=>!(0,zu.alwaysValidSchema)(s,r[d]));if(a.length===0)return;let c=t.name("valid");for(let d of a)u(d)?l(d):(t.if((0,Vy.propertyInData)(t,o,d,s.opts.ownProperties)),l(d),s.allErrors||t.else().var(c,!0),t.endIf()),e.it.definedProperties.add(d),e.ok(c);function u(d){return s.opts.useDefaults&&!s.compositeRule&&r[d].default!==void 0}function l(d){e.subschema({keyword:"properties",schemaProp:d,dataProp:d},c)}}};Pu.default=HP});var Wy=x(Eu=>{"use strict";Object.defineProperty(Eu,"__esModule",{value:!0});var Jy=Ue(),ci=j(),Ky=F(),Gy=F(),BP={keyword:"patternProperties",type:"object",schemaType:"object",code(e){let{gen:t,schema:r,data:n,parentSchema:o,it:s}=e,{opts:i}=s,a=(0,Jy.allSchemaProperties)(r),c=a.filter(h=>(0,Ky.alwaysValidSchema)(s,r[h]));if(a.length===0||c.length===a.length&&(!s.opts.unevaluated||s.props===!0))return;let u=i.strictSchema&&!i.allowMatchingProperties&&o.properties,l=t.name("valid");s.props!==!0&&!(s.props instanceof ci.Name)&&(s.props=(0,Gy.evaluatedPropsToName)(t,s.props));let{props:d}=s;f();function f(){for(let h of a)u&&p(h),s.allErrors?m(h):(t.var(l,!0),m(h),t.if(l))}function p(h){for(let g in u)new RegExp(h).test(g)&&(0,Ky.checkStrictMode)(s,`property ${g} matches pattern ${h} (use allowMatchingProperties)`)}function m(h){t.forIn("key",n,g=>{t.if((0,ci._)`${(0,Jy.usePattern)(e,h)}.test(${g})`,()=>{let w=c.includes(h);w||e.subschema({keyword:"patternProperties",schemaProp:h,dataProp:g,dataPropType:Gy.Type.Str},l),s.opts.unevaluated&&d!==!0?t.assign((0,ci._)`${d}[${g}]`,!0):!w&&!s.allErrors&&t.if((0,ci.not)(l),()=>t.break())})})}}};Eu.default=BP});var Yy=x(Iu=>{"use strict";Object.defineProperty(Iu,"__esModule",{value:!0});var JP=F(),KP={keyword:"not",schemaType:["object","boolean"],trackErrors:!0,code(e){let{gen:t,schema:r,it:n}=e;if((0,JP.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"}};Iu.default=KP});var Xy=x(Tu=>{"use strict";Object.defineProperty(Tu,"__esModule",{value:!0});var GP=Ue(),WP={keyword:"anyOf",schemaType:"array",trackErrors:!0,code:GP.validateUnion,error:{message:"must match a schema in anyOf"}};Tu.default=WP});var Qy=x(Ou=>{"use strict";Object.defineProperty(Ou,"__esModule",{value:!0});var ui=j(),YP=F(),XP={message:"must match exactly one schema in oneOf",params:({params:e})=>(0,ui._)`{passingSchemas: ${e.passing}}`},QP={keyword:"oneOf",schemaType:"array",trackErrors:!0,error:XP,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 s=r,i=t.let("valid",!1),a=t.let("passing",null),c=t.name("_valid");e.setParams({passing:a}),t.block(u),e.result(i,()=>e.reset(),()=>e.error(!0));function u(){s.forEach((l,d)=>{let f;(0,YP.alwaysValidSchema)(o,l)?t.var(c,!0):f=e.subschema({keyword:"oneOf",schemaProp:d,compositeRule:!0},c),d>0&&t.if((0,ui._)`${c} && ${i}`).assign(i,!1).assign(a,(0,ui._)`[${a}, ${d}]`).else(),t.if(c,()=>{t.assign(i,!0),t.assign(a,d),f&&e.mergeEvaluated(f,ui.Name)})})}}};Ou.default=QP});var e_=x(Ru=>{"use strict";Object.defineProperty(Ru,"__esModule",{value:!0});var eE=F(),tE={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((s,i)=>{if((0,eE.alwaysValidSchema)(n,s))return;let a=e.subschema({keyword:"allOf",schemaProp:i},o);e.ok(o),e.mergeEvaluated(a)})}};Ru.default=tE});var n_=x(Au=>{"use strict";Object.defineProperty(Au,"__esModule",{value:!0});var li=j(),r_=F(),rE={message:({params:e})=>(0,li.str)`must match "${e.ifClause}" schema`,params:({params:e})=>(0,li._)`{failingKeyword: ${e.ifClause}}`},nE={keyword:"if",schemaType:["object","boolean"],trackErrors:!0,error:rE,code(e){let{gen:t,parentSchema:r,it:n}=e;r.then===void 0&&r.else===void 0&&(0,r_.checkStrictMode)(n,'"if" without "then" and "else" is ignored');let o=t_(n,"then"),s=t_(n,"else");if(!o&&!s)return;let i=t.let("valid",!0),a=t.name("_valid");if(c(),e.reset(),o&&s){let l=t.let("ifClause");e.setParams({ifClause:l}),t.if(a,u("then",l),u("else",l))}else o?t.if(a,u("then")):t.if((0,li.not)(a),u("else"));e.pass(i,()=>e.error(!0));function c(){let l=e.subschema({keyword:"if",compositeRule:!0,createErrors:!1,allErrors:!1},a);e.mergeEvaluated(l)}function u(l,d){return()=>{let f=e.subschema({keyword:l},a);t.assign(i,a),e.mergeValidEvaluated(f,i),d?t.assign(d,(0,li._)`${l}`):e.setParams({ifClause:l})}}}};function t_(e,t){let r=e.schema[t];return r!==void 0&&!(0,r_.alwaysValidSchema)(e,r)}Au.default=nE});var o_=x(Cu=>{"use strict";Object.defineProperty(Cu,"__esModule",{value:!0});var oE=F(),sE={keyword:["then","else"],schemaType:["object","boolean"],code({keyword:e,parentSchema:t,it:r}){t.if===void 0&&(0,oE.checkStrictMode)(r,`"${e}" without "if" is ignored`)}};Cu.default=sE});var s_=x(Nu=>{"use strict";Object.defineProperty(Nu,"__esModule",{value:!0});var iE=yu(),aE=Ny(),cE=_u(),uE=Dy(),lE=Zy(),dE=Fy(),fE=Uy(),pE=ku(),mE=By(),hE=Wy(),gE=Yy(),yE=Xy(),_E=Qy(),wE=e_(),bE=n_(),vE=o_();function $E(e=!1){let t=[gE.default,yE.default,_E.default,wE.default,bE.default,vE.default,fE.default,pE.default,dE.default,mE.default,hE.default];return e?t.push(aE.default,uE.default):t.push(iE.default,cE.default),t.push(lE.default),t}Nu.default=$E});var i_=x(ju=>{"use strict";Object.defineProperty(ju,"__esModule",{value:!0});var ae=j(),xE={message:({schemaCode:e})=>(0,ae.str)`must match format "${e}"`,params:({schemaCode:e})=>(0,ae._)`{format: ${e}}`},SE={keyword:"format",type:["number","string"],schemaType:"string",$data:!0,error:xE,code(e,t){let{gen:r,data:n,$data:o,schema:s,schemaCode:i,it:a}=e,{opts:c,errSchemaPath:u,schemaEnv:l,self:d}=a;if(!c.validateFormats)return;o?f():p();function f(){let m=r.scopeValue("formats",{ref:d.formats,code:c.code.formats}),h=r.const("fDef",(0,ae._)`${m}[${i}]`),g=r.let("fType"),w=r.let("format");r.if((0,ae._)`typeof ${h} == "object" && !(${h} instanceof RegExp)`,()=>r.assign(g,(0,ae._)`${h}.type || "string"`).assign(w,(0,ae._)`${h}.validate`),()=>r.assign(g,(0,ae._)`"string"`).assign(w,h)),e.fail$data((0,ae.or)(v(),$()));function v(){return c.strictSchema===!1?ae.nil:(0,ae._)`${i} && !${w}`}function $(){let O=l.$async?(0,ae._)`(${h}.async ? await ${w}(${n}) : ${w}(${n}))`:(0,ae._)`${w}(${n})`,k=(0,ae._)`(typeof ${w} == "function" ? ${O} : ${w}.test(${n}))`;return(0,ae._)`${w} && ${w} !== true && ${g} === ${t} && !${k}`}}function p(){let m=d.formats[s];if(!m){v();return}if(m===!0)return;let[h,g,w]=$(m);h===t&&e.pass(O());function v(){if(c.strictSchema===!1){d.logger.warn(k());return}throw new Error(k());function k(){return`unknown format "${s}" ignored in schema at path "${u}"`}}function $(k){let N=k instanceof RegExp?(0,ae.regexpCode)(k):c.code.formats?(0,ae._)`${c.code.formats}${(0,ae.getProperty)(s)}`:void 0,se=r.scopeValue("formats",{key:s,ref:k,code:N});return typeof k=="object"&&!(k instanceof RegExp)?[k.type||"string",k.validate,(0,ae._)`${se}.validate`]:["string",k,se]}function O(){if(typeof m=="object"&&!(m instanceof RegExp)&&m.async){if(!l.$async)throw new Error("async format in sync schema");return(0,ae._)`await ${w}(${n})`}return typeof g=="function"?(0,ae._)`${w}(${n})`:(0,ae._)`${w}.test(${n})`}}}};ju.default=SE});var a_=x(Du=>{"use strict";Object.defineProperty(Du,"__esModule",{value:!0});var kE=i_(),zE=[kE.default];Du.default=zE});var c_=x(Ar=>{"use strict";Object.defineProperty(Ar,"__esModule",{value:!0});Ar.contentVocabulary=Ar.metadataVocabulary=void 0;Ar.metadataVocabulary=["title","description","default","deprecated","readOnly","writeOnly","examples"];Ar.contentVocabulary=["contentMediaType","contentEncoding","contentSchema"]});var l_=x(Zu=>{"use strict";Object.defineProperty(Zu,"__esModule",{value:!0});var PE=yy(),EE=Oy(),IE=s_(),TE=a_(),u_=c_(),OE=[PE.default,EE.default,(0,IE.default)(),TE.default,u_.metadataVocabulary,u_.contentVocabulary];Zu.default=OE});var f_=x(di=>{"use strict";Object.defineProperty(di,"__esModule",{value:!0});di.DiscrError=void 0;var d_;(function(e){e.Tag="tag",e.Mapping="mapping"})(d_||(di.DiscrError=d_={}))});var m_=x(qu=>{"use strict";Object.defineProperty(qu,"__esModule",{value:!0});var Cr=j(),Mu=f_(),p_=Vs(),RE=Mn(),AE=F(),CE={message:({params:{discrError:e,tagName:t}})=>e===Mu.DiscrError.Tag?`tag "${t}" must be string`:`value of tag "${t}" must be in oneOf`,params:({params:{discrError:e,tag:t,tagName:r}})=>(0,Cr._)`{error: ${e}, tag: ${r}, tagValue: ${t}}`},NE={keyword:"discriminator",type:"object",schemaType:"object",error:CE,code(e){let{gen:t,data:r,schema:n,parentSchema:o,it:s}=e,{oneOf:i}=o;if(!s.opts.discriminator)throw new Error("discriminator: requires discriminator option");let a=n.propertyName;if(typeof a!="string")throw new Error("discriminator: requires propertyName");if(n.mapping)throw new Error("discriminator: mapping is not supported");if(!i)throw new Error("discriminator: requires oneOf keyword");let c=t.let("valid",!1),u=t.const("tag",(0,Cr._)`${r}${(0,Cr.getProperty)(a)}`);t.if((0,Cr._)`typeof ${u} == "string"`,()=>l(),()=>e.error(!1,{discrError:Mu.DiscrError.Tag,tag:u,tagName:a})),e.ok(c);function l(){let p=f();t.if(!1);for(let m in p)t.elseIf((0,Cr._)`${u} === ${m}`),t.assign(c,d(p[m]));t.else(),e.error(!1,{discrError:Mu.DiscrError.Mapping,tag:u,tagName:a}),t.endIf()}function d(p){let m=t.name("valid"),h=e.subschema({keyword:"oneOf",schemaProp:p},m);return e.mergeEvaluated(h,Cr.Name),m}function f(){var p;let m={},h=w(o),g=!0;for(let O=0;O<i.length;O++){let k=i[O];if(k?.$ref&&!(0,AE.schemaHasRulesButRef)(k,s.self.RULES)){let se=k.$ref;if(k=p_.resolveRef.call(s.self,s.schemaEnv.root,s.baseId,se),k instanceof p_.SchemaEnv&&(k=k.schema),k===void 0)throw new RE.default(s.opts.uriResolver,s.baseId,se)}let N=(p=k?.properties)===null||p===void 0?void 0:p[a];if(typeof N!="object")throw new Error(`discriminator: oneOf subschemas (or referenced schemas) must have "properties/${a}"`);g=g&&(h||w(k)),v(N,O)}if(!g)throw new Error(`discriminator: "${a}" must be required`);return m;function w({required:O}){return Array.isArray(O)&&O.includes(a)}function v(O,k){if(O.const)$(O.const,k);else if(O.enum)for(let N of O.enum)$(N,k);else throw new Error(`discriminator: "properties/${a}" must have "const" or "enum"`)}function $(O,k){if(typeof O!="string"||O in m)throw new Error(`discriminator: "${a}" values must be unique strings`);m[O]=k}}}};qu.default=NE});var h_=x((hD,jE)=>{jE.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 Lu=x((Q,Fu)=>{"use strict";Object.defineProperty(Q,"__esModule",{value:!0});Q.MissingRefError=Q.ValidationError=Q.CodeGen=Q.Name=Q.nil=Q.stringify=Q.str=Q._=Q.KeywordCxt=Q.Ajv=void 0;var DE=dy(),ZE=l_(),ME=m_(),g_=h_(),qE=["/properties"],fi="http://json-schema.org/draft-07/schema",Nr=class extends DE.default{_addVocabularies(){super._addVocabularies(),ZE.default.forEach(t=>this.addVocabulary(t)),this.opts.discriminator&&this.addKeyword(ME.default)}_addDefaultMetaSchema(){if(super._addDefaultMetaSchema(),!this.opts.meta)return;let t=this.opts.$data?this.$dataMetaSchema(g_,qE):g_;this.addMetaSchema(t,fi,!1),this.refs["http://json-schema.org/schema"]=fi}defaultMeta(){return this.opts.defaultMeta=super.defaultMeta()||(this.getSchema(fi)?fi:void 0)}};Q.Ajv=Nr;Fu.exports=Q=Nr;Fu.exports.Ajv=Nr;Object.defineProperty(Q,"__esModule",{value:!0});Q.default=Nr;var FE=Zn();Object.defineProperty(Q,"KeywordCxt",{enumerable:!0,get:function(){return FE.KeywordCxt}});var jr=j();Object.defineProperty(Q,"_",{enumerable:!0,get:function(){return jr._}});Object.defineProperty(Q,"str",{enumerable:!0,get:function(){return jr.str}});Object.defineProperty(Q,"stringify",{enumerable:!0,get:function(){return jr.stringify}});Object.defineProperty(Q,"nil",{enumerable:!0,get:function(){return jr.nil}});Object.defineProperty(Q,"Name",{enumerable:!0,get:function(){return jr.Name}});Object.defineProperty(Q,"CodeGen",{enumerable:!0,get:function(){return jr.CodeGen}});var LE=Ls();Object.defineProperty(Q,"ValidationError",{enumerable:!0,get:function(){return LE.default}});var UE=Mn();Object.defineProperty(Q,"MissingRefError",{enumerable:!0,get:function(){return UE.default}})});var S_=x(it=>{"use strict";Object.defineProperty(it,"__esModule",{value:!0});it.formatNames=it.fastFormats=it.fullFormats=void 0;function st(e,t){return{validate:e,compare:t}}it.fullFormats={date:st(b_,Bu),time:st(Vu(!0),Ju),"date-time":st(y_(!0),$_),"iso-time":st(Vu(),v_),"iso-date-time":st(y_(),x_),duration:/^P(?!$)((\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+S)?)?|(\d+W)?)$/,uri:GE,"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:rI,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:WE,int32:{type:"number",validate:QE},int64:{type:"number",validate:eI},float:{type:"number",validate:w_},double:{type:"number",validate:w_},password:!0,binary:!0};it.fastFormats={...it.fullFormats,date:st(/^\d\d\d\d-[0-1]\d-[0-3]\d$/,Bu),time:st(/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)$/i,Ju),"date-time":st(/^\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,$_),"iso-time":st(/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)?$/i,v_),"iso-date-time":st(/^\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,x_),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};it.formatNames=Object.keys(it.fullFormats);function VE(e){return e%4===0&&(e%100!==0||e%400===0)}var HE=/^(\d\d\d\d)-(\d\d)-(\d\d)$/,BE=[0,31,28,31,30,31,30,31,31,30,31,30,31];function b_(e){let t=HE.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&&VE(r)?29:BE[n])}function Bu(e,t){if(e&&t)return e>t?1:e<t?-1:0}var Uu=/^(\d\d):(\d\d):(\d\d(?:\.\d+)?)(z|([+-])(\d\d)(?::?(\d\d))?)?$/i;function Vu(e){return function(r){let n=Uu.exec(r);if(!n)return!1;let o=+n[1],s=+n[2],i=+n[3],a=n[4],c=n[5]==="-"?-1:1,u=+(n[6]||0),l=+(n[7]||0);if(u>23||l>59||e&&!a)return!1;if(o<=23&&s<=59&&i<60)return!0;let d=s-l*c,f=o-u*c-(d<0?1:0);return(f===23||f===-1)&&(d===59||d===-1)&&i<61}}function Ju(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 v_(e,t){if(!(e&&t))return;let r=Uu.exec(e),n=Uu.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 Hu=/t|\s/i;function y_(e){let t=Vu(e);return function(n){let o=n.split(Hu);return o.length===2&&b_(o[0])&&t(o[1])}}function $_(e,t){if(!(e&&t))return;let r=new Date(e).valueOf(),n=new Date(t).valueOf();if(r&&n)return r-n}function x_(e,t){if(!(e&&t))return;let[r,n]=e.split(Hu),[o,s]=t.split(Hu),i=Bu(r,o);if(i!==void 0)return i||Ju(n,s)}var JE=/\/|:/,KE=/^(?:[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 GE(e){return JE.test(e)&&KE.test(e)}var __=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/gm;function WE(e){return __.lastIndex=0,__.test(e)}var YE=-(2**31),XE=2**31-1;function QE(e){return Number.isInteger(e)&&e<=XE&&e>=YE}function eI(e){return Number.isInteger(e)}function w_(){return!0}var tI=/[^\\]\\Z/;function rI(e){if(tI.test(e))return!1;try{return new RegExp(e),!0}catch{return!1}}});var k_=x(Dr=>{"use strict";Object.defineProperty(Dr,"__esModule",{value:!0});Dr.formatLimitDefinition=void 0;var nI=Lu(),tt=j(),jt=tt.operators,pi={formatMaximum:{okStr:"<=",ok:jt.LTE,fail:jt.GT},formatMinimum:{okStr:">=",ok:jt.GTE,fail:jt.LT},formatExclusiveMaximum:{okStr:"<",ok:jt.LT,fail:jt.GTE},formatExclusiveMinimum:{okStr:">",ok:jt.GT,fail:jt.LTE}},oI={message:({keyword:e,schemaCode:t})=>(0,tt.str)`should be ${pi[e].okStr} ${t}`,params:({keyword:e,schemaCode:t})=>(0,tt._)`{comparison: ${pi[e].okStr}, limit: ${t}}`};Dr.formatLimitDefinition={keyword:Object.keys(pi),type:"string",schemaType:"string",$data:!0,error:oI,code(e){let{gen:t,data:r,schemaCode:n,keyword:o,it:s}=e,{opts:i,self:a}=s;if(!i.validateFormats)return;let c=new nI.KeywordCxt(s,a.RULES.all.format.definition,"format");c.$data?u():l();function u(){let f=t.scopeValue("formats",{ref:a.formats,code:i.code.formats}),p=t.const("fmt",(0,tt._)`${f}[${c.schemaCode}]`);e.fail$data((0,tt.or)((0,tt._)`typeof ${p} != "object"`,(0,tt._)`${p} instanceof RegExp`,(0,tt._)`typeof ${p}.compare != "function"`,d(p)))}function l(){let f=c.schema,p=a.formats[f];if(!p||p===!0)return;if(typeof p!="object"||p instanceof RegExp||typeof p.compare!="function")throw new Error(`"${o}": format "${f}" does not define "compare" function`);let m=t.scopeValue("formats",{key:f,ref:p,code:i.code.formats?(0,tt._)`${i.code.formats}${(0,tt.getProperty)(f)}`:void 0});e.fail$data(d(m))}function d(f){return(0,tt._)`${f}.compare(${r}, ${n}) ${pi[o].fail} 0`}},dependencies:["format"]};var sI=e=>(e.addKeyword(Dr.formatLimitDefinition),e);Dr.default=sI});var I_=x((eo,E_)=>{"use strict";Object.defineProperty(eo,"__esModule",{value:!0});var Zr=S_(),iI=k_(),Ku=j(),z_=new Ku.Name("fullFormats"),aI=new Ku.Name("fastFormats"),Gu=(e,t={keywords:!0})=>{if(Array.isArray(t))return P_(e,t,Zr.fullFormats,z_),e;let[r,n]=t.mode==="fast"?[Zr.fastFormats,aI]:[Zr.fullFormats,z_],o=t.formats||Zr.formatNames;return P_(e,o,r,n),t.keywords&&(0,iI.default)(e),e};Gu.get=(e,t="full")=>{let n=(t==="fast"?Zr.fastFormats:Zr.fullFormats)[e];if(!n)throw new Error(`Unknown format "${e}"`);return n};function P_(e,t,r,n){var o,s;(o=(s=e.opts.code).formats)!==null&&o!==void 0||(s.formats=(0,Ku._)`require("ajv-formats/dist/formats").${n}`);for(let i of t)e.addFormat(i,r[i])}E_.exports=eo=Gu;Object.defineProperty(eo,"__esModule",{value:!0});eo.default=Gu});import{existsSync as pT}from"node:fs";import{homedir as vw}from"node:os";import{isAbsolute as mT,join as vi,sep as hT}from"node:path";import{fileURLToPath as gT}from"node:url";import Qm from"node:process";var I={};ul(I,{BIGINT_FORMAT_RANGES:()=>mo,CONSTANT_CATCH:()=>vl,Class:()=>ki,NUMBER_FORMAT_RANGES:()=>Vr,aborted:()=>Ke,allowsEval:()=>Ti,assert:()=>Cw,assertEqual:()=>Iw,assertIs:()=>Rw,assertNever:()=>Aw,assertNotEqual:()=>Tw,assignProp:()=>Re,attachSchema:()=>Hr,base64ToUint8Array:()=>wl,base64urlToUint8Array:()=>Qw,cached:()=>lr,captureStackTrace:()=>fo,cleanEnum:()=>Xw,cleanRegex:()=>Ur,clone:()=>Je,cloneDef:()=>Dw,codePointLength:()=>Br,constantCatch:()=>$l,createTransparentProxy:()=>Uw,defineLazy:()=>fl,defineLazyInternal:()=>U,derived:()=>nb,esc:()=>Ei,escapeRegex:()=>lt,explicitlyAborted:()=>Ai,extend:()=>Bw,finalizeIssue:()=>Ge,floatSafeRemainder:()=>Pi,getElementAtPath:()=>Zw,getEnumValues:()=>cr,getLengthableOrigin:()=>Jr,getParsedType:()=>Lw,getSizableOrigin:()=>_l,hexToUint8Array:()=>tb,hide:()=>yo,installLazyProp:()=>ab,isObject:()=>Mt,isPlainObject:()=>bt,issue:()=>fr,joinValues:()=>lo,jsonStringifyReplacer:()=>ur,members:()=>Ni,merge:()=>Kw,mergeDefs:()=>ut,normalizeParams:()=>E,nullish:()=>zi,numKeys:()=>Fw,objectClone:()=>Nw,omit:()=>Hw,optionalKeys:()=>Ri,own:()=>wt,parsedType:()=>Ci,partial:()=>Gw,pick:()=>Vw,prefixIssues:()=>dt,primitiveTypes:()=>gl,promiseAllObject:()=>Mw,propertyKeyTypes:()=>Oi,randomString:()=>qw,rawShape:()=>dr,required:()=>Ww,safeExtend:()=>Jw,shallowClone:()=>hl,sizeCaps:()=>go,slugify:()=>Ii,stringifyPrimitive:()=>po,toZod:()=>Ow,uint8ArrayToBase64:()=>bl,uint8ArrayToBase64url:()=>eb,uint8ArrayToHex:()=>rb,unwrapMessage:()=>ar});function Iw(e){return e}function Tw(e){return e}function Ow(){return e=>e}function Rw(e){}function Aw(e){throw new Error("Unexpected value in exhaustive check")}function Cw(e){}function cr(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 lo(e,t="|"){return e.map(r=>po(r)).join(t)}function ur(e,t){return typeof t=="bigint"?t.toString():t}var Si=class{constructor(t){this._getter=t,this._value=void 0}get value(){let t=this._getter;return t!==void 0&&(this._value=t(),this._getter=void 0),this._value}};function lr(e){return new Si(e)}function zi(e){return e==null}function Ur(e){let t=e.startsWith("^")?1:0,r=e.endsWith("$")?e.length-1:e.length;return e.slice(t,r)}function Pi(e,t){let r=e/t,n=Math.round(r),o=4*Number.EPSILON*Math.max(Math.abs(r),1);return Math.abs(r-n)<o?0:r-n}var dl=Symbol("evaluating");function fl(e,t,r){let n;Object.defineProperty(e,t,{get(){if(n!==dl)return n===void 0&&(n=dl,n=r()),n},set(o){Object.defineProperty(e,t,{value:o})},configurable:!0})}function Nw(e){return Object.create(Object.getPrototypeOf(e),Object.getOwnPropertyDescriptors(e))}function Re(e,t,r){Object.defineProperty(e,t,{value:r,writable:!0,enumerable:!0,configurable:!0})}function dr(e){let t=Object.getOwnPropertyDescriptor(e,"shape");return t?.get?t.get.raw:t?.value}function ct(e){return dr(e._zod.def)??e._zod.def.shape}function pl(e,t,r){Object.defineProperty(e,t,{get(){let n=r();return Re(this,t,n),n},enumerable:!0,configurable:!0})}function ml(e,t,r){t in e?Re(e,t,r):e[t]=r}function Zt(e,t,r,n){let o=ct(t);for(let s of r){let i=Object.getOwnPropertyDescriptor(o,s);i.enumerable&&(i.get?pl(e,s,()=>{let a=t._zod.def.shape[s];return n?n(a,s):a}):ml(e,s,n?n(i.value,s):i.value))}}function jw(e,t){for(let r of Reflect.ownKeys(t)){let n=Object.getOwnPropertyDescriptor(t,r);n.enumerable&&(n.get?pl(e,r,()=>t[r]):ml(e,r,n.value))}}function ut(...e){let t={};for(let r of e){let n=Object.getOwnPropertyDescriptors(r);Object.assign(t,n)}return Object.defineProperties({},t)}function Dw(e){return ut(e._zod.def)}function Zw(e,t){return t?t.reduce((r,n)=>r?.[n],e):e}function Mw(e){let t=Object.keys(e),r=t.map(n=>e[n]);return Promise.all(r).then(n=>{let o={};for(let s=0;s<t.length;s++)o[t[s]]=n[s];return o})}function qw(e=10){let t="abcdefghijklmnopqrstuvwxyz",r="";for(let n=0;n<e;n++)r+=t[Math.floor(Math.random()*t.length)];return r}function Ei(e){return JSON.stringify(e)}function Ii(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}var fo="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function Mt(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}var Ti=lr(()=>{if(Se.jitless||typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{let e=Function;return new e(""),!0}catch{return!1}});function bt(e){if(Mt(e)===!1)return!1;let t=e.constructor;if(t===void 0||typeof t!="function")return!0;let r=t.prototype;return!(Mt(r)===!1||Object.prototype.hasOwnProperty.call(r,"isPrototypeOf")===!1)}function hl(e){return bt(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}function Fw(e){let t=0;for(let r in e)Object.prototype.hasOwnProperty.call(e,r)&&t++;return t}var Lw=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}`)}},Oi=new Set(["string","number","symbol"]),gl=new Set(["string","number","bigint","boolean","symbol","undefined"]);function lt(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Je(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 Uw(e){let t;return new Proxy({},{get(r,n,o){return t??(t=e()),Reflect.get(t,n,o)},set(r,n,o,s){return t??(t=e()),Reflect.set(t,n,o,s)},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 po(e){return typeof e=="bigint"?e.toString()+"n":typeof e=="string"?`"${e}"`:`${e}`}function Ri(e){return Object.keys(e).filter(t=>e[t]._zod.optin!==void 0&&e[t]._zod.optout==="optional")}var Vr={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]},mo={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};function Vw(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 s={};return Zt(s,e,ho(e,t)),Je(e,ut(r,{shape:s,checks:[]}))}function ho(e,t){let r=ct(e),n=[];for(let o of Reflect.ownKeys(t)){if(!Object.getOwnPropertyDescriptor(r,o)?.enumerable)throw new Error(`Unrecognized key: "${String(o)}"`);t[o]&&n.push(o)}return n}function Hw(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 s=new Set(ho(e,t)),i={};return Zt(i,e,Reflect.ownKeys(ct(e)).filter(a=>!s.has(a))),Je(e,ut(r,{shape:i,checks:[]}))}function Bw(e,t){if(!bt(t))throw new Error("Invalid input to extend: expected a plain object");let r=e._zod.def.checks;if(r&&r.length>0){let o=ct(e);for(let s of Reflect.ownKeys(t))if(Object.getOwnPropertyDescriptor(o,s)!==void 0)throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}return Je(e,ut(e._zod.def,{shape:yl(e,t)}))}function yl(e,t){let r={};return Zt(r,e,Reflect.ownKeys(ct(e))),jw(r,t),r}function Jw(e,t){if(!bt(t))throw new Error("Invalid input to safeExtend: expected a plain object");return Je(e,ut(e._zod.def,{shape:yl(e,t)}))}function Kw(e,t){if(!t?._zod?.def)throw new Error("Invalid input to merge: expected an object schema. To merge a plain shape, use `.extend()`.");if(e._zod.def.checks?.length)throw new Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");let r={};Zt(r,e,Reflect.ownKeys(ct(e))),Zt(r,t,Reflect.ownKeys(ct(t)));let n=ut(e._zod.def,{shape:r,get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]});return Je(e,n)}function Gw(e,t,r,n="partial"){let s=t._zod.def.checks;if(s&&s.length>0)throw new Error(`.${n}() cannot be used on object schemas containing refinements`);let a=r?new Set(ho(t,r)):void 0,c={};return Zt(c,t,Reflect.ownKeys(ct(t)),e&&((u,l)=>a&&!a.has(l)?u:new e({type:"optional",innerType:u}))),Je(t,ut(t._zod.def,{shape:c,checks:[]}))}function Ww(e,t,r){let n=r?new Set(ho(t,r)):void 0,o={};return Zt(o,t,Reflect.ownKeys(ct(t)),(s,i)=>n&&!n.has(i)?s:new e({type:"nonoptional",innerType:s})),Je(t,ut(t._zod.def,{shape:o}))}function Ke(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 Ai(e,t=0){if(e.aborted===!0)return!0;for(let r=t;r<e.issues.length;r++)if(e.issues[r]?.continue===!1)return!0;return!1}function dt(e,t){return t.map(r=>{var n;return(n=r).path??(n.path=[]),r.path.unshift(e),r})}function ar(e){return typeof e=="string"?e:e?.message}function go(e){let t=[];for(let r of e??[]){let n=r._zod.def;if(!/_(length|size)$|_equals$/.test(n.check))break;let o=n.maximum??n.length??n.size;o>=0&&t.push([o,r])}return t}function Hr(e,t,r){var n;for(let o=t;o<e.length;o++)(n=e[o]).schema??(n.schema=r)}function Ge(e,t,r){var n;let o=e.inst?._zod?.traits;o?.has("$ZodType")&&(o.has("$ZodCheck")?(n=e).schema??(n.schema=e.inst):e.schema=e.inst);let s=e.schema!==e.inst?e.schema?._zod.def?.error:void 0,i=e.message?e.message:ar(e.inst?._zod.def?.error?.(e))??ar(s?.(e))??ar(t?.error?.(e))??ar(r.customError?.(e))??ar(r.localeError?.(e))??"Invalid input",a={};for(let c of Object.keys(e))c==="inst"||c==="schema"||c==="continue"||c==="input"||c==="__proto__"||(a[c]=e[c]);return a.path??(a.path=[]),a.message=i,t?.reportInput&&(a.input=e.input),a}function _l(e){return e instanceof Set?"set":e instanceof Map?"map":e instanceof File?"file":"unknown"}var Yw=/[\uD800-\uDBFF]/;function Br(e){let t=e.length;if(!Yw.test(e))return t;let r=t;for(let n=0;n<t-1;n++)(e.charCodeAt(n)&64512)===55296&&(e.charCodeAt(n+1)&64512)===56320&&(r--,n++);return r}function Jr(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function Ci(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 fr(...e){let[t,r,n]=e;return typeof t=="string"?{message:t,code:"custom",input:r,inst:n}:{...t}}function Xw(e){return Object.entries(e).filter(([t,r])=>Number.isNaN(Number.parseInt(t,10))).map(t=>t[1])}function wl(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 bl(e){let t="";for(let r=0;r<e.length;r++)t+=String.fromCharCode(e[r]);return btoa(t)}function Qw(e){let t=e.replace(/-/g,"+").replace(/_/g,"/"),r="=".repeat((4-t.length%4)%4);return wl(t+r)}function eb(e){return bl(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function tb(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 rb(e){return Array.from(e).map(t=>t.toString(16).padStart(2,"0")).join("")}var ki=class{constructor(...t){}};function Ni(e,t){for(let r in t){let n=Object.getOwnPropertyDescriptor(t,r);n.get?Object.defineProperty(e,r,{...n,enumerable:!1}):ob(e,r,n.value)}}function wt(e,t,r,n=!0){return Object.defineProperty(e,t,{configurable:!0,writable:!0,enumerable:n,value:r}),r}function yo(e,t,r){return wt(e,t,r,!1)}function nb(e,t){for(let r in e){let n=e[r];Object.defineProperty(t,r,{configurable:!0,enumerable:!0,get(){return wt(this,r,n(this))},set(o){wt(this,r,o)}})}return t}function ob(e,t,r){Object.defineProperty(e,t,{configurable:!0,get(){return this==null?r:wt(this,t,r.bind(this))},set(n){wt(this,t,n)}})}function sb(e,t){let r=Object.getPrototypeOf(e);return t in r?void 0:r}var xi,_t=!1,ib={configurable:!0,get(){_t=!0}};function U(e,t,r){let n=Object.getPrototypeOf(e._zod);if(t in n&&xi!==e._zod){xi=void 0;return}xi=e._zod,Object.defineProperty(n,t,{configurable:!0,get(){Object.defineProperty(this,t,ib);let o=_t;_t=!1;try{let s=r(this);return _t?delete this[t]:Object.defineProperty(this,t,{configurable:!0,writable:!0,value:s}),_t=_t||o,s}catch(s){throw delete this[t],_t=_t||o,s}},set(o){Object.defineProperty(this,t,{configurable:!0,writable:!0,value:o})}})}function ab(e,t,r,n){let o=sb(e,t);o&&Object.defineProperty(o,t,{configurable:!0,get(){let s={configurable:!0,writable:!0,enumerable:n,value:void 0};return Object.defineProperty(this,t,s),s.value=r(this),Object.defineProperty(this,t,s),s.value},set(s){Object.defineProperty(this,t,{configurable:!0,writable:!0,enumerable:n,value:s})}})}var vl="~constantCatch";function $l(e){let t=()=>e;return t[vl]=!0,t}var xl;var ji={value:void 0,enumerable:!1},Sl="captureStackTrace"in Error?Error:null;function cb(e){let t=Sl;if(t){let r=t.stackTraceLimit;if(typeof r=="number"){try{t.stackTraceLimit=0}catch{return Sl=null,new e}try{return new e}finally{t.stackTraceLimit=r}}}return new e}function _(e,t,r,n){let o={};function s(f){this.def=f,this.constr=d,this.traits=new Set}s.prototype=o;let i=r,a=i&&new WeakSet;function c(f,p){if(f._zod){if(f._zod.traits.has(e))return}else{ji.value=new s(p);try{Object.defineProperty(f,"_zod",ji)}finally{ji.value=void 0}}if(f._zod.traits.add(e),t(f,p),a){let h=Object.getPrototypeOf(f),g=f._zod.constr.prototype,w=h;for(;w&&w!==g;)w=Object.getPrototypeOf(w);let v=w??h;a.has(v)||(a.add(v),Ni(v,i))}let m=d.prototype;for(let h in m)Object.prototype.hasOwnProperty.call(m,h)&&(h in f||(f[h]=m[h].bind(f)))}let u=n?.Parent??Object;class l extends u{}Object.defineProperty(l,"name",{value:e});function d(f){let p=n?.Parent?cb(l):this;c(p,f);let m=p._zod.deferred;if(m){for(let g of m)g();p._zod.deferred=void 0}let h=globalThis.__zod_globalConfig?.postProcessor;return h&&h(p),p}return Object.defineProperty(d,"init",{value:c}),Object.defineProperty(d,Symbol.hasInstance,{value:f=>n?.Parent&&f instanceof n.Parent?!0:f?._zod?.traits?.has(e)}),Object.defineProperty(d,"name",{value:e}),d}var We=class extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}},pr=class extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}};(xl=globalThis).__zod_globalConfig??(xl.__zod_globalConfig={});var Se=globalThis.__zod_globalConfig;function Ae(e){return e&&Object.assign(Se,e),Se}function ub(){let e=this._zod;return e.message??(e.message=JSON.stringify(e.def,ur,2)),e.message}function lb(e){this._zod.message=e}var db={get:ub,set:lb,enumerable:!0,configurable:!0},Zi={value:void 0,enumerable:!1},kl=new WeakSet([Object.prototype,Error.prototype]),zl=(e,t)=>{e.name="$ZodError",Zi.value=t,Object.defineProperty(e,"issues",Zi),Zi.value=void 0,Object.defineProperty(e,"message",db);let r=Object.getPrototypeOf(e);kl.has(r)||(kl.add(r),Object.defineProperty(r,"toString",{configurable:!0,enumerable:!1,get(){let n=()=>this.message;return Object.defineProperty(this,"toString",{value:n,configurable:!0,writable:!0}),n},set(n){Object.defineProperty(this,"toString",{value:n,configurable:!0,writable:!0})}}))},Pl=_("$ZodError",zl),El=_("$ZodError",zl,void 0,{Parent:Error});function fb(e,t,r){return Object.prototype.hasOwnProperty.call(e,t)||(t==="__proto__"?Object.defineProperty(e,t,{value:r(),writable:!0,enumerable:!0,configurable:!0}):e[t]=r()),e[t]}function Il(e,t=r=>r.message){let r={},n=[];for(let o of e.issues)o.path.length>0?fb(r,o.path[0],()=>[]).push(t(o)):n.push(t(o));return{formErrors:n,fieldErrors:r}}function Tl(e,t=r=>r.message){let r={_errors:[]},n=(o,s=[])=>{for(let i of o.issues)if(i.code==="invalid_union"&&i.errors.length)i.errors.map(a=>n({issues:a},[...s,...i.path]));else if(i.code==="invalid_key")n({issues:i.issues},[...s,...i.path]);else if(i.code==="invalid_element")n({issues:i.issues},[...s,...i.path]);else{let a=[...s,...i.path];if(a.length===0)r._errors.push(t(i));else{let c=r,u=0;for(;u<a.length;){let l=a[u],d=u===a.length-1;if(l==="_errors"){d&&c._errors.push(t(i)),u++;continue}Object.prototype.hasOwnProperty.call(c,l)||Object.defineProperty(c,l,{value:{_errors:[]},enumerable:!0,writable:!0,configurable:!0});let f=c[l];d&&f._errors.push(t(i)),c=f,u++}}}};return n(e),r}function _o(e,t){return{callee:t?.callee??e,Err:t?.Err}}var wo=e=>{let t=(r,n,o,s)=>{let i=o?{...o,async:!1}:{async:!1},a=r._zod.run({value:n,issues:[]},i);if(a instanceof Promise)throw new We;if(a.issues.length){let c=new(s?.Err??e)(a.issues.map(u=>Ge(u,i,Ae())));throw fo(c,s?.callee??t),c}return a.value};return t};var bo=e=>{let t=async(r,n,o,s)=>{let i=o?{...o,async:!0}:{async:!0},a=r._zod.run({value:n,issues:[]},i);if(a instanceof Promise&&(a=await a),a.issues.length){let c=new(s?.Err??e)(a.issues.map(u=>Ge(u,i,Ae())));throw fo(c,s?.callee??t),c}return a.value};return t};var Kr=e=>(t,r,n)=>{let o=n?{...n,async:!1}:{async:!1},s=t._zod.run({value:r,issues:[]},o);if(s instanceof Promise)throw new We;return s.issues.length?Ol(e,s.issues,o):{success:!0,data:s.value}},Mi=Kr(El);function Ol(e,t,r){let n;return{success:!1,get error(){return n||(n=new e(t.map(o=>Ge(o,r,Ae()))),t=void 0,r=void 0),n},set error(o){n=o,t=void 0,r=void 0}}}var vo=e=>async(t,r,n)=>{let o=n?{...n,async:!0}:{async:!0},s=t._zod.run({value:r,issues:[]},o);return s instanceof Promise&&(s=await s),s.issues.length?Ol(e,s.issues,o):{success:!0,data:s.value}};var mb=Symbol.for("zod.compile.invalid"),hb=Symbol.for("zod.compile.fallback"),$o=((e,t,r)=>{let n=e._zod.bag.validator;if(n!==void 0){if(n(t)!==mb)return!0;if(n.definite===!0&&r===void 0)return!1}return gb(e,t,r)});function gb(e,t,r){let n=r?{...r,async:!1,abortEarly:!0}:{async:!1,abortEarly:!0},o=e._zod.bag.fallbackRun,s;if(o?(n[hb]=!0,s=o({value:t,issues:[]},n)):s=e._zod.run({value:t,issues:[]},n),s instanceof Promise)throw new We;return s.issues.length===0}var xo=async(e,t,r)=>{let n=r?{...r,async:!0,abortEarly:!0}:{async:!0,abortEarly:!0},o=e._zod.run({value:t,issues:[]},n);return o instanceof Promise&&(o=await o),o.issues.length===0},Rl=e=>{let t=wo(e),r=(n,o,s,i)=>{let a=s?{...s,direction:"backward"}:{direction:"backward"};return t(n,o,a,_o(r,i))};return r};var Al=e=>{let t=wo(e),r=(n,o,s,i)=>t(n,o,s,_o(r,i));return r};var Cl=e=>{let t=bo(e),r=async(n,o,s,i)=>{let a=s?{...s,direction:"backward"}:{direction:"backward"};return await t(n,o,a,_o(r,i))};return r};var Nl=e=>{let t=bo(e),r=async(n,o,s,i)=>await t(n,o,s,_o(r,i));return r};var jl=e=>(t,r,n)=>{let o=n?{...n,direction:"backward"}:{direction:"backward"};return Kr(e)(t,r,o)};var Dl=e=>(t,r,n)=>Kr(e)(t,r,n);var Zl=e=>async(t,r,n)=>{let o=n?{...n,direction:"backward"}:{direction:"backward"};return vo(e)(t,r,o)};var Ml=e=>async(t,r,n)=>vo(e)(t,r,n);var ql=/^[cC][0-9a-z]{6,}$/,Fl=/^[0-9a-z]+$/,Ll=/^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$/,Ul=/^[0-9a-vA-V]{20}$/,Vl=/^[A-Za-z0-9]{27}$/,Hl=/^[a-zA-Z0-9_-]{21}$/;function Bl(e){return new RegExp(`^[a-zA-Z0-9_-]{${e}}$`)}var Jl=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/;var Kl=/^([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})$/,Fi=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)$/;var Gl=/^(?:[A-Za-z0-9_'+\-]+\.)*[A-Za-z0-9_'+\-]*[A-Za-z0-9_+-]@(?:[A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;var yb="^(?=[\\s\\S]*[\\p{Extended_Pictographic}\\p{Regional_Indicator}\\u20E3])[\\p{Extended_Pictographic}\\p{Emoji_Component}]+$";function Wl(){return new RegExp(yb,"u")}var Yl=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,Xl=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/;var Ql=/^((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])$/,ed=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,td=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,rd=/^(?:[A-Za-z0-9_-]{4})*(?:[A-Za-z0-9_-]{2,3})?$/;var nd=/^https?$/,od=/^\+[1-9]\d{6,14}$/;var sd="(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))";function _b(e){return new RegExp(`^${e}$`)}var id=_b(sd);function qi(e){let t="(?:[01]\\d|2[0-3]):[0-5]\\d";return typeof e.precision=="number"?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:e.seconds?`${t}:[0-5]\\d(?:\\.\\d+)?`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function ad(e){return new RegExp(`^${qi(e)}$`)}function cd(e){let t=["Z"];e.offset&&t.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");let r=`${qi({precision:e.precision,seconds:!0})}(?:${t.join("|")})`,n=e.local?`${r}|${qi({precision:e.precision})}`:r;return new RegExp(`^${sd}T(?:${n})$`)}var ud=/^[\s\S]{0,}$/;var Li=/^-?\d+$/,Gr=/^-?\d+(?:\.\d+)?$/,ld=/^(?:true|false)$/i,dd=/^null$/i;var fd=/^[^A-Z]*$/,pd=/^[^a-z]*$/;var le=_("$ZodCheck",(e,t)=>{var r;e._zod??(e._zod={}),e._zod.def=t,(r=e._zod).onattach??(r.onattach=[])});var Ui=e=>{let t=e.value;return!zi(t)&&t.length!==void 0},So={number:"number",bigint:"bigint",object:"date"},Vi=_("$ZodCheckLessThan",(e,t)=>{le.init(e,t);let r=So[typeof t.value];e._zod.check=n=>{(t.inclusive?n.value<=t.value:n.value<t.value)||n.issues.push({origin:So[typeof n.value]??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})}}),Hi=_("$ZodCheckGreaterThan",(e,t)=>{le.init(e,t);let r=So[typeof t.value];e._zod.check=n=>{(t.inclusive?n.value>=t.value:n.value>t.value)||n.issues.push({origin:So[typeof n.value]??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})}}),md=_("$ZodCheckMultipleOf",(e,t)=>{le.init(e,t),e._zod.check=r=>{if(typeof r.value!=typeof t.value)throw new Error("Cannot mix number and bigint in multiple_of check.");(typeof r.value=="bigint"?t.value!==BigInt(0)&&r.value%t.value===BigInt(0):Pi(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})}}),hd=_("$ZodCheckNumberFormat",(e,t)=>{le.init(e,t),t.format=t.format||"float64";let r=t.format?.includes("int"),n=r?"int":"number",[o,s]=Vr[t.format];e._zod.check=i=>{let a=i.value;if(r){if(!Number.isInteger(a)){i.issues.push({expected:n,format:t.format,code:"invalid_type",continue:!1,input:a,inst:e});return}if(!Number.isSafeInteger(a)){a>0?i.issues.push({input:a,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:n,inclusive:!0,continue:!t.abort}):i.issues.push({input:a,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:n,inclusive:!0,continue:!t.abort});return}}a<o&&i.issues.push({origin:"number",input:a,code:"too_small",minimum:o,inclusive:!0,inst:e,continue:!t.abort}),a>s&&i.issues.push({origin:"number",input:a,code:"too_big",maximum:s,inclusive:!0,inst:e,continue:!t.abort})}});var gd=_("$ZodCheckMaxLength",(e,t)=>{var r;le.init(e,t),(r=e._zod.def).when??(r.when=Ui),e._zod.check=n=>{let o=n.value,s=o.length;if((typeof o=="string"&&s>t.maximum?Br(o):s)<=t.maximum)return;let a=Jr(o);n.issues.push({origin:a,code:"too_big",maximum:t.maximum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),yd=_("$ZodCheckMinLength",(e,t)=>{var r;le.init(e,t),(r=e._zod.def).when??(r.when=Ui),e._zod.check=n=>{let o=n.value,s=o.length;if((typeof o=="string"&&s>=t.minimum&&s<t.minimum*2?Br(o):s)>=t.minimum)return;let a=Jr(o);n.issues.push({origin:a,code:"too_small",minimum:t.minimum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),_d=_("$ZodCheckLengthEquals",(e,t)=>{var r;le.init(e,t),(r=e._zod.def).when??(r.when=Ui),e._zod.check=n=>{let o=n.value,s=o.length,i=typeof o=="string"&&s>=t.length&&s<=t.length*2?Br(o):s;if(i===t.length)return;let a=Jr(o),c=i>t.length;n.issues.push({origin:a,...c?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}}),Yr=_("$ZodCheckStringFormat",(e,t)=>{var r,n;le.init(e,t),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=()=>{})}),wd=_("$ZodCheckRegex",(e,t)=>{Yr.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})}}),bd=_("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=fd),Yr.init(e,t)}),vd=_("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=pd),Yr.init(e,t)}),$d=_("$ZodCheckIncludes",(e,t)=>{le.init(e,t);let r=lt(t.includes),n=new RegExp(typeof t.position=="number"?`^.{${t.position},}${r}`:r);t.pattern=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})}}),xd=_("$ZodCheckStartsWith",(e,t)=>{le.init(e,t);let r=new RegExp(`^${lt(t.prefix)}.*`);t.pattern??(t.pattern=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})}}),Sd=_("$ZodCheckEndsWith",(e,t)=>{le.init(e,t);let r=new RegExp(`.*${lt(t.suffix)}$`);t.pattern??(t.pattern=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})}});var kd=_("$ZodCheckOverwrite",(e,t)=>{le.init(e,t),e._zod.check=r=>{r.value=t.tx(r.value)}});var ko=class{constructor(t=[],r={}){this.content=[],this.indent=0,this.args=t,this.closed=r}indented(t){this.indent+=1;try{t(this)}finally{this.indent-=1}}write(t){if(typeof t=="function"){t(this,{execution:"sync"}),t(this,{execution:"async"});return}let n=t.split(`
|
|
10
|
+
deps: ${r}}`};var iI={keyword:"dependencies",type:"object",schemaType:"object",error:ft.error,code(e){let[t,r]=aI(e);Jy(e,t),Gy(e,r)}};function aI({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 Jy(e,t=e.schema){let{gen:r,data:n,it:o}=e;if(Object.keys(t).length===0)return;let s=r.let("missing");for(let i in t){let a=t[i];if(a.length===0)continue;let c=(0,so.propertyInData)(r,n,i,o.opts.ownProperties);e.setParams({property:i,depsCount:a.length,deps:a.join(", ")}),o.allErrors?r.if(c,()=>{for(let u of a)(0,so.checkReportMissingProp)(e,u)}):(r.if((0,Iu._)`${c} && (${(0,so.checkMissingProp)(e,a,s)})`),(0,so.reportMissingProp)(e,s),r.else())}}ft.validatePropertyDeps=Jy;function Gy(e,t=e.schema){let{gen:r,data:n,keyword:o,it:s}=e,i=r.name("valid");for(let a in t)(0,sI.alwaysValidSchema)(s,t[a])||(r.if((0,so.propertyInData)(r,n,a,s.opts.ownProperties),()=>{let c=e.subschema({keyword:o,schemaProp:a},i);e.mergeValidEvaluated(c,i)},()=>r.var(i,!0)),e.ok(i))}ft.validateSchemaDeps=Gy;ft.default=iI});var Xy=S(Eu=>{"use strict";Object.defineProperty(Eu,"__esModule",{value:!0});var Yy=q(),cI=H(),uI={message:"property name must be valid",params:({params:e})=>(0,Yy._)`{propertyName: ${e.propertyName}}`},lI={keyword:"propertyNames",type:"object",schemaType:["object","boolean"],error:uI,code(e){let{gen:t,schema:r,data:n,it:o}=e;if((0,cI.alwaysValidSchema)(o,r))return;let s=t.name("valid");t.forIn("key",n,i=>{e.setParams({propertyName:i}),e.subschema({keyword:"propertyNames",data:i,dataTypes:["string"],propertyName:i,compositeRule:!0},s),t.if((0,Yy.not)(s),()=>{e.error(!0),o.allErrors||t.break()})}),e.ok(s)}};Eu.default=lI});var Ou=S(Tu=>{"use strict";Object.defineProperty(Tu,"__esModule",{value:!0});var fi=Xe(),ct=q(),dI=xt(),pi=H(),fI={message:"must NOT have additional properties",params:({params:e})=>(0,ct._)`{additionalProperty: ${e.additionalProperty}}`},pI={keyword:"additionalProperties",type:["object"],schemaType:["boolean","object"],allowUndefined:!0,trackErrors:!0,error:fI,code(e){let{gen:t,schema:r,parentSchema:n,data:o,errsCount:s,it:i}=e;if(!s)throw new Error("ajv implementation error");let{allErrors:a,opts:c}=i;if(i.props=!0,c.removeAdditional!=="all"&&(0,pi.alwaysValidSchema)(i,r))return;let u=(0,fi.allSchemaProperties)(n.properties),l=(0,fi.allSchemaProperties)(n.patternProperties);d(),e.ok((0,ct._)`${s} === ${dI.default.errors}`);function d(){t.forIn("key",o,g=>{!u.length&&!l.length?m(g):t.if(f(g),()=>m(g))})}function f(g){let y;if(u.length>8){let v=(0,pi.schemaRefOrVal)(i,n.properties,"properties");y=(0,fi.isOwnProperty)(t,v,g)}else u.length?y=(0,ct.or)(...u.map(v=>(0,ct._)`${g} === ${v}`)):y=ct.nil;return l.length&&(y=(0,ct.or)(y,...l.map(v=>(0,ct._)`${(0,fi.usePattern)(e,v)}.test(${g})`))),(0,ct.not)(y)}function p(g){t.code((0,ct._)`delete ${o}[${g}]`)}function m(g){if(c.removeAdditional==="all"||c.removeAdditional&&r===!1){p(g);return}if(r===!1){e.setParams({additionalProperty:g}),e.error(),a||t.break();return}if(typeof r=="object"&&!(0,pi.alwaysValidSchema)(i,r)){let y=t.name("valid");c.removeAdditional==="failing"?(h(g,y,!1),t.if((0,ct.not)(y),()=>{e.reset(),p(g)})):(h(g,y),a||t.if((0,ct.not)(y),()=>t.break()))}}function h(g,y,v){let k={keyword:"additionalProperties",dataProp:g,dataPropType:pi.Type.Str};v===!1&&Object.assign(k,{compositeRule:!0,createErrors:!1,allErrors:!1}),e.subschema(k,y)}}};Tu.default=pI});var t_=S(Au=>{"use strict";Object.defineProperty(Au,"__esModule",{value:!0});var mI=Vn(),Qy=Xe(),Ru=H(),e_=Ou(),hI={keyword:"properties",type:"object",schemaType:"object",code(e){let{gen:t,schema:r,parentSchema:n,data:o,it:s}=e;s.opts.removeAdditional==="all"&&n.additionalProperties===void 0&&e_.default.code(new mI.KeywordCxt(s,e_.default,"additionalProperties"));let i=(0,Qy.allSchemaProperties)(r);for(let d of i)s.definedProperties.add(d);s.opts.unevaluated&&i.length&&s.props!==!0&&(s.props=Ru.mergeEvaluated.props(t,(0,Ru.toHash)(i),s.props));let a=i.filter(d=>!(0,Ru.alwaysValidSchema)(s,r[d]));if(a.length===0)return;let c=t.name("valid");for(let d of a)u(d)?l(d):(t.if((0,Qy.propertyInData)(t,o,d,s.opts.ownProperties)),l(d),s.allErrors||t.else().var(c,!0),t.endIf()),e.it.definedProperties.add(d),e.ok(c);function u(d){return s.opts.useDefaults&&!s.compositeRule&&r[d].default!==void 0}function l(d){e.subschema({keyword:"properties",schemaProp:d,dataProp:d},c)}}};Au.default=hI});var s_=S(Cu=>{"use strict";Object.defineProperty(Cu,"__esModule",{value:!0});var r_=Xe(),mi=q(),n_=H(),o_=H(),gI={keyword:"patternProperties",type:"object",schemaType:"object",code(e){let{gen:t,schema:r,data:n,parentSchema:o,it:s}=e,{opts:i}=s,a=(0,r_.allSchemaProperties)(r),c=a.filter(h=>(0,n_.alwaysValidSchema)(s,r[h]));if(a.length===0||c.length===a.length&&(!s.opts.unevaluated||s.props===!0))return;let u=i.strictSchema&&!i.allowMatchingProperties&&o.properties,l=t.name("valid");s.props!==!0&&!(s.props instanceof mi.Name)&&(s.props=(0,o_.evaluatedPropsToName)(t,s.props));let{props:d}=s;f();function f(){for(let h of a)u&&p(h),s.allErrors?m(h):(t.var(l,!0),m(h),t.if(l))}function p(h){for(let g in u)new RegExp(h).test(g)&&(0,n_.checkStrictMode)(s,`property ${g} matches pattern ${h} (use allowMatchingProperties)`)}function m(h){t.forIn("key",n,g=>{t.if((0,mi._)`${(0,r_.usePattern)(e,h)}.test(${g})`,()=>{let y=c.includes(h);y||e.subschema({keyword:"patternProperties",schemaProp:h,dataProp:g,dataPropType:o_.Type.Str},l),s.opts.unevaluated&&d!==!0?t.assign((0,mi._)`${d}[${g}]`,!0):!y&&!s.allErrors&&t.if((0,mi.not)(l),()=>t.break())})})}}};Cu.default=gI});var i_=S(Nu=>{"use strict";Object.defineProperty(Nu,"__esModule",{value:!0});var yI=H(),_I={keyword:"not",schemaType:["object","boolean"],trackErrors:!0,code(e){let{gen:t,schema:r,it:n}=e;if((0,yI.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"}};Nu.default=_I});var a_=S(ju=>{"use strict";Object.defineProperty(ju,"__esModule",{value:!0});var wI=Xe(),bI={keyword:"anyOf",schemaType:"array",trackErrors:!0,code:wI.validateUnion,error:{message:"must match a schema in anyOf"}};ju.default=bI});var c_=S(Du=>{"use strict";Object.defineProperty(Du,"__esModule",{value:!0});var hi=q(),vI=H(),$I={message:"must match exactly one schema in oneOf",params:({params:e})=>(0,hi._)`{passingSchemas: ${e.passing}}`},kI={keyword:"oneOf",schemaType:"array",trackErrors:!0,error:$I,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 s=r,i=t.let("valid",!1),a=t.let("passing",null),c=t.name("_valid");e.setParams({passing:a}),t.block(u),e.result(i,()=>e.reset(),()=>e.error(!0));function u(){s.forEach((l,d)=>{let f;(0,vI.alwaysValidSchema)(o,l)?t.var(c,!0):f=e.subschema({keyword:"oneOf",schemaProp:d,compositeRule:!0},c),d>0&&t.if((0,hi._)`${c} && ${i}`).assign(i,!1).assign(a,(0,hi._)`[${a}, ${d}]`).else(),t.if(c,()=>{t.assign(i,!0),t.assign(a,d),f&&e.mergeEvaluated(f,hi.Name)})})}}};Du.default=kI});var u_=S(Zu=>{"use strict";Object.defineProperty(Zu,"__esModule",{value:!0});var xI=H(),SI={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((s,i)=>{if((0,xI.alwaysValidSchema)(n,s))return;let a=e.subschema({keyword:"allOf",schemaProp:i},o);e.ok(o),e.mergeEvaluated(a)})}};Zu.default=SI});var f_=S(Mu=>{"use strict";Object.defineProperty(Mu,"__esModule",{value:!0});var gi=q(),d_=H(),zI={message:({params:e})=>(0,gi.str)`must match "${e.ifClause}" schema`,params:({params:e})=>(0,gi._)`{failingKeyword: ${e.ifClause}}`},PI={keyword:"if",schemaType:["object","boolean"],trackErrors:!0,error:zI,code(e){let{gen:t,parentSchema:r,it:n}=e;r.then===void 0&&r.else===void 0&&(0,d_.checkStrictMode)(n,'"if" without "then" and "else" is ignored');let o=l_(n,"then"),s=l_(n,"else");if(!o&&!s)return;let i=t.let("valid",!0),a=t.name("_valid");if(c(),e.reset(),o&&s){let l=t.let("ifClause");e.setParams({ifClause:l}),t.if(a,u("then",l),u("else",l))}else o?t.if(a,u("then")):t.if((0,gi.not)(a),u("else"));e.pass(i,()=>e.error(!0));function c(){let l=e.subschema({keyword:"if",compositeRule:!0,createErrors:!1,allErrors:!1},a);e.mergeEvaluated(l)}function u(l,d){return()=>{let f=e.subschema({keyword:l},a);t.assign(i,a),e.mergeValidEvaluated(f,i),d?t.assign(d,(0,gi._)`${l}`):e.setParams({ifClause:l})}}}};function l_(e,t){let r=e.schema[t];return r!==void 0&&!(0,d_.alwaysValidSchema)(e,r)}Mu.default=PI});var p_=S(qu=>{"use strict";Object.defineProperty(qu,"__esModule",{value:!0});var II=H(),EI={keyword:["then","else"],schemaType:["object","boolean"],code({keyword:e,parentSchema:t,it:r}){t.if===void 0&&(0,II.checkStrictMode)(r,`"${e}" without "if" is ignored`)}};qu.default=EI});var m_=S(Fu=>{"use strict";Object.defineProperty(Fu,"__esModule",{value:!0});var TI=ku(),OI=Vy(),RI=xu(),AI=Hy(),CI=Ky(),NI=Wy(),jI=Xy(),DI=Ou(),ZI=t_(),MI=s_(),qI=i_(),FI=a_(),LI=c_(),UI=u_(),VI=f_(),BI=p_();function HI(e=!1){let t=[qI.default,FI.default,LI.default,UI.default,VI.default,BI.default,jI.default,DI.default,NI.default,ZI.default,MI.default];return e?t.push(OI.default,AI.default):t.push(TI.default,RI.default),t.push(CI.default),t}Fu.default=HI});var h_=S(Lu=>{"use strict";Object.defineProperty(Lu,"__esModule",{value:!0});var pe=q(),KI={message:({schemaCode:e})=>(0,pe.str)`must match format "${e}"`,params:({schemaCode:e})=>(0,pe._)`{format: ${e}}`},JI={keyword:"format",type:["number","string"],schemaType:"string",$data:!0,error:KI,code(e,t){let{gen:r,data:n,$data:o,schema:s,schemaCode:i,it:a}=e,{opts:c,errSchemaPath:u,schemaEnv:l,self:d}=a;if(!c.validateFormats)return;o?f():p();function f(){let m=r.scopeValue("formats",{ref:d.formats,code:c.code.formats}),h=r.const("fDef",(0,pe._)`${m}[${i}]`),g=r.let("fType"),y=r.let("format");r.if((0,pe._)`typeof ${h} == "object" && !(${h} instanceof RegExp)`,()=>r.assign(g,(0,pe._)`${h}.type || "string"`).assign(y,(0,pe._)`${h}.validate`),()=>r.assign(g,(0,pe._)`"string"`).assign(y,h)),e.fail$data((0,pe.or)(v(),k()));function v(){return c.strictSchema===!1?pe.nil:(0,pe._)`${i} && !${y}`}function k(){let T=l.$async?(0,pe._)`(${h}.async ? await ${y}(${n}) : ${y}(${n}))`:(0,pe._)`${y}(${n})`,x=(0,pe._)`(typeof ${y} == "function" ? ${T} : ${y}.test(${n}))`;return(0,pe._)`${y} && ${y} !== true && ${g} === ${t} && !${x}`}}function p(){let m=d.formats[s];if(!m){v();return}if(m===!0)return;let[h,g,y]=k(m);h===t&&e.pass(T());function v(){if(c.strictSchema===!1){d.logger.warn(x());return}throw new Error(x());function x(){return`unknown format "${s}" ignored in schema at path "${u}"`}}function k(x){let $=x instanceof RegExp?(0,pe.regexpCode)(x):c.code.formats?(0,pe._)`${c.code.formats}${(0,pe.getProperty)(s)}`:void 0,P=r.scopeValue("formats",{key:s,ref:x,code:$});return typeof x=="object"&&!(x instanceof RegExp)?[x.type||"string",x.validate,(0,pe._)`${P}.validate`]:["string",x,P]}function T(){if(typeof m=="object"&&!(m instanceof RegExp)&&m.async){if(!l.$async)throw new Error("async format in sync schema");return(0,pe._)`await ${y}(${n})`}return typeof g=="function"?(0,pe._)`${y}(${n})`:(0,pe._)`${y}.test(${n})`}}}};Lu.default=JI});var g_=S(Uu=>{"use strict";Object.defineProperty(Uu,"__esModule",{value:!0});var GI=h_(),WI=[GI.default];Uu.default=WI});var y_=S(Zr=>{"use strict";Object.defineProperty(Zr,"__esModule",{value:!0});Zr.contentVocabulary=Zr.metadataVocabulary=void 0;Zr.metadataVocabulary=["title","description","default","deprecated","readOnly","writeOnly","examples"];Zr.contentVocabulary=["contentMediaType","contentEncoding","contentSchema"]});var w_=S(Vu=>{"use strict";Object.defineProperty(Vu,"__esModule",{value:!0});var YI=zy(),XI=qy(),QI=m_(),eE=g_(),__=y_(),tE=[YI.default,XI.default,(0,QI.default)(),eE.default,__.metadataVocabulary,__.contentVocabulary];Vu.default=tE});var v_=S(yi=>{"use strict";Object.defineProperty(yi,"__esModule",{value:!0});yi.DiscrError=void 0;var b_;(function(e){e.Tag="tag",e.Mapping="mapping"})(b_||(yi.DiscrError=b_={}))});var k_=S(Hu=>{"use strict";Object.defineProperty(Hu,"__esModule",{value:!0});var Mr=q(),Bu=v_(),$_=Ws(),rE=Bn(),nE=H(),oE={message:({params:{discrError:e,tagName:t}})=>e===Bu.DiscrError.Tag?`tag "${t}" must be string`:`value of tag "${t}" must be in oneOf`,params:({params:{discrError:e,tag:t,tagName:r}})=>(0,Mr._)`{error: ${e}, tag: ${r}, tagValue: ${t}}`},sE={keyword:"discriminator",type:"object",schemaType:"object",error:oE,code(e){let{gen:t,data:r,schema:n,parentSchema:o,it:s}=e,{oneOf:i}=o;if(!s.opts.discriminator)throw new Error("discriminator: requires discriminator option");let a=n.propertyName;if(typeof a!="string")throw new Error("discriminator: requires propertyName");if(n.mapping)throw new Error("discriminator: mapping is not supported");if(!i)throw new Error("discriminator: requires oneOf keyword");let c=t.let("valid",!1),u=t.const("tag",(0,Mr._)`${r}${(0,Mr.getProperty)(a)}`);t.if((0,Mr._)`typeof ${u} == "string"`,()=>l(),()=>e.error(!1,{discrError:Bu.DiscrError.Tag,tag:u,tagName:a})),e.ok(c);function l(){let p=f();t.if(!1);for(let m in p)t.elseIf((0,Mr._)`${u} === ${m}`),t.assign(c,d(p[m]));t.else(),e.error(!1,{discrError:Bu.DiscrError.Mapping,tag:u,tagName:a}),t.endIf()}function d(p){let m=t.name("valid"),h=e.subschema({keyword:"oneOf",schemaProp:p},m);return e.mergeEvaluated(h,Mr.Name),m}function f(){var p;let m={},h=y(o),g=!0;for(let T=0;T<i.length;T++){let x=i[T];if(x?.$ref&&!(0,nE.schemaHasRulesButRef)(x,s.self.RULES)){let P=x.$ref;if(x=$_.resolveRef.call(s.self,s.schemaEnv.root,s.baseId,P),x instanceof $_.SchemaEnv&&(x=x.schema),x===void 0)throw new rE.default(s.opts.uriResolver,s.baseId,P)}let $=(p=x?.properties)===null||p===void 0?void 0:p[a];if(typeof $!="object")throw new Error(`discriminator: oneOf subschemas (or referenced schemas) must have "properties/${a}"`);g=g&&(h||y(x)),v($,T)}if(!g)throw new Error(`discriminator: "${a}" must be required`);return m;function y({required:T}){return Array.isArray(T)&&T.includes(a)}function v(T,x){if(T.const)k(T.const,x);else if(T.enum)for(let $ of T.enum)k($,x);else throw new Error(`discriminator: "properties/${a}" must have "const" or "enum"`)}function k(T,x){if(typeof T!="string"||T in m)throw new Error(`discriminator: "${a}" values must be unique strings`);m[T]=x}}}};Hu.default=sE});var x_=S((dZ,iE)=>{iE.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 Ju=S((oe,Ku)=>{"use strict";Object.defineProperty(oe,"__esModule",{value:!0});oe.MissingRefError=oe.ValidationError=oe.CodeGen=oe.Name=oe.nil=oe.stringify=oe.str=oe._=oe.KeywordCxt=oe.Ajv=void 0;var aE=by(),cE=w_(),uE=k_(),S_=x_(),lE=["/properties"],_i="http://json-schema.org/draft-07/schema",qr=class extends aE.default{_addVocabularies(){super._addVocabularies(),cE.default.forEach(t=>this.addVocabulary(t)),this.opts.discriminator&&this.addKeyword(uE.default)}_addDefaultMetaSchema(){if(super._addDefaultMetaSchema(),!this.opts.meta)return;let t=this.opts.$data?this.$dataMetaSchema(S_,lE):S_;this.addMetaSchema(t,_i,!1),this.refs["http://json-schema.org/schema"]=_i}defaultMeta(){return this.opts.defaultMeta=super.defaultMeta()||(this.getSchema(_i)?_i:void 0)}};oe.Ajv=qr;Ku.exports=oe=qr;Ku.exports.Ajv=qr;Object.defineProperty(oe,"__esModule",{value:!0});oe.default=qr;var dE=Vn();Object.defineProperty(oe,"KeywordCxt",{enumerable:!0,get:function(){return dE.KeywordCxt}});var Fr=q();Object.defineProperty(oe,"_",{enumerable:!0,get:function(){return Fr._}});Object.defineProperty(oe,"str",{enumerable:!0,get:function(){return Fr.str}});Object.defineProperty(oe,"stringify",{enumerable:!0,get:function(){return Fr.stringify}});Object.defineProperty(oe,"nil",{enumerable:!0,get:function(){return Fr.nil}});Object.defineProperty(oe,"Name",{enumerable:!0,get:function(){return Fr.Name}});Object.defineProperty(oe,"CodeGen",{enumerable:!0,get:function(){return Fr.CodeGen}});var fE=Js();Object.defineProperty(oe,"ValidationError",{enumerable:!0,get:function(){return fE.default}});var pE=Bn();Object.defineProperty(oe,"MissingRefError",{enumerable:!0,get:function(){return pE.default}})});var A_=S(mt=>{"use strict";Object.defineProperty(mt,"__esModule",{value:!0});mt.formatNames=mt.fastFormats=mt.fullFormats=void 0;function pt(e,t){return{validate:e,compare:t}}mt.fullFormats={date:pt(E_,Xu),time:pt(Wu(!0),Qu),"date-time":pt(z_(!0),O_),"iso-time":pt(Wu(),T_),"iso-date-time":pt(z_(),R_),duration:/^P(?!$)((\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+S)?)?|(\d+W)?)$/,uri:wE,"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:zE,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:bE,int32:{type:"number",validate:kE},int64:{type:"number",validate:xE},float:{type:"number",validate:I_},double:{type:"number",validate:I_},password:!0,binary:!0};mt.fastFormats={...mt.fullFormats,date:pt(/^\d\d\d\d-[0-1]\d-[0-3]\d$/,Xu),time:pt(/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)$/i,Qu),"date-time":pt(/^\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,O_),"iso-time":pt(/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)?$/i,T_),"iso-date-time":pt(/^\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,R_),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};mt.formatNames=Object.keys(mt.fullFormats);function mE(e){return e%4===0&&(e%100!==0||e%400===0)}var hE=/^(\d\d\d\d)-(\d\d)-(\d\d)$/,gE=[0,31,28,31,30,31,30,31,31,30,31,30,31];function E_(e){let t=hE.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&&mE(r)?29:gE[n])}function Xu(e,t){if(e&&t)return e>t?1:e<t?-1:0}var Gu=/^(\d\d):(\d\d):(\d\d(?:\.\d+)?)(z|([+-])(\d\d)(?::?(\d\d))?)?$/i;function Wu(e){return function(r){let n=Gu.exec(r);if(!n)return!1;let o=+n[1],s=+n[2],i=+n[3],a=n[4],c=n[5]==="-"?-1:1,u=+(n[6]||0),l=+(n[7]||0);if(u>23||l>59||e&&!a)return!1;if(o<=23&&s<=59&&i<60)return!0;let d=s-l*c,f=o-u*c-(d<0?1:0);return(f===23||f===-1)&&(d===59||d===-1)&&i<61}}function Qu(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 T_(e,t){if(!(e&&t))return;let r=Gu.exec(e),n=Gu.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 Yu=/t|\s/i;function z_(e){let t=Wu(e);return function(n){let o=n.split(Yu);return o.length===2&&E_(o[0])&&t(o[1])}}function O_(e,t){if(!(e&&t))return;let r=new Date(e).valueOf(),n=new Date(t).valueOf();if(r&&n)return r-n}function R_(e,t){if(!(e&&t))return;let[r,n]=e.split(Yu),[o,s]=t.split(Yu),i=Xu(r,o);if(i!==void 0)return i||Qu(n,s)}var yE=/\/|:/,_E=/^(?:[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 wE(e){return yE.test(e)&&_E.test(e)}var P_=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/gm;function bE(e){return P_.lastIndex=0,P_.test(e)}var vE=-(2**31),$E=2**31-1;function kE(e){return Number.isInteger(e)&&e<=$E&&e>=vE}function xE(e){return Number.isInteger(e)}function I_(){return!0}var SE=/[^\\]\\Z/;function zE(e){if(SE.test(e))return!1;try{return new RegExp(e),!0}catch{return!1}}});var C_=S(Lr=>{"use strict";Object.defineProperty(Lr,"__esModule",{value:!0});Lr.formatLimitDefinition=void 0;var PE=Ju(),ut=q(),Ht=ut.operators,wi={formatMaximum:{okStr:"<=",ok:Ht.LTE,fail:Ht.GT},formatMinimum:{okStr:">=",ok:Ht.GTE,fail:Ht.LT},formatExclusiveMaximum:{okStr:"<",ok:Ht.LT,fail:Ht.GTE},formatExclusiveMinimum:{okStr:">",ok:Ht.GT,fail:Ht.LTE}},IE={message:({keyword:e,schemaCode:t})=>(0,ut.str)`should be ${wi[e].okStr} ${t}`,params:({keyword:e,schemaCode:t})=>(0,ut._)`{comparison: ${wi[e].okStr}, limit: ${t}}`};Lr.formatLimitDefinition={keyword:Object.keys(wi),type:"string",schemaType:"string",$data:!0,error:IE,code(e){let{gen:t,data:r,schemaCode:n,keyword:o,it:s}=e,{opts:i,self:a}=s;if(!i.validateFormats)return;let c=new PE.KeywordCxt(s,a.RULES.all.format.definition,"format");c.$data?u():l();function u(){let f=t.scopeValue("formats",{ref:a.formats,code:i.code.formats}),p=t.const("fmt",(0,ut._)`${f}[${c.schemaCode}]`);e.fail$data((0,ut.or)((0,ut._)`typeof ${p} != "object"`,(0,ut._)`${p} instanceof RegExp`,(0,ut._)`typeof ${p}.compare != "function"`,d(p)))}function l(){let f=c.schema,p=a.formats[f];if(!p||p===!0)return;if(typeof p!="object"||p instanceof RegExp||typeof p.compare!="function")throw new Error(`"${o}": format "${f}" does not define "compare" function`);let m=t.scopeValue("formats",{key:f,ref:p,code:i.code.formats?(0,ut._)`${i.code.formats}${(0,ut.getProperty)(f)}`:void 0});e.fail$data(d(m))}function d(f){return(0,ut._)`${f}.compare(${r}, ${n}) ${wi[o].fail} 0`}},dependencies:["format"]};var EE=e=>(e.addKeyword(Lr.formatLimitDefinition),e);Lr.default=EE});var Z_=S((io,D_)=>{"use strict";Object.defineProperty(io,"__esModule",{value:!0});var Ur=A_(),TE=C_(),el=q(),N_=new el.Name("fullFormats"),OE=new el.Name("fastFormats"),tl=(e,t={keywords:!0})=>{if(Array.isArray(t))return j_(e,t,Ur.fullFormats,N_),e;let[r,n]=t.mode==="fast"?[Ur.fastFormats,OE]:[Ur.fullFormats,N_],o=t.formats||Ur.formatNames;return j_(e,o,r,n),t.keywords&&(0,TE.default)(e),e};tl.get=(e,t="full")=>{let n=(t==="fast"?Ur.fastFormats:Ur.fullFormats)[e];if(!n)throw new Error(`Unknown format "${e}"`);return n};function j_(e,t,r,n){var o,s;(o=(s=e.opts.code).formats)!==null&&o!==void 0||(s.formats=(0,el._)`require("ajv-formats/dist/formats").${n}`);for(let i of t)e.addFormat(i,r[i])}D_.exports=io=tl;Object.defineProperty(io,"__esModule",{value:!0});io.default=tl});import{existsSync as uO}from"node:fs";import{homedir as Bw}from"node:os";import{isAbsolute as lO,join as Ii,sep as dO}from"node:path";import{fileURLToPath as fO}from"node:url";import uh from"node:process";var R={};wl(R,{BIGINT_FORMAT_RANGES:()=>wo,CONSTANT_CATCH:()=>Ol,Class:()=>Ri,NUMBER_FORMAT_RANGES:()=>Gr,aborted:()=>rt,allowsEval:()=>Di,assert:()=>ob,assertEqual:()=>Qw,assertIs:()=>rb,assertNever:()=>nb,assertNotEqual:()=>eb,assignProp:()=>Le,attachSchema:()=>Wr,base64ToUint8Array:()=>El,base64urlToUint8Array:()=>kb,cached:()=>hr,captureStackTrace:()=>yo,cleanEnum:()=>$b,cleanRegex:()=>Jr,clone:()=>tt,cloneDef:()=>ab,codePointLength:()=>Yr,constantCatch:()=>Rl,createTransparentProxy:()=>pb,defineLazy:()=>$l,defineLazyInternal:()=>J,derived:()=>Pb,esc:()=>Ni,escapeRegex:()=>yt,explicitlyAborted:()=>qi,extend:()=>gb,finalizeIssue:()=>nt,floatSafeRemainder:()=>Ci,getElementAtPath:()=>cb,getEnumValues:()=>pr,getLengthableOrigin:()=>Xr,getParsedType:()=>fb,getSizableOrigin:()=>Il,hexToUint8Array:()=>Sb,hide:()=>$o,installLazyProp:()=>Ob,isObject:()=>Jt,isPlainObject:()=>Tt,issue:()=>yr,joinValues:()=>go,jsonStringifyReplacer:()=>mr,members:()=>Li,merge:()=>_b,mergeDefs:()=>gt,normalizeParams:()=>O,nullish:()=>Ai,numKeys:()=>db,objectClone:()=>sb,omit:()=>hb,optionalKeys:()=>Mi,own:()=>Et,parsedType:()=>Fi,partial:()=>wb,pick:()=>mb,prefixIssues:()=>_t,primitiveTypes:()=>zl,promiseAllObject:()=>ub,propertyKeyTypes:()=>Zi,randomString:()=>lb,rawShape:()=>gr,required:()=>bb,safeExtend:()=>yb,shallowClone:()=>Sl,sizeCaps:()=>vo,slugify:()=>ji,stringifyPrimitive:()=>_o,toZod:()=>tb,uint8ArrayToBase64:()=>Tl,uint8ArrayToBase64url:()=>xb,uint8ArrayToHex:()=>zb,unwrapMessage:()=>fr});function Qw(e){return e}function eb(e){return e}function tb(){return e=>e}function rb(e){}function nb(e){throw new Error("Unexpected value in exhaustive check")}function ob(e){}function pr(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 go(e,t="|"){return e.map(r=>_o(r)).join(t)}function mr(e,t){return typeof t=="bigint"?t.toString():t}var Oi=class{constructor(t){this._getter=t,this._value=void 0}get value(){let t=this._getter;return t!==void 0&&(this._value=t(),this._getter=void 0),this._value}};function hr(e){return new Oi(e)}function Ai(e){return e==null}function Jr(e){let t=e.startsWith("^")?1:0,r=e.endsWith("$")?e.length-1:e.length;return e.slice(t,r)}function Ci(e,t){let r=e/t,n=Math.round(r),o=4*Number.EPSILON*Math.max(Math.abs(r),1);return Math.abs(r-n)<o?0:r-n}var vl=Symbol("evaluating");function $l(e,t,r){let n;Object.defineProperty(e,t,{get(){if(n!==vl)return n===void 0&&(n=vl,n=r()),n},set(o){Object.defineProperty(e,t,{value:o})},configurable:!0})}function sb(e){return Object.create(Object.getPrototypeOf(e),Object.getOwnPropertyDescriptors(e))}function Le(e,t,r){Object.defineProperty(e,t,{value:r,writable:!0,enumerable:!0,configurable:!0})}function gr(e){let t=Object.getOwnPropertyDescriptor(e,"shape");return t?.get?t.get.raw:t?.value}function ht(e){return gr(e._zod.def)??e._zod.def.shape}function kl(e,t,r){Object.defineProperty(e,t,{get(){let n=r();return Le(this,t,n),n},enumerable:!0,configurable:!0})}function xl(e,t,r){t in e?Le(e,t,r):e[t]=r}function Kt(e,t,r,n){let o=ht(t);for(let s of r){let i=Object.getOwnPropertyDescriptor(o,s);i.enumerable&&(i.get?kl(e,s,()=>{let a=t._zod.def.shape[s];return n?n(a,s):a}):xl(e,s,n?n(i.value,s):i.value))}}function ib(e,t){for(let r of Reflect.ownKeys(t)){let n=Object.getOwnPropertyDescriptor(t,r);n.enumerable&&(n.get?kl(e,r,()=>t[r]):xl(e,r,n.value))}}function gt(...e){let t={};for(let r of e){let n=Object.getOwnPropertyDescriptors(r);Object.assign(t,n)}return Object.defineProperties({},t)}function ab(e){return gt(e._zod.def)}function cb(e,t){return t?t.reduce((r,n)=>r?.[n],e):e}function ub(e){let t=Object.keys(e),r=t.map(n=>e[n]);return Promise.all(r).then(n=>{let o={};for(let s=0;s<t.length;s++)o[t[s]]=n[s];return o})}function lb(e=10){let t="abcdefghijklmnopqrstuvwxyz",r="";for(let n=0;n<e;n++)r+=t[Math.floor(Math.random()*t.length)];return r}function Ni(e){return JSON.stringify(e)}function ji(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}var yo="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function Jt(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}var Di=hr(()=>{if(Ce.jitless||typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{let e=Function;return new e(""),!0}catch{return!1}});function Tt(e){if(Jt(e)===!1)return!1;let t=e.constructor;if(t===void 0||typeof t!="function")return!0;let r=t.prototype;return!(Jt(r)===!1||Object.prototype.hasOwnProperty.call(r,"isPrototypeOf")===!1)}function Sl(e){return Tt(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}function db(e){let t=0;for(let r in e)Object.prototype.hasOwnProperty.call(e,r)&&t++;return t}var fb=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}`)}},Zi=new Set(["string","number","symbol"]),zl=new Set(["string","number","bigint","boolean","symbol","undefined"]);function yt(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function tt(e,t,r){let n=new e._zod.constr(t??e._zod.def);return(!t||r?.parent)&&(n._zod.parent=e),n}function O(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 pb(e){let t;return new Proxy({},{get(r,n,o){return t??(t=e()),Reflect.get(t,n,o)},set(r,n,o,s){return t??(t=e()),Reflect.set(t,n,o,s)},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 _o(e){return typeof e=="bigint"?e.toString()+"n":typeof e=="string"?`"${e}"`:`${e}`}function Mi(e){return Object.keys(e).filter(t=>e[t]._zod.optin!==void 0&&e[t]._zod.optout==="optional")}var Gr={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]},wo={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};function mb(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 s={};return Kt(s,e,bo(e,t)),tt(e,gt(r,{shape:s,checks:[]}))}function bo(e,t){let r=ht(e),n=[];for(let o of Reflect.ownKeys(t)){if(!Object.getOwnPropertyDescriptor(r,o)?.enumerable)throw new Error(`Unrecognized key: "${String(o)}"`);t[o]&&n.push(o)}return n}function hb(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 s=new Set(bo(e,t)),i={};return Kt(i,e,Reflect.ownKeys(ht(e)).filter(a=>!s.has(a))),tt(e,gt(r,{shape:i,checks:[]}))}function gb(e,t){if(!Tt(t))throw new Error("Invalid input to extend: expected a plain object");let r=e._zod.def.checks;if(r&&r.length>0){let o=ht(e);for(let s of Reflect.ownKeys(t))if(Object.getOwnPropertyDescriptor(o,s)!==void 0)throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}return tt(e,gt(e._zod.def,{shape:Pl(e,t)}))}function Pl(e,t){let r={};return Kt(r,e,Reflect.ownKeys(ht(e))),ib(r,t),r}function yb(e,t){if(!Tt(t))throw new Error("Invalid input to safeExtend: expected a plain object");return tt(e,gt(e._zod.def,{shape:Pl(e,t)}))}function _b(e,t){if(!t?._zod?.def)throw new Error("Invalid input to merge: expected an object schema. To merge a plain shape, use `.extend()`.");if(e._zod.def.checks?.length)throw new Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");let r={};Kt(r,e,Reflect.ownKeys(ht(e))),Kt(r,t,Reflect.ownKeys(ht(t)));let n=gt(e._zod.def,{shape:r,get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]});return tt(e,n)}function wb(e,t,r,n="partial"){let s=t._zod.def.checks;if(s&&s.length>0)throw new Error(`.${n}() cannot be used on object schemas containing refinements`);let a=r?new Set(bo(t,r)):void 0,c={};return Kt(c,t,Reflect.ownKeys(ht(t)),e&&((u,l)=>a&&!a.has(l)?u:new e({type:"optional",innerType:u}))),tt(t,gt(t._zod.def,{shape:c,checks:[]}))}function bb(e,t,r){let n=r?new Set(bo(t,r)):void 0,o={};return Kt(o,t,Reflect.ownKeys(ht(t)),(s,i)=>n&&!n.has(i)?s:new e({type:"nonoptional",innerType:s})),tt(t,gt(t._zod.def,{shape:o}))}function rt(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 qi(e,t=0){if(e.aborted===!0)return!0;for(let r=t;r<e.issues.length;r++)if(e.issues[r]?.continue===!1)return!0;return!1}function _t(e,t){return t.map(r=>{var n;return(n=r).path??(n.path=[]),r.path.unshift(e),r})}function fr(e){return typeof e=="string"?e:e?.message}function vo(e){let t=[];for(let r of e??[]){let n=r._zod.def;if(!/_(length|size)$|_equals$/.test(n.check))break;let o=n.maximum??n.length??n.size;o>=0&&t.push([o,r])}return t}function Wr(e,t,r){var n;for(let o=t;o<e.length;o++)(n=e[o]).schema??(n.schema=r)}function nt(e,t,r){var n;let o=e.inst?._zod?.traits;o?.has("$ZodType")&&(o.has("$ZodCheck")?(n=e).schema??(n.schema=e.inst):e.schema=e.inst);let s=e.schema!==e.inst?e.schema?._zod.def?.error:void 0,i=e.message?e.message:fr(e.inst?._zod.def?.error?.(e))??fr(s?.(e))??fr(t?.error?.(e))??fr(r.customError?.(e))??fr(r.localeError?.(e))??"Invalid input",a={};for(let c of Object.keys(e))c==="inst"||c==="schema"||c==="continue"||c==="input"||c==="__proto__"||(a[c]=e[c]);return a.path??(a.path=[]),a.message=i,t?.reportInput&&(a.input=e.input),a}function Il(e){return e instanceof Set?"set":e instanceof Map?"map":e instanceof File?"file":"unknown"}var vb=/[\uD800-\uDBFF]/;function Yr(e){let t=e.length;if(!vb.test(e))return t;let r=t;for(let n=0;n<t-1;n++)(e.charCodeAt(n)&64512)===55296&&(e.charCodeAt(n+1)&64512)===56320&&(r--,n++);return r}function Xr(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function Fi(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 yr(...e){let[t,r,n]=e;return typeof t=="string"?{message:t,code:"custom",input:r,inst:n}:{...t}}function $b(e){return Object.entries(e).filter(([t,r])=>Number.isNaN(Number.parseInt(t,10))).map(t=>t[1])}function El(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 Tl(e){let t="";for(let r=0;r<e.length;r++)t+=String.fromCharCode(e[r]);return btoa(t)}function kb(e){let t=e.replace(/-/g,"+").replace(/_/g,"/"),r="=".repeat((4-t.length%4)%4);return El(t+r)}function xb(e){return Tl(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function Sb(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 zb(e){return Array.from(e).map(t=>t.toString(16).padStart(2,"0")).join("")}var Ri=class{constructor(...t){}};function Li(e,t){for(let r in t){let n=Object.getOwnPropertyDescriptor(t,r);n.get?Object.defineProperty(e,r,{...n,enumerable:!1}):Ib(e,r,n.value)}}function Et(e,t,r,n=!0){return Object.defineProperty(e,t,{configurable:!0,writable:!0,enumerable:n,value:r}),r}function $o(e,t,r){return Et(e,t,r,!1)}function Pb(e,t){for(let r in e){let n=e[r];Object.defineProperty(t,r,{configurable:!0,enumerable:!0,get(){return Et(this,r,n(this))},set(o){Et(this,r,o)}})}return t}function Ib(e,t,r){Object.defineProperty(e,t,{configurable:!0,get(){return this==null?r:Et(this,t,r.bind(this))},set(n){Et(this,t,n)}})}function Eb(e,t){let r=Object.getPrototypeOf(e);return t in r?void 0:r}var Ti,It=!1,Tb={configurable:!0,get(){It=!0}};function J(e,t,r){let n=Object.getPrototypeOf(e._zod);if(t in n&&Ti!==e._zod){Ti=void 0;return}Ti=e._zod,Object.defineProperty(n,t,{configurable:!0,get(){Object.defineProperty(this,t,Tb);let o=It;It=!1;try{let s=r(this);return It?delete this[t]:Object.defineProperty(this,t,{configurable:!0,writable:!0,value:s}),It=It||o,s}catch(s){throw delete this[t],It=It||o,s}},set(o){Object.defineProperty(this,t,{configurable:!0,writable:!0,value:o})}})}function Ob(e,t,r,n){let o=Eb(e,t);o&&Object.defineProperty(o,t,{configurable:!0,get(){let s={configurable:!0,writable:!0,enumerable:n,value:void 0};return Object.defineProperty(this,t,s),s.value=r(this),Object.defineProperty(this,t,s),s.value},set(s){Object.defineProperty(this,t,{configurable:!0,writable:!0,enumerable:n,value:s})}})}var Ol="~constantCatch";function Rl(e){let t=()=>e;return t[Ol]=!0,t}var Al;var Ui={value:void 0,enumerable:!1},Cl="captureStackTrace"in Error?Error:null;function Rb(e){let t=Cl;if(t){let r=t.stackTraceLimit;if(typeof r=="number"){try{t.stackTraceLimit=0}catch{return Cl=null,new e}try{return new e}finally{t.stackTraceLimit=r}}}return new e}function b(e,t,r,n){let o={};function s(f){this.def=f,this.constr=d,this.traits=new Set}s.prototype=o;let i=r,a=i&&new WeakSet;function c(f,p){if(f._zod){if(f._zod.traits.has(e))return}else{Ui.value=new s(p);try{Object.defineProperty(f,"_zod",Ui)}finally{Ui.value=void 0}}if(f._zod.traits.add(e),t(f,p),a){let h=Object.getPrototypeOf(f),g=f._zod.constr.prototype,y=h;for(;y&&y!==g;)y=Object.getPrototypeOf(y);let v=y??h;a.has(v)||(a.add(v),Li(v,i))}let m=d.prototype;for(let h in m)Object.prototype.hasOwnProperty.call(m,h)&&(h in f||(f[h]=m[h].bind(f)))}let u=n?.Parent??Object;class l extends u{}Object.defineProperty(l,"name",{value:e});function d(f){let p=n?.Parent?Rb(l):this;c(p,f);let m=p._zod.deferred;if(m){for(let g of m)g();p._zod.deferred=void 0}let h=globalThis.__zod_globalConfig?.postProcessor;return h&&h(p),p}return Object.defineProperty(d,"init",{value:c}),Object.defineProperty(d,Symbol.hasInstance,{value:f=>n?.Parent&&f instanceof n.Parent?!0:f?._zod?.traits?.has(e)}),Object.defineProperty(d,"name",{value:e}),d}var ot=class extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}},_r=class extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}};(Al=globalThis).__zod_globalConfig??(Al.__zod_globalConfig={});var Ce=globalThis.__zod_globalConfig;function Ue(e){return e&&Object.assign(Ce,e),Ce}function Ab(){let e=this._zod;return e.message??(e.message=JSON.stringify(e.def,mr,2)),e.message}function Cb(e){this._zod.message=e}var Nb={get:Ab,set:Cb,enumerable:!0,configurable:!0},Bi={value:void 0,enumerable:!1},Nl=new WeakSet([Object.prototype,Error.prototype]),jl=(e,t)=>{e.name="$ZodError",Bi.value=t,Object.defineProperty(e,"issues",Bi),Bi.value=void 0,Object.defineProperty(e,"message",Nb);let r=Object.getPrototypeOf(e);Nl.has(r)||(Nl.add(r),Object.defineProperty(r,"toString",{configurable:!0,enumerable:!1,get(){let n=()=>this.message;return Object.defineProperty(this,"toString",{value:n,configurable:!0,writable:!0}),n},set(n){Object.defineProperty(this,"toString",{value:n,configurable:!0,writable:!0})}}))},Dl=b("$ZodError",jl),Zl=b("$ZodError",jl,void 0,{Parent:Error});function jb(e,t,r){return Object.prototype.hasOwnProperty.call(e,t)||(t==="__proto__"?Object.defineProperty(e,t,{value:r(),writable:!0,enumerable:!0,configurable:!0}):e[t]=r()),e[t]}function Ml(e,t=r=>r.message){let r={},n=[];for(let o of e.issues)o.path.length>0?jb(r,o.path[0],()=>[]).push(t(o)):n.push(t(o));return{formErrors:n,fieldErrors:r}}function ql(e,t=r=>r.message){let r={_errors:[]},n=(o,s=[])=>{for(let i of o.issues)if(i.code==="invalid_union"&&i.errors.length)i.errors.map(a=>n({issues:a},[...s,...i.path]));else if(i.code==="invalid_key")n({issues:i.issues},[...s,...i.path]);else if(i.code==="invalid_element")n({issues:i.issues},[...s,...i.path]);else{let a=[...s,...i.path];if(a.length===0)r._errors.push(t(i));else{let c=r,u=0;for(;u<a.length;){let l=a[u],d=u===a.length-1;if(l==="_errors"){d&&c._errors.push(t(i)),u++;continue}Object.prototype.hasOwnProperty.call(c,l)||Object.defineProperty(c,l,{value:{_errors:[]},enumerable:!0,writable:!0,configurable:!0});let f=c[l];d&&f._errors.push(t(i)),c=f,u++}}}};return n(e),r}function ko(e,t){return{callee:t?.callee??e,Err:t?.Err}}var xo=e=>{let t=(r,n,o,s)=>{let i=o?{...o,async:!1}:{async:!1},a=r._zod.run({value:n,issues:[]},i);if(a instanceof Promise)throw new ot;if(a.issues.length){let c=new(s?.Err??e)(a.issues.map(u=>nt(u,i,Ue())));throw yo(c,s?.callee??t),c}return a.value};return t};var So=e=>{let t=async(r,n,o,s)=>{let i=o?{...o,async:!0}:{async:!0},a=r._zod.run({value:n,issues:[]},i);if(a instanceof Promise&&(a=await a),a.issues.length){let c=new(s?.Err??e)(a.issues.map(u=>nt(u,i,Ue())));throw yo(c,s?.callee??t),c}return a.value};return t};var Qr=e=>(t,r,n)=>{let o=n?{...n,async:!1}:{async:!1},s=t._zod.run({value:r,issues:[]},o);if(s instanceof Promise)throw new ot;return s.issues.length?Fl(e,s.issues,o):{success:!0,data:s.value}},Hi=Qr(Zl);function Fl(e,t,r){let n;return{success:!1,get error(){return n||(n=new e(t.map(o=>nt(o,r,Ue()))),t=void 0,r=void 0),n},set error(o){n=o,t=void 0,r=void 0}}}var zo=e=>async(t,r,n)=>{let o=n?{...n,async:!0}:{async:!0},s=t._zod.run({value:r,issues:[]},o);return s instanceof Promise&&(s=await s),s.issues.length?Fl(e,s.issues,o):{success:!0,data:s.value}};var Zb=Symbol.for("zod.compile.invalid"),Mb=Symbol.for("zod.compile.fallback"),Po=((e,t,r)=>{let n=e._zod.bag.validator;if(n!==void 0){if(n(t)!==Zb)return!0;if(n.definite===!0&&r===void 0)return!1}return qb(e,t,r)});function qb(e,t,r){let n=r?{...r,async:!1,abortEarly:!0}:{async:!1,abortEarly:!0},o=e._zod.bag.fallbackRun,s;if(o?(n[Mb]=!0,s=o({value:t,issues:[]},n)):s=e._zod.run({value:t,issues:[]},n),s instanceof Promise)throw new ot;return s.issues.length===0}var Io=async(e,t,r)=>{let n=r?{...r,async:!0,abortEarly:!0}:{async:!0,abortEarly:!0},o=e._zod.run({value:t,issues:[]},n);return o instanceof Promise&&(o=await o),o.issues.length===0},Ll=e=>{let t=xo(e),r=(n,o,s,i)=>{let a=s?{...s,direction:"backward"}:{direction:"backward"};return t(n,o,a,ko(r,i))};return r};var Ul=e=>{let t=xo(e),r=(n,o,s,i)=>t(n,o,s,ko(r,i));return r};var Vl=e=>{let t=So(e),r=async(n,o,s,i)=>{let a=s?{...s,direction:"backward"}:{direction:"backward"};return await t(n,o,a,ko(r,i))};return r};var Bl=e=>{let t=So(e),r=async(n,o,s,i)=>await t(n,o,s,ko(r,i));return r};var Hl=e=>(t,r,n)=>{let o=n?{...n,direction:"backward"}:{direction:"backward"};return Qr(e)(t,r,o)};var Kl=e=>(t,r,n)=>Qr(e)(t,r,n);var Jl=e=>async(t,r,n)=>{let o=n?{...n,direction:"backward"}:{direction:"backward"};return zo(e)(t,r,o)};var Gl=e=>async(t,r,n)=>zo(e)(t,r,n);var Wl=/^[cC][0-9a-z]{6,}$/,Yl=/^[0-9a-z]+$/,Xl=/^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$/,Ql=/^[0-9a-vA-V]{20}$/,ed=/^[A-Za-z0-9]{27}$/,td=/^[a-zA-Z0-9_-]{21}$/;function rd(e){return new RegExp(`^[a-zA-Z0-9_-]{${e}}$`)}var nd=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/;var od=/^([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})$/,Ji=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)$/;var sd=/^(?:[A-Za-z0-9_'+\-]+\.)*[A-Za-z0-9_'+\-]*[A-Za-z0-9_+-]@(?:[A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;var Fb="^(?=[\\s\\S]*[\\p{Extended_Pictographic}\\p{Regional_Indicator}\\u20E3])[\\p{Extended_Pictographic}\\p{Emoji_Component}]+$";function id(){return new RegExp(Fb,"u")}var ad=/^(?:(?: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])$/,cd=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/;var ud=/^((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])$/,ld=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,dd=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,fd=/^(?:[A-Za-z0-9_-]{4})*(?:[A-Za-z0-9_-]{2,3})?$/;var pd=/^https?$/,md=/^\+[1-9]\d{6,14}$/;var hd="(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))";function Lb(e){return new RegExp(`^${e}$`)}var gd=Lb(hd);function Ki(e){let t="(?:[01]\\d|2[0-3]):[0-5]\\d";return typeof e.precision=="number"?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:e.seconds?`${t}:[0-5]\\d(?:\\.\\d+)?`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function yd(e){return new RegExp(`^${Ki(e)}$`)}function _d(e){let t=["Z"];e.offset&&t.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");let r=`${Ki({precision:e.precision,seconds:!0})}(?:${t.join("|")})`,n=e.local?`${r}|${Ki({precision:e.precision})}`:r;return new RegExp(`^${hd}T(?:${n})$`)}var wd=/^[\s\S]{0,}$/;var Gi=/^-?\d+$/,en=/^-?\d+(?:\.\d+)?$/,bd=/^(?:true|false)$/i,vd=/^null$/i;var $d=/^[^A-Z]*$/,kd=/^[^a-z]*$/;var ye=b("$ZodCheck",(e,t)=>{var r;e._zod??(e._zod={}),e._zod.def=t,(r=e._zod).onattach??(r.onattach=[])});var Wi=e=>{let t=e.value;return!Ai(t)&&t.length!==void 0},Eo={number:"number",bigint:"bigint",object:"date"},Yi=b("$ZodCheckLessThan",(e,t)=>{ye.init(e,t);let r=Eo[typeof t.value];e._zod.check=n=>{(t.inclusive?n.value<=t.value:n.value<t.value)||n.issues.push({origin:Eo[typeof n.value]??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})}}),Xi=b("$ZodCheckGreaterThan",(e,t)=>{ye.init(e,t);let r=Eo[typeof t.value];e._zod.check=n=>{(t.inclusive?n.value>=t.value:n.value>t.value)||n.issues.push({origin:Eo[typeof n.value]??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})}}),xd=b("$ZodCheckMultipleOf",(e,t)=>{ye.init(e,t),e._zod.check=r=>{if(typeof r.value!=typeof t.value)throw new Error("Cannot mix number and bigint in multiple_of check.");(typeof r.value=="bigint"?t.value!==BigInt(0)&&r.value%t.value===BigInt(0):Ci(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})}}),Sd=b("$ZodCheckNumberFormat",(e,t)=>{ye.init(e,t),t.format=t.format||"float64";let r=t.format?.includes("int"),n=r?"int":"number",[o,s]=Gr[t.format];e._zod.check=i=>{let a=i.value;if(r){if(!Number.isInteger(a)){i.issues.push({expected:n,format:t.format,code:"invalid_type",continue:!1,input:a,inst:e});return}if(!Number.isSafeInteger(a)){a>0?i.issues.push({input:a,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:n,inclusive:!0,continue:!t.abort}):i.issues.push({input:a,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:n,inclusive:!0,continue:!t.abort});return}}a<o&&i.issues.push({origin:"number",input:a,code:"too_small",minimum:o,inclusive:!0,inst:e,continue:!t.abort}),a>s&&i.issues.push({origin:"number",input:a,code:"too_big",maximum:s,inclusive:!0,inst:e,continue:!t.abort})}});var zd=b("$ZodCheckMaxLength",(e,t)=>{var r;ye.init(e,t),(r=e._zod.def).when??(r.when=Wi),e._zod.check=n=>{let o=n.value,s=o.length;if((typeof o=="string"&&s>t.maximum?Yr(o):s)<=t.maximum)return;let a=Xr(o);n.issues.push({origin:a,code:"too_big",maximum:t.maximum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),Pd=b("$ZodCheckMinLength",(e,t)=>{var r;ye.init(e,t),(r=e._zod.def).when??(r.when=Wi),e._zod.check=n=>{let o=n.value,s=o.length;if((typeof o=="string"&&s>=t.minimum&&s<t.minimum*2?Yr(o):s)>=t.minimum)return;let a=Xr(o);n.issues.push({origin:a,code:"too_small",minimum:t.minimum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),Id=b("$ZodCheckLengthEquals",(e,t)=>{var r;ye.init(e,t),(r=e._zod.def).when??(r.when=Wi),e._zod.check=n=>{let o=n.value,s=o.length,i=typeof o=="string"&&s>=t.length&&s<=t.length*2?Yr(o):s;if(i===t.length)return;let a=Xr(o),c=i>t.length;n.issues.push({origin:a,...c?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}}),rn=b("$ZodCheckStringFormat",(e,t)=>{var r,n;ye.init(e,t),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=()=>{})}),Ed=b("$ZodCheckRegex",(e,t)=>{rn.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})}}),Td=b("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=$d),rn.init(e,t)}),Od=b("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=kd),rn.init(e,t)}),Rd=b("$ZodCheckIncludes",(e,t)=>{ye.init(e,t);let r=yt(t.includes),n=new RegExp(typeof t.position=="number"?`^.{${t.position},}${r}`:r);t.pattern=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})}}),Ad=b("$ZodCheckStartsWith",(e,t)=>{ye.init(e,t);let r=new RegExp(`^${yt(t.prefix)}.*`);t.pattern??(t.pattern=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})}}),Cd=b("$ZodCheckEndsWith",(e,t)=>{ye.init(e,t);let r=new RegExp(`.*${yt(t.suffix)}$`);t.pattern??(t.pattern=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})}});var Nd=b("$ZodCheckOverwrite",(e,t)=>{ye.init(e,t),e._zod.check=r=>{r.value=t.tx(r.value)}});var To=class{constructor(t=[],r={}){this.content=[],this.indent=0,this.args=t,this.closed=r}indented(t){this.indent+=1;try{t(this)}finally{this.indent-=1}}write(t){if(typeof t=="function"){t(this,{execution:"sync"}),t(this,{execution:"async"});return}let n=t.split(`
|
|
11
11
|
`).filter(i=>i),o=Math.min(...n.map(i=>i.length-i.trimStart().length)),s=n.map(i=>i.slice(o)).map(i=>" ".repeat(this.indent*2)+i);for(let i of s)this.content.push(i)}compile(){let t=Function,r=this?.content??[""];return new t(...Object.keys(this.closed),`return function (${this.args.join(", ")}) {
|
|
12
12
|
${r.join(`
|
|
13
13
|
`)}
|
|
14
|
-
};`)(...Object.values(this.closed))}};var Pd={major:4,minor:6,patch:7};var G=_("$ZodType",(e,t)=>{var r;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=Pd;let n=e._zod.def.checks,o=e._zod.traits.has("$ZodCheck")?[e,...n??[]]:n?.length?[...n]:[];for(let s of o)for(let i of s._zod.onattach)i(e);if(o.length===0)(r=e._zod).deferred??(r.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let s=(a,c,u)=>{if(a.memo)return a;let l=Ke(a),d;for(let f of c){if(f._zod.def.when){if(Ai(a)||!f._zod.def.when(a))continue}else if(l)continue;let p=a.issues.length,m=f._zod.check(a);if(m instanceof Promise&&u?.async===!1)throw new We;if(d||m instanceof Promise)d=(d??Promise.resolve()).then(async()=>{await m,a.issues.length!==p&&(Hr(a.issues,p,e),l||(l=Ke(a,p)))});else{if(a.issues.length===p)continue;Hr(a.issues,p,e),l||(l=Ke(a,p))}}return d?d.then(()=>a):a},i=(a,c,u)=>{if(Ke(a))return a.aborted=!0,a;let l=s(c,o,u);if(l instanceof Promise){if(u.async===!1)throw new We;return l.then(d=>e._zod.parse(d,u))}return e._zod.parse(l,u)};e._zod.run=(a,c)=>{if(c.skipChecks)return e._zod.parse(a,c);if(c.direction==="backward"){let l=e._zod.parse({value:a.value,issues:[]},{...c,skipChecks:!0});return l instanceof Promise?l.then(d=>i(d,a,c)):i(l,a,c)}let u=e._zod.parse(a,c);if(u instanceof Promise){if(c.async===!1)throw new We;return u.then(l=>s(l,o,c))}return s(u,o,c)}}},{get"~standard"(){return yo(this,"~standard",Ji(this))},set"~standard"(e){wt(this,"~standard",e)}}),Zd=(e,t)=>e.issues.length?{issues:e.issues.map(r=>Ge(r,t,Ae()))}:{value:e.value};async function wb(e,t){let r={async:!0};return Zd(await e._zod.run({value:t,issues:[]},r),r)}function Ji(e){return{validate:t=>{let r={async:!1};try{let n=e._zod.run({value:t,issues:[]},r);if(!(n instanceof Promise))return Zd(n,r)}catch{}return wb(e,t)},vendor:"zod",version:1}}var Io=_("$ZodString",(e,t)=>{G.init(e,t),e._zod.pattern=t.pattern??ud,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}}),W=_("$ZodStringFormat",(e,t)=>{Yr.init(e,t),Io.init(e,t)}),Md=_("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=Kl),W.init(e,t)}),qd=_("$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=Fi(n))}else t.pattern??(t.pattern=Fi());W.init(e,t)}),Fd=_("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=Gl),W.init(e,t)}),Ld=1,Po=2;function Ud(e){try{return typeof URL<"u"&&typeof URL.canParse=="function"?URL.canParse(e):(new URL(e),!0)}catch{return!1}}function bb(e,t){return!("normalize"in t)&&!("hostname"in t)&&!("protocol"in t)?Ud(e)||Po:vb(e,t)}function vb(e,t){if(!t.normalize&&t.protocol?.source===nd.source&&!/^https?:\/\//i.test(e))return Ld;try{if(typeof URL<"u"){let r=URL;if(typeof r.parse=="function")return r.parse(e)??Po}return new URL(e)}catch{return Po}}var $b=/[\t\n\r]/g;function Ed(e){return e.replace($b,"")}function xb(e,t){return t.lastIndex=0,t.test(e.hostname)}function Sb(e,t){return t.lastIndex=0,t.test(e.protocol.endsWith(":")?e.protocol.slice(0,-1):e.protocol)}var Vd=_("$ZodURL",(e,t)=>{W.init(e,t),e._zod.check=r=>{try{let n=r.value.trim(),o=bb(n,t);if(o===Ld){r.issues.push({code:"invalid_format",format:"url",note:"Invalid URL format",input:r.value,inst:e,continue:!t.abort});return}if(o===Po){r.issues.push({code:"invalid_format",format:"url",input:r.value,inst:e,continue:!t.abort});return}if(o===!0){r.value=Ed(n);return}t.hostname&&!xb(o,t.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&&!Sb(o,t.protocol)&&r.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:r.value,inst:e,continue:!t.abort}),r.value=t.normalize?o.href:Ed(n);return}catch{r.issues.push({code:"invalid_format",format:"url",input:r.value,inst:e,continue:!t.abort})}}}),Hd=_("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=Wl()),W.init(e,t)}),Bd=_("$ZodNanoID",(e,t)=>{if(t.length!==void 0&&(!Number.isInteger(t.length)||t.length<1))throw new Error(`Invalid nanoid length: ${t.length}`);t.pattern??(t.pattern=t.length===void 0?Hl:Bl(t.length)),W.init(e,t)}),Jd=_("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=ql),W.init(e,t)}),Kd=_("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=Fl),W.init(e,t)}),Gd=_("$ZodULID",(e,t)=>{t.pattern??(t.pattern=Ll),W.init(e,t)}),Wd=_("$ZodXID",(e,t)=>{t.pattern??(t.pattern=Ul),W.init(e,t)}),Yd=_("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=Vl),W.init(e,t)}),Xd=_("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=cd(t)),W.init(e,t)}),Qd=_("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=id),W.init(e,t)}),ef=_("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=ad(t)),W.init(e,t)}),tf=_("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=Jl),W.init(e,t)}),rf=_("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=Yl),W.init(e,t)}),kb=/^[0-9a-fA-F:.]+$/;function nf(e){return kb.test(e)?Ud(`http://[${e}]`):!1}var of=_("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=Xl),W.init(e,t),e._zod.check=r=>{nf(r.value)||r.issues.push({code:"invalid_format",format:"ipv6",input:r.value,inst:e,continue:!t.abort})}});var sf=_("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=Ql),W.init(e,t)});function zb(e){let t=e.split("/");if(t.length!==2)return!1;let[r,n]=t;if(!n)return!1;let o=Number(n);return`${o}`!==n||o<0||o>128?!1:nf(r)}var af=_("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=ed),W.init(e,t),e._zod.check=r=>{zb(r.value)||r.issues.push({code:"invalid_format",format:"cidrv6",input:r.value,inst:e,continue:!t.abort})}});function cf(e){if(e==="")return!0;if(/\s/.test(e)||e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}var Ki=/^[0-9a-zA-Z+/]*={0,2}$/,uf=_("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=Ki),W.init(e,t),e._zod.check=r=>{cf(r.value)||r.issues.push({code:"invalid_format",format:"base64",input:r.value,inst:e,continue:!t.abort})}}),To=/^[A-Za-z0-9_-]*$/;function Pb(e){if(!To.test(e))return!1;let t=e.replace(/[-_]/g,n=>n==="-"?"+":"/"),r=t.padEnd(Math.ceil(t.length/4)*4,"=");return cf(r)}var lf=_("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=To),W.init(e,t),e._zod.check=r=>{Pb(r.value)||r.issues.push({code:"invalid_format",format:"base64url",input:r.value,inst:e,continue:!t.abort})}}),df=_("$ZodE164",(e,t)=>{t.pattern??(t.pattern=od),W.init(e,t)});function Eb(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 ff=_("$ZodJWT",(e,t)=>{W.init(e,t),e._zod.check=r=>{Eb(r.value,t.alg)||r.issues.push({code:"invalid_format",format:"jwt",input:r.value,inst:e,continue:!t.abort})}});var Gi=_("$ZodNumber",(e,t)=>{G.init(e,t),e._zod.pattern=Gr,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 s=typeof o=="number"?Number.isNaN(o)?"NaN":Number.isFinite(o)?void 0:String(o):void 0;return r.issues.push({expected:"number",code:"invalid_type",input:o,inst:e,...s?{received:s}:{}}),r}}),pf=_("$ZodNumberFormat",(e,t)=>{hd.init(e,t),Gi.init(e,t)}),mf=_("$ZodBoolean",(e,t)=>{G.init(e,t),e._zod.pattern=ld,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}});var hf=_("$ZodNull",(e,t)=>{G.init(e,t),e._zod.pattern=dd,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}});var gf=_("$ZodUnknown",(e,t)=>{G.init(e,t),e._zod.parse=r=>r}),yf=_("$ZodNever",(e,t)=>{G.init(e,t),e._zod.parse=(r,n)=>(r.issues.push({expected:"never",code:"invalid_type",input:r.value,inst:e}),r)});function Ib(e,t){let r=go(e._zod.def.checks);if(!r.length)return;let n=Math.min(...r.map(s=>s[0])),o=e._zod.parse;e._zod.parse=(s,i)=>{let a=t(s.value);if(a>n&&!i?.skipChecks&&i?.direction!=="backward"){for(let[c,u]of go(e._zod.def.checks))if(a>c&&u._zod.def.when(s)){let l=s.issues.length;return u._zod.check(s),s.issues[l].continue=!1,Hr(s.issues,l,e),s}}return o(s,i)}}var Tb=e=>Array.isArray(e)?e.length:-1;function Id(e,t,r){e.issues.length&&t.issues.push(...dt(r,e.issues)),t.value[r]=e.value}var _f=_("$ZodArray",(e,t)=>{G.init(e,t);let r=Se.memoizer;r?.attach(e),e._zod.parse=(n,o)=>{let s=n.value;if(!Array.isArray(s))return n.issues.push({expected:"array",code:"invalid_type",input:s,inst:e}),n;n.value=r?r.alloc(e,n,Array(s.length),o):Array(s.length);let i=[],a=o?.abortEarly;for(let c=0;c<s.length;c++){let u=s[c],l=t.element._zod.run({value:u,issues:[]},o);if(l instanceof Promise)i.push(l.then(d=>Id(d,n,c)));else if(Id(l,n,c),a&&l.issues.length!==0&&Ke(l))break}return i.length?Promise.all(i).then(()=>n):n},Ib(e,Tb)});function Eo(e,t,r,n,o,s){let i=r in n,a=s==="optional";if(!(!i&&a&&o==="optional")){if(e.issues.length){if(o!==void 0&&a&&!i)return;t.issues.push(...dt(r,e.issues))}if(!i&&o===void 0){e.issues.length||t.issues.push({code:"invalid_type",expected:"nonoptional",input:void 0,path:[r]});return}e.value===void 0?(i||o==="defaulted"&&!a)&&(t.value[r]=void 0):t.value[r]=e.value}}var Ob=[];function wf(e){let t=Object.keys(e.shape),r=Object.getOwnPropertySymbols(e.shape),n=r.length?r:Ob,o=n.length?[...t,...n]:t;for(let i of o)if(!e.shape?.[i]?._zod?.traits?.has("$ZodType"))throw new Error(`Invalid element at key "${String(i)}": expected a Zod schema`);let s=Ri(e.shape);return{...e,allKeys:o,symbolKeys:n,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(s)}}function bf(e,t,r,n,o,s,i){let a=[],c=o.keySet,u=o.catchall._zod,l=u.def.type,d=u.optin,f=u.optout,p=0;for(let m in t){if(i&&r.issues.length!==p){if(Ke(r,p))break;p=r.issues.length}if(c.has(m))continue;if(m==="__proto__"){l==="never"&&a.push(m);continue}if(l==="never"){a.push(m);continue}let h=u.run({value:t[m],issues:[]},n);h instanceof Promise?e.push(h.then(g=>Eo(g,r,m,t,d,f))):Eo(h,r,m,t,d,f)}return a.length&&r.issues.push({code:"unrecognized_keys",keys:a,input:t,inst:s,continue:!0}),e.length?Promise.all(e).then(()=>r):r}var Rb=_("$ZodObject",(e,t)=>{G.init(e,t);let r=Object.getOwnPropertyDescriptor(t,"shape"),n=r?.get?r.get.raw:t.shape??{};if(n){let u=()=>{let l={...n};return Object.defineProperty(t,"shape",{value:l}),u.raw=l,l};u.raw=n,Object.defineProperty(t,"shape",{get:u})}let o=lr(()=>wf(t));U(e,"propValues",u=>{let l=u.def.shape,d={};for(let f in l){let p=l[f]._zod;if(p.values){Object.prototype.hasOwnProperty.call(d,f)||Re(d,f,new Set);for(let m of p.values)d[f].add(m);p.optin!==void 0&&d[f].add(void 0)}}return d});let s=Mt,i=t.catchall,a,c=Se.memoizer;c?.attach(e),e._zod.parse=(u,l)=>{a??(a=o.value);let d=u.value;if(!s(d))return u.issues.push({expected:"object",code:"invalid_type",input:d,inst:e}),u;u.value=c?c.alloc(e,u,{},l):{};let f=[],p=a.shape,m=l?.abortEarly,h=u.issues.length;for(let g of a.allKeys){if(m&&u.issues.length!==h){if(Ke(u,h))break;h=u.issues.length}if(g==="__proto__")continue;let w=p[g],v=w._zod.optin,$=w._zod.optout,O=w._zod.run({value:d[g],issues:[]},l);O instanceof Promise?f.push(O.then(k=>Eo(k,u,g,d,v,$))):Eo(O,u,g,d,v,$)}return i?bf(f,d,u,l,o.value,e,m===!0):f.length?Promise.all(f).then(()=>u):u}}),vf=_("$ZodObjectJIT",(e,t)=>{Rb.init(e,t);let r=e._zod.parse,n=lr(()=>wf(t)),o=Se.memoizer,s=p=>{let m=n.value,h=m.symbolKeys,g=new ko(["payload","ctx"],{shape:p,inst:e,memo:o,syms:h}),w=k=>`shape[${k}]._zod.run({ value: input[${k}], issues: [] }, ctx)`,v=(k,N)=>`
|
|
15
|
-
let ${
|
|
16
|
-
for (let i = 0; i < ${
|
|
17
|
-
const iss = ${
|
|
18
|
-
iss.path = iss.path ? [${
|
|
14
|
+
};`)(...Object.values(this.closed))}};var Dd={major:4,minor:6,patch:7};var ee=b("$ZodType",(e,t)=>{var r;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=Dd;let n=e._zod.def.checks,o=e._zod.traits.has("$ZodCheck")?[e,...n??[]]:n?.length?[...n]:[];for(let s of o)for(let i of s._zod.onattach)i(e);if(o.length===0)(r=e._zod).deferred??(r.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let s=(a,c,u)=>{if(a.memo)return a;let l=rt(a),d;for(let f of c){if(f._zod.def.when){if(qi(a)||!f._zod.def.when(a))continue}else if(l)continue;let p=a.issues.length,m=f._zod.check(a);if(m instanceof Promise&&u?.async===!1)throw new ot;if(d||m instanceof Promise)d=(d??Promise.resolve()).then(async()=>{await m,a.issues.length!==p&&(Wr(a.issues,p,e),l||(l=rt(a,p)))});else{if(a.issues.length===p)continue;Wr(a.issues,p,e),l||(l=rt(a,p))}}return d?d.then(()=>a):a},i=(a,c,u)=>{if(rt(a))return a.aborted=!0,a;let l=s(c,o,u);if(l instanceof Promise){if(u.async===!1)throw new ot;return l.then(d=>e._zod.parse(d,u))}return e._zod.parse(l,u)};e._zod.run=(a,c)=>{if(c.skipChecks)return e._zod.parse(a,c);if(c.direction==="backward"){let l=e._zod.parse({value:a.value,issues:[]},{...c,skipChecks:!0});return l instanceof Promise?l.then(d=>i(d,a,c)):i(l,a,c)}let u=e._zod.parse(a,c);if(u instanceof Promise){if(c.async===!1)throw new ot;return u.then(l=>s(l,o,c))}return s(u,o,c)}}},{get"~standard"(){return $o(this,"~standard",ea(this))},set"~standard"(e){Et(this,"~standard",e)}}),Jd=(e,t)=>e.issues.length?{issues:e.issues.map(r=>nt(r,t,Ue()))}:{value:e.value};async function Ub(e,t){let r={async:!0};return Jd(await e._zod.run({value:t,issues:[]},r),r)}function ea(e){return{validate:t=>{let r={async:!1};try{let n=e._zod.run({value:t,issues:[]},r);if(!(n instanceof Promise))return Jd(n,r)}catch{}return Ub(e,t)},vendor:"zod",version:1}}var Co=b("$ZodString",(e,t)=>{ee.init(e,t),e._zod.pattern=t.pattern??wd,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}}),te=b("$ZodStringFormat",(e,t)=>{rn.init(e,t),Co.init(e,t)}),Gd=b("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=od),te.init(e,t)}),Wd=b("$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=Ji(n))}else t.pattern??(t.pattern=Ji());te.init(e,t)}),Yd=b("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=sd),te.init(e,t)}),Xd=1,Ro=2;function Qd(e){try{return typeof URL<"u"&&typeof URL.canParse=="function"?URL.canParse(e):(new URL(e),!0)}catch{return!1}}function Vb(e,t){return!("normalize"in t)&&!("hostname"in t)&&!("protocol"in t)?Qd(e)||Ro:Bb(e,t)}function Bb(e,t){if(!t.normalize&&t.protocol?.source===pd.source&&!/^https?:\/\//i.test(e))return Xd;try{if(typeof URL<"u"){let r=URL;if(typeof r.parse=="function")return r.parse(e)??Ro}return new URL(e)}catch{return Ro}}var Hb=/[\t\n\r]/g;function Zd(e){return e.replace(Hb,"")}function Kb(e,t){return t.lastIndex=0,t.test(e.hostname)}function Jb(e,t){return t.lastIndex=0,t.test(e.protocol.endsWith(":")?e.protocol.slice(0,-1):e.protocol)}var ef=b("$ZodURL",(e,t)=>{te.init(e,t),e._zod.check=r=>{try{let n=r.value.trim(),o=Vb(n,t);if(o===Xd){r.issues.push({code:"invalid_format",format:"url",note:"Invalid URL format",input:r.value,inst:e,continue:!t.abort});return}if(o===Ro){r.issues.push({code:"invalid_format",format:"url",input:r.value,inst:e,continue:!t.abort});return}if(o===!0){r.value=Zd(n);return}t.hostname&&!Kb(o,t.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&&!Jb(o,t.protocol)&&r.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:r.value,inst:e,continue:!t.abort}),r.value=t.normalize?o.href:Zd(n);return}catch{r.issues.push({code:"invalid_format",format:"url",input:r.value,inst:e,continue:!t.abort})}}}),tf=b("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=id()),te.init(e,t)}),rf=b("$ZodNanoID",(e,t)=>{if(t.length!==void 0&&(!Number.isInteger(t.length)||t.length<1))throw new Error(`Invalid nanoid length: ${t.length}`);t.pattern??(t.pattern=t.length===void 0?td:rd(t.length)),te.init(e,t)}),nf=b("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=Wl),te.init(e,t)}),of=b("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=Yl),te.init(e,t)}),sf=b("$ZodULID",(e,t)=>{t.pattern??(t.pattern=Xl),te.init(e,t)}),af=b("$ZodXID",(e,t)=>{t.pattern??(t.pattern=Ql),te.init(e,t)}),cf=b("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=ed),te.init(e,t)}),uf=b("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=_d(t)),te.init(e,t)}),lf=b("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=gd),te.init(e,t)}),df=b("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=yd(t)),te.init(e,t)}),ff=b("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=nd),te.init(e,t)}),pf=b("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=ad),te.init(e,t)}),Gb=/^[0-9a-fA-F:.]+$/;function mf(e){return Gb.test(e)?Qd(`http://[${e}]`):!1}var hf=b("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=cd),te.init(e,t),e._zod.check=r=>{mf(r.value)||r.issues.push({code:"invalid_format",format:"ipv6",input:r.value,inst:e,continue:!t.abort})}});var gf=b("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=ud),te.init(e,t)});function Wb(e){let t=e.split("/");if(t.length!==2)return!1;let[r,n]=t;if(!n)return!1;let o=Number(n);return`${o}`!==n||o<0||o>128?!1:mf(r)}var yf=b("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=ld),te.init(e,t),e._zod.check=r=>{Wb(r.value)||r.issues.push({code:"invalid_format",format:"cidrv6",input:r.value,inst:e,continue:!t.abort})}});function _f(e){if(e==="")return!0;if(/\s/.test(e)||e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}var ta=/^[0-9a-zA-Z+/]*={0,2}$/,wf=b("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=ta),te.init(e,t),e._zod.check=r=>{_f(r.value)||r.issues.push({code:"invalid_format",format:"base64",input:r.value,inst:e,continue:!t.abort})}}),No=/^[A-Za-z0-9_-]*$/;function Yb(e){if(!No.test(e))return!1;let t=e.replace(/[-_]/g,n=>n==="-"?"+":"/"),r=t.padEnd(Math.ceil(t.length/4)*4,"=");return _f(r)}var bf=b("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=No),te.init(e,t),e._zod.check=r=>{Yb(r.value)||r.issues.push({code:"invalid_format",format:"base64url",input:r.value,inst:e,continue:!t.abort})}}),vf=b("$ZodE164",(e,t)=>{t.pattern??(t.pattern=md),te.init(e,t)});function Xb(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 $f=b("$ZodJWT",(e,t)=>{te.init(e,t),e._zod.check=r=>{Xb(r.value,t.alg)||r.issues.push({code:"invalid_format",format:"jwt",input:r.value,inst:e,continue:!t.abort})}});var ra=b("$ZodNumber",(e,t)=>{ee.init(e,t),e._zod.pattern=en,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 s=typeof o=="number"?Number.isNaN(o)?"NaN":Number.isFinite(o)?void 0:String(o):void 0;return r.issues.push({expected:"number",code:"invalid_type",input:o,inst:e,...s?{received:s}:{}}),r}}),kf=b("$ZodNumberFormat",(e,t)=>{Sd.init(e,t),ra.init(e,t)}),xf=b("$ZodBoolean",(e,t)=>{ee.init(e,t),e._zod.pattern=bd,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}});var Sf=b("$ZodNull",(e,t)=>{ee.init(e,t),e._zod.pattern=vd,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}});var zf=b("$ZodUnknown",(e,t)=>{ee.init(e,t),e._zod.parse=r=>r}),Pf=b("$ZodNever",(e,t)=>{ee.init(e,t),e._zod.parse=(r,n)=>(r.issues.push({expected:"never",code:"invalid_type",input:r.value,inst:e}),r)});function Qb(e,t){let r=vo(e._zod.def.checks);if(!r.length)return;let n=Math.min(...r.map(s=>s[0])),o=e._zod.parse;e._zod.parse=(s,i)=>{let a=t(s.value);if(a>n&&!i?.skipChecks&&i?.direction!=="backward"){for(let[c,u]of vo(e._zod.def.checks))if(a>c&&u._zod.def.when(s)){let l=s.issues.length;return u._zod.check(s),s.issues[l].continue=!1,Wr(s.issues,l,e),s}}return o(s,i)}}var ev=e=>Array.isArray(e)?e.length:-1;function Md(e,t,r){e.issues.length&&t.issues.push(..._t(r,e.issues)),t.value[r]=e.value}var If=b("$ZodArray",(e,t)=>{ee.init(e,t);let r=Ce.memoizer;r?.attach(e),e._zod.parse=(n,o)=>{let s=n.value;if(!Array.isArray(s))return n.issues.push({expected:"array",code:"invalid_type",input:s,inst:e}),n;n.value=r?r.alloc(e,n,Array(s.length),o):Array(s.length);let i=[],a=o?.abortEarly;for(let c=0;c<s.length;c++){let u=s[c],l=t.element._zod.run({value:u,issues:[]},o);if(l instanceof Promise)i.push(l.then(d=>Md(d,n,c)));else if(Md(l,n,c),a&&l.issues.length!==0&&rt(l))break}return i.length?Promise.all(i).then(()=>n):n},Qb(e,ev)});function Ao(e,t,r,n,o,s){let i=r in n,a=s==="optional";if(!(!i&&a&&o==="optional")){if(e.issues.length){if(o!==void 0&&a&&!i)return;t.issues.push(..._t(r,e.issues))}if(!i&&o===void 0){e.issues.length||t.issues.push({code:"invalid_type",expected:"nonoptional",input:void 0,path:[r]});return}e.value===void 0?(i||o==="defaulted"&&!a)&&(t.value[r]=void 0):t.value[r]=e.value}}var tv=[];function Ef(e){let t=Object.keys(e.shape),r=Object.getOwnPropertySymbols(e.shape),n=r.length?r:tv,o=n.length?[...t,...n]:t;for(let i of o)if(!e.shape?.[i]?._zod?.traits?.has("$ZodType"))throw new Error(`Invalid element at key "${String(i)}": expected a Zod schema`);let s=Mi(e.shape);return{...e,allKeys:o,symbolKeys:n,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(s)}}function Tf(e,t,r,n,o,s,i){let a=[],c=o.keySet,u=o.catchall._zod,l=u.def.type,d=u.optin,f=u.optout,p=0;for(let m in t){if(i&&r.issues.length!==p){if(rt(r,p))break;p=r.issues.length}if(c.has(m))continue;if(m==="__proto__"){l==="never"&&a.push(m);continue}if(l==="never"){a.push(m);continue}let h=u.run({value:t[m],issues:[]},n);h instanceof Promise?e.push(h.then(g=>Ao(g,r,m,t,d,f))):Ao(h,r,m,t,d,f)}return a.length&&r.issues.push({code:"unrecognized_keys",keys:a,input:t,inst:s,continue:!0}),e.length?Promise.all(e).then(()=>r):r}var rv=b("$ZodObject",(e,t)=>{ee.init(e,t);let r=Object.getOwnPropertyDescriptor(t,"shape"),n=r?.get?r.get.raw:t.shape??{};if(n){let u=()=>{let l={...n};return Object.defineProperty(t,"shape",{value:l}),u.raw=l,l};u.raw=n,Object.defineProperty(t,"shape",{get:u})}let o=hr(()=>Ef(t));J(e,"propValues",u=>{let l=u.def.shape,d={};for(let f in l){let p=l[f]._zod;if(p.values){Object.prototype.hasOwnProperty.call(d,f)||Le(d,f,new Set);for(let m of p.values)d[f].add(m);p.optin!==void 0&&d[f].add(void 0)}}return d});let s=Jt,i=t.catchall,a,c=Ce.memoizer;c?.attach(e),e._zod.parse=(u,l)=>{a??(a=o.value);let d=u.value;if(!s(d))return u.issues.push({expected:"object",code:"invalid_type",input:d,inst:e}),u;u.value=c?c.alloc(e,u,{},l):{};let f=[],p=a.shape,m=l?.abortEarly,h=u.issues.length;for(let g of a.allKeys){if(m&&u.issues.length!==h){if(rt(u,h))break;h=u.issues.length}if(g==="__proto__")continue;let y=p[g],v=y._zod.optin,k=y._zod.optout,T=y._zod.run({value:d[g],issues:[]},l);T instanceof Promise?f.push(T.then(x=>Ao(x,u,g,d,v,k))):Ao(T,u,g,d,v,k)}return i?Tf(f,d,u,l,o.value,e,m===!0):f.length?Promise.all(f).then(()=>u):u}}),Of=b("$ZodObjectJIT",(e,t)=>{rv.init(e,t);let r=e._zod.parse,n=hr(()=>Ef(t)),o=Ce.memoizer,s=p=>{let m=n.value,h=m.symbolKeys,g=new To(["payload","ctx"],{shape:p,inst:e,memo:o,syms:h}),y=x=>`shape[${x}]._zod.run({ value: input[${x}], issues: [] }, ctx)`,v=(x,$)=>`
|
|
15
|
+
let ${x}_ab = false;
|
|
16
|
+
for (let i = 0; i < ${x}.issues.length; i++) {
|
|
17
|
+
const iss = ${x}.issues[i];
|
|
18
|
+
iss.path = iss.path ? [${$}, ...iss.path] : [${$}];
|
|
19
19
|
payload.issues.push(iss);
|
|
20
|
-
if (iss.continue !== true) ${
|
|
20
|
+
if (iss.continue !== true) ${x}_ab = true;
|
|
21
21
|
}
|
|
22
|
-
if (${
|
|
22
|
+
if (${x}_ab && ctx && ctx.abortEarly) {
|
|
23
23
|
payload.value = newResult;
|
|
24
24
|
return payload;
|
|
25
|
-
}`;g.write("const input = payload.value;");let
|
|
26
|
-
const ${
|
|
27
|
-
if (!${
|
|
28
|
-
if (${
|
|
25
|
+
}`;g.write("const input = payload.value;");let k=Object.create(null),T=0;for(let x of m.allKeys)k[x]=`key_${T++}`;g.write(o?"const newResult = memo.alloc(inst, payload, {}, ctx);":"const newResult = {};");for(let x of m.allKeys){if(x==="__proto__")continue;let $=k[x],P=typeof x=="symbol"?`syms[${h.indexOf(x)}]`:Ni(x),F=`${P} in input`,C=p[x],D=C?._zod?.optin,de=D!==void 0,M=C?._zod?.optout==="optional";if(g.write(`const ${$} = ${y(P)};`),de&&M){let me=D==="optional"?`${$}_present`:`${$}.value !== undefined || ${$}_present`;g.write(`
|
|
26
|
+
const ${$}_present = ${F};
|
|
27
|
+
if (!${$}.issues.length || ${$}_present) {
|
|
28
|
+
if (${$}.issues.length) {${v($,P)}
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
-
if (${
|
|
32
|
-
newResult[${
|
|
31
|
+
if (${me}) {
|
|
32
|
+
newResult[${P}] = ${$}.value;
|
|
33
33
|
}
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
-
`)}else
|
|
37
|
-
if (${
|
|
36
|
+
`)}else de?(g.write(`
|
|
37
|
+
if (${$}.issues.length) {${v($,P)}
|
|
38
38
|
}
|
|
39
|
-
`),
|
|
40
|
-
if (${
|
|
41
|
-
newResult[${
|
|
39
|
+
`),D==="defaulted"?g.write(`newResult[${P}] = ${$}.value;`):g.write(`
|
|
40
|
+
if (${$}.value !== undefined || ${F}) {
|
|
41
|
+
newResult[${P}] = ${$}.value;
|
|
42
42
|
}
|
|
43
43
|
`)):g.write(`
|
|
44
|
-
const ${
|
|
45
|
-
if (${
|
|
44
|
+
const ${$}_present = ${F};
|
|
45
|
+
if (${$}.issues.length) {${v($,P)}
|
|
46
46
|
}
|
|
47
|
-
if (!${
|
|
47
|
+
if (!${$}_present && !${$}.issues.length) {
|
|
48
48
|
payload.issues.push({
|
|
49
49
|
code: "invalid_type",
|
|
50
50
|
expected: "nonoptional",
|
|
51
51
|
input: undefined,
|
|
52
|
-
path: [${
|
|
52
|
+
path: [${P}]
|
|
53
53
|
});
|
|
54
54
|
if (ctx && ctx.abortEarly) {
|
|
55
55
|
payload.value = newResult;
|
|
@@ -57,48 +57,49 @@ ${r.join(`
|
|
|
57
57
|
}
|
|
58
58
|
}
|
|
59
59
|
|
|
60
|
-
if (${
|
|
61
|
-
newResult[${
|
|
60
|
+
if (${$}_present) {
|
|
61
|
+
newResult[${P}] = ${$}.value;
|
|
62
62
|
}
|
|
63
63
|
|
|
64
|
-
`)}return g.write("payload.value = newResult;"),g.write("return payload;"),g.compile()},i,a=Mt,c=!Se.jitless,l=c&&Ti.value,d=t.catchall,f;e._zod.parse=(p,m)=>{f??(f=n.value);let h=p.value;return a(h)?c&&l&&m?.async===!1&&m.jitless!==!0?(i||(i=s(t.shape)),p=i(p,m),d?bf([],h,p,m,f,e,m?.abortEarly===!0):p):r(p,m):(p.issues.push({expected:"object",code:"invalid_type",input:h,inst:e}),p)}});function Td(e,t,r,n){for(let s of e)if(s.issues.length===0)return t.value=s.value,t;let o=e.filter(s=>!Ke(s));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(s=>s.issues.map(i=>Ge(i,n,Ae())))}),t)}var Wi=_("$ZodUnion",(e,t)=>{G.init(e,t),U(e,"optin",n=>n.def.options.some(o=>o._zod.optin==="defaulted")?"defaulted":n.def.options.some(o=>o._zod.optin!==void 0)?"optional":void 0),U(e,"optout",n=>n.def.options.some(o=>o._zod.optout==="optional")?"optional":void 0),U(e,"values",n=>{if(n.def.options.every(o=>o._zod.values))return new Set(n.def.options.flatMap(o=>Array.from(o._zod.values)))}),U(e,"pattern",n=>{if(n.def.options.every(o=>o._zod.pattern)){let o=n.def.options.map(s=>s._zod.pattern);return new RegExp(`^(${o.map(s=>Ur(s.source)).join("|")})$`)}});let r=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(n,o)=>{if(r)return r(n,o);let s=!1,i=[];for(let a of t.options){let c=a._zod.run({value:n.value,issues:[]},o);if(c instanceof Promise)i.push(c),s=!0;else{if(c.issues.length===0)return c;i.push(c)}}return s?Promise.all(i).then(a=>Td(a,n,e,o)):Td(i,n,e,o)}});function Ab(e){let t=new Map;for(let r of e.options){let n=r._zod.propValues?.[e.discriminator];if(!n||n.size===0)throw new Error(`Invalid discriminated union option at index "${e.options.indexOf(r)}"`);for(let o of n)if(t.has(o)){if(o!==void 0)throw new Error(`Duplicate discriminator value "${String(o)}"`);t.set(o,null)}else t.set(o,r)}return t}var $f=_("$ZodDiscriminatedUnion",(e,t)=>{t.inclusive=!1,Wi.init(e,t);let r=e._zod.parse;U(e,"propValues",o=>{let s={},i=0;for(let a of o.def.options){let c=a._zod.propValues;if(!c||Object.keys(c).length===0)throw new Error(`Invalid discriminated union option at index "${o.def.options.indexOf(a)}"`);c[o.def.discriminator]?.has(void 0)&&i++;for(let[u,l]of Object.entries(c)){Object.prototype.hasOwnProperty.call(s,u)||Re(s,u,new Set);for(let d of l)s[u].add(d)}}return!o.def.unionFallback&&i>1&&s[o.def.discriminator]?.delete(void 0),s}),t.options.forEach((o,s)=>{let i=dr(o._zod.def);if(i&&!Object.prototype.hasOwnProperty.call(i,t.discriminator))throw new Error(`Invalid discriminated union option at index "${s}"`)});let n=lr(()=>Ab(t));e._zod.parse=(o,s)=>{let i=o.value;if(!Mt(i))return o.issues.push({code:"invalid_type",expected:"object",input:i,inst:e}),o;let a=i?.[t.discriminator],c=n.value.get(a);return c&&(a!==void 0||s.direction!=="backward")?c._zod.run(o,s):t.unionFallback||s.direction==="backward"?r(o,s):(o.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:t.discriminator,options:Array.from(n.value.keys()).filter(u=>n.value.get(u)!==null),input:i,path:[t.discriminator],inst:e}),o)}}),xf=_("$ZodIntersection",(e,t)=>{G.init(e,t),e._zod.parse=(r,n)=>{let o=r.value,s=t.left._zod.run({value:o,issues:[]},n),i=t.right._zod.run({value:o,issues:[]},n);return s instanceof Promise||i instanceof Promise?Promise.all([s,i]).then(([c,u])=>Od(r,c,u)):Od(r,s,i)}});function Bi(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(bt(e)&&bt(t)){let r=Object.keys(t),n=Object.keys(e).filter(s=>r.indexOf(s)!==-1),o={...e,...t};Object.prototype.hasOwnProperty.call(o,"__proto__")&&delete o.__proto__;for(let s of n){if(s==="__proto__")continue;let i=Bi(e[s],t[s]);if(!i.valid)return{valid:!1,mergeErrorPath:[s,...i.mergeErrorPath]};o[s]=i.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],s=t[n],i=Bi(o,s);if(!i.valid)return{valid:!1,mergeErrorPath:[n,...i.mergeErrorPath]};r.push(i.data)}return{valid:!0,data:r}}return{valid:!1,mergeErrorPath:[]}}function Od(e,t,r){let n=new Map,o,s=new Map,i=(u,l)=>{let d;if(u.code==="unrecognized_keys"&&!u.path?.length)o??(o=u),d=u.keys;else if(u.code==="invalid_key"&&u.origin==="record"&&u.path?.length===1){let f=String(u.path[0]);s.has(f)||s.set(f,u),d=[f]}else return!1;for(let f of d)n.has(f)||n.set(f,{}),n.get(f)[l]=!0;return!0};for(let u of t.issues)i(u,"l")||e.issues.push(u);for(let u of r.issues)i(u,"r")||e.issues.push(u);let a=[...n].filter(([,u])=>u.l&&u.r).map(([u])=>u);if(a.length){let u=o?a.filter(l=>o.keys.includes(l)):[];u.length&&e.issues.push({...o,keys:u});for(let l of a)!u.includes(l)&&s.has(l)&&e.issues.push(s.get(l))}let c=Bi(t.value,r.value);if(!c.valid){if(Ke(e))return e;throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(c.mergeErrorPath)}`)}return e.value=c.data,e}var Sf=_("$ZodRecord",(e,t)=>{G.init(e,t);let r=Se.memoizer;r?.attach(e),e._zod.parse=(n,o)=>{let s=n.value;if(!bt(s))return n.issues.push({expected:"record",code:"invalid_type",input:s,inst:e}),n;let i=[],a=t.keyType._zod.values;if(a&&!t.partial){n.value=r?r.alloc(e,n,{},o):{};let c=new Set;for(let l of a)if(typeof l=="string"||typeof l=="number"||typeof l=="symbol"){if(c.add(typeof l=="number"?l.toString():l),l==="__proto__")continue;let d=t.keyType._zod.run({value:l,issues:[]},o);if(d instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(d.issues.length){n.issues.push({code:"invalid_key",origin:"record",issues:d.issues.map(m=>Ge(m,o,Ae())),input:l,path:[l],inst:e});continue}let f=d.value;if(f==="__proto__")continue;let p=t.valueType._zod.run({value:s[l],issues:[]},o);p instanceof Promise?i.push(p.then(m=>{m.issues.length&&n.issues.push(...dt(l,m.issues)),n.value[f]=m.value})):(p.issues.length&&n.issues.push(...dt(l,p.issues)),n.value[f]=p.value)}let u;for(let l in s)if(!c.has(l))if(t.mode==="loose"){if(l==="__proto__")continue;n.value[l]=s[l]}else u=u??[],u.push(l);u&&u.length>0&&n.issues.push({code:"unrecognized_keys",input:s,inst:e,keys:u,continue:!0})}else{n.value=r?r.alloc(e,n,{},o):{};let c;for(let u of Reflect.ownKeys(s)){if(u==="__proto__"||!Object.prototype.propertyIsEnumerable.call(s,u))continue;let l=t.keyType._zod.run({value:u,issues:[]},o);if(l instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(typeof u=="string"&&Gr.test(u)&&l.issues.length){let m=t.keyType._zod.run({value:Number(u),issues:[]},o);if(m instanceof Promise)throw new Error("Async schemas not supported in object keys currently");m.issues.length===0&&(l=m)}if(l.issues.length){t.mode==="loose"?n.value[u]=s[u]:a?(c=c??[],c.push(u)):n.issues.push({code:"invalid_key",origin:"record",issues:l.issues.map(m=>Ge(m,o,Ae())),input:u,path:[u],inst:e});continue}let f=l.value;if(f==="__proto__")continue;let p=t.valueType._zod.run({value:s[u],issues:[]},o);p instanceof Promise?i.push(p.then(m=>{m.issues.length&&n.issues.push(...dt(u,m.issues)),n.value[f]=m.value})):(p.issues.length&&n.issues.push(...dt(u,p.issues)),n.value[f]=p.value)}c&&c.length>0&&n.issues.push({code:"unrecognized_keys",input:s,inst:e,keys:c,continue:!0})}return i.length?Promise.all(i).then(()=>n):n}});var kf=_("$ZodEnum",(e,t)=>{G.init(e,t);let r=cr(t.entries),n=new Set(r);e._zod.values=n,U(e,"pattern",o=>{let s=cr(o.def.entries).filter(i=>Oi.has(typeof i));return new RegExp(s.length?`^(${s.map(i=>lt(i.toString())).join("|")})$`:"^[^\\s\\S]$")}),e._zod.parse=(o,s)=>{let i=o.value;return n.has(i)||o.issues.push({code:"invalid_value",values:r,input:i,inst:e}),o}}),zf=_("$ZodLiteral",(e,t)=>{G.init(e,t);let r=new Set(t.values);e._zod.values=r,U(e,"pattern",n=>{let o=n.def.values;return new RegExp(o.length?`^(${o.map(s=>typeof s=="string"?lt(s):s?lt(s.toString()):String(s)).join("|")})$`:"^[^\\s\\S]$")}),e._zod.parse=(n,o)=>{let s=n.value;return r.has(s)||n.issues.push({code:"invalid_value",values:t.values,input:s,inst:e}),n}});var Pf=_("$ZodTransform",(e,t)=>{G.init(e,t),e._zod.optin="optional",Se.memoizer?.guard(e),e._zod.parse=(r,n)=>{if(n.direction==="backward")throw new pr(e.constructor.name);let o=t.transform(r.value,r);if(n.async)return(o instanceof Promise?o:Promise.resolve(o)).then(i=>(r.value=i,r));if(o instanceof Promise)throw new We;return r.value=o,r}});function Rd(e,t){return e.value=t.issues.length?void 0:t.value,e}var Yi=_("$ZodOptional",(e,t)=>{G.init(e,t),U(e,"optin",r=>r.def.innerType._zod.optin==="defaulted"?"defaulted":"optional"),e._zod.optout="optional",U(e,"values",r=>{let n=r.def.innerType._zod.values;return n?new Set([...n,void 0]):void 0}),U(e,"pattern",r=>{let n=r.def.innerType._zod.pattern;return n?new RegExp(`^(${Ur(n.source)})?$`):void 0}),e._zod.parse=(r,n)=>{if(r.value===void 0){if(t.innerType._zod.optin!=="defaulted")return r;let o=t.innerType._zod.run({value:r.value,issues:[]},n);return o instanceof Promise?o.then(s=>Rd(r,s)):Rd(r,o)}return t.innerType._zod.run(r,n)}}),Ef=_("$ZodExactOptional",(e,t)=>{Yi.init(e,t),U(e,"values",r=>r.def.innerType._zod.values),U(e,"pattern",r=>r.def.innerType._zod.pattern),e._zod.parse=(r,n)=>t.innerType._zod.run(r,n)}),If=_("$ZodNullable",(e,t)=>{G.init(e,t),U(e,"optin",r=>r.def.innerType._zod.optin),U(e,"optout",r=>r.def.innerType._zod.optout),U(e,"pattern",r=>{let n=r.def.innerType._zod.pattern;return n?new RegExp(`^(${Ur(n.source)}|null)$`):void 0}),U(e,"values",r=>r.def.innerType._zod.values?new Set([...r.def.innerType._zod.values,null]):void 0),e._zod.parse=(r,n)=>r.value===null?r:t.innerType._zod.run(r,n)}),Tf=_("$ZodDefault",(e,t)=>{G.init(e,t),e._zod.optin="defaulted",U(e,"values",r=>r.def.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(s=>Ad(s,t)):Ad(o,t)}});function Ad(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}var Of=_("$ZodPrefault",(e,t)=>{G.init(e,t),e._zod.optin="defaulted",U(e,"values",r=>r.def.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))}),Rf=_("$ZodNonOptional",(e,t)=>{G.init(e,t),U(e,"values",r=>{let n=r.def.innerType._zod.values;return n?new Set([...n].filter(o=>o!==void 0)):void 0}),e._zod.parse=(r,n)=>{let o=t.innerType._zod.run(r,n);return o instanceof Promise?o.then(s=>Cd(s,e)):Cd(o,e)}});function Cd(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:"invalid_type",expected:"nonoptional",input:e.value,inst:t}),e}function Nd(e,t,r,n){return t.issues.length?(e.value=r.catchValue({...t,value:e.value,error:{issues:t.issues.map(o=>Ge(o,n,Ae()))},input:e.value}),e):(e.value=t.value,t.memo&&(e.memo=!0),e)}var Af=_("$ZodCatch",(e,t)=>{G.init(e,t),U(e,"optin",r=>r.def.innerType._zod.optin==="defaulted"?"defaulted":"optional"),U(e,"optout",r=>r.def.innerType._zod.optout),U(e,"values",r=>r.def.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({value:r.value,issues:[]},n);return o instanceof Promise?o.then(s=>Nd(r,s,t,n)):Nd(r,o,t,n)}});var Xi=_("$ZodPipe",(e,t)=>{G.init(e,t),U(e,"values",r=>r.def.in._zod.values),U(e,"optin",r=>r.def.in._zod.optin),U(e,"optout",r=>r.def.out._zod.optout),U(e,"propValues",r=>r.def.in._zod.propValues),e._zod.parse=(r,n)=>{if(n.direction==="backward"){let s=t.out._zod.run(r,n);return s instanceof Promise?s.then(i=>zo(i,t.in,n)):zo(s,t.in,n)}let o=t.in._zod.run(r,n);return o instanceof Promise?o.then(s=>zo(s,t.out,n)):zo(o,t.out,n)}});function zo(e,t,r){return e.issues.some(n=>n.code!=="unrecognized_keys")?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},r)}var Cf=_("$ZodPreprocess",(e,t)=>{Xi.init(e,t)}),Nf=_("$ZodReadonly",(e,t)=>{G.init(e,t),U(e,"propValues",r=>r.def.innerType._zod.propValues),U(e,"values",r=>r.def.innerType._zod.values),U(e,"optin",r=>r.def.innerType?._zod?.optin),U(e,"optout",r=>r.def.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(jd):jd(o)}});function jd(e){return e.memo||(e.value=Object.freeze(e.value)),e}var jf=_("$ZodCustom",(e,t)=>{le.init(e,t),G.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(s=>Dd(s,r,n,e));Dd(o,r,n,e)}});function Dd(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(fr(o))}}var ea=class extends Error{constructor(){super("Cannot parse a reference cycle that closes through a transform"),this.name="ZodCyclicError"}},ta="~memo",Df=[];function Zf(e){return e!==null&&typeof e=="object"}function Qi(e){return e.map(t=>t.path?{...t,path:t.path.slice()}:{...t})}var Mf=new WeakMap,Xr=0,Ao=1,Qr=2;function Co(e,t,r){let n=Mf.get(e);if(n!==void 0)return n?Qr:Xr;if(t.has(e))return Qr;t.add(e);let o=Xr,s=l=>{if(o!==Qr&&l?._zod){let d=Co(l,t,r);d>o&&(o=d)}},i=(l,d)=>{let f=Xr;for(let p of Reflect.ownKeys(l)){let m=Object.getOwnPropertyDescriptor(l,p);if(d&&!m.enumerable)continue;let h=m.get?Ao:m.value?._zod?Co(m.value,t,r):Xr;h>f&&(f=h)}return f},a=l=>{l>o&&(o=l)},c=e._zod.def,u=c.type;switch(u){case"object":{let l=dr(c);a(l?i(l,!0):Ao),s(c.catchall);break}case"array":s(c.element);break;case"tuple":for(let l of c.items)s(l);s(c.rest);break;case"record":case"map":s(c.keyType),s(c.valueType);break;case"set":s(c.valueType);break;case"union":for(let l of c.options)s(l);break;case"intersection":s(c.left),s(c.right);break;case"optional":case"nullable":case"default":case"prefault":case"catch":case"readonly":case"nonoptional":case"promise":case"success":s(c.innerType);break;case"pipe":s(c.in),s(c.out);break;case"function":s(c.input),s(c.output);break;case"lazy":{let l=c._cachedInner??(r?e._zod.innerType:void 0);a(l?Co(l,t,!1):Ao);break}case"template_literal":case"string":case"number":case"int":case"boolean":case"bigint":case"symbol":case"undefined":case"null":case"void":case"never":case"any":case"unknown":case"date":case"nan":case"enum":case"literal":case"file":case"transform":case"custom":break;default:for(let l in c){let d=Object.getOwnPropertyDescriptor(c,l);if(!d||d.get)continue;let f=d.value;if(!(!f||typeof f!="object")){if(f._zod)s(f);else if(Array.isArray(f))for(let p of f)s(p)}}}return t.delete(e),Cb(e,o)}function Cb(e,t){return t!==Ao&&Mf.set(e,t===Qr),t}function Nb(e,t){let r=e.buckets.get(t);return r||(r=new WeakMap,e.buckets.set(t,r)),r}var Oo,Ro=[],jb={alloc(e,t,r){let n=Oo;if(!n)return r;Oo=void 0;let o={value:r,issues:null};return n.set(t.value,o),Ro.push(o),r},guard(e){var t;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{let r=e._zod.parse,n=(o,s)=>{if(s.direction!=="backward"&&Db(s,o.value))throw new ea;return r(o,s)};e._zod.parse=n,e._zod.run===r&&(e._zod.run=n)})},attach(e){var t;let r,n=!1,o,s;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{let i=e._zod.parse,a=(c,u)=>{if(r===void 0){let w=Co(e,new Set,!1);if(w===Xr)return e._zod.parse=i,e._zod.run===a&&(e._zod.run=i),i(c,u);w===Qr||n?r=!0:n=!0}let l=c.value;if(!Zf(l))return i(c,u);let d=u[ta];d||(d={buckets:new WeakMap,backEdges:void 0},u[ta]=d);let f;o===u?f=s:(f=Nb(d,e),o=u,s=f);let p=f.get(l);if(p)return c.value=p.value,p.issues?p.issues.length&&c.issues.push(...Qi(p.issues)):(c.memo=!0,d.backEdges??(d.backEdges=new WeakSet),d.backEdges.add(p.value)),c;Oo=f;let m=Ro.length,h=i(c,u);Oo=void 0;let g=Ro.length>m?Ro.pop():void 0;return h instanceof Promise?h.then(w=>(g&&(g.issues=w.issues.length?Qi(w.issues):Df),w)):(g&&(g.issues=h.issues.length?Qi(h.issues):Df),h)};e._zod.parse=a,e._zod.run===i&&(e._zod.run=a)})}};function qf(){return jb}function Db(e,t){let r=e[ta]?.backEdges;return r!==void 0&&Zf(t)&&r.has(t)}var Zb=()=>{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(s){return e[s]??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",currency_code:"currency code",credit_card:"credit card number",iban:"IBAN",jwt:"JWT",template_literal:"input"},n={nan:"NaN"};function o(s,i){return s==="number"&&typeof i=="number"&&!Number.isFinite(i)?String(i):n[s]??s}return s=>{switch(s.code){case"invalid_type":{let i=o(s.expected),a=Ci(s.input),c=o(a,s.input);return`Invalid input: expected ${i}, received ${c}`}case"invalid_value":return s.values.length===1?`Invalid input: expected ${po(s.values[0])}`:`Invalid option: expected one of ${lo(s.values,"|")}`;case"too_big":{let i=s.exact?"exactly ":s.inclusive?"<=":"<",a=t(s.origin);return a?`Too big: expected ${s.origin??"value"} to have ${i}${s.maximum.toString()} ${a.unit??"elements"}`:`Too big: expected ${s.origin??"value"} to be ${i}${s.maximum.toString()}`}case"too_small":{let i=s.exact?"exactly ":s.inclusive?">=":">",a=t(s.origin);return a?`Too small: expected ${s.origin} to have ${i}${s.minimum.toString()} ${a.unit}`:`Too small: expected ${s.origin} to be ${i}${s.minimum.toString()}`}case"invalid_format":{let i=s;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]??s.format}`}case"not_multiple_of":return`Invalid number: must be a multiple of ${s.divisor}`;case"unrecognized_keys":return`Unrecognized key${s.keys.length>1?"s":""}: ${lo(s.keys,", ")}`;case"invalid_key":return`Invalid key in ${s.origin}`;case"invalid_union":return s.options&&Array.isArray(s.options)&&s.options.length>0?`Invalid discriminator value. Expected ${s.options.map(a=>`'${a}'`).join(" | ")}`:s.inclusive===!1?"Invalid input: more than one option matched":"Invalid input";case"invalid_element":return`Invalid value in ${s.origin}`;default:return"Invalid input"}}};function Ff(){return{localeError:Zb()}}var Lf;var ra=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 Mb(){return new ra}(Lf=globalThis).__zod_globalRegistry??(Lf.__zod_globalRegistry=Mb());var qt=globalThis.__zod_globalRegistry;function Uf(e){return e.checks&&(e.checks=[...e.checks]),e}function Vf(e,t){return new e(Uf({type:"string",...E(t)}))}function Hf(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...E(t)})}function Bf(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...E(t)})}function Jf(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...E(t)})}function Kf(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...E(t)})}function Gf(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...E(t)})}function Wf(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...E(t)})}function Yf(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...E(t)})}function Xf(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...E(t)})}function Qf(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...E(t)})}function ep(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...E(t)})}function tp(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...E(t)})}function rp(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...E(t)})}function np(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...E(t)})}function op(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...E(t)})}function sp(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...E(t)})}function ip(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...E(t)})}function ap(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...E(t)})}function cp(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...E(t)})}function up(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...E(t)})}function lp(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...E(t)})}function dp(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...E(t)})}function fp(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...E(t)})}function No(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...E(t)})}function jo(e,t){return new e({type:"string",format:"date",check:"string_format",...E(t)})}function Do(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...E(t)})}function Zo(e,t){return new e({type:"string",format:"duration",check:"string_format",...E(t)})}function pp(e,t){return new e(Uf({type:"number",checks:[],...E(t)}))}function mp(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...E(t)})}function hp(e,t){return new e({type:"boolean",...E(t)})}function gp(e,t){return new e({type:"null",...E(t)})}function yp(e){return new e({type:"unknown"})}function _p(e,t){return new e({type:"never",...E(t)})}function Mo(e,t){return new Vi({check:"less_than",...E(t),value:e,inclusive:!1})}function en(e,t){return new Vi({check:"less_than",...E(t),value:e,inclusive:!0})}function qo(e,t){return new Hi({check:"greater_than",...E(t),value:e,inclusive:!1})}function tn(e,t){return new Hi({check:"greater_than",...E(t),value:e,inclusive:!0})}function Fo(e,t){return new md({check:"multiple_of",...E(t),value:e})}function Lo(e,t){return new gd({check:"max_length",...E(t),maximum:e})}function mr(e,t){return new yd({check:"min_length",...E(t),minimum:e})}function Uo(e,t){return new _d({check:"length_equals",...E(t),length:e})}function na(e,t){return new wd({check:"string_format",format:"regex",...E(t),pattern:e})}function oa(e){return new bd({check:"string_format",format:"lowercase",...E(e)})}function sa(e){return new vd({check:"string_format",format:"uppercase",...E(e)})}function ia(e,t){return new $d({check:"string_format",format:"includes",...E(t),includes:e})}function aa(e,t){return new xd({check:"string_format",format:"starts_with",...E(t),prefix:e})}function ca(e,t){return new Sd({check:"string_format",format:"ends_with",...E(t),suffix:e})}function vt(e){return new kd({check:"overwrite",tx:e})}function ua(e){return vt(t=>t.normalize(e))}function la(){return vt(e=>e.trim())}function da(){return vt(e=>e.toLowerCase())}function fa(){return vt(e=>e.toUpperCase())}function pa(){return vt(e=>Ii(e))}function wp(e,t,r){return new e({type:"array",element:t,...E(r)})}function bp(e,t,r){let n=E(r);return n.abort??(n.abort=!0),new e({type:"custom",check:"custom",fn:t,...n})}function vp(e,t,r){return new e({type:"custom",check:"custom",fn:t,...E(r)})}function $p(e,t){let r=qb(n=>(n.addIssue=o=>{if(typeof o=="string")n.issues.push(fr(o,n.value,r._zod.def));else{let s=o;s.fatal&&(s.continue=!1),s.code??(s.code="custom"),"input"in s||(s.input=n.value),s.inst??(s.inst=r),s.continue??(s.continue=!r._zod.def.abort),n.issues.push(fr(s))}},e(n.value,n)),t);return r}function qb(e,t){let r=new le({check:"custom",...E(t)});return r._zod.check=e,r}function rn(e,...t){for(let r of t)for(let n of Reflect.ownKeys(r))Object.prototype.propertyIsEnumerable.call(r,n)&&Re(e,n,r[n]);return e}function ha(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??qt,target:t,unrepresentable:e?.unrepresentable??"throw",override:e?.override??(()=>{}),io:e?.io??"output",counter:0,seen:new Map,sharedDefsExtractedFor:void 0,sharedEmitDoneFor:void 0,cycles:e?.cycles??"ref",reused:e?.reused??"inline",intersections:[],deferred:[],external:e?.external??void 0}}function ft(e,t,r,n,o){let s=typeof t.unrepresentable=="function"?t.unrepresentable({zodSchema:e,path:n.path,message:o}):t.unrepresentable;if(s==="any")return!1;if(s===void 0||s==="throw")throw new Error(o);return Object.assign(r,s),!0}function ie(e,t,r={path:[],schemaPath:[]}){var n;let o=e._zod.def,s=t.seen.get(e);if(s)return s.count++,r.schemaPath.includes(e)&&(s.cycle=r.path),s.schema;let i={schema:{},count:1,cycle:void 0,path:r.path};t.seen.set(e,i),t.sharedDefsExtractedFor=void 0,t.sharedEmitDoneFor=void 0;let a=e._zod.toJSONSchema?.();if(a)i.schema=a;else{let l={...r,schemaPath:[...r.schemaPath,e],path:r.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,i.schema,l);else{let f=i.schema,p=t.processors[o.type];if(!p)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${o.type}`);p(e,t,f,l)}let d=e._zod.parent;d&&(i.ref||(i.ref=d),ie(d,t,l),t.seen.get(d).isParent=!0)}let c=t.metadataRegistry.get(e);return c&&rn(i.schema,c),t.io==="input"&&be(e)&&(delete i.schema.examples,delete i.schema.default),t.io==="input"&&"_prefault"in i.schema&&((n=i.schema).default??(n.default=i.schema._prefault)),delete i.schema._prefault,t.seen.get(e).schema}function xp(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}function ga(e,t){let r=e.seen.get(t);if(!r)throw new Error("Unprocessed schema. This is a bug in Zod.");if(e.external&&e.sharedDefsExtractedFor===e.external)return;let n=new Map;for(let i of e.seen.entries()){let a=e.metadataRegistry.get(i[0])?.id;if(a){let c=n.get(a);if(c&&c!==i[0])throw new Error(`Duplicate schema id "${a}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);n.set(a,i[0])}}let o=i=>{let a=e.target==="draft-2020-12"?"$defs":"definitions";if(e.external){let d=e.external.registry.get(i[0])?.id,f=e.external.uri??(m=>m);if(d)return{ref:f(d)};let p=i[1].defId??i[1].schema.id??`schema${e.counter++}`;return i[1].defId=p,{defId:p,ref:`${f("__shared")}#/${a}/${xp(p)}`}}let c="#",u=`${c}/${a}/`;if(i[1]===r&&!i[1].schema.id)return{ref:c};let l=i[1].schema.id??`__schema${e.counter++}`;return{defId:l,ref:u+xp(l)}},s=i=>{if(i[1].schema.$ref)return;let a=i[1],{ref:c,defId:u}=o(i);a.def={...a.schema},u&&(a.defId=u);let l=a.schema;for(let d in l)delete l[d];l.$ref=c};if(e.cycles==="throw")for(let i of e.seen.entries()){let a=i[1];if(a.cycle)throw new Error(`Cycle detected: #/${a.cycle?.join("/")}/<root>
|
|
64
|
+
`)}return g.write("payload.value = newResult;"),g.write("return payload;"),g.compile()},i,a=Jt,c=!Ce.jitless,l=c&&Di.value,d=t.catchall,f;e._zod.parse=(p,m)=>{f??(f=n.value);let h=p.value;return a(h)?c&&l&&m?.async===!1&&m.jitless!==!0?(i||(i=s(t.shape)),p=i(p,m),d?Tf([],h,p,m,f,e,m?.abortEarly===!0):p):r(p,m):(p.issues.push({expected:"object",code:"invalid_type",input:h,inst:e}),p)}});function qd(e,t,r,n){for(let s of e)if(s.issues.length===0)return t.value=s.value,t;let o=e.filter(s=>!rt(s));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(s=>s.issues.map(i=>nt(i,n,Ue())))}),t)}var na=b("$ZodUnion",(e,t)=>{ee.init(e,t),J(e,"optin",n=>n.def.options.some(o=>o._zod.optin==="defaulted")?"defaulted":n.def.options.some(o=>o._zod.optin!==void 0)?"optional":void 0),J(e,"optout",n=>n.def.options.some(o=>o._zod.optout==="optional")?"optional":void 0),J(e,"values",n=>{if(n.def.options.every(o=>o._zod.values))return new Set(n.def.options.flatMap(o=>Array.from(o._zod.values)))}),J(e,"pattern",n=>{if(n.def.options.every(o=>o._zod.pattern)){let o=n.def.options.map(s=>s._zod.pattern);return new RegExp(`^(${o.map(s=>Jr(s.source)).join("|")})$`)}});let r=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(n,o)=>{if(r)return r(n,o);let s=!1,i=[];for(let a of t.options){let c=a._zod.run({value:n.value,issues:[]},o);if(c instanceof Promise)i.push(c),s=!0;else{if(c.issues.length===0)return c;i.push(c)}}return s?Promise.all(i).then(a=>qd(a,n,e,o)):qd(i,n,e,o)}});function nv(e){let t=new Map;for(let r of e.options){let n=r._zod.propValues?.[e.discriminator];if(!n||n.size===0)throw new Error(`Invalid discriminated union option at index "${e.options.indexOf(r)}"`);for(let o of n)if(t.has(o)){if(o!==void 0)throw new Error(`Duplicate discriminator value "${String(o)}"`);t.set(o,null)}else t.set(o,r)}return t}var Rf=b("$ZodDiscriminatedUnion",(e,t)=>{t.inclusive=!1,na.init(e,t);let r=e._zod.parse;J(e,"propValues",o=>{let s={},i=0;for(let a of o.def.options){let c=a._zod.propValues;if(!c||Object.keys(c).length===0)throw new Error(`Invalid discriminated union option at index "${o.def.options.indexOf(a)}"`);c[o.def.discriminator]?.has(void 0)&&i++;for(let[u,l]of Object.entries(c)){Object.prototype.hasOwnProperty.call(s,u)||Le(s,u,new Set);for(let d of l)s[u].add(d)}}return!o.def.unionFallback&&i>1&&s[o.def.discriminator]?.delete(void 0),s}),t.options.forEach((o,s)=>{let i=gr(o._zod.def);if(i&&!Object.prototype.hasOwnProperty.call(i,t.discriminator))throw new Error(`Invalid discriminated union option at index "${s}"`)});let n=hr(()=>nv(t));e._zod.parse=(o,s)=>{let i=o.value;if(!Jt(i))return o.issues.push({code:"invalid_type",expected:"object",input:i,inst:e}),o;let a=i?.[t.discriminator],c=n.value.get(a);return c&&(a!==void 0||s.direction!=="backward")?c._zod.run(o,s):t.unionFallback||s.direction==="backward"?r(o,s):(o.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:t.discriminator,options:Array.from(n.value.keys()).filter(u=>n.value.get(u)!==null),input:i,path:[t.discriminator],inst:e}),o)}}),Af=b("$ZodIntersection",(e,t)=>{ee.init(e,t),e._zod.parse=(r,n)=>{let o=r.value,s=t.left._zod.run({value:o,issues:[]},n),i=t.right._zod.run({value:o,issues:[]},n);return s instanceof Promise||i instanceof Promise?Promise.all([s,i]).then(([c,u])=>Fd(r,c,u)):Fd(r,s,i)}});function Qi(e,t){if(e===t)return{valid:!0,data:e};if(e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(Tt(e)&&Tt(t)){let r=Object.keys(t),n=Object.keys(e).filter(s=>r.indexOf(s)!==-1),o={...e,...t};Object.prototype.hasOwnProperty.call(o,"__proto__")&&delete o.__proto__;for(let s of n){if(s==="__proto__")continue;let i=Qi(e[s],t[s]);if(!i.valid)return{valid:!1,mergeErrorPath:[s,...i.mergeErrorPath]};o[s]=i.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],s=t[n],i=Qi(o,s);if(!i.valid)return{valid:!1,mergeErrorPath:[n,...i.mergeErrorPath]};r.push(i.data)}return{valid:!0,data:r}}return{valid:!1,mergeErrorPath:[]}}function Fd(e,t,r){let n=new Map,o,s=new Map,i=(u,l)=>{let d;if(u.code==="unrecognized_keys"&&!u.path?.length)o??(o=u),d=u.keys;else if(u.code==="invalid_key"&&u.origin==="record"&&u.path?.length===1){let f=String(u.path[0]);s.has(f)||s.set(f,u),d=[f]}else return!1;for(let f of d)n.has(f)||n.set(f,{}),n.get(f)[l]=!0;return!0};for(let u of t.issues)i(u,"l")||e.issues.push(u);for(let u of r.issues)i(u,"r")||e.issues.push(u);let a=[...n].filter(([,u])=>u.l&&u.r).map(([u])=>u);if(a.length){let u=o?a.filter(l=>o.keys.includes(l)):[];u.length&&e.issues.push({...o,keys:u});for(let l of a)!u.includes(l)&&s.has(l)&&e.issues.push(s.get(l))}let c=Qi(t.value,r.value);if(!c.valid){if(rt(e))return e;throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(c.mergeErrorPath)}`)}return e.value=c.data,e}var Cf=b("$ZodRecord",(e,t)=>{ee.init(e,t);let r=Ce.memoizer;r?.attach(e),e._zod.parse=(n,o)=>{let s=n.value;if(!Tt(s))return n.issues.push({expected:"record",code:"invalid_type",input:s,inst:e}),n;let i=[],a=t.keyType._zod.values;if(a&&!t.partial){n.value=r?r.alloc(e,n,{},o):{};let c=new Set;for(let l of a)if(typeof l=="string"||typeof l=="number"||typeof l=="symbol"){if(c.add(typeof l=="number"?l.toString():l),l==="__proto__")continue;let d=t.keyType._zod.run({value:l,issues:[]},o);if(d instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(d.issues.length){n.issues.push({code:"invalid_key",origin:"record",issues:d.issues.map(m=>nt(m,o,Ue())),input:l,path:[l],inst:e});continue}let f=d.value;if(f==="__proto__")continue;let p=t.valueType._zod.run({value:s[l],issues:[]},o);p instanceof Promise?i.push(p.then(m=>{m.issues.length&&n.issues.push(..._t(l,m.issues)),n.value[f]=m.value})):(p.issues.length&&n.issues.push(..._t(l,p.issues)),n.value[f]=p.value)}let u;for(let l in s)if(!c.has(l))if(t.mode==="loose"){if(l==="__proto__")continue;n.value[l]=s[l]}else u=u??[],u.push(l);u&&u.length>0&&n.issues.push({code:"unrecognized_keys",input:s,inst:e,keys:u,continue:!0})}else{n.value=r?r.alloc(e,n,{},o):{};let c;for(let u of Reflect.ownKeys(s)){if(u==="__proto__"||!Object.prototype.propertyIsEnumerable.call(s,u))continue;let l=t.keyType._zod.run({value:u,issues:[]},o);if(l instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(typeof u=="string"&&en.test(u)&&l.issues.length){let m=t.keyType._zod.run({value:Number(u),issues:[]},o);if(m instanceof Promise)throw new Error("Async schemas not supported in object keys currently");m.issues.length===0&&(l=m)}if(l.issues.length){t.mode==="loose"?n.value[u]=s[u]:a?(c=c??[],c.push(u)):n.issues.push({code:"invalid_key",origin:"record",issues:l.issues.map(m=>nt(m,o,Ue())),input:u,path:[u],inst:e});continue}let f=l.value;if(f==="__proto__")continue;let p=t.valueType._zod.run({value:s[u],issues:[]},o);p instanceof Promise?i.push(p.then(m=>{m.issues.length&&n.issues.push(..._t(u,m.issues)),n.value[f]=m.value})):(p.issues.length&&n.issues.push(..._t(u,p.issues)),n.value[f]=p.value)}c&&c.length>0&&n.issues.push({code:"unrecognized_keys",input:s,inst:e,keys:c,continue:!0})}return i.length?Promise.all(i).then(()=>n):n}});var Nf=b("$ZodEnum",(e,t)=>{ee.init(e,t);let r=pr(t.entries),n=new Set(r);e._zod.values=n,J(e,"pattern",o=>{let s=pr(o.def.entries).filter(i=>Zi.has(typeof i));return new RegExp(s.length?`^(${s.map(i=>yt(i.toString())).join("|")})$`:"^[^\\s\\S]$")}),e._zod.parse=(o,s)=>{let i=o.value;return n.has(i)||o.issues.push({code:"invalid_value",values:r,input:i,inst:e}),o}}),jf=b("$ZodLiteral",(e,t)=>{ee.init(e,t);let r=new Set(t.values);e._zod.values=r,J(e,"pattern",n=>{let o=n.def.values;return new RegExp(o.length?`^(${o.map(s=>typeof s=="string"?yt(s):s?yt(s.toString()):String(s)).join("|")})$`:"^[^\\s\\S]$")}),e._zod.parse=(n,o)=>{let s=n.value;return r.has(s)||n.issues.push({code:"invalid_value",values:t.values,input:s,inst:e}),n}});var Df=b("$ZodTransform",(e,t)=>{ee.init(e,t),e._zod.optin="optional",Ce.memoizer?.guard(e),e._zod.parse=(r,n)=>{if(n.direction==="backward")throw new _r(e.constructor.name);let o=t.transform(r.value,r);if(n.async)return(o instanceof Promise?o:Promise.resolve(o)).then(i=>(r.value=i,r));if(o instanceof Promise)throw new ot;return r.value=o,r}});function Ld(e,t){return e.value=t.issues.length?void 0:t.value,e}var oa=b("$ZodOptional",(e,t)=>{ee.init(e,t),J(e,"optin",r=>r.def.innerType._zod.optin==="defaulted"?"defaulted":"optional"),e._zod.optout="optional",J(e,"values",r=>{let n=r.def.innerType._zod.values;return n?new Set([...n,void 0]):void 0}),J(e,"pattern",r=>{let n=r.def.innerType._zod.pattern;return n?new RegExp(`^(${Jr(n.source)})?$`):void 0}),e._zod.parse=(r,n)=>{if(r.value===void 0){if(t.innerType._zod.optin!=="defaulted")return r;let o=t.innerType._zod.run({value:r.value,issues:[]},n);return o instanceof Promise?o.then(s=>Ld(r,s)):Ld(r,o)}return t.innerType._zod.run(r,n)}}),Zf=b("$ZodExactOptional",(e,t)=>{oa.init(e,t),J(e,"values",r=>r.def.innerType._zod.values),J(e,"pattern",r=>r.def.innerType._zod.pattern),e._zod.parse=(r,n)=>t.innerType._zod.run(r,n)}),Mf=b("$ZodNullable",(e,t)=>{ee.init(e,t),J(e,"optin",r=>r.def.innerType._zod.optin),J(e,"optout",r=>r.def.innerType._zod.optout),J(e,"pattern",r=>{let n=r.def.innerType._zod.pattern;return n?new RegExp(`^(${Jr(n.source)}|null)$`):void 0}),J(e,"values",r=>r.def.innerType._zod.values?new Set([...r.def.innerType._zod.values,null]):void 0),e._zod.parse=(r,n)=>r.value===null?r:t.innerType._zod.run(r,n)}),qf=b("$ZodDefault",(e,t)=>{ee.init(e,t),e._zod.optin="defaulted",J(e,"values",r=>r.def.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(s=>Ud(s,t)):Ud(o,t)}});function Ud(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}var Ff=b("$ZodPrefault",(e,t)=>{ee.init(e,t),e._zod.optin="defaulted",J(e,"values",r=>r.def.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))}),Lf=b("$ZodNonOptional",(e,t)=>{ee.init(e,t),J(e,"values",r=>{let n=r.def.innerType._zod.values;return n?new Set([...n].filter(o=>o!==void 0)):void 0}),e._zod.parse=(r,n)=>{let o=t.innerType._zod.run(r,n);return o instanceof Promise?o.then(s=>Vd(s,e)):Vd(o,e)}});function Vd(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:"invalid_type",expected:"nonoptional",input:e.value,inst:t}),e}function Bd(e,t,r,n){return t.issues.length?(e.value=r.catchValue({...t,value:e.value,error:{issues:t.issues.map(o=>nt(o,n,Ue()))},input:e.value}),e):(e.value=t.value,t.memo&&(e.memo=!0),e)}var Uf=b("$ZodCatch",(e,t)=>{ee.init(e,t),J(e,"optin",r=>r.def.innerType._zod.optin==="defaulted"?"defaulted":"optional"),J(e,"optout",r=>r.def.innerType._zod.optout),J(e,"values",r=>r.def.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({value:r.value,issues:[]},n);return o instanceof Promise?o.then(s=>Bd(r,s,t,n)):Bd(r,o,t,n)}});var sa=b("$ZodPipe",(e,t)=>{ee.init(e,t),J(e,"values",r=>r.def.in._zod.values),J(e,"optin",r=>r.def.in._zod.optin),J(e,"optout",r=>r.def.out._zod.optout),J(e,"propValues",r=>r.def.in._zod.propValues),e._zod.parse=(r,n)=>{if(n.direction==="backward"){let s=t.out._zod.run(r,n);return s instanceof Promise?s.then(i=>Oo(i,t.in,n)):Oo(s,t.in,n)}let o=t.in._zod.run(r,n);return o instanceof Promise?o.then(s=>Oo(s,t.out,n)):Oo(o,t.out,n)}});function Oo(e,t,r){return e.issues.some(n=>n.code!=="unrecognized_keys")?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},r)}var Vf=b("$ZodPreprocess",(e,t)=>{sa.init(e,t)}),Bf=b("$ZodReadonly",(e,t)=>{ee.init(e,t),J(e,"propValues",r=>r.def.innerType._zod.propValues),J(e,"values",r=>r.def.innerType._zod.values),J(e,"optin",r=>r.def.innerType?._zod?.optin),J(e,"optout",r=>r.def.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(Hd):Hd(o)}});function Hd(e){return e.memo||(e.value=Object.freeze(e.value)),e}var Hf=b("$ZodCustom",(e,t)=>{ye.init(e,t),ee.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(s=>Kd(s,r,n,e));Kd(o,r,n,e)}});function Kd(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(yr(o))}}var aa=class extends Error{constructor(){super("Cannot parse a reference cycle that closes through a transform"),this.name="ZodCyclicError"}},ca="~memo",Kf=[];function Jf(e){return e!==null&&typeof e=="object"}function ia(e){return e.map(t=>t.path?{...t,path:t.path.slice()}:{...t})}var Gf=new WeakMap,nn=0,Zo=1,on=2;function Mo(e,t,r){let n=Gf.get(e);if(n!==void 0)return n?on:nn;if(t.has(e))return on;t.add(e);let o=nn,s=l=>{if(o!==on&&l?._zod){let d=Mo(l,t,r);d>o&&(o=d)}},i=(l,d)=>{let f=nn;for(let p of Reflect.ownKeys(l)){let m=Object.getOwnPropertyDescriptor(l,p);if(d&&!m.enumerable)continue;let h=m.get?Zo:m.value?._zod?Mo(m.value,t,r):nn;h>f&&(f=h)}return f},a=l=>{l>o&&(o=l)},c=e._zod.def,u=c.type;switch(u){case"object":{let l=gr(c);a(l?i(l,!0):Zo),s(c.catchall);break}case"array":s(c.element);break;case"tuple":for(let l of c.items)s(l);s(c.rest);break;case"record":case"map":s(c.keyType),s(c.valueType);break;case"set":s(c.valueType);break;case"union":for(let l of c.options)s(l);break;case"intersection":s(c.left),s(c.right);break;case"optional":case"nullable":case"default":case"prefault":case"catch":case"readonly":case"nonoptional":case"promise":case"success":s(c.innerType);break;case"pipe":s(c.in),s(c.out);break;case"function":s(c.input),s(c.output);break;case"lazy":{let l=c._cachedInner??(r?e._zod.innerType:void 0);a(l?Mo(l,t,!1):Zo);break}case"template_literal":case"string":case"number":case"int":case"boolean":case"bigint":case"symbol":case"undefined":case"null":case"void":case"never":case"any":case"unknown":case"date":case"nan":case"enum":case"literal":case"file":case"transform":case"custom":break;default:for(let l in c){let d=Object.getOwnPropertyDescriptor(c,l);if(!d||d.get)continue;let f=d.value;if(!(!f||typeof f!="object")){if(f._zod)s(f);else if(Array.isArray(f))for(let p of f)s(p)}}}return t.delete(e),ov(e,o)}function ov(e,t){return t!==Zo&&Gf.set(e,t===on),t}function sv(e,t){let r=e.buckets.get(t);return r||(r=new WeakMap,e.buckets.set(t,r)),r}var jo,Do=[],iv={alloc(e,t,r){let n=jo;if(!n)return r;jo=void 0;let o={value:r,issues:null};return n.set(t.value,o),Do.push(o),r},guard(e){var t;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{let r=e._zod.parse,n=(o,s)=>{if(s.direction!=="backward"&&av(s,o.value))throw new aa;return r(o,s)};e._zod.parse=n,e._zod.run===r&&(e._zod.run=n)})},attach(e){var t;let r,n=!1,o,s;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{let i=e._zod.parse,a=(c,u)=>{if(r===void 0){let y=Mo(e,new Set,!1);if(y===nn)return e._zod.parse=i,e._zod.run===a&&(e._zod.run=i),i(c,u);y===on||n?r=!0:n=!0}let l=c.value;if(!Jf(l))return i(c,u);let d=u[ca];d||(d={buckets:new WeakMap,backEdges:void 0},u[ca]=d);let f;o===u?f=s:(f=sv(d,e),o=u,s=f);let p=f.get(l);if(p)return c.value=p.value,p.issues?p.issues.length&&c.issues.push(...ia(p.issues)):(c.memo=!0,d.backEdges??(d.backEdges=new WeakSet),d.backEdges.add(p.value)),c;jo=f;let m=Do.length,h=i(c,u);jo=void 0;let g=Do.length>m?Do.pop():void 0;return h instanceof Promise?h.then(y=>(g&&(g.issues=y.issues.length?ia(y.issues):Kf),y)):(g&&(g.issues=h.issues.length?ia(h.issues):Kf),h)};e._zod.parse=a,e._zod.run===i&&(e._zod.run=a)})}};function Wf(){return iv}function av(e,t){let r=e[ca]?.backEdges;return r!==void 0&&Jf(t)&&r.has(t)}var cv=()=>{let e={string:{unit:"characters",verb:"to have"},file:{unit:"bytes",verb:"to have"},array:{unit:"items",verb:"to have"},set:{unit:"items",verb:"to have"},map:{unit:"entries",verb:"to have"}};function t(s){return e[s]??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",currency_code:"currency code",credit_card:"credit card number",iban:"IBAN",jwt:"JWT",template_literal:"input"},n={nan:"NaN"};function o(s,i){return s==="number"&&typeof i=="number"&&!Number.isFinite(i)?String(i):n[s]??s}return s=>{switch(s.code){case"invalid_type":{let i=o(s.expected),a=Fi(s.input),c=o(a,s.input);return`Invalid input: expected ${i}, received ${c}`}case"invalid_value":return s.values.length===1?`Invalid input: expected ${_o(s.values[0])}`:`Invalid option: expected one of ${go(s.values,"|")}`;case"too_big":{let i=s.exact?"exactly ":s.inclusive?"<=":"<",a=t(s.origin);return a?`Too big: expected ${s.origin??"value"} to have ${i}${s.maximum.toString()} ${a.unit??"elements"}`:`Too big: expected ${s.origin??"value"} to be ${i}${s.maximum.toString()}`}case"too_small":{let i=s.exact?"exactly ":s.inclusive?">=":">",a=t(s.origin);return a?`Too small: expected ${s.origin} to have ${i}${s.minimum.toString()} ${a.unit}`:`Too small: expected ${s.origin} to be ${i}${s.minimum.toString()}`}case"invalid_format":{let i=s;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]??s.format}`}case"not_multiple_of":return`Invalid number: must be a multiple of ${s.divisor}`;case"unrecognized_keys":return`Unrecognized key${s.keys.length>1?"s":""}: ${go(s.keys,", ")}`;case"invalid_key":return`Invalid key in ${s.origin}`;case"invalid_union":return s.options&&Array.isArray(s.options)&&s.options.length>0?`Invalid discriminator value. Expected ${s.options.map(a=>`'${a}'`).join(" | ")}`:s.inclusive===!1?"Invalid input: more than one option matched":"Invalid input";case"invalid_element":return`Invalid value in ${s.origin}`;default:return"Invalid input"}}};function Yf(){return{localeError:cv()}}var Xf;var ua=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 uv(){return new ua}(Xf=globalThis).__zod_globalRegistry??(Xf.__zod_globalRegistry=uv());var Gt=globalThis.__zod_globalRegistry;function Qf(e){return e.checks&&(e.checks=[...e.checks]),e}function ep(e,t){return new e(Qf({type:"string",...O(t)}))}function tp(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...O(t)})}function rp(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...O(t)})}function np(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...O(t)})}function op(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...O(t)})}function sp(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...O(t)})}function ip(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...O(t)})}function ap(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...O(t)})}function cp(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...O(t)})}function up(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...O(t)})}function lp(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...O(t)})}function dp(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...O(t)})}function fp(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...O(t)})}function pp(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...O(t)})}function mp(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...O(t)})}function hp(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...O(t)})}function gp(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...O(t)})}function yp(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...O(t)})}function _p(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...O(t)})}function wp(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...O(t)})}function bp(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...O(t)})}function vp(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...O(t)})}function $p(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...O(t)})}function qo(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...O(t)})}function Fo(e,t){return new e({type:"string",format:"date",check:"string_format",...O(t)})}function Lo(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...O(t)})}function Uo(e,t){return new e({type:"string",format:"duration",check:"string_format",...O(t)})}function kp(e,t){return new e(Qf({type:"number",checks:[],...O(t)}))}function xp(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...O(t)})}function Sp(e,t){return new e({type:"boolean",...O(t)})}function zp(e,t){return new e({type:"null",...O(t)})}function Pp(e){return new e({type:"unknown"})}function Ip(e,t){return new e({type:"never",...O(t)})}function Vo(e,t){return new Yi({check:"less_than",...O(t),value:e,inclusive:!1})}function sn(e,t){return new Yi({check:"less_than",...O(t),value:e,inclusive:!0})}function Bo(e,t){return new Xi({check:"greater_than",...O(t),value:e,inclusive:!1})}function an(e,t){return new Xi({check:"greater_than",...O(t),value:e,inclusive:!0})}function Ho(e,t){return new xd({check:"multiple_of",...O(t),value:e})}function Ko(e,t){return new zd({check:"max_length",...O(t),maximum:e})}function wr(e,t){return new Pd({check:"min_length",...O(t),minimum:e})}function Jo(e,t){return new Id({check:"length_equals",...O(t),length:e})}function la(e,t){return new Ed({check:"string_format",format:"regex",...O(t),pattern:e})}function da(e){return new Td({check:"string_format",format:"lowercase",...O(e)})}function fa(e){return new Od({check:"string_format",format:"uppercase",...O(e)})}function pa(e,t){return new Rd({check:"string_format",format:"includes",...O(t),includes:e})}function ma(e,t){return new Ad({check:"string_format",format:"starts_with",...O(t),prefix:e})}function ha(e,t){return new Cd({check:"string_format",format:"ends_with",...O(t),suffix:e})}function Ot(e){return new Nd({check:"overwrite",tx:e})}function ga(e){return Ot(t=>t.normalize(e))}function ya(){return Ot(e=>e.trim())}function _a(){return Ot(e=>e.toLowerCase())}function wa(){return Ot(e=>e.toUpperCase())}function ba(){return Ot(e=>ji(e))}function Ep(e,t,r){return new e({type:"array",element:t,...O(r)})}function Tp(e,t,r){let n=O(r);return n.abort??(n.abort=!0),new e({type:"custom",check:"custom",fn:t,...n})}function Op(e,t,r){return new e({type:"custom",check:"custom",fn:t,...O(r)})}function Rp(e,t){let r=lv(n=>(n.addIssue=o=>{if(typeof o=="string")n.issues.push(yr(o,n.value,r._zod.def));else{let s=o;s.fatal&&(s.continue=!1),s.code??(s.code="custom"),"input"in s||(s.input=n.value),s.inst??(s.inst=r),s.continue??(s.continue=!r._zod.def.abort),n.issues.push(yr(s))}},e(n.value,n)),t);return r}function lv(e,t){let r=new ye({check:"custom",...O(t)});return r._zod.check=e,r}function cn(e,...t){for(let r of t)for(let n of Reflect.ownKeys(r))Object.prototype.propertyIsEnumerable.call(r,n)&&Le(e,n,r[n]);return e}function $a(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??Gt,target:t,unrepresentable:e?.unrepresentable??"throw",override:e?.override??(()=>{}),io:e?.io??"output",counter:0,seen:new Map,sharedDefsExtractedFor:void 0,sharedEmitDoneFor:void 0,cycles:e?.cycles??"ref",reused:e?.reused??"inline",intersections:[],deferred:[],external:e?.external??void 0}}function wt(e,t,r,n,o){let s=typeof t.unrepresentable=="function"?t.unrepresentable({zodSchema:e,path:n.path,message:o}):t.unrepresentable;if(s==="any")return!1;if(s===void 0||s==="throw")throw new Error(o);return Object.assign(r,s),!0}function fe(e,t,r={path:[],schemaPath:[]}){var n;let o=e._zod.def,s=t.seen.get(e);if(s)return s.count++,r.schemaPath.includes(e)&&(s.cycle=r.path),s.schema;let i={schema:{},count:1,cycle:void 0,path:r.path};t.seen.set(e,i),t.sharedDefsExtractedFor=void 0,t.sharedEmitDoneFor=void 0;let a=e._zod.toJSONSchema?.();if(a)i.schema=a;else{let l={...r,schemaPath:[...r.schemaPath,e],path:r.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,i.schema,l);else{let f=i.schema,p=t.processors[o.type];if(!p)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${o.type}`);p(e,t,f,l)}let d=e._zod.parent;d&&(i.ref||(i.ref=d),fe(d,t,l),t.seen.get(d).isParent=!0)}let c=t.metadataRegistry.get(e);return c&&cn(i.schema,c),t.io==="input"&&Ee(e)&&(delete i.schema.examples,delete i.schema.default),t.io==="input"&&"_prefault"in i.schema&&((n=i.schema).default??(n.default=i.schema._prefault)),delete i.schema._prefault,t.seen.get(e).schema}function Ap(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}function ka(e,t){let r=e.seen.get(t);if(!r)throw new Error("Unprocessed schema. This is a bug in Zod.");if(e.external&&e.sharedDefsExtractedFor===e.external)return;let n=new Map;for(let i of e.seen.entries()){let a=e.metadataRegistry.get(i[0])?.id;if(a){let c=n.get(a);if(c&&c!==i[0])throw new Error(`Duplicate schema id "${a}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);n.set(a,i[0])}}let o=i=>{let a=e.target==="draft-2020-12"?"$defs":"definitions";if(e.external){let d=e.external.registry.get(i[0])?.id,f=e.external.uri??(m=>m);if(d)return{ref:f(d)};let p=i[1].defId??i[1].schema.id??`schema${e.counter++}`;return i[1].defId=p,{defId:p,ref:`${f("__shared")}#/${a}/${Ap(p)}`}}let c="#",u=`${c}/${a}/`;if(i[1]===r&&!i[1].schema.id)return{ref:c};let l=i[1].schema.id??`__schema${e.counter++}`;return{defId:l,ref:u+Ap(l)}},s=i=>{if(i[1].schema.$ref)return;let a=i[1],{ref:c,defId:u}=o(i);a.def={...a.schema},u&&(a.defId=u);let l=a.schema;for(let d in l)delete l[d];l.$ref=c};if(e.cycles==="throw")for(let i of e.seen.entries()){let a=i[1];if(a.cycle)throw new Error(`Cycle detected: #/${a.cycle?.join("/")}/<root>
|
|
65
65
|
|
|
66
|
-
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let i of e.seen.entries()){let a=i[1];if(t===i[0]){s(i);continue}if(e.external){let u=e.external.registry.get(i[0])?.id;if(t!==i[0]&&u){s(i);continue}}if(e.metadataRegistry.get(i[0])?.id){s(i);continue}if(a.cycle){s(i);continue}a.count>1&&e.reused==="ref"&&s(i)}e.external&&(e.sharedDefsExtractedFor=e.external)}function zp(e){let t=e.anyOf;if(!Array.isArray(t)||t.length===0||e.type!==void 0)return;let r=[];for(let n of t){if(!n||typeof n!="object")return;zp(n);let o=Object.keys(n);if(o.length!==1||o[0]!=="type")return;let s=n.type;for(let i of Array.isArray(s)?s:[s]){if(typeof i!="string")return;r.includes(i)||r.push(i)}}delete e.anyOf,e.type=r.length===1?r[0]:r}var Pp=new Set(["type","properties","required","additionalProperties"]),Sp=["oneOf","anyOf"];function kp(e){let t=e.additionalProperties;return t===void 0||t===!1||typeof t!="object"||t===null?null:Object.keys(t).length?t:null}function ma(e){let t=[];for(let s of e){if(typeof s!="object"||s.type!=="object")return null;for(let i in s)if(!Pp.has(i))return null;t.push(s)}let r={},n=new Set;for(let s of t){for(let i in s.properties){if(Object.prototype.hasOwnProperty.call(r,i))continue;let a=[];for(let u of t){let l=u.properties?.[i]??kp(u);l!=null&&(a.some(d=>JSON.stringify(d)===JSON.stringify(l))||a.push(l))}let c=a.length===1?a[0]:ma(a)??{allOf:a};Re(r,i,c)}for(let i of s.required??[])n.add(i)}let o={type:"object",properties:r};if(n.size&&(o.required=[...n]),t.every(s=>s.additionalProperties===!1))o.additionalProperties=!1;else{let s=[];for(let i of t){let a=kp(i);a&&!s.some(c=>JSON.stringify(c)===JSON.stringify(a))&&s.push(a)}s.length===1?o.additionalProperties=s[0]:s.length>1&&(o.additionalProperties={allOf:s})}return o}function Fb(e){let t=e.allOf;if(!Array.isArray(t)||t.length<2)return;for(let o of Pp)if(o in e)return;let r=t.filter(o=>Sp.some(s=>Array.isArray(o[s]))),n=null;if(!r.length)n=ma(t);else{let o=r[0],s=Sp.find(c=>Array.isArray(o[c]));if(Object.keys(o).length!==1)return;let i=t.filter(c=>c!==o),a=o[s].map(c=>ma([...i,c]));if(a.some(c=>!c))return;n={[s]:a}}n&&(delete e.allOf,rn(e,n))}function ya(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 c=e.seen.get(a);if(c.ref===null)return;let u=c.def??c.schema,l={...u},d=c.ref;if(c.ref=null,d){n(d);let p=e.seen.get(d),m=p.schema;if(m.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0")?(u.allOf=u.allOf??[],u.allOf.push(m)):rn(u,m),rn(u,l),a._zod.parent===d)for(let g in u)g==="$ref"||g==="allOf"||g in l||delete u[g];if(m.$ref&&p.def)for(let g in u)g==="$ref"||g==="allOf"||g in p.def&&JSON.stringify(u[g])===JSON.stringify(p.def[g])&&delete u[g]}let f=a._zod.parent;if(f&&f!==d){n(f);let p=e.seen.get(f);if(p?.schema.$ref&&(u.$ref=p.schema.$ref,p.def))for(let m in u)m==="$ref"||m==="allOf"||m in p.def&&JSON.stringify(u[m])===JSON.stringify(p.def[m])&&delete u[m]}e.override({zodSchema:a,jsonSchema:u,path:c.path??[]})};if(!e.external||e.sharedEmitDoneFor!==e.external){for(let a of[...e.seen.entries()].reverse())n(a[0]);if(e.target!=="openapi-3.0")for(let a of e.seen.entries())zp(a[1].def??a[1].schema);for(let a of e.deferred)a();if(e.intersections.length){let a=new Map;for(let c of e.seen.values())for(let u of[c.schema,c.def]){let l=u?.allOf;if(!Array.isArray(l))continue;let d=a.get(l);d?d.push(u):a.set(l,[u])}for(let c of e.intersections)for(let u of a.get(c)??[])Fb(u)}}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)}rn(o,r.defId?r.schema:r.def??r.schema);let s=e.metadataRegistry.get(t)?.id;s!==void 0&&o.id===s&&delete o.id;let i=e.external?.defs??{};if(!e.external||e.sharedEmitDoneFor!==e.external)for(let a of e.seen.entries()){let c=a[1];c.def&&c.defId&&(c.def.id===c.defId&&delete c.def.id,Re(i,c.defId,c.def))}e.external&&(e.sharedEmitDoneFor=e.external),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:nn(t,"input",e.processors),output:nn(t,"output",e.processors)}},enumerable:!1,writable:!1}),a}catch{throw new Error("Error converting schema to JSON.")}}function be(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 be(n.element,r);if(n.type==="set")return be(n.valueType,r);if(n.type==="lazy")return be(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"||n.type==="catch")return be(n.innerType,r);if(n.type==="intersection")return be(n.left,r)||be(n.right,r);if(n.type==="record"||n.type==="map")return be(n.keyType,r)||be(n.valueType,r);if(n.type==="pipe")return e._zod.traits.has("$ZodCodec")?!0:be(n.in,r)||be(n.out,r);if(n.type==="object"){for(let o in n.shape)if(be(n.shape[o],r))return!0;return!1}if(n.type==="union"){for(let o of n.options)if(be(o,r))return!0;return!1}if(n.type==="tuple"){for(let o of n.items)if(be(o,r))return!0;return!!(n.rest&&be(n.rest,r))}return!1}var Ep=(e,t={})=>r=>{let n=ha({...r,processors:t});return ie(e,n),ga(n,e),ya(n,e)},nn=(e,t,r={})=>n=>{let{libraryOptions:o,target:s}=n??{},i=ha({...o??{},target:s,io:t,processors:r});return ie(e,i),ga(i,e),ya(i,e)};var hr=(e,t,r)=>{(e[t]===void 0||r>e[t])&&(e[t]=r)},gr=(e,t,r)=>{(e[t]===void 0||r<e[t])&&(e[t]=r)},Ip=(e,t)=>{hr(e,"minimum",t),gr(e,"maximum",t)},Ap=(e,t)=>{e.multipleOf??(e.multipleOf=[]),e.multipleOf.includes(t)||e.multipleOf.push(t)},Cp=(e,t)=>{e.patterns??(e.patterns=new Set),e.patterns.add(t)},Np=(e,t)=>{e.mime=e.mime?e.mime.filter(r=>t.includes(r)):[...t]},jp=(e,t)=>{e.format=t,t.includes("int")&&(e.isInt=!0)},Tp=(e,t)=>hr(e,"minimum",t.minimum),Op=(e,t)=>gr(e,"maximum",t.maximum),Rp=e=>(t,r)=>{jp(t,r.format);let[n,o]=e[r.format];hr(t,"minimum",n),gr(t,"maximum",o)},Lb={greater_than:(e,t)=>hr(e,t.inclusive?"minimum":"exclusiveMinimum",t.value),less_than:(e,t)=>gr(e,t.inclusive?"maximum":"exclusiveMaximum",t.value),multiple_of:(e,t)=>Ap(e,t.value),number_format:Rp(Vr),bigint_format:Rp(mo),min_length:Tp,max_length:Op,length_equals:(e,t)=>Ip(e,t.length),min_size:Tp,max_size:Op,size_equals:(e,t)=>Ip(e,t.size),string_format:(e,t)=>{jp(e,t.format),t.pattern&&Cp(e,t.pattern),(t.format==="base64"||t.format==="base64url")&&(e.contentEncoding=t.format),(t.local||t.precision===-1)&&(e.laxFormat=!0)},mime_type:(e,t)=>Np(e,t.mime)};function je(e){let t={},r=e._zod.def,n=e._zod.traits.has("$ZodCheck")?[e,...r.checks??[]]:r.checks??[];for(let s of n)Lb[s._zod.def.check]?.(t,s._zod.def);let o=e._zod.bag;o.minimum!==void 0&&hr(t,"minimum",o.minimum),o.exclusiveMinimum!==void 0&&hr(t,"exclusiveMinimum",o.exclusiveMinimum),o.maximum!==void 0&&gr(t,"maximum",o.maximum),o.exclusiveMaximum!==void 0&&gr(t,"exclusiveMaximum",o.exclusiveMaximum),o.multipleOf!==void 0&&Ap(t,o.multipleOf),o.format!==void 0&&(t.format??(t.format=o.format),o.format.includes("int")&&(t.isInt=!0)),o.mime&&Np(t,o.mime);for(let s of o.patterns??[])Cp(t,s);return t}var Ub={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},Vb=new Map([[Ki,td],[To,rd]]),Dp=e=>Vb.get(e)??e,Zp=(e,t,r,n)=>{let o=r;o.type="string";let{minimum:s,maximum:i,format:a,patterns:c,contentEncoding:u,laxFormat:l}=je(e);if(typeof s=="number"&&(o.minLength=s),typeof i=="number"&&(o.maxLength=i),a&&(o.format=Ub[a]??a,o.format===""&&delete o.format,(a==="time"||l)&&delete o.format),u&&(o.contentEncoding=u),c&&c.size>0){let d=[...c].map(Dp);d.length===1?o.pattern=d[0].source:d.length>1&&(o.allOf=[...d.map(f=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:f.source}))])}},Mp=(e,t,r,n)=>{let o=r,{minimum:s,maximum:i,multipleOf:a,exclusiveMaximum:c,exclusiveMinimum:u,isInt:l}=je(e);o.type=l?"integer":"number";let d=typeof u=="number"&&u>=(s??Number.NEGATIVE_INFINITY),f=typeof c=="number"&&c<=(i??Number.POSITIVE_INFINITY),p=t.target==="draft-04"||t.target==="openapi-3.0";if(d?p?(o.minimum=u,o.exclusiveMinimum=!0):o.exclusiveMinimum=u:typeof s=="number"&&(o.minimum=s),f?p?(o.maximum=c,o.exclusiveMaximum=!0):o.exclusiveMaximum=c:typeof i=="number"&&(o.maximum=i),a){let m=new Set;for(let w of a)Number.isFinite(w)&&w!==0?m.add(Math.abs(w)):ft(e,t,o,n,`A multipleOf divisor of ${w} cannot be represented in JSON Schema`);let[h,...g]=m;h!==void 0&&(o.multipleOf=h),g.length&&(o.allOf=[...o.allOf??[],...g.map(w=>({multipleOf:w}))])}},qp=(e,t,r,n)=>{r.type="boolean"};var Fp=(e,t,r,n)=>{t.target==="openapi-3.0"?(r.type="string",r.nullable=!0,r.enum=[null]):r.type="null"};var Lp=(e,t,r,n)=>{r.not={}};var Up=(e,t,r,n)=>{};var Vp=(e,t,r,n)=>{let o=e._zod.def,s=cr(o.entries);if(s.length===0){r.not={};return}s.every(i=>typeof i=="number")&&(r.type="number"),s.every(i=>typeof i=="string")&&(r.type="string"),r.enum=s},Hp=(e,t,r,n)=>{let o=e._zod.def;if(o.values.length===0){r.not={};return}let s=[];for(let i of o.values)if(i===void 0){if(ft(e,t,r,n,"Literal `undefined` cannot be represented in JSON Schema"))return}else if(typeof i=="bigint"){if(ft(e,t,r,n,"BigInt literals cannot be represented in JSON Schema"))return;s.push(Number(i))}else s.push(i);if(s.length!==0)if(s.length===1){let i=s[0];r.type=i===null?"null":typeof i,t.target==="draft-04"||t.target==="openapi-3.0"?r.enum=[i]:r.const=i}else s.every(i=>typeof i=="number")&&(r.type="number"),s.every(i=>typeof i=="string")&&(r.type="string"),s.every(i=>typeof i=="boolean")&&(r.type="boolean"),s.every(i=>i===null)&&(r.type="null"),r.enum=s};var Bp=(e,t,r,n)=>{ft(e,t,r,n,"Custom types cannot be represented in JSON Schema")};var Jp=(e,t,r,n)=>{ft(e,t,r,n,"Transforms cannot be represented in JSON Schema")};var Kp=(e,t,r,n)=>{let o=r,s=e._zod.def,{minimum:i,maximum:a}=je(e);typeof i=="number"&&(o.minItems=i),typeof a=="number"&&(o.maxItems=a),o.type="array",o.items=ie(s.element,t,{...n,path:[...n.path,"items"]})};function Vo(e){let t=e._zod.def;return t.type==="pipe"&&t.in._zod.traits.has("$ZodTransform")?Vo(t.out):t.type==="catch"?Vo(t.innerType):e._zod.optin}var Gp=(e,t,r,n)=>{let o=r,s=e._zod.def,i=s.shape;if(Object.getOwnPropertySymbols(i).length&&ft(e,t,o,n,"Symbol keys cannot be represented in JSON Schema"))return;o.type="object",o.properties={};for(let u in i)Re(o.properties,u,ie(i[u],t,{...n,path:[...n.path,"properties",u]}));let c=[];for(let u of Object.keys(i)){let l=s.shape[u];(t.io==="input"?Vo(l)===void 0:l._zod.optout===void 0)&&c.push(u)}c.length>0&&(o.required=c),s.catchall?._zod.def.type==="never"?o.additionalProperties=!1:s.catchall?s.catchall&&(o.additionalProperties=ie(s.catchall,t,{...n,path:[...n.path,"additionalProperties"]})):t.io==="output"&&(o.additionalProperties=!1)},Wp=(e,t,r,n)=>{let o=e._zod.def,s=o.inclusive===!1,i=o.options.map((a,c)=>ie(a,t,{...n,path:[...n.path,s?"oneOf":"anyOf",c]}));s?r.oneOf=i:r.anyOf=i},Yp=(e,t,r,n)=>{let o=e._zod.def,s=ie(o.left,t,{...n,path:[...n.path,"allOf",0]}),i=ie(o.right,t,{...n,path:[...n.path,"allOf",1]}),a=u=>"allOf"in u&&Object.keys(u).length===1,c=[...a(s)?s.allOf:[s],...a(i)?i.allOf:[i]];r.allOf=c,t.intersections.push(c)};function _a(e,t,r){if(t.$ref){if(r.has(t))return t;r.add(t);let m=e.get(t)?.def;if(!m)return t;let h=_a(e,m,r);return h===m?t:h}for(let m of["anyOf","oneOf"]){let h=t[m];if(!Array.isArray(h))continue;let g=h.map(w=>_a(e,w,r));g.some((w,v)=>w!==h[v])&&(t={...t,[m]:g})}let n=Array.isArray(t.type)?t.type:[t.type],o=!n.includes("string")&&n.some(m=>m==="number"||m==="integer"),s=t.enum??(t.const!==void 0?[t.const]:void 0);if(!o&&!s?.some(m=>typeof m=="number"))return t;let{minimum:i,maximum:a,exclusiveMinimum:c,exclusiveMaximum:u,multipleOf:l,format:d,id:f,...p}=t;return p.enum?p.enum=p.enum.map(m=>typeof m=="number"?String(m):m):typeof p.const=="number"&&(p.const=String(p.const)),o&&(p.type="string",s||(p.pattern=(n.includes("number")?Gr:Li).source)),p}var wa=new WeakMap;function Hb(e){let t=new Map;for(let n of e.seen.values())n.def&&!t.has(n.schema)&&t.set(n.schema,n);let r=new Map;for(let n of wa.get(e)??[]){let o=e.seen.get(n),s=(o?.def??o?.schema)?.propertyNames;if(!s||s===!0||r.has(s))continue;let i=_a(t,s,new Set);i!==s&&r.set(s,i)}if(r.size)for(let n of e.seen.values())for(let o of[n.schema,n.def]){let s=o&&r.get(o.propertyNames);s&&(o.propertyNames=s)}}var Xp=(e,t,r,n)=>{let o=r,s=e._zod.def;o.type="object";let i=s.keyType,a=je(i).patterns;if(s.mode==="loose"&&a&&a.size>0){let l=ie(s.valueType,t,{...n,path:[...n.path,"patternProperties","*"]});o.patternProperties={};for(let d of a)Re(o.patternProperties,Dp(d).source,l)}else{if(t.target==="draft-07"||t.target==="draft-2020-12"){o.propertyNames=ie(s.keyType,t,{...n,path:[...n.path,"propertyNames"]});let l=wa.get(t);l||(l=[],wa.set(t,l),t.deferred.push(()=>Hb(t))),l.push(e)}o.additionalProperties=ie(s.valueType,t,{...n,path:[...n.path,"additionalProperties"]})}let c=i._zod.values,u=t.io==="input"&&Vo(s.valueType)!==void 0;if(c&&!s.partial&&!u){let l=[...c].filter(d=>typeof d=="string"||typeof d=="number");l.length>0&&(o.required=l.map(String))}},Qp=(e,t,r,n)=>{let o=e._zod.def,s=ie(o.innerType,t,n),i=t.seen.get(e);t.target==="openapi-3.0"?(i.ref=o.innerType,r.nullable=!0):r.anyOf=[s,{type:"null"}]},em=(e,t,r,n)=>{let o=e._zod.def;ie(o.innerType,t,n);let s=t.seen.get(e);s.ref=o.innerType},ba=Symbol();function tm(e,t,r,n,o){let s=!1,i=JSON.stringify(e,(a,c)=>typeof c!="bigint"?c:(s=!0,null));return s?(ft(t,r,n,o,"BigInt defaults cannot be represented in JSON Schema"),ba):JSON.parse(i)}var rm=(e,t,r,n)=>{let o=e._zod.def;ie(o.innerType,t,n);let s=t.seen.get(e);s.ref=o.innerType;let i=tm(o.defaultValue,e,t,r,n);i!==ba&&(r.default=i)},nm=(e,t,r,n)=>{let o=e._zod.def;ie(o.innerType,t,n);let s=t.seen.get(e);if(s.ref=o.innerType,t.io!=="input")return;let i=tm(o.defaultValue,e,t,r,n);i!==ba&&(r._prefault=i)},om=(e,t,r,n)=>{let o=e._zod.def;ie(o.innerType,t,n);let s=t.seen.get(e);s.ref=o.innerType;let i;try{i=o.catchValue(void 0)}catch{ft(e,t,r,n,"Dynamic catch values are not supported in JSON Schema");return}r.default=i},sm=(e,t,r,n)=>{let o=e._zod.def,s=o.in._zod.traits.has("$ZodTransform"),i=t.io==="input"?s?o.out:o.in:o.out;ie(i,t,n);let a=t.seen.get(e);a.ref=i},im=(e,t,r,n)=>{let o=e._zod.def;ie(o.innerType,t,n);let s=t.seen.get(e);s.ref=o.innerType,r.readOnly=!0};var va=(e,t,r,n)=>{let o=e._zod.def;ie(o.innerType,t,n);let s=t.seen.get(e);s.ref=o.innerType};var am=new WeakSet([Object.prototype,Error.prototype]);function Ho(e,t,r){Object.defineProperty(e,t,{configurable:!0,enumerable:!1,get(){let n=r(this);return Object.defineProperty(this,t,{value:n,configurable:!0,writable:!0}),n},set(n){Object.defineProperty(this,t,{value:n,configurable:!0,writable:!0})}})}var ev=(e,t)=>{Pl.init(e,t),e.name="ZodError";let r=Object.getPrototypeOf(e);am.has(r)||(am.add(r),Ho(r,"format",n=>o=>Tl(n,o)),Ho(r,"flatten",n=>o=>Il(n,o)),Ho(r,"addIssue",n=>o=>{n.issues.push(o),n.message=JSON.stringify(n.issues,ur,2)}),Ho(r,"addIssues",n=>o=>{n.issues.push(...o),n.message=JSON.stringify(n.issues,ur,2)}),Object.defineProperty(r,"isEmpty",{configurable:!0,enumerable:!1,get(){return this.issues.length===0}}))};var Ce=_("ZodError",ev,void 0,{Parent:Error});var cm=wo(Ce),um=bo(Ce),lm=Kr(Ce),dm=vo(Ce),fm=Rl(Ce),pm=Al(Ce),mm=Cl(Ce),hm=Nl(Ce),gm=jl(Ce),ym=Dl(Ce),_m=Zl(Ce),wm=Ml(Ce);function rv(){Se.localeError||Ae(Ff())}function Jo(){Se.memoizer||Ae({memoizer:qf()})}var re=_("ZodType",(e,t)=>(rv(),G.init(e,t),e.def=t,e.type=t.type,e),{check(...e){let t=this.def;return this.clone(I.mergeDefs(t,{checks:[...t.checks??[],...e.map(r=>typeof r=="function"?{_zod:{check:r,def:{check:"custom"},onattach:[]}}:r)]}),{parent:!0})},with(...e){return this.check(...e)},clone(e,t){return Je(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(Hv(e,t))},superRefine(e,t){return this.check(Bv(e,t))},overwrite(e){return this.check(vt(e))},optional(){return te(this)},exactOptional(){return Av(this)},nullable(){return $m(this)},nullish(){return te($m(this))},nonoptional(e){return Mv(this,e)},array(){return M(this)},or(e){return Y([this,e])},and(e){return Ko(this,e)},transform(e){return xm(this,Im(e))},default(e){return jv(this,e)},prefault(e){return Zv(this,e)},catch(e){return Fv(this,e)},pipe(e){return xm(this,e)},readonly(){return Vv(this)},describe(e){let t=this.clone();return qt.add(t,{description:e}),t},meta(...e){if(e.length===0)return qt.get(this);let t=this.clone();return qt.add(t,e[0]),t},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(e,...t){return t.length===0?e(this):e(this,...t)},get"~standard"(){return I.hide(this,"~standard",{...Ji(this),jsonSchema:{input:nn(this,"input"),output:nn(this,"output")}})},set"~standard"(e){I.own(this,"~standard",e)},parse:function e(t,r){return cm(this,t,r,{callee:e})},parseAsync:async function e(t,r){return await um(this,t,r,{callee:e})},safeParse(e,t){return lm(this,e,t)},async safeParseAsync(e,t){return dm(this,e,t)},get spa(){return this?.safeParseAsync},set spa(e){I.own(this,"spa",e)},validate(e,t){return $o(this,e,t)},validateAsync(e,t){return xo(this,e,t)},encode:function e(t,r){return fm(this,t,r,{callee:e})},decode:function e(t,r){return pm(this,t,r,{callee:e})},encodeAsync:async function e(t,r){return await mm(this,t,r,{callee:e})},decodeAsync:async function e(t,r){return await hm(this,t,r,{callee:e})},safeEncode(e,t){return gm(this,e,t)},safeDecode(e,t){return ym(this,e,t)},async safeEncodeAsync(e,t){return _m(this,e,t)},async safeDecodeAsync(e,t){return wm(this,e,t)},toJSONSchema(e){return Ep(this,{})(e)},get description(){return qt.get(this)?.description},get _def(){return this._zod.def}}),Sm=_("_ZodString",(e,t)=>{Io.init(e,t),re.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Zp(e,r,n,o)},I.derived({format:e=>je(e).format??null,minLength:e=>je(e).minimum??null,maxLength:e=>je(e).maximum??null},{regex(...e){return this.check(na(...e))},includes(...e){return this.check(ia(...e))},startsWith(...e){return this.check(aa(...e))},endsWith(...e){return this.check(ca(...e))},min(...e){return this.check(mr(...e))},max(...e){return this.check(Lo(...e))},length(...e){return this.check(Uo(...e))},nonempty(...e){return this.check(mr(1,...e))},lowercase(e){return this.check(oa(e))},uppercase(e){return this.check(sa(e))},trim(){return this.check(la())},normalize(...e){return this.check(ua(...e))},toLowerCase(){return this.check(da())},toUpperCase(){return this.check(fa())},slugify(){return this.check(pa())}})),nv=_("ZodString",(e,t)=>{Io.init(e,t),Sm.init(e,t)},{email(e){return this.check(Hf(ov,e))},url(e){return this.check(Yf(iv,e))},jwt(e){return this.check(fp(vv,e))},emoji(e){return this.check(Xf(av,e))},guid(e){return this.check(Bf(sv,e))},uuid(e){return this.check(Jf(Bo,e))},uuidv4(e){return this.check(Kf(Bo,e))},uuidv6(e){return this.check(Gf(Bo,e))},uuidv7(e){return this.check(Wf(Bo,e))},nanoid(e){return this.check(Qf(cv,e))},cuid(e){return this.check(ep(uv,e))},cuid2(e){return this.check(tp(lv,e))},ulid(e){return this.check(rp(dv,e))},base64(e){return this.check(up(_v,e))},base64url(e){return this.check(lp(wv,e))},xid(e){return this.check(np(fv,e))},ksuid(e){return this.check(op(pv,e))},ipv4(e){return this.check(sp(mv,e))},ipv6(e){return this.check(ip(hv,e))},cidrv4(e){return this.check(ap(gv,e))},cidrv6(e){return this.check(cp(yv,e))},e164(e){return this.check(dp(bv,e))},datetime(e){return this.check(No(sn,e))},date(e){return this.check(jo(an,e))},time(e){return this.check(Do(cn,e))},duration(e){return this.check(Zo(un,e))}});function y(e){return Vf(nv,e)}var ne=_("ZodStringFormat",(e,t)=>{W.init(e,t),Sm.init(e,t)}),sn=_("ZodISODateTime",(e,t)=>{Xd.init(e,t),ne.init(e,t)}),an=_("ZodISODate",(e,t)=>{Qd.init(e,t),ne.init(e,t)}),cn=_("ZodISOTime",(e,t)=>{ef.init(e,t),ne.init(e,t)}),un=_("ZodISODuration",(e,t)=>{tf.init(e,t),ne.init(e,t)}),ov=_("ZodEmail",(e,t)=>{Fd.init(e,t),ne.init(e,t)});var sv=_("ZodGUID",(e,t)=>{Md.init(e,t),ne.init(e,t)});var Bo=_("ZodUUID",(e,t)=>{qd.init(e,t),ne.init(e,t)});var iv=_("ZodURL",(e,t)=>{Vd.init(e,t),ne.init(e,t)});var av=_("ZodEmoji",(e,t)=>{Hd.init(e,t),ne.init(e,t)});var cv=_("ZodNanoID",(e,t)=>{Bd.init(e,t),ne.init(e,t)});var uv=_("ZodCUID",(e,t)=>{Jd.init(e,t),ne.init(e,t)});var lv=_("ZodCUID2",(e,t)=>{Kd.init(e,t),ne.init(e,t)});var dv=_("ZodULID",(e,t)=>{Gd.init(e,t),ne.init(e,t)});var fv=_("ZodXID",(e,t)=>{Wd.init(e,t),ne.init(e,t)});var pv=_("ZodKSUID",(e,t)=>{Yd.init(e,t),ne.init(e,t)});var mv=_("ZodIPv4",(e,t)=>{rf.init(e,t),ne.init(e,t)});var hv=_("ZodIPv6",(e,t)=>{of.init(e,t),ne.init(e,t)});var gv=_("ZodCIDRv4",(e,t)=>{sf.init(e,t),ne.init(e,t)});var yv=_("ZodCIDRv6",(e,t)=>{af.init(e,t),ne.init(e,t)});var _v=_("ZodBase64",(e,t)=>{uf.init(e,t),ne.init(e,t)});var wv=_("ZodBase64URL",(e,t)=>{lf.init(e,t),ne.init(e,t)});var bv=_("ZodE164",(e,t)=>{df.init(e,t),ne.init(e,t)});var vv=_("ZodJWT",(e,t)=>{ff.init(e,t),ne.init(e,t)});var km=_("ZodNumber",(e,t)=>{Gi.init(e,t),re.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Mp(e,r,n,o),e.isFinite=!0},I.derived({minValue:e=>{let{minimum:t,exclusiveMinimum:r}=je(e);return Math.max(t??Number.NEGATIVE_INFINITY,r??Number.NEGATIVE_INFINITY)},maxValue:e=>{let{maximum:t,exclusiveMaximum:r}=je(e);return Math.min(t??Number.POSITIVE_INFINITY,r??Number.POSITIVE_INFINITY)},isInt:e=>{let{isInt:t,multipleOf:r}=je(e);return!!t||!!r?.some(Number.isSafeInteger)},format:e=>je(e).format??null},{gt(e,t){return this.check(qo(e,t))},gte(e,t){return this.check(tn(e,t))},min(e,t){return this.check(tn(e,t))},lt(e,t){return this.check(Mo(e,t))},lte(e,t){return this.check(en(e,t))},max(e,t){return this.check(en(e,t))},int(e){return this.check(bm(e))},safe(e){return this.check(bm(e))},positive(e){return this.check(qo(0,e))},nonnegative(e){return this.check(tn(0,e))},negative(e){return this.check(Mo(0,e))},nonpositive(e){return this.check(en(0,e))},multipleOf(e,t){return this.check(Fo(e,t))},step(e,t){return this.check(Fo(e,t))},finite(){return this}}));function H(e){return pp(km,e)}var $v=_("ZodNumberFormat",(e,t)=>{pf.init(e,t),km.init(e,t)});function bm(e){return mp($v,e)}var xv=_("ZodBoolean",(e,t)=>{mf.init(e,t),re.init(e,t),e._zod.processJSONSchema=(r,n,o)=>qp(e,r,n,o)});function ue(e){return hp(xv,e)}var Sv=_("ZodNull",(e,t)=>{hf.init(e,t),re.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Fp(e,r,n,o)});function zm(e){return gp(Sv,e)}var kv=_("ZodUnknown",(e,t)=>{gf.init(e,t),re.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Up(e,r,n,o)});function ee(){return yp(kv)}var zv=_("ZodNever",(e,t)=>{yf.init(e,t),re.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Lp(e,r,n,o)});function Pv(e){return _p(zv,e)}var Ev=_("ZodArray",(e,t)=>{Jo(),_f.init(e,t),re.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Kp(e,r,n,o),e.element=t.element},{min(e,t){return this.check(mr(e,t))},nonempty(e){return this.check(mr(1,e))},max(e,t){return this.check(Lo(e,t))},length(e,t){return this.check(Uo(e,t))},unwrap(){return this.element}});function M(e,t){return wp(Ev,e,t)}var Pm=_("ZodObject",(e,t)=>{Jo(),vf.init(e,t),re.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Gp(e,r,n,o),I.installLazyProp(e,"shape",r=>r._zod.def.shape,!1)},{keyof(){return ke(Object.keys(this._zod.def.shape))},catchall(e){return this.clone(I.mergeDefs(this._zod.def,{catchall:e}))},passthrough(){return this.clone(I.mergeDefs(this._zod.def,{catchall:ee()}))},loose(){return this.clone(I.mergeDefs(this._zod.def,{catchall:ee()}))},strict(){return this.clone(I.mergeDefs(this._zod.def,{catchall:Pv()}))},strip(){return this.clone(I.mergeDefs(this._zod.def,{catchall:void 0}))},extend(e){return I.extend(this,e)},safeExtend(e){return I.safeExtend(this,e)},merge(e){return I.merge(this,e)},pick(e){return I.pick(this,e)},omit(e){return I.omit(this,e)},partial(...e){return I.partial(Tm,this,e[0])},exactPartial(...e){return I.partial(Om,this,e[0],"exactPartial")},required(...e){return I.required(Rm,this,e[0])}});function S(e,t){let r={type:"object",shape:e??{},...I.normalizeParams(t)};return new Pm(r)}function ve(e,t){return new Pm({type:"object",shape:e,catchall:ee(),...I.normalizeParams(t)})}var Em=_("ZodUnion",(e,t)=>{Wi.init(e,t),re.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Wp(e,r,n,o),e.options=t.options});function Y(e,t){return new Em({type:"union",options:e,...I.normalizeParams(t)})}var Iv=_("ZodDiscriminatedUnion",(e,t)=>{Em.init(e,t),$f.init(e,t)});function xa(e,t,r){return new Iv({type:"union",options:t,discriminator:e,...I.normalizeParams(r)})}var Tv=_("ZodIntersection",(e,t)=>{xf.init(e,t),re.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Yp(e,r,n,o)});function Ko(e,t){return new Tv({type:"intersection",left:e,right:t})}var vm=_("ZodRecord",(e,t)=>{Jo(),Sf.init(e,t),re.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Xp(e,r,n,o),e.keyType=t.keyType,e.valueType=t.valueType});function K(e,t,r){return!t||!t._zod?new vm({type:"record",keyType:y(),valueType:e,...I.normalizeParams(t)}):new vm({type:"record",keyType:e,valueType:t,...I.normalizeParams(r)})}var $a=_("ZodEnum",(e,t)=>{kf.init(e,t),re.init(e,t),e._zod.processJSONSchema=(n,o,s)=>Vp(e,n,o,s),e.enum=t.entries,e.options=[...e._zod.values];let r=new Set(Object.keys(t.entries));e.extract=(n,o)=>{let s={};for(let i of n)if(r.has(i))s[i]=t.entries[i];else throw new Error(`Key ${i} not found in enum`);return new $a({...t,checks:[],...I.normalizeParams(o),entries:s})},e.exclude=(n,o)=>{let s={...t.entries};for(let i of n)if(r.has(i))delete s[i];else throw new Error(`Key ${i} not found in enum`);return new $a({...t,checks:[],...I.normalizeParams(o),entries:s})}});function ke(e,t){let r=Array.isArray(e)?Object.fromEntries(e.map(n=>[n,n])):e;return new $a({type:"enum",entries:r,...I.normalizeParams(t)})}var Ov=_("ZodLiteral",(e,t)=>{zf.init(e,t),re.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Hp(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 z(e,t){return new Ov({type:"literal",values:Array.isArray(e)?e:[e],...I.normalizeParams(t)})}var Rv=_("ZodTransform",(e,t)=>{Jo(),Pf.init(e,t),re.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Jp(e,r,n,o),e._zod.parse=(r,n)=>{if(n.direction==="backward")throw new pr(e.constructor.name);r.addIssue=s=>{if(typeof s=="string")r.issues.push(I.issue(s,r.value,t));else{let i=s;i.fatal&&(i.continue=!1),i.code??(i.code="custom"),"input"in i||(i.input=r.value),i.inst??(i.inst=e),r.issues.push(I.issue(i))}};let o=t.transform(r.value,r);return o instanceof Promise?o.then(s=>(r.value=s,r)):(r.value=o,r)}});function Im(e){return new Rv({type:"transform",transform:e})}var Tm=_("ZodOptional",(e,t)=>{Yi.init(e,t),re.init(e,t),e._zod.processJSONSchema=(r,n,o)=>va(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function te(e){return new Tm({type:"optional",innerType:e})}var Om=_("ZodExactOptional",(e,t)=>{Ef.init(e,t),re.init(e,t),e._zod.processJSONSchema=(r,n,o)=>va(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function Av(e){return new Om({type:"optional",innerType:e})}var Cv=_("ZodNullable",(e,t)=>{If.init(e,t),re.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Qp(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function $m(e){return new Cv({type:"nullable",innerType:e})}var Nv=_("ZodDefault",(e,t)=>{Tf.init(e,t),re.init(e,t),e._zod.processJSONSchema=(r,n,o)=>rm(e,r,n,o),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function jv(e,t){return new Nv({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():I.shallowClone(t)}})}var Dv=_("ZodPrefault",(e,t)=>{Of.init(e,t),re.init(e,t),e._zod.processJSONSchema=(r,n,o)=>nm(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function Zv(e,t){return new Dv({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():I.shallowClone(t)}})}var Rm=_("ZodNonOptional",(e,t)=>{Rf.init(e,t),re.init(e,t),e._zod.processJSONSchema=(r,n,o)=>em(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function Mv(e,t){return new Rm({type:"nonoptional",innerType:e,...I.normalizeParams(t)})}var qv=_("ZodCatch",(e,t)=>{Af.init(e,t),re.init(e,t),e._zod.processJSONSchema=(r,n,o)=>om(e,r,n,o),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function Fv(e,t){return new qv({type:"catch",innerType:e,catchValue:typeof t=="function"?t:I.constantCatch(t)})}var Am=_("ZodPipe",(e,t)=>{Xi.init(e,t),re.init(e,t),e._zod.processJSONSchema=(r,n,o)=>sm(e,r,n,o),e.in=t.in,e.out=t.out});function xm(e,t){return new Am({type:"pipe",in:e,out:t})}var Lv=_("ZodPreprocess",(e,t)=>{Am.init(e,t),Cf.init(e,t)}),Uv=_("ZodReadonly",(e,t)=>{Nf.init(e,t),re.init(e,t),e._zod.processJSONSchema=(r,n,o)=>im(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function Vv(e){return new Uv({type:"readonly",innerType:e})}var Cm=_("ZodCustom",(e,t)=>{jf.init(e,t),re.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Bp(e,r,n,o)});function Nm(e,t){return bp(Cm,e??(()=>!0),t)}function Hv(e,t={}){return vp(Cm,e,t)}function Bv(e,t){return $p(e,t)}function Sa(e,t){return new Lv({type:"pipe",in:Im(e),out:t})}var Go={};ul(Go,{ZodISODate:()=>an,ZodISODateTime:()=>sn,ZodISODuration:()=>un,ZodISOTime:()=>cn,date:()=>Kv,datetime:()=>Jv,duration:()=>Wv,time:()=>Gv});function Jv(e){return No(sn,e)}function Kv(e){return jo(an,e)}function Gv(e){return Do(cn,e)}function Wv(e){return Zo(un,e)}var za="2025-11-25";var jm=[za,"2025-06-18","2025-03-26","2024-11-05","2024-10-07"],$t="io.modelcontextprotocol/related-task",Yo="2.0",ce=Nm(e=>e!==null&&(typeof e=="object"||typeof e=="function")),Dm=Y([y(),H().int()]),Zm=y(),FR=ve({ttl:H().optional(),pollInterval:H().optional()}),Yv=S({ttl:H().optional()}),Xv=S({taskId:y()}),Pa=ve({progressToken:Dm.optional(),[$t]:Xv.optional()}),Ne=S({_meta:Pa.optional()}),ln=Ne.extend({task:Yv.optional()}),Mm=e=>ln.safeParse(e).success,de=S({method:y(),params:Ne.loose().optional()}),De=S({_meta:Pa.optional()}),Ze=S({method:y(),params:De.loose().optional()}),fe=ve({_meta:Pa.optional()}),Xo=Y([y(),H().int()]),qm=S({jsonrpc:z(Yo),id:Xo,...de.shape}).strict(),Ea=e=>qm.safeParse(e).success,Fm=S({jsonrpc:z(Yo),...Ze.shape}).strict(),Lm=e=>Fm.safeParse(e).success,Ia=S({jsonrpc:z(Yo),id:Xo,result:fe}).strict(),dn=e=>Ia.safeParse(e).success;var A;(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"})(A||(A={}));var Ta=S({jsonrpc:z(Yo),id:Xo.optional(),error:S({code:H().int(),message:y(),data:ee().optional()})}).strict();var Um=e=>Ta.safeParse(e).success;var Vm=Y([qm,Fm,Ia,Ta]),LR=Y([Ia,Ta]),Qo=fe.strict(),Qv=De.extend({requestId:Xo.optional(),reason:y().optional()}),es=Ze.extend({method:z("notifications/cancelled"),params:Qv}),e0=S({src:y(),mimeType:y().optional(),sizes:M(y()).optional(),theme:ke(["light","dark"]).optional()}),fn=S({icons:M(e0).optional()}),yr=S({name:y(),title:y().optional()}),Hm=yr.extend({...yr.shape,...fn.shape,version:y(),websiteUrl:y().optional(),description:y().optional()}),t0=Ko(S({applyDefaults:ue().optional()}),K(y(),ee())),r0=Sa(e=>e&&typeof e=="object"&&!Array.isArray(e)&&Object.keys(e).length===0?{form:{}}:e,Ko(S({form:t0.optional(),url:ce.optional()}),K(y(),ee()).optional())),n0=ve({list:ce.optional(),cancel:ce.optional(),requests:ve({sampling:ve({createMessage:ce.optional()}).optional(),elicitation:ve({create:ce.optional()}).optional()}).optional()}),o0=ve({list:ce.optional(),cancel:ce.optional(),requests:ve({tools:ve({call:ce.optional()}).optional()}).optional()}),s0=S({experimental:K(y(),ce).optional(),sampling:S({context:ce.optional(),tools:ce.optional()}).optional(),elicitation:r0.optional(),roots:S({listChanged:ue().optional()}).optional(),tasks:n0.optional(),extensions:K(y(),ce).optional()}),i0=Ne.extend({protocolVersion:y(),capabilities:s0,clientInfo:Hm}),Oa=de.extend({method:z("initialize"),params:i0});var a0=S({experimental:K(y(),ce).optional(),logging:ce.optional(),completions:ce.optional(),prompts:S({listChanged:ue().optional()}).optional(),resources:S({subscribe:ue().optional(),listChanged:ue().optional()}).optional(),tools:S({listChanged:ue().optional()}).optional(),tasks:o0.optional(),extensions:K(y(),ce).optional()}),c0=fe.extend({protocolVersion:y(),capabilities:a0,serverInfo:Hm,instructions:y().optional()}),Ra=Ze.extend({method:z("notifications/initialized"),params:De.optional()});var ts=de.extend({method:z("ping"),params:Ne.optional()}),u0=S({progress:H(),total:te(H()),message:te(y())}),l0=S({...De.shape,...u0.shape,progressToken:Dm}),rs=Ze.extend({method:z("notifications/progress"),params:l0}),d0=Ne.extend({cursor:Zm.optional()}),pn=de.extend({params:d0.optional()}),mn=fe.extend({nextCursor:Zm.optional()}),f0=ke(["working","input_required","completed","failed","cancelled"]),hn=S({taskId:y(),status:f0,ttl:Y([H(),zm()]),createdAt:y(),lastUpdatedAt:y(),pollInterval:te(H()),statusMessage:te(y())}),_r=fe.extend({task:hn}),p0=De.merge(hn),gn=Ze.extend({method:z("notifications/tasks/status"),params:p0}),ns=de.extend({method:z("tasks/get"),params:Ne.extend({taskId:y()})}),os=fe.merge(hn),ss=de.extend({method:z("tasks/result"),params:Ne.extend({taskId:y()})}),UR=fe.loose(),is=pn.extend({method:z("tasks/list")}),as=mn.extend({tasks:M(hn)}),cs=de.extend({method:z("tasks/cancel"),params:Ne.extend({taskId:y()})}),Bm=fe.merge(hn),Jm=S({uri:y(),mimeType:te(y()),_meta:K(y(),ee()).optional()}),Km=Jm.extend({text:y()}),Aa=y().refine(e=>{try{return atob(e),!0}catch{return!1}},{message:"Invalid Base64 string"}),Gm=Jm.extend({blob:Aa}),yn=ke(["user","assistant"]),wr=S({audience:M(yn).optional(),priority:H().min(0).max(1).optional(),lastModified:Go.datetime({offset:!0}).optional()}),Wm=S({...yr.shape,...fn.shape,uri:y(),description:te(y()),mimeType:te(y()),size:te(H()),annotations:wr.optional(),_meta:te(ve({}))}),m0=S({...yr.shape,...fn.shape,uriTemplate:y(),description:te(y()),mimeType:te(y()),annotations:wr.optional(),_meta:te(ve({}))}),h0=pn.extend({method:z("resources/list")}),g0=mn.extend({resources:M(Wm)}),y0=pn.extend({method:z("resources/templates/list")}),_0=mn.extend({resourceTemplates:M(m0)}),Ca=Ne.extend({uri:y()}),w0=Ca,b0=de.extend({method:z("resources/read"),params:w0}),v0=fe.extend({contents:M(Y([Km,Gm]))}),$0=Ze.extend({method:z("notifications/resources/list_changed"),params:De.optional()}),x0=Ca,S0=de.extend({method:z("resources/subscribe"),params:x0}),k0=Ca,z0=de.extend({method:z("resources/unsubscribe"),params:k0}),P0=De.extend({uri:y()}),E0=Ze.extend({method:z("notifications/resources/updated"),params:P0}),I0=S({name:y(),description:te(y()),required:te(ue())}),T0=S({...yr.shape,...fn.shape,description:te(y()),arguments:te(M(I0)),_meta:te(ve({}))}),O0=pn.extend({method:z("prompts/list")}),R0=mn.extend({prompts:M(T0)}),A0=Ne.extend({name:y(),arguments:K(y(),y()).optional()}),C0=de.extend({method:z("prompts/get"),params:A0}),Na=S({type:z("text"),text:y(),annotations:wr.optional(),_meta:K(y(),ee()).optional()}),ja=S({type:z("image"),data:Aa,mimeType:y(),annotations:wr.optional(),_meta:K(y(),ee()).optional()}),Da=S({type:z("audio"),data:Aa,mimeType:y(),annotations:wr.optional(),_meta:K(y(),ee()).optional()}),N0=S({type:z("tool_use"),name:y(),id:y(),input:K(y(),ee()),_meta:K(y(),ee()).optional()}),j0=S({type:z("resource"),resource:Y([Km,Gm]),annotations:wr.optional(),_meta:K(y(),ee()).optional()}),D0=Wm.extend({type:z("resource_link")}),Za=Y([Na,ja,Da,D0,j0]),Z0=S({role:yn,content:Za}),M0=fe.extend({description:y().optional(),messages:M(Z0)}),q0=Ze.extend({method:z("notifications/prompts/list_changed"),params:De.optional()}),F0=S({title:y().optional(),readOnlyHint:ue().optional(),destructiveHint:ue().optional(),idempotentHint:ue().optional(),openWorldHint:ue().optional()}),L0=S({taskSupport:ke(["required","optional","forbidden"]).optional()}),Ym=S({...yr.shape,...fn.shape,description:y().optional(),inputSchema:S({type:z("object"),properties:K(y(),ce).optional(),required:M(y()).optional()}).catchall(ee()),outputSchema:S({type:z("object"),properties:K(y(),ce).optional(),required:M(y()).optional()}).catchall(ee()).optional(),annotations:F0.optional(),execution:L0.optional(),_meta:K(y(),ee()).optional()}),Ma=pn.extend({method:z("tools/list")}),U0=mn.extend({tools:M(Ym)}),us=fe.extend({content:M(Za).default([]),structuredContent:K(y(),ee()).optional(),isError:ue().optional()}),VR=us.or(fe.extend({toolResult:ee()})),V0=ln.extend({name:y(),arguments:K(y(),ee()).optional()}),_n=de.extend({method:z("tools/call"),params:V0}),H0=Ze.extend({method:z("notifications/tools/list_changed"),params:De.optional()}),HR=S({autoRefresh:ue().default(!0),debounceMs:H().int().nonnegative().default(300)}),wn=ke(["debug","info","notice","warning","error","critical","alert","emergency"]),B0=Ne.extend({level:wn}),qa=de.extend({method:z("logging/setLevel"),params:B0}),J0=De.extend({level:wn,logger:y().optional(),data:ee()}),K0=Ze.extend({method:z("notifications/message"),params:J0}),G0=S({name:y().optional()}),W0=S({hints:M(G0).optional(),costPriority:H().min(0).max(1).optional(),speedPriority:H().min(0).max(1).optional(),intelligencePriority:H().min(0).max(1).optional()}),Y0=S({mode:ke(["auto","required","none"]).optional()}),X0=S({type:z("tool_result"),toolUseId:y().describe("The unique identifier for the corresponding tool call."),content:M(Za).default([]),structuredContent:S({}).loose().optional(),isError:ue().optional(),_meta:K(y(),ee()).optional()}),Q0=xa("type",[Na,ja,Da]),Wo=xa("type",[Na,ja,Da,N0,X0]),e$=S({role:yn,content:Y([Wo,M(Wo)]),_meta:K(y(),ee()).optional()}),t$=ln.extend({messages:M(e$),modelPreferences:W0.optional(),systemPrompt:y().optional(),includeContext:ke(["none","thisServer","allServers"]).optional(),temperature:H().optional(),maxTokens:H().int(),stopSequences:M(y()).optional(),metadata:ce.optional(),tools:M(Ym).optional(),toolChoice:Y0.optional()}),r$=de.extend({method:z("sampling/createMessage"),params:t$}),bn=fe.extend({model:y(),stopReason:te(ke(["endTurn","stopSequence","maxTokens"]).or(y())),role:yn,content:Q0}),Fa=fe.extend({model:y(),stopReason:te(ke(["endTurn","stopSequence","maxTokens","toolUse"]).or(y())),role:yn,content:Y([Wo,M(Wo)])}),n$=S({type:z("boolean"),title:y().optional(),description:y().optional(),default:ue().optional()}),o$=S({type:z("string"),title:y().optional(),description:y().optional(),minLength:H().optional(),maxLength:H().optional(),format:ke(["email","uri","date","date-time"]).optional(),default:y().optional()}),s$=S({type:ke(["number","integer"]),title:y().optional(),description:y().optional(),minimum:H().optional(),maximum:H().optional(),default:H().optional()}),i$=S({type:z("string"),title:y().optional(),description:y().optional(),enum:M(y()),default:y().optional()}),a$=S({type:z("string"),title:y().optional(),description:y().optional(),oneOf:M(S({const:y(),title:y()})),default:y().optional()}),c$=S({type:z("string"),title:y().optional(),description:y().optional(),enum:M(y()),enumNames:M(y()).optional(),default:y().optional()}),u$=Y([i$,a$]),l$=S({type:z("array"),title:y().optional(),description:y().optional(),minItems:H().optional(),maxItems:H().optional(),items:S({type:z("string"),enum:M(y())}),default:M(y()).optional()}),d$=S({type:z("array"),title:y().optional(),description:y().optional(),minItems:H().optional(),maxItems:H().optional(),items:S({anyOf:M(S({const:y(),title:y()}))}),default:M(y()).optional()}),f$=Y([l$,d$]),p$=Y([c$,u$,f$]),m$=Y([p$,n$,o$,s$]),h$=ln.extend({mode:z("form").optional(),message:y(),requestedSchema:S({type:z("object"),properties:K(y(),m$),required:M(y()).optional()})}),g$=ln.extend({mode:z("url"),message:y(),elicitationId:y(),url:y().url()}),y$=Y([h$,g$]),_$=de.extend({method:z("elicitation/create"),params:y$}),w$=De.extend({elicitationId:y()}),b$=Ze.extend({method:z("notifications/elicitation/complete"),params:w$}),br=fe.extend({action:ke(["accept","decline","cancel"]),content:Sa(e=>e===null?void 0:e,K(y(),Y([y(),H(),ue(),M(y())])).optional())}),v$=S({type:z("ref/resource"),uri:y()});var $$=S({type:z("ref/prompt"),name:y()}),x$=Ne.extend({ref:Y([$$,v$]),argument:S({name:y(),value:y()}),context:S({arguments:K(y(),y()).optional()}).optional()}),S$=de.extend({method:z("completion/complete"),params:x$});var k$=fe.extend({completion:ve({values:M(y()).max(100),total:te(H().int()),hasMore:te(ue())})}),z$=S({uri:y().startsWith("file://"),name:y().optional(),_meta:K(y(),ee()).optional()}),P$=de.extend({method:z("roots/list"),params:Ne.optional()}),La=fe.extend({roots:M(z$)}),E$=Ze.extend({method:z("notifications/roots/list_changed"),params:De.optional()}),BR=Y([ts,Oa,S$,qa,C0,O0,h0,y0,b0,S0,z0,_n,Ma,ns,ss,is,cs]),JR=Y([es,rs,Ra,E$,gn]),KR=Y([Qo,bn,Fa,br,La,os,as,_r]),GR=Y([ts,r$,_$,P$,ns,ss,is,cs]),WR=Y([es,rs,K0,E0,$0,H0,q0,gn,b$]),YR=Y([Qo,c0,k$,M0,R0,g0,_0,v0,us,U0,os,as,_r]),T=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===A.UrlElicitationRequired&&n){let o=n;if(o.elicitations)return new ka(o.elicitations,r)}return new e(t,r,n)}},ka=class extends T{constructor(t,r=`URL elicitation${t.length>1?"s":""} required`){super(A.UrlElicitationRequired,r,{elicitations:t})}get elicitations(){return this.data?.elicitations??[]}};var I$=10*1024*1024,ls=class{constructor(t){this._maxBufferSize=t?.maxBufferSize??I$}append(t){if((this._buffer?.length??0)+t.length>this._maxBufferSize)throw this.clear(),new Error(`ReadBuffer exceeded maximum size of ${this._maxBufferSize} bytes`);this._buffer=this._buffer?Buffer.concat([this._buffer,t]):t}readMessage(){if(!this._buffer)return null;let t=this._buffer.indexOf(`
|
|
67
|
-
`);if(t===-1)return null;let r=this._buffer.toString("utf8",0,t).replace(/\r$/,"");return this._buffer=this._buffer.subarray(t+1),
|
|
68
|
-
`}var
|
|
69
|
-
`,"utf8"),ah(r,e),gs(e)}var ws=class{dir;itemsDir;imagesDir;palaceFile;palace={value:Ua(),stamp:"",broken:!1};items=new Map;rev=1;constructor(t,{create:r=!0}={}){this.dir=t,this.itemsDir=ze(t,"items"),this.imagesDir=ze(t,"images"),this.palaceFile=ze(t,"palace.json"),r&&(ms(this.itemsDir,{recursive:!0}),ms(this.imagesDir,{recursive:!0}));let n=this.refreshPalace();if(!r&&(n.stamp===""||n.broken))throw new b(`\u65E0\u6CD5\u8BFB\u53D6 ${this.palaceFile}`)}refreshPalace(){if(!vr(this.palaceFile))return this.palace.stamp!==""&&(this.palace={value:Ua(),stamp:"",broken:!1},this.rev+=1),this.palace;let t=gs(this.palaceFile);if(t===this.palace.stamp)return this.palace;let r=this.palace.schema;try{let n=JSON.parse(sh(this.palaceFile,"utf8"));r=_s(n),this.palace={value:M$(n),stamp:t,broken:!1,schema:r}}catch(n){console.warn("[dsh-palace] palace.json \u89E3\u6790\u5931\u8D25\uFF0C\u7EE7\u7EED\u4F7F\u7528\u5185\u5B58\u4E2D\u7684\u6570\u636E",n),this.palace={...this.palace,stamp:t,broken:!0,schema:r}}return this.rev+=1,this.palace}refreshItem(t){St(t);let r=ze(this.itemsDir,`${t}.json`),n=this.items.get(t);if(!vr(r))return n!==void 0&&(this.items.delete(t),this.rev+=1),{value:Ft(t),stamp:"",broken:!1};let o=gs(r);if(n!==void 0&&n.stamp===o)return n;let s,i=n?.schema;try{let a=JSON.parse(sh(r,"utf8"));i=_s(a),s={value:q$(a,t),stamp:o,broken:!1,schema:i}}catch(a){console.warn(`[dsh-palace] items/${t}.json \u89E3\u6790\u5931\u8D25`,a),s={value:n?.value??Ft(t),stamp:o,broken:!0,schema:i}}return n!==void 0&&(this.rev+=1),this.items.set(t,s),s}getPalace(){return this.refreshPalace().value}getItem(t){return this.refreshItem(t).value}checkDisk(){for(let t of this.getPalace().cells)t.kind!=="group"&&this.refreshItem(t.id);return this.rev}summaries(){let t={};for(let r of this.getPalace().cells)r.kind!=="group"&&(t[r.id]=rh(this.getItem(r.id)));return t}snapshotBeforeWrite(){let t=".snapshots",r=ze(this.dir,t),n=ze(r,vn());try{let o=C$(r,{throwIfNoEntry:!1});if(o&&!o.isDirectory())throw new Error("\u5FEB\u7167\u8DEF\u5F84\u4E0D\u662F\u666E\u901A\u76EE\u5F55");if(vr(n))return;ms(r,{recursive:!0});let s=N$(ze(r,".partial-"));try{for(let a of oh(this.dir))a!==t&&A$(ze(this.dir,a),ze(s,a),{recursive:!0,verbatimSymlinks:!0});vr(n)||ah(s,n)}finally{hs(s,{recursive:!0,force:!0})}let i=oh(r,{withFileTypes:!0}).filter(a=>a.isDirectory()&&/^\d{4}-\d{2}-\d{2}$/.test(a.name)).map(a=>a.name);for(let a of i.sort().slice(0,-3))hs(ze(r,a),{recursive:!0,force:!0})}catch(o){console.warn("[dsh-palace] \u6BCF\u65E5\u5FEB\u7167\u5931\u8D25\uFF0C\u7EE7\u7EED\u5199\u5165",o)}}assertWritable(){let t=this.refreshPalace();this.assertSupportedSchema(t,"palace.json");for(let r of t.value.cells)r.kind==="group"||!ch.test(r.id)||this.assertSupportedSchema(this.refreshItem(r.id),`items/${r.id}.json`)}assertSupportedSchema(t,r){if((t.schema??2)>2)throw new b(`${r} \u7684\u6570\u636E\u7248\u672C\u8F83\u65B0\uFF0C\u8BF7\u5347\u7EA7\u63D2\u4EF6`)}mutate(t){try{return Promise.resolve(this.commit(t))}catch(r){return Promise.reject(r)}}commit(t){this.assertWritable();let r=this.palace;if(r.broken)throw new b("palace.json \u683C\u5F0F\u6709\u8BEF\uFF1A\u8BF7\u5148\u4FEE\u597D\u6216\u5220\u6389\u8FD9\u4E2A\u6587\u4EF6\uFF0C\u518D\u7EE7\u7EED\u64CD\u4F5C");let n=structuredClone(r.value),o=new Map,s=[],a=t({palace:n,item:f=>{let p=o.get(f);if(p!==void 0){if(p.item===null)throw new b("\u683C\u5B50\u5DF2\u5220\u9664");return p.item}let m=this.refreshItem(f);if(this.assertSupportedSchema(m,`items/${f}.json`),m.broken)throw new b(`items/${f}.json \u683C\u5F0F\u6709\u8BEF\uFF1A\u8BF7\u5148\u4FEE\u597D\u6216\u5220\u6389\u8FD9\u4E2A\u6587\u4EF6`);let h=structuredClone(m.value);return o.set(f,{item:h,before:JSON.stringify(m.value),stamp:m.stamp}),h},createItem:f=>{this.assertSupportedSchema(this.refreshItem(f.id),`items/${f.id}.json`),o.set(f.id,{item:f,before:"",stamp:""})},deleteItem:f=>{this.assertSupportedSchema(this.refreshItem(f),`items/${f}.json`),o.set(f,{item:null,before:"",stamp:""})},deleteImage:f=>{s.push(f)}});if(a instanceof Promise)throw new Error("mutate \u7684\u56DE\u8C03\u5FC5\u987B\u662F\u540C\u6B65\u7684");let c=JSON.stringify(n)!==JSON.stringify(r.value),u=[...o].filter(([,{item:f,before:p}])=>f===null||JSON.stringify(f)!==p);(c||u.length>0||s.length>0)&&this.snapshotBeforeWrite();let l=(f,p)=>(vr(f)?gs(f):"")!==p;if(l(this.palaceFile,r.stamp))throw new b("palace.json \u521A\u88AB\u5176\u4ED6\u7A0B\u5E8F\u4FEE\u6539\u8FC7\uFF0C\u8BF7\u91CD\u8BD5");for(let[f,p]of o)if(p.before!==""&&l(ze(this.itemsDir,`${f}.json`),p.stamp))throw new b(`items/${f}.json \u521A\u88AB\u5176\u4ED6\u7A0B\u5E8F\u4FEE\u6539\u8FC7\uFF0C\u8BF7\u91CD\u8BD5`);for(let[f,{item:p}]of u){if(p===null)continue;vr(this.itemsDir)||ms(this.itemsDir,{recursive:!0});let m=ih(ze(this.itemsDir,`${f}.json`),p);this.items.set(f,{value:p,stamp:m,broken:!1})}if(c){let f=ih(this.palaceFile,n);this.palace={value:n,stamp:f,broken:!1}}this.rev+=1;let d=(f,p)=>{try{p()}catch(m){console.warn(`[dsh-palace] \u6E05\u7406 ${f} \u5931\u8D25\uFF0C\u5DF2\u5FFD\u7565`,m)}};for(let[f,{item:p}]of o)p===null&&(this.items.delete(f),d(`items/${f}.json`,()=>hs(ze(this.itemsDir,`${f}.json`),{force:!0})));for(let f of s)/^[\w.-]+$/.test(f)&&d(`images/${f}`,()=>hs(ze(this.imagesDir,f),{force:!0}));return a}};function kt(e,t){if(typeof e!="string"||e.trim()==="")throw new b(`${t}\u4E0D\u80FD\u4E3A\u7A7A`);return e.trim()}function $n(e,t){if(e!=null){if(typeof e!="string")throw new b(`${t}\u5E94\u4E3A\u6587\u5B57`);return e.trim()===""?void 0:e.trim()}}function Va(e,t){if(!(e==null||e==="")){if(!nh(e))throw new b(`${t}\u683C\u5F0F\u5E94\u4E3A YYYY-MM-DD`);return e}}function bs(e,t){if(!Number.isSafeInteger(e))throw new b(`${t}\u5E94\u4E3A\u6574\u6570`);return e}function xn(e,t,r,n){n?delete e[t]:r!==void 0&&(e[t]=r)}function Ut(e){return e===null||e===""}function Vt(e,t){St(t);let r=e.cells.find(n=>n.id===t);if(r===void 0)throw new b("\u683C\u5B50\u4E0D\u5B58\u5728");return r}function Fe(e,t){let r=Vt(e.palace,t);if(r.kind==="group")throw new b("\u5206\u7EC4\u6CA1\u6709\u7B14\u8BB0\u672C");return e.item(r.id)}function F$(e){let t=e;if(t?.type==="pdf"&&typeof t.path=="string"&&Number.isSafeInteger(t.pageCount))return{type:"pdf",path:t.path,pageCount:t.pageCount};if(t?.type==="epub"&&typeof t.path=="string")return{type:"epub",path:t.path};if(t?.type==="video"&&typeof t.url=="string")return{type:"video",url:t.url};throw new b("\u539F\u6587\u4FE1\u606F\u65E0\u6548")}function Ha(e,t,r,n){return e.cells.find(o=>o.parentId===t&&o.col===r&&o.row===n)}function Ba(e,t){let r=e.cells.filter(o=>o.parentId===t).length,n=t===null?3:Math.max(2,Math.ceil(Math.sqrt(r+1)));for(let o=0;;o++){let s=o%n,i=Math.floor(o/n);if(Ha(e,t,s,i)===void 0)return{col:s,row:i}}}function uh(e,t,r){if(t==null)return null;let n=Vt(e,t);if(n.kind!=="group")throw new b("\u53EA\u80FD\u653E\u8FDB\u5206\u7EC4\u91CC");if(r==="group")throw new b("\u5206\u7EC4\u91CC\u4E0D\u80FD\u518D\u653E\u5206\u7EC4");return n.id}function lh(e,t,r){if(e!==null&&(t<0||r<0))throw new b("\u5206\u7EC4\u91CC\u7684\u5750\u6807\u4E0D\u80FD\u4E3A\u8D1F")}function Ja(e,t){t===null||e.cells.some(r=>r.parentId===t)||(e.cells=e.cells.filter(r=>r.id!==t))}var Ka="https://dsh-palace.pages.dev";async function dh(e){return e.mutate(t=>{let r={id:Me("c"),kind:"note",parentId:null,...Ba(t.palace,null),title:"Memory Palace \u2197",subtitle:"\u4EC0\u4E48\u662F",icon:"open-book",href:Ka,createdAt:qe()};return t.palace.cells.push(r),t.createItem(Ft(r.id,null)),r})}async function zt(e,t){let r=t.kind;if(r!=="book"&&r!=="note"&&r!=="group")throw new b("\u683C\u5B50\u7C7B\u578B\u5E94\u4E3A book / note / group");let n=kt(t.title,"\u6807\u9898"),o=$n(t.subtitle,"\u5907\u6CE8"),s=r==="book"?F$(t.source):null,i=Va(t.targetDate,"\u76EE\u6807\u65E5\u671F");return e.mutate(a=>{let c=uh(a.palace,t.parentId,r),u;if(t.col===void 0&&t.row===void 0)u=Ba(a.palace,c);else if(u={col:bs(t.col,"\u5217"),row:bs(t.row,"\u884C")},lh(c,u.col,u.row),Ha(a.palace,c,u.col,u.row)!==void 0)throw new b("\u8FD9\u4E2A\u4F4D\u7F6E\u5DF2\u7ECF\u6709\u683C\u5B50\u4E86");let l={id:Me("c"),kind:r,parentId:c,...u,title:n,...o?{subtitle:o}:{},createdAt:qe()};if(a.palace.cells.push(l),r!=="group"){let d=Ft(l.id,s);i!==void 0&&(d.targetDate=i),r==="book"&&t.outline!==void 0&&(d.chapters=gh(t.outline),d.chapters.length>0&&t.outlineSource!==void 0&&(d.outlineSource=t.outlineSource)),a.createItem(d)}return l})}async function fh(e,t){let r=t.title===void 0?void 0:kt(t.title,"\u6807\u9898"),n=$n(t.subtitle,"\u5907\u6CE8"),o=$n(t.icon,"\u56FE\u6807");if(o!==void 0&&!/^[a-z][a-z0-9-]{0,30}$/.test(o))throw new b("\u56FE\u6807\u540D\u65E0\u6548");return e.mutate(s=>{let i=Vt(s.palace,t.id);return r!==void 0&&(i.title=r),xn(i,"subtitle",n,Ut(t.subtitle)),xn(i,"icon",o,Ut(t.icon)),i})}async function ph(e,t){let r=t.col===void 0&&t.row===void 0,n=r?0:bs(t.col,"\u5217"),o=r?0:bs(t.row,"\u884C");return e.mutate(s=>{let i=Vt(s.palace,t.id),a=uh(s.palace,t.parentId,i.kind);if(a===i.id)throw new b("\u4E0D\u80FD\u653E\u8FDB\u81EA\u5DF1\u91CC\u9762");if(r){if(i.parentId===a)return i;({col:n,row:o}=Ba(s.palace,a))}lh(a,n,o);let c=[i.parentId],u=Ha(s.palace,a,n,o);if(u!==void 0&&u.id!==i.id){if(c.push(u.parentId),u.kind==="group"&&i.parentId!==null)throw new b("\u5206\u7EC4\u4E0D\u80FD\u6362\u8FDB\u53E6\u4E00\u4E2A\u5206\u7EC4\u91CC");u.parentId=i.parentId,u.col=i.col,u.row=i.row}i.parentId=a,i.col=n,i.row=o;for(let l of c)Ja(s.palace,l);return i})}async function mh(e,t){let r=t.title===void 0?"\u65B0\u5206\u7EC4":kt(t.title,"\u6807\u9898");return e.mutate(n=>{let o=Vt(n.palace,t.id),s=Vt(n.palace,t.ontoId);if(o.id===s.id)throw new b("\u4E0D\u80FD\u548C\u81EA\u5DF1\u7EC4\u6210\u5206\u7EC4");if(o.kind==="group"||s.kind==="group")throw new b("\u5206\u7EC4\u4E0D\u80FD\u518D\u653E\u8FDB\u5206\u7EC4");if(s.parentId!==null)throw new b("\u53EA\u80FD\u5728\u6700\u5916\u5C42\u62D6\u6210\u5206\u7EC4");let i={id:Me("c"),kind:"group",parentId:null,col:s.col,row:s.row,title:r,createdAt:qe()};n.palace.cells.push(i),s.parentId=i.id,s.col=0,s.row=0;let a=o.parentId;return o.parentId=i.id,o.col=1,o.row=0,Ja(n.palace,a),i})}async function vs(e,t){return e.mutate(r=>{let n=Vt(r.palace,t.id);if(n.kind==="group"){if(r.palace.cells.some(o=>o.parentId===n.id))throw new b("\u5206\u7EC4\u91CC\u8FD8\u6709\u683C\u5B50\uFF0C\u5148\u79FB\u51FA\u53BB\u6216\u5220\u6389")}else{for(let o of r.item(n.id).cards)o.image&&r.deleteImage(o.image);r.deleteItem(n.id)}r.palace.cells=r.palace.cells.filter(o=>o.id!==n.id),Ja(r.palace,n.parentId)})}async function $s(e,t){let r=Va(t.targetDate,"\u76EE\u6807\u65E5\u671F"),n=Va(t.finishedAt,"\u8BFB\u5B8C\u65E5\u671F");return e.mutate(o=>{let s=Fe(o,t.id);return xn(s,"targetDate",r,Ut(t.targetDate)),xn(s,"finishedAt",n,Ut(t.finishedAt)),s})}async function hh(e,t){let r=kt(t.loc,"\u4F4D\u7F6E"),n=t.percent;if(typeof n!="number"||!(n>=0&&n<=1))throw new b("percent \u5E94\u4E3A 0\u20131 \u7684\u5C0F\u6570");return e.mutate(o=>{Fe(o,t.id).position={loc:r,percent:n}})}function gh(e,t=[]){let r=new Map;for(let o of t)for(let s of o.sections)s.done&&r.set(`${o.title}\0${s.title}`,s);let n=o=>typeof o=="string"&&o!==""?{loc:o}:{};return e.filter(o=>typeof o?.title=="string"&&o.title.trim()!=="").map(o=>{let s=o.title.trim(),i=(o.sections??[]).map(c=>typeof c=="string"?{title:c}:c).filter(c=>typeof c?.title=="string"&&c.title.trim()!==""),a=(i.length>0?i:[{title:s,loc:o.loc}]).map(c=>{let u=c.title.trim(),l=r.get(`${s}\0${u}`);return{id:Me("s"),title:u,...n(c.loc),done:l!==void 0,...l?.doneAt!==void 0?{doneAt:l.doneAt}:{}}});return{id:Me("ch"),title:s,sections:a}})}async function xs(e,t){if(!Array.isArray(t.chapters)||t.chapters.length===0)throw new b("\u76EE\u5F55\u4E0D\u80FD\u4E3A\u7A7A");let r=t.chapters;return e.mutate(n=>{let o=Fe(n,t.id),s=(u,l)=>`${u.title}\0${l.title}`,i=new Map;for(let u of o.chapters)for(let l of u.sections)i.set(l.id,s(u,l));let a=gh(r,o.chapters);if(a.length===0)throw new b("\u76EE\u5F55\u4E0D\u80FD\u4E3A\u7A7A");o.chapters=a;let c=new Map;for(let u of o.chapters)for(let l of u.sections)c.has(s(u,l))||c.set(s(u,l),l.id);for(let u of o.cards){if(u.sectionId===void 0)continue;let l=c.get(i.get(u.sectionId)??"");l!==void 0?u.sectionId=l:delete u.sectionId}return t.source!==void 0&&(o.outlineSource=t.source),o})}async function yh(e,t){return e.mutate(r=>{let n=xt(Fe(r,t.id),t.sectionId);if(n===void 0)throw new b("\u8282\u4E0D\u5B58\u5728");n.section.done=t.done===!0,n.section.done?n.section.doneAt=qe():delete n.section.doneAt})}async function _h(e,t){return e.mutate(r=>{let n=Fe(r,t.id);if(xt(n,t.sectionId)===void 0)throw new b("\u8282\u4E0D\u5B58\u5728");let o=!0,s=qe();for(let i of n.chapters)for(let a of i.sections)o&&!a.done&&(a.done=!0,a.doneAt=s),!o&&a.done&&(a.done=!1,delete a.doneAt),a.id===t.sectionId&&(o=!1)})}async function wh(e,t){return e.mutate(r=>{for(let n of Fe(r,t.id).chapters)for(let o of n.sections)o.done=!1,delete o.doneAt})}var L$=new Set(["excerpt","thought","mistake"]);function bh(e,t,r){for(let n of e.palace.cells)if(n.kind!=="group"&&e.item(n.id).cards.some(o=>o.image===t&&o.id!==r))throw new b("\u8FD9\u5F20\u56FE\u7247\u5DF2\u7ECF\u5C5E\u4E8E\u53E6\u4E00\u5F20\u5361\u7247")}function vh(e){if(e.type==="thought"&&e.note===void 0)throw new b("\u60F3\u6CD5\u4E0D\u80FD\u4E3A\u7A7A");if(e.type!=="thought"&&e.quote===void 0&&e.image===void 0)throw new b("\u6458\u5F55\u548C\u9519\u9898\u9700\u8981\u539F\u6587\u6216\u56FE\u7247")}function $h(e,t,r){if(t.sectionId!==void 0&&!Ut(t.sectionId)&&xt(e,t.sectionId)===void 0)throw new b("\u8282\u4E0D\u5B58\u5728");if(t.status!==void 0&&t.status!=="todo"&&t.status!=="mastered")throw new b("\u72B6\u6001\u5E94\u4E3A todo / mastered");if(t.image!==void 0&&!Ut(t.image)&&(typeof t.image!="string"||!/^[\w.-]+$/.test(t.image)))throw new b("\u56FE\u7247\u6587\u4EF6\u540D\u65E0\u6548");for(let n of["sectionId","loc","quote","note","answer","image"])xn(r,n,$n(t[n],n),Ut(t[n]));if(t.status!==void 0&&(r.status=t.status),t.share!==void 0)if(t.share===null)delete r.share;else{if(typeof t.share!="object"||Array.isArray(t.share))throw new b("\u5206\u4EAB\u8349\u7A3F\u683C\u5F0F\u4E0D\u5BF9");if(JSON.stringify(t.share).length>64*1024)throw new b("\u5206\u4EAB\u8349\u7A3F\u592A\u5927");r.share=t.share}}async function Ss(e,t){let r=t.type;if(!L$.has(r))throw new b("\u5361\u7247\u7C7B\u578B\u5E94\u4E3A excerpt / thought / mistake");return e.mutate(n=>{let o=Fe(n,t.id),s={id:Me("k"),type:r,createdAt:qe()};return $h(o,t,s),r==="mistake"&&s.status===void 0&&(s.status="todo"),vh(s),s.image!==void 0&&bh(n,s.image,s.id),o.cards.push(s),s})}async function xh(e,t){return e.mutate(r=>{let n=Fe(r,t.id),o=n.cards.find(i=>i.id===t.cardId);if(o===void 0)throw new b("\u5361\u7247\u4E0D\u5B58\u5728");if(t.type!==void 0)throw new b("\u5361\u7247\u7C7B\u578B\u4E0D\u80FD\u4FEE\u6539");let s=o.image;return $h(n,t,o),vh(o),o.image!==void 0&&o.image!==s&&bh(r,o.image,o.id),s!==void 0&&s!==o.image&&r.deleteImage(s),o})}async function Sh(e,t){return e.mutate(r=>{let n=Fe(r,t.id),o=n.cards.find(s=>s.id===t.cardId);if(o===void 0)throw new b("\u5361\u7247\u4E0D\u5B58\u5728");o.image&&r.deleteImage(o.image),n.cards=n.cards.filter(s=>s.id!==o.id);for(let s of n.inspirations)s.cardIds&&(s.cardIds=s.cardIds.filter(i=>i!==o.id))})}async function ks(e,t){let r=kt(t.title,"\u7075\u611F\u6807\u9898"),n=kt(t.body,"\u7075\u611F\u6B63\u6587"),o=$n(t.sessionId,"sessionId");return e.mutate(s=>{let i=Fe(s,t.id),a=Array.isArray(t.cardIds)?t.cardIds.filter(u=>i.cards.some(l=>l.id===u)):[],c={id:Me("i"),title:r,body:n,...o?{sessionId:o}:{},...a.length?{cardIds:a}:{},createdAt:qe()};return i.inspirations.push(c),c})}async function kh(e,t){let r=t.title===void 0?void 0:kt(t.title,"\u7075\u611F\u6807\u9898"),n=t.body===void 0?void 0:kt(t.body,"\u7075\u611F\u6B63\u6587");return e.mutate(o=>{let s=Fe(o,t.id).inspirations.find(i=>i.id===t.inspirationId);if(s===void 0)throw new b("\u7075\u611F\u4E0D\u5B58\u5728");return r!==void 0&&(s.title=r),n!==void 0&&(s.body=n),s})}async function zh(e,t){return e.mutate(r=>{let n=Fe(r,t.id);if(!n.inspirations.some(o=>o.id===t.inspirationId))throw new b("\u7075\u611F\u4E0D\u5B58\u5728");n.inspirations=n.inspirations.filter(o=>o.id!==t.inspirationId)})}import{isAbsolute as jI}from"node:path";function zs(e){return!!e._zod}function Pt(e,t){return zs(e)?Mi(e,t):e.safeParse(t)}function Ps(e){if(!e)return;let t;if(zs(e)?t=e._zod?.def?.shape:t=e.shape,!!t){if(typeof t=="function")try{return t()}catch{return}return t}}function Es(e){if(zs(e)){let s=e._zod?.def;if(s){if(s.value!==void 0)return s.value;if(Array.isArray(s.values)&&s.values.length>0)return s.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}function Et(e){return e==="completed"||e==="failed"||e==="cancelled"}var oA=new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");function Wa(e){let r=Ps(e)?.method;if(!r)throw new Error("Schema is missing a method literal");let n=Es(r);if(typeof n!="string")throw new Error("Schema method literal must be a string");return n}function Ya(e,t){let r=Pt(e,t);if(!r.success)throw r.error;return r.data}var G$=6e4,Is=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(es,r=>{this._oncancel(r)}),this.setNotificationHandler(rs,r=>{this._onprogress(r)}),this.setRequestHandler(ts,r=>({})),this._taskStore=t?.taskStore,this._taskMessageQueue=t?.taskMessageQueue,this._taskStore&&(this.setRequestHandler(ns,async(r,n)=>{let o=await this._taskStore.getTask(r.params.taskId,n.sessionId);if(!o)throw new T(A.InvalidParams,"Failed to retrieve task: Task not found");return{...o}}),this.setRequestHandler(ss,async(r,n)=>{let o=async()=>{let s=r.params.taskId;if(!await this._taskStore.getTask(s,n.sessionId))throw new T(A.InvalidParams,`Task not found: ${s}`);if(this._taskMessageQueue){let a;for(;a=await this._taskMessageQueue.dequeue(s,n.sessionId);){if(a.type==="response"||a.type==="error"){let c=a.message,u=c.id,l=this._requestResolvers.get(u);if(l)if(this._requestResolvers.delete(u),a.type==="response")l(c);else{let d=c,f=new T(d.error.code,d.error.message,d.error.data);l(f)}else{let d=a.type==="response"?"Response":"Error";this._onerror(new Error(`${d} handler missing for request ${u}`))}continue}await this._transport?.send(a.message,{relatedRequestId:n.requestId})}}let i=await this._taskStore.getTask(s,n.sessionId);if(!i)throw new T(A.InvalidParams,`Task not found: ${s}`);if(!Et(i.status))return await this._waitForTaskUpdate(s,n.signal,n.sessionId),await o();if(Et(i.status)){let a=await this._taskStore.getTaskResult(s,n.sessionId);return this._clearTaskQueue(s,n.sessionId),{...a,_meta:{...a._meta,[$t]:{taskId:s}}}}return await o()};return await o()}),this.setRequestHandler(is,async(r,n)=>{try{let{tasks:o,nextCursor:s}=await this._taskStore.listTasks(r.params?.cursor,n.sessionId);return{tasks:o,nextCursor:s,_meta:{}}}catch(o){throw new T(A.InvalidParams,`Failed to list tasks: ${o instanceof Error?o.message:String(o)}`)}}),this.setRequestHandler(cs,async(r,n)=>{try{let o=await this._taskStore.getTask(r.params.taskId,n.sessionId);if(!o)throw new T(A.InvalidParams,`Task not found: ${r.params.taskId}`);if(Et(o.status))throw new T(A.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,n.sessionId);let s=await this._taskStore.getTask(r.params.taskId,n.sessionId);if(!s)throw new T(A.InvalidParams,`Task not found after cancellation: ${r.params.taskId}`);return{_meta:{},...s}}catch(o){throw o instanceof T?o:new T(A.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,s=!1){this._timeoutInfo.set(t,{timeoutId:setTimeout(o,r),startTime:Date.now(),timeout:r,maxTotalTimeout:n,resetTimeoutOnProgress:s,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),T.fromError(A.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){if(this._transport)throw new Error("Already connected to a transport. Call close() before connecting to a new transport, or use a separate Protocol instance per connection.");this._transport=t;let r=this.transport?.onclose;this._transport.onclose=()=>{r?.(),this._onclose()};let n=this.transport?.onerror;this._transport.onerror=s=>{n?.(s),this._onerror(s)};let o=this._transport?.onmessage;this._transport.onmessage=(s,i)=>{o?.(s,i),dn(s)||Um(s)?this._onresponse(s):Ea(s)?this._onrequest(s,i):Lm(s)?this._onnotification(s):this._onerror(new Error(`Unknown message type: ${JSON.stringify(s)}`))},await this._transport.start()}_onclose(){let t=this._responseHandlers;this._responseHandlers=new Map,this._progressHandlers.clear(),this._taskProgressTokens.clear(),this._pendingDebouncedNotifications.clear();for(let n of this._timeoutInfo.values())clearTimeout(n.timeoutId);this._timeoutInfo.clear();for(let n of this._requestHandlerAbortControllers.values())n.abort();this._requestHandlerAbortControllers.clear();let r=T.fromError(A.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,s=t.params?._meta?.[$t]?.taskId,i=o?.sessionId,a=this._taskStore,c=!0,u;if(s&&a&&this._taskMessageQueue&&i!==void 0&&(c=!1,u=(async()=>{if(!await a.getTask(s,i))throw new T(A.InvalidParams,`Task not found: ${s}`);c=!0})()),n===void 0){let m={jsonrpc:"2.0",id:t.id,error:{code:A.MethodNotFound,message:"Method not found"}};if(s&&u){let h={type:"error",message:m,timestamp:Date.now()};u.then(()=>this._enqueueTaskMessage(s,h,i),()=>o?.send(m)).catch(g=>this._onerror(new Error(`Failed to send an error response: ${g}`)))}else s&&this._taskMessageQueue?this._enqueueTaskMessage(s,{type:"error",message:m,timestamp:Date.now()},o?.sessionId).catch(h=>this._onerror(new Error(`Failed to enqueue error response: ${h}`))):o?.send(m).catch(h=>this._onerror(new Error(`Failed to send an error response: ${h}`)));return}let l=new AbortController;this._requestHandlerAbortControllers.set(t.id,l);let d=Mm(t.params)?t.params.task:void 0,f=this._taskStore?this.requestTaskStore(t,o?.sessionId):void 0,p={signal:l.signal,sessionId:o?.sessionId,_meta:t.params?._meta,sendNotification:async m=>{if(l.signal.aborted)return;let h={relatedRequestId:t.id};s&&(h.relatedTask={taskId:s}),await this.notification(m,h)},sendRequest:async(m,h,g)=>{if(l.signal.aborted)throw new T(A.ConnectionClosed,"Request was cancelled");let w={...g,relatedRequestId:t.id};s&&!w.relatedTask&&(w.relatedTask={taskId:s});let v=w.relatedTask?.taskId??s;return v&&f&&await f.updateTaskStatus(v,"input_required"),await this.request(m,h,w)},authInfo:r?.authInfo,requestId:t.id,requestInfo:r?.requestInfo,taskId:s,taskStore:f,taskRequestedTtl:d?.ttl,closeSSEStream:r?.closeSSEStream,closeStandaloneSSEStream:r?.closeStandaloneSSEStream};(u??Promise.resolve()).then(()=>{if(u&&l.signal.aborted)throw new T(A.ConnectionClosed,"Request was cancelled");d&&this.assertTaskHandlerCapability(t.method)}).then(()=>n(t,p)).then(async m=>{if(l.signal.aborted)return;let h={result:m,jsonrpc:"2.0",id:t.id};s&&this._taskMessageQueue?await this._enqueueTaskMessage(s,{type:"response",message:h,timestamp:Date.now()},o?.sessionId):await o?.send(h)},async m=>{if(l.signal.aborted)return;let h={jsonrpc:"2.0",id:t.id,error:{code:Number.isSafeInteger(m.code)?m.code:A.InternalError,message:m.message??"Internal error",...m.data!==void 0&&{data:m.data}}};s&&this._taskMessageQueue&&c?await this._enqueueTaskMessage(s,{type:"error",message:h,timestamp:Date.now()},o?.sessionId):await o?.send(h)}).catch(m=>this._onerror(new Error(`Failed to send response: ${m}`))).finally(()=>{this._requestHandlerAbortControllers.get(t.id)===l&&this._requestHandlerAbortControllers.delete(t.id)})}_onprogress(t){let{progressToken:r,...n}=t.params,o=Number(r),s=this._progressHandlers.get(o);if(!s){this._onerror(new Error(`Received a progress notification for an unknown token: ${JSON.stringify(t)}`));return}let i=this._responseHandlers.get(o),a=this._timeoutInfo.get(o);if(a&&i&&a.resetTimeoutOnProgress)try{this._resetTimeout(o)}catch(c){this._responseHandlers.delete(o),this._progressHandlers.delete(o),this._cleanupTimeout(o),i(c);return}s(n)}_onresponse(t){let r=Number(t.id),n=this._requestResolvers.get(r);if(n){if(this._requestResolvers.delete(r),dn(t))n(t);else{let i=new T(t.error.code,t.error.message,t.error.data);n(i)}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 s=!1;if(dn(t)&&t.result&&typeof t.result=="object"){let i=t.result;if(i.task&&typeof i.task=="object"){let a=i.task;typeof a.taskId=="string"&&(s=!0,this._taskProgressTokens.set(a.taskId,r))}}if(s||this._progressHandlers.delete(r),dn(t))o(t);else{let i=T.fromError(t.error.code,t.error.message,t.error.data);o(i)}}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(i){yield{type:"error",error:i instanceof T?i:new T(A.InternalError,String(i))}}return}let s;try{let i=await this.request(t,_r,n);if(i.task)s=i.task.taskId,yield{type:"taskCreated",task:i.task};else throw new T(A.InternalError,"Task creation did not return a task");for(;;){let a=await this.getTask({taskId:s},n);if(yield{type:"taskStatus",task:a},Et(a.status)){a.status==="completed"?yield{type:"result",result:await this.getTaskResult({taskId:s},r,n)}:a.status==="failed"?yield{type:"error",error:new T(A.InternalError,`Task ${s} failed`)}:a.status==="cancelled"&&(yield{type:"error",error:new T(A.InternalError,`Task ${s} was cancelled`)});return}if(a.status==="input_required"){yield{type:"result",result:await this.getTaskResult({taskId:s},r,n)};return}let c=a.pollInterval??this._options?.defaultTaskPollInterval??1e3;await new Promise(u=>setTimeout(u,c)),n?.signal?.throwIfAborted()}}catch(i){yield{type:"error",error:i instanceof T?i:new T(A.InternalError,String(i))}}}request(t,r,n){let{relatedRequestId:o,resumptionToken:s,onresumptiontoken:i,task:a,relatedTask:c}=n??{};return new Promise((u,l)=>{let d=v=>{l(v)};if(!this._transport){d(new Error("Not connected"));return}if(this._options?.enforceStrictCapabilities===!0)try{this.assertCapabilityForMethod(t.method),a&&this.assertTaskCapability(t.method)}catch(v){d(v);return}n?.signal?.throwIfAborted();let f=this._requestMessageId++,p={...t,jsonrpc:"2.0",id:f};n?.onprogress&&(this._progressHandlers.set(f,n.onprogress),p.params={...t.params,_meta:{...t.params?._meta||{},progressToken:f}}),a&&(p.params={...p.params,task:a}),c&&(p.params={...p.params,_meta:{...p.params?._meta||{},[$t]:c}});let m=v=>{this._responseHandlers.delete(f),this._progressHandlers.delete(f),this._cleanupTimeout(f),this._transport?.send({jsonrpc:"2.0",method:"notifications/cancelled",params:{requestId:f,reason:String(v)}},{relatedRequestId:o,resumptionToken:s,onresumptiontoken:i}).catch(O=>this._onerror(new Error(`Failed to send cancellation: ${O}`)));let $=v instanceof T?v:new T(A.RequestTimeout,String(v));l($)};this._responseHandlers.set(f,v=>{if(!n?.signal?.aborted){if(v instanceof Error)return l(v);try{let $=Pt(r,v.result);$.success?u($.data):l($.error)}catch($){l($)}}}),n?.signal?.addEventListener("abort",()=>{m(n?.signal?.reason)});let h=n?.timeout??G$,g=()=>m(T.fromError(A.RequestTimeout,"Request timed out",{timeout:h}));this._setupTimeout(f,h,n?.maxTotalTimeout,g,n?.resetTimeoutOnProgress??!1);let w=c?.taskId;if(w){let v=$=>{let O=this._responseHandlers.get(f);O?O($):this._onerror(new Error(`Response handler missing for side-channeled request ${f}`))};this._requestResolvers.set(f,v),this._enqueueTaskMessage(w,{type:"request",message:p,timestamp:Date.now()}).catch($=>{this._cleanupTimeout(f),l($)})}else this._transport.send(p,{relatedRequestId:o,resumptionToken:s,onresumptiontoken:i}).catch(v=>{this._cleanupTimeout(f),l(v)})})}async getTask(t,r){return this.request({method:"tasks/get",params:t},os,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},as,r)}async cancelTask(t,r){return this.request({method:"tasks/cancel",params:t},Bm,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 a={...t,jsonrpc:"2.0",params:{...t.params,_meta:{...t.params?._meta||{},[$t]:r.relatedTask}}};await this._enqueueTaskMessage(n,{type:"notification",message:a,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 a={...t,jsonrpc:"2.0"};r?.relatedTask&&(a={...a,params:{...a.params,_meta:{...a.params?._meta||{},[$t]:r.relatedTask}}}),this._transport?.send(a,r).catch(c=>this._onerror(c))});return}let i={...t,jsonrpc:"2.0"};r?.relatedTask&&(i={...i,params:{...i.params,_meta:{...i.params?._meta||{},[$t]:r.relatedTask}}}),await this._transport.send(i,r)}setRequestHandler(t,r){let n=Wa(t);this.assertRequestHandlerCapability(n),this._requestHandlers.set(n,(o,s)=>{let i=Ya(t,o);return Promise.resolve(r(i,s))})}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=Wa(t);this._notificationHandlers.set(n,o=>{let s=Ya(t,o);return Promise.resolve(r(s))})}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??this._transport?.sessionId,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"&&Ea(o.message)){let s=o.message.id,i=this._requestResolvers.get(s);i?(i(new T(A.InternalError,"Task cancelled or completed")),this._requestResolvers.delete(s)):this._onerror(new Error(`Resolver missing for request ${s} during task ${t} cleanup`))}}}async _waitForTaskUpdate(t,r,n){let o=this._options?.defaultTaskPollInterval??1e3;try{let s=await this._taskStore?.getTask(t,n);s?.pollInterval&&(o=s.pollInterval)}catch{}return new Promise((s,i)=>{if(r.aborted){i(new T(A.InvalidRequest,"Request cancelled"));return}let a=setTimeout(s,o);r.addEventListener("abort",()=>{clearTimeout(a),i(new T(A.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 s=await n.getTask(o,r);if(!s)throw new T(A.InvalidParams,"Failed to retrieve task: Task not found");return s},storeTaskResult:async(o,s,i)=>{await n.storeTaskResult(o,s,i,r);let a=await n.getTask(o,r);if(a){let c=gn.parse({method:"notifications/tasks/status",params:a});await this.notification(c),Et(a.status)&&this._cleanupTaskProgressHandler(o)}},getTaskResult:o=>n.getTaskResult(o,r),updateTaskStatus:async(o,s,i)=>{let a=await n.getTask(o,r);if(!a)throw new T(A.InvalidParams,`Task "${o}" not found - it may have been cleaned up`);if(Et(a.status))throw new T(A.InvalidParams,`Cannot update task "${o}" from terminal status "${a.status}" to "${s}". Terminal states (completed, failed, cancelled) cannot transition to other states.`);await n.updateTaskStatus(o,s,i,r);let c=await n.getTask(o,r);if(c){let u=gn.parse({method:"notifications/tasks/status",params:c});await this.notification(u),Et(c.status)&&this._cleanupTaskProgressHandler(o)}},listTasks:o=>n.listTasks(o,r)}}};function Ph(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function Eh(e,t){let r={...e};for(let n in t){let o=n,s=t[o];if(s===void 0)continue;let i=r[o];Ph(i)&&Ph(s)?r[o]={...i,...s}:r[o]=s}return r}var T_=ll(Lu(),1),O_=ll(I_(),1);function cI(){let e=new T_.default({strict:!1,validateFormats:!0,validateSchema:!1,allErrors:!0});return(0,O_.default)(e),e}var Mr=class{constructor(t){this._ajv=t??cI()}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 mi=class{constructor(t){this._server=t}requestStream(t,r,n){return this._server.requestStream(t,r,n)}createMessageStream(t,r){let n=this._server.getClientCapabilities();if((t.tools||t.toolChoice)&&!n?.sampling?.tools)throw new Error("Client does not support sampling tools capability.");if(t.messages.length>0){let o=t.messages[t.messages.length-1],s=Array.isArray(o.content)?o.content:[o.content],i=s.some(l=>l.type==="tool_result"),a=t.messages.length>1?t.messages[t.messages.length-2]:void 0,c=a?Array.isArray(a.content)?a.content:[a.content]:[],u=c.some(l=>l.type==="tool_use");if(i){if(s.some(l=>l.type!=="tool_result"))throw new Error("The last message must contain only tool_result content if any is present");if(!u)throw new Error("tool_result blocks are not matching any tool_use from the previous message")}if(u){let l=new Set(c.filter(f=>f.type==="tool_use").map(f=>f.id)),d=new Set(s.filter(f=>f.type==="tool_result").map(f=>f.toolUseId));if(l.size!==d.size||![...l].every(f=>d.has(f)))throw new Error("ids of tool_result blocks and tool_use blocks from previous message do not match")}}return this.requestStream({method:"sampling/createMessage",params:t},bn,r)}elicitInputStream(t,r){let n=this._server.getClientCapabilities(),o=t.mode??"form";switch(o){case"url":{if(!n?.elicitation?.url)throw new Error("Client does not support url elicitation.");break}case"form":{if(!n?.elicitation?.form)throw new Error("Client does not support form elicitation.");break}}let s=o==="form"&&t.mode===void 0?{...t,mode:"form"}:t;return this.requestStream({method:"elicitation/create",params:s},br,r)}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 R_(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 A_(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 hi=class extends Is{constructor(t,r){super(r),this._serverInfo=t,this._loggingLevels=new Map,this.LOG_LEVEL_SEVERITY=new Map(wn.options.map((n,o)=>[n,o])),this.isMessageIgnored=(n,o)=>{let s=this._loggingLevels.get(o);return s?this.LOG_LEVEL_SEVERITY.get(n)<this.LOG_LEVEL_SEVERITY.get(s):!1},this._capabilities=r?.capabilities??{},this._instructions=r?.instructions,this._jsonSchemaValidator=r?.jsonSchemaValidator??new Mr,this.setRequestHandler(Oa,n=>this._oninitialize(n)),this.setNotificationHandler(Ra,()=>this.oninitialized?.()),this._capabilities.logging&&this.setRequestHandler(qa,async(n,o)=>{let s=o.sessionId||o.requestInfo?.headers["mcp-session-id"]||void 0,{level:i}=n.params,a=wn.safeParse(i);return a.success&&this._loggingLevels.set(s,a.data),{}})}get experimental(){return this._experimental||(this._experimental={tasks:new mi(this)}),this._experimental}registerCapabilities(t){if(this.transport)throw new Error("Cannot register capabilities after connecting to transport");this._capabilities=Eh(this._capabilities,t)}setRequestHandler(t,r){let o=Ps(t)?.method;if(!o)throw new Error("Schema is missing a method literal");let s=Es(o);if(typeof s!="string")throw new Error("Schema method literal must be a string");if(s==="tools/call"){let a=async(c,u)=>{let l=Pt(_n,c);if(!l.success){let m=l.error instanceof Error?l.error.message:String(l.error);throw new T(A.InvalidParams,`Invalid tools/call request: ${m}`)}let{params:d}=l.data,f=await Promise.resolve(r(c,u));if(d.task){let m=Pt(_r,f);if(!m.success){let h=m.error instanceof Error?m.error.message:String(m.error);throw new T(A.InvalidParams,`Invalid task creation result: ${h}`)}return m.data}let p=Pt(us,f);if(!p.success){let m=p.error instanceof Error?p.error.message:String(p.error);throw new T(A.InvalidParams,`Invalid tools/call result: ${m}`)}return p.data};return super.setRequestHandler(t,a)}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){A_(this._clientCapabilities?.tasks?.requests,t,"Client")}assertTaskHandlerCapability(t){this._capabilities&&R_(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:jm.includes(r)?r:za,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"},Qo)}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],s=o.some(u=>u.type==="tool_result"),i=t.messages.length>1?t.messages[t.messages.length-2]:void 0,a=i?Array.isArray(i.content)?i.content:[i.content]:[],c=a.some(u=>u.type==="tool_use");if(s){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(a.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},Fa,r):this.request({method:"sampling/createMessage",params:t},bn,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},br,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"},s=await this.request({method:"elicitation/create",params:o},br,r);if(s.action==="accept"&&s.content&&o.requestedSchema)try{let a=this._jsonSchemaValidator.getValidator(o.requestedSchema)(s.content);if(!a.valid)throw new T(A.InvalidParams,`Elicitation response content does not match requested schema: ${a.errorMessage}`)}catch(i){throw i instanceof T?i:new T(A.InternalError,`Error validating elicitation response: ${i instanceof Error?i.message:String(i)}`)}return s}}}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},La,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"})}};import{appendFileSync as uI,existsSync as Wu,mkdirSync as lI,readFileSync as Yu,renameSync as dI,statSync as C_,writeFileSync as fI}from"node:fs";import{join as to}from"node:path";var no=500,N_=40,j_=40,D_=5,Xu=e=>[...e].length,nr=(e,t)=>e<t?`${e}|${t}`:`${t}|${e}`;function ro(e){let t=new Map;for(let r of e.cards)t.set(r.id,r.createdAt);for(let r of e.inspirations)t.set(r.id,r.createdAt);return t}function pI(e){let t=/^---\n([\s\S]*?)\n---\n?([\s\S]*)$/.exec(e);if(t===null)return{body:e.trim(),writtenAt:""};let r={};for(let o of t[1].split(`
|
|
70
|
-
`)){let s=o.indexOf(":");s>0&&(r[o.slice(0,s).trim()]=o.slice(s+1).trim())}let n;try{n=r.topics?JSON.parse(r.topics):void 0}catch{n=void 0}return{...r.summary?{summary:r.summary}:{},...Array.isArray(n)?{topics:n.filter(o=>typeof o=="string")}:{},body:t[2].trim(),writtenAt:r.writtenAt??""}}function
|
|
66
|
+
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let i of e.seen.entries()){let a=i[1];if(t===i[0]){s(i);continue}if(e.external){let u=e.external.registry.get(i[0])?.id;if(t!==i[0]&&u){s(i);continue}}if(e.metadataRegistry.get(i[0])?.id){s(i);continue}if(a.cycle){s(i);continue}a.count>1&&e.reused==="ref"&&s(i)}e.external&&(e.sharedDefsExtractedFor=e.external)}function jp(e){let t=e.anyOf;if(!Array.isArray(t)||t.length===0||e.type!==void 0)return;let r=[];for(let n of t){if(!n||typeof n!="object")return;jp(n);let o=Object.keys(n);if(o.length!==1||o[0]!=="type")return;let s=n.type;for(let i of Array.isArray(s)?s:[s]){if(typeof i!="string")return;r.includes(i)||r.push(i)}}delete e.anyOf,e.type=r.length===1?r[0]:r}var Dp=new Set(["type","properties","required","additionalProperties"]),Cp=["oneOf","anyOf"];function Np(e){let t=e.additionalProperties;return t===void 0||t===!1||typeof t!="object"||t===null?null:Object.keys(t).length?t:null}function va(e){let t=[];for(let s of e){if(typeof s!="object"||s.type!=="object")return null;for(let i in s)if(!Dp.has(i))return null;t.push(s)}let r={},n=new Set;for(let s of t){for(let i in s.properties){if(Object.prototype.hasOwnProperty.call(r,i))continue;let a=[];for(let u of t){let l=u.properties?.[i]??Np(u);l!=null&&(a.some(d=>JSON.stringify(d)===JSON.stringify(l))||a.push(l))}let c=a.length===1?a[0]:va(a)??{allOf:a};Le(r,i,c)}for(let i of s.required??[])n.add(i)}let o={type:"object",properties:r};if(n.size&&(o.required=[...n]),t.every(s=>s.additionalProperties===!1))o.additionalProperties=!1;else{let s=[];for(let i of t){let a=Np(i);a&&!s.some(c=>JSON.stringify(c)===JSON.stringify(a))&&s.push(a)}s.length===1?o.additionalProperties=s[0]:s.length>1&&(o.additionalProperties={allOf:s})}return o}function dv(e){let t=e.allOf;if(!Array.isArray(t)||t.length<2)return;for(let o of Dp)if(o in e)return;let r=t.filter(o=>Cp.some(s=>Array.isArray(o[s]))),n=null;if(!r.length)n=va(t);else{let o=r[0],s=Cp.find(c=>Array.isArray(o[c]));if(Object.keys(o).length!==1)return;let i=t.filter(c=>c!==o),a=o[s].map(c=>va([...i,c]));if(a.some(c=>!c))return;n={[s]:a}}n&&(delete e.allOf,cn(e,n))}function xa(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 c=e.seen.get(a);if(c.ref===null)return;let u=c.def??c.schema,l={...u},d=c.ref;if(c.ref=null,d){n(d);let p=e.seen.get(d),m=p.schema;if(m.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0")?(u.allOf=u.allOf??[],u.allOf.push(m)):cn(u,m),cn(u,l),a._zod.parent===d)for(let g in u)g==="$ref"||g==="allOf"||g in l||delete u[g];if(m.$ref&&p.def)for(let g in u)g==="$ref"||g==="allOf"||g in p.def&&JSON.stringify(u[g])===JSON.stringify(p.def[g])&&delete u[g]}let f=a._zod.parent;if(f&&f!==d){n(f);let p=e.seen.get(f);if(p?.schema.$ref&&(u.$ref=p.schema.$ref,p.def))for(let m in u)m==="$ref"||m==="allOf"||m in p.def&&JSON.stringify(u[m])===JSON.stringify(p.def[m])&&delete u[m]}e.override({zodSchema:a,jsonSchema:u,path:c.path??[]})};if(!e.external||e.sharedEmitDoneFor!==e.external){for(let a of[...e.seen.entries()].reverse())n(a[0]);if(e.target!=="openapi-3.0")for(let a of e.seen.entries())jp(a[1].def??a[1].schema);for(let a of e.deferred)a();if(e.intersections.length){let a=new Map;for(let c of e.seen.values())for(let u of[c.schema,c.def]){let l=u?.allOf;if(!Array.isArray(l))continue;let d=a.get(l);d?d.push(u):a.set(l,[u])}for(let c of e.intersections)for(let u of a.get(c)??[])dv(u)}}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)}cn(o,r.defId?r.schema:r.def??r.schema);let s=e.metadataRegistry.get(t)?.id;s!==void 0&&o.id===s&&delete o.id;let i=e.external?.defs??{};if(!e.external||e.sharedEmitDoneFor!==e.external)for(let a of e.seen.entries()){let c=a[1];c.def&&c.defId&&(c.def.id===c.defId&&delete c.def.id,Le(i,c.defId,c.def))}e.external&&(e.sharedEmitDoneFor=e.external),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:un(t,"input",e.processors),output:un(t,"output",e.processors)}},enumerable:!1,writable:!1}),a}catch{throw new Error("Error converting schema to JSON.")}}function Ee(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 Ee(n.element,r);if(n.type==="set")return Ee(n.valueType,r);if(n.type==="lazy")return Ee(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"||n.type==="catch")return Ee(n.innerType,r);if(n.type==="intersection")return Ee(n.left,r)||Ee(n.right,r);if(n.type==="record"||n.type==="map")return Ee(n.keyType,r)||Ee(n.valueType,r);if(n.type==="pipe")return e._zod.traits.has("$ZodCodec")?!0:Ee(n.in,r)||Ee(n.out,r);if(n.type==="object"){for(let o in n.shape)if(Ee(n.shape[o],r))return!0;return!1}if(n.type==="union"){for(let o of n.options)if(Ee(o,r))return!0;return!1}if(n.type==="tuple"){for(let o of n.items)if(Ee(o,r))return!0;return!!(n.rest&&Ee(n.rest,r))}return!1}var Zp=(e,t={})=>r=>{let n=$a({...r,processors:t});return fe(e,n),ka(n,e),xa(n,e)},un=(e,t,r={})=>n=>{let{libraryOptions:o,target:s}=n??{},i=$a({...o??{},target:s,io:t,processors:r});return fe(e,i),ka(i,e),xa(i,e)};var br=(e,t,r)=>{(e[t]===void 0||r>e[t])&&(e[t]=r)},vr=(e,t,r)=>{(e[t]===void 0||r<e[t])&&(e[t]=r)},Mp=(e,t)=>{br(e,"minimum",t),vr(e,"maximum",t)},Up=(e,t)=>{e.multipleOf??(e.multipleOf=[]),e.multipleOf.includes(t)||e.multipleOf.push(t)},Vp=(e,t)=>{e.patterns??(e.patterns=new Set),e.patterns.add(t)},Bp=(e,t)=>{e.mime=e.mime?e.mime.filter(r=>t.includes(r)):[...t]},Hp=(e,t)=>{e.format=t,t.includes("int")&&(e.isInt=!0)},qp=(e,t)=>br(e,"minimum",t.minimum),Fp=(e,t)=>vr(e,"maximum",t.maximum),Lp=e=>(t,r)=>{Hp(t,r.format);let[n,o]=e[r.format];br(t,"minimum",n),vr(t,"maximum",o)},fv={greater_than:(e,t)=>br(e,t.inclusive?"minimum":"exclusiveMinimum",t.value),less_than:(e,t)=>vr(e,t.inclusive?"maximum":"exclusiveMaximum",t.value),multiple_of:(e,t)=>Up(e,t.value),number_format:Lp(Gr),bigint_format:Lp(wo),min_length:qp,max_length:Fp,length_equals:(e,t)=>Mp(e,t.length),min_size:qp,max_size:Fp,size_equals:(e,t)=>Mp(e,t.size),string_format:(e,t)=>{Hp(e,t.format),t.pattern&&Vp(e,t.pattern),(t.format==="base64"||t.format==="base64url")&&(e.contentEncoding=t.format),(t.local||t.precision===-1)&&(e.laxFormat=!0)},mime_type:(e,t)=>Bp(e,t.mime)};function Ke(e){let t={},r=e._zod.def,n=e._zod.traits.has("$ZodCheck")?[e,...r.checks??[]]:r.checks??[];for(let s of n)fv[s._zod.def.check]?.(t,s._zod.def);let o=e._zod.bag;o.minimum!==void 0&&br(t,"minimum",o.minimum),o.exclusiveMinimum!==void 0&&br(t,"exclusiveMinimum",o.exclusiveMinimum),o.maximum!==void 0&&vr(t,"maximum",o.maximum),o.exclusiveMaximum!==void 0&&vr(t,"exclusiveMaximum",o.exclusiveMaximum),o.multipleOf!==void 0&&Up(t,o.multipleOf),o.format!==void 0&&(t.format??(t.format=o.format),o.format.includes("int")&&(t.isInt=!0)),o.mime&&Bp(t,o.mime);for(let s of o.patterns??[])Vp(t,s);return t}var pv={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},mv=new Map([[ta,dd],[No,fd]]),Kp=e=>mv.get(e)??e,Jp=(e,t,r,n)=>{let o=r;o.type="string";let{minimum:s,maximum:i,format:a,patterns:c,contentEncoding:u,laxFormat:l}=Ke(e);if(typeof s=="number"&&(o.minLength=s),typeof i=="number"&&(o.maxLength=i),a&&(o.format=pv[a]??a,o.format===""&&delete o.format,(a==="time"||l)&&delete o.format),u&&(o.contentEncoding=u),c&&c.size>0){let d=[...c].map(Kp);d.length===1?o.pattern=d[0].source:d.length>1&&(o.allOf=[...d.map(f=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:f.source}))])}},Gp=(e,t,r,n)=>{let o=r,{minimum:s,maximum:i,multipleOf:a,exclusiveMaximum:c,exclusiveMinimum:u,isInt:l}=Ke(e);o.type=l?"integer":"number";let d=typeof u=="number"&&u>=(s??Number.NEGATIVE_INFINITY),f=typeof c=="number"&&c<=(i??Number.POSITIVE_INFINITY),p=t.target==="draft-04"||t.target==="openapi-3.0";if(d?p?(o.minimum=u,o.exclusiveMinimum=!0):o.exclusiveMinimum=u:typeof s=="number"&&(o.minimum=s),f?p?(o.maximum=c,o.exclusiveMaximum=!0):o.exclusiveMaximum=c:typeof i=="number"&&(o.maximum=i),a){let m=new Set;for(let y of a)Number.isFinite(y)&&y!==0?m.add(Math.abs(y)):wt(e,t,o,n,`A multipleOf divisor of ${y} cannot be represented in JSON Schema`);let[h,...g]=m;h!==void 0&&(o.multipleOf=h),g.length&&(o.allOf=[...o.allOf??[],...g.map(y=>({multipleOf:y}))])}},Wp=(e,t,r,n)=>{r.type="boolean"};var Yp=(e,t,r,n)=>{t.target==="openapi-3.0"?(r.type="string",r.nullable=!0,r.enum=[null]):r.type="null"};var Xp=(e,t,r,n)=>{r.not={}};var Qp=(e,t,r,n)=>{};var em=(e,t,r,n)=>{let o=e._zod.def,s=pr(o.entries);if(s.length===0){r.not={};return}s.every(i=>typeof i=="number")&&(r.type="number"),s.every(i=>typeof i=="string")&&(r.type="string"),r.enum=s},tm=(e,t,r,n)=>{let o=e._zod.def;if(o.values.length===0){r.not={};return}let s=[];for(let i of o.values)if(i===void 0){if(wt(e,t,r,n,"Literal `undefined` cannot be represented in JSON Schema"))return}else if(typeof i=="bigint"){if(wt(e,t,r,n,"BigInt literals cannot be represented in JSON Schema"))return;s.push(Number(i))}else s.push(i);if(s.length!==0)if(s.length===1){let i=s[0];r.type=i===null?"null":typeof i,t.target==="draft-04"||t.target==="openapi-3.0"?r.enum=[i]:r.const=i}else s.every(i=>typeof i=="number")&&(r.type="number"),s.every(i=>typeof i=="string")&&(r.type="string"),s.every(i=>typeof i=="boolean")&&(r.type="boolean"),s.every(i=>i===null)&&(r.type="null"),r.enum=s};var rm=(e,t,r,n)=>{wt(e,t,r,n,"Custom types cannot be represented in JSON Schema")};var nm=(e,t,r,n)=>{wt(e,t,r,n,"Transforms cannot be represented in JSON Schema")};var om=(e,t,r,n)=>{let o=r,s=e._zod.def,{minimum:i,maximum:a}=Ke(e);typeof i=="number"&&(o.minItems=i),typeof a=="number"&&(o.maxItems=a),o.type="array",o.items=fe(s.element,t,{...n,path:[...n.path,"items"]})};function Go(e){let t=e._zod.def;return t.type==="pipe"&&t.in._zod.traits.has("$ZodTransform")?Go(t.out):t.type==="catch"?Go(t.innerType):e._zod.optin}var sm=(e,t,r,n)=>{let o=r,s=e._zod.def,i=s.shape;if(Object.getOwnPropertySymbols(i).length&&wt(e,t,o,n,"Symbol keys cannot be represented in JSON Schema"))return;o.type="object",o.properties={};for(let u in i)Le(o.properties,u,fe(i[u],t,{...n,path:[...n.path,"properties",u]}));let c=[];for(let u of Object.keys(i)){let l=s.shape[u];(t.io==="input"?Go(l)===void 0:l._zod.optout===void 0)&&c.push(u)}c.length>0&&(o.required=c),s.catchall?._zod.def.type==="never"?o.additionalProperties=!1:s.catchall?s.catchall&&(o.additionalProperties=fe(s.catchall,t,{...n,path:[...n.path,"additionalProperties"]})):t.io==="output"&&(o.additionalProperties=!1)},im=(e,t,r,n)=>{let o=e._zod.def,s=o.inclusive===!1,i=o.options.map((a,c)=>fe(a,t,{...n,path:[...n.path,s?"oneOf":"anyOf",c]}));s?r.oneOf=i:r.anyOf=i},am=(e,t,r,n)=>{let o=e._zod.def,s=fe(o.left,t,{...n,path:[...n.path,"allOf",0]}),i=fe(o.right,t,{...n,path:[...n.path,"allOf",1]}),a=u=>"allOf"in u&&Object.keys(u).length===1,c=[...a(s)?s.allOf:[s],...a(i)?i.allOf:[i]];r.allOf=c,t.intersections.push(c)};function Sa(e,t,r){if(t.$ref){if(r.has(t))return t;r.add(t);let m=e.get(t)?.def;if(!m)return t;let h=Sa(e,m,r);return h===m?t:h}for(let m of["anyOf","oneOf"]){let h=t[m];if(!Array.isArray(h))continue;let g=h.map(y=>Sa(e,y,r));g.some((y,v)=>y!==h[v])&&(t={...t,[m]:g})}let n=Array.isArray(t.type)?t.type:[t.type],o=!n.includes("string")&&n.some(m=>m==="number"||m==="integer"),s=t.enum??(t.const!==void 0?[t.const]:void 0);if(!o&&!s?.some(m=>typeof m=="number"))return t;let{minimum:i,maximum:a,exclusiveMinimum:c,exclusiveMaximum:u,multipleOf:l,format:d,id:f,...p}=t;return p.enum?p.enum=p.enum.map(m=>typeof m=="number"?String(m):m):typeof p.const=="number"&&(p.const=String(p.const)),o&&(p.type="string",s||(p.pattern=(n.includes("number")?en:Gi).source)),p}var za=new WeakMap;function hv(e){let t=new Map;for(let n of e.seen.values())n.def&&!t.has(n.schema)&&t.set(n.schema,n);let r=new Map;for(let n of za.get(e)??[]){let o=e.seen.get(n),s=(o?.def??o?.schema)?.propertyNames;if(!s||s===!0||r.has(s))continue;let i=Sa(t,s,new Set);i!==s&&r.set(s,i)}if(r.size)for(let n of e.seen.values())for(let o of[n.schema,n.def]){let s=o&&r.get(o.propertyNames);s&&(o.propertyNames=s)}}var cm=(e,t,r,n)=>{let o=r,s=e._zod.def;o.type="object";let i=s.keyType,a=Ke(i).patterns;if(s.mode==="loose"&&a&&a.size>0){let l=fe(s.valueType,t,{...n,path:[...n.path,"patternProperties","*"]});o.patternProperties={};for(let d of a)Le(o.patternProperties,Kp(d).source,l)}else{if(t.target==="draft-07"||t.target==="draft-2020-12"){o.propertyNames=fe(s.keyType,t,{...n,path:[...n.path,"propertyNames"]});let l=za.get(t);l||(l=[],za.set(t,l),t.deferred.push(()=>hv(t))),l.push(e)}o.additionalProperties=fe(s.valueType,t,{...n,path:[...n.path,"additionalProperties"]})}let c=i._zod.values,u=t.io==="input"&&Go(s.valueType)!==void 0;if(c&&!s.partial&&!u){let l=[...c].filter(d=>typeof d=="string"||typeof d=="number");l.length>0&&(o.required=l.map(String))}},um=(e,t,r,n)=>{let o=e._zod.def,s=fe(o.innerType,t,n),i=t.seen.get(e);t.target==="openapi-3.0"?(i.ref=o.innerType,r.nullable=!0):r.anyOf=[s,{type:"null"}]},lm=(e,t,r,n)=>{let o=e._zod.def;fe(o.innerType,t,n);let s=t.seen.get(e);s.ref=o.innerType},Pa=Symbol();function dm(e,t,r,n,o){let s=!1,i=JSON.stringify(e,(a,c)=>typeof c!="bigint"?c:(s=!0,null));return s?(wt(t,r,n,o,"BigInt defaults cannot be represented in JSON Schema"),Pa):JSON.parse(i)}var fm=(e,t,r,n)=>{let o=e._zod.def;fe(o.innerType,t,n);let s=t.seen.get(e);s.ref=o.innerType;let i=dm(o.defaultValue,e,t,r,n);i!==Pa&&(r.default=i)},pm=(e,t,r,n)=>{let o=e._zod.def;fe(o.innerType,t,n);let s=t.seen.get(e);if(s.ref=o.innerType,t.io!=="input")return;let i=dm(o.defaultValue,e,t,r,n);i!==Pa&&(r._prefault=i)},mm=(e,t,r,n)=>{let o=e._zod.def;fe(o.innerType,t,n);let s=t.seen.get(e);s.ref=o.innerType;let i;try{i=o.catchValue(void 0)}catch{wt(e,t,r,n,"Dynamic catch values are not supported in JSON Schema");return}r.default=i},hm=(e,t,r,n)=>{let o=e._zod.def,s=o.in._zod.traits.has("$ZodTransform"),i=t.io==="input"?s?o.out:o.in:o.out;fe(i,t,n);let a=t.seen.get(e);a.ref=i},gm=(e,t,r,n)=>{let o=e._zod.def;fe(o.innerType,t,n);let s=t.seen.get(e);s.ref=o.innerType,r.readOnly=!0};var Ia=(e,t,r,n)=>{let o=e._zod.def;fe(o.innerType,t,n);let s=t.seen.get(e);s.ref=o.innerType};var ym=new WeakSet([Object.prototype,Error.prototype]);function Wo(e,t,r){Object.defineProperty(e,t,{configurable:!0,enumerable:!1,get(){let n=r(this);return Object.defineProperty(this,t,{value:n,configurable:!0,writable:!0}),n},set(n){Object.defineProperty(this,t,{value:n,configurable:!0,writable:!0})}})}var xv=(e,t)=>{Dl.init(e,t),e.name="ZodError";let r=Object.getPrototypeOf(e);ym.has(r)||(ym.add(r),Wo(r,"format",n=>o=>ql(n,o)),Wo(r,"flatten",n=>o=>Ml(n,o)),Wo(r,"addIssue",n=>o=>{n.issues.push(o),n.message=JSON.stringify(n.issues,mr,2)}),Wo(r,"addIssues",n=>o=>{n.issues.push(...o),n.message=JSON.stringify(n.issues,mr,2)}),Object.defineProperty(r,"isEmpty",{configurable:!0,enumerable:!1,get(){return this.issues.length===0}}))};var Ve=b("ZodError",xv,void 0,{Parent:Error});var _m=xo(Ve),wm=So(Ve),bm=Qr(Ve),vm=zo(Ve),$m=Ll(Ve),km=Ul(Ve),xm=Vl(Ve),Sm=Bl(Ve),zm=Hl(Ve),Pm=Kl(Ve),Im=Jl(Ve),Em=Gl(Ve);function zv(){Ce.localeError||Ue(Yf())}function Xo(){Ce.memoizer||Ue({memoizer:Wf()})}var ce=b("ZodType",(e,t)=>(zv(),ee.init(e,t),e.def=t,e.type=t.type,e),{check(...e){let t=this.def;return this.clone(R.mergeDefs(t,{checks:[...t.checks??[],...e.map(r=>typeof r=="function"?{_zod:{check:r,def:{check:"custom"},onattach:[]}}:r)]}),{parent:!0})},with(...e){return this.check(...e)},clone(e,t){return tt(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(h0(e,t))},superRefine(e,t){return this.check(g0(e,t))},overwrite(e){return this.check(Ot(e))},optional(){return ae(this)},exactOptional(){return n0(this)},nullable(){return Rm(this)},nullish(){return ae(Rm(this))},nonoptional(e){return u0(this,e)},array(){return V(this)},or(e){return re([this,e])},and(e){return Qo(this,e)},transform(e){return Am(this,Mm(e))},default(e){return i0(this,e)},prefault(e){return c0(this,e)},catch(e){return d0(this,e)},pipe(e){return Am(this,e)},readonly(){return m0(this)},describe(e){let t=this.clone();return Gt.add(t,{description:e}),t},meta(...e){if(e.length===0)return Gt.get(this);let t=this.clone();return Gt.add(t,e[0]),t},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(e,...t){return t.length===0?e(this):e(this,...t)},get"~standard"(){return R.hide(this,"~standard",{...ea(this),jsonSchema:{input:un(this,"input"),output:un(this,"output")}})},set"~standard"(e){R.own(this,"~standard",e)},parse:function e(t,r){return _m(this,t,r,{callee:e})},parseAsync:async function e(t,r){return await wm(this,t,r,{callee:e})},safeParse(e,t){return bm(this,e,t)},async safeParseAsync(e,t){return vm(this,e,t)},get spa(){return this?.safeParseAsync},set spa(e){R.own(this,"spa",e)},validate(e,t){return Po(this,e,t)},validateAsync(e,t){return Io(this,e,t)},encode:function e(t,r){return $m(this,t,r,{callee:e})},decode:function e(t,r){return km(this,t,r,{callee:e})},encodeAsync:async function e(t,r){return await xm(this,t,r,{callee:e})},decodeAsync:async function e(t,r){return await Sm(this,t,r,{callee:e})},safeEncode(e,t){return zm(this,e,t)},safeDecode(e,t){return Pm(this,e,t)},async safeEncodeAsync(e,t){return Im(this,e,t)},async safeDecodeAsync(e,t){return Em(this,e,t)},toJSONSchema(e){return Zp(this,{})(e)},get description(){return Gt.get(this)?.description},get _def(){return this._zod.def}}),Cm=b("_ZodString",(e,t)=>{Co.init(e,t),ce.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Jp(e,r,n,o)},R.derived({format:e=>Ke(e).format??null,minLength:e=>Ke(e).minimum??null,maxLength:e=>Ke(e).maximum??null},{regex(...e){return this.check(la(...e))},includes(...e){return this.check(pa(...e))},startsWith(...e){return this.check(ma(...e))},endsWith(...e){return this.check(ha(...e))},min(...e){return this.check(wr(...e))},max(...e){return this.check(Ko(...e))},length(...e){return this.check(Jo(...e))},nonempty(...e){return this.check(wr(1,...e))},lowercase(e){return this.check(da(e))},uppercase(e){return this.check(fa(e))},trim(){return this.check(ya())},normalize(...e){return this.check(ga(...e))},toLowerCase(){return this.check(_a())},toUpperCase(){return this.check(wa())},slugify(){return this.check(ba())}})),Pv=b("ZodString",(e,t)=>{Co.init(e,t),Cm.init(e,t)},{email(e){return this.check(tp(Iv,e))},url(e){return this.check(ap(Tv,e))},jwt(e){return this.check($p(Bv,e))},emoji(e){return this.check(cp(Ov,e))},guid(e){return this.check(rp(Ev,e))},uuid(e){return this.check(np(Yo,e))},uuidv4(e){return this.check(op(Yo,e))},uuidv6(e){return this.check(sp(Yo,e))},uuidv7(e){return this.check(ip(Yo,e))},nanoid(e){return this.check(up(Rv,e))},cuid(e){return this.check(lp(Av,e))},cuid2(e){return this.check(dp(Cv,e))},ulid(e){return this.check(fp(Nv,e))},base64(e){return this.check(wp(Lv,e))},base64url(e){return this.check(bp(Uv,e))},xid(e){return this.check(pp(jv,e))},ksuid(e){return this.check(mp(Dv,e))},ipv4(e){return this.check(hp(Zv,e))},ipv6(e){return this.check(gp(Mv,e))},cidrv4(e){return this.check(yp(qv,e))},cidrv6(e){return this.check(_p(Fv,e))},e164(e){return this.check(vp(Vv,e))},datetime(e){return this.check(qo(dn,e))},date(e){return this.check(Fo(fn,e))},time(e){return this.check(Lo(pn,e))},duration(e){return this.check(Uo(mn,e))}});function _(e){return ep(Pv,e)}var ue=b("ZodStringFormat",(e,t)=>{te.init(e,t),Cm.init(e,t)}),dn=b("ZodISODateTime",(e,t)=>{uf.init(e,t),ue.init(e,t)}),fn=b("ZodISODate",(e,t)=>{lf.init(e,t),ue.init(e,t)}),pn=b("ZodISOTime",(e,t)=>{df.init(e,t),ue.init(e,t)}),mn=b("ZodISODuration",(e,t)=>{ff.init(e,t),ue.init(e,t)}),Iv=b("ZodEmail",(e,t)=>{Yd.init(e,t),ue.init(e,t)});var Ev=b("ZodGUID",(e,t)=>{Gd.init(e,t),ue.init(e,t)});var Yo=b("ZodUUID",(e,t)=>{Wd.init(e,t),ue.init(e,t)});var Tv=b("ZodURL",(e,t)=>{ef.init(e,t),ue.init(e,t)});var Ov=b("ZodEmoji",(e,t)=>{tf.init(e,t),ue.init(e,t)});var Rv=b("ZodNanoID",(e,t)=>{rf.init(e,t),ue.init(e,t)});var Av=b("ZodCUID",(e,t)=>{nf.init(e,t),ue.init(e,t)});var Cv=b("ZodCUID2",(e,t)=>{of.init(e,t),ue.init(e,t)});var Nv=b("ZodULID",(e,t)=>{sf.init(e,t),ue.init(e,t)});var jv=b("ZodXID",(e,t)=>{af.init(e,t),ue.init(e,t)});var Dv=b("ZodKSUID",(e,t)=>{cf.init(e,t),ue.init(e,t)});var Zv=b("ZodIPv4",(e,t)=>{pf.init(e,t),ue.init(e,t)});var Mv=b("ZodIPv6",(e,t)=>{hf.init(e,t),ue.init(e,t)});var qv=b("ZodCIDRv4",(e,t)=>{gf.init(e,t),ue.init(e,t)});var Fv=b("ZodCIDRv6",(e,t)=>{yf.init(e,t),ue.init(e,t)});var Lv=b("ZodBase64",(e,t)=>{wf.init(e,t),ue.init(e,t)});var Uv=b("ZodBase64URL",(e,t)=>{bf.init(e,t),ue.init(e,t)});var Vv=b("ZodE164",(e,t)=>{vf.init(e,t),ue.init(e,t)});var Bv=b("ZodJWT",(e,t)=>{$f.init(e,t),ue.init(e,t)});var Nm=b("ZodNumber",(e,t)=>{ra.init(e,t),ce.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Gp(e,r,n,o),e.isFinite=!0},R.derived({minValue:e=>{let{minimum:t,exclusiveMinimum:r}=Ke(e);return Math.max(t??Number.NEGATIVE_INFINITY,r??Number.NEGATIVE_INFINITY)},maxValue:e=>{let{maximum:t,exclusiveMaximum:r}=Ke(e);return Math.min(t??Number.POSITIVE_INFINITY,r??Number.POSITIVE_INFINITY)},isInt:e=>{let{isInt:t,multipleOf:r}=Ke(e);return!!t||!!r?.some(Number.isSafeInteger)},format:e=>Ke(e).format??null},{gt(e,t){return this.check(Bo(e,t))},gte(e,t){return this.check(an(e,t))},min(e,t){return this.check(an(e,t))},lt(e,t){return this.check(Vo(e,t))},lte(e,t){return this.check(sn(e,t))},max(e,t){return this.check(sn(e,t))},int(e){return this.check(Tm(e))},safe(e){return this.check(Tm(e))},positive(e){return this.check(Bo(0,e))},nonnegative(e){return this.check(an(0,e))},negative(e){return this.check(Vo(0,e))},nonpositive(e){return this.check(sn(0,e))},multipleOf(e,t){return this.check(Ho(e,t))},step(e,t){return this.check(Ho(e,t))},finite(){return this}}));function W(e){return kp(Nm,e)}var Hv=b("ZodNumberFormat",(e,t)=>{kf.init(e,t),Nm.init(e,t)});function Tm(e){return xp(Hv,e)}var Kv=b("ZodBoolean",(e,t)=>{xf.init(e,t),ce.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Wp(e,r,n,o)});function ge(e){return Sp(Kv,e)}var Jv=b("ZodNull",(e,t)=>{Sf.init(e,t),ce.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Yp(e,r,n,o)});function jm(e){return zp(Jv,e)}var Gv=b("ZodUnknown",(e,t)=>{zf.init(e,t),ce.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Qp(e,r,n,o)});function ie(){return Pp(Gv)}var Wv=b("ZodNever",(e,t)=>{Pf.init(e,t),ce.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Xp(e,r,n,o)});function Yv(e){return Ip(Wv,e)}var Xv=b("ZodArray",(e,t)=>{Xo(),If.init(e,t),ce.init(e,t),e._zod.processJSONSchema=(r,n,o)=>om(e,r,n,o),e.element=t.element},{min(e,t){return this.check(wr(e,t))},nonempty(e){return this.check(wr(1,e))},max(e,t){return this.check(Ko(e,t))},length(e,t){return this.check(Jo(e,t))},unwrap(){return this.element}});function V(e,t){return Ep(Xv,e,t)}var Dm=b("ZodObject",(e,t)=>{Xo(),Of.init(e,t),ce.init(e,t),e._zod.processJSONSchema=(r,n,o)=>sm(e,r,n,o),R.installLazyProp(e,"shape",r=>r._zod.def.shape,!1)},{keyof(){return Ne(Object.keys(this._zod.def.shape))},catchall(e){return this.clone(R.mergeDefs(this._zod.def,{catchall:e}))},passthrough(){return this.clone(R.mergeDefs(this._zod.def,{catchall:ie()}))},loose(){return this.clone(R.mergeDefs(this._zod.def,{catchall:ie()}))},strict(){return this.clone(R.mergeDefs(this._zod.def,{catchall:Yv()}))},strip(){return this.clone(R.mergeDefs(this._zod.def,{catchall:void 0}))},extend(e){return R.extend(this,e)},safeExtend(e){return R.safeExtend(this,e)},merge(e){return R.merge(this,e)},pick(e){return R.pick(this,e)},omit(e){return R.omit(this,e)},partial(...e){return R.partial(qm,this,e[0])},exactPartial(...e){return R.partial(Fm,this,e[0],"exactPartial")},required(...e){return R.required(Lm,this,e[0])}});function z(e,t){let r={type:"object",shape:e??{},...R.normalizeParams(t)};return new Dm(r)}function Te(e,t){return new Dm({type:"object",shape:e,catchall:ie(),...R.normalizeParams(t)})}var Zm=b("ZodUnion",(e,t)=>{na.init(e,t),ce.init(e,t),e._zod.processJSONSchema=(r,n,o)=>im(e,r,n,o),e.options=t.options});function re(e,t){return new Zm({type:"union",options:e,...R.normalizeParams(t)})}var Qv=b("ZodDiscriminatedUnion",(e,t)=>{Zm.init(e,t),Rf.init(e,t)});function Ta(e,t,r){return new Qv({type:"union",options:t,discriminator:e,...R.normalizeParams(r)})}var e0=b("ZodIntersection",(e,t)=>{Af.init(e,t),ce.init(e,t),e._zod.processJSONSchema=(r,n,o)=>am(e,r,n,o)});function Qo(e,t){return new e0({type:"intersection",left:e,right:t})}var Om=b("ZodRecord",(e,t)=>{Xo(),Cf.init(e,t),ce.init(e,t),e._zod.processJSONSchema=(r,n,o)=>cm(e,r,n,o),e.keyType=t.keyType,e.valueType=t.valueType});function Q(e,t,r){return!t||!t._zod?new Om({type:"record",keyType:_(),valueType:e,...R.normalizeParams(t)}):new Om({type:"record",keyType:e,valueType:t,...R.normalizeParams(r)})}var Ea=b("ZodEnum",(e,t)=>{Nf.init(e,t),ce.init(e,t),e._zod.processJSONSchema=(n,o,s)=>em(e,n,o,s),e.enum=t.entries,e.options=[...e._zod.values];let r=new Set(Object.keys(t.entries));e.extract=(n,o)=>{let s={};for(let i of n)if(r.has(i))s[i]=t.entries[i];else throw new Error(`Key ${i} not found in enum`);return new Ea({...t,checks:[],...R.normalizeParams(o),entries:s})},e.exclude=(n,o)=>{let s={...t.entries};for(let i of n)if(r.has(i))delete s[i];else throw new Error(`Key ${i} not found in enum`);return new Ea({...t,checks:[],...R.normalizeParams(o),entries:s})}});function Ne(e,t){let r=Array.isArray(e)?Object.fromEntries(e.map(n=>[n,n])):e;return new Ea({type:"enum",entries:r,...R.normalizeParams(t)})}var t0=b("ZodLiteral",(e,t)=>{jf.init(e,t),ce.init(e,t),e._zod.processJSONSchema=(r,n,o)=>tm(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 I(e,t){return new t0({type:"literal",values:Array.isArray(e)?e:[e],...R.normalizeParams(t)})}var r0=b("ZodTransform",(e,t)=>{Xo(),Df.init(e,t),ce.init(e,t),e._zod.processJSONSchema=(r,n,o)=>nm(e,r,n,o),e._zod.parse=(r,n)=>{if(n.direction==="backward")throw new _r(e.constructor.name);r.addIssue=s=>{if(typeof s=="string")r.issues.push(R.issue(s,r.value,t));else{let i=s;i.fatal&&(i.continue=!1),i.code??(i.code="custom"),"input"in i||(i.input=r.value),i.inst??(i.inst=e),r.issues.push(R.issue(i))}};let o=t.transform(r.value,r);return o instanceof Promise?o.then(s=>(r.value=s,r)):(r.value=o,r)}});function Mm(e){return new r0({type:"transform",transform:e})}var qm=b("ZodOptional",(e,t)=>{oa.init(e,t),ce.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Ia(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function ae(e){return new qm({type:"optional",innerType:e})}var Fm=b("ZodExactOptional",(e,t)=>{Zf.init(e,t),ce.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Ia(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function n0(e){return new Fm({type:"optional",innerType:e})}var o0=b("ZodNullable",(e,t)=>{Mf.init(e,t),ce.init(e,t),e._zod.processJSONSchema=(r,n,o)=>um(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function Rm(e){return new o0({type:"nullable",innerType:e})}var s0=b("ZodDefault",(e,t)=>{qf.init(e,t),ce.init(e,t),e._zod.processJSONSchema=(r,n,o)=>fm(e,r,n,o),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function i0(e,t){return new s0({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():R.shallowClone(t)}})}var a0=b("ZodPrefault",(e,t)=>{Ff.init(e,t),ce.init(e,t),e._zod.processJSONSchema=(r,n,o)=>pm(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function c0(e,t){return new a0({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():R.shallowClone(t)}})}var Lm=b("ZodNonOptional",(e,t)=>{Lf.init(e,t),ce.init(e,t),e._zod.processJSONSchema=(r,n,o)=>lm(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function u0(e,t){return new Lm({type:"nonoptional",innerType:e,...R.normalizeParams(t)})}var l0=b("ZodCatch",(e,t)=>{Uf.init(e,t),ce.init(e,t),e._zod.processJSONSchema=(r,n,o)=>mm(e,r,n,o),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function d0(e,t){return new l0({type:"catch",innerType:e,catchValue:typeof t=="function"?t:R.constantCatch(t)})}var Um=b("ZodPipe",(e,t)=>{sa.init(e,t),ce.init(e,t),e._zod.processJSONSchema=(r,n,o)=>hm(e,r,n,o),e.in=t.in,e.out=t.out});function Am(e,t){return new Um({type:"pipe",in:e,out:t})}var f0=b("ZodPreprocess",(e,t)=>{Um.init(e,t),Vf.init(e,t)}),p0=b("ZodReadonly",(e,t)=>{Bf.init(e,t),ce.init(e,t),e._zod.processJSONSchema=(r,n,o)=>gm(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function m0(e){return new p0({type:"readonly",innerType:e})}var Vm=b("ZodCustom",(e,t)=>{Hf.init(e,t),ce.init(e,t),e._zod.processJSONSchema=(r,n,o)=>rm(e,r,n,o)});function Bm(e,t){return Tp(Vm,e??(()=>!0),t)}function h0(e,t={}){return Op(Vm,e,t)}function g0(e,t){return Rp(e,t)}function Oa(e,t){return new f0({type:"pipe",in:Mm(e),out:t})}var es={};wl(es,{ZodISODate:()=>fn,ZodISODateTime:()=>dn,ZodISODuration:()=>mn,ZodISOTime:()=>pn,date:()=>_0,datetime:()=>y0,duration:()=>b0,time:()=>w0});function y0(e){return qo(dn,e)}function _0(e){return Fo(fn,e)}function w0(e){return Lo(pn,e)}function b0(e){return Uo(mn,e)}var Aa="2025-11-25";var Hm=[Aa,"2025-06-18","2025-03-26","2024-11-05","2024-10-07"],Rt="io.modelcontextprotocol/related-task",rs="2.0",he=Bm(e=>e!==null&&(typeof e=="object"||typeof e=="function")),Km=re([_(),W().int()]),Jm=_(),DA=Te({ttl:W().optional(),pollInterval:W().optional()}),v0=z({ttl:W().optional()}),$0=z({taskId:_()}),Ca=Te({progressToken:Km.optional(),[Rt]:$0.optional()}),Be=z({_meta:Ca.optional()}),hn=Be.extend({task:v0.optional()}),Gm=e=>hn.safeParse(e).success,_e=z({method:_(),params:Be.loose().optional()}),Je=z({_meta:Ca.optional()}),Ge=z({method:_(),params:Je.loose().optional()}),we=Te({_meta:Ca.optional()}),ns=re([_(),W().int()]),Wm=z({jsonrpc:I(rs),id:ns,..._e.shape}).strict(),Na=e=>Wm.safeParse(e).success,Ym=z({jsonrpc:I(rs),...Ge.shape}).strict(),Xm=e=>Ym.safeParse(e).success,ja=z({jsonrpc:I(rs),id:ns,result:we}).strict(),gn=e=>ja.safeParse(e).success;var j;(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"})(j||(j={}));var Da=z({jsonrpc:I(rs),id:ns.optional(),error:z({code:W().int(),message:_(),data:ie().optional()})}).strict();var Qm=e=>Da.safeParse(e).success;var eh=re([Wm,Ym,ja,Da]),ZA=re([ja,Da]),os=we.strict(),k0=Je.extend({requestId:ns.optional(),reason:_().optional()}),ss=Ge.extend({method:I("notifications/cancelled"),params:k0}),x0=z({src:_(),mimeType:_().optional(),sizes:V(_()).optional(),theme:Ne(["light","dark"]).optional()}),yn=z({icons:V(x0).optional()}),$r=z({name:_(),title:_().optional()}),th=$r.extend({...$r.shape,...yn.shape,version:_(),websiteUrl:_().optional(),description:_().optional()}),S0=Qo(z({applyDefaults:ge().optional()}),Q(_(),ie())),z0=Oa(e=>e&&typeof e=="object"&&!Array.isArray(e)&&Object.keys(e).length===0?{form:{}}:e,Qo(z({form:S0.optional(),url:he.optional()}),Q(_(),ie()).optional())),P0=Te({list:he.optional(),cancel:he.optional(),requests:Te({sampling:Te({createMessage:he.optional()}).optional(),elicitation:Te({create:he.optional()}).optional()}).optional()}),I0=Te({list:he.optional(),cancel:he.optional(),requests:Te({tools:Te({call:he.optional()}).optional()}).optional()}),E0=z({experimental:Q(_(),he).optional(),sampling:z({context:he.optional(),tools:he.optional()}).optional(),elicitation:z0.optional(),roots:z({listChanged:ge().optional()}).optional(),tasks:P0.optional(),extensions:Q(_(),he).optional()}),T0=Be.extend({protocolVersion:_(),capabilities:E0,clientInfo:th}),Za=_e.extend({method:I("initialize"),params:T0});var O0=z({experimental:Q(_(),he).optional(),logging:he.optional(),completions:he.optional(),prompts:z({listChanged:ge().optional()}).optional(),resources:z({subscribe:ge().optional(),listChanged:ge().optional()}).optional(),tools:z({listChanged:ge().optional()}).optional(),tasks:I0.optional(),extensions:Q(_(),he).optional()}),R0=we.extend({protocolVersion:_(),capabilities:O0,serverInfo:th,instructions:_().optional()}),Ma=Ge.extend({method:I("notifications/initialized"),params:Je.optional()});var is=_e.extend({method:I("ping"),params:Be.optional()}),A0=z({progress:W(),total:ae(W()),message:ae(_())}),C0=z({...Je.shape,...A0.shape,progressToken:Km}),as=Ge.extend({method:I("notifications/progress"),params:C0}),N0=Be.extend({cursor:Jm.optional()}),_n=_e.extend({params:N0.optional()}),wn=we.extend({nextCursor:Jm.optional()}),j0=Ne(["working","input_required","completed","failed","cancelled"]),bn=z({taskId:_(),status:j0,ttl:re([W(),jm()]),createdAt:_(),lastUpdatedAt:_(),pollInterval:ae(W()),statusMessage:ae(_())}),kr=we.extend({task:bn}),D0=Je.merge(bn),vn=Ge.extend({method:I("notifications/tasks/status"),params:D0}),cs=_e.extend({method:I("tasks/get"),params:Be.extend({taskId:_()})}),us=we.merge(bn),ls=_e.extend({method:I("tasks/result"),params:Be.extend({taskId:_()})}),MA=we.loose(),ds=_n.extend({method:I("tasks/list")}),fs=wn.extend({tasks:V(bn)}),ps=_e.extend({method:I("tasks/cancel"),params:Be.extend({taskId:_()})}),rh=we.merge(bn),nh=z({uri:_(),mimeType:ae(_()),_meta:Q(_(),ie()).optional()}),oh=nh.extend({text:_()}),qa=_().refine(e=>{try{return atob(e),!0}catch{return!1}},{message:"Invalid Base64 string"}),sh=nh.extend({blob:qa}),$n=Ne(["user","assistant"]),xr=z({audience:V($n).optional(),priority:W().min(0).max(1).optional(),lastModified:es.datetime({offset:!0}).optional()}),ih=z({...$r.shape,...yn.shape,uri:_(),description:ae(_()),mimeType:ae(_()),size:ae(W()),annotations:xr.optional(),_meta:ae(Te({}))}),Z0=z({...$r.shape,...yn.shape,uriTemplate:_(),description:ae(_()),mimeType:ae(_()),annotations:xr.optional(),_meta:ae(Te({}))}),M0=_n.extend({method:I("resources/list")}),q0=wn.extend({resources:V(ih)}),F0=_n.extend({method:I("resources/templates/list")}),L0=wn.extend({resourceTemplates:V(Z0)}),Fa=Be.extend({uri:_()}),U0=Fa,V0=_e.extend({method:I("resources/read"),params:U0}),B0=we.extend({contents:V(re([oh,sh]))}),H0=Ge.extend({method:I("notifications/resources/list_changed"),params:Je.optional()}),K0=Fa,J0=_e.extend({method:I("resources/subscribe"),params:K0}),G0=Fa,W0=_e.extend({method:I("resources/unsubscribe"),params:G0}),Y0=Je.extend({uri:_()}),X0=Ge.extend({method:I("notifications/resources/updated"),params:Y0}),Q0=z({name:_(),description:ae(_()),required:ae(ge())}),e$=z({...$r.shape,...yn.shape,description:ae(_()),arguments:ae(V(Q0)),_meta:ae(Te({}))}),t$=_n.extend({method:I("prompts/list")}),r$=wn.extend({prompts:V(e$)}),n$=Be.extend({name:_(),arguments:Q(_(),_()).optional()}),o$=_e.extend({method:I("prompts/get"),params:n$}),La=z({type:I("text"),text:_(),annotations:xr.optional(),_meta:Q(_(),ie()).optional()}),Ua=z({type:I("image"),data:qa,mimeType:_(),annotations:xr.optional(),_meta:Q(_(),ie()).optional()}),Va=z({type:I("audio"),data:qa,mimeType:_(),annotations:xr.optional(),_meta:Q(_(),ie()).optional()}),s$=z({type:I("tool_use"),name:_(),id:_(),input:Q(_(),ie()),_meta:Q(_(),ie()).optional()}),i$=z({type:I("resource"),resource:re([oh,sh]),annotations:xr.optional(),_meta:Q(_(),ie()).optional()}),a$=ih.extend({type:I("resource_link")}),Ba=re([La,Ua,Va,a$,i$]),c$=z({role:$n,content:Ba}),u$=we.extend({description:_().optional(),messages:V(c$)}),l$=Ge.extend({method:I("notifications/prompts/list_changed"),params:Je.optional()}),d$=z({title:_().optional(),readOnlyHint:ge().optional(),destructiveHint:ge().optional(),idempotentHint:ge().optional(),openWorldHint:ge().optional()}),f$=z({taskSupport:Ne(["required","optional","forbidden"]).optional()}),ah=z({...$r.shape,...yn.shape,description:_().optional(),inputSchema:z({type:I("object"),properties:Q(_(),he).optional(),required:V(_()).optional()}).catchall(ie()),outputSchema:z({type:I("object"),properties:Q(_(),he).optional(),required:V(_()).optional()}).catchall(ie()).optional(),annotations:d$.optional(),execution:f$.optional(),_meta:Q(_(),ie()).optional()}),Ha=_n.extend({method:I("tools/list")}),p$=wn.extend({tools:V(ah)}),ms=we.extend({content:V(Ba).default([]),structuredContent:Q(_(),ie()).optional(),isError:ge().optional()}),qA=ms.or(we.extend({toolResult:ie()})),m$=hn.extend({name:_(),arguments:Q(_(),ie()).optional()}),kn=_e.extend({method:I("tools/call"),params:m$}),h$=Ge.extend({method:I("notifications/tools/list_changed"),params:Je.optional()}),FA=z({autoRefresh:ge().default(!0),debounceMs:W().int().nonnegative().default(300)}),xn=Ne(["debug","info","notice","warning","error","critical","alert","emergency"]),g$=Be.extend({level:xn}),Ka=_e.extend({method:I("logging/setLevel"),params:g$}),y$=Je.extend({level:xn,logger:_().optional(),data:ie()}),_$=Ge.extend({method:I("notifications/message"),params:y$}),w$=z({name:_().optional()}),b$=z({hints:V(w$).optional(),costPriority:W().min(0).max(1).optional(),speedPriority:W().min(0).max(1).optional(),intelligencePriority:W().min(0).max(1).optional()}),v$=z({mode:Ne(["auto","required","none"]).optional()}),$$=z({type:I("tool_result"),toolUseId:_().describe("The unique identifier for the corresponding tool call."),content:V(Ba).default([]),structuredContent:z({}).loose().optional(),isError:ge().optional(),_meta:Q(_(),ie()).optional()}),k$=Ta("type",[La,Ua,Va]),ts=Ta("type",[La,Ua,Va,s$,$$]),x$=z({role:$n,content:re([ts,V(ts)]),_meta:Q(_(),ie()).optional()}),S$=hn.extend({messages:V(x$),modelPreferences:b$.optional(),systemPrompt:_().optional(),includeContext:Ne(["none","thisServer","allServers"]).optional(),temperature:W().optional(),maxTokens:W().int(),stopSequences:V(_()).optional(),metadata:he.optional(),tools:V(ah).optional(),toolChoice:v$.optional()}),z$=_e.extend({method:I("sampling/createMessage"),params:S$}),Sn=we.extend({model:_(),stopReason:ae(Ne(["endTurn","stopSequence","maxTokens"]).or(_())),role:$n,content:k$}),Ja=we.extend({model:_(),stopReason:ae(Ne(["endTurn","stopSequence","maxTokens","toolUse"]).or(_())),role:$n,content:re([ts,V(ts)])}),P$=z({type:I("boolean"),title:_().optional(),description:_().optional(),default:ge().optional()}),I$=z({type:I("string"),title:_().optional(),description:_().optional(),minLength:W().optional(),maxLength:W().optional(),format:Ne(["email","uri","date","date-time"]).optional(),default:_().optional()}),E$=z({type:Ne(["number","integer"]),title:_().optional(),description:_().optional(),minimum:W().optional(),maximum:W().optional(),default:W().optional()}),T$=z({type:I("string"),title:_().optional(),description:_().optional(),enum:V(_()),default:_().optional()}),O$=z({type:I("string"),title:_().optional(),description:_().optional(),oneOf:V(z({const:_(),title:_()})),default:_().optional()}),R$=z({type:I("string"),title:_().optional(),description:_().optional(),enum:V(_()),enumNames:V(_()).optional(),default:_().optional()}),A$=re([T$,O$]),C$=z({type:I("array"),title:_().optional(),description:_().optional(),minItems:W().optional(),maxItems:W().optional(),items:z({type:I("string"),enum:V(_())}),default:V(_()).optional()}),N$=z({type:I("array"),title:_().optional(),description:_().optional(),minItems:W().optional(),maxItems:W().optional(),items:z({anyOf:V(z({const:_(),title:_()}))}),default:V(_()).optional()}),j$=re([C$,N$]),D$=re([R$,A$,j$]),Z$=re([D$,P$,I$,E$]),M$=hn.extend({mode:I("form").optional(),message:_(),requestedSchema:z({type:I("object"),properties:Q(_(),Z$),required:V(_()).optional()})}),q$=hn.extend({mode:I("url"),message:_(),elicitationId:_(),url:_().url()}),F$=re([M$,q$]),L$=_e.extend({method:I("elicitation/create"),params:F$}),U$=Je.extend({elicitationId:_()}),V$=Ge.extend({method:I("notifications/elicitation/complete"),params:U$}),Sr=we.extend({action:Ne(["accept","decline","cancel"]),content:Oa(e=>e===null?void 0:e,Q(_(),re([_(),W(),ge(),V(_())])).optional())}),B$=z({type:I("ref/resource"),uri:_()});var H$=z({type:I("ref/prompt"),name:_()}),K$=Be.extend({ref:re([H$,B$]),argument:z({name:_(),value:_()}),context:z({arguments:Q(_(),_()).optional()}).optional()}),J$=_e.extend({method:I("completion/complete"),params:K$});var G$=we.extend({completion:Te({values:V(_()).max(100),total:ae(W().int()),hasMore:ae(ge())})}),W$=z({uri:_().startsWith("file://"),name:_().optional(),_meta:Q(_(),ie()).optional()}),Y$=_e.extend({method:I("roots/list"),params:Be.optional()}),Ga=we.extend({roots:V(W$)}),X$=Ge.extend({method:I("notifications/roots/list_changed"),params:Je.optional()}),LA=re([is,Za,J$,Ka,o$,t$,M0,F0,V0,J0,W0,kn,Ha,cs,ls,ds,ps]),UA=re([ss,as,Ma,X$,vn]),VA=re([os,Sn,Ja,Sr,Ga,us,fs,kr]),BA=re([is,z$,L$,Y$,cs,ls,ds,ps]),HA=re([ss,as,_$,X0,H0,h$,l$,vn,V$]),KA=re([os,R0,G$,u$,r$,q0,L0,B0,ms,p$,us,fs,kr]),A=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===j.UrlElicitationRequired&&n){let o=n;if(o.elicitations)return new Ra(o.elicitations,r)}return new e(t,r,n)}},Ra=class extends A{constructor(t,r=`URL elicitation${t.length>1?"s":""} required`){super(j.UrlElicitationRequired,r,{elicitations:t})}get elicitations(){return this.data?.elicitations??[]}};var Q$=10*1024*1024,hs=class{constructor(t){this._maxBufferSize=t?.maxBufferSize??Q$}append(t){if((this._buffer?.length??0)+t.length>this._maxBufferSize)throw this.clear(),new Error(`ReadBuffer exceeded maximum size of ${this._maxBufferSize} bytes`);this._buffer=this._buffer?Buffer.concat([this._buffer,t]):t}readMessage(){if(!this._buffer)return null;let t=this._buffer.indexOf(`
|
|
67
|
+
`);if(t===-1)return null;let r=this._buffer.toString("utf8",0,t).replace(/\r$/,"");return this._buffer=this._buffer.subarray(t+1),ek(r)}clear(){this._buffer=void 0}};function ek(e){return eh.parse(JSON.parse(e))}function ch(e){return JSON.stringify(e)+`
|
|
68
|
+
`}var gs=class{constructor(t=uh.stdin,r=uh.stdout,n){this._stdin=t,this._stdout=r,this._started=!1,this._ondata=o=>{try{this._readBuffer.append(o),this.processReadBuffer()}catch(s){this.onerror?.(s),this.close().catch(()=>{})}},this._onerror=o=>{this.onerror?.(o)},this._readBuffer=new hs({maxBufferSize:n?.maxBufferSize})}async start(){if(this._started)throw new Error("StdioServerTransport already started! If using Server class, note that connect() calls start() automatically.");this._started=!0,this._stdin.on("data",this._ondata),this._stdin.on("error",this._onerror)}processReadBuffer(){for(;;)try{let t=this._readBuffer.readMessage();if(t===null)break;this.onmessage?.(t)}catch(t){this.onerror?.(t)}}async close(){this._stdin.off("data",this._ondata),this._stdin.off("error",this._onerror),this._stdin.listenerCount("data")===0&&this._stdin.pause(),this._readBuffer.clear(),this.onclose?.()}send(t){return new Promise(r=>{let n=ch(t);this._stdout.write(n)?r():this._stdout.once("drain",r)})}};function Wa(){return{schema:2,cells:[]}}function bt(e,t=null){return{schema:2,id:e,source:t,chapters:[],cards:[],inspirations:[]}}function Wt(e){let t=0,r=0,n;for(let o of e.chapters)for(let s of o.sections)r+=1,s.done?t+=1:n===void 0&&(n={chapter:o,section:s});return{done:t,total:r,current:n}}function _s(e,t=zn()){if(e.targetDate===void 0)return;let{done:r,total:n}=Wt(e),o=n-r,s=tk(t,e.targetDate)+1;if(s<=0)return{remaining:o,daysLeft:s,overdue:o>0};let i=o===0?0:Math.ceil(o/s*10)/10;return{remaining:o,daysLeft:s,perDay:i,overdue:!1}}function fh(e,t=zn()){let{done:r,total:n}=Wt(e),o=_s(e,t);return{done:r,total:n,...o?.perDay!==void 0?{perDay:o.perDay}:{},...o?.overdue?{overdue:!0}:{},cards:e.cards.length,finished:e.finishedAt!==void 0,...e.source!==null?{source:e.source.type}:{},...lh(e)!==void 0?{period:lh(e)}:{},...dh(e,r,n)!==void 0?{percent:dh(e,r,n)}:{}}}function lh(e){let t=[...e.chapters.flatMap(o=>o.sections.map(s=>s.doneAt)),...e.cards.map(o=>o.createdAt),...e.inspirations.map(o=>o.createdAt)].filter(o=>typeof o=="string"&&o!=="");if(t.length===0)return e.finishedAt?{start:ys(e.finishedAt),end:ys(e.finishedAt)}:void 0;let r=ys(t.reduce((o,s)=>o<s?o:s));if(!e.finishedAt)return{start:r};let n=ys(e.finishedAt);return{start:r<n?r:n,end:n}}function ys(e){return/^\d{4}-\d{2}-\d{2}$/.test(e)?e.slice(0,7):zn(new Date(e)).slice(0,7)}function dh(e,t,r){return e.finishedAt!==void 0?1:e.source?.type==="epub"&&e.position!==void 0?e.position.percent:r>0?t/r:void 0}function At(e,t){if(t!==void 0)for(let r of e.chapters){let n=r.sections.find(o=>o.id===t);if(n!==void 0)return{chapter:r,section:n}}}function zn(e=new Date){let t=e.getFullYear(),r=String(e.getMonth()+1).padStart(2,"0"),n=String(e.getDate()).padStart(2,"0");return`${t}-${r}-${n}`}function tk(e,t){let r=Date.UTC(+e.slice(0,4),+e.slice(5,7)-1,+e.slice(8,10)),n=Date.UTC(+t.slice(0,4),+t.slice(5,7)-1,+t.slice(8,10));return Math.round((n-r)/864e5)}function ph(e){return typeof e=="string"&&/^\d{4}-\d{2}-\d{2}$/.test(e)}import{randomBytes as rk}from"node:crypto";import{cpSync as nk,existsSync as zr,lstatSync as ok,mkdirSync as ws,mkdtempSync as sk,readdirSync as mh,readFileSync as hh,renameSync as yh,rmSync as bs,statSync as ik,writeFileSync as ak}from"node:fs";import{join as je}from"node:path";var w=class extends Error{};function He(e){return`${e}_${rk(5).toString("hex")}`}function Oe(){return new Date().toISOString()}var _h=/^c_[0-9a-f]{10}$/,ck=new Set(["book","note","group"]);function Ct(e){if(typeof e!="string"||!_h.test(e))throw new w("\u683C\u5B50 id \u65E0\u6548")}function ks(e){return typeof e?.schema=="number"&&e.schema>2?e.schema:2}function uk(e){if(e===null||typeof e!="object"||!Array.isArray(e.cells))throw new Error("\u7F3A\u5C11 cells \u6570\u7EC4");for(let t of e.cells){if(typeof t?.id!="string"||!ck.has(t.kind)||!Number.isSafeInteger(t.col)||!Number.isSafeInteger(t.row)||typeof t.title!="string")throw new Error(`\u683C\u5B50\u683C\u5F0F\u6709\u8BEF\uFF1A${JSON.stringify(t)?.slice(0,80)}`);t.parentId===void 0&&(t.parentId=null)}return{...e,schema:ks(e),cells:e.cells}}function lk(e,t){if(e===null||typeof e!="object")throw new Error("\u4E0D\u662F JSON \u5BF9\u8C61");for(let r of["chapters","cards","inspirations"])if(e[r]!==void 0&&!Array.isArray(e[r]))throw new Error(`${r} \u5E94\u4E3A\u6570\u7EC4`);for(let r of e.chapters??[]){if(typeof r?.id!="string"||!Array.isArray(r.sections))throw new Error("\u7AE0\u683C\u5F0F\u6709\u8BEF");for(let n of r.sections)if(typeof n?.id!="string"||typeof n.done!="boolean")throw new Error("\u8282\u683C\u5F0F\u6709\u8BEF")}for(let r of e.cards??[])if(typeof r?.id!="string"||typeof r.type!="string")throw new Error("\u5361\u7247\u683C\u5F0F\u6709\u8BEF");for(let r of e.inspirations??[])if(typeof r?.id!="string")throw new Error("\u7075\u611F\u683C\u5F0F\u6709\u8BEF");if(e.source!==void 0&&e.source!==null&&typeof e.source!="object")throw new Error("source \u683C\u5F0F\u6709\u8BEF");return{...bt(t),...e,schema:ks(e),id:t,chapters:e.chapters??[],cards:e.cards??[],inspirations:e.inspirations??[]}}function vs(e){let t=ik(e);return`${t.mtimeMs}:${t.size}`}function gh(e,t){let r=`${e}.${process.pid}.tmp`;return ak(r,JSON.stringify(t,null,2)+`
|
|
69
|
+
`,"utf8"),yh(r,e),vs(e)}var xs=class{dir;itemsDir;imagesDir;palaceFile;palace={value:Wa(),stamp:"",broken:!1};items=new Map;rev=1;constructor(t,{create:r=!0}={}){this.dir=t,this.itemsDir=je(t,"items"),this.imagesDir=je(t,"images"),this.palaceFile=je(t,"palace.json"),r&&(ws(this.itemsDir,{recursive:!0}),ws(this.imagesDir,{recursive:!0}));let n=this.refreshPalace();if(!r&&(n.stamp===""||n.broken))throw new w(`\u65E0\u6CD5\u8BFB\u53D6 ${this.palaceFile}`)}refreshPalace(){if(!zr(this.palaceFile))return this.palace.stamp!==""&&(this.palace={value:Wa(),stamp:"",broken:!1},this.rev+=1),this.palace;let t=vs(this.palaceFile);if(t===this.palace.stamp)return this.palace;let r=this.palace.schema;try{let n=JSON.parse(hh(this.palaceFile,"utf8"));r=ks(n),this.palace={value:uk(n),stamp:t,broken:!1,schema:r}}catch(n){console.warn("[dsh-palace] palace.json \u89E3\u6790\u5931\u8D25\uFF0C\u7EE7\u7EED\u4F7F\u7528\u5185\u5B58\u4E2D\u7684\u6570\u636E",n),this.palace={...this.palace,stamp:t,broken:!0,schema:r}}return this.rev+=1,this.palace}refreshItem(t){Ct(t);let r=je(this.itemsDir,`${t}.json`),n=this.items.get(t);if(!zr(r))return n!==void 0&&(this.items.delete(t),this.rev+=1),{value:bt(t),stamp:"",broken:!1};let o=vs(r);if(n!==void 0&&n.stamp===o)return n;let s,i=n?.schema;try{let a=JSON.parse(hh(r,"utf8"));i=ks(a),s={value:lk(a,t),stamp:o,broken:!1,schema:i}}catch(a){console.warn(`[dsh-palace] items/${t}.json \u89E3\u6790\u5931\u8D25`,a),s={value:n?.value??bt(t),stamp:o,broken:!0,schema:i}}return n!==void 0&&(this.rev+=1),this.items.set(t,s),s}getPalace(){return this.refreshPalace().value}getItem(t){return this.refreshItem(t).value}checkDisk(){for(let t of this.getPalace().cells)t.kind!=="group"&&this.refreshItem(t.id);return this.rev}summaries(){let t={};for(let r of this.getPalace().cells)r.kind!=="group"&&(t[r.id]=fh(this.getItem(r.id)));return t}snapshotBeforeWrite(){let t=".snapshots",r=je(this.dir,t),n=je(r,zn());try{let o=ok(r,{throwIfNoEntry:!1});if(o&&!o.isDirectory())throw new Error("\u5FEB\u7167\u8DEF\u5F84\u4E0D\u662F\u666E\u901A\u76EE\u5F55");if(zr(n))return;ws(r,{recursive:!0});let s=sk(je(r,".partial-"));try{for(let a of mh(this.dir))a!==t&&nk(je(this.dir,a),je(s,a),{recursive:!0,verbatimSymlinks:!0});zr(n)||yh(s,n)}finally{bs(s,{recursive:!0,force:!0})}let i=mh(r,{withFileTypes:!0}).filter(a=>a.isDirectory()&&/^\d{4}-\d{2}-\d{2}$/.test(a.name)).map(a=>a.name);for(let a of i.sort().slice(0,-3))bs(je(r,a),{recursive:!0,force:!0})}catch(o){console.warn("[dsh-palace] \u6BCF\u65E5\u5FEB\u7167\u5931\u8D25\uFF0C\u7EE7\u7EED\u5199\u5165",o)}}assertWritable(){let t=this.refreshPalace();this.assertSupportedSchema(t,"palace.json");for(let r of t.value.cells)r.kind==="group"||!_h.test(r.id)||this.assertSupportedSchema(this.refreshItem(r.id),`items/${r.id}.json`)}assertSupportedSchema(t,r){if((t.schema??2)>2)throw new w(`${r} \u7684\u6570\u636E\u7248\u672C\u8F83\u65B0\uFF0C\u8BF7\u5347\u7EA7\u63D2\u4EF6`)}mutate(t){try{return Promise.resolve(this.commit(t))}catch(r){return Promise.reject(r)}}commit(t){this.assertWritable();let r=this.palace;if(r.broken)throw new w("palace.json \u683C\u5F0F\u6709\u8BEF\uFF1A\u8BF7\u5148\u4FEE\u597D\u6216\u5220\u6389\u8FD9\u4E2A\u6587\u4EF6\uFF0C\u518D\u7EE7\u7EED\u64CD\u4F5C");let n=structuredClone(r.value),o=new Map,s=[],a=t({palace:n,item:f=>{let p=o.get(f);if(p!==void 0){if(p.item===null)throw new w("\u683C\u5B50\u5DF2\u5220\u9664");return p.item}let m=this.refreshItem(f);if(this.assertSupportedSchema(m,`items/${f}.json`),m.broken)throw new w(`items/${f}.json \u683C\u5F0F\u6709\u8BEF\uFF1A\u8BF7\u5148\u4FEE\u597D\u6216\u5220\u6389\u8FD9\u4E2A\u6587\u4EF6`);let h=structuredClone(m.value);return o.set(f,{item:h,before:JSON.stringify(m.value),stamp:m.stamp}),h},createItem:f=>{this.assertSupportedSchema(this.refreshItem(f.id),`items/${f.id}.json`),o.set(f.id,{item:f,before:"",stamp:""})},deleteItem:f=>{this.assertSupportedSchema(this.refreshItem(f),`items/${f}.json`),o.set(f,{item:null,before:"",stamp:""})},deleteImage:f=>{s.push(f)}});if(a instanceof Promise)throw new Error("mutate \u7684\u56DE\u8C03\u5FC5\u987B\u662F\u540C\u6B65\u7684");let c=JSON.stringify(n)!==JSON.stringify(r.value),u=[...o].filter(([,{item:f,before:p}])=>f===null||JSON.stringify(f)!==p);(c||u.length>0||s.length>0)&&this.snapshotBeforeWrite();let l=(f,p)=>(zr(f)?vs(f):"")!==p;if(l(this.palaceFile,r.stamp))throw new w("palace.json \u521A\u88AB\u5176\u4ED6\u7A0B\u5E8F\u4FEE\u6539\u8FC7\uFF0C\u8BF7\u91CD\u8BD5");for(let[f,p]of o)if(p.before!==""&&l(je(this.itemsDir,`${f}.json`),p.stamp))throw new w(`items/${f}.json \u521A\u88AB\u5176\u4ED6\u7A0B\u5E8F\u4FEE\u6539\u8FC7\uFF0C\u8BF7\u91CD\u8BD5`);for(let[f,{item:p}]of u){if(p===null)continue;zr(this.itemsDir)||ws(this.itemsDir,{recursive:!0});let m=gh(je(this.itemsDir,`${f}.json`),p);this.items.set(f,{value:p,stamp:m,broken:!1})}if(c){let f=gh(this.palaceFile,n);this.palace={value:n,stamp:f,broken:!1}}this.rev+=1;let d=(f,p)=>{try{p()}catch(m){console.warn(`[dsh-palace] \u6E05\u7406 ${f} \u5931\u8D25\uFF0C\u5DF2\u5FFD\u7565`,m)}};for(let[f,{item:p}]of o)p===null&&(this.items.delete(f),d(`items/${f}.json`,()=>bs(je(this.itemsDir,`${f}.json`),{force:!0})));for(let f of s)/^[\w.-]+$/.test(f)&&d(`images/${f}`,()=>bs(je(this.imagesDir,f),{force:!0}));return a}};function Nt(e,t){if(typeof e!="string"||e.trim()==="")throw new w(`${t}\u4E0D\u80FD\u4E3A\u7A7A`);return e.trim()}function Pn(e,t){if(e!=null){if(typeof e!="string")throw new w(`${t}\u5E94\u4E3A\u6587\u5B57`);return e.trim()===""?void 0:e.trim()}}function Ya(e,t){if(!(e==null||e==="")){if(!ph(e))throw new w(`${t}\u683C\u5F0F\u5E94\u4E3A YYYY-MM-DD`);return e}}function Ss(e,t){if(!Number.isSafeInteger(e))throw new w(`${t}\u5E94\u4E3A\u6574\u6570`);return e}function In(e,t,r,n){n?delete e[t]:r!==void 0&&(e[t]=r)}function Yt(e){return e===null||e===""}function Xt(e,t){Ct(t);let r=e.cells.find(n=>n.id===t);if(r===void 0)throw new w("\u683C\u5B50\u4E0D\u5B58\u5728");return r}function We(e,t){let r=Xt(e.palace,t);if(r.kind==="group")throw new w("\u5206\u7EC4\u6CA1\u6709\u7B14\u8BB0\u672C");return e.item(r.id)}function dk(e){let t=e;if(t?.type==="pdf"&&typeof t.path=="string"&&Number.isSafeInteger(t.pageCount))return{type:"pdf",path:t.path,pageCount:t.pageCount};if(t?.type==="epub"&&typeof t.path=="string")return{type:"epub",path:t.path};if(t?.type==="video"&&typeof t.url=="string")return{type:"video",url:t.url};throw new w("\u539F\u6587\u4FE1\u606F\u65E0\u6548")}function Xa(e,t,r,n){return e.cells.find(o=>o.parentId===t&&o.col===r&&o.row===n)}function En(e,t){let r=e.cells.filter(o=>o.parentId===t).length,n=t===null?3:Math.max(2,Math.ceil(Math.sqrt(r+1)));for(let o=0;;o++){let s=o%n,i=Math.floor(o/n);if(Xa(e,t,s,i)===void 0)return{col:s,row:i}}}function wh(e,t,r){if(t==null)return null;let n=Xt(e,t);if(n.kind!=="group")throw new w("\u53EA\u80FD\u653E\u8FDB\u5206\u7EC4\u91CC");if(r==="group")throw new w("\u5206\u7EC4\u91CC\u4E0D\u80FD\u518D\u653E\u5206\u7EC4");return n.id}function bh(e,t,r){if(e!==null&&(t<0||r<0))throw new w("\u5206\u7EC4\u91CC\u7684\u5750\u6807\u4E0D\u80FD\u4E3A\u8D1F")}function Qa(e,t){t===null||e.cells.some(r=>r.parentId===t)||(e.cells=e.cells.filter(r=>r.id!==t))}var ec="https://dsh-palace.pages.dev";async function vh(e){return e.mutate(t=>{let r={id:He("c"),kind:"note",parentId:null,...En(t.palace,null),title:"Memory Palace \u2197",subtitle:"\u4EC0\u4E48\u662F",icon:"open-book",href:ec,createdAt:Oe()};return t.palace.cells.push(r),t.createItem(bt(r.id,null)),r})}async function jt(e,t){let r=t.kind;if(r!=="book"&&r!=="note"&&r!=="group")throw new w("\u683C\u5B50\u7C7B\u578B\u5E94\u4E3A book / note / group");let n=Nt(t.title,"\u6807\u9898"),o=Pn(t.subtitle,"\u5907\u6CE8"),s=r==="book"?dk(t.source):null,i=Ya(t.targetDate,"\u76EE\u6807\u65E5\u671F");return e.mutate(a=>{let c=wh(a.palace,t.parentId,r),u;if(t.col===void 0&&t.row===void 0)u=En(a.palace,c);else if(u={col:Ss(t.col,"\u5217"),row:Ss(t.row,"\u884C")},bh(c,u.col,u.row),Xa(a.palace,c,u.col,u.row)!==void 0)throw new w("\u8FD9\u4E2A\u4F4D\u7F6E\u5DF2\u7ECF\u6709\u683C\u5B50\u4E86");let l={id:He("c"),kind:r,parentId:c,...u,title:n,...o?{subtitle:o}:{},createdAt:Oe()};if(a.palace.cells.push(l),r!=="group"){let d=bt(l.id,s);i!==void 0&&(d.targetDate=i),r==="book"&&t.outline!==void 0&&(d.chapters=Is(t.outline),d.chapters.length>0&&t.outlineSource!==void 0&&(d.outlineSource=t.outlineSource)),a.createItem(d)}return l})}async function $h(e,t){let r=t.title===void 0?void 0:Nt(t.title,"\u6807\u9898"),n=Pn(t.subtitle,"\u5907\u6CE8"),o=Pn(t.icon,"\u56FE\u6807");if(o!==void 0&&!/^[a-z][a-z0-9-]{0,30}$/.test(o))throw new w("\u56FE\u6807\u540D\u65E0\u6548");return e.mutate(s=>{let i=Xt(s.palace,t.id);return r!==void 0&&(i.title=r),In(i,"subtitle",n,Yt(t.subtitle)),In(i,"icon",o,Yt(t.icon)),i})}async function kh(e,t){let r=t.col===void 0&&t.row===void 0,n=r?0:Ss(t.col,"\u5217"),o=r?0:Ss(t.row,"\u884C");return e.mutate(s=>{let i=Xt(s.palace,t.id),a=wh(s.palace,t.parentId,i.kind);if(a===i.id)throw new w("\u4E0D\u80FD\u653E\u8FDB\u81EA\u5DF1\u91CC\u9762");if(r){if(i.parentId===a)return i;({col:n,row:o}=En(s.palace,a))}bh(a,n,o);let c=[i.parentId],u=Xa(s.palace,a,n,o);if(u!==void 0&&u.id!==i.id){if(c.push(u.parentId),u.kind==="group"&&i.parentId!==null)throw new w("\u5206\u7EC4\u4E0D\u80FD\u6362\u8FDB\u53E6\u4E00\u4E2A\u5206\u7EC4\u91CC");u.parentId=i.parentId,u.col=i.col,u.row=i.row}i.parentId=a,i.col=n,i.row=o;for(let l of c)Qa(s.palace,l);return i})}async function xh(e,t){let r=t.title===void 0?"\u65B0\u5206\u7EC4":Nt(t.title,"\u6807\u9898");return e.mutate(n=>{let o=Xt(n.palace,t.id),s=Xt(n.palace,t.ontoId);if(o.id===s.id)throw new w("\u4E0D\u80FD\u548C\u81EA\u5DF1\u7EC4\u6210\u5206\u7EC4");if(o.kind==="group"||s.kind==="group")throw new w("\u5206\u7EC4\u4E0D\u80FD\u518D\u653E\u8FDB\u5206\u7EC4");if(s.parentId!==null)throw new w("\u53EA\u80FD\u5728\u6700\u5916\u5C42\u62D6\u6210\u5206\u7EC4");let i={id:He("c"),kind:"group",parentId:null,col:s.col,row:s.row,title:r,createdAt:Oe()};n.palace.cells.push(i),s.parentId=i.id,s.col=0,s.row=0;let a=o.parentId;return o.parentId=i.id,o.col=1,o.row=0,Qa(n.palace,a),i})}async function zs(e,t){return e.mutate(r=>{let n=Xt(r.palace,t.id);if(n.kind==="group"){if(r.palace.cells.some(o=>o.parentId===n.id))throw new w("\u5206\u7EC4\u91CC\u8FD8\u6709\u683C\u5B50\uFF0C\u5148\u79FB\u51FA\u53BB\u6216\u5220\u6389")}else{for(let o of r.item(n.id).cards)o.image&&r.deleteImage(o.image);r.deleteItem(n.id)}r.palace.cells=r.palace.cells.filter(o=>o.id!==n.id),Qa(r.palace,n.parentId)})}async function Ps(e,t){let r=Ya(t.targetDate,"\u76EE\u6807\u65E5\u671F"),n=Ya(t.finishedAt,"\u8BFB\u5B8C\u65E5\u671F");return e.mutate(o=>{let s=We(o,t.id);return In(s,"targetDate",r,Yt(t.targetDate)),In(s,"finishedAt",n,Yt(t.finishedAt)),s})}async function Sh(e,t){let r=Nt(t.loc,"\u4F4D\u7F6E"),n=t.percent;if(typeof n!="number"||!(n>=0&&n<=1))throw new w("percent \u5E94\u4E3A 0\u20131 \u7684\u5C0F\u6570");return e.mutate(o=>{We(o,t.id).position={loc:r,percent:n}})}function Is(e,t=[]){let r=new Map;for(let o of t)for(let s of o.sections)s.done&&r.set(`${o.title}\0${s.title}`,s);let n=o=>typeof o=="string"&&o!==""?{loc:o}:{};return e.filter(o=>typeof o?.title=="string"&&o.title.trim()!=="").map(o=>{let s=o.title.trim(),i=(o.sections??[]).map(c=>typeof c=="string"?{title:c}:c).filter(c=>typeof c?.title=="string"&&c.title.trim()!==""),a=(i.length>0?i:[{title:s,loc:o.loc}]).map(c=>{let u=c.title.trim(),l=r.get(`${s}\0${u}`);return{id:He("s"),title:u,...n(c.loc),done:l!==void 0,...l?.doneAt!==void 0?{doneAt:l.doneAt}:{}}});return{id:He("ch"),title:s,sections:a}})}async function Es(e,t){if(!Array.isArray(t.chapters)||t.chapters.length===0)throw new w("\u76EE\u5F55\u4E0D\u80FD\u4E3A\u7A7A");let r=t.chapters;return e.mutate(n=>{let o=We(n,t.id),s=(u,l)=>`${u.title}\0${l.title}`,i=new Map;for(let u of o.chapters)for(let l of u.sections)i.set(l.id,s(u,l));let a=Is(r,o.chapters);if(a.length===0)throw new w("\u76EE\u5F55\u4E0D\u80FD\u4E3A\u7A7A");o.chapters=a;let c=new Map;for(let u of o.chapters)for(let l of u.sections)c.has(s(u,l))||c.set(s(u,l),l.id);for(let u of o.cards){if(u.sectionId===void 0)continue;let l=c.get(i.get(u.sectionId)??"");l!==void 0?u.sectionId=l:delete u.sectionId}return t.source!==void 0&&(o.outlineSource=t.source),o})}async function zh(e,t){return e.mutate(r=>{let n=At(We(r,t.id),t.sectionId);if(n===void 0)throw new w("\u8282\u4E0D\u5B58\u5728");n.section.done=t.done===!0,n.section.done?n.section.doneAt=Oe():delete n.section.doneAt})}async function Ph(e,t){return e.mutate(r=>{let n=We(r,t.id);if(At(n,t.sectionId)===void 0)throw new w("\u8282\u4E0D\u5B58\u5728");let o=!0,s=Oe();for(let i of n.chapters)for(let a of i.sections)o&&!a.done&&(a.done=!0,a.doneAt=s),!o&&a.done&&(a.done=!1,delete a.doneAt),a.id===t.sectionId&&(o=!1)})}async function Ih(e,t){return e.mutate(r=>{for(let n of We(r,t.id).chapters)for(let o of n.sections)o.done=!1,delete o.doneAt})}var fk=new Set(["excerpt","thought","mistake"]);function Eh(e,t,r){for(let n of e.palace.cells)if(n.kind!=="group"&&e.item(n.id).cards.some(o=>o.image===t&&o.id!==r))throw new w("\u8FD9\u5F20\u56FE\u7247\u5DF2\u7ECF\u5C5E\u4E8E\u53E6\u4E00\u5F20\u5361\u7247")}function Th(e){if(e.type==="thought"&&e.note===void 0)throw new w("\u60F3\u6CD5\u4E0D\u80FD\u4E3A\u7A7A");if(e.type!=="thought"&&e.quote===void 0&&e.image===void 0)throw new w("\u6458\u5F55\u548C\u9519\u9898\u9700\u8981\u539F\u6587\u6216\u56FE\u7247")}function Oh(e,t,r){if(t.sectionId!==void 0&&!Yt(t.sectionId)&&At(e,t.sectionId)===void 0)throw new w("\u8282\u4E0D\u5B58\u5728");if(t.status!==void 0&&t.status!=="todo"&&t.status!=="mastered")throw new w("\u72B6\u6001\u5E94\u4E3A todo / mastered");if(t.image!==void 0&&!Yt(t.image)&&(typeof t.image!="string"||!/^[\w.-]+$/.test(t.image)))throw new w("\u56FE\u7247\u6587\u4EF6\u540D\u65E0\u6548");for(let n of["sectionId","loc","quote","note","answer","image"])In(r,n,Pn(t[n],n),Yt(t[n]));if(t.status!==void 0&&(r.status=t.status),t.share!==void 0)if(t.share===null)delete r.share;else{if(typeof t.share!="object"||Array.isArray(t.share))throw new w("\u5206\u4EAB\u8349\u7A3F\u683C\u5F0F\u4E0D\u5BF9");if(JSON.stringify(t.share).length>64*1024)throw new w("\u5206\u4EAB\u8349\u7A3F\u592A\u5927");r.share=t.share}}async function Ts(e,t){let r=t.type;if(!fk.has(r))throw new w("\u5361\u7247\u7C7B\u578B\u5E94\u4E3A excerpt / thought / mistake");return e.mutate(n=>{let o=We(n,t.id),s={id:He("k"),type:r,createdAt:Oe()};return Oh(o,t,s),r==="mistake"&&s.status===void 0&&(s.status="todo"),Th(s),s.image!==void 0&&Eh(n,s.image,s.id),o.cards.push(s),s})}async function Rh(e,t){return e.mutate(r=>{let n=We(r,t.id),o=n.cards.find(i=>i.id===t.cardId);if(o===void 0)throw new w("\u5361\u7247\u4E0D\u5B58\u5728");if(t.type!==void 0)throw new w("\u5361\u7247\u7C7B\u578B\u4E0D\u80FD\u4FEE\u6539");let s=o.image;return Oh(n,t,o),Th(o),o.image!==void 0&&o.image!==s&&Eh(r,o.image,o.id),s!==void 0&&s!==o.image&&r.deleteImage(s),o})}async function Ah(e,t){return e.mutate(r=>{let n=We(r,t.id),o=n.cards.find(s=>s.id===t.cardId);if(o===void 0)throw new w("\u5361\u7247\u4E0D\u5B58\u5728");o.image&&r.deleteImage(o.image),n.cards=n.cards.filter(s=>s.id!==o.id);for(let s of n.inspirations)s.cardIds&&(s.cardIds=s.cardIds.filter(i=>i!==o.id))})}async function Os(e,t){let r=Nt(t.title,"\u7075\u611F\u6807\u9898"),n=Nt(t.body,"\u7075\u611F\u6B63\u6587"),o=Pn(t.sessionId,"sessionId");return e.mutate(s=>{let i=We(s,t.id),a=Array.isArray(t.cardIds)?t.cardIds.filter(u=>i.cards.some(l=>l.id===u)):[],c={id:He("i"),title:r,body:n,...o?{sessionId:o}:{},...a.length?{cardIds:a}:{},createdAt:Oe()};return i.inspirations.push(c),c})}async function Ch(e,t){let r=t.title===void 0?void 0:Nt(t.title,"\u7075\u611F\u6807\u9898"),n=t.body===void 0?void 0:Nt(t.body,"\u7075\u611F\u6B63\u6587");return e.mutate(o=>{let s=We(o,t.id).inspirations.find(i=>i.id===t.inspirationId);if(s===void 0)throw new w("\u7075\u611F\u4E0D\u5B58\u5728");return r!==void 0&&(s.title=r),n!==void 0&&(s.body=n),s})}async function Nh(e,t){return e.mutate(r=>{let n=We(r,t.id);if(!n.inspirations.some(o=>o.id===t.inspirationId))throw new w("\u7075\u611F\u4E0D\u5B58\u5728");n.inspirations=n.inspirations.filter(o=>o.id!==t.inspirationId)})}import{isAbsolute as TT}from"node:path";function Rs(e){return!!e._zod}function Dt(e,t){return Rs(e)?Hi(e,t):e.safeParse(t)}function As(e){if(!e)return;let t;if(Rs(e)?t=e._zod?.def?.shape:t=e.shape,!!t){if(typeof t=="function")try{return t()}catch{return}return t}}function Cs(e){if(Rs(e)){let s=e._zod?.def;if(s){if(s.value!==void 0)return s.value;if(Array.isArray(s.values)&&s.values.length>0)return s.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}function Zt(e){return e==="completed"||e==="failed"||e==="cancelled"}var eC=new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");function rc(e){let r=As(e)?.method;if(!r)throw new Error("Schema is missing a method literal");let n=Cs(r);if(typeof n!="string")throw new Error("Schema method literal must be a string");return n}function nc(e,t){let r=Dt(e,t);if(!r.success)throw r.error;return r.data}var wk=6e4,Ns=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(ss,r=>{this._oncancel(r)}),this.setNotificationHandler(as,r=>{this._onprogress(r)}),this.setRequestHandler(is,r=>({})),this._taskStore=t?.taskStore,this._taskMessageQueue=t?.taskMessageQueue,this._taskStore&&(this.setRequestHandler(cs,async(r,n)=>{let o=await this._taskStore.getTask(r.params.taskId,n.sessionId);if(!o)throw new A(j.InvalidParams,"Failed to retrieve task: Task not found");return{...o}}),this.setRequestHandler(ls,async(r,n)=>{let o=async()=>{let s=r.params.taskId;if(!await this._taskStore.getTask(s,n.sessionId))throw new A(j.InvalidParams,`Task not found: ${s}`);if(this._taskMessageQueue){let a;for(;a=await this._taskMessageQueue.dequeue(s,n.sessionId);){if(a.type==="response"||a.type==="error"){let c=a.message,u=c.id,l=this._requestResolvers.get(u);if(l)if(this._requestResolvers.delete(u),a.type==="response")l(c);else{let d=c,f=new A(d.error.code,d.error.message,d.error.data);l(f)}else{let d=a.type==="response"?"Response":"Error";this._onerror(new Error(`${d} handler missing for request ${u}`))}continue}await this._transport?.send(a.message,{relatedRequestId:n.requestId})}}let i=await this._taskStore.getTask(s,n.sessionId);if(!i)throw new A(j.InvalidParams,`Task not found: ${s}`);if(!Zt(i.status))return await this._waitForTaskUpdate(s,n.signal,n.sessionId),await o();if(Zt(i.status)){let a=await this._taskStore.getTaskResult(s,n.sessionId);return this._clearTaskQueue(s,n.sessionId),{...a,_meta:{...a._meta,[Rt]:{taskId:s}}}}return await o()};return await o()}),this.setRequestHandler(ds,async(r,n)=>{try{let{tasks:o,nextCursor:s}=await this._taskStore.listTasks(r.params?.cursor,n.sessionId);return{tasks:o,nextCursor:s,_meta:{}}}catch(o){throw new A(j.InvalidParams,`Failed to list tasks: ${o instanceof Error?o.message:String(o)}`)}}),this.setRequestHandler(ps,async(r,n)=>{try{let o=await this._taskStore.getTask(r.params.taskId,n.sessionId);if(!o)throw new A(j.InvalidParams,`Task not found: ${r.params.taskId}`);if(Zt(o.status))throw new A(j.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,n.sessionId);let s=await this._taskStore.getTask(r.params.taskId,n.sessionId);if(!s)throw new A(j.InvalidParams,`Task not found after cancellation: ${r.params.taskId}`);return{_meta:{},...s}}catch(o){throw o instanceof A?o:new A(j.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,s=!1){this._timeoutInfo.set(t,{timeoutId:setTimeout(o,r),startTime:Date.now(),timeout:r,maxTotalTimeout:n,resetTimeoutOnProgress:s,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),A.fromError(j.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){if(this._transport)throw new Error("Already connected to a transport. Call close() before connecting to a new transport, or use a separate Protocol instance per connection.");this._transport=t;let r=this.transport?.onclose;this._transport.onclose=()=>{r?.(),this._onclose()};let n=this.transport?.onerror;this._transport.onerror=s=>{n?.(s),this._onerror(s)};let o=this._transport?.onmessage;this._transport.onmessage=(s,i)=>{o?.(s,i),gn(s)||Qm(s)?this._onresponse(s):Na(s)?this._onrequest(s,i):Xm(s)?this._onnotification(s):this._onerror(new Error(`Unknown message type: ${JSON.stringify(s)}`))},await this._transport.start()}_onclose(){let t=this._responseHandlers;this._responseHandlers=new Map,this._progressHandlers.clear(),this._taskProgressTokens.clear(),this._pendingDebouncedNotifications.clear();for(let n of this._timeoutInfo.values())clearTimeout(n.timeoutId);this._timeoutInfo.clear();for(let n of this._requestHandlerAbortControllers.values())n.abort();this._requestHandlerAbortControllers.clear();let r=A.fromError(j.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,s=t.params?._meta?.[Rt]?.taskId,i=o?.sessionId,a=this._taskStore,c=!0,u;if(s&&a&&this._taskMessageQueue&&i!==void 0&&(c=!1,u=(async()=>{if(!await a.getTask(s,i))throw new A(j.InvalidParams,`Task not found: ${s}`);c=!0})()),n===void 0){let m={jsonrpc:"2.0",id:t.id,error:{code:j.MethodNotFound,message:"Method not found"}};if(s&&u){let h={type:"error",message:m,timestamp:Date.now()};u.then(()=>this._enqueueTaskMessage(s,h,i),()=>o?.send(m)).catch(g=>this._onerror(new Error(`Failed to send an error response: ${g}`)))}else s&&this._taskMessageQueue?this._enqueueTaskMessage(s,{type:"error",message:m,timestamp:Date.now()},o?.sessionId).catch(h=>this._onerror(new Error(`Failed to enqueue error response: ${h}`))):o?.send(m).catch(h=>this._onerror(new Error(`Failed to send an error response: ${h}`)));return}let l=new AbortController;this._requestHandlerAbortControllers.set(t.id,l);let d=Gm(t.params)?t.params.task:void 0,f=this._taskStore?this.requestTaskStore(t,o?.sessionId):void 0,p={signal:l.signal,sessionId:o?.sessionId,_meta:t.params?._meta,sendNotification:async m=>{if(l.signal.aborted)return;let h={relatedRequestId:t.id};s&&(h.relatedTask={taskId:s}),await this.notification(m,h)},sendRequest:async(m,h,g)=>{if(l.signal.aborted)throw new A(j.ConnectionClosed,"Request was cancelled");let y={...g,relatedRequestId:t.id};s&&!y.relatedTask&&(y.relatedTask={taskId:s});let v=y.relatedTask?.taskId??s;return v&&f&&await f.updateTaskStatus(v,"input_required"),await this.request(m,h,y)},authInfo:r?.authInfo,requestId:t.id,requestInfo:r?.requestInfo,taskId:s,taskStore:f,taskRequestedTtl:d?.ttl,closeSSEStream:r?.closeSSEStream,closeStandaloneSSEStream:r?.closeStandaloneSSEStream};(u??Promise.resolve()).then(()=>{if(u&&l.signal.aborted)throw new A(j.ConnectionClosed,"Request was cancelled");d&&this.assertTaskHandlerCapability(t.method)}).then(()=>n(t,p)).then(async m=>{if(l.signal.aborted)return;let h={result:m,jsonrpc:"2.0",id:t.id};s&&this._taskMessageQueue?await this._enqueueTaskMessage(s,{type:"response",message:h,timestamp:Date.now()},o?.sessionId):await o?.send(h)},async m=>{if(l.signal.aborted)return;let h={jsonrpc:"2.0",id:t.id,error:{code:Number.isSafeInteger(m.code)?m.code:j.InternalError,message:m.message??"Internal error",...m.data!==void 0&&{data:m.data}}};s&&this._taskMessageQueue&&c?await this._enqueueTaskMessage(s,{type:"error",message:h,timestamp:Date.now()},o?.sessionId):await o?.send(h)}).catch(m=>this._onerror(new Error(`Failed to send response: ${m}`))).finally(()=>{this._requestHandlerAbortControllers.get(t.id)===l&&this._requestHandlerAbortControllers.delete(t.id)})}_onprogress(t){let{progressToken:r,...n}=t.params,o=Number(r),s=this._progressHandlers.get(o);if(!s){this._onerror(new Error(`Received a progress notification for an unknown token: ${JSON.stringify(t)}`));return}let i=this._responseHandlers.get(o),a=this._timeoutInfo.get(o);if(a&&i&&a.resetTimeoutOnProgress)try{this._resetTimeout(o)}catch(c){this._responseHandlers.delete(o),this._progressHandlers.delete(o),this._cleanupTimeout(o),i(c);return}s(n)}_onresponse(t){let r=Number(t.id),n=this._requestResolvers.get(r);if(n){if(this._requestResolvers.delete(r),gn(t))n(t);else{let i=new A(t.error.code,t.error.message,t.error.data);n(i)}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 s=!1;if(gn(t)&&t.result&&typeof t.result=="object"){let i=t.result;if(i.task&&typeof i.task=="object"){let a=i.task;typeof a.taskId=="string"&&(s=!0,this._taskProgressTokens.set(a.taskId,r))}}if(s||this._progressHandlers.delete(r),gn(t))o(t);else{let i=A.fromError(t.error.code,t.error.message,t.error.data);o(i)}}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(i){yield{type:"error",error:i instanceof A?i:new A(j.InternalError,String(i))}}return}let s;try{let i=await this.request(t,kr,n);if(i.task)s=i.task.taskId,yield{type:"taskCreated",task:i.task};else throw new A(j.InternalError,"Task creation did not return a task");for(;;){let a=await this.getTask({taskId:s},n);if(yield{type:"taskStatus",task:a},Zt(a.status)){a.status==="completed"?yield{type:"result",result:await this.getTaskResult({taskId:s},r,n)}:a.status==="failed"?yield{type:"error",error:new A(j.InternalError,`Task ${s} failed`)}:a.status==="cancelled"&&(yield{type:"error",error:new A(j.InternalError,`Task ${s} was cancelled`)});return}if(a.status==="input_required"){yield{type:"result",result:await this.getTaskResult({taskId:s},r,n)};return}let c=a.pollInterval??this._options?.defaultTaskPollInterval??1e3;await new Promise(u=>setTimeout(u,c)),n?.signal?.throwIfAborted()}}catch(i){yield{type:"error",error:i instanceof A?i:new A(j.InternalError,String(i))}}}request(t,r,n){let{relatedRequestId:o,resumptionToken:s,onresumptiontoken:i,task:a,relatedTask:c}=n??{};return new Promise((u,l)=>{let d=v=>{l(v)};if(!this._transport){d(new Error("Not connected"));return}if(this._options?.enforceStrictCapabilities===!0)try{this.assertCapabilityForMethod(t.method),a&&this.assertTaskCapability(t.method)}catch(v){d(v);return}n?.signal?.throwIfAborted();let f=this._requestMessageId++,p={...t,jsonrpc:"2.0",id:f};n?.onprogress&&(this._progressHandlers.set(f,n.onprogress),p.params={...t.params,_meta:{...t.params?._meta||{},progressToken:f}}),a&&(p.params={...p.params,task:a}),c&&(p.params={...p.params,_meta:{...p.params?._meta||{},[Rt]:c}});let m=v=>{this._responseHandlers.delete(f),this._progressHandlers.delete(f),this._cleanupTimeout(f),this._transport?.send({jsonrpc:"2.0",method:"notifications/cancelled",params:{requestId:f,reason:String(v)}},{relatedRequestId:o,resumptionToken:s,onresumptiontoken:i}).catch(T=>this._onerror(new Error(`Failed to send cancellation: ${T}`)));let k=v instanceof A?v:new A(j.RequestTimeout,String(v));l(k)};this._responseHandlers.set(f,v=>{if(!n?.signal?.aborted){if(v instanceof Error)return l(v);try{let k=Dt(r,v.result);k.success?u(k.data):l(k.error)}catch(k){l(k)}}}),n?.signal?.addEventListener("abort",()=>{m(n?.signal?.reason)});let h=n?.timeout??wk,g=()=>m(A.fromError(j.RequestTimeout,"Request timed out",{timeout:h}));this._setupTimeout(f,h,n?.maxTotalTimeout,g,n?.resetTimeoutOnProgress??!1);let y=c?.taskId;if(y){let v=k=>{let T=this._responseHandlers.get(f);T?T(k):this._onerror(new Error(`Response handler missing for side-channeled request ${f}`))};this._requestResolvers.set(f,v),this._enqueueTaskMessage(y,{type:"request",message:p,timestamp:Date.now()}).catch(k=>{this._cleanupTimeout(f),l(k)})}else this._transport.send(p,{relatedRequestId:o,resumptionToken:s,onresumptiontoken:i}).catch(v=>{this._cleanupTimeout(f),l(v)})})}async getTask(t,r){return this.request({method:"tasks/get",params:t},us,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},fs,r)}async cancelTask(t,r){return this.request({method:"tasks/cancel",params:t},rh,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 a={...t,jsonrpc:"2.0",params:{...t.params,_meta:{...t.params?._meta||{},[Rt]:r.relatedTask}}};await this._enqueueTaskMessage(n,{type:"notification",message:a,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 a={...t,jsonrpc:"2.0"};r?.relatedTask&&(a={...a,params:{...a.params,_meta:{...a.params?._meta||{},[Rt]:r.relatedTask}}}),this._transport?.send(a,r).catch(c=>this._onerror(c))});return}let i={...t,jsonrpc:"2.0"};r?.relatedTask&&(i={...i,params:{...i.params,_meta:{...i.params?._meta||{},[Rt]:r.relatedTask}}}),await this._transport.send(i,r)}setRequestHandler(t,r){let n=rc(t);this.assertRequestHandlerCapability(n),this._requestHandlers.set(n,(o,s)=>{let i=nc(t,o);return Promise.resolve(r(i,s))})}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=rc(t);this._notificationHandlers.set(n,o=>{let s=nc(t,o);return Promise.resolve(r(s))})}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??this._transport?.sessionId,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"&&Na(o.message)){let s=o.message.id,i=this._requestResolvers.get(s);i?(i(new A(j.InternalError,"Task cancelled or completed")),this._requestResolvers.delete(s)):this._onerror(new Error(`Resolver missing for request ${s} during task ${t} cleanup`))}}}async _waitForTaskUpdate(t,r,n){let o=this._options?.defaultTaskPollInterval??1e3;try{let s=await this._taskStore?.getTask(t,n);s?.pollInterval&&(o=s.pollInterval)}catch{}return new Promise((s,i)=>{if(r.aborted){i(new A(j.InvalidRequest,"Request cancelled"));return}let a=setTimeout(s,o);r.addEventListener("abort",()=>{clearTimeout(a),i(new A(j.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 s=await n.getTask(o,r);if(!s)throw new A(j.InvalidParams,"Failed to retrieve task: Task not found");return s},storeTaskResult:async(o,s,i)=>{await n.storeTaskResult(o,s,i,r);let a=await n.getTask(o,r);if(a){let c=vn.parse({method:"notifications/tasks/status",params:a});await this.notification(c),Zt(a.status)&&this._cleanupTaskProgressHandler(o)}},getTaskResult:o=>n.getTaskResult(o,r),updateTaskStatus:async(o,s,i)=>{let a=await n.getTask(o,r);if(!a)throw new A(j.InvalidParams,`Task "${o}" not found - it may have been cleaned up`);if(Zt(a.status))throw new A(j.InvalidParams,`Cannot update task "${o}" from terminal status "${a.status}" to "${s}". Terminal states (completed, failed, cancelled) cannot transition to other states.`);await n.updateTaskStatus(o,s,i,r);let c=await n.getTask(o,r);if(c){let u=vn.parse({method:"notifications/tasks/status",params:c});await this.notification(u),Zt(c.status)&&this._cleanupTaskProgressHandler(o)}},listTasks:o=>n.listTasks(o,r)}}};function jh(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function Dh(e,t){let r={...e};for(let n in t){let o=n,s=t[o];if(s===void 0)continue;let i=r[o];jh(i)&&jh(s)?r[o]={...i,...s}:r[o]=s}return r}var M_=bl(Ju(),1),q_=bl(Z_(),1);function RE(){let e=new M_.default({strict:!1,validateFormats:!0,validateSchema:!1,allErrors:!0});return(0,q_.default)(e),e}var Vr=class{constructor(t){this._ajv=t??RE()}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 bi=class{constructor(t){this._server=t}requestStream(t,r,n){return this._server.requestStream(t,r,n)}createMessageStream(t,r){let n=this._server.getClientCapabilities();if((t.tools||t.toolChoice)&&!n?.sampling?.tools)throw new Error("Client does not support sampling tools capability.");if(t.messages.length>0){let o=t.messages[t.messages.length-1],s=Array.isArray(o.content)?o.content:[o.content],i=s.some(l=>l.type==="tool_result"),a=t.messages.length>1?t.messages[t.messages.length-2]:void 0,c=a?Array.isArray(a.content)?a.content:[a.content]:[],u=c.some(l=>l.type==="tool_use");if(i){if(s.some(l=>l.type!=="tool_result"))throw new Error("The last message must contain only tool_result content if any is present");if(!u)throw new Error("tool_result blocks are not matching any tool_use from the previous message")}if(u){let l=new Set(c.filter(f=>f.type==="tool_use").map(f=>f.id)),d=new Set(s.filter(f=>f.type==="tool_result").map(f=>f.toolUseId));if(l.size!==d.size||![...l].every(f=>d.has(f)))throw new Error("ids of tool_result blocks and tool_use blocks from previous message do not match")}}return this.requestStream({method:"sampling/createMessage",params:t},Sn,r)}elicitInputStream(t,r){let n=this._server.getClientCapabilities(),o=t.mode??"form";switch(o){case"url":{if(!n?.elicitation?.url)throw new Error("Client does not support url elicitation.");break}case"form":{if(!n?.elicitation?.form)throw new Error("Client does not support form elicitation.");break}}let s=o==="form"&&t.mode===void 0?{...t,mode:"form"}:t;return this.requestStream({method:"elicitation/create",params:s},Sr,r)}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 F_(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 L_(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 vi=class extends Ns{constructor(t,r){super(r),this._serverInfo=t,this._loggingLevels=new Map,this.LOG_LEVEL_SEVERITY=new Map(xn.options.map((n,o)=>[n,o])),this.isMessageIgnored=(n,o)=>{let s=this._loggingLevels.get(o);return s?this.LOG_LEVEL_SEVERITY.get(n)<this.LOG_LEVEL_SEVERITY.get(s):!1},this._capabilities=r?.capabilities??{},this._instructions=r?.instructions,this._jsonSchemaValidator=r?.jsonSchemaValidator??new Vr,this.setRequestHandler(Za,n=>this._oninitialize(n)),this.setNotificationHandler(Ma,()=>this.oninitialized?.()),this._capabilities.logging&&this.setRequestHandler(Ka,async(n,o)=>{let s=o.sessionId||o.requestInfo?.headers["mcp-session-id"]||void 0,{level:i}=n.params,a=xn.safeParse(i);return a.success&&this._loggingLevels.set(s,a.data),{}})}get experimental(){return this._experimental||(this._experimental={tasks:new bi(this)}),this._experimental}registerCapabilities(t){if(this.transport)throw new Error("Cannot register capabilities after connecting to transport");this._capabilities=Dh(this._capabilities,t)}setRequestHandler(t,r){let o=As(t)?.method;if(!o)throw new Error("Schema is missing a method literal");let s=Cs(o);if(typeof s!="string")throw new Error("Schema method literal must be a string");if(s==="tools/call"){let a=async(c,u)=>{let l=Dt(kn,c);if(!l.success){let m=l.error instanceof Error?l.error.message:String(l.error);throw new A(j.InvalidParams,`Invalid tools/call request: ${m}`)}let{params:d}=l.data,f=await Promise.resolve(r(c,u));if(d.task){let m=Dt(kr,f);if(!m.success){let h=m.error instanceof Error?m.error.message:String(m.error);throw new A(j.InvalidParams,`Invalid task creation result: ${h}`)}return m.data}let p=Dt(ms,f);if(!p.success){let m=p.error instanceof Error?p.error.message:String(p.error);throw new A(j.InvalidParams,`Invalid tools/call result: ${m}`)}return p.data};return super.setRequestHandler(t,a)}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){L_(this._clientCapabilities?.tasks?.requests,t,"Client")}assertTaskHandlerCapability(t){this._capabilities&&F_(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:Hm.includes(r)?r:Aa,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"},os)}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],s=o.some(u=>u.type==="tool_result"),i=t.messages.length>1?t.messages[t.messages.length-2]:void 0,a=i?Array.isArray(i.content)?i.content:[i.content]:[],c=a.some(u=>u.type==="tool_use");if(s){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(a.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},Ja,r):this.request({method:"sampling/createMessage",params:t},Sn,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},Sr,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"},s=await this.request({method:"elicitation/create",params:o},Sr,r);if(s.action==="accept"&&s.content&&o.requestedSchema)try{let a=this._jsonSchemaValidator.getValidator(o.requestedSchema)(s.content);if(!a.valid)throw new A(j.InvalidParams,`Elicitation response content does not match requested schema: ${a.errorMessage}`)}catch(i){throw i instanceof A?i:new A(j.InternalError,`Error validating elicitation response: ${i instanceof Error?i.message:String(i)}`)}return s}}}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},Ga,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"})}};import{appendFileSync as AE,existsSync as rl,mkdirSync as CE,readFileSync as nl,renameSync as NE,statSync as U_,writeFileSync as jE}from"node:fs";import{join as ao}from"node:path";var uo=500,V_=40,B_=40,H_=5,sl=e=>[...e].length;function ol(e){if(typeof e!="string"||e.trim()==="")throw new w("\u8981\u5199\u4E00\u53E5\u7406\u7531");let t=e.trim().replace(/\n/g," ");if(sl(t)>B_)throw new w(`\u7406\u7531\u6700\u591A ${B_} \u5B57`);return t}var Pe=(e,t)=>e<t?`${e}|${t}`:`${t}|${e}`;function co(e){let t=new Map;for(let r of e.cards)t.set(r.id,r.createdAt);for(let r of e.inspirations)t.set(r.id,r.createdAt);return t}function DE(e){let t=/^---\n([\s\S]*?)\n---\n?([\s\S]*)$/.exec(e);if(t===null)return{body:e.trim(),writtenAt:""};let r={};for(let o of t[1].split(`
|
|
70
|
+
`)){let s=o.indexOf(":");s>0&&(r[o.slice(0,s).trim()]=o.slice(s+1).trim())}let n;try{n=r.topics?JSON.parse(r.topics):void 0}catch{n=void 0}return{...r.summary?{summary:r.summary}:{},...Array.isArray(n)?{topics:n.filter(o=>typeof o=="string")}:{},body:t[2].trim(),writtenAt:r.writtenAt??""}}function ZE(e){return`---
|
|
71
71
|
${[...e.summary?[`summary: ${e.summary}`]:[],...e.topics?.length?[`topics: ${JSON.stringify(e.topics)}`]:[],`writtenAt: ${e.writtenAt}`].join(`
|
|
72
72
|
`)}
|
|
73
73
|
---
|
|
74
74
|
${e.body}
|
|
75
|
-
`}var
|
|
76
|
-
`))if(o.trim()!=="")try{let s=JSON.parse(o);(s.type==="link"||s.type==="cut")&&typeof s.from=="string"&&typeof s.to=="string"&&n.push(s)}catch{}return this.cache={stamp:r,records:n},n}append(t){this.store.assertWritable(),this.store.snapshotBeforeWrite();let n=(
|
|
77
|
-
`;
|
|
78
|
-
`:"")+JSON.stringify(
|
|
79
|
-
|
|
75
|
+
`}var Br=class{dir;cellsDir;linksFile;cache={stamp:"",records:[]};store;constructor(t){this.store=t,this.dir=ao(t.dir,"memory"),this.cellsDir=ao(this.dir,"cells"),this.linksFile=ao(t.dir,"links.jsonl")}pageFile(t){return t==="me"?ao(this.dir,"me.md"):(Ct(t),ao(this.cellsDir,`${t}.md`))}readPage(t){let r=this.pageFile(t);if(rl(r))try{return DE(nl(r,"utf8"))}catch{return}}writePage(t,r){if(this.store.assertWritable(),t!=="me"&&this.cellOf(t,!1),typeof r.body!="string"||r.body.trim()==="")throw new w("\u6B63\u6587\u4E0D\u80FD\u4E3A\u7A7A");let n=r.body.trim(),o=sl(n);if(o>uo)throw new w(`\u6B63\u6587 ${o} \u5B57\uFF0C\u4E0A\u9650 ${uo} \u5B57\uFF1A\u8BF7\u5408\u5E76\u76F8\u8FD1\u7684\u5185\u5BB9\u3001\u5220\u6389\u8FC7\u65F6\u7684\uFF0C\u7CBE\u7B80\u540E\u518D\u5199`);let s=typeof r.summary=="string"&&r.summary.trim()!==""?r.summary.trim().replace(/\n/g," "):void 0;if(s!==void 0&&sl(s)>V_)throw new w(`\u4E00\u53E5\u8BDD\u6982\u62EC\u6700\u591A ${V_} \u5B57`);let i;if(r.topics!==void 0){if(!Array.isArray(r.topics))throw new w("\u4E3B\u9898\u8BCD\u5E94\u4E3A\u6570\u7EC4");if(i=[...new Set(r.topics.filter(l=>typeof l=="string").map(l=>l.trim()).filter(Boolean))],i.length>H_)throw new w(`\u4E3B\u9898\u8BCD\u6700\u591A ${H_} \u4E2A`)}let a={...t!=="me"&&s?{summary:s}:{},...t!=="me"&&i?.length?{topics:i}:{},body:n,writtenAt:Oe()},c=this.pageFile(t);this.store.snapshotBeforeWrite(),CE(this.cellsDir,{recursive:!0});let u=`${c}.${process.pid}.tmp`;return jE(u,ZE(a),"utf8"),NE(u,c),a}debt(t){let r=this.readPage(t)?.writtenAt??"",n=0;for(let o of co(this.store.getItem(t)).values())o>r&&(n+=1);return n}records(){if(!rl(this.linksFile))return[];let t=U_(this.linksFile),r=`${t.mtimeMs}:${t.size}`;if(r===this.cache.stamp)return this.cache.records;let n=[];for(let o of nl(this.linksFile,"utf8").split(`
|
|
76
|
+
`))if(o.trim()!=="")try{let s=JSON.parse(o);(s.type==="link"||s.type==="cut"||s.type==="retitle"&&typeof s.why=="string")&&typeof s.from=="string"&&typeof s.to=="string"&&n.push(s)}catch{}return this.cache={stamp:r,records:n},n}append(t){if(t.length===0)return;this.store.assertWritable(),this.store.snapshotBeforeWrite();let n=(rl(this.linksFile)?U_(this.linksFile).size:0)>0&&nl(this.linksFile,"utf8").at(-1)!==`
|
|
77
|
+
`;AE(this.linksFile,(n?`
|
|
78
|
+
`:"")+t.map(o=>JSON.stringify(o)).join(`
|
|
79
|
+
`)+`
|
|
80
|
+
`,"utf8"),this.store.rev+=1}cellOf(t,r){Ct(t);let n=this.store.getPalace().cells.find(o=>o.id===t);if(n===void 0||!r&&n.kind==="group")throw new w("\u683C\u5B50\u4E0D\u5B58\u5728");return n}lastCut(t,r){let n="";for(let o of this.records())o.type==="cut"&&Pe(o.from,o.to)===Pe(t,r)&&o.createdAt>n&&(n=o.createdAt);return n}addLink(t){let r=this.cellOf(t.from,!1),n=this.cellOf(t.to,!1);if(r.id===n.id)throw new w("\u4E0D\u80FD\u8FDE\u5230\u81EA\u5DF1");let o=ol(t.why);if(!Array.isArray(t.evidence))throw new w("evidence \u5E94\u4E3A\u5361\u7247 / \u7075\u611F id \u7684\u6570\u7EC4");let s=[...new Set(t.evidence.filter(d=>typeof d=="string"))],i=co(this.store.getItem(r.id)),a=co(this.store.getItem(n.id)),c=s.filter(d=>!i.has(d)&&!a.has(d));if(c.length>0)throw new w(`\u8FD9\u4E9B\u8BC1\u636E\u4E0D\u5728\u4E24\u7AEF\u7684\u683C\u5B50\u91CC\uFF1A${c.join("\u3001")}`);if(!s.some(d=>i.has(d))||!s.some(d=>a.has(d)))throw new w("\u4E24\u7AEF\u90FD\u8981\u81F3\u5C11\u6709\u4E00\u5F20\u5361\u7247\u6216\u4E00\u6761\u7075\u611F\u4F5C\u4E3A\u8BC1\u636E");if(this.lastCut(r.id,n.id)!==""&&t.userAsked!==!0)throw new w("\u7528\u6237\u526A\u65AD\u8FC7\u8FD9\u4E24\u683C\u4E4B\u95F4\u7684\u7535\u5F27\uFF1A\u9664\u975E\u7528\u6237\u660E\u786E\u8981\u6C42\u91CD\u65B0\u8FDE\uFF0C\u5426\u5219\u4E0D\u8981\u518D\u8FDE");let u=new Set(this.validLinks().filter(d=>Pe(d.from,d.to)===Pe(r.id,n.id)).flatMap(d=>d.evidence));if(s.every(d=>u.has(d)))throw new w("\u8FD9\u4E9B\u8BC1\u636E\u5DF2\u7ECF\u8FDE\u8FC7\u4E86\uFF1B\u6709\u65B0\u7684\u5361\u7247\u6216\u7075\u611F\u518D\u8FDE");let l={type:"link",id:He("l"),from:r.id,to:n.id,why:o,evidence:s,...t.sessionId?{sessionId:t.sessionId}:{},createdAt:Oe()};return this.append([l]),l}previewImportedLinks(t){let r=this.records(),n=new Set(r.filter(l=>l.type==="cut").map(l=>Pe(l.from,l.to))),o=new Set(r.flatMap(l=>l.type==="link"&&l.sourceKey?[l.sourceKey]:[])),s=this.validLinks(),i=new Set(s.map(l=>l.sourceKey)),a=new Set(s.map(l=>Pe(l.from,l.to))),c=t.filter(l=>!n.has(Pe(l.from,l.to))),u=c.filter(l=>!i.has(l.sourceKey));return{pending:c.filter(l=>!o.has(l.sourceKey)),arcs:new Set(u.map(l=>Pe(l.from,l.to)).filter(l=>!a.has(l))).size,strands:u.length}}addImportedLinks(t){if(t.length===0)return;let{pending:r}=this.previewImportedLinks(t);this.append(r.map(n=>({...n,type:"link",id:He("l"),why:ol(n.why),createdAt:Oe()})))}retitleLink(t){let r=this.cellOf(t.from,!1).id,n=this.cellOf(t.to,!1).id,o=ol(t.why),s=this.arcs().find(i=>Pe(i.from,i.to)===Pe(r,n));if(!s)throw new w("\u8FD9\u4E24\u683C\u4E4B\u95F4\u6CA1\u6709\u6709\u6548\u7535\u5F27");s.why!==o&&this.append([{type:"retitle",from:r,to:n,why:o}])}cut(t){let r=this.cellOf(t.from,!0),n=this.cellOf(t.to,!0);this.append([{type:"cut",from:r.id,to:n.id,createdAt:Oe()}])}validLinks(){let t=new Map(this.store.getPalace().cells.filter(i=>i.kind!=="group").map(i=>[i.id,i])),r=new Map,n=i=>{let a=r.get(i);return a===void 0&&(a=co(this.store.getItem(i)),r.set(i,a)),a},o=this.records(),s=new Map;for(let i of o)if(i.type==="cut"){let a=Pe(i.from,i.to);i.createdAt>(s.get(a)??"")&&s.set(a,i.createdAt)}return o.filter(i=>{if(i.type!=="link"||!t.has(i.from)||!t.has(i.to)||i.createdAt<=(s.get(Pe(i.from,i.to))??""))return!1;let a=Array.isArray(i.evidence)?i.evidence:[];return a.some(c=>n(i.from).has(c))&&a.some(c=>n(i.to).has(c))})}arcs(){let t=new Map;for(let n of this.records())n.type==="cut"&&t.delete(Pe(n.from,n.to)),n.type==="retitle"&&t.set(Pe(n.from,n.to),n.why);let r=new Map;for(let n of this.validLinks()){let o=Pe(n.from,n.to),s=r.get(o);s?s.push(n):r.set(o,[n])}return[...r.values()].map(n=>{let o=n.reduce((s,i)=>i.createdAt>=s.createdAt?i:s);return{from:o.from,to:o.to,strands:n.length,why:t.get(Pe(o.from,o.to))??o.why,lastAt:o.createdAt,links:n}}).sort((n,o)=>o.strands-n.strands||(o.lastAt>n.lastAt?1:-1))}lastTouched(t,r){let n=t.createdAt,o=s=>{s!==void 0&&s>n&&(n=s)};if(t.kind!=="group"){let s=this.store.getItem(t.id);for(let i of co(s).values())o(i);for(let i of s.chapters)for(let a of i.sections)o(a.doneAt);o(this.readPage(t.id)?.writtenAt)}for(let s of r)(s.from===t.id||s.to===t.id)&&o(s.lastAt);return n}context(t){let r=t.maxChars??6e3,n=this.store.getPalace(),o=this.arcs(),s=t.itemId!==void 0?n.cells.find(p=>p.id===t.itemId&&p.kind!=="group"):void 0,i=new Set;if(s)for(let p of o)(p.from===s.id||p.to===s.id)&&i.add(p.from===s.id?p.to:p.from);let a=p=>n.cells.find(m=>m.id===p)?.title??p,c=p=>p.parentId?n.cells.find(m=>m.id===p.parentId)?.title:void 0,u=[];u.push("## Memory Palace\uFF1A\u8BB0\u5FC6"),u.push(`\u4E0B\u9762\u662F\u4F60\uFF08AI\uFF09\u5728\u5BAB\u6BBF\u91CC\u7EF4\u62A4\u7684\u8BB0\u5FC6\uFF0C\u5E2E\u52A9\u4F60\u8BA4\u8BC6\u7528\u6237\u3001\u628A\u7528\u6237\u7684\u60F3\u6CD5\u8FDE\u8D77\u6765\u3002\u7528\u6CD5\uFF1A
|
|
80
81
|
- \u7528\u6237\u900F\u9732\u4E86\u503C\u5F97\u957F\u671F\u8BB0\u4F4F\u7684\u4E8B\uFF08\u559C\u597D\u3001\u6B63\u5728\u7ECF\u5386\u7684\u4E8B\u3001\u6DF1\u5165\u804A\u8FC7\u7684\u8BDD\u9898\uFF09\uFF0C\u7528 palace_wiki_write(target="me") \u6574\u9875\u66F4\u65B0\u300C\u5173\u4E8E\u7528\u6237\u300D\uFF1B\u53EA\u8BB0\u7528\u6237\u8BF4\u8FC7\u6216\u505A\u8FC7\u7684\u4E8B\u5B9E\uFF0C\u4E0D\u7ED9\u7528\u6237\u8D34\u6027\u683C\u6807\u7B7E\u3002
|
|
81
82
|
- \u5728\u4E00\u683C\u91CC\u804A\u51FA\u4E86\u65B0\u7684\u8BA4\u8BC6\uFF0C\u7528 palace_wiki_write \u66F4\u65B0\u8FD9\u4E00\u683C\u7684 wiki\uFF1A\u53EA\u5199\u5361\u7247\u548C\u7075\u611F\u91CC\u6CA1\u6709\u7684\uFF08\u8FD9\u4E00\u683C\u5BF9\u7528\u6237\u610F\u5473\u7740\u4EC0\u4E48\u3001\u5361\u5728\u54EA\u3001\u53CD\u590D\u51FA\u73B0\u7684\u4E3B\u9898\u3001\u6CA1\u89E3\u51B3\u7684\u7591\u95EE\uFF09\uFF0C\u53E5\u672B\u7528 [^\u5361\u7247\u6216\u7075\u611F id] \u6807\u51FA\u4F9D\u636E\u3002
|
|
82
83
|
- \u7528\u6237\u7684\u60F3\u6CD5\u628A\u4E24\u683C\u8FDE\u5728\u4E00\u8D77\u65F6\uFF08\u4E24\u672C\u5C0F\u8BF4\u4E0D\u4F1A\u4E92\u76F8\u63D0\u53CA\uFF0C\u4F46\u7528\u6237\u7684\u5FF5\u5934\u4F1A\uFF09\uFF0C\u7528 palace_link \u8FDE\u4E00\u6761\u7535\u5F27\uFF0C\u4E24\u7AEF\u5404\u5E26\u81F3\u5C11\u4E00\u5F20\u5361\u7247\u6216\u7075\u611F\u4F5C\u8BC1\u636E\u3002
|
|
83
|
-
- \u6BCF\u9875\u4E0A\u9650 ${
|
|
84
|
+
- \u6BCF\u9875\u4E0A\u9650 ${uo} \u5B57\uFF0C\u8D85\u4E86\u4F1A\u88AB\u62D2\u7EDD\uFF1A\u5408\u5E76\u3001\u5220\u6389\u8FC7\u65F6\u7684\uFF0C\u518D\u6574\u9875\u91CD\u5199\u3002\u7EAF\u529F\u80FD\u6027\u7684\u8BF7\u6C42\uFF08\u52A0\u4E66\u3001\u5220\u4E66\uFF09\u4E0D\u7528\u7BA1\u8BB0\u5FC6\u3002
|
|
84
85
|
- \u522B\u7684\u683C\u5B50\u7684 wiki \u7528 palace_wiki_read \u8BFB\uFF1B\u4E0B\u9762\u7684\u7D22\u5F15\u53EF\u80FD\u53EA\u662F\u8282\u9009\uFF0C\u5168\u90E8\u683C\u5B50\u7528 palace_overview \u67E5\u3002`);let l=this.readPage("me");u.push(`### \u5173\u4E8E\u7528\u6237\uFF08me\uFF09
|
|
85
|
-
${l?l.body:"\uFF08\u8FD8\u6CA1\u6709\u8BB0\u5F55\uFF09"}`);let d=n.cells.filter(p=>p.kind!=="group");if(d.length>0){let p=d.map(v=>({c:v,at:this.lastTouched(v,o)})).sort((v
|
|
86
|
+
${l?l.body:"\uFF08\u8FD8\u6CA1\u6709\u8BB0\u5F55\uFF09"}`);let d=n.cells.filter(p=>p.kind!=="group");if(d.length>0){let p=d.map(v=>({c:v,at:this.lastTouched(v,o)})).sort((v,k)=>k.at>v.at?1:-1),m=[],h=[],g=u.join(`
|
|
86
87
|
|
|
87
|
-
`).length;for(let[v,{c
|
|
88
|
+
`).length;for(let[v,{c:k,at:T}]of p.entries()){let x=this.readPage(k.id),$=`- ${k.title} id=${k.id}${c(k)?` \u3014${c(k)}\u3015`:""}`+(x?.summary?` \xB7 ${x.summary}`:"")+(x?.topics?.length?` \xB7 ${x.topics.join("\u3001")}`:"")+` \xB7 ${T.slice(0,7)}`;(k.id===s?.id||i.has(k.id)||v<30)&&g+$.length<r*.7?(m.push($),g+=$.length+1):h.push(k.title)}let y=`### \u5BAB\u6BBF\u7D22\u5F15\uFF08\u6807\u9898 \xB7 \u4E00\u53E5\u8BDD \xB7 \u4E3B\u9898\u8BCD \xB7 \u6700\u8FD1\u6D3B\u8DC3\u6708\u4EFD\uFF09
|
|
88
89
|
${m.join(`
|
|
89
|
-
`)}`;h.length>0&&(
|
|
90
|
-
\u5176\u4F59 ${h.length} \u683C\uFF1A${h.join("\u3001").slice(0,Math.max(200,r-g-800))}`),u.push(
|
|
90
|
+
`)}`;h.length>0&&(y+=`
|
|
91
|
+
\u5176\u4F59 ${h.length} \u683C\uFF1A${h.join("\u3001").slice(0,Math.max(200,r-g-800))}`),u.push(y)}if(s){let p=this.readPage(s.id),m=this.debt(s.id),h=`### \u5F53\u524D\u683C\u5B50\u300A${s.title}\u300B\u7684 wiki
|
|
91
92
|
${p?p.body:"\uFF08\u8FD8\u6CA1\u5199\uFF09"}`;m>0&&(h+=`
|
|
92
|
-
\uFF08\u8FD9\u4E00\u9875\u4E4B\u540E\u65B0\u589E\u4E86 ${m} \u6761\u5361\u7247 / \u7075\u611F\uFF0C\u65B9\u4FBF\u65F6\u66F4\u65B0\uFF09`);let g=o.filter(
|
|
93
|
+
\uFF08\u8FD9\u4E00\u9875\u4E4B\u540E\u65B0\u589E\u4E86 ${m} \u6761\u5361\u7247 / \u7075\u611F\uFF0C\u65B9\u4FBF\u65F6\u66F4\u65B0\uFF09`);let g=o.filter(y=>y.from===s.id||y.to===s.id).slice(0,8);g.length>0&&(h+=`
|
|
93
94
|
\u7535\u5F27\uFF1A
|
|
94
|
-
${g.map(
|
|
95
|
+
${g.map(y=>`- \u2194 ${a(y.from===s.id?y.to:y.from)}\uFF08${y.strands} \u80A1\uFF09\uFF1A${y.why}`).join(`
|
|
95
96
|
`)}`),u.push(h)}let f=u.join(`
|
|
96
97
|
|
|
97
|
-
`);return f.length>r?f.slice(0,r):f}};var
|
|
98
|
-
`)}function
|
|
98
|
+
`);return f.length>r?f.slice(0,r):f}};import{createHash as ME}from"node:crypto";var $i=e=>ME("sha256").update(JSON.stringify(e)).digest("hex"),K_=(e,...t)=>`${e}_${$i(t).slice(0,10)}`;async function il(e,t,r,n,o=!1){let s=e.getPalace(),i=new Map(s.cells.map($=>[$.id,$])),a=new Map;for(let $ of s.cells)if($.kind!=="group")for(let P of e.getItem($.id).cards)P.importSource?.source===r.source&&a.set(P.importSource.key,{cell:$,card:P});let c=new Map,u=new Map,l=new Map,d=Oe();for(let $ of r.groups){let P=$.itemId??K_("c",r.source,$.key),F=i.get(P)??c.get(P);if($.itemId!==void 0&&(F===void 0||F.kind==="group"))throw new w("\u5BFC\u5165\u76EE\u6807\u5FC5\u987B\u662F\u5DF2\u6709\u7684\u4E66\u6216\u7B14\u8BB0\u683C\u5B50");F===void 0&&($.kind==="book"||$.cards.some(C=>!a.has(C.key)))&&(F={id:P,kind:$.kind??"note",title:$.title,href:$.href,parentId:null,col:0,row:0,createdAt:d},c.set(P,F)),F&&$.chapters?.length&&(c.has(P)||e.getItem(P).chapters.length===0)&&u.set(P,$.chapters);for(let C of $.cards){if(l.has(C.key))throw new w(`\u65B9\u6848\u91CC\u91CD\u590D\u51FA\u73B0\uFF1A${C.key}`);let D=a.get(C.key);if(D&&$.itemId!==void 0&&D.cell.id!==$.itemId)throw new w(`\u5DF2\u5BFC\u5165\u7684\u7B14\u8BB0\u7559\u5728\u539F\u683C\u5B50\uFF1A${C.key}`);let de=$i(C.type===void 0?[C.note,C.frontmatter]:[C.type,C.note,C.quote,C.sectionKey]),M={...D?.card??{id:K_("k",r.source,C.key),type:C.type??"thought",quote:C.quote,createdAt:d},note:D?.card.importSource?.digest===de?D.card.note:C.note,importSource:{source:r.source,key:C.key,digest:de,frontmatter:C.frontmatter}};l.set(C.key,{cell:D?.cell??F,card:M,previous:D?.card,sectionKey:C.sectionKey})}}let f=[],p=new Map;for(let $ of r.links){let P=l.get($.from),F=l.get($.to)??a.get($.to);if(!P||!F||P.cell.id===F.cell.id)continue;let C=JSON.stringify([$.from,$.to]),D=(p.get(C)??0)+1;p.set(C,D);let de=$i([r.source,C,D,P.cell.id,F.cell.id]);f.push({sourceKey:de,from:P.cell.id,to:F.cell.id,why:$.why,evidence:[P.card.id,F.card.id],fromPath:$.from,toPath:$.to})}let m=[...l.values()].filter(({previous:$,card:P})=>$===void 0||!o&&$.importSource?.digest!==P.importSource?.digest),{pending:h,arcs:g,strands:y}=t.previewImportedLinks(f.map(({sourceKey:$,from:P,to:F,why:C,evidence:D})=>({sourceKey:$,from:P,to:F,why:C,evidence:D}))),v={cells:c.size,cards:m.filter($=>!$.previous).length,updatedCards:m.filter($=>$.previous).length,arcs:g,strands:y},k=$i([r,[...l].map(([$,P])=>[$,P.cell.id,P.previous?.id]),f,h,[...u.keys()],v]);if(n===void 0)return{preview:!0,...v,token:k};if(n!==k)throw new w("\u7B14\u8BB0\u3001\u65B9\u6848\u6216\u5BAB\u6BBF\u5DF2\u53D8\u5316\uFF0C\u8BF7\u91CD\u65B0\u9884\u89C8\u5E76\u786E\u8BA4");(m.length||c.size||u.size)&&await e.mutate($=>{for(let P of c.values())Object.assign(P,En($.palace,null)),$.palace.cells.push(P),$.createItem(bt(P.id,null));for(let[P,F]of u)$.item(P).chapters=Is(F);for(let{cell:P,card:F,previous:C,sectionKey:D}of m){let de=$.item(P.id);D!==void 0&&(F.sectionId=de.chapters.flatMap(se=>se.sections).find(se=>se.loc===D)?.id);let{cards:M}=de,me=C===void 0?-1:M.findIndex(se=>se.id===C.id);me===-1?M.push(F):M[me]=F}}),t.addImportedLinks(h);let T=new Set(t.validLinks().map($=>$.sourceKey)),x=new Map;for(let{sourceKey:$,from:P,to:F,fromPath:C,toPath:D,evidence:de}of f)if(T.has($)&&x.set([P,F].sort().join(":"),{from:P,to:F,fromPath:C,toPath:D,evidence:de}),x.size===20)break;return{preview:!1,...v,links:[...x.values()]}}var al={book:"\u4E66",note:"\u7B14\u8BB0",group:"\u5206\u7EC4"},G_={excerpt:"\u6458\u5F55",thought:"\u60F3\u6CD5",mistake:"\u9519\u9898"};function J_(e,t,r){let n=`${al[t.kind]}\u300C${t.title}\u300D${t.subtitle?`\uFF08${t.subtitle}\uFF09`:""} id=${t.id}`;if(t.kind!=="group"){let o=e.getItem(t.id),s=Wt(o),i=_s(o),a=o.cards.filter(c=>c.type==="mistake"&&c.status==="todo").length;o.source!==null&&(n+=` \u539F\u6587 ${o.source.type}${o.source.type==="pdf"?` ${o.source.pageCount} \u9875`:""}`),s.total>0?n+=` \u8FDB\u5EA6 ${s.done}/${s.total} \u8282`:o.source?.type==="pdf"&&(n+="\uFF08\u8FD8\u6CA1\u6709\u76EE\u5F55\uFF09"),o.targetDate&&(n+=` \u76EE\u6807\u65E5\u671F ${o.targetDate}`),i?.perDay!==void 0&&i.remaining>0&&(n+=` \u6BCF\u5929\u7EA6 ${i.perDay} \u8282`),s.current&&(n+=` \u5F53\u524D\uFF1A${s.current.chapter.title} \u203A ${s.current.section.title}`),o.cards.length>0&&(n+=` \u5361\u7247 ${o.cards.length} \u5F20${a>0?`\uFF08\u5F85\u91CD\u505A\u9519\u9898 ${a}\uFF09`:""}`),o.inspirations.length>0&&(n+=` \u7075\u611F ${o.inspirations.length} \u6761`)}return t.id===r&&(n+=" \u2190 \u7528\u6237\u5F53\u524D\u6253\u5F00\u7684\u683C\u5B50"),n}function qE(e,t){let r=e.getPalace().cells;if(r.length===0)return"\u5BAB\u6BBF\u662F\u7A7A\u7684\u3002";let n=[];for(let o of r.filter(s=>s.parentId===null)){n.push(J_(e,o,t));for(let s of r.filter(i=>i.parentId===o.id))n.push(` ${J_(e,s,t)}`)}return n.join(`
|
|
99
|
+
`)}function FE(e,t){let r=e.getPalace().cells.find(a=>a.id===t);if(r===void 0||r.kind==="group")throw new w("\u683C\u5B50\u4E0D\u5B58\u5728");let n=e.getItem(t),o=n.chapters.length===0?"\uFF08\u8FD8\u6CA1\u6709\u76EE\u5F55\uFF09":n.chapters.map((a,c)=>`${c+1}. ${a.title}
|
|
99
100
|
${a.sections.map(u=>` - ${u.done?"[x]":"[ ]"} ${u.title} (section_id=${u.id})`).join(`
|
|
100
101
|
`)}`).join(`
|
|
101
|
-
`),s=n.cards.slice(-20).map(a=>`- ${
|
|
102
|
+
`),s=n.cards.slice(-20).map(a=>`- ${G_[a.type]} ${a.id}\uFF1A${(a.quote??a.note??"").slice(0,60)}`).join(`
|
|
102
103
|
`),i=n.inspirations.slice(-10).map(a=>`- ${a.id} ${a.createdAt.slice(0,10)} ${a.title}`).join(`
|
|
103
104
|
`);return`\u300A${r.title}\u300B\u76EE\u5F55\uFF1A
|
|
104
105
|
${o}`+(s?`
|
|
@@ -107,30 +108,33 @@ ${o}`+(s?`
|
|
|
107
108
|
${s}`:"")+(i?`
|
|
108
109
|
|
|
109
110
|
\u7075\u611F\uFF1A
|
|
110
|
-
${i}`:"")}function
|
|
111
|
-
${
|
|
111
|
+
${i}`:"")}function LE(e,t){let r=At(e,t.sectionId);return r?` ${r.chapter.title} \u203A ${r.section.title}`:""}async function Ie(e){try{return await e()}catch(t){if(t instanceof w)return`\u64CD\u4F5C\u5931\u8D25\uFF1A${t.message}`;throw t}}function UE(e,t){return{name:"palace_overview",description:"\u67E5\u770B\u7528\u6237\u7684 Memory Palace\uFF08\u8BB0\u5FC6\u5BAB\u6BBF\uFF09\uFF1A\u6240\u6709\u5206\u7EC4\u3001\u4E66\u3001\u7B14\u8BB0\u7684 id\u3001\u8FDB\u5EA6\u3001\u5361\u7247\u6570"+(t?"\uFF0C\u4EE5\u53CA\u7528\u6237\u5F53\u524D\u6253\u5F00\u7684\u662F\u54EA\u4E2A\u683C\u5B50":"")+"\u3002\u6D89\u53CA\u5BAB\u6BBF\u7684\u4EFB\u4F55\u64CD\u4F5C\u524D\u5148\u8C03\u7528\u5B83\u62FF\u5230 id\u3002\u4F20 item_id \u53EF\u67E5\u770B\u8FD9\u4E2A\u683C\u5B50\u7684\u5B8C\u6574\u76EE\u5F55\uFF08\u542B section_id\uFF09\u3001\u6700\u8FD1\u7684\u5361\u7247\u548C\u7075\u611F\u3002",parameters:{item_id:{type:"string",description:"\u53EF\u9009\uFF1A\u67E5\u770B\u8FD9\u4E2A\u683C\u5B50\u7684\u8BE6\u60C5"}},async execute(r,n){return Ie(async()=>r.item_id===void 0?qE(e,n.highlightId):FE(e,r.item_id))}}}function W_(e,t,r){let n=r.currentItem?{type:"string"}:{type:"string",minLength:1,required:!0,description:"\u76EE\u6807\u683C\u5B50 id"};return[UE(e,r.currentItem),{name:"palace_add",description:"\u5F80\u5BAB\u6BBF\u91CC\u653E\u4E1C\u897F\u3002kind=group \u65B0\u5EFA\u5206\u7EC4\uFF08title\uFF09\uFF1Bkind=note \u65B0\u5EFA\u7B14\u8BB0\u683C\u5B50\uFF08title\uFF0C\u7528\u4E8E\u6CA1\u6709\u539F\u6587\u7684\u4E1C\u897F\uFF1A\u65E5\u8BB0\u3001\u5FC3\u60C5\u3001\u8FFD\u5267\uFF09\uFF1Bkind=book \u6DFB\u52A0 PDF / EPUB\uFF08path \u4E3A\u7EDD\u5BF9\u8DEF\u5F84\uFF09\u6216\u89C6\u9891\uFF08url\uFF0C\u5267\u3001\u7EFC\u827A\u3001\u8BFE\u90FD\u7B97\uFF09\uFF0C\u53EF\u9009 title\u3001subtitle\uFF08\u5907\u6CE8\uFF1A\u683C\u5B50\u4E0A\u6807\u9898\u4E0A\u65B9\u7684\u4E00\u884C\u5C0F\u5B57\uFF0C\u7528\u6237\u60F3\u586B\u4EC0\u4E48\u90FD\u884C\uFF0C\u5E38\u89C1\u662F\u4F5C\u8005\u6216\u53E6\u4E00\u79CD\u8BED\u8A00\u7684\u4E66\u540D\uFF09\u3002title \u7528\u4E66\u7684\u539F\u540D\uFF0C\u5927\u5C0F\u5199\u7167\u539F\u4E66\uFF08\u5982 Invention of Nature\uFF09\uFF0C\u4E0D\u5E26\u6587\u4EF6\u540D\u91CC\u7684 - _ \u300A\u300B \u7B49\u7B26\u53F7\uFF1B\u5916\u6587\u4E66\u53EF\u628A\u4E2D\u6587\u8BD1\u540D\u653E subtitle\u3001target_date\uFF08YYYY-MM-DD\uFF09\u3002parent_id \u586B\u5206\u7EC4 id \u53EF\u4EE5\u76F4\u63A5\u653E\u8FDB\u5206\u7EC4\uFF08\u5206\u7EC4\u91CC\u4E0D\u80FD\u518D\u653E\u5206\u7EC4\uFF09\u3002"+r.videoHelp,parameters:{kind:{type:"string",enum:["group","note","book"],required:!0},title:{type:"string"},subtitle:{type:"string"},parent_id:{type:"string"},path:{type:"string",description:"book\uFF1APDF \u6216 EPUB \u7684\u7EDD\u5BF9\u8DEF\u5F84"},url:{type:"string",description:"book\uFF1A\u89C6\u9891\u94FE\u63A5\uFF08http / https\uFF09"},target_date:{type:"string"}},async execute(o,s){return Ie(async()=>{if(o.kind!=="book"){let u=await jt(e,{kind:o.kind,title:o.title,subtitle:o.subtitle,parentId:o.parent_id});return`\u5DF2\u65B0\u5EFA${al[u.kind]}\u300C${u.title}\u300D id=${u.id}`}let i=await r.addBook({file:o.path,url:o.url,title:o.title,subtitle:o.subtitle,parentId:o.parent_id,targetDate:o.target_date},s.signal),a=e.getItem(i.id),c=Wt(a).total;return a.source?.type==="video"?c>0?`\u5DF2\u6DFB\u52A0\u89C6\u9891\u300A${i.title}\u300B id=${i.id}\uFF0C\u5171 ${c} \u96C6\u3002`:`\u5DF2\u6DFB\u52A0\u89C6\u9891\u300A${i.title}\u300B id=${i.id}\uFF0C\u8FD8\u6CA1\u6709\u5206\u96C6\u76EE\u5F55\u3002\u5148\u544A\u8BC9\u7528\u6237\u5DF2\u7ECF\u653E\u8FDB\u6765\u4E86\uFF0C\u95EE\u8981\u4E0D\u8981\u4E0A\u7F51\u67E5\u5206\u96C6\u548C\u6BCF\u4E00\u96C6\u7684\u94FE\u63A5\uFF08\u8981\u82B1\u4E00\u4E24\u5206\u949F\uFF09\uFF1B\u7528\u6237\u5DF2\u7ECF\u8981\u4E86\u76EE\u5F55\u5C31\u76F4\u63A5\u67E5\uFF0C\u67E5\u597D\u7528 palace_set_outline \u5199\u5165\u3002`:a.source?.type==="epub"?`\u5DF2\u6DFB\u52A0\u300A${i.title}\u300B id=${i.id}\u3002\u7528\u6237\u7B2C\u4E00\u6B21\u5728\u7B14\u8BB0\u672C\u91CC\u6253\u5F00\u9605\u8BFB\u65F6\u4F1A\u81EA\u52A8\u8BFB\u51FA\u76EE\u5F55\u3002`:`\u5DF2\u6DFB\u52A0\u300A${i.title}\u300B id=${i.id}\uFF0C\u5171 ${a.source?.type==="pdf"?a.source.pageCount:"?"} \u9875\u3002`+(c>0?`\u5DF2\u4ECE PDF \u4E66\u7B7E\u8BFB\u51FA\u76EE\u5F55\uFF1A${a.chapters.length} \u7AE0 ${c} \u8282\u3002`:"\u8FD9\u672C PDF \u6CA1\u6709\u4E66\u7B7E\uFF0C\u9700\u8981\u751F\u6210\u76EE\u5F55\uFF1A\u8BF7\u7528\u6237\u5728\u53F3\u4FA7\u7B14\u8BB0\u672C\u7684\u300C\u8FDB\u5EA6\u300D\u91CC\u52FE\u9009\u76EE\u5F55\u9875\uFF0C\u6216\u544A\u8BC9\u4F60\u76EE\u5F55\u5728\u7B2C\u51E0\u9875\uFF0C\u7136\u540E\u7528 palace_read \u8BFB\u53D6\u3002")})}},{name:"palace_remove",description:"\u4ECE\u5BAB\u6BBF\u91CC\u5220\u6389\u4E00\u4E2A\u683C\u5B50\uFF08\u4E66\u3001\u7B14\u8BB0\u6216\u7A7A\u5206\u7EC4\uFF09\uFF0C\u8FDE\u540C\u5B83\u7684\u8FDB\u5EA6\u3001\u5361\u7247\u548C\u7075\u611F\uFF0C\u4E0D\u5220\u7535\u8111\u4E0A\u7684\u539F\u6587\u4EF6\u3002\u5206\u7EC4\u91CC\u6700\u540E\u4E00\u683C\u5220\u6389\u6216\u79FB\u51FA\u540E\uFF0C\u5206\u7EC4\u4F1A\u81EA\u52A8\u6D88\u5931\uFF0C\u4E0D\u7528\u518D\u5220\u3002\u4E0D\u53EF\u64A4\u9500\uFF1A\u8C03\u7528\u524D\u5FC5\u987B\u5148\u8BF4\u6E05\u8981\u5220\u7684\u662F\u54EA\u4E00\u4E2A\u3001\u4F1A\u4E22\u6389\u591A\u5C11\u5361\u7247\u548C\u7075\u611F\uFF0C\u7B49\u7528\u6237\u660E\u786E\u540C\u610F\u540E\u518D\u8C03\u7528\u3002\u5206\u7EC4\u91CC\u8FD8\u6709\u4E1C\u897F\u65F6\u4E0D\u80FD\u5220\u3002",parameters:{item_id:{type:"string",required:!0}},async execute(o){return Ie(async()=>{let s=e.getPalace().cells.find(a=>a.id===o.item_id);if(s===void 0)throw new w("\u683C\u5B50\u4E0D\u5B58\u5728");let i=s.kind==="group"?void 0:e.getItem(s.id);return await zs(e,{id:s.id}),`\u5DF2\u5220\u9664${al[s.kind]}\u300C${s.title}\u300D`+(i?`\uFF08\u5361\u7247 ${i.cards.length} \u5F20\u3001\u7075\u611F ${i.inspirations.length} \u6761\uFF09`:"")})}},{name:"palace_read",description:"\u8BFB\u53D6\u67D0\u672C PDF \u6307\u5B9A\u9875\u7684\u6587\u5B57\uFF08\u9875\u7801\u4E3A PDF \u7684\u9875\u5E8F\u53F7\uFF0C\u4ECE 1 \u5F00\u59CB\uFF0C\u4E0D\u662F\u4E66\u4E0A\u5370\u7684\u9875\u7801\uFF09\u3002\u7528\u4E8E\u8BFB\u53D6\u76EE\u5F55\u9875\u6765\u751F\u6210\u7AE0\u8282\u7ED3\u6784\u3002\u6BCF\u6B21\u6700\u591A 30 \u9875\u3002",parameters:{item_id:{type:"string",required:!0},pages:{type:"array",items:{type:"integer"},required:!0,description:"PDF \u9875\u5E8F\u53F7\u5217\u8868"}},async execute(o){return Ie(async()=>{let s=e.getItem(o.item_id).source;if(s?.type!=="pdf")throw new w("\u8FD9\u4E2A\u683C\u5B50\u4E0D\u662F PDF");let i=[...new Set(o.pages)].slice(0,30),a=await r.readPageTexts(s.path,i),c=a.filter(l=>l.text.length<r.scannedThreshold).map(l=>l.page),u=a.map(l=>`=== \u7B2C ${l.page} \u9875 ===
|
|
112
|
+
${l.text||"\uFF08\u65E0\u6587\u5B57\uFF09"}`).join(`
|
|
112
113
|
|
|
113
|
-
`);return
|
|
114
|
+
`);return c.length>0&&(u+=`
|
|
114
115
|
|
|
115
|
-
\u6CE8\u610F\uFF1A\u7B2C ${
|
|
116
|
-
${
|
|
117
|
-
`)}`})}},{name:"palace_add_card",description:"\u8BB0\u4E00\u5F20\u5361\u7247\u3002type=mistake \u9519\u9898\uFF1A\u7528\u6237\u53D1\u6765\u9519\u9898\u622A\u56FE\u5E76\u8BF4\u300C\u8BB0\u9519\u9898\u300D\u65F6\u8C03\u7528\uFF0C\u5148\u770B\u56FE\u628A\u9898\u76EE\u5B8C\u6574\u8F6C\u6210\u6587\u5B57\u5199\u8FDB quote\uFF08\u542B\u9009\u9879\uFF09\uFF0C\u80FD\u5224\u65AD\u7684\u8BDD\u628A\u7B54\u6848\u548C\u89E3\u6790\u5199\u8FDB answer\uFF1Btype=excerpt \u6458\u5F55\uFF1Aquote \u662F\u539F\u6587\uFF0Cnote \u662F\u7528\u6237\u7684\u60F3\u6CD5\uFF1Btype=thought \u60F3\u6CD5\uFF1A\u53EA\u6709 note\
|
|
118
|
-
\u4E00\u53E5\u8BDD\uFF1A${
|
|
119
|
-
\u4E3B\u9898\u8BCD\uFF1A${
|
|
116
|
+
\u6CE8\u610F\uFF1A\u7B2C ${c.join("\u3001")} \u9875\u6CA1\u6709\u6587\u5B57\u5C42\uFF08\u53EF\u80FD\u662F\u626B\u63CF\u4EF6\uFF09\u3002\u5982\u679C\u5BF9\u8BDD\u91CC\u9644\u6709\u8FD9\u4E9B\u9875\u7684\u56FE\u7247\uFF0C\u8BF7\u76F4\u63A5\u770B\u56FE\u8BC6\u522B\uFF1B`+r.scannedPageHelp),u})}},{name:"palace_set_outline",description:"\u5199\u5165\uFF08\u8986\u76D6\uFF09\u4E66\u7684\u76EE\u5F55\u7ED3\u6784\uFF0C\u53EA\u8981\u4E24\u7EA7\uFF1A\u7AE0 \u203A \u8282\u3002\u6CA1\u6709\u5206\u8282\u7684\u7AE0\uFF0Csections \u7559\u7A7A\u5373\u53EF\uFF08\u4F1A\u81EA\u52A8\u7B97\u4F5C\u4E00\u8282\uFF09\u3002\u6807\u9898\u4FDD\u6301\u539F\u4E66\u5199\u6CD5\uFF0C\u53BB\u6389\u9875\u7801\u548C\u7701\u7565\u53F7\u3002\u91CD\u65B0\u751F\u6210\u76EE\u5F55\u65F6\uFF0C\u6807\u9898\u4E0D\u53D8\u7684\u8282\u4F1A\u4FDD\u7559\u5B8C\u6210\u72B6\u6001\u3002\u9875\u7801 page \u53EF\u9009\uFF0C\u586B PDF \u9875\u5E8F\u53F7\uFF08\u4E66\u4E0A\u5370\u7684\u9875\u7801 + \u504F\u79FB\u91CF\uFF09\uFF1B\u4E0D\u786E\u5B9A\u5C31\u4E0D\u586B\u3002\u89C6\u9891\u7684\u6BCF\u4E00\u96C6\u53EF\u4EE5\u586B url\uFF08\u8FD9\u4E00\u96C6\u7684\u64AD\u653E\u94FE\u63A5\uFF0Chttp / https\uFF09\uFF0C\u7528\u6237\u70B9\u300C\u64AD\u653E\u300D\u76F4\u63A5\u6253\u5F00\uFF1B\u4E0D\u586B\u5C31\u6253\u5F00\u4F5C\u54C1\u94FE\u63A5\u3002",parameters:{item_id:{type:"string",required:!0},chapters:{type:"array",required:!0,items:{type:"object",additionalProperties:!1,properties:{title:{type:"string",required:!0},sections:{type:"array",items:{type:"object",additionalProperties:!1,properties:{title:{type:"string",required:!0},page:{type:"integer"},url:{type:"string"}}}}}}}},async execute(o){return Ie(async()=>{let s=!1;try{s=e.getItem(String(o.item_id)).source?.type==="video"}catch{}let i=u=>s?typeof u.url=="string"&&/^https?:\/\/\S+$/.test(u.url.trim())?{loc:u.url.trim()}:{}:Number.isInteger(u.page)?{loc:String(u.page)}:{},a=o.chapters.map(u=>({title:u.title,sections:(u.sections??[]).map(l=>({title:l.title,...i(l)}))})),c=await Es(e,{id:o.item_id,chapters:a,source:"ai"});return`\u5DF2\u5199\u5165\u76EE\u5F55\uFF1A${c.chapters.length} \u7AE0 ${Wt(c).total} \u8282\u3002\u7528\u6237\u53EF\u4EE5\u5728\u53F3\u4FA7\u7B14\u8BB0\u672C\u91CC\u67E5\u770B\u548C\u6253\u52FE\u3002`})}},{name:"palace_set_target_dates",description:"\u8BBE\u7F6E\u4E66\u7684\u76EE\u6807\u5B8C\u6210\u65E5\u671F\uFF08YYYY-MM-DD\uFF09\uFF0C\u7528\u4E8E\u89C4\u5212\u8FDB\u5EA6\u3002\u53EF\u4E00\u6B21\u8BBE\u7F6E\u591A\u672C\u3002\u89C4\u5212\u65F6\u53C2\u8003\u5404\u4E66\u7684\u8282\u6570\uFF0C\u5E76\u7ED9\u590D\u4E60\u7559\u51FA\u65F6\u95F4\u3002\u8BBE\u7F6E\u524D\u5148\u548C\u7528\u6237\u786E\u8BA4\u65B9\u6848\u3002",parameters:{items:{type:"array",required:!0,items:{type:"object",additionalProperties:!1,properties:{item_id:{type:"string",required:!0},target_date:{type:"string",required:!0}}}}},async execute(o){return Ie(async()=>{let s=[];for(let i of o.items){let a=await Ps(e,{id:i.item_id,targetDate:i.target_date}),c=e.getPalace().cells.find(l=>l.id===i.item_id)?.title??i.item_id,u=_s(a);s.push(`\u300A${c}\u300B\u2192 ${a.targetDate}`+(u?.perDay!==void 0?`\uFF0C\u5269 ${u.remaining} \u8282\uFF0C\u6BCF\u5929\u7EA6 ${u.perDay} \u8282`:""))}return`\u5DF2\u8BBE\u7F6E\uFF1A
|
|
117
|
+
${s.join(`
|
|
118
|
+
`)}`})}},{name:"palace_add_card",description:"\u8BB0\u4E00\u5F20\u5361\u7247\u3002type=mistake \u9519\u9898\uFF1A\u7528\u6237\u53D1\u6765\u9519\u9898\u622A\u56FE\u5E76\u8BF4\u300C\u8BB0\u9519\u9898\u300D\u65F6\u8C03\u7528\uFF0C\u5148\u770B\u56FE\u628A\u9898\u76EE\u5B8C\u6574\u8F6C\u6210\u6587\u5B57\u5199\u8FDB quote\uFF08\u542B\u9009\u9879\uFF09\uFF0C\u80FD\u5224\u65AD\u7684\u8BDD\u628A\u7B54\u6848\u548C\u89E3\u6790\u5199\u8FDB answer\uFF1Btype=excerpt \u6458\u5F55\uFF1Aquote \u662F\u539F\u6587\uFF0Cnote \u662F\u7528\u6237\u7684\u60F3\u6CD5\uFF1Btype=thought \u60F3\u6CD5\uFF1A\u53EA\u6709 note\u3002"+r.imageHelp+(r.currentItem?"item_id \u4E0D\u586B\u65F6\u8BB0\u5230\u7528\u6237\u5F53\u524D\u6253\u5F00\u7684\u683C\u5B50\uFF1B":"item_id \u586B\u76EE\u6807\u683C\u5B50 id\uFF1B")+"section_id \u4E0D\u586B\u65F6\uFF0C\u6458\u5F55\u548C\u9519\u9898\u9ED8\u8BA4\u6302\u5230\u5F53\u524D\u5728\u5B66\u7684\u90A3\u4E00\u8282\u3002",parameters:{type:{type:"string",enum:["mistake","excerpt","thought"],required:!0},quote:{type:"string",description:"\u539F\u6587\u6216\u9898\u76EE"},note:{type:"string",description:"\u60F3\u6CD5\u3001\u6279\u6CE8\u6216\u9519\u56E0\uFF08\u7528\u6237\u8BF4\u4E86\u624D\u586B\uFF09"},answer:{type:"string",description:"\u9519\u9898\u7684\u7B54\u6848\u4E0E\u89E3\u6790"},image:{type:"string",description:r.imageDescription},item_id:n,section_id:{type:"string"}},async execute(o,s){return Ie(async()=>{let i=o.item_id,a=e.getItem(i),c=o.section_id??(o.type==="thought"?void 0:Wt(a).current?.section.id),u=r.saveImage(o.image),l=await Ts(e,{id:i,type:o.type,quote:o.quote,note:o.note,answer:o.answer,image:u,sectionId:c});return`\u5DF2\u8BB0\u5165\u300A${e.getPalace().cells.find(f=>f.id===i)?.title}\u300B${LE(e.getItem(i),l)}\u7684${G_[l.type]}`+(o.image?u?"\uFF0C\u539F\u56FE\u5DF2\u4FDD\u5B58\u3002":"\u3002\uFF08\u6CA1\u6709\u627E\u5230\u539F\u56FE\uFF09":"\u3002")+(s.nudge?.(i,"wiki")??"")})}},{name:"palace_add_inspiration",description:"\u628A\u8FD9\u6B21\u5BF9\u8BDD\u5B58\u6210\u4E00\u6761\u300C\u7075\u611F\u300D\uFF1A\u7528\u6237\u8BF4\u300C\u5B58\u6210\u7075\u611F\u300D\u300C\u8BB0\u4E0B\u6765\u300D\u4E4B\u7C7B\u65F6\u8C03\u7528\u3002\u7528\u7528\u6237\u7684\u53E3\u543B\u3001\u7B80\u6D01\u5730\u603B\u7ED3\u8FD9\u6B21\u5BF9\u8BDD\u91CC\u7528\u6237\u7684\u60F3\u6CD5\u548C\u5F97\u51FA\u7684\u7ED3\u8BBA\uFF08\u4E0D\u662F\u590D\u8FF0 AI \u8BF4\u4E86\u4EC0\u4E48\uFF09\uFF0Cbody \u7528 Markdown\uFF0C\u51E0\u6BB5\u5373\u53EF\uFF1Btitle \u4E00\u53E5\u8BDD\u70B9\u9898\u3002"+(r.currentItem?"item_id \u4E0D\u586B\u65F6\u5B58\u5230\u7528\u6237\u5F53\u524D\u6253\u5F00\u7684\u683C\u5B50\u3002":"item_id \u5FC5\u987B\u586B\u76EE\u6807\u683C\u5B50 id\u3002"),parameters:{title:{type:"string",required:!0},body:{type:"string",required:!0},item_id:n,card_ids:{type:"array",items:{type:"string"},description:"\u53EF\u9009\uFF1A\u8FD9\u6B21\u5BF9\u8BDD\u6D89\u53CA\u7684\u5361\u7247"}},async execute(o,s){return Ie(async()=>{let i=o.item_id,a=await Os(e,{id:i,title:o.title,body:o.body,cardIds:o.card_ids,...s.attribution});return`\u5DF2\u5B58\u5230\u300A${e.getPalace().cells.find(u=>u.id===i)?.title}\u300B\u7684\u7075\u611F\uFF1A\u300C${a.title}\u300D id=${a.id}`+(s.nudge?.(i,"link")??"")+(s.nudge?.(i,"wiki")??"")})}},{name:"palace_wiki_read",description:"\u8BFB\u4E00\u9875\u8BB0\u5FC6\uFF1Atarget \u586B\u683C\u5B50 id \u8BFB\u8FD9\u4E00\u683C\u7684 wiki\uFF08\u4E00\u53E5\u8BDD\u3001\u4E3B\u9898\u8BCD\u3001\u6B63\u6587\uFF09\uFF0C\u586B me \u8BFB\u300C\u5173\u4E8E\u7528\u6237\u300D\u3002"+r.wikiReadHelp,parameters:{target:{type:"string",required:!0,description:"\u683C\u5B50 id \u6216 me"}},async execute(o){return Ie(async()=>{let s=t.readPage(o.target);if(o.target!=="me"){let i=e.getPalace().cells.find(c=>c.id===o.target);if(i===void 0||i.kind==="group")throw new w("\u683C\u5B50\u4E0D\u5B58\u5728");let a=t.debt(i.id);return s===void 0?`\u300A${i.title}\u300B\u8FD8\u6CA1\u6709 wiki\u3002`+(a>0?`\u5DF2\u6709 ${a} \u6761\u5361\u7247 / \u7075\u611F\uFF0C\u53EF\u4EE5\u7528 palace_overview \u67E5\u770B\u540E\u5199\u4E00\u9875\u3002`:""):`\u300A${i.title}\u300Bwiki\uFF08${s.writtenAt.slice(0,10)}\uFF09
|
|
119
|
+
\u4E00\u53E5\u8BDD\uFF1A${s.summary??"\uFF08\u65E0\uFF09"}
|
|
120
|
+
\u4E3B\u9898\u8BCD\uFF1A${s.topics?.join("\u3001")??"\uFF08\u65E0\uFF09"}
|
|
120
121
|
|
|
121
|
-
${
|
|
122
|
+
${s.body}`+(a>0?`
|
|
122
123
|
|
|
123
|
-
\uFF08\u8FD9\u4E00\u9875\u4E4B\u540E\u65B0\u589E\u4E86 ${
|
|
124
|
-
${o.body}`})}},{name:"palace_wiki_write",description:`\u6574\u9875\u91CD\u5199\u4E00\u9875\u8BB0\u5FC6\uFF08\u4F1A\u8986\u76D6\u65E7\u5185\u5BB9\uFF0C\u5148\u5728\u65E7\u5185\u5BB9\u57FA\u7840\u4E0A\u6539\uFF09\u3002\u6B63\u6587\u6700\u591A ${no} \u5B57\uFF0C\u8D85\u4E86\u4F1A\u88AB\u62D2\u7EDD\uFF1A\u5408\u5E76\u76F8\u8FD1\u7684\u3001\u5220\u6389\u8FC7\u65F6\u7684\u518D\u5199\u3002target=me\uFF1A\u5173\u4E8E\u7528\u6237\u7684\u957F\u671F\u8BB0\u5FC6\uFF0C\u5206\u300C\u957F\u671F\u300D\u300C\u6700\u8FD1\u300D\u4E24\u6BB5\uFF0C\u53EA\u8BB0\u7528\u6237\u8BF4\u8FC7\u6216\u505A\u8FC7\u7684\u4E8B\u5B9E\uFF08\u559C\u597D\u3001\u6B63\u5728\u7ECF\u5386\u7684\u4E8B\u3001\u6DF1\u5165\u804A\u8FC7\u7684\u8BDD\u9898\uFF09\uFF0C\u4E0D\u8D34\u6027\u683C\u6807\u7B7E\u3002target=\u683C\u5B50 id\uFF1A\u8FD9\u4E00\u683C\u7684 wiki\uFF0C\u53EA\u5199\u5361\u7247\u548C\u7075\u611F\u91CC\u6CA1\u6709\u7684\u4E1C\u897F\uFF08\u5BF9\u7528\u6237\u610F\u5473\u7740\u4EC0\u4E48\u3001\u5361\u5728\u54EA\u3001\u53CD\u590D\u51FA\u73B0\u7684\u4E3B\u9898\u3001\u6CA1\u89E3\u51B3\u7684\u7591\u95EE\uFF09\uFF0C\u53E5\u672B\u7528 [^\u5361\u7247\u6216\u7075\u611F id] \u6807\u51FA\u4F9D\u636E\uFF1Bsummary \u4E00\u53E5\u8BDD\uFF08\u226440 \u5B57\uFF09\uFF0Ctopics 3\u20135 \u4E2A\u4E3B\u9898\u8BCD\uFF08\u81EA\u7531\u586B\u5199\uFF0C\u8DE8\u683C\u5B50\u76F8\u901A\u7684\u8BCD\u66F4\u597D\uFF0C\u6BD4\u5982\u300C\u7B49\u5F85\u300D\u300C\u5B64\u72EC\u300D\uFF09\u3002`,parameters:{target:{type:"string",required:!0,description:"\u683C\u5B50 id \u6216 me"},body:{type:"string",required:!0,description:"Markdown \u6B63\u6587"},summary:{type:"string"},topics:{type:"array",items:{type:"string"}}},async execute(n){return Be(async()=>{let o=t.writePage(n.target,{body:n.body,summary:n.summary,topics:n.topics});return n.target==="me"?"\u5DF2\u66F4\u65B0\u300C\u5173\u4E8E\u7528\u6237\u300D\u3002":`\u5DF2\u66F4\u65B0\u300A${e.getPalace().cells.find(i=>i.id===n.target)?.title}\u300B\u7684 wiki`+(o.topics?.length?`\uFF08\u4E3B\u9898\u8BCD\uFF1A${o.topics.join("\u3001")}\uFF09`:"")+"\u3002"})}},{name:"palace_link",description:"\u5728\u4E24\u683C\u4E4B\u95F4\u8FDE\u4E00\u6761\u7535\u5F27\uFF08\u8054\u60F3\uFF09\uFF1A\u7528\u6237\u7684\u67D0\u4E2A\u60F3\u6CD5\u3001\u4E3B\u9898\u6216\u7591\u95EE\u628A\u8FD9\u4E24\u683C\u8FDE\u5728\u4E00\u8D77\u65F6\u8C03\u7528\u3002\u4E0D\u9700\u8981\u4E24\u672C\u4E66\u4E92\u76F8\u63D0\u53CA\uFF0C\u8FDE\u7684\u662F\u7528\u6237\u7684\u5FF5\u5934\u3002why \u4E00\u53E5\u8BDD\u8BF4\u6E05\u8FDE\u5728\u54EA\uFF08\u226440 \u5B57\uFF0C\u4F8B\u5982\u300C\u90FD\u5728\u5199\u7B49\u5F85\uFF1A\u76D6\u8328\u6BD4\u7B49\u7EFF\u706F\uFF0C\u4F60\u5728\u7B49 offer\u300D\uFF09\uFF1Bevidence \u586B\u4E24\u7AEF\u5404\u81F3\u5C11\u4E00\u5F20\u5361\u7247\u6216\u4E00\u6761\u7075\u611F\u7684 id\u3002\u540C\u6837\u7684\u8BC1\u636E\u4E0D\u80FD\u91CD\u590D\u8FDE\uFF1B\u6709\u65B0\u8BC1\u636E\u5C31\u518D\u8FDE\u4E00\u6761\uFF0C\u7535\u5F27\u4F1A\u53D8\u7C97\u3002\u7528\u6237\u526A\u65AD\u8FC7\u7684\u4E24\u683C\uFF0C\u9664\u975E\u7528\u6237\u660E\u786E\u8981\u6C42\uFF0C\u5426\u5219\u4E0D\u8981\u518D\u8FDE\u3002",parameters:{from:{type:"string",required:!0,description:"\u683C\u5B50 id"},to:{type:"string",required:!0,description:"\u683C\u5B50 id"},why:{type:"string",required:!0},evidence:{type:"array",items:{type:"string"},required:!0,description:"\u5361\u7247 / \u7075\u611F id"},user_asked:{type:"boolean",description:"\u7528\u6237\u660E\u786E\u8981\u6C42\u8FDE\uFF08\u526A\u65AD\u8FC7\u7684\u4E5F\u80FD\u91CD\u8FDE\uFF09"}},async execute(n,o){return Be(async()=>{let s=t.addLink({from:n.from,to:n.to,why:n.why,evidence:n.evidence,...o.attribution,userAsked:n.user_asked===!0}),i=e.getPalace().cells,a=t.arcs().find(c=>c.links.some(u=>u.id===s.id));return`\u5DF2\u8FDE\u4E0A\u300A${i.find(c=>c.id===s.from)?.title}\u300B\u2194\u300A${i.find(c=>c.id===s.to)?.title}\u300B\uFF1A${s.why}\uFF08\u73B0\u5728 ${a?.strands??1} \u80A1\uFF09`})}},{name:"palace_unlink",description:"\u526A\u65AD\u4E24\u683C\u4E4B\u95F4\u7684\u7535\u5F27\uFF08\u7528\u6237\u8BF4\u8FD9\u4E24\u4E2A\u6CA1\u5173\u7CFB\u3001\u8FDE\u9519\u4E86\u65F6\u8C03\u7528\uFF09\u3002\u4E4B\u524D\u7684\u8054\u60F3\u90FD\u4E0D\u518D\u663E\u793A\uFF0C\u4EE5\u540E\u4E5F\u4E0D\u4F1A\u81EA\u52A8\u518D\u8FDE\u3002",parameters:{from:{type:"string",required:!0},to:{type:"string",required:!0}},async execute(n){return Be(async()=>(t.cut({from:n.from,to:n.to}),"\u5DF2\u526A\u65AD\u3002"))}}]}function F_(e){return{name:"palace_context",description:"\u8BFB\u53D6 Memory Palace \u7684\u8BB0\u5FC6\u80CC\u666F\uFF0C\u53EF\u6307\u5B9A\u683C\u5B50 id\u3002",parameters:{item_id:{type:"string"}},async execute(t){return e.context({itemId:t.item_id})}}}function L_(e){return{name:"palace_open",description:"\u6253\u5F00\u6211\u7684\u8BB0\u5FC6\u5BAB\u6BBF\uFF1A\u8FD4\u56DE\u672C\u673A\u6D4F\u89C8\u5668\u53EF\u4EE5\u6253\u5F00\u7684\u5BAB\u6BBF\u7F51\u9875\u5730\u5740\u3002",parameters:{},async execute(){return e}}}import{closeSync as zI,copyFileSync as PI,existsSync as tl,mkdirSync as EI,openSync as II,readdirSync as TI,readSync as OI,statSync as RI}from"node:fs";import{homedir as tw}from"node:os";import{basename as ew,extname as _i,isAbsolute as rw,join as so}from"node:path";var U_="Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130 Safari/537.36",oo=class extends Error{};function V_(e){if(!/^https?:\/\//.test(e))return/BV[0-9A-Za-z]{10}/.test(e);try{let t=new URL(e).hostname;return t==="b23.tv"||t==="bilibili.com"||t.endsWith(".bilibili.com")}catch{return!1}}async function wI(e,t){let r=e.match(/BV[0-9A-Za-z]{10}/);if(r)return r[0];let n=e.match(/https?:\/\/b23\.tv\/[0-9A-Za-z]+/);if(n){let s=(await fetch(n[0],{redirect:"follow",headers:{"user-agent":U_},signal:H_(t)})).url.match(/BV[0-9A-Za-z]{10}/);if(s)return s[0]}throw new oo("\u6CA1\u6709\u8BC6\u522B\u5230 B \u7AD9\u89C6\u9891\u94FE\u63A5\uFF08\u9700\u8981\u5305\u542B BV \u53F7\uFF0C\u6216 b23.tv \u77ED\u94FE\uFF09")}async function bI(e,t){let r=await fetch(`https://api.bilibili.com/x/web-interface/view?bvid=${e}`,{headers:{"user-agent":U_,referer:"https://www.bilibili.com/"},signal:H_(t)});if(!r.ok)throw new oo(`B \u7AD9\u63A5\u53E3\u8BF7\u6C42\u5931\u8D25\uFF08HTTP ${r.status}\uFF09`);let n=await r.json();if(n.code!==0||n.data===void 0)throw new oo(`B \u7AD9\u8FD4\u56DE\u9519\u8BEF\uFF1A${n.message??n.code}`);return n.data}function H_(e){let t=AbortSignal.timeout(15e3);return e?AbortSignal.any([e,t]):t}async function B_(e,t){let r=await wI(e,t),n=await bI(r,t),o=`https://www.bilibili.com/video/${n.bvid}`,s=n.pages??[];if(s.length>1)return{title:n.title,url:o,chapters:[{title:"\u5168\u90E8\u89C6\u9891",episodes:s.map(a=>({title:a.part||`\u7B2C ${a.page} \u96C6`,url:`${o}?p=${a.page}`}))}]};let i=n.ugc_season;if(i!==void 0&&i.sections.some(a=>a.episodes.length>1)){let a=i.sections.filter(c=>c.episodes.length>0).map(c=>({title:i.sections.length===1?"\u5168\u90E8\u89C6\u9891":c.title,episodes:c.episodes.map(u=>({title:u.title,url:`https://www.bilibili.com/video/${u.bvid}`}))}));return{title:i.title||n.title,url:o,chapters:a}}return{title:n.title,url:o,chapters:[{title:"\u5168\u90E8\u89C6\u9891",episodes:[{title:n.title,url:o}]}]}}import{readFile as vI}from"node:fs/promises";import{createRequire as $I}from"node:module";import{dirname as xI,join as J_,sep as K_}from"node:path";var SI=$I(import.meta.url),G_;function kI(){return G_??=import("pdfjs-dist/legacy/build/pdf.mjs"),G_}function el(){return xI(SI.resolve("pdfjs-dist/package.json"))}async function X_(e){let t=await kI(),r=new Uint8Array(await vI(e)),n=el(),o=t.getDocument({data:r,cMapUrl:J_(n,"cmaps")+K_,cMapPacked:!0,standardFontDataUrl:J_(n,"standard_fonts")+K_,isEvalSupported:!1,disableFontFace:!0,verbosity:0});return{doc:await o.promise,close:()=>o.destroy()}}async function W_(e,t){try{let r=typeof t=="string"?await e.getDestination(t):t;if(!Array.isArray(r)||r.length===0)return;let n=r[0];if(typeof n=="number")return n+1;if(n!==null&&typeof n=="object")return await e.getPageIndex(n)+1}catch{}}function Y_(e){return e.replace(/\s+/g," ").trim()}async function Q_(e){let{doc:t,close:r}=await X_(e);try{let n=await t.getOutline()??[];for(;n.length===1&&n[0].items.length>0;)n=n[0].items;let o=[];for(let i of n){let a=[];for(let u of i.items){let l=Y_(u.title);l!==""&&a.push({title:l,page:await W_(t,u.dest)})}let c=Y_(i.title);c!==""&&o.push({title:c,page:await W_(t,i.dest),sections:a})}let s;try{let a=(await t.getMetadata()).info;typeof a?.Title=="string"&&a.Title.trim()!==""&&(s=a.Title.trim())}catch{}return{pageCount:t.numPages,title:s,outline:o}}finally{await r()}}async function gi(e,t){let{doc:r,close:n}=await X_(e);try{let o=[];for(let s of t){if(!Number.isInteger(s)||s<1||s>r.numPages)continue;let i=await r.getPage(s),a=await i.getTextContent(),c="";for(let u of a.items)"str"in u&&(c+=u.str,u.hasEOL&&(c+=`
|
|
124
|
+
\uFF08\u8FD9\u4E00\u9875\u4E4B\u540E\u65B0\u589E\u4E86 ${a} \u6761\u5361\u7247 / \u7075\u611F\uFF09`:"")}return s===void 0?"\u8FD8\u6CA1\u6709\u5173\u4E8E\u7528\u6237\u7684\u8BB0\u5F55\u3002":`\u5173\u4E8E\u7528\u6237\uFF08${s.writtenAt.slice(0,10)}\uFF09\uFF1A
|
|
125
|
+
${s.body}`})}},{name:"palace_wiki_write",description:`\u6574\u9875\u91CD\u5199\u4E00\u9875\u8BB0\u5FC6\uFF08\u4F1A\u8986\u76D6\u65E7\u5185\u5BB9\uFF0C\u5148\u5728\u65E7\u5185\u5BB9\u57FA\u7840\u4E0A\u6539\uFF09\u3002\u6B63\u6587\u6700\u591A ${uo} \u5B57\uFF0C\u8D85\u4E86\u4F1A\u88AB\u62D2\u7EDD\uFF1A\u5408\u5E76\u76F8\u8FD1\u7684\u3001\u5220\u6389\u8FC7\u65F6\u7684\u518D\u5199\u3002target=me\uFF1A\u5173\u4E8E\u7528\u6237\u7684\u957F\u671F\u8BB0\u5FC6\uFF0C\u5206\u300C\u957F\u671F\u300D\u300C\u6700\u8FD1\u300D\u4E24\u6BB5\uFF0C\u53EA\u8BB0\u7528\u6237\u8BF4\u8FC7\u6216\u505A\u8FC7\u7684\u4E8B\u5B9E\uFF08\u559C\u597D\u3001\u6B63\u5728\u7ECF\u5386\u7684\u4E8B\u3001\u6DF1\u5165\u804A\u8FC7\u7684\u8BDD\u9898\uFF09\uFF0C\u4E0D\u8D34\u6027\u683C\u6807\u7B7E\u3002target=\u683C\u5B50 id\uFF1A\u8FD9\u4E00\u683C\u7684 wiki\uFF0C\u53EA\u5199\u5361\u7247\u548C\u7075\u611F\u91CC\u6CA1\u6709\u7684\u4E1C\u897F\uFF08\u5BF9\u7528\u6237\u610F\u5473\u7740\u4EC0\u4E48\u3001\u5361\u5728\u54EA\u3001\u53CD\u590D\u51FA\u73B0\u7684\u4E3B\u9898\u3001\u6CA1\u89E3\u51B3\u7684\u7591\u95EE\uFF09\uFF0C\u53E5\u672B\u7528 [^\u5361\u7247\u6216\u7075\u611F id] \u6807\u51FA\u4F9D\u636E\uFF1Bsummary \u4E00\u53E5\u8BDD\uFF08\u226440 \u5B57\uFF09\uFF0Ctopics 3\u20135 \u4E2A\u4E3B\u9898\u8BCD\uFF08\u81EA\u7531\u586B\u5199\uFF0C\u8DE8\u683C\u5B50\u76F8\u901A\u7684\u8BCD\u66F4\u597D\uFF0C\u6BD4\u5982\u300C\u7B49\u5F85\u300D\u300C\u5B64\u72EC\u300D\uFF09\u3002`,parameters:{target:{type:"string",required:!0,description:"\u683C\u5B50 id \u6216 me"},body:{type:"string",required:!0,description:"Markdown \u6B63\u6587"},summary:{type:"string"},topics:{type:"array",items:{type:"string"}}},async execute(o){return Ie(async()=>{let s=t.writePage(o.target,{body:o.body,summary:o.summary,topics:o.topics});return o.target==="me"?"\u5DF2\u66F4\u65B0\u300C\u5173\u4E8E\u7528\u6237\u300D\u3002":`\u5DF2\u66F4\u65B0\u300A${e.getPalace().cells.find(a=>a.id===o.target)?.title}\u300B\u7684 wiki`+(s.topics?.length?`\uFF08\u4E3B\u9898\u8BCD\uFF1A${s.topics.join("\u3001")}\uFF09`:"")+"\u3002"})}},{name:"palace_link",description:"\u5728\u4E24\u683C\u4E4B\u95F4\u8FDE\u4E00\u6761\u7535\u5F27\uFF08\u8054\u60F3\uFF09\uFF1A\u7528\u6237\u7684\u67D0\u4E2A\u60F3\u6CD5\u3001\u4E3B\u9898\u6216\u7591\u95EE\u628A\u8FD9\u4E24\u683C\u8FDE\u5728\u4E00\u8D77\u65F6\u8C03\u7528\u3002\u4E0D\u9700\u8981\u4E24\u672C\u4E66\u4E92\u76F8\u63D0\u53CA\uFF0C\u8FDE\u7684\u662F\u7528\u6237\u7684\u5FF5\u5934\u3002why \u4E00\u53E5\u8BDD\u8BF4\u6E05\u8FDE\u5728\u54EA\uFF08\u226440 \u5B57\uFF0C\u4F8B\u5982\u300C\u90FD\u5728\u5199\u7B49\u5F85\uFF1A\u76D6\u8328\u6BD4\u7B49\u7EFF\u706F\uFF0C\u4F60\u5728\u7B49 offer\u300D\uFF09\uFF1Bevidence \u586B\u4E24\u7AEF\u5404\u81F3\u5C11\u4E00\u5F20\u5361\u7247\u6216\u4E00\u6761\u7075\u611F\u7684 id\u3002\u540C\u6837\u7684\u8BC1\u636E\u4E0D\u80FD\u91CD\u590D\u8FDE\uFF1B\u6709\u65B0\u8BC1\u636E\u5C31\u518D\u8FDE\u4E00\u6761\uFF0C\u7535\u5F27\u4F1A\u53D8\u7C97\u3002\u7528\u6237\u526A\u65AD\u8FC7\u7684\u4E24\u683C\uFF0C\u9664\u975E\u7528\u6237\u660E\u786E\u8981\u6C42\uFF0C\u5426\u5219\u4E0D\u8981\u518D\u8FDE\u3002\u53EA\u6539\u5DF2\u6709\u7535\u5F27\u7684\u9898\u8BCD\u65F6\u586B update_why=true\uFF0Cwhy \u4ECE\u4E24\u7AEF\u539F\u6587\u6458\u53D6\uFF0C\u7701\u7565 evidence\u3002",parameters:{from:{type:"string",required:!0,description:"\u683C\u5B50 id"},to:{type:"string",required:!0,description:"\u683C\u5B50 id"},why:{type:"string",required:!0},evidence:{type:"array",items:{type:"string"},description:"\u8FDE\u7EBF\u5FC5\u586B\uFF1A\u5361\u7247 / \u7075\u611F id"},update_why:{type:"boolean",description:"\u53EA\u66F4\u65B0\u73B0\u6709\u7535\u5F27\u7684\u9898\u8BCD"},user_asked:{type:"boolean",description:"\u7528\u6237\u660E\u786E\u8981\u6C42\u8FDE\uFF08\u526A\u65AD\u8FC7\u7684\u4E5F\u80FD\u91CD\u8FDE\uFF09"}},async execute(o,s){return Ie(async()=>{if(o.update_why===!0)return t.retitleLink({from:o.from,to:o.to,why:o.why}),"\u5DF2\u66F4\u65B0\u7535\u5F27\u9898\u8BCD\u3002";let i=t.addLink({from:o.from,to:o.to,why:o.why,evidence:o.evidence,...s.attribution,userAsked:o.user_asked===!0}),a=e.getPalace().cells,c=t.arcs().find(u=>u.links.some(l=>l.id===i.id));return`\u5DF2\u8FDE\u4E0A\u300A${a.find(u=>u.id===i.from)?.title}\u300B\u2194\u300A${a.find(u=>u.id===i.to)?.title}\u300B\uFF1A${i.why}\uFF08\u73B0\u5728 ${c?.strands??1} \u80A1\uFF09`})}},{name:"palace_unlink",description:"\u526A\u65AD\u4E24\u683C\u4E4B\u95F4\u7684\u7535\u5F27\uFF08\u7528\u6237\u8BF4\u8FD9\u4E24\u4E2A\u6CA1\u5173\u7CFB\u3001\u8FDE\u9519\u4E86\u65F6\u8C03\u7528\uFF09\u3002\u4E4B\u524D\u7684\u8054\u60F3\u90FD\u4E0D\u518D\u663E\u793A\uFF0C\u4EE5\u540E\u4E5F\u4E0D\u4F1A\u81EA\u52A8\u518D\u8FDE\u3002",parameters:{from:{type:"string",required:!0},to:{type:"string",required:!0}},async execute(o){return Ie(async()=>(t.cut({from:o.from,to:o.to}),"\u5DF2\u526A\u65AD\u3002"))}}]}function Y_(e,t,r){let n={type:"string",required:!0,description:"\u7528\u6237\u63D0\u4F9B\u7684\u7B14\u8BB0\u5E93\u6587\u4EF6\u5939\u7EDD\u5BF9\u8DEF\u5F84"};return[{name:"palace_scan_obsidian",description:"\u53EA\u8BFB\u626B\u63CF Obsidian \u7B14\u8BB0\u5E93\u3002\u5411\u7528\u6237\u8BE2\u95EE\u8DEF\u5F84\u540E\u8C03\u7528\uFF0C\u6309\u6587\u4EF6\u5939\u7EDF\u8BA1\u7BC7\u6570\u3001\u6807\u7B7E\u548C\u53EF\u89E3\u6790\u53CC\u94FE\uFF0C\u6BCF\u9875\u5217\u51FA\u6700\u591A 100 \u7BC7\u3002\u548C\u7528\u6237\u5546\u91CF\u5206\u683C\u65B9\u6848\u540E\u518D\u9884\u89C8\u3002",parameters:{path:n,offset:{type:"integer",description:"\u4E0B\u4E00\u9875\u8D77\u70B9\uFF0C\u4F7F\u7528\u4E0A\u6B21\u8FD4\u56DE\u7684 nextOffset"}},async execute(o,s){return Ie(async()=>JSON.stringify(await r.scan(o.path,o.offset,s.signal)))}},{name:"palace_import_obsidian",description:"\u5BFC\u5165 Obsidian \u7B14\u8BB0\u3002plan \u7701\u7565\u65F6\u6309\u6587\u4EF6\u5939\u5EFA\u683C\uFF1B\u6241\u5E73\u7B14\u8BB0\u5E93\u6309\u6807\u7B7E\u548C\u53CC\u94FE\u5546\u91CF\u5206\u683C\u3002plan \u6BCF\u4E2A\u76EE\u6807\u7528 paths \u6216 tags \u9009\u7B14\u8BB0\uFF0C\u4E8C\u9009\u4E00\uFF0C\u518D\u6307\u5B9A\u65B0\u683C\u5B50\u6807\u9898\u6216\u5DF2\u6709\u683C\u5B50 id\u3002\u5148\u7701\u7565 confirmation \u83B7\u53D6\u65B0\u589E\u683C\u5B50\u3001\u5361\u7247\u548C\u7535\u5F27\u7684\u9884\u89C8\uFF0C\u5411\u7528\u6237\u590D\u8FF0\u5E76\u7B49\u786E\u8BA4\uFF0C\u518D\u7528\u76F8\u540C\u65B9\u6848\u548C\u9884\u89C8\u7684 token \u8C03\u7528\u3002\u53CC\u94FE\u81EA\u52A8\u8FDE\u7EBF\u3002\u5BFC\u5165\u540E\u6309\u7ED3\u679C\u91CC\u7684\u4E24\u7AEF\u7B14\u8BB0\u8DEF\u5F84\u8BFB\u539F\u6587\uFF0C\u5FC5\u8981\u65F6\u7528 palace_link \u7684 update_why \u6539\u987A\u9898\u8BCD\u3002",parameters:{path:n,plan:{type:"array",items:{type:"object",additionalProperties:!1,properties:{title:{type:"string",description:"\u65B0\u7B14\u8BB0\u683C\u5B50\u6807\u9898"},item_id:{type:"string",description:"\u5DF2\u6709\u4E66\u6216\u7B14\u8BB0\u683C\u5B50 id"},paths:{type:"array",items:{type:"string"},description:"\u626B\u63CF\u8FD4\u56DE\u7684\u7B14\u8BB0\u76F8\u5BF9\u8DEF\u5F84"},tags:{type:"array",items:{type:"string"},description:"\u626B\u63CF\u8FD4\u56DE\u7684\u6807\u7B7E\uFF0C\u5339\u914D\u5176\u4E2D\u4EFB\u610F\u4E00\u4E2A\u5C31\u9009\u5165"}}}},confirmation:{type:"string",description:"\u4EC5\u5728\u7528\u6237\u786E\u8BA4\u540E\u4F20\u5165\u9884\u89C8\u8FD4\u56DE\u7684 token"}},async execute(o,s){return Ie(async()=>{if(o.confirmation!==void 0&&typeof o.confirmation!="string")throw new w("\u786E\u8BA4\u503C\u5FC5\u987B\u662F\u9884\u89C8\u8FD4\u56DE\u7684 token");let i=await r.prepare(o.path,o.plan,s.signal);return s.signal?.throwIfAborted(),JSON.stringify(await il(e,t,i,o.confirmation))})}}]}function X_(e,t,r){return[{name:"palace_scan_weread",description:"\u9884\u89C8\u5FAE\u4FE1\u8BFB\u4E66\u4E66\u67B6\u548C\u6709\u5212\u7EBF\u6216\u60F3\u6CD5\u7684\u4E66\u3002\u7528\u6237\u63D0\u51FA\u5BFC\u5165\u65F6\uFF0C\u5148\u7528\u8FD9\u4E9B\u4FE1\u606F\u5546\u91CF\u8981\u5BFC\u5165\u54EA\u4E9B\u4E66\u3002",parameters:{},async execute(n,{signal:o}){return Ie(async()=>JSON.stringify(await r.scan(o)))}},{name:"palace_import_weread",description:"\u628A\u9009\u4E2D\u7684\u5FAE\u4FE1\u8BFB\u4E66\u4E66\u548C\u7B14\u8BB0\u5BFC\u5165\u5BAB\u6BBF\u3002plan \u586B\u626B\u63CF\u5F97\u5230\u7684 bookId \u5217\u8868\u3002\u5148\u7701\u7565 confirmation \u8FDB\u884C\u9884\u89C8\uFF0C\u7B49\u7528\u6237\u786E\u8BA4\u540E\u7528\u540C\u4E00\u65B9\u6848\u548C\u9884\u89C8\u7684 token \u5199\u5165\u3002",parameters:{plan:{type:"array",required:!0,items:{type:"string"}},confirmation:{type:"string"}},async execute({plan:n,confirmation:o},{signal:s}){return Ie(async()=>{if(o!==void 0&&typeof o!="string")throw new w("\u8BF7\u4F7F\u7528\u9884\u89C8\u8FD4\u56DE\u7684 token");let i=await r.prepare(n,o!==void 0,s);if(s?.aborted)throw new w("\u5FAE\u4FE1\u8BFB\u4E66\u5BFC\u5165\u5DF2\u53D6\u6D88");return JSON.stringify(await il(e,t,i,o,!0))})}}]}function Q_(e,t=""){return{name:"palace_context",description:"\u8BFB\u53D6 Memory Palace \u7684\u8BB0\u5FC6\u80CC\u666F\uFF0C\u53EF\u6307\u5B9A\u683C\u5B50 id\u3002"+t,parameters:{item_id:{type:"string"}},async execute(r){return e.context({itemId:r.item_id})}}}function ew(e){return{name:"palace_open",description:"\u6253\u5F00\u6211\u7684\u8BB0\u5FC6\u5BAB\u6BBF\uFF1A\u8FD4\u56DE\u672C\u673A\u6D4F\u89C8\u5668\u53EF\u4EE5\u6253\u5F00\u7684\u5BAB\u6BBF\u7F51\u9875\u5730\u5740\u3002",parameters:{},async execute(){return e}}}import{closeSync as YE,copyFileSync as XE,existsSync as ul,mkdirSync as QE,openSync as eT,readdirSync as tT,readSync as rT,statSync as nT}from"node:fs";import{homedir as pw}from"node:os";import{basename as fw,extname as Si,isAbsolute as mw,join as fo}from"node:path";var tw="Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130 Safari/537.36",lo=class extends Error{};function rw(e){if(!/^https?:\/\//.test(e))return/BV[0-9A-Za-z]{10}/.test(e);try{let t=new URL(e).hostname;return t==="b23.tv"||t==="bilibili.com"||t.endsWith(".bilibili.com")}catch{return!1}}async function VE(e,t){let r=e.match(/BV[0-9A-Za-z]{10}/);if(r)return r[0];let n=e.match(/https?:\/\/b23\.tv\/[0-9A-Za-z]+/);if(n){let s=(await fetch(n[0],{redirect:"follow",headers:{"user-agent":tw},signal:nw(t)})).url.match(/BV[0-9A-Za-z]{10}/);if(s)return s[0]}throw new lo("\u6CA1\u6709\u8BC6\u522B\u5230 B \u7AD9\u89C6\u9891\u94FE\u63A5\uFF08\u9700\u8981\u5305\u542B BV \u53F7\uFF0C\u6216 b23.tv \u77ED\u94FE\uFF09")}async function BE(e,t){let r=await fetch(`https://api.bilibili.com/x/web-interface/view?bvid=${e}`,{headers:{"user-agent":tw,referer:"https://www.bilibili.com/"},signal:nw(t)});if(!r.ok)throw new lo(`B \u7AD9\u63A5\u53E3\u8BF7\u6C42\u5931\u8D25\uFF08HTTP ${r.status}\uFF09`);let n=await r.json();if(n.code!==0||n.data===void 0)throw new lo(`B \u7AD9\u8FD4\u56DE\u9519\u8BEF\uFF1A${n.message??n.code}`);return n.data}function nw(e){let t=AbortSignal.timeout(15e3);return e?AbortSignal.any([e,t]):t}async function ow(e,t){let r=await VE(e,t),n=await BE(r,t),o=`https://www.bilibili.com/video/${n.bvid}`,s=n.pages??[];if(s.length>1)return{title:n.title,url:o,chapters:[{title:"\u5168\u90E8\u89C6\u9891",episodes:s.map(a=>({title:a.part||`\u7B2C ${a.page} \u96C6`,url:`${o}?p=${a.page}`}))}]};let i=n.ugc_season;if(i!==void 0&&i.sections.some(a=>a.episodes.length>1)){let a=i.sections.filter(c=>c.episodes.length>0).map(c=>({title:i.sections.length===1?"\u5168\u90E8\u89C6\u9891":c.title,episodes:c.episodes.map(u=>({title:u.title,url:`https://www.bilibili.com/video/${u.bvid}`}))}));return{title:i.title||n.title,url:o,chapters:a}}return{title:n.title,url:o,chapters:[{title:"\u5168\u90E8\u89C6\u9891",episodes:[{title:n.title,url:o}]}]}}import{readFile as HE}from"node:fs/promises";import{createRequire as KE}from"node:module";import{dirname as JE,join as sw,sep as iw}from"node:path";var GE=KE(import.meta.url),aw;function WE(){return aw??=import("pdfjs-dist/legacy/build/pdf.mjs"),aw}function cl(){return JE(GE.resolve("pdfjs-dist/package.json"))}async function lw(e){let t=await WE(),r=new Uint8Array(await HE(e)),n=cl(),o=t.getDocument({data:r,cMapUrl:sw(n,"cmaps")+iw,cMapPacked:!0,standardFontDataUrl:sw(n,"standard_fonts")+iw,isEvalSupported:!1,disableFontFace:!0,verbosity:0});return{doc:await o.promise,close:()=>o.destroy()}}async function cw(e,t){try{let r=typeof t=="string"?await e.getDestination(t):t;if(!Array.isArray(r)||r.length===0)return;let n=r[0];if(typeof n=="number")return n+1;if(n!==null&&typeof n=="object")return await e.getPageIndex(n)+1}catch{}}function uw(e){return e.replace(/\s+/g," ").trim()}async function dw(e){let{doc:t,close:r}=await lw(e);try{let n=await t.getOutline()??[];for(;n.length===1&&n[0].items.length>0;)n=n[0].items;let o=[];for(let i of n){let a=[];for(let u of i.items){let l=uw(u.title);l!==""&&a.push({title:l,page:await cw(t,u.dest)})}let c=uw(i.title);c!==""&&o.push({title:c,page:await cw(t,i.dest),sections:a})}let s;try{let a=(await t.getMetadata()).info;typeof a?.Title=="string"&&a.Title.trim()!==""&&(s=a.Title.trim())}catch{}return{pageCount:t.numPages,title:s,outline:o}}finally{await r()}}async function ki(e,t){let{doc:r,close:n}=await lw(e);try{let o=[];for(let s of t){if(!Number.isInteger(s)||s<1||s>r.numPages)continue;let i=await r.getPage(s),a=await i.getTextContent(),c="";for(let u of a.items)"str"in u&&(c+=u.str,u.hasEOL&&(c+=`
|
|
125
126
|
`));o.push({page:s,text:c.replace(/[ \t]+/g," ").replace(/\n{3,}/g,`
|
|
126
127
|
|
|
127
|
-
`).trim()}),i.cleanup()}return o}finally{await n()}}var
|
|
128
|
+
`).trim()}),i.cleanup()}return o}finally{await n()}}var xi=20;function po(e){return e.startsWith("~/")?fo(pw(),e.slice(2)):e}async function zi(e,t,r,{readVideo:n=!0}={}){let o=()=>{if(r?.aborted)throw new w("\u5DF2\u53D6\u6D88")},s,i,a=[],c;if(typeof t.url=="string"&&t.url.trim()!==""){let u=t.url.trim();if(!n||!rw(u)){if(!/^https?:\/\/\S+$/.test(u))throw new w("\u89C6\u9891\u94FE\u63A5\u8981\u4EE5 http:// \u6216 https:// \u5F00\u5934");if(typeof t.title!="string"||t.title.trim()==="")throw new w(n?"\u4E0D\u662F B \u7AD9\u94FE\u63A5\u65F6\u8981\u586B\u4F5C\u54C1\u540D":"\u89C6\u9891\u94FE\u63A5\u8981\u586B\u4F5C\u54C1\u540D");return o(),jt(e,{kind:"book",title:t.title.trim(),subtitle:t.subtitle,source:{type:"video",url:u},parentId:t.parentId,targetDate:t.targetDate})}let l=await ow(u,r).catch(d=>{throw o(),new w(d.message)});s={type:"video",url:l.url},i=l.title,a=l.chapters.map(d=>({title:d.title,sections:d.episodes.map(f=>({title:f.title,loc:f.url}))})),c="video"}else if(typeof t.file=="string"&&t.file.trim()!==""){let u=po(t.file.trim().replace(/^['"]|['"]$/g,""));if(!mw(u))throw new w("\u8BF7\u63D0\u4F9B PDF \u7684\u5B8C\u6574\u8DEF\u5F84\uFF08\u4EE5 / \u5F00\u5934\uFF09");if(!ul(u)||!nT(u).isFile())throw new w(`\u627E\u4E0D\u5230\u6587\u4EF6\uFF1A${u}`);let l=Si(u).toLowerCase();if(l!==".pdf"&&l!==".epub")throw new w("\u76EE\u524D\u53EA\u652F\u6301 PDF \u548C EPUB \u6587\u4EF6");if(l===".epub"){if(!oT(u))throw new w("\u8FD9\u4E0D\u662F\u6709\u6548\u7684 EPUB \u6587\u4EF6\uFF08\u53EF\u80FD\u635F\u574F\u6216\u6CA1\u4E0B\u8F7D\u5B8C\u6574\uFF09");return s={type:"epub",path:u},i=fw(u,l),typeof t.title=="string"&&t.title.trim()!==""&&(i=t.title.trim()),o(),jt(e,{kind:"book",title:i,subtitle:t.subtitle,source:s,parentId:t.parentId,targetDate:t.targetDate})}let d=await dw(u).catch(f=>{throw new w(`PDF \u6253\u4E0D\u5F00\uFF1A${f.message}`)});s={type:"pdf",path:u,pageCount:d.pageCount},i=fw(u,Si(u)),a=d.outline.map(f=>({title:f.title,...f.page!==void 0?{loc:String(f.page)}:{},sections:f.sections.map(p=>({title:p.title,...p.page!==void 0?{loc:String(p.page)}:{}}))})),c="bookmarks"}else throw new w("\u8BF7\u9009\u62E9 PDF \u6587\u4EF6\uFF0C\u6216\u7C98\u8D34\u89C6\u9891\u94FE\u63A5");return typeof t.title=="string"&&t.title.trim()!==""&&(i=t.title.trim()),o(),jt(e,{kind:"book",title:i,subtitle:t.subtitle,source:s,parentId:t.parentId,targetDate:t.targetDate,outline:a,outlineSource:c})}function oT(e){let t=eT(e,"r");try{let r=Buffer.alloc(4);return rT(t,r,0,4,0)===4&&r.equals(Buffer.from([80,75,3,4]))}finally{YE(t)}}function sT(e){let t=e.match(/sha256:([0-9a-f]{8,64})/i)?.[1]?.toLowerCase();if(t===void 0)return;let r=process.env.DSH_HOME??fo(pw(),".dsh"),n=fo(r,"attachments","v1","objects",t.slice(0,2));if(!ul(n))return;let o=tT(n).find(s=>s.startsWith(t));return o===void 0?void 0:fo(n,o)}var iT=new Set([".png",".jpg",".jpeg",".webp",".gif"]);function hw(e,t){if(typeof t!="string"||t.trim()==="")return;let r=po(t.trim().replace(/^['"]|['"]$/g,"")),n=mw(r)&&ul(r)?r:sT(r);if(n===void 0)return;let o=iT.has(Si(n).toLowerCase())?Si(n).toLowerCase():".png",s=`${He("img")}${o}`;return e.assertWritable(),e.snapshotBeforeWrite(),QE(e.imagesDir,{recursive:!0}),XE(n,fo(e.imagesDir,s)),s}import{createHash as aT}from"node:crypto";import{constants as gw}from"node:fs";import{open as cT,readdir as uT,realpath as lT,stat as dT}from"node:fs/promises";import{isAbsolute as fT,join as yw,posix as zt}from"node:path";function pT(e,t,r){let n=e.replace(/^(?:\uFEFF)?(?:[ \t]*\r?\n)*/,"");if(/^ {0,3}#{1,6}(?:[ \t]|\r?\n|$)/.test(n)||/^ {0,3}\S[^\r\n]*\r?\n {0,3}(?:=+|-+)[ \t]*(?:\r?\n|$)/.test(n))return e;let o=zt.basename(t).replace(/\.md$/i,"").replace(/[\r\n]+/g," "),s=r.match(/\r?\n/)?.[0]??`
|
|
129
|
+
`;return`# ${o}${s}${s}${e}`}async function _w(e,t){if(typeof e!="string"||!fT(po(e)))throw new w("\u8BF7\u63D0\u4F9B Obsidian \u7B14\u8BB0\u5E93\u7684\u7EDD\u5BF9\u8DEF\u5F84");let r=[],n=[],o;try{if(o=await lT(po(e)),!(await dT(o)).isDirectory())throw new w("\u8BF7\u9009\u62E9 Obsidian \u7B14\u8BB0\u5E93\u6587\u4EF6\u5939");async function c(u){t?.throwIfAborted();let l=await uT(yw(o,u),{withFileTypes:!0});for(let d of l.sort((f,p)=>f.name.localeCompare(p.name))){if(t?.throwIfAborted(),d.name.startsWith("."))continue;let f=zt.join(u,d.name);if(d.isDirectory()){await c(f);continue}if(!d.isFile()||!/\.md$/i.test(d.name))continue;let p=await cT(yw(o,f),gw.O_RDONLY|gw.O_NOFOLLOW),m;try{m=await p.readFile({encoding:"utf8",signal:t})}finally{await p.close()}let h=/^(?:\uFEFF)?---[ \t]*\r?\n[\s\S]*?^---[ \t]*(?:\r?\n|$)/m.exec(m),g=h?.index===0?h[0]:void 0,y=m.slice(g?.length??0),v=/^tags:[ \t]*(.*)((?:\r?\n[ \t]*-[ \t]+[^\r\n]*)*)/m.exec(g??""),k=v?v[1]+v[2].replace(/^[ \t]*-[ \t]+/gm," "):"",T=new Set(k.match(/[\p{L}\p{N}_/-]+/gu)??[]),x=y.replace(/<!--[^]*?(?:-->|$)|%%[^]*?(?:%%|$)/g,P=>P.replace(/[^\r\n]/g," ")),$;for(let P of x.split(/\r?\n/)){let F=/^ {0,3}(`{3,}|~{3,})/.exec(P)?.[1];if(F&&!$){$=F;continue}if($){F?.startsWith($)&&P.trim()===F&&($=void 0);continue}let C=P.replace(/(`+)[^`]*\1/g,D=>" ".repeat(D.length));for(let D of C.matchAll(/(?:^|[\s((,。!?、;:])#([\p{L}\p{N}_/-]+)/gu))T.add(D[1]);for(let D of C.matchAll(/(!|\\)?\[\[([^\]\n]+)\]\]/g)){if(D[1])continue;let de=D[2].split(/[|#]/,1)[0].trim();if(!de)continue;let M=D.index,me=M+D[0].length,se=P.slice(0,M).split(/[。!?!?]/).at(-1)??"",Pt=P.slice(me).split(/[。!?!?]/,1)[0],_l=[...(se+D[0]+Pt).trim()],Hw=_l.length<=40?_l.join(""):[...se.trimEnd()].slice(-8).concat([...D[0]+Pt]).slice(0,40).join("").trim();n.push({from:f,to:de,why:Hw})}}r.push({key:f,note:pT(y,f,m),frontmatter:g,tags:[...T].sort()})}}await c("")}catch(c){throw t?.aborted||c instanceof w?c:new w("\u65E0\u6CD5\u8BFB\u53D6\u8FD9\u4E2A Obsidian \u7B14\u8BB0\u5E93\uFF0C\u8BF7\u786E\u8BA4\u8DEF\u5F84\u548C\u8BFB\u53D6\u6743\u9650")}let s=new Set(r.map(c=>c.key)),i=new Map;for(let{key:c}of r){let u=zt.basename(c).replace(/\.md$/i,""),l=i.get(u);l?l.push(c):i.set(u,[c])}let a=n.flatMap(c=>{let u=/\.md$/i.test(c.to)?c.to:c.to+".md",l=zt.normalize(zt.join(zt.dirname(c.from),u)),d=i.get(c.to.replace(/\.md$/i,"")),f=u.startsWith(".")?s.has(l)?l:void 0:u.includes("/")?s.has(u)?u:s.has(l)?l:void 0:s.has(l)?l:d?.length===1?d[0]:void 0;return f&&f!==c.from?[{...c,to:f}]:[]});return{root:o,notes:r,links:a,unresolved:n.length-a.length}}var ww={async scan(e,t,r){if(t!==void 0&&(typeof t!="number"||!Number.isSafeInteger(t)||t<0))throw new w("offset \u5E94\u4E3A\u975E\u8D1F\u6574\u6570");let{notes:n,links:o,unresolved:s}=await _w(e,r),i=Number(t??0),a=new Map,c=new Map;for(let l of o){let d=c.get(l.from);d?d.push(l.to):c.set(l.from,[l.to])}let u=n.map(({key:l,tags:d})=>{let f=zt.dirname(l),p=a.get(f)??{path:f,count:0,tags:new Set,links:0};a.set(f,p);let m=c.get(l)??[];p.count+=1;for(let h of d)p.tags.add(h);return p.links+=m.length,{path:l,tags:d,links:m}});return{count:n.length,links:o.length,unresolved:s,folders:[...a.values()].map(l=>({...l,tags:[...l.tags].sort()})),notes:u.slice(i,i+100),nextOffset:i+100<u.length?i+100:void 0}},async prepare(e,t,r){let{root:n,notes:o,links:s}=await _w(e,r);if(o.length===0)throw new w("\u8FD9\u4E2A\u6587\u4EF6\u5939\u6CA1\u6709 Markdown \u7B14\u8BB0");let i="obsidian:"+aT("sha256").update(n).digest("hex"),a=[];if(t===void 0){let c=new Map;for(let u of o){let l=zt.dirname(u.key),d=c.get(l)??{key:"folder:"+l,title:zt.basename(l==="."?n:l)||"Obsidian",cards:[]};c.set(l,d),d.cards.push(u)}a.push(...c.values())}else{if(!Array.isArray(t)||t.length===0)throw new w("\u5206\u683C\u65B9\u6848\u81F3\u5C11\u9700\u8981\u4E00\u4E2A\u76EE\u6807");let c=new Map(o.map(u=>[u.key,u]));for(let u of t){if(!u||typeof u!="object")throw new w("\u5206\u683C\u65B9\u6848\u65E0\u6548");let{title:l,item_id:d,paths:f,tags:p}=u;if(f===void 0==(p===void 0))throw new w("\u6BCF\u4E2A\u76EE\u6807\u8BF7\u5728 paths \u548C tags \u4E2D\u9009\u4E00\u9879");let m=f??p;if(!Array.isArray(m)||m.length===0||m.some(g=>typeof g!="string"||!g.trim()))throw new w("paths \u6216 tags \u5FC5\u987B\u662F\u975E\u7A7A\u7684\u6587\u5B57\u5217\u8868");let h=f===void 0?o.filter(g=>g.tags.some(y=>m.includes(y))):m.map(g=>{let y=c.get(g);if(!y)throw new w(`\u65B9\u6848\u4E2D\u7684\u7B14\u8BB0\u4E0D\u5B58\u5728\uFF1A${g}`);return y});if(h.length===0)throw new w("\u6240\u9009\u6807\u7B7E\u6CA1\u6709\u5339\u914D\u7684\u7B14\u8BB0");if(typeof d=="string"&&d)a.push({key:d,itemId:d,title:"",cards:h});else if(d===void 0&&typeof l=="string"&&l.trim())a.push({key:"title:"+l.trim(),title:l.trim(),cards:h});else throw new w("\u6BCF\u4E2A\u76EE\u6807\u8BF7\u586B\u5DF2\u6709\u683C\u5B50 item_id \u6216\u65B0\u683C\u5B50 title")}}return{source:i,groups:a,links:s}}};import{randomUUID as mT}from"node:crypto";import{mkdirSync as hT,readFileSync as gT,realpathSync as bw,renameSync as yT,rmSync as vw,writeFileSync as _T}from"node:fs";import{homedir as wT}from"node:os";import{basename as bT,dirname as $w,isAbsolute as vT,join as xw,relative as $T,sep as kT}from"node:path";import{setTimeout as xT}from"node:timers/promises";var ST="https://i.weread.qq.com/api/agent/gateway",zT="1.0.6",Sw=e=>typeof e=="string"&&/^wrk-[A-Za-z0-9_-]+$/.test(e),zw=xw(wT(),".dsh-palace","weread.json");function Pw(e=zw){try{let{key:t}=JSON.parse(gT(e,"utf8"));if(Sw(t))return t}catch(t){if(t.code==="ENOENT")return}throw new w("\u65E0\u6CD5\u8BFB\u53D6\u5FAE\u4FE1\u8BFB\u4E66 Key\uFF0C\u8BF7\u5728\u5BAB\u6BBF\u91CD\u65B0\u4FDD\u5B58")}function Iw(e,t=zw,r){if(e===void 0)return Pw(t)!==void 0;if(e!==null&&!Sw(e))throw new w("\u8BF7\u8F93\u5165\u6709\u6548\u7684\u5FAE\u4FE1\u8BFB\u4E66 API Key");let n=t+"."+mT();try{if(e===null)return vw(t,{force:!0}),!1;if(hT($w(t),{recursive:!0,mode:448}),r!==void 0){let o=$T(bw(r),xw(bw($w(t)),bT(t)));if(!vT(o)&&o!==".."&&!o.startsWith(".."+kT))throw new w("\u5FAE\u4FE1\u8BFB\u4E66 Key \u5FC5\u987B\u4FDD\u5B58\u5728\u5BAB\u6BBF\u6570\u636E\u76EE\u5F55\u5916")}return _T(n,JSON.stringify({key:e}),{mode:384,flag:"wx"}),yT(n,t),!0}catch(o){throw o instanceof w?o:new w("\u65E0\u6CD5\u4FDD\u5B58\u6216\u5220\u9664\u5FAE\u4FE1\u8BFB\u4E66 Key")}finally{try{vw(n,{force:!0})}catch{}}}var kw=({chapterUid:e,range:t})=>e!=null&&t?.trim()?JSON.stringify([String(e),t]):void 0,PT={"/shelf/sync":"books","/user/notebooks":"books","/review/list/mine":"reviews","/book/chapterinfo":"chapters","/book/bookmarklist":"updated"};function IT(e,t){let r=[];for(let o of e){let s=o.title?.trim();if(!s)continue;let i=o.level??1,a={title:s,loc:String(o.chapterUid),sections:[]};i===1||i===2&&!r.length?r.push(a):i===2&&r.at(-1).sections.push({title:a.title,loc:a.loc})}let n=new Set(t.map(o=>o.sectionKey));for(let o of r)o.sections?.length&&o.loc&&n.has(o.loc)&&o.sections.unshift({title:o.title,loc:o.loc});return r}function ET(e=fetch,t=Pw){let r=new Set;async function n(c,u,l,d,f=!1){async function p(){let m=AbortSignal.timeout(12e3),h=d?AbortSignal.any([d,m]):m,g=await e(ST,{method:"POST",redirect:"error",signal:h,headers:{Authorization:`Bearer ${c}`,"Content-Type":"application/json"},body:JSON.stringify({api_name:u,skill_version:zT,...l})});return{response:g,data:g.ok?await g.json():{}}}try{for(;r.size>=3;)d?.throwIfAborted(),await Promise.race(r).catch(()=>{});d?.throwIfAborted();let m=p();r.add(m);let{response:h,data:g}=await m.finally(()=>r.delete(m)),y=Number(g?.errcode||h.status);if(y===429){let v=Number(h.headers.get("retry-after")??1);if(v>=0&&v<=3&&!f)return await xT(v*1e3,void 0,{signal:d}),n(c,u,l,d,!0);throw new w("\u5FAE\u4FE1\u8BFB\u4E66\u8BF7\u6C42\u8FC7\u4E8E\u9891\u7E41\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5")}if(y===401||y===403)throw new w("\u5FAE\u4FE1\u8BFB\u4E66\u9274\u6743\u5931\u8D25\uFF0C\u8BF7\u66F4\u6362 API Key");if(!h.ok||!g||Number(g.errcode??0)!==0)throw new w("\u5FAE\u4FE1\u8BFB\u4E66\u63A5\u53E3\u6682\u65F6\u4E0D\u53EF\u7528\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5");if(!Array.isArray(g[PT[u]]))throw new w("\u5FAE\u4FE1\u8BFB\u4E66\u56DE\u5305\u4E0D\u5B8C\u6574\uFF0C\u8BF7\u91CD\u8BD5");return g}catch(m){throw m instanceof w?m:d?.aborted?new w("\u5FAE\u4FE1\u8BFB\u4E66\u5BFC\u5165\u5DF2\u53D6\u6D88"):new w("\u8FDE\u63A5\u5FAE\u4FE1\u8BFB\u4E66\u5931\u8D25\u6216\u8D85\u65F6\uFF0C\u8BF7\u91CD\u8BD5")}}function o(){let c=t();if(!c)throw new w("\u8BF7\u5148\u5728\u5BAB\u6BBF\u300C\u4ECE\u5FAE\u4FE1\u8BFB\u4E66\u5BFC\u5165\u300D\u91CC\u4FDD\u5B58 API Key");return c}async function s(c,u){let l=await n(c,"/shelf/sync",{},u),d=new Map(l.books.map(p=>[p.bookId,{...p,hasNotes:!1}])),f;for(;;){let p=await n(c,"/user/notebooks",{count:100,lastSort:f},u);for(let h of p.books){let g=d.get(h.bookId)??h.book;g&&d.set(h.bookId,{...g,bookId:h.bookId,hasNotes:!!(h.noteCount||h.reviewCount)})}if(!p.hasMore)break;let m=p.books.at(-1)?.sort;if(m===void 0||m===f)throw new w("\u5FAE\u4FE1\u8BFB\u4E66\u7B14\u8BB0\u5217\u8868\u5206\u9875\u5931\u8D25\uFF0C\u8BF7\u91CD\u8BD5");f=m}return{books:d,total:l.books.length+(l.albums?.length??0)+ +(Object.keys(l.mp??{}).length>0)}}let i,a;return{async scan(c){let u=o();i={key:u,data:await s(u,c)},a=void 0;let{books:l,total:d}=i.data;return{total:d,withNotes:[...l.values()].filter(f=>f.hasNotes).length,books:[...l.values()].map(({bookId:f,title:p,author:m,category:h,finishReading:g,readUpdateTime:y,publishTime:v,hasNotes:k})=>({bookId:f,title:p,author:m,category:h,finished:g===1,readUpdateTime:y,publishTime:v,hasNotes:k}))}},async prepare(c,u,l){if(!Array.isArray(c)||c.length===0||c.some(y=>typeof y!="string"||!y))throw new w("\u8BF7\u63D0\u4F9B\u8981\u5BFC\u5165\u7684 bookId \u5217\u8868");let d=o(),f=[...new Set(c)],p=JSON.stringify(f);if(u&&a?.key===d&&a.plan===p)return a.batch;if(u)throw new w("\u5FAE\u4FE1\u8BFB\u4E66\u5BFC\u5165\u9884\u89C8\u5DF2\u53D8\u5316\uFF0C\u8BF7\u91CD\u65B0\u9884\u89C8\u5E76\u786E\u8BA4");let{books:m}=i?.key===d?i.data:await s(d,l),h=[];for(let y of f){let v=m.get(y);if(!v)throw new w("\u9009\u4E2D\u7684\u4E66\u4E0D\u5728\u4E66\u67B6\u6216\u7B14\u8BB0\u672C\u91CC\uFF0C\u8BF7\u91CD\u65B0\u626B\u63CF");let k=[v.readerLink,v.deepLink].find(M=>typeof M=="string"&&/^https?:\/\//.test(M)),T={key:y,kind:"book",title:v.title,href:k,cards:[]};if(h.push(T),!v.hasNotes)continue;let x=async()=>{let M=[],me=0;for(;;){let se=await n(d,"/review/list/mine",{bookid:y,synckey:me,count:100},l);if(M.push(...se.reviews),!se.hasMore)return M;if(!se.synckey||se.synckey===me)throw new w("\u5FAE\u4FE1\u8BFB\u4E66\u60F3\u6CD5\u5217\u8868\u5206\u9875\u5931\u8D25\uFF0C\u8BF7\u91CD\u8BD5");me=se.synckey}},[$,P,F]=await Promise.all([n(d,"/book/chapterinfo",{bookId:y},l),n(d,"/book/bookmarklist",{bookId:y},l),x()]),C=new Map,D=new Map;for(let M of P.updated)if(M.markText?.trim()){let me=JSON.stringify([y,"bookmark",M.bookmarkId]),se={key:me,type:"excerpt",quote:M.markText,sectionKey:M.chapterUid?.toString()};C.set(me,se);let Pt=kw(M);Pt!==void 0&&D.set(Pt,se)}let de=new Map(F.map(({review:M})=>[M.reviewId,M]));for(let M of de.values())if(M.abstract?.trim()||M.content?.trim()){let me=kw(M),se=me===void 0?void 0:D.get(me);if(se){M.content?.trim()&&(se.note=se.note?se.note+`
|
|
130
|
+
|
|
131
|
+
`+M.content:M.content);continue}let Pt=JSON.stringify([y,"review",M.reviewId]);C.set(Pt,{key:Pt,type:M.abstract?.trim()?"excerpt":"thought",quote:M.abstract||void 0,note:M.content,sectionKey:M.chapterUid?.toString()})}T.cards=[...C.values()],T.chapters=IT($.chapters,T.cards)}let g={source:"weread",groups:h,links:[]};return a={key:d,plan:p,batch:g},g}}}var Ew=ET();var OT=new Set(["palace_remove","palace_unlink"]),RT=new Set(["palace_overview","palace_read","palace_wiki_read","palace_context","palace_open","palace_scan_obsidian","palace_scan_weread"]);function ll(e){let{required:t,properties:r,items:n,...o}=e;return Array.isArray(t)&&(o.required=t),r&&(o.properties=Object.fromEntries(Object.entries(r).map(([s,i])=>[s,ll(i)])),o.required=Object.entries(r).filter(([,s])=>s.required===!0).map(([s])=>s)),n&&(o.items=ll(n)),o}var AT="Memory Palace \u662F\u7528\u6237\u672C\u673A\u7684\u77E5\u8BC6\u4E0E\u8BB0\u5FC6\u5E93\u3002\u4EC5\u5728\u7528\u6237\u8C08\u5230\u5BAB\u6BBF\u6216\u5176\u4E2D\u5185\u5BB9\u65F6\u4F7F\u7528\u3002\u5F00\u59CB\u5BAB\u6BBF\u8BDD\u9898\u65F6\u5148\u8C03\u7528 palace_context\uFF0C\u5DF2\u77E5\u683C\u5B50 id \u5C31\u4F20 item_id\uFF1B\u5207\u6362\u683C\u5B50\u65F6\u91CD\u65B0\u8BFB\u53D6\u3002\u4E0D\u8981\u5047\u5B9A\u80CC\u666F\u5DF2\u81EA\u52A8\u6CE8\u5165\u3002\u64CD\u4F5C\u524D\u7528 palace_overview \u6838\u5B9E\u683C\u5B50 id\uFF0C\u5199\u5361\u7247\u548C\u7075\u611F\u5FC5\u987B\u663E\u5F0F\u4F20 item_id\u3002\u53EA\u8BB0\u7528\u6237\u8868\u8FBE\u8FC7\u7684\u4E8B\u5B9E\u548C\u60F3\u6CD5\uFF0C\u4E0D\u628A AI \u7684\u63A8\u6D4B\u8BB0\u6210\u7528\u6237\u89C2\u70B9\uFF1B\u66F4\u65B0\u8BB0\u5FC6\u524D\u5148\u8BFB\u65E7\u9875\uFF0C\u4FDD\u7559\u4ECD\u7136\u6709\u6548\u7684\u4FE1\u606F\u3002\u7528\u6237\u8981\u6C42\u4FDD\u5B58\u5BF9\u8BDD\u65F6\u7528 palace_add_inspiration\uFF0C\u5FC5\u8981\u65F6\u66F4\u65B0\u683C\u5B50\u8BB0\u5FC6\uFF1B\u7EAF\u529F\u80FD\u64CD\u4F5C\u4E0D\u5F3A\u884C\u66F4\u65B0\u8BB0\u5FC6\u3002\u5220\u9664\u524D\u8BF4\u660E\u76EE\u6807\u53CA\u5361\u7247\u3001\u7075\u611F\u6570\u91CF\u5E76\u53D6\u5F97\u7528\u6237\u660E\u786E\u540C\u610F\u3002\u7F51\u9875\u7531 palace_open \u8FD4\u56DE\uFF0C\u804A\u5929\u4ECD\u5728 Codex \u4E2D\u8FDB\u884C\u3002";function Tw(e,t){let r=new Br(e),n=W_(e,r,{addBook:(c,u)=>zi(e,c,u,{readVideo:!1}),readPageTexts:ki,scannedThreshold:xi,scannedPageHelp:"\u5426\u5219\u8BF7\u8BFB\u53D6\u672C\u673A PDF \u5BF9\u5E94\u9875\u7684\u56FE\u7247\uFF0C\u6216\u8BF7\u7528\u6237\u628A\u8FD9\u4E9B\u9875\u7684\u622A\u56FE\u9644\u5230 Codex \u5BF9\u8BDD\u3002",videoHelp:"\u89C6\u9891\u586B url \u548C\u6B63\u5F0F\u4F5C\u54C1\u540D title\uFF0C\u5148\u4FDD\u5B58\u94FE\u63A5\u3002",imageHelp:"image \u586B\u672C\u673A\u56FE\u7247\u7684\u7EDD\u5BF9\u8DEF\u5F84\u3002",imageDescription:"\u622A\u56FE\u7684\u672C\u673A\u7EDD\u5BF9\u8DEF\u5F84",currentItem:!1,wikiReadHelp:"\u9700\u8981\u80CC\u666F\u65F6\u5148\u8C03\u7528 palace_context\uFF1B\u66F4\u65B0\u8BB0\u5FC6\u524D\u5148\u8BFB\u53D6\u65E7\u9875\u3002",saveImage:c=>typeof c=="string"&&TT(c)?hw(e,c):void 0}),o=new Vr,s=Q_(r,"\u5F00\u59CB\u5BAB\u6BBF\u8BDD\u9898\u6216\u5207\u6362\u683C\u5B50\u65F6\u5148\u8C03\u7528\uFF1B\u8BB0\u5FC6\u4E0D\u4F1A\u81EA\u52A8\u6CE8\u5165 Codex \u5BF9\u8BDD\u3002"),i=new Map([...n,...Y_(e,r,ww),...X_(e,r,Ew),s,ew(t)].map(({name:c,description:u,parameters:l,execute:d})=>{let f=ll({type:"object",properties:l,additionalProperties:!1}),p={name:c,description:u,inputSchema:f,annotations:{readOnlyHint:RT.has(c),destructiveHint:OT.has(c)}};return[c,{tool:p,execute:d,validate:o.getValidator(f)}]})),a=new vi({name:"dsh-palace",version:"1.0.0"},{capabilities:{tools:{}},jsonSchemaValidator:o,instructions:AT});return a.setRequestHandler(Ha,()=>({tools:[...i.values()].map(({tool:c})=>c)})),a.setRequestHandler(kn,async({params:c},{signal:u})=>{let l=i.get(c.name);if(!l)throw new A(j.InvalidParams,"\u672A\u77E5\u5DE5\u5177");let d=l.validate(c.arguments??{});if(!d.valid)throw new A(j.InvalidParams,d.errorMessage);let f=await l.execute(d.data,{signal:u});return/^操作失败:(?:palace\.json|items\/[^\n]+\.json) 刚被其他程序修改过,请重试$/.test(f)&&(f="\u64CD\u4F5C\u5931\u8D25\uFF1A\u6570\u636E\u521A\u88AB\u522B\u5904\u6539\u8FC7\uFF0C\u8BF7\u91CD\u8BD5"),{content:[{type:"text",text:f}],isError:f.startsWith("\u64CD\u4F5C\u5931\u8D25\uFF1A")}}),a}import{randomUUID as CT}from"node:crypto";import{lstatSync as Ow,mkdirSync as NT,readFileSync as jT,renameSync as DT,rmSync as ZT,writeFileSync as MT}from"node:fs";import{dirname as qT}from"node:path";var dl=e=>JSON.stringify(e).replace(/\u007f/g,"\\u007f"),fl=()=>new Error("\u68C0\u6D4B\u5230\u590D\u6742\u7684 MCP \u914D\u7F6E\uFF0C\u8BF7\u6309 README \u624B\u52A8\u8BBE\u7F6E dsh-palace"),pl=/(?:[\w-]+|"[^"\\]*"|'[^']*')/.source,FT=new RegExp(`^\\s*(\\[\\[?)\\s*(${pl}(?:\\s*\\.\\s*${pl})*)\\s*(\\]\\]?)\\s*(?:#.*)?$`),Rw=e=>new RegExp(`^\\s*(?:${e}|"${e}"|'${e}')\\s*[.=]`);function Aw(e,t){let r=`${e}.${CT()}.tmp`;try{MT(r,t,{mode:384,flag:"wx"}),DT(r,e)}finally{ZT(r,{force:!0})}}function Cw(e,t,r){let n=Ow(e,{throwIfNoEntry:!1});if(n&&!n.isFile())throw fl();let o=n?jT(e,"utf8"):"";if(o.includes('"""')||o.includes("'''"))throw fl();let s=o.includes(`\r
|
|
128
132
|
`)?`\r
|
|
129
133
|
`:`
|
|
130
|
-
`,i=[],a=(o.match(/[^\n]*\n|[^\n]+$/g)??[]).filter(l=>{let d=
|
|
131
|
-
`)?s:"")+c.join(s)+s;if(u!==o){if(n?
|
|
134
|
+
`,i=[],a=(o.match(/[^\n]*\n|[^\n]+$/g)??[]).filter(l=>{let d=FT.exec(l.trimEnd());d&&(i=[...d[2].matchAll(new RegExp(pl,"g"))].map(([p])=>p.replace(/^["']|["']$/g,"")));let f=i[0]==="mcp_servers"&&i[1]==="dsh-palace";if(d?d[1].length!==d[3].length||i[0]==="mcp_servers"&&d[1]==="[[":/^\s*\[/.test(l)||i.length===0&&Rw("mcp_servers").test(l)||i.length===1&&i[0]==="mcp_servers"&&Rw("dsh-palace").test(l))throw fl();return!f}).join(""),c=["[mcp_servers.dsh-palace]",`command = ${dl(process.execPath)}`,`args = [${dl(t)}]`];r!==void 0&&c.push("","[mcp_servers.dsh-palace.env]",`DSH_PALACE_DATA_DIR = ${dl(r)}`);let u=a+(a&&!a.endsWith(`
|
|
135
|
+
`)?s:"")+c.join(s)+s;if(u!==o){if(n?Aw(`${e}.bak`,o):NT(qT(e),{recursive:!0}),Ow(e,{throwIfNoEntry:!1})?.mtimeMs!==n?.mtimeMs)throw new Error("Codex \u914D\u7F6E\u521A\u88AB\u522B\u5904\u6539\u8FC7\uFF0C\u8BF7\u91CD\u8BD5");Aw(e,u)}}import{once as sO}from"node:events";import{createReadStream as iO}from"node:fs";import{createServer as aO}from"node:http";import{Readable as Fw}from"node:stream";import{pipeline as Lw}from"node:stream/promises";import{execFile as VT,spawn as hl}from"node:child_process";import{createReadStream as BT,existsSync as dr,statSync as HT}from"node:fs";import{homedir as KT}from"node:os";import{basename as JT,extname as GT,join as ho,normalize as WT,sep as yl}from"node:path";import{Readable as YT}from"node:stream";import{fileURLToPath as Dw}from"node:url";import{execFile as LT}from"node:child_process";var UT=`ObjC.import('CoreServices')
|
|
132
136
|
function run(argv) {
|
|
133
137
|
const w = $(argv[0])
|
|
134
138
|
const r = $.DCSCopyTextDefinition($(), w, $.CFRangeMake(0, w.length))
|
|
135
139
|
return r ? ObjC.unwrap(ObjC.castRefToObject(r)) : ''
|
|
136
|
-
}`,sl=/^[A-Za-zÀ-ɏ]+(?:['’-][A-Za-zÀ-ɏ]+)*$/,io=new Map;async function fw(e){if(process.platform!=="darwin")return{supported:!1,definition:null};let t=await dw(e.replace(/’/g,"'")),r=t!==null&&t.length<160?/→\s*([A-Za-z]+(?:-[A-Za-z]+)*)/.exec(t)?.[1]:void 0,n=r!==void 0&&r.toLowerCase()!==e.toLowerCase()?await dw(r):null;return{supported:!0,definition:t,...n!==null?{lemma:{word:r,definition:n}}:{}}}async function dw(e){if(!sl.test(e)||e.length>80)return null;if(io.has(e))return io.get(e);let t=await new Promise((n,o)=>{BI("osascript",["-l","JavaScript","-e",JI,e],{timeout:5e3,maxBuffer:1<<20},(s,i)=>{s?o(new b("\u7CFB\u7EDF\u8BCD\u5178\u6CA1\u6709\u54CD\u5E94")):n(i.trim())})}),r=t===""?null:t;return io.size>2e3&&io.clear(),io.set(e,r),r}var rT="/api/dsh-palace";function nT(e,t){if(t.kind==="book"||t.source!==void 0)throw new b("\u6DFB\u52A0\u4E66\u8BF7\u7528 addBook");return zt(e,{...t,outline:void 0,outlineSource:void 0})}var mw={addBook:wi,addCell:nT,updateCell:fh,moveCell:ph,groupCells:mh,deleteCell:vs,updateItem:$s,setPosition:hh,setOutline:xs,setSectionDone:yh,markUpTo:_h,resetProgress:wh,addCard:Ss,updateCard:xh,deleteCard:Sh,addInspiration:ks,updateInspiration:kh,deleteInspiration:zh};function oe(e,t=200){return new Response(JSON.stringify(e),{status:t,headers:{"content-type":"application/json; charset=utf-8","cache-control":"no-store"}})}function oT(e){return e instanceof b?oe({ok:!1,error:e.message},400):(console.error("[dsh-palace]",e),oe({ok:!1,error:`\u5185\u90E8\u9519\u8BEF\uFF1A${e?.message??String(e)}`},500))}function Fr(e,t){let r=WI(e).size,n=tT.toWeb(GI(e));return new Response(n,{headers:{"content-type":t,"content-length":String(r),"cache-control":"no-store"}})}function hw(e){let t=YI();return e===t||e.startsWith(t+cl)?"~"+e.slice(t.length):e}function Lr(e){let t=process.platform==="darwin"?il("open",[e],{detached:!0,stdio:"ignore"}):process.platform==="win32"?il("cmd",["/c","start","",e],{detached:!0,stdio:"ignore",windowsHide:!0}):il("xdg-open",[e],{detached:!0,stdio:"ignore"});t.on("error",r=>console.error("[dsh-palace] \u6253\u5F00\u5931\u8D25",e,r)),t.unref()}function sT(){return process.platform!=="darwin"?Promise.resolve(void 0):new Promise(e=>{KI("osascript",["-e",'set f to choose file with prompt "\u9009\u62E9 PDF \u6216 EPUB" of type {"com.adobe.pdf", "org.idpf.epub-container"}',"-e","POSIX path of f"],{timeout:10*6e4},(t,r)=>{e(t?null:r.trim())})})}var iT=["jszip.min.js","epub.min.js"];function al(){let e=pw(new URL("../vendor/",import.meta.url));return or(e)?e:pw(new URL("../../vendor/",import.meta.url))}var aT={webp:"image/webp",png:"image/png",svg:"image/svg+xml",ttf:"font/ttf",woff2:"font/woff2"},cT={".png":"image/png",".jpg":"image/jpeg",".jpeg":"image/jpeg",".webp":"image/webp",".gif":"image/gif"};function bi(e,t){St(t);let r=e.getPalace().cells.find(n=>n.id===t);if(r===void 0||r.kind==="group")throw new b("\u683C\u5B50\u4E0D\u5B58\u5728");return e.getItem(t)}function gw(e,t,r=new qr(e)){let n=(o,s,i)=>({path:`${rT}/${s}`,methods:[o],requestBody:"buffered",fetch:async a=>{try{let c=o==="POST"?await a.json().catch(()=>({}))??{}:{};return await i({url:new URL(a.url),body:c,signal:a.signal})}catch(c){return oT(c)}}});return[n("GET","palace",()=>oe({ok:!0,rev:e.rev,palace:e.getPalace(),summaries:e.summaries(),dataDir:hw(e.dir)})),n("GET","chat-workspace",()=>oe({ok:!0,cwd:e.dir})),n("GET","arcs",()=>oe({ok:!0,rev:e.rev,arcs:r.arcs()})),n("POST","cut-arc",({body:o})=>(r.cut({from:o.from,to:o.to}),oe({ok:!0,rev:e.rev}))),n("GET","lookup",async({url:o})=>oe({ok:!0,...await fw(o.searchParams.get("word")??"")})),n("POST","open-dictionary",({body:o})=>{let s=typeof o.word=="string"?o.word:"";if(process.platform!=="darwin"||!sl.test(s))throw new b("\u65E0\u6CD5\u6253\u5F00\u8BCD\u5178");return Lr(`dict://${encodeURIComponent(s)}`),oe({ok:!0})}),n("GET","item",({url:o})=>oe({ok:!0,rev:e.rev,item:bi(e,o.searchParams.get("id"))})),n("GET","rev",()=>oe({ok:!0,rev:e.checkDisk()})),n("POST","op",async({body:o,signal:s})=>{let i=String(o.op),a=Object.hasOwn(mw,i)?mw[i]:void 0;if(a===void 0)return oe({ok:!1,error:`\u672A\u77E5\u64CD\u4F5C ${i}`},400);let c=await a(e,o.args??{},s);return oe({ok:!0,rev:e.rev,result:c??null})}),n("GET","file",({url:o})=>{let s=bi(e,o.searchParams.get("id")).source;if(s===null||s.type==="video")throw new b("\u8FD9\u4E2A\u683C\u5B50\u6CA1\u6709\u539F\u6587\u6587\u4EF6");return or(s.path)?Fr(s.path,s.type==="pdf"?"application/pdf":"application/epub+zip"):oe({ok:!1,error:"\u627E\u4E0D\u5230\u539F\u6587\u6587\u4EF6\uFF0C\u53EF\u80FD\u88AB\u79FB\u52A8\u6216\u5220\u9664\u4E86"},404)}),n("GET","page-text",async({url:o})=>{let s=bi(e,o.searchParams.get("id")).source;if(s?.type!=="pdf")throw new b("\u8FD9\u4E0D\u662F PDF");let i=(o.searchParams.get("pages")??"").split(",").map(Number).filter(Number.isInteger),a=await gi(s.path,i),c=a.filter(u=>u.text.length<yi).map(u=>u.page);return oe({ok:!0,pages:a,scanned:c})}),n("GET","image",({url:o})=>{let s=XI(o.searchParams.get("name")??""),i=ao(e.imagesDir,s),a=cT[QI(s).toLowerCase()];return s===""||a===void 0||!or(i)?new Response("not found",{status:404}):Fr(i,a)}),n("GET","asset",({url:o})=>{let s=eT(o.searchParams.get("f")??"");if(s.startsWith("reader/")){let d=s.slice(7);if(!iT.includes(d))return new Response("not found",{status:404});let f=Fr(ao(al(),d),"text/javascript; charset=utf-8");return f.headers.set("cache-control","public, max-age=86400"),f}let i=/^themes\/[a-z][a-z0-9-]{0,30}\/(?:[a-z]+\/)?[A-Za-z0-9][A-Za-z0-9-]{0,60}\.(webp|png|svg|ttf|woff2)$/.exec(s.split(cl).join("/"));if(i!==null){let d=ao(al(),s);if(!or(d))return new Response("not found",{status:404});let f=Fr(d,aT[i[1]]);return f.headers.set("cache-control","public, max-age=86400"),f}let a=/^fonts\/([a-z0-9][a-z0-9-]{0,60})\.woff2$/.exec(s)?.[1];if(a!==void 0){let d=ao(al(),"fonts",`${a}.woff2`);if(!or(d))return new Response("not found",{status:404});let f=Fr(d,"font/woff2");return f.headers.set("cache-control","public, max-age=31536000, immutable"),f}if(!["cmaps","standard_fonts","wasm","iccs"].some(d=>s.startsWith(d+cl))||s.includes(".."))return new Response("not found",{status:404});let u=ao(el(),s);if(!or(u))return new Response("not found",{status:404});let l=Fr(u,u.endsWith(".wasm")?"application/wasm":"application/octet-stream");return l.headers.set("cache-control","public, max-age=31536000, immutable"),l}),n("POST","pick-file",async()=>oe({ok:!0,path:await sT()})),n("POST","open",({body:o})=>{if(o.target==="welcome")return Lr(Ka),oe({ok:!0});if(o.target==="dataDir")return Lr(e.dir),oe({ok:!0});let s=e.getPalace().cells.find(u=>u.id===o.id)?.href;if(s!==void 0&&/^https?:\/\//.test(s))return Lr(s),oe({ok:!0});let i=bi(e,o.id),a=xt(i,typeof o.sectionId=="string"?o.sectionId:void 0)?.section,c=i.source;if(c===null)throw new b("\u8FD9\u4E2A\u683C\u5B50\u6CA1\u6709\u539F\u6587");if(c.type==="video"){let u=a?.loc;return Lr(u!==void 0&&/^https?:\/\//.test(u)?u:c.url),oe({ok:!0})}if(!or(c.path))throw new b(`\u627E\u4E0D\u5230\u6587\u4EF6\uFF1A${hw(c.path)}`);return Lr(c.path),oe({ok:!0})}),n("POST","active",({body:o})=>{let s=typeof o.sessionId=="string"?o.sessionId:void 0;return s===void 0?oe({ok:!1,error:"\u7F3A\u5C11 sessionId"},400):(typeof o.itemId=="string"?t.set(s,o.itemId):t.delete(s),oe({ok:!0}))})]}var ww="127.0.0.1",fT='<!doctype html><html lang="zh-CN"><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1"><title>Memory Palace</title><div id="app"></div><script src="/palace-web.js" defer></script></html>';async function bw(e,t=4196){let r=new Map(gw(e,new Map).map(a=>[a.path,a])),n=dT(async(a,c)=>{let u=a.headers.host,l=a.socket.localPort,d=`http://${u}`;if(u!==`${ww}:${l}`&&u!==`localhost:${l}`||a.method!=="GET"&&a.headers.origin!==d){c.writeHead(403).end();return}c.setHeader("x-content-type-options","nosniff"),c.setHeader("x-frame-options","DENY"),c.setHeader("cross-origin-resource-policy","same-origin");try{let f=new URL(a.url??"/",d),{pathname:p}=f;if(f.origin!==d){c.writeHead(403).end();return}if(a.method==="GET"&&p==="/"){c.writeHead(200,{"content-type":"text/html; charset=utf-8"}).end(fT);return}if(a.method==="GET"&&p==="/palace-web.js"){c.setHeader("content-type","text/javascript; charset=utf-8"),await _w(lT(new URL("./palace-web.js",import.meta.url)),c);return}let m=r.get(p);if(m===void 0){c.writeHead(404).end();return}let h=a.headers.origin,g=a.headers["sec-fetch-site"];if(h!==void 0&&h!==d||g==="cross-site"||g==="same-site"){c.writeHead(403).end();return}if(a.method!=="GET"&&a.method!=="POST"||!m.methods.includes(a.method)){c.writeHead(405,{allow:m.methods.join(", ")}).end();return}let w=new AbortController;c.once("close",()=>w.abort());let v=a.method==="POST"?yw.toWeb(a):void 0,$={method:a.method,headers:a.headers,body:v,duplex:"half",signal:w.signal},O=await m.fetch(new Request(f,$));c.writeHead(O.status,Object.fromEntries(O.headers)),O.body===null?c.end():await _w(yw.from(O.body),c)}catch(f){if(c.destroyed)return;console.error("[dsh-palace:localhost]",f),c.headersSent?c.destroy():c.writeHead(500).end("\u5BAB\u6BBF\u7F51\u9875\u8BF7\u6C42\u5931\u8D25")}}),o=a=>(n.listen(a,ww),uT(n,"listening"));try{await o(t)}catch(a){if(a.code!=="EADDRINUSE")throw a;await o(0)}n.unref();let{address:s,port:i}=n.address();return{url:`http://${s}:${i}/`,close:()=>{n.close(),n.closeAllConnections()}}}async function yT(){let e=process.env.DSH_PALACE_DATA_DIR,t=e??vi(vw(),"Documents","dsh-palace-data");if(!mT(t))throw new Error("DSH_PALACE_DATA_DIR \u5FC5\u987B\u662F\u6570\u636E\u76EE\u5F55\u7684\u7EDD\u5BF9\u8DEF\u5F84");let r=process.argv.includes("--install"),n=gT(import.meta.url);if(r&&n.split(hT).includes("_npx"))throw new Error("npx \u7F13\u5B58\u91CC\u7684\u8DEF\u5F84\u53EF\u80FD\u5931\u6548\u3002\u8BF7\u8FD0\u884C npm install -g dsh-palace && dsh-palace-mcp --install");let o=r&&e===void 0&&!pT(vi(t,"palace.json")),s=new ws(t,{create:o});if(r){o&&await dh(s);let c=vi(process.env.CODEX_HOME||vi(vw(),".codex"),"config.toml");lw(c,n,e),console.error("Memory Palace \u5DF2\u5199\u5165 Codex \u914D\u7F6E\uFF0C\u8BF7\u91CD\u542F\u684C\u9762\u7AEF\u3002");return}let i=await bw(s),a=iw(s,i.url);a.onclose=i.close,process.stdin.once("end",()=>{a.close()}),await a.connect(new ds).catch(c=>{throw i.close(),c})}yT().catch(e=>{console.error(`\u65E0\u6CD5\u542F\u52A8 Memory Palace MCP\uFF1A${e.message}\u3002\u8BF7\u786E\u8BA4 Harness \u6570\u636E\u76EE\u5F55\u548C DSH_PALACE_DATA_DIR \u8BBE\u7F6E\u3002`),process.exitCode=1});
|
|
140
|
+
}`,ml=/^[A-Za-zÀ-ɏ]+(?:['’-][A-Za-zÀ-ɏ]+)*$/,mo=new Map;async function jw(e){if(process.platform!=="darwin")return{supported:!1,definition:null};let t=await Nw(e.replace(/’/g,"'")),r=t!==null&&t.length<160?/→\s*([A-Za-z]+(?:-[A-Za-z]+)*)/.exec(t)?.[1]:void 0,n=r!==void 0&&r.toLowerCase()!==e.toLowerCase()?await Nw(r):null;return{supported:!0,definition:t,...n!==null?{lemma:{word:r,definition:n}}:{}}}async function Nw(e){if(!ml.test(e)||e.length>80)return null;if(mo.has(e))return mo.get(e);let t=await new Promise((n,o)=>{LT("osascript",["-l","JavaScript","-e",UT,e],{timeout:5e3,maxBuffer:1<<20},(s,i)=>{s?o(new w("\u7CFB\u7EDF\u8BCD\u5178\u6CA1\u6709\u54CD\u5E94")):n(i.trim())})}),r=t===""?null:t;return mo.size>2e3&&mo.clear(),mo.set(e,r),r}var XT="/api/dsh-palace";function QT(e,t){if(t.kind==="book"||t.source!==void 0)throw new w("\u6DFB\u52A0\u4E66\u8BF7\u7528 addBook");return jt(e,{...t,outline:void 0,outlineSource:void 0})}var Zw={addBook:zi,addCell:QT,updateCell:$h,moveCell:kh,groupCells:xh,deleteCell:zs,updateItem:Ps,setPosition:Sh,setOutline:Es,setSectionDone:zh,markUpTo:Ph,resetProgress:Ih,addCard:Ts,updateCard:Rh,deleteCard:Ah,addInspiration:Os,updateInspiration:Ch,deleteInspiration:Nh};function le(e,t=200){return new Response(JSON.stringify(e),{status:t,headers:{"content-type":"application/json; charset=utf-8","cache-control":"no-store"}})}function eO(e){return e instanceof w?le({ok:!1,error:e.message},400):(console.error("[dsh-palace]",e),le({ok:!1,error:`\u5185\u90E8\u9519\u8BEF\uFF1A${e?.message??String(e)}`},500))}function Hr(e,t){let r=HT(e).size,n=YT.toWeb(BT(e));return new Response(n,{headers:{"content-type":t,"content-length":String(r),"cache-control":"no-store"}})}function Mw(e){let t=KT();return e===t||e.startsWith(t+yl)?"~"+e.slice(t.length):e}function Kr(e){let t=process.platform==="darwin"?hl("open",[e],{detached:!0,stdio:"ignore"}):process.platform==="win32"?hl("cmd",["/c","start","",e],{detached:!0,stdio:"ignore",windowsHide:!0}):hl("xdg-open",[e],{detached:!0,stdio:"ignore"});t.on("error",r=>console.error("[dsh-palace] \u6253\u5F00\u5931\u8D25",e,r)),t.unref()}function tO(){return process.platform!=="darwin"?Promise.resolve(void 0):new Promise(e=>{VT("osascript",["-e",'set f to choose file with prompt "\u9009\u62E9 PDF \u6216 EPUB" of type {"com.adobe.pdf", "org.idpf.epub-container"}',"-e","POSIX path of f"],{timeout:10*6e4},(t,r)=>{e(t?null:r.trim())})})}var rO=["jszip.min.js","epub.min.js"];function gl(){let e=Dw(new URL("../vendor/",import.meta.url));return dr(e)?e:Dw(new URL("../../vendor/",import.meta.url))}var nO={webp:"image/webp",png:"image/png",svg:"image/svg+xml",ttf:"font/ttf",woff2:"font/woff2"},oO={".png":"image/png",".jpg":"image/jpeg",".jpeg":"image/jpeg",".webp":"image/webp",".gif":"image/gif"};function Pi(e,t){Ct(t);let r=e.getPalace().cells.find(n=>n.id===t);if(r===void 0||r.kind==="group")throw new w("\u683C\u5B50\u4E0D\u5B58\u5728");return e.getItem(t)}function qw(e,t,r=new Br(e)){let n=(o,s,i)=>({path:`${XT}/${s}`,methods:[o],requestBody:"buffered",fetch:async a=>{try{let c=o==="POST"?await a.json().catch(()=>({}))??{}:{};return await i({url:new URL(a.url),body:c,signal:a.signal})}catch(c){return eO(c)}}});return[n("POST","weread-key",({body:o})=>le({ok:!0,saved:Iw(o.key,void 0,e.dir)})),n("GET","palace",()=>le({ok:!0,rev:e.rev,palace:e.getPalace(),summaries:e.summaries(),dataDir:Mw(e.dir)})),n("GET","chat-workspace",()=>le({ok:!0,cwd:e.dir})),n("GET","arcs",()=>le({ok:!0,rev:e.rev,arcs:r.arcs()})),n("POST","cut-arc",({body:o})=>(r.cut({from:o.from,to:o.to}),le({ok:!0,rev:e.rev}))),n("GET","lookup",async({url:o})=>le({ok:!0,...await jw(o.searchParams.get("word")??"")})),n("POST","open-dictionary",({body:o})=>{let s=typeof o.word=="string"?o.word:"";if(process.platform!=="darwin"||!ml.test(s))throw new w("\u65E0\u6CD5\u6253\u5F00\u8BCD\u5178");return Kr(`dict://${encodeURIComponent(s)}`),le({ok:!0})}),n("GET","item",({url:o})=>le({ok:!0,rev:e.rev,item:Pi(e,o.searchParams.get("id"))})),n("GET","rev",()=>le({ok:!0,rev:e.checkDisk()})),n("POST","op",async({body:o,signal:s})=>{let i=String(o.op),a=Object.hasOwn(Zw,i)?Zw[i]:void 0;if(a===void 0)return le({ok:!1,error:`\u672A\u77E5\u64CD\u4F5C ${i}`},400);let c=await a(e,o.args??{},s);return le({ok:!0,rev:e.rev,result:c??null})}),n("GET","file",({url:o})=>{let s=Pi(e,o.searchParams.get("id")).source;if(s===null||s.type==="video")throw new w("\u8FD9\u4E2A\u683C\u5B50\u6CA1\u6709\u539F\u6587\u6587\u4EF6");return dr(s.path)?Hr(s.path,s.type==="pdf"?"application/pdf":"application/epub+zip"):le({ok:!1,error:"\u627E\u4E0D\u5230\u539F\u6587\u6587\u4EF6\uFF0C\u53EF\u80FD\u88AB\u79FB\u52A8\u6216\u5220\u9664\u4E86"},404)}),n("GET","page-text",async({url:o})=>{let s=Pi(e,o.searchParams.get("id")).source;if(s?.type!=="pdf")throw new w("\u8FD9\u4E0D\u662F PDF");let i=(o.searchParams.get("pages")??"").split(",").map(Number).filter(Number.isInteger),a=await ki(s.path,i),c=a.filter(u=>u.text.length<xi).map(u=>u.page);return le({ok:!0,pages:a,scanned:c})}),n("GET","image",({url:o})=>{let s=JT(o.searchParams.get("name")??""),i=ho(e.imagesDir,s),a=oO[GT(s).toLowerCase()];return s===""||a===void 0||!dr(i)?new Response("not found",{status:404}):Hr(i,a)}),n("GET","asset",({url:o})=>{let s=WT(o.searchParams.get("f")??"");if(s.startsWith("reader/")){let d=s.slice(7);if(!rO.includes(d))return new Response("not found",{status:404});let f=Hr(ho(gl(),d),"text/javascript; charset=utf-8");return f.headers.set("cache-control","public, max-age=86400"),f}let i=/^themes\/[a-z][a-z0-9-]{0,30}\/(?:[a-z]+\/)?[A-Za-z0-9][A-Za-z0-9-]{0,60}\.(webp|png|svg|ttf|woff2)$/.exec(s.split(yl).join("/"));if(i!==null){let d=ho(gl(),s);if(!dr(d))return new Response("not found",{status:404});let f=Hr(d,nO[i[1]]);return f.headers.set("cache-control","public, max-age=86400"),f}let a=/^fonts\/([a-z0-9][a-z0-9-]{0,60})\.woff2$/.exec(s)?.[1];if(a!==void 0){let d=ho(gl(),"fonts",`${a}.woff2`);if(!dr(d))return new Response("not found",{status:404});let f=Hr(d,"font/woff2");return f.headers.set("cache-control","public, max-age=31536000, immutable"),f}if(!["cmaps","standard_fonts","wasm","iccs"].some(d=>s.startsWith(d+yl))||s.includes(".."))return new Response("not found",{status:404});let u=ho(cl(),s);if(!dr(u))return new Response("not found",{status:404});let l=Hr(u,u.endsWith(".wasm")?"application/wasm":"application/octet-stream");return l.headers.set("cache-control","public, max-age=31536000, immutable"),l}),n("POST","pick-file",async()=>le({ok:!0,path:await tO()})),n("POST","open",({body:o})=>{if(o.target==="welcome")return Kr(ec),le({ok:!0});if(o.target==="dataDir")return Kr(e.dir),le({ok:!0});let s=e.getPalace().cells.find(u=>u.id===o.id)?.href;if(s!==void 0&&/^https?:\/\//.test(s))return Kr(s),le({ok:!0});let i=Pi(e,o.id),a=At(i,typeof o.sectionId=="string"?o.sectionId:void 0)?.section,c=i.source;if(c===null)throw new w("\u8FD9\u4E2A\u683C\u5B50\u6CA1\u6709\u539F\u6587");if(c.type==="video"){let u=a?.loc;return Kr(u!==void 0&&/^https?:\/\//.test(u)?u:c.url),le({ok:!0})}if(!dr(c.path))throw new w(`\u627E\u4E0D\u5230\u6587\u4EF6\uFF1A${Mw(c.path)}`);return Kr(c.path),le({ok:!0})}),n("POST","active",({body:o})=>{let s=typeof o.sessionId=="string"?o.sessionId:void 0;return s===void 0?le({ok:!1,error:"\u7F3A\u5C11 sessionId"},400):(typeof o.itemId=="string"?t.set(s,o.itemId):t.delete(s),le({ok:!0}))})]}var Uw="127.0.0.1",cO='<!doctype html><html lang="zh-CN"><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1"><title>Memory Palace</title><div id="app"></div><script src="/palace-web.js" defer></script></html>';async function Vw(e,t=4196){let r=new Map(qw(e,new Map).map(a=>[a.path,a])),n=aO(async(a,c)=>{let u=a.headers.host,l=a.socket.localPort,d=`http://${u}`;if(u!==`${Uw}:${l}`&&u!==`localhost:${l}`||a.method!=="GET"&&a.headers.origin!==d){c.writeHead(403).end();return}c.setHeader("x-content-type-options","nosniff"),c.setHeader("x-frame-options","DENY"),c.setHeader("cross-origin-resource-policy","same-origin");try{let f=new URL(a.url??"/",d),{pathname:p}=f;if(f.origin!==d){c.writeHead(403).end();return}if(a.method==="GET"&&p==="/"){c.writeHead(200,{"content-type":"text/html; charset=utf-8"}).end(cO);return}if(a.method==="GET"&&p==="/palace-web.js"){c.setHeader("content-type","text/javascript; charset=utf-8"),await Lw(iO(new URL("./palace-web.js",import.meta.url)),c);return}let m=r.get(p);if(m===void 0){c.writeHead(404).end();return}let h=a.headers.origin,g=a.headers["sec-fetch-site"];if(h!==void 0&&h!==d||g==="cross-site"||g==="same-site"){c.writeHead(403).end();return}if(a.method!=="GET"&&a.method!=="POST"||!m.methods.includes(a.method)){c.writeHead(405,{allow:m.methods.join(", ")}).end();return}let y=new AbortController;c.once("close",()=>y.abort());let v=a.method==="POST"?Fw.toWeb(a):void 0,k={method:a.method,headers:a.headers,body:v,duplex:"half",signal:y.signal},T=await m.fetch(new Request(f,k));c.writeHead(T.status,Object.fromEntries(T.headers)),T.body===null?c.end():await Lw(Fw.from(T.body),c)}catch(f){if(c.destroyed)return;console.error("[dsh-palace:localhost]",f),c.headersSent?c.destroy():c.writeHead(500).end("\u5BAB\u6BBF\u7F51\u9875\u8BF7\u6C42\u5931\u8D25")}}),o=a=>(n.listen(a,Uw),sO(n,"listening"));try{await o(t)}catch(a){if(a.code!=="EADDRINUSE")throw a;await o(0)}n.unref();let{address:s,port:i}=n.address();return{url:`http://${s}:${i}/`,close:()=>{n.close(),n.closeAllConnections()}}}async function pO(){let e=process.env.DSH_PALACE_DATA_DIR,t=e??Ii(Bw(),"Documents","dsh-palace-data");if(!lO(t))throw new Error("DSH_PALACE_DATA_DIR \u5FC5\u987B\u662F\u6570\u636E\u76EE\u5F55\u7684\u7EDD\u5BF9\u8DEF\u5F84");let r=process.argv.includes("--install"),n=fO(import.meta.url);if(r&&n.split(dO).includes("_npx"))throw new Error("npx \u7F13\u5B58\u91CC\u7684\u8DEF\u5F84\u53EF\u80FD\u5931\u6548\u3002\u8BF7\u8FD0\u884C npm install -g dsh-palace && dsh-palace-mcp --install");let o=r&&e===void 0&&!uO(Ii(t,"palace.json")),s=new xs(t,{create:o});if(r){o&&await vh(s);let c=Ii(process.env.CODEX_HOME||Ii(Bw(),".codex"),"config.toml");Cw(c,n,e),console.error("Memory Palace \u5DF2\u5199\u5165 Codex \u914D\u7F6E\uFF0C\u8BF7\u91CD\u542F\u684C\u9762\u7AEF\u3002");return}let i=await Vw(s),a=Tw(s,i.url);a.onclose=i.close,process.stdin.once("end",()=>{a.close()}),await a.connect(new gs).catch(c=>{throw i.close(),c})}pO().catch(e=>{console.error(`\u65E0\u6CD5\u542F\u52A8 Memory Palace MCP\uFF1A${e.message}\u3002\u8BF7\u786E\u8BA4 Harness \u6570\u636E\u76EE\u5F55\u548C DSH_PALACE_DATA_DIR \u8BBE\u7F6E\u3002`),process.exitCode=1});
|