dsh-palace 1.2.0 → 1.3.0
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 +59 -16
- package/client/client.js +34 -21
- package/lib/index.js +209 -116
- package/lib/mcp.js +136 -0
- package/lib/palace-web.js +890 -0
- package/package.json +16 -4
package/lib/mcp.js
ADDED
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
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,C._)`+${o}`);return;case"integer":n.elseIf((0,C._)`${i} === "boolean" || ${o} === null
|
|
6
|
+
|| (${i} === "string" && ${o} && ${o} == +${o} && !(${o} % 1))`).assign(a,(0,C._)`+${o}`);return;case"boolean":n.elseIf((0,C._)`${o} === "false" || ${o} === 0 || ${o} === null`).assign(a,!1).elseIf((0,C._)`${o} === "true" || ${o} === 1`).assign(a,!0);return;case"null":n.elseIf((0,C._)`${o} === "" || ${o} === 0 || ${o} === false`),n.assign(a,null);return;case"array":n.elseIf((0,C._)`${i} === "string" || ${i} === "number"
|
|
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},
|
|
8
|
+
missingProperty: ${n},
|
|
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(`
|
|
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
|
+
${r.join(`
|
|
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 ${k}_ab = false;
|
|
16
|
+
for (let i = 0; i < ${k}.issues.length; i++) {
|
|
17
|
+
const iss = ${k}.issues[i];
|
|
18
|
+
iss.path = iss.path ? [${N}, ...iss.path] : [${N}];
|
|
19
|
+
payload.issues.push(iss);
|
|
20
|
+
if (iss.continue !== true) ${k}_ab = true;
|
|
21
|
+
}
|
|
22
|
+
if (${k}_ab && ctx && ctx.abortEarly) {
|
|
23
|
+
payload.value = newResult;
|
|
24
|
+
return payload;
|
|
25
|
+
}`;g.write("const input = payload.value;");let $=Object.create(null),O=0;for(let k of m.allKeys)$[k]=`key_${O++}`;g.write(o?"const newResult = memo.alloc(inst, payload, {}, ctx);":"const newResult = {};");for(let k of m.allKeys){if(k==="__proto__")continue;let N=$[k],se=typeof k=="symbol"?`syms[${h.indexOf(k)}]`:Ei(k),Dt=`${se} in input`,sr=p[k],at=sr?._zod?.optin,ir=at!==void 0,co=sr?._zod?.optout==="optional";if(g.write(`const ${N} = ${w(se)};`),ir&&co){let uo=at==="optional"?`${N}_present`:`${N}.value !== undefined || ${N}_present`;g.write(`
|
|
26
|
+
const ${N}_present = ${Dt};
|
|
27
|
+
if (!${N}.issues.length || ${N}_present) {
|
|
28
|
+
if (${N}.issues.length) {${v(N,se)}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
if (${uo}) {
|
|
32
|
+
newResult[${se}] = ${N}.value;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
`)}else ir?(g.write(`
|
|
37
|
+
if (${N}.issues.length) {${v(N,se)}
|
|
38
|
+
}
|
|
39
|
+
`),at==="defaulted"?g.write(`newResult[${se}] = ${N}.value;`):g.write(`
|
|
40
|
+
if (${N}.value !== undefined || ${Dt}) {
|
|
41
|
+
newResult[${se}] = ${N}.value;
|
|
42
|
+
}
|
|
43
|
+
`)):g.write(`
|
|
44
|
+
const ${N}_present = ${Dt};
|
|
45
|
+
if (${N}.issues.length) {${v(N,se)}
|
|
46
|
+
}
|
|
47
|
+
if (!${N}_present && !${N}.issues.length) {
|
|
48
|
+
payload.issues.push({
|
|
49
|
+
code: "invalid_type",
|
|
50
|
+
expected: "nonoptional",
|
|
51
|
+
input: undefined,
|
|
52
|
+
path: [${se}]
|
|
53
|
+
});
|
|
54
|
+
if (ctx && ctx.abortEarly) {
|
|
55
|
+
payload.value = newResult;
|
|
56
|
+
return payload;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
if (${N}_present) {
|
|
61
|
+
newResult[${se}] = ${N}.value;
|
|
62
|
+
}
|
|
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>
|
|
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),T$(r)}clear(){this._buffer=void 0}};function T$(e){return Vm.parse(JSON.parse(e))}function Xm(e){return JSON.stringify(e)+`
|
|
68
|
+
`}var ds=class{constructor(t=Qm.stdin,r=Qm.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 ls({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=Xm(t);this._stdout.write(n)?r():this._stdout.once("drain",r)})}};function Ua(){return{schema:2,cells:[]}}function Ft(e,t=null){return{schema:2,id:e,source:t,chapters:[],cards:[],inspirations:[]}}function Lt(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 ps(e,t=vn()){if(e.targetDate===void 0)return;let{done:r,total:n}=Lt(e),o=n-r,s=O$(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 rh(e,t=vn()){let{done:r,total:n}=Lt(e),o=ps(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}:{},...eh(e)!==void 0?{period:eh(e)}:{},...th(e,r,n)!==void 0?{percent:th(e,r,n)}:{}}}function eh(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:fs(e.finishedAt),end:fs(e.finishedAt)}:void 0;let r=fs(t.reduce((o,s)=>o<s?o:s));if(!e.finishedAt)return{start:r};let n=fs(e.finishedAt);return{start:r<n?r:n,end:n}}function fs(e){return/^\d{4}-\d{2}-\d{2}$/.test(e)?e.slice(0,7):vn(new Date(e)).slice(0,7)}function th(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 xt(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 vn(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 O$(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 nh(e){return typeof e=="string"&&/^\d{4}-\d{2}-\d{2}$/.test(e)}import{randomBytes as R$}from"node:crypto";import{cpSync as A$,existsSync as vr,lstatSync as C$,mkdirSync as ms,mkdtempSync as N$,readdirSync as oh,readFileSync as sh,renameSync as ah,rmSync as hs,statSync as j$,writeFileSync as D$}from"node:fs";import{join as ze}from"node:path";var b=class extends Error{};function Me(e){return`${e}_${R$(5).toString("hex")}`}function qe(){return new Date().toISOString()}var ch=/^c_[0-9a-f]{10}$/,Z$=new Set(["book","note","group"]);function St(e){if(typeof e!="string"||!ch.test(e))throw new b("\u683C\u5B50 id \u65E0\u6548")}function _s(e){return typeof e?.schema=="number"&&e.schema>2?e.schema:2}function M$(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"||!Z$.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:_s(e),cells:e.cells}}function q$(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{...Ft(t),...e,schema:_s(e),id:t,chapters:e.chapters??[],cards:e.cards??[],inspirations:e.inspirations??[]}}function gs(e){let t=j$(e);return`${t.mtimeMs}:${t.size}`}function ih(e,t){let r=`${e}.${process.pid}.tmp`;return D$(r,JSON.stringify(t,null,2)+`
|
|
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 mI(e){return`---
|
|
71
|
+
${[...e.summary?[`summary: ${e.summary}`]:[],...e.topics?.length?[`topics: ${JSON.stringify(e.topics)}`]:[],`writtenAt: ${e.writtenAt}`].join(`
|
|
72
|
+
`)}
|
|
73
|
+
---
|
|
74
|
+
${e.body}
|
|
75
|
+
`}var qr=class{dir;cellsDir;linksFile;cache={stamp:"",records:[]};store;constructor(t){this.store=t,this.dir=to(t.dir,"memory"),this.cellsDir=to(this.dir,"cells"),this.linksFile=to(t.dir,"links.jsonl")}pageFile(t){return t==="me"?to(this.dir,"me.md"):(St(t),to(this.cellsDir,`${t}.md`))}readPage(t){let r=this.pageFile(t);if(Wu(r))try{return pI(Yu(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 b("\u6B63\u6587\u4E0D\u80FD\u4E3A\u7A7A");let n=r.body.trim(),o=Xu(n);if(o>no)throw new b(`\u6B63\u6587 ${o} \u5B57\uFF0C\u4E0A\u9650 ${no} \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&&Xu(s)>N_)throw new b(`\u4E00\u53E5\u8BDD\u6982\u62EC\u6700\u591A ${N_} \u5B57`);let i;if(r.topics!==void 0){if(!Array.isArray(r.topics))throw new b("\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>D_)throw new b(`\u4E3B\u9898\u8BCD\u6700\u591A ${D_} \u4E2A`)}let a={...t!=="me"&&s?{summary:s}:{},...t!=="me"&&i?.length?{topics:i}:{},body:n,writtenAt:qe()},c=this.pageFile(t);this.store.snapshotBeforeWrite(),lI(this.cellsDir,{recursive:!0});let u=`${c}.${process.pid}.tmp`;return fI(u,mI(a),"utf8"),dI(u,c),a}debt(t){let r=this.readPage(t)?.writtenAt??"",n=0;for(let o of ro(this.store.getItem(t)).values())o>r&&(n+=1);return n}records(){if(!Wu(this.linksFile))return[];let t=C_(this.linksFile),r=`${t.mtimeMs}:${t.size}`;if(r===this.cache.stamp)return this.cache.records;let n=[];for(let o of Yu(this.linksFile,"utf8").split(`
|
|
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=(Wu(this.linksFile)?C_(this.linksFile).size:0)>0&&Yu(this.linksFile,"utf8").at(-1)!==`
|
|
77
|
+
`;uI(this.linksFile,(n?`
|
|
78
|
+
`:"")+JSON.stringify(t)+`
|
|
79
|
+
`,"utf8"),this.store.rev+=1}cellOf(t,r){St(t);let n=this.store.getPalace().cells.find(o=>o.id===t);if(n===void 0||!r&&n.kind==="group")throw new b("\u683C\u5B50\u4E0D\u5B58\u5728");return n}lastCut(t,r){let n="";for(let o of this.records())o.type==="cut"&&nr(o.from,o.to)===nr(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 b("\u4E0D\u80FD\u8FDE\u5230\u81EA\u5DF1");if(typeof t.why!="string"||t.why.trim()==="")throw new b("\u8981\u5199\u4E00\u53E5\u7406\u7531");let o=t.why.trim().replace(/\n/g," ");if(Xu(o)>j_)throw new b(`\u7406\u7531\u6700\u591A ${j_} \u5B57`);if(!Array.isArray(t.evidence))throw new b("evidence \u5E94\u4E3A\u5361\u7247 / \u7075\u611F id \u7684\u6570\u7EC4");let s=[...new Set(t.evidence.filter(d=>typeof d=="string"))],i=ro(this.store.getItem(r.id)),a=ro(this.store.getItem(n.id)),c=s.filter(d=>!i.has(d)&&!a.has(d));if(c.length>0)throw new b(`\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 b("\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 b("\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=>nr(d.from,d.to)===nr(r.id,n.id)).flatMap(d=>d.evidence));if(s.every(d=>u.has(d)))throw new b("\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:Me("l"),from:r.id,to:n.id,why:o,evidence:s,...t.sessionId?{sessionId:t.sessionId}:{},createdAt:qe()};return this.append(l),l}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:qe()})}validLinks(){let t=new Map(this.store.getPalace().cells.filter(s=>s.kind!=="group").map(s=>[s.id,s])),r=new Map,n=s=>{let i=r.get(s);return i===void 0&&(i=ro(this.store.getItem(s)),r.set(s,i)),i},o=new Map;for(let s of this.records())if(s.type==="cut"){let i=nr(s.from,s.to);s.createdAt>(o.get(i)??"")&&o.set(i,s.createdAt)}return this.records().filter(s=>{if(s.type!=="link"||!t.has(s.from)||!t.has(s.to)||s.createdAt<=(o.get(nr(s.from,s.to))??""))return!1;let i=Array.isArray(s.evidence)?s.evidence:[];return i.some(a=>n(s.from).has(a))&&i.some(a=>n(s.to).has(a))})}arcs(){let t=new Map;for(let r of this.validLinks()){let n=nr(r.from,r.to);t.set(n,[...t.get(n)??[],r])}return[...t.values()].map(r=>{let n=r.reduce((o,s)=>s.createdAt>=o.createdAt?s:o);return{from:n.from,to:n.to,strands:r.length,why:n.why,lastAt:n.createdAt,links:r}}).sort((r,n)=>n.strands-r.strands||(n.lastAt>r.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 ro(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
|
+
- \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
|
+
- \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
|
+
- \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 ${no} \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
|
+
- \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,$)=>$.at>v.at?1:-1),m=[],h=[],g=u.join(`
|
|
86
|
+
|
|
87
|
+
`).length;for(let[v,{c:$,at:O}]of p.entries()){let k=this.readPage($.id),N=`- ${$.title} id=${$.id}${c($)?` \u3014${c($)}\u3015`:""}`+(k?.summary?` \xB7 ${k.summary}`:"")+(k?.topics?.length?` \xB7 ${k.topics.join("\u3001")}`:"")+` \xB7 ${O.slice(0,7)}`;($.id===s?.id||i.has($.id)||v<30)&&g+N.length<r*.7?(m.push(N),g+=N.length+1):h.push($.title)}let w=`### \u5BAB\u6BBF\u7D22\u5F15\uFF08\u6807\u9898 \xB7 \u4E00\u53E5\u8BDD \xB7 \u4E3B\u9898\u8BCD \xB7 \u6700\u8FD1\u6D3B\u8DC3\u6708\u4EFD\uFF09
|
|
88
|
+
${m.join(`
|
|
89
|
+
`)}`;h.length>0&&(w+=`
|
|
90
|
+
\u5176\u4F59 ${h.length} \u683C\uFF1A${h.join("\u3001").slice(0,Math.max(200,r-g-800))}`),u.push(w)}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
|
+
${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(w=>w.from===s.id||w.to===s.id).slice(0,8);g.length>0&&(h+=`
|
|
93
|
+
\u7535\u5F27\uFF1A
|
|
94
|
+
${g.map(w=>`- \u2194 ${a(w.from===s.id?w.to:w.from)}\uFF08${w.strands} \u80A1\uFF09\uFF1A${w.why}`).join(`
|
|
95
|
+
`)}`),u.push(h)}let f=u.join(`
|
|
96
|
+
|
|
97
|
+
`);return f.length>r?f.slice(0,r):f}};var Qu={book:"\u4E66",note:"\u7B14\u8BB0",group:"\u5206\u7EC4"},M_={excerpt:"\u6458\u5F55",thought:"\u60F3\u6CD5",mistake:"\u9519\u9898"};function Z_(e,t,r){let n=`${Qu[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=Lt(o),i=ps(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 hI(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(Z_(e,o,t));for(let s of r.filter(i=>i.parentId===o.id))n.push(` ${Z_(e,s,t)}`)}return n.join(`
|
|
98
|
+
`)}function gI(e,t){let r=e.getPalace().cells.find(a=>a.id===t);if(r===void 0||r.kind==="group")throw new b("\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
|
+
${a.sections.map(u=>` - ${u.done?"[x]":"[ ]"} ${u.title} (section_id=${u.id})`).join(`
|
|
100
|
+
`)}`).join(`
|
|
101
|
+
`),s=n.cards.slice(-20).map(a=>`- ${M_[a.type]} ${a.id}\uFF1A${(a.quote??a.note??"").slice(0,60)}`).join(`
|
|
102
|
+
`),i=n.inspirations.slice(-10).map(a=>`- ${a.id} ${a.createdAt.slice(0,10)} ${a.title}`).join(`
|
|
103
|
+
`);return`\u300A${r.title}\u300B\u76EE\u5F55\uFF1A
|
|
104
|
+
${o}`+(s?`
|
|
105
|
+
|
|
106
|
+
\u6700\u8FD1\u7684\u5361\u7247\uFF1A
|
|
107
|
+
${s}`:"")+(i?`
|
|
108
|
+
|
|
109
|
+
\u7075\u611F\uFF1A
|
|
110
|
+
${i}`:"")}function yI(e,t){let r=xt(e,t.sectionId);return r?` ${r.chapter.title} \u203A ${r.section.title}`:""}async function Be(e){try{return await e()}catch(t){if(t instanceof b)return`\u64CD\u4F5C\u5931\u8D25\uFF1A${t.message}`;throw t}}function _I(e){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\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(t,r){return Be(async()=>t.item_id===void 0?hI(e,r.highlightId):gI(e,t.item_id))}}}function q_(e,t,r){return[_I(e),{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\u89C6\u9891\u94FE\u63A5\u6309\u5E73\u53F0\u5904\u7406\uFF1AB \u7AD9\uFF08\u5E26 BV \u53F7\u6216 b23.tv \u77ED\u94FE\uFF09\u76F4\u63A5\u4F20 url\uFF0C\u4F1A\u81EA\u52A8\u8BFB\u51FA\u5206 P / \u5408\u96C6\u548C\u6BCF\u4E00\u96C6\u7684\u94FE\u63A5\uFF0Ctitle \u53EF\u4E0D\u586B\uFF1BYouTube\uFF1A\u4F20 url \u548C\u89C6\u9891\u6216\u64AD\u653E\u5217\u8868\u7684\u6807\u9898\uFF1B\u5176\u4ED6\u5E73\u53F0\uFF08Netflix\u3001\u7231\u5947\u827A\u3001\u8292\u679C TV\u3001\u817E\u8BAF\u89C6\u9891\u3001\u8BFE\u7A0B\u7F51\u7AD9\u2026\u2026\uFF09\uFF1A\u4ECE\u94FE\u63A5\u548C\u7528\u6237\u7684\u8BDD\u8BA4\u51FA\u4F5C\u54C1\uFF0Ctitle \u7528\u4F5C\u54C1\u7684\u6B63\u5F0F\u540D\uFF0C\u4F20 url\u3002\u8FD9\u4E24\u7C7B\u5EFA\u597D\u540E\u5148\u505C\u4E0B\uFF1A\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\u5728\u539F\u8BDD\u91CC\u5DF2\u7ECF\u8981\u4E86\u76EE\u5F55\u5C31\u76F4\u63A5\u67E5\u3002\u67E5\u7684\u65F6\u5019\u5206\u5B63\u5C31\u4E00\u5B63\u4E00\u7AE0\uFF0C\u7528 palace_set_outline \u5199\u5165\uFF08\u6BCF\u96C6\u5C3D\u91CF\u5E26 url\uFF09\uFF1B\u8FDE\u8F7D\u4E2D\u7684\u53EA\u5199\u5DF2\u7ECF\u67E5\u5B9E\u7684\u96C6\u6570\uFF0C\u67E5\u4E0D\u5230\u94FE\u63A5\u5C31\u53EA\u5199\u6807\u9898\u3002\u540C\u6837\u7684\u89C4\u77E9\u9002\u7528\u4E8E\u4EFB\u4F55\u8981\u82B1\u65F6\u95F4\u7684\u8865\u5168\uFF08\u4E0A\u7F51\u67E5\u76EE\u5F55\u3001\u8BFB\u5F88\u591A\u9875\u2026\u2026\uFF09\uFF1A\u5148\u5EFA\u683C\u5B50\uFF0C\u518D\u95EE\u7528\u6237\uFF1B\u51E0\u79D2\u5185\u5C31\u80FD\u5B8C\u6210\u7684\uFF08B \u7AD9\u63A5\u53E3\u3001PDF \u4E66\u7B7E\u3001EPUB \u76EE\u5F55\uFF09\u7167\u65E7\u81EA\u52A8\u505A\u3002\u6CA1\u6709\u539F\u6587\u3001\u4E5F\u4E0D\u9700\u8981\u6309\u96C6\u6253\u52FE\u7684\uFF08\u6BD4\u5982\u53EA\u662F\u60F3\u804A\u4E00\u90E8\u5267\uFF09\uFF0C\u7528 kind=note\u3002",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(n,o){return Be(async()=>{if(n.kind!=="book"){let c=await zt(e,{kind:n.kind,title:n.title,subtitle:n.subtitle,parentId:n.parent_id});return`\u5DF2\u65B0\u5EFA${Qu[c.kind]}\u300C${c.title}\u300D id=${c.id}`}let s=await r.addBook({file:n.path,url:n.url,title:n.title,subtitle:n.subtitle,parentId:n.parent_id,targetDate:n.target_date},o.signal),i=e.getItem(s.id),a=Lt(i).total;return i.source?.type==="video"?a>0?`\u5DF2\u6DFB\u52A0\u89C6\u9891\u300A${s.title}\u300B id=${s.id}\uFF0C\u5171 ${a} \u96C6\u3002`:`\u5DF2\u6DFB\u52A0\u89C6\u9891\u300A${s.title}\u300B id=${s.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`:i.source?.type==="epub"?`\u5DF2\u6DFB\u52A0\u300A${s.title}\u300B id=${s.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${s.title}\u300B id=${s.id}\uFF0C\u5171 ${i.source?.type==="pdf"?i.source.pageCount:"?"} \u9875\u3002`+(a>0?`\u5DF2\u4ECE PDF \u4E66\u7B7E\u8BFB\u51FA\u76EE\u5F55\uFF1A${i.chapters.length} \u7AE0 ${a} \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(n){return Be(async()=>{let o=e.getPalace().cells.find(i=>i.id===n.item_id);if(o===void 0)throw new b("\u683C\u5B50\u4E0D\u5B58\u5728");let s=o.kind==="group"?void 0:e.getItem(o.id);return await vs(e,{id:o.id}),`\u5DF2\u5220\u9664${Qu[o.kind]}\u300C${o.title}\u300D`+(s?`\uFF08\u5361\u7247 ${s.cards.length} \u5F20\u3001\u7075\u611F ${s.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(n){return Be(async()=>{let o=e.getItem(n.item_id).source;if(o?.type!=="pdf")throw new b("\u8FD9\u4E2A\u683C\u5B50\u4E0D\u662F PDF");let s=[...new Set(n.pages)].slice(0,30),i=await r.readPageTexts(o.path,s),a=i.filter(u=>u.text.length<r.scannedThreshold).map(u=>u.page),c=i.map(u=>`=== \u7B2C ${u.page} \u9875 ===
|
|
111
|
+
${u.text||"\uFF08\u65E0\u6587\u5B57\uFF09"}`).join(`
|
|
112
|
+
|
|
113
|
+
`);return a.length>0&&(c+=`
|
|
114
|
+
|
|
115
|
+
\u6CE8\u610F\uFF1A\u7B2C ${a.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\u5426\u5219\u8BF7\u7528\u6237\u5728\u53F3\u4FA7\u7B14\u8BB0\u672C\u91CC\u91CD\u65B0\u52FE\u9009\u8FD9\u4E9B\u9875\uFF08\u4F1A\u628A\u9875\u9762\u56FE\u7247\u53D1\u5230\u5BF9\u8BDD\uFF09\u3002`),c})}},{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(n){return Be(async()=>{let o=!1;try{o=e.getItem(String(n.item_id)).source?.type==="video"}catch{}let s=c=>o?typeof c.url=="string"&&/^https?:\/\/\S+$/.test(c.url.trim())?{loc:c.url.trim()}:{}:Number.isInteger(c.page)?{loc:String(c.page)}:{},i=n.chapters.map(c=>({title:c.title,sections:(c.sections??[]).map(u=>({title:u.title,...s(u)}))})),a=await xs(e,{id:n.item_id,chapters:i,source:"ai"});return`\u5DF2\u5199\u5165\u76EE\u5F55\uFF1A${a.chapters.length} \u7AE0 ${Lt(a).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(n){return Be(async()=>{let o=[];for(let s of n.items){let i=await $s(e,{id:s.item_id,targetDate:s.target_date}),a=e.getPalace().cells.find(u=>u.id===s.item_id)?.title??s.item_id,c=ps(i);o.push(`\u300A${a}\u300B\u2192 ${i.targetDate}`+(c?.perDay!==void 0?`\uFF0C\u5269 ${c.remaining} \u8282\uFF0C\u6BCF\u5929\u7EA6 ${c.perDay} \u8282`:""))}return`\u5DF2\u8BBE\u7F6E\uFF1A
|
|
116
|
+
${o.join(`
|
|
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\u3002image \u586B\u5BF9\u8BDD\u91CC\u56FE\u7247\u7684\u672C\u5730\u53EA\u8BFB\u8DEF\u5F84\uFF08\u56FE\u7247\u8BF4\u660E\u4E2D\u7684 read-only path\uFF09\uFF0C\u6CA1\u6709\u8DEF\u5F84\u5C31\u586B\u9644\u4EF6 id\uFF08sha256:...\uFF09\u3002item_id \u4E0D\u586B\u65F6\u8BB0\u5230\u7528\u6237\u5F53\u524D\u6253\u5F00\u7684\u683C\u5B50\uFF1Bsection_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:"\u622A\u56FE\u7684\u672C\u5730\u8DEF\u5F84\u6216\u9644\u4EF6 id"},item_id:{type:"string"},section_id:{type:"string"}},async execute(n,o){return Be(async()=>{let s=n.item_id,i=e.getItem(s),a=n.section_id??(n.type==="thought"?void 0:Lt(i).current?.section.id),c=r.saveImage(n.image),u=await Ss(e,{id:s,type:n.type,quote:n.quote,note:n.note,answer:n.answer,image:c,sectionId:a});return`\u5DF2\u8BB0\u5165\u300A${e.getPalace().cells.find(d=>d.id===s)?.title}\u300B${yI(e.getItem(s),u)}\u7684${M_[u.type]}`+(n.image?c?"\uFF0C\u539F\u56FE\u5DF2\u4FDD\u5B58\u3002":"\u3002\uFF08\u6CA1\u6709\u627E\u5230\u539F\u56FE\uFF09":"\u3002")+(o.nudge?.(s,"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\u3002item_id \u4E0D\u586B\u65F6\u5B58\u5230\u7528\u6237\u5F53\u524D\u6253\u5F00\u7684\u683C\u5B50\u3002",parameters:{title:{type:"string",required:!0},body:{type:"string",required:!0},item_id:{type:"string"},card_ids:{type:"array",items:{type:"string"},description:"\u53EF\u9009\uFF1A\u8FD9\u6B21\u5BF9\u8BDD\u6D89\u53CA\u7684\u5361\u7247"}},async execute(n,o){return Be(async()=>{let s=n.item_id,i=await ks(e,{id:s,title:n.title,body:n.body,cardIds:n.card_ids,...o.attribution});return`\u5DF2\u5B58\u5230\u300A${e.getPalace().cells.find(c=>c.id===s)?.title}\u300B\u7684\u7075\u611F\uFF1A\u300C${i.title}\u300D id=${i.id}`+(o.nudge?.(s,"link")??"")+(o.nudge?.(s,"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\u5F53\u524D\u683C\u5B50\u548C me \u5DF2\u7ECF\u5728\u5BF9\u8BDD\u80CC\u666F\u91CC\uFF0C\u8BFB\u522B\u7684\u683C\u5B50\u65F6\u624D\u9700\u8981\u8C03\u7528\u3002",parameters:{target:{type:"string",required:!0,description:"\u683C\u5B50 id \u6216 me"}},async execute(n){return Be(async()=>{let o=t.readPage(n.target);if(n.target!=="me"){let s=e.getPalace().cells.find(a=>a.id===n.target);if(s===void 0||s.kind==="group")throw new b("\u683C\u5B50\u4E0D\u5B58\u5728");let i=t.debt(s.id);return o===void 0?`\u300A${s.title}\u300B\u8FD8\u6CA1\u6709 wiki\u3002`+(i>0?`\u5DF2\u6709 ${i} \u6761\u5361\u7247 / \u7075\u611F\uFF0C\u53EF\u4EE5\u7528 palace_overview \u67E5\u770B\u540E\u5199\u4E00\u9875\u3002`:""):`\u300A${s.title}\u300Bwiki\uFF08${o.writtenAt.slice(0,10)}\uFF09
|
|
118
|
+
\u4E00\u53E5\u8BDD\uFF1A${o.summary??"\uFF08\u65E0\uFF09"}
|
|
119
|
+
\u4E3B\u9898\u8BCD\uFF1A${o.topics?.join("\u3001")??"\uFF08\u65E0\uFF09"}
|
|
120
|
+
|
|
121
|
+
${o.body}`+(i>0?`
|
|
122
|
+
|
|
123
|
+
\uFF08\u8FD9\u4E00\u9875\u4E4B\u540E\u65B0\u589E\u4E86 ${i} \u6761\u5361\u7247 / \u7075\u611F\uFF09`:"")}return o===void 0?"\u8FD8\u6CA1\u6709\u5173\u4E8E\u7528\u6237\u7684\u8BB0\u5F55\u3002":`\u5173\u4E8E\u7528\u6237\uFF08${o.writtenAt.slice(0,10)}\uFF09\uFF1A
|
|
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+=`
|
|
125
|
+
`));o.push({page:s,text:c.replace(/[ \t]+/g," ").replace(/\n{3,}/g,`
|
|
126
|
+
|
|
127
|
+
`).trim()}),i.cleanup()}return o}finally{await n()}}var yi=20;function nw(e){return e.startsWith("~/")?so(tw(),e.slice(2)):e}async function wi(e,t,r,{readVideo:n=!0}={}){let o=()=>{if(r?.aborted)throw new b("\u5DF2\u53D6\u6D88")},s,i,a=[],c;if(typeof t.url=="string"&&t.url.trim()!==""){let u=t.url.trim();if(!n||!V_(u)){if(!/^https?:\/\/\S+$/.test(u))throw new b("\u89C6\u9891\u94FE\u63A5\u8981\u4EE5 http:// \u6216 https:// \u5F00\u5934");if(typeof t.title!="string"||t.title.trim()==="")throw new b(n?"\u4E0D\u662F B \u7AD9\u94FE\u63A5\u65F6\u8981\u586B\u4F5C\u54C1\u540D":"\u89C6\u9891\u94FE\u63A5\u8981\u586B\u4F5C\u54C1\u540D");return o(),zt(e,{kind:"book",title:t.title.trim(),subtitle:t.subtitle,source:{type:"video",url:u},parentId:t.parentId,targetDate:t.targetDate})}let l=await B_(u,r).catch(d=>{throw o(),new b(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=nw(t.file.trim().replace(/^['"]|['"]$/g,""));if(!rw(u))throw new b("\u8BF7\u63D0\u4F9B PDF \u7684\u5B8C\u6574\u8DEF\u5F84\uFF08\u4EE5 / \u5F00\u5934\uFF09");if(!tl(u)||!RI(u).isFile())throw new b(`\u627E\u4E0D\u5230\u6587\u4EF6\uFF1A${u}`);let l=_i(u).toLowerCase();if(l!==".pdf"&&l!==".epub")throw new b("\u76EE\u524D\u53EA\u652F\u6301 PDF \u548C EPUB \u6587\u4EF6");if(l===".epub"){if(!AI(u))throw new b("\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=ew(u,l),typeof t.title=="string"&&t.title.trim()!==""&&(i=t.title.trim()),o(),zt(e,{kind:"book",title:i,subtitle:t.subtitle,source:s,parentId:t.parentId,targetDate:t.targetDate})}let d=await Q_(u).catch(f=>{throw new b(`PDF \u6253\u4E0D\u5F00\uFF1A${f.message}`)});s={type:"pdf",path:u,pageCount:d.pageCount},i=ew(u,_i(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 b("\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(),zt(e,{kind:"book",title:i,subtitle:t.subtitle,source:s,parentId:t.parentId,targetDate:t.targetDate,outline:a,outlineSource:c})}function AI(e){let t=II(e,"r");try{let r=Buffer.alloc(4);return OI(t,r,0,4,0)===4&&r.equals(Buffer.from([80,75,3,4]))}finally{zI(t)}}function CI(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??so(tw(),".dsh"),n=so(r,"attachments","v1","objects",t.slice(0,2));if(!tl(n))return;let o=TI(n).find(s=>s.startsWith(t));return o===void 0?void 0:so(n,o)}var NI=new Set([".png",".jpg",".jpeg",".webp",".gif"]);function ow(e,t){if(typeof t!="string"||t.trim()==="")return;let r=nw(t.trim().replace(/^['"]|['"]$/g,"")),n=rw(r)&&tl(r)?r:CI(r);if(n===void 0)return;let o=NI.has(_i(n).toLowerCase())?_i(n).toLowerCase():".png",s=`${Me("img")}${o}`;return e.assertWritable(),e.snapshotBeforeWrite(),EI(e.imagesDir,{recursive:!0}),PI(n,so(e.imagesDir,s)),s}var sw=new Set(["palace_add","palace_add_card"]),DI=new Set(["palace_overview","palace_read","palace_wiki_read"]);function iw(e,t){let r=new qr(e),n=q_(e,r,{addBook:(a,c)=>wi(e,a,c,{readVideo:!1}),readPageTexts:gi,scannedThreshold:yi,saveImage:a=>typeof a=="string"&&jI(a)?ow(e,a):void 0}).filter(({name:a})=>DI.has(a)||sw.has(a)),o=new Mr,s=new Map([...n,F_(r),L_(t)].map(({name:a,description:c,parameters:u,execute:l})=>{let d=[],p={type:"object",properties:Object.fromEntries(Object.entries(u).map(([h,g])=>{let{required:w,...v}=g;return(w||a==="palace_add_card"&&h==="item_id")&&d.push(h),a==="palace_add_card"&&h==="image"?[h,{...v,description:"\u622A\u56FE\u7684\u672C\u673A\u7EDD\u5BF9\u8DEF\u5F84"}]:[h,v]})),required:d,additionalProperties:!1};c=c.replace("\uFF0C\u4EE5\u53CA\u7528\u6237\u5F53\u524D\u6253\u5F00\u7684\u662F\u54EA\u4E2A\u683C\u5B50","").replace("image \u586B\u5BF9\u8BDD\u91CC\u56FE\u7247\u7684\u672C\u5730\u53EA\u8BFB\u8DEF\u5F84\uFF08\u56FE\u7247\u8BF4\u660E\u4E2D\u7684 read-only path\uFF09\uFF0C\u6CA1\u6709\u8DEF\u5F84\u5C31\u586B\u9644\u4EF6 id\uFF08sha256:...\uFF09\u3002","image \u586B\u672C\u673A\u56FE\u7247\u7684\u7EDD\u5BF9\u8DEF\u5F84\u3002").replace("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"),a==="palace_add"&&(c=c.split("\u89C6\u9891\u94FE\u63A5\u6309\u5E73\u53F0\u5904\u7406\uFF1A")[0]+"\u89C6\u9891\u586B url \u548C\u6B63\u5F0F\u4F5C\u54C1\u540D title\uFF0C\u5148\u4FDD\u5B58\u94FE\u63A5\u3002");let m={name:a,description:c,inputSchema:p,annotations:{readOnlyHint:!sw.has(a),destructiveHint:!1}};return[a,{tool:m,execute:l,validate:o.getValidator(p)}]})),i=new hi({name:"dsh-palace",version:"1.0.0"},{capabilities:{tools:{}},jsonSchemaValidator:o});return i.setRequestHandler(Ma,()=>({tools:[...s.values()].map(({tool:a})=>a)})),i.setRequestHandler(_n,async({params:a},{signal:c})=>{let u=s.get(a.name);if(!u)throw new T(A.InvalidParams,"\u672A\u77E5\u5DE5\u5177");let l=u.validate(a.arguments??{});if(!l.valid)throw new T(A.InvalidParams,l.errorMessage);let d=await u.execute(l.data,{signal:c});return/^操作失败:(?:palace\.json|items\/[^\n]+\.json) 刚被其他程序修改过,请重试$/.test(d)&&(d="\u64CD\u4F5C\u5931\u8D25\uFF1A\u6570\u636E\u521A\u88AB\u522B\u5904\u6539\u8FC7\uFF0C\u8BF7\u91CD\u8BD5"),{content:[{type:"text",text:d}],isError:d.startsWith("\u64CD\u4F5C\u5931\u8D25\uFF1A")}}),i}import{randomUUID as ZI}from"node:crypto";import{lstatSync as aw,mkdirSync as MI,readFileSync as qI,renameSync as FI,rmSync as LI,writeFileSync as UI}from"node:fs";import{dirname as VI}from"node:path";var rl=e=>JSON.stringify(e).replace(/\u007f/g,"\\u007f"),nl=()=>new Error("\u68C0\u6D4B\u5230\u590D\u6742\u7684 MCP \u914D\u7F6E\uFF0C\u8BF7\u6309 README \u624B\u52A8\u8BBE\u7F6E dsh-palace"),ol=/(?:[\w-]+|"[^"\\]*"|'[^']*')/.source,HI=new RegExp(`^\\s*(\\[\\[?)\\s*(${ol}(?:\\s*\\.\\s*${ol})*)\\s*(\\]\\]?)\\s*(?:#.*)?$`),cw=e=>new RegExp(`^\\s*(?:${e}|"${e}"|'${e}')\\s*[.=]`);function uw(e,t){let r=`${e}.${ZI()}.tmp`;try{UI(r,t,{mode:384,flag:"wx"}),FI(r,e)}finally{LI(r,{force:!0})}}function lw(e,t,r){let n=aw(e,{throwIfNoEntry:!1});if(n&&!n.isFile())throw nl();let o=n?qI(e,"utf8"):"";if(o.includes('"""')||o.includes("'''"))throw nl();let s=o.includes(`\r
|
|
128
|
+
`)?`\r
|
|
129
|
+
`:`
|
|
130
|
+
`,i=[],a=(o.match(/[^\n]*\n|[^\n]+$/g)??[]).filter(l=>{let d=HI.exec(l.trimEnd());d&&(i=[...d[2].matchAll(new RegExp(ol,"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&&cw("mcp_servers").test(l)||i.length===1&&i[0]==="mcp_servers"&&cw("dsh-palace").test(l))throw nl();return!f}).join(""),c=["[mcp_servers.dsh-palace]",`command = ${rl(process.execPath)}`,`args = [${rl(t)}]`];r!==void 0&&c.push("","[mcp_servers.dsh-palace.env]",`DSH_PALACE_DATA_DIR = ${rl(r)}`);let u=a+(a&&!a.endsWith(`
|
|
131
|
+
`)?s:"")+c.join(s)+s;if(u!==o){if(n?uw(`${e}.bak`,o):MI(VI(e),{recursive:!0}),aw(e,{throwIfNoEntry:!1})?.mtimeMs!==n?.mtimeMs)throw new Error("Codex \u914D\u7F6E\u521A\u88AB\u522B\u5904\u6539\u8FC7\uFF0C\u8BF7\u91CD\u8BD5");uw(e,u)}}import{once as uT}from"node:events";import{createReadStream as lT}from"node:fs";import{createServer as dT}from"node:http";import{Readable as yw}from"node:stream";import{pipeline as _w}from"node:stream/promises";import{execFile as KI,spawn as il}from"node:child_process";import{createReadStream as GI,existsSync as or,statSync as WI}from"node:fs";import{homedir as YI}from"node:os";import{basename as XI,extname as QI,join as ao,normalize as eT,sep as cl}from"node:path";import{Readable as tT}from"node:stream";import{fileURLToPath as pw}from"node:url";import{execFile as BI}from"node:child_process";var JI=`ObjC.import('CoreServices')
|
|
132
|
+
function run(argv) {
|
|
133
|
+
const w = $(argv[0])
|
|
134
|
+
const r = $.DCSCopyTextDefinition($(), w, $.CFRangeMake(0, w.length))
|
|
135
|
+
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});
|